fix: integrate with signature

This commit is contained in:
2025-12-04 02:09:33 +07:00
parent 5fe9b48f2d
commit 3ad93441b2
5 changed files with 32 additions and 47 deletions
-13
View File
@@ -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}`