@passflow/core 0.20.0 → 0.21.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 +54 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6362 -0
- package/dist/index.d.ts +6362 -0
- package/dist/index.mjs +2644 -880
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -7
- package/dist/lib/api/app.d.ts +0 -11
- package/dist/lib/api/app.d.ts.map +0 -1
- package/dist/lib/api/auth.d.ts +0 -42
- package/dist/lib/api/auth.d.ts.map +0 -1
- package/dist/lib/api/axios-client.d.ts +0 -109
- package/dist/lib/api/axios-client.d.ts.map +0 -1
- package/dist/lib/api/cli-auth.d.ts +0 -12
- package/dist/lib/api/cli-auth.d.ts.map +0 -1
- package/dist/lib/api/index.d.ts +0 -11
- package/dist/lib/api/index.d.ts.map +0 -1
- package/dist/lib/api/invitation.d.ts +0 -80
- package/dist/lib/api/invitation.d.ts.map +0 -1
- package/dist/lib/api/model.d.ts +0 -844
- package/dist/lib/api/model.d.ts.map +0 -1
- package/dist/lib/api/setting.d.ts +0 -13
- package/dist/lib/api/setting.d.ts.map +0 -1
- package/dist/lib/api/tenant.d.ts +0 -216
- package/dist/lib/api/tenant.d.ts.map +0 -1
- package/dist/lib/api/two-factor.d.ts +0 -137
- package/dist/lib/api/two-factor.d.ts.map +0 -1
- package/dist/lib/api/upgrade.d.ts +0 -39
- package/dist/lib/api/upgrade.d.ts.map +0 -1
- package/dist/lib/api/user.d.ts +0 -22
- package/dist/lib/api/user.d.ts.map +0 -1
- package/dist/lib/constants/index.d.ts +0 -33
- package/dist/lib/constants/index.d.ts.map +0 -1
- package/dist/lib/device/index.d.ts +0 -17
- package/dist/lib/device/index.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -22
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/interceptors/fetch-registry.d.ts +0 -96
- package/dist/lib/interceptors/fetch-registry.d.ts.map +0 -1
- package/dist/lib/m2m/client.d.ts +0 -196
- package/dist/lib/m2m/client.d.ts.map +0 -1
- package/dist/lib/m2m/errors.d.ts +0 -107
- package/dist/lib/m2m/errors.d.ts.map +0 -1
- package/dist/lib/m2m/index.d.ts +0 -27
- package/dist/lib/m2m/index.d.ts.map +0 -1
- package/dist/lib/m2m/types.d.ts +0 -217
- package/dist/lib/m2m/types.d.ts.map +0 -1
- package/dist/lib/passflow.d.ts +0 -1224
- package/dist/lib/passflow.d.ts.map +0 -1
- package/dist/lib/pkce.d.ts +0 -13
- package/dist/lib/pkce.d.ts.map +0 -1
- package/dist/lib/platform/index.d.ts +0 -4
- package/dist/lib/platform/index.d.ts.map +0 -1
- package/dist/lib/platform/types.d.ts +0 -206
- package/dist/lib/platform/types.d.ts.map +0 -1
- package/dist/lib/platform/web-adapter.d.ts +0 -104
- package/dist/lib/platform/web-adapter.d.ts.map +0 -1
- package/dist/lib/services/auth-service.d.ts +0 -197
- package/dist/lib/services/auth-service.d.ts.map +0 -1
- package/dist/lib/services/index.d.ts +0 -8
- package/dist/lib/services/index.d.ts.map +0 -1
- package/dist/lib/services/invitation-service.d.ts +0 -44
- package/dist/lib/services/invitation-service.d.ts.map +0 -1
- package/dist/lib/services/logger.d.ts +0 -24
- package/dist/lib/services/logger.d.ts.map +0 -1
- package/dist/lib/services/tenant-service.d.ts +0 -200
- package/dist/lib/services/tenant-service.d.ts.map +0 -1
- package/dist/lib/services/tenant-user-membership.d.ts +0 -76
- package/dist/lib/services/tenant-user-membership.d.ts.map +0 -1
- package/dist/lib/services/token-cache-service.d.ts +0 -36
- package/dist/lib/services/token-cache-service.d.ts.map +0 -1
- package/dist/lib/services/two-factor-service.d.ts +0 -193
- package/dist/lib/services/two-factor-service.d.ts.map +0 -1
- package/dist/lib/services/user-service.d.ts +0 -41
- package/dist/lib/services/user-service.d.ts.map +0 -1
- package/dist/lib/storage/index.d.ts +0 -106
- package/dist/lib/storage/index.d.ts.map +0 -1
- package/dist/lib/store.d.ts +0 -175
- package/dist/lib/store.d.ts.map +0 -1
- package/dist/lib/token/delivery-manager.d.ts +0 -121
- package/dist/lib/token/delivery-manager.d.ts.map +0 -1
- package/dist/lib/token/index.d.ts +0 -4
- package/dist/lib/token/index.d.ts.map +0 -1
- package/dist/lib/token/membership.d.ts +0 -37
- package/dist/lib/token/membership.d.ts.map +0 -1
- package/dist/lib/token/service.d.ts +0 -47
- package/dist/lib/token/service.d.ts.map +0 -1
- package/dist/lib/token/token.d.ts +0 -55
- package/dist/lib/token/token.d.ts.map +0 -1
- package/dist/lib/types/index.d.ts +0 -24
- package/dist/lib/types/index.d.ts.map +0 -1
- package/dist/lib/upgrade/acr.d.ts +0 -85
- package/dist/lib/upgrade/acr.d.ts.map +0 -1
- package/dist/lib/upgrade/axios-adapter.d.ts +0 -81
- package/dist/lib/upgrade/axios-adapter.d.ts.map +0 -1
- package/dist/lib/upgrade/challenge.d.ts +0 -217
- package/dist/lib/upgrade/challenge.d.ts.map +0 -1
- package/dist/lib/upgrade/client.d.ts +0 -29
- package/dist/lib/upgrade/client.d.ts.map +0 -1
- package/dist/lib/upgrade/controller.d.ts +0 -435
- package/dist/lib/upgrade/controller.d.ts.map +0 -1
- package/dist/lib/upgrade/core.d.ts +0 -353
- package/dist/lib/upgrade/core.d.ts.map +0 -1
- package/dist/lib/upgrade/errors.d.ts +0 -208
- package/dist/lib/upgrade/errors.d.ts.map +0 -1
- package/dist/lib/upgrade/facade.d.ts +0 -188
- package/dist/lib/upgrade/facade.d.ts.map +0 -1
- package/dist/lib/upgrade/factors.d.ts +0 -97
- package/dist/lib/upgrade/factors.d.ts.map +0 -1
- package/dist/lib/upgrade/fetch-adapter.d.ts +0 -30
- package/dist/lib/upgrade/fetch-adapter.d.ts.map +0 -1
- package/dist/lib/upgrade/index.d.ts +0 -17
- package/dist/lib/upgrade/index.d.ts.map +0 -1
- package/dist/lib/upgrade/markers.d.ts +0 -64
- package/dist/lib/upgrade/markers.d.ts.map +0 -1
- package/dist/lib/upgrade/replay.d.ts +0 -132
- package/dist/lib/upgrade/replay.d.ts.map +0 -1
- package/dist/lib/upgrade/select.d.ts +0 -48
- package/dist/lib/upgrade/select.d.ts.map +0 -1
- package/dist/lib/upgrade/session.d.ts +0 -72
- package/dist/lib/upgrade/session.d.ts.map +0 -1
- package/dist/lib/upgrade/snapshot.d.ts +0 -196
- package/dist/lib/upgrade/snapshot.d.ts.map +0 -1
- package/dist/lib/upgrade/transport.d.ts +0 -69
- package/dist/lib/upgrade/transport.d.ts.map +0 -1
- package/dist/lib/utils/validation.d.ts +0 -54
- package/dist/lib/utils/validation.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/dist/lib/passflow.d.ts
DELETED
|
@@ -1,1224 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from 'axios';
|
|
2
|
-
import { type AppSettings, type InvitationsPaginatedList, type InviteLinkResponse, type PassflowAuthorizationResponse, type PassflowConfig, PassflowFederatedAuthPayload, type PassflowPasskeyAuthenticateStartPayload, type PassflowPasskeyRegisterStartPayload, type PassflowPasskeySettings, type PassflowPasswordlessResponse, type PassflowPasswordlessSignInCompletePayload, type PassflowPasswordlessSignInPayload, type PassflowPasswordPolicySettings, type PassflowSendPasswordResetEmailPayload, type PassflowSettingsAll, type PassflowSignInPayload, type PassflowSignUpPayload, type PassflowSuccessResponse, type PassflowTenantResponse, type PassflowValidationResponse, type RequestInviteLinkPayload, type TwoFactorCompletionOptions, type TwoFactorConfirmResponse, type TwoFactorDisableResponse, type TwoFactorRecoveryResponse, type TwoFactorRegenerateResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorTrustedDevice, type TwoFactorVerifyResponse } from './api';
|
|
3
|
-
import { TenantService, TwoFactorService } from './services';
|
|
4
|
-
import { PassflowEvent, type PassflowSubscriber } from './store';
|
|
5
|
-
import { TokenType } from './token';
|
|
6
|
-
import type { ParsedTokens, SessionParams, Tokens } from './types';
|
|
7
|
-
import { type CreateClientConfig, type FetchLike, type ResponseInterceptorHost, type UpgradeFacade } from './upgrade';
|
|
8
|
-
export declare class Passflow {
|
|
9
|
-
/**
|
|
10
|
-
* SDK version string.
|
|
11
|
-
* Useful for debugging and reporting version-specific issues.
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* console.log('Using Passflow SDK version:', Passflow.version);
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
static readonly version: string;
|
|
18
|
-
private authApi;
|
|
19
|
-
private appApi;
|
|
20
|
-
private userApi;
|
|
21
|
-
private settingApi;
|
|
22
|
-
private tenantApi;
|
|
23
|
-
private invitationApi;
|
|
24
|
-
private twoFactorApi;
|
|
25
|
-
private upgradeApi;
|
|
26
|
-
private scopes;
|
|
27
|
-
private createTenantForNewUser;
|
|
28
|
-
private doRefreshTokens;
|
|
29
|
-
private deviceService;
|
|
30
|
-
private storageManager;
|
|
31
|
-
private subscribeStore;
|
|
32
|
-
private authService;
|
|
33
|
-
private userService;
|
|
34
|
-
private tenantService;
|
|
35
|
-
private invitationService;
|
|
36
|
-
private tokenCacheService;
|
|
37
|
-
private twoFactorService;
|
|
38
|
-
tenant: TenantService;
|
|
39
|
-
twoFactor: TwoFactorService;
|
|
40
|
-
/**
|
|
41
|
-
* Step-up (assurance upgrade) wiring. Always present, inert until
|
|
42
|
-
* `enable({ prompt })` is called — constructing a `Passflow` must never patch
|
|
43
|
-
* a global or install a prompt.
|
|
44
|
-
*/
|
|
45
|
-
readonly upgrade: UpgradeFacade;
|
|
46
|
-
/**
|
|
47
|
-
* Passflow's own API as an interception scope ("domain 1"), resolved ONCE
|
|
48
|
-
* here from `PassflowConfig.url` so no adapter or wrapper ever derives it.
|
|
49
|
-
* `null` when no `url` was configured, which is empty — never a throw, and
|
|
50
|
-
* never silent: the first parseable challenge then names `url` as the fix.
|
|
51
|
-
*/
|
|
52
|
-
private readonly upgradeDomain;
|
|
53
|
-
private createSessionCallback?;
|
|
54
|
-
private expiredSessionCallback?;
|
|
55
|
-
private pkceEnabledRead?;
|
|
56
|
-
error?: Error;
|
|
57
|
-
private platform;
|
|
58
|
-
get origin(): string;
|
|
59
|
-
url: string;
|
|
60
|
-
appId?: string;
|
|
61
|
-
constructor(config: PassflowConfig);
|
|
62
|
-
/**
|
|
63
|
-
* Whether the current app wants PKCE. A sign-in asks before a passkey ceremony,
|
|
64
|
-
* where a round-trip eats into the browser's user-gesture window, so the answer
|
|
65
|
-
* is kept for the appId. A failed read is not kept: the next sign-in asks again.
|
|
66
|
-
*/
|
|
67
|
-
private readPkceEnabled;
|
|
68
|
-
/**
|
|
69
|
-
* Update the appId and propagate it to all API clients.
|
|
70
|
-
* This ensures that all future API requests use the new appId in their headers.
|
|
71
|
-
*
|
|
72
|
-
* @param appId - The new application ID to set
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* // Update appId after discovery
|
|
77
|
-
* passflow.setAppId('discovered-app-id-123');
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
setAppId(appId: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Wraps a `fetch`, returning a new function with step-up handling attached.
|
|
83
|
-
*
|
|
84
|
-
* Installs nothing and touches no global — this is the SSR- and
|
|
85
|
-
* React-Native-safe surface. Two verbs exist because the semantics genuinely
|
|
86
|
-
* differ: an axios interceptor mutates, a fetch wrapper returns, and one name
|
|
87
|
-
* would hide which happened.
|
|
88
|
-
*
|
|
89
|
-
* A challenge from Passflow's own API is handled with no further
|
|
90
|
-
* configuration; a challenge from the developer's own backend needs that
|
|
91
|
-
* backend declared via `upgrade.enable({ backend })`.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const authedFetch = passflow.withAuth(fetch);
|
|
96
|
-
* const res = await authedFetch('https://api.example.com/transfer', { method: 'POST' });
|
|
97
|
-
* if (!res.ok && isUpgradeCancelled(res)) {
|
|
98
|
-
* // the user declined the step-up — not an authorization failure
|
|
99
|
-
* }
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
withAuth(next?: FetchLike): FetchLike;
|
|
103
|
-
/**
|
|
104
|
-
* Attaches step-up handling to an axios instance the caller already owns,
|
|
105
|
-
* **mutating** it, and returns a `detach()` disposer.
|
|
106
|
-
*
|
|
107
|
-
* The parameter is typed structurally — duck-typed on
|
|
108
|
-
* `interceptors.response.use` — so this package's axios version is not a
|
|
109
|
-
* constraint on the caller's. It returns the disposer rather than the
|
|
110
|
-
* instance on purpose: it mutates, so returning the instance would read as if
|
|
111
|
-
* it had built something.
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* const api = axios.create({ baseURL: 'https://api.example.com' });
|
|
116
|
-
* const detach = passflow.attachAuth(api);
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
attachAuth(instance: ResponseInterceptorHost): () => void;
|
|
120
|
-
/**
|
|
121
|
-
* Builds a ready axios instance with step-up handling already wired, for a
|
|
122
|
-
* caller with no HTTP client of their own.
|
|
123
|
-
*
|
|
124
|
-
* Pure passthrough of axios' own create options, so `baseURL`, `headers`,
|
|
125
|
-
* `timeout` and `adapter` stay the caller's. A `baseURL` is NOT read as a
|
|
126
|
-
* declared backend — that would derive an interception scope through a side
|
|
127
|
-
* door; declare it with `upgrade.enable({ backend })`.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```typescript
|
|
131
|
-
* const api = passflow.createClient({ baseURL: 'https://api.example.com' });
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
createClient(config?: CreateClientConfig): AxiosInstance;
|
|
135
|
-
/**
|
|
136
|
-
* The assurance bar the session currently holds, read from the `acr` claim of
|
|
137
|
-
* the stored access token.
|
|
138
|
-
*
|
|
139
|
-
* The server scores `acr` and is the only authority; this is the client-side
|
|
140
|
-
* read of what it last said, and it is what lets an `insufficient` outcome
|
|
141
|
-
* report a real `obtained` bar instead of the bar the ceremony was ranked for.
|
|
142
|
-
*/
|
|
143
|
-
private readAssuranceBar;
|
|
144
|
-
/** Every axios client this instance owns, which is every surface a Passflow 401 can arrive on. */
|
|
145
|
-
private axiosClients;
|
|
146
|
-
/**
|
|
147
|
-
* Installs (or clears) §4.4's internal seam on every one of the SDK's own
|
|
148
|
-
* clients.
|
|
149
|
-
*
|
|
150
|
-
* Each client gets a handler bound to its OWN `replay`, so a replayed request
|
|
151
|
-
* goes back out through the instance that issued it. The seam is consulted
|
|
152
|
-
* inside the existing error interceptor, which is where it has to live: axios
|
|
153
|
-
* runs response interceptors FIFO and that handler converts the `AxiosError`
|
|
154
|
-
* into a `PassflowError` with no headers and no config, so anything
|
|
155
|
-
* registered afterwards is structurally too late.
|
|
156
|
-
*/
|
|
157
|
-
private attachUpgradeSeam;
|
|
158
|
-
/**
|
|
159
|
-
* Notifies on a session change, which the facade answers by discarding its
|
|
160
|
-
* controller.
|
|
161
|
-
*
|
|
162
|
-
* `SignIn` and `SignOut` both count: a challenge is server-bound to the
|
|
163
|
-
* session's `sid`, so an elevation abandoned across either boundary must never
|
|
164
|
-
* elevate the NEW session.
|
|
165
|
-
*/
|
|
166
|
-
private subscribeToSessionChange;
|
|
167
|
-
/**
|
|
168
|
-
* Configure session callbacks and check current session status.
|
|
169
|
-
*
|
|
170
|
-
* **WARNING**: Calling this method multiple times will overwrite previously registered callbacks.
|
|
171
|
-
* Only the most recent `createSession` and `expiredSession` callbacks will be active.
|
|
172
|
-
*
|
|
173
|
-
* @param params - Session configuration parameters
|
|
174
|
-
* @param params.createSession - Callback invoked when a valid session exists or is created
|
|
175
|
-
* @param params.expiredSession - Callback invoked when no valid session exists
|
|
176
|
-
* @param params.doRefresh - Whether to automatically refresh expired tokens (default: false)
|
|
177
|
-
* @returns Promise that resolves when session check is complete
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* await passflow.session({
|
|
182
|
-
* createSession: async ({ tokens, parsedTokens }) => {
|
|
183
|
-
* console.log('User is authenticated', parsedTokens?.access_token?.sub);
|
|
184
|
-
* // Initialize user session in your app
|
|
185
|
-
* },
|
|
186
|
-
* expiredSession: async () => {
|
|
187
|
-
* console.log('User session expired');
|
|
188
|
-
* // Redirect to login or show login modal
|
|
189
|
-
* },
|
|
190
|
-
* doRefresh: true // Automatically refresh tokens if expired
|
|
191
|
-
* });
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
session: ({ createSession, expiredSession, doRefresh }: SessionParams) => Promise<void>;
|
|
195
|
-
private submitSessionCheck;
|
|
196
|
-
/**
|
|
197
|
-
* Subscribe to Passflow authentication events.
|
|
198
|
-
*
|
|
199
|
-
* @param subscriber - Subscriber function that receives event type and payload
|
|
200
|
-
* @param events - Optional array of specific events to listen for. If omitted, subscribes to all events.
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```typescript
|
|
204
|
-
* // Subscribe to all events
|
|
205
|
-
* passflow.subscribe((event, payload) => {
|
|
206
|
-
* console.log('Event:', event, payload);
|
|
207
|
-
* });
|
|
208
|
-
*
|
|
209
|
-
* // Subscribe to specific events only
|
|
210
|
-
* passflow.subscribe(
|
|
211
|
-
* (event, payload) => {
|
|
212
|
-
* if (event === PassflowEvent.SignIn) {
|
|
213
|
-
* console.log('User signed in', payload.tokens);
|
|
214
|
-
* }
|
|
215
|
-
* },
|
|
216
|
-
* [PassflowEvent.SignIn, PassflowEvent.SignOut]
|
|
217
|
-
* );
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
subscribe(subscriber: PassflowSubscriber, events?: PassflowEvent[]): void;
|
|
221
|
-
/**
|
|
222
|
-
* Unsubscribe from Passflow authentication events.
|
|
223
|
-
*
|
|
224
|
-
* @param subscriber - The subscriber function to remove
|
|
225
|
-
* @param events - Optional array of specific events to unsubscribe from. If omitted, unsubscribes from all events.
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* ```typescript
|
|
229
|
-
* const subscriber = (event, payload) => console.log(event, payload);
|
|
230
|
-
*
|
|
231
|
-
* // Subscribe
|
|
232
|
-
* passflow.subscribe(subscriber);
|
|
233
|
-
*
|
|
234
|
-
* // Later, unsubscribe
|
|
235
|
-
* passflow.unsubscribe(subscriber);
|
|
236
|
-
* ```
|
|
237
|
-
*/
|
|
238
|
-
unsubscribe(subscriber: PassflowSubscriber, events?: PassflowEvent[]): void;
|
|
239
|
-
/**
|
|
240
|
-
* Handle OAuth redirect callback and extract tokens from URL query parameters.
|
|
241
|
-
* This method should be called on the redirect page after authentication.
|
|
242
|
-
*
|
|
243
|
-
* @returns Tokens object if found in URL, undefined otherwise
|
|
244
|
-
*
|
|
245
|
-
* @example
|
|
246
|
-
* ```typescript
|
|
247
|
-
* // On your redirect page (e.g., /auth/callback)
|
|
248
|
-
* const tokens = passflow.handleTokensRedirect();
|
|
249
|
-
* if (tokens) {
|
|
250
|
-
* console.log('Authentication successful', tokens.access_token);
|
|
251
|
-
* // Tokens are automatically saved to storage
|
|
252
|
-
* }
|
|
253
|
-
* ```
|
|
254
|
-
*/
|
|
255
|
-
handleTokensRedirect(): Tokens | undefined;
|
|
256
|
-
private checkAndSetTokens;
|
|
257
|
-
/**
|
|
258
|
-
* Adopts a `#tfa_token=` fragment: the 2FA token goes to the TwoFactorService
|
|
259
|
-
* through `TwoFactorRequired`, exactly as a password sign-in's does, and the
|
|
260
|
-
* fragment is stripped from the URL. Nothing is saved as a session.
|
|
261
|
-
*
|
|
262
|
-
* @returns true when the URL carried a 2FA token
|
|
263
|
-
*/
|
|
264
|
-
private adoptTwoFactorTokenFromUrl;
|
|
265
|
-
private checkErrorsFromURL;
|
|
266
|
-
private cleanupUrlParams;
|
|
267
|
-
private setTokensToCacheFromLocalStorage;
|
|
268
|
-
/**
|
|
269
|
-
* Get cached tokens from memory without triggering a refresh.
|
|
270
|
-
*
|
|
271
|
-
* @returns Cached tokens or undefined if not cached
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```typescript
|
|
275
|
-
* const tokens = passflow.getCachedTokens();
|
|
276
|
-
* if (tokens) {
|
|
277
|
-
* console.log('Access token:', tokens.access_token);
|
|
278
|
-
* }
|
|
279
|
-
* ```
|
|
280
|
-
*/
|
|
281
|
-
getCachedTokens(): Tokens | undefined;
|
|
282
|
-
/**
|
|
283
|
-
* Get cached tokens from memory and automatically refresh if expired.
|
|
284
|
-
*
|
|
285
|
-
* @returns Promise resolving to tokens or undefined
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```typescript
|
|
289
|
-
* const tokens = await passflow.getTokensWithRefresh();
|
|
290
|
-
* // Tokens are guaranteed to be valid or undefined
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
getTokensWithRefresh(): Promise<Tokens | undefined>;
|
|
294
|
-
/**
|
|
295
|
-
* Get parsed JWT tokens with decoded claims.
|
|
296
|
-
*
|
|
297
|
-
* @returns Parsed token objects with decoded payloads
|
|
298
|
-
*
|
|
299
|
-
* @example
|
|
300
|
-
* ```typescript
|
|
301
|
-
* const parsed = passflow.getParsedTokens();
|
|
302
|
-
* if (parsed?.access_token) {
|
|
303
|
-
* console.log('User ID:', parsed.access_token.sub);
|
|
304
|
-
* console.log('Expires at:', new Date(parsed.access_token.exp * 1000));
|
|
305
|
-
* }
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
getParsedTokens(): ParsedTokens | undefined;
|
|
309
|
-
/**
|
|
310
|
-
* Check if the cached tokens are expired.
|
|
311
|
-
*
|
|
312
|
-
* @returns True if tokens are expired, false otherwise
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* ```typescript
|
|
316
|
-
* if (passflow.areTokensExpired()) {
|
|
317
|
-
* await passflow.refreshToken();
|
|
318
|
-
* }
|
|
319
|
-
* ```
|
|
320
|
-
*/
|
|
321
|
-
areTokensExpired(): boolean;
|
|
322
|
-
/**
|
|
323
|
-
* Check if the user is currently authenticated with valid tokens.
|
|
324
|
-
*
|
|
325
|
-
* @returns True if user has valid, non-expired tokens
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```typescript
|
|
329
|
-
* if (passflow.isAuthenticated()) {
|
|
330
|
-
* console.log('User is logged in');
|
|
331
|
-
* } else {
|
|
332
|
-
* console.log('User needs to sign in');
|
|
333
|
-
* }
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
isAuthenticated(): boolean;
|
|
337
|
-
/**
|
|
338
|
-
* Sign in a user with email/username and password.
|
|
339
|
-
*
|
|
340
|
-
* @param payload - Sign-in credentials and options
|
|
341
|
-
* @param payload.email - User's email or username
|
|
342
|
-
* @param payload.password - User's password
|
|
343
|
-
* @param payload.scopes - Optional scopes to request (defaults to SDK scopes)
|
|
344
|
-
* @returns Promise with authorization response containing tokens
|
|
345
|
-
* @throws {PassflowError} If authentication fails
|
|
346
|
-
*
|
|
347
|
-
* @example
|
|
348
|
-
* ```typescript
|
|
349
|
-
* try {
|
|
350
|
-
* const response = await passflow.signIn({
|
|
351
|
-
* email: 'user@example.com',
|
|
352
|
-
* password: 'secure-password'
|
|
353
|
-
* });
|
|
354
|
-
* console.log('Signed in successfully', response.access_token);
|
|
355
|
-
* } catch (error) {
|
|
356
|
-
* console.error('Sign in failed', error.message);
|
|
357
|
-
* }
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
signIn(payload: PassflowSignInPayload): Promise<PassflowAuthorizationResponse>;
|
|
361
|
-
/**
|
|
362
|
-
* Register a new user account with email and password.
|
|
363
|
-
*
|
|
364
|
-
* @param payload - Registration details
|
|
365
|
-
* @param payload.email - User's email address
|
|
366
|
-
* @param payload.password - User's password
|
|
367
|
-
* @param payload.username - Optional username
|
|
368
|
-
* @param payload.scopes - Optional scopes to request
|
|
369
|
-
* @returns Promise with authorization response containing tokens
|
|
370
|
-
* @throws {PassflowError} If registration fails
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* ```typescript
|
|
374
|
-
* try {
|
|
375
|
-
* const response = await passflow.signUp({
|
|
376
|
-
* email: 'newuser@example.com',
|
|
377
|
-
* password: 'secure-password',
|
|
378
|
-
* username: 'newuser'
|
|
379
|
-
* });
|
|
380
|
-
* console.log('Account created', response.access_token);
|
|
381
|
-
* } catch (error) {
|
|
382
|
-
* console.error('Sign up failed', error.message);
|
|
383
|
-
* }
|
|
384
|
-
* ```
|
|
385
|
-
*/
|
|
386
|
-
signUp(payload: PassflowSignUpPayload): Promise<PassflowAuthorizationResponse>;
|
|
387
|
-
/**
|
|
388
|
-
* Initiate passwordless authentication by sending a magic link or OTP.
|
|
389
|
-
*
|
|
390
|
-
* @param payload - Passwordless sign-in configuration
|
|
391
|
-
* @param payload.email - User's email address
|
|
392
|
-
* @param payload.method - Delivery method ('email' or 'sms')
|
|
393
|
-
* @returns Promise with response indicating if the code was sent
|
|
394
|
-
* @throws {PassflowError} If request fails
|
|
395
|
-
*
|
|
396
|
-
* @example
|
|
397
|
-
* ```typescript
|
|
398
|
-
* // Send magic link via email
|
|
399
|
-
* const response = await passflow.passwordlessSignIn({
|
|
400
|
-
* email: 'user@example.com',
|
|
401
|
-
* method: 'email'
|
|
402
|
-
* });
|
|
403
|
-
* console.log('Magic link sent:', response.success);
|
|
404
|
-
* ```
|
|
405
|
-
*/
|
|
406
|
-
passwordlessSignIn(payload: PassflowPasswordlessSignInPayload): Promise<PassflowPasswordlessResponse>;
|
|
407
|
-
/**
|
|
408
|
-
* Complete passwordless authentication by verifying the OTP or token.
|
|
409
|
-
*
|
|
410
|
-
* @param payload - Verification payload
|
|
411
|
-
* @param payload.email - User's email address
|
|
412
|
-
* @param payload.code - Verification code from email/SMS
|
|
413
|
-
* @param payload.scopes - Optional scopes to request
|
|
414
|
-
* @returns Promise with validation response containing tokens
|
|
415
|
-
* @throws {PassflowError} If verification fails
|
|
416
|
-
*
|
|
417
|
-
* @example
|
|
418
|
-
* ```typescript
|
|
419
|
-
* try {
|
|
420
|
-
* const response = await passflow.passwordlessSignInComplete({
|
|
421
|
-
* email: 'user@example.com',
|
|
422
|
-
* code: '123456'
|
|
423
|
-
* });
|
|
424
|
-
* console.log('Passwordless sign-in complete', response.access_token);
|
|
425
|
-
* } catch (error) {
|
|
426
|
-
* console.error('Invalid code', error.message);
|
|
427
|
-
* }
|
|
428
|
-
* ```
|
|
429
|
-
*/
|
|
430
|
-
passwordlessSignInComplete(payload: PassflowPasswordlessSignInCompletePayload): Promise<PassflowValidationResponse>;
|
|
431
|
-
/**
|
|
432
|
-
* Centralized error handler for all public methods.
|
|
433
|
-
* Creates proper ErrorPayload, distinguishes PassflowError from generic Error,
|
|
434
|
-
* notifies error event, and re-throws the error.
|
|
435
|
-
*
|
|
436
|
-
* @param error - The error to handle
|
|
437
|
-
* @param context - Context description for the error
|
|
438
|
-
* @throws The original error after handling
|
|
439
|
-
*/
|
|
440
|
-
private handleError;
|
|
441
|
-
/**
|
|
442
|
-
* Sign out the current user and clear all tokens.
|
|
443
|
-
*
|
|
444
|
-
* @returns Promise that resolves when sign-out is complete
|
|
445
|
-
* @throws {PassflowError} If sign-out request fails
|
|
446
|
-
*
|
|
447
|
-
* @example
|
|
448
|
-
* ```typescript
|
|
449
|
-
* try {
|
|
450
|
-
* await passflow.logOut();
|
|
451
|
-
* console.log('User signed out successfully');
|
|
452
|
-
* // Redirect to login page
|
|
453
|
-
* } catch (error) {
|
|
454
|
-
* console.error('Sign out failed', error.message);
|
|
455
|
-
* }
|
|
456
|
-
* ```
|
|
457
|
-
*/
|
|
458
|
-
logOut(): Promise<void>;
|
|
459
|
-
/**
|
|
460
|
-
* Initiate federated authentication (OAuth) with a popup window.
|
|
461
|
-
*
|
|
462
|
-
* @param payload - Federated authentication configuration
|
|
463
|
-
* @param payload.provider - OAuth provider (e.g., 'google', 'github', 'microsoft')
|
|
464
|
-
* @param payload.scopes - Optional scopes to request
|
|
465
|
-
*
|
|
466
|
-
* @example
|
|
467
|
-
* ```typescript
|
|
468
|
-
* // Sign in with Google using a popup
|
|
469
|
-
* passflow.federatedAuthWithPopup({
|
|
470
|
-
* provider: 'google'
|
|
471
|
-
* });
|
|
472
|
-
*
|
|
473
|
-
* // Listen for the result via subscribe
|
|
474
|
-
* passflow.subscribe((event, payload) => {
|
|
475
|
-
* if (event === PassflowEvent.SignIn) {
|
|
476
|
-
* console.log('OAuth sign-in successful', payload.tokens);
|
|
477
|
-
* }
|
|
478
|
-
* });
|
|
479
|
-
* ```
|
|
480
|
-
*/
|
|
481
|
-
federatedAuthWithPopup(payload: PassflowFederatedAuthPayload): void;
|
|
482
|
-
/**
|
|
483
|
-
* Initiate federated authentication (OAuth) with a full-page redirect.
|
|
484
|
-
*
|
|
485
|
-
* @param payload - Federated authentication configuration
|
|
486
|
-
* @param payload.provider - OAuth provider (e.g., 'google', 'github', 'microsoft')
|
|
487
|
-
* @param payload.scopes - Optional scopes to request
|
|
488
|
-
* @param payload.redirectUrl - URL to redirect to after authentication
|
|
489
|
-
*
|
|
490
|
-
* @example
|
|
491
|
-
* ```typescript
|
|
492
|
-
* // Sign in with GitHub using redirect
|
|
493
|
-
* passflow.federatedAuthWithRedirect({
|
|
494
|
-
* provider: 'github',
|
|
495
|
-
* redirectUrl: window.location.origin + '/auth/callback'
|
|
496
|
-
* });
|
|
497
|
-
* ```
|
|
498
|
-
*/
|
|
499
|
-
federatedAuthWithRedirect(payload: PassflowFederatedAuthPayload): void;
|
|
500
|
-
/**
|
|
501
|
-
* Reset the SDK state by clearing all tokens and optionally throwing an error.
|
|
502
|
-
*
|
|
503
|
-
* @param error - Optional error message to throw after reset
|
|
504
|
-
* @throws {Error} If error message is provided
|
|
505
|
-
*
|
|
506
|
-
* @example
|
|
507
|
-
* ```typescript
|
|
508
|
-
* // Clear tokens without error
|
|
509
|
-
* passflow.reset();
|
|
510
|
-
*
|
|
511
|
-
* // Clear tokens and throw error
|
|
512
|
-
* try {
|
|
513
|
-
* passflow.reset('Session expired');
|
|
514
|
-
* } catch (error) {
|
|
515
|
-
* console.error('Reset error:', error.message);
|
|
516
|
-
* }
|
|
517
|
-
* ```
|
|
518
|
-
*/
|
|
519
|
-
reset(error?: string): void;
|
|
520
|
-
/**
|
|
521
|
-
* Refresh the access token using the refresh token.
|
|
522
|
-
*
|
|
523
|
-
* @returns Promise with new authorization response containing refreshed tokens
|
|
524
|
-
* @throws {Error} If no refresh token is found
|
|
525
|
-
* @throws {PassflowError} If refresh request fails
|
|
526
|
-
*
|
|
527
|
-
* @example
|
|
528
|
-
* ```typescript
|
|
529
|
-
* try {
|
|
530
|
-
* const response = await passflow.refreshToken();
|
|
531
|
-
* console.log('Token refreshed', response.access_token);
|
|
532
|
-
* } catch (error) {
|
|
533
|
-
* console.error('Failed to refresh token', error.message);
|
|
534
|
-
* // Redirect to login
|
|
535
|
-
* }
|
|
536
|
-
* ```
|
|
537
|
-
*/
|
|
538
|
-
refreshToken(): Promise<PassflowAuthorizationResponse>;
|
|
539
|
-
/**
|
|
540
|
-
* Send a password reset email to the user.
|
|
541
|
-
*
|
|
542
|
-
* @param payload - Password reset request
|
|
543
|
-
* @param payload.email - User's email address
|
|
544
|
-
* @returns Promise with success response
|
|
545
|
-
* @throws {PassflowError} If request fails
|
|
546
|
-
*
|
|
547
|
-
* @example
|
|
548
|
-
* ```typescript
|
|
549
|
-
* try {
|
|
550
|
-
* await passflow.sendPasswordResetEmail({
|
|
551
|
-
* email: 'user@example.com'
|
|
552
|
-
* });
|
|
553
|
-
* console.log('Password reset email sent');
|
|
554
|
-
* } catch (error) {
|
|
555
|
-
* console.error('Failed to send reset email', error.message);
|
|
556
|
-
* }
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload): Promise<PassflowSuccessResponse>;
|
|
560
|
-
/**
|
|
561
|
-
* Reset password using a reset token (typically from URL after clicking email link).
|
|
562
|
-
*
|
|
563
|
-
* @param newPassword - The new password to set
|
|
564
|
-
* @param scopes - Optional scopes to request after reset
|
|
565
|
-
* @returns Promise with authorization response containing new tokens
|
|
566
|
-
* @throws {PassflowError} If reset fails
|
|
567
|
-
*
|
|
568
|
-
* @example
|
|
569
|
-
* ```typescript
|
|
570
|
-
* // On password reset page (e.g., /reset-password?token=xyz)
|
|
571
|
-
* try {
|
|
572
|
-
* const response = await passflow.resetPassword('new-secure-password');
|
|
573
|
-
* console.log('Password reset successful', response.access_token);
|
|
574
|
-
* } catch (error) {
|
|
575
|
-
* console.error('Password reset failed', error.message);
|
|
576
|
-
* }
|
|
577
|
-
* ```
|
|
578
|
-
*/
|
|
579
|
-
resetPassword(newPassword: string, scopes?: string[]): Promise<PassflowAuthorizationResponse>;
|
|
580
|
-
/**
|
|
581
|
-
* Get application settings and configuration.
|
|
582
|
-
*
|
|
583
|
-
* @returns Promise with app settings including branding, features, and config
|
|
584
|
-
* @throws {PassflowError} If request fails
|
|
585
|
-
*
|
|
586
|
-
* @example
|
|
587
|
-
* ```typescript
|
|
588
|
-
* const settings = await passflow.getAppSettings();
|
|
589
|
-
* console.log('App name:', settings.name);
|
|
590
|
-
* console.log('Passwordless enabled:', settings.passwordless_enabled);
|
|
591
|
-
* ```
|
|
592
|
-
*/
|
|
593
|
-
getAppSettings(): Promise<AppSettings>;
|
|
594
|
-
/**
|
|
595
|
-
* Get all Passflow settings including password policy, passkey settings, etc.
|
|
596
|
-
*
|
|
597
|
-
* @returns Promise with all settings
|
|
598
|
-
* @throws {PassflowError} If request fails
|
|
599
|
-
*
|
|
600
|
-
* @example
|
|
601
|
-
* ```typescript
|
|
602
|
-
* const settings = await passflow.getSettingsAll();
|
|
603
|
-
* console.log('Password policy:', settings.password_policy);
|
|
604
|
-
* console.log('Passkey settings:', settings.passkey);
|
|
605
|
-
* ```
|
|
606
|
-
*/
|
|
607
|
-
getSettingsAll(): Promise<PassflowSettingsAll>;
|
|
608
|
-
/**
|
|
609
|
-
* Get password policy settings (min length, complexity requirements, etc.).
|
|
610
|
-
*
|
|
611
|
-
* @returns Promise with password policy configuration
|
|
612
|
-
* @throws {PassflowError} If request fails
|
|
613
|
-
*
|
|
614
|
-
* @example
|
|
615
|
-
* ```typescript
|
|
616
|
-
* const policy = await passflow.getPasswordPolicySettings();
|
|
617
|
-
* console.log('Min length:', policy.min_length);
|
|
618
|
-
* console.log('Require uppercase:', policy.require_uppercase);
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
getPasswordPolicySettings(): Promise<PassflowPasswordPolicySettings>;
|
|
622
|
-
/**
|
|
623
|
-
* Get passkey (WebAuthn) configuration settings.
|
|
624
|
-
*
|
|
625
|
-
* @returns Promise with passkey settings
|
|
626
|
-
* @throws {PassflowError} If request fails
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```typescript
|
|
630
|
-
* const passkeySettings = await passflow.getPasskeySettings();
|
|
631
|
-
* console.log('Passkeys enabled:', passkeySettings.enabled);
|
|
632
|
-
* console.log('User verification:', passkeySettings.user_verification);
|
|
633
|
-
* ```
|
|
634
|
-
*/
|
|
635
|
-
getPasskeySettings(): Promise<PassflowPasskeySettings>;
|
|
636
|
-
/**
|
|
637
|
-
* Register a new user with a passkey (WebAuthn).
|
|
638
|
-
*
|
|
639
|
-
* @param payload - Passkey registration configuration
|
|
640
|
-
* @param payload.email - User's email address
|
|
641
|
-
* @param payload.username - Optional username
|
|
642
|
-
* @param payload.scopes - Optional scopes to request
|
|
643
|
-
* @returns Promise with authorization response containing tokens
|
|
644
|
-
* @throws {PassflowError} If passkey registration fails
|
|
645
|
-
*
|
|
646
|
-
* @example
|
|
647
|
-
* ```typescript
|
|
648
|
-
* try {
|
|
649
|
-
* const response = await passflow.passkeyRegister({
|
|
650
|
-
* email: 'user@example.com',
|
|
651
|
-
* username: 'myusername'
|
|
652
|
-
* });
|
|
653
|
-
* console.log('Passkey registered', response.access_token);
|
|
654
|
-
* } catch (error) {
|
|
655
|
-
* console.error('Passkey registration failed', error.message);
|
|
656
|
-
* }
|
|
657
|
-
* ```
|
|
658
|
-
*/
|
|
659
|
-
passkeyRegister(payload: PassflowPasskeyRegisterStartPayload): Promise<PassflowAuthorizationResponse>;
|
|
660
|
-
/**
|
|
661
|
-
* Authenticate a user with a passkey (WebAuthn).
|
|
662
|
-
*
|
|
663
|
-
* @param payload - Passkey authentication configuration
|
|
664
|
-
* @param payload.email - Optional user email to pre-fill
|
|
665
|
-
* @param payload.scopes - Optional scopes to request
|
|
666
|
-
* @returns Promise with authorization response containing tokens
|
|
667
|
-
* @throws {PassflowError} If passkey authentication fails
|
|
668
|
-
*
|
|
669
|
-
* @example
|
|
670
|
-
* ```typescript
|
|
671
|
-
* try {
|
|
672
|
-
* // Let user select from available passkeys
|
|
673
|
-
* const response = await passflow.passkeyAuthenticate({});
|
|
674
|
-
* console.log('Passkey sign-in successful', response.access_token);
|
|
675
|
-
* } catch (error) {
|
|
676
|
-
* console.error('Passkey authentication failed', error.message);
|
|
677
|
-
* }
|
|
678
|
-
* ```
|
|
679
|
-
*/
|
|
680
|
-
passkeyAuthenticate(payload: PassflowPasskeyAuthenticateStartPayload): Promise<PassflowAuthorizationResponse>;
|
|
681
|
-
/**
|
|
682
|
-
* Manually set tokens (useful after custom authentication flows).
|
|
683
|
-
* This will save tokens to storage, update cache, and trigger SignIn event.
|
|
684
|
-
*
|
|
685
|
-
* @param tokensData - Tokens object to set
|
|
686
|
-
* @param tokensData.access_token - JWT access token
|
|
687
|
-
* @param tokensData.refresh_token - Optional refresh token
|
|
688
|
-
* @param tokensData.id_token - Optional ID token
|
|
689
|
-
* @param tokensData.scopes - Token scopes
|
|
690
|
-
*
|
|
691
|
-
* @example
|
|
692
|
-
* ```typescript
|
|
693
|
-
* // Set tokens from a custom auth flow
|
|
694
|
-
* passflow.setTokens({
|
|
695
|
-
* access_token: 'eyJhbGci...',
|
|
696
|
-
* refresh_token: 'eyJhbGci...',
|
|
697
|
-
* id_token: 'eyJhbGci...',
|
|
698
|
-
* scopes: ['id', 'offline', 'email']
|
|
699
|
-
* });
|
|
700
|
-
* ```
|
|
701
|
-
*/
|
|
702
|
-
setTokens(tokensData: Tokens): void;
|
|
703
|
-
/**
|
|
704
|
-
* Get current tokens from storage, optionally refreshing if expired.
|
|
705
|
-
*
|
|
706
|
-
* @param doRefresh - If true, automatically refresh expired tokens (default: false)
|
|
707
|
-
* @returns Promise with tokens or undefined if not authenticated
|
|
708
|
-
*
|
|
709
|
-
* @example
|
|
710
|
-
* ```typescript
|
|
711
|
-
* // Get tokens without refresh
|
|
712
|
-
* const tokens = await passflow.getTokens();
|
|
713
|
-
*
|
|
714
|
-
* // Get tokens and auto-refresh if expired
|
|
715
|
-
* const freshTokens = await passflow.getTokens(true);
|
|
716
|
-
* ```
|
|
717
|
-
*/
|
|
718
|
-
getTokens(doRefresh?: boolean): Promise<Tokens | undefined>;
|
|
719
|
-
/**
|
|
720
|
-
* Get a specific token from storage by type.
|
|
721
|
-
*
|
|
722
|
-
* @param tokenType - Type of token to retrieve ('access_token', 'refresh_token', 'id_token')
|
|
723
|
-
* @returns Token string or undefined if not found
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* ```typescript
|
|
727
|
-
* const accessToken = passflow.getToken('access_token');
|
|
728
|
-
* if (accessToken) {
|
|
729
|
-
* // Use token for API calls
|
|
730
|
-
* fetch('/api/data', {
|
|
731
|
-
* headers: { Authorization: `Bearer ${accessToken}` }
|
|
732
|
-
* });
|
|
733
|
-
* }
|
|
734
|
-
* ```
|
|
735
|
-
*/
|
|
736
|
-
getToken(tokenType: TokenType): string | undefined;
|
|
737
|
-
/**
|
|
738
|
-
* Get list of passkeys registered for the current user.
|
|
739
|
-
*
|
|
740
|
-
* @returns Promise with array of user's passkeys
|
|
741
|
-
* @throws {PassflowError} If request fails
|
|
742
|
-
*
|
|
743
|
-
* @example
|
|
744
|
-
* ```typescript
|
|
745
|
-
* const passkeys = await passflow.getUserPasskeys();
|
|
746
|
-
* passkeys.forEach(passkey => {
|
|
747
|
-
* console.log('Passkey:', passkey.name, passkey.id);
|
|
748
|
-
* });
|
|
749
|
-
* ```
|
|
750
|
-
*/
|
|
751
|
-
getUserPasskeys(): Promise<import("./api").PassflowUserPasskey[]>;
|
|
752
|
-
/**
|
|
753
|
-
* Rename a user's passkey to a friendly name.
|
|
754
|
-
*
|
|
755
|
-
* @param name - New friendly name for the passkey
|
|
756
|
-
* @param passkeyId - ID of the passkey to rename
|
|
757
|
-
* @returns Promise with success response
|
|
758
|
-
* @throws {PassflowError} If request fails
|
|
759
|
-
*
|
|
760
|
-
* @example
|
|
761
|
-
* ```typescript
|
|
762
|
-
* await passflow.renameUserPasskey('My MacBook Pro', 'passkey-123');
|
|
763
|
-
* console.log('Passkey renamed successfully');
|
|
764
|
-
* ```
|
|
765
|
-
*/
|
|
766
|
-
renameUserPasskey(name: string, passkeyId: string): Promise<PassflowSuccessResponse>;
|
|
767
|
-
/**
|
|
768
|
-
* Delete a passkey from the user's account.
|
|
769
|
-
*
|
|
770
|
-
* @param passkeyId - ID of the passkey to delete
|
|
771
|
-
* @returns Promise with success response
|
|
772
|
-
* @throws {PassflowError} If request fails
|
|
773
|
-
*
|
|
774
|
-
* @example
|
|
775
|
-
* ```typescript
|
|
776
|
-
* await passflow.deleteUserPasskey('passkey-123');
|
|
777
|
-
* console.log('Passkey deleted successfully');
|
|
778
|
-
* ```
|
|
779
|
-
*/
|
|
780
|
-
deleteUserPasskey(passkeyId: string): Promise<PassflowSuccessResponse>;
|
|
781
|
-
/**
|
|
782
|
-
* Add a new passkey to the current user's account (requires active session).
|
|
783
|
-
*
|
|
784
|
-
* @param options - Optional passkey configuration
|
|
785
|
-
* @param options.relyingPartyId - Optional RP ID for the passkey
|
|
786
|
-
* @param options.passkeyUsername - Optional username to associate with passkey
|
|
787
|
-
* @param options.passkeyDisplayName - Optional display name for the passkey
|
|
788
|
-
* @returns Promise that resolves when passkey is added
|
|
789
|
-
* @throws {PassflowError} If request fails
|
|
790
|
-
*
|
|
791
|
-
* @example
|
|
792
|
-
* ```typescript
|
|
793
|
-
* // Add passkey with default settings
|
|
794
|
-
* await passflow.addUserPasskey();
|
|
795
|
-
*
|
|
796
|
-
* // Add passkey with custom display name
|
|
797
|
-
* await passflow.addUserPasskey({
|
|
798
|
-
* passkeyDisplayName: 'My iPhone'
|
|
799
|
-
* });
|
|
800
|
-
* ```
|
|
801
|
-
*/
|
|
802
|
-
addUserPasskey(options?: {
|
|
803
|
-
relyingPartyId?: string;
|
|
804
|
-
passkeyUsername?: string;
|
|
805
|
-
passkeyDisplayName?: string;
|
|
806
|
-
}): Promise<void>;
|
|
807
|
-
/**
|
|
808
|
-
* Join a tenant invitation
|
|
809
|
-
* @param token The invitation token
|
|
810
|
-
* @param scopes Optional scopes to request
|
|
811
|
-
* @returns Promise with invite response
|
|
812
|
-
*/
|
|
813
|
-
joinInvitation(token: string, scopes?: string[]): Promise<PassflowAuthorizationResponse>;
|
|
814
|
-
/**
|
|
815
|
-
* Create a new tenant
|
|
816
|
-
* @param name The name of the tenant
|
|
817
|
-
* @param refreshToken Whether to refresh the token after creating the tenant
|
|
818
|
-
* @returns Promise with tenant response
|
|
819
|
-
*/
|
|
820
|
-
createTenant(name: string, refreshToken?: boolean): Promise<PassflowTenantResponse>;
|
|
821
|
-
/**
|
|
822
|
-
* Request an invitation link for a user to join a tenant.
|
|
823
|
-
*
|
|
824
|
-
* @param payload - Invitation request configuration
|
|
825
|
-
* @param payload.email - Email address to send invitation to
|
|
826
|
-
* @param payload.tenantID - Tenant ID for the invitation
|
|
827
|
-
* @param payload.send_to_email - Whether to send email automatically (default: true)
|
|
828
|
-
* @returns Promise with invitation link response
|
|
829
|
-
* @throws {PassflowError} If request fails
|
|
830
|
-
*
|
|
831
|
-
* @example
|
|
832
|
-
* ```typescript
|
|
833
|
-
* const invitation = await passflow.requestInviteLink({
|
|
834
|
-
* email: 'newuser@example.com',
|
|
835
|
-
* tenantID: 'tenant-123',
|
|
836
|
-
* send_to_email: true
|
|
837
|
-
* });
|
|
838
|
-
* console.log('Invitation link:', invitation.link);
|
|
839
|
-
* ```
|
|
840
|
-
*/
|
|
841
|
-
requestInviteLink(payload: RequestInviteLinkPayload): Promise<InviteLinkResponse>;
|
|
842
|
-
/**
|
|
843
|
-
* Gets a list of active invitations
|
|
844
|
-
* @param options Optional parameters for filtering and pagination
|
|
845
|
-
* @returns Promise with paginated list of invitations
|
|
846
|
-
*/
|
|
847
|
-
getInvitations(options: {
|
|
848
|
-
tenantID: string;
|
|
849
|
-
groupID?: string;
|
|
850
|
-
skip?: number | string;
|
|
851
|
-
limit?: number | string;
|
|
852
|
-
}): Promise<InvitationsPaginatedList>;
|
|
853
|
-
/**
|
|
854
|
-
* Delete an invitation by its token.
|
|
855
|
-
*
|
|
856
|
-
* @param token - Invitation token to delete
|
|
857
|
-
* @returns Promise with success response
|
|
858
|
-
* @throws {PassflowError} If request fails
|
|
859
|
-
*
|
|
860
|
-
* @example
|
|
861
|
-
* ```typescript
|
|
862
|
-
* await passflow.deleteInvitation('invitation-token-123');
|
|
863
|
-
* console.log('Invitation deleted');
|
|
864
|
-
* ```
|
|
865
|
-
*/
|
|
866
|
-
deleteInvitation(token: string): Promise<PassflowSuccessResponse>;
|
|
867
|
-
/**
|
|
868
|
-
* Resend an invitation email.
|
|
869
|
-
*
|
|
870
|
-
* @param token - Invitation token to resend
|
|
871
|
-
* @returns Promise with success response
|
|
872
|
-
* @throws {PassflowError} If request fails
|
|
873
|
-
*
|
|
874
|
-
* @example
|
|
875
|
-
* ```typescript
|
|
876
|
-
* await passflow.resendInvitation('invitation-token-123');
|
|
877
|
-
* console.log('Invitation email resent');
|
|
878
|
-
* ```
|
|
879
|
-
*/
|
|
880
|
-
resendInvitation(token: string): Promise<PassflowSuccessResponse>;
|
|
881
|
-
/**
|
|
882
|
-
* Get invitation details and link by invitation ID.
|
|
883
|
-
*
|
|
884
|
-
* @param invitationID - Invitation ID to retrieve
|
|
885
|
-
* @returns Promise with invitation link response
|
|
886
|
-
* @throws {PassflowError} If request fails
|
|
887
|
-
*
|
|
888
|
-
* @example
|
|
889
|
-
* ```typescript
|
|
890
|
-
* const invitation = await passflow.getInvitationLink('invitation-123');
|
|
891
|
-
* console.log('Invitation link:', invitation.link);
|
|
892
|
-
* ```
|
|
893
|
-
*/
|
|
894
|
-
getInvitationLink(invitationID: string): Promise<InviteLinkResponse>;
|
|
895
|
-
/**
|
|
896
|
-
* Generate an authentication redirect URL for hosted login.
|
|
897
|
-
*
|
|
898
|
-
* @param options - Redirect URL configuration
|
|
899
|
-
* @param options.url - Optional custom Passflow server URL
|
|
900
|
-
* @param options.redirectUrl - URL to redirect to after authentication
|
|
901
|
-
* @param options.scopes - Optional scopes to request
|
|
902
|
-
* @param options.appId - Optional app ID to use
|
|
903
|
-
* @returns Authentication redirect URL
|
|
904
|
-
*
|
|
905
|
-
* @example
|
|
906
|
-
* ```typescript
|
|
907
|
-
* const authUrl = passflow.authRedirectUrl({
|
|
908
|
-
* redirectUrl: window.location.origin + '/auth/callback',
|
|
909
|
-
* scopes: ['id', 'email', 'offline']
|
|
910
|
-
* });
|
|
911
|
-
* console.log('Auth URL:', authUrl);
|
|
912
|
-
* // Use this URL for custom navigation logic
|
|
913
|
-
* ```
|
|
914
|
-
*/
|
|
915
|
-
authRedirectUrl(options?: {
|
|
916
|
-
url?: string;
|
|
917
|
-
redirectUrl?: string;
|
|
918
|
-
scopes?: string[];
|
|
919
|
-
appId?: string;
|
|
920
|
-
}): string;
|
|
921
|
-
/**
|
|
922
|
-
* Redirect to the Passflow hosted login page.
|
|
923
|
-
*
|
|
924
|
-
* @param options - Redirect configuration
|
|
925
|
-
* @param options.url - Optional custom Passflow server URL
|
|
926
|
-
* @param options.redirectUrl - URL to redirect to after authentication
|
|
927
|
-
* @param options.scopes - Optional scopes to request
|
|
928
|
-
* @param options.appId - Optional app ID to use
|
|
929
|
-
*
|
|
930
|
-
* @example
|
|
931
|
-
* ```typescript
|
|
932
|
-
* // Redirect to hosted login page
|
|
933
|
-
* passflow.authRedirect({
|
|
934
|
-
* redirectUrl: window.location.origin + '/auth/callback'
|
|
935
|
-
* });
|
|
936
|
-
* ```
|
|
937
|
-
*/
|
|
938
|
-
authRedirect(options?: {
|
|
939
|
-
url?: string;
|
|
940
|
-
redirectUrl?: string;
|
|
941
|
-
scopes?: string[];
|
|
942
|
-
appId?: string;
|
|
943
|
-
}): void;
|
|
944
|
-
/**
|
|
945
|
-
* Get the current token delivery mode.
|
|
946
|
-
* Returns the mode determined by the server (json_body, cookie, or mobile).
|
|
947
|
-
*
|
|
948
|
-
* @returns The current token delivery mode
|
|
949
|
-
*
|
|
950
|
-
* @example
|
|
951
|
-
* ```typescript
|
|
952
|
-
* import { TokenDeliveryMode } from '@passflow/core';
|
|
953
|
-
*
|
|
954
|
-
* const mode = passflow.getDeliveryMode();
|
|
955
|
-
* if (mode === TokenDeliveryMode.Cookie) {
|
|
956
|
-
* console.log('Using cookie-based authentication');
|
|
957
|
-
* } else {
|
|
958
|
-
* console.log('Using JSON body authentication');
|
|
959
|
-
* }
|
|
960
|
-
* ```
|
|
961
|
-
*/
|
|
962
|
-
getDeliveryMode(): import('./token/delivery-manager').TokenDeliveryMode;
|
|
963
|
-
/**
|
|
964
|
-
* Restore and validate session for cookie mode on page load.
|
|
965
|
-
* Only applicable when using cookie-based token delivery.
|
|
966
|
-
* Validates that HttpOnly cookies are still valid with the server.
|
|
967
|
-
*
|
|
968
|
-
* This method is automatically called on SDK initialization for cookie mode,
|
|
969
|
-
* but can be called manually to re-validate the session.
|
|
970
|
-
*
|
|
971
|
-
* @returns Promise resolving to true if session is valid, false otherwise
|
|
972
|
-
*
|
|
973
|
-
* @example
|
|
974
|
-
* ```typescript
|
|
975
|
-
* // Check if session is valid (useful after page reload)
|
|
976
|
-
* const isValid = await passflow.restoreSession();
|
|
977
|
-
* if (isValid) {
|
|
978
|
-
* console.log('Session restored successfully');
|
|
979
|
-
* } else {
|
|
980
|
-
* console.log('Session expired, please sign in again');
|
|
981
|
-
* }
|
|
982
|
-
* ```
|
|
983
|
-
*/
|
|
984
|
-
restoreSession(): Promise<boolean>;
|
|
985
|
-
/**
|
|
986
|
-
* Get the current 2FA enrollment status for the authenticated user.
|
|
987
|
-
*
|
|
988
|
-
* @returns Promise with 2FA status including enabled state and policy
|
|
989
|
-
* @throws {PassflowError} If request fails
|
|
990
|
-
*
|
|
991
|
-
* @example
|
|
992
|
-
* ```typescript
|
|
993
|
-
* const status = await passflow.getTwoFactorStatus();
|
|
994
|
-
* console.log('2FA enabled:', status.enabled);
|
|
995
|
-
* console.log('Recovery codes remaining:', status.recovery_codes_remaining);
|
|
996
|
-
* ```
|
|
997
|
-
*/
|
|
998
|
-
getTwoFactorStatus(): Promise<TwoFactorStatusResponse>;
|
|
999
|
-
/**
|
|
1000
|
-
* Begin the 2FA setup process for the authenticated user.
|
|
1001
|
-
* Returns a secret and QR code to scan with an authenticator app.
|
|
1002
|
-
*
|
|
1003
|
-
* @returns Promise with setup response containing secret and QR code
|
|
1004
|
-
* @throws {PassflowError} If request fails
|
|
1005
|
-
*
|
|
1006
|
-
* @example
|
|
1007
|
-
* ```typescript
|
|
1008
|
-
* const setup = await passflow.beginTwoFactorSetup();
|
|
1009
|
-
* console.log('Scan this QR code:', setup.qr_code);
|
|
1010
|
-
* console.log('Or enter this secret:', setup.secret);
|
|
1011
|
-
* ```
|
|
1012
|
-
*/
|
|
1013
|
-
beginTwoFactorSetup(): Promise<TwoFactorSetupResponse>;
|
|
1014
|
-
/**
|
|
1015
|
-
* Confirm 2FA setup by verifying a TOTP code from the authenticator app.
|
|
1016
|
-
* Returns recovery codes that MUST be saved by the user.
|
|
1017
|
-
*
|
|
1018
|
-
* @param code - 6-digit TOTP code from authenticator app
|
|
1019
|
-
* @returns Promise with confirmation response including recovery codes
|
|
1020
|
-
* @throws {PassflowError} If verification fails
|
|
1021
|
-
*
|
|
1022
|
-
* @example
|
|
1023
|
-
* ```typescript
|
|
1024
|
-
* const result = await passflow.confirmTwoFactorSetup('123456');
|
|
1025
|
-
* console.log('SAVE THESE RECOVERY CODES:', result.recovery_codes);
|
|
1026
|
-
* // Display recovery codes to user for safekeeping
|
|
1027
|
-
* ```
|
|
1028
|
-
*/
|
|
1029
|
-
confirmTwoFactorSetup(code: string): Promise<TwoFactorConfirmResponse>;
|
|
1030
|
-
/**
|
|
1031
|
-
* Verify a TOTP code during login when 2FA is required.
|
|
1032
|
-
* Completes the authentication process and saves tokens.
|
|
1033
|
-
*
|
|
1034
|
-
* @param code - 6-digit TOTP code from authenticator app
|
|
1035
|
-
* @param options - `trustDevice: true` asks the server to trust this device,
|
|
1036
|
-
* so later sign-ins from it skip the second factor where the app allows it
|
|
1037
|
-
* @returns Promise with verification response containing tokens
|
|
1038
|
-
* @throws {PassflowError} If verification fails
|
|
1039
|
-
*
|
|
1040
|
-
* @example
|
|
1041
|
-
* ```typescript
|
|
1042
|
-
* // After signIn returns requires_2fa: true
|
|
1043
|
-
* if (passflow.isTwoFactorVerificationRequired()) {
|
|
1044
|
-
* const response = await passflow.verifyTwoFactor('123456', { trustDevice: true });
|
|
1045
|
-
* console.log('Authentication complete', response.access_token);
|
|
1046
|
-
* }
|
|
1047
|
-
* ```
|
|
1048
|
-
*/
|
|
1049
|
-
verifyTwoFactor(code: string, options?: TwoFactorCompletionOptions): Promise<TwoFactorVerifyResponse>;
|
|
1050
|
-
/**
|
|
1051
|
-
* Use a recovery code for authentication when TOTP is unavailable.
|
|
1052
|
-
* Completes the authentication process and saves tokens.
|
|
1053
|
-
*
|
|
1054
|
-
* @param code - Recovery code from the list provided during setup
|
|
1055
|
-
* @param options - `trustDevice: true` asks the server to trust this device
|
|
1056
|
-
* @returns Promise with recovery response containing tokens and remaining codes count
|
|
1057
|
-
* @throws {PassflowError} If recovery code is invalid
|
|
1058
|
-
*
|
|
1059
|
-
* @example
|
|
1060
|
-
* ```typescript
|
|
1061
|
-
* // After signIn returns requires_2fa: true
|
|
1062
|
-
* const result = await passflow.useTwoFactorRecoveryCode('ABCD-1234');
|
|
1063
|
-
* console.log('Authenticated with recovery code');
|
|
1064
|
-
* console.log(`${result.remaining_recovery_codes} recovery codes remaining`);
|
|
1065
|
-
* ```
|
|
1066
|
-
*/
|
|
1067
|
-
useTwoFactorRecoveryCode(code: string, options?: TwoFactorCompletionOptions): Promise<TwoFactorRecoveryResponse>;
|
|
1068
|
-
/**
|
|
1069
|
-
* Disable 2FA for the authenticated user.
|
|
1070
|
-
* Requires verification with a current TOTP code.
|
|
1071
|
-
*
|
|
1072
|
-
* @param code - Current 6-digit TOTP code for verification
|
|
1073
|
-
* @returns Promise with success response
|
|
1074
|
-
* @throws {PassflowError} If verification fails
|
|
1075
|
-
*
|
|
1076
|
-
* @example
|
|
1077
|
-
* ```typescript
|
|
1078
|
-
* await passflow.disableTwoFactor('123456');
|
|
1079
|
-
* console.log('2FA disabled successfully');
|
|
1080
|
-
* ```
|
|
1081
|
-
*/
|
|
1082
|
-
disableTwoFactor(code: string): Promise<TwoFactorDisableResponse>;
|
|
1083
|
-
/**
|
|
1084
|
-
* Regenerate recovery codes for the authenticated user.
|
|
1085
|
-
* Old recovery codes will be invalidated. Requires verification with a current TOTP code.
|
|
1086
|
-
*
|
|
1087
|
-
* @param code - Current 6-digit TOTP code for verification
|
|
1088
|
-
* @returns Promise with response containing new recovery codes
|
|
1089
|
-
* @throws {PassflowError} If verification fails
|
|
1090
|
-
*
|
|
1091
|
-
* @example
|
|
1092
|
-
* ```typescript
|
|
1093
|
-
* const result = await passflow.regenerateTwoFactorRecoveryCodes('123456');
|
|
1094
|
-
* console.log('New recovery codes:', result.recovery_codes);
|
|
1095
|
-
* // Display new recovery codes to user for safekeeping
|
|
1096
|
-
* ```
|
|
1097
|
-
*/
|
|
1098
|
-
regenerateTwoFactorRecoveryCodes(code: string): Promise<TwoFactorRegenerateResponse>;
|
|
1099
|
-
/**
|
|
1100
|
-
* List the devices the signed-in user trusted to skip the second factor on
|
|
1101
|
-
* this app. The device making the request has `current: true`.
|
|
1102
|
-
*
|
|
1103
|
-
* @returns Promise with the trusted devices
|
|
1104
|
-
* @throws {PassflowError} If the request fails
|
|
1105
|
-
*
|
|
1106
|
-
* @example
|
|
1107
|
-
* ```typescript
|
|
1108
|
-
* const devices = await passflow.getTrustedDevices();
|
|
1109
|
-
* devices.forEach((d) => console.log(d.user_agent, d.current ? '(this device)' : ''));
|
|
1110
|
-
* ```
|
|
1111
|
-
*/
|
|
1112
|
-
getTrustedDevices(): Promise<TwoFactorTrustedDevice[]>;
|
|
1113
|
-
/**
|
|
1114
|
-
* Revoke one of the signed-in user's trusted devices. Its next sign-in
|
|
1115
|
-
* asks for the second factor again.
|
|
1116
|
-
*
|
|
1117
|
-
* @param id - The trusted device's `id` from `getTrustedDevices()`
|
|
1118
|
-
* @throws {PassflowError} If the request fails, including a 404 for an unknown id
|
|
1119
|
-
*
|
|
1120
|
-
* @example
|
|
1121
|
-
* ```typescript
|
|
1122
|
-
* await passflow.revokeTrustedDevice(device.id);
|
|
1123
|
-
* ```
|
|
1124
|
-
*/
|
|
1125
|
-
revokeTrustedDevice(id: string): Promise<void>;
|
|
1126
|
-
/**
|
|
1127
|
-
* Check if 2FA verification is currently required (local state check).
|
|
1128
|
-
* Returns true if user has signed in but needs to complete 2FA verification.
|
|
1129
|
-
*
|
|
1130
|
-
* @returns True if 2FA verification is pending, false otherwise
|
|
1131
|
-
*
|
|
1132
|
-
* @example
|
|
1133
|
-
* ```typescript
|
|
1134
|
-
* if (passflow.isTwoFactorVerificationRequired()) {
|
|
1135
|
-
* // Show 2FA code input UI
|
|
1136
|
-
* console.log('Please enter your 2FA code');
|
|
1137
|
-
* }
|
|
1138
|
-
* ```
|
|
1139
|
-
*/
|
|
1140
|
-
isTwoFactorVerificationRequired(): boolean;
|
|
1141
|
-
/**
|
|
1142
|
-
* Get configured TOTP digit count for the current app
|
|
1143
|
-
* @returns Number of digits (6 or 8) configured for TOTP codes
|
|
1144
|
-
*
|
|
1145
|
-
* @example
|
|
1146
|
-
* ```typescript
|
|
1147
|
-
* const digits = passflow.getTotpDigits();
|
|
1148
|
-
* console.log(`TOTP codes should be ${digits} digits`);
|
|
1149
|
-
* ```
|
|
1150
|
-
*/
|
|
1151
|
-
getTotpDigits(): 6 | 8;
|
|
1152
|
-
/**
|
|
1153
|
-
* Validate a magic link token for 2FA setup.
|
|
1154
|
-
* Used when a user clicks on an admin-generated magic link to set up 2FA.
|
|
1155
|
-
*
|
|
1156
|
-
* The magic link creates a scoped session that can ONLY be used for 2FA setup,
|
|
1157
|
-
* not for regular authentication.
|
|
1158
|
-
*
|
|
1159
|
-
* @param token - Magic link token from URL parameter
|
|
1160
|
-
* @returns Promise with validation response containing scoped session or error
|
|
1161
|
-
*
|
|
1162
|
-
* @example
|
|
1163
|
-
* ```typescript
|
|
1164
|
-
* // On the magic link landing page (e.g., /2fa-setup/:token)
|
|
1165
|
-
* const urlToken = extractTokenFromUrl();
|
|
1166
|
-
* const result = await passflow.validateTwoFactorSetupMagicLink(urlToken);
|
|
1167
|
-
*
|
|
1168
|
-
* if (result.success) {
|
|
1169
|
-
* console.log('Magic link validated');
|
|
1170
|
-
* console.log('User ID:', result.userId);
|
|
1171
|
-
* console.log('Session expires in:', result.expiresIn, 'seconds');
|
|
1172
|
-
* // Show 2FA setup form
|
|
1173
|
-
* } else {
|
|
1174
|
-
* console.error('Validation failed:', result.error?.message);
|
|
1175
|
-
* // Show error UI
|
|
1176
|
-
* }
|
|
1177
|
-
* ```
|
|
1178
|
-
*/
|
|
1179
|
-
validateTwoFactorSetupMagicLink(token: string): Promise<import('./api/model').TwoFactorSetupMagicLinkValidationResponse>;
|
|
1180
|
-
/**
|
|
1181
|
-
* Get the current magic link session (if any).
|
|
1182
|
-
* Used by React SDK components to access session data.
|
|
1183
|
-
*
|
|
1184
|
-
* @returns Active magic link session or null if none/expired
|
|
1185
|
-
*
|
|
1186
|
-
* @example
|
|
1187
|
-
* ```typescript
|
|
1188
|
-
* const session = passflow.getMagicLinkSession();
|
|
1189
|
-
* if (session) {
|
|
1190
|
-
* console.log('Active session for user:', session.userId);
|
|
1191
|
-
* console.log('Expires at:', new Date(session.expiresAt));
|
|
1192
|
-
* }
|
|
1193
|
-
* ```
|
|
1194
|
-
*/
|
|
1195
|
-
getMagicLinkSession(): import('./api/model').TwoFactorSetupMagicLinkSession | null;
|
|
1196
|
-
/**
|
|
1197
|
-
* Check if a magic link session is currently active.
|
|
1198
|
-
*
|
|
1199
|
-
* @returns True if magic link session is active and not expired
|
|
1200
|
-
*
|
|
1201
|
-
* @example
|
|
1202
|
-
* ```typescript
|
|
1203
|
-
* if (passflow.hasMagicLinkSession()) {
|
|
1204
|
-
* // User can proceed with 2FA setup
|
|
1205
|
-
* } else {
|
|
1206
|
-
* // Redirect to error page or request new link
|
|
1207
|
-
* }
|
|
1208
|
-
* ```
|
|
1209
|
-
*/
|
|
1210
|
-
hasMagicLinkSession(): boolean;
|
|
1211
|
-
/**
|
|
1212
|
-
* Clear the magic link session.
|
|
1213
|
-
* Called after successful 2FA setup or on error.
|
|
1214
|
-
*
|
|
1215
|
-
* @example
|
|
1216
|
-
* ```typescript
|
|
1217
|
-
* // After 2FA setup is complete
|
|
1218
|
-
* passflow.clearMagicLinkSession();
|
|
1219
|
-
* // Redirect to sign-in
|
|
1220
|
-
* ```
|
|
1221
|
-
*/
|
|
1222
|
-
clearMagicLinkSession(): void;
|
|
1223
|
-
}
|
|
1224
|
-
//# sourceMappingURL=passflow.d.ts.map
|