@sphereon/did-auth-siop-adapter 0.14.1-next.10
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 +201 -0
- package/README.md +13 -0
- package/dist/DidJwtAdapter.d.ts +17 -0
- package/dist/DidJwtAdapter.d.ts.map +1 -0
- package/dist/DidJwtAdapter.js +57 -0
- package/dist/DidJwtAdapter.js.map +1 -0
- package/dist/did/DIDResolution.d.ts +18 -0
- package/dist/did/DIDResolution.d.ts.map +1 -0
- package/dist/did/DIDResolution.js +119 -0
- package/dist/did/DIDResolution.js.map +1 -0
- package/dist/did/DidJWT.d.ts +57 -0
- package/dist/did/DidJWT.d.ts.map +1 -0
- package/dist/did/DidJWT.js +247 -0
- package/dist/did/DidJWT.js.map +1 -0
- package/dist/did/LinkedDomainValidations.d.ts +3 -0
- package/dist/did/LinkedDomainValidations.d.ts.map +1 -0
- package/dist/did/LinkedDomainValidations.js +102 -0
- package/dist/did/LinkedDomainValidations.js.map +1 -0
- package/dist/did/index.d.ts +4 -0
- package/dist/did/index.d.ts.map +1 -0
- package/dist/did/index.js +20 -0
- package/dist/did/index.js.map +1 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +10 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/types/SIOP.types.d.ts +63 -0
- package/dist/types/SIOP.types.d.ts.map +1 -0
- package/dist/types/SIOP.types.js +15 -0
- package/dist/types/SIOP.types.js.map +1 -0
- package/dist/types/SSI.types.d.ts +15 -0
- package/dist/types/SSI.types.d.ts.map +1 -0
- package/dist/types/SSI.types.js +3 -0
- package/dist/types/SSI.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/lib/DidJwtAdapter.ts +67 -0
- package/lib/did/DIDResolution.ts +117 -0
- package/lib/did/DidJWT.ts +273 -0
- package/lib/did/LinkedDomainValidations.ts +98 -0
- package/lib/did/index.ts +3 -0
- package/lib/helpers.ts +10 -0
- package/lib/index.ts +5 -0
- package/lib/types/SIOP.types.ts +77 -0
- package/lib/types/SSI.types.ts +16 -0
- package/lib/types/index.ts +2 -0
- package/package.json +53 -0
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 B.V.]
|
|
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,13 @@
|
|
|
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><center>Self Issued OpenID Provider (SIOPv2)<br/>
|
|
6
|
+
with OpenID4VP support DID-JWT adapter</center>
|
|
7
|
+
<br>
|
|
8
|
+
</h1>
|
|
9
|
+
<br>
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
A simple utility library for creating and veryfing did-jwt's with.
|
|
13
|
+
[@spheren/did-auth-siop](https://img.shields.io/npm/v/@sphereon/did-auth-siop.svg)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JwtHeader, JwtIssuerWithContext, JwtPayload } from '@sphereon/did-auth-siop';
|
|
2
|
+
import { JwtVerifier } from '@sphereon/did-auth-siop/dist/types/JwtVerifier';
|
|
3
|
+
import { Resolvable } from 'did-resolver';
|
|
4
|
+
import { ExternalSignature, ExternalVerification, InternalSignature, InternalVerification, SuppliedSignature } from './types';
|
|
5
|
+
export declare const verfiyDidJwtAdapter: (jwtVerifier: JwtVerifier, jwt: {
|
|
6
|
+
header: JwtHeader;
|
|
7
|
+
payload: JwtPayload;
|
|
8
|
+
raw: string;
|
|
9
|
+
}, options: {
|
|
10
|
+
verification: InternalVerification | ExternalVerification;
|
|
11
|
+
resolver: Resolvable;
|
|
12
|
+
}) => Promise<boolean>;
|
|
13
|
+
export declare const createDidJwtAdapter: (signature: InternalSignature | ExternalSignature | SuppliedSignature, jwtIssuer: JwtIssuerWithContext, jwt: {
|
|
14
|
+
header: JwtHeader;
|
|
15
|
+
payload: JwtPayload;
|
|
16
|
+
}) => Promise<string>;
|
|
17
|
+
//# sourceMappingURL=DidJwtAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DidJwtAdapter.d.ts","sourceRoot":"","sources":["../lib/DidJwtAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EACT,oBAAoB,EACpB,UAAU,EAEX,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,gDAAgD,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,OAAO,EAAqB,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhJ,eAAO,MAAM,mBAAmB,gBACjB,WAAW,OACnB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,WACnD;IACP,YAAY,EAAE,oBAAoB,GAAG,oBAAoB,CAAA;IACzD,QAAQ,EAAE,UAAU,CAAA;CACrB,KACA,QAAQ,OAAO,CA4BjB,CAAA;AAED,eAAO,MAAM,mBAAmB,cACnB,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,aACzD,oBAAoB,OAC1B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,KAC9C,QAAQ,MAAM,CAWhB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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.createDidJwtAdapter = exports.verfiyDidJwtAdapter = void 0;
|
|
13
|
+
const did_1 = require("./did");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
const verfiyDidJwtAdapter = (jwtVerifier, jwt, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
17
|
+
if (jwtVerifier.method === 'did') {
|
|
18
|
+
const audience = (_d = (_c = (_b = (_a = options === null || options === void 0 ? void 0 : options.verification) === null || _a === void 0 ? void 0 : _a.resolveOpts) === null || _b === void 0 ? void 0 : _b.jwtVerifyOpts) === null || _c === void 0 ? void 0 : _c.audience) !== null && _d !== void 0 ? _d : (0, did_1.getAudience)(jwt.raw);
|
|
19
|
+
yield (0, did_1.verifyDidJWT)(jwt.raw, options.resolver, Object.assign(Object.assign({}, (_f = (_e = options.verification) === null || _e === void 0 ? void 0 : _e.resolveOpts) === null || _f === void 0 ? void 0 : _f.jwtVerifyOpts), { audience }));
|
|
20
|
+
if (jwtVerifier.type === 'request-object' && ((_g = jwt.payload.client_id) === null || _g === void 0 ? void 0 : _g.startsWith('did:'))) {
|
|
21
|
+
const authorizationRequestPayload = jwt.payload;
|
|
22
|
+
if (((_h = options.verification) === null || _h === void 0 ? void 0 : _h.checkLinkedDomain) && options.verification.checkLinkedDomain != types_1.CheckLinkedDomain.NEVER) {
|
|
23
|
+
yield (0, did_1.validateLinkedDomainWithDid)(authorizationRequestPayload.client_id, options.verification);
|
|
24
|
+
}
|
|
25
|
+
else if (!((_j = options.verification) === null || _j === void 0 ? void 0 : _j.checkLinkedDomain) && options.verification.wellknownDIDVerifyCallback) {
|
|
26
|
+
yield (0, did_1.validateLinkedDomainWithDid)(authorizationRequestPayload.client_id, options.verification);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (jwtVerifier.type === 'id-token') {
|
|
30
|
+
const issuerDid = (0, did_1.getSubDidFromPayload)(jwt.payload);
|
|
31
|
+
if (((_k = options.verification) === null || _k === void 0 ? void 0 : _k.checkLinkedDomain) && options.verification.checkLinkedDomain != types_1.CheckLinkedDomain.NEVER) {
|
|
32
|
+
yield (0, did_1.validateLinkedDomainWithDid)(issuerDid, options.verification);
|
|
33
|
+
}
|
|
34
|
+
else if (!((_l = options.verification) === null || _l === void 0 ? void 0 : _l.checkLinkedDomain) && options.verification.wellknownDIDVerifyCallback) {
|
|
35
|
+
yield (0, did_1.validateLinkedDomainWithDid)(issuerDid, options.verification);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
throw new Error('Invalid use of the did-auth-siop create jwt adapter');
|
|
41
|
+
});
|
|
42
|
+
exports.verfiyDidJwtAdapter = verfiyDidJwtAdapter;
|
|
43
|
+
const createDidJwtAdapter = (signature, jwtIssuer, jwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
if (jwtIssuer.method === 'did') {
|
|
45
|
+
const issuer = jwtIssuer.didUrl.split('#')[0];
|
|
46
|
+
jwt.payload.issuer = issuer;
|
|
47
|
+
if (jwtIssuer.type === 'request-object') {
|
|
48
|
+
return yield (0, did_1.signRequestObjectPayload)(jwt.payload, signature);
|
|
49
|
+
}
|
|
50
|
+
else if (jwtIssuer.type === 'id-token') {
|
|
51
|
+
return yield (0, did_1.signIDTokenPayload)(jwt.payload, signature);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
throw new Error('Invalid use of the did-auth-siop create jwt adapter');
|
|
55
|
+
});
|
|
56
|
+
exports.createDidJwtAdapter = createDidJwtAdapter;
|
|
57
|
+
//# sourceMappingURL=DidJwtAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DidJwtAdapter.js","sourceRoot":"","sources":["../lib/DidJwtAdapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,+BAAkJ;AAClJ,mCAAgJ;AAEzI,MAAM,mBAAmB,GAAG,CACjC,WAAwB,EACxB,GAA4D,EAC5D,OAGC,EACiB,EAAE;;IACpB,IAAI,WAAW,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAA,MAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,0CAAE,WAAW,0CAAE,aAAa,0CAAE,QAAQ,mCAAI,IAAA,iBAAW,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEpG,MAAM,IAAA,kBAAY,EAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,kCAAO,MAAA,MAAA,OAAO,CAAC,YAAY,0CAAE,WAAW,0CAAE,aAAa,KAAE,QAAQ,IAAG,CAAA;QAEhH,IAAI,WAAW,CAAC,IAAI,KAAK,gBAAgB,KAAI,MAAC,GAAG,CAAC,OAA+C,CAAC,SAAS,0CAAE,UAAU,CAAC,MAAM,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,QAAA,mBAAmB,uBAmC/B;AAEM,MAAM,mBAAmB,GAAG,CACjC,SAAoE,EACpE,SAA+B,EAC/B,GAA+C,EAC9B,EAAE;IACnB,IAAI,SAAS,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7C,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;QAC3B,IAAI,SAAS,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACxC,OAAO,MAAM,IAAA,8BAAwB,EAAC,GAAG,CAAC,OAA+B,EAAE,SAAS,CAAC,CAAA;QACvF,CAAC;aAAM,IAAI,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACzC,OAAO,MAAM,IAAA,wBAAkB,EAAC,GAAG,CAAC,OAAyB,EAAE,SAAS,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;AACxE,CAAC,CAAA,CAAA;AAfY,QAAA,mBAAmB,uBAe/B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Resolvable } from 'did-resolver';
|
|
2
|
+
import { DIDDocument, ResolveOpts } from '../types';
|
|
3
|
+
export declare function getResolver(opts: ResolveOpts): Resolvable;
|
|
4
|
+
/**
|
|
5
|
+
* This method returns a resolver object in OP/RP
|
|
6
|
+
* If the user of this library, configures OP/RP to have a customResolver, we will use that
|
|
7
|
+
* If the user of this library configures OP/RP to use a custom resolver for any specific did method, we will use that
|
|
8
|
+
* and in the end for the rest of the did methods, configured either with calling `addDidMethod` upon building OP/RP
|
|
9
|
+
* (without any resolver configuration) or declaring in the subject_syntax_types_supported of the registration object
|
|
10
|
+
* we will use universal resolver from Sphereon's DID Universal Resolver library
|
|
11
|
+
* @param customResolver
|
|
12
|
+
* @param subjectSyntaxTypesSupported
|
|
13
|
+
* @param resolverMap
|
|
14
|
+
*/
|
|
15
|
+
export declare function getResolverUnion(customResolver: Resolvable, subjectSyntaxTypesSupported: string[] | string, resolverMap: Map<string, Resolvable>): Resolvable;
|
|
16
|
+
export declare function mergeAllDidMethods(subjectSyntaxTypesSupported: string | string[], resolvers: Map<string, Resolvable>): string[];
|
|
17
|
+
export declare function resolveDidDocument(did: string, opts?: ResolveOpts): Promise<DIDDocument>;
|
|
18
|
+
//# sourceMappingURL=DIDResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DIDResolution.d.ts","sourceRoot":"","sources":["../../lib/did/DIDResolution.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,UAAU,EAAY,MAAM,cAAc,CAAA;AAEzG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAInD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CAoCzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,UAAU,EAC1B,2BAA2B,EAAE,MAAM,EAAE,GAAG,MAAM,EAC9C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GACnC,UAAU,CA8BZ;AAED,wBAAgB,kBAAkB,CAAC,2BAA2B,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,EAAE,CAQ/H;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAa9F"}
|
|
@@ -0,0 +1,119 @@
|
|
|
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.resolveDidDocument = exports.mergeAllDidMethods = exports.getResolverUnion = exports.getResolver = void 0;
|
|
13
|
+
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
14
|
+
const did_uni_client_1 = require("@sphereon/did-uni-client");
|
|
15
|
+
const did_resolver_1 = require("did-resolver");
|
|
16
|
+
const index_1 = require("./index");
|
|
17
|
+
function getResolver(opts) {
|
|
18
|
+
if (opts && typeof opts.resolver === 'object') {
|
|
19
|
+
return opts.resolver;
|
|
20
|
+
}
|
|
21
|
+
if (!opts || !opts.subjectSyntaxTypesSupported) {
|
|
22
|
+
if (opts === null || opts === void 0 ? void 0 : opts.noUniversalResolverFallback) {
|
|
23
|
+
throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`);
|
|
24
|
+
}
|
|
25
|
+
console.log(`Falling back to universal resolver as no resolve opts have been provided, or no subject syntax types supported are provided. It is wise to fix this`);
|
|
26
|
+
return new did_uni_client_1.UniResolver();
|
|
27
|
+
}
|
|
28
|
+
const uniResolvers = [];
|
|
29
|
+
if (opts.subjectSyntaxTypesSupported.indexOf(did_auth_siop_1.SubjectIdentifierType.DID) === -1) {
|
|
30
|
+
const specificDidMethods = opts.subjectSyntaxTypesSupported.filter((sst) => sst.includes('did:'));
|
|
31
|
+
if (!specificDidMethods.length) {
|
|
32
|
+
throw new Error('No did method found.');
|
|
33
|
+
}
|
|
34
|
+
for (const didMethod of specificDidMethods) {
|
|
35
|
+
const uniResolver = (0, did_uni_client_1.getUniResolver)((0, index_1.getMethodFromDid)(didMethod), { resolveUrl: opts.resolveUrl });
|
|
36
|
+
uniResolvers.push(uniResolver);
|
|
37
|
+
}
|
|
38
|
+
return new did_resolver_1.Resolver(...uniResolvers);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (opts === null || opts === void 0 ? void 0 : opts.noUniversalResolverFallback) {
|
|
42
|
+
throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`);
|
|
43
|
+
}
|
|
44
|
+
console.log(`Falling back to universal resolver as no resolve opts have been provided, or no subject syntax types supported are provided. It is wise to fix this`);
|
|
45
|
+
return new did_uni_client_1.UniResolver();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.getResolver = getResolver;
|
|
49
|
+
/**
|
|
50
|
+
* This method returns a resolver object in OP/RP
|
|
51
|
+
* If the user of this library, configures OP/RP to have a customResolver, we will use that
|
|
52
|
+
* If the user of this library configures OP/RP to use a custom resolver for any specific did method, we will use that
|
|
53
|
+
* and in the end for the rest of the did methods, configured either with calling `addDidMethod` upon building OP/RP
|
|
54
|
+
* (without any resolver configuration) or declaring in the subject_syntax_types_supported of the registration object
|
|
55
|
+
* we will use universal resolver from Sphereon's DID Universal Resolver library
|
|
56
|
+
* @param customResolver
|
|
57
|
+
* @param subjectSyntaxTypesSupported
|
|
58
|
+
* @param resolverMap
|
|
59
|
+
*/
|
|
60
|
+
function getResolverUnion(customResolver, subjectSyntaxTypesSupported, resolverMap) {
|
|
61
|
+
if (customResolver) {
|
|
62
|
+
return customResolver;
|
|
63
|
+
}
|
|
64
|
+
const fallbackResolver = customResolver ? customResolver : new did_uni_client_1.UniResolver();
|
|
65
|
+
const uniResolvers = [];
|
|
66
|
+
const subjectTypes = [];
|
|
67
|
+
if (subjectSyntaxTypesSupported) {
|
|
68
|
+
typeof subjectSyntaxTypesSupported === 'string'
|
|
69
|
+
? subjectTypes.push(subjectSyntaxTypesSupported)
|
|
70
|
+
: subjectTypes.push(...subjectSyntaxTypesSupported);
|
|
71
|
+
}
|
|
72
|
+
if (subjectTypes.indexOf(did_auth_siop_1.SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1) {
|
|
73
|
+
return customResolver ? customResolver : new did_uni_client_1.UniResolver();
|
|
74
|
+
}
|
|
75
|
+
const specificDidMethods = subjectTypes.filter((sst) => !!sst && sst.startsWith('did:'));
|
|
76
|
+
specificDidMethods.forEach((dm) => {
|
|
77
|
+
let methodResolver;
|
|
78
|
+
if (!resolverMap.has(dm) || resolverMap.get(dm) === null) {
|
|
79
|
+
methodResolver = (0, did_uni_client_1.getUniResolver)((0, index_1.getMethodFromDid)(dm));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
methodResolver = resolverMap.get(dm);
|
|
83
|
+
}
|
|
84
|
+
uniResolvers.push(methodResolver);
|
|
85
|
+
});
|
|
86
|
+
return subjectTypes.indexOf(did_auth_siop_1.SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1
|
|
87
|
+
? new did_resolver_1.Resolver(...Object.assign({ fallbackResolver }, uniResolvers))
|
|
88
|
+
: new did_resolver_1.Resolver(...uniResolvers);
|
|
89
|
+
}
|
|
90
|
+
exports.getResolverUnion = getResolverUnion;
|
|
91
|
+
function mergeAllDidMethods(subjectSyntaxTypesSupported, resolvers) {
|
|
92
|
+
if (!Array.isArray(subjectSyntaxTypesSupported)) {
|
|
93
|
+
subjectSyntaxTypesSupported = [subjectSyntaxTypesSupported];
|
|
94
|
+
}
|
|
95
|
+
const unionSubjectSyntaxTypes = new Set();
|
|
96
|
+
subjectSyntaxTypesSupported.forEach((sst) => unionSubjectSyntaxTypes.add(sst));
|
|
97
|
+
resolvers.forEach((_, didMethod) => unionSubjectSyntaxTypes.add((0, index_1.toSIOPRegistrationDidMethod)(didMethod)));
|
|
98
|
+
return Array.from(unionSubjectSyntaxTypes);
|
|
99
|
+
}
|
|
100
|
+
exports.mergeAllDidMethods = mergeAllDidMethods;
|
|
101
|
+
function resolveDidDocument(did, opts) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
var _a;
|
|
104
|
+
// todo: The accept is only there because did:key used by Veramo requires it. According to the spec it is optional. It should not hurt, but let's test
|
|
105
|
+
const result = yield getResolver(Object.assign({}, opts)).resolve(did, { accept: 'application/did+ld+json' });
|
|
106
|
+
if ((_a = result === null || result === void 0 ? void 0 : result.didResolutionMetadata) === null || _a === void 0 ? void 0 : _a.error) {
|
|
107
|
+
throw Error(result.didResolutionMetadata.error);
|
|
108
|
+
}
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
if (!result.didDocument && result.id) {
|
|
112
|
+
// todo: This looks like a bug. It seems that sometimes we get back a DID document directly instead of a did resolution results
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
return result.didDocument;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.resolveDidDocument = resolveDidDocument;
|
|
119
|
+
//# sourceMappingURL=DIDResolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DIDResolution.js","sourceRoot":"","sources":["../../lib/did/DIDResolution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAkG;AAClG,6DAAsE;AACtE,+CAAyG;AAIzG,mCAAuE;AAEvE,SAAgB,WAAW,CAAC,IAAiB;IAC3C,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IACD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC/C,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,2BAA2B,EAAE,CAAC;YACtC,MAAM,KAAK,CAAC,6HAA6H,CAAC,CAAA;QAC5I,C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M,CAAC,EAAE,EAAE,CAAC;YACrC,+HAA+H;YAC/H,OAAO,MAAgC,CAAA;QACzC,CAAC;QACD,OAAO,MAAM,CAAC,WAAW,CAAA;IAC3B,CAAC;CAAA;AAbD,gDAaC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { IDTokenPayload, RequestObjectPayload, SigningAlgo, VerifiedJWT } from '@sphereon/did-auth-siop';
|
|
2
|
+
import { JWTHeader, JWTOptions, JWTPayload, JWTVerifyOptions, Signer } from 'did-jwt';
|
|
3
|
+
import { Resolvable } from 'did-resolver';
|
|
4
|
+
import { ExternalSignature, InternalSignature, SuppliedSignature } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Verifies given JWT. If the JWT is valid, the promise returns an object including the JWT, the payload of the JWT,
|
|
7
|
+
* and the did doc of the issuer of the JWT.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* verifyDidJWT('did:key:example', resolver, {audience: '5A8bRWU3F7j3REx3vkJ...', callbackUrl: 'https://...'}).then(obj => {
|
|
11
|
+
* const did = obj.did // DIDres of signer
|
|
12
|
+
* const payload = obj.payload
|
|
13
|
+
* const doc = obj.doc // DIDres Document of signer
|
|
14
|
+
* const JWT = obj.JWT // JWT
|
|
15
|
+
* const signerKeyId = obj.signerKeyId // ID of key in DIDres document that signed JWT
|
|
16
|
+
* ...
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* @param {String} jwt a JSON Web Token to verify
|
|
20
|
+
* @param {Resolvable} resolver
|
|
21
|
+
* @param {JWTVerifyOptions} [options] Options
|
|
22
|
+
* @param {String} options.audience DID of the recipient of the JWT
|
|
23
|
+
* @param {String} options.callbackUrl callback url in JWT
|
|
24
|
+
* @return {Promise<Object, Error>} a promise which resolves with a response object or rejects with an error
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifyDidJWT(jwt: string, resolver: Resolvable, options: JWTVerifyOptions): Promise<VerifiedJWT>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a signed JWT given an address which becomes the issuer, a signer function, and a payload for which the withSignature is over.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const signer = ES256KSigner(process.env.PRIVATE_KEY)
|
|
32
|
+
* createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(JWT => {
|
|
33
|
+
* ...
|
|
34
|
+
* })
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} payload payload object
|
|
37
|
+
* @param {Object} [options] an unsigned credential object
|
|
38
|
+
* @param {String} options.issuer The DID of the issuer (signer) of JWT
|
|
39
|
+
* @param {Signer} options.signer a `Signer` function, Please see `ES256KSigner` or `EdDSASigner`
|
|
40
|
+
* @param {boolean} options.canonicalize optional flag to canonicalize header and payload before signing
|
|
41
|
+
* @param {Object} header optional object to specify or customize the JWT header
|
|
42
|
+
* @return {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an error
|
|
43
|
+
*/
|
|
44
|
+
export declare function createDidJWT(payload: Partial<JWTPayload>, { issuer, signer, expiresIn, canonicalize }: JWTOptions, header: Partial<JWTHeader>): Promise<string>;
|
|
45
|
+
export declare function signIDTokenPayload(payload: IDTokenPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature): Promise<string>;
|
|
46
|
+
export declare function signRequestObjectPayload(payload: RequestObjectPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature): Promise<string>;
|
|
47
|
+
export declare function signDidJwtInternal(payload: IDTokenPayload | RequestObjectPayload, issuer: string, hexPrivateKey: string, alg: SigningAlgo, kid: string, customJwtSigner?: Signer): Promise<string>;
|
|
48
|
+
export declare function getAudience(jwt: string): string;
|
|
49
|
+
export declare function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): string;
|
|
50
|
+
export declare function isIssSelfIssued(payload: JWTPayload): boolean;
|
|
51
|
+
export declare function getMethodFromDid(did: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Since the OIDC SIOP spec incorrectly uses 'did:<method>:' and calls that a method, we have to fix it
|
|
54
|
+
* @param didOrMethod
|
|
55
|
+
*/
|
|
56
|
+
export declare function toSIOPRegistrationDidMethod(didOrMethod: string): string;
|
|
57
|
+
//# sourceMappingURL=DidJWT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DidJWT.d.ts","sourceRoot":"","sources":["../../lib/did/DidJWT.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EACd,oBAAoB,EAGpB,WAAW,EAGX,WAAW,EACZ,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAOL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,MAAM,EAEP,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAGzC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAElF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAErH;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,EAC5B,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,UAAU,EACvD,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,mBAYrI;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,mBAyBjJ;AAED,wBAAsB,kBAAkB,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