@openid4vc/utils 0.3.0-alpha-20250324175730 → 0.3.0-alpha-20250325212250
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 +15 -18
- package/dist/index.d.ts +15 -18
- package/dist/index.js +58 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import z, { ZodError } from 'zod';
|
|
1
|
+
import z$1, { ZodError, z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare const _URL: {
|
|
4
4
|
new (url: string | URL, base?: string | URL): URL;
|
|
@@ -30,11 +30,6 @@ declare class JsonParseError extends Error {
|
|
|
30
30
|
|
|
31
31
|
declare class ValidationError extends Error {
|
|
32
32
|
zodError: ZodError | undefined;
|
|
33
|
-
private escapeQuotes;
|
|
34
|
-
private joinPath;
|
|
35
|
-
private getMessageFromUnionErrors;
|
|
36
|
-
private getMessageFromZodIssue;
|
|
37
|
-
private formatError;
|
|
38
33
|
constructor(message: string, zodError?: z.ZodError);
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -89,13 +84,13 @@ declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
|
89
84
|
*/
|
|
90
85
|
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
91
86
|
|
|
92
|
-
type BaseSchema = z.ZodTypeAny;
|
|
87
|
+
type BaseSchema = z$1.ZodTypeAny;
|
|
93
88
|
type InferOutputUnion<T extends readonly any[]> = {
|
|
94
|
-
[K in keyof T]: z.infer<T[K]>;
|
|
89
|
+
[K in keyof T]: z$1.infer<T[K]>;
|
|
95
90
|
}[number];
|
|
96
91
|
declare function stringToJsonWithErrorHandling(string: string, errorMessage?: string): any;
|
|
97
92
|
declare function parseIfJson<T>(data: T): T | Record<string, unknown>;
|
|
98
|
-
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z.infer<Schema>;
|
|
93
|
+
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z$1.infer<Schema>;
|
|
99
94
|
|
|
100
95
|
/**
|
|
101
96
|
* Combine multiple uri parts into a single uri taking into account slashes.
|
|
@@ -119,9 +114,9 @@ declare function objectToQueryParams(object: Record<string, unknown>): InstanceT
|
|
|
119
114
|
* A type utility which represents the function returned
|
|
120
115
|
* from createZodFetcher
|
|
121
116
|
*/
|
|
122
|
-
type ZodFetcher = <Schema extends z.ZodTypeAny>(schema: Schema, expectedContentType: ContentType, ...args: Parameters<Fetch>) => Promise<{
|
|
117
|
+
type ZodFetcher = <Schema extends z$1.ZodTypeAny>(schema: Schema, expectedContentType: ContentType, ...args: Parameters<Fetch>) => Promise<{
|
|
123
118
|
response: Awaited<ReturnType<Fetch>>;
|
|
124
|
-
result?: z.SafeParseReturnType<Schema, z.infer<Schema>>;
|
|
119
|
+
result?: z$1.SafeParseReturnType<Schema, z$1.infer<Schema>>;
|
|
125
120
|
}>;
|
|
126
121
|
declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
127
122
|
/**
|
|
@@ -144,12 +139,14 @@ declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
|
144
139
|
*/
|
|
145
140
|
declare function createZodFetcher(fetcher?: Fetch): ZodFetcher;
|
|
146
141
|
|
|
147
|
-
declare const zHttpsUrl: z.ZodEffects<z.ZodString, string, string>;
|
|
148
|
-
declare const zInteger: z.ZodNumber;
|
|
149
|
-
declare const zHttpMethod: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]>;
|
|
150
|
-
type HttpMethod = z.infer<typeof zHttpMethod>;
|
|
151
|
-
declare const zStringToJson: z.ZodEffects<z.ZodString, any, string>;
|
|
152
|
-
declare const zIs: <Schema extends z.ZodSchema>(schema: Schema, data: unknown) => data is z.infer<typeof schema>;
|
|
142
|
+
declare const zHttpsUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
|
|
143
|
+
declare const zInteger: z$1.ZodNumber;
|
|
144
|
+
declare const zHttpMethod: z$1.ZodEnum<["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]>;
|
|
145
|
+
type HttpMethod = z$1.infer<typeof zHttpMethod>;
|
|
146
|
+
declare const zStringToJson: z$1.ZodEffects<z$1.ZodString, any, string>;
|
|
147
|
+
declare const zIs: <Schema extends z$1.ZodSchema>(schema: Schema, data: unknown) => data is z$1.infer<typeof schema>;
|
|
148
|
+
|
|
149
|
+
declare function formatZodError(error?: z$1.ZodError): string;
|
|
153
150
|
|
|
154
151
|
interface WwwAuthenticateHeaderChallenge {
|
|
155
152
|
scheme: string;
|
|
@@ -162,4 +159,4 @@ interface WwwAuthenticateHeaderChallenge {
|
|
|
162
159
|
declare function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[];
|
|
163
160
|
declare function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]): string;
|
|
164
161
|
|
|
165
|
-
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, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isContentType, isObject, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs, zStringToJson };
|
|
162
|
+
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, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, formatZodError, getGlobalConfig, getQueryParams, isContentType, isObject, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs, zStringToJson };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import z, { ZodError } from 'zod';
|
|
1
|
+
import z$1, { ZodError, z } from 'zod';
|
|
2
2
|
|
|
3
3
|
declare const _URL: {
|
|
4
4
|
new (url: string | URL, base?: string | URL): URL;
|
|
@@ -30,11 +30,6 @@ declare class JsonParseError extends Error {
|
|
|
30
30
|
|
|
31
31
|
declare class ValidationError extends Error {
|
|
32
32
|
zodError: ZodError | undefined;
|
|
33
|
-
private escapeQuotes;
|
|
34
|
-
private joinPath;
|
|
35
|
-
private getMessageFromUnionErrors;
|
|
36
|
-
private getMessageFromZodIssue;
|
|
37
|
-
private formatError;
|
|
38
33
|
constructor(message: string, zodError?: z.ZodError);
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -89,13 +84,13 @@ declare function isObject(item: unknown): item is Record<string, unknown>;
|
|
|
89
84
|
*/
|
|
90
85
|
declare function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown;
|
|
91
86
|
|
|
92
|
-
type BaseSchema = z.ZodTypeAny;
|
|
87
|
+
type BaseSchema = z$1.ZodTypeAny;
|
|
93
88
|
type InferOutputUnion<T extends readonly any[]> = {
|
|
94
|
-
[K in keyof T]: z.infer<T[K]>;
|
|
89
|
+
[K in keyof T]: z$1.infer<T[K]>;
|
|
95
90
|
}[number];
|
|
96
91
|
declare function stringToJsonWithErrorHandling(string: string, errorMessage?: string): any;
|
|
97
92
|
declare function parseIfJson<T>(data: T): T | Record<string, unknown>;
|
|
98
|
-
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z.infer<Schema>;
|
|
93
|
+
declare function parseWithErrorHandling<Schema extends BaseSchema>(schema: Schema, data: unknown, customErrorMessage?: string): z$1.infer<Schema>;
|
|
99
94
|
|
|
100
95
|
/**
|
|
101
96
|
* Combine multiple uri parts into a single uri taking into account slashes.
|
|
@@ -119,9 +114,9 @@ declare function objectToQueryParams(object: Record<string, unknown>): InstanceT
|
|
|
119
114
|
* A type utility which represents the function returned
|
|
120
115
|
* from createZodFetcher
|
|
121
116
|
*/
|
|
122
|
-
type ZodFetcher = <Schema extends z.ZodTypeAny>(schema: Schema, expectedContentType: ContentType, ...args: Parameters<Fetch>) => Promise<{
|
|
117
|
+
type ZodFetcher = <Schema extends z$1.ZodTypeAny>(schema: Schema, expectedContentType: ContentType, ...args: Parameters<Fetch>) => Promise<{
|
|
123
118
|
response: Awaited<ReturnType<Fetch>>;
|
|
124
|
-
result?: z.SafeParseReturnType<Schema, z.infer<Schema>>;
|
|
119
|
+
result?: z$1.SafeParseReturnType<Schema, z$1.infer<Schema>>;
|
|
125
120
|
}>;
|
|
126
121
|
declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
127
122
|
/**
|
|
@@ -144,12 +139,14 @@ declare function createFetcher(fetcher?: typeof fetch): Fetch;
|
|
|
144
139
|
*/
|
|
145
140
|
declare function createZodFetcher(fetcher?: Fetch): ZodFetcher;
|
|
146
141
|
|
|
147
|
-
declare const zHttpsUrl: z.ZodEffects<z.ZodString, string, string>;
|
|
148
|
-
declare const zInteger: z.ZodNumber;
|
|
149
|
-
declare const zHttpMethod: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]>;
|
|
150
|
-
type HttpMethod = z.infer<typeof zHttpMethod>;
|
|
151
|
-
declare const zStringToJson: z.ZodEffects<z.ZodString, any, string>;
|
|
152
|
-
declare const zIs: <Schema extends z.ZodSchema>(schema: Schema, data: unknown) => data is z.infer<typeof schema>;
|
|
142
|
+
declare const zHttpsUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
|
|
143
|
+
declare const zInteger: z$1.ZodNumber;
|
|
144
|
+
declare const zHttpMethod: z$1.ZodEnum<["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]>;
|
|
145
|
+
type HttpMethod = z$1.infer<typeof zHttpMethod>;
|
|
146
|
+
declare const zStringToJson: z$1.ZodEffects<z$1.ZodString, any, string>;
|
|
147
|
+
declare const zIs: <Schema extends z$1.ZodSchema>(schema: Schema, data: unknown) => data is z$1.infer<typeof schema>;
|
|
148
|
+
|
|
149
|
+
declare function formatZodError(error?: z$1.ZodError): string;
|
|
153
150
|
|
|
154
151
|
interface WwwAuthenticateHeaderChallenge {
|
|
155
152
|
scheme: string;
|
|
@@ -162,4 +159,4 @@ interface WwwAuthenticateHeaderChallenge {
|
|
|
162
159
|
declare function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[];
|
|
163
160
|
declare function encodeWwwAuthenticateHeader(challenges: WwwAuthenticateHeaderChallenge[]): string;
|
|
164
161
|
|
|
165
|
-
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, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isContentType, isObject, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs, zStringToJson };
|
|
162
|
+
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, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64, encodeToBase64Url, encodeToUtf8String, encodeWwwAuthenticateHeader, formatZodError, getGlobalConfig, getQueryParams, isContentType, isObject, isResponseContentType, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWithErrorHandling, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zHttpMethod, zHttpsUrl, zInteger, zIs, zStringToJson };
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __export(src_exports, {
|
|
|
48
48
|
encodeToBase64Url: () => encodeToBase64Url,
|
|
49
49
|
encodeToUtf8String: () => encodeToUtf8String,
|
|
50
50
|
encodeWwwAuthenticateHeader: () => encodeWwwAuthenticateHeader,
|
|
51
|
+
formatZodError: () => formatZodError,
|
|
51
52
|
getGlobalConfig: () => getGlobalConfig,
|
|
52
53
|
getQueryParams: () => getQueryParams,
|
|
53
54
|
isContentType: () => isContentType,
|
|
@@ -92,7 +93,7 @@ ${jsonString}`);
|
|
|
92
93
|
}
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
// src/error
|
|
96
|
+
// src/zod-error.ts
|
|
96
97
|
var import_zod = require("zod");
|
|
97
98
|
var constants = {
|
|
98
99
|
// biome-ignore lint/suspicious/noMisleadingCharacterClass: expected
|
|
@@ -100,69 +101,71 @@ var constants = {
|
|
|
100
101
|
unionSeparator: ", or ",
|
|
101
102
|
issueSeparator: "\n - "
|
|
102
103
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return path[0].toString();
|
|
110
|
-
}
|
|
111
|
-
return path.reduce((acc, item) => {
|
|
112
|
-
if (typeof item === "number") {
|
|
113
|
-
return `${acc}[${item.toString()}]`;
|
|
114
|
-
}
|
|
115
|
-
if (item.includes('"')) {
|
|
116
|
-
return `${acc}["${this.escapeQuotes(item)}"]`;
|
|
117
|
-
}
|
|
118
|
-
if (!constants.identifierRegex.test(item)) {
|
|
119
|
-
return `${acc}["${item}"]`;
|
|
120
|
-
}
|
|
121
|
-
const separator = acc.length === 0 ? "" : ".";
|
|
122
|
-
return acc + separator + item;
|
|
123
|
-
}, "");
|
|
124
|
-
}
|
|
125
|
-
getMessageFromUnionErrors(unionErrors) {
|
|
126
|
-
return unionErrors.reduce((acc, zodError) => {
|
|
127
|
-
const newIssues = zodError.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator);
|
|
128
|
-
if (!acc.includes(newIssues)) acc.push(newIssues);
|
|
129
|
-
return acc;
|
|
130
|
-
}, []).join(constants.unionSeparator);
|
|
104
|
+
function escapeQuotes(str) {
|
|
105
|
+
return str.replace(/"/g, '\\"');
|
|
106
|
+
}
|
|
107
|
+
function joinPath(path) {
|
|
108
|
+
if (path.length === 1) {
|
|
109
|
+
return path[0].toString();
|
|
131
110
|
}
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
111
|
+
return path.reduce((acc, item) => {
|
|
112
|
+
if (typeof item === "number") {
|
|
113
|
+
return `${acc}[${item.toString()}]`;
|
|
135
114
|
}
|
|
136
|
-
if (
|
|
137
|
-
return [
|
|
138
|
-
constants.issueSeparator
|
|
139
|
-
);
|
|
115
|
+
if (item.includes('"')) {
|
|
116
|
+
return `${acc}["${escapeQuotes(item)}"]`;
|
|
140
117
|
}
|
|
141
|
-
if (
|
|
142
|
-
return [
|
|
143
|
-
constants.issueSeparator
|
|
144
|
-
);
|
|
118
|
+
if (!constants.identifierRegex.test(item)) {
|
|
119
|
+
return `${acc}["${item}"]`;
|
|
145
120
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
121
|
+
const separator = acc.length === 0 ? "" : ".";
|
|
122
|
+
return acc + separator + item;
|
|
123
|
+
}, "");
|
|
124
|
+
}
|
|
125
|
+
function getMessageFromZodIssue(issue) {
|
|
126
|
+
if (issue.code === import_zod.ZodIssueCode.invalid_union) {
|
|
127
|
+
return getMessageFromUnionErrors(issue.unionErrors);
|
|
128
|
+
}
|
|
129
|
+
if (issue.code === import_zod.ZodIssueCode.invalid_arguments) {
|
|
130
|
+
return [issue.message, ...issue.argumentsError.issues.map((issue2) => getMessageFromZodIssue(issue2))].join(
|
|
131
|
+
constants.issueSeparator
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
if (issue.code === import_zod.ZodIssueCode.invalid_return_type) {
|
|
135
|
+
return [issue.message, ...issue.returnTypeError.issues.map((issue2) => getMessageFromZodIssue(issue2))].join(
|
|
136
|
+
constants.issueSeparator
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (issue.path.length !== 0) {
|
|
140
|
+
if (issue.path.length === 1) {
|
|
141
|
+
const identifier = issue.path[0];
|
|
142
|
+
if (typeof identifier === "number") {
|
|
143
|
+
return `${issue.message} at index ${identifier}`;
|
|
152
144
|
}
|
|
153
|
-
return `${issue.message} at "${this.joinPath(issue.path)}"`;
|
|
154
145
|
}
|
|
155
|
-
return issue.message
|
|
156
|
-
}
|
|
157
|
-
formatError(error) {
|
|
158
|
-
if (!error) return "";
|
|
159
|
-
return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator);
|
|
146
|
+
return `${issue.message} at "${joinPath(issue.path)}"`;
|
|
160
147
|
}
|
|
148
|
+
return issue.message;
|
|
149
|
+
}
|
|
150
|
+
function getMessageFromUnionErrors(unionErrors) {
|
|
151
|
+
return unionErrors.reduce((acc, zodError) => {
|
|
152
|
+
const newIssues = zodError.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator);
|
|
153
|
+
if (!acc.includes(newIssues)) acc.push(newIssues);
|
|
154
|
+
return acc;
|
|
155
|
+
}, []).join(constants.unionSeparator);
|
|
156
|
+
}
|
|
157
|
+
function formatZodError(error) {
|
|
158
|
+
if (!error) return "";
|
|
159
|
+
return ` - ${error?.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator)}`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/error/ValidationError.ts
|
|
163
|
+
var ValidationError = class extends Error {
|
|
161
164
|
constructor(message, zodError) {
|
|
162
165
|
super(message);
|
|
163
|
-
const formattedError =
|
|
166
|
+
const formattedError = formatZodError(zodError);
|
|
164
167
|
this.message = `${message}
|
|
165
|
-
|
|
168
|
+
${formattedError}`;
|
|
166
169
|
Object.defineProperty(this, "zodError", {
|
|
167
170
|
value: zodError,
|
|
168
171
|
writable: false,
|
|
@@ -481,6 +484,7 @@ function encodeWwwAuthenticateHeader(challenges) {
|
|
|
481
484
|
encodeToBase64Url,
|
|
482
485
|
encodeToUtf8String,
|
|
483
486
|
encodeWwwAuthenticateHeader,
|
|
487
|
+
formatZodError,
|
|
484
488
|
getGlobalConfig,
|
|
485
489
|
getQueryParams,
|
|
486
490
|
isContentType,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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/error/FetchError.ts","../src/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, createFetcher } from './fetcher'\nexport {\n type HttpMethod,\n zHttpMethod,\n zHttpsUrl,\n zInteger,\n zIs,\n zStringToJson,\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 OAuthAuthorizationRequestJwt = '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","export class FetchError extends Error {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\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// biome-ignore lint/style/noRestrictedGlobals: this is the only place where we use the global\nconst defaultFetcher = fetch\n\nexport function createFetcher(fetcher = defaultFetcher): Fetch {\n return (input, init, ...args) => {\n return fetcher(\n input,\n init\n ? {\n ...init,\n // React Native does not seem to handle the toString(). This is hard to catch when running\n // tests in Node.JS where this does work correctly. so we handle it here.\n body: init.body instanceof URLSearchParams ? init.body.toString() : init.body,\n }\n : undefined,\n ...args\n ).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${input}'`, { cause: error })\n })\n }\n}\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher?: Fetch): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await createFetcher(fetcher)(...args)\n\n 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.OAuthAuthorizationRequestJwt) {\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 zStringToJson = z.string().transform((string, ctx) => {\n try {\n return JSON.parse(string)\n } catch (error) {\n ctx.addIssue({\n code: 'custom',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n })\n return z.NEVER\n }\n})\n\nexport const zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\n","const unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\\"/g, '\"')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,IAAM,OAAO;AAGb,IAAM,mBAAmB;AAOzB,IAAM,WAAW;;;ACXV,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAG5C,YACL,SACgB,cAChB,UACA;AACA,U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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/zod-error.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/error/FetchError.ts","../src/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, createFetcher } from './fetcher'\nexport {\n type HttpMethod,\n zHttpMethod,\n zHttpsUrl,\n zInteger,\n zIs,\n zStringToJson,\n} from './validation'\nexport { formatZodError } from './zod-error'\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 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\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n}\n\nfunction 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}[\"${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}\nfunction getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => 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) => 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 \"${joinPath(issue.path)}\"`\n }\n\n return issue.message\n}\n\nfunction getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n}\n\nexport function formatZodError(error?: z.ZodError): string {\n if (!error) return ''\n\n return `\\t- ${error?.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator)}`\n}\n","import type { ZodError, z } from 'zod'\nimport { formatZodError } from '../zod-error'\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = formatZodError(zodError)\n this.message = `${message}\\n${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n OAuthAuthorizationRequestJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n}\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","export class FetchError extends Error {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\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// biome-ignore lint/style/noRestrictedGlobals: this is the only place where we use the global\nconst defaultFetcher = fetch\n\nexport function createFetcher(fetcher = defaultFetcher): Fetch {\n return (input, init, ...args) => {\n return fetcher(\n input,\n init\n ? {\n ...init,\n // React Native does not seem to handle the toString(). This is hard to catch when running\n // tests in Node.JS where this does work correctly. so we handle it here.\n body: init.body instanceof URLSearchParams ? init.body.toString() : init.body,\n }\n : undefined,\n ...args\n ).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${input}'`, { cause: error })\n })\n }\n}\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher?: Fetch): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await createFetcher(fetcher)(...args)\n\n 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.OAuthAuthorizationRequestJwt) {\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 zStringToJson = z.string().transform((string, ctx) => {\n try {\n return JSON.parse(string)\n } catch (error) {\n ctx.addIssue({\n code: 'custom',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n })\n return z.NEVER\n }\n})\n\nexport const zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\n","const unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\\"/g, '\"')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,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,iBAA4C;AAM5C,IAAM,YAAY;AAAA;AAAA,EAEhB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;AAEA,SAAS,aAAa,KAAqB;AACzC,SAAO,IAAI,QAAQ,MAAM,KAAK;AAChC;AAEA,SAAS,SAAS,MAAsC;AACtD,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO,KAAK,CAAC,EAAE,SAAS;AAAA,EAC1B;AAEA,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E;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType","import_zod","z"]}
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ ${jsonString}`);
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// src/error
|
|
24
|
+
// src/zod-error.ts
|
|
25
25
|
import { ZodIssueCode } from "zod";
|
|
26
26
|
var constants = {
|
|
27
27
|
// biome-ignore lint/suspicious/noMisleadingCharacterClass: expected
|
|
@@ -29,69 +29,71 @@ var constants = {
|
|
|
29
29
|
unionSeparator: ", or ",
|
|
30
30
|
issueSeparator: "\n - "
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return path[0].toString();
|
|
39
|
-
}
|
|
40
|
-
return path.reduce((acc, item) => {
|
|
41
|
-
if (typeof item === "number") {
|
|
42
|
-
return `${acc}[${item.toString()}]`;
|
|
43
|
-
}
|
|
44
|
-
if (item.includes('"')) {
|
|
45
|
-
return `${acc}["${this.escapeQuotes(item)}"]`;
|
|
46
|
-
}
|
|
47
|
-
if (!constants.identifierRegex.test(item)) {
|
|
48
|
-
return `${acc}["${item}"]`;
|
|
49
|
-
}
|
|
50
|
-
const separator = acc.length === 0 ? "" : ".";
|
|
51
|
-
return acc + separator + item;
|
|
52
|
-
}, "");
|
|
53
|
-
}
|
|
54
|
-
getMessageFromUnionErrors(unionErrors) {
|
|
55
|
-
return unionErrors.reduce((acc, zodError) => {
|
|
56
|
-
const newIssues = zodError.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator);
|
|
57
|
-
if (!acc.includes(newIssues)) acc.push(newIssues);
|
|
58
|
-
return acc;
|
|
59
|
-
}, []).join(constants.unionSeparator);
|
|
32
|
+
function escapeQuotes(str) {
|
|
33
|
+
return str.replace(/"/g, '\\"');
|
|
34
|
+
}
|
|
35
|
+
function joinPath(path) {
|
|
36
|
+
if (path.length === 1) {
|
|
37
|
+
return path[0].toString();
|
|
60
38
|
}
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
39
|
+
return path.reduce((acc, item) => {
|
|
40
|
+
if (typeof item === "number") {
|
|
41
|
+
return `${acc}[${item.toString()}]`;
|
|
64
42
|
}
|
|
65
|
-
if (
|
|
66
|
-
return [
|
|
67
|
-
constants.issueSeparator
|
|
68
|
-
);
|
|
43
|
+
if (item.includes('"')) {
|
|
44
|
+
return `${acc}["${escapeQuotes(item)}"]`;
|
|
69
45
|
}
|
|
70
|
-
if (
|
|
71
|
-
return [
|
|
72
|
-
constants.issueSeparator
|
|
73
|
-
);
|
|
46
|
+
if (!constants.identifierRegex.test(item)) {
|
|
47
|
+
return `${acc}["${item}"]`;
|
|
74
48
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
49
|
+
const separator = acc.length === 0 ? "" : ".";
|
|
50
|
+
return acc + separator + item;
|
|
51
|
+
}, "");
|
|
52
|
+
}
|
|
53
|
+
function getMessageFromZodIssue(issue) {
|
|
54
|
+
if (issue.code === ZodIssueCode.invalid_union) {
|
|
55
|
+
return getMessageFromUnionErrors(issue.unionErrors);
|
|
56
|
+
}
|
|
57
|
+
if (issue.code === ZodIssueCode.invalid_arguments) {
|
|
58
|
+
return [issue.message, ...issue.argumentsError.issues.map((issue2) => getMessageFromZodIssue(issue2))].join(
|
|
59
|
+
constants.issueSeparator
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (issue.code === ZodIssueCode.invalid_return_type) {
|
|
63
|
+
return [issue.message, ...issue.returnTypeError.issues.map((issue2) => getMessageFromZodIssue(issue2))].join(
|
|
64
|
+
constants.issueSeparator
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (issue.path.length !== 0) {
|
|
68
|
+
if (issue.path.length === 1) {
|
|
69
|
+
const identifier = issue.path[0];
|
|
70
|
+
if (typeof identifier === "number") {
|
|
71
|
+
return `${issue.message} at index ${identifier}`;
|
|
81
72
|
}
|
|
82
|
-
return `${issue.message} at "${this.joinPath(issue.path)}"`;
|
|
83
73
|
}
|
|
84
|
-
return issue.message
|
|
85
|
-
}
|
|
86
|
-
formatError(error) {
|
|
87
|
-
if (!error) return "";
|
|
88
|
-
return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator);
|
|
74
|
+
return `${issue.message} at "${joinPath(issue.path)}"`;
|
|
89
75
|
}
|
|
76
|
+
return issue.message;
|
|
77
|
+
}
|
|
78
|
+
function getMessageFromUnionErrors(unionErrors) {
|
|
79
|
+
return unionErrors.reduce((acc, zodError) => {
|
|
80
|
+
const newIssues = zodError.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator);
|
|
81
|
+
if (!acc.includes(newIssues)) acc.push(newIssues);
|
|
82
|
+
return acc;
|
|
83
|
+
}, []).join(constants.unionSeparator);
|
|
84
|
+
}
|
|
85
|
+
function formatZodError(error) {
|
|
86
|
+
if (!error) return "";
|
|
87
|
+
return ` - ${error?.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator)}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/error/ValidationError.ts
|
|
91
|
+
var ValidationError = class extends Error {
|
|
90
92
|
constructor(message, zodError) {
|
|
91
93
|
super(message);
|
|
92
|
-
const formattedError =
|
|
94
|
+
const formattedError = formatZodError(zodError);
|
|
93
95
|
this.message = `${message}
|
|
94
|
-
|
|
96
|
+
${formattedError}`;
|
|
95
97
|
Object.defineProperty(this, "zodError", {
|
|
96
98
|
value: zodError,
|
|
97
99
|
writable: false,
|
|
@@ -409,6 +411,7 @@ export {
|
|
|
409
411
|
encodeToBase64Url,
|
|
410
412
|
encodeToUtf8String,
|
|
411
413
|
encodeWwwAuthenticateHeader,
|
|
414
|
+
formatZodError,
|
|
412
415
|
getGlobalConfig,
|
|
413
416
|
getQueryParams,
|
|
414
417
|
isContentType,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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/error/FetchError.ts","../src/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 OAuthAuthorizationRequestJwt = '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","export class FetchError extends Error {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\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// biome-ignore lint/style/noRestrictedGlobals: this is the only place where we use the global\nconst defaultFetcher = fetch\n\nexport function createFetcher(fetcher = defaultFetcher): Fetch {\n return (input, init, ...args) => {\n return fetcher(\n input,\n init\n ? {\n ...init,\n // React Native does not seem to handle the toString(). This is hard to catch when running\n // tests in Node.JS where this does work correctly. so we handle it here.\n body: init.body instanceof URLSearchParams ? init.body.toString() : init.body,\n }\n : undefined,\n ...args\n ).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${input}'`, { cause: error })\n })\n }\n}\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher?: Fetch): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await createFetcher(fetcher)(...args)\n\n 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.OAuthAuthorizationRequestJwt) {\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 zStringToJson = z.string().transform((string, ctx) => {\n try {\n return JSON.parse(string)\n } catch (error) {\n ctx.addIssue({\n code: 'custom',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n })\n return z.NEVER\n }\n})\n\nexport const zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\n","const unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\\"/g, '\"')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <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}\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AK,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/zod-error.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/error/FetchError.ts","../src/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 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\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n}\n\nfunction 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}[\"${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}\nfunction getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => 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) => 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 \"${joinPath(issue.path)}\"`\n }\n\n return issue.message\n}\n\nfunction getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n}\n\nexport function formatZodError(error?: z.ZodError): string {\n if (!error) return ''\n\n return `\\t- ${error?.issues.map((issue) => getMessageFromZodIssue(issue)).join(constants.issueSeparator)}`\n}\n","import type { ZodError, z } from 'zod'\nimport { formatZodError } from '../zod-error'\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = formatZodError(zodError)\n this.message = `${message}\\n${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n OAuthAuthorizationRequestJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n}\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","export class FetchError extends Error {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\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// biome-ignore lint/style/noRestrictedGlobals: this is the only place where we use the global\nconst defaultFetcher = fetch\n\nexport function createFetcher(fetcher = defaultFetcher): Fetch {\n return (input, init, ...args) => {\n return fetcher(\n input,\n init\n ? {\n ...init,\n // React Native does not seem to handle the toString(). This is hard to catch when running\n // tests in Node.JS where this does work correctly. so we handle it here.\n body: init.body instanceof URLSearchParams ? init.body.toString() : init.body,\n }\n : undefined,\n ...args\n ).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${input}'`, { cause: error })\n })\n }\n}\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher?: Fetch): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await createFetcher(fetcher)(...args)\n\n 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.OAuthAuthorizationRequestJwt) {\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 zStringToJson = z.string().transform((string, ctx) => {\n try {\n return JSON.parse(string)\n } catch (error) {\n ctx.addIssue({\n code: 'custom',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n })\n return z.NEVER\n }\n})\n\nexport const zIs = <Schema extends z.ZodSchema>(schema: Schema, data: unknown): data is z.infer<typeof schema> =>\n schema.safeParse(data).success\n","const unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\\"/g, '\"')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: <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,SAAwB,oBAAoB;AAM5C,IAAM,YAAY;AAAA;AAAA,EAEhB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB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