Compare commits

...

2 Commits

Author SHA1 Message Date
Laan Tungir
08fc661077 Prioritize live window.nostr authState for active signing port registration 2026-05-27 15:48:34 -04:00
Laan Tungir
92430296c2 Fix shared-worker signer authority routing for multi-tab nsigner 2026-05-27 15:27:24 -04:00
3 changed files with 7 additions and 6 deletions

View File

@@ -184,7 +184,7 @@ export async function initNDKPage(options = {}) {
// All pages in www/ directory, so worker path is always the same.
// Include explicit worker revision token so updated SharedWorker code is guaranteed to restart.
const WORKER_REVISION = 'relay-events-db-5';
const WORKER_REVISION = 'relay-events-db-6';
const workerPath = `./ndk-worker.js?v=${encodeURIComponent(VERSION)}&wr=${encodeURIComponent(WORKER_REVISION)}`;
// Initialize NDK SharedWorker (shared across all tabs/pages)
@@ -217,6 +217,7 @@ export async function initNDKPage(options = {}) {
const readyHandler = () => {
cleanup();
console.log('[init-ndk] Worker signaled ready, initialization complete');
tryRegisterActiveSigningPort();
resolve();
};
@@ -319,6 +320,7 @@ async function ensureAuthenticated() {
try {
const pubkey = await getPublicKeyWithTimeout(4000);
console.log('[init-ndk] Authentication successful, pubkey:', pubkey);
tryRegisterActiveSigningPort();
finish(true);
} catch (error) {
console.log('[init-ndk] window.nostr not ready yet:', error.message);
@@ -488,7 +490,7 @@ function isExpectedSignerCapabilityError(method, error) {
function tryRegisterActiveSigningPort() {
if (!ndkWorker?.port) return;
try {
const auth = window?.NOSTR_LOGIN_LITE?.getAuthState?.() || window?.nostr?.authState || null;
const auth = window?.nostr?.authState || window?.NOSTR_LOGIN_LITE?.getAuthState?.() || null;
if (auth?.method === 'nsigner' && auth?.signer?.driver) {
ndkWorker.port.postMessage({ type: 'setActiveSigningPort' });
}

View File

@@ -1,5 +1,5 @@
{
"VERSION": "v0.7.12",
"VERSION_NUMBER": "0.7.12",
"BUILD_DATE": "2026-05-27T19:17:45.501Z"
"VERSION": "v0.7.14",
"VERSION_NUMBER": "0.7.14",
"BUILD_DATE": "2026-05-27T19:48:34.590Z"
}

View File

@@ -6103,7 +6103,6 @@ self.onconnect = (event) => {
console.log('[Worker] New port connected');
connectedPorts.push(port);
activeSigningPort = port;
port.onmessage = async (e) => {
const {