Skip to content

Add random source modules for node, browsers, and cross-platform usage #19

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

Merged
merged 2 commits into from
Jun 13, 2017
Merged

Add random source modules for node, browsers, and cross-platform usage #19

merged 2 commits into from
Jun 13, 2017

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Jun 6, 2017

This PR adds support for getting cryptographically secure random values (necessary for v4 UUIDs and any future encryption modules) from the WebCrypto APIs in supported browsers (including IE 11), from the crypto module in node, and from the SJCL everywhere else.

@jeskew jeskew requested review from awood45 and chrisradek June 6, 2017 00:31
@jeskew jeskew mentioned this pull request Jun 6, 2017
7 tasks
Copy link
Contributor

@chrisradek chrisradek 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! It might be too soon, but we'll probably want a browser field in the universal version of the app that sets the node version of the module to false so bundlers don't attempt to pollyfill those node modules.


describe('implementation selection', () => {
it('should use the node implementation in node', async () => {
(isNode as any).mockReturnValue(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like mockReturnValue may be deprecated ☹️
https://facebook.github.io/jest/docs/mock-function-api.html#mockfnmockreturnvaluevalue

That said, I'm not convinced by the docs that their suggested alternative is what we want. mockImplementation might work... I'm also fine with sticking to a major version of jest if this method gets removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think mockImplementation would be the way to go. I think we should keep updating jest until everything goes GA, so I'm willing to remove uses of deprecated functions until then.

@jeskew
Copy link
Contributor Author

jeskew commented Jun 9, 2017

Per our discussion re: self in React Native, I'm going to hold off on merging this in until #18 lands, as it includes a utility module for locating the proper global scope variable

@jeskew jeskew merged commit bb8033a into aws:master Jun 13, 2017
@jeskew jeskew deleted the feature/random-source branch June 13, 2017 02:37
trivikr referenced this pull request in trivikr/aws-sdk-js-v3 Dec 10, 2018
#19)

* Add random source modules for node, browsers, and cross-platform usage

* Use util-locate-window instead of directly dereferencing "self"
@lock
Copy link

lock bot commented Sep 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants