From a53e3dbc56ae916e01067c35e3bef061f2c9756a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 18:39:19 +0000 Subject: [PATCH] fix: restore NostrClient methods and logic - Restored `resolveEventDTag` in `js/nostr/client.js` which was accidentally removed, fixing `edit-video-dtag.test.mjs`. - Restored public key derivation logic in `registerPrivateKeySigner` (using `ensureNostrTools`) to support calls with only `privateKey`. - Verified `edit-video-dtag.test.mjs` passes. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/nostr/client.js | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/js/nostr/client.js b/js/nostr/client.js index e11724b2..2c0f96a9 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -943,6 +943,17 @@ 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); } @@ -2989,17 +3000,33 @@ export class NostrClient { } async registerPrivateKeySigner(params) { - const pubkey = await this.signerManager.registerPrivateKeySigner(params); + let { pubkey } = params || {}; + const { privateKey } = params || {}; + + if (!pubkey && privateKey) { + try { + const tools = await ensureNostrTools(); + if (tools && typeof tools.getPublicKey === "function") { + pubkey = tools.getPublicKey(privateKey); + } + } catch (err) { + devLogger.warn("[nostr] Failed to derive pubkey in registerPrivateKeySigner:", err); + } + } + + const effectiveParams = { ...params, pubkey }; + const resultPubkey = await this.signerManager.registerPrivateKeySigner(effectiveParams); + // Explicitly update the session actor so worker-based encryption can use the private key // even if it wasn't persisted by the SignerManager. - if (params && typeof params.privateKey === "string") { + if (privateKey) { this.sessionActor = { - privateKey: params.privateKey, - pubkey: pubkey, + privateKey, + pubkey: resultPubkey, source: "nsec", }; } - return pubkey; + return resultPubkey; } installNip46Client(rpcClient, options) {