@credo-ts/core 0.7.5-alpha-20261118140058 → 0.7.5
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.
- package/build/crypto/webcrypto/CredoWalletWebCrypto.d.mts +1 -1
- package/build/modules/dids/domain/verificationMethod/JsonWebKey2020.d.mts +24 -24
- package/build/modules/dids/methods/jwk/DidJwk.d.mts +24 -24
- package/build/modules/dif-presentation-exchange/DifPresentationExchangeService.d.mts +1 -1
- package/build/modules/dif-presentation-exchange/DifPresentationExchangeService.d.mts.map +1 -1
- package/build/modules/dif-presentation-exchange/DifPresentationExchangeService.mjs +2 -1
- package/build/modules/dif-presentation-exchange/DifPresentationExchangeService.mjs.map +1 -1
- package/build/modules/dif-presentation-exchange/utils/presentationSelection.d.mts.map +1 -1
- package/build/modules/dif-presentation-exchange/utils/presentationSelection.mjs +5 -2
- package/build/modules/dif-presentation-exchange/utils/presentationSelection.mjs.map +1 -1
- package/build/modules/kms/KeyManagementApi.d.mts +14 -14
- package/build/modules/kms/jwk/jwa.d.mts +1 -1
- package/build/modules/kms/jwk/knownJwk.d.mts +4 -4
- package/build/modules/kms/jwk/kty/ec/P256PublicJwk.d.mts +1 -1
- package/build/modules/kms/jwk/kty/ec/P384PublicJwk.d.mts +1 -1
- package/build/modules/kms/jwk/kty/ec/P521PublicJwk.d.mts +1 -1
- package/build/modules/kms/jwk/kty/ec/Secp256k1PublicJwk.d.mts +1 -1
- package/build/modules/kms/jwk/kty/okp/Ed25519PublicJwk.d.mts +2 -2
- package/build/modules/kms/jwk/kty/okp/X25519PublicJwk.d.mts +1 -1
- package/build/modules/kms/jwk/kty/okp/okpJwk.d.mts +2 -2
- package/build/modules/kms/options/KmsCreateKeyOptions.d.mts +3 -3
- package/build/modules/kms/options/KmsSignOptions.d.mts +1 -1
- package/build/modules/kms/options/KmsVerifyOptions.d.mts +2 -2
- package/build/modules/mdoc/repository/MdocRecord.d.mts +1 -1
- package/build/modules/sd-jwt-vc/repository/SdJwtVcRecord.d.mts +1 -1
- package/build/modules/vc/models/credential/W3cV2EnvelopedVerifiableCredential.d.mts +1 -1
- package/build/modules/vc/models/credential/W3cV2EnvelopedVerifiableCredential.d.mts.map +1 -1
- package/build/modules/vc/models/credential/W3cV2VerifiableCredential.d.mts +1 -1
- package/build/modules/vc/models/credential/W3cV2VerifiableCredential.d.mts.map +1 -1
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ export declare class CredoWalletWebCrypto {
|
|
|
29
29
|
modulusLength?: undefined;
|
|
30
30
|
} | {
|
|
31
31
|
kty: "RSA";
|
|
32
|
-
modulusLength:
|
|
32
|
+
modulusLength: 2048 | 3072 | 4096;
|
|
33
33
|
crv?: undefined;
|
|
34
34
|
}>>;
|
|
35
35
|
importKey(format: KeyFormat, keyData: Uint8Array | JsonWebKey, algorithm: KeyImportParams, extractable: boolean, keyUsages: Array<KeyUsage>): Promise<CredoWebCryptoKey>;
|
|
@@ -15,7 +15,27 @@ export declare function getJsonWebKey2020(options: GetJsonWebKey2020Options): {
|
|
|
15
15
|
id: string;
|
|
16
16
|
type: string;
|
|
17
17
|
controller: string;
|
|
18
|
-
publicKeyJwk:
|
|
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
|
+
} | ({
|
|
19
39
|
kty: "EC";
|
|
20
40
|
crv: "P-256" | "P-384" | "P-521" | "secp256k1";
|
|
21
41
|
x: string;
|
|
@@ -85,7 +105,7 @@ export declare function getJsonWebKey2020(options: GetJsonWebKey2020Options): {
|
|
|
85
105
|
crv: "secp256k1";
|
|
86
106
|
}) | ({
|
|
87
107
|
kty: "OKP";
|
|
88
|
-
crv: "
|
|
108
|
+
crv: "Ed25519" | "X25519";
|
|
89
109
|
x: string;
|
|
90
110
|
d?: string | undefined;
|
|
91
111
|
kid?: string | undefined;
|
|
@@ -99,29 +119,9 @@ export declare function getJsonWebKey2020(options: GetJsonWebKey2020Options): {
|
|
|
99
119
|
x5u?: string | undefined;
|
|
100
120
|
} & {
|
|
101
121
|
crv: "Ed25519";
|
|
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
|
-
} | ({
|
|
122
|
+
}) | ({
|
|
123
123
|
kty: "OKP";
|
|
124
|
-
crv: "
|
|
124
|
+
crv: "Ed25519" | "X25519";
|
|
125
125
|
x: string;
|
|
126
126
|
d?: string | undefined;
|
|
127
127
|
kid?: string | undefined;
|
|
@@ -16,7 +16,27 @@ export declare class DidJwk {
|
|
|
16
16
|
*/
|
|
17
17
|
get verificationMethodId(): string;
|
|
18
18
|
static fromPublicJwk(publicJwk: PublicJwk): DidJwk;
|
|
19
|
-
get jwkJson():
|
|
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
|
+
} | ({
|
|
20
40
|
kty: "EC";
|
|
21
41
|
crv: "P-256" | "P-384" | "P-521" | "secp256k1";
|
|
22
42
|
x: string;
|
|
@@ -86,7 +106,7 @@ export declare class DidJwk {
|
|
|
86
106
|
crv: "secp256k1";
|
|
87
107
|
}) | ({
|
|
88
108
|
kty: "OKP";
|
|
89
|
-
crv: "
|
|
109
|
+
crv: "Ed25519" | "X25519";
|
|
90
110
|
x: string;
|
|
91
111
|
d?: string | undefined;
|
|
92
112
|
kid?: string | undefined;
|
|
@@ -100,29 +120,9 @@ export declare class DidJwk {
|
|
|
100
120
|
x5u?: string | undefined;
|
|
101
121
|
} & {
|
|
102
122
|
crv: "Ed25519";
|
|
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
|
-
} | ({
|
|
123
|
+
}) | ({
|
|
124
124
|
kty: "OKP";
|
|
125
|
-
crv: "
|
|
125
|
+
crv: "Ed25519" | "X25519";
|
|
126
126
|
x: string;
|
|
127
127
|
d?: string | undefined;
|
|
128
128
|
kid?: string | undefined;
|
|
@@ -51,7 +51,7 @@ export declare class DifPresentationExchangeService {
|
|
|
51
51
|
*/
|
|
52
52
|
mdocSessionTranscript?: MdocSessionTranscriptOptions;
|
|
53
53
|
}): Promise<{
|
|
54
|
-
verifiablePresentations: (
|
|
54
|
+
verifiablePresentations: (MdocDeviceResponse | W3cJwtVerifiablePresentation | W3cJsonLdVerifiablePresentation | SdJwtVc<SdJwtVcHeader, import("@sd-jwt/sd-jwt-vc").SdJwtVcPayload>)[];
|
|
55
55
|
encodedVerifiablePresentations: (string | W3cJsonPresentation)[];
|
|
56
56
|
presentationSubmission: import("@sphereon/pex-models").PresentationSubmission;
|
|
57
57
|
presentationSubmissionLocation: PresentationSubmissionLocation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DifPresentationExchangeService.d.mts","names":[],"sources":["../../../src/modules/dif-presentation-exchange/DifPresentationExchangeService.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBA4Da;UAGgB;UAFnB;EAEmB,YAAA,sBAAsB;EAEpC,yBACX,cAAc,cACd,wBAAwB,oCACvB,QAAQ;;;;;EASJ,4BACL,uBAAuB,8BACtB;EAsBI,+BAA+B,wBAAwB;EASvD,+BAA+B,wBAAwB;EAQvD,qBACL,wBAAwB,mCACxB,eAAe,yBAAyB,0BACxC,yBAAyB;
|
|
1
|
+
{"version":3,"file":"DifPresentationExchangeService.d.mts","names":[],"sources":["../../../src/modules/dif-presentation-exchange/DifPresentationExchangeService.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBA4Da;UAGgB;UAFnB;EAEmB,YAAA,sBAAsB;EAEpC,yBACX,cAAc,cACd,wBAAwB,oCACvB,QAAQ;;;;;EASJ,4BACL,uBAAuB,8BACtB;EAsBI,+BAA+B,wBAAwB;EASvD,+BAA+B,wBAAwB;EAQvD,qBACL,wBAAwB,mCACxB,eAAe,yBAAyB,0BACxC,yBAAyB;UAuBnB;EAQK,mBACX,cAAc,cACd;IACE,+BAA+B;IAC/B,wBAAwB;;;;IAIxB,iCAAiC;;;;IAIjC;;;;IAKA;;;;IAKA,wBAAwB;MACzB;;;;;;UAkKK;UA0BA;UAyCA;UAkBA;;;;;;UAuDA;UAuBA;UA8HM;;;;;UA2BA;UAqEN;UAIA"}
|
|
@@ -69,7 +69,8 @@ let DifPresentationExchangeService = class DifPresentationExchangeService {
|
|
|
69
69
|
validatePresentation(presentationDefinition, presentations, presentationSubmission) {
|
|
70
70
|
const result = this.pex.evaluatePresentation(presentationDefinition, Array.isArray(presentations) ? presentations.map(getSphereonOriginalVerifiablePresentation) : getSphereonOriginalVerifiablePresentation(presentations), {
|
|
71
71
|
limitDisclosureSignatureSuites: ["DataIntegrityProof.anoncreds-2023"],
|
|
72
|
-
presentationSubmission
|
|
72
|
+
presentationSubmission,
|
|
73
|
+
presentationSubmissionLocation: presentationSubmission ? PresentationSubmissionLocation.EXTERNAL : void 0
|
|
73
74
|
});
|
|
74
75
|
if (result.areRequiredCredentialsPresent === Status.ERROR) {
|
|
75
76
|
const errorMessages = this.formatValidated(result.errors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DifPresentationExchangeService.mjs","names":["DifPresentationExchangeSubmissionLocation"],"sources":["../../../src/modules/dif-presentation-exchange/DifPresentationExchangeService.ts"],"sourcesContent":["import type { Checked, PresentationSignCallBackParams, Validated, VerifiablePresentationResult } from '@animo-id/pex'\nimport { PEX, Status } from '@animo-id/pex'\nimport { type PartialSdJwtDecodedVerifiableCredential, PEVersion } from '@animo-id/pex/dist/main/lib/index.js'\nimport type { InputDescriptorV2 } from '@sphereon/pex-models'\nimport type {\n SdJwtDecodedVerifiableCredential,\n W3CVerifiablePresentation as SphereonW3cVerifiablePresentation,\n W3CVerifiablePresentation,\n} from '@sphereon/ssi-types'\nimport type { AgentContext } from '../../agent'\nimport { CredoError } from '../../error'\nimport { injectable } from '../../plugins'\nimport type { Query } from '../../storage/StorageService'\nimport { JsonTransformer } from '../../utils'\nimport { uuid } from '../../utils/uuid'\nimport type { VerificationMethod } from '../dids'\nimport { DidsApi, getPublicJwkFromVerificationMethod } from '../dids'\nimport { getJwkHumanDescription } from '../kms'\nimport { MdocApi, MdocRecord, type MdocSessionTranscriptOptions } from '../mdoc'\nimport { MdocDeviceResponse } from '../mdoc/MdocDeviceResponse'\nimport type { SdJwtVcRecord } from '../sd-jwt-vc'\nimport { SdJwtVcApi } from '../sd-jwt-vc'\nimport type { W3cCredentialRecord, W3cJsonPresentation } from '../vc'\nimport {\n ClaimFormat,\n SignatureSuiteRegistry,\n W3cCredentialRepository,\n W3cCredentialService,\n W3cPresentation,\n} from '../vc'\nimport type { IAnonCredsW3cCredentialService } from '../vc/anoncreds-w3c-credential'\nimport {\n ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE,\n AnonCredsW3cCredentialServiceSymbol,\n} from '../vc/anoncreds-w3c-credential'\nimport { purposes } from '../vc/linked-data-proofs/adapters/jsonld-signatures-adapter'\nimport { DifPresentationExchangeError } from './DifPresentationExchangeError'\nimport type {\n DifPexCredentialsForRequest,\n DifPexInputDescriptorToCredentials,\n DifPresentationExchangeDefinition,\n DifPresentationExchangeDefinitionV1,\n DifPresentationExchangeDefinitionV2,\n DifPresentationExchangeSubmission,\n VerifiablePresentation,\n} from './models'\nimport { DifPresentationExchangeSubmissionLocation } from './models'\nimport type { PresentationToCreate } from './utils'\nimport {\n getCredentialsForRequest,\n getPresentationsToCreate,\n getSphereonOriginalVerifiableCredential,\n getSphereonOriginalVerifiablePresentation,\n getVerifiablePresentationFromEncoded,\n} from './utils'\n\n/**\n * @todo create a public api for using dif presentation exchange\n */\n@injectable()\nexport class DifPresentationExchangeService {\n private pex = new PEX()\n\n public constructor(private w3cCredentialService: W3cCredentialService) {}\n\n public async getCredentialsForRequest(\n agentContext: AgentContext,\n presentationDefinition: DifPresentationExchangeDefinition\n ): Promise<DifPexCredentialsForRequest> {\n const credentialRecords = await this.queryCredentialForPresentationDefinition(agentContext, presentationDefinition)\n return getCredentialsForRequest(agentContext, this.pex, presentationDefinition, credentialRecords)\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 credentialsForRequest: DifPexCredentialsForRequest\n ): DifPexInputDescriptorToCredentials {\n if (!credentialsForRequest.areRequirementsSatisfied) {\n throw new CredoError('Could not find the required credentials for the presentation submission')\n }\n\n const credentials: DifPexInputDescriptorToCredentials = {}\n\n for (const requirement of credentialsForRequest.requirements) {\n // Take needsCount entries from the submission entry\n for (const submission of requirement.submissionEntry.slice(0, requirement.needsCount)) {\n if (!credentials[submission.inputDescriptorId]) {\n credentials[submission.inputDescriptorId] = []\n }\n\n // We pick the first matching VC if we are auto-selecting\n credentials[submission.inputDescriptorId].push(submission.verifiableCredentials[0])\n }\n }\n\n return credentials\n }\n\n public validatePresentationDefinition(presentationDefinition: DifPresentationExchangeDefinition) {\n const validation = PEX.validateDefinition(presentationDefinition)\n const errorMessages = this.formatValidated(validation)\n\n if (errorMessages.length > 0) {\n throw new DifPresentationExchangeError('Invalid presentation definition', { additionalMessages: errorMessages })\n }\n }\n\n public validatePresentationSubmission(presentationSubmission: DifPresentationExchangeSubmission) {\n const validation = PEX.validateSubmission(presentationSubmission)\n const errorMessages = this.formatValidated(validation)\n if (errorMessages.length > 0) {\n throw new DifPresentationExchangeError('Invalid presentation submission', { additionalMessages: errorMessages })\n }\n }\n\n public validatePresentation(\n presentationDefinition: DifPresentationExchangeDefinition,\n presentations: VerifiablePresentation | VerifiablePresentation[],\n presentationSubmission?: DifPresentationExchangeSubmission\n ) {\n const result = this.pex.evaluatePresentation(\n presentationDefinition,\n Array.isArray(presentations)\n ? presentations.map(getSphereonOriginalVerifiablePresentation)\n : getSphereonOriginalVerifiablePresentation(presentations),\n {\n limitDisclosureSignatureSuites: ['DataIntegrityProof.anoncreds-2023'],\n presentationSubmission,\n }\n )\n\n if (result.areRequiredCredentialsPresent === Status.ERROR) {\n const errorMessages = this.formatValidated(result.errors)\n throw new DifPresentationExchangeError('Invalid presentation', { additionalMessages: errorMessages })\n }\n }\n\n private formatValidated(v?: Checked[] | Validated) {\n const validated = Array.isArray(v) ? v : v ? [v] : []\n return validated\n .filter((r) => r.status === Status.ERROR)\n .map((r) => r.message)\n .filter((r): r is string => Boolean(r))\n }\n\n public async createPresentation(\n agentContext: AgentContext,\n options: {\n credentialsForInputDescriptor: DifPexInputDescriptorToCredentials\n presentationDefinition: DifPresentationExchangeDefinition\n /**\n * Defaults to {@link DifPresentationExchangeSubmissionLocation.PRESENTATION}\n */\n presentationSubmissionLocation?: DifPresentationExchangeSubmissionLocation\n /**\n * Also known as `nonce`\n */\n challenge: string\n\n /**\n * Also known as `audience`\n */\n domain?: string\n\n /**\n * Mdoc openid4vp specific options\n */\n mdocSessionTranscript?: MdocSessionTranscriptOptions\n }\n ) {\n const { presentationDefinition, domain, challenge, mdocSessionTranscript } = options\n const presentationSubmissionLocation =\n options.presentationSubmissionLocation ?? DifPresentationExchangeSubmissionLocation.PRESENTATION\n\n const verifiablePresentationResultsWithFormat: Array<{\n verifiablePresentationResult: VerifiablePresentationResult\n claimFormat: PresentationToCreate['claimFormat']\n }> = []\n\n const presentationsToCreate = getPresentationsToCreate(options.credentialsForInputDescriptor)\n for (const presentationToCreate of presentationsToCreate) {\n // We create a presentation for each subject\n // Thus for each subject we need to filter all the related input descriptors and credentials\n const inputDescriptorIds = presentationToCreate.verifiableCredentials.map((c) => c.inputDescriptorId)\n const inputDescriptorsForPresentation = (\n presentationDefinition as DifPresentationExchangeDefinitionV1\n ).input_descriptors.filter((inputDescriptor) => inputDescriptorIds.includes(inputDescriptor.id))\n\n const presentationDefinitionForSubject: DifPresentationExchangeDefinition = {\n ...presentationDefinition,\n input_descriptors: inputDescriptorsForPresentation,\n\n // We remove the submission requirements, as it will otherwise fail to create the VP\n submission_requirements: undefined,\n }\n\n if (presentationToCreate.claimFormat === ClaimFormat.MsoMdoc) {\n if (presentationToCreate.verifiableCredentials.length !== 1) {\n throw new DifPresentationExchangeError(\n 'Currently a Mdoc presentation can only be created from a single credential'\n )\n }\n\n if (!mdocSessionTranscript) {\n throw new DifPresentationExchangeError(\n 'Missing mdoc session transcript options for creating MDOC presentation.'\n )\n }\n\n const { credential, inputDescriptorId } = presentationToCreate.verifiableCredentials[0]\n\n const deviceResponse = await MdocDeviceResponse.createDeviceResponseWithPresentationDefinition(agentContext, {\n mdocs: [credential.firstCredential],\n presentationDefinition,\n sessionTranscriptOptions: mdocSessionTranscript,\n })\n\n if (presentationSubmissionLocation !== DifPresentationExchangeSubmissionLocation.EXTERNAL) {\n throw new DifPresentationExchangeError(\n 'Only EXTERNAL DifPresentationExchangeSubmissionLocation supported for mdoc presentations'\n )\n }\n\n verifiablePresentationResultsWithFormat.push({\n verifiablePresentationResult: {\n presentationSubmission: {\n id: `MdocPresentationSubmission ${uuid()}`,\n definition_id: presentationDefinition.id,\n descriptor_map: [\n {\n id: inputDescriptorId,\n format: 'mso_mdoc',\n path: '$',\n },\n ],\n },\n verifiablePresentations: [deviceResponse.encoded],\n presentationSubmissionLocation,\n },\n claimFormat: presentationToCreate.claimFormat,\n })\n } else {\n // Get all the credentials for the presentation\n const credentialsForPresentation = presentationToCreate.verifiableCredentials.map((c) =>\n getSphereonOriginalVerifiableCredential(c.credential)\n )\n\n const extraProofOptions = this.shouldSignWithAnonCredsW3cService(presentationToCreate)\n ? {\n typeSupportsSelectiveDisclosure: true,\n type: `DataIntegrityProof.${ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE}`,\n }\n : {}\n\n const verifiablePresentationResult = await this.pex.verifiablePresentationFrom(\n presentationDefinitionForSubject,\n credentialsForPresentation,\n this.getPresentationSignCallback(agentContext, presentationToCreate),\n {\n proofOptions: {\n challenge,\n domain,\n\n ...extraProofOptions,\n },\n presentationSubmissionLocation,\n }\n )\n\n verifiablePresentationResultsWithFormat.push({\n verifiablePresentationResult,\n claimFormat: presentationToCreate.claimFormat,\n })\n }\n }\n\n if (verifiablePresentationResultsWithFormat.length === 0) {\n throw new DifPresentationExchangeError('No verifiable presentations created')\n }\n\n if (presentationsToCreate.length !== verifiablePresentationResultsWithFormat.length) {\n throw new DifPresentationExchangeError('Invalid amount of verifiable presentations created')\n }\n\n const presentationSubmission: DifPresentationExchangeSubmission = {\n id: verifiablePresentationResultsWithFormat[0].verifiablePresentationResult.presentationSubmission.id,\n definition_id:\n verifiablePresentationResultsWithFormat[0].verifiablePresentationResult.presentationSubmission.definition_id,\n descriptor_map: [],\n }\n\n verifiablePresentationResultsWithFormat.forEach(({ verifiablePresentationResult }, index) => {\n const descriptorMap = verifiablePresentationResult.presentationSubmission.descriptor_map.map((d) => {\n const descriptor = { ...d }\n\n // when multiple presentations are submitted, path should be $[0], $[1]\n // FIXME: this should be addressed in the PEX/OID4VP lib.\n // See https://github.com/Sphereon-Opensource/SIOP-OID4VP/issues/62\n if (\n presentationSubmissionLocation === DifPresentationExchangeSubmissionLocation.EXTERNAL &&\n verifiablePresentationResultsWithFormat.length > 1\n ) {\n descriptor.path = `$[${index}]`\n }\n\n return descriptor\n })\n\n presentationSubmission.descriptor_map.push(...descriptorMap)\n })\n\n return {\n verifiablePresentations: verifiablePresentationResultsWithFormat.flatMap((resultWithFormat) =>\n resultWithFormat.verifiablePresentationResult.verifiablePresentations.map((vp) =>\n getVerifiablePresentationFromEncoded(agentContext, vp)\n )\n ),\n encodedVerifiablePresentations: verifiablePresentationResultsWithFormat.flatMap(\n (resultWithFormat) =>\n resultWithFormat.verifiablePresentationResult.verifiablePresentations as unknown as (\n | string\n | W3cJsonPresentation\n )[]\n ),\n presentationSubmission,\n presentationSubmissionLocation:\n verifiablePresentationResultsWithFormat[0].verifiablePresentationResult.presentationSubmissionLocation,\n }\n }\n\n private getSigningAlgorithmFromVerificationMethod(\n verificationMethod: VerificationMethod,\n suitableAlgorithms?: Array<string>\n ) {\n const publicJwk = getPublicJwkFromVerificationMethod(verificationMethod)\n\n if (suitableAlgorithms) {\n const possibleAlgorithms = publicJwk.supportedSignatureAlgorithms.filter((alg) =>\n suitableAlgorithms?.includes(alg)\n )\n if (!possibleAlgorithms || possibleAlgorithms.length === 0) {\n throw new DifPresentationExchangeError(\n [\n 'Found no suitable signing algorithm.',\n `Algorithms supported by Verification method: ${publicJwk.supportedSignatureAlgorithms.join(', ')}`,\n `Suitable algorithms: ${suitableAlgorithms.join(', ')}`,\n ].join('\\n')\n )\n }\n\n return possibleAlgorithms[0]\n }\n\n return publicJwk.signatureAlgorithm\n }\n\n private getSigningAlgorithmsForPresentationDefinitionAndInputDescriptors(\n algorithmsSatisfyingDefinition: Array<string>,\n inputDescriptorAlgorithms: Array<Array<string>>\n ) {\n const allDescriptorAlgorithms = inputDescriptorAlgorithms.flat()\n const algorithmsSatisfyingDescriptors = allDescriptorAlgorithms.filter((alg) =>\n inputDescriptorAlgorithms.every((descriptorAlgorithmSet) => descriptorAlgorithmSet.includes(alg))\n )\n\n const algorithmsSatisfyingPdAndDescriptorRestrictions = algorithmsSatisfyingDefinition.filter((alg) =>\n algorithmsSatisfyingDescriptors.includes(alg)\n )\n\n if (\n algorithmsSatisfyingDefinition.length > 0 &&\n algorithmsSatisfyingDescriptors.length > 0 &&\n algorithmsSatisfyingPdAndDescriptorRestrictions.length === 0\n ) {\n throw new DifPresentationExchangeError(\n 'No signature algorithm found for satisfying restrictions of the presentation definition and input descriptors'\n )\n }\n\n if (allDescriptorAlgorithms.length > 0 && algorithmsSatisfyingDescriptors.length === 0) {\n throw new DifPresentationExchangeError(\n 'No signature algorithm found for satisfying restrictions of the input descriptors'\n )\n }\n\n let suitableAlgorithms: Array<string> | undefined\n if (algorithmsSatisfyingPdAndDescriptorRestrictions.length > 0) {\n suitableAlgorithms = algorithmsSatisfyingPdAndDescriptorRestrictions\n } else if (algorithmsSatisfyingDescriptors.length > 0) {\n suitableAlgorithms = algorithmsSatisfyingDescriptors\n } else if (algorithmsSatisfyingDefinition.length > 0) {\n suitableAlgorithms = algorithmsSatisfyingDefinition\n }\n\n return suitableAlgorithms\n }\n\n private getSigningAlgorithmForJwtVc(\n presentationDefinition: DifPresentationExchangeDefinitionV1 | DifPresentationExchangeDefinitionV2,\n verificationMethod: VerificationMethod\n ) {\n const algorithmsSatisfyingDefinition = presentationDefinition.format?.jwt_vc?.alg ?? []\n\n const inputDescriptorAlgorithms: Array<Array<string>> = presentationDefinition.input_descriptors\n .map((descriptor) => (descriptor as InputDescriptorV2).format?.jwt_vc?.alg ?? [])\n .filter((alg) => alg.length > 0)\n\n const suitableAlgorithms = this.getSigningAlgorithmsForPresentationDefinitionAndInputDescriptors(\n algorithmsSatisfyingDefinition,\n inputDescriptorAlgorithms\n )\n\n return this.getSigningAlgorithmFromVerificationMethod(verificationMethod, suitableAlgorithms)\n }\n\n private getProofTypeForLdpVc(\n agentContext: AgentContext,\n presentationDefinition: DifPresentationExchangeDefinitionV1 | DifPresentationExchangeDefinitionV2,\n verificationMethod: VerificationMethod\n ) {\n const algorithmsSatisfyingDefinition = presentationDefinition.format?.ldp_vc?.proof_type ?? []\n\n const inputDescriptorAlgorithms: Array<Array<string>> = presentationDefinition.input_descriptors\n .map((descriptor) => (descriptor as InputDescriptorV2).format?.ldp_vc?.proof_type ?? [])\n .filter((alg) => alg.length > 0)\n\n const suitableSignatureSuites = this.getSigningAlgorithmsForPresentationDefinitionAndInputDescriptors(\n algorithmsSatisfyingDefinition,\n inputDescriptorAlgorithms\n )\n\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 DifPresentationExchangeError(\n `Couldn't find a supported signature suite for the given jwk ${getJwkHumanDescription(publicJwk.toJson())}`\n )\n }\n\n if (suitableSignatureSuites) {\n const foundSignatureSuite = supportedSignatureSuites.find((suite) =>\n suitableSignatureSuites.includes(suite.proofType)\n )\n\n if (!foundSignatureSuite) {\n throw new DifPresentationExchangeError(\n [\n 'No possible signature suite found for the given verification method.',\n `Verification method type: ${verificationMethod.type}`,\n `jwk type: ${getJwkHumanDescription(publicJwk.toJson())}`,\n `SupportedSignatureSuites: '${supportedSignatureSuites.map((s) => s.proofType).join(', ')}'`,\n `SuitableSignatureSuites: ${suitableSignatureSuites.join(', ')}`,\n ].join('\\n')\n )\n }\n\n return foundSignatureSuite.proofType\n }\n\n return supportedSignatureSuites[0].proofType\n }\n\n /**\n * if all submission descriptors have a format of di | ldp,\n * and all credentials have an anoncreds W3C credential proof we default to\n * signing the presentation using the ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE\n */\n private shouldSignWithAnonCredsW3cService(\n presentationToCreate: PresentationToCreate,\n presentationSubmission?: DifPresentationExchangeSubmission\n ) {\n if (presentationToCreate.claimFormat !== ClaimFormat.LdpVp) return undefined\n\n const validDescriptorFormat =\n !presentationSubmission ||\n presentationSubmission.descriptor_map.every((descriptor) =>\n [ClaimFormat.DiVc, ClaimFormat.DiVp, ClaimFormat.LdpVc, ClaimFormat.LdpVp].includes(\n descriptor.format as ClaimFormat\n )\n )\n\n const credentialsAreSignedWithAnonCredsW3c = presentationToCreate.verifiableCredentials.every(({ credential }) => {\n const firstCredential = credential.firstCredential\n if (firstCredential.claimFormat !== ClaimFormat.LdpVc) return false\n return firstCredential.anonCredsW3cCredentialCryptosuites.includes(ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE)\n })\n\n return validDescriptorFormat && credentialsAreSignedWithAnonCredsW3c\n }\n\n private getPresentationSignCallback(agentContext: AgentContext, presentationToCreate: PresentationToCreate) {\n return async (callBackParams: PresentationSignCallBackParams) => {\n // The created partial proof and presentation, as well as original supplied options\n const {\n presentation: presentationInput,\n options,\n presentationDefinition,\n presentationSubmission,\n } = callBackParams\n const { challenge, domain } = options.proofOptions ?? {}\n\n if (!challenge) {\n throw new CredoError('challenge MUST be provided when signing a Verifiable Presentation')\n }\n\n if (presentationToCreate.claimFormat === ClaimFormat.JwtVp) {\n if (!presentationToCreate.subjectIds) {\n throw new DifPresentationExchangeError('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 presentationToCreate.subjectIds[0]\n )\n\n const w3cPresentation = JsonTransformer.fromJSON(presentationInput, W3cPresentation)\n w3cPresentation.holder = verificationMethod.controller\n\n const signedPresentation = await this.w3cCredentialService.signPresentation<ClaimFormat.JwtVp>(agentContext, {\n format: ClaimFormat.JwtVp,\n alg: this.getSigningAlgorithmForJwtVc(presentationDefinition, verificationMethod),\n verificationMethod: verificationMethod.id,\n presentation: w3cPresentation,\n challenge,\n domain,\n })\n\n return signedPresentation.encoded as W3CVerifiablePresentation\n }\n if (presentationToCreate.claimFormat === ClaimFormat.LdpVp) {\n if (this.shouldSignWithAnonCredsW3cService(presentationToCreate, presentationSubmission)) {\n // make sure the descriptors format properties are set correctly\n presentationSubmission.descriptor_map = presentationSubmission.descriptor_map.map((descriptor) => ({\n ...descriptor,\n format: 'di_vp',\n }))\n const anoncredsW3cCredentialService = agentContext.dependencyManager.resolve<IAnonCredsW3cCredentialService>(\n AnonCredsW3cCredentialServiceSymbol\n )\n const presentation = await anoncredsW3cCredentialService.createPresentation(agentContext, {\n presentationDefinition,\n presentationSubmission,\n selectedCredentialRecords: presentationToCreate.verifiableCredentials.map((vc) => vc.credential),\n challenge,\n })\n return {\n ...presentation.toJSON(),\n presentation_submission: presentationSubmission,\n } as unknown as SphereonW3cVerifiablePresentation\n }\n\n if (!presentationToCreate.subjectIds) {\n throw new DifPresentationExchangeError('Cannot create presentation for credentials without subject id')\n }\n // Determine a suitable verification method for the presentation\n const verificationMethod = await this.getVerificationMethodForSubjectId(\n agentContext,\n presentationToCreate.subjectIds[0]\n )\n\n const w3cPresentation = JsonTransformer.fromJSON(presentationInput, W3cPresentation)\n w3cPresentation.holder = verificationMethod.controller\n\n const signedPresentation = await this.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, presentationDefinition, verificationMethod),\n proofPurpose: new purposes.AuthenticationProofPurpose({ challenge, domain }),\n verificationMethod: verificationMethod.id,\n presentation: w3cPresentation,\n challenge,\n domain,\n })\n\n return signedPresentation.encoded as W3CVerifiablePresentation\n }\n if (presentationToCreate.claimFormat === ClaimFormat.SdJwtDc) {\n const sdJwtInput = presentationInput as\n | SdJwtDecodedVerifiableCredential\n | PartialSdJwtDecodedVerifiableCredential\n\n if (!domain) {\n throw new CredoError(\"Missing 'domain' property, unable to set required 'aud' property in SD-JWT KB-JWT\")\n }\n\n const sdJwtVcApi = this.getSdJwtVcApi(agentContext)\n\n // NOTE: we use the kmsKeyId from the first credential. We don't support the new useMode (for single-use credentials) for PEX\n const originalSdJwtVc = sdJwtVcApi.fromCompact(sdJwtInput.compactSdJwtVc)\n originalSdJwtVc.kmsKeyId =\n presentationToCreate.verifiableCredentials[0].credential.credentialInstances[0].kmsKeyId\n\n const sdJwtVc = await sdJwtVcApi.present({\n sdJwtVc: originalSdJwtVc,\n // SD is already handled by PEX, so we presents all keys\n presentationFrame: undefined,\n verifierMetadata: {\n audience: domain,\n nonce: challenge,\n // TODO: we should make this optional\n issuedAt: Math.floor(Date.now() / 1000),\n },\n additionalPayload: presentationToCreate.verifiableCredentials[0].additionalPayload,\n })\n\n return sdJwtVc\n }\n throw new DifPresentationExchangeError(\n 'Only JWT, SD-JWT-VC, JSONLD credentials are supported for a single presentation'\n )\n }\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 DifPresentationExchangeError(\n `Only dids are supported as credentialSubject id. ${subjectId} is not a valid did`\n )\n }\n\n const didDocument = await didsApi.resolveDidDocument(subjectId)\n\n if (!didDocument.authentication || didDocument.authentication.length === 0) {\n throw new DifPresentationExchangeError(\n `No authentication verificationMethods found for did ${subjectId} in did document`\n )\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 /**\n * Queries the wallet for credentials that match the given presentation definition. 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 queryCredentialForPresentationDefinition(\n agentContext: AgentContext,\n presentationDefinition: DifPresentationExchangeDefinition\n ): Promise<Array<SdJwtVcRecord | W3cCredentialRecord | MdocRecord>> {\n const w3cCredentialRepository = agentContext.dependencyManager.resolve(W3cCredentialRepository)\n const w3cQuery: Array<Query<W3cCredentialRecord>> = []\n const sdJwtVcQuery: Array<Query<SdJwtVcRecord>> = []\n const mdocQuery: Array<Query<MdocRecord>> = []\n\n const presentationDefinitionVersion = PEX.definitionVersionDiscovery(presentationDefinition)\n\n if (!presentationDefinitionVersion.version) {\n throw new DifPresentationExchangeError(\n 'Unable to determine the Presentation Exchange version from the presentation definition',\n presentationDefinitionVersion.error ? { additionalMessages: [presentationDefinitionVersion.error] } : {}\n )\n }\n\n // FIXME: in the query we should take into account the supported proof types of the verifier\n // this could help enormously in the amount of credentials we have to retrieve from storage.\n if (presentationDefinitionVersion.version === PEVersion.v1) {\n const pd = presentationDefinition as DifPresentationExchangeDefinitionV1\n\n // The schema.uri can contain either an expanded type, or a context uri\n for (const inputDescriptor of pd.input_descriptors) {\n for (const schema of inputDescriptor.schema) {\n sdJwtVcQuery.push({\n vct: schema.uri,\n })\n w3cQuery.push({\n $or: [{ expandedTypes: [schema.uri] }, { contexts: [schema.uri] }, { types: [schema.uri] }],\n })\n mdocQuery.push({\n docType: inputDescriptor.id,\n })\n }\n }\n } else if (presentationDefinitionVersion.version === PEVersion.v2) {\n // FIXME: As PE version 2 does not have the `schema` anymore, we can't query by schema anymore.\n // We probably need\n // to find some way to do initial filtering, hopefully if there's a filter on the `type` field or something.\n } else {\n throw new DifPresentationExchangeError(\n `Unsupported presentation definition version ${presentationDefinitionVersion.version as unknown as string}`\n )\n }\n\n const allRecords: Array<SdJwtVcRecord | W3cCredentialRecord | MdocRecord> = []\n\n // query the wallet ourselves first to avoid the need to query the pex library for all\n // credentials for every proof request\n const w3cCredentialRecords =\n w3cQuery.length > 0\n ? await w3cCredentialRepository.findByQuery(agentContext, { $or: w3cQuery })\n : await w3cCredentialRepository.getAll(agentContext)\n allRecords.push(...w3cCredentialRecords)\n\n const sdJwtVcApi = this.getSdJwtVcApi(agentContext)\n const sdJwtVcRecords =\n sdJwtVcQuery.length > 0 ? await sdJwtVcApi.findAllByQuery({ $or: sdJwtVcQuery }) : await sdJwtVcApi.getAll()\n allRecords.push(...sdJwtVcRecords)\n\n const mdocApi = this.getMdocApi(agentContext)\n const mdocRecords = mdocQuery.length > 0 ? await mdocApi.findAllByQuery({ $or: mdocQuery }) : await mdocApi.getAll()\n allRecords.push(...mdocRecords)\n\n return allRecords\n }\n\n private getSdJwtVcApi(agentContext: AgentContext) {\n return agentContext.dependencyManager.resolve(SdJwtVcApi)\n }\n\n private getM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S,CAAC,IACzE,MAAM,wBAAwB,OAAO,YAAY;EACvD,WAAW,KAAK,GAAG,oBAAoB;EAEvC,MAAM,aAAa,KAAK,cAAc,YAAY;EAClD,MAAM,iBACJ,aAAa,SAAS,IAAI,MAAM,WAAW,eAAe,EAAE,KAAK,aAAa,CAAC,IAAI,MAAM,WAAW,OAAO;EAC7G,WAAW,KAAK,GAAG,cAAc;EAEjC,MAAM,UAAU,KAAK,WAAW,YAAY;EAC5C,MAAM,cAAc,UAAU,SAAS,IAAI,MAAM,QAAQ,eAAe,EAAE,KAAK,UAAU,CAAC,IAAI,MAAM,QAAQ,OAAO;EACnH,WAAW,KAAK,GAAG,WAAW;EAE9B,OAAO;CACT;CAEA,cAAsB,cAA4B;EAChD,OAAO,aAAa,kBAAkB,QAAQ,UAAU;CAC1D;CAEA,WAAmB,cAA4B;EAC7C,OAAO,aAAa,kBAAkB,QAAQ,OAAO;CACvD;AACF;AA1pBC,iCAAA,WAAA,CAAA,WAAW,GAAA,mBAAA,qBAAA,CAAA,OAAA,yBAAA,cAAA,SAAA,oBAAA,CAAA,CAAA,GAAA,8BAAA"}
|
|
1
|
+
{"version":3,"file":"DifPresentationExchangeService.mjs","names":["DifPresentationExchangeSubmissionLocation"],"sources":["../../../src/modules/dif-presentation-exchange/DifPresentationExchangeService.ts"],"sourcesContent":["import type { Checked, PresentationSignCallBackParams, Validated, VerifiablePresentationResult } from '@animo-id/pex'\nimport { PEX, Status } from '@animo-id/pex'\nimport { type PartialSdJwtDecodedVerifiableCredential, PEVersion } from '@animo-id/pex/dist/main/lib/index.js'\nimport type { InputDescriptorV2 } from '@sphereon/pex-models'\nimport type {\n SdJwtDecodedVerifiableCredential,\n W3CVerifiablePresentation as SphereonW3cVerifiablePresentation,\n W3CVerifiablePresentation,\n} from '@sphereon/ssi-types'\nimport type { AgentContext } from '../../agent'\nimport { CredoError } from '../../error'\nimport { injectable } from '../../plugins'\nimport type { Query } from '../../storage/StorageService'\nimport { JsonTransformer } from '../../utils'\nimport { uuid } from '../../utils/uuid'\nimport type { VerificationMethod } from '../dids'\nimport { DidsApi, getPublicJwkFromVerificationMethod } from '../dids'\nimport { getJwkHumanDescription } from '../kms'\nimport { MdocApi, MdocRecord, type MdocSessionTranscriptOptions } from '../mdoc'\nimport { MdocDeviceResponse } from '../mdoc/MdocDeviceResponse'\nimport type { SdJwtVcRecord } from '../sd-jwt-vc'\nimport { SdJwtVcApi } from '../sd-jwt-vc'\nimport type { W3cCredentialRecord, W3cJsonPresentation } from '../vc'\nimport {\n ClaimFormat,\n SignatureSuiteRegistry,\n W3cCredentialRepository,\n W3cCredentialService,\n W3cPresentation,\n} from '../vc'\nimport type { IAnonCredsW3cCredentialService } from '../vc/anoncreds-w3c-credential'\nimport {\n ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE,\n AnonCredsW3cCredentialServiceSymbol,\n} from '../vc/anoncreds-w3c-credential'\nimport { purposes } from '../vc/linked-data-proofs/adapters/jsonld-signatures-adapter'\nimport { DifPresentationExchangeError } from './DifPresentationExchangeError'\nimport type {\n DifPexCredentialsForRequest,\n DifPexInputDescriptorToCredentials,\n DifPresentationExchangeDefinition,\n DifPresentationExchangeDefinitionV1,\n DifPresentationExchangeDefinitionV2,\n DifPresentationExchangeSubmission,\n VerifiablePresentation,\n} from './models'\nimport { DifPresentationExchangeSubmissionLocation } from './models'\nimport type { PresentationToCreate } from './utils'\nimport {\n getCredentialsForRequest,\n getPresentationsToCreate,\n getSphereonOriginalVerifiableCredential,\n getSphereonOriginalVerifiablePresentation,\n getVerifiablePresentationFromEncoded,\n} from './utils'\n\n/**\n * @todo create a public api for using dif presentation exchange\n */\n@injectable()\nexport class DifPresentationExchangeService {\n private pex = new PEX()\n\n public constructor(private w3cCredentialService: W3cCredentialService) {}\n\n public async getCredentialsForRequest(\n agentContext: AgentContext,\n presentationDefinition: DifPresentationExchangeDefinition\n ): Promise<DifPexCredentialsForRequest> {\n const credentialRecords = await this.queryCredentialForPresentationDefinition(agentContext, presentationDefinition)\n return getCredentialsForRequest(agentContext, this.pex, presentationDefinition, credentialRecords)\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 credentialsForRequest: DifPexCredentialsForRequest\n ): DifPexInputDescriptorToCredentials {\n if (!credentialsForRequest.areRequirementsSatisfied) {\n throw new CredoError('Could not find the required credentials for the presentation submission')\n }\n\n const credentials: DifPexInputDescriptorToCredentials = {}\n\n for (const requirement of credentialsForRequest.requirements) {\n // Take needsCount entries from the submission entry\n for (const submission of requirement.submissionEntry.slice(0, requirement.needsCount)) {\n if (!credentials[submission.inputDescriptorId]) {\n credentials[submission.inputDescriptorId] = []\n }\n\n // We pick the first matching VC if we are auto-selecting\n credentials[submission.inputDescriptorId].push(submission.verifiableCredentials[0])\n }\n }\n\n return credentials\n }\n\n public validatePresentationDefinition(presentationDefinition: DifPresentationExchangeDefinition) {\n const validation = PEX.validateDefinition(presentationDefinition)\n const errorMessages = this.formatValidated(validation)\n\n if (errorMessages.length > 0) {\n throw new DifPresentationExchangeError('Invalid presentation definition', { additionalMessages: errorMessages })\n }\n }\n\n public validatePresentationSubmission(presentationSubmission: DifPresentationExchangeSubmission) {\n const validation = PEX.validateSubmission(presentationSubmission)\n const errorMessages = this.formatValidated(validation)\n if (errorMessages.length > 0) {\n throw new DifPresentationExchangeError('Invalid presentation submission', { additionalMessages: errorMessages })\n }\n }\n\n public validatePresentation(\n presentationDefinition: DifPresentationExchangeDefinition,\n presentations: VerifiablePresentation | VerifiablePresentation[],\n presentationSubmission?: DifPresentationExchangeSubmission\n ) {\n const result = this.pex.evaluatePresentation(\n presentationDefinition,\n Array.isArray(presentations)\n ? presentations.map(getSphereonOriginalVerifiablePresentation)\n : getSphereonOriginalVerifiablePresentation(presentations),\n {\n limitDisclosureSignatureSuites: ['DataIntegrityProof.anoncreds-2023'],\n presentationSubmission,\n // A separate submission is external, so pex evaluates the credential that path_nested points at\n presentationSubmissionLocation: presentationSubmission\n ? DifPresentationExchangeSubmissionLocation.EXTERNAL\n : undefined,\n }\n )\n\n if (result.areRequiredCredentialsPresent === Status.ERROR) {\n const errorMessages = this.formatValidated(result.errors)\n throw new DifPresentationExchangeError('Invalid presentation', { additionalMessages: errorMessages })\n }\n }\n\n private formatValidated(v?: Checked[] | Validated) {\n const validated = Array.isArray(v) ? v : v ? [v] : []\n return validated\n .filter((r) => r.status === Status.ERROR)\n .map((r) => r.message)\n .filter((r): r is string => Boolean(r))\n }\n\n public async createPresentation(\n agentContext: AgentContext,\n options: {\n credentialsForInputDescriptor: DifPexInputDescriptorToCredentials\n presentationDefinition: DifPresentationExchangeDefinition\n /**\n * Defaults to {@link DifPresentationExchangeSubmissionLocation.PRESENTATION}\n */\n presentationSubmissionLocation?: DifPresentationExchangeSubmissionLocation\n /**\n * Also known as `nonce`\n */\n challenge: string\n\n /**\n * Also known as `audience`\n */\n domain?: string\n\n /**\n * Mdoc openid4vp specific options\n */\n mdocSessionTranscript?: MdocSessionTranscriptOptions\n }\n ) {\n const { presentationDefinition, domain, challenge, mdocSessionTranscript } = options\n const presentationSubmissionLocation =\n options.presentationSubmissionLocation ?? DifPresentationExchangeSubmissionLocation.PRESENTATION\n\n const verifiablePresentationResultsWithFormat: Array<{\n verifiablePresentationResult: VerifiablePresentationResult\n claimFormat: PresentationToCreate['claimFormat']\n }> = []\n\n const presentationsToCreate = getPresentationsToCreate(options.credentialsForInputDescriptor)\n for (const presentationToCreate of presentationsToCreate) {\n // We create a presentation for each subject\n // Thus for each subject we need to filter all the related input descriptors and credentials\n const inputDescriptorIds = presentationToCreate.verifiableCredentials.map((c) => c.inputDescriptorId)\n const inputDescriptorsForPresentation = (\n presentationDefinition as DifPresentationExchangeDefinitionV1\n ).input_descriptors.filter((inputDescriptor) => inputDescriptorIds.includes(inputDescriptor.id))\n\n const presentationDefinitionForSubject: DifPresentationExchangeDefinition = {\n ...presentationDefinition,\n input_descriptors: inputDescriptorsForPresentation,\n\n // We remove the submission requirements, as it will otherwise fail to create the VP\n submission_requirements: undefined,\n }\n\n if (presentationToCreate.claimFormat === ClaimFormat.MsoMdoc) {\n if (presentationToCreate.verifiableCredentials.length !== 1) {\n throw new DifPresentationExchangeError(\n 'Currently a Mdoc presentation can only be created from a single credential'\n )\n }\n\n if (!mdocSessionTranscript) {\n throw new DifPresentationExchangeError(\n 'Missing mdoc session transcript options for creating MDOC presentation.'\n )\n }\n\n const { credential, inputDescriptorId } = presentationToCreate.verifiableCredentials[0]\n\n const deviceResponse = await MdocDeviceResponse.createDeviceResponseWithPresentationDefinition(agentContext, {\n mdocs: [credential.firstCredential],\n presentationDefinition,\n sessionTranscriptOptions: mdocSessionTranscript,\n })\n\n if (presentationSubmissionLocation !== DifPresentationExchangeSubmissionLocation.EXTERNAL) {\n throw new DifPresentationExchangeError(\n 'Only EXTERNAL DifPresentationExchangeSubmissionLocation supported for mdoc presentations'\n )\n }\n\n verifiablePresentationResultsWithFormat.push({\n verifiablePresentationResult: {\n presentationSubmission: {\n id: `MdocPresentationSubmission ${uuid()}`,\n definition_id: presentationDefinition.id,\n descriptor_map: [\n {\n id: inputDescriptorId,\n format: 'mso_mdoc',\n path: '$',\n },\n ],\n },\n verifiablePresentations: [deviceResponse.encoded],\n presentationSubmissionLocation,\n },\n claimFormat: presentationToCreate.claimFormat,\n })\n } else {\n // Get all the credentials for the presentation\n const credentialsForPresentation = presentationToCreate.verifiableCredentials.map((c) =>\n getSphereonOriginalVerifiableCredential(c.credential)\n )\n\n const extraProofOptions = this.shouldSignWithAnonCredsW3cService(presentationToCreate)\n ? {\n typeSupportsSelectiveDisclosure: true,\n type: `DataIntegrityProof.${ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE}`,\n }\n : {}\n\n const verifiablePresentationResult = await this.pex.verifiablePresentationFrom(\n presentationDefinitionForSubject,\n credentialsForPresentation,\n this.getPresentationSignCallback(agentContext, presentationToCreate),\n {\n proofOptions: {\n challenge,\n domain,\n\n ...extraProofOptions,\n },\n presentationSubmissionLocation,\n }\n )\n\n verifiablePresentationResultsWithFormat.push({\n verifiablePresentationResult,\n claimFormat: presentationToCreate.claimFormat,\n })\n }\n }\n\n if (verifiablePresentationResultsWithFormat.length === 0) {\n throw new DifPresentationExchangeError('No verifiable presentations created')\n }\n\n if (presentationsToCreate.length !== verifiablePresentationResultsWithFormat.length) {\n throw new DifPresentationExchangeError('Invalid amount of verifiable presentations created')\n }\n\n const presentationSubmission: DifPresentationExchangeSubmission = {\n id: verifiablePresentationResultsWithFormat[0].verifiablePresentationResult.presentationSubmission.id,\n definition_id:\n verifiablePresentationResultsWithFormat[0].verifiablePresentationResult.presentationSubmission.definition_id,\n descriptor_map: [],\n }\n\n verifiablePresentationResultsWithFormat.forEach(({ verifiablePresentationResult }, index) => {\n const descriptorMap = verifiablePresentationResult.presentationSubmission.descriptor_map.map((d) => {\n const descriptor = { ...d }\n\n // when multiple presentations are submitted, path should be $[0], $[1]\n // FIXME: this should be addressed in the PEX/OID4VP lib.\n // See https://github.com/Sphereon-Opensource/SIOP-OID4VP/issues/62\n if (\n presentationSubmissionLocation === DifPresentationExchangeSubmissionLocation.EXTERNAL &&\n verifiablePresentationResultsWithFormat.length > 1\n ) {\n descriptor.path = `$[${index}]`\n }\n\n return descriptor\n })\n\n presentationSubmission.descriptor_map.push(...descriptorMap)\n })\n\n return {\n verifiablePresentations: verifiablePresentationResultsWithFormat.flatMap((resultWithFormat) =>\n resultWithFormat.verifiablePresentationResult.verifiablePresentations.map((vp) =>\n getVerifiablePresentationFromEncoded(agentContext, vp)\n )\n ),\n encodedVerifiablePresentations: verifiablePresentationResultsWithFormat.flatMap(\n (resultWithFormat) =>\n resultWithFormat.verifiablePresentationResult.verifiablePresentations as unknown as (\n | string\n | W3cJsonPresentation\n )[]\n ),\n presentationSubmission,\n presentationSubmissionLocation:\n verifiablePresentationResultsWithFormat[0].verifiablePresentationResult.presentationSubmissionLocation,\n }\n }\n\n private getSigningAlgorithmFromVerificationMethod(\n verificationMethod: VerificationMethod,\n suitableAlgorithms?: Array<string>\n ) {\n const publicJwk = getPublicJwkFromVerificationMethod(verificationMethod)\n\n if (suitableAlgorithms) {\n const possibleAlgorithms = publicJwk.supportedSignatureAlgorithms.filter((alg) =>\n suitableAlgorithms?.includes(alg)\n )\n if (!possibleAlgorithms || possibleAlgorithms.length === 0) {\n throw new DifPresentationExchangeError(\n [\n 'Found no suitable signing algorithm.',\n `Algorithms supported by Verification method: ${publicJwk.supportedSignatureAlgorithms.join(', ')}`,\n `Suitable algorithms: ${suitableAlgorithms.join(', ')}`,\n ].join('\\n')\n )\n }\n\n return possibleAlgorithms[0]\n }\n\n return publicJwk.signatureAlgorithm\n }\n\n private getSigningAlgorithmsForPresentationDefinitionAndInputDescriptors(\n algorithmsSatisfyingDefinition: Array<string>,\n inputDescriptorAlgorithms: Array<Array<string>>\n ) {\n const allDescriptorAlgorithms = inputDescriptorAlgorithms.flat()\n const algorithmsSatisfyingDescriptors = allDescriptorAlgorithms.filter((alg) =>\n inputDescriptorAlgorithms.every((descriptorAlgorithmSet) => descriptorAlgorithmSet.includes(alg))\n )\n\n const algorithmsSatisfyingPdAndDescriptorRestrictions = algorithmsSatisfyingDefinition.filter((alg) =>\n algorithmsSatisfyingDescriptors.includes(alg)\n )\n\n if (\n algorithmsSatisfyingDefinition.length > 0 &&\n algorithmsSatisfyingDescriptors.length > 0 &&\n algorithmsSatisfyingPdAndDescriptorRestrictions.length === 0\n ) {\n throw new DifPresentationExchangeError(\n 'No signature algorithm found for satisfying restrictions of the presentation definition and input descriptors'\n )\n }\n\n if (allDescriptorAlgorithms.length > 0 && algorithmsSatisfyingDescriptors.length === 0) {\n throw new DifPresentationExchangeError(\n 'No signature algorithm found for satisfying restrictions of the input descriptors'\n )\n }\n\n let suitableAlgorithms: Array<string> | undefined\n if (algorithmsSatisfyingPdAndDescriptorRestrictions.length > 0) {\n suitableAlgorithms = algorithmsSatisfyingPdAndDescriptorRestrictions\n } else if (algorithmsSatisfyingDescriptors.length > 0) {\n suitableAlgorithms = algorithmsSatisfyingDescriptors\n } else if (algorithmsSatisfyingDefinition.length > 0) {\n suitableAlgorithms = algorithmsSatisfyingDefinition\n }\n\n return suitableAlgorithms\n }\n\n private getSigningAlgorithmForJwtVc(\n presentationDefinition: DifPresentationExchangeDefinitionV1 | DifPresentationExchangeDefinitionV2,\n verificationMethod: VerificationMethod\n ) {\n const algorithmsSatisfyingDefinition = presentationDefinition.format?.jwt_vc?.alg ?? []\n\n const inputDescriptorAlgorithms: Array<Array<string>> = presentationDefinition.input_descriptors\n .map((descriptor) => (descriptor as InputDescriptorV2).format?.jwt_vc?.alg ?? [])\n .filter((alg) => alg.length > 0)\n\n const suitableAlgorithms = this.getSigningAlgorithmsForPresentationDefinitionAndInputDescriptors(\n algorithmsSatisfyingDefinition,\n inputDescriptorAlgorithms\n )\n\n return this.getSigningAlgorithmFromVerificationMethod(verificationMethod, suitableAlgorithms)\n }\n\n private getProofTypeForLdpVc(\n agentContext: AgentContext,\n presentationDefinition: DifPresentationExchangeDefinitionV1 | DifPresentationExchangeDefinitionV2,\n verificationMethod: VerificationMethod\n ) {\n const algorithmsSatisfyingDefinition = presentationDefinition.format?.ldp_vc?.proof_type ?? []\n\n const inputDescriptorAlgorithms: Array<Array<string>> = presentationDefinition.input_descriptors\n .map((descriptor) => (descriptor as InputDescriptorV2).format?.ldp_vc?.proof_type ?? [])\n .filter((alg) => alg.length > 0)\n\n const suitableSignatureSuites = this.getSigningAlgorithmsForPresentationDefinitionAndInputDescriptors(\n algorithmsSatisfyingDefinition,\n inputDescriptorAlgorithms\n )\n\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 DifPresentationExchangeError(\n `Couldn't find a supported signature suite for the given jwk ${getJwkHumanDescription(publicJwk.toJson())}`\n )\n }\n\n if (suitableSignatureSuites) {\n const foundSignatureSuite = supportedSignatureSuites.find((suite) =>\n suitableSignatureSuites.includes(suite.proofType)\n )\n\n if (!foundSignatureSuite) {\n throw new DifPresentationExchangeError(\n [\n 'No possible signature suite found for the given verification method.',\n `Verification method type: ${verificationMethod.type}`,\n `jwk type: ${getJwkHumanDescription(publicJwk.toJson())}`,\n `SupportedSignatureSuites: '${supportedSignatureSuites.map((s) => s.proofType).join(', ')}'`,\n `SuitableSignatureSuites: ${suitableSignatureSuites.join(', ')}`,\n ].join('\\n')\n )\n }\n\n return foundSignatureSuite.proofType\n }\n\n return supportedSignatureSuites[0].proofType\n }\n\n /**\n * if all submission descriptors have a format of di | ldp,\n * and all credentials have an anoncreds W3C credential proof we default to\n * signing the presentation using the ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE\n */\n private shouldSignWithAnonCredsW3cService(\n presentationToCreate: PresentationToCreate,\n presentationSubmission?: DifPresentationExchangeSubmission\n ) {\n if (presentationToCreate.claimFormat !== ClaimFormat.LdpVp) return undefined\n\n const validDescriptorFormat =\n !presentationSubmission ||\n presentationSubmission.descriptor_map.every((descriptor) =>\n [ClaimFormat.DiVc, ClaimFormat.DiVp, ClaimFormat.LdpVc, ClaimFormat.LdpVp].includes(\n descriptor.format as ClaimFormat\n )\n )\n\n const credentialsAreSignedWithAnonCredsW3c = presentationToCreate.verifiableCredentials.every(({ credential }) => {\n const firstCredential = credential.firstCredential\n if (firstCredential.claimFormat !== ClaimFormat.LdpVc) return false\n return firstCredential.anonCredsW3cCredentialCryptosuites.includes(ANONCREDS_W3C_CREDENTIAL_CRYPTOSUITE)\n })\n\n return validDescriptorFormat && credentialsAreSignedWithAnonCredsW3c\n }\n\n private getPresentationSignCallback(agentContext: AgentContext, presentationToCreate: PresentationToCreate) {\n return async (callBackParams: PresentationSignCallBackParams) => {\n // The created partial proof and presentation, as well as original supplied options\n const {\n presentation: presentationInput,\n options,\n presentationDefinition,\n presentationSubmission,\n } = callBackParams\n const { challenge, domain } = options.proofOptions ?? {}\n\n if (!challenge) {\n throw new CredoError('challenge MUST be provided when signing a Verifiable Presentation')\n }\n\n if (presentationToCreate.claimFormat === ClaimFormat.JwtVp) {\n if (!presentationToCreate.subjectIds) {\n throw new DifPresentationExchangeError('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 presentationToCreate.subjectIds[0]\n )\n\n const w3cPresentation = JsonTransformer.fromJSON(presentationInput, W3cPresentation)\n w3cPresentation.holder = verificationMethod.controller\n\n const signedPresentation = await this.w3cCredentialService.signPresentation<ClaimFormat.JwtVp>(agentContext, {\n format: ClaimFormat.JwtVp,\n alg: this.getSigningAlgorithmForJwtVc(presentationDefinition, verificationMethod),\n verificationMethod: verificationMethod.id,\n presentation: w3cPresentation,\n challenge,\n domain,\n })\n\n return signedPresentation.encoded as W3CVerifiablePresentation\n }\n if (presentationToCreate.claimFormat === ClaimFormat.LdpVp) {\n if (this.shouldSignWithAnonCredsW3cService(presentationToCreate, presentationSubmission)) {\n // make sure the descriptors format properties are set correctly\n presentationSubmission.descriptor_map = presentationSubmission.descriptor_map.map((descriptor) => ({\n ...descriptor,\n format: 'di_vp',\n }))\n const anoncredsW3cCredentialService = agentContext.dependencyManager.resolve<IAnonCredsW3cCredentialService>(\n AnonCredsW3cCredentialServiceSymbol\n )\n const presentation = await anoncredsW3cCredentialService.createPresentation(agentContext, {\n presentationDefinition,\n presentationSubmission,\n selectedCredentialRecords: presentationToCreate.verifiableCredentials.map((vc) => vc.credential),\n challenge,\n })\n return {\n ...presentation.toJSON(),\n presentation_submission: presentationSubmission,\n } as unknown as SphereonW3cVerifiablePresentation\n }\n\n if (!presentationToCreate.subjectIds) {\n throw new DifPresentationExchangeError('Cannot create presentation for credentials without subject id')\n }\n // Determine a suitable verification method for the presentation\n const verificationMethod = await this.getVerificationMethodForSubjectId(\n agentContext,\n presentationToCreate.subjectIds[0]\n )\n\n const w3cPresentation = JsonTransformer.fromJSON(presentationInput, W3cPresentation)\n w3cPresentation.holder = verificationMethod.controller\n\n const signedPresentation = await this.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, presentationDefinition, verificationMethod),\n proofPurpose: new purposes.AuthenticationProofPurpose({ challenge, domain }),\n verificationMethod: verificationMethod.id,\n presentation: w3cPresentation,\n challenge,\n domain,\n })\n\n return signedPresentation.encoded as W3CVerifiablePresentation\n }\n if (presentationToCreate.claimFormat === ClaimFormat.SdJwtDc) {\n const sdJwtInput = presentationInput as\n | SdJwtDecodedVerifiableCredential\n | PartialSdJwtDecodedVerifiableCredential\n\n if (!domain) {\n throw new CredoError(\"Missing 'domain' property, unable to set required 'aud' property in SD-JWT KB-JWT\")\n }\n\n const sdJwtVcApi = this.getSdJwtVcApi(agentContext)\n\n // NOTE: we use the kmsKeyId from the first credential. We don't support the new useMode (for single-use credentials) for PEX\n const originalSdJwtVc = sdJwtVcApi.fromCompact(sdJwtInput.compactSdJwtVc)\n originalSdJwtVc.kmsKeyId =\n presentationToCreate.verifiableCredentials[0].credential.credentialInstances[0].kmsKeyId\n\n const sdJwtVc = await sdJwtVcApi.present({\n sdJwtVc: originalSdJwtVc,\n // SD is already handled by PEX, so we presents all keys\n presentationFrame: undefined,\n verifierMetadata: {\n audience: domain,\n nonce: challenge,\n // TODO: we should make this optional\n issuedAt: Math.floor(Date.now() / 1000),\n },\n additionalPayload: presentationToCreate.verifiableCredentials[0].additionalPayload,\n })\n\n return sdJwtVc\n }\n throw new DifPresentationExchangeError(\n 'Only JWT, SD-JWT-VC, JSONLD credentials are supported for a single presentation'\n )\n }\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 DifPresentationExchangeError(\n `Only dids are supported as credentialSubject id. ${subjectId} is not a valid did`\n )\n }\n\n const didDocument = await didsApi.resolveDidDocument(subjectId)\n\n if (!didDocument.authentication || didDocument.authentication.length === 0) {\n throw new DifPresentationExchangeError(\n `No authentication verificationMethods found for did ${subjectId} in did document`\n )\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 /**\n * Queries the wallet for credentials that match the given presentation definition. 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 queryCredentialForPresentationDefinition(\n agentContext: AgentContext,\n presentationDefinition: DifPresentationExchangeDefinition\n ): Promise<Array<SdJwtVcRecord | W3cCredentialRecord | MdocRecord>> {\n const w3cCredentialRepository = agentContext.dependencyManager.resolve(W3cCredentialRepository)\n const w3cQuery: Array<Query<W3cCredentialRecord>> = []\n const sdJwtVcQuery: Array<Query<SdJwtVcRecord>> = []\n const mdocQuery: Array<Query<MdocRecord>> = []\n\n const presentationDefinitionVersion = PEX.definitionVersionDiscovery(presentationDefinition)\n\n if (!presentationDefinitionVersion.version) {\n throw new DifPresentationExchangeError(\n 'Unable to determine the Presentation Exchange version from the presentation definition',\n presentationDefinitionVersion.error ? { additionalMessages: [presentationDefinitionVersion.error] } : {}\n )\n }\n\n // FIXME: in the query we should take into account the supported proof types of the verifier\n // this could help enormously in the amount of credentials we have to retrieve from storage.\n if (presentationDefinitionVersion.version === PEVersion.v1) {\n const pd = presentationDefinition as DifPresentationExchangeDefinitionV1\n\n // The schema.uri can contain either an expanded type, or a context uri\n for (const inputDescriptor of pd.input_descriptors) {\n for (const schema of inputDescriptor.schema) {\n sdJwtVcQuery.push({\n vct: schema.uri,\n })\n w3cQuery.push({\n $or: [{ expandedTypes: [schema.uri] }, { contexts: [schema.uri] }, { types: [schema.uri] }],\n })\n mdocQuery.push({\n docType: inputDescriptor.id,\n })\n }\n }\n } else if (presentationDefinitionVersion.version === PEVersion.v2) {\n // FIXME: As PE version 2 does not have the `schema` anymore, we can't query by schema anymore.\n // We probably need\n // to find some way to do initial filtering, hopefully if there's a filter on the `type` field or something.\n } else {\n throw new DifPresentationExchangeError(\n `Unsupported presentation definition version ${presentationDefinitionVersion.version as unknown as string}`\n )\n }\n\n const allRecords: Array<SdJwtVcRecord | W3cCredentialRecord | MdocRecord> = []\n\n // query the wallet ourselves first to avoid the need to query the pex library for all\n // credentials for every proof request\n const w3cCredentialRecords =\n w3cQuery.length > 0\n ? await w3cCredentialRepository.findByQuery(agentContext, { $or: w3cQuery })\n : await w3cCredentialRepository.getAll(agentContext)\n allRecords.push(...w3cCredentialRecords)\n\n const sdJwtVcApi = this.getSdJwtVcApi(agentContext)\n const sdJwtVcRecords =\n sdJwtVcQuery.length > 0 ? await sdJwtVcApi.findAllByQuery({ $or: sdJwtVcQuery }) : await sdJwtVcApi.getAll()\n allRecords.push(...sdJwtVcRecords)\n\n const mdocApi = this.getMdocApi(agentContext)\n const mdocRecords = mdocQuery.length > 0 ? await mdocApi.findAllByQuery({ $or: mdocQuery }) : await mdocApi.getAll()\n allRecords.push(...mdocRecords)\n\n return allRecords\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DO,IAAM,iCAAN,MAAM,+BAA+B;CAG1C,YAAmB,sBAAoD;EAA5C,KAAA,uBAAA;EAF3B,KAAQ,MAAM,IAAI,IAAI;CAEkD;CAExE,MAAa,yBACX,cACA,wBACsC;EACtC,MAAM,oBAAoB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GAAG,cAAc;EAEjC,MAAM,UAAU,KAAK,WAAW,YAAY;EAC5C,MAAM,cAAc,UAAU,SAAS,IAAI,MAAM,QAAQ,eAAe,EAAE,KAAK,UAAU,CAAC,IAAI,MAAM,QAAQ,OAAO;EACnH,WAAW,KAAK,GAAG,WAAW;EAE9B,OAAO;CACT;CAEA,cAAsB,cAA4B;EAChD,OAAO,aAAa,kBAAkB,QAAQ,UAAU;CAC1D;CAEA,WAAmB,cAA4B;EAC7C,OAAO,aAAa,kBAAkB,QAAQ,OAAO;CACvD;AACF;AA9pBC,iCAAA,WAAA,CAAA,WAAW,GAAA,mBAAA,qBAAA,CAAA,OAAA,yBAAA,cAAA,SAAA,oBAAA,CAAA,CAAA,GAAA,8BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentationSelection.d.mts","names":[],"sources":["../../../../src/modules/dif-presentation-exchange/utils/presentationSelection.ts"],"mappings":";;;;;;;;;;;;;;YAoBY,mCAAmC,kBACtC;wBAEO,kDACd,eAAe,cAAc,yBAC7B,YAAY,mCACZ,YAAY;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"presentationSelection.d.mts","names":[],"sources":["../../../../src/modules/dif-presentation-exchange/utils/presentationSelection.ts"],"mappings":";;;;;;;;;;;;;;YAoBY,mCAAmC,kBACtC;wBAEO,kDACd,eAAe,cAAc,yBAC7B,YAAY,mCACZ,YAAY;;;;;;;;;;;;;;;;WAiFoB,YAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CredoError } from "../../../error/CredoError.mjs";
|
|
2
2
|
import "../../../error/index.mjs";
|
|
3
|
+
import { asArray } from "../../../utils/array.mjs";
|
|
3
4
|
import "../../vc/models/ClaimFormat.mjs";
|
|
4
5
|
import { W3cJwtVerifiablePresentation } from "../../vc/jwt-vc/W3cJwtVerifiablePresentation.mjs";
|
|
5
6
|
import { W3cV2DataIntegrityVerifiablePresentation } from "../../vc/data-integrity/W3cV2DataIntegrityVerifiablePresentation.mjs";
|
|
@@ -17,7 +18,7 @@ function extractPresentationsWithDescriptorsFromSubmission(presentations, submis
|
|
|
17
18
|
return submission.descriptor_map.map((descriptor) => {
|
|
18
19
|
const [presentation] = JSONPath.query(presentations, descriptor.path);
|
|
19
20
|
const inputDescriptor = definition.input_descriptors.find(({ id }) => id === descriptor.id);
|
|
20
|
-
if (!presentation) throw new CredoError(`Unable to extract presentation at path '${descriptor.path}' for submission descriptor '${descriptor.id}'`);
|
|
21
|
+
if (!presentation || !asArray(presentations).includes(presentation)) throw new CredoError(`Unable to extract presentation at path '${descriptor.path}' for submission descriptor '${descriptor.id}'`);
|
|
21
22
|
if (!inputDescriptor) throw new Error(`Unable to extract input descriptor '${descriptor.id}' from definition '${definition.id}' for submission '${submission.id}'`);
|
|
22
23
|
if (presentation instanceof MdocDeviceResponse) {
|
|
23
24
|
const document = presentation.deviceResponse.documents?.find((document) => document.docType === descriptor.id);
|
|
@@ -32,7 +33,9 @@ function extractPresentationsWithDescriptorsFromSubmission(presentations, submis
|
|
|
32
33
|
}
|
|
33
34
|
if (presentation instanceof W3cJwtVerifiablePresentation || presentation instanceof W3cJsonLdVerifiablePresentation) {
|
|
34
35
|
if (!descriptor.path_nested) throw new Error(`Submission descriptor '${descriptor.id}' for submission '${submission.id}' has no 'path_nested' but presentation is format '${presentation.claimFormat}'`);
|
|
35
|
-
const
|
|
36
|
+
const nestedPathRegex = presentation.claimFormat === "jwt_vp" ? /^\$\.vp\.verifiableCredential\[(\d+)\]$/ : /^\$\.verifiableCredential\[(\d+)\]$/;
|
|
37
|
+
const credentialIndex = descriptor.path_nested.path.match(nestedPathRegex)?.[1];
|
|
38
|
+
const verifiableCredential = credentialIndex !== void 0 ? asArray(presentation.verifiableCredential)[Number(credentialIndex)] : void 0;
|
|
36
39
|
if (!verifiableCredential) throw new CredoError(`Unable to extract credential at path '${descriptor.path_nested.path}' from presentation at path '${descriptor.path}' for submission descriptor '${descriptor.id}'`);
|
|
37
40
|
return {
|
|
38
41
|
claimFormat: presentation.claimFormat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentationSelection.mjs","names":[],"sources":["../../../../src/modules/dif-presentation-exchange/utils/presentationSelection.ts"],"sourcesContent":["import { JSONPath } from '@astronautlabs/jsonpath'\nimport { CredoError } from '../../../error'\nimport type { SingleOrArray } from '../../../types'\nimport {
|
|
1
|
+
{"version":3,"file":"presentationSelection.mjs","names":[],"sources":["../../../../src/modules/dif-presentation-exchange/utils/presentationSelection.ts"],"sourcesContent":["import { JSONPath } from '@astronautlabs/jsonpath'\nimport { CredoError } from '../../../error'\nimport type { SingleOrArray } from '../../../types'\nimport { asArray } from '../../../utils/array'\nimport { MdocDeviceResponse } from '../../mdoc'\nimport type { SdJwtVc } from '../../sd-jwt-vc'\nimport {\n ClaimFormat,\n W3cJsonLdVerifiablePresentation,\n W3cJwtVerifiablePresentation,\n W3cV2JwtVerifiablePresentation,\n} from '../../vc'\nimport { W3cV2DataIntegrityVerifiablePresentation } from '../../vc/data-integrity'\nimport { W3cV2SdJwtVerifiablePresentation } from '../../vc/sd-jwt-vc'\nimport type {\n DifPresentationExchangeDefinition,\n DifPresentationExchangeSubmission,\n VerifiablePresentation,\n} from '../models'\n\nexport type DifPexPresentationWithDescriptor = ReturnType<\n typeof extractPresentationsWithDescriptorsFromSubmission\n>[number]\nexport function extractPresentationsWithDescriptorsFromSubmission(\n presentations: SingleOrArray<VerifiablePresentation>,\n submission: DifPresentationExchangeSubmission,\n definition: DifPresentationExchangeDefinition\n) {\n return submission.descriptor_map.map((descriptor) => {\n const [presentation] = JSONPath.query(presentations, descriptor.path) as [VerifiablePresentation | undefined]\n const inputDescriptor = definition.input_descriptors.find(({ id }) => id === descriptor.id)\n\n // The submission comes from the holder, so the path must resolve to one of the presentations, not an object inside one\n if (!presentation || !asArray(presentations).includes(presentation)) {\n throw new CredoError(\n `Unable to extract presentation at path '${descriptor.path}' for submission descriptor '${descriptor.id}'`\n )\n }\n\n if (!inputDescriptor) {\n throw new Error(\n `Unable to extract input descriptor '${descriptor.id}' from definition '${definition.id}' for submission '${submission.id}'`\n )\n }\n\n if (presentation instanceof MdocDeviceResponse) {\n const document = presentation.deviceResponse.documents?.find((document) => document.docType === descriptor.id)\n if (!document) {\n throw new Error(\n `Unable to extract mdoc document with doctype '${descriptor.id}' from mdoc device response for submission '${submission.id}'.`\n )\n }\n\n return {\n claimFormat: ClaimFormat.MsoMdoc,\n descriptor,\n presentation,\n credential: document,\n inputDescriptor,\n } as const\n }\n if (\n presentation instanceof W3cJwtVerifiablePresentation ||\n presentation instanceof W3cJsonLdVerifiablePresentation\n ) {\n if (!descriptor.path_nested) {\n throw new Error(\n `Submission descriptor '${descriptor.id}' for submission '${submission.id}' has no 'path_nested' but presentation is format '${presentation.claimFormat}'`\n )\n }\n\n // Only a direct index into the credentials of the presentation, so the credential is one the presentation contains\n const nestedPathRegex =\n presentation.claimFormat === ClaimFormat.JwtVp\n ? /^\\$\\.vp\\.verifiableCredential\\[(\\d+)\\]$/\n : /^\\$\\.verifiableCredential\\[(\\d+)\\]$/\n const credentialIndex = descriptor.path_nested.path.match(nestedPathRegex)?.[1]\n const verifiableCredential =\n credentialIndex !== undefined ? asArray(presentation.verifiableCredential)[Number(credentialIndex)] : undefined\n\n if (!verifiableCredential) {\n throw new CredoError(\n `Unable to extract credential at path '${descriptor.path_nested.path}' from presentation at path '${descriptor.path}' for submission descriptor '${descriptor.id}'`\n )\n }\n\n return {\n claimFormat: presentation.claimFormat,\n descriptor,\n presentation,\n credential: verifiableCredential,\n inputDescriptor,\n } as const\n }\n if (\n presentation instanceof W3cV2JwtVerifiablePresentation ||\n presentation instanceof W3cV2SdJwtVerifiablePresentation ||\n presentation instanceof W3cV2DataIntegrityVerifiablePresentation\n ) {\n throw new CredoError(\n `Presentation format '${presentation.claimFormat}' is not supported with DIF Presentation Exchange`\n )\n }\n return {\n claimFormat: ClaimFormat.SdJwtDc,\n descriptor,\n presentation,\n credential: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G,EACnK;GAGF,OAAO;IACL,aAAa,aAAa;IAC1B;IACA;IACA,YAAY;IACZ;GACF;EACF;EACA,IACE,wBAAwB,kCACxB,wBAAwB,oCACxB,wBAAwB,0CAExB,MAAM,IAAI,WACR,wBAAwB,aAAa,YAAY,kDACnD;EAEF,OAAO;GACL,aAAA;GACA;GACA;GACA,YAAY;GACZ;EACF;CACF,CAAC;AACH"}
|
|
@@ -73,20 +73,6 @@ 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;
|
|
90
76
|
} | {
|
|
91
77
|
kty: "RSA";
|
|
92
78
|
n: string;
|
|
@@ -119,6 +105,20 @@ export declare class KeyManagementApi {
|
|
|
119
105
|
x5t?: string | undefined;
|
|
120
106
|
'x5t#S256'?: string | undefined;
|
|
121
107
|
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,7 +18,6 @@ export declare const KnownJwaSignatureAlgorithms: {
|
|
|
18
18
|
readonly ES256K: "ES256K";
|
|
19
19
|
};
|
|
20
20
|
export declare const zKnownJwaSignatureAlgorithm: z$1.ZodEnum<{
|
|
21
|
-
Ed25519: "Ed25519";
|
|
22
21
|
HS256: "HS256";
|
|
23
22
|
HS384: "HS384";
|
|
24
23
|
HS512: "HS512";
|
|
@@ -32,6 +31,7 @@ export declare const zKnownJwaSignatureAlgorithm: z$1.ZodEnum<{
|
|
|
32
31
|
PS384: "PS384";
|
|
33
32
|
PS512: "PS512";
|
|
34
33
|
EdDSA: "EdDSA";
|
|
34
|
+
Ed25519: "Ed25519";
|
|
35
35
|
ES256K: "ES256K";
|
|
36
36
|
}>;
|
|
37
37
|
export type KnownJwaSignatureAlgorithm = z$1.output<typeof zKnownJwaSignatureAlgorithm>;
|
|
@@ -49,8 +49,8 @@ export declare const zKmsJwkPublicAsymmetric: z$1.ZodDiscriminatedUnion<[z$1.Zod
|
|
|
49
49
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
50
50
|
kty: z$1.ZodLiteral<"OKP">;
|
|
51
51
|
crv: z$1.ZodEnum<{
|
|
52
|
-
X25519: "X25519";
|
|
53
52
|
Ed25519: "Ed25519";
|
|
53
|
+
X25519: "X25519";
|
|
54
54
|
}>;
|
|
55
55
|
x: z$1.ZodString;
|
|
56
56
|
d: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -122,8 +122,8 @@ export declare const zKmsJwkPublic: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
|
122
122
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
123
123
|
kty: z$1.ZodLiteral<"OKP">;
|
|
124
124
|
crv: z$1.ZodEnum<{
|
|
125
|
-
X25519: "X25519";
|
|
126
125
|
Ed25519: "Ed25519";
|
|
126
|
+
X25519: "X25519";
|
|
127
127
|
}>;
|
|
128
128
|
x: z$1.ZodString;
|
|
129
129
|
d: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -198,8 +198,8 @@ export declare const zKmsJwkPrivate: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
|
198
198
|
d: z$1.ZodString;
|
|
199
199
|
kty: z$1.ZodLiteral<"OKP">;
|
|
200
200
|
crv: z$1.ZodEnum<{
|
|
201
|
-
X25519: "X25519";
|
|
202
201
|
Ed25519: "Ed25519";
|
|
202
|
+
X25519: "X25519";
|
|
203
203
|
}>;
|
|
204
204
|
x: z$1.ZodString;
|
|
205
205
|
kid: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -261,8 +261,8 @@ export declare const zKmsJwkPrivateAsymmetric: z$1.ZodDiscriminatedUnion<[z$1.Zo
|
|
|
261
261
|
d: z$1.ZodString;
|
|
262
262
|
kty: z$1.ZodLiteral<"OKP">;
|
|
263
263
|
crv: z$1.ZodEnum<{
|
|
264
|
-
X25519: "X25519";
|
|
265
264
|
Ed25519: "Ed25519";
|
|
265
|
+
X25519: "X25519";
|
|
266
266
|
}>;
|
|
267
267
|
x: z$1.ZodString;
|
|
268
268
|
kid: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -11,7 +11,7 @@ export declare class P256PublicJwk implements PublicJwkType<Jwk> {
|
|
|
11
11
|
static supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
12
12
|
static multicodecPrefix: number;
|
|
13
13
|
supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
14
|
-
supportedSignatureAlgorithms: ("
|
|
14
|
+
supportedSignatureAlgorithms: ("HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K")[];
|
|
15
15
|
multicodecPrefix: number;
|
|
16
16
|
constructor(jwk: Jwk);
|
|
17
17
|
get publicKey(): {
|
|
@@ -11,7 +11,7 @@ export declare class P384PublicJwk implements PublicJwkType<Jwk> {
|
|
|
11
11
|
static supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
12
12
|
static multicodecPrefix: number;
|
|
13
13
|
supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
14
|
-
supportedSignatureAlgorithms: ("
|
|
14
|
+
supportedSignatureAlgorithms: ("HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K")[];
|
|
15
15
|
multicodecPrefix: number;
|
|
16
16
|
constructor(jwk: Jwk);
|
|
17
17
|
get publicKey(): {
|
|
@@ -11,7 +11,7 @@ export declare class P521PublicJwk implements PublicJwkType<Jwk> {
|
|
|
11
11
|
static supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
12
12
|
static multicodecPrefix: number;
|
|
13
13
|
supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
14
|
-
supportedSignatureAlgorithms: ("
|
|
14
|
+
supportedSignatureAlgorithms: ("HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K")[];
|
|
15
15
|
multicodecPrefix: number;
|
|
16
16
|
constructor(jwk: Jwk);
|
|
17
17
|
get publicKey(): {
|
|
@@ -11,7 +11,7 @@ export declare class Secp256k1PublicJwk implements PublicJwkType<Jwk> {
|
|
|
11
11
|
static supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
12
12
|
static multicodecPrefix: number;
|
|
13
13
|
supportedEncryptionKeyAgreementAlgorithms: "ECDH-ES"[];
|
|
14
|
-
supportedSignatureAlgorithms: ("
|
|
14
|
+
supportedSignatureAlgorithms: ("HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K")[];
|
|
15
15
|
multicodecPrefix: number;
|
|
16
16
|
constructor(jwk: Jwk);
|
|
17
17
|
get publicKey(): {
|
|
@@ -11,7 +11,7 @@ export declare class Ed25519PublicJwk implements PublicJwkType<Jwk> {
|
|
|
11
11
|
static supportedEncryptionKeyAgreementAlgorithms: KnownJwaKeyAgreementAlgorithm[];
|
|
12
12
|
static multicodecPrefix: number;
|
|
13
13
|
supportedEncryptionKeyAgreementAlgorithms: ("ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A192KW" | "ECDH-ES+A256KW" | "ECDH-HSALSA20" | "HPKE-0" | "HPKE-3" | "HPKE-7")[];
|
|
14
|
-
supportedSignatureAlgorithms: ("
|
|
14
|
+
supportedSignatureAlgorithms: ("HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K")[];
|
|
15
15
|
multicodecPrefix: number;
|
|
16
16
|
constructor(jwk: Jwk);
|
|
17
17
|
get publicKey(): {
|
|
@@ -28,7 +28,7 @@ export declare class Ed25519PublicJwk implements PublicJwkType<Jwk> {
|
|
|
28
28
|
static fromMulticodec(multicodec: Uint8Array): Ed25519PublicJwk;
|
|
29
29
|
toX25519PublicJwk(): {
|
|
30
30
|
kty: "OKP";
|
|
31
|
-
crv: "
|
|
31
|
+
crv: "Ed25519" | "X25519";
|
|
32
32
|
x: string;
|
|
33
33
|
d?: string | undefined;
|
|
34
34
|
kid?: string | undefined;
|
|
@@ -11,7 +11,7 @@ export declare class X25519PublicJwk implements PublicJwkType<Jwk> {
|
|
|
11
11
|
static supportedSignatureAlgorithms: KnownJwaSignatureAlgorithm[];
|
|
12
12
|
static multicodecPrefix: number;
|
|
13
13
|
supportedEncryptionKeyAgreementAlgorithms: "ECDH-HSALSA20"[];
|
|
14
|
-
supportedSignatureAlgorithms: ("
|
|
14
|
+
supportedSignatureAlgorithms: ("HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K")[];
|
|
15
15
|
multicodecPrefix: number;
|
|
16
16
|
constructor(jwk: Jwk);
|
|
17
17
|
get publicKey(): {
|
|
@@ -3,8 +3,8 @@ import { z as z$1 } from "zod";
|
|
|
3
3
|
export declare const zKmsJwkPublicOkp: z$1.ZodObject<{
|
|
4
4
|
kty: z$1.ZodLiteral<"OKP">;
|
|
5
5
|
crv: z$1.ZodEnum<{
|
|
6
|
-
X25519: "X25519";
|
|
7
6
|
Ed25519: "Ed25519";
|
|
7
|
+
X25519: "X25519";
|
|
8
8
|
}>;
|
|
9
9
|
x: z$1.ZodString;
|
|
10
10
|
d: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -23,8 +23,8 @@ export declare const zKmsJwkPrivateOkp: z$1.ZodObject<{
|
|
|
23
23
|
d: z$1.ZodString;
|
|
24
24
|
kty: z$1.ZodLiteral<"OKP">;
|
|
25
25
|
crv: z$1.ZodEnum<{
|
|
26
|
-
X25519: "X25519";
|
|
27
26
|
Ed25519: "Ed25519";
|
|
27
|
+
X25519: "X25519";
|
|
28
28
|
}>;
|
|
29
29
|
x: z$1.ZodString;
|
|
30
30
|
kid: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -19,8 +19,8 @@ export type KmsCreateKeyTypeEc = z$1.output<typeof zKmsCreateKeyTypeEc>;
|
|
|
19
19
|
declare const zKmsCreateKeyTypeOkp: z$1.ZodObject<{
|
|
20
20
|
kty: z$1.ZodLiteral<"OKP">;
|
|
21
21
|
crv: z$1.ZodEnum<{
|
|
22
|
-
X25519: "X25519";
|
|
23
22
|
Ed25519: "Ed25519";
|
|
23
|
+
X25519: "X25519";
|
|
24
24
|
}>;
|
|
25
25
|
}, z$1.core.$strip>;
|
|
26
26
|
export type KmsCreateKeyTypeOkp = z$1.output<typeof zKmsCreateKeyTypeOkp>;
|
|
@@ -59,8 +59,8 @@ export declare const zKmsCreateKeyTypeAsymmetric: z$1.ZodUnion<readonly [z$1.Zod
|
|
|
59
59
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
60
60
|
kty: z$1.ZodLiteral<"OKP">;
|
|
61
61
|
crv: z$1.ZodEnum<{
|
|
62
|
-
X25519: "X25519";
|
|
63
62
|
Ed25519: "Ed25519";
|
|
63
|
+
X25519: "X25519";
|
|
64
64
|
}>;
|
|
65
65
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
66
66
|
kty: z$1.ZodLiteral<"RSA">;
|
|
@@ -78,8 +78,8 @@ export declare const zKmsCreateKeyType: z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
|
78
78
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
79
79
|
kty: z$1.ZodLiteral<"OKP">;
|
|
80
80
|
crv: z$1.ZodEnum<{
|
|
81
|
-
X25519: "X25519";
|
|
82
81
|
Ed25519: "Ed25519";
|
|
82
|
+
X25519: "X25519";
|
|
83
83
|
}>;
|
|
84
84
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
85
85
|
kty: z$1.ZodLiteral<"RSA">;
|
|
@@ -3,7 +3,6 @@ import { z as z$1 } from "zod";
|
|
|
3
3
|
export declare const zKmsSignOptions: z$1.ZodObject<{
|
|
4
4
|
keyId: z$1.ZodString;
|
|
5
5
|
algorithm: z$1.ZodEnum<{
|
|
6
|
-
Ed25519: "Ed25519";
|
|
7
6
|
HS256: "HS256";
|
|
8
7
|
HS384: "HS384";
|
|
9
8
|
HS512: "HS512";
|
|
@@ -17,6 +16,7 @@ export declare const zKmsSignOptions: z$1.ZodObject<{
|
|
|
17
16
|
PS384: "PS384";
|
|
18
17
|
PS512: "PS512";
|
|
19
18
|
EdDSA: "EdDSA";
|
|
19
|
+
Ed25519: "Ed25519";
|
|
20
20
|
ES256K: "ES256K";
|
|
21
21
|
}>;
|
|
22
22
|
data: z$1.ZodInstanceOf<Uint8Array<ArrayBufferLike>>;
|
|
@@ -49,8 +49,8 @@ export declare const zKmsVerifyOptions: z$1.ZodObject<{
|
|
|
49
49
|
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
50
50
|
kty: z$1.ZodLiteral<"OKP">;
|
|
51
51
|
crv: z$1.ZodEnum<{
|
|
52
|
-
X25519: "X25519";
|
|
53
52
|
Ed25519: "Ed25519";
|
|
53
|
+
X25519: "X25519";
|
|
54
54
|
}>;
|
|
55
55
|
x: z$1.ZodString;
|
|
56
56
|
d: z$1.ZodOptional<z$1.ZodString>;
|
|
@@ -67,7 +67,6 @@ export declare const zKmsVerifyOptions: z$1.ZodObject<{
|
|
|
67
67
|
keyId: z$1.ZodOptional<z$1.ZodNever>;
|
|
68
68
|
}, z$1.core.$strip>]>;
|
|
69
69
|
algorithm: z$1.ZodEnum<{
|
|
70
|
-
Ed25519: "Ed25519";
|
|
71
70
|
HS256: "HS256";
|
|
72
71
|
HS384: "HS384";
|
|
73
72
|
HS512: "HS512";
|
|
@@ -81,6 +80,7 @@ export declare const zKmsVerifyOptions: z$1.ZodObject<{
|
|
|
81
80
|
PS384: "PS384";
|
|
82
81
|
PS512: "PS512";
|
|
83
82
|
EdDSA: "EdDSA";
|
|
83
|
+
Ed25519: "Ed25519";
|
|
84
84
|
ES256K: "ES256K";
|
|
85
85
|
}>;
|
|
86
86
|
data: z$1.ZodInstanceOf<Uint8Array<ArrayBufferLike>>;
|
|
@@ -58,7 +58,7 @@ export declare class MdocRecord extends BaseRecord<DefaultMdocRecordTags> {
|
|
|
58
58
|
static fromMdoc(mdoc: Mdoc): MdocRecord;
|
|
59
59
|
getTags(): {
|
|
60
60
|
docType: string;
|
|
61
|
-
alg: "
|
|
61
|
+
alg: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K";
|
|
62
62
|
multiInstanceState: CredentialMultiInstanceState;
|
|
63
63
|
};
|
|
64
64
|
clone(): this;
|
|
@@ -89,7 +89,7 @@ export declare class SdJwtVcRecord extends BaseRecord<DefaultSdJwtVcRecordTags>
|
|
|
89
89
|
vct: string;
|
|
90
90
|
extendedVctValues: string[];
|
|
91
91
|
sdAlg: string;
|
|
92
|
-
alg: "
|
|
92
|
+
alg: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | "Ed25519" | "ES256K";
|
|
93
93
|
multiInstanceState: CredentialMultiInstanceState;
|
|
94
94
|
};
|
|
95
95
|
clone(): this;
|
|
@@ -20,7 +20,7 @@ export declare class W3cV2EnvelopedVerifiableCredential {
|
|
|
20
20
|
/**
|
|
21
21
|
* Gets the enveloped credential.
|
|
22
22
|
*/
|
|
23
|
-
get envelopedCredential():
|
|
23
|
+
get envelopedCredential(): W3cV2SdJwtVerifiableCredential | W3cV2JwtVerifiableCredential;
|
|
24
24
|
/**
|
|
25
25
|
* Resolved credential is the fully resolved {@link W3cV2Credential} instance.
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"W3cV2EnvelopedVerifiableCredential.d.mts","names":[],"sources":["../../../../../src/modules/vc/models/credential/W3cV2EnvelopedVerifiableCredential.ts"],"mappings":";;;;;;;iBAWiB;EACf;EACA,mBAAmB,eAAe;EAClC,OAAO;;qBAGI;UAEH;EAEW,YAAA,SAAS;SASd,yBACZ,YAAY,iCAAiC,+BAC5C;EAUI,kBAAmB,eAAe;EAGlC;EAGA,MAAO;;;;MAKH,uBAAmB
|
|
1
|
+
{"version":3,"file":"W3cV2EnvelopedVerifiableCredential.d.mts","names":[],"sources":["../../../../../src/modules/vc/models/credential/W3cV2EnvelopedVerifiableCredential.ts"],"mappings":";;;;;;;iBAWiB;EACf;EACA,mBAAmB,eAAe;EAClC,OAAO;;qBAGI;UAEH;EAEW,YAAA,SAAS;SASd,yBACZ,YAAY,iCAAiC,+BAC5C;EAUI,kBAAmB,eAAe;EAGlC;EAGA,MAAO;;;;MAKH,uBAAmB,iCAAA;;;;MAWnB,sBAAsB;;;;MAOtB,eAAe,YAAY,aAAa,YAAY;;wBAMjD,qCACd,iBACC,SAAS;wBAyBI,iDAA6C;wBAgB7C,oCAAoC,oBAAoB,oBAAoB"}
|
|
@@ -6,7 +6,7 @@ import "../../sd-jwt-vc/index.mjs";
|
|
|
6
6
|
import "../../jwt-vc/index.mjs";
|
|
7
7
|
import "../../data-integrity/index.mjs";
|
|
8
8
|
//#region src/modules/vc/models/credential/W3cV2VerifiableCredential.d.ts
|
|
9
|
-
export declare const decodeW3cV2VerifiableCredential: (v: unknown) => W3cV2DataIntegrityVerifiableCredential |
|
|
9
|
+
export declare const decodeW3cV2VerifiableCredential: (v: unknown) => W3cV2DataIntegrityVerifiableCredential | W3cV2SdJwtVerifiableCredential | W3cV2JwtVerifiableCredential;
|
|
10
10
|
export declare function W3cV2VerifiableCredentialTransformer(): PropertyDecorator;
|
|
11
11
|
/**
|
|
12
12
|
* A Secured W3C Verifiable Credential (VC) as defined in the W3C VC Data Model 2.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"W3cV2VerifiableCredential.d.mts","names":[],"sources":["../../../../../src/modules/vc/models/credential/W3cV2VerifiableCredential.ts"],"mappings":";;;;;;;;qBAaa,kCAAmC,eAAU,yCAAA
|
|
1
|
+
{"version":3,"file":"W3cV2VerifiableCredential.d.mts","names":[],"sources":["../../../../../src/modules/vc/models/credential/W3cV2VerifiableCredential.ts"],"mappings":";;;;;;;;qBAaa,kCAAmC,eAAU,yCAAA,iCAAA;wBAoE1C,wCAAoC;;;;;;;;;;;;;;YA6BxC,0BACV,eAAe,YAAY,WAAW,YAAY,aAAa,YAAY,4BACzE,eAAe,YAAY,WAC3B,+BACA,eAAe,YAAY,aACzB,iCACA,eAAe,YAAY,OACzB,yCACA,+BAA+B,iCAAiC;YAE5D,iCACV,eAAe,YAAY,WAAW,YAAY,aAAa,YAAY,4BACzE,eAAe,YAAY,WAC3B,sCACA,eAAe,YAAY,aACzB,wCACA,eAAe,YAAY,OACzB,gDAEI,sCACA,wCACA"}
|