Skip to content

Commit 9b858cd

Browse files
committed
crypto patch
1 parent 90bd8b1 commit 9b858cd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
12
export function generateUUID(): string {
3+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
24
return crypto.randomUUID();
3-
}
5+
}
6+
7+
// Fallback (non cryptographique)
8+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
9+
const r = Math.random() * 16 | 0;
10+
const v = c === 'x' ? r : (r & 0x3 | 0x8);
11+
return v.toString(16);
12+
});
13+
}

0 commit comments

Comments
 (0)