@sphereon/did-auth-siop-adapter 0.18.2 → 0.19.1-next.2
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 -201
- package/README.md +12 -12
- package/dist/index.cjs +0 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/LICENSE
CHANGED
|
@@ -1,201 +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.
|
|
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
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
|
-
A simple utility library for creating and veryfing did-jwt's with.
|
|
12
|
-
[@spheren/did-auth-siop](https://img.shields.io/npm/v/@sphereon/did-auth-siop.svg)
|
|
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
|
+
A simple utility library for creating and veryfing did-jwt's with.
|
|
12
|
+
[@spheren/did-auth-siop](https://img.shields.io/npm/v/@sphereon/did-auth-siop.svg)
|
package/dist/index.cjs
CHANGED
|
@@ -518,29 +518,4 @@ var createDidJwtAdapter = /* @__PURE__ */ __name(async (signature, jwtIssuer, jw
|
|
|
518
518
|
}
|
|
519
519
|
throw new Error("Invalid use of the did-auth-siop create jwt adapter");
|
|
520
520
|
}, "createDidJwtAdapter");
|
|
521
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
522
|
-
0 && (module.exports = {
|
|
523
|
-
CheckLinkedDomain,
|
|
524
|
-
VerificationMode,
|
|
525
|
-
createDidJWT,
|
|
526
|
-
createDidJwtAdapter,
|
|
527
|
-
getAudience,
|
|
528
|
-
getMethodFromDid,
|
|
529
|
-
getResolver,
|
|
530
|
-
getResolverUnion,
|
|
531
|
-
getSubDidFromPayload,
|
|
532
|
-
isExternalSignature,
|
|
533
|
-
isInternalSignature,
|
|
534
|
-
isIssSelfIssued,
|
|
535
|
-
isSuppliedSignature,
|
|
536
|
-
mergeAllDidMethods,
|
|
537
|
-
resolveDidDocument,
|
|
538
|
-
signDidJwtInternal,
|
|
539
|
-
signIDTokenPayload,
|
|
540
|
-
signRequestObjectPayload,
|
|
541
|
-
toSIOPRegistrationDidMethod,
|
|
542
|
-
validateLinkedDomainWithDid,
|
|
543
|
-
verfiyDidJwtAdapter,
|
|
544
|
-
verifyDidJWT
|
|
545
|
-
});
|
|
546
521
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.ts","../lib/did/DidJWT.ts","../lib/helpers.ts","../lib/did/DIDResolution.ts","../lib/did/LinkedDomainValidations.ts","../lib/types/SIOP.types.ts","../lib/DidJwtAdapter.ts"],"sourcesContent":["export * from './did'\r\n\r\nexport * from './types'\r\nexport * from './DidJwtAdapter'\r\nexport * from './helpers'\r\n","import {\r\n DEFAULT_EXPIRATION_TIME,\r\n IDTokenPayload,\r\n post,\r\n RequestObjectPayload,\r\n ResponseIss,\r\n SignatureResponse,\r\n SIOPErrors,\r\n SIOPResonse,\r\n VerifiedJWT,\r\n} from '@sphereon/did-auth-siop'\r\nimport { SigningAlgo } from '@sphereon/oid4vc-common'\r\nimport {\r\n createJWT,\r\n decodeJWT,\r\n EdDSASigner,\r\n ES256KSigner,\r\n ES256Signer,\r\n hexToBytes,\r\n JWTHeader,\r\n JWTOptions,\r\n JWTPayload,\r\n JWTVerifyOptions,\r\n Signer,\r\n verifyJWT,\r\n} from 'did-jwt'\r\nimport { Resolvable } from 'did-resolver'\r\n\r\nimport { isExternalSignature, isInternalSignature, isSuppliedSignature } from '../helpers'\r\nimport { ExternalSignature, InternalSignature, SuppliedSignature } from '../types'\r\n\r\n/**\r\n * Verifies given JWT. If the JWT is valid, the promise returns an object including the JWT, the payload of the JWT,\r\n * and the did doc of the issuer of the JWT.\r\n *\r\n * @example\r\n * verifyDidJWT('did:key:example', resolver, {audience: '5A8bRWU3F7j3REx3vkJ...', callbackUrl: 'https://...'}).then(obj => {\r\n * const did = obj.did // DIDres of signer\r\n * const payload = obj.payload\r\n * const doc = obj.doc // DIDres Document of signer\r\n * const JWT = obj.JWT // JWT\r\n * const signerKeyId = obj.signerKeyId // ID of key in DIDres document that signed JWT\r\n * ...\r\n * })\r\n *\r\n * @param {String} jwt a JSON Web Token to verify\r\n * @param {Resolvable} resolver\r\n * @param {JWTVerifyOptions} [options] Options\r\n * @param {String} options.audience DID of the recipient of the JWT\r\n * @param {String} options.callbackUrl callback url in JWT\r\n * @return {Promise<Object, Error>} a promise which resolves with a response object or rejects with an error\r\n */\r\nexport async function verifyDidJWT(jwt: string, resolver: Resolvable, options: JWTVerifyOptions): Promise<VerifiedJWT> {\r\n return verifyJWT(jwt, { ...options, resolver })\r\n}\r\n\r\n/**\r\n * Creates a signed JWT given an address which becomes the issuer, a signer function, and a payload for which the withSignature is over.\r\n *\r\n * @example\r\n * const signer = ES256KSigner(process.env.PRIVATE_KEY)\r\n * createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(JWT => {\r\n * ...\r\n * })\r\n *\r\n * @param {Object} payload payload object\r\n * @param {Object} [options] an unsigned credential object\r\n * @param {String} options.issuer The DID of the issuer (signer) of JWT\r\n * @param {Signer} options.signer a `Signer` function, Please see `ES256KSigner` or `EdDSASigner`\r\n * @param {boolean} options.canonicalize optional flag to canonicalize header and payload before signing\r\n * @param {Object} header optional object to specify or customize the JWT header\r\n * @return {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an error\r\n */\r\nexport async function createDidJWT(\r\n payload: Partial<JWTPayload>,\r\n { issuer, signer, expiresIn, canonicalize }: JWTOptions,\r\n header: Partial<JWTHeader>,\r\n): Promise<string> {\r\n return createJWT(payload, { issuer, signer, expiresIn, canonicalize }, header)\r\n}\r\n\r\nexport async function signIDTokenPayload(payload: IDTokenPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\r\n if (isInternalSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtInternal(payload, payload.issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\r\n } else if (isExternalSignature(signature)) {\r\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\r\n } else if (isSuppliedSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtSupplied(payload, payload.issuer, signature.signature, signature.alg, signature.kid)\r\n } else {\r\n throw new Error(\r\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\r\n )\r\n }\r\n}\r\n\r\nexport async function signRequestObjectPayload(payload: RequestObjectPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\r\n let issuer = payload.iss\r\n if (!issuer) {\r\n issuer = signature.did\r\n }\r\n if (!issuer) {\r\n throw Error('No issuer supplied to sign the JWT')\r\n }\r\n if (!payload.iss) {\r\n payload.iss = issuer\r\n }\r\n if (!payload.sub) {\r\n payload.sub = signature.did\r\n }\r\n if (isInternalSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtInternal(payload, issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\r\n } else if (isExternalSignature(signature)) {\r\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\r\n } else if (isSuppliedSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtSupplied(payload, issuer, signature.signature, signature.alg, signature.kid)\r\n } else {\r\n throw new Error(\r\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\r\n )\r\n }\r\n}\r\n\r\nexport async function signDidJwtInternal(\r\n payload: IDTokenPayload | RequestObjectPayload,\r\n issuer: string,\r\n hexPrivateKey: string,\r\n alg: SigningAlgo,\r\n kid: string,\r\n customJwtSigner?: Signer,\r\n): Promise<string> {\r\n const signer = determineSigner(alg, hexPrivateKey, customJwtSigner)\r\n const header = {\r\n alg,\r\n kid,\r\n }\r\n const options = {\r\n issuer,\r\n signer,\r\n expiresIn: DEFAULT_EXPIRATION_TIME,\r\n }\r\n\r\n return await createDidJWT({ ...payload }, options, header)\r\n}\r\n\r\nasync function signDidJwtExternal(\r\n payload: IDTokenPayload | RequestObjectPayload,\r\n signatureUri: string,\r\n authZToken: string,\r\n alg: SigningAlgo,\r\n kid?: string,\r\n): Promise<string> {\r\n const body = {\r\n issuer: payload.iss && payload.iss.includes('did:') ? payload.iss : payload.sub,\r\n payload,\r\n expiresIn: DEFAULT_EXPIRATION_TIME,\r\n alg,\r\n selfIssued: payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2) ? payload.iss : undefined,\r\n kid,\r\n }\r\n\r\n const response: SIOPResonse<SignatureResponse> = await post(signatureUri, JSON.stringify(body), { bearerToken: authZToken })\r\n if (!response.successBody) {\r\n return Promise.reject(Error('the siop SignatureResponse does not have a successBody'))\r\n }\r\n return response.successBody.jws\r\n}\r\n\r\nasync function signDidJwtSupplied(\r\n payload: IDTokenPayload | RequestObjectPayload,\r\n issuer: string,\r\n signer: Signer,\r\n alg: SigningAlgo,\r\n kid: string,\r\n): Promise<string> {\r\n const header = {\r\n alg,\r\n kid,\r\n }\r\n const options = {\r\n issuer,\r\n signer,\r\n expiresIn: DEFAULT_EXPIRATION_TIME,\r\n }\r\n\r\n return await createDidJWT({ ...payload }, options, header)\r\n}\r\n\r\nconst determineSigner = (alg: SigningAlgo, hexPrivateKey?: string, customSigner?: Signer): Signer => {\r\n if (customSigner) {\r\n return customSigner\r\n } else if (!hexPrivateKey) {\r\n throw new Error('no private key provided')\r\n }\r\n const privateKey = hexToBytes(hexPrivateKey.replace('0x', ''))\r\n switch (alg) {\r\n case SigningAlgo.EDDSA:\r\n return EdDSASigner(privateKey)\r\n case SigningAlgo.ES256:\r\n return ES256Signer(privateKey)\r\n case SigningAlgo.ES256K:\r\n return ES256KSigner(privateKey)\r\n case SigningAlgo.PS256:\r\n throw Error('PS256 is not supported yet. Please provide a custom signer')\r\n case SigningAlgo.RS256:\r\n throw Error('RS256 is not supported yet. Please provide a custom signer')\r\n }\r\n}\r\n\r\nexport function getAudience(jwt: string) {\r\n const { payload } = decodeJWT(jwt)\r\n if (!payload) {\r\n throw new Error(SIOPErrors.NO_AUDIENCE)\r\n } else if (!payload.aud) {\r\n return undefined\r\n } else if (Array.isArray(payload.aud)) {\r\n throw new Error(SIOPErrors.INVALID_AUDIENCE)\r\n }\r\n\r\n return payload.aud\r\n}\r\n\r\n//TODO To enable automatic registration, it cannot be a did, but HTTPS URL\r\nfunction assertIssSelfIssuedOrDid(payload: JWTPayload) {\r\n if (!payload.sub || !payload.sub.startsWith('did:') || !payload.iss || !isIssSelfIssued(payload)) {\r\n throw new Error('Token does not have a iss DID')\r\n }\r\n}\r\n\r\nexport function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): string {\r\n assertIssSelfIssuedOrDid(payload)\r\n\r\n if (isIssSelfIssued(payload)) {\r\n let did\r\n if (payload.sub && payload.sub.startsWith('did:')) {\r\n did = payload.sub\r\n }\r\n if (!did && header && header.kid && header.kid.startsWith('did:')) {\r\n did = header.kid.split('#')[0]\r\n }\r\n if (did) {\r\n return did\r\n }\r\n }\r\n return payload.sub!\r\n}\r\n\r\nexport function isIssSelfIssued(payload: JWTPayload): boolean {\r\n return (\r\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V1)) ||\r\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2)) ||\r\n payload.iss === payload.sub\r\n )\r\n}\r\n\r\nexport function getMethodFromDid(did: string): string {\r\n if (!did) {\r\n throw new Error(SIOPErrors.BAD_PARAMS)\r\n }\r\n const split = did.split(':')\r\n if (split.length == 1 && did.length > 0) {\r\n return did\r\n } else if (!did.startsWith('did:') || split.length < 2) {\r\n throw new Error(SIOPErrors.BAD_PARAMS)\r\n }\r\n\r\n return split[1]\r\n}\r\n\r\n/**\r\n * Since the OIDC SIOP spec incorrectly uses 'did:<method>:' and calls that a method, we have to fix it\r\n * @param didOrMethod\r\n */\r\nexport function toSIOPRegistrationDidMethod(didOrMethod: string) {\r\n let prefix = didOrMethod\r\n if (!didOrMethod.startsWith('did:')) {\r\n prefix = 'did:' + didOrMethod\r\n }\r\n const split = prefix.split(':')\r\n return `${split[0]}:${split[1]}`\r\n}\r\n","import { ExternalSignature, InternalSignature, NoSignature, SuppliedSignature } from './types/SIOP.types'\r\n\r\nexport const isInternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is InternalSignature =>\r\n 'hexPrivateKey' in object && 'did' in object\r\n\r\nexport const isExternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is ExternalSignature =>\r\n 'signatureUri' in object && 'did' in object\r\n\r\nexport const isSuppliedSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is SuppliedSignature =>\r\n 'signature' in object\r\n","import { SubjectIdentifierType, SubjectSyntaxTypesSupportedValues } from '@sphereon/did-auth-siop'\r\nimport { getUniResolver, UniResolver } from '@sphereon/did-uni-client'\r\nimport { DIDResolutionOptions, DIDResolutionResult, ParsedDID, Resolvable, Resolver, ResolverRegistry } from 'did-resolver'\r\n\r\nimport { DIDDocument, ResolveOpts } from '../types'\r\n\r\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from './index'\r\n\r\nexport function getResolver(opts: ResolveOpts): Resolvable {\r\n if (opts && typeof opts.resolver === 'object') {\r\n return opts.resolver\r\n }\r\n if (!opts || !opts.subjectSyntaxTypesSupported) {\r\n if (opts?.noUniversalResolverFallback) {\r\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\r\n }\r\n console.log(\r\n `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`,\r\n )\r\n return new UniResolver()\r\n }\r\n\r\n const uniResolvers: {\r\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\r\n }[] = []\r\n if (opts.subjectSyntaxTypesSupported.indexOf(SubjectIdentifierType.DID) === -1) {\r\n const specificDidMethods = opts.subjectSyntaxTypesSupported.filter((sst) => sst.includes('did:'))\r\n if (!specificDidMethods.length) {\r\n throw new Error('No did method found.')\r\n }\r\n for (const didMethod of specificDidMethods) {\r\n const uniResolver = getUniResolver(getMethodFromDid(didMethod), { resolveUrl: opts.resolveUrl })\r\n uniResolvers.push(uniResolver)\r\n }\r\n return new Resolver(...uniResolvers)\r\n } else {\r\n if (opts?.noUniversalResolverFallback) {\r\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\r\n }\r\n console.log(\r\n `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`,\r\n )\r\n return new UniResolver()\r\n }\r\n}\r\n\r\n/**\r\n * This method returns a resolver object in OP/RP\r\n * If the user of this library, configures OP/RP to have a customResolver, we will use that\r\n * If the user of this library configures OP/RP to use a custom resolver for any specific did method, we will use that\r\n * and in the end for the rest of the did methods, configured either with calling `addDidMethod` upon building OP/RP\r\n * (without any resolver configuration) or declaring in the subject_syntax_types_supported of the registration object\r\n * we will use universal resolver from Sphereon's DID Universal Resolver library\r\n * @param customResolver\r\n * @param subjectSyntaxTypesSupported\r\n * @param resolverMap\r\n */\r\nexport function getResolverUnion(\r\n customResolver: Resolvable,\r\n subjectSyntaxTypesSupported: string[] | string,\r\n resolverMap: Map<string, Resolvable>,\r\n): Resolvable {\r\n if (customResolver) {\r\n return customResolver\r\n }\r\n const fallbackResolver: Resolvable = customResolver ? customResolver : new UniResolver()\r\n const uniResolvers: {\r\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\r\n }[] = []\r\n const subjectTypes: string[] = []\r\n if (subjectSyntaxTypesSupported) {\r\n typeof subjectSyntaxTypesSupported === 'string'\r\n ? subjectTypes.push(subjectSyntaxTypesSupported)\r\n : subjectTypes.push(...subjectSyntaxTypesSupported)\r\n }\r\n if (subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1) {\r\n return customResolver ? customResolver : new UniResolver()\r\n }\r\n const specificDidMethods = subjectTypes.filter((sst) => !!sst && sst.startsWith('did:'))\r\n specificDidMethods.forEach((dm) => {\r\n let methodResolver: ResolverRegistry | Resolvable | undefined\r\n if (!resolverMap.has(dm) || resolverMap.get(dm) === null) {\r\n methodResolver = getUniResolver(getMethodFromDid(dm))\r\n if (methodResolver) {\r\n uniResolvers.push(methodResolver)\r\n }\r\n } else {\r\n methodResolver = resolverMap.get(dm)\r\n if (methodResolver) {\r\n uniResolvers.push({ [dm]: methodResolver.resolve })\r\n }\r\n }\r\n })\r\n return subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1\r\n ? new Resolver(...{ fallbackResolver, ...uniResolvers })\r\n : new Resolver(...uniResolvers)\r\n}\r\n\r\nexport function mergeAllDidMethods(subjectSyntaxTypesSupported: string | string[], resolvers: Map<string, Resolvable>): string[] {\r\n if (!Array.isArray(subjectSyntaxTypesSupported)) {\r\n subjectSyntaxTypesSupported = [subjectSyntaxTypesSupported]\r\n }\r\n const unionSubjectSyntaxTypes = new Set()\r\n subjectSyntaxTypesSupported.forEach((sst) => unionSubjectSyntaxTypes.add(sst))\r\n resolvers.forEach((_, didMethod) => unionSubjectSyntaxTypes.add(toSIOPRegistrationDidMethod(didMethod)))\r\n return Array.from(unionSubjectSyntaxTypes) as string[]\r\n}\r\n\r\nexport async function resolveDidDocument(did: string, opts?: ResolveOpts): Promise<DIDDocument> {\r\n // 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\r\n const result = await getResolver({ ...opts }).resolve(did, { accept: 'application/did+ld+json' })\r\n if (result?.didResolutionMetadata?.error) {\r\n throw Error(result.didResolutionMetadata.error)\r\n }\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n if (!result.didDocument && result.id) {\r\n // todo: This looks like a bug. It seems that sometimes we get back a DID document directly instead of a did resolution results\r\n return result as unknown as DIDDocument\r\n }\r\n return result.didDocument as DIDDocument\r\n}\r\n","import { IDomainLinkageValidation, ValidationStatusEnum, VerifyCallback, WDCErrors, WellKnownDidVerifier } from '@sphereon/wellknown-dids-client'\r\n\r\nimport { DIDDocument } from '../types/SSI.types'\r\n\r\nimport { CheckLinkedDomain, ExternalVerification, InternalVerification } from './../types/'\r\nimport { resolveDidDocument } from './DIDResolution'\r\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from './DidJWT'\r\n\r\nfunction getValidationErrorMessages(validationResult: IDomainLinkageValidation): string[] {\r\n const messages = []\r\n if (validationResult.message) {\r\n messages.push(validationResult.message)\r\n }\r\n if (validationResult?.endpointDescriptors?.length) {\r\n for (const endpointDescriptor of validationResult.endpointDescriptors) {\r\n if (endpointDescriptor.message) {\r\n messages.push(endpointDescriptor.message)\r\n }\r\n if (endpointDescriptor.resources) {\r\n for (const resource of endpointDescriptor.resources) {\r\n if (resource.message) {\r\n messages.push(resource.message)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return messages\r\n}\r\n\r\n/**\r\n * @param validationErrorMessages\r\n * @return returns false if the messages received from wellknown-dids-client makes this invalid for CheckLinkedDomain.IF_PRESENT plus the message itself\r\n * and true for when we can move on\r\n */\r\nfunction checkInvalidMessages(validationErrorMessages: string[]): { status: boolean; message?: string } {\r\n if (!validationErrorMessages || !validationErrorMessages.length) {\r\n return { status: false, message: 'linked domain is invalid.' }\r\n }\r\n const validMessages: string[] = [\r\n WDCErrors.PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS.valueOf(),\r\n WDCErrors.PROPERTY_LINKED_DIDS_NOT_PRESENT.valueOf(),\r\n WDCErrors.PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN.valueOf(),\r\n WDCErrors.PROPERTY_SERVICE_NOT_PRESENT.valueOf(),\r\n ]\r\n for (const validationErrorMessage of validationErrorMessages) {\r\n if (!validMessages.filter((vm) => validationErrorMessage.includes(vm)).pop()) {\r\n return { status: false, message: validationErrorMessage }\r\n }\r\n }\r\n return { status: true }\r\n}\r\n\r\nexport async function validateLinkedDomainWithDid(did: string, verification: InternalVerification | ExternalVerification): Promise<void> {\r\n const { checkLinkedDomain, resolveOpts, wellknownDIDVerifyCallback } = verification\r\n if (checkLinkedDomain === CheckLinkedDomain.NEVER) {\r\n return\r\n }\r\n const didDocument = await resolveDidDocument(did, {\r\n ...resolveOpts,\r\n subjectSyntaxTypesSupported: [toSIOPRegistrationDidMethod(getMethodFromDid(did))],\r\n })\r\n if (!didDocument) {\r\n throw Error(`Could not resolve DID: ${did}`)\r\n }\r\n if ((!didDocument.service || !didDocument.service.find((s) => s.type === 'LinkedDomains')) && checkLinkedDomain === CheckLinkedDomain.IF_PRESENT) {\r\n // No linked domains in DID document and it was optional. Let's cut it short here.\r\n return\r\n }\r\n try {\r\n if (!wellknownDIDVerifyCallback) {\r\n return Promise.reject(Error('wellknownDIDVerifyCallback is required for checkWellKnownDid'))\r\n }\r\n const validationResult = await checkWellKnownDid({ didDocument, verifyCallback: wellknownDIDVerifyCallback })\r\n if (validationResult.status === ValidationStatusEnum.INVALID) {\r\n const validationErrorMessages = getValidationErrorMessages(validationResult)\r\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages(validationErrorMessages)\r\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\r\n throw new Error(messageCondition.message ? messageCondition.message : validationErrorMessages[0])\r\n }\r\n }\r\n } catch (err: any) {\r\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages([err.message])\r\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\r\n throw new Error(err.message)\r\n }\r\n }\r\n}\r\n\r\ninterface CheckWellKnownDidArgs {\r\n didDocument: DIDDocument\r\n verifyCallback: VerifyCallback\r\n}\r\n\r\nasync function checkWellKnownDid(args: CheckWellKnownDidArgs): Promise<IDomainLinkageValidation> {\r\n const verifier = new WellKnownDidVerifier({\r\n verifySignatureCallback: args.verifyCallback,\r\n onlyVerifyServiceDid: false,\r\n })\r\n return await verifier.verifyDomainLinkage({ didDocument: args.didDocument })\r\n}\r\n","import { SigningAlgo } from '@sphereon/oid4vc-common'\r\nimport { VerifyCallback as WellknownDIDVerifyCallback } from '@sphereon/wellknown-dids-client'\r\nimport { JWTVerifyOptions } from 'did-jwt'\r\nimport { Resolvable } from 'did-resolver'\r\n\r\nexport enum CheckLinkedDomain {\r\n NEVER = 'never', // We don't want to verify Linked domains\r\n IF_PRESENT = 'if_present', // If present, did-auth-siop will check the linked domain, if exist and not valid, throws an exception\r\n ALWAYS = 'always', // We'll always check the linked domains, if not exist or not valid, throws an exception\r\n}\r\n\r\nexport interface InternalSignature {\r\n hexPrivateKey: string // hex private key Only secp256k1 format\r\n did: string\r\n\r\n alg: SigningAlgo\r\n kid?: string // Optional: key identifier\r\n\r\n customJwtSigner?: Signer\r\n}\r\n\r\nexport interface SuppliedSignature {\r\n signature: (data: string | Uint8Array) => Promise<EcdsaSignature | string>\r\n\r\n alg: SigningAlgo\r\n did: string\r\n kid: string\r\n}\r\n\r\nexport interface NoSignature {\r\n hexPublicKey: string // hex public key\r\n did: string\r\n kid?: string // Optional: key identifier\r\n}\r\n\r\nexport interface ExternalSignature {\r\n signatureUri: string // url to call to generate a withSignature\r\n did: string\r\n authZToken: string // Optional: bearer token to use to the call\r\n hexPublicKey?: string // Optional: hex encoded public key to compute JWK key, if not possible from DIDres Document\r\n\r\n alg: SigningAlgo\r\n kid?: string // Optional: key identifier. default did#keys-1\r\n}\r\n\r\nexport enum VerificationMode {\r\n INTERNAL,\r\n EXTERNAL,\r\n}\r\n\r\nexport interface EcdsaSignature {\r\n r: string\r\n s: string\r\n recoveryParam?: number | null\r\n}\r\nexport type Signer = (data: string | Uint8Array) => Promise<EcdsaSignature | string>\r\n\r\nexport interface Verification {\r\n checkLinkedDomain?: CheckLinkedDomain\r\n wellknownDIDVerifyCallback?: WellknownDIDVerifyCallback\r\n resolveOpts: ResolveOpts\r\n}\r\n\r\nexport type InternalVerification = Verification\r\n\r\nexport interface ExternalVerification extends Verification {\r\n verifyUri: string // url to call to verify the id_token withSignature\r\n authZToken?: string // Optional: bearer token to use to the call\r\n}\r\n\r\nexport interface ResolveOpts {\r\n jwtVerifyOpts?: JWTVerifyOptions\r\n resolver?: Resolvable\r\n resolveUrl?: string\r\n noUniversalResolverFallback?: boolean\r\n subjectSyntaxTypesSupported?: string[]\r\n}\r\n","import { AuthorizationRequestPayload, IDTokenPayload, JwtIssuerWithContext, JwtVerifier, RequestObjectPayload } from '@sphereon/did-auth-siop'\r\nimport { JwtHeader, JwtPayload } from '@sphereon/oid4vc-common'\r\nimport { Resolvable } from 'did-resolver'\r\n\r\nimport { getAudience, getSubDidFromPayload, signIDTokenPayload, signRequestObjectPayload, validateLinkedDomainWithDid, verifyDidJWT } from './did'\r\nimport { CheckLinkedDomain, ExternalSignature, ExternalVerification, InternalSignature, InternalVerification, SuppliedSignature } from './types'\r\n\r\nexport const verfiyDidJwtAdapter = async (\r\n jwtVerifier: JwtVerifier,\r\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\r\n options: {\r\n verification: InternalVerification | ExternalVerification\r\n resolver: Resolvable\r\n },\r\n): Promise<boolean> => {\r\n if (jwtVerifier.method === 'did') {\r\n const audience = options?.verification?.resolveOpts?.jwtVerifyOpts?.audience ?? getAudience(jwt.raw)\r\n\r\n await verifyDidJWT(jwt.raw, options.resolver, { ...options.verification?.resolveOpts?.jwtVerifyOpts, audience })\r\n\r\n if (jwtVerifier.type === 'request-object' && (jwt.payload as JwtPayload & { client_id?: string }).client_id?.startsWith('did:')) {\r\n const authorizationRequestPayload = jwt.payload as AuthorizationRequestPayload\r\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\r\n if (!authorizationRequestPayload.client_id) {\r\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\r\n }\r\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\r\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\r\n if (!authorizationRequestPayload.client_id) {\r\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\r\n }\r\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\r\n }\r\n }\r\n\r\n if (jwtVerifier.type === 'id-token') {\r\n const issuerDid = getSubDidFromPayload(jwt.payload)\r\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\r\n await validateLinkedDomainWithDid(issuerDid, options.verification)\r\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\r\n await validateLinkedDomainWithDid(issuerDid, options.verification)\r\n }\r\n }\r\n\r\n return true\r\n }\r\n\r\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\r\n}\r\n\r\nexport const createDidJwtAdapter = async (\r\n signature: InternalSignature | ExternalSignature | SuppliedSignature,\r\n jwtIssuer: JwtIssuerWithContext,\r\n jwt: { header: JwtHeader; payload: JwtPayload },\r\n): Promise<string> => {\r\n if (jwtIssuer.method === 'did') {\r\n const issuer = jwtIssuer.didUrl.split('#')[0]\r\n jwt.payload.issuer = issuer\r\n if (jwtIssuer.type === 'request-object') {\r\n return await signRequestObjectPayload(jwt.payload as RequestObjectPayload, signature)\r\n } else if (jwtIssuer.type === 'id-token') {\r\n return await signIDTokenPayload(jwt.payload as IDTokenPayload, signature)\r\n }\r\n }\r\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA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MAAMsB,mBAAmBjC,IAAIY,SAA2Be,SAAAA;IACjE;EACF;AACA,QAAM,IAAIN,MAAM,qDAAA;AAClB,GAfmC;","names":["isInternalSignature","object","isExternalSignature","isSuppliedSignature","verifyDidJWT","jwt","resolver","options","verifyJWT","createDidJWT","payload","issuer","signer","expiresIn","canonicalize","header","createJWT","signIDTokenPayload","signature","isInternalSignature","kid","Promise","reject","Error","signDidJwtInternal","hexPrivateKey","alg","customJwtSigner","isExternalSignature","signDidJwtExternal","signatureUri","authZToken","isSuppliedSignature","signDidJwtSupplied","signRequestObjectPayload","iss","did","sub","determineSigner","DEFAULT_EXPIRATION_TIME","body","includes","selfIssued","ResponseIss","SELF_ISSUED_V2","undefined","response","post","JSON","stringify","bearerToken","successBody","jws","customSigner","privateKey","hexToBytes","replace","SigningAlgo","EDDSA","EdDSASigner","ES256","ES256Signer","ES256K","ES256KSigner","PS256","RS256","getAudience","decodeJWT","SIOPErrors","NO_AUDIENCE","aud","Array","isArray","INVALID_AUDIENCE","assertIssSelfIssuedOrDid","startsWith","isIssSelfIssued","getSubDidFromPayload","split","SELF_ISSUED_V1","getMethodFromDid","BAD_PARAMS","length","toSIOPRegistrationDidMethod","didOrMethod","prefix","import_did_auth_siop","getResolver","opts","resolver","subjectSyntaxTypesSupported","noUniversalResolverFallback","Error","console","log","UniResolver","uniResolvers","indexOf","SubjectIdentifierType","DID","specificDidMethods","filter","sst","includes","length","didMethod","uniResolver","getUniResolver","getMethodFromDid","resolveUrl","push","Resolver","getResolverUnion","customResolver","resolverMap","fallbackResolver","subjectTypes","SubjectSyntaxTypesSupportedValues","valueOf","startsWith","forEach","dm","methodResolver","has","get","resolve","mergeAllDidMethods","resolvers","Array","isArray","unionSubjectSyntaxTypes","Set","add","_","toSIOPRegistrationDidMethod","from","resolveDidDocument","did","result","accept","didResolutionMetadata","error","didDocument","id","CheckLinkedDomain","VerificationMode","getValidationErrorMessages","validationResult","messages","message","push","endpointDescriptors","length","endpointDescriptor","resources","resource","checkInvalidMessages","validationErrorMessages","status","validMessages","WDCErrors","PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS","valueOf","PROPERTY_LINKED_DIDS_NOT_PRESENT","PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN","PROPERTY_SERVICE_NOT_PRESENT","validationErrorMessage","filter","vm","includes","pop","validateLinkedDomainWithDid","did","verification","checkLinkedDomain","resolveOpts","wellknownDIDVerifyCallback","CheckLinkedDomain","NEVER","didDocument","resolveDidDocument","subjectSyntaxTypesSupported","toSIOPRegistrationDidMethod","getMethodFromDid","Error","service","find","s","type","IF_PRESENT","Promise","reject","checkWellKnownDid","verifyCallback","ValidationStatusEnum","INVALID","messageCondition","ALWAYS","err","args","verifier","WellKnownDidVerifier","verifySignatureCallback","onlyVerifyServiceDid","verifyDomainLinkage","verfiyDidJwtAdapter","jwtVerifier","jwt","options","method","audience","verification","resolveOpts","jwtVerifyOpts","getAudience","raw","verifyDidJWT","resolver","type","payload","client_id","startsWith","authorizationRequestPayload","checkLinkedDomain","CheckLinkedDomain","NEVER","Promise","reject","Error","validateLinkedDomainWithDid","wellknownDIDVerifyCallback","issuerDid","getSubDidFromPayload","createDidJwtAdapter","signature","jwtIssuer","issuer","didUrl","split","signRequestObjectPayload","signIDTokenPayload"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts","../lib/did/DidJWT.ts","../lib/helpers.ts","../lib/did/DIDResolution.ts","../lib/did/LinkedDomainValidations.ts","../lib/types/SIOP.types.ts","../lib/DidJwtAdapter.ts"],"sourcesContent":["export * from './did'\n\nexport * from './types'\nexport * from './DidJwtAdapter'\nexport * from './helpers'\n","import {\n DEFAULT_EXPIRATION_TIME,\n IDTokenPayload,\n post,\n RequestObjectPayload,\n ResponseIss,\n SignatureResponse,\n SIOPErrors,\n SIOPResonse,\n VerifiedJWT,\n} from '@sphereon/did-auth-siop'\nimport { SigningAlgo } from '@sphereon/oid4vc-common'\nimport {\n createJWT,\n decodeJWT,\n EdDSASigner,\n ES256KSigner,\n ES256Signer,\n hexToBytes,\n JWTHeader,\n JWTOptions,\n JWTPayload,\n JWTVerifyOptions,\n Signer,\n verifyJWT,\n} from 'did-jwt'\nimport { Resolvable } from 'did-resolver'\n\nimport { isExternalSignature, isInternalSignature, isSuppliedSignature } from '../helpers'\nimport { ExternalSignature, InternalSignature, SuppliedSignature } from '../types'\n\n/**\n * Verifies given JWT. If the JWT is valid, the promise returns an object including the JWT, the payload of the JWT,\n * and the did doc of the issuer of the JWT.\n *\n * @example\n * verifyDidJWT('did:key:example', resolver, {audience: '5A8bRWU3F7j3REx3vkJ...', callbackUrl: 'https://...'}).then(obj => {\n * const did = obj.did // DIDres of signer\n * const payload = obj.payload\n * const doc = obj.doc // DIDres Document of signer\n * const JWT = obj.JWT // JWT\n * const signerKeyId = obj.signerKeyId // ID of key in DIDres document that signed JWT\n * ...\n * })\n *\n * @param {String} jwt a JSON Web Token to verify\n * @param {Resolvable} resolver\n * @param {JWTVerifyOptions} [options] Options\n * @param {String} options.audience DID of the recipient of the JWT\n * @param {String} options.callbackUrl callback url in JWT\n * @return {Promise<Object, Error>} a promise which resolves with a response object or rejects with an error\n */\nexport async function verifyDidJWT(jwt: string, resolver: Resolvable, options: JWTVerifyOptions): Promise<VerifiedJWT> {\n return verifyJWT(jwt, { ...options, resolver })\n}\n\n/**\n * Creates a signed JWT given an address which becomes the issuer, a signer function, and a payload for which the withSignature is over.\n *\n * @example\n * const signer = ES256KSigner(process.env.PRIVATE_KEY)\n * createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(JWT => {\n * ...\n * })\n *\n * @param {Object} payload payload object\n * @param {Object} [options] an unsigned credential object\n * @param {String} options.issuer The DID of the issuer (signer) of JWT\n * @param {Signer} options.signer a `Signer` function, Please see `ES256KSigner` or `EdDSASigner`\n * @param {boolean} options.canonicalize optional flag to canonicalize header and payload before signing\n * @param {Object} header optional object to specify or customize the JWT header\n * @return {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an error\n */\nexport async function createDidJWT(\n payload: Partial<JWTPayload>,\n { issuer, signer, expiresIn, canonicalize }: JWTOptions,\n header: Partial<JWTHeader>,\n): Promise<string> {\n return createJWT(payload, { issuer, signer, expiresIn, canonicalize }, header)\n}\n\nexport async function signIDTokenPayload(payload: IDTokenPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\n if (isInternalSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtInternal(payload, payload.issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\n } else if (isExternalSignature(signature)) {\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\n } else if (isSuppliedSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtSupplied(payload, payload.issuer, signature.signature, signature.alg, signature.kid)\n } else {\n throw new Error(\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\n )\n }\n}\n\nexport async function signRequestObjectPayload(payload: RequestObjectPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\n let issuer = payload.iss\n if (!issuer) {\n issuer = signature.did\n }\n if (!issuer) {\n throw Error('No issuer supplied to sign the JWT')\n }\n if (!payload.iss) {\n payload.iss = issuer\n }\n if (!payload.sub) {\n payload.sub = signature.did\n }\n if (isInternalSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtInternal(payload, issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\n } else if (isExternalSignature(signature)) {\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\n } else if (isSuppliedSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtSupplied(payload, issuer, signature.signature, signature.alg, signature.kid)\n } else {\n throw new Error(\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\n )\n }\n}\n\nexport async function signDidJwtInternal(\n payload: IDTokenPayload | RequestObjectPayload,\n issuer: string,\n hexPrivateKey: string,\n alg: SigningAlgo,\n kid: string,\n customJwtSigner?: Signer,\n): Promise<string> {\n const signer = determineSigner(alg, hexPrivateKey, customJwtSigner)\n const header = {\n alg,\n kid,\n }\n const options = {\n issuer,\n signer,\n expiresIn: DEFAULT_EXPIRATION_TIME,\n }\n\n return await createDidJWT({ ...payload }, options, header)\n}\n\nasync function signDidJwtExternal(\n payload: IDTokenPayload | RequestObjectPayload,\n signatureUri: string,\n authZToken: string,\n alg: SigningAlgo,\n kid?: string,\n): Promise<string> {\n const body = {\n issuer: payload.iss && payload.iss.includes('did:') ? payload.iss : payload.sub,\n payload,\n expiresIn: DEFAULT_EXPIRATION_TIME,\n alg,\n selfIssued: payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2) ? payload.iss : undefined,\n kid,\n }\n\n const response: SIOPResonse<SignatureResponse> = await post(signatureUri, JSON.stringify(body), { bearerToken: authZToken })\n if (!response.successBody) {\n return Promise.reject(Error('the siop SignatureResponse does not have a successBody'))\n }\n return response.successBody.jws\n}\n\nasync function signDidJwtSupplied(\n payload: IDTokenPayload | RequestObjectPayload,\n issuer: string,\n signer: Signer,\n alg: SigningAlgo,\n kid: string,\n): Promise<string> {\n const header = {\n alg,\n kid,\n }\n const options = {\n issuer,\n signer,\n expiresIn: DEFAULT_EXPIRATION_TIME,\n }\n\n return await createDidJWT({ ...payload }, options, header)\n}\n\nconst determineSigner = (alg: SigningAlgo, hexPrivateKey?: string, customSigner?: Signer): Signer => {\n if (customSigner) {\n return customSigner\n } else if (!hexPrivateKey) {\n throw new Error('no private key provided')\n }\n const privateKey = hexToBytes(hexPrivateKey.replace('0x', ''))\n switch (alg) {\n case SigningAlgo.EDDSA:\n return EdDSASigner(privateKey)\n case SigningAlgo.ES256:\n return ES256Signer(privateKey)\n case SigningAlgo.ES256K:\n return ES256KSigner(privateKey)\n case SigningAlgo.PS256:\n throw Error('PS256 is not supported yet. Please provide a custom signer')\n case SigningAlgo.RS256:\n throw Error('RS256 is not supported yet. Please provide a custom signer')\n }\n}\n\nexport function getAudience(jwt: string) {\n const { payload } = decodeJWT(jwt)\n if (!payload) {\n throw new Error(SIOPErrors.NO_AUDIENCE)\n } else if (!payload.aud) {\n return undefined\n } else if (Array.isArray(payload.aud)) {\n throw new Error(SIOPErrors.INVALID_AUDIENCE)\n }\n\n return payload.aud\n}\n\n//TODO To enable automatic registration, it cannot be a did, but HTTPS URL\nfunction assertIssSelfIssuedOrDid(payload: JWTPayload) {\n if (!payload.sub || !payload.sub.startsWith('did:') || !payload.iss || !isIssSelfIssued(payload)) {\n throw new Error('Token does not have a iss DID')\n }\n}\n\nexport function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): string {\n assertIssSelfIssuedOrDid(payload)\n\n if (isIssSelfIssued(payload)) {\n let did\n if (payload.sub && payload.sub.startsWith('did:')) {\n did = payload.sub\n }\n if (!did && header && header.kid && header.kid.startsWith('did:')) {\n did = header.kid.split('#')[0]\n }\n if (did) {\n return did\n }\n }\n return payload.sub!\n}\n\nexport function isIssSelfIssued(payload: JWTPayload): boolean {\n return (\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V1)) ||\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2)) ||\n payload.iss === payload.sub\n )\n}\n\nexport function getMethodFromDid(did: string): string {\n if (!did) {\n throw new Error(SIOPErrors.BAD_PARAMS)\n }\n const split = did.split(':')\n if (split.length == 1 && did.length > 0) {\n return did\n } else if (!did.startsWith('did:') || split.length < 2) {\n throw new Error(SIOPErrors.BAD_PARAMS)\n }\n\n return split[1]\n}\n\n/**\n * Since the OIDC SIOP spec incorrectly uses 'did:<method>:' and calls that a method, we have to fix it\n * @param didOrMethod\n */\nexport function toSIOPRegistrationDidMethod(didOrMethod: string) {\n let prefix = didOrMethod\n if (!didOrMethod.startsWith('did:')) {\n prefix = 'did:' + didOrMethod\n }\n const split = prefix.split(':')\n return `${split[0]}:${split[1]}`\n}\n","import { ExternalSignature, InternalSignature, NoSignature, SuppliedSignature } from './types/SIOP.types'\n\nexport const isInternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is InternalSignature =>\n 'hexPrivateKey' in object && 'did' in object\n\nexport const isExternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is ExternalSignature =>\n 'signatureUri' in object && 'did' in object\n\nexport const isSuppliedSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is SuppliedSignature =>\n 'signature' in object\n","import { SubjectIdentifierType, SubjectSyntaxTypesSupportedValues } from '@sphereon/did-auth-siop'\nimport { getUniResolver, UniResolver } from '@sphereon/did-uni-client'\nimport { DIDResolutionOptions, DIDResolutionResult, ParsedDID, Resolvable, Resolver, ResolverRegistry } from 'did-resolver'\n\nimport { DIDDocument, ResolveOpts } from '../types'\n\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from '.'\n\nexport function getResolver(opts: ResolveOpts): Resolvable {\n if (opts && typeof opts.resolver === 'object') {\n return opts.resolver\n }\n if (!opts || !opts.subjectSyntaxTypesSupported) {\n if (opts?.noUniversalResolverFallback) {\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\n }\n console.log(\n `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`,\n )\n return new UniResolver()\n }\n\n const uniResolvers: {\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\n }[] = []\n if (opts.subjectSyntaxTypesSupported.indexOf(SubjectIdentifierType.DID) === -1) {\n const specificDidMethods = opts.subjectSyntaxTypesSupported.filter((sst) => sst.includes('did:'))\n if (!specificDidMethods.length) {\n throw new Error('No did method found.')\n }\n for (const didMethod of specificDidMethods) {\n const uniResolver = getUniResolver(getMethodFromDid(didMethod), { resolveUrl: opts.resolveUrl })\n uniResolvers.push(uniResolver)\n }\n return new Resolver(...uniResolvers)\n } else {\n if (opts?.noUniversalResolverFallback) {\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\n }\n console.log(\n `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`,\n )\n return new UniResolver()\n }\n}\n\n/**\n * This method returns a resolver object in OP/RP\n * If the user of this library, configures OP/RP to have a customResolver, we will use that\n * If the user of this library configures OP/RP to use a custom resolver for any specific did method, we will use that\n * and in the end for the rest of the did methods, configured either with calling `addDidMethod` upon building OP/RP\n * (without any resolver configuration) or declaring in the subject_syntax_types_supported of the registration object\n * we will use universal resolver from Sphereon's DID Universal Resolver library\n * @param customResolver\n * @param subjectSyntaxTypesSupported\n * @param resolverMap\n */\nexport function getResolverUnion(\n customResolver: Resolvable,\n subjectSyntaxTypesSupported: string[] | string,\n resolverMap: Map<string, Resolvable>,\n): Resolvable {\n if (customResolver) {\n return customResolver\n }\n const fallbackResolver: Resolvable = customResolver ? customResolver : new UniResolver()\n const uniResolvers: {\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\n }[] = []\n const subjectTypes: string[] = []\n if (subjectSyntaxTypesSupported) {\n typeof subjectSyntaxTypesSupported === 'string'\n ? subjectTypes.push(subjectSyntaxTypesSupported)\n : subjectTypes.push(...subjectSyntaxTypesSupported)\n }\n if (subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1) {\n return customResolver ? customResolver : new UniResolver()\n }\n const specificDidMethods = subjectTypes.filter((sst) => !!sst && sst.startsWith('did:'))\n specificDidMethods.forEach((dm) => {\n let methodResolver: ResolverRegistry | Resolvable | undefined\n if (!resolverMap.has(dm) || resolverMap.get(dm) === null) {\n methodResolver = getUniResolver(getMethodFromDid(dm))\n if (methodResolver) {\n uniResolvers.push(methodResolver)\n }\n } else {\n methodResolver = resolverMap.get(dm)\n if (methodResolver) {\n uniResolvers.push({ [dm]: methodResolver.resolve })\n }\n }\n })\n return subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1\n ? new Resolver(...{ fallbackResolver, ...uniResolvers })\n : new Resolver(...uniResolvers)\n}\n\nexport function mergeAllDidMethods(subjectSyntaxTypesSupported: string | string[], resolvers: Map<string, Resolvable>): string[] {\n if (!Array.isArray(subjectSyntaxTypesSupported)) {\n subjectSyntaxTypesSupported = [subjectSyntaxTypesSupported]\n }\n const unionSubjectSyntaxTypes = new Set()\n subjectSyntaxTypesSupported.forEach((sst) => unionSubjectSyntaxTypes.add(sst))\n resolvers.forEach((_, didMethod) => unionSubjectSyntaxTypes.add(toSIOPRegistrationDidMethod(didMethod)))\n return Array.from(unionSubjectSyntaxTypes) as string[]\n}\n\nexport async function resolveDidDocument(did: string, opts?: ResolveOpts): Promise<DIDDocument> {\n // 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\n const result = await getResolver({ ...opts }).resolve(did, { accept: 'application/did+ld+json' })\n if (result?.didResolutionMetadata?.error) {\n throw Error(result.didResolutionMetadata.error)\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!result.didDocument && result.id) {\n // todo: This looks like a bug. It seems that sometimes we get back a DID document directly instead of a did resolution results\n return result as unknown as DIDDocument\n }\n return result.didDocument as DIDDocument\n}\n","import { IDomainLinkageValidation, ValidationStatusEnum, VerifyCallback, WDCErrors, WellKnownDidVerifier } from '@sphereon/wellknown-dids-client'\n\nimport { DIDDocument } from '../types/SSI.types'\n\nimport { CheckLinkedDomain, ExternalVerification, InternalVerification } from './../types/'\nimport { resolveDidDocument } from './DIDResolution'\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from './DidJWT'\n\nfunction getValidationErrorMessages(validationResult: IDomainLinkageValidation): string[] {\n const messages = []\n if (validationResult.message) {\n messages.push(validationResult.message)\n }\n if (validationResult?.endpointDescriptors?.length) {\n for (const endpointDescriptor of validationResult.endpointDescriptors) {\n if (endpointDescriptor.message) {\n messages.push(endpointDescriptor.message)\n }\n if (endpointDescriptor.resources) {\n for (const resource of endpointDescriptor.resources) {\n if (resource.message) {\n messages.push(resource.message)\n }\n }\n }\n }\n }\n return messages\n}\n\n/**\n * @param validationErrorMessages\n * @return returns false if the messages received from wellknown-dids-client makes this invalid for CheckLinkedDomain.IF_PRESENT plus the message itself\n * and true for when we can move on\n */\nfunction checkInvalidMessages(validationErrorMessages: string[]): { status: boolean; message?: string } {\n if (!validationErrorMessages || !validationErrorMessages.length) {\n return { status: false, message: 'linked domain is invalid.' }\n }\n const validMessages: string[] = [\n WDCErrors.PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS.valueOf(),\n WDCErrors.PROPERTY_LINKED_DIDS_NOT_PRESENT.valueOf(),\n WDCErrors.PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN.valueOf(),\n WDCErrors.PROPERTY_SERVICE_NOT_PRESENT.valueOf(),\n ]\n for (const validationErrorMessage of validationErrorMessages) {\n if (!validMessages.filter((vm) => validationErrorMessage.includes(vm)).pop()) {\n return { status: false, message: validationErrorMessage }\n }\n }\n return { status: true }\n}\n\nexport async function validateLinkedDomainWithDid(did: string, verification: InternalVerification | ExternalVerification): Promise<void> {\n const { checkLinkedDomain, resolveOpts, wellknownDIDVerifyCallback } = verification\n if (checkLinkedDomain === CheckLinkedDomain.NEVER) {\n return\n }\n const didDocument = await resolveDidDocument(did, {\n ...resolveOpts,\n subjectSyntaxTypesSupported: [toSIOPRegistrationDidMethod(getMethodFromDid(did))],\n })\n if (!didDocument) {\n throw Error(`Could not resolve DID: ${did}`)\n }\n if ((!didDocument.service || !didDocument.service.find((s) => s.type === 'LinkedDomains')) && checkLinkedDomain === CheckLinkedDomain.IF_PRESENT) {\n // No linked domains in DID document and it was optional. Let's cut it short here.\n return\n }\n try {\n if (!wellknownDIDVerifyCallback) {\n return Promise.reject(Error('wellknownDIDVerifyCallback is required for checkWellKnownDid'))\n }\n const validationResult = await checkWellKnownDid({ didDocument, verifyCallback: wellknownDIDVerifyCallback })\n if (validationResult.status === ValidationStatusEnum.INVALID) {\n const validationErrorMessages = getValidationErrorMessages(validationResult)\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages(validationErrorMessages)\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\n throw new Error(messageCondition.message ? messageCondition.message : validationErrorMessages[0])\n }\n }\n } catch (err: any) {\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages([err.message])\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\n throw new Error(err.message)\n }\n }\n}\n\ninterface CheckWellKnownDidArgs {\n didDocument: DIDDocument\n verifyCallback: VerifyCallback\n}\n\nasync function checkWellKnownDid(args: CheckWellKnownDidArgs): Promise<IDomainLinkageValidation> {\n const verifier = new WellKnownDidVerifier({\n verifySignatureCallback: args.verifyCallback,\n onlyVerifyServiceDid: false,\n })\n return await verifier.verifyDomainLinkage({ didDocument: args.didDocument })\n}\n","import { SigningAlgo } from '@sphereon/oid4vc-common'\nimport { VerifyCallback as WellknownDIDVerifyCallback } from '@sphereon/wellknown-dids-client'\nimport { JWTVerifyOptions } from 'did-jwt'\nimport { Resolvable } from 'did-resolver'\n\nexport enum CheckLinkedDomain {\n NEVER = 'never', // We don't want to verify Linked domains\n IF_PRESENT = 'if_present', // If present, did-auth-siop will check the linked domain, if exist and not valid, throws an exception\n ALWAYS = 'always', // We'll always check the linked domains, if not exist or not valid, throws an exception\n}\n\nexport interface InternalSignature {\n hexPrivateKey: string // hex private key Only secp256k1 format\n did: string\n\n alg: SigningAlgo\n kid?: string // Optional: key identifier\n\n customJwtSigner?: Signer\n}\n\nexport interface SuppliedSignature {\n signature: (data: string | Uint8Array) => Promise<EcdsaSignature | string>\n\n alg: SigningAlgo\n did: string\n kid: string\n}\n\nexport interface NoSignature {\n hexPublicKey: string // hex public key\n did: string\n kid?: string // Optional: key identifier\n}\n\nexport interface ExternalSignature {\n signatureUri: string // url to call to generate a withSignature\n did: string\n authZToken: string // Optional: bearer token to use to the call\n hexPublicKey?: string // Optional: hex encoded public key to compute JWK key, if not possible from DIDres Document\n\n alg: SigningAlgo\n kid?: string // Optional: key identifier. default did#keys-1\n}\n\nexport enum VerificationMode {\n INTERNAL,\n EXTERNAL,\n}\n\nexport interface EcdsaSignature {\n r: string\n s: string\n recoveryParam?: number | null\n}\nexport type Signer = (data: string | Uint8Array) => Promise<EcdsaSignature | string>\n\nexport interface Verification {\n checkLinkedDomain?: CheckLinkedDomain\n wellknownDIDVerifyCallback?: WellknownDIDVerifyCallback\n resolveOpts: ResolveOpts\n}\n\nexport type InternalVerification = Verification\n\nexport interface ExternalVerification extends Verification {\n verifyUri: string // url to call to verify the id_token withSignature\n authZToken?: string // Optional: bearer token to use to the call\n}\n\nexport interface ResolveOpts {\n jwtVerifyOpts?: JWTVerifyOptions\n resolver?: Resolvable\n resolveUrl?: string\n noUniversalResolverFallback?: boolean\n subjectSyntaxTypesSupported?: string[]\n}\n","import { AuthorizationRequestPayload, IDTokenPayload, JwtIssuerWithContext, JwtVerifier, RequestObjectPayload } from '@sphereon/did-auth-siop'\nimport { JwtHeader, JwtPayload } from '@sphereon/oid4vc-common'\nimport { Resolvable } from 'did-resolver'\n\nimport { getAudience, getSubDidFromPayload, signIDTokenPayload, signRequestObjectPayload, validateLinkedDomainWithDid, verifyDidJWT } from './did'\nimport { CheckLinkedDomain, ExternalSignature, ExternalVerification, InternalSignature, InternalVerification, SuppliedSignature } from './types'\n\nexport const verfiyDidJwtAdapter = async (\n jwtVerifier: JwtVerifier,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n options: {\n verification: InternalVerification | ExternalVerification\n resolver: Resolvable\n },\n): Promise<boolean> => {\n if (jwtVerifier.method === 'did') {\n const audience = options?.verification?.resolveOpts?.jwtVerifyOpts?.audience ?? getAudience(jwt.raw)\n\n await verifyDidJWT(jwt.raw, options.resolver, { ...options.verification?.resolveOpts?.jwtVerifyOpts, audience })\n\n if (jwtVerifier.type === 'request-object' && (jwt.payload as JwtPayload & { client_id?: string }).client_id?.startsWith('did:')) {\n const authorizationRequestPayload = jwt.payload as AuthorizationRequestPayload\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\n if (!authorizationRequestPayload.client_id) {\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\n }\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\n if (!authorizationRequestPayload.client_id) {\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\n }\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\n }\n }\n\n if (jwtVerifier.type === 'id-token') {\n const issuerDid = getSubDidFromPayload(jwt.payload)\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\n await validateLinkedDomainWithDid(issuerDid, options.verification)\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\n await validateLinkedDomainWithDid(issuerDid, options.verification)\n }\n }\n\n return true\n }\n\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\n}\n\nexport const createDidJwtAdapter = async (\n signature: InternalSignature | ExternalSignature | SuppliedSignature,\n jwtIssuer: JwtIssuerWithContext,\n jwt: { header: JwtHeader; payload: JwtPayload },\n): Promise<string> => {\n if (jwtIssuer.method === 'did') {\n const issuer = jwtIssuer.didUrl.split('#')[0]\n jwt.payload.issuer = issuer\n if (jwtIssuer.type === 'request-object') {\n return await signRequestObjectPayload(jwt.payload as RequestObjectPayload, signature)\n } else if (jwtIssuer.type === 'id-token') {\n return await signIDTokenPayload(jwt.payload as IDTokenPayload, signature)\n }\n }\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,2BAUO;AACP,2BAA4B;AAC5B,qBAaO;;;ACvBA,IAAMA,sBAAsB,wBAACC,WAClC,mBAAmBA,UAAU,SAASA,QADL;AAG5B,IAAMC,sBAAsB,wBAACD,WAClC,kBAAkBA,UAAU,SAASA,QADJ;AAG5B,IAAME,sBAAsB,wBAACF,WAClC,eAAeA,QADkB;;;AD4CnC,eAAsBG,aAAaC,KAAaC,UAAsBC,SAAyB;AAC7F,aAAOC,0BAAUH,KAAK;IAAE,GAAGE;IAASD;EAAS,CAAA;AAC/C;AAFsBF;AAqBtB,eAAsBK,aACpBC,SACA,EAAEC,QAAQC,QAAQC,WAAWC,aAAY,GACzCC,QAA0B;AAE1B,aAAOC,0BAAUN,SAAS;IAAEC;IAAQC;IAAQC;IAAWC;EAAa,GAAGC,MAAAA;AACzE;AANsBN;AAQtB,eAAsBQ,mBAAmBP,SAAyBQ,WAAoE;AACpI,MAAIC,oBAAoBD,SAAAA,GAAY;AAClC,QAAI,CAACA,UAAUE,KAAK;AAClB,aAAOC,QAAQC,OAAOC,MAAM,4BAAA,CAAA;IAC9B;AACA,WAAOC,mBAAmBd,SAASA,QAAQC,QAAQO,UAAUO,eAAeP,UAAUQ,KAAKR,UAAUE,KAAKF,UAAUS,eAAe;EACrI,WAAWC,oBAAoBV,SAAAA,GAAY;AACzC,WAAOW,mBAAmBnB,SAASQ,UAAUY,cAAcZ,UAAUa,YAAYb,UAAUQ,KAAKR,UAAUE,G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sBAAsB,8BACjCC,WACAC,WACA5B,QAAAA;AAEA,MAAI4B,UAAU1B,WAAW,OAAO;AAC9B,UAAM2B,SAASD,UAAUE,OAAOC,MAAM,GAAA,EAAK,CAAA;AAC3C/B,QAAIY,QAAQiB,SAASA;AACrB,QAAID,UAAUjB,SAAS,kBAAkB;AACvC,aAAO,MAAMqB,yBAAyBhC,IAAIY,SAAiCe,SAAAA;IAC7E,WAAWC,UAAUjB,SAAS,YAAY;AACxC,aAAO,MAAMsB,mBAAmBjC,IAAIY,SAA2Be,SAAAA;IACjE;EACF;AACA,QAAM,IAAIN,MAAM,qDAAA;AAClB,GAfmC;","names":["isInternalSignature","object","isExternalSignature","isSuppliedSignature","verifyDidJWT","jwt","resolver","options","verifyJWT","createDidJWT","payload","issuer","signer","expiresIn","canonicalize","header","createJWT","signIDTokenPayload","signature","isInternalSignature","kid","Promise","reject","Error","signDidJwtInternal","hexPrivateKey","alg","customJwtSigner","isExternalSignature","signDidJwtExternal","signatureUri","authZToken","isSuppliedSignature","signDidJwtSupplied","signRequestObjectPayload","iss","did","sub","determineSigner","DEFAULT_EXPIRATION_TIME","body","includes","selfIssued","ResponseIss","SELF_ISSUED_V2","undefined","response","post","JSON","stringify","bearerToken","successBody","jws","customSigner","privateKey","hexToBytes","replace","SigningAlgo","EDDSA","EdDSASigner","ES256","ES256Signer","ES256K","ES256KSigner","PS256","RS256","getAudience","decodeJWT","SIOPErrors","NO_AUDIENCE","aud","Array","isArray","INVALID_AUDIENCE","assertIssSelfIssuedOrDid","startsWith","isIssSelfIssued","getSubDidFromPayload","split","SELF_ISSUED_V1","getMethodFromDid","BAD_PARAMS","length","toSIOPRegistrationDidMethod","didOrMethod","prefix","import_did_auth_siop","getResolver","opts","resolver","subjectSyntaxTypesSupported","noUniversalResolverFallback","Error","console","log","UniResolver","uniResolvers","indexOf","SubjectIdentifierType","DID","specificDidMethods","filter","sst","includes","length","didMethod","uniResolver","getUniResolver","getMethodFromDid","resolveUrl","push","Resolver","getResolverUnion","customResolver","resolverMap","fallbackResolver","subjectTypes","SubjectSyntaxTypesSupportedValues","valueOf","startsWith","forEach","dm","methodResolver","has","get","resolve","mergeAllDidMethods","resolvers","Array","isArray","unionSubjectSyntaxTypes","Set","add","_","toSIOPRegistrationDidMethod","from","resolveDidDocument","did","result","accept","didResolutionMetadata","error","didDocument","id","CheckLinkedDomain","VerificationMode","getValidationErrorMessages","validationResult","messages","message","push","endpointDescriptors","length","endpointDescriptor","resources","resource","checkInvalidMessages","validationErrorMessages","status","validMessages","WDCErrors","PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS","valueOf","PROPERTY_LINKED_DIDS_NOT_PRESENT","PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN","PROPERTY_SERVICE_NOT_PRESENT","validationErrorMessage","filter","vm","includes","pop","validateLinkedDomainWithDid","did","verification","checkLinkedDomain","resolveOpts","wellknownDIDVerifyCallback","CheckLinkedDomain","NEVER","didDocument","resolveDidDocument","subjectSyntaxTypesSupported","toSIOPRegistrationDidMethod","getMethodFromDid","Error","service","find","s","type","IF_PRESENT","Promise","reject","checkWellKnownDid","verifyCallback","ValidationStatusEnum","INVALID","messageCondition","ALWAYS","err","args","verifier","WellKnownDidVerifier","verifySignatureCallback","onlyVerifyServiceDid","verifyDomainLinkage","verfiyDidJwtAdapter","jwtVerifier","jwt","options","method","audience","verification","resolveOpts","jwtVerifyOpts","getAudience","raw","verifyDidJWT","resolver","type","payload","client_id","startsWith","authorizationRequestPayload","checkLinkedDomain","CheckLinkedDomain","NEVER","Promise","reject","Error","validateLinkedDomainWithDid","wellknownDIDVerifyCallback","issuerDid","getSubDidFromPayload","createDidJwtAdapter","signature","jwtIssuer","issuer","didUrl","split","signRequestObjectPayload","signIDTokenPayload"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/did/DidJWT.ts","../lib/helpers.ts","../lib/did/DIDResolution.ts","../lib/did/LinkedDomainValidations.ts","../lib/types/SIOP.types.ts","../lib/DidJwtAdapter.ts"],"sourcesContent":["import {\r\n DEFAULT_EXPIRATION_TIME,\r\n IDTokenPayload,\r\n post,\r\n RequestObjectPayload,\r\n ResponseIss,\r\n SignatureResponse,\r\n SIOPErrors,\r\n SIOPResonse,\r\n VerifiedJWT,\r\n} from '@sphereon/did-auth-siop'\r\nimport { SigningAlgo } from '@sphereon/oid4vc-common'\r\nimport {\r\n createJWT,\r\n decodeJWT,\r\n EdDSASigner,\r\n ES256KSigner,\r\n ES256Signer,\r\n hexToBytes,\r\n JWTHeader,\r\n JWTOptions,\r\n JWTPayload,\r\n JWTVerifyOptions,\r\n Signer,\r\n verifyJWT,\r\n} from 'did-jwt'\r\nimport { Resolvable } from 'did-resolver'\r\n\r\nimport { isExternalSignature, isInternalSignature, isSuppliedSignature } from '../helpers'\r\nimport { ExternalSignature, InternalSignature, SuppliedSignature } from '../types'\r\n\r\n/**\r\n * Verifies given JWT. If the JWT is valid, the promise returns an object including the JWT, the payload of the JWT,\r\n * and the did doc of the issuer of the JWT.\r\n *\r\n * @example\r\n * verifyDidJWT('did:key:example', resolver, {audience: '5A8bRWU3F7j3REx3vkJ...', callbackUrl: 'https://...'}).then(obj => {\r\n * const did = obj.did // DIDres of signer\r\n * const payload = obj.payload\r\n * const doc = obj.doc // DIDres Document of signer\r\n * const JWT = obj.JWT // JWT\r\n * const signerKeyId = obj.signerKeyId // ID of key in DIDres document that signed JWT\r\n * ...\r\n * })\r\n *\r\n * @param {String} jwt a JSON Web Token to verify\r\n * @param {Resolvable} resolver\r\n * @param {JWTVerifyOptions} [options] Options\r\n * @param {String} options.audience DID of the recipient of the JWT\r\n * @param {String} options.callbackUrl callback url in JWT\r\n * @return {Promise<Object, Error>} a promise which resolves with a response object or rejects with an error\r\n */\r\nexport async function verifyDidJWT(jwt: string, resolver: Resolvable, options: JWTVerifyOptions): Promise<VerifiedJWT> {\r\n return verifyJWT(jwt, { ...options, resolver })\r\n}\r\n\r\n/**\r\n * Creates a signed JWT given an address which becomes the issuer, a signer function, and a payload for which the withSignature is over.\r\n *\r\n * @example\r\n * const signer = ES256KSigner(process.env.PRIVATE_KEY)\r\n * createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(JWT => {\r\n * ...\r\n * })\r\n *\r\n * @param {Object} payload payload object\r\n * @param {Object} [options] an unsigned credential object\r\n * @param {String} options.issuer The DID of the issuer (signer) of JWT\r\n * @param {Signer} options.signer a `Signer` function, Please see `ES256KSigner` or `EdDSASigner`\r\n * @param {boolean} options.canonicalize optional flag to canonicalize header and payload before signing\r\n * @param {Object} header optional object to specify or customize the JWT header\r\n * @return {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an error\r\n */\r\nexport async function createDidJWT(\r\n payload: Partial<JWTPayload>,\r\n { issuer, signer, expiresIn, canonicalize }: JWTOptions,\r\n header: Partial<JWTHeader>,\r\n): Promise<string> {\r\n return createJWT(payload, { issuer, signer, expiresIn, canonicalize }, header)\r\n}\r\n\r\nexport async function signIDTokenPayload(payload: IDTokenPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\r\n if (isInternalSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtInternal(payload, payload.issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\r\n } else if (isExternalSignature(signature)) {\r\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\r\n } else if (isSuppliedSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtSupplied(payload, payload.issuer, signature.signature, signature.alg, signature.kid)\r\n } else {\r\n throw new Error(\r\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\r\n )\r\n }\r\n}\r\n\r\nexport async function signRequestObjectPayload(payload: RequestObjectPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\r\n let issuer = payload.iss\r\n if (!issuer) {\r\n issuer = signature.did\r\n }\r\n if (!issuer) {\r\n throw Error('No issuer supplied to sign the JWT')\r\n }\r\n if (!payload.iss) {\r\n payload.iss = issuer\r\n }\r\n if (!payload.sub) {\r\n payload.sub = signature.did\r\n }\r\n if (isInternalSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtInternal(payload, issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\r\n } else if (isExternalSignature(signature)) {\r\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\r\n } else if (isSuppliedSignature(signature)) {\r\n if (!signature.kid) {\r\n return Promise.reject(Error('missing kid from signature'))\r\n }\r\n return signDidJwtSupplied(payload, issuer, signature.signature, signature.alg, signature.kid)\r\n } else {\r\n throw new Error(\r\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\r\n )\r\n }\r\n}\r\n\r\nexport async function signDidJwtInternal(\r\n payload: IDTokenPayload | RequestObjectPayload,\r\n issuer: string,\r\n hexPrivateKey: string,\r\n alg: SigningAlgo,\r\n kid: string,\r\n customJwtSigner?: Signer,\r\n): Promise<string> {\r\n const signer = determineSigner(alg, hexPrivateKey, customJwtSigner)\r\n const header = {\r\n alg,\r\n kid,\r\n }\r\n const options = {\r\n issuer,\r\n signer,\r\n expiresIn: DEFAULT_EXPIRATION_TIME,\r\n }\r\n\r\n return await createDidJWT({ ...payload }, options, header)\r\n}\r\n\r\nasync function signDidJwtExternal(\r\n payload: IDTokenPayload | RequestObjectPayload,\r\n signatureUri: string,\r\n authZToken: string,\r\n alg: SigningAlgo,\r\n kid?: string,\r\n): Promise<string> {\r\n const body = {\r\n issuer: payload.iss && payload.iss.includes('did:') ? payload.iss : payload.sub,\r\n payload,\r\n expiresIn: DEFAULT_EXPIRATION_TIME,\r\n alg,\r\n selfIssued: payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2) ? payload.iss : undefined,\r\n kid,\r\n }\r\n\r\n const response: SIOPResonse<SignatureResponse> = await post(signatureUri, JSON.stringify(body), { bearerToken: authZToken })\r\n if (!response.successBody) {\r\n return Promise.reject(Error('the siop SignatureResponse does not have a successBody'))\r\n }\r\n return response.successBody.jws\r\n}\r\n\r\nasync function signDidJwtSupplied(\r\n payload: IDTokenPayload | RequestObjectPayload,\r\n issuer: string,\r\n signer: Signer,\r\n alg: SigningAlgo,\r\n kid: string,\r\n): Promise<string> {\r\n const header = {\r\n alg,\r\n kid,\r\n }\r\n const options = {\r\n issuer,\r\n signer,\r\n expiresIn: DEFAULT_EXPIRATION_TIME,\r\n }\r\n\r\n return await createDidJWT({ ...payload }, options, header)\r\n}\r\n\r\nconst determineSigner = (alg: SigningAlgo, hexPrivateKey?: string, customSigner?: Signer): Signer => {\r\n if (customSigner) {\r\n return customSigner\r\n } else if (!hexPrivateKey) {\r\n throw new Error('no private key provided')\r\n }\r\n const privateKey = hexToBytes(hexPrivateKey.replace('0x', ''))\r\n switch (alg) {\r\n case SigningAlgo.EDDSA:\r\n return EdDSASigner(privateKey)\r\n case SigningAlgo.ES256:\r\n return ES256Signer(privateKey)\r\n case SigningAlgo.ES256K:\r\n return ES256KSigner(privateKey)\r\n case SigningAlgo.PS256:\r\n throw Error('PS256 is not supported yet. Please provide a custom signer')\r\n case SigningAlgo.RS256:\r\n throw Error('RS256 is not supported yet. Please provide a custom signer')\r\n }\r\n}\r\n\r\nexport function getAudience(jwt: string) {\r\n const { payload } = decodeJWT(jwt)\r\n if (!payload) {\r\n throw new Error(SIOPErrors.NO_AUDIENCE)\r\n } else if (!payload.aud) {\r\n return undefined\r\n } else if (Array.isArray(payload.aud)) {\r\n throw new Error(SIOPErrors.INVALID_AUDIENCE)\r\n }\r\n\r\n return payload.aud\r\n}\r\n\r\n//TODO To enable automatic registration, it cannot be a did, but HTTPS URL\r\nfunction assertIssSelfIssuedOrDid(payload: JWTPayload) {\r\n if (!payload.sub || !payload.sub.startsWith('did:') || !payload.iss || !isIssSelfIssued(payload)) {\r\n throw new Error('Token does not have a iss DID')\r\n }\r\n}\r\n\r\nexport function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): string {\r\n assertIssSelfIssuedOrDid(payload)\r\n\r\n if (isIssSelfIssued(payload)) {\r\n let did\r\n if (payload.sub && payload.sub.startsWith('did:')) {\r\n did = payload.sub\r\n }\r\n if (!did && header && header.kid && header.kid.startsWith('did:')) {\r\n did = header.kid.split('#')[0]\r\n }\r\n if (did) {\r\n return did\r\n }\r\n }\r\n return payload.sub!\r\n}\r\n\r\nexport function isIssSelfIssued(payload: JWTPayload): boolean {\r\n return (\r\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V1)) ||\r\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2)) ||\r\n payload.iss === payload.sub\r\n )\r\n}\r\n\r\nexport function getMethodFromDid(did: string): string {\r\n if (!did) {\r\n throw new Error(SIOPErrors.BAD_PARAMS)\r\n }\r\n const split = did.split(':')\r\n if (split.length == 1 && did.length > 0) {\r\n return did\r\n } else if (!did.startsWith('did:') || split.length < 2) {\r\n throw new Error(SIOPErrors.BAD_PARAMS)\r\n }\r\n\r\n return split[1]\r\n}\r\n\r\n/**\r\n * Since the OIDC SIOP spec incorrectly uses 'did:<method>:' and calls that a method, we have to fix it\r\n * @param didOrMethod\r\n */\r\nexport function toSIOPRegistrationDidMethod(didOrMethod: string) {\r\n let prefix = didOrMethod\r\n if (!didOrMethod.startsWith('did:')) {\r\n prefix = 'did:' + didOrMethod\r\n }\r\n const split = prefix.split(':')\r\n return `${split[0]}:${split[1]}`\r\n}\r\n","import { ExternalSignature, InternalSignature, NoSignature, SuppliedSignature } from './types/SIOP.types'\r\n\r\nexport const isInternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is InternalSignature =>\r\n 'hexPrivateKey' in object && 'did' in object\r\n\r\nexport const isExternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is ExternalSignature =>\r\n 'signatureUri' in object && 'did' in object\r\n\r\nexport const isSuppliedSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is SuppliedSignature =>\r\n 'signature' in object\r\n","import { SubjectIdentifierType, SubjectSyntaxTypesSupportedValues } from '@sphereon/did-auth-siop'\r\nimport { getUniResolver, UniResolver } from '@sphereon/did-uni-client'\r\nimport { DIDResolutionOptions, DIDResolutionResult, ParsedDID, Resolvable, Resolver, ResolverRegistry } from 'did-resolver'\r\n\r\nimport { DIDDocument, ResolveOpts } from '../types'\r\n\r\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from './index'\r\n\r\nexport function getResolver(opts: ResolveOpts): Resolvable {\r\n if (opts && typeof opts.resolver === 'object') {\r\n return opts.resolver\r\n }\r\n if (!opts || !opts.subjectSyntaxTypesSupported) {\r\n if (opts?.noUniversalResolverFallback) {\r\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\r\n }\r\n console.log(\r\n `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`,\r\n )\r\n return new UniResolver()\r\n }\r\n\r\n const uniResolvers: {\r\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\r\n }[] = []\r\n if (opts.subjectSyntaxTypesSupported.indexOf(SubjectIdentifierType.DID) === -1) {\r\n const specificDidMethods = opts.subjectSyntaxTypesSupported.filter((sst) => sst.includes('did:'))\r\n if (!specificDidMethods.length) {\r\n throw new Error('No did method found.')\r\n }\r\n for (const didMethod of specificDidMethods) {\r\n const uniResolver = getUniResolver(getMethodFromDid(didMethod), { resolveUrl: opts.resolveUrl })\r\n uniResolvers.push(uniResolver)\r\n }\r\n return new Resolver(...uniResolvers)\r\n } else {\r\n if (opts?.noUniversalResolverFallback) {\r\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\r\n }\r\n console.log(\r\n `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`,\r\n )\r\n return new UniResolver()\r\n }\r\n}\r\n\r\n/**\r\n * This method returns a resolver object in OP/RP\r\n * If the user of this library, configures OP/RP to have a customResolver, we will use that\r\n * If the user of this library configures OP/RP to use a custom resolver for any specific did method, we will use that\r\n * and in the end for the rest of the did methods, configured either with calling `addDidMethod` upon building OP/RP\r\n * (without any resolver configuration) or declaring in the subject_syntax_types_supported of the registration object\r\n * we will use universal resolver from Sphereon's DID Universal Resolver library\r\n * @param customResolver\r\n * @param subjectSyntaxTypesSupported\r\n * @param resolverMap\r\n */\r\nexport function getResolverUnion(\r\n customResolver: Resolvable,\r\n subjectSyntaxTypesSupported: string[] | string,\r\n resolverMap: Map<string, Resolvable>,\r\n): Resolvable {\r\n if (customResolver) {\r\n return customResolver\r\n }\r\n const fallbackResolver: Resolvable = customResolver ? customResolver : new UniResolver()\r\n const uniResolvers: {\r\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\r\n }[] = []\r\n const subjectTypes: string[] = []\r\n if (subjectSyntaxTypesSupported) {\r\n typeof subjectSyntaxTypesSupported === 'string'\r\n ? subjectTypes.push(subjectSyntaxTypesSupported)\r\n : subjectTypes.push(...subjectSyntaxTypesSupported)\r\n }\r\n if (subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1) {\r\n return customResolver ? customResolver : new UniResolver()\r\n }\r\n const specificDidMethods = subjectTypes.filter((sst) => !!sst && sst.startsWith('did:'))\r\n specificDidMethods.forEach((dm) => {\r\n let methodResolver: ResolverRegistry | Resolvable | undefined\r\n if (!resolverMap.has(dm) || resolverMap.get(dm) === null) {\r\n methodResolver = getUniResolver(getMethodFromDid(dm))\r\n if (methodResolver) {\r\n uniResolvers.push(methodResolver)\r\n }\r\n } else {\r\n methodResolver = resolverMap.get(dm)\r\n if (methodResolver) {\r\n uniResolvers.push({ [dm]: methodResolver.resolve })\r\n }\r\n }\r\n })\r\n return subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1\r\n ? new Resolver(...{ fallbackResolver, ...uniResolvers })\r\n : new Resolver(...uniResolvers)\r\n}\r\n\r\nexport function mergeAllDidMethods(subjectSyntaxTypesSupported: string | string[], resolvers: Map<string, Resolvable>): string[] {\r\n if (!Array.isArray(subjectSyntaxTypesSupported)) {\r\n subjectSyntaxTypesSupported = [subjectSyntaxTypesSupported]\r\n }\r\n const unionSubjectSyntaxTypes = new Set()\r\n subjectSyntaxTypesSupported.forEach((sst) => unionSubjectSyntaxTypes.add(sst))\r\n resolvers.forEach((_, didMethod) => unionSubjectSyntaxTypes.add(toSIOPRegistrationDidMethod(didMethod)))\r\n return Array.from(unionSubjectSyntaxTypes) as string[]\r\n}\r\n\r\nexport async function resolveDidDocument(did: string, opts?: ResolveOpts): Promise<DIDDocument> {\r\n // 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\r\n const result = await getResolver({ ...opts }).resolve(did, { accept: 'application/did+ld+json' })\r\n if (result?.didResolutionMetadata?.error) {\r\n throw Error(result.didResolutionMetadata.error)\r\n }\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n if (!result.didDocument && result.id) {\r\n // todo: This looks like a bug. It seems that sometimes we get back a DID document directly instead of a did resolution results\r\n return result as unknown as DIDDocument\r\n }\r\n return result.didDocument as DIDDocument\r\n}\r\n","import { IDomainLinkageValidation, ValidationStatusEnum, VerifyCallback, WDCErrors, WellKnownDidVerifier } from '@sphereon/wellknown-dids-client'\r\n\r\nimport { DIDDocument } from '../types/SSI.types'\r\n\r\nimport { CheckLinkedDomain, ExternalVerification, InternalVerification } from './../types/'\r\nimport { resolveDidDocument } from './DIDResolution'\r\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from './DidJWT'\r\n\r\nfunction getValidationErrorMessages(validationResult: IDomainLinkageValidation): string[] {\r\n const messages = []\r\n if (validationResult.message) {\r\n messages.push(validationResult.message)\r\n }\r\n if (validationResult?.endpointDescriptors?.length) {\r\n for (const endpointDescriptor of validationResult.endpointDescriptors) {\r\n if (endpointDescriptor.message) {\r\n messages.push(endpointDescriptor.message)\r\n }\r\n if (endpointDescriptor.resources) {\r\n for (const resource of endpointDescriptor.resources) {\r\n if (resource.message) {\r\n messages.push(resource.message)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return messages\r\n}\r\n\r\n/**\r\n * @param validationErrorMessages\r\n * @return returns false if the messages received from wellknown-dids-client makes this invalid for CheckLinkedDomain.IF_PRESENT plus the message itself\r\n * and true for when we can move on\r\n */\r\nfunction checkInvalidMessages(validationErrorMessages: string[]): { status: boolean; message?: string } {\r\n if (!validationErrorMessages || !validationErrorMessages.length) {\r\n return { status: false, message: 'linked domain is invalid.' }\r\n }\r\n const validMessages: string[] = [\r\n WDCErrors.PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS.valueOf(),\r\n WDCErrors.PROPERTY_LINKED_DIDS_NOT_PRESENT.valueOf(),\r\n WDCErrors.PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN.valueOf(),\r\n WDCErrors.PROPERTY_SERVICE_NOT_PRESENT.valueOf(),\r\n ]\r\n for (const validationErrorMessage of validationErrorMessages) {\r\n if (!validMessages.filter((vm) => validationErrorMessage.includes(vm)).pop()) {\r\n return { status: false, message: validationErrorMessage }\r\n }\r\n }\r\n return { status: true }\r\n}\r\n\r\nexport async function validateLinkedDomainWithDid(did: string, verification: InternalVerification | ExternalVerification): Promise<void> {\r\n const { checkLinkedDomain, resolveOpts, wellknownDIDVerifyCallback } = verification\r\n if (checkLinkedDomain === CheckLinkedDomain.NEVER) {\r\n return\r\n }\r\n const didDocument = await resolveDidDocument(did, {\r\n ...resolveOpts,\r\n subjectSyntaxTypesSupported: [toSIOPRegistrationDidMethod(getMethodFromDid(did))],\r\n })\r\n if (!didDocument) {\r\n throw Error(`Could not resolve DID: ${did}`)\r\n }\r\n if ((!didDocument.service || !didDocument.service.find((s) => s.type === 'LinkedDomains')) && checkLinkedDomain === CheckLinkedDomain.IF_PRESENT) {\r\n // No linked domains in DID document and it was optional. Let's cut it short here.\r\n return\r\n }\r\n try {\r\n if (!wellknownDIDVerifyCallback) {\r\n return Promise.reject(Error('wellknownDIDVerifyCallback is required for checkWellKnownDid'))\r\n }\r\n const validationResult = await checkWellKnownDid({ didDocument, verifyCallback: wellknownDIDVerifyCallback })\r\n if (validationResult.status === ValidationStatusEnum.INVALID) {\r\n const validationErrorMessages = getValidationErrorMessages(validationResult)\r\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages(validationErrorMessages)\r\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\r\n throw new Error(messageCondition.message ? messageCondition.message : validationErrorMessages[0])\r\n }\r\n }\r\n } catch (err: any) {\r\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages([err.message])\r\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\r\n throw new Error(err.message)\r\n }\r\n }\r\n}\r\n\r\ninterface CheckWellKnownDidArgs {\r\n didDocument: DIDDocument\r\n verifyCallback: VerifyCallback\r\n}\r\n\r\nasync function checkWellKnownDid(args: CheckWellKnownDidArgs): Promise<IDomainLinkageValidation> {\r\n const verifier = new WellKnownDidVerifier({\r\n verifySignatureCallback: args.verifyCallback,\r\n onlyVerifyServiceDid: false,\r\n })\r\n return await verifier.verifyDomainLinkage({ didDocument: args.didDocument })\r\n}\r\n","import { SigningAlgo } from '@sphereon/oid4vc-common'\r\nimport { VerifyCallback as WellknownDIDVerifyCallback } from '@sphereon/wellknown-dids-client'\r\nimport { JWTVerifyOptions } from 'did-jwt'\r\nimport { Resolvable } from 'did-resolver'\r\n\r\nexport enum CheckLinkedDomain {\r\n NEVER = 'never', // We don't want to verify Linked domains\r\n IF_PRESENT = 'if_present', // If present, did-auth-siop will check the linked domain, if exist and not valid, throws an exception\r\n ALWAYS = 'always', // We'll always check the linked domains, if not exist or not valid, throws an exception\r\n}\r\n\r\nexport interface InternalSignature {\r\n hexPrivateKey: string // hex private key Only secp256k1 format\r\n did: string\r\n\r\n alg: SigningAlgo\r\n kid?: string // Optional: key identifier\r\n\r\n customJwtSigner?: Signer\r\n}\r\n\r\nexport interface SuppliedSignature {\r\n signature: (data: string | Uint8Array) => Promise<EcdsaSignature | string>\r\n\r\n alg: SigningAlgo\r\n did: string\r\n kid: string\r\n}\r\n\r\nexport interface NoSignature {\r\n hexPublicKey: string // hex public key\r\n did: string\r\n kid?: string // Optional: key identifier\r\n}\r\n\r\nexport interface ExternalSignature {\r\n signatureUri: string // url to call to generate a withSignature\r\n did: string\r\n authZToken: string // Optional: bearer token to use to the call\r\n hexPublicKey?: string // Optional: hex encoded public key to compute JWK key, if not possible from DIDres Document\r\n\r\n alg: SigningAlgo\r\n kid?: string // Optional: key identifier. default did#keys-1\r\n}\r\n\r\nexport enum VerificationMode {\r\n INTERNAL,\r\n EXTERNAL,\r\n}\r\n\r\nexport interface EcdsaSignature {\r\n r: string\r\n s: string\r\n recoveryParam?: number | null\r\n}\r\nexport type Signer = (data: string | Uint8Array) => Promise<EcdsaSignature | string>\r\n\r\nexport interface Verification {\r\n checkLinkedDomain?: CheckLinkedDomain\r\n wellknownDIDVerifyCallback?: WellknownDIDVerifyCallback\r\n resolveOpts: ResolveOpts\r\n}\r\n\r\nexport type InternalVerification = Verification\r\n\r\nexport interface ExternalVerification extends Verification {\r\n verifyUri: string // url to call to verify the id_token withSignature\r\n authZToken?: string // Optional: bearer token to use to the call\r\n}\r\n\r\nexport interface ResolveOpts {\r\n jwtVerifyOpts?: JWTVerifyOptions\r\n resolver?: Resolvable\r\n resolveUrl?: string\r\n noUniversalResolverFallback?: boolean\r\n subjectSyntaxTypesSupported?: string[]\r\n}\r\n","import { AuthorizationRequestPayload, IDTokenPayload, JwtIssuerWithContext, JwtVerifier, RequestObjectPayload } from '@sphereon/did-auth-siop'\r\nimport { JwtHeader, JwtPayload } from '@sphereon/oid4vc-common'\r\nimport { Resolvable } from 'did-resolver'\r\n\r\nimport { getAudience, getSubDidFromPayload, signIDTokenPayload, signRequestObjectPayload, validateLinkedDomainWithDid, verifyDidJWT } from './did'\r\nimport { CheckLinkedDomain, ExternalSignature, ExternalVerification, InternalSignature, InternalVerification, SuppliedSignature } from './types'\r\n\r\nexport const verfiyDidJwtAdapter = async (\r\n jwtVerifier: JwtVerifier,\r\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\r\n options: {\r\n verification: InternalVerification | ExternalVerification\r\n resolver: Resolvable\r\n },\r\n): Promise<boolean> => {\r\n if (jwtVerifier.method === 'did') {\r\n const audience = options?.verification?.resolveOpts?.jwtVerifyOpts?.audience ?? getAudience(jwt.raw)\r\n\r\n await verifyDidJWT(jwt.raw, options.resolver, { ...options.verification?.resolveOpts?.jwtVerifyOpts, audience })\r\n\r\n if (jwtVerifier.type === 'request-object' && (jwt.payload as JwtPayload & { client_id?: string }).client_id?.startsWith('did:')) {\r\n const authorizationRequestPayload = jwt.payload as AuthorizationRequestPayload\r\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\r\n if (!authorizationRequestPayload.client_id) {\r\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\r\n }\r\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\r\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\r\n if (!authorizationRequestPayload.client_id) {\r\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\r\n }\r\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\r\n }\r\n }\r\n\r\n if (jwtVerifier.type === 'id-token') {\r\n const issuerDid = getSubDidFromPayload(jwt.payload)\r\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\r\n await validateLinkedDomainWithDid(issuerDid, options.verification)\r\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\r\n await validateLinkedDomainWithDid(issuerDid, options.verification)\r\n }\r\n }\r\n\r\n return true\r\n }\r\n\r\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\r\n}\r\n\r\nexport const createDidJwtAdapter = async (\r\n signature: InternalSignature | ExternalSignature | SuppliedSignature,\r\n jwtIssuer: JwtIssuerWithContext,\r\n jwt: { header: JwtHeader; payload: JwtPayload },\r\n): Promise<string> => {\r\n if (jwtIssuer.method === 'did') {\r\n const issuer = jwtIssuer.didUrl.split('#')[0]\r\n jwt.payload.issuer = issuer\r\n if (jwtIssuer.type === 'request-object') {\r\n return await signRequestObjectPayload(jwt.payload as RequestObjectPayload, signature)\r\n } else if (jwtIssuer.type === 'id-token') {\r\n return await signIDTokenPayload(jwt.payload as IDTokenPayload, signature)\r\n }\r\n }\r\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\r\n}\r\n"],"mappings":";;;;AAAA,SACEA,yBAEAC,MAEAC,aAEAC,kBAGK;AACP,SAASC,mBAAmB;AAC5B,SACEC,WACAC,WACAC,aACAC,cACAC,aACAC,YAMAC,iBACK;;;ACvBA,IAAMC,sBAAsB,wBAACC,WAClC,mBAAmBA,UAAU,SAASA,QADL;AAG5B,IAAMC,sBAAsB,wBAACD,WAClC,kBAAkBA,UAAU,SAASA,QADJ;AAG5B,IAAME,sBAAsB,wBAACF,WAClC,eAAeA,QADkB;;;AD4CnC,eAA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C9B;AACA,cAAMC,4BAA4BP,4BAA4BF,WAAWZ,QAAQG,YAAY;MAC/F,WAAW,CAACH,QAAQG,cAAcY,qBAAqBf,QAAQG,aAAamB,4BAA4B;AACtG,YAAI,CAACR,4BAA4BF,WAAW;AAC1C,iBAAOM,QAAQC,OAAOC,MAAM,oDAAA,CAAA;QAC9B;AACA,cAAMC,4BAA4BP,4BAA4BF,WAAWZ,QAAQG,YAAY;MAC/F;IACF;AAEA,QAAIL,YAAYY,SAAS,YAAY;AACnC,YAAMa,YAAYC,qBAAqBzB,IAAIY,OAAO;AAClD,UAAIX,QAAQG,cAAcY,qBAAqBf,QAAQG,aAAaY,qBAAqBC,kBAAkBC,OAAO;AAChH,cAAMI,4BAA4BE,WAAWvB,QAAQG,YAAY;MACnE,WAAW,CAACH,QAAQG,cAAcY,qBAAqBf,QAAQG,aAAamB,4BAA4B;AACtG,cAAMD,4BAA4BE,WAAWvB,QAAQG,YAAY;MACnE;IACF;AAEA,WAAO;EACT;AAEA,QAAM,IAAIiB,MAAM,qDAAA;AAClB,GAzCmC;AA2C5B,IAAMK,sBAAsB,8BACjCC,WACAC,WACA5B,QAAAA;AAEA,MAAI4B,UAAU1B,WAAW,OAAO;AAC9B,UAAM2B,SAASD,UAAUE,OAAOC,MAAM,GAAA,EAAK,CAAA;AAC3C/B,QAAIY,QAAQiB,SAASA;AACrB,QAAID,UAAUjB,SAAS,kBAAkB;AACvC,aAAO,MAAMqB,yBAAyBhC,IAAIY,SAAiCe,SAAAA;IAC7E,WAAWC,UAAUjB,SAAS,YAAY;AACxC,aAAO,MAAMsB,mBAAmBjC,IAAIY,SAA2Be,SAAAA;IACjE;EACF;AACA,QAAM,IAAIN,MAAM,qDAAA;AAClB,GAfmC;","names":["DEFAULT_EXPIRATION_TIME","post","ResponseIss","SIOPErrors","SigningAlgo","createJWT","decodeJWT","EdDSASigner","ES256KSigner","ES256Signer","hexToBytes","verifyJWT","isInternalSignature","object","isExternalSignature","isSuppliedSignature","verifyDidJWT","jwt","resolver","options","verifyJWT","createDidJWT","payload","issuer","signer","expiresIn","canonicalize","header","createJWT","signIDTokenPayload","signature","isInternalSignature","kid","Promise","reject","Error","signDidJwtInternal","hexPrivateKey","alg","customJwtSigner","isExternalSignature","signDidJwtExternal","signatureUri","authZToken","isSuppliedSignature","signDidJwtSupplied","signRequestObjectPayload","iss","did","sub","determineSigner","DEFAULT_EXPIRATION_TIME","body","includes","selfIssued","ResponseIss","SELF_ISSUED_V2","undefined","response","post","JSON","stringify","bearerToken","successBody","jws","customSigner","privateKey","hexToBytes","replace","SigningAlgo","EDDSA","EdDSASigner","ES256","ES256Signer","ES256K","ES256KSigner","PS256","RS256","getAudience","decodeJWT","SIOPErrors","NO_AUDIENCE","aud","Array","isArray","INVALID_AUDIENCE","assertIssSelfIssuedOrDid","startsWith","isIssSelfIssued","getSubDidFromPayload","split","SELF_ISSUED_V1","getMethodFromDid","BAD_PARAMS","length","toSIOPRegistrationDidMethod","didOrMethod","prefix","SubjectIdentifierType","SubjectSyntaxTypesSupportedValues","getUniResolver","UniResolver","Resolver","getResolver","opts","resolver","subjectSyntaxTypesSupported","noUniversalResolverFallback","Error","console","log","UniResolver","uniResolvers","indexOf","SubjectIdentifierType","DID","specificDidMethods","filter","sst","includes","length","didMethod","uniResolver","getUniResolver","getMethodFromDid","resolveUrl","push","Resolver","getResolverUnion","customResolver","resolverMap","fallbackResolver","subjectTypes","SubjectSyntaxTypesSupportedValues","valueOf","startsWith","forEach","dm","methodResolver","has","get","resolve","mergeAllDidMethods","resolvers","Array","isArray","unionSubjectSyntaxTypes","Set","add","_","toSIOPRegistrationDidMethod","from","resolveDidDocument","did","result","accept","didResolutionMetadata","error","didDocument","id","ValidationStatusEnum","WDCErrors","WellKnownDidVerifier","CheckLinkedDomain","VerificationMode","getValidationErrorMessages","validationResult","messages","message","push","endpointDescriptors","length","endpointDescriptor","resources","resource","checkInvalidMessages","validationErrorMessages","status","validMessages","WDCErrors","PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS","valueOf","PROPERTY_LINKED_DIDS_NOT_PRESENT","PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN","PROPERTY_SERVICE_NOT_PRESENT","validationErrorMessage","filter","vm","includes","pop","validateLinkedDomainWithDid","did","verification","checkLinkedDomain","resolveOpts","wellknownDIDVerifyCallback","CheckLinkedDomain","NEVER","didDocument","resolveDidDocument","subjectSyntaxTypesSupported","toSIOPRegistrationDidMethod","getMethodFromDid","Error","service","find","s","type","IF_PRESENT","Promise","reject","checkWellKnownDid","verifyCallback","ValidationStatusEnum","INVALID","messageCondition","ALWAYS","err","args","verifier","WellKnownDidVerifier","verifySignatureCallback","onlyVerifyServiceDid","verifyDomainLinkage","verfiyDidJwtAdapter","jwtVerifier","jwt","options","method","audience","verification","resolveOpts","jwtVerifyOpts","getAudience","raw","verifyDidJWT","resolver","type","payload","client_id","startsWith","authorizationRequestPayload","checkLinkedDomain","CheckLinkedDomain","NEVER","Promise","reject","Error","validateLinkedDomainWithDid","wellknownDIDVerifyCallback","issuerDid","getSubDidFromPayload","createDidJwtAdapter","signature","jwtIssuer","issuer","didUrl","split","signRequestObjectPayload","signIDTokenPayload"]}
|
|
1
|
+
{"version":3,"sources":["../lib/did/DidJWT.ts","../lib/helpers.ts","../lib/did/DIDResolution.ts","../lib/did/LinkedDomainValidations.ts","../lib/types/SIOP.types.ts","../lib/DidJwtAdapter.ts"],"sourcesContent":["import {\n DEFAULT_EXPIRATION_TIME,\n IDTokenPayload,\n post,\n RequestObjectPayload,\n ResponseIss,\n SignatureResponse,\n SIOPErrors,\n SIOPResonse,\n VerifiedJWT,\n} from '@sphereon/did-auth-siop'\nimport { SigningAlgo } from '@sphereon/oid4vc-common'\nimport {\n createJWT,\n decodeJWT,\n EdDSASigner,\n ES256KSigner,\n ES256Signer,\n hexToBytes,\n JWTHeader,\n JWTOptions,\n JWTPayload,\n JWTVerifyOptions,\n Signer,\n verifyJWT,\n} from 'did-jwt'\nimport { Resolvable } from 'did-resolver'\n\nimport { isExternalSignature, isInternalSignature, isSuppliedSignature } from '../helpers'\nimport { ExternalSignature, InternalSignature, SuppliedSignature } from '../types'\n\n/**\n * Verifies given JWT. If the JWT is valid, the promise returns an object including the JWT, the payload of the JWT,\n * and the did doc of the issuer of the JWT.\n *\n * @example\n * verifyDidJWT('did:key:example', resolver, {audience: '5A8bRWU3F7j3REx3vkJ...', callbackUrl: 'https://...'}).then(obj => {\n * const did = obj.did // DIDres of signer\n * const payload = obj.payload\n * const doc = obj.doc // DIDres Document of signer\n * const JWT = obj.JWT // JWT\n * const signerKeyId = obj.signerKeyId // ID of key in DIDres document that signed JWT\n * ...\n * })\n *\n * @param {String} jwt a JSON Web Token to verify\n * @param {Resolvable} resolver\n * @param {JWTVerifyOptions} [options] Options\n * @param {String} options.audience DID of the recipient of the JWT\n * @param {String} options.callbackUrl callback url in JWT\n * @return {Promise<Object, Error>} a promise which resolves with a response object or rejects with an error\n */\nexport async function verifyDidJWT(jwt: string, resolver: Resolvable, options: JWTVerifyOptions): Promise<VerifiedJWT> {\n return verifyJWT(jwt, { ...options, resolver })\n}\n\n/**\n * Creates a signed JWT given an address which becomes the issuer, a signer function, and a payload for which the withSignature is over.\n *\n * @example\n * const signer = ES256KSigner(process.env.PRIVATE_KEY)\n * createJWT({address: '5A8bRWU3F7j3REx3vkJ...', signer}, {key1: 'value', key2: ..., ... }).then(JWT => {\n * ...\n * })\n *\n * @param {Object} payload payload object\n * @param {Object} [options] an unsigned credential object\n * @param {String} options.issuer The DID of the issuer (signer) of JWT\n * @param {Signer} options.signer a `Signer` function, Please see `ES256KSigner` or `EdDSASigner`\n * @param {boolean} options.canonicalize optional flag to canonicalize header and payload before signing\n * @param {Object} header optional object to specify or customize the JWT header\n * @return {Promise<Object, Error>} a promise which resolves with a signed JSON Web Token or rejects with an error\n */\nexport async function createDidJWT(\n payload: Partial<JWTPayload>,\n { issuer, signer, expiresIn, canonicalize }: JWTOptions,\n header: Partial<JWTHeader>,\n): Promise<string> {\n return createJWT(payload, { issuer, signer, expiresIn, canonicalize }, header)\n}\n\nexport async function signIDTokenPayload(payload: IDTokenPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\n if (isInternalSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtInternal(payload, payload.issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\n } else if (isExternalSignature(signature)) {\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\n } else if (isSuppliedSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtSupplied(payload, payload.issuer, signature.signature, signature.alg, signature.kid)\n } else {\n throw new Error(\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\n )\n }\n}\n\nexport async function signRequestObjectPayload(payload: RequestObjectPayload, signature: InternalSignature | ExternalSignature | SuppliedSignature) {\n let issuer = payload.iss\n if (!issuer) {\n issuer = signature.did\n }\n if (!issuer) {\n throw Error('No issuer supplied to sign the JWT')\n }\n if (!payload.iss) {\n payload.iss = issuer\n }\n if (!payload.sub) {\n payload.sub = signature.did\n }\n if (isInternalSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtInternal(payload, issuer, signature.hexPrivateKey, signature.alg, signature.kid, signature.customJwtSigner)\n } else if (isExternalSignature(signature)) {\n return signDidJwtExternal(payload, signature.signatureUri, signature.authZToken, signature.alg, signature.kid)\n } else if (isSuppliedSignature(signature)) {\n if (!signature.kid) {\n return Promise.reject(Error('missing kid from signature'))\n }\n return signDidJwtSupplied(payload, issuer, signature.signature, signature.alg, signature.kid)\n } else {\n throw new Error(\n 'Signature parameters should be internal signature with hexPrivateKey, did, and an optional kid, or external signature parameters with signatureUri, did, and optionals parameters authZToken, hexPublicKey, and kid',\n )\n }\n}\n\nexport async function signDidJwtInternal(\n payload: IDTokenPayload | RequestObjectPayload,\n issuer: string,\n hexPrivateKey: string,\n alg: SigningAlgo,\n kid: string,\n customJwtSigner?: Signer,\n): Promise<string> {\n const signer = determineSigner(alg, hexPrivateKey, customJwtSigner)\n const header = {\n alg,\n kid,\n }\n const options = {\n issuer,\n signer,\n expiresIn: DEFAULT_EXPIRATION_TIME,\n }\n\n return await createDidJWT({ ...payload }, options, header)\n}\n\nasync function signDidJwtExternal(\n payload: IDTokenPayload | RequestObjectPayload,\n signatureUri: string,\n authZToken: string,\n alg: SigningAlgo,\n kid?: string,\n): Promise<string> {\n const body = {\n issuer: payload.iss && payload.iss.includes('did:') ? payload.iss : payload.sub,\n payload,\n expiresIn: DEFAULT_EXPIRATION_TIME,\n alg,\n selfIssued: payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2) ? payload.iss : undefined,\n kid,\n }\n\n const response: SIOPResonse<SignatureResponse> = await post(signatureUri, JSON.stringify(body), { bearerToken: authZToken })\n if (!response.successBody) {\n return Promise.reject(Error('the siop SignatureResponse does not have a successBody'))\n }\n return response.successBody.jws\n}\n\nasync function signDidJwtSupplied(\n payload: IDTokenPayload | RequestObjectPayload,\n issuer: string,\n signer: Signer,\n alg: SigningAlgo,\n kid: string,\n): Promise<string> {\n const header = {\n alg,\n kid,\n }\n const options = {\n issuer,\n signer,\n expiresIn: DEFAULT_EXPIRATION_TIME,\n }\n\n return await createDidJWT({ ...payload }, options, header)\n}\n\nconst determineSigner = (alg: SigningAlgo, hexPrivateKey?: string, customSigner?: Signer): Signer => {\n if (customSigner) {\n return customSigner\n } else if (!hexPrivateKey) {\n throw new Error('no private key provided')\n }\n const privateKey = hexToBytes(hexPrivateKey.replace('0x', ''))\n switch (alg) {\n case SigningAlgo.EDDSA:\n return EdDSASigner(privateKey)\n case SigningAlgo.ES256:\n return ES256Signer(privateKey)\n case SigningAlgo.ES256K:\n return ES256KSigner(privateKey)\n case SigningAlgo.PS256:\n throw Error('PS256 is not supported yet. Please provide a custom signer')\n case SigningAlgo.RS256:\n throw Error('RS256 is not supported yet. Please provide a custom signer')\n }\n}\n\nexport function getAudience(jwt: string) {\n const { payload } = decodeJWT(jwt)\n if (!payload) {\n throw new Error(SIOPErrors.NO_AUDIENCE)\n } else if (!payload.aud) {\n return undefined\n } else if (Array.isArray(payload.aud)) {\n throw new Error(SIOPErrors.INVALID_AUDIENCE)\n }\n\n return payload.aud\n}\n\n//TODO To enable automatic registration, it cannot be a did, but HTTPS URL\nfunction assertIssSelfIssuedOrDid(payload: JWTPayload) {\n if (!payload.sub || !payload.sub.startsWith('did:') || !payload.iss || !isIssSelfIssued(payload)) {\n throw new Error('Token does not have a iss DID')\n }\n}\n\nexport function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): string {\n assertIssSelfIssuedOrDid(payload)\n\n if (isIssSelfIssued(payload)) {\n let did\n if (payload.sub && payload.sub.startsWith('did:')) {\n did = payload.sub\n }\n if (!did && header && header.kid && header.kid.startsWith('did:')) {\n did = header.kid.split('#')[0]\n }\n if (did) {\n return did\n }\n }\n return payload.sub!\n}\n\nexport function isIssSelfIssued(payload: JWTPayload): boolean {\n return (\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V1)) ||\n (payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V2)) ||\n payload.iss === payload.sub\n )\n}\n\nexport function getMethodFromDid(did: string): string {\n if (!did) {\n throw new Error(SIOPErrors.BAD_PARAMS)\n }\n const split = did.split(':')\n if (split.length == 1 && did.length > 0) {\n return did\n } else if (!did.startsWith('did:') || split.length < 2) {\n throw new Error(SIOPErrors.BAD_PARAMS)\n }\n\n return split[1]\n}\n\n/**\n * Since the OIDC SIOP spec incorrectly uses 'did:<method>:' and calls that a method, we have to fix it\n * @param didOrMethod\n */\nexport function toSIOPRegistrationDidMethod(didOrMethod: string) {\n let prefix = didOrMethod\n if (!didOrMethod.startsWith('did:')) {\n prefix = 'did:' + didOrMethod\n }\n const split = prefix.split(':')\n return `${split[0]}:${split[1]}`\n}\n","import { ExternalSignature, InternalSignature, NoSignature, SuppliedSignature } from './types/SIOP.types'\n\nexport const isInternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is InternalSignature =>\n 'hexPrivateKey' in object && 'did' in object\n\nexport const isExternalSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is ExternalSignature =>\n 'signatureUri' in object && 'did' in object\n\nexport const isSuppliedSignature = (object: InternalSignature | ExternalSignature | SuppliedSignature | NoSignature): object is SuppliedSignature =>\n 'signature' in object\n","import { SubjectIdentifierType, SubjectSyntaxTypesSupportedValues } from '@sphereon/did-auth-siop'\nimport { getUniResolver, UniResolver } from '@sphereon/did-uni-client'\nimport { DIDResolutionOptions, DIDResolutionResult, ParsedDID, Resolvable, Resolver, ResolverRegistry } from 'did-resolver'\n\nimport { DIDDocument, ResolveOpts } from '../types'\n\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from '.'\n\nexport function getResolver(opts: ResolveOpts): Resolvable {\n if (opts && typeof opts.resolver === 'object') {\n return opts.resolver\n }\n if (!opts || !opts.subjectSyntaxTypesSupported) {\n if (opts?.noUniversalResolverFallback) {\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\n }\n console.log(\n `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`,\n )\n return new UniResolver()\n }\n\n const uniResolvers: {\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\n }[] = []\n if (opts.subjectSyntaxTypesSupported.indexOf(SubjectIdentifierType.DID) === -1) {\n const specificDidMethods = opts.subjectSyntaxTypesSupported.filter((sst) => sst.includes('did:'))\n if (!specificDidMethods.length) {\n throw new Error('No did method found.')\n }\n for (const didMethod of specificDidMethods) {\n const uniResolver = getUniResolver(getMethodFromDid(didMethod), { resolveUrl: opts.resolveUrl })\n uniResolvers.push(uniResolver)\n }\n return new Resolver(...uniResolvers)\n } else {\n if (opts?.noUniversalResolverFallback) {\n throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`)\n }\n console.log(\n `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`,\n )\n return new UniResolver()\n }\n}\n\n/**\n * This method returns a resolver object in OP/RP\n * If the user of this library, configures OP/RP to have a customResolver, we will use that\n * If the user of this library configures OP/RP to use a custom resolver for any specific did method, we will use that\n * and in the end for the rest of the did methods, configured either with calling `addDidMethod` upon building OP/RP\n * (without any resolver configuration) or declaring in the subject_syntax_types_supported of the registration object\n * we will use universal resolver from Sphereon's DID Universal Resolver library\n * @param customResolver\n * @param subjectSyntaxTypesSupported\n * @param resolverMap\n */\nexport function getResolverUnion(\n customResolver: Resolvable,\n subjectSyntaxTypesSupported: string[] | string,\n resolverMap: Map<string, Resolvable>,\n): Resolvable {\n if (customResolver) {\n return customResolver\n }\n const fallbackResolver: Resolvable = customResolver ? customResolver : new UniResolver()\n const uniResolvers: {\n [p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>\n }[] = []\n const subjectTypes: string[] = []\n if (subjectSyntaxTypesSupported) {\n typeof subjectSyntaxTypesSupported === 'string'\n ? subjectTypes.push(subjectSyntaxTypesSupported)\n : subjectTypes.push(...subjectSyntaxTypesSupported)\n }\n if (subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1) {\n return customResolver ? customResolver : new UniResolver()\n }\n const specificDidMethods = subjectTypes.filter((sst) => !!sst && sst.startsWith('did:'))\n specificDidMethods.forEach((dm) => {\n let methodResolver: ResolverRegistry | Resolvable | undefined\n if (!resolverMap.has(dm) || resolverMap.get(dm) === null) {\n methodResolver = getUniResolver(getMethodFromDid(dm))\n if (methodResolver) {\n uniResolvers.push(methodResolver)\n }\n } else {\n methodResolver = resolverMap.get(dm)\n if (methodResolver) {\n uniResolvers.push({ [dm]: methodResolver.resolve })\n }\n }\n })\n return subjectTypes.indexOf(SubjectSyntaxTypesSupportedValues.DID.valueOf()) !== -1\n ? new Resolver(...{ fallbackResolver, ...uniResolvers })\n : new Resolver(...uniResolvers)\n}\n\nexport function mergeAllDidMethods(subjectSyntaxTypesSupported: string | string[], resolvers: Map<string, Resolvable>): string[] {\n if (!Array.isArray(subjectSyntaxTypesSupported)) {\n subjectSyntaxTypesSupported = [subjectSyntaxTypesSupported]\n }\n const unionSubjectSyntaxTypes = new Set()\n subjectSyntaxTypesSupported.forEach((sst) => unionSubjectSyntaxTypes.add(sst))\n resolvers.forEach((_, didMethod) => unionSubjectSyntaxTypes.add(toSIOPRegistrationDidMethod(didMethod)))\n return Array.from(unionSubjectSyntaxTypes) as string[]\n}\n\nexport async function resolveDidDocument(did: string, opts?: ResolveOpts): Promise<DIDDocument> {\n // 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\n const result = await getResolver({ ...opts }).resolve(did, { accept: 'application/did+ld+json' })\n if (result?.didResolutionMetadata?.error) {\n throw Error(result.didResolutionMetadata.error)\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!result.didDocument && result.id) {\n // todo: This looks like a bug. It seems that sometimes we get back a DID document directly instead of a did resolution results\n return result as unknown as DIDDocument\n }\n return result.didDocument as DIDDocument\n}\n","import { IDomainLinkageValidation, ValidationStatusEnum, VerifyCallback, WDCErrors, WellKnownDidVerifier } from '@sphereon/wellknown-dids-client'\n\nimport { DIDDocument } from '../types/SSI.types'\n\nimport { CheckLinkedDomain, ExternalVerification, InternalVerification } from './../types/'\nimport { resolveDidDocument } from './DIDResolution'\nimport { getMethodFromDid, toSIOPRegistrationDidMethod } from './DidJWT'\n\nfunction getValidationErrorMessages(validationResult: IDomainLinkageValidation): string[] {\n const messages = []\n if (validationResult.message) {\n messages.push(validationResult.message)\n }\n if (validationResult?.endpointDescriptors?.length) {\n for (const endpointDescriptor of validationResult.endpointDescriptors) {\n if (endpointDescriptor.message) {\n messages.push(endpointDescriptor.message)\n }\n if (endpointDescriptor.resources) {\n for (const resource of endpointDescriptor.resources) {\n if (resource.message) {\n messages.push(resource.message)\n }\n }\n }\n }\n }\n return messages\n}\n\n/**\n * @param validationErrorMessages\n * @return returns false if the messages received from wellknown-dids-client makes this invalid for CheckLinkedDomain.IF_PRESENT plus the message itself\n * and true for when we can move on\n */\nfunction checkInvalidMessages(validationErrorMessages: string[]): { status: boolean; message?: string } {\n if (!validationErrorMessages || !validationErrorMessages.length) {\n return { status: false, message: 'linked domain is invalid.' }\n }\n const validMessages: string[] = [\n WDCErrors.PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS.valueOf(),\n WDCErrors.PROPERTY_LINKED_DIDS_NOT_PRESENT.valueOf(),\n WDCErrors.PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN.valueOf(),\n WDCErrors.PROPERTY_SERVICE_NOT_PRESENT.valueOf(),\n ]\n for (const validationErrorMessage of validationErrorMessages) {\n if (!validMessages.filter((vm) => validationErrorMessage.includes(vm)).pop()) {\n return { status: false, message: validationErrorMessage }\n }\n }\n return { status: true }\n}\n\nexport async function validateLinkedDomainWithDid(did: string, verification: InternalVerification | ExternalVerification): Promise<void> {\n const { checkLinkedDomain, resolveOpts, wellknownDIDVerifyCallback } = verification\n if (checkLinkedDomain === CheckLinkedDomain.NEVER) {\n return\n }\n const didDocument = await resolveDidDocument(did, {\n ...resolveOpts,\n subjectSyntaxTypesSupported: [toSIOPRegistrationDidMethod(getMethodFromDid(did))],\n })\n if (!didDocument) {\n throw Error(`Could not resolve DID: ${did}`)\n }\n if ((!didDocument.service || !didDocument.service.find((s) => s.type === 'LinkedDomains')) && checkLinkedDomain === CheckLinkedDomain.IF_PRESENT) {\n // No linked domains in DID document and it was optional. Let's cut it short here.\n return\n }\n try {\n if (!wellknownDIDVerifyCallback) {\n return Promise.reject(Error('wellknownDIDVerifyCallback is required for checkWellKnownDid'))\n }\n const validationResult = await checkWellKnownDid({ didDocument, verifyCallback: wellknownDIDVerifyCallback })\n if (validationResult.status === ValidationStatusEnum.INVALID) {\n const validationErrorMessages = getValidationErrorMessages(validationResult)\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages(validationErrorMessages)\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\n throw new Error(messageCondition.message ? messageCondition.message : validationErrorMessages[0])\n }\n }\n } catch (err: any) {\n const messageCondition: { status: boolean; message?: string } = checkInvalidMessages([err.message])\n if (checkLinkedDomain === CheckLinkedDomain.ALWAYS || (checkLinkedDomain === CheckLinkedDomain.IF_PRESENT && !messageCondition.status)) {\n throw new Error(err.message)\n }\n }\n}\n\ninterface CheckWellKnownDidArgs {\n didDocument: DIDDocument\n verifyCallback: VerifyCallback\n}\n\nasync function checkWellKnownDid(args: CheckWellKnownDidArgs): Promise<IDomainLinkageValidation> {\n const verifier = new WellKnownDidVerifier({\n verifySignatureCallback: args.verifyCallback,\n onlyVerifyServiceDid: false,\n })\n return await verifier.verifyDomainLinkage({ didDocument: args.didDocument })\n}\n","import { SigningAlgo } from '@sphereon/oid4vc-common'\nimport { VerifyCallback as WellknownDIDVerifyCallback } from '@sphereon/wellknown-dids-client'\nimport { JWTVerifyOptions } from 'did-jwt'\nimport { Resolvable } from 'did-resolver'\n\nexport enum CheckLinkedDomain {\n NEVER = 'never', // We don't want to verify Linked domains\n IF_PRESENT = 'if_present', // If present, did-auth-siop will check the linked domain, if exist and not valid, throws an exception\n ALWAYS = 'always', // We'll always check the linked domains, if not exist or not valid, throws an exception\n}\n\nexport interface InternalSignature {\n hexPrivateKey: string // hex private key Only secp256k1 format\n did: string\n\n alg: SigningAlgo\n kid?: string // Optional: key identifier\n\n customJwtSigner?: Signer\n}\n\nexport interface SuppliedSignature {\n signature: (data: string | Uint8Array) => Promise<EcdsaSignature | string>\n\n alg: SigningAlgo\n did: string\n kid: string\n}\n\nexport interface NoSignature {\n hexPublicKey: string // hex public key\n did: string\n kid?: string // Optional: key identifier\n}\n\nexport interface ExternalSignature {\n signatureUri: string // url to call to generate a withSignature\n did: string\n authZToken: string // Optional: bearer token to use to the call\n hexPublicKey?: string // Optional: hex encoded public key to compute JWK key, if not possible from DIDres Document\n\n alg: SigningAlgo\n kid?: string // Optional: key identifier. default did#keys-1\n}\n\nexport enum VerificationMode {\n INTERNAL,\n EXTERNAL,\n}\n\nexport interface EcdsaSignature {\n r: string\n s: string\n recoveryParam?: number | null\n}\nexport type Signer = (data: string | Uint8Array) => Promise<EcdsaSignature | string>\n\nexport interface Verification {\n checkLinkedDomain?: CheckLinkedDomain\n wellknownDIDVerifyCallback?: WellknownDIDVerifyCallback\n resolveOpts: ResolveOpts\n}\n\nexport type InternalVerification = Verification\n\nexport interface ExternalVerification extends Verification {\n verifyUri: string // url to call to verify the id_token withSignature\n authZToken?: string // Optional: bearer token to use to the call\n}\n\nexport interface ResolveOpts {\n jwtVerifyOpts?: JWTVerifyOptions\n resolver?: Resolvable\n resolveUrl?: string\n noUniversalResolverFallback?: boolean\n subjectSyntaxTypesSupported?: string[]\n}\n","import { AuthorizationRequestPayload, IDTokenPayload, JwtIssuerWithContext, JwtVerifier, RequestObjectPayload } from '@sphereon/did-auth-siop'\nimport { JwtHeader, JwtPayload } from '@sphereon/oid4vc-common'\nimport { Resolvable } from 'did-resolver'\n\nimport { getAudience, getSubDidFromPayload, signIDTokenPayload, signRequestObjectPayload, validateLinkedDomainWithDid, verifyDidJWT } from './did'\nimport { CheckLinkedDomain, ExternalSignature, ExternalVerification, InternalSignature, InternalVerification, SuppliedSignature } from './types'\n\nexport const verfiyDidJwtAdapter = async (\n jwtVerifier: JwtVerifier,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n options: {\n verification: InternalVerification | ExternalVerification\n resolver: Resolvable\n },\n): Promise<boolean> => {\n if (jwtVerifier.method === 'did') {\n const audience = options?.verification?.resolveOpts?.jwtVerifyOpts?.audience ?? getAudience(jwt.raw)\n\n await verifyDidJWT(jwt.raw, options.resolver, { ...options.verification?.resolveOpts?.jwtVerifyOpts, audience })\n\n if (jwtVerifier.type === 'request-object' && (jwt.payload as JwtPayload & { client_id?: string }).client_id?.startsWith('did:')) {\n const authorizationRequestPayload = jwt.payload as AuthorizationRequestPayload\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\n if (!authorizationRequestPayload.client_id) {\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\n }\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\n if (!authorizationRequestPayload.client_id) {\n return Promise.reject(Error('missing client_id from AuthorizationRequestPayload'))\n }\n await validateLinkedDomainWithDid(authorizationRequestPayload.client_id, options.verification)\n }\n }\n\n if (jwtVerifier.type === 'id-token') {\n const issuerDid = getSubDidFromPayload(jwt.payload)\n if (options.verification?.checkLinkedDomain && options.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {\n await validateLinkedDomainWithDid(issuerDid, options.verification)\n } else if (!options.verification?.checkLinkedDomain && options.verification.wellknownDIDVerifyCallback) {\n await validateLinkedDomainWithDid(issuerDid, options.verification)\n }\n }\n\n return true\n }\n\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\n}\n\nexport const createDidJwtAdapter = async (\n signature: InternalSignature | ExternalSignature | SuppliedSignature,\n jwtIssuer: JwtIssuerWithContext,\n jwt: { header: JwtHeader; payload: JwtPayload },\n): Promise<string> => {\n if (jwtIssuer.method === 'did') {\n const issuer = jwtIssuer.didUrl.split('#')[0]\n jwt.payload.issuer = issuer\n if (jwtIssuer.type === 'request-object') {\n return await signRequestObjectPayload(jwt.payload as RequestObjectPayload, signature)\n } else if (jwtIssuer.type === 'id-token') {\n return await signIDTokenPayload(jwt.payload as IDTokenPayload, signature)\n }\n }\n throw new Error('Invalid use of the did-auth-siop create jwt adapter')\n}\n"],"mappings":";;;;AAAA,SACEA,yBAEAC,MAEAC,aAEAC,kBAGK;AACP,SAASC,mBAAmB;AAC5B,SACEC,WACAC,WACAC,aACAC,cACAC,aACAC,YAMAC,iBACK;;;ACvBA,IAAMC,sBAAsB,wBAACC,WAClC,mBAAmBA,UAAU,SAASA,QADL;AAG5B,IAAMC,sBAAsB,wBAACD,WAClC,kBAAkBA,UAAU,SAASA,QADJ;AAG5B,IAAME,sBAAsB,wBAACF,WAClC,eAAeA,QADkB;;;AD4CnC,eAAsBG,aAAaC,KAAaC,UAAsBC,SAAyB;AAC7F,SAAOC,UAAUH,KAAK;IAAE,GAAGE;IAASD;EAAS,CAAA;AAC/C;AAFsBF;AAqBtB,eAAsBK,aACpBC,SACA,EAAEC,QAAQC,QAAQC,WAAWC,aAAY,GACzCC,QAA0B;AAE1B,SAAOC,UAAUN,SAAS;IAAEC;IAAQC;IAAQC;IAAWC;EAAa,GAAGC,MAAAA;AACzE;AANsBN;AAQtB,eAAsBQ,mBAAmBP,SAAyBQ,WAAoE;AACpI,MAAIC,oBAAoBD,SAAAA,GAAY;AAClC,QAAI,CAACA,UAAUE,KAAK;AAClB,aAAOC,QAAQC,OAAOC,MAAM,4BAAA,CAAA;IAC9B;AACA,WAAOC,mBAAmBd,SAASA,QAAQC,QAAQO,UAAUO,eAAeP,UAAUQ,KAAKR,UAAUE,KAAKF,UAAUS,eAAe;EACrI,WAAWC,oBAAoBV,SAAAA,GAAY;AACzC,WAAOW,mBAAmBnB,SAASQ,UAAUY,cAAcZ,UAAUa,YAAYb,UAAUQ,KAAKR,UAAUE,GAAG;EAC/G,WAAWY,oBAAoBd,SAAAA,GAAY;AACzC,QAAI,CAACA,UAAUE,KAAK;AAClB,aAAOC,QAAQC,OAAOC,MAAM,4BAAA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E,OAAOC,MAAM,GAAA,EAAK,CAAA;AAC3C/B,QAAIY,QAAQiB,SAASA;AACrB,QAAID,UAAUjB,SAAS,kBAAkB;AACvC,aAAO,MAAMqB,yBAAyBhC,IAAIY,SAAiCe,SAAAA;IAC7E,WAAWC,UAAUjB,SAAS,YAAY;AACxC,aAAO,MAAMsB,mBAAmBjC,IAAIY,SAA2Be,SAAAA;IACjE;EACF;AACA,QAAM,IAAIN,MAAM,qDAAA;AAClB,GAfmC;","names":["DEFAULT_EXPIRATION_TIME","post","ResponseIss","SIOPErrors","SigningAlgo","createJWT","decodeJWT","EdDSASigner","ES256KSigner","ES256Signer","hexToBytes","verifyJWT","isInternalSignature","object","isExternalSignature","isSuppliedSignature","verifyDidJWT","jwt","resolver","options","verifyJWT","createDidJWT","payload","issuer","signer","expiresIn","canonicalize","header","createJWT","signIDTokenPayload","signature","isInternalSignature","kid","Promise","reject","Error","signDidJwtInternal","hexPrivateKey","alg","customJwtSigner","isExternalSignature","signDidJwtExternal","signatureUri","authZToken","isSuppliedSignature","signDidJwtSupplied","signRequestObjectPayload","iss","did","sub","determineSigner","DEFAULT_EXPIRATION_TIME","body","includes","selfIssued","ResponseIss","SELF_ISSUED_V2","undefined","response","post","JSON","stringify","bearerToken","successBody","jws","customSigner","privateKey","hexToBytes","replace","SigningAlgo","EDDSA","EdDSASigner","ES256","ES256Signer","ES256K","ES256KSigner","PS256","RS256","getAudience","decodeJWT","SIOPErrors","NO_AUDIENCE","aud","Array","isArray","INVALID_AUDIENCE","assertIssSelfIssuedOrDid","startsWith","isIssSelfIssued","getSubDidFromPayload","split","SELF_ISSUED_V1","getMethodFromDid","BAD_PARAMS","length","toSIOPRegistrationDidMethod","didOrMethod","prefix","SubjectIdentifierType","SubjectSyntaxTypesSupportedValues","getUniResolver","UniResolver","Resolver","getResolver","opts","resolver","subjectSyntaxTypesSupported","noUniversalResolverFallback","Error","console","log","UniResolver","uniResolvers","indexOf","SubjectIdentifierType","DID","specificDidMethods","filter","sst","includes","length","didMethod","uniResolver","getUniResolver","getMethodFromDid","resolveUrl","push","Resolver","getResolverUnion","customResolver","resolverMap","fallbackResolver","subjectTypes","SubjectSyntaxTypesSupportedValues","valueOf","startsWith","forEach","dm","methodResolver","has","get","resolve","mergeAllDidMethods","resolvers","Array","isArray","unionSubjectSyntaxTypes","Set","add","_","toSIOPRegistrationDidMethod","from","resolveDidDocument","did","result","accept","didResolutionMetadata","error","didDocument","id","ValidationStatusEnum","WDCErrors","WellKnownDidVerifier","CheckLinkedDomain","VerificationMode","getValidationErrorMessages","validationResult","messages","message","push","endpointDescriptors","length","endpointDescriptor","resources","resource","checkInvalidMessages","validationErrorMessages","status","validMessages","WDCErrors","PROPERTY_LINKED_DIDS_DOES_NOT_CONTAIN_ANY_DOMAIN_LINK_CREDENTIALS","valueOf","PROPERTY_LINKED_DIDS_NOT_PRESENT","PROPERTY_TYPE_NOT_CONTAIN_VALID_LINKED_DOMAIN","PROPERTY_SERVICE_NOT_PRESENT","validationErrorMessage","filter","vm","includes","pop","validateLinkedDomainWithDid","did","verification","checkLinkedDomain","resolveOpts","wellknownDIDVerifyCallback","CheckLinkedDomain","NEVER","didDocument","resolveDidDocument","subjectSyntaxTypesSupported","toSIOPRegistrationDidMethod","getMethodFromDid","Error","service","find","s","type","IF_PRESENT","Promise","reject","checkWellKnownDid","verifyCallback","ValidationStatusEnum","INVALID","messageCondition","ALWAYS","err","args","verifier","WellKnownDidVerifier","verifySignatureCallback","onlyVerifyServiceDid","verifyDomainLinkage","verfiyDidJwtAdapter","jwtVerifier","jwt","options","method","audience","verification","resolveOpts","jwtVerifyOpts","getAudience","raw","verifyDidJWT","resolver","type","payload","client_id","startsWith","authorizationRequestPayload","checkLinkedDomain","CheckLinkedDomain","NEVER","Promise","reject","Error","validateLinkedDomainWithDid","wellknownDIDVerifyCallback","issuerDid","getSubDidFromPayload","createDidJwtAdapter","signature","jwtIssuer","issuer","didUrl","split","signRequestObjectPayload","signIDTokenPayload"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/did-auth-siop-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1-next.2+4c0450e",
|
|
4
4
|
"description": "Self Issued OpenID V2 (SIOPv2) and OpenID 4 Verifiable Presentations (OID4VP) did adapter",
|
|
5
|
+
"source": "./src/index.ts",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.cjs",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -22,9 +23,9 @@
|
|
|
22
23
|
"clean": "rimraf dist coverage"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@sphereon/did-auth-siop": "0.
|
|
26
|
+
"@sphereon/did-auth-siop": "^0.19.1-next.2+4c0450e",
|
|
26
27
|
"@sphereon/did-uni-client": "^0.6.2",
|
|
27
|
-
"@sphereon/oid4vc-common": "0.
|
|
28
|
+
"@sphereon/oid4vc-common": "^0.19.1-next.2+4c0450e",
|
|
28
29
|
"@sphereon/wellknown-dids-client": "^0.1.3",
|
|
29
30
|
"did-jwt": "6.11.6",
|
|
30
31
|
"did-resolver": "^4.1.0"
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"publishConfig": {
|
|
60
61
|
"access": "public"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "4c0450e17a060b0095d1f572870c0eedd1656c7b"
|
|
63
64
|
}
|