fix(auth): optimize login speed and list decryption

- Reduced decryption timeout for user lists from 90s to 15s to fail faster.
- Optimized NIP-07 decryption calls to avoid retries and long timeouts during critical loading paths.
- Fixed a bug where `loginWithExtension` triggered `getPublicKey` twice, doubling the user interaction time.
- Added a 10s grace period for relay health warnings to prevent false positives on startup.
- Verified `deferBlocks` logic in `authService` prevents blocking the login UI on slow list decryption.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-30 20:31:24 +00:00
1 parent 13f8b9f6aa
commit 6347ab0db1
5 files changed
+84 -12

No files matched your search

+11 -5
View File
@@ -40,7 +40,7 @@ import { relaySubscriptionService } from "./services/relaySubscriptionService.js
const SUBSCRIPTION_SET_KIND =
getNostrEventSchema(NOTE_TYPES.SUBSCRIPTION_LIST)?.kind ?? 30000;
const DECRYPT_TIMEOUT_MS = 90000;
const DECRYPT_TIMEOUT_MS = 15000;
const DECRYPT_RETRY_DELAY_MS = 10000;
function normalizeHexPubkey(value) {
@@ -937,13 +937,19 @@ class SubscriptionsManager {
}
if (nostrApi) {
const decrypterOptions = {
priority: NIP07_PRIORITY.HIGH,
timeoutMs: 12000,
retryMultiplier: 1,
};
if (typeof nostrApi.nip04?.decrypt === "function") {
registerDecryptor("nip04", (payload) =>
runNip07WithRetry(
() => nostrApi.nip04.decrypt(userPubkey, payload),
{
label: "nip04.decrypt",
priority: NIP07_PRIORITY.HIGH,
...decrypterOptions,
},
),
);
@@ -960,7 +966,7 @@ class SubscriptionsManager {
() => nip44.decrypt(userPubkey, payload),
{
label: "nip44.decrypt",
priority: NIP07_PRIORITY.HIGH,
...decrypterOptions,
},
),
);
@@ -974,7 +980,7 @@ class SubscriptionsManager {
() => nip44v2.decrypt(userPubkey, payload),
{
label: "nip44.v2.decrypt",
priority: NIP07_PRIORITY.HIGH,
...decrypterOptions,
},
),
);
@@ -984,7 +990,7 @@ class SubscriptionsManager {
() => nip44v2.decrypt(userPubkey, payload),
{
label: "nip44.v2.decrypt",
priority: NIP07_PRIORITY.HIGH,
...decrypterOptions,
},
),
);