Created
April 30, 2025 05:23
-
-
Save ilsubyeega/c47e8048964334d1a1a112ef460db712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://github.com/firebase/firebase-js-sdk/blob/ea1f9139e6baec0269fbb91233fd3f7f4b0d5875/packages/installations/src/helpers/generate-fid.ts#L20 | |
const fidByteArray = new Uint8Array(17); | |
self.crypto.getRandomValues(fidByteArray); | |
fidByteArray[0] = 0b01110000 + (fidByteArray[0] % 0b00010000) | |
const fid = btoa(String.fromCharCode(...fidByteArray)).replace(/\+/g, '-').replace(/\//g, '_').substr(0,22); | |
/^[cdef][\w-]{21}$/.test(fid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment