mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
nip19: improve return type
This commit is contained in:
13
nip19.ts
13
nip19.ts
@@ -23,10 +23,15 @@ export type AddressPointer = {
|
|||||||
relays?: string[]
|
relays?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function decode(nip19: string): {
|
export type DecodeResult =
|
||||||
type: string
|
| {type: 'nprofile'; data: ProfilePointer}
|
||||||
data: ProfilePointer | EventPointer | AddressPointer | string
|
| {type: 'nevent'; data: EventPointer}
|
||||||
} {
|
| {type: 'naddr'; data: AddressPointer}
|
||||||
|
| {type: 'nsec'; data: string}
|
||||||
|
| {type: 'npub'; data: string}
|
||||||
|
| {type: 'note'; data: string}
|
||||||
|
|
||||||
|
export function decode(nip19: string): DecodeResult {
|
||||||
let {prefix, words} = bech32.decode(nip19, Bech32MaxSize)
|
let {prefix, words} = bech32.decode(nip19, Bech32MaxSize)
|
||||||
let data = new Uint8Array(bech32.fromWords(words))
|
let data = new Uint8Array(bech32.fromWords(words))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user