Merge pull request #45 from coutadeurf/fix/random-uuid-insecure-context

Correction : création d'arbre impossible en HTTP simple
This commit is contained in:
IliesAllali authored and GitHub committed 2026-10-08 16:45:22 +02:00
commit 24e28e98b8
1 file changed
+9 -1
+9 -1
View File
@@ -107,7 +107,15 @@ function normalizeSlug(value) {
}
function generateSecurePassword() {
return crypto.randomUUID().replace(/-/g, '')
if (typeof crypto.randomUUID === 'function') {
return crypto.randomUUID().replace(/-/g, '')
}
// crypto.randomUUID n'est exposé qu'en contexte sécurisé (HTTPS ou localhost) :
// sur du HTTP simple, getRandomValues reste disponible et donne le même UUID v4.
const bytes = crypto.getRandomValues(new Uint8Array(16))
bytes[6] = (bytes[6] & 0x0f) | 0x40
bytes[8] = (bytes[8] & 0x3f) | 0x80
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')
}
function getAccountSelfPersonStorageKey(userEmail, treeId) {