Fix USER_ID TDZ error in Firefox by using window.USER_ID
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
93dcae84d3
commit
c965da6891
1 changed files with 4 additions and 4 deletions
|
|
@ -1813,7 +1813,7 @@ function hexToBytes(hex) {
|
|||
|
||||
async function getOrCreateEncKey() {
|
||||
if (_encKey) return _encKey;
|
||||
const storageKey = `diora_enc_key_${typeof USER_ID !== 'undefined' ? USER_ID : 'anon'}`;
|
||||
const storageKey = `diora_enc_key_${window.USER_ID || 'anon'}`;
|
||||
const stored = localStorage.getItem(storageKey);
|
||||
if (stored) {
|
||||
try {
|
||||
|
|
@ -2605,7 +2605,7 @@ function showImportKey() {
|
|||
const raw = base64ToBytes(b64);
|
||||
const importedKey = await crypto.subtle.importKey('raw', raw, {name: 'AES-GCM', length: 256}, true, ['encrypt', 'decrypt']);
|
||||
const re_exported = await crypto.subtle.exportKey('raw', importedKey);
|
||||
localStorage.setItem(`diora_enc_key_${USER_ID}`, bytesToBase64(re_exported));
|
||||
localStorage.setItem(`diora_enc_key_${window.USER_ID}`, bytesToBase64(re_exported));
|
||||
closeSidebar();
|
||||
if (statusEl) statusEl.textContent = '✓ Key imported — reloading books…';
|
||||
await loadBookList();
|
||||
|
|
@ -3828,10 +3828,10 @@ async function saveFocusStation(url, name) {
|
|||
|
||||
(function init() {
|
||||
// Migrate PBKDF2-derived key stored by login/register form
|
||||
if (typeof USER_ID !== 'undefined' && USER_ID) {
|
||||
if (window.USER_ID) {
|
||||
const pending = localStorage.getItem('diora_pending_enc_key');
|
||||
if (pending) {
|
||||
localStorage.setItem(`diora_enc_key_${USER_ID}`, pending);
|
||||
localStorage.setItem(`diora_enc_key_${window.USER_ID}`, pending);
|
||||
localStorage.removeItem('diora_pending_enc_key');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue