diff --git a/jest.config.js b/jest.config.js index f7253f9d2..c81058563 100644 --- a/jest.config.js +++ b/jest.config.js @@ -31,6 +31,6 @@ module.exports = { setupFilesAfterEnv: ['/test-setup.js'], // The test environment that will be used for testing. - transformIgnorePatterns: ['/node_modules/(?!(react-syntax-highlighter)/)'], + transformIgnorePatterns: ['/node_modules/(?!(react-syntax-highlighter|keycloak-js)/)'], testEnvironment: "jsdom", }; diff --git a/package-lock.json b/package-lock.json index 6fd1487de..b8866a082 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "i18next": "^23.14.0", "i18next-browser-languagedetector": "^8.0.0", "i18next-http-backend": "^2.6.1", - "keycloak-js": "^23.0.7", + "keycloak-js": "^26", "numeral": "^2.0.6", "react": "^18", "react-dom": "^18", @@ -3796,6 +3796,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -10086,11 +10087,6 @@ "@sideway/pinpoint": "^2.0.0" } }, - "node_modules/js-sha256": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.10.1.tgz", - "integrity": "sha512-5obBtsz9301ULlsgggLg542s/jqtddfOpV5KJc4hajc9JV8GeY2gZHSVpYBn4nWqAUTJ9v+xwtbJ1mIBgIH5Vw==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -10359,23 +10355,10 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/jwt-decode": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", - "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", - "engines": { - "node": ">=18" - } - }, "node_modules/keycloak-js": { - "version": "23.0.7", - "resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-23.0.7.tgz", - "integrity": "sha512-OmszsKzBhhm5yP4W1q/tMd+nNnKpOAdeVYcoGhphlv8Fj1bNk4wRTYzp7pn5BkvueLz7fhvKHz7uOc33524YrA==", - "dependencies": { - "base64-js": "^1.5.1", - "js-sha256": "^0.10.1", - "jwt-decode": "^4.0.0" - } + "version": "26.0.1", + "resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-26.0.1.tgz", + "integrity": "sha512-Fhn7a9FVKTpno2yfhL6/eiQrmEgBkiM+toVBJ1+g8kasG6CeiMKnI93byL5W8W3M7Ld3Im1QD3kuL/z4vJHGcg==" }, "node_modules/keyv": { "version": "4.5.4", diff --git a/package.json b/package.json index a8234fa1f..f75910f3c 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "i18next": "^23.14.0", "i18next-browser-languagedetector": "^8.0.0", "i18next-http-backend": "^2.6.1", - "keycloak-js": "^23.0.7", + "keycloak-js": "^26", "numeral": "^2.0.6", "react": "^18", "react-dom": "^18", diff --git a/src/services/keycloakService.ts b/src/services/keycloakService.ts index 900f5a227..62c9deff6 100644 --- a/src/services/keycloakService.ts +++ b/src/services/keycloakService.ts @@ -1,4 +1,4 @@ -import Keycloak, { KeycloakError, KeycloakLoginOptions } from 'keycloak-js'; +import Keycloak, { KeycloakConfig, KeycloakLoginOptions } from 'keycloak-js'; export class KeycloakService { private initialized = false; @@ -13,7 +13,7 @@ export class KeycloakService { return this.instance; } - public static init(configOptions: Keycloak.KeycloakConfig | undefined): Promise { + public static init(configOptions: KeycloakConfig | undefined): Promise { if (!configOptions) { console.error('Unable to init Keycloak with undefined configOptions'); return new Promise((resolve, reject) => reject('Unable to init Keycloak with undefined configOptions')); @@ -27,7 +27,7 @@ export class KeycloakService { KeycloakService.Instance.initialized = true; resolve(); }) - .catch((errorData: KeycloakError) => { + .catch((errorData) => { reject(errorData); }); }); @@ -55,8 +55,17 @@ export class KeycloakService { }); } - public logout(redirectUri?: string): void { - KeycloakService.keycloakAuth.logout({ redirectUri: redirectUri }); + public logout(redirectUri?: string): Promise { + return new Promise((resolve, reject) => { + KeycloakService.keycloakAuth + .logout({ redirectUri: redirectUri }) + .then(() => { + resolve(); + }) + .catch(() => { + reject(); + }); + }); } public account(): void { diff --git a/src/types/InfinispanTypes.ts b/src/types/InfinispanTypes.ts index ff5c80aee..3e197ce28 100644 --- a/src/types/InfinispanTypes.ts +++ b/src/types/InfinispanTypes.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ - interface Status { name: string; color: string; diff --git a/tsconfig.json b/tsconfig.json index 02d0b730a..f16c44ee3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "lib": ["es6", "dom"], "sourceMap": true, "jsx": "react", - "moduleResolution": "node", + "moduleResolution": "Bundler", "forceConsistentCasingInFileNames": true, "noImplicitReturns": true, "noImplicitThis": true,