@passflow/core 0.41.0 → 0.42.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 +15 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -6
- package/dist/index.d.ts +151 -6
- package/dist/index.mjs +1387 -1100
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -290,6 +290,7 @@ declare class StorageManager {
|
|
|
290
290
|
appKey(name: string): string;
|
|
291
291
|
private idTokenKey;
|
|
292
292
|
private csrfTokenKey;
|
|
293
|
+
private refreshChallengeKey;
|
|
293
294
|
private deliveryModeKey;
|
|
294
295
|
/** The stored value, or undefined when it is a JWT issued for another app than this one. */
|
|
295
296
|
private ownToken;
|
|
@@ -407,6 +408,13 @@ declare class StorageManager {
|
|
|
407
408
|
* Clear the CSRF token from storage
|
|
408
409
|
*/
|
|
409
410
|
clearCsrfToken(): void;
|
|
411
|
+
/**
|
|
412
|
+
* The `refresh_challenge` of the last token answer: what a cookie-mode refresh signs its device
|
|
413
|
+
* proof over, since the refresh token itself is out of reach in an HttpOnly cookie.
|
|
414
|
+
*/
|
|
415
|
+
getRefreshChallenge(): string | undefined;
|
|
416
|
+
setRefreshChallenge(challenge: string): void;
|
|
417
|
+
clearRefreshChallenge(): void;
|
|
410
418
|
/**
|
|
411
419
|
* Every storage key the token session lives in (JSON tokens, scopes, the cookie-mode ID token,
|
|
412
420
|
* CSRF token and delivery mode). The refresh coordinator filters `storage` events by it, so
|
|
@@ -1135,7 +1143,9 @@ export declare enum PassflowEndpointPaths {
|
|
|
1135
1143
|
antiBotChallenge = "/auth/anti-bot/challenge",
|
|
1136
1144
|
deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge",
|
|
1137
1145
|
enterpriseResolve = "/auth/enterprise/resolve",
|
|
1138
|
-
enterpriseStart = "/auth/enterprise/start"
|
|
1146
|
+
enterpriseStart = "/auth/enterprise/start",
|
|
1147
|
+
deviceChallenge = "/auth/device/challenge",
|
|
1148
|
+
userDeviceKey = "/user/device/key"
|
|
1139
1149
|
}
|
|
1140
1150
|
export declare enum PassflowAdminEndpointPaths {
|
|
1141
1151
|
passkeyRegisterStart = "/admin/auth/passkey/register/start",
|
|
@@ -1237,6 +1247,13 @@ export type PassflowConfig = {
|
|
|
1237
1247
|
* built-in check. Without it the proof of work runs on the main thread.
|
|
1238
1248
|
*/
|
|
1239
1249
|
antiBotWorkerUrl?: string;
|
|
1250
|
+
/**
|
|
1251
|
+
* Device-key proofs at sign-in and refresh. The browser keeps a non-extractable ES256 key in
|
|
1252
|
+
* IndexedDB, enrols it after a second factor, and signs `X-Passflow-Device-Proof` with it;
|
|
1253
|
+
* `/auth/refresh` is sent with credentials. Default false. Ignored in BFF mode (`tokenExchange`).
|
|
1254
|
+
* Needs Passflow server v0.137.0 or later. See `docs/device-key.md`.
|
|
1255
|
+
*/
|
|
1256
|
+
deviceKey?: boolean;
|
|
1240
1257
|
};
|
|
1241
1258
|
export type PassflowUpgradeConfig = {
|
|
1242
1259
|
/** Relying-party id forwarded verbatim to `POST /auth/upgrade/start` for passkey upgrades. */
|
|
@@ -1313,6 +1330,8 @@ export type PassflowAuthorizationResponse = Tokens & {
|
|
|
1313
1330
|
email_verification_required?: boolean;
|
|
1314
1331
|
/** Human-readable text from the server, e.g. "We sent a code to a***@example.com." */
|
|
1315
1332
|
message?: string;
|
|
1333
|
+
/** Base64url (no padding) SHA-256 of the refresh token issued with this answer. */
|
|
1334
|
+
refresh_challenge?: string;
|
|
1316
1335
|
};
|
|
1317
1336
|
/**
|
|
1318
1337
|
* A sign-up, sign-in or password change that waits for the email to be proven.
|
|
@@ -1739,6 +1758,12 @@ export type AntiBotSettings = {
|
|
|
1739
1758
|
* `POST /auth/anti-bot/challenge` and `POST /oidc/device/anti-bot/challenge`. The answer is the
|
|
1740
1759
|
* integer `number` in `[0, max]` with `hex(SHA-256(salt + ":" + number)) === challenge`.
|
|
1741
1760
|
*/
|
|
1761
|
+
/** `POST /auth/device/challenge`: a one-use challenge for an enrol or sign-in device proof. */
|
|
1762
|
+
export type DeviceChallengeResponse = {
|
|
1763
|
+
challenge: string;
|
|
1764
|
+
/** Seconds the challenge stays valid. */
|
|
1765
|
+
expires_in: number;
|
|
1766
|
+
};
|
|
1742
1767
|
export type AntiBotChallenge = {
|
|
1743
1768
|
algorithm: 'SHA-256';
|
|
1744
1769
|
app: string;
|
|
@@ -2613,7 +2638,7 @@ export declare enum PassflowEvent {
|
|
|
2613
2638
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
2614
2639
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
2615
2640
|
*/
|
|
2616
|
-
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' | '2fa.recovery-codes.start' | '2fa.recovery-codes.complete' | 'profile.update' | 'profile.address-proof';
|
|
2641
|
+
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' | 'device-key.enrol' | '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' | '2fa.recovery-codes.start' | '2fa.recovery-codes.complete' | 'profile.update' | 'profile.address-proof';
|
|
2617
2642
|
/**
|
|
2618
2643
|
* Error payload interface for structured error information
|
|
2619
2644
|
*/
|
|
@@ -2979,6 +3004,10 @@ export declare class AppAPI {
|
|
|
2979
3004
|
setAppId(appId: string): void;
|
|
2980
3005
|
getAppSettings(): Promise<AppSettings>;
|
|
2981
3006
|
}
|
|
3007
|
+
/** What a refresh sends for device keys: credentials always, and the proof header when there is a proof. */
|
|
3008
|
+
export type RefreshDeviceArg = {
|
|
3009
|
+
proof?: string;
|
|
3010
|
+
};
|
|
2982
3011
|
export declare class AuthAPI {
|
|
2983
3012
|
protected axiosClient: AxiosClient;
|
|
2984
3013
|
constructor(config: PassflowConfig, storageManager?: StorageManager, deviceService?: DeviceService);
|
|
@@ -2992,6 +3021,11 @@ export declare class AuthAPI {
|
|
|
2992
3021
|
antiBotChallenge(payload: {
|
|
2993
3022
|
identifier?: string;
|
|
2994
3023
|
}): Promise<AntiBotChallenge>;
|
|
3024
|
+
/**
|
|
3025
|
+
* A one-use challenge for an enrol or sign-in device proof, for this app. Rejects only with a
|
|
3026
|
+
* `PassflowError`.
|
|
3027
|
+
*/
|
|
3028
|
+
deviceChallenge(): Promise<DeviceChallengeResponse>;
|
|
2995
3029
|
/**
|
|
2996
3030
|
* A built-in anti-bot challenge for the device verification page, for the app of `user_code`.
|
|
2997
3031
|
* Same-origin only, with the page's CSRF token. Rejects only with a `PassflowError`.
|
|
@@ -3028,9 +3062,14 @@ export declare class AuthAPI {
|
|
|
3028
3062
|
* vocabulary, which is indistinguishable from an expired session on the
|
|
3029
3063
|
* response alone; the marker is what tells the response interceptor not to
|
|
3030
3064
|
* invalidate the session over a mistyped digit.
|
|
3065
|
+
*
|
|
3066
|
+
* `device` is passed with `PassflowConfig.deviceKey` only: the request then goes with
|
|
3067
|
+
* credentials (so a browser that registered a DBSC session sends its cookie), and with the
|
|
3068
|
+
* device-proof header when `device.proof` is set.
|
|
3031
3069
|
*/
|
|
3032
|
-
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField): Promise<PassflowAuthorizationResponse>;
|
|
3033
|
-
|
|
3070
|
+
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField, device?: RefreshDeviceArg): Promise<PassflowAuthorizationResponse>;
|
|
3071
|
+
/** `deviceProof`: a `use: "sign_in"` device proof, sent as `X-Passflow-Device-Proof`. */
|
|
3072
|
+
signIn(payload: PassflowSignInPayload, deviceId: string, os: OS, options?: PassflowAuthOptions, deviceProof?: string): Promise<PassflowAuthorizationResponse>;
|
|
3034
3073
|
signUp(payload: PassflowSignUpPayload, options?: PassflowAuthOptions): Promise<PassflowAuthorizationResponse>;
|
|
3035
3074
|
/**
|
|
3036
3075
|
* Redeems the code a PKCE sign-in answered with for the tokens it stands for.
|
|
@@ -3075,7 +3114,8 @@ export declare class AuthAPI {
|
|
|
3075
3114
|
passkeyRegisterStart(payload: PassflowPasskeyRegisterStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
|
|
3076
3115
|
passkeyRegisterComplete(passkeyData: RegistrationResponseJSON, deviceId: string, challengeId: string, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowAuthorizationResponse>;
|
|
3077
3116
|
passkeyAuthenticateStart(payload: PassflowPasskeyAuthenticateStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
|
|
3078
|
-
|
|
3117
|
+
/** `deviceProof`: a `use: "sign_in"` device proof, sent as `X-Passflow-Device-Proof`. */
|
|
3118
|
+
passkeyAuthenticateComplete(passkeyData: AuthenticationResponseJSON, deviceId: string, challengeId: string, isAdmin?: boolean, options?: PassflowAuthOptions, deviceProof?: string): Promise<PassflowAuthorizationResponse>;
|
|
3079
3119
|
passkeyValidate(otp: string, deviceId: string, challengeId: string, isAdmin?: boolean, appId?: string): Promise<PassflowValidationResponse>;
|
|
3080
3120
|
}
|
|
3081
3121
|
export declare class CLIAuthAPI {
|
|
@@ -3607,6 +3647,14 @@ export declare class UserAPI {
|
|
|
3607
3647
|
protected axiosClient: AxiosClient;
|
|
3608
3648
|
constructor(config: PassflowConfig, storageManager?: StorageManager, deviceService?: DeviceService);
|
|
3609
3649
|
setAppId(appId: string): void;
|
|
3650
|
+
/**
|
|
3651
|
+
* Enrols this browser's device key for the signed-in session: `proof` is a `use: "enrol"` device
|
|
3652
|
+
* proof. Answers 200 (the current key) or 201 (a new key replaced the device's old one).
|
|
3653
|
+
*/
|
|
3654
|
+
enrolDeviceKey(body: {
|
|
3655
|
+
proof: string;
|
|
3656
|
+
key_storage: 'software';
|
|
3657
|
+
}): Promise<unknown>;
|
|
3610
3658
|
getUserPasskeys(): Promise<PassflowUserPasskey[]>;
|
|
3611
3659
|
renameUserPasskey(name: string, passkeyId: string): Promise<PassflowSuccessResponse>;
|
|
3612
3660
|
deleteUserPasskey(passkeyId: string): Promise<PassflowSuccessResponse>;
|
|
@@ -3640,6 +3688,8 @@ export declare const DEVICE_TYPE_HEADER_KEY = "X-Passflow-DeviceType";
|
|
|
3640
3688
|
export declare const ANTI_BOT_HEADER_KEY = "X-Passflow-Anti-Bot";
|
|
3641
3689
|
/** Set to `1` on requests an agent tool sends (`PassflowAuthOptions.agentTool`). */
|
|
3642
3690
|
export declare const AGENT_TOOL_HEADER_KEY = "X-Passflow-Agent-Tool";
|
|
3691
|
+
/** A device-key proof (compact JWS) on sign-in and refresh requests, with `PassflowConfig.deviceKey`. */
|
|
3692
|
+
export declare const DEVICE_PROOF_HEADER_KEY = "X-Passflow-Device-Proof";
|
|
3643
3693
|
/** The `action` a token provider receives; a reCAPTCHA score key must be executed with it. */
|
|
3644
3694
|
export declare const ANTI_BOT_ACTION = "passflow_auth";
|
|
3645
3695
|
/**
|
|
@@ -3670,6 +3720,44 @@ export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 30;
|
|
|
3670
3720
|
export declare const USERNAME_MIN_LENGTH = 3;
|
|
3671
3721
|
export declare const USERNAME_MAX_LENGTH = 30;
|
|
3672
3722
|
export declare const ERROR_MESSAGE_MAX_LENGTH = 200;
|
|
3723
|
+
/**
|
|
3724
|
+
* Device-key proofs: a compact JWS signed with ES256 by the browser's device key.
|
|
3725
|
+
*
|
|
3726
|
+
* Header `{"alg":"ES256","typ":"pf-device-proof+jwt","jwk":{kty,crv,x,y}}`, payload
|
|
3727
|
+
* `{"jti","ctr","did","use","iat"}`. WebCrypto's ECDSA signature is already the raw 64-byte
|
|
3728
|
+
* `r||s` form JWS uses. Pure functions: no storage, no network.
|
|
3729
|
+
*
|
|
3730
|
+
* @module device-key/proof
|
|
3731
|
+
*/
|
|
3732
|
+
/** What a proof is for: enrolling the key, a first-factor sign-in, or a refresh. */
|
|
3733
|
+
type DeviceProofUse = 'enrol' | 'sign_in' | 'refresh';
|
|
3734
|
+
interface DeviceKeyService {
|
|
3735
|
+
/** IndexedDB and `crypto.subtle` exist. False: proofs are undefined, enrolment rejects, the rest does nothing. */
|
|
3736
|
+
readonly supported: boolean;
|
|
3737
|
+
/** Whether a key is stored and enrolled. */
|
|
3738
|
+
isEnrolled(): Promise<boolean>;
|
|
3739
|
+
/**
|
|
3740
|
+
* A proof by the enrolled key over `jti`, with the next counter value, or undefined when no key
|
|
3741
|
+
* is stored or it is not enrolled. Each call takes a new counter value, so a retry signs anew.
|
|
3742
|
+
*/
|
|
3743
|
+
proof(use: Exclude<DeviceProofUse, 'enrol'>, jti: string): Promise<string | undefined>;
|
|
3744
|
+
/** Creates the key when there is none, then a `use: "enrol"` proof over `jti`. */
|
|
3745
|
+
enrolProof(jti: string): Promise<string>;
|
|
3746
|
+
markEnrolled(): Promise<void>;
|
|
3747
|
+
clear(): Promise<void>;
|
|
3748
|
+
}
|
|
3749
|
+
/** Error ids an app sees around device keys. */
|
|
3750
|
+
export declare const DeviceKeyErrorId: {
|
|
3751
|
+
/** The key was used with a counter that did not rise, or it was retired: the device was reset, sign in again. */
|
|
3752
|
+
readonly keyReused: 'error.device.key.reused';
|
|
3753
|
+
/** A key-bound session refreshed without a valid proof. */
|
|
3754
|
+
readonly proofRequired: 'error.device.proof.required';
|
|
3755
|
+
/** Enrolment needs a second factor in the last 10 minutes. */
|
|
3756
|
+
readonly stepUpRequired: 'error.device.key.step_up_required';
|
|
3757
|
+
/** The SDK could not read the key or sign with it for a refresh; the key is deleted, sign in again. */
|
|
3758
|
+
readonly proofUnavailable: 'error.device.proof.unavailable';
|
|
3759
|
+
};
|
|
3760
|
+
export type DeviceKeyErrorId = (typeof DeviceKeyErrorId)[keyof typeof DeviceKeyErrorId];
|
|
3673
3761
|
/**
|
|
3674
3762
|
* One `fetch` patch point, many middlewares.
|
|
3675
3763
|
*
|
|
@@ -4458,6 +4546,11 @@ export declare class TokenCacheService {
|
|
|
4458
4546
|
getParsedTokens(): ParsedTokens | undefined;
|
|
4459
4547
|
isExpired(): boolean;
|
|
4460
4548
|
}
|
|
4549
|
+
/** The body of `POST /user/device/key`. */
|
|
4550
|
+
export type DeviceKeyEnrolBody = {
|
|
4551
|
+
proof: string;
|
|
4552
|
+
key_storage: 'software';
|
|
4553
|
+
};
|
|
4461
4554
|
/** Options of `authRedirect()`. `url` and `appId` may only repeat the instance's own values. */
|
|
4462
4555
|
export type AuthRedirectOptions = {
|
|
4463
4556
|
url?: string;
|
|
@@ -4502,6 +4595,10 @@ export type AuthServiceRefreshOptions = {
|
|
|
4502
4595
|
coordination: ResolvedCoordination;
|
|
4503
4596
|
/** `PassflowConfig.refreshStrikes`; the controller resolves the default. */
|
|
4504
4597
|
strikes?: number;
|
|
4598
|
+
/** Set with `PassflowConfig.deviceKey` only (never in BFF mode): proofs at sign-in and refresh. */
|
|
4599
|
+
deviceKey?: DeviceKeyService;
|
|
4600
|
+
/** `POST /user/device/key`; needed with `deviceKey`. */
|
|
4601
|
+
enrolDeviceKeyRequest?: (body: DeviceKeyEnrolBody) => Promise<unknown>;
|
|
4505
4602
|
};
|
|
4506
4603
|
/**
|
|
4507
4604
|
* Service for handling authentication related functionality
|
|
@@ -4537,6 +4634,9 @@ export declare class AuthService {
|
|
|
4537
4634
|
* `Passflow` attaches it, `TokenCacheService.getTokensWithRefresh()`.
|
|
4538
4635
|
*/
|
|
4539
4636
|
readonly refresh: RefreshController;
|
|
4637
|
+
/** The device key, with `PassflowConfig.deviceKey` only. Undefined: no device-key code runs. */
|
|
4638
|
+
private readonly deviceKey?;
|
|
4639
|
+
private readonly enrolDeviceKeyRequest?;
|
|
4540
4640
|
constructor(authApi: AuthAPI, deviceService: DeviceService, storageManager: StorageManager, subscribeStore: PassflowStore, tokenCacheService: TokenCacheService, scopes: string[], createTenantForNewUser: boolean, url: string, sessionCallbacks: {
|
|
4541
4641
|
createSession?: ({ tokens, parsedTokens }: {
|
|
4542
4642
|
tokens?: Tokens;
|
|
@@ -4794,6 +4894,38 @@ export declare class AuthService {
|
|
|
4794
4894
|
* the body's `error.id` or `error.http.<status>`), so it is classified like any other answer.
|
|
4795
4895
|
*/
|
|
4796
4896
|
private createRefreshTransport;
|
|
4897
|
+
/**
|
|
4898
|
+
* A JSON or cookie refresh with `PassflowConfig.deviceKey`: sent with credentials, and with a
|
|
4899
|
+
* proof by the enrolled key over the refresh challenge of the token presented. JSON mode works the
|
|
4900
|
+
* challenge out from the refresh token it sends; cookie mode uses the stored `refresh_challenge`
|
|
4901
|
+
* of the last answer. Each call (each retry, the upgrade commit) signs a new counter value.
|
|
4902
|
+
*
|
|
4903
|
+
* A device error from the server, or a key that cannot be read or sign, deletes the key; the
|
|
4904
|
+
* rejection carries an `error.device.*` id, which ends the session (`classify` row 0).
|
|
4905
|
+
*/
|
|
4906
|
+
private sendDeviceKeyRefresh;
|
|
4907
|
+
/**
|
|
4908
|
+
* A `use: "sign_in"` proof over a new challenge, when the device key is enrolled; undefined
|
|
4909
|
+
* otherwise. A failed challenge request or signature also answers undefined: the sign-in goes on
|
|
4910
|
+
* without a proof and the key stays.
|
|
4911
|
+
*/
|
|
4912
|
+
private signInProof;
|
|
4913
|
+
/**
|
|
4914
|
+
* Creates this browser's device key when there is none and enrols it for the signed-in session:
|
|
4915
|
+
* a challenge, a `use: "enrol"` proof, `POST /user/device/key`. The server needs a second factor
|
|
4916
|
+
* in the last 10 minutes (else 403 `error.device.key.step_up_required`).
|
|
4917
|
+
*
|
|
4918
|
+
* Any failure emits one `Error` (operation `device-key.enrol`) and rejects. On
|
|
4919
|
+
* `error.device.key.reused` the server has reset the device and ended the session: the key is
|
|
4920
|
+
* deleted and this tab signs out (`SignOut`) first.
|
|
4921
|
+
*/
|
|
4922
|
+
enrolDeviceKey(): Promise<void>;
|
|
4923
|
+
/**
|
|
4924
|
+
* Called by `TwoFactorService` once a sign-in's second factor has completed and its tokens are
|
|
4925
|
+
* applied: enrols the device key, which also binds the new session to it. A failure is already
|
|
4926
|
+
* reported as an `Error` event and does not change the sign-in's result.
|
|
4927
|
+
*/
|
|
4928
|
+
secondFactorCompleted(): Promise<void>;
|
|
4797
4929
|
/** The BFF refresh endpoint. A non-OK answer becomes a `PassflowError`; a network failure rejects as is. */
|
|
4798
4930
|
private sendBffRefresh;
|
|
4799
4931
|
/**
|
|
@@ -5228,6 +5360,8 @@ export interface SignInCompleter {
|
|
|
5228
5360
|
forgetPkceSignIn(): void;
|
|
5229
5361
|
/** Reports a finished sign-in: emits `SignIn` with these tokens, then runs the session check. */
|
|
5230
5362
|
notifySignedIn(tokens: Tokens): Promise<void>;
|
|
5363
|
+
/** Runs once the second factor's tokens are applied (device-key enrolment). Must not reject. */
|
|
5364
|
+
secondFactorCompleted?(): Promise<void>;
|
|
5231
5365
|
}
|
|
5232
5366
|
/**
|
|
5233
5367
|
* Service for managing Two-Factor Authentication
|
|
@@ -7207,6 +7341,17 @@ export declare class Passflow {
|
|
|
7207
7341
|
* ```
|
|
7208
7342
|
*/
|
|
7209
7343
|
refreshToken(): Promise<PassflowAuthorizationResponse>;
|
|
7344
|
+
/**
|
|
7345
|
+
* Creates (if needed) and enrols this browser's device key for the signed-in session, which binds
|
|
7346
|
+
* the session to the key. Needs `deviceKey: true` in the config and a second factor in the last
|
|
7347
|
+
* 10 minutes. A sign-in that completes a second factor already enrols automatically.
|
|
7348
|
+
*
|
|
7349
|
+
* @throws {PassflowError} `error.device.key.step_up_required` (403) without a recent second
|
|
7350
|
+
* factor; `error.device.key.reused` (401) when the server reset the device: the key is deleted
|
|
7351
|
+
* and this tab is signed out. Every failure also emits an `Error` with operation `device-key.enrol`.
|
|
7352
|
+
* @throws {Error} with the option off, in BFF mode, or without IndexedDB and WebCrypto
|
|
7353
|
+
*/
|
|
7354
|
+
enrolDeviceKey(): Promise<void>;
|
|
7210
7355
|
/**
|
|
7211
7356
|
* Send a password reset email to the user.
|
|
7212
7357
|
*
|
|
@@ -8177,4 +8322,4 @@ export declare function isValidPhoneNumber(phone: string): boolean;
|
|
|
8177
8322
|
* @returns true if valid username format, false otherwise
|
|
8178
8323
|
*/
|
|
8179
8324
|
export declare function isValidUsername(username: string): boolean;
|
|
8180
|
-
export type { AntiBotAppSettings, AntiBotDeviceContext, AntiBotOperation, AntiBotTokenContext, AntiBotTokenProvider, AntiBotTokenRequest, AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OidcErrorCode, OpenAuthUrlOptions, OperationErrorPayload, PassflowEmailVerificationOperation, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport, WithAuthOptions };
|
|
8325
|
+
export type { AntiBotAppSettings, AntiBotDeviceContext, AntiBotOperation, AntiBotTokenContext, AntiBotTokenProvider, AntiBotTokenRequest, AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, DeviceProofUse, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OidcErrorCode, OpenAuthUrlOptions, OperationErrorPayload, PassflowEmailVerificationOperation, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport, WithAuthOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -290,6 +290,7 @@ declare class StorageManager {
|
|
|
290
290
|
appKey(name: string): string;
|
|
291
291
|
private idTokenKey;
|
|
292
292
|
private csrfTokenKey;
|
|
293
|
+
private refreshChallengeKey;
|
|
293
294
|
private deliveryModeKey;
|
|
294
295
|
/** The stored value, or undefined when it is a JWT issued for another app than this one. */
|
|
295
296
|
private ownToken;
|
|
@@ -407,6 +408,13 @@ declare class StorageManager {
|
|
|
407
408
|
* Clear the CSRF token from storage
|
|
408
409
|
*/
|
|
409
410
|
clearCsrfToken(): void;
|
|
411
|
+
/**
|
|
412
|
+
* The `refresh_challenge` of the last token answer: what a cookie-mode refresh signs its device
|
|
413
|
+
* proof over, since the refresh token itself is out of reach in an HttpOnly cookie.
|
|
414
|
+
*/
|
|
415
|
+
getRefreshChallenge(): string | undefined;
|
|
416
|
+
setRefreshChallenge(challenge: string): void;
|
|
417
|
+
clearRefreshChallenge(): void;
|
|
410
418
|
/**
|
|
411
419
|
* Every storage key the token session lives in (JSON tokens, scopes, the cookie-mode ID token,
|
|
412
420
|
* CSRF token and delivery mode). The refresh coordinator filters `storage` events by it, so
|
|
@@ -1135,7 +1143,9 @@ export declare enum PassflowEndpointPaths {
|
|
|
1135
1143
|
antiBotChallenge = "/auth/anti-bot/challenge",
|
|
1136
1144
|
deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge",
|
|
1137
1145
|
enterpriseResolve = "/auth/enterprise/resolve",
|
|
1138
|
-
enterpriseStart = "/auth/enterprise/start"
|
|
1146
|
+
enterpriseStart = "/auth/enterprise/start",
|
|
1147
|
+
deviceChallenge = "/auth/device/challenge",
|
|
1148
|
+
userDeviceKey = "/user/device/key"
|
|
1139
1149
|
}
|
|
1140
1150
|
export declare enum PassflowAdminEndpointPaths {
|
|
1141
1151
|
passkeyRegisterStart = "/admin/auth/passkey/register/start",
|
|
@@ -1237,6 +1247,13 @@ export type PassflowConfig = {
|
|
|
1237
1247
|
* built-in check. Without it the proof of work runs on the main thread.
|
|
1238
1248
|
*/
|
|
1239
1249
|
antiBotWorkerUrl?: string;
|
|
1250
|
+
/**
|
|
1251
|
+
* Device-key proofs at sign-in and refresh. The browser keeps a non-extractable ES256 key in
|
|
1252
|
+
* IndexedDB, enrols it after a second factor, and signs `X-Passflow-Device-Proof` with it;
|
|
1253
|
+
* `/auth/refresh` is sent with credentials. Default false. Ignored in BFF mode (`tokenExchange`).
|
|
1254
|
+
* Needs Passflow server v0.137.0 or later. See `docs/device-key.md`.
|
|
1255
|
+
*/
|
|
1256
|
+
deviceKey?: boolean;
|
|
1240
1257
|
};
|
|
1241
1258
|
export type PassflowUpgradeConfig = {
|
|
1242
1259
|
/** Relying-party id forwarded verbatim to `POST /auth/upgrade/start` for passkey upgrades. */
|
|
@@ -1313,6 +1330,8 @@ export type PassflowAuthorizationResponse = Tokens & {
|
|
|
1313
1330
|
email_verification_required?: boolean;
|
|
1314
1331
|
/** Human-readable text from the server, e.g. "We sent a code to a***@example.com." */
|
|
1315
1332
|
message?: string;
|
|
1333
|
+
/** Base64url (no padding) SHA-256 of the refresh token issued with this answer. */
|
|
1334
|
+
refresh_challenge?: string;
|
|
1316
1335
|
};
|
|
1317
1336
|
/**
|
|
1318
1337
|
* A sign-up, sign-in or password change that waits for the email to be proven.
|
|
@@ -1739,6 +1758,12 @@ export type AntiBotSettings = {
|
|
|
1739
1758
|
* `POST /auth/anti-bot/challenge` and `POST /oidc/device/anti-bot/challenge`. The answer is the
|
|
1740
1759
|
* integer `number` in `[0, max]` with `hex(SHA-256(salt + ":" + number)) === challenge`.
|
|
1741
1760
|
*/
|
|
1761
|
+
/** `POST /auth/device/challenge`: a one-use challenge for an enrol or sign-in device proof. */
|
|
1762
|
+
export type DeviceChallengeResponse = {
|
|
1763
|
+
challenge: string;
|
|
1764
|
+
/** Seconds the challenge stays valid. */
|
|
1765
|
+
expires_in: number;
|
|
1766
|
+
};
|
|
1742
1767
|
export type AntiBotChallenge = {
|
|
1743
1768
|
algorithm: 'SHA-256';
|
|
1744
1769
|
app: string;
|
|
@@ -2613,7 +2638,7 @@ export declare enum PassflowEvent {
|
|
|
2613
2638
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
2614
2639
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
2615
2640
|
*/
|
|
2616
|
-
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' | '2fa.recovery-codes.start' | '2fa.recovery-codes.complete' | 'profile.update' | 'profile.address-proof';
|
|
2641
|
+
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' | 'device-key.enrol' | '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' | '2fa.recovery-codes.start' | '2fa.recovery-codes.complete' | 'profile.update' | 'profile.address-proof';
|
|
2617
2642
|
/**
|
|
2618
2643
|
* Error payload interface for structured error information
|
|
2619
2644
|
*/
|
|
@@ -2979,6 +3004,10 @@ export declare class AppAPI {
|
|
|
2979
3004
|
setAppId(appId: string): void;
|
|
2980
3005
|
getAppSettings(): Promise<AppSettings>;
|
|
2981
3006
|
}
|
|
3007
|
+
/** What a refresh sends for device keys: credentials always, and the proof header when there is a proof. */
|
|
3008
|
+
export type RefreshDeviceArg = {
|
|
3009
|
+
proof?: string;
|
|
3010
|
+
};
|
|
2982
3011
|
export declare class AuthAPI {
|
|
2983
3012
|
protected axiosClient: AxiosClient;
|
|
2984
3013
|
constructor(config: PassflowConfig, storageManager?: StorageManager, deviceService?: DeviceService);
|
|
@@ -2992,6 +3021,11 @@ export declare class AuthAPI {
|
|
|
2992
3021
|
antiBotChallenge(payload: {
|
|
2993
3022
|
identifier?: string;
|
|
2994
3023
|
}): Promise<AntiBotChallenge>;
|
|
3024
|
+
/**
|
|
3025
|
+
* A one-use challenge for an enrol or sign-in device proof, for this app. Rejects only with a
|
|
3026
|
+
* `PassflowError`.
|
|
3027
|
+
*/
|
|
3028
|
+
deviceChallenge(): Promise<DeviceChallengeResponse>;
|
|
2995
3029
|
/**
|
|
2996
3030
|
* A built-in anti-bot challenge for the device verification page, for the app of `user_code`.
|
|
2997
3031
|
* Same-origin only, with the page's CSRF token. Rejects only with a `PassflowError`.
|
|
@@ -3028,9 +3062,14 @@ export declare class AuthAPI {
|
|
|
3028
3062
|
* vocabulary, which is indistinguishable from an expired session on the
|
|
3029
3063
|
* response alone; the marker is what tells the response interceptor not to
|
|
3030
3064
|
* invalidate the session over a mistyped digit.
|
|
3065
|
+
*
|
|
3066
|
+
* `device` is passed with `PassflowConfig.deviceKey` only: the request then goes with
|
|
3067
|
+
* credentials (so a browser that registered a DBSC session sends its cookie), and with the
|
|
3068
|
+
* device-proof header when `device.proof` is set.
|
|
3031
3069
|
*/
|
|
3032
|
-
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField): Promise<PassflowAuthorizationResponse>;
|
|
3033
|
-
|
|
3070
|
+
refreshToken(refreshToken: string, scopes: string[], accessToken?: string, upgrade?: UpgradeRefreshField, device?: RefreshDeviceArg): Promise<PassflowAuthorizationResponse>;
|
|
3071
|
+
/** `deviceProof`: a `use: "sign_in"` device proof, sent as `X-Passflow-Device-Proof`. */
|
|
3072
|
+
signIn(payload: PassflowSignInPayload, deviceId: string, os: OS, options?: PassflowAuthOptions, deviceProof?: string): Promise<PassflowAuthorizationResponse>;
|
|
3034
3073
|
signUp(payload: PassflowSignUpPayload, options?: PassflowAuthOptions): Promise<PassflowAuthorizationResponse>;
|
|
3035
3074
|
/**
|
|
3036
3075
|
* Redeems the code a PKCE sign-in answered with for the tokens it stands for.
|
|
@@ -3075,7 +3114,8 @@ export declare class AuthAPI {
|
|
|
3075
3114
|
passkeyRegisterStart(payload: PassflowPasskeyRegisterStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
|
|
3076
3115
|
passkeyRegisterComplete(passkeyData: RegistrationResponseJSON, deviceId: string, challengeId: string, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowAuthorizationResponse>;
|
|
3077
3116
|
passkeyAuthenticateStart(payload: PassflowPasskeyAuthenticateStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
|
|
3078
|
-
|
|
3117
|
+
/** `deviceProof`: a `use: "sign_in"` device proof, sent as `X-Passflow-Device-Proof`. */
|
|
3118
|
+
passkeyAuthenticateComplete(passkeyData: AuthenticationResponseJSON, deviceId: string, challengeId: string, isAdmin?: boolean, options?: PassflowAuthOptions, deviceProof?: string): Promise<PassflowAuthorizationResponse>;
|
|
3079
3119
|
passkeyValidate(otp: string, deviceId: string, challengeId: string, isAdmin?: boolean, appId?: string): Promise<PassflowValidationResponse>;
|
|
3080
3120
|
}
|
|
3081
3121
|
export declare class CLIAuthAPI {
|
|
@@ -3607,6 +3647,14 @@ export declare class UserAPI {
|
|
|
3607
3647
|
protected axiosClient: AxiosClient;
|
|
3608
3648
|
constructor(config: PassflowConfig, storageManager?: StorageManager, deviceService?: DeviceService);
|
|
3609
3649
|
setAppId(appId: string): void;
|
|
3650
|
+
/**
|
|
3651
|
+
* Enrols this browser's device key for the signed-in session: `proof` is a `use: "enrol"` device
|
|
3652
|
+
* proof. Answers 200 (the current key) or 201 (a new key replaced the device's old one).
|
|
3653
|
+
*/
|
|
3654
|
+
enrolDeviceKey(body: {
|
|
3655
|
+
proof: string;
|
|
3656
|
+
key_storage: 'software';
|
|
3657
|
+
}): Promise<unknown>;
|
|
3610
3658
|
getUserPasskeys(): Promise<PassflowUserPasskey[]>;
|
|
3611
3659
|
renameUserPasskey(name: string, passkeyId: string): Promise<PassflowSuccessResponse>;
|
|
3612
3660
|
deleteUserPasskey(passkeyId: string): Promise<PassflowSuccessResponse>;
|
|
@@ -3640,6 +3688,8 @@ export declare const DEVICE_TYPE_HEADER_KEY = "X-Passflow-DeviceType";
|
|
|
3640
3688
|
export declare const ANTI_BOT_HEADER_KEY = "X-Passflow-Anti-Bot";
|
|
3641
3689
|
/** Set to `1` on requests an agent tool sends (`PassflowAuthOptions.agentTool`). */
|
|
3642
3690
|
export declare const AGENT_TOOL_HEADER_KEY = "X-Passflow-Agent-Tool";
|
|
3691
|
+
/** A device-key proof (compact JWS) on sign-in and refresh requests, with `PassflowConfig.deviceKey`. */
|
|
3692
|
+
export declare const DEVICE_PROOF_HEADER_KEY = "X-Passflow-Device-Proof";
|
|
3643
3693
|
/** The `action` a token provider receives; a reCAPTCHA score key must be executed with it. */
|
|
3644
3694
|
export declare const ANTI_BOT_ACTION = "passflow_auth";
|
|
3645
3695
|
/**
|
|
@@ -3670,6 +3720,44 @@ export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 30;
|
|
|
3670
3720
|
export declare const USERNAME_MIN_LENGTH = 3;
|
|
3671
3721
|
export declare const USERNAME_MAX_LENGTH = 30;
|
|
3672
3722
|
export declare const ERROR_MESSAGE_MAX_LENGTH = 200;
|
|
3723
|
+
/**
|
|
3724
|
+
* Device-key proofs: a compact JWS signed with ES256 by the browser's device key.
|
|
3725
|
+
*
|
|
3726
|
+
* Header `{"alg":"ES256","typ":"pf-device-proof+jwt","jwk":{kty,crv,x,y}}`, payload
|
|
3727
|
+
* `{"jti","ctr","did","use","iat"}`. WebCrypto's ECDSA signature is already the raw 64-byte
|
|
3728
|
+
* `r||s` form JWS uses. Pure functions: no storage, no network.
|
|
3729
|
+
*
|
|
3730
|
+
* @module device-key/proof
|
|
3731
|
+
*/
|
|
3732
|
+
/** What a proof is for: enrolling the key, a first-factor sign-in, or a refresh. */
|
|
3733
|
+
type DeviceProofUse = 'enrol' | 'sign_in' | 'refresh';
|
|
3734
|
+
interface DeviceKeyService {
|
|
3735
|
+
/** IndexedDB and `crypto.subtle` exist. False: proofs are undefined, enrolment rejects, the rest does nothing. */
|
|
3736
|
+
readonly supported: boolean;
|
|
3737
|
+
/** Whether a key is stored and enrolled. */
|
|
3738
|
+
isEnrolled(): Promise<boolean>;
|
|
3739
|
+
/**
|
|
3740
|
+
* A proof by the enrolled key over `jti`, with the next counter value, or undefined when no key
|
|
3741
|
+
* is stored or it is not enrolled. Each call takes a new counter value, so a retry signs anew.
|
|
3742
|
+
*/
|
|
3743
|
+
proof(use: Exclude<DeviceProofUse, 'enrol'>, jti: string): Promise<string | undefined>;
|
|
3744
|
+
/** Creates the key when there is none, then a `use: "enrol"` proof over `jti`. */
|
|
3745
|
+
enrolProof(jti: string): Promise<string>;
|
|
3746
|
+
markEnrolled(): Promise<void>;
|
|
3747
|
+
clear(): Promise<void>;
|
|
3748
|
+
}
|
|
3749
|
+
/** Error ids an app sees around device keys. */
|
|
3750
|
+
export declare const DeviceKeyErrorId: {
|
|
3751
|
+
/** The key was used with a counter that did not rise, or it was retired: the device was reset, sign in again. */
|
|
3752
|
+
readonly keyReused: 'error.device.key.reused';
|
|
3753
|
+
/** A key-bound session refreshed without a valid proof. */
|
|
3754
|
+
readonly proofRequired: 'error.device.proof.required';
|
|
3755
|
+
/** Enrolment needs a second factor in the last 10 minutes. */
|
|
3756
|
+
readonly stepUpRequired: 'error.device.key.step_up_required';
|
|
3757
|
+
/** The SDK could not read the key or sign with it for a refresh; the key is deleted, sign in again. */
|
|
3758
|
+
readonly proofUnavailable: 'error.device.proof.unavailable';
|
|
3759
|
+
};
|
|
3760
|
+
export type DeviceKeyErrorId = (typeof DeviceKeyErrorId)[keyof typeof DeviceKeyErrorId];
|
|
3673
3761
|
/**
|
|
3674
3762
|
* One `fetch` patch point, many middlewares.
|
|
3675
3763
|
*
|
|
@@ -4458,6 +4546,11 @@ export declare class TokenCacheService {
|
|
|
4458
4546
|
getParsedTokens(): ParsedTokens | undefined;
|
|
4459
4547
|
isExpired(): boolean;
|
|
4460
4548
|
}
|
|
4549
|
+
/** The body of `POST /user/device/key`. */
|
|
4550
|
+
export type DeviceKeyEnrolBody = {
|
|
4551
|
+
proof: string;
|
|
4552
|
+
key_storage: 'software';
|
|
4553
|
+
};
|
|
4461
4554
|
/** Options of `authRedirect()`. `url` and `appId` may only repeat the instance's own values. */
|
|
4462
4555
|
export type AuthRedirectOptions = {
|
|
4463
4556
|
url?: string;
|
|
@@ -4502,6 +4595,10 @@ export type AuthServiceRefreshOptions = {
|
|
|
4502
4595
|
coordination: ResolvedCoordination;
|
|
4503
4596
|
/** `PassflowConfig.refreshStrikes`; the controller resolves the default. */
|
|
4504
4597
|
strikes?: number;
|
|
4598
|
+
/** Set with `PassflowConfig.deviceKey` only (never in BFF mode): proofs at sign-in and refresh. */
|
|
4599
|
+
deviceKey?: DeviceKeyService;
|
|
4600
|
+
/** `POST /user/device/key`; needed with `deviceKey`. */
|
|
4601
|
+
enrolDeviceKeyRequest?: (body: DeviceKeyEnrolBody) => Promise<unknown>;
|
|
4505
4602
|
};
|
|
4506
4603
|
/**
|
|
4507
4604
|
* Service for handling authentication related functionality
|
|
@@ -4537,6 +4634,9 @@ export declare class AuthService {
|
|
|
4537
4634
|
* `Passflow` attaches it, `TokenCacheService.getTokensWithRefresh()`.
|
|
4538
4635
|
*/
|
|
4539
4636
|
readonly refresh: RefreshController;
|
|
4637
|
+
/** The device key, with `PassflowConfig.deviceKey` only. Undefined: no device-key code runs. */
|
|
4638
|
+
private readonly deviceKey?;
|
|
4639
|
+
private readonly enrolDeviceKeyRequest?;
|
|
4540
4640
|
constructor(authApi: AuthAPI, deviceService: DeviceService, storageManager: StorageManager, subscribeStore: PassflowStore, tokenCacheService: TokenCacheService, scopes: string[], createTenantForNewUser: boolean, url: string, sessionCallbacks: {
|
|
4541
4641
|
createSession?: ({ tokens, parsedTokens }: {
|
|
4542
4642
|
tokens?: Tokens;
|
|
@@ -4794,6 +4894,38 @@ export declare class AuthService {
|
|
|
4794
4894
|
* the body's `error.id` or `error.http.<status>`), so it is classified like any other answer.
|
|
4795
4895
|
*/
|
|
4796
4896
|
private createRefreshTransport;
|
|
4897
|
+
/**
|
|
4898
|
+
* A JSON or cookie refresh with `PassflowConfig.deviceKey`: sent with credentials, and with a
|
|
4899
|
+
* proof by the enrolled key over the refresh challenge of the token presented. JSON mode works the
|
|
4900
|
+
* challenge out from the refresh token it sends; cookie mode uses the stored `refresh_challenge`
|
|
4901
|
+
* of the last answer. Each call (each retry, the upgrade commit) signs a new counter value.
|
|
4902
|
+
*
|
|
4903
|
+
* A device error from the server, or a key that cannot be read or sign, deletes the key; the
|
|
4904
|
+
* rejection carries an `error.device.*` id, which ends the session (`classify` row 0).
|
|
4905
|
+
*/
|
|
4906
|
+
private sendDeviceKeyRefresh;
|
|
4907
|
+
/**
|
|
4908
|
+
* A `use: "sign_in"` proof over a new challenge, when the device key is enrolled; undefined
|
|
4909
|
+
* otherwise. A failed challenge request or signature also answers undefined: the sign-in goes on
|
|
4910
|
+
* without a proof and the key stays.
|
|
4911
|
+
*/
|
|
4912
|
+
private signInProof;
|
|
4913
|
+
/**
|
|
4914
|
+
* Creates this browser's device key when there is none and enrols it for the signed-in session:
|
|
4915
|
+
* a challenge, a `use: "enrol"` proof, `POST /user/device/key`. The server needs a second factor
|
|
4916
|
+
* in the last 10 minutes (else 403 `error.device.key.step_up_required`).
|
|
4917
|
+
*
|
|
4918
|
+
* Any failure emits one `Error` (operation `device-key.enrol`) and rejects. On
|
|
4919
|
+
* `error.device.key.reused` the server has reset the device and ended the session: the key is
|
|
4920
|
+
* deleted and this tab signs out (`SignOut`) first.
|
|
4921
|
+
*/
|
|
4922
|
+
enrolDeviceKey(): Promise<void>;
|
|
4923
|
+
/**
|
|
4924
|
+
* Called by `TwoFactorService` once a sign-in's second factor has completed and its tokens are
|
|
4925
|
+
* applied: enrols the device key, which also binds the new session to it. A failure is already
|
|
4926
|
+
* reported as an `Error` event and does not change the sign-in's result.
|
|
4927
|
+
*/
|
|
4928
|
+
secondFactorCompleted(): Promise<void>;
|
|
4797
4929
|
/** The BFF refresh endpoint. A non-OK answer becomes a `PassflowError`; a network failure rejects as is. */
|
|
4798
4930
|
private sendBffRefresh;
|
|
4799
4931
|
/**
|
|
@@ -5228,6 +5360,8 @@ export interface SignInCompleter {
|
|
|
5228
5360
|
forgetPkceSignIn(): void;
|
|
5229
5361
|
/** Reports a finished sign-in: emits `SignIn` with these tokens, then runs the session check. */
|
|
5230
5362
|
notifySignedIn(tokens: Tokens): Promise<void>;
|
|
5363
|
+
/** Runs once the second factor's tokens are applied (device-key enrolment). Must not reject. */
|
|
5364
|
+
secondFactorCompleted?(): Promise<void>;
|
|
5231
5365
|
}
|
|
5232
5366
|
/**
|
|
5233
5367
|
* Service for managing Two-Factor Authentication
|
|
@@ -7207,6 +7341,17 @@ export declare class Passflow {
|
|
|
7207
7341
|
* ```
|
|
7208
7342
|
*/
|
|
7209
7343
|
refreshToken(): Promise<PassflowAuthorizationResponse>;
|
|
7344
|
+
/**
|
|
7345
|
+
* Creates (if needed) and enrols this browser's device key for the signed-in session, which binds
|
|
7346
|
+
* the session to the key. Needs `deviceKey: true` in the config and a second factor in the last
|
|
7347
|
+
* 10 minutes. A sign-in that completes a second factor already enrols automatically.
|
|
7348
|
+
*
|
|
7349
|
+
* @throws {PassflowError} `error.device.key.step_up_required` (403) without a recent second
|
|
7350
|
+
* factor; `error.device.key.reused` (401) when the server reset the device: the key is deleted
|
|
7351
|
+
* and this tab is signed out. Every failure also emits an `Error` with operation `device-key.enrol`.
|
|
7352
|
+
* @throws {Error} with the option off, in BFF mode, or without IndexedDB and WebCrypto
|
|
7353
|
+
*/
|
|
7354
|
+
enrolDeviceKey(): Promise<void>;
|
|
7210
7355
|
/**
|
|
7211
7356
|
* Send a password reset email to the user.
|
|
7212
7357
|
*
|
|
@@ -8177,4 +8322,4 @@ export declare function isValidPhoneNumber(phone: string): boolean;
|
|
|
8177
8322
|
* @returns true if valid username format, false otherwise
|
|
8178
8323
|
*/
|
|
8179
8324
|
export declare function isValidUsername(username: string): boolean;
|
|
8180
|
-
export type { AntiBotAppSettings, AntiBotDeviceContext, AntiBotOperation, AntiBotTokenContext, AntiBotTokenProvider, AntiBotTokenRequest, AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OidcErrorCode, OpenAuthUrlOptions, OperationErrorPayload, PassflowEmailVerificationOperation, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport, WithAuthOptions };
|
|
8325
|
+
export type { AntiBotAppSettings, AntiBotDeviceContext, AntiBotOperation, AntiBotTokenContext, AntiBotTokenProvider, AntiBotTokenRequest, AssuranceBar, AuthCallbackResult, BodyKind, ChallengeChannel, CreateClientConfig, CurrentUrlInfo, DeviceProofUse, ErrorPayload, EventOrigin, FetchLike, FetchMiddleware, GroupMembership, InvitationToken, M2MClientConfig, M2MErrorCode, M2MErrorResponse, M2MRateLimitInfo, M2MTokenCache, M2MTokenClaims, M2MTokenRequestInfo, M2MTokenRequestOptions, M2MTokenResponse, OidcErrorCode, OpenAuthUrlOptions, OperationErrorPayload, PassflowEmailVerificationOperation, PassflowEventPayload, PassflowOperation, PassflowRefreshErrorOptions, PassflowSubscriber, PasskeySupport, PlatformAdapter, PlatformStorage, RawUserMembership, RefreshChannel, RefreshClock, RefreshCoordination, RefreshCoordinator, RefreshErrorInfo, RefreshFailureKind, RefreshLockManager, RefreshLockOptions, RefreshTrigger, RegisterOptions, ReplayPolicy, RequestSnapshot, ResponseInterceptorHost, RetryStrategy, SessionExpiredReason, SnapshotHeader, Tenant, TenantMembership, Token, UpgradeAssertContext, UpgradeAssertion, UpgradeChallenge, UpgradeCommitInterruptedReason, UpgradeControllerOptions, UpgradeDiagnostic, UpgradeDiagnosticReason, UpgradeDiagnosticSink, UpgradeElevation, UpgradeEnableOptions, UpgradeEndpoint, UpgradeErrorKind, UpgradeFacade, UpgradeFactor, UpgradeFactorInput, UpgradeFactorType, UpgradeFlightState, UpgradeFlightSummary, UpgradeOptions, UpgradePrepared, UpgradePromptHandler, UpgradePromptRequest, UpgradePromptResult, UpgradeProof, UpgradeReplayInfo, UpgradeResult, UpgradeSessionPin, UpgradeTransport, UpgradeTransportErrorInit, UpgradeWaiterSummary, UserMembership, Waiter, WaiterEntry, WaiterOutcome, WaiterReport, WithAuthOptions };
|