Page MenuHomePhabricator

Reimplement generateRandomString using browser crypto module
ClosedPublic

Authored by ashoat on Feb 12 2023, 6:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 12, 3:11 PM
Unknown Object (File)
Fri, Apr 11, 8:32 AM
Unknown Object (File)
Thu, Apr 10, 10:47 PM
Unknown Object (File)
Thu, Apr 10, 7:21 PM
Unknown Object (File)
Thu, Apr 10, 2:10 PM
Unknown Object (File)
Fri, Mar 28, 3:15 PM
Unknown Object (File)
Mar 2 2025, 8:01 PM
Unknown Object (File)
Mar 2 2025, 8:01 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
Lint Not Applicable
Unit
Tests Not Applicable