@hookflo/tern 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,7 @@ exports.platformAlgorithmConfigs = {
62
62
  customConfig: {
63
63
  signatureFormat: "v1={signature}",
64
64
  payloadFormat: "{id}.{timestamp}.{body}",
65
+ encoding: "base64",
65
66
  idHeader: "webhook-id",
66
67
  },
67
68
  },
package/dist/test.js CHANGED
@@ -118,18 +118,23 @@ async function runTests() {
118
118
  try {
119
119
  const webhookId = 'test-webhook-id-123';
120
120
  const timestamp = Math.floor(Date.now() / 1000);
121
+ // Create a proper secret format for Standard Webhooks (whsec_ + base64 encoded secret)
122
+ const base64Secret = Buffer.from(testSecret).toString('base64');
123
+ const dodoSecret = `whsec_${base64Secret}`;
121
124
  // Create svix-style signature: {webhook-id}.{webhook-timestamp}.{payload}
122
125
  const signedContent = `${webhookId}.${timestamp}.${testBody}`;
123
- const hmac = (0, crypto_1.createHmac)('sha256', testSecret);
126
+ // Use the base64-decoded secret for HMAC (like the Standard Webhooks library)
127
+ const secretBytes = new Uint8Array(Buffer.from(base64Secret, 'base64'));
128
+ const hmac = (0, crypto_1.createHmac)('sha256', secretBytes);
124
129
  hmac.update(signedContent);
125
- const signature = hmac.digest('hex');
130
+ const signature = `v1,${hmac.digest('base64')}`;
126
131
  const dodoRequest = createMockRequest({
127
132
  'webhook-signature': signature,
128
133
  'webhook-id': webhookId,
129
134
  'webhook-timestamp': timestamp.toString(),
130
135
  'content-type': 'application/json',
131
136
  });
132
- const dodoResult = await index_1.WebhookVerificationService.verifyWithPlatformConfig(dodoRequest, 'dodopayments', testSecret);
137
+ const dodoResult = await index_1.WebhookVerificationService.verifyWithPlatformConfig(dodoRequest, 'dodopayments', dodoSecret);
133
138
  console.log(' ✅ Dodo Payments:', dodoResult.isValid ? 'PASSED' : 'FAILED');
134
139
  if (!dodoResult.isValid) {
135
140
  console.log(' ❌ Error:', dodoResult.error);
@@ -31,8 +31,7 @@ class AlgorithmBasedVerifier extends base_1.WebhookVerifier {
31
31
  return sigMap.v1 || sigMap.signature || null;
32
32
  case "raw":
33
33
  default:
34
- // For Clerk, handle space-separated signatures
35
- if (this.platform === "clerk") {
34
+ if (this.platform === "clerk" || this.platform === "dodopayments") {
36
35
  const signatures = headerValue.split(" ");
37
36
  for (const sig of signatures) {
38
37
  const [version, signature] = sig.split(",");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hookflo/tern",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A robust, scalable webhook verification framework supporting multiple platforms and signature algorithms",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",