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:
António Conselheiro
2024-09-09 14:16:23 -03:00
committed by GitHub
parent 21433049b8
commit ee76d69b4b
7 changed files with 204 additions and 13 deletions

View File

@@ -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
}