@schemavaults/auth-common 0.31.0 → 0.33.0

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.
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Size limits of a client error report. The client SDK truncates its
4
+ * reports to fit them; the auth server refuses a report that exceeds any of
5
+ * them (400) and any request body over `max_body_bytes` (413).
6
+ */
7
+ export declare const CLIENT_ERROR_REPORT_LIMITS: {
8
+ readonly name: 200;
9
+ readonly message: 2000;
10
+ readonly stack: 16000;
11
+ readonly operation: 200;
12
+ readonly sdk_name: 100;
13
+ readonly sdk_version: 64;
14
+ readonly page_url: 2048;
15
+ /** Length of `JSON.stringify(context)`. */
16
+ readonly context_json: 8192;
17
+ /** Request body size accepted by `POST /api/client-errors/{client_app_id}`. */
18
+ readonly max_body_bytes: number;
19
+ };
20
+ /**
21
+ * One error a client (the auth client SDK, or an app through
22
+ * `SchemaVaultsAuthClient.reportError()`) sends to
23
+ * `POST /api/client-errors/{client_app_id}`. The client app is the path
24
+ * parameter; the server records the `Origin`, `User-Agent` and receive
25
+ * time itself. Unknown members are ignored.
26
+ */
27
+ export declare const clientErrorReportSchema: z.ZodObject<{
28
+ name: z.ZodString;
29
+ message: z.ZodString;
30
+ stack: z.ZodOptional<z.ZodString>;
31
+ operation: z.ZodOptional<z.ZodString>;
32
+ occurred_at: z.ZodOptional<z.ZodNumber>;
33
+ sdk_name: z.ZodOptional<z.ZodString>;
34
+ sdk_version: z.ZodOptional<z.ZodString>;
35
+ app_env: z.ZodOptional<z.ZodEnum<{
36
+ development: "development";
37
+ staging: "staging";
38
+ test: "test";
39
+ production: "production";
40
+ }>>;
41
+ page_url: z.ZodOptional<z.ZodString>;
42
+ reported_uid: z.ZodOptional<z.ZodGUID>;
43
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
44
+ }, z.core.$strip>;
45
+ export type ClientErrorReport = z.infer<typeof clientErrorReportSchema>;
@@ -0,0 +1,93 @@
1
+ import { z } from "zod";
2
+ import { schemaVaultsAppEnvironmentSchema } from "@schemavaults/app-definitions";
3
+ /**
4
+ * Size limits of a client error report. The client SDK truncates its
5
+ * reports to fit them; the auth server refuses a report that exceeds any of
6
+ * them (400) and any request body over `max_body_bytes` (413).
7
+ */
8
+ export const CLIENT_ERROR_REPORT_LIMITS = {
9
+ name: 200,
10
+ message: 2_000,
11
+ stack: 16_000,
12
+ operation: 200,
13
+ sdk_name: 100,
14
+ sdk_version: 64,
15
+ page_url: 2_048,
16
+ /** Length of `JSON.stringify(context)`. */
17
+ context_json: 8_192,
18
+ /** Request body size accepted by `POST /api/client-errors/{client_app_id}`. */
19
+ max_body_bytes: 64 * 1024,
20
+ };
21
+ /**
22
+ * Whether `JSON.stringify(value)` fits in `max_length` characters. A value
23
+ * that cannot be serialized (cycles, BigInt) does not fit.
24
+ */
25
+ function fitsAsJson(value, max_length) {
26
+ try {
27
+ const serialized = JSON.stringify(value);
28
+ return typeof serialized === "string" && serialized.length <= max_length;
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ }
34
+ const L = CLIENT_ERROR_REPORT_LIMITS;
35
+ /**
36
+ * One error a client (the auth client SDK, or an app through
37
+ * `SchemaVaultsAuthClient.reportError()`) sends to
38
+ * `POST /api/client-errors/{client_app_id}`. The client app is the path
39
+ * parameter; the server records the `Origin`, `User-Agent` and receive
40
+ * time itself. Unknown members are ignored.
41
+ */
42
+ export const clientErrorReportSchema = z.object({
43
+ name: z
44
+ .string()
45
+ .min(1)
46
+ .max(L.name)
47
+ .describe("The error's class name (`Error`, `TypeError`, ...)."),
48
+ message: z.string().max(L.message).describe("The error message."),
49
+ stack: z
50
+ .string()
51
+ .max(L.stack)
52
+ .optional()
53
+ .describe("Stack trace, with the `cause` chain appended as `Caused by:` sections."),
54
+ operation: z
55
+ .string()
56
+ .min(1)
57
+ .max(L.operation)
58
+ .optional()
59
+ .describe("What the client was doing, e.g. the SDK method (`acquireAccessToken`)."),
60
+ occurred_at: z
61
+ .number()
62
+ .int()
63
+ .nonnegative()
64
+ .optional()
65
+ .describe("When the error happened on the client (Unix epoch milliseconds)."),
66
+ sdk_name: z
67
+ .string()
68
+ .min(1)
69
+ .max(L.sdk_name)
70
+ .optional()
71
+ .describe("Package that sent the report, e.g. `@schemavaults/auth-client-sdk`."),
72
+ sdk_version: z.string().min(1).max(L.sdk_version).optional().describe("Version of `sdk_name`."),
73
+ app_env: schemaVaultsAppEnvironmentSchema
74
+ .optional()
75
+ .describe("Environment the client app runs in."),
76
+ page_url: z
77
+ .string()
78
+ .max(L.page_url)
79
+ .optional()
80
+ .describe("Page the error happened on. The server keeps only its origin and path."),
81
+ reported_uid: z
82
+ .guid()
83
+ .optional()
84
+ .describe("The signed-in user as the client knows it. Reported by the client, not verified."),
85
+ context: z
86
+ .record(z.string(), z.unknown())
87
+ .refine((value) => fitsAsJson(value, L.context_json), {
88
+ message: `context must serialize to at most ${L.context_json} characters of JSON`,
89
+ })
90
+ .optional()
91
+ .describe(`Extra structured details (at most ${L.context_json} characters as JSON).`),
92
+ });
93
+ //# sourceMappingURL=client-error-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-error-report.js","sourceRoot":"","sources":["../../src/client-errors/client-error-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE,GAAG;IACT,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,KAAK;IACf,2CAA2C;IAC3C,YAAY,EAAE,KAAK;IACnB,+EAA+E;IAC/E,cAAc,EAAE,EAAE,GAAG,IAAI;CACjB,CAAC;A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V,QAAQ,CAAC,qEAAqE,CAAC;IAClF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC/F,OAAO,EAAE,gCAAgC;SACtC,QAAQ,EAAE;SACV,QAAQ,CAAC,qCAAqC,CAAC;IAClD,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;SACf,QAAQ,EAAE;SACV,QAAQ,CAAC,wEAAwE,CAAC;IACrF,YAAY,EAAE,CAAC;SACZ,IAAI,EAAE;SACN,QAAQ,EAAE;SACV,QAAQ,CAAC,kFAAkF,CAAC;IAC/F,OAAO,EAAE,CAAC;SACP,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE;QACpD,OAAO,EAAE,qCAAqC,CAAC,CAAC,YAAY,qBAAqB;KAClF,CAAC;SACD,QAAQ,EAAE;SACV,QAAQ,CAAC,qCAAqC,CAAC,CAAC,YAAY,uBAAuB,CAAC;CACxF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { CLIENT_ERROR_REPORT_LIMITS, clientErrorReportSchema, type ClientErrorReport, } from "./client-error-report";
2
+ export { CLIENT_ERROR_REDACTED, isClientErrorSecretKey, redactClientErrorContext, redactClientErrorReport, redactClientErrorText, } from "./redact-client-error-secrets";
@@ -0,0 +1,3 @@
1
+ export { CLIENT_ERROR_REPORT_LIMITS, clientErrorReportSchema, } from "./client-error-report";
2
+ export { CLIENT_ERROR_REDACTED, isClientErrorSecretKey, redactClientErrorContext, redactClientErrorReport, redactClientErrorText, } from "./redact-client-error-secrets";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client-errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { ClientErrorReport } from "./client-error-report";
2
+ /**
3
+ * Redaction of credentials in client error reports. Error messages, stack
4
+ * traces and app-supplied context can carry tokens (a token response that
5
+ * fails validation ends up in the error's `cause`), authorization codes,
6
+ * passwords or cookies. The client SDK redacts its reports before sending
7
+ * them, and the auth server redacts every report again before storing it,
8
+ * since older SDKs and other clients do not. Over-redaction is accepted: a
9
+ * report only has to say what went wrong.
10
+ *
11
+ * The patterns run in linear time (the server applies them to unauthenticated
12
+ * input) and use no lookbehind (older Safari cannot parse it). Isomorphic.
13
+ */
14
+ /** What a redacted value is replaced with. */
15
+ export declare const CLIENT_ERROR_REDACTED: string;
16
+ /** Whether a key (an object member, query parameter or header name) holds a secret. */
17
+ export declare function isClientErrorSecretKey(key: string): boolean;
18
+ /** `text` with tokens, `Authorization` credentials and the values of secret keys replaced. */
19
+ export declare function redactClientErrorText(text: string): string;
20
+ /**
21
+ * A report's JSON `context` with the members under secret keys replaced and
22
+ * every string redacted like {@link redactClientErrorText}. Members nested
23
+ * deeper than {@link MAX_CONTEXT_DEPTH} are replaced too.
24
+ */
25
+ export declare function redactClientErrorContext(context: Record<string, unknown>): Record<string, unknown>;
26
+ /** `report` with its message, stack and context redacted. */
27
+ export declare function redactClientErrorReport(report: ClientErrorReport): ClientErrorReport;
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Redaction of credentials in client error reports. Error messages, stack
3
+ * traces and app-supplied context can carry tokens (a token response that
4
+ * fails validation ends up in the error's `cause`), authorization codes,
5
+ * passwords or cookies. The client SDK redacts its reports before sending
6
+ * them, and the auth server redacts every report again before storing it,
7
+ * since older SDKs and other clients do not. Over-redaction is accepted: a
8
+ * report only has to say what went wrong.
9
+ *
10
+ * The patterns run in linear time (the server applies them to unauthenticated
11
+ * input) and use no lookbehind (older Safari cannot parse it). Isomorphic.
12
+ */
13
+ /** What a redacted value is replaced with. */
14
+ export const CLIENT_ERROR_REDACTED = "[redacted]";
15
+ /** A key containing one of these (lowercased, `-` read as `_`) holds a secret. */
16
+ const SECRET_KEY_FRAGMENTS = [
17
+ "token",
18
+ "secret",
19
+ "password",
20
+ "passwd",
21
+ "authorization",
22
+ "cookie",
23
+ "credential",
24
+ "api_key",
25
+ "apikey",
26
+ "private_key",
27
+ "privatekey",
28
+ "code_verifier",
29
+ "session_id",
30
+ "sessionid",
31
+ ];
32
+ /** Keys that hold a secret when they are the whole (last dotted segment of the) key. */
33
+ const SECRET_KEY_NAMES = new Set(["auth", "pass", "pwd", "jwt", "otp", "totp", "nonce"]);
34
+ /**
35
+ * Query / form parameters that hold a secret: `code` is the authorization
36
+ * code in a callback URL, but too common a key elsewhere (`code: 500`,
37
+ * `{ code: "ERR_NETWORK" }`) to redact outside `name=value` pairs.
38
+ */
39
+ const SECRET_PARAM_NAMES = new Set(["code"]);
40
+ /** Context deeper than this is not inspected, so it is not kept. */
41
+ const MAX_CONTEXT_DEPTH = 32;
42
+ /** Whether a key (an object member, query parameter or header name) holds a secret. */
43
+ export function isClientErrorSecretKey(key) {
44
+ const normalized = key.toLowerCase().replace(/-/g, "_");
45
+ const last = normalized.slice(normalized.lastIndexOf(".") + 1);
46
+ return SECRET_KEY_NAMES.has(last) || SECRET_KEY_FRAGMENTS.some((fragment) => normalized.includes(fragment));
47
+ }
48
+ /**
49
+ * JWS (3 segments) and JWE (5 segments) compact serializations, which start
50
+ * with a base64url `{"` header. The dot is checked in the replacer rather
51
+ * than the pattern, which would otherwise backtrack over long runs.
52
+ */
53
+ const JWT_CANDIDATE_REGEX = /eyJ[A-Za-z0-9_.-]{4,}/g;
54
+ /** The credentials of an `Authorization` header value. */
55
+ const AUTH_SCHEME_REGEX = /\b(Bearer|DPoP|Basic)([ \t]+)[A-Za-z0-9._~+/-]{8,}=*/gi;
56
+ /**
57
+ * The key and separator of `key=value`, `key: value` and `"key": value`
58
+ * (also with JSON-escaped quotes, as in a stringified body inside a
59
+ * message). Only the key is matched here: a non-secret value (`https:` in
60
+ * a URL, say) must not swallow the `?code=` that follows it. Bounded key
61
+ * and whitespace lengths keep it linear.
62
+ */
63
+ const KEY_SEPARATOR_REGEX = /([A-Za-z_][A-Za-z0-9_.-]{0,63})(\\?["']?[ \t]{0,8}([:=])[ \t]{0,8})/g;
64
+ /**
65
+ * The value after a secret key's separator: a quoted string (also
66
+ * unterminated, as when truncation cut it short) or an unquoted run,
67
+ * optionally after an `Authorization` scheme. Sticky: it is matched where
68
+ * the separator ends.
69
+ */
70
+ const SECRET_VALUE_REGEX = /\\?"(?:[^"\\]|\\[^"])*(?:\\?")?|'[^'\n]*'?|(?:(?:Bearer|DPoP|Basic)[ \t]+)?[^\s"'\\&,;{}()[\]<>]+/iy;
71
+ /** Source file names in stack frames (`exchange-auth-tokens.js:216:13`) are not keys. */
72
+ const SOURCE_FILE_KEY_REGEX = /\.(?:[cm]?[jt]sx?|map|html?|vue|svelte)$/i;
73
+ /** `value` with its content replaced, keeping its quotes. */
74
+ function redactedValue(value) {
75
+ const open = /^\\?["']/.exec(value)?.[0] ?? "";
76
+ if (!open)
77
+ return CLIENT_ERROR_REDACTED;
78
+ const close = value.length > open.length && value.endsWith(open) ? open : "";
79
+ return `${open}${CLIENT_ERROR_REDACTED}${close}`;
80
+ }
81
+ function isSecretKeyBeforeOperator(key, operator) {
82
+ if (SOURCE_FILE_KEY_REGEX.test(key))
83
+ return false;
84
+ return isClientErrorSecretKey(key) || (operator === "=" && SECRET_PARAM_NAMES.has(key.toLowerCase()));
85
+ }
86
+ /** `text` with the values of secret keys replaced. */
87
+ function redactKeyValues(text) {
88
+ let redacted = "";
89
+ let copied = 0;
90
+ KEY_SEPARATOR_REGEX.lastIndex = 0;
91
+ for (let match = KEY_SEPARATOR_REGEX.exec(text); match !== null; match = KEY_SEPARATOR_REGEX.exec(text)) {
92
+ const [keyAndSeparator, key = "", , operator = ""] = match;
93
+ if (!isSecretKeyBeforeOperator(key, operator))
94
+ continue;
95
+ const valueStart = match.index + keyAndSeparator.length;
96
+ SECRET_VALUE_REGEX.lastIndex = valueStart;
97
+ const value = SECRET_VALUE_REGEX.exec(text)?.[0];
98
+ if (!value)
99
+ continue;
100
+ redacted += text.slice(copied, valueStart) + redactedValue(value);
101
+ copied = valueStart + value.length;
102
+ KEY_SEPARATOR_REGEX.lastIndex = copied;
103
+ }
104
+ return redacted + text.slice(copied);
105
+ }
106
+ /** `text` with tokens, `Authorization` credentials and the values of secret keys replaced. */
107
+ export function redactClientErrorText(text) {
108
+ return redactKeyValues(text
109
+ .replace(JWT_CANDIDATE_REGEX, (candidate) => candidate.includes(".") ? CLIENT_ERROR_REDACTED : candidate)
110
+ .replace(AUTH_SCHEME_REGEX, `$1$2${CLIENT_ERROR_REDACTED}`));
111
+ }
112
+ function redactJsonValue(value, depth) {
113
+ if (typeof value === "string")
114
+ return redactClientErrorText(value);
115
+ if (value === null || typeof value !== "object")
116
+ return value;
117
+ if (depth >= MAX_CONTEXT_DEPTH)
118
+ return CLIENT_ERROR_REDACTED;
119
+ if (Array.isArray(value))
120
+ return value.map((item) => redactJsonValue(item, depth + 1));
121
+ // Object.fromEntries defines own properties: a `__proto__` member stays data.
122
+ return Object.fromEntries(Object.entries(value).map(([key, member]) => [
123
+ key,
124
+ isClientErrorSecretKey(key) ? CLIENT_ERROR_REDACTED : redactJsonValue(member, depth + 1),
125
+ ]));
126
+ }
127
+ /**
128
+ * A report's JSON `context` with the members under secret keys replaced and
129
+ * every string redacted like {@link redactClientErrorText}. Members nested
130
+ * deeper than {@link MAX_CONTEXT_DEPTH} are replaced too.
131
+ */
132
+ export function redactClientErrorContext(context) {
133
+ return redactJsonValue(context, 0);
134
+ }
135
+ /** `report` with its message, stack and context redacted. */
136
+ export function redactClientErrorReport(report) {
137
+ return {
138
+ ...report,
139
+ message: redactClientErrorText(report.message),
140
+ ...(report.stack !== undefined ? { stack: redactClientErrorText(report.stack) } : {}),
141
+ ...(report.context !== undefined ? { context: redactClientErrorContext(report.context) } : {}),
142
+ };
143
+ }
144
+ //# sourceMappingURL=redact-client-error-secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact-client-error-secrets.js","sourceRoot":"","sources":["../../src/client-errors/redact-client-error-secrets.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAW,YAAY,CAAC;AAE1D,kFAAkF;AAClF,MAAM,oBAAoB,GAAsB;IAC9C,OAAO;IACP,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,eAAe;IACf,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,WAAW;CACZ,CAAC;AAEF,wFAAwF;AACxF,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9G;;;;GAIG;AACH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAElE,oEAAoE;AACpE,MAAM,iBAAiB,GAAW,EAAE,CAAC;AAErC,uFAAuF;AACvF,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,UAAU,GAAW,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChE,MAAM,IAAI,GAAW,UAAU,CAAC,KAAK,CAAC,U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CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrF,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/F,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -35,6 +35,8 @@ export type { PaginationOptions } from "./pagination";
35
35
  export { timingSafeStringEqual } from "./timing-safe-string-equal";
36
36
  export { sanitizeNextHref, MAX_NEXT_HREF_LENGTH, } from "./sanitize-next-href";
37
37
  export { isOriginInAllowedList } from "./cors";
38
+ export { CLIENT_ERROR_REPORT_LIMITS, clientErrorReportSchema, CLIENT_ERROR_REDACTED, isClientErrorSecretKey, redactClientErrorContext, redactClientErrorReport, redactClientErrorText, } from "./client-errors";
39
+ export type { ClientErrorReport } from "./client-errors";
38
40
  export { isRedirectUriInCallbackAllowlist } from "./oauth2";
39
41
  export { oauth2StateSchema, OAUTH2_STATE_VSCHAR_REGEX, parseOAuth2State, OAuth2StateValidationError, } from "./oauth2-state-schema";
40
42
  export type { OAuth2State } from "./oauth2-state-schema";
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ export { paginationOptionsSchema, DEFAULT_PAGINATION_PAGE_INDEX, DEFAULT_PAGINAT
25
25
  export { timingSafeStringEqual } from "./timing-safe-string-equal";
26
26
  export { sanitizeNextHref, MAX_NEXT_HREF_LENGTH, } from "./sanitize-next-href";
27
27
  export { isOriginInAllowedList } from "./cors";
28
+ export { CLIENT_ERROR_REPORT_LIMITS, clientErrorReportSchema, CLIENT_ERROR_REDACTED, isClientErrorSecretKey, redactClientErrorContext, redactClientErrorReport, redactClientErrorText, } from "./client-errors";
28
29
  export { isRedirectUriInCallbackAllowlist } from "./oauth2";
29
30
  export { oauth2StateSchema, OAUTH2_STATE_VSCHAR_REGEX, parseOAuth2State, OAuth2StateValidationError, } from "./oauth2-state-schema";
30
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,mCAAmC,EACnC,qCAAqC,GACtC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EAIvB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,GAK1B,MAAM,aAAa,CAAC;AAErB,cAAc,eAAe,CAAC;AAG9B,mBAAmB;AACnB,cAAc,cAAc,CAAC;AAM7B,cAAc,cAAc,CAAC;AAG7B,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EACL,wBAAwB,EACxB,qCAAqC,EACrC,mCAAmC,EACnC,+BAA+B,EAC/B,wCAAwC,EACxC,iDAAiD,EACjD,wBAAwB,EACxB,uBAAuB,GAQxB,MAAM,uBAAuB,CAAC;AAE/B,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,+BAA+B,EAE/B,6CAA6C,GAE9C,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,EAC/B,qBAAqB,EACrB,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAG3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common",
3
3
  "description": "Types and utility functions for authentication and authorization",
4
- "version": "0.31.0",
4
+ "version": "0.33.0",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
7
  "repository": {