@mereb/web-runtime 0.0.4 → 0.0.5
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/config.d.ts +2 -0
- package/dist/config.js +4 -2
- package/dist/providers/auth.js +18 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type ShellRuntimeEnv = {
|
|
|
5
5
|
KEYCLOAK_URL?: string;
|
|
6
6
|
KC_REALM?: string;
|
|
7
7
|
KC_CLIENT_ID?: string;
|
|
8
|
+
KC_SILENT_CHECK_SSO_PATH?: string;
|
|
8
9
|
};
|
|
9
10
|
declare global {
|
|
10
11
|
interface Window {
|
|
@@ -19,6 +20,7 @@ export declare const appConfig: {
|
|
|
19
20
|
url: string;
|
|
20
21
|
realm: string;
|
|
21
22
|
clientId: string;
|
|
23
|
+
silentCheckSsoPath: string;
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
export type AppConfig = typeof appConfig;
|
package/dist/config.js
CHANGED
|
@@ -4,7 +4,8 @@ const defaultRuntime = {
|
|
|
4
4
|
FLAGS_URL: 'http://localhost:8000/flags',
|
|
5
5
|
KEYCLOAK_URL: 'http://localhost:8081',
|
|
6
6
|
KC_REALM: 'social',
|
|
7
|
-
KC_CLIENT_ID: 'web-shell'
|
|
7
|
+
KC_CLIENT_ID: 'web-shell',
|
|
8
|
+
KC_SILENT_CHECK_SSO_PATH: ''
|
|
8
9
|
};
|
|
9
10
|
const runtimeEnv = globalThis.window === undefined ? {} : globalThis.window.__MEREB_ENV__ ?? {};
|
|
10
11
|
function resolveEnv(metaValue, key) {
|
|
@@ -25,7 +26,8 @@ export const appConfig = {
|
|
|
25
26
|
keycloak: {
|
|
26
27
|
url: resolveEnv(import.meta.env.VITE_KEYCLOAK_URL, 'KEYCLOAK_URL'),
|
|
27
28
|
realm: resolveEnv(import.meta.env.VITE_KC_REALM, 'KC_REALM'),
|
|
28
|
-
clientId: resolveEnv(import.meta.env.VITE_KC_CLIENT_ID, 'KC_CLIENT_ID')
|
|
29
|
+
clientId: resolveEnv(import.meta.env.VITE_KC_CLIENT_ID, 'KC_CLIENT_ID'),
|
|
30
|
+
silentCheckSsoPath: resolveEnv(import.meta.env.VITE_KC_SILENT_CHECK_SSO_PATH, 'KC_SILENT_CHECK_SSO_PATH')
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
export function resolveKeycloakMissingKeys() {
|
package/dist/providers/auth.js
CHANGED
|
@@ -99,6 +99,16 @@ function resetPkceState(instance) {
|
|
|
99
99
|
;
|
|
100
100
|
instance.pkceMethod = undefined;
|
|
101
101
|
}
|
|
102
|
+
function resolveSilentCheckSsoRedirectUri() {
|
|
103
|
+
if (typeof window === 'undefined' || !window.location?.origin) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const silentCheckSsoPath = appConfig.keycloak.silentCheckSsoPath?.trim();
|
|
107
|
+
if (!silentCheckSsoPath) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
return new URL(silentCheckSsoPath, window.location.origin).toString();
|
|
111
|
+
}
|
|
102
112
|
async function attemptKeycloakInit(instance, options) {
|
|
103
113
|
try {
|
|
104
114
|
return await instance.init(options);
|
|
@@ -119,7 +129,15 @@ function initKeycloak() {
|
|
|
119
129
|
return Promise.resolve(false);
|
|
120
130
|
if (!keycloakInitPromise) {
|
|
121
131
|
const instance = getKeycloak();
|
|
132
|
+
const silentCheckSsoRedirectUri = resolveSilentCheckSsoRedirectUri();
|
|
122
133
|
const options = {
|
|
134
|
+
...(silentCheckSsoRedirectUri
|
|
135
|
+
? {
|
|
136
|
+
onLoad: 'check-sso',
|
|
137
|
+
silentCheckSsoRedirectUri,
|
|
138
|
+
silentCheckSsoFallback: false
|
|
139
|
+
}
|
|
140
|
+
: {}),
|
|
123
141
|
pkceMethod: 'S256',
|
|
124
142
|
checkLoginIframe: false,
|
|
125
143
|
useNonce: false
|