{"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;CACtC,OAAO,iBAAiB;AAC1B;AAEA,SAAgB,0CACd,wBACwC;CACxC,OAAO,uBAAuB;AAChC;AAGA,SAAgB,qCACd,cACA,+BACA;CACA,IAAI,OAAO,kCAAkC,YAAY,8BAA8B,SAAS,GAAG,GAEjG,OADmB,aAAa,kBAAkB,QAAQ,UAC1C,CAAC,CAAC,YAAY,6BAA6B;CAE7D,IAAI,OAAO,kCAAkC,YAAY,IAAI,OAAO,KAAK,6BAA6B,GACpG,OAAO,6BAA6B,kBAAkB,6BAA6B;CAErF,IAAI,OAAO,kCAAkC,YAAY,cAAc,+BACrE,OAAO,gBAAgB,SAAS,+BAA+B,+BAA+B;CAEhG,OAAO,mBAAmB,cAAc,6BAA6B;AACvE"}