@onecx/shell-auth 8.0.0-rc.9 → 8.0.0
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 +0 -1
- package/fesm2022/onecx-shell-auth.mjs +54 -15
- package/fesm2022/onecx-shell-auth.mjs.map +1 -1
- package/package.json +6 -8
- package/types/onecx-shell-auth.d.ts +3 -0
- package/migrations/index.d.ts +0 -0
- package/migrations/index.js +0 -2
- package/migrations/index.js.map +0 -1
- package/migrations.json +0 -0
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@ npm install @onecx/shell-auth
|
|
|
11
11
|
|
|
12
12
|
## Additional Commands
|
|
13
13
|
- `npx nx run shell-auth:build` - Builds the library and outputs the result to the `dist` folder.
|
|
14
|
-
- `npx nx run shell-auth:build-migrations` - Builds the migration files for the library.
|
|
15
14
|
- `npx nx run shell-auth:test` - Runs the unit tests for the library.
|
|
16
15
|
- `npx nx run shell-auth:lint` - Lints the library's codebase.
|
|
17
16
|
- `npx nx run shell-auth:release` - Releases a new version of the library to npm, following semantic versioning guidelines.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { registerRemotes, loadRemote } from '@module-federation/enhanced/runtime';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { inject, Injectable, Injector, provideAppInitializer } from '@angular/core';
|
|
4
4
|
import { ConfigurationService, CONFIG_KEY, AppStateService } from '@onecx/angular-integration-interface';
|
|
5
5
|
import { EventsTopic, EventType } from '@onecx/integration-interface';
|
|
6
6
|
import { filter } from 'rxjs/internal/operators/filter';
|
|
7
7
|
import { createLoggerFactory } from '@onecx/accelerator';
|
|
8
|
+
import Semaphore from 'ts-semaphore';
|
|
8
9
|
|
|
9
10
|
var Injectables;
|
|
10
11
|
(function (Injectables) {
|
|
@@ -22,6 +23,7 @@ class KeycloakAuthService {
|
|
|
22
23
|
constructor() {
|
|
23
24
|
this.logger = createLogger('KeycloakAuthService');
|
|
24
25
|
this.configService = inject(ConfigurationService);
|
|
26
|
+
this.updateTokenSemaphore = new Semaphore(1);
|
|
25
27
|
}
|
|
26
28
|
async init(config) {
|
|
27
29
|
this.config = config;
|
|
@@ -44,6 +46,7 @@ class KeycloakAuthService {
|
|
|
44
46
|
kcConfig = './assets/keycloak.json';
|
|
45
47
|
}
|
|
46
48
|
const enableSilentSSOCheck = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ENABLE_SILENT_SSO)) === 'true';
|
|
49
|
+
const timeSkew = await this.getConfigValueNumberOrUndefined(CONFIG_KEY.KEYCLOAK_TIME_SKEW);
|
|
47
50
|
try {
|
|
48
51
|
await import('keycloak-js').then(({ default: Keycloak }) => {
|
|
49
52
|
this.keycloak = new Keycloak(kcConfig);
|
|
@@ -57,7 +60,7 @@ class KeycloakAuthService {
|
|
|
57
60
|
if (!this.keycloak) {
|
|
58
61
|
throw new Error('Keycloak initialization failed!');
|
|
59
62
|
}
|
|
60
|
-
this.setupEventListener();
|
|
63
|
+
await this.setupEventListener();
|
|
61
64
|
return this.keycloak
|
|
62
65
|
.init({
|
|
63
66
|
onLoad: 'check-sso',
|
|
@@ -66,6 +69,7 @@ class KeycloakAuthService {
|
|
|
66
69
|
idToken: idToken || undefined,
|
|
67
70
|
refreshToken: refreshToken || undefined,
|
|
68
71
|
token: token || undefined,
|
|
72
|
+
timeSkew: timeSkew,
|
|
69
73
|
})
|
|
70
74
|
.catch((err) => {
|
|
71
75
|
this.logger.warn(`Keycloak err: ${err}, try force login`);
|
|
@@ -103,8 +107,10 @@ class KeycloakAuthService {
|
|
|
103
107
|
realm,
|
|
104
108
|
};
|
|
105
109
|
}
|
|
106
|
-
setupEventListener() {
|
|
110
|
+
async setupEventListener() {
|
|
107
111
|
if (this.keycloak) {
|
|
112
|
+
const onTokenExpiredEnabled = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ON_TOKEN_EXPIRED_ENABLED)) === 'true';
|
|
113
|
+
const onAuthRefreshErrorEnabled = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ON_AUTH_REFRESH_ERROR_ENABLED)) === 'true';
|
|
108
114
|
this.keycloak.onAuthError = () => {
|
|
109
115
|
this.updateLocalStorage();
|
|
110
116
|
};
|
|
@@ -118,12 +124,23 @@ class KeycloakAuthService {
|
|
|
118
124
|
};
|
|
119
125
|
this.keycloak.onAuthRefreshError = () => {
|
|
120
126
|
this.updateLocalStorage();
|
|
127
|
+
if (onAuthRefreshErrorEnabled) {
|
|
128
|
+
this.logger.info('Auth refresh error - initiating re-login');
|
|
129
|
+
this.keycloak?.login(this.config);
|
|
130
|
+
}
|
|
121
131
|
};
|
|
122
132
|
this.keycloak.onAuthSuccess = () => {
|
|
123
133
|
this.updateLocalStorage();
|
|
124
134
|
};
|
|
125
135
|
this.keycloak.onTokenExpired = () => {
|
|
126
136
|
this.updateLocalStorage();
|
|
137
|
+
if (onTokenExpiredEnabled) {
|
|
138
|
+
// A semaphore is used to prevent executing multiple updateToken calls in parallel.
|
|
139
|
+
this.updateTokenSemaphore.use(async () => {
|
|
140
|
+
this.logger.info('Token expired - proactively refreshing');
|
|
141
|
+
this.keycloak?.updateToken();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
127
144
|
};
|
|
128
145
|
this.keycloak.onActionUpdate = () => {
|
|
129
146
|
this.updateLocalStorage();
|
|
@@ -177,12 +194,13 @@ class KeycloakAuthService {
|
|
|
177
194
|
this.keycloak?.logout();
|
|
178
195
|
}
|
|
179
196
|
async updateTokenIfNeeded() {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
197
|
+
return this.updateTokenSemaphore.use(async () => {
|
|
198
|
+
if (!this.keycloak?.authenticated) {
|
|
199
|
+
return this.keycloak?.login(this.config).then(() => false) ?? Promise.reject('Keycloak not initialized!');
|
|
200
|
+
}
|
|
201
|
+
const minValidity = await this.getConfigValueNumberOrUndefined(CONFIG_KEY.KEYCLOAK_UPDATE_TOKEN_MIN_VALIDITY);
|
|
202
|
+
return this.keycloak.updateToken(minValidity);
|
|
203
|
+
});
|
|
186
204
|
}
|
|
187
205
|
getAuthProviderName() {
|
|
188
206
|
return 'keycloak-auth';
|
|
@@ -196,6 +214,15 @@ class KeycloakAuthService {
|
|
|
196
214
|
getHeaderValues() {
|
|
197
215
|
return { 'apm-principal-token': this.getIdToken() ?? '', Authorization: `Bearer ${this.getAccessToken()}` };
|
|
198
216
|
}
|
|
217
|
+
async getConfigValueNumberOrUndefined(configKey) {
|
|
218
|
+
const value = await this.configService.getProperty(configKey);
|
|
219
|
+
if (value === undefined)
|
|
220
|
+
return undefined;
|
|
221
|
+
const parsed = Number.parseInt(value, 10);
|
|
222
|
+
if (Number.isNaN(parsed))
|
|
223
|
+
return undefined;
|
|
224
|
+
return parsed;
|
|
225
|
+
}
|
|
199
226
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: KeycloakAuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
200
227
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: KeycloakAuthService }); }
|
|
201
228
|
}
|
|
@@ -231,6 +258,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
231
258
|
type: Injectable
|
|
232
259
|
}] });
|
|
233
260
|
|
|
261
|
+
const CUSTOM_AUTH_REMOTE_ALIAS = 'custom-auth-service';
|
|
234
262
|
class AuthServiceWrapper {
|
|
235
263
|
constructor() {
|
|
236
264
|
this.configService = inject(ConfigurationService);
|
|
@@ -313,14 +341,25 @@ class AuthServiceWrapper {
|
|
|
313
341
|
throw new Error('unknown injectable type');
|
|
314
342
|
}
|
|
315
343
|
async getAuthServiceFactory() {
|
|
316
|
-
if (await
|
|
344
|
+
if (!(await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_URL))) {
|
|
317
345
|
throw new Error('URL of the custom auth service is not defined');
|
|
318
346
|
}
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
347
|
+
const remoteEntry = (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_URL)) ?? '';
|
|
348
|
+
const exposedModule = (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_MODULE_NAME)) ?? './CustomAuth';
|
|
349
|
+
const sanitizedExposedModule = exposedModule.startsWith('./') ? exposedModule.slice(2) : exposedModule;
|
|
350
|
+
const customAuthShareScope = await this.configService.getProperty(CONFIG_KEY.CUSTOM_AUTH_SHARE_SCOPE);
|
|
351
|
+
registerRemotes([
|
|
352
|
+
{
|
|
353
|
+
type: 'module',
|
|
354
|
+
entry: remoteEntry,
|
|
355
|
+
name: CUSTOM_AUTH_REMOTE_ALIAS,
|
|
356
|
+
shareScope: customAuthShareScope,
|
|
357
|
+
},
|
|
358
|
+
]);
|
|
359
|
+
const module = await loadRemote(CUSTOM_AUTH_REMOTE_ALIAS + '/' + sanitizedExposedModule);
|
|
360
|
+
if (!module) {
|
|
361
|
+
throw new Error('Failed to load custom auth service module');
|
|
362
|
+
}
|
|
324
363
|
return module.default;
|
|
325
364
|
}
|
|
326
365
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: AuthServiceWrapper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onecx-shell-auth.mjs","sources":["../../../../libs/shell-auth/src/lib/auth.service.ts","../../../../libs/shell-auth/src/lib/utils/logger.utils.ts","../../../../libs/shell-auth/src/lib/auth_services/keycloak-auth.service.ts","../../../../libs/shell-auth/src/lib/declarations.ts","../../../../libs/shell-auth/src/lib/auth_services/disabled-auth.service.ts","../../../../libs/shell-auth/src/lib/auth-service-wrapper.ts","../../../../libs/shell-auth/src/lib/provide-auth-service.ts","../../../../libs/shell-auth/src/onecx-shell-auth.ts"],"sourcesContent":["export interface AuthService {\n init(config?: Record<string, unknown>): Promise<boolean>\n\n getHeaderValues(): Record<string, string>\n\n logout(): void\n\n updateTokenIfNeeded(): Promise<boolean>\n}\n\nexport enum Injectables {\n KEYCLOAK_AUTH_SERVICE = 'KEYCLOAK_AUTH_SERVICE',\n CONFIG = 'CONFIG',\n}\n\nexport type AuthServiceFactory = (\n injectorFunction: (injectable: Injectables) => Promise<unknown> | unknown\n) => AuthService | Promise<AuthService>\n","// This file is not planned to be in the index.ts so it is private to this lib\nimport { createLoggerFactory } from '@onecx/accelerator'\n\nexport const createLogger = createLoggerFactory('@onecx/shell-auth')\n","import { Injectable, inject } from '@angular/core'\nimport { CONFIG_KEY, ConfigurationService } from '@onecx/angular-integration-interface'\nimport Keycloak, { KeycloakServerConfig } from 'keycloak-js'\nimport { AuthService } from '../auth.service'\nimport { createLogger } from '../utils/logger.utils'\n\nconst KC_REFRESH_TOKEN_LS = 'onecx_kc_refreshToken'\nconst KC_ID_TOKEN_LS = 'onecx_kc_idToken'\nconst KC_TOKEN_LS = 'onecx_kc_token'\n\n@Injectable()\nexport class KeycloakAuthService implements AuthService {\n private readonly logger = createLogger('KeycloakAuthService')\n private configService = inject(ConfigurationService)\n private keycloak: Keycloak | undefined\n\n config?: Record<string, unknown>\n\n public async init(config?: Record<string, unknown>): Promise<boolean> {\n this.config = config\n let token = localStorage.getItem(KC_TOKEN_LS)\n let idToken = localStorage.getItem(KC_ID_TOKEN_LS)\n let refreshToken = localStorage.getItem(KC_REFRESH_TOKEN_LS)\n if (token && refreshToken) {\n const parsedToken = JSON.parse(atob(refreshToken.split('.')[1]))\n if (parsedToken.exp * 1000 < new Date().getTime()) {\n token = null\n refreshToken = null\n idToken = null\n this.clearKCStateFromLocalstorage()\n }\n }\n\n let kcConfig: KeycloakServerConfig | string\n const validKCConfig = await this.getValidKCConfig()\n kcConfig = { ...validKCConfig, ...(config ?? {}) }\n \n if (!kcConfig.clientId || !kcConfig.realm || !kcConfig.url) {\n kcConfig = './assets/keycloak.json'\n }\n\n const enableSilentSSOCheck =\n (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ENABLE_SILENT_SSO)) === 'true'\n\n try {\n await import('keycloak-js').then(({ default: Keycloak }) => {\n this.keycloak = new Keycloak(kcConfig)\n })\n } catch (err) {\n const errorMessage = 'Keycloak initialization failed! Could not load keycloak-js library which is required in the current environment.'\n this.logger.error(\n errorMessage,\n err\n )\n throw new Error(\n errorMessage\n )\n }\n\n if (!this.keycloak) {\n throw new Error('Keycloak initialization failed!')\n }\n\n this.setupEventListener()\n\n return this.keycloak\n .init({\n onLoad: 'check-sso',\n checkLoginIframe: false,\n silentCheckSsoRedirectUri: enableSilentSSOCheck ? this.getSilentSSOUrl() : undefined,\n idToken: idToken || undefined,\n refreshToken: refreshToken || undefined,\n token: token || undefined,\n })\n .catch((err) => {\n this.logger.warn(`Keycloak err: ${err}, try force login`)\n return this.keycloak?.login(this.config)\n })\n .then((loginOk) => {\n if (loginOk) {\n return this.keycloak?.token\n } else {\n return this.keycloak?.login(this.config).then(() => 'login')\n }\n })\n .then(() => {\n return true\n })\n .catch((err) => {\n this.logger.error(`KC ERROR ${err} as json ${JSON.stringify(err)}`)\n throw err\n })\n }\n\n protected async getValidKCConfig(): Promise<KeycloakServerConfig> {\n const clientId = await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_CLIENT_ID)\n if (!clientId) {\n throw new Error('Invalid KC config, missing clientId')\n }\n const realm = await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_REALM)\n if (!realm) {\n throw new Error('Invalid KC config, missing realm')\n }\n const url = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_URL)) ?? ''\n return {\n url,\n clientId,\n realm,\n }\n }\n\n private setupEventListener() {\n if (this.keycloak) {\n this.keycloak.onAuthError = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onAuthLogout = () => {\n this.logger.info('SSO logout nav to root')\n this.clearKCStateFromLocalstorage()\n this.keycloak?.login(this.config)\n }\n this.keycloak.onAuthRefreshSuccess = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onAuthRefreshError = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onAuthSuccess = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onTokenExpired = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onActionUpdate = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onReady = () => {\n this.updateLocalStorage()\n }\n }\n }\n\n private updateLocalStorage() {\n if (this.keycloak) {\n if (this.keycloak.token) {\n localStorage.setItem(KC_TOKEN_LS, this.keycloak.token)\n } else {\n localStorage.removeItem(KC_TOKEN_LS)\n }\n if (this.keycloak.idToken) {\n localStorage.setItem(KC_ID_TOKEN_LS, this.keycloak.idToken)\n } else {\n localStorage.removeItem(KC_ID_TOKEN_LS)\n }\n if (this.keycloak.refreshToken) {\n localStorage.setItem(KC_REFRESH_TOKEN_LS, this.keycloak.refreshToken)\n } else {\n localStorage.removeItem(KC_REFRESH_TOKEN_LS)\n }\n }\n }\n\n private clearKCStateFromLocalstorage() {\n localStorage.removeItem(KC_ID_TOKEN_LS)\n localStorage.removeItem(KC_TOKEN_LS)\n localStorage.removeItem(KC_REFRESH_TOKEN_LS)\n }\n\n private getSilentSSOUrl() {\n let currentBase = document.getElementsByTagName('base')[0].href\n if (currentBase === '/') {\n currentBase = ''\n }\n return `${currentBase}/assets/silent-check-sso.html`\n }\n\n getIdToken(): string | null {\n return this.keycloak?.idToken ?? null\n }\n getAccessToken(): string | null {\n return this.keycloak?.token ?? null\n }\n\n logout(): void {\n this.keycloak?.logout()\n }\n\n async updateTokenIfNeeded(): Promise<boolean> {\n if (!this.keycloak?.authenticated) {\n return this.keycloak?.login(this.config).then(() => false) ?? Promise.reject('Keycloak not initialized!')\n } else {\n return this.keycloak.updateToken()\n }\n }\n\n getAuthProviderName(): string {\n return 'keycloak-auth'\n }\n\n hasRole(_role: string): boolean {\n return false\n }\n\n getUserRoles(): string[] {\n return []\n }\n\n getHeaderValues(): Record<string, string> {\n return { 'apm-principal-token': this.getIdToken() ?? '', Authorization: `Bearer ${this.getAccessToken()}` }\n }\n}\n","declare global {\n interface Window {\n onecxAuth?: {\n authServiceProxy?: {\n v1?: {\n getHeaderValues: () => Record<string, string>\n updateTokenIfNeeded: () => Promise<boolean>\n }\n }\n }\n // Shell defines these properties to support older library versions\n onecxAngularAuth?: {\n authServiceProxy?: {\n v1?: {\n getHeaderValues: () => Record<string, string>\n updateTokenIfNeeded: () => Promise<boolean>\n }\n }\n }\n }\n}\n\nexport default globalThis\n","import { Injectable } from '@angular/core';\nimport { AuthService } from '../auth.service';\n\n@Injectable()\nexport class DisabledAuthService implements AuthService {\n\n public async init(_config?: Record<string, unknown>): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n getIdToken(): string | null {\n return \"\";\n }\n getAccessToken(): string | null {\n return \"\";\n }\n\n logout(): void {\n window.location.href = \"https://github.com/onecx/\";\n }\n\n async updateTokenIfNeeded(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n getHeaderValues(): Record<string, string> {\n return {};\n }\n}\n","import { loadRemoteModule } from '@angular-architects/module-federation'\nimport { Injectable, Injector, inject } from '@angular/core'\nimport { AppStateService, CONFIG_KEY, ConfigurationService } from '@onecx/angular-integration-interface'\nimport { Config, EventsTopic, EventType } from '@onecx/integration-interface'\nimport { filter } from 'rxjs/internal/operators/filter'\nimport { AuthService, AuthServiceFactory, Injectables } from './auth.service'\nimport { KeycloakAuthService } from './auth_services/keycloak-auth.service'\nimport './declarations'\nimport { DisabledAuthService } from './auth_services/disabled-auth.service'\n\n@Injectable()\nexport class AuthServiceWrapper {\n private configService = inject(ConfigurationService)\n private appStateService = inject(AppStateService)\n private injector = inject(Injector)\n\n private eventsTopic$ = new EventsTopic()\n private authService: AuthService | undefined\n\n constructor() {\n this.eventsTopic$\n .pipe(filter((e) => e.type === EventType.AUTH_LOGOUT_BUTTON_CLICKED))\n .subscribe(() => this.authService?.logout())\n // Shell defines these properties to support older library versions\n window.onecxAngularAuth ??= {}\n window.onecxAngularAuth.authServiceProxy ??= {}\n window.onecxAngularAuth.authServiceProxy.v1 ??= {\n updateTokenIfNeeded: (): Promise<boolean> => {\n return this.updateTokenIfNeeded()\n },\n getHeaderValues: (): Record<string, string> => {\n return this.getHeaderValues()\n },\n }\n window.onecxAuth ??= {}\n window.onecxAuth.authServiceProxy ??= {}\n window.onecxAuth.authServiceProxy.v1 ??= {\n updateTokenIfNeeded: (): Promise<boolean> => {\n return this.updateTokenIfNeeded()\n },\n getHeaderValues: (): Record<string, string> => {\n return this.getHeaderValues()\n },\n }\n }\n async init(): Promise<boolean | undefined> {\n await this.configService.isInitialized\n\n await this.initializeAuthService()\n const initResult = this.getInitResult()\n return initResult\n }\n async getInitResult(): Promise<boolean | undefined> {\n const initResult = await this.authService?.init()\n\n if (initResult) {\n await this.appStateService.isAuthenticated$.publish()\n }\n return initResult\n }\n getHeaderValues(): Record<string, string> {\n return this.authService?.getHeaderValues() ?? {}\n }\n updateTokenIfNeeded(): Promise<boolean> {\n return this.authService?.updateTokenIfNeeded() ?? Promise.reject()\n }\n\n async initializeAuthService(): Promise<void> {\n const serviceTypeConfig = (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE)) ?? 'keycloak'\n\n switch (serviceTypeConfig) {\n case 'keycloak':\n this.authService = this.injector.get(KeycloakAuthService)\n break\n case 'custom': {\n // remote module is exposing function as default export (this is a convention)\n // this function is responsible for creating the custom auth service\n // to have access to the dependency mechanism of the shell\n // the function gets a callback which is returning the requested injectable\n const factory = await this.getAuthServiceFactory()\n this.authService = await Promise.resolve(\n factory((injectable: Injectables) => this.retrieveInjectables(injectable))\n )\n break\n }\n case 'disabled':\n this.authService = this.injector.get(DisabledAuthService)\n break\n default:\n throw new Error('Configured AuthService not found')\n }\n }\n\n async retrieveInjectables(injectable: Injectables): Promise<KeycloakAuthService | Config | undefined> {\n if (injectable === Injectables.KEYCLOAK_AUTH_SERVICE) {\n return this.injector.get(KeycloakAuthService)\n } else if (injectable === Injectables.CONFIG) {\n return this.configService.getConfig()\n }\n throw new Error('unknown injectable type')\n }\n\n async getAuthServiceFactory(): Promise<AuthServiceFactory> {\n if (await !this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_URL)) {\n throw new Error('URL of the custom auth service is not defined')\n }\n const module = await loadRemoteModule({\n type: 'module',\n remoteEntry: (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_URL)) ?? '',\n exposedModule:\n (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_MODULE_NAME)) ?? './CustomAuth',\n })\n return module.default as AuthServiceFactory\n }\n}\n","import { inject, provideAppInitializer } from '@angular/core'\nimport { ConfigurationService } from '@onecx/angular-integration-interface'\nimport { AuthServiceWrapper } from './auth-service-wrapper'\nimport { DisabledAuthService } from './auth_services/disabled-auth.service'\nimport { KeycloakAuthService } from './auth_services/keycloak-auth.service'\n\nfunction provideAuthServices() {\n return [AuthServiceWrapper, KeycloakAuthService, DisabledAuthService]\n}\n\nexport function provideAuthService() {\n return [\n provideAuthServices(),\n provideAppInitializer(async () => {\n const configService = inject(ConfigurationService)\n const authServiceWrapper = inject(AuthServiceWrapper)\n await configService.isInitialized\n await authServiceWrapper.init()\n }),\n ]\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAUA,IAAY,WAGX;AAHD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,uBAAA,CAAA,GAAA,uBAA+C;AAC/C,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAHW,WAAW,KAAX,WAAW,GAAA,EAAA,CAAA,CAAA;;ACVvB;AAGO,MAAM,YAAY,GAAG,mBAAmB,CAAC,mBAAmB,CAAC;;ACGpE,MAAM,mBA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,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,CAAC;AACvE;SAEgB,kBAAkB,GAAA;IAChC,OAAO;AACL,QAAA,mBAAmB,EAAE;QACrB,qBAAqB,CAAC,YAAW;AAC/B,YAAA,MAAM,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAClD,YAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;YACrD,MAAM,aAAa,CAAC,aAAa;AACjC,YAAA,MAAM,kBAAkB,CAAC,IAAI,EAAE;AACjC,QAAA,CAAC,CAAC;KACH;AACH;;ACpBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"onecx-shell-auth.mjs","sources":["../../../../libs/shell-auth/src/lib/auth.service.ts","../../../../libs/shell-auth/src/lib/utils/logger.utils.ts","../../../../libs/shell-auth/src/lib/auth_services/keycloak-auth.service.ts","../../../../libs/shell-auth/src/lib/declarations.ts","../../../../libs/shell-auth/src/lib/auth_services/disabled-auth.service.ts","../../../../libs/shell-auth/src/lib/auth-service-wrapper.ts","../../../../libs/shell-auth/src/lib/provide-auth-service.ts","../../../../libs/shell-auth/src/onecx-shell-auth.ts"],"sourcesContent":["export interface AuthService {\n init(config?: Record<string, unknown>): Promise<boolean>\n\n getHeaderValues(): Record<string, string>\n\n logout(): void\n\n updateTokenIfNeeded(): Promise<boolean>\n}\n\nexport enum Injectables {\n KEYCLOAK_AUTH_SERVICE = 'KEYCLOAK_AUTH_SERVICE',\n CONFIG = 'CONFIG',\n}\n\nexport type AuthServiceFactory = (\n injectorFunction: (injectable: Injectables) => Promise<unknown> | unknown\n) => AuthService | Promise<AuthService>\n","// This file is not planned to be in the index.ts so it is private to this lib\nimport { createLoggerFactory } from '@onecx/accelerator'\n\nexport const createLogger = createLoggerFactory('@onecx/shell-auth')\n","import { Injectable, inject } from '@angular/core'\nimport { CONFIG_KEY, ConfigurationService } from '@onecx/angular-integration-interface'\nimport Keycloak, { KeycloakServerConfig } from 'keycloak-js'\nimport { AuthService } from '../auth.service'\nimport { createLogger } from '../utils/logger.utils'\nimport Semaphore from 'ts-semaphore'\n\nconst KC_REFRESH_TOKEN_LS = 'onecx_kc_refreshToken'\nconst KC_ID_TOKEN_LS = 'onecx_kc_idToken'\nconst KC_TOKEN_LS = 'onecx_kc_token'\n\n@Injectable()\nexport class KeycloakAuthService implements AuthService {\n private readonly logger = createLogger('KeycloakAuthService')\n private configService = inject(ConfigurationService)\n private keycloak: Keycloak | undefined\n private readonly updateTokenSemaphore = new Semaphore(1)\n\n config?: Record<string, unknown>\n\n public async init(config?: Record<string, unknown>): Promise<boolean> {\n this.config = config\n let token = localStorage.getItem(KC_TOKEN_LS)\n let idToken = localStorage.getItem(KC_ID_TOKEN_LS)\n let refreshToken = localStorage.getItem(KC_REFRESH_TOKEN_LS)\n if (token && refreshToken) {\n const parsedToken = JSON.parse(atob(refreshToken.split('.')[1]))\n if (parsedToken.exp * 1000 < new Date().getTime()) {\n token = null\n refreshToken = null\n idToken = null\n this.clearKCStateFromLocalstorage()\n }\n }\n\n let kcConfig: KeycloakServerConfig | string\n const validKCConfig = await this.getValidKCConfig()\n kcConfig = { ...validKCConfig, ...(config ?? {}) }\n \n if (!kcConfig.clientId || !kcConfig.realm || !kcConfig.url) {\n kcConfig = './assets/keycloak.json'\n }\n\n const enableSilentSSOCheck =\n (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ENABLE_SILENT_SSO)) === 'true'\n\n const timeSkew = await this.getConfigValueNumberOrUndefined(CONFIG_KEY.KEYCLOAK_TIME_SKEW)\n\n try {\n await import('keycloak-js').then(({ default: Keycloak }) => {\n this.keycloak = new Keycloak(kcConfig)\n })\n } catch (err) {\n const errorMessage = 'Keycloak initialization failed! Could not load keycloak-js library which is required in the current environment.'\n this.logger.error(\n errorMessage,\n err\n )\n throw new Error(\n errorMessage\n )\n }\n\n if (!this.keycloak) {\n throw new Error('Keycloak initialization failed!')\n }\n\n await this.setupEventListener()\n\n return this.keycloak\n .init({\n onLoad: 'check-sso',\n checkLoginIframe: false,\n silentCheckSsoRedirectUri: enableSilentSSOCheck ? this.getSilentSSOUrl() : undefined,\n idToken: idToken || undefined,\n refreshToken: refreshToken || undefined,\n token: token || undefined,\n timeSkew: timeSkew,\n })\n .catch((err) => {\n this.logger.warn(`Keycloak err: ${err}, try force login`)\n return this.keycloak?.login(this.config)\n })\n .then((loginOk) => {\n if (loginOk) {\n return this.keycloak?.token\n } else {\n return this.keycloak?.login(this.config).then(() => 'login')\n }\n })\n .then(() => {\n return true\n })\n .catch((err) => {\n this.logger.error(`KC ERROR ${err} as json ${JSON.stringify(err)}`)\n throw err\n })\n }\n\n protected async getValidKCConfig(): Promise<KeycloakServerConfig> {\n const clientId = await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_CLIENT_ID)\n if (!clientId) {\n throw new Error('Invalid KC config, missing clientId')\n }\n const realm = await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_REALM)\n if (!realm) {\n throw new Error('Invalid KC config, missing realm')\n }\n const url = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_URL)) ?? ''\n return {\n url,\n clientId,\n realm,\n }\n }\n\n private async setupEventListener() {\n if (this.keycloak) {\n const onTokenExpiredEnabled = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ON_TOKEN_EXPIRED_ENABLED)) === 'true'\n\n const onAuthRefreshErrorEnabled = (await this.configService.getProperty(CONFIG_KEY.KEYCLOAK_ON_AUTH_REFRESH_ERROR_ENABLED)) === 'true'\n\n this.keycloak.onAuthError = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onAuthLogout = () => {\n this.logger.info('SSO logout nav to root')\n this.clearKCStateFromLocalstorage()\n this.keycloak?.login(this.config)\n }\n this.keycloak.onAuthRefreshSuccess = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onAuthRefreshError = () => {\n this.updateLocalStorage()\n if (onAuthRefreshErrorEnabled) {\n this.logger.info('Auth refresh error - initiating re-login')\n this.keycloak?.login(this.config)\n }\n }\n this.keycloak.onAuthSuccess = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onTokenExpired = () => {\n this.updateLocalStorage()\n if (onTokenExpiredEnabled) {\n // A semaphore is used to prevent executing multiple updateToken calls in parallel.\n this.updateTokenSemaphore.use(async () => {\n this.logger.info('Token expired - proactively refreshing')\n this.keycloak?.updateToken()\n })\n }\n }\n this.keycloak.onActionUpdate = () => {\n this.updateLocalStorage()\n }\n this.keycloak.onReady = () => {\n this.updateLocalStorage()\n }\n }\n }\n\n private updateLocalStorage() {\n if (this.keycloak) {\n if (this.keycloak.token) {\n localStorage.setItem(KC_TOKEN_LS, this.keycloak.token)\n } else {\n localStorage.removeItem(KC_TOKEN_LS)\n }\n if (this.keycloak.idToken) {\n localStorage.setItem(KC_ID_TOKEN_LS, this.keycloak.idToken)\n } else {\n localStorage.removeItem(KC_ID_TOKEN_LS)\n }\n if (this.keycloak.refreshToken) {\n localStorage.setItem(KC_REFRESH_TOKEN_LS, this.keycloak.refreshToken)\n } else {\n localStorage.removeItem(KC_REFRESH_TOKEN_LS)\n }\n }\n }\n\n private clearKCStateFromLocalstorage() {\n localStorage.removeItem(KC_ID_TOKEN_LS)\n localStorage.removeItem(KC_TOKEN_LS)\n localStorage.removeItem(KC_REFRESH_TOKEN_LS)\n }\n\n private getSilentSSOUrl() {\n let currentBase = document.getElementsByTagName('base')[0].href\n if (currentBase === '/') {\n currentBase = ''\n }\n return `${currentBase}/assets/silent-check-sso.html`\n }\n\n getIdToken(): string | null {\n return this.keycloak?.idToken ?? null\n }\n getAccessToken(): string | null {\n return this.keycloak?.token ?? null\n }\n\n logout(): void {\n this.keycloak?.logout()\n }\n\n async updateTokenIfNeeded(): Promise<boolean> {\n return this.updateTokenSemaphore.use(async () => {\n if (!this.keycloak?.authenticated) {\n return this.keycloak?.login(this.config).then(() => false) ?? Promise.reject('Keycloak not initialized!')\n }\n\n const minValidity = await this.getConfigValueNumberOrUndefined(CONFIG_KEY.KEYCLOAK_UPDATE_TOKEN_MIN_VALIDITY)\n\n return this.keycloak.updateToken(minValidity)\n })\n }\n\n getAuthProviderName(): string {\n return 'keycloak-auth'\n }\n\n hasRole(_role: string): boolean {\n return false\n }\n\n getUserRoles(): string[] {\n return []\n }\n\n getHeaderValues(): Record<string, string> {\n return { 'apm-principal-token': this.getIdToken() ?? '', Authorization: `Bearer ${this.getAccessToken()}` }\n }\n\n async getConfigValueNumberOrUndefined(configKey: CONFIG_KEY): Promise<number | undefined> {\n const value = await this.configService.getProperty(configKey)\n if (value === undefined) return undefined\n\n const parsed = Number.parseInt(value, 10)\n if (Number.isNaN(parsed)) return undefined\n return parsed\n }\n}\n","declare global {\n interface Window {\n onecxAuth?: {\n authServiceProxy?: {\n v1?: {\n getHeaderValues: () => Record<string, string>\n updateTokenIfNeeded: () => Promise<boolean>\n }\n }\n }\n // Shell defines these properties to support older library versions\n onecxAngularAuth?: {\n authServiceProxy?: {\n v1?: {\n getHeaderValues: () => Record<string, string>\n updateTokenIfNeeded: () => Promise<boolean>\n }\n }\n }\n }\n}\n\nexport default globalThis\n","import { Injectable } from '@angular/core';\nimport { AuthService } from '../auth.service';\n\n@Injectable()\nexport class DisabledAuthService implements AuthService {\n\n public async init(_config?: Record<string, unknown>): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n getIdToken(): string | null {\n return \"\";\n }\n getAccessToken(): string | null {\n return \"\";\n }\n\n logout(): void {\n window.location.href = \"https://github.com/onecx/\";\n }\n\n async updateTokenIfNeeded(): Promise<boolean> {\n return Promise.resolve(true);\n }\n\n getHeaderValues(): Record<string, string> {\n return {};\n }\n}\n","import { loadRemote, registerRemotes } from '@module-federation/enhanced/runtime'\nimport { Injectable, Injector, inject } from '@angular/core'\nimport { AppStateService, CONFIG_KEY, ConfigurationService } from '@onecx/angular-integration-interface'\nimport { Config, EventsTopic, EventType } from '@onecx/integration-interface'\nimport { filter } from 'rxjs/internal/operators/filter'\nimport { AuthService, AuthServiceFactory, Injectables } from './auth.service'\nimport { KeycloakAuthService } from './auth_services/keycloak-auth.service'\nimport './declarations'\nimport { DisabledAuthService } from './auth_services/disabled-auth.service'\n\nconst CUSTOM_AUTH_REMOTE_ALIAS = 'custom-auth-service'\n\n@Injectable()\nexport class AuthServiceWrapper {\n private configService = inject(ConfigurationService)\n private appStateService = inject(AppStateService)\n private injector = inject(Injector)\n\n private eventsTopic$ = new EventsTopic()\n private authService: AuthService | undefined\n\n constructor() {\n this.eventsTopic$\n .pipe(filter((e) => e.type === EventType.AUTH_LOGOUT_BUTTON_CLICKED))\n .subscribe(() => this.authService?.logout())\n // Shell defines these properties to support older library versions\n window.onecxAngularAuth ??= {}\n window.onecxAngularAuth.authServiceProxy ??= {}\n window.onecxAngularAuth.authServiceProxy.v1 ??= {\n updateTokenIfNeeded: (): Promise<boolean> => {\n return this.updateTokenIfNeeded()\n },\n getHeaderValues: (): Record<string, string> => {\n return this.getHeaderValues()\n },\n }\n window.onecxAuth ??= {}\n window.onecxAuth.authServiceProxy ??= {}\n window.onecxAuth.authServiceProxy.v1 ??= {\n updateTokenIfNeeded: (): Promise<boolean> => {\n return this.updateTokenIfNeeded()\n },\n getHeaderValues: (): Record<string, string> => {\n return this.getHeaderValues()\n },\n }\n }\n async init(): Promise<boolean | undefined> {\n await this.configService.isInitialized\n\n await this.initializeAuthService()\n const initResult = this.getInitResult()\n return initResult\n }\n async getInitResult(): Promise<boolean | undefined> {\n const initResult = await this.authService?.init()\n\n if (initResult) {\n await this.appStateService.isAuthenticated$.publish()\n }\n return initResult\n }\n getHeaderValues(): Record<string, string> {\n return this.authService?.getHeaderValues() ?? {}\n }\n updateTokenIfNeeded(): Promise<boolean> {\n return this.authService?.updateTokenIfNeeded() ?? Promise.reject()\n }\n\n async initializeAuthService(): Promise<void> {\n const serviceTypeConfig = (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE)) ?? 'keycloak'\n\n switch (serviceTypeConfig) {\n case 'keycloak':\n this.authService = this.injector.get(KeycloakAuthService)\n break\n case 'custom': {\n // remote module is exposing function as default export (this is a convention)\n // this function is responsible for creating the custom auth service\n // to have access to the dependency mechanism of the shell\n // the function gets a callback which is returning the requested injectable\n const factory = await this.getAuthServiceFactory()\n this.authService = await Promise.resolve(\n factory((injectable: Injectables) => this.retrieveInjectables(injectable))\n )\n break\n }\n case 'disabled':\n this.authService = this.injector.get(DisabledAuthService)\n break\n default:\n throw new Error('Configured AuthService not found')\n }\n }\n\n async retrieveInjectables(injectable: Injectables): Promise<KeycloakAuthService | Config | undefined> {\n if (injectable === Injectables.KEYCLOAK_AUTH_SERVICE) {\n return this.injector.get(KeycloakAuthService)\n } else if (injectable === Injectables.CONFIG) {\n return this.configService.getConfig()\n }\n throw new Error('unknown injectable type')\n }\n\n async getAuthServiceFactory(): Promise<AuthServiceFactory> {\n if (!(await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_URL))) {\n throw new Error('URL of the custom auth service is not defined')\n }\n const remoteEntry = (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_URL)) ?? ''\n const exposedModule =\n (await this.configService.getProperty(CONFIG_KEY.AUTH_SERVICE_CUSTOM_MODULE_NAME)) ?? './CustomAuth'\n const sanitizedExposedModule = exposedModule.startsWith('./') ? exposedModule.slice(2) : exposedModule\n\n const customAuthShareScope = await this.configService.getProperty(CONFIG_KEY.CUSTOM_AUTH_SHARE_SCOPE)\n registerRemotes([\n {\n type: 'module',\n entry: remoteEntry,\n name: CUSTOM_AUTH_REMOTE_ALIAS,\n shareScope: customAuthShareScope,\n },\n ])\n const module = await loadRemote<{ default: AuthServiceFactory }>(\n CUSTOM_AUTH_REMOTE_ALIAS + '/' + sanitizedExposedModule\n )\n\n if (!module) {\n throw new Error('Failed to load custom auth service module')\n }\n\n return module.default as AuthServiceFactory\n }\n}\n","import { inject, provideAppInitializer } from '@angular/core'\nimport { ConfigurationService } from '@onecx/angular-integration-interface'\nimport { AuthServiceWrapper } from './auth-service-wrapper'\nimport { DisabledAuthService } from './auth_services/disabled-auth.service'\nimport { KeycloakAuthService } from './auth_services/keycloak-auth.service'\n\nfunction provideAuthServices() {\n return [AuthServiceWrapper, KeycloakAuthService, DisabledAuthService]\n}\n\nexport function provideAuthService() {\n return [\n provideAuthServices(),\n provideAppInitializer(async () => {\n const configService = inject(ConfigurationService)\n const authServiceWrapper = inject(AuthServiceWrapper)\n await configService.isInitialized\n await authServiceWrapper.init()\n }),\n ]\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAUA,IAAY,WAGX;AAHD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,uBAAA,CAAA,GAAA,uBAA+C;AAC/C,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAHW,WAAW,KAAX,WAAW,GAAA,EAAA,CAAA,CAAA;;ACVvB;AAGO,MAAM,YAAY,GAAG,mBAAmB,CAAC,mBAAmB,CAAC;;ACIpE,MAAM,mBAAmB,GAAG,uBAAuB;AACnD,MAAM,cAAc,GAAG,kBAAkB;AACzC,MAAM,WAAW,GAAG,gBAAgB;MAGvB,mBAAmB,CAAA;AADhC,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,MAAM,GAAG,YAAY,CAAC,qBAAqB,CAAC;AACrD,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAEnC,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC;AAmOzD,IAAA;IA/NQ,MAAM,IAAI,CAAC,MAAgC,EAAA;AAChD,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,IAAI,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC;QAClD,IAAI,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC;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AAA,EAAA,CAAA;kBAD9B;;;ACND,SAAS,mBAAmB,GAAA;AAC1B,IAAA,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,CAAC;AACvE;SAEgB,kBAAkB,GAAA;IAChC,OAAO;AACL,QAAA,mBAAmB,EAAE;QACrB,qBAAqB,CAAC,YAAW;AAC/B,YAAA,MAAM,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAClD,YAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;YACrD,MAAM,aAAa,CAAC,aAAa;AACjC,YAAA,MAAM,kBAAkB,CAAC,IAAI,EAAE;AACjC,QAAA,CAAC,CAAC;KACH;AACH;;ACpBA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onecx/shell-auth",
|
|
3
|
-
"version": "8.0.0
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/onecx/onecx-portal-ui-libs"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@angular-architects/module-federation": "^20.0.0",
|
|
11
10
|
"@angular/core": "^21.0.0",
|
|
12
|
-
"@
|
|
13
|
-
"@onecx/
|
|
14
|
-
"@onecx/integration-interface": "^8.0.0
|
|
11
|
+
"@module-federation/enhanced": "^2.0.1",
|
|
12
|
+
"@onecx/accelerator": "^8.0.0",
|
|
13
|
+
"@onecx/angular-integration-interface": "^8.0.0",
|
|
14
|
+
"@onecx/integration-interface": "^8.0.0",
|
|
15
15
|
"keycloak-js": "^26.2.3",
|
|
16
|
+
"ts-semaphore": "^1.0.0",
|
|
16
17
|
"rxjs": "~7.8.0"
|
|
17
18
|
},
|
|
18
19
|
"peerDependenciesMeta": {
|
|
@@ -23,9 +24,6 @@
|
|
|
23
24
|
"publishConfig": {
|
|
24
25
|
"access": "public"
|
|
25
26
|
},
|
|
26
|
-
"nx-migrations": {
|
|
27
|
-
"migrations": "./migrations.json"
|
|
28
|
-
},
|
|
29
27
|
"module": "fesm2022/onecx-shell-auth.mjs",
|
|
30
28
|
"typings": "types/onecx-shell-auth.d.ts",
|
|
31
29
|
"exports": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Config } from '@onecx/integration-interface';
|
|
2
|
+
import { CONFIG_KEY } from '@onecx/angular-integration-interface';
|
|
2
3
|
import { KeycloakServerConfig } from 'keycloak-js';
|
|
3
4
|
import * as i0 from '@angular/core';
|
|
4
5
|
|
|
@@ -18,6 +19,7 @@ declare class KeycloakAuthService implements AuthService {
|
|
|
18
19
|
private readonly logger;
|
|
19
20
|
private configService;
|
|
20
21
|
private keycloak;
|
|
22
|
+
private readonly updateTokenSemaphore;
|
|
21
23
|
config?: Record<string, unknown>;
|
|
22
24
|
init(config?: Record<string, unknown>): Promise<boolean>;
|
|
23
25
|
protected getValidKCConfig(): Promise<KeycloakServerConfig>;
|
|
@@ -33,6 +35,7 @@ declare class KeycloakAuthService implements AuthService {
|
|
|
33
35
|
hasRole(_role: string): boolean;
|
|
34
36
|
getUserRoles(): string[];
|
|
35
37
|
getHeaderValues(): Record<string, string>;
|
|
38
|
+
getConfigValueNumberOrUndefined(configKey: CONFIG_KEY): Promise<number | undefined>;
|
|
36
39
|
static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakAuthService, never>;
|
|
37
40
|
static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakAuthService>;
|
|
38
41
|
}
|
package/migrations/index.d.ts
DELETED
|
File without changes
|
package/migrations/index.js
DELETED
package/migrations/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/shell-auth/migrations/index.ts"],"names":[],"mappings":""}
|
package/migrations.json
DELETED
|
File without changes
|