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

Fix Node Crypto polyfill #49288

Merged
merged 5 commits into from May 9, 2023
Merged

Conversation

g12i
Copy link
Contributor

@g12i g12i commented May 5, 2023

What?

Allow overwriting the global.crypto property when polyfilling it.

Why?

#48941 introduced global.crypto polyfill. The problem is that if some library (e.g. xksuid) tries to do the same thing, it breaks as global.crypto is defined as non-writable1. Arguably libraries should check for global.crypto presence before overwriting it BUT I think polyfill should match the actual implementation2.

How?

Make global.crypto enumerable and configurable, as well as define set implementation3.

Footnotes

  1. image

  2. image

  3. image

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for this change?

@g12i
Copy link
Contributor Author

g12i commented May 5, 2023

Hey @timneutkens, of course! I added unit tests. I think I might have not pushed them by the time I pressed Create PR button. Would you think more tests are needed?

@g12i g12i requested a review from timneutkens May 5, 2023 11:38
Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now 👍 thanks!

@timneutkens timneutkens merged commit e570ad4 into vercel:canary May 9, 2023
8 of 11 checks passed
@g12i g12i deleted the fix/fix-crypto-polyfill branch May 15, 2023 08:39
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants