{"version":3,"file":"types.mjs","names":[],"sources":["../../src/jwe/types.ts"],"sourcesContent":["/**\n * Wire-format types for JWE General JSON Serialization (RFC 7516 §7.2).\n */\n\nexport const ALG_ECDH_ES = 'ECDH-ES'\nexport const ENC_A256GCM = 'A256GCM'\n\n/**\n * One recipient entry on the sender side. The registered alg handler\n * for `alg` interprets `publicKey` bytes (raw X25519 for ECDH-ES,\n * concatenated X25519||ML-KEM for pq-hybrid).\n */\nexport interface Recipient {\n  kid: string\n  publicKey: Uint8Array\n  alg?: string\n}\n\n/**\n * Output of an alg handler's sender-side step.\n * `encryptedKey` is empty for Direct Key Agreement (ECDH-ES); for\n * key-wrap algs it carries the per-recipient wrapped CEK.\n */\nexport interface KeyAgreementResult {\n  cek: Uint8Array\n  encryptedKey: Uint8Array\n  headerExtra: Record<string, unknown>\n}\n\n/** Function signature for an alg handler's sender path. */\nexport type SenderFn = (args: {\n  recipientPublicKey: Uint8Array\n  enc: string\n  apu: Uint8Array\n  apv: Uint8Array\n}) => KeyAgreementResult\n\n/**\n * Function signature for an alg handler's recipient path.\n * `recipientHeader` is the per-recipient header (with `epk` for\n * ECDH-ES, `encryptedKey` injected for key-wrap algs).\n */\nexport type RecipientFn = (args: {\n  privateKey: Uint8Array\n  recipientHeader: Record<string, unknown>\n  enc: string\n  apu: Uint8Array\n  apv: Uint8Array\n}) => Uint8Array\n\n/** JWE General JSON Serialization wire shape. */\nexport interface JweGeneralJson {\n  protected: string\n  unprotected?: Record<string, unknown>\n  recipients: Array<{\n    header?: Record<string, unknown>\n    encrypted_key?: string\n  }>\n  iv: string\n  ciphertext: string\n  tag: string\n  aad?: string\n}\n\nexport class JweAlgUnsupportedError extends Error {\n  public constructor(message: string) {\n    super(message)\n    this.name = 'JweAlgUnsupportedError'\n  }\n}\n\nexport class JweEncryptError extends Error {\n  public constructor(message: string) {\n    super(message)\n    this.name = 'JweEncryptError'\n  }\n}\n\nexport class JweDecryptError extends Error {\n  public constructor(message: string) {\n    super(message)\n    this.name = 'JweDecryptError'\n  }\n}\n\nexport class JweInvalidStructure extends Error {\n  public constructor(message: string) {\n    super(message)\n    this.name = 'JweInvalidStructure'\n  }\n}\n\nexport class JweRecipientNotFound extends Error {\n  public constructor(message: string) {\n    super(message)\n    this.name = 'JweRecipientNotFound'\n  }\n}\n"],"mappings":";;;;AAIA,MAAa,cAAc;AAC3B,MAAa,cAAc;AA2D3B,IAAa,yBAAb,cAA4C,MAAM;CAChD,AAAO,YAAY,SAAiB;AAClC,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,kBAAb,cAAqC,MAAM;CACzC,AAAO,YAAY,SAAiB;AAClC,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,kBAAb,cAAqC,MAAM;CACzC,AAAO,YAAY,SAAiB;AAClC,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,sBAAb,cAAyC,MAAM;CAC7C,AAAO,YAAY,SAAiB;AAClC,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,IAAa,uBAAb,cAA0C,MAAM;CAC9C,AAAO,YAAY,SAAiB;AAClC,QAAM,QAAQ;AACd,OAAK,OAAO"}