@passflow/core 0.23.0 → 0.25.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 +85 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +325 -8
- package/dist/index.d.ts +325 -8
- package/dist/index.mjs +1064 -673
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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",
|
|
@@ -1039,6 +1042,10 @@ export declare enum PassflowEndpointPaths {
|
|
|
1039
1042
|
twoFactorRecovery = "/auth/2fa/recovery",
|
|
1040
1043
|
twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate",
|
|
1041
1044
|
twoFactorSetupMagicLink = "/auth/2fa-setup", // :token param appended in API call
|
|
1045
|
+
twoFactorEnrollment = "/auth/2fa/enrollment",
|
|
1046
|
+
twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link",
|
|
1047
|
+
twoFactorEnrollmentBegin = "/auth/2fa/setup/begin",
|
|
1048
|
+
twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm",
|
|
1042
1049
|
TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available",
|
|
1043
1050
|
TwoFactorMethodsRegistered = "/v2/user/2fa/methods",
|
|
1044
1051
|
TwoFactorSetupStart = "/v2/user/2fa/setup/start",
|
|
@@ -1102,6 +1109,12 @@ export type PassflowConfig = {
|
|
|
1102
1109
|
scopes?: string[];
|
|
1103
1110
|
createTenantForNewUser?: boolean;
|
|
1104
1111
|
parseQueryParams?: boolean;
|
|
1112
|
+
/**
|
|
1113
|
+
* Leaves a federated `?code=` landing alone in the constructor and in `handleTokensRedirect`,
|
|
1114
|
+
* so that only `completeFederatedLanding()` takes it. For hosts that build the instance during
|
|
1115
|
+
* render and may discard it. Token and `#tfa_token` landings are not affected.
|
|
1116
|
+
*/
|
|
1117
|
+
deferFederatedLanding?: boolean;
|
|
1105
1118
|
keyStoragePrefix?: string;
|
|
1106
1119
|
/**
|
|
1107
1120
|
* Token exchange configuration for secure server-side token handling.
|
|
@@ -1245,6 +1258,8 @@ export type PassflowValidationResponse = Tokens & {
|
|
|
1245
1258
|
requires_2fa?: boolean;
|
|
1246
1259
|
challenge_id?: string;
|
|
1247
1260
|
tfa_token?: string;
|
|
1261
|
+
/** PKCE app: the code to redeem with the verifier, in place of tokens. */
|
|
1262
|
+
code?: string;
|
|
1248
1263
|
};
|
|
1249
1264
|
export type PassflowSuccessResponse = {
|
|
1250
1265
|
result: 'ok';
|
|
@@ -1346,6 +1361,7 @@ export type PassflowPasswordlessSignInPayload = {
|
|
|
1346
1361
|
scopes?: string[];
|
|
1347
1362
|
create_tenant?: boolean;
|
|
1348
1363
|
invite_token?: string;
|
|
1364
|
+
code_challenge?: string;
|
|
1349
1365
|
} & ({
|
|
1350
1366
|
email: string;
|
|
1351
1367
|
phone?: never;
|
|
@@ -1356,6 +1372,8 @@ export type PassflowPasswordlessSignInPayload = {
|
|
|
1356
1372
|
export type PassflowPasswordlessResponse = {
|
|
1357
1373
|
challenge_id: string;
|
|
1358
1374
|
expires_at: Date | string;
|
|
1375
|
+
/** The code the user types on the approving device. Only on a row that can be approved from another device. */
|
|
1376
|
+
match_code?: string;
|
|
1359
1377
|
};
|
|
1360
1378
|
export type PassflowPasswordlessSignInExtendedPayload = PassflowPasswordlessSignInPayload & {
|
|
1361
1379
|
device: string;
|
|
@@ -1368,6 +1386,47 @@ export type PassflowPasswordlessSignInCompletePayload = {
|
|
|
1368
1386
|
scopes?: string[];
|
|
1369
1387
|
challenge_type?: InternalStrategyChallenge;
|
|
1370
1388
|
};
|
|
1389
|
+
export type PassflowPasswordlessStatusPayload = {
|
|
1390
|
+
challenge_id: string;
|
|
1391
|
+
code_challenge: string;
|
|
1392
|
+
};
|
|
1393
|
+
export type PassflowPasswordlessStatusResponse = {
|
|
1394
|
+
status: 'pending' | 'denied' | 'expired' | 'completed';
|
|
1395
|
+
} | {
|
|
1396
|
+
status: 'approved';
|
|
1397
|
+
code: string;
|
|
1398
|
+
};
|
|
1399
|
+
export type PassflowPasswordlessApprovalInfoPayload = {
|
|
1400
|
+
challenge_id: string;
|
|
1401
|
+
};
|
|
1402
|
+
export type PassflowPasswordlessApprovalDecidePayload = {
|
|
1403
|
+
challenge_id: string;
|
|
1404
|
+
otp: string;
|
|
1405
|
+
approve: boolean;
|
|
1406
|
+
match_code?: string;
|
|
1407
|
+
};
|
|
1408
|
+
export type PassflowPasswordlessApprovalDecideResponse = {
|
|
1409
|
+
state: 'approved' | 'denied';
|
|
1410
|
+
};
|
|
1411
|
+
export type PasswordlessWaitResult = {
|
|
1412
|
+
status: 'signed-in';
|
|
1413
|
+
tokens: PassflowAuthorizationResponse;
|
|
1414
|
+
} | {
|
|
1415
|
+
status: 'second-factor-required' | 'denied' | 'expired' | 'completed';
|
|
1416
|
+
};
|
|
1417
|
+
export type PasswordlessApprovalInfo = {
|
|
1418
|
+
state: 'pending' | 'approved' | 'denied' | 'expired' | 'completed';
|
|
1419
|
+
app_name: string;
|
|
1420
|
+
requested_at: string;
|
|
1421
|
+
expires_at: string;
|
|
1422
|
+
browser: string;
|
|
1423
|
+
os: string;
|
|
1424
|
+
location: {
|
|
1425
|
+
city: string;
|
|
1426
|
+
country: string;
|
|
1427
|
+
} | null;
|
|
1428
|
+
attempts_left: number;
|
|
1429
|
+
};
|
|
1371
1430
|
export declare enum Providers {
|
|
1372
1431
|
google = "google",
|
|
1373
1432
|
facebook = "facebook"
|
|
@@ -1540,6 +1599,8 @@ export type PassflowFederatedAuthPayload = {
|
|
|
1540
1599
|
scopes?: string[];
|
|
1541
1600
|
invite_token?: string;
|
|
1542
1601
|
create_tenant?: boolean;
|
|
1602
|
+
code_challenge?: string;
|
|
1603
|
+
code_challenge_method?: 'S256';
|
|
1543
1604
|
};
|
|
1544
1605
|
export type PassflowFederatedAuthExtendedPayload = PassflowFederatedAuthPayload & {
|
|
1545
1606
|
device?: string;
|
|
@@ -1760,13 +1821,33 @@ export type TwoFactorStatusResponse = {
|
|
|
1760
1821
|
};
|
|
1761
1822
|
export type TwoFactorSetupResponse = {
|
|
1762
1823
|
secret: string;
|
|
1824
|
+
/** Base64-encoded PNG of the QR code. Empty when the server sent no image: use `qr_code_url`. */
|
|
1763
1825
|
qr_code: string;
|
|
1826
|
+
/** The `otpauth://` URL the QR code holds. */
|
|
1827
|
+
qr_code_url?: string;
|
|
1764
1828
|
totp_digits?: 6 | 8;
|
|
1765
1829
|
};
|
|
1766
1830
|
export type TwoFactorConfirmResponse = {
|
|
1767
1831
|
success: true;
|
|
1832
|
+
enabled?: boolean;
|
|
1768
1833
|
recovery_codes: string[];
|
|
1769
1834
|
};
|
|
1835
|
+
/**
|
|
1836
|
+
* What a sign-in waiting on its second factor can do next, decided by the server:
|
|
1837
|
+
* - `verify`: ask for a code; the user has a factor the app accepts.
|
|
1838
|
+
* - `email_link`: no factor yet and a validated email: send the setup link, then the user signs in again.
|
|
1839
|
+
* - `direct`: no factor and no validated email: enrol here, then finish with the code.
|
|
1840
|
+
* - `unavailable`: the app offers no way to enrol this user: contact the administrator.
|
|
1841
|
+
*/
|
|
1842
|
+
export type TwoFactorEnrollment = 'verify' | 'email_link' | 'direct' | 'unavailable';
|
|
1843
|
+
/** GET /auth/2fa/enrollment */
|
|
1844
|
+
export type TwoFactorEnrollmentResponse = {
|
|
1845
|
+
enrollment: TwoFactorEnrollment;
|
|
1846
|
+
};
|
|
1847
|
+
/** POST /auth/2fa/enrollment/email-link */
|
|
1848
|
+
export type TwoFactorSetupLinkResponse = {
|
|
1849
|
+
email_sent: boolean;
|
|
1850
|
+
};
|
|
1770
1851
|
export type TwoFactorVerifyResponse = Tokens & {
|
|
1771
1852
|
success: true;
|
|
1772
1853
|
/** On a PKCE app; `TwoFactorService` redeems it, so its callers never see one. */
|
|
@@ -1815,7 +1896,7 @@ export type TwoFactorRegenerateResponse = {
|
|
|
1815
1896
|
/**
|
|
1816
1897
|
* Two-Factor magic link error codes
|
|
1817
1898
|
*/
|
|
1818
|
-
export type TwoFactorSetupMagicLinkErrorCode = 'INVALID_TOKEN' | 'EXPIRED_TOKEN' | 'REVOKED_TOKEN' | 'RATE_LIMITED' | 'SERVER_ERROR';
|
|
1899
|
+
export type TwoFactorSetupMagicLinkErrorCode = 'INVALID_TOKEN' | 'EXPIRED_TOKEN' | 'REVOKED_TOKEN' | 'ALREADY_USED' | 'RATE_LIMITED' | 'SERVER_ERROR';
|
|
1819
1900
|
/**
|
|
1820
1901
|
* Two-Factor magic link error details
|
|
1821
1902
|
*/
|
|
@@ -2064,10 +2145,32 @@ export declare class AuthAPI {
|
|
|
2064
2145
|
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField): Promise<PassflowAuthorizationResponse>;
|
|
2065
2146
|
signIn(payload: PassflowSignInPayload, deviceId: string, os: OS): Promise<PassflowAuthorizationResponse>;
|
|
2066
2147
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
2067
|
-
/**
|
|
2148
|
+
/**
|
|
2149
|
+
* Redeems the code a PKCE sign-in answered with for the tokens it stands for.
|
|
2150
|
+
*
|
|
2151
|
+
* Every exchange goes through here, so this is the one place that keeps the code and the
|
|
2152
|
+
* verifier out of its errors: it rejects only with a `PassflowError`.
|
|
2153
|
+
*/
|
|
2068
2154
|
pkceExchange(code: string, verifier: string): Promise<PassflowAuthorizationResponse>;
|
|
2155
|
+
/** Rejects only with a `PassflowError`, because its body can hold the poll secret. */
|
|
2069
2156
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload, deviceId: string, os: OS): Promise<PassflowPasswordlessResponse>;
|
|
2157
|
+
/** Rejects only with a `PassflowError`, because its body holds the OTP. */
|
|
2070
2158
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
2159
|
+
/**
|
|
2160
|
+
* Polls a magic-link sign-in waiting for approval from another device. Sent with credentials:
|
|
2161
|
+
* the trusted-device cookie is read when an approved row answers with its code. It rejects only
|
|
2162
|
+
* with a `PassflowError`, because its body holds the poll secret.
|
|
2163
|
+
*/
|
|
2164
|
+
passwordlessStatus(payload: PassflowPasswordlessStatusPayload, options?: {
|
|
2165
|
+
signal?: AbortSignal;
|
|
2166
|
+
}): Promise<PassflowPasswordlessStatusResponse>;
|
|
2167
|
+
/** Reads what the approving device shows. It changes nothing on the server. */
|
|
2168
|
+
passwordlessApprovalInfo(payload: PassflowPasswordlessApprovalInfoPayload): Promise<PasswordlessApprovalInfo>;
|
|
2169
|
+
/**
|
|
2170
|
+
* Approves or denies a waiting sign-in from the device that opened the link. It rejects only with
|
|
2171
|
+
* a `PassflowError`, because its body holds the OTP and the match code.
|
|
2172
|
+
*/
|
|
2173
|
+
passwordlessApprovalDecide(payload: PassflowPasswordlessApprovalDecidePayload): Promise<PassflowPasswordlessApprovalDecideResponse>;
|
|
2071
2174
|
/**
|
|
2072
2175
|
* Proves an emailed code for a sign-up, sign-in or password change that answered with
|
|
2073
2176
|
* `email_verification_required`. Only `{challenge_id, otp}` is sent: the server reads the
|
|
@@ -2396,20 +2499,46 @@ export declare class TwoFactorApiClient {
|
|
|
2396
2499
|
/**
|
|
2397
2500
|
* Get current 2FA enrollment status
|
|
2398
2501
|
* GET /user/2fa/status
|
|
2502
|
+
*
|
|
2503
|
+
* `setupSessionToken` is a setup link's session; without it the stored session is used.
|
|
2399
2504
|
*/
|
|
2400
|
-
getStatus(): Promise<TwoFactorStatusResponse>;
|
|
2505
|
+
getStatus(setupSessionToken?: string): Promise<TwoFactorStatusResponse>;
|
|
2401
2506
|
/**
|
|
2402
2507
|
* Begin 2FA setup process
|
|
2403
2508
|
* POST /user/2fa/setup/begin
|
|
2404
2509
|
* Returns secret and QR code for authenticator app
|
|
2510
|
+
*
|
|
2511
|
+
* `setupSessionToken` is a setup link's session; without it the stored session is used.
|
|
2405
2512
|
*/
|
|
2406
|
-
beginSetup(): Promise<TwoFactorSetupResponse>;
|
|
2513
|
+
beginSetup(setupSessionToken?: string): Promise<TwoFactorSetupResponse>;
|
|
2407
2514
|
/**
|
|
2408
2515
|
* Confirm 2FA setup with TOTP code
|
|
2409
2516
|
* POST /user/2fa/setup/confirm
|
|
2410
2517
|
* Returns recovery codes on success
|
|
2518
|
+
*
|
|
2519
|
+
* `setupSessionToken` is a setup link's session; without it the stored session is used.
|
|
2520
|
+
*/
|
|
2521
|
+
confirmSetup(payload: TwoFactorConfirmRequest, setupSessionToken?: string): Promise<TwoFactorConfirmResponse>;
|
|
2522
|
+
/**
|
|
2523
|
+
* What a sign-in waiting on its second factor can do next
|
|
2524
|
+
* GET /auth/2fa/enrollment
|
|
2525
|
+
*/
|
|
2526
|
+
getEnrollment(tfaToken: string): Promise<TwoFactorEnrollment>;
|
|
2527
|
+
/**
|
|
2528
|
+
* Email the user a link to set up 2FA
|
|
2529
|
+
* POST /auth/2fa/enrollment/email-link
|
|
2530
|
+
*/
|
|
2531
|
+
sendSetupLink(tfaToken: string): Promise<TwoFactorSetupLinkResponse>;
|
|
2532
|
+
/**
|
|
2533
|
+
* Begin 2FA setup on the sign-in itself, for a user with no validated email
|
|
2534
|
+
* POST /auth/2fa/setup/begin
|
|
2535
|
+
*/
|
|
2536
|
+
beginEnrollment(tfaToken: string): Promise<TwoFactorSetupResponse>;
|
|
2537
|
+
/**
|
|
2538
|
+
* Confirm 2FA setup on the sign-in itself; `verify` with the same code then finishes it
|
|
2539
|
+
* POST /auth/2fa/setup/confirm
|
|
2411
2540
|
*/
|
|
2412
|
-
|
|
2541
|
+
confirmEnrollment(tfaToken: string, payload: TwoFactorConfirmRequest): Promise<TwoFactorConfirmResponse>;
|
|
2413
2542
|
/**
|
|
2414
2543
|
* Verify TOTP code during login
|
|
2415
2544
|
* POST /auth/2fa/verify
|
|
@@ -3314,7 +3443,7 @@ export declare enum PassflowEvent {
|
|
|
3314
3443
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
3315
3444
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
3316
3445
|
*/
|
|
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';
|
|
3446
|
+
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.enrollment.read' | '2fa.enrollment.setup-link' | '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
3447
|
/**
|
|
3319
3448
|
* Error payload interface for structured error information
|
|
3320
3449
|
*/
|
|
@@ -3345,6 +3474,8 @@ type PassflowEventPayload = {
|
|
|
3345
3474
|
parsedTokens?: ParsedTokens;
|
|
3346
3475
|
/** `'other-tab'` only when an ended tab revives on a new session found in storage. Absent on this tab's own sign-in. */
|
|
3347
3476
|
origin?: EventOrigin;
|
|
3477
|
+
/** Set only when a federated redirect landed here and this instance exchanged its code. */
|
|
3478
|
+
source?: 'federated-landing';
|
|
3348
3479
|
};
|
|
3349
3480
|
[PassflowEvent.SignInStart]: {
|
|
3350
3481
|
email?: string;
|
|
@@ -3433,7 +3564,7 @@ type PassflowEventPayload = {
|
|
|
3433
3564
|
};
|
|
3434
3565
|
[PassflowEvent.TwoFactorSetupMagicLinkFailed]: {
|
|
3435
3566
|
error: {
|
|
3436
|
-
code: 'INVALID_TOKEN' | 'EXPIRED_TOKEN' | 'REVOKED_TOKEN' | 'RATE_LIMITED' | 'SERVER_ERROR';
|
|
3567
|
+
code: 'INVALID_TOKEN' | 'EXPIRED_TOKEN' | 'REVOKED_TOKEN' | 'ALREADY_USED' | 'RATE_LIMITED' | 'SERVER_ERROR';
|
|
3437
3568
|
message: string;
|
|
3438
3569
|
retryAfter?: number;
|
|
3439
3570
|
};
|
|
@@ -3588,6 +3719,8 @@ export declare class AuthService {
|
|
|
3588
3719
|
private tokenDeliveryManager;
|
|
3589
3720
|
private tokenExchangeConfig?;
|
|
3590
3721
|
private pendingPkce?;
|
|
3722
|
+
private pendingPasswordless?;
|
|
3723
|
+
private federatedSlot?;
|
|
3591
3724
|
/**
|
|
3592
3725
|
* The emailed code challenges this instance produced, by `challenge_id`. Memory only: an id
|
|
3593
3726
|
* this instance does not know (reload, another tab, a recreated instance) finishes as a sign-in.
|
|
@@ -3667,6 +3800,18 @@ export declare class AuthService {
|
|
|
3667
3800
|
hasPendingPkceSignIn(): boolean;
|
|
3668
3801
|
/** Drops the verifier of a pending sign-in. `TwoFactorService` calls this with its own state. */
|
|
3669
3802
|
forgetPkceSignIn(): void;
|
|
3803
|
+
/**
|
|
3804
|
+
* Keeps a passwordless sign-in's proof key in memory, read from first, and in sessionStorage, so
|
|
3805
|
+
* a reload of this tab can still finish it. Never localStorage: only this tab finishes the sign-in.
|
|
3806
|
+
*/
|
|
3807
|
+
private rememberPendingPasswordless;
|
|
3808
|
+
private readPendingPasswordless;
|
|
3809
|
+
private forgetPendingPasswordless;
|
|
3810
|
+
/** Keeps the verifier in memory, and in sessionStorage for the page the redirect lands on. */
|
|
3811
|
+
private rememberFederatedSlot;
|
|
3812
|
+
/** The slot, unless it has expired. An expired one stays until a newer start overwrites it. */
|
|
3813
|
+
private readFederatedSlot;
|
|
3814
|
+
private forgetFederatedSlot;
|
|
3670
3815
|
/**
|
|
3671
3816
|
* The proof key for a sign-in on a PKCE app, undefined on any other app.
|
|
3672
3817
|
*
|
|
@@ -3703,6 +3848,32 @@ export declare class AuthService {
|
|
|
3703
3848
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
3704
3849
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
3705
3850
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
3851
|
+
/**
|
|
3852
|
+
* Waits for the magic-link sign-in this tab started to be approved on another device, polling
|
|
3853
|
+
* every 3 s until its expiry. Network errors, 429, 5xx and unreadable answers keep polling.
|
|
3854
|
+
*
|
|
3855
|
+
* Aborting rejects with `signal.reason` and keeps the record, so a later call can wait again.
|
|
3856
|
+
* Once the server has answered `approved` the row is spent, and the exchange finishes regardless
|
|
3857
|
+
* of the signal.
|
|
3858
|
+
*
|
|
3859
|
+
* @throws The verifier-gone error when this tab's record does not name `challengeId`, or stops
|
|
3860
|
+
* naming it (sign-out, new start). A `PassflowError` on a 4xx answer other than 429 or a failed exchange.
|
|
3861
|
+
*/
|
|
3862
|
+
waitForPasswordlessSignIn(challengeId: string, options?: {
|
|
3863
|
+
signal?: AbortSignal;
|
|
3864
|
+
}): Promise<PasswordlessWaitResult>;
|
|
3865
|
+
/** Redeems an approved row's code. The row is spent, so the record goes whatever happens here. */
|
|
3866
|
+
private finishApprovedPasswordless;
|
|
3867
|
+
/** The match code to show, when this tab's record names that challenge and holds one. */
|
|
3868
|
+
getPendingPasswordlessSignIn(challengeId: string): {
|
|
3869
|
+
matchCode: string;
|
|
3870
|
+
expiresAt: number;
|
|
3871
|
+
} | undefined;
|
|
3872
|
+
/** What the approving device shows about a waiting sign-in. It changes nothing on the server. */
|
|
3873
|
+
getPasswordlessApproval(challengeId: string): Promise<PasswordlessApprovalInfo>;
|
|
3874
|
+
/** Approves or denies a waiting sign-in. `matchCode` is the code shown in the tab that started it. */
|
|
3875
|
+
decidePasswordlessApproval(challengeId: string, otp: string, approve: boolean, matchCode?: string): Promise<void>;
|
|
3876
|
+
private reportApprovalFailure;
|
|
3706
3877
|
/**
|
|
3707
3878
|
* Finishes a sign-up, sign-in or password change that answered with an emailed code
|
|
3708
3879
|
* (`email_verification_required` with a `challenge_id`): posts the code to `/auth/validate`, then
|
|
@@ -3806,6 +3977,16 @@ export declare class AuthService {
|
|
|
3806
3977
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
3807
3978
|
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload): Promise<void>;
|
|
3808
3979
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload): void;
|
|
3980
|
+
/**
|
|
3981
|
+
* Takes the slot for a `?code=` landing and exchanges the code in the background. `SignIn`,
|
|
3982
|
+
* `TwoFactorRequired` or an `Error` with operation `federated.redirect` reports the outcome.
|
|
3983
|
+
*
|
|
3984
|
+
* @returns false with no appId yet, or with no live slot: the slot stays for the instance built
|
|
3985
|
+
* after app-id discovery, and a code this tab did not ask for is not exchanged
|
|
3986
|
+
*/
|
|
3987
|
+
handleFederatedCode(code: string): boolean;
|
|
3988
|
+
private finishFederatedLanding;
|
|
3989
|
+
private reportFederatedRedirectFailure;
|
|
3809
3990
|
authRedirectUrl(options?: {
|
|
3810
3991
|
url?: string;
|
|
3811
3992
|
redirectUrl?: string;
|
|
@@ -4190,13 +4371,39 @@ export declare class TwoFactorService {
|
|
|
4190
4371
|
/**
|
|
4191
4372
|
* Begin 2FA setup process
|
|
4192
4373
|
* Returns secret and QR code for authenticator app
|
|
4374
|
+
*
|
|
4375
|
+
* With a setup link's session active the call runs on that session, whoever is signed in here.
|
|
4193
4376
|
*/
|
|
4194
4377
|
beginSetup(): Promise<TwoFactorSetupResponse>;
|
|
4195
4378
|
/**
|
|
4196
4379
|
* Confirm 2FA setup with TOTP code
|
|
4197
4380
|
* Returns recovery codes that MUST be displayed to user
|
|
4381
|
+
*
|
|
4382
|
+
* With a setup link's session active the call runs on that session, which it then ends.
|
|
4198
4383
|
*/
|
|
4199
4384
|
confirmSetup(code: string): Promise<TwoFactorConfirmResponse>;
|
|
4385
|
+
/**
|
|
4386
|
+
* What the sign-in waiting on its second factor can do next. Read this before asking for a code:
|
|
4387
|
+
* the server decides, and only `verify` means the user has a factor to enter a code from.
|
|
4388
|
+
*/
|
|
4389
|
+
getEnrollment(): Promise<TwoFactorEnrollment>;
|
|
4390
|
+
/**
|
|
4391
|
+
* Email the user a link to set up 2FA (`email_link`). They sign in again after enrolling.
|
|
4392
|
+
*/
|
|
4393
|
+
sendSetupLink(): Promise<TwoFactorSetupLinkResponse>;
|
|
4394
|
+
/**
|
|
4395
|
+
* Begin 2FA setup on the sign-in itself (`direct`).
|
|
4396
|
+
*/
|
|
4397
|
+
beginEnrollment(): Promise<TwoFactorSetupResponse>;
|
|
4398
|
+
/**
|
|
4399
|
+
* Confirm 2FA setup on the sign-in itself (`direct`). The sign-in stays pending:
|
|
4400
|
+
* show the recovery codes, then `verify` with the same code finishes it.
|
|
4401
|
+
*/
|
|
4402
|
+
confirmEnrollment(code: string): Promise<TwoFactorConfirmResponse>;
|
|
4403
|
+
private assertTotpCode;
|
|
4404
|
+
private requirePendingTfaToken;
|
|
4405
|
+
private setupStarted;
|
|
4406
|
+
private setupConfirmed;
|
|
4200
4407
|
/**
|
|
4201
4408
|
* Verify TOTP code during login
|
|
4202
4409
|
* Completes authentication if successful
|
|
@@ -4288,7 +4495,7 @@ export declare class TwoFactorService {
|
|
|
4288
4495
|
hasMagicLinkSession(): boolean;
|
|
4289
4496
|
/**
|
|
4290
4497
|
* Get the session token from magic link session (if active)
|
|
4291
|
-
*
|
|
4498
|
+
* `getStatus`, `beginSetup` and `confirmSetup` send it as their bearer while it is active
|
|
4292
4499
|
*/
|
|
4293
4500
|
getMagicLinkSessionToken(): string | null;
|
|
4294
4501
|
/**
|
|
@@ -5187,6 +5394,7 @@ export declare class Passflow {
|
|
|
5187
5394
|
private scopes;
|
|
5188
5395
|
private createTenantForNewUser;
|
|
5189
5396
|
private doRefreshTokens;
|
|
5397
|
+
private deferFederatedLanding;
|
|
5190
5398
|
private deviceService;
|
|
5191
5399
|
private storageManager;
|
|
5192
5400
|
private subscribeStore;
|
|
@@ -5412,9 +5620,28 @@ export declare class Passflow {
|
|
|
5412
5620
|
* // Tokens are automatically saved to storage
|
|
5413
5621
|
* }
|
|
5414
5622
|
* ```
|
|
5623
|
+
*
|
|
5624
|
+
* A PKCE federated landing (`?code=`) returns `undefined` and finishes in the background: `SignIn`
|
|
5625
|
+
* or `TwoFactorRequired` is the signal. With `deferFederatedLanding` it is left to
|
|
5626
|
+
* `completeFederatedLanding()`.
|
|
5415
5627
|
*/
|
|
5416
5628
|
handleTokensRedirect(): Tokens | undefined;
|
|
5629
|
+
/**
|
|
5630
|
+
* Takes a PKCE federated landing (`?code=&user_state=`) on this page, for an instance built with
|
|
5631
|
+
* `deferFederatedLanding`. The code is exchanged in the background; `SignIn` with
|
|
5632
|
+
* `source: 'federated-landing'`, `TwoFactorRequired`, or `Error` with operation `federated.redirect`
|
|
5633
|
+
* reports the outcome, so subscribe first.
|
|
5634
|
+
*
|
|
5635
|
+
* @returns true when this tab started that sign-in and the exchange began. On false, neither the
|
|
5636
|
+
* URL nor the stored proof key has changed, so an instance that has its app id can still take it.
|
|
5637
|
+
*/
|
|
5638
|
+
completeFederatedLanding(): boolean;
|
|
5417
5639
|
private checkAndSetTokens;
|
|
5640
|
+
/**
|
|
5641
|
+
* Removes only `code` and `user_state`, and only once the code is taken, so `appid` and
|
|
5642
|
+
* `redirectto` stay for the login page. A code this tab did not ask for leaves the URL as it is.
|
|
5643
|
+
*/
|
|
5644
|
+
private takeFederatedLanding;
|
|
5418
5645
|
/**
|
|
5419
5646
|
* Adopts a `#tfa_token=` fragment: the 2FA token goes to the TwoFactorService
|
|
5420
5647
|
* through `TwoFactorRequired`, exactly as a password sign-in's does, and the
|
|
@@ -5593,6 +5820,63 @@ export declare class Passflow {
|
|
|
5593
5820
|
* ```
|
|
5594
5821
|
*/
|
|
5595
5822
|
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
5823
|
+
/**
|
|
5824
|
+
* Waits for a magic-link sign-in this tab started to be approved on another device, then
|
|
5825
|
+
* finishes it here. Polls every 3 s until the challenge expires; network errors, 429 and 5xx keep
|
|
5826
|
+
* polling. Emits `SignIn` or `TwoFactorRequired` as any other sign-in does.
|
|
5827
|
+
*
|
|
5828
|
+
* Aborting rejects with `signal.reason` and keeps the sign-in, so a later call can wait again.
|
|
5829
|
+
* Once the approval has been read, the token exchange finishes regardless of the signal.
|
|
5830
|
+
*
|
|
5831
|
+
* @param challengeId - The `challenge_id` from `passwordlessSignIn`
|
|
5832
|
+
* @param options - Optional `signal` to stop waiting
|
|
5833
|
+
* @returns `signed-in` with the tokens, or `second-factor-required`, `denied`, `expired`, `completed`
|
|
5834
|
+
* @throws When this tab no longer holds the sign-in, on a refused status poll, or on a failed exchange
|
|
5835
|
+
*
|
|
5836
|
+
* @example
|
|
5837
|
+
* ```typescript
|
|
5838
|
+
* const { challenge_id } = await passflow.passwordlessSignIn(payload);
|
|
5839
|
+
* const pending = passflow.getPendingPasswordlessSignIn(challenge_id);
|
|
5840
|
+
* if (pending) {
|
|
5841
|
+
* showCode(pending.matchCode);
|
|
5842
|
+
* const result = await passflow.waitForPasswordlessSignIn(challenge_id);
|
|
5843
|
+
* }
|
|
5844
|
+
* ```
|
|
5845
|
+
*/
|
|
5846
|
+
waitForPasswordlessSignIn(challengeId: string, options?: {
|
|
5847
|
+
signal?: AbortSignal;
|
|
5848
|
+
}): Promise<PasswordlessWaitResult>;
|
|
5849
|
+
/**
|
|
5850
|
+
* The code to show while waiting for approval on another device.
|
|
5851
|
+
*
|
|
5852
|
+
* @param challengeId - The `challenge_id` from `passwordlessSignIn`
|
|
5853
|
+
* @returns The match code and expiry (epoch milliseconds), or `undefined` unless this tab started
|
|
5854
|
+
* that sign-in and it can be approved from another device
|
|
5855
|
+
*/
|
|
5856
|
+
getPendingPasswordlessSignIn(challengeId: string): {
|
|
5857
|
+
matchCode: string;
|
|
5858
|
+
expiresAt: number;
|
|
5859
|
+
} | undefined;
|
|
5860
|
+
/**
|
|
5861
|
+
* Reads what the device that opened a magic link shows before approving: app, requesting browser
|
|
5862
|
+
* and OS, location, time and attempts left. It holds no identity and changes nothing on the server.
|
|
5863
|
+
*
|
|
5864
|
+
* @param challengeId - The `challenge_id` from the link
|
|
5865
|
+
* @returns The approval context
|
|
5866
|
+
* @throws {PassflowError} If the challenge is unknown or cannot be approved
|
|
5867
|
+
*/
|
|
5868
|
+
getPasswordlessApproval(challengeId: string): Promise<PasswordlessApprovalInfo>;
|
|
5869
|
+
/**
|
|
5870
|
+
* Approves or denies a waiting sign-in from the device that opened the magic link. The tab that
|
|
5871
|
+
* started the sign-in finishes it; this device gets no tokens.
|
|
5872
|
+
*
|
|
5873
|
+
* @param challengeId - The `challenge_id` from the link
|
|
5874
|
+
* @param otp - The one-time code from the link
|
|
5875
|
+
* @param approve - `true` to approve, `false` to deny
|
|
5876
|
+
* @param matchCode - The code the user read from the waiting tab. Needed to approve.
|
|
5877
|
+
* @throws {PassflowError} If the code is wrong, the sign-in is expired or already decided
|
|
5878
|
+
*/
|
|
5879
|
+
decidePasswordlessApproval(challengeId: string, otp: string, approve: boolean, matchCode?: string): Promise<void>;
|
|
5596
5880
|
/**
|
|
5597
5881
|
* Finishes a sign-up, sign-in or password change that answered with `email_verification_required`
|
|
5598
5882
|
* and a `challenge_id`, using the code the user received by email. Answers like `signIn`: a new
|
|
@@ -6244,6 +6528,39 @@ export declare class Passflow {
|
|
|
6244
6528
|
* ```
|
|
6245
6529
|
*/
|
|
6246
6530
|
confirmTwoFactorSetup(code: string): Promise<TwoFactorConfirmResponse>;
|
|
6531
|
+
/**
|
|
6532
|
+
* What the sign-in waiting on its second factor can do next. The server decides; read this
|
|
6533
|
+
* before asking for a code, and call `requestChallenge` only on `verify`.
|
|
6534
|
+
*
|
|
6535
|
+
* @returns `verify`: ask for a code. `email_link`: `sendTwoFactorSetupLink`, then the user signs
|
|
6536
|
+
* in again after enrolling. `direct`: `beginTwoFactorEnrollment`, `confirmTwoFactorEnrollment`,
|
|
6537
|
+
* then `verifyTwoFactor`. `unavailable`: tell the user to contact the administrator.
|
|
6538
|
+
* @throws {PassflowError} A 401 means the sign-in is over: sign in again.
|
|
6539
|
+
*/
|
|
6540
|
+
getTwoFactorEnrollment(): Promise<TwoFactorEnrollment>;
|
|
6541
|
+
/**
|
|
6542
|
+
* Email the user a link to set up 2FA, on a sign-in whose enrollment is `email_link`.
|
|
6543
|
+
* The budget is 3 requests in 5 minutes, shared with `requestChallenge`, so limit resends.
|
|
6544
|
+
*
|
|
6545
|
+
* @throws {PassflowError} 503 `error.2fa.setup_link.send_failed` when the email could not be sent
|
|
6546
|
+
*/
|
|
6547
|
+
sendTwoFactorSetupLink(): Promise<TwoFactorSetupLinkResponse>;
|
|
6548
|
+
/**
|
|
6549
|
+
* Begin 2FA setup on the pending sign-in, when its enrollment is `direct`.
|
|
6550
|
+
* Returns a secret and QR code to scan with an authenticator app.
|
|
6551
|
+
*
|
|
6552
|
+
* @throws {PassflowError} 403 `error.2fa.enrollment.not_allowed` in any other state
|
|
6553
|
+
*/
|
|
6554
|
+
beginTwoFactorEnrollment(): Promise<TwoFactorSetupResponse>;
|
|
6555
|
+
/**
|
|
6556
|
+
* Confirm 2FA setup on the pending sign-in. The sign-in stays pending: show the recovery codes,
|
|
6557
|
+
* then `verifyTwoFactor` with the same code finishes it.
|
|
6558
|
+
*
|
|
6559
|
+
* @param code - TOTP code from the authenticator app
|
|
6560
|
+
* @returns Promise with the recovery codes the user must save
|
|
6561
|
+
* @throws {PassflowError} 401 `error.api.request.2fa_code.invalid` on a wrong code
|
|
6562
|
+
*/
|
|
6563
|
+
confirmTwoFactorEnrollment(code: string): Promise<TwoFactorConfirmResponse>;
|
|
6247
6564
|
/**
|
|
6248
6565
|
* Verify a TOTP code during login when 2FA is required.
|
|
6249
6566
|
* Completes the authentication process and saves tokens.
|