@passflow/core 0.21.1 → 0.23.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/README.md +88 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -5
- package/dist/index.d.ts +157 -5
- package/dist/index.mjs +738 -658
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1213,7 +1213,33 @@ export type PassflowAuthorizationResponse = Tokens & {
|
|
|
1213
1213
|
token_delivery?: 'json_body' | 'cookie' | 'mobile';
|
|
1214
1214
|
cookies?: string[];
|
|
1215
1215
|
csrf_token?: string;
|
|
1216
|
+
/** `true` when the server needs the email proven before this sign-in finishes. No tokens come with it. */
|
|
1217
|
+
email_verification_required?: boolean;
|
|
1218
|
+
/** Human-readable text from the server, e.g. "We sent a code to a***@example.com." */
|
|
1219
|
+
message?: string;
|
|
1220
|
+
};
|
|
1221
|
+
/**
|
|
1222
|
+
* A sign-up, sign-in or password change that waits for the email to be proven.
|
|
1223
|
+
* With `challenge_id`: a code was emailed, finish with `Passflow.verifyEmailCode`.
|
|
1224
|
+
* Without: the code budget is spent and a link was emailed instead.
|
|
1225
|
+
* `message` is what the server sent; a malformed answer may leave it out.
|
|
1226
|
+
*/
|
|
1227
|
+
export type PassflowEmailVerificationStep = {
|
|
1228
|
+
email_verification_required: true;
|
|
1229
|
+
message: string;
|
|
1230
|
+
challenge_id?: string;
|
|
1216
1231
|
};
|
|
1232
|
+
/** The emailed code for a `PassflowEmailVerificationStep` that carried a `challenge_id`. */
|
|
1233
|
+
export type PassflowEmailCodePayload = {
|
|
1234
|
+
challenge_id: string;
|
|
1235
|
+
otp: string;
|
|
1236
|
+
};
|
|
1237
|
+
/**
|
|
1238
|
+
* Whether an auth answer is an email verification step rather than a session. Only the
|
|
1239
|
+
* `email_verification_required` flag is checked, so an answer with the flag is never taken
|
|
1240
|
+
* for a session.
|
|
1241
|
+
*/
|
|
1242
|
+
export declare const isEmailVerificationStep: (response: unknown) => response is PassflowEmailVerificationStep;
|
|
1217
1243
|
export type PassflowValidationResponse = Tokens & {
|
|
1218
1244
|
redirect_url: string;
|
|
1219
1245
|
requires_2fa?: boolean;
|
|
@@ -1393,12 +1419,64 @@ export type AppSettings = {
|
|
|
1393
1419
|
create_tenant_on_registration: 'never' | 'always' | 'optional';
|
|
1394
1420
|
fim_merge_by_email_allowed: boolean;
|
|
1395
1421
|
debug_otp_code_allowed: boolean;
|
|
1396
|
-
|
|
1422
|
+
/**
|
|
1423
|
+
* WRITE-ONLY. Every read and write answer returns it as an empty string; the stored code is
|
|
1424
|
+
* never echoed. On write, a blank or absent value keeps the stored code and a non-blank value
|
|
1425
|
+
* replaces it. The only way to clear it is
|
|
1426
|
+
* `DELETE /admin/apps/{id}/secrets/debug_otp_code_for_registration` (see `AppSecretName`).
|
|
1427
|
+
* Use `debug_otp_code_set` to tell whether a code is stored.
|
|
1428
|
+
*/
|
|
1429
|
+
debug_otp_code_for_registration?: string;
|
|
1430
|
+
/** READ-ONLY. `true` when a `debug_otp_code_for_registration` is stored. Ignored on write. */
|
|
1431
|
+
debug_otp_code_set?: boolean;
|
|
1397
1432
|
defaults: DefaultAppSettings;
|
|
1398
1433
|
login_app_theme: LoginWebAppTheme;
|
|
1399
1434
|
login_app_settings?: unknown;
|
|
1400
1435
|
token_delivery_method?: TokenDeliveryMethod;
|
|
1401
1436
|
};
|
|
1437
|
+
/**
|
|
1438
|
+
* A write-only app secret that the admin API clears by name with
|
|
1439
|
+
* `DELETE /admin/apps/{id}/secrets/{name}`. The SDK has no admin client, so this route is not
|
|
1440
|
+
* wrapped; the names are exported for admin UIs that call it themselves.
|
|
1441
|
+
*
|
|
1442
|
+
* - `debug_otp_code_for_registration`: an `AppSettings` field. Answers return it as an empty
|
|
1443
|
+
* string; `AppSettings.debug_otp_code_set` tells whether one is stored.
|
|
1444
|
+
* - `fcm_server_key`, `webpush_vapid_private_key`: push settings in the app's
|
|
1445
|
+
* `two_factor_settings`. Both are absent from every answer; `webpush_vapid_public_key` is
|
|
1446
|
+
* still returned.
|
|
1447
|
+
*
|
|
1448
|
+
* On write, a blank or absent value keeps the stored secret and a non-blank value replaces it.
|
|
1449
|
+
* DELETE is the only way to clear one. See docs/admin-secrets.md.
|
|
1450
|
+
*/
|
|
1451
|
+
export type AppSecretName = 'debug_otp_code_for_registration' | 'fcm_server_key' | 'webpush_vapid_private_key';
|
|
1452
|
+
/** Every `AppSecretName`, in the order the type lists them. */
|
|
1453
|
+
export declare const APP_SECRET_NAMES: readonly AppSecretName[];
|
|
1454
|
+
/**
|
|
1455
|
+
* A secret in the server settings (`GET`/`PUT /admin/settings`) as the admin API returns it.
|
|
1456
|
+
*
|
|
1457
|
+
* - Secrets come back as `mask://********`.
|
|
1458
|
+
* - Connection strings, dynamo/s3/ssm endpoints, plugin address/cmd, activity-logger endpoints
|
|
1459
|
+
* and management_keys come back as `mask://********` followed by `/` and 16 lowercase
|
|
1460
|
+
* hex characters (e.g. a `/0123456789abcdef` suffix); the suffix tells values apart without
|
|
1461
|
+
* revealing them. (Written in two parts because the full form would end this comment.)
|
|
1462
|
+
*
|
|
1463
|
+
* On `PUT`: echo the masked value unchanged to keep the stored one, send a plain value to
|
|
1464
|
+
* replace it, send an empty string to clear it. A stale or edited masked value fails with
|
|
1465
|
+
* HTTP 400 and id `SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID`. See docs/admin-secrets.md.
|
|
1466
|
+
*/
|
|
1467
|
+
export type MaskedSecret = string;
|
|
1468
|
+
/** The prefix every `MaskedSecret` starts with. */
|
|
1469
|
+
export declare const MASKED_SECRET_PREFIX = "mask://";
|
|
1470
|
+
/**
|
|
1471
|
+
* Error id of the HTTP 400 that `PUT /admin/settings` returns for a masked value the server did
|
|
1472
|
+
* not issue for the stored one (stale or edited).
|
|
1473
|
+
*/
|
|
1474
|
+
export declare const SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID = "error.server.update.settings.masked.value.unknown";
|
|
1475
|
+
/**
|
|
1476
|
+
* Whether a server settings value is a masked secret rather than a plain value: any string that
|
|
1477
|
+
* starts with `MASKED_SECRET_PREFIX`. It does not check that the server would accept it.
|
|
1478
|
+
*/
|
|
1479
|
+
export declare const isMaskedSecret: (value: unknown) => value is MaskedSecret;
|
|
1402
1480
|
export type DefaultAppSettings = {
|
|
1403
1481
|
app_id: string;
|
|
1404
1482
|
redirect: string;
|
|
@@ -1990,6 +2068,13 @@ export declare class AuthAPI {
|
|
|
1990
2068
|
pkceExchange(code: string, verifier: string): Promise<PassflowAuthorizationResponse>;
|
|
1991
2069
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload, deviceId: string, os: OS): Promise<PassflowPasswordlessResponse>;
|
|
1992
2070
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Proves an emailed code for a sign-up, sign-in or password change that answered with
|
|
2073
|
+
* `email_verification_required`. Only `{challenge_id, otp}` is sent: the server reads the
|
|
2074
|
+
* device from the `X-Passflow-DeviceId` header. Sent with credentials, as every call that
|
|
2075
|
+
* ends a sign-in is.
|
|
2076
|
+
*/
|
|
2077
|
+
validateEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
1993
2078
|
logOut(deviceId?: string, refreshToken?: string, isAdmin?: boolean): Promise<PassflowLogoutResponse>;
|
|
1994
2079
|
validateSession(): Promise<PassflowSessionValidationResponse>;
|
|
1995
2080
|
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload): Promise<PassflowSuccessResponse>;
|
|
@@ -3198,6 +3283,8 @@ export declare enum PassflowEvent {
|
|
|
3198
3283
|
SignInStart = "signin:start",
|
|
3199
3284
|
Register = "register",
|
|
3200
3285
|
RegisterStart = "register:start",
|
|
3286
|
+
/** A sign-up, sign-in or password change is waiting for the email to be proven (no session yet). */
|
|
3287
|
+
EmailVerificationRequired = "email-verification:required",
|
|
3201
3288
|
SignOut = "signout",
|
|
3202
3289
|
SessionRestored = "session:restored",
|
|
3203
3290
|
SessionExpired = "session:expired",
|
|
@@ -3227,7 +3314,7 @@ export declare enum PassflowEvent {
|
|
|
3227
3314
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
3228
3315
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
3229
3316
|
*/
|
|
3230
|
-
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'password-reset.send' | 'password-reset.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'auth-redirect.url' | 'auth-redirect' | 'auth.is-authenticated' | 'session.check' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'settings.app' | 'settings.all' | 'settings.password-policy' | 'settings.passkey' | 'passkey.list' | 'passkey.rename' | 'passkey.delete' | 'passkey.add' | 'tenant.create' | 'invitation.join' | 'invitation.request-link' | 'invitation.list' | 'invitation.delete' | 'invitation.resend' | 'invitation.get-link' | '2fa.status' | '2fa.setup.begin' | '2fa.setup.confirm' | '2fa.verify' | '2fa.recovery.use' | '2fa.disable' | '2fa.recovery.regenerate' | '2fa.methods.available' | '2fa.methods.registered' | '2fa.method.setup.start' | '2fa.method.setup.complete' | '2fa.method.remove' | '2fa.challenge.request' | '2fa.challenge.verify' | '2fa.method.switch' | '2fa.trusted-devices.list' | '2fa.trusted-devices.revoke';
|
|
3317
|
+
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'password-reset.send' | 'password-reset.complete' | 'email-verification.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'auth-redirect.url' | 'auth-redirect' | 'auth.is-authenticated' | 'session.check' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'settings.app' | 'settings.all' | 'settings.password-policy' | 'settings.passkey' | 'passkey.list' | 'passkey.rename' | 'passkey.delete' | 'passkey.add' | 'tenant.create' | 'invitation.join' | 'invitation.request-link' | 'invitation.list' | 'invitation.delete' | 'invitation.resend' | 'invitation.get-link' | '2fa.status' | '2fa.setup.begin' | '2fa.setup.confirm' | '2fa.verify' | '2fa.recovery.use' | '2fa.disable' | '2fa.recovery.regenerate' | '2fa.methods.available' | '2fa.methods.registered' | '2fa.method.setup.start' | '2fa.method.setup.complete' | '2fa.method.remove' | '2fa.challenge.request' | '2fa.challenge.verify' | '2fa.method.switch' | '2fa.trusted-devices.list' | '2fa.trusted-devices.revoke';
|
|
3231
3318
|
/**
|
|
3232
3319
|
* Error payload interface for structured error information
|
|
3233
3320
|
*/
|
|
@@ -3247,6 +3334,8 @@ interface ErrorPayload {
|
|
|
3247
3334
|
type OperationErrorPayload = ErrorPayload & {
|
|
3248
3335
|
operation: PassflowOperation;
|
|
3249
3336
|
};
|
|
3337
|
+
/** Which call produced an `EmailVerificationRequired` event. */
|
|
3338
|
+
type PassflowEmailVerificationOperation = 'sign-up' | 'sign-in' | 'reset-password';
|
|
3250
3339
|
/**
|
|
3251
3340
|
* Event-specific payload types
|
|
3252
3341
|
*/
|
|
@@ -3268,6 +3357,13 @@ type PassflowEventPayload = {
|
|
|
3268
3357
|
[PassflowEvent.RegisterStart]: {
|
|
3269
3358
|
email?: string;
|
|
3270
3359
|
};
|
|
3360
|
+
[PassflowEvent.EmailVerificationRequired]: {
|
|
3361
|
+
/** The address the code or link went to, when the SDK knows it. */
|
|
3362
|
+
email?: string;
|
|
3363
|
+
/** Present when a code was emailed; absent when a link was emailed instead. */
|
|
3364
|
+
challengeId?: string;
|
|
3365
|
+
operation: PassflowEmailVerificationOperation;
|
|
3366
|
+
};
|
|
3271
3367
|
[PassflowEvent.SignOut]: {
|
|
3272
3368
|
/** `sub` of the session that ended, when known. */
|
|
3273
3369
|
userId?: string;
|
|
@@ -3492,6 +3588,11 @@ export declare class AuthService {
|
|
|
3492
3588
|
private tokenDeliveryManager;
|
|
3493
3589
|
private tokenExchangeConfig?;
|
|
3494
3590
|
private pendingPkce?;
|
|
3591
|
+
/**
|
|
3592
|
+
* The emailed code challenges this instance produced, by `challenge_id`. Memory only: an id
|
|
3593
|
+
* this instance does not know (reload, another tab, a recreated instance) finishes as a sign-in.
|
|
3594
|
+
*/
|
|
3595
|
+
private emailChallenges;
|
|
3495
3596
|
/**
|
|
3496
3597
|
* The one place this instance sends `/auth/refresh` (PFL-792). Every refresh path asks it: the
|
|
3497
3598
|
* explicit `refreshToken()`, the upgrade commit, `getTokens(true)`/`session()` and, once
|
|
@@ -3544,6 +3645,17 @@ export declare class AuthService {
|
|
|
3544
3645
|
* the verifier stays here for `completePkceSignIn`, off the public event.
|
|
3545
3646
|
*/
|
|
3546
3647
|
private handlePendingSecondFactor;
|
|
3648
|
+
/**
|
|
3649
|
+
* Reports whether an answer is an email verification step, and when it is, prepares its completion.
|
|
3650
|
+
*
|
|
3651
|
+
* That answer is not a session: on `true` the caller returns it as it is, without
|
|
3652
|
+
* `processAuthResponse`, a `SignIn`/`Register` event, a session check or an error event. With a
|
|
3653
|
+
* code (`challenge_id`) on a PKCE app the verifier is kept for the code `/auth/validate` answers
|
|
3654
|
+
* with. A link step drops any verifier: that sign-in finishes on another page.
|
|
3655
|
+
*/
|
|
3656
|
+
private handleEmailVerificationStep;
|
|
3657
|
+
/** Adds a challenge at the newest end, dropping the oldest past `MAX_EMAIL_CHALLENGES`. */
|
|
3658
|
+
private rememberEmailChallenge;
|
|
3547
3659
|
/**
|
|
3548
3660
|
* Keeps the verifier in memory, which is where it is read from first. The copy
|
|
3549
3661
|
* in sessionStorage is only for a redirect or reload during the second factor,
|
|
@@ -3591,6 +3703,14 @@ export declare class AuthService {
|
|
|
3591
3703
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
3592
3704
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
3593
3705
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
3706
|
+
/**
|
|
3707
|
+
* Finishes a sign-up, sign-in or password change that answered with an emailed code
|
|
3708
|
+
* (`email_verification_required` with a `challenge_id`): posts the code to `/auth/validate`, then
|
|
3709
|
+
* continues like `signIn`. Emits `Register` for a sign-up's challenge and `SignIn` otherwise
|
|
3710
|
+
* (an unknown id included), `TwoFactorRequired` when a second factor is owed, and one `Error`
|
|
3711
|
+
* on failure. Emits no Start event: the code step's `EmailVerificationRequired` ended that one.
|
|
3712
|
+
*/
|
|
3713
|
+
verifyEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
3594
3714
|
/**
|
|
3595
3715
|
* Signs this tab out under the refresh lock (PFL-792 §2.8): stops this tab's refresh callers and
|
|
3596
3716
|
* retry timer, waits at most 5 s for the lock (a request already in flight lands first), posts
|
|
@@ -3680,7 +3800,7 @@ export declare class AuthService {
|
|
|
3680
3800
|
*/
|
|
3681
3801
|
refreshToken(upgrade?: UpgradeRefreshField, pin?: UpgradeSessionPin): Promise<PassflowAuthorizationResponse>;
|
|
3682
3802
|
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload): Promise<PassflowSuccessResponse>;
|
|
3683
|
-
resetPassword(newPassword: string, scopes?: string[]): Promise<PassflowAuthorizationResponse>;
|
|
3803
|
+
resetPassword(newPassword: string, scopes?: string[], token?: string): Promise<PassflowAuthorizationResponse>;
|
|
3684
3804
|
passkeyRegister(payload: PassflowPasskeyRegisterStartPayload): Promise<PassflowAuthorizationResponse>;
|
|
3685
3805
|
passkeyAuthenticate(payload: PassflowPasskeyAuthenticateStartPayload): Promise<PassflowAuthorizationResponse>;
|
|
3686
3806
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
@@ -5383,6 +5503,8 @@ export declare class Passflow {
|
|
|
5383
5503
|
* @param payload.password - User's password
|
|
5384
5504
|
* @param payload.scopes - Optional scopes to request (defaults to SDK scopes)
|
|
5385
5505
|
* @returns Promise with authorization response containing tokens
|
|
5506
|
+
* May answer an email verification step instead of tokens: check it with
|
|
5507
|
+
* `isEmailVerificationStep(response)`. With a `challenge_id`, finish with `verifyEmailCode`.
|
|
5386
5508
|
* @throws {PassflowError} If authentication fails
|
|
5387
5509
|
*
|
|
5388
5510
|
* @example
|
|
@@ -5408,6 +5530,8 @@ export declare class Passflow {
|
|
|
5408
5530
|
* @param payload.username - Optional username
|
|
5409
5531
|
* @param payload.scopes - Optional scopes to request
|
|
5410
5532
|
* @returns Promise with authorization response containing tokens
|
|
5533
|
+
* May answer an email verification step instead of tokens: check it with
|
|
5534
|
+
* `isEmailVerificationStep(response)`. With a `challenge_id`, finish with `verifyEmailCode`.
|
|
5411
5535
|
* @throws {PassflowError} If registration fails
|
|
5412
5536
|
*
|
|
5413
5537
|
* @example
|
|
@@ -5469,6 +5593,29 @@ export declare class Passflow {
|
|
|
5469
5593
|
* ```
|
|
5470
5594
|
*/
|
|
5471
5595
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
5596
|
+
/**
|
|
5597
|
+
* Finishes a sign-up, sign-in or password change that answered with `email_verification_required`
|
|
5598
|
+
* and a `challenge_id`, using the code the user received by email. Answers like `signIn`: a new
|
|
5599
|
+
* token pair, or a `tfa_token` when a second factor is owed (`isTwoFactorVerificationRequired()`
|
|
5600
|
+
* is then true).
|
|
5601
|
+
*
|
|
5602
|
+
* Emits `Register` for a challenge this instance got from `signUp`, and `SignIn` otherwise. The
|
|
5603
|
+
* challenges are remembered in memory only, so a code typed in another tab or after the
|
|
5604
|
+
* `Passflow` instance was recreated emits `SignIn`, even for a sign-up.
|
|
5605
|
+
*
|
|
5606
|
+
* @param payload.challenge_id - The `challenge_id` from the email verification step
|
|
5607
|
+
* @param payload.otp - The code from the email
|
|
5608
|
+
* @throws {PassflowError} wrong, expired or spent code (`error.otp.*`), unknown challenge (`error.not.found`)
|
|
5609
|
+
*
|
|
5610
|
+
* @example
|
|
5611
|
+
* ```typescript
|
|
5612
|
+
* const step = await passflow.signUp({ user: { email, password } });
|
|
5613
|
+
* if (isEmailVerificationStep(step) && step.challenge_id) {
|
|
5614
|
+
* const response = await passflow.verifyEmailCode({ challenge_id: step.challenge_id, otp: '123456' });
|
|
5615
|
+
* }
|
|
5616
|
+
* ```
|
|
5617
|
+
*/
|
|
5618
|
+
verifyEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
5472
5619
|
/**
|
|
5473
5620
|
* Centralized error handler for all public methods.
|
|
5474
5621
|
* Creates proper ErrorPayload, distinguishes PassflowError from generic Error,
|
|
@@ -5627,7 +5774,12 @@ export declare class Passflow {
|
|
|
5627
5774
|
*
|
|
5628
5775
|
* @param newPassword - The new password to set
|
|
5629
5776
|
* @param scopes - Optional scopes to request after reset
|
|
5777
|
+
* @param resetToken - The reset link's token. Without it the token is read from `?token=` in
|
|
5778
|
+
* `location.search`, then from a hash route's query (`#/reset?token=…`). Pass it when your
|
|
5779
|
+
* router keeps the link's query somewhere else (memory router).
|
|
5630
5780
|
* @returns Promise with authorization response containing new tokens
|
|
5781
|
+
* May answer an email verification step instead of tokens: check it with
|
|
5782
|
+
* `isEmailVerificationStep(response)`. With a `challenge_id`, finish with `verifyEmailCode`.
|
|
5631
5783
|
* @throws {PassflowError} If reset fails
|
|
5632
5784
|
*
|
|
5633
5785
|
* @example
|
|
@@ -5641,7 +5793,7 @@ export declare class Passflow {
|
|
|
5641
5793
|
* }
|
|
5642
5794
|
* ```
|
|
5643
5795
|
*/
|
|
5644
|
-
resetPassword(newPassword: string, scopes?: string[]): Promise<PassflowAuthorizationResponse>;
|
|
5796
|
+
resetPassword(newPassword: string, scopes?: string[], resetToken?: string): Promise<PassflowAuthorizationResponse>;
|
|
5645
5797
|
/**
|
|
5646
5798
|
* Get application settings and configuration.
|
|
5647
5799
|
*
|
|
@@ -6368,4 +6520,4 @@ export declare function isValidPhoneNumber(phone: string): boolean;
|
|
|
6368
6520
|
* @returns true if valid username format, false otherwise
|
|
6369
6521
|
*/
|
|
6370
6522
|
export declare function isValidUsername(username: string): boolean;
|
|
6371
|
-
export type { AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OpenAuthUrlOptions, OperationErrorPayload, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport };
|
|
6523
|
+
export type { AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OpenAuthUrlOptions, OperationErrorPayload, PassflowEmailVerificationOperation, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport };
|
package/dist/index.d.ts
CHANGED
|
@@ -1213,7 +1213,33 @@ export type PassflowAuthorizationResponse = Tokens & {
|
|
|
1213
1213
|
token_delivery?: 'json_body' | 'cookie' | 'mobile';
|
|
1214
1214
|
cookies?: string[];
|
|
1215
1215
|
csrf_token?: string;
|
|
1216
|
+
/** `true` when the server needs the email proven before this sign-in finishes. No tokens come with it. */
|
|
1217
|
+
email_verification_required?: boolean;
|
|
1218
|
+
/** Human-readable text from the server, e.g. "We sent a code to a***@example.com." */
|
|
1219
|
+
message?: string;
|
|
1220
|
+
};
|
|
1221
|
+
/**
|
|
1222
|
+
* A sign-up, sign-in or password change that waits for the email to be proven.
|
|
1223
|
+
* With `challenge_id`: a code was emailed, finish with `Passflow.verifyEmailCode`.
|
|
1224
|
+
* Without: the code budget is spent and a link was emailed instead.
|
|
1225
|
+
* `message` is what the server sent; a malformed answer may leave it out.
|
|
1226
|
+
*/
|
|
1227
|
+
export type PassflowEmailVerificationStep = {
|
|
1228
|
+
email_verification_required: true;
|
|
1229
|
+
message: string;
|
|
1230
|
+
challenge_id?: string;
|
|
1216
1231
|
};
|
|
1232
|
+
/** The emailed code for a `PassflowEmailVerificationStep` that carried a `challenge_id`. */
|
|
1233
|
+
export type PassflowEmailCodePayload = {
|
|
1234
|
+
challenge_id: string;
|
|
1235
|
+
otp: string;
|
|
1236
|
+
};
|
|
1237
|
+
/**
|
|
1238
|
+
* Whether an auth answer is an email verification step rather than a session. Only the
|
|
1239
|
+
* `email_verification_required` flag is checked, so an answer with the flag is never taken
|
|
1240
|
+
* for a session.
|
|
1241
|
+
*/
|
|
1242
|
+
export declare const isEmailVerificationStep: (response: unknown) => response is PassflowEmailVerificationStep;
|
|
1217
1243
|
export type PassflowValidationResponse = Tokens & {
|
|
1218
1244
|
redirect_url: string;
|
|
1219
1245
|
requires_2fa?: boolean;
|
|
@@ -1393,12 +1419,64 @@ export type AppSettings = {
|
|
|
1393
1419
|
create_tenant_on_registration: 'never' | 'always' | 'optional';
|
|
1394
1420
|
fim_merge_by_email_allowed: boolean;
|
|
1395
1421
|
debug_otp_code_allowed: boolean;
|
|
1396
|
-
|
|
1422
|
+
/**
|
|
1423
|
+
* WRITE-ONLY. Every read and write answer returns it as an empty string; the stored code is
|
|
1424
|
+
* never echoed. On write, a blank or absent value keeps the stored code and a non-blank value
|
|
1425
|
+
* replaces it. The only way to clear it is
|
|
1426
|
+
* `DELETE /admin/apps/{id}/secrets/debug_otp_code_for_registration` (see `AppSecretName`).
|
|
1427
|
+
* Use `debug_otp_code_set` to tell whether a code is stored.
|
|
1428
|
+
*/
|
|
1429
|
+
debug_otp_code_for_registration?: string;
|
|
1430
|
+
/** READ-ONLY. `true` when a `debug_otp_code_for_registration` is stored. Ignored on write. */
|
|
1431
|
+
debug_otp_code_set?: boolean;
|
|
1397
1432
|
defaults: DefaultAppSettings;
|
|
1398
1433
|
login_app_theme: LoginWebAppTheme;
|
|
1399
1434
|
login_app_settings?: unknown;
|
|
1400
1435
|
token_delivery_method?: TokenDeliveryMethod;
|
|
1401
1436
|
};
|
|
1437
|
+
/**
|
|
1438
|
+
* A write-only app secret that the admin API clears by name with
|
|
1439
|
+
* `DELETE /admin/apps/{id}/secrets/{name}`. The SDK has no admin client, so this route is not
|
|
1440
|
+
* wrapped; the names are exported for admin UIs that call it themselves.
|
|
1441
|
+
*
|
|
1442
|
+
* - `debug_otp_code_for_registration`: an `AppSettings` field. Answers return it as an empty
|
|
1443
|
+
* string; `AppSettings.debug_otp_code_set` tells whether one is stored.
|
|
1444
|
+
* - `fcm_server_key`, `webpush_vapid_private_key`: push settings in the app's
|
|
1445
|
+
* `two_factor_settings`. Both are absent from every answer; `webpush_vapid_public_key` is
|
|
1446
|
+
* still returned.
|
|
1447
|
+
*
|
|
1448
|
+
* On write, a blank or absent value keeps the stored secret and a non-blank value replaces it.
|
|
1449
|
+
* DELETE is the only way to clear one. See docs/admin-secrets.md.
|
|
1450
|
+
*/
|
|
1451
|
+
export type AppSecretName = 'debug_otp_code_for_registration' | 'fcm_server_key' | 'webpush_vapid_private_key';
|
|
1452
|
+
/** Every `AppSecretName`, in the order the type lists them. */
|
|
1453
|
+
export declare const APP_SECRET_NAMES: readonly AppSecretName[];
|
|
1454
|
+
/**
|
|
1455
|
+
* A secret in the server settings (`GET`/`PUT /admin/settings`) as the admin API returns it.
|
|
1456
|
+
*
|
|
1457
|
+
* - Secrets come back as `mask://********`.
|
|
1458
|
+
* - Connection strings, dynamo/s3/ssm endpoints, plugin address/cmd, activity-logger endpoints
|
|
1459
|
+
* and management_keys come back as `mask://********` followed by `/` and 16 lowercase
|
|
1460
|
+
* hex characters (e.g. a `/0123456789abcdef` suffix); the suffix tells values apart without
|
|
1461
|
+
* revealing them. (Written in two parts because the full form would end this comment.)
|
|
1462
|
+
*
|
|
1463
|
+
* On `PUT`: echo the masked value unchanged to keep the stored one, send a plain value to
|
|
1464
|
+
* replace it, send an empty string to clear it. A stale or edited masked value fails with
|
|
1465
|
+
* HTTP 400 and id `SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID`. See docs/admin-secrets.md.
|
|
1466
|
+
*/
|
|
1467
|
+
export type MaskedSecret = string;
|
|
1468
|
+
/** The prefix every `MaskedSecret` starts with. */
|
|
1469
|
+
export declare const MASKED_SECRET_PREFIX = "mask://";
|
|
1470
|
+
/**
|
|
1471
|
+
* Error id of the HTTP 400 that `PUT /admin/settings` returns for a masked value the server did
|
|
1472
|
+
* not issue for the stored one (stale or edited).
|
|
1473
|
+
*/
|
|
1474
|
+
export declare const SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID = "error.server.update.settings.masked.value.unknown";
|
|
1475
|
+
/**
|
|
1476
|
+
* Whether a server settings value is a masked secret rather than a plain value: any string that
|
|
1477
|
+
* starts with `MASKED_SECRET_PREFIX`. It does not check that the server would accept it.
|
|
1478
|
+
*/
|
|
1479
|
+
export declare const isMaskedSecret: (value: unknown) => value is MaskedSecret;
|
|
1402
1480
|
export type DefaultAppSettings = {
|
|
1403
1481
|
app_id: string;
|
|
1404
1482
|
redirect: string;
|
|
@@ -1990,6 +2068,13 @@ export declare class AuthAPI {
|
|
|
1990
2068
|
pkceExchange(code: string, verifier: string): Promise<PassflowAuthorizationResponse>;
|
|
1991
2069
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload, deviceId: string, os: OS): Promise<PassflowPasswordlessResponse>;
|
|
1992
2070
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Proves an emailed code for a sign-up, sign-in or password change that answered with
|
|
2073
|
+
* `email_verification_required`. Only `{challenge_id, otp}` is sent: the server reads the
|
|
2074
|
+
* device from the `X-Passflow-DeviceId` header. Sent with credentials, as every call that
|
|
2075
|
+
* ends a sign-in is.
|
|
2076
|
+
*/
|
|
2077
|
+
validateEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
1993
2078
|
logOut(deviceId?: string, refreshToken?: string, isAdmin?: boolean): Promise<PassflowLogoutResponse>;
|
|
1994
2079
|
validateSession(): Promise<PassflowSessionValidationResponse>;
|
|
1995
2080
|
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload): Promise<PassflowSuccessResponse>;
|
|
@@ -3198,6 +3283,8 @@ export declare enum PassflowEvent {
|
|
|
3198
3283
|
SignInStart = "signin:start",
|
|
3199
3284
|
Register = "register",
|
|
3200
3285
|
RegisterStart = "register:start",
|
|
3286
|
+
/** A sign-up, sign-in or password change is waiting for the email to be proven (no session yet). */
|
|
3287
|
+
EmailVerificationRequired = "email-verification:required",
|
|
3201
3288
|
SignOut = "signout",
|
|
3202
3289
|
SessionRestored = "session:restored",
|
|
3203
3290
|
SessionExpired = "session:expired",
|
|
@@ -3227,7 +3314,7 @@ export declare enum PassflowEvent {
|
|
|
3227
3314
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
3228
3315
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
3229
3316
|
*/
|
|
3230
|
-
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'password-reset.send' | 'password-reset.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'auth-redirect.url' | 'auth-redirect' | 'auth.is-authenticated' | 'session.check' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'settings.app' | 'settings.all' | 'settings.password-policy' | 'settings.passkey' | 'passkey.list' | 'passkey.rename' | 'passkey.delete' | 'passkey.add' | 'tenant.create' | 'invitation.join' | 'invitation.request-link' | 'invitation.list' | 'invitation.delete' | 'invitation.resend' | 'invitation.get-link' | '2fa.status' | '2fa.setup.begin' | '2fa.setup.confirm' | '2fa.verify' | '2fa.recovery.use' | '2fa.disable' | '2fa.recovery.regenerate' | '2fa.methods.available' | '2fa.methods.registered' | '2fa.method.setup.start' | '2fa.method.setup.complete' | '2fa.method.remove' | '2fa.challenge.request' | '2fa.challenge.verify' | '2fa.method.switch' | '2fa.trusted-devices.list' | '2fa.trusted-devices.revoke';
|
|
3317
|
+
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'password-reset.send' | 'password-reset.complete' | 'email-verification.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'auth-redirect.url' | 'auth-redirect' | 'auth.is-authenticated' | 'session.check' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'settings.app' | 'settings.all' | 'settings.password-policy' | 'settings.passkey' | 'passkey.list' | 'passkey.rename' | 'passkey.delete' | 'passkey.add' | 'tenant.create' | 'invitation.join' | 'invitation.request-link' | 'invitation.list' | 'invitation.delete' | 'invitation.resend' | 'invitation.get-link' | '2fa.status' | '2fa.setup.begin' | '2fa.setup.confirm' | '2fa.verify' | '2fa.recovery.use' | '2fa.disable' | '2fa.recovery.regenerate' | '2fa.methods.available' | '2fa.methods.registered' | '2fa.method.setup.start' | '2fa.method.setup.complete' | '2fa.method.remove' | '2fa.challenge.request' | '2fa.challenge.verify' | '2fa.method.switch' | '2fa.trusted-devices.list' | '2fa.trusted-devices.revoke';
|
|
3231
3318
|
/**
|
|
3232
3319
|
* Error payload interface for structured error information
|
|
3233
3320
|
*/
|
|
@@ -3247,6 +3334,8 @@ interface ErrorPayload {
|
|
|
3247
3334
|
type OperationErrorPayload = ErrorPayload & {
|
|
3248
3335
|
operation: PassflowOperation;
|
|
3249
3336
|
};
|
|
3337
|
+
/** Which call produced an `EmailVerificationRequired` event. */
|
|
3338
|
+
type PassflowEmailVerificationOperation = 'sign-up' | 'sign-in' | 'reset-password';
|
|
3250
3339
|
/**
|
|
3251
3340
|
* Event-specific payload types
|
|
3252
3341
|
*/
|
|
@@ -3268,6 +3357,13 @@ type PassflowEventPayload = {
|
|
|
3268
3357
|
[PassflowEvent.RegisterStart]: {
|
|
3269
3358
|
email?: string;
|
|
3270
3359
|
};
|
|
3360
|
+
[PassflowEvent.EmailVerificationRequired]: {
|
|
3361
|
+
/** The address the code or link went to, when the SDK knows it. */
|
|
3362
|
+
email?: string;
|
|
3363
|
+
/** Present when a code was emailed; absent when a link was emailed instead. */
|
|
3364
|
+
challengeId?: string;
|
|
3365
|
+
operation: PassflowEmailVerificationOperation;
|
|
3366
|
+
};
|
|
3271
3367
|
[PassflowEvent.SignOut]: {
|
|
3272
3368
|
/** `sub` of the session that ended, when known. */
|
|
3273
3369
|
userId?: string;
|
|
@@ -3492,6 +3588,11 @@ export declare class AuthService {
|
|
|
3492
3588
|
private tokenDeliveryManager;
|
|
3493
3589
|
private tokenExchangeConfig?;
|
|
3494
3590
|
private pendingPkce?;
|
|
3591
|
+
/**
|
|
3592
|
+
* The emailed code challenges this instance produced, by `challenge_id`. Memory only: an id
|
|
3593
|
+
* this instance does not know (reload, another tab, a recreated instance) finishes as a sign-in.
|
|
3594
|
+
*/
|
|
3595
|
+
private emailChallenges;
|
|
3495
3596
|
/**
|
|
3496
3597
|
* The one place this instance sends `/auth/refresh` (PFL-792). Every refresh path asks it: the
|
|
3497
3598
|
* explicit `refreshToken()`, the upgrade commit, `getTokens(true)`/`session()` and, once
|
|
@@ -3544,6 +3645,17 @@ export declare class AuthService {
|
|
|
3544
3645
|
* the verifier stays here for `completePkceSignIn`, off the public event.
|
|
3545
3646
|
*/
|
|
3546
3647
|
private handlePendingSecondFactor;
|
|
3648
|
+
/**
|
|
3649
|
+
* Reports whether an answer is an email verification step, and when it is, prepares its completion.
|
|
3650
|
+
*
|
|
3651
|
+
* That answer is not a session: on `true` the caller returns it as it is, without
|
|
3652
|
+
* `processAuthResponse`, a `SignIn`/`Register` event, a session check or an error event. With a
|
|
3653
|
+
* code (`challenge_id`) on a PKCE app the verifier is kept for the code `/auth/validate` answers
|
|
3654
|
+
* with. A link step drops any verifier: that sign-in finishes on another page.
|
|
3655
|
+
*/
|
|
3656
|
+
private handleEmailVerificationStep;
|
|
3657
|
+
/** Adds a challenge at the newest end, dropping the oldest past `MAX_EMAIL_CHALLENGES`. */
|
|
3658
|
+
private rememberEmailChallenge;
|
|
3547
3659
|
/**
|
|
3548
3660
|
* Keeps the verifier in memory, which is where it is read from first. The copy
|
|
3549
3661
|
* in sessionStorage is only for a redirect or reload during the second factor,
|
|
@@ -3591,6 +3703,14 @@ export declare class AuthService {
|
|
|
3591
3703
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
3592
3704
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
3593
3705
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
3706
|
+
/**
|
|
3707
|
+
* Finishes a sign-up, sign-in or password change that answered with an emailed code
|
|
3708
|
+
* (`email_verification_required` with a `challenge_id`): posts the code to `/auth/validate`, then
|
|
3709
|
+
* continues like `signIn`. Emits `Register` for a sign-up's challenge and `SignIn` otherwise
|
|
3710
|
+
* (an unknown id included), `TwoFactorRequired` when a second factor is owed, and one `Error`
|
|
3711
|
+
* on failure. Emits no Start event: the code step's `EmailVerificationRequired` ended that one.
|
|
3712
|
+
*/
|
|
3713
|
+
verifyEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
3594
3714
|
/**
|
|
3595
3715
|
* Signs this tab out under the refresh lock (PFL-792 §2.8): stops this tab's refresh callers and
|
|
3596
3716
|
* retry timer, waits at most 5 s for the lock (a request already in flight lands first), posts
|
|
@@ -3680,7 +3800,7 @@ export declare class AuthService {
|
|
|
3680
3800
|
*/
|
|
3681
3801
|
refreshToken(upgrade?: UpgradeRefreshField, pin?: UpgradeSessionPin): Promise<PassflowAuthorizationResponse>;
|
|
3682
3802
|
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload): Promise<PassflowSuccessResponse>;
|
|
3683
|
-
resetPassword(newPassword: string, scopes?: string[]): Promise<PassflowAuthorizationResponse>;
|
|
3803
|
+
resetPassword(newPassword: string, scopes?: string[], token?: string): Promise<PassflowAuthorizationResponse>;
|
|
3684
3804
|
passkeyRegister(payload: PassflowPasskeyRegisterStartPayload): Promise<PassflowAuthorizationResponse>;
|
|
3685
3805
|
passkeyAuthenticate(payload: PassflowPasskeyAuthenticateStartPayload): Promise<PassflowAuthorizationResponse>;
|
|
3686
3806
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
@@ -5383,6 +5503,8 @@ export declare class Passflow {
|
|
|
5383
5503
|
* @param payload.password - User's password
|
|
5384
5504
|
* @param payload.scopes - Optional scopes to request (defaults to SDK scopes)
|
|
5385
5505
|
* @returns Promise with authorization response containing tokens
|
|
5506
|
+
* May answer an email verification step instead of tokens: check it with
|
|
5507
|
+
* `isEmailVerificationStep(response)`. With a `challenge_id`, finish with `verifyEmailCode`.
|
|
5386
5508
|
* @throws {PassflowError} If authentication fails
|
|
5387
5509
|
*
|
|
5388
5510
|
* @example
|
|
@@ -5408,6 +5530,8 @@ export declare class Passflow {
|
|
|
5408
5530
|
* @param payload.username - Optional username
|
|
5409
5531
|
* @param payload.scopes - Optional scopes to request
|
|
5410
5532
|
* @returns Promise with authorization response containing tokens
|
|
5533
|
+
* May answer an email verification step instead of tokens: check it with
|
|
5534
|
+
* `isEmailVerificationStep(response)`. With a `challenge_id`, finish with `verifyEmailCode`.
|
|
5411
5535
|
* @throws {PassflowError} If registration fails
|
|
5412
5536
|
*
|
|
5413
5537
|
* @example
|
|
@@ -5469,6 +5593,29 @@ export declare class Passflow {
|
|
|
5469
5593
|
* ```
|
|
5470
5594
|
*/
|
|
5471
5595
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
5596
|
+
/**
|
|
5597
|
+
* Finishes a sign-up, sign-in or password change that answered with `email_verification_required`
|
|
5598
|
+
* and a `challenge_id`, using the code the user received by email. Answers like `signIn`: a new
|
|
5599
|
+
* token pair, or a `tfa_token` when a second factor is owed (`isTwoFactorVerificationRequired()`
|
|
5600
|
+
* is then true).
|
|
5601
|
+
*
|
|
5602
|
+
* Emits `Register` for a challenge this instance got from `signUp`, and `SignIn` otherwise. The
|
|
5603
|
+
* challenges are remembered in memory only, so a code typed in another tab or after the
|
|
5604
|
+
* `Passflow` instance was recreated emits `SignIn`, even for a sign-up.
|
|
5605
|
+
*
|
|
5606
|
+
* @param payload.challenge_id - The `challenge_id` from the email verification step
|
|
5607
|
+
* @param payload.otp - The code from the email
|
|
5608
|
+
* @throws {PassflowError} wrong, expired or spent code (`error.otp.*`), unknown challenge (`error.not.found`)
|
|
5609
|
+
*
|
|
5610
|
+
* @example
|
|
5611
|
+
* ```typescript
|
|
5612
|
+
* const step = await passflow.signUp({ user: { email, password } });
|
|
5613
|
+
* if (isEmailVerificationStep(step) && step.challenge_id) {
|
|
5614
|
+
* const response = await passflow.verifyEmailCode({ challenge_id: step.challenge_id, otp: '123456' });
|
|
5615
|
+
* }
|
|
5616
|
+
* ```
|
|
5617
|
+
*/
|
|
5618
|
+
verifyEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
5472
5619
|
/**
|
|
5473
5620
|
* Centralized error handler for all public methods.
|
|
5474
5621
|
* Creates proper ErrorPayload, distinguishes PassflowError from generic Error,
|
|
@@ -5627,7 +5774,12 @@ export declare class Passflow {
|
|
|
5627
5774
|
*
|
|
5628
5775
|
* @param newPassword - The new password to set
|
|
5629
5776
|
* @param scopes - Optional scopes to request after reset
|
|
5777
|
+
* @param resetToken - The reset link's token. Without it the token is read from `?token=` in
|
|
5778
|
+
* `location.search`, then from a hash route's query (`#/reset?token=…`). Pass it when your
|
|
5779
|
+
* router keeps the link's query somewhere else (memory router).
|
|
5630
5780
|
* @returns Promise with authorization response containing new tokens
|
|
5781
|
+
* May answer an email verification step instead of tokens: check it with
|
|
5782
|
+
* `isEmailVerificationStep(response)`. With a `challenge_id`, finish with `verifyEmailCode`.
|
|
5631
5783
|
* @throws {PassflowError} If reset fails
|
|
5632
5784
|
*
|
|
5633
5785
|
* @example
|
|
@@ -5641,7 +5793,7 @@ export declare class Passflow {
|
|
|
5641
5793
|
* }
|
|
5642
5794
|
* ```
|
|
5643
5795
|
*/
|
|
5644
|
-
resetPassword(newPassword: string, scopes?: string[]): Promise<PassflowAuthorizationResponse>;
|
|
5796
|
+
resetPassword(newPassword: string, scopes?: string[], resetToken?: string): Promise<PassflowAuthorizationResponse>;
|
|
5645
5797
|
/**
|
|
5646
5798
|
* Get application settings and configuration.
|
|
5647
5799
|
*
|
|
@@ -6368,4 +6520,4 @@ export declare function isValidPhoneNumber(phone: string): boolean;
|
|
|
6368
6520
|
* @returns true if valid username format, false otherwise
|
|
6369
6521
|
*/
|
|
6370
6522
|
export declare function isValidUsername(username: string): boolean;
|
|
6371
|
-
export type { AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OpenAuthUrlOptions, OperationErrorPayload, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport };
|
|
6523
|
+
export type { AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OpenAuthUrlOptions, OperationErrorPayload, PassflowEmailVerificationOperation, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport };
|