-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Improve random int #14828
Improve random int #14828
Conversation
ee18606
to
734e974
Compare
@@ -44,7 +44,7 @@ const config: webpack.Configuration = { | |||
src: path.resolve(__dirname, '../../suite/src/'), | |||
}, | |||
fallback: { | |||
// Polyfills crypto API for NodeJS libraries in the browser. 'crypto' does not run without 'stream' | |||
// Polyfills crypto API for Node.js libraries in the browser. 'crypto' does not run without 'stream' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I received a notice, that this is the official™ spelling is Node.js
. 🤷
db025fb
to
61d28fc
Compare
13b1c56
to
299bc68
Compare
@@ -14,7 +14,7 @@ | |||
"test:e2e:new-bridge:hw": "USE_HW=true USE_NODE_BRIDGE=true yarn test:e2e:bridge", | |||
"test:e2e:new-bridge:emu": "USE_HW=false USE_NODE_BRIDGE=true yarn test:e2e:bridge", | |||
"build:e2e:api:node": "yarn esbuild ./e2e/api/api.test.ts --bundle --outfile=./e2e/dist/api.test.node.js --platform=node --target=node18 --external:usb", | |||
"build:e2e:api:browser": "yarn esbuild ./e2e/api/api.test.ts --bundle --outfile=./e2e/dist/api.test.browser.js --platform=browser --external:usb && cp e2e/ui/api.test.html e2e/dist/index.html", | |||
"build:e2e:api:browser": "yarn esbuild ./e2e/api/api.test.ts --bundle --alias:crypto=crypto-browserify --alias:stream=stream-browserify --outfile=./e2e/dist/api.test.browser.js --platform=browser --external:usb && cp e2e/ui/api.test.html e2e/dist/index.html", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to figure this out: https://esbuild.github.io/api/#alias
299bc68
to
3ba7748
Compare
3ba7748
to
42529a9
Compare
@@ -45,7 +45,8 @@ | |||
"dependencies": { | |||
"@trezor/connect": "workspace:*", | |||
"@trezor/connect-common": "workspace:*", | |||
"@trezor/utils": "workspace:*" | |||
"@trezor/utils": "workspace:*", | |||
"crypto-browserify": "^3.12.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependency or devDependency ? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends... 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should, imho, be only devDependency
. because we only need it to produce lib
using build:lib
. it shouldn't be needed in the runtime of this package at all I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect-web itself only imports scheduleAction, createDeferred and createDeferredManager
@@ -25,6 +25,7 @@ | |||
"@trezor/device-utils": "workspace:*", | |||
"@trezor/transport": "workspace:*", | |||
"@trezor/urls": "workspace:*", | |||
"crypto-browserify": "^3.12.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what about stream-browserify
. this is transient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I used the same approach as was in suite
package
=> #14878 |
getRandomNumberInRange
togetWeakRandomNumberInRange
randomInt
that usescrypto
lib (becauserandomInt
from crypto is not supported bycrypto-browserify
=> feat: crypto.randomInt([min, ]max[, callback]) browserify/crypto-browserify#224)arrayShuffle
now usesrandomInt
and thereforecrypto
lib