@passflow/core 0.35.1 → 0.35.3
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 +97 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -27
- package/dist/index.d.ts +44 -27
- package/dist/index.mjs +1083 -1034
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -146,10 +146,12 @@ declare class TokenDeliveryManager {
|
|
|
146
146
|
private mode;
|
|
147
147
|
private sessionState;
|
|
148
148
|
private isInitializedFlag;
|
|
149
|
-
private readonly STORAGE_PREFIX;
|
|
150
|
-
private readonly DELIVERY_MODE_KEY;
|
|
151
149
|
private readonly SESSION_STATE_KEY;
|
|
152
150
|
constructor(storageManager: StorageManager);
|
|
151
|
+
/** The session state's storage key: the app's own, like the delivery mode's. */
|
|
152
|
+
private sessionStateKey;
|
|
153
|
+
/** Reads the mode and session state again, for when the app id changes: both are the new app's. */
|
|
154
|
+
reload(): void;
|
|
153
155
|
/**
|
|
154
156
|
* Set the token delivery mode
|
|
155
157
|
*/
|
|
@@ -207,10 +209,9 @@ declare class TokenDeliveryManager {
|
|
|
207
209
|
*/
|
|
208
210
|
getSessionState(): SessionState;
|
|
209
211
|
/**
|
|
210
|
-
* Reset delivery manager to initial state
|
|
211
|
-
* the stored mode and session state belong to another app's session and stay.
|
|
212
|
+
* Reset delivery manager to initial state, removing this app's stored mode and session state.
|
|
212
213
|
*/
|
|
213
|
-
reset(
|
|
214
|
+
reset(): void;
|
|
214
215
|
/**
|
|
215
216
|
* Load persisted delivery mode from storage
|
|
216
217
|
*/
|
|
@@ -227,10 +228,6 @@ declare class TokenDeliveryManager {
|
|
|
227
228
|
* Persist session state to storage
|
|
228
229
|
*/
|
|
229
230
|
private persistSessionState;
|
|
230
|
-
/**
|
|
231
|
-
* Clear persisted delivery mode from storage
|
|
232
|
-
*/
|
|
233
|
-
private clearPersistedMode;
|
|
234
231
|
/**
|
|
235
232
|
* Clear persisted session state from storage
|
|
236
233
|
*/
|
|
@@ -274,9 +271,6 @@ declare class StorageManager {
|
|
|
274
271
|
readonly invitationToken: string;
|
|
275
272
|
readonly previousRedirectUrl: string;
|
|
276
273
|
private readonly STORAGE_PREFIX;
|
|
277
|
-
private readonly ID_TOKEN_KEY;
|
|
278
|
-
private readonly CSRF_TOKEN_KEY;
|
|
279
|
-
private readonly DELIVERY_MODE_KEY;
|
|
280
274
|
private storage;
|
|
281
275
|
private appId;
|
|
282
276
|
constructor({ storage, prefix, appId }?: StorageManagerParams);
|
|
@@ -286,6 +280,17 @@ declare class StorageManager {
|
|
|
286
280
|
* app's. With no app id, every stored token counts.
|
|
287
281
|
*/
|
|
288
282
|
setAppId(appId: string | undefined): void;
|
|
283
|
+
/** The app id set at construction or by `setAppId()`, or undefined when there is none. */
|
|
284
|
+
getAppId(): string | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* The storage key of a value each app keeps for itself: `name:<appId>`, so apps on one origin do
|
|
287
|
+
* not read or remove each other's. With no app id, `name`. Worked out at each use, so it follows
|
|
288
|
+
* `setAppId()`.
|
|
289
|
+
*/
|
|
290
|
+
appKey(name: string): string;
|
|
291
|
+
private idTokenKey;
|
|
292
|
+
private csrfTokenKey;
|
|
293
|
+
private deliveryModeKey;
|
|
289
294
|
/** The stored value, or undefined when it is a JWT issued for another app than this one. */
|
|
290
295
|
private ownToken;
|
|
291
296
|
/**
|
|
@@ -302,8 +307,8 @@ declare class StorageManager {
|
|
|
302
307
|
private holdsOtherAppToken;
|
|
303
308
|
/**
|
|
304
309
|
* Whether the stored session is only another app's: some key holds another app's token and none
|
|
305
|
-
* holds this app's. The
|
|
306
|
-
*
|
|
310
|
+
* holds this app's. The scopes, which every session shares, are then that app's, and this
|
|
311
|
+
* instance's clearing leaves them in place.
|
|
307
312
|
*/
|
|
308
313
|
holdsOnlyOtherAppSession(): boolean;
|
|
309
314
|
/** Removes the token in `key` unless it is another app's. */
|
|
@@ -342,8 +347,8 @@ declare class StorageManager {
|
|
|
342
347
|
deleteToken(tokenType: TokenType): void;
|
|
343
348
|
/**
|
|
344
349
|
* Clears this app's stored session, key by key: a key holding another app's token stays. The
|
|
345
|
-
*
|
|
346
|
-
*
|
|
350
|
+
* scopes, which every session shares, stay only when the stored session is another app's alone,
|
|
351
|
+
* and the hosted sign-in record only when another app wrote it.
|
|
347
352
|
*/
|
|
348
353
|
deleteTokens(): void;
|
|
349
354
|
/**
|
|
@@ -402,7 +407,6 @@ declare class StorageManager {
|
|
|
402
407
|
* Clear the CSRF token from storage
|
|
403
408
|
*/
|
|
404
409
|
clearCsrfToken(): void;
|
|
405
|
-
private removeCsrfToken;
|
|
406
410
|
/**
|
|
407
411
|
* Every storage key the token session lives in (JSON tokens, scopes, the cookie-mode ID token,
|
|
408
412
|
* CSRF token and delivery mode). The refresh coordinator filters `storage` events by it, so
|
|
@@ -1207,15 +1211,12 @@ export type PassflowSuccessResponse = {
|
|
|
1207
1211
|
export type PassflowLogoutResponse = {
|
|
1208
1212
|
status: 'ok';
|
|
1209
1213
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
[key: string]: unknown;
|
|
1217
|
-
};
|
|
1218
|
-
expires_at?: number;
|
|
1214
|
+
/** The signed-in user, as `GET /user/me` answers: the user object itself. */
|
|
1215
|
+
export interface PassflowSessionUser {
|
|
1216
|
+
id: string;
|
|
1217
|
+
email?: string;
|
|
1218
|
+
username?: string;
|
|
1219
|
+
[key: string]: unknown;
|
|
1219
1220
|
}
|
|
1220
1221
|
export type PassflowResponseError = {
|
|
1221
1222
|
error: {
|
|
@@ -2597,6 +2598,8 @@ type AxiosUpgradeHandler = (error: AxiosError, challenge: UpgradeChallenge) => P
|
|
|
2597
2598
|
* `allowStale` is true when the access token is inside the 30 s window but not yet expired: during
|
|
2598
2599
|
* a pending retry the controller then resolves at once and the call goes out with the current
|
|
2599
2600
|
* bearer instead of waiting for the retry.
|
|
2601
|
+
*
|
|
2602
|
+
* In cookie and BFF mode the same handler runs after a 401 instead, with `allowStale` false.
|
|
2600
2603
|
*/
|
|
2601
2604
|
type AxiosRefreshHandler = (request: {
|
|
2602
2605
|
trigger: 'pre-request';
|
|
@@ -2677,6 +2680,13 @@ declare class AxiosClient {
|
|
|
2677
2680
|
*/
|
|
2678
2681
|
replay<T = unknown>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
2679
2682
|
private isProtectedEndpoint;
|
|
2683
|
+
/**
|
|
2684
|
+
* After a 401 in cookie or BFF mode: one refresh through the handler, at most once per request.
|
|
2685
|
+
* True when the session was refreshed and the request is to be sent again. False for a request
|
|
2686
|
+
* that does not carry the session, a second 401 of the same request, a failed refresh and an
|
|
2687
|
+
* ended session: the 401 then stands.
|
|
2688
|
+
*/
|
|
2689
|
+
private refreshedAfterUnauthorized;
|
|
2680
2690
|
private isNonAuthEndpoint;
|
|
2681
2691
|
/**
|
|
2682
2692
|
* Detect if cookies are supported/enabled in the browser.
|
|
@@ -2791,7 +2801,8 @@ export declare class AuthAPI {
|
|
|
2791
2801
|
*/
|
|
2792
2802
|
validateEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
2793
2803
|
logOut(deviceId?: string, refreshToken?: string, isAdmin?: boolean): Promise<PassflowLogoutResponse>;
|
|
2794
|
-
|
|
2804
|
+
/** Reads the signed-in user. An invalid session rejects. */
|
|
2805
|
+
validateSession(): Promise<PassflowSessionUser>;
|
|
2795
2806
|
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload, options?: PassflowAuthOptions): Promise<PassflowSuccessResponse>;
|
|
2796
2807
|
resetPassword(newPassword: string, scopes: string[], resetToken?: string, codeChallenge?: string): Promise<PassflowAuthorizationResponse>;
|
|
2797
2808
|
passkeyRegisterStart(payload: PassflowPasskeyRegisterStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
|
|
@@ -4062,6 +4073,8 @@ interface RefreshController {
|
|
|
4062
4073
|
signOutNow(cleanup: (newest?: string) => void): void;
|
|
4063
4074
|
/** A new session in this tab (sign-in, register, setTokens): new generation, counters reset. */
|
|
4064
4075
|
sessionStarted(): void;
|
|
4076
|
+
/** Counts the sessions of this tab: an answer asked for under an earlier number is not applied. */
|
|
4077
|
+
readonly generation: number;
|
|
4065
4078
|
/** The `sub` this tab's session belongs to. */
|
|
4066
4079
|
identity(): string | undefined;
|
|
4067
4080
|
readonly coordinated: boolean;
|
|
@@ -4204,6 +4217,8 @@ export declare class AuthService {
|
|
|
4204
4217
|
readAppSettings?: (() => Promise<AppSettings | undefined>) | undefined);
|
|
4205
4218
|
/** The app id used for `client_id`, the override check, federated starts and landings. */
|
|
4206
4219
|
setAppId(appId: string): void;
|
|
4220
|
+
/** With token exchange enabled the mode is BFF from the start, before any server answer. */
|
|
4221
|
+
private setBffModeIfConfigured;
|
|
4207
4222
|
/**
|
|
4208
4223
|
* Whether the app is known to be in Simple mode (`pkce_enabled === false`), the only mode in
|
|
4209
4224
|
* which tokens are accepted from a URL. An unknown mode (no app id, a failed read) is not.
|
|
@@ -4234,6 +4249,8 @@ export declare class AuthService {
|
|
|
4234
4249
|
* its answer through here too. `replace` marks a new session: see `StorageManager.saveTokens()`.
|
|
4235
4250
|
*/
|
|
4236
4251
|
private applyAuthResponse;
|
|
4252
|
+
/** Whether the answer's ID or access token names audiences that leave out the current app id. */
|
|
4253
|
+
private issuedForAnotherApp;
|
|
4237
4254
|
/** A registration that leaves the user signed in: `Register`, then `SignIn` with the same payload. */
|
|
4238
4255
|
private notifyRegisteredAndSignedIn;
|
|
4239
4256
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -146,10 +146,12 @@ declare class TokenDeliveryManager {
|
|
|
146
146
|
private mode;
|
|
147
147
|
private sessionState;
|
|
148
148
|
private isInitializedFlag;
|
|
149
|
-
private readonly STORAGE_PREFIX;
|
|
150
|
-
private readonly DELIVERY_MODE_KEY;
|
|
151
149
|
private readonly SESSION_STATE_KEY;
|
|
152
150
|
constructor(storageManager: StorageManager);
|
|
151
|
+
/** The session state's storage key: the app's own, like the delivery mode's. */
|
|
152
|
+
private sessionStateKey;
|
|
153
|
+
/** Reads the mode and session state again, for when the app id changes: both are the new app's. */
|
|
154
|
+
reload(): void;
|
|
153
155
|
/**
|
|
154
156
|
* Set the token delivery mode
|
|
155
157
|
*/
|
|
@@ -207,10 +209,9 @@ declare class TokenDeliveryManager {
|
|
|
207
209
|
*/
|
|
208
210
|
getSessionState(): SessionState;
|
|
209
211
|
/**
|
|
210
|
-
* Reset delivery manager to initial state
|
|
211
|
-
* the stored mode and session state belong to another app's session and stay.
|
|
212
|
+
* Reset delivery manager to initial state, removing this app's stored mode and session state.
|
|
212
213
|
*/
|
|
213
|
-
reset(
|
|
214
|
+
reset(): void;
|
|
214
215
|
/**
|
|
215
216
|
* Load persisted delivery mode from storage
|
|
216
217
|
*/
|
|
@@ -227,10 +228,6 @@ declare class TokenDeliveryManager {
|
|
|
227
228
|
* Persist session state to storage
|
|
228
229
|
*/
|
|
229
230
|
private persistSessionState;
|
|
230
|
-
/**
|
|
231
|
-
* Clear persisted delivery mode from storage
|
|
232
|
-
*/
|
|
233
|
-
private clearPersistedMode;
|
|
234
231
|
/**
|
|
235
232
|
* Clear persisted session state from storage
|
|
236
233
|
*/
|
|
@@ -274,9 +271,6 @@ declare class StorageManager {
|
|
|
274
271
|
readonly invitationToken: string;
|
|
275
272
|
readonly previousRedirectUrl: string;
|
|
276
273
|
private readonly STORAGE_PREFIX;
|
|
277
|
-
private readonly ID_TOKEN_KEY;
|
|
278
|
-
private readonly CSRF_TOKEN_KEY;
|
|
279
|
-
private readonly DELIVERY_MODE_KEY;
|
|
280
274
|
private storage;
|
|
281
275
|
private appId;
|
|
282
276
|
constructor({ storage, prefix, appId }?: StorageManagerParams);
|
|
@@ -286,6 +280,17 @@ declare class StorageManager {
|
|
|
286
280
|
* app's. With no app id, every stored token counts.
|
|
287
281
|
*/
|
|
288
282
|
setAppId(appId: string | undefined): void;
|
|
283
|
+
/** The app id set at construction or by `setAppId()`, or undefined when there is none. */
|
|
284
|
+
getAppId(): string | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* The storage key of a value each app keeps for itself: `name:<appId>`, so apps on one origin do
|
|
287
|
+
* not read or remove each other's. With no app id, `name`. Worked out at each use, so it follows
|
|
288
|
+
* `setAppId()`.
|
|
289
|
+
*/
|
|
290
|
+
appKey(name: string): string;
|
|
291
|
+
private idTokenKey;
|
|
292
|
+
private csrfTokenKey;
|
|
293
|
+
private deliveryModeKey;
|
|
289
294
|
/** The stored value, or undefined when it is a JWT issued for another app than this one. */
|
|
290
295
|
private ownToken;
|
|
291
296
|
/**
|
|
@@ -302,8 +307,8 @@ declare class StorageManager {
|
|
|
302
307
|
private holdsOtherAppToken;
|
|
303
308
|
/**
|
|
304
309
|
* Whether the stored session is only another app's: some key holds another app's token and none
|
|
305
|
-
* holds this app's. The
|
|
306
|
-
*
|
|
310
|
+
* holds this app's. The scopes, which every session shares, are then that app's, and this
|
|
311
|
+
* instance's clearing leaves them in place.
|
|
307
312
|
*/
|
|
308
313
|
holdsOnlyOtherAppSession(): boolean;
|
|
309
314
|
/** Removes the token in `key` unless it is another app's. */
|
|
@@ -342,8 +347,8 @@ declare class StorageManager {
|
|
|
342
347
|
deleteToken(tokenType: TokenType): void;
|
|
343
348
|
/**
|
|
344
349
|
* Clears this app's stored session, key by key: a key holding another app's token stays. The
|
|
345
|
-
*
|
|
346
|
-
*
|
|
350
|
+
* scopes, which every session shares, stay only when the stored session is another app's alone,
|
|
351
|
+
* and the hosted sign-in record only when another app wrote it.
|
|
347
352
|
*/
|
|
348
353
|
deleteTokens(): void;
|
|
349
354
|
/**
|
|
@@ -402,7 +407,6 @@ declare class StorageManager {
|
|
|
402
407
|
* Clear the CSRF token from storage
|
|
403
408
|
*/
|
|
404
409
|
clearCsrfToken(): void;
|
|
405
|
-
private removeCsrfToken;
|
|
406
410
|
/**
|
|
407
411
|
* Every storage key the token session lives in (JSON tokens, scopes, the cookie-mode ID token,
|
|
408
412
|
* CSRF token and delivery mode). The refresh coordinator filters `storage` events by it, so
|
|
@@ -1207,15 +1211,12 @@ export type PassflowSuccessResponse = {
|
|
|
1207
1211
|
export type PassflowLogoutResponse = {
|
|
1208
1212
|
status: 'ok';
|
|
1209
1213
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
[key: string]: unknown;
|
|
1217
|
-
};
|
|
1218
|
-
expires_at?: number;
|
|
1214
|
+
/** The signed-in user, as `GET /user/me` answers: the user object itself. */
|
|
1215
|
+
export interface PassflowSessionUser {
|
|
1216
|
+
id: string;
|
|
1217
|
+
email?: string;
|
|
1218
|
+
username?: string;
|
|
1219
|
+
[key: string]: unknown;
|
|
1219
1220
|
}
|
|
1220
1221
|
export type PassflowResponseError = {
|
|
1221
1222
|
error: {
|
|
@@ -2597,6 +2598,8 @@ type AxiosUpgradeHandler = (error: AxiosError, challenge: UpgradeChallenge) => P
|
|
|
2597
2598
|
* `allowStale` is true when the access token is inside the 30 s window but not yet expired: during
|
|
2598
2599
|
* a pending retry the controller then resolves at once and the call goes out with the current
|
|
2599
2600
|
* bearer instead of waiting for the retry.
|
|
2601
|
+
*
|
|
2602
|
+
* In cookie and BFF mode the same handler runs after a 401 instead, with `allowStale` false.
|
|
2600
2603
|
*/
|
|
2601
2604
|
type AxiosRefreshHandler = (request: {
|
|
2602
2605
|
trigger: 'pre-request';
|
|
@@ -2677,6 +2680,13 @@ declare class AxiosClient {
|
|
|
2677
2680
|
*/
|
|
2678
2681
|
replay<T = unknown>(config: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
2679
2682
|
private isProtectedEndpoint;
|
|
2683
|
+
/**
|
|
2684
|
+
* After a 401 in cookie or BFF mode: one refresh through the handler, at most once per request.
|
|
2685
|
+
* True when the session was refreshed and the request is to be sent again. False for a request
|
|
2686
|
+
* that does not carry the session, a second 401 of the same request, a failed refresh and an
|
|
2687
|
+
* ended session: the 401 then stands.
|
|
2688
|
+
*/
|
|
2689
|
+
private refreshedAfterUnauthorized;
|
|
2680
2690
|
private isNonAuthEndpoint;
|
|
2681
2691
|
/**
|
|
2682
2692
|
* Detect if cookies are supported/enabled in the browser.
|
|
@@ -2791,7 +2801,8 @@ export declare class AuthAPI {
|
|
|
2791
2801
|
*/
|
|
2792
2802
|
validateEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
|
|
2793
2803
|
logOut(deviceId?: string, refreshToken?: string, isAdmin?: boolean): Promise<PassflowLogoutResponse>;
|
|
2794
|
-
|
|
2804
|
+
/** Reads the signed-in user. An invalid session rejects. */
|
|
2805
|
+
validateSession(): Promise<PassflowSessionUser>;
|
|
2795
2806
|
sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload, options?: PassflowAuthOptions): Promise<PassflowSuccessResponse>;
|
|
2796
2807
|
resetPassword(newPassword: string, scopes: string[], resetToken?: string, codeChallenge?: string): Promise<PassflowAuthorizationResponse>;
|
|
2797
2808
|
passkeyRegisterStart(payload: PassflowPasskeyRegisterStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
|
|
@@ -4062,6 +4073,8 @@ interface RefreshController {
|
|
|
4062
4073
|
signOutNow(cleanup: (newest?: string) => void): void;
|
|
4063
4074
|
/** A new session in this tab (sign-in, register, setTokens): new generation, counters reset. */
|
|
4064
4075
|
sessionStarted(): void;
|
|
4076
|
+
/** Counts the sessions of this tab: an answer asked for under an earlier number is not applied. */
|
|
4077
|
+
readonly generation: number;
|
|
4065
4078
|
/** The `sub` this tab's session belongs to. */
|
|
4066
4079
|
identity(): string | undefined;
|
|
4067
4080
|
readonly coordinated: boolean;
|
|
@@ -4204,6 +4217,8 @@ export declare class AuthService {
|
|
|
4204
4217
|
readAppSettings?: (() => Promise<AppSettings | undefined>) | undefined);
|
|
4205
4218
|
/** The app id used for `client_id`, the override check, federated starts and landings. */
|
|
4206
4219
|
setAppId(appId: string): void;
|
|
4220
|
+
/** With token exchange enabled the mode is BFF from the start, before any server answer. */
|
|
4221
|
+
private setBffModeIfConfigured;
|
|
4207
4222
|
/**
|
|
4208
4223
|
* Whether the app is known to be in Simple mode (`pkce_enabled === false`), the only mode in
|
|
4209
4224
|
* which tokens are accepted from a URL. An unknown mode (no app id, a failed read) is not.
|
|
@@ -4234,6 +4249,8 @@ export declare class AuthService {
|
|
|
4234
4249
|
* its answer through here too. `replace` marks a new session: see `StorageManager.saveTokens()`.
|
|
4235
4250
|
*/
|
|
4236
4251
|
private applyAuthResponse;
|
|
4252
|
+
/** Whether the answer's ID or access token names audiences that leave out the current app id. */
|
|
4253
|
+
private issuedForAnotherApp;
|
|
4237
4254
|
/** A registration that leaves the user signed in: `Register`, then `SignIn` with the same payload. */
|
|
4238
4255
|
private notifyRegisteredAndSignedIn;
|
|
4239
4256
|
/**
|