@auth0/auth0-server-js 1.6.1 → 1.8.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 +435 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +327 -14
- package/dist/index.d.ts +327 -14
- package/dist/index.js +433 -37
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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, OtpEnrollmentResponse, 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, 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';
|
|
3
3
|
import { JWTPayload } from 'jose';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -92,11 +92,25 @@ interface SessionData {
|
|
|
92
92
|
tokenSets: TokenSet[];
|
|
93
93
|
connectionTokenSets?: ConnectionTokenSet[];
|
|
94
94
|
domain?: string;
|
|
95
|
+
/**
|
|
96
|
+
* IPSIE SL1 `session_expiry` ceiling for this session, as an absolute Unix timestamp in
|
|
97
|
+
* seconds. Present only when the user logged in through an enterprise connection configured
|
|
98
|
+
* with `id_token_session_expiry_supported: true`. When set, the SDK treats the session as
|
|
99
|
+
* expired once this time is reached (minus a small leeway) and forces re-authentication.
|
|
100
|
+
* Absent for database/social logins, connections without the option, and sessions created
|
|
101
|
+
* before this feature — those behave unchanged.
|
|
102
|
+
*/
|
|
103
|
+
sessionExpiresAt?: number;
|
|
95
104
|
[key: string]: unknown;
|
|
96
105
|
}
|
|
97
106
|
interface TransactionData {
|
|
98
107
|
audience?: string;
|
|
99
|
-
|
|
108
|
+
/**
|
|
109
|
+
* PKCE code verifier for interactive (authorization-code) logins. Optional because
|
|
110
|
+
* magic-link transactions are bound by anti-forgery `state` only and register no PKCE
|
|
111
|
+
* challenge, so they persist no verifier.
|
|
112
|
+
*/
|
|
113
|
+
codeVerifier?: string;
|
|
100
114
|
domain?: string;
|
|
101
115
|
[key: string]: unknown;
|
|
102
116
|
}
|
|
@@ -143,6 +157,126 @@ interface LoginBackchannelOptions {
|
|
|
143
157
|
interface LoginBackchannelResult {
|
|
144
158
|
authorizationDetails?: AuthorizationDetails[];
|
|
145
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Result of completing a passkey authentication flow (signup or login).
|
|
162
|
+
*/
|
|
163
|
+
interface PasskeyGetTokenResult {
|
|
164
|
+
authorizationDetails?: AuthorizationDetails[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Options for starting an email passwordless flow by sending a one-time code (OTP).
|
|
168
|
+
*
|
|
169
|
+
* Complete it with {@link ServerClient#loginWithPasswordless}.
|
|
170
|
+
*/
|
|
171
|
+
interface StartPasswordlessEmailCodeOptions {
|
|
172
|
+
/** Discriminator: email connection. */
|
|
173
|
+
connection: 'email';
|
|
174
|
+
/** The destination email address. */
|
|
175
|
+
email: string;
|
|
176
|
+
/** Send a one-time code. Optional; this is the default for the email connection. */
|
|
177
|
+
send?: 'code';
|
|
178
|
+
/**
|
|
179
|
+
* BCP-47 language tag forwarded as `x-request-language` to localize the email template.
|
|
180
|
+
*/
|
|
181
|
+
language?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Options for starting an email passwordless magic-link flow.
|
|
185
|
+
*
|
|
186
|
+
* The SDK generates and persists an anti-forgery `state`, sends the link, and validates
|
|
187
|
+
* `state` on the callback. No PKCE is used. Complete it with
|
|
188
|
+
* {@link ServerClient#completePasswordlessMagicLink}.
|
|
189
|
+
*/
|
|
190
|
+
interface StartPasswordlessEmailLinkOptions {
|
|
191
|
+
/** Discriminator: email connection. */
|
|
192
|
+
connection: 'email';
|
|
193
|
+
/** The destination email address. */
|
|
194
|
+
email: string;
|
|
195
|
+
/** Send a magic link. Required literal to select link mode. */
|
|
196
|
+
send: 'link';
|
|
197
|
+
/**
|
|
198
|
+
* The callback URL Auth0 redirects to after the magic link is clicked. Embedded in the link
|
|
199
|
+
* as `redirect_uri`; must be registered on the application.
|
|
200
|
+
*/
|
|
201
|
+
redirectUri: string;
|
|
202
|
+
/**
|
|
203
|
+
* Additional OAuth authorization parameters merged into the link. `client_id`, `response_type`,
|
|
204
|
+
* and `state` are set by the SDK and cannot be overridden.
|
|
205
|
+
*/
|
|
206
|
+
authParams?: Record<string, unknown>;
|
|
207
|
+
/**
|
|
208
|
+
* Scope for the resulting tokens. `openid` is ensured. Include `offline_access` for a refresh token.
|
|
209
|
+
*/
|
|
210
|
+
scope?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Audience for the resulting access token.
|
|
213
|
+
*/
|
|
214
|
+
audience?: string;
|
|
215
|
+
/**
|
|
216
|
+
* BCP-47 language tag forwarded as `x-request-language` to localize the email template.
|
|
217
|
+
*/
|
|
218
|
+
language?: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Options for starting an SMS passwordless flow (one-time code only; SMS has no magic link).
|
|
222
|
+
*
|
|
223
|
+
* Complete it with {@link ServerClient#loginWithPasswordless}.
|
|
224
|
+
*/
|
|
225
|
+
interface StartPasswordlessSmsOptions {
|
|
226
|
+
/** Discriminator: sms connection. */
|
|
227
|
+
connection: 'sms';
|
|
228
|
+
/** Phone number in E.164 format, e.g. `+14155550100`. */
|
|
229
|
+
phoneNumber: string;
|
|
230
|
+
/**
|
|
231
|
+
* BCP-47 language tag forwarded as `x-request-language` to localize the SMS template.
|
|
232
|
+
*/
|
|
233
|
+
language?: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Options for starting a passwordless flow. Discriminated on `connection` (and, for email,
|
|
237
|
+
* on `send`) to mirror the `@auth0/nextjs-auth0` `passwordless.start()` surface.
|
|
238
|
+
*
|
|
239
|
+
* - `{ connection: 'email', send?: 'code' }` — email OTP (default)
|
|
240
|
+
* - `{ connection: 'email', send: 'link', redirectUri }` — email magic link
|
|
241
|
+
* - `{ connection: 'sms' }` — SMS OTP
|
|
242
|
+
*/
|
|
243
|
+
type StartPasswordlessOptions = StartPasswordlessEmailCodeOptions | StartPasswordlessEmailLinkOptions | StartPasswordlessSmsOptions;
|
|
244
|
+
/**
|
|
245
|
+
* Options for completing an email passwordless OTP login and establishing a session.
|
|
246
|
+
*/
|
|
247
|
+
interface CompletePasswordlessEmailOptions {
|
|
248
|
+
/** Discriminator: email connection. */
|
|
249
|
+
connection: 'email';
|
|
250
|
+
/** The email address the code was sent to. */
|
|
251
|
+
email: string;
|
|
252
|
+
/** The one-time code entered by the user. */
|
|
253
|
+
verificationCode: string;
|
|
254
|
+
authorizationParams?: AuthorizationParameters;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Options for completing an SMS passwordless OTP login and establishing a session.
|
|
258
|
+
*/
|
|
259
|
+
interface CompletePasswordlessSmsOptions {
|
|
260
|
+
/** Discriminator: sms connection. */
|
|
261
|
+
connection: 'sms';
|
|
262
|
+
/** The phone number the code was sent to, in E.164 format. */
|
|
263
|
+
phoneNumber: string;
|
|
264
|
+
/** The one-time code entered by the user. */
|
|
265
|
+
verificationCode: string;
|
|
266
|
+
authorizationParams?: AuthorizationParameters;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Options for completing a passwordless OTP login. Discriminated on `connection` to mirror the
|
|
270
|
+
* `@auth0/nextjs-auth0` `passwordless.verify()` surface.
|
|
271
|
+
*/
|
|
272
|
+
type CompletePasswordlessOptions = CompletePasswordlessEmailOptions | CompletePasswordlessSmsOptions;
|
|
273
|
+
/**
|
|
274
|
+
* Result of a passwordless login (OTP or magic link). The session is persisted to the state
|
|
275
|
+
* store; `authorizationDetails` is included when Rich Authorization Requests (RAR) were used.
|
|
276
|
+
*/
|
|
277
|
+
interface CompletePasswordlessResult {
|
|
278
|
+
authorizationDetails?: AuthorizationDetails[];
|
|
279
|
+
}
|
|
146
280
|
interface AccessTokenForConnectionOptions {
|
|
147
281
|
connection: string;
|
|
148
282
|
loginHint?: string;
|
|
@@ -355,6 +489,89 @@ declare class ServerMfaClient<TStoreOptions = unknown> {
|
|
|
355
489
|
verify(options: MfaVerifyOptions, storeOptions?: TStoreOptions): Promise<MfaVerifyResponse>;
|
|
356
490
|
}
|
|
357
491
|
|
|
492
|
+
/**
|
|
493
|
+
* @internal
|
|
494
|
+
* Options for constructing a ServerPasskeyClient.
|
|
495
|
+
*
|
|
496
|
+
* Unlike the MFA client, the passkey client resolves the domain per call so it
|
|
497
|
+
* keeps working in resolver (multi-tenant) mode. It therefore receives the
|
|
498
|
+
* parent client's `resolveDomain` and `getAuthClient` helpers instead of a
|
|
499
|
+
* fixed domain/authClient.
|
|
500
|
+
*/
|
|
501
|
+
interface ServerPasskeyClientOptions<TStoreOptions = unknown> {
|
|
502
|
+
resolveDomain: (storeOptions?: TStoreOptions) => Promise<string>;
|
|
503
|
+
getAuthClient: (domain: string) => AuthClient;
|
|
504
|
+
stateStore: StateStore<TStoreOptions>;
|
|
505
|
+
stateStoreIdentifier: string;
|
|
506
|
+
defaultScope?: string;
|
|
507
|
+
defaultAudience?: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
declare class ServerPasskeyClient<TStoreOptions = unknown> {
|
|
511
|
+
#private;
|
|
512
|
+
/**
|
|
513
|
+
* @internal
|
|
514
|
+
*/
|
|
515
|
+
constructor(options: ServerPasskeyClientOptions<TStoreOptions>);
|
|
516
|
+
/**
|
|
517
|
+
* Requests a passkey signup challenge for a new user.
|
|
518
|
+
*
|
|
519
|
+
* Returns the `authSession` and the WebAuthn credential creation options
|
|
520
|
+
* (`authnParamsPublicKey`). The application must return these to the browser,
|
|
521
|
+
* pass `authnParamsPublicKey` to `navigator.credentials.create()`, and then
|
|
522
|
+
* call `getToken()` with the resulting credential to complete signup.
|
|
523
|
+
*
|
|
524
|
+
* This method does not create a session; no state is persisted.
|
|
525
|
+
*
|
|
526
|
+
* @param options User profile data and optional realm/organization.
|
|
527
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
528
|
+
*
|
|
529
|
+
* @throws {PasskeyRegisterError} If there was an issue requesting the signup challenge.
|
|
530
|
+
*
|
|
531
|
+
* @returns A promise resolving to the signup challenge.
|
|
532
|
+
*/
|
|
533
|
+
register(options: PasskeySignupChallengeOptions, storeOptions?: TStoreOptions): Promise<PasskeySignupChallengeResponse>;
|
|
534
|
+
/**
|
|
535
|
+
* Requests a passkey login challenge for an existing user.
|
|
536
|
+
*
|
|
537
|
+
* Returns the `authSession` and the WebAuthn credential request options
|
|
538
|
+
* (`authnParamsPublicKey`). The application must return these to the browser,
|
|
539
|
+
* pass `authnParamsPublicKey` to `navigator.credentials.get()`, and then
|
|
540
|
+
* call `getToken()` with the resulting credential to complete login.
|
|
541
|
+
*
|
|
542
|
+
* This method does not create a session; no state is persisted.
|
|
543
|
+
*
|
|
544
|
+
* @param options Optional realm/organization configuration.
|
|
545
|
+
* @param storeOptions Optional options used to resolve the domain (resolver mode).
|
|
546
|
+
*
|
|
547
|
+
* @throws {PasskeyChallengeError} If there was an issue requesting the login challenge.
|
|
548
|
+
*
|
|
549
|
+
* @returns A promise resolving to the login challenge.
|
|
550
|
+
*/
|
|
551
|
+
challenge(options?: PasskeyLoginChallengeOptions, storeOptions?: TStoreOptions): Promise<PasskeyLoginChallengeResponse>;
|
|
552
|
+
/**
|
|
553
|
+
* Completes a passkey authentication flow (signup or login) by exchanging the
|
|
554
|
+
* WebAuthn credential for tokens, and persists the resulting session.
|
|
555
|
+
*
|
|
556
|
+
* Call this after obtaining a credential from `navigator.credentials.create()`
|
|
557
|
+
* (signup) or `navigator.credentials.get()` (login), passing the `authSession`
|
|
558
|
+
* returned by `register()` / `challenge()` together with the serialized credential.
|
|
559
|
+
*
|
|
560
|
+
* In resolver (multi-tenant) mode, pass the same `storeOptions` you passed to
|
|
561
|
+
* `register()` / `challenge()` so the token exchange resolves the same tenant
|
|
562
|
+
* that issued the `authSession`; otherwise the exchange will fail.
|
|
563
|
+
*
|
|
564
|
+
* @param options The auth session, serialized credential, and optional realm/scope/audience/organization.
|
|
565
|
+
* @param storeOptions Optional options used to pass to the State Store (and to resolve the domain in resolver mode).
|
|
566
|
+
*
|
|
567
|
+
* @throws {PasskeyGetTokenError} If there was an issue exchanging the credential for tokens. When the cause is `mfa_required`, use `isMfaRequiredError(error)` to narrow the error and read `cause.mfa_token`. No session is persisted in this case.
|
|
568
|
+
* @throws {OrganizationValidationError} When `organization` is passed and the returned ID token's organization claim is missing or does not match. The error is thrown before the session is written, so no session is persisted in this case.
|
|
569
|
+
*
|
|
570
|
+
* @returns A promise resolving to an object containing the authorizationDetails (when RAR was used).
|
|
571
|
+
*/
|
|
572
|
+
getToken(options: GetTokenByPasskeyOptions, storeOptions?: TStoreOptions): Promise<PasskeyGetTokenResult>;
|
|
573
|
+
}
|
|
574
|
+
|
|
358
575
|
declare class ServerClient<TStoreOptions = unknown> {
|
|
359
576
|
#private;
|
|
360
577
|
/**
|
|
@@ -381,6 +598,17 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
381
598
|
* In resolver mode (`domain` as a function), MFA is not supported.
|
|
382
599
|
*/
|
|
383
600
|
get mfa(): ServerMfaClient<TStoreOptions>;
|
|
601
|
+
/**
|
|
602
|
+
* The passkey client for signing up and logging in users with WebAuthn credentials.
|
|
603
|
+
*
|
|
604
|
+
* Provides `register()` and `challenge()` to request signup/login challenges, and
|
|
605
|
+
* `getToken()` to exchange the resulting credential for tokens and persist the session.
|
|
606
|
+
*
|
|
607
|
+
* Unlike `mfa`, this property is available in both static and resolver (multi-tenant)
|
|
608
|
+
* domain modes. In resolver mode, pass the same `storeOptions` to `register()`/`challenge()`
|
|
609
|
+
* and `getToken()` so the credential is exchanged against the tenant that issued it.
|
|
610
|
+
*/
|
|
611
|
+
get passkey(): ServerPasskeyClient<TStoreOptions>;
|
|
384
612
|
constructor(options: ServerClientOptions<TStoreOptions>);
|
|
385
613
|
/**
|
|
386
614
|
* Starts the interactive login process, and returns a URL to redirect the user-agent to to request authorization at Auth0.
|
|
@@ -400,6 +628,7 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
400
628
|
*
|
|
401
629
|
* @throws {MissingTransactionError} When no transaction was found.
|
|
402
630
|
* @throws {TokenByCodeError} If there was an issue requesting the access token.
|
|
631
|
+
* @throws {SessionExpiredError} When the ID token's `session_expiry` is already in the past at login (the session is born expired); nothing is persisted.
|
|
403
632
|
*
|
|
404
633
|
* @returns A promise resolving to an object, containing the original appState (if present) and the authorizationDetails (when RAR was used).
|
|
405
634
|
*/
|
|
@@ -414,6 +643,7 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
414
643
|
*
|
|
415
644
|
* @throws {MissingSessionError} If there is no active session.
|
|
416
645
|
* @throws {BuildLinkUserUrlError} If there was an issue when building the Authorization URL.
|
|
646
|
+
* @throws {SessionExpiredError} When the session's `session_expiry` ceiling has been reached; the session is cleared and re-authentication is required.
|
|
417
647
|
*
|
|
418
648
|
* @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
|
|
419
649
|
*/
|
|
@@ -439,6 +669,7 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
439
669
|
*
|
|
440
670
|
* @throws {MissingSessionError} If there is no active session.
|
|
441
671
|
* @throws {BuildUnlinkUserUrlError} If there was an issue when building the User Unlinking URL.
|
|
672
|
+
* @throws {SessionExpiredError} When the session's `session_expiry` ceiling has been reached; the session is cleared and re-authentication is required.
|
|
442
673
|
*
|
|
443
674
|
* @returns A promise resolving to a URL object, representing the URL to redirect the user-agent to to request authorization at Auth0.
|
|
444
675
|
*/
|
|
@@ -466,10 +697,91 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
466
697
|
* @param storeOptions Optional options used to pass to the Transaction and State Store.
|
|
467
698
|
*
|
|
468
699
|
* @throws {BackchannelAuthenticationError} If there was an issue when doing backchannel authentication.
|
|
700
|
+
* @throws {SessionExpiredError} When the ID token's `session_expiry` is already in the past at login (the session is born expired); nothing is persisted.
|
|
469
701
|
*
|
|
470
702
|
* @returns A promise resolving to an object, containing the authorizationDetails (when RAR was used).
|
|
471
703
|
*/
|
|
472
704
|
loginBackchannel(options: LoginBackchannelOptions, storeOptions?: TStoreOptions): Promise<LoginBackchannelResult>;
|
|
705
|
+
/**
|
|
706
|
+
* Starts a passwordless flow by sending a one-time code (OTP) or a magic link.
|
|
707
|
+
*
|
|
708
|
+
* Discriminated on `connection` (and, for email, `send`) to mirror the
|
|
709
|
+
* `@auth0/nextjs-auth0` `passwordless.start()` surface:
|
|
710
|
+
* - `{ connection: 'email' }` / `{ connection: 'email', send: 'code' }` — email OTP
|
|
711
|
+
* - `{ connection: 'email', send: 'link', redirectUri }` — email magic link
|
|
712
|
+
* - `{ connection: 'sms' }` — SMS OTP
|
|
713
|
+
*
|
|
714
|
+
* OTP modes are a stateless passthrough to the Authentication API (no session, no transaction);
|
|
715
|
+
* complete them with {@link ServerClient#completePasswordless}.
|
|
716
|
+
*
|
|
717
|
+
* Magic-link mode is stateful: the SDK generates an opaque anti-forgery `state`, sends the link
|
|
718
|
+
* with the OAuth parameters embedded (`redirect_uri`, `response_type=code`, `scope`, `state`),
|
|
719
|
+
* and persists a transaction carrying that `state`. NO PKCE challenge is registered, so the
|
|
720
|
+
* transaction holds no `codeVerifier`. Complete it with
|
|
721
|
+
* {@link ServerClient#completePasswordlessMagicLink}. Requires the tenant setting
|
|
722
|
+
* `allow_magiclink_verify_without_session: true` for server-side completion.
|
|
723
|
+
*
|
|
724
|
+
* @param options Discriminated start options.
|
|
725
|
+
* @param storeOptions Optional options passed to the resolver / stores.
|
|
726
|
+
*
|
|
727
|
+
* @throws {PasswordlessStartError} If the request fails, or if a magic link is requested without a `redirectUri`.
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* // Email OTP
|
|
731
|
+
* await serverClient.startPasswordless({ connection: 'email', email: 'user@example.com' });
|
|
732
|
+
* // SMS OTP
|
|
733
|
+
* await serverClient.startPasswordless({ connection: 'sms', phoneNumber: '+14155550100' });
|
|
734
|
+
* // Email magic link
|
|
735
|
+
* await serverClient.startPasswordless({
|
|
736
|
+
* connection: 'email',
|
|
737
|
+
* email: 'user@example.com',
|
|
738
|
+
* send: 'link',
|
|
739
|
+
* redirectUri: 'https://app.example.com/auth/callback',
|
|
740
|
+
* });
|
|
741
|
+
*/
|
|
742
|
+
startPasswordless(options: StartPasswordlessOptions, storeOptions?: TStoreOptions): Promise<void>;
|
|
743
|
+
/**
|
|
744
|
+
* Completes a passwordless OTP login and persists the resulting session.
|
|
745
|
+
*
|
|
746
|
+
* Discriminated on `connection` to mirror the `@auth0/nextjs-auth0` `passwordless.verify()`
|
|
747
|
+
* surface. Non-redirect flow: no PKCE and no transaction store (mirrors
|
|
748
|
+
* {@link ServerClient#loginBackchannel}). The `openid` scope is always ensured by this layer.
|
|
749
|
+
*
|
|
750
|
+
* Note: the state store is read-then-written; if your deployment performs concurrent
|
|
751
|
+
* logins for the same session identifier, use a state store with atomic/serializable
|
|
752
|
+
* writes to avoid last-write-wins races.
|
|
753
|
+
*
|
|
754
|
+
* @param options Discriminated completion options (`connection`, identifier, `verificationCode`).
|
|
755
|
+
* @param storeOptions Optional options passed to the resolver / stores.
|
|
756
|
+
*
|
|
757
|
+
* @throws {PasswordlessVerifyError} If the code is invalid, expired, or rate-limited. When the
|
|
758
|
+
* connection requires MFA, the server responds with `mfa_required`; narrow the thrown error
|
|
759
|
+
* with `isMfaRequiredError(error)` to read `cause.mfa_token`.
|
|
760
|
+
*
|
|
761
|
+
* @returns A promise resolving to the authorizationDetails (when RAR was used).
|
|
762
|
+
*/
|
|
763
|
+
completePasswordless(options: CompletePasswordlessOptions, storeOptions?: TStoreOptions): Promise<CompletePasswordlessResult>;
|
|
764
|
+
/**
|
|
765
|
+
* Completes a passwordless magic-link login and persists the resulting session.
|
|
766
|
+
*
|
|
767
|
+
* Loads the transaction persisted by {@link ServerClient#startPasswordless} (magic-link mode), validates the
|
|
768
|
+
* `state` returned on the callback URL against the stored `state` (anti-forgery binding), exchanges
|
|
769
|
+
* the authorization code WITHOUT PKCE, writes the session, and deletes the transaction. The existing
|
|
770
|
+
* interactive login path ({@link ServerClient#completeInteractiveLogin}) is not used.
|
|
771
|
+
*
|
|
772
|
+
* @param url The callback URL containing the authorization `code` and `state`.
|
|
773
|
+
* @param storeOptions Optional options passed to the resolver / stores.
|
|
774
|
+
*
|
|
775
|
+
* @throws {MissingTransactionError} If no magic-link transaction was found.
|
|
776
|
+
* @throws {PasswordlessVerifyError} If the returned `state` is missing or does not match.
|
|
777
|
+
* @throws {TokenByCodeError} If the token exchange fails.
|
|
778
|
+
*
|
|
779
|
+
* @returns A promise resolving to the authorizationDetails (when RAR was used).
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* const result = await serverClient.completePasswordlessMagicLink(callbackUrl, storeOptions);
|
|
783
|
+
*/
|
|
784
|
+
completePasswordlessMagicLink(url: URL, storeOptions?: TStoreOptions): Promise<CompletePasswordlessResult>;
|
|
473
785
|
/**
|
|
474
786
|
* Retrieves the user from the store, or undefined if no user found.
|
|
475
787
|
* @param storeOptions Optional options used to pass to the Transaction and State Store.
|
|
@@ -482,16 +794,8 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
482
794
|
* @returns The session or undefined if no session found in the store.
|
|
483
795
|
*/
|
|
484
796
|
getSession(storeOptions?: TStoreOptions): Promise<SessionData | undefined>;
|
|
485
|
-
/**
|
|
486
|
-
* 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.
|
|
487
|
-
* Also updates the store when a new token was retrieved from Auth0.
|
|
488
|
-
* @param storeOptions Optional options used to pass to the Transaction and State Store.
|
|
489
|
-
*
|
|
490
|
-
* @throws {TokenByRefreshTokenError} If the refresh token was not found or there was an issue requesting the access token. When the cause is `mfa_required`, use `isMfaRequiredError(error)` to narrow the error and read `cause.mfa_token`.
|
|
491
|
-
*
|
|
492
|
-
* @returns The Token Set, containing the access token, as well as additional information.
|
|
493
|
-
*/
|
|
494
797
|
getAccessToken(storeOptions?: TStoreOptions): Promise<TokenSet>;
|
|
798
|
+
getAccessToken(options: GetAccessTokenOptions, storeOptions?: TStoreOptions): Promise<TokenSet>;
|
|
495
799
|
/**
|
|
496
800
|
* Retrieves an access token for a connection.
|
|
497
801
|
*
|
|
@@ -663,8 +967,9 @@ declare abstract class AbstractSessionStore<TStoreOptions> extends AbstractState
|
|
|
663
967
|
constructor(options: SessionConfiguration & EncryptedStoreOptions);
|
|
664
968
|
/**
|
|
665
969
|
* calculateMaxAge calculates the max age of the session based on createdAt and the rolling and absolute durations.
|
|
970
|
+
* When sessionExpiresAt is provided, caps the maxAge to not exceed the time until that ceiling.
|
|
666
971
|
*/
|
|
667
|
-
protected calculateMaxAge(createdAt: number): number;
|
|
972
|
+
protected calculateMaxAge(createdAt: number, sessionExpiresAt?: number): number;
|
|
668
973
|
}
|
|
669
974
|
|
|
670
975
|
interface StatefulStateStoreOptions<TStoreOptions> extends EncryptedStoreOptions {
|
|
@@ -739,5 +1044,13 @@ declare class IssuerValidationError extends Error {
|
|
|
739
1044
|
code: string;
|
|
740
1045
|
constructor(message: string);
|
|
741
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Error thrown when the session has passed its upstream IdP-asserted
|
|
1049
|
+
* `session_expiry` ceiling (IPSIE SL1). The user must re-authenticate.
|
|
1050
|
+
*/
|
|
1051
|
+
declare class SessionExpiredError extends Error {
|
|
1052
|
+
code: string;
|
|
1053
|
+
constructor(message?: string);
|
|
1054
|
+
}
|
|
742
1055
|
|
|
743
|
-
export { type AbstractDataStore, AbstractStateStore, AbstractTransactionStore, type AccessTokenForConnectionOptions, type AuthorizationParameters, BackchannelLogoutError, 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, ServerClient, type ServerClientOptions, ServerMfaClient, type SessionConfiguration, type SessionCookieOptions, type SessionData, type SessionStore, type StartInteractiveLoginOptions, StartLinkUserError, type StartLinkUserOptions, type StartUnlinkUserOptions, type StateData, type StateStore, StatefulStateStore, type StatefulStateStoreOptions, StatelessStateStore, type TokenSet, type TransactionData, type TransactionStore, type UserClaims };
|
|
1056
|
+
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 };
|