Skip to content

Commit b97c7e7

Browse files
authored
Add check if crypto.getRandomValues is available (#3487)
1 parent e8b950f commit b97c7e7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/silver-trainers-rhyme.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/firestore": patch
3+
---
4+
5+
Enable fallback for auto-generated identifiers in environments that support `crypto` but not `crypto.getRandomValues`.

packages/firestore/src/platform/browser/random_bytes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function randomBytes(nBytes: number): Uint8Array {
3030
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3131
typeof self !== 'undefined' && (self.crypto || (self as any)['msCrypto']);
3232
const bytes = new Uint8Array(nBytes);
33-
if (crypto) {
33+
if (crypto && typeof crypto.getRandomValues === 'function') {
3434
crypto.getRandomValues(bytes);
3535
} else {
3636
// Falls back to Math.random

0 commit comments

Comments
 (0)