@passflow/core 0.22.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 +73 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +263 -3
- package/dist/index.d.ts +263 -3
- package/dist/index.mjs +978 -689
- 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"
|
|
@@ -1419,12 +1474,64 @@ export type AppSettings = {
|
|
|
1419
1474
|
create_tenant_on_registration: 'never' | 'always' | 'optional';
|
|
1420
1475
|
fim_merge_by_email_allowed: boolean;
|
|
1421
1476
|
debug_otp_code_allowed: boolean;
|
|
1422
|
-
|
|
1477
|
+
/**
|
|
1478
|
+
* WRITE-ONLY. Every read and write answer returns it as an empty string; the stored code is
|
|
1479
|
+
* never echoed. On write, a blank or absent value keeps the stored code and a non-blank value
|
|
1480
|
+
* replaces it. The only way to clear it is
|
|
1481
|
+
* `DELETE /admin/apps/{id}/secrets/debug_otp_code_for_registration` (see `AppSecretName`).
|
|
1482
|
+
* Use `debug_otp_code_set` to tell whether a code is stored.
|
|
1483
|
+
*/
|
|
1484
|
+
debug_otp_code_for_registration?: string;
|
|
1485
|
+
/** READ-ONLY. `true` when a `debug_otp_code_for_registration` is stored. Ignored on write. */
|
|
1486
|
+
debug_otp_code_set?: boolean;
|
|
1423
1487
|
defaults: DefaultAppSettings;
|
|
1424
1488
|
login_app_theme: LoginWebAppTheme;
|
|
1425
1489
|
login_app_settings?: unknown;
|
|
1426
1490
|
token_delivery_method?: TokenDeliveryMethod;
|
|
1427
1491
|
};
|
|
1492
|
+
/**
|
|
1493
|
+
* A write-only app secret that the admin API clears by name with
|
|
1494
|
+
* `DELETE /admin/apps/{id}/secrets/{name}`. The SDK has no admin client, so this route is not
|
|
1495
|
+
* wrapped; the names are exported for admin UIs that call it themselves.
|
|
1496
|
+
*
|
|
1497
|
+
* - `debug_otp_code_for_registration`: an `AppSettings` field. Answers return it as an empty
|
|
1498
|
+
* string; `AppSettings.debug_otp_code_set` tells whether one is stored.
|
|
1499
|
+
* - `fcm_server_key`, `webpush_vapid_private_key`: push settings in the app's
|
|
1500
|
+
* `two_factor_settings`. Both are absent from every answer; `webpush_vapid_public_key` is
|
|
1501
|
+
* still returned.
|
|
1502
|
+
*
|
|
1503
|
+
* On write, a blank or absent value keeps the stored secret and a non-blank value replaces it.
|
|
1504
|
+
* DELETE is the only way to clear one. See docs/admin-secrets.md.
|
|
1505
|
+
*/
|
|
1506
|
+
export type AppSecretName = 'debug_otp_code_for_registration' | 'fcm_server_key' | 'webpush_vapid_private_key';
|
|
1507
|
+
/** Every `AppSecretName`, in the order the type lists them. */
|
|
1508
|
+
export declare const APP_SECRET_NAMES: readonly AppSecretName[];
|
|
1509
|
+
/**
|
|
1510
|
+
* A secret in the server settings (`GET`/`PUT /admin/settings`) as the admin API returns it.
|
|
1511
|
+
*
|
|
1512
|
+
* - Secrets come back as `mask://********`.
|
|
1513
|
+
* - Connection strings, dynamo/s3/ssm endpoints, plugin address/cmd, activity-logger endpoints
|
|
1514
|
+
* and management_keys come back as `mask://********` followed by `/` and 16 lowercase
|
|
1515
|
+
* hex characters (e.g. a `/0123456789abcdef` suffix); the suffix tells values apart without
|
|
1516
|
+
* revealing them. (Written in two parts because the full form would end this comment.)
|
|
1517
|
+
*
|
|
1518
|
+
* On `PUT`: echo the masked value unchanged to keep the stored one, send a plain value to
|
|
1519
|
+
* replace it, send an empty string to clear it. A stale or edited masked value fails with
|
|
1520
|
+
* HTTP 400 and id `SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID`. See docs/admin-secrets.md.
|
|
1521
|
+
*/
|
|
1522
|
+
export type MaskedSecret = string;
|
|
1523
|
+
/** The prefix every `MaskedSecret` starts with. */
|
|
1524
|
+
export declare const MASKED_SECRET_PREFIX = "mask://";
|
|
1525
|
+
/**
|
|
1526
|
+
* Error id of the HTTP 400 that `PUT /admin/settings` returns for a masked value the server did
|
|
1527
|
+
* not issue for the stored one (stale or edited).
|
|
1528
|
+
*/
|
|
1529
|
+
export declare const SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID = "error.server.update.settings.masked.value.unknown";
|
|
1530
|
+
/**
|
|
1531
|
+
* Whether a server settings value is a masked secret rather than a plain value: any string that
|
|
1532
|
+
* starts with `MASKED_SECRET_PREFIX`. It does not check that the server would accept it.
|
|
1533
|
+
*/
|
|
1534
|
+
export declare const isMaskedSecret: (value: unknown) => value is MaskedSecret;
|
|
1428
1535
|
export type DefaultAppSettings = {
|
|
1429
1536
|
app_id: string;
|
|
1430
1537
|
redirect: string;
|
|
@@ -1488,6 +1595,8 @@ export type PassflowFederatedAuthPayload = {
|
|
|
1488
1595
|
scopes?: string[];
|
|
1489
1596
|
invite_token?: string;
|
|
1490
1597
|
create_tenant?: boolean;
|
|
1598
|
+
code_challenge?: string;
|
|
1599
|
+
code_challenge_method?: 'S256';
|
|
1491
1600
|
};
|
|
1492
1601
|
export type PassflowFederatedAuthExtendedPayload = PassflowFederatedAuthPayload & {
|
|
1493
1602
|
device?: string;
|
|
@@ -2012,10 +2121,32 @@ export declare class AuthAPI {
|
|
|
2012
2121
|
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField): Promise<PassflowAuthorizationResponse>;
|
|
2013
2122
|
signIn(payload: PassflowSignInPayload, deviceId: string, os: OS): Promise<PassflowAuthorizationResponse>;
|
|
2014
2123
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
2015
|
-
/**
|
|
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
|
+
*/
|
|
2016
2130
|
pkceExchange(code: string, verifier: string): Promise<PassflowAuthorizationResponse>;
|
|
2131
|
+
/** Rejects only with a `PassflowError`, because its body can hold the poll secret. */
|
|
2017
2132
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload, deviceId: string, os: OS): Promise<PassflowPasswordlessResponse>;
|
|
2133
|
+
/** Rejects only with a `PassflowError`, because its body holds the OTP. */
|
|
2018
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>;
|
|
2019
2150
|
/**
|
|
2020
2151
|
* Proves an emailed code for a sign-up, sign-in or password change that answered with
|
|
2021
2152
|
* `email_verification_required`. Only `{challenge_id, otp}` is sent: the server reads the
|
|
@@ -3262,7 +3393,7 @@ export declare enum PassflowEvent {
|
|
|
3262
3393
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
3263
3394
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
3264
3395
|
*/
|
|
3265
|
-
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';
|
|
3266
3397
|
/**
|
|
3267
3398
|
* Error payload interface for structured error information
|
|
3268
3399
|
*/
|
|
@@ -3293,6 +3424,8 @@ type PassflowEventPayload = {
|
|
|
3293
3424
|
parsedTokens?: ParsedTokens;
|
|
3294
3425
|
/** `'other-tab'` only when an ended tab revives on a new session found in storage. Absent on this tab's own sign-in. */
|
|
3295
3426
|
origin?: EventOrigin;
|
|
3427
|
+
/** Set only when a federated redirect landed here and this instance exchanged its code. */
|
|
3428
|
+
source?: 'federated-landing';
|
|
3296
3429
|
};
|
|
3297
3430
|
[PassflowEvent.SignInStart]: {
|
|
3298
3431
|
email?: string;
|
|
@@ -3536,6 +3669,8 @@ export declare class AuthService {
|
|
|
3536
3669
|
private tokenDeliveryManager;
|
|
3537
3670
|
private tokenExchangeConfig?;
|
|
3538
3671
|
private pendingPkce?;
|
|
3672
|
+
private pendingPasswordless?;
|
|
3673
|
+
private federatedSlot?;
|
|
3539
3674
|
/**
|
|
3540
3675
|
* The emailed code challenges this instance produced, by `challenge_id`. Memory only: an id
|
|
3541
3676
|
* this instance does not know (reload, another tab, a recreated instance) finishes as a sign-in.
|
|
@@ -3615,6 +3750,18 @@ export declare class AuthService {
|
|
|
3615
3750
|
hasPendingPkceSignIn(): boolean;
|
|
3616
3751
|
/** Drops the verifier of a pending sign-in. `TwoFactorService` calls this with its own state. */
|
|
3617
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;
|
|
3618
3765
|
/**
|
|
3619
3766
|
* The proof key for a sign-in on a PKCE app, undefined on any other app.
|
|
3620
3767
|
*
|
|
@@ -3651,6 +3798,32 @@ export declare class AuthService {
|
|
|
3651
3798
|
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
3652
3799
|
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
3653
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;
|
|
3654
3827
|
/**
|
|
3655
3828
|
* Finishes a sign-up, sign-in or password change that answered with an emailed code
|
|
3656
3829
|
* (`email_verification_required` with a `challenge_id`): posts the code to `/auth/validate`, then
|
|
@@ -3754,6 +3927,16 @@ export declare class AuthService {
|
|
|
3754
3927
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
3755
3928
|
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload): Promise<void>;
|
|
3756
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;
|
|
3757
3940
|
authRedirectUrl(options?: {
|
|
3758
3941
|
url?: string;
|
|
3759
3942
|
redirectUrl?: string;
|
|
@@ -5135,6 +5318,7 @@ export declare class Passflow {
|
|
|
5135
5318
|
private scopes;
|
|
5136
5319
|
private createTenantForNewUser;
|
|
5137
5320
|
private doRefreshTokens;
|
|
5321
|
+
private deferFederatedLanding;
|
|
5138
5322
|
private deviceService;
|
|
5139
5323
|
private storageManager;
|
|
5140
5324
|
private subscribeStore;
|
|
@@ -5360,9 +5544,28 @@ export declare class Passflow {
|
|
|
5360
5544
|
* // Tokens are automatically saved to storage
|
|
5361
5545
|
* }
|
|
5362
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()`.
|
|
5363
5551
|
*/
|
|
5364
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;
|
|
5365
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;
|
|
5366
5569
|
/**
|
|
5367
5570
|
* Adopts a `#tfa_token=` fragment: the 2FA token goes to the TwoFactorService
|
|
5368
5571
|
* through `TwoFactorRequired`, exactly as a password sign-in's does, and the
|
|
@@ -5541,6 +5744,63 @@ export declare class Passflow {
|
|
|
5541
5744
|
* ```
|
|
5542
5745
|
*/
|
|
5543
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>;
|
|
5544
5804
|
/**
|
|
5545
5805
|
* Finishes a sign-up, sign-in or password change that answered with `email_verification_required`
|
|
5546
5806
|
* and a `challenge_id`, using the code the user received by email. Answers like `signIn`: a new
|