@passflow/core 0.23.0 → 0.24.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 +50 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -2
- package/dist/index.d.ts +210 -2
- package/dist/index.mjs +831 -546
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1007,6 +1007,9 @@ export declare enum PassflowEndpointPaths {
|
|
|
1007
1007
|
signInWithProvider = "/auth/federated/start/",
|
|
1008
1008
|
passwordless = "/auth/passwordless/start",
|
|
1009
1009
|
passwordlessComplete = "/auth/passwordless/complete",
|
|
1010
|
+
passwordlessStatus = "/auth/passwordless/status",
|
|
1011
|
+
passwordlessApprovalInfo = "/auth/passwordless/approval/info",
|
|
1012
|
+
passwordlessApprovalDecide = "/auth/passwordless/approval/decide",
|
|
1010
1013
|
logout = "/user/logout",
|
|
1011
1014
|
refresh = "/auth/refresh",
|
|
1012
1015
|
validateSession = "/user/me",
|
|
@@ -1102,6 +1105,12 @@ export type PassflowConfig = {
|
|
|
1102
1105
|
scopes?: string[];
|
|
1103
1106
|
createTenantForNewUser?: boolean;
|
|
1104
1107
|
parseQueryParams?: boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
* Leaves a federated `?code=` landing alone in the constructor and in `handleTokensRedirect`,
|
|
1110
|
+
* so that only `completeFederatedLanding()` takes it. For hosts that build the instance during
|
|
1111
|
+
* render and may discard it. Token and `#tfa_token` landings are not affected.
|
|
1112
|
+
*/
|
|
1113
|
+
deferFederatedLanding?: boolean;
|
|
1105
1114
|
keyStoragePrefix?: string;
|
|
1106
1115
|
/**
|
|
1107
1116
|
* Token exchange configuration for secure server-side token handling.
|
|
@@ -1245,6 +1254,8 @@ export type PassflowValidationResponse = Tokens & {
|
|
|
1245
1254
|
requires_2fa?: boolean;
|
|
1246
1255
|
challenge_id?: string;
|
|
1247
1256
|
tfa_token?: string;
|
|
1257
|
+
/** PKCE app: the code to redeem with the verifier, in place of tokens. */
|
|
1258
|
+
code?: string;
|
|
1248
1259
|
};
|
|
1249
1260
|
export type PassflowSuccessResponse = {
|
|
1250
1261
|
result: 'ok';
|
|
@@ -1346,6 +1357,7 @@ export type PassflowPasswordlessSignInPayload = {
|
|
|
1346
1357
|
scopes?: string[];
|
|
1347
1358
|
create_tenant?: boolean;
|
|
1348
1359
|
invite_token?: string;
|
|
1360
|
+
code_challenge?: string;
|
|
1349
1361
|
} & ({
|
|
1350
1362
|
email: string;
|
|
1351
1363
|
phone?: never;
|
|
@@ -1356,6 +1368,8 @@ export type PassflowPasswordlessSignInPayload = {
|
|
|
1356
1368
|
export type PassflowPasswordlessResponse = {
|
|
1357
1369
|
challenge_id: string;
|
|
1358
1370
|
expires_at: Date | string;
|
|
1371
|
+
/** The code the user types on the approving device. Only on a row that can be approved from another device. */
|
|
1372
|
+
match_code?: string;
|
|
1359
1373
|
};
|
|
1360
1374
|
export type PassflowPasswordlessSignInExtendedPayload = PassflowPasswordlessSignInPayload & {
|
|
1361
1375
|
device: string;
|
|
@@ -1368,6 +1382,47 @@ export type PassflowPasswordlessSignInCompletePayload = {
|
|
|
1368
1382
|
scopes?: string[];
|
|
1369
1383
|
challenge_type?: InternalStrategyChallenge;
|
|
1370
1384
|
};
|
|
1385
|
+
export type PassflowPasswordlessStatusPayload = {
|
|
1386
|
+
challenge_id: string;
|
|
1387
|
+
code_challenge: string;
|
|
1388
|
+
};
|
|
1389
|
+
export type PassflowPasswordlessStatusResponse = {
|
|
1390
|
+
status: 'pending' | 'denied' | 'expired' | 'completed';
|
|
1391
|
+
} | {
|
|
1392
|
+
status: 'approved';
|
|
1393
|
+
code: string;
|
|
1394
|
+
};
|
|
1395
|
+
export type PassflowPasswordlessApprovalInfoPayload = {
|
|
1396
|
+
challenge_id: string;
|
|
1397
|
+
};
|
|
1398
|
+
export type PassflowPasswordlessApprovalDecidePayload = {
|
|
1399
|
+
challenge_id: string;
|
|
1400
|
+
otp: string;
|
|
1401
|
+
approve: boolean;
|
|
1402
|
+
match_code?: string;
|
|
1403
|
+
};
|
|
1404
|
+
export type PassflowPasswordlessApprovalDecideResponse = {
|
|
1405
|
+
state: 'approved' | 'denied';
|
|
1406
|
+
};
|
|
1407
|
+
export type PasswordlessWaitResult = {
|
|
1408
|
+
status: 'signed-in';
|
|
1409
|
+
tokens: PassflowAuthorizationResponse;
|
|
1410
|
+
} | {
|
|
1411
|
+
status: 'second-factor-required' | 'denied' | 'expired' | 'completed';
|
|
1412
|
+
};
|
|
1413
|
+
export type PasswordlessApprovalInfo = {
|
|
1414
|
+
state: 'pending' | 'approved' | 'denied' | 'expired' | 'completed';
|
|
1415
|
+
app_name: string;
|
|
1416
|
+
requested_at: string;
|
|
1417
|
+
expires_at: string;
|
|
1418
|
+
browser: string;
|
|
1419
|
+
os: string;
|
|
1420
|
+
location: {
|
|
1421
|
+
city: string;
|
|
1422
|
+
country: string;
|
|
1423
|
+
} | null;
|
|
1424
|
+
attempts_left: number;
|
|
1425
|
+
};
|
|
1371
1426
|
export declare enum Providers {
|
|
1372
1427
|
google = "google",
|
|
1373
1428
|
facebook = "facebook"
|
|
@@ -1540,6 +1595,8 @@ export type PassflowFederatedAuthPayload = {
|
|
|
1540
1595
|
scopes?: string[];
|
|
1541
1596
|
invite_token?: string;
|
|
1542
1597
|
create_tenant?: boolean;
|
|
1598
|
+
code_challenge?: string;
|
|
1599
|
+
code_challenge_method?: 'S256';
|
|
1543
1600
|
};
|
|
1544
1601
|
export type PassflowFederatedAuthExtendedPayload = PassflowFederatedAuthPayload & {
|
|
1545
1602
|
device?: string;
|
|
@@ -2064,10 +2121,32 @@ export declare class AuthAPI {
|
|
|
2064
2121
|
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField): Promise<PassflowAuthorizationResponse>;
|
|
2065
2122
|
signIn(payload: PassflowSignInPayload, deviceId: string, os: OS): Promise<PassflowAuthorizationResponse>;
|
|
2066
2123
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
2067
|
-
/**
|
|
2124
|
+
/**
|
|
2125
|
+
* Redeems the code a PKCE sign-in answered with for the tokens it stands for.
|
|
2126
|
+
*
|
|
2127
|
+
* Every exchange goes through here, so this is the one place that keeps the code and the
|
|
2128
|
+
* verifier out of its errors: it rejects only with a `PassflowError`.
|
|
2129
|
+
*/
|
|
2068
2130
|
pkceExchange(code: string, verifier: string): Promise<PassflowAuthorizationResponse>;
|
|
2131
|
+
/** Rejects only with a `PassflowError`, because its body can hold the poll secret. */
|
|
2069
2132
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload, deviceId: string, os: OS): Promise<PassflowPasswordlessResponse>;
|
|
2133
|
+
/** Rejects only with a `PassflowError`, because its body holds the OTP. */
|
|
2070
2134
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
2135
|
+
/**
|
|
2136
|
+
* Polls a magic-link sign-in waiting for approval from another device. Sent with credentials:
|
|
2137
|
+
* the trusted-device cookie is read when an approved row answers with its code. It rejects only
|
|
2138
|
+
* with a `PassflowError`, because its body holds the poll secret.
|
|
2139
|
+
*/
|
|
2140
|
+
passwordlessStatus(payload: PassflowPasswordlessStatusPayload, options?: {
|
|
2141
|
+
signal?: AbortSignal;
|
|
2142
|
+
}): Promise<PassflowPasswordlessStatusResponse>;
|
|
2143
|
+
/** Reads what the approving device shows. It changes nothing on the server. */
|
|
2144
|
+
passwordlessApprovalInfo(payload: PassflowPasswordlessApprovalInfoPayload): Promise<PasswordlessApprovalInfo>;
|
|
2145
|
+
/**
|
|
2146
|
+
* Approves or denies a waiting sign-in from the device that opened the link. It rejects only with
|
|
2147
|
+
* a `PassflowError`, because its body holds the OTP and the match code.
|
|
2148
|
+
*/
|
|
2149
|
+
passwordlessApprovalDecide(payload: PassflowPasswordlessApprovalDecidePayload): Promise<PassflowPasswordlessApprovalDecideResponse>;
|
|
2071
2150
|
/**
|
|
2072
2151
|
* Proves an emailed code for a sign-up, sign-in or password change that answered with
|
|
2073
2152
|
* `email_verification_required`. Only `{challenge_id, otp}` is sent: the server reads the
|
|
@@ -3314,7 +3393,7 @@ export declare enum PassflowEvent {
|
|
|
3314
3393
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
3315
3394
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
3316
3395
|
*/
|
|
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';
|
|
3396
|
+
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'passwordless.wait' | 'passwordless.approval' | 'password-reset.send' | 'password-reset.complete' | 'email-verification.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'federated.redirect' | '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';
|
|
3318
3397
|
/**
|
|
3319
3398
|
* Error payload interface for structured error information
|
|
3320
3399
|
*/
|
|
@@ -3345,6 +3424,8 @@ type PassflowEventPayload = {
|
|
|
3345
3424
|
parsedTokens?: ParsedTokens;
|
|
3346
3425
|
/** `'other-tab'` only when an ended tab revives on a new session found in storage. Absent on this tab's own sign-in. */
|
|
3347
3426
|
origin?: EventOrigin;
|
|
3427
|
+
/** Set only when a federated redirect landed here and this instance exchanged its code. */
|
|
3428
|
+
source?: 'federated-landing';
|
|
3348
3429
|
};
|
|
3349
3430
|
[PassflowEvent.SignInStart]: {
|
|
3350
3431
|
email?: string;
|
|
@@ -3588,6 +3669,8 @@ export declare class AuthService {
|
|
|
3588
3669
|
private tokenDeliveryManager;
|
|
3589
3670
|
private tokenExchangeConfig?;
|
|
3590
3671
|
private pendingPkce?;
|
|
3672
|
+
private pendingPasswordless?;
|
|
3673
|
+
private federatedSlot?;
|
|
3591
3674
|
/**
|
|
3592
3675
|
* The emailed code challenges this instance produced, by `challenge_id`. Memory only: an id
|
|
3593
3676
|
* this instance does not know (reload, another tab, a recreated instance) finishes as a sign-in.
|
|
@@ -3667,6 +3750,18 @@ export declare class AuthService {
|
|
|
3667
3750
|
hasPendingPkceSignIn(): boolean;
|
|
3668
3751
|
/** Drops the verifier of a pending sign-in. `TwoFactorService` calls this with its own state. */
|
|
3669
3752
|
forgetPkceSignIn(): void;
|
|
3753
|
+
/**
|
|
3754
|
+
* Keeps a passwordless sign-in's proof key in memory, read from first, and in sessionStorage, so
|
|
3755
|
+
* a reload of this tab can still finish it. Never localStorage: only this tab finishes the sign-in.
|
|
3756
|
+
*/
|
|
3757
|
+
private rememberPendingPasswordless;
|
|
3758
|
+
private readPendingPasswordless;
|
|
3759
|
+
private forgetPendingPasswordless;
|
|
3760
|
+
/** Keeps the verifier in memory, and in sessionStorage for the page the redirect lands on. */
|
|
3761
|
+
private rememberFederatedSlot;
|
|
3762
|
+
/** The slot, unless it has expired. An expired one stays until a newer start overwrites it. */
|
|
3763
|
+
private readFederatedSlot;
|
|
3764
|
+
private forgetFederatedSlot;
|
|
3670
3765
|
/**
|
|
3671
3766
|
* The proof key for a sign-in on a PKCE app, undefined on any other app.
|
|
3672
3767
|
*
|
|
@@ -3703,6 +3798,32 @@ export declare class AuthService {
|
|
|
3703
3798
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
3704
3799
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
3705
3800
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
3801
|
+
/**
|
|
3802
|
+
* Waits for the magic-link sign-in this tab started to be approved on another device, polling
|
|
3803
|
+
* every 3 s until its expiry. Network errors, 429, 5xx and unreadable answers keep polling.
|
|
3804
|
+
*
|
|
3805
|
+
* Aborting rejects with `signal.reason` and keeps the record, so a later call can wait again.
|
|
3806
|
+
* Once the server has answered `approved` the row is spent, and the exchange finishes regardless
|
|
3807
|
+
* of the signal.
|
|
3808
|
+
*
|
|
3809
|
+
* @throws The verifier-gone error when this tab's record does not name `challengeId`, or stops
|
|
3810
|
+
* naming it (sign-out, new start). A `PassflowError` on a 4xx answer other than 429 or a failed exchange.
|
|
3811
|
+
*/
|
|
3812
|
+
waitForPasswordlessSignIn(challengeId: string, options?: {
|
|
3813
|
+
signal?: AbortSignal;
|
|
3814
|
+
}): Promise<PasswordlessWaitResult>;
|
|
3815
|
+
/** Redeems an approved row's code. The row is spent, so the record goes whatever happens here. */
|
|
3816
|
+
private finishApprovedPasswordless;
|
|
3817
|
+
/** The match code to show, when this tab's record names that challenge and holds one. */
|
|
3818
|
+
getPendingPasswordlessSignIn(challengeId: string): {
|
|
3819
|
+
matchCode: string;
|
|
3820
|
+
expiresAt: number;
|
|
3821
|
+
} | undefined;
|
|
3822
|
+
/** What the approving device shows about a waiting sign-in. It changes nothing on the server. */
|
|
3823
|
+
getPasswordlessApproval(challengeId: string): Promise<PasswordlessApprovalInfo>;
|
|
3824
|
+
/** Approves or denies a waiting sign-in. `matchCode` is the code shown in the tab that started it. */
|
|
3825
|
+
decidePasswordlessApproval(challengeId: string, otp: string, approve: boolean, matchCode?: string): Promise<void>;
|
|
3826
|
+
private reportApprovalFailure;
|
|
3706
3827
|
/**
|
|
3707
3828
|
* Finishes a sign-up, sign-in or password change that answered with an emailed code
|
|
3708
3829
|
* (`email_verification_required` with a `challenge_id`): posts the code to `/auth/validate`, then
|
|
@@ -3806,6 +3927,16 @@ export declare class AuthService {
|
|
|
3806
3927
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
3807
3928
|
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload): Promise<void>;
|
|
3808
3929
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload): void;
|
|
3930
|
+
/**
|
|
3931
|
+
* Takes the slot for a `?code=` landing and exchanges the code in the background. `SignIn`,
|
|
3932
|
+
* `TwoFactorRequired` or an `Error` with operation `federated.redirect` reports the outcome.
|
|
3933
|
+
*
|
|
3934
|
+
* @returns false with no appId yet, or with no live slot: the slot stays for the instance built
|
|
3935
|
+
* after app-id discovery, and a code this tab did not ask for is not exchanged
|
|
3936
|
+
*/
|
|
3937
|
+
handleFederatedCode(code: string): boolean;
|
|
3938
|
+
private finishFederatedLanding;
|
|
3939
|
+
private reportFederatedRedirectFailure;
|
|
3809
3940
|
authRedirectUrl(options?: {
|
|
3810
3941
|
url?: string;
|
|
3811
3942
|
redirectUrl?: string;
|
|
@@ -5187,6 +5318,7 @@ export declare class Passflow {
|
|
|
5187
5318
|
private scopes;
|
|
5188
5319
|
private createTenantForNewUser;
|
|
5189
5320
|
private doRefreshTokens;
|
|
5321
|
+
private deferFederatedLanding;
|
|
5190
5322
|
private deviceService;
|
|
5191
5323
|
private storageManager;
|
|
5192
5324
|
private subscribeStore;
|
|
@@ -5412,9 +5544,28 @@ export declare class Passflow {
|
|
|
5412
5544
|
* // Tokens are automatically saved to storage
|
|
5413
5545
|
* }
|
|
5414
5546
|
* ```
|
|
5547
|
+
*
|
|
5548
|
+
* A PKCE federated landing (`?code=`) returns `undefined` and finishes in the background: `SignIn`
|
|
5549
|
+
* or `TwoFactorRequired` is the signal. With `deferFederatedLanding` it is left to
|
|
5550
|
+
* `completeFederatedLanding()`.
|
|
5415
5551
|
*/
|
|
5416
5552
|
handleTokensRedirect(): Tokens | undefined;
|
|
5553
|
+
/**
|
|
5554
|
+
* Takes a PKCE federated landing (`?code=&user_state=`) on this page, for an instance built with
|
|
5555
|
+
* `deferFederatedLanding`. The code is exchanged in the background; `SignIn` with
|
|
5556
|
+
* `source: 'federated-landing'`, `TwoFactorRequired`, or `Error` with operation `federated.redirect`
|
|
5557
|
+
* reports the outcome, so subscribe first.
|
|
5558
|
+
*
|
|
5559
|
+
* @returns true when this tab started that sign-in and the exchange began. On false, neither the
|
|
5560
|
+
* URL nor the stored proof key has changed, so an instance that has its app id can still take it.
|
|
5561
|
+
*/
|
|
5562
|
+
completeFederatedLanding(): boolean;
|
|
5417
5563
|
private checkAndSetTokens;
|
|
5564
|
+
/**
|
|
5565
|
+
* Removes only `code` and `user_state`, and only once the code is taken, so `appid` and
|
|
5566
|
+
* `redirectto` stay for the login page. A code this tab did not ask for leaves the URL as it is.
|
|
5567
|
+
*/
|
|
5568
|
+
private takeFederatedLanding;
|
|
5418
5569
|
/**
|
|
5419
5570
|
* Adopts a `#tfa_token=` fragment: the 2FA token goes to the TwoFactorService
|
|
5420
5571
|
* through `TwoFactorRequired`, exactly as a password sign-in's does, and the
|
|
@@ -5593,6 +5744,63 @@ export declare class Passflow {
|
|
|
5593
5744
|
* ```
|
|
5594
5745
|
*/
|
|
5595
5746
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
5747
|
+
/**
|
|
5748
|
+
* Waits for a magic-link sign-in this tab started to be approved on another device, then
|
|
5749
|
+
* finishes it here. Polls every 3 s until the challenge expires; network errors, 429 and 5xx keep
|
|
5750
|
+
* polling. Emits `SignIn` or `TwoFactorRequired` as any other sign-in does.
|
|
5751
|
+
*
|
|
5752
|
+
* Aborting rejects with `signal.reason` and keeps the sign-in, so a later call can wait again.
|
|
5753
|
+
* Once the approval has been read, the token exchange finishes regardless of the signal.
|
|
5754
|
+
*
|
|
5755
|
+
* @param challengeId - The `challenge_id` from `passwordlessSignIn`
|
|
5756
|
+
* @param options - Optional `signal` to stop waiting
|
|
5757
|
+
* @returns `signed-in` with the tokens, or `second-factor-required`, `denied`, `expired`, `completed`
|
|
5758
|
+
* @throws When this tab no longer holds the sign-in, on a refused status poll, or on a failed exchange
|
|
5759
|
+
*
|
|
5760
|
+
* @example
|
|
5761
|
+
* ```typescript
|
|
5762
|
+
* const { challenge_id } = await passflow.passwordlessSignIn(payload);
|
|
5763
|
+
* const pending = passflow.getPendingPasswordlessSignIn(challenge_id);
|
|
5764
|
+
* if (pending) {
|
|
5765
|
+
* showCode(pending.matchCode);
|
|
5766
|
+
* const result = await passflow.waitForPasswordlessSignIn(challenge_id);
|
|
5767
|
+
* }
|
|
5768
|
+
* ```
|
|
5769
|
+
*/
|
|
5770
|
+
waitForPasswordlessSignIn(challengeId: string, options?: {
|
|
5771
|
+
signal?: AbortSignal;
|
|
5772
|
+
}): Promise<PasswordlessWaitResult>;
|
|
5773
|
+
/**
|
|
5774
|
+
* The code to show while waiting for approval on another device.
|
|
5775
|
+
*
|
|
5776
|
+
* @param challengeId - The `challenge_id` from `passwordlessSignIn`
|
|
5777
|
+
* @returns The match code and expiry (epoch milliseconds), or `undefined` unless this tab started
|
|
5778
|
+
* that sign-in and it can be approved from another device
|
|
5779
|
+
*/
|
|
5780
|
+
getPendingPasswordlessSignIn(challengeId: string): {
|
|
5781
|
+
matchCode: string;
|
|
5782
|
+
expiresAt: number;
|
|
5783
|
+
} | undefined;
|
|
5784
|
+
/**
|
|
5785
|
+
* Reads what the device that opened a magic link shows before approving: app, requesting browser
|
|
5786
|
+
* and OS, location, time and attempts left. It holds no identity and changes nothing on the server.
|
|
5787
|
+
*
|
|
5788
|
+
* @param challengeId - The `challenge_id` from the link
|
|
5789
|
+
* @returns The approval context
|
|
5790
|
+
* @throws {PassflowError} If the challenge is unknown or cannot be approved
|
|
5791
|
+
*/
|
|
5792
|
+
getPasswordlessApproval(challengeId: string): Promise<PasswordlessApprovalInfo>;
|
|
5793
|
+
/**
|
|
5794
|
+
* Approves or denies a waiting sign-in from the device that opened the magic link. The tab that
|
|
5795
|
+
* started the sign-in finishes it; this device gets no tokens.
|
|
5796
|
+
*
|
|
5797
|
+
* @param challengeId - The `challenge_id` from the link
|
|
5798
|
+
* @param otp - The one-time code from the link
|
|
5799
|
+
* @param approve - `true` to approve, `false` to deny
|
|
5800
|
+
* @param matchCode - The code the user read from the waiting tab. Needed to approve.
|
|
5801
|
+
* @throws {PassflowError} If the code is wrong, the sign-in is expired or already decided
|
|
5802
|
+
*/
|
|
5803
|
+
decidePasswordlessApproval(challengeId: string, otp: string, approve: boolean, matchCode?: string): Promise<void>;
|
|
5596
5804
|
/**
|
|
5597
5805
|
* Finishes a sign-up, sign-in or password change that answered with `email_verification_required`
|
|
5598
5806
|
* and a `challenge_id`, using the code the user received by email. Answers like `signIn`: a new
|
package/dist/index.d.ts
CHANGED
|
@@ -1007,6 +1007,9 @@ export declare enum PassflowEndpointPaths {
|
|
|
1007
1007
|
signInWithProvider = "/auth/federated/start/",
|
|
1008
1008
|
passwordless = "/auth/passwordless/start",
|
|
1009
1009
|
passwordlessComplete = "/auth/passwordless/complete",
|
|
1010
|
+
passwordlessStatus = "/auth/passwordless/status",
|
|
1011
|
+
passwordlessApprovalInfo = "/auth/passwordless/approval/info",
|
|
1012
|
+
passwordlessApprovalDecide = "/auth/passwordless/approval/decide",
|
|
1010
1013
|
logout = "/user/logout",
|
|
1011
1014
|
refresh = "/auth/refresh",
|
|
1012
1015
|
validateSession = "/user/me",
|
|
@@ -1102,6 +1105,12 @@ export type PassflowConfig = {
|
|
|
1102
1105
|
scopes?: string[];
|
|
1103
1106
|
createTenantForNewUser?: boolean;
|
|
1104
1107
|
parseQueryParams?: boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
* Leaves a federated `?code=` landing alone in the constructor and in `handleTokensRedirect`,
|
|
1110
|
+
* so that only `completeFederatedLanding()` takes it. For hosts that build the instance during
|
|
1111
|
+
* render and may discard it. Token and `#tfa_token` landings are not affected.
|
|
1112
|
+
*/
|
|
1113
|
+
deferFederatedLanding?: boolean;
|
|
1105
1114
|
keyStoragePrefix?: string;
|
|
1106
1115
|
/**
|
|
1107
1116
|
* Token exchange configuration for secure server-side token handling.
|
|
@@ -1245,6 +1254,8 @@ export type PassflowValidationResponse = Tokens & {
|
|
|
1245
1254
|
requires_2fa?: boolean;
|
|
1246
1255
|
challenge_id?: string;
|
|
1247
1256
|
tfa_token?: string;
|
|
1257
|
+
/** PKCE app: the code to redeem with the verifier, in place of tokens. */
|
|
1258
|
+
code?: string;
|
|
1248
1259
|
};
|
|
1249
1260
|
export type PassflowSuccessResponse = {
|
|
1250
1261
|
result: 'ok';
|
|
@@ -1346,6 +1357,7 @@ export type PassflowPasswordlessSignInPayload = {
|
|
|
1346
1357
|
scopes?: string[];
|
|
1347
1358
|
create_tenant?: boolean;
|
|
1348
1359
|
invite_token?: string;
|
|
1360
|
+
code_challenge?: string;
|
|
1349
1361
|
} & ({
|
|
1350
1362
|
email: string;
|
|
1351
1363
|
phone?: never;
|
|
@@ -1356,6 +1368,8 @@ export type PassflowPasswordlessSignInPayload = {
|
|
|
1356
1368
|
export type PassflowPasswordlessResponse = {
|
|
1357
1369
|
challenge_id: string;
|
|
1358
1370
|
expires_at: Date | string;
|
|
1371
|
+
/** The code the user types on the approving device. Only on a row that can be approved from another device. */
|
|
1372
|
+
match_code?: string;
|
|
1359
1373
|
};
|
|
1360
1374
|
export type PassflowPasswordlessSignInExtendedPayload = PassflowPasswordlessSignInPayload & {
|
|
1361
1375
|
device: string;
|
|
@@ -1368,6 +1382,47 @@ export type PassflowPasswordlessSignInCompletePayload = {
|
|
|
1368
1382
|
scopes?: string[];
|
|
1369
1383
|
challenge_type?: InternalStrategyChallenge;
|
|
1370
1384
|
};
|
|
1385
|
+
export type PassflowPasswordlessStatusPayload = {
|
|
1386
|
+
challenge_id: string;
|
|
1387
|
+
code_challenge: string;
|
|
1388
|
+
};
|
|
1389
|
+
export type PassflowPasswordlessStatusResponse = {
|
|
1390
|
+
status: 'pending' | 'denied' | 'expired' | 'completed';
|
|
1391
|
+
} | {
|
|
1392
|
+
status: 'approved';
|
|
1393
|
+
code: string;
|
|
1394
|
+
};
|
|
1395
|
+
export type PassflowPasswordlessApprovalInfoPayload = {
|
|
1396
|
+
challenge_id: string;
|
|
1397
|
+
};
|
|
1398
|
+
export type PassflowPasswordlessApprovalDecidePayload = {
|
|
1399
|
+
challenge_id: string;
|
|
1400
|
+
otp: string;
|
|
1401
|
+
approve: boolean;
|
|
1402
|
+
match_code?: string;
|
|
1403
|
+
};
|
|
1404
|
+
export type PassflowPasswordlessApprovalDecideResponse = {
|
|
1405
|
+
state: 'approved' | 'denied';
|
|
1406
|
+
};
|
|
1407
|
+
export type PasswordlessWaitResult = {
|
|
1408
|
+
status: 'signed-in';
|
|
1409
|
+
tokens: PassflowAuthorizationResponse;
|
|
1410
|
+
} | {
|
|
1411
|
+
status: 'second-factor-required' | 'denied' | 'expired' | 'completed';
|
|
1412
|
+
};
|
|
1413
|
+
export type PasswordlessApprovalInfo = {
|
|
1414
|
+
state: 'pending' | 'approved' | 'denied' | 'expired' | 'completed';
|
|
1415
|
+
app_name: string;
|
|
1416
|
+
requested_at: string;
|
|
1417
|
+
expires_at: string;
|
|
1418
|
+
browser: string;
|
|
1419
|
+
os: string;
|
|
1420
|
+
location: {
|
|
1421
|
+
city: string;
|
|
1422
|
+
country: string;
|
|
1423
|
+
} | null;
|
|
1424
|
+
attempts_left: number;
|
|
1425
|
+
};
|
|
1371
1426
|
export declare enum Providers {
|
|
1372
1427
|
google = "google",
|
|
1373
1428
|
facebook = "facebook"
|
|
@@ -1540,6 +1595,8 @@ export type PassflowFederatedAuthPayload = {
|
|
|
1540
1595
|
scopes?: string[];
|
|
1541
1596
|
invite_token?: string;
|
|
1542
1597
|
create_tenant?: boolean;
|
|
1598
|
+
code_challenge?: string;
|
|
1599
|
+
code_challenge_method?: 'S256';
|
|
1543
1600
|
};
|
|
1544
1601
|
export type PassflowFederatedAuthExtendedPayload = PassflowFederatedAuthPayload & {
|
|
1545
1602
|
device?: string;
|
|
@@ -2064,10 +2121,32 @@ export declare class AuthAPI {
|
|
|
2064
2121
|
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField): Promise<PassflowAuthorizationResponse>;
|
|
2065
2122
|
signIn(payload: PassflowSignInPayload, deviceId: string, os: OS): Promise<PassflowAuthorizationResponse>;
|
|
2066
2123
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
2067
|
-
/**
|
|
2124
|
+
/**
|
|
2125
|
+
* Redeems the code a PKCE sign-in answered with for the tokens it stands for.
|
|
2126
|
+
*
|
|
2127
|
+
* Every exchange goes through here, so this is the one place that keeps the code and the
|
|
2128
|
+
* verifier out of its errors: it rejects only with a `PassflowError`.
|
|
2129
|
+
*/
|
|
2068
2130
|
pkceExchange(code: string, verifier: string): Promise<PassflowAuthorizationResponse>;
|
|
2131
|
+
/** Rejects only with a `PassflowError`, because its body can hold the poll secret. */
|
|
2069
2132
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload, deviceId: string, os: OS): Promise<PassflowPasswordlessResponse>;
|
|
2133
|
+
/** Rejects only with a `PassflowError`, because its body holds the OTP. */
|
|
2070
2134
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
2135
|
+
/**
|
|
2136
|
+
* Polls a magic-link sign-in waiting for approval from another device. Sent with credentials:
|
|
2137
|
+
* the trusted-device cookie is read when an approved row answers with its code. It rejects only
|
|
2138
|
+
* with a `PassflowError`, because its body holds the poll secret.
|
|
2139
|
+
*/
|
|
2140
|
+
passwordlessStatus(payload: PassflowPasswordlessStatusPayload, options?: {
|
|
2141
|
+
signal?: AbortSignal;
|
|
2142
|
+
}): Promise<PassflowPasswordlessStatusResponse>;
|
|
2143
|
+
/** Reads what the approving device shows. It changes nothing on the server. */
|
|
2144
|
+
passwordlessApprovalInfo(payload: PassflowPasswordlessApprovalInfoPayload): Promise<PasswordlessApprovalInfo>;
|
|
2145
|
+
/**
|
|
2146
|
+
* Approves or denies a waiting sign-in from the device that opened the link. It rejects only with
|
|
2147
|
+
* a `PassflowError`, because its body holds the OTP and the match code.
|
|
2148
|
+
*/
|
|
2149
|
+
passwordlessApprovalDecide(payload: PassflowPasswordlessApprovalDecidePayload): Promise<PassflowPasswordlessApprovalDecideResponse>;
|
|
2071
2150
|
/**
|
|
2072
2151
|
* Proves an emailed code for a sign-up, sign-in or password change that answered with
|
|
2073
2152
|
* `email_verification_required`. Only `{challenge_id, otp}` is sent: the server reads the
|
|
@@ -3314,7 +3393,7 @@ export declare enum PassflowEvent {
|
|
|
3314
3393
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
3315
3394
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
3316
3395
|
*/
|
|
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';
|
|
3396
|
+
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'passwordless.wait' | 'passwordless.approval' | 'password-reset.send' | 'password-reset.complete' | 'email-verification.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'federated.redirect' | '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';
|
|
3318
3397
|
/**
|
|
3319
3398
|
* Error payload interface for structured error information
|
|
3320
3399
|
*/
|
|
@@ -3345,6 +3424,8 @@ type PassflowEventPayload = {
|
|
|
3345
3424
|
parsedTokens?: ParsedTokens;
|
|
3346
3425
|
/** `'other-tab'` only when an ended tab revives on a new session found in storage. Absent on this tab's own sign-in. */
|
|
3347
3426
|
origin?: EventOrigin;
|
|
3427
|
+
/** Set only when a federated redirect landed here and this instance exchanged its code. */
|
|
3428
|
+
source?: 'federated-landing';
|
|
3348
3429
|
};
|
|
3349
3430
|
[PassflowEvent.SignInStart]: {
|
|
3350
3431
|
email?: string;
|
|
@@ -3588,6 +3669,8 @@ export declare class AuthService {
|
|
|
3588
3669
|
private tokenDeliveryManager;
|
|
3589
3670
|
private tokenExchangeConfig?;
|
|
3590
3671
|
private pendingPkce?;
|
|
3672
|
+
private pendingPasswordless?;
|
|
3673
|
+
private federatedSlot?;
|
|
3591
3674
|
/**
|
|
3592
3675
|
* The emailed code challenges this instance produced, by `challenge_id`. Memory only: an id
|
|
3593
3676
|
* this instance does not know (reload, another tab, a recreated instance) finishes as a sign-in.
|
|
@@ -3667,6 +3750,18 @@ export declare class AuthService {
|
|
|
3667
3750
|
hasPendingPkceSignIn(): boolean;
|
|
3668
3751
|
/** Drops the verifier of a pending sign-in. `TwoFactorService` calls this with its own state. */
|
|
3669
3752
|
forgetPkceSignIn(): void;
|
|
3753
|
+
/**
|
|
3754
|
+
* Keeps a passwordless sign-in's proof key in memory, read from first, and in sessionStorage, so
|
|
3755
|
+
* a reload of this tab can still finish it. Never localStorage: only this tab finishes the sign-in.
|
|
3756
|
+
*/
|
|
3757
|
+
private rememberPendingPasswordless;
|
|
3758
|
+
private readPendingPasswordless;
|
|
3759
|
+
private forgetPendingPasswordless;
|
|
3760
|
+
/** Keeps the verifier in memory, and in sessionStorage for the page the redirect lands on. */
|
|
3761
|
+
private rememberFederatedSlot;
|
|
3762
|
+
/** The slot, unless it has expired. An expired one stays until a newer start overwrites it. */
|
|
3763
|
+
private readFederatedSlot;
|
|
3764
|
+
private forgetFederatedSlot;
|
|
3670
3765
|
/**
|
|
3671
3766
|
* The proof key for a sign-in on a PKCE app, undefined on any other app.
|
|
3672
3767
|
*
|
|
@@ -3703,6 +3798,32 @@ export declare class AuthService {
|
|
|
3703
3798
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
3704
3799
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
3705
3800
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
3801
|
+
/**
|
|
3802
|
+
* Waits for the magic-link sign-in this tab started to be approved on another device, polling
|
|
3803
|
+
* every 3 s until its expiry. Network errors, 429, 5xx and unreadable answers keep polling.
|
|
3804
|
+
*
|
|
3805
|
+
* Aborting rejects with `signal.reason` and keeps the record, so a later call can wait again.
|
|
3806
|
+
* Once the server has answered `approved` the row is spent, and the exchange finishes regardless
|
|
3807
|
+
* of the signal.
|
|
3808
|
+
*
|
|
3809
|
+
* @throws The verifier-gone error when this tab's record does not name `challengeId`, or stops
|
|
3810
|
+
* naming it (sign-out, new start). A `PassflowError` on a 4xx answer other than 429 or a failed exchange.
|
|
3811
|
+
*/
|
|
3812
|
+
waitForPasswordlessSignIn(challengeId: string, options?: {
|
|
3813
|
+
signal?: AbortSignal;
|
|
3814
|
+
}): Promise<PasswordlessWaitResult>;
|
|
3815
|
+
/** Redeems an approved row's code. The row is spent, so the record goes whatever happens here. */
|
|
3816
|
+
private finishApprovedPasswordless;
|
|
3817
|
+
/** The match code to show, when this tab's record names that challenge and holds one. */
|
|
3818
|
+
getPendingPasswordlessSignIn(challengeId: string): {
|
|
3819
|
+
matchCode: string;
|
|
3820
|
+
expiresAt: number;
|
|
3821
|
+
} | undefined;
|
|
3822
|
+
/** What the approving device shows about a waiting sign-in. It changes nothing on the server. */
|
|
3823
|
+
getPasswordlessApproval(challengeId: string): Promise<PasswordlessApprovalInfo>;
|
|
3824
|
+
/** Approves or denies a waiting sign-in. `matchCode` is the code shown in the tab that started it. */
|
|
3825
|
+
decidePasswordlessApproval(challengeId: string, otp: string, approve: boolean, matchCode?: string): Promise<void>;
|
|
3826
|
+
private reportApprovalFailure;
|
|
3706
3827
|
/**
|
|
3707
3828
|
* Finishes a sign-up, sign-in or password change that answered with an emailed code
|
|
3708
3829
|
* (`email_verification_required` with a `challenge_id`): posts the code to `/auth/validate`, then
|
|
@@ -3806,6 +3927,16 @@ export declare class AuthService {
|
|
|
3806
3927
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
3807
3928
|
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload): Promise<void>;
|
|
3808
3929
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload): void;
|
|
3930
|
+
/**
|
|
3931
|
+
* Takes the slot for a `?code=` landing and exchanges the code in the background. `SignIn`,
|
|
3932
|
+
* `TwoFactorRequired` or an `Error` with operation `federated.redirect` reports the outcome.
|
|
3933
|
+
*
|
|
3934
|
+
* @returns false with no appId yet, or with no live slot: the slot stays for the instance built
|
|
3935
|
+
* after app-id discovery, and a code this tab did not ask for is not exchanged
|
|
3936
|
+
*/
|
|
3937
|
+
handleFederatedCode(code: string): boolean;
|
|
3938
|
+
private finishFederatedLanding;
|
|
3939
|
+
private reportFederatedRedirectFailure;
|
|
3809
3940
|
authRedirectUrl(options?: {
|
|
3810
3941
|
url?: string;
|
|
3811
3942
|
redirectUrl?: string;
|
|
@@ -5187,6 +5318,7 @@ export declare class Passflow {
|
|
|
5187
5318
|
private scopes;
|
|
5188
5319
|
private createTenantForNewUser;
|
|
5189
5320
|
private doRefreshTokens;
|
|
5321
|
+
private deferFederatedLanding;
|
|
5190
5322
|
private deviceService;
|
|
5191
5323
|
private storageManager;
|
|
5192
5324
|
private subscribeStore;
|
|
@@ -5412,9 +5544,28 @@ export declare class Passflow {
|
|
|
5412
5544
|
* // Tokens are automatically saved to storage
|
|
5413
5545
|
* }
|
|
5414
5546
|
* ```
|
|
5547
|
+
*
|
|
5548
|
+
* A PKCE federated landing (`?code=`) returns `undefined` and finishes in the background: `SignIn`
|
|
5549
|
+
* or `TwoFactorRequired` is the signal. With `deferFederatedLanding` it is left to
|
|
5550
|
+
* `completeFederatedLanding()`.
|
|
5415
5551
|
*/
|
|
5416
5552
|
handleTokensRedirect(): Tokens | undefined;
|
|
5553
|
+
/**
|
|
5554
|
+
* Takes a PKCE federated landing (`?code=&user_state=`) on this page, for an instance built with
|
|
5555
|
+
* `deferFederatedLanding`. The code is exchanged in the background; `SignIn` with
|
|
5556
|
+
* `source: 'federated-landing'`, `TwoFactorRequired`, or `Error` with operation `federated.redirect`
|
|
5557
|
+
* reports the outcome, so subscribe first.
|
|
5558
|
+
*
|
|
5559
|
+
* @returns true when this tab started that sign-in and the exchange began. On false, neither the
|
|
5560
|
+
* URL nor the stored proof key has changed, so an instance that has its app id can still take it.
|
|
5561
|
+
*/
|
|
5562
|
+
completeFederatedLanding(): boolean;
|
|
5417
5563
|
private checkAndSetTokens;
|
|
5564
|
+
/**
|
|
5565
|
+
* Removes only `code` and `user_state`, and only once the code is taken, so `appid` and
|
|
5566
|
+
* `redirectto` stay for the login page. A code this tab did not ask for leaves the URL as it is.
|
|
5567
|
+
*/
|
|
5568
|
+
private takeFederatedLanding;
|
|
5418
5569
|
/**
|
|
5419
5570
|
* Adopts a `#tfa_token=` fragment: the 2FA token goes to the TwoFactorService
|
|
5420
5571
|
* through `TwoFactorRequired`, exactly as a password sign-in's does, and the
|
|
@@ -5593,6 +5744,63 @@ export declare class Passflow {
|
|
|
5593
5744
|
* ```
|
|
5594
5745
|
*/
|
|
5595
5746
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
5747
|
+
/**
|
|
5748
|
+
* Waits for a magic-link sign-in this tab started to be approved on another device, then
|
|
5749
|
+
* finishes it here. Polls every 3 s until the challenge expires; network errors, 429 and 5xx keep
|
|
5750
|
+
* polling. Emits `SignIn` or `TwoFactorRequired` as any other sign-in does.
|
|
5751
|
+
*
|
|
5752
|
+
* Aborting rejects with `signal.reason` and keeps the sign-in, so a later call can wait again.
|
|
5753
|
+
* Once the approval has been read, the token exchange finishes regardless of the signal.
|
|
5754
|
+
*
|
|
5755
|
+
* @param challengeId - The `challenge_id` from `passwordlessSignIn`
|
|
5756
|
+
* @param options - Optional `signal` to stop waiting
|
|
5757
|
+
* @returns `signed-in` with the tokens, or `second-factor-required`, `denied`, `expired`, `completed`
|
|
5758
|
+
* @throws When this tab no longer holds the sign-in, on a refused status poll, or on a failed exchange
|
|
5759
|
+
*
|
|
5760
|
+
* @example
|
|
5761
|
+
* ```typescript
|
|
5762
|
+
* const { challenge_id } = await passflow.passwordlessSignIn(payload);
|
|
5763
|
+
* const pending = passflow.getPendingPasswordlessSignIn(challenge_id);
|
|
5764
|
+
* if (pending) {
|
|
5765
|
+
* showCode(pending.matchCode);
|
|
5766
|
+
* const result = await passflow.waitForPasswordlessSignIn(challenge_id);
|
|
5767
|
+
* }
|
|
5768
|
+
* ```
|
|
5769
|
+
*/
|
|
5770
|
+
waitForPasswordlessSignIn(challengeId: string, options?: {
|
|
5771
|
+
signal?: AbortSignal;
|
|
5772
|
+
}): Promise<PasswordlessWaitResult>;
|
|
5773
|
+
/**
|
|
5774
|
+
* The code to show while waiting for approval on another device.
|
|
5775
|
+
*
|
|
5776
|
+
* @param challengeId - The `challenge_id` from `passwordlessSignIn`
|
|
5777
|
+
* @returns The match code and expiry (epoch milliseconds), or `undefined` unless this tab started
|
|
5778
|
+
* that sign-in and it can be approved from another device
|
|
5779
|
+
*/
|
|
5780
|
+
getPendingPasswordlessSignIn(challengeId: string): {
|
|
5781
|
+
matchCode: string;
|
|
5782
|
+
expiresAt: number;
|
|
5783
|
+
} | undefined;
|
|
5784
|
+
/**
|
|
5785
|
+
* Reads what the device that opened a magic link shows before approving: app, requesting browser
|
|
5786
|
+
* and OS, location, time and attempts left. It holds no identity and changes nothing on the server.
|
|
5787
|
+
*
|
|
5788
|
+
* @param challengeId - The `challenge_id` from the link
|
|
5789
|
+
* @returns The approval context
|
|
5790
|
+
* @throws {PassflowError} If the challenge is unknown or cannot be approved
|
|
5791
|
+
*/
|
|
5792
|
+
getPasswordlessApproval(challengeId: string): Promise<PasswordlessApprovalInfo>;
|
|
5793
|
+
/**
|
|
5794
|
+
* Approves or denies a waiting sign-in from the device that opened the magic link. The tab that
|
|
5795
|
+
* started the sign-in finishes it; this device gets no tokens.
|
|
5796
|
+
*
|
|
5797
|
+
* @param challengeId - The `challenge_id` from the link
|
|
5798
|
+
* @param otp - The one-time code from the link
|
|
5799
|
+
* @param approve - `true` to approve, `false` to deny
|
|
5800
|
+
* @param matchCode - The code the user read from the waiting tab. Needed to approve.
|
|
5801
|
+
* @throws {PassflowError} If the code is wrong, the sign-in is expired or already decided
|
|
5802
|
+
*/
|
|
5803
|
+
decidePasswordlessApproval(challengeId: string, otp: string, approve: boolean, matchCode?: string): Promise<void>;
|
|
5596
5804
|
/**
|
|
5597
5805
|
* Finishes a sign-up, sign-in or password change that answered with `email_verification_required`
|
|
5598
5806
|
* and a `challenge_id`, using the code the user received by email. Answers like `signIn`: a new
|