@sphereon/ssi-sdk.mdl-mdoc 0.29.1-next.80

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2022] [Sphereon BV]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ <!--suppress HtmlDeprecatedAttribute -->
2
+ <h1 align="center">
3
+ <br>
4
+ <a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
5
+ <br>MDL-Mdoc (Typescript)
6
+ <br>
7
+ </h1>
8
+
9
+ ---
10
+
11
+ **Warning: This package still is in very early development. Breaking changes without notice will happen at this point!**
12
+
13
+ ---
14
+
15
+ This SDK module provides mDL-mdoc support for the SDK. The heavy lifting is performed by our Kotlin Multiplatform
16
+ low-level library however. You can find that library in a
17
+ separate [Github repository](https://github.com/Sphereon-Opensource/mDL-mdoc-multiplatform).
@@ -0,0 +1,10 @@
1
+ import { IAgentPlugin } from '@veramo/core';
2
+ import { ImDLMdoc } from '../types/ImDLMdoc';
3
+ export declare const mdocSupportMethods: Array<string>;
4
+ export declare class MDLMdoc implements IAgentPlugin {
5
+ readonly schema: any;
6
+ readonly methods: ImDLMdoc;
7
+ private mdocVerifyIssuerSigned;
8
+ private verifyCertificateChain;
9
+ }
10
+ //# sourceMappingURL=mDLMdoc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mDLMdoc.d.ts","sourceRoot":"","sources":["../../src/agent/mDLMdoc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAAE,QAAQ,EAAW,MAAM,mBAAmB,CAAA;AAMrD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAA8B,CAAA;AAE3E,qBAAa,OAAQ,YAAW,YAAY;IAC1C,QAAQ,CAAC,MAAM,MAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAGzB;YAEa,sBAAsB;YAWtB,sBAAsB;CAGrC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MDLMdoc = exports.mdocSupportMethods = void 0;
13
+ const kmp_mdl_mdoc_1 = require("@sphereon/kmp-mdl-mdoc");
14
+ const functions_1 = require("../functions");
15
+ const index_1 = require("../index");
16
+ var CoseSign1Json = kmp_mdl_mdoc_1.com.sphereon.cbor.cose.CoseSign1Json;
17
+ exports.mdocSupportMethods = ['mdocVerifyIssuerSigned'];
18
+ class MDLMdoc {
19
+ constructor() {
20
+ this.schema = index_1.schema.IMDLMdoc;
21
+ this.methods = {
22
+ verifyCertificateChain: this.verifyCertificateChain.bind(this),
23
+ mdocVerifyIssuerSigned: this.mdocVerifyIssuerSigned.bind(this),
24
+ };
25
+ }
26
+ mdocVerifyIssuerSigned(args, context) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const { input, keyInfo } = args;
29
+ // FIXME: The ignore because of json/cbor
30
+ // @ts-ignore
31
+ return yield new functions_1.CoseCryptoService().verify1(CoseSign1Json.Companion.fromDTO(input).toCbor(), Object.assign(Object.assign({}, keyInfo), { key: keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.key })); // fixme: Json to Cbor for key
32
+ });
33
+ }
34
+ verifyCertificateChain(args, _context) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return yield new functions_1.X509CallbackService().verifyCertificateChain(args);
37
+ });
38
+ }
39
+ }
40
+ exports.MDLMdoc = MDLMdoc;
41
+ //# sourceMappingURL=mDLMdoc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mDLMdoc.js","sourceRoot":"","sources":["../../src/agent/mDLMdoc.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA4C;AAG5C,4CAAqE;AACrE,oCAA2G;AAK3G,IAAO,aAAa,GAAG,kBAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA;AAE9C,QAAA,kBAAkB,GAAkB,CAAC,wBAAwB,CAAC,CAAA;AAE3E,MAAa,OAAO;IAApB;QACW,WAAM,GAAG,cAAM,CAAC,QAAQ,CAAA;QACxB,YAAO,GAAa;YAC3B,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9D,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/D,CAAA;IAgBH,CAAC;IAde,sBAAsB,CAAC,IAAgC,EAAE,OAAyB;;YAC9F,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;YAE/B,yCAAyC;YACzC,aAAa;YACb,OAAO,MAAM,IAAI,6BAAiB,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,gCACzF,OAAO,KACV,GAAG,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,GACQ,CAAC,CAAA,CAAC,8BAA8B;QAC7D,CAAC;KAAA;IAEa,sBAAsB,CAAC,IAAgC,EAAE,QAA0B;;YAC/F,OAAO,MAAM,IAAI,+BAAmB,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;QACrE,CAAC;KAAA;CACF;AArBD,0BAqBC"}
@@ -0,0 +1,42 @@
1
+ import { com, Nullable } from '@sphereon/kmp-mdl-mdoc';
2
+ import { X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils';
3
+ import { VerifyCertificateChainArgs } from '../types/ImDLMdoc';
4
+ import CoseSign1Cbor = com.sphereon.cbor.cose.CoseSign1Cbor;
5
+ import CoseSign1InputCbor = com.sphereon.cbor.cose.CoseSign1InputCbor;
6
+ import ICoseKeyCbor = com.sphereon.cbor.cose.ICoseKeyCbor;
7
+ import IKey = com.sphereon.cbor.cose.IKey;
8
+ import ICoseCryptoCallbackJS = com.sphereon.crypto.ICoseCryptoCallbackJS;
9
+ import IKeyInfo = com.sphereon.crypto.IKeyInfo;
10
+ import IVerifySignatureResult = com.sphereon.crypto.IVerifySignatureResult;
11
+ import IX509ServiceJS = com.sphereon.crypto.IX509ServiceJS;
12
+ import IX509VerificationResult = com.sphereon.crypto.IX509VerificationResult;
13
+ import X509VerificationProfile = com.sphereon.crypto.X509VerificationProfile;
14
+ export declare class CoseCryptoService implements ICoseCryptoCallbackJS {
15
+ sign1<CborType, JsonType>(input: CoseSign1InputCbor<CborType, JsonType>, keyInfo?: IKeyInfo<ICoseKeyCbor>): Promise<CoseSign1Cbor<CborType, JsonType>>;
16
+ verify1<CborType, JsonType>(input: CoseSign1Cbor<CborType, JsonType>, keyInfo?: IKeyInfo<ICoseKeyCbor>): Promise<IVerifySignatureResult<ICoseKeyCbor>>;
17
+ }
18
+ /**
19
+ * This class can be used for X509 validations.
20
+ * Either have an instance per trustedCerts and verification invocation or use a single instance and provide the trusted certs in the method argument
21
+ *
22
+ * The class is also registered with the low-level mDL/mdoc Kotlin Multiplatform library
23
+ * Next to the specific function for the library it exports a more powerful version of the same verification method as well
24
+ */
25
+ export declare class X509CallbackService implements IX509ServiceJS {
26
+ private _trustedCerts?;
27
+ constructor(trustedCerts?: Array<string>);
28
+ /**
29
+ * A more powerful version of the method below. Allows to verify at a specific time and returns more information
30
+ * @param chain
31
+ * @param trustAnchors
32
+ * @param verificationTime
33
+ */
34
+ verifyCertificateChain({ chain, trustAnchors, verificationTime, }: VerifyCertificateChainArgs): Promise<X509ValidationResult>;
35
+ /**
36
+ * This method is the implementation used within the mDL/Mdoc library
37
+ */
38
+ verifyCertificateChainJS<KeyType extends IKey>(chainDER: Nullable<Int8Array[]>, chainPEM: Nullable<string[]>, trustedCerts: Nullable<string[]>, verificationProfile?: X509VerificationProfile | undefined): Promise<IX509VerificationResult<KeyType>>;
39
+ setTrustedCerts: (trustedCertsInPEM?: Array<string>) => void;
40
+ getTrustedCerts: () => string[] | undefined;
41
+ }
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAGvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA;AAC3D,OAAO,kBAAkB,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAA;AACrE,OAAO,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAA;AACzD,OAAO,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;AAEzC,OAAO,qBAAqB,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAA;AACxE,OAAO,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;AAC9C,OAAO,sBAAsB,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,CAAC,EAAE,uBAAuB,GAAG,SAAS,GACxD,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IA0B5C,eAAe,uBAAwB,MAAM,MAAM,CAAC,UAQnD;IAED,eAAe,6BAA2B;CAC3C"}
@@ -0,0 +1,218 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
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_mdl_mdoc_1 = require("@sphereon/kmp-mdl-mdoc");
37
+ const ssi_sdk_ext_x509_utils_1 = require("@sphereon/ssi-sdk-ext.x509-utils");
38
+ const crypto = __importStar(require("crypto"));
39
+ const pkijs_1 = require("pkijs");
40
+ var CryptoServiceJS = kmp_mdl_mdoc_1.com.sphereon.crypto.CryptoServiceJS;
41
+ var Jwk = kmp_mdl_mdoc_1.com.sphereon.jose.jwk.Jwk;
42
+ var decodeFrom = kmp_mdl_mdoc_1.com.sphereon.kmp.decodeFrom;
43
+ var Encoding = kmp_mdl_mdoc_1.com.sphereon.kmp.Encoding;
44
+ class CoseCryptoService {
45
+ sign1(input, keyInfo) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ throw new Error('Method not implemented.');
48
+ });
49
+ }
50
+ verify1(input, keyInfo) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
53
+ function getCertAndKey(x5c) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ if (!x5c || x5c.length === 0) {
56
+ // We should not be able to get here anyway, as the MLD-mdoc library already validated at this point. But let's make sure
57
+ return Promise.reject(new Error(`No x5chain was present in the CoseSign headers!`));
58
+ }
59
+ // 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!
60
+ issuerCert = (0, ssi_sdk_ext_x509_utils_1.pemOrDerToX509Certificate)(x5c[0]);
61
+ issuerPublicKey = yield issuerCert.getPublicKey();
62
+ return { issuerCert, issuerPublicKey };
63
+ });
64
+ }
65
+ if ((_a = keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.key) === null || _a === void 0 ? void 0 : _a.d) {
66
+ throw Error('Do not use private keys to verify!');
67
+ }
68
+ else if (!((_b = input.payload) === null || _b === void 0 ? void 0 : _b.value)) {
69
+ return Promise.reject(Error('Signature validation without payload not supported'));
70
+ }
71
+ const sign1Json = input.toJson(); // Let's make it a bit easier on ourselves, instead of working with CBOR
72
+ const coseAlg = sign1Json.protectedHeader.alg;
73
+ if (!coseAlg) {
74
+ return Promise.reject(Error('No alg protected header present'));
75
+ }
76
+ let issuerPublicKey;
77
+ let issuerCert;
78
+ let kid = (_d = (_c = keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.kid) !== null && _c !== void 0 ? _c : sign1Json.protectedHeader.kid) !== null && _d !== void 0 ? _d : (_e = sign1Json.unprotectedHeader) === null || _e === void 0 ? void 0 : _e.kid;
79
+ // Please note this method does not perform chain validation. The MDL-MDOC library already performed this before this step
80
+ const x5c = (_m = (_k = (_j = (_h = (_g = (_f = keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.key) === null || _f === void 0 ? void 0 : _f.x5chain) === null || _g === void 0 ? void 0 : _g.value) === null || _h === void 0 ? void 0 : _h.asJsArrayView()) === null || _j === void 0 ? void 0 : _j.map((x509) => x509.encodeTo(Encoding.BASE64))) !== null && _k !== void 0 ? _k : (_l = sign1Json.protectedHeader) === null || _l === void 0 ? void 0 : _l.x5chain) !== null && _m !== void 0 ? _m : (_o = sign1Json.unprotectedHeader) === null || _o === void 0 ? void 0 : _o.x5chain;
81
+ if (!keyInfo || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.key) || ((_p = keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.key) === null || _p === void 0 ? void 0 : _p.x5chain)) {
82
+ const certAndKey = yield getCertAndKey(x5c);
83
+ issuerPublicKey = certAndKey.issuerPublicKey;
84
+ issuerCert = certAndKey.issuerCert;
85
+ }
86
+ else {
87
+ if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.key)) {
88
+ return Promise.reject(Error(`Either a x5c needs to be in the headers, or you need to provide a key for verification`));
89
+ }
90
+ const key = keyInfo.key;
91
+ // todo: Workaround as the Agent only works with cosekey json objects and we do not support conversion of these from Json to cbor yet
92
+ const jwk = typeof key.x === 'string'
93
+ ? Jwk.Companion.fromCoseKeyJson(keyInfo.key).toJsonObject()
94
+ : Jwk.Companion.fromCoseKey(keyInfo.key).toJsonObject();
95
+ if (kid === null) {
96
+ kid = jwk.kid;
97
+ }
98
+ let keyAlg = (_q = jwk.kty) !== null && _q !== void 0 ? _q : 'ECDSA';
99
+ const crv = (_r = jwk.crv) !== null && _r !== void 0 ? _r : 'P-256';
100
+ issuerPublicKey = yield crypto.subtle.importKey('jwk', Object.assign(Object.assign(Object.assign({ kty: jwk.kty, crv }, (jwk.x5c && { x5c: jwk.x5c })), (jwk.x && { x: jwk.x })), (jwk.y && { y: jwk.y })), {
101
+ name: keyAlg === 'EC' ? 'ECDSA' : keyAlg,
102
+ namedCurve: crv,
103
+ }, true, ['verify']);
104
+ }
105
+ const exportedJwk = yield crypto.subtle.exportKey('jwk', issuerPublicKey);
106
+ const crv = exportedJwk.crv;
107
+ const coseKey = Jwk.Companion.fromJsonObject(exportedJwk).jwkToCoseKeyJson();
108
+ const recalculatedToBeSigned = input.toBeSignedJson(coseKey, coseAlg);
109
+ const valid = yield crypto.subtle.verify(Object.assign(Object.assign({}, issuerPublicKey.algorithm), { hash: (crv === null || crv === void 0 ? void 0 : crv.includes('-')) ? `SHA-${crv.split('-')[1]}` : 'SHA-256' }), issuerPublicKey, decodeFrom(sign1Json.signature, Encoding.BASE64URL), decodeFrom(recalculatedToBeSigned.hexValue, Encoding.HEX));
110
+ return {
111
+ name: 'mdoc',
112
+ critical: true,
113
+ error: !valid,
114
+ message: `Signature of '${issuerCert ? (0, ssi_sdk_ext_x509_utils_1.getSubjectDN)(issuerCert).DN : kid}' was ${valid ? '' : 'in'}valid`,
115
+ keyInfo: keyInfo !== null && keyInfo !== void 0 ? keyInfo : ({ kid, key: coseKey.toCbor() }),
116
+ };
117
+ });
118
+ }
119
+ }
120
+ exports.CoseCryptoService = CoseCryptoService;
121
+ /**
122
+ * This class can be used for X509 validations.
123
+ * Either have an instance per trustedCerts and verification invocation or use a single instance and provide the trusted certs in the method argument
124
+ *
125
+ * The class is also registered with the low-level mDL/mdoc Kotlin Multiplatform library
126
+ * Next to the specific function for the library it exports a more powerful version of the same verification method as well
127
+ */
128
+ class X509CallbackService {
129
+ constructor(trustedCerts) {
130
+ this.setTrustedCerts = (trustedCertsInPEM) => {
131
+ this._trustedCerts = trustedCertsInPEM === null || trustedCertsInPEM === void 0 ? void 0 : trustedCertsInPEM.map((cert) => {
132
+ if (cert.includes('CERTIFICATE')) {
133
+ // PEM
134
+ return cert;
135
+ }
136
+ return (0, ssi_sdk_ext_x509_utils_1.derToPEM)(cert);
137
+ });
138
+ };
139
+ this.getTrustedCerts = () => this._trustedCerts;
140
+ this.setTrustedCerts(trustedCerts);
141
+ }
142
+ /**
143
+ * A more powerful version of the method below. Allows to verify at a specific time and returns more information
144
+ * @param chain
145
+ * @param trustAnchors
146
+ * @param verificationTime
147
+ */
148
+ verifyCertificateChain(_a) {
149
+ return __awaiter(this, arguments, void 0, function* ({ chain, trustAnchors = this.getTrustedCerts(), verificationTime, }) {
150
+ return yield (0, ssi_sdk_ext_x509_utils_1.validateX509CertificateChain)({
151
+ chain,
152
+ trustAnchors,
153
+ verificationTime,
154
+ opts: { trustRootWhenNoAnchors: true },
155
+ });
156
+ });
157
+ }
158
+ /**
159
+ * This method is the implementation used within the mDL/Mdoc library
160
+ */
161
+ verifyCertificateChainJS(chainDER, chainPEM, trustedCerts, verificationProfile) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ var _a;
164
+ let chain = [];
165
+ if (chainDER && chainDER.length > 0) {
166
+ chain = chainDER.map((der) => Uint8Array.from(der));
167
+ }
168
+ if (chainPEM && chainPEM.length > 0) {
169
+ chain = (chain !== null && chain !== void 0 ? chain : []).concat(chainPEM);
170
+ }
171
+ const result = yield (0, ssi_sdk_ext_x509_utils_1.validateX509CertificateChain)({
172
+ chain: chain, // The function will handle an empty array
173
+ trustAnchors: trustedCerts !== null && trustedCerts !== void 0 ? trustedCerts : this.getTrustedCerts(),
174
+ opts: { trustRootWhenNoAnchors: true },
175
+ });
176
+ const cert = result.certificateChain ? result.certificateChain[result.certificateChain.length - 1] : undefined;
177
+ return {
178
+ publicKey: cert === null || cert === void 0 ? void 0 : cert.publicKeyJWK, // fixme
179
+ publicKeyAlgorithm: (_a = cert === null || cert === void 0 ? void 0 : cert.publicKeyJWK) === null || _a === void 0 ? void 0 : _a.alg,
180
+ name: 'x.509',
181
+ critical: result.critical,
182
+ message: result.message,
183
+ error: result.error,
184
+ };
185
+ });
186
+ }
187
+ }
188
+ exports.X509CallbackService = X509CallbackService;
189
+ const defaultCryptoEngine = () => {
190
+ if (typeof self !== 'undefined') {
191
+ if ('crypto' in self) {
192
+ let engineName = 'webcrypto';
193
+ if ('webkitSubtle' in self.crypto) {
194
+ engineName = 'safari';
195
+ }
196
+ // @ts-ignore
197
+ (0, pkijs_1.setEngine)(engineName, new pkijs_1.CryptoEngine({ name: engineName, crypto: crypto }));
198
+ }
199
+ }
200
+ else if (typeof crypto !== 'undefined' && 'webcrypto' in crypto) {
201
+ const name = 'NodeJS ^15';
202
+ const nodeCrypto = crypto.webcrypto;
203
+ // @ts-ignore
204
+ (0, pkijs_1.setEngine)(name, new pkijs_1.CryptoEngine({ name, crypto: nodeCrypto }));
205
+ }
206
+ else {
207
+ // @ts-ignore
208
+ if (typeof crypto !== 'undefined' && typeof crypto.subtle !== 'undefined') {
209
+ const name = 'crypto';
210
+ (0, pkijs_1.setEngine)(name, new pkijs_1.CryptoEngine({ name, crypto: crypto }));
211
+ }
212
+ }
213
+ };
214
+ defaultCryptoEngine();
215
+ // We register the services with the mDL/mdoc library
216
+ CryptoServiceJS.X509.register(new X509CallbackService());
217
+ CryptoServiceJS.COSE.register(new CoseCryptoService());
218
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsD;AACtD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a;YACb,IAAA,iBAAS,EAAC,UAAU,EAAE,IAAI,oBAAY,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAClE,MAAM,IAAI,GAAG,YAAY,CAAA;QACzB,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAA;QACnC,aAAa;QACb,IAAA,iBAAS,EAAC,IAAI,EAAE,IAAI,oBAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;IACjE,CAAC;SAAM,CAAC;QACN,aAAa;QACb,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAC1E,MAAM,IAAI,GAAG,QAAQ,CAAA;YACrB,IAAA,iBAAS,EAAC,IAAI,EAAE,IAAI,oBAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,mBAAmB,EAAE,CAAA;AAErB,qDAAqD;AACrD,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAA;AACxD,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const logger: import("@sphereon/ssi-types").ISimpleLogger<unknown>;
2
+ declare const schema: any;
3
+ export { schema };
4
+ export { MDLMdoc, mdocSupportMethods } from './agent/mDLMdoc';
5
+ export * from './types/ImDLMdoc';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,sDAA2C,CAAA;AAC9D,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,cAAc,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
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.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:mdl-mdoc');
20
+ const schema = require('../plugin.schema.json');
21
+ exports.schema = schema;
22
+ var mDLMdoc_1 = require("./agent/mDLMdoc");
23
+ Object.defineProperty(exports, "MDLMdoc", { enumerable: true, get: function () { return mDLMdoc_1.MDLMdoc; } });
24
+ Object.defineProperty(exports, "mdocSupportMethods", { enumerable: true, get: function () { return mDLMdoc_1.mdocSupportMethods; } });
25
+ __exportStar(require("./types/ImDLMdoc"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAA6C;AAEhC,QAAA,MAAM,GAAG,mBAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,2CAA6D;AAApD,kGAAA,OAAO,OAAA;AAAE,6GAAA,kBAAkB,OAAA;AACpC,mDAAgC"}
@@ -0,0 +1,23 @@
1
+ import { com } from '@sphereon/kmp-mdl-mdoc';
2
+ import { X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils';
3
+ import { IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core';
4
+ import CoseSign1Json = com.sphereon.cbor.cose.CoseSign1Json;
5
+ import ICoseKeyJson = com.sphereon.cbor.cose.ICoseKeyJson;
6
+ import IKeyInfo = com.sphereon.crypto.IKeyInfo;
7
+ import IVerifySignatureResult = com.sphereon.crypto.IVerifySignatureResult;
8
+ export interface ImDLMdoc extends IPluginMethodMap {
9
+ verifyCertificateChain(args: VerifyCertificateChainArgs, context: IRequiredContext): Promise<X509ValidationResult>;
10
+ mdocVerifyIssuerSigned(args: MdocVerifyIssuerSignedArgs, context: IRequiredContext): Promise<IVerifySignatureResult<KeyType>>;
11
+ }
12
+ export type IRequiredContext = IAgentContext<IKeyManager & IDIDManager & IResolver>;
13
+ export type VerifyCertificateChainArgs = {
14
+ chain: Array<string | Uint8Array>;
15
+ trustAnchors?: string[];
16
+ verificationTime?: Date;
17
+ };
18
+ export type KeyType = ICoseKeyJson;
19
+ export type MdocVerifyIssuerSignedArgs = {
20
+ input: CoseSign1Json<any, any>;
21
+ keyInfo?: IKeyInfo<KeyType>;
22
+ };
23
+ //# sourceMappingURL=ImDLMdoc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImDLMdoc.d.ts","sourceRoot":"","sources":["../../src/types/ImDLMdoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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