From e3c546fbaaf1b9ad09d5e366fb4cf71eab80cd28 Mon Sep 17 00:00:00 2001 From: Grzegorz Grzybek Date: Fri, 6 Dec 2024 14:01:16 +0100 Subject: [PATCH] 1.6.x keycloak upgrade (#1252) * build(deps): bump keycloak-js from 23.0.7 to 26.0.2 Bumps [keycloak-js](https://github.com/keycloak/keycloak) from 23.0.7 to 26.0.2. - [Release notes](https://github.com/keycloak/keycloak/releases) - [Commits](https://github.com/keycloak/keycloak/compare/23.0.7...26.0.2) --- updated-dependencies: - dependency-name: keycloak-js dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] (cherry picked from commit e9645dc80a89755b001b78201a5c85c328d9d1a1) * chore(keycloak): Fix Jest tests with Keycloak.js 26 - but needs tsconfig.json change... (cherry picked from commit 072cb395a0afa0c2f3f2aad74c0b3f5ff3ba6b70) * build(deps): bump keycloak-js from 26.0.2 to 26.0.6 Bumps [keycloak-js](https://github.com/keycloak/keycloak) from 26.0.2 to 26.0.6. - [Release notes](https://github.com/keycloak/keycloak/releases) - [Commits](https://github.com/keycloak/keycloak/compare/26.0.2...26.0.6) --- updated-dependencies: - dependency-name: keycloak-js dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (cherry picked from commit bc6ad2d65ca582ba9368605866d10ffe0eaeb4ad) --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/hawtio/jest.config.ts | 1 + packages/hawtio/package.json | 2 +- packages/hawtio/src/__mocks__/keycloak.js | 3 +++ .../plugins/auth/keycloak/keycloak-service.ts | 4 ++-- packages/hawtio/tsconfig.json | 2 +- yarn.lock | 23 +++++-------------- 6 files changed, 14 insertions(+), 21 deletions(-) create mode 100644 packages/hawtio/src/__mocks__/keycloak.js diff --git a/packages/hawtio/jest.config.ts b/packages/hawtio/jest.config.ts index d9d79a75d..a38e5b721 100644 --- a/packages/hawtio/jest.config.ts +++ b/packages/hawtio/jest.config.ts @@ -15,6 +15,7 @@ const config: Config = { '\\.(css|less)$': '/src/__mocks__/styleMock.js', '@hawtiosrc/(.*)': '/src/$1', 'react-markdown': '/../../node_modules/react-markdown/react-markdown.min.js', + 'keycloak-js': path.resolve(__dirname, './src/__mocks__/keycloak.js'), 'monaco-editor': path.resolve(__dirname, './src/__mocks__/monacoEditor.js'), '@monaco-editor/react': path.resolve(__dirname, './src/__mocks__/monacoEditor.js'), '@patternfly/react-code-editor': path.resolve(__dirname, './src/__mocks__/codeEditorMock.js'), diff --git a/packages/hawtio/package.json b/packages/hawtio/package.json index 67d16abd4..dd380b74d 100644 --- a/packages/hawtio/package.json +++ b/packages/hawtio/package.json @@ -61,7 +61,7 @@ "jquery": "^3.7.1", "js-logger": "^1.6.1", "jwt-decode": "^4.0.0", - "keycloak-js": "^23.0.7", + "keycloak-js": "^26.0.6", "monaco-editor": "^0.52.0", "oauth4webapi": "^2.17.0", "react": "^18.3.1", diff --git a/packages/hawtio/src/__mocks__/keycloak.js b/packages/hawtio/src/__mocks__/keycloak.js new file mode 100644 index 000000000..c3769a17a --- /dev/null +++ b/packages/hawtio/src/__mocks__/keycloak.js @@ -0,0 +1,3 @@ +module.exports = { + Keycloak: () => {}, +} diff --git a/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts b/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts index 0b451cb81..37eaff235 100644 --- a/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts +++ b/packages/hawtio/src/plugins/auth/keycloak/keycloak-service.ts @@ -242,7 +242,7 @@ class KeycloakService implements IKeycloakService { keycloak .updateToken(KEYCLOAK_TOKEN_MINIMUM_VALIDITY) - .then(refreshed => { + .then((refreshed: boolean) => { if (refreshed) { const token = keycloak.token if (token) { @@ -252,7 +252,7 @@ class KeycloakService implements IKeycloakService { log.debug('Token is still valid') } }) - .catch(reason => { + .catch((reason: Error) => { log.error("Couldn't update token:", reason) errorFn?.() }) diff --git a/packages/hawtio/tsconfig.json b/packages/hawtio/tsconfig.json index 1440b66cc..63068776e 100644 --- a/packages/hawtio/tsconfig.json +++ b/packages/hawtio/tsconfig.json @@ -16,7 +16,7 @@ "noImplicitThis": true, "noUncheckedIndexedAccess": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, diff --git a/yarn.lock b/yarn.lock index 2f48b2899..a23ae45f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2051,7 +2051,7 @@ __metadata: jquery: "npm:^3.7.1" js-logger: "npm:^1.6.1" jwt-decode: "npm:^4.0.0" - keycloak-js: "npm:^23.0.7" + keycloak-js: "npm:^26.0.6" monaco-editor: "npm:^0.52.0" oauth4webapi: "npm:^2.17.0" react: "npm:^18.3.1" @@ -5169,7 +5169,7 @@ __metadata: languageName: node linkType: hard -"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": +"base64-js@npm:^1.3.1": version: 1.5.1 resolution: "base64-js@npm:1.5.1" checksum: 10/669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 @@ -10238,13 +10238,6 @@ __metadata: languageName: node linkType: hard -"js-sha256@npm:^0.10.1": - version: 0.10.1 - resolution: "js-sha256@npm:0.10.1" - checksum: 10/6bae235dd458744e573876cc0875e21ea18a84e3aec4ba82d0efdb28537366e225304d93072789883500ca995fcc7c4500528c66d02da88cc5d6ab4554ce2b8c - languageName: node - linkType: hard - "js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" @@ -10465,14 +10458,10 @@ __metadata: languageName: node linkType: hard -"keycloak-js@npm:^23.0.7": - version: 23.0.7 - resolution: "keycloak-js@npm:23.0.7" - dependencies: - base64-js: "npm:^1.5.1" - js-sha256: "npm:^0.10.1" - jwt-decode: "npm:^4.0.0" - checksum: 10/61c127a9ac4954d1d0f7f1eee2348043322e21ec956f1ac7819bced39ce1360470cbbb5bd6f81ac1ee59a6fecc1cc5c2667f4e4f249c9c9b86a747a3654efb97 +"keycloak-js@npm:^26.0.6": + version: 26.0.6 + resolution: "keycloak-js@npm:26.0.6" + checksum: 10/f4cd1a46f379f38bd426076ab40625602226d8fc8565857d44d97bd408a2604864e567e129526ffe9a4be3bab2955d496aa5f09cda9c59e7eaf5e65eb95de197 languageName: node linkType: hard