@auth0/auth0-server-js 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { AuthorizationDetails, ExchangeProfileOptions, DiscoveryCacheOptions, TelemetryConfig, AuthClient, ListAuthenticatorsOptions, AuthenticatorResponse, EnrollAuthenticatorOptions, EnrollmentResponse, ChallengeOptions, ChallengeResponse, MfaVerifyOptions, PasskeySignupChallengeOptions, PasskeySignupChallengeResponse, PasskeyLoginChallengeOptions, PasskeyLoginChallengeResponse, GetTokenByPasskeyOptions, SignUpOptions, SignUpResult, ChangePasswordOptions, TokenResponse } from '@auth0/auth0-auth-js';
2
- export { ActClaim, AuthenticatorResponse, AuthenticatorType, ChallengeOptions, ChallengeResponse, ChangePasswordError, ChangePasswordOptions, DiscoveryCacheOptions, EnrollAuthenticatorOptions, EnrollEmailOptions, EnrollOobOptions, EnrollOtpOptions, EnrollmentResponse, ListAuthenticatorsOptions, MfaChallengeError, MfaEnrollmentError, MfaFactorType, MfaListAuthenticatorsError, MfaRequirements, MfaVerifyError, MfaVerifyOobOptions, MfaVerifyOptions, MfaVerifyOtpOptions, MfaVerifyRecoveryCodeOptions, MissingClientAuthError, OobChannel, OobEnrollmentResponse, OrganizationValidationError, OtpEnrollmentResponse, PasskeyChallengeError, PasskeyLoginChallengeOptions as PasskeyChallengeOptions, PasskeyLoginChallengeResponse as PasskeyChallengeResponse, PasskeyCreationOptions, PasskeyCredentialResponse, PasskeyGetTokenError, GetTokenByPasskeyOptions as PasskeyGetTokenOptions, PasskeyRegisterError, PasskeySignupChallengeOptions as PasskeyRegisterOptions, PasskeySignupChallengeResponse as PasskeyRegisterResponse, PasskeyRequestOptions, SignUpError, SignUpOptions, SignUpResult, TelemetryConfig, TokenExchangeError, TokenResponse, TokenRevocationError, isMfaRequiredError } from '@auth0/auth0-auth-js';
1
+ import { ActClaim, AuthorizationDetails, ExchangeProfileOptions, DiscoveryCacheOptions, TelemetryConfig, AuthClient, ListAuthenticatorsOptions, AuthenticatorResponse, EnrollAuthenticatorOptions, EnrollmentResponse, ChallengeOptions, ChallengeResponse, MfaVerifyOptions, PasskeySignupChallengeOptions, PasskeySignupChallengeResponse, PasskeyLoginChallengeOptions, PasskeyLoginChallengeResponse, GetTokenByPasskeyOptions, SignUpOptions, SignUpResult, ChangePasswordOptions, TokenResponse } from '@auth0/auth0-auth-js';
2
+ export { ActClaim, AuthenticatorResponse, AuthenticatorType, ChallengeOptions, ChallengeResponse, ChangePasswordError, ChangePasswordOptions, DiscoveryCacheOptions, EnrollAuthenticatorOptions, EnrollEmailOptions, EnrollOobOptions, EnrollOtpOptions, EnrollmentResponse, ListAuthenticatorsOptions, MfaChallengeError, MfaEnrollmentError, MfaFactorType, MfaListAuthenticatorsError, MfaRequirements, MfaVerifyError, MfaVerifyOobOptions, MfaVerifyOptions, MfaVerifyOtpOptions, MfaVerifyRecoveryCodeOptions, MissingClientAuthError, OobChannel, OobEnrollmentResponse, OrganizationValidationError, OtpEnrollmentResponse, PasskeyChallengeError, PasskeyLoginChallengeOptions as PasskeyChallengeOptions, PasskeyLoginChallengeResponse as PasskeyChallengeResponse, PasskeyCreationOptions, PasskeyCredentialResponse, PasskeyGetTokenError, GetTokenByPasskeyOptions as PasskeyGetTokenOptions, PasskeyRegisterError, PasskeySignupChallengeOptions as PasskeyRegisterOptions, PasskeySignupChallengeResponse as PasskeyRegisterResponse, PasskeyRequestOptions, PasswordlessStartError, PasswordlessVerifyError, SignUpError, SignUpOptions, SignUpResult, TelemetryConfig, TokenExchangeError, TokenResponse, TokenRevocationError, isMfaRequiredError } from '@auth0/auth0-auth-js';
3
3
  import { JWTPayload } from 'jose';
4
4
 
5
5
  /**
@@ -64,6 +64,12 @@ interface UserClaims {
64
64
  email_verified?: boolean;
65
65
  org_id?: string;
66
66
  org_name?: string;
67
+ /**
68
+ * The actor (`act`) claim, present when the session was established via impersonation
69
+ * (e.g. Custom Token Exchange Session Transfer). Identifies the acting party — read it
70
+ * to drive UI such as an impersonation banner.
71
+ */
72
+ act?: ActClaim;
67
73
  [key: string]: unknown;
68
74
  }
69
75
  interface AuthorizationParameters {
@@ -415,6 +421,108 @@ interface LoginWithCustomTokenExchangeResult {
415
421
  */
416
422
  authorizationDetails?: AuthorizationDetails[];
417
423
  }
424
+ /**
425
+ * An explicit actor (the acting party) for a Session Transfer Token request.
426
+ *
427
+ * Supplying this overrides the default behaviour of sourcing the actor from the
428
+ * current agent session's ID token.
429
+ */
430
+ interface SessionTransferActor {
431
+ /**
432
+ * The actor token — for the default flow this is the agent's ID token.
433
+ */
434
+ token: string;
435
+ /**
436
+ * The actor token type URI. Defaults to the ID token URN when omitted
437
+ * (`urn:ietf:params:oauth:token-type:id_token`).
438
+ */
439
+ type?: string;
440
+ }
441
+ /**
442
+ * Options for requesting a Session Transfer Token (STT) for impersonation via
443
+ * session transfer (Custom Token Exchange Release 2).
444
+ *
445
+ * The SDK fills in the protocol plumbing (audience, grant type, and the actor token
446
+ * pair). The `subjectToken` is always developer-supplied — it is your own proof of
447
+ * which customer to impersonate, validated only by your Action.
448
+ *
449
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8693 RFC 8693: OAuth 2.0 Token Exchange}
450
+ */
451
+ interface RequestSessionTransferTokenOptions {
452
+ /**
453
+ * Your proof of which customer to impersonate — opaque to Auth0 and validated by
454
+ * your Action (which then calls `setUserById`). The SDK never produces it.
455
+ */
456
+ subjectToken: string;
457
+ /**
458
+ * A URI identifying the type of the subject token, routing the request to your
459
+ * Token Exchange Profile / Action.
460
+ */
461
+ subjectTokenType: string;
462
+ /**
463
+ * An explicit actor to override the default (the agent session's ID token).
464
+ *
465
+ * Resolution order: this explicit `actor` wins; otherwise the agent session's ID
466
+ * token is used (refreshed when expired); if neither is available the request fails
467
+ * client-side with a `TokenExchangeError` whose code is `actor_unavailable`, before
468
+ * any network call.
469
+ */
470
+ actor?: SessionTransferActor;
471
+ /**
472
+ * Space-separated list of OAuth 2.0 scopes to request for the session's tokens.
473
+ */
474
+ scope?: string;
475
+ /**
476
+ * Additional custom parameters forwarded to the token endpoint (and thus to your
477
+ * Action via `event.request.body`). Cannot override reserved OAuth parameters.
478
+ */
479
+ extra?: Record<string, string | string[]>;
480
+ }
481
+ /**
482
+ * Options for {@link ServerClient.buildSessionTransferRedirect}.
483
+ */
484
+ interface BuildSessionTransferRedirectOptions {
485
+ /**
486
+ * The organization identifier to forward to the target's `/authorize` (as the
487
+ * `organization` query parameter). Required only when the STT was issued in an
488
+ * organization context.
489
+ */
490
+ organization?: string;
491
+ }
492
+ /**
493
+ * The result of requesting a Session Transfer Token (STT) for impersonation via
494
+ * session transfer (Custom Token Exchange).
495
+ *
496
+ * The STT is opaque, single-use, and short-lived (~60s). Hand it to
497
+ * {@link ServerClient.buildSessionTransferRedirect} and do not decode, cache, or persist
498
+ * it. The `act` claim is deliberately not on this result — it only appears on the tokens
499
+ * of the session established after the STT is redeemed at `/authorize`.
500
+ */
501
+ interface SessionTransferTokenResult {
502
+ /**
503
+ * The opaque, single-use Session Transfer Token. Never decode, cache, or persist it.
504
+ */
505
+ sessionTransferToken: string;
506
+ /**
507
+ * The issued token type URI — the session-transfer URN
508
+ * (`urn:auth0:params:oauth:token-type:session_transfer_token`). Branch on this,
509
+ * never on {@link SessionTransferTokenResult.tokenType}.
510
+ */
511
+ issuedTokenType: string;
512
+ /**
513
+ * The token lifetime in seconds (typically ~60).
514
+ */
515
+ expiresIn: number;
516
+ /**
517
+ * The token type as returned by the server (typically `"N_A"`). Informational only —
518
+ * never branch on it.
519
+ */
520
+ tokenType?: string;
521
+ /**
522
+ * The granted scopes, when returned by the server.
523
+ */
524
+ scope?: string;
525
+ }
418
526
  interface SessionCookieOptions {
419
527
  /**
420
528
  * The name of the session cookie.
@@ -985,6 +1093,54 @@ declare class ServerClient<TStoreOptions = unknown> {
985
1093
  * @returns A promise resolving to the token response from Auth0.
986
1094
  */
987
1095
  customTokenExchange(options: CustomTokenExchangeOptions, storeOptions?: TStoreOptions): Promise<TokenResponse>;
1096
+ /**
1097
+ * Requests a Session Transfer Token (STT) for impersonation via session transfer (RFC 8693).
1098
+ *
1099
+ * Performs a Custom Token Exchange against the `urn:{domain}:session_transfer` audience and
1100
+ * returns the resulting STT. The audience is built from the SDK's resolved request domain, so
1101
+ * it is correct under multiple custom domains. The returned STT is opaque and single-use — hand
1102
+ * it to {@link ServerClient.buildSessionTransferRedirect} and do not decode, cache, or persist
1103
+ * it. This method writes nothing to the state store for the STT itself; the `act` claim is not
1104
+ * on the result — it only appears on the target session's tokens once the STT is redeemed.
1105
+ *
1106
+ * An actor is mandatory for an STT (this is what makes it auditable impersonation). It is
1107
+ * resolved in this order: an explicit `options.actor` wins; otherwise the current agent
1108
+ * session's ID token is used, refreshed when it has expired; if neither is available the method
1109
+ * throws before any network call.
1110
+ *
1111
+ * @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
1112
+ * @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
1113
+ *
1114
+ * @throws {TokenExchangeError} With code `actor_unavailable` when no explicit actor is given and no usable session ID token can be resolved — no logged-in agent, a session that belongs to a different domain in resolver mode, or an expired ID token that cannot be refreshed (raised client-side, before any network call). With the default code when the exchange itself fails; a server-side `setactor_required` or `session_transfer_disabled` condition is surfaced via `cause.error` / `cause.error_description`.
1115
+ * @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
1116
+ * @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
1117
+ *
1118
+ * @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
1119
+ */
1120
+ requestSessionTransferToken(options: RequestSessionTransferTokenOptions, storeOptions?: TStoreOptions): Promise<SessionTransferTokenResult>;
1121
+ /**
1122
+ * Builds the redirect URL that hands a Session Transfer Token (STT) to the target app's login URL.
1123
+ *
1124
+ * Returns `targetLoginUrl` with `session_transfer_token` (and `organization`, when provided)
1125
+ * appended as query parameters, URL-encoded. This performs no network call and writes nothing
1126
+ * to the session — it only builds a string. The developer hands the returned URL to their
1127
+ * framework's redirect.
1128
+ *
1129
+ * `targetLoginUrl` attaches a single-use credential, so it must be a trusted, app-controlled
1130
+ * value — never derived from untrusted input (e.g. a `returnTo`), or the token could leak to an
1131
+ * attacker host. To harden against that, the URL must be absolute and use `https:` (an `http:`
1132
+ * URL is accepted only for `localhost` / loopback, to support local development).
1133
+ *
1134
+ * @param targetLoginUrl The target app's login URL (absolute, https).
1135
+ * @param result The {@link SessionTransferTokenResult} from {@link ServerClient.requestSessionTransferToken}.
1136
+ * @param options Optional options, e.g. the `organization` to forward when the STT is org-scoped.
1137
+ *
1138
+ * @throws {MissingRequiredArgumentError} When `targetLoginUrl` is missing or blank.
1139
+ * @throws {InvalidConfigurationError} When `targetLoginUrl` is not an absolute URL, or does not use `https:` (except for loopback hosts).
1140
+ *
1141
+ * @returns A {@link URL} with the STT (and optional organization) as query parameters.
1142
+ */
1143
+ buildSessionTransferRedirect(targetLoginUrl: string, result: SessionTransferTokenResult, options?: BuildSessionTransferRedirectOptions): URL;
988
1144
  /**
989
1145
  * Handles the backchannel logout process by verifying the logout token and deleting the session from the store if the logout token was considered valid.
990
1146
  * @param logoutToken The logout token to verify and use to delete the session from the store.
@@ -1122,6 +1278,31 @@ declare class StatelessStateStore<TStoreOptions> extends AbstractSessionStore<TS
1122
1278
  private getCookieKeys;
1123
1279
  }
1124
1280
 
1281
+ /**
1282
+ * Codes carried on the `code` field of a `TokenExchangeError` raised by the Session
1283
+ * Transfer Token (STT) flow. These are specific to Custom Token Exchange Impersonation
1284
+ * via Session Transfer:
1285
+ *
1286
+ * - `actor_unavailable` — raised client-side, before any network call, when a Session
1287
+ * Transfer Token is requested but no actor could be resolved (no explicit actor and
1288
+ * no usable session ID token).
1289
+ * - `setactor_required` — the server rejected the exchange because the Action did not
1290
+ * call `setActor` (an actor is mandatory for a Session Transfer Token).
1291
+ * - `session_transfer_disabled` — the server rejected the exchange because the tenant
1292
+ * feature flag is off.
1293
+ *
1294
+ * Only `actor_unavailable` is raised by the SDK itself. `setactor_required` and
1295
+ * `session_transfer_disabled` are surfaced from the raw server response via the
1296
+ * error's `cause.error` / `cause.error_description`; they are defined here as named
1297
+ * constants for documentation and for the day the platform returns a machine-readable
1298
+ * code.
1299
+ */
1300
+ declare const TokenExchangeErrorCode: {
1301
+ readonly ACTOR_UNAVAILABLE: "actor_unavailable";
1302
+ readonly SETACTOR_REQUIRED: "setactor_required";
1303
+ readonly SESSION_TRANSFER_DISABLED: "session_transfer_disabled";
1304
+ };
1305
+ type TokenExchangeErrorCode = (typeof TokenExchangeErrorCode)[keyof typeof TokenExchangeErrorCode];
1125
1306
  /**
1126
1307
  * Error thrown when there is no transaction available.
1127
1308
  */
@@ -1180,4 +1361,4 @@ declare class SessionExpiredError extends Error {
1180
1361
  constructor(message?: string);
1181
1362
  }
1182
1363
 
1183
- export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, type CompletePasswordlessEmailOptions, type CompletePasswordlessOptions, type CompletePasswordlessResult, type CompletePasswordlessSmsOptions, type ConnectionTokenSet, type CookieHandler, type CookieSerializeOptions, CookieTransactionStore, type CustomTokenExchangeOptions, type DomainResolver, type EncryptedStoreOptions, type GetAccessTokenOptions, type InternalStateData, InvalidConfigurationError, IssuerValidationError, type LoginBackchannelOptions, type LoginBackchannelResult, type LoginWithCustomTokenExchangeOptions, type LoginWithCustomTokenExchangeResult, type LogoutOptions, type LogoutTokenClaims, type MfaVerifyResponse, MissingRequiredArgumentError, MissingSessionError, MissingTransactionError, type PasskeyGetTokenResult, type RevokeRefreshTokenOptions, ServerClient, type ServerClientOptions, ServerDatabaseClient, ServerMfaClient, ServerPasskeyClient, type SessionConfiguration, type SessionCookieOptions, type SessionData, SessionExpiredError, type SessionStore, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartPasswordlessEmailCodeOptions, type StartPasswordlessEmailLinkOptions, type StartPasswordlessOptions, type StartPasswordlessSmsOptions, type StartUnlinkUserOptions, type StateData, type StateStore, StatefulStateStore, type StatefulStateStoreOptions, StatelessStateStore, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };
1364
+ export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, type BuildSessionTransferRedirectOptions, type CompletePasswordlessEmailOptions, type CompletePasswordlessOptions, type CompletePasswordlessResult, type CompletePasswordlessSmsOptions, type ConnectionTokenSet, type CookieHandler, type CookieSerializeOptions, CookieTransactionStore, type CustomTokenExchangeOptions, type DomainResolver, type EncryptedStoreOptions, type GetAccessTokenOptions, type InternalStateData, InvalidConfigurationError, IssuerValidationError, type LoginBackchannelOptions, type LoginBackchannelResult, type LoginWithCustomTokenExchangeOptions, type LoginWithCustomTokenExchangeResult, type LogoutOptions, type LogoutTokenClaims, type MfaVerifyResponse, MissingRequiredArgumentError, MissingSessionError, MissingTransactionError, type PasskeyGetTokenResult, type RequestSessionTransferTokenOptions, type RevokeRefreshTokenOptions, ServerClient, type ServerClientOptions, ServerDatabaseClient, ServerMfaClient, ServerPasskeyClient, type SessionConfiguration, type SessionCookieOptions, type SessionData, SessionExpiredError, type SessionStore, type SessionTransferActor, type SessionTransferTokenResult, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartPasswordlessEmailCodeOptions, type StartPasswordlessEmailLinkOptions, type StartPasswordlessOptions, type StartPasswordlessSmsOptions, type StartUnlinkUserOptions, type StateData, type StateStore, StatefulStateStore, type StatefulStateStoreOptions, StatelessStateStore, TokenExchangeErrorCode, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AuthorizationDetails, ExchangeProfileOptions, DiscoveryCacheOptions, TelemetryConfig, AuthClient, ListAuthenticatorsOptions, AuthenticatorResponse, EnrollAuthenticatorOptions, EnrollmentResponse, ChallengeOptions, ChallengeResponse, MfaVerifyOptions, PasskeySignupChallengeOptions, PasskeySignupChallengeResponse, PasskeyLoginChallengeOptions, PasskeyLoginChallengeResponse, GetTokenByPasskeyOptions, SignUpOptions, SignUpResult, ChangePasswordOptions, TokenResponse } from '@auth0/auth0-auth-js';
2
- export { ActClaim, AuthenticatorResponse, AuthenticatorType, ChallengeOptions, ChallengeResponse, ChangePasswordError, ChangePasswordOptions, DiscoveryCacheOptions, EnrollAuthenticatorOptions, EnrollEmailOptions, EnrollOobOptions, EnrollOtpOptions, EnrollmentResponse, ListAuthenticatorsOptions, MfaChallengeError, MfaEnrollmentError, MfaFactorType, MfaListAuthenticatorsError, MfaRequirements, MfaVerifyError, MfaVerifyOobOptions, MfaVerifyOptions, MfaVerifyOtpOptions, MfaVerifyRecoveryCodeOptions, MissingClientAuthError, OobChannel, OobEnrollmentResponse, OrganizationValidationError, OtpEnrollmentResponse, PasskeyChallengeError, PasskeyLoginChallengeOptions as PasskeyChallengeOptions, PasskeyLoginChallengeResponse as PasskeyChallengeResponse, PasskeyCreationOptions, PasskeyCredentialResponse, PasskeyGetTokenError, GetTokenByPasskeyOptions as PasskeyGetTokenOptions, PasskeyRegisterError, PasskeySignupChallengeOptions as PasskeyRegisterOptions, PasskeySignupChallengeResponse as PasskeyRegisterResponse, PasskeyRequestOptions, SignUpError, SignUpOptions, SignUpResult, TelemetryConfig, TokenExchangeError, TokenResponse, TokenRevocationError, isMfaRequiredError } from '@auth0/auth0-auth-js';
1
+ import { ActClaim, AuthorizationDetails, ExchangeProfileOptions, DiscoveryCacheOptions, TelemetryConfig, AuthClient, ListAuthenticatorsOptions, AuthenticatorResponse, EnrollAuthenticatorOptions, EnrollmentResponse, ChallengeOptions, ChallengeResponse, MfaVerifyOptions, PasskeySignupChallengeOptions, PasskeySignupChallengeResponse, PasskeyLoginChallengeOptions, PasskeyLoginChallengeResponse, GetTokenByPasskeyOptions, SignUpOptions, SignUpResult, ChangePasswordOptions, TokenResponse } from '@auth0/auth0-auth-js';
2
+ export { ActClaim, AuthenticatorResponse, AuthenticatorType, ChallengeOptions, ChallengeResponse, ChangePasswordError, ChangePasswordOptions, DiscoveryCacheOptions, EnrollAuthenticatorOptions, EnrollEmailOptions, EnrollOobOptions, EnrollOtpOptions, EnrollmentResponse, ListAuthenticatorsOptions, MfaChallengeError, MfaEnrollmentError, MfaFactorType, MfaListAuthenticatorsError, MfaRequirements, MfaVerifyError, MfaVerifyOobOptions, MfaVerifyOptions, MfaVerifyOtpOptions, MfaVerifyRecoveryCodeOptions, MissingClientAuthError, OobChannel, OobEnrollmentResponse, OrganizationValidationError, OtpEnrollmentResponse, PasskeyChallengeError, PasskeyLoginChallengeOptions as PasskeyChallengeOptions, PasskeyLoginChallengeResponse as PasskeyChallengeResponse, PasskeyCreationOptions, PasskeyCredentialResponse, PasskeyGetTokenError, GetTokenByPasskeyOptions as PasskeyGetTokenOptions, PasskeyRegisterError, PasskeySignupChallengeOptions as PasskeyRegisterOptions, PasskeySignupChallengeResponse as PasskeyRegisterResponse, PasskeyRequestOptions, PasswordlessStartError, PasswordlessVerifyError, SignUpError, SignUpOptions, SignUpResult, TelemetryConfig, TokenExchangeError, TokenResponse, TokenRevocationError, isMfaRequiredError } from '@auth0/auth0-auth-js';
3
3
  import { JWTPayload } from 'jose';
4
4
 
5
5
  /**
@@ -64,6 +64,12 @@ interface UserClaims {
64
64
  email_verified?: boolean;
65
65
  org_id?: string;
66
66
  org_name?: string;
67
+ /**
68
+ * The actor (`act`) claim, present when the session was established via impersonation
69
+ * (e.g. Custom Token Exchange Session Transfer). Identifies the acting party — read it
70
+ * to drive UI such as an impersonation banner.
71
+ */
72
+ act?: ActClaim;
67
73
  [key: string]: unknown;
68
74
  }
69
75
  interface AuthorizationParameters {
@@ -415,6 +421,108 @@ interface LoginWithCustomTokenExchangeResult {
415
421
  */
416
422
  authorizationDetails?: AuthorizationDetails[];
417
423
  }
424
+ /**
425
+ * An explicit actor (the acting party) for a Session Transfer Token request.
426
+ *
427
+ * Supplying this overrides the default behaviour of sourcing the actor from the
428
+ * current agent session's ID token.
429
+ */
430
+ interface SessionTransferActor {
431
+ /**
432
+ * The actor token — for the default flow this is the agent's ID token.
433
+ */
434
+ token: string;
435
+ /**
436
+ * The actor token type URI. Defaults to the ID token URN when omitted
437
+ * (`urn:ietf:params:oauth:token-type:id_token`).
438
+ */
439
+ type?: string;
440
+ }
441
+ /**
442
+ * Options for requesting a Session Transfer Token (STT) for impersonation via
443
+ * session transfer (Custom Token Exchange Release 2).
444
+ *
445
+ * The SDK fills in the protocol plumbing (audience, grant type, and the actor token
446
+ * pair). The `subjectToken` is always developer-supplied — it is your own proof of
447
+ * which customer to impersonate, validated only by your Action.
448
+ *
449
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8693 RFC 8693: OAuth 2.0 Token Exchange}
450
+ */
451
+ interface RequestSessionTransferTokenOptions {
452
+ /**
453
+ * Your proof of which customer to impersonate — opaque to Auth0 and validated by
454
+ * your Action (which then calls `setUserById`). The SDK never produces it.
455
+ */
456
+ subjectToken: string;
457
+ /**
458
+ * A URI identifying the type of the subject token, routing the request to your
459
+ * Token Exchange Profile / Action.
460
+ */
461
+ subjectTokenType: string;
462
+ /**
463
+ * An explicit actor to override the default (the agent session's ID token).
464
+ *
465
+ * Resolution order: this explicit `actor` wins; otherwise the agent session's ID
466
+ * token is used (refreshed when expired); if neither is available the request fails
467
+ * client-side with a `TokenExchangeError` whose code is `actor_unavailable`, before
468
+ * any network call.
469
+ */
470
+ actor?: SessionTransferActor;
471
+ /**
472
+ * Space-separated list of OAuth 2.0 scopes to request for the session's tokens.
473
+ */
474
+ scope?: string;
475
+ /**
476
+ * Additional custom parameters forwarded to the token endpoint (and thus to your
477
+ * Action via `event.request.body`). Cannot override reserved OAuth parameters.
478
+ */
479
+ extra?: Record<string, string | string[]>;
480
+ }
481
+ /**
482
+ * Options for {@link ServerClient.buildSessionTransferRedirect}.
483
+ */
484
+ interface BuildSessionTransferRedirectOptions {
485
+ /**
486
+ * The organization identifier to forward to the target's `/authorize` (as the
487
+ * `organization` query parameter). Required only when the STT was issued in an
488
+ * organization context.
489
+ */
490
+ organization?: string;
491
+ }
492
+ /**
493
+ * The result of requesting a Session Transfer Token (STT) for impersonation via
494
+ * session transfer (Custom Token Exchange).
495
+ *
496
+ * The STT is opaque, single-use, and short-lived (~60s). Hand it to
497
+ * {@link ServerClient.buildSessionTransferRedirect} and do not decode, cache, or persist
498
+ * it. The `act` claim is deliberately not on this result — it only appears on the tokens
499
+ * of the session established after the STT is redeemed at `/authorize`.
500
+ */
501
+ interface SessionTransferTokenResult {
502
+ /**
503
+ * The opaque, single-use Session Transfer Token. Never decode, cache, or persist it.
504
+ */
505
+ sessionTransferToken: string;
506
+ /**
507
+ * The issued token type URI — the session-transfer URN
508
+ * (`urn:auth0:params:oauth:token-type:session_transfer_token`). Branch on this,
509
+ * never on {@link SessionTransferTokenResult.tokenType}.
510
+ */
511
+ issuedTokenType: string;
512
+ /**
513
+ * The token lifetime in seconds (typically ~60).
514
+ */
515
+ expiresIn: number;
516
+ /**
517
+ * The token type as returned by the server (typically `"N_A"`). Informational only —
518
+ * never branch on it.
519
+ */
520
+ tokenType?: string;
521
+ /**
522
+ * The granted scopes, when returned by the server.
523
+ */
524
+ scope?: string;
525
+ }
418
526
  interface SessionCookieOptions {
419
527
  /**
420
528
  * The name of the session cookie.
@@ -985,6 +1093,54 @@ declare class ServerClient<TStoreOptions = unknown> {
985
1093
  * @returns A promise resolving to the token response from Auth0.
986
1094
  */
987
1095
  customTokenExchange(options: CustomTokenExchangeOptions, storeOptions?: TStoreOptions): Promise<TokenResponse>;
1096
+ /**
1097
+ * Requests a Session Transfer Token (STT) for impersonation via session transfer (RFC 8693).
1098
+ *
1099
+ * Performs a Custom Token Exchange against the `urn:{domain}:session_transfer` audience and
1100
+ * returns the resulting STT. The audience is built from the SDK's resolved request domain, so
1101
+ * it is correct under multiple custom domains. The returned STT is opaque and single-use — hand
1102
+ * it to {@link ServerClient.buildSessionTransferRedirect} and do not decode, cache, or persist
1103
+ * it. This method writes nothing to the state store for the STT itself; the `act` claim is not
1104
+ * on the result — it only appears on the target session's tokens once the STT is redeemed.
1105
+ *
1106
+ * An actor is mandatory for an STT (this is what makes it auditable impersonation). It is
1107
+ * resolved in this order: an explicit `options.actor` wins; otherwise the current agent
1108
+ * session's ID token is used, refreshed when it has expired; if neither is available the method
1109
+ * throws before any network call.
1110
+ *
1111
+ * @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
1112
+ * @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
1113
+ *
1114
+ * @throws {TokenExchangeError} With code `actor_unavailable` when no explicit actor is given and no usable session ID token can be resolved — no logged-in agent, a session that belongs to a different domain in resolver mode, or an expired ID token that cannot be refreshed (raised client-side, before any network call). With the default code when the exchange itself fails; a server-side `setactor_required` or `session_transfer_disabled` condition is surfaced via `cause.error` / `cause.error_description`.
1115
+ * @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
1116
+ * @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
1117
+ *
1118
+ * @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
1119
+ */
1120
+ requestSessionTransferToken(options: RequestSessionTransferTokenOptions, storeOptions?: TStoreOptions): Promise<SessionTransferTokenResult>;
1121
+ /**
1122
+ * Builds the redirect URL that hands a Session Transfer Token (STT) to the target app's login URL.
1123
+ *
1124
+ * Returns `targetLoginUrl` with `session_transfer_token` (and `organization`, when provided)
1125
+ * appended as query parameters, URL-encoded. This performs no network call and writes nothing
1126
+ * to the session — it only builds a string. The developer hands the returned URL to their
1127
+ * framework's redirect.
1128
+ *
1129
+ * `targetLoginUrl` attaches a single-use credential, so it must be a trusted, app-controlled
1130
+ * value — never derived from untrusted input (e.g. a `returnTo`), or the token could leak to an
1131
+ * attacker host. To harden against that, the URL must be absolute and use `https:` (an `http:`
1132
+ * URL is accepted only for `localhost` / loopback, to support local development).
1133
+ *
1134
+ * @param targetLoginUrl The target app's login URL (absolute, https).
1135
+ * @param result The {@link SessionTransferTokenResult} from {@link ServerClient.requestSessionTransferToken}.
1136
+ * @param options Optional options, e.g. the `organization` to forward when the STT is org-scoped.
1137
+ *
1138
+ * @throws {MissingRequiredArgumentError} When `targetLoginUrl` is missing or blank.
1139
+ * @throws {InvalidConfigurationError} When `targetLoginUrl` is not an absolute URL, or does not use `https:` (except for loopback hosts).
1140
+ *
1141
+ * @returns A {@link URL} with the STT (and optional organization) as query parameters.
1142
+ */
1143
+ buildSessionTransferRedirect(targetLoginUrl: string, result: SessionTransferTokenResult, options?: BuildSessionTransferRedirectOptions): URL;
988
1144
  /**
989
1145
  * Handles the backchannel logout process by verifying the logout token and deleting the session from the store if the logout token was considered valid.
990
1146
  * @param logoutToken The logout token to verify and use to delete the session from the store.
@@ -1122,6 +1278,31 @@ declare class StatelessStateStore<TStoreOptions> extends AbstractSessionStore<TS
1122
1278
  private getCookieKeys;
1123
1279
  }
1124
1280
 
1281
+ /**
1282
+ * Codes carried on the `code` field of a `TokenExchangeError` raised by the Session
1283
+ * Transfer Token (STT) flow. These are specific to Custom Token Exchange Impersonation
1284
+ * via Session Transfer:
1285
+ *
1286
+ * - `actor_unavailable` — raised client-side, before any network call, when a Session
1287
+ * Transfer Token is requested but no actor could be resolved (no explicit actor and
1288
+ * no usable session ID token).
1289
+ * - `setactor_required` — the server rejected the exchange because the Action did not
1290
+ * call `setActor` (an actor is mandatory for a Session Transfer Token).
1291
+ * - `session_transfer_disabled` — the server rejected the exchange because the tenant
1292
+ * feature flag is off.
1293
+ *
1294
+ * Only `actor_unavailable` is raised by the SDK itself. `setactor_required` and
1295
+ * `session_transfer_disabled` are surfaced from the raw server response via the
1296
+ * error's `cause.error` / `cause.error_description`; they are defined here as named
1297
+ * constants for documentation and for the day the platform returns a machine-readable
1298
+ * code.
1299
+ */
1300
+ declare const TokenExchangeErrorCode: {
1301
+ readonly ACTOR_UNAVAILABLE: "actor_unavailable";
1302
+ readonly SETACTOR_REQUIRED: "setactor_required";
1303
+ readonly SESSION_TRANSFER_DISABLED: "session_transfer_disabled";
1304
+ };
1305
+ type TokenExchangeErrorCode = (typeof TokenExchangeErrorCode)[keyof typeof TokenExchangeErrorCode];
1125
1306
  /**
1126
1307
  * Error thrown when there is no transaction available.
1127
1308
  */
@@ -1180,4 +1361,4 @@ declare class SessionExpiredError extends Error {
1180
1361
  constructor(message?: string);
1181
1362
  }
1182
1363
 
1183
- export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, type CompletePasswordlessEmailOptions, type CompletePasswordlessOptions, type CompletePasswordlessResult, type CompletePasswordlessSmsOptions, type ConnectionTokenSet, type CookieHandler, type CookieSerializeOptions, CookieTransactionStore, type CustomTokenExchangeOptions, type DomainResolver, type EncryptedStoreOptions, type GetAccessTokenOptions, type InternalStateData, InvalidConfigurationError, IssuerValidationError, type LoginBackchannelOptions, type LoginBackchannelResult, type LoginWithCustomTokenExchangeOptions, type LoginWithCustomTokenExchangeResult, type LogoutOptions, type LogoutTokenClaims, type MfaVerifyResponse, MissingRequiredArgumentError, MissingSessionError, MissingTransactionError, type PasskeyGetTokenResult, type RevokeRefreshTokenOptions, ServerClient, type ServerClientOptions, ServerDatabaseClient, ServerMfaClient, ServerPasskeyClient, type SessionConfiguration, type SessionCookieOptions, type SessionData, SessionExpiredError, type SessionStore, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartPasswordlessEmailCodeOptions, type StartPasswordlessEmailLinkOptions, type StartPasswordlessOptions, type StartPasswordlessSmsOptions, type StartUnlinkUserOptions, type StateData, type StateStore, StatefulStateStore, type StatefulStateStoreOptions, StatelessStateStore, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };
1364
+ export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, type BuildSessionTransferRedirectOptions, type CompletePasswordlessEmailOptions, type CompletePasswordlessOptions, type CompletePasswordlessResult, type CompletePasswordlessSmsOptions, type ConnectionTokenSet, type CookieHandler, type CookieSerializeOptions, CookieTransactionStore, type CustomTokenExchangeOptions, type DomainResolver, type EncryptedStoreOptions, type GetAccessTokenOptions, type InternalStateData, InvalidConfigurationError, IssuerValidationError, type LoginBackchannelOptions, type LoginBackchannelResult, type LoginWithCustomTokenExchangeOptions, type LoginWithCustomTokenExchangeResult, type LogoutOptions, type LogoutTokenClaims, type MfaVerifyResponse, MissingRequiredArgumentError, MissingSessionError, MissingTransactionError, type PasskeyGetTokenResult, type RequestSessionTransferTokenOptions, type RevokeRefreshTokenOptions, ServerClient, type ServerClientOptions, ServerDatabaseClient, ServerMfaClient, ServerPasskeyClient, type SessionConfiguration, type SessionCookieOptions, type SessionData, SessionExpiredError, type SessionStore, type SessionTransferActor, type SessionTransferTokenResult, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartPasswordlessEmailCodeOptions, type StartPasswordlessEmailLinkOptions, type StartPasswordlessOptions, type StartPasswordlessSmsOptions, type StartUnlinkUserOptions, type StateData, type StateStore, StatefulStateStore, type StatefulStateStoreOptions, StatelessStateStore, TokenExchangeErrorCode, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };