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

Global 'crypto' object could conflict with Node REPL #3

Open
rbuckton opened this issue Feb 6, 2020 · 4 comments
Open

Global 'crypto' object could conflict with Node REPL #3

rbuckton opened this issue Feb 6, 2020 · 4 comments

Comments

@rbuckton
Copy link
Collaborator

rbuckton commented Feb 6, 2020

be aware that the default node repl exposes builtin modules as globals and crypto is the name of one of them.

$ echo 'typeof globalThis.crypto' | node -i
Welcome to Node.js v12.13.1.
Type ".help" for more information.
> typeof globalThis.crypto
'object'

Originally posted by @bmeck in #2 (comment)

@rbuckton
Copy link
Collaborator Author

rbuckton commented Feb 6, 2020

cc: @ljharb

@rbuckton
Copy link
Collaborator Author

rbuckton commented Feb 6, 2020

I imagine there's a number of ways to address this in Node. For example: Given that its the REPL and almost guaranteed to have a developer actively interacting with the REPL, Node could chose to make their built-in crypto module available via both a crypto global and a nodeCrypto global, with a deprecation warning issued when crypto is referenced in the REPL (similar to other existing deprecation warnings issued in Node today).

I'm sure someone from Node could weigh in on this with their thoughts and concerns.

@ljharb
Copy link
Member

ljharb commented Feb 6, 2020

For one, since this is just in the repl, it won't break any code, it just might confuse some users. However, require('crypto') would continue to work in the node repl.

@ByteEater-pl
Copy link

Maybe put it on Math where random already lives?

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

3 participants