-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto.subtle.importKey does not accept ArrayBuffer (ArrayBuffer.prototype mismatch) #813
Comments
Occuring the same issue while using gr2m/universal-github-app-jwt. They obviously generate an ArrayBuffer, but importKey fails with the exact same type error. I can also replicate it simply by doing |
I wrote a simple test code. new ArrayBuffer().constructor === ArrayBuffer above code evaluated as |
any update on this? seems to not give the same error on cloudflare workers |
Same situation here in my local development. I have not yet pushed this up to Vercel to test in production. Using next 14.0.4 and node 18.18.2. (also tried with node 20.16.0) |
It seems node 18.17.0 changes the Crypto arguments validation: |
Thanks @ssikyou - are you sure that makes an impact though? Because in non-edge runtime this code works perfect - https://stackoverflow.com/questions/78960913/converting-pkcs8-node-crypto-to-web-crypto-apple-mapkit-js-token But as soon as it's in edge runtime it doesn't work. |
@Noitidart, I'm not sure why this makes the difference. But edge-runtime 2.5.x + nodejs 18.16.1 works for me in local env. |
Node.js 20.11.1
[email protected]
Bug Report
Current behavior
foo.js
:cmd:
result(error):
Expected behavior/code
Done without error
Additional context/screenshots
The above code has been verified to work with raw Node.js, Firefox and Chrome.
ArrayBuffer.prototype seems to be different from the original. Node.js checks here:
https://github.com/nodejs/node/blob/9b1bf44ea9e7785e38c93b7d22d32dbca262df6c/lib/internal/crypto/webidl.js#L183
Wrapping with uint8array is a workaround:
The text was updated successfully, but these errors were encountered: