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

Can't access Web Crypto API from within remix's dev server #6913 #6915

Closed
1 task done
tavoyne opened this issue Jul 21, 2023 · 1 comment
Closed
1 task done

Can't access Web Crypto API from within remix's dev server #6913 #6915

tavoyne opened this issue Jul 21, 2023 · 1 comment

Comments

@tavoyne
Copy link

tavoyne commented Jul 21, 2023

What version of Remix are you using?

1.19.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Just console.log(globalThis.crypto) from server code or open https://stackblitz.com/edit/remix-run-remix-fbmasu?file=app%2Fentry.server.tsx and check the console.

Expected Behavior

If using Node >=15.0.0, globalThis.crypto or just crypto should return a Crypto object. It already works natively in Node (Node documentation and MDN) just like in all other environments, so why does remix removes it from the global object?

Actual Behavior

It returns undefined.

@kiliman
Copy link
Collaborator

kiliman commented Jul 21, 2023

WebCrypto was not added to Node.js globalThis until v19. Prior to that you had to require('node:crypto').webcrypto. Make sure you are using the correct version of Node.js.

https://medium.com/@Luna-Rojas/nodejs-19-is-here-3-features-that-will-blow-your-mind-565572086f77

nodejs/node#44897

As confirmation, here's a test in a Remix app

export function loader() {
  console.log({ version: process.version, crypto: globalThis.crypto });
  return null;
}
{ version: 'v18.16.1', crypto: undefined }
{ version: 'v19.9.0', crypto: Crypto {} }
{ version: 'v20.4.0', crypto: Crypto {} }

@kiliman kiliman closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants