@openid4vc/utils 0.10.0-alpha-20261103204813 → 0.10.0-alpha-20261103225859
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 +2 -13
- package/dist/index.mjs +5 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,7 @@ interface Oid4vcTsConfig {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function setGlobalConfig(config: Oid4vcTsConfig): void;
|
|
17
17
|
export declare function getGlobalConfig(): Oid4vcTsConfig;
|
|
18
|
+
export declare function addSecondsToDate(date: Date, seconds: number): Date;
|
|
18
19
|
declare const _URL: {
|
|
19
20
|
new (url: string | URL, base?: string | URL): URL;
|
|
20
21
|
prototype: URL;
|
|
@@ -32,18 +33,6 @@ type FetchResponse = Response;
|
|
|
32
33
|
declare const _Headers: typeof globalThis.Headers;
|
|
33
34
|
type FetchHeaders = globalThis.Headers;
|
|
34
35
|
type FetchRequestInit = RequestInit;
|
|
35
|
-
export declare enum ContentType {
|
|
36
|
-
XWwwFormUrlencoded = "application/x-www-form-urlencoded",
|
|
37
|
-
Json = "application/json",
|
|
38
|
-
JwkSet = "application/jwk-set+json",
|
|
39
|
-
OauthAuthorizationRequestJwt = "application/oauth-authz-req+jwt",
|
|
40
|
-
Jwt = "application/jwt",
|
|
41
|
-
Html = "text/html"
|
|
42
|
-
}
|
|
43
|
-
/** Whether `value` has the media type `contentType`, ignoring casing and parameters */
|
|
44
|
-
export declare function isContentType(contentType: ContentType, value: string): boolean;
|
|
45
|
-
export declare function isResponseContentType(contentType: ContentType | ContentType[], response: FetchResponse): boolean;
|
|
46
|
-
export declare function addSecondsToDate(date: Date, seconds: number): Date;
|
|
47
36
|
/**
|
|
48
37
|
* Base error class for `@openid4vc/utils`, on the shared `IdentityError` base.
|
|
49
38
|
*
|
|
@@ -64,7 +53,7 @@ export declare class JsonParseError extends Openid4vcBaseError {
|
|
|
64
53
|
* A type utility which represents the function returned
|
|
65
54
|
* from createZodFetcher
|
|
66
55
|
*/
|
|
67
|
-
type ZodFetcher = <Schema extends z.ZodTypeAny>(schema: Schema, expectedContentType:
|
|
56
|
+
type ZodFetcher = <Schema extends z.ZodTypeAny>(schema: Schema, expectedContentType: string | string[], ...args: Parameters<Fetch>) => Promise<{
|
|
68
57
|
response: Awaited<ReturnType<Fetch>>;
|
|
69
58
|
result?: SchemaParseResult<z.infer<Schema>>;
|
|
70
59
|
}>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IdentityError, addValidationIssue, createAcceptHeader, isMediaType, parseWithSchema } from "@owf/identity-common";
|
|
1
|
+
import { CommonMediaTypes, IdentityError, addValidationIssue, createAcceptHeader, isMediaType, parseWithSchema } from "@owf/identity-common";
|
|
2
2
|
import z from "zod";
|
|
3
3
|
// src/array.ts
|
|
4
4
|
/**
|
|
@@ -18,24 +18,6 @@ function setGlobalConfig(config) {
|
|
|
18
18
|
function getGlobalConfig() {
|
|
19
19
|
return GLOBAL_CONFIG;
|
|
20
20
|
}
|
|
21
|
-
// src/content-type.ts
|
|
22
|
-
let ContentType = /* @__PURE__ */ function(ContentType) {
|
|
23
|
-
ContentType["XWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
|
|
24
|
-
ContentType["Json"] = "application/json";
|
|
25
|
-
ContentType["JwkSet"] = "application/jwk-set+json";
|
|
26
|
-
ContentType["OauthAuthorizationRequestJwt"] = "application/oauth-authz-req+jwt";
|
|
27
|
-
ContentType["Jwt"] = "application/jwt";
|
|
28
|
-
ContentType["Html"] = "text/html";
|
|
29
|
-
return ContentType;
|
|
30
|
-
}({});
|
|
31
|
-
/** Whether `value` has the media type `contentType`, ignoring casing and parameters */
|
|
32
|
-
function isContentType(contentType, value) {
|
|
33
|
-
return isMediaType(value, contentType);
|
|
34
|
-
}
|
|
35
|
-
function isResponseContentType(contentType, response) {
|
|
36
|
-
const contentTypeArray = Array.isArray(contentType) ? contentType : [contentType];
|
|
37
|
-
return isMediaType(response.headers.get("Content-Type"), contentTypeArray);
|
|
38
|
-
}
|
|
39
21
|
// src/date.ts
|
|
40
22
|
function addSecondsToDate(date, seconds) {
|
|
41
23
|
return new Date(date.getTime() + seconds * 1e3);
|
|
@@ -52,7 +34,7 @@ var Openid4vcBaseError = class extends IdentityError {};
|
|
|
52
34
|
// src/error/InvalidFetchResponseError.ts
|
|
53
35
|
var InvalidFetchResponseError = class extends Openid4vcBaseError {
|
|
54
36
|
constructor(message, textResponse, response) {
|
|
55
|
-
const textResponseMessage =
|
|
37
|
+
const textResponseMessage = isMediaType(response.headers.get("Content-Type"), CommonMediaTypes.Html) ? void 0 : textResponse.substring(0, 1e3);
|
|
56
38
|
super(textResponseMessage ? `${message}\n${textResponseMessage}` : message);
|
|
57
39
|
this.textResponse = textResponse;
|
|
58
40
|
this.response = response.clone();
|
|
@@ -121,8 +103,8 @@ function createZodFetcher(fetcher) {
|
|
|
121
103
|
...init,
|
|
122
104
|
headers
|
|
123
105
|
});
|
|
124
|
-
if (response.ok && !
|
|
125
|
-
if (
|
|
106
|
+
if (response.ok && !isMediaType(response.headers.get("Content-Type"), expectedContentTypeArray)) throw new InvalidFetchResponseError(`Expected response to match content type ${expectedContentTypeArray.join(" | ")}, but received '${response.headers.get("Content-Type")}'`, await response.clone().text(), response);
|
|
107
|
+
if (isMediaType(response.headers.get("Content-Type"), CommonMediaTypes.Jwt)) return {
|
|
126
108
|
response,
|
|
127
109
|
result: response.ok ? parseWithSchema(schema, await response.text()) : void 0
|
|
128
110
|
};
|
|
@@ -323,6 +305,6 @@ function encodeWwwAuthenticateHeader(challenges) {
|
|
|
323
305
|
}
|
|
324
306
|
return entries.join(", ");
|
|
325
307
|
}
|
|
326
|
-
export {
|
|
308
|
+
export { _Headers as Headers, InvalidFetchResponseError, JsonParseError, Openid4vcBaseError, _URL as URL, _URLSearchParams as URLSearchParams, addSecondsToDate, arrayEqualsIgnoreOrder, createFetcher, createZodFetcher, encodeWwwAuthenticateHeader, getGlobalConfig, getQueryParams, isObject, joinUriParts, mergeDeep, objectToQueryParams, parseIfJson, parseWwwAuthenticateHeader, setGlobalConfig, stringToJsonWithErrorHandling, zDataUrl, zHttpMethod, zHttpsUrl, zInteger, zIs, zStringToJson };
|
|
327
309
|
|
|
328
310
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["URLSearchParams","Headers","URL","URLSearchParams"],"sources":["../src/array.ts","../src/config.ts","../src/content-type.ts","../src/date.ts","../src/error/Openid4vcBaseError.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/error/FetchError.ts","../src/globals.ts","../src/fetcher.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","import { isMediaType } from '@owf/identity-common'\nimport type { FetchResponse } from './globals'\n\nexport enum ContentType {\n XWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n Json = 'application/json',\n JwkSet = 'application/jwk-set+json',\n OauthAuthorizationRequestJwt = 'application/oauth-authz-req+jwt',\n Jwt = 'application/jwt',\n Html = 'text/html',\n}\n\n/** Whether `value` has the media type `contentType`, ignoring casing and parameters */\nexport function isContentType(contentType: ContentType, value: string) {\n return isMediaType(value, contentType)\n}\n\nexport function isResponseContentType(contentType: ContentType | ContentType[], response: FetchResponse) {\n const contentTypeArray = Array.isArray(contentType) ? contentType : [contentType]\n\n return isMediaType(response.headers.get('Content-Type'), contentTypeArray)\n}\n","export function addSecondsToDate(date: Date, seconds: number) {\n return new Date(date.getTime() + seconds * 1000)\n}\n","import { IdentityError } from '@owf/identity-common'\n\n/**\n * Base error class for `@openid4vc/utils`, on the shared `IdentityError` base.\n *\n * A value that does not validate is reported with the `ValidationError` of `@owf/identity-common`,\n * which is an `IdentityError` but not an `Openid4vcBaseError`: catch `IdentityError` to\n * handle both.\n */\nexport abstract class Openid4vcBaseError extends IdentityError {}\n","import { ContentType, isResponseContentType } from '../content-type'\nimport type { FetchResponse } from '../globals'\nimport { Openid4vcBaseError } from './Openid4vcBaseError'\n\nexport class InvalidFetchResponseError extends Openid4vcBaseError {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n // We don't want to put html content in pages. For other content we take the first 1000 characters\n // to prevent ridiculously long errors.\n const textResponseMessage = isResponseContentType(ContentType.Html, response)\n ? undefined\n : textResponse.substring(0, 1000)\n\n super(textResponseMessage ? `${message}\\n${textResponseMessage}` : message)\n\n this.response = response.clone()\n }\n}\n","import { Openid4vcBaseError } from './Openid4vcBaseError'\n\nexport class JsonParseError extends Openid4vcBaseError {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import { Openid4vcBaseError } from './Openid4vcBaseError'\n\nexport class FetchError extends Openid4vcBaseError {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _Headers as Headers, _URL as URL, _URLSearchParams as URLSearchParams }\n","import { createAcceptHeader, parseWithSchema, type SchemaParseResult } from '@owf/identity-common'\nimport type z from 'zod'\nimport { ContentType, isResponseContentType } from './content-type'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, Headers, URLSearchParams } from './globals'\n\n/**\n * A type utility which represents the function returned\n * from createZodFetcher\n */\nexport type ZodFetcher = <Schema extends z.ZodTypeAny>(\n schema: Schema,\n expectedContentType: ContentType | ContentType[],\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: SchemaParseResult<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. The expected content types are sent as the\n * `Accept` header, unless the request already has one. The\n * order of the expected content types is the order of preference,\n * expressed with decreasing `q` values.\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, input, init) => {\n const expectedContentTypeArray = Array.isArray(expectedContentType) ? expectedContentType : [expectedContentType]\n\n // Ask for the expected content types in order of preference, unless the caller already set an Accept header\n const headers = new Headers(init?.headers)\n if (!headers.has('Accept')) {\n headers.set('Accept', createAcceptHeader(expectedContentTypeArray))\n }\n\n const response = await createFetcher(fetcher)(input, { ...init, headers })\n\n if (response.ok && !isResponseContentType(expectedContentTypeArray, response)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type ${expectedContentTypeArray.join(' | ')}, but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n if (isResponseContentType([ContentType.OauthAuthorizationRequestJwt, ContentType.Jwt], response)) {\n return {\n response,\n result: response.ok ? parseWithSchema(schema, await response.text()) : undefined,\n }\n }\n\n return {\n response,\n result: response.ok ? parseWithSchema(schema, await response.json()) : undefined,\n }\n }\n}\n","export function isObject(item: unknown): item is Record<string, unknown> {\n return item != null && typeof item === 'object' && !Array.isArray(item)\n}\n\n/**\n * Deep merge two objects.\n * @param target\n * @param ...sources\n */\nexport function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown {\n if (!sources.length) return target\n const source = sources.shift()\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} })\n mergeDeep(target[key], source[key])\n } else {\n Object.assign(target, { [key]: source[key] })\n }\n }\n }\n\n return mergeDeep(target, ...sources)\n}\n","import type z from 'zod'\nimport { JsonParseError } from './error/JsonParseError'\n\n// biome-ignore lint/suspicious/noExplicitAny: no explanation\nexport type InferOutputUnion<T extends readonly any[]> = {\n [K in keyof T]: z.infer<T[K]>\n}[number]\n\nexport function stringToJsonWithErrorHandling(string: string, errorMessage?: string) {\n try {\n return JSON.parse(string)\n } catch (_error) {\n throw new JsonParseError(errorMessage ?? 'Unable to parse string to JSON.', string)\n }\n}\n\nexport function parseIfJson<T>(data: T): T | Record<string, unknown> {\n if (typeof data !== 'string') {\n return data\n }\n\n try {\n // Try to parse the string as JSON\n return JSON.parse(data)\n } catch (_error) {}\n\n return data\n}\n","/**\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 { addValidationIssue } from '@owf/identity-common'\nimport z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z.url().superRefine((url, ctx) => {\n const { allowInsecureUrls } = getGlobalConfig()\n // the scheme is case-insensitive (RFC 3986 §3.1)\n if (allowInsecureUrls ? /^https?:\\/\\//i.test(url) : /^https:\\/\\//i.test(url)) return\n addValidationIssue(ctx, {\n code: 'invalid_format',\n message: 'url must be an https:// url',\n context: { format: 'https_url' },\n })\n})\n\nexport const zDataUrl = z.string().regex(/data:[\\w/\\-.]+(\\+[\\w/\\-.]+)?;\\w+,.*/, 'url must be a data URL')\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 addValidationIssue(ctx, {\n code: 'invalid_format',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n context: { format: '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","// A backslash escapes the character after it in a quoted string (RFC 9110 §5.6.4), not only a quote\nconst unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\(.)/g, '$1')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: no explanation\n /((?:[a-zA-Z0-9._~+/-]+=*(?:\\s+|$))|[^\\u0000-\\u001F\\u007F()<>@,;:\\\\\"/?={}[\\]\\u0020\\u0009]+)(?:=([^\\\\\"=\\s,]+|\"(?:[^\"\\\\]|\\\\.)*\"))?/g\n\nexport interface WwwAuthenticateHeaderChallenge {\n scheme: string\n\n /**\n * Record where the keys are the names, and the value can be 0 (null), 1 (string) or multiple (string[])\n * entries. Entries with an `undefined` value are omitted when encoding.\n */\n payload: Record<string, string | string[] | null | undefined>\n}\n\nconst parsePayload = (scheme: string, string: string): WwwAuthenticateHeaderChallenge => {\n const payload: Record<string, string | string[] | null> = {}\n\n while (true) {\n const res = body.exec(string)\n if (!res) break\n\n const [, key, newValue] = res\n\n const payloadValue = payload[key]\n if (newValue) {\n const sanitizedValue = sanitize(newValue)\n payload[key] = payloadValue\n ? Array.isArray(payloadValue)\n ? [...payloadValue, sanitizedValue]\n : [payloadValue, sanitizedValue]\n : sanitizedValue\n } else if (!payloadValue) {\n payload[key] = null\n }\n }\n\n return { scheme, payload }\n}\n\nexport function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[] {\n const start = str.indexOf(' ')\n let scheme = str.substring(0, start)\n let value = str.substring(start)\n\n const challenges: WwwAuthenticateHeaderChallenge[] = []\n\n // Some well-known schemes to support-multi parsing\n const endsWithSchemeRegex = /, ?(Bearer|DPoP|Basic)$/\n const endsWithSchemeTest = endsWithSchemeRegex.exec(value)\n let endsWithScheme: string | undefined\n if (endsWithSchemeTest) {\n value = value.substring(0, value.length - endsWithSchemeTest[0].length)\n endsWithScheme = endsWithSchemeTest[1]\n }\n\n const additionalSchemesRegex = /(.*?)(, ?)(Bearer|DPoP|Basic)[, ]/\n let match = additionalSchemesRegex.exec(value)\n while (match) {\n challenges.push(parsePayload(scheme, match[1]))\n value = value.substring(match[0].length - 1)\n scheme = match[3]\n\n match = additionalSchemesRegex.exec(value)\n }\n challenges.push(parsePayload(scheme, value))\n if (endsWithScheme) {\n challenges.push({ scheme: endsWithScheme, payload: {} })\n }\n return challenges\n}\n\n/**\n * Replaces every run of characters outside visible ASCII and space with a single space.\n *\n * A value is often an error message, which can hold line breaks and input from whoever sent the\n * request. A CR or LF would end the header there, and `Headers.set` rejects it as well as any\n * character above U+00FF. RFC 6750 §3 limits `error_description` to a subset of the characters\n * that are kept in any case.\n */\nconst toHeaderText = (value: string) => value.replace(/[^\\x20-\\x7E]+/g, ' ')\n\n/**\n * `error_description` is meant for a developer reading it, and is mostly filled from an error\n * message, so it is cut off rather than letting the message decide how large the header gets.\n */\nconst MAX_ERROR_DESCRIPTION_LENGTH = 500\n\n/**\n * Encodes challenges as the value of a `WWW-Authenticate` header.\n *\n * The result is always a value a header can carry, whatever the challenges hold: every run of\n * characters outside visible ASCII and space is replaced with a single space, and an\n * `error_description` longer than 500 characters is cut off.\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 if (value === undefined) return []\n\n const name = toHeaderText(key)\n const encode = (s: string) => {\n let text = toHeaderText(s)\n if (key === 'error_description' && text.length > MAX_ERROR_DESCRIPTION_LENGTH) {\n text = `${text.slice(0, MAX_ERROR_DESCRIPTION_LENGTH - 3)}...`\n }\n\n // Escaped last, so that cutting off cannot split an escape\n return text.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => `${name}=\"${encode(v)}\"`)\n }\n\n return value ? `${name}=\"${encode(value)}\"` : name\n })\n\n const scheme = toHeaderText(challenge.scheme)\n entries.push(encodedParams.length === 0 ? scheme : `${scheme} ${encodedParams.join(', ')}`)\n }\n\n return entries.join(', ')\n}\n"],"mappings":";;;;;;;AAIA,SAAgB,uBACd,GACA,GACS;CACT,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO;CAChD,IAAI,EAAE,WAAW,EAAE,QAAQ,OAAO;CAElC,OAAO,EAAE,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC;AACrC;;ACHA,IAAI,gBAAgC,EAClC,mBAAmB,MACrB;AAEA,SAAgB,gBAAgB,QAAwB;CACtD,gBAAgB;AAClB;AAEA,SAAgB,kBAAkC;CAChD,OAAO;AACT;;AChBA,IAAY,cAAL,yBAAA,aAAA;CACL,YAAA,wBAAA;CACA,YAAA,UAAA;CACA,YAAA,YAAA;CACA,YAAA,kCAAA;CACA,YA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zD,OAAO;AACT;;;;;;;;;AAUA,MAAM,gBAAgB,UAAkB,MAAM,QAAQ,kBAAkB,GAAG;;;;;AAM3E,MAAM,+BAA+B;;;;;;;;AASrC,SAAgB,4BAA4B,YAA8C;CACxF,MAAM,UAAoB,CAAC;CAE3B,KAAK,MAAM,aAAa,YAAY;EAElC,MAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;GAChF,IAAI,UAAU,KAAA,GAAW,OAAO,CAAC;GAEjC,MAAM,OAAO,aAAa,GAAG;GAC7B,MAAM,UAAU,MAAc;IAC5B,IAAI,OAAO,aAAa,CAAC;IACzB,IAAI,QAAQ,uBAAuB,KAAK,SAAS,8BAC/C,OAAO,GAAG,KAAK,MAAM,GAAG,GAAgC,EAAE;IAI5D,OAAO,KAAK,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK;GACxD;GAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,MAAM,GAAG,KAAK,IAAI,OAAO,CAAC,EAAE,EAAE;GAGlD,OAAO,QAAQ,GAAG,KAAK,IAAI,OAAO,KAAK,EAAE,KAAK;EAChD,CAAC;EAED,MAAM,SAAS,aAAa,UAAU,MAAM;EAC5C,QAAQ,KAAK,cAAc,WAAW,IAAI,SAAS,GAAG,OAAO,GAAG,cAAc,KAAK,IAAI,GAAG;CAC5F;CAEA,OAAO,QAAQ,KAAK,IAAI;AAC1B"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["URLSearchParams","Headers","URL","URLSearchParams"],"sources":["../src/array.ts","../src/config.ts","../src/date.ts","../src/error/Openid4vcBaseError.ts","../src/error/InvalidFetchResponseError.ts","../src/error/JsonParseError.ts","../src/error/FetchError.ts","../src/globals.ts","../src/fetcher.ts","../src/object.ts","../src/parse.ts","../src/path.ts","../src/url.ts","../src/validation.ts","../src/www-authenticate.ts"],"sourcesContent":["/**\n * Only primitive types allowed\n * Must have not duplicate entries (will always return false in this case)\n */\nexport function arrayEqualsIgnoreOrder<Item extends string | number | boolean>(\n a: Array<Item>,\n b: Array<Item>\n): boolean {\n if (new Set(a).size !== new Set(b).size) return false\n if (a.length !== b.length) return false\n\n return a.every((k) => b.includes(k))\n}\n","export interface Oid4vcTsConfig {\n /**\n * Whether to allow insecure http urls.\n *\n * @default false\n */\n allowInsecureUrls: boolean\n}\n\nlet GLOBAL_CONFIG: Oid4vcTsConfig = {\n allowInsecureUrls: false,\n}\n\nexport function setGlobalConfig(config: Oid4vcTsConfig) {\n GLOBAL_CONFIG = config\n}\n\nexport function getGlobalConfig(): Oid4vcTsConfig {\n return GLOBAL_CONFIG\n}\n","export function addSecondsToDate(date: Date, seconds: number) {\n return new Date(date.getTime() + seconds * 1000)\n}\n","import { IdentityError } from '@owf/identity-common'\n\n/**\n * Base error class for `@openid4vc/utils`, on the shared `IdentityError` base.\n *\n * A value that does not validate is reported with the `ValidationError` of `@owf/identity-common`,\n * which is an `IdentityError` but not an `Openid4vcBaseError`: catch `IdentityError` to\n * handle both.\n */\nexport abstract class Openid4vcBaseError extends IdentityError {}\n","import { CommonMediaTypes, isMediaType } from '@owf/identity-common'\nimport type { FetchResponse } from '../globals'\nimport { Openid4vcBaseError } from './Openid4vcBaseError'\n\nexport class InvalidFetchResponseError extends Openid4vcBaseError {\n public readonly response: FetchResponse\n\n public constructor(\n message: string,\n public readonly textResponse: string,\n response: FetchResponse\n ) {\n // We don't want to put html content in pages. For other content we take the first 1000 characters\n // to prevent ridiculously long errors.\n const textResponseMessage = isMediaType(response.headers.get('Content-Type'), CommonMediaTypes.Html)\n ? undefined\n : textResponse.substring(0, 1000)\n\n super(textResponseMessage ? `${message}\\n${textResponseMessage}` : message)\n\n this.response = response.clone()\n }\n}\n","import { Openid4vcBaseError } from './Openid4vcBaseError'\n\nexport class JsonParseError extends Openid4vcBaseError {\n public constructor(message: string, jsonString: string) {\n super(`${message}\\n${jsonString}`)\n }\n}\n","import { Openid4vcBaseError } from './Openid4vcBaseError'\n\nexport class FetchError extends Openid4vcBaseError {\n public readonly cause?: Error\n\n public constructor(message: string, { cause }: { cause?: Error } = {}) {\n super(`${message}\\nCause: ${cause?.message}`)\n this.cause = cause\n }\n}\n","// Theses types are provided by the platform (so @types/node, @types/react-native, DOM)\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URL = URL\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _URLSearchParams = URLSearchParams\n\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type Fetch = typeof fetch\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nexport type FetchResponse = Response\n// biome-ignore lint/style/noRestrictedGlobals: no explanation\nconst _Headers = Headers as typeof globalThis.Headers\nexport type FetchHeaders = globalThis.Headers\nexport type FetchRequestInit = RequestInit\n\nexport { _Headers as Headers, _URL as URL, _URLSearchParams as URLSearchParams }\n","import {\n CommonMediaTypes,\n createAcceptHeader,\n isMediaType,\n parseWithSchema,\n type SchemaParseResult,\n} from '@owf/identity-common'\nimport type z from 'zod'\nimport { FetchError } from './error/FetchError'\nimport { InvalidFetchResponseError } from './error/InvalidFetchResponseError'\nimport { type Fetch, Headers, 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: string | string[],\n ...args: Parameters<Fetch>\n) => Promise<{ response: Awaited<ReturnType<Fetch>>; result?: SchemaParseResult<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. The expected content types are sent as the\n * `Accept` header, unless the request already has one. The\n * order of the expected content types is the order of preference,\n * expressed with decreasing `q` values.\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, input, init) => {\n const expectedContentTypeArray = Array.isArray(expectedContentType) ? expectedContentType : [expectedContentType]\n\n // Ask for the expected content types in order of preference, unless the caller already set an Accept header\n const headers = new Headers(init?.headers)\n if (!headers.has('Accept')) {\n headers.set('Accept', createAcceptHeader(expectedContentTypeArray))\n }\n\n const response = await createFetcher(fetcher)(input, { ...init, headers })\n\n if (response.ok && !isMediaType(response.headers.get('Content-Type'), expectedContentTypeArray)) {\n throw new InvalidFetchResponseError(\n `Expected response to match content type ${expectedContentTypeArray.join(' | ')}, but received '${response.headers.get('Content-Type')}'`,\n await response.clone().text(),\n response\n )\n }\n\n // A compact JWT is text, not JSON (RFC 7519 Section 1)\n if (isMediaType(response.headers.get('Content-Type'), CommonMediaTypes.Jwt)) {\n return {\n response,\n result: response.ok ? parseWithSchema(schema, await response.text()) : undefined,\n }\n }\n\n return {\n response,\n result: response.ok ? parseWithSchema(schema, await response.json()) : undefined,\n }\n }\n}\n","export function isObject(item: unknown): item is Record<string, unknown> {\n return item != null && typeof item === 'object' && !Array.isArray(item)\n}\n\n/**\n * Deep merge two objects.\n * @param target\n * @param ...sources\n */\nexport function mergeDeep(target: unknown, ...sources: Array<unknown>): unknown {\n if (!sources.length) return target\n const source = sources.shift()\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} })\n mergeDeep(target[key], source[key])\n } else {\n Object.assign(target, { [key]: source[key] })\n }\n }\n }\n\n return mergeDeep(target, ...sources)\n}\n","import type z from 'zod'\nimport { JsonParseError } from './error/JsonParseError'\n\n// biome-ignore lint/suspicious/noExplicitAny: no explanation\nexport type InferOutputUnion<T extends readonly any[]> = {\n [K in keyof T]: z.infer<T[K]>\n}[number]\n\nexport function stringToJsonWithErrorHandling(string: string, errorMessage?: string) {\n try {\n return JSON.parse(string)\n } catch (_error) {\n throw new JsonParseError(errorMessage ?? 'Unable to parse string to JSON.', string)\n }\n}\n\nexport function parseIfJson<T>(data: T): T | Record<string, unknown> {\n if (typeof data !== 'string') {\n return data\n }\n\n try {\n // Try to parse the string as JSON\n return JSON.parse(data)\n } catch (_error) {}\n\n return data\n}\n","/**\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 { addValidationIssue } from '@owf/identity-common'\nimport z from 'zod'\nimport { getGlobalConfig } from './config'\n\nexport const zHttpsUrl = z.url().superRefine((url, ctx) => {\n const { allowInsecureUrls } = getGlobalConfig()\n // the scheme is case-insensitive (RFC 3986 §3.1)\n if (allowInsecureUrls ? /^https?:\\/\\//i.test(url) : /^https:\\/\\//i.test(url)) return\n addValidationIssue(ctx, {\n code: 'invalid_format',\n message: 'url must be an https:// url',\n context: { format: 'https_url' },\n })\n})\n\nexport const zDataUrl = z.string().regex(/data:[\\w/\\-.]+(\\+[\\w/\\-.]+)?;\\w+,.*/, 'url must be a data URL')\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 addValidationIssue(ctx, {\n code: 'invalid_format',\n message: 'Expected a JSON string, but could not parse the string to JSON',\n context: { format: '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","// A backslash escapes the character after it in a quoted string (RFC 9110 §5.6.4), not only a quote\nconst unquote = (value: string) => value.substring(1, value.length - 1).replace(/\\\\(.)/g, '$1')\n// Fixup quoted strings and tokens with spaces around them\nconst sanitize = (value: string) => (value.charAt(0) === '\"' ? unquote(value) : value.trim())\n\n// lol dis\nconst body =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: no explanation\n /((?:[a-zA-Z0-9._~+/-]+=*(?:\\s+|$))|[^\\u0000-\\u001F\\u007F()<>@,;:\\\\\"/?={}[\\]\\u0020\\u0009]+)(?:=([^\\\\\"=\\s,]+|\"(?:[^\"\\\\]|\\\\.)*\"))?/g\n\nexport interface WwwAuthenticateHeaderChallenge {\n scheme: string\n\n /**\n * Record where the keys are the names, and the value can be 0 (null), 1 (string) or multiple (string[])\n * entries. Entries with an `undefined` value are omitted when encoding.\n */\n payload: Record<string, string | string[] | null | undefined>\n}\n\nconst parsePayload = (scheme: string, string: string): WwwAuthenticateHeaderChallenge => {\n const payload: Record<string, string | string[] | null> = {}\n\n while (true) {\n const res = body.exec(string)\n if (!res) break\n\n const [, key, newValue] = res\n\n const payloadValue = payload[key]\n if (newValue) {\n const sanitizedValue = sanitize(newValue)\n payload[key] = payloadValue\n ? Array.isArray(payloadValue)\n ? [...payloadValue, sanitizedValue]\n : [payloadValue, sanitizedValue]\n : sanitizedValue\n } else if (!payloadValue) {\n payload[key] = null\n }\n }\n\n return { scheme, payload }\n}\n\nexport function parseWwwAuthenticateHeader(str: string): WwwAuthenticateHeaderChallenge[] {\n const start = str.indexOf(' ')\n let scheme = str.substring(0, start)\n let value = str.substring(start)\n\n const challenges: WwwAuthenticateHeaderChallenge[] = []\n\n // Some well-known schemes to support-multi parsing\n const endsWithSchemeRegex = /, ?(Bearer|DPoP|Basic)$/\n const endsWithSchemeTest = endsWithSchemeRegex.exec(value)\n let endsWithScheme: string | undefined\n if (endsWithSchemeTest) {\n value = value.substring(0, value.length - endsWithSchemeTest[0].length)\n endsWithScheme = endsWithSchemeTest[1]\n }\n\n const additionalSchemesRegex = /(.*?)(, ?)(Bearer|DPoP|Basic)[, ]/\n let match = additionalSchemesRegex.exec(value)\n while (match) {\n challenges.push(parsePayload(scheme, match[1]))\n value = value.substring(match[0].length - 1)\n scheme = match[3]\n\n match = additionalSchemesRegex.exec(value)\n }\n challenges.push(parsePayload(scheme, value))\n if (endsWithScheme) {\n challenges.push({ scheme: endsWithScheme, payload: {} })\n }\n return challenges\n}\n\n/**\n * Replaces every run of characters outside visible ASCII and space with a single space.\n *\n * A value is often an error message, which can hold line breaks and input from whoever sent the\n * request. A CR or LF would end the header there, and `Headers.set` rejects it as well as any\n * character above U+00FF. RFC 6750 §3 limits `error_description` to a subset of the characters\n * that are kept in any case.\n */\nconst toHeaderText = (value: string) => value.replace(/[^\\x20-\\x7E]+/g, ' ')\n\n/**\n * `error_description` is meant for a developer reading it, and is mostly filled from an error\n * message, so it is cut off rather than letting the message decide how large the header gets.\n */\nconst MAX_ERROR_DESCRIPTION_LENGTH = 500\n\n/**\n * Encodes challenges as the value of a `WWW-Authenticate` header.\n *\n * The result is always a value a header can carry, whatever the challenges hold: every run of\n * characters outside visible ASCII and space is replaced with a single space, and an\n * `error_description` longer than 500 characters is cut off.\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 if (value === undefined) return []\n\n const name = toHeaderText(key)\n const encode = (s: string) => {\n let text = toHeaderText(s)\n if (key === 'error_description' && text.length > MAX_ERROR_DESCRIPTION_LENGTH) {\n text = `${text.slice(0, MAX_ERROR_DESCRIPTION_LENGTH - 3)}...`\n }\n\n // Escaped last, so that cutting off cannot split an escape\n return text.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => `${name}=\"${encode(v)}\"`)\n }\n\n return value ? `${name}=\"${encode(value)}\"` : name\n })\n\n const scheme = toHeaderText(challenge.scheme)\n entries.push(encodedParams.length === 0 ? scheme : `${scheme} ${encodedParams.join(', ')}`)\n }\n\n return entries.join(', ')\n}\n"],"mappings":";;;;;;;AAIA,SAAgB,uBACd,GACA,GACS;CACT,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO;CAChD,IAAI,EAAE,WAAW,EAAE,QAAQ,OAAO;CAElC,OAAO,EAAE,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC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3E,MAAM,+BAA+B;;;;;;;;AASrC,SAAgB,4BAA4B,YAA8C;CACxF,MAAM,UAAoB,CAAC;CAE3B,KAAK,MAAM,aAAa,YAAY;EAElC,MAAM,gBAAgB,OAAO,QAAQ,UAAU,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;GAChF,IAAI,UAAU,KAAA,GAAW,OAAO,CAAC;GAEjC,MAAM,OAAO,aAAa,GAAG;GAC7B,MAAM,UAAU,MAAc;IAC5B,IAAI,OAAO,aAAa,CAAC;IACzB,IAAI,QAAQ,uBAAuB,KAAK,SAAS,8BAC/C,OAAO,GAAG,KAAK,MAAM,GAAG,GAAgC,EAAE;IAI5D,OAAO,KAAK,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK;GACxD;GAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,MAAM,GAAG,KAAK,IAAI,OAAO,CAAC,EAAE,EAAE;GAGlD,OAAO,QAAQ,GAAG,KAAK,IAAI,OAAO,KAAK,EAAE,KAAK;EAChD,CAAC;EAED,MAAM,SAAS,aAAa,UAAU,MAAM;EAC5C,QAAQ,KAAK,cAAc,WAAW,IAAI,SAAS,GAAG,OAAO,GAAG,cAAc,KAAK,IAAI,GAAG;CAC5F;CAEA,OAAO,QAAQ,KAAK,IAAI;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openid4vc/utils",
|
|
3
|
-
"version": "0.10.0-alpha-
|
|
3
|
+
"version": "0.10.0-alpha-20261103225859",
|
|
4
4
|
"description": "Shared utilities for the @openid4vc packages",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^4.6.7",
|
|
31
|
-
"@owf/identity-common": "^0.8.0-alpha-
|
|
31
|
+
"@owf/identity-common": "^0.8.0-alpha-20261103225859"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsdown src/index.ts --format esm --dts --sourcemap"
|