@gramota/oid4vp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @gramota/oid4vp
2
+
3
+ > OpenID for Verifiable Presentations transport — authorization request/response wire format for EUDIW.
4
+
5
+ Part of [Gramota](https://github.com/gramota-org/gramota) — the TypeScript
6
+ SDK for the EU Digital Identity Wallet (EUDIW).
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm add @gramota/oid4vp
12
+ # or: npm install @gramota/oid4vp
13
+ # or: yarn add @gramota/oid4vp
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import { buildAuthorizationRequest, parseAuthorizationResponse } from "@gramota/oid4vp";
20
+
21
+ const req = buildAuthorizationRequest({ client_id, nonce, ... });
22
+ const res = parseAuthorizationResponse(formData);
23
+ ```
24
+
25
+ For full docs, examples, and the high-level Verifier/Issuer/Holder API,
26
+ see the [main repo](https://github.com/gramota-org/gramota).
27
+
28
+ ## License
29
+
30
+ [Apache 2.0](https://github.com/gramota-org/gramota/blob/main/LICENSE)
@@ -0,0 +1,4 @@
1
+ export { buildAuthorizationRequestUrl, parseAuthorizationRequestUrl, parseAuthorizationRequestSearchParams, } from "./request.js";
2
+ export { buildAuthorizationResponseBody, parseAuthorizationResponseBody, parseAuthorizationResponseFromParams, } from "./response.js";
3
+ export { Oid4vpError, type AuthorizationRequest, type AuthorizationResponse, type ClientIdScheme, type Oid4vpErrorCode, type ResponseMode, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,qCAAqC,GACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { buildAuthorizationRequestUrl, parseAuthorizationRequestUrl, parseAuthorizationRequestSearchParams, } from "./request.js";
2
+ export { buildAuthorizationResponseBody, parseAuthorizationResponseBody, parseAuthorizationResponseFromParams, } from "./response.js";
3
+ export { Oid4vpError, } from "./types.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,qCAAqC,GACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,GAMZ,MAAM,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type AuthorizationRequest } from "./types.js";
2
+ /**
3
+ * Serialise an Authorization Request to a URL with query parameters per
4
+ * OID4VP §5.1 (parameter encoding rules).
5
+ *
6
+ * The base URL is typically `https://wallet.example.com/authorize` for web
7
+ * flows or a custom scheme like `openid4vp://`. Both work — we just append
8
+ * the query string.
9
+ */
10
+ export declare function buildAuthorizationRequestUrl(baseUrl: string, request: AuthorizationRequest): string;
11
+ /** Parse an OID4VP Authorization Request from a URL string. */
12
+ export declare function parseAuthorizationRequestUrl(rawUrl: string): AuthorizationRequest;
13
+ /**
14
+ * Parse from a `URLSearchParams` (or anything that quacks like one) — useful
15
+ * when the verifier already has a parsed `req.query` from Express, Hono, etc.
16
+ */
17
+ export declare function parseAuthorizationRequestSearchParams(params: URLSearchParams | Record<string, string>): AuthorizationRequest;
18
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAYpE;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAkBR;AAED,+DAA+D;AAC/D,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,GACb,oBAAoB,CAWtB;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/C,oBAAoB,CA0CtB"}
@@ -0,0 +1,110 @@
1
+ import { Oid4vpError } from "./types.js";
2
+ /** Required fields per OID4VP §5. */
3
+ const REQUIRED_FIELDS = ["response_type", "client_id", "nonce"];
4
+ /** Object-valued parameters that must be JSON-encoded in URL form. */
5
+ const JSON_FIELDS = new Set([
6
+ "presentation_definition",
7
+ "dcql_query",
8
+ "client_metadata",
9
+ ]);
10
+ /**
11
+ * Serialise an Authorization Request to a URL with query parameters per
12
+ * OID4VP §5.1 (parameter encoding rules).
13
+ *
14
+ * The base URL is typically `https://wallet.example.com/authorize` for web
15
+ * flows or a custom scheme like `openid4vp://`. Both work — we just append
16
+ * the query string.
17
+ */
18
+ export function buildAuthorizationRequestUrl(baseUrl, request) {
19
+ validateRequest(request);
20
+ const url = new URL(baseUrl);
21
+ for (const [key, value] of Object.entries(request)) {
22
+ if (value === undefined)
23
+ continue;
24
+ if (JSON_FIELDS.has(key)) {
25
+ url.searchParams.set(key, JSON.stringify(value));
26
+ }
27
+ else if (typeof value === "string") {
28
+ url.searchParams.set(key, value);
29
+ }
30
+ else {
31
+ throw new Oid4vpError("oid4vp.invalid_value_type", `unsupported value type for '${key}': ${typeof value}`);
32
+ }
33
+ }
34
+ return url.toString();
35
+ }
36
+ /** Parse an OID4VP Authorization Request from a URL string. */
37
+ export function parseAuthorizationRequestUrl(rawUrl) {
38
+ let url;
39
+ try {
40
+ url = new URL(rawUrl);
41
+ }
42
+ catch (err) {
43
+ throw new Oid4vpError("oid4vp.invalid_url", `not a valid URL: ${err instanceof Error ? err.message : String(err)}`);
44
+ }
45
+ return parseAuthorizationRequestSearchParams(url.searchParams);
46
+ }
47
+ /**
48
+ * Parse from a `URLSearchParams` (or anything that quacks like one) — useful
49
+ * when the verifier already has a parsed `req.query` from Express, Hono, etc.
50
+ */
51
+ export function parseAuthorizationRequestSearchParams(params) {
52
+ const get = (k) => params instanceof URLSearchParams ? params.get(k) ?? undefined : params[k];
53
+ const out = {};
54
+ const known = [
55
+ "response_type",
56
+ "client_id",
57
+ "client_id_scheme",
58
+ "response_mode",
59
+ "response_uri",
60
+ "redirect_uri",
61
+ "nonce",
62
+ "state",
63
+ "presentation_definition",
64
+ "presentation_definition_uri",
65
+ "dcql_query",
66
+ "client_metadata",
67
+ "scope",
68
+ ];
69
+ for (const key of known) {
70
+ const value = get(key);
71
+ if (value === undefined)
72
+ continue;
73
+ if (JSON_FIELDS.has(key)) {
74
+ try {
75
+ out[key] = JSON.parse(value);
76
+ }
77
+ catch (err) {
78
+ throw new Oid4vpError("oid4vp.invalid_json", `invalid JSON for parameter '${key}': ${err instanceof Error ? err.message : String(err)}`);
79
+ }
80
+ }
81
+ else {
82
+ out[key] = value;
83
+ }
84
+ }
85
+ validateRequest(out);
86
+ return out;
87
+ }
88
+ function validateRequest(req) {
89
+ for (const field of REQUIRED_FIELDS) {
90
+ const v = req[field];
91
+ if (typeof v !== "string" || v.length === 0) {
92
+ throw new Oid4vpError("oid4vp.required_field_missing", `Authorization Request is missing required parameter: ${field}`);
93
+ }
94
+ }
95
+ if (req.response_type !== "vp_token") {
96
+ throw new Oid4vpError("oid4vp.unsupported_response_type", `Authorization Request response_type must be 'vp_token', got '${req.response_type}'`);
97
+ }
98
+ if (req.presentation_definition !== undefined &&
99
+ req.presentation_definition_uri !== undefined) {
100
+ throw new Oid4vpError("oid4vp.mutually_exclusive_fields", "presentation_definition and presentation_definition_uri are mutually exclusive (OID4VP §5.4)");
101
+ }
102
+ if (req.presentation_definition !== undefined &&
103
+ req.dcql_query !== undefined) {
104
+ throw new Oid4vpError("oid4vp.mutually_exclusive_fields", "presentation_definition and dcql_query are mutually exclusive — pick one query language");
105
+ }
106
+ if (req.response_mode === "direct_post" && req.response_uri === undefined) {
107
+ throw new Oid4vpError("oid4vp.response_uri_required", "response_mode=direct_post requires response_uri (OID4VP §6.2)");
108
+ }
109
+ }
110
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA6B,MAAM,YAAY,CAAC;AAEpE,qCAAqC;AACrC,MAAM,eAAe,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,OAAO,CAAU,CAAC;AAEzE,sEAAsE;AACtE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS;IAClC,yBAAyB;IACzB,YAAY;IACZ,iBAAiB;CAClB,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAe,EACf,OAA6B;IAE7B,eAAe,CAAC,OAAO,CAAC,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,YAAY,CAAC,GAAG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CAAC;IACJ,CAAC;IACD,IACE,GAAG,CAAC,uBAAuB,KAAK,SAAS;QACzC,GAAG,CAAC,2BAA2B,KAAK,SAAS,EAC7C,CAAC;QACD,MAAM,IAAI,WAAW,CACnB,kCAAkC,EAClC,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,IACE,GAAG,CAAC,uBAAuB,KAAK,SAAS;QACzC,GAAG,CAAC,UAAU,KAAK,SAAS,EAC5B,CAAC;QACD,MAAM,IAAI,WAAW,CACnB,kCAAkC,EAClC,yFAAyF,CAC1F,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,CAAC,aAAa,KAAK,aAAa,IAAI,GAAG,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QAC1E,MAAM,IAAI,WAAW,CACnB,8BAA8B,EAC9B,+DAA+D,CAChE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type AuthorizationResponse } from "./types.js";
2
+ /**
3
+ * Serialise an Authorization Response to a URL-encoded form body, suitable
4
+ * for `direct_post` (POST application/x-www-form-urlencoded). Per OID4VP §6:
5
+ *
6
+ * - `vp_token` is the raw presentation string, or a JSON-encoded array if
7
+ * multiple credentials are presented.
8
+ * - `presentation_submission` is JSON-encoded.
9
+ * - `state` (optional) and `iss` (optional) pass through as strings.
10
+ */
11
+ export declare function buildAuthorizationResponseBody(response: AuthorizationResponse): string;
12
+ /** Parse an Authorization Response from a URL-encoded form body string. */
13
+ export declare function parseAuthorizationResponseBody(rawBody: string): AuthorizationResponse;
14
+ /** Parse from URLSearchParams or a plain object — handy when frameworks have
15
+ * already decoded the body. */
16
+ export declare function parseAuthorizationResponseFromParams(params: URLSearchParams | Record<string, string>): AuthorizationResponse;
17
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAKrE;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,MAAM,CAuBR;AAED,2EAA2E;AAC3E,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,MAAM,GACd,qBAAqB,CAavB;AAED;+BAC+B;AAC/B,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/C,qBAAqB,CAqEvB"}
@@ -0,0 +1,106 @@
1
+ import { Oid4vpError } from "./types.js";
2
+ /** Required fields per OID4VP §6.1. */
3
+ const REQUIRED_FIELDS = ["vp_token", "presentation_submission"];
4
+ /**
5
+ * Serialise an Authorization Response to a URL-encoded form body, suitable
6
+ * for `direct_post` (POST application/x-www-form-urlencoded). Per OID4VP §6:
7
+ *
8
+ * - `vp_token` is the raw presentation string, or a JSON-encoded array if
9
+ * multiple credentials are presented.
10
+ * - `presentation_submission` is JSON-encoded.
11
+ * - `state` (optional) and `iss` (optional) pass through as strings.
12
+ */
13
+ export function buildAuthorizationResponseBody(response) {
14
+ validateResponse(response);
15
+ const body = new URLSearchParams();
16
+ if (Array.isArray(response.vp_token)) {
17
+ body.set("vp_token", JSON.stringify(response.vp_token));
18
+ }
19
+ else if (typeof response.vp_token === "string") {
20
+ body.set("vp_token", response.vp_token);
21
+ }
22
+ else {
23
+ throw new Oid4vpError("oid4vp.invalid_value_type", "vp_token must be a string or an array of strings");
24
+ }
25
+ body.set("presentation_submission", JSON.stringify(response.presentation_submission));
26
+ if (response.state !== undefined)
27
+ body.set("state", response.state);
28
+ if (response.iss !== undefined)
29
+ body.set("iss", response.iss);
30
+ return body.toString();
31
+ }
32
+ /** Parse an Authorization Response from a URL-encoded form body string. */
33
+ export function parseAuthorizationResponseBody(rawBody) {
34
+ let params;
35
+ try {
36
+ params = new URLSearchParams(rawBody);
37
+ }
38
+ catch (err) {
39
+ throw new Oid4vpError("oid4vp.malformed_body", `Authorization Response body is not valid URL-encoded form data: ${err instanceof Error ? err.message : String(err)}`);
40
+ }
41
+ return parseAuthorizationResponseFromParams(params);
42
+ }
43
+ /** Parse from URLSearchParams or a plain object — handy when frameworks have
44
+ * already decoded the body. */
45
+ export function parseAuthorizationResponseFromParams(params) {
46
+ const get = (k) => params instanceof URLSearchParams ? params.get(k) ?? undefined : params[k];
47
+ const vpRaw = get("vp_token");
48
+ const submissionRaw = get("presentation_submission");
49
+ if (vpRaw === undefined) {
50
+ throw new Oid4vpError("oid4vp.required_field_missing", "Authorization Response is missing required parameter: vp_token");
51
+ }
52
+ if (submissionRaw === undefined) {
53
+ throw new Oid4vpError("oid4vp.required_field_missing", "Authorization Response is missing required parameter: presentation_submission");
54
+ }
55
+ let submission;
56
+ try {
57
+ submission = JSON.parse(submissionRaw);
58
+ }
59
+ catch (err) {
60
+ throw new Oid4vpError("oid4vp.invalid_json", `presentation_submission is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
61
+ }
62
+ if (submission === null ||
63
+ typeof submission !== "object" ||
64
+ Array.isArray(submission)) {
65
+ throw new Oid4vpError("oid4vp.malformed_submission", "presentation_submission must be a JSON object (DIF Presentation Exchange v2)");
66
+ }
67
+ // vp_token may be a string OR a JSON-encoded array of strings.
68
+ let vp_token = vpRaw;
69
+ if (vpRaw.trim().startsWith("[")) {
70
+ try {
71
+ const parsed = JSON.parse(vpRaw);
72
+ if (Array.isArray(parsed) &&
73
+ parsed.every((p) => typeof p === "string")) {
74
+ vp_token = parsed;
75
+ }
76
+ }
77
+ catch {
78
+ // Not a JSON array — treat as a literal string.
79
+ }
80
+ }
81
+ const result = {
82
+ vp_token,
83
+ presentation_submission: submission,
84
+ };
85
+ const state = get("state");
86
+ if (state !== undefined)
87
+ result.state = state;
88
+ const iss = get("iss");
89
+ if (iss !== undefined)
90
+ result.iss = iss;
91
+ validateResponse(result);
92
+ return result;
93
+ }
94
+ function validateResponse(resp) {
95
+ for (const field of REQUIRED_FIELDS) {
96
+ if (resp[field] === undefined) {
97
+ throw new Oid4vpError("oid4vp.required_field_missing", `Authorization Response is missing required parameter: ${field}`);
98
+ }
99
+ }
100
+ if (typeof resp.vp_token !== "string" &&
101
+ !(Array.isArray(resp.vp_token) &&
102
+ resp.vp_token.every((v) => typeof v === "string"))) {
103
+ throw new Oid4vpError("oid4vp.invalid_value_type", "vp_token must be a string or an array of strings");
104
+ }
105
+ }
106
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA8B,MAAM,YAAY,CAAC;AAErE,uCAAuC;AACvC,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,yBAAyB,CAAU,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA+B;IAE/B,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1D,CAAC;SAAM,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,WAAW,CACnB,2BAA2B,EAC3B,kDAAkD,CACnD,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,GAAG,CACN,yBAAyB,EACzB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CACjD,CAAC;IACF,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;QAAE,IAAI,CAAC,GA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G,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,GAAG,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IAExC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAoC;IAC5D,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,WAAW,CACnB,+BAA+B,EAC/B,yDAAyD,KAAK,EAAE,CACjE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IACE,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ;QACjC,CAAC,CACC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC5B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAClD,EACD,CAAC;QACD,MAAM,IAAI,WAAW,CACnB,2BAA2B,EAC3B,kDAAkD,CACnD,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * OID4VP Final 1.0 wire-format types.
3
+ * Spec: https://openid.net/specs/openid-4-verifiable-presentations-1_0.html
4
+ *
5
+ * Scope of this package: §5 Authorization Request, §6 Authorization Response.
6
+ * Presentation Definition (§5.4) is modelled but not yet matched/queried —
7
+ * downstream packages will add DIF Presentation Exchange JSONPath support.
8
+ */
9
+ /** OID4VP §5.4 — `client_id_scheme` enumerated values. */
10
+ export type ClientIdScheme = "pre-registered" | "redirect_uri" | "https" | "did" | "x509_san_dns" | "x509_san_uri" | "verifier_attestation" | (string & {});
11
+ /** OID4VP §6.2 — `response_mode` for the authorization response. */
12
+ export type ResponseMode = "direct_post" | "direct_post.jwt" | "fragment" | "query";
13
+ /** OID4VP §5 — Authorization Request, the bundle a verifier sends to a wallet.
14
+ *
15
+ * In production this is delivered as a query string, a `request_uri` (signed
16
+ * JWT), or via a custom URI scheme like `openid4vp://`. We model the parsed
17
+ * structure once and let serialisation handle the rest. */
18
+ export interface AuthorizationRequest {
19
+ /** MUST be `vp_token` per OID4VP §5. */
20
+ response_type: "vp_token";
21
+ /** Identifier of the verifier — meaning depends on `client_id_scheme`. */
22
+ client_id: string;
23
+ /** How the wallet should resolve and trust `client_id`. Default
24
+ * `pre-registered` — for HAIP/EUDIW the spec mandates explicit. */
25
+ client_id_scheme?: ClientIdScheme;
26
+ /** How the wallet returns the response. HAIP requires `direct_post`. */
27
+ response_mode?: ResponseMode;
28
+ /** Where to POST the response when `response_mode=direct_post`. */
29
+ response_uri?: string;
30
+ /** Where to redirect the response for legacy modes. */
31
+ redirect_uri?: string;
32
+ /** Cryptographic challenge — bound into KB-JWT to prevent replay. */
33
+ nonce: string;
34
+ /** Opaque verifier-controlled correlation token, echoed back unchanged. */
35
+ state?: string;
36
+ /** Inline DIF Presentation Definition JSON — what the verifier wants
37
+ * (OID4VP 1.0 query shape). */
38
+ presentation_definition?: Readonly<Record<string, unknown>>;
39
+ /** Or a URL the wallet can fetch the PD from. Mutually exclusive with above. */
40
+ presentation_definition_uri?: string;
41
+ /** DCQL query (OID4VP 2.0 — Digital Credentials Query Language).
42
+ * Mutually exclusive with `presentation_definition`. */
43
+ dcql_query?: Readonly<Record<string, unknown>>;
44
+ /** Wallet metadata transparency parameter. */
45
+ client_metadata?: Readonly<Record<string, unknown>>;
46
+ /** Subset of the wallet's supported response formats / curves the verifier
47
+ * is willing to accept. */
48
+ scope?: string;
49
+ }
50
+ /** OID4VP §6 — Authorization Response from wallet to verifier. */
51
+ export interface AuthorizationResponse {
52
+ /** The presentation(s) — a single SD-JWT-VC or an array for multi-credential. */
53
+ vp_token: string | readonly string[];
54
+ /** DIF Presentation Submission mapping descriptors → vp_token positions. */
55
+ presentation_submission: Readonly<Record<string, unknown>>;
56
+ /** Echoes the verifier's `state` from the request. */
57
+ state?: string;
58
+ /** OID4VP §6.4 — the wallet's identifier (e.g. issuer URL). */
59
+ iss?: string;
60
+ }
61
+ /** Stable codes for `Oid4vpError`. */
62
+ export type Oid4vpErrorCode = "oid4vp.invalid_url" | "oid4vp.required_field_missing" | "oid4vp.unsupported_response_type" | "oid4vp.mutually_exclusive_fields" | "oid4vp.response_uri_required" | "oid4vp.invalid_json" | "oid4vp.invalid_value_type" | "oid4vp.malformed_body" | "oid4vp.malformed_submission";
63
+ export declare class Oid4vpError extends Error {
64
+ readonly name = "Oid4vpError";
65
+ readonly code: Oid4vpErrorCode;
66
+ constructor(code: Oid4vpErrorCode, message: string, options?: {
67
+ cause?: unknown;
68
+ });
69
+ }
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,KAAK,GACL,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,oEAAoE;AACpE,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,iBAAiB,GACjB,UAAU,GACV,OAAO,CAAC;AAEZ;;;;2DAI2D;AAC3D,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,aAAa,EAAE,UAAU,CAAC;IAC1B,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB;uEACmE;IACnE,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC,wEAAwE;IACxE,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd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ID4VP Final 1.0 wire-format types.
3
+ * Spec: https://openid.net/specs/openid-4-verifiable-presentations-1_0.html
4
+ *
5
+ * Scope of this package: §5 Authorization Request, §6 Authorization Response.
6
+ * Presentation Definition (§5.4) is modelled but not yet matched/queried —
7
+ * downstream packages will add DIF Presentation Exchange JSONPath support.
8
+ */
9
+ export class Oid4vpError extends Error {
10
+ name = "Oid4vpError";
11
+ code;
12
+ constructor(code, message, options) {
13
+ super(message);
14
+ this.code = code;
15
+ if (options?.cause !== undefined) {
16
+ this.cause = options.cause;
17
+ }
18
+ }
19
+ }
20
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkFH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClB,IAAI,GAAG,aAAa,CAAC;IAC9B,IAAI,CAAkB;IAE/B,YACE,IAAqB,EACrB,OAAe,EACf,OAA6B;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,IAA4B,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QACtD,CAAC;IACH,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@gramota/oid4vp",
3
+ "version": "0.1.0",
4
+ "description": "OpenID for Verifiable Presentations transport — authorization request/response wire format for EUDIW.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "author": "Petromil Pavlov <petromilpavlov@gmail.com>",
19
+ "homepage": "https://github.com/gramota-org/gramota#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/gramota-org/gramota/issues"
22
+ },
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "sideEffects": false,
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org/"
30
+ },
31
+ "keywords": [
32
+ "oid4vp",
33
+ "openid4vp",
34
+ "verifiable-presentations",
35
+ "eudi",
36
+ "authorization-request"
37
+ ],
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/gramota-org/gramota.git",
41
+ "directory": "packages/oid4vp"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.json",
45
+ "typecheck": "tsc -p tsconfig.json --noEmit"
46
+ }
47
+ }