Correction : création d'arbre impossible en HTTP simple

crypto.randomUUID n'est exposé par le navigateur qu'en contexte sécurisé
(HTTPS ou localhost). Servie en HTTP simple, l'app plantait dans
generateSecurePassword à l'étape de création de l'arbre.

Repli sur crypto.getRandomValues, disponible partout, qui produit le
même UUID v4 sans tirets.

Signed-off-by: Fabrice Coutadeur <coutadeurf@gmail.com>
This commit is contained in:
Fabrice Coutadeur committed 2026-10-08 12:00:17 +02:00
1 parent 0365a71618
commit ebba0c8ce8
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) {