Skip to content
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

Implement cypto.createHash #177

Open
1 task
clangenb opened this issue Apr 30, 2024 · 10 comments
Open
1 task

Implement cypto.createHash #177

clangenb opened this issue Apr 30, 2024 · 10 comments

Comments

@clangenb
Copy link

Describe the feature

This is currently a showstopper for our project

Additional information

  • Would you be willing to help implement this feature?
@pi0
Copy link
Member

pi0 commented Apr 30, 2024

Hi. What is your deployment/runtime that does not support crypto.createHash?

@clangenb
Copy link
Author

Hi there, thanks for the quick response! I am not a pro when it comes to the JS world, so I am not sure if this is the correct piece of information. Essentially, it is this tiny nuxt project that I am working on: integritee-network/try-incognitee-app#10.

Frramework: Nuxt 3.11.2 with Nitro 2.9.6

 ╭────────────────────────────────────────Preview Mode──────────────────────────────────────────╮
 │                                                                                              │
 │  You are running Nuxt production build in preview mode.                                      │
 │  For production deployments, please directly use node ./server/index.mjs command.            │
 │                                                                                              │
 │  Node.js:           v21.7.3                                                                  │
 │  Nitro Preset:      node-server                                                              │
 │  Working directory: .output                                                                  │
 │                                                                                              │
 ╰──────────────────────────────────────────────────────────────────────────────────────────────╯

@clangenb
Copy link
Author

clangenb commented Apr 30, 2024

Unfortunately, I just realized that I will probably need more than only this function as an RSA library needs this polyfill, so I guess unenv is probably not the right solution as most of the crypto polyfills are not implemented...

@pi0
Copy link
Member

pi0 commented May 1, 2024

Thanks but i still didn't get what you mean. Node.js 21.7 implements crypto you probably don't need any polyfill unless I'm wrong but if it is not part of crypto subtle, feel free to raise an issue in uncrypto we can introduce them in there.

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
@clangenb
Copy link
Author

clangenb commented May 1, 2024

Thanks again for the swift answer!

I mean the crypto is running in the browser, and I was checking the code in node/modules/unenv/runtime/node/crypto/node.mjs and I see those lines, which is why I thought it is unimplemented.

export const createDecipheriv = notImplemented("crypto.createDecipheriv");
export const createDiffieHellman = notImplemented("crypto.createDiffieHellman");
export const createDiffieHellmanGroup = notImplemented("crypto.createDiffieHellmanGroup");
export const createECDH = notImplemented("crypto.createECDH");
export const createHash = notImplemented("crypto.createHash");
export const createHmac = notImplemented("crypto.createHmac");
export const createPrivateKey = notImplemented("crypto.createPrivateKey");
export const createPublicKey = notImplemented("crypto.createPublicKey");
export const createSecretKey = notImplemented("crypto.createSecretKey");

This is the log that I saw in the browser that made me think that I am on the right track:

image

Am I doing something wrong? Any pointer would be appreciated.

@pi0
Copy link
Member

pi0 commented May 1, 2024

Oh right. Yes, they are node.js specific APIs we didn't implement in the browser let me to reopen to investigate how hard it would be to support them.

@pi0 pi0 reopened this May 1, 2024
@angelorc
Copy link

angelorc commented Sep 7, 2024

I'm encountering the same issue here. I'm trying to use ecies-js (with Nuxt 3.13 and nuxthub/cloudflare), and during the decrypt function, I receive the error: Error: [unenv] crypto.createDecipheriv is not implemented yet!

@FutureExcited

This comment was marked as off-topic.

@clangenb
Copy link
Author

clangenb commented Oct 4, 2024

I was lucky that I had access to the library depending on nodes' crypto. So I was able to rewrite the crypto with the webcrypto api, encointer/encointer-js#101. Not sure if this helps anybody.

@Mehdi-Hp
Copy link

Having kinda the same problem using @nuxthub/core": "^0.7.34 and cloudflare-pages. I'm getting [unenv] crypto.createHash is not implemented yet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants