nip19: remove note1.

This commit is contained in:
Asai Toshiya
2024-11-19 23:22:26 +09:00
committed by fiatjaf_
parent 43ce7f9377
commit b22e2465cc
6 changed files with 29 additions and 57 deletions

View File

@@ -8,7 +8,6 @@ export type NEvent = `nevent1${string}`
export type NAddr = `naddr1${string}`
export type NSec = `nsec1${string}`
export type NPub = `npub1${string}`
export type Note = `note1${string}`
export type Ncryptsec = `ncryptsec1${string}`
export const NostrTypeGuard = {
@@ -17,7 +16,6 @@ export const NostrTypeGuard = {
isNAddr: (value?: string | null): value is NAddr => /^naddr1[a-z\d]+$/.test(value || ''),
isNSec: (value?: string | null): value is NSec => /^nsec1[a-z\d]{58}$/.test(value || ''),
isNPub: (value?: string | null): value is NPub => /^npub1[a-z\d]{58}$/.test(value || ''),
isNote: (value?: string | null): value is Note => /^note1[a-z\d]+$/.test(value || ''),
isNcryptsec: (value?: string | null): value is Ncryptsec => /^ncryptsec1[a-z\d]+$/.test(value || ''),
}
@@ -67,7 +65,6 @@ type Prefixes = {
naddr: AddressPointer
nsec: Uint8Array
npub: string
note: string
}
type DecodeValue<Prefix extends keyof Prefixes> = {
@@ -140,7 +137,6 @@ export function decode(nip19: string): DecodeResult {
return { type: prefix, data }
case 'npub':
case 'note':
return { type: prefix, data: bytesToHex(data) }
default:
@@ -173,10 +169,6 @@ export function npubEncode(hex: string): NPub {
return encodeBytes('npub', hexToBytes(hex))
}
export function noteEncode(hex: string): Note {
return encodeBytes('note', hexToBytes(hex))
}
function encodeBech32<Prefix extends string>(prefix: Prefix, data: Uint8Array): `${Prefix}1${string}` {
let words = bech32.toWords(data)
return bech32.encode(prefix, words, Bech32MaxSize) as `${Prefix}1${string}`