fix: use nip44 for nip46 comms

This commit is contained in:
kieran 2024-12-06 11:07:28 +00:00
parent 6eafdc1367
commit 892b00810d
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -69,6 +69,8 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
if (u.hash.length > 1) { if (u.hash.length > 1) {
this.#token = u.hash.substring(1); this.#token = u.hash.substring(1);
} else {
this.#token = u.searchParams.get("secret") || undefined;
} }
if (this.#localPubkey.startsWith("npub")) { if (this.#localPubkey.startsWith("npub")) {
this.#localPubkey = bech32ToHex(this.#localPubkey); this.#localPubkey = bech32ToHex(this.#localPubkey);
@ -83,7 +85,7 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
} }
get supports(): string[] { get supports(): string[] {
return ["nip04"]; return ["nip44"];
} }
get relays() { get relays() {
@ -222,7 +224,7 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
throw new Error("Unknown event kind"); throw new Error("Unknown event kind");
} }
const decryptedContent = await this.#insideSigner.nip4Decrypt(e.content, e.pubkey); const decryptedContent = await this.#insideSigner.nip44Decrypt(e.content, e.pubkey);
const reply = JSON.parse(decryptedContent) as Nip46Request | Nip46Response; const reply = JSON.parse(decryptedContent) as Nip46Request | Nip46Response;
let id = reply.id; let id = reply.id;
@ -286,7 +288,7 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
const eb = new EventBuilder(); const eb = new EventBuilder();
eb.kind(NIP46_KIND as EventKind) eb.kind(NIP46_KIND as EventKind)
.content(await this.#insideSigner.nip4Encrypt(JSON.stringify(payload), target)) .content(await this.#insideSigner.nip44Encrypt(JSON.stringify(payload), target))
.tag(["p", target]); .tag(["p", target]);
this.#log("Send: %O", payload); this.#log("Send: %O", payload);