Page MenuHomePhabricator

Reimplement generateRandomString using browser crypto module
ClosedPublic

Authored by ashoat on Feb 12 2023, 6:40 PM.
Tags
None
Referenced Files
F3486253: D6697.diff
Wed, Dec 18, 4:09 AM
Unknown Object (File)
Fri, Dec 6, 2:15 AM
Unknown Object (File)
Tue, Dec 3, 1:16 PM
Unknown Object (File)
Tue, Dec 3, 1:16 PM
Unknown Object (File)
Wed, Nov 20, 1:04 PM
Unknown Object (File)
Nov 11 2024, 4:44 AM
Unknown Object (File)
Nov 11 2024, 4:42 AM
Unknown Object (File)
Nov 9 2024, 4:55 PM
Subscribers
None

Details

Summary

generateRandomString is currently implemented using a polyfill of the Node.js crypto library, but Webpack 5 no longer includes this polyfill by default.

We could configure the polyfill manually, but instead I figured we could save some bundle size and just reimplement this using the browser-native crypto module, which has a getRandomValues function.

Test Plan

console.log'd the results of calling generateDeviceID in web

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage