@auth0/auth0-server-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,333 @@
1
+ import { AuthorizationDetails } from '@auth0/auth0-auth-js';
2
+ import { JWTPayload } from 'jose';
3
+
4
+ interface ServerClientOptions<TStoreOptions = unknown> {
5
+ domain: string;
6
+ clientId: string;
7
+ clientSecret?: string;
8
+ clientAssertionSigningKey?: string | CryptoKey;
9
+ clientAssertionSigningAlg?: string;
10
+ authorizationParams?: AuthorizationParameters;
11
+ transactionIdentifier?: string;
12
+ stateIdentifier?: string;
13
+ /**
14
+ * Optional, custom Fetch implementation to use.
15
+ */
16
+ customFetch?: typeof fetch;
17
+ transactionStore: TransactionStore<TStoreOptions>;
18
+ stateStore: StateStore<TStoreOptions>;
19
+ }
20
+ interface UserClaims {
21
+ sub: string;
22
+ name?: string;
23
+ nickname?: string;
24
+ given_name?: string;
25
+ family_name?: string;
26
+ picture?: string;
27
+ email?: string;
28
+ email_verified?: boolean;
29
+ org_id?: string;
30
+ [key: string]: unknown;
31
+ }
32
+ interface AuthorizationParameters {
33
+ scope?: string;
34
+ audience?: string;
35
+ redirect_uri?: string;
36
+ [key: string]: unknown;
37
+ }
38
+ interface TokenSet {
39
+ audience: string;
40
+ accessToken: string;
41
+ scope: string | undefined;
42
+ expiresAt: number;
43
+ }
44
+ interface ConnectionTokenSet {
45
+ accessToken: string;
46
+ scope: string | undefined;
47
+ expiresAt: number;
48
+ connection: string;
49
+ loginHint?: string;
50
+ }
51
+ interface InternalStateData {
52
+ sid: string;
53
+ createdAt: number;
54
+ }
55
+ interface StateData extends SessionData {
56
+ internal: InternalStateData;
57
+ }
58
+ interface SessionData {
59
+ user: UserClaims | undefined;
60
+ idToken: string | undefined;
61
+ refreshToken: string | undefined;
62
+ tokenSets: TokenSet[];
63
+ connectionTokenSets?: ConnectionTokenSet[];
64
+ [key: string]: unknown;
65
+ }
66
+ interface TransactionData {
67
+ audience?: string;
68
+ codeVerifier: string;
69
+ [key: string]: unknown;
70
+ }
71
+ interface AbstractDataStore<TData, TStoreOptions = unknown> {
72
+ set(identifier: string, state: TData, removeIfExists?: boolean, options?: TStoreOptions): Promise<void>;
73
+ get(identifier: string, options?: TStoreOptions): Promise<TData | undefined>;
74
+ delete(identifier: string, options?: TStoreOptions): Promise<void>;
75
+ }
76
+ type LogoutTokenClaims = {
77
+ sub?: string;
78
+ sid?: string;
79
+ };
80
+ interface StateStore<TStoreOptions = unknown> extends AbstractDataStore<StateData, TStoreOptions> {
81
+ deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions): Promise<void>;
82
+ }
83
+ interface TransactionStore<TStoreOptions = unknown> extends AbstractDataStore<TransactionData, TStoreOptions> {
84
+ }
85
+ interface EncryptedStoreOptions {
86
+ secret: string;
87
+ }
88
+ interface StartInteractiveLoginOptions<TAppState = unknown> {
89
+ pushedAuthorizationRequests?: boolean;
90
+ appState?: TAppState;
91
+ authorizationParams?: AuthorizationParameters;
92
+ }
93
+ interface LoginBackchannelOptions {
94
+ bindingMessage: string;
95
+ loginHint: {
96
+ sub: string;
97
+ };
98
+ authorizationParams?: AuthorizationParameters;
99
+ }
100
+ interface LoginBackchannelResult {
101
+ authorizationDetails?: AuthorizationDetails[];
102
+ }
103
+ interface AccessTokenForConnectionOptions {
104
+ connection: string;
105
+ loginHint?: string;
106
+ }
107
+ interface LogoutOptions {
108
+ returnTo: string;
109
+ }
110
+ interface StartLinkUserOptions<TAppState = unknown> {
111
+ connection: string;
112
+ connectionScope: string;
113
+ appState?: TAppState;
114
+ authorizationParams?: AuthorizationParameters;
115
+ }
116
+ interface StartUnlinkUserOptions<TAppState = unknown> {
117
+ connection: string;
118
+ appState?: TAppState;
119
+ authorizationParams?: AuthorizationParameters;
120
+ }
121
+
122
+ declare class ServerClient<TStoreOptions = unknown> {
123
+ #private;
124
+ constructor(options: ServerClientOptions<TStoreOptions>);
125
+ /**
126
+ * Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
127
+ * @param options Optional options used to configure the interactive login process.
128
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
129
+ *
130
+ * @throws {BuildAuthorizationUrlError} If there was an issue when building the Authorization URL.
131
+ *
132
+ * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
133
+ */
134
+ startInteractiveLogin(options?: StartInteractiveLoginOptions, storeOptions?: TStoreOptions): Promise<URL>;
135
+ /**
136
+ * Completes the interactive login process.
137
+ * Takes an URL, extract the Authorization Code flow query parameters and requests a token.
138
+ * @param url The URl from which the query params should be extracted to exchange for a token.
139
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
140
+ *
141
+ * @throws {MissingTransactionError} When no transaction was found.
142
+ * @throws {TokenByCodeError} If there was an issue requesting the access token.
143
+ *
144
+ * @returns A promise resolving to an object, containing the original appState (if present) and the authorizationDetails (when RAR was used).
145
+ */
146
+ completeInteractiveLogin<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions): Promise<{
147
+ appState?: TAppState;
148
+ authorizationDetails?: AuthorizationDetails[];
149
+ }>;
150
+ /**
151
+ * Starts the user linking process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
152
+ * @param options Options used to configure the user linking process.
153
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
154
+ *
155
+ * @throws {MissingSessionError} If there is no active session.
156
+ * @throws {BuildLinkUserUrlError} If there was an issue when building the Authorization URL.
157
+ *
158
+ * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
159
+ */
160
+ startLinkUser(options: StartLinkUserOptions, storeOptions?: TStoreOptions): Promise<URL>;
161
+ /**
162
+ * Completes the user linking process.
163
+ * Takes an URL, extract the Authorization Code flow query parameters and requests a token.
164
+ * @param url The URl from which the query params should be extracted to exchange for a token.
165
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
166
+ *
167
+ * @throws {MissingTransactionError} When no transaction was found.
168
+ * @throws {TokenByCodeError} If there was an issue requesting the access token.
169
+ *
170
+ * @returns A promise resolving to an object, containing the original appState (if present).
171
+ */
172
+ completeLinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions): Promise<{
173
+ appState: TAppState | undefined;
174
+ }>;
175
+ /**
176
+ * Starts the user unlinking process, and returns a URL to redirect the user-agent to to initialize user unlinking at Auth0.
177
+ * @param options Options used to configure the user unlinking process.
178
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
179
+ *
180
+ * @throws {MissingSessionError} If there is no active session.
181
+ * @throws {BuildUnlinkUserUrlError} If there was an issue when building the User Unlinking URL.
182
+ *
183
+ * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
184
+ */
185
+ startUnlinkUser(options: StartUnlinkUserOptions, storeOptions?: TStoreOptions): Promise<URL>;
186
+ /**
187
+ * Completes the user unlinking process.
188
+ * Takes an URL, extract the Authorization Code flow query parameters and requests a token.
189
+ * @param url The URl from which the query params should be extracted to exchange for a token.
190
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
191
+ *
192
+ * @throws {MissingTransactionError} When no transaction was found.
193
+ * @throws {TokenByCodeError} If there was an issue requesting the access token.
194
+ *
195
+ * @returns A promise resolving to an object, containing the original appState (if present).
196
+ */
197
+ completeUnlinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions): Promise<{
198
+ appState: TAppState | undefined;
199
+ }>;
200
+ /**
201
+ * Logs in using Client-Initiated Backchannel Authentication.
202
+ *
203
+ * Using Client-Initiated Backchannel Authentication requires the feature to be enabled in the Auth0 dashboard.
204
+ * @see https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-initiated-backchannel-authentication-flow
205
+ * @param options Options used to configure the backchannel login process.
206
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
207
+ *
208
+ * @throws {BackchannelAuthenticationError} If there was an issue when doing backchannel authentication.
209
+ *
210
+ * @returns A promise resolving to an object, containing the authorizationDetails (when RAR was used).
211
+ */
212
+ loginBackchannel(options: LoginBackchannelOptions, storeOptions?: TStoreOptions): Promise<LoginBackchannelResult>;
213
+ /**
214
+ * Retrieves the user from the store, or undefined if no user found.
215
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
216
+ * @returns The user, or undefined if no user found in the store.
217
+ */
218
+ getUser(storeOptions?: TStoreOptions): Promise<UserClaims | undefined>;
219
+ /**
220
+ * Retrieve the user session from the store, or undefined if no session found.
221
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
222
+ * @returns The sessionm or undefined if no session found in the store.
223
+ */
224
+ getSession(storeOptions?: TStoreOptions): Promise<SessionData | undefined>;
225
+ /**
226
+ * 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.
227
+ * Also updates the store when a new token was retrieved from Auth0.
228
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
229
+ *
230
+ * @throws {TokenByRefreshTokenError} If the refresh token was not found or there was an issue requesting the access token.
231
+ *
232
+ * @returns The Token Set, containing the access token, as well as additional information.
233
+ */
234
+ getAccessToken(storeOptions?: TStoreOptions): Promise<TokenSet>;
235
+ /**
236
+ * Retrieves an access token for a connection.
237
+ *
238
+ * This method attempts to obtain an access token for a specified connection.
239
+ * It first checks if a refresh token exists in the store.
240
+ * If no refresh token is found, it throws an `AccessTokenForConnectionError` indicating
241
+ * that the refresh token was not found.
242
+ *
243
+ * @param options - Options for retrieving an access token for a connection.
244
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
245
+ *
246
+ * @throws {TokenForConnectionError} If the refresh token was not found or there was an issue requesting the access token.
247
+ *
248
+ * @returns The Connection Token Set, containing the access token for the connection, as well as additional information.
249
+ */
250
+ getAccessTokenForConnection(options: AccessTokenForConnectionOptions, storeOptions?: TStoreOptions): Promise<ConnectionTokenSet>;
251
+ /**
252
+ * Logs the user out and returns a URL to redirect the user-agent to after they log out.
253
+ * @param options Options used to configure the logout process.
254
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
255
+ * @returns {URL}
256
+ */
257
+ logout(options: LogoutOptions, storeOptions?: TStoreOptions): Promise<URL>;
258
+ /**
259
+ * Handles the backchannel logout process by verifying the logout token and deleting the session from the store if the logout token was considered valid.
260
+ * @param logoutToken The logout token to verify and use to delete the session from the store.
261
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
262
+ *
263
+ * @throws {BackchannelLogoutError} If the logout token is missing.
264
+ * @throws {VerifyLogoutTokenError} If the logout token is invalid.
265
+ */
266
+ handleBackchannelLogout(logoutToken: string, storeOptions?: TStoreOptions): Promise<void>;
267
+ }
268
+
269
+ /**
270
+ * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.
271
+ */
272
+ declare abstract class AbstractStore<TData extends JWTPayload, TStoreOptions = unknown> implements AbstractDataStore<TData, TStoreOptions> {
273
+ protected readonly options: EncryptedStoreOptions;
274
+ constructor(options: EncryptedStoreOptions);
275
+ abstract set(identifier: string, state: TData, removeIfExists?: boolean, options?: TStoreOptions | undefined): Promise<void>;
276
+ abstract get(identifier: string, options?: TStoreOptions | undefined): Promise<TData | undefined>;
277
+ abstract delete(identifier: string, options?: TStoreOptions | undefined): Promise<void>;
278
+ protected encrypt<TData extends JWTPayload>(identifier: string, stateData: TData, expiration: number): Promise<string>;
279
+ protected decrypt<TData>(identifier: string, encryptedStateData: string): Promise<TData>;
280
+ }
281
+
282
+ /**
283
+ * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.
284
+ */
285
+ declare abstract class AbstractStateStore<TStoreOptions = unknown> extends AbstractStore<StateData, TStoreOptions> implements StateStore<TStoreOptions> {
286
+ constructor(options: EncryptedStoreOptions);
287
+ abstract deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions | undefined): Promise<void>;
288
+ }
289
+
290
+ /**
291
+ * Abstract class that can be used to implement an Encrypted JWT Transaction Store, using the 'A256CBC-HS512' encryption algorithm.
292
+ */
293
+ declare abstract class AbstractTransactionStore<TStoreOptions = unknown> extends AbstractStore<TransactionData, TStoreOptions> implements TransactionStore<TStoreOptions> {
294
+ constructor(options: EncryptedStoreOptions);
295
+ }
296
+
297
+ /**
298
+ * Error thrown when there is no transaction available.
299
+ */
300
+ declare class MissingTransactionError extends Error {
301
+ code: string;
302
+ constructor(message?: string);
303
+ }
304
+ /**
305
+ * Error thrown when backchannel logout fails.
306
+ */
307
+ declare class BackchannelLogoutError extends Error {
308
+ code: string;
309
+ constructor(message: string);
310
+ }
311
+ /**
312
+ * Error thrown when starting the user-linking failed.
313
+ */
314
+ declare class StartLinkUserError extends Error {
315
+ code: string;
316
+ constructor(message: string);
317
+ }
318
+ /**
319
+ * Error thrown when a required argument is missing.
320
+ */
321
+ declare class MissingRequiredArgumentError extends Error {
322
+ code: string;
323
+ constructor(argument: string);
324
+ }
325
+ /**
326
+ * Error thrown when a session is missing.
327
+ */
328
+ declare class MissingSessionError extends Error {
329
+ code: string;
330
+ constructor(message: string);
331
+ }
332
+
333
+ export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, type ConnectionTokenSet, type EncryptedStoreOptions, type InternalStateData, type LoginBackchannelOptions, type LoginBackchannelResult, type LogoutOptions, type LogoutTokenClaims, MissingRequiredArgumentError, MissingSessionError, MissingTransactionError, ServerClient, type ServerClientOptions, type SessionData, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartUnlinkUserOptions, type StateData, type StateStore, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };
@@ -0,0 +1,333 @@
1
+ import { AuthorizationDetails } from '@auth0/auth0-auth-js';
2
+ import { JWTPayload } from 'jose';
3
+
4
+ interface ServerClientOptions<TStoreOptions = unknown> {
5
+ domain: string;
6
+ clientId: string;
7
+ clientSecret?: string;
8
+ clientAssertionSigningKey?: string | CryptoKey;
9
+ clientAssertionSigningAlg?: string;
10
+ authorizationParams?: AuthorizationParameters;
11
+ transactionIdentifier?: string;
12
+ stateIdentifier?: string;
13
+ /**
14
+ * Optional, custom Fetch implementation to use.
15
+ */
16
+ customFetch?: typeof fetch;
17
+ transactionStore: TransactionStore<TStoreOptions>;
18
+ stateStore: StateStore<TStoreOptions>;
19
+ }
20
+ interface UserClaims {
21
+ sub: string;
22
+ name?: string;
23
+ nickname?: string;
24
+ given_name?: string;
25
+ family_name?: string;
26
+ picture?: string;
27
+ email?: string;
28
+ email_verified?: boolean;
29
+ org_id?: string;
30
+ [key: string]: unknown;
31
+ }
32
+ interface AuthorizationParameters {
33
+ scope?: string;
34
+ audience?: string;
35
+ redirect_uri?: string;
36
+ [key: string]: unknown;
37
+ }
38
+ interface TokenSet {
39
+ audience: string;
40
+ accessToken: string;
41
+ scope: string | undefined;
42
+ expiresAt: number;
43
+ }
44
+ interface ConnectionTokenSet {
45
+ accessToken: string;
46
+ scope: string | undefined;
47
+ expiresAt: number;
48
+ connection: string;
49
+ loginHint?: string;
50
+ }
51
+ interface InternalStateData {
52
+ sid: string;
53
+ createdAt: number;
54
+ }
55
+ interface StateData extends SessionData {
56
+ internal: InternalStateData;
57
+ }
58
+ interface SessionData {
59
+ user: UserClaims | undefined;
60
+ idToken: string | undefined;
61
+ refreshToken: string | undefined;
62
+ tokenSets: TokenSet[];
63
+ connectionTokenSets?: ConnectionTokenSet[];
64
+ [key: string]: unknown;
65
+ }
66
+ interface TransactionData {
67
+ audience?: string;
68
+ codeVerifier: string;
69
+ [key: string]: unknown;
70
+ }
71
+ interface AbstractDataStore<TData, TStoreOptions = unknown> {
72
+ set(identifier: string, state: TData, removeIfExists?: boolean, options?: TStoreOptions): Promise<void>;
73
+ get(identifier: string, options?: TStoreOptions): Promise<TData | undefined>;
74
+ delete(identifier: string, options?: TStoreOptions): Promise<void>;
75
+ }
76
+ type LogoutTokenClaims = {
77
+ sub?: string;
78
+ sid?: string;
79
+ };
80
+ interface StateStore<TStoreOptions = unknown> extends AbstractDataStore<StateData, TStoreOptions> {
81
+ deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions): Promise<void>;
82
+ }
83
+ interface TransactionStore<TStoreOptions = unknown> extends AbstractDataStore<TransactionData, TStoreOptions> {
84
+ }
85
+ interface EncryptedStoreOptions {
86
+ secret: string;
87
+ }
88
+ interface StartInteractiveLoginOptions<TAppState = unknown> {
89
+ pushedAuthorizationRequests?: boolean;
90
+ appState?: TAppState;
91
+ authorizationParams?: AuthorizationParameters;
92
+ }
93
+ interface LoginBackchannelOptions {
94
+ bindingMessage: string;
95
+ loginHint: {
96
+ sub: string;
97
+ };
98
+ authorizationParams?: AuthorizationParameters;
99
+ }
100
+ interface LoginBackchannelResult {
101
+ authorizationDetails?: AuthorizationDetails[];
102
+ }
103
+ interface AccessTokenForConnectionOptions {
104
+ connection: string;
105
+ loginHint?: string;
106
+ }
107
+ interface LogoutOptions {
108
+ returnTo: string;
109
+ }
110
+ interface StartLinkUserOptions<TAppState = unknown> {
111
+ connection: string;
112
+ connectionScope: string;
113
+ appState?: TAppState;
114
+ authorizationParams?: AuthorizationParameters;
115
+ }
116
+ interface StartUnlinkUserOptions<TAppState = unknown> {
117
+ connection: string;
118
+ appState?: TAppState;
119
+ authorizationParams?: AuthorizationParameters;
120
+ }
121
+
122
+ declare class ServerClient<TStoreOptions = unknown> {
123
+ #private;
124
+ constructor(options: ServerClientOptions<TStoreOptions>);
125
+ /**
126
+ * Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
127
+ * @param options Optional options used to configure the interactive login process.
128
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
129
+ *
130
+ * @throws {BuildAuthorizationUrlError} If there was an issue when building the Authorization URL.
131
+ *
132
+ * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
133
+ */
134
+ startInteractiveLogin(options?: StartInteractiveLoginOptions, storeOptions?: TStoreOptions): Promise<URL>;
135
+ /**
136
+ * Completes the interactive login process.
137
+ * Takes an URL, extract the Authorization Code flow query parameters and requests a token.
138
+ * @param url The URl from which the query params should be extracted to exchange for a token.
139
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
140
+ *
141
+ * @throws {MissingTransactionError} When no transaction was found.
142
+ * @throws {TokenByCodeError} If there was an issue requesting the access token.
143
+ *
144
+ * @returns A promise resolving to an object, containing the original appState (if present) and the authorizationDetails (when RAR was used).
145
+ */
146
+ completeInteractiveLogin<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions): Promise<{
147
+ appState?: TAppState;
148
+ authorizationDetails?: AuthorizationDetails[];
149
+ }>;
150
+ /**
151
+ * Starts the user linking process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
152
+ * @param options Options used to configure the user linking process.
153
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
154
+ *
155
+ * @throws {MissingSessionError} If there is no active session.
156
+ * @throws {BuildLinkUserUrlError} If there was an issue when building the Authorization URL.
157
+ *
158
+ * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
159
+ */
160
+ startLinkUser(options: StartLinkUserOptions, storeOptions?: TStoreOptions): Promise<URL>;
161
+ /**
162
+ * Completes the user linking process.
163
+ * Takes an URL, extract the Authorization Code flow query parameters and requests a token.
164
+ * @param url The URl from which the query params should be extracted to exchange for a token.
165
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
166
+ *
167
+ * @throws {MissingTransactionError} When no transaction was found.
168
+ * @throws {TokenByCodeError} If there was an issue requesting the access token.
169
+ *
170
+ * @returns A promise resolving to an object, containing the original appState (if present).
171
+ */
172
+ completeLinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions): Promise<{
173
+ appState: TAppState | undefined;
174
+ }>;
175
+ /**
176
+ * Starts the user unlinking process, and returns a URL to redirect the user-agent to to initialize user unlinking at Auth0.
177
+ * @param options Options used to configure the user unlinking process.
178
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
179
+ *
180
+ * @throws {MissingSessionError} If there is no active session.
181
+ * @throws {BuildUnlinkUserUrlError} If there was an issue when building the User Unlinking URL.
182
+ *
183
+ * @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
184
+ */
185
+ startUnlinkUser(options: StartUnlinkUserOptions, storeOptions?: TStoreOptions): Promise<URL>;
186
+ /**
187
+ * Completes the user unlinking process.
188
+ * Takes an URL, extract the Authorization Code flow query parameters and requests a token.
189
+ * @param url The URl from which the query params should be extracted to exchange for a token.
190
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
191
+ *
192
+ * @throws {MissingTransactionError} When no transaction was found.
193
+ * @throws {TokenByCodeError} If there was an issue requesting the access token.
194
+ *
195
+ * @returns A promise resolving to an object, containing the original appState (if present).
196
+ */
197
+ completeUnlinkUser<TAppState = unknown>(url: URL, storeOptions?: TStoreOptions): Promise<{
198
+ appState: TAppState | undefined;
199
+ }>;
200
+ /**
201
+ * Logs in using Client-Initiated Backchannel Authentication.
202
+ *
203
+ * Using Client-Initiated Backchannel Authentication requires the feature to be enabled in the Auth0 dashboard.
204
+ * @see https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-initiated-backchannel-authentication-flow
205
+ * @param options Options used to configure the backchannel login process.
206
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
207
+ *
208
+ * @throws {BackchannelAuthenticationError} If there was an issue when doing backchannel authentication.
209
+ *
210
+ * @returns A promise resolving to an object, containing the authorizationDetails (when RAR was used).
211
+ */
212
+ loginBackchannel(options: LoginBackchannelOptions, storeOptions?: TStoreOptions): Promise<LoginBackchannelResult>;
213
+ /**
214
+ * Retrieves the user from the store, or undefined if no user found.
215
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
216
+ * @returns The user, or undefined if no user found in the store.
217
+ */
218
+ getUser(storeOptions?: TStoreOptions): Promise<UserClaims | undefined>;
219
+ /**
220
+ * Retrieve the user session from the store, or undefined if no session found.
221
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
222
+ * @returns The sessionm or undefined if no session found in the store.
223
+ */
224
+ getSession(storeOptions?: TStoreOptions): Promise<SessionData | undefined>;
225
+ /**
226
+ * 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.
227
+ * Also updates the store when a new token was retrieved from Auth0.
228
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
229
+ *
230
+ * @throws {TokenByRefreshTokenError} If the refresh token was not found or there was an issue requesting the access token.
231
+ *
232
+ * @returns The Token Set, containing the access token, as well as additional information.
233
+ */
234
+ getAccessToken(storeOptions?: TStoreOptions): Promise<TokenSet>;
235
+ /**
236
+ * Retrieves an access token for a connection.
237
+ *
238
+ * This method attempts to obtain an access token for a specified connection.
239
+ * It first checks if a refresh token exists in the store.
240
+ * If no refresh token is found, it throws an `AccessTokenForConnectionError` indicating
241
+ * that the refresh token was not found.
242
+ *
243
+ * @param options - Options for retrieving an access token for a connection.
244
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
245
+ *
246
+ * @throws {TokenForConnectionError} If the refresh token was not found or there was an issue requesting the access token.
247
+ *
248
+ * @returns The Connection Token Set, containing the access token for the connection, as well as additional information.
249
+ */
250
+ getAccessTokenForConnection(options: AccessTokenForConnectionOptions, storeOptions?: TStoreOptions): Promise<ConnectionTokenSet>;
251
+ /**
252
+ * Logs the user out and returns a URL to redirect the user-agent to after they log out.
253
+ * @param options Options used to configure the logout process.
254
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
255
+ * @returns {URL}
256
+ */
257
+ logout(options: LogoutOptions, storeOptions?: TStoreOptions): Promise<URL>;
258
+ /**
259
+ * Handles the backchannel logout process by verifying the logout token and deleting the session from the store if the logout token was considered valid.
260
+ * @param logoutToken The logout token to verify and use to delete the session from the store.
261
+ * @param storeOptions Optional options used to pass to the Transaction and State Store.
262
+ *
263
+ * @throws {BackchannelLogoutError} If the logout token is missing.
264
+ * @throws {VerifyLogoutTokenError} If the logout token is invalid.
265
+ */
266
+ handleBackchannelLogout(logoutToken: string, storeOptions?: TStoreOptions): Promise<void>;
267
+ }
268
+
269
+ /**
270
+ * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.
271
+ */
272
+ declare abstract class AbstractStore<TData extends JWTPayload, TStoreOptions = unknown> implements AbstractDataStore<TData, TStoreOptions> {
273
+ protected readonly options: EncryptedStoreOptions;
274
+ constructor(options: EncryptedStoreOptions);
275
+ abstract set(identifier: string, state: TData, removeIfExists?: boolean, options?: TStoreOptions | undefined): Promise<void>;
276
+ abstract get(identifier: string, options?: TStoreOptions | undefined): Promise<TData | undefined>;
277
+ abstract delete(identifier: string, options?: TStoreOptions | undefined): Promise<void>;
278
+ protected encrypt<TData extends JWTPayload>(identifier: string, stateData: TData, expiration: number): Promise<string>;
279
+ protected decrypt<TData>(identifier: string, encryptedStateData: string): Promise<TData>;
280
+ }
281
+
282
+ /**
283
+ * Abstract class that can be used to implement an Encrypted JWT State Store, using the 'A256CBC-HS512' encryption algorithm.
284
+ */
285
+ declare abstract class AbstractStateStore<TStoreOptions = unknown> extends AbstractStore<StateData, TStoreOptions> implements StateStore<TStoreOptions> {
286
+ constructor(options: EncryptedStoreOptions);
287
+ abstract deleteByLogoutToken(claims: LogoutTokenClaims, options?: TStoreOptions | undefined): Promise<void>;
288
+ }
289
+
290
+ /**
291
+ * Abstract class that can be used to implement an Encrypted JWT Transaction Store, using the 'A256CBC-HS512' encryption algorithm.
292
+ */
293
+ declare abstract class AbstractTransactionStore<TStoreOptions = unknown> extends AbstractStore<TransactionData, TStoreOptions> implements TransactionStore<TStoreOptions> {
294
+ constructor(options: EncryptedStoreOptions);
295
+ }
296
+
297
+ /**
298
+ * Error thrown when there is no transaction available.
299
+ */
300
+ declare class MissingTransactionError extends Error {
301
+ code: string;
302
+ constructor(message?: string);
303
+ }
304
+ /**
305
+ * Error thrown when backchannel logout fails.
306
+ */
307
+ declare class BackchannelLogoutError extends Error {
308
+ code: string;
309
+ constructor(message: string);
310
+ }
311
+ /**
312
+ * Error thrown when starting the user-linking failed.
313
+ */
314
+ declare class StartLinkUserError extends Error {
315
+ code: string;
316
+ constructor(message: string);
317
+ }
318
+ /**
319
+ * Error thrown when a required argument is missing.
320
+ */
321
+ declare class MissingRequiredArgumentError extends Error {
322
+ code: string;
323
+ constructor(argument: string);
324
+ }
325
+ /**
326
+ * Error thrown when a session is missing.
327
+ */
328
+ declare class MissingSessionError extends Error {
329
+ code: string;
330
+ constructor(message: string);
331
+ }
332
+
333
+ export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, type ConnectionTokenSet, type EncryptedStoreOptions, type InternalStateData, type LoginBackchannelOptions, type LoginBackchannelResult, type LogoutOptions, type LogoutTokenClaims, MissingRequiredArgumentError, MissingSessionError, MissingTransactionError, ServerClient, type ServerClientOptions, type SessionData, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartUnlinkUserOptions, type StateData, type StateStore, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };