@credo-ts/core 0.6.0-pr-2102-20241124110714 → 0.6.0-pr-2094-20241124155338
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/modules/dif-presentation-exchange/DifPresentationExchangeService.d.ts +1 -1
- package/build/modules/dif-presentation-exchange/DifPresentationExchangeService.js +1 -1
- package/build/modules/dif-presentation-exchange/models/index.d.ts +1 -1
- package/build/modules/dif-presentation-exchange/models/index.js +1 -1
- package/build/modules/dif-presentation-exchange/utils/credentialSelection.d.ts +1 -1
- package/build/modules/dif-presentation-exchange/utils/credentialSelection.js +84 -96
- package/build/modules/dif-presentation-exchange/utils/credentialSelection.js.map +1 -1
- package/build/modules/dif-presentation-exchange/utils/presentationSelection.js +3 -6
- package/build/modules/dif-presentation-exchange/utils/presentationSelection.js.map +1 -1
- package/build/modules/dif-presentation-exchange/utils/transform.d.ts +2 -2
- package/build/modules/dif-presentation-exchange/utils/transform.js +3 -0
- package/build/modules/dif-presentation-exchange/utils/transform.js.map +1 -1
- package/package.json +3 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DifPexCredentialsForRequest, DifPexInputDescriptorToCredentials, DifPresentationExchangeDefinition, DifPresentationExchangeSubmission, VerifiablePresentation } from './models';
|
|
2
2
|
import type { AgentContext } from '../../agent';
|
|
3
|
-
import { PresentationSubmissionLocation } from '@
|
|
3
|
+
import { PresentationSubmissionLocation } from '@animo-id/pex';
|
|
4
4
|
import { MdocOpenId4VpSessionTranscriptOptions } from '../mdoc';
|
|
5
5
|
import { MdocDeviceResponse } from '../mdoc/MdocDeviceResponse';
|
|
6
6
|
import { W3cCredentialService } from '../vc';
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.DifPresentationExchangeService = void 0;
|
|
13
|
-
const pex_1 = require("@
|
|
13
|
+
const pex_1 = require("@animo-id/pex");
|
|
14
14
|
const tsyringe_1 = require("tsyringe");
|
|
15
15
|
const crypto_1 = require("../../crypto");
|
|
16
16
|
const error_1 = require("../../error");
|
|
@@ -3,7 +3,7 @@ import type { Mdoc, MdocDeviceResponse } from '../../mdoc';
|
|
|
3
3
|
import type { SdJwtVc } from '../../sd-jwt-vc';
|
|
4
4
|
import type { W3cVerifiableCredential, W3cVerifiablePresentation } from '../../vc';
|
|
5
5
|
import type { PresentationDefinitionV1, PresentationDefinitionV2, PresentationSubmission } from '@sphereon/pex-models';
|
|
6
|
-
import { PresentationSubmissionLocation } from '@
|
|
6
|
+
import { PresentationSubmissionLocation } from '@animo-id/pex';
|
|
7
7
|
export type DifPresentationExchangeDefinition = PresentationDefinitionV1 | PresentationDefinitionV2;
|
|
8
8
|
export type DifPresentationExchangeDefinitionV1 = PresentationDefinitionV1;
|
|
9
9
|
export type DifPresentationExchangeDefinitionV2 = PresentationDefinitionV2;
|
|
@@ -16,6 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.DifPresentationExchangeSubmissionLocation = void 0;
|
|
18
18
|
__exportStar(require("./DifPexCredentialsForRequest"), exports);
|
|
19
|
-
const pex_1 = require("@
|
|
19
|
+
const pex_1 = require("@animo-id/pex");
|
|
20
20
|
Object.defineProperty(exports, "DifPresentationExchangeSubmissionLocation", { enumerable: true, get: function () { return pex_1.PresentationSubmissionLocation; } });
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DifPexCredentialsForRequest } from '../models';
|
|
2
|
-
import type { IPresentationDefinition, PEX } from '@
|
|
2
|
+
import type { IPresentationDefinition, PEX } from '@animo-id/pex';
|
|
3
3
|
import { MdocRecord } from '../../mdoc';
|
|
4
4
|
import { SdJwtVcRecord } from '../../sd-jwt-vc';
|
|
5
5
|
import { W3cCredentialRecord } from '../../vc';
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getCredentialsForRequest = getCredentialsForRequest;
|
|
4
|
+
const pex_1 = require("@animo-id/pex");
|
|
5
|
+
const core_1 = require("@animo-id/pex/dist/main/lib/evaluation/core");
|
|
6
|
+
const jsonpath_1 = require("@astronautlabs/jsonpath");
|
|
7
7
|
const decode_1 = require("@sd-jwt/decode");
|
|
8
|
-
const pex_1 = require("@sphereon/pex");
|
|
9
|
-
const core_1 = require("@sphereon/pex/dist/main/lib/evaluation/core");
|
|
10
8
|
const pex_models_1 = require("@sphereon/pex-models");
|
|
11
|
-
const jsonpath_1 = __importDefault(require("jsonpath"));
|
|
12
9
|
const crypto_1 = require("../../../crypto");
|
|
13
10
|
const error_1 = require("../../../error");
|
|
14
|
-
const utils_1 = require("../../../utils");
|
|
15
11
|
const mdoc_1 = require("../../mdoc");
|
|
16
12
|
const Mdoc_1 = require("../../mdoc/Mdoc");
|
|
17
13
|
const MdocDeviceResponse_1 = require("../../mdoc/MdocDeviceResponse");
|
|
@@ -22,35 +18,15 @@ const transform_1 = require("./transform");
|
|
|
22
18
|
async function getCredentialsForRequest(
|
|
23
19
|
// PEX instance with hasher defined
|
|
24
20
|
pex, presentationDefinition, credentialRecords) {
|
|
25
|
-
var _a;
|
|
26
|
-
const encodedCredentials = credentialRecords
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
: selectResultsRaw.areRequiredCredentialsPresent,
|
|
35
|
-
// Map the encoded credential to their respective w3c credential record
|
|
36
|
-
verifiableCredential: (_a = selectResultsRaw.verifiableCredential) === null || _a === void 0 ? void 0 : _a.map((selectedEncoded) => {
|
|
37
|
-
const credentialRecordIndex = encodedCredentials.findIndex((encoded) => {
|
|
38
|
-
if (typeof selectedEncoded === 'string' &&
|
|
39
|
-
selectedEncoded.includes('~') &&
|
|
40
|
-
typeof encoded === 'string' &&
|
|
41
|
-
encoded.includes('~')) {
|
|
42
|
-
// FIXME: pex applies SD-JWT, so we actually can't match the record anymore :(
|
|
43
|
-
// We take the first part of the sd-jwt, as that will never change, and should
|
|
44
|
-
// be unique on it's own
|
|
45
|
-
const [encodedJwt] = encoded.split('~');
|
|
46
|
-
const [selectedEncodedJwt] = selectedEncoded.split('~');
|
|
47
|
-
return encodedJwt === selectedEncodedJwt;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return (0, utils_1.deepEquality)(selectedEncoded, encoded);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
if (credentialRecordIndex === -1) {
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
|
+
const encodedCredentials = credentialRecords.map(transform_1.getSphereonOriginalVerifiableCredential);
|
|
23
|
+
const selectResultsRaw = pex.selectFrom(presentationDefinition, encodedCredentials);
|
|
24
|
+
const selectResults = Object.assign(Object.assign({}, selectResultsRaw), { matches: (_a = selectResultsRaw.matches) !== null && _a !== void 0 ? _a : [],
|
|
25
|
+
// Map the encoded credential to their respective credential record
|
|
26
|
+
verifiableCredential: (_c = (_b = selectResultsRaw.verifiableCredential) === null || _b === void 0 ? void 0 : _b.map((selectedEncoded, index) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const credentialRecordIndex = (_a = selectResultsRaw.vcIndexes) === null || _a === void 0 ? void 0 : _a[index];
|
|
29
|
+
if (credentialRecordIndex === undefined || credentialRecordIndex === -1) {
|
|
54
30
|
throw new DifPresentationExchangeError_1.DifPresentationExchangeError('Unable to find credential in credential records.');
|
|
55
31
|
}
|
|
56
32
|
const credentialRecord = credentialRecords[credentialRecordIndex];
|
|
@@ -65,6 +41,13 @@ pex, presentationDefinition, credentialRecords) {
|
|
|
65
41
|
disclosedPayload: prettyClaims,
|
|
66
42
|
};
|
|
67
43
|
}
|
|
44
|
+
else if (credentialRecord instanceof mdoc_1.MdocRecord) {
|
|
45
|
+
return {
|
|
46
|
+
type: vc_1.ClaimFormat.MsoMdoc,
|
|
47
|
+
credentialRecord,
|
|
48
|
+
disclosedPayload: {},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
68
51
|
else if (credentialRecord instanceof vc_1.W3cCredentialRecord) {
|
|
69
52
|
return {
|
|
70
53
|
type: credentialRecord.credential.claimFormat,
|
|
@@ -74,39 +57,7 @@ pex, presentationDefinition, credentialRecords) {
|
|
|
74
57
|
else {
|
|
75
58
|
throw new error_1.CredoError(`Unrecognized credential record type`);
|
|
76
59
|
}
|
|
77
|
-
}) });
|
|
78
|
-
const mdocRecords = credentialRecords.filter((c) => c instanceof mdoc_1.MdocRecord);
|
|
79
|
-
for (const mdocInputDescriptor of mdocPresentationDefinition.input_descriptors) {
|
|
80
|
-
if (!selectResults.verifiableCredential)
|
|
81
|
-
selectResults.verifiableCredential = [];
|
|
82
|
-
if (!selectResults.matches)
|
|
83
|
-
selectResults.matches = [];
|
|
84
|
-
const mdocRecordsMatchingId = mdocRecords.filter((mdocRecord) => mdocRecord.getTags().docType === mdocInputDescriptor.id);
|
|
85
|
-
const submissionRequirementMatch = {
|
|
86
|
-
id: mdocInputDescriptor.id,
|
|
87
|
-
type: core_1.SubmissionRequirementMatchType.InputDescriptor,
|
|
88
|
-
name: mdocInputDescriptor.id,
|
|
89
|
-
rule: pex_models_1.Rules.Pick,
|
|
90
|
-
vc_path: [],
|
|
91
|
-
};
|
|
92
|
-
for (const mdocRecordMatchingId of mdocRecordsMatchingId) {
|
|
93
|
-
selectResults.verifiableCredential.push({
|
|
94
|
-
type: vc_1.ClaimFormat.MsoMdoc,
|
|
95
|
-
credentialRecord: mdocRecordMatchingId,
|
|
96
|
-
disclosedPayload: MdocDeviceResponse_1.MdocDeviceResponse.limitDisclosureToInputDescriptor({
|
|
97
|
-
mdoc: Mdoc_1.Mdoc.fromBase64Url(mdocRecordMatchingId.base64Url),
|
|
98
|
-
inputDescriptor: mdocInputDescriptor,
|
|
99
|
-
}),
|
|
100
|
-
});
|
|
101
|
-
submissionRequirementMatch.vc_path.push(`$.verifiableCredential[${selectResults.verifiableCredential.length - 1}]`);
|
|
102
|
-
}
|
|
103
|
-
if (submissionRequirementMatch.vc_path.length >= 1) {
|
|
104
|
-
selectResults.matches.push(submissionRequirementMatch);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
selectResultsRaw.areRequiredCredentialsPresent = 'error';
|
|
108
|
-
}
|
|
109
|
-
}
|
|
60
|
+
})) !== null && _c !== void 0 ? _c : [] });
|
|
110
61
|
const presentationSubmission = {
|
|
111
62
|
requirements: [],
|
|
112
63
|
areRequirementsSatisfied: false,
|
|
@@ -120,13 +71,48 @@ pex, presentationDefinition, credentialRecords) {
|
|
|
120
71
|
else {
|
|
121
72
|
presentationSubmission.requirements = getSubmissionRequirements(presentationDefinition, selectResults);
|
|
122
73
|
}
|
|
74
|
+
const allEntries = presentationSubmission.requirements.flatMap((requirement) => requirement.submissionEntry);
|
|
75
|
+
const inputDescriptorsForMdocCredential = new Map();
|
|
76
|
+
for (const entry of allEntries)
|
|
77
|
+
for (const verifiableCredential of entry.verifiableCredentials) {
|
|
78
|
+
if (verifiableCredential.type !== vc_1.ClaimFormat.MsoMdoc)
|
|
79
|
+
continue;
|
|
80
|
+
const set = (_d = inputDescriptorsForMdocCredential.get(verifiableCredential)) !== null && _d !== void 0 ? _d : new Set();
|
|
81
|
+
set.add(entry.inputDescriptorId);
|
|
82
|
+
inputDescriptorsForMdocCredential.set(verifiableCredential, set);
|
|
83
|
+
}
|
|
84
|
+
// NOTE: it might be better to apply disclosure per credential/match (as that's also how mdoc does this)
|
|
85
|
+
// however this doesn't work very well in wallets, as you usually won't show the same credential twice with
|
|
86
|
+
// different disclosed attributes
|
|
87
|
+
// Apply limit disclosure for all mdocs
|
|
88
|
+
for (const [verifiableCredential, inputDescriptorIds] of inputDescriptorsForMdocCredential.entries()) {
|
|
89
|
+
if (verifiableCredential.type !== vc_1.ClaimFormat.MsoMdoc)
|
|
90
|
+
continue;
|
|
91
|
+
const inputDescriptorsForCredential = presentationDefinition.input_descriptors.filter(({ id }) => inputDescriptorIds.has(id));
|
|
92
|
+
const mdoc = Mdoc_1.Mdoc.fromBase64Url(verifiableCredential.credentialRecord.base64Url);
|
|
93
|
+
verifiableCredential.disclosedPayload = MdocDeviceResponse_1.MdocDeviceResponse.limitDisclosureToInputDescriptor({
|
|
94
|
+
inputDescriptor: {
|
|
95
|
+
id: mdoc.docType,
|
|
96
|
+
format: {
|
|
97
|
+
mso_mdoc: {
|
|
98
|
+
alg: [],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
constraints: {
|
|
102
|
+
limit_disclosure: 'required',
|
|
103
|
+
fields: inputDescriptorsForCredential.flatMap((i) => { var _a, _b; return (_b = (_a = i.constraints) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : []; }),
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
mdoc: Mdoc_1.Mdoc.fromBase64Url(verifiableCredential.credentialRecord.base64Url),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
123
109
|
// There may be no requirements if we filter out all optional ones. To not makes things too complicated, we see it as an error
|
|
124
110
|
// for now if a request is made that has no required requirements (but only e.g. min: 0, which means we don't need to disclose anything)
|
|
125
111
|
// I see this more as the fault of the presentation definition, as it should have at least some requirements.
|
|
126
112
|
if (presentationSubmission.requirements.length === 0) {
|
|
127
113
|
throw new DifPresentationExchangeError_1.DifPresentationExchangeError('Presentation Definition does not require any credentials. Optional credentials are not included in the presentation submission.');
|
|
128
114
|
}
|
|
129
|
-
if (selectResults.areRequiredCredentialsPresent ===
|
|
115
|
+
if (selectResults.areRequiredCredentialsPresent === pex_1.Status.ERROR) {
|
|
130
116
|
return presentationSubmission;
|
|
131
117
|
}
|
|
132
118
|
return Object.assign(Object.assign({}, presentationSubmission), {
|
|
@@ -136,9 +122,13 @@ pex, presentationDefinition, credentialRecords) {
|
|
|
136
122
|
function getSubmissionRequirements(presentationDefinition, selectResults) {
|
|
137
123
|
var _a;
|
|
138
124
|
const submissionRequirements = [];
|
|
125
|
+
const matches = selectResults.matches;
|
|
126
|
+
if (!matches.every((match) => match.type === core_1.SubmissionRequirementMatchType.SubmissionRequirement && match.from)) {
|
|
127
|
+
throw new DifPresentationExchangeError_1.DifPresentationExchangeError(`Expected all matches to be of type '${core_1.SubmissionRequirementMatchType.SubmissionRequirement}' with 'from' key.`);
|
|
128
|
+
}
|
|
139
129
|
// There are submission requirements, so we need to select the input_descriptors
|
|
140
130
|
// based on the submission requirements
|
|
141
|
-
|
|
131
|
+
(_a = presentationDefinition.submission_requirements) === null || _a === void 0 ? void 0 : _a.forEach((submissionRequirement, submissionRequirementIndex) => {
|
|
142
132
|
// Check: if the submissionRequirement uses `from_nested`, as we don't support this yet
|
|
143
133
|
if (submissionRequirement.from_nested) {
|
|
144
134
|
throw new DifPresentationExchangeError_1.DifPresentationExchangeError("Presentation definition contains requirement using 'from_nested', which is not supported yet.");
|
|
@@ -147,15 +137,19 @@ function getSubmissionRequirements(presentationDefinition, selectResults) {
|
|
|
147
137
|
if (!submissionRequirement.from) {
|
|
148
138
|
throw new DifPresentationExchangeError_1.DifPresentationExchangeError("Missing 'from' in submission requirement match");
|
|
149
139
|
}
|
|
140
|
+
const match = matches.find((match) => match.id === submissionRequirementIndex);
|
|
141
|
+
if (!match) {
|
|
142
|
+
throw new Error(`Unable to find a match for submission requirement with index '${submissionRequirementIndex}'`);
|
|
143
|
+
}
|
|
150
144
|
if (submissionRequirement.rule === pex_models_1.Rules.All) {
|
|
151
|
-
const selectedSubmission = getSubmissionRequirementRuleAll(submissionRequirement, presentationDefinition, selectResults);
|
|
145
|
+
const selectedSubmission = getSubmissionRequirementRuleAll(submissionRequirement, presentationDefinition, selectResults.verifiableCredential, match);
|
|
152
146
|
submissionRequirements.push(selectedSubmission);
|
|
153
147
|
}
|
|
154
148
|
else {
|
|
155
|
-
const selectedSubmission = getSubmissionRequirementRulePick(submissionRequirement, presentationDefinition, selectResults);
|
|
149
|
+
const selectedSubmission = getSubmissionRequirementRulePick(submissionRequirement, presentationDefinition, selectResults.verifiableCredential, match);
|
|
156
150
|
submissionRequirements.push(selectedSubmission);
|
|
157
151
|
}
|
|
158
|
-
}
|
|
152
|
+
});
|
|
159
153
|
// Submission may have requirement that doesn't require a credential to be submitted (e.g. min: 0)
|
|
160
154
|
// We use minimization strategy, and thus only disclose the minimum amount of information
|
|
161
155
|
const requirementsWithCredentials = submissionRequirements.filter((requirement) => requirement.needsCount > 0);
|
|
@@ -163,8 +157,12 @@ function getSubmissionRequirements(presentationDefinition, selectResults) {
|
|
|
163
157
|
}
|
|
164
158
|
function getSubmissionRequirementsForAllInputDescriptors(inputDescriptors, selectResults) {
|
|
165
159
|
const submissionRequirements = [];
|
|
160
|
+
const matches = selectResults.matches;
|
|
161
|
+
if (!matches.every((match) => match.type === core_1.SubmissionRequirementMatchType.InputDescriptor)) {
|
|
162
|
+
throw new DifPresentationExchangeError_1.DifPresentationExchangeError(`Expected all matches to be of type '${core_1.SubmissionRequirementMatchType.InputDescriptor}' when.`);
|
|
163
|
+
}
|
|
166
164
|
for (const inputDescriptor of inputDescriptors) {
|
|
167
|
-
const submission = getSubmissionForInputDescriptor(inputDescriptor, selectResults);
|
|
165
|
+
const submission = getSubmissionForInputDescriptor(inputDescriptor, selectResults.verifiableCredential, matches);
|
|
168
166
|
submissionRequirements.push({
|
|
169
167
|
rule: pex_models_1.Rules.Pick,
|
|
170
168
|
needsCount: 1, // Every input descriptor is a distinct requirement, so the count is always 1,
|
|
@@ -174,7 +172,7 @@ function getSubmissionRequirementsForAllInputDescriptors(inputDescriptors, selec
|
|
|
174
172
|
}
|
|
175
173
|
return submissionRequirements;
|
|
176
174
|
}
|
|
177
|
-
function getSubmissionRequirementRuleAll(submissionRequirement, presentationDefinition,
|
|
175
|
+
function getSubmissionRequirementRuleAll(submissionRequirement, presentationDefinition, verifiableCredentials, match) {
|
|
178
176
|
var _a;
|
|
179
177
|
// Check if there's a 'from'. If not the structure is not as we expect it
|
|
180
178
|
if (!submissionRequirement.from)
|
|
@@ -189,9 +187,9 @@ function getSubmissionRequirementRuleAll(submissionRequirement, presentationDefi
|
|
|
189
187
|
};
|
|
190
188
|
for (const inputDescriptor of presentationDefinition.input_descriptors) {
|
|
191
189
|
// We only want to get the submission if the input descriptor belongs to the group
|
|
192
|
-
if (!((_a = inputDescriptor.group) === null || _a === void 0 ? void 0 : _a.includes(
|
|
190
|
+
if (!((_a = inputDescriptor.group) === null || _a === void 0 ? void 0 : _a.includes(match.from)))
|
|
193
191
|
continue;
|
|
194
|
-
const submission = getSubmissionForInputDescriptor(inputDescriptor,
|
|
192
|
+
const submission = getSubmissionForInputDescriptor(inputDescriptor, verifiableCredentials, match.input_descriptors);
|
|
195
193
|
// Rule ALL, so for every input descriptor that matches in this group, we need to add it
|
|
196
194
|
selectedSubmission.needsCount += 1;
|
|
197
195
|
selectedSubmission.submissionEntry.push(submission);
|
|
@@ -200,7 +198,7 @@ function getSubmissionRequirementRuleAll(submissionRequirement, presentationDefi
|
|
|
200
198
|
// If all submissions have a credential, the requirement is satisfied
|
|
201
199
|
isRequirementSatisfied: selectedSubmission.submissionEntry.every((submission) => submission.verifiableCredentials.length >= 1) });
|
|
202
200
|
}
|
|
203
|
-
function getSubmissionRequirementRulePick(submissionRequirement, presentationDefinition,
|
|
201
|
+
function getSubmissionRequirementRulePick(submissionRequirement, presentationDefinition, verifiableCredentials, match) {
|
|
204
202
|
var _a, _b, _c;
|
|
205
203
|
// Check if there's a 'from'. If not the structure is not as we expect it
|
|
206
204
|
if (!submissionRequirement.from) {
|
|
@@ -220,9 +218,9 @@ function getSubmissionRequirementRulePick(submissionRequirement, presentationDef
|
|
|
220
218
|
const unsatisfiedSubmissions = [];
|
|
221
219
|
for (const inputDescriptor of presentationDefinition.input_descriptors) {
|
|
222
220
|
// We only want to get the submission if the input descriptor belongs to the group
|
|
223
|
-
if (!((_c = inputDescriptor.group) === null || _c === void 0 ? void 0 : _c.includes(
|
|
221
|
+
if (!((_c = inputDescriptor.group) === null || _c === void 0 ? void 0 : _c.includes(match.from)))
|
|
224
222
|
continue;
|
|
225
|
-
const submission = getSubmissionForInputDescriptor(inputDescriptor,
|
|
223
|
+
const submission = getSubmissionForInputDescriptor(inputDescriptor, verifiableCredentials, match.input_descriptors);
|
|
226
224
|
if (submission.verifiableCredentials.length >= 1) {
|
|
227
225
|
satisfiedSubmissions.push(submission);
|
|
228
226
|
}
|
|
@@ -243,33 +241,23 @@ function getSubmissionRequirementRulePick(submissionRequirement, presentationDef
|
|
|
243
241
|
? satisfiedSubmissions
|
|
244
242
|
: [...satisfiedSubmissions, ...unsatisfiedSubmissions] });
|
|
245
243
|
}
|
|
246
|
-
function getSubmissionForInputDescriptor(inputDescriptor,
|
|
247
|
-
|
|
248
|
-
// https://github.com/Sphereon-Opensource/PEX/issues/116
|
|
249
|
-
// If the input descriptor doesn't contain a name, the name of the match will be the id of the input descriptor that satisfied it
|
|
250
|
-
const matchesForInputDescriptor = (_a = selectResults.matches) === null || _a === void 0 ? void 0 : _a.filter((m) => m.name === inputDescriptor.id ||
|
|
251
|
-
// FIXME: this is not collision proof as the name doesn't have to be unique
|
|
252
|
-
m.name === inputDescriptor.name);
|
|
244
|
+
function getSubmissionForInputDescriptor(inputDescriptor, verifiableCredentials, matches) {
|
|
245
|
+
const matchesForInputDescriptor = matches.filter((m) => m.id === inputDescriptor.id);
|
|
253
246
|
const submissionEntry = {
|
|
254
247
|
inputDescriptorId: inputDescriptor.id,
|
|
255
248
|
name: inputDescriptor.name,
|
|
256
249
|
purpose: inputDescriptor.purpose,
|
|
257
|
-
verifiableCredentials:
|
|
250
|
+
verifiableCredentials: matchesForInputDescriptor.flatMap((matchForInputDescriptor) => extractCredentialsFromInputDescriptorMatch(matchForInputDescriptor, verifiableCredentials)),
|
|
258
251
|
};
|
|
259
252
|
// return early if no matches.
|
|
260
253
|
if (!(matchesForInputDescriptor === null || matchesForInputDescriptor === void 0 ? void 0 : matchesForInputDescriptor.length))
|
|
261
254
|
return submissionEntry;
|
|
262
|
-
// FIXME: This can return multiple credentials for multiple input_descriptors,
|
|
263
|
-
// which I think is a bug in the PEX library
|
|
264
|
-
// Extract all credentials from the match
|
|
265
|
-
const verifiableCredentials = matchesForInputDescriptor.flatMap((matchForInputDescriptor) => extractCredentialsFromMatch(matchForInputDescriptor, selectResults.verifiableCredential));
|
|
266
|
-
submissionEntry.verifiableCredentials = verifiableCredentials;
|
|
267
255
|
return submissionEntry;
|
|
268
256
|
}
|
|
269
|
-
function
|
|
257
|
+
function extractCredentialsFromInputDescriptorMatch(match, availableCredentials) {
|
|
270
258
|
const verifiableCredentials = [];
|
|
271
259
|
for (const vcPath of match.vc_path) {
|
|
272
|
-
const [verifiableCredential] = jsonpath_1.
|
|
260
|
+
const [verifiableCredential] = jsonpath_1.JSONPath.query({ verifiableCredential: availableCredentials }, vcPath);
|
|
273
261
|
verifiableCredentials.push(verifiableCredential);
|
|
274
262
|
}
|
|
275
263
|
return verifiableCredentials;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentialSelection.js","sourceRoot":"","sources":["../../../../src/modules/dif-presentation-exchange/utils/credentialSelection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentialSelection.js","sourceRoot":"","sources":["../../../../src/modules/dif-presentation-exchange/utils/credentialSelection.ts"],"names":[],"mappings":";;AA8BA,4DA+HC;AAhJD,uCAAsC;AACtC,sEAA4F;AAC5F,sDAAkD;AAClD,2CAA+D;AAC/D,qDAA4C;AAE5C,4CAAwC;AACxC,0CAA2C;AAC3C,qCAAuC;AACvC,0CAAsC;AACtC,sEAAkE;AAClE,+CAA+C;AAC/C,iCAA2D;AAC3D,kFAA8E;AA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CAAA;IAE7D,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACnC,MAAM,CAAC,oBAAoB,CAAC,GAAG,mBAAQ,CAAC,KAAK,CAC3C,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,EAC9C,MAAM,CACwB,CAAA;QAChC,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,qBAAqB,CAAA;AAC9B,CAAC"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.extractPresentationsWithDescriptorsFromSubmission = extractPresentationsWithDescriptorsFromSubmission;
|
|
7
|
-
const jsonpath_1 =
|
|
4
|
+
const jsonpath_1 = require("@astronautlabs/jsonpath");
|
|
8
5
|
const error_1 = require("../../../error");
|
|
9
6
|
const mdoc_1 = require("../../mdoc");
|
|
10
7
|
const vc_1 = require("../../vc");
|
|
11
8
|
function extractPresentationsWithDescriptorsFromSubmission(presentations, submission, definition) {
|
|
12
9
|
return submission.descriptor_map.map((descriptor) => {
|
|
13
|
-
const [presentation] = jsonpath_1.
|
|
10
|
+
const [presentation] = jsonpath_1.JSONPath.query(presentations, descriptor.path);
|
|
14
11
|
const inputDescriptor = definition.input_descriptors.find(({ id }) => id === descriptor.id);
|
|
15
12
|
if (!presentation) {
|
|
16
13
|
throw new error_1.CredoError(`Unable to extract presentation at path '${descriptor.path}' for submission descriptor '${descriptor.id}'`);
|
|
@@ -36,7 +33,7 @@ function extractPresentationsWithDescriptorsFromSubmission(presentations, submis
|
|
|
36
33
|
if (!descriptor.path_nested) {
|
|
37
34
|
throw new Error(`Submission descriptor '${descriptor.id}' for submission '${submission.id}' has no 'path_nested' but presentation is format '${presentation.claimFormat}'`);
|
|
38
35
|
}
|
|
39
|
-
const [verifiableCredential] = jsonpath_1.
|
|
36
|
+
const [verifiableCredential] = jsonpath_1.JSONPath.query(
|
|
40
37
|
// Path is `$.vp.verifiableCredential[]` in case of jwt vp
|
|
41
38
|
presentation.claimFormat === vc_1.ClaimFormat.JwtVp ? { vp: presentation } : presentation, descriptor.path_nested.path);
|
|
42
39
|
if (!verifiableCredential) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentationSelection.js","sourceRoot":"","sources":["../../../../src/modules/dif-presentation-exchange/utils/presentationSelection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presentationSelection.js","sourceRoot":"","sources":["../../../../src/modules/dif-presentation-exchange/utils/presentationSelection.ts"],"names":[],"mappings":";;AAiBA,8GA2EC;AApFD,sDAAkD;AAElD,0CAA2C;AAC3C,qCAA+C;AAC/C,iCAAqG;AAKrG,SAAgB,iDAAiD,CAC/D,aAAoD,EACpD,UAA6C,EAC7C,UAA6C;IAE7C,OAAO,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAClD,MAAM,CAAC,YAAY,CAAC,GAAG,mBAAQ,CAAC,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,IAAI,CAAyC,CAAA;QAC7G,MAAM,eAAe,GAAG,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC,CAAA;QAE3F,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,kBAAU,CAClB,2CAA2C,UAAU,CAAC,IAAI,gCAAgC,UAAU,CAAC,EAAE,GAAG,CAC3G,CAAA;QACH,CAAC;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,uCAAuC,UAAU,CAAC,EAAE,sBAAsB,UAAU,CAAC,EAAE,qBAAq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AAO;gBACL,MAAM,EAAE,YAAY,CAAC,WAAW;gBAChC,UAAU;gBACV,YAAY;gBACZ,UAAU,EAAE,oBAAoB;gBAChC,eAAe;aACP,CAAA;QACZ,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,MAAM,EAAE,gBAAW,CAAC,OAAO;gBAC3B,UAAU;gBACV,YAAY;gBACZ,UAAU,EAAE,YAAY;gBACxB,eAAe;aACP,CAAA;QACZ,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -3,8 +3,8 @@ import type { SdJwtVcRecord } from '../../sd-jwt-vc';
|
|
|
3
3
|
import type { W3cJsonPresentation } from '../../vc/models/presentation/W3cJsonPresentation';
|
|
4
4
|
import type { VerifiablePresentation } from '../models';
|
|
5
5
|
import type { OriginalVerifiableCredential as SphereonOriginalVerifiableCredential, OriginalVerifiablePresentation as SphereonOriginalVerifiablePresentation, W3CVerifiablePresentation as SphereonW3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
6
|
-
import { MdocDeviceResponse } from '../../mdoc';
|
|
6
|
+
import { MdocDeviceResponse, MdocRecord } from '../../mdoc';
|
|
7
7
|
import { W3cCredentialRecord, W3cJsonLdVerifiablePresentation, W3cJwtVerifiablePresentation } from '../../vc';
|
|
8
|
-
export declare function getSphereonOriginalVerifiableCredential(credentialRecord: W3cCredentialRecord | SdJwtVcRecord): SphereonOriginalVerifiableCredential;
|
|
8
|
+
export declare function getSphereonOriginalVerifiableCredential(credentialRecord: W3cCredentialRecord | SdJwtVcRecord | MdocRecord): SphereonOriginalVerifiableCredential;
|
|
9
9
|
export declare function getSphereonOriginalVerifiablePresentation(verifiablePresentation: VerifiablePresentation): SphereonOriginalVerifiablePresentation;
|
|
10
10
|
export declare function getVerifiablePresentationFromEncoded(agentContext: AgentContext, encodedVerifiablePresentation: string | W3cJsonPresentation | SphereonW3CVerifiablePresentation): MdocDeviceResponse | import("../../sd-jwt-vc").SdJwtVc<import("../../sd-jwt-vc").SdJwtVcHeader, import("../../sd-jwt-vc").SdJwtVcPayload> | W3cJsonLdVerifiablePresentation | W3cJwtVerifiablePresentation;
|
|
@@ -12,6 +12,9 @@ function getSphereonOriginalVerifiableCredential(credentialRecord) {
|
|
|
12
12
|
if (credentialRecord instanceof vc_1.W3cCredentialRecord) {
|
|
13
13
|
return credentialRecord.credential.encoded;
|
|
14
14
|
}
|
|
15
|
+
else if (credentialRecord instanceof mdoc_1.MdocRecord) {
|
|
16
|
+
return credentialRecord.base64Url;
|
|
17
|
+
}
|
|
15
18
|
else {
|
|
16
19
|
return credentialRecord.compactSdJwtVc;
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../src/modules/dif-presentation-exchange/utils/transform.ts"],"names":[],"mappings":";;AAgBA,
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../src/modules/dif-presentation-exchange/utils/transform.ts"],"names":[],"mappings":";;AAgBA,0FAUC;AAED,8FAaC;AAGD,oFAcC;AAhDD,4CAAqC;AACrC,0CAAgD;AAChD,qCAA2D;AAC3D,+CAA4C;AAC5C,iCAA6G;AAE7G,SAAgB,uCAAuC,CACrD,gBAAkE;IAElE,IAAI,gBAAgB,YAAY,wBAAmB,EAAE,CAAC;QACpD,OAAO,gBAAgB,CAAC,UAAU,CAAC,OAA+C,CAAA;IACpF,CAAC;SAAM,IAAI,gBAAgB,YAAY,iBAAU,EAAE,CAAC;QAClD,OAAO,gBAAgB,CAAC,SAAS,CAAA;IACnC,CAAC;SAAM,CAAC;QACN,OAAO,gBAAgB,CAAC,cAAc,CAAA;IACxC,CAAC;AACH,CAAC;AAED,SAAgB,yCAAyC,CACvD,sBAA8C;IAE9C,IACE,sBAAsB,YAAY,iCAA4B;QAC9D,sBAAsB,YAAY,oCAA+B,EACjE,CAAC;QACD,OAAO,sBAAsB,CAAC,OAAiD,CAAA;IACjF,CAAC;SAAM,IAAI,sBAAsB,YAAY,yBAAkB,EAAE,CAAC;QAChE,OAAO,sBAAsB,CAAC,SAAS,CAAA;IACzC,CAAC;SAAM,CAAC;QACN,OAAO,sBAAsB,CAAC,OAAO,CAAA;IACvC,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,SAAgB,oCAAoC,CAClD,YAA0B,EAC1B,6BAA+F;IAE/F,IAAI,OAAO,6BAA6B,KAAK,QAAQ,IAAI,6BAA6B,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACrG,MAAM,UAAU,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,sBAAU,CAAC,CAAA;QACrE,OAAO,UAAU,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAA;IAC9D,CAAC;SAAM,IAAI,OAAO,6BAA6B,KAAK,QAAQ,IAAI,YAAG,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,EAAE,CAAC;QAC/G,OAAO,iCAA4B,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;IACtF,CAAC;SAAM,IAAI,OAAO,6BAA6B,KAAK,QAAQ,IAAI,UAAU,IAAI,6BAA6B,EAAE,CAAC;QAC5G,OAAO,uBAAe,CAAC,QAAQ,CAAC,6BAA6B,EAAE,oCAA+B,CAAC,CAAA;IACjG,CAAC;SAAM,CAAC;QACN,OAAO,yBAAkB,CAAC,aAAa,CAAC,6BAA6B,CAAC,CAAA;IACxE,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@credo-ts/core",
|
|
3
3
|
"main": "build/index",
|
|
4
4
|
"types": "build/index",
|
|
5
|
-
"version": "0.6.0-pr-
|
|
5
|
+
"version": "0.6.0-pr-2094-20241124155338",
|
|
6
6
|
"files": [
|
|
7
7
|
"build"
|
|
8
8
|
],
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@sd-jwt/sd-jwt-vc": "^0.7.0",
|
|
35
35
|
"@sd-jwt/types": "^0.7.0",
|
|
36
36
|
"@sd-jwt/utils": "^0.7.0",
|
|
37
|
-
"@
|
|
37
|
+
"@animo-id/pex": "4.1.1-alpha.0",
|
|
38
38
|
"@sphereon/pex-models": "^2.3.1",
|
|
39
39
|
"@sphereon/ssi-types": "0.30.2-next.135",
|
|
40
40
|
"@stablelib/ed25519": "^1.0.2",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"class-transformer": "0.5.1",
|
|
47
47
|
"class-validator": "0.14.1",
|
|
48
48
|
"did-resolver": "^4.1.0",
|
|
49
|
-
"jsonpath": "^1.1.
|
|
49
|
+
"@astronautlabs/jsonpath": "^1.1.2",
|
|
50
50
|
"lru_map": "^0.4.1",
|
|
51
51
|
"luxon": "^3.5.0",
|
|
52
52
|
"make-error": "^1.3.6",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/events": "^3.0.0",
|
|
65
|
-
"@types/jsonpath": "^0.2.4",
|
|
66
65
|
"@types/luxon": "^3.2.0",
|
|
67
66
|
"@types/object-inspect": "^1.8.0",
|
|
68
67
|
"@types/uuid": "^9.0.1",
|