{"version":3,"sources":["../../src/errors.ts","../../src/identity/fingerprint.ts","../../src/identity/base64url.ts","../../src/identity/signing.ts","../../src/a2a/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,IAAI,YAAA,CAAY,OAAA,EAAS,m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,eAAA,EAAiB,iBAAA;AAAA,IACjB,MAAM,KAAA,CAAM,IAAA;AAAA,IACZ,aAAa,CAAA,sBAAA,EAAyB,KAAA,CAAM,EAAE,CAAA,EAAA,EAAK,MAAM,MAAM,CAAA,CAAA,CAAA;AAAA,IAC/D,OAAA,EAAS,MAAA,CAAO,KAAA,CAAM,iBAAiB,CAAA;AAAA,IACvC,QAAA;AAAA,IACA,MAAA,EAAQ,KAAA,CAAM,YAAA,CAAa,GAAA,CAAI,CAAC,UAAA,MAAgB;AAAA,MAC9C,IAAI,UAAA,CAAW,IAAA;AAAA,MACf,MAAM,UAAA,CAAW,IAAA;AAAA,MACjB,IAAA,EAAM,CAAC,GAAG,UAAA,CAAW,OAAO,CAAA;AAAA,MAC5B,GAAI,UAAA,CAAW,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,EAAW,CAAC,GAAG,UAAA,CAAW,SAAS,CAAA,EAAE,GAAI;AAAC,KACvF,CAAE,CAAA;AAAA,IACF,aAAa,KAAA,CAAM,WAAA;AAAA,IACnB,GAAI,KAAA,CAAM,SAAA,KAAc,MAAA,GAAY,EAAE,UAAA,EAAY,CAAC,KAAA,CAAM,SAAS,CAAA,EAAE,GAAI;AAAC,GAC3E;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"]}