From 177e673d83ac5c52d117d42385f5e7a6a98e44b9 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 12 Feb 2024 09:04:06 -0300 Subject: [PATCH] nip46: params for createAccount that get passed into BunkerSigner. --- nip46.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nip46.ts b/nip46.ts index fd0c911..26a7f35 100644 --- a/nip46.ts +++ b/nip46.ts @@ -64,6 +64,11 @@ async function queryBunkerProfile(nip05: string): Promise } } +export type BunkerSignerParams = { + pool?: AbstractSimplePool + onauth?: (url: string) => void +} + export class BunkerSigner { private pool: AbstractSimplePool private subCloser: SubCloser @@ -87,14 +92,7 @@ export class BunkerSigner { * @param remotePubkey - An optional remote public key. This is the key you want to sign as. * @param secretKey - An optional key pair. */ - public constructor( - clientSecretKey: Uint8Array, - bp: BunkerPointer, - params: { - pool?: AbstractSimplePool - onauth?: (url: string) => void - } = {}, - ) { + public constructor(clientSecretKey: Uint8Array, bp: BunkerPointer, params: BunkerSignerParams = {}) { this.pool = params.pool || new SimplePool() this.secretKey = clientSecretKey this.relays = bp.relays @@ -223,6 +221,7 @@ export class BunkerSigner { */ export async function createAccount( bunker: BunkerProfile, + params: BunkerSignerParams, username: string, domain: string, email?: string, @@ -230,7 +229,7 @@ export async function createAccount( if (email && !EMAIL_REGEX.test(email)) throw new Error('Invalid email') let sk = generateSecretKey() - let rpc = new BunkerSigner(sk, bunker.bunkerPointer) + let rpc = new BunkerSigner(sk, bunker.bunkerPointer, params) let pubkey = await rpc.sendRequest('create_account', [username, domain, email || ''])