@openid4vc/utils 0.3.0-alpha-20250206100745 → 0.3.0-alpha-20250225095929
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/dist/index.d.mts +41 -37
- package/dist/index.d.ts +41 -37
- package/dist/index.js +84 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,12 @@ declare const _Headers: typeof globalThis.Headers;
|
|
|
18
18
|
type FetchHeaders = globalThis.Headers;
|
|
19
19
|
type FetchRequestInit = RequestInit;
|
|
20
20
|
|
|
21
|
+
declare class InvalidFetchResponseError extends Error {
|
|
22
|
+
readonly textResponse: string;
|
|
23
|
+
readonly response: FetchResponse;
|
|
24
|
+
constructor(message: string, textResponse: string, response: FetchResponse);
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
declare class JsonParseError extends Error {
|
|
22
28
|
constructor(message: string, jsonString: string);
|
|
23
29
|
}
|
|
@@ -32,11 +38,32 @@ declare class ValidationError extends Error {
|
|
|
32
38
|
constructor(message: string, zodError?: z.ZodError);
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Only primitive types allowed
|
|
43
|
+
* Must have not duplicate entries (will always return false in this case)
|
|
44
|
+
*/
|
|
45
|
+
declare function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(a: Array<Item>, b: Array<Item>): boolean;
|
|
46
|
+
|
|
47
|
+
interface Oid4vcTsConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Whether to allow insecure http urls.
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
allowInsecureUrls: boolean;
|
|
39
54
|
}
|
|
55
|
+
declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
56
|
+
declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
57
|
+
|
|
58
|
+
declare enum ContentType {
|
|
59
|
+
XWwwFormUrlencoded = "application/x-www-form-urlencoded",
|
|
60
|
+
Json = "application/json",
|
|
61
|
+
JwkSet = "application/jwk-set+json",
|
|
62
|
+
OAuthRequestObjectJwt = "application/oauth-authz-req+jwt",
|
|
63
|
+
Jwt = "application/jwt"
|
|
64
|
+
}
|
|
65
|
+
declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
66
|
+
declare function isResponseContentType(contentType: ContentType, response: FetchResponse): boolean;
|
|
40
67
|
|
|
41
68
|
/**
|
|
42
69
|
* Get the time in seconds since epoch for a date.
|
|
@@ -54,11 +81,20 @@ declare function decodeBase64(base64: string): Uint8Array;
|
|
|
54
81
|
declare function encodeToBase64(data: Uint8Array | string): string;
|
|
55
82
|
declare function encodeToBase64Url(data: Uint8Array | string): string;
|
|
56
83
|
|
|
84
|
+
declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Deep merge two objects.
|
|
87
|
+
* @param target
|
|
88
|
+
* @param ...sources
|
|
89
|
+
*/
|
|
90
|
+
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
91
|
+
|
|
57
92
|
type BaseSchema = z.ZodTypeAny;
|
|
58
93
|
type InferOutputUnion<T extends readonly any[]> = {
|
|
59
94
|
[K in keyof T]: z.infer<T[K]>;
|
|
60
95
|
}[number];
|
|
61
96
|
declare function stringToJsonWithErrorHandling(string: string, errorMessage?: string): any;
|
|
97
|
+
declare function parseIfJson<T>(data: T): T | Record<string, unknown>;
|
|
62
98
|
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z.infer<Schema>;
|
|
63
99
|
|
|
64
100
|
/**
|
|
@@ -79,14 +115,6 @@ type OrPromise<T> = T | Promise<T>;
|
|
|
79
115
|
declare function getQueryParams(url: string): Record<string, string>;
|
|
80
116
|
declare function objectToQueryParams(object: Record<string, unknown>): InstanceType<typeof _URLSearchParams>;
|
|
81
117
|
|
|
82
|
-
declare enum ContentType {
|
|
83
|
-
XWwwFormUrlencoded = "application/x-www-form-urlencoded",
|
|
84
|
-
Json = "application/json",
|
|
85
|
-
JwkSet = "application/jwk-set+json"
|
|
86
|
-
}
|
|
87
|
-
declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
88
|
-
declare function isResponseContentType(contentType: ContentType, response: FetchResponse): boolean;
|
|
89
|
-
|
|
90
118
|
/**
|
|
91
119
|
* A type utility which represents the function returned
|
|
92
120
|
* from createZodFetcher
|
|
@@ -126,19 +154,6 @@ declare const zHttpMethod: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "HEAD", "O
|
|
|
126
154
|
type HttpMethod = z.infer<typeof zHttpMethod>;
|
|
127
155
|
declare const zIs: <Schema extends z.ZodSchema>(schema: Schema, data: unknown) => data is z.infer<typeof schema>;
|
|
128
156
|
|
|
129
|
-
/**
|
|
130
|
-
* Deep merge two objects.
|
|
131
|
-
* @param target
|
|
132
|
-
* @param ...sources
|
|
133
|
-
*/
|
|
134
|
-
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Only primitive types allowed
|
|
138
|
-
* Must have not duplicate entries (will always return false in this case)
|
|
139
|
-
*/
|
|
140
|
-
declare function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(a: Array<Item>, b: Array<Item>): boolean;
|
|
141
|
-
|
|
142
157
|
interface WwwAuthenticateHeaderChallenge {
|
|
143
158
|
scheme: string;
|
|
144
159
|
/**
|
|
@@ -150,15 +165,4 @@ interface WwwAuthenticateHeaderChallenge {
|
|
|
150
165
|
declare function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[];
|
|
151
166
|
declare function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]): string;
|
|
152
167
|
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Whether to allow insecure http urls.
|
|
156
|
-
*
|
|
157
|
-
* @default false
|
|
158
|
-
*/
|
|
159
|
-
allowInsecureUrls: boolean;
|
|
160
|
-
}
|
|
161
|
-
declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
162
|
-
declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
163
|
-
|
|
164
|
-
export { type BaseSchema, ContentType, type Fetch, type FetchHeaders, type FetchRequestInit, type FetchResponse, _Headers as Headers, type HttpMethod, type InferOutputUnion, InvalidFetchResponseError, JsonParseError, type Oid4vcTsConfig, type Optional, type OrPromise, type Simplify, type StringWithAutoCompletion, _URL as URL, _URLSearchParams as URLSearchParams, ValidationError, type WwwAuthenticateHeaderChallenge, type ZodFetcher, addSecondsToDate, arrayEqualsIgnoreOrder, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, defaultFetcher, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isContentType, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs };
|
|
168
|
+
export { type BaseSchema, ContentType, type Fetch, type FetchHeaders, type FetchRequestInit, type FetchResponse, _Headers as Headers, type HttpMethod, type InferOutputUnion, InvalidFetchResponseError, JsonParseError, type Oid4vcTsConfig, type Optional, type OrPromise, type Simplify, type StringWithAutoCompletion, _URL as URL, _URLSearchParams as URLSearchParams, ValidationError, type WwwAuthenticateHeaderChallenge, type ZodFetcher, addSecondsToDate, arrayEqualsIgnoreOrder, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, defaultFetcher, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isContentType, isObject, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ declare const _Headers: typeof globalThis.Headers;
|
|
|
18
18
|
type FetchHeaders = globalThis.Headers;
|
|
19
19
|
type FetchRequestInit = RequestInit;
|
|
20
20
|
|
|
21
|
+
declare class InvalidFetchResponseError extends Error {
|
|
22
|
+
readonly textResponse: string;
|
|
23
|
+
readonly response: FetchResponse;
|
|
24
|
+
constructor(message: string, textResponse: string, response: FetchResponse);
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
declare class JsonParseError extends Error {
|
|
22
28
|
constructor(message: string, jsonString: string);
|
|
23
29
|
}
|
|
@@ -32,11 +38,32 @@ declare class ValidationError extends Error {
|
|
|
32
38
|
constructor(message: string, zodError?: z.ZodError);
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Only primitive types allowed
|
|
43
|
+
* Must have not duplicate entries (will always return false in this case)
|
|
44
|
+
*/
|
|
45
|
+
declare function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(a: Array<Item>, b: Array<Item>): boolean;
|
|
46
|
+
|
|
47
|
+
interface Oid4vcTsConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Whether to allow insecure http urls.
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
allowInsecureUrls: boolean;
|
|
39
54
|
}
|
|
55
|
+
declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
56
|
+
declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
57
|
+
|
|
58
|
+
declare enum ContentType {
|
|
59
|
+
XWwwFormUrlencoded = "application/x-www-form-urlencoded",
|
|
60
|
+
Json = "application/json",
|
|
61
|
+
JwkSet = "application/jwk-set+json",
|
|
62
|
+
OAuthRequestObjectJwt = "application/oauth-authz-req+jwt",
|
|
63
|
+
Jwt = "application/jwt"
|
|
64
|
+
}
|
|
65
|
+
declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
66
|
+
declare function isResponseContentType(contentType: ContentType, response: FetchResponse): boolean;
|
|
40
67
|
|
|
41
68
|
/**
|
|
42
69
|
* Get the time in seconds since epoch for a date.
|
|
@@ -54,11 +81,20 @@ declare function decodeBase64(base64: string): Uint8Array;
|
|
|
54
81
|
declare function encodeToBase64(data: Uint8Array | string): string;
|
|
55
82
|
declare function encodeToBase64Url(data: Uint8Array | string): string;
|
|
56
83
|
|
|
84
|
+
declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Deep merge two objects.
|
|
87
|
+
* @param target
|
|
88
|
+
* @param ...sources
|
|
89
|
+
*/
|
|
90
|
+
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
91
|
+
|
|
57
92
|
type BaseSchema = z.ZodTypeAny;
|
|
58
93
|
type InferOutputUnion<T extends readonly any[]> = {
|
|
59
94
|
[K in keyof T]: z.infer<T[K]>;
|
|
60
95
|
}[number];
|
|
61
96
|
declare function stringToJsonWithErrorHandling(string: string, errorMessage?: string): any;
|
|
97
|
+
declare function parseIfJson<T>(data: T): T | Record<string, unknown>;
|
|
62
98
|
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z.infer<Schema>;
|
|
63
99
|
|
|
64
100
|
/**
|
|
@@ -79,14 +115,6 @@ type OrPromise<T> = T | Promise<T>;
|
|
|
79
115
|
declare function getQueryParams(url: string): Record<string, string>;
|
|
80
116
|
declare function objectToQueryParams(object: Record<string, unknown>): InstanceType<typeof _URLSearchParams>;
|
|
81
117
|
|
|
82
|
-
declare enum ContentType {
|
|
83
|
-
XWwwFormUrlencoded = "application/x-www-form-urlencoded",
|
|
84
|
-
Json = "application/json",
|
|
85
|
-
JwkSet = "application/jwk-set+json"
|
|
86
|
-
}
|
|
87
|
-
declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
88
|
-
declare function isResponseContentType(contentType: ContentType, response: FetchResponse): boolean;
|
|
89
|
-
|
|
90
118
|
/**
|
|
91
119
|
* A type utility which represents the function returned
|
|
92
120
|
* from createZodFetcher
|
|
@@ -126,19 +154,6 @@ declare const zHttpMethod: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "HEAD", "O
|
|
|
126
154
|
type HttpMethod = z.infer<typeof zHttpMethod>;
|
|
127
155
|
declare const zIs: <Schema extends z.ZodSchema>(schema: Schema, data: unknown) => data is z.infer<typeof schema>;
|
|
128
156
|
|
|
129
|
-
/**
|
|
130
|
-
* Deep merge two objects.
|
|
131
|
-
* @param target
|
|
132
|
-
* @param ...sources
|
|
133
|
-
*/
|
|
134
|
-
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Only primitive types allowed
|
|
138
|
-
* Must have not duplicate entries (will always return false in this case)
|
|
139
|
-
*/
|
|
140
|
-
declare function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(a: Array<Item>, b: Array<Item>): boolean;
|
|
141
|
-
|
|
142
157
|
interface WwwAuthenticateHeaderChallenge {
|
|
143
158
|
scheme: string;
|
|
144
159
|
/**
|
|
@@ -150,15 +165,4 @@ interface WwwAuthenticateHeaderChallenge {
|
|
|
150
165
|
declare function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[];
|
|
151
166
|
declare function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]): string;
|
|
152
167
|
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Whether to allow insecure http urls.
|
|
156
|
-
*
|
|
157
|
-
* @default false
|
|
158
|
-
*/
|
|
159
|
-
allowInsecureUrls: boolean;
|
|
160
|
-
}
|
|
161
|
-
declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
162
|
-
declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
163
|
-
|
|
164
|
-
export { type BaseSchema, ContentType, type Fetch, type FetchHeaders, type FetchRequestInit, type FetchResponse, _Headers as Headers, type HttpMethod, type InferOutputUnion, InvalidFetchResponseError, JsonParseError, type Oid4vcTsConfig, type Optional, type OrPromise, type Simplify, type StringWithAutoCompletion, _URL as URL, _URLSearchParams as URLSearchParams, ValidationError, type WwwAuthenticateHeaderChallenge, type ZodFetcher, addSecondsToDate, arrayEqualsIgnoreOrder, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, defaultFetcher, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isContentType, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs };
|
|
168
|
+
export { type BaseSchema, ContentType, type Fetch, type FetchHeaders, type FetchRequestInit, type FetchResponse, _Headers as Headers, type HttpMethod, type InferOutputUnion, InvalidFetchResponseError, JsonParseError, type Oid4vcTsConfig, type Optional, type OrPromise, type Simplify, type StringWithAutoCompletion, _URL as URL, _URLSearchParams as URLSearchParams, ValidationError, type WwwAuthenticateHeaderChallenge, type ZodFetcher, addSecondsToDate, arrayEqualsIgnoreOrder, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, defaultFetcher, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isContentType, isObject, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs };
|
package/dist/index.js
CHANGED
|
@@ -51,10 +51,12 @@ __export(src_exports, {
|
|
|
51
51
|
getGlobalConfig: () => getGlobalConfig,
|
|
52
52
|
getQueryParams: () => getQueryParams,
|
|
53
53
|
isContentType: () => isContentType,
|
|
54
|
+
isObject: () => isObject,
|
|
54
55
|
isResponseContentType: () => isResponseContentType,
|
|
55
56
|
joinUriParts: () => joinUriParts,
|
|
56
57
|
mergeDeep: () => mergeDeep,
|
|
57
58
|
objectToQueryParams: () => objectToQueryParams,
|
|
59
|
+
parseIfJson: () => parseIfJson,
|
|
58
60
|
parseWithErrorHandling: () => parseWithErrorHandling,
|
|
59
61
|
parseWwwAuthenticateHeader: () => parseWwwAuthenticateHeader,
|
|
60
62
|
setGlobalConfig: () => setGlobalConfig,
|
|
@@ -71,6 +73,16 @@ var _URL = URL;
|
|
|
71
73
|
var _URLSearchParams = URLSearchParams;
|
|
72
74
|
var _Headers = Headers;
|
|
73
75
|
|
|
76
|
+
// src/error/InvalidFetchResponseError.ts
|
|
77
|
+
var InvalidFetchResponseError = class extends Error {
|
|
78
|
+
constructor(message, textResponse, response) {
|
|
79
|
+
super(`${message}
|
|
80
|
+
${textResponse}`);
|
|
81
|
+
this.textResponse = textResponse;
|
|
82
|
+
this.response = response.clone();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
74
86
|
// src/error/JsonParseError.ts
|
|
75
87
|
var JsonParseError = class extends Error {
|
|
76
88
|
constructor(message, jsonString) {
|
|
@@ -158,15 +170,41 @@ var ValidationError = class extends Error {
|
|
|
158
170
|
}
|
|
159
171
|
};
|
|
160
172
|
|
|
161
|
-
// src/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
// src/array.ts
|
|
174
|
+
function arrayEqualsIgnoreOrder(a, b) {
|
|
175
|
+
if (new Set(a).size !== new Set(b).size) return false;
|
|
176
|
+
if (a.length !== b.length) return false;
|
|
177
|
+
return a.every((k) => b.includes(k));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/config.ts
|
|
181
|
+
var GLOBAL_CONFIG = {
|
|
182
|
+
allowInsecureUrls: false
|
|
169
183
|
};
|
|
184
|
+
function setGlobalConfig(config) {
|
|
185
|
+
GLOBAL_CONFIG = config;
|
|
186
|
+
}
|
|
187
|
+
function getGlobalConfig() {
|
|
188
|
+
return GLOBAL_CONFIG;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/content-type.ts
|
|
192
|
+
var ContentType = /* @__PURE__ */ ((ContentType2) => {
|
|
193
|
+
ContentType2["XWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
|
|
194
|
+
ContentType2["Json"] = "application/json";
|
|
195
|
+
ContentType2["JwkSet"] = "application/jwk-set+json";
|
|
196
|
+
ContentType2["OAuthRequestObjectJwt"] = "application/oauth-authz-req+jwt";
|
|
197
|
+
ContentType2["Jwt"] = "application/jwt";
|
|
198
|
+
return ContentType2;
|
|
199
|
+
})(ContentType || {});
|
|
200
|
+
function isContentType(contentType, value) {
|
|
201
|
+
return value.toLowerCase().trim().split(";")[0] === contentType;
|
|
202
|
+
}
|
|
203
|
+
function isResponseContentType(contentType, response) {
|
|
204
|
+
const header = response.headers.get("Content-Type");
|
|
205
|
+
if (!header) return false;
|
|
206
|
+
return isContentType(contentType, header);
|
|
207
|
+
}
|
|
170
208
|
|
|
171
209
|
// src/date.ts
|
|
172
210
|
function dateToSeconds(date) {
|
|
@@ -201,6 +239,26 @@ function base64ToBase64Url(base64) {
|
|
|
201
239
|
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
202
240
|
}
|
|
203
241
|
|
|
242
|
+
// src/object.ts
|
|
243
|
+
function isObject(item) {
|
|
244
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
245
|
+
}
|
|
246
|
+
function mergeDeep(target, ...sources) {
|
|
247
|
+
if (!sources.length) return target;
|
|
248
|
+
const source = sources.shift();
|
|
249
|
+
if (isObject(target) && isObject(source)) {
|
|
250
|
+
for (const key in source) {
|
|
251
|
+
if (isObject(source[key])) {
|
|
252
|
+
if (!target[key]) Object.assign(target, { [key]: {} });
|
|
253
|
+
mergeDeep(target[key], source[key]);
|
|
254
|
+
} else {
|
|
255
|
+
Object.assign(target, { [key]: source[key] });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return mergeDeep(target, ...sources);
|
|
260
|
+
}
|
|
261
|
+
|
|
204
262
|
// src/parse.ts
|
|
205
263
|
function stringToJsonWithErrorHandling(string, errorMessage) {
|
|
206
264
|
try {
|
|
@@ -209,6 +267,16 @@ function stringToJsonWithErrorHandling(string, errorMessage) {
|
|
|
209
267
|
throw new JsonParseError(errorMessage ?? "Unable to parse string to JSON.", string);
|
|
210
268
|
}
|
|
211
269
|
}
|
|
270
|
+
function parseIfJson(data) {
|
|
271
|
+
if (typeof data !== "string") {
|
|
272
|
+
return data;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
return JSON.parse(data);
|
|
276
|
+
} catch (error) {
|
|
277
|
+
}
|
|
278
|
+
return data;
|
|
279
|
+
}
|
|
212
280
|
function parseWithErrorHandling(schema, data, customErrorMessage) {
|
|
213
281
|
const parseResult = schema.safeParse(data);
|
|
214
282
|
if (!parseResult.success) {
|
|
@@ -255,22 +323,6 @@ function objectToQueryParams(object) {
|
|
|
255
323
|
return params;
|
|
256
324
|
}
|
|
257
325
|
|
|
258
|
-
// src/content-type.ts
|
|
259
|
-
var ContentType = /* @__PURE__ */ ((ContentType2) => {
|
|
260
|
-
ContentType2["XWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
|
|
261
|
-
ContentType2["Json"] = "application/json";
|
|
262
|
-
ContentType2["JwkSet"] = "application/jwk-set+json";
|
|
263
|
-
return ContentType2;
|
|
264
|
-
})(ContentType || {});
|
|
265
|
-
function isContentType(contentType, value) {
|
|
266
|
-
return value.toLowerCase().trim().split(";")[0] === contentType;
|
|
267
|
-
}
|
|
268
|
-
function isResponseContentType(contentType, response) {
|
|
269
|
-
const header = response.headers.get("Content-Type");
|
|
270
|
-
if (!header) return false;
|
|
271
|
-
return isContentType(contentType, header);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
326
|
// src/zod-fetcher.ts
|
|
275
327
|
var defaultFetcher = fetch;
|
|
276
328
|
function createZodFetcher(fetcher = defaultFetcher) {
|
|
@@ -283,6 +335,12 @@ function createZodFetcher(fetcher = defaultFetcher) {
|
|
|
283
335
|
response
|
|
284
336
|
);
|
|
285
337
|
}
|
|
338
|
+
if (expectedContentType === "application/oauth-authz-req+jwt" /* OAuthRequestObjectJwt */) {
|
|
339
|
+
return {
|
|
340
|
+
response,
|
|
341
|
+
result: response.ok ? schema.safeParse(await response.text()) : void 0
|
|
342
|
+
};
|
|
343
|
+
}
|
|
286
344
|
return {
|
|
287
345
|
response,
|
|
288
346
|
result: response.ok ? schema.safeParse(await response.json()) : void 0
|
|
@@ -292,19 +350,6 @@ function createZodFetcher(fetcher = defaultFetcher) {
|
|
|
292
350
|
|
|
293
351
|
// src/validation.ts
|
|
294
352
|
var import_zod2 = __toESM(require("zod"));
|
|
295
|
-
|
|
296
|
-
// src/config.ts
|
|
297
|
-
var GLOBAL_CONFIG = {
|
|
298
|
-
allowInsecureUrls: false
|
|
299
|
-
};
|
|
300
|
-
function setGlobalConfig(config) {
|
|
301
|
-
GLOBAL_CONFIG = config;
|
|
302
|
-
}
|
|
303
|
-
function getGlobalConfig() {
|
|
304
|
-
return GLOBAL_CONFIG;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// src/validation.ts
|
|
308
353
|
var zHttpsUrl = import_zod2.default.string().url().refine(
|
|
309
354
|
(url) => {
|
|
310
355
|
const { allowInsecureUrls } = getGlobalConfig();
|
|
@@ -316,33 +361,6 @@ var zInteger = import_zod2.default.number().int();
|
|
|
316
361
|
var zHttpMethod = import_zod2.default.enum(["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]);
|
|
317
362
|
var zIs = (schema, data) => schema.safeParse(data).success;
|
|
318
363
|
|
|
319
|
-
// src/object.ts
|
|
320
|
-
function isObject(item) {
|
|
321
|
-
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
322
|
-
}
|
|
323
|
-
function mergeDeep(target, ...sources) {
|
|
324
|
-
if (!sources.length) return target;
|
|
325
|
-
const source = sources.shift();
|
|
326
|
-
if (isObject(target) && isObject(source)) {
|
|
327
|
-
for (const key in source) {
|
|
328
|
-
if (isObject(source[key])) {
|
|
329
|
-
if (!target[key]) Object.assign(target, { [key]: {} });
|
|
330
|
-
mergeDeep(target[key], source[key]);
|
|
331
|
-
} else {
|
|
332
|
-
Object.assign(target, { [key]: source[key] });
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return mergeDeep(target, ...sources);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// src/array.ts
|
|
340
|
-
function arrayEqualsIgnoreOrder(a, b) {
|
|
341
|
-
if (new Set(a).size !== new Set(b).size) return false;
|
|
342
|
-
if (a.length !== b.length) return false;
|
|
343
|
-
return a.every((k) => b.includes(k));
|
|
344
|
-
}
|
|
345
|
-
|
|
346
364
|
// src/www-authenticate.ts
|
|
347
365
|
var unquote = (value) => value.substring(1, value.length - 1).replace(/\\"/g, '"');
|
|
348
366
|
var sanitize = (value) => value.charAt(0) === '"' ? unquote(value) : value.trim();
|
|
@@ -429,10 +447,12 @@ function encodeWwwAuthenticateHeader(challenges) {
|
|
|
429
447
|
getGlobalConfig,
|
|
430
448
|
getQueryParams,
|
|
431
449
|
isContentType,
|
|
450
|
+
isObject,
|
|
432
451
|
isResponseContentType,
|
|
433
452
|
joinUriParts,
|
|
434
453
|
mergeDeep,
|
|
435
454
|
objectToQueryParams,
|
|
455
|
+
parseIfJson,
|
|
436
456
|
parseWithErrorHandling,
|
|
437
457
|
parseWwwAuthenticateHeader,
|
|
438
458
|
setGlobalConfig,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/globals.ts","../src/error/JsonParseError.ts","../src/error/ValidationError.ts","../src/error/InvalidFetchResponseError.ts","../src/date.ts","../src/encoding.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/content-type.ts","../src/zod-fetcher.ts","../src/validation.ts","../src/config.ts","../src/object.ts","../src/array.ts","../src/www-authenticate.ts"],"sourcesContent":["export {\n type Fetch,\n Headers,\n type FetchRequestInit,\n type FetchHeaders,\n type FetchResponse,\n URL,\n URLSearchParams,\n} from './globals'\n\nexport { JsonParseError } from './error/JsonParseError'\nexport { ValidationError } from './error/ValidationError'\nexport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\n\nexport { addSecondsToDate, dateToSeconds } from './date'\nexport { decodeBase64, decodeUtf8String, encodeToBase64, encodeToBase64Url, encodeToUtf8String } from './encoding'\nexport {\n parseWithErrorHandling,\n stringToJsonWithErrorHandling,\n type BaseSchema,\n type InferOutputUnion,\n} from './parse'\nexport { joinUriParts } from './path'\nexport type { Optional, Simplify, StringWithAutoCompletion, OrPromise } from './type'\nexport { getQueryParams, objectToQueryParams } from './url'\nexport { type ZodFetcher, createZodFetcher, defaultFetcher } from './zod-fetcher'\nexport {\n type HttpMethod,\n zHttpMethod,\n zHttpsUrl,\n zInteger,\n zIs,\n} from './validation'\nexport { mergeDeep } from './object'\nexport { arrayEqualsIgnoreOrder } from './array'\nexport {\n parseWwwAuthenticateHeader,\n type WwwAuthenticateHeaderChallenge,\n encodeWwwAuthenticateHeader,\n} from './www-authenticate'\nexport { ContentType, isContentType, isResponseContentType } from './content-type'\nexport { setGlobalConfig, type Oid4vcTsConfig, getGlobalConfig } from './config'\n","// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URL = URL\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _URLSearchParams as URLSearchParams, _URL as URL, _Headers as Headers }\n","export class JsonParseError extends Error {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import type z from 'zod'\nimport { type ZodError, type ZodIssue, ZodIssueCode } from 'zod'\n\n/**\n * Some code comes from `zod-validation-error` package (MIT License) and\n * was slightly simplified to fit our needs.\n */\nconst constants = {\n // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected\n identifierRegex: /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u,\n unionSeparator: ', or ',\n issueSeparator: '\\n\\t- ',\n}\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n private escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n }\n\n private joinPath(path: Array<string | number>): string {\n if (path.length === 1) {\n return path[0].toString()\n }\n\n return path.reduce<string>((acc, item) => {\n // handle numeric indices\n if (typeof item === 'number') {\n return `${acc}[${item.toString()}]`\n }\n\n // handle quoted values\n if (item.includes('\"')) {\n return `${acc}[\"${this.escapeQuotes(item)}\"]`\n }\n\n // handle special characters\n if (!constants.identifierRegex.test(item)) {\n return `${acc}[\"${item}\"]`\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.'\n return acc + separator + item\n }, '')\n }\n\n private getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) => this.getMessageFromZodIssue(issue))\n .join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n }\n\n private getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return this.getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.code === ZodIssueCode.invalid_return_type) {\n return [issue.message, ...issue.returnTypeError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.path.length !== 0) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0]\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`\n }\n }\n\n return `${issue.message} at \"${this.joinPath(issue.path)}\"`\n }\n\n return issue.message\n }\n\n private formatError(error?: z.ZodError): string {\n if (!error) return ''\n\n return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n }\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = this.formatError(zodError)\n this.message = `${message}\\n\\t- ${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","import type { FetchResponse } from '../globals'\n\nexport class InvalidFetchResponseError extends Error {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n super(`${message}\\n${textResponse}`)\n this.response = response.clone()\n }\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","// biome-ignore lint/style/useNodejsImportProtocol: also imported in other environments\nimport { 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","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: <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 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 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}\n\nexport function isContentType(contentType: ContentType, value: string) {\n return value.toLowerCase().trim().split(';')[0] === contentType\n}\n\nexport function isResponseContentType(contentType: ContentType, response: FetchResponse) {\n const header = response.headers.get('Content-Type')\n if (!header) return false\n return isContentType(contentType, header)\n}\n","import type z from 'zod'\nimport { type ContentType, isResponseContentType } from './content-type'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport type { Fetch } 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,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\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 = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args)\n\n if (response.ok && !isResponseContentType(expectedContentType, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type '${expectedContentType}', but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n return {\n response,\n result: response.ok ? schema.safeParse(await response.json()) : undefined,\n }\n }\n}\n","import z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z\n .string()\n .url()\n .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 zInteger = z.number().int()\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 zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\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","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","/**\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","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: <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 = 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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C,YAAQ,MAAM,UAAU,MAAM,CAAC,EAAE,SAAS,CAAC;AAC3C,aAAS,MAAM,CAAC;AAEhB,YAAQ,uBAAuB,KAAK,KAAK;AAAA,EAC3C;AACA,aAAW,KAAK,aAAa,QAAQ,KAAK,CAAC;AAC3C,MAAI,gBAAgB;AAClB,eAAW,KAAK,EAAE,QAAQ,gBAAgB,SAAS,CAAC,EAAE,CAAC;AAAA,EACzD;AACA,SAAO;AACT;AAEO,SAAS,4BAA4B,YAA8C;AACxF,QAAM,UAAoB,CAAC;AAE3B,aAAW,aAAa,YAAY;AAElC,UAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChF,YAAM,SAAS,CAAC,MAAc,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK;AAE1E,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM,IAAI,CAAC,MAAM,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,GAAG;AAAA,MACjD;AAEA,aAAO,QAAQ,GAAG,GAAG,KAAK,OAAO,KAAK,CAAC,MAAM;AAAA,IAC/C,CAAC;AAED,YAAQ,KAAK,cAAc,WAAW,IAAI,UAAU,SAAS,GAAG,UAAU,MAAM,IAAI,cAAc,KAAK,IAAI,CAAC,EAAE;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType","import_zod","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/globals.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/error/ValidationError.ts","../src/array.ts","../src/config.ts","../src/content-type.ts","../src/date.ts","../src/encoding.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/zod-fetcher.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["export {\n Headers,\n URL,\n URLSearchParams,\n type Fetch,\n type FetchHeaders,\n type FetchRequestInit,\n type FetchResponse,\n} from './globals'\n\nexport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nexport { JsonParseError } from './error/JsonParseError'\nexport { ValidationError } from './error/ValidationError'\n\nexport { arrayEqualsIgnoreOrder } from './array'\nexport { getGlobalConfig, setGlobalConfig, type Oid4vcTsConfig } from './config'\nexport { ContentType, isContentType, isResponseContentType } from './content-type'\nexport { addSecondsToDate, dateToSeconds } from './date'\nexport {\n decodeBase64,\n decodeUtf8String,\n encodeToBase64,\n encodeToBase64Url,\n encodeToUtf8String,\n} from './encoding'\nexport { mergeDeep } from './object'\nexport {\n parseWithErrorHandling,\n stringToJsonWithErrorHandling,\n parseIfJson,\n type BaseSchema,\n type InferOutputUnion,\n} from './parse'\nexport { joinUriParts } from './path'\nexport type { Optional, OrPromise, Simplify, StringWithAutoCompletion } from './type'\nexport { getQueryParams, objectToQueryParams } from './url'\nexport { type ZodFetcher, createZodFetcher, defaultFetcher } from './zod-fetcher'\nexport {\n type HttpMethod,\n zHttpMethod,\n zHttpsUrl,\n zInteger,\n zIs,\n} from './validation'\nexport {\n encodeWwwAuthenticateHeader,\n parseWwwAuthenticateHeader,\n type WwwAuthenticateHeaderChallenge,\n} from './www-authenticate'\n\nexport { isObject } from './object'\n","// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _URLSearchParams as URLSearchParams, _URL as URL, _Headers as Headers }\n","import type { FetchResponse } from '../globals'\n\nexport class InvalidFetchResponseError extends Error {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n super(`${message}\\n${textResponse}`)\n this.response = response.clone()\n }\n}\n","export class JsonParseError extends Error {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import type z from 'zod'\nimport { type ZodError, type ZodIssue, ZodIssueCode } from 'zod'\n\n/**\n * Some code comes from `zod-validation-error` package (MIT License) and\n * was slightly simplified to fit our needs.\n */\nconst constants = {\n // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected\n identifierRegex: /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u,\n unionSeparator: ', or ',\n issueSeparator: '\\n\\t- ',\n}\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n private escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n }\n\n private joinPath(path: Array<string | number>): string {\n if (path.length === 1) {\n return path[0].toString()\n }\n\n return path.reduce<string>((acc, item) => {\n // handle numeric indices\n if (typeof item === 'number') {\n return `${acc}[${item.toString()}]`\n }\n\n // handle quoted values\n if (item.includes('\"')) {\n return `${acc}[\"${this.escapeQuotes(item)}\"]`\n }\n\n // handle special characters\n if (!constants.identifierRegex.test(item)) {\n return `${acc}[\"${item}\"]`\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.'\n return acc + separator + item\n }, '')\n }\n\n private getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) => this.getMessageFromZodIssue(issue))\n .join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n }\n\n private getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return this.getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.code === ZodIssueCode.invalid_return_type) {\n return [issue.message, ...issue.returnTypeError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.path.length !== 0) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0]\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`\n }\n }\n\n return `${issue.message} at \"${this.joinPath(issue.path)}\"`\n }\n\n return issue.message\n }\n\n private formatError(error?: z.ZodError): string {\n if (!error) return ''\n\n return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n }\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = this.formatError(zodError)\n this.message = `${message}\\n\\t- ${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","/**\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 OAuthRequestObjectJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n}\n\nexport function isContentType(contentType: ContentType, value: string) {\n return value.toLowerCase().trim().split(';')[0] === contentType\n}\n\nexport function isResponseContentType(contentType: ContentType, response: FetchResponse) {\n const header = response.headers.get('Content-Type')\n if (!header) return false\n return isContentType(contentType, 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","// biome-ignore lint/style/useNodejsImportProtocol: also imported in other environments\nimport { 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 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: <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 type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport type { Fetch } 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,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\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 = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args)\n\n if (response.ok && !isResponseContentType(expectedContentType, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type '${expectedContentType}', but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (expectedContentType === ContentType.OAuthRequestObjectJwt) {\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","import z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z\n .string()\n .url()\n .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 zInteger = z.number().int()\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 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: <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 = 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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GAAG,UAAU,MAAM,IAAI,cAAc,KAAK,IAAI,CAAC,EAAE;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType","import_zod","z"]}
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,16 @@ var _URL = URL;
|
|
|
3
3
|
var _URLSearchParams = URLSearchParams;
|
|
4
4
|
var _Headers = Headers;
|
|
5
5
|
|
|
6
|
+
// src/error/InvalidFetchResponseError.ts
|
|
7
|
+
var InvalidFetchResponseError = class extends Error {
|
|
8
|
+
constructor(message, textResponse, response) {
|
|
9
|
+
super(`${message}
|
|
10
|
+
${textResponse}`);
|
|
11
|
+
this.textResponse = textResponse;
|
|
12
|
+
this.response = response.clone();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
6
16
|
// src/error/JsonParseError.ts
|
|
7
17
|
var JsonParseError = class extends Error {
|
|
8
18
|
constructor(message, jsonString) {
|
|
@@ -90,15 +100,41 @@ var ValidationError = class extends Error {
|
|
|
90
100
|
}
|
|
91
101
|
};
|
|
92
102
|
|
|
93
|
-
// src/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
// src/array.ts
|
|
104
|
+
function arrayEqualsIgnoreOrder(a, b) {
|
|
105
|
+
if (new Set(a).size !== new Set(b).size) return false;
|
|
106
|
+
if (a.length !== b.length) return false;
|
|
107
|
+
return a.every((k) => b.includes(k));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/config.ts
|
|
111
|
+
var GLOBAL_CONFIG = {
|
|
112
|
+
allowInsecureUrls: false
|
|
101
113
|
};
|
|
114
|
+
function setGlobalConfig(config) {
|
|
115
|
+
GLOBAL_CONFIG = config;
|
|
116
|
+
}
|
|
117
|
+
function getGlobalConfig() {
|
|
118
|
+
return GLOBAL_CONFIG;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/content-type.ts
|
|
122
|
+
var ContentType = /* @__PURE__ */ ((ContentType2) => {
|
|
123
|
+
ContentType2["XWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
|
|
124
|
+
ContentType2["Json"] = "application/json";
|
|
125
|
+
ContentType2["JwkSet"] = "application/jwk-set+json";
|
|
126
|
+
ContentType2["OAuthRequestObjectJwt"] = "application/oauth-authz-req+jwt";
|
|
127
|
+
ContentType2["Jwt"] = "application/jwt";
|
|
128
|
+
return ContentType2;
|
|
129
|
+
})(ContentType || {});
|
|
130
|
+
function isContentType(contentType, value) {
|
|
131
|
+
return value.toLowerCase().trim().split(";")[0] === contentType;
|
|
132
|
+
}
|
|
133
|
+
function isResponseContentType(contentType, response) {
|
|
134
|
+
const header = response.headers.get("Content-Type");
|
|
135
|
+
if (!header) return false;
|
|
136
|
+
return isContentType(contentType, header);
|
|
137
|
+
}
|
|
102
138
|
|
|
103
139
|
// src/date.ts
|
|
104
140
|
function dateToSeconds(date) {
|
|
@@ -133,6 +169,26 @@ function base64ToBase64Url(base64) {
|
|
|
133
169
|
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
134
170
|
}
|
|
135
171
|
|
|
172
|
+
// src/object.ts
|
|
173
|
+
function isObject(item) {
|
|
174
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
175
|
+
}
|
|
176
|
+
function mergeDeep(target, ...sources) {
|
|
177
|
+
if (!sources.length) return target;
|
|
178
|
+
const source = sources.shift();
|
|
179
|
+
if (isObject(target) && isObject(source)) {
|
|
180
|
+
for (const key in source) {
|
|
181
|
+
if (isObject(source[key])) {
|
|
182
|
+
if (!target[key]) Object.assign(target, { [key]: {} });
|
|
183
|
+
mergeDeep(target[key], source[key]);
|
|
184
|
+
} else {
|
|
185
|
+
Object.assign(target, { [key]: source[key] });
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return mergeDeep(target, ...sources);
|
|
190
|
+
}
|
|
191
|
+
|
|
136
192
|
// src/parse.ts
|
|
137
193
|
function stringToJsonWithErrorHandling(string, errorMessage) {
|
|
138
194
|
try {
|
|
@@ -141,6 +197,16 @@ function stringToJsonWithErrorHandling(string, errorMessage) {
|
|
|
141
197
|
throw new JsonParseError(errorMessage ?? "Unable to parse string to JSON.", string);
|
|
142
198
|
}
|
|
143
199
|
}
|
|
200
|
+
function parseIfJson(data) {
|
|
201
|
+
if (typeof data !== "string") {
|
|
202
|
+
return data;
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
return JSON.parse(data);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
}
|
|
208
|
+
return data;
|
|
209
|
+
}
|
|
144
210
|
function parseWithErrorHandling(schema, data, customErrorMessage) {
|
|
145
211
|
const parseResult = schema.safeParse(data);
|
|
146
212
|
if (!parseResult.success) {
|
|
@@ -187,22 +253,6 @@ function objectToQueryParams(object) {
|
|
|
187
253
|
return params;
|
|
188
254
|
}
|
|
189
255
|
|
|
190
|
-
// src/content-type.ts
|
|
191
|
-
var ContentType = /* @__PURE__ */ ((ContentType2) => {
|
|
192
|
-
ContentType2["XWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
|
|
193
|
-
ContentType2["Json"] = "application/json";
|
|
194
|
-
ContentType2["JwkSet"] = "application/jwk-set+json";
|
|
195
|
-
return ContentType2;
|
|
196
|
-
})(ContentType || {});
|
|
197
|
-
function isContentType(contentType, value) {
|
|
198
|
-
return value.toLowerCase().trim().split(";")[0] === contentType;
|
|
199
|
-
}
|
|
200
|
-
function isResponseContentType(contentType, response) {
|
|
201
|
-
const header = response.headers.get("Content-Type");
|
|
202
|
-
if (!header) return false;
|
|
203
|
-
return isContentType(contentType, header);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
256
|
// src/zod-fetcher.ts
|
|
207
257
|
var defaultFetcher = fetch;
|
|
208
258
|
function createZodFetcher(fetcher = defaultFetcher) {
|
|
@@ -215,6 +265,12 @@ function createZodFetcher(fetcher = defaultFetcher) {
|
|
|
215
265
|
response
|
|
216
266
|
);
|
|
217
267
|
}
|
|
268
|
+
if (expectedContentType === "application/oauth-authz-req+jwt" /* OAuthRequestObjectJwt */) {
|
|
269
|
+
return {
|
|
270
|
+
response,
|
|
271
|
+
result: response.ok ? schema.safeParse(await response.text()) : void 0
|
|
272
|
+
};
|
|
273
|
+
}
|
|
218
274
|
return {
|
|
219
275
|
response,
|
|
220
276
|
result: response.ok ? schema.safeParse(await response.json()) : void 0
|
|
@@ -224,19 +280,6 @@ function createZodFetcher(fetcher = defaultFetcher) {
|
|
|
224
280
|
|
|
225
281
|
// src/validation.ts
|
|
226
282
|
import z from "zod";
|
|
227
|
-
|
|
228
|
-
// src/config.ts
|
|
229
|
-
var GLOBAL_CONFIG = {
|
|
230
|
-
allowInsecureUrls: false
|
|
231
|
-
};
|
|
232
|
-
function setGlobalConfig(config) {
|
|
233
|
-
GLOBAL_CONFIG = config;
|
|
234
|
-
}
|
|
235
|
-
function getGlobalConfig() {
|
|
236
|
-
return GLOBAL_CONFIG;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/validation.ts
|
|
240
283
|
var zHttpsUrl = z.string().url().refine(
|
|
241
284
|
(url) => {
|
|
242
285
|
const { allowInsecureUrls } = getGlobalConfig();
|
|
@@ -248,33 +291,6 @@ var zInteger = z.number().int();
|
|
|
248
291
|
var zHttpMethod = z.enum(["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]);
|
|
249
292
|
var zIs = (schema, data) => schema.safeParse(data).success;
|
|
250
293
|
|
|
251
|
-
// src/object.ts
|
|
252
|
-
function isObject(item) {
|
|
253
|
-
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
254
|
-
}
|
|
255
|
-
function mergeDeep(target, ...sources) {
|
|
256
|
-
if (!sources.length) return target;
|
|
257
|
-
const source = sources.shift();
|
|
258
|
-
if (isObject(target) && isObject(source)) {
|
|
259
|
-
for (const key in source) {
|
|
260
|
-
if (isObject(source[key])) {
|
|
261
|
-
if (!target[key]) Object.assign(target, { [key]: {} });
|
|
262
|
-
mergeDeep(target[key], source[key]);
|
|
263
|
-
} else {
|
|
264
|
-
Object.assign(target, { [key]: source[key] });
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return mergeDeep(target, ...sources);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// src/array.ts
|
|
272
|
-
function arrayEqualsIgnoreOrder(a, b) {
|
|
273
|
-
if (new Set(a).size !== new Set(b).size) return false;
|
|
274
|
-
if (a.length !== b.length) return false;
|
|
275
|
-
return a.every((k) => b.includes(k));
|
|
276
|
-
}
|
|
277
|
-
|
|
278
294
|
// src/www-authenticate.ts
|
|
279
295
|
var unquote = (value) => value.substring(1, value.length - 1).replace(/\\"/g, '"');
|
|
280
296
|
var sanitize = (value) => value.charAt(0) === '"' ? unquote(value) : value.trim();
|
|
@@ -360,10 +376,12 @@ export {
|
|
|
360
376
|
getGlobalConfig,
|
|
361
377
|
getQueryParams,
|
|
362
378
|
isContentType,
|
|
379
|
+
isObject,
|
|
363
380
|
isResponseContentType,
|
|
364
381
|
joinUriParts,
|
|
365
382
|
mergeDeep,
|
|
366
383
|
objectToQueryParams,
|
|
384
|
+
parseIfJson,
|
|
367
385
|
parseWithErrorHandling,
|
|
368
386
|
parseWwwAuthenticateHeader,
|
|
369
387
|
setGlobalConfig,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/globals.ts","../src/error/JsonParseError.ts","../src/error/ValidationError.ts","../src/error/InvalidFetchResponseError.ts","../src/date.ts","../src/encoding.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/content-type.ts","../src/zod-fetcher.ts","../src/validation.ts","../src/config.ts","../src/object.ts","../src/array.ts","../src/www-authenticate.ts"],"sourcesContent":["// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URL = URL\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _URLSearchParams as URLSearchParams, _URL as URL, _Headers as Headers }\n","export class JsonParseError extends Error {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import type z from 'zod'\nimport { type ZodError, type ZodIssue, ZodIssueCode } from 'zod'\n\n/**\n * Some code comes from `zod-validation-error` package (MIT License) and\n * was slightly simplified to fit our needs.\n */\nconst constants = {\n // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected\n identifierRegex: /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u,\n unionSeparator: ', or ',\n issueSeparator: '\\n\\t- ',\n}\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n private escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n }\n\n private joinPath(path: Array<string | number>): string {\n if (path.length === 1) {\n return path[0].toString()\n }\n\n return path.reduce<string>((acc, item) => {\n // handle numeric indices\n if (typeof item === 'number') {\n return `${acc}[${item.toString()}]`\n }\n\n // handle quoted values\n if (item.includes('\"')) {\n return `${acc}[\"${this.escapeQuotes(item)}\"]`\n }\n\n // handle special characters\n if (!constants.identifierRegex.test(item)) {\n return `${acc}[\"${item}\"]`\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.'\n return acc + separator + item\n }, '')\n }\n\n private getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) => this.getMessageFromZodIssue(issue))\n .join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n }\n\n private getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return this.getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.code === ZodIssueCode.invalid_return_type) {\n return [issue.message, ...issue.returnTypeError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.path.length !== 0) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0]\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`\n }\n }\n\n return `${issue.message} at \"${this.joinPath(issue.path)}\"`\n }\n\n return issue.message\n }\n\n private formatError(error?: z.ZodError): string {\n if (!error) return ''\n\n return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n }\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = this.formatError(zodError)\n this.message = `${message}\\n\\t- ${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","import type { FetchResponse } from '../globals'\n\nexport class InvalidFetchResponseError extends Error {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n super(`${message}\\n${textResponse}`)\n this.response = response.clone()\n }\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","// biome-ignore lint/style/useNodejsImportProtocol: also imported in other environments\nimport { 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","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: <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 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 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}\n\nexport function isContentType(contentType: ContentType, value: string) {\n return value.toLowerCase().trim().split(';')[0] === contentType\n}\n\nexport function isResponseContentType(contentType: ContentType, response: FetchResponse) {\n const header = response.headers.get('Content-Type')\n if (!header) return false\n return isContentType(contentType, header)\n}\n","import type z from 'zod'\nimport { type ContentType, isResponseContentType } from './content-type'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport type { Fetch } 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,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\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 = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args)\n\n if (response.ok && !isResponseContentType(expectedContentType, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type '${expectedContentType}', but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n return {\n response,\n result: response.ok ? schema.safeParse(await response.json()) : undefined,\n }\n }\n}\n","import z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z\n .string()\n .url()\n .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 zInteger = z.number().int()\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 zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\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","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","/**\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","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: <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 = 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":";AAGA,IAAM,OAA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AAK,KAAK;AAAA,EAC3C;AACA,aAAW,KAAK,aAAa,QAAQ,KAAK,CAAC;AAC3C,MAAI,gBAAgB;AAClB,eAAW,KAAK,EAAE,QAAQ,gBAAgB,SAAS,CAAC,EAAE,CAAC;AAAA,EACzD;AACA,SAAO;AACT;AAEO,SAAS,4BAA4B,YAA8C;AACxF,QAAM,UAAoB,CAAC;AAE3B,aAAW,aAAa,YAAY;AAElC,UAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChF,YAAM,SAAS,CAAC,MAAc,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK;AAE1E,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM,IAAI,CAAC,MAAM,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,GAAG;AAAA,MACjD;AAEA,aAAO,QAAQ,GAAG,GAAG,KAAK,OAAO,KAAK,CAAC,MAAM;AAAA,IAC/C,CAAC;AAED,YAAQ,KAAK,cAAc,WAAW,IAAI,UAAU,SAAS,GAAG,UAAU,MAAM,IAAI,cAAc,KAAK,IAAI,CAAC,EAAE;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType"]}
|
|
1
|
+
{"version":3,"sources":["../src/globals.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/error/ValidationError.ts","../src/array.ts","../src/config.ts","../src/content-type.ts","../src/date.ts","../src/encoding.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/zod-fetcher.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _URLSearchParams as URLSearchParams, _URL as URL, _Headers as Headers }\n","import type { FetchResponse } from '../globals'\n\nexport class InvalidFetchResponseError extends Error {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n super(`${message}\\n${textResponse}`)\n this.response = response.clone()\n }\n}\n","export class JsonParseError extends Error {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import type z from 'zod'\nimport { type ZodError, type ZodIssue, ZodIssueCode } from 'zod'\n\n/**\n * Some code comes from `zod-validation-error` package (MIT License) and\n * was slightly simplified to fit our needs.\n */\nconst constants = {\n // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected\n identifierRegex: /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u,\n unionSeparator: ', or ',\n issueSeparator: '\\n\\t- ',\n}\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n private escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n }\n\n private joinPath(path: Array<string | number>): string {\n if (path.length === 1) {\n return path[0].toString()\n }\n\n return path.reduce<string>((acc, item) => {\n // handle numeric indices\n if (typeof item === 'number') {\n return `${acc}[${item.toString()}]`\n }\n\n // handle quoted values\n if (item.includes('\"')) {\n return `${acc}[\"${this.escapeQuotes(item)}\"]`\n }\n\n // handle special characters\n if (!constants.identifierRegex.test(item)) {\n return `${acc}[\"${item}\"]`\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.'\n return acc + separator + item\n }, '')\n }\n\n private getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) => this.getMessageFromZodIssue(issue))\n .join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n }\n\n private getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return this.getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.code === ZodIssueCode.invalid_return_type) {\n return [issue.message, ...issue.returnTypeError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.path.length !== 0) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0]\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`\n }\n }\n\n return `${issue.message} at \"${this.joinPath(issue.path)}\"`\n }\n\n return issue.message\n }\n\n private formatError(error?: z.ZodError): string {\n if (!error) return ''\n\n return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n }\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = this.formatError(zodError)\n this.message = `${message}\\n\\t- ${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","/**\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 OAuthRequestObjectJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n}\n\nexport function isContentType(contentType: ContentType, value: string) {\n return value.toLowerCase().trim().split(';')[0] === contentType\n}\n\nexport function isResponseContentType(contentType: ContentType, response: FetchResponse) {\n const header = response.headers.get('Content-Type')\n if (!header) return false\n return isContentType(contentType, 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","// biome-ignore lint/style/useNodejsImportProtocol: also imported in other environments\nimport { 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 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: <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 type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport type { Fetch } 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,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\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 = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args)\n\n if (response.ok && !isResponseContentType(expectedContentType, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type '${expectedContentType}', but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (expectedContentType === ContentType.OAuthRequestObjectJwt) {\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","import z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z\n .string()\n .url()\n .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 zInteger = z.number().int()\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 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: <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 = 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":";AAGA,IAAM,OAAO;AAGb,IAAM,mBAAmB;AAOzB,IAAM,WAAW;;;ACXV,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAG5C,YACL,SACgB,cAChB,UACA;AACA,UAAM,GAAG,OAAO;AAAA,EAAK,YAAY,EAAE;AAHnB;AAIhB,SAAK,WAAW,SAAS,MAAM;AAAA,EACjC;AACF;;;ACbO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACjC,YAAY,SAAiB,YAAoB;AACtD,UAAM,GAAG,OAAO;AAAA,EAAK,UAAU,EAAE;AAAA,EACnC;AACF;;;ACHA,SAAuC,oBAAoB;AAM3D,IAAM,YAAY;AAAA;AAAA,EAEhB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGjC,aAAa,KAAqB;AACxC,WAAO,IAAI,QAAQ,MAAM,KAAK;AAAA,EAChC;AAAA,EAEQ,SAAS,MAAsC;AACrD,QAAI,KAAK,WAAW,GAAG;AACrB,aAAO,KAAK,CAAC,EAAE,SAAS;AAAA,IAC1B;AAEA,WAAO,KAAK,OAAe,CAAC,KAAK,SAAS;AAExC,UAAI,OAAO,SAAS,UAAU;AAC5B,eAAO,GAAG,GAAG,IAAI,KAAK,SAAS,CAAC;AAAA,MAClC;AAGA,UAAI,KAAK,SAAS,GAAG,GAAG;AACtB,eAAO,GAAG,GAAG,KAAK,KAAK,aAAa,IAAI,CAAC;AAAA,MAC3C;AAGA,UAAI,CAAC,UAAU,gBAAgB,KAAK,IAAI,GAAG;AACzC,eAAO,GAAG,GAAG,KAAK,IAAI;AAAA,MACxB;AAGA,YAAM,YAAY,IAAI,WAAW,IAAI,KAAK;AAC1C,aA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AAI,cAAc,KAAK,IAAI,CAAC,EAAE;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openid4vc/utils",
|
|
3
|
-
"version": "0.3.0-alpha-
|
|
3
|
+
"version": "0.3.0-alpha-20250225095929",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
7
|
+
"license": "Apache-2.0",
|
|
4
8
|
"exports": {
|
|
5
9
|
".": {
|
|
6
10
|
"import": "./dist/index.mjs",
|
|
@@ -9,10 +13,6 @@
|
|
|
9
13
|
},
|
|
10
14
|
"./package.json": "./package.json"
|
|
11
15
|
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist"
|
|
14
|
-
],
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
16
|
"homepage": "https://github.com/openwallet-foundation-labs/oid4vc-ts/tree/main/packages/utils",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|