@sphereon/jarm 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 +0 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
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
|
@@ -493,24 +493,4 @@ var jarmMetadataValidate = /* @__PURE__ */ __name((vJarmMetadataValidate) => {
|
|
|
493
493
|
throw new Error(`Invalid jarm client_metadata combination`);
|
|
494
494
|
}
|
|
495
495
|
}, "jarmMetadataValidate");
|
|
496
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
497
|
-
0 && (module.exports = {
|
|
498
|
-
jarmAuthResponseDirectPostJwtValidate,
|
|
499
|
-
jarmAuthResponseDirectPostValidateParams,
|
|
500
|
-
jarmAuthResponseSend,
|
|
501
|
-
jarmMetadataValidate,
|
|
502
|
-
vAuthRequestParams,
|
|
503
|
-
vJarmAuthResponseErrorParams,
|
|
504
|
-
vJarmAuthResponseParams,
|
|
505
|
-
vJarmAuthResponseValidateMetadataInput,
|
|
506
|
-
vJarmClientMetadata,
|
|
507
|
-
vJarmClientMetadataEncrypt,
|
|
508
|
-
vJarmClientMetadataSign,
|
|
509
|
-
vJarmClientMetadataSignEncrypt,
|
|
510
|
-
vJarmDirectPostJwtParams,
|
|
511
|
-
vJarmMetadataValidateOut,
|
|
512
|
-
vJarmServerMetadata,
|
|
513
|
-
vOAuthAuthRequestGetParamsOut,
|
|
514
|
-
validateJarmAuthResponseParams
|
|
515
|
-
});
|
|
516
496
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.ts","../lib/utils.ts","../lib/v-response-mode-registry.ts","../lib/jarm-auth-response-send/jarm-auth-response-send.ts","../lib/jarm-auth-response/c-jarm-auth-response.ts","../lib/v-response-type-registry.ts","../lib/jarm-auth-response/jarm-auth-response.ts","../lib/jarm-auth-response/v-jarm-auth-response-params.ts","../lib/jarm-auth-response/v-jarm-direct-post-jwt-auth-response-params.ts","../lib/metadata/v-jarm-client-metadata.ts","../lib/metadata/v-jarm-server-metadata.ts","../lib/metadata/jarm-validate-metadata.ts"],"sourcesContent":["export * from './jarm-auth-response-send/index.js';\nexport * from './jarm-auth-response/index.js';\nexport * from './metadata/index.js';\n","export function appendQueryParams(input: { url: URL; params: Record<string, string | number | boolean> }) {\n const { url, params } = input;\n\n // Append the new query parameters from the params object\n for (const [key, value] of Object.entries(params)) {\n url.searchParams.append(key, encodeURIComponent(value));\n }\n\n return url;\n}\n\nexport function appendFragmentParams(input: { url: URL; fragments: Record<string, string | number | boolean> }) {\n const { url, fragments } = input;\n\n // Convert existing fragment to an object and remove the leading '#'\n const fragmentParams = new URLSearchParams(url.hash.slice(1)); // Remove the leading '#' from the fragment\n\n // Append the new fragments from the fragments object\n for (const [key, value] of Object.entries(fragments)) {\n fragmentParams.append(key, encodeURIComponent(value));\n }\n\n // Rebuild the fragment string and assign it to the URL\n url.hash = fragmentParams.toString();\n\n return url;\n}\n\ninterface AssertValueSupported<T> {\n supported: T[];\n actual: T;\n error: Error;\n required: boolean;\n}\n\nexport function assertValueSupported<T>(input: AssertValueSupported<T>): T | undefined {\n const { required, error, supported, actual } = input;\n const intersection = supported.find((value) => value === actual);\n\n if (required && !intersection) throw error;\n return intersection;\n}\n","import * as v from 'valibot';\n\nimport type { ResponseTypeOut } from './v-response-type-registry.js';\n\nexport const vJarmResponseMode = v.picklist(['jwt', 'query.jwt', 'fragment.jwt', 'form_post.jwt']);\nexport type JarmResponseMode = v.InferInput<typeof vJarmResponseMode>;\n\nexport const vOpenid4vpResponseMode = v.picklist(['direct_post']);\nexport type Openid4vpResponseMode = v.InferInput<typeof vOpenid4vpResponseMode>;\n\n/**\n * * 'direct_post.jwt' The response is send as HTTP POST request using the application/x-www-form-urlencoded content type. The body contains a single parameter response which is the JWT encoded Response as defined in JARM 4.1\n */\nexport const vOpenid4vpJarmResponseMode = v.picklist(['direct_post.jwt']);\nexport type Openid4vpJarmResponseMode = v.InferInput<typeof vOpenid4vpJarmResponseMode>;\n\n/**\n * The use of this parameter is NOT RECOMMENDED when the Response Mode that would be requested is the default mode specified for the Response Type.\n * * 'query' In this mode, Authorization Response parameters are encoded in the query string added to the redirect_uri when redirecting back to the Client.\n * * 'fragment' In this mode, Authorization Response parameters are encoded in the fragment added to the redirect_uri when redirecting back to the Client.\n * * 'direct_post' the Authorization Response is send to an endpoint controlled by the Verifier via an HTTP POST request.\n */\nexport const vResponseMode = v.pipe(\n v.picklist(['query', 'fragment', ...vOpenid4vpResponseMode.options, ...vJarmResponseMode.options, ...vOpenid4vpJarmResponseMode.options]),\n v.description('Informs the Authorization Server of the mechanism to be used for returning parameters from the Authorization Endpoint.'),\n);\nexport type ResponseMode = v.InferInput<typeof vResponseMode>;\n\nconst getDisAllowedResponseModes = (input: { response_type: ResponseTypeOut }): [ResponseMode, ...ResponseMode[]] | undefined => {\n const { response_type } = input;\n\n switch (response_type) {\n case 'code token':\n return ['query'];\n case 'code id_token':\n return ['query'];\n case 'id_token token':\n return ['query'];\n case 'code id_token token':\n return ['query'];\n }\n return undefined;\n};\n\nexport const getDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query' | 'fragment' => {\n const { response_type } = input;\n\n switch (response_type) {\n case 'code':\n case 'none':\n return 'query';\n case 'token':\n case 'id_token':\n case 'code token':\n case 'code id_token':\n case 'id_token token':\n case 'code id_token token':\n case 'vp_token':\n case 'id_token vp_token':\n return 'fragment';\n }\n};\n\nexport const getJarmDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query.jwt' | 'fragment.jwt' => {\n const responseMode = getDefaultResponseMode(input);\n\n switch (responseMode) {\n case 'query':\n return 'query.jwt';\n case 'fragment':\n return 'fragment.jwt';\n }\n};\n\nexport const validateResponseMode = (input: { response_type: ResponseTypeOut; response_mode: ResponseMode }) => {\n const disallowedResponseModes = getDisAllowedResponseModes(input);\n\n if (disallowedResponseModes?.includes(input.response_mode)) {\n throw new Error(`Response_type '${input.response_type}' is not compatible with response_mode '${input.response_mode}'.`);\n }\n};\n","import { appendFragmentParams, appendQueryParams } from '../utils.js';\nimport type { JarmResponseMode, Openid4vpJarmResponseMode } from '../v-response-mode-registry.js';\nimport { getJarmDefaultResponseMode, validateResponseMode } from '../v-response-mode-registry.js';\nimport type { ResponseTypeOut } from '../v-response-type-registry.js';\n\ninterface JarmAuthResponseSendInput {\n authRequestParams: {\n response_mode?: JarmResponseMode | Openid4vpJarmResponseMode;\n response_type: ResponseTypeOut;\n } & (\n | {\n response_uri: string;\n }\n | {\n redirect_uri: string;\n }\n );\n\n authResponse: string;\n state: string;\n}\n\nexport const jarmAuthResponseSend = async (input: JarmAuthResponseSendInput): Promise<Response> => {\n const { authRequestParams, authResponse, state } = input;\n\n const responseEndpoint = 'response_uri' in authRequestParams ? new URL(authRequestParams.response_uri) : new URL(authRequestParams.redirect_uri);\n\n const responseMode =\n authRequestParams.response_mode && authRequestParams.response_mode !== 'jwt'\n ? authRequestParams.response_mode\n : getJarmDefaultResponseMode(authRequestParams);\n\n validateResponseMode({\n response_type: authRequestParams.response_type,\n response_mode: responseMode,\n });\n\n switch (responseMode) {\n case 'direct_post.jwt':\n return handleDirectPostJwt(responseEndpoint, authResponse, state);\n case 'query.jwt':\n return handleQueryJwt(responseEndpoint, authResponse, state);\n case 'fragment.jwt':\n return handleFragmentJwt(responseEndpoint, authResponse, state);\n case 'form_post.jwt':\n throw new Error('Not implemented. form_post.jwt is not yet supported.');\n }\n};\n\nasync function handleDirectPostJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const response = await fetch(responseEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: `response=${responseJwt}&state=${state}`,\n });\n return response;\n}\n\nasync function handleQueryJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendQueryParams({\n url: responseEndpoint,\n params: { response: responseJwt, state },\n });\n\n const response = await fetch(responseUrl, { method: 'POST' });\n return response;\n}\n\nasync function handleFragmentJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendFragmentParams({\n url: responseEndpoint,\n fragments: { response: responseJwt, state },\n });\n const response = await fetch(responseUrl, { method: 'POST' });\n return response;\n}\n","import * as v from 'valibot';\n\nimport { vJarmResponseMode, vOpenid4vpJarmResponseMode } from '../v-response-mode-registry.js';\nimport { vResponseType } from '../v-response-type-registry.js';\n\nimport type { JarmAuthResponseParams } from './v-jarm-auth-response-params.js';\nimport type { JarmDirectPostJwtResponseParams } from './v-jarm-direct-post-jwt-auth-response-params.js';\n\nexport const vAuthRequestParams = v.looseObject({\n state: v.optional(v.string()),\n response_mode: v.optional(v.union([vJarmResponseMode, vOpenid4vpJarmResponseMode])),\n client_id: v.string(),\n response_type: vResponseType,\n client_metadata: v.looseObject({\n jwks: v.optional(\n v.object({\n keys: v.array(v.looseObject({ kid: v.optional(v.string()), kty: v.string() })),\n }),\n ),\n jwks_uri: v.optional(v.string()),\n }),\n});\n\nexport type AuthRequestParams = v.InferInput<typeof vAuthRequestParams>;\n\nexport const vOAuthAuthRequestGetParamsOut = v.object({\n authRequestParams: vAuthRequestParams,\n});\n\nexport type OAuthAuthRequestGetParamsOut = v.InferOutput<typeof vOAuthAuthRequestGetParamsOut>;\n\nexport interface JarmDirectPostJwtAuthResponseValidationContext {\n openid4vp: {\n authRequest: {\n getParams: (input: JarmAuthResponseParams | JarmDirectPostJwtResponseParams) => Promise<OAuthAuthRequestGetParamsOut>;\n };\n };\n jwe: {\n decryptCompact: (input: { jwe: string; jwk: { kid: string } }) => Promise<{ plaintext: string }>;\n };\n}\n","import * as v from 'valibot';\n\nexport const oAuthResponseTypes = v.picklist(['code', 'token']);\n\n// NOTE: MAKE SURE THAT THE RESPONSE TYPES ARE SORTED CORRECTLY\nexport const oAuthMRTEPResponseTypes = v.picklist(['none', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token']);\n\nexport const openid4vpResponseTypes = v.picklist(['vp_token', 'id_token vp_token']);\n\nexport const vTransformedResponseTypes = v.picklist([\n ...openid4vpResponseTypes.options,\n ...oAuthResponseTypes.options,\n ...oAuthMRTEPResponseTypes.options,\n]);\n\nexport const vResponseType = v.pipe(\n v.string(),\n v.transform((val) => val.split(' ').sort().join(' ')),\n vTransformedResponseTypes,\n);\n\nexport type ResponseType = v.InferInput<typeof vTransformedResponseTypes>;\nexport type ResponseTypeOut = v.InferOutput<typeof vTransformedResponseTypes>;\n","import { decodeProtectedHeader, isJwe, isJws } from '@sphereon/oid4vc-common';\nimport * as v from 'valibot';\n\nimport type { JarmDirectPostJwtResponseParams } from '../index.js';\n\nimport type { AuthRequestParams, JarmDirectPostJwtAuthResponseValidationContext } from './c-jarm-auth-response.js';\nimport { vJarmAuthResponseErrorParams } from './v-jarm-auth-response-params.js';\nimport { jarmAuthResponseDirectPostValidateParams, vJarmDirectPostJwtParams } from './v-jarm-direct-post-jwt-auth-response-params.js';\n\nexport interface JarmDirectPostJwtAuthResponseValidation {\n /**\n * The JARM response parameter conveyed either as url query param, fragment param, or application/x-www-form-urlencoded in the body of a post request\n */\n response: string;\n}\n\nconst parseJarmAuthResponseParams = <Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(\n schema: Schema,\n responseParams: unknown,\n) => {\n if (v.is(vJarmAuthResponseErrorParams, responseParams)) {\n const errorResponseJson = JSON.stringify(responseParams, undefined, 2);\n throw new Error(`Received error response from authorization server. '${errorResponseJson}'`);\n }\n\n return v.parse(schema, responseParams);\n};\n\nconst decryptJarmAuthResponse = async (input: { response: string }, ctx: JarmDirectPostJwtAuthResponseValidationContext) => {\n const { response } = input;\n\n const responseProtectedHeader = decodeProtectedHeader(response);\n if (!responseProtectedHeader.kid) {\n throw new Error(`Jarm JWE is missing the protected header field 'kid'.`);\n }\n\n const { plaintext } = await ctx.jwe.decryptCompact({\n jwe: response,\n jwk: { kid: responseProtectedHeader.kid },\n });\n\n return plaintext;\n};\n\n/**\n * Validate a JARM direct_post.jwt compliant authentication response\n * * The decryption key should be resolvable using the the protected header's 'kid' field\n * * The signature verification jwk should be resolvable using the jws protected header's 'kid' field and the payload's 'iss' field.\n */\nexport const jarmAuthResponseDirectPostJwtValidate = async (\n input: JarmDirectPostJwtAuthResponseValidation,\n ctx: JarmDirectPostJwtAuthResponseValidationContext,\n) => {\n const { response } = input;\n\n const responseIsEncrypted = isJwe(response);\n const decryptedResponse = responseIsEncrypted ? await decryptJarmAuthResponse(input, ctx) : response;\n\n const responseIsSigned = isJws(decryptedResponse);\n if (!responseIsEncrypted && !responseIsSigned) {\n throw new Error('Jarm Auth Response must be either encrypted, signed, or signed and encrypted.');\n }\n\n let authResponseParams: JarmDirectPostJwtResponseParams;\n let authRequestParams: AuthRequestParams;\n\n if (responseIsSigned) {\n throw new Error('Signed JARM responses are not supported.');\n //const jwsProtectedHeader = decodeProtectedHeader(decryptedResponse);\n //const jwsPayload = decodeJwt(decryptedResponse);\n\n //const schema = v.required(vJarmDirectPostJwtParams, ['iss', 'aud', 'exp']);\n //const responseParams = parseJarmAuthResponseParams(schema, jwsPayload);\n //({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(responseParams));\n\n //if (!jwsProtectedHeader.kid) {\n //throw new Error(`Jarm JWS is missing the protected header field 'kid'.`);\n //}\n\n //await ctx.jose.jws.verifyJwt({\n //jws: decryptedResponse,\n //jwk: { kid: jwsProtectedHeader.kid, kty: 'auto' },\n //});\n //authResponseParams = responseParams;\n } else {\n const jsonResponse: unknown = JSON.parse(decryptedResponse);\n authResponseParams = parseJarmAuthResponseParams(vJarmDirectPostJwtParams, jsonResponse);\n ({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(authResponseParams));\n }\n\n jarmAuthResponseDirectPostValidateParams({\n authRequestParams,\n authResponseParams,\n });\n\n let type: 'signed encrypted' | 'encrypted' | 'signed';\n if (responseIsSigned && responseIsEncrypted) type = 'signed encrypted';\n else if (responseIsEncrypted) type = 'encrypted';\n else type = 'signed';\n\n return {\n authRequestParams,\n authResponseParams,\n type,\n };\n};\n","import { checkExp } from '@sphereon/oid4vc-common';\nimport * as v from 'valibot';\n\nexport const vJarmAuthResponseErrorParams = v.looseObject({\n error: v.string(),\n state: v.optional(v.string()),\n\n error_description: v.pipe(\n v.optional(v.string()),\n v.description('Text providing additional information, used to assist the client developer in understanding the error that occurred.'),\n ),\n\n error_uri: v.pipe(\n v.optional(v.pipe(v.string(), v.url())),\n v.description(\n 'A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error',\n ),\n ),\n});\n\nexport const vJarmAuthResponseParams = v.looseObject({\n state: v.optional(v.string()),\n\n /**\n * The issuer URL of the authorization server that created the response\n */\n iss: v.string(),\n\n /**\n * Expiration of the JWT\n */\n exp: v.number(),\n\n /**\n * The client_id of the client the response is intended for\n */\n aud: v.string(),\n});\n\nexport type JarmAuthResponseParams = v.InferInput<typeof vJarmAuthResponseParams>;\n\nexport const validateJarmAuthResponseParams = (input: {\n authRequestParams: { client_id: string; state?: string };\n authResponseParams: JarmAuthResponseParams;\n}) => {\n const { authRequestParams, authResponseParams } = input;\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch in jarm-auth-response. Expected '${authRequestParams.state}' received '${authRequestParams.state}'.`);\n }\n\n // 4. The client obtains the aud element from the JWT and checks whether it matches the client id the client used to identify itself in the corresponding authorization request. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.client_id !== authResponseParams.aud) {\n throw new Error(`Invalid audience in jarm-auth-response. Expected '${authRequestParams.client_id}' received '${authResponseParams.aud}'.`);\n }\n\n // 5. The client checks the JWT's exp element to determine if the JWT is still valid. If the check fails, the client MUST abort processing and refuse the response.\n // 120 seconds clock skew\n if (checkExp({ exp: authResponseParams.exp })) {\n throw new Error(`The '${authRequestParams.state}' and the jarm-auth-response.`);\n }\n};\n","import * as v from 'valibot';\n\nimport { vJarmAuthResponseParams } from './v-jarm-auth-response-params.js';\n\nexport const vJarmDirectPostJwtParams = v.looseObject({\n ...v.omit(vJarmAuthResponseParams, ['iss', 'aud', 'exp']).entries,\n ...v.partial(v.pick(vJarmAuthResponseParams, ['iss', 'aud', 'exp'])).entries,\n\n vp_token: v.union([v.string(), v.array(v.pipe(v.string(), v.nonEmpty()))]),\n presentation_submission: v.unknown(),\n nonce: v.optional(v.string()),\n});\n\nexport type JarmDirectPostJwtResponseParams = v.InferInput<typeof vJarmDirectPostJwtParams>;\n\nexport const jarmAuthResponseDirectPostValidateParams = (input: {\n authRequestParams: { state?: string };\n authResponseParams: JarmDirectPostJwtResponseParams;\n}) => {\n const { authRequestParams, authResponseParams } = input;\n\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch between auth request '${authRequestParams.state}' and the jarm-auth-response.`);\n }\n};\n","import * as v from 'valibot';\n\nexport const vJarmClientMetadataSign = v.object({\n authorization_signed_response_alg: v.pipe(\n v.optional(v.string()), // @default 'RS256' This makes no sense with openid4vp if just encrypted can be specified\n v.description(\n 'JWA. If this is specified, the response will be signed using JWS and the configured algorithm. The algorithm none is not allowed.',\n ),\n ),\n\n authorization_encrypted_response_alg: v.optional(v.never()),\n authorization_encrypted_response_enc: v.optional(v.never()),\n});\n\nexport const vJarmClientMetadataEncrypt = v.object({\n authorization_signed_response_alg: v.optional(v.never()),\n authorization_encrypted_response_alg: v.pipe(\n v.string(),\n v.description(\n 'JWE alg algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n\n authorization_encrypted_response_enc: v.pipe(\n v.optional(v.string(), 'A128CBC-HS256'),\n v.description(\n 'JWE enc algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n});\n\nexport const vJarmClientMetadataSignEncrypt = v.object({\n ...v.pick(vJarmClientMetadataSign, ['authorization_signed_response_alg']).entries,\n ...v.pick(vJarmClientMetadataEncrypt, ['authorization_encrypted_response_alg', 'authorization_encrypted_response_enc']).entries,\n});\n\n/**\n * Clients may register their public encryption keys using the jwks_uri or jwks metadata parameters.\n */\nexport const vJarmClientMetadata = v.union([vJarmClientMetadataSign, vJarmClientMetadataEncrypt, vJarmClientMetadataSignEncrypt]);\n\nexport type JarmClientMetadata = v.InferInput<typeof vJarmClientMetadata>;\n","import * as v from 'valibot';\n\n/**\n * Authorization servers SHOULD publish the supported algorithms for signing and encrypting the JWT of an authorization response by utilizing OAuth 2.0 Authorization Server Metadata [RFC8414] parameters.\n */\nexport const vJarmServerMetadata = v.object({\n authorization_signing_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWS [RFC7515] signing algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to sign the response.',\n ),\n ),\n\n authorization_encryption_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n\n authorization_encryption_enc_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (enc values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n});\n\nexport type JarmServerMetadata = v.InferInput<typeof vJarmServerMetadata>;\n","import * as v from 'valibot';\n\nimport {\n vJarmClientMetadata,\n vJarmClientMetadataEncrypt,\n vJarmClientMetadataSign,\n vJarmClientMetadataSignEncrypt,\n} from '../metadata/v-jarm-client-metadata.js';\nimport { vJarmServerMetadata } from '../metadata/v-jarm-server-metadata.js';\nimport { assertValueSupported } from '../utils.js';\n\nexport const vJarmAuthResponseValidateMetadataInput = v.object({\n client_metadata: vJarmClientMetadata,\n server_metadata: v.partial(vJarmServerMetadata),\n});\nexport type JarmMetadataValidate = v.InferInput<typeof vJarmAuthResponseValidateMetadataInput>;\n\nexport const vJarmMetadataValidateOut = v.variant('type', [\n v.object({\n type: v.literal('signed'),\n client_metadata: vJarmClientMetadataSign,\n }),\n v.object({\n type: v.literal('encrypted'),\n client_metadata: vJarmClientMetadataEncrypt,\n }),\n v.object({\n type: v.literal('signed encrypted'),\n client_metadata: vJarmClientMetadataSignEncrypt,\n }),\n]);\n\nexport const jarmMetadataValidate = (vJarmMetadataValidate: JarmMetadataValidate): v.InferOutput<typeof vJarmMetadataValidateOut> => {\n const { client_metadata, server_metadata } = vJarmMetadataValidate;\n const { authorization_encrypted_response_alg, authorization_encrypted_response_enc, authorization_signed_response_alg } = client_metadata;\n\n assertValueSupported({\n supported: server_metadata.authorization_signing_alg_values_supported ?? [],\n actual: authorization_signed_response_alg,\n required: !!authorization_signed_response_alg,\n error: new Error('Invalid authorization_signed_response_alg'),\n });\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_alg_values_supported ?? [],\n actual: authorization_encrypted_response_alg,\n required: !!authorization_encrypted_response_alg,\n error: new Error('Invalid authorization_encrypted_response_alg'),\n });\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_enc_values_supported ?? [],\n actual: authorization_encrypted_response_enc,\n required: !!authorization_encrypted_response_enc,\n error: new Error('Invalid authorization_encrypted_response_enc'),\n });\n\n if (authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'signed encrypted',\n client_metadata: {\n authorization_signed_response_alg,\n authorization_encrypted_response_alg,\n authorization_encrypted_response_enc,\n },\n };\n } else if (authorization_signed_response_alg && !authorization_encrypted_response_alg && !authorization_encrypted_response_enc) {\n return {\n type: 'signed',\n client_metadata: { authorization_signed_response_alg },\n };\n } else if (!authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'encrypted',\n client_metadata: { authorization_encrypted_response_alg, authorization_encrypted_response_enc },\n };\n } else {\n throw new Error(`Invalid jarm client_metadata combination`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;ACAO,SAASA,kBAAkBC,OAAsE;AACtG,QAAM,EAAEC,KAAAA,MAAKC,OAAM,IAAKF;AAGxB,aAAW,CAACG,KAAKC,KAAAA,KAAUC,OAAOC,QAAQJ,MAAAA,GAAS;AACjDD,IAAAA,KAAIM,aAAaC,OAAOL,KAAKM,mBAAmBL,KAAAA,CAAAA;EAClD;AAEA,SAAOH;AACT;AATgBF;AAWT,SAASW,qBAAqBV,OAAyE;AAC5G,QAAM,EAAEC,KAAAA,MAAKU,UAAS,IAAKX;AAG3B,QAAMY,iBAAiB,IAAIC,gBAAgBZ,KAAIa,KAAKC,MAAM,CAAA,CAAA;AAG1D,aAAW,CAACZ,KAAKC,KAAAA,KAAUC,OAAOC,QAAQK,SAAAA,GAAY;AACpDC,mBAAeJ,OAAOL,KAAKM,mB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AEgB;MAAkC;IACvD;EACF,WAAW,CAACA,qCAAqCF,wCAAwCC,sCAAsC;AAC7H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEc;QAAsCC;MAAqC;IAChG;EACF,OAAO;AACL,UAAM,IAAIQ,MAAM,0CAA0C;EAC5D;AACF,GA/CoC;","names":["appendQueryParams","input","url","params","key","value","Object","entries","searchParams","append","encodeURIComponent","appendFragmentParams","fragments","fragmentParams","URLSearchParams","hash","slice","toString","assertValueSupported","required","error","supported","actual","intersection","find","vJarmResponseMode","picklist","vOpenid4vpResponseMode","vOpenid4vpJarmResponseMode","vResponseMode","pipe","options","description","getDisAllowedResponseModes","input","response_type","undefined","getDefaultResponseMode","getJarmDefaultResponseMode","responseMode","validateResponseMode","disallowedResponseModes","includes","response_mode","Error","jarmAuthResponseSend","input","authRequestParams","authResponse","state","responseEndpoint","URL","response_uri","redirect_uri","responseMode","response_mode","getJarmDefaultResponseMode","validateResponseMode","response_type","handleDirectPostJwt","handleQueryJwt","handleFragmentJwt","Error","responseJwt","response","fetch","method","headers","body","responseUrl","appendQueryParams","url","params","appendFragmentParams","fragments","v","v","oAuthResponseTypes","picklist","oAuthMRTEPResponseTypes","openid4vpResponseTypes","vTransformedResponseTypes","options","vResponseType","pipe","string","transform","val","split","sort","join","vAuthRequestParams","looseObject","state","optional","string","response_mode","union","vJarmResponseMode","vOpenid4vpJarmResponseMode","client_id","response_type","vResponseType","client_metadata","jwks","object","keys","array","kid","kty","jwks_uri","vOAuthAuthRequestGetParamsOut","authRequestParams","import_oid4vc_common","v","v","vJarmAuthResponseErrorParams","looseObject","error","string","state","optional","error_description","pipe","description","error_uri","url","vJarmAuthResponseParams","iss","exp","number","aud","validateJarmAuthResponseParams","input","authRequestParams","authResponseParams","Error","client_id","checkExp","v","vJarmDirectPostJwtParams","looseObject","omit","vJarmAuthResponseParams","entries","partial","pick","vp_token","union","string","array","pipe","nonEmpty","presentation_submission","unknown","nonce","optional","jarmAuthResponseDirectPostValidateParams","input","authRequestParams","authResponseParams","state","Error","parseJarmAuthResponseParams","schema","responseParams","is","vJarmAuthResponseErrorParams","errorResponseJson","JSON","stringify","undefined","Error","parse","decryptJarmAuthResponse","input","ctx","response","responseProtectedHeader","decodeProtectedHeader","kid","plaintext","jwe","decryptCompact","jwk","jarmAuthResponseDirectPostJwtValidate","responseIsEncrypted","isJwe","decryptedResponse","responseIsSigned","isJws","authResponseParams","authRequestParams","jsonResponse","vJarmDirectPostJwtParams","openid4vp","authRequest","getParams","jarmAuthResponseDirectPostValidateParams","type","v","vJarmClientMetadataSign","object","authorization_signed_response_alg","pipe","optional","string","description","authorization_encrypted_response_alg","never","authorization_encrypted_response_enc","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","pick","entries","vJarmClientMetadata","union","v","vJarmServerMetadata","object","authorization_signing_alg_values_supported","pipe","array","string","description","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported","v","vJarmAuthResponseValidateMetadataInput","object","client_metadata","vJarmClientMetadata","server_metadata","partial","vJarmServerMetadata","vJarmMetadataValidateOut","variant","type","literal","vJarmClientMetadataSign","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","jarmMetadataValidate","vJarmMetadataValidate","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","assertValueSupported","supported","authorization_signing_alg_values_supported","actual","required","error","Error","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts","../lib/utils.ts","../lib/v-response-mode-registry.ts","../lib/jarm-auth-response-send/jarm-auth-response-send.ts","../lib/jarm-auth-response/c-jarm-auth-response.ts","../lib/v-response-type-registry.ts","../lib/jarm-auth-response/jarm-auth-response.ts","../lib/jarm-auth-response/v-jarm-auth-response-params.ts","../lib/jarm-auth-response/v-jarm-direct-post-jwt-auth-response-params.ts","../lib/metadata/v-jarm-client-metadata.ts","../lib/metadata/v-jarm-server-metadata.ts","../lib/metadata/jarm-validate-metadata.ts"],"sourcesContent":["export * from './jarm-auth-response-send'\nexport * from './jarm-auth-response'\nexport * from './metadata'\n","export function appendQueryParams(input: { url: URL; params: Record<string, string | number | boolean> }) {\n const { url, params } = input\n\n // Append the new query parameters from the params object\n for (const [key, value] of Object.entries(params)) {\n url.searchParams.append(key, encodeURIComponent(value))\n }\n\n return url\n}\n\nexport function appendFragmentParams(input: { url: URL; fragments: Record<string, string | number | boolean> }) {\n const { url, fragments } = input\n\n // Convert existing fragment to an object and remove the leading '#'\n const fragmentParams = new URLSearchParams(url.hash.slice(1)) // Remove the leading '#' from the fragment\n\n // Append the new fragments from the fragments object\n for (const [key, value] of Object.entries(fragments)) {\n fragmentParams.append(key, encodeURIComponent(value))\n }\n\n // Rebuild the fragment string and assign it to the URL\n url.hash = fragmentParams.toString()\n\n return url\n}\n\ninterface AssertValueSupported<T> {\n supported: T[]\n actual: T\n error: Error\n required: boolean\n}\n\nexport function assertValueSupported<T>(input: AssertValueSupported<T>): T | undefined {\n const { required, error, supported, actual } = input\n const intersection = supported.find((value) => value === actual)\n\n if (required && !intersection) throw error\n return intersection\n}\n","import * as v from 'valibot'\n\nimport type { ResponseTypeOut } from './v-response-type-registry'\n\nexport const vJarmResponseMode = v.picklist(['jwt', 'query.jwt', 'fragment.jwt', 'form_post.jwt'])\nexport type JarmResponseMode = v.InferInput<typeof vJarmResponseMode>\n\nexport const vOpenid4vpResponseMode = v.picklist(['direct_post'])\nexport type Openid4vpResponseMode = v.InferInput<typeof vOpenid4vpResponseMode>\n\n/**\n * * 'direct_post.jwt' The response is send as HTTP POST request using the application/x-www-form-urlencoded content type. The body contains a single parameter response which is the JWT encoded Response as defined in JARM 4.1\n */\nexport const vOpenid4vpJarmResponseMode = v.picklist(['direct_post.jwt'])\nexport type Openid4vpJarmResponseMode = v.InferInput<typeof vOpenid4vpJarmResponseMode>\n\n/**\n * The use of this parameter is NOT RECOMMENDED when the Response Mode that would be requested is the default mode specified for the Response Type.\n * * 'query' In this mode, Authorization Response parameters are encoded in the query string added to the redirect_uri when redirecting back to the Client.\n * * 'fragment' In this mode, Authorization Response parameters are encoded in the fragment added to the redirect_uri when redirecting back to the Client.\n * * 'direct_post' the Authorization Response is send to an endpoint controlled by the Verifier via an HTTP POST request.\n */\nexport const vResponseMode = v.pipe(\n v.picklist(['query', 'fragment', ...vOpenid4vpResponseMode.options, ...vJarmResponseMode.options, ...vOpenid4vpJarmResponseMode.options]),\n v.description('Informs the Authorization Server of the mechanism to be used for returning parameters from the Authorization Endpoint.'),\n)\nexport type ResponseMode = v.InferInput<typeof vResponseMode>\n\nconst getDisAllowedResponseModes = (input: { response_type: ResponseTypeOut }): [ResponseMode, ...ResponseMode[]] | undefined => {\n const { response_type } = input\n\n switch (response_type) {\n case 'code token':\n return ['query']\n case 'code id_token':\n return ['query']\n case 'id_token token':\n return ['query']\n case 'code id_token token':\n return ['query']\n }\n return undefined\n}\n\nexport const getDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query' | 'fragment' => {\n const { response_type } = input\n\n switch (response_type) {\n case 'code':\n case 'none':\n return 'query'\n case 'token':\n case 'id_token':\n case 'code token':\n case 'code id_token':\n case 'id_token token':\n case 'code id_token token':\n case 'vp_token':\n case 'id_token vp_token':\n return 'fragment'\n }\n}\n\nexport const getJarmDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query.jwt' | 'fragment.jwt' => {\n const responseMode = getDefaultResponseMode(input)\n\n switch (responseMode) {\n case 'query':\n return 'query.jwt'\n case 'fragment':\n return 'fragment.jwt'\n }\n}\n\nexport const validateResponseMode = (input: { response_type: ResponseTypeOut; response_mode: ResponseMode }) => {\n const disallowedResponseModes = getDisAllowedResponseModes(input)\n\n if (disallowedResponseModes?.includes(input.response_mode)) {\n throw new Error(`Response_type '${input.response_type}' is not compatible with response_mode '${input.response_mode}'.`)\n }\n}\n","import { appendFragmentParams, appendQueryParams } from '../utils'\nimport type { JarmResponseMode, Openid4vpJarmResponseMode } from '../v-response-mode-registry'\nimport { getJarmDefaultResponseMode, validateResponseMode } from '../v-response-mode-registry'\nimport type { ResponseTypeOut } from '../v-response-type-registry'\n\ninterface JarmAuthResponseSendInput {\n authRequestParams: {\n response_mode?: JarmResponseMode | Openid4vpJarmResponseMode\n response_type: ResponseTypeOut\n } & (\n | {\n response_uri: string\n }\n | {\n redirect_uri: string\n }\n )\n\n authResponse: string\n state: string\n}\n\nexport const jarmAuthResponseSend = async (input: JarmAuthResponseSendInput): Promise<Response> => {\n const { authRequestParams, authResponse, state } = input\n\n const responseEndpoint = 'response_uri' in authRequestParams ? new URL(authRequestParams.response_uri) : new URL(authRequestParams.redirect_uri)\n\n const responseMode =\n authRequestParams.response_mode && authRequestParams.response_mode !== 'jwt'\n ? authRequestParams.response_mode\n : getJarmDefaultResponseMode(authRequestParams)\n\n validateResponseMode({\n response_type: authRequestParams.response_type,\n response_mode: responseMode,\n })\n\n switch (responseMode) {\n case 'direct_post.jwt':\n return handleDirectPostJwt(responseEndpoint, authResponse, state)\n case 'query.jwt':\n return handleQueryJwt(responseEndpoint, authResponse, state)\n case 'fragment.jwt':\n return handleFragmentJwt(responseEndpoint, authResponse, state)\n case 'form_post.jwt':\n throw new Error('Not implemented. form_post.jwt is not yet supported.')\n }\n}\n\nasync function handleDirectPostJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const response = await fetch(responseEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: `response=${responseJwt}&state=${state}`,\n })\n return response\n}\n\nasync function handleQueryJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendQueryParams({\n url: responseEndpoint,\n params: { response: responseJwt, state },\n })\n\n const response = await fetch(responseUrl, { method: 'POST' })\n return response\n}\n\nasync function handleFragmentJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendFragmentParams({\n url: responseEndpoint,\n fragments: { response: responseJwt, state },\n })\n const response = await fetch(responseUrl, { method: 'POST' })\n return response\n}\n","import * as v from 'valibot'\n\nimport { vJarmResponseMode, vOpenid4vpJarmResponseMode } from '../v-response-mode-registry'\nimport { vResponseType } from '../v-response-type-registry'\n\nimport type { JarmAuthResponseParams } from './v-jarm-auth-response-params'\nimport type { JarmDirectPostJwtResponseParams } from './v-jarm-direct-post-jwt-auth-response-params'\n\nexport const vAuthRequestParams = v.looseObject({\n state: v.optional(v.string()),\n response_mode: v.optional(v.union([vJarmResponseMode, vOpenid4vpJarmResponseMode])),\n client_id: v.string(),\n response_type: vResponseType,\n client_metadata: v.looseObject({\n jwks: v.optional(\n v.object({\n keys: v.array(v.looseObject({ kid: v.optional(v.string()), kty: v.string() })),\n }),\n ),\n jwks_uri: v.optional(v.string()),\n }),\n})\n\nexport type AuthRequestParams = v.InferInput<typeof vAuthRequestParams>\n\nexport const vOAuthAuthRequestGetParamsOut = v.object({\n authRequestParams: vAuthRequestParams,\n})\n\nexport type OAuthAuthRequestGetParamsOut = v.InferOutput<typeof vOAuthAuthRequestGetParamsOut>\n\nexport interface JarmDirectPostJwtAuthResponseValidationContext {\n openid4vp: {\n authRequest: {\n getParams: (input: JarmAuthResponseParams | JarmDirectPostJwtResponseParams) => Promise<OAuthAuthRequestGetParamsOut>\n }\n }\n jwe: {\n decryptCompact: (input: { jwe: string; jwk: { kid: string } }) => Promise<{ plaintext: string }>\n }\n}\n","import * as v from 'valibot'\n\nexport const oAuthResponseTypes = v.picklist(['code', 'token'])\n\n// NOTE: MAKE SURE THAT THE RESPONSE TYPES ARE SORTED CORRECTLY\nexport const oAuthMRTEPResponseTypes = v.picklist(['none', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token'])\n\nexport const openid4vpResponseTypes = v.picklist(['vp_token', 'id_token vp_token'])\n\nexport const vTransformedResponseTypes = v.picklist([\n ...openid4vpResponseTypes.options,\n ...oAuthResponseTypes.options,\n ...oAuthMRTEPResponseTypes.options,\n])\n\nexport const vResponseType = v.pipe(\n v.string(),\n v.transform((val) => val.split(' ').sort().join(' ')),\n vTransformedResponseTypes,\n)\n\nexport type ResponseType = v.InferInput<typeof vTransformedResponseTypes>\nexport type ResponseTypeOut = v.InferOutput<typeof vTransformedResponseTypes>\n","import { decodeProtectedHeader, isJwe, isJws } from '@sphereon/oid4vc-common'\nimport * as v from 'valibot'\n\nimport type { AuthRequestParams, JarmDirectPostJwtAuthResponseValidationContext } from './c-jarm-auth-response'\nimport { vJarmAuthResponseErrorParams } from './v-jarm-auth-response-params'\nimport {\n jarmAuthResponseDirectPostValidateParams,\n JarmDirectPostJwtResponseParams,\n vJarmDirectPostJwtParams,\n} from './v-jarm-direct-post-jwt-auth-response-params'\n\nexport interface JarmDirectPostJwtAuthResponseValidation {\n /**\n * The JARM response parameter conveyed either as url query param, fragment param, or application/x-www-form-urlencoded in the body of a post request\n */\n response: string\n}\n\nconst parseJarmAuthResponseParams = <Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(\n schema: Schema,\n responseParams: unknown,\n) => {\n if (v.is(vJarmAuthResponseErrorParams, responseParams)) {\n const errorResponseJson = JSON.stringify(responseParams, undefined, 2)\n throw new Error(`Received error response from authorization server. '${errorResponseJson}'`)\n }\n\n return v.parse(schema, responseParams)\n}\n\nconst decryptJarmAuthResponse = async (input: { response: string }, ctx: JarmDirectPostJwtAuthResponseValidationContext) => {\n const { response } = input\n\n const responseProtectedHeader = decodeProtectedHeader(response)\n if (!responseProtectedHeader.kid) {\n throw new Error(`Jarm JWE is missing the protected header field 'kid'.`)\n }\n\n const { plaintext } = await ctx.jwe.decryptCompact({\n jwe: response,\n jwk: { kid: responseProtectedHeader.kid },\n })\n\n return plaintext\n}\n\n/**\n * Validate a JARM direct_post.jwt compliant authentication response\n * * The decryption key should be resolvable using the the protected header's 'kid' field\n * * The signature verification jwk should be resolvable using the jws protected header's 'kid' field and the payload's 'iss' field.\n */\nexport const jarmAuthResponseDirectPostJwtValidate = async (\n input: JarmDirectPostJwtAuthResponseValidation,\n ctx: JarmDirectPostJwtAuthResponseValidationContext,\n) => {\n const { response } = input\n\n const responseIsEncrypted = isJwe(response)\n const decryptedResponse = responseIsEncrypted ? await decryptJarmAuthResponse(input, ctx) : response\n\n const responseIsSigned = isJws(decryptedResponse)\n if (!responseIsEncrypted && !responseIsSigned) {\n throw new Error('Jarm Auth Response must be either encrypted, signed, or signed and encrypted.')\n }\n\n let authResponseParams: JarmDirectPostJwtResponseParams\n let authRequestParams: AuthRequestParams\n\n if (responseIsSigned) {\n throw new Error('Signed JARM responses are not supported.')\n //const jwsProtectedHeader = decodeProtectedHeader(decryptedResponse);\n //const jwsPayload = decodeJwt(decryptedResponse);\n\n //const schema = v.required(vJarmDirectPostJwtParams, ['iss', 'aud', 'exp']);\n //const responseParams = parseJarmAuthResponseParams(schema, jwsPayload);\n //({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(responseParams));\n\n //if (!jwsProtectedHeader.kid) {\n //throw new Error(`Jarm JWS is missing the protected header field 'kid'.`);\n //}\n\n //await ctx.jose.jws.verifyJwt({\n //jws: decryptedResponse,\n //jwk: { kid: jwsProtectedHeader.kid, kty: 'auto' },\n //});\n //authResponseParams = responseParams;\n } else {\n const jsonResponse: unknown = JSON.parse(decryptedResponse)\n authResponseParams = parseJarmAuthResponseParams(vJarmDirectPostJwtParams, jsonResponse)\n ;({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(authResponseParams))\n }\n\n jarmAuthResponseDirectPostValidateParams({\n authRequestParams,\n authResponseParams,\n })\n\n let type: 'signed encrypted' | 'encrypted' | 'signed'\n if (responseIsSigned && responseIsEncrypted) type = 'signed encrypted'\n else if (responseIsEncrypted) type = 'encrypted'\n else type = 'signed'\n\n return {\n authRequestParams,\n authResponseParams,\n type,\n }\n}\n","import { checkExp } from '@sphereon/oid4vc-common'\nimport * as v from 'valibot'\n\nexport const vJarmAuthResponseErrorParams = v.looseObject({\n error: v.string(),\n state: v.optional(v.string()),\n\n error_description: v.pipe(\n v.optional(v.string()),\n v.description('Text providing additional information, used to assist the client developer in understanding the error that occurred.'),\n ),\n\n error_uri: v.pipe(\n v.optional(v.pipe(v.string(), v.url())),\n v.description(\n 'A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error',\n ),\n ),\n})\n\nexport const vJarmAuthResponseParams = v.looseObject({\n state: v.optional(v.string()),\n\n /**\n * The issuer URL of the authorization server that created the response\n */\n iss: v.string(),\n\n /**\n * Expiration of the JWT\n */\n exp: v.number(),\n\n /**\n * The client_id of the client the response is intended for\n */\n aud: v.string(),\n})\n\nexport type JarmAuthResponseParams = v.InferInput<typeof vJarmAuthResponseParams>\n\nexport const validateJarmAuthResponseParams = (input: {\n authRequestParams: { client_id: string; state?: string }\n authResponseParams: JarmAuthResponseParams\n}) => {\n const { authRequestParams, authResponseParams } = input\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch in jarm-auth-response. Expected '${authRequestParams.state}' received '${authRequestParams.state}'.`)\n }\n\n // 4. The client obtains the aud element from the JWT and checks whether it matches the client id the client used to identify itself in the corresponding authorization request. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.client_id !== authResponseParams.aud) {\n throw new Error(`Invalid audience in jarm-auth-response. Expected '${authRequestParams.client_id}' received '${authResponseParams.aud}'.`)\n }\n\n // 5. The client checks the JWT's exp element to determine if the JWT is still valid. If the check fails, the client MUST abort processing and refuse the response.\n // 120 seconds clock skew\n if (checkExp({ exp: authResponseParams.exp })) {\n throw new Error(`The '${authRequestParams.state}' and the jarm-auth-response.`)\n }\n}\n","import * as v from 'valibot'\n\nimport { vJarmAuthResponseParams } from './v-jarm-auth-response-params'\n\nexport const vJarmDirectPostJwtParams = v.looseObject({\n ...v.omit(vJarmAuthResponseParams, ['iss', 'aud', 'exp']).entries,\n ...v.partial(v.pick(vJarmAuthResponseParams, ['iss', 'aud', 'exp'])).entries,\n\n vp_token: v.union([v.string(), v.array(v.pipe(v.string(), v.nonEmpty()))]),\n presentation_submission: v.unknown(),\n nonce: v.optional(v.string()),\n})\n\nexport type JarmDirectPostJwtResponseParams = v.InferInput<typeof vJarmDirectPostJwtParams>\n\nexport const jarmAuthResponseDirectPostValidateParams = (input: {\n authRequestParams: { state?: string }\n authResponseParams: JarmDirectPostJwtResponseParams\n}) => {\n const { authRequestParams, authResponseParams } = input\n\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch between auth request '${authRequestParams.state}' and the jarm-auth-response.`)\n }\n}\n","import * as v from 'valibot'\n\nexport const vJarmClientMetadataSign = v.object({\n authorization_signed_response_alg: v.pipe(\n v.optional(v.string()), // @default 'RS256' This makes no sense with openid4vp if just encrypted can be specified\n v.description(\n 'JWA. If this is specified, the response will be signed using JWS and the configured algorithm. The algorithm none is not allowed.',\n ),\n ),\n\n authorization_encrypted_response_alg: v.optional(v.never()),\n authorization_encrypted_response_enc: v.optional(v.never()),\n})\n\nexport const vJarmClientMetadataEncrypt = v.object({\n authorization_signed_response_alg: v.optional(v.never()),\n authorization_encrypted_response_alg: v.pipe(\n v.string(),\n v.description(\n 'JWE alg algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n\n authorization_encrypted_response_enc: v.pipe(\n v.optional(v.string(), 'A128CBC-HS256'),\n v.description(\n 'JWE enc algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n})\n\nexport const vJarmClientMetadataSignEncrypt = v.object({\n ...v.pick(vJarmClientMetadataSign, ['authorization_signed_response_alg']).entries,\n ...v.pick(vJarmClientMetadataEncrypt, ['authorization_encrypted_response_alg', 'authorization_encrypted_response_enc']).entries,\n})\n\n/**\n * Clients may register their public encryption keys using the jwks_uri or jwks metadata parameters.\n */\nexport const vJarmClientMetadata = v.union([vJarmClientMetadataSign, vJarmClientMetadataEncrypt, vJarmClientMetadataSignEncrypt])\n\nexport type JarmClientMetadata = v.InferInput<typeof vJarmClientMetadata>\n","import * as v from 'valibot'\n\n/**\n * Authorization servers SHOULD publish the supported algorithms for signing and encrypting the JWT of an authorization response by utilizing OAuth 2.0 Authorization Server Metadata [RFC8414] parameters.\n */\nexport const vJarmServerMetadata = v.object({\n authorization_signing_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWS [RFC7515] signing algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to sign the response.',\n ),\n ),\n\n authorization_encryption_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n\n authorization_encryption_enc_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (enc values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n})\n\nexport type JarmServerMetadata = v.InferInput<typeof vJarmServerMetadata>\n","import * as v from 'valibot'\n\nimport {\n vJarmClientMetadata,\n vJarmClientMetadataEncrypt,\n vJarmClientMetadataSign,\n vJarmClientMetadataSignEncrypt,\n} from '../metadata/v-jarm-client-metadata'\nimport { vJarmServerMetadata } from '../metadata/v-jarm-server-metadata'\nimport { assertValueSupported } from '../utils'\n\nexport const vJarmAuthResponseValidateMetadataInput = v.object({\n client_metadata: vJarmClientMetadata,\n server_metadata: v.partial(vJarmServerMetadata),\n})\nexport type JarmMetadataValidate = v.InferInput<typeof vJarmAuthResponseValidateMetadataInput>\n\nexport const vJarmMetadataValidateOut = v.variant('type', [\n v.object({\n type: v.literal('signed'),\n client_metadata: vJarmClientMetadataSign,\n }),\n v.object({\n type: v.literal('encrypted'),\n client_metadata: vJarmClientMetadataEncrypt,\n }),\n v.object({\n type: v.literal('signed encrypted'),\n client_metadata: vJarmClientMetadataSignEncrypt,\n }),\n])\n\nexport const jarmMetadataValidate = (vJarmMetadataValidate: JarmMetadataValidate): v.InferOutput<typeof vJarmMetadataValidateOut> => {\n const { client_metadata, server_metadata } = vJarmMetadataValidate\n const { authorization_encrypted_response_alg, authorization_encrypted_response_enc, authorization_signed_response_alg } = client_metadata\n\n assertValueSupported({\n supported: server_metadata.authorization_signing_alg_values_supported ?? [],\n actual: authorization_signed_response_alg,\n required: !!authorization_signed_response_alg,\n error: new Error('Invalid authorization_signed_response_alg'),\n })\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_alg_values_supported ?? [],\n actual: authorization_encrypted_response_alg,\n required: !!authorization_encrypted_response_alg,\n error: new Error('Invalid authorization_encrypted_response_alg'),\n })\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_enc_values_supported ?? [],\n actual: authorization_encrypted_response_enc,\n required: !!authorization_encrypted_response_enc,\n error: new Error('Invalid authorization_encrypted_response_enc'),\n })\n\n if (authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'signed encrypted',\n client_metadata: {\n authorization_signed_response_alg,\n authorization_encrypted_response_alg,\n authorization_encrypted_response_enc,\n },\n }\n } else if (authorization_signed_response_alg && !authorization_encrypted_response_alg && !authorization_encrypted_response_enc) {\n return {\n type: 'signed',\n client_metadata: { authorization_signed_response_alg },\n }\n } else if (!authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'encrypted',\n client_metadata: { authorization_encrypted_response_alg, authorization_encrypted_response_enc },\n }\n } else {\n throw new Error(`Invalid jarm client_metadata combination`)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;ACAO,SAASA,kBAAkBC,OAAsE;AACtG,QAAM,EAAEC,KAAAA,MAAKC,OAAM,IAAKF;AAGxB,aAAW,CAACG,KAAKC,KAAAA,KAAUC,OAAOC,QAAQJ,MAAAA,GAAS;AACjDD,IAAAA,KA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,uBAAqB;IACnBC,WAAWhB,gBAAgBuB,iDAAiD,CAAA;IAC5EL,QAAQL;IACRM,UAAU,CAAC,CAACN;IACZO,OAAO,IAAIC,MAAM,8CAAA;EACnB,CAAA;AAEA,MAAIP,qCAAqCF,wCAAwCC,sCAAsC;AACrH,WAAO;MACLR,MAAM;MACNP,iBAAiB;QACfgB;QACAF;QACAC;MACF;IACF;EACF,WAAWC,qCAAqC,CAACF,wCAAwC,CAACC,sCAAsC;AAC9H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEgB;MAAkC;IACvD;EACF,WAAW,CAACA,qCAAqCF,wCAAwCC,sCAAsC;AAC7H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEc;QAAsCC;MAAqC;IAChG;EACF,OAAO;AACL,UAAM,IAAIQ,MAAM,0CAA0C;EAC5D;AACF,GA/CoC;","names":["appendQueryParams","input","url","params","key","value","Object","entries","searchParams","append","encodeURIComponent","appendFragmentParams","fragments","fragmentParams","URLSearchParams","hash","slice","toString","assertValueSupported","required","error","supported","actual","intersection","find","vJarmResponseMode","picklist","vOpenid4vpResponseMode","vOpenid4vpJarmResponseMode","vResponseMode","pipe","options","description","getDisAllowedResponseModes","input","response_type","undefined","getDefaultResponseMode","getJarmDefaultResponseMode","responseMode","validateResponseMode","disallowedResponseModes","includes","response_mode","Error","jarmAuthResponseSend","input","authRequestParams","authResponse","state","responseEndpoint","URL","response_uri","redirect_uri","responseMode","response_mode","getJarmDefaultResponseMode","validateResponseMode","response_type","handleDirectPostJwt","handleQueryJwt","handleFragmentJwt","Error","responseJwt","response","fetch","method","headers","body","responseUrl","appendQueryParams","url","params","appendFragmentParams","fragments","v","v","oAuthResponseTypes","picklist","oAuthMRTEPResponseTypes","openid4vpResponseTypes","vTransformedResponseTypes","options","vResponseType","pipe","string","transform","val","split","sort","join","vAuthRequestParams","looseObject","state","optional","string","response_mode","union","vJarmResponseMode","vOpenid4vpJarmResponseMode","client_id","response_type","vResponseType","client_metadata","jwks","object","keys","array","kid","kty","jwks_uri","vOAuthAuthRequestGetParamsOut","authRequestParams","import_oid4vc_common","v","v","vJarmAuthResponseErrorParams","looseObject","error","string","state","optional","error_description","pipe","description","error_uri","url","vJarmAuthResponseParams","iss","exp","number","aud","validateJarmAuthResponseParams","input","authRequestParams","authResponseParams","Error","client_id","checkExp","v","vJarmDirectPostJwtParams","looseObject","omit","vJarmAuthResponseParams","entries","partial","pick","vp_token","union","string","array","pipe","nonEmpty","presentation_submission","unknown","nonce","optional","jarmAuthResponseDirectPostValidateParams","input","authRequestParams","authResponseParams","state","Error","parseJarmAuthResponseParams","schema","responseParams","is","vJarmAuthResponseErrorParams","errorResponseJson","JSON","stringify","undefined","Error","parse","decryptJarmAuthResponse","input","ctx","response","responseProtectedHeader","decodeProtectedHeader","kid","plaintext","jwe","decryptCompact","jwk","jarmAuthResponseDirectPostJwtValidate","responseIsEncrypted","isJwe","decryptedResponse","responseIsSigned","isJws","authResponseParams","authRequestParams","jsonResponse","vJarmDirectPostJwtParams","openid4vp","authRequest","getParams","jarmAuthResponseDirectPostValidateParams","type","v","vJarmClientMetadataSign","object","authorization_signed_response_alg","pipe","optional","string","description","authorization_encrypted_response_alg","never","authorization_encrypted_response_enc","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","pick","entries","vJarmClientMetadata","union","v","vJarmServerMetadata","object","authorization_signing_alg_values_supported","pipe","array","string","description","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported","v","vJarmAuthResponseValidateMetadataInput","object","client_metadata","vJarmClientMetadata","server_metadata","partial","vJarmServerMetadata","vJarmMetadataValidateOut","variant","type","literal","vJarmClientMetadataSign","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","jarmMetadataValidate","vJarmMetadataValidate","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","assertValueSupported","supported","authorization_signing_alg_values_supported","actual","required","error","Error","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/utils.ts","../lib/v-response-mode-registry.ts","../lib/jarm-auth-response-send/jarm-auth-response-send.ts","../lib/jarm-auth-response/c-jarm-auth-response.ts","../lib/v-response-type-registry.ts","../lib/jarm-auth-response/jarm-auth-response.ts","../lib/jarm-auth-response/v-jarm-auth-response-params.ts","../lib/jarm-auth-response/v-jarm-direct-post-jwt-auth-response-params.ts","../lib/metadata/v-jarm-client-metadata.ts","../lib/metadata/v-jarm-server-metadata.ts","../lib/metadata/jarm-validate-metadata.ts"],"sourcesContent":["export function appendQueryParams(input: { url: URL; params: Record<string, string | number | boolean> }) {\n const { url, params } = input;\n\n // Append the new query parameters from the params object\n for (const [key, value] of Object.entries(params)) {\n url.searchParams.append(key, encodeURIComponent(value));\n }\n\n return url;\n}\n\nexport function appendFragmentParams(input: { url: URL; fragments: Record<string, string | number | boolean> }) {\n const { url, fragments } = input;\n\n // Convert existing fragment to an object and remove the leading '#'\n const fragmentParams = new URLSearchParams(url.hash.slice(1)); // Remove the leading '#' from the fragment\n\n // Append the new fragments from the fragments object\n for (const [key, value] of Object.entries(fragments)) {\n fragmentParams.append(key, encodeURIComponent(value));\n }\n\n // Rebuild the fragment string and assign it to the URL\n url.hash = fragmentParams.toString();\n\n return url;\n}\n\ninterface AssertValueSupported<T> {\n supported: T[];\n actual: T;\n error: Error;\n required: boolean;\n}\n\nexport function assertValueSupported<T>(input: AssertValueSupported<T>): T | undefined {\n const { required, error, supported, actual } = input;\n const intersection = supported.find((value) => value === actual);\n\n if (required && !intersection) throw error;\n return intersection;\n}\n","import * as v from 'valibot';\n\nimport type { ResponseTypeOut } from './v-response-type-registry.js';\n\nexport const vJarmResponseMode = v.picklist(['jwt', 'query.jwt', 'fragment.jwt', 'form_post.jwt']);\nexport type JarmResponseMode = v.InferInput<typeof vJarmResponseMode>;\n\nexport const vOpenid4vpResponseMode = v.picklist(['direct_post']);\nexport type Openid4vpResponseMode = v.InferInput<typeof vOpenid4vpResponseMode>;\n\n/**\n * * 'direct_post.jwt' The response is send as HTTP POST request using the application/x-www-form-urlencoded content type. The body contains a single parameter response which is the JWT encoded Response as defined in JARM 4.1\n */\nexport const vOpenid4vpJarmResponseMode = v.picklist(['direct_post.jwt']);\nexport type Openid4vpJarmResponseMode = v.InferInput<typeof vOpenid4vpJarmResponseMode>;\n\n/**\n * The use of this parameter is NOT RECOMMENDED when the Response Mode that would be requested is the default mode specified for the Response Type.\n * * 'query' In this mode, Authorization Response parameters are encoded in the query string added to the redirect_uri when redirecting back to the Client.\n * * 'fragment' In this mode, Authorization Response parameters are encoded in the fragment added to the redirect_uri when redirecting back to the Client.\n * * 'direct_post' the Authorization Response is send to an endpoint controlled by the Verifier via an HTTP POST request.\n */\nexport const vResponseMode = v.pipe(\n v.picklist(['query', 'fragment', ...vOpenid4vpResponseMode.options, ...vJarmResponseMode.options, ...vOpenid4vpJarmResponseMode.options]),\n v.description('Informs the Authorization Server of the mechanism to be used for returning parameters from the Authorization Endpoint.'),\n);\nexport type ResponseMode = v.InferInput<typeof vResponseMode>;\n\nconst getDisAllowedResponseModes = (input: { response_type: ResponseTypeOut }): [ResponseMode, ...ResponseMode[]] | undefined => {\n const { response_type } = input;\n\n switch (response_type) {\n case 'code token':\n return ['query'];\n case 'code id_token':\n return ['query'];\n case 'id_token token':\n return ['query'];\n case 'code id_token token':\n return ['query'];\n }\n return undefined;\n};\n\nexport const getDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query' | 'fragment' => {\n const { response_type } = input;\n\n switch (response_type) {\n case 'code':\n case 'none':\n return 'query';\n case 'token':\n case 'id_token':\n case 'code token':\n case 'code id_token':\n case 'id_token token':\n case 'code id_token token':\n case 'vp_token':\n case 'id_token vp_token':\n return 'fragment';\n }\n};\n\nexport const getJarmDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query.jwt' | 'fragment.jwt' => {\n const responseMode = getDefaultResponseMode(input);\n\n switch (responseMode) {\n case 'query':\n return 'query.jwt';\n case 'fragment':\n return 'fragment.jwt';\n }\n};\n\nexport const validateResponseMode = (input: { response_type: ResponseTypeOut; response_mode: ResponseMode }) => {\n const disallowedResponseModes = getDisAllowedResponseModes(input);\n\n if (disallowedResponseModes?.includes(input.response_mode)) {\n throw new Error(`Response_type '${input.response_type}' is not compatible with response_mode '${input.response_mode}'.`);\n }\n};\n","import { appendFragmentParams, appendQueryParams } from '../utils.js';\nimport type { JarmResponseMode, Openid4vpJarmResponseMode } from '../v-response-mode-registry.js';\nimport { getJarmDefaultResponseMode, validateResponseMode } from '../v-response-mode-registry.js';\nimport type { ResponseTypeOut } from '../v-response-type-registry.js';\n\ninterface JarmAuthResponseSendInput {\n authRequestParams: {\n response_mode?: JarmResponseMode | Openid4vpJarmResponseMode;\n response_type: ResponseTypeOut;\n } & (\n | {\n response_uri: string;\n }\n | {\n redirect_uri: string;\n }\n );\n\n authResponse: string;\n state: string;\n}\n\nexport const jarmAuthResponseSend = async (input: JarmAuthResponseSendInput): Promise<Response> => {\n const { authRequestParams, authResponse, state } = input;\n\n const responseEndpoint = 'response_uri' in authRequestParams ? new URL(authRequestParams.response_uri) : new URL(authRequestParams.redirect_uri);\n\n const responseMode =\n authRequestParams.response_mode && authRequestParams.response_mode !== 'jwt'\n ? authRequestParams.response_mode\n : getJarmDefaultResponseMode(authRequestParams);\n\n validateResponseMode({\n response_type: authRequestParams.response_type,\n response_mode: responseMode,\n });\n\n switch (responseMode) {\n case 'direct_post.jwt':\n return handleDirectPostJwt(responseEndpoint, authResponse, state);\n case 'query.jwt':\n return handleQueryJwt(responseEndpoint, authResponse, state);\n case 'fragment.jwt':\n return handleFragmentJwt(responseEndpoint, authResponse, state);\n case 'form_post.jwt':\n throw new Error('Not implemented. form_post.jwt is not yet supported.');\n }\n};\n\nasync function handleDirectPostJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const response = await fetch(responseEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: `response=${responseJwt}&state=${state}`,\n });\n return response;\n}\n\nasync function handleQueryJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendQueryParams({\n url: responseEndpoint,\n params: { response: responseJwt, state },\n });\n\n const response = await fetch(responseUrl, { method: 'POST' });\n return response;\n}\n\nasync function handleFragmentJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendFragmentParams({\n url: responseEndpoint,\n fragments: { response: responseJwt, state },\n });\n const response = await fetch(responseUrl, { method: 'POST' });\n return response;\n}\n","import * as v from 'valibot';\n\nimport { vJarmResponseMode, vOpenid4vpJarmResponseMode } from '../v-response-mode-registry.js';\nimport { vResponseType } from '../v-response-type-registry.js';\n\nimport type { JarmAuthResponseParams } from './v-jarm-auth-response-params.js';\nimport type { JarmDirectPostJwtResponseParams } from './v-jarm-direct-post-jwt-auth-response-params.js';\n\nexport const vAuthRequestParams = v.looseObject({\n state: v.optional(v.string()),\n response_mode: v.optional(v.union([vJarmResponseMode, vOpenid4vpJarmResponseMode])),\n client_id: v.string(),\n response_type: vResponseType,\n client_metadata: v.looseObject({\n jwks: v.optional(\n v.object({\n keys: v.array(v.looseObject({ kid: v.optional(v.string()), kty: v.string() })),\n }),\n ),\n jwks_uri: v.optional(v.string()),\n }),\n});\n\nexport type AuthRequestParams = v.InferInput<typeof vAuthRequestParams>;\n\nexport const vOAuthAuthRequestGetParamsOut = v.object({\n authRequestParams: vAuthRequestParams,\n});\n\nexport type OAuthAuthRequestGetParamsOut = v.InferOutput<typeof vOAuthAuthRequestGetParamsOut>;\n\nexport interface JarmDirectPostJwtAuthResponseValidationContext {\n openid4vp: {\n authRequest: {\n getParams: (input: JarmAuthResponseParams | JarmDirectPostJwtResponseParams) => Promise<OAuthAuthRequestGetParamsOut>;\n };\n };\n jwe: {\n decryptCompact: (input: { jwe: string; jwk: { kid: string } }) => Promise<{ plaintext: string }>;\n };\n}\n","import * as v from 'valibot';\n\nexport const oAuthResponseTypes = v.picklist(['code', 'token']);\n\n// NOTE: MAKE SURE THAT THE RESPONSE TYPES ARE SORTED CORRECTLY\nexport const oAuthMRTEPResponseTypes = v.picklist(['none', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token']);\n\nexport const openid4vpResponseTypes = v.picklist(['vp_token', 'id_token vp_token']);\n\nexport const vTransformedResponseTypes = v.picklist([\n ...openid4vpResponseTypes.options,\n ...oAuthResponseTypes.options,\n ...oAuthMRTEPResponseTypes.options,\n]);\n\nexport const vResponseType = v.pipe(\n v.string(),\n v.transform((val) => val.split(' ').sort().join(' ')),\n vTransformedResponseTypes,\n);\n\nexport type ResponseType = v.InferInput<typeof vTransformedResponseTypes>;\nexport type ResponseTypeOut = v.InferOutput<typeof vTransformedResponseTypes>;\n","import { decodeProtectedHeader, isJwe, isJws } from '@sphereon/oid4vc-common';\nimport * as v from 'valibot';\n\nimport type { JarmDirectPostJwtResponseParams } from '../index.js';\n\nimport type { AuthRequestParams, JarmDirectPostJwtAuthResponseValidationContext } from './c-jarm-auth-response.js';\nimport { vJarmAuthResponseErrorParams } from './v-jarm-auth-response-params.js';\nimport { jarmAuthResponseDirectPostValidateParams, vJarmDirectPostJwtParams } from './v-jarm-direct-post-jwt-auth-response-params.js';\n\nexport interface JarmDirectPostJwtAuthResponseValidation {\n /**\n * The JARM response parameter conveyed either as url query param, fragment param, or application/x-www-form-urlencoded in the body of a post request\n */\n response: string;\n}\n\nconst parseJarmAuthResponseParams = <Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(\n schema: Schema,\n responseParams: unknown,\n) => {\n if (v.is(vJarmAuthResponseErrorParams, responseParams)) {\n const errorResponseJson = JSON.stringify(responseParams, undefined, 2);\n throw new Error(`Received error response from authorization server. '${errorResponseJson}'`);\n }\n\n return v.parse(schema, responseParams);\n};\n\nconst decryptJarmAuthResponse = async (input: { response: string }, ctx: JarmDirectPostJwtAuthResponseValidationContext) => {\n const { response } = input;\n\n const responseProtectedHeader = decodeProtectedHeader(response);\n if (!responseProtectedHeader.kid) {\n throw new Error(`Jarm JWE is missing the protected header field 'kid'.`);\n }\n\n const { plaintext } = await ctx.jwe.decryptCompact({\n jwe: response,\n jwk: { kid: responseProtectedHeader.kid },\n });\n\n return plaintext;\n};\n\n/**\n * Validate a JARM direct_post.jwt compliant authentication response\n * * The decryption key should be resolvable using the the protected header's 'kid' field\n * * The signature verification jwk should be resolvable using the jws protected header's 'kid' field and the payload's 'iss' field.\n */\nexport const jarmAuthResponseDirectPostJwtValidate = async (\n input: JarmDirectPostJwtAuthResponseValidation,\n ctx: JarmDirectPostJwtAuthResponseValidationContext,\n) => {\n const { response } = input;\n\n const responseIsEncrypted = isJwe(response);\n const decryptedResponse = responseIsEncrypted ? await decryptJarmAuthResponse(input, ctx) : response;\n\n const responseIsSigned = isJws(decryptedResponse);\n if (!responseIsEncrypted && !responseIsSigned) {\n throw new Error('Jarm Auth Response must be either encrypted, signed, or signed and encrypted.');\n }\n\n let authResponseParams: JarmDirectPostJwtResponseParams;\n let authRequestParams: AuthRequestParams;\n\n if (responseIsSigned) {\n throw new Error('Signed JARM responses are not supported.');\n //const jwsProtectedHeader = decodeProtectedHeader(decryptedResponse);\n //const jwsPayload = decodeJwt(decryptedResponse);\n\n //const schema = v.required(vJarmDirectPostJwtParams, ['iss', 'aud', 'exp']);\n //const responseParams = parseJarmAuthResponseParams(schema, jwsPayload);\n //({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(responseParams));\n\n //if (!jwsProtectedHeader.kid) {\n //throw new Error(`Jarm JWS is missing the protected header field 'kid'.`);\n //}\n\n //await ctx.jose.jws.verifyJwt({\n //jws: decryptedResponse,\n //jwk: { kid: jwsProtectedHeader.kid, kty: 'auto' },\n //});\n //authResponseParams = responseParams;\n } else {\n const jsonResponse: unknown = JSON.parse(decryptedResponse);\n authResponseParams = parseJarmAuthResponseParams(vJarmDirectPostJwtParams, jsonResponse);\n ({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(authResponseParams));\n }\n\n jarmAuthResponseDirectPostValidateParams({\n authRequestParams,\n authResponseParams,\n });\n\n let type: 'signed encrypted' | 'encrypted' | 'signed';\n if (responseIsSigned && responseIsEncrypted) type = 'signed encrypted';\n else if (responseIsEncrypted) type = 'encrypted';\n else type = 'signed';\n\n return {\n authRequestParams,\n authResponseParams,\n type,\n };\n};\n","import { checkExp } from '@sphereon/oid4vc-common';\nimport * as v from 'valibot';\n\nexport const vJarmAuthResponseErrorParams = v.looseObject({\n error: v.string(),\n state: v.optional(v.string()),\n\n error_description: v.pipe(\n v.optional(v.string()),\n v.description('Text providing additional information, used to assist the client developer in understanding the error that occurred.'),\n ),\n\n error_uri: v.pipe(\n v.optional(v.pipe(v.string(), v.url())),\n v.description(\n 'A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error',\n ),\n ),\n});\n\nexport const vJarmAuthResponseParams = v.looseObject({\n state: v.optional(v.string()),\n\n /**\n * The issuer URL of the authorization server that created the response\n */\n iss: v.string(),\n\n /**\n * Expiration of the JWT\n */\n exp: v.number(),\n\n /**\n * The client_id of the client the response is intended for\n */\n aud: v.string(),\n});\n\nexport type JarmAuthResponseParams = v.InferInput<typeof vJarmAuthResponseParams>;\n\nexport const validateJarmAuthResponseParams = (input: {\n authRequestParams: { client_id: string; state?: string };\n authResponseParams: JarmAuthResponseParams;\n}) => {\n const { authRequestParams, authResponseParams } = input;\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch in jarm-auth-response. Expected '${authRequestParams.state}' received '${authRequestParams.state}'.`);\n }\n\n // 4. The client obtains the aud element from the JWT and checks whether it matches the client id the client used to identify itself in the corresponding authorization request. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.client_id !== authResponseParams.aud) {\n throw new Error(`Invalid audience in jarm-auth-response. Expected '${authRequestParams.client_id}' received '${authResponseParams.aud}'.`);\n }\n\n // 5. The client checks the JWT's exp element to determine if the JWT is still valid. If the check fails, the client MUST abort processing and refuse the response.\n // 120 seconds clock skew\n if (checkExp({ exp: authResponseParams.exp })) {\n throw new Error(`The '${authRequestParams.state}' and the jarm-auth-response.`);\n }\n};\n","import * as v from 'valibot';\n\nimport { vJarmAuthResponseParams } from './v-jarm-auth-response-params.js';\n\nexport const vJarmDirectPostJwtParams = v.looseObject({\n ...v.omit(vJarmAuthResponseParams, ['iss', 'aud', 'exp']).entries,\n ...v.partial(v.pick(vJarmAuthResponseParams, ['iss', 'aud', 'exp'])).entries,\n\n vp_token: v.union([v.string(), v.array(v.pipe(v.string(), v.nonEmpty()))]),\n presentation_submission: v.unknown(),\n nonce: v.optional(v.string()),\n});\n\nexport type JarmDirectPostJwtResponseParams = v.InferInput<typeof vJarmDirectPostJwtParams>;\n\nexport const jarmAuthResponseDirectPostValidateParams = (input: {\n authRequestParams: { state?: string };\n authResponseParams: JarmDirectPostJwtResponseParams;\n}) => {\n const { authRequestParams, authResponseParams } = input;\n\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch between auth request '${authRequestParams.state}' and the jarm-auth-response.`);\n }\n};\n","import * as v from 'valibot';\n\nexport const vJarmClientMetadataSign = v.object({\n authorization_signed_response_alg: v.pipe(\n v.optional(v.string()), // @default 'RS256' This makes no sense with openid4vp if just encrypted can be specified\n v.description(\n 'JWA. If this is specified, the response will be signed using JWS and the configured algorithm. The algorithm none is not allowed.',\n ),\n ),\n\n authorization_encrypted_response_alg: v.optional(v.never()),\n authorization_encrypted_response_enc: v.optional(v.never()),\n});\n\nexport const vJarmClientMetadataEncrypt = v.object({\n authorization_signed_response_alg: v.optional(v.never()),\n authorization_encrypted_response_alg: v.pipe(\n v.string(),\n v.description(\n 'JWE alg algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n\n authorization_encrypted_response_enc: v.pipe(\n v.optional(v.string(), 'A128CBC-HS256'),\n v.description(\n 'JWE enc algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n});\n\nexport const vJarmClientMetadataSignEncrypt = v.object({\n ...v.pick(vJarmClientMetadataSign, ['authorization_signed_response_alg']).entries,\n ...v.pick(vJarmClientMetadataEncrypt, ['authorization_encrypted_response_alg', 'authorization_encrypted_response_enc']).entries,\n});\n\n/**\n * Clients may register their public encryption keys using the jwks_uri or jwks metadata parameters.\n */\nexport const vJarmClientMetadata = v.union([vJarmClientMetadataSign, vJarmClientMetadataEncrypt, vJarmClientMetadataSignEncrypt]);\n\nexport type JarmClientMetadata = v.InferInput<typeof vJarmClientMetadata>;\n","import * as v from 'valibot';\n\n/**\n * Authorization servers SHOULD publish the supported algorithms for signing and encrypting the JWT of an authorization response by utilizing OAuth 2.0 Authorization Server Metadata [RFC8414] parameters.\n */\nexport const vJarmServerMetadata = v.object({\n authorization_signing_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWS [RFC7515] signing algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to sign the response.',\n ),\n ),\n\n authorization_encryption_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n\n authorization_encryption_enc_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (enc values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n});\n\nexport type JarmServerMetadata = v.InferInput<typeof vJarmServerMetadata>;\n","import * as v from 'valibot';\n\nimport {\n vJarmClientMetadata,\n vJarmClientMetadataEncrypt,\n vJarmClientMetadataSign,\n vJarmClientMetadataSignEncrypt,\n} from '../metadata/v-jarm-client-metadata.js';\nimport { vJarmServerMetadata } from '../metadata/v-jarm-server-metadata.js';\nimport { assertValueSupported } from '../utils.js';\n\nexport const vJarmAuthResponseValidateMetadataInput = v.object({\n client_metadata: vJarmClientMetadata,\n server_metadata: v.partial(vJarmServerMetadata),\n});\nexport type JarmMetadataValidate = v.InferInput<typeof vJarmAuthResponseValidateMetadataInput>;\n\nexport const vJarmMetadataValidateOut = v.variant('type', [\n v.object({\n type: v.literal('signed'),\n client_metadata: vJarmClientMetadataSign,\n }),\n v.object({\n type: v.literal('encrypted'),\n client_metadata: vJarmClientMetadataEncrypt,\n }),\n v.object({\n type: v.literal('signed encrypted'),\n client_metadata: vJarmClientMetadataSignEncrypt,\n }),\n]);\n\nexport const jarmMetadataValidate = (vJarmMetadataValidate: JarmMetadataValidate): v.InferOutput<typeof vJarmMetadataValidateOut> => {\n const { client_metadata, server_metadata } = vJarmMetadataValidate;\n const { authorization_encrypted_response_alg, authorization_encrypted_response_enc, authorization_signed_response_alg } = client_metadata;\n\n assertValueSupported({\n supported: server_metadata.authorization_signing_alg_values_supported ?? [],\n actual: authorization_signed_response_alg,\n required: !!authorization_signed_response_alg,\n error: new Error('Invalid authorization_signed_response_alg'),\n });\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_alg_values_supported ?? [],\n actual: authorization_encrypted_response_alg,\n required: !!authorization_encrypted_response_alg,\n error: new Error('Invalid authorization_encrypted_response_alg'),\n });\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_enc_values_supported ?? [],\n actual: authorization_encrypted_response_enc,\n required: !!authorization_encrypted_response_enc,\n error: new Error('Invalid authorization_encrypted_response_enc'),\n });\n\n if (authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'signed encrypted',\n client_metadata: {\n authorization_signed_response_alg,\n authorization_encrypted_response_alg,\n authorization_encrypted_response_enc,\n },\n };\n } else if (authorization_signed_response_alg && !authorization_encrypted_response_alg && !authorization_encrypted_response_enc) {\n return {\n type: 'signed',\n client_metadata: { authorization_signed_response_alg },\n };\n } else if (!authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'encrypted',\n client_metadata: { authorization_encrypted_response_alg, authorization_encrypted_response_enc },\n };\n } else {\n throw new Error(`Invalid jarm client_metadata combination`);\n }\n};\n"],"mappings":";;;;AAAO,SAASA,kBAAkBC,OAAsE;AACtG,QAAM,EAAEC,KAAAA,MAAKC,OAAM,IAAKF;AAGxB,aAAW,CAACG,KAAKC,KAAAA,KAAUC,OAAOC,QAAQJ,MAAAA,GAAS;AACjDD,IAAAA,KAAIM,aAAaC,OAAOL,KAAKM,mBAAmBL,KAAAA,CAAAA;EAClD;AAEA,SAAOH;AACT;AATgBF;AAWT,SAASW,qBAAqBV,OAAyE;AAC5G,QAAM,EAAEC,KAAAA,MAAKU,UAAS,IAAKX;AAG3B,QAAMY,iBAAiB,IAAIC,gBAAgBZ,KAAIa,KAAKC,MAAM,CAAA,CAAA;AAG1D,aAAW,CAACZ,KAAKC,KAAAA,KAAUC,OAAOC,QAAQK,SAAAA,GAAY;AACpDC,mBAAeJ,OAAOL,KAAKM,mBAAmBL,KAAAA,CAAAA;EAChD;AAGAH,EAAAA,KAAIa,OAAOF,eAAeI,SAAQ;AAElC,SAAOf;AACT;AAfgBS;AAwBT,SAASO,qBAAwBjB,OAA8B;AACpE,QAAM,EAAEkB,UAAUC,OAAOC,WAAWC,OAAM,IAAKrB;AAC/C,QAAMsB,eAAeF,UAAUG,KAAK,CAACnB,UAAUA,UAAUiB,MAAAA;AAEzD,MAAIH,YAAY,CAACI,aAAc,OAAMH;AACrC,SAAOG;AACT;AANgBL;;;ACnChB,YAAYO,OAAO;AAIZ,IAAMC,oBAAsBC,WAAS;EAAC;EAAO;EAAa;EAAgB;CAAgB;AAG1F,IAAMC,yBAA2BD,WAAS;EAAC;CAAc;AAMzD,IAAME,6BAA+BF,WAAS;EAAC;CAAkB;AASjE,IAAMG,gBAAkBC,OAC3BJ,WAAS;EAAC;EAAS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,iBAAiBE,gBAAe,IAAKW;AAC7C,QAAM,EAAEC,sCAAsCC,sCAAsCC,kCAAiC,IAAKhB;AAE1HiB,uBAAqB;IACnBC,WAAWhB,gBAAgBiB,8CAA8C,CAAA;IACzEC,QAAQJ;IACRK,UAAU,CAAC,CAACL;IACZM,OAAO,IAAIC,MAAM,2CAAA;EACnB,CAAA;AAEAN,uBAAqB;IACnBC,WAAWhB,gBAAgBsB,iDAAiD,CAAA;IAC5EJ,QAAQN;IACRO,UAAU,CAAC,CAACP;IACZQ,OAAO,IAAIC,MAAM,8CAAA;EACnB,CAAA;AAEAN,uBAAqB;IACnBC,WAAWhB,gBAAgBuB,iDAAiD,CAAA;IAC5EL,QAAQL;IACRM,UAAU,CAAC,CAACN;IACZO,OAAO,IAAIC,MAAM,8CAAA;EACnB,CAAA;AAEA,MAAIP,qCAAqCF,wCAAwCC,sCAAsC;AACrH,WAAO;MACLR,MAAM;MACNP,iBAAiB;QACfgB;QACAF;QACAC;MACF;IACF;EACF,WAAWC,qCAAqC,CAACF,wCAAwC,CAACC,sCAAsC;AAC9H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEgB;MAAkC;IACvD;EACF,WAAW,CAACA,qCAAqCF,wCAAwCC,sCAAsC;AAC7H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEc;QAAsCC;MAAqC;IAChG;EACF,OAAO;AACL,UAAM,IAAIQ,MAAM,0CAA0C;EAC5D;AACF,GA/CoC;","names":["appendQueryParams","input","url","params","key","value","Object","entries","searchParams","append","encodeURIComponent","appendFragmentParams","fragments","fragmentParams","URLSearchParams","hash","slice","toString","assertValueSupported","required","error","supported","actual","intersection","find","v","vJarmResponseMode","picklist","vOpenid4vpResponseMode","vOpenid4vpJarmResponseMode","vResponseMode","pipe","options","description","getDisAllowedResponseModes","input","response_type","undefined","getDefaultResponseMode","getJarmDefaultResponseMode","responseMode","validateResponseMode","disallowedResponseModes","includes","response_mode","Error","jarmAuthResponseSend","input","authRequestParams","authResponse","state","responseEndpoint","URL","response_uri","redirect_uri","responseMode","response_mode","getJarmDefaultResponseMode","validateResponseMode","response_type","handleDirectPostJwt","handleQueryJwt","handleFragmentJwt","Error","responseJwt","response","fetch","method","headers","body","responseUrl","appendQueryParams","url","params","appendFragmentParams","fragments","v","v","oAuthResponseTypes","picklist","oAuthMRTEPResponseTypes","openid4vpResponseTypes","vTransformedResponseTypes","options","vResponseType","pipe","string","transform","val","split","sort","join","vAuthRequestParams","looseObject","state","optional","string","response_mode","union","vJarmResponseMode","vOpenid4vpJarmResponseMode","client_id","response_type","vResponseType","client_metadata","jwks","object","keys","array","kid","kty","jwks_uri","vOAuthAuthRequestGetParamsOut","authRequestParams","decodeProtectedHeader","isJwe","isJws","v","checkExp","v","vJarmAuthResponseErrorParams","looseObject","error","string","state","optional","error_description","pipe","description","error_uri","url","vJarmAuthResponseParams","iss","exp","number","aud","validateJarmAuthResponseParams","input","authRequestParams","authResponseParams","Error","client_id","checkExp","v","vJarmDirectPostJwtParams","looseObject","omit","vJarmAuthResponseParams","entries","partial","pick","vp_token","union","string","array","pipe","nonEmpty","presentation_submission","unknown","nonce","optional","jarmAuthResponseDirectPostValidateParams","input","authRequestParams","authResponseParams","state","Error","parseJarmAuthResponseParams","schema","responseParams","is","vJarmAuthResponseErrorParams","errorResponseJson","JSON","stringify","undefined","Error","parse","decryptJarmAuthResponse","input","ctx","response","responseProtectedHeader","decodeProtectedHeader","kid","plaintext","jwe","decryptCompact","jwk","jarmAuthResponseDirectPostJwtValidate","responseIsEncrypted","isJwe","decryptedResponse","responseIsSigned","isJws","authResponseParams","authRequestParams","jsonResponse","vJarmDirectPostJwtParams","openid4vp","authRequest","getParams","jarmAuthResponseDirectPostValidateParams","type","v","vJarmClientMetadataSign","object","authorization_signed_response_alg","pipe","optional","string","description","authorization_encrypted_response_alg","never","authorization_encrypted_response_enc","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","pick","entries","vJarmClientMetadata","union","v","vJarmServerMetadata","object","authorization_signing_alg_values_supported","pipe","array","string","description","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported","v","vJarmAuthResponseValidateMetadataInput","object","client_metadata","vJarmClientMetadata","server_metadata","partial","vJarmServerMetadata","vJarmMetadataValidateOut","variant","type","literal","vJarmClientMetadataSign","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","jarmMetadataValidate","vJarmMetadataValidate","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","assertValueSupported","supported","authorization_signing_alg_values_supported","actual","required","error","Error","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported"]}
|
|
1
|
+
{"version":3,"sources":["../lib/utils.ts","../lib/v-response-mode-registry.ts","../lib/jarm-auth-response-send/jarm-auth-response-send.ts","../lib/jarm-auth-response/c-jarm-auth-response.ts","../lib/v-response-type-registry.ts","../lib/jarm-auth-response/jarm-auth-response.ts","../lib/jarm-auth-response/v-jarm-auth-response-params.ts","../lib/jarm-auth-response/v-jarm-direct-post-jwt-auth-response-params.ts","../lib/metadata/v-jarm-client-metadata.ts","../lib/metadata/v-jarm-server-metadata.ts","../lib/metadata/jarm-validate-metadata.ts"],"sourcesContent":["export function appendQueryParams(input: { url: URL; params: Record<string, string | number | boolean> }) {\n const { url, params } = input\n\n // Append the new query parameters from the params object\n for (const [key, value] of Object.entries(params)) {\n url.searchParams.append(key, encodeURIComponent(value))\n }\n\n return url\n}\n\nexport function appendFragmentParams(input: { url: URL; fragments: Record<string, string | number | boolean> }) {\n const { url, fragments } = input\n\n // Convert existing fragment to an object and remove the leading '#'\n const fragmentParams = new URLSearchParams(url.hash.slice(1)) // Remove the leading '#' from the fragment\n\n // Append the new fragments from the fragments object\n for (const [key, value] of Object.entries(fragments)) {\n fragmentParams.append(key, encodeURIComponent(value))\n }\n\n // Rebuild the fragment string and assign it to the URL\n url.hash = fragmentParams.toString()\n\n return url\n}\n\ninterface AssertValueSupported<T> {\n supported: T[]\n actual: T\n error: Error\n required: boolean\n}\n\nexport function assertValueSupported<T>(input: AssertValueSupported<T>): T | undefined {\n const { required, error, supported, actual } = input\n const intersection = supported.find((value) => value === actual)\n\n if (required && !intersection) throw error\n return intersection\n}\n","import * as v from 'valibot'\n\nimport type { ResponseTypeOut } from './v-response-type-registry'\n\nexport const vJarmResponseMode = v.picklist(['jwt', 'query.jwt', 'fragment.jwt', 'form_post.jwt'])\nexport type JarmResponseMode = v.InferInput<typeof vJarmResponseMode>\n\nexport const vOpenid4vpResponseMode = v.picklist(['direct_post'])\nexport type Openid4vpResponseMode = v.InferInput<typeof vOpenid4vpResponseMode>\n\n/**\n * * 'direct_post.jwt' The response is send as HTTP POST request using the application/x-www-form-urlencoded content type. The body contains a single parameter response which is the JWT encoded Response as defined in JARM 4.1\n */\nexport const vOpenid4vpJarmResponseMode = v.picklist(['direct_post.jwt'])\nexport type Openid4vpJarmResponseMode = v.InferInput<typeof vOpenid4vpJarmResponseMode>\n\n/**\n * The use of this parameter is NOT RECOMMENDED when the Response Mode that would be requested is the default mode specified for the Response Type.\n * * 'query' In this mode, Authorization Response parameters are encoded in the query string added to the redirect_uri when redirecting back to the Client.\n * * 'fragment' In this mode, Authorization Response parameters are encoded in the fragment added to the redirect_uri when redirecting back to the Client.\n * * 'direct_post' the Authorization Response is send to an endpoint controlled by the Verifier via an HTTP POST request.\n */\nexport const vResponseMode = v.pipe(\n v.picklist(['query', 'fragment', ...vOpenid4vpResponseMode.options, ...vJarmResponseMode.options, ...vOpenid4vpJarmResponseMode.options]),\n v.description('Informs the Authorization Server of the mechanism to be used for returning parameters from the Authorization Endpoint.'),\n)\nexport type ResponseMode = v.InferInput<typeof vResponseMode>\n\nconst getDisAllowedResponseModes = (input: { response_type: ResponseTypeOut }): [ResponseMode, ...ResponseMode[]] | undefined => {\n const { response_type } = input\n\n switch (response_type) {\n case 'code token':\n return ['query']\n case 'code id_token':\n return ['query']\n case 'id_token token':\n return ['query']\n case 'code id_token token':\n return ['query']\n }\n return undefined\n}\n\nexport const getDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query' | 'fragment' => {\n const { response_type } = input\n\n switch (response_type) {\n case 'code':\n case 'none':\n return 'query'\n case 'token':\n case 'id_token':\n case 'code token':\n case 'code id_token':\n case 'id_token token':\n case 'code id_token token':\n case 'vp_token':\n case 'id_token vp_token':\n return 'fragment'\n }\n}\n\nexport const getJarmDefaultResponseMode = (input: { response_type: ResponseTypeOut }): 'query.jwt' | 'fragment.jwt' => {\n const responseMode = getDefaultResponseMode(input)\n\n switch (responseMode) {\n case 'query':\n return 'query.jwt'\n case 'fragment':\n return 'fragment.jwt'\n }\n}\n\nexport const validateResponseMode = (input: { response_type: ResponseTypeOut; response_mode: ResponseMode }) => {\n const disallowedResponseModes = getDisAllowedResponseModes(input)\n\n if (disallowedResponseModes?.includes(input.response_mode)) {\n throw new Error(`Response_type '${input.response_type}' is not compatible with response_mode '${input.response_mode}'.`)\n }\n}\n","import { appendFragmentParams, appendQueryParams } from '../utils'\nimport type { JarmResponseMode, Openid4vpJarmResponseMode } from '../v-response-mode-registry'\nimport { getJarmDefaultResponseMode, validateResponseMode } from '../v-response-mode-registry'\nimport type { ResponseTypeOut } from '../v-response-type-registry'\n\ninterface JarmAuthResponseSendInput {\n authRequestParams: {\n response_mode?: JarmResponseMode | Openid4vpJarmResponseMode\n response_type: ResponseTypeOut\n } & (\n | {\n response_uri: string\n }\n | {\n redirect_uri: string\n }\n )\n\n authResponse: string\n state: string\n}\n\nexport const jarmAuthResponseSend = async (input: JarmAuthResponseSendInput): Promise<Response> => {\n const { authRequestParams, authResponse, state } = input\n\n const responseEndpoint = 'response_uri' in authRequestParams ? new URL(authRequestParams.response_uri) : new URL(authRequestParams.redirect_uri)\n\n const responseMode =\n authRequestParams.response_mode && authRequestParams.response_mode !== 'jwt'\n ? authRequestParams.response_mode\n : getJarmDefaultResponseMode(authRequestParams)\n\n validateResponseMode({\n response_type: authRequestParams.response_type,\n response_mode: responseMode,\n })\n\n switch (responseMode) {\n case 'direct_post.jwt':\n return handleDirectPostJwt(responseEndpoint, authResponse, state)\n case 'query.jwt':\n return handleQueryJwt(responseEndpoint, authResponse, state)\n case 'fragment.jwt':\n return handleFragmentJwt(responseEndpoint, authResponse, state)\n case 'form_post.jwt':\n throw new Error('Not implemented. form_post.jwt is not yet supported.')\n }\n}\n\nasync function handleDirectPostJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const response = await fetch(responseEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: `response=${responseJwt}&state=${state}`,\n })\n return response\n}\n\nasync function handleQueryJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendQueryParams({\n url: responseEndpoint,\n params: { response: responseJwt, state },\n })\n\n const response = await fetch(responseUrl, { method: 'POST' })\n return response\n}\n\nasync function handleFragmentJwt(responseEndpoint: URL, responseJwt: string, state: string) {\n const responseUrl = appendFragmentParams({\n url: responseEndpoint,\n fragments: { response: responseJwt, state },\n })\n const response = await fetch(responseUrl, { method: 'POST' })\n return response\n}\n","import * as v from 'valibot'\n\nimport { vJarmResponseMode, vOpenid4vpJarmResponseMode } from '../v-response-mode-registry'\nimport { vResponseType } from '../v-response-type-registry'\n\nimport type { JarmAuthResponseParams } from './v-jarm-auth-response-params'\nimport type { JarmDirectPostJwtResponseParams } from './v-jarm-direct-post-jwt-auth-response-params'\n\nexport const vAuthRequestParams = v.looseObject({\n state: v.optional(v.string()),\n response_mode: v.optional(v.union([vJarmResponseMode, vOpenid4vpJarmResponseMode])),\n client_id: v.string(),\n response_type: vResponseType,\n client_metadata: v.looseObject({\n jwks: v.optional(\n v.object({\n keys: v.array(v.looseObject({ kid: v.optional(v.string()), kty: v.string() })),\n }),\n ),\n jwks_uri: v.optional(v.string()),\n }),\n})\n\nexport type AuthRequestParams = v.InferInput<typeof vAuthRequestParams>\n\nexport const vOAuthAuthRequestGetParamsOut = v.object({\n authRequestParams: vAuthRequestParams,\n})\n\nexport type OAuthAuthRequestGetParamsOut = v.InferOutput<typeof vOAuthAuthRequestGetParamsOut>\n\nexport interface JarmDirectPostJwtAuthResponseValidationContext {\n openid4vp: {\n authRequest: {\n getParams: (input: JarmAuthResponseParams | JarmDirectPostJwtResponseParams) => Promise<OAuthAuthRequestGetParamsOut>\n }\n }\n jwe: {\n decryptCompact: (input: { jwe: string; jwk: { kid: string } }) => Promise<{ plaintext: string }>\n }\n}\n","import * as v from 'valibot'\n\nexport const oAuthResponseTypes = v.picklist(['code', 'token'])\n\n// NOTE: MAKE SURE THAT THE RESPONSE TYPES ARE SORTED CORRECTLY\nexport const oAuthMRTEPResponseTypes = v.picklist(['none', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token'])\n\nexport const openid4vpResponseTypes = v.picklist(['vp_token', 'id_token vp_token'])\n\nexport const vTransformedResponseTypes = v.picklist([\n ...openid4vpResponseTypes.options,\n ...oAuthResponseTypes.options,\n ...oAuthMRTEPResponseTypes.options,\n])\n\nexport const vResponseType = v.pipe(\n v.string(),\n v.transform((val) => val.split(' ').sort().join(' ')),\n vTransformedResponseTypes,\n)\n\nexport type ResponseType = v.InferInput<typeof vTransformedResponseTypes>\nexport type ResponseTypeOut = v.InferOutput<typeof vTransformedResponseTypes>\n","import { decodeProtectedHeader, isJwe, isJws } from '@sphereon/oid4vc-common'\nimport * as v from 'valibot'\n\nimport type { AuthRequestParams, JarmDirectPostJwtAuthResponseValidationContext } from './c-jarm-auth-response'\nimport { vJarmAuthResponseErrorParams } from './v-jarm-auth-response-params'\nimport {\n jarmAuthResponseDirectPostValidateParams,\n JarmDirectPostJwtResponseParams,\n vJarmDirectPostJwtParams,\n} from './v-jarm-direct-post-jwt-auth-response-params'\n\nexport interface JarmDirectPostJwtAuthResponseValidation {\n /**\n * The JARM response parameter conveyed either as url query param, fragment param, or application/x-www-form-urlencoded in the body of a post request\n */\n response: string\n}\n\nconst parseJarmAuthResponseParams = <Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(\n schema: Schema,\n responseParams: unknown,\n) => {\n if (v.is(vJarmAuthResponseErrorParams, responseParams)) {\n const errorResponseJson = JSON.stringify(responseParams, undefined, 2)\n throw new Error(`Received error response from authorization server. '${errorResponseJson}'`)\n }\n\n return v.parse(schema, responseParams)\n}\n\nconst decryptJarmAuthResponse = async (input: { response: string }, ctx: JarmDirectPostJwtAuthResponseValidationContext) => {\n const { response } = input\n\n const responseProtectedHeader = decodeProtectedHeader(response)\n if (!responseProtectedHeader.kid) {\n throw new Error(`Jarm JWE is missing the protected header field 'kid'.`)\n }\n\n const { plaintext } = await ctx.jwe.decryptCompact({\n jwe: response,\n jwk: { kid: responseProtectedHeader.kid },\n })\n\n return plaintext\n}\n\n/**\n * Validate a JARM direct_post.jwt compliant authentication response\n * * The decryption key should be resolvable using the the protected header's 'kid' field\n * * The signature verification jwk should be resolvable using the jws protected header's 'kid' field and the payload's 'iss' field.\n */\nexport const jarmAuthResponseDirectPostJwtValidate = async (\n input: JarmDirectPostJwtAuthResponseValidation,\n ctx: JarmDirectPostJwtAuthResponseValidationContext,\n) => {\n const { response } = input\n\n const responseIsEncrypted = isJwe(response)\n const decryptedResponse = responseIsEncrypted ? await decryptJarmAuthResponse(input, ctx) : response\n\n const responseIsSigned = isJws(decryptedResponse)\n if (!responseIsEncrypted && !responseIsSigned) {\n throw new Error('Jarm Auth Response must be either encrypted, signed, or signed and encrypted.')\n }\n\n let authResponseParams: JarmDirectPostJwtResponseParams\n let authRequestParams: AuthRequestParams\n\n if (responseIsSigned) {\n throw new Error('Signed JARM responses are not supported.')\n //const jwsProtectedHeader = decodeProtectedHeader(decryptedResponse);\n //const jwsPayload = decodeJwt(decryptedResponse);\n\n //const schema = v.required(vJarmDirectPostJwtParams, ['iss', 'aud', 'exp']);\n //const responseParams = parseJarmAuthResponseParams(schema, jwsPayload);\n //({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(responseParams));\n\n //if (!jwsProtectedHeader.kid) {\n //throw new Error(`Jarm JWS is missing the protected header field 'kid'.`);\n //}\n\n //await ctx.jose.jws.verifyJwt({\n //jws: decryptedResponse,\n //jwk: { kid: jwsProtectedHeader.kid, kty: 'auto' },\n //});\n //authResponseParams = responseParams;\n } else {\n const jsonResponse: unknown = JSON.parse(decryptedResponse)\n authResponseParams = parseJarmAuthResponseParams(vJarmDirectPostJwtParams, jsonResponse)\n ;({ authRequestParams } = await ctx.openid4vp.authRequest.getParams(authResponseParams))\n }\n\n jarmAuthResponseDirectPostValidateParams({\n authRequestParams,\n authResponseParams,\n })\n\n let type: 'signed encrypted' | 'encrypted' | 'signed'\n if (responseIsSigned && responseIsEncrypted) type = 'signed encrypted'\n else if (responseIsEncrypted) type = 'encrypted'\n else type = 'signed'\n\n return {\n authRequestParams,\n authResponseParams,\n type,\n }\n}\n","import { checkExp } from '@sphereon/oid4vc-common'\nimport * as v from 'valibot'\n\nexport const vJarmAuthResponseErrorParams = v.looseObject({\n error: v.string(),\n state: v.optional(v.string()),\n\n error_description: v.pipe(\n v.optional(v.string()),\n v.description('Text providing additional information, used to assist the client developer in understanding the error that occurred.'),\n ),\n\n error_uri: v.pipe(\n v.optional(v.pipe(v.string(), v.url())),\n v.description(\n 'A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error',\n ),\n ),\n})\n\nexport const vJarmAuthResponseParams = v.looseObject({\n state: v.optional(v.string()),\n\n /**\n * The issuer URL of the authorization server that created the response\n */\n iss: v.string(),\n\n /**\n * Expiration of the JWT\n */\n exp: v.number(),\n\n /**\n * The client_id of the client the response is intended for\n */\n aud: v.string(),\n})\n\nexport type JarmAuthResponseParams = v.InferInput<typeof vJarmAuthResponseParams>\n\nexport const validateJarmAuthResponseParams = (input: {\n authRequestParams: { client_id: string; state?: string }\n authResponseParams: JarmAuthResponseParams\n}) => {\n const { authRequestParams, authResponseParams } = input\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch in jarm-auth-response. Expected '${authRequestParams.state}' received '${authRequestParams.state}'.`)\n }\n\n // 4. The client obtains the aud element from the JWT and checks whether it matches the client id the client used to identify itself in the corresponding authorization request. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.client_id !== authResponseParams.aud) {\n throw new Error(`Invalid audience in jarm-auth-response. Expected '${authRequestParams.client_id}' received '${authResponseParams.aud}'.`)\n }\n\n // 5. The client checks the JWT's exp element to determine if the JWT is still valid. If the check fails, the client MUST abort processing and refuse the response.\n // 120 seconds clock skew\n if (checkExp({ exp: authResponseParams.exp })) {\n throw new Error(`The '${authRequestParams.state}' and the jarm-auth-response.`)\n }\n}\n","import * as v from 'valibot'\n\nimport { vJarmAuthResponseParams } from './v-jarm-auth-response-params'\n\nexport const vJarmDirectPostJwtParams = v.looseObject({\n ...v.omit(vJarmAuthResponseParams, ['iss', 'aud', 'exp']).entries,\n ...v.partial(v.pick(vJarmAuthResponseParams, ['iss', 'aud', 'exp'])).entries,\n\n vp_token: v.union([v.string(), v.array(v.pipe(v.string(), v.nonEmpty()))]),\n presentation_submission: v.unknown(),\n nonce: v.optional(v.string()),\n})\n\nexport type JarmDirectPostJwtResponseParams = v.InferInput<typeof vJarmDirectPostJwtParams>\n\nexport const jarmAuthResponseDirectPostValidateParams = (input: {\n authRequestParams: { state?: string }\n authResponseParams: JarmDirectPostJwtResponseParams\n}) => {\n const { authRequestParams, authResponseParams } = input\n\n // 2. The client obtains the state parameter from the JWT and checks its binding to the user agent. If the check fails, the client MUST abort processing and refuse the response.\n if (authRequestParams.state !== authResponseParams.state) {\n throw new Error(`State missmatch between auth request '${authRequestParams.state}' and the jarm-auth-response.`)\n }\n}\n","import * as v from 'valibot'\n\nexport const vJarmClientMetadataSign = v.object({\n authorization_signed_response_alg: v.pipe(\n v.optional(v.string()), // @default 'RS256' This makes no sense with openid4vp if just encrypted can be specified\n v.description(\n 'JWA. If this is specified, the response will be signed using JWS and the configured algorithm. The algorithm none is not allowed.',\n ),\n ),\n\n authorization_encrypted_response_alg: v.optional(v.never()),\n authorization_encrypted_response_enc: v.optional(v.never()),\n})\n\nexport const vJarmClientMetadataEncrypt = v.object({\n authorization_signed_response_alg: v.optional(v.never()),\n authorization_encrypted_response_alg: v.pipe(\n v.string(),\n v.description(\n 'JWE alg algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n\n authorization_encrypted_response_enc: v.pipe(\n v.optional(v.string(), 'A128CBC-HS256'),\n v.description(\n 'JWE enc algorithm JWA. If both signing and encryption are requested, the response will be signed then encrypted with the provided algorithm.',\n ),\n ),\n})\n\nexport const vJarmClientMetadataSignEncrypt = v.object({\n ...v.pick(vJarmClientMetadataSign, ['authorization_signed_response_alg']).entries,\n ...v.pick(vJarmClientMetadataEncrypt, ['authorization_encrypted_response_alg', 'authorization_encrypted_response_enc']).entries,\n})\n\n/**\n * Clients may register their public encryption keys using the jwks_uri or jwks metadata parameters.\n */\nexport const vJarmClientMetadata = v.union([vJarmClientMetadataSign, vJarmClientMetadataEncrypt, vJarmClientMetadataSignEncrypt])\n\nexport type JarmClientMetadata = v.InferInput<typeof vJarmClientMetadata>\n","import * as v from 'valibot'\n\n/**\n * Authorization servers SHOULD publish the supported algorithms for signing and encrypting the JWT of an authorization response by utilizing OAuth 2.0 Authorization Server Metadata [RFC8414] parameters.\n */\nexport const vJarmServerMetadata = v.object({\n authorization_signing_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWS [RFC7515] signing algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to sign the response.',\n ),\n ),\n\n authorization_encryption_alg_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (alg values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n\n authorization_encryption_enc_values_supported: v.pipe(\n v.array(v.string()),\n v.description(\n 'JSON array containing a list of the JWE [RFC7516] encryption algorithms (enc values) JWA [RFC7518] supported by the authorization endpoint to encrypt the response.',\n ),\n ),\n})\n\nexport type JarmServerMetadata = v.InferInput<typeof vJarmServerMetadata>\n","import * as v from 'valibot'\n\nimport {\n vJarmClientMetadata,\n vJarmClientMetadataEncrypt,\n vJarmClientMetadataSign,\n vJarmClientMetadataSignEncrypt,\n} from '../metadata/v-jarm-client-metadata'\nimport { vJarmServerMetadata } from '../metadata/v-jarm-server-metadata'\nimport { assertValueSupported } from '../utils'\n\nexport const vJarmAuthResponseValidateMetadataInput = v.object({\n client_metadata: vJarmClientMetadata,\n server_metadata: v.partial(vJarmServerMetadata),\n})\nexport type JarmMetadataValidate = v.InferInput<typeof vJarmAuthResponseValidateMetadataInput>\n\nexport const vJarmMetadataValidateOut = v.variant('type', [\n v.object({\n type: v.literal('signed'),\n client_metadata: vJarmClientMetadataSign,\n }),\n v.object({\n type: v.literal('encrypted'),\n client_metadata: vJarmClientMetadataEncrypt,\n }),\n v.object({\n type: v.literal('signed encrypted'),\n client_metadata: vJarmClientMetadataSignEncrypt,\n }),\n])\n\nexport const jarmMetadataValidate = (vJarmMetadataValidate: JarmMetadataValidate): v.InferOutput<typeof vJarmMetadataValidateOut> => {\n const { client_metadata, server_metadata } = vJarmMetadataValidate\n const { authorization_encrypted_response_alg, authorization_encrypted_response_enc, authorization_signed_response_alg } = client_metadata\n\n assertValueSupported({\n supported: server_metadata.authorization_signing_alg_values_supported ?? [],\n actual: authorization_signed_response_alg,\n required: !!authorization_signed_response_alg,\n error: new Error('Invalid authorization_signed_response_alg'),\n })\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_alg_values_supported ?? [],\n actual: authorization_encrypted_response_alg,\n required: !!authorization_encrypted_response_alg,\n error: new Error('Invalid authorization_encrypted_response_alg'),\n })\n\n assertValueSupported({\n supported: server_metadata.authorization_encryption_enc_values_supported ?? [],\n actual: authorization_encrypted_response_enc,\n required: !!authorization_encrypted_response_enc,\n error: new Error('Invalid authorization_encrypted_response_enc'),\n })\n\n if (authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'signed encrypted',\n client_metadata: {\n authorization_signed_response_alg,\n authorization_encrypted_response_alg,\n authorization_encrypted_response_enc,\n },\n }\n } else if (authorization_signed_response_alg && !authorization_encrypted_response_alg && !authorization_encrypted_response_enc) {\n return {\n type: 'signed',\n client_metadata: { authorization_signed_response_alg },\n }\n } else if (!authorization_signed_response_alg && authorization_encrypted_response_alg && authorization_encrypted_response_enc) {\n return {\n type: 'encrypted',\n client_metadata: { authorization_encrypted_response_alg, authorization_encrypted_response_enc },\n }\n } else {\n throw new Error(`Invalid jarm client_metadata combination`)\n }\n}\n"],"mappings":";;;;AAAO,SAASA,kBAAkBC,OAAsE;AACtG,QAAM,EAAEC,KAAAA,MAAKC,OAAM,IAAKF;AAGxB,aAAW,CAACG,KAAKC,KAAAA,KAAUC,OAAOC,QAAQJ,MAAAA,GAAS;AACjDD,IAAAA,KAAIM,aAAaC,OAAOL,KAAKM,mBAAmBL,KAAAA,CAAAA;EAClD;AAEA,SAAOH;AACT;AATgBF;AAWT,SAASW,qBAAqBV,OAAyE;AAC5G,QAAM,EAAEC,KAAAA,MAAKU,UAAS,IAAKX;AAG3B,QAAMY,iBAAiB,IAAIC,gBAAgBZ,KAAIa,KAAKC,MAAM,CAAA,CAAA;AAG1D,aAAW,CAACZ,KAAKC,KAAAA,KAAUC,OAAOC,QAAQK,SAAAA,GAAY;AACpDC,mBAAeJ,OAAOL,KAAKM,mBAAmBL,KAAAA,CAAAA;EAChD;AAGAH,EAAAA,KAAIa,OAAOF,eAAeI,SAAQ;AAElC,SAAOf;AACT;AAfgBS;AAwBT,SAASO,qBAAwBjB,OAA8B;AACpE,QAAM,EAAEkB,UAAUC,OAAOC,WAAWC,OAAM,IAAKrB;AAC/C,QAAMsB,eAAeF,UAAUG,KAAK,CAACnB,UAAUA,UAAUiB,MAAAA;AAEzD,MAAIH,YAAY,CAACI,aAAc,OAAMH;AACrC,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Q,QAAA;IAChBR,iBAAiBS;EACnB,CAAA;EACEV,UAAO;IACPQ,MAAQC,WAAQ,WAAA;IAChBR,iBAAiBU;EACnB,CAAA;EACEX,UAAO;IACPQ,MAAQC,WAAQ,kBAAA;IAChBR,iBAAiBW;EACnB,CAAA;CACD;AAEM,IAAMC,uBAAuB,wBAACC,0BAAAA;AACnC,QAAM,EAAEb,iBAAiBE,gBAAe,IAAKW;AAC7C,QAAM,EAAEC,sCAAsCC,sCAAsCC,kCAAiC,IAAKhB;AAE1HiB,uBAAqB;IACnBC,WAAWhB,gBAAgBiB,8CAA8C,CAAA;IACzEC,QAAQJ;IACRK,UAAU,CAAC,CAACL;IACZM,OAAO,IAAIC,MAAM,2CAAA;EACnB,CAAA;AAEAN,uBAAqB;IACnBC,WAAWhB,gBAAgBsB,iDAAiD,CAAA;IAC5EJ,QAAQN;IACRO,UAAU,CAAC,CAACP;IACZQ,OAAO,IAAIC,MAAM,8CAAA;EACnB,CAAA;AAEAN,uBAAqB;IACnBC,WAAWhB,gBAAgBuB,iDAAiD,CAAA;IAC5EL,QAAQL;IACRM,UAAU,CAAC,CAACN;IACZO,OAAO,IAAIC,MAAM,8CAAA;EACnB,CAAA;AAEA,MAAIP,qCAAqCF,wCAAwCC,sCAAsC;AACrH,WAAO;MACLR,MAAM;MACNP,iBAAiB;QACfgB;QACAF;QACAC;MACF;IACF;EACF,WAAWC,qCAAqC,CAACF,wCAAwC,CAACC,sCAAsC;AAC9H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEgB;MAAkC;IACvD;EACF,WAAW,CAACA,qCAAqCF,wCAAwCC,sCAAsC;AAC7H,WAAO;MACLR,MAAM;MACNP,iBAAiB;QAAEc;QAAsCC;MAAqC;IAChG;EACF,OAAO;AACL,UAAM,IAAIQ,MAAM,0CAA0C;EAC5D;AACF,GA/CoC;","names":["appendQueryParams","input","url","params","key","value","Object","entries","searchParams","append","encodeURIComponent","appendFragmentParams","fragments","fragmentParams","URLSearchParams","hash","slice","toString","assertValueSupported","required","error","supported","actual","intersection","find","v","vJarmResponseMode","picklist","vOpenid4vpResponseMode","vOpenid4vpJarmResponseMode","vResponseMode","pipe","options","description","getDisAllowedResponseModes","input","response_type","undefined","getDefaultResponseMode","getJarmDefaultResponseMode","responseMode","validateResponseMode","disallowedResponseModes","includes","response_mode","Error","jarmAuthResponseSend","input","authRequestParams","authResponse","state","responseEndpoint","URL","response_uri","redirect_uri","responseMode","response_mode","getJarmDefaultResponseMode","validateResponseMode","response_type","handleDirectPostJwt","handleQueryJwt","handleFragmentJwt","Error","responseJwt","response","fetch","method","headers","body","responseUrl","appendQueryParams","url","params","appendFragmentParams","fragments","v","v","oAuthResponseTypes","picklist","oAuthMRTEPResponseTypes","openid4vpResponseTypes","vTransformedResponseTypes","options","vResponseType","pipe","string","transform","val","split","sort","join","vAuthRequestParams","looseObject","state","optional","string","response_mode","union","vJarmResponseMode","vOpenid4vpJarmResponseMode","client_id","response_type","vResponseType","client_metadata","jwks","object","keys","array","kid","kty","jwks_uri","vOAuthAuthRequestGetParamsOut","authRequestParams","decodeProtectedHeader","isJwe","isJws","v","checkExp","v","vJarmAuthResponseErrorParams","looseObject","error","string","state","optional","error_description","pipe","description","error_uri","url","vJarmAuthResponseParams","iss","exp","number","aud","validateJarmAuthResponseParams","input","authRequestParams","authResponseParams","Error","client_id","checkExp","v","vJarmDirectPostJwtParams","looseObject","omit","vJarmAuthResponseParams","entries","partial","pick","vp_token","union","string","array","pipe","nonEmpty","presentation_submission","unknown","nonce","optional","jarmAuthResponseDirectPostValidateParams","input","authRequestParams","authResponseParams","state","Error","parseJarmAuthResponseParams","schema","responseParams","is","vJarmAuthResponseErrorParams","errorResponseJson","JSON","stringify","undefined","Error","parse","decryptJarmAuthResponse","input","ctx","response","responseProtectedHeader","decodeProtectedHeader","kid","plaintext","jwe","decryptCompact","jwk","jarmAuthResponseDirectPostJwtValidate","responseIsEncrypted","isJwe","decryptedResponse","responseIsSigned","isJws","authResponseParams","authRequestParams","jsonResponse","vJarmDirectPostJwtParams","openid4vp","authRequest","getParams","jarmAuthResponseDirectPostValidateParams","type","v","vJarmClientMetadataSign","object","authorization_signed_response_alg","pipe","optional","string","description","authorization_encrypted_response_alg","never","authorization_encrypted_response_enc","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","pick","entries","vJarmClientMetadata","union","v","vJarmServerMetadata","object","authorization_signing_alg_values_supported","pipe","array","string","description","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported","v","vJarmAuthResponseValidateMetadataInput","object","client_metadata","vJarmClientMetadata","server_metadata","partial","vJarmServerMetadata","vJarmMetadataValidateOut","variant","type","literal","vJarmClientMetadataSign","vJarmClientMetadataEncrypt","vJarmClientMetadataSignEncrypt","jarmMetadataValidate","vJarmMetadataValidate","authorization_encrypted_response_alg","authorization_encrypted_response_enc","authorization_signed_response_alg","assertValueSupported","supported","authorization_signing_alg_values_supported","actual","required","error","Error","authorization_encryption_alg_values_supported","authorization_encryption_enc_values_supported"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/jarm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1-next.2+4c0450e",
|
|
4
4
|
"description": "Sphereon JARM",
|
|
5
|
+
"source": "./src/index.ts",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.cjs",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@sphereon/oid4vc-common": "0.
|
|
24
|
+
"@sphereon/oid4vc-common": "^0.19.1-next.2+4c0450e",
|
|
24
25
|
"valibot": "^0.42.1"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
@@ -30,12 +31,11 @@
|
|
|
30
31
|
"node": ">=20"
|
|
31
32
|
},
|
|
32
33
|
"files": [
|
|
33
|
-
"
|
|
34
|
+
"src",
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE.md"
|
|
34
38
|
],
|
|
35
|
-
"prettier": {
|
|
36
|
-
"singleQuote": true,
|
|
37
|
-
"printWidth": 150
|
|
38
|
-
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"Sphereon",
|
|
41
41
|
"Verifiable Credentials",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "4c0450e17a060b0095d1f572870c0eedd1656c7b"
|
|
56
56
|
}
|