logicsrc/packages/ans/src/index.ts
Anthony Ettinger 29975b2df7 feat(ans): implement @logicsrc/ans M1 — resolver + offline verifier
M1 of the ANS SDK (docs/ans-sdk.md):

- name: parse/format ans://v<semver>.<agent>.<domain>
- cbor: minimal RFC 8949 codec for the COSE_Sign1 subset
- verify/merkle: RFC 6962 leaf/node hashing, tree build, inclusion-proof
  generation + verification
- verify/es256 + cose: COSE_Sign1 build/parse, Sig_structure, ES256 (WebCrypto)
- verify/rootkeys: kid -> verifier key (JWKS entries; sumdb-note is M2)
- verify: verifyReceipt() + verifyResolution() (signature + inclusion proof +
  name binding), pure and offline
- client: AnsClient resolve/rootKeys/register/status over injectable fetch,
  with a DnsApplier hook for verify-dns

Tests (24) cover name parsing, CBOR round-trips/vectors, RFC 6962 proofs, a full
ES256+Merkle receipt round-trip with positive/negative cases, and the client
against mocked fetch. Wired into the root build script.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 14:48:24 +00:00

15 lines
943 B
TypeScript

// @logicsrc/ans — TypeScript SDK for the Agent Name Service (ANS).
// See docs/ans-sdk.md. M1: resolver + offline transparency-log verifier.
export * from './types.js';
export { parseAnsName, formatAnsName, toAnsName } from './name.js';
export { AnsClient, type AnsClientOptions } from './client.js';
export { verifyReceipt, verifyResolution } from './verify/index.js';
export { rootKeysFromEntries, type RootKeyEntry } from './verify/rootkeys.js';
// Lower-level building blocks (stable enough to reuse; handy for tooling/tests).
export { merkleRoot, inclusionProof, verifyInclusion, leafHash, nodeHash } from './verify/merkle.js';
export { buildReceipt, parseReceipt, sigStructure, type ReceiptEnvelope, type InclusionProof } from './verify/cose.js';
export { importEs256VerifyKey, verifyEs256 } from './verify/es256.js';
export { encodeCbor, decodeCbor, CborTag, type CborValue } from './cbor.js';
export * as bytes from './bytes.js';