From 9b858cde9b0fdfaa85b7f147e860267c4c4e5dca Mon Sep 17 00:00:00 2001 From: fredericcarre Date: Tue, 8 Apr 2025 19:55:31 +0200 Subject: [PATCH 1/3] crypto patch --- package.json | 2 +- src/utils/uuid.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4ca0609..3c4a11a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reactivexcomponent.js", - "version": "7.0.7", + "version": "7.0.8", "description": "Javascript reactive client API for XComponent", "module": "dist/index.js", "main": "dist/index.js", diff --git a/src/utils/uuid.ts b/src/utils/uuid.ts index ceac18e..d10d9fe 100644 --- a/src/utils/uuid.ts +++ b/src/utils/uuid.ts @@ -1,3 +1,13 @@ + export function generateUUID(): string { + if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") { return crypto.randomUUID(); -} + } + + // Fallback (non cryptographique) + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + const r = Math.random() * 16 | 0; + const v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); +} \ No newline at end of file From a78f162efc7ad81d36528e3062b3613f96734b33 Mon Sep 17 00:00:00 2001 From: fredericcarre Date: Tue, 8 Apr 2025 20:00:46 +0200 Subject: [PATCH 2/3] crypto patch --- src/utils/uuid.ts | 21 ++++++++++----------- tslint.json | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/utils/uuid.ts b/src/utils/uuid.ts index d10d9fe..05c966f 100644 --- a/src/utils/uuid.ts +++ b/src/utils/uuid.ts @@ -1,13 +1,12 @@ - export function generateUUID(): string { - if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") { - return crypto.randomUUID(); - } + if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + return crypto.randomUUID(); + } - // Fallback (non cryptographique) - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - const r = Math.random() * 16 | 0; - const v = c === 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); -} \ No newline at end of file + // Fallback (non cryptographique) + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c: string) { + const r = (Math.random() * 16) | 0; + const v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +} diff --git a/tslint.json b/tslint.json index 6479113..6050ddb 100644 --- a/tslint.json +++ b/tslint.json @@ -14,7 +14,7 @@ "label-position": true, "no-any": true, "no-arg": true, - "no-bitwise": true, + "no-bitwise": false, "no-console": [ false, "log", From 929f4fb6ec8c03b51874e7b4b1e0abdf7e16171c Mon Sep 17 00:00:00 2001 From: fredericcarre Date: Tue, 8 Apr 2025 20:01:57 +0200 Subject: [PATCH 3/3] crypto patch --- src/utils/uuid.ts | 6 +++--- tslint.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/uuid.ts b/src/utils/uuid.ts index 05c966f..24ef220 100644 --- a/src/utils/uuid.ts +++ b/src/utils/uuid.ts @@ -4,9 +4,9 @@ export function generateUUID(): string { } // Fallback (non cryptographique) - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c: string) { - const r = (Math.random() * 16) | 0; - const v = c === 'x' ? r : (r & 0x3) | 0x8; + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c: string): string { + const r = Math.floor(Math.random() * 16); // évite l'opérateur bitwise + const v = c === 'x' ? r : (r % 4) + 8; // remplace (r & 0x3 | 0x8) return v.toString(16); }); } diff --git a/tslint.json b/tslint.json index 6050ddb..6479113 100644 --- a/tslint.json +++ b/tslint.json @@ -14,7 +14,7 @@ "label-position": true, "no-any": true, "no-arg": true, - "no-bitwise": false, + "no-bitwise": true, "no-console": [ false, "log",