NIP-39: validate github

This commit is contained in:
BilligsterUser
2023-03-10 23:09:28 +01:00
committed by fiatjaf_
parent 5539e5cf89
commit be7c981c14
3 changed files with 43 additions and 0 deletions

27
nip39.ts Normal file
View File

@@ -0,0 +1,27 @@
var _fetch: any
try {
_fetch = fetch
} catch {}
export function useFetchImplementation(fetchImplementation: any) {
_fetch = fetchImplementation
}
export async function validateGithub(
pubkey: string,
username: string,
proof: string
): Promise<boolean> {
try {
let res = await (
await _fetch(`https://gist.github.com/${username}/${proof}/raw`)
).text()
return (
res ===
`Verifying that I control the following Nostr public key: ${pubkey}`
)
} catch (_) {
return false
}
}