@sphereon/ssi-sdk.mdl-mdoc 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/mDLMdoc.d.ts.map +1 -1
- package/dist/agent/mDLMdoc.js +158 -179
- package/dist/agent/mDLMdoc.js.map +1 -1
- package/dist/functions/index.js +142 -188
- package/dist/functions/index.js.map +1 -1
- package/dist/index.js +6 -25
- package/dist/index.js.map +1 -1
- package/dist/types/ImDLMdoc.js +1 -2
- package/package.json +17 -17
- package/src/agent/mDLMdoc.ts +32 -44
- package/src/functions/index.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mDLMdoc.d.ts","sourceRoot":"","sources":["../../src/agent/mDLMdoc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mDLMdoc.d.ts","sourceRoot":"","sources":["../../src/agent/mDLMdoc.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAEL,QAAQ,EAKT,MAAM,mBAAmB,CAAA;AAoB1B,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAM5C,CAAA;AAED;;;;GAIG;AACH,qBAAa,OAAQ,YAAW,YAAY;IAC1C,QAAQ,CAAC,MAAM,MAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAMzB;IACD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,IAAI,CAIX;gBAEW,IAAI,CAAC,EAAE;QACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE;YAEL,sBAAsB,CAAC,EAAE,OAAO,CAAA;YAEhC,2BAA2B,CAAC,EAAE,OAAO,CAAA;YAGrC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAA;SACjC,CAAA;KACF;IAKD;;;;;;OAMG;YACW,uBAAuB;IAuGrC;;;;;;;OAOG;YACW,kBAAkB;IAiDhC;;;;;;OAMG;YACW,sBAAsB;IAWpC;;;;;;;OAOG;YACW,0BAA0B;IAcxC;;;;;;;;;OASG;YACW,sBAAsB;CAIrC"}
|
package/dist/agent/mDLMdoc.js
CHANGED
|
@@ -1,59 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
var CoseCryptoServiceJS = kmp_mdoc_core_1.com.sphereon.crypto.CoseCryptoServiceJS;
|
|
22
|
-
var CoseJoseKeyMappingService = kmp_mdoc_core_1.com.sphereon.crypto.CoseJoseKeyMappingService;
|
|
23
|
-
var KeyInfo = kmp_mdoc_core_1.com.sphereon.crypto.KeyInfo;
|
|
24
|
-
var DateTimeUtils = kmp_mdoc_core_1.com.sphereon.kmp.DateTimeUtils;
|
|
25
|
-
var decodeFrom = kmp_mdoc_core_1.com.sphereon.kmp.decodeFrom;
|
|
26
|
-
var encodeTo = kmp_mdoc_core_1.com.sphereon.kmp.encodeTo;
|
|
27
|
-
var Encoding = kmp_mdoc_core_1.com.sphereon.kmp.Encoding;
|
|
28
|
-
var DeviceResponseCbor = kmp_mdoc_core_1.com.sphereon.mdoc.data.device.DeviceResponseCbor;
|
|
29
|
-
var MdocValidations = kmp_mdoc_core_1.com.sphereon.mdoc.data.MdocValidations;
|
|
30
|
-
var MdocOid4vpService = kmp_mdoc_core_1.com.sphereon.mdoc.oid4vp.MdocOid4vpServiceJs;
|
|
31
|
-
var Oid4VPPresentationSubmission = kmp_mdoc_core_1.com.sphereon.mdoc.oid4vp.Oid4VPPresentationSubmission;
|
|
32
|
-
exports.mdocSupportMethods = [
|
|
1
|
+
import { com } from '@sphereon/kmp-mdoc-core';
|
|
2
|
+
import { calculateJwkThumbprint } from '@sphereon/ssi-sdk-ext.key-utils';
|
|
3
|
+
import { getCertificateInfo, pemOrDerToX509Certificate } from '@sphereon/ssi-sdk-ext.x509-utils';
|
|
4
|
+
import { schema } from '..';
|
|
5
|
+
import { CoseCryptoService, X509CallbackService } from '../functions';
|
|
6
|
+
var CborByteString = com.sphereon.cbor.CborByteString;
|
|
7
|
+
var CoseKeyCbor = com.sphereon.crypto.cose.CoseKeyCbor;
|
|
8
|
+
var CoseSign1Json = com.sphereon.crypto.cose.CoseSign1Json;
|
|
9
|
+
var CoseCryptoServiceJS = com.sphereon.crypto.CoseCryptoServiceJS;
|
|
10
|
+
var CoseJoseKeyMappingService = com.sphereon.crypto.CoseJoseKeyMappingService;
|
|
11
|
+
var KeyInfo = com.sphereon.crypto.KeyInfo;
|
|
12
|
+
var DateTimeUtils = com.sphereon.kmp.DateTimeUtils;
|
|
13
|
+
var decodeFrom = com.sphereon.kmp.decodeFrom;
|
|
14
|
+
var encodeTo = com.sphereon.kmp.encodeTo;
|
|
15
|
+
var Encoding = com.sphereon.kmp.Encoding;
|
|
16
|
+
var DeviceResponseCbor = com.sphereon.mdoc.data.device.DeviceResponseCbor;
|
|
17
|
+
var MdocValidations = com.sphereon.mdoc.data.MdocValidations;
|
|
18
|
+
var MdocOid4vpService = com.sphereon.mdoc.oid4vp.MdocOid4vpServiceJs;
|
|
19
|
+
var Oid4VPPresentationSubmission = com.sphereon.mdoc.oid4vp.Oid4VPPresentationSubmission;
|
|
20
|
+
export const mdocSupportMethods = [
|
|
33
21
|
'x509VerifyCertificateChain',
|
|
34
22
|
'x509GetCertificateInfo',
|
|
35
23
|
'mdocVerifyIssuerSigned',
|
|
36
24
|
'mdocOid4vpHolderPresent',
|
|
37
|
-
'mdocOid4vpRPVerify'
|
|
25
|
+
'mdocOid4vpRPVerify',
|
|
38
26
|
];
|
|
39
27
|
/**
|
|
40
28
|
* The MDLMdoc class implements the IAgentPlugin interface, providing methods for
|
|
41
29
|
* verification and information retrieval related to X.509 certificates and mDL (mobile
|
|
42
30
|
* driver's license) documents.
|
|
43
31
|
*/
|
|
44
|
-
class MDLMdoc {
|
|
32
|
+
export class MDLMdoc {
|
|
33
|
+
schema = schema.IMDLMdoc;
|
|
34
|
+
methods = {
|
|
35
|
+
x509VerifyCertificateChain: this.x509VerifyCertificateChain.bind(this),
|
|
36
|
+
x509GetCertificateInfo: this.x509GetCertificateInfo.bind(this),
|
|
37
|
+
mdocVerifyIssuerSigned: this.mdocVerifyIssuerSigned.bind(this),
|
|
38
|
+
mdocOid4vpHolderPresent: this.mdocOid4vpHolderPresent.bind(this),
|
|
39
|
+
mdocOid4vpRPVerify: this.mdocOid4vpRPVerify.bind(this),
|
|
40
|
+
};
|
|
41
|
+
trustAnchors;
|
|
42
|
+
opts;
|
|
45
43
|
constructor(args) {
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
this.methods = {
|
|
49
|
-
x509VerifyCertificateChain: this.x509VerifyCertificateChain.bind(this),
|
|
50
|
-
x509GetCertificateInfo: this.x509GetCertificateInfo.bind(this),
|
|
51
|
-
mdocVerifyIssuerSigned: this.mdocVerifyIssuerSigned.bind(this),
|
|
52
|
-
mdocOid4vpHolderPresent: this.mdocOid4vpHolderPresent.bind(this),
|
|
53
|
-
mdocOid4vpRPVerify: this.mdocOid4vpRPVerify.bind(this)
|
|
54
|
-
};
|
|
55
|
-
this.trustAnchors = (_a = args === null || args === void 0 ? void 0 : args.trustAnchors) !== null && _a !== void 0 ? _a : [];
|
|
56
|
-
this.opts = (_b = args === null || args === void 0 ? void 0 : args.opts) !== null && _b !== void 0 ? _b : { trustRootWhenNoAnchors: true };
|
|
44
|
+
this.trustAnchors = args?.trustAnchors ?? [];
|
|
45
|
+
this.opts = args?.opts ?? { trustRootWhenNoAnchors: true };
|
|
57
46
|
}
|
|
58
47
|
/**
|
|
59
48
|
* Processes and verifies the provided mdoc, generates device response and presentation submission tokens.
|
|
@@ -62,83 +51,79 @@ class MDLMdoc {
|
|
|
62
51
|
* @param {IRequiredContext} _context - Required context for the operation.
|
|
63
52
|
* @return {Promise<MdocOid4VPPresentationAuth>} A promise that resolves to an object containing vp_token and presentation_submission.
|
|
64
53
|
*/
|
|
65
|
-
mdocOid4vpHolderPresent(args, _context) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const result = yield MdocValidations.fromDocumentAsync(mdoc, null, trustAnchors !== null && trustAnchors !== void 0 ? trustAnchors : this.trustAnchors, DateTimeUtils.Static.DEFAULT.dateTimeLocal(((_b = (_a = verifications === null || verifications === void 0 ? void 0 : verifications.verificationTime) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : Date.now()) / 1000), verifications === null || verifications === void 0 ? void 0 : verifications.allowExpiredDocuments);
|
|
75
|
-
if (result.error) {
|
|
76
|
-
console.log(JSON.stringify(result, null, 2));
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
console.log(e);
|
|
82
|
-
return {
|
|
83
|
-
error: true,
|
|
84
|
-
verifications: [
|
|
85
|
-
{
|
|
86
|
-
name: 'mdoc',
|
|
87
|
-
error: true,
|
|
88
|
-
critical: true,
|
|
89
|
-
message: e.message
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
};
|
|
54
|
+
async mdocOid4vpHolderPresent(args, _context) {
|
|
55
|
+
const { mdocs, presentationDefinition, trustAnchors, verifications, mdocHolderNonce, authorizationRequestNonce, responseUri, clientId } = args;
|
|
56
|
+
const oid4vpService = new MdocOid4vpService();
|
|
57
|
+
// const mdoc = DocumentCbor.Static.cborDecode(decodeFrom(mdocBase64Url, Encoding.BASE64URL))
|
|
58
|
+
const validate = async (mdoc) => {
|
|
59
|
+
try {
|
|
60
|
+
const result = await MdocValidations.fromDocumentAsync(mdoc, null, trustAnchors ?? this.trustAnchors, DateTimeUtils.Static.DEFAULT.dateTimeLocal((verifications?.verificationTime?.getTime() ?? Date.now()) / 1000), verifications?.allowExpiredDocuments);
|
|
61
|
+
if (result.error) {
|
|
62
|
+
console.log(JSON.stringify(result, null, 2));
|
|
93
63
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.log(e);
|
|
68
|
+
return {
|
|
69
|
+
error: true,
|
|
70
|
+
verifications: [
|
|
71
|
+
{
|
|
72
|
+
name: 'mdoc',
|
|
73
|
+
error: true,
|
|
74
|
+
critical: true,
|
|
75
|
+
message: e.message,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const allMatches = oid4vpService.matchDocumentsAndDescriptors(mdocHolderNonce, mdocs, presentationDefinition);
|
|
82
|
+
const docsAndDescriptors = [];
|
|
83
|
+
let lastError = undefined;
|
|
84
|
+
for (let match of allMatches) {
|
|
85
|
+
if (match.document) {
|
|
86
|
+
const result = await validate(match.document);
|
|
87
|
+
if (!result.error || responseUri.includes('openid.net')) {
|
|
88
|
+
// TODO: We relax for the conformance suite, as the cert would be invalid
|
|
89
|
+
try {
|
|
90
|
+
const cborKey = result.keyInfo?.key ? CoseKeyCbor.Static.fromDTO(result.keyInfo.key) : undefined;
|
|
91
|
+
if (!cborKey) {
|
|
92
|
+
throw Error('No key found in result');
|
|
120
93
|
}
|
|
121
|
-
|
|
122
|
-
|
|
94
|
+
let jwk = CoseJoseKeyMappingService.toJoseJwk(cborKey).toJsonDTO();
|
|
95
|
+
if (!result.keyInfo?.kmsKeyRef) {
|
|
96
|
+
const keyInfo = result.keyInfo;
|
|
97
|
+
const kid = jwk.kid ?? calculateJwkThumbprint({ jwk: jwk });
|
|
98
|
+
const key = await _context.agent.keyManagerGet({ kid });
|
|
99
|
+
const kms = key.kms;
|
|
100
|
+
const kmsKeyRef = key.meta?.kmsKeyRef;
|
|
101
|
+
const updateCborKey = cborKey.copy(false, cborKey.kty, cborKey.kid ?? new CborByteString(decodeFrom(kid, Encoding.UTF8)));
|
|
102
|
+
const deviceKeyInfo = KeyInfo.Static.fromDTO(keyInfo).copy(kid, updateCborKey, keyInfo.opts, keyInfo.keyVisibility, keyInfo.signatureAlgorithm, keyInfo.x5c, kmsKeyRef, kms);
|
|
103
|
+
const updateMatch = match.copy(match.inputDescriptor, match.document, match.documentError, deviceKeyInfo);
|
|
104
|
+
match = updateMatch;
|
|
123
105
|
}
|
|
124
|
-
docsAndDescriptors.push(match);
|
|
125
106
|
}
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
catch (e) {
|
|
108
|
+
console.log(`We tied to ammend key info from the KMS, but failed. Potential trouble ahead ${e.message}`, e);
|
|
128
109
|
}
|
|
110
|
+
docsAndDescriptors.push(match);
|
|
129
111
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (lastError) {
|
|
133
|
-
return Promise.reject(Error((_f = lastError.verifications[0].message) !== null && _f !== void 0 ? _f : 'No matching documents found'));
|
|
112
|
+
else if (result.error) {
|
|
113
|
+
lastError = result;
|
|
134
114
|
}
|
|
135
|
-
return Promise.reject(Error('No matching documents found'));
|
|
136
115
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
116
|
+
}
|
|
117
|
+
if (docsAndDescriptors.length === 0) {
|
|
118
|
+
if (lastError) {
|
|
119
|
+
return Promise.reject(Error(lastError.verifications[0].message ?? 'No matching documents found'));
|
|
120
|
+
}
|
|
121
|
+
return Promise.reject(Error('No matching documents found'));
|
|
122
|
+
}
|
|
123
|
+
const deviceResponse = await oid4vpService.createDeviceResponse(docsAndDescriptors, presentationDefinition, clientId, responseUri, authorizationRequestNonce);
|
|
124
|
+
const vp_token = encodeTo(deviceResponse.cborEncode(), Encoding.BASE64URL);
|
|
125
|
+
const presentation_submission = Oid4VPPresentationSubmission.Static.fromPresentationDefinition(presentationDefinition);
|
|
126
|
+
return { vp_token, presentation_submission };
|
|
142
127
|
}
|
|
143
128
|
/**
|
|
144
129
|
* Verifies on the Relying Party (RP) side for mdoc (mobile document) OIDC4VP (OpenID Connect for Verifiable Presentations).
|
|
@@ -148,54 +133,52 @@ class MDLMdoc {
|
|
|
148
133
|
* @return {Promise<MdocOid4vpRPVerifyResult>} - A promise that resolves to an object containing error status,
|
|
149
134
|
* validated documents, and the original presentation submission.
|
|
150
135
|
*/
|
|
151
|
-
mdocOid4vpRPVerify(args, _context) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
error = true;
|
|
164
|
-
}
|
|
165
|
-
if (presentation_submission.descriptor_map.find((m) => m.id === document.docType.value) === null) {
|
|
166
|
-
error = true;
|
|
167
|
-
validations.verifications.push({
|
|
168
|
-
name: 'mdoc',
|
|
169
|
-
error,
|
|
170
|
-
critical: error,
|
|
171
|
-
message: `No descriptor map id with document type ${document.docType.value} present`
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return { document: document.toJson(), validations };
|
|
136
|
+
async mdocOid4vpRPVerify(args, _context) {
|
|
137
|
+
const { vp_token, presentation_submission, trustAnchors } = args;
|
|
138
|
+
const deviceResponse = DeviceResponseCbor.Static.cborDecode(decodeFrom(vp_token, Encoding.BASE64URL));
|
|
139
|
+
if (!deviceResponse.documents) {
|
|
140
|
+
return Promise.reject(Error(`No documents found in vp_token`));
|
|
141
|
+
}
|
|
142
|
+
let error = false;
|
|
143
|
+
const documents = await Promise.all(deviceResponse.documents.map(async (document) => {
|
|
144
|
+
try {
|
|
145
|
+
const validations = await MdocValidations.fromDocumentAsync(document, null, trustAnchors ?? this.trustAnchors);
|
|
146
|
+
if (!validations || validations.error) {
|
|
147
|
+
error = true;
|
|
175
148
|
}
|
|
176
|
-
|
|
149
|
+
if (presentation_submission.descriptor_map.find((m) => m.id === document.docType.value) === null) {
|
|
177
150
|
error = true;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
name: 'mdoc',
|
|
185
|
-
error,
|
|
186
|
-
critical: true,
|
|
187
|
-
message: e.message
|
|
188
|
-
}
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
};
|
|
151
|
+
validations.verifications.push({
|
|
152
|
+
name: 'mdoc',
|
|
153
|
+
error,
|
|
154
|
+
critical: error,
|
|
155
|
+
message: `No descriptor map id with document type ${document.docType.value} present`,
|
|
156
|
+
});
|
|
192
157
|
}
|
|
193
|
-
|
|
194
|
-
if (error) {
|
|
195
|
-
console.log(JSON.stringify(documents, null, 2));
|
|
158
|
+
return { document: document.toJson(), validations };
|
|
196
159
|
}
|
|
197
|
-
|
|
198
|
-
|
|
160
|
+
catch (e) {
|
|
161
|
+
error = true;
|
|
162
|
+
return {
|
|
163
|
+
document: document.toJson(),
|
|
164
|
+
validations: {
|
|
165
|
+
error: true,
|
|
166
|
+
verifications: [
|
|
167
|
+
{
|
|
168
|
+
name: 'mdoc',
|
|
169
|
+
error,
|
|
170
|
+
critical: true,
|
|
171
|
+
message: e.message,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
if (error) {
|
|
179
|
+
console.log(JSON.stringify(documents, null, 2));
|
|
180
|
+
}
|
|
181
|
+
return { error, documents, presentation_submission };
|
|
199
182
|
}
|
|
200
183
|
/**
|
|
201
184
|
* Verifies the issuer-signed Mobile Document (mDoc) using the provided arguments and context.
|
|
@@ -204,13 +187,11 @@ class MDLMdoc {
|
|
|
204
187
|
* @param {IRequiredContext} context - The context encompassing necessary dependencies and configurations.
|
|
205
188
|
* @return {Promise<IVerifySignatureResult<KeyType>>} A promise that resolves to the result of the signature verification, including key information if available.
|
|
206
189
|
*/
|
|
207
|
-
mdocVerifyIssuerSigned(args, context) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return Object.assign(Object.assign({}, verification), { keyInfo: keyInfo });
|
|
213
|
-
});
|
|
190
|
+
async mdocVerifyIssuerSigned(args, context) {
|
|
191
|
+
const { input, keyInfo, requireX5Chain } = args;
|
|
192
|
+
const coseKeyInfo = keyInfo && CoseJoseKeyMappingService.toCoseKeyInfo(keyInfo);
|
|
193
|
+
const verification = await new CoseCryptoServiceJS(new CoseCryptoService(context)).verify1(CoseSign1Json.Static.fromDTO(input).toCbor(), coseKeyInfo, requireX5Chain);
|
|
194
|
+
return { ...verification, keyInfo: keyInfo };
|
|
214
195
|
}
|
|
215
196
|
/**
|
|
216
197
|
* Verifies an X.509 certificate chain against a set of trust anchors.
|
|
@@ -220,15 +201,16 @@ class MDLMdoc {
|
|
|
220
201
|
* @param {IRequiredContext} _context - The context required for verification, including necessary dependencies and settings.
|
|
221
202
|
* @return {Promise<X509ValidationResult>} A promise that resolves to the result of the validation process, indicating the success or failure of the certificate chain verification.
|
|
222
203
|
*/
|
|
223
|
-
x509VerifyCertificateChain(args, _context) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return validationResult;
|
|
204
|
+
async x509VerifyCertificateChain(args, _context) {
|
|
205
|
+
const mergedAnchors = [...this.trustAnchors, ...(args.trustAnchors ?? [])];
|
|
206
|
+
const trustAnchors = new Set(mergedAnchors);
|
|
207
|
+
const validationResult = await new X509CallbackService(Array.from(mergedAnchors)).verifyCertificateChain({
|
|
208
|
+
...args,
|
|
209
|
+
trustAnchors: Array.from(trustAnchors),
|
|
210
|
+
opts: { ...args?.opts, ...this.opts },
|
|
231
211
|
});
|
|
212
|
+
console.log(`x509 validation for ${validationResult.error ? 'Error' : 'Success'}. message: ${validationResult.message}, details: ${validationResult.detailMessage}`);
|
|
213
|
+
return validationResult;
|
|
232
214
|
}
|
|
233
215
|
/**
|
|
234
216
|
* Extracts information from a list of X509 certificates.
|
|
@@ -240,12 +222,9 @@ class MDLMdoc {
|
|
|
240
222
|
* @return {Promise<CertificateInfo[]>} A promise that resolves with an array of certificate
|
|
241
223
|
* information objects, each containing details extracted from individual certificates.
|
|
242
224
|
*/
|
|
243
|
-
x509GetCertificateInfo(args, context) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return yield Promise.all(certificates.map((cert) => (0, ssi_sdk_ext_x509_utils_1.getCertificateInfo)(cert, args.sanTypeFilter && { sanTypeFilter: args.sanTypeFilter })));
|
|
247
|
-
});
|
|
225
|
+
async x509GetCertificateInfo(args, context) {
|
|
226
|
+
const certificates = args.certificates.map((cert) => pemOrDerToX509Certificate(cert));
|
|
227
|
+
return await Promise.all(certificates.map((cert) => getCertificateInfo(cert, args.sanTypeFilter && { sanTypeFilter: args.sanTypeFilter })));
|
|
248
228
|
}
|
|
249
229
|
}
|
|
250
|
-
exports.MDLMdoc = MDLMdoc;
|
|
251
230
|
//# sourceMappingURL=mDLMdoc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mDLMdoc.js","sourceRoot":"","sources":["../../src/agent/mDLMdoc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mDLMdoc.js","sourceRoot":"","sources":["../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CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7I,CAAC;CACF"}
|
package/dist/functions/index.js
CHANGED
|
@@ -1,155 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.X509CallbackService = exports.CoseCryptoService = void 0;
|
|
36
|
-
const kmp_mdoc_core_1 = require("@sphereon/kmp-mdoc-core");
|
|
37
|
-
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
38
|
-
const ssi_sdk_ext_x509_utils_1 = require("@sphereon/ssi-sdk-ext.x509-utils");
|
|
39
|
-
const crypto = __importStar(require("crypto"));
|
|
40
|
-
const pkijs_1 = require("pkijs");
|
|
41
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
42
|
-
var CoseKeyCbor = kmp_mdoc_core_1.com.sphereon.crypto.cose.CoseKeyCbor;
|
|
43
|
-
var CoseJoseKeyMappingService = kmp_mdoc_core_1.com.sphereon.crypto.CoseJoseKeyMappingService;
|
|
44
|
-
var DefaultCallbacks = kmp_mdoc_core_1.com.sphereon.crypto.DefaultCallbacks;
|
|
45
|
-
var SignatureAlgorithm = kmp_mdoc_core_1.com.sphereon.crypto.generic.SignatureAlgorithm;
|
|
46
|
-
var KeyInfo = kmp_mdoc_core_1.com.sphereon.crypto.KeyInfo;
|
|
47
|
-
var ResolvedKeyInfo = kmp_mdoc_core_1.com.sphereon.crypto.ResolvedKeyInfo;
|
|
48
|
-
var DateTimeUtils = kmp_mdoc_core_1.com.sphereon.kmp.DateTimeUtils;
|
|
49
|
-
var decodeFrom = kmp_mdoc_core_1.com.sphereon.kmp.decodeFrom;
|
|
50
|
-
var encodeTo = kmp_mdoc_core_1.com.sphereon.kmp.encodeTo;
|
|
51
|
-
var Encoding = kmp_mdoc_core_1.com.sphereon.kmp.Encoding;
|
|
52
|
-
class CoseCryptoService {
|
|
1
|
+
import { com } from '@sphereon/kmp-mdoc-core';
|
|
2
|
+
import { calculateJwkThumbprint, globalCrypto, verifyRawSignature } from '@sphereon/ssi-sdk-ext.key-utils';
|
|
3
|
+
import { derToPEM, getCertificateInfo, getSubjectDN, pemOrDerToX509Certificate, validateX509CertificateChain, } from '@sphereon/ssi-sdk-ext.x509-utils';
|
|
4
|
+
import * as crypto from 'crypto';
|
|
5
|
+
import { CryptoEngine, setEngine } from 'pkijs';
|
|
6
|
+
import * as u8a from 'uint8arrays';
|
|
7
|
+
var CoseKeyCbor = com.sphereon.crypto.cose.CoseKeyCbor;
|
|
8
|
+
var CoseJoseKeyMappingService = com.sphereon.crypto.CoseJoseKeyMappingService;
|
|
9
|
+
var DefaultCallbacks = com.sphereon.crypto.DefaultCallbacks;
|
|
10
|
+
var SignatureAlgorithm = com.sphereon.crypto.generic.SignatureAlgorithm;
|
|
11
|
+
var KeyInfo = com.sphereon.crypto.KeyInfo;
|
|
12
|
+
var ResolvedKeyInfo = com.sphereon.crypto.ResolvedKeyInfo;
|
|
13
|
+
var DateTimeUtils = com.sphereon.kmp.DateTimeUtils;
|
|
14
|
+
var decodeFrom = com.sphereon.kmp.decodeFrom;
|
|
15
|
+
var encodeTo = com.sphereon.kmp.encodeTo;
|
|
16
|
+
var Encoding = com.sphereon.kmp.Encoding;
|
|
17
|
+
export class CoseCryptoService {
|
|
18
|
+
context;
|
|
53
19
|
constructor(context) {
|
|
54
20
|
this.context = context;
|
|
55
21
|
}
|
|
56
22
|
setContext(context) {
|
|
57
23
|
this.context = context;
|
|
58
24
|
}
|
|
59
|
-
signAsync(input, requireX5Chain) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
25
|
+
async signAsync(input, requireX5Chain) {
|
|
26
|
+
if (!this.context) {
|
|
27
|
+
throw Error('No context provided. Please provide a context with the setContext method or constructor');
|
|
28
|
+
}
|
|
29
|
+
const { keyInfo, alg, value } = input;
|
|
30
|
+
let kmsKeyRef = keyInfo.kmsKeyRef ?? undefined;
|
|
31
|
+
if (!kmsKeyRef) {
|
|
32
|
+
const key = keyInfo.key;
|
|
33
|
+
if (key == null) {
|
|
34
|
+
return Promise.reject(Error('No key present in keyInfo. This implementation cannot sign without a key!'));
|
|
64
35
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return Promise.reject(Error('No key present in keyInfo. This implementation cannot sign without a key!'));
|
|
71
|
-
}
|
|
72
|
-
const resolvedKeyInfo = ResolvedKeyInfo.Static.fromKeyInfo(keyInfo, key);
|
|
73
|
-
const jwkKeyInfo = CoseJoseKeyMappingService.toResolvedJwkKeyInfo(resolvedKeyInfo);
|
|
74
|
-
const kid = (_c = (_b = jwkKeyInfo.kid) !== null && _b !== void 0 ? _b : (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk: jwkKeyInfo.key.toJsonDTO() })) !== null && _c !== void 0 ? _c : jwkKeyInfo.key.getKidAsString(true);
|
|
75
|
-
if (!kid) {
|
|
76
|
-
return Promise.reject(Error('No kid present and not kmsKeyRef provided'));
|
|
77
|
-
}
|
|
78
|
-
kmsKeyRef = kid;
|
|
36
|
+
const resolvedKeyInfo = ResolvedKeyInfo.Static.fromKeyInfo(keyInfo, key);
|
|
37
|
+
const jwkKeyInfo = CoseJoseKeyMappingService.toResolvedJwkKeyInfo(resolvedKeyInfo);
|
|
38
|
+
const kid = jwkKeyInfo.kid ?? calculateJwkThumbprint({ jwk: jwkKeyInfo.key.toJsonDTO() }) ?? jwkKeyInfo.key.getKidAsString(true);
|
|
39
|
+
if (!kid) {
|
|
40
|
+
return Promise.reject(Error('No kid present and not kmsKeyRef provided'));
|
|
79
41
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
42
|
+
kmsKeyRef = kid;
|
|
43
|
+
}
|
|
44
|
+
const result = await this.context.agent.keyManagerSign({
|
|
45
|
+
algorithm: alg.jose.value,
|
|
46
|
+
data: encodeTo(value, Encoding.UTF8),
|
|
47
|
+
encoding: 'utf-8',
|
|
48
|
+
keyRef: kmsKeyRef,
|
|
87
49
|
});
|
|
50
|
+
return decodeFrom(result, Encoding.UTF8);
|
|
88
51
|
}
|
|
89
|
-
verify1Async(input, keyInfo, requireX5Chain) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// We should not be able to get here anyway, as the MLD-mdoc library already validated at this point. But let's make sure
|
|
95
|
-
return Promise.reject(new Error(`No x5chain was present in the CoseSign headers!`));
|
|
96
|
-
}
|
|
97
|
-
// TODO: According to the IETF spec there should be a x5t in case the x5chain is in the protected headers. In the Funke this does not seem to be done/used!
|
|
98
|
-
issuerCert = x5c ? (0, ssi_sdk_ext_x509_utils_1.pemOrDerToX509Certificate)(x5c[0]) : undefined;
|
|
99
|
-
let issuerJwk;
|
|
100
|
-
if (issuerCert) {
|
|
101
|
-
const info = yield (0, ssi_sdk_ext_x509_utils_1.getCertificateInfo)(issuerCert);
|
|
102
|
-
issuerJwk = info.publicKeyJWK;
|
|
103
|
-
}
|
|
104
|
-
return { issuerCert, issuerJwk };
|
|
105
|
-
});
|
|
106
|
-
const coseKeyInfo = CoseJoseKeyMappingService.toCoseKeyInfo(keyInfo);
|
|
107
|
-
if ((_a = coseKeyInfo === null || coseKeyInfo === void 0 ? void 0 : coseKeyInfo.key) === null || _a === void 0 ? void 0 : _a.d) {
|
|
108
|
-
throw Error('Do not use private keys to verify!');
|
|
109
|
-
}
|
|
110
|
-
else if (!((_b = input.payload) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
111
|
-
return Promise.reject(Error('Signature validation without payload not supported'));
|
|
52
|
+
async verify1Async(input, keyInfo, requireX5Chain) {
|
|
53
|
+
const getCertAndKey = async (x5c) => {
|
|
54
|
+
if (requireX5Chain && (!x5c || x5c.length === 0)) {
|
|
55
|
+
// We should not be able to get here anyway, as the MLD-mdoc library already validated at this point. But let's make sure
|
|
56
|
+
return Promise.reject(new Error(`No x5chain was present in the CoseSign headers!`));
|
|
112
57
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
58
|
+
// TODO: According to the IETF spec there should be a x5t in case the x5chain is in the protected headers. In the Funke this does not seem to be done/used!
|
|
59
|
+
issuerCert = x5c ? pemOrDerToX509Certificate(x5c[0]) : undefined;
|
|
60
|
+
let issuerJwk;
|
|
61
|
+
if (issuerCert) {
|
|
62
|
+
const info = await getCertificateInfo(issuerCert);
|
|
63
|
+
issuerJwk = info.publicKeyJWK;
|
|
117
64
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
65
|
+
return { issuerCert, issuerJwk };
|
|
66
|
+
};
|
|
67
|
+
const coseKeyInfo = CoseJoseKeyMappingService.toCoseKeyInfo(keyInfo);
|
|
68
|
+
if (coseKeyInfo?.key?.d) {
|
|
69
|
+
throw Error('Do not use private keys to verify!');
|
|
70
|
+
}
|
|
71
|
+
else if (!input.payload?.value) {
|
|
72
|
+
return Promise.reject(Error('Signature validation without payload not supported'));
|
|
73
|
+
}
|
|
74
|
+
const sign1Json = input.toJson(); // Let's make it a bit easier on ourselves, instead of working with CBOR
|
|
75
|
+
const coseAlg = sign1Json.protectedHeader.alg;
|
|
76
|
+
if (!coseAlg) {
|
|
77
|
+
return Promise.reject(Error('No alg protected header present'));
|
|
78
|
+
}
|
|
79
|
+
let issuerCert;
|
|
80
|
+
let issuerCoseKey;
|
|
81
|
+
let kid = coseKeyInfo?.kid ?? sign1Json.protectedHeader.kid ?? sign1Json.unprotectedHeader?.kid;
|
|
82
|
+
// Please note this method does not perform chain validation. The MDL-MSO_MDOC library already performed this before this step
|
|
83
|
+
const x5c = coseKeyInfo?.key?.getX509CertificateChain() ?? sign1Json.protectedHeader?.x5chain ?? sign1Json.unprotectedHeader?.x5chain;
|
|
84
|
+
if (!coseKeyInfo || !coseKeyInfo?.key || coseKeyInfo?.key?.x5chain) {
|
|
85
|
+
const certAndKey = await getCertAndKey(x5c);
|
|
86
|
+
issuerCoseKey = certAndKey.issuerJwk ? CoseJoseKeyMappingService.toCoseKey(certAndKey.issuerJwk) : undefined;
|
|
87
|
+
issuerCert = certAndKey.issuerCert;
|
|
88
|
+
}
|
|
89
|
+
if (!issuerCoseKey) {
|
|
90
|
+
if (!coseKeyInfo?.key) {
|
|
91
|
+
return Promise.reject(Error(`Either a x5c needs to be in the headers, or you need to provide a key for verification`));
|
|
127
92
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
return Promise.reject(Error(`Either a x5c needs to be in the headers, or you need to provide a key for verification`));
|
|
131
|
-
}
|
|
132
|
-
if (kid === null) {
|
|
133
|
-
kid = coseKeyInfo.key.getKidAsString(false);
|
|
134
|
-
}
|
|
135
|
-
issuerCoseKey = CoseKeyCbor.Static.fromDTO(coseKeyInfo.key);
|
|
93
|
+
if (kid === null) {
|
|
94
|
+
kid = coseKeyInfo.key.getKidAsString(false);
|
|
136
95
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
name: 'mdoc',
|
|
147
|
-
critical: true,
|
|
148
|
-
error: !valid,
|
|
149
|
-
message: `Signature of '${issuerCert ? (0, ssi_sdk_ext_x509_utils_1.getSubjectDN)(issuerCert).DN : kid}' was ${valid ? '' : 'in'}valid`,
|
|
150
|
-
keyInfo: issuerCoseKeyInfo,
|
|
151
|
-
};
|
|
96
|
+
issuerCoseKey = CoseKeyCbor.Static.fromDTO(coseKeyInfo.key);
|
|
97
|
+
}
|
|
98
|
+
const issuerCoseKeyInfo = new KeyInfo(kid, issuerCoseKey, coseKeyInfo.opts, coseKeyInfo.keyVisibility, issuerCoseKey.getSignatureAlgorithm() ?? coseKeyInfo.signatureAlgorithm, x5c, coseKeyInfo.kmsKeyRef, coseKeyInfo.kms, coseKeyInfo.keyType ?? issuerCoseKey.getKty());
|
|
99
|
+
const recalculatedToBeSigned = input.toBeSignedJson(issuerCoseKeyInfo, SignatureAlgorithm.Static.fromCose(coseAlg));
|
|
100
|
+
const key = CoseJoseKeyMappingService.toJoseJwk(issuerCoseKeyInfo.key).toJsonDTO();
|
|
101
|
+
const valid = await verifyRawSignature({
|
|
102
|
+
data: u8a.fromString(recalculatedToBeSigned.base64UrlValue, 'base64url'),
|
|
103
|
+
signature: u8a.fromString(sign1Json.signature, 'base64url'),
|
|
104
|
+
key,
|
|
152
105
|
});
|
|
106
|
+
return {
|
|
107
|
+
name: 'mdoc',
|
|
108
|
+
critical: true,
|
|
109
|
+
error: !valid,
|
|
110
|
+
message: `Signature of '${issuerCert ? getSubjectDN(issuerCert).DN : kid}' was ${valid ? '' : 'in'}valid`,
|
|
111
|
+
keyInfo: issuerCoseKeyInfo,
|
|
112
|
+
};
|
|
153
113
|
}
|
|
154
114
|
resolvePublicKeyAsync(keyInfo) {
|
|
155
115
|
if (keyInfo.key) {
|
|
@@ -158,7 +118,6 @@ class CoseCryptoService {
|
|
|
158
118
|
return Promise.reject(Error('No key present in keyInfo. This implementation cannot resolve public keys on its own currently!'));
|
|
159
119
|
}
|
|
160
120
|
}
|
|
161
|
-
exports.CoseCryptoService = CoseCryptoService;
|
|
162
121
|
/**
|
|
163
122
|
* This class can be used for X509 validations.
|
|
164
123
|
* Either have an instance per trustedCerts and verification invocation or use a single instance and provide the trusted certs in the method argument
|
|
@@ -166,18 +125,9 @@ exports.CoseCryptoService = CoseCryptoService;
|
|
|
166
125
|
* The class is also registered with the low-level mDL/mdoc Kotlin Multiplatform library
|
|
167
126
|
* Next to the specific function for the library it exports a more powerful version of the same verification method as well
|
|
168
127
|
*/
|
|
169
|
-
class X509CallbackService {
|
|
128
|
+
export class X509CallbackService {
|
|
129
|
+
_trustedCerts;
|
|
170
130
|
constructor(trustedCerts) {
|
|
171
|
-
this.setTrustedCerts = (trustedCertsInPEM) => {
|
|
172
|
-
this._trustedCerts = trustedCertsInPEM === null || trustedCertsInPEM === void 0 ? void 0 : trustedCertsInPEM.map((cert) => {
|
|
173
|
-
if (cert.includes('CERTIFICATE')) {
|
|
174
|
-
// PEM
|
|
175
|
-
return cert;
|
|
176
|
-
}
|
|
177
|
-
return (0, ssi_sdk_ext_x509_utils_1.derToPEM)(cert);
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
this.getTrustedCerts = () => this._trustedCerts;
|
|
181
131
|
this.setTrustedCerts(trustedCerts);
|
|
182
132
|
}
|
|
183
133
|
/**
|
|
@@ -186,50 +136,54 @@ class X509CallbackService {
|
|
|
186
136
|
* @param trustAnchors
|
|
187
137
|
* @param verificationTime
|
|
188
138
|
*/
|
|
189
|
-
verifyCertificateChain(
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
opts,
|
|
196
|
-
});
|
|
139
|
+
async verifyCertificateChain({ chain, trustAnchors = this.getTrustedCerts(), verificationTime, opts, }) {
|
|
140
|
+
return await validateX509CertificateChain({
|
|
141
|
+
chain,
|
|
142
|
+
trustAnchors,
|
|
143
|
+
verificationTime,
|
|
144
|
+
opts,
|
|
197
145
|
});
|
|
198
146
|
}
|
|
199
147
|
/**
|
|
200
148
|
* This method is the implementation used within the mDL/Mdoc library
|
|
201
149
|
*/
|
|
202
|
-
verifyCertificateChainJS(chainDER, chainPEM, trustedCerts, verificationProfile, verificationTime) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
verificationTime: new Date(verificationAt.toEpochSeconds().toULong() * 1000),
|
|
217
|
-
opts: { trustRootWhenNoAnchors: true },
|
|
218
|
-
});
|
|
219
|
-
const cert = result.certificateChain ? result.certificateChain[result.certificateChain.length - 1] : undefined;
|
|
220
|
-
return {
|
|
221
|
-
publicKey: cert === null || cert === void 0 ? void 0 : cert.publicKeyJWK, // fixme
|
|
222
|
-
publicKeyAlgorithm: (_a = cert === null || cert === void 0 ? void 0 : cert.publicKeyJWK) === null || _a === void 0 ? void 0 : _a.alg,
|
|
223
|
-
name: 'x.509',
|
|
224
|
-
critical: result.critical,
|
|
225
|
-
message: result.message,
|
|
226
|
-
error: result.error,
|
|
227
|
-
verificationTime: verificationAt,
|
|
228
|
-
};
|
|
150
|
+
async verifyCertificateChainJS(chainDER, chainPEM, trustedCerts, verificationProfile, verificationTime) {
|
|
151
|
+
const verificationAt = verificationTime ?? DateTimeUtils.Static.DEFAULT.dateTimeLocal();
|
|
152
|
+
let chain = [];
|
|
153
|
+
if (chainDER && chainDER.length > 0) {
|
|
154
|
+
chain = chainDER.map((der) => Uint8Array.from(der));
|
|
155
|
+
}
|
|
156
|
+
if (chainPEM && chainPEM.length > 0) {
|
|
157
|
+
chain = (chain ?? []).concat(chainPEM);
|
|
158
|
+
}
|
|
159
|
+
const result = await validateX509CertificateChain({
|
|
160
|
+
chain: chain, // The function will handle an empty array
|
|
161
|
+
trustAnchors: trustedCerts ?? this.getTrustedCerts(),
|
|
162
|
+
verificationTime: new Date(verificationAt.toEpochSeconds().toULong() * 1000),
|
|
163
|
+
opts: { trustRootWhenNoAnchors: true },
|
|
229
164
|
});
|
|
165
|
+
const cert = result.certificateChain ? result.certificateChain[result.certificateChain.length - 1] : undefined;
|
|
166
|
+
return {
|
|
167
|
+
publicKey: cert?.publicKeyJWK, // fixme
|
|
168
|
+
publicKeyAlgorithm: cert?.publicKeyJWK?.alg,
|
|
169
|
+
name: 'x.509',
|
|
170
|
+
critical: result.critical,
|
|
171
|
+
message: result.message,
|
|
172
|
+
error: result.error,
|
|
173
|
+
verificationTime: verificationAt,
|
|
174
|
+
};
|
|
230
175
|
}
|
|
176
|
+
setTrustedCerts = (trustedCertsInPEM) => {
|
|
177
|
+
this._trustedCerts = trustedCertsInPEM?.map((cert) => {
|
|
178
|
+
if (cert.includes('CERTIFICATE')) {
|
|
179
|
+
// PEM
|
|
180
|
+
return cert;
|
|
181
|
+
}
|
|
182
|
+
return derToPEM(cert);
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
getTrustedCerts = () => this._trustedCerts;
|
|
231
186
|
}
|
|
232
|
-
exports.X509CallbackService = X509CallbackService;
|
|
233
187
|
const defaultCryptoEngine = () => {
|
|
234
188
|
if (typeof self !== 'undefined') {
|
|
235
189
|
if ('crypto' in self) {
|
|
@@ -238,19 +192,19 @@ const defaultCryptoEngine = () => {
|
|
|
238
192
|
engineName = 'safari';
|
|
239
193
|
}
|
|
240
194
|
// @ts-ignore
|
|
241
|
-
|
|
195
|
+
setEngine(engineName, new CryptoEngine({ name: engineName, crypto: crypto }));
|
|
242
196
|
}
|
|
243
197
|
}
|
|
244
198
|
else if (typeof crypto !== 'undefined' && 'webcrypto' in crypto) {
|
|
245
199
|
const name = 'NodeJS ^15';
|
|
246
200
|
const nodeCrypto = crypto.webcrypto;
|
|
247
201
|
// @ts-ignore
|
|
248
|
-
|
|
202
|
+
setEngine(name, new CryptoEngine({ name, crypto: nodeCrypto }));
|
|
249
203
|
}
|
|
250
204
|
else {
|
|
251
205
|
// @ts-ignore
|
|
252
206
|
const name = 'crypto';
|
|
253
|
-
|
|
207
|
+
setEngine(name, new CryptoEngine({ name, crypto: globalCrypto(false) }));
|
|
254
208
|
}
|
|
255
209
|
};
|
|
256
210
|
defaultCryptoEngine();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAC1G,OAAO,EAEL,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,GAE7B,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAe,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAElC,IAAO,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAA;AAIzD,IAAO,yB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UAAU,GAAG,MAAM,CAAC,SAAS,CAAA;QACnC,aAAa;QACb,SAAS,CAAC,IAAI,EAAE,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IACjE,CAAC;SAAM,CAAC;QACN,aAAa;QACb,MAAM,IAAI,GAAG,QAAQ,CAAA;QACrB,SAAS,CAAC,IAAI,EAAE,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1E,CAAC;AACH,CAAC,CAAA;AAED,mBAAmB,EAAE,CAAA;AAErB,wIAAwI;AACxI,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAA;AAC9D,gBAAgB,CAAC,cAAc,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.mdocSupportMethods = exports.MDLMdoc = exports.schema = exports.logger = void 0;
|
|
18
|
-
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
19
|
-
exports.logger = ssi_types_1.Loggers.DEFAULT.get('sphereon:mdoc');
|
|
1
|
+
import { Loggers } from '@sphereon/ssi-types';
|
|
2
|
+
export const logger = Loggers.DEFAULT.get('sphereon:mdoc');
|
|
20
3
|
const schema = require('../plugin.schema.json');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
__exportStar(require("./types/ImDLMdoc"), exports);
|
|
26
|
-
__exportStar(require("./functions"), exports);
|
|
4
|
+
export { schema };
|
|
5
|
+
export { MDLMdoc, mdocSupportMethods } from './agent/mDLMdoc';
|
|
6
|
+
export * from './types/ImDLMdoc';
|
|
7
|
+
export * from './functions';
|
|
27
8
|
//# 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,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA"}
|
package/dist/types/ImDLMdoc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.mdl-mdoc",
|
|
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",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sphereon/did-auth-siop": "0.
|
|
17
|
+
"@sphereon/did-auth-siop-adapter": "0.17.0",
|
|
18
18
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
19
19
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
20
20
|
"@sphereon/pex-models": "^2.3.2",
|
|
21
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
22
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.
|
|
23
|
-
"@sphereon/ssi-sdk-ext.x509-utils": "0.
|
|
24
|
-
"@sphereon/ssi-sdk.core": "0.
|
|
25
|
-
"@sphereon/ssi-types": "0.
|
|
21
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.0",
|
|
22
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.0",
|
|
23
|
+
"@sphereon/ssi-sdk-ext.x509-utils": "0.28.0",
|
|
24
|
+
"@sphereon/ssi-sdk.core": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
25
|
+
"@sphereon/ssi-types": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
26
26
|
"@veramo/core": "4.2.0",
|
|
27
27
|
"@veramo/did-manager": "4.2.0",
|
|
28
28
|
"@veramo/utils": "4.2.0",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"uuid": "^9.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@sphereon/oid4vci-client": "0.
|
|
39
|
-
"@sphereon/oid4vci-common": "0.
|
|
40
|
-
"@sphereon/ssi-express-support": "0.
|
|
41
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.
|
|
42
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.
|
|
43
|
-
"@sphereon/ssi-sdk.agent-config": "0.
|
|
44
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
45
|
-
"@sphereon/ssi-sdk.public-key-hosting": "0.
|
|
38
|
+
"@sphereon/oid4vci-client": "0.17.0",
|
|
39
|
+
"@sphereon/oid4vci-common": "0.17.0",
|
|
40
|
+
"@sphereon/ssi-express-support": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
41
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.28.0",
|
|
42
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.28.0",
|
|
43
|
+
"@sphereon/ssi-sdk.agent-config": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
44
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
45
|
+
"@sphereon/ssi-sdk.public-key-hosting": "0.33.1-feature.vcdm2.4+9f634bdb",
|
|
46
46
|
"@transmute/json-web-signature": "0.7.0-unstable.81",
|
|
47
47
|
"@types/cors": "^2.8.17",
|
|
48
48
|
"@types/express": "^4.17.21",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"cors": "^2.8.5",
|
|
58
58
|
"express": "^4.19.2",
|
|
59
59
|
"jose": "^5.6.3",
|
|
60
|
-
"typeorm": "^0.3.
|
|
60
|
+
"typeorm": "^0.3.21"
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
63
|
"plugin.schema.json",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"EBSI Authorization Client"
|
|
79
79
|
],
|
|
80
80
|
"nx": {},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "9f634bdb714061141e277508c124b08d626f6036"
|
|
82
82
|
}
|
package/src/agent/mDLMdoc.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import { com } from '@sphereon/kmp-mdoc-core'
|
|
2
2
|
import { calculateJwkThumbprint } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
3
|
-
import {
|
|
4
|
-
CertificateInfo,
|
|
5
|
-
getCertificateInfo,
|
|
6
|
-
pemOrDerToX509Certificate,
|
|
7
|
-
X509ValidationResult
|
|
8
|
-
} from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
3
|
+
import { CertificateInfo, getCertificateInfo, pemOrDerToX509Certificate, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
9
4
|
import { JWK } from '@sphereon/ssi-types'
|
|
10
5
|
import { IAgentPlugin } from '@veramo/core'
|
|
11
|
-
import {
|
|
12
|
-
MdocOid4vpPresentArgs,
|
|
13
|
-
MdocOid4VPPresentationAuth,
|
|
14
|
-
MdocOid4vpRPVerifyArgs,
|
|
15
|
-
MdocOid4vpRPVerifyResult,
|
|
16
|
-
schema
|
|
17
|
-
} from '..'
|
|
6
|
+
import { MdocOid4vpPresentArgs, MdocOid4VPPresentationAuth, MdocOid4vpRPVerifyArgs, MdocOid4vpRPVerifyResult, schema } from '..'
|
|
18
7
|
import { CoseCryptoService, X509CallbackService } from '../functions'
|
|
19
8
|
import {
|
|
20
9
|
GetX509CertificateInfoArgs,
|
|
@@ -22,7 +11,7 @@ import {
|
|
|
22
11
|
IRequiredContext,
|
|
23
12
|
KeyType,
|
|
24
13
|
MdocVerifyIssuerSignedArgs,
|
|
25
|
-
VerifyCertificateChainArgs
|
|
14
|
+
VerifyCertificateChainArgs,
|
|
26
15
|
} from '../types/ImDLMdoc'
|
|
27
16
|
import CborByteString = com.sphereon.cbor.CborByteString
|
|
28
17
|
import CoseKeyCbor = com.sphereon.crypto.cose.CoseKeyCbor
|
|
@@ -48,7 +37,7 @@ export const mdocSupportMethods: Array<string> = [
|
|
|
48
37
|
'x509GetCertificateInfo',
|
|
49
38
|
'mdocVerifyIssuerSigned',
|
|
50
39
|
'mdocOid4vpHolderPresent',
|
|
51
|
-
'mdocOid4vpRPVerify'
|
|
40
|
+
'mdocOid4vpRPVerify',
|
|
52
41
|
]
|
|
53
42
|
|
|
54
43
|
/**
|
|
@@ -63,7 +52,7 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
63
52
|
x509GetCertificateInfo: this.x509GetCertificateInfo.bind(this),
|
|
64
53
|
mdocVerifyIssuerSigned: this.mdocVerifyIssuerSigned.bind(this),
|
|
65
54
|
mdocOid4vpHolderPresent: this.mdocOid4vpHolderPresent.bind(this),
|
|
66
|
-
mdocOid4vpRPVerify: this.mdocOid4vpRPVerify.bind(this)
|
|
55
|
+
mdocOid4vpRPVerify: this.mdocOid4vpRPVerify.bind(this),
|
|
67
56
|
}
|
|
68
57
|
private readonly trustAnchors: string[]
|
|
69
58
|
private opts: {
|
|
@@ -96,16 +85,7 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
96
85
|
* @return {Promise<MdocOid4VPPresentationAuth>} A promise that resolves to an object containing vp_token and presentation_submission.
|
|
97
86
|
*/
|
|
98
87
|
private async mdocOid4vpHolderPresent(args: MdocOid4vpPresentArgs, _context: IRequiredContext): Promise<MdocOid4VPPresentationAuth> {
|
|
99
|
-
const {
|
|
100
|
-
mdocs,
|
|
101
|
-
presentationDefinition,
|
|
102
|
-
trustAnchors,
|
|
103
|
-
verifications,
|
|
104
|
-
mdocHolderNonce,
|
|
105
|
-
authorizationRequestNonce,
|
|
106
|
-
responseUri,
|
|
107
|
-
clientId
|
|
108
|
-
} = args
|
|
88
|
+
const { mdocs, presentationDefinition, trustAnchors, verifications, mdocHolderNonce, authorizationRequestNonce, responseUri, clientId } = args
|
|
109
89
|
|
|
110
90
|
const oid4vpService = new MdocOid4vpService()
|
|
111
91
|
// const mdoc = DocumentCbor.Static.cborDecode(decodeFrom(mdocBase64Url, Encoding.BASE64URL))
|
|
@@ -116,7 +96,7 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
116
96
|
null,
|
|
117
97
|
trustAnchors ?? this.trustAnchors,
|
|
118
98
|
DateTimeUtils.Static.DEFAULT.dateTimeLocal((verifications?.verificationTime?.getTime() ?? Date.now()) / 1000),
|
|
119
|
-
verifications?.allowExpiredDocuments
|
|
99
|
+
verifications?.allowExpiredDocuments,
|
|
120
100
|
)
|
|
121
101
|
if (result.error) {
|
|
122
102
|
console.log(JSON.stringify(result, null, 2))
|
|
@@ -131,9 +111,9 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
131
111
|
name: 'mdoc',
|
|
132
112
|
error: true,
|
|
133
113
|
critical: true,
|
|
134
|
-
message: e.message as string
|
|
135
|
-
}
|
|
136
|
-
]
|
|
114
|
+
message: e.message as string,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
137
117
|
}
|
|
138
118
|
}
|
|
139
119
|
}
|
|
@@ -141,7 +121,7 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
141
121
|
const allMatches: DocumentDescriptorMatchResult[] = oid4vpService.matchDocumentsAndDescriptors(
|
|
142
122
|
mdocHolderNonce,
|
|
143
123
|
mdocs,
|
|
144
|
-
presentationDefinition as IOid4VPPresentationDefinition
|
|
124
|
+
presentationDefinition as IOid4VPPresentationDefinition,
|
|
145
125
|
)
|
|
146
126
|
const docsAndDescriptors: DocumentDescriptorMatchResult[] = []
|
|
147
127
|
let lastError: com.sphereon.crypto.generic.IVerifyResults<com.sphereon.crypto.cose.ICoseKeyCbor> | undefined = undefined
|
|
@@ -164,7 +144,16 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
164
144
|
const kms = key.kms
|
|
165
145
|
const kmsKeyRef = key.meta?.kmsKeyRef
|
|
166
146
|
const updateCborKey = cborKey.copy(false, cborKey.kty, cborKey.kid ?? new CborByteString(decodeFrom(kid, Encoding.UTF8)))
|
|
167
|
-
const deviceKeyInfo = KeyInfo.Static.fromDTO(keyInfo).copy(
|
|
147
|
+
const deviceKeyInfo = KeyInfo.Static.fromDTO(keyInfo).copy(
|
|
148
|
+
kid,
|
|
149
|
+
updateCborKey,
|
|
150
|
+
keyInfo.opts,
|
|
151
|
+
keyInfo.keyVisibility,
|
|
152
|
+
keyInfo.signatureAlgorithm,
|
|
153
|
+
keyInfo.x5c,
|
|
154
|
+
kmsKeyRef,
|
|
155
|
+
kms,
|
|
156
|
+
)
|
|
168
157
|
const updateMatch = match.copy(match.inputDescriptor, match.document, match.documentError, deviceKeyInfo)
|
|
169
158
|
match = updateMatch
|
|
170
159
|
}
|
|
@@ -172,7 +161,6 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
172
161
|
console.log(`We tied to ammend key info from the KMS, but failed. Potential trouble ahead ${e.message}`, e)
|
|
173
162
|
}
|
|
174
163
|
|
|
175
|
-
|
|
176
164
|
docsAndDescriptors.push(match)
|
|
177
165
|
} else if (result.error) {
|
|
178
166
|
lastError = result
|
|
@@ -190,11 +178,11 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
190
178
|
presentationDefinition as IOid4VPPresentationDefinition,
|
|
191
179
|
clientId,
|
|
192
180
|
responseUri,
|
|
193
|
-
authorizationRequestNonce
|
|
181
|
+
authorizationRequestNonce,
|
|
194
182
|
)
|
|
195
183
|
const vp_token = encodeTo(deviceResponse.cborEncode(), Encoding.BASE64URL)
|
|
196
184
|
const presentation_submission = Oid4VPPresentationSubmission.Static.fromPresentationDefinition(
|
|
197
|
-
presentationDefinition as IOid4VPPresentationDefinition
|
|
185
|
+
presentationDefinition as IOid4VPPresentationDefinition,
|
|
198
186
|
)
|
|
199
187
|
return { vp_token, presentation_submission }
|
|
200
188
|
}
|
|
@@ -227,7 +215,7 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
227
215
|
name: 'mdoc',
|
|
228
216
|
error,
|
|
229
217
|
critical: error,
|
|
230
|
-
message: `No descriptor map id with document type ${document.docType.value} present
|
|
218
|
+
message: `No descriptor map id with document type ${document.docType.value} present`,
|
|
231
219
|
})
|
|
232
220
|
}
|
|
233
221
|
return { document: document.toJson(), validations }
|
|
@@ -242,13 +230,13 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
242
230
|
name: 'mdoc',
|
|
243
231
|
error,
|
|
244
232
|
critical: true,
|
|
245
|
-
message: e.message as string
|
|
246
|
-
}
|
|
247
|
-
]
|
|
248
|
-
}
|
|
233
|
+
message: e.message as string,
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
249
237
|
}
|
|
250
238
|
}
|
|
251
|
-
})
|
|
239
|
+
}),
|
|
252
240
|
)
|
|
253
241
|
if (error) {
|
|
254
242
|
console.log(JSON.stringify(documents, null, 2))
|
|
@@ -269,7 +257,7 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
269
257
|
const verification = await new CoseCryptoServiceJS(new CoseCryptoService(context)).verify1(
|
|
270
258
|
CoseSign1Json.Static.fromDTO(input).toCbor(),
|
|
271
259
|
coseKeyInfo,
|
|
272
|
-
requireX5Chain
|
|
260
|
+
requireX5Chain,
|
|
273
261
|
)
|
|
274
262
|
return { ...verification, keyInfo: keyInfo }
|
|
275
263
|
}
|
|
@@ -288,10 +276,10 @@ export class MDLMdoc implements IAgentPlugin {
|
|
|
288
276
|
const validationResult = await new X509CallbackService(Array.from(mergedAnchors)).verifyCertificateChain({
|
|
289
277
|
...args,
|
|
290
278
|
trustAnchors: Array.from(trustAnchors),
|
|
291
|
-
opts: { ...args?.opts, ...this.opts }
|
|
279
|
+
opts: { ...args?.opts, ...this.opts },
|
|
292
280
|
})
|
|
293
281
|
console.log(
|
|
294
|
-
`x509 validation for ${validationResult.error ? 'Error' : 'Success'}. message: ${validationResult.message}, details: ${validationResult.detailMessage}
|
|
282
|
+
`x509 validation for ${validationResult.error ? 'Error' : 'Success'}. message: ${validationResult.message}, details: ${validationResult.detailMessage}`,
|
|
295
283
|
)
|
|
296
284
|
return validationResult
|
|
297
285
|
}
|
package/src/functions/index.ts
CHANGED
|
@@ -58,7 +58,7 @@ export class CoseCryptoService implements ICoseCryptoCallbackJS {
|
|
|
58
58
|
const resolvedKeyInfo = ResolvedKeyInfo.Static.fromKeyInfo(keyInfo, key)
|
|
59
59
|
const jwkKeyInfo: ResolvedKeyInfo<Jwk> = CoseJoseKeyMappingService.toResolvedJwkKeyInfo(resolvedKeyInfo)
|
|
60
60
|
|
|
61
|
-
const kid = jwkKeyInfo.kid ?? calculateJwkThumbprint({jwk: jwkKeyInfo.key.toJsonDTO()}) ?? jwkKeyInfo.key.getKidAsString(true)
|
|
61
|
+
const kid = jwkKeyInfo.kid ?? calculateJwkThumbprint({ jwk: jwkKeyInfo.key.toJsonDTO() }) ?? jwkKeyInfo.key.getKidAsString(true)
|
|
62
62
|
if (!kid) {
|
|
63
63
|
return Promise.reject(Error('No kid present and not kmsKeyRef provided'))
|
|
64
64
|
}
|