(secret: string, signature: string, body: string)
| 15 | const logger = createLogger('WebhookProvider:Typeform') |
| 16 | |
| 17 | function validateTypeformSignature(secret: string, signature: string, body: string): boolean { |
| 18 | try { |
| 19 | if (!secret || !signature || !body) { |
| 20 | return false |
| 21 | } |
| 22 | if (!signature.startsWith('sha256=')) { |
| 23 | return false |
| 24 | } |
| 25 | const providedSignature = signature.substring(7) |
| 26 | const computedHash = hmacSha256Base64(body, secret) |
| 27 | return safeCompare(computedHash, providedSignature) |
| 28 | } catch (error) { |
| 29 | logger.error('Error validating Typeform signature:', error) |
| 30 | return false |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | export const typeformHandler: WebhookProviderHandler = { |
| 35 | async formatInput({ body, webhook }: FormatInputContext): Promise<FormatInputResult> { |
nothing calls this directly
no test coverage detected