Skip to content

Commit

Permalink
Merge pull request #2153 from qmonmert/keycloak
Browse files Browse the repository at this point in the history
Upgrade keycloak-js 18.0.1
  • Loading branch information
pascalgrimaud authored Jun 20, 2022
2 parents 19fe4af + ed1e2de commit 4658bee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Oauth2AuthService } from './oauth2-auth.service';
import { TestBed } from '@angular/core/testing';
import Keycloak, { KeycloakError, KeycloakInitOptions, KeycloakInstance, KeycloakPromise } from 'keycloak-js';
import Keycloak, { KeycloakError, KeycloakInitOptions, KeycloakPromise } from 'keycloak-js';
import { lastValueFrom } from 'rxjs';
import SpyInstance = jest.SpyInstance;

Expand All @@ -16,7 +16,7 @@ jest.mock('keycloak-js', () => ({
exp: 1200,
},
timeSkew: 0,
} as unknown as KeycloakInstance),
} as unknown as Keycloak),
}));

jest.mock('../../environments/environment', () => ({
Expand All @@ -38,7 +38,7 @@ const UPDATE_TOKEN_INTERVAL_MS = 6000;

describe('Oauth2 Auth Service', () => {
let service: Oauth2AuthService;
let keycloakInstance: KeycloakInstance;
let keycloakInstance: Keycloak;

let consoleDebugMock: SpyInstance;
let consoleErrorMock: SpyInstance;
Expand All @@ -49,7 +49,7 @@ describe('Oauth2 Auth Service', () => {
});

service = TestBed.inject(Oauth2AuthService);
keycloakInstance = Keycloak();
keycloakInstance = new Keycloak();

consoleDebugMock = jest.spyOn(console, 'debug').mockImplementation(() => {});
consoleErrorMock = jest.spyOn(console, 'error').mockImplementation(() => {});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import Keycloak, { KeycloakConfig, KeycloakInstance } from 'keycloak-js';
import Keycloak, { KeycloakConfig } from 'keycloak-js';
import { from, Observable, tap } from 'rxjs';
import { environment } from '../../environments/environment';

Expand All @@ -8,7 +8,7 @@ const REFRESH_TOKEN_TIMEOUT_MS = 6000;

@Injectable({ providedIn: 'root' })
export class Oauth2AuthService {
private keycloak!: KeycloakInstance;
private keycloak = new Keycloak();

get token(): string | undefined {
return this.keycloak.token;
Expand All @@ -24,7 +24,7 @@ export class Oauth2AuthService {
realm: environment.keycloak.realm,
clientId: environment.keycloak.client_id,
};
this.keycloak = Keycloak(config);
this.keycloak = new Keycloak(config);

return from(this.keycloak.init({ onLoad: 'login-required', checkLoginIframe: false })).pipe(
tap(authenticated => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@angular/platform-browser": "14.0.2",
"@angular/platform-browser-dynamic": "14.0.2",
"@angular/router": "14.0.2",
"keycloak-js": "16.1.1",
"keycloak-js": "18.0.1",
"ngx-webstorage": "10.0.1",
"rxjs": "7.5.5",
"tslib": "2.4.0",
Expand Down

0 comments on commit 4658bee

Please sign in to comment.