@sphereon/oid4vc-common 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/dist/index.cjs +11 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -17
- package/dist/index.js.map +1 -1
- package/package.json +9 -11
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/dist/index.cjs
CHANGED
|
@@ -59,7 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
verifyResourceDPoP: () => verifyResourceDPoP
|
|
60
60
|
});
|
|
61
61
|
module.exports = __toCommonJS(index_exports);
|
|
62
|
-
var
|
|
62
|
+
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
63
63
|
|
|
64
64
|
// lib/jwt/Jwt.types.ts
|
|
65
65
|
var SigningAlgo = /* @__PURE__ */ function(SigningAlgo2) {
|
|
@@ -72,25 +72,16 @@ var SigningAlgo = /* @__PURE__ */ function(SigningAlgo2) {
|
|
|
72
72
|
}({});
|
|
73
73
|
|
|
74
74
|
// lib/jwt/JwkThumbprint.ts
|
|
75
|
-
var
|
|
75
|
+
var u8a = __toESM(require("uint8arrays"), 1);
|
|
76
76
|
|
|
77
77
|
// lib/hasher.ts
|
|
78
|
-
var
|
|
79
|
-
var u8a = __toESM(require("uint8arrays"), 1);
|
|
80
|
-
var supportedAlgorithms = [
|
|
81
|
-
"sha256",
|
|
82
|
-
"sha384",
|
|
83
|
-
"sha512"
|
|
84
|
-
];
|
|
78
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
85
79
|
var defaultHasher = /* @__PURE__ */ __name((data, algorithm) => {
|
|
86
|
-
|
|
87
|
-
if (!supportedAlgorithms.includes(sanitizedAlgorithm)) {
|
|
88
|
-
throw new Error(`Unsupported hashing algorithm ${algorithm}`);
|
|
89
|
-
}
|
|
90
|
-
return new Uint8Array((0, import_sha.default)(sanitizedAlgorithm).update(typeof data === "string" ? u8a.fromString(data) : data).digest());
|
|
80
|
+
return (0, import_ssi_types.shaHasher)(data, algorithm);
|
|
91
81
|
}, "defaultHasher");
|
|
92
82
|
|
|
93
83
|
// lib/jwt/JwkThumbprint.ts
|
|
84
|
+
var { toString } = u8a;
|
|
94
85
|
var check = /* @__PURE__ */ __name((value, description) => {
|
|
95
86
|
if (typeof value !== "string" || !value) {
|
|
96
87
|
throw Error(`${description} missing or invalid`);
|
|
@@ -145,7 +136,7 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
|
145
136
|
default:
|
|
146
137
|
throw Error('"kty" (Key Type) Parameter missing or unsupported');
|
|
147
138
|
}
|
|
148
|
-
return
|
|
139
|
+
return toString(defaultHasher(JSON.stringify(components), algorithm), "base64url");
|
|
149
140
|
}
|
|
150
141
|
__name(calculateJwkThumbprint, "calculateJwkThumbprint");
|
|
151
142
|
async function getDigestAlgorithmFromJwkThumbprintUri(uri) {
|
|
@@ -300,8 +291,9 @@ var checkExp = /* @__PURE__ */ __name((input) => {
|
|
|
300
291
|
|
|
301
292
|
// lib/dpop/DPoP.ts
|
|
302
293
|
var import_jwt_decode2 = require("jwt-decode");
|
|
303
|
-
var
|
|
294
|
+
var u8a2 = __toESM(require("uint8arrays"), 1);
|
|
304
295
|
var import_uuid = require("uuid");
|
|
296
|
+
var { toString: toString2 } = u8a2;
|
|
305
297
|
var dpopTokenRequestNonceError = "use_dpop_nonce";
|
|
306
298
|
function getCreateDPoPOptions(createDPoPClientOpts, endPointUrl, resourceRequestOpts) {
|
|
307
299
|
const htu = endPointUrl.split("?")[0].split("#")[0];
|
|
@@ -323,7 +315,7 @@ async function createDPoP(options) {
|
|
|
323
315
|
if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith("DPoP ") || jwtPayloadProps.accessToken?.startsWith("Bearer "))) {
|
|
324
316
|
throw new Error("expected access token without scheme");
|
|
325
317
|
}
|
|
326
|
-
const ath = jwtPayloadProps.accessToken ?
|
|
318
|
+
const ath = jwtPayloadProps.accessToken ? toString2(defaultHasher(jwtPayloadProps.accessToken, "sha256"), "base64url") : void 0;
|
|
327
319
|
return createJwtCallback({
|
|
328
320
|
method: "jwk",
|
|
329
321
|
type: "dpop",
|
|
@@ -413,7 +405,7 @@ async function verifyDPoP(request, options) {
|
|
|
413
405
|
throw new Error("invalid_dpop_proof. Invalid authorization header.");
|
|
414
406
|
}
|
|
415
407
|
const accessToken = authorizationHeader.replace("DPoP ", "");
|
|
416
|
-
const expectedAth =
|
|
408
|
+
const expectedAth = toString2(defaultHasher(accessToken, "sha256"), "base64url");
|
|
417
409
|
if (dPoPPayload.ath !== expectedAth) {
|
|
418
410
|
throw new Error("invalid_dpop_proof. Invalid ath claim");
|
|
419
411
|
}
|
|
@@ -451,35 +443,6 @@ __name(verifyResourceDPoP, "verifyResourceDPoP");
|
|
|
451
443
|
|
|
452
444
|
// lib/index.ts
|
|
453
445
|
var import_uuid2 = require("uuid");
|
|
454
|
-
var VCI_LOGGERS =
|
|
446
|
+
var VCI_LOGGERS = import_ssi_types2.Loggers.DEFAULT;
|
|
455
447
|
var VCI_LOG_COMMON = VCI_LOGGERS.get("sphereon:oid4vci:common");
|
|
456
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
457
|
-
0 && (module.exports = {
|
|
458
|
-
BASE64_URL_REGEX,
|
|
459
|
-
SigningAlgo,
|
|
460
|
-
VCI_LOGGERS,
|
|
461
|
-
VCI_LOG_COMMON,
|
|
462
|
-
calculateJwkThumbprint,
|
|
463
|
-
calculateJwkThumbprintUri,
|
|
464
|
-
checkExp,
|
|
465
|
-
createDPoP,
|
|
466
|
-
decodeJwt,
|
|
467
|
-
decodeProtectedHeader,
|
|
468
|
-
defaultHasher,
|
|
469
|
-
dpopTokenRequestNonceError,
|
|
470
|
-
epochTime,
|
|
471
|
-
getCreateDPoPOptions,
|
|
472
|
-
getDidJwtVerifier,
|
|
473
|
-
getDigestAlgorithmFromJwkThumbprintUri,
|
|
474
|
-
getJwkVerifier,
|
|
475
|
-
getJwtVerifierWithContext,
|
|
476
|
-
getNowSkewed,
|
|
477
|
-
getX5cVerifier,
|
|
478
|
-
isJwe,
|
|
479
|
-
isJws,
|
|
480
|
-
parseJWT,
|
|
481
|
-
uuidv4,
|
|
482
|
-
verifyDPoP,
|
|
483
|
-
verifyResourceDPoP
|
|
484
|
-
});
|
|
485
448
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types';\n\nexport const VCI_LOGGERS = Loggers.DEFAULT;\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common');\n\nexport * from './types';\nexport * from './jwt';\nexport * from './dpop';\nexport * from './oauth';\n\nexport { v4 as uuidv4 } from 'uuid';\nexport { defaultHasher } from './hasher';\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode';\n\nimport { JWK } from './Jwk.types';\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string;\n x5c?: string[];\n kid?: string;\n jwk?: JWK;\n jwt?: string;\n} & Record<string, unknown>;\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string;\n nonce?: string;\n request_uri?: string;\n client_id_scheme?: string;\n} & Record<string, unknown>;\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nimport { defaultHasher } from '../hasher';\nimport { DigestAlgorithm } from '../types';\n\nimport { JWK } from './Jwk.types';\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`);\n }\n};\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object');\n }\n const algorithm = digestAlgorithm ?? 'sha256';\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"');\n }\n let components;\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter');\n check(jwk.x, '\"x\" (X Coordinate) Parameter');\n check(jwk.y, '\"y\" (Y Coordinate) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };\n break;\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter');\n check(jwk.x, '\"x\" (Public Key) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n break;\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter');\n check(jwk.n, '\"n\" (Modulus) Parameter');\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n };\n break;\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter');\n components = { k: jwk.k, kty: jwk.kty };\n break;\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported');\n }\n return u8a.toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url');\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/);\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`);\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm;\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`);\n }\n return algorithm;\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;\n}\n","import { HasherSync } from '@sphereon/ssi-types';\nimport sha from 'sha.js';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nconst supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const;\ntype SupportedAlgorithms = (typeof supportedAlgorithms)[number];\n\nexport const defaultHasher: HasherSync = (data, algorithm) => {\n const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');\n if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {\n throw new Error(`Unsupported hashing algorithm ${algorithm}`);\n }\n\n return new Uint8Array(\n sha(sanitizedAlgorithm as SupportedAlgorithms)\n .update(typeof data === 'string' ? u8a.fromString(data) : data)\n .digest(),\n );\n};\n","import { JWK } from './Jwk.types';\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types';\nimport { JwtProtectionMethod, JwtType } from './jwtUtils';\n\nexport interface JwtVerifierBase {\n type: JwtType;\n method: JwtProtectionMethod;\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did';\n\n alg: SigningAlgo | string;\n didUrl: string;\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c';\n\n alg: SigningAlgo | string;\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>;\n\n /**\n * The jwt issuer\n */\n issuer: string;\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation';\n\n /**\n * The OpenId federation Entity\n */\n entityId: string;\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk';\n alg: SigningAlgo | string;\n\n jwk: JWK;\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom';\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier;\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options;\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`);\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg };\n};\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT');\n }\n return payload.client_id as string;\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`);\n }\n return payload.iss;\n};\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options;\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`);\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n };\n};\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options;\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`);\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg };\n};\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt;\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options);\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options);\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options);\n\n return { method: 'custom', type: options.type };\n};\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>;\n","import { jwtDecode } from 'jwt-decode';\n\nimport { JwtHeader, JwtPayload } from './Jwt.types';\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true });\n const payload = jwtDecode<Payload>(jwt, { header: false });\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed');\n }\n return { header, payload };\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60;\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime();\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n };\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000);\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.');\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part));\n};\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.');\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part));\n};\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true });\n};\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false });\n};\n\nexport const checkExp = (input: {\n exp: number;\n now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number;\n}) => {\n const { exp, now, clockSkew } = input;\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120);\n};\n","import { jwtDecode } from 'jwt-decode';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { defaultHasher } from '../hasher';\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt';\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce';\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop';\n dPoPSigningAlgValuesSupported?: string[];\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string;\n iat: number;\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH';\n ath?: string;\n nonce?: string;\n jti: string;\n};\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK };\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string };\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>;\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>;\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps;\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[];\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>;\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0];\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n };\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options;\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme');\n }\n\n const ath = jwtPayloadProps.accessToken ? u8a.toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined;\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n );\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>;\nexport interface DPoPVerifyOptions {\n expectedNonce?: string;\n acceptedAlgorithms?: (string | SigningAlgo)[];\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number;\n expectAccessToken?: boolean;\n jwtVerifyCallback: DPoPVerifyJwtCallback;\n now?: number;\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop'];\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT');\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop);\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims');\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims');\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`);\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n );\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature');\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'));\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`);\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0];\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim');\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now);\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim');\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization;\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.');\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.');\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.');\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '');\n const expectedAth = u8a.toString(defaultHasher(accessToken, 'sha256'), 'base64url');\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim');\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false });\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim');\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256');\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch');\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk;\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.');\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false });\n const tokenType = tokenPayload.token_type;\n\n if (tokenType !== 'DPoP') {\n return;\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAwB;;;ACmBjB,IAAKA,cAAAA,yBAAAA,cAAAA;;;;;;SAAAA;;;;ACjBZ,IAAAC,OAAqB;;;ACDrB,iBAAgB;AAGhB,UAAqB;AAErB,IAAMC,sBAAsB;EAAC;EAAU;EAAU;;AAG1C,IAAMC,gBAA4B,wBAACC,MAAMC,cAAAA;AAC9C,QAAMC,qBAAqBD,UAAUE,YAAW,EAAGC,QAAQ,SAAS,EAAA;AACpE,MAAI,CAACN,oBAAoBO,SAASH,kBAAAA,GAA4C;AAC5E,UAAM,IAAII,MAAM,iCAAiCL,SAAAA,EAAW;EAC9D;AAEA,SAAO,IAAIM,eACTC,WAAAA,SAAIN,kBAAAA,EACDO,OAAO,OAAOT,SAAS,WAAeU,eAAWV,IAAAA,IAAQA,IAAAA,EACzDW,OAAM,CAAA;AAEb,GAXyC;;;ADAzC,IAAMC,QAAQ,wBAACC,OAAgBC,gBAAAA;AAC7B,MAAI,OAAOD,UAAU,YAAY,CAACA,OAAO;AACvC,UAAME,MAAM,GAAGD,WAAAA,qBAAgC;EACjD;AACF,GAJc;AAMd,eAAsBE,uBAAuBC,KAAUC,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,mBAAmBE,KAAKC,KAAK;AAChC,YAAM,IAAIjD,MAAM,2DAAA;IAClB;AAEA,UAAMkD,YAAY,MAAMC,uBAAuB/B,WAAWZ,KAAK,QAAA;AAC/D,QAAIsC,mBAAmBE,KAAKC,QAAQC,WAAW;AAC7C,YAAM,IAAIlD,MAAM,4CAAA;IAClB;EACF;AAGA,SAAOoB,WAAWZ;AACpB;AAxHsBQ;AAiItB,eAAsBoC,mBACpBnC,SACAtB,SAAqD;AAErD,MAAI,CAACsB,QAAQE,QAAQuB,iBAAiB,OAAOzB,QAAQE,QAAQuB,kBAAkB,UAAU;AACvF,UAAM,IAAI1C,MAAM,qEAAA;EAClB;AACA,QAAMqD,mBAAeN,8BAAgD9B,QAAQE,QAAQuB,eAAe;IAAEjC,QAAQ;EAAM,CAAA;AACpH,QAAM6C,YAAYD,aAAaE;AAE/B,MAAID,cAAc,QAAQ;AACxB;EACF;AAEA,SAAOtC,WAAWC,SAAS;IAAE,GAAGtB;IAASgD,mBAAmB;EAAK,CAAA;AACnE;AAfsBS;;;ANzNtB,IAAAI,eAA6B;AARtB,IAAMC,cAAcC,yBAAQC;AAC5B,IAAMC,iBAAiBH,YAAYI,IAAI,yBAAA;","names":["SigningAlgo","u8a","supportedAlgorithms","defaultHasher","data","algorithm","sanitizedAlgorithm","toLowerCase","replace","includes","Error","Uint8Array","sha","update","fromString","digest","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","toString","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","import_jwt_decode","u8a","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","toString","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","import_uuid","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types'\n\nexport const VCI_LOGGERS = Loggers.DEFAULT\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common')\n\nexport * from './types'\nexport * from './jwt'\nexport * from './dpop'\nexport * from './oauth'\n\nexport { v4 as uuidv4 } from 'uuid'\nexport { defaultHasher } from './hasher'\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode'\n\nimport { JWK } from './Jwk.types'\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string\n x5c?: string[]\n kid?: string\n jwk?: JWK\n jwt?: string\n} & Record<string, unknown>\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string\n nonce?: string\n request_uri?: string\n client_id_scheme?: string\n} & Record<string, unknown>\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\n\nimport { defaultHasher } from '../hasher'\nimport { DigestAlgorithm } from '../types'\n\nimport { JWK } from './Jwk.types'\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`)\n }\n}\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object')\n }\n const algorithm = digestAlgorithm ?? 'sha256'\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"')\n }\n let components\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter')\n check(jwk.x, '\"x\" (X Coordinate) Parameter')\n check(jwk.y, '\"y\" (Y Coordinate) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }\n break\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter')\n check(jwk.x, '\"x\" (Public Key) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x }\n break\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter')\n check(jwk.n, '\"n\" (Modulus) Parameter')\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n }\n break\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter')\n components = { k: jwk.k, kty: jwk.kty }\n break\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported')\n }\n return toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url')\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/)\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`)\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`)\n }\n return algorithm\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm)\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`\n}\n","import { HasherSync, shaHasher } from '@sphereon/ssi-types'\n\nexport const defaultHasher: HasherSync = (data: string | ArrayBuffer, algorithm: string) => {\n return shaHasher(data, algorithm)\n}\n","import { JWK } from './Jwk.types'\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types'\nimport { JwtProtectionMethod, JwtType } from './jwtUtils'\n\nexport interface JwtVerifierBase {\n type: JwtType\n method: JwtProtectionMethod\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did'\n\n alg: SigningAlgo | string\n didUrl: string\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c'\n\n alg: SigningAlgo | string\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>\n\n /**\n * The jwt issuer\n */\n issuer: string\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation'\n\n /**\n * The OpenId federation Entity\n */\n entityId: string\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk'\n alg: SigningAlgo | string\n\n jwk: JWK\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom'\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`)\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg }\n}\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT')\n }\n return payload.client_id as string\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`)\n }\n return payload.iss\n}\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`)\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n }\n}\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`)\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg }\n}\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options)\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options)\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options)\n\n return { method: 'custom', type: options.type }\n}\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>\n","import { jwtDecode } from 'jwt-decode'\n\nimport { JwtHeader, JwtPayload } from './Jwt.types'\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop'\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom'\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true })\n const payload = jwtDecode<Payload>(jwt, { header: false })\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed')\n }\n return { header, payload }\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime()\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n }\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000)\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.')\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part))\n}\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.')\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part))\n}\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true })\n}\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false })\n}\n\nexport const checkExp = (input: {\n exp: number\n now?: number // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number\n}) => {\n const { exp, now, clockSkew } = input\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120)\n}\n","import { jwtDecode } from 'jwt-decode'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\n\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { defaultHasher } from '../hasher'\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt'\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce'\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop'\n dPoPSigningAlgValuesSupported?: string[]\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string\n iat: number\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH'\n ath?: string\n nonce?: string\n jti: string\n}\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK }\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string }\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[]\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0]\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n }\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme')\n }\n\n const ath = jwtPayloadProps.accessToken ? toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n )\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>\nexport interface DPoPVerifyOptions {\n expectedNonce?: string\n acceptedAlgorithms?: (string | SigningAlgo)[]\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number\n expectAccessToken?: boolean\n jwtVerifyCallback: DPoPVerifyJwtCallback\n now?: number\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop']\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT')\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop)\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims')\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims')\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`)\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n )\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature')\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'))\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`)\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0]\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim')\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now)\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim')\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.')\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.')\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.')\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '')\n const expectedAth = toString(defaultHasher(accessToken, 'sha256'), 'base64url')\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim')\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false })\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim')\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256')\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch')\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.')\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false })\n const tokenType = tokenPayload.token_type\n\n if (tokenType !== 'DPoP') {\n return\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAwB;;;ACmBj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ithm","shaHasher","toString","u8a","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","import_jwt_decode","u8a","toString","u8a","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","import_uuid","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
package/dist/index.js
CHANGED
|
@@ -15,25 +15,16 @@ var SigningAlgo = /* @__PURE__ */ function(SigningAlgo2) {
|
|
|
15
15
|
}({});
|
|
16
16
|
|
|
17
17
|
// lib/jwt/JwkThumbprint.ts
|
|
18
|
-
import * as
|
|
18
|
+
import * as u8a from "uint8arrays";
|
|
19
19
|
|
|
20
20
|
// lib/hasher.ts
|
|
21
|
-
import
|
|
22
|
-
import * as u8a from "uint8arrays";
|
|
23
|
-
var supportedAlgorithms = [
|
|
24
|
-
"sha256",
|
|
25
|
-
"sha384",
|
|
26
|
-
"sha512"
|
|
27
|
-
];
|
|
21
|
+
import { shaHasher } from "@sphereon/ssi-types";
|
|
28
22
|
var defaultHasher = /* @__PURE__ */ __name((data, algorithm) => {
|
|
29
|
-
|
|
30
|
-
if (!supportedAlgorithms.includes(sanitizedAlgorithm)) {
|
|
31
|
-
throw new Error(`Unsupported hashing algorithm ${algorithm}`);
|
|
32
|
-
}
|
|
33
|
-
return new Uint8Array(sha(sanitizedAlgorithm).update(typeof data === "string" ? u8a.fromString(data) : data).digest());
|
|
23
|
+
return shaHasher(data, algorithm);
|
|
34
24
|
}, "defaultHasher");
|
|
35
25
|
|
|
36
26
|
// lib/jwt/JwkThumbprint.ts
|
|
27
|
+
var { toString } = u8a;
|
|
37
28
|
var check = /* @__PURE__ */ __name((value, description) => {
|
|
38
29
|
if (typeof value !== "string" || !value) {
|
|
39
30
|
throw Error(`${description} missing or invalid`);
|
|
@@ -88,7 +79,7 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
|
88
79
|
default:
|
|
89
80
|
throw Error('"kty" (Key Type) Parameter missing or unsupported');
|
|
90
81
|
}
|
|
91
|
-
return
|
|
82
|
+
return toString(defaultHasher(JSON.stringify(components), algorithm), "base64url");
|
|
92
83
|
}
|
|
93
84
|
__name(calculateJwkThumbprint, "calculateJwkThumbprint");
|
|
94
85
|
async function getDigestAlgorithmFromJwkThumbprintUri(uri) {
|
|
@@ -243,8 +234,9 @@ var checkExp = /* @__PURE__ */ __name((input) => {
|
|
|
243
234
|
|
|
244
235
|
// lib/dpop/DPoP.ts
|
|
245
236
|
import { jwtDecode as jwtDecode2 } from "jwt-decode";
|
|
246
|
-
import * as
|
|
237
|
+
import * as u8a2 from "uint8arrays";
|
|
247
238
|
import { v4 as uuidv4 } from "uuid";
|
|
239
|
+
var { toString: toString2 } = u8a2;
|
|
248
240
|
var dpopTokenRequestNonceError = "use_dpop_nonce";
|
|
249
241
|
function getCreateDPoPOptions(createDPoPClientOpts, endPointUrl, resourceRequestOpts) {
|
|
250
242
|
const htu = endPointUrl.split("?")[0].split("#")[0];
|
|
@@ -266,7 +258,7 @@ async function createDPoP(options) {
|
|
|
266
258
|
if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith("DPoP ") || jwtPayloadProps.accessToken?.startsWith("Bearer "))) {
|
|
267
259
|
throw new Error("expected access token without scheme");
|
|
268
260
|
}
|
|
269
|
-
const ath = jwtPayloadProps.accessToken ?
|
|
261
|
+
const ath = jwtPayloadProps.accessToken ? toString2(defaultHasher(jwtPayloadProps.accessToken, "sha256"), "base64url") : void 0;
|
|
270
262
|
return createJwtCallback({
|
|
271
263
|
method: "jwk",
|
|
272
264
|
type: "dpop",
|
|
@@ -356,7 +348,7 @@ async function verifyDPoP(request, options) {
|
|
|
356
348
|
throw new Error("invalid_dpop_proof. Invalid authorization header.");
|
|
357
349
|
}
|
|
358
350
|
const accessToken = authorizationHeader.replace("DPoP ", "");
|
|
359
|
-
const expectedAth =
|
|
351
|
+
const expectedAth = toString2(defaultHasher(accessToken, "sha256"), "base64url");
|
|
360
352
|
if (dPoPPayload.ath !== expectedAth) {
|
|
361
353
|
throw new Error("invalid_dpop_proof. Invalid ath claim");
|
|
362
354
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types';\n\nexport const VCI_LOGGERS = Loggers.DEFAULT;\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common');\n\nexport * from './types';\nexport * from './jwt';\nexport * from './dpop';\nexport * from './oauth';\n\nexport { v4 as uuidv4 } from 'uuid';\nexport { defaultHasher } from './hasher';\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode';\n\nimport { JWK } from './Jwk.types';\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string;\n x5c?: string[];\n kid?: string;\n jwk?: JWK;\n jwt?: string;\n} & Record<string, unknown>;\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string;\n nonce?: string;\n request_uri?: string;\n client_id_scheme?: string;\n} & Record<string, unknown>;\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nimport { defaultHasher } from '../hasher';\nimport { DigestAlgorithm } from '../types';\n\nimport { JWK } from './Jwk.types';\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`);\n }\n};\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object');\n }\n const algorithm = digestAlgorithm ?? 'sha256';\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"');\n }\n let components;\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter');\n check(jwk.x, '\"x\" (X Coordinate) Parameter');\n check(jwk.y, '\"y\" (Y Coordinate) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };\n break;\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter');\n check(jwk.x, '\"x\" (Public Key) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n break;\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter');\n check(jwk.n, '\"n\" (Modulus) Parameter');\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n };\n break;\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter');\n components = { k: jwk.k, kty: jwk.kty };\n break;\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported');\n }\n return u8a.toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url');\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/);\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`);\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm;\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`);\n }\n return algorithm;\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;\n}\n","import { HasherSync } from '@sphereon/ssi-types';\nimport sha from 'sha.js';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nconst supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const;\ntype SupportedAlgorithms = (typeof supportedAlgorithms)[number];\n\nexport const defaultHasher: HasherSync = (data, algorithm) => {\n const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');\n if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {\n throw new Error(`Unsupported hashing algorithm ${algorithm}`);\n }\n\n return new Uint8Array(\n sha(sanitizedAlgorithm as SupportedAlgorithms)\n .update(typeof data === 'string' ? u8a.fromString(data) : data)\n .digest(),\n );\n};\n","import { JWK } from './Jwk.types';\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types';\nimport { JwtProtectionMethod, JwtType } from './jwtUtils';\n\nexport interface JwtVerifierBase {\n type: JwtType;\n method: JwtProtectionMethod;\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did';\n\n alg: SigningAlgo | string;\n didUrl: string;\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c';\n\n alg: SigningAlgo | string;\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>;\n\n /**\n * The jwt issuer\n */\n issuer: string;\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation';\n\n /**\n * The OpenId federation Entity\n */\n entityId: string;\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk';\n alg: SigningAlgo | string;\n\n jwk: JWK;\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom';\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier;\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options;\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`);\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg };\n};\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT');\n }\n return payload.client_id as string;\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`);\n }\n return payload.iss;\n};\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options;\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`);\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n };\n};\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options;\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`);\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg };\n};\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt;\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options);\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options);\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options);\n\n return { method: 'custom', type: options.type };\n};\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>;\n","import { jwtDecode } from 'jwt-decode';\n\nimport { JwtHeader, JwtPayload } from './Jwt.types';\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true });\n const payload = jwtDecode<Payload>(jwt, { header: false });\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed');\n }\n return { header, payload };\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60;\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime();\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n };\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000);\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.');\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part));\n};\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.');\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part));\n};\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true });\n};\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false });\n};\n\nexport const checkExp = (input: {\n exp: number;\n now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number;\n}) => {\n const { exp, now, clockSkew } = input;\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120);\n};\n","import { jwtDecode } from 'jwt-decode';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { defaultHasher } from '../hasher';\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt';\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce';\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop';\n dPoPSigningAlgValuesSupported?: string[];\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string;\n iat: number;\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH';\n ath?: string;\n nonce?: string;\n jti: string;\n};\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK };\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string };\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>;\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>;\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps;\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[];\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>;\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0];\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n };\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options;\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme');\n }\n\n const ath = jwtPayloadProps.accessToken ? u8a.toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined;\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n );\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>;\nexport interface DPoPVerifyOptions {\n expectedNonce?: string;\n acceptedAlgorithms?: (string | SigningAlgo)[];\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number;\n expectAccessToken?: boolean;\n jwtVerifyCallback: DPoPVerifyJwtCallback;\n now?: number;\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop'];\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT');\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop);\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims');\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims');\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`);\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n );\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature');\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'));\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`);\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0];\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim');\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now);\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim');\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization;\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.');\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.');\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.');\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '');\n const expectedAth = u8a.toString(defaultHasher(accessToken, 'sha256'), 'base64url');\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim');\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false });\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim');\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256');\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch');\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk;\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.');\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false });\n const tokenType = tokenPayload.token_type;\n\n if (tokenType !== 'DPoP') {\n return;\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true });\n}\n"],"mappings":";;;;AAAA,SAASA,eAAe;;;ACmBjB,IAAKC,cAAAA,yBAAAA,cAAAA;;;;;;SAAAA;;;;ACjBZ,YAAYC,UAAS;;;ACDrB,OAAOC,SAAS;AAGhB,YAAYC,SAAS;AAErB,IAAMC,sBAAsB;EAAC;EAAU;EAAU;;AAG1C,IAAMC,gBAA4B,wBAACC,MAAMC,cAAAA;AAC9C,QAAMC,qBAAqBD,UAAUE,YAAW,EAAGC,QAAQ,SAAS,EAAA;AACpE,MAAI,CAACN,oBAAoBO,SAASH,kBAAAA,GAA4C;AAC5E,UAAM,IAAII,MAAM,iCAAiCL,SAAAA,EAAW;EAC9D;AAEA,SAAO,IAAIM,WACTC,IAAIN,kBAAAA,EACDO,OAAO,OAAOT,SAAS,WAAeU,eAAWV,IAAAA,IAAQA,IAAAA,EACzDW,OAAM,CAAA;AAEb,GAXyC;;;ADAzC,IAAMC,QAAQ,wBAACC,OAAgBC,gBAAAA;AAC7B,MAAI,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a;AACnC,YAAM,IAAI7C,MAAM,uCAAA;IAClB;AAGA,UAAM8C,qBAAqBC,WAAmDtD,aAAa;MAAEgB,QAAQ;IAAM,CAAA;AAC3G,QAAI,CAACqC,mBAAmBE,KAAKC,KAAK;AAChC,YAAM,IAAIjD,MAAM,2DAAA;IAClB;AAEA,UAAMkD,YAAY,MAAMC,uBAAuB/B,WAAWZ,KAAK,QAAA;AAC/D,QAAIsC,mBAAmBE,KAAKC,QAAQC,WAAW;AAC7C,YAAM,IAAIlD,MAAM,4CAAA;IAClB;EACF;AAGA,SAAOoB,WAAWZ;AACpB;AAxHsBQ;AAiItB,eAAsBoC,mBACpBnC,SACAtB,SAAqD;AAErD,MAAI,CAACsB,QAAQE,QAAQuB,iBAAiB,OAAOzB,QAAQE,QAAQuB,kBAAkB,UAAU;AACvF,UAAM,IAAI1C,MAAM,qEAAA;EAClB;AACA,QAAMqD,eAAeN,WAAgD9B,QAAQE,QAAQuB,eAAe;IAAEjC,QAAQ;EAAM,CAAA;AACpH,QAAM6C,YAAYD,aAAaE;AAE/B,MAAID,cAAc,QAAQ;AACxB;EACF;AAEA,SAAOtC,WAAWC,SAAS;IAAE,GAAGtB;IAASgD,mBAAmB;EAAK,CAAA;AACnE;AAfsBS;;;ANzNtB,SAAeI,UAAc;AARtB,IAAMC,cAAcC,QAAQC;AAC5B,IAAMC,iBAAiBH,YAAYI,IAAI,yBAAA;","names":["Loggers","SigningAlgo","u8a","sha","u8a","supportedAlgorithms","defaultHasher","data","algorithm","sanitizedAlgorithm","toLowerCase","replace","includes","Error","Uint8Array","sha","update","fromString","digest","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","toString","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","jwtDecode","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","jwtDecode","u8a","v4","uuidv4","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","toString","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","uuidv4","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types'\n\nexport const VCI_LOGGERS = Loggers.DEFAULT\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common')\n\nexport * from './types'\nexport * from './jwt'\nexport * from './dpop'\nexport * from './oauth'\n\nexport { v4 as uuidv4 } from 'uuid'\nexport { defaultHasher } from './hasher'\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode'\n\nimport { JWK } from './Jwk.types'\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string\n x5c?: string[]\n kid?: string\n jwk?: JWK\n jwt?: string\n} & Record<string, unknown>\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string\n nonce?: string\n request_uri?: string\n client_id_scheme?: string\n} & Record<string, unknown>\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\n\nimport { defaultHasher } from '../hasher'\nimport { DigestAlgorithm } from '../types'\n\nimport { JWK } from './Jwk.types'\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`)\n }\n}\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object')\n }\n const algorithm = digestAlgorithm ?? 'sha256'\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"')\n }\n let components\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter')\n check(jwk.x, '\"x\" (X Coordinate) Parameter')\n check(jwk.y, '\"y\" (Y Coordinate) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }\n break\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter')\n check(jwk.x, '\"x\" (Public Key) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x }\n break\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter')\n check(jwk.n, '\"n\" (Modulus) Parameter')\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n }\n break\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter')\n components = { k: jwk.k, kty: jwk.kty }\n break\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported')\n }\n return toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url')\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/)\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`)\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`)\n }\n return algorithm\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm)\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`\n}\n","import { HasherSync, shaHasher } from '@sphereon/ssi-types'\n\nexport const defaultHasher: HasherSync = (data: string | ArrayBuffer, algorithm: string) => {\n return shaHasher(data, algorithm)\n}\n","import { JWK } from './Jwk.types'\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types'\nimport { JwtProtectionMethod, JwtType } from './jwtUtils'\n\nexport interface JwtVerifierBase {\n type: JwtType\n method: JwtProtectionMethod\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did'\n\n alg: SigningAlgo | string\n didUrl: string\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c'\n\n alg: SigningAlgo | string\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>\n\n /**\n * The jwt issuer\n */\n issuer: string\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation'\n\n /**\n * The OpenId federation Entity\n */\n entityId: string\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk'\n alg: SigningAlgo | string\n\n jwk: JWK\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom'\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`)\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg }\n}\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT')\n }\n return payload.client_id as string\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`)\n }\n return payload.iss\n}\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`)\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n }\n}\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`)\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg }\n}\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options)\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options)\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options)\n\n return { method: 'custom', type: options.type }\n}\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>\n","import { jwtDecode } from 'jwt-decode'\n\nimport { JwtHeader, JwtPayload } from './Jwt.types'\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop'\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom'\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true })\n const payload = jwtDecode<Payload>(jwt, { header: false })\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed')\n }\n return { header, payload }\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime()\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n }\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000)\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.')\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part))\n}\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.')\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part))\n}\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true })\n}\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false })\n}\n\nexport const checkExp = (input: {\n exp: number\n now?: number // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number\n}) => {\n const { exp, now, clockSkew } = input\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120)\n}\n","import { jwtDecode } from 'jwt-decode'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays'\nconst { toString } = u8a\n\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { defaultHasher } from '../hasher'\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt'\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce'\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop'\n dPoPSigningAlgValuesSupported?: string[]\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string\n iat: number\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH'\n ath?: string\n nonce?: string\n jti: string\n}\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK }\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string }\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[]\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0]\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n }\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme')\n }\n\n const ath = jwtPayloadProps.accessToken ? toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n )\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>\nexport interface DPoPVerifyOptions {\n expectedNonce?: string\n acceptedAlgorithms?: (string | SigningAlgo)[]\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number\n expectAccessToken?: boolean\n jwtVerifyCallback: DPoPVerifyJwtCallback\n now?: number\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop']\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT')\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop)\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims')\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims')\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`)\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n )\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature')\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'))\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`)\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0]\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim')\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now)\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim')\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.')\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.')\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.')\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '')\n const expectedAth = toString(defaultHasher(accessToken, 'sha256'), 'base64url')\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim')\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false })\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim')\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256')\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch')\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.')\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false })\n const tokenType = tokenPayload.token_type\n\n if (tokenType !== 'DPoP') {\n return\n }\n\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AAcC,QAAQC;AAC5B,IAAMC,iBAAiBH,YAAYI,IAAI,yBAAA;","names":["Loggers","SigningAlgo","u8a","shaHasher","defaultHasher","data","algorithm","shaHasher","toString","u8a","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","jwtDecode","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","jwtDecode","u8a","v4","uuidv4","toString","u8a","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","uuidv4","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vc-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1-next.2+4c0450e",
|
|
4
4
|
"description": "OpenID 4 Verifiable Credentials Common",
|
|
5
|
+
"source": "./src/index.ts",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.cjs",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -21,14 +22,12 @@
|
|
|
21
22
|
"test": "vitest run --config ../../vitest.config.ts --coverage"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@sphereon/ssi-types": "
|
|
25
|
+
"@sphereon/ssi-types": "0.34.1-next.3",
|
|
25
26
|
"jwt-decode": "^4.0.0",
|
|
26
|
-
"
|
|
27
|
-
"uint8arrays": "3.1.1",
|
|
27
|
+
"uint8arrays": "^3.1.1",
|
|
28
28
|
"uuid": "^9.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/sha.js": "^2.4.4",
|
|
32
31
|
"@types/uuid": "^9.0.1",
|
|
33
32
|
"typescript": "5.8.3"
|
|
34
33
|
},
|
|
@@ -36,12 +35,11 @@
|
|
|
36
35
|
"node": ">=20"
|
|
37
36
|
},
|
|
38
37
|
"files": [
|
|
39
|
-
"
|
|
38
|
+
"src",
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE.md"
|
|
40
42
|
],
|
|
41
|
-
"prettier": {
|
|
42
|
-
"singleQuote": true,
|
|
43
|
-
"printWidth": 150
|
|
44
|
-
},
|
|
45
43
|
"keywords": [
|
|
46
44
|
"Sphereon",
|
|
47
45
|
"Verifiable Credentials",
|
|
@@ -61,5 +59,5 @@
|
|
|
61
59
|
"publishConfig": {
|
|
62
60
|
"access": "public"
|
|
63
61
|
},
|
|
64
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4c0450e17a060b0095d1f572870c0eedd1656c7b"
|
|
65
63
|
}
|