|
|
|
|
@@ -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' });
|
|
|
|
|
}
|
|
|
|
|
|