@open-pioneer/authentication-keycloak 4.4.0-dev.20260121102820 → 4.4.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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @open-pioneer/authentication-keycloak
|
|
2
2
|
|
|
3
|
-
## 4.4.0
|
|
3
|
+
## 4.4.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
- Updated dependencies [b28d6bc]
|
|
15
15
|
- Updated dependencies [554d58e]
|
|
16
16
|
- Updated dependencies [1cc3415]
|
|
17
|
+
- Updated dependencies [d7ec65c]
|
|
17
18
|
- Updated dependencies [1872a6d]
|
|
18
19
|
- Updated dependencies [84068f2]
|
|
19
|
-
|
|
20
|
-
- @open-pioneer/
|
|
21
|
-
- @open-pioneer/
|
|
22
|
-
- @open-pioneer/
|
|
20
|
+
- Updated dependencies [d7ec65c]
|
|
21
|
+
- @open-pioneer/authentication@4.4.0
|
|
22
|
+
- @open-pioneer/core@4.4.0
|
|
23
|
+
- @open-pioneer/notifier@4.4.0
|
|
24
|
+
- @open-pioneer/runtime@4.4.0
|
|
23
25
|
|
|
24
26
|
## 4.3.0
|
|
25
27
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { reactive } from '@conterra/reactivity-core';
|
|
2
2
|
import { createLogger, destroyResource } from '@open-pioneer/core';
|
|
3
3
|
import Keycloak from 'keycloak-js';
|
|
4
|
+
import { sourceId } from './_virtual/source-info.js';
|
|
4
5
|
import { getKeycloakConfig } from './getKeycloakConfig.js';
|
|
5
6
|
|
|
6
|
-
const LOG = createLogger(
|
|
7
|
+
const LOG = createLogger(sourceId);
|
|
7
8
|
class KeycloakAuthPluginImpl {
|
|
8
9
|
#notifier;
|
|
9
10
|
#intl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeycloakAuthPluginImpl.js","sources":["KeycloakAuthPluginImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { AuthState, LoginBehavior } from \"@open-pioneer/authentication\";\nimport { createLogger, destroyResource, Resource } from \"@open-pioneer/core\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport {\n PackageIntl,\n Service,\n ServiceOptions,\n type DECLARE_SERVICE_INTERFACE\n} from \"@open-pioneer/runtime\";\nimport Keycloak, { KeycloakLogoutOptions } from \"keycloak-js\";\nimport { KeycloakAuthPlugin } from \"./api\";\nimport { getKeycloakConfig, ResolvedKeycloakOptions } from \"./getKeycloakConfig\";\n\nconst LOG = createLogger(\"authentication-keycloak:KeycloakAuthPlugin\");\n\ninterface References {\n notifier: NotificationService;\n}\n\nexport class KeycloakAuthPluginImpl implements Service, KeycloakAuthPlugin {\n declare [DECLARE_SERVICE_INTERFACE]: \"authentication-keycloak.KeycloakAuthPlugin\";\n\n #notifier: NotificationService;\n #intl: PackageIntl;\n #keycloakOptions: ResolvedKeycloakOptions;\n #keycloak: Keycloak;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #timerId: any;\n #watcher: Resource | undefined;\n\n #state = reactive<AuthState>({\n kind: \"pending\"\n });\n\n constructor(options: ServiceOptions<References>) {\n this.#notifier = options.references.notifier;\n this.#intl = options.intl;\n\n try {\n this.#keycloakOptions = getKeycloakConfig(options.properties);\n } catch (e) {\n throw new Error(\"Invalid keycloak configuration\", { cause: e });\n }\n\n try {\n this.#keycloak = new Keycloak(this.#keycloakOptions.config);\n } catch (e) {\n throw new Error(\"Failed to construct keycloak instance\", { cause: e });\n }\n this.#init().catch((e) => {\n this.#updateState({\n kind: \"error\",\n error: e\n });\n this.#notifier.notify({\n level: \"error\",\n title: this.#intl.formatMessage({\n id: \"loginFailed.title\"\n }),\n message: this.#intl.formatMessage({\n id: \"loginFailed.message\"\n })\n });\n\n LOG.error(\"Failed to check if user is authenticated\", e);\n });\n }\n\n destroy() {\n clearInterval(this.#timerId);\n this.#watcher = destroyResource(this.#watcher);\n this.#timerId = undefined;\n }\n\n getAuthState(): AuthState {\n return this.#state.value;\n }\n\n getLoginBehavior(): LoginBehavior {\n const doLogin = () => {\n const options = this.#keycloakOptions.loginOptions;\n LOG.debug(\"Login with options\", options);\n this.#keycloak.login(options);\n };\n return {\n kind: \"effect\",\n login: doLogin\n };\n }\n\n logout(options?: Partial<KeycloakLogoutOptions>) {\n const logoutOptions = {\n ...this.#keycloakOptions.logoutOptions,\n ...options\n };\n LOG.debug(\"Logout with options\", logoutOptions);\n this.#keycloak.logout(logoutOptions);\n }\n\n async #init() {\n const { initOptions, refreshOptions } = this.#keycloakOptions;\n\n let isAuthenticated: boolean;\n try {\n LOG.debug(\"Init with options\", initOptions);\n isAuthenticated = await this.#keycloak.init(initOptions);\n } catch (e) {\n // Note: keycloak.init() can also throw an exception, in addition to a rejected promise.\n // It may also just throw a string..\n const error = typeof e === \"string\" ? new Error(e) : e;\n throw new Error(\"Failed to initialize keycloak session\", { cause: error });\n }\n\n if (isAuthenticated) {\n this.#updateState({\n kind: \"authenticated\",\n sessionInfo: {\n userId: this.#keycloak.subject ? this.#keycloak.subject : \"undefined\",\n userName: this.#keycloak.idTokenParsed?.preferred_username,\n attributes: {\n keycloak: this.#keycloak,\n familyName: this.#keycloak.idTokenParsed?.family_name,\n givenName: this.#keycloak.idTokenParsed?.given_name,\n userName: this.#keycloak.idTokenParsed?.preferred_username\n }\n }\n });\n\n LOG.debug(`User ${this.#keycloak.subject} is authenticated`);\n\n if (refreshOptions.autoRefresh) {\n LOG.debug(\"Starting auto-refresh\", refreshOptions);\n this.__refresh(refreshOptions.interval, refreshOptions.timeLeft);\n }\n } else {\n this.#updateState({\n kind: \"not-authenticated\"\n });\n LOG.debug(\"User is not authenticated\");\n }\n }\n\n // Mocked in test\n private __refresh(interval: number, timeLeft: number) {\n clearInterval(this.#timerId);\n this.#timerId = setInterval(() => {\n LOG.debug(\"Checking token validity\");\n this.#keycloak\n .updateToken(timeLeft)\n .then((refreshed) => {\n if (refreshed) {\n LOG.debug(\"Token refreshed successfully\");\n } else {\n LOG.debug(\"Token is still valid\");\n }\n })\n .catch((e) => {\n LOG.error(\"Failed to refresh token\", e);\n this.#updateState({\n kind: \"not-authenticated\"\n });\n this.destroy();\n });\n }, interval);\n }\n\n #updateState(newState: AuthState) {\n this.#state.value = newState;\n }\n}\n"],"names":[],"mappings":";;;;;AAgBA,MAAM,GAAA,GAAM,aAAa,4CAA4C,CAAA;AAM9D,MAAM,sBAAA,CAA8D;AAAA,EAGvE,SAAA;AAAA,EACA,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EACA,QAAA;AAAA,EAEA,SAAS,QAAA,CAAoB;AAAA,IACzB,IAAA,EAAM;AAAA,GACT,CAAA;AAAA,EAED,YAAY,OAAA,EAAqC;AAC7C,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,UAAA,CAAW,QAAA;AACpC,IAAA,IAAA,CAAK,QAAQ,OAAA,CAAQ,IAAA;AAErB,IAAA,IAAI;AACA,MAAA,IAAA,CAAK,gBAAA,GAAmB,iBAAA,CAAkB,OAAA,CAAQ,UAAU,CAAA;AAAA,IAChE,SAAS,CAAA,EAAG;AACR,MAAA,MAAM,IAAI,KAAA,CAAM,gCAAA,EAAkC,EAAE,KAAA,EAAO,GAAG,CAAA;AAAA,IAClE;AAEA,IAAA,IAAI;AACA,MAAA,IAAA,CAAK,SAAA,GAAY,IAAI,QAAA,CAAS,IAAA,CAAK,iBAAiB,MAAM,CAAA;AAAA,IAC9D,SAAS,CAAA,EAAG;AACR,MAAA,MAAM,IAAI,KAAA,CAAM,uCAAA,EAAyC,EAAE,KAAA,EAAO,GAAG,CAAA;AAAA,IACzE;AACA,IAAA,IAAA,CAAK,KAAA,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A,CAAK,OAAO,KAAA,GAAQ,QAAA;AAAA,EACxB;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"KeycloakAuthPluginImpl.js","sources":["KeycloakAuthPluginImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { AuthState, LoginBehavior } from \"@open-pioneer/authentication\";\nimport { createLogger, destroyResource, Resource } from \"@open-pioneer/core\";\nimport { NotificationService } from \"@open-pioneer/notifier\";\nimport {\n PackageIntl,\n Service,\n ServiceOptions,\n type DECLARE_SERVICE_INTERFACE\n} from \"@open-pioneer/runtime\";\nimport Keycloak, { KeycloakLogoutOptions } from \"keycloak-js\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { KeycloakAuthPlugin } from \"./api\";\nimport { getKeycloakConfig, ResolvedKeycloakOptions } from \"./getKeycloakConfig\";\n\nconst LOG = createLogger(sourceId);\n\ninterface References {\n notifier: NotificationService;\n}\n\nexport class KeycloakAuthPluginImpl implements Service, KeycloakAuthPlugin {\n declare [DECLARE_SERVICE_INTERFACE]: \"authentication-keycloak.KeycloakAuthPlugin\";\n\n #notifier: NotificationService;\n #intl: PackageIntl;\n #keycloakOptions: ResolvedKeycloakOptions;\n #keycloak: Keycloak;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #timerId: any;\n #watcher: Resource | undefined;\n\n #state = reactive<AuthState>({\n kind: \"pending\"\n });\n\n constructor(options: ServiceOptions<References>) {\n this.#notifier = options.references.notifier;\n this.#intl = options.intl;\n\n try {\n this.#keycloakOptions = getKeycloakConfig(options.properties);\n } catch (e) {\n throw new Error(\"Invalid keycloak configuration\", { cause: e });\n }\n\n try {\n this.#keycloak = new Keycloak(this.#keycloakOptions.config);\n } catch (e) {\n throw new Error(\"Failed to construct keycloak instance\", { cause: e });\n }\n this.#init().catch((e) => {\n this.#updateState({\n kind: \"error\",\n error: e\n });\n this.#notifier.notify({\n level: \"error\",\n title: this.#intl.formatMessage({\n id: \"loginFailed.title\"\n }),\n message: this.#intl.formatMessage({\n id: \"loginFailed.message\"\n })\n });\n\n LOG.error(\"Failed to check if user is authenticated\", e);\n });\n }\n\n destroy() {\n clearInterval(this.#timerId);\n this.#watcher = destroyResource(this.#watcher);\n this.#timerId = undefined;\n }\n\n getAuthState(): AuthState {\n return this.#state.value;\n }\n\n getLoginBehavior(): LoginBehavior {\n const doLogin = () => {\n const options = this.#keycloakOptions.loginOptions;\n LOG.debug(\"Login with options\", options);\n this.#keycloak.login(options);\n };\n return {\n kind: \"effect\",\n login: doLogin\n };\n }\n\n logout(options?: Partial<KeycloakLogoutOptions>) {\n const logoutOptions = {\n ...this.#keycloakOptions.logoutOptions,\n ...options\n };\n LOG.debug(\"Logout with options\", logoutOptions);\n this.#keycloak.logout(logoutOptions);\n }\n\n async #init() {\n const { initOptions, refreshOptions } = this.#keycloakOptions;\n\n let isAuthenticated: boolean;\n try {\n LOG.debug(\"Init with options\", initOptions);\n isAuthenticated = await this.#keycloak.init(initOptions);\n } catch (e) {\n // Note: keycloak.init() can also throw an exception, in addition to a rejected promise.\n // It may also just throw a string..\n const error = typeof e === \"string\" ? new Error(e) : e;\n throw new Error(\"Failed to initialize keycloak session\", { cause: error });\n }\n\n if (isAuthenticated) {\n this.#updateState({\n kind: \"authenticated\",\n sessionInfo: {\n userId: this.#keycloak.subject ? this.#keycloak.subject : \"undefined\",\n userName: this.#keycloak.idTokenParsed?.preferred_username,\n attributes: {\n keycloak: this.#keycloak,\n familyName: this.#keycloak.idTokenParsed?.family_name,\n givenName: this.#keycloak.idTokenParsed?.given_name,\n userName: this.#keycloak.idTokenParsed?.preferred_username\n }\n }\n });\n\n LOG.debug(`User ${this.#keycloak.subject} is authenticated`);\n\n if (refreshOptions.autoRefresh) {\n LOG.debug(\"Starting auto-refresh\", refreshOptions);\n this.__refresh(refreshOptions.interval, refreshOptions.timeLeft);\n }\n } else {\n this.#updateState({\n kind: \"not-authenticated\"\n });\n LOG.debug(\"User is not authenticated\");\n }\n }\n\n // Mocked in test\n private __refresh(interval: number, timeLeft: number) {\n clearInterval(this.#timerId);\n this.#timerId = setInterval(() => {\n LOG.debug(\"Checking token validity\");\n this.#keycloak\n .updateToken(timeLeft)\n .then((refreshed) => {\n if (refreshed) {\n LOG.debug(\"Token refreshed successfully\");\n } else {\n LOG.debug(\"Token is still valid\");\n }\n })\n .catch((e) => {\n LOG.error(\"Failed to refresh token\", e);\n this.#updateState({\n kind: \"not-authenticated\"\n });\n this.destroy();\n });\n }, interval);\n }\n\n #updateState(newState: AuthState) {\n this.#state.value = newState;\n }\n}\n"],"names":[],"mappings":";;;;;;AAiBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAM1B,MAAM,sBAAA,CAA8D;AAAA,EAGvE,SAAA;AAAA,EACA,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EACA,QAAA;AAAA,EAEA,SAAS,QAAA,CAAoB;AAAA,IACzB,IAAA,EAAM;AAAA,GACT,CAAA;AAAA,EAED,YAAY,OAAA,EAAqC;AAC7C,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,UAAA,CAAW,QAAA;AACpC,IAAA,IAAA,CAAK,QAAQ,OAAA,CAAQ,IAAA;AAErB,IAAA,IAAI;AACA,MAAA,IAAA,CAAK,gBAAA,GAAmB,iBAAA,CAAkB,OAAA,CAAQ,UAAU,CAAA;AAAA,IAChE,SAAS,CAAA,EAAG;AACR,MAAA,MAAM,IAAI,KAAA,CAAM,gCAAA,EAAkC,EAAE,KAAA,EAAO,GAAG,CAAA;AAAA,IAClE;AAEA,IAAA,IAAI;AACA,MAAA,IAAA,CAAK,SAAA,GAAY,IAAI,QAAA,CAAS,IAAA,CAAK,iBAAiB,MAAM,CAAA;AAAA,IAC9D,SAAS,CAAA,EAAG;AACR,MAAA,MAAM,IAAI,KAAA,C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;AAAA,IACT,GAAG,QAAQ,CAAA;AAAA,EACf;AAAA,EAEA,aAAa,QAAA,EAAqB;AAC9B,IAAA,IAAA,CAAK,OAAO,KAAA,GAAQ,QAAA;AAAA,EACxB;AACJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/getKeycloakConfig.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '@open-pioneer/core';
|
|
2
|
+
import { sourceId$1 as sourceId } from './_virtual/source-info.js';
|
|
2
3
|
|
|
3
|
-
const LOG = createLogger(
|
|
4
|
+
const LOG = createLogger(sourceId);
|
|
4
5
|
const DEFAULT_REFRESH_OPTS = {
|
|
5
6
|
autoRefresh: true,
|
|
6
7
|
interval: 1e4,
|
package/getKeycloakConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKeycloakConfig.js","sources":["getKeycloakConfig.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n KeycloakConfig,\n KeycloakInitOptions,\n KeycloakLoginOptions,\n KeycloakLogoutOptions\n} from \"keycloak-js\";\nimport
|
|
1
|
+
{"version":3,"file":"getKeycloakConfig.js","sources":["getKeycloakConfig.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport type {\n KeycloakConfig,\n KeycloakInitOptions,\n KeycloakLoginOptions,\n KeycloakLogoutOptions\n} from \"keycloak-js\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { KeycloakProperties, RefreshOptions } from \"./api\";\nconst LOG = createLogger(sourceId);\n\nconst DEFAULT_REFRESH_OPTS = {\n autoRefresh: true,\n interval: 10000,\n timeLeft: 60\n} as const;\n\nconst DEFAULT_INIT_OPTS = {\n onLoad: \"check-sso\",\n pkceMethod: \"S256\"\n} as const;\n\nexport type ResolvedRefreshOptions = Required<RefreshOptions>;\n\nexport interface ResolvedKeycloakOptions {\n config: KeycloakConfig;\n initOptions: KeycloakInitOptions;\n refreshOptions: ResolvedRefreshOptions;\n loginOptions: Partial<KeycloakLoginOptions>;\n logoutOptions: Partial<KeycloakLogoutOptions>;\n}\n\n/**\n * Parses the user supplied package properties.\n */\nexport function getKeycloakConfig(\n properties: Partial<KeycloakProperties>\n): ResolvedKeycloakOptions {\n const { keycloakOptions } = properties;\n if (!keycloakOptions) {\n throw new Error(\n `KeycloakOptions not found: The Keycloak configuration options are required by the plugin to perform login and logout operations`\n );\n }\n const {\n refreshOptions,\n keycloakInitOptions,\n keycloakConfig,\n keycloakLoginOptions,\n keycloakLogoutOptions\n } = keycloakOptions;\n return {\n config: getConfig(keycloakConfig),\n refreshOptions: getRefreshOptions(refreshOptions),\n initOptions: getInitOptions(keycloakInitOptions),\n loginOptions: getLoginOptions(keycloakLoginOptions),\n logoutOptions: getLogoutOptions(keycloakLogoutOptions)\n };\n}\n\nfunction getConfig(keycloakConfig: KeycloakConfig | undefined): KeycloakConfig {\n if (!keycloakConfig || isObjectEmpty(keycloakConfig)) {\n throw new Error(\n `KeycloakConfig not found: The Keycloak configuration options are required by the plugin to perform login and logout operations`\n );\n }\n return { ...keycloakConfig };\n}\n\nfunction getRefreshOptions(refreshOptions: RefreshOptions | undefined): ResolvedRefreshOptions {\n if (!refreshOptions || isObjectEmpty(refreshOptions)) {\n LOG.info(`Using default options for keycloak token refresh`, DEFAULT_REFRESH_OPTS);\n }\n return {\n ...DEFAULT_REFRESH_OPTS,\n ...refreshOptions\n };\n}\n\nfunction getInitOptions(keycloakInitOptions: KeycloakInitOptions | undefined): KeycloakInitOptions {\n if (!keycloakInitOptions || isObjectEmpty(keycloakInitOptions)) {\n LOG.info(`Using default options for keycloak init`, DEFAULT_INIT_OPTS);\n }\n return {\n ...DEFAULT_INIT_OPTS,\n ...keycloakInitOptions\n };\n}\n\nfunction getLoginOptions(\n keycloakLoginOptions: Partial<KeycloakLoginOptions> | undefined\n): Partial<KeycloakLoginOptions> {\n return {\n redirectUri: undefined, // backwards-compat; unsure if needed\n ...keycloakLoginOptions\n };\n}\n\nfunction getLogoutOptions(\n keycloakLogoutOptions: Partial<KeycloakLogoutOptions> | undefined\n): Partial<KeycloakLogoutOptions> {\n return {\n redirectUri: undefined, // backwards-compat; unsure if needed\n ...keycloakLogoutOptions\n };\n}\n\nconst isObjectEmpty = (objectName: unknown) => {\n return objectName && Object.keys(objectName).length === 0 && objectName.constructor === Object;\n};\n"],"names":[],"mappings":";;;AAWA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,oBAAA,GAAuB;AAAA,EACzB,WAAA,EAAa,IAAA;AAAA,EACb,QAAA,EAAU,GAAA;AAAA,EACV,QAAA,EAAU;AACd,CAAA;AAEA,MAAM,iBAAA,GAAoB;AAAA,EACtB,MAAA,EAAQ,WAAA;AAAA,EACR,UAAA,EAAY;AAChB,CAAA;AAeO,SAAS,kBACZ,UAAA,EACuB;AACvB,EAAA,MAAM,EAAE,iBAAgB,GAAI,UAAA;AAC5B,EAAA,IAAI,CAAC,eAAA,EAAiB;AAClB,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,+HAAA;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,MAAM;AAAA,IACF,cAAA;AAAA,IACA,mBAAA;AAAA,IACA,cAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACJ,GAAI,eAAA;AACJ,EAAA,OAAO;AAAA,IACH,MAAA,EAAQ,UAAU,cAAc,CAAA;AAAA,IAChC,cAAA,EAAgB,kBAAkB,cAAc,CAAA;AAAA,IAChD,WAAA,EAAa,eAAe,mBAAmB,CAAA;AAAA,IAC/C,YAAA,EAAc,gBAAgB,oBAAoB,CAAA;AAAA,IA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
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/authentication-keycloak",
|
|
4
|
-
"version": "4.4.0
|
|
4
|
+
"version": "4.4.0",
|
|
5
5
|
"description": "Implements authentication against Keycloak servers.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@conterra/reactivity-core": "^0.8.1",
|
|
18
18
|
"keycloak-js": "^26.2.2",
|
|
19
|
-
"@open-pioneer/authentication": "4.4.0
|
|
20
|
-
"@open-pioneer/runtime": "4.4.0
|
|
21
|
-
"@open-pioneer/
|
|
22
|
-
"@open-pioneer/
|
|
19
|
+
"@open-pioneer/authentication": "4.4.0",
|
|
20
|
+
"@open-pioneer/runtime": "4.4.0",
|
|
21
|
+
"@open-pioneer/notifier": "4.4.0",
|
|
22
|
+
"@open-pioneer/core": "4.4.0"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
"./package.json": "./package.json",
|