From 6a043c29464a9f7315737119b4d2092326ffaa5b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 01:07:50 +0000 Subject: [PATCH] Fix CI test failures and clean up NostrClient - Fixed duplicate imports and initializations in `js/nostr/client.js`. - Fixed `registerPrivateKeySigner` to populate `sessionActor`, ensuring fallback encryption works in tests (fixing `tests/nostr-send-direct-message.test.mjs`). - Removed duplicate/unused methods (`resolveEventDTag`, `extensionPermissionCache` getter). - Installed missing dev dependencies (`jsdom`, `fake-indexeddb`). Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/nostr/client.js | 36 +++++++++--------------------------- test_output.txt | 46 ---------------------------------------------- 2 files changed, 9 insertions(+), 73 deletions(-) delete mode 100644 test_output.txt diff --git a/js/nostr/client.js b/js/nostr/client.js index b1647bb5..748b6119 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -220,7 +220,6 @@ import { hydrateExtensionSignerCapabilities, attachNipMethodAliases, } from "./managers/SignerManager.js"; -import { RelayBatchFetcher } from "./relayBatchFetcher.js"; import { prepareVideoPublishPayload, prepareVideoMirrorOptions, @@ -475,11 +474,8 @@ export class NostrClient { this.rootCreatedAtByRoot = new Map(); - this.dirtyEventIds = new Set(); - this.dirtyTombstones = new Set(); this.persistenceManager = new PersistenceManager(this); this.syncMetadataStore = new SyncMetadataStore(); - this.relayBatchFetcher = new RelayBatchFetcher(this); this.nip71Cache = new Map(); this.watchHistory = createWatchHistoryManager({ @@ -628,8 +624,6 @@ export class NostrClient { get unreachableRelays() { return this.connectionManager.unreachableRelays; } - get extensionPermissionCache() { return this.signerManager.extensionPermissionCache; } - /** * Records a deletion timestamp for a video identifier (Tombstoning). * @@ -768,17 +762,6 @@ export class NostrClient { } } - resolveEventDTag(event, fallbackEvent = null) { - if (event && typeof event === "object") { - const dTag = getDTagValueFromTags(event.tags); - if (dTag) return dTag; - } - if (fallbackEvent && typeof fallbackEvent === "object") { - return getDTagValueFromTags(fallbackEvent.tags); - } - return null; - } - getActiveKey(video) { return getActiveKey(video); } @@ -1048,16 +1031,6 @@ export class NostrClient { * * @returns {Promise} Resolves when the relay pool is initialized and connections are attempted. */ - /** - * Main entry point for the client. - * - * 1. Restores local state from IndexedDB (Stale-While-Revalidate). - * 2. Initializes the relay connection pool. - * 3. Connects to configured relays. - * 4. Restores any persistent remote signer sessions. - * - * @returns {Promise} Resolves after the initial relay connection attempt completes. - */ async init() { if (this.isInitialized) { return; @@ -2367,6 +2340,15 @@ export class NostrClient { async registerPrivateKeySigner(opts) { const adapter = await createNsecAdapter(opts); this.signerManager.setActiveSigner(adapter); + + if (opts.privateKey && typeof opts.privateKey === "string") { + this.sessionActor = { + pubkey: adapter.pubkey, + privateKey: opts.privateKey.trim().toLowerCase(), + source: "nsec", + }; + } + return adapter; } diff --git a/test_output.txt b/test_output.txt deleted file mode 100644 index f84eb770..00000000 --- a/test_output.txt +++ /dev/null @@ -1,46 +0,0 @@ - -→ Running tests/nostr/integration-remote-flow.test.mjs -VIEW RESULT ERROR: { ok: false, error: 'missing-actor' } -TAP version 13 -# Subtest: nostr login + remote signing + publish + watch history integration -not ok 1 - nostr login + remote signing + publish + watch history integration - --- - duration_ms: 60.800483 - type: 'test' - location: '/app/tests/nostr/integration-remote-flow.test.mjs:52:1' - failureType: 'testCodeFailure' - error: |- - Expected values to be strictly equal: - - false !== true - - code: 'ERR_ASSERTION' - name: 'AssertionError' - expected: true - actual: false - operator: 'strictEqual' - stack: |- - TestContext. (file:///app/tests/nostr/integration-remote-flow.test.mjs:272:83) - async Test.run (node:internal/test_runner/test:1054:7) - async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3) - ... -1..1 -# tests 1 -# suites 0 -# pass 0 -# fail 1 -# cancelled 0 -# skipped 0 -# todo 0 -# duration_ms 72.354406 -file:///app/scripts/run-targeted-tests.mjs:44 - reject(new Error(`${relativePath} failed with exit code ${code}`)); - ^ - -Error: tests/nostr/integration-remote-flow.test.mjs failed with exit code 1 - at ChildProcess. (file:///app/scripts/run-targeted-tests.mjs:44:16) - at ChildProcess.emit (node:events:519:28) - at maybeClose (node:internal/child_process:1101:16) - at ChildProcess._handle.onexit (node:internal/child_process:304:5) - -Node.js v22.22.0