@credo-ts/core 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/build/agent/TrustedIssuerContext.d.mts +11 -1
  2. package/build/agent/TrustedIssuerContext.d.mts.map +1 -1
  3. package/build/agent/TrustedIssuerContext.mjs +7 -0
  4. package/build/agent/TrustedIssuerContext.mjs.map +1 -1
  5. package/build/agent/TrustedIssuersForVerification.d.mts +11 -1
  6. package/build/agent/TrustedIssuersForVerification.d.mts.map +1 -1
  7. package/build/index.d.mts +3 -3
  8. package/build/index.mjs +2 -2
  9. package/build/modules/dcql/DcqlService.d.mts.map +1 -1
  10. package/build/modules/dcql/DcqlService.mjs +24 -12
  11. package/build/modules/dcql/DcqlService.mjs.map +1 -1
  12. package/build/modules/dids/domain/verificationMethod/JsonWebKey2020.d.mts +24 -24
  13. package/build/modules/dids/methods/jwk/DidJwk.d.mts +24 -24
  14. package/build/modules/dids/services/DidResolverService.d.mts +4 -0
  15. package/build/modules/dids/services/DidResolverService.d.mts.map +1 -1
  16. package/build/modules/dids/services/DidResolverService.mjs +21 -5
  17. package/build/modules/dids/services/DidResolverService.mjs.map +1 -1
  18. package/build/modules/kms/KeyManagementApi.d.mts +14 -14
  19. package/build/modules/kms/jwk/jwa.d.mts +1 -1
  20. package/build/modules/kms/jwk/knownJwk.d.mts +4 -4
  21. package/build/modules/kms/jwk/kty/ec/P256PublicJwk.d.mts +1 -1
  22. package/build/modules/kms/jwk/kty/ec/P384PublicJwk.d.mts +1 -1
  23. package/build/modules/kms/jwk/kty/ec/P521PublicJwk.d.mts +1 -1
  24. package/build/modules/kms/jwk/kty/ec/Secp256k1PublicJwk.d.mts +1 -1
  25. package/build/modules/kms/jwk/kty/okp/Ed25519PublicJwk.d.mts +2 -2
  26. package/build/modules/kms/jwk/kty/okp/X25519PublicJwk.d.mts +1 -1
  27. package/build/modules/kms/jwk/kty/okp/okpJwk.d.mts +2 -2
  28. package/build/modules/kms/options/KmsCreateKeyOptions.d.mts +3 -3
  29. package/build/modules/kms/options/KmsSignOptions.d.mts +1 -1
  30. package/build/modules/kms/options/KmsVerifyOptions.d.mts +2 -2
  31. package/build/modules/mdoc/repository/MdocRecord.d.mts +1 -1
  32. package/build/modules/sd-jwt-vc/repository/SdJwtVcRecord.d.mts +1 -1
  33. package/build/modules/sd-jwt-vc/utils.mjs +4 -4
  34. package/build/modules/sd-jwt-vc/utils.mjs.map +1 -1
  35. package/build/modules/vc/W3cCredentialServiceOptions.d.mts +5 -5
  36. package/build/modules/vc/W3cCredentialServiceOptions.d.mts.map +1 -1
  37. package/build/modules/vc/W3cV2CredentialService.d.mts +5 -1
  38. package/build/modules/vc/W3cV2CredentialService.d.mts.map +1 -1
  39. package/build/modules/vc/W3cV2CredentialService.mjs +72 -26
  40. package/build/modules/vc/W3cV2CredentialService.mjs.map +1 -1
  41. package/build/modules/vc/W3cV2CredentialServiceOptions.d.mts +14 -6
  42. package/build/modules/vc/W3cV2CredentialServiceOptions.d.mts.map +1 -1
  43. package/build/modules/vc/data-integrity/W3cV2DataIntegrityCredentialService.d.mts +0 -18
  44. package/build/modules/vc/data-integrity/W3cV2DataIntegrityCredentialService.d.mts.map +1 -1
  45. package/build/modules/vc/data-integrity/W3cV2DataIntegrityCredentialService.mjs +38 -36
  46. package/build/modules/vc/data-integrity/W3cV2DataIntegrityCredentialService.mjs.map +1 -1
  47. package/build/modules/vc/data-integrity/v2-di-utils.mjs +17 -35
  48. package/build/modules/vc/data-integrity/v2-di-utils.mjs.map +1 -1
  49. package/build/modules/vc/jwt-vc/W3cJwtCredentialService.d.mts +0 -23
  50. package/build/modules/vc/jwt-vc/W3cJwtCredentialService.d.mts.map +1 -1
  51. package/build/modules/vc/jwt-vc/W3cJwtCredentialService.mjs +17 -68
  52. package/build/modules/vc/jwt-vc/W3cJwtCredentialService.mjs.map +1 -1
  53. package/build/modules/vc/jwt-vc/W3cV2JwtCredentialService.d.mts.map +1 -1
  54. package/build/modules/vc/jwt-vc/W3cV2JwtCredentialService.mjs +11 -17
  55. package/build/modules/vc/jwt-vc/W3cV2JwtCredentialService.mjs.map +1 -1
  56. package/build/modules/vc/linked-data-proofs/W3cJsonLdCredentialService.d.mts +5 -0
  57. package/build/modules/vc/linked-data-proofs/W3cJsonLdCredentialService.d.mts.map +1 -1
  58. package/build/modules/vc/linked-data-proofs/W3cJsonLdCredentialService.mjs +18 -4
  59. package/build/modules/vc/linked-data-proofs/W3cJsonLdCredentialService.mjs.map +1 -1
  60. package/build/modules/vc/models/W3cV2VerifyResult.d.mts +6 -0
  61. package/build/modules/vc/models/W3cV2VerifyResult.d.mts.map +1 -1
  62. package/build/modules/vc/resolveSigner.mjs +74 -0
  63. package/build/modules/vc/resolveSigner.mjs.map +1 -0
  64. package/build/modules/vc/sd-jwt-vc/W3cV2SdJwtCredentialService.d.mts.map +1 -1
  65. package/build/modules/vc/sd-jwt-vc/W3cV2SdJwtCredentialService.mjs +16 -18
  66. package/build/modules/vc/sd-jwt-vc/W3cV2SdJwtCredentialService.mjs.map +1 -1
  67. package/build/modules/vc/sd-jwt-vc/disclosureFrame.d.mts +1 -1
  68. package/build/modules/vc/sd-jwt-vc/disclosureFrame.d.mts.map +1 -1
  69. package/build/modules/vc/sd-jwt-vc/disclosureFrame.mjs +2 -1
  70. package/build/modules/vc/sd-jwt-vc/disclosureFrame.mjs.map +1 -1
  71. package/build/modules/vc/v2-jwt-utils.mjs +54 -55
  72. package/build/modules/vc/v2-jwt-utils.mjs.map +1 -1
  73. package/build/modules/x509/X509ModuleConfig.d.mts +5 -13
  74. package/build/modules/x509/X509ModuleConfig.d.mts.map +1 -1
  75. package/build/modules/x509/X509ModuleConfig.mjs +2 -1
  76. package/build/modules/x509/X509ModuleConfig.mjs.map +1 -1
  77. package/build/modules/x509/X509RevocationService.d.mts.map +1 -1
  78. package/build/modules/x509/X509RevocationService.mjs +17 -20
  79. package/build/modules/x509/X509RevocationService.mjs.map +1 -1
  80. package/build/modules/x509/X509Service.mjs +1 -1
  81. package/build/modules/x509/X509Service.mjs.map +1 -1
  82. package/build/modules/x509/X509ServiceOptions.d.mts +4 -6
  83. package/build/modules/x509/X509ServiceOptions.d.mts.map +1 -1
  84. package/build/modules/x509/X509ValidationOptions.d.mts +19 -2
  85. package/build/modules/x509/X509ValidationOptions.d.mts.map +1 -1
  86. package/build/modules/x509/X509ValidationOptions.mjs +21 -1
  87. package/build/modules/x509/X509ValidationOptions.mjs.map +1 -1
  88. package/build/modules/x509/index.d.mts +2 -2
  89. package/build/modules/x509/index.mjs +2 -2
  90. package/build/modules/x509/utils/crlFetcher.mjs +1 -11
  91. package/build/modules/x509/utils/crlFetcher.mjs.map +1 -1
  92. package/package.json +1 -1
@@ -1 +1 @@
1
- {"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,EA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;EAGxG,MAAM,cAAc,MAAM,QAAQ,mBAAmB,SAAS;EAE9D,IAAI,CAAC,YAAY,kBAAkB,YAAY,eAAe,WAAW,GACvE,MAAM,IAAI,UAAU,uDAAuD,UAAU,iBAAiB;EAKxG,MAAM,CAAC,sBAAsB,YAAY,iCAAiC,CAAC,gBAAgB,CAAC;EAC5F,OAAO;CACT;CAGA,qBAA6B,cAA4B,oBAAwC;EAE/F,MAAM,yBAAyB,aAAa,kBAAkB,QAAQ,sBAAsB;EAE5F,MAAM,YAAY,mCAAmC,kBAAkB;EACvE,MAAM,2BAA2B,uBAAuB,sBAAsB,SAAS;EACvF,IAAI,yBAAyB,WAAW,GACtC,MAAM,IAAI,UACR,+DAA+D,UAAU,yBAC3E;EAGF,OAAO,yBAAyB,EAAE,CAAC;CACrC;AACF;AA/9BC,cAAA,WAAA,CAAA,WAAW,CAAA,GAAA,WAAA"}
1
+ {"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 W3cV2JwtVerifiableCredential,\n W3cV2Presentation,\n type W3cV2VerifiableCredential,\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: presentation.kbJwt !== undefined,\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: hasHolderBinding(undefined, vc.credentialSubjectIds),\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: hasHolderBinding(undefined, vc.credentialSubjectIds),\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: hasW3cV2HolderBinding(firstEntry.envelopedCredential),\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: sdJwtVc.holder !== undefined,\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: sdJwtVc.holder !== undefined,\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: sdJwtVc.holder !== undefined,\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: sdJwtVc.holder !== undefined,\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: hasHolderBinding(undefined, firstCredential.credentialSubjectIds),\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: hasHolderBinding(undefined, firstCredential.credentialSubjectIds),\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: hasW3cV2HolderBinding(firstCredential),\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.credentialSubjectIds[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\n/**\n * A credential is bound to its holder through a key (`cnf`) or its subject. Verifying a presentation\n * checks that the presenter proves the binding. A subject id that is not a DID also counts, so such\n * a credential can't be presented.\n */\nfunction hasHolderBinding(cnf: unknown, credentialSubjectIds: string[]) {\n return cnf !== undefined || credentialSubjectIds.length > 0\n}\n\nfunction hasW3cV2HolderBinding(credential: W3cV2VerifiableCredential) {\n const cnf =\n credential instanceof W3cV2SdJwtVerifiableCredential\n ? credential.sdJwt.prettyClaims.cnf\n : credential instanceof W3cV2JwtVerifiableCredential\n ? credential.jwt.payload.additionalClaims.cnf\n : undefined\n\n return hasHolderBinding(cnf, credential.resolvedCredential.credentialSubjectIds)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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BAAsB,YAAY,iCAAiC,CAAC,gBAAgB,CAAC;EAC5F,OAAO;CACT;CAGA,qBAA6B,cAA4B,oBAAwC;EAE/F,MAAM,yBAAyB,aAAa,kBAAkB,QAAQ,sBAAsB;EAE5F,MAAM,YAAY,mCAAmC,kBAAkB;EACvE,MAAM,2BAA2B,uBAAuB,sBAAsB,SAAS;EACvF,IAAI,yBAAyB,WAAW,GACtC,MAAM,IAAI,UACR,+DAA+D,UAAU,yBAC3E;EAGF,OAAO,yBAAyB,EAAE,CAAC;CACrC;AACF;AA/9BC,cAAA,WAAA,CAAA,WAAW,CAAA,GAAA,WAAA;;;;;;AAs+BZ,SAAS,iBAAiB,KAAc,sBAAgC;CACtE,OAAO,QAAQ,KAAA,KAAa,qBAAqB,SAAS;AAC5D;AAEA,SAAS,sBAAsB,YAAuC;CAQpE,OAAO,iBANL,sBAAsB,iCAClB,WAAW,MAAM,aAAa,MAC9B,sBAAsB,+BACpB,WAAW,IAAI,QAAQ,iBAAiB,MACxC,KAAA,GAEqB,WAAW,mBAAmB,oBAAoB;AACjF"}
@@ -15,27 +15,7 @@ export declare function getJsonWebKey2020(options: GetJsonWebKey2020Options): {
15
15
  id: string;
16
16
  type: string;
17
17
  controller: string;
18
- publicKeyJwk: {
19
- kty: "RSA";
20
- n: string;
21
- e: string;
22
- d?: undefined;
23
- p?: undefined;
24
- q?: undefined;
25
- dp?: undefined;
26
- dq?: undefined;
27
- qi?: undefined;
28
- oth?: undefined;
29
- kid?: string | undefined;
30
- alg?: string | undefined;
31
- key_ops?: string[] | undefined;
32
- use?: string | undefined;
33
- ext?: boolean | undefined;
34
- x5c?: string[] | undefined;
35
- x5t?: string | undefined;
36
- 'x5t#S256'?: string | undefined;
37
- x5u?: string | undefined;
38
- } | ({
18
+ publicKeyJwk: ({
39
19
  kty: "EC";
40
20
  crv: "P-256" | "P-384" | "P-521" | "secp256k1";
41
21
  x: string;
@@ -105,7 +85,7 @@ export declare function getJsonWebKey2020(options: GetJsonWebKey2020Options): {
105
85
  crv: "secp256k1";
106
86
  }) | ({
107
87
  kty: "OKP";
108
- crv: "Ed25519" | "X25519";
88
+ crv: "X25519" | "Ed25519";
109
89
  x: string;
110
90
  d?: string | undefined;
111
91
  kid?: string | undefined;
@@ -119,9 +99,29 @@ export declare function getJsonWebKey2020(options: GetJsonWebKey2020Options): {
119
99
  x5u?: string | undefined;
120
100
  } & {
121
101
  crv: "Ed25519";
122
- }) | ({
102
+ }) | {
103
+ kty: "RSA";
104
+ n: string;
105
+ e: string;
106
+ d?: undefined;
107
+ p?: undefined;
108
+ q?: undefined;
109
+ dp?: undefined;
110
+ dq?: undefined;
111
+ qi?: undefined;
112
+ oth?: undefined;
113
+ kid?: string | undefined;
114
+ alg?: string | undefined;
115
+ key_ops?: string[] | undefined;
116
+ use?: string | undefined;
117
+ ext?: boolean | undefined;
118
+ x5c?: string[] | undefined;
119
+ x5t?: string | undefined;
120
+ 'x5t#S256'?: string | undefined;
121
+ x5u?: string | undefined;
122
+ } | ({
123
123
  kty: "OKP";
124
- crv: "Ed25519" | "X25519";
124
+ crv: "X25519" | "Ed25519";
125
125
  x: string;
126
126
  d?: string | undefined;
127
127
  kid?: string | undefined;
@@ -16,27 +16,7 @@ export declare class DidJwk {
16
16
  */
17
17
  get verificationMethodId(): string;
18
18
  static fromPublicJwk(publicJwk: PublicJwk): DidJwk;
19
- get jwkJson(): {
20
- kty: "RSA";
21
- n: string;
22
- e: string;
23
- d?: undefined;
24
- p?: undefined;
25
- q?: undefined;
26
- dp?: undefined;
27
- dq?: undefined;
28
- qi?: undefined;
29
- oth?: undefined;
30
- kid?: string | undefined;
31
- alg?: string | undefined;
32
- key_ops?: string[] | undefined;
33
- use?: string | undefined;
34
- ext?: boolean | undefined;
35
- x5c?: string[] | undefined;
36
- x5t?: string | undefined;
37
- 'x5t#S256'?: string | undefined;
38
- x5u?: string | undefined;
39
- } | ({
19
+ get jwkJson(): ({
40
20
  kty: "EC";
41
21
  crv: "P-256" | "P-384" | "P-521" | "secp256k1";
42
22
  x: string;
@@ -106,7 +86,7 @@ export declare class DidJwk {
106
86
  crv: "secp256k1";
107
87
  }) | ({
108
88
  kty: "OKP";
109
- crv: "Ed25519" | "X25519";
89
+ crv: "X25519" | "Ed25519";
110
90
  x: string;
111
91
  d?: string | undefined;
112
92
  kid?: string | undefined;
@@ -120,9 +100,29 @@ export declare class DidJwk {
120
100
  x5u?: string | undefined;
121
101
  } & {
122
102
  crv: "Ed25519";
123
- }) | ({
103
+ }) | {
104
+ kty: "RSA";
105
+ n: string;
106
+ e: string;
107
+ d?: undefined;
108
+ p?: undefined;
109
+ q?: undefined;
110
+ dp?: undefined;
111
+ dq?: undefined;
112
+ qi?: undefined;
113
+ oth?: undefined;
114
+ kid?: string | undefined;
115
+ alg?: string | undefined;
116
+ key_ops?: string[] | undefined;
117
+ use?: string | undefined;
118
+ ext?: boolean | undefined;
119
+ x5c?: string[] | undefined;
120
+ x5t?: string | undefined;
121
+ 'x5t#S256'?: string | undefined;
122
+ x5u?: string | undefined;
123
+ } | ({
124
124
  kty: "OKP";
125
- crv: "Ed25519" | "X25519";
125
+ crv: "X25519" | "Ed25519";
126
126
  x: string;
127
127
  d?: string | undefined;
128
128
  kid?: string | undefined;
@@ -20,6 +20,10 @@ export declare class DidResolverService {
20
20
  */
21
21
  resolveDidDocument(agentContext: AgentContext, did: string): Promise<DidDocument>;
22
22
  invalidateCacheForDid(agentContext: AgentContext, did: string): Promise<void>;
23
+ /**
24
+ * A short form did:peer:4 resolves to the document of its long form, which is bound to it by hash.
25
+ */
26
+ private ensureDidDocumentIdMatchesDid;
23
27
  private getCacheKeyAndScope;
24
28
  private findResolver;
25
29
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DidResolverService.d.mts","names":[],"sources":["../../../../src/modules/dids/services/DidResolverService.ts"],"mappings":";;;;;;;;;;qBAea;UACH;UACA;UACA;EAG2B,YAAA,QAAQ,QACzC,kBAAkB,kBAClB,eAAe;EAOJ,QACX,cAAc,cACd,gBACA,UAAS,uBACR,QAAQ;;;;;EAiHE,mBAAmB,cAAc,cAAc,cAAW,QAAA;EAY1D,sBAAsB,cAAc,cAAc,cAAW;UAelE;UAOA;;;;MAOG"}
1
+ {"version":3,"file":"DidResolverService.d.mts","names":[],"sources":["../../../../src/modules/dids/services/DidResolverService.ts"],"mappings":";;;;;;;;;;qBAgBa;UACH;UACA;UACA;EAG2B,YAAA,QAAQ,QACzC,kBAAkB,kBAClB,eAAe;EAOJ,QACX,cAAc,cACd,gBACA,UAAS,uBACR,QAAQ;;;;;EAoHE,mBAAmB,cAAc,cAAc,cAAW,QAAA;EAY1D,sBAAsB,cAAc,cAAc,cAAW;;;;UAkBlE;UAcA;UAOA;;;;MAOG"}
@@ -14,6 +14,7 @@ import { DidDocument } from "../domain/DidDocument.mjs";
14
14
  import "../domain/index.mjs";
15
15
  import { DidRepository } from "../repository/DidRepository.mjs";
16
16
  import "../repository/index.mjs";
17
+ import { getAlternativeDidsForNumAlgo4Did } from "../methods/peer/peerDidNumAlgo4.mjs";
17
18
  import { DidsModuleConfig } from "../DidsModuleConfig.mjs";
18
19
  //#region src/modules/dids/services/DidResolverService.ts
19
20
  let DidResolverService = class DidResolverService {
@@ -50,27 +51,27 @@ let DidResolverService = class DidResolverService {
50
51
  const { cacheKey, cacheScope } = this.getCacheKeyAndScope(parsed);
51
52
  if (resolver.allowsCaching && useCache) {
52
53
  const cachedDidDocument = await agentContext.dependencyManager.resolve(CacheModuleConfig).cache.get(agentContext, cacheKey, { scope: cacheScope });
53
- if (cachedDidDocument) return {
54
+ if (cachedDidDocument) return this.ensureDidDocumentIdMatchesDid(parsed, {
54
55
  ...cachedDidDocument,
55
56
  didDocument: JsonTransformer.fromJSON(cachedDidDocument.didDocument, DidDocument),
56
57
  didResolutionMetadata: {
57
58
  ...cachedDidDocument.didResolutionMetadata,
58
59
  servedFromCache: true
59
60
  }
60
- };
61
+ });
61
62
  }
62
63
  if (resolver.allowsLocalDidRecord && useLocalCreatedDidRecord) {
63
64
  const [didRecord] = await this.didRepository.getCreatedDids(agentContext, { did: parsed.did });
64
- if (didRecord?.didDocument) return {
65
+ if (didRecord?.didDocument) return this.ensureDidDocumentIdMatchesDid(parsed, {
65
66
  didDocument: didRecord.didDocument,
66
67
  didDocumentMetadata: {},
67
68
  didResolutionMetadata: {
68
69
  servedFromCache: false,
69
70
  servedFromDidRecord: true
70
71
  }
71
- };
72
+ });
72
73
  }
73
- let resolutionResult = await resolver.resolve(agentContext, parsed.did, parsed, options);
74
+ let resolutionResult = this.ensureDidDocumentIdMatchesDid(parsed, await resolver.resolve(agentContext, parsed.did, parsed, options));
74
75
  resolutionResult = {
75
76
  ...resolutionResult,
76
77
  didResolutionMetadata: {
@@ -105,6 +106,21 @@ let DidResolverService = class DidResolverService {
105
106
  const { cacheKey, cacheScope } = this.getCacheKeyAndScope(parsed);
106
107
  await cache.remove(agentContext, cacheKey, { scope: cacheScope });
107
108
  }
109
+ /**
110
+ * A short form did:peer:4 resolves to the document of its long form, which is bound to it by hash.
111
+ */
112
+ ensureDidDocumentIdMatchesDid(parsed, result) {
113
+ const id = result.didDocument?.id;
114
+ if (!id || id === parsed.did || getAlternativeDidsForNumAlgo4Did(id)?.includes(parsed.did)) return result;
115
+ return {
116
+ didDocument: null,
117
+ didDocumentMetadata: {},
118
+ didResolutionMetadata: {
119
+ error: "invalidDidDocument",
120
+ message: `DID document id '${id}' does not match the resolved did '${parsed.did}'`
121
+ }
122
+ };
123
+ }
108
124
  getCacheKeyAndScope(parsed) {
109
125
  return {
110
126
  cacheKey: `did:resolver:${parsed.did}`,
@@ -1 +1 @@
1
- {"version":3,"file":"DidResolverService.mjs","names":[],"sources":["../../../../src/modules/dids/services/DidResolverService.ts"],"sourcesContent":["import type { AgentContext } from '../../../agent'\nimport { InjectionSymbols } from '../../../constants'\nimport { CredoError } from '../../../error'\nimport type { Logger } from '../../../logger'\nimport { inject, injectable } from '../../../plugins'\nimport { JsonTransformer } from '../../../utils'\nimport { CacheModuleConfig } from '../../cache'\nimport { DidsModuleConfig } from '../DidsModuleConfig'\nimport { DidDocument } from '../domain'\nimport type { DidResolver } from '../domain/DidResolver'\nimport { parseDid } from '../domain/parse'\nimport { DidRepository } from '../repository'\nimport type { DidResolutionOptions, DidResolutionResult, ParsedDid } from '../types'\n\n@injectable()\nexport class DidResolverService {\n private logger: Logger\n private didsModuleConfig: DidsModuleConfig\n private didRepository: DidRepository\n\n public constructor(\n @inject(InjectionSymbols.Logger) logger: Logger,\n didsModuleConfig: DidsModuleConfig,\n didRepository: DidRepository\n ) {\n this.logger = logger\n this.didsModuleConfig = didsModuleConfig\n this.didRepository = didRepository\n }\n\n public async resolve(\n agentContext: AgentContext,\n didUrl: string,\n options: DidResolutionOptions = {}\n ): Promise<DidResolutionResult> {\n this.logger.debug(`resolving didUrl ${didUrl}`)\n\n const result = {\n didResolutionMetadata: {},\n didDocument: null,\n didDocumentMetadata: {},\n }\n\n let parsed: ParsedDid\n try {\n parsed = parseDid(didUrl)\n } catch (_error) {\n return {\n ...result,\n didResolutionMetadata: { error: 'invalidDid' },\n }\n }\n\n const resolver = this.findResolver(parsed)\n if (!resolver) {\n return {\n ...result,\n didResolutionMetadata: {\n error: 'unsupportedDidMethod',\n message: `No did resolver registered for did method ${parsed.method}`,\n },\n }\n }\n\n // extract caching options and set defaults\n const {\n useCache = true,\n cacheDurationInSeconds = 300,\n persistInCache = true,\n useLocalCreatedDidRecord = true,\n } = options\n const { cacheKey, cacheScope } = this.getCacheKeyAndScope(parsed)\n\n if (resolver.allowsCaching && useCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n const cachedDidDocument = await cache.get<DidResolutionResult & { didDocument: Record<string, unknown> }>(\n agentContext,\n cacheKey,\n { scope: cacheScope }\n )\n\n if (cachedDidDocument) {\n return {\n ...cachedDidDocument,\n didDocument: JsonTransformer.fromJSON(cachedDidDocument.didDocument, DidDocument),\n didResolutionMetadata: {\n ...cachedDidDocument.didResolutionMetadata,\n servedFromCache: true,\n },\n }\n }\n }\n\n // TODO: we should store the document for future reference\n if (resolver.allowsLocalDidRecord && useLocalCreatedDidRecord) {\n // TODO: did should have tag whether a did document is present in the did record\n const [didRecord] = await this.didRepository.getCreatedDids(agentContext, {\n did: parsed.did,\n })\n\n if (didRecord?.didDocument) {\n return {\n didDocument: didRecord.didDocument,\n didDocumentMetadata: {},\n didResolutionMetadata: {\n servedFromCache: false,\n servedFromDidRecord: true,\n },\n }\n }\n }\n\n let resolutionResult = await resolver.resolve(agentContext, parsed.did, parsed, options)\n // Avoid overwriting existing document\n resolutionResult = {\n ...resolutionResult,\n didResolutionMetadata: {\n ...resolutionResult.didResolutionMetadata,\n resolutionTime: Date.now(),\n // Did resolver implementation might use did method specific caching strategy\n // We only set to false if not defined by the resolver\n servedFromCache: resolutionResult.didResolutionMetadata.servedFromCache ?? false,\n },\n }\n\n if (resolutionResult.didDocument && resolver.allowsCaching && persistInCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n await cache.set(\n agentContext,\n cacheKey,\n {\n ...resolutionResult,\n didDocument: resolutionResult.didDocument.toJSON(),\n },\n // Set cache duration\n cacheDurationInSeconds,\n { scope: cacheScope }\n )\n }\n\n return resolutionResult\n }\n\n /**\n * Resolve a did document. This uses the default resolution options, and thus\n * will use caching if available.\n */\n public async resolveDidDocument(agentContext: AgentContext, did: string) {\n const {\n didDocument,\n didResolutionMetadata: { error, message },\n } = await this.resolve(agentContext, did)\n\n if (!didDocument) {\n throw new CredoError(`Unable to resolve did document for did '${did}': ${error} ${message}`)\n }\n return didDocument\n }\n\n public async invalidateCacheForDid(agentContext: AgentContext, did: string) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n\n let parsed: ParsedDid\n try {\n parsed = parseDid(did)\n } catch (_error) {\n // If the did is invalid, there is no cache to invalidate, so we can just return\n return\n }\n\n const { cacheKey, cacheScope } = this.getCacheKeyAndScope(parsed)\n await cache.remove(agentContext, cacheKey, { scope: cacheScope })\n }\n\n private getCacheKeyAndScope(parsed: ParsedDid): { cacheKey: string; cacheScope: 'context' | 'global' } {\n return {\n cacheKey: `did:resolver:${parsed.did}`,\n cacheScope: this.didsModuleConfig.publicDidMethods.includes(parsed.method) ? 'global' : 'context',\n }\n }\n\n private findResolver(parsed: ParsedDid): DidResolver | null {\n return this.didsModuleConfig.resolvers.find((r) => r.supportedMethods.includes(parsed.method)) ?? null\n }\n\n /**\n * Get all supported did methods for the did resolver.\n */\n public get supportedMethods() {\n return Array.from(new Set(this.didsModuleConfig.resolvers.flatMap((r) => r.supportedMethods)))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeO,IAAM,qBAAN,MAAM,mBAAmB;CAK9B,YACE,QACA,kBACA,eACA;EACA,KAAK,SAAS;EACd,KAAK,mBAAmB;EACxB,KAAK,gBAAgB;CACvB;CAEA,MAAa,QACX,cACA,QACA,UAAgC,CAAC,GACH;EAC9B,KAAK,OAAO,MAAM,oBAAoB,QAAQ;EAE9C,MAAM,SAAS;GACb,uBAAuB,CAAC;GACxB,aAAa;GACb,qBAAqB,CAAC;EACxB;EAEA,IAAI;EACJ,IAAI;GACF,SAAS,SAAS,MAAM;EAC1B,SAAS,QAAQ;GACf,OAAO;IACL,GAAG;IACH,uBAAuB,EAAE,OAAO,aAAa;GAC/C;EACF;EAEA,MAAM,WAAW,KAAK,aAAa,MAAM;EACzC,IAAI,CAAC,UACH,OAAO;GACL,GAAG;GACH,uBAAuB;IACrB,OAAO;IACP,SAAS,6CAA6C,OAAO;GAC/D;EACF;EAIF,MAAM,EACJ,WAAW,MACX,yBAAyB,KACzB,iBAAiB,MACjB,2BAA2B,SACzB;EACJ,MAAM,EAAE,UAAU,eAAe,KAAK,oBAAoB,MAAM;EAEhE,IAAI,SAAS,iBAAiB,UAAU;GAEtC,MAAM,oBAAoB,MADZ,aAAa,kBAAkB,QAAQ,iBAAiB,CAAC,CAAC,MAClC,IACpC,cACA,UACA,EAAE,OAAO,WAAW,CACtB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E,UAAU,eAAe,KAAK,oBAAoB,MAAM;EAChE,MAAM,MAAM,OAAO,cAAc,UAAU,EAAE,OAAO,WAAW,CAAC;CAClE;CAEA,oBAA4B,QAA2E;EACrG,OAAO;GACL,UAAU,gBAAgB,OAAO;GACjC,YAAY,KAAK,iBAAiB,iBAAiB,SAAS,OAAO,MAAM,IAAI,WAAW;EAC1F;CACF;CAEA,aAAqB,QAAuC;EAC1D,OAAO,KAAK,iBAAiB,UAAU,MAAM,MAAM,EAAE,iBAAiB,SAAS,OAAO,MAAM,CAAC,KAAK;CACpG;;;;CAKA,IAAW,mBAAmB;EAC5B,OAAO,MAAM,KAAK,IAAI,IAAI,KAAK,iBAAiB,UAAU,SAAS,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC/F;AACF;;CAjLC,WAAW;CAOP,gBAAA,GAAA,OAAO,iBAAiB,MAAM,CAAA"}
1
+ {"version":3,"file":"DidResolverService.mjs","names":[],"sources":["../../../../src/modules/dids/services/DidResolverService.ts"],"sourcesContent":["import type { AgentContext } from '../../../agent'\nimport { InjectionSymbols } from '../../../constants'\nimport { CredoError } from '../../../error'\nimport type { Logger } from '../../../logger'\nimport { inject, injectable } from '../../../plugins'\nimport { JsonTransformer } from '../../../utils'\nimport { CacheModuleConfig } from '../../cache'\nimport { DidsModuleConfig } from '../DidsModuleConfig'\nimport { DidDocument } from '../domain'\nimport type { DidResolver } from '../domain/DidResolver'\nimport { parseDid } from '../domain/parse'\nimport { getAlternativeDidsForNumAlgo4Did } from '../methods/peer/peerDidNumAlgo4'\nimport { DidRepository } from '../repository'\nimport type { DidResolutionOptions, DidResolutionResult, ParsedDid } from '../types'\n\n@injectable()\nexport class DidResolverService {\n private logger: Logger\n private didsModuleConfig: DidsModuleConfig\n private didRepository: DidRepository\n\n public constructor(\n @inject(InjectionSymbols.Logger) logger: Logger,\n didsModuleConfig: DidsModuleConfig,\n didRepository: DidRepository\n ) {\n this.logger = logger\n this.didsModuleConfig = didsModuleConfig\n this.didRepository = didRepository\n }\n\n public async resolve(\n agentContext: AgentContext,\n didUrl: string,\n options: DidResolutionOptions = {}\n ): Promise<DidResolutionResult> {\n this.logger.debug(`resolving didUrl ${didUrl}`)\n\n const result = {\n didResolutionMetadata: {},\n didDocument: null,\n didDocumentMetadata: {},\n }\n\n let parsed: ParsedDid\n try {\n parsed = parseDid(didUrl)\n } catch (_error) {\n return {\n ...result,\n didResolutionMetadata: { error: 'invalidDid' },\n }\n }\n\n const resolver = this.findResolver(parsed)\n if (!resolver) {\n return {\n ...result,\n didResolutionMetadata: {\n error: 'unsupportedDidMethod',\n message: `No did resolver registered for did method ${parsed.method}`,\n },\n }\n }\n\n // extract caching options and set defaults\n const {\n useCache = true,\n cacheDurationInSeconds = 300,\n persistInCache = true,\n useLocalCreatedDidRecord = true,\n } = options\n const { cacheKey, cacheScope } = this.getCacheKeyAndScope(parsed)\n\n if (resolver.allowsCaching && useCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n const cachedDidDocument = await cache.get<DidResolutionResult & { didDocument: Record<string, unknown> }>(\n agentContext,\n cacheKey,\n { scope: cacheScope }\n )\n\n if (cachedDidDocument) {\n return this.ensureDidDocumentIdMatchesDid(parsed, {\n ...cachedDidDocument,\n didDocument: JsonTransformer.fromJSON(cachedDidDocument.didDocument, DidDocument),\n didResolutionMetadata: {\n ...cachedDidDocument.didResolutionMetadata,\n servedFromCache: true,\n },\n })\n }\n }\n\n // TODO: we should store the document for future reference\n if (resolver.allowsLocalDidRecord && useLocalCreatedDidRecord) {\n // TODO: did should have tag whether a did document is present in the did record\n const [didRecord] = await this.didRepository.getCreatedDids(agentContext, {\n did: parsed.did,\n })\n\n if (didRecord?.didDocument) {\n return this.ensureDidDocumentIdMatchesDid(parsed, {\n didDocument: didRecord.didDocument,\n didDocumentMetadata: {},\n didResolutionMetadata: {\n servedFromCache: false,\n servedFromDidRecord: true,\n },\n })\n }\n }\n\n let resolutionResult = this.ensureDidDocumentIdMatchesDid(\n parsed,\n await resolver.resolve(agentContext, parsed.did, parsed, options)\n )\n // Avoid overwriting existing document\n resolutionResult = {\n ...resolutionResult,\n didResolutionMetadata: {\n ...resolutionResult.didResolutionMetadata,\n resolutionTime: Date.now(),\n // Did resolver implementation might use did method specific caching strategy\n // We only set to false if not defined by the resolver\n servedFromCache: resolutionResult.didResolutionMetadata.servedFromCache ?? false,\n },\n }\n\n if (resolutionResult.didDocument && resolver.allowsCaching && persistInCache) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n await cache.set(\n agentContext,\n cacheKey,\n {\n ...resolutionResult,\n didDocument: resolutionResult.didDocument.toJSON(),\n },\n // Set cache duration\n cacheDurationInSeconds,\n { scope: cacheScope }\n )\n }\n\n return resolutionResult\n }\n\n /**\n * Resolve a did document. This uses the default resolution options, and thus\n * will use caching if available.\n */\n public async resolveDidDocument(agentContext: AgentContext, did: string) {\n const {\n didDocument,\n didResolutionMetadata: { error, message },\n } = await this.resolve(agentContext, did)\n\n if (!didDocument) {\n throw new CredoError(`Unable to resolve did document for did '${did}': ${error} ${message}`)\n }\n return didDocument\n }\n\n public async invalidateCacheForDid(agentContext: AgentContext, did: string) {\n const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache\n\n let parsed: ParsedDid\n try {\n parsed = parseDid(did)\n } catch (_error) {\n // If the did is invalid, there is no cache to invalidate, so we can just return\n return\n }\n\n const { cacheKey, cacheScope } = this.getCacheKeyAndScope(parsed)\n await cache.remove(agentContext, cacheKey, { scope: cacheScope })\n }\n\n /**\n * A short form did:peer:4 resolves to the document of its long form, which is bound to it by hash.\n */\n private ensureDidDocumentIdMatchesDid(parsed: ParsedDid, result: DidResolutionResult): DidResolutionResult {\n const id = result.didDocument?.id\n if (!id || id === parsed.did || getAlternativeDidsForNumAlgo4Did(id)?.includes(parsed.did)) return result\n\n return {\n didDocument: null,\n didDocumentMetadata: {},\n didResolutionMetadata: {\n error: 'invalidDidDocument',\n message: `DID document id '${id}' does not match the resolved did '${parsed.did}'`,\n },\n }\n }\n\n private getCacheKeyAndScope(parsed: ParsedDid): { cacheKey: string; cacheScope: 'context' | 'global' } {\n return {\n cacheKey: `did:resolver:${parsed.did}`,\n cacheScope: this.didsModuleConfig.publicDidMethods.includes(parsed.method) ? 'global' : 'context',\n }\n }\n\n private findResolver(parsed: ParsedDid): DidResolver | null {\n return this.didsModuleConfig.resolvers.find((r) => r.supportedMethods.includes(parsed.method)) ?? null\n }\n\n /**\n * Get all supported did methods for the did resolver.\n */\n public get supportedMethods() {\n return Array.from(new Set(this.didsModuleConfig.resolvers.flatMap((r) => r.supportedMethods)))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBO,IAAM,qBAAN,MAAM,mBAAmB;CAK9B,YACE,QACA,kBACA,eACA;EACA,KAAK,SAAS;EACd,KAAK,mBAAmB;EACxB,KAAK,gBAAgB;CACvB;CAEA,MAAa,QACX,cACA,QACA,UAAgC,CAAC,GACH;EAC9B,KAAK,OAAO,MAAM,oBAAoB,QAAQ;EAE9C,MAAM,SAAS;GACb,uBAAuB,CAAC;GACxB,aAAa;GACb,qBAAqB,CAAC;EACxB;EAEA,IAAI;EACJ,IAAI;GACF,SAAS,SAAS,MAAM;EAC1B,SAAS,QAAQ;GACf,OAAO;IACL,GAAG;IACH,uBAAuB,EAAE,OAAO,aAAa;GAC/C;EACF;EAEA,MAAM,WAAW,KAAK,aAAa,MAAM;EACzC,IAAI,CAAC,UACH,OAAO;GACL,GAAG;GACH,uBAAuB;IACrB,OAAO;IACP,SAAS,6CAA6C,OAAO;GAC/D;EACF;EAIF,MAAM,EACJ,WAAW,MACX,yBAAyB,KACzB,iBAAiB,MACjB,2BAA2B,SACzB;EACJ,MAAM,EAAE,UAAU,eAAe,KAAK,oBAAoB,MAAM;EAEhE,IAAI,SAAS,iBAAiB,UAAU;GAEtC,MAAM,oBAAoB,MADZ,aAAa,kBAAkB,QAAQ,iBAAiB,CAAC,CAAC,MAClC,IACpC,cACA,UACA,EAAE,O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C;EAExE,IAAI;EACJ,IAAI;GACF,SAAS,SAAS,GAAG;EACvB,SAAS,QAAQ;GAEf;EACF;EAEA,MAAM,EAAE,UAAU,eAAe,KAAK,oBAAoB,MAAM;EAChE,MAAM,MAAM,OAAO,cAAc,UAAU,EAAE,OAAO,WAAW,CAAC;CAClE;;;;CAKA,8BAAsC,QAAmB,QAAkD;EACzG,MAAM,KAAK,OAAO,aAAa;EAC/B,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO,iCAAiC,EAAE,CAAC,EAAE,SAAS,OAAO,GAAG,GAAG,OAAO;EAEnG,OAAO;GACL,aAAa;GACb,qBAAqB,CAAC;GACtB,uBAAuB;IACrB,OAAO;IACP,SAAS,oBAAoB,GAAG,qCAAqC,OAAO,IAAI;GAClF;EACF;CACF;CAEA,oBAA4B,QAA2E;EACrG,OAAO;GACL,UAAU,gBAAgB,OAAO;GACjC,YAAY,KAAK,iBAAiB,iBAAiB,SAAS,OAAO,MAAM,IAAI,WAAW;EAC1F;CACF;CAEA,aAAqB,QAAuC;EAC1D,OAAO,KAAK,iBAAiB,UAAU,MAAM,MAAM,EAAE,iBAAiB,SAAS,OAAO,MAAM,CAAC,KAAK;CACpG;;;;CAKA,IAAW,mBAAmB;EAC5B,OAAO,MAAM,KAAK,IAAI,IAAI,KAAK,iBAAiB,UAAU,SAAS,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC/F;AACF;;CArMC,WAAW;CAOP,gBAAA,GAAA,OAAO,iBAAiB,MAAM,CAAA"}
@@ -73,6 +73,20 @@ export declare class KeyManagementApi {
73
73
  x5t?: string | undefined;
74
74
  'x5t#S256'?: string | undefined;
75
75
  x5u?: string | undefined;
76
+ } | {
77
+ kty: "OKP";
78
+ crv: "X25519" | "Ed25519";
79
+ x: string;
80
+ d?: string | undefined;
81
+ kid?: string | undefined;
82
+ alg?: string | undefined;
83
+ key_ops?: string[] | undefined;
84
+ use?: string | undefined;
85
+ ext?: boolean | undefined;
86
+ x5c?: string[] | undefined;
87
+ x5t?: string | undefined;
88
+ 'x5t#S256'?: string | undefined;
89
+ x5u?: string | undefined;
76
90
  } | {
77
91
  kty: "RSA";
78
92
  n: string;
@@ -105,20 +119,6 @@ export declare class KeyManagementApi {
105
119
  x5t?: string | undefined;
106
120
  'x5t#S256'?: string | undefined;
107
121
  x5u?: string | undefined;
108
- } | {
109
- kty: "OKP";
110
- crv: "Ed25519" | "X25519";
111
- x: string;
112
- d?: string | undefined;
113
- kid?: string | undefined;
114
- alg?: string | undefined;
115
- key_ops?: string[] | undefined;
116
- use?: string | undefined;
117
- ext?: boolean | undefined;
118
- x5c?: string[] | undefined;
119
- x5t?: string | undefined;
120
- 'x5t#S256'?: string | undefined;
121
- x5u?: string | undefined;
122
122
  }>;
123
123
  /**
124
124
  * Delete a key.
@@ -18,6 +18,7 @@ export declare const KnownJwaSignatureAlgorithms: {
18
18
  readonly ES256K: "ES256K";
19
19
  };
20
20
  export declare const zKnownJwaSignatureAlgorithm: z$1.ZodEnum<{
21
+ Ed25519: "Ed25519";
21
22
  HS256: "HS256";
22
23
  HS384: "HS384";
23
24
  HS512: "HS512";
@@ -31,7 +32,6 @@ export declare const zKnownJwaSignatureAlgorithm: z$1.ZodEnum<{
31
32
  PS384: "PS384";
32
33
  PS512: "PS512";
33
34
  EdDSA: "EdDSA";
34
- Ed25519: "Ed25519";
35
35
  ES256K: "ES256K";
36
36
  }>;
37
37
  export type KnownJwaSignatureAlgorithm = z$1.output<typeof zKnownJwaSignatureAlgorithm>;