mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
nip46: toBunkerURL() function.
This commit is contained in:
11
nip46.ts
11
nip46.ts
@@ -26,6 +26,17 @@ export type BunkerPointer = {
|
|||||||
secret: null | string
|
secret: null | string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toBunkerURL(bunkerPointer: BunkerPointer): string {
|
||||||
|
let bunkerURL = new URL(`bunker://${bunkerPointer.pubkey}`)
|
||||||
|
bunkerPointer.relays.forEach(relay => {
|
||||||
|
bunkerURL.searchParams.append('relay', relay)
|
||||||
|
})
|
||||||
|
if (bunkerPointer.secret) {
|
||||||
|
bunkerURL.searchParams.set('secret', bunkerPointer.secret)
|
||||||
|
}
|
||||||
|
return bunkerURL.toString()
|
||||||
|
}
|
||||||
|
|
||||||
/** This takes either a bunker:// URL or a name@domain.com NIP-05 identifier
|
/** This takes either a bunker:// URL or a name@domain.com NIP-05 identifier
|
||||||
and returns a BunkerPointer -- or null in case of error */
|
and returns a BunkerPointer -- or null in case of error */
|
||||||
export async function parseBunkerInput(input: string): Promise<BunkerPointer | null> {
|
export async function parseBunkerInput(input: string): Promise<BunkerPointer | null> {
|
||||||
|
|||||||
Reference in New Issue
Block a user