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)
Mon, Jun 17, 10:54 PM
Unknown Object (File)
Mon, Jun 17, 10:54 PM
Unknown Object (File)
Fri, Jun 7, 7:17 AM
Unknown Object (File)
Fri, Jun 7, 6:16 AM
Unknown Object (File)
Fri, Jun 7, 6:16 AM
Unknown Object (File)
Tue, May 28, 5:42 AM
Unknown Object (File)
Tue, May 28, 5:42 AM
Unknown Object (File)
Tue, May 28, 5:41 AM
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