@clerk/shared 4.30.0-canary.v20260821144536 → 4.30.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.
- package/dist/_chunks/{error-DiOD3e6d.js → error-C-B61RHn.js} +7 -7
- package/dist/_chunks/error-C-B61RHn.js.map +1 -0
- package/dist/_chunks/{error-DRCZN5DP.mjs → error-CYyD2kei.mjs} +7 -7
- package/dist/_chunks/error-CYyD2kei.mjs.map +1 -0
- package/dist/error.js +1 -1
- package/dist/error.mjs +1 -1
- package/dist/errors/errorThrower.d.mts +3 -3
- package/dist/errors/errorThrower.d.ts +3 -3
- package/dist/errors/errorThrower.js +6 -6
- package/dist/internal/clerk-js/passkeys.js +1 -1
- package/dist/internal/clerk-js/passkeys.mjs +1 -1
- package/dist/internal/clerk-js/protectCheck.js +1 -1
- package/dist/internal/clerk-js/protectCheck.mjs +1 -1
- package/dist/internal/clerk-js/url.d.mts +6 -1
- package/dist/internal/clerk-js/url.d.ts +6 -1
- package/dist/internal/clerk-js/url.js +7 -0
- package/dist/internal/clerk-js/url.js.map +1 -1
- package/dist/internal/clerk-js/url.mjs +6 -1
- package/dist/internal/clerk-js/url.mjs.map +1 -1
- package/dist/internal/clerk-js/web3.js +1 -1
- package/dist/internal/clerk-js/web3.mjs +1 -1
- package/dist/keys.js +2 -2
- package/dist/keys.js.map +1 -1
- package/dist/keys.mjs +2 -2
- package/dist/keys.mjs.map +1 -1
- package/dist/loadClerkJsScript.js +2 -2
- package/dist/loadClerkJsScript.js.map +1 -1
- package/dist/loadClerkJsScript.mjs +2 -2
- package/dist/loadClerkJsScript.mjs.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.mjs +1 -1
- package/dist/versionSelector.js +1 -1
- package/dist/versionSelector.js.map +1 -1
- package/dist/versionSelector.mjs +1 -1
- package/dist/versionSelector.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/error-DRCZN5DP.mjs.map +0 -1
- package/dist/_chunks/error-DiOD3e6d.js.map +0 -1
|
@@ -220,23 +220,23 @@ const DefaultMessages = Object.freeze({
|
|
|
220
220
|
InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`,
|
|
221
221
|
InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
npx clerk@latest init
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
226
226
|
|
|
227
227
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys (\`--instance prod\` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.`,
|
|
228
228
|
MissingPublishableKeyErrorMessage: `Missing publishableKey. To set up Clerk for this project, in your terminal run:
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
npx clerk@latest init
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
233
233
|
|
|
234
234
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
|
|
235
235
|
MissingSecretKeyErrorMessage: `Missing secretKey. To set up Clerk for this project, in your terminal run:
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
npx clerk@latest init
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
240
240
|
|
|
241
241
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
|
|
242
242
|
MissingClerkProvider: `{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`
|
|
@@ -646,4 +646,4 @@ Object.defineProperty(exports, 'parseErrors', {
|
|
|
646
646
|
return parseErrors;
|
|
647
647
|
}
|
|
648
648
|
});
|
|
649
|
-
//# sourceMappingURL=error-
|
|
649
|
+
//# sourceMappingURL=error-C-B61RHn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-C-B61RHn.js","names":["createErrorTypeGuard","ClerkError","createErrorTypeGuard","ClerkRuntimeError","isClerkRuntimeError","ClerkRuntimeError","isClerkRuntimeError"],"sources":["../../src/errors/clerkApiError.ts","../../src/errors/parseError.ts","../../src/errors/clerkApiResponseError.ts","../../src/errors/missingExpiredTokenError.ts","../../src/errors/clerkOfflineError.ts","../../src/errors/errorThrower.ts","../../src/errors/emailLinkError.ts","../../src/errors/webAuthNError.ts","../../src/errors/helpers.ts","../../src/errors/globalHookError.ts"],"sourcesContent":["import type { ClerkAPIError as ClerkAPIErrorInterface, ClerkAPIErrorJSON } from '../types';\nimport { createErrorTypeGuard } from './createErrorTypeGuard';\n\nexport type ClerkAPIErrorMeta = Record<string, unknown>;\n\n/**\n * This error contains the specific error message, code, and any additional metadata that was returned by the Clerk API.\n */\nexport class ClerkAPIError<Meta extends ClerkAPIErrorMeta = any> implements ClerkAPIErrorInterface {\n static kind = 'ClerkAPIError';\n readonly code: string;\n readonly message: string;\n readonly longMessage: string | undefined;\n readonly meta: Meta;\n\n constructor(json: ClerkAPIErrorJSON) {\n const parsedError = {\n code: json.code,\n message: json.message,\n longMessage: json.long_message,\n meta: {\n paramName: json.meta?.param_name,\n sessionId: json.meta?.session_id,\n emailAddresses: json.meta?.email_addresses,\n identifiers: json.meta?.identifiers,\n zxcvbn: json.meta?.zxcvbn,\n plan: json.meta?.plan,\n isPlanUpgradePossible: json.meta?.is_plan_upgrade_possible,\n seatsQuantityToAdd: json.meta?.seats_quantity_to_add,\n seatsQuantity: json.meta?.seats_quantity,\n } as unknown as Meta,\n };\n this.code = parsedError.code;\n this.message = parsedError.message;\n this.longMessage = parsedError.longMessage;\n this.meta = parsedError.meta;\n }\n}\n\n/**\n * Type guard to check if a value is a ClerkAPIError instance.\n */\nexport const isClerkAPIError = createErrorTypeGuard(ClerkAPIError);\n","import type { ClerkAPIError as ClerkAPIErrorInterface, ClerkAPIErrorJSON } from '../types';\nimport { ClerkAPIError } from './clerkApiError';\n\n/**\n * Parses an array of ClerkAPIErrorJSON objects into an array of ClerkAPIError objects.\n *\n * @internal\n */\nexport function parseErrors(data: ClerkAPIErrorJSON[] = []): ClerkAPIErrorInterface[] {\n return data.length > 0 ? data.map(e => new ClerkAPIError(e)) : [];\n}\n\n/**\n * Parses a ClerkAPIErrorJSON object into a ClerkAPIError object.\n *\n * @deprecated Use `ClerkAPIError` class instead\n *\n * @internal\n */\nexport function parseError(error: ClerkAPIErrorJSON): ClerkAPIErrorInterface {\n return new ClerkAPIError(error);\n}\n\n/**\n * Converts a ClerkAPIError object into a ClerkAPIErrorJSON object.\n *\n * @internal\n */\nexport function errorToJSON(error: ClerkAPIError | null): ClerkAPIErrorJSON {\n return {\n code: error?.code || '',\n message: error?.message || '',\n long_message: error?.longMessage,\n meta: {\n param_name: error?.meta?.paramName,\n session_id: error?.meta?.sessionId,\n email_addresses: error?.meta?.emailAddresses,\n identifiers: error?.meta?.identifiers,\n zxcvbn: error?.meta?.zxcvbn,\n plan: error?.meta?.plan,\n is_plan_upgrade_possible: error?.meta?.isPlanUpgradePossible,\n seats_quantity_to_add: error?.meta?.seatsQuantityToAdd,\n seats_quantity: error?.meta?.seatsQuantity,\n },\n };\n}\n","import type { ClerkAPIErrorJSON, ClerkAPIResponseError as ClerkAPIResponseErrorInterface } from '../types';\nimport { ClerkAPIError } from './clerkApiError';\nimport type { ClerkErrorParams } from './clerkError';\nimport { ClerkError } from './clerkError';\nimport { createErrorTypeGuard } from './createErrorTypeGuard';\n\ninterface ClerkAPIResponseOptions extends Omit<ClerkErrorParams, 'message' | 'code'> {\n data: ClerkAPIErrorJSON[];\n status: number;\n clerkTraceId?: string;\n retryAfter?: number;\n}\n\nexport class ClerkAPIResponseError extends ClerkError implements ClerkAPIResponseErrorInterface {\n static kind = 'ClerkAPIResponseError';\n status: number;\n clerkTraceId?: string;\n retryAfter?: number;\n errors: ClerkAPIError[];\n\n constructor(message: string, options: ClerkAPIResponseOptions) {\n const { data: errorsJson, status, clerkTraceId, retryAfter } = options;\n super({ ...options, message, code: 'api_response_error' });\n Object.setPrototypeOf(this, ClerkAPIResponseError.prototype);\n this.status = status;\n this.clerkTraceId = clerkTraceId;\n this.retryAfter = retryAfter;\n this.errors = (errorsJson || []).map(e => new ClerkAPIError(e));\n }\n\n public toString() {\n let message = `[${this.name}]\\nMessage:${this.message}\\nStatus:${this.status}\\nSerialized errors: ${this.errors.map(\n e => JSON.stringify(e),\n )}`;\n\n if (this.clerkTraceId) {\n message += `\\nClerk Trace ID: ${this.clerkTraceId}`;\n }\n\n return message;\n }\n\n // Override formatMessage to keep it unformatted for backward compatibility\n protected static override formatMessage(name: string, msg: string, _: string, __: string | undefined) {\n return msg;\n }\n}\n\n/**\n * Type guard to check if an error is a ClerkAPIResponseError.\n * Can be called as a standalone function or as a method on an error object.\n *\n * @example\n * // As a standalone function\n * if (isClerkAPIResponseError(error)) { ... }\n *\n * // As a method (when attached to error object)\n * if (error.isClerkAPIResponseError()) { ... }\n */\nexport const isClerkAPIResponseError = createErrorTypeGuard(ClerkAPIResponseError);\n","import { ClerkAPIResponseError, isClerkAPIResponseError } from './clerkApiResponseError';\n\n/**\n * Error class representing a missing expired token error from the API.\n * This error occurs when the server requires an expired token to mint a new session token.\n *\n * Use the static `is` method to check if a ClerkAPIResponseError matches this error type.\n *\n * @example\n * ```typescript\n * if (MissingExpiredTokenError.is(error)) {\n * // Handle the missing expired token error\n * }\n * ```\n */\nexport class MissingExpiredTokenError extends ClerkAPIResponseError {\n static kind = 'MissingExpiredTokenError';\n static readonly ERROR_CODE = 'missing_expired_token' as const;\n static readonly STATUS = 422 as const;\n\n /**\n * Type guard to check if an error is a MissingExpiredTokenError.\n * This checks the error's properties (status and error code) rather than instanceof,\n * allowing it to work with ClerkAPIResponseError instances thrown from the API layer.\n *\n * @example\n * ```typescript\n * try {\n * await someApiCall();\n * } catch (e) {\n * if (MissingExpiredTokenError.is(e)) {\n * // e is typed as ClerkAPIResponseError with the specific error properties\n * }\n * }\n * ```\n */\n static is(err: unknown): err is ClerkAPIResponseError {\n return (\n isClerkAPIResponseError(err) &&\n err.status === MissingExpiredTokenError.STATUS &&\n err.errors.length > 0 &&\n err.errors[0].code === MissingExpiredTokenError.ERROR_CODE\n );\n }\n}\n","import { ClerkRuntimeError, isClerkRuntimeError } from './clerkRuntimeError';\n\n/**\n * Error thrown when a network request fails due to the client being offline.\n *\n * This error is thrown instead of returning `null` to make it explicit that\n * the failure was due to network conditions, not authentication state.\n *\n * @example\n * ```typescript\n * try {\n * const token = await session.getToken();\n * } catch (error) {\n * if (ClerkOfflineError.is(error)) {\n * // Handle offline scenario\n * showOfflineScreen();\n * }\n * }\n * ```\n */\nexport class ClerkOfflineError extends ClerkRuntimeError {\n static kind = 'ClerkOfflineError';\n static readonly ERROR_CODE = 'clerk_offline' as const;\n\n constructor(message: string) {\n super(message, { code: ClerkOfflineError.ERROR_CODE });\n Object.setPrototypeOf(this, ClerkOfflineError.prototype);\n }\n\n /**\n * Type guard to check if an error is a ClerkOfflineError.\n * This checks both instanceof and the error code to support cross-bundle/cross-realm errors\n *\n * @example\n * ```typescript\n * try {\n * const token = await session.getToken();\n * } catch (error) {\n * if (ClerkOfflineError.is(error)) {\n * // error is typed as ClerkOfflineError\n * console.log('User is offline');\n * }\n * }\n * ```\n */\n static is(error: unknown): error is ClerkOfflineError {\n if (error === null || error === undefined) {\n return false;\n }\n return (\n error instanceof ClerkOfflineError || (isClerkRuntimeError(error) && error.code === ClerkOfflineError.ERROR_CODE)\n );\n }\n}\n","const DefaultMessages = Object.freeze({\n InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`,\n InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\nnpx clerk@latest init\n\n\\`npx clerk@latest init\\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run \\`npx clerk@latest env pull\\` to write the keys (\\`--instance prod\\` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.`,\n MissingPublishableKeyErrorMessage: `Missing publishableKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n\\`npx clerk@latest init\\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run \\`npx clerk@latest env pull\\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \\`npx clerk@latest deploy\\`, or \\`npx clerk@latest env pull --instance prod\\` to use an existing one.`,\n MissingSecretKeyErrorMessage: `Missing secretKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n\\`npx clerk@latest init\\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run \\`npx clerk@latest env pull\\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \\`npx clerk@latest deploy\\`, or \\`npx clerk@latest env pull --instance prod\\` to use an existing one.`,\n MissingClerkProvider: `{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`,\n});\n\ntype MessageKeys = keyof typeof DefaultMessages;\n\ntype Messages = Record<MessageKeys, string>;\n\ntype CustomMessages = Partial<Messages>;\n\nexport type ErrorThrowerOptions = {\n packageName: string;\n customMessages?: CustomMessages;\n};\n\nexport interface ErrorThrower {\n setPackageName(options: ErrorThrowerOptions): ErrorThrower;\n\n setMessages(options: ErrorThrowerOptions): ErrorThrower;\n\n throwInvalidPublishableKeyError(params: { key?: string }): never;\n\n throwInvalidProxyUrl(params: { url?: string }): never;\n\n throwMissingPublishableKeyError(): never;\n\n throwMissingSecretKeyError(): never;\n\n throwMissingClerkProviderError(params: { source?: string }): never;\n\n throw(message: string): never;\n}\n\n/**\n * Builds an error thrower.\n *\n * @internal\n */\nexport function buildErrorThrower({ packageName, customMessages }: ErrorThrowerOptions): ErrorThrower {\n let pkg = packageName;\n\n /**\n * Builds a message from a raw message and replacements.\n *\n * @internal\n */\n function buildMessage(rawMessage: string, replacements?: Record<string, string | number>) {\n if (!replacements) {\n return `${pkg}: ${rawMessage}`;\n }\n\n let msg = rawMessage;\n const matches = rawMessage.matchAll(/{{([a-zA-Z0-9-_]+)}}/g);\n\n for (const match of matches) {\n const replacement = (replacements[match[1]] || '').toString();\n msg = msg.replace(`{{${match[1]}}}`, replacement);\n }\n\n return `${pkg}: ${msg}`;\n }\n\n const messages = {\n ...DefaultMessages,\n ...customMessages,\n };\n\n return {\n setPackageName({ packageName }: ErrorThrowerOptions): ErrorThrower {\n if (typeof packageName === 'string') {\n pkg = packageName;\n }\n return this;\n },\n\n setMessages({ customMessages }: ErrorThrowerOptions): ErrorThrower {\n Object.assign(messages, customMessages || {});\n return this;\n },\n\n throwInvalidPublishableKeyError(params: { key?: string }): never {\n throw new Error(buildMessage(messages.InvalidPublishableKeyErrorMessage, params));\n },\n\n throwInvalidProxyUrl(params: { url?: string }): never {\n throw new Error(buildMessage(messages.InvalidProxyUrlErrorMessage, params));\n },\n\n throwMissingPublishableKeyError(): never {\n throw new Error(buildMessage(messages.MissingPublishableKeyErrorMessage));\n },\n\n throwMissingSecretKeyError(): never {\n throw new Error(buildMessage(messages.MissingSecretKeyErrorMessage));\n },\n\n throwMissingClerkProviderError(params: { source?: string }): never {\n throw new Error(buildMessage(messages.MissingClerkProvider, params));\n },\n\n throw(message: string): never {\n throw new Error(buildMessage(message));\n },\n };\n}\n","export class EmailLinkError extends Error {\n code: string;\n\n constructor(code: string) {\n super(code);\n this.code = code;\n this.name = 'EmailLinkError' as const;\n Object.setPrototypeOf(this, EmailLinkError.prototype);\n }\n}\n\n/**\n * @deprecated Use `EmailLinkErrorCodeStatus` instead.\n *\n * @internal\n */\nexport const EmailLinkErrorCode = {\n Expired: 'expired',\n Failed: 'failed',\n ClientMismatch: 'client_mismatch',\n};\n\nexport const EmailLinkErrorCodeStatus = {\n Expired: 'expired',\n Failed: 'failed',\n ClientMismatch: 'client_mismatch',\n} as const;\n","import type { ClerkErrorParams } from './clerkError';\nimport { ClerkRuntimeError } from './clerkRuntimeError';\n\ntype ClerkWebAuthnErrorCode =\n // Generic\n | 'passkey_not_supported'\n | 'passkey_pa_not_supported'\n | 'passkey_invalid_rpID_or_domain'\n | 'passkey_already_exists'\n | 'passkey_operation_aborted'\n // Retrieval\n | 'passkey_retrieval_cancelled'\n | 'passkey_retrieval_failed'\n // Registration\n | 'passkey_registration_cancelled'\n | 'passkey_registration_failed';\n\ntype ClerkWebAuthnErrorOptions = Omit<ClerkErrorParams, 'message' | 'code'> & { code: ClerkWebAuthnErrorCode };\n\nexport class ClerkWebAuthnError extends ClerkRuntimeError {\n /**\n * A unique code identifying the error, can be used for localization.\n */\n code: ClerkWebAuthnErrorCode;\n\n constructor(message: string, options: ClerkWebAuthnErrorOptions) {\n super(message, options);\n this.code = options.code;\n }\n}\n","import type { ClerkAPIResponseError } from './clerkApiResponseError';\nimport { isClerkAPIResponseError } from './clerkApiResponseError';\nimport type { ClerkRuntimeError } from './clerkRuntimeError';\nimport { isClerkRuntimeError } from './clerkRuntimeError';\nimport type { EmailLinkError } from './emailLinkError';\nimport type { MetamaskError } from './metamaskError';\n\n/**\n * Checks if the provided error object is an unauthorized error.\n *\n * @internal\n *\n * @deprecated This is no longer used, and will be removed in the next major version.\n */\nexport function isUnauthorizedError(e: any): boolean {\n const status = e?.status;\n const code = e?.errors?.[0]?.code;\n return code === 'authentication_invalid' && status === 401;\n}\n\n/**\n * Checks if the provided error object is a captcha error.\n *\n * @internal\n */\nexport function isCaptchaError(e: ClerkAPIResponseError): boolean {\n return ['captcha_invalid', 'captcha_not_enabled', 'captcha_missing_token'].includes(e.errors[0].code);\n}\n\n/**\n * Checks if the provided error is a 4xx error.\n *\n * @internal\n */\nexport function is4xxError(e: any): boolean {\n const status = e?.status;\n return !!status && status >= 400 && status < 500;\n}\n\n/**\n * Checks if the provided error is a 429 (Too Many Requests) error.\n *\n * @internal\n */\nexport function is429Error(e: any): boolean {\n return e?.status === 429;\n}\n\nconst unauthenticated403ErrorCodes = new Set(['user_banned', 'user_deactivated']);\n\n/**\n * Checks if the provided error indicates the user's session is no longer valid\n * and should trigger the unauthenticated flow (e.g. sign-out / redirect to sign-in).\n *\n * Only matches explicit authentication failure status codes:\n * - 401: session is invalid or expired\n * - 422: invalid session state (e.g. missing_expired_token)\n * - 403: terminal user state (e.g. user_banned, user_deactivated)\n *\n * 404 is intentionally excluded despite being returned for \"session not found\",\n * because it's also returned for unrelated resources (org not found, JWT template\n * not found) and shares the same `resource_not_found` error code, making it\n * impossible to distinguish. Session-not-found 401s are already handled directly\n * by Base._fetch.\n *\n * @internal\n */\nexport function isUnauthenticatedError(e: any): boolean {\n const status = e?.status;\n const hasTerminalUserErrorCode =\n Array.isArray(e?.errors) && e.errors.some((error: any) => unauthenticated403ErrorCodes.has(error?.code));\n\n return status === 401 || status === 422 || (status === 403 && hasTerminalUserErrorCode);\n}\n\n/**\n * Checks if the provided error is a network error.\n *\n * @internal\n */\nexport function isNetworkError(e: any): boolean {\n // TODO: revise during error handling epic\n const message = (`${e.message}${e.name}` || '').toLowerCase().replace(/\\s+/g, '');\n return message.includes('networkerror');\n}\n\n/**\n * Checks if the provided error is either a ClerkAPIResponseError, a ClerkRuntimeError, or a MetamaskError.\n */\nexport function isKnownError(error: any): error is ClerkAPIResponseError | ClerkRuntimeError | MetamaskError {\n return isClerkAPIResponseError(error) || isMetamaskError(error) || isClerkRuntimeError(error);\n}\n\n/**\n * Checks if the provided error is a Clerk runtime error indicating a reverification was cancelled.\n */\nexport function isReverificationCancelledError(err: any) {\n return isClerkRuntimeError(err) && err.code === 'reverification_cancelled';\n}\n\n/**\n * Checks if the provided error is a Metamask error.\n */\nexport function isMetamaskError(err: any): err is MetamaskError {\n return 'code' in err && [4001, 32602, 32603].includes(err.code) && 'message' in err;\n}\n\n/**\n * Checks if the provided error is clerk api response error indicating a user is locked.\n */\nexport function isUserLockedError(err: any) {\n return isClerkAPIResponseError(err) && err.errors?.[0]?.code === 'user_locked';\n}\n\n/**\n * Checks if the provided error is a clerk api response error indicating a password was pwned.\n *\n * @internal\n */\nexport function isPasswordPwnedError(err: any) {\n return isClerkAPIResponseError(err) && err.errors?.[0]?.code === 'form_password_pwned';\n}\n\n/**\n * Checks if the provided error is a clerk api response error indicating a password was compromised.\n *\n * @internal\n */\nexport function isPasswordCompromisedError(err: any) {\n return isClerkAPIResponseError(err) && err.errors?.[0]?.code === 'form_password_compromised';\n}\n\n/**\n * Checks if the provided error is an EmailLinkError.\n */\nexport function isEmailLinkError(err: Error): err is EmailLinkError {\n return err.name === 'EmailLinkError';\n}\n","import { isClerkAPIResponseError } from './clerkApiResponseError';\nimport type { ClerkError } from './clerkError';\nimport { isClerkRuntimeError } from './clerkRuntimeError';\n\n/**\n * Creates a ClerkGlobalHookError object from a ClerkError instance.\n * It's a wrapper for all the different instances of Clerk errors that can\n * be returned when using Clerk hooks.\n */\nexport function createClerkGlobalHookError(error: ClerkError) {\n const predicates = {\n isClerkAPIResponseError,\n isClerkRuntimeError,\n } as const;\n\n for (const [name, fn] of Object.entries(predicates)) {\n Object.assign(error, { [name]: fn });\n }\n\n return error as ClerkError & typeof pred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220
|
InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`,
|
|
221
221
|
InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
npx clerk@latest init
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
226
226
|
|
|
227
227
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys (\`--instance prod\` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.`,
|
|
228
228
|
MissingPublishableKeyErrorMessage: `Missing publishableKey. To set up Clerk for this project, in your terminal run:
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
npx clerk@latest init
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
233
233
|
|
|
234
234
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
|
|
235
235
|
MissingSecretKeyErrorMessage: `Missing secretKey. To set up Clerk for this project, in your terminal run:
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
npx clerk@latest init
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
240
240
|
|
|
241
241
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
|
|
242
242
|
MissingClerkProvider: `{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`
|
|
@@ -479,4 +479,4 @@ function createClerkGlobalHookError(error) {
|
|
|
479
479
|
|
|
480
480
|
//#endregion
|
|
481
481
|
export { isClerkAPIResponseError as C, ClerkAPIError as D, parseErrors as E, isClerkAPIError as O, ClerkAPIResponseError as S, parseError as T, EmailLinkErrorCode as _, isEmailLinkError as a, ClerkOfflineError as b, isNetworkError as c, isReverificationCancelledError as d, isUnauthenticatedError as f, EmailLinkError as g, ClerkWebAuthnError as h, isCaptchaError as i, isPasswordCompromisedError as l, isUserLockedError as m, is429Error as n, isKnownError as o, isUnauthorizedError as p, is4xxError as r, isMetamaskError as s, createClerkGlobalHookError as t, isPasswordPwnedError as u, EmailLinkErrorCodeStatus as v, errorToJSON as w, MissingExpiredTokenError as x, buildErrorThrower as y };
|
|
482
|
-
//# sourceMappingURL=error-
|
|
482
|
+
//# sourceMappingURL=error-CYyD2kei.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-CYyD2kei.mjs","names":[],"sources":["../../src/errors/clerkApiError.ts","../../src/errors/parseError.ts","../../src/errors/clerkApiResponseError.ts","../../src/errors/missingExpiredTokenError.ts","../../src/errors/clerkOfflineError.ts","../../src/errors/errorThrower.ts","../../src/errors/emailLinkError.ts","../../src/errors/webAuthNError.ts","../../src/errors/helpers.ts","../../src/errors/globalHookError.ts"],"sourcesContent":["import type { ClerkAPIError as ClerkAPIErrorInterface, ClerkAPIErrorJSON } from '../types';\nimport { createErrorTypeGuard } from './createErrorTypeGuard';\n\nexport type ClerkAPIErrorMeta = Record<string, unknown>;\n\n/**\n * This error contains the specific error message, code, and any additional metadata that was returned by the Clerk API.\n */\nexport class ClerkAPIError<Meta extends ClerkAPIErrorMeta = any> implements ClerkAPIErrorInterface {\n static kind = 'ClerkAPIError';\n readonly code: string;\n readonly message: string;\n readonly longMessage: string | undefined;\n readonly meta: Meta;\n\n constructor(json: ClerkAPIErrorJSON) {\n const parsedError = {\n code: json.code,\n message: json.message,\n longMessage: json.long_message,\n meta: {\n paramName: json.meta?.param_name,\n sessionId: json.meta?.session_id,\n emailAddresses: json.meta?.email_addresses,\n identifiers: json.meta?.identifiers,\n zxcvbn: json.meta?.zxcvbn,\n plan: json.meta?.plan,\n isPlanUpgradePossible: json.meta?.is_plan_upgrade_possible,\n seatsQuantityToAdd: json.meta?.seats_quantity_to_add,\n seatsQuantity: json.meta?.seats_quantity,\n } as unknown as Meta,\n };\n this.code = parsedError.code;\n this.message = parsedError.message;\n this.longMessage = parsedError.longMessage;\n this.meta = parsedError.meta;\n }\n}\n\n/**\n * Type guard to check if a value is a ClerkAPIError instance.\n */\nexport const isClerkAPIError = createErrorTypeGuard(ClerkAPIError);\n","import type { ClerkAPIError as ClerkAPIErrorInterface, ClerkAPIErrorJSON } from '../types';\nimport { ClerkAPIError } from './clerkApiError';\n\n/**\n * Parses an array of ClerkAPIErrorJSON objects into an array of ClerkAPIError objects.\n *\n * @internal\n */\nexport function parseErrors(data: ClerkAPIErrorJSON[] = []): ClerkAPIErrorInterface[] {\n return data.length > 0 ? data.map(e => new ClerkAPIError(e)) : [];\n}\n\n/**\n * Parses a ClerkAPIErrorJSON object into a ClerkAPIError object.\n *\n * @deprecated Use `ClerkAPIError` class instead\n *\n * @internal\n */\nexport function parseError(error: ClerkAPIErrorJSON): ClerkAPIErrorInterface {\n return new ClerkAPIError(error);\n}\n\n/**\n * Converts a ClerkAPIError object into a ClerkAPIErrorJSON object.\n *\n * @internal\n */\nexport function errorToJSON(error: ClerkAPIError | null): ClerkAPIErrorJSON {\n return {\n code: error?.code || '',\n message: error?.message || '',\n long_message: error?.longMessage,\n meta: {\n param_name: error?.meta?.paramName,\n session_id: error?.meta?.sessionId,\n email_addresses: error?.meta?.emailAddresses,\n identifiers: error?.meta?.identifiers,\n zxcvbn: error?.meta?.zxcvbn,\n plan: error?.meta?.plan,\n is_plan_upgrade_possible: error?.meta?.isPlanUpgradePossible,\n seats_quantity_to_add: error?.meta?.seatsQuantityToAdd,\n seats_quantity: error?.meta?.seatsQuantity,\n },\n };\n}\n","import type { ClerkAPIErrorJSON, ClerkAPIResponseError as ClerkAPIResponseErrorInterface } from '../types';\nimport { ClerkAPIError } from './clerkApiError';\nimport type { ClerkErrorParams } from './clerkError';\nimport { ClerkError } from './clerkError';\nimport { createErrorTypeGuard } from './createErrorTypeGuard';\n\ninterface ClerkAPIResponseOptions extends Omit<ClerkErrorParams, 'message' | 'code'> {\n data: ClerkAPIErrorJSON[];\n status: number;\n clerkTraceId?: string;\n retryAfter?: number;\n}\n\nexport class ClerkAPIResponseError extends ClerkError implements ClerkAPIResponseErrorInterface {\n static kind = 'ClerkAPIResponseError';\n status: number;\n clerkTraceId?: string;\n retryAfter?: number;\n errors: ClerkAPIError[];\n\n constructor(message: string, options: ClerkAPIResponseOptions) {\n const { data: errorsJson, status, clerkTraceId, retryAfter } = options;\n super({ ...options, message, code: 'api_response_error' });\n Object.setPrototypeOf(this, ClerkAPIResponseError.prototype);\n this.status = status;\n this.clerkTraceId = clerkTraceId;\n this.retryAfter = retryAfter;\n this.errors = (errorsJson || []).map(e => new ClerkAPIError(e));\n }\n\n public toString() {\n let message = `[${this.name}]\\nMessage:${this.message}\\nStatus:${this.status}\\nSerialized errors: ${this.errors.map(\n e => JSON.stringify(e),\n )}`;\n\n if (this.clerkTraceId) {\n message += `\\nClerk Trace ID: ${this.clerkTraceId}`;\n }\n\n return message;\n }\n\n // Override formatMessage to keep it unformatted for backward compatibility\n protected static override formatMessage(name: string, msg: string, _: string, __: string | undefined) {\n return msg;\n }\n}\n\n/**\n * Type guard to check if an error is a ClerkAPIResponseError.\n * Can be called as a standalone function or as a method on an error object.\n *\n * @example\n * // As a standalone function\n * if (isClerkAPIResponseError(error)) { ... }\n *\n * // As a method (when attached to error object)\n * if (error.isClerkAPIResponseError()) { ... }\n */\nexport const isClerkAPIResponseError = createErrorTypeGuard(ClerkAPIResponseError);\n","import { ClerkAPIResponseError, isClerkAPIResponseError } from './clerkApiResponseError';\n\n/**\n * Error class representing a missing expired token error from the API.\n * This error occurs when the server requires an expired token to mint a new session token.\n *\n * Use the static `is` method to check if a ClerkAPIResponseError matches this error type.\n *\n * @example\n * ```typescript\n * if (MissingExpiredTokenError.is(error)) {\n * // Handle the missing expired token error\n * }\n * ```\n */\nexport class MissingExpiredTokenError extends ClerkAPIResponseError {\n static kind = 'MissingExpiredTokenError';\n static readonly ERROR_CODE = 'missing_expired_token' as const;\n static readonly STATUS = 422 as const;\n\n /**\n * Type guard to check if an error is a MissingExpiredTokenError.\n * This checks the error's properties (status and error code) rather than instanceof,\n * allowing it to work with ClerkAPIResponseError instances thrown from the API layer.\n *\n * @example\n * ```typescript\n * try {\n * await someApiCall();\n * } catch (e) {\n * if (MissingExpiredTokenError.is(e)) {\n * // e is typed as ClerkAPIResponseError with the specific error properties\n * }\n * }\n * ```\n */\n static is(err: unknown): err is ClerkAPIResponseError {\n return (\n isClerkAPIResponseError(err) &&\n err.status === MissingExpiredTokenError.STATUS &&\n err.errors.length > 0 &&\n err.errors[0].code === MissingExpiredTokenError.ERROR_CODE\n );\n }\n}\n","import { ClerkRuntimeError, isClerkRuntimeError } from './clerkRuntimeError';\n\n/**\n * Error thrown when a network request fails due to the client being offline.\n *\n * This error is thrown instead of returning `null` to make it explicit that\n * the failure was due to network conditions, not authentication state.\n *\n * @example\n * ```typescript\n * try {\n * const token = await session.getToken();\n * } catch (error) {\n * if (ClerkOfflineError.is(error)) {\n * // Handle offline scenario\n * showOfflineScreen();\n * }\n * }\n * ```\n */\nexport class ClerkOfflineError extends ClerkRuntimeError {\n static kind = 'ClerkOfflineError';\n static readonly ERROR_CODE = 'clerk_offline' as const;\n\n constructor(message: string) {\n super(message, { code: ClerkOfflineError.ERROR_CODE });\n Object.setPrototypeOf(this, ClerkOfflineError.prototype);\n }\n\n /**\n * Type guard to check if an error is a ClerkOfflineError.\n * This checks both instanceof and the error code to support cross-bundle/cross-realm errors\n *\n * @example\n * ```typescript\n * try {\n * const token = await session.getToken();\n * } catch (error) {\n * if (ClerkOfflineError.is(error)) {\n * // error is typed as ClerkOfflineError\n * console.log('User is offline');\n * }\n * }\n * ```\n */\n static is(error: unknown): error is ClerkOfflineError {\n if (error === null || error === undefined) {\n return false;\n }\n return (\n error instanceof ClerkOfflineError || (isClerkRuntimeError(error) && error.code === ClerkOfflineError.ERROR_CODE)\n );\n }\n}\n","const DefaultMessages = Object.freeze({\n InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`,\n InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\nnpx clerk@latest init\n\n\\`npx clerk@latest init\\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run \\`npx clerk@latest env pull\\` to write the keys (\\`--instance prod\\` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.`,\n MissingPublishableKeyErrorMessage: `Missing publishableKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n\\`npx clerk@latest init\\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run \\`npx clerk@latest env pull\\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \\`npx clerk@latest deploy\\`, or \\`npx clerk@latest env pull --instance prod\\` to use an existing one.`,\n MissingSecretKeyErrorMessage: `Missing secretKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n\\`npx clerk@latest init\\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run \\`npx clerk@latest env pull\\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \\`npx clerk@latest deploy\\`, or \\`npx clerk@latest env pull --instance prod\\` to use an existing one.`,\n MissingClerkProvider: `{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`,\n});\n\ntype MessageKeys = keyof typeof DefaultMessages;\n\ntype Messages = Record<MessageKeys, string>;\n\ntype CustomMessages = Partial<Messages>;\n\nexport type ErrorThrowerOptions = {\n packageName: string;\n customMessages?: CustomMessages;\n};\n\nexport interface ErrorThrower {\n setPackageName(options: ErrorThrowerOptions): ErrorThrower;\n\n setMessages(options: ErrorThrowerOptions): ErrorThrower;\n\n throwInvalidPublishableKeyError(params: { key?: string }): never;\n\n throwInvalidProxyUrl(params: { url?: string }): never;\n\n throwMissingPublishableKeyError(): never;\n\n throwMissingSecretKeyError(): never;\n\n throwMissingClerkProviderError(params: { source?: string }): never;\n\n throw(message: string): never;\n}\n\n/**\n * Builds an error thrower.\n *\n * @internal\n */\nexport function buildErrorThrower({ packageName, customMessages }: ErrorThrowerOptions): ErrorThrower {\n let pkg = packageName;\n\n /**\n * Builds a message from a raw message and replacements.\n *\n * @internal\n */\n function buildMessage(rawMessage: string, replacements?: Record<string, string | number>) {\n if (!replacements) {\n return `${pkg}: ${rawMessage}`;\n }\n\n let msg = rawMessage;\n const matches = rawMessage.matchAll(/{{([a-zA-Z0-9-_]+)}}/g);\n\n for (const match of matches) {\n const replacement = (replacements[match[1]] || '').toString();\n msg = msg.replace(`{{${match[1]}}}`, replacement);\n }\n\n return `${pkg}: ${msg}`;\n }\n\n const messages = {\n ...DefaultMessages,\n ...customMessages,\n };\n\n return {\n setPackageName({ packageName }: ErrorThrowerOptions): ErrorThrower {\n if (typeof packageName === 'string') {\n pkg = packageName;\n }\n return this;\n },\n\n setMessages({ customMessages }: ErrorThrowerOptions): ErrorThrower {\n Object.assign(messages, customMessages || {});\n return this;\n },\n\n throwInvalidPublishableKeyError(params: { key?: string }): never {\n throw new Error(buildMessage(messages.InvalidPublishableKeyErrorMessage, params));\n },\n\n throwInvalidProxyUrl(params: { url?: string }): never {\n throw new Error(buildMessage(messages.InvalidProxyUrlErrorMessage, params));\n },\n\n throwMissingPublishableKeyError(): never {\n throw new Error(buildMessage(messages.MissingPublishableKeyErrorMessage));\n },\n\n throwMissingSecretKeyError(): never {\n throw new Error(buildMessage(messages.MissingSecretKeyErrorMessage));\n },\n\n throwMissingClerkProviderError(params: { source?: string }): never {\n throw new Error(buildMessage(messages.MissingClerkProvider, params));\n },\n\n throw(message: string): never {\n throw new Error(buildMessage(message));\n },\n };\n}\n","export class EmailLinkError extends Error {\n code: string;\n\n constructor(code: string) {\n super(code);\n this.code = code;\n this.name = 'EmailLinkError' as const;\n Object.setPrototypeOf(this, EmailLinkError.prototype);\n }\n}\n\n/**\n * @deprecated Use `EmailLinkErrorCodeStatus` instead.\n *\n * @internal\n */\nexport const EmailLinkErrorCode = {\n Expired: 'expired',\n Failed: 'failed',\n ClientMismatch: 'client_mismatch',\n};\n\nexport const EmailLinkErrorCodeStatus = {\n Expired: 'expired',\n Failed: 'failed',\n ClientMismatch: 'client_mismatch',\n} as const;\n","import type { ClerkErrorParams } from './clerkError';\nimport { ClerkRuntimeError } from './clerkRuntimeError';\n\ntype ClerkWebAuthnErrorCode =\n // Generic\n | 'passkey_not_supported'\n | 'passkey_pa_not_supported'\n | 'passkey_invalid_rpID_or_domain'\n | 'passkey_already_exists'\n | 'passkey_operation_aborted'\n // Retrieval\n | 'passkey_retrieval_cancelled'\n | 'passkey_retrieval_failed'\n // Registration\n | 'passkey_registration_cancelled'\n | 'passkey_registration_failed';\n\ntype ClerkWebAuthnErrorOptions = Omit<ClerkErrorParams, 'message' | 'code'> & { code: ClerkWebAuthnErrorCode };\n\nexport class ClerkWebAuthnError extends ClerkRuntimeError {\n /**\n * A unique code identifying the error, can be used for localization.\n */\n code: ClerkWebAuthnErrorCode;\n\n constructor(message: string, options: ClerkWebAuthnErrorOptions) {\n super(message, options);\n this.code = options.code;\n }\n}\n","import type { ClerkAPIResponseError } from './clerkApiResponseError';\nimport { isClerkAPIResponseError } from './clerkApiResponseError';\nimport type { ClerkRuntimeError } from './clerkRuntimeError';\nimport { isClerkRuntimeError } from './clerkRuntimeError';\nimport type { EmailLinkError } from './emailLinkError';\nimport type { MetamaskError } from './metamaskError';\n\n/**\n * Checks if the provided error object is an unauthorized error.\n *\n * @internal\n *\n * @deprecated This is no longer used, and will be removed in the next major version.\n */\nexport function isUnauthorizedError(e: any): boolean {\n const status = e?.status;\n const code = e?.errors?.[0]?.code;\n return code === 'authentication_invalid' && status === 401;\n}\n\n/**\n * Checks if the provided error object is a captcha error.\n *\n * @internal\n */\nexport function isCaptchaError(e: ClerkAPIResponseError): boolean {\n return ['captcha_invalid', 'captcha_not_enabled', 'captcha_missing_token'].includes(e.errors[0].code);\n}\n\n/**\n * Checks if the provided error is a 4xx error.\n *\n * @internal\n */\nexport function is4xxError(e: any): boolean {\n const status = e?.status;\n return !!status && status >= 400 && status < 500;\n}\n\n/**\n * Checks if the provided error is a 429 (Too Many Requests) error.\n *\n * @internal\n */\nexport function is429Error(e: any): boolean {\n return e?.status === 429;\n}\n\nconst unauthenticated403ErrorCodes = new Set(['user_banned', 'user_deactivated']);\n\n/**\n * Checks if the provided error indicates the user's session is no longer valid\n * and should trigger the unauthenticated flow (e.g. sign-out / redirect to sign-in).\n *\n * Only matches explicit authentication failure status codes:\n * - 401: session is invalid or expired\n * - 422: invalid session state (e.g. missing_expired_token)\n * - 403: terminal user state (e.g. user_banned, user_deactivated)\n *\n * 404 is intentionally excluded despite being returned for \"session not found\",\n * because it's also returned for unrelated resources (org not found, JWT template\n * not found) and shares the same `resource_not_found` error code, making it\n * impossible to distinguish. Session-not-found 401s are already handled directly\n * by Base._fetch.\n *\n * @internal\n */\nexport function isUnauthenticatedError(e: any): boolean {\n const status = e?.status;\n const hasTerminalUserErrorCode =\n Array.isArray(e?.errors) && e.errors.some((error: any) => unauthenticated403ErrorCodes.has(error?.code));\n\n return status === 401 || status === 422 || (status === 403 && hasTerminalUserErrorCode);\n}\n\n/**\n * Checks if the provided error is a network error.\n *\n * @internal\n */\nexport function isNetworkError(e: any): boolean {\n // TODO: revise during error handling epic\n const message = (`${e.message}${e.name}` || '').toLowerCase().replace(/\\s+/g, '');\n return message.includes('networkerror');\n}\n\n/**\n * Checks if the provided error is either a ClerkAPIResponseError, a ClerkRuntimeError, or a MetamaskError.\n */\nexport function isKnownError(error: any): error is ClerkAPIResponseError | ClerkRuntimeError | MetamaskError {\n return isClerkAPIResponseError(error) || isMetamaskError(error) || isClerkRuntimeError(error);\n}\n\n/**\n * Checks if the provided error is a Clerk runtime error indicating a reverification was cancelled.\n */\nexport function isReverificationCancelledError(err: any) {\n return isClerkRuntimeError(err) && err.code === 'reverification_cancelled';\n}\n\n/**\n * Checks if the provided error is a Metamask error.\n */\nexport function isMetamaskError(err: any): err is MetamaskError {\n return 'code' in err && [4001, 32602, 32603].includes(err.code) && 'message' in err;\n}\n\n/**\n * Checks if the provided error is clerk api response error indicating a user is locked.\n */\nexport function isUserLockedError(err: any) {\n return isClerkAPIResponseError(err) && err.errors?.[0]?.code === 'user_locked';\n}\n\n/**\n * Checks if the provided error is a clerk api response error indicating a password was pwned.\n *\n * @internal\n */\nexport function isPasswordPwnedError(err: any) {\n return isClerkAPIResponseError(err) && err.errors?.[0]?.code === 'form_password_pwned';\n}\n\n/**\n * Checks if the provided error is a clerk api response error indicating a password was compromised.\n *\n * @internal\n */\nexport function isPasswordCompromisedError(err: any) {\n return isClerkAPIResponseError(err) && err.errors?.[0]?.code === 'form_password_compromised';\n}\n\n/**\n * Checks if the provided error is an EmailLinkError.\n */\nexport function isEmailLinkError(err: Error): err is EmailLinkError {\n return err.name === 'EmailLinkError';\n}\n","import { isClerkAPIResponseError } from './clerkApiResponseError';\nimport type { ClerkError } from './clerkError';\nimport { isClerkRuntimeError } from './clerkRuntimeError';\n\n/**\n * Creates a ClerkGlobalHookError object from a ClerkError instance.\n * It's a wrapper for all the different instances of Clerk errors that can\n * be returned when using Clerk hooks.\n */\nexport function createClerkGlobalHookError(error: ClerkError) {\n const predicates = {\n isClerkAPIResponseError,\n isClerkRuntimeError,\n } as const;\n\n for (const [name, fn] of Object.entries(predicates)) {\n Object.assign(error, { [name]: fn });\n }\n\n return error as ClerkError & typeof predicates;\n}\n\nexport type ClerkGlobalHookError = ReturnType<typeof createClerkGlobalHookError>;\n"],"mappings":";;;;;;AAQA,IAAa,gBAAb,MAAmG;CACjG,OAAO,OAAO;CACd,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,MAAyB;EACnC,MAAM,cAAc;GAClB,MAAM,KAAK;GACX,SAAS,KAAK;GACd,aAAa,KAAK;GAClB,MAAM;IACJ,WAAW,KAAK,MAAM;IACtB,WAAW,KAAK,MAAM;IACtB,gBAAgB,KAAK,MAAM;IAC3B,aAAa,KAAK,MAAM;IACxB,QAAQ,KAAK,MAAM;IACnB,MAAM,KAAK,MAAM;IACjB,uBAAuB,KAAK,MAAM;IAClC,oBAAoB,KAAK,MAAM;IAC/B,eAAe,KAAK,MAAM;GAC5B;EACF;EACA,KAAK,OAAO,YAAY;EACxB,KAAK,UAAU,YAAY;EAC3B,KAAK,cAAc,YAAY;EAC/B,KAAK,OAAO,YAAY;CAC1B;AACF;;;;AAKA,MAAa,kBAAkB,qBAAqB,aAAa;;;;;;;;;AClCjE,SAAgB,YAAY,OAA4B,CAAC,GAA6B;CACpF,OAAO,KAAK,SAAS,IAAI,KAAK,KAAI,MAAK,IAAI,cAAc,CAAC,CAAC,IAAI,CAAC;AAClE;;;;;;;;AASA,SAAgB,WAAW,OAAkD;CAC3E,OAAO,IAAI,cAAc,KAAK;AAChC;;;;;;AAOA,SAAgB,YAAY,OAAgD;CAC1E,OAAO;EACL,MAAM,OAAO,QAAQ;EACrB,SAAS,OAAO,WAAW;EAC3B,cAAc,OAAO;EACrB,MAAM;GACJ,YAAY,OAAO,MAAM;GACzB,YAAY,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AAa;EACjB;EACA;CACF;CAEA,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,UAAU,GAChD,OAAO,OAAO,OAAO,GAAG,OAAO,GAAG,CAAC;CAGrC,OAAO;AACT"}
|
package/dist/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_clerkRuntimeError = require('./_chunks/clerkRuntimeError-CYZdTZ_x.js');
|
|
3
|
-
const require_error = require('./_chunks/error-
|
|
3
|
+
const require_error = require('./_chunks/error-C-B61RHn.js');
|
|
4
4
|
|
|
5
5
|
exports.ClerkAPIError = require_error.ClerkAPIError;
|
|
6
6
|
exports.ClerkAPIResponseError = require_error.ClerkAPIResponseError;
|
package/dist/error.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as isClerkError, n as isClerkRuntimeError, r as ClerkError, t as ClerkRuntimeError } from "./_chunks/clerkRuntimeError-DlesLWqO.mjs";
|
|
2
|
-
import { C as isClerkAPIResponseError, D as ClerkAPIError, E as parseErrors, O as isClerkAPIError, S as ClerkAPIResponseError, T as parseError, _ as EmailLinkErrorCode, a as isEmailLinkError, b as ClerkOfflineError, c as isNetworkError, d as isReverificationCancelledError, f as isUnauthenticatedError, g as EmailLinkError, h as ClerkWebAuthnError, i as isCaptchaError, l as isPasswordCompromisedError, m as isUserLockedError, n as is429Error, o as isKnownError, p as isUnauthorizedError, r as is4xxError, s as isMetamaskError, t as createClerkGlobalHookError, u as isPasswordPwnedError, v as EmailLinkErrorCodeStatus, w as errorToJSON, x as MissingExpiredTokenError, y as buildErrorThrower } from "./_chunks/error-
|
|
2
|
+
import { C as isClerkAPIResponseError, D as ClerkAPIError, E as parseErrors, O as isClerkAPIError, S as ClerkAPIResponseError, T as parseError, _ as EmailLinkErrorCode, a as isEmailLinkError, b as ClerkOfflineError, c as isNetworkError, d as isReverificationCancelledError, f as isUnauthenticatedError, g as EmailLinkError, h as ClerkWebAuthnError, i as isCaptchaError, l as isPasswordCompromisedError, m as isUserLockedError, n as is429Error, o as isKnownError, p as isUnauthorizedError, r as is4xxError, s as isMetamaskError, t as createClerkGlobalHookError, u as isPasswordPwnedError, v as EmailLinkErrorCodeStatus, w as errorToJSON, x as MissingExpiredTokenError, y as buildErrorThrower } from "./_chunks/error-CYyD2kei.mjs";
|
|
3
3
|
|
|
4
4
|
export { ClerkAPIError, ClerkAPIResponseError, ClerkError, ClerkOfflineError, ClerkRuntimeError, ClerkWebAuthnError, EmailLinkError, EmailLinkErrorCode, EmailLinkErrorCodeStatus, MissingExpiredTokenError, buildErrorThrower, createClerkGlobalHookError, errorToJSON, is429Error, is4xxError, isCaptchaError, isClerkAPIError, isClerkAPIResponseError, isClerkError, isClerkRuntimeError, isEmailLinkError, isKnownError, isMetamaskError, isNetworkError, isPasswordCompromisedError, isPasswordPwnedError, isReverificationCancelledError, isUnauthenticatedError, isUnauthorizedError, isUserLockedError, parseError, parseErrors };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/errors/errorThrower.d.ts
|
|
2
2
|
declare const DefaultMessages: Readonly<{
|
|
3
3
|
InvalidProxyUrlErrorMessage: "The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})";
|
|
4
|
-
InvalidPublishableKeyErrorMessage: "The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\
|
|
5
|
-
MissingPublishableKeyErrorMessage: "Missing publishableKey. To set up Clerk for this project, in your terminal run:\n\
|
|
6
|
-
MissingSecretKeyErrorMessage: "Missing secretKey. To set up Clerk for this project, in your terminal run:\n\
|
|
4
|
+
InvalidPublishableKeyErrorMessage: "The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\nnpx clerk@latest init\n\n`npx clerk@latest init` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run `npx clerk@latest env pull` to write the keys (`--instance prod` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.";
|
|
5
|
+
MissingPublishableKeyErrorMessage: "Missing publishableKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n`npx clerk@latest init` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run `npx clerk@latest env pull` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running `npx clerk@latest deploy`, or `npx clerk@latest env pull --instance prod` to use an existing one.";
|
|
6
|
+
MissingSecretKeyErrorMessage: "Missing secretKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n`npx clerk@latest init` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run `npx clerk@latest env pull` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running `npx clerk@latest deploy`, or `npx clerk@latest env pull --instance prod` to use an existing one.";
|
|
7
7
|
MissingClerkProvider: "{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider";
|
|
8
8
|
}>;
|
|
9
9
|
type MessageKeys = keyof typeof DefaultMessages;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/errors/errorThrower.d.ts
|
|
2
2
|
declare const DefaultMessages: Readonly<{
|
|
3
3
|
InvalidProxyUrlErrorMessage: "The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})";
|
|
4
|
-
InvalidPublishableKeyErrorMessage: "The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\
|
|
5
|
-
MissingPublishableKeyErrorMessage: "Missing publishableKey. To set up Clerk for this project, in your terminal run:\n\
|
|
6
|
-
MissingSecretKeyErrorMessage: "Missing secretKey. To set up Clerk for this project, in your terminal run:\n\
|
|
4
|
+
InvalidPublishableKeyErrorMessage: "The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\nnpx clerk@latest init\n\n`npx clerk@latest init` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run `npx clerk@latest env pull` to write the keys (`--instance prod` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.";
|
|
5
|
+
MissingPublishableKeyErrorMessage: "Missing publishableKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n`npx clerk@latest init` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run `npx clerk@latest env pull` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running `npx clerk@latest deploy`, or `npx clerk@latest env pull --instance prod` to use an existing one.";
|
|
6
|
+
MissingSecretKeyErrorMessage: "Missing secretKey. To set up Clerk for this project, in your terminal run:\n\nnpx clerk@latest init\n\n`npx clerk@latest init` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.\n\nIf you have a Clerk application, run `npx clerk@latest env pull` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running `npx clerk@latest deploy`, or `npx clerk@latest env pull --instance prod` to use an existing one.";
|
|
7
7
|
MissingClerkProvider: "{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider";
|
|
8
8
|
}>;
|
|
9
9
|
type MessageKeys = keyof typeof DefaultMessages;
|
|
@@ -4,23 +4,23 @@ const DefaultMessages = Object.freeze({
|
|
|
4
4
|
InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`,
|
|
5
5
|
InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
npx clerk@latest init
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
10
10
|
|
|
11
11
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys (\`--instance prod\` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.`,
|
|
12
12
|
MissingPublishableKeyErrorMessage: `Missing publishableKey. To set up Clerk for this project, in your terminal run:
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
npx clerk@latest init
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
17
17
|
|
|
18
18
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
|
|
19
19
|
MissingSecretKeyErrorMessage: `Missing secretKey. To set up Clerk for this project, in your terminal run:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
npx clerk@latest init
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
\`npx clerk@latest init\` creates a Clerk application and writes keys to your .env file. No Clerk account or login required and the command is non-interactive.
|
|
24
24
|
|
|
25
25
|
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
|
|
26
26
|
MissingClerkProvider: `{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_error = require('../../_chunks/error-
|
|
2
|
+
const require_error = require('../../_chunks/error-C-B61RHn.js');
|
|
3
3
|
|
|
4
4
|
//#region src/internal/clerk-js/passkeys.ts
|
|
5
5
|
var Base64Converter = class {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_clerkRuntimeError = require('../../_chunks/clerkRuntimeError-CYZdTZ_x.js');
|
|
3
|
-
require('../../_chunks/error-
|
|
3
|
+
require('../../_chunks/error-C-B61RHn.js');
|
|
4
4
|
|
|
5
5
|
//#region src/internal/clerk-js/protectCheck.ts
|
|
6
6
|
/**
|
|
@@ -134,9 +134,14 @@ declare const hasUrlInFragment: (_url: URL | string) => boolean;
|
|
|
134
134
|
*/
|
|
135
135
|
declare const mergeFragmentIntoUrl: (_url: string | URL) => URL;
|
|
136
136
|
declare const pathFromFullPath: (fullPath: string) => string;
|
|
137
|
+
declare const VIRTUAL_ROUTER_BASE_PATH = "CLERK-ROUTER/VIRTUAL";
|
|
138
|
+
/**
|
|
139
|
+
* Whether `to` addresses the in-memory component router rather than a real application route.
|
|
140
|
+
*/
|
|
141
|
+
declare const isVirtualRouterPath: (to: string) => boolean;
|
|
137
142
|
declare function isRedirectForFAPIInitiatedFlow(frontendApi: string, redirectUrl: string): boolean;
|
|
138
143
|
declare function requiresUserInput(redirectUrl: string): boolean;
|
|
139
144
|
declare const isAllowedRedirect: (allowedRedirectOrigins: Array<string | RegExp> | undefined, currentOrigin: string) => (_url: URL | string) => boolean;
|
|
140
145
|
declare function createAllowedRedirectOrigins(allowedRedirectOrigins: Array<string | RegExp> | undefined, frontendApi: string, instanceType?: string): (string | RegExp)[] | undefined;
|
|
141
146
|
//#endregion
|
|
142
|
-
export { buildURL, createAllowedRedirectOrigins, getETLDPlusOneFromFrontendApi, getSearchParameterFromHash, hasBannedHrefProtocol, hasBannedProtocol, hasExternalAccountSignUpError, hasUrlInFragment, isAllowedRedirect, isDataUri, isDevAccountPortalOrigin, isDevOrStagingUrl, isProblematicUrl, isRedirectForFAPIInitiatedFlow, isValidUrl, mergeFragmentIntoUrl, pathFromFullPath, relativeToAbsoluteUrl, requiresUserInput, sanitizeHref, stripOrigin, toURL, trimLeadingSlash, trimTrailingSlash };
|
|
147
|
+
export { VIRTUAL_ROUTER_BASE_PATH, buildURL, createAllowedRedirectOrigins, getETLDPlusOneFromFrontendApi, getSearchParameterFromHash, hasBannedHrefProtocol, hasBannedProtocol, hasExternalAccountSignUpError, hasUrlInFragment, isAllowedRedirect, isDataUri, isDevAccountPortalOrigin, isDevOrStagingUrl, isProblematicUrl, isRedirectForFAPIInitiatedFlow, isValidUrl, isVirtualRouterPath, mergeFragmentIntoUrl, pathFromFullPath, relativeToAbsoluteUrl, requiresUserInput, sanitizeHref, stripOrigin, toURL, trimLeadingSlash, trimTrailingSlash };
|
|
@@ -134,9 +134,14 @@ declare const hasUrlInFragment: (_url: URL | string) => boolean;
|
|
|
134
134
|
*/
|
|
135
135
|
declare const mergeFragmentIntoUrl: (_url: string | URL) => URL;
|
|
136
136
|
declare const pathFromFullPath: (fullPath: string) => string;
|
|
137
|
+
declare const VIRTUAL_ROUTER_BASE_PATH = "CLERK-ROUTER/VIRTUAL";
|
|
138
|
+
/**
|
|
139
|
+
* Whether `to` addresses the in-memory component router rather than a real application route.
|
|
140
|
+
*/
|
|
141
|
+
declare const isVirtualRouterPath: (to: string) => boolean;
|
|
137
142
|
declare function isRedirectForFAPIInitiatedFlow(frontendApi: string, redirectUrl: string): boolean;
|
|
138
143
|
declare function requiresUserInput(redirectUrl: string): boolean;
|
|
139
144
|
declare const isAllowedRedirect: (allowedRedirectOrigins: Array<string | RegExp> | undefined, currentOrigin: string) => (_url: URL | string) => boolean;
|
|
140
145
|
declare function createAllowedRedirectOrigins(allowedRedirectOrigins: Array<string | RegExp> | undefined, frontendApi: string, instanceType?: string): (string | RegExp)[] | undefined;
|
|
141
146
|
//#endregion
|
|
142
|
-
export { buildURL, createAllowedRedirectOrigins, getETLDPlusOneFromFrontendApi, getSearchParameterFromHash, hasBannedHrefProtocol, hasBannedProtocol, hasExternalAccountSignUpError, hasUrlInFragment, isAllowedRedirect, isDataUri, isDevAccountPortalOrigin, isDevOrStagingUrl, isProblematicUrl, isRedirectForFAPIInitiatedFlow, isValidUrl, mergeFragmentIntoUrl, pathFromFullPath, relativeToAbsoluteUrl, requiresUserInput, sanitizeHref, stripOrigin, toURL, trimLeadingSlash, trimTrailingSlash };
|
|
147
|
+
export { VIRTUAL_ROUTER_BASE_PATH, buildURL, createAllowedRedirectOrigins, getETLDPlusOneFromFrontendApi, getSearchParameterFromHash, hasBannedHrefProtocol, hasBannedProtocol, hasExternalAccountSignUpError, hasUrlInFragment, isAllowedRedirect, isDataUri, isDevAccountPortalOrigin, isDevOrStagingUrl, isProblematicUrl, isRedirectForFAPIInitiatedFlow, isValidUrl, isVirtualRouterPath, mergeFragmentIntoUrl, pathFromFullPath, relativeToAbsoluteUrl, requiresUserInput, sanitizeHref, stripOrigin, toURL, trimLeadingSlash, trimTrailingSlash };
|
|
@@ -224,6 +224,11 @@ const mergeFragmentIntoUrl = (_url) => {
|
|
|
224
224
|
const pathFromFullPath = (fullPath) => {
|
|
225
225
|
return fullPath.replace(/CLERK-ROUTER\/(.*?)\//, "");
|
|
226
226
|
};
|
|
227
|
+
const VIRTUAL_ROUTER_BASE_PATH = "CLERK-ROUTER/VIRTUAL";
|
|
228
|
+
/**
|
|
229
|
+
* Whether `to` addresses the in-memory component router rather than a real application route.
|
|
230
|
+
*/
|
|
231
|
+
const isVirtualRouterPath = (to) => to.includes(VIRTUAL_ROUTER_BASE_PATH);
|
|
227
232
|
const frontendApiRedirectPathsWithUserInput = ["/oauth/authorize"];
|
|
228
233
|
const frontendApiRedirectPathsNoUserInput = [
|
|
229
234
|
"/v1/verify",
|
|
@@ -261,6 +266,7 @@ function createAllowedRedirectOrigins(allowedRedirectOrigins, frontendApi, insta
|
|
|
261
266
|
}
|
|
262
267
|
|
|
263
268
|
//#endregion
|
|
269
|
+
exports.VIRTUAL_ROUTER_BASE_PATH = VIRTUAL_ROUTER_BASE_PATH;
|
|
264
270
|
exports.buildURL = buildURL;
|
|
265
271
|
exports.createAllowedRedirectOrigins = createAllowedRedirectOrigins;
|
|
266
272
|
exports.getETLDPlusOneFromFrontendApi = getETLDPlusOneFromFrontendApi;
|
|
@@ -276,6 +282,7 @@ exports.isDevOrStagingUrl = isDevOrStagingUrl;
|
|
|
276
282
|
exports.isProblematicUrl = isProblematicUrl;
|
|
277
283
|
exports.isRedirectForFAPIInitiatedFlow = isRedirectForFAPIInitiatedFlow;
|
|
278
284
|
exports.isValidUrl = isValidUrl;
|
|
285
|
+
exports.isVirtualRouterPath = isVirtualRouterPath;
|
|
279
286
|
exports.mergeFragmentIntoUrl = mergeFragmentIntoUrl;
|
|
280
287
|
exports.pathFromFullPath = pathFromFullPath;
|
|
281
288
|
exports.relativeToAbsoluteUrl = relativeToAbsoluteUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","names":["createDevOrStagingUrlCache","isLegacyDevAccountPortalOrigin","isCurrentDevAccountPortalOrigin","camelToSnake","joinPaths","getQueryParams","globs"],"sources":["../../../src/internal/clerk-js/url.ts"],"sourcesContent":["import { globs } from '../../globs';\nimport { createDevOrStagingUrlCache } from '../../keys';\nimport { logger } from '../../logger';\nimport type { SignUpResource } from '../../types';\nimport { camelToSnake } from '../../underscore';\nimport { isCurrentDevAccountPortalOrigin, isLegacyDevAccountPortalOrigin } from '../../url';\nimport { joinPaths } from './path';\nimport { getQueryParams } from './querystring';\n\ndeclare global {\n export interface Window {\n tldts: {\n getDomain(hostname: string, { allowPrivateDomains }: { allowPrivateDomains: boolean }): string;\n };\n }\n}\n\n// This is used as a dummy base when we need to invoke \"new URL()\" but we don't care about the URL origin.\nconst DUMMY_URL_BASE = 'http://clerk-dummy';\n\nconst BANNED_URI_PROTOCOLS = ['javascript:'] as const;\n\n// Protocols that are dangerous specifically for href attributes in links\nconst BANNED_HREF_PROTOCOLS = ['javascript:', 'data:', 'vbscript:', 'blob:'] as const;\n\nconst { isDevOrStagingUrl } = createDevOrStagingUrlCache();\nexport { isDevOrStagingUrl };\nconst accountPortalCache = new Map<string, boolean>();\n\nexport function isDevAccountPortalOrigin(hostname: string = window.location.hostname): boolean {\n if (!hostname) {\n return false;\n }\n\n let res = accountPortalCache.get(hostname);\n\n if (res === undefined) {\n res = isLegacyDevAccountPortalOrigin(hostname) || isCurrentDevAccountPortalOrigin(hostname);\n accountPortalCache.set(hostname, res);\n }\n\n return res;\n}\n\nexport function getETLDPlusOneFromFrontendApi(frontendApi: string): string {\n return frontendApi.replace('clerk.', '');\n}\n\ninterface BuildURLParams extends Partial<URL> {\n base?: string;\n hashPath?: string;\n hashSearch?: string;\n hashSearchParams?: URLSearchParams | Record<string, string> | Array<URLSearchParams | Record<string, string>>;\n}\n\ninterface BuildURLOptions<T> {\n skipOrigin?: boolean;\n stringify?: T;\n}\n\n/**\n *\n * buildURL(params: URLParams, options: BuildURLOptions): string\n *\n * Builds a URL safely by using the native URL() constructor. It can\n * also build a secondary path and search URL that lives inside the hash\n * of the main URL. For example:\n *\n * https://foo.com/bar?qux=42#/hash-bar?hash-qux=42\n *\n * References:\n * https://developer.mozilla.org/en-US/docs/Web/API/URL\n *\n * @param params\n * @param options\n * @returns Returns the URL href\n */\nexport function buildURL<B extends boolean>(\n params: BuildURLParams,\n options?: BuildURLOptions<B>,\n): B extends true ? string : URL;\n\nexport function buildURL(params: BuildURLParams, options: BuildURLOptions<boolean> = {}): URL | string {\n const { base, hashPath, hashSearch, searchParams, hashSearchParams, ...rest } = params;\n\n let fallbackBase = '';\n // This check is necessary for React native environments where window is undefined.\n // TODO: Refactor all window and document usages in clerk-js and import them from\n // a single file that will be mocked easily in React native environments.\n if (typeof window !== 'undefined' && !!window.location) {\n fallbackBase = window.location.href;\n } else {\n fallbackBase = 'http://react-native-fake-base-url';\n }\n\n const url = new URL(base || '', fallbackBase);\n\n // Properly copy URLSearchParams\n if (searchParams instanceof URLSearchParams) {\n searchParams.forEach((value, key) => {\n if (value !== null && value !== undefined) {\n url.searchParams.set(camelToSnake(key), value);\n }\n });\n }\n\n Object.assign(url, rest);\n\n // Treat that hash part of the main URL as if it's another URL with a pathname and a search.\n // Another nested hash inside the top level hash (e.g. #my-hash#my-second-hash) is currently\n // not supported as there is no use case for it yet.\n if (hashPath || hashSearch || hashSearchParams) {\n // Parse the hash to a URL object\n const dummyUrlForHash = new URL(DUMMY_URL_BASE + url.hash.substring(1));\n\n // Join the current hash path and with the provided one\n dummyUrlForHash.pathname = joinPaths(dummyUrlForHash.pathname, hashPath || '');\n\n // Merge search params from hashSearch string\n const searchParamsFromHashSearchString = getQueryParams(hashSearch || '');\n for (const [key, val] of Object.entries(searchParamsFromHashSearchString)) {\n dummyUrlForHash.searchParams.append(key, val);\n }\n\n // Merge search params from the hashSearchParams object\n if (hashSearchParams) {\n const paramsArr = Array.isArray(hashSearchParams) ? hashSearchParams : [hashSearchParams];\n for (const _params of paramsArr) {\n if (!(_params instanceof URLSearchParams) && typeof _params !== 'object') {\n continue;\n }\n const params = new URLSearchParams(_params);\n params.forEach((value, key) => {\n if (value !== null && value !== undefined) {\n dummyUrlForHash.searchParams.set(camelToSnake(key), value);\n }\n });\n }\n }\n\n // Keep just the pathname and the search\n const newHash = dummyUrlForHash.href.replace(DUMMY_URL_BASE, '');\n\n // if the hash is `/`, it means that nothing new was added to the hash\n // so we can skip assigning it to the hash of the main url\n if (newHash !== '/') {\n // Assign them to the hash of the main url\n url.hash = newHash;\n }\n }\n\n const { stringify, skipOrigin } = options;\n if (stringify) {\n return skipOrigin ? url.href.replace(url.origin, '') : url.href;\n }\n return url;\n}\n\nexport function toURL(url: string | URL): URL {\n return new URL(url.toString(), window.location.origin);\n}\n\n/**\n *\n * stripOrigin(url: URL | string): string\n *\n * Strips the origin part of a URL and preserves path, search and hash is applicable\n *\n * References:\n * https://developer.mozilla.org/en-US/docs/Web/API/URL\n *\n * @param url\n * @returns Returns the URL href without the origin\n */\nexport function stripOrigin(url: URL | string): string {\n // In non-browser environments `window.location.origin` might not be available\n // if not polyfilled, so we can't construct a URL object with the `url` string\n // note: in that case, we can't easily strip the origin, so we return the original string\n if (typeof window.location === 'undefined' && typeof url === 'string') {\n return url;\n }\n\n url = toURL(url);\n return url.href.replace(url.origin, '');\n}\n\n/**\n * trimTrailingSlash(path: string): string\n *\n * Strips the trailing slashes from a string\n *\n * @returns Returns the string without trailing slashes\n *\n * @param path\n */\nexport const trimTrailingSlash = (path: string): string => {\n return (path || '').replace(/\\/+$/, '');\n};\n\n/**\n * trimLeadingSlash(path: string): string\n *\n * Strips the leading slashes from a string\n *\n * @returns Returns the string without leading slashes\n *\n * @param path\n */\nexport const trimLeadingSlash = (path: string): string => {\n return (path || '').replace(/^\\/+/, '');\n};\n\nexport const hasExternalAccountSignUpError = (signUp: SignUpResource): boolean => {\n const { externalAccount } = signUp.verifications;\n return !!externalAccount.error;\n};\n\nexport function getSearchParameterFromHash({\n hash = window.location.hash,\n paramName,\n}: {\n hash?: string;\n paramName: string;\n}) {\n const h = hash.startsWith('#') ? hash.substring(1) : hash;\n const dummyUrlForHash = new URL(h, DUMMY_URL_BASE);\n return dummyUrlForHash.searchParams.get(paramName);\n}\n\nexport function isValidUrl(val: string | URL | undefined | null): boolean {\n if (!val) {\n return false;\n }\n\n try {\n new URL(val as string);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function relativeToAbsoluteUrl(url: string, origin: string | URL): URL {\n try {\n return new URL(url);\n } catch {\n return new URL(url, origin);\n }\n}\n\n// Regular expression to detect disallowed patterns\nconst disallowedPatterns = [\n /\\0/, // Null bytes\n /^\\/\\//, // Protocol-relative\n // eslint-disable-next-line no-control-regex\n /[\\x00-\\x1F]/, // Control characters\n];\n\n/**\n * Check for potentially problematic URLs that could have been crafted to intentionally bypass the origin check. Note that the URLs passed to this\n * function are assumed to be from an \"allowed origin\", so we are not executing origin-specific checks here.\n */\nexport function isProblematicUrl(url: URL): boolean {\n if (hasBannedProtocol(url)) {\n return true;\n }\n // Check against disallowed patterns\n for (const pattern of disallowedPatterns) {\n if (pattern.test(url.pathname)) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function isDataUri(val?: string): val is string {\n if (!val || !isValidUrl(val)) {\n return false;\n }\n\n return new URL(val).protocol === 'data:';\n}\n\n/**\n * Checks if a URL uses javascript: protocol.\n * This prevents some XSS attacks through javascript: URLs.\n *\n * IMPORTANT: This does not check for `data:` or other protocols which\n * are dangerous if used for links or setting the window location.\n *\n * @param val - The URL to check\n * @returns True if the URL contains a banned protocol, false otherwise\n */\nexport function hasBannedProtocol(val: string | URL) {\n if (!isValidUrl(val)) {\n return false;\n }\n const protocol = new URL(val).protocol;\n return BANNED_URI_PROTOCOLS.some(bp => bp === protocol);\n}\n\n/**\n * Checks if a URL contains a banned protocol for href attributes in links.\n * This prevents some XSS attacks through javascript:, data:, vbscript:, and blob: URLs.\n *\n * @param val - The URL to check\n * @returns True if the URL contains a banned protocol, false otherwise\n */\nexport function hasBannedHrefProtocol(val: string | URL): boolean {\n if (!isValidUrl(val)) {\n return false;\n }\n const protocol = new URL(val).protocol;\n return BANNED_HREF_PROTOCOLS.some(bp => bp === protocol);\n}\n\n/**\n * Sanitizes an href value by checking for dangerous protocols.\n * Returns null if the href contains a dangerous protocol, otherwise returns the original href.\n * This prevents some XSS attacks through javascript:, data:, vbscript:, and blob: URLs.\n *\n * @param href - The href value to sanitize\n * @returns The sanitized href or null if dangerous\n */\nexport function sanitizeHref(href: string | undefined | null): string | null {\n if (!href || href.trim() === '') {\n return null;\n }\n\n // For relative URLs (starting with / or # or ?), allow them through\n if (href.startsWith('/') || href.startsWith('#') || href.startsWith('?')) {\n return href;\n }\n\n // For relative URLs without leading slash, allow them through\n if (!href.includes(':')) {\n return href;\n }\n\n // Check if it's a valid URL with a dangerous protocol\n try {\n const url = new URL(href);\n if (hasBannedHrefProtocol(url)) {\n return null;\n }\n return href;\n } catch {\n // If URL parsing fails, it's likely a relative URL or malformed\n // Allow relative URLs through, but be cautious with malformed ones\n return href;\n }\n}\n\nexport const hasUrlInFragment = (_url: URL | string) => {\n return new URL(_url, DUMMY_URL_BASE).hash.startsWith('#/');\n};\n\n/**\n * Creates a new URL by merging a fragment-based URL, if found.\n * The result URL has the original and the fragment pathnames appended\n * and also includes all search params from both places.\n *\n * @example\n * ```ts\n * mergeFragmentIntoUrl('https://accounts.clerk.com/sign-in?user_param=hello#/verify/factor-one?redirect_url=/protected')\n * // Returns: 'https://accounts.clerk.com/sign-in/verify/factor-one?user_param=hello&redirect_url=/protected'\n * ```\n */\nexport const mergeFragmentIntoUrl = (_url: string | URL): URL => {\n const url = new URL(_url);\n\n if (!hasUrlInFragment(url)) {\n return url;\n }\n\n const fragmentUrl = new URL(url.hash.replace('#/', '/'), url.href);\n const mergedPathname = [url.pathname, fragmentUrl.pathname]\n .map(s => s.split('/'))\n .flat()\n .filter(Boolean)\n .join('/');\n\n const mergedUrl = new URL(mergedPathname, url.origin);\n\n url.searchParams.forEach((val, key) => {\n mergedUrl.searchParams.set(key, val);\n });\n\n fragmentUrl.searchParams.forEach((val, key) => {\n mergedUrl.searchParams.set(key, val);\n });\n\n return mergedUrl;\n};\n\nexport const pathFromFullPath = (fullPath: string) => {\n return fullPath.replace(/CLERK-ROUTER\\/(.*?)\\//, '');\n};\n\nconst frontendApiRedirectPathsWithUserInput: string[] = [\n '/oauth/authorize', // OAuth2 identify provider flow\n];\n\nconst frontendApiRedirectPathsNoUserInput: string[] = [\n '/v1/verify', // magic links\n '/v1/tickets/accept', // ticket flow\n '/oauth/authorize-with-immediate-redirect', // OAuth 2 identity provider\n '/oauth/end_session', // OIDC logout\n];\n\nexport function isRedirectForFAPIInitiatedFlow(frontendApi: string, redirectUrl: string): boolean {\n const url = new URL(redirectUrl, DUMMY_URL_BASE);\n const path = url.pathname;\n\n const isValidFrontendRedirectPath =\n frontendApiRedirectPathsWithUserInput.includes(path) || frontendApiRedirectPathsNoUserInput.includes(path);\n return frontendApi === url.host && isValidFrontendRedirectPath;\n}\n\nexport function requiresUserInput(redirectUrl: string): boolean {\n const url = new URL(redirectUrl, DUMMY_URL_BASE);\n return frontendApiRedirectPathsWithUserInput.includes(url.pathname);\n}\n\nexport const isAllowedRedirect =\n (allowedRedirectOrigins: Array<string | RegExp> | undefined, currentOrigin: string) => (_url: URL | string) => {\n let url = _url;\n if (typeof url === 'string') {\n url = relativeToAbsoluteUrl(url, currentOrigin);\n }\n\n if (!allowedRedirectOrigins) {\n return true;\n }\n\n const isSameOrigin = currentOrigin === url.origin;\n\n const isAllowed =\n !isProblematicUrl(url) &&\n (isSameOrigin ||\n allowedRedirectOrigins\n .map(origin => (typeof origin === 'string' ? globs.toRegexp(trimTrailingSlash(origin)) : origin))\n .some(origin => origin.test(trimTrailingSlash(url.origin))));\n\n if (!isAllowed) {\n logger.warnOnce(\n `Clerk: Redirect URL ${url} is not on one of the allowedRedirectOrigins, falling back to the default redirect URL.`,\n );\n }\n return isAllowed;\n };\n\nexport function createAllowedRedirectOrigins(\n allowedRedirectOrigins: Array<string | RegExp> | undefined,\n frontendApi: string,\n instanceType?: string,\n): (string | RegExp)[] | undefined {\n if (Array.isArray(allowedRedirectOrigins) && !!allowedRedirectOrigins.length) {\n return allowedRedirectOrigins;\n }\n\n const origins: string[] = [];\n if (typeof window !== 'undefined' && !!window.location) {\n origins.push(window.location.origin);\n }\n\n origins.push(`https://${getETLDPlusOneFromFrontendApi(frontendApi)}`);\n origins.push(`https://*.${getETLDPlusOneFromFrontendApi(frontendApi)}`);\n\n if (instanceType === 'development') {\n origins.push(`https://${frontendApi}`);\n }\n\n return origins;\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,iBAAiB;AAEvB,MAAM,uBAAuB,CAAC,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rC;AAEA,SAAgB,kBAAkB,aAA8B;CAC9D,MAAM,MAAM,IAAI,IAAI,aAAa,cAAc;CAC/C,OAAO,sCAAsC,SAAS,IAAI,QAAQ;AACpE;AAEA,MAAa,qBACV,wBAA4D,mBAA2B,SAAuB;CAC7G,IAAI,MAAM;CACV,IAAI,OAAO,QAAQ,UACjB,MAAM,sBAAsB,KAAK,aAAa;CAGhD,IAAI,CAAC,wBACH,OAAO;CAGT,MAAM,eAAe,kBAAkB,IAAI;CAE3C,MAAM,YACJ,CAAC,iBAAiB,GAAG,MACpB,gBACC,uBACG,KAAI,WAAW,OAAO,WAAW,WAAWG,oBAAM,SAAS,kBAAkB,MAAM,CAAC,IAAI,MAAO,CAAC,CAChG,MAAK,WAAU,OAAO,KAAK,kBAAkB,IAAI,MAAM,CAAC,CAAC;CAEhE,IAAI,CAAC,WACH,sBAAO,SACL,uBAAuB,IAAI,wFAC7B;CAEF,OAAO;AACT;AAEF,SAAgB,6BACd,wBACA,aACA,cACiC;CACjC,IAAI,MAAM,QAAQ,sBAAsB,KAAK,CAAC,CAAC,uBAAuB,QACpE,OAAO;CAGT,MAAM,UAAoB,CAAC;CAC3B,IAAI,OAAO,WAAW,eAAe,CAAC,CAAC,OAAO,UAC5C,QAAQ,KAAK,OAAO,SAAS,MAAM;CAGrC,QAAQ,KAAK,WAAW,8BAA8B,WAAW,GAAG;CACpE,QAAQ,KAAK,aAAa,8BAA8B,WAAW,GAAG;CAEtE,IAAI,iBAAiB,eACnB,QAAQ,KAAK,WAAW,aAAa;CAGvC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"url.js","names":["createDevOrStagingUrlCache","isLegacyDevAccountPortalOrigin","isCurrentDevAccountPortalOrigin","camelToSnake","joinPaths","getQueryParams","globs"],"sources":["../../../src/internal/clerk-js/url.ts"],"sourcesContent":["import { globs } from '../../globs';\nimport { createDevOrStagingUrlCache } from '../../keys';\nimport { logger } from '../../logger';\nimport type { SignUpResource } from '../../types';\nimport { camelToSnake } from '../../underscore';\nimport { isCurrentDevAccountPortalOrigin, isLegacyDevAccountPortalOrigin } from '../../url';\nimport { joinPaths } from './path';\nimport { getQueryParams } from './querystring';\n\ndeclare global {\n export interface Window {\n tldts: {\n getDomain(hostname: string, { allowPrivateDomains }: { allowPrivateDomains: boolean }): string;\n };\n }\n}\n\n// This is used as a dummy base when we need to invoke \"new URL()\" but we don't care about the URL origin.\nconst DUMMY_URL_BASE = 'http://clerk-dummy';\n\nconst BANNED_URI_PROTOCOLS = ['javascript:'] as const;\n\n// Protocols that are dangerous specifically for href attributes in links\nconst BANNED_HREF_PROTOCOLS = ['javascript:', 'data:', 'vbscript:', 'blob:'] as const;\n\nconst { isDevOrStagingUrl } = createDevOrStagingUrlCache();\nexport { isDevOrStagingUrl };\nconst accountPortalCache = new Map<string, boolean>();\n\nexport function isDevAccountPortalOrigin(hostname: string = window.location.hostname): boolean {\n if (!hostname) {\n return false;\n }\n\n let res = accountPortalCache.get(hostname);\n\n if (res === undefined) {\n res = isLegacyDevAccountPortalOrigin(hostname) || isCurrentDevAccountPortalOrigin(hostname);\n accountPortalCache.set(hostname, res);\n }\n\n return res;\n}\n\nexport function getETLDPlusOneFromFrontendApi(frontendApi: string): string {\n return frontendApi.replace('clerk.', '');\n}\n\ninterface BuildURLParams extends Partial<URL> {\n base?: string;\n hashPath?: string;\n hashSearch?: string;\n hashSearchParams?: URLSearchParams | Record<string, string> | Array<URLSearchParams | Record<string, string>>;\n}\n\ninterface BuildURLOptions<T> {\n skipOrigin?: boolean;\n stringify?: T;\n}\n\n/**\n *\n * buildURL(params: URLParams, options: BuildURLOptions): string\n *\n * Builds a URL safely by using the native URL() constructor. It can\n * also build a secondary path and search URL that lives inside the hash\n * of the main URL. For example:\n *\n * https://foo.com/bar?qux=42#/hash-bar?hash-qux=42\n *\n * References:\n * https://developer.mozilla.org/en-US/docs/Web/API/URL\n *\n * @param params\n * @param options\n * @returns Returns the URL href\n */\nexport function buildURL<B extends boolean>(\n params: BuildURLParams,\n options?: BuildURLOptions<B>,\n): B extends true ? string : URL;\n\nexport function buildURL(params: BuildURLParams, options: BuildURLOptions<boolean> = {}): URL | string {\n const { base, hashPath, hashSearch, searchParams, hashSearchParams, ...rest } = params;\n\n let fallbackBase = '';\n // This check is necessary for React native environments where window is undefined.\n // TODO: Refactor all window and document usages in clerk-js and import them from\n // a single file that will be mocked easily in React native environments.\n if (typeof window !== 'undefined' && !!window.location) {\n fallbackBase = window.location.href;\n } else {\n fallbackBase = 'http://react-native-fake-base-url';\n }\n\n const url = new URL(base || '', fallbackBase);\n\n // Properly copy URLSearchParams\n if (searchParams instanceof URLSearchParams) {\n searchParams.forEach((value, key) => {\n if (value !== null && value !== undefined) {\n url.searchParams.set(camelToSnake(key), value);\n }\n });\n }\n\n Object.assign(url, rest);\n\n // Treat that hash part of the main URL as if it's another URL with a pathname and a search.\n // Another nested hash inside the top level hash (e.g. #my-hash#my-second-hash) is currently\n // not supported as there is no use case for it yet.\n if (hashPath || hashSearch || hashSearchParams) {\n // Parse the hash to a URL object\n const dummyUrlForHash = new URL(DUMMY_URL_BASE + url.hash.substring(1));\n\n // Join the current hash path and with the provided one\n dummyUrlForHash.pathname = joinPaths(dummyUrlForHash.pathname, hashPath || '');\n\n // Merge search params from hashSearch string\n const searchParamsFromHashSearchString = getQueryParams(hashSearch || '');\n for (const [key, val] of Object.entries(searchParamsFromHashSearchString)) {\n dummyUrlForHash.searchParams.append(key, val);\n }\n\n // Merge search params from the hashSearchParams object\n if (hashSearchParams) {\n const paramsArr = Array.isArray(hashSearchParams) ? hashSearchParams : [hashSearchParams];\n for (const _params of paramsArr) {\n if (!(_params instanceof URLSearchParams) && typeof _params !== 'object') {\n continue;\n }\n const params = new URLSearchParams(_params);\n params.forEach((value, key) => {\n if (value !== null && value !== undefined) {\n dummyUrlForHash.searchParams.set(camelToSnake(key), value);\n }\n });\n }\n }\n\n // Keep just the pathname and the search\n const newHash = dummyUrlForHash.href.replace(DUMMY_URL_BASE, '');\n\n // if the hash is `/`, it means that nothing new was added to the hash\n // so we can skip assigning it to the hash of the main url\n if (newHash !== '/') {\n // Assign them to the hash of the main url\n url.hash = newHash;\n }\n }\n\n const { stringify, skipOrigin } = options;\n if (stringify) {\n return skipOrigin ? url.href.replace(url.origin, '') : url.href;\n }\n return url;\n}\n\nexport function toURL(url: string | URL): URL {\n return new URL(url.toString(), window.location.origin);\n}\n\n/**\n *\n * stripOrigin(url: URL | string): string\n *\n * Strips the origin part of a URL and preserves path, search and hash is applicable\n *\n * References:\n * https://developer.mozilla.org/en-US/docs/Web/API/URL\n *\n * @param url\n * @returns Returns the URL href without the origin\n */\nexport function stripOrigin(url: URL | string): string {\n // In non-browser environments `window.location.origin` might not be available\n // if not polyfilled, so we can't construct a URL object with the `url` string\n // note: in that case, we can't easily strip the origin, so we return the original string\n if (typeof window.location === 'undefined' && typeof url === 'string') {\n return url;\n }\n\n url = toURL(url);\n return url.href.replace(url.origin, '');\n}\n\n/**\n * trimTrailingSlash(path: string): string\n *\n * Strips the trailing slashes from a string\n *\n * @returns Returns the string without trailing slashes\n *\n * @param path\n */\nexport const trimTrailingSlash = (path: string): string => {\n return (path || '').replace(/\\/+$/, '');\n};\n\n/**\n * trimLeadingSlash(path: string): string\n *\n * Strips the leading slashes from a string\n *\n * @returns Returns the string without leading slashes\n *\n * @param path\n */\nexport const trimLeadingSlash = (path: string): string => {\n return (path || '').replace(/^\\/+/, '');\n};\n\nexport const hasExternalAccountSignUpError = (signUp: SignUpResource): boolean => {\n const { externalAccount } = signUp.verifications;\n return !!externalAccount.error;\n};\n\nexport function getSearchParameterFromHash({\n hash = window.location.hash,\n paramName,\n}: {\n hash?: string;\n paramName: string;\n}) {\n const h = hash.startsWith('#') ? hash.substring(1) : hash;\n const dummyUrlForHash = new URL(h, DUMMY_URL_BASE);\n return dummyUrlForHash.searchParams.get(paramName);\n}\n\nexport function isValidUrl(val: string | URL | undefined | null): boolean {\n if (!val) {\n return false;\n }\n\n try {\n new URL(val as string);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function relativeToAbsoluteUrl(url: string, origin: string | URL): URL {\n try {\n return new URL(url);\n } catch {\n return new URL(url, origin);\n }\n}\n\n// Regular expression to detect disallowed patterns\nconst disallowedPatterns = [\n /\\0/, // Null bytes\n /^\\/\\//, // Protocol-relative\n // eslint-disable-next-line no-control-regex\n /[\\x00-\\x1F]/, // Control characters\n];\n\n/**\n * Check for potentially problematic URLs that could have been crafted to intentionally bypass the origin check. Note that the URLs passed to this\n * function are assumed to be from an \"allowed origin\", so we are not executing origin-specific checks here.\n */\nexport function isProblematicUrl(url: URL): boolean {\n if (hasBannedProtocol(url)) {\n return true;\n }\n // Check against disallowed patterns\n for (const pattern of disallowedPatterns) {\n if (pattern.test(url.pathname)) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function isDataUri(val?: string): val is string {\n if (!val || !isValidUrl(val)) {\n return false;\n }\n\n return new URL(val).protocol === 'data:';\n}\n\n/**\n * Checks if a URL uses javascript: protocol.\n * This prevents some XSS attacks through javascript: URLs.\n *\n * IMPORTANT: This does not check for `data:` or other protocols which\n * are dangerous if used for links or setting the window location.\n *\n * @param val - The URL to check\n * @returns True if the URL contains a banned protocol, false otherwise\n */\nexport function hasBannedProtocol(val: string | URL) {\n if (!isValidUrl(val)) {\n return false;\n }\n const protocol = new URL(val).protocol;\n return BANNED_URI_PROTOCOLS.some(bp => bp === protocol);\n}\n\n/**\n * Checks if a URL contains a banned protocol for href attributes in links.\n * This prevents some XSS attacks through javascript:, data:, vbscript:, and blob: URLs.\n *\n * @param val - The URL to check\n * @returns True if the URL contains a banned protocol, false otherwise\n */\nexport function hasBannedHrefProtocol(val: string | URL): boolean {\n if (!isValidUrl(val)) {\n return false;\n }\n const protocol = new URL(val).protocol;\n return BANNED_HREF_PROTOCOLS.some(bp => bp === protocol);\n}\n\n/**\n * Sanitizes an href value by checking for dangerous protocols.\n * Returns null if the href contains a dangerous protocol, otherwise returns the original href.\n * This prevents some XSS attacks through javascript:, data:, vbscript:, and blob: URLs.\n *\n * @param href - The href value to sanitize\n * @returns The sanitized href or null if dangerous\n */\nexport function sanitizeHref(href: string | undefined | null): string | null {\n if (!href || href.trim() === '') {\n return null;\n }\n\n // For relative URLs (starting with / or # or ?), allow them through\n if (href.startsWith('/') || href.startsWith('#') || href.startsWith('?')) {\n return href;\n }\n\n // For relative URLs without leading slash, allow them through\n if (!href.includes(':')) {\n return href;\n }\n\n // Check if it's a valid URL with a dangerous protocol\n try {\n const url = new URL(href);\n if (hasBannedHrefProtocol(url)) {\n return null;\n }\n return href;\n } catch {\n // If URL parsing fails, it's likely a relative URL or malformed\n // Allow relative URLs through, but be cautious with malformed ones\n return href;\n }\n}\n\nexport const hasUrlInFragment = (_url: URL | string) => {\n return new URL(_url, DUMMY_URL_BASE).hash.startsWith('#/');\n};\n\n/**\n * Creates a new URL by merging a fragment-based URL, if found.\n * The result URL has the original and the fragment pathnames appended\n * and also includes all search params from both places.\n *\n * @example\n * ```ts\n * mergeFragmentIntoUrl('https://accounts.clerk.com/sign-in?user_param=hello#/verify/factor-one?redirect_url=/protected')\n * // Returns: 'https://accounts.clerk.com/sign-in/verify/factor-one?user_param=hello&redirect_url=/protected'\n * ```\n */\nexport const mergeFragmentIntoUrl = (_url: string | URL): URL => {\n const url = new URL(_url);\n\n if (!hasUrlInFragment(url)) {\n return url;\n }\n\n const fragmentUrl = new URL(url.hash.replace('#/', '/'), url.href);\n const mergedPathname = [url.pathname, fragmentUrl.pathname]\n .map(s => s.split('/'))\n .flat()\n .filter(Boolean)\n .join('/');\n\n const mergedUrl = new URL(mergedPathname, url.origin);\n\n url.searchParams.forEach((val, key) => {\n mergedUrl.searchParams.set(key, val);\n });\n\n fragmentUrl.searchParams.forEach((val, key) => {\n mergedUrl.searchParams.set(key, val);\n });\n\n return mergedUrl;\n};\n\nexport const pathFromFullPath = (fullPath: string) => {\n return fullPath.replace(/CLERK-ROUTER\\/(.*?)\\//, '');\n};\n\nexport const VIRTUAL_ROUTER_BASE_PATH = 'CLERK-ROUTER/VIRTUAL';\n\n/**\n * Whether `to` addresses the in-memory component router rather than a real application route.\n */\nexport const isVirtualRouterPath = (to: string): boolean => to.includes(VIRTUAL_ROUTER_BASE_PATH);\n\nconst frontendApiRedirectPathsWithUserInput: string[] = [\n '/oauth/authorize', // OAuth2 identify provider flow\n];\n\nconst frontendApiRedirectPathsNoUserInput: string[] = [\n '/v1/verify', // magic links\n '/v1/tickets/accept', // ticket flow\n '/oauth/authorize-with-immediate-redirect', // OAuth 2 identity provider\n '/oauth/end_session', // OIDC logout\n];\n\nexport function isRedirectForFAPIInitiatedFlow(frontendApi: string, redirectUrl: string): boolean {\n const url = new URL(redirectUrl, DUMMY_URL_BASE);\n const path = url.pathname;\n\n const isValidFrontendRedirectPath =\n frontendApiRedirectPathsWithUserInput.includes(path) || frontendApiRedirectPathsNoUserInput.includes(path);\n return frontendApi === url.host && isValidFrontendRedirectPath;\n}\n\nexport function requiresUserInput(redirectUrl: string): boolean {\n const url = new URL(redirectUrl, DUMMY_URL_BASE);\n return frontendApiRedirectPathsWithUserInput.includes(url.pathname);\n}\n\nexport const isAllowedRedirect =\n (allowedRedirectOrigins: Array<string | RegExp> | undefined, currentOrigin: string) => (_url: URL | string) => {\n let url = _url;\n if (typeof url === 'string') {\n url = relativeToAbsoluteUrl(url, currentOrigin);\n }\n\n if (!allowedRedirectOrigins) {\n return true;\n }\n\n const isSameOrigin = currentOrigin === url.origin;\n\n const isAllowed =\n !isProblematicUrl(url) &&\n (isSameOrigin ||\n allowedRedirectOrigins\n .map(origin => (typeof origin === 'string' ? globs.toRegexp(trimTrailingSlash(origin)) : origin))\n .some(origin => origin.test(trimTrailingSlash(url.origin))));\n\n if (!isAllowed) {\n logger.warnOnce(\n `Clerk: Redirect URL ${url} is not on one of the allowedRedirectOrigins, falling back to the default redirect URL.`,\n );\n }\n return isAllowed;\n };\n\nexport function createAllowedRedirectOrigins(\n allowedRedirectOrigins: Array<string | RegExp> | undefined,\n frontendApi: string,\n instanceType?: string,\n): (string | RegExp)[] | undefined {\n if (Array.isArray(allowedRedirectOrigins) && !!allowedRedirectOrigins.length) {\n return allowedRedirectOrigins;\n }\n\n const origins: string[] = [];\n if (typeof window !== 'undefined' && !!window.location) {\n origins.push(window.location.origin);\n }\n\n origins.push(`https://${getETLDPlusOneFromFrontendApi(frontendApi)}`);\n origins.push(`https://*.${getETLDPlusOneFromFrontendApi(frontendApi)}`);\n\n if (instanceType === 'development') {\n origins.push(`https://${frontendApi}`);\n }\n\n return origins;\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,iBAAiB;AAEvB,MAAM,uBAAuB,CAAC,aAAa;AAG3C,MAAM,wBAAwB;CAAC;CAAe;CAAS;CAAa;AAAO;AAE3E,MAAM,EAAE,sBAAsBA,wCAA2B;AAEzD,MAAM,qCAAqB,IAAI,IAAqB;AAEpD,SAAgB,yBAAyB,WAAmB,OAAO,SAAS,UAAmB;CAC7F,IAAI,CAAC,UACH,OAAO;CAGT,IAAI,MAAM,mBAAmB,IAAI,QAAQ;CAEzC,IAAI,QAAQ,QAAW;EACrB,MAAMC,2CAA+B,QAAQ,KAAKC,4CAAgC,QAAQ;EAC1F,mBAAmB,IAAI,UAAU,GAAG;CACtC;CAEA,OAAO;AACT;AAEA,SAAgB,8BAA8B,aAA6B;CACzE,OAAO,YAAY,QAAQ,UAAU,EAAE;AACzC;AAoCA,SAAgB,SAAS,QAAwB,UAAoC,CAAC,GAAiB;CACrG,MAAM,EAAE,MAAM,UAAU,YAAY,cAAc,kBAAkB,GAAG,SAAS;CAEhF,IAAI,eAAe;CAInB,IAAI,OAAO,WAAW,eAAe,CAAC,CAAC,OAAO,UAC5C,eAAe,OAAO,SAAS;MAE/B,eAAe;CAGjB,MAAM,MAAM,IAAI,IAAI,QAAQ,IAAI,YAAY;CAG5C,IAAI,wBAAwB,iBAC1B,aAAa,SAAS,OAAO,QAAQ;EACnC,IAAI,UAAU,QAAQ,UAAU,QAC9B,IAAI,aAAa,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CAAC,OAAO,UAC5C,QAAQ,KAAK,OAAO,SAAS,MAAM;CAGrC,QAAQ,KAAK,WAAW,8BAA8B,WAAW,GAAG;CACpE,QAAQ,KAAK,aAAa,8BAA8B,WAAW,GAAG;CAEtE,IAAI,iBAAiB,eACnB,QAAQ,KAAK,WAAW,aAAa;CAGvC,OAAO;AACT"}
|
|
@@ -223,6 +223,11 @@ const mergeFragmentIntoUrl = (_url) => {
|
|
|
223
223
|
const pathFromFullPath = (fullPath) => {
|
|
224
224
|
return fullPath.replace(/CLERK-ROUTER\/(.*?)\//, "");
|
|
225
225
|
};
|
|
226
|
+
const VIRTUAL_ROUTER_BASE_PATH = "CLERK-ROUTER/VIRTUAL";
|
|
227
|
+
/**
|
|
228
|
+
* Whether `to` addresses the in-memory component router rather than a real application route.
|
|
229
|
+
*/
|
|
230
|
+
const isVirtualRouterPath = (to) => to.includes(VIRTUAL_ROUTER_BASE_PATH);
|
|
226
231
|
const frontendApiRedirectPathsWithUserInput = ["/oauth/authorize"];
|
|
227
232
|
const frontendApiRedirectPathsNoUserInput = [
|
|
228
233
|
"/v1/verify",
|
|
@@ -260,5 +265,5 @@ function createAllowedRedirectOrigins(allowedRedirectOrigins, frontendApi, insta
|
|
|
260
265
|
}
|
|
261
266
|
|
|
262
267
|
//#endregion
|
|
263
|
-
export { buildURL, createAllowedRedirectOrigins, getETLDPlusOneFromFrontendApi, getSearchParameterFromHash, hasBannedHrefProtocol, hasBannedProtocol, hasExternalAccountSignUpError, hasUrlInFragment, isAllowedRedirect, isDataUri, isDevAccountPortalOrigin, isDevOrStagingUrl, isProblematicUrl, isRedirectForFAPIInitiatedFlow, isValidUrl, mergeFragmentIntoUrl, pathFromFullPath, relativeToAbsoluteUrl, requiresUserInput, sanitizeHref, stripOrigin, toURL, trimLeadingSlash, trimTrailingSlash };
|
|
268
|
+
export { VIRTUAL_ROUTER_BASE_PATH, buildURL, createAllowedRedirectOrigins, getETLDPlusOneFromFrontendApi, getSearchParameterFromHash, hasBannedHrefProtocol, hasBannedProtocol, hasExternalAccountSignUpError, hasUrlInFragment, isAllowedRedirect, isDataUri, isDevAccountPortalOrigin, isDevOrStagingUrl, isProblematicUrl, isRedirectForFAPIInitiatedFlow, isValidUrl, isVirtualRouterPath, mergeFragmentIntoUrl, pathFromFullPath, relativeToAbsoluteUrl, requiresUserInput, sanitizeHref, stripOrigin, toURL, trimLeadingSlash, trimTrailingSlash };
|
|
264
269
|
//# sourceMappingURL=url.mjs.map
|