@passflow/core 0.36.1 → 0.37.1
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 +64 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -6
- package/dist/index.d.ts +126 -6
- package/dist/index.mjs +68 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -991,6 +991,7 @@ export declare enum PassflowEndpointPaths {
|
|
|
991
991
|
TwoFactorAlternative = "/v2/auth/2fa/alternative",
|
|
992
992
|
TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices",
|
|
993
993
|
TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id",
|
|
994
|
+
TwoFactorPreferredMethod = "/v2/user/2fa/preferred-method",
|
|
994
995
|
cliAuthStatus = "/cli/auth/status/:sessionId",
|
|
995
996
|
cliAuthComplete = "/cli/auth/complete",
|
|
996
997
|
upgradeStart = "/auth/upgrade/start",
|
|
@@ -2019,6 +2020,11 @@ export type TwoFactorEnrollmentResponse = {
|
|
|
2019
2020
|
* Absent from servers older than the flag; treat absent as unknown.
|
|
2020
2021
|
*/
|
|
2021
2022
|
device_trust_available?: boolean;
|
|
2023
|
+
/**
|
|
2024
|
+
* A masked name of the account signing in: the email, else the phone, else the username.
|
|
2025
|
+
* Absent when the user has none, and from servers that do not send it.
|
|
2026
|
+
*/
|
|
2027
|
+
account_hint?: string;
|
|
2022
2028
|
};
|
|
2023
2029
|
/** POST /auth/2fa/enrollment/email-link */
|
|
2024
2030
|
export type TwoFactorSetupLinkResponse = {
|
|
@@ -2068,6 +2074,11 @@ export type TwoFactorTrustedDevice = {
|
|
|
2068
2074
|
export type TwoFactorTrustedDevicesResponse = {
|
|
2069
2075
|
devices: TwoFactorTrustedDevice[];
|
|
2070
2076
|
};
|
|
2077
|
+
/** GET, PUT and DELETE /v2/user/2fa/preferred-method */
|
|
2078
|
+
export type TwoFactorPreferredMethodResponse = {
|
|
2079
|
+
/** `null` when the user has no preference this app can use now. */
|
|
2080
|
+
preferred_method: TwoFactorMethod | null;
|
|
2081
|
+
};
|
|
2071
2082
|
export type TwoFactorRecoveryResponse = Tokens & {
|
|
2072
2083
|
success?: true;
|
|
2073
2084
|
/** Codes left after this one. The server may leave it out. */
|
|
@@ -2103,6 +2114,11 @@ export type TwoFactorSetupMagicLinkValidationResponse = {
|
|
|
2103
2114
|
userId?: string;
|
|
2104
2115
|
expiresIn?: number;
|
|
2105
2116
|
appId?: string | null;
|
|
2117
|
+
/**
|
|
2118
|
+
* On a success: `true` for a link an administrator sent to replace an enrolled authenticator.
|
|
2119
|
+
* Its session replaces that authenticator once, when setup begins, without a code.
|
|
2120
|
+
*/
|
|
2121
|
+
reset?: boolean;
|
|
2106
2122
|
error?: TwoFactorSetupMagicLinkError;
|
|
2107
2123
|
};
|
|
2108
2124
|
/**
|
|
@@ -2114,6 +2130,8 @@ export type TwoFactorSetupMagicLinkSession = {
|
|
|
2114
2130
|
userId: string;
|
|
2115
2131
|
appId?: string | null;
|
|
2116
2132
|
scope: '2fa_setup';
|
|
2133
|
+
/** `true` when the link replaces an enrolled authenticator. The SDK always sets it. */
|
|
2134
|
+
reset?: boolean;
|
|
2117
2135
|
timestamp: number;
|
|
2118
2136
|
expiresAt: number;
|
|
2119
2137
|
};
|
|
@@ -2134,7 +2152,13 @@ export interface TwoFactorChallengeRequest {
|
|
|
2134
2152
|
export interface TwoFactorChallengeResponse {
|
|
2135
2153
|
challenge_id: string;
|
|
2136
2154
|
method: TwoFactorMethod;
|
|
2137
|
-
/**
|
|
2155
|
+
/**
|
|
2156
|
+
* The method login offers first. From `requestChallenge` it equals `method`; from
|
|
2157
|
+
* `switchToAlternative` it stays the suggestion while `method` is the one the user chose.
|
|
2158
|
+
* Absent from servers that do not send it.
|
|
2159
|
+
*/
|
|
2160
|
+
suggested_method?: TwoFactorMethod;
|
|
2161
|
+
/** Other methods the user can switch to. Absent when there are none. */
|
|
2138
2162
|
alternative_methods?: TwoFactorMethod[];
|
|
2139
2163
|
expires_at: string;
|
|
2140
2164
|
code_sent_to?: string;
|
|
@@ -2148,6 +2172,11 @@ export interface TwoFactorChallengeResponse {
|
|
|
2148
2172
|
* Absent from servers older than the flag; treat absent as unknown.
|
|
2149
2173
|
*/
|
|
2150
2174
|
device_trust_available?: boolean;
|
|
2175
|
+
/**
|
|
2176
|
+
* A masked name of the account signing in: the email, else the phone, else the username.
|
|
2177
|
+
* Absent when the user has none, and from servers that do not send it.
|
|
2178
|
+
*/
|
|
2179
|
+
account_hint?: string;
|
|
2151
2180
|
}
|
|
2152
2181
|
/**
|
|
2153
2182
|
* Verify Request for v2 2FA flow
|
|
@@ -2179,6 +2208,11 @@ export interface RegisteredTwoFactorMethod {
|
|
|
2179
2208
|
app_id?: string;
|
|
2180
2209
|
/** `true` when this passkey also signs the user in as the first factor. */
|
|
2181
2210
|
is_passkey_for_1fa?: boolean;
|
|
2211
|
+
/**
|
|
2212
|
+
* `true` on the user's preferred method, on at most one item. Absent from servers that do not
|
|
2213
|
+
* send it.
|
|
2214
|
+
*/
|
|
2215
|
+
preferred?: boolean;
|
|
2182
2216
|
created_at?: string;
|
|
2183
2217
|
updated_at?: string;
|
|
2184
2218
|
last_used_at?: string;
|
|
@@ -2288,7 +2322,7 @@ export declare enum PassflowEvent {
|
|
|
2288
2322
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
2289
2323
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
2290
2324
|
*/
|
|
2291
|
-
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' | 'enterprise.resolve' | 'enterprise.start' | 'auth-redirect.url' | 'auth-redirect' | 'redirect.check' | 'auth.is-authenticated' | 'session.check' | 'session.list' | 'session.revoke' | 'session.revoke-others' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'oidc.redirect' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'anti-bot.token' | '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';
|
|
2325
|
+
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' | 'enterprise.resolve' | 'enterprise.start' | 'auth-redirect.url' | 'auth-redirect' | 'redirect.check' | 'auth.is-authenticated' | 'session.check' | 'session.list' | 'session.revoke' | 'session.revoke-others' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'oidc.redirect' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'anti-bot.token' | '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' | '2fa.preferred-method.read' | '2fa.preferred-method.set' | '2fa.preferred-method.clear';
|
|
2292
2326
|
/**
|
|
2293
2327
|
* Error payload interface for structured error information
|
|
2294
2328
|
*/
|
|
@@ -2413,6 +2447,8 @@ type PassflowEventPayload = {
|
|
|
2413
2447
|
appId?: string | null;
|
|
2414
2448
|
expiresIn: number;
|
|
2415
2449
|
sessionToken: string;
|
|
2450
|
+
/** `true` when the link replaces an enrolled authenticator. The SDK always sets it. */
|
|
2451
|
+
reset?: boolean;
|
|
2416
2452
|
};
|
|
2417
2453
|
[PassflowEvent.TwoFactorSetupMagicLinkFailed]: {
|
|
2418
2454
|
error: {
|
|
@@ -3337,6 +3373,25 @@ export declare class TwoFactorApiClient {
|
|
|
3337
3373
|
* The server answers 404 when the user has no such device.
|
|
3338
3374
|
*/
|
|
3339
3375
|
revokeTrustedDevice(deviceId: string): Promise<void>;
|
|
3376
|
+
/**
|
|
3377
|
+
* Get the user's preferred 2FA method
|
|
3378
|
+
* GET /v2/user/2fa/preferred-method
|
|
3379
|
+
* `null` when the user has no preference this app can use now.
|
|
3380
|
+
*/
|
|
3381
|
+
getPreferredMethod(): Promise<TwoFactorMethod | null>;
|
|
3382
|
+
/**
|
|
3383
|
+
* Set the user's preferred 2FA method
|
|
3384
|
+
* PUT /v2/user/2fa/preferred-method
|
|
3385
|
+
* Answers the stored method. The server refuses `recovery_codes` and a method the user
|
|
3386
|
+
* cannot present at this app with 400 `error.2fa.preferred_method.unavailable`.
|
|
3387
|
+
*/
|
|
3388
|
+
setPreferredMethod(method: TwoFactorMethod): Promise<TwoFactorMethod>;
|
|
3389
|
+
/**
|
|
3390
|
+
* Clear the user's preferred 2FA method
|
|
3391
|
+
* DELETE /v2/user/2fa/preferred-method
|
|
3392
|
+
* No error when none is stored.
|
|
3393
|
+
*/
|
|
3394
|
+
clearPreferredMethod(): Promise<void>;
|
|
3340
3395
|
}
|
|
3341
3396
|
/** The `POST /auth/upgrade/start` request body. `relying_party_id` is passkey-only. */
|
|
3342
3397
|
export type UpgradeStartPayload = {
|
|
@@ -5165,6 +5220,21 @@ export declare class TwoFactorService {
|
|
|
5165
5220
|
* Rejects with the server's 404 when the user has no such device.
|
|
5166
5221
|
*/
|
|
5167
5222
|
revokeTrustedDevice(deviceId: string): Promise<void>;
|
|
5223
|
+
/**
|
|
5224
|
+
* The method the user prefers as their second factor on this app, or `null` when there is
|
|
5225
|
+
* none the app can use now.
|
|
5226
|
+
*/
|
|
5227
|
+
getPreferredMethod(): Promise<TwoFactorMethod | null>;
|
|
5228
|
+
/**
|
|
5229
|
+
* Store the user's preferred second factor; resolves the method the server stored.
|
|
5230
|
+
* Rejects with the server's 400 `error.2fa.preferred_method.unavailable` for `recovery_codes`
|
|
5231
|
+
* and for a method the user cannot present at this app.
|
|
5232
|
+
*/
|
|
5233
|
+
setPreferredMethod(method: TwoFactorMethod): Promise<TwoFactorMethod>;
|
|
5234
|
+
/**
|
|
5235
|
+
* Remove the user's preferred second factor. Resolves also when none was stored.
|
|
5236
|
+
*/
|
|
5237
|
+
clearPreferredMethod(): Promise<void>;
|
|
5168
5238
|
}
|
|
5169
5239
|
/**
|
|
5170
5240
|
* Service for managing user profile, passkeys and sessions
|
|
@@ -5813,13 +5883,16 @@ export declare const UpgradeErrorIds: {
|
|
|
5813
5883
|
readonly twoFactorNotEnabled: 'error.2fa.not_enabled';
|
|
5814
5884
|
readonly notImplemented: 'error.not.implemented';
|
|
5815
5885
|
readonly tokenInvalid: 'error.api.request.token.invalid';
|
|
5886
|
+
readonly grantPredatesCredentialReset: 'error.grant.predates_credential_reset';
|
|
5887
|
+
readonly tokenAccessEnded: 'error.token.access_ended';
|
|
5888
|
+
readonly userNotFound: 'error.user.not_found';
|
|
5816
5889
|
};
|
|
5817
5890
|
/**
|
|
5818
|
-
*
|
|
5819
|
-
*
|
|
5891
|
+
* The errors `refreshErrorStatus` (`src/web/api/refresh_token.go`) maps to a 401 on the commit
|
|
5892
|
+
* path that are the upgrade protocol talking. The same function answers 401 for three more ids,
|
|
5893
|
+
* which end the session: see `SESSION_INVALIDATING_COMMIT_ERROR_IDS`.
|
|
5820
5894
|
*
|
|
5821
|
-
* All five are "recoverable" in the session sense:
|
|
5822
|
-
* upgrade protocol talking, so none of them means the session died. Note that
|
|
5895
|
+
* All five are "recoverable" in the session sense: none of them means the session died. Note that
|
|
5823
5896
|
* `challenge_too_many_attempts` is in here yet is NOT retryable — it ends the
|
|
5824
5897
|
* elevation while leaving the session intact. The two axes are independent and
|
|
5825
5898
|
* are deliberately not collapsed.
|
|
@@ -5843,6 +5916,13 @@ export declare const RECOVERABLE_COMMIT_ERROR_IDS: readonly string[];
|
|
|
5843
5916
|
* feature's governing rule. A client-side miss costs a stale session that the
|
|
5844
5917
|
* next ordinary 401 clears; a false positive costs the user their session in
|
|
5845
5918
|
* the middle of proving who they are.
|
|
5919
|
+
*
|
|
5920
|
+
* Besides the invalid token, the server answers 401 on the commit path for three ids that end the
|
|
5921
|
+
* session: a session from before a credential reset, a token from before the user's access was
|
|
5922
|
+
* ended, and a user who is gone. After each of them the user signs in again.
|
|
5923
|
+
*
|
|
5924
|
+
* Invalidating sets the stored session state. Cookie mode reads it (`isAuthenticated()` turns
|
|
5925
|
+
* false); JSON mode does not, and there the tokens stay until the next refresh fails.
|
|
5846
5926
|
*/
|
|
5847
5927
|
export declare const SESSION_INVALIDATING_COMMIT_ERROR_IDS: readonly string[];
|
|
5848
5928
|
/** True when a kind leaves the elevation alive. Single source for `retryable`. */
|
|
@@ -7576,6 +7656,45 @@ export declare class Passflow {
|
|
|
7576
7656
|
* ```
|
|
7577
7657
|
*/
|
|
7578
7658
|
revokeTrustedDevice(id: string): Promise<void>;
|
|
7659
|
+
/**
|
|
7660
|
+
* Read the second factor the signed-in user prefers on this app.
|
|
7661
|
+
*
|
|
7662
|
+
* @returns Promise with the method, or `null` when the user has no preference the app can use now
|
|
7663
|
+
* @throws {PassflowError} If the request fails
|
|
7664
|
+
*
|
|
7665
|
+
* @example
|
|
7666
|
+
* ```typescript
|
|
7667
|
+
* const preferred = await passflow.getPreferredTwoFactorMethod();
|
|
7668
|
+
* console.log(preferred ?? 'no preferred method');
|
|
7669
|
+
* ```
|
|
7670
|
+
*/
|
|
7671
|
+
getPreferredTwoFactorMethod(): Promise<TwoFactorMethod | null>;
|
|
7672
|
+
/**
|
|
7673
|
+
* Store the second factor the signed-in user prefers on this app. Sign-in then offers it first.
|
|
7674
|
+
*
|
|
7675
|
+
* @param method - A method the user can present at this app; not `recovery_codes`
|
|
7676
|
+
* @returns Promise with the method the server stored
|
|
7677
|
+
* @throws {PassflowError} If the request fails, including a 400
|
|
7678
|
+
* `error.2fa.preferred_method.unavailable` for `recovery_codes`, an unknown method, or one the
|
|
7679
|
+
* user cannot present at this app
|
|
7680
|
+
*
|
|
7681
|
+
* @example
|
|
7682
|
+
* ```typescript
|
|
7683
|
+
* await passflow.setPreferredTwoFactorMethod('totp');
|
|
7684
|
+
* ```
|
|
7685
|
+
*/
|
|
7686
|
+
setPreferredTwoFactorMethod(method: TwoFactorMethod): Promise<TwoFactorMethod>;
|
|
7687
|
+
/**
|
|
7688
|
+
* Remove the signed-in user's preferred second factor. Resolves also when none was stored.
|
|
7689
|
+
*
|
|
7690
|
+
* @throws {PassflowError} If the request fails
|
|
7691
|
+
*
|
|
7692
|
+
* @example
|
|
7693
|
+
* ```typescript
|
|
7694
|
+
* await passflow.clearPreferredTwoFactorMethod();
|
|
7695
|
+
* ```
|
|
7696
|
+
*/
|
|
7697
|
+
clearPreferredTwoFactorMethod(): Promise<void>;
|
|
7579
7698
|
/**
|
|
7580
7699
|
* Check if 2FA verification is currently required (local state check).
|
|
7581
7700
|
* Returns true if user has signed in but needs to complete 2FA verification.
|
|
@@ -7622,6 +7741,7 @@ export declare class Passflow {
|
|
|
7622
7741
|
* console.log('Magic link validated');
|
|
7623
7742
|
* console.log('User ID:', result.userId);
|
|
7624
7743
|
* console.log('Session expires in:', result.expiresIn, 'seconds');
|
|
7744
|
+
* console.log('Replaces an enrolled authenticator:', result.reset);
|
|
7625
7745
|
* // Show 2FA setup form
|
|
7626
7746
|
* } else {
|
|
7627
7747
|
* console.error('Validation failed:', result.error?.message);
|
package/dist/index.d.ts
CHANGED
|
@@ -991,6 +991,7 @@ export declare enum PassflowEndpointPaths {
|
|
|
991
991
|
TwoFactorAlternative = "/v2/auth/2fa/alternative",
|
|
992
992
|
TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices",
|
|
993
993
|
TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id",
|
|
994
|
+
TwoFactorPreferredMethod = "/v2/user/2fa/preferred-method",
|
|
994
995
|
cliAuthStatus = "/cli/auth/status/:sessionId",
|
|
995
996
|
cliAuthComplete = "/cli/auth/complete",
|
|
996
997
|
upgradeStart = "/auth/upgrade/start",
|
|
@@ -2019,6 +2020,11 @@ export type TwoFactorEnrollmentResponse = {
|
|
|
2019
2020
|
* Absent from servers older than the flag; treat absent as unknown.
|
|
2020
2021
|
*/
|
|
2021
2022
|
device_trust_available?: boolean;
|
|
2023
|
+
/**
|
|
2024
|
+
* A masked name of the account signing in: the email, else the phone, else the username.
|
|
2025
|
+
* Absent when the user has none, and from servers that do not send it.
|
|
2026
|
+
*/
|
|
2027
|
+
account_hint?: string;
|
|
2022
2028
|
};
|
|
2023
2029
|
/** POST /auth/2fa/enrollment/email-link */
|
|
2024
2030
|
export type TwoFactorSetupLinkResponse = {
|
|
@@ -2068,6 +2074,11 @@ export type TwoFactorTrustedDevice = {
|
|
|
2068
2074
|
export type TwoFactorTrustedDevicesResponse = {
|
|
2069
2075
|
devices: TwoFactorTrustedDevice[];
|
|
2070
2076
|
};
|
|
2077
|
+
/** GET, PUT and DELETE /v2/user/2fa/preferred-method */
|
|
2078
|
+
export type TwoFactorPreferredMethodResponse = {
|
|
2079
|
+
/** `null` when the user has no preference this app can use now. */
|
|
2080
|
+
preferred_method: TwoFactorMethod | null;
|
|
2081
|
+
};
|
|
2071
2082
|
export type TwoFactorRecoveryResponse = Tokens & {
|
|
2072
2083
|
success?: true;
|
|
2073
2084
|
/** Codes left after this one. The server may leave it out. */
|
|
@@ -2103,6 +2114,11 @@ export type TwoFactorSetupMagicLinkValidationResponse = {
|
|
|
2103
2114
|
userId?: string;
|
|
2104
2115
|
expiresIn?: number;
|
|
2105
2116
|
appId?: string | null;
|
|
2117
|
+
/**
|
|
2118
|
+
* On a success: `true` for a link an administrator sent to replace an enrolled authenticator.
|
|
2119
|
+
* Its session replaces that authenticator once, when setup begins, without a code.
|
|
2120
|
+
*/
|
|
2121
|
+
reset?: boolean;
|
|
2106
2122
|
error?: TwoFactorSetupMagicLinkError;
|
|
2107
2123
|
};
|
|
2108
2124
|
/**
|
|
@@ -2114,6 +2130,8 @@ export type TwoFactorSetupMagicLinkSession = {
|
|
|
2114
2130
|
userId: string;
|
|
2115
2131
|
appId?: string | null;
|
|
2116
2132
|
scope: '2fa_setup';
|
|
2133
|
+
/** `true` when the link replaces an enrolled authenticator. The SDK always sets it. */
|
|
2134
|
+
reset?: boolean;
|
|
2117
2135
|
timestamp: number;
|
|
2118
2136
|
expiresAt: number;
|
|
2119
2137
|
};
|
|
@@ -2134,7 +2152,13 @@ export interface TwoFactorChallengeRequest {
|
|
|
2134
2152
|
export interface TwoFactorChallengeResponse {
|
|
2135
2153
|
challenge_id: string;
|
|
2136
2154
|
method: TwoFactorMethod;
|
|
2137
|
-
/**
|
|
2155
|
+
/**
|
|
2156
|
+
* The method login offers first. From `requestChallenge` it equals `method`; from
|
|
2157
|
+
* `switchToAlternative` it stays the suggestion while `method` is the one the user chose.
|
|
2158
|
+
* Absent from servers that do not send it.
|
|
2159
|
+
*/
|
|
2160
|
+
suggested_method?: TwoFactorMethod;
|
|
2161
|
+
/** Other methods the user can switch to. Absent when there are none. */
|
|
2138
2162
|
alternative_methods?: TwoFactorMethod[];
|
|
2139
2163
|
expires_at: string;
|
|
2140
2164
|
code_sent_to?: string;
|
|
@@ -2148,6 +2172,11 @@ export interface TwoFactorChallengeResponse {
|
|
|
2148
2172
|
* Absent from servers older than the flag; treat absent as unknown.
|
|
2149
2173
|
*/
|
|
2150
2174
|
device_trust_available?: boolean;
|
|
2175
|
+
/**
|
|
2176
|
+
* A masked name of the account signing in: the email, else the phone, else the username.
|
|
2177
|
+
* Absent when the user has none, and from servers that do not send it.
|
|
2178
|
+
*/
|
|
2179
|
+
account_hint?: string;
|
|
2151
2180
|
}
|
|
2152
2181
|
/**
|
|
2153
2182
|
* Verify Request for v2 2FA flow
|
|
@@ -2179,6 +2208,11 @@ export interface RegisteredTwoFactorMethod {
|
|
|
2179
2208
|
app_id?: string;
|
|
2180
2209
|
/** `true` when this passkey also signs the user in as the first factor. */
|
|
2181
2210
|
is_passkey_for_1fa?: boolean;
|
|
2211
|
+
/**
|
|
2212
|
+
* `true` on the user's preferred method, on at most one item. Absent from servers that do not
|
|
2213
|
+
* send it.
|
|
2214
|
+
*/
|
|
2215
|
+
preferred?: boolean;
|
|
2182
2216
|
created_at?: string;
|
|
2183
2217
|
updated_at?: string;
|
|
2184
2218
|
last_used_at?: string;
|
|
@@ -2288,7 +2322,7 @@ export declare enum PassflowEvent {
|
|
|
2288
2322
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
2289
2323
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
2290
2324
|
*/
|
|
2291
|
-
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' | 'enterprise.resolve' | 'enterprise.start' | 'auth-redirect.url' | 'auth-redirect' | 'redirect.check' | 'auth.is-authenticated' | 'session.check' | 'session.list' | 'session.revoke' | 'session.revoke-others' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'oidc.redirect' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'anti-bot.token' | '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';
|
|
2325
|
+
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' | 'enterprise.resolve' | 'enterprise.start' | 'auth-redirect.url' | 'auth-redirect' | 'redirect.check' | 'auth.is-authenticated' | 'session.check' | 'session.list' | 'session.revoke' | 'session.revoke-others' | 'tokens.get' | 'tokens.load' | 'tokens.from-url' | 'oidc.redirect' | 'refresh' | 'upgrade.commit' | 'log-out' | 'reset' | 'anti-bot.token' | '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' | '2fa.preferred-method.read' | '2fa.preferred-method.set' | '2fa.preferred-method.clear';
|
|
2292
2326
|
/**
|
|
2293
2327
|
* Error payload interface for structured error information
|
|
2294
2328
|
*/
|
|
@@ -2413,6 +2447,8 @@ type PassflowEventPayload = {
|
|
|
2413
2447
|
appId?: string | null;
|
|
2414
2448
|
expiresIn: number;
|
|
2415
2449
|
sessionToken: string;
|
|
2450
|
+
/** `true` when the link replaces an enrolled authenticator. The SDK always sets it. */
|
|
2451
|
+
reset?: boolean;
|
|
2416
2452
|
};
|
|
2417
2453
|
[PassflowEvent.TwoFactorSetupMagicLinkFailed]: {
|
|
2418
2454
|
error: {
|
|
@@ -3337,6 +3373,25 @@ export declare class TwoFactorApiClient {
|
|
|
3337
3373
|
* The server answers 404 when the user has no such device.
|
|
3338
3374
|
*/
|
|
3339
3375
|
revokeTrustedDevice(deviceId: string): Promise<void>;
|
|
3376
|
+
/**
|
|
3377
|
+
* Get the user's preferred 2FA method
|
|
3378
|
+
* GET /v2/user/2fa/preferred-method
|
|
3379
|
+
* `null` when the user has no preference this app can use now.
|
|
3380
|
+
*/
|
|
3381
|
+
getPreferredMethod(): Promise<TwoFactorMethod | null>;
|
|
3382
|
+
/**
|
|
3383
|
+
* Set the user's preferred 2FA method
|
|
3384
|
+
* PUT /v2/user/2fa/preferred-method
|
|
3385
|
+
* Answers the stored method. The server refuses `recovery_codes` and a method the user
|
|
3386
|
+
* cannot present at this app with 400 `error.2fa.preferred_method.unavailable`.
|
|
3387
|
+
*/
|
|
3388
|
+
setPreferredMethod(method: TwoFactorMethod): Promise<TwoFactorMethod>;
|
|
3389
|
+
/**
|
|
3390
|
+
* Clear the user's preferred 2FA method
|
|
3391
|
+
* DELETE /v2/user/2fa/preferred-method
|
|
3392
|
+
* No error when none is stored.
|
|
3393
|
+
*/
|
|
3394
|
+
clearPreferredMethod(): Promise<void>;
|
|
3340
3395
|
}
|
|
3341
3396
|
/** The `POST /auth/upgrade/start` request body. `relying_party_id` is passkey-only. */
|
|
3342
3397
|
export type UpgradeStartPayload = {
|
|
@@ -5165,6 +5220,21 @@ export declare class TwoFactorService {
|
|
|
5165
5220
|
* Rejects with the server's 404 when the user has no such device.
|
|
5166
5221
|
*/
|
|
5167
5222
|
revokeTrustedDevice(deviceId: string): Promise<void>;
|
|
5223
|
+
/**
|
|
5224
|
+
* The method the user prefers as their second factor on this app, or `null` when there is
|
|
5225
|
+
* none the app can use now.
|
|
5226
|
+
*/
|
|
5227
|
+
getPreferredMethod(): Promise<TwoFactorMethod | null>;
|
|
5228
|
+
/**
|
|
5229
|
+
* Store the user's preferred second factor; resolves the method the server stored.
|
|
5230
|
+
* Rejects with the server's 400 `error.2fa.preferred_method.unavailable` for `recovery_codes`
|
|
5231
|
+
* and for a method the user cannot present at this app.
|
|
5232
|
+
*/
|
|
5233
|
+
setPreferredMethod(method: TwoFactorMethod): Promise<TwoFactorMethod>;
|
|
5234
|
+
/**
|
|
5235
|
+
* Remove the user's preferred second factor. Resolves also when none was stored.
|
|
5236
|
+
*/
|
|
5237
|
+
clearPreferredMethod(): Promise<void>;
|
|
5168
5238
|
}
|
|
5169
5239
|
/**
|
|
5170
5240
|
* Service for managing user profile, passkeys and sessions
|
|
@@ -5813,13 +5883,16 @@ export declare const UpgradeErrorIds: {
|
|
|
5813
5883
|
readonly twoFactorNotEnabled: 'error.2fa.not_enabled';
|
|
5814
5884
|
readonly notImplemented: 'error.not.implemented';
|
|
5815
5885
|
readonly tokenInvalid: 'error.api.request.token.invalid';
|
|
5886
|
+
readonly grantPredatesCredentialReset: 'error.grant.predates_credential_reset';
|
|
5887
|
+
readonly tokenAccessEnded: 'error.token.access_ended';
|
|
5888
|
+
readonly userNotFound: 'error.user.not_found';
|
|
5816
5889
|
};
|
|
5817
5890
|
/**
|
|
5818
|
-
*
|
|
5819
|
-
*
|
|
5891
|
+
* The errors `refreshErrorStatus` (`src/web/api/refresh_token.go`) maps to a 401 on the commit
|
|
5892
|
+
* path that are the upgrade protocol talking. The same function answers 401 for three more ids,
|
|
5893
|
+
* which end the session: see `SESSION_INVALIDATING_COMMIT_ERROR_IDS`.
|
|
5820
5894
|
*
|
|
5821
|
-
* All five are "recoverable" in the session sense:
|
|
5822
|
-
* upgrade protocol talking, so none of them means the session died. Note that
|
|
5895
|
+
* All five are "recoverable" in the session sense: none of them means the session died. Note that
|
|
5823
5896
|
* `challenge_too_many_attempts` is in here yet is NOT retryable — it ends the
|
|
5824
5897
|
* elevation while leaving the session intact. The two axes are independent and
|
|
5825
5898
|
* are deliberately not collapsed.
|
|
@@ -5843,6 +5916,13 @@ export declare const RECOVERABLE_COMMIT_ERROR_IDS: readonly string[];
|
|
|
5843
5916
|
* feature's governing rule. A client-side miss costs a stale session that the
|
|
5844
5917
|
* next ordinary 401 clears; a false positive costs the user their session in
|
|
5845
5918
|
* the middle of proving who they are.
|
|
5919
|
+
*
|
|
5920
|
+
* Besides the invalid token, the server answers 401 on the commit path for three ids that end the
|
|
5921
|
+
* session: a session from before a credential reset, a token from before the user's access was
|
|
5922
|
+
* ended, and a user who is gone. After each of them the user signs in again.
|
|
5923
|
+
*
|
|
5924
|
+
* Invalidating sets the stored session state. Cookie mode reads it (`isAuthenticated()` turns
|
|
5925
|
+
* false); JSON mode does not, and there the tokens stay until the next refresh fails.
|
|
5846
5926
|
*/
|
|
5847
5927
|
export declare const SESSION_INVALIDATING_COMMIT_ERROR_IDS: readonly string[];
|
|
5848
5928
|
/** True when a kind leaves the elevation alive. Single source for `retryable`. */
|
|
@@ -7576,6 +7656,45 @@ export declare class Passflow {
|
|
|
7576
7656
|
* ```
|
|
7577
7657
|
*/
|
|
7578
7658
|
revokeTrustedDevice(id: string): Promise<void>;
|
|
7659
|
+
/**
|
|
7660
|
+
* Read the second factor the signed-in user prefers on this app.
|
|
7661
|
+
*
|
|
7662
|
+
* @returns Promise with the method, or `null` when the user has no preference the app can use now
|
|
7663
|
+
* @throws {PassflowError} If the request fails
|
|
7664
|
+
*
|
|
7665
|
+
* @example
|
|
7666
|
+
* ```typescript
|
|
7667
|
+
* const preferred = await passflow.getPreferredTwoFactorMethod();
|
|
7668
|
+
* console.log(preferred ?? 'no preferred method');
|
|
7669
|
+
* ```
|
|
7670
|
+
*/
|
|
7671
|
+
getPreferredTwoFactorMethod(): Promise<TwoFactorMethod | null>;
|
|
7672
|
+
/**
|
|
7673
|
+
* Store the second factor the signed-in user prefers on this app. Sign-in then offers it first.
|
|
7674
|
+
*
|
|
7675
|
+
* @param method - A method the user can present at this app; not `recovery_codes`
|
|
7676
|
+
* @returns Promise with the method the server stored
|
|
7677
|
+
* @throws {PassflowError} If the request fails, including a 400
|
|
7678
|
+
* `error.2fa.preferred_method.unavailable` for `recovery_codes`, an unknown method, or one the
|
|
7679
|
+
* user cannot present at this app
|
|
7680
|
+
*
|
|
7681
|
+
* @example
|
|
7682
|
+
* ```typescript
|
|
7683
|
+
* await passflow.setPreferredTwoFactorMethod('totp');
|
|
7684
|
+
* ```
|
|
7685
|
+
*/
|
|
7686
|
+
setPreferredTwoFactorMethod(method: TwoFactorMethod): Promise<TwoFactorMethod>;
|
|
7687
|
+
/**
|
|
7688
|
+
* Remove the signed-in user's preferred second factor. Resolves also when none was stored.
|
|
7689
|
+
*
|
|
7690
|
+
* @throws {PassflowError} If the request fails
|
|
7691
|
+
*
|
|
7692
|
+
* @example
|
|
7693
|
+
* ```typescript
|
|
7694
|
+
* await passflow.clearPreferredTwoFactorMethod();
|
|
7695
|
+
* ```
|
|
7696
|
+
*/
|
|
7697
|
+
clearPreferredTwoFactorMethod(): Promise<void>;
|
|
7579
7698
|
/**
|
|
7580
7699
|
* Check if 2FA verification is currently required (local state check).
|
|
7581
7700
|
* Returns true if user has signed in but needs to complete 2FA verification.
|
|
@@ -7622,6 +7741,7 @@ export declare class Passflow {
|
|
|
7622
7741
|
* console.log('Magic link validated');
|
|
7623
7742
|
* console.log('User ID:', result.userId);
|
|
7624
7743
|
* console.log('Session expires in:', result.expiresIn, 'seconds');
|
|
7744
|
+
* console.log('Replaces an enrolled authenticator:', result.reset);
|
|
7625
7745
|
* // Show 2FA setup form
|
|
7626
7746
|
* } else {
|
|
7627
7747
|
* console.error('Validation failed:', result.error?.message);
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var i = "__passflowAntiBot", a = (e, t) => {
|
|
|
11
11
|
if (typeof e != "object" || !e) return;
|
|
12
12
|
let t = e[i];
|
|
13
13
|
return typeof t == "object" && t ? t : void 0;
|
|
14
|
-
}, s = "0.
|
|
14
|
+
}, s = "0.37.1", c = "X-Passflow-Clientid", l = "Authorization", u = "X-Passflow-DeviceId", d = "X-Passflow-DeviceType", f = "X-Passflow-Anti-Bot", p = "X-Passflow-Agent-Tool", m = "passflow_auth", h = s, g = [
|
|
15
15
|
"id",
|
|
16
16
|
"offline",
|
|
17
17
|
"openid"
|
|
@@ -675,7 +675,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
675
675
|
}), Le = (e) => Ne(e, Me), Re = /* @__PURE__ */ function(e) {
|
|
676
676
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
677
677
|
}({}), z = /* @__PURE__ */ function(e) {
|
|
678
|
-
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.redirectCheck = "/auth/redirect/check", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.userSessions = "/user/sessions", e.userSessionsRevokeOthers = "/user/sessions/revoke-others", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e.hostedUpgradeStart = "/auth/session/upgrade/start", e.hostedUpgrade = "/auth/session/upgrade", e.antiBotChallenge = "/auth/anti-bot/challenge", e.deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge", e.enterpriseResolve = "/auth/enterprise/resolve", e.enterpriseStart = "/auth/enterprise/start", e;
|
|
678
|
+
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.redirectCheck = "/auth/redirect/check", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.userSessions = "/user/sessions", e.userSessionsRevokeOthers = "/user/sessions/revoke-others", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.TwoFactorPreferredMethod = "/v2/user/2fa/preferred-method", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e.hostedUpgradeStart = "/auth/session/upgrade/start", e.hostedUpgrade = "/auth/session/upgrade", e.antiBotChallenge = "/auth/anti-bot/challenge", e.deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge", e.enterpriseResolve = "/auth/enterprise/resolve", e.enterpriseStart = "/auth/enterprise/start", e;
|
|
679
679
|
}({}), ze = /* @__PURE__ */ function(e) {
|
|
680
680
|
return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
|
|
681
681
|
}({}), Be = (e) => {
|
|
@@ -1405,7 +1405,8 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1405
1405
|
sessionToken: t.session_token,
|
|
1406
1406
|
userId: t.user_id,
|
|
1407
1407
|
expiresIn: t.expires_in,
|
|
1408
|
-
appId: t.app_id
|
|
1408
|
+
appId: t.app_id,
|
|
1409
|
+
reset: t.reset === !0
|
|
1409
1410
|
};
|
|
1410
1411
|
}).catch((e) => {
|
|
1411
1412
|
if (e instanceof B) return {
|
|
@@ -1495,6 +1496,15 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1495
1496
|
let t = lt(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1496
1497
|
return this.axiosClient.delete(t);
|
|
1497
1498
|
}
|
|
1499
|
+
async getPreferredMethod() {
|
|
1500
|
+
return (await this.axiosClient.get(z.TwoFactorPreferredMethod))?.preferred_method ?? null;
|
|
1501
|
+
}
|
|
1502
|
+
async setPreferredMethod(e) {
|
|
1503
|
+
return (await this.axiosClient.put(z.TwoFactorPreferredMethod, { method: e }))?.preferred_method ?? e;
|
|
1504
|
+
}
|
|
1505
|
+
async clearPreferredMethod() {
|
|
1506
|
+
await this.axiosClient.delete(z.TwoFactorPreferredMethod);
|
|
1507
|
+
}
|
|
1498
1508
|
}, Kt = class {
|
|
1499
1509
|
constructor(e, t, n) {
|
|
1500
1510
|
this.axiosClient = new Ot(e, t, n);
|
|
@@ -3940,14 +3950,22 @@ var Q = {
|
|
|
3940
3950
|
methodNotSupported: "error.2fa.method_not_supported",
|
|
3941
3951
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3942
3952
|
notImplemented: "error.not.implemented",
|
|
3943
|
-
tokenInvalid: "error.api.request.token.invalid"
|
|
3953
|
+
tokenInvalid: "error.api.request.token.invalid",
|
|
3954
|
+
grantPredatesCredentialReset: "error.grant.predates_credential_reset",
|
|
3955
|
+
tokenAccessEnded: "error.token.access_ended",
|
|
3956
|
+
userNotFound: "error.user.not_found"
|
|
3944
3957
|
}, Ci = Object.freeze([
|
|
3945
3958
|
Q.twoFactorCodeInvalid,
|
|
3946
3959
|
Q.twoFactorNotEnabled,
|
|
3947
3960
|
Q.challengeInvalid,
|
|
3948
3961
|
Q.challengeSessionMismatch,
|
|
3949
3962
|
Q.challengeTooManyAttempts
|
|
3950
|
-
]), wi = Object.freeze([
|
|
3963
|
+
]), wi = Object.freeze([
|
|
3964
|
+
Q.tokenInvalid,
|
|
3965
|
+
Q.grantPredatesCredentialReset,
|
|
3966
|
+
Q.tokenAccessEnded,
|
|
3967
|
+
Q.userNotFound
|
|
3968
|
+
]), Ti = Object.freeze([
|
|
3951
3969
|
"wrong_code",
|
|
3952
3970
|
"challenge_spent",
|
|
3953
3971
|
"not_registered",
|
|
@@ -5789,13 +5807,15 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5789
5807
|
userId: t.userId,
|
|
5790
5808
|
appId: t.appId,
|
|
5791
5809
|
scope: "2fa_setup",
|
|
5810
|
+
reset: t.reset === !0,
|
|
5792
5811
|
timestamp: Date.now(),
|
|
5793
5812
|
expiresAt: Date.now() + (t.expiresIn || 3600) * 1e3
|
|
5794
5813
|
}, this.subscribeStore.notify(G.TwoFactorSetupMagicLinkValidated, {
|
|
5795
5814
|
userId: t.userId,
|
|
5796
5815
|
appId: t.appId,
|
|
5797
5816
|
expiresIn: t.expiresIn || 3600,
|
|
5798
|
-
sessionToken: t.sessionToken
|
|
5817
|
+
sessionToken: t.sessionToken,
|
|
5818
|
+
reset: t.reset === !0
|
|
5799
5819
|
})) : t.error && this.subscribeStore.notify(G.TwoFactorSetupMagicLinkFailed, { error: t.error }), t;
|
|
5800
5820
|
}
|
|
5801
5821
|
getMagicLinkSession() {
|
|
@@ -5905,6 +5925,27 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5905
5925
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
5906
5926
|
}
|
|
5907
5927
|
}
|
|
5928
|
+
async getPreferredMethod() {
|
|
5929
|
+
try {
|
|
5930
|
+
return await this.twoFactorApi.getPreferredMethod();
|
|
5931
|
+
} catch (e) {
|
|
5932
|
+
this.emitErrorAndThrow(e, "2fa.preferred-method.read", "Get preferred 2FA method");
|
|
5933
|
+
}
|
|
5934
|
+
}
|
|
5935
|
+
async setPreferredMethod(e) {
|
|
5936
|
+
try {
|
|
5937
|
+
return await this.twoFactorApi.setPreferredMethod(e);
|
|
5938
|
+
} catch (e) {
|
|
5939
|
+
this.emitErrorAndThrow(e, "2fa.preferred-method.set", "Set preferred 2FA method");
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
async clearPreferredMethod() {
|
|
5943
|
+
try {
|
|
5944
|
+
await this.twoFactorApi.clearPreferredMethod();
|
|
5945
|
+
} catch (e) {
|
|
5946
|
+
this.emitErrorAndThrow(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5908
5949
|
}, va = class {
|
|
5909
5950
|
constructor(e, t, n = R) {
|
|
5910
5951
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
@@ -7841,6 +7882,27 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7841
7882
|
this.handleError(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
7842
7883
|
}
|
|
7843
7884
|
}
|
|
7885
|
+
async getPreferredTwoFactorMethod() {
|
|
7886
|
+
try {
|
|
7887
|
+
return await this.twoFactorService.getPreferredMethod();
|
|
7888
|
+
} catch (e) {
|
|
7889
|
+
this.handleError(e, "2fa.preferred-method.read", "Get preferred 2FA method");
|
|
7890
|
+
}
|
|
7891
|
+
}
|
|
7892
|
+
async setPreferredTwoFactorMethod(e) {
|
|
7893
|
+
try {
|
|
7894
|
+
return await this.twoFactorService.setPreferredMethod(e);
|
|
7895
|
+
} catch (e) {
|
|
7896
|
+
this.handleError(e, "2fa.preferred-method.set", "Set preferred 2FA method");
|
|
7897
|
+
}
|
|
7898
|
+
}
|
|
7899
|
+
async clearPreferredTwoFactorMethod() {
|
|
7900
|
+
try {
|
|
7901
|
+
await this.twoFactorService.clearPreferredMethod();
|
|
7902
|
+
} catch (e) {
|
|
7903
|
+
this.handleError(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
|
|
7904
|
+
}
|
|
7905
|
+
}
|
|
7844
7906
|
isTwoFactorVerificationRequired() {
|
|
7845
7907
|
return this.twoFactorService.isVerificationRequired();
|
|
7846
7908
|
}
|