Skip to content

Commit 1a2d8fa

Browse files
Copilotmtrezza
andcommitted
Fix browser build to use native Web Crypto API
Co-authored-by: mtrezza <5673677+mtrezza@users.noreply.github.com>
1 parent 7a77c8e commit 1a2d8fa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/uuid.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ if (process.env.PARSE_BUILD === 'weapp') {
1414
s[8] = s[13] = s[18] = s[23] = '-';
1515
return s.join('');
1616
};
17+
} else if (process.env.PARSE_BUILD === 'browser') {
18+
// Use native crypto.randomUUID() from the Web Crypto API in browsers
19+
uuid = () => globalThis.crypto.randomUUID();
1720
} else {
18-
// Use crypto.randomUUID() for Node, React Native, and browser builds
21+
// Use Node.js crypto.randomUUID() for Node and React Native builds
1922
uuid = require('crypto').randomUUID;
2023
}
2124

0 commit comments

Comments
 (0)