@passflow/core 0.35.1 → 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/README.md +74 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -27
- package/dist/index.d.ts +31 -27
- package/dist/index.mjs +57 -46
- 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: {
|
|
@@ -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
|
-
|
|
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
|
|
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: {
|
|
@@ -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
|
-
|
|
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.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var i = "__passflowAntiBot", a = (e, t) => {
|
|
|
11
11
|
if (typeof e != "object" || !e) return;
|
|
12
12
|
let t = e[i];
|
|
13
13
|
return typeof t == "object" && t ? t : void 0;
|
|
14
|
-
}, s = "0.35.
|
|
14
|
+
}, s = "0.35.2", c = "X-Passflow-Clientid", l = "Authorization", u = "X-Passflow-DeviceId", d = "X-Passflow-DeviceType", f = "X-Passflow-Anti-Bot", p = "X-Passflow-Agent-Tool", m = "passflow_auth", h = s, g = [
|
|
15
15
|
"id",
|
|
16
16
|
"offline",
|
|
17
17
|
"openid"
|
|
@@ -113,7 +113,13 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
113
113
|
return e.Unknown = "unknown", e.Valid = "valid", e.Invalid = "invalid", e;
|
|
114
114
|
}({}), ce = class {
|
|
115
115
|
constructor(e) {
|
|
116
|
-
this.storageManager = e, this.mode = "json_body", this.sessionState = "unknown", this.isInitializedFlag = !1, this.
|
|
116
|
+
this.storageManager = e, this.mode = "json_body", this.sessionState = "unknown", this.isInitializedFlag = !1, this.SESSION_STATE_KEY = "passflow_session_state", this.loadPersistedMode(), this.loadPersistedSessionState();
|
|
117
|
+
}
|
|
118
|
+
sessionStateKey() {
|
|
119
|
+
return this.storageManager.appKey(this.SESSION_STATE_KEY);
|
|
120
|
+
}
|
|
121
|
+
reload() {
|
|
122
|
+
this.mode = "json_body", this.isInitializedFlag = !1, this.sessionState = "unknown", this.loadPersistedMode(), this.loadPersistedSessionState();
|
|
117
123
|
}
|
|
118
124
|
setMode(e) {
|
|
119
125
|
this.mode = e, this.isInitializedFlag = !0, this.persistMode();
|
|
@@ -157,48 +163,54 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
157
163
|
getSessionState() {
|
|
158
164
|
return this.sessionState;
|
|
159
165
|
}
|
|
160
|
-
reset(
|
|
161
|
-
this.mode = "json_body", this.sessionState = "unknown", this.isInitializedFlag = !1,
|
|
166
|
+
reset() {
|
|
167
|
+
this.mode = "json_body", this.sessionState = "unknown", this.isInitializedFlag = !1, this.clearPersistedSessionState(), this.storageManager.clearDeliveryMode();
|
|
162
168
|
}
|
|
163
169
|
loadPersistedMode() {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
e && Object.values(N).includes(e) && (this.mode = e, this.isInitializedFlag = !0);
|
|
167
|
-
} catch {}
|
|
170
|
+
let e = this.storageManager.getDeliveryMode();
|
|
171
|
+
e && (this.mode = e, this.isInitializedFlag = !0);
|
|
168
172
|
}
|
|
169
173
|
loadPersistedSessionState() {
|
|
170
174
|
try {
|
|
171
|
-
let e = this.storageManager.storage.getItem(this.
|
|
175
|
+
let e = this.storageManager.storage.getItem(this.sessionStateKey());
|
|
172
176
|
e && Object.values(se).includes(e) && (this.sessionState = e);
|
|
173
177
|
} catch {}
|
|
174
178
|
}
|
|
175
179
|
persistMode() {
|
|
176
|
-
|
|
177
|
-
this.storageManager.storage.setItem(this.DELIVERY_MODE_KEY, this.mode);
|
|
178
|
-
} catch {}
|
|
180
|
+
this.storageManager.setDeliveryMode(this.mode);
|
|
179
181
|
}
|
|
180
182
|
persistSessionState() {
|
|
181
183
|
try {
|
|
182
|
-
this.storageManager.storage.setItem(this.
|
|
183
|
-
} catch {}
|
|
184
|
-
}
|
|
185
|
-
clearPersistedMode() {
|
|
186
|
-
try {
|
|
187
|
-
this.storageManager.storage.removeItem(this.DELIVERY_MODE_KEY);
|
|
184
|
+
this.storageManager.storage.setItem(this.sessionStateKey(), this.sessionState);
|
|
188
185
|
} catch {}
|
|
189
186
|
}
|
|
190
187
|
clearPersistedSessionState() {
|
|
191
188
|
try {
|
|
192
|
-
this.storageManager.storage.removeItem(this.
|
|
189
|
+
this.storageManager.storage.removeItem(this.sessionStateKey());
|
|
193
190
|
} catch {}
|
|
194
191
|
}
|
|
195
192
|
}, P = "tokens_scopes", F = "passflowDeviceId", I = "passflowInvitationToken", le = "passflowPreviousRedirectUrl", ue = class {
|
|
196
193
|
constructor({ storage: e, prefix: t, appId: n } = {}) {
|
|
197
|
-
this.keyStoragePrefix = "", this.STORAGE_PREFIX = "passflow_", this.
|
|
194
|
+
this.keyStoragePrefix = "", this.STORAGE_PREFIX = "passflow_", this.storage = e ?? localStorage, this.keyStoragePrefix = t ? `${t}_` : "", this.scopes = `${this.keyStoragePrefix}${P}`, this.deviceId = `${this.keyStoragePrefix}${F}`, this.invitationToken = `${this.keyStoragePrefix}${I}`, this.previousRedirectUrl = `${this.keyStoragePrefix}${le}`, this.appId = n || void 0;
|
|
198
195
|
}
|
|
199
196
|
setAppId(e) {
|
|
200
197
|
this.appId = e || void 0;
|
|
201
198
|
}
|
|
199
|
+
getAppId() {
|
|
200
|
+
return this.appId;
|
|
201
|
+
}
|
|
202
|
+
appKey(e) {
|
|
203
|
+
return this.appId ? `${e}:${this.appId}` : e;
|
|
204
|
+
}
|
|
205
|
+
idTokenKey() {
|
|
206
|
+
return this.appKey(`${this.STORAGE_PREFIX}id_token`);
|
|
207
|
+
}
|
|
208
|
+
csrfTokenKey() {
|
|
209
|
+
return this.appKey(`${this.STORAGE_PREFIX}csrf_token`);
|
|
210
|
+
}
|
|
211
|
+
deliveryModeKey() {
|
|
212
|
+
return this.appKey(`${this.STORAGE_PREFIX}delivery_mode`);
|
|
213
|
+
}
|
|
202
214
|
ownToken(e) {
|
|
203
215
|
if (!e) return;
|
|
204
216
|
if (!this.appId) return e;
|
|
@@ -227,7 +239,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
227
239
|
this.getKeyForTokenType(M.access_token),
|
|
228
240
|
this.getKeyForTokenType(M.refresh_token),
|
|
229
241
|
this.getKeyForTokenType(M.id_token),
|
|
230
|
-
this.
|
|
242
|
+
this.idTokenKey()
|
|
231
243
|
];
|
|
232
244
|
}
|
|
233
245
|
holdsOtherAppToken(e) {
|
|
@@ -245,7 +257,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
245
257
|
}
|
|
246
258
|
saveTokens(e, t, n) {
|
|
247
259
|
let { id_token: r, access_token: i, refresh_token: a, scopes: o } = e;
|
|
248
|
-
if (t === N.Cookie || t === N.BFF) r && this.storage.setItem(this.
|
|
260
|
+
if (t === N.Cookie || t === N.BFF) r && this.storage.setItem(this.idTokenKey(), r);
|
|
249
261
|
else {
|
|
250
262
|
if (n?.replace && i) {
|
|
251
263
|
let e = this.holdsOnlyOtherAppSession();
|
|
@@ -260,7 +272,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
260
272
|
getTokens() {
|
|
261
273
|
let e = this.getDeliveryMode();
|
|
262
274
|
if (e === N.Cookie || e === N.BFF) {
|
|
263
|
-
let e = this.readToken(this.
|
|
275
|
+
let e = this.readToken(this.idTokenKey());
|
|
264
276
|
return e ? { id_token: e } : void 0;
|
|
265
277
|
}
|
|
266
278
|
let t = this.readToken(this.getKeyForTokenType(M.access_token));
|
|
@@ -278,7 +290,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
278
290
|
return !!this.readToken(this.getKeyForTokenType(M.access_token));
|
|
279
291
|
}
|
|
280
292
|
hasCookieModeIdToken() {
|
|
281
|
-
return !!this.readToken(this.
|
|
293
|
+
return !!this.readToken(this.idTokenKey());
|
|
282
294
|
}
|
|
283
295
|
deleteToken(e) {
|
|
284
296
|
let t = this.getKeyForTokenType(e);
|
|
@@ -287,7 +299,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
287
299
|
deleteTokens() {
|
|
288
300
|
let e = this.holdsOnlyOtherAppSession();
|
|
289
301
|
for (let e of this.tokenValueKeys()) this.removeOwnToken(e);
|
|
290
|
-
e ||
|
|
302
|
+
e || this.removePrefixed(this.scopes, P), this.clearDeliveryMode(), this.clearCsrfToken(), this.appId && this.getHostedSignIn() === void 0 && this.storage.getItem(this.hostedSignInKey()) || this.storage.removeItem(this.hostedSignInKey());
|
|
291
303
|
}
|
|
292
304
|
setHostedSignIn(e) {
|
|
293
305
|
this.storage.setItem(this.hostedSignInKey(), JSON.stringify({
|
|
@@ -335,55 +347,52 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
335
347
|
}
|
|
336
348
|
setDeliveryMode(e) {
|
|
337
349
|
try {
|
|
338
|
-
this.storage.setItem(this.
|
|
350
|
+
this.storage.setItem(this.deliveryModeKey(), e);
|
|
339
351
|
} catch {}
|
|
340
352
|
}
|
|
341
353
|
getDeliveryMode() {
|
|
342
354
|
try {
|
|
343
|
-
let e = this.storage.getItem(this.
|
|
355
|
+
let e = this.storage.getItem(this.deliveryModeKey());
|
|
344
356
|
if (e && Object.values(N).includes(e)) return e;
|
|
345
357
|
} catch {}
|
|
346
358
|
}
|
|
347
359
|
clearDeliveryMode() {
|
|
348
360
|
try {
|
|
349
|
-
this.storage.removeItem(this.
|
|
361
|
+
this.storage.removeItem(this.deliveryModeKey());
|
|
350
362
|
} catch {}
|
|
351
363
|
}
|
|
352
364
|
getIdToken() {
|
|
353
365
|
try {
|
|
354
|
-
return this.readToken(this.
|
|
366
|
+
return this.readToken(this.idTokenKey());
|
|
355
367
|
} catch {
|
|
356
368
|
return;
|
|
357
369
|
}
|
|
358
370
|
}
|
|
359
371
|
setIdToken(e) {
|
|
360
372
|
try {
|
|
361
|
-
this.storage.setItem(this.
|
|
373
|
+
this.storage.setItem(this.idTokenKey(), e);
|
|
362
374
|
} catch {}
|
|
363
375
|
}
|
|
364
376
|
clearIdToken() {
|
|
365
377
|
try {
|
|
366
|
-
this.removeOwnToken(this.
|
|
378
|
+
this.removeOwnToken(this.idTokenKey());
|
|
367
379
|
} catch {}
|
|
368
380
|
}
|
|
369
381
|
getCsrfToken() {
|
|
370
382
|
try {
|
|
371
|
-
return this.storage.getItem(this.
|
|
383
|
+
return this.storage.getItem(this.csrfTokenKey()) ?? void 0;
|
|
372
384
|
} catch {
|
|
373
385
|
return;
|
|
374
386
|
}
|
|
375
387
|
}
|
|
376
388
|
setCsrfToken(e) {
|
|
377
389
|
try {
|
|
378
|
-
this.storage.setItem(this.
|
|
390
|
+
this.storage.setItem(this.csrfTokenKey(), e);
|
|
379
391
|
} catch {}
|
|
380
392
|
}
|
|
381
393
|
clearCsrfToken() {
|
|
382
|
-
this.holdsOnlyOtherAppSession() || this.removeCsrfToken();
|
|
383
|
-
}
|
|
384
|
-
removeCsrfToken() {
|
|
385
394
|
try {
|
|
386
|
-
this.storage.removeItem(this.
|
|
395
|
+
this.storage.removeItem(this.csrfTokenKey());
|
|
387
396
|
} catch {}
|
|
388
397
|
}
|
|
389
398
|
tokenKeys() {
|
|
@@ -392,9 +401,9 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
392
401
|
this.getKeyForTokenType(M.access_token),
|
|
393
402
|
this.getKeyForTokenType(M.refresh_token),
|
|
394
403
|
this.scopes,
|
|
395
|
-
this.
|
|
396
|
-
this.
|
|
397
|
-
this.
|
|
404
|
+
this.idTokenKey(),
|
|
405
|
+
this.csrfTokenKey(),
|
|
406
|
+
this.deliveryModeKey()
|
|
398
407
|
];
|
|
399
408
|
}
|
|
400
409
|
getKeyForTokenType(e) {
|
|
@@ -904,7 +913,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
904
913
|
return this.send(Re.DELETE, e, t);
|
|
905
914
|
}
|
|
906
915
|
setAppId(e) {
|
|
907
|
-
this.appId = e, this.defaultHeaders = {
|
|
916
|
+
this.appId = e, this.tokenDeliveryManager.reload(), this.defaultHeaders = {
|
|
908
917
|
...this.defaultHeaders,
|
|
909
918
|
[c]: e
|
|
910
919
|
}, this.instance.defaults.headers[c] = e;
|
|
@@ -4090,7 +4099,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4090
4099
|
}
|
|
4091
4100
|
}, oa = class {
|
|
4092
4101
|
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination: jr() }, m) {
|
|
4093
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ce(n),
|
|
4102
|
+
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ce(n), this.setBffModeIfConfigured(), this.refresh = fi({
|
|
4094
4103
|
emit: this.createRefreshEmit(),
|
|
4095
4104
|
storage: n,
|
|
4096
4105
|
cache: i,
|
|
@@ -4102,7 +4111,10 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4102
4111
|
}), this.initializeSession();
|
|
4103
4112
|
}
|
|
4104
4113
|
setAppId(e) {
|
|
4105
|
-
this.appId = e;
|
|
4114
|
+
this.appId = e, this.tokenDeliveryManager.reload(), this.setBffModeIfConfigured();
|
|
4115
|
+
}
|
|
4116
|
+
setBffModeIfConfigured() {
|
|
4117
|
+
this.tokenExchangeConfig?.enabled && this.tokenDeliveryManager.setMode(N.BFF);
|
|
4106
4118
|
}
|
|
4107
4119
|
async isSimpleModeApp() {
|
|
4108
4120
|
try {
|
|
@@ -4128,7 +4140,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4128
4140
|
if (!this.tokenDeliveryManager.isCookieMode()) return !1;
|
|
4129
4141
|
try {
|
|
4130
4142
|
let e = await this.authApi.validateSession();
|
|
4131
|
-
return e
|
|
4143
|
+
return e?.id ? (this.tokenDeliveryManager.setSessionValid(), this.subscribeStore.notify(G.SessionRestored, e), !0) : (this.tokenDeliveryManager.setSessionInvalid(), !1);
|
|
4132
4144
|
} catch {
|
|
4133
4145
|
return this.tokenDeliveryManager.setSessionInvalid(), !1;
|
|
4134
4146
|
}
|
|
@@ -4618,8 +4630,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4618
4630
|
} catch {}
|
|
4619
4631
|
}
|
|
4620
4632
|
clearLocalSession() {
|
|
4621
|
-
|
|
4622
|
-
this.storageManager.deleteTokens(), this.storageManager.clearIdToken(), this.storageManager.clearCsrfToken(), this.tokenDeliveryManager.reset(e), this.tokenCacheService.setTokensCache(void 0), this.tokenCacheService.stopTokenCheck?.();
|
|
4633
|
+
this.storageManager.deleteTokens(), this.tokenDeliveryManager.reset(), this.tokenCacheService.setTokensCache(void 0), this.tokenCacheService.stopTokenCheck?.();
|
|
4623
4634
|
}
|
|
4624
4635
|
readSessionPin() {
|
|
4625
4636
|
try {
|