Pass pubkey to nip 55 signer to avoid mixing up sessions

This commit is contained in:
Jon Staab
2025-10-13 11:20:01 -07:00
parent bbab2e0628
commit 5c03ff3e29
4 changed files with 16 additions and 84 deletions
+10 -3
View File
@@ -1,5 +1,5 @@
import {NostrSignerPlugin, AppInfo} from "nostr-signer-capacitor-plugin"
import {decode} from "nostr-tools/nip19"
import * as nip19 from "nostr-tools/nip19"
import {SignedEvent, StampedEvent} from "@welshman/util"
import {hash, own, signWithOptions, SignOptions, ISigner} from "../util.js"
@@ -16,8 +16,14 @@ export class Nip55Signer implements ISigner {
#npub?: string
#publicKey?: string
constructor(packageName: string) {
constructor(packageName: string, publicKey?: string) {
this.#packageName = packageName
if (publicKey) {
this.#publicKey = publicKey
this.#npub = nip19.npubEncode(publicKey)
}
this.#initialize()
}
@@ -53,8 +59,9 @@ export class Nip55Signer implements ISigner {
if (!this.#publicKey || !this.#npub) {
try {
const {npub} = await signer.getPublicKey()
const {data} = nip19.decode(npub)
this.#npub = npub
const {data} = decode(npub)
this.#publicKey = data as string
} catch (error) {
throw new Error("Failed to get public key")