@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.
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
|
-
|
|
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('
|
|
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',
|
|
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
|
-
|
|
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