signers.ts (1098B)
1 import { getNip07, Nip01Signer, Nip07Signer, Nip46Broker, Nip46Signer, Nip55Signer } from "@welshman/signer"; 2 import type { NostrSigner } from "./types/nostr.js"; 3 4 export type NostrSignerNip46Options = { 5 client_secret: string; 6 signer_pubkey: string; 7 relays: string[]; 8 }; 9 10 export type NostrSignerNip55Options = { 11 signer: string; 12 pubkey: string; 13 }; 14 15 export const nostr_signer_nip01_create = (secret_key: string): NostrSigner => { 16 return new Nip01Signer(secret_key); 17 }; 18 19 export const nostr_signer_nip07_create = (): NostrSigner => { 20 return new Nip07Signer(); 21 }; 22 23 export const nostr_signer_nip07_get = () => { 24 return getNip07(); 25 }; 26 27 export const nostr_signer_nip46_create = (opts: NostrSignerNip46Options): NostrSigner => { 28 const broker = new Nip46Broker({ 29 clientSecret: opts.client_secret, 30 signerPubkey: opts.signer_pubkey, 31 relays: opts.relays, 32 }); 33 return new Nip46Signer(broker); 34 }; 35 36 export const nostr_signer_nip55_create = (opts: NostrSignerNip55Options): NostrSigner => { 37 return new Nip55Signer(opts.signer, opts.pubkey); 38 };