@handlepay/resolve 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -2
- package/dist/index.js +806 -0
- package/dist/index.js.map +1 -0
- package/dist/types/packages/resolve/src/index.d.ts +42 -0
- package/dist/types/src/lib/auth.d.ts +18 -0
- package/dist/types/src/lib/binding.d.ts +116 -0
- package/dist/types/src/lib/network.d.ts +36 -0
- package/dist/types/src/lib/nostr.d.ts +95 -0
- package/dist/types/src/lib/resolve.d.ts +35 -0
- package/package.json +29 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["HEX64"],"sources":["../../../src/lib/network.ts","../../../src/lib/binding.ts","../../../src/lib/nostr.ts","../../../src/lib/resolve.ts","../../../src/lib/auth.ts","../src/index.ts"],"sourcesContent":["import { ElectrumNetworkProvider } from \"cashscript\";\n\nexport type BchNetwork = \"chipnet\" | \"mainnet\";\n\n/** CashAddr prefix for each network. */\nexport const PREFIX: Record<BchNetwork, \"bchtest\" | \"bitcoincash\"> = {\n chipnet: \"bchtest\",\n mainnet: \"bitcoincash\",\n};\n\n/**\n * Link to HandlePay's own transaction page. Public chipnet explorers proved\n * unreliable (some only show unconfirmed transactions, one sits behind a bot\n * check), so links go to /tx/<txid>, which reads the transaction from the same\n * server the app already uses. The network is in the link so a shared link\n * shows the right chain. Absolute when a browser origin is available, so a\n * copied receipt carries a working link.\n */\nexport const explorerTx = (network: BchNetwork, txid: string) => {\n const origin = typeof window !== \"undefined\" ? window.location.origin : \"\";\n return `${origin}/tx/${txid}?network=${network}`;\n};\n\n/** Third-party explorers, offered as a second opinion on the transaction page. */\nexport const externalExplorers = (network: BchNetwork, txid: string): { name: string; url: string }[] =>\n network === \"mainnet\"\n ? [\n { name: \"Blockchair\", url: `https://blockchair.com/bitcoin-cash/transaction/${txid}` },\n { name: \"Blockchain.com\", url: `https://www.blockchain.com/explorer/transactions/bch/${txid}` },\n ]\n : [\n { name: \"Chaingraph\", url: `https://chipnet.chaingraph.cash/tx/${txid}` },\n { name: \"Imaginary (unconfirmed only)\", url: `https://chipnet.imaginary.cash/tx/${txid}` },\n ];\n\n/**\n * Electrum providers are cached per network. Each one opens a WebSocket to a\n * public Fulcrum server (CashScript's defaults: chipnet.bch.ninja for chipnet,\n * bch.imaginary.cash for mainnet). Override with VITE_ELECTRUM_CHIPNET /\n * VITE_ELECTRUM_MAINNET if a default server is down.\n */\nconst providers = new Map<BchNetwork, ElectrumNetworkProvider>();\n\nexport function getProvider(network: BchNetwork): ElectrumNetworkProvider {\n let provider = providers.get(network);\n if (!provider) {\n const hostname =\n network === \"chipnet\"\n ? import.meta.env?.VITE_ELECTRUM_CHIPNET\n : import.meta.env?.VITE_ELECTRUM_MAINNET;\n provider = hostname\n ? new ElectrumNetworkProvider(network, { hostname })\n : new ElectrumNetworkProvider(network);\n providers.set(network, provider);\n }\n return provider;\n}\n\nexport interface ChainTx {\n hex: string;\n /** 0 while in the mempool. */\n confirmations: number;\n}\n\n/**\n * Raw transaction plus confirmation count, from Fulcrum's verbose\n * `blockchain.transaction.get`. Callers re-hash `hex` against the txid; the\n * server is only trusted for availability and confirmation depth.\n */\n/**\n * True when the server answered that the transaction doesn't exist, as\n * opposed to not answering at all (timeout, connection dropped). Only the\n * first may be shown as \"not found\"; the second means \"couldn't check\".\n */\nexport function isTxNotFound(e: unknown): boolean {\n const message = e instanceof Error ? e.message : String(e);\n return /no such mempool|not found|unknown transaction/i.test(message);\n}\n\nexport async function getTransaction(network: BchNetwork, txid: string): Promise<ChainTx> {\n const result = (await getProvider(network).performRequest(\"blockchain.transaction.get\", txid, true)) as unknown;\n if (typeof result === \"string\") return { hex: result, confirmations: 0 };\n const r = result as { hex?: unknown; confirmations?: unknown };\n if (typeof r?.hex !== \"string\") throw new Error(`Transaction ${txid} not found.`);\n return { hex: r.hex, confirmations: typeof r.confirmations === \"number\" ? r.confirmations : 0 };\n}\n","/**\n * HPAY-BIND v1: a name is Verified when two proofs point at each other.\n *\n * - A BCH proof transaction, spent only from the bound address, carries\n * `OP_RETURN \"HPAY\" 0x01 <32-byte x-only Nostr pubkey>`.\n * - A Nostr event signed by that pubkey names the address and the proof txid.\n *\n * This module is pure: building events, parsing them, and checking a proof\n * transaction from raw bytes. Fetching lives in nostr.ts and resolve.ts.\n */\nimport {\n binToHex,\n cashAddressToLockingBytecode,\n decodeCashAddress,\n decodeTransaction,\n hashTransaction,\n hexToBin,\n type TransactionCommon,\n} from \"@bitauth/libauth\";\nimport type { EventTemplate, NostrEvent } from \"nostr-tools\";\nimport { PREFIX, type BchNetwork } from \"./network\";\n\n/** Binding event kind. Placeholder until Paytaca confirms a number. */\nexport const BINDING_KIND = 30145;\nexport const BINDING_D = \"bch-bind\";\n/** NIP-A3 public payment target. */\nexport const PAYTO_KIND = 10133;\n/** Paytaca's existing app-data format; read-only, never Verified. */\nexport const PAYTACA_KIND = 30078;\nexport const PAYTACA_D = \"paytaca:bch-address\";\n\nexport const PROOF_MAGIC = \"48504159\"; // \"HPAY\"\nexport const PROOF_VERSION = 1;\n\nconst HEX64 = /^[0-9a-f]{64}$/;\n\n// ---------------------------------------------------------------------------\n// Addresses\n// ---------------------------------------------------------------------------\n\n/** Strip the `bitcoincash:` / `bchtest:` prefix (tags store addresses bare). */\nexport function bareAddress(address: string): string {\n const i = address.indexOf(\":\");\n return (i >= 0 ? address.slice(i + 1) : address).toLowerCase();\n}\n\n/**\n * Normalise an address (with or without prefix) to the full P2PKH cashaddr for\n * `network`. Returns null if it doesn't decode, belongs to another network, or\n * isn't P2PKH (bindings are P2PKH only).\n */\nexport function normalizeAddress(address: string, network: BchNetwork): string | null {\n const full = `${PREFIX[network]}:${bareAddress(address)}`;\n if (address.includes(\":\") && !address.toLowerCase().startsWith(`${PREFIX[network]}:`)) return null;\n const decoded = decodeCashAddress(full);\n if (typeof decoded === \"string\") return null;\n if (decoded.type !== \"p2pkh\") return null;\n return full;\n}\n\nfunction lockingBytecodeHex(address: string): string {\n const decoded = cashAddressToLockingBytecode(address);\n if (typeof decoded === \"string\") throw new Error(decoded);\n return binToHex(decoded.bytecode);\n}\n\n// ---------------------------------------------------------------------------\n// Proof transaction\n// ---------------------------------------------------------------------------\n\n/** OP_RETURN chunks for `sendBch({ opReturn })`, in CashScript's \"0x…\" hex form. */\nexport function proofOpReturnChunks(pubkeyHex: string): string[] {\n const pubkey = pubkeyHex.toLowerCase();\n if (!HEX64.test(pubkey)) throw new Error(\"Nostr pubkey must be 32 bytes of hex.\");\n return [`0x${PROOF_MAGIC}`, `0x0${PROOF_VERSION}`, `0x${pubkey}`];\n}\n\n/**\n * Read the committed pubkey from one output's locking bytecode. Only the exact\n * canonical form is accepted:\n * `6a 04 48504159 01 01 20 <32 bytes>` (41 bytes).\n */\nexport function parseProofOutput(lockingBytecode: Uint8Array): string | null {\n const hex = binToHex(lockingBytecode);\n const head = `6a04${PROOF_MAGIC}010${PROOF_VERSION}20`;\n if (hex.length !== head.length + 64 || !hex.startsWith(head)) return null;\n return hex.slice(head.length);\n}\n\n/** Every pubkey a transaction commits to via an HPAY output. */\nexport function proofCommitments(tx: TransactionCommon): string[] {\n return tx.outputs.map((o) => parseProofOutput(o.lockingBytecode)).filter((p): p is string => p !== null);\n}\n\nexport type ProofCheckId = \"spends\" | \"commits\" | \"confirmed\" | \"network\";\n\nexport interface Check {\n id: ProofCheckId | \"nip05\" | \"signature\";\n ok: boolean;\n /** Plain-language line for the \"How we checked\" list. */\n label: string;\n /** Why it failed, when it did. */\n detail?: string;\n}\n\nexport interface ProofInput {\n /** Raw hex of the proof transaction, as served by Fulcrum. */\n proofHex: string;\n /** The txid the binding event names. */\n proofTxid: string;\n confirmations: number;\n /** Raw hex of each parent transaction, keyed by txid. */\n parents: Map<string, string>;\n /** Address the event claims, normalised for `network`. */\n address: string;\n /** Author of the binding event. */\n pubkey: string;\n /** Network the event says it's on. */\n eventNetwork: string;\n /** Network this page is resolving on. */\n network: BchNetwork;\n}\n\nfunction decodeHex(hex: string): TransactionCommon | null {\n try {\n const tx = decodeTransaction(hexToBin(hex));\n return typeof tx === \"string\" ? null : tx;\n } catch {\n return null;\n }\n}\n\n/**\n * The four BCH-side checks, all re-derived from raw bytes so a server can't\n * fake them beyond withholding data:\n *\n * a. every input spends a coin locked to the claimed address;\n * b. an output is `OP_RETURN HPAY 01 <pubkey>` with the event author's pubkey;\n * c. at least one confirmation;\n * d. the event's network matches the page's.\n *\n * Spec note: v1 requires *every* input to come from the bound address (the\n * proof transaction has \"no other inputs\"), so a mixed-input transaction is\n * Claimed, not Verified.\n */\nexport function checkProof(input: ProofInput): Check[] {\n const { proofHex, proofTxid, confirmations, parents, address, pubkey, eventNetwork, network } = input;\n const checks: Check[] = [];\n\n const tx = decodeHex(proofHex);\n const hashOk = tx !== null && hashTransaction(hexToBin(proofHex)) === proofTxid;\n\n // a. spends from the address\n let spends: Check = { id: \"spends\", ok: false, label: \"Proof was paid from this address\" };\n if (!hashOk) {\n spends.detail = \"Proof transaction could not be read\";\n } else {\n const want = lockingBytecodeHex(address);\n let ok = tx!.inputs.length > 0;\n let detail: string | undefined;\n for (const inp of tx!.inputs) {\n const parentTxid = binToHex(inp.outpointTransactionHash);\n const parentHex = parents.get(parentTxid);\n const parent = parentHex && hashTransaction(hexToBin(parentHex)) === parentTxid ? decodeHex(parentHex) : null;\n const spent = parent?.outputs[inp.outpointIndex];\n if (!spent) {\n ok = false;\n detail = \"Could not read a coin the proof spent\";\n break;\n }\n if (binToHex(spent.lockingBytecode) !== want) {\n ok = false;\n detail = \"Proof spends a coin from a different address\";\n break;\n }\n }\n spends = { ...spends, ok, detail: ok ? undefined : detail };\n }\n checks.push(spends);\n\n // b. commits to the author's pubkey\n const commitments = hashOk ? proofCommitments(tx!) : [];\n const commits: Check = {\n id: \"commits\",\n ok: commitments.includes(pubkey.toLowerCase()),\n label: \"Proof names this Nostr key\",\n };\n if (!commits.ok) {\n commits.detail = commitments.length\n ? \"Proof names a different Nostr key\"\n : hashOk\n ? \"No HandlePay proof in this transaction\"\n : \"Proof transaction could not be read\";\n }\n checks.push(commits);\n\n // c. confirmed\n checks.push({\n id: \"confirmed\",\n ok: hashOk && confirmations >= 1,\n label: \"Proof is confirmed on chain\",\n detail: hashOk && confirmations < 1 ? \"Waiting for confirmation\" : hashOk ? undefined : \"Proof not found\",\n });\n\n // d. network\n const netOk = eventNetwork === network;\n checks.push({\n id: \"network\",\n ok: netOk,\n label: `Binding is for ${network}`,\n detail: netOk ? undefined : `Binding is for ${eventNetwork || \"an unknown network\"}`,\n });\n\n return checks;\n}\n\n// ---------------------------------------------------------------------------\n// Nostr events\n// ---------------------------------------------------------------------------\n\nexport function buildBindingEvent(opts: {\n address: string;\n proofTxid: string;\n network: BchNetwork;\n nip05?: string;\n createdAt?: number;\n}): EventTemplate {\n const { address, proofTxid, network, nip05 } = opts;\n const normalized = normalizeAddress(address, network);\n if (!normalized) throw new Error(`Not a ${network} P2PKH address: ${address}`);\n if (!HEX64.test(proofTxid)) throw new Error(\"Proof txid must be 32 bytes of hex.\");\n const bare = bareAddress(normalized);\n const tags = [\n [\"d\", BINDING_D],\n [\"payto\", \"bitcoincash\", bare],\n [\"proof\", proofTxid],\n [\"network\", network],\n ];\n if (nip05) tags.push([\"nip05\", nip05.toLowerCase()]);\n return {\n kind: BINDING_KIND,\n created_at: opts.createdAt ?? Math.floor(Date.now() / 1000),\n tags,\n content: JSON.stringify({ v: 1, network, address: bare, proof: { type: \"op_return_spend\", txid: proofTxid } }),\n };\n}\n\nexport function buildRevokeEvent(createdAt?: number): EventTemplate {\n return {\n kind: BINDING_KIND,\n created_at: createdAt ?? Math.floor(Date.now() / 1000),\n tags: [[\"d\", BINDING_D]],\n content: JSON.stringify({ v: 1, revoked: true }),\n };\n}\n\n/** NIP-A3 payment target so other Nostr clients can find the address. */\nexport function buildPaytoEvent(address: string, createdAt?: number): EventTemplate {\n return {\n kind: PAYTO_KIND,\n created_at: createdAt ?? Math.floor(Date.now() / 1000),\n tags: [[\"payto\", \"bitcoincash\", bareAddress(address)]],\n content: \"\",\n };\n}\n\nexport type ParsedBinding =\n | { type: \"binding\"; address: string; proofTxid: string; network: string; nip05?: string }\n | { type: \"revoked\" }\n | { type: \"invalid\"; reason: string };\n\nconst tagValue = (event: NostrEvent, name: string, index = 1) => event.tags.find((t) => t[0] === name)?.[index];\n\n/**\n * Parse a kind-30145 event. Content and tags must agree; the address is\n * returned normalised for the event's own network.\n */\nexport function parseBindingEvent(event: NostrEvent): ParsedBinding {\n if (event.kind !== BINDING_KIND || tagValue(event, \"d\") !== BINDING_D) {\n return { type: \"invalid\", reason: \"Not a HandlePay binding\" };\n }\n let content: unknown;\n try {\n content = JSON.parse(event.content);\n } catch {\n return { type: \"invalid\", reason: \"Binding content is not JSON\" };\n }\n if (typeof content !== \"object\" || content === null) return { type: \"invalid\", reason: \"Binding content is empty\" };\n const c = content as Record<string, unknown>;\n if (c.v !== 1) return { type: \"invalid\", reason: \"Unsupported binding version\" };\n if (c.revoked === true) return { type: \"revoked\" };\n\n const network = typeof c.network === \"string\" ? c.network : \"\";\n if (network !== \"mainnet\" && network !== \"chipnet\") return { type: \"invalid\", reason: \"Unknown network\" };\n const address = typeof c.address === \"string\" ? normalizeAddress(c.address, network) : null;\n if (!address) return { type: \"invalid\", reason: \"Address does not match the network\" };\n const proof = c.proof as Record<string, unknown> | undefined;\n const txid = typeof proof?.txid === \"string\" ? proof.txid.toLowerCase() : \"\";\n if (proof?.type !== \"op_return_spend\" || !HEX64.test(txid)) return { type: \"invalid\", reason: \"Missing proof\" };\n\n const payto = event.tags.find((t) => t[0] === \"payto\" && t[1] === \"bitcoincash\")?.[2];\n if (!payto || bareAddress(payto) !== bareAddress(address)) {\n return { type: \"invalid\", reason: \"Tags and content name different addresses\" };\n }\n if ((tagValue(event, \"proof\") ?? \"\").toLowerCase() !== txid) {\n return { type: \"invalid\", reason: \"Tags and content name different proofs\" };\n }\n if (tagValue(event, \"network\") !== network) return { type: \"invalid\", reason: \"Tags and content disagree on network\" };\n\n return { type: \"binding\", address, proofTxid: txid, network, nip05: tagValue(event, \"nip05\") };\n}\n\n/** Address from a NIP-A3 `payto` event (Claimed only). */\nexport function parsePaytoEvent(event: NostrEvent, network: BchNetwork): string | null {\n if (event.kind !== PAYTO_KIND) return null;\n for (const t of event.tags) {\n if (t[0] === \"payto\" && t[1] === \"bitcoincash\" && t[2]) {\n const a = normalizeAddress(t[2], network);\n if (a) return a;\n }\n }\n return null;\n}\n\n/**\n * Address from Paytaca's kind-30078 `paytaca:bch-address` event (Claimed only).\n * The exact content format is unconfirmed, so this accepts either a bare\n * address string or a JSON object with an `address` field.\n */\nexport function parsePaytacaEvent(event: NostrEvent, network: BchNetwork): string | null {\n if (event.kind !== PAYTACA_KIND || tagValue(event, \"d\") !== PAYTACA_D) return null;\n let candidate = event.content.trim();\n try {\n const parsed = JSON.parse(candidate);\n if (parsed && typeof parsed.address === \"string\") candidate = parsed.address;\n } catch {\n /* plain string content */\n }\n return normalizeAddress(candidate, network);\n}\n","/**\n * Nostr I/O: NIP-05 lookups, relay queries and publishing, NIP-07 signing.\n * Every event that comes back from a relay or a signer is signature-checked\n * here before anything else sees it.\n */\nimport type { WindowNostr } from \"nostr-tools/nip07\";\nimport { SimplePool } from \"nostr-tools/pool\";\nimport { verifyEvent, type EventTemplate, type NostrEvent } from \"nostr-tools/pure\";\nimport { BINDING_D, BINDING_KIND, PAYTACA_D, PAYTACA_KIND, PAYTO_KIND } from \"./binding\";\n\ndeclare global {\n interface Window {\n nostr?: WindowNostr;\n }\n}\n\n/** Always queried and published to, alongside any relays the NIP-05 file lists. */\nexport const DEFAULT_RELAYS = [\"wss://relay.damus.io\", \"wss://nos.lol\", \"wss://relay.primal.net\"];\n\nconst HEX64 = /^[0-9a-f]{64}$/;\n\n// ---------------------------------------------------------------------------\n// Handles and NIP-05\n// ---------------------------------------------------------------------------\n\nexport interface Handle {\n local: string;\n domain: string;\n /** Canonical lowercase `local@domain`. */\n full: string;\n /** Non-ASCII characters can hide look-alike names; the UI flags these. */\n nonAscii: boolean;\n}\n\n/** Parse `local@domain`. Returns null if it can't be a NIP-05 name. */\nexport function parseHandle(input: string): Handle | null {\n const trimmed = input.trim().toLowerCase();\n const at = trimmed.lastIndexOf(\"@\");\n if (at <= 0 || at === trimmed.length - 1) return null;\n const local = trimmed.slice(0, at);\n const domain = trimmed.slice(at + 1);\n // NIP-05 local parts are a-z0-9-_. ; we also allow non-ASCII so we can flag it.\n if (!/^[\\p{L}\\p{N}._-]+$/u.test(local)) return null;\n if (!/^[\\p{L}\\p{N}-]+(\\.[\\p{L}\\p{N}-]+)+$/u.test(domain)) return null;\n const nonAscii = /[^\\x20-\\x7e]/.test(trimmed);\n return { local, domain, full: `${local}@${domain}`, nonAscii };\n}\n\nexport interface Nip05Result {\n pubkey: string;\n relays: string[];\n}\n\nexport class Nip05UnreachableError extends Error {\n constructor(domain: string) {\n super(`Couldn't reach ${domain} to look up this name.`);\n this.name = \"Nip05UnreachableError\";\n }\n}\n\ntype FetchLike = (url: string, init?: RequestInit) => Promise<Response>;\n\n/** Parse a nostr.json body for one name. */\nexport function readNip05Json(json: unknown, local: string): Nip05Result | null {\n if (typeof json !== \"object\" || json === null) return null;\n const j = json as { names?: Record<string, unknown>; relays?: Record<string, unknown> };\n const pubkey = j.names?.[local];\n if (typeof pubkey !== \"string\" || !HEX64.test(pubkey)) return null;\n const listed = j.relays?.[pubkey];\n const relays = Array.isArray(listed) ? listed.filter((r): r is string => typeof r === \"string\" && r.startsWith(\"wss://\")) : [];\n return { pubkey, relays };\n}\n\n/**\n * Look up `local@domain` via `https://domain/.well-known/nostr.json?name=local`.\n * Tries the domain directly; if that fails at the network level (usually CORS),\n * retries through the HandlePay Worker when `proxy` is set.\n *\n * Returns null when the domain answers but doesn't list the name; throws\n * Nip05UnreachableError when it can't be reached at all.\n */\nexport async function fetchNip05(\n handle: Handle,\n opts: { fetchImpl?: FetchLike; proxy?: string; timeoutMs?: number } = {},\n): Promise<Nip05Result | null> {\n const fetchImpl = opts.fetchImpl ?? ((url, init) => fetch(url, init));\n const proxy = opts.proxy ?? import.meta.env?.VITE_NIP05_PROXY;\n const timeoutMs = opts.timeoutMs ?? 5_000;\n const direct = `https://${handle.domain}/.well-known/nostr.json?name=${encodeURIComponent(handle.local)}`;\n const urls = [direct];\n if (proxy) urls.push(`${proxy.replace(/\\/$/, \"\")}/nip05?name=${encodeURIComponent(handle.full)}`);\n\n for (const url of urls) {\n let response: Response;\n try {\n // NIP-05 forbids following redirects.\n response = await fetchImpl(url, { redirect: \"error\", signal: AbortSignal.timeout(timeoutMs) });\n } catch {\n continue; // network / CORS failure: try the next route\n }\n if (response.status === 404) return null;\n if (!response.ok) continue;\n try {\n return readNip05Json(await response.json(), handle.local);\n } catch {\n return null;\n }\n }\n throw new Nip05UnreachableError(handle.domain);\n}\n\n// ---------------------------------------------------------------------------\n// Relays\n// ---------------------------------------------------------------------------\n\nlet pool: SimplePool | null = null;\nfunction getPool() {\n pool ??= new SimplePool();\n return pool;\n}\n\nexport function relaysFor(extra: string[] = []): string[] {\n return [...new Set([...extra, ...DEFAULT_RELAYS].map((r) => r.replace(/\\/$/, \"\")))];\n}\n\n/** No relay could be reached, so an empty answer would mean \"couldn't check\", not \"nothing published\". */\nexport class RelaysUnreachableError extends Error {\n constructor() {\n super(\"Couldn't reach any Nostr relay to read this name's records. Check your connection and try again.\");\n this.name = \"RelaysUnreachableError\";\n }\n}\n\n/**\n * The relays that accept a connection. querySync answers [] both when relays have nothing and when\n * none can be reached; connecting first tells the two apart, so a dead connection reads as\n * \"couldn't check\", never as \"no identity\". Throws RelaysUnreachableError when none connect.\n */\nexport async function reachableRelays(\n p: { ensureRelay(url: string, params?: { connectionTimeout?: number }): Promise<unknown> },\n relays: string[],\n timeout: number,\n): Promise<string[]> {\n const connected = await Promise.allSettled(relays.map((url) => p.ensureRelay(url, { connectionTimeout: timeout })));\n const ok = relays.filter((_, i) => connected[i].status === \"fulfilled\");\n if (!ok.length) throw new RelaysUnreachableError();\n return ok;\n}\n\n/**\n * Fetch a pubkey's identity events (binding, payto, Paytaca) from relays.\n * Drops anything with a bad signature or a different author.\n *\n * Throws RelaysUnreachableError when not one relay can be connected to.\n */\nexport async function queryIdentityEvents(pubkey: string, relays: string[], maxWait = 4_000): Promise<NostrEvent[]> {\n const p = getPool();\n relays = await reachableRelays(p, relays, maxWait);\n const results = await Promise.all([\n p.querySync(relays, { authors: [pubkey], kinds: [BINDING_KIND], \"#d\": [BINDING_D] }, { maxWait }),\n p.querySync(relays, { authors: [pubkey], kinds: [PAYTO_KIND] }, { maxWait }),\n p.querySync(relays, { authors: [pubkey], kinds: [PAYTACA_KIND], \"#d\": [PAYTACA_D] }, { maxWait }),\n ]);\n return dedupeVerified(results.flat(), pubkey);\n}\n\n/**\n * Check an event's id and signature from its fields alone.\n *\n * nostr-tools caches a successful check in a symbol property on the event\n * object, and object spread copies that symbol. So `{...signed, sig: other}`\n * would pass `verifyEvent` without being checked. Verifying a fresh copy of\n * the NIP-01 fields defeats the cache.\n */\nexport function verifySignature(e: NostrEvent): boolean {\n const { id, pubkey, created_at, kind, tags, content, sig } = e;\n try {\n return verifyEvent({ id, pubkey, created_at, kind, tags, content, sig });\n } catch {\n return false;\n }\n}\n\n/** Unique events by id, signature-checked, from `author` only. */\nexport function dedupeVerified(events: NostrEvent[], author: string): NostrEvent[] {\n const seen = new Map<string, NostrEvent>();\n for (const e of events) {\n if (seen.has(e.id) || e.pubkey !== author) continue;\n if (!verifySignature(e)) continue;\n seen.set(e.id, e);\n }\n return [...seen.values()];\n}\n\n/** Newest event, ties broken by lowest id (NIP-01 replaceable-event rule). */\nexport function newest(events: NostrEvent[]): NostrEvent | undefined {\n return [...events].sort((a, b) => b.created_at - a.created_at || (a.id < b.id ? -1 : 1))[0];\n}\n\nexport interface PublishResult {\n ok: string[];\n failed: { relay: string; reason: string }[];\n}\n\nexport async function publishEvent(event: NostrEvent, relays: string[]): Promise<PublishResult> {\n const attempts = getPool().publish(relays, event);\n const settled = await Promise.allSettled(attempts);\n const result: PublishResult = { ok: [], failed: [] };\n settled.forEach((s, i) => {\n if (s.status === \"fulfilled\") result.ok.push(relays[i]);\n else result.failed.push({ relay: relays[i], reason: String((s.reason as Error)?.message ?? s.reason) });\n });\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// NIP-07 signer (Alby, nos2x, …)\n// ---------------------------------------------------------------------------\n\nexport function hasSigner(): boolean {\n return typeof window !== \"undefined\" && !!window.nostr;\n}\n\nexport async function signerPubkey(): Promise<string> {\n if (!window.nostr) throw new Error(\"No Nostr signer found. Install Alby or nos2x, then reload.\");\n const pubkey = await window.nostr.getPublicKey();\n if (!HEX64.test(pubkey)) throw new Error(\"The Nostr signer returned an invalid key.\");\n return pubkey;\n}\n\n/** Sign with the browser extension and check the result before trusting it. */\nexport async function signWithExtension(template: EventTemplate, expectedPubkey?: string): Promise<NostrEvent> {\n if (!window.nostr) throw new Error(\"No Nostr signer found. Install Alby or nos2x, then reload.\");\n const event = await window.nostr.signEvent(template);\n if (!verifySignature(event)) throw new Error(\"The Nostr signer returned a bad signature.\");\n if (expectedPubkey && event.pubkey !== expectedPubkey) {\n throw new Error(\"The Nostr signer used a different key than the one you connected.\");\n }\n return event;\n}\n","/**\n * resolveHandle: name → Verified / Claimed / Changed / Not found, with the\n * reasons. All fetching goes through `ResolveDeps`, so the same logic runs\n * against live relays and Fulcrum or against test fixtures.\n */\nimport { binToHex, decodeTransaction, hexToBin } from \"@bitauth/libauth\";\nimport type { NostrEvent } from \"nostr-tools/pure\";\nimport {\n BINDING_KIND,\n PAYTACA_KIND,\n PAYTO_KIND,\n checkProof,\n normalizeAddress,\n parseBindingEvent,\n parsePaytacaEvent,\n parsePaytoEvent,\n type Check,\n} from \"./binding\";\nimport { getTransaction, isTxNotFound, type BchNetwork, type ChainTx } from \"./network\";\nimport {\n dedupeVerified,\n fetchNip05,\n newest,\n parseHandle,\n queryIdentityEvents,\n relaysFor,\n type Handle,\n type Nip05Result,\n} from \"./nostr\";\n\nexport type Status = \"verified\" | \"claimed\" | \"changed\" | \"not_found\";\n\nexport interface Pin {\n pubkey: string;\n address: string;\n}\n\nexport interface Resolution {\n status: Status;\n /** Canonical handle, when the input parsed. */\n handle?: Handle;\n pubkey?: string;\n /** Payable address on this page's network. Absent for Not found. */\n address?: string;\n proofTxid?: string;\n /** Where the address came from. */\n source?: \"binding\" | \"payto\" | \"paytaca\";\n /** The \"How we checked\" list, in order. */\n checks: Check[];\n /** One-line reason shown when the status isn't Verified. */\n reason?: string;\n /** What this browser saw before, when the status is Changed. */\n previous?: Pin;\n}\n\nexport interface ResolveDeps {\n fetchNip05(handle: Handle): Promise<Nip05Result | null>;\n queryEvents(pubkey: string, relays: string[]): Promise<NostrEvent[]>;\n getTransaction(txid: string): Promise<ChainTx>;\n}\n\nexport function liveDeps(network: BchNetwork): ResolveDeps {\n return {\n fetchNip05: (h) => fetchNip05(h),\n queryEvents: (pubkey, relays) => queryIdentityEvents(pubkey, relays),\n getTransaction: (txid) => getTransaction(network, txid),\n };\n}\n\nconst firstFailure = (checks: Check[]) => checks.find((c) => !c.ok);\n\nexport async function resolveHandle(\n input: string,\n network: BchNetwork,\n deps: ResolveDeps,\n pinned?: Pin | null,\n): Promise<Resolution> {\n const handle = parseHandle(input) ?? undefined;\n if (!handle) return { status: \"not_found\", checks: [], reason: \"That doesn't look like a name (name@domain)\" };\n\n // 1. Name → Nostr key\n let nip05: Nip05Result | null;\n try {\n nip05 = await deps.fetchNip05(handle);\n } catch (e) {\n return {\n status: \"not_found\",\n handle,\n checks: [{ id: \"nip05\", ok: false, label: `${handle.domain} lists this name`, detail: (e as Error).message }],\n reason: (e as Error).message,\n };\n }\n const nip05Check: Check = { id: \"nip05\", ok: !!nip05, label: `${handle.domain} lists this name` };\n if (!nip05) {\n return { status: \"not_found\", handle, checks: [{ ...nip05Check, detail: \"Name not listed\" }], reason: \"No HandlePay identity for this name\" };\n }\n const { pubkey } = nip05;\n\n // 2. Key → signed events (re-verified here even if deps already did)\n const events = dedupeVerified(await deps.queryEvents(pubkey, relaysFor(nip05.relays)), pubkey);\n const binding = newest(events.filter((e) => e.kind === BINDING_KIND));\n const parsed = binding ? parseBindingEvent(binding) : undefined;\n\n // 3. Revoked\n if (parsed?.type === \"revoked\") {\n return {\n status: \"not_found\",\n handle,\n pubkey,\n checks: [nip05Check, { id: \"signature\", ok: false, label: \"Signed binding found\", detail: \"Binding revoked\" }],\n reason: \"Binding revoked\",\n };\n }\n\n // 4–5. Binding with BCH proof\n if (parsed?.type === \"binding\") {\n const signature: Check = { id: \"signature\", ok: true, label: \"Signed by this name's Nostr key\" };\n const proofChecks = await gatherProofChecks(parsed, pubkey, network, deps);\n const checks = [nip05Check, signature, ...proofChecks];\n const address = normalizeAddress(parsed.address, network) ?? undefined;\n const failed = firstFailure(checks);\n if (failed || !address) {\n return {\n status: \"claimed\",\n handle,\n pubkey,\n address,\n proofTxid: parsed.proofTxid,\n source: \"binding\",\n checks,\n reason: failed?.detail ?? \"Address is for another network\",\n };\n }\n const result: Resolution = { status: \"verified\", handle, pubkey, address, proofTxid: parsed.proofTxid, source: \"binding\", checks };\n // 6. Trust on first use\n if (pinned && (pinned.pubkey !== pubkey || pinned.address !== address)) {\n return { ...result, status: \"changed\", previous: pinned, reason: \"This name now points to a different address than last time\" };\n }\n return result;\n }\n\n // Fallbacks: a claim with no BCH proof\n const payto = newest(events.filter((e) => e.kind === PAYTO_KIND));\n const paytoAddress = payto ? parsePaytoEvent(payto, network) : null;\n const paytaca = newest(events.filter((e) => e.kind === PAYTACA_KIND));\n const paytacaAddress = paytaca ? parsePaytacaEvent(paytaca, network) : null;\n const claimed = paytoAddress ?? paytacaAddress;\n const bindingProblem = parsed?.type === \"invalid\" ? parsed.reason : undefined;\n\n if (claimed) {\n return {\n status: \"claimed\",\n handle,\n pubkey,\n address: claimed,\n source: paytoAddress ? \"payto\" : \"paytaca\",\n checks: [\n nip05Check,\n { id: \"signature\", ok: true, label: \"Signed by this name's Nostr key\" },\n { id: \"spends\", ok: false, label: \"Proof was paid from this address\", detail: \"No BCH proof from this address\" },\n ],\n reason: bindingProblem ?? \"No BCH proof from this address\",\n };\n }\n\n return {\n status: \"not_found\",\n handle,\n pubkey,\n checks: [nip05Check, { id: \"signature\", ok: false, label: \"Signed binding found\", detail: bindingProblem ?? \"No binding published\" }],\n reason: bindingProblem ?? \"No HandlePay identity for this name\",\n };\n}\n\nasync function gatherProofChecks(\n parsed: { address: string; proofTxid: string; network: string },\n pubkey: string,\n network: BchNetwork,\n deps: ResolveDeps,\n): Promise<Check[]> {\n // A server that doesn't answer is not evidence against the name: fail the\n // whole check (\"Couldn't check this name · Try again\") instead of showing\n // Claimed. Only a server that says the transaction doesn't exist counts.\n const unreachable = () =>\n new Error(`Couldn't reach the ${network} BCH server to check the proof. Check your connection and try again.`);\n\n let proof: ChainTx;\n try {\n proof = await deps.getTransaction(parsed.proofTxid);\n } catch (e) {\n if (!isTxNotFound(e)) throw unreachable();\n return [\n { id: \"spends\", ok: false, label: \"Proof was paid from this address\", detail: \"Proof transaction not found\" },\n { id: \"commits\", ok: false, label: \"Proof names this Nostr key\", detail: \"Proof transaction not found\" },\n { id: \"confirmed\", ok: false, label: \"Proof is confirmed on chain\", detail: \"Proof transaction not found\" },\n {\n id: \"network\",\n ok: parsed.network === network,\n label: `Binding is for ${network}`,\n detail: parsed.network === network ? undefined : `Binding is for ${parsed.network}`,\n },\n ];\n }\n\n // Fetch each parent so \"spends from this address\" is checked from raw bytes.\n const parents = new Map<string, string>();\n try {\n const tx = decodeTransaction(hexToBin(proof.hex));\n if (typeof tx !== \"string\") {\n const ids = [...new Set(tx.inputs.map((i) => binToHex(i.outpointTransactionHash)))];\n await Promise.all(\n ids.map(async (id) => {\n try {\n parents.set(id, (await deps.getTransaction(id)).hex);\n } catch (e) {\n if (!isTxNotFound(e)) throw unreachable();\n /* missing parent → the spends check fails with a reason */\n }\n }),\n );\n }\n } catch (e) {\n if (e instanceof Error && e.message.startsWith(\"Couldn't reach\")) throw e;\n /* undecodable → checkProof reports it */\n }\n\n return checkProof({\n proofHex: proof.hex,\n proofTxid: parsed.proofTxid,\n confirmations: proof.confirmations,\n parents,\n address: parsed.address,\n pubkey,\n eventNetwork: parsed.network,\n network,\n });\n}\n\n/** Whether the pay button is allowed, and what has to be confirmed first. */\nexport function paymentGate(r: Resolution): \"allowed\" | \"confirm_unverified\" | \"acknowledge_change\" | \"blocked\" {\n if (!r.address) return \"blocked\";\n switch (r.status) {\n case \"verified\":\n return \"allowed\";\n case \"claimed\":\n return \"confirm_unverified\";\n case \"changed\":\n return \"acknowledge_change\";\n default:\n return \"blocked\";\n }\n}\n","/**\n * F4: challenge–response sign-in against a handle's Nostr key. No server:\n * the verifier makes the challenge, the user signs a kind-22242 event with\n * NIP-07, and the verifier checks it. A real site must create and remember\n * the challenge itself; this page does both ends to demonstrate the flow.\n */\nimport { binToHex } from \"@bitauth/libauth\";\nimport type { EventTemplate, NostrEvent } from \"nostr-tools/pure\";\nimport { verifySignature } from \"./nostr\";\n\nexport const AUTH_KIND = 22242;\nexport const AUTH_MAX_AGE_SEC = 5 * 60;\n\nexport function createChallenge(): string {\n return binToHex(crypto.getRandomValues(new Uint8Array(32)));\n}\n\nexport function buildAuthTemplate(challenge: string, origin: string, createdAt?: number): EventTemplate {\n return {\n kind: AUTH_KIND,\n created_at: createdAt ?? Math.floor(Date.now() / 1000),\n tags: [\n [\"challenge\", challenge],\n [\"relay\", origin],\n ],\n content: \"\",\n };\n}\n\nexport type AuthResult = { ok: true; pubkey: string } | { ok: false; reason: string };\n\nexport function verifyAuthEvent(\n event: NostrEvent,\n expected: { challenge: string; origin: string; pubkey: string; now?: number },\n): AuthResult {\n const now = expected.now ?? Math.floor(Date.now() / 1000);\n const tag = (name: string) => event.tags.find((t) => t[0] === name)?.[1];\n if (event.kind !== AUTH_KIND) return { ok: false, reason: \"Not a sign-in event\" };\n if (!verifySignature(event)) return { ok: false, reason: \"Signature is invalid\" };\n if (tag(\"challenge\") !== expected.challenge) return { ok: false, reason: \"Signed a different challenge\" };\n if (tag(\"relay\") !== expected.origin) return { ok: false, reason: \"Signed for a different site\" };\n if (Math.abs(now - event.created_at) > AUTH_MAX_AGE_SEC) return { ok: false, reason: \"Sign-in expired; try again\" };\n if (event.pubkey !== expected.pubkey) return { ok: false, reason: \"Signed with a key this name doesn't use\" };\n return { ok: true, pubkey: event.pubkey };\n}\n","/**\n * @handlepay/resolve: check a name like `sani@lycanforge.com.ng` and get back\n * the Bitcoin Cash address it has proven it controls, or the reason it hasn't.\n *\n * This is the same code the HandlePay app runs (src/lib), re-exported, so the\n * app and the package can't drift apart. See docs/SPEC.md for the protocol.\n */\nimport type { BchNetwork } from \"../../../src/lib/network\";\nimport { liveDeps, resolveHandle, type Pin, type Resolution, type ResolveDeps } from \"../../../src/lib/resolve\";\n\nexport interface ResolveOptions {\n /** Which chain the address must be on. Default: mainnet. */\n network?: BchNetwork;\n /**\n * What you saw for this name last time. If the name now resolves to a\n * different key or address, the status is \"changed\" instead of \"verified\".\n */\n pinned?: Pin | null;\n /** Replace the network lookups, for tests or your own servers. */\n deps?: ResolveDeps;\n}\n\n/**\n * Resolve a name to a verified address.\n *\n * Looks the name up with NIP-05, reads its signed binding from Nostr relays,\n * and checks the BCH proof transaction from raw bytes. Pay `address` only\n * when `status` is \"verified\" (or after your user has confirmed a \"claimed\"\n * or \"changed\" result, as the app does).\n *\n * Rejects, rather than returning \"not_found\", when it can't check: no Nostr\n * relay could be reached (RelaysUnreachableError) or the BCH server didn't\n * answer. A name you couldn't check isn't a name that doesn't exist.\n */\nexport async function resolve(name: string, options: ResolveOptions = {}): Promise<Resolution> {\n const network = options.network ?? \"mainnet\";\n return resolveHandle(name, network, options.deps ?? liveDeps(network), options.pinned);\n}\n\nexport { resolveHandle, liveDeps, paymentGate } from \"../../../src/lib/resolve\";\nexport type { Pin, Resolution, ResolveDeps, Status } from \"../../../src/lib/resolve\";\n\nexport {\n BINDING_KIND,\n BINDING_D,\n PAYTO_KIND,\n PROOF_MAGIC,\n PROOF_VERSION,\n buildBindingEvent,\n buildPaytoEvent,\n buildRevokeEvent,\n checkProof,\n normalizeAddress,\n parseBindingEvent,\n parseProofOutput,\n proofOpReturnChunks,\n} from \"../../../src/lib/binding\";\nexport type { Check, ParsedBinding, ProofInput } from \"../../../src/lib/binding\";\n\nexport { DEFAULT_RELAYS, RelaysUnreachableError, fetchNip05, parseHandle, queryIdentityEvents } from \"../../../src/lib/nostr\";\nexport type { Handle, Nip05Result } from \"../../../src/lib/nostr\";\n\nexport { AUTH_KIND, AUTH_MAX_AGE_SEC, buildAuthTemplate, createChallenge, verifyAuthEvent } from \"../../../src/lib/auth\";\nexport type { AuthResult } from \"../../../src/lib/auth\";\n\nexport type { BchNetwork } from \"../../../src/lib/network\";\n"],"mappings":";;;;;;AAKA,IAAa,SAAwD;CACnE,SAAS;CACT,SAAS;AACX;;;;;;;AAiCA,IAAM,4BAAY,IAAI,IAAyC;AAE/D,SAAgB,YAAY,SAA8C;CACxE,IAAI,WAAW,UAAU,IAAI,OAAO;CACpC,IAAI,CAAC,UAAU;EACb,MAAM,WACJ,YAAY,YAAA,KAAA,IAAA,KAAA;EAGd,WAAW,WACP,IAAI,wBAAwB,SAAS,EAAE,SAAS,CAAC,IACjD,IAAI,wBAAwB,OAAO;EACvC,UAAU,IAAI,SAAS,QAAQ;CACjC;CACA,OAAO;AACT;;;;;;;;;;;AAkBA,SAAgB,aAAa,GAAqB;CAChD,MAAM,UAAU,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;CACzD,OAAO,iDAAiD,KAAK,OAAO;AACtE;AAEA,eAAsB,eAAe,SAAqB,MAAgC;CACxF,MAAM,SAAU,MAAM,YAAY,OAAO,CAAC,CAAC,eAAe,8BAA8B,MAAM,IAAI;CAClG,IAAI,OAAO,WAAW,UAAU,OAAO;EAAE,KAAK;EAAQ,eAAe;CAAE;CACvE,MAAM,IAAI;CACV,IAAI,OAAO,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CAChG,IAAI,KAAK,IAAI,MAAM,MAAM,UAAU,IAAA,KAAsB,OAAO;EAAE,IAAI;EAAO,QAAQ;CAA6B;CAClH,IAAI,MAAM,WAAW,SAAS,QAAQ,OAAO;EAAE,IAAI;EAAO,QAAQ;CAA0C;CAC5G,OAAO;EAAE,IAAI;EAAM,QAAQ,MAAM;CAAO;AAC1C;;;;;;;;;;;;;;ACVA,eAAsB,QAAQ,MAAc,UAA0B,CAAC,GAAwB;CAC7F,MAAM,UAAU,QAAQ,WAAW;CACnC,OAAO,cAAc,MAAM,SAAS,QAAQ,QAAQ,SAAS,OAAO,GAAG,QAAQ,MAAM;AACvF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @handlepay/resolve: check a name like `sani@lycanforge.com.ng` and get back
|
|
3
|
+
* the Bitcoin Cash address it has proven it controls, or the reason it hasn't.
|
|
4
|
+
*
|
|
5
|
+
* This is the same code the HandlePay app runs (src/lib), re-exported, so the
|
|
6
|
+
* app and the package can't drift apart. See docs/SPEC.md for the protocol.
|
|
7
|
+
*/
|
|
8
|
+
import type { BchNetwork } from "../../../src/lib/network";
|
|
9
|
+
import { type Pin, type Resolution, type ResolveDeps } from "../../../src/lib/resolve";
|
|
10
|
+
export interface ResolveOptions {
|
|
11
|
+
/** Which chain the address must be on. Default: mainnet. */
|
|
12
|
+
network?: BchNetwork;
|
|
13
|
+
/**
|
|
14
|
+
* What you saw for this name last time. If the name now resolves to a
|
|
15
|
+
* different key or address, the status is "changed" instead of "verified".
|
|
16
|
+
*/
|
|
17
|
+
pinned?: Pin | null;
|
|
18
|
+
/** Replace the network lookups, for tests or your own servers. */
|
|
19
|
+
deps?: ResolveDeps;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a name to a verified address.
|
|
23
|
+
*
|
|
24
|
+
* Looks the name up with NIP-05, reads its signed binding from Nostr relays,
|
|
25
|
+
* and checks the BCH proof transaction from raw bytes. Pay `address` only
|
|
26
|
+
* when `status` is "verified" (or after your user has confirmed a "claimed"
|
|
27
|
+
* or "changed" result, as the app does).
|
|
28
|
+
*
|
|
29
|
+
* Rejects, rather than returning "not_found", when it can't check: no Nostr
|
|
30
|
+
* relay could be reached (RelaysUnreachableError) or the BCH server didn't
|
|
31
|
+
* answer. A name you couldn't check isn't a name that doesn't exist.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolve(name: string, options?: ResolveOptions): Promise<Resolution>;
|
|
34
|
+
export { resolveHandle, liveDeps, paymentGate } from "../../../src/lib/resolve";
|
|
35
|
+
export type { Pin, Resolution, ResolveDeps, Status } from "../../../src/lib/resolve";
|
|
36
|
+
export { BINDING_KIND, BINDING_D, PAYTO_KIND, PROOF_MAGIC, PROOF_VERSION, buildBindingEvent, buildPaytoEvent, buildRevokeEvent, checkProof, normalizeAddress, parseBindingEvent, parseProofOutput, proofOpReturnChunks, } from "../../../src/lib/binding";
|
|
37
|
+
export type { Check, ParsedBinding, ProofInput } from "../../../src/lib/binding";
|
|
38
|
+
export { DEFAULT_RELAYS, RelaysUnreachableError, fetchNip05, parseHandle, queryIdentityEvents } from "../../../src/lib/nostr";
|
|
39
|
+
export type { Handle, Nip05Result } from "../../../src/lib/nostr";
|
|
40
|
+
export { AUTH_KIND, AUTH_MAX_AGE_SEC, buildAuthTemplate, createChallenge, verifyAuthEvent } from "../../../src/lib/auth";
|
|
41
|
+
export type { AuthResult } from "../../../src/lib/auth";
|
|
42
|
+
export type { BchNetwork } from "../../../src/lib/network";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EventTemplate, NostrEvent } from "nostr-tools/pure";
|
|
2
|
+
export declare const AUTH_KIND = 22242;
|
|
3
|
+
export declare const AUTH_MAX_AGE_SEC: number;
|
|
4
|
+
export declare function createChallenge(): string;
|
|
5
|
+
export declare function buildAuthTemplate(challenge: string, origin: string, createdAt?: number): EventTemplate;
|
|
6
|
+
export type AuthResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
pubkey: string;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function verifyAuthEvent(event: NostrEvent, expected: {
|
|
14
|
+
challenge: string;
|
|
15
|
+
origin: string;
|
|
16
|
+
pubkey: string;
|
|
17
|
+
now?: number;
|
|
18
|
+
}): AuthResult;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HPAY-BIND v1: a name is Verified when two proofs point at each other.
|
|
3
|
+
*
|
|
4
|
+
* - A BCH proof transaction, spent only from the bound address, carries
|
|
5
|
+
* `OP_RETURN "HPAY" 0x01 <32-byte x-only Nostr pubkey>`.
|
|
6
|
+
* - A Nostr event signed by that pubkey names the address and the proof txid.
|
|
7
|
+
*
|
|
8
|
+
* This module is pure: building events, parsing them, and checking a proof
|
|
9
|
+
* transaction from raw bytes. Fetching lives in nostr.ts and resolve.ts.
|
|
10
|
+
*/
|
|
11
|
+
import { type TransactionCommon } from "@bitauth/libauth";
|
|
12
|
+
import type { EventTemplate, NostrEvent } from "nostr-tools";
|
|
13
|
+
import { type BchNetwork } from "./network";
|
|
14
|
+
/** Binding event kind. Placeholder until Paytaca confirms a number. */
|
|
15
|
+
export declare const BINDING_KIND = 30145;
|
|
16
|
+
export declare const BINDING_D = "bch-bind";
|
|
17
|
+
/** NIP-A3 public payment target. */
|
|
18
|
+
export declare const PAYTO_KIND = 10133;
|
|
19
|
+
/** Paytaca's existing app-data format; read-only, never Verified. */
|
|
20
|
+
export declare const PAYTACA_KIND = 30078;
|
|
21
|
+
export declare const PAYTACA_D = "paytaca:bch-address";
|
|
22
|
+
export declare const PROOF_MAGIC = "48504159";
|
|
23
|
+
export declare const PROOF_VERSION = 1;
|
|
24
|
+
/** Strip the `bitcoincash:` / `bchtest:` prefix (tags store addresses bare). */
|
|
25
|
+
export declare function bareAddress(address: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Normalise an address (with or without prefix) to the full P2PKH cashaddr for
|
|
28
|
+
* `network`. Returns null if it doesn't decode, belongs to another network, or
|
|
29
|
+
* isn't P2PKH (bindings are P2PKH only).
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeAddress(address: string, network: BchNetwork): string | null;
|
|
32
|
+
/** OP_RETURN chunks for `sendBch({ opReturn })`, in CashScript's "0x…" hex form. */
|
|
33
|
+
export declare function proofOpReturnChunks(pubkeyHex: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Read the committed pubkey from one output's locking bytecode. Only the exact
|
|
36
|
+
* canonical form is accepted:
|
|
37
|
+
* `6a 04 48504159 01 01 20 <32 bytes>` (41 bytes).
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseProofOutput(lockingBytecode: Uint8Array): string | null;
|
|
40
|
+
/** Every pubkey a transaction commits to via an HPAY output. */
|
|
41
|
+
export declare function proofCommitments(tx: TransactionCommon): string[];
|
|
42
|
+
export type ProofCheckId = "spends" | "commits" | "confirmed" | "network";
|
|
43
|
+
export interface Check {
|
|
44
|
+
id: ProofCheckId | "nip05" | "signature";
|
|
45
|
+
ok: boolean;
|
|
46
|
+
/** Plain-language line for the "How we checked" list. */
|
|
47
|
+
label: string;
|
|
48
|
+
/** Why it failed, when it did. */
|
|
49
|
+
detail?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ProofInput {
|
|
52
|
+
/** Raw hex of the proof transaction, as served by Fulcrum. */
|
|
53
|
+
proofHex: string;
|
|
54
|
+
/** The txid the binding event names. */
|
|
55
|
+
proofTxid: string;
|
|
56
|
+
confirmations: number;
|
|
57
|
+
/** Raw hex of each parent transaction, keyed by txid. */
|
|
58
|
+
parents: Map<string, string>;
|
|
59
|
+
/** Address the event claims, normalised for `network`. */
|
|
60
|
+
address: string;
|
|
61
|
+
/** Author of the binding event. */
|
|
62
|
+
pubkey: string;
|
|
63
|
+
/** Network the event says it's on. */
|
|
64
|
+
eventNetwork: string;
|
|
65
|
+
/** Network this page is resolving on. */
|
|
66
|
+
network: BchNetwork;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The four BCH-side checks, all re-derived from raw bytes so a server can't
|
|
70
|
+
* fake them beyond withholding data:
|
|
71
|
+
*
|
|
72
|
+
* a. every input spends a coin locked to the claimed address;
|
|
73
|
+
* b. an output is `OP_RETURN HPAY 01 <pubkey>` with the event author's pubkey;
|
|
74
|
+
* c. at least one confirmation;
|
|
75
|
+
* d. the event's network matches the page's.
|
|
76
|
+
*
|
|
77
|
+
* Spec note: v1 requires *every* input to come from the bound address (the
|
|
78
|
+
* proof transaction has "no other inputs"), so a mixed-input transaction is
|
|
79
|
+
* Claimed, not Verified.
|
|
80
|
+
*/
|
|
81
|
+
export declare function checkProof(input: ProofInput): Check[];
|
|
82
|
+
export declare function buildBindingEvent(opts: {
|
|
83
|
+
address: string;
|
|
84
|
+
proofTxid: string;
|
|
85
|
+
network: BchNetwork;
|
|
86
|
+
nip05?: string;
|
|
87
|
+
createdAt?: number;
|
|
88
|
+
}): EventTemplate;
|
|
89
|
+
export declare function buildRevokeEvent(createdAt?: number): EventTemplate;
|
|
90
|
+
/** NIP-A3 payment target so other Nostr clients can find the address. */
|
|
91
|
+
export declare function buildPaytoEvent(address: string, createdAt?: number): EventTemplate;
|
|
92
|
+
export type ParsedBinding = {
|
|
93
|
+
type: "binding";
|
|
94
|
+
address: string;
|
|
95
|
+
proofTxid: string;
|
|
96
|
+
network: string;
|
|
97
|
+
nip05?: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: "revoked";
|
|
100
|
+
} | {
|
|
101
|
+
type: "invalid";
|
|
102
|
+
reason: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Parse a kind-30145 event. Content and tags must agree; the address is
|
|
106
|
+
* returned normalised for the event's own network.
|
|
107
|
+
*/
|
|
108
|
+
export declare function parseBindingEvent(event: NostrEvent): ParsedBinding;
|
|
109
|
+
/** Address from a NIP-A3 `payto` event (Claimed only). */
|
|
110
|
+
export declare function parsePaytoEvent(event: NostrEvent, network: BchNetwork): string | null;
|
|
111
|
+
/**
|
|
112
|
+
* Address from Paytaca's kind-30078 `paytaca:bch-address` event (Claimed only).
|
|
113
|
+
* The exact content format is unconfirmed, so this accepts either a bare
|
|
114
|
+
* address string or a JSON object with an `address` field.
|
|
115
|
+
*/
|
|
116
|
+
export declare function parsePaytacaEvent(event: NostrEvent, network: BchNetwork): string | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ElectrumNetworkProvider } from "cashscript";
|
|
2
|
+
export type BchNetwork = "chipnet" | "mainnet";
|
|
3
|
+
/** CashAddr prefix for each network. */
|
|
4
|
+
export declare const PREFIX: Record<BchNetwork, "bchtest" | "bitcoincash">;
|
|
5
|
+
/**
|
|
6
|
+
* Link to HandlePay's own transaction page. Public chipnet explorers proved
|
|
7
|
+
* unreliable (some only show unconfirmed transactions, one sits behind a bot
|
|
8
|
+
* check), so links go to /tx/<txid>, which reads the transaction from the same
|
|
9
|
+
* server the app already uses. The network is in the link so a shared link
|
|
10
|
+
* shows the right chain. Absolute when a browser origin is available, so a
|
|
11
|
+
* copied receipt carries a working link.
|
|
12
|
+
*/
|
|
13
|
+
export declare const explorerTx: (network: BchNetwork, txid: string) => string;
|
|
14
|
+
/** Third-party explorers, offered as a second opinion on the transaction page. */
|
|
15
|
+
export declare const externalExplorers: (network: BchNetwork, txid: string) => {
|
|
16
|
+
name: string;
|
|
17
|
+
url: string;
|
|
18
|
+
}[];
|
|
19
|
+
export declare function getProvider(network: BchNetwork): ElectrumNetworkProvider;
|
|
20
|
+
export interface ChainTx {
|
|
21
|
+
hex: string;
|
|
22
|
+
/** 0 while in the mempool. */
|
|
23
|
+
confirmations: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Raw transaction plus confirmation count, from Fulcrum's verbose
|
|
27
|
+
* `blockchain.transaction.get`. Callers re-hash `hex` against the txid; the
|
|
28
|
+
* server is only trusted for availability and confirmation depth.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* True when the server answered that the transaction doesn't exist, as
|
|
32
|
+
* opposed to not answering at all (timeout, connection dropped). Only the
|
|
33
|
+
* first may be shown as "not found"; the second means "couldn't check".
|
|
34
|
+
*/
|
|
35
|
+
export declare function isTxNotFound(e: unknown): boolean;
|
|
36
|
+
export declare function getTransaction(network: BchNetwork, txid: string): Promise<ChainTx>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nostr I/O: NIP-05 lookups, relay queries and publishing, NIP-07 signing.
|
|
3
|
+
* Every event that comes back from a relay or a signer is signature-checked
|
|
4
|
+
* here before anything else sees it.
|
|
5
|
+
*/
|
|
6
|
+
import type { WindowNostr } from "nostr-tools/nip07";
|
|
7
|
+
import { type EventTemplate, type NostrEvent } from "nostr-tools/pure";
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
nostr?: WindowNostr;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Always queried and published to, alongside any relays the NIP-05 file lists. */
|
|
14
|
+
export declare const DEFAULT_RELAYS: string[];
|
|
15
|
+
export interface Handle {
|
|
16
|
+
local: string;
|
|
17
|
+
domain: string;
|
|
18
|
+
/** Canonical lowercase `local@domain`. */
|
|
19
|
+
full: string;
|
|
20
|
+
/** Non-ASCII characters can hide look-alike names; the UI flags these. */
|
|
21
|
+
nonAscii: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Parse `local@domain`. Returns null if it can't be a NIP-05 name. */
|
|
24
|
+
export declare function parseHandle(input: string): Handle | null;
|
|
25
|
+
export interface Nip05Result {
|
|
26
|
+
pubkey: string;
|
|
27
|
+
relays: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare class Nip05UnreachableError extends Error {
|
|
30
|
+
constructor(domain: string);
|
|
31
|
+
}
|
|
32
|
+
type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
|
|
33
|
+
/** Parse a nostr.json body for one name. */
|
|
34
|
+
export declare function readNip05Json(json: unknown, local: string): Nip05Result | null;
|
|
35
|
+
/**
|
|
36
|
+
* Look up `local@domain` via `https://domain/.well-known/nostr.json?name=local`.
|
|
37
|
+
* Tries the domain directly; if that fails at the network level (usually CORS),
|
|
38
|
+
* retries through the HandlePay Worker when `proxy` is set.
|
|
39
|
+
*
|
|
40
|
+
* Returns null when the domain answers but doesn't list the name; throws
|
|
41
|
+
* Nip05UnreachableError when it can't be reached at all.
|
|
42
|
+
*/
|
|
43
|
+
export declare function fetchNip05(handle: Handle, opts?: {
|
|
44
|
+
fetchImpl?: FetchLike;
|
|
45
|
+
proxy?: string;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
}): Promise<Nip05Result | null>;
|
|
48
|
+
export declare function relaysFor(extra?: string[]): string[];
|
|
49
|
+
/** No relay could be reached, so an empty answer would mean "couldn't check", not "nothing published". */
|
|
50
|
+
export declare class RelaysUnreachableError extends Error {
|
|
51
|
+
constructor();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The relays that accept a connection. querySync answers [] both when relays have nothing and when
|
|
55
|
+
* none can be reached; connecting first tells the two apart, so a dead connection reads as
|
|
56
|
+
* "couldn't check", never as "no identity". Throws RelaysUnreachableError when none connect.
|
|
57
|
+
*/
|
|
58
|
+
export declare function reachableRelays(p: {
|
|
59
|
+
ensureRelay(url: string, params?: {
|
|
60
|
+
connectionTimeout?: number;
|
|
61
|
+
}): Promise<unknown>;
|
|
62
|
+
}, relays: string[], timeout: number): Promise<string[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Fetch a pubkey's identity events (binding, payto, Paytaca) from relays.
|
|
65
|
+
* Drops anything with a bad signature or a different author.
|
|
66
|
+
*
|
|
67
|
+
* Throws RelaysUnreachableError when not one relay can be connected to.
|
|
68
|
+
*/
|
|
69
|
+
export declare function queryIdentityEvents(pubkey: string, relays: string[], maxWait?: number): Promise<NostrEvent[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Check an event's id and signature from its fields alone.
|
|
72
|
+
*
|
|
73
|
+
* nostr-tools caches a successful check in a symbol property on the event
|
|
74
|
+
* object, and object spread copies that symbol. So `{...signed, sig: other}`
|
|
75
|
+
* would pass `verifyEvent` without being checked. Verifying a fresh copy of
|
|
76
|
+
* the NIP-01 fields defeats the cache.
|
|
77
|
+
*/
|
|
78
|
+
export declare function verifySignature(e: NostrEvent): boolean;
|
|
79
|
+
/** Unique events by id, signature-checked, from `author` only. */
|
|
80
|
+
export declare function dedupeVerified(events: NostrEvent[], author: string): NostrEvent[];
|
|
81
|
+
/** Newest event, ties broken by lowest id (NIP-01 replaceable-event rule). */
|
|
82
|
+
export declare function newest(events: NostrEvent[]): NostrEvent | undefined;
|
|
83
|
+
export interface PublishResult {
|
|
84
|
+
ok: string[];
|
|
85
|
+
failed: {
|
|
86
|
+
relay: string;
|
|
87
|
+
reason: string;
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
90
|
+
export declare function publishEvent(event: NostrEvent, relays: string[]): Promise<PublishResult>;
|
|
91
|
+
export declare function hasSigner(): boolean;
|
|
92
|
+
export declare function signerPubkey(): Promise<string>;
|
|
93
|
+
/** Sign with the browser extension and check the result before trusting it. */
|
|
94
|
+
export declare function signWithExtension(template: EventTemplate, expectedPubkey?: string): Promise<NostrEvent>;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { NostrEvent } from "nostr-tools/pure";
|
|
2
|
+
import { type Check } from "./binding";
|
|
3
|
+
import { type BchNetwork, type ChainTx } from "./network";
|
|
4
|
+
import { type Handle, type Nip05Result } from "./nostr";
|
|
5
|
+
export type Status = "verified" | "claimed" | "changed" | "not_found";
|
|
6
|
+
export interface Pin {
|
|
7
|
+
pubkey: string;
|
|
8
|
+
address: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Resolution {
|
|
11
|
+
status: Status;
|
|
12
|
+
/** Canonical handle, when the input parsed. */
|
|
13
|
+
handle?: Handle;
|
|
14
|
+
pubkey?: string;
|
|
15
|
+
/** Payable address on this page's network. Absent for Not found. */
|
|
16
|
+
address?: string;
|
|
17
|
+
proofTxid?: string;
|
|
18
|
+
/** Where the address came from. */
|
|
19
|
+
source?: "binding" | "payto" | "paytaca";
|
|
20
|
+
/** The "How we checked" list, in order. */
|
|
21
|
+
checks: Check[];
|
|
22
|
+
/** One-line reason shown when the status isn't Verified. */
|
|
23
|
+
reason?: string;
|
|
24
|
+
/** What this browser saw before, when the status is Changed. */
|
|
25
|
+
previous?: Pin;
|
|
26
|
+
}
|
|
27
|
+
export interface ResolveDeps {
|
|
28
|
+
fetchNip05(handle: Handle): Promise<Nip05Result | null>;
|
|
29
|
+
queryEvents(pubkey: string, relays: string[]): Promise<NostrEvent[]>;
|
|
30
|
+
getTransaction(txid: string): Promise<ChainTx>;
|
|
31
|
+
}
|
|
32
|
+
export declare function liveDeps(network: BchNetwork): ResolveDeps;
|
|
33
|
+
export declare function resolveHandle(input: string, network: BchNetwork, deps: ResolveDeps, pinned?: Pin | null): Promise<Resolution>;
|
|
34
|
+
/** Whether the pay button is allowed, and what has to be confirmed first. */
|
|
35
|
+
export declare function paymentGate(r: Resolution): "allowed" | "confirm_unverified" | "acknowledge_change" | "blocked";
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handlepay/resolve",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Resolve a name like sani@lycanforge.com.ng to the Bitcoin Cash address it has proven it controls (HPAY-BIND v1: NIP-05 + signed Nostr binding + BCH proof transaction).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/types/packages/resolve/src/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/packages/resolve/src/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist", "README.md"],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build && tsc -p tsconfig.json",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@bitauth/libauth": "^3.1.0-next.8",
|
|
23
|
+
"cashscript": "^0.14.0",
|
|
24
|
+
"nostr-tools": "^2.26.1"
|
|
25
|
+
},
|
|
26
|
+
"engines": { "node": ">=22" },
|
|
27
|
+
"keywords": ["bitcoin-cash", "bch", "nostr", "nip-05", "identity", "payments", "cashaddr"],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": { "type": "git", "url": "git+https://github.com/Lycan-Xx/handlepay.git", "directory": "packages/resolve" },
|
|
30
|
+
"homepage": "https://handlepay.lycanforge.com.ng"
|
|
31
|
+
}
|