Use globalThis.atob/btoa in analytics module for linter compatibility
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ const SK_HASH = '_h'
|
|||||||
let encKey = null
|
let encKey = null
|
||||||
|
|
||||||
async function importKey(b64) {
|
async function importKey(b64) {
|
||||||
const raw = Uint8Array.from(atob(b64), c => c.charCodeAt(0))
|
const raw = Uint8Array.from(globalThis.atob(b64), c => c.charCodeAt(0))
|
||||||
return globalThis.crypto.subtle.importKey('raw', raw, 'AES-GCM', false, ['encrypt', 'decrypt'])
|
return globalThis.crypto.subtle.importKey('raw', raw, 'AES-GCM', false, ['encrypt', 'decrypt'])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,12 +18,12 @@ async function encrypt(data) {
|
|||||||
const combined = new Uint8Array(12 + buf.length)
|
const combined = new Uint8Array(12 + buf.length)
|
||||||
combined.set(iv)
|
combined.set(iv)
|
||||||
combined.set(buf, 12)
|
combined.set(buf, 12)
|
||||||
return btoa(String.fromCharCode(...combined))
|
return globalThis.btoa(String.fromCharCode(...combined))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function decrypt(b64) {
|
async function decrypt(b64) {
|
||||||
if (!encKey) return null
|
if (!encKey) return null
|
||||||
const raw = Uint8Array.from(atob(b64), c => c.charCodeAt(0))
|
const raw = Uint8Array.from(globalThis.atob(b64), c => c.charCodeAt(0))
|
||||||
const iv = raw.slice(0, 12)
|
const iv = raw.slice(0, 12)
|
||||||
const data = raw.slice(12)
|
const data = raw.slice(12)
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user