From 73adc0a73544d0f63f37dc3ae5cd759e1ce9f39f Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Thu, 26 Mar 2026 21:08:37 +0100 Subject: [PATCH] Use globalThis for TextEncoder, TextDecoder, and atob browser globals Co-Authored-By: Claude Opus 4.6 (1M context) --- assets/modules/analytics.js | 4 ++-- templates/scanner/index.html.twig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/modules/analytics.js b/assets/modules/analytics.js index be8b6de..54c6f52 100644 --- a/assets/modules/analytics.js +++ b/assets/modules/analytics.js @@ -11,7 +11,7 @@ async function importKey(b64) { async function encrypt(data) { if (!encKey) return null - const json = new TextEncoder().encode(JSON.stringify(data)) + const json = new globalThis.TextEncoder().encode(JSON.stringify(data)) const iv = globalThis.crypto.getRandomValues(new Uint8Array(12)) const encrypted = await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv, tagLength: 128 }, encKey, json) const buf = new Uint8Array(encrypted) @@ -28,7 +28,7 @@ async function decrypt(b64) { const data = raw.slice(12) try { const decrypted = await globalThis.crypto.subtle.decrypt({ name: 'AES-GCM', iv, tagLength: 128 }, encKey, data) - return JSON.parse(new TextDecoder().decode(decrypted)) + return JSON.parse(new globalThis.TextDecoder().decode(decrypted)) } catch { return null } diff --git a/templates/scanner/index.html.twig b/templates/scanner/index.html.twig index b9370f7..3faab6c 100644 --- a/templates/scanner/index.html.twig +++ b/templates/scanner/index.html.twig @@ -403,7 +403,7 @@ let reference = decodedText; try { - const decoded = atob(decodedText); + const decoded = globalThis.atob(decodedText); if (decoded.startsWith('ETICKET-')) reference = decoded; } catch {}