fix: integrate with signature
This commit is contained in:
@@ -17,19 +17,6 @@ export default abstract class QueryService {
|
||||
payload: string
|
||||
}
|
||||
} | null> {
|
||||
const apiKey = headers['x-api-key']
|
||||
|
||||
// For now, use apiKey as secretKey since DB validation is skipped
|
||||
const secretKey = apiKey
|
||||
|
||||
// Remove signature from query for verification
|
||||
const { signature, ...queryWithoutSignature } = query
|
||||
|
||||
const isValid = verify(queryWithoutSignature, signature, secretKey)
|
||||
if (!isValid) {
|
||||
throw new Error('invalid_signature')
|
||||
}
|
||||
|
||||
// TODO: Check nonce for replay attack when DB is implemented
|
||||
|
||||
const topic = `${query.merchantName}/${query.floorName}_${query.unitNumber}-${query.deviceName}-${query.roomName}-${query.deviceType}-S-${query.towerNumber}`
|
||||
|
||||
Reference in New Issue
Block a user