Skip to content

Commit 4843332

Browse files
Merge pull request #268 from xcomponent/cryptopatch
Cryptopatch
2 parents 90bd8b1 + 929f4fb commit 4843332

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactivexcomponent.js",
3-
"version": "7.0.7",
3+
"version": "7.0.8",
44
"description": "Javascript reactive client API for XComponent",
55
"module": "dist/index.js",
66
"main": "dist/index.js",

src/utils/uuid.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
export function generateUUID(): string {
2-
return crypto.randomUUID();
2+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
3+
return crypto.randomUUID();
4+
}
5+
6+
// Fallback (non cryptographique)
7+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c: string): string {
8+
const r = Math.floor(Math.random() * 16); // évite l'opérateur bitwise
9+
const v = c === 'x' ? r : (r % 4) + 8; // remplace (r & 0x3 | 0x8)
10+
return v.toString(16);
11+
});
312
}

0 commit comments

Comments
 (0)