refactor(auth): decouple NIP-07 logic and optimize list fetching (agent)

- Moved NIP-07 extension detection and permission logic from `NostrClient` to `nip07` provider.
- Removed redundant `login` method from `NostrClient`.
- Increased concurrency and added timeouts to `fetchListIncrementally` to prevent hanging on slow relays.
- Updated `UserBlocks` to force full fetch on cache miss, fixing "empty list" issues.
- Updated unit tests for login permissions and hashtag preferences to reflect architectural changes.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-26 21:48:52 +00:00
1 parent 967bb079f5
commit 3c7a396da9
6 files changed
+241 -207

No files matched your search

+8
View File
@@ -729,6 +729,8 @@ class UserBlockListManager {
emitStatus({ status: "loading", relays: Array.from(nostrClient.relays || []) });
const localBlocks = this._loadLocal(normalized);
const hasLocalData = !!localBlocks;
if (localBlocks) {
this.blockedPubkeys = localBlocks;
this.loaded = true;
@@ -1067,18 +1069,24 @@ class UserBlockListManager {
}
};
// If we don't have local data, we must ignore the sync metadata and force a full fetch (since: 0).
// Otherwise, we might miss data if the metadata store says we are up-to-date but the actual list is missing.
const fetchSince = hasLocalData ? undefined : 0;
// Concurrent incremental fetch for both kinds
const [muteEvents, blockEvents] = await Promise.all([
nostrClient.fetchListIncrementally({
kind: 10000,
pubkey: normalized,
relayUrls: relays,
since: fetchSince,
}),
nostrClient.fetchListIncrementally({
kind: 30002,
pubkey: normalized,
dTag: BLOCK_LIST_IDENTIFIER,
relayUrls: relays,
since: fetchSince,
}),
]);