@auth0/auth0-server-js 1.9.0 → 1.10.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.cjs +135 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -3
- package/dist/index.d.ts +92 -3
- package/dist/index.js +128 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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, TokenResponse } from '@auth0/auth0-auth-js';
|
|
2
|
-
export { ActClaim, AuthenticatorResponse, AuthenticatorType, ChallengeOptions, ChallengeResponse, 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, TelemetryConfig, TokenExchangeError, TokenResponse, isMfaRequiredError } from '@auth0/auth0-auth-js';
|
|
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';
|
|
3
3
|
import { JWTPayload } from 'jose';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -330,6 +330,13 @@ interface GetAccessTokenOptions {
|
|
|
330
330
|
*/
|
|
331
331
|
scope?: string;
|
|
332
332
|
}
|
|
333
|
+
interface RevokeRefreshTokenOptions {
|
|
334
|
+
/**
|
|
335
|
+
* Explicitly provide a refresh token to revoke.
|
|
336
|
+
* If omitted, the token stored in the current session is used.
|
|
337
|
+
*/
|
|
338
|
+
token?: string;
|
|
339
|
+
}
|
|
333
340
|
interface LogoutOptions {
|
|
334
341
|
returnTo: string;
|
|
335
342
|
}
|
|
@@ -602,6 +609,59 @@ declare class ServerPasskeyClient<TStoreOptions = unknown> {
|
|
|
602
609
|
getToken(options: GetTokenByPasskeyOptions, storeOptions?: TStoreOptions): Promise<PasskeyGetTokenResult>;
|
|
603
610
|
}
|
|
604
611
|
|
|
612
|
+
/**
|
|
613
|
+
* @internal
|
|
614
|
+
* Options for constructing a ServerDatabaseClient.
|
|
615
|
+
*
|
|
616
|
+
* Like the passkey client, the database client resolves the domain per call so
|
|
617
|
+
* it keeps working in resolver (multi-tenant) mode. It therefore receives the
|
|
618
|
+
* parent client's `resolveDomain` and `getAuthClient` helpers instead of a
|
|
619
|
+
* fixed domain/authClient. Unlike the MFA/passkey clients, it never touches the
|
|
620
|
+
* state store — signup and change-password write no session.
|
|
621
|
+
*/
|
|
622
|
+
interface ServerDatabaseClientOptions<TStoreOptions = unknown> {
|
|
623
|
+
resolveDomain: (storeOptions?: TStoreOptions) => Promise<string>;
|
|
624
|
+
getAuthClient: (domain: string) => AuthClient;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
declare class ServerDatabaseClient<TStoreOptions = unknown> {
|
|
628
|
+
#private;
|
|
629
|
+
/**
|
|
630
|
+
* @internal
|
|
631
|
+
*/
|
|
632
|
+
constructor(options: ServerDatabaseClientOptions<TStoreOptions>);
|
|
633
|
+
/**
|
|
634
|
+
* Registers a new user in a database connection.
|
|
635
|
+
*
|
|
636
|
+
* Delegates to the underlying `AuthClient.database.signUp` without any session
|
|
637
|
+
* state modification. The caller is responsible for handling the returned user
|
|
638
|
+
* data as needed.
|
|
639
|
+
*
|
|
640
|
+
* @param options The signup options (email, password, connection, etc.).
|
|
641
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
642
|
+
*
|
|
643
|
+
* @throws {SignUpError} If there was an issue signing the user up.
|
|
644
|
+
*
|
|
645
|
+
* @returns A promise resolving to the created user result with a normalized `id` field.
|
|
646
|
+
*/
|
|
647
|
+
signUp(options: SignUpOptions, storeOptions?: TStoreOptions): Promise<SignUpResult>;
|
|
648
|
+
/**
|
|
649
|
+
* Requests a password-change email for a database connection user.
|
|
650
|
+
*
|
|
651
|
+
* Delegates to the underlying `AuthClient.database.changePassword` without any
|
|
652
|
+
* session state modification. The caller is responsible for informing the user
|
|
653
|
+
* of the sent email as needed.
|
|
654
|
+
*
|
|
655
|
+
* @param options The password change options (email, connection, organization, etc.).
|
|
656
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
657
|
+
*
|
|
658
|
+
* @throws {ChangePasswordError} If there was an issue requesting the password change.
|
|
659
|
+
*
|
|
660
|
+
* @returns A promise resolving to the server's plain-text confirmation message.
|
|
661
|
+
*/
|
|
662
|
+
changePassword(options: ChangePasswordOptions, storeOptions?: TStoreOptions): Promise<string>;
|
|
663
|
+
}
|
|
664
|
+
|
|
605
665
|
declare class ServerClient<TStoreOptions = unknown> {
|
|
606
666
|
#private;
|
|
607
667
|
/**
|
|
@@ -639,6 +699,19 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
639
699
|
* and `getToken()` so the credential is exchanged against the tenant that issued it.
|
|
640
700
|
*/
|
|
641
701
|
get passkey(): ServerPasskeyClient<TStoreOptions>;
|
|
702
|
+
/**
|
|
703
|
+
* The database client for self-service sign-up and password-change requests
|
|
704
|
+
* against an Auth0 database connection.
|
|
705
|
+
*
|
|
706
|
+
* Provides `signUp()` to register a user and `changePassword()` to request a
|
|
707
|
+
* password-reset email. Both are pure passthrough operations to the Auth0
|
|
708
|
+
* Authentication API — they never read or write the session/state store.
|
|
709
|
+
*
|
|
710
|
+
* Like `passkey`, this property is available in both static and resolver
|
|
711
|
+
* (multi-tenant) domain modes. In resolver mode, pass `storeOptions` so the
|
|
712
|
+
* request resolves the intended tenant.
|
|
713
|
+
*/
|
|
714
|
+
get database(): ServerDatabaseClient<TStoreOptions>;
|
|
642
715
|
constructor(options: ServerClientOptions<TStoreOptions>);
|
|
643
716
|
/**
|
|
644
717
|
* Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
|
|
@@ -850,6 +923,22 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
850
923
|
* @returns The Connection Token Set, containing the access token for the connection, as well as additional information.
|
|
851
924
|
*/
|
|
852
925
|
getAccessTokenForConnection(options: AccessTokenForConnectionOptions, storeOptions?: TStoreOptions): Promise<ConnectionTokenSet>;
|
|
926
|
+
/**
|
|
927
|
+
* Revokes the refresh token stored in the current session, or an explicitly supplied token.
|
|
928
|
+
*
|
|
929
|
+
* In resolver mode, revocation only occurs when the session domain matches the domain resolved
|
|
930
|
+
* for the current request. If the domains differ (or the session has no stored domain), the call
|
|
931
|
+
* returns without revoking to avoid sending a token to the wrong tenant. This guard applies even
|
|
932
|
+
* when a token is passed explicitly via `options.token`.
|
|
933
|
+
*
|
|
934
|
+
* @param options Optionally supply a token to revoke instead of reading from the session.
|
|
935
|
+
* @param storeOptions Optional options passed to the StateStore.
|
|
936
|
+
*
|
|
937
|
+
* @throws {MissingRequiredArgumentError} If `options.token` is an empty string.
|
|
938
|
+
* @throws {MissingSessionError} If no refresh token is found in the session and none was provided.
|
|
939
|
+
* @throws {TokenRevocationError} If the revocation request fails.
|
|
940
|
+
*/
|
|
941
|
+
revokeRefreshToken(options?: RevokeRefreshTokenOptions, storeOptions?: TStoreOptions): Promise<void>;
|
|
853
942
|
/**
|
|
854
943
|
* Logs the user out and returns a URL to redirect the user-agent to after they log out.
|
|
855
944
|
* @param options Options used to configure the logout process.
|
|
@@ -1091,4 +1180,4 @@ declare class SessionExpiredError extends Error {
|
|
|
1091
1180
|
constructor(message?: string);
|
|
1092
1181
|
}
|
|
1093
1182
|
|
|
1094
|
-
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, ServerClient, type ServerClientOptions, 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 };
|
|
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 };
|
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, TokenResponse } from '@auth0/auth0-auth-js';
|
|
2
|
-
export { ActClaim, AuthenticatorResponse, AuthenticatorType, ChallengeOptions, ChallengeResponse, 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, TelemetryConfig, TokenExchangeError, TokenResponse, isMfaRequiredError } from '@auth0/auth0-auth-js';
|
|
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';
|
|
3
3
|
import { JWTPayload } from 'jose';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -330,6 +330,13 @@ interface GetAccessTokenOptions {
|
|
|
330
330
|
*/
|
|
331
331
|
scope?: string;
|
|
332
332
|
}
|
|
333
|
+
interface RevokeRefreshTokenOptions {
|
|
334
|
+
/**
|
|
335
|
+
* Explicitly provide a refresh token to revoke.
|
|
336
|
+
* If omitted, the token stored in the current session is used.
|
|
337
|
+
*/
|
|
338
|
+
token?: string;
|
|
339
|
+
}
|
|
333
340
|
interface LogoutOptions {
|
|
334
341
|
returnTo: string;
|
|
335
342
|
}
|
|
@@ -602,6 +609,59 @@ declare class ServerPasskeyClient<TStoreOptions = unknown> {
|
|
|
602
609
|
getToken(options: GetTokenByPasskeyOptions, storeOptions?: TStoreOptions): Promise<PasskeyGetTokenResult>;
|
|
603
610
|
}
|
|
604
611
|
|
|
612
|
+
/**
|
|
613
|
+
* @internal
|
|
614
|
+
* Options for constructing a ServerDatabaseClient.
|
|
615
|
+
*
|
|
616
|
+
* Like the passkey client, the database client resolves the domain per call so
|
|
617
|
+
* it keeps working in resolver (multi-tenant) mode. It therefore receives the
|
|
618
|
+
* parent client's `resolveDomain` and `getAuthClient` helpers instead of a
|
|
619
|
+
* fixed domain/authClient. Unlike the MFA/passkey clients, it never touches the
|
|
620
|
+
* state store — signup and change-password write no session.
|
|
621
|
+
*/
|
|
622
|
+
interface ServerDatabaseClientOptions<TStoreOptions = unknown> {
|
|
623
|
+
resolveDomain: (storeOptions?: TStoreOptions) => Promise<string>;
|
|
624
|
+
getAuthClient: (domain: string) => AuthClient;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
declare class ServerDatabaseClient<TStoreOptions = unknown> {
|
|
628
|
+
#private;
|
|
629
|
+
/**
|
|
630
|
+
* @internal
|
|
631
|
+
*/
|
|
632
|
+
constructor(options: ServerDatabaseClientOptions<TStoreOptions>);
|
|
633
|
+
/**
|
|
634
|
+
* Registers a new user in a database connection.
|
|
635
|
+
*
|
|
636
|
+
* Delegates to the underlying `AuthClient.database.signUp` without any session
|
|
637
|
+
* state modification. The caller is responsible for handling the returned user
|
|
638
|
+
* data as needed.
|
|
639
|
+
*
|
|
640
|
+
* @param options The signup options (email, password, connection, etc.).
|
|
641
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
642
|
+
*
|
|
643
|
+
* @throws {SignUpError} If there was an issue signing the user up.
|
|
644
|
+
*
|
|
645
|
+
* @returns A promise resolving to the created user result with a normalized `id` field.
|
|
646
|
+
*/
|
|
647
|
+
signUp(options: SignUpOptions, storeOptions?: TStoreOptions): Promise<SignUpResult>;
|
|
648
|
+
/**
|
|
649
|
+
* Requests a password-change email for a database connection user.
|
|
650
|
+
*
|
|
651
|
+
* Delegates to the underlying `AuthClient.database.changePassword` without any
|
|
652
|
+
* session state modification. The caller is responsible for informing the user
|
|
653
|
+
* of the sent email as needed.
|
|
654
|
+
*
|
|
655
|
+
* @param options The password change options (email, connection, organization, etc.).
|
|
656
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
657
|
+
*
|
|
658
|
+
* @throws {ChangePasswordError} If there was an issue requesting the password change.
|
|
659
|
+
*
|
|
660
|
+
* @returns A promise resolving to the server's plain-text confirmation message.
|
|
661
|
+
*/
|
|
662
|
+
changePassword(options: ChangePasswordOptions, storeOptions?: TStoreOptions): Promise<string>;
|
|
663
|
+
}
|
|
664
|
+
|
|
605
665
|
declare class ServerClient<TStoreOptions = unknown> {
|
|
606
666
|
#private;
|
|
607
667
|
/**
|
|
@@ -639,6 +699,19 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
639
699
|
* and `getToken()` so the credential is exchanged against the tenant that issued it.
|
|
640
700
|
*/
|
|
641
701
|
get passkey(): ServerPasskeyClient<TStoreOptions>;
|
|
702
|
+
/**
|
|
703
|
+
* The database client for self-service sign-up and password-change requests
|
|
704
|
+
* against an Auth0 database connection.
|
|
705
|
+
*
|
|
706
|
+
* Provides `signUp()` to register a user and `changePassword()` to request a
|
|
707
|
+
* password-reset email. Both are pure passthrough operations to the Auth0
|
|
708
|
+
* Authentication API — they never read or write the session/state store.
|
|
709
|
+
*
|
|
710
|
+
* Like `passkey`, this property is available in both static and resolver
|
|
711
|
+
* (multi-tenant) domain modes. In resolver mode, pass `storeOptions` so the
|
|
712
|
+
* request resolves the intended tenant.
|
|
713
|
+
*/
|
|
714
|
+
get database(): ServerDatabaseClient<TStoreOptions>;
|
|
642
715
|
constructor(options: ServerClientOptions<TStoreOptions>);
|
|
643
716
|
/**
|
|
644
717
|
* Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
|
|
@@ -850,6 +923,22 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
850
923
|
* @returns The Connection Token Set, containing the access token for the connection, as well as additional information.
|
|
851
924
|
*/
|
|
852
925
|
getAccessTokenForConnection(options: AccessTokenForConnectionOptions, storeOptions?: TStoreOptions): Promise<ConnectionTokenSet>;
|
|
926
|
+
/**
|
|
927
|
+
* Revokes the refresh token stored in the current session, or an explicitly supplied token.
|
|
928
|
+
*
|
|
929
|
+
* In resolver mode, revocation only occurs when the session domain matches the domain resolved
|
|
930
|
+
* for the current request. If the domains differ (or the session has no stored domain), the call
|
|
931
|
+
* returns without revoking to avoid sending a token to the wrong tenant. This guard applies even
|
|
932
|
+
* when a token is passed explicitly via `options.token`.
|
|
933
|
+
*
|
|
934
|
+
* @param options Optionally supply a token to revoke instead of reading from the session.
|
|
935
|
+
* @param storeOptions Optional options passed to the StateStore.
|
|
936
|
+
*
|
|
937
|
+
* @throws {MissingRequiredArgumentError} If `options.token` is an empty string.
|
|
938
|
+
* @throws {MissingSessionError} If no refresh token is found in the session and none was provided.
|
|
939
|
+
* @throws {TokenRevocationError} If the revocation request fails.
|
|
940
|
+
*/
|
|
941
|
+
revokeRefreshToken(options?: RevokeRefreshTokenOptions, storeOptions?: TStoreOptions): Promise<void>;
|
|
853
942
|
/**
|
|
854
943
|
* Logs the user out and returns a URL to redirect the user-agent to after they log out.
|
|
855
944
|
* @param options Options used to configure the logout process.
|
|
@@ -1091,4 +1180,4 @@ declare class SessionExpiredError extends Error {
|
|
|
1091
1180
|
constructor(message?: string);
|
|
1092
1181
|
}
|
|
1093
1182
|
|
|
1094
|
-
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, ServerClient, type ServerClientOptions, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -205,7 +205,7 @@ function getTelemetryConfig(config) {
|
|
|
205
205
|
return {
|
|
206
206
|
enabled: true,
|
|
207
207
|
name: config?.name ?? "@auth0/auth0-server-js",
|
|
208
|
-
version: config?.version ?? "1.
|
|
208
|
+
version: config?.version ?? "1.10.0"
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -384,6 +384,53 @@ var ServerPasskeyClient = class {
|
|
|
384
384
|
}
|
|
385
385
|
};
|
|
386
386
|
|
|
387
|
+
// src/database/server-database-client.ts
|
|
388
|
+
var ServerDatabaseClient = class {
|
|
389
|
+
#options;
|
|
390
|
+
/**
|
|
391
|
+
* @internal
|
|
392
|
+
*/
|
|
393
|
+
constructor(options) {
|
|
394
|
+
this.#options = options;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Registers a new user in a database connection.
|
|
398
|
+
*
|
|
399
|
+
* Delegates to the underlying `AuthClient.database.signUp` without any session
|
|
400
|
+
* state modification. The caller is responsible for handling the returned user
|
|
401
|
+
* data as needed.
|
|
402
|
+
*
|
|
403
|
+
* @param options The signup options (email, password, connection, etc.).
|
|
404
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
405
|
+
*
|
|
406
|
+
* @throws {SignUpError} If there was an issue signing the user up.
|
|
407
|
+
*
|
|
408
|
+
* @returns A promise resolving to the created user result with a normalized `id` field.
|
|
409
|
+
*/
|
|
410
|
+
async signUp(options, storeOptions) {
|
|
411
|
+
const domain = await this.#options.resolveDomain(storeOptions);
|
|
412
|
+
return this.#options.getAuthClient(domain).database.signUp(options);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Requests a password-change email for a database connection user.
|
|
416
|
+
*
|
|
417
|
+
* Delegates to the underlying `AuthClient.database.changePassword` without any
|
|
418
|
+
* session state modification. The caller is responsible for informing the user
|
|
419
|
+
* of the sent email as needed.
|
|
420
|
+
*
|
|
421
|
+
* @param options The password change options (email, connection, organization, etc.).
|
|
422
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
423
|
+
*
|
|
424
|
+
* @throws {ChangePasswordError} If there was an issue requesting the password change.
|
|
425
|
+
*
|
|
426
|
+
* @returns A promise resolving to the server's plain-text confirmation message.
|
|
427
|
+
*/
|
|
428
|
+
async changePassword(options, storeOptions) {
|
|
429
|
+
const domain = await this.#options.resolveDomain(storeOptions);
|
|
430
|
+
return this.#options.getAuthClient(domain).database.changePassword(options);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
387
434
|
// src/server-client.ts
|
|
388
435
|
var normalizeDomain = (value) => {
|
|
389
436
|
const trimmed = value.trim();
|
|
@@ -409,6 +456,7 @@ var ServerClient = class {
|
|
|
409
456
|
#authClient;
|
|
410
457
|
#mfaClient;
|
|
411
458
|
#passkeyClient;
|
|
459
|
+
#databaseClient;
|
|
412
460
|
/**
|
|
413
461
|
* The underlying `authClient` instance that can be used to interact with the Auth0 Authentication API.
|
|
414
462
|
* Generally, you should prefer to use the higher-level methods exposed on the `ServerClient` instance.
|
|
@@ -456,6 +504,21 @@ var ServerClient = class {
|
|
|
456
504
|
get passkey() {
|
|
457
505
|
return this.#passkeyClient;
|
|
458
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* The database client for self-service sign-up and password-change requests
|
|
509
|
+
* against an Auth0 database connection.
|
|
510
|
+
*
|
|
511
|
+
* Provides `signUp()` to register a user and `changePassword()` to request a
|
|
512
|
+
* password-reset email. Both are pure passthrough operations to the Auth0
|
|
513
|
+
* Authentication API — they never read or write the session/state store.
|
|
514
|
+
*
|
|
515
|
+
* Like `passkey`, this property is available in both static and resolver
|
|
516
|
+
* (multi-tenant) domain modes. In resolver mode, pass `storeOptions` so the
|
|
517
|
+
* request resolves the intended tenant.
|
|
518
|
+
*/
|
|
519
|
+
get database() {
|
|
520
|
+
return this.#databaseClient;
|
|
521
|
+
}
|
|
459
522
|
constructor(options) {
|
|
460
523
|
this.#options = options;
|
|
461
524
|
this.#stateStoreIdentifier = this.#options.stateIdentifier || "__a0_session";
|
|
@@ -505,6 +568,10 @@ var ServerClient = class {
|
|
|
505
568
|
defaultScope: this.#options.authorizationParams?.scope,
|
|
506
569
|
defaultAudience: this.#options.authorizationParams?.audience
|
|
507
570
|
});
|
|
571
|
+
this.#databaseClient = new ServerDatabaseClient({
|
|
572
|
+
resolveDomain: (storeOptions) => this.#resolveDomain(storeOptions),
|
|
573
|
+
getAuthClient: (domain) => this.#getAuthClient(domain)
|
|
574
|
+
});
|
|
508
575
|
}
|
|
509
576
|
async #resolveDomain(storeOptions) {
|
|
510
577
|
if (typeof this.#options.domain === "function") {
|
|
@@ -1170,6 +1237,47 @@ var ServerClient = class {
|
|
|
1170
1237
|
loginHint: options.loginHint
|
|
1171
1238
|
};
|
|
1172
1239
|
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Revokes the refresh token stored in the current session, or an explicitly supplied token.
|
|
1242
|
+
*
|
|
1243
|
+
* In resolver mode, revocation only occurs when the session domain matches the domain resolved
|
|
1244
|
+
* for the current request. If the domains differ (or the session has no stored domain), the call
|
|
1245
|
+
* returns without revoking to avoid sending a token to the wrong tenant. This guard applies even
|
|
1246
|
+
* when a token is passed explicitly via `options.token`.
|
|
1247
|
+
*
|
|
1248
|
+
* @param options Optionally supply a token to revoke instead of reading from the session.
|
|
1249
|
+
* @param storeOptions Optional options passed to the StateStore.
|
|
1250
|
+
*
|
|
1251
|
+
* @throws {MissingRequiredArgumentError} If `options.token` is an empty string.
|
|
1252
|
+
* @throws {MissingSessionError} If no refresh token is found in the session and none was provided.
|
|
1253
|
+
* @throws {TokenRevocationError} If the revocation request fails.
|
|
1254
|
+
*/
|
|
1255
|
+
async revokeRefreshToken(options = {}, storeOptions) {
|
|
1256
|
+
if (options.token !== void 0 && options.token.length === 0) {
|
|
1257
|
+
throw new MissingRequiredArgumentError("options.token must not be an empty string.");
|
|
1258
|
+
}
|
|
1259
|
+
let refreshToken = options.token;
|
|
1260
|
+
const needsStateData = !refreshToken || this.#isResolverMode();
|
|
1261
|
+
const stateData = needsStateData ? await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions) : void 0;
|
|
1262
|
+
if (!refreshToken) {
|
|
1263
|
+
refreshToken = stateData?.refreshToken;
|
|
1264
|
+
}
|
|
1265
|
+
if (!refreshToken) {
|
|
1266
|
+
throw new MissingSessionError("Unable to revoke refresh token: no refresh token found in session.");
|
|
1267
|
+
}
|
|
1268
|
+
let authClient;
|
|
1269
|
+
if (this.#isResolverMode()) {
|
|
1270
|
+
const resolvedDomain = await this.#resolveDomain(storeOptions);
|
|
1271
|
+
const sessionDomain = stateData ? this.#getSessionDomain(stateData) : void 0;
|
|
1272
|
+
if (stateData && sessionDomain !== resolvedDomain) {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
authClient = this.#getAuthClient(sessionDomain ?? resolvedDomain);
|
|
1276
|
+
} else {
|
|
1277
|
+
authClient = this.authClient;
|
|
1278
|
+
}
|
|
1279
|
+
await authClient.revokeToken({ token: refreshToken, tokenTypeHint: "refresh_token" });
|
|
1280
|
+
}
|
|
1173
1281
|
/**
|
|
1174
1282
|
* Logs the user out and returns a URL to redirect the user-agent to after they log out.
|
|
1175
1283
|
* @param options Options used to configure the logout process.
|
|
@@ -1178,17 +1286,26 @@ var ServerClient = class {
|
|
|
1178
1286
|
*/
|
|
1179
1287
|
async logout(options, storeOptions) {
|
|
1180
1288
|
if (!this.#isResolverMode()) {
|
|
1289
|
+
try {
|
|
1290
|
+
await this.revokeRefreshToken({}, storeOptions);
|
|
1291
|
+
} catch {
|
|
1292
|
+
}
|
|
1181
1293
|
await this.#stateStore.delete(this.#stateStoreIdentifier, storeOptions);
|
|
1182
1294
|
return this.authClient.buildLogoutUrl(options);
|
|
1183
1295
|
}
|
|
1184
1296
|
const resolvedDomain = await this.#resolveDomain(storeOptions);
|
|
1185
1297
|
const authClient = this.#getAuthClient(resolvedDomain);
|
|
1186
1298
|
const stateData = await this.#stateStore.get(this.#stateStoreIdentifier, storeOptions);
|
|
1187
|
-
const sessionDomain = stateData ? this.#getSessionDomain(stateData) : void 0;
|
|
1188
1299
|
if (!stateData) {
|
|
1189
1300
|
return authClient.buildLogoutUrl(options);
|
|
1190
1301
|
}
|
|
1191
|
-
|
|
1302
|
+
const sessionDomain = this.#getSessionDomain(stateData);
|
|
1303
|
+
const domainMatches = sessionDomain === resolvedDomain;
|
|
1304
|
+
if (domainMatches) {
|
|
1305
|
+
try {
|
|
1306
|
+
await this.revokeRefreshToken({}, storeOptions);
|
|
1307
|
+
} catch {
|
|
1308
|
+
}
|
|
1192
1309
|
await this.#stateStore.delete(this.#stateStoreIdentifier, storeOptions);
|
|
1193
1310
|
}
|
|
1194
1311
|
return authClient.buildLogoutUrl(options);
|
|
@@ -1406,7 +1523,7 @@ var AbstractTransactionStore = class extends AbstractStore {
|
|
|
1406
1523
|
};
|
|
1407
1524
|
|
|
1408
1525
|
// src/index.ts
|
|
1409
|
-
import { TokenExchangeError, MissingClientAuthError, OrganizationValidationError as OrganizationValidationError3 } from "@auth0/auth0-auth-js";
|
|
1526
|
+
import { TokenExchangeError, TokenRevocationError, MissingClientAuthError, OrganizationValidationError as OrganizationValidationError3 } from "@auth0/auth0-auth-js";
|
|
1410
1527
|
|
|
1411
1528
|
// src/store/cookie-transaction-store.ts
|
|
1412
1529
|
var CookieTransactionStore = class extends AbstractTransactionStore {
|
|
@@ -1618,10 +1735,14 @@ import {
|
|
|
1618
1735
|
PasskeyGetTokenError,
|
|
1619
1736
|
OrganizationValidationError as OrganizationValidationError2
|
|
1620
1737
|
} from "@auth0/auth0-auth-js";
|
|
1738
|
+
|
|
1739
|
+
// src/database/index.ts
|
|
1740
|
+
import { SignUpError, ChangePasswordError } from "@auth0/auth0-auth-js";
|
|
1621
1741
|
export {
|
|
1622
1742
|
AbstractStateStore,
|
|
1623
1743
|
AbstractTransactionStore,
|
|
1624
1744
|
BackchannelLogoutError,
|
|
1745
|
+
ChangePasswordError,
|
|
1625
1746
|
CookieTransactionStore,
|
|
1626
1747
|
InvalidConfigurationError,
|
|
1627
1748
|
IssuerValidationError,
|
|
@@ -1638,13 +1759,16 @@ export {
|
|
|
1638
1759
|
PasskeyGetTokenError,
|
|
1639
1760
|
PasskeyRegisterError,
|
|
1640
1761
|
ServerClient,
|
|
1762
|
+
ServerDatabaseClient,
|
|
1641
1763
|
ServerMfaClient,
|
|
1642
1764
|
ServerPasskeyClient,
|
|
1643
1765
|
SessionExpiredError,
|
|
1766
|
+
SignUpError,
|
|
1644
1767
|
StartLinkUserError,
|
|
1645
1768
|
StatefulStateStore,
|
|
1646
1769
|
StatelessStateStore,
|
|
1647
1770
|
TokenExchangeError,
|
|
1771
|
+
TokenRevocationError,
|
|
1648
1772
|
isMfaRequiredError
|
|
1649
1773
|
};
|
|
1650
1774
|
//# sourceMappingURL=index.js.map
|