@hookflo/tern 1.0.1 ā 1.0.3
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/README.md +191 -283
- package/dist/examples.d.ts +8 -28
- package/dist/examples.js +270 -128
- package/dist/index.js +8 -3
- package/dist/platforms/algorithms.js +6 -2
- package/dist/test-compiled.js +1 -1
- package/dist/test.d.ts +2 -6
- package/dist/test.js +160 -86
- package/dist/verifiers/algorithms.d.ts +17 -9
- package/dist/verifiers/algorithms.js +162 -139
- package/dist/verifiers/custom-algorithms.d.ts +0 -10
- package/dist/verifiers/custom-algorithms.js +7 -216
- package/package.json +4 -2
package/dist/examples.js
CHANGED
|
@@ -1,160 +1,302 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.exampleTokenBased = exampleTokenBased;
|
|
3
|
+
exports.examplePlatformSpecific = examplePlatformSpecific;
|
|
5
4
|
exports.exampleCustomSignature = exampleCustomSignature;
|
|
6
|
-
exports.
|
|
5
|
+
exports.exampleSimplifiedPlatform = exampleSimplifiedPlatform;
|
|
6
|
+
exports.exampleTokenBased = exampleTokenBased;
|
|
7
7
|
exports.exampleErrorHandling = exampleErrorHandling;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.exampleCustomPlatform = exampleCustomPlatform;
|
|
12
|
-
exports.exampleHelperMethods = exampleHelperMethods;
|
|
8
|
+
exports.examplePlatformInfo = examplePlatformInfo;
|
|
9
|
+
exports.exampleRealWorldUsage = exampleRealWorldUsage;
|
|
10
|
+
exports.runAllExamples = runAllExamples;
|
|
13
11
|
const index_1 = require("./index");
|
|
14
|
-
// Example 1:
|
|
15
|
-
async function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
// Example 1: Using platform-specific configurations (Recommended)
|
|
13
|
+
async function examplePlatformSpecific() {
|
|
14
|
+
console.log('š§ Example 1: Platform-Specific Configurations\n');
|
|
15
|
+
// Stripe webhook verification
|
|
16
|
+
const stripeConfig = {
|
|
17
|
+
platform: 'stripe',
|
|
18
|
+
secret: 'whsec_your_stripe_webhook_secret',
|
|
19
|
+
toleranceInSeconds: 300,
|
|
20
|
+
};
|
|
21
|
+
// GitHub webhook verification
|
|
22
|
+
const githubConfig = {
|
|
23
|
+
platform: 'github',
|
|
24
|
+
secret: 'your_github_webhook_secret',
|
|
25
|
+
toleranceInSeconds: 300,
|
|
26
|
+
};
|
|
27
|
+
// Clerk webhook verification
|
|
28
|
+
const clerkConfig = {
|
|
29
|
+
platform: 'clerk',
|
|
30
|
+
secret: 'whsec_your_clerk_webhook_secret',
|
|
31
|
+
toleranceInSeconds: 300,
|
|
32
|
+
};
|
|
33
|
+
// Usage with Request object
|
|
34
|
+
const request = new Request('https://your-app.com/webhook', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: {
|
|
37
|
+
'stripe-signature': 't=1234567890,v1=abc123...',
|
|
38
|
+
'content-type': 'application/json',
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify({ event: 'payment_intent.succeeded' }),
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
const result = await index_1.WebhookVerificationService.verify(request, stripeConfig);
|
|
44
|
+
if (result.isValid) {
|
|
45
|
+
console.log('ā
Webhook verified successfully!');
|
|
46
|
+
console.log('Platform:', result.platform);
|
|
47
|
+
console.log('Payload:', result.payload);
|
|
48
|
+
console.log('Metadata:', result.metadata);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.log('ā Webhook verification failed:', result.error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('Error verifying webhook:', error);
|
|
56
|
+
}
|
|
23
57
|
}
|
|
24
|
-
// Example
|
|
25
|
-
async function exampleCustomSignature(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
58
|
+
// Example 2: Using custom signature configurations
|
|
59
|
+
async function exampleCustomSignature() {
|
|
60
|
+
console.log('\nš§ Example 2: Custom Signature Configurations\n');
|
|
61
|
+
// Custom HMAC-SHA256 configuration
|
|
62
|
+
const customConfig = {
|
|
63
|
+
platform: 'custom',
|
|
64
|
+
secret: 'your_custom_secret',
|
|
65
|
+
signatureConfig: {
|
|
66
|
+
algorithm: 'hmac-sha256',
|
|
67
|
+
headerName: 'x-custom-signature',
|
|
68
|
+
headerFormat: 'prefixed',
|
|
69
|
+
prefix: 'sha256=',
|
|
70
|
+
payloadFormat: 'raw',
|
|
71
|
+
},
|
|
32
72
|
};
|
|
33
|
-
|
|
73
|
+
// Custom timestamped configuration
|
|
74
|
+
const timestampedConfig = {
|
|
34
75
|
platform: 'custom',
|
|
35
|
-
secret: '
|
|
36
|
-
signatureConfig
|
|
76
|
+
secret: 'your_custom_secret',
|
|
77
|
+
signatureConfig: {
|
|
78
|
+
algorithm: 'hmac-sha256',
|
|
79
|
+
headerName: 'x-webhook-signature',
|
|
80
|
+
headerFormat: 'raw',
|
|
81
|
+
timestampHeader: 'x-webhook-timestamp',
|
|
82
|
+
timestampFormat: 'unix',
|
|
83
|
+
payloadFormat: 'timestamped',
|
|
84
|
+
},
|
|
37
85
|
};
|
|
38
|
-
|
|
39
|
-
return result;
|
|
86
|
+
console.log('Custom configurations created for different signature formats');
|
|
40
87
|
}
|
|
41
|
-
// Example
|
|
42
|
-
async function
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
88
|
+
// Example 3: Using the simplified platform config method
|
|
89
|
+
async function exampleSimplifiedPlatform() {
|
|
90
|
+
console.log('\nš§ Example 3: Simplified Platform Configuration\n');
|
|
91
|
+
const request = new Request('https://your-app.com/webhook', {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers: {
|
|
94
|
+
'x-hub-signature-256': 'sha256=abc123...',
|
|
95
|
+
'x-github-event': 'push',
|
|
96
|
+
'content-type': 'application/json',
|
|
97
|
+
},
|
|
98
|
+
body: JSON.stringify({ ref: 'refs/heads/main' }),
|
|
99
|
+
});
|
|
53
100
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
101
|
+
// Simple one-liner for platform-specific verification
|
|
102
|
+
const result = await index_1.WebhookVerificationService.verifyWithPlatformConfig(request, 'github', 'your_github_webhook_secret');
|
|
103
|
+
if (result.isValid) {
|
|
104
|
+
console.log('ā
GitHub webhook verified!');
|
|
105
|
+
console.log('Event:', result.metadata?.event);
|
|
106
|
+
console.log('Payload:', result.payload);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.log('ā GitHub webhook verification failed:', result.error);
|
|
58
110
|
}
|
|
59
|
-
return { success: true, payload: result.payload };
|
|
60
111
|
}
|
|
61
112
|
catch (error) {
|
|
62
|
-
console.error('
|
|
63
|
-
return { success: false, error: error.message };
|
|
113
|
+
console.error('Error:', error);
|
|
64
114
|
}
|
|
65
115
|
}
|
|
66
|
-
// Example
|
|
67
|
-
async function
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
116
|
+
// Example 4: Token-based authentication (Supabase style)
|
|
117
|
+
async function exampleTokenBased() {
|
|
118
|
+
console.log('\nš§ Example 4: Token-Based Authentication\n');
|
|
119
|
+
const request = new Request('https://your-app.com/webhook', {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: {
|
|
122
|
+
'x-webhook-id': 'webhook_123',
|
|
123
|
+
'x-webhook-token': 'token_456',
|
|
124
|
+
'content-type': 'application/json',
|
|
125
|
+
},
|
|
126
|
+
body: JSON.stringify({ event: 'database.insert' }),
|
|
127
|
+
});
|
|
128
|
+
try {
|
|
129
|
+
const result = await index_1.WebhookVerificationService.verifyTokenBased(request, 'webhook_123', 'token_456');
|
|
130
|
+
if (result.isValid) {
|
|
131
|
+
console.log('ā
Token-based webhook verified!');
|
|
132
|
+
console.log('Webhook ID:', result.metadata?.id);
|
|
133
|
+
console.log('Payload:', result.payload);
|
|
74
134
|
}
|
|
75
|
-
|
|
76
|
-
|
|
135
|
+
else {
|
|
136
|
+
console.log('ā Token-based webhook verification failed:', result.error);
|
|
77
137
|
}
|
|
78
138
|
}
|
|
79
|
-
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.error('Error:', error);
|
|
141
|
+
}
|
|
80
142
|
}
|
|
81
|
-
// Example
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
app.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
res.status(401).json({ error: result.error });
|
|
99
|
-
}
|
|
143
|
+
// Example 5: Error handling and validation
|
|
144
|
+
async function exampleErrorHandling() {
|
|
145
|
+
console.log('\nš§ Example 5: Error Handling and Validation\n');
|
|
146
|
+
// Test with invalid signature
|
|
147
|
+
const invalidRequest = new Request('https://your-app.com/webhook', {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
headers: {
|
|
150
|
+
'stripe-signature': 't=1234567890,v1=invalid_signature',
|
|
151
|
+
'content-type': 'application/json',
|
|
152
|
+
},
|
|
153
|
+
body: JSON.stringify({ event: 'test' }),
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
const result = await index_1.WebhookVerificationService.verifyWithPlatformConfig(invalidRequest, 'stripe', 'whsec_your_stripe_webhook_secret');
|
|
157
|
+
if (!result.isValid) {
|
|
158
|
+
console.log('ā Expected failure:', result.error);
|
|
159
|
+
console.log('Platform:', result.platform);
|
|
100
160
|
}
|
|
101
|
-
|
|
102
|
-
|
|
161
|
+
else {
|
|
162
|
+
console.log('ā ļø Unexpected success - this should have failed');
|
|
103
163
|
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error('Error during verification:', error);
|
|
167
|
+
}
|
|
168
|
+
// Test with missing headers
|
|
169
|
+
const missingHeadersRequest = new Request('https://your-app.com/webhook', {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
headers: {
|
|
172
|
+
'content-type': 'application/json',
|
|
173
|
+
},
|
|
174
|
+
body: JSON.stringify({ event: 'test' }),
|
|
104
175
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return async function handler(req, res) {
|
|
110
|
-
if (req.method !== 'POST') {
|
|
111
|
-
return res.status(405).json({ error: 'Method not allowed' });
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
const result = await index_1.WebhookVerificationService.verifyWithPlatformConfig(req, 'stripe', process.env.STRIPE_WEBHOOK_SECRET || '', 300);
|
|
115
|
-
if (result.isValid) {
|
|
116
|
-
console.log('Stripe webhook:', result.payload);
|
|
117
|
-
res.status(200).json({ received: true });
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
res.status(401).json({ error: result.error });
|
|
121
|
-
}
|
|
176
|
+
try {
|
|
177
|
+
const result = await index_1.WebhookVerificationService.verifyWithPlatformConfig(missingHeadersRequest, 'stripe', 'whsec_your_stripe_webhook_secret');
|
|
178
|
+
if (!result.isValid) {
|
|
179
|
+
console.log('ā Missing headers detected:', result.error);
|
|
122
180
|
}
|
|
123
|
-
|
|
124
|
-
|
|
181
|
+
else {
|
|
182
|
+
console.log('ā ļø Unexpected success - should have detected missing headers');
|
|
125
183
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const customConfig = {
|
|
131
|
-
platform: 'custom',
|
|
132
|
-
secret: 'your-custom-secret',
|
|
133
|
-
signatureConfig: {
|
|
134
|
-
algorithm: 'hmac-sha256',
|
|
135
|
-
headerName: 'x-custom-signature',
|
|
136
|
-
headerFormat: 'raw',
|
|
137
|
-
payloadFormat: 'raw',
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
const result = await index_1.WebhookVerificationService.verify(request, customConfig);
|
|
141
|
-
return result;
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
console.error('Error during verification:', error);
|
|
187
|
+
}
|
|
142
188
|
}
|
|
143
|
-
// Example
|
|
144
|
-
function
|
|
145
|
-
|
|
189
|
+
// Example 6: Platform algorithm information
|
|
190
|
+
function examplePlatformInfo() {
|
|
191
|
+
console.log('\nš§ Example 6: Platform Algorithm Information\n');
|
|
146
192
|
// Get all platforms using HMAC-SHA256
|
|
147
|
-
const
|
|
148
|
-
console.log('Platforms using HMAC-SHA256:',
|
|
193
|
+
const hmacSha256Platforms = index_1.WebhookVerificationService.getPlatformsUsingAlgorithm('hmac-sha256');
|
|
194
|
+
console.log('Platforms using HMAC-SHA256:', hmacSha256Platforms);
|
|
149
195
|
// Check if a platform uses a specific algorithm
|
|
150
|
-
const
|
|
151
|
-
console.log('
|
|
152
|
-
|
|
153
|
-
|
|
196
|
+
const stripeUsesHmac = index_1.WebhookVerificationService.platformUsesAlgorithm('stripe', 'hmac-sha256');
|
|
197
|
+
console.log('Stripe uses HMAC-SHA256:', stripeUsesHmac);
|
|
198
|
+
const clerkUsesCustom = index_1.WebhookVerificationService.platformUsesAlgorithm('clerk', 'custom');
|
|
199
|
+
console.log('Clerk uses custom algorithm:', clerkUsesCustom);
|
|
200
|
+
// Validate signature config
|
|
201
|
+
const validConfig = {
|
|
154
202
|
algorithm: 'hmac-sha256',
|
|
155
|
-
headerName: 'x-signature',
|
|
203
|
+
headerName: 'x-webhook-signature',
|
|
204
|
+
headerFormat: 'raw',
|
|
156
205
|
payloadFormat: 'raw',
|
|
157
206
|
};
|
|
158
|
-
const isValid = WebhookVerificationService.validateSignatureConfig(
|
|
159
|
-
console.log('
|
|
207
|
+
const isValid = index_1.WebhookVerificationService.validateSignatureConfig(validConfig);
|
|
208
|
+
console.log('Signature config is valid:', isValid);
|
|
209
|
+
}
|
|
210
|
+
// Example 7: Real-world usage patterns
|
|
211
|
+
async function exampleRealWorldUsage() {
|
|
212
|
+
console.log('\nš§ Example 7: Real-World Usage Patterns\n');
|
|
213
|
+
// Pattern 1: Express.js middleware
|
|
214
|
+
console.log('Pattern 1: Express.js Middleware');
|
|
215
|
+
console.log(`
|
|
216
|
+
app.post('/webhooks/stripe', async (req, res) => {
|
|
217
|
+
const result = await WebhookVerificationService.verifyWithPlatformConfig(
|
|
218
|
+
req,
|
|
219
|
+
'stripe',
|
|
220
|
+
process.env.STRIPE_WEBHOOK_SECRET
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
if (!result.isValid) {
|
|
224
|
+
return res.status(400).json({ error: result.error });
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Process the webhook
|
|
228
|
+
console.log('Stripe event:', result.payload.type);
|
|
229
|
+
res.json({ received: true });
|
|
230
|
+
});
|
|
231
|
+
`);
|
|
232
|
+
// Pattern 2: Next.js API route
|
|
233
|
+
console.log('\nPattern 2: Next.js API Route');
|
|
234
|
+
console.log(`
|
|
235
|
+
// pages/api/webhooks/github.js
|
|
236
|
+
export default async function handler(req, res) {
|
|
237
|
+
if (req.method !== 'POST') {
|
|
238
|
+
return res.status(405).json({ error: 'Method not allowed' });
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const result = await WebhookVerificationService.verifyWithPlatformConfig(
|
|
242
|
+
req,
|
|
243
|
+
'github',
|
|
244
|
+
process.env.GITHUB_WEBHOOK_SECRET
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
if (!result.isValid) {
|
|
248
|
+
return res.status(400).json({ error: result.error });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Handle GitHub webhook
|
|
252
|
+
const event = req.headers['x-github-event'];
|
|
253
|
+
console.log('GitHub event:', event);
|
|
254
|
+
|
|
255
|
+
res.json({ received: true });
|
|
256
|
+
}
|
|
257
|
+
`);
|
|
258
|
+
// Pattern 3: Cloudflare Workers
|
|
259
|
+
console.log('\nPattern 3: Cloudflare Workers');
|
|
260
|
+
console.log(`
|
|
261
|
+
addEventListener('fetch', event => {
|
|
262
|
+
event.respondWith(handleRequest(event.request));
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
async function handleRequest(request) {
|
|
266
|
+
if (request.url.includes('/webhooks/clerk')) {
|
|
267
|
+
const result = await WebhookVerificationService.verifyWithPlatformConfig(
|
|
268
|
+
request,
|
|
269
|
+
'clerk',
|
|
270
|
+
CLERK_WEBHOOK_SECRET
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
if (!result.isValid) {
|
|
274
|
+
return new Response(JSON.stringify({ error: result.error }), {
|
|
275
|
+
status: 400,
|
|
276
|
+
headers: { 'Content-Type': 'application/json' }
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Process Clerk webhook
|
|
281
|
+
console.log('Clerk event:', result.payload.type);
|
|
282
|
+
return new Response(JSON.stringify({ received: true }));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
`);
|
|
286
|
+
}
|
|
287
|
+
// Run all examples
|
|
288
|
+
async function runAllExamples() {
|
|
289
|
+
console.log('š Running Webhook Verification Examples\n');
|
|
290
|
+
await examplePlatformSpecific();
|
|
291
|
+
await exampleCustomSignature();
|
|
292
|
+
await exampleSimplifiedPlatform();
|
|
293
|
+
await exampleTokenBased();
|
|
294
|
+
await exampleErrorHandling();
|
|
295
|
+
examplePlatformInfo();
|
|
296
|
+
await exampleRealWorldUsage();
|
|
297
|
+
console.log('\nā
All examples completed!');
|
|
298
|
+
}
|
|
299
|
+
// Run examples if this file is executed directly
|
|
300
|
+
if (require.main === module) {
|
|
301
|
+
runAllExamples().catch(console.error);
|
|
160
302
|
}
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,12 @@ const algorithms_2 = require("./platforms/algorithms");
|
|
|
21
21
|
class WebhookVerificationService {
|
|
22
22
|
static async verify(request, config) {
|
|
23
23
|
const verifier = this.getVerifier(config);
|
|
24
|
-
|
|
24
|
+
const result = await verifier.verify(request);
|
|
25
|
+
// Ensure the platform is set correctly in the result
|
|
26
|
+
if (result.isValid) {
|
|
27
|
+
result.platform = config.platform;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
25
30
|
}
|
|
26
31
|
static getVerifier(config) {
|
|
27
32
|
const platform = config.platform.toLowerCase();
|
|
@@ -37,12 +42,12 @@ class WebhookVerificationService {
|
|
|
37
42
|
if (!signatureConfig) {
|
|
38
43
|
throw new Error('Signature config is required for algorithm-based verification');
|
|
39
44
|
}
|
|
40
|
-
// Use custom verifiers for special cases
|
|
45
|
+
// Use custom verifiers for special cases (token-based, etc.)
|
|
41
46
|
if (signatureConfig.algorithm === 'custom') {
|
|
42
47
|
return (0, custom_algorithms_1.createCustomVerifier)(secret, signatureConfig, toleranceInSeconds);
|
|
43
48
|
}
|
|
44
49
|
// Use algorithm-based verifiers for standard algorithms
|
|
45
|
-
return (0, algorithms_1.createAlgorithmVerifier)(secret, signatureConfig, toleranceInSeconds);
|
|
50
|
+
return (0, algorithms_1.createAlgorithmVerifier)(secret, signatureConfig, config.platform, toleranceInSeconds);
|
|
46
51
|
}
|
|
47
52
|
static getLegacyVerifier(config) {
|
|
48
53
|
const platform = config.platform.toLowerCase();
|
|
@@ -39,17 +39,17 @@ exports.platformAlgorithmConfigs = {
|
|
|
39
39
|
clerk: {
|
|
40
40
|
platform: "clerk",
|
|
41
41
|
signatureConfig: {
|
|
42
|
-
algorithm: "
|
|
42
|
+
algorithm: "hmac-sha256",
|
|
43
43
|
headerName: "svix-signature",
|
|
44
44
|
headerFormat: "raw",
|
|
45
45
|
timestampHeader: "svix-timestamp",
|
|
46
46
|
timestampFormat: "unix",
|
|
47
47
|
payloadFormat: "custom",
|
|
48
48
|
customConfig: {
|
|
49
|
-
type: "clerk-custom",
|
|
50
49
|
signatureFormat: "v1={signature}",
|
|
51
50
|
payloadFormat: "{id}.{timestamp}.{body}",
|
|
52
51
|
encoding: "base64",
|
|
52
|
+
idHeader: "svix-id",
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
55
|
description: "Clerk webhooks use HMAC-SHA256 with base64 encoding",
|
|
@@ -128,6 +128,10 @@ exports.platformAlgorithmConfigs = {
|
|
|
128
128
|
headerName: "x-webhook-token",
|
|
129
129
|
headerFormat: "raw",
|
|
130
130
|
payloadFormat: "raw",
|
|
131
|
+
customConfig: {
|
|
132
|
+
type: "token-based",
|
|
133
|
+
idHeader: "x-webhook-id",
|
|
134
|
+
},
|
|
131
135
|
},
|
|
132
136
|
description: "Custom webhook configuration",
|
|
133
137
|
},
|
package/dist/test-compiled.js
CHANGED
package/dist/test.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
declare function
|
|
2
|
-
|
|
3
|
-
declare function testPlatformDetection(): void;
|
|
4
|
-
declare function testCustomSignature(): Promise<import("./types").WebhookVerificationResult>;
|
|
5
|
-
export declare function runAllTests(): Promise<void>;
|
|
6
|
-
export { testGitHubWebhook, testTokenBasedWebhook, testPlatformDetection, testCustomSignature, };
|
|
1
|
+
declare function runTests(): Promise<void>;
|
|
2
|
+
export { runTests };
|