Skip to content

Export verifyWebhookSignature as standalone function from webhooks/verify.ts #617

Description

@Kingsman-99

Description

src/webhooks/verify.ts contains signature verification logic but it is not exported as a standalone function from src/index.ts. Consumers building their own webhook receivers cannot import the verifier directly — they must copy the logic. This issue exposes it as a first-class SDK export.

Acceptance Criteria

  • verifyWebhookSignature(payload: string, signature: string, secret: string): boolean exported from src/webhooks/verify.ts
  • Uses HMAC-SHA256: crypto.createHmac('sha256', secret).update(payload).digest('hex') and compares with signature using a timing-safe comparison (crypto.timingSafeEqual)
  • Returns false (never throws) when signature is malformed or lengths differ
  • WebhookVerificationError class exported for consumers who prefer throwing — wraps verifyWebhookSignature and throws if it returns false
  • Both exported from src/index.ts
  • Unit tests: valid signature returns true, wrong secret returns false, tampered payload returns false, mismatched length returns false without throwing

Context

  • Target files: src/webhooks/verify.ts, src/index.ts
  • Must use crypto.timingSafeEqual to prevent timing attacks — not ===

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions