@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
1 lines • 59.9 kB
Source Map (JSON)
{"version":3,"file":"DcqlService.mjs","names":["getDcqlVcPresentationsToCreate"],"sources":["../../../src/modules/dcql/DcqlService.ts"],"sourcesContent":["import {\n DcqlCredential,\n DcqlCredentialQuery,\n DcqlMdocCredential,\n DcqlPresentationResult,\n DcqlQuery,\n DcqlSdJwtVcCredential,\n DcqlW3cVcCredential,\n} from 'dcql'\nimport type { AgentContext } from '../../agent'\nimport { injectable } from '../../plugins'\nimport { isNonEmptyArray, type JsonObject, type JsonValue, mapNonEmptyArray } from '../../types'\nimport { asArray, JsonTransformer, TypedArrayEncoder } from '../../utils'\nimport {\n CredentialMultiInstanceUseMode,\n canUseInstanceFromCredentialRecord,\n useInstanceFromCredentialRecord,\n} from '../../utils/credentialUse'\nimport { DidsApi, getPublicJwkFromVerificationMethod, VerificationMethod } from '../dids'\nimport type { VerifiableCredential, VerifiablePresentation } from '../dif-presentation-exchange/index'\nimport {\n Mdoc,\n MdocApi,\n MdocDeviceResponse,\n type MdocNameSpaces,\n MdocRecord,\n type MdocSessionTranscriptOptions,\n} from '../mdoc'\nimport { SdJwtVcApi, SdJwtVcRecord, SdJwtVcService } from '../sd-jwt-vc'\nimport {\n applyDisclosuresForPaths,\n buildDisclosureFrameForPayload,\n buildPresentationFrameForPaths,\n type ClaimPath,\n getClaimPathsForDcqlClaimSet,\n} from '../sd-jwt-vc/disclosureFrame'\nimport {\n ClaimFormat,\n SignatureSuiteRegistry,\n W3cCredentialRecord,\n W3cCredentialRepository,\n W3cCredentialService,\n W3cJsonLdCredentialService,\n W3cJsonLdVerifiableCredential,\n W3cPresentation,\n W3cV2Credential,\n W3cV2CredentialRecord,\n W3cV2CredentialRepository,\n W3cV2CredentialService,\n W3cV2EnvelopedVerifiableCredential,\n W3cV2Presentation,\n} from '../vc'\nimport { purposes } from '../vc/linked-data-proofs/adapters/jsonld-signatures-adapter'\nimport { W3cV2SdJwtCredentialService, W3cV2SdJwtVerifiableCredential } from '../vc/sd-jwt-vc'\nimport { X509Certificate } from '../x509'\nimport { DcqlError } from './DcqlError'\nimport type {\n DcqlCredentialsForRequest,\n DcqlEncodedPresentations,\n DcqlFailedCredential,\n DcqlPresentation,\n DcqlQueryResult,\n DcqlSelectiveDisclosure,\n DcqlValidCredential,\n} from './models'\nimport { dcqlGetPresentationsToCreate as getDcqlVcPresentationsToCreate } from './utils'\n\nexport interface DcqlSelectCredentialsForRequestOptions {\n /**\n * The usage mode to apply to the credentials when selecting credentials.\n *\n * If an usage mode is selected that require a new instance to be used, and there's no\n * new instances available, an error will be thrown.\n *\n * It does not actually select the credential from the record yet, it just filters\n * out records that don't match the filter.\n */\n useMode?: CredentialMultiInstanceUseMode\n}\n\n@injectable()\nexport class DcqlService {\n /**\n * Queries the wallet for credentials that match the given dcql query. This only does an initial query based on the\n * schema of the input descriptors. It does not do any further filtering based on the constraints in the input descriptors.\n */\n private async queryCredentialsForDcqlQuery(\n agentContext: AgentContext,\n dcqlQuery: DcqlQuery\n ): Promise<Array<SdJwtVcRecord | W3cCredentialRecord | W3cV2CredentialRecord | MdocRecord>> {\n const formats = new Set(dcqlQuery.credentials.map((c) => c.format))\n const allRecords: Array<SdJwtVcRecord | W3cCredentialRecord | W3cV2CredentialRecord | MdocRecord> = []\n\n const mdocDoctypes = dcqlQuery.credentials\n .filter((credentialQuery) => credentialQuery.format === 'mso_mdoc')\n .map((c) => c.meta?.doctype_value)\n\n const mdocApi = this.getMdocApi(agentContext)\n if (mdocDoctypes.every((doctype) => doctype !== undefined)) {\n const mdocRecords = await mdocApi.findAllByQuery({\n $or: mdocDoctypes.map((docType) => ({\n docType: docType,\n })),\n })\n allRecords.push(...mdocRecords)\n } else if (formats.has('mso_mdoc')) {\n const mdocRecords = await mdocApi.getAll()\n allRecords.push(...mdocRecords)\n }\n\n const sdJwts = dcqlQuery.credentials.filter(\n (credentialQuery): credentialQuery is DcqlCredentialQuery.SdJwtVc =>\n (credentialQuery.format === 'vc+sd-jwt' && !(credentialQuery.meta && 'type_values' in credentialQuery.meta)) ||\n credentialQuery.format === 'dc+sd-jwt'\n )\n\n const sdJwtVctValues = sdJwts.flatMap((c) => c.meta?.vct_values)\n\n const sdJwtVcApi = this.getSdJwtVcApi(agentContext)\n if (sdJwtVctValues.every((vct) => vct !== undefined)) {\n const sdjwtVcRecords = await sdJwtVcApi.findAllByQuery({\n $or: [\n // Look for direct vct match\n ...sdJwtVctValues.map((vct) => ({\n vct,\n })),\n // Or an extended vct value\n ...sdJwtVctValues.map((vct) => ({\n extendedVctValues: [vct],\n })),\n ],\n })\n allRecords.push(...sdjwtVcRecords)\n } else if (sdJwts.length > 0) {\n const sdJwtVcRecords = await sdJwtVcApi.getAll()\n allRecords.push(...sdJwtVcRecords)\n }\n\n const w3cCredentialRepository = agentContext.dependencyManager.resolve(W3cCredentialRepository)\n if (formats.has('jwt_vc_json')) {\n const w3cRecords = await w3cCredentialRepository.findByQuery(agentContext, {\n claimFormat: ClaimFormat.JwtVc,\n\n // For jwt_vc_json we query the non-expanded types\n $or: dcqlQuery.credentials\n .flatMap((c) => (c.format === 'jwt_vc_json' ? c.meta.type_values : []))\n .map((typeValues) => ({\n types: typeValues,\n })),\n })\n allRecords.push(...w3cRecords)\n }\n\n if (formats.has('ldp_vc')) {\n const w3cRecords = await w3cCredentialRepository.findByQuery(agentContext, {\n claimFormat: ClaimFormat.LdpVc,\n\n // For LDP_VC we query the expanded types\n $or: dcqlQuery.credentials\n .flatMap((c) => (c.format === 'jwt_vc_json' ? c.meta.type_values : []))\n .map((typeValues) => ({\n expandedTypes: typeValues,\n })),\n })\n allRecords.push(...w3cRecords)\n }\n\n const w3cSdJwts = dcqlQuery.credentials.filter(\n (credentialQuery): credentialQuery is DcqlCredentialQuery.W3cVc & { format: 'vc+sd-jwt' } =>\n credentialQuery.format === 'vc+sd-jwt' && !!credentialQuery.meta && 'type_values' in credentialQuery.meta\n )\n\n if (w3cSdJwts.length > 0) {\n const w3cV2CredentialRepository = agentContext.dependencyManager.resolve(W3cV2CredentialRepository)\n\n const w3cV2Records = await w3cV2CredentialRepository.findByQuery(agentContext, {\n claimFormat: ClaimFormat.SdJwtW3cVc,\n $or: dcqlQuery.credentials\n .flatMap((c) => (c.format === 'vc+sd-jwt' && c.meta && 'type_values' in c.meta ? c.meta.type_values : []))\n .map((typeValues) => ({\n types: typeValues,\n })),\n })\n\n allRecords.push(...w3cV2Records)\n }\n\n return allRecords\n }\n\n private getAuthorityForCredential(\n credential: VerifiableCredential | W3cV2EnvelopedVerifiableCredential\n ): DcqlCredential['authority'] {\n if (credential.claimFormat === ClaimFormat.SdJwtDc) {\n const akiValues = (credential.header.x5c as string[] | undefined)\n ?.map((c) => {\n const akiHex = X509Certificate.fromEncodedCertificate(c).authorityKeyIdentifier\n return akiHex ? TypedArrayEncoder.toBase64Url(TypedArrayEncoder.fromHex(akiHex)) : undefined\n })\n .filter((aki) => aki !== undefined)\n\n return akiValues && isNonEmptyArray(akiValues)\n ? ({\n type: 'aki',\n values: akiValues,\n } as const)\n : undefined\n }\n\n if (credential.claimFormat === ClaimFormat.MsoMdoc) {\n const akiValues = credential.issuerSignedCertificateChain\n .map((c) => {\n const akiHex = X509Certificate.fromRawCertificate(c).authorityKeyIdentifier\n return akiHex ? TypedArrayEncoder.toBase64Url(TypedArrayEncoder.fromHex(akiHex)) : undefined\n })\n .filter((aki) => aki !== undefined)\n\n return akiValues && isNonEmptyArray(akiValues)\n ? ({\n type: 'aki',\n values: akiValues,\n } as const)\n : undefined\n }\n\n return undefined\n }\n\n public async getDcqlCredentialRepresentation(\n agentContext: AgentContext,\n presentation: VerifiablePresentation,\n queryCredential: DcqlQuery['credentials'][number]\n ): Promise<DcqlCredential> {\n // SD-JWT credential can be used as both dc+sd-jwt and vc+sd-jwt\n // At some point we might want to look at the header value of the sd-jwt (vc+sd-jwt vc dc+sd-jwt)\n if (presentation.claimFormat === ClaimFormat.SdJwtDc) {\n const requestedVcts = queryCredential.format === 'dc+sd-jwt' ? queryCredential.meta?.vct_values : undefined\n\n let presentationVctValues = [presentation.payload.vct]\n // FIXME: we should probably add an option whether to resolve VCT if we didn't get a direct hit\n if (!requestedVcts?.includes(presentation.payload.vct)) {\n const typeMetadataChain = await agentContext\n .resolve(SdJwtVcService)\n .fetchTypeMetadata(agentContext, presentation, {\n throwErrorOnFetchError: false,\n throwErrorOnUnsupportedVctValue: false,\n })\n\n if (typeMetadataChain) {\n presentationVctValues = typeMetadataChain?.vctValues\n }\n }\n\n return {\n credential_format: queryCredential.format === 'dc+sd-jwt' ? 'dc+sd-jwt' : 'vc+sd-jwt',\n authority: this.getAuthorityForCredential(presentation),\n cryptographic_holder_binding: true,\n vct:\n presentationVctValues.find((presentationVctValue) => requestedVcts?.includes(presentationVctValue)) ??\n presentation.payload.vct,\n claims: presentation.prettyClaims as DcqlSdJwtVcCredential.Claims,\n } satisfies DcqlSdJwtVcCredential\n }\n if (presentation.claimFormat === ClaimFormat.MsoMdoc) {\n if (!presentation.deviceResponse.documents || presentation.deviceResponse.documents.length !== 1) {\n throw new DcqlError('MDOC presentations must contain exactly one document')\n }\n\n return {\n cryptographic_holder_binding: true,\n credential_format: 'mso_mdoc',\n authority: this.getAuthorityForCredential(new Mdoc(presentation.deviceResponse.documents[0].issuerSigned)),\n doctype: presentation.deviceResponse.documents[0].docType,\n namespaces: Object.entries(\n Object.fromEntries(\n presentation.deviceResponse.documents[0].issuerSigned.issuerNamespaces?.issuerNamespaces ?? []\n )\n ).reduce(\n (prev, [key, value]) => ({\n // biome-ignore lint/performance/noAccumulatingSpread: time complexity not relevant here\n ...prev,\n [key]: value.reduce<Record<string, unknown>>(\n // biome-ignore lint/performance/noAccumulatingSpread: time complexity not relevant here\n (prev, curr) => ({ ...prev, [curr.elementIdentifier]: curr.elementValue }),\n {}\n ),\n }),\n {}\n ),\n } satisfies DcqlMdocCredential\n }\n if (presentation.claimFormat === ClaimFormat.JwtVp) {\n const vc = Array.isArray(presentation.verifiableCredential)\n ? presentation.verifiableCredential[0]\n : presentation.verifiableCredential\n\n return {\n cryptographic_holder_binding: true,\n credential_format: 'jwt_vc_json',\n authority: this.getAuthorityForCredential(vc),\n claims: vc.jsonCredential as { [key: string]: JsonValue },\n type: vc.type,\n } satisfies DcqlW3cVcCredential\n }\n if (presentation.claimFormat === ClaimFormat.LdpVp) {\n const vc = Array.isArray(presentation.verifiableCredential)\n ? (presentation.verifiableCredential[0] as W3cJsonLdVerifiableCredential)\n : (presentation.verifiableCredential as W3cJsonLdVerifiableCredential)\n\n const w3cJsonLdCredentialService = agentContext.dependencyManager.resolve(W3cJsonLdCredentialService)\n const expandedTypes = await w3cJsonLdCredentialService.getExpandedTypesForCredential(agentContext, vc)\n\n return {\n cryptographic_holder_binding: true,\n credential_format: 'ldp_vc',\n authority: this.getAuthorityForCredential(vc),\n claims: vc.jsonCredential as DcqlW3cVcCredential.Claims,\n type: expandedTypes,\n } satisfies DcqlW3cVcCredential\n }\n if (presentation.claimFormat === ClaimFormat.SdJwtW3cVp) {\n const firstEntry = Array.isArray(presentation.resolvedPresentation.verifiableCredential)\n ? presentation.resolvedPresentation.verifiableCredential[0]\n : presentation.resolvedPresentation.verifiableCredential\n\n if (!(firstEntry instanceof W3cV2EnvelopedVerifiableCredential)) {\n throw new DcqlError(\n 'Expected an EnvelopedVerifiableCredential entry for vc+sd-jwt presentation claim extraction'\n )\n }\n\n return {\n cryptographic_holder_binding: true,\n credential_format: 'vc+sd-jwt',\n authority: this.getAuthorityForCredential(firstEntry),\n type: asArray(firstEntry.resolvedCredential.type),\n claims: firstEntry.resolvedCredential.toJSON() as { [key: string]: JsonValue },\n } satisfies DcqlW3cVcCredential\n }\n\n throw new DcqlError('Unsupported claim format for presentation')\n }\n\n public async getCredentialsForRequest(agentContext: AgentContext, dcqlQuery: DcqlQuery): Promise<DcqlQueryResult> {\n const credentialRecords = await this.queryCredentialsForDcqlQuery(agentContext, dcqlQuery)\n const credentialRecordsWithFormatDuplicates: typeof credentialRecords = []\n const parsedQuery = DcqlQuery.parse(dcqlQuery)\n\n const dcqlCredentials: DcqlCredential[] = credentialRecords.flatMap((record): DcqlCredential | DcqlCredential[] => {\n if (record.type === 'MdocRecord') {\n credentialRecordsWithFormatDuplicates.push(record)\n\n // We always extract the first mdoc for querying\n const mdoc = record.firstCredential\n\n return {\n authority: this.getAuthorityForCredential(mdoc),\n credential_format: 'mso_mdoc',\n doctype: mdoc.docType,\n namespaces: mdoc.issuerSignedNamespaces,\n cryptographic_holder_binding: true,\n } satisfies DcqlCredential\n }\n\n if (record.type === 'SdJwtVcRecord') {\n const sdJwtVc = record.firstCredential\n const claims = sdJwtVc.prettyClaims as DcqlSdJwtVcCredential.Claims\n\n // To keep correct mapping of input credential index, we add it multiple times here:\n // - for dc+sd-jwt and vc+sd-jwt\n // - for each extended VCT (until we have multi-vct support in DCQL)\n credentialRecordsWithFormatDuplicates.push(\n record,\n record,\n ...record.extendedVctValues.map(() => record),\n ...record.extendedVctValues.map(() => record)\n )\n\n return [\n {\n authority: this.getAuthorityForCredential(sdJwtVc),\n credential_format: 'dc+sd-jwt',\n vct: record.getTags().vct,\n claims,\n cryptographic_holder_binding: true,\n } satisfies DcqlSdJwtVcCredential,\n ...record.extendedVctValues.map(\n (extendedVctValue) =>\n ({\n authority: this.getAuthorityForCredential(sdJwtVc),\n credential_format: 'dc+sd-jwt',\n vct: extendedVctValue,\n claims,\n cryptographic_holder_binding: true,\n }) satisfies DcqlSdJwtVcCredential\n ),\n {\n authority: this.getAuthorityForCredential(sdJwtVc),\n credential_format: 'vc+sd-jwt',\n vct: record.getTags().vct,\n claims,\n cryptographic_holder_binding: true,\n } satisfies DcqlSdJwtVcCredential,\n ...record.extendedVctValues.map(\n (extendedVctValue) =>\n ({\n authority: this.getAuthorityForCredential(sdJwtVc),\n credential_format: 'vc+sd-jwt',\n vct: extendedVctValue,\n claims,\n cryptographic_holder_binding: true,\n }) satisfies DcqlSdJwtVcCredential\n ),\n ] satisfies DcqlSdJwtVcCredential[]\n }\n\n if (record.type === 'W3cCredentialRecord') {\n const firstCredential = record.firstCredential\n credentialRecordsWithFormatDuplicates.push(record)\n if (firstCredential.claimFormat === ClaimFormat.LdpVc) {\n return {\n credential_format: 'ldp_vc',\n authority: this.getAuthorityForCredential(firstCredential),\n type: record.getTags().expandedTypes ?? [],\n claims: firstCredential.jsonCredential as DcqlW3cVcCredential.Claims,\n cryptographic_holder_binding: true,\n } satisfies DcqlW3cVcCredential\n }\n\n return {\n credential_format: 'jwt_vc_json',\n authority: this.getAuthorityForCredential(firstCredential),\n type: firstCredential.type,\n claims: firstCredential.jsonCredential as DcqlW3cVcCredential.Claims,\n cryptographic_holder_binding: true,\n } satisfies DcqlW3cVcCredential\n }\n\n if (record.type === 'W3cV2CredentialRecord') {\n credentialRecordsWithFormatDuplicates.push(record)\n const firstCredential = record.firstCredential\n\n return {\n credential_format: 'vc+sd-jwt',\n authority: this.getAuthorityForCredential(firstCredential),\n type: asArray(firstCredential.resolvedCredential.type),\n claims: firstCredential.resolvedCredential.toJSON() as DcqlW3cVcCredential.Claims,\n cryptographic_holder_binding: true,\n } satisfies DcqlW3cVcCredential\n }\n\n throw new DcqlError('Unsupported record type')\n })\n\n const queryResult = DcqlQuery.query(parsedQuery, dcqlCredentials)\n\n const matchesWithRecord = Object.fromEntries(\n Object.entries(queryResult.credential_matches).map(([credential_query_id, result]) => {\n const failedCredentials = result.failed_credentials\n ? mapNonEmptyArray(result.failed_credentials, (credential) => {\n const record = credentialRecordsWithFormatDuplicates[credential.input_credential_index]\n const updatedCredential: DcqlFailedCredential = {\n ...credential,\n record,\n claims: credential.claims.success\n ? {\n ...credential.claims,\n success: true,\n valid_claim_sets: mapNonEmptyArray(credential.claims.valid_claim_sets, (claimSet) => ({\n ...claimSet,\n ...this.getDisclosedClaimSetOutput(record, claimSet, parsedQuery, credential_query_id),\n })),\n }\n : credential.claims,\n }\n return updatedCredential\n })\n : undefined\n\n // If not success, valid_credentials will be undefined, so we only have to map failed_credentials\n if (!result.success) {\n return [\n credential_query_id,\n {\n ...result,\n failed_credentials: failedCredentials,\n },\n ]\n }\n\n return [\n credential_query_id,\n {\n ...result,\n failed_credentials: failedCredentials,\n valid_credentials: mapNonEmptyArray(result.valid_credentials, (credential) => {\n const record = credentialRecordsWithFormatDuplicates[credential.input_credential_index]\n const updatedCredential: DcqlValidCredential = {\n ...credential,\n record,\n claims: {\n ...credential.claims,\n valid_claim_sets: mapNonEmptyArray(credential.claims.valid_claim_sets, (claimSet) => ({\n ...claimSet,\n ...this.getDisclosedClaimSetOutput(record, claimSet, parsedQuery, credential_query_id),\n })),\n },\n }\n return updatedCredential\n }),\n },\n ]\n })\n )\n\n return {\n ...queryResult,\n credential_matches: matchesWithRecord,\n }\n }\n\n /**\n * What a selectively disclosable credential discloses for the output of a claim set.\n *\n * The output of DCQL only holds the requested claims, while a claim that is not selectively\n * disclosable is always disclosed. So the output is replaced with the claims as the verifier receives\n * them, and `disclosed_paths` added: the paths to those claims in the credential, which are what to\n * disclose when presenting it.\n *\n * Other credentials disclose the output as it is.\n */\n private getDisclosedClaimSetOutput(\n record: DcqlValidCredential['record'],\n claimSet: { output: unknown; valid_claim_indexes?: number[] },\n dcqlQuery: DcqlQuery.Output,\n credentialQueryId: string\n ) {\n // The paths of the claims queries of the claim set, each with the elements a `null` in it selects\n const getClaimPaths = () => {\n const claimsQueries = dcqlQuery.credentials.find((credential) => credential.id === credentialQueryId)?.claims\n const claimsQueryPaths = (claimSet.valid_claim_indexes ?? []).flatMap((index) => {\n const claimsQuery = claimsQueries?.[index]\n // Note path is an array again, we use flatmap, so wrap it in another array, so that if\n // no value is returned ([]) it is not included as undefined in the array\n return claimsQuery && 'path' in claimsQuery ? [claimsQuery.path] : []\n })\n\n return getClaimPathsForDcqlClaimSet(claimsQueryPaths, claimSet.output)\n }\n\n if (record.type === 'SdJwtVcRecord') {\n const { prettyClaims, disclosedPaths } = applyDisclosuresForPaths(record.encoded, getClaimPaths())\n\n return { output: prettyClaims as { [key: string]: JsonValue }, disclosed_paths: disclosedPaths }\n }\n\n if (record.type === 'W3cV2CredentialRecord' && record.firstCredential instanceof W3cV2SdJwtVerifiableCredential) {\n const { prettyClaims, disclosedPaths } = applyDisclosuresForPaths(record.firstCredential.encoded, getClaimPaths())\n\n return {\n // The same shape as the claims DCQL was queried with, which are the credential's JSON\n output: JsonTransformer.fromJSON(prettyClaims, W3cV2Credential, { validate: false }).toJSON() as {\n [key: string]: JsonValue\n },\n disclosed_paths: disclosedPaths,\n }\n }\n\n return {}\n }\n\n public async assertValidDcqlPresentation(\n agentContext: AgentContext,\n dcqlPresentation: DcqlPresentation,\n dcqlQuery: DcqlQuery\n ) {\n const internalDcqlPresentation = Object.fromEntries(\n await Promise.all(\n Object.entries(dcqlPresentation).map(async ([credentialId, presentations]) => {\n const queryCredential = dcqlQuery.credentials.find((c) => c.id === credentialId)\n if (!queryCredential) {\n throw new DcqlError(\n `DCQL presentation contains presentation entry for credential id '${credentialId}', but this id is not present in the DCQL query`\n )\n }\n\n return [\n credentialId,\n await Promise.all(\n presentations.map((presentation) =>\n this.getDcqlCredentialRepresentation(agentContext, presentation, queryCredential)\n )\n ),\n ]\n })\n )\n )\n\n const presentationResult = DcqlPresentationResult.fromDcqlPresentation(internalDcqlPresentation, { dcqlQuery })\n\n if (!presentationResult.can_be_satisfied) {\n throw new DcqlError('Presentations do not satisfy the DCQL query.', {\n additionalMessages: Object.entries(presentationResult.credential_matches ?? {})\n .flatMap(([queryId, match]) =>\n match.success\n ? undefined\n : !match.failed_credentials\n ? `Unable to match query credential '${queryId}'. No prsentations provided`\n : match.failed_credentials.map(\n (failedCredential) =>\n `Presentation at index ${failedCredential.input_credential_index} does not match query credential '${queryId}'. ${JSON.stringify(\n {\n ...(failedCredential.claims.success\n ? {}\n : { claims: failedCredential.claims.failed_claim_sets.map((cs) => cs.issues) }),\n ...(failedCredential.trusted_authorities.success\n ? {}\n : {\n trusted_authorities:\n failedCredential.trusted_authorities.failed_trusted_authorities.map(\n (ta) => ta.issues\n ),\n }),\n ...(failedCredential.meta.success ? {} : { meta: failedCredential.meta.issues }),\n },\n null,\n 2\n )}`\n )\n )\n .filter((message) => message !== undefined),\n })\n }\n\n return presentationResult\n }\n\n private getSelectiveDisclosure(validCredential: DcqlValidCredential): DcqlSelectiveDisclosure {\n const [{ output, disclosed_paths }] = validCredential.claims.valid_claim_sets\n\n return disclosed_paths\n ? { disclosedPaths: disclosed_paths, disclosedPayload: output as JsonObject }\n : { disclosedPayload: output as JsonObject }\n }\n\n private dcqlCredentialForRequestForValidCredential(validCredential: DcqlValidCredential) {\n if (validCredential.record.type === 'MdocRecord') {\n return {\n claimFormat: ClaimFormat.MsoMdoc,\n credentialRecord: validCredential.record,\n disclosedPayload: validCredential.claims.valid_claim_sets[0].output as MdocNameSpaces,\n } as const\n }\n if (validCredential.record.type === 'SdJwtVcRecord') {\n return {\n claimFormat: ClaimFormat.SdJwtDc,\n credentialRecord: validCredential.record,\n ...this.getSelectiveDisclosure(validCredential),\n } as const\n }\n\n if (validCredential.record.type === 'W3cCredentialRecord') {\n return {\n claimFormat: validCredential.record.firstCredential.claimFormat,\n credentialRecord: validCredential.record,\n disclosedPayload: validCredential.record.firstCredential.jsonCredential as JsonObject,\n } as const\n }\n\n if (validCredential.record.type === 'W3cV2CredentialRecord') {\n const claimFormat = validCredential.record.firstCredential.claimFormat\n\n if (claimFormat === ClaimFormat.DiVc) {\n throw new DcqlError('DCQL credential selection does not support W3C V2 Data Integrity credentials yet')\n }\n\n if (claimFormat === ClaimFormat.SdJwtW3cVc) {\n return {\n claimFormat,\n credentialRecord: validCredential.record,\n ...this.getSelectiveDisclosure(validCredential),\n } as const\n }\n\n return {\n claimFormat,\n credentialRecord: validCredential.record,\n disclosedPayload: validCredential.claims.valid_claim_sets[0].output as JsonObject,\n } as const\n }\n\n throw new DcqlError('Unsupported record type for DCQL')\n }\n\n /**\n * Selects the credentials to use based on the output from `getCredentialsForRequest`\n * Use this method if you don't want to manually select the credentials yourself.\n */\n public selectCredentialsForRequest(\n dcqlQueryResult: DcqlQueryResult,\n { useMode = CredentialMultiInstanceUseMode.NewOrFirst }: DcqlSelectCredentialsForRequestOptions = {}\n ): DcqlCredentialsForRequest {\n if (!dcqlQueryResult.can_be_satisfied) {\n throw new DcqlError(\n 'Cannot select the credentials for the dcql query presentation if the request cannot be satisfied'\n )\n }\n\n const credentials: DcqlCredentialsForRequest = {}\n\n if (dcqlQueryResult.credential_sets) {\n credentialSetLoop: for (const credentialSet of dcqlQueryResult.credential_sets) {\n // undefined defaults to true\n if (credentialSet.required === false) continue\n const fullfillableOptions = credentialSet.matching_options\n\n if (!fullfillableOptions) {\n throw new DcqlError('Invalid dcql query result. No option is fullfillable')\n }\n\n for (const fullfillableOption of fullfillableOptions) {\n const optionMatches = fullfillableOption.map((credentialQueryId) => {\n const credentialMatch = dcqlQueryResult.credential_matches[credentialQueryId]\n if (!credentialMatch.success) return undefined\n const match = credentialMatch.valid_credentials.find((match: DcqlValidCredential) =>\n canUseInstanceFromCredentialRecord({ credentialRecord: match.record, useMode })\n )\n\n if (!match) return undefined\n return {\n match,\n credentialQueryId,\n }\n })\n\n if (optionMatches.every((c) => c !== undefined)) {\n for (const { match, credentialQueryId } of optionMatches) {\n credentials[credentialQueryId] = [this.dcqlCredentialForRequestForValidCredential(match)]\n }\n\n continue credentialSetLoop\n }\n }\n\n throw new DcqlError(\n 'Unable to select credentials for credential set. No new credential instance available on any of the available credentials.'\n )\n }\n } else {\n for (const credentialQuery of dcqlQueryResult.credentials) {\n const credentialMatch = dcqlQueryResult.credential_matches[credentialQuery.id]\n if (!credentialMatch.success) {\n throw new DcqlError(\n `Invalid dcql query result for credential query id '${credentialQuery.id}'. Cannot auto-select credentials`\n )\n }\n\n const credential = credentialMatch.valid_credentials.find((match: DcqlValidCredential) =>\n canUseInstanceFromCredentialRecord({ credentialRecord: match.record, useMode })\n )\n if (!credential) {\n throw new DcqlError(\n `Unable to select credential for credential query id '${credentialQuery.id}'. No new credential instance available on any of the available credentials.`\n )\n }\n\n credentials[credentialQuery.id] = [this.dcqlCredentialForRequestForValidCredential(credential)]\n }\n }\n\n return credentials\n }\n\n public validateDcqlQuery(dcqlQuery: DcqlQuery | DcqlQuery.Input | unknown): DcqlQuery {\n const parsed = DcqlQuery.parse(dcqlQuery as DcqlQuery)\n DcqlQuery.validate(parsed)\n return parsed\n }\n\n public async createPresentation(\n agentContext: AgentContext,\n options: {\n credentialQueryToCredential: DcqlCredentialsForRequest\n challenge: string\n domain?: string\n mdocSessionTranscript?: MdocSessionTranscriptOptions\n }\n ): Promise<{\n dcqlPresentation: DcqlPresentation\n encodedDcqlPresentation: DcqlEncodedPresentations\n }> {\n const { domain, challenge, mdocSessionTranscript } = options\n\n const dcqlPresentation: DcqlPresentation = {}\n const encodedDcqlPresentation: DcqlEncodedPresentations = {}\n const vcPresentationsToCreate = getDcqlVcPresentationsToCreate(options.credentialQueryToCredential)\n\n for (const [credentialQueryId, presentationsToCreate] of Object.entries(vcPresentationsToCreate)) {\n for (const presentationToCreate of presentationsToCreate) {\n let createdPresentation: VerifiablePresentation\n let encodedCreatedPresentation: string | Record<string, unknown>\n\n if (presentationToCreate.claimFormat === ClaimFormat.MsoMdoc) {\n const mdocRecord = presentationToCreate.credentialRecord\n if (!mdocSessionTranscript) {\n throw new DcqlError('Missing mdoc session transcript options for creating MDOC presentation.')\n }\n\n const { credentialInstance } = await useInstanceFromCredentialRecord({\n agentContext,\n useMode: presentationToCreate.useMode,\n credentialRecord: mdocRecord,\n })\n\n const deviceResponse = await MdocDeviceResponse.createDeviceResponse(agentContext, {\n mdocs: [credentialInstance],\n documentRequests: [\n {\n docType: mdocRecord.getTags().docType,\n nameSpaces: Object.fromEntries(\n Object.entries(presentationToCreate.disclosedPayload).map(([key, value]) => {\n // FIXME: we need the DCQL query here to get the intent_to_retain from query (currently hardcoded to false)\n return [key, Object.fromEntries(Object.entries(value).map(([key]) => [key, false]))]\n })\n ),\n },\n ],\n sessionTranscriptOptions: mdocSessionTranscript,\n })\n const deviceResponseBase64Url = deviceResponse.encoded\n\n encodedCreatedPresentation = deviceResponseBase64Url\n createdPresentation = MdocDeviceResponse.fromBase64Url(deviceResponseBase64Url)\n } else if (presentationToCreate.claimFormat === ClaimFormat.SdJwtDc) {\n if (!domain) {\n throw new DcqlError('Missing domain property for creating SdJwtVc presentation.')\n }\n\n const { credentialInstance } = await useInstanceFromCredentialRecord({\n agentContext,\n useMode: presentationToCreate.useMode,\n credentialRecord: presentationToCreate.credentialRecord,\n })\n\n const presentationFrame = this.getPresentationFrame(\n typeof credentialInstance === 'string' ? credentialInstance : credentialInstance.compact,\n presentationToCreate\n )\n\n const sdJwtVcApi = this.getSdJwtVcApi(agentContext)\n const presentation = await sdJwtVcApi.present({\n sdJwtVc: credentialInstance,\n presentationFrame,\n verifierMetadata: {\n audience: domain,\n nonce: challenge,\n issuedAt: Math.floor(Date.now() / 1000),\n },\n additionalPayload: presentationToCreate.additionalPayload,\n })\n\n encodedCreatedPresentation = presentation\n createdPresentation = sdJwtVcApi.fromCompact(presentation)\n } else if (presentationToCreate.claimFormat === ClaimFormat.JwtVp) {\n const { credentialInstance } = await useInstanceFromCredentialRecord({\n agentContext,\n useMode: presentationToCreate.useMode,\n credentialRecord: presentationToCreate.credentialRecord,\n })\n\n if (!credentialInstance.credentialSubjectIds[0]) {\n throw new DcqlError('Cannot create presentation for credentials without subject id')\n }\n\n // Determine a suitable verification method for the presentation\n const verificationMethod = await this.getVerificationMethodForSubjectId(\n agentContext,\n credentialInstance.credentialSubjectIds[0]\n )\n\n const w3cCredentialService = agentContext.resolve(W3cCredentialService)\n const w3cPresentation = new W3cPresentation({\n verifiableCredential: [credentialInstance],\n holder: verificationMethod.controller,\n })\n\n const publicJwk = getPublicJwkFromVerificationMethod(verificationMethod)\n\n const signedPresentation = await w3cCredentialService.signPresentation<ClaimFormat.JwtVp>(agentContext, {\n format: ClaimFormat.JwtVp,\n alg: publicJwk.signatureAlgorithm,\n verificationMethod: verificationMethod.id,\n presentation: w3cPresentation,\n challenge,\n domain,\n })\n\n encodedCreatedPresentation = signedPresentation.encoded\n createdPresentation = signedPresentation\n } else if (presentationToCreate.claimFormat === ClaimFormat.LdpVp) {\n const { credentialInstance } = await useInstanceFromCredentialRecord({\n agentContext,\n useMode: presentationToCreate.useMode,\n credentialRecord: presentationToCreate.credentialRecord,\n })\n\n if (!credentialInstance.credentialSubjectIds[0]) {\n throw new DcqlError('Cannot create presentation for credentials without subject id')\n }\n\n // Determine a suitable verification method for the presentation\n const verificationMethod = await this.getVerificationMethodForSubjectId(\n agentContext,\n credentialInstance.credentialSubjectIds[0]\n )\n\n const w3cCredentialService = agentContext.resolve(W3cCredentialService)\n const w3cPresentation = new W3cPresentation({\n verifiableCredential: [credentialInstance],\n holder: verificationMethod.controller,\n })\n\n const signedPresentation = await w3cCredentialService.signPresentation(agentContext, {\n format: ClaimFormat.LdpVp,\n // TODO: we should move the check for which proof to use for a presentation to earlier\n // as then we know when determining which VPs to submit already if the proof types are supported\n // by the verifier, and we can then just add this to the vpToCreate interface\n proofType: this.getProofTypeForLdpVc(agentContext, verificationMethod),\n proofPurpose: new purposes.AuthenticationProofPurpose({ challenge, domain }),\n verificationMethod: verificationMethod.id,\n presentation: w3cPresentation,\n challenge,\n domain,\n })\n\n encodedCreatedPresentation = signedPresentation.encoded\n createdPresentation = signedPresentation\n } else if (presentationToCreate.claimFormat === ClaimFormat.JwtW3cVp) {\n const w3cV2CredentialService = agentContext.resolve(W3cV2CredentialService)\n const firstCredential = presentationToCreate.credentialRecord.firstCredential\n\n if (firstCredential.claimFormat === ClaimFormat.DiVc) {\n throw new DcqlError('DCQL JWT W3C VP creation does not support W3C V2 Data Integrity credentials yet')\n }\n\n const w3cV2Presentation = new W3cV2Presentation({\n holder: firstCredential.resolvedCredential.credentialSubjectIds[0],\n verifiableCredential: [W3cV2EnvelopedVerifiableCredential.fromVerifiableCredential(firstCredential)],\n })\n\n const signedPresentation = await w3cV2CredentialService.signPresentation<ClaimFormat.JwtW3cVp>(agentContext, {\n format: ClaimFormat.JwtW3cVp,\n presentation: w3cV2Presentation,\n challenge,\n domain,\n })\n\n encodedCreatedPresentation = signedPresentation.encoded\n createdPresentation = signedPresentation\n } else if (presentationToCreate.claimFormat === ClaimFormat.SdJwtW3cVp) {\n const presentationFrame = this.getPresentationFrame(\n presentationToCreate.credentialRecord.firstCredential.encoded,\n presentationToCreate\n )\n if (!domain) {\n throw new DcqlError('Missing domain property for creating SdJwtVc presentation.')\n }\n\n const w3cV2SdJwtCredentialService = agentContext.resolve(W3cV2SdJwtCredentialService)\n const sdJwtVc = await w3cV2SdJwtCredentialService.present(agentContext, {\n credential: presentationToCreate.credentialRecord.firstCredential.encoded,\n presentationFrame,\n })\n\n const w3cV2CredentialService = agentContext.resolve(W3cV2CredentialService)\n const w3cV2Presentation = new W3cV2Presentation({\n holder: presentationToCreate.credentialRecord.firstCredential.resolvedCredential.credentialSchemaIds[0],\n verifiableCredential: [W3cV2EnvelopedVerifiableCredential.fromVerifiableCredential(sdJwtVc)],\n })\n\n const signedPresentation = await w3cV2CredentialService.signPresentation<ClaimFormat.SdJwtW3cVp>(\n agentContext,\n {\n format: ClaimFormat.SdJwtW3cVp,\n presentation: w3cV2Presentation,\n challenge,\n domain,\n }\n )\n\n encodedCreatedPresentation = signedPresentation.encoded\n createdPresentation = signedPresentation\n } else {\n throw new DcqlError('Unsupported presentation format.')\n }\n\n if (!dcqlPresentation[credentialQueryId]) {\n dcqlPresentation[credentialQueryId] = [createdPresentation]\n } else {\n dcqlPresentation[credentialQueryId].push(createdPresentation)\n }\n\n if (!encodedDcqlPresentation[credentialQueryId]) {\n encodedDcqlPresentation[credentialQueryId] = [encodedCreatedPresentation]\n } else {\n encodedDcqlPresentation[credentialQueryId].push(encodedCreatedPresentation)\n }\n }\n }\n\n return {\n dcqlPresentation,\n encodedDcqlPresentation,\n }\n }\n\n private getPresentationFrame(\n compactSdJwt: string,\n { disclosedPaths, disclosedPayload }: { disclosedPaths?: ClaimPath[]; disclosedPayload?: JsonObject }\n ) {\n if (disclosedPaths) return buildPresentationFrameForPaths(compactSdJwt, disclosedPaths)\n // DisclosedPayload will be removed in future version\n if (disclosedPayload) return buildDisclosureFrameForPayload(disclosedPayload)\n\n throw new DcqlError(\n 'Either disclosedPaths or disclosedPayload is required to present a selectively disclosable credential.'\n )\n }\n\n private getSdJwtVcApi(agentContext: AgentContext) {\n return agentContext.dependencyManager.resolve(SdJwtVcApi)\n }\n\n private getMdocApi(agentContext: AgentContext) {\n return agentContext.dependencyManager.resolve(MdocApi)\n }\n\n private async getVerificationMethodForSubjectId(agentContext: AgentContext, subjectId: string) {\n const didsApi = agentContext.dependencyManager.resolve(DidsApi)\n\n if (!subjectId.startsWith('did:')) {\n throw new DcqlError(`Only dids are supported as credentialSubject id. ${subjectId} is not a valid did`)\n }\n\n const didDocument = await didsApi.resolveDidDocument(subjectId)\n\n if (!didDocument.authentication || didDocument.authentication.length === 0) {\n throw new DcqlError(`No authentication verificationMethods found for did ${subjectId} in did document`)\n }\n\n // the signature suite to use for the presentation is dependant on the credentials we share.\n // 1. Get the verification method for this given proof purpose in this DID document\n const [verificationMethod] = didDocument.findVerificationMethodsByPurpose(['authentication'])\n return verificationMethod\n }\n\n // FIXME: We need to take into account OpenID4VP metadata (probably providing supported/allowed algs to the DCQL create presentation method)\n private getProofTypeForLdpVc(agentContext: AgentContext, verificationMethod: VerificationMethod) {\n // For each of the supported algs, find the key types, then find the proof types\n const signatureSuiteRegistry = agentContext.dependencyManager.resolve(SignatureSuiteRegistry)\n\n const publicJwk = getPublicJwkFromVerificationMethod(verificationMethod)\n const supportedSignatureSuites = signatureSuiteRegistry.getAllByPublicJwkType(publicJwk)\n if (supportedSignatureSuites.length === 0) {\n throw new DcqlError(\n `Couldn't find a supported signature suite for the given jwk ${publicJwk.jwkTypeHumanDescription}`\n )\n }\n\n return supportedSignatureSuites[0].proofType\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFO,IAAM,cAAN,MAAM,YAAY;;;;;CAKvB,MAAc,6BACZ,cACA,WAC0F;EAC1F,MAAM,UAAU,IAAI,IAAI,UAAU,YAAY,KAAK,MAAM,EAAE,MAAM,CAAC;EAClE,MAAM,aAA8F,CAAC;EAErG,MAAM,eAAe,UAAU,YAC5B,QAAQ,oBAAoB,gBAAgB,WAAW,UAAU,CAAC,CAClE,KAAK,MAAM,EAAE,MAAM,aAAa;EAEnC,MAAM,UAAU,KAAK,WAAW,YAAY;EAC5C,IAAI,aAAa,OAAO,YAAY,YAAY,KAAA,CAAS,GAAG;GAC1D,MAAM,cAAc,MAAM,QAAQ,eAAe,EAC/C,KAAK,aAAa,KAAK,aAAa,EACzB,QACX,EAAE,EACJ,CAAC;GACD,WAAW,KAAK,GAAG,WAAW;EAChC,OAAO,IAAI,QAAQ,IAAI,UAAU,GAAG;GAClC,MAAM,cAAc,MAAM,QAAQ,OAAO;GACzC,WAAW,KAAK,GAAG,WAAW;EAChC;EAEA,MAAM,SAAS,UAAU,YAAY,QAClC,oBACE,gBAAgB,WAAW,eAAe,EAAE,gBAAgB,QAAQ,iBAAiB,gBAAgB,SACtG,gBAAgB,WAAW,WAC/B;EAEA,MAAM,iBAAiB,OAAO,SAAS,MAAM,EAAE,MAAM,UAAU;EAE/D,MAAM,aAAa,KAAK,cAAc,YAAY;EAClD,IAAI,eAAe,OAAO,QAAQ,QAAQ,KAAA,CAAS,GAAG;GACpD,MAAM,iBAAiB,MAAM,WAAW,eAAe,EACrD,KAAK,CAEH,GAAG,eAAe,KAAK,SAAS,EAC9B,IACF,EAAE,GAEF,GAAG,eAAe,KAAK,SAAS,EAC9B,mBAAmB,CAAC,GAAG,EACzB,EAAE,CACJ,EACF,CAAC;GACD,WAA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