@openid4vc/utils 0.3.0-alpha-20250321142414 → 0.3.0-alpha-20250321145547
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.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -324,11 +324,22 @@ function objectToQueryParams(object) {
|
|
|
324
324
|
return params;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
// src/error/FetchError.ts
|
|
328
|
+
var FetchError = class extends Error {
|
|
329
|
+
constructor(message, { cause } = {}) {
|
|
330
|
+
super(`${message}
|
|
331
|
+
Cause: ${cause?.message}`);
|
|
332
|
+
this.cause = cause;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
327
336
|
// src/zod-fetcher.ts
|
|
328
337
|
var defaultFetcher = fetch;
|
|
329
338
|
function createZodFetcher(fetcher = defaultFetcher) {
|
|
330
339
|
return async (schema, expectedContentType, ...args) => {
|
|
331
|
-
const response = await fetcher(...args)
|
|
340
|
+
const response = await fetcher(...args).catch((error) => {
|
|
341
|
+
throw new FetchError(`Unknown error occurred during fetch to '${args[0]}'`, { cause: error });
|
|
342
|
+
});
|
|
332
343
|
if (response.ok && !isResponseContentType(expectedContentType, response)) {
|
|
333
344
|
throw new InvalidFetchResponseError(
|
|
334
345
|
`Expected response to match content type '${expectedContentType}', but received '${response.headers.get("Content-Type")}'`,
|
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/zod-fetcher.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["export {\n Headers,\n URL,\n URLSearchParams,\n type Fetch,\n type FetchHeaders,\n type FetchRequestInit,\n type FetchResponse,\n} from './globals'\n\nexport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nexport { JsonParseError } from './error/JsonParseError'\nexport { ValidationError } from './error/ValidationError'\n\nexport { arrayEqualsIgnoreOrder } from './array'\nexport { getGlobalConfig, setGlobalConfig, type Oid4vcTsConfig } from './config'\nexport { ContentType, isContentType, isResponseContentType } from './content-type'\nexport { addSecondsToDate, dateToSeconds } from './date'\nexport {\n decodeBase64,\n decodeUtf8String,\n encodeToBase64,\n encodeToBase64Url,\n encodeToUtf8String,\n} from './encoding'\nexport { mergeDeep } from './object'\nexport {\n parseWithErrorHandling,\n stringToJsonWithErrorHandling,\n parseIfJson,\n type BaseSchema,\n type InferOutputUnion,\n} from './parse'\nexport { joinUriParts } from './path'\nexport type { Optional, OrPromise, Simplify, StringWithAutoCompletion } from './type'\nexport { getQueryParams, objectToQueryParams } from './url'\nexport { type ZodFetcher, createZodFetcher, defaultFetcher } from './zod-fetcher'\nexport {\n type HttpMethod,\n zHttpMethod,\n zHttpsUrl,\n zInteger,\n zIs,\n 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","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport type { Fetch } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args)\n\n if (response.ok && !isResponseContentType(expectedContentType, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type '${expectedContentType}', but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (expectedContentType === ContentType.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,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,iBAA2D;AAM3D,IAAM,YAAY;AAAA;AAAA,EAEhB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGjC,aAAa,KAAqB;AACxC,WAAO,IAAI,QAAQ,MAAM,KAAK;AAAA,EAChC;AAAA,EAEQ,SAAS,MAAsC;AACrD,QAAI,KAAK,WAAW,GAAG;AACrB,aAAO,KAAK,CAAC,EAAE,SAAS;AAAA,IAC1B;AAEA,WAAO,KAAK,OAAe,CAAC,KAAK,SAAS;AAExC,UAAI,OAAO,SAAS,UAAU;AAC5B,eAAO,GAAG,GAAG,IAAI,KAAK,SAAS,CAAC;AAAA,MAClC;AAGA,UAAI,KAAK,SAAS,G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4B,YAA8C;AACxF,QAAM,UAAoB,CAAC;AAE3B,aAAW,aAAa,YAAY;AAElC,UAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChF,YAAM,SAAS,CAAC,MAAc,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK;AAE1E,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM,IAAI,CAAC,MAAM,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,GAAG;AAAA,MACjD;AAEA,aAAO,QAAQ,GAAG,GAAG,KAAK,OAAO,KAAK,CAAC,MAAM;AAAA,IAC/C,CAAC;AAED,YAAQ,KAAK,cAAc,WAAW,IAAI,UAAU,SAAS,GAAG,UAAU,MAAM,IAAI,cAAc,KAAK,IAAI,CAAC,EAAE;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType","import_zod","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/globals.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/error/ValidationError.ts","../src/array.ts","../src/config.ts","../src/content-type.ts","../src/date.ts","../src/encoding.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/error/FetchError.ts","../src/zod-fetcher.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["export {\n Headers,\n URL,\n URLSearchParams,\n type Fetch,\n type FetchHeaders,\n type FetchRequestInit,\n type FetchResponse,\n} from './globals'\n\nexport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nexport { JsonParseError } from './error/JsonParseError'\nexport { ValidationError } from './error/ValidationError'\n\nexport { arrayEqualsIgnoreOrder } from './array'\nexport { getGlobalConfig, setGlobalConfig, type Oid4vcTsConfig } from './config'\nexport { ContentType, isContentType, isResponseContentType } from './content-type'\nexport { addSecondsToDate, dateToSeconds } from './date'\nexport {\n decodeBase64,\n decodeUtf8String,\n encodeToBase64,\n encodeToBase64Url,\n encodeToUtf8String,\n} from './encoding'\nexport { mergeDeep } from './object'\nexport {\n parseWithErrorHandling,\n stringToJsonWithErrorHandling,\n parseIfJson,\n type BaseSchema,\n type InferOutputUnion,\n} from './parse'\nexport { joinUriParts } from './path'\nexport type { Optional, OrPromise, Simplify, StringWithAutoCompletion } from './type'\nexport { getQueryParams, objectToQueryParams } from './url'\nexport { type ZodFetcher, createZodFetcher, defaultFetcher } from './zod-fetcher'\nexport {\n type HttpMethod,\n zHttpMethod,\n zHttpsUrl,\n zInteger,\n zIs,\n 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 } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${args[0]}'`, { cause: error })\n })\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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,QAAQ,KAAK,CAAC;AAC3C,MAAI,gBAAgB;AAClB,eAAW,KAAK,EAAE,QAAQ,gBAAgB,SAAS,CAAC,EAAE,CAAC;AAAA,EACzD;AACA,SAAO;AACT;AAEO,SAAS,4BAA4B,YAA8C;AACxF,QAAM,UAAoB,CAAC;AAE3B,aAAW,aAAa,YAAY;AAElC,UAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAChF,YAAM,SAAS,CAAC,MAAc,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK;AAE1E,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM,IAAI,CAAC,MAAM,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,GAAG;AAAA,MACjD;AAEA,aAAO,QAAQ,GAAG,GAAG,KAAK,OAAO,KAAK,CAAC,MAAM;AAAA,IAC/C,CAAC;AAED,YAAQ,KAAK,cAAc,WAAW,IAAI,UAAU,SAAS,GAAG,UAAU,MAAM,IAAI,cAAc,KAAK,IAAI,CAAC,EAAE;AAAA,EAChH;AAEA,SAAO,QAAQ,KAAK,IAAI;AAC1B;","names":["issue","ContentType","import_zod","z"]}
|
package/dist/index.mjs
CHANGED
|
@@ -253,11 +253,22 @@ function objectToQueryParams(object) {
|
|
|
253
253
|
return params;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
// src/error/FetchError.ts
|
|
257
|
+
var FetchError = class extends Error {
|
|
258
|
+
constructor(message, { cause } = {}) {
|
|
259
|
+
super(`${message}
|
|
260
|
+
Cause: ${cause?.message}`);
|
|
261
|
+
this.cause = cause;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
256
265
|
// src/zod-fetcher.ts
|
|
257
266
|
var defaultFetcher = fetch;
|
|
258
267
|
function createZodFetcher(fetcher = defaultFetcher) {
|
|
259
268
|
return async (schema, expectedContentType, ...args) => {
|
|
260
|
-
const response = await fetcher(...args)
|
|
269
|
+
const response = await fetcher(...args).catch((error) => {
|
|
270
|
+
throw new FetchError(`Unknown error occurred during fetch to '${args[0]}'`, { cause: error });
|
|
271
|
+
});
|
|
261
272
|
if (response.ok && !isResponseContentType(expectedContentType, response)) {
|
|
262
273
|
throw new InvalidFetchResponseError(
|
|
263
274
|
`Expected response to match content type '${expectedContentType}', but received '${response.headers.get("Content-Type")}'`,
|
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/zod-fetcher.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _URLSearchParams as URLSearchParams, _URL as URL, _Headers as Headers }\n","import type { FetchResponse } from '../globals'\n\nexport class InvalidFetchResponseError extends Error {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n super(`${message}\\n${textResponse}`)\n this.response = response.clone()\n }\n}\n","export class JsonParseError extends Error {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import type z from 'zod'\nimport { type ZodError, type ZodIssue, ZodIssueCode } from 'zod'\n\n/**\n * Some code comes from `zod-validation-error` package (MIT License) and\n * was slightly simplified to fit our needs.\n */\nconst constants = {\n // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected\n identifierRegex: /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u,\n unionSeparator: ', or ',\n issueSeparator: '\\n\\t- ',\n}\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n private escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n }\n\n private joinPath(path: Array<string | number>): string {\n if (path.length === 1) {\n return path[0].toString()\n }\n\n return path.reduce<string>((acc, item) => {\n // handle numeric indices\n if (typeof item === 'number') {\n return `${acc}[${item.toString()}]`\n }\n\n // handle quoted values\n if (item.includes('\"')) {\n return `${acc}[\"${this.escapeQuotes(item)}\"]`\n }\n\n // handle special characters\n if (!constants.identifierRegex.test(item)) {\n return `${acc}[\"${item}\"]`\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.'\n return acc + separator + item\n }, '')\n }\n\n private getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) => this.getMessageFromZodIssue(issue))\n .join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n }\n\n private getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return this.getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.code === ZodIssueCode.invalid_return_type) {\n return [issue.message, ...issue.returnTypeError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.path.length !== 0) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0]\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`\n }\n }\n\n return `${issue.message} at \"${this.joinPath(issue.path)}\"`\n }\n\n return issue.message\n }\n\n private formatError(error?: z.ZodError): string {\n if (!error) return ''\n\n return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n }\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = this.formatError(zodError)\n this.message = `${message}\\n\\t- ${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n 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","import type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport type { Fetch } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args)\n\n if (response.ok && !isResponseContentType(expectedContentType, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type '${expectedContentType}', but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (expectedContentType === ContentType.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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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/zod-fetcher.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _URLSearchParams as URLSearchParams, _URL as URL, _Headers as Headers }\n","import type { FetchResponse } from '../globals'\n\nexport class InvalidFetchResponseError extends Error {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n super(`${message}\\n${textResponse}`)\n this.response = response.clone()\n }\n}\n","export class JsonParseError extends Error {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import type z from 'zod'\nimport { type ZodError, type ZodIssue, ZodIssueCode } from 'zod'\n\n/**\n * Some code comes from `zod-validation-error` package (MIT License) and\n * was slightly simplified to fit our needs.\n */\nconst constants = {\n // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected\n identifierRegex: /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u,\n unionSeparator: ', or ',\n issueSeparator: '\\n\\t- ',\n}\n\nexport class ValidationError extends Error {\n public zodError: ZodError | undefined\n\n private escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"')\n }\n\n private joinPath(path: Array<string | number>): string {\n if (path.length === 1) {\n return path[0].toString()\n }\n\n return path.reduce<string>((acc, item) => {\n // handle numeric indices\n if (typeof item === 'number') {\n return `${acc}[${item.toString()}]`\n }\n\n // handle quoted values\n if (item.includes('\"')) {\n return `${acc}[\"${this.escapeQuotes(item)}\"]`\n }\n\n // handle special characters\n if (!constants.identifierRegex.test(item)) {\n return `${acc}[\"${item}\"]`\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.'\n return acc + separator + item\n }, '')\n }\n\n private getMessageFromUnionErrors(unionErrors: z.ZodError[]): string {\n return unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) => this.getMessageFromZodIssue(issue))\n .join(constants.issueSeparator)\n\n if (!acc.includes(newIssues)) acc.push(newIssues)\n\n return acc\n }, [])\n .join(constants.unionSeparator)\n }\n\n private getMessageFromZodIssue(issue: ZodIssue): string {\n if (issue.code === ZodIssueCode.invalid_union) {\n return this.getMessageFromUnionErrors(issue.unionErrors)\n }\n\n if (issue.code === ZodIssueCode.invalid_arguments) {\n return [issue.message, ...issue.argumentsError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.code === ZodIssueCode.invalid_return_type) {\n return [issue.message, ...issue.returnTypeError.issues.map((issue) => this.getMessageFromZodIssue(issue))].join(\n constants.issueSeparator\n )\n }\n\n if (issue.path.length !== 0) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0]\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`\n }\n }\n\n return `${issue.message} at \"${this.joinPath(issue.path)}\"`\n }\n\n return issue.message\n }\n\n private formatError(error?: z.ZodError): string {\n if (!error) return ''\n\n return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator)\n }\n\n constructor(message: string, zodError?: z.ZodError) {\n super(message)\n\n const formattedError = this.formatError(zodError)\n this.message = `${message}\\n\\t- ${formattedError}`\n\n Object.defineProperty(this, 'zodError', {\n value: zodError,\n writable: false,\n enumerable: false,\n })\n }\n}\n","/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n 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 } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType,\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: z.SafeParseReturnType<Schema, z.infer<Schema>> }>\n\n/**\n * The default fetcher used by createZodFetcher when no\n * fetcher is provided.\n */\n\n// biome-ignore lint/style/noRestrictedGlobals: <explanation>\nexport const defaultFetcher = fetch\n\n/**\n * Creates a `fetchWithZod` function that takes in a schema of\n * the expected response, and the arguments to the fetcher\n * you provided.\n *\n * @example\n *\n * const fetchWithZod = createZodFetcher((url) => {\n * return fetch(url).then((res) => res.json());\n * });\n *\n * const response = await fetchWithZod(\n * z.object({\n * hello: z.string(),\n * }),\n * \"https://example.com\",\n * );\n */\nexport function createZodFetcher(fetcher = defaultFetcher): ZodFetcher {\n return async (schema, expectedContentType, ...args) => {\n const response = await fetcher(...args).catch((error) => {\n throw new FetchError(`Unknown error occurred during fetch to '${args[0]}'`, { cause: error })\n })\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,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