@sphereon/ssi-sdk.presentation-exchange 0.32.1-next.54 → 0.33.1-feature.vcdm2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/PresentationExchange.js +87 -109
- package/dist/agent/PresentationExchange.js.map +1 -1
- package/dist/functions.js +126 -130
- package/dist/functions.js.map +1 -1
- package/dist/index.js +4 -22
- package/dist/index.js.map +1 -1
- package/dist/types/IPresentationExchange.js +1 -2
- package/package.json +9 -9
- package/src/functions.ts +1 -1
|
@@ -1,120 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { schema, } from '../index';
|
|
2
|
+
import { PEX } from '@sphereon/pex';
|
|
3
|
+
import { CredentialMapper, JWT_PROOF_TYPE_2020 } from '@sphereon/ssi-types';
|
|
4
|
+
import { toDIDs } from '@sphereon/ssi-sdk-ext.did-utils';
|
|
5
|
+
import { verifiableCredentialForRoleFilter } from '@sphereon/ssi-sdk.credential-store';
|
|
6
|
+
export class PresentationExchange {
|
|
7
|
+
schema = schema.IDidAuthSiopOpAuthenticator;
|
|
8
|
+
pex = new PEX();
|
|
9
|
+
methods = {
|
|
10
|
+
pexValidateDefinition: this.pexValidateDefinition.bind(this),
|
|
11
|
+
pexDefinitionVersion: this.pexDefinitionVersion.bind(this),
|
|
12
|
+
pexDefinitionFilterCredentials: this.pexDefinitionFilterCredentials.bind(this),
|
|
13
|
+
pexDefinitionFilterCredentialsPerInputDescriptor: this.pexDefinitionFilterCredentialsPerInputDescriptor.bind(this),
|
|
14
|
+
};
|
|
15
|
+
constructor(opts) { }
|
|
16
|
+
async pexValidateDefinition(args) {
|
|
17
|
+
const { definition } = args;
|
|
18
|
+
const invalids = [];
|
|
19
|
+
try {
|
|
20
|
+
const result = PEX.validateDefinition(definition);
|
|
21
|
+
const validations = Array.isArray(result) ? result : [result];
|
|
22
|
+
invalids.push(...validations.filter((v) => v.status === 'error'));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
invalids.push({
|
|
26
|
+
status: 'error',
|
|
27
|
+
message: typeof error === 'string'
|
|
28
|
+
? error
|
|
29
|
+
: typeof error === 'object' && 'message' in error
|
|
30
|
+
? error.message
|
|
31
|
+
: 'unknown error',
|
|
32
|
+
tag: 'validation',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (invalids.length > 0) {
|
|
36
|
+
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`);
|
|
37
|
+
}
|
|
38
|
+
return true; // Never returns false, but REST API does not allow Promise<void>
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
const { definition } = args;
|
|
32
|
-
const invalids = [];
|
|
33
|
-
try {
|
|
34
|
-
const result = pex_1.PEX.validateDefinition(definition);
|
|
35
|
-
const validations = Array.isArray(result) ? result : [result];
|
|
36
|
-
invalids.push(...validations.filter((v) => v.status === 'error'));
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
invalids.push({
|
|
40
|
-
status: 'error',
|
|
41
|
-
message: typeof error === 'string'
|
|
42
|
-
? error
|
|
43
|
-
: typeof error === 'object' && 'message' in error
|
|
44
|
-
? error.message
|
|
45
|
-
: 'unknown error',
|
|
46
|
-
tag: 'validation',
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (invalids.length > 0) {
|
|
50
|
-
throw Error(`Invalid definition. ${invalids.map((v) => v.message).toString()}`);
|
|
51
|
-
}
|
|
52
|
-
return true; // Never returns false, but REST API does not allow Promise<void>
|
|
53
|
-
});
|
|
40
|
+
async pexDefinitionVersion(presentationDefinition) {
|
|
41
|
+
return PEX.definitionVersionDiscovery(presentationDefinition);
|
|
54
42
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
async pexDefinitionFilterCredentials(args, context) {
|
|
44
|
+
const credentials = await this.pexFilterCredentials(args.credentialFilterOpts, context);
|
|
45
|
+
const holderDIDs = args.holderDIDs ? toDIDs(args.holderDIDs) : toDIDs(await context.agent.dataStoreORMGetIdentifiers());
|
|
46
|
+
const selectResults = this.pex.selectFrom(args.presentationDefinition, credentials ?? [], {
|
|
47
|
+
...args,
|
|
48
|
+
holderDIDs,
|
|
49
|
+
limitDisclosureSignatureSuites: args.limitDisclosureSignatureSuites ?? ['BbsBlsSignature2020'],
|
|
58
50
|
});
|
|
51
|
+
return {
|
|
52
|
+
id: args.presentationDefinition.id,
|
|
53
|
+
selectResults,
|
|
54
|
+
filteredCredentials: selectResults.verifiableCredential?.map((vc) => CredentialMapper.storedCredentialToOriginalFormat(vc)) ?? [],
|
|
55
|
+
};
|
|
59
56
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
async pexDefinitionFilterCredentialsPerInputDescriptor(args, context) {
|
|
58
|
+
const origDefinition = args.presentationDefinition;
|
|
59
|
+
const credentials = await this.pexFilterCredentials(args.credentialFilterOpts ?? {}, context);
|
|
60
|
+
const holderDIDs = args.holderDIDs ? toDIDs(args.holderDIDs) : toDIDs(await context.agent.dataStoreORMGetIdentifiers());
|
|
61
|
+
const limitDisclosureSignatureSuites = args.limitDisclosureSignatureSuites;
|
|
62
|
+
const promises = new Map();
|
|
63
|
+
origDefinition.input_descriptors.forEach((inputDescriptor) => {
|
|
64
|
+
const presentationDefinition = {
|
|
65
|
+
id: inputDescriptor.id,
|
|
66
|
+
input_descriptors: [inputDescriptor],
|
|
70
67
|
};
|
|
68
|
+
const credentialRole = args.credentialFilterOpts.credentialRole;
|
|
69
|
+
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
70
|
+
credentialFilterOpts: { credentialRole, verifiableCredentials: credentials },
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
presentationDefinition,
|
|
73
|
+
holderDIDs,
|
|
74
|
+
limitDisclosureSignatureSuites,
|
|
75
|
+
}, context));
|
|
71
76
|
});
|
|
77
|
+
await Promise.all(promises.values());
|
|
78
|
+
const result = [];
|
|
79
|
+
for (const entry of promises.entries()) {
|
|
80
|
+
result.push({ ...(await entry[1]), inputDescriptor: entry[0] });
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
72
83
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
input_descriptors: [inputDescriptor],
|
|
85
|
-
};
|
|
86
|
-
const credentialRole = args.credentialFilterOpts.credentialRole;
|
|
87
|
-
promises.set(inputDescriptor, this.pexDefinitionFilterCredentials({
|
|
88
|
-
credentialFilterOpts: { credentialRole, verifiableCredentials: credentials },
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
presentationDefinition,
|
|
91
|
-
holderDIDs,
|
|
92
|
-
limitDisclosureSignatureSuites,
|
|
93
|
-
}, context));
|
|
94
|
-
});
|
|
95
|
-
yield Promise.all(promises.values());
|
|
96
|
-
const result = [];
|
|
97
|
-
for (const entry of promises.entries()) {
|
|
98
|
-
result.push(Object.assign(Object.assign({}, (yield entry[1])), { inputDescriptor: entry[0] }));
|
|
99
|
-
}
|
|
100
|
-
return result;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
pexFilterCredentials(filterOpts, context) {
|
|
104
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
if (filterOpts.verifiableCredentials && filterOpts.verifiableCredentials.length > 0) {
|
|
106
|
-
return filterOpts.verifiableCredentials;
|
|
107
|
-
}
|
|
108
|
-
const filter = (0, ssi_sdk_credential_store_1.verifiableCredentialForRoleFilter)(filterOpts.credentialRole, filterOpts.filter);
|
|
109
|
-
const uniqueCredentials = yield context.agent.crsGetUniqueCredentials({ filter });
|
|
110
|
-
return uniqueCredentials.map((uniqueVC) => {
|
|
111
|
-
const vc = uniqueVC.uniformVerifiableCredential;
|
|
112
|
-
const proof = Array.isArray(vc.proof) ? vc.proof : [vc.proof];
|
|
113
|
-
const jwtProof = proof.find((p) => (p === null || p === void 0 ? void 0 : p.type) === ssi_types_1.JWT_PROOF_TYPE_2020);
|
|
114
|
-
return jwtProof ? jwtProof.jwt : vc;
|
|
115
|
-
});
|
|
84
|
+
async pexFilterCredentials(filterOpts, context) {
|
|
85
|
+
if (filterOpts.verifiableCredentials && filterOpts.verifiableCredentials.length > 0) {
|
|
86
|
+
return filterOpts.verifiableCredentials;
|
|
87
|
+
}
|
|
88
|
+
const filter = verifiableCredentialForRoleFilter(filterOpts.credentialRole, filterOpts.filter);
|
|
89
|
+
const uniqueCredentials = await context.agent.crsGetUniqueCredentials({ filter });
|
|
90
|
+
return uniqueCredentials.map((uniqueVC) => {
|
|
91
|
+
const vc = uniqueVC.uniformVerifiableCredential;
|
|
92
|
+
const proof = Array.isArray(vc.proof) ? vc.proof : [vc.proof];
|
|
93
|
+
const jwtProof = proof.find((p) => p?.type === JWT_PROOF_TYPE_2020);
|
|
94
|
+
return jwtProof ? jwtProof.jwt : vc;
|
|
116
95
|
});
|
|
117
96
|
}
|
|
118
97
|
}
|
|
119
|
-
exports.PresentationExchange = PresentationExchange;
|
|
120
98
|
//# sourceMappingURL=PresentationExchange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationExchange.js","sourceRoot":"","sources":["../../src/agent/PresentationExchange.ts"],"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,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,mBAAmB,CAAC,CAAA;YAC3E,OAAO,QAAQ,CAAC,CAAC,CAAE,QAAQ,CAAC,GAAkB,CAAC,CAAC,CAAC,EAAE,CAAA;QACrD,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/functions.js
CHANGED
|
@@ -1,148 +1,144 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function createPEXPresentationSignCallback(args, context) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
function determineProofFormat(determineArgs) {
|
|
18
|
-
var _a;
|
|
19
|
-
const { format, presentationDefinition, presentation } = determineArgs;
|
|
20
|
-
var formatOptions = (_a = format !== null && format !== void 0 ? format : presentationDefinition.format) !== null && _a !== void 0 ? _a : args.format;
|
|
21
|
-
// TODO Refactor so it takes into account the Input Descriptors and we can lookup from there. Now we only do that if there is 1 descriptor
|
|
22
|
-
if (!formatOptions && presentationDefinition.input_descriptors.length == 1 && 'format' in presentationDefinition.input_descriptors[0]) {
|
|
23
|
-
formatOptions = presentationDefinition.input_descriptors[0].format;
|
|
24
|
-
}
|
|
25
|
-
// All format arguments are optional. So if no format has been given we go for the most supported 'jwt'
|
|
26
|
-
if (!formatOptions) {
|
|
27
|
-
if (ssi_types_1.CredentialMapper.isSdJwtDecodedCredentialPayload(presentation.decodedPayload)) {
|
|
28
|
-
return 'vc+sd-jwt';
|
|
29
|
-
}
|
|
30
|
-
else if (ssi_types_1.CredentialMapper.isMsoMdocDecodedPresentation(presentation.decodedPayload)) {
|
|
31
|
-
return 'mso_mdoc';
|
|
32
|
-
}
|
|
33
|
-
else if (ssi_types_1.CredentialMapper.isW3cPresentation(presentation.decodedPayload)) {
|
|
34
|
-
if (typeof presentation.signedPayload === 'string') {
|
|
35
|
-
return 'jwt';
|
|
36
|
-
}
|
|
37
|
-
return 'lds';
|
|
38
|
-
}
|
|
39
|
-
return 'jwt';
|
|
40
|
-
}
|
|
41
|
-
else if (typeof formatOptions === 'string') {
|
|
42
|
-
// if formatOptions is a singular string we can return that as the format
|
|
43
|
-
return formatOptions;
|
|
1
|
+
import { isManagedIdentifierDidOpts, isManagedIdentifierDidResult, isManagedIdentifierX5cResult, } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
+
import { CredentialMapper, } from '@sphereon/ssi-types';
|
|
3
|
+
export async function createPEXPresentationSignCallback(args, context) {
|
|
4
|
+
function determineProofFormat(determineArgs) {
|
|
5
|
+
const { format, presentationDefinition, presentation } = determineArgs;
|
|
6
|
+
var formatOptions = format ?? presentationDefinition.format ?? args.format;
|
|
7
|
+
// TODO Refactor so it takes into account the Input Descriptors and we can lookup from there. Now we only do that if there is 1 descriptor
|
|
8
|
+
if (!formatOptions && presentationDefinition.input_descriptors.length == 1 && 'format' in presentationDefinition.input_descriptors[0]) {
|
|
9
|
+
formatOptions = presentationDefinition.input_descriptors[0].format;
|
|
10
|
+
}
|
|
11
|
+
// All format arguments are optional. So if no format has been given we go for the most supported 'jwt'
|
|
12
|
+
if (!formatOptions) {
|
|
13
|
+
if (CredentialMapper.isSdJwtDecodedCredentialPayload(presentation.decodedPayload)) {
|
|
14
|
+
return 'vc+sd-jwt';
|
|
44
15
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// if we only have 1 format type we can return that
|
|
48
|
-
if (formats.size === 1) {
|
|
49
|
-
return formats.values().next().value;
|
|
16
|
+
else if (CredentialMapper.isMsoMdocDecodedPresentation(presentation.decodedPayload)) {
|
|
17
|
+
return 'mso_mdoc';
|
|
50
18
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
19
|
+
else if (CredentialMapper.isW3cPresentation(presentation.decodedPayload)) {
|
|
20
|
+
if (typeof presentation.signedPayload === 'string') {
|
|
21
|
+
return 'jwt';
|
|
22
|
+
}
|
|
23
|
+
return 'lds';
|
|
55
24
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
25
|
+
return 'jwt';
|
|
26
|
+
}
|
|
27
|
+
else if (typeof formatOptions === 'string') {
|
|
28
|
+
// if formatOptions is a singular string we can return that as the format
|
|
29
|
+
return formatOptions;
|
|
30
|
+
}
|
|
31
|
+
// here we transform all format options to either lds or jwt. but we also want to support sd-jwt, so we need to specifically check for this one. which is ['vc+sd-jwt']
|
|
32
|
+
const formats = new Set(Object.keys(formatOptions).map((form) => (form.includes('ldp') ? 'lds' : form.includes('vc+sd-jwt') ? 'vc+sd-jwt' : 'jwt')));
|
|
33
|
+
// if we only have 1 format type we can return that
|
|
34
|
+
if (formats.size === 1) {
|
|
35
|
+
return formats.values().next().value;
|
|
36
|
+
}
|
|
37
|
+
formats.keys().next();
|
|
38
|
+
// if we can go for sd-jwt, we go for sd-jwt
|
|
39
|
+
if (formats.has('vc+sd-jwt')) {
|
|
40
|
+
return 'vc+sd-jwt';
|
|
41
|
+
}
|
|
42
|
+
// if it is not sd-jwt we would like to go for jwt
|
|
43
|
+
else if (formats.has('jwt')) {
|
|
44
|
+
return 'jwt';
|
|
45
|
+
}
|
|
46
|
+
// else we go for lds
|
|
47
|
+
return 'lds';
|
|
48
|
+
}
|
|
49
|
+
return async ({ presentation, domain, presentationDefinition, format, challenge, }) => {
|
|
50
|
+
const proofFormat = determineProofFormat({ format, presentationDefinition, presentation });
|
|
51
|
+
const { idOpts } = args;
|
|
52
|
+
const CLOCK_SKEW = 120;
|
|
53
|
+
if (args.skipDidResolution && isManagedIdentifierDidOpts(idOpts)) {
|
|
54
|
+
idOpts.offlineWhenNoDIDRegistered = true;
|
|
55
|
+
}
|
|
56
|
+
if ('compactSdJwtVc' in presentation) {
|
|
57
|
+
if (proofFormat !== 'vc+sd-jwt') {
|
|
58
|
+
return Promise.reject(Error(`presentation payload does not match proof format ${proofFormat}`));
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const presentationResult = await context.agent.createSdJwtPresentation({
|
|
61
|
+
...(idOpts?.method === 'oid4vci-issuer' && { holder: idOpts?.issuer }),
|
|
62
|
+
presentation: presentation.compactSdJwtVc,
|
|
63
|
+
kb: {
|
|
64
|
+
payload: {
|
|
65
|
+
...presentation.kbJwt?.payload,
|
|
66
|
+
iat: presentation.kbJwt?.payload?.iat ?? Math.floor(Date.now() / 1000 - CLOCK_SKEW),
|
|
67
|
+
nonce: challenge ?? presentation.kbJwt?.payload?.nonce,
|
|
68
|
+
aud: presentation.kbJwt?.payload?.aud ?? domain ?? args.domain,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return CredentialMapper.storedPresentationToOriginalFormat(presentationResult.presentation);
|
|
62
73
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const CLOCK_SKEW = 120;
|
|
68
|
-
if (args.skipDidResolution && (0, ssi_sdk_ext_identifier_resolution_1.isManagedIdentifierDidOpts)(idOpts)) {
|
|
69
|
-
idOpts.offlineWhenNoDIDRegistered = true;
|
|
74
|
+
else {
|
|
75
|
+
const resolution = await context.agent.identifierManagedGet(idOpts);
|
|
76
|
+
if (proofFormat === 'vc+sd-jwt') {
|
|
77
|
+
return Promise.reject(Error(`presentation payload does not match proof format ${proofFormat}`));
|
|
70
78
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
const presentationResult = yield context.agent.createSdJwtPresentation(Object.assign(Object.assign({}, ((idOpts === null || idOpts === void 0 ? void 0 : idOpts.method) === 'oid4vci-issuer' && { holder: idOpts === null || idOpts === void 0 ? void 0 : idOpts.issuer })), { presentation: presentation.compactSdJwtVc, kb: {
|
|
76
|
-
payload: Object.assign(Object.assign({}, (_b = presentation.kbJwt) === null || _b === void 0 ? void 0 : _b.payload), { iat: (_e = (_d = (_c = presentation.kbJwt) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.iat) !== null && _e !== void 0 ? _e : Math.floor(Date.now() / 1000 - CLOCK_SKEW), nonce: challenge !== null && challenge !== void 0 ? challenge : (_g = (_f = presentation.kbJwt) === null || _f === void 0 ? void 0 : _f.payload) === null || _g === void 0 ? void 0 : _g.nonce, aud: (_l = (_k = (_j = (_h = presentation.kbJwt) === null || _h === void 0 ? void 0 : _h.payload) === null || _j === void 0 ? void 0 : _j.aud) !== null && _k !== void 0 ? _k : domain) !== null && _l !== void 0 ? _l : args.domain }),
|
|
77
|
-
} }));
|
|
78
|
-
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(presentationResult.presentation);
|
|
79
|
+
let header;
|
|
80
|
+
if (!presentation.holder) {
|
|
81
|
+
presentation.holder = resolution.issuer;
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
presentation.
|
|
83
|
+
if (proofFormat === 'jwt') {
|
|
84
|
+
header = {
|
|
85
|
+
...((isManagedIdentifierDidResult(resolution) || isManagedIdentifierX5cResult(resolution)) && resolution.kid && { kid: resolution.kid }),
|
|
86
|
+
...(isManagedIdentifierX5cResult(resolution) && { jwk: resolution.jwk }),
|
|
87
|
+
};
|
|
88
|
+
if (presentation.verifier || !presentation.aud) {
|
|
89
|
+
presentation.aud = Array.isArray(presentation.verifier) ? presentation.verifier : (presentation.verifier ?? domain ?? args.domain);
|
|
90
|
+
delete presentation.verifier;
|
|
88
91
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
if (!presentation.nbf) {
|
|
96
|
-
if (presentation.issuanceDate) {
|
|
97
|
-
const converted = Date.parse(presentation.issuanceDate);
|
|
98
|
-
if (!isNaN(converted)) {
|
|
99
|
-
presentation.nbf = Math.floor(converted / 1000); // no skew here, as an explicit value was given
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
presentation.nbf = Math.floor(Date.now() / 1000 - CLOCK_SKEW);
|
|
92
|
+
if (!presentation.nbf) {
|
|
93
|
+
if (presentation.issuanceDate) {
|
|
94
|
+
const converted = Date.parse(presentation.issuanceDate);
|
|
95
|
+
if (!isNaN(converted)) {
|
|
96
|
+
presentation.nbf = Math.floor(converted / 1000); // no skew here, as an explicit value was given
|
|
104
97
|
}
|
|
105
98
|
}
|
|
106
|
-
|
|
107
|
-
presentation.
|
|
99
|
+
else {
|
|
100
|
+
presentation.nbf = Math.floor(Date.now() / 1000 - CLOCK_SKEW);
|
|
108
101
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
presentation.exp =
|
|
102
|
+
}
|
|
103
|
+
if (!presentation.iat) {
|
|
104
|
+
presentation.iat = presentation.nbf;
|
|
105
|
+
}
|
|
106
|
+
if (!presentation.exp) {
|
|
107
|
+
if (presentation.expirationDate) {
|
|
108
|
+
const converted = Date.parse(presentation.expirationDate);
|
|
109
|
+
if (!isNaN(converted)) {
|
|
110
|
+
presentation.exp = Math.floor(converted / 1000); // no skew here as an explicit value w as given
|
|
118
111
|
}
|
|
119
112
|
}
|
|
120
|
-
|
|
121
|
-
presentation.
|
|
122
|
-
}
|
|
123
|
-
/*if (!presentation.sub) {
|
|
124
|
-
presentation.sub = id.did
|
|
125
|
-
}*/
|
|
126
|
-
if (!presentation.vp.holder) {
|
|
127
|
-
presentation.vp.holder = presentation.holder;
|
|
113
|
+
else {
|
|
114
|
+
presentation.exp = presentation.nbf + 600 + CLOCK_SKEW;
|
|
128
115
|
}
|
|
129
116
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
proofFormat: proofFormat,
|
|
140
|
-
header,
|
|
141
|
-
});
|
|
142
|
-
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
143
|
-
return ssi_types_1.CredentialMapper.storedPresentationToOriginalFormat(vp);
|
|
117
|
+
if (!presentation.vp) {
|
|
118
|
+
presentation.vp = {};
|
|
119
|
+
}
|
|
120
|
+
/*if (!presentation.sub) {
|
|
121
|
+
presentation.sub = id.did
|
|
122
|
+
}*/
|
|
123
|
+
if (!presentation.vp.holder) {
|
|
124
|
+
presentation.vp.holder = presentation.holder;
|
|
125
|
+
}
|
|
144
126
|
}
|
|
145
|
-
|
|
146
|
-
|
|
127
|
+
// we ignore the alg / proof_format for now, as we already have the kid anyway at this point
|
|
128
|
+
// todo: look for jwt_vc_json and remove types and @context
|
|
129
|
+
const vp = await context.agent.createVerifiablePresentation({
|
|
130
|
+
presentation: presentation,
|
|
131
|
+
removeOriginalFields: false,
|
|
132
|
+
keyRef: resolution.kmsKeyRef,
|
|
133
|
+
// domain: domain ?? args.domain, // handled above, and did-jwt-vc creates an array even for 1 entry
|
|
134
|
+
challenge: challenge ?? args.challenge,
|
|
135
|
+
fetchRemoteContexts: args.fetchRemoteContexts !== false,
|
|
136
|
+
proofFormat: proofFormat,
|
|
137
|
+
header,
|
|
138
|
+
});
|
|
139
|
+
// makes sure we extract an actual JWT from the internal representation in case it is a JWT
|
|
140
|
+
return CredentialMapper.storedPresentationToOriginalFormat(vp);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
147
143
|
}
|
|
148
144
|
//# sourceMappingURL=functions.js.map
|
package/dist/functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources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,CAAC,mBAAmB,KAAK,KAAK;gBACvD,WAAW,EAAE,WAA0B;gBACvC,MAAM;aACP,CAAC,CAAA;YAEF,2FAA2F;YAC3F,OAAO,gBAAgB,CAAC,kCAAkC,CAAC,EAAoC,CAAC,CAAA;QAClG,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PresentationExchange = exports.schema = void 0;
|
|
18
1
|
/**
|
|
19
2
|
* @public
|
|
20
3
|
*/
|
|
21
4
|
const schema = require('../plugin.schema.json');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__exportStar(require("./functions"), exports);
|
|
5
|
+
export { schema };
|
|
6
|
+
export { PresentationExchange } from './agent/PresentationExchange';
|
|
7
|
+
export * from './types/IPresentationExchange';
|
|
8
|
+
export * from './functions';
|
|
27
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,cAAc,+BAA+B,CAAA;AAC7C,cAAc,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.presentation-exchange",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
18
18
|
"@sphereon/pex-models": "^2.3.2",
|
|
19
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
20
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.
|
|
21
|
-
"@sphereon/ssi-sdk.credential-store": "0.
|
|
22
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
23
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.
|
|
24
|
-
"@sphereon/ssi-types": "0.
|
|
19
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.0",
|
|
20
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.0",
|
|
21
|
+
"@sphereon/ssi-sdk.credential-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
22
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
23
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
24
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
25
25
|
"@veramo/core": "4.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
29
|
-
"@sphereon/ssi-sdk.agent-config": "0.
|
|
29
|
+
"@sphereon/ssi-sdk.agent-config": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
30
30
|
"@types/json-buffer": "^3.0.2",
|
|
31
31
|
"@veramo/did-provider-key": "4.2.0",
|
|
32
32
|
"@veramo/did-resolver": "4.2.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"Authenticator"
|
|
65
65
|
],
|
|
66
66
|
"nx": {},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
68
68
|
}
|
package/src/functions.ts
CHANGED
|
@@ -43,7 +43,7 @@ export async function createPEXPresentationSignCallback(
|
|
|
43
43
|
if (!formatOptions) {
|
|
44
44
|
if (CredentialMapper.isSdJwtDecodedCredentialPayload(presentation.decodedPayload)) {
|
|
45
45
|
return 'vc+sd-jwt'
|
|
46
|
-
} else if (
|
|
46
|
+
} else if (CredentialMapper.isMsoMdocDecodedPresentation(presentation.decodedPayload as OriginalVerifiablePresentation)) {
|
|
47
47
|
return 'mso_mdoc'
|
|
48
48
|
} else if (CredentialMapper.isW3cPresentation(presentation.decodedPayload)) {
|
|
49
49
|
if (typeof presentation.signedPayload === 'string') {
|