{"version":3,"file":"W3cJsonLdVerifiablePresentation.mjs","names":[],"sources":["../../../../../src/modules/vc/data-integrity/models/W3cJsonLdVerifiablePresentation.ts"],"sourcesContent":["import type { SingleOrArray } from '../../../../types'\nimport { asArray, IsInstanceOrArrayOfInstances, JsonTransformer } from '../../../../utils'\nimport { ClaimFormat } from '../../models'\nimport type { W3cPresentationOptions } from '../../models/presentation/W3cPresentation'\nimport { W3cPresentation } from '../../models/presentation/W3cPresentation'\nimport type { DataIntegrityProofOptions } from './DataIntegrityProof'\nimport { DataIntegrityProof } from './DataIntegrityProof'\nimport type { LinkedDataProofOptions } from './LinkedDataProof'\nimport { LinkedDataProof } from './LinkedDataProof'\nimport { ProofTransformer } from './ProofTransformer'\n\nexport interface W3cJsonLdVerifiablePresentationOptions extends W3cPresentationOptions {\n  proof: LinkedDataProofOptions | DataIntegrityProofOptions\n}\n\nexport class W3cJsonLdVerifiablePresentation extends W3cPresentation {\n  public constructor(options: W3cJsonLdVerifiablePresentationOptions) {\n    super(options)\n    if (options) {\n      if (options.proof.cryptosuite) this.proof = new DataIntegrityProof(options.proof)\n      else this.proof = new LinkedDataProof(options.proof as LinkedDataProofOptions)\n    }\n  }\n\n  @ProofTransformer()\n  @IsInstanceOrArrayOfInstances({ classType: [LinkedDataProof, DataIntegrityProof] })\n  public proof!: SingleOrArray<LinkedDataProof | DataIntegrityProof>\n\n  public get proofTypes(): Array<string> {\n    const proofArray = asArray(this.proof) ?? []\n    return proofArray.map((proof) => proof.type)\n  }\n\n  public get dataIntegrityCryptosuites(): Array<string> {\n    const proofArray = asArray(this.proof) ?? []\n    return proofArray\n      .filter((proof): proof is DataIntegrityProof => proof.type === 'DataIntegrityProof' && 'cryptosuite' in proof)\n      .map((proof) => proof.cryptosuite)\n  }\n\n  public toJson() {\n    return JsonTransformer.toJSON(this)\n  }\n\n  /**\n   * The {@link ClaimFormat} of the presentation. For JSON-LD credentials this is always `ldp_vp`.\n   */\n  public get claimFormat(): ClaimFormat.LdpVp {\n    return ClaimFormat.LdpVp\n  }\n\n  /**\n   * Get the encoded variant of the W3C Verifiable Presentation. For JSON-LD presentations this is\n   * a JSON object.\n   */\n  public get encoded() {\n    return this.toJson()\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAa,kCAAb,cAAqD,gBAAgB;CACnE,AAAO,YAAY,SAAiD;AAClE,QAAM,QAAQ;AACd,MAAI,QACF,KAAI,QAAQ,MAAM,YAAa,MAAK,QAAQ,IAAI,mBAAmB,QAAQ,MAAM;MAC5E,MAAK,QAAQ,IAAI,gBAAgB,QAAQ,MAAgC;;CAQlF,IAAW,aAA4B;AAErC,UADmB,QAAQ,KAAK,MAAM,IAAI,EAAE,EAC1B,KAAK,UAAU,MAAM,KAAK;;CAG9C,IAAW,4BAA2C;AAEpD,UADmB,QAAQ,KAAK,MAAM,IAAI,EAAE,EAEzC,QAAQ,UAAuC,MAAM,SAAS,wBAAwB,iBAAiB,MAAM,CAC7G,KAAK,UAAU,MAAM,YAAY;;CAGtC,AAAO,SAAS;AACd,SAAO,gBAAgB,OAAO,KAAK;;;;;CAMrC,IAAW,cAAiC;AAC1C,SAAO,YAAY;;;;;;CAOrB,IAAW,UAAU;AACnB,SAAO,KAAK,QAAQ;;;;CAhCrB,kBAAkB;CAClB,6BAA6B,EAAE,WAAW,CAAC,iBAAiB,mBAAmB,EAAE,CAAC"}