mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
including nostr specialized types (#409)
* including nostr types * including tests for nostr type guard * fix tests for nostr type guard * fix linter and add eslint and prettier to devcontainer * including null in nostr type guard signature * fix type, ops * including ncryptsec in nostr type guard * fix linter for ncryptsec * including ncryptsec return type for nip49 * fixing names of nostr types and types guards * fixing names of nostr types and types guards in unit tests descriptions * fix prettier * including type guard for nip5
This commit is contained in:
committed by
GitHub
parent
21433049b8
commit
ee76d69b4b
4
nip05.ts
4
nip05.ts
@@ -1,3 +1,4 @@
|
||||
import { Nip05 } from './core.ts'
|
||||
import { ProfilePointer } from './nip19.ts'
|
||||
|
||||
/**
|
||||
@@ -8,6 +9,7 @@ import { ProfilePointer } from './nip19.ts'
|
||||
* - 2: domain
|
||||
*/
|
||||
export const NIP05_REGEX = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/
|
||||
export const isNip05 = (value?: string | null): value is Nip05 => NIP05_REGEX.test(value || '')
|
||||
|
||||
var _fetch: any
|
||||
|
||||
@@ -47,7 +49,7 @@ export async function queryProfile(fullname: string): Promise<ProfilePointer | n
|
||||
}
|
||||
}
|
||||
|
||||
export async function isValid(pubkey: string, nip05: string): Promise<boolean> {
|
||||
export async function isValid(pubkey: string, nip05: Nip05): Promise<boolean> {
|
||||
let res = await queryProfile(nip05)
|
||||
return res ? res.pubkey === pubkey : false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user