{"version":3,"sources":["../../src/errors.ts","../../src/identity/fingerprint.ts","../../src/identity/base64url.ts","../../src/identity/signing.ts","../../src/a2a/index.ts","../../src/capability/match.ts","../../src/edge/index.ts"],"names":[],"mappings":";;;AAiCO,IAAM,WAAA,GAAN,MAAM,YAAA,SAAoB,KAAA,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5B,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,WAAA,CAAY,SAAiB,IAAA,EAAc;AACzC,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,OAAO,QAAQ,OAAA,EAA8B;AAC3C,IAAA,OAAO,IAAI,YAAA,CAAY,OAAA,EAAS,mBAAmB,CAAA;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,SAAS,OAAA,EAA8B;AAC5C,IAAA,OAAO,IAAI,YAAA,CAAY,OAAA,EAAS,eAAe,CAAA;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,OAAO,WAAW,OAAA,EAA8B;AAC9C,IAAA,OAAO,IAAI,YAAA,CAAY,OAAA,EAAS,wBAAwB,CAAA;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,SAAS,OAAA,EAA8B;AAC5C,IAAA,OAAO,IAAI,YAAA,CAAY,OAAA,EAAS,cAAc,CAAA;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,MAAM,OAAA,EAA8B;AACzC,IAAA,OAAO,IA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AA,CAAK,SAAA,CAAU,SAAS,CAAA,EAAG;AAC/C,QAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAA,EAAQ,eAAA,EAAgB;AAAA,MACnD;AACA,MAAA,MAAM,KAAA,GAAQ,MAAM,eAAA,CAAgB,IAAA,EAAM,QAAQ,OAAO,CAAA;AACzD,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAA,EAAQ,eAAA,EAAgB;AAAA,MACnD;AACA,MAAA,IAAI,IAAA,CAAK,WAAW,QAAA,EAAU;AAC5B,QAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAA,EAAQ,YAAA,EAAa;AAAA,MAChD;AACA,MAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,IAAO,IAAA,CAAK,GAAA,EAAI;AACpC,MAAA,IAAI,IAAA,CAAK,SAAA,KAAc,IAAA,IAAQ,IAAA,CAAK,aAAa,GAAA,EAAK;AACpD,QAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,MAAA,EAAQ,SAAA,EAAU;AAAA,MAC7C;AACA,MAAA,MAAM,UAAA,GAAa,qBAAA;AAAA,QACjB,IAAA,CAAK,YAAA;AAAA,QACL,OAAA,CAAQ,UAAA;AAAA,QACR,OAAA,CAAQ,MAAA;AAAA,QACR,OAAA,CAAQ;AAAA,OACV;AACA,MAAA,OAAO,UAAA,GACH,EAAE,OAAA,EAAS,IAAA,EAAM,MAAA,EAAQ,SAAA,EAAU,GACnC,EAAE,OAAA,EAAS,KAAA,EAAO,MAAA,EAAQ,mBAAA,EAAoB;AAAA,IACpD;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Error model for Krikos, the identity registry and lifecycle manager for fleets of Massive\n * Intelligence (IM) agents and non-human entities (NHE).\n *\n * Krikos throws exactly one error class so that host applications can catch and branch on a\n * single type, then dispatch on the stable machine-readable {@link KrikosError.code}. New codes\n * may be added in minor versions, so consumers must treat the code space as open and fall back\n * gracefully on codes they do not recognize.\n *\n * @packageDocumentation\n */\n\n/**\n * The only error type thrown by Krikos.\n *\n * Invariants:\n * - `name` is always the literal string `'KrikosError'`, safe for cross-realm checks where\n *   `instanceof` fails (multiple bundles, workers, iframes).\n * - `code` is a stable, machine-readable, SCREAMING_SNAKE identifier prefixed with `ERR_`.\n *   It never changes meaning across versions, although new codes may appear in minors.\n * - `message` is human-readable English prose intended for logs, never for parsing.\n *\n * @example\n * ```ts\n * try {\n *   krikos.activate(id);\n * } catch (error) {\n *   if (error instanceof KrikosError && error.code === 'ERR_INVALID_TRANSITION') {\n *     // The agent cannot move to active from its current lifecycle state.\n *   }\n * }\n * ```\n */\nexport class KrikosError extends Error {\n  /**\n   * Stable machine-readable error code, for example `'ERR_INVALID_TRANSITION'`.\n   *\n   * Branch on this field, never on `message`. The code space is minor-extensible.\n   */\n  readonly code: string;\n\n  /**\n   * @param message - Human-readable description of what went wrong and how to fix it.\n   * @param code - Stable machine-readable code, see {@link KrikosError.code}.\n   */\n  constructor(message: string, code: string) {\n    super(message);\n    this.name = 'KrikosError';\n    this.code = code;\n  }\n\n  /**\n   * Builds a {@link KrikosError} with code `'ERR_INVALID_INPUT'`.\n   *\n   * Used for every caller-side contract violation: an agent with no name, an empty capability\n   * name, a non-finite expiration timestamp, a capability action that is not a string, and any\n   * other input the type system cannot reject for untyped JavaScript callers.\n   *\n   * @param message - Human-readable description of the invalid input.\n   * @returns A new error instance, never thrown by this factory itself.\n   */\n  static invalid(message: string): KrikosError {\n    return new KrikosError(message, 'ERR_INVALID_INPUT');\n  }\n\n  /**\n   * Builds a {@link KrikosError} with code `'ERR_NOT_FOUND'`.\n   *\n   * Used when a caller references an agent by id that the registry does not hold, for example\n   * activating an id that was never issued.\n   *\n   * @param message - Human-readable description of what was not found.\n   * @returns A new error instance, never thrown by this factory itself.\n   */\n  static notFound(message: string): KrikosError {\n    return new KrikosError(message, 'ERR_NOT_FOUND');\n  }\n\n  /**\n   * Builds a {@link KrikosError} with code `'ERR_INVALID_TRANSITION'`.\n   *\n   * Used when a lifecycle operation is requested from a state that does not allow it, for\n   * example resuming an agent that was revoked, or activating one that is archived. The\n   * registry stays consistent; the offending transition is rejected whole.\n   *\n   * @param message - Human-readable description of the illegal transition.\n   * @returns A new error instance, never thrown by this factory itself.\n   */\n  static transition(message: string): KrikosError {\n    return new KrikosError(message, 'ERR_INVALID_TRANSITION');\n  }\n\n  /**\n   * Builds a {@link KrikosError} with code `'ERR_CONFLICT'`.\n   *\n   * Used when an operation collides with existing state, for example issuing an agent with an\n   * explicit id that is already registered.\n   *\n   * @param message - Human-readable description of the conflict.\n   * @returns A new error instance, never thrown by this factory itself.\n   */\n  static conflict(message: string): KrikosError {\n    return new KrikosError(message, 'ERR_CONFLICT');\n  }\n\n  /**\n   * Builds a {@link KrikosError} with code `'ERR_LIMIT_REACHED'`.\n   *\n   * Used when an operation would exceed a configured bound, for example issuing past\n   * `maxAgents`. The registry stays consistent; the offending write is rejected whole.\n   *\n   * @param message - Human-readable description of the limit that was hit.\n   * @returns A new error instance, never thrown by this factory itself.\n   */\n  static limit(message: string): KrikosError {\n    return new KrikosError(message, 'ERR_LIMIT_REACHED');\n  }\n}\n","/**\n * Deterministic agent fingerprinting and the canonical signable passport.\n *\n * The fingerprint is a stable content hash of an agent's identity-defining fields at a given\n * credential version. Two registries that canonicalize the same identity derive the same\n * fingerprint, which is what lets a signature produced anywhere be verified anywhere. The\n * canonical passport is the exact byte string a cryptographic signer signs, so signing and\n * verification never disagree about what was covered.\n *\n * Determinism: pure functions, no clock, no randomness, no platform globals. Capability order\n * and resource order are normalized by sorting, so a reordered-but-equal capability set yields\n * an identical fingerprint.\n *\n * @packageDocumentation\n */\n\nimport { combineKeys } from '../stats/hash.js';\nimport type { Agent, Capability, Issuer } from '../types.js';\n\n/**\n * Canonicalizes a capability set into a single stable string.\n *\n * Within each capability the actions and resources are sorted; the capabilities themselves are\n * sorted by name then by their canonical body, so set-equal capability lists in any order map to\n * the same canonical form. Field and element boundaries use control separators that cannot occur\n * in normal capability text, so distinct sets cannot collide by concatenation ambiguity.\n *\n * @param capabilities - The capabilities to canonicalize.\n * @returns A stable canonical string.\n */\nexport function canonicalCapabilities(capabilities: readonly Capability[]): string {\n  // ASCII control separators (record, field, element) that cannot occur in capability text, so\n  // distinct sets cannot collide by concatenation ambiguity. Written as escapes, never raw chars.\n  const RECORD = '\u001e';\n  const FIELD = '\u001f';\n  const ELEMENT = '\u001d';\n  const parts = capabilities.map((capability) => {\n    const actions = [...capability.actions].sort().join(ELEMENT);\n    const resources =\n      capability.resources === undefined ? '*' : [...capability.resources].sort().join(ELEMENT);\n    return `${capability.name}${FIELD}${actions}${FIELD}${resources}`;\n  });\n  return parts.sort().join(RECORD);\n}\n\n/**\n * Canonicalizes the issuer into a stable string. The optional name is included so two issuers\n * that share an id but differ in name produce different fingerprints.\n *\n * @param issuer - The issuer to canonicalize.\n * @returns A stable canonical string.\n */\nexport function canonicalIssuer(issuer: Issuer): string {\n  return `${issuer.id}${issuer.name ?? ''}`;\n}\n\n/**\n * Computes the deterministic fingerprint of an identity from its identity-defining fields: name,\n * issuer, canonical capabilities, and credential version. Lifecycle state, timestamps, and\n * metadata are deliberately excluded, so the fingerprint is the stable identity of the agent at\n * a credential epoch and changes only on rotation or a capability change.\n *\n * @param name - The agent name.\n * @param issuer - The issuing principal.\n * @param capabilities - The declared capabilities.\n * @param credentialVersion - The credential epoch.\n * @returns A 16-character lowercase hex fingerprint.\n */\nexport function computeFingerprint(\n  name: string,\n  issuer: Issuer,\n  capabilities: readonly Capability[],\n  credentialVersion: number,\n): string {\n  return combineKeys([\n    name,\n    canonicalIssuer(issuer),\n    canonicalCapabilities(capabilities),\n    String(credentialVersion),\n  ]);\n}\n\n/**\n * The claim set a cryptographic signer signs to bind an agent's identity. Plain data,\n * JSON-stable: serializing it always yields the same bytes for the same identity because every\n * field is canonical and the key order is fixed by {@link canonicalPassportString}.\n */\nexport interface AgentPassport {\n  /** Opaque agent id. */\n  readonly id: string;\n  /** Agent name. */\n  readonly name: string;\n  /** Canonical issuer string. */\n  readonly issuer: string;\n  /** Canonical capabilities string. */\n  readonly capabilities: string;\n  /** Credential epoch. */\n  readonly credentialVersion: number;\n  /** The identity fingerprint, redundant with the fields above but convenient for verifiers. */\n  readonly fingerprint: string;\n  /** Expiration instant (epoch ms) or null. */\n  readonly expiresAt: number | null;\n}\n\n/**\n * Builds the canonical passport for an agent. The passport is what the Ed25519 signer in\n * `@takk/krikos/a2a` signs; the verifier rebuilds the same passport from a presented agent and\n * checks the signature against it.\n *\n * @param agent - The agent to build a passport for.\n * @returns The canonical passport.\n */\nexport function buildPassport(agent: Agent): AgentPassport {\n  return {\n    id: agent.id,\n    name: agent.name,\n    issuer: canonicalIssuer(agent.issuer),\n    capabilities: canonicalCapabilities(agent.capabilities),\n    credentialVersion: agent.credentialVersion,\n    fingerprint: agent.fingerprint,\n    expiresAt: agent.expiresAt,\n  };\n}\n\n/**\n * Serializes a passport to its canonical signable string with a fixed field order, so the exact\n * bytes are reproducible and a signer and verifier never disagree about what was covered.\n *\n * @param passport - The passport to serialize.\n * @returns The canonical UTF-8 string to sign or verify.\n */\nexport function canonicalPassportString(passport: AgentPassport): string {\n  return [\n    passport.id,\n    passport.name,\n    passport.issuer,\n    passport.capabilities,\n    String(passport.credentialVersion),\n    passport.fingerprint,\n    passport.expiresAt === null ? 'null' : String(passport.expiresAt),\n  ].join('\\n');\n}\n","/**\n * Portable base64url codec over byte arrays.\n *\n * Pure, dependency-free, and identical in Node, browsers, and edge runtimes: no `Buffer`, no\n * `btoa`/`atob`, no platform globals. Krikos uses it so a key or signature encoded by the Node\n * signer decodes byte-for-byte under the Web signer and vice versa, which is what makes a Signed\n * Agent Card portable across runtimes.\n *\n * Encoding is URL-safe base64 without padding (RFC 4648 section 5): `+` becomes `-`, `/` becomes\n * `_`, and trailing `=` is dropped.\n *\n * @packageDocumentation\n */\n\nimport { KrikosError } from '../errors.js';\n\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\n\n/** Reverse lookup table from character code to 6-bit value, -1 for non-alphabet characters. */\nconst LOOKUP = (() => {\n  const table = new Int8Array(128).fill(-1);\n  for (let index = 0; index < ALPHABET.length; index += 1) {\n    table[ALPHABET.charCodeAt(index)] = index;\n  }\n  return table;\n})();\n\n/**\n * Encodes bytes as URL-safe base64 without padding.\n *\n * @param bytes - The bytes to encode.\n * @returns The base64url string.\n */\nexport function encodeBase64Url(bytes: Uint8Array): string {\n  // charAt never returns undefined (unlike index access under noUncheckedIndexedAccess), and the\n  // masked values are always 0..63, well within the 64-character alphabet.\n  const at = (value: number): string => ALPHABET.charAt(value & 63);\n  let output = '';\n  let index = 0;\n  for (; index + 2 < bytes.length; index += 3) {\n    const a = bytes[index] as number;\n    const b = bytes[index + 1] as number;\n    const c = bytes[index + 2] as number;\n    const triple = (a << 16) | (b << 8) | c;\n    output += at(triple >> 18) + at(triple >> 12) + at(triple >> 6) + at(triple);\n  }\n  const remaining = bytes.length - index;\n  if (remaining === 1) {\n    const a = bytes[index] as number;\n    const triple = a << 16;\n    output += at(triple >> 18) + at(triple >> 12);\n  } else if (remaining === 2) {\n    const a = bytes[index] as number;\n    const b = bytes[index + 1] as number;\n    const triple = (a << 16) | (b << 8);\n    output += at(triple >> 18) + at(triple >> 12) + at(triple >> 6);\n  }\n  return output;\n}\n\n/**\n * Decodes a URL-safe base64 string (with or without padding) back to bytes.\n *\n * @param text - The base64url string to decode.\n * @returns The decoded bytes.\n * @throws KrikosError `ERR_INVALID_INPUT` when the text contains a character outside the\n *   base64url alphabet or has an impossible length.\n */\nexport function decodeBase64Url(text: string): Uint8Array {\n  const stripped = text.replace(/=+$/, '');\n  const length = stripped.length;\n  if (length % 4 === 1) {\n    throw KrikosError.invalid('invalid base64url length.');\n  }\n  const byteLength = Math.floor((length * 3) / 4);\n  const out = new Uint8Array(byteLength);\n  let outIndex = 0;\n  let buffer = 0;\n  let bits = 0;\n  for (let index = 0; index < length; index += 1) {\n    const code = stripped.charCodeAt(index);\n    const value = code < 128 ? LOOKUP[code] : -1;\n    if (value === undefined || value < 0) {\n      throw KrikosError.invalid('invalid base64url character.');\n    }\n    buffer = (buffer << 6) | value;\n    bits += 6;\n    if (bits >= 8) {\n      bits -= 8;\n      out[outIndex] = (buffer >> bits) & 0xff;\n      outIndex += 1;\n    }\n  }\n  return out;\n}\n\n/** Encodes a UTF-8 string to bytes without depending on `TextEncoder` being a global type import. */\nexport function utf8ToBytes(text: string): Uint8Array {\n  return new TextEncoder().encode(text);\n}\n","/**\n * Cryptographic agent identity for Krikos: Ed25519 key generation, signing, and verification,\n * with interchangeable Node and Web implementations.\n *\n * This is the opt-in security layer on top of the deterministic registry. The core never\n * requires it: an agent always has a non-cryptographic fingerprint, and authorization keys off\n * lifecycle state and declared capabilities. When a host wants verifiable, portable identity,\n * it signs an agent's canonical passport with a {@link Signer} and attaches the signature, or\n * exports a Signed Agent Card from `@takk/krikos/a2a`.\n *\n * Key encoding is shared across runtimes so a card signed under {@link nodeSigner} verifies under\n * {@link webSigner} and vice versa: public keys are the raw 32-byte Ed25519 key, private keys are\n * the raw 32-byte seed, both base64url. The Node and Web back ends rebuild the standard SPKI and\n * PKCS8 DER wrappers from those raw bytes using the fixed Ed25519 ASN.1 prefixes.\n *\n * The Node back end loads `node:crypto` lazily inside method bodies, so importing this module\n * stays safe in browsers and edge runtimes; the platform requirement only materializes when a\n * Node method actually runs.\n *\n * @packageDocumentation\n */\n\nimport { KrikosError } from '../errors.js';\nimport { decodeBase64Url, encodeBase64Url, utf8ToBytes } from './base64url.js';\n\n/** An Ed25519 key pair with raw, base64url-encoded keys. */\nexport interface KeyPair {\n  /** Raw 32-byte Ed25519 public key, base64url. */\n  readonly publicKey: string;\n  /** Raw 32-byte Ed25519 private seed, base64url. Treat as a secret. */\n  readonly privateKey: string;\n}\n\n/**\n * A pluggable Ed25519 signer. Two interchangeable implementations ship: {@link nodeSigner} and\n * {@link webSigner}. A host may supply its own (an HSM, a KMS) as long as it honors the same key\n * encoding and Ed25519 semantics.\n */\nexport interface Signer {\n  /** Algorithm identifier, always `ed25519` in 1.0. */\n  readonly algorithm: 'ed25519';\n  /** Generates a fresh key pair. */\n  generateKeyPair(): Promise<KeyPair>;\n  /** Signs `message` with `privateKey`, returning a base64url detached signature. */\n  sign(message: string, privateKey: string): Promise<string>;\n  /** Verifies `signature` over `message` against `publicKey`. Never throws on a bad signature. */\n  verify(message: string, signature: string, publicKey: string): Promise<boolean>;\n}\n\n/** Fixed ASN.1 DER prefix for an Ed25519 SPKI public key wrapper (12 bytes), then the raw key. */\nconst SPKI_PREFIX = new Uint8Array([\n  0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,\n]);\n\n/** Fixed ASN.1 DER prefix for an Ed25519 PKCS8 private key wrapper (16 bytes), then the seed. */\nconst PKCS8_PREFIX = new Uint8Array([\n  0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20,\n]);\n\n/** Concatenates two byte arrays into a fresh array. */\nfunction concatBytes(a: Uint8Array, b: Uint8Array): Uint8Array {\n  const out = new Uint8Array(a.length + b.length);\n  out.set(a, 0);\n  out.set(b, a.length);\n  return out;\n}\n\n/** Wraps a raw 32-byte public key in its SPKI DER envelope. */\nfunction rawPublicToSpki(raw: Uint8Array): Uint8Array {\n  if (raw.length !== 32) {\n    throw KrikosError.invalid('an Ed25519 public key must be 32 bytes.');\n  }\n  return concatBytes(SPKI_PREFIX, raw);\n}\n\n/** Wraps a raw 32-byte private seed in its PKCS8 DER envelope. */\nfunction rawSeedToPkcs8(seed: Uint8Array): Uint8Array {\n  if (seed.length !== 32) {\n    throw KrikosError.invalid('an Ed25519 private seed must be 32 bytes.');\n  }\n  return concatBytes(PKCS8_PREFIX, seed);\n}\n\n/**\n * Creates an Ed25519 signer backed by `node:crypto`, loaded lazily. Use this on a Node server\n * or in the CLI. Throws only on genuinely malformed inputs (wrong key length, non-base64url);\n * a cryptographically invalid signature resolves to `false`, never throws.\n *\n * @returns A {@link Signer} bound to `node:crypto`.\n */\nexport function nodeSigner(): Signer {\n  return {\n    algorithm: 'ed25519',\n    async generateKeyPair(): Promise<KeyPair> {\n      const crypto = await import('node:crypto');\n      const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');\n      const pubJwk = publicKey.export({ format: 'jwk' }) as { x?: string };\n      const privJwk = privateKey.export({ format: 'jwk' }) as { d?: string };\n      if (pubJwk.x === undefined || privJwk.d === undefined) {\n        throw KrikosError.invalid('node:crypto did not return raw Ed25519 key material.');\n      }\n      // JWK already encodes x and d as base64url raw bytes; reuse them directly.\n      return { publicKey: pubJwk.x, privateKey: privJwk.d };\n    },\n    async sign(message: string, privateKey: string): Promise<string> {\n      const crypto = await import('node:crypto');\n      const seed = decodeBase64Url(privateKey);\n      const key = crypto.createPrivateKey({\n        key: Buffer.from(rawSeedToPkcs8(seed)),\n        format: 'der',\n        type: 'pkcs8',\n      });\n      const signature = crypto.sign(null, Buffer.from(utf8ToBytes(message)), key);\n      return encodeBase64Url(new Uint8Array(signature));\n    },\n    async verify(message: string, signature: string, publicKey: string): Promise<boolean> {\n      const crypto = await import('node:crypto');\n      try {\n        const raw = decodeBase64Url(publicKey);\n        const key = crypto.createPublicKey({\n          key: Buffer.from(rawPublicToSpki(raw)),\n          format: 'der',\n          type: 'spki',\n        });\n        return crypto.verify(\n          null,\n          Buffer.from(utf8ToBytes(message)),\n          key,\n          Buffer.from(decodeBase64Url(signature)),\n        );\n      } catch {\n        return false;\n      }\n    },\n  };\n}\n\n/**\n * Creates an Ed25519 signer backed by the Web Crypto API (`globalThis.crypto.subtle`). Use this\n * in browsers and edge runtimes. Requires a runtime whose Web Crypto implements the Ed25519\n * algorithm, which the major edge runtimes and modern browsers do as of 2026.\n *\n * @returns A {@link Signer} bound to Web Crypto.\n */\nexport function webSigner(): Signer {\n  const subtle = (): SubtleCrypto => {\n    const value = (globalThis as { crypto?: Crypto }).crypto?.subtle;\n    if (value === undefined) {\n      throw KrikosError.invalid('Web Crypto (globalThis.crypto.subtle) is not available here.');\n    }\n    return value;\n  };\n  return {\n    algorithm: 'ed25519',\n    async generateKeyPair(): Promise<KeyPair> {\n      const pair = (await subtle().generateKey({ name: 'Ed25519' }, true, [\n        'sign',\n        'verify',\n      ])) as CryptoKeyPair;\n      const pubJwk = (await subtle().exportKey('jwk', pair.publicKey)) as { x?: string };\n      const privJwk = (await subtle().exportKey('jwk', pair.privateKey)) as { d?: string };\n      if (pubJwk.x === undefined || privJwk.d === undefined) {\n        throw KrikosError.invalid('Web Crypto did not return raw Ed25519 key material.');\n      }\n      return { publicKey: pubJwk.x, privateKey: privJwk.d };\n    },\n    async sign(message: string, privateKey: string): Promise<string> {\n      const seed = decodeBase64Url(privateKey);\n      const key = await subtle().importKey(\n        'pkcs8',\n        rawSeedToPkcs8(seed) as unknown as ArrayBuffer,\n        { name: 'Ed25519' },\n        false,\n        ['sign'],\n      );\n      const signature = await subtle().sign(\n        { name: 'Ed25519' },\n        key,\n        utf8ToBytes(message) as unknown as ArrayBuffer,\n      );\n      return encodeBase64Url(new Uint8Array(signature));\n    },\n    async verify(message: string, signature: string, publicKey: string): Promise<boolean> {\n      try {\n        const key = await subtle().importKey(\n          'raw',\n          decodeBase64Url(publicKey) as unknown as ArrayBuffer,\n          { name: 'Ed25519' },\n          false,\n          ['verify'],\n        );\n        return await subtle().verify(\n          { name: 'Ed25519' },\n          key,\n          decodeBase64Url(signature) as unknown as ArrayBuffer,\n          utf8ToBytes(message) as unknown as ArrayBuffer,\n        );\n      } catch {\n        return false;\n      }\n    },\n  };\n}\n","/**\n * A2A-aligned cryptographic agent identity for Krikos.\n *\n * The Agent2Agent (A2A) protocol, hosted by the Linux Foundation, uses Agent Cards to advertise\n * an agent's identity and capabilities, and Signed Agent Cards to let a receiving party verify\n * that a card was issued by who it claims, before any interaction. A2A does not mandate how those\n * cards are produced or verified. Krikos fills that gap: it exports a registered agent as a card,\n * signs the agent's canonical passport with Ed25519, and verifies a presented card's signature\n * anywhere, in Node, the browser, or an edge runtime, with byte-identical key encoding.\n *\n * This module is the cryptographic surface. The core registry never requires it; an agent always\n * has a deterministic fingerprint and authorization keys off lifecycle state and capabilities.\n *\n * @packageDocumentation\n */\n\nimport { KrikosError } from '../errors.js';\nimport {\n  buildPassport,\n  canonicalCapabilities,\n  canonicalIssuer,\n  canonicalPassportString,\n} from '../identity/fingerprint.js';\nimport type { KeyPair, Signer } from '../identity/signing.js';\nimport { nodeSigner, webSigner } from '../identity/signing.js';\nimport type {\n  Agent,\n  AgentInput,\n  AgentSignature,\n  AgentStatus,\n  Capability,\n  Issuer,\n  Krikos,\n} from '../types.js';\n\nexport type { AgentPassport } from '../identity/fingerprint.js';\nexport { buildPassport, canonicalPassportString } from '../identity/fingerprint.js';\nexport type { KeyPair, Signer } from '../identity/signing.js';\nexport { nodeSigner, webSigner } from '../identity/signing.js';\n\n/**\n * A Krikos Agent Card: an A2A-aligned, self-describing identity document for one agent, suitable\n * for cross-boundary discovery and trust. When `signature` is present, a verifier can confirm the\n * card was issued by the holder of the corresponding key without contacting Krikos.\n */\nexport interface KrikosAgentCard {\n  /** Card schema version. */\n  readonly protocolVersion: 'krikos/1.0';\n  /** Opaque agent id. */\n  readonly id: string;\n  /** Human-readable agent name. */\n  readonly name: string;\n  /** The issuing principal. */\n  readonly issuer: Issuer;\n  /** Declared capabilities. */\n  readonly capabilities: readonly Capability[];\n  /** Optional framework tag. */\n  readonly framework?: string;\n  /** Credential epoch. */\n  readonly credentialVersion: number;\n  /** Deterministic identity fingerprint. */\n  readonly fingerprint: string;\n  /** Lifecycle state at the time the card was produced. */\n  readonly status: AgentStatus;\n  /** Issue instant (epoch ms). */\n  readonly issuedAt: number;\n  /** Expiration instant (epoch ms) or null. */\n  readonly expiresAt: number | null;\n  /** Detached Ed25519 signature over the canonical passport, when signed. */\n  readonly signature?: AgentSignature;\n}\n\n/**\n * Maps a registered agent to its Agent Card. Carries the attached signature if present, so the\n * card is independently verifiable.\n *\n * @param agent - The agent to export.\n * @returns A {@link KrikosAgentCard}.\n */\nexport function toAgentCard(agent: Agent): KrikosAgentCard {\n  return {\n    protocolVersion: 'krikos/1.0',\n    id: agent.id,\n    name: agent.name,\n    issuer: agent.issuer,\n    capabilities: agent.capabilities,\n    ...(agent.framework !== undefined ? { framework: agent.framework } : {}),\n    credentialVersion: agent.credentialVersion,\n    fingerprint: agent.fingerprint,\n    status: agent.status,\n    issuedAt: agent.issuedAt,\n    expiresAt: agent.expiresAt,\n    ...(agent.signature !== undefined ? { signature: agent.signature } : {}),\n  };\n}\n\n/**\n * Signs an agent's canonical passport, producing a detached signature that attests to its\n * fingerprint and credential version. Attach it with {@link Krikos.attachSignature}.\n *\n * @param agent - The agent to sign.\n * @param signer - The Ed25519 signer ({@link nodeSigner} or {@link webSigner}).\n * @param keyPair - The signing key pair; its public key is embedded in the signature.\n * @returns The detached {@link AgentSignature}.\n */\nexport async function signAgent(\n  agent: Agent,\n  signer: Signer,\n  keyPair: KeyPair,\n): Promise<AgentSignature> {\n  const message = canonicalPassportString(buildPassport(agent));\n  const signature = await signer.sign(message, keyPair.privateKey);\n  return {\n    algorithm: signer.algorithm,\n    publicKey: keyPair.publicKey,\n    signature,\n    signedFingerprint: agent.fingerprint,\n    signedCredentialVersion: agent.credentialVersion,\n  };\n}\n\n/** A trust anchor: the issuer public key, or the set of keys, the verifier pins out of band. */\nexport type TrustedKeys = string | readonly string[];\n\n/** Normalizes a trust anchor to a list and tests membership of a presented key. */\nfunction isTrustedKey(publicKey: string, trusted: TrustedKeys): boolean {\n  const keys = typeof trusted === 'string' ? [trusted] : trusted;\n  return keys.includes(publicKey);\n}\n\n/** Rebuilds the canonical passport string a card's signature must cover. */\nfunction cardMessage(card: KrikosAgentCard): string {\n  return canonicalPassportString({\n    id: card.id,\n    name: card.name,\n    issuer: canonicalIssuer(card.issuer),\n    capabilities: canonicalCapabilities(card.capabilities),\n    credentialVersion: card.credentialVersion,\n    fingerprint: card.fingerprint,\n    expiresAt: card.expiresAt,\n  });\n}\n\n/**\n * Checks that an agent's attached signature is internally consistent: it covers the agent's current\n * fingerprint and credential version, and the Ed25519 signature verifies against the public key\n * embedded in the signature.\n *\n * This is NOT a trust check. A consistent signature proves only that the holder of the embedded\n * key signed this passport; it says nothing about whether that key belongs to the issuer you\n * trust. An attacker can mint a fully consistent self-signed card for any identity. Use it only\n * when the card already arrived over a trusted channel; otherwise use {@link verifyAgent} with a\n * pinned trust anchor. Returns false, never throws.\n *\n * @param agent - The agent whose signature to check.\n * @param signer - The Ed25519 signer to verify with.\n * @returns Whether the signature is internally consistent.\n */\nexport async function verifyAgentConsistency(agent: Agent, signer: Signer): Promise<boolean> {\n  const signature = agent.signature;\n  if (signature === undefined) {\n    return false;\n  }\n  if (\n    signature.signedFingerprint !== agent.fingerprint ||\n    signature.signedCredentialVersion !== agent.credentialVersion\n  ) {\n    return false;\n  }\n  return signer.verify(\n    canonicalPassportString(buildPassport(agent)),\n    signature.signature,\n    signature.publicKey,\n  );\n}\n\n/** The card-shaped counterpart of {@link verifyAgentConsistency}. Not a trust check. */\nexport async function verifyCardConsistency(\n  card: KrikosAgentCard,\n  signer: Signer,\n): Promise<boolean> {\n  const signature = card.signature;\n  if (signature === undefined) {\n    return false;\n  }\n  if (\n    signature.signedFingerprint !== card.fingerprint ||\n    signature.signedCredentialVersion !== card.credentialVersion\n  ) {\n    return false;\n  }\n  return signer.verify(cardMessage(card), signature.signature, signature.publicKey);\n}\n\n/**\n * Verifies an agent's identity against a pinned trust anchor: the signature must be internally\n * consistent AND signed by a public key the verifier already trusts (the issuer key, obtained out\n * of band, not the self-asserted key on the card). This is the real trust check; without a trust\n * anchor there is no verifiable identity, only self-consistency.\n *\n * A forged card signed with an attacker's own key fails here because the attacker's public key is\n * not among `trustedKeys`. Returns false, never throws.\n *\n * @param agent - The agent whose identity to verify.\n * @param signer - The Ed25519 signer to verify with.\n * @param trustedKeys - The pinned issuer public key(s) (base64url), obtained over a trusted channel.\n * @returns Whether the identity is verified against the trust anchor.\n */\nexport async function verifyAgent(\n  agent: Agent,\n  signer: Signer,\n  trustedKeys: TrustedKeys,\n): Promise<boolean> {\n  const signature = agent.signature;\n  if (signature === undefined || !isTrustedKey(signature.publicKey, trustedKeys)) {\n    return false;\n  }\n  return verifyAgentConsistency(agent, signer);\n}\n\n/**\n * Verifies a presented Agent Card against a pinned trust anchor, without access to the registry.\n * The card's signature must be internally consistent AND signed by a public key in `trustedKeys`.\n * A card signed with any other key (the impersonation case) is rejected. Returns false, never\n * throws.\n *\n * @param card - The presented Agent Card.\n * @param signer - The Ed25519 signer to verify with.\n * @param trustedKeys - The pinned issuer public key(s) (base64url), obtained over a trusted channel.\n * @returns Whether the card is verified against the trust anchor.\n */\nexport async function verifyAgentCard(\n  card: KrikosAgentCard,\n  signer: Signer,\n  trustedKeys: TrustedKeys,\n): Promise<boolean> {\n  const signature = card.signature;\n  if (signature === undefined || !isTrustedKey(signature.publicKey, trustedKeys)) {\n    return false;\n  }\n  return verifyCardConsistency(card, signer);\n}\n\n/**\n * Convenience: issue an agent, generate a fresh key pair, sign the agent, and attach the\n * signature, in one call. Returns the signed agent and the key pair so the caller can persist the\n * private key in its own secret store, Krikos never retains it.\n *\n * @param krikos - The registry to issue into.\n * @param input - The agent input.\n * @param signer - The Ed25519 signer to use.\n * @returns The signed agent and the generated key pair.\n */\nexport async function issueSigned(\n  krikos: Krikos,\n  input: AgentInput,\n  signer: Signer,\n): Promise<{ readonly agent: Agent; readonly keyPair: KeyPair }> {\n  const agent = krikos.issue(input);\n  const keyPair = await signer.generateKeyPair();\n  const signature = await signAgent(agent, signer, keyPair);\n  if (signature.algorithm !== 'ed25519') {\n    throw KrikosError.invalid('signer must produce an ed25519 signature.');\n  }\n  const signed = krikos.attachSignature(agent.id, signature);\n  return { agent: signed, keyPair };\n}\n\n/**\n * One skill in an A2A-aligned card, mapped from a Krikos capability: the capability name as the\n * skill id, its actions as tags, and any resource scope carried alongside.\n */\nexport interface A2ASkill {\n  readonly id: string;\n  readonly name: string;\n  readonly tags: readonly string[];\n  readonly resources?: readonly string[];\n}\n\n/**\n * An A2A-aligned agent card, shaped toward the Agent2Agent protocol's AgentCard so a krikos\n * identity can be advertised to A2A-aware peers. This is a best-effort alignment, not a certified\n * conformance to a specific A2A schema version; fields outside this subset are the host's to add.\n * The signature, when present, is the same Ed25519 detached signature verified by\n * {@link verifyAgentCard} with a pinned trust anchor.\n */\nexport interface A2AAgentCard {\n  readonly protocolVersion: 'a2a-aligned/1.0';\n  readonly name: string;\n  readonly description: string;\n  readonly version: string;\n  readonly provider: { readonly organization: string; readonly url?: string };\n  readonly skills: readonly A2ASkill[];\n  readonly fingerprint: string;\n  readonly signatures?: readonly AgentSignature[];\n}\n\n/**\n * Maps a registered agent to an A2A-aligned card, deriving one skill per declared capability.\n *\n * @param agent - The agent to export.\n * @param provider - The advertising organization and optional URL.\n * @returns An {@link A2AAgentCard}.\n */\nexport function toA2ACard(\n  agent: Agent,\n  provider: { readonly organization: string; readonly url?: string },\n): A2AAgentCard {\n  return {\n    protocolVersion: 'a2a-aligned/1.0',\n    name: agent.name,\n    description: `Krikos-governed agent ${agent.id} (${agent.status})`,\n    version: String(agent.credentialVersion),\n    provider,\n    skills: agent.capabilities.map((capability) => ({\n      id: capability.name,\n      name: capability.name,\n      tags: [...capability.actions],\n      ...(capability.resources !== undefined ? { resources: [...capability.resources] } : {}),\n    })),\n    fingerprint: agent.fingerprint,\n    ...(agent.signature !== undefined ? { signatures: [agent.signature] } : {}),\n  };\n}\n","/**\n * Capability matching for Krikos: the pure predicate behind every authorization decision.\n *\n * A capability grants a set of actions, optionally scoped to a set of resource patterns. This\n * module decides whether a declared capability set admits a requested (capability, action,\n * resource) triple. It is the only place resource-pattern semantics live, so the rule is stated\n * once and shared by the engine, the Vercel tool guard, the MCP guard, and the edge verifier.\n *\n * Determinism: pure functions of their inputs, no clock, no randomness, no platform globals.\n *\n * @packageDocumentation\n */\n\nimport { KrikosError } from '../errors.js';\nimport type { Capability } from '../types.js';\n\n/**\n * Validates one capability's shape, throwing on a malformed declaration so a bad capability is\n * rejected at the boundary (issue, grant) rather than silently never matching.\n *\n * @param capability - The capability to validate.\n * @throws KrikosError `ERR_INVALID_INPUT` for an empty name, an empty actions list, a non-string\n *   action, or a non-string resource pattern.\n */\nexport function assertValidCapability(capability: Capability): void {\n  if (typeof capability.name !== 'string' || capability.name.length === 0) {\n    throw KrikosError.invalid('a capability requires a non-empty name.');\n  }\n  if (!Array.isArray(capability.actions) || capability.actions.length === 0) {\n    throw KrikosError.invalid(`capability '${capability.name}' requires at least one action.`);\n  }\n  for (const action of capability.actions) {\n    if (typeof action !== 'string' || action.length === 0) {\n      throw KrikosError.invalid(\n        `capability '${capability.name}' has a non-string or empty action.`,\n      );\n    }\n  }\n  if (capability.resources !== undefined) {\n    if (!Array.isArray(capability.resources)) {\n      throw KrikosError.invalid(`capability '${capability.name}' resources must be an array.`);\n    }\n    for (const resource of capability.resources) {\n      if (typeof resource !== 'string' || resource.length === 0) {\n        throw KrikosError.invalid(\n          `capability '${capability.name}' has a non-string or empty resource pattern.`,\n        );\n      }\n    }\n  }\n}\n\n/**\n * True when `pattern` admits `resource`.\n *\n * Pattern semantics, deliberately small and unsurprising:\n * - `*` alone matches any resource.\n * - A pattern ending in `*` is a prefix match: `/data/*` admits `/data/x` and `/data/`.\n * - Any other pattern is an exact match.\n *\n * No regex, no path normalization, no globbing beyond the trailing star, so the rule cannot\n * surprise an operator reasoning about what a capability grants.\n *\n * @param pattern - A resource pattern from a capability.\n * @param resource - The concrete resource being requested.\n * @returns Whether the pattern admits the resource.\n */\nexport function resourceMatches(pattern: string, resource: string): boolean {\n  if (pattern === '*') {\n    return true;\n  }\n  if (pattern.endsWith('*')) {\n    return resource.startsWith(pattern.slice(0, -1));\n  }\n  return pattern === resource;\n}\n\n/**\n * True when a single capability admits the requested action and resource.\n *\n * The capability must permit `action`. If `resource` is provided and the capability declares\n * `resources`, one of the patterns must admit it; a capability with no `resources` admits any\n * resource. If `resource` is omitted, resource scope is not checked.\n *\n * @param capability - The capability to test.\n * @param action - The requested action.\n * @param resource - The requested resource, or undefined to skip resource scoping.\n * @returns Whether this capability alone authorizes the request.\n */\nexport function capabilityAdmits(\n  capability: Capability,\n  action: string,\n  resource: string | undefined,\n  requireResourceScope = false,\n): boolean {\n  if (!capability.actions.includes(action)) {\n    return false;\n  }\n  if (resource === undefined) {\n    return true;\n  }\n  if (capability.resources === undefined) {\n    // An unscoped capability admits any resource by default. Under least-privilege enforcement\n    // (requireResourceScope), a request that names a resource must hit an explicitly scoped\n    // capability, so an unscoped one is denied for resource-bearing requests.\n    return !requireResourceScope;\n  }\n  return capability.resources.some((pattern) => resourceMatches(pattern, resource));\n}\n\n/**\n * True when a declared capability set authorizes the (capability name, action, resource) triple.\n *\n * Finds capabilities matching `name` and returns whether any one of them admits the action and\n * resource. This is the lexical half of authorization; the engine combines it with the agent's\n * lifecycle state to produce the final fail-closed decision.\n *\n * @param capabilities - The agent's declared capabilities.\n * @param name - The capability name requested.\n * @param action - The action requested.\n * @param resource - The resource requested, or undefined.\n * @param requireResourceScope - When true, a resource-bearing request is admitted only by a\n *   capability that declares explicit resource patterns; an unscoped capability is denied. Enforces\n *   least privilege.\n * @returns Whether the capability set admits the request.\n */\nexport function capabilitiesAuthorize(\n  capabilities: readonly Capability[],\n  name: string,\n  action: string,\n  resource: string | undefined,\n  requireResourceScope = false,\n): boolean {\n  return capabilities.some(\n    (capability) =>\n      capability.name === name &&\n      capabilityAdmits(capability, action, resource, requireResourceScope),\n  );\n}\n","/**\n * Edge entry point of Krikos: a stateless identity verifier for the boundary before execution.\n *\n * An edge runtime rarely holds the registry; it holds a request and a presented Signed Agent\n * Card. The edge verifier checks, with no I/O and no registry, that the card was signed by a\n * pinned issuer key (the trust anchor), that the identity is active and unexpired, and that it\n * declares a capability admitting the requested action and resource. Only then does the edge let\n * the request through.\n *\n * Fail-closed: any missing piece (no signature, an untrusted signing key, a bad signature,\n * inactive, expired, capability not granted) denies. The verifier never throws on a bad card; it\n * returns a decision with a reason. Without a pinned trust anchor there is no verifiable identity,\n * so the verifier is constructed with the issuer key(s) it trusts.\n *\n * @packageDocumentation\n */\n\nimport type { KrikosAgentCard, TrustedKeys } from '../a2a/index.js';\nimport { verifyAgentCard } from '../a2a/index.js';\nimport { capabilitiesAuthorize } from '../capability/match.js';\nimport type { Signer } from '../identity/signing.js';\n\nexport type { KrikosAgentCard, TrustedKeys } from '../a2a/index.js';\nexport { capabilitiesAuthorize, capabilityAdmits, resourceMatches } from '../capability/match.js';\nexport type { KeyPair, Signer } from '../identity/signing.js';\nexport { webSigner } from '../identity/signing.js';\n\n/** The reason an edge decision was reached. */\nexport type EdgeDecisionReason =\n  | 'allowed'\n  | 'unsigned'\n  | 'untrusted-key'\n  | 'bad-signature'\n  | 'not-active'\n  | 'expired'\n  | 'capability-denied';\n\n/** The outcome of an edge verification. */\nexport interface EdgeDecision {\n  /** Whether the request is allowed through. */\n  readonly allowed: boolean;\n  /** The reason, machine-readable. */\n  readonly reason: EdgeDecisionReason;\n}\n\n/** What the edge is authorizing: a capability, an action, and an optional resource at an instant. */\nexport interface EdgeRequest {\n  /** The capability name required. */\n  readonly capability: string;\n  /** The action required. */\n  readonly action: string;\n  /** The resource, for resource-scoped capabilities. */\n  readonly resource?: string;\n  /** The current instant (epoch ms). Defaults to `Date.now()` at call time. */\n  readonly now?: number;\n}\n\n/**\n * Builds a stateless edge verifier bound to an Ed25519 signer and a pinned trust anchor.\n *\n * @param signer - The signer to verify card signatures with (typically {@link webSigner}).\n * @param trustedKeys - The pinned issuer public key(s) (base64url), obtained over a trusted\n *   channel. A card signed by any other key is denied with reason `untrusted-key`.\n * @returns An object with a `verify` method.\n */\nexport function edgeVerifier(\n  signer: Signer,\n  trustedKeys: TrustedKeys,\n): {\n  verify(card: KrikosAgentCard, request: EdgeRequest): Promise<EdgeDecision>;\n} {\n  const trusted: readonly string[] = typeof trustedKeys === 'string' ? [trustedKeys] : trustedKeys;\n  return {\n    async verify(card: KrikosAgentCard, request: EdgeRequest): Promise<EdgeDecision> {\n      if (card.signature === undefined) {\n        return { allowed: false, reason: 'unsigned' };\n      }\n      if (!trusted.includes(card.signature.publicKey)) {\n        return { allowed: false, reason: 'untrusted-key' };\n      }\n      const valid = await verifyAgentCard(card, signer, trusted);\n      if (!valid) {\n        return { allowed: false, reason: 'bad-signature' };\n      }\n      if (card.status !== 'active') {\n        return { allowed: false, reason: 'not-active' };\n      }\n      const now = request.now ?? Date.now();\n      if (card.expiresAt !== null && card.expiresAt <= now) {\n        return { allowed: false, reason: 'expired' };\n      }\n      const authorized = capabilitiesAuthorize(\n        card.capabilities,\n        request.capability,\n        request.action,\n        request.resource,\n      );\n      return authorized\n        ? { allowed: true, reason: 'allowed' }\n        : { allowed: false, reason: 'capability-denied' };\n    },\n  };\n}\n"]}