From 1bb4d1ec85efe8ddd59ac2fb5d31d17205065e18 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 26 Jan 2026 20:58:02 +0000 Subject: [PATCH] fix(nostr): await nip-07 extension injection to resolve race conditions This commit fixes a critical race condition where `window.nostr` might not be injected before the app attempts to use it, causing failures in decryption (subscriptions, hashtags, DMs) and login flows. Changes: - Updated `ensureExtensionPermissions` in `js/nostr/client.js` to verify `window.nostr` existence even when permissions are cached. If missing, it now awaits `waitForNip07Extension` instead of returning a false success. - Updated `ensureActiveSignerForPubkey` in `js/nostr/client.js` to wait for the extension if permissions are cached but `window.nostr` is missing, ensuring a valid signer is created. Verification: - Confirmed `waitForNip07Extension` is imported in `js/nostr/client.js`. - Verified `HashtagPreferencesService` already implements multi-scheme decryption and optimistic updates. - Verified `SubscriptionsManager` implements multi-scheme decryption. - The race condition fix ensures the signer is correctly initialized with capabilities, enabling the decryption logic to work. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com>