mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
nip05: move NIP05Result to the bottom, add another test
This commit is contained in:
@@ -22,4 +22,18 @@ test('fetch nip05 profiles', async () => {
|
|||||||
expect(p3.pubkey).toEqual(
|
expect(p3.pubkey).toEqual(
|
||||||
'36e65b503eba8a6b698e724a59137603101166a1cddb45ddc704247fc8aa0fce'
|
'36e65b503eba8a6b698e724a59137603101166a1cddb45ddc704247fc8aa0fce'
|
||||||
)
|
)
|
||||||
|
expect(p3.relays).toEqual(undefined)
|
||||||
|
|
||||||
|
let p4 = await nip05.queryProfile('_@fiatjaf.com')
|
||||||
|
expect(p4.pubkey).toEqual(
|
||||||
|
'3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d'
|
||||||
|
)
|
||||||
|
expect(p4.relays).toEqual([
|
||||||
|
'wss://relay.nostr.bg',
|
||||||
|
'wss://nos.lol',
|
||||||
|
'wss://nostr-verified.wellorder.net',
|
||||||
|
'wss://nostr.zebedee.cloud',
|
||||||
|
'wss://eden.nostr.land',
|
||||||
|
'wss://nostr.milou.lol',
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|||||||
20
nip05.ts
20
nip05.ts
@@ -34,16 +34,6 @@ export async function searchDomain(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** nostr.json result. */
|
|
||||||
export interface NIP05Result {
|
|
||||||
names: {
|
|
||||||
[name: string]: string
|
|
||||||
}
|
|
||||||
relays?: {
|
|
||||||
[pubkey: string]: string[]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function queryProfile(fullname: string): Promise<ProfilePointer | null> {
|
export async function queryProfile(fullname: string): Promise<ProfilePointer | null> {
|
||||||
const match = fullname.match(NIP05_REGEX)
|
const match = fullname.match(NIP05_REGEX)
|
||||||
if (!match) return null
|
if (!match) return null
|
||||||
@@ -61,6 +51,16 @@ export async function queryProfile(fullname: string): Promise<ProfilePointer | n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** nostr.json result. */
|
||||||
|
export interface NIP05Result {
|
||||||
|
names: {
|
||||||
|
[name: string]: string
|
||||||
|
}
|
||||||
|
relays?: {
|
||||||
|
[pubkey: string]: string[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Parse the nostr.json and throw if it's not valid. */
|
/** Parse the nostr.json and throw if it's not valid. */
|
||||||
function parseNIP05Result(json: any): NIP05Result {
|
function parseNIP05Result(json: any): NIP05Result {
|
||||||
const result: NIP05Result = {
|
const result: NIP05Result = {
|
||||||
|
|||||||
Reference in New Issue
Block a user