fix types from latest nip19 type change.
This commit is contained in:
parent
3e839db6f2
commit
7dbd86eb5c
|
@ -4,7 +4,7 @@ import { decode } from './nip19.ts'
|
||||||
import { wrapEvent, wrapManyEvents, unwrapEvent } from './nip17.ts'
|
import { wrapEvent, wrapManyEvents, unwrapEvent } from './nip17.ts'
|
||||||
import { hexToBytes } from '@noble/hashes/utils'
|
import { hexToBytes } from '@noble/hashes/utils'
|
||||||
|
|
||||||
const senderPrivateKey = decode(`nsec1p0ht6p3wepe47sjrgesyn4m50m6avk2waqudu9rl324cg2c4ufesyp6rdg`).data
|
const senderPrivateKey = decode(`nsec1p0ht6p3wepe47sjrgesyn4m50m6avk2waqudu9rl324cg2c4ufesyp6rdg`).data as Uint8Array
|
||||||
|
|
||||||
const sk1 = hexToBytes('f09ac9b695d0a4c6daa418fe95b977eea20f54d9545592bc36a4f9e14f3eb840')
|
const sk1 = hexToBytes('f09ac9b695d0a4c6daa418fe95b977eea20f54d9545592bc36a4f9e14f3eb840')
|
||||||
const sk2 = hexToBytes('5393a825e5892d8e18d4a5ea61ced105e8bb2a106f42876be3a40522e0b13747')
|
const sk2 = hexToBytes('5393a825e5892d8e18d4a5ea61ced105e8bb2a106f42876be3a40522e0b13747')
|
||||||
|
|
28
nip21.ts
28
nip21.ts
|
@ -1,4 +1,4 @@
|
||||||
import { BECH32_REGEX, decode, type DecodeResult } from './nip19.ts'
|
import { AddressPointer, BECH32_REGEX, decode, EventPointer, ProfilePointer } from './nip19.ts'
|
||||||
|
|
||||||
/** Nostr URI regex, eg `nostr:npub1...` */
|
/** Nostr URI regex, eg `nostr:npub1...` */
|
||||||
export const NOSTR_URI_REGEX: RegExp = new RegExp(`nostr:(${BECH32_REGEX.source})`)
|
export const NOSTR_URI_REGEX: RegExp = new RegExp(`nostr:(${BECH32_REGEX.source})`)
|
||||||
|
@ -15,7 +15,31 @@ export interface NostrURI {
|
||||||
/** The bech32-encoded data (eg `npub1...`). */
|
/** The bech32-encoded data (eg `npub1...`). */
|
||||||
value: string
|
value: string
|
||||||
/** Decoded bech32 string, according to NIP-19. */
|
/** Decoded bech32 string, according to NIP-19. */
|
||||||
decoded: DecodeResult
|
decoded:
|
||||||
|
| {
|
||||||
|
type: 'nevent'
|
||||||
|
data: EventPointer
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'nprofile'
|
||||||
|
data: ProfilePointer
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'naddr'
|
||||||
|
data: AddressPointer
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'npub'
|
||||||
|
data: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'nsec'
|
||||||
|
data: Uint8Array
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'note'
|
||||||
|
data: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse and decode a Nostr URI. */
|
/** Parse and decode a Nostr URI. */
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { SimplePool } from './pool.ts'
|
||||||
import { GiftWrap } from './kinds.ts'
|
import { GiftWrap } from './kinds.ts'
|
||||||
import { hexToBytes } from '@noble/hashes/utils'
|
import { hexToBytes } from '@noble/hashes/utils'
|
||||||
|
|
||||||
const senderPrivateKey = decode(`nsec1p0ht6p3wepe47sjrgesyn4m50m6avk2waqudu9rl324cg2c4ufesyp6rdg`).data
|
const senderPrivateKey = decode(`nsec1p0ht6p3wepe47sjrgesyn4m50m6avk2waqudu9rl324cg2c4ufesyp6rdg`).data as Uint8Array
|
||||||
const recipientPrivateKey = decode(`nsec1uyyrnx7cgfp40fcskcr2urqnzekc20fj0er6de0q8qvhx34ahazsvs9p36`).data
|
const recipientPrivateKey = decode(`nsec1uyyrnx7cgfp40fcskcr2urqnzekc20fj0er6de0q8qvhx34ahazsvs9p36`).data as Uint8Array
|
||||||
const recipientPublicKey = getPublicKey(recipientPrivateKey)
|
const recipientPublicKey = getPublicKey(recipientPrivateKey)
|
||||||
const event = {
|
const event = {
|
||||||
kind: 1,
|
kind: 1,
|
||||||
|
|
Loading…
Reference in New Issue