@auth0/auth0-server-js 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +67 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -3
- package/dist/index.d.ts +69 -3
- package/dist/index.js +65 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/state/utils.ts","../src/server-client.ts","../src/utils.ts","../src/telemetry.ts","../src/mfa/server-mfa-client.ts","../src/encryption/index.ts","../src/store/abstract-store.ts","../src/store/abstract-state-store.ts","../src/store/abstract-transaction-store.ts","../src/store/cookie-transaction-store.ts","../src/store/abstract-session-store.ts","../src/store/stateful-state-store.ts","../src/store/stateless-state-store.ts","../src/mfa/index.ts"],"sourcesContent":["/**\n * Error thrown when there is no transaction available.\n */\nexport class MissingTransactionError extends Error {\n public code: string = 'missing_transaction_error';\n\n constructor(message?: string) {\n super(message ?? 'The transaction is missing.');\n this.name = 'MissingTransactionError';\n }\n}\n\n\n/**\n * Error thrown when backchannel logout fails.\n */\nexport class BackchannelLogoutError extends Error {\n public code: string = 'backchannel_logout_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'BackchannelLogoutError';\n }\n}\n\n/**\n * Error thrown when starting the user-linking failed.\n */\nexport class StartLinkUserError extends Error {\n public code: string = 'start_link_user_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'StartLinkUserError';\n }\n}\n\n/**\n * Error thrown when a required argument is missing.\n */\nexport class MissingRequiredArgumentError extends Error {\n public code: string = 'missing_required_argument_error';\n\n constructor(argument: string) {\n super(`The argument '${argument}' is required but was not provided.`);\n this.name = 'MissingRequiredArgumentError';\n }\n}\n\n/**\n * Error thrown when a session is missing.\n */\nexport class MissingSessionError extends Error {\n public code: string = 'missing_session_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'MissingSessionError';\n }\n}\n\n/**\n * Error thrown when a configuration is invalid.\n */\nexport class InvalidConfigurationError extends Error {\n public code: string = 'invalid_configuration_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'InvalidConfigurationError';\n }\n}\n\n/**\n * Error thrown when the issuer validation fails.\n */\nexport class IssuerValidationError extends Error {\n public code: string = 'issuer_validation_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'IssuerValidationError';\n }\n}\n","import type { AccessTokenForConnectionOptions, StateData } from '../types.js';\nimport { TokenResponse } from '@auth0/auth0-auth-js';\n\n/**\n * Creates an updated token set object from the token endpoint response\n * @param audience The audience for which the token was requested\n * @param response The response from the token endpoint\n * @returns Updated token set object\n */\nconst createUpdatedTokenSet = (audience: string, response: TokenResponse) => ({\n audience,\n accessToken: response.accessToken,\n scope: response.scope,\n expiresAt: response.expiresAt,\n});\n\n/**\n * Utility function to update the state with a new response from the token endpoint\n * @param audience The audience of the token endpoint response\n * @param stateData The existing state data to update, or undefined if no state data available.\n * @param tokenEndpointResponse The response from the token endpoint.\n * @returns Updated state data.\n */\nexport function updateStateData(\n audience: string,\n stateData: StateData | undefined,\n tokenEndpointResponse: TokenResponse,\n context?: { domain?: string }\n): StateData {\n // If we already have a session and the new token belongs to a different user (iss or sub mismatch),\n // wipe the existing state to start a fresh session. This handles the case where a user logs in\n // as a different user without explicitly logging out first.\n if (stateData && tokenEndpointResponse.claims) {\n const newSub = tokenEndpointResponse.claims.sub;\n const newIss = tokenEndpointResponse.claims.iss;\n const existingSub = stateData.user?.sub;\n const existingIss = stateData.user?.iss;\n\n const subMismatch = newSub !== undefined && existingSub !== undefined && newSub !== existingSub;\n const issMismatch = newIss !== undefined && existingIss !== undefined && newIss !== existingIss;\n\n if (subMismatch || issMismatch) {\n stateData = undefined;\n }\n }\n\n if (stateData) {\n const isNewTokenSet = !stateData.tokenSets.some(\n (tokenSet) => tokenSet.audience === audience && tokenSet.scope === tokenEndpointResponse.scope\n );\n\n const tokenSets = isNewTokenSet\n ? [...stateData.tokenSets, createUpdatedTokenSet(audience, tokenEndpointResponse)]\n : stateData.tokenSets.map((tokenSet) =>\n tokenSet.audience === audience && tokenSet.scope === tokenEndpointResponse.scope\n ? createUpdatedTokenSet(audience, tokenEndpointResponse)\n : tokenSet\n );\n\n return {\n ...stateData,\n idToken: tokenEndpointResponse.idToken ?? stateData.idToken,\n refreshToken: tokenEndpointResponse.refreshToken ?? stateData.refreshToken,\n tokenSets,\n domain: context?.domain ?? stateData.domain,\n };\n } else {\n const user = tokenEndpointResponse.claims;\n return {\n user,\n idToken: tokenEndpointResponse.idToken,\n refreshToken: tokenEndpointResponse.refreshToken,\n tokenSets: [createUpdatedTokenSet(audience, tokenEndpointResponse)],\n domain: context?.domain,\n internal: {\n sid: user?.sid as string,\n createdAt: Math.floor(Date.now() / 1000),\n },\n };\n }\n}\n\nexport function updateStateDataForConnectionTokenSet(\n options: AccessTokenForConnectionOptions,\n stateData: StateData,\n tokenEndpointResponse: TokenResponse\n) {\n stateData.connectionTokenSets = stateData.connectionTokenSets || [];\n\n const isNewTokenSet = !stateData.connectionTokenSets.some(\n (tokenSet) =>\n tokenSet.connection === options.connection && (!options.loginHint || tokenSet.loginHint === options.loginHint)\n );\n\n const connectionTokenSet = {\n connection: options.connection,\n loginHint: options.loginHint,\n accessToken: tokenEndpointResponse.accessToken,\n scope: tokenEndpointResponse.scope,\n expiresAt: tokenEndpointResponse.expiresAt,\n };\n\n const connectionTokenSets = isNewTokenSet\n ? [...stateData.connectionTokenSets, connectionTokenSet]\n : stateData.connectionTokenSets.map((tokenSet) =>\n tokenSet.connection === options.connection && (!options.loginHint || tokenSet.loginHint === options.loginHint)\n ? connectionTokenSet\n : tokenSet\n );\n\n return {\n ...stateData,\n connectionTokenSets,\n };\n}\n","import {\n AccessTokenForConnectionOptions,\n ConnectionTokenSet,\n DomainResolver,\n LoginBackchannelOptions,\n LoginBackchannelResult,\n LogoutOptions,\n ServerClientOptions,\n SessionData,\n StartInteractiveLoginOptions,\n StartLinkUserOptions,\n StartUnlinkUserOptions,\n StateData,\n StateStore,\n TokenSet,\n TransactionData,\n TransactionStore,\n} from './types.js';\nimport {\n BackchannelLogoutError,\n InvalidConfigurationError,\n MissingRequiredArgumentError,\n MissingSessionError,\n MissingTransactionError,\n} from './errors.js';\nimport { updateStateData, updateStateDataForConnectionTokenSet } from './state/utils.js';\nimport {\n TokenForConnectionError,\n AuthClient,\n AuthorizationDetails,\n TokenByRefreshTokenError,\n} from '@auth0/auth0-auth-js';\nimport { compareScopes } from './utils.js';\nimport { decodeJwt } from 'jose';\nimport type { AuthClientOptions } from '@auth0/auth0-auth-js';\nimport { getTelemetryConfig } from './telemetry.js';\nimport { ServerMfaClient } from './mfa/server-mfa-client.js';\n\nconst DEFAULT_SCOPES = 'openid profile email offline_access';\n\nconst normalizeDomain = (value: string) => {\n const trimmed = value.trim();\n const parsed = trimmed.startsWith('http') ? new URL(trimmed) : new URL(`https://${trimmed}`);\n return parsed.host.toLowerCase();\n};\n\nconst decodeIssuer = (token: string) => {\n try {\n const { iss } = decodeJwt(token);\n return typeof iss === 'string' ? iss : undefined;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Ensures that the \"openid\" scope is always included in the scope string.\n *\n * @param scope - The scope provided by the user (optional)\n * @returns A scope string that includes \"openid\" if it was not already present.\n */\nconst ensureOpenIdScope = (scope?: string) => {\n if (!scope) {\n return DEFAULT_SCOPES;\n }\n\n const scopes = scope.split(' ');\n if (!scopes.includes('openid')) {\n scopes.unshift('openid');\n }\n\n return scopes.join(' ');\n};\n\nexport class ServerClient<TStoreOptions = unknown> {\n readonly #options: ServerClientOptions<TStoreOptions>;\n readonly #transactionStore: TransactionStore<TStoreOptions>;\n readonly #transactionStoreIdentifier: string;\n readonly #stateStore: StateStore<TStoreOptions>;\n readonly #stateStoreIdentifier: string;\n readonly #authClientOptions: Omit<AuthClientOptions, 'domain'>;\n readonly #staticDomain?: string;\n readonly #authClient?: AuthClient;\n readonly #mfaClient?: ServerMfaClient<TStoreOptions>;\n\n /**\n * The underlying `authClient` instance that can be used to interact with the Auth0 Authentication API.\n * Generally, you should prefer to use the higher-level methods exposed on the `ServerClient` instance.\n *\n * This property can only be used when `domain` is configured as a static string.\n * In resolver mode (`domain` as a function), the SDK resolves the domain per request,\n * so use `ServerClient` methods instead.\n *\n * Important: the methods exposed on the `authClient` instance do not handle any session or state management.\n */\n public get authClient(): AuthClient {\n if (!this.#authClient) {\n throw new InvalidConfigurationError('authClient is only available when using a static domain configuration.');\n }\n return this.#authClient;\n }\n\n /**\n * The MFA client for managing multi-factor authentication operations.\n *\n * Provides methods to list, enroll, and challenge MFA authenticators,\n * as well as verify MFA challenges to complete authentication.\n *\n * The `verify` method integrates with the session state store, persisting tokens\n * and user data after successful MFA verification.\n *\n * This property can only be used when `domain` is configured as a static string.\n * In resolver mode (`domain` as a function), MFA is not supported.\n */\n public get mfa(): ServerMfaClient<TStoreOptions> {\n if (!this.#mfaClient) {\n throw new InvalidConfigurationError('mfa is only available when using a static domain configuration.');\n }\n return this.#mfaClient;\n }\n\n constructor(options: ServerClientOptions<TStoreOptions>) {\n this.#options = options;\n this.#stateStoreIdentifier = this.#options.stateIdentifier || '__a0_session';\n this.#transactionStoreIdentifier = this.#options.transactionIdentifier || '__a0_tx';\n this.#transactionStore = options.transactionStore;\n this.#stateStore = options.stateStore;\n\n if (!this.#options.stateStore) {\n throw new MissingRequiredArgumentError('stateStore');\n }\n\n if (!this.#options.transactionStore) {\n throw new MissingRequiredArgumentError('transactionStore');\n }\n\n if (typeof this.#options.domain !== 'string' && typeof this.#options.domain !== 'function') {\n throw new InvalidConfigurationError('domain must be a string or resolver function');\n }\n\n this.#authClientOptions = {\n clientId: this.#options.clientId,\n clientSecret: this.#options.clientSecret,\n clientAssertionSigningKey: this.#options.clientAssertionSigningKey,\n clientAssertionSigningAlg: this.#options.clientAssertionSigningAlg,\n authorizationParams: this.#options.authorizationParams,\n discoveryCache: this.#options.discoveryCache,\n customFetch: this.#options.customFetch,\n useMtls: this.#options.useMtls,\n };\n\n if (typeof this.#options.domain === 'string') {\n const domain = normalizeDomain(this.#options.domain);\n this.#staticDomain = domain;\n this.#authClient = new AuthClient({\n domain,\n ...this.#authClientOptions,\n telemetry: getTelemetryConfig(this.#options.telemetry),\n });\n\n this.#mfaClient = new ServerMfaClient({\n authClient: this.#authClient,\n domain,\n stateStore: this.#stateStore,\n stateStoreIdentifier: this.#stateStoreIdentifier,\n defaultAudience: this.#options.authorizationParams?.audience ?? 'default',\n });\n }\n }\n\n async #resolveDomain(storeOptions?: TStoreOptions): Promise<string> {\n if (typeof this.#options.domain === 'function') {\n const resolved = await (this.#options.domain as DomainResolver<TStoreOptions>)(storeOptions);\n if (typeof resolved !== 'string' || resolved.trim().length === 0) {\n throw new InvalidConfigurationError('domainResolver returned no domain');\n }\n return normalizeDomain(resolved);\n }\n\n return normalizeDomain(this.#options.domain);\n }\n\n #createAuthClient(domain: string): AuthClient {\n return new AuthClient({\n domain,\n ...this.#authClientOptions,\n telemetry: getTelemetryConfig(this.#options.telemetry),\n });\n }\n\n #getAuthClient(domain: string): AuthClient {\n const normalizedDomain = normalizeDomain(domain);\n if (this.#authClient && this.#staticDomain === normalizedDomain) {\n return this.#authClient;\n }\n return this.#createAuthClient(normalizedDomain);\n }\n\n #getSessionDomain(stateData: StateData): string | undefined {\n if (stateData.domain) {\n return normalizeDomain(stateData.domain);\n }\n\n if (this.#staticDomain) {\n return this.#staticDomain;\n }\n\n // Legacy sessions may not have `domain` persisted yet; infer it from ID token claims.\n const issuerFromClaims = stateData.user?.iss;\n if (typeof issuerFromClaims === 'string' && issuerFromClaims.trim().length > 0) {\n return normalizeDomain(issuerFromClaims);\n }\n\n return;\n }\n\n #isResolverMode(): boolean {\n return typeof this.#options.domain === 'function';\n }\n\n async #isSessionForCurrentDomain(stateData: StateData, storeOptions?: TStoreOptions): Promise<boolean> {\n const sessionDomain = this.#getSessionDomain(stateData);\n if (!sessionDomain) {\n return false;\n }\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n return sessionDomain === resolvedDomain;\n }\n\n /**\n * Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.\n * @param options Optional options used to configure the interactive login process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {BuildAuthorizationUrlError} If there was an issue when building the Authorization URL.\n *\n * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.\n */\n public async startInteractiveLogin(options?: StartInteractiveLoginOptions, storeOptions?: TStoreOptions) {\n const redirectUri = options?.authorizationParams?.redirect_uri ?? this.#options.authorizationParams?.redirect_uri;\n if (!redirectUri) {\n throw new MissingRequiredArgumentError('authorizationParams.redirect_uri');\n }\n\n const scope = ensureOpenIdScope(options?.authorizationParams?.scope ?? this.#options.authorizationParams?.scope);\n\n const domain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(domain);\n const { codeVerifier, authorizationUrl } = await authClient.buildAuthorizationUrl({\n pushedAuthorizationRequests: options?.pushedAuthorizationRequests,\n authorizationParams: {\n ...options?.authorizationParams,\n redirect_uri: redirectUri,\n scope,\n },\n });\n\n const transactionState: TransactionData = {\n audience: options?.authorizationParams?.audience ?? this.#options.authorizationParams?.audience,\n codeVerifier,\n domain,\n };\n\n if (options?.appState) {\n transactionState.appState = options.appState;\n }\n\n await this.#transactionStore.set(this.#transactionStoreIdentifier, transactionState, false, storeOptions);\n\n return authorizationUrl;\n }\n\n /**\n * Completes the interactive login process.\n * Takes an URL, extract the Authorization Code flow query parameters and requests a token.\n * @param url The URl from which the query params should be extracted to exchange for a token.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingTransactionError} When no transaction was found.\n * @throws {TokenByCodeError} If there was an issue requesting the access token.\n *\n * @returns A promise resolving to an object, containing the original appState (if present) and the authorizationDetails (when RAR was used).\n */\n public async completeInteractiveLogin<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions) {\n const transactionData = await this.#transactionStore.get(this.#transactionStoreIdentifier, storeOptions);\n\n if (!transactionData) {\n throw new MissingTransactionError();\n }\n\n const domain = transactionData.domain ?? (await this.#resolveDomain(storeOptions));\n const authClient = this.#getAuthClient(domain);\n const tokenEndpointResponse = await authClient.getTokenByCode(url, {\n codeVerifier: transactionData.codeVerifier,\n });\n\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const stateData = updateStateData(transactionData.audience ?? 'default', existingStateData, tokenEndpointResponse, {\n domain,\n });\n\n await this.#stateStore.set(this.#stateStoreIdentifier, stateData, true, storeOptions);\n await this.#transactionStore.delete(this.#transactionStoreIdentifier, storeOptions);\n\n return { appState: transactionData.appState, authorizationDetails: tokenEndpointResponse.authorizationDetails } as {\n appState?: TAppState;\n authorizationDetails?: AuthorizationDetails[];\n };\n }\n\n /**\n * Starts the user linking process, and returns a URL to redirect the user-agent to to request authorization at Auth0.\n * @param options Options used to configure the user linking process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingSessionError} If there is no active session.\n * @throws {BuildLinkUserUrlError} If there was an issue when building the Authorization URL.\n *\n * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.\n */\n public async startLinkUser(options: StartLinkUserOptions, storeOptions?: TStoreOptions) {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (!stateData || !stateData.idToken) {\n throw new MissingSessionError(\n 'Unable to start the user linking process without a logged in user. Ensure to login using the SDK before starting the user linking process.'\n );\n }\n\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const domain = this.#getSessionDomain(stateData)!;\n const authClient = this.#getAuthClient(domain);\n const { linkUserUrl, codeVerifier } = await authClient.buildLinkUserUrl({\n connection: options.connection,\n connectionScope: options.connectionScope,\n idToken: stateData.idToken,\n authorizationParams: options.authorizationParams,\n });\n\n const transactionState: TransactionData = {\n audience: options?.authorizationParams?.audience ?? this.#options.authorizationParams?.audience,\n codeVerifier,\n domain,\n };\n\n if (options?.appState) {\n transactionState.appState = options.appState;\n }\n\n await this.#transactionStore.set(this.#transactionStoreIdentifier, transactionState, false, storeOptions);\n\n return linkUserUrl;\n }\n\n /**\n * Completes the user linking process.\n * Takes an URL, extract the Authorization Code flow query parameters and requests a token.\n * @param url The URl from which the query params should be extracted to exchange for a token.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingTransactionError} When no transaction was found.\n * @throws {TokenByCodeError} If there was an issue requesting the access token.\n *\n * @returns A promise resolving to an object, containing the original appState (if present).\n */\n public async completeLinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions) {\n // In order to complete the link user flow, we need to exchange the code for a token in the same\n // way as we do for the interactive login flow.\n const result = await this.completeInteractiveLogin<TAppState>(url, storeOptions);\n\n // As we currently do not support RAR when starting the user linking flow, we will ommit it from being returned as optional altogether.\n return {\n appState: result.appState,\n };\n }\n\n /**\n * Starts the user unlinking process, and returns a URL to redirect the user-agent to to initialize user unlinking at Auth0.\n * @param options Options used to configure the user unlinking process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingSessionError} If there is no active session.\n * @throws {BuildUnlinkUserUrlError} If there was an issue when building the User Unlinking URL.\n *\n * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.\n */\n public async startUnlinkUser(options: StartUnlinkUserOptions, storeOptions?: TStoreOptions) {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (!stateData || !stateData.idToken) {\n throw new MissingSessionError(\n 'Unable to start the user unlinking process without a logged in user. Ensure to login using the SDK before starting the user unlinking process.'\n );\n }\n\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const domain = this.#getSessionDomain(stateData)!;\n const authClient = this.#getAuthClient(domain);\n const { unlinkUserUrl, codeVerifier } = await authClient.buildUnlinkUserUrl({\n connection: options.connection,\n idToken: stateData.idToken,\n authorizationParams: options.authorizationParams,\n });\n\n const transactionState: TransactionData = {\n audience: options?.authorizationParams?.audience ?? this.#options.authorizationParams?.audience,\n codeVerifier,\n domain,\n };\n\n if (options?.appState) {\n transactionState.appState = options.appState;\n }\n\n await this.#transactionStore.set(this.#transactionStoreIdentifier, transactionState, false, storeOptions);\n\n return unlinkUserUrl;\n }\n\n /**\n * Completes the user unlinking process.\n * Takes an URL, extract the Authorization Code flow query parameters and requests a token.\n * @param url The URl from which the query params should be extracted to exchange for a token.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingTransactionError} When no transaction was found.\n * @throws {TokenByCodeError} If there was an issue requesting the access token.\n *\n * @returns A promise resolving to an object, containing the original appState (if present).\n */\n public async completeUnlinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions) {\n // In order to complete the link user flow, we need to exchange the code for a token in the same\n // way as we do for the interactive login flow.\n const result = await this.completeInteractiveLogin<TAppState>(url, storeOptions);\n\n // As we currently do not support RAR when starting the user unlinking flow, we will ommit it from being returned as optional altogether.\n return {\n appState: result.appState,\n };\n }\n\n /**\n * Logs in using Client-Initiated Backchannel Authentication.\n *\n * Using Client-Initiated Backchannel Authentication requires the feature to be enabled in the Auth0 dashboard.\n * @see https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-initiated-backchannel-authentication-flow\n * @param options Options used to configure the backchannel login process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {BackchannelAuthenticationError} If there was an issue when doing backchannel authentication.\n *\n * @returns A promise resolving to an object, containing the authorizationDetails (when RAR was used).\n */\n public async loginBackchannel(\n options: LoginBackchannelOptions,\n storeOptions?: TStoreOptions\n ): Promise<LoginBackchannelResult> {\n const scope = ensureOpenIdScope(options.authorizationParams?.scope ?? this.#options.authorizationParams?.scope);\n const domain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(domain);\n const tokenEndpointResponse = await authClient.backchannelAuthentication({\n bindingMessage: options.bindingMessage,\n loginHint: options.loginHint,\n authorizationParams: {\n ...options.authorizationParams,\n scope,\n },\n });\n\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n const stateData = updateStateData(\n this.#options.authorizationParams?.audience ?? 'default',\n existingStateData,\n tokenEndpointResponse,\n { domain }\n );\n\n await this.#stateStore.set(this.#stateStoreIdentifier, stateData, true, storeOptions);\n\n return {\n authorizationDetails: tokenEndpointResponse.authorizationDetails,\n };\n }\n\n /**\n * Retrieves the user from the store, or undefined if no user found.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n * @returns The user, or undefined if no user found in the store.\n */\n public async getUser(storeOptions?: TStoreOptions) {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (!stateData) {\n return;\n }\n\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n return;\n }\n }\n\n return stateData.user;\n }\n\n /**\n * Retrieve the user session from the store, or undefined if no session found.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n * @returns The session or undefined if no session found in the store.\n */\n public async getSession(storeOptions?: TStoreOptions): Promise<SessionData | undefined> {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (stateData) {\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n return;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { internal, ...sessionData } = stateData;\n return sessionData;\n }\n }\n\n /**\n * Retrieves the access token from the store, or calls Auth0 when the access token is expired and a refresh token is available in the store.\n * Also updates the store when a new token was retrieved from Auth0.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {TokenByRefreshTokenError} If the refresh token was not found or there was an issue requesting the access token. When the cause is `mfa_required`, use `isMfaRequiredError(error)` to narrow the error and read `cause.mfa_token`.\n *\n * @returns The Token Set, containing the access token, as well as additional information.\n */\n public async getAccessToken(storeOptions?: TStoreOptions): Promise<TokenSet> {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const audience = this.#options.authorizationParams?.audience ?? 'default';\n const scope = this.#options.authorizationParams?.scope;\n\n const sessionDomain = stateData ? this.#getSessionDomain(stateData) : this.#staticDomain;\n if (this.#isResolverMode()) {\n if (!stateData) {\n throw new MissingSessionError('Unable to retrieve access token without a logged in user.');\n }\n if (!sessionDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n if (sessionDomain !== resolvedDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const tokenSet = stateData?.tokenSets.find(\n (tokenSet) => tokenSet.audience === audience && (!scope || compareScopes(tokenSet.scope, scope))\n );\n\n if (tokenSet && tokenSet.expiresAt > Date.now() / 1000) {\n return tokenSet;\n }\n\n if (!stateData?.refreshToken) {\n throw new TokenByRefreshTokenError(\n 'The access token has expired and a refresh token was not provided. The user needs to re-authenticate.'\n );\n }\n\n const domainForSession = sessionDomain!;\n const tokenEndpointResponse = await this.#getAuthClient(domainForSession).getTokenByRefreshToken({\n refreshToken: stateData.refreshToken,\n });\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const updatedStateData = updateStateData(audience, existingStateData, tokenEndpointResponse, {\n domain: domainForSession,\n });\n\n await this.#stateStore.set(this.#stateStoreIdentifier, updatedStateData, false, storeOptions);\n\n return {\n accessToken: tokenEndpointResponse.accessToken,\n scope: tokenEndpointResponse.scope,\n expiresAt: tokenEndpointResponse.expiresAt,\n audience: audience,\n };\n }\n\n /**\n * Retrieves an access token for a connection.\n *\n * This method attempts to obtain an access token for a specified connection.\n * It first checks if a refresh token exists in the store.\n * If no refresh token is found, it throws an `AccessTokenForConnectionError` indicating\n * that the refresh token was not found.\n *\n * @param options - Options for retrieving an access token for a connection.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {TokenForConnectionError} If the refresh token was not found or there was an issue requesting the access token.\n *\n * @returns The Connection Token Set, containing the access token for the connection, as well as additional information.\n */\n public async getAccessTokenForConnection(\n options: AccessTokenForConnectionOptions,\n storeOptions?: TStoreOptions\n ): Promise<ConnectionTokenSet> {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n const sessionDomain = stateData ? this.#getSessionDomain(stateData) : this.#staticDomain;\n if (this.#isResolverMode()) {\n if (!stateData) {\n throw new MissingSessionError('Unable to retrieve an access token for a connection without a logged in user.');\n }\n if (!sessionDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n if (sessionDomain !== resolvedDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const connectionTokenSet = stateData?.connectionTokenSets?.find(\n (tokenSet) => tokenSet.connection === options.connection\n );\n\n if (connectionTokenSet && connectionTokenSet.expiresAt > Date.now() / 1000) {\n return connectionTokenSet;\n }\n\n if (!stateData?.refreshToken) {\n throw new TokenForConnectionError(\n 'A refresh token was not found but is required to be able to retrieve an access token for a connection.'\n );\n }\n\n const domainForSession = sessionDomain!;\n const tokenEndpointResponse = await this.#getAuthClient(domainForSession).getTokenForConnection({\n connection: options.connection,\n loginHint: options.loginHint,\n refreshToken: stateData.refreshToken,\n });\n\n const updatedStateData = updateStateDataForConnectionTokenSet(\n options,\n {\n ...stateData,\n domain: stateData.domain ?? domainForSession,\n },\n tokenEndpointResponse\n );\n\n await this.#stateStore.set(this.#stateStoreIdentifier, updatedStateData, false, storeOptions);\n\n return {\n accessToken: tokenEndpointResponse.accessToken,\n scope: tokenEndpointResponse.scope,\n expiresAt: tokenEndpointResponse.expiresAt,\n connection: options.connection,\n loginHint: options.loginHint,\n };\n }\n\n /**\n * Logs the user out and returns a URL to redirect the user-agent to after they log out.\n * @param options Options used to configure the logout process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n * @returns {URL}\n */\n public async logout(options: LogoutOptions, storeOptions?: TStoreOptions) {\n if (!this.#isResolverMode()) {\n await this.#stateStore.delete(this.#stateStoreIdentifier, storeOptions);\n return this.authClient.buildLogoutUrl(options);\n }\n\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(resolvedDomain);\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const sessionDomain = stateData ? this.#getSessionDomain(stateData) : undefined;\n\n if (!stateData) {\n // No local session, still return a logout URL for the current domain.\n return authClient.buildLogoutUrl(options);\n }\n\n if (sessionDomain && sessionDomain === resolvedDomain) {\n await this.#stateStore.delete(this.#stateStoreIdentifier, storeOptions);\n }\n\n return authClient.buildLogoutUrl(options);\n }\n\n /**\n * Handles the backchannel logout process by verifying the logout token and deleting the session from the store if the logout token was considered valid.\n * @param logoutToken The logout token to verify and use to delete the session from the store.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {BackchannelLogoutError} If the logout token is missing.\n * @throws {VerifyLogoutTokenError} If the logout token is invalid.\n */\n public async handleBackchannelLogout(logoutToken: string, storeOptions?: TStoreOptions) {\n if (!logoutToken) {\n throw new BackchannelLogoutError('Missing Logout Token');\n }\n\n if (!this.#isResolverMode()) {\n const logoutTokenClaims = await this.authClient.verifyLogoutToken({ logoutToken });\n await this.#stateStore.deleteByLogoutToken(logoutTokenClaims, storeOptions);\n return;\n }\n\n const issuer = decodeIssuer(logoutToken);\n if (!issuer) {\n throw new BackchannelLogoutError('Logout token is missing an issuer');\n }\n\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n const domain = normalizeDomain(issuer);\n if (domain !== resolvedDomain) {\n throw new BackchannelLogoutError('Logout token issuer does not match the resolved domain');\n }\n\n const authClient = this.#getAuthClient(domain);\n const logoutTokenClaims = await authClient.verifyLogoutToken({ logoutToken });\n\n await this.#stateStore.deleteByLogoutToken({ ...logoutTokenClaims, iss: issuer }, storeOptions);\n }\n}\n","/**\n * Compares two sets of scopes to determine if all required scopes are present in the provided scopes.\n * @param scopes Scopes to compare\n * @param requiredScopes Scopes required to be present in the scopes\n * @returns True if all required scopes are present in the scopes, false otherwise\n */\nexport const compareScopes = (scopes: string | undefined, requiredScopes: string | undefined) => {\n // When the scopes and requiredScopes are exactly the same, return true\n // This handles cases where both are empty or undefined or both are the same string\n if (scopes === requiredScopes) {\n return true;\n }\n\n if (!scopes || !requiredScopes) {\n return false;\n }\n\n const scopesSet = new Set(scopes.trim().split(' ').filter(Boolean));\n const requiredScopesArray = requiredScopes.trim().split(' ').filter(Boolean);\n\n return requiredScopesArray.every((scope) => scopesSet.has(scope));\n};\n","import { TelemetryConfig } from '@auth0/auth0-auth-js';\n\n// These constants are injected at build time via tsup\ndeclare const __AUTH0_SERVER_JS_PACKAGE_NAME__: string;\ndeclare const __AUTH0_SERVER_JS_PACKAGE_VERSION__: string;\n\nexport function getTelemetryConfig(config?: TelemetryConfig): TelemetryConfig {\n if (config?.enabled === false) {\n return config;\n }\n\n return {\n enabled: true,\n name: config?.name ?? __AUTH0_SERVER_JS_PACKAGE_NAME__,\n version: config?.version ?? __AUTH0_SERVER_JS_PACKAGE_VERSION__,\n };\n}\n","import { updateStateData } from '../state/utils.js';\nimport type { ServerMfaClientOptions, MfaVerifyResponse } from './types.js';\nimport type {\n ListAuthenticatorsOptions,\n AuthenticatorResponse,\n EnrollAuthenticatorOptions,\n EnrollmentResponse,\n ChallengeOptions,\n ChallengeResponse,\n MfaVerifyOptions,\n} from '@auth0/auth0-auth-js';\n\nexport class ServerMfaClient<TStoreOptions = unknown> {\n readonly #options: ServerMfaClientOptions<TStoreOptions>;\n\n /**\n * @internal\n */\n constructor(options: ServerMfaClientOptions<TStoreOptions>) {\n this.#options = options;\n }\n\n /**\n * Lists all MFA authenticators enrolled by the user.\n *\n * @param options - Options for listing authenticators\n * @returns Promise resolving to an array of enrolled authenticators\n * @throws {MfaListAuthenticatorsError} When the request fails\n */\n async listAuthenticators(options: ListAuthenticatorsOptions): Promise<AuthenticatorResponse[]> {\n return this.#options.authClient.mfa.listAuthenticators(options);\n }\n\n /**\n * Enrolls a new MFA authenticator for the user.\n *\n * @param options - Enrollment options\n * @returns Promise resolving to enrollment response with authenticator details\n * @throws {MfaEnrollmentError} When enrollment fails\n */\n async enrollAuthenticator(options: EnrollAuthenticatorOptions): Promise<EnrollmentResponse> {\n return this.#options.authClient.mfa.enrollAuthenticator(options);\n }\n\n /**\n * Initiates an MFA challenge for user verification.\n *\n * @param options - Challenge options\n * @returns Promise resolving to challenge response with challenge details\n * @throws {MfaChallengeError} When the challenge fails\n */\n async challengeAuthenticator(options: ChallengeOptions): Promise<ChallengeResponse> {\n return this.#options.authClient.mfa.challengeAuthenticator(options);\n }\n\n /**\n * Verifies an MFA challenge and completes the authentication flow.\n *\n * Exchanges the MFA token and verification code for access, ID, and refresh tokens,\n * then saves them into the user's session automatically.\n *\n * @param options - The MFA token, factor type (otp / oob / recovery-code), and the code to verify\n * @param storeOptions - Optional options forwarded to the session store. Can be omitted when\n * using the built-in stores; required if your custom store needs extra context (e.g. a request object).\n * @returns The tokens returned by Auth0 after successful verification\n * @throws {MfaVerifyError} When verification fails (e.g. invalid token, wrong code)\n */\n async verify(options: MfaVerifyOptions, storeOptions?: TStoreOptions): Promise<MfaVerifyResponse> {\n const tokenResponse = await this.#options.authClient.mfa.verify(options);\n\n const audience = options.audience ?? this.#options.defaultAudience;\n const existingStateData = await this.#options.stateStore.get(\n this.#options.stateStoreIdentifier,\n storeOptions\n );\n\n const updatedStateData = updateStateData(audience, existingStateData, tokenResponse, {\n domain: this.#options.domain,\n });\n\n await this.#options.stateStore.set(\n this.#options.stateStoreIdentifier,\n updatedStateData,\n true,\n storeOptions\n );\n\n const result: MfaVerifyResponse = {\n accessToken: tokenResponse.accessToken,\n tokenType: tokenResponse.tokenType ?? 'bearer',\n expiresAt: tokenResponse.expiresAt,\n scope: tokenResponse.scope,\n };\n\n if (tokenResponse.idToken) result.idToken = tokenResponse.idToken;\n if (tokenResponse.refreshToken) result.refreshToken = tokenResponse.refreshToken;\n if (tokenResponse.recoveryCode) result.recoveryCode = tokenResponse.recoveryCode;\n\n return result;\n }\n}\n","import { EncryptJWT, jwtDecrypt, errors } from 'jose';\nimport type { JWTPayload } from 'jose';\nimport { InvalidConfigurationError } from '../errors.js';\n\nconst ENC = 'A256CBC-HS512';\nconst ALG = 'dir';\nconst DIGEST = 'SHA-256';\nconst BIT_LENGTH = 512;\nconst HKDF_INFO = 'derived cookie encryption secret';\n\nlet encoder: TextEncoder | undefined;\n\n/**\n * Type guard to determine if an error is a decryption-related error.\n * Decryption errors (JWEDecryptionFailed, JWEInvalid) indicate issues with the encryption key or data format.\n * These are distinct from claim validation errors (like expiration), which indicate a valid token with invalid claims.\n * @param e - The error thrown during decryption\n * @returns True if the error is a decryption error, false otherwise\n */\nexport function isDecryptionError(e: unknown): e is Error {\n return e instanceof errors.JWEDecryptionFailed || e instanceof errors.JWEInvalid;\n}\n\nasync function deriveEncryptionSecret(secret: string, salt: string, kid: string) {\n encoder ||= new TextEncoder();\n const key = await crypto.subtle.importKey('raw', encoder.encode(secret), 'HKDF', false, ['deriveBits']);\n\n return new Uint8Array(\n await crypto.subtle.deriveBits(\n {\n name: 'HKDF',\n hash: DIGEST,\n info: encoder.encode(HKDF_INFO),\n salt: encoder.encode(`${salt}${kid}`),\n } as HkdfParams,\n key,\n BIT_LENGTH\n )\n );\n}\n\n/**\n * Encrypts a payload using the provided secret and salt, with an expiration time.\n * @param payload The payload to encrypt.\n * @param secret The secret to use for encryption.\n * @param salt The salt to use for encryption.\n * @param expiration The expiration time for the encrypted payload.\n * @returns The encrypted payload.\n */\nasync function _encrypt(payload: JWTPayload, secret: string, salt: string, expiration: number) {\n const kid = crypto.randomUUID();\n const encryptionSecret = await deriveEncryptionSecret(secret, salt, kid);\n\n return await new EncryptJWT(payload)\n .setProtectedHeader({ enc: ENC, alg: ALG, kid: kid })\n .setExpirationTime(expiration)\n .encrypt(encryptionSecret);\n}\n\n/**\n * Encrypts a payload using the provided secret and salt, with an expiration time.\n * The secret can be a single string or an array of strings for secret rotation support.\n * When using an array of secrets, only the first one is used for encryption (all secrets are tried for decryption).\n * @param payload The payload to encrypt.\n * @param secret The secret(s) to use for encryption. Can be a single string or an array of strings for secret rotation support.\n * @param salt The salt to use for encryption.\n * @param expiration The expiration time for the encrypted payload.\n * @returns The encrypted payload.\n */\nexport async function encrypt(payload: JWTPayload, secret: string | string[], salt: string, expiration: number) {\n if (typeof secret === 'string') {\n return await _encrypt(payload, secret, salt, expiration);\n } else {\n // For encryption, we only use the newest secret, as the old secrets are only used for backward compatibility during decryption.\n const [newSecret] = secret;\n\n if (!newSecret) {\n throw new InvalidConfigurationError('At least one secret must be provided');\n }\n\n return await _encrypt(payload, newSecret, salt, expiration);\n }\n}\n\n/**\n * Decrypts an encrypted payload using the provided secret(s) and salt.\n * @param value The encrypted payload to decrypt.\n * @param secret The secret to use for decryption.\n * @param salt The salt to use for decryption.\n * @returns The decrypted payload.\n */\nexport async function _decrypt<T>(value: string, secret: string, salt: string) {\n const res = await jwtDecrypt<T>(\n value,\n async (protectedHeader) => {\n // This error shouldn't happen, as we always set a kid.\n // However, leaving this here as a safety net.\n if (!protectedHeader.kid) {\n throw new Error('Missing \"kid\" in JWE header');\n }\n\n return await deriveEncryptionSecret(secret, salt, protectedHeader.kid);\n },\n { clockTolerance: 15 }\n );\n return res.payload;\n}\n\n/**\n * Decrypts an encrypted payload using the provided secret(s) and salt.\n * The secret can be a single string or an array of strings for secret rotation support.\n * When using an array of secrets, the function will try to decrypt with each secret in order until it succeeds or exhausts all options.\n * Only decryption-related errors (JWEDecryptionFailed, JWEInvalid) will trigger fallback to old secrets.\n * Other errors (like expiration) will be thrown immediately.\n * @param value The encrypted payload to decrypt.\n * @param secret The secret(s) to use for decryption. Can be a single string or an array of strings for secret rotation support.\n * @param salt The salt to use for decryption.\n * @returns The decrypted payload.\n */\nexport async function decrypt<T>(value: string, secret: string | string[], salt: string) {\n if (typeof secret === 'string') {\n return await _decrypt<T>(value, secret, salt);\n } else {\n const [newSecret, ...oldSecrets] = secret;\n\n if (!newSecret) {\n throw new InvalidConfigurationError('At least one secret must be provided');\n }\n\n let firstError: Error | undefined;\n\n try {\n return await _decrypt<T>(value, newSecret, salt);\n } catch (err) {\n firstError = err as Error;\n\n // Only try old secrets if this is a decryption-related error\n // Other errors (like expiration) should be thrown immediately\n if (!isDecryptionError(err)) {\n throw firstError;\n }\n\n for (const oldSecret of oldSecrets) {\n try {\n return await _decrypt(value, oldSecret, salt);\n } catch (fallbackErr) {\n // Only ignore decryption errors with old secrets and continue trying with the next one\n // If it's a different type of error, throw it\n if (!isDecryptionError(fallbackErr)) {\n throw fallbackErr;\n }\n }\n }\n\n // If we've exhausted all secrets and still can't decrypt, throw the original error.\n throw firstError;\n }\n }\n}\n","import type { EncryptedStoreOptions, AbstractDataStore } from '../types.js';\nimport { encrypt, decrypt, isDecryptionError } from '../encryption/index.js';\nimport { JWTPayload } from 'jose';\n\n/**\n * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.\n */\nexport abstract class AbstractStore<TData extends JWTPayload, TStoreOptions = unknown> implements AbstractDataStore<TData, TStoreOptions>\n{\n protected readonly options: EncryptedStoreOptions;\n\n constructor(options: EncryptedStoreOptions) {\n this.options = options;\n }\n\n abstract set(identifier: string, state: TData, removeIfExists?: boolean, options?: TStoreOptions | undefined): Promise<void>;\n abstract get(identifier: string, options?: TStoreOptions | undefined): Promise<TData | undefined>;\n abstract delete(identifier: string, options?: TStoreOptions | undefined): Promise<void>;\n\n protected async encrypt<TData extends JWTPayload>(identifier: string, stateData: TData, expiration: number) {\n return await encrypt(stateData, this.options.secret, identifier, expiration);\n }\n\n protected async decrypt<TData>(identifier: string, encryptedStateData: string) {\n try {\n return (await decrypt(encryptedStateData, this.options.secret, identifier)) as TData;\n } catch (e: unknown){\n // When the error is a decryption failure, we want to ignore it and return undefined, as this likely means the session has expired or the data is invalid.\n if (isDecryptionError(e)) {\n return;\n }\n\n throw e;\n }\n }\n}\n","import type { StateData, EncryptedStoreOptions, StateStore, LogoutTokenClaims } from '../types.js';\nimport { AbstractStore } from './abstract-store.js';\n\n/**\n * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.\n */\nexport abstract class AbstractStateStore<TStoreOptions = unknown> extends AbstractStore<StateData, TStoreOptions> implements StateStore<TStoreOptions> {\n constructor(options: EncryptedStoreOptions) {\n super(options);\n }\n\n abstract deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions | undefined): Promise<void>;\n}","import type { EncryptedStoreOptions, TransactionData, TransactionStore } from '../types.js';\nimport { AbstractStore } from './abstract-store.js';\n\n/**\n * Abstract class that can be used to implement an Encrypted JWT Transaction Store, using the 'A256CBC-HS512' encryption algorithm.\n */\nexport abstract class AbstractTransactionStore<TStoreOptions = unknown> extends AbstractStore<TransactionData, TStoreOptions> implements TransactionStore<TStoreOptions> {\n constructor(options: EncryptedStoreOptions) {\n super(options);\n }\n}","import type { EncryptedStoreOptions, TransactionData } from './../types.js';\nimport { AbstractTransactionStore } from './abstract-transaction-store.js';\nimport type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';\n\nexport class CookieTransactionStore<TStoreOptions> extends AbstractTransactionStore<TStoreOptions> {\n readonly #cookieHandler: CookieHandler<TStoreOptions>;\n\n constructor(options: EncryptedStoreOptions, cookieHandler: CookieHandler<TStoreOptions>) {\n super(options);\n this.#cookieHandler = cookieHandler;\n }\n\n async set(\n identifier: string,\n transactionData: TransactionData,\n removeIfExists?: boolean,\n options?: TStoreOptions\n ): Promise<void> { \n const maxAge = 60 * 60;\n const cookieOpts: CookieSerializeOptions = { httpOnly: true, sameSite: 'lax', path: '/', maxAge };\n const expiration = Math.floor(Date.now() / 1000 + maxAge);\n const encryptedStateData = await this.encrypt(identifier, transactionData, expiration);\n\n this.#cookieHandler.setCookie(identifier, encryptedStateData, cookieOpts, options);\n }\n\n async get(identifier: string, options?: TStoreOptions): Promise<TransactionData | undefined> {\n const cookieValue = this.#cookieHandler.getCookie(identifier, options);\n\n if (cookieValue) {\n return await this.decrypt(identifier, cookieValue);\n }\n }\n\n async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {\n this.#cookieHandler.deleteCookie(identifier, options);\n }\n}\n","import { AbstractStateStore } from './abstract-state-store.js';\nimport type { EncryptedStoreOptions, SessionConfiguration } from '../types.js';\n\nexport abstract class AbstractSessionStore<TStoreOptions> extends AbstractStateStore<TStoreOptions> {\n readonly #rolling: boolean;\n readonly #absoluteDuration: number;\n readonly #inactivityDuration: number;\n\n constructor(options: SessionConfiguration & EncryptedStoreOptions) {\n super(options);\n\n this.#rolling = options.rolling ?? true;\n this.#absoluteDuration = options.absoluteDuration ?? 60 * 60 * 24 * 3;\n this.#inactivityDuration = options.inactivityDuration ?? 60 * 60 * 24 * 1;\n }\n\n /**\n * calculateMaxAge calculates the max age of the session based on createdAt and the rolling and absolute durations.\n */\n protected calculateMaxAge(createdAt: number) {\n if (!this.#rolling) {\n return this.#absoluteDuration;\n }\n\n const now = (Date.now() / 1000) | 0;\n const expiresAt = Math.min(now + this.#inactivityDuration, createdAt + this.#absoluteDuration);\n const maxAge = expiresAt - now;\n\n return maxAge > 0 ? maxAge : 0;\n }\n}","import type {\n EncryptedStoreOptions,\n LogoutTokenClaims,\n SessionConfiguration,\n SessionCookieOptions,\n SessionStore,\n StateData,\n} from '../types.js';\nimport { AbstractSessionStore } from './abstract-session-store.js';\nimport type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';\n\nexport interface StatefulStateStoreOptions<TStoreOptions> extends EncryptedStoreOptions {\n store: SessionStore<TStoreOptions>;\n}\n\nconst generateId = () => {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n};\n\nexport class StatefulStateStore<TStoreOptions> extends AbstractSessionStore<TStoreOptions> {\n readonly #store: SessionStore<TStoreOptions>;\n readonly #cookieOptions: SessionCookieOptions | undefined;\n readonly #cookieHandler: CookieHandler<TStoreOptions>;\n\n constructor(\n options: StatefulStateStoreOptions<TStoreOptions> & SessionConfiguration,\n cookieHandler: CookieHandler<TStoreOptions>\n ) {\n super(options);\n\n this.#store = options.store;\n this.#cookieOptions = options.cookie;\n this.#cookieHandler = cookieHandler;\n }\n\n async set(\n identifier: string,\n stateData: StateData,\n removeIfExists?: boolean,\n options?: TStoreOptions | undefined\n ): Promise<void> {\n let sessionId = await this.getSessionId(identifier, options);\n\n // if this is a new session created by a new login we need to remove the old session\n // from the store and regenerate the session ID to prevent session fixation.\n if (sessionId && removeIfExists) {\n await this.#store.delete(sessionId);\n sessionId = generateId();\n }\n\n sessionId ??= generateId();\n\n const maxAge = this.calculateMaxAge(stateData.internal.createdAt);\n const cookieOpts = this.#getCookieOptions({\n maxAge,\n });\n const expiration = Date.now() / 1000 + maxAge;\n const encryptedStateData = await this.encrypt<{ id: string }>(\n identifier,\n {\n id: sessionId,\n },\n expiration\n );\n\n await this.#store.set(sessionId, stateData);\n\n this.#cookieHandler.setCookie(identifier, encryptedStateData, cookieOpts, options);\n }\n\n async get(identifier: string, options?: TStoreOptions | undefined): Promise<StateData | undefined> {\n const sessionId = await this.getSessionId(identifier, options);\n\n if (sessionId) {\n const stateData = await this.#store.get(sessionId);\n\n // If we have a session cookie, but no `stateData`, we should remove the cookie.\n if (!stateData) {\n this.#cookieHandler.deleteCookie(identifier, options, this.#getCookieOptions());\n }\n\n return stateData;\n }\n }\n\n async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {\n const sessionId = await this.getSessionId(identifier, options);\n\n if (sessionId) {\n await this.#store.delete(sessionId);\n }\n\n this.#cookieHandler.deleteCookie(identifier, options, this.#getCookieOptions());\n }\n\n private async getSessionId(identifier: string, options?: TStoreOptions) {\n const cookieValue = this.#cookieHandler.getCookie(identifier, options);\n if (cookieValue) {\n const sessionCookie = await this.decrypt<{ id: string }>(identifier, cookieValue);\n \n if (sessionCookie) {\n return sessionCookie.id;\n }\n }\n }\n\n deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions | undefined): Promise<void> {\n return this.#store.deleteByLogoutToken(claims, options);\n }\n\n #getCookieOptions(partial?: Partial<CookieSerializeOptions>): CookieSerializeOptions {\n return {\n httpOnly: true,\n sameSite: this.#cookieOptions?.sameSite ?? 'lax',\n path: this.#cookieOptions?.path ?? '/',\n secure: this.#cookieOptions?.secure ?? true,\n ...partial,\n };\n }\n}\n","import type { EncryptedStoreOptions, SessionConfiguration, SessionCookieOptions, StateData } from '../types.js';\nimport { AbstractSessionStore } from './abstract-session-store.js';\nimport type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';\n\nexport class StatelessStateStore<TStoreOptions> extends AbstractSessionStore<TStoreOptions> {\n readonly #cookieOptions: SessionCookieOptions | undefined;\n readonly #cookieHandler: CookieHandler<TStoreOptions>;\n\n constructor(options: SessionConfiguration & EncryptedStoreOptions, cookieHandler: CookieHandler<TStoreOptions>) {\n super(options);\n\n this.#cookieOptions = options.cookie;\n this.#cookieHandler = cookieHandler;\n }\n\n async set(\n identifier: string,\n stateData: StateData,\n removeIfExists?: boolean,\n options?: TStoreOptions | undefined\n ): Promise<void> {\n const maxAge = this.calculateMaxAge(stateData.internal.createdAt);\n const cookieOpts = this.#getCookieOptions({\n maxAge,\n });\n const expiration = Math.floor(Date.now() / 1000 + maxAge);\n const encryptedStateData = await this.encrypt(identifier, stateData, expiration);\n\n const chunkSize = 3072;\n const chunkCount = Math.ceil(encryptedStateData.length / chunkSize);\n const chunks = [...Array(chunkCount).keys()].map((i) => ({\n value: encryptedStateData.substring(i * chunkSize, (i + 1) * chunkSize),\n name: `${identifier}.${i}`,\n }));\n\n chunks.forEach((chunk) => {\n this.#cookieHandler.setCookie(chunk.name, chunk.value, cookieOpts, options);\n });\n\n const existingCookieKeys = this.getCookieKeys(identifier, options);\n const cookieKeysToRemove = existingCookieKeys.filter((key) => !chunks.some((chunk) => chunk.name === key));\n cookieKeysToRemove.forEach((key) => {\n this.#cookieHandler.deleteCookie(key, options, cookieOpts);\n });\n }\n\n async get(identifier: string, options?: TStoreOptions | undefined): Promise<StateData | undefined> {\n const cookieKeys = this.getCookieKeys(identifier, options);\n const encryptedStateData = cookieKeys\n .map((key) => ({\n index: parseInt(key.split('.')[1] as string, 10),\n value: this.#cookieHandler.getCookie(key, options),\n }))\n .sort((a, b) => a.index - b.index)\n .map((item) => item.value)\n .join('');\n\n if (encryptedStateData) {\n return await this.decrypt(identifier, encryptedStateData);\n }\n }\n\n async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {\n const cookieKeys = this.getCookieKeys(identifier, options);\n for (const key of cookieKeys) {\n this.#cookieHandler.deleteCookie(key, options, this.#getCookieOptions());\n }\n }\n\n deleteByLogoutToken(): Promise<void> {\n throw new Error(\n 'Backchannel logout is not available when using Stateless Storage. Use Stateful Storage by providing a `sessionStore`'\n );\n }\n\n private getCookieKeys(identifier: string, options?: TStoreOptions): string[] {\n return Object.keys(this.#cookieHandler.getCookies(options)).filter((key) => key.startsWith(identifier));\n }\n\n #getCookieOptions(partial?: Partial<CookieSerializeOptions>): CookieSerializeOptions {\n return {\n httpOnly: true,\n sameSite: this.#cookieOptions?.sameSite ?? 'lax',\n path: this.#cookieOptions?.path ?? '/',\n secure: this.#cookieOptions?.secure ?? true,\n ...partial,\n };\n }\n}\n","export { ServerMfaClient } from './server-mfa-client.js';\nexport type { MfaVerifyResponse } from './types.js';\nexport type {\n MfaFactorType,\n MfaVerifyOtpOptions,\n MfaVerifyOobOptions,\n MfaVerifyRecoveryCodeOptions,\n MfaVerifyOptions,\n} from '@auth0/auth0-auth-js';\n\n// Re-export MFA types and errors from auth0-auth-js for convenience\nexport type {\n AuthenticatorResponse,\n AuthenticatorType,\n OobChannel,\n ListAuthenticatorsOptions,\n EnrollOtpOptions,\n EnrollOobOptions,\n EnrollEmailOptions,\n EnrollAuthenticatorOptions,\n OtpEnrollmentResponse,\n OobEnrollmentResponse,\n EnrollmentResponse,\n ChallengeOptions,\n ChallengeResponse,\n MfaRequirements,\n} from '@auth0/auth0-auth-js';\n\nexport {\n MfaListAuthenticatorsError,\n MfaEnrollmentError,\n MfaChallengeError,\n MfaVerifyError,\n isMfaRequiredError,\n} from '@auth0/auth0-auth-js';\n"],"mappings":";AAGO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAC1C,OAAe;AAAA,EAEtB,YAAY,SAAkB;AAC5B,UAAM,WAAW,6BAA6B;AAC9C,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EACzC,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACrC,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,+BAAN,cAA2C,MAAM;AAAA,EAC/C,OAAe;AAAA,EAEtB,YAAY,UAAkB;AAC5B,UAAM,iBAAiB,QAAQ,qCAAqC;AACpE,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACtC,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAC5C,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,wBAAN,cAAoC,MAAM;AA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AAK,EACxB,KAAK,EAAE;AAEV,QAAI,oBAAoB;AACtB,aAAO,MAAM,KAAK,QAAQ,YAAY,kBAAkB;AAAA,IAC1D;AAAA,EACF;AAAA,EAEA,MAAM,OAAO,YAAoB,SAAoD;AACnF,UAAM,aAAa,KAAK,cAAc,YAAY,OAAO;AACzD,eAAW,OAAO,YAAY;AAC5B,WAAK,eAAe,aAAa,KAAK,SAAS,KAAK,kBAAkB,CAAC;AAAA,IACzE;AAAA,EACF;AAAA,EAEA,sBAAqC;AACnC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,cAAc,YAAoB,SAAmC;AAC3E,WAAO,OAAO,KAAK,KAAK,eAAe,WAAW,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,IAAI,WAAW,UAAU,CAAC;AAAA,EACxG;AAAA,EAEA,kBAAkB,SAAmE;AACnF,WAAO;AAAA,MACL,UAAU;AAAA,MACV,UAAU,KAAK,gBAAgB,YAAY;AAAA,MAC3C,MAAM,KAAK,gBAAgB,QAAQ;AAAA,MACnC,QAAQ,KAAK,gBAAgB,UAAU;AAAA,MACvC,GAAG;AAAA,IACL;AAAA,EACF;AACF;;;AC5DA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["tokenSet","logoutTokenClaims"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/state/utils.ts","../src/server-client.ts","../src/utils.ts","../src/telemetry.ts","../src/mfa/server-mfa-client.ts","../src/encryption/index.ts","../src/store/abstract-store.ts","../src/store/abstract-state-store.ts","../src/store/abstract-transaction-store.ts","../src/index.ts","../src/store/cookie-transaction-store.ts","../src/store/abstract-session-store.ts","../src/store/stateful-state-store.ts","../src/store/stateless-state-store.ts","../src/mfa/index.ts"],"sourcesContent":["/**\n * Error thrown when there is no transaction available.\n */\nexport class MissingTransactionError extends Error {\n public code: string = 'missing_transaction_error';\n\n constructor(message?: string) {\n super(message ?? 'The transaction is missing.');\n this.name = 'MissingTransactionError';\n }\n}\n\n\n/**\n * Error thrown when backchannel logout fails.\n */\nexport class BackchannelLogoutError extends Error {\n public code: string = 'backchannel_logout_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'BackchannelLogoutError';\n }\n}\n\n/**\n * Error thrown when starting the user-linking failed.\n */\nexport class StartLinkUserError extends Error {\n public code: string = 'start_link_user_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'StartLinkUserError';\n }\n}\n\n/**\n * Error thrown when a required argument is missing.\n */\nexport class MissingRequiredArgumentError extends Error {\n public code: string = 'missing_required_argument_error';\n\n constructor(argument: string) {\n super(`The argument '${argument}' is required but was not provided.`);\n this.name = 'MissingRequiredArgumentError';\n }\n}\n\n/**\n * Error thrown when a session is missing.\n */\nexport class MissingSessionError extends Error {\n public code: string = 'missing_session_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'MissingSessionError';\n }\n}\n\n/**\n * Error thrown when a configuration is invalid.\n */\nexport class InvalidConfigurationError extends Error {\n public code: string = 'invalid_configuration_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'InvalidConfigurationError';\n }\n}\n\n/**\n * Error thrown when the issuer validation fails.\n */\nexport class IssuerValidationError extends Error {\n public code: string = 'issuer_validation_error';\n\n constructor(message: string) {\n super(message);\n this.name = 'IssuerValidationError';\n }\n}\n","import type { AccessTokenForConnectionOptions, StateData } from '../types.js';\nimport { TokenResponse } from '@auth0/auth0-auth-js';\n\n/**\n * Creates an updated token set object from the token endpoint response\n * @param audience The audience for which the token was requested\n * @param response The response from the token endpoint\n * @returns Updated token set object\n */\nconst createUpdatedTokenSet = (audience: string, response: TokenResponse) => ({\n audience,\n accessToken: response.accessToken,\n scope: response.scope,\n expiresAt: response.expiresAt,\n});\n\n/**\n * Utility function to update the state with a new response from the token endpoint\n * @param audience The audience of the token endpoint response\n * @param stateData The existing state data to update, or undefined if no state data available.\n * @param tokenEndpointResponse The response from the token endpoint.\n * @returns Updated state data.\n */\nexport function updateStateData(\n audience: string,\n stateData: StateData | undefined,\n tokenEndpointResponse: TokenResponse,\n context?: { domain?: string }\n): StateData {\n // If we already have a session and the new token belongs to a different user (iss or sub mismatch),\n // wipe the existing state to start a fresh session. This handles the case where a user logs in\n // as a different user without explicitly logging out first.\n if (stateData && tokenEndpointResponse.claims) {\n const newSub = tokenEndpointResponse.claims.sub;\n const newIss = tokenEndpointResponse.claims.iss;\n const existingSub = stateData.user?.sub;\n const existingIss = stateData.user?.iss;\n\n const subMismatch = newSub !== undefined && existingSub !== undefined && newSub !== existingSub;\n const issMismatch = newIss !== undefined && existingIss !== undefined && newIss !== existingIss;\n\n if (subMismatch || issMismatch) {\n stateData = undefined;\n }\n }\n\n if (stateData) {\n const isNewTokenSet = !stateData.tokenSets.some(\n (tokenSet) => tokenSet.audience === audience && tokenSet.scope === tokenEndpointResponse.scope\n );\n\n const tokenSets = isNewTokenSet\n ? [...stateData.tokenSets, createUpdatedTokenSet(audience, tokenEndpointResponse)]\n : stateData.tokenSets.map((tokenSet) =>\n tokenSet.audience === audience && tokenSet.scope === tokenEndpointResponse.scope\n ? createUpdatedTokenSet(audience, tokenEndpointResponse)\n : tokenSet\n );\n\n return {\n ...stateData,\n idToken: tokenEndpointResponse.idToken ?? stateData.idToken,\n refreshToken: tokenEndpointResponse.refreshToken ?? stateData.refreshToken,\n tokenSets,\n domain: context?.domain ?? stateData.domain,\n };\n } else {\n const user = tokenEndpointResponse.claims;\n return {\n user,\n idToken: tokenEndpointResponse.idToken,\n refreshToken: tokenEndpointResponse.refreshToken,\n tokenSets: [createUpdatedTokenSet(audience, tokenEndpointResponse)],\n domain: context?.domain,\n internal: {\n sid: user?.sid as string,\n createdAt: Math.floor(Date.now() / 1000),\n },\n };\n }\n}\n\nexport function updateStateDataForConnectionTokenSet(\n options: AccessTokenForConnectionOptions,\n stateData: StateData,\n tokenEndpointResponse: TokenResponse\n) {\n stateData.connectionTokenSets = stateData.connectionTokenSets || [];\n\n const isNewTokenSet = !stateData.connectionTokenSets.some(\n (tokenSet) =>\n tokenSet.connection === options.connection && (!options.loginHint || tokenSet.loginHint === options.loginHint)\n );\n\n const connectionTokenSet = {\n connection: options.connection,\n loginHint: options.loginHint,\n accessToken: tokenEndpointResponse.accessToken,\n scope: tokenEndpointResponse.scope,\n expiresAt: tokenEndpointResponse.expiresAt,\n };\n\n const connectionTokenSets = isNewTokenSet\n ? [...stateData.connectionTokenSets, connectionTokenSet]\n : stateData.connectionTokenSets.map((tokenSet) =>\n tokenSet.connection === options.connection && (!options.loginHint || tokenSet.loginHint === options.loginHint)\n ? connectionTokenSet\n : tokenSet\n );\n\n return {\n ...stateData,\n connectionTokenSets,\n };\n}\n","import {\n AccessTokenForConnectionOptions,\n ConnectionTokenSet,\n CustomTokenExchangeOptions,\n DomainResolver,\n LoginBackchannelOptions,\n LoginBackchannelResult,\n LoginWithCustomTokenExchangeOptions,\n LoginWithCustomTokenExchangeResult,\n LogoutOptions,\n ServerClientOptions,\n SessionData,\n StartInteractiveLoginOptions,\n StartLinkUserOptions,\n StartUnlinkUserOptions,\n StateData,\n StateStore,\n TokenSet,\n TransactionData,\n TransactionStore,\n} from './types.js';\nimport {\n BackchannelLogoutError,\n InvalidConfigurationError,\n MissingRequiredArgumentError,\n MissingSessionError,\n MissingTransactionError,\n} from './errors.js';\nimport { updateStateData, updateStateDataForConnectionTokenSet } from './state/utils.js';\nimport {\n TokenForConnectionError,\n AuthClient,\n AuthorizationDetails,\n TokenByRefreshTokenError,\n TokenResponse,\n} from '@auth0/auth0-auth-js';\nimport { compareScopes } from './utils.js';\nimport { decodeJwt } from 'jose';\nimport type { AuthClientOptions } from '@auth0/auth0-auth-js';\nimport { getTelemetryConfig } from './telemetry.js';\nimport { ServerMfaClient } from './mfa/server-mfa-client.js';\n\nconst DEFAULT_SCOPES = 'openid profile email offline_access';\n\nconst normalizeDomain = (value: string) => {\n const trimmed = value.trim();\n const parsed = trimmed.startsWith('http') ? new URL(trimmed) : new URL(`https://${trimmed}`);\n return parsed.host.toLowerCase();\n};\n\nconst decodeIssuer = (token: string) => {\n try {\n const { iss } = decodeJwt(token);\n return typeof iss === 'string' ? iss : undefined;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Ensures that the \"openid\" scope is always included in the scope string.\n *\n * @param scope - The scope provided by the user (optional)\n * @returns A scope string that includes \"openid\" if it was not already present.\n */\nconst ensureOpenIdScope = (scope?: string) => {\n if (!scope) {\n return DEFAULT_SCOPES;\n }\n\n const scopes = scope.split(' ');\n if (!scopes.includes('openid')) {\n scopes.unshift('openid');\n }\n\n return scopes.join(' ');\n};\n\nexport class ServerClient<TStoreOptions = unknown> {\n readonly #options: ServerClientOptions<TStoreOptions>;\n readonly #transactionStore: TransactionStore<TStoreOptions>;\n readonly #transactionStoreIdentifier: string;\n readonly #stateStore: StateStore<TStoreOptions>;\n readonly #stateStoreIdentifier: string;\n readonly #authClientOptions: Omit<AuthClientOptions, 'domain'>;\n readonly #staticDomain?: string;\n readonly #authClient?: AuthClient;\n readonly #mfaClient?: ServerMfaClient<TStoreOptions>;\n\n /**\n * The underlying `authClient` instance that can be used to interact with the Auth0 Authentication API.\n * Generally, you should prefer to use the higher-level methods exposed on the `ServerClient` instance.\n *\n * This property can only be used when `domain` is configured as a static string.\n * In resolver mode (`domain` as a function), the SDK resolves the domain per request,\n * so use `ServerClient` methods instead.\n *\n * Important: the methods exposed on the `authClient` instance do not handle any session or state management.\n */\n public get authClient(): AuthClient {\n if (!this.#authClient) {\n throw new InvalidConfigurationError('authClient is only available when using a static domain configuration.');\n }\n return this.#authClient;\n }\n\n /**\n * The MFA client for managing multi-factor authentication operations.\n *\n * Provides methods to list, enroll, and challenge MFA authenticators,\n * as well as verify MFA challenges to complete authentication.\n *\n * The `verify` method integrates with the session state store, persisting tokens\n * and user data after successful MFA verification.\n *\n * This property can only be used when `domain` is configured as a static string.\n * In resolver mode (`domain` as a function), MFA is not supported.\n */\n public get mfa(): ServerMfaClient<TStoreOptions> {\n if (!this.#mfaClient) {\n throw new InvalidConfigurationError('mfa is only available when using a static domain configuration.');\n }\n return this.#mfaClient;\n }\n\n constructor(options: ServerClientOptions<TStoreOptions>) {\n this.#options = options;\n this.#stateStoreIdentifier = this.#options.stateIdentifier || '__a0_session';\n this.#transactionStoreIdentifier = this.#options.transactionIdentifier || '__a0_tx';\n this.#transactionStore = options.transactionStore;\n this.#stateStore = options.stateStore;\n\n if (!this.#options.stateStore) {\n throw new MissingRequiredArgumentError('stateStore');\n }\n\n if (!this.#options.transactionStore) {\n throw new MissingRequiredArgumentError('transactionStore');\n }\n\n if (typeof this.#options.domain !== 'string' && typeof this.#options.domain !== 'function') {\n throw new InvalidConfigurationError('domain must be a string or resolver function');\n }\n\n this.#authClientOptions = {\n clientId: this.#options.clientId,\n clientSecret: this.#options.clientSecret,\n clientAssertionSigningKey: this.#options.clientAssertionSigningKey,\n clientAssertionSigningAlg: this.#options.clientAssertionSigningAlg,\n authorizationParams: this.#options.authorizationParams,\n discoveryCache: this.#options.discoveryCache,\n customFetch: this.#options.customFetch,\n useMtls: this.#options.useMtls,\n };\n\n if (typeof this.#options.domain === 'string') {\n const domain = normalizeDomain(this.#options.domain);\n this.#staticDomain = domain;\n this.#authClient = new AuthClient({\n domain,\n ...this.#authClientOptions,\n telemetry: getTelemetryConfig(this.#options.telemetry),\n });\n\n this.#mfaClient = new ServerMfaClient({\n authClient: this.#authClient,\n domain,\n stateStore: this.#stateStore,\n stateStoreIdentifier: this.#stateStoreIdentifier,\n defaultAudience: this.#options.authorizationParams?.audience ?? 'default',\n });\n }\n }\n\n async #resolveDomain(storeOptions?: TStoreOptions): Promise<string> {\n if (typeof this.#options.domain === 'function') {\n const resolved = await (this.#options.domain as DomainResolver<TStoreOptions>)(storeOptions);\n if (typeof resolved !== 'string' || resolved.trim().length === 0) {\n throw new InvalidConfigurationError('domainResolver returned no domain');\n }\n return normalizeDomain(resolved);\n }\n\n return normalizeDomain(this.#options.domain);\n }\n\n #createAuthClient(domain: string): AuthClient {\n return new AuthClient({\n domain,\n ...this.#authClientOptions,\n telemetry: getTelemetryConfig(this.#options.telemetry),\n });\n }\n\n #getAuthClient(domain: string): AuthClient {\n const normalizedDomain = normalizeDomain(domain);\n if (this.#authClient && this.#staticDomain === normalizedDomain) {\n return this.#authClient;\n }\n return this.#createAuthClient(normalizedDomain);\n }\n\n #getSessionDomain(stateData: StateData): string | undefined {\n if (stateData.domain) {\n return normalizeDomain(stateData.domain);\n }\n\n if (this.#staticDomain) {\n return this.#staticDomain;\n }\n\n // Legacy sessions may not have `domain` persisted yet; infer it from ID token claims.\n const issuerFromClaims = stateData.user?.iss;\n if (typeof issuerFromClaims === 'string' && issuerFromClaims.trim().length > 0) {\n return normalizeDomain(issuerFromClaims);\n }\n\n return;\n }\n\n #isResolverMode(): boolean {\n return typeof this.#options.domain === 'function';\n }\n\n async #isSessionForCurrentDomain(stateData: StateData, storeOptions?: TStoreOptions): Promise<boolean> {\n const sessionDomain = this.#getSessionDomain(stateData);\n if (!sessionDomain) {\n return false;\n }\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n return sessionDomain === resolvedDomain;\n }\n\n /**\n * Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.\n * @param options Optional options used to configure the interactive login process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {BuildAuthorizationUrlError} If there was an issue when building the Authorization URL.\n *\n * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.\n */\n public async startInteractiveLogin(options?: StartInteractiveLoginOptions, storeOptions?: TStoreOptions) {\n const redirectUri = options?.authorizationParams?.redirect_uri ?? this.#options.authorizationParams?.redirect_uri;\n if (!redirectUri) {\n throw new MissingRequiredArgumentError('authorizationParams.redirect_uri');\n }\n\n const scope = ensureOpenIdScope(options?.authorizationParams?.scope ?? this.#options.authorizationParams?.scope);\n\n const domain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(domain);\n const { codeVerifier, authorizationUrl } = await authClient.buildAuthorizationUrl({\n pushedAuthorizationRequests: options?.pushedAuthorizationRequests,\n authorizationParams: {\n ...options?.authorizationParams,\n redirect_uri: redirectUri,\n scope,\n },\n });\n\n const transactionState: TransactionData = {\n audience: options?.authorizationParams?.audience ?? this.#options.authorizationParams?.audience,\n codeVerifier,\n domain,\n };\n\n if (options?.appState) {\n transactionState.appState = options.appState;\n }\n\n await this.#transactionStore.set(this.#transactionStoreIdentifier, transactionState, false, storeOptions);\n\n return authorizationUrl;\n }\n\n /**\n * Completes the interactive login process.\n * Takes an URL, extract the Authorization Code flow query parameters and requests a token.\n * @param url The URl from which the query params should be extracted to exchange for a token.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingTransactionError} When no transaction was found.\n * @throws {TokenByCodeError} If there was an issue requesting the access token.\n *\n * @returns A promise resolving to an object, containing the original appState (if present) and the authorizationDetails (when RAR was used).\n */\n public async completeInteractiveLogin<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions) {\n const transactionData = await this.#transactionStore.get(this.#transactionStoreIdentifier, storeOptions);\n\n if (!transactionData) {\n throw new MissingTransactionError();\n }\n\n const domain = transactionData.domain ?? (await this.#resolveDomain(storeOptions));\n const authClient = this.#getAuthClient(domain);\n const tokenEndpointResponse = await authClient.getTokenByCode(url, {\n codeVerifier: transactionData.codeVerifier,\n });\n\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const stateData = updateStateData(transactionData.audience ?? 'default', existingStateData, tokenEndpointResponse, {\n domain,\n });\n\n await this.#stateStore.set(this.#stateStoreIdentifier, stateData, true, storeOptions);\n await this.#transactionStore.delete(this.#transactionStoreIdentifier, storeOptions);\n\n return { appState: transactionData.appState, authorizationDetails: tokenEndpointResponse.authorizationDetails } as {\n appState?: TAppState;\n authorizationDetails?: AuthorizationDetails[];\n };\n }\n\n /**\n * Starts the user linking process, and returns a URL to redirect the user-agent to to request authorization at Auth0.\n * @param options Options used to configure the user linking process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingSessionError} If there is no active session.\n * @throws {BuildLinkUserUrlError} If there was an issue when building the Authorization URL.\n *\n * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.\n */\n public async startLinkUser(options: StartLinkUserOptions, storeOptions?: TStoreOptions) {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (!stateData || !stateData.idToken) {\n throw new MissingSessionError(\n 'Unable to start the user linking process without a logged in user. Ensure to login using the SDK before starting the user linking process.'\n );\n }\n\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const domain = this.#getSessionDomain(stateData)!;\n const authClient = this.#getAuthClient(domain);\n const { linkUserUrl, codeVerifier } = await authClient.buildLinkUserUrl({\n connection: options.connection,\n connectionScope: options.connectionScope,\n idToken: stateData.idToken,\n authorizationParams: options.authorizationParams,\n });\n\n const transactionState: TransactionData = {\n audience: options?.authorizationParams?.audience ?? this.#options.authorizationParams?.audience,\n codeVerifier,\n domain,\n };\n\n if (options?.appState) {\n transactionState.appState = options.appState;\n }\n\n await this.#transactionStore.set(this.#transactionStoreIdentifier, transactionState, false, storeOptions);\n\n return linkUserUrl;\n }\n\n /**\n * Completes the user linking process.\n * Takes an URL, extract the Authorization Code flow query parameters and requests a token.\n * @param url The URl from which the query params should be extracted to exchange for a token.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingTransactionError} When no transaction was found.\n * @throws {TokenByCodeError} If there was an issue requesting the access token.\n *\n * @returns A promise resolving to an object, containing the original appState (if present).\n */\n public async completeLinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions) {\n // In order to complete the link user flow, we need to exchange the code for a token in the same\n // way as we do for the interactive login flow.\n const result = await this.completeInteractiveLogin<TAppState>(url, storeOptions);\n\n // As we currently do not support RAR when starting the user linking flow, we will ommit it from being returned as optional altogether.\n return {\n appState: result.appState,\n };\n }\n\n /**\n * Starts the user unlinking process, and returns a URL to redirect the user-agent to to initialize user unlinking at Auth0.\n * @param options Options used to configure the user unlinking process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingSessionError} If there is no active session.\n * @throws {BuildUnlinkUserUrlError} If there was an issue when building the User Unlinking URL.\n *\n * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.\n */\n public async startUnlinkUser(options: StartUnlinkUserOptions, storeOptions?: TStoreOptions) {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (!stateData || !stateData.idToken) {\n throw new MissingSessionError(\n 'Unable to start the user unlinking process without a logged in user. Ensure to login using the SDK before starting the user unlinking process.'\n );\n }\n\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const domain = this.#getSessionDomain(stateData)!;\n const authClient = this.#getAuthClient(domain);\n const { unlinkUserUrl, codeVerifier } = await authClient.buildUnlinkUserUrl({\n connection: options.connection,\n idToken: stateData.idToken,\n authorizationParams: options.authorizationParams,\n });\n\n const transactionState: TransactionData = {\n audience: options?.authorizationParams?.audience ?? this.#options.authorizationParams?.audience,\n codeVerifier,\n domain,\n };\n\n if (options?.appState) {\n transactionState.appState = options.appState;\n }\n\n await this.#transactionStore.set(this.#transactionStoreIdentifier, transactionState, false, storeOptions);\n\n return unlinkUserUrl;\n }\n\n /**\n * Completes the user unlinking process.\n * Takes an URL, extract the Authorization Code flow query parameters and requests a token.\n * @param url The URl from which the query params should be extracted to exchange for a token.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {MissingTransactionError} When no transaction was found.\n * @throws {TokenByCodeError} If there was an issue requesting the access token.\n *\n * @returns A promise resolving to an object, containing the original appState (if present).\n */\n public async completeUnlinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions) {\n // In order to complete the link user flow, we need to exchange the code for a token in the same\n // way as we do for the interactive login flow.\n const result = await this.completeInteractiveLogin<TAppState>(url, storeOptions);\n\n // As we currently do not support RAR when starting the user unlinking flow, we will ommit it from being returned as optional altogether.\n return {\n appState: result.appState,\n };\n }\n\n /**\n * Logs in using Client-Initiated Backchannel Authentication.\n *\n * Using Client-Initiated Backchannel Authentication requires the feature to be enabled in the Auth0 dashboard.\n * @see https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-initiated-backchannel-authentication-flow\n * @param options Options used to configure the backchannel login process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {BackchannelAuthenticationError} If there was an issue when doing backchannel authentication.\n *\n * @returns A promise resolving to an object, containing the authorizationDetails (when RAR was used).\n */\n public async loginBackchannel(\n options: LoginBackchannelOptions,\n storeOptions?: TStoreOptions\n ): Promise<LoginBackchannelResult> {\n const scope = ensureOpenIdScope(options.authorizationParams?.scope ?? this.#options.authorizationParams?.scope);\n const domain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(domain);\n const tokenEndpointResponse = await authClient.backchannelAuthentication({\n bindingMessage: options.bindingMessage,\n loginHint: options.loginHint,\n authorizationParams: {\n ...options.authorizationParams,\n scope,\n },\n });\n\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n const stateData = updateStateData(\n this.#options.authorizationParams?.audience ?? 'default',\n existingStateData,\n tokenEndpointResponse,\n { domain }\n );\n\n await this.#stateStore.set(this.#stateStoreIdentifier, stateData, true, storeOptions);\n\n return {\n authorizationDetails: tokenEndpointResponse.authorizationDetails,\n };\n }\n\n /**\n * Retrieves the user from the store, or undefined if no user found.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n * @returns The user, or undefined if no user found in the store.\n */\n public async getUser(storeOptions?: TStoreOptions) {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (!stateData) {\n return;\n }\n\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n return;\n }\n }\n\n return stateData.user;\n }\n\n /**\n * Retrieve the user session from the store, or undefined if no session found.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n * @returns The session or undefined if no session found in the store.\n */\n public async getSession(storeOptions?: TStoreOptions): Promise<SessionData | undefined> {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n if (stateData) {\n if (this.#isResolverMode()) {\n const isCurrentDomain = await this.#isSessionForCurrentDomain(stateData, storeOptions);\n if (!isCurrentDomain) {\n return;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { internal, ...sessionData } = stateData;\n return sessionData;\n }\n }\n\n /**\n * Retrieves the access token from the store, or calls Auth0 when the access token is expired and a refresh token is available in the store.\n * Also updates the store when a new token was retrieved from Auth0.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {TokenByRefreshTokenError} If the refresh token was not found or there was an issue requesting the access token. When the cause is `mfa_required`, use `isMfaRequiredError(error)` to narrow the error and read `cause.mfa_token`.\n *\n * @returns The Token Set, containing the access token, as well as additional information.\n */\n public async getAccessToken(storeOptions?: TStoreOptions): Promise<TokenSet> {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const audience = this.#options.authorizationParams?.audience ?? 'default';\n const scope = this.#options.authorizationParams?.scope;\n\n const sessionDomain = stateData ? this.#getSessionDomain(stateData) : this.#staticDomain;\n if (this.#isResolverMode()) {\n if (!stateData) {\n throw new MissingSessionError('Unable to retrieve access token without a logged in user.');\n }\n if (!sessionDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n if (sessionDomain !== resolvedDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const tokenSet = stateData?.tokenSets.find(\n (tokenSet) => tokenSet.audience === audience && (!scope || compareScopes(tokenSet.scope, scope))\n );\n\n if (tokenSet && tokenSet.expiresAt > Date.now() / 1000) {\n return tokenSet;\n }\n\n if (!stateData?.refreshToken) {\n throw new TokenByRefreshTokenError(\n 'The access token has expired and a refresh token was not provided. The user needs to re-authenticate.'\n );\n }\n\n const domainForSession = sessionDomain!;\n const tokenEndpointResponse = await this.#getAuthClient(domainForSession).getTokenByRefreshToken({\n refreshToken: stateData.refreshToken,\n });\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const updatedStateData = updateStateData(audience, existingStateData, tokenEndpointResponse, {\n domain: domainForSession,\n });\n\n await this.#stateStore.set(this.#stateStoreIdentifier, updatedStateData, false, storeOptions);\n\n return {\n accessToken: tokenEndpointResponse.accessToken,\n scope: tokenEndpointResponse.scope,\n expiresAt: tokenEndpointResponse.expiresAt,\n audience: audience,\n };\n }\n\n /**\n * Retrieves an access token for a connection.\n *\n * This method attempts to obtain an access token for a specified connection.\n * It first checks if a refresh token exists in the store.\n * If no refresh token is found, it throws an `AccessTokenForConnectionError` indicating\n * that the refresh token was not found.\n *\n * @param options - Options for retrieving an access token for a connection.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {TokenForConnectionError} If the refresh token was not found or there was an issue requesting the access token.\n *\n * @returns The Connection Token Set, containing the access token for the connection, as well as additional information.\n */\n public async getAccessTokenForConnection(\n options: AccessTokenForConnectionOptions,\n storeOptions?: TStoreOptions\n ): Promise<ConnectionTokenSet> {\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n\n const sessionDomain = stateData ? this.#getSessionDomain(stateData) : this.#staticDomain;\n if (this.#isResolverMode()) {\n if (!stateData) {\n throw new MissingSessionError('Unable to retrieve an access token for a connection without a logged in user.');\n }\n if (!sessionDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n if (sessionDomain !== resolvedDomain) {\n throw new MissingSessionError('Session domain does not match the current domain.');\n }\n }\n\n const connectionTokenSet = stateData?.connectionTokenSets?.find(\n (tokenSet) => tokenSet.connection === options.connection\n );\n\n if (connectionTokenSet && connectionTokenSet.expiresAt > Date.now() / 1000) {\n return connectionTokenSet;\n }\n\n if (!stateData?.refreshToken) {\n throw new TokenForConnectionError(\n 'A refresh token was not found but is required to be able to retrieve an access token for a connection.'\n );\n }\n\n const domainForSession = sessionDomain!;\n const tokenEndpointResponse = await this.#getAuthClient(domainForSession).getTokenForConnection({\n connection: options.connection,\n loginHint: options.loginHint,\n refreshToken: stateData.refreshToken,\n });\n\n const updatedStateData = updateStateDataForConnectionTokenSet(\n options,\n {\n ...stateData,\n domain: stateData.domain ?? domainForSession,\n },\n tokenEndpointResponse\n );\n\n await this.#stateStore.set(this.#stateStoreIdentifier, updatedStateData, false, storeOptions);\n\n return {\n accessToken: tokenEndpointResponse.accessToken,\n scope: tokenEndpointResponse.scope,\n expiresAt: tokenEndpointResponse.expiresAt,\n connection: options.connection,\n loginHint: options.loginHint,\n };\n }\n\n /**\n * Logs the user out and returns a URL to redirect the user-agent to after they log out.\n * @param options Options used to configure the logout process.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n * @returns {URL}\n */\n public async logout(options: LogoutOptions, storeOptions?: TStoreOptions) {\n if (!this.#isResolverMode()) {\n await this.#stateStore.delete(this.#stateStoreIdentifier, storeOptions);\n return this.authClient.buildLogoutUrl(options);\n }\n\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(resolvedDomain);\n const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const sessionDomain = stateData ? this.#getSessionDomain(stateData) : undefined;\n\n if (!stateData) {\n // No local session, still return a logout URL for the current domain.\n return authClient.buildLogoutUrl(options);\n }\n\n if (sessionDomain && sessionDomain === resolvedDomain) {\n await this.#stateStore.delete(this.#stateStoreIdentifier, storeOptions);\n }\n\n return authClient.buildLogoutUrl(options);\n }\n\n /**\n * Exchanges a custom token for Auth0 tokens and persists the resulting session (RFC 8693).\n *\n * Calls the token endpoint using the RFC 8693 Token Exchange grant, then stores the\n * resulting tokens in the StateStore — effectively logging the user in without an\n * interactive browser flow. Use this when the caller already holds a trusted external\n * token (e.g. a Google ID token, a legacy system token) and wants to establish an\n * Auth0 session from it.\n *\n * Requires a Token Exchange Profile configured in your Auth0 tenant.\n *\n * @param options Options for the custom token exchange, including the subject token and its type.\n * @param storeOptions Optional options passed to the StateStore.\n *\n * @throws {TokenExchangeError} If the exchange fails or the subject token is invalid.\n * @throws {MissingClientAuthError} If client credentials are not configured.\n *\n * @returns A promise resolving to an object containing `authorizationDetails` when RAR was used.\n */\n public async loginWithCustomTokenExchange(\n options: LoginWithCustomTokenExchangeOptions,\n storeOptions?: TStoreOptions\n ): Promise<LoginWithCustomTokenExchangeResult> {\n const domain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(domain);\n const tokenEndpointResponse = await authClient.exchangeToken({\n ...options,\n scope: ensureOpenIdScope(options.scope),\n });\n\n const existingStateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);\n const stateData = updateStateData(\n this.#options.authorizationParams?.audience ?? 'default',\n existingStateData,\n tokenEndpointResponse,\n { domain }\n );\n\n await this.#stateStore.set(this.#stateStoreIdentifier, stateData, true, storeOptions);\n\n return { authorizationDetails: tokenEndpointResponse.authorizationDetails };\n }\n\n /**\n * Exchanges a custom token for Auth0 tokens without establishing a session (RFC 8693).\n *\n * Performs the same RFC 8693 Token Exchange as `loginWithCustomTokenExchange` but\n * returns the raw token response without writing anything to the StateStore. Use this\n * for delegation or impersonation flows where you need downstream tokens but do not\n * want to create or modify the current user session.\n *\n * Requires a Token Exchange Profile configured in your Auth0 tenant.\n *\n * @param options Options for the custom token exchange, including the subject token and its type.\n * @param storeOptions Optional options passed to the StateStore (used only for domain resolution in resolver mode).\n *\n * @throws {TokenExchangeError} If the exchange fails or the subject token is invalid.\n * @throws {MissingClientAuthError} If client credentials are not configured.\n *\n * @returns A promise resolving to the token response from Auth0.\n */\n public async customTokenExchange(\n options: CustomTokenExchangeOptions,\n storeOptions?: TStoreOptions\n ): Promise<TokenResponse> {\n const domain = await this.#resolveDomain(storeOptions);\n const authClient = this.#getAuthClient(domain);\n return authClient.exchangeToken(options);\n }\n\n /**\n * Handles the backchannel logout process by verifying the logout token and deleting the session from the store if the logout token was considered valid.\n * @param logoutToken The logout token to verify and use to delete the session from the store.\n * @param storeOptions Optional options used to pass to the Transaction and State Store.\n *\n * @throws {BackchannelLogoutError} If the logout token is missing.\n * @throws {VerifyLogoutTokenError} If the logout token is invalid.\n */\n public async handleBackchannelLogout(logoutToken: string, storeOptions?: TStoreOptions) {\n if (!logoutToken) {\n throw new BackchannelLogoutError('Missing Logout Token');\n }\n\n if (!this.#isResolverMode()) {\n const logoutTokenClaims = await this.authClient.verifyLogoutToken({ logoutToken });\n await this.#stateStore.deleteByLogoutToken(logoutTokenClaims, storeOptions);\n return;\n }\n\n const issuer = decodeIssuer(logoutToken);\n if (!issuer) {\n throw new BackchannelLogoutError('Logout token is missing an issuer');\n }\n\n const resolvedDomain = await this.#resolveDomain(storeOptions);\n const domain = normalizeDomain(issuer);\n if (domain !== resolvedDomain) {\n throw new BackchannelLogoutError('Logout token issuer does not match the resolved domain');\n }\n\n const authClient = this.#getAuthClient(domain);\n const logoutTokenClaims = await authClient.verifyLogoutToken({ logoutToken });\n\n await this.#stateStore.deleteByLogoutToken({ ...logoutTokenClaims, iss: issuer }, storeOptions);\n }\n}\n","/**\n * Compares two sets of scopes to determine if all required scopes are present in the provided scopes.\n * @param scopes Scopes to compare\n * @param requiredScopes Scopes required to be present in the scopes\n * @returns True if all required scopes are present in the scopes, false otherwise\n */\nexport const compareScopes = (scopes: string | undefined, requiredScopes: string | undefined) => {\n // When the scopes and requiredScopes are exactly the same, return true\n // This handles cases where both are empty or undefined or both are the same string\n if (scopes === requiredScopes) {\n return true;\n }\n\n if (!scopes || !requiredScopes) {\n return false;\n }\n\n const scopesSet = new Set(scopes.trim().split(' ').filter(Boolean));\n const requiredScopesArray = requiredScopes.trim().split(' ').filter(Boolean);\n\n return requiredScopesArray.every((scope) => scopesSet.has(scope));\n};\n","import { TelemetryConfig } from '@auth0/auth0-auth-js';\n\n// These constants are injected at build time via tsup\ndeclare const __AUTH0_SERVER_JS_PACKAGE_NAME__: string;\ndeclare const __AUTH0_SERVER_JS_PACKAGE_VERSION__: string;\n\nexport function getTelemetryConfig(config?: TelemetryConfig): TelemetryConfig {\n if (config?.enabled === false) {\n return config;\n }\n\n return {\n enabled: true,\n name: config?.name ?? __AUTH0_SERVER_JS_PACKAGE_NAME__,\n version: config?.version ?? __AUTH0_SERVER_JS_PACKAGE_VERSION__,\n };\n}\n","import { updateStateData } from '../state/utils.js';\nimport type { ServerMfaClientOptions, MfaVerifyResponse } from './types.js';\nimport type {\n ListAuthenticatorsOptions,\n AuthenticatorResponse,\n EnrollAuthenticatorOptions,\n EnrollmentResponse,\n ChallengeOptions,\n ChallengeResponse,\n MfaVerifyOptions,\n} from '@auth0/auth0-auth-js';\n\nexport class ServerMfaClient<TStoreOptions = unknown> {\n readonly #options: ServerMfaClientOptions<TStoreOptions>;\n\n /**\n * @internal\n */\n constructor(options: ServerMfaClientOptions<TStoreOptions>) {\n this.#options = options;\n }\n\n /**\n * Lists all MFA authenticators enrolled by the user.\n *\n * @param options - Options for listing authenticators\n * @returns Promise resolving to an array of enrolled authenticators\n * @throws {MfaListAuthenticatorsError} When the request fails\n */\n async listAuthenticators(options: ListAuthenticatorsOptions): Promise<AuthenticatorResponse[]> {\n return this.#options.authClient.mfa.listAuthenticators(options);\n }\n\n /**\n * Enrolls a new MFA authenticator for the user.\n *\n * @param options - Enrollment options\n * @returns Promise resolving to enrollment response with authenticator details\n * @throws {MfaEnrollmentError} When enrollment fails\n */\n async enrollAuthenticator(options: EnrollAuthenticatorOptions): Promise<EnrollmentResponse> {\n return this.#options.authClient.mfa.enrollAuthenticator(options);\n }\n\n /**\n * Initiates an MFA challenge for user verification.\n *\n * @param options - Challenge options\n * @returns Promise resolving to challenge response with challenge details\n * @throws {MfaChallengeError} When the challenge fails\n */\n async challengeAuthenticator(options: ChallengeOptions): Promise<ChallengeResponse> {\n return this.#options.authClient.mfa.challengeAuthenticator(options);\n }\n\n /**\n * Verifies an MFA challenge and completes the authentication flow.\n *\n * Exchanges the MFA token and verification code for access, ID, and refresh tokens,\n * then saves them into the user's session automatically.\n *\n * @param options - The MFA token, factor type (otp / oob / recovery-code), and the code to verify\n * @param storeOptions - Optional options forwarded to the session store. Can be omitted when\n * using the built-in stores; required if your custom store needs extra context (e.g. a request object).\n * @returns The tokens returned by Auth0 after successful verification\n * @throws {MfaVerifyError} When verification fails (e.g. invalid token, wrong code)\n */\n async verify(options: MfaVerifyOptions, storeOptions?: TStoreOptions): Promise<MfaVerifyResponse> {\n const tokenResponse = await this.#options.authClient.mfa.verify(options);\n\n const audience = options.audience ?? this.#options.defaultAudience;\n const existingStateData = await this.#options.stateStore.get(\n this.#options.stateStoreIdentifier,\n storeOptions\n );\n\n const updatedStateData = updateStateData(audience, existingStateData, tokenResponse, {\n domain: this.#options.domain,\n });\n\n await this.#options.stateStore.set(\n this.#options.stateStoreIdentifier,\n updatedStateData,\n true,\n storeOptions\n );\n\n const result: MfaVerifyResponse = {\n accessToken: tokenResponse.accessToken,\n tokenType: tokenResponse.tokenType ?? 'bearer',\n expiresAt: tokenResponse.expiresAt,\n scope: tokenResponse.scope,\n };\n\n if (tokenResponse.idToken) result.idToken = tokenResponse.idToken;\n if (tokenResponse.refreshToken) result.refreshToken = tokenResponse.refreshToken;\n if (tokenResponse.recoveryCode) result.recoveryCode = tokenResponse.recoveryCode;\n\n return result;\n }\n}\n","import { EncryptJWT, jwtDecrypt, errors } from 'jose';\nimport type { JWTPayload } from 'jose';\nimport { InvalidConfigurationError } from '../errors.js';\n\nconst ENC = 'A256CBC-HS512';\nconst ALG = 'dir';\nconst DIGEST = 'SHA-256';\nconst BIT_LENGTH = 512;\nconst HKDF_INFO = 'derived cookie encryption secret';\n\nlet encoder: TextEncoder | undefined;\n\n/**\n * Type guard to determine if an error is a decryption-related error.\n * Decryption errors (JWEDecryptionFailed, JWEInvalid) indicate issues with the encryption key or data format.\n * These are distinct from claim validation errors (like expiration), which indicate a valid token with invalid claims.\n * @param e - The error thrown during decryption\n * @returns True if the error is a decryption error, false otherwise\n */\nexport function isDecryptionError(e: unknown): e is Error {\n return e instanceof errors.JWEDecryptionFailed || e instanceof errors.JWEInvalid;\n}\n\nasync function deriveEncryptionSecret(secret: string, salt: string, kid: string) {\n encoder ||= new TextEncoder();\n const key = await crypto.subtle.importKey('raw', encoder.encode(secret), 'HKDF', false, ['deriveBits']);\n\n return new Uint8Array(\n await crypto.subtle.deriveBits(\n {\n name: 'HKDF',\n hash: DIGEST,\n info: encoder.encode(HKDF_INFO),\n salt: encoder.encode(`${salt}${kid}`),\n } as HkdfParams,\n key,\n BIT_LENGTH\n )\n );\n}\n\n/**\n * Encrypts a payload using the provided secret and salt, with an expiration time.\n * @param payload The payload to encrypt.\n * @param secret The secret to use for encryption.\n * @param salt The salt to use for encryption.\n * @param expiration The expiration time for the encrypted payload.\n * @returns The encrypted payload.\n */\nasync function _encrypt(payload: JWTPayload, secret: string, salt: string, expiration: number) {\n const kid = crypto.randomUUID();\n const encryptionSecret = await deriveEncryptionSecret(secret, salt, kid);\n\n return await new EncryptJWT(payload)\n .setProtectedHeader({ enc: ENC, alg: ALG, kid: kid })\n .setExpirationTime(expiration)\n .encrypt(encryptionSecret);\n}\n\n/**\n * Encrypts a payload using the provided secret and salt, with an expiration time.\n * The secret can be a single string or an array of strings for secret rotation support.\n * When using an array of secrets, only the first one is used for encryption (all secrets are tried for decryption).\n * @param payload The payload to encrypt.\n * @param secret The secret(s) to use for encryption. Can be a single string or an array of strings for secret rotation support.\n * @param salt The salt to use for encryption.\n * @param expiration The expiration time for the encrypted payload.\n * @returns The encrypted payload.\n */\nexport async function encrypt(payload: JWTPayload, secret: string | string[], salt: string, expiration: number) {\n if (typeof secret === 'string') {\n return await _encrypt(payload, secret, salt, expiration);\n } else {\n // For encryption, we only use the newest secret, as the old secrets are only used for backward compatibility during decryption.\n const [newSecret] = secret;\n\n if (!newSecret) {\n throw new InvalidConfigurationError('At least one secret must be provided');\n }\n\n return await _encrypt(payload, newSecret, salt, expiration);\n }\n}\n\n/**\n * Decrypts an encrypted payload using the provided secret(s) and salt.\n * @param value The encrypted payload to decrypt.\n * @param secret The secret to use for decryption.\n * @param salt The salt to use for decryption.\n * @returns The decrypted payload.\n */\nexport async function _decrypt<T>(value: string, secret: string, salt: string) {\n const res = await jwtDecrypt<T>(\n value,\n async (protectedHeader) => {\n // This error shouldn't happen, as we always set a kid.\n // However, leaving this here as a safety net.\n if (!protectedHeader.kid) {\n throw new Error('Missing \"kid\" in JWE header');\n }\n\n return await deriveEncryptionSecret(secret, salt, protectedHeader.kid);\n },\n { clockTolerance: 15 }\n );\n return res.payload;\n}\n\n/**\n * Decrypts an encrypted payload using the provided secret(s) and salt.\n * The secret can be a single string or an array of strings for secret rotation support.\n * When using an array of secrets, the function will try to decrypt with each secret in order until it succeeds or exhausts all options.\n * Only decryption-related errors (JWEDecryptionFailed, JWEInvalid) will trigger fallback to old secrets.\n * Other errors (like expiration) will be thrown immediately.\n * @param value The encrypted payload to decrypt.\n * @param secret The secret(s) to use for decryption. Can be a single string or an array of strings for secret rotation support.\n * @param salt The salt to use for decryption.\n * @returns The decrypted payload.\n */\nexport async function decrypt<T>(value: string, secret: string | string[], salt: string) {\n if (typeof secret === 'string') {\n return await _decrypt<T>(value, secret, salt);\n } else {\n const [newSecret, ...oldSecrets] = secret;\n\n if (!newSecret) {\n throw new InvalidConfigurationError('At least one secret must be provided');\n }\n\n let firstError: Error | undefined;\n\n try {\n return await _decrypt<T>(value, newSecret, salt);\n } catch (err) {\n firstError = err as Error;\n\n // Only try old secrets if this is a decryption-related error\n // Other errors (like expiration) should be thrown immediately\n if (!isDecryptionError(err)) {\n throw firstError;\n }\n\n for (const oldSecret of oldSecrets) {\n try {\n return await _decrypt(value, oldSecret, salt);\n } catch (fallbackErr) {\n // Only ignore decryption errors with old secrets and continue trying with the next one\n // If it's a different type of error, throw it\n if (!isDecryptionError(fallbackErr)) {\n throw fallbackErr;\n }\n }\n }\n\n // If we've exhausted all secrets and still can't decrypt, throw the original error.\n throw firstError;\n }\n }\n}\n","import type { EncryptedStoreOptions, AbstractDataStore } from '../types.js';\nimport { encrypt, decrypt, isDecryptionError } from '../encryption/index.js';\nimport { JWTPayload } from 'jose';\n\n/**\n * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.\n */\nexport abstract class AbstractStore<TData extends JWTPayload, TStoreOptions = unknown> implements AbstractDataStore<TData, TStoreOptions>\n{\n protected readonly options: EncryptedStoreOptions;\n\n constructor(options: EncryptedStoreOptions) {\n this.options = options;\n }\n\n abstract set(identifier: string, state: TData, removeIfExists?: boolean, options?: TStoreOptions | undefined): Promise<void>;\n abstract get(identifier: string, options?: TStoreOptions | undefined): Promise<TData | undefined>;\n abstract delete(identifier: string, options?: TStoreOptions | undefined): Promise<void>;\n\n protected async encrypt<TData extends JWTPayload>(identifier: string, stateData: TData, expiration: number) {\n return await encrypt(stateData, this.options.secret, identifier, expiration);\n }\n\n protected async decrypt<TData>(identifier: string, encryptedStateData: string) {\n try {\n return (await decrypt(encryptedStateData, this.options.secret, identifier)) as TData;\n } catch (e: unknown){\n // When the error is a decryption failure, we want to ignore it and return undefined, as this likely means the session has expired or the data is invalid.\n if (isDecryptionError(e)) {\n return;\n }\n\n throw e;\n }\n }\n}\n","import type { StateData, EncryptedStoreOptions, StateStore, LogoutTokenClaims } from '../types.js';\nimport { AbstractStore } from './abstract-store.js';\n\n/**\n * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.\n */\nexport abstract class AbstractStateStore<TStoreOptions = unknown> extends AbstractStore<StateData, TStoreOptions> implements StateStore<TStoreOptions> {\n constructor(options: EncryptedStoreOptions) {\n super(options);\n }\n\n abstract deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions | undefined): Promise<void>;\n}","import type { EncryptedStoreOptions, TransactionData, TransactionStore } from '../types.js';\nimport { AbstractStore } from './abstract-store.js';\n\n/**\n * Abstract class that can be used to implement an Encrypted JWT Transaction Store, using the 'A256CBC-HS512' encryption algorithm.\n */\nexport abstract class AbstractTransactionStore<TStoreOptions = unknown> extends AbstractStore<TransactionData, TStoreOptions> implements TransactionStore<TStoreOptions> {\n constructor(options: EncryptedStoreOptions) {\n super(options);\n }\n}","export { ServerClient } from './server-client.js';\nexport { AbstractStateStore } from './store/abstract-state-store.js';\nexport { AbstractTransactionStore } from './store/abstract-transaction-store.js';\nexport type { TokenResponse, ActClaim } from '@auth0/auth0-auth-js';\nexport { TokenExchangeError, MissingClientAuthError } from '@auth0/auth0-auth-js';\n\nexport type { CookieHandler, CookieSerializeOptions } from './store/cookie-handler.js';\nexport { CookieTransactionStore } from './store/cookie-transaction-store.js';\n\nexport { StatefulStateStore } from './store/stateful-state-store.js';\nexport type { StatefulStateStoreOptions } from './store/stateful-state-store.js';\nexport { StatelessStateStore } from './store/stateless-state-store.js';\n\nexport * from './errors.js';\nexport * from './types.js';\nexport * from './mfa/index.js';\n","import type { EncryptedStoreOptions, TransactionData } from './../types.js';\nimport { AbstractTransactionStore } from './abstract-transaction-store.js';\nimport type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';\n\nexport class CookieTransactionStore<TStoreOptions> extends AbstractTransactionStore<TStoreOptions> {\n readonly #cookieHandler: CookieHandler<TStoreOptions>;\n\n constructor(options: EncryptedStoreOptions, cookieHandler: CookieHandler<TStoreOptions>) {\n super(options);\n this.#cookieHandler = cookieHandler;\n }\n\n async set(\n identifier: string,\n transactionData: TransactionData,\n removeIfExists?: boolean,\n options?: TStoreOptions\n ): Promise<void> { \n const maxAge = 60 * 60;\n const cookieOpts: CookieSerializeOptions = { httpOnly: true, sameSite: 'lax', path: '/', maxAge };\n const expiration = Math.floor(Date.now() / 1000 + maxAge);\n const encryptedStateData = await this.encrypt(identifier, transactionData, expiration);\n\n this.#cookieHandler.setCookie(identifier, encryptedStateData, cookieOpts, options);\n }\n\n async get(identifier: string, options?: TStoreOptions): Promise<TransactionData | undefined> {\n const cookieValue = this.#cookieHandler.getCookie(identifier, options);\n\n if (cookieValue) {\n return await this.decrypt(identifier, cookieValue);\n }\n }\n\n async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {\n this.#cookieHandler.deleteCookie(identifier, options);\n }\n}\n","import { AbstractStateStore } from './abstract-state-store.js';\nimport type { EncryptedStoreOptions, SessionConfiguration } from '../types.js';\n\nexport abstract class AbstractSessionStore<TStoreOptions> extends AbstractStateStore<TStoreOptions> {\n readonly #rolling: boolean;\n readonly #absoluteDuration: number;\n readonly #inactivityDuration: number;\n\n constructor(options: SessionConfiguration & EncryptedStoreOptions) {\n super(options);\n\n this.#rolling = options.rolling ?? true;\n this.#absoluteDuration = options.absoluteDuration ?? 60 * 60 * 24 * 3;\n this.#inactivityDuration = options.inactivityDuration ?? 60 * 60 * 24 * 1;\n }\n\n /**\n * calculateMaxAge calculates the max age of the session based on createdAt and the rolling and absolute durations.\n */\n protected calculateMaxAge(createdAt: number) {\n if (!this.#rolling) {\n return this.#absoluteDuration;\n }\n\n const now = (Date.now() / 1000) | 0;\n const expiresAt = Math.min(now + this.#inactivityDuration, createdAt + this.#absoluteDuration);\n const maxAge = expiresAt - now;\n\n return maxAge > 0 ? maxAge : 0;\n }\n}","import type {\n EncryptedStoreOptions,\n LogoutTokenClaims,\n SessionConfiguration,\n SessionCookieOptions,\n SessionStore,\n StateData,\n} from '../types.js';\nimport { AbstractSessionStore } from './abstract-session-store.js';\nimport type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';\n\nexport interface StatefulStateStoreOptions<TStoreOptions> extends EncryptedStoreOptions {\n store: SessionStore<TStoreOptions>;\n}\n\nconst generateId = () => {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n};\n\nexport class StatefulStateStore<TStoreOptions> extends AbstractSessionStore<TStoreOptions> {\n readonly #store: SessionStore<TStoreOptions>;\n readonly #cookieOptions: SessionCookieOptions | undefined;\n readonly #cookieHandler: CookieHandler<TStoreOptions>;\n\n constructor(\n options: StatefulStateStoreOptions<TStoreOptions> & SessionConfiguration,\n cookieHandler: CookieHandler<TStoreOptions>\n ) {\n super(options);\n\n this.#store = options.store;\n this.#cookieOptions = options.cookie;\n this.#cookieHandler = cookieHandler;\n }\n\n async set(\n identifier: string,\n stateData: StateData,\n removeIfExists?: boolean,\n options?: TStoreOptions | undefined\n ): Promise<void> {\n let sessionId = await this.getSessionId(identifier, options);\n\n // if this is a new session created by a new login we need to remove the old session\n // from the store and regenerate the session ID to prevent session fixation.\n if (sessionId && removeIfExists) {\n await this.#store.delete(sessionId);\n sessionId = generateId();\n }\n\n sessionId ??= generateId();\n\n const maxAge = this.calculateMaxAge(stateData.internal.createdAt);\n const cookieOpts = this.#getCookieOptions({\n maxAge,\n });\n const expiration = Date.now() / 1000 + maxAge;\n const encryptedStateData = await this.encrypt<{ id: string }>(\n identifier,\n {\n id: sessionId,\n },\n expiration\n );\n\n await this.#store.set(sessionId, stateData);\n\n this.#cookieHandler.setCookie(identifier, encryptedStateData, cookieOpts, options);\n }\n\n async get(identifier: string, options?: TStoreOptions | undefined): Promise<StateData | undefined> {\n const sessionId = await this.getSessionId(identifier, options);\n\n if (sessionId) {\n const stateData = await this.#store.get(sessionId);\n\n // If we have a session cookie, but no `stateData`, we should remove the cookie.\n if (!stateData) {\n this.#cookieHandler.deleteCookie(identifier, options, this.#getCookieOptions());\n }\n\n return stateData;\n }\n }\n\n async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {\n const sessionId = await this.getSessionId(identifier, options);\n\n if (sessionId) {\n await this.#store.delete(sessionId);\n }\n\n this.#cookieHandler.deleteCookie(identifier, options, this.#getCookieOptions());\n }\n\n private async getSessionId(identifier: string, options?: TStoreOptions) {\n const cookieValue = this.#cookieHandler.getCookie(identifier, options);\n if (cookieValue) {\n const sessionCookie = await this.decrypt<{ id: string }>(identifier, cookieValue);\n \n if (sessionCookie) {\n return sessionCookie.id;\n }\n }\n }\n\n deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions | undefined): Promise<void> {\n return this.#store.deleteByLogoutToken(claims, options);\n }\n\n #getCookieOptions(partial?: Partial<CookieSerializeOptions>): CookieSerializeOptions {\n return {\n httpOnly: true,\n sameSite: this.#cookieOptions?.sameSite ?? 'lax',\n path: this.#cookieOptions?.path ?? '/',\n secure: this.#cookieOptions?.secure ?? true,\n ...partial,\n };\n }\n}\n","import type { EncryptedStoreOptions, SessionConfiguration, SessionCookieOptions, StateData } from '../types.js';\nimport { AbstractSessionStore } from './abstract-session-store.js';\nimport type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';\n\nexport class StatelessStateStore<TStoreOptions> extends AbstractSessionStore<TStoreOptions> {\n readonly #cookieOptions: SessionCookieOptions | undefined;\n readonly #cookieHandler: CookieHandler<TStoreOptions>;\n\n constructor(options: SessionConfiguration & EncryptedStoreOptions, cookieHandler: CookieHandler<TStoreOptions>) {\n super(options);\n\n this.#cookieOptions = options.cookie;\n this.#cookieHandler = cookieHandler;\n }\n\n async set(\n identifier: string,\n stateData: StateData,\n removeIfExists?: boolean,\n options?: TStoreOptions | undefined\n ): Promise<void> {\n const maxAge = this.calculateMaxAge(stateData.internal.createdAt);\n const cookieOpts = this.#getCookieOptions({\n maxAge,\n });\n const expiration = Math.floor(Date.now() / 1000 + maxAge);\n const encryptedStateData = await this.encrypt(identifier, stateData, expiration);\n\n const chunkSize = 3072;\n const chunkCount = Math.ceil(encryptedStateData.length / chunkSize);\n const chunks = [...Array(chunkCount).keys()].map((i) => ({\n value: encryptedStateData.substring(i * chunkSize, (i + 1) * chunkSize),\n name: `${identifier}.${i}`,\n }));\n\n chunks.forEach((chunk) => {\n this.#cookieHandler.setCookie(chunk.name, chunk.value, cookieOpts, options);\n });\n\n const existingCookieKeys = this.getCookieKeys(identifier, options);\n const cookieKeysToRemove = existingCookieKeys.filter((key) => !chunks.some((chunk) => chunk.name === key));\n cookieKeysToRemove.forEach((key) => {\n this.#cookieHandler.deleteCookie(key, options, cookieOpts);\n });\n }\n\n async get(identifier: string, options?: TStoreOptions | undefined): Promise<StateData | undefined> {\n const cookieKeys = this.getCookieKeys(identifier, options);\n const encryptedStateData = cookieKeys\n .map((key) => ({\n index: parseInt(key.split('.')[1] as string, 10),\n value: this.#cookieHandler.getCookie(key, options),\n }))\n .sort((a, b) => a.index - b.index)\n .map((item) => item.value)\n .join('');\n\n if (encryptedStateData) {\n return await this.decrypt(identifier, encryptedStateData);\n }\n }\n\n async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {\n const cookieKeys = this.getCookieKeys(identifier, options);\n for (const key of cookieKeys) {\n this.#cookieHandler.deleteCookie(key, options, this.#getCookieOptions());\n }\n }\n\n deleteByLogoutToken(): Promise<void> {\n throw new Error(\n 'Backchannel logout is not available when using Stateless Storage. Use Stateful Storage by providing a `sessionStore`'\n );\n }\n\n private getCookieKeys(identifier: string, options?: TStoreOptions): string[] {\n return Object.keys(this.#cookieHandler.getCookies(options)).filter((key) => key.startsWith(identifier));\n }\n\n #getCookieOptions(partial?: Partial<CookieSerializeOptions>): CookieSerializeOptions {\n return {\n httpOnly: true,\n sameSite: this.#cookieOptions?.sameSite ?? 'lax',\n path: this.#cookieOptions?.path ?? '/',\n secure: this.#cookieOptions?.secure ?? true,\n ...partial,\n };\n }\n}\n","export { ServerMfaClient } from './server-mfa-client.js';\nexport type { MfaVerifyResponse } from './types.js';\nexport type {\n MfaFactorType,\n MfaVerifyOtpOptions,\n MfaVerifyOobOptions,\n MfaVerifyRecoveryCodeOptions,\n MfaVerifyOptions,\n} from '@auth0/auth0-auth-js';\n\n// Re-export MFA types and errors from auth0-auth-js for convenience\nexport type {\n AuthenticatorResponse,\n AuthenticatorType,\n OobChannel,\n ListAuthenticatorsOptions,\n EnrollOtpOptions,\n EnrollOobOptions,\n EnrollEmailOptions,\n EnrollAuthenticatorOptions,\n OtpEnrollmentResponse,\n OobEnrollmentResponse,\n EnrollmentResponse,\n ChallengeOptions,\n ChallengeResponse,\n MfaRequirements,\n} from '@auth0/auth0-auth-js';\n\nexport {\n MfaListAuthenticatorsError,\n MfaEnrollmentError,\n MfaChallengeError,\n MfaVerifyError,\n isMfaRequiredError,\n} from '@auth0/auth0-auth-js';\n"],"mappings":";AAGO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EAC1C,OAAe;AAAA,EAEtB,YAAY,SAAkB;AAC5B,UAAM,WAAW,6BAA6B;AAC9C,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,yBAAN,cAAqC,MAAM;AAAA,EACzC,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACrC,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,+BAAN,cAA2C,MAAM;AAAA,EAC/C,OAAe;AAAA,EAEtB,YAAY,UAAkB;AAC5B,UAAM,iBAAiB,QAAQ,qCAAqC;AACpE,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACtC,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,4BAAN,cAAwC,MAAM;AAAA,EAC5C,OAAe;AAAA,EAEtB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAKO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KAAK,kBAAkB,CAAC;AAAA,IACzE;AAAA,EACF;AAAA,EAEA,sBAAqC;AACnC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,cAAc,YAAoB,SAAmC;AAC3E,WAAO,OAAO,KAAK,KAAK,eAAe,WAAW,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,IAAI,WAAW,UAAU,CAAC;AAAA,EACxG;AAAA,EAEA,kBAAkB,SAAmE;AACnF,WAAO;AAAA,MACL,UAAU;AAAA,MACV,UAAU,KAAK,gBAAgB,YAAY;AAAA,MAC3C,MAAM,KAAK,gBAAgB,QAAQ;AAAA,MACnC,QAAQ,KAAK,gBAAgB,UAAU;AAAA,MACvC,GAAG;AAAA,IACL;AAAA,EACF;AACF;;;AC5DA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["tokenSet","logoutTokenClaims"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth0/auth0-server-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Auth0 Authentication SDK for Server-Side Applications on JavaScript runtimes",
|
|
5
5
|
"author": "Auth0",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"clean": "rm -rf ./dist",
|
|
12
12
|
"lint": "eslint \"./**/*.ts*\"",
|
|
13
13
|
"test": "vitest run",
|
|
14
|
-
"test:ci": "vitest --watch false --coverage"
|
|
14
|
+
"test:ci": "vitest --watch false --coverage",
|
|
15
|
+
"test:workers": "vitest run --config vitest.config.workers.ts"
|
|
15
16
|
},
|
|
16
17
|
"types": "./dist/index.d.ts",
|
|
17
18
|
"main": "./dist/index.cjs",
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@auth0/auth0-auth-js": "^1.
|
|
28
|
+
"@auth0/auth0-auth-js": "^1.9.1",
|
|
28
29
|
"jose": "^6.0.8"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
@@ -36,7 +37,9 @@
|
|
|
36
37
|
"tsup": "^8.4.0",
|
|
37
38
|
"typescript": "~5.8.3",
|
|
38
39
|
"typescript-eslint": "^8.24.0",
|
|
39
|
-
"vitest": "^3.0.5"
|
|
40
|
+
"vitest": "^3.0.5",
|
|
41
|
+
"@cloudflare/vitest-pool-workers": "^0.12.10",
|
|
42
|
+
"wrangler": "^4.98.0"
|
|
40
43
|
},
|
|
41
44
|
"files": [
|
|
42
45
|
"dist"
|