{"version":3,"file":"transform.mjs","names":[],"sources":["../../../../src/modules/dif-presentation-exchange/utils/transform.ts"],"sourcesContent":["import type {\n  OriginalVerifiableCredential as SphereonOriginalVerifiableCredential,\n  OriginalVerifiablePresentation as SphereonOriginalVerifiablePresentation,\n} from '@animo-id/pex/dist/main/lib/types/PexCredentialMapper'\nimport type { W3CVerifiablePresentation as SphereonW3CVerifiablePresentation } from '@sphereon/ssi-types'\nimport type { AgentContext } from '../../../agent'\nimport { Jwt } from '../../../crypto'\nimport { JsonTransformer } from '../../../utils'\nimport type { MdocRecord } from '../../mdoc'\nimport { MdocDeviceResponse } from '../../mdoc'\nimport type { SdJwtVcRecord } from '../../sd-jwt-vc'\nimport { SdJwtVcApi } from '../../sd-jwt-vc'\nimport type { W3cCredentialRecord } from '../../vc'\nimport { W3cJsonLdVerifiablePresentation, W3cJwtVerifiablePresentation } from '../../vc'\nimport type { W3cJsonPresentation } from '../../vc/models/presentation/W3cJsonPresentation'\nimport type { VerifiablePresentation } from '../models'\n\nexport function getSphereonOriginalVerifiableCredential(\n  credentialRecord: W3cCredentialRecord | SdJwtVcRecord | MdocRecord\n): SphereonOriginalVerifiableCredential {\n  return credentialRecord.encoded as SphereonOriginalVerifiableCredential\n}\n\nexport function getSphereonOriginalVerifiablePresentation(\n  verifiablePresentation: VerifiablePresentation\n): SphereonOriginalVerifiablePresentation {\n  return verifiablePresentation.encoded as SphereonOriginalVerifiablePresentation\n}\n\n// TODO: we might want to move this to some generic vc transformation util\nexport function getVerifiablePresentationFromEncoded(\n  agentContext: AgentContext,\n  encodedVerifiablePresentation: string | W3cJsonPresentation | SphereonW3CVerifiablePresentation\n) {\n  if (typeof encodedVerifiablePresentation === 'string' && encodedVerifiablePresentation.includes('~')) {\n    const sdJwtVcApi = agentContext.dependencyManager.resolve(SdJwtVcApi)\n    return sdJwtVcApi.fromCompact(encodedVerifiablePresentation)\n  }\n  if (typeof encodedVerifiablePresentation === 'string' && Jwt.format.test(encodedVerifiablePresentation)) {\n    return W3cJwtVerifiablePresentation.fromSerializedJwt(encodedVerifiablePresentation)\n  }\n  if (typeof encodedVerifiablePresentation === 'object' && '@context' in encodedVerifiablePresentation) {\n    return JsonTransformer.fromJSON(encodedVerifiablePresentation, W3cJsonLdVerifiablePresentation)\n  }\n  return MdocDeviceResponse.fromBase64Url(encodedVerifiablePresentation)\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,wCACd,kBACsC;AACtC,QAAO,iBAAiB;;AAG1B,SAAgB,0CACd,wBACwC;AACxC,QAAO,uBAAuB;;AAIhC,SAAgB,qCACd,cACA,+BACA;AACA,KAAI,OAAO,kCAAkC,YAAY,8BAA8B,SAAS,IAAI,CAElG,QADmB,aAAa,kBAAkB,QAAQ,WAAW,CACnD,YAAY,8BAA8B;AAE9D,KAAI,OAAO,kCAAkC,YAAY,IAAI,OAAO,KAAK,8BAA8B,CACrG,QAAO,6BAA6B,kBAAkB,8BAA8B;AAEtF,KAAI,OAAO,kCAAkC,YAAY,cAAc,8BACrE,QAAO,gBAAgB,SAAS,+BAA+B,gCAAgC;AAEjG,QAAO,mBAAmB,cAAc,8BAA8B"}