{"version":3,"file":"disclosureFrame.mjs","names":[],"sources":["../../../../src/modules/vc/sd-jwt-vc/disclosureFrame.ts"],"sourcesContent":["import { CredoError } from '../../../error'\nimport type { IDisclosureFrame } from '../../sd-jwt-vc'\n\n/**\n * List of fields that cannot be selectively disclosed.\n *\n * @see https://www.w3.org/TR/vc-jose-cose/#securing-with-sd-jwt\n * @see https://www.w3.org/TR/vc-jose-cose/#securing-vps-sd-jwt\n */\nexport const NON_DISCLOSEABLE_FIELDS = [\n  '@context',\n  'type',\n  'credentialStatus',\n  'credentialSchema',\n  'relatedResource',\n] as const\n\n/**\n * Asserts that a disclosure frame does not make any of the {@link NON_DISCLOSEABLE_FIELDS} of a W3C\n * VCDM 2.0 credential or presentation selectively disclosable.\n *\n * Only the top level of the frame is checked. A nested claim that happens to share a name with a\n * non-discloseable field, such as `credentialSubject.type`, may be selectively disclosed.\n */\nexport function validateW3cV2SdJwtDisclosureFrame(disclosureFrame?: IDisclosureFrame) {\n  if (!disclosureFrame) return\n\n  for (const field of NON_DISCLOSEABLE_FIELDS) {\n    if (disclosureFrame[field]) {\n      throw new CredoError(`'${field}' property cannot be selectively disclosed`)\n    }\n\n    if (Array.isArray(disclosureFrame._sd) && disclosureFrame._sd.includes(field)) {\n      throw new CredoError(`'${field}' property cannot be selectively disclosed`)\n    }\n  }\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,kCAAkC,iBAAoC;CACpF,IAAI,CAAC,iBAAiB;CAEtB,KAAK,MAAM,SAAS,yBAAyB;EAC3C,IAAI,gBAAgB,QAClB,MAAM,IAAI,WAAW,IAAI,MAAM,2CAA2C;EAG5E,IAAI,MAAM,QAAQ,gBAAgB,GAAG,KAAK,gBAAgB,IAAI,SAAS,KAAK,GAC1E,MAAM,IAAI,WAAW,IAAI,MAAM,2CAA2C;CAE9E;AACF"}