Fix music optional auth to detect existing logged-in session on page load
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"VERSION": "v0.7.2",
|
||||
"VERSION_NUMBER": "0.7.2",
|
||||
"BUILD_DATE": "2026-04-19T17:37:32.473Z"
|
||||
"VERSION": "v0.7.3",
|
||||
"VERSION_NUMBER": "0.7.3",
|
||||
"BUILD_DATE": "2026-04-19T17:43:13.562Z"
|
||||
}
|
||||
|
||||
@@ -1617,6 +1617,21 @@ import { GreyscaleAPI } from './js/greyscale-api.mjs';
|
||||
return message.includes('authentication required');
|
||||
}
|
||||
|
||||
async function tryGetPubkeyWithoutPrompt({ attempts = 8, delayMs = 350 } = {}) {
|
||||
for (let i = 0; i < attempts; i += 1) {
|
||||
try {
|
||||
const pubkey = await getPubkey();
|
||||
if (pubkey) return pubkey;
|
||||
} catch {
|
||||
// Signer can attach slightly after initial script execution.
|
||||
}
|
||||
if (i < attempts - 1) {
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function isReadOnlyTargetMode() {
|
||||
return Boolean(targetPubkey && (!currentPubkey || targetPubkey !== currentPubkey));
|
||||
}
|
||||
@@ -1695,13 +1710,8 @@ import { GreyscaleAPI } from './js/greyscale-api.mjs';
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
currentPubkey = await getPubkey();
|
||||
isAuthenticated = Boolean(currentPubkey);
|
||||
} catch {
|
||||
currentPubkey = null;
|
||||
isAuthenticated = false;
|
||||
}
|
||||
currentPubkey = await tryGetPubkeyWithoutPrompt();
|
||||
isAuthenticated = Boolean(currentPubkey);
|
||||
}
|
||||
|
||||
async function initializeAuthenticatedPageFeatures() {
|
||||
|
||||
Reference in New Issue
Block a user