mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 16:48:50 +00:00
nip46: params for createAccount that get passed into BunkerSigner.
This commit is contained in:
17
nip46.ts
17
nip46.ts
@@ -64,6 +64,11 @@ async function queryBunkerProfile(nip05: string): Promise<BunkerPointer | null>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type BunkerSignerParams = {
|
||||||
|
pool?: AbstractSimplePool
|
||||||
|
onauth?: (url: string) => void
|
||||||
|
}
|
||||||
|
|
||||||
export class BunkerSigner {
|
export class BunkerSigner {
|
||||||
private pool: AbstractSimplePool
|
private pool: AbstractSimplePool
|
||||||
private subCloser: SubCloser
|
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 remotePubkey - An optional remote public key. This is the key you want to sign as.
|
||||||
* @param secretKey - An optional key pair.
|
* @param secretKey - An optional key pair.
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(clientSecretKey: Uint8Array, bp: BunkerPointer, params: BunkerSignerParams = {}) {
|
||||||
clientSecretKey: Uint8Array,
|
|
||||||
bp: BunkerPointer,
|
|
||||||
params: {
|
|
||||||
pool?: AbstractSimplePool
|
|
||||||
onauth?: (url: string) => void
|
|
||||||
} = {},
|
|
||||||
) {
|
|
||||||
this.pool = params.pool || new SimplePool()
|
this.pool = params.pool || new SimplePool()
|
||||||
this.secretKey = clientSecretKey
|
this.secretKey = clientSecretKey
|
||||||
this.relays = bp.relays
|
this.relays = bp.relays
|
||||||
@@ -223,6 +221,7 @@ export class BunkerSigner {
|
|||||||
*/
|
*/
|
||||||
export async function createAccount(
|
export async function createAccount(
|
||||||
bunker: BunkerProfile,
|
bunker: BunkerProfile,
|
||||||
|
params: BunkerSignerParams,
|
||||||
username: string,
|
username: string,
|
||||||
domain: string,
|
domain: string,
|
||||||
email?: string,
|
email?: string,
|
||||||
@@ -230,7 +229,7 @@ export async function createAccount(
|
|||||||
if (email && !EMAIL_REGEX.test(email)) throw new Error('Invalid email')
|
if (email && !EMAIL_REGEX.test(email)) throw new Error('Invalid email')
|
||||||
|
|
||||||
let sk = generateSecretKey()
|
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 || ''])
|
let pubkey = await rpc.sendRequest('create_account', [username, domain, email || ''])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user