@openid4vc/utils 0.5.6-alpha-20260916130156 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +49 -7
- package/dist/index.d.mts +43 -43
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
# @openid4vc/utils
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<img src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg" />
|
|
6
|
-
</a>
|
|
7
|
-
</p>
|
|
3
|
+
[](https://npmjs.com/package/@openid4vc/utils)
|
|
4
|
+
[](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE)
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
Shared utilities used by the `@openid4vc/*` packages, such as encoding helpers, validation errors, and platform-agnostic `fetch`, `URL` and `URLSearchParams` wrappers.
|
|
7
|
+
|
|
8
|
+
This package is mostly used internally by [`@openid4vc/oauth2`](https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/oauth2), [`@openid4vc/openid4vci`](https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/openid4vci) and [`@openid4vc/openid4vp`](https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/openid4vp).
|
|
9
|
+
|
|
10
|
+
This package was previously developed in the [oid4vc-ts](https://github.com/openwallet-foundation-labs/oid4vc-ts) repository. The `@openid4vc/*` packages are versioned together, separately from the other packages in this repository.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Using npm
|
|
16
|
+
npm install @openid4vc/utils
|
|
17
|
+
|
|
18
|
+
# Using pnpm
|
|
19
|
+
pnpm add @openid4vc/utils
|
|
20
|
+
|
|
21
|
+
# Using yarn
|
|
22
|
+
yarn add @openid4vc/utils
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Dependencies
|
|
26
|
+
|
|
27
|
+
- [buffer](https://www.npmjs.com/package/buffer)
|
|
28
|
+
- [zod](https://www.npmjs.com/package/zod)
|
|
29
|
+
- [zod-validation-error](https://www.npmjs.com/package/zod-validation-error)
|
|
30
|
+
|
|
31
|
+
## Platform Support
|
|
32
|
+
|
|
33
|
+
This library is **platform agnostic** and works in:
|
|
34
|
+
|
|
35
|
+
- ✅ Node.js (>=22)
|
|
36
|
+
- ✅ Browsers (modern browsers with ES2020 support)
|
|
37
|
+
- ✅ React Native
|
|
38
|
+
|
|
39
|
+
The environment must provide an implementation of `URL` and `URLSearchParams`. Platform-specific functionality such as hashing, generating random bytes and signing is provided through callbacks. If no global `fetch` is available in your environment, it also needs to be provided through the callbacks.
|
|
40
|
+
|
|
41
|
+
## Contributing
|
|
42
|
+
|
|
43
|
+
See the [Contributing Guide](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/CONTRIBUTING.md) for details on how to contribute to this project.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
This project is licensed under the [Apache License Version 2.0](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE) (Apache-2.0).
|
|
48
|
+
|
|
49
|
+
## Credits
|
|
50
|
+
|
|
51
|
+
This library was initially created by [Animo](https://animo.id) as part of the [SPRIN-D EUDI Wallet Prototypes Funke](https://www.sprind.org/en/impulses/challenges/eudi-wallet-prototypes).
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import z, { ZodError } from "zod";
|
|
|
4
4
|
* Only primitive types allowed
|
|
5
5
|
* Must have not duplicate entries (will always return false in this case)
|
|
6
6
|
*/
|
|
7
|
-
declare function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(a: Array<Item>, b: Array<Item>): boolean;
|
|
7
|
+
export declare function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(a: Array<Item>, b: Array<Item>): boolean;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/config.d.ts
|
|
10
10
|
interface Oid4vcTsConfig {
|
|
@@ -15,8 +15,8 @@ interface Oid4vcTsConfig {
|
|
|
15
15
|
*/
|
|
16
16
|
allowInsecureUrls: boolean;
|
|
17
17
|
}
|
|
18
|
-
declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
19
|
-
declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
18
|
+
export declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
19
|
+
export declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/globals.d.ts
|
|
22
22
|
declare const _URL: {
|
|
@@ -38,7 +38,7 @@ type FetchHeaders = globalThis.Headers;
|
|
|
38
38
|
type FetchRequestInit = RequestInit;
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/content-type.d.ts
|
|
41
|
-
declare enum ContentType {
|
|
41
|
+
export declare enum ContentType {
|
|
42
42
|
XWwwFormUrlencoded = "application/x-www-form-urlencoded",
|
|
43
43
|
Json = "application/json",
|
|
44
44
|
JwkSet = "application/jwk-set+json",
|
|
@@ -46,44 +46,44 @@ declare enum ContentType {
|
|
|
46
46
|
Jwt = "application/jwt",
|
|
47
47
|
Html = "text/html"
|
|
48
48
|
}
|
|
49
|
-
declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
50
|
-
declare function isResponseContentType(contentType: ContentType | ContentType[], response: FetchResponse): boolean;
|
|
49
|
+
export declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
50
|
+
export declare function isResponseContentType(contentType: ContentType | ContentType[], response: FetchResponse): boolean;
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/date.d.ts
|
|
53
53
|
/**
|
|
54
54
|
* Get the time in seconds since epoch for a date.
|
|
55
55
|
* If date is not provided the current time will be used.
|
|
56
56
|
*/
|
|
57
|
-
declare function dateToSeconds(date?: Date): number;
|
|
58
|
-
declare function addSecondsToDate(date: Date, seconds: number): Date;
|
|
57
|
+
export declare function dateToSeconds(date?: Date): number;
|
|
58
|
+
export declare function addSecondsToDate(date: Date, seconds: number): Date;
|
|
59
59
|
//#endregion
|
|
60
60
|
//#region src/encoding.d.ts
|
|
61
|
-
declare function decodeUtf8String(string: string): Uint8Array;
|
|
62
|
-
declare function encodeToUtf8String(data: Uint8Array): string;
|
|
61
|
+
export declare function decodeUtf8String(string: string): Uint8Array;
|
|
62
|
+
export declare function encodeToUtf8String(data: Uint8Array): string;
|
|
63
63
|
/**
|
|
64
64
|
* Also supports base64 url
|
|
65
65
|
*/
|
|
66
|
-
declare function decodeBase64(base64: string): Uint8Array;
|
|
67
|
-
declare function encodeToBase64(data: Uint8Array | string): string;
|
|
68
|
-
declare function encodeToBase64Url(data: Uint8Array | string): string;
|
|
66
|
+
export declare function decodeBase64(base64: string): Uint8Array;
|
|
67
|
+
export declare function encodeToBase64(data: Uint8Array | string): string;
|
|
68
|
+
export declare function encodeToBase64Url(data: Uint8Array | string): string;
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/error/OpenId4VcBaseError.d.ts
|
|
71
|
-
declare abstract class OpenId4VcBaseError extends Error {}
|
|
71
|
+
export declare abstract class OpenId4VcBaseError extends Error {}
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/error/InvalidFetchResponseError.d.ts
|
|
74
|
-
declare class InvalidFetchResponseError extends OpenId4VcBaseError {
|
|
74
|
+
export declare class InvalidFetchResponseError extends OpenId4VcBaseError {
|
|
75
75
|
readonly textResponse: string;
|
|
76
76
|
readonly response: FetchResponse;
|
|
77
77
|
constructor(message: string, textResponse: string, response: FetchResponse);
|
|
78
78
|
}
|
|
79
79
|
//#endregion
|
|
80
80
|
//#region src/error/JsonParseError.d.ts
|
|
81
|
-
declare class JsonParseError extends OpenId4VcBaseError {
|
|
81
|
+
export declare class JsonParseError extends OpenId4VcBaseError {
|
|
82
82
|
constructor(message: string, jsonString: string);
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/error/ValidationError.d.ts
|
|
86
|
-
declare class ValidationError extends OpenId4VcBaseError {
|
|
86
|
+
export declare class ValidationError extends OpenId4VcBaseError {
|
|
87
87
|
zodError: ZodError | undefined;
|
|
88
88
|
constructor(message: string, zodError?: ZodError);
|
|
89
89
|
}
|
|
@@ -97,7 +97,7 @@ type ZodFetcher = <Schema extends z.ZodTypeAny>(schema: Schema, expectedContentT
|
|
|
97
97
|
response: Awaited<ReturnType<Fetch>>;
|
|
98
98
|
result?: z.ZodSafeParseResult<z.infer<Schema>>;
|
|
99
99
|
}>;
|
|
100
|
-
declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
100
|
+
export declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
101
101
|
/**
|
|
102
102
|
* Creates a `fetchWithZod` function that takes in a schema of
|
|
103
103
|
* the expected response, and the arguments to the fetcher
|
|
@@ -116,23 +116,23 @@ declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
|
116
116
|
* "https://example.com",
|
|
117
117
|
* );
|
|
118
118
|
*/
|
|
119
|
-
declare function createZodFetcher(fetcher?: Fetch): ZodFetcher;
|
|
119
|
+
export declare function createZodFetcher(fetcher?: Fetch): ZodFetcher;
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/object.d.ts
|
|
122
|
-
declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
122
|
+
export declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
123
123
|
/**
|
|
124
124
|
* Deep merge two objects.
|
|
125
125
|
* @param target
|
|
126
126
|
* @param ...sources
|
|
127
127
|
*/
|
|
128
|
-
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
128
|
+
export declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/parse.d.ts
|
|
131
131
|
type BaseSchema = z.ZodTypeAny;
|
|
132
132
|
type InferOutputUnion<T extends readonly any[]> = { [K in keyof T]: z.infer<T[K]>; }[number];
|
|
133
|
-
declare function stringToJsonWithErrorHandling(string: string, errorMessage?: string): any;
|
|
134
|
-
declare function parseIfJson<T>(data: T): T | Record<string, unknown>;
|
|
135
|
-
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z.infer<Schema>;
|
|
133
|
+
export declare function stringToJsonWithErrorHandling(string: string, errorMessage?: string): any;
|
|
134
|
+
export declare function parseIfJson<T>(data: T): T | Record<string, unknown>;
|
|
135
|
+
export declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z.infer<Schema>;
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region src/path.d.ts
|
|
138
138
|
/**
|
|
@@ -141,7 +141,7 @@ declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schem
|
|
|
141
141
|
* @param parts the parts to combine
|
|
142
142
|
* @returns the combined url
|
|
143
143
|
*/
|
|
144
|
-
declare function joinUriParts(base: string, parts: string[]): string;
|
|
144
|
+
export declare function joinUriParts(base: string, parts: string[]): string;
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region src/type.d.ts
|
|
147
147
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
@@ -151,34 +151,34 @@ type OrPromise<T> = T | Promise<T>;
|
|
|
151
151
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/url.d.ts
|
|
154
|
-
declare function getQueryParams(url: string): Record<string, string>;
|
|
155
|
-
declare function objectToQueryParams(object: Record<string, unknown>): InstanceType<typeof _URLSearchParams>;
|
|
154
|
+
export declare function getQueryParams(url: string): Record<string, string>;
|
|
155
|
+
export declare function objectToQueryParams(object: Record<string, unknown>): InstanceType<typeof _URLSearchParams>;
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/validation.d.ts
|
|
158
|
-
declare const zHttpsUrl: z.ZodURL;
|
|
159
|
-
declare const zDataUrl: z.ZodString;
|
|
160
|
-
declare const zInteger: z.ZodNumber;
|
|
158
|
+
export declare const zHttpsUrl: z.ZodURL;
|
|
159
|
+
export declare const zDataUrl: z.ZodString;
|
|
160
|
+
export declare const zInteger: z.ZodNumber;
|
|
161
161
|
/**
|
|
162
162
|
* NumericDate as defined in RFC 7519 Section 2
|
|
163
163
|
* A JSON numeric value representing the number of seconds from
|
|
164
164
|
* 1970-01-01T00:00:00Z UTC until the specified UTC date/time,
|
|
165
165
|
* ignoring leap seconds. Non-integer values can be represented.
|
|
166
166
|
*/
|
|
167
|
-
declare const zNumericDate: z.ZodNumber;
|
|
168
|
-
declare const zHttpMethod: z.ZodEnum<{
|
|
169
|
-
|
|
170
|
-
POST: "POST";
|
|
171
|
-
PUT: "PUT";
|
|
167
|
+
export declare const zNumericDate: z.ZodNumber;
|
|
168
|
+
export declare const zHttpMethod: z.ZodEnum<{
|
|
169
|
+
CONNECT: "CONNECT";
|
|
172
170
|
DELETE: "DELETE";
|
|
171
|
+
GET: "GET";
|
|
173
172
|
HEAD: "HEAD";
|
|
174
173
|
OPTIONS: "OPTIONS";
|
|
175
|
-
TRACE: "TRACE";
|
|
176
|
-
CONNECT: "CONNECT";
|
|
177
174
|
PATCH: "PATCH";
|
|
175
|
+
POST: "POST";
|
|
176
|
+
PUT: "PUT";
|
|
177
|
+
TRACE: "TRACE";
|
|
178
178
|
}>;
|
|
179
179
|
type HttpMethod = z.infer<typeof zHttpMethod>;
|
|
180
|
-
declare const zStringToJson: z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>;
|
|
181
|
-
declare const zIs: <Schema extends z.ZodSchema>(schema: Schema, data: unknown) => data is z.infer<typeof schema>;
|
|
180
|
+
export declare const zStringToJson: z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>;
|
|
181
|
+
export declare const zIs: <Schema extends z.ZodSchema>(schema: Schema, data: unknown) => data is z.infer<typeof schema>;
|
|
182
182
|
//#endregion
|
|
183
183
|
//#region src/www-authenticate.d.ts
|
|
184
184
|
interface WwwAuthenticateHeaderChallenge {
|
|
@@ -189,11 +189,11 @@ interface WwwAuthenticateHeaderChallenge {
|
|
|
189
189
|
*/
|
|
190
190
|
payload: Record<string, string | string[] | null>;
|
|
191
191
|
}
|
|
192
|
-
declare function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[];
|
|
193
|
-
declare function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]): string;
|
|
192
|
+
export declare function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[];
|
|
193
|
+
export declare function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]): string;
|
|
194
194
|
//#endregion
|
|
195
195
|
//#region src/zod-error.d.ts
|
|
196
|
-
declare function formatZodError(error?: z.ZodError): string;
|
|
196
|
+
export declare function formatZodError(error?: z.ZodError): string;
|
|
197
197
|
//#endregion
|
|
198
|
-
export { type BaseSchema,
|
|
198
|
+
export { type BaseSchema, type Fetch, type FetchHeaders, type FetchRequestInit, type FetchResponse, _Headers as Headers, type HttpMethod, type InferOutputUnion, type NonEmptyArray, type Oid4vcTsConfig, type Optional, type OrPromise, type Simplify, type StringWithAutoCompletion, _URL as URL, _URLSearchParams as URLSearchParams, type WwwAuthenticateHeaderChallenge, type ZodFetcher };
|
|
199
199
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -252,7 +252,8 @@ function joinUriParts(base, parts) {
|
|
|
252
252
|
//#endregion
|
|
253
253
|
//#region src/url.ts
|
|
254
254
|
function getQueryParams(url) {
|
|
255
|
-
const
|
|
255
|
+
const parsedUrl = new _URL(url);
|
|
256
|
+
const searchParams = new _URLSearchParams(parsedUrl.search);
|
|
256
257
|
const params = {};
|
|
257
258
|
searchParams.forEach((value, key) => {
|
|
258
259
|
params[key] = value;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["URLSearchParams","URLSearchParams","URL"],"sources":["../src/array.ts","../src/config.ts","../src/content-type.ts","../src/date.ts","../src/encoding.ts","../src/error/OpenId4VcBaseError.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/zod-error.ts","../src/error/ValidationError.ts","../src/error/FetchError.ts","../src/globals.ts","../src/fetcher.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n OAuthAuthorizationRequestJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n Html = 'text/html',\n}\n\nexport function isContentType(contentType: ContentType, value: string) {\n return value.toLowerCase().includes(contentType)\n}\n\nexport function isResponseContentType(contentType: ContentType | ContentType[], response: FetchResponse) {\n const contentTypeArray = Array.isArray(contentType) ? contentType : [contentType]\n\n const header = response.headers.get('Content-Type')\n if (!header) return false\n return contentTypeArray.some((contentTypeEntry) => isContentType(contentTypeEntry, header))\n}\n","/**\n * Get the time in seconds since epoch for a date.\n * If date is not provided the current time will be used.\n */\nexport function dateToSeconds(date?: Date) {\n const milliseconds = date?.getTime() ?? Date.now()\n\n return Math.floor(milliseconds / 1000)\n}\n\nexport function addSecondsToDate(date: Date, seconds: number) {\n return new Date(date.getTime() + seconds * 1000)\n}\n","import { Buffer } from 'buffer'\n\nexport function decodeUtf8String(string: string): Uint8Array {\n return new Uint8Array(Buffer.from(string, 'utf-8'))\n}\n\nexport function encodeToUtf8String(data: Uint8Array) {\n return Buffer.from(data).toString('utf-8')\n}\n\n/**\n * Also supports base64 url\n */\nexport function decodeBase64(base64: string): Uint8Array {\n return new Uint8Array(Buffer.from(base64, 'base64'))\n}\n\nexport function encodeToBase64(data: Uint8Array | string) {\n // To make ts happy. Somehow Uint8Array or string is no bueno\n if (typeof data === 'string') {\n return Buffer.from(data).toString('base64')\n }\n\n return Buffer.from(data).toString('base64')\n}\n\nexport function encodeToBase64Url(data: Uint8Array | string) {\n return base64ToBase64Url(encodeToBase64(data))\n}\n\n/**\n * The 'buffer' npm library does not support base64url.\n */\nfunction base64ToBase64Url(base64: string) {\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '')\n}\n","export abstract class OpenId4VcBaseError extends Error {}\n","import { ContentType, isResponseContentType } from '../content-type'\nimport type { FetchResponse } from '../globals'\nimport { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class InvalidFetchResponseError extends OpenId4VcBaseError {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n // We don't want to put html content in pages. For other content we take the first 1000 characters\n // to prevent ridiculously long errors.\n const textResponseMessage = isResponseContentType(ContentType.Html, response)\n ? undefined\n : textResponse.substring(0, 1000)\n\n super(textResponseMessage ? `${message}\\n${textResponseMessage}` : message)\n\n this.response = response.clone()\n }\n}\n","import { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class JsonParseError extends OpenId4VcBaseError {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import z from 'zod'\nimport { createErrorMap, fromError } from 'zod-validation-error'\n\nz.config({\n customError: createErrorMap(),\n})\n\nexport function formatZodError(error?: z.ZodError): string {\n if (!error) return ''\n\n return fromError(error, { prefix: '', prefixSeparator: '✖ ', issueSeparator: '\\n✖ ' }).toString()\n}\n","import type { ZodError } from 'zod'\nimport { formatZodError } from '../zod-error'\nimport { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class ValidationError extends OpenId4VcBaseError {\n public zodError: ZodError | undefined\n\n constructor(message: string, zodError?: ZodError) {\n super(message)\n\n const formattedError = zodError ? formatZodError(zodError) : ''\n this.message = `${message}\\n${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","import { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class FetchError extends OpenId4VcBaseError {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _Headers as Headers, _URL as URL, _URLSearchParams as URLSearchParams }\n","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType | ContentType[],\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.ZodSafeParseResult<z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n// biome-ignore lint/style/noRestrictedGlobals: this is the only place where we use the global\nconst defaultFetcher = fetch\n\nexport function createFetcher(fetcher = defaultFetcher): Fetch {\n return (input, init, ...args) => {\n return fetcher(\n input,\n init\n ? {\n ...init,\n // React Native does not seem to handle the toString(). This is hard to catch when running\n // tests in Node.JS where this does work correctly. so we handle it here.\n body: init.body instanceof URLSearchParams ? init.body.toString() : init.body,\n }\n : undefined,\n ...args\n ).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${input}'`, { cause: error })\n })\n }\n}\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher?: Fetch): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await createFetcher(fetcher)(...args)\n\n const expectedContentTypeArray = Array.isArray(expectedContentType) ? expectedContentType : [expectedContentType]\n\n if (response.ok && !isResponseContentType(expectedContentTypeArray, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type ${expectedContentTypeArray.join(' | ')}, but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (isResponseContentType([ContentType.OAuthAuthorizationRequestJwt, ContentType.Jwt], response)) {\n return {\n response,\n result: response.ok ? schema.safeParse(await response.text()) : undefined,\n }\n }\n\n return {\n response,\n result: response.ok ? schema.safeParse(await response.json()) : undefined,\n }\n }\n}\n","export function isObject(item: unknown): item is Record<string, unknown> {\n return item != null && typeof item === 'object' && !Array.isArray(item)\n}\n\n/**\n * Deep merge two objects.\n * @param target\n * @param ...sources\n */\nexport function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown {\n if (!sources.length) return target\n const source = sources.shift()\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} })\n mergeDeep(target[key], source[key])\n } else {\n Object.assign(target, { [key]: source[key] })\n }\n }\n }\n\n return mergeDeep(target, ...sources)\n}\n","import type z from 'zod'\nimport { JsonParseError } from './error/JsonParseError'\nimport { ValidationError } from './error/ValidationError'\n\nexport type BaseSchema = z.ZodTypeAny\n// biome-ignore lint/suspicious/noExplicitAny: no explanation\nexport type InferOutputUnion<T extends readonly any[]> = {\n [K in keyof T]: z.infer<T[K]>\n}[number]\n\nexport function stringToJsonWithErrorHandling(string: string, errorMessage?: string) {\n try {\n return JSON.parse(string)\n } catch (_error) {\n throw new JsonParseError(errorMessage ?? 'Unable to parse string to JSON.', string)\n }\n}\n\nexport function parseIfJson<T>(data: T): T | Record<string, unknown> {\n if (typeof data !== 'string') {\n return data\n }\n\n try {\n // Try to parse the string as JSON\n return JSON.parse(data)\n } catch (_error) {}\n\n return data\n}\n\nexport function parseWithErrorHandling<Schema extends BaseSchema>(\n schema: Schema,\n data: unknown,\n customErrorMessage?: string\n): z.infer<Schema> {\n const parseResult = schema.safeParse(data)\n\n if (!parseResult.success) {\n throw new ValidationError(\n customErrorMessage ?? `Error validating schema with data ${JSON.stringify(data)}`,\n parseResult.error\n )\n }\n\n return parseResult.data\n}\n","/**\n * Combine multiple uri parts into a single uri taking into account slashes.\n *\n * @param parts the parts to combine\n * @returns the combined url\n */\nexport function joinUriParts(base: string, parts: string[]) {\n if (parts.length === 0) return base\n\n // take base without trailing /\n let combined = base.trim()\n combined = base.endsWith('/') ? base.slice(0, base.length - 1) : base\n\n for (const part of parts) {\n // Remove leading and trailing /\n let strippedPart = part.trim()\n strippedPart = strippedPart.startsWith('/') ? strippedPart.slice(1) : strippedPart\n strippedPart = strippedPart.endsWith('/') ? strippedPart.slice(0, strippedPart.length - 1) : strippedPart\n\n // Don't want to add if empty\n if (strippedPart === '') continue\n\n combined += `/${strippedPart}`\n }\n\n return combined\n}\n","import { URL, URLSearchParams } from './globals'\n\nexport function getQueryParams(url: string) {\n const parsedUrl = new URL(url)\n const searchParams = new URLSearchParams(parsedUrl.search)\n const params: Record<string, string> = {}\n\n searchParams.forEach((value, key) => {\n params[key] = value\n })\n\n return params\n}\n\nexport function objectToQueryParams(object: Record<string, unknown>): InstanceType<typeof URLSearchParams> {\n const params = new URLSearchParams()\n\n for (const [key, value] of Object.entries(object)) {\n if (value != null) {\n params.append(key, typeof value === 'object' ? JSON.stringify(value) : String(value))\n }\n }\n\n return params\n}\n","import z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z.url().refine(\n (url) => {\n const { allowInsecureUrls } = getGlobalConfig()\n return allowInsecureUrls ? url.startsWith('http://') || url.startsWith('https://') : url.startsWith('https://')\n },\n { message: 'url must be an https:// url' }\n)\n\nexport const zDataUrl = z.string().regex(/data:[\\w/\\-.]+;\\w+,.*/, 'url must be a data URL')\n\nexport const zInteger = z.number().int()\n\n/**\n * NumericDate as defined in RFC 7519 Section 2\n * A JSON numeric value representing the number of seconds from\n * 1970-01-01T00:00:00Z UTC until the specified UTC date/time,\n * ignoring leap seconds. Non-integer values can be represented.\n */\nexport const zNumericDate = z.number()\n\nexport const zHttpMethod = z.enum(['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT', 'PATCH'])\nexport type HttpMethod = z.infer<typeof zHttpMethod>\n\nexport const zStringToJson = z.string().transform((string, ctx) => {\n try {\n return JSON.parse(string)\n } catch (_error) {\n ctx.addIssue({\n code: 'custom',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n })\n return z.NEVER\n }\n})\n\nexport const zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\n","const unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\\"/g, '\"')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: no explanation\n /((?:[a-zA-Z0-9._~+/-]+=*(?:\\s+|$))|[^\\u0000-\\u001F\\u007F()<>@,;:\\\\\"/?={}[\\]\\u0020\\u0009]+)(?:=([^\\\\\"=\\s,]+|\"(?:[^\"\\\\]|\\\\.)*\"))?/g\n\nexport interface WwwAuthenticateHeaderChallenge {\n scheme: string\n\n /**\n * Record where the keys are the names, and the value can be 0 (null), 1 (string) or multiple (string[])\n * entries\n */\n payload: Record<string, string | string[] | null>\n}\n\nconst parsePayload = (scheme: string, string: string): WwwAuthenticateHeaderChallenge => {\n const payload: Record<string, string | string[] | null> = {}\n\n while (true) {\n const res = body.exec(string)\n if (!res) break\n\n const [, key, newValue] = res\n\n const payloadValue = payload[key]\n if (newValue) {\n const sanitizedValue = sanitize(newValue)\n payload[key] = payloadValue\n ? Array.isArray(payloadValue)\n ? [...payloadValue, sanitizedValue]\n : [payloadValue, sanitizedValue]\n : sanitizedValue\n } else if (!payloadValue) {\n payload[key] = null\n }\n }\n\n return { scheme, payload }\n}\n\nexport function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[] {\n const start = str.indexOf(' ')\n let scheme = str.substring(0, start)\n let value = str.substring(start)\n\n const challenges: WwwAuthenticateHeaderChallenge[] = []\n\n // Some well-known schemes to support-multi parsing\n const endsWithSchemeRegex = /, ?(Bearer|DPoP|Basic)$/\n const endsWithSchemeTest = endsWithSchemeRegex.exec(value)\n let endsWithScheme: string | undefined\n if (endsWithSchemeTest) {\n value = value.substring(0, value.length - endsWithSchemeTest[0].length)\n endsWithScheme = endsWithSchemeTest[1]\n }\n\n const additionalSchemesRegex = /(.*?)(, ?)(Bearer|DPoP|Basic)[, ]/\n let match = additionalSchemesRegex.exec(value)\n while (match) {\n challenges.push(parsePayload(scheme, match[1]))\n value = value.substring(match[0].length - 1)\n scheme = match[3]\n\n match = additionalSchemesRegex.exec(value)\n }\n challenges.push(parsePayload(scheme, value))\n if (endsWithScheme) {\n challenges.push({ scheme: endsWithScheme, payload: {} })\n }\n return challenges\n}\n\nexport function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]) {\n const entries: string[] = []\n\n for (const challenge of challenges) {\n // Encode each parameter according to RFC 7235\n const encodedParams = Object.entries(challenge.payload).flatMap(([key, value]) => {\n const encode = (s: string) => s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n // Convert value to string and escape special characters\n if (Array.isArray(value)) {\n return value.map((v) => `${key}=\"${encode(v)}\"`)\n }\n\n return value ? `${key}=\"${encode(value)}\"` : key\n })\n\n entries.push(encodedParams.length === 0 ? challenge.scheme : `${challenge.scheme} ${encodedParams.join(', ')}`)\n }\n\n return entries.join(', ')\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,uBACd,GACA,GACS;CACT,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO;CAChD,IAAI,EAAE,WAAW,EAAE,QAAQ,OAAO;CAElC,OAAO,EAAE,OAAO,MAAM,EAAE,SAAS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CAC/B,IAAI,QAAQ,uBAAuB,KAAK,KAAK;CAC7C,OAAO,OAAO;EACZ,WAAW,KAAK,aAAa,QAAQ,MAAM,EAAE,CAAC;EAC9C,QAAQ,MAAM,UAAU,MAAM,EAAE,CAAC,SAAS,CAAC;EAC3C,SAAS,MAAM;EAEf,QAAQ,uBAAuB,KAAK,KAAK;CAC3C;CACA,WAAW,KAAK,aAAa,QAAQ,KAAK,CAAC;CAC3C,IAAI,gBACF,WAAW,KAAK;EAAE,QAAQ;EAAgB,SAAS,CAAC;CAAE,CAAC;CAEzD,OAAO;AACT;AAEA,SAAgB,4BAA4B,YAA8C;CACxF,MAAM,UAAoB,CAAC;CAE3B,KAAK,MAAM,aAAa,YAAY;EAElC,MAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;GAChF,MAAM,UAAU,MAAc,EAAE,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK;GAE1E,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,MAAM,GAAG,IAAI,IAAI,OAAO,CAAC,EAAE,EAAE;GAGjD,OAAO,QAAQ,GAAG,IAAI,IAAI,OAAO,KAAK,EAAE,KAAK;EAC/C,CAAC;EAED,QAAQ,KAAK,cAAc,WAAW,IAAI,UAAU,SAAS,GAAG,UAAU,OAAO,GAAG,cAAc,KAAK,IAAI,GAAG;CAChH;CAEA,OAAO,QAAQ,KAAK,IAAI;AAC1B"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["URLSearchParams","URL","URLSearchParams"],"sources":["../src/array.ts","../src/config.ts","../src/content-type.ts","../src/date.ts","../src/encoding.ts","../src/error/OpenId4VcBaseError.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/zod-error.ts","../src/error/ValidationError.ts","../src/error/FetchError.ts","../src/globals.ts","../src/fetcher.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n OAuthAuthorizationRequestJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n Html = 'text/html',\n}\n\nexport function isContentType(contentType: ContentType, value: string) {\n return value.toLowerCase().includes(contentType)\n}\n\nexport function isResponseContentType(contentType: ContentType | ContentType[], response: FetchResponse) {\n const contentTypeArray = Array.isArray(contentType) ? contentType : [contentType]\n\n const header = response.headers.get('Content-Type')\n if (!header) return false\n return contentTypeArray.some((contentTypeEntry) => isContentType(contentTypeEntry, header))\n}\n","/**\n * Get the time in seconds since epoch for a date.\n * If date is not provided the current time will be used.\n */\nexport function dateToSeconds(date?: Date) {\n const milliseconds = date?.getTime() ?? Date.now()\n\n return Math.floor(milliseconds / 1000)\n}\n\nexport function addSecondsToDate(date: Date, seconds: number) {\n return new Date(date.getTime() + seconds * 1000)\n}\n","import { Buffer } from 'buffer'\n\nexport function decodeUtf8String(string: string): Uint8Array {\n return new Uint8Array(Buffer.from(string, 'utf-8'))\n}\n\nexport function encodeToUtf8String(data: Uint8Array) {\n return Buffer.from(data).toString('utf-8')\n}\n\n/**\n * Also supports base64 url\n */\nexport function decodeBase64(base64: string): Uint8Array {\n return new Uint8Array(Buffer.from(base64, 'base64'))\n}\n\nexport function encodeToBase64(data: Uint8Array | string) {\n // To make ts happy. Somehow Uint8Array or string is no bueno\n if (typeof data === 'string') {\n return Buffer.from(data).toString('base64')\n }\n\n return Buffer.from(data).toString('base64')\n}\n\nexport function encodeToBase64Url(data: Uint8Array | string) {\n return base64ToBase64Url(encodeToBase64(data))\n}\n\n/**\n * The 'buffer' npm library does not support base64url.\n */\nfunction base64ToBase64Url(base64: string) {\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '')\n}\n","export abstract class OpenId4VcBaseError extends Error {}\n","import { ContentType, isResponseContentType } from '../content-type'\nimport type { FetchResponse } from '../globals'\nimport { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class InvalidFetchResponseError extends OpenId4VcBaseError {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n // We don't want to put html content in pages. For other content we take the first 1000 characters\n // to prevent ridiculously long errors.\n const textResponseMessage = isResponseContentType(ContentType.Html, response)\n ? undefined\n : textResponse.substring(0, 1000)\n\n super(textResponseMessage ? `${message}\\n${textResponseMessage}` : message)\n\n this.response = response.clone()\n }\n}\n","import { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class JsonParseError extends OpenId4VcBaseError {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import z from 'zod'\nimport { createErrorMap, fromError } from 'zod-validation-error'\n\nz.config({\n customError: createErrorMap(),\n})\n\nexport function formatZodError(error?: z.ZodError): string {\n if (!error) return ''\n\n return fromError(error, { prefix: '', prefixSeparator: '✖ ', issueSeparator: '\\n✖ ' }).toString()\n}\n","import type { ZodError } from 'zod'\nimport { formatZodError } from '../zod-error'\nimport { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class ValidationError extends OpenId4VcBaseError {\n public zodError: ZodError | undefined\n\n constructor(message: string, zodError?: ZodError) {\n super(message)\n\n const formattedError = zodError ? formatZodError(zodError) : ''\n this.message = `${message}\\n${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","import { OpenId4VcBaseError } from './OpenId4VcBaseError'\n\nexport class FetchError extends OpenId4VcBaseError {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _Headers as Headers, _URL as URL, _URLSearchParams as URLSearchParams }\n","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType | ContentType[],\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.ZodSafeParseResult<z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n// biome-ignore lint/style/noRestrictedGlobals: this is the only place where we use the global\nconst defaultFetcher = fetch\n\nexport function createFetcher(fetcher = defaultFetcher): Fetch {\n return (input, init, ...args) => {\n return fetcher(\n input,\n init\n ? {\n ...init,\n // React Native does not seem to handle the toString(). This is hard to catch when running\n // tests in Node.JS where this does work correctly. so we handle it here.\n body: init.body instanceof URLSearchParams ? init.body.toString() : init.body,\n }\n : undefined,\n ...args\n ).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${input}'`, { cause: error })\n })\n }\n}\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher?: Fetch): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await createFetcher(fetcher)(...args)\n\n const expectedContentTypeArray = Array.isArray(expectedContentType) ? expectedContentType : [expectedContentType]\n\n if (response.ok && !isResponseContentType(expectedContentTypeArray, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type ${expectedContentTypeArray.join(' | ')}, but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (isResponseContentType([ContentType.OAuthAuthorizationRequestJwt, ContentType.Jwt], response)) {\n return {\n response,\n result: response.ok ? schema.safeParse(await response.text()) : undefined,\n }\n }\n\n return {\n response,\n result: response.ok ? schema.safeParse(await response.json()) : undefined,\n }\n }\n}\n","export function isObject(item: unknown): item is Record<string, unknown> {\n return item != null && typeof item === 'object' && !Array.isArray(item)\n}\n\n/**\n * Deep merge two objects.\n * @param target\n * @param ...sources\n */\nexport function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown {\n if (!sources.length) return target\n const source = sources.shift()\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} })\n mergeDeep(target[key], source[key])\n } else {\n Object.assign(target, { [key]: source[key] })\n }\n }\n }\n\n return mergeDeep(target, ...sources)\n}\n","import type z from 'zod'\nimport { JsonParseError } from './error/JsonParseError'\nimport { ValidationError } from './error/ValidationError'\n\nexport type BaseSchema = z.ZodTypeAny\n// biome-ignore lint/suspicious/noExplicitAny: no explanation\nexport type InferOutputUnion<T extends readonly any[]> = {\n [K in keyof T]: z.infer<T[K]>\n}[number]\n\nexport function stringToJsonWithErrorHandling(string: string, errorMessage?: string) {\n try {\n return JSON.parse(string)\n } catch (_error) {\n throw new JsonParseError(errorMessage ?? 'Unable to parse string to JSON.', string)\n }\n}\n\nexport function parseIfJson<T>(data: T): T | Record<string, unknown> {\n if (typeof data !== 'string') {\n return data\n }\n\n try {\n // Try to parse the string as JSON\n return JSON.parse(data)\n } catch (_error) {}\n\n return data\n}\n\nexport function parseWithErrorHandling<Schema extends BaseSchema>(\n schema: Schema,\n data: unknown,\n customErrorMessage?: string\n): z.infer<Schema> {\n const parseResult = schema.safeParse(data)\n\n if (!parseResult.success) {\n throw new ValidationError(\n customErrorMessage ?? `Error validating schema with data ${JSON.stringify(data)}`,\n parseResult.error\n )\n }\n\n return parseResult.data\n}\n","/**\n * Combine multiple uri parts into a single uri taking into account slashes.\n *\n * @param parts the parts to combine\n * @returns the combined url\n */\nexport function joinUriParts(base: string, parts: string[]) {\n if (parts.length === 0) return base\n\n // take base without trailing /\n let combined = base.trim()\n combined = base.endsWith('/') ? base.slice(0, base.length - 1) : base\n\n for (const part of parts) {\n // Remove leading and trailing /\n let strippedPart = part.trim()\n strippedPart = strippedPart.startsWith('/') ? strippedPart.slice(1) : strippedPart\n strippedPart = strippedPart.endsWith('/') ? strippedPart.slice(0, strippedPart.length - 1) : strippedPart\n\n // Don't want to add if empty\n if (strippedPart === '') continue\n\n combined += `/${strippedPart}`\n }\n\n return combined\n}\n","import { URL, URLSearchParams } from './globals'\n\nexport function getQueryParams(url: string) {\n const parsedUrl = new URL(url)\n const searchParams = new URLSearchParams(parsedUrl.search)\n const params: Record<string, string> = {}\n\n searchParams.forEach((value, key) => {\n params[key] = value\n })\n\n return params\n}\n\nexport function objectToQueryParams(object: Record<string, unknown>): InstanceType<typeof URLSearchParams> {\n const params = new URLSearchParams()\n\n for (const [key, value] of Object.entries(object)) {\n if (value != null) {\n params.append(key, typeof value === 'object' ? JSON.stringify(value) : String(value))\n }\n }\n\n return params\n}\n","import z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z.url().refine(\n (url) => {\n const { allowInsecureUrls } = getGlobalConfig()\n return allowInsecureUrls ? url.startsWith('http://') || url.startsWith('https://') : url.startsWith('https://')\n },\n { message: 'url must be an https:// url' }\n)\n\nexport const zDataUrl = z.string().regex(/data:[\\w/\\-.]+;\\w+,.*/, 'url must be a data URL')\n\nexport const zInteger = z.number().int()\n\n/**\n * NumericDate as defined in RFC 7519 Section 2\n * A JSON numeric value representing the number of seconds from\n * 1970-01-01T00:00:00Z UTC until the specified UTC date/time,\n * ignoring leap seconds. Non-integer values can be represented.\n */\nexport const zNumericDate = z.number()\n\nexport const zHttpMethod = z.enum(['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT', 'PATCH'])\nexport type HttpMethod = z.infer<typeof zHttpMethod>\n\nexport const zStringToJson = z.string().transform((string, ctx) => {\n try {\n return JSON.parse(string)\n } catch (_error) {\n ctx.addIssue({\n code: 'custom',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n })\n return z.NEVER\n }\n})\n\nexport const zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\n","const unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\\"/g, '\"')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: no explanation\n /((?:[a-zA-Z0-9._~+/-]+=*(?:\\s+|$))|[^\\u0000-\\u001F\\u007F()<>@,;:\\\\\"/?={}[\\]\\u0020\\u0009]+)(?:=([^\\\\\"=\\s,]+|\"(?:[^\"\\\\]|\\\\.)*\"))?/g\n\nexport interface WwwAuthenticateHeaderChallenge {\n scheme: string\n\n /**\n * Record where the keys are the names, and the value can be 0 (null), 1 (string) or multiple (string[])\n * entries\n */\n payload: Record<string, string | string[] | null>\n}\n\nconst parsePayload = (scheme: string, string: string): WwwAuthenticateHeaderChallenge => {\n const payload: Record<string, string | string[] | null> = {}\n\n while (true) {\n const res = body.exec(string)\n if (!res) break\n\n const [, key, newValue] = res\n\n const payloadValue = payload[key]\n if (newValue) {\n const sanitizedValue = sanitize(newValue)\n payload[key] = payloadValue\n ? Array.isArray(payloadValue)\n ? [...payloadValue, sanitizedValue]\n : [payloadValue, sanitizedValue]\n : sanitizedValue\n } else if (!payloadValue) {\n payload[key] = null\n }\n }\n\n return { scheme, payload }\n}\n\nexport function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[] {\n const start = str.indexOf(' ')\n let scheme = str.substring(0, start)\n let value = str.substring(start)\n\n const challenges: WwwAuthenticateHeaderChallenge[] = []\n\n // Some well-known schemes to support-multi parsing\n const endsWithSchemeRegex = /, ?(Bearer|DPoP|Basic)$/\n const endsWithSchemeTest = endsWithSchemeRegex.exec(value)\n let endsWithScheme: string | undefined\n if (endsWithSchemeTest) {\n value = value.substring(0, value.length - endsWithSchemeTest[0].length)\n endsWithScheme = endsWithSchemeTest[1]\n }\n\n const additionalSchemesRegex = /(.*?)(, ?)(Bearer|DPoP|Basic)[, ]/\n let match = additionalSchemesRegex.exec(value)\n while (match) {\n challenges.push(parsePayload(scheme, match[1]))\n value = value.substring(match[0].length - 1)\n scheme = match[3]\n\n match = additionalSchemesRegex.exec(value)\n }\n challenges.push(parsePayload(scheme, value))\n if (endsWithScheme) {\n challenges.push({ scheme: endsWithScheme, payload: {} })\n }\n return challenges\n}\n\nexport function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]) {\n const entries: string[] = []\n\n for (const challenge of challenges) {\n // Encode each parameter according to RFC 7235\n const encodedParams = Object.entries(challenge.payload).flatMap(([key, value]) => {\n const encode = (s: string) => s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n // Convert value to string and escape special characters\n if (Array.isArray(value)) {\n return value.map((v) => `${key}=\"${encode(v)}\"`)\n }\n\n return value ? `${key}=\"${encode(value)}\"` : key\n })\n\n entries.push(encodedParams.length === 0 ? challenge.scheme : `${challenge.scheme} ${encodedParams.join(', ')}`)\n }\n\n return entries.join(', ')\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,uBACd,GACA,GACS;CACT,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO;CAChD,IAAI,EAAE,WAAW,EAAE,QAAQ,OAAO;CAElC,OAAO,EAAE,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC;AACrC;;;ACHA,IAAI,gBAAgC,EAClC,mBAAmB,MACrB;AAEA,SAAgB,gBAAgB,QAAwB;CACtD,gBAAgB;AAClB;AAEA,SAAgB,kBAAkC;CAChD,OAAO;AACT;;;ACjBA,IAAY,cAAL,yBAAA,aAAA;CACL,YAAA,wBAAA;CACA,YAAA,UAAA;CACA,YAAA,YAAA;CACA,YAAA,kCAAA;CACA,YAAA,SAAA;CACA,YAAA,UAAA;;AACF,EAAA,CAAA,CAAA;AAEA,SAAgB,cAAc,aAA0B,OAAe;CACrE,OAAO,MAAM,YAAY,CAAC,CAAC,SAAS,WAAW;AACjD;AAEA,SAAgB,sBAAsB,aAA0C,UAAyB;CACvG,MAAM,mBAAmB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;CAEhF,MAAM,SAAS,SAAS,QAAQ,IAAI,cAAc;CAClD,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,iBAAi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CAAC,CAAC,QAAQ,MAAM,MAAK;GAE1E,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,MAAM,GAAG,IAAI,IAAI,OAAO,CAAC,EAAE,EAAE;GAGjD,OAAO,QAAQ,GAAG,IAAI,IAAI,OAAO,KAAK,EAAE,KAAK;EAC/C,CAAC;EAED,QAAQ,KAAK,cAAc,WAAW,IAAI,UAAU,SAAS,GAAG,UAAU,OAAO,GAAG,cAAc,KAAK,IAAI,GAAG;CAChH;CAEA,OAAO,QAAQ,KAAK,IAAI;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openid4vc/utils",
|
|
3
|
-
"version": "0.5.6
|
|
3
|
+
"version": "0.5.6",
|
|
4
|
+
"description": "Shared utilities for the @openid4vc packages",
|
|
4
5
|
"files": [
|
|
5
6
|
"dist"
|
|
6
7
|
],
|
|
7
8
|
"license": "Apache-2.0",
|
|
9
|
+
"author": "Animo Solutions",
|
|
8
10
|
"exports": {
|
|
9
|
-
".":
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
10
15
|
"./package.json": "./package.json"
|
|
11
16
|
},
|
|
12
|
-
"homepage": "https://github.com/openwallet-foundation-labs/
|
|
17
|
+
"homepage": "https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/openid4vc-utils",
|
|
13
18
|
"repository": {
|
|
14
19
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/openwallet-foundation-labs/
|
|
16
|
-
"directory": "packages/utils"
|
|
20
|
+
"url": "https://github.com/openwallet-foundation-labs/identity-common-ts",
|
|
21
|
+
"directory": "packages/openid4vc-utils"
|
|
17
22
|
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"openid4vc"
|
|
28
|
+
],
|
|
18
29
|
"dependencies": {
|
|
19
30
|
"buffer": "^6.0.3",
|
|
20
|
-
"zod": "^4.
|
|
31
|
+
"zod": "^4.6.5",
|
|
21
32
|
"zod-validation-error": "^5.0.0"
|
|
22
33
|
},
|
|
23
34
|
"scripts": {
|
|
24
35
|
"build": "tsdown src/index.ts --format esm --dts --sourcemap"
|
|
25
36
|
},
|
|
37
|
+
"main": "./dist/index.mjs",
|
|
26
38
|
"module": "./dist/index.mjs",
|
|
27
39
|
"types": "./dist/index.d.mts"
|
|
28
40
|
}
|