crypto3.getCiphers is not a function
cre8 opened this issue · 6 comments
I am using your package in one of my subpackages in the browser with Angular. However when I call it, I am getting this error:
webcrypto.es.js:2233 Uncaught TypeError: crypto3.getCiphers is not a function
at new SubtleCrypto2 (webcrypto.es.js:2233:32)
at new Crypto2 (webcrypto.es.js:2276:23)
at node_modules/@transmute/web-crypto-key-pair/dist/web-crypto-key-pair.esm.js (web-crypto-key-pair.esm.js:814:27)
at __init (chunk-QPLMLQ3O.js?v=8ada0fd4:45:56)
at node_modules/@transmute/json-web-signature/dist/json-web-signature.esm.js (json-web-signature.esm.js:5:1)
at __init (chunk-QPLMLQ3O.js?v=8ada0fd4:45:56)
at node_modules/@cef-ebsi/verifiable-credential/dist/index.js (index.js:18:30)
at __require2 (chunk-QPLMLQ3O.js?v=8ada0fd4:48:50)
at node_modules/@cef-ebsi/verifiable-presentation/dist/index.js (index.js:20:33)
at __require2 (chunk-QPLMLQ3O.js?v=8ada0fd4:48:50)
I am using esbuild and added the polyfills like
import { polyfillNode } from 'esbuild-plugin-polyfill-node';
export default polyfillNode();
On the backend it's working fine, it seems to be a problem with the browser. Do you know if there needs to be an extra import?
Did you find a fix for that?
I have a suspicion it could be a collusion with another crypto polyfill library but I'm still investigating.
Did you find a fix for that?
I have a suspicion it could be a collusion with another crypto polyfill library but I'm still investigating.
I am not working on the project anymore (no access anymore) so I don't know if this could be the problem...
For maintainers I have tried to turn things around but the problem persist.
So getCiphers
is used here:
Line 34 in 919c67e
getHashes
Line 80 in 919c67e
Those functions come from crypto
(node:crypto
) as imported here
Line 1 in 919c67e
However, it seems that getCiphers
and getHashes
have been deprecated from node 20, as they don't appear in the docs anymore from that version.
I also couldn't find getCiphers
in polyfill libraries for rollup and vite, and only this mention of getHashes
in this licence (https://github.com/FredKSchott/rollup-plugin-polyfill-node/blob/31face71b94b8408a907f04753318dff589adc2f/polyfills/LICENSE-crypto-browserify.txt#L55), which means I cannot inject them in my browser build either.
What do you advise from here?
I don't see any indication that these methods are deprecated. They are still present in the documentation for version v22:
- https://nodejs.org/api/crypto.html#cryptogetciphers
- https://nodejs.org/api/crypto.html#cryptogethashes
If you're trying to build your application using Rollup for Node.js, you should exclude the crypto
module from the bundle to prevent it from being included.
If you're building the application for the browser, use the native crypto
module instead of @peculiar/webcrypto
, as that module is intended for implementing the WebCrypto API in Node.js.
Thanks for checking the docs, I swear I couldn't find them.
If you're building the application for the browser, use the native crypto module instead of @peculiar/webcrypto, as that module is intended for implementing the WebCrypto API in Node.js.
My main problem here is that webcrypto
supports secp256k1
which the original crypto
does not, in the browser or in nodejs.
Try webcrypto-liner. It supports the K-256
named curve.