@passflow/core 0.35.0 → 0.35.2

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/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. With `keepStored`, only the in-memory state is reset:
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(keepStored?: boolean): void;
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 keys every session shares (scopes, delivery mode, CSRF token) are then
306
- * that app's, and this instance's clearing leaves them in place.
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
- * keys every session shares (scopes, delivery mode, CSRF token) stay only when the stored session
346
- * is another app's alone, and the hosted sign-in record only when another app wrote it.
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
- export interface PassflowSessionValidationResponse {
1211
- valid: boolean;
1212
- user?: {
1213
- id: string;
1214
- email?: string;
1215
- username?: string;
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: {
@@ -2791,7 +2792,8 @@ export declare class AuthAPI {
2791
2792
  */
2792
2793
  validateEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
2793
2794
  logOut(deviceId?: string, refreshToken?: string, isAdmin?: boolean): Promise<PassflowLogoutResponse>;
2794
- validateSession(): Promise<PassflowSessionValidationResponse>;
2795
+ /** Reads the signed-in user. An invalid session rejects. */
2796
+ validateSession(): Promise<PassflowSessionUser>;
2795
2797
  sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload, options?: PassflowAuthOptions): Promise<PassflowSuccessResponse>;
2796
2798
  resetPassword(newPassword: string, scopes: string[], resetToken?: string, codeChallenge?: string): Promise<PassflowAuthorizationResponse>;
2797
2799
  passkeyRegisterStart(payload: PassflowPasskeyRegisterStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
@@ -4204,6 +4206,8 @@ export declare class AuthService {
4204
4206
  readAppSettings?: (() => Promise<AppSettings | undefined>) | undefined);
4205
4207
  /** The app id used for `client_id`, the override check, federated starts and landings. */
4206
4208
  setAppId(appId: string): void;
4209
+ /** With token exchange enabled the mode is BFF from the start, before any server answer. */
4210
+ private setBffModeIfConfigured;
4207
4211
  /**
4208
4212
  * Whether the app is known to be in Simple mode (`pkce_enabled === false`), the only mode in
4209
4213
  * which tokens are accepted from a URL. An unknown mode (no app id, a failed read) is not.
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. With `keepStored`, only the in-memory state is reset:
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(keepStored?: boolean): void;
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 keys every session shares (scopes, delivery mode, CSRF token) are then
306
- * that app's, and this instance's clearing leaves them in place.
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
- * keys every session shares (scopes, delivery mode, CSRF token) stay only when the stored session
346
- * is another app's alone, and the hosted sign-in record only when another app wrote it.
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
- export interface PassflowSessionValidationResponse {
1211
- valid: boolean;
1212
- user?: {
1213
- id: string;
1214
- email?: string;
1215
- username?: string;
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: {
@@ -2791,7 +2792,8 @@ export declare class AuthAPI {
2791
2792
  */
2792
2793
  validateEmailCode(payload: PassflowEmailCodePayload): Promise<PassflowAuthorizationResponse>;
2793
2794
  logOut(deviceId?: string, refreshToken?: string, isAdmin?: boolean): Promise<PassflowLogoutResponse>;
2794
- validateSession(): Promise<PassflowSessionValidationResponse>;
2795
+ /** Reads the signed-in user. An invalid session rejects. */
2796
+ validateSession(): Promise<PassflowSessionUser>;
2795
2797
  sendPasswordResetEmail(payload: PassflowSendPasswordResetEmailPayload, options?: PassflowAuthOptions): Promise<PassflowSuccessResponse>;
2796
2798
  resetPassword(newPassword: string, scopes: string[], resetToken?: string, codeChallenge?: string): Promise<PassflowAuthorizationResponse>;
2797
2799
  passkeyRegisterStart(payload: PassflowPasskeyRegisterStartPayload, deviceId: string, os: OS, isAdmin?: boolean, options?: PassflowAuthOptions): Promise<PassflowPasskeyStart>;
@@ -4204,6 +4206,8 @@ export declare class AuthService {
4204
4206
  readAppSettings?: (() => Promise<AppSettings | undefined>) | undefined);
4205
4207
  /** The app id used for `client_id`, the override check, federated starts and landings. */
4206
4208
  setAppId(appId: string): void;
4209
+ /** With token exchange enabled the mode is BFF from the start, before any server answer. */
4210
+ private setBffModeIfConfigured;
4207
4211
  /**
4208
4212
  * Whether the app is known to be in Simple mode (`pkce_enabled === false`), the only mode in
4209
4213
  * which tokens are accepted from a URL. An unknown mode (no app id, a failed read) is not.