@passflow/core 0.35.2 → 0.36.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 +122 -41
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +158 -3
- package/dist/index.d.ts +158 -3
- package/dist/index.mjs +822 -734
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -997,7 +997,9 @@ export declare enum PassflowEndpointPaths {
|
|
|
997
997
|
hostedUpgradeStart = "/auth/session/upgrade/start",
|
|
998
998
|
hostedUpgrade = "/auth/session/upgrade",
|
|
999
999
|
antiBotChallenge = "/auth/anti-bot/challenge",
|
|
1000
|
-
deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge"
|
|
1000
|
+
deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge",
|
|
1001
|
+
enterpriseResolve = "/auth/enterprise/resolve",
|
|
1002
|
+
enterpriseStart = "/auth/enterprise/start"
|
|
1001
1003
|
}
|
|
1002
1004
|
export declare enum PassflowAdminEndpointPaths {
|
|
1003
1005
|
passkeyRegisterStart = "/admin/auth/passkey/register/start",
|
|
@@ -1257,6 +1259,14 @@ export declare const ANTI_BOT_PROVIDER_MISSING_ERROR_ID = "error.anti_bot.provid
|
|
|
1257
1259
|
export declare const ANTI_BOT_PROVIDER_FAILED_ERROR_ID = "error.anti_bot.provider_failed";
|
|
1258
1260
|
/** The built-in proof of work could not be solved: no Web Crypto, a worker error, or no number found. */
|
|
1259
1261
|
export declare const ANTI_BOT_SOLVE_FAILED_ERROR_ID = "error.anti_bot.solve_failed";
|
|
1262
|
+
/** The email is not one plain address (enterprise resolve and start, 400). */
|
|
1263
|
+
export declare const ENTERPRISE_EMAIL_INVALID_ERROR_ID = "error.api.enterprise.email_invalid";
|
|
1264
|
+
/** The enterprise start named neither or both of `connection_id` and `email` (400). */
|
|
1265
|
+
export declare const ENTERPRISE_START_INPUT_ERROR_ID = "error.api.enterprise.start_input";
|
|
1266
|
+
/** No connection the picker shows serves the email's domain (400). */
|
|
1267
|
+
export declare const ENTERPRISE_NO_CONNECTION_ERROR_ID = "error.api.enterprise.no_connection";
|
|
1268
|
+
/** Several connections serve the email's domain: show the picker and start by `connection_id` (400). */
|
|
1269
|
+
export declare const ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID = "error.api.enterprise.connection_ambiguous";
|
|
1260
1270
|
/** The sign-in was refused until the user changes the password; no token comes with it. */
|
|
1261
1271
|
export declare class PassflowPasswordChangeRequiredError extends PassflowError {
|
|
1262
1272
|
constructor(error: PassflowResponseError['error'], options?: {
|
|
@@ -1547,6 +1557,29 @@ export type PassflowFederatedStartBody = {
|
|
|
1547
1557
|
export type PassflowFederatedStartResponse = {
|
|
1548
1558
|
auth_url: string;
|
|
1549
1559
|
};
|
|
1560
|
+
/** The identity provider protocol of an enterprise connection. */
|
|
1561
|
+
export type PassflowEnterpriseProtocol = 'oidc' | 'saml';
|
|
1562
|
+
/** One connection a picker can offer: nothing more of the connection is sent. */
|
|
1563
|
+
export type PassflowEnterpriseConnection = {
|
|
1564
|
+
connection_id: string;
|
|
1565
|
+
display_name: string;
|
|
1566
|
+
protocol: PassflowEnterpriseProtocol;
|
|
1567
|
+
};
|
|
1568
|
+
/** `POST /auth/enterprise/resolve`. `connections` is always an array, empty when not available. */
|
|
1569
|
+
export type PassflowEnterpriseResolveResponse = {
|
|
1570
|
+
available: boolean;
|
|
1571
|
+
connections: PassflowEnterpriseConnection[];
|
|
1572
|
+
};
|
|
1573
|
+
/** Exactly one of a connection id, or an email whose domain has exactly one connection. */
|
|
1574
|
+
export type PassflowEnterpriseTarget = {
|
|
1575
|
+
connection_id: string;
|
|
1576
|
+
email?: never;
|
|
1577
|
+
} | {
|
|
1578
|
+
email: string;
|
|
1579
|
+
connection_id?: never;
|
|
1580
|
+
};
|
|
1581
|
+
/** `POST /auth/enterprise/start`: the federated start body plus the connection or email. */
|
|
1582
|
+
export type PassflowEnterpriseStartBody = PassflowFederatedStartBody & PassflowEnterpriseTarget;
|
|
1550
1583
|
/**
|
|
1551
1584
|
* A write-only app secret that the admin API clears by name with
|
|
1552
1585
|
* `DELETE /admin/apps/{id}/secrets/{name}`. The SDK has no admin client, so this route is not
|
|
@@ -1653,7 +1686,15 @@ export type PassflowPasskeyAuthenticateStartExtendedPayload = PassflowPasskeyAut
|
|
|
1653
1686
|
os: OS;
|
|
1654
1687
|
};
|
|
1655
1688
|
export type PassflowFederatedAuthPayload = {
|
|
1656
|
-
|
|
1689
|
+
/**
|
|
1690
|
+
* A social provider, or `conn_<connection_id>` for an enterprise (OIDC or SAML) connection. The
|
|
1691
|
+
* `connection_id` comes from `enterpriseResolve()`. A "Sign in with SSO" button and its picker
|
|
1692
|
+
* should resolve the email, then run `federatedAuthWithRedirect` or `federatedAuthWithPopup`
|
|
1693
|
+
* with `conn_<connection_id>` (which keep PKCE and the landing exchange), or call
|
|
1694
|
+
* `enterpriseStart()`. They should never use `createEnterpriseAuthUrl()`: a refused GET start
|
|
1695
|
+
* lands on the server's error page, not on the app, and a `human_only` app refuses it with 403.
|
|
1696
|
+
*/
|
|
1697
|
+
provider: Providers | `conn_${string}`;
|
|
1657
1698
|
redirect_url: string;
|
|
1658
1699
|
scopes?: string[];
|
|
1659
1700
|
invite_token?: string;
|
|
@@ -1668,6 +1709,8 @@ export type PassflowFederatedAuthPayload = {
|
|
|
1668
1709
|
export type PassflowFederatedAuthExtendedPayload = PassflowFederatedAuthPayload & {
|
|
1669
1710
|
device?: string;
|
|
1670
1711
|
};
|
|
1712
|
+
/** An enterprise start: the federated start's fields, with the connection or email instead of a provider. */
|
|
1713
|
+
export type PassflowEnterpriseAuthPayload = Omit<PassflowFederatedAuthPayload, 'provider'> & PassflowEnterpriseTarget;
|
|
1671
1714
|
export type PassflowValidatePayload = {
|
|
1672
1715
|
otp: string;
|
|
1673
1716
|
device: string;
|
|
@@ -2228,7 +2271,7 @@ export declare enum PassflowEvent {
|
|
|
2228
2271
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
2229
2272
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
2230
2273
|
*/
|
|
2231
|
-
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'passwordless.wait' | 'passwordless.approval' | 'password-reset.send' | 'password-reset.complete' | 'email-verification.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'federated.redirect' | 'auth-redirect.url' | 'auth-redirect' | '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';
|
|
2274
|
+
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';
|
|
2232
2275
|
/**
|
|
2233
2276
|
* Error payload interface for structured error information
|
|
2234
2277
|
*/
|
|
@@ -2598,6 +2641,8 @@ type AxiosUpgradeHandler = (error: AxiosError, challenge: UpgradeChallenge) => P
|
|
|
2598
2641
|
* `allowStale` is true when the access token is inside the 30 s window but not yet expired: during
|
|
2599
2642
|
* a pending retry the controller then resolves at once and the call goes out with the current
|
|
2600
2643
|
* bearer instead of waiting for the retry.
|
|
2644
|
+
*
|
|
2645
|
+
* In cookie and BFF mode the same handler runs after a 401 instead, with `allowStale` false.
|
|
2601
2646
|
*/
|
|
2602
2647
|
type AxiosRefreshHandler = (request: {
|
|
2603
2648
|
trigger: 'pre-request';
|
|
@@ -2678,6 +2723,13 @@ declare class AxiosClient {
|
|
|
2678
2723
|
*/
|
|
2679
2724
|
replay<T = unknown>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
2680
2725
|
private isProtectedEndpoint;
|
|
2726
|
+
/**
|
|
2727
|
+
* After a 401 in cookie or BFF mode: one refresh through the handler, at most once per request.
|
|
2728
|
+
* True when the session was refreshed and the request is to be sent again. False for a request
|
|
2729
|
+
* that does not carry the session, a second 401 of the same request, a failed refresh and an
|
|
2730
|
+
* ended session: the 401 then stands.
|
|
2731
|
+
*/
|
|
2732
|
+
private refreshedAfterUnauthorized;
|
|
2681
2733
|
private isNonAuthEndpoint;
|
|
2682
2734
|
/**
|
|
2683
2735
|
* Detect if cookies are supported/enabled in the browser.
|
|
@@ -2738,6 +2790,14 @@ export declare class AuthAPI {
|
|
|
2738
2790
|
* challenge cookie the answer sets.
|
|
2739
2791
|
*/
|
|
2740
2792
|
federatedStart(provider: string, body: PassflowFederatedStartBody, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
2793
|
+
/** Which enterprise connections the app offers for the email's domain. Not anti-bot covered. */
|
|
2794
|
+
enterpriseResolve(email: string): Promise<PassflowEnterpriseResolveResponse>;
|
|
2795
|
+
/**
|
|
2796
|
+
* Starts an enterprise sign-in with a POST, which can carry the anti-bot and agent-tool headers,
|
|
2797
|
+
* and answers the URL to navigate to. Sent with credentials, so the browser keeps the challenge
|
|
2798
|
+
* cookie the answer sets. The anti-bot identifier is the email when the start is by email.
|
|
2799
|
+
*/
|
|
2800
|
+
enterpriseStart(body: PassflowEnterpriseStartBody, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
2741
2801
|
/**
|
|
2742
2802
|
* Refreshes the session, optionally committing an assurance upgrade.
|
|
2743
2803
|
*
|
|
@@ -4064,6 +4124,8 @@ interface RefreshController {
|
|
|
4064
4124
|
signOutNow(cleanup: (newest?: string) => void): void;
|
|
4065
4125
|
/** A new session in this tab (sign-in, register, setTokens): new generation, counters reset. */
|
|
4066
4126
|
sessionStarted(): void;
|
|
4127
|
+
/** Counts the sessions of this tab: an answer asked for under an earlier number is not applied. */
|
|
4128
|
+
readonly generation: number;
|
|
4067
4129
|
/** The `sub` this tab's session belongs to. */
|
|
4068
4130
|
identity(): string | undefined;
|
|
4069
4131
|
readonly coordinated: boolean;
|
|
@@ -4238,6 +4300,8 @@ export declare class AuthService {
|
|
|
4238
4300
|
* its answer through here too. `replace` marks a new session: see `StorageManager.saveTokens()`.
|
|
4239
4301
|
*/
|
|
4240
4302
|
private applyAuthResponse;
|
|
4303
|
+
/** Whether the answer's ID or access token names audiences that leave out the current app id. */
|
|
4304
|
+
private issuedForAnotherApp;
|
|
4241
4305
|
/** A registration that leaves the user signed in: `Register`, then `SignIn` with the same payload. */
|
|
4242
4306
|
private notifyRegisteredAndSignedIn;
|
|
4243
4307
|
/**
|
|
@@ -4477,6 +4541,20 @@ export declare class AuthService {
|
|
|
4477
4541
|
* the start there instead.
|
|
4478
4542
|
*/
|
|
4479
4543
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
4544
|
+
/** The query of a GET start: the same fields `federatedStartBody` sends in a POST, as strings. */
|
|
4545
|
+
private federatedStartQuery;
|
|
4546
|
+
/**
|
|
4547
|
+
* The GET enterprise start, for a top-level navigation. Sends the device id and every field
|
|
4548
|
+
* `createFederatedAuthUrl` sends. A `human_only` app refuses it (403): use `enterpriseStart`.
|
|
4549
|
+
* Its refusals land on the server's error page, not on `redirect_url`. It creates no PKCE pair.
|
|
4550
|
+
* @throws Error when no app id is set
|
|
4551
|
+
*/
|
|
4552
|
+
createEnterpriseAuthUrl(payload: PassflowEnterpriseAuthPayload): string;
|
|
4553
|
+
/**
|
|
4554
|
+
* The POST enterprise start. Answers `{auth_url}`, checked to be an http or https address; the
|
|
4555
|
+
* caller navigates to it. Rejects with the server's error otherwise. It creates no PKCE pair.
|
|
4556
|
+
*/
|
|
4557
|
+
enterpriseStart(payload: PassflowEnterpriseAuthPayload, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
4480
4558
|
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload, options?: PassflowAuthOptions): Promise<void>;
|
|
4481
4559
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload, options?: PassflowAuthOptions): void;
|
|
4482
4560
|
/**
|
|
@@ -6645,6 +6723,83 @@ export declare class Passflow {
|
|
|
6645
6723
|
* ```
|
|
6646
6724
|
*/
|
|
6647
6725
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload, options?: PassflowAuthOptions): void;
|
|
6726
|
+
/**
|
|
6727
|
+
* Which enterprise (OIDC or SAML) connections the app offers for the email's domain.
|
|
6728
|
+
*
|
|
6729
|
+
* The email is sent as given; the server checks it. The call is never anti-bot covered.
|
|
6730
|
+
*
|
|
6731
|
+
* @param email - The address the user typed
|
|
6732
|
+
* @returns `{ available, connections }`; `connections` is empty when nothing serves the domain
|
|
6733
|
+
* @throws {PassflowError} `ENTERPRISE_EMAIL_INVALID_ERROR_ID` when the email is not one plain
|
|
6734
|
+
* address. A 429 rejects with the raw HTTP error and is not retried.
|
|
6735
|
+
*
|
|
6736
|
+
* @example
|
|
6737
|
+
* ```typescript
|
|
6738
|
+
* const { available, connections } = await passflow.enterpriseResolve('jane@corp.example');
|
|
6739
|
+
* if (connections.length === 1) {
|
|
6740
|
+
* // Start the one connection
|
|
6741
|
+
* passflow.federatedAuthWithRedirect({
|
|
6742
|
+
* provider: `conn_${connections[0].connection_id}`,
|
|
6743
|
+
* redirect_url: window.location.origin,
|
|
6744
|
+
* });
|
|
6745
|
+
* } else if (available) {
|
|
6746
|
+
* // Show a picker: connection.display_name and connection.protocol
|
|
6747
|
+
* }
|
|
6748
|
+
* ```
|
|
6749
|
+
*/
|
|
6750
|
+
enterpriseResolve(email: string): Promise<PassflowEnterpriseResolveResponse>;
|
|
6751
|
+
/**
|
|
6752
|
+
* The address of a GET enterprise start, for a plain link or a server-rendered page.
|
|
6753
|
+
*
|
|
6754
|
+
* Sends no request and emits no event. A `human_only` app refuses this form with 403, and every
|
|
6755
|
+
* refusal lands on the server's error page, not on the app. A sign-in button and its picker use
|
|
6756
|
+
* `enterpriseStart()` or the federated flows with `conn_<connection_id>` instead. No PKCE pair is
|
|
6757
|
+
* created: on a PKCE app, pass your own `code_challenge` and keep the verifier.
|
|
6758
|
+
*
|
|
6759
|
+
* @param payload - `connection_id` or `email`, plus the federated start fields
|
|
6760
|
+
* @returns The `/auth/enterprise/start?...` URL to navigate to
|
|
6761
|
+
* @throws {Error} When the SDK has no app id
|
|
6762
|
+
*
|
|
6763
|
+
* @example
|
|
6764
|
+
* ```typescript
|
|
6765
|
+
* const url = passflow.createEnterpriseAuthUrl({
|
|
6766
|
+
* connection_id: 'c1',
|
|
6767
|
+
* redirect_url: window.location.origin + '/auth/callback',
|
|
6768
|
+
* });
|
|
6769
|
+
* window.location.assign(url);
|
|
6770
|
+
* ```
|
|
6771
|
+
*/
|
|
6772
|
+
createEnterpriseAuthUrl(payload: PassflowEnterpriseAuthPayload): string;
|
|
6773
|
+
/**
|
|
6774
|
+
* Starts an enterprise sign-in with a POST and answers the address to navigate to.
|
|
6775
|
+
*
|
|
6776
|
+
* Works on every bot mode: on a `human_only` app the request carries the anti-bot header. The
|
|
6777
|
+
* SDK never navigates; the caller does. No PKCE pair is created.
|
|
6778
|
+
*
|
|
6779
|
+
* @param payload - `connection_id` or `email`, plus the federated start fields
|
|
6780
|
+
* @param options - `agentTool` sends `X-Passflow-Agent-Tool: 1`
|
|
6781
|
+
* @returns `{ auth_url }`, an http or https address
|
|
6782
|
+
* @throws {PassflowError} `ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID` when several connections
|
|
6783
|
+
* serve the email's domain (show the picker and start again by `connection_id`),
|
|
6784
|
+
* `ENTERPRISE_NO_CONNECTION_ERROR_ID`, `ENTERPRISE_EMAIL_INVALID_ERROR_ID`,
|
|
6785
|
+
* `ENTERPRISE_START_INPUT_ERROR_ID`, or the federated start's own ids
|
|
6786
|
+
*
|
|
6787
|
+
* @example
|
|
6788
|
+
* ```typescript
|
|
6789
|
+
* try {
|
|
6790
|
+
* const { auth_url } = await passflow.enterpriseStart({
|
|
6791
|
+
* email: 'jane@corp.example',
|
|
6792
|
+
* redirect_url: window.location.origin,
|
|
6793
|
+
* });
|
|
6794
|
+
* window.location.assign(auth_url);
|
|
6795
|
+
* } catch (error) {
|
|
6796
|
+
* if (error instanceof PassflowError && error.id === ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID) {
|
|
6797
|
+
* // Show the picker from enterpriseResolve(), then start by connection_id
|
|
6798
|
+
* }
|
|
6799
|
+
* }
|
|
6800
|
+
* ```
|
|
6801
|
+
*/
|
|
6802
|
+
enterpriseStart(payload: PassflowEnterpriseAuthPayload, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
6648
6803
|
/**
|
|
6649
6804
|
* Reset the SDK state by clearing all tokens and optionally throwing an error.
|
|
6650
6805
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -997,7 +997,9 @@ export declare enum PassflowEndpointPaths {
|
|
|
997
997
|
hostedUpgradeStart = "/auth/session/upgrade/start",
|
|
998
998
|
hostedUpgrade = "/auth/session/upgrade",
|
|
999
999
|
antiBotChallenge = "/auth/anti-bot/challenge",
|
|
1000
|
-
deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge"
|
|
1000
|
+
deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge",
|
|
1001
|
+
enterpriseResolve = "/auth/enterprise/resolve",
|
|
1002
|
+
enterpriseStart = "/auth/enterprise/start"
|
|
1001
1003
|
}
|
|
1002
1004
|
export declare enum PassflowAdminEndpointPaths {
|
|
1003
1005
|
passkeyRegisterStart = "/admin/auth/passkey/register/start",
|
|
@@ -1257,6 +1259,14 @@ export declare const ANTI_BOT_PROVIDER_MISSING_ERROR_ID = "error.anti_bot.provid
|
|
|
1257
1259
|
export declare const ANTI_BOT_PROVIDER_FAILED_ERROR_ID = "error.anti_bot.provider_failed";
|
|
1258
1260
|
/** The built-in proof of work could not be solved: no Web Crypto, a worker error, or no number found. */
|
|
1259
1261
|
export declare const ANTI_BOT_SOLVE_FAILED_ERROR_ID = "error.anti_bot.solve_failed";
|
|
1262
|
+
/** The email is not one plain address (enterprise resolve and start, 400). */
|
|
1263
|
+
export declare const ENTERPRISE_EMAIL_INVALID_ERROR_ID = "error.api.enterprise.email_invalid";
|
|
1264
|
+
/** The enterprise start named neither or both of `connection_id` and `email` (400). */
|
|
1265
|
+
export declare const ENTERPRISE_START_INPUT_ERROR_ID = "error.api.enterprise.start_input";
|
|
1266
|
+
/** No connection the picker shows serves the email's domain (400). */
|
|
1267
|
+
export declare const ENTERPRISE_NO_CONNECTION_ERROR_ID = "error.api.enterprise.no_connection";
|
|
1268
|
+
/** Several connections serve the email's domain: show the picker and start by `connection_id` (400). */
|
|
1269
|
+
export declare const ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID = "error.api.enterprise.connection_ambiguous";
|
|
1260
1270
|
/** The sign-in was refused until the user changes the password; no token comes with it. */
|
|
1261
1271
|
export declare class PassflowPasswordChangeRequiredError extends PassflowError {
|
|
1262
1272
|
constructor(error: PassflowResponseError['error'], options?: {
|
|
@@ -1547,6 +1557,29 @@ export type PassflowFederatedStartBody = {
|
|
|
1547
1557
|
export type PassflowFederatedStartResponse = {
|
|
1548
1558
|
auth_url: string;
|
|
1549
1559
|
};
|
|
1560
|
+
/** The identity provider protocol of an enterprise connection. */
|
|
1561
|
+
export type PassflowEnterpriseProtocol = 'oidc' | 'saml';
|
|
1562
|
+
/** One connection a picker can offer: nothing more of the connection is sent. */
|
|
1563
|
+
export type PassflowEnterpriseConnection = {
|
|
1564
|
+
connection_id: string;
|
|
1565
|
+
display_name: string;
|
|
1566
|
+
protocol: PassflowEnterpriseProtocol;
|
|
1567
|
+
};
|
|
1568
|
+
/** `POST /auth/enterprise/resolve`. `connections` is always an array, empty when not available. */
|
|
1569
|
+
export type PassflowEnterpriseResolveResponse = {
|
|
1570
|
+
available: boolean;
|
|
1571
|
+
connections: PassflowEnterpriseConnection[];
|
|
1572
|
+
};
|
|
1573
|
+
/** Exactly one of a connection id, or an email whose domain has exactly one connection. */
|
|
1574
|
+
export type PassflowEnterpriseTarget = {
|
|
1575
|
+
connection_id: string;
|
|
1576
|
+
email?: never;
|
|
1577
|
+
} | {
|
|
1578
|
+
email: string;
|
|
1579
|
+
connection_id?: never;
|
|
1580
|
+
};
|
|
1581
|
+
/** `POST /auth/enterprise/start`: the federated start body plus the connection or email. */
|
|
1582
|
+
export type PassflowEnterpriseStartBody = PassflowFederatedStartBody & PassflowEnterpriseTarget;
|
|
1550
1583
|
/**
|
|
1551
1584
|
* A write-only app secret that the admin API clears by name with
|
|
1552
1585
|
* `DELETE /admin/apps/{id}/secrets/{name}`. The SDK has no admin client, so this route is not
|
|
@@ -1653,7 +1686,15 @@ export type PassflowPasskeyAuthenticateStartExtendedPayload = PassflowPasskeyAut
|
|
|
1653
1686
|
os: OS;
|
|
1654
1687
|
};
|
|
1655
1688
|
export type PassflowFederatedAuthPayload = {
|
|
1656
|
-
|
|
1689
|
+
/**
|
|
1690
|
+
* A social provider, or `conn_<connection_id>` for an enterprise (OIDC or SAML) connection. The
|
|
1691
|
+
* `connection_id` comes from `enterpriseResolve()`. A "Sign in with SSO" button and its picker
|
|
1692
|
+
* should resolve the email, then run `federatedAuthWithRedirect` or `federatedAuthWithPopup`
|
|
1693
|
+
* with `conn_<connection_id>` (which keep PKCE and the landing exchange), or call
|
|
1694
|
+
* `enterpriseStart()`. They should never use `createEnterpriseAuthUrl()`: a refused GET start
|
|
1695
|
+
* lands on the server's error page, not on the app, and a `human_only` app refuses it with 403.
|
|
1696
|
+
*/
|
|
1697
|
+
provider: Providers | `conn_${string}`;
|
|
1657
1698
|
redirect_url: string;
|
|
1658
1699
|
scopes?: string[];
|
|
1659
1700
|
invite_token?: string;
|
|
@@ -1668,6 +1709,8 @@ export type PassflowFederatedAuthPayload = {
|
|
|
1668
1709
|
export type PassflowFederatedAuthExtendedPayload = PassflowFederatedAuthPayload & {
|
|
1669
1710
|
device?: string;
|
|
1670
1711
|
};
|
|
1712
|
+
/** An enterprise start: the federated start's fields, with the connection or email instead of a provider. */
|
|
1713
|
+
export type PassflowEnterpriseAuthPayload = Omit<PassflowFederatedAuthPayload, 'provider'> & PassflowEnterpriseTarget;
|
|
1671
1714
|
export type PassflowValidatePayload = {
|
|
1672
1715
|
otp: string;
|
|
1673
1716
|
device: string;
|
|
@@ -2228,7 +2271,7 @@ export declare enum PassflowEvent {
|
|
|
2228
2271
|
* The SDK operation that failed (`ErrorPayload.operation`). The SDK sets it on every `Error` it
|
|
2229
2272
|
* emits, so a subscriber can tell a failed sign-in from a failed refresh without parsing messages.
|
|
2230
2273
|
*/
|
|
2231
|
-
type PassflowOperation = 'sign-in' | 'sign-up' | 'passwordless.start' | 'passwordless.complete' | 'passwordless.wait' | 'passwordless.approval' | 'password-reset.send' | 'password-reset.complete' | 'email-verification.complete' | 'passkey.register' | 'passkey.authenticate' | 'federated.popup' | 'federated.redirect' | 'auth-redirect.url' | 'auth-redirect' | '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';
|
|
2274
|
+
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';
|
|
2232
2275
|
/**
|
|
2233
2276
|
* Error payload interface for structured error information
|
|
2234
2277
|
*/
|
|
@@ -2598,6 +2641,8 @@ type AxiosUpgradeHandler = (error: AxiosError, challenge: UpgradeChallenge) => P
|
|
|
2598
2641
|
* `allowStale` is true when the access token is inside the 30 s window but not yet expired: during
|
|
2599
2642
|
* a pending retry the controller then resolves at once and the call goes out with the current
|
|
2600
2643
|
* bearer instead of waiting for the retry.
|
|
2644
|
+
*
|
|
2645
|
+
* In cookie and BFF mode the same handler runs after a 401 instead, with `allowStale` false.
|
|
2601
2646
|
*/
|
|
2602
2647
|
type AxiosRefreshHandler = (request: {
|
|
2603
2648
|
trigger: 'pre-request';
|
|
@@ -2678,6 +2723,13 @@ declare class AxiosClient {
|
|
|
2678
2723
|
*/
|
|
2679
2724
|
replay<T = unknown>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
2680
2725
|
private isProtectedEndpoint;
|
|
2726
|
+
/**
|
|
2727
|
+
* After a 401 in cookie or BFF mode: one refresh through the handler, at most once per request.
|
|
2728
|
+
* True when the session was refreshed and the request is to be sent again. False for a request
|
|
2729
|
+
* that does not carry the session, a second 401 of the same request, a failed refresh and an
|
|
2730
|
+
* ended session: the 401 then stands.
|
|
2731
|
+
*/
|
|
2732
|
+
private refreshedAfterUnauthorized;
|
|
2681
2733
|
private isNonAuthEndpoint;
|
|
2682
2734
|
/**
|
|
2683
2735
|
* Detect if cookies are supported/enabled in the browser.
|
|
@@ -2738,6 +2790,14 @@ export declare class AuthAPI {
|
|
|
2738
2790
|
* challenge cookie the answer sets.
|
|
2739
2791
|
*/
|
|
2740
2792
|
federatedStart(provider: string, body: PassflowFederatedStartBody, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
2793
|
+
/** Which enterprise connections the app offers for the email's domain. Not anti-bot covered. */
|
|
2794
|
+
enterpriseResolve(email: string): Promise<PassflowEnterpriseResolveResponse>;
|
|
2795
|
+
/**
|
|
2796
|
+
* Starts an enterprise sign-in with a POST, which can carry the anti-bot and agent-tool headers,
|
|
2797
|
+
* and answers the URL to navigate to. Sent with credentials, so the browser keeps the challenge
|
|
2798
|
+
* cookie the answer sets. The anti-bot identifier is the email when the start is by email.
|
|
2799
|
+
*/
|
|
2800
|
+
enterpriseStart(body: PassflowEnterpriseStartBody, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
2741
2801
|
/**
|
|
2742
2802
|
* Refreshes the session, optionally committing an assurance upgrade.
|
|
2743
2803
|
*
|
|
@@ -4064,6 +4124,8 @@ interface RefreshController {
|
|
|
4064
4124
|
signOutNow(cleanup: (newest?: string) => void): void;
|
|
4065
4125
|
/** A new session in this tab (sign-in, register, setTokens): new generation, counters reset. */
|
|
4066
4126
|
sessionStarted(): void;
|
|
4127
|
+
/** Counts the sessions of this tab: an answer asked for under an earlier number is not applied. */
|
|
4128
|
+
readonly generation: number;
|
|
4067
4129
|
/** The `sub` this tab's session belongs to. */
|
|
4068
4130
|
identity(): string | undefined;
|
|
4069
4131
|
readonly coordinated: boolean;
|
|
@@ -4238,6 +4300,8 @@ export declare class AuthService {
|
|
|
4238
4300
|
* its answer through here too. `replace` marks a new session: see `StorageManager.saveTokens()`.
|
|
4239
4301
|
*/
|
|
4240
4302
|
private applyAuthResponse;
|
|
4303
|
+
/** Whether the answer's ID or access token names audiences that leave out the current app id. */
|
|
4304
|
+
private issuedForAnotherApp;
|
|
4241
4305
|
/** A registration that leaves the user signed in: `Register`, then `SignIn` with the same payload. */
|
|
4242
4306
|
private notifyRegisteredAndSignedIn;
|
|
4243
4307
|
/**
|
|
@@ -4477,6 +4541,20 @@ export declare class AuthService {
|
|
|
4477
4541
|
* the start there instead.
|
|
4478
4542
|
*/
|
|
4479
4543
|
createFederatedAuthUrl(payload: PassflowFederatedAuthExtendedPayload): string;
|
|
4544
|
+
/** The query of a GET start: the same fields `federatedStartBody` sends in a POST, as strings. */
|
|
4545
|
+
private federatedStartQuery;
|
|
4546
|
+
/**
|
|
4547
|
+
* The GET enterprise start, for a top-level navigation. Sends the device id and every field
|
|
4548
|
+
* `createFederatedAuthUrl` sends. A `human_only` app refuses it (403): use `enterpriseStart`.
|
|
4549
|
+
* Its refusals land on the server's error page, not on `redirect_url`. It creates no PKCE pair.
|
|
4550
|
+
* @throws Error when no app id is set
|
|
4551
|
+
*/
|
|
4552
|
+
createEnterpriseAuthUrl(payload: PassflowEnterpriseAuthPayload): string;
|
|
4553
|
+
/**
|
|
4554
|
+
* The POST enterprise start. Answers `{auth_url}`, checked to be an http or https address; the
|
|
4555
|
+
* caller navigates to it. Rejects with the server's error otherwise. It creates no PKCE pair.
|
|
4556
|
+
*/
|
|
4557
|
+
enterpriseStart(payload: PassflowEnterpriseAuthPayload, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
4480
4558
|
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload, options?: PassflowAuthOptions): Promise<void>;
|
|
4481
4559
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload, options?: PassflowAuthOptions): void;
|
|
4482
4560
|
/**
|
|
@@ -6645,6 +6723,83 @@ export declare class Passflow {
|
|
|
6645
6723
|
* ```
|
|
6646
6724
|
*/
|
|
6647
6725
|
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload, options?: PassflowAuthOptions): void;
|
|
6726
|
+
/**
|
|
6727
|
+
* Which enterprise (OIDC or SAML) connections the app offers for the email's domain.
|
|
6728
|
+
*
|
|
6729
|
+
* The email is sent as given; the server checks it. The call is never anti-bot covered.
|
|
6730
|
+
*
|
|
6731
|
+
* @param email - The address the user typed
|
|
6732
|
+
* @returns `{ available, connections }`; `connections` is empty when nothing serves the domain
|
|
6733
|
+
* @throws {PassflowError} `ENTERPRISE_EMAIL_INVALID_ERROR_ID` when the email is not one plain
|
|
6734
|
+
* address. A 429 rejects with the raw HTTP error and is not retried.
|
|
6735
|
+
*
|
|
6736
|
+
* @example
|
|
6737
|
+
* ```typescript
|
|
6738
|
+
* const { available, connections } = await passflow.enterpriseResolve('jane@corp.example');
|
|
6739
|
+
* if (connections.length === 1) {
|
|
6740
|
+
* // Start the one connection
|
|
6741
|
+
* passflow.federatedAuthWithRedirect({
|
|
6742
|
+
* provider: `conn_${connections[0].connection_id}`,
|
|
6743
|
+
* redirect_url: window.location.origin,
|
|
6744
|
+
* });
|
|
6745
|
+
* } else if (available) {
|
|
6746
|
+
* // Show a picker: connection.display_name and connection.protocol
|
|
6747
|
+
* }
|
|
6748
|
+
* ```
|
|
6749
|
+
*/
|
|
6750
|
+
enterpriseResolve(email: string): Promise<PassflowEnterpriseResolveResponse>;
|
|
6751
|
+
/**
|
|
6752
|
+
* The address of a GET enterprise start, for a plain link or a server-rendered page.
|
|
6753
|
+
*
|
|
6754
|
+
* Sends no request and emits no event. A `human_only` app refuses this form with 403, and every
|
|
6755
|
+
* refusal lands on the server's error page, not on the app. A sign-in button and its picker use
|
|
6756
|
+
* `enterpriseStart()` or the federated flows with `conn_<connection_id>` instead. No PKCE pair is
|
|
6757
|
+
* created: on a PKCE app, pass your own `code_challenge` and keep the verifier.
|
|
6758
|
+
*
|
|
6759
|
+
* @param payload - `connection_id` or `email`, plus the federated start fields
|
|
6760
|
+
* @returns The `/auth/enterprise/start?...` URL to navigate to
|
|
6761
|
+
* @throws {Error} When the SDK has no app id
|
|
6762
|
+
*
|
|
6763
|
+
* @example
|
|
6764
|
+
* ```typescript
|
|
6765
|
+
* const url = passflow.createEnterpriseAuthUrl({
|
|
6766
|
+
* connection_id: 'c1',
|
|
6767
|
+
* redirect_url: window.location.origin + '/auth/callback',
|
|
6768
|
+
* });
|
|
6769
|
+
* window.location.assign(url);
|
|
6770
|
+
* ```
|
|
6771
|
+
*/
|
|
6772
|
+
createEnterpriseAuthUrl(payload: PassflowEnterpriseAuthPayload): string;
|
|
6773
|
+
/**
|
|
6774
|
+
* Starts an enterprise sign-in with a POST and answers the address to navigate to.
|
|
6775
|
+
*
|
|
6776
|
+
* Works on every bot mode: on a `human_only` app the request carries the anti-bot header. The
|
|
6777
|
+
* SDK never navigates; the caller does. No PKCE pair is created.
|
|
6778
|
+
*
|
|
6779
|
+
* @param payload - `connection_id` or `email`, plus the federated start fields
|
|
6780
|
+
* @param options - `agentTool` sends `X-Passflow-Agent-Tool: 1`
|
|
6781
|
+
* @returns `{ auth_url }`, an http or https address
|
|
6782
|
+
* @throws {PassflowError} `ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID` when several connections
|
|
6783
|
+
* serve the email's domain (show the picker and start again by `connection_id`),
|
|
6784
|
+
* `ENTERPRISE_NO_CONNECTION_ERROR_ID`, `ENTERPRISE_EMAIL_INVALID_ERROR_ID`,
|
|
6785
|
+
* `ENTERPRISE_START_INPUT_ERROR_ID`, or the federated start's own ids
|
|
6786
|
+
*
|
|
6787
|
+
* @example
|
|
6788
|
+
* ```typescript
|
|
6789
|
+
* try {
|
|
6790
|
+
* const { auth_url } = await passflow.enterpriseStart({
|
|
6791
|
+
* email: 'jane@corp.example',
|
|
6792
|
+
* redirect_url: window.location.origin,
|
|
6793
|
+
* });
|
|
6794
|
+
* window.location.assign(auth_url);
|
|
6795
|
+
* } catch (error) {
|
|
6796
|
+
* if (error instanceof PassflowError && error.id === ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID) {
|
|
6797
|
+
* // Show the picker from enterpriseResolve(), then start by connection_id
|
|
6798
|
+
* }
|
|
6799
|
+
* }
|
|
6800
|
+
* ```
|
|
6801
|
+
*/
|
|
6802
|
+
enterpriseStart(payload: PassflowEnterpriseAuthPayload, options?: PassflowAuthOptions): Promise<PassflowFederatedStartResponse>;
|
|
6648
6803
|
/**
|
|
6649
6804
|
* Reset the SDK state by clearing all tokens and optionally throwing an error.
|
|
6650
6805
|
*
|