MCPcopy Index your code
hub / github.com/simstudioai/sim / validateWhatsAppSignature

Function validateWhatsAppSignature

apps/sim/lib/webhooks/providers/whatsapp.ts:106–121  ·  view source on GitHub ↗
(secret: string, signature: string, body: string)

Source from the content-addressed store, hash-verified

104}
105
106function validateWhatsAppSignature(secret: string, signature: string, body: string): boolean {
107 try {
108 if (!signature.startsWith('sha256=')) {
109 logger.warn('WhatsApp signature has invalid format')
110 return false
111 }
112
113 const providedSignature = signature.substring(7)
114 const computedSignature = hmacSha256Hex(body, secret)
115
116 return safeCompare(computedSignature, providedSignature)
117 } catch (error) {
118 logger.error('Error validating WhatsApp signature:', error)
119 return false
120 }
121}
122
123function buildWhatsAppIdempotencyKey(keys: Set<string>): string | null {
124 if (keys.size === 0) {

Callers 1

verifyAuthFunction · 0.85

Calls 4

hmacSha256HexFunction · 0.90
safeCompareFunction · 0.90
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected