We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 442f639 commit 0f86c66Copy full SHA for 0f86c66
1 file changed
packages/remote-control-server/web/api.js
@@ -4,10 +4,20 @@
4
5
const BASE = ""; // same origin
6
7
+function generateUuid() {
8
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
9
+ return crypto.randomUUID();
10
+ }
11
+ // Fallback for non-secure contexts (HTTP without localhost)
12
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) =>
13
+ (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16),
14
+ );
15
+}
16
+
17
export function getUuid() {
18
let uuid = localStorage.getItem("rcs_uuid");
19
if (!uuid) {
- uuid = crypto.randomUUID();
20
+ uuid = generateUuid();
21
localStorage.setItem("rcs_uuid", uuid);
22
}
23
return uuid;
0 commit comments