Increase / increase-node

Apache License 2.0
8 stars 1 forks source link

`crypto` usage breaks compatibility with Vercel Edge Runtime #383

Open heysanil opened 6 months ago

heysanil commented 6 months ago

We primarily use this SDK in the Vercel Edge Runtime (on Next.js 14), which doesn't have support for the node:crypto module (only for the Web Crypto API). Commit 7580e133b111b6e212c3f89e43b7ce2b3dc78116 (in release 0.25.0 and onwards) added usage of createHmac for webhook payload signing, which causes builds to fail when the Increase SDK is imported on edge endpoints:

build: Failed to compile.
build: 
build: ../../node_modules/increase/resources/webhooks.mjs:3:0
build: Module not found: Can't resolve 'crypto'
build: 
build: https://nextjs.org/docs/messages/module-not-found

The Web Crypto API should likely be used directly for HMAC signing as a fallback in runtimes where crypto is unavailable.

saescapa commented 6 months ago

+1 Same here

rattrayalex commented 6 months ago

Thanks for reporting, we're looking into this.

saescapa commented 3 weeks ago

hey team, any updates on this?