Commit ff593f8
authored
fix(webhooks): make the SDK browser-bundle-safe (namespace import of node:crypto) (#4)
webhooks.ts did a NAMED import of node:crypto (createHmac, timingSafeEqual).
Because the package index re-exports verifyWebhook, any bundler building an app
that imports the SDK (Vite/webpack/rollup) externalizes node:crypto to an empty
module and then ERRORS on the missing named exports - so the SDK could not be
bundled for the browser at all (found while building a browser demo).
Switch to a namespace import (import * as nodeCrypto) and reference
nodeCrypto.createHmac / nodeCrypto.timingSafeEqual. Browser bundles now build
(a single benign 'externalized for browser' warning instead of a hard error);
verifyWebhook stays synchronous and works unchanged in Node, where it actually
runs. No API change. 17 tests still green. Bump 0.1.2 -> 0.1.3.1 parent 5bcad60 commit ff593f8
2 files changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
4 | 10 | | |
| |||
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | | - | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
30 | | - | |
| 36 | + | |
31 | 37 | | |
0 commit comments