oidc-spa 8.2.0 → 8.2.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/core/AuthResponse.d.ts +0 -5
- package/core/AuthResponse.js +0 -25
- package/core/AuthResponse.js.map +1 -1
- package/core/OidcMetadata.d.ts +5 -0
- package/core/OidcMetadata.js +56 -0
- package/core/OidcMetadata.js.map +1 -1
- package/core/createOidc.d.ts +4 -3
- package/core/createOidc.js +229 -197
- package/core/createOidc.js.map +1 -1
- package/core/diagnostic.d.ts +0 -1
- package/core/diagnostic.js +18 -5
- package/core/diagnostic.js.map +1 -1
- package/core/instancesThatCantUseIframes.d.ts +2 -0
- package/core/instancesThatCantUseIframes.js +20 -0
- package/core/instancesThatCantUseIframes.js.map +1 -0
- package/core/loginOrGoToAuthServer.d.ts +1 -1
- package/core/loginOrGoToAuthServer.js +4 -16
- package/core/loginOrGoToAuthServer.js.map +1 -1
- package/core/loginSilent.d.ts +1 -2
- package/core/loginSilent.js +3 -21
- package/core/loginSilent.js.map +1 -1
- package/core/persistedAuthState.d.ts +1 -0
- package/core/persistedAuthState.js +14 -4
- package/core/persistedAuthState.js.map +1 -1
- package/esm/core/AuthResponse.d.ts +0 -5
- package/esm/core/AuthResponse.js +0 -23
- package/esm/core/AuthResponse.js.map +1 -1
- package/esm/core/OidcMetadata.d.ts +5 -0
- package/esm/core/OidcMetadata.js +54 -0
- package/esm/core/OidcMetadata.js.map +1 -1
- package/esm/core/createOidc.d.ts +4 -3
- package/esm/core/createOidc.js +230 -198
- package/esm/core/createOidc.js.map +1 -1
- package/esm/core/diagnostic.d.ts +0 -1
- package/esm/core/diagnostic.js +15 -1
- package/esm/core/diagnostic.js.map +1 -1
- package/esm/core/instancesThatCantUseIframes.d.ts +2 -0
- package/esm/core/instancesThatCantUseIframes.js +16 -0
- package/esm/core/instancesThatCantUseIframes.js.map +1 -0
- package/esm/core/loginOrGoToAuthServer.d.ts +1 -1
- package/esm/core/loginOrGoToAuthServer.js +4 -16
- package/esm/core/loginOrGoToAuthServer.js.map +1 -1
- package/esm/core/loginSilent.d.ts +1 -2
- package/esm/core/loginSilent.js +3 -21
- package/esm/core/loginSilent.js.map +1 -1
- package/esm/core/persistedAuthState.d.ts +1 -0
- package/esm/core/persistedAuthState.js +14 -4
- package/esm/core/persistedAuthState.js.map +1 -1
- package/esm/keycloak/keycloakIssuerUriParsed.js +8 -1
- package/esm/keycloak/keycloakIssuerUriParsed.js.map +1 -1
- package/esm/tools/isLikelyDevServer.d.ts +1 -0
- package/esm/tools/isLikelyDevServer.js +14 -0
- package/esm/tools/isLikelyDevServer.js.map +1 -0
- package/esm/tools/{EphemeralSessionStorage.d.ts → lazySessionStorage.d.ts} +2 -4
- package/esm/tools/lazySessionStorage.js +81 -0
- package/esm/tools/lazySessionStorage.js.map +1 -0
- package/keycloak/keycloakIssuerUriParsed.js +8 -1
- package/keycloak/keycloakIssuerUriParsed.js.map +1 -1
- package/package.json +1 -1
- package/src/core/AuthResponse.ts +0 -36
- package/src/core/OidcMetadata.ts +75 -0
- package/src/core/createOidc.ts +277 -264
- package/src/core/diagnostic.ts +21 -2
- package/src/core/instancesThatCantUseIframes.ts +24 -0
- package/src/core/loginOrGoToAuthServer.ts +5 -22
- package/src/core/loginSilent.ts +4 -27
- package/src/core/persistedAuthState.ts +27 -5
- package/src/keycloak/keycloakIssuerUriParsed.ts +10 -1
- package/src/tools/isLikelyDevServer.ts +17 -0
- package/src/tools/lazySessionStorage.ts +119 -0
- package/src/vite-plugin/manageOptimizedDeps.ts +2 -0
- package/tools/isLikelyDevServer.d.ts +1 -0
- package/tools/isLikelyDevServer.js +17 -0
- package/tools/isLikelyDevServer.js.map +1 -0
- package/tools/{EphemeralSessionStorage.d.ts → lazySessionStorage.d.ts} +2 -4
- package/tools/lazySessionStorage.js +84 -0
- package/tools/lazySessionStorage.js.map +1 -0
- package/vite-plugin/manageOptimizedDeps.js +1 -0
- package/vite-plugin/manageOptimizedDeps.js.map +1 -1
- package/esm/tools/EphemeralSessionStorage.js +0 -143
- package/esm/tools/EphemeralSessionStorage.js.map +0 -1
- package/src/tools/EphemeralSessionStorage.ts +0 -225
- package/tools/EphemeralSessionStorage.js +0 -146
- package/tools/EphemeralSessionStorage.js.map +0 -1
package/src/core/diagnostic.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { OidcInitializationError } from "./OidcInitializationError";
|
|
2
2
|
import { isKeycloak, createKeycloakUtils } from "../keycloak";
|
|
3
3
|
import { getIsValidRemoteJson } from "../tools/getIsValidRemoteJson";
|
|
4
|
-
|
|
5
|
-
export const WELL_KNOWN_PATH = "/.well-known/openid-configuration";
|
|
4
|
+
import { WELL_KNOWN_PATH } from "./OidcMetadata";
|
|
6
5
|
|
|
7
6
|
export async function createWellKnownOidcConfigurationEndpointUnreachableInitializationError(params: {
|
|
8
7
|
issuerUri: string;
|
|
@@ -95,6 +94,16 @@ export async function createIframeTimeoutInitializationError(params: {
|
|
|
95
94
|
}): Promise<OidcInitializationError> {
|
|
96
95
|
const { redirectUri, issuerUri, clientId, noIframe } = params;
|
|
97
96
|
|
|
97
|
+
check_if_well_known_endpoint_is_reachable: {
|
|
98
|
+
const isValid = await getIsValidRemoteJson(`${issuerUri}${WELL_KNOWN_PATH}`);
|
|
99
|
+
|
|
100
|
+
if (isValid) {
|
|
101
|
+
break check_if_well_known_endpoint_is_reachable;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return createWellKnownOidcConfigurationEndpointUnreachableInitializationError({ issuerUri });
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
iframe_blocked: {
|
|
99
108
|
if (noIframe) {
|
|
100
109
|
break iframe_blocked;
|
|
@@ -233,6 +242,16 @@ export async function createFailedToFetchTokenEndpointInitializationError(params
|
|
|
233
242
|
}) {
|
|
234
243
|
const { issuerUri, clientId } = params;
|
|
235
244
|
|
|
245
|
+
check_if_well_known_endpoint_is_reachable: {
|
|
246
|
+
const isValid = await getIsValidRemoteJson(`${issuerUri}${WELL_KNOWN_PATH}`);
|
|
247
|
+
|
|
248
|
+
if (isValid) {
|
|
249
|
+
break check_if_well_known_endpoint_is_reachable;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return createWellKnownOidcConfigurationEndpointUnreachableInitializationError({ issuerUri });
|
|
253
|
+
}
|
|
254
|
+
|
|
236
255
|
return new OidcInitializationError({
|
|
237
256
|
isAuthServerLikelyDown: false,
|
|
238
257
|
messageOrCause: [
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createStatefulEvt } from "../tools/StatefulEvt";
|
|
2
|
+
|
|
3
|
+
const SESSION_STORAGE_KEY = "oidc-spa:more-than-one-instance-cant-use-iframe";
|
|
4
|
+
|
|
5
|
+
export const evtIsThereMoreThanOneInstanceThatCantUserIframes = createStatefulEvt(
|
|
6
|
+
() => sessionStorage.getItem(SESSION_STORAGE_KEY) !== null
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
let count = 0;
|
|
10
|
+
|
|
11
|
+
export function notifyNewInstanceThatCantUseIframes() {
|
|
12
|
+
count++;
|
|
13
|
+
|
|
14
|
+
if (count === 1) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (evtIsThereMoreThanOneInstanceThatCantUserIframes.current) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
sessionStorage.setItem(SESSION_STORAGE_KEY, "true");
|
|
23
|
+
evtIsThereMoreThanOneInstanceThatCantUserIframes.current = true;
|
|
24
|
+
}
|
|
@@ -20,7 +20,6 @@ namespace Params {
|
|
|
20
20
|
redirectUrl: string;
|
|
21
21
|
extraQueryParams_local: Record<string, string | undefined> | undefined;
|
|
22
22
|
transformUrlBeforeRedirect_local: ((url: string) => string) | undefined;
|
|
23
|
-
onCantFetchWellKnownEndpointError: () => void;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
export type Login = Common & {
|
|
@@ -31,6 +30,7 @@ namespace Params {
|
|
|
31
30
|
| "ensure no interaction"
|
|
32
31
|
| "ensure interaction"
|
|
33
32
|
| "directly redirect if active session show login otherwise";
|
|
33
|
+
preRedirectHook: (() => void) | undefined;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export type GoToAuthServer = Common & {
|
|
@@ -90,10 +90,8 @@ export function createLoginOrGoToAuthServer(params: {
|
|
|
90
90
|
redirectUrl: redirectUrl_params,
|
|
91
91
|
extraQueryParams_local,
|
|
92
92
|
transformUrlBeforeRedirect_local,
|
|
93
|
-
onCantFetchWellKnownEndpointError: onCantFetchWellKnownEndpointError_params,
|
|
94
93
|
...rest
|
|
95
94
|
} = params;
|
|
96
|
-
let onCantFetchWellKnownEndpointError = onCantFetchWellKnownEndpointError_params;
|
|
97
95
|
|
|
98
96
|
log?.(`Calling loginOrGoToAuthServer ${JSON.stringify(params, null, 2)}`);
|
|
99
97
|
|
|
@@ -147,12 +145,6 @@ export function createLoginOrGoToAuthServer(params: {
|
|
|
147
145
|
};
|
|
148
146
|
|
|
149
147
|
window.addEventListener("pageshow", callback);
|
|
150
|
-
|
|
151
|
-
onCantFetchWellKnownEndpointError = () => {
|
|
152
|
-
window.removeEventListener("pageshow", callback);
|
|
153
|
-
onCantFetchWellKnownEndpointError_params();
|
|
154
|
-
};
|
|
155
|
-
|
|
156
148
|
break bf_cache_handling;
|
|
157
149
|
}
|
|
158
150
|
|
|
@@ -183,12 +175,6 @@ export function createLoginOrGoToAuthServer(params: {
|
|
|
183
175
|
};
|
|
184
176
|
|
|
185
177
|
window.addEventListener("pageshow", callback);
|
|
186
|
-
|
|
187
|
-
onCantFetchWellKnownEndpointError = () => {
|
|
188
|
-
window.removeEventListener("pageshow", callback);
|
|
189
|
-
globalContext.evtHasLoginBeenCalled.current = false;
|
|
190
|
-
onCantFetchWellKnownEndpointError_params();
|
|
191
|
-
};
|
|
192
178
|
}
|
|
193
179
|
}
|
|
194
180
|
|
|
@@ -320,6 +306,10 @@ export function createLoginOrGoToAuthServer(params: {
|
|
|
320
306
|
|
|
321
307
|
log?.(`redirectMethod: ${redirectMethod}`);
|
|
322
308
|
|
|
309
|
+
if (rest.action === "login") {
|
|
310
|
+
rest.preRedirectHook?.();
|
|
311
|
+
}
|
|
312
|
+
|
|
323
313
|
return oidcClientTsUserManager
|
|
324
314
|
.signinRedirect({
|
|
325
315
|
state: stateData,
|
|
@@ -348,13 +338,6 @@ export function createLoginOrGoToAuthServer(params: {
|
|
|
348
338
|
.then(
|
|
349
339
|
() => new Promise<never>(() => {}),
|
|
350
340
|
(error: Error) => {
|
|
351
|
-
if (error.message === "Failed to fetch") {
|
|
352
|
-
// NOTE: See ./loginSilent for explanation.
|
|
353
|
-
onCantFetchWellKnownEndpointError();
|
|
354
|
-
|
|
355
|
-
return new Promise<never>(() => {});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
341
|
if (error.message.includes("Crypto.subtle is available only in secure contexts")) {
|
|
359
342
|
throw new Error(
|
|
360
343
|
[
|
package/src/core/loginSilent.ts
CHANGED
|
@@ -20,8 +20,7 @@ type ResultOfLoginSilent =
|
|
|
20
20
|
authResponse: AuthResponse;
|
|
21
21
|
}
|
|
22
22
|
| {
|
|
23
|
-
outcome: "
|
|
24
|
-
cause: "timeout" | "can't reach well-known oidc endpoint";
|
|
23
|
+
outcome: "timeout";
|
|
25
24
|
}
|
|
26
25
|
| {
|
|
27
26
|
outcome: "token refreshed using refresh token";
|
|
@@ -106,8 +105,7 @@ export async function loginSilent(params: {
|
|
|
106
105
|
const timeouts = [
|
|
107
106
|
setTimeout(() => {
|
|
108
107
|
dResult.resolve({
|
|
109
|
-
outcome: "
|
|
110
|
-
cause: "timeout"
|
|
108
|
+
outcome: "timeout"
|
|
111
109
|
});
|
|
112
110
|
}, timeoutDelayMs),
|
|
113
111
|
setTimeout(() => {
|
|
@@ -259,28 +257,7 @@ export async function loginSilent(params: {
|
|
|
259
257
|
oidcClientTsUser
|
|
260
258
|
});
|
|
261
259
|
},
|
|
262
|
-
(
|
|
263
|
-
if (error.message === "Failed to fetch") {
|
|
264
|
-
// NOTE: If we got an error here it means that the fetch to the
|
|
265
|
-
// well-known oidc endpoint failed.
|
|
266
|
-
// This usually means that the server is down or that the issuerUri
|
|
267
|
-
// is not pointing to a valid oidc server.
|
|
268
|
-
// It could be a CORS error on the well-known endpoint but it's unlikely.
|
|
269
|
-
|
|
270
|
-
// NOTE: This error should happen well before we displayed
|
|
271
|
-
// the warning notifying that something is probably misconfigured.
|
|
272
|
-
// wasSuccess shouldn't really be a required parameter but we do it
|
|
273
|
-
// for peace of mind.
|
|
274
|
-
clearTimeouts({ wasSuccess: false });
|
|
275
|
-
|
|
276
|
-
dResult.resolve({
|
|
277
|
-
outcome: "failure",
|
|
278
|
-
cause: "can't reach well-known oidc endpoint"
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
|
|
260
|
+
() => {
|
|
284
261
|
// NOTE: Here, except error on our understanding there can't be any other
|
|
285
262
|
// error than timeout so we fail silently and let the timeout expire.
|
|
286
263
|
}
|
|
@@ -289,7 +266,7 @@ export async function loginSilent(params: {
|
|
|
289
266
|
dResult.pr.then(result => {
|
|
290
267
|
clearSessionStoragePublicKey();
|
|
291
268
|
|
|
292
|
-
if (result.outcome === "
|
|
269
|
+
if (result.outcome === "timeout") {
|
|
293
270
|
clearStateStore({ stateUrlParamValue: stateUrlParamValue_instance });
|
|
294
271
|
}
|
|
295
272
|
});
|
|
@@ -30,6 +30,7 @@ export function persistAuthState(params: {
|
|
|
30
30
|
stateDescription: "logged in";
|
|
31
31
|
idleSessionLifetimeInSeconds: number | undefined;
|
|
32
32
|
refreshTokenExpirationTime: number | undefined;
|
|
33
|
+
serverDateNow: number;
|
|
33
34
|
}
|
|
34
35
|
| {
|
|
35
36
|
stateDescription: "explicitly logged out";
|
|
@@ -56,14 +57,35 @@ export function persistAuthState(params: {
|
|
|
56
57
|
__brand: "PersistedAuthState-v1",
|
|
57
58
|
stateDescription: "logged in",
|
|
58
59
|
untilTime: (() => {
|
|
59
|
-
const {
|
|
60
|
-
|
|
60
|
+
const {
|
|
61
|
+
idleSessionLifetimeInSeconds,
|
|
62
|
+
refreshTokenExpirationTime,
|
|
63
|
+
serverDateNow
|
|
64
|
+
} = state;
|
|
65
|
+
|
|
66
|
+
const untilTime_real = (() => {
|
|
67
|
+
if (refreshTokenExpirationTime === undefined) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const msBeforeExpirationOfTheSession =
|
|
72
|
+
refreshTokenExpirationTime - serverDateNow;
|
|
73
|
+
|
|
74
|
+
return Date.now() + msBeforeExpirationOfTheSession;
|
|
75
|
+
})();
|
|
76
|
+
|
|
77
|
+
const unitTime_userOverwrite = (() => {
|
|
78
|
+
if (idleSessionLifetimeInSeconds === undefined) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
61
81
|
|
|
62
|
-
if (idleSessionLifetimeInSeconds !== undefined) {
|
|
63
82
|
return Date.now() + idleSessionLifetimeInSeconds * 1000;
|
|
64
|
-
}
|
|
83
|
+
})();
|
|
65
84
|
|
|
66
|
-
return
|
|
85
|
+
return Math.min(
|
|
86
|
+
untilTime_real ?? Number.POSITIVE_INFINITY,
|
|
87
|
+
unitTime_userOverwrite ?? Number.POSITIVE_INFINITY
|
|
88
|
+
);
|
|
67
89
|
})()
|
|
68
90
|
});
|
|
69
91
|
case "explicitly logged out":
|
|
@@ -11,7 +11,16 @@ export type KeycloakIssuerUriParsed = {
|
|
|
11
11
|
export function parseKeycloakIssuerUri(params: { issuerUri: string }): KeycloakIssuerUriParsed {
|
|
12
12
|
const { issuerUri } = params;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
if (!isKeycloak({ issuerUri })) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
[
|
|
17
|
+
`oidc-spa: The issuer uri provided ${issuerUri}`,
|
|
18
|
+
"if you are in an environnement that should support multiple",
|
|
19
|
+
"auth provider, you should first test `isKeycloakUrl({ issuerUri })`",
|
|
20
|
+
"before calling parseKeycloakIssuerUri({ issuerUri })"
|
|
21
|
+
].join(" ")
|
|
22
|
+
);
|
|
23
|
+
}
|
|
15
24
|
|
|
16
25
|
const url = new URL(issuerUri.replace(/\/$/, ""));
|
|
17
26
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function getIsLikelyDevServer(): boolean {
|
|
2
|
+
const origin = window.location.origin;
|
|
3
|
+
|
|
4
|
+
if (/^https?:\/\/localhost/.test(origin)) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (/^https?:\/\/\[::\]/.test(origin)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (/^https?:\/\/127.0.0.1/.test(origin)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { assert } from "../tools/tsafe/assert";
|
|
2
|
+
|
|
3
|
+
const SESSION_STORAGE_PREFIX = "lazy-session-storage:";
|
|
4
|
+
|
|
5
|
+
export type LazySessionStorage = {
|
|
6
|
+
// `Storage` methods, we don't use the type directly because it has [name: string]: any;
|
|
7
|
+
readonly length: number;
|
|
8
|
+
clear(): void;
|
|
9
|
+
getItem(key: string): string | null;
|
|
10
|
+
key(index: number): string | null;
|
|
11
|
+
removeItem(key: string): void;
|
|
12
|
+
setItem(key: string, value: string): void;
|
|
13
|
+
|
|
14
|
+
// Custom method
|
|
15
|
+
persistCurrentStateAndSubsequentChanges: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function createLazySessionStorage(): LazySessionStorage {
|
|
19
|
+
const entries: { key: string; value: string }[] = [];
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
22
|
+
const key = sessionStorage.key(i);
|
|
23
|
+
assert(key !== null, "470498");
|
|
24
|
+
|
|
25
|
+
if (!key.startsWith(SESSION_STORAGE_PREFIX)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const value = sessionStorage.getItem(key);
|
|
30
|
+
|
|
31
|
+
assert(value !== null, "846771");
|
|
32
|
+
|
|
33
|
+
sessionStorage.removeItem(key);
|
|
34
|
+
|
|
35
|
+
entries.push({
|
|
36
|
+
key: key.slice(SESSION_STORAGE_PREFIX.length),
|
|
37
|
+
value
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let isPersistenceEnabled = false;
|
|
42
|
+
|
|
43
|
+
const storage: LazySessionStorage = {
|
|
44
|
+
persistCurrentStateAndSubsequentChanges: () => {
|
|
45
|
+
isPersistenceEnabled = true;
|
|
46
|
+
|
|
47
|
+
for (let i = 0; i < storage.length; i++) {
|
|
48
|
+
const key = storage.key(i);
|
|
49
|
+
assert(key !== null, "803385");
|
|
50
|
+
|
|
51
|
+
const value = storage.getItem(key);
|
|
52
|
+
|
|
53
|
+
assert(value !== null, "777098");
|
|
54
|
+
|
|
55
|
+
storage.setItem(key, value);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
get length() {
|
|
59
|
+
return entries.length;
|
|
60
|
+
},
|
|
61
|
+
key: index => {
|
|
62
|
+
const entry = entries[index];
|
|
63
|
+
|
|
64
|
+
if (entry === undefined) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return entry.key;
|
|
69
|
+
},
|
|
70
|
+
removeItem: key => {
|
|
71
|
+
const entry = entries.find(entry => entry.key === key);
|
|
72
|
+
|
|
73
|
+
if (entry === undefined) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
sessionStorage.removeItem(`${SESSION_STORAGE_PREFIX}${entry.key}`);
|
|
78
|
+
|
|
79
|
+
const index = entries.indexOf(entry);
|
|
80
|
+
|
|
81
|
+
entries.splice(index, 1);
|
|
82
|
+
},
|
|
83
|
+
clear: () => {
|
|
84
|
+
for (let i = 0; i < storage.length; i++) {
|
|
85
|
+
const key = storage.key(i);
|
|
86
|
+
assert(key !== null, "290875");
|
|
87
|
+
storage.removeItem(key);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
getItem: key => {
|
|
91
|
+
const entry = entries.find(entry => entry.key === key);
|
|
92
|
+
if (entry === undefined) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return entry.value;
|
|
96
|
+
},
|
|
97
|
+
setItem: (key, value) => {
|
|
98
|
+
if (isPersistenceEnabled) {
|
|
99
|
+
sessionStorage.setItem(`${SESSION_STORAGE_PREFIX}${key}`, value);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
update: {
|
|
103
|
+
const entry = entries.find(entry => entry.key === key);
|
|
104
|
+
|
|
105
|
+
if (entry === undefined) {
|
|
106
|
+
break update;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
entry.value = value;
|
|
110
|
+
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
entries.push({ key, value });
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return storage;
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getIsLikelyDevServer(): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIsLikelyDevServer = getIsLikelyDevServer;
|
|
4
|
+
function getIsLikelyDevServer() {
|
|
5
|
+
const origin = window.location.origin;
|
|
6
|
+
if (/^https?:\/\/localhost/.test(origin)) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (/^https?:\/\/\[::\]/.test(origin)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (/^https?:\/\/127.0.0.1/.test(origin)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=isLikelyDevServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isLikelyDevServer.js","sourceRoot":"","sources":["../src/tools/isLikelyDevServer.ts"],"names":[],"mappings":";;AAAA,oDAgBC;AAhBD,SAAgB,oBAAoB;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAEtC,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type LazySessionStorage = {
|
|
2
2
|
readonly length: number;
|
|
3
3
|
clear(): void;
|
|
4
4
|
getItem(key: string): string | null;
|
|
@@ -7,6 +7,4 @@ export type EphemeralSessionStorage = {
|
|
|
7
7
|
setItem(key: string, value: string): void;
|
|
8
8
|
persistCurrentStateAndSubsequentChanges: () => void;
|
|
9
9
|
};
|
|
10
|
-
export declare function
|
|
11
|
-
sessionStorageTtlMs: number;
|
|
12
|
-
}): EphemeralSessionStorage;
|
|
10
|
+
export declare function createLazySessionStorage(): LazySessionStorage;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLazySessionStorage = createLazySessionStorage;
|
|
4
|
+
const assert_1 = require("../tools/tsafe/assert");
|
|
5
|
+
const SESSION_STORAGE_PREFIX = "lazy-session-storage:";
|
|
6
|
+
function createLazySessionStorage() {
|
|
7
|
+
const entries = [];
|
|
8
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
9
|
+
const key = sessionStorage.key(i);
|
|
10
|
+
(0, assert_1.assert)(key !== null, "470498");
|
|
11
|
+
if (!key.startsWith(SESSION_STORAGE_PREFIX)) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const value = sessionStorage.getItem(key);
|
|
15
|
+
(0, assert_1.assert)(value !== null, "846771");
|
|
16
|
+
sessionStorage.removeItem(key);
|
|
17
|
+
entries.push({
|
|
18
|
+
key: key.slice(SESSION_STORAGE_PREFIX.length),
|
|
19
|
+
value
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
let isPersistenceEnabled = false;
|
|
23
|
+
const storage = {
|
|
24
|
+
persistCurrentStateAndSubsequentChanges: () => {
|
|
25
|
+
isPersistenceEnabled = true;
|
|
26
|
+
for (let i = 0; i < storage.length; i++) {
|
|
27
|
+
const key = storage.key(i);
|
|
28
|
+
(0, assert_1.assert)(key !== null, "803385");
|
|
29
|
+
const value = storage.getItem(key);
|
|
30
|
+
(0, assert_1.assert)(value !== null, "777098");
|
|
31
|
+
storage.setItem(key, value);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
get length() {
|
|
35
|
+
return entries.length;
|
|
36
|
+
},
|
|
37
|
+
key: index => {
|
|
38
|
+
const entry = entries[index];
|
|
39
|
+
if (entry === undefined) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return entry.key;
|
|
43
|
+
},
|
|
44
|
+
removeItem: key => {
|
|
45
|
+
const entry = entries.find(entry => entry.key === key);
|
|
46
|
+
if (entry === undefined) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
sessionStorage.removeItem(`${SESSION_STORAGE_PREFIX}${entry.key}`);
|
|
50
|
+
const index = entries.indexOf(entry);
|
|
51
|
+
entries.splice(index, 1);
|
|
52
|
+
},
|
|
53
|
+
clear: () => {
|
|
54
|
+
for (let i = 0; i < storage.length; i++) {
|
|
55
|
+
const key = storage.key(i);
|
|
56
|
+
(0, assert_1.assert)(key !== null, "290875");
|
|
57
|
+
storage.removeItem(key);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
getItem: key => {
|
|
61
|
+
const entry = entries.find(entry => entry.key === key);
|
|
62
|
+
if (entry === undefined) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return entry.value;
|
|
66
|
+
},
|
|
67
|
+
setItem: (key, value) => {
|
|
68
|
+
if (isPersistenceEnabled) {
|
|
69
|
+
sessionStorage.setItem(`${SESSION_STORAGE_PREFIX}${key}`, value);
|
|
70
|
+
}
|
|
71
|
+
update: {
|
|
72
|
+
const entry = entries.find(entry => entry.key === key);
|
|
73
|
+
if (entry === undefined) {
|
|
74
|
+
break update;
|
|
75
|
+
}
|
|
76
|
+
entry.value = value;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
entries.push({ key, value });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return storage;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=lazySessionStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazySessionStorage.js","sourceRoot":"","sources":["../src/tools/lazySessionStorage.ts"],"names":[],"mappings":";;AAiBA,4DAqGC;AAtHD,kDAA+C;AAE/C,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAevD,SAAgB,wBAAwB;IACpC,MAAM,OAAO,GAAqC,EAAE,CAAC;IAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClC,IAAA,eAAM,EAAC,GAAG,KAAK,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE/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G,sBAAsB,GAAG,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;YACrE,CAAC;YAED,MAAM,EAAE,CAAC;gBACL,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;gBAEvD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACtB,MAAM,MAAM,CAAC;gBACjB,CAAC;gBAED,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;gBAEpB,OAAO;YACX,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QACjC,CAAC;KACJ,CAAC;IAEF,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -76,6 +76,7 @@ function manageOptimizedDeps(params) {
|
|
|
76
76
|
if (isZodInstalled) {
|
|
77
77
|
moduleNames_include.push("zod");
|
|
78
78
|
}
|
|
79
|
+
moduleNames_include.push("oidc-spa");
|
|
79
80
|
((_b = (userConfig.optimizeDeps ?? (userConfig.optimizeDeps = {}))).include ?? (_b.include = [])).push(...moduleNames_include);
|
|
80
81
|
}
|
|
81
82
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manageOptimizedDeps.js","sourceRoot":"","sources":["../src/vite-plugin/manageOptimizedDeps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,
|
|
1
|
+
{"version":3,"file":"manageOptimizedDeps.js","sourceRoot":"","sources":["../src/vite-plugin/manageOptimizedDeps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,kDA0DC;AAhED,4FAAqF;AACrF,4CAA8B;AAC9B,+BAAwC;AAExC,kDAA+C;AAE/C,SAAgB,mBAAmB,CAAC,MAGnC;;IACG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;I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