1 | {"version":3,"file":"keycloak-angular.js","sources":["ng://keycloak-angular/lib/core/interfaces/keycloak-event.ts","ng://keycloak-angular/lib/core/services/keycloak-auth-guard.ts","ng://keycloak-angular/lib/core/services/keycloak.service.ts","ng://keycloak-angular/lib/core/interceptors/keycloak-bearer.interceptor.ts","ng://keycloak-angular/lib/core/core.module.ts","ng://keycloak-angular/lib/keycloak-angular.module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Mauricio Gemelli Vigolo and contributors.\n *\n * Use of this source code is governed by a MIT-style license that can be\n * found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/LICENSE\n */\n\n/**\n * Keycloak event types, as described at the keycloak-js documentation:\n * https://www.keycloak.org/docs/latest/securing_apps/index.html#callback-events\n */\nexport enum KeycloakEventType {\n /**\n * Called if there was an error during authentication.\n */\n OnAuthError,\n /**\n * Called if the user is logged out\n * (will only be called if the session status iframe is enabled, or in Cordova mode).\n */\n OnAuthLogout,\n /**\n * Called if there was an error while trying to refresh the token.\n */\n OnAuthRefreshError,\n /**\n * Called when the token is refreshed.\n */\n OnAuthRefreshSuccess,\n /**\n * Called when a user is successfully authenticated.\n */\n OnAuthSuccess,\n /**\n * Called when the adapter is initialized.\n */\n OnReady,\n /**\n * Called when the access token is expired. If a refresh token is available the token\n * can be refreshed with updateToken, or in cases where it is not (that is, with implicit flow)\n * you can redirect to login screen to obtain a new access token.\n */\n OnTokenExpired\n}\n\n/**\n * Structure of an event triggered by Keycloak, contains it's type\n * and arguments (if any).\n */\nexport interface KeycloakEvent {\n /**\n * Event type as described at {@link KeycloakEventType}.\n */\n type: KeycloakEventType;\n /**\n * Arguments from the keycloak-js event function.\n */\n args?: any;\n}\n","/**\n * @license\n * Copyright Mauricio Gemelli Vigolo and contributors.\n *\n * Use of this source code is governed by a MIT-style license that can be\n * found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/LICENSE\n */\n\nimport { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\n\nimport { KeycloakService } from './keycloak.service';\n\n/**\n * A simple guard implementation out of the box. This class should be inherited and\n * implemented by the application. The only method that should be implemented is #isAccessAllowed.\n * The reason for this is that the authorization flow is usually not unique, so in this way you will\n * have more freedom to customize your authorization flow.\n */\nexport abstract class KeycloakAuthGuard implements CanActivate {\n /**\n * Indicates if the user is authenticated or not.\n */\n protected authenticated: boolean;\n /**\n * Roles of the logged user. It contains the clientId and realm user roles.\n */\n protected roles: string[];\n\n constructor(protected router: Router, protected keycloakAngular: KeycloakService) {}\n\n /**\n * CanActivate checks if the user is logged in and get the full list of roles (REALM + CLIENT)\n * of the logged user. This values are set to authenticated and roles params.\n *\n * @param route\n * @param state\n */\n canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {\n return new Promise(async (resolve, reject) => {\n try {\n this.authenticated = await this.keycloakAngular.isLoggedIn();\n this.roles = await this.keycloakAngular.getUserRoles(true);\n\n const result = await this.isAccessAllowed(route, state);\n resolve(result);\n } catch (error) {\n reject('An error happened during access validation. Details:' + error);\n }\n });\n }\n\n /**\n * Create your own customized authorization flow in this method. From here you already known\n * if the user is authenticated (this.authenticated) and the user roles (this.roles).\n *\n * @param route\n * @param state\n */\n abstract isAccessAllowed(\n route: ActivatedRouteSnapshot,\n state: RouterStateSnapshot\n ): Promise<boolean>;\n}\n","/**\n * @license\n * Copyright Mauricio Gemelli Vigolo and contributors.\n *\n * Use of this source code is governed by a MIT-style license that can be\n * found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/LICENSE\n */\n\nimport { Injectable } from '@angular/core';\nimport { HttpHeaders } from '@angular/common/http';\n\nimport { Observable, Observer, Subject } from 'rxjs';\n\n// Workaround for rollup library behaviour, as pointed out on issue #1267 (https://github.com/rollup/rollup/issues/1267).\nimport * as Keycloak_ from 'keycloak-js';\nexport const Keycloak = Keycloak_;\n\nimport { ExcludedUrl, ExcludedUrlRegex, KeycloakOptions } from '../interfaces/keycloak-options';\nimport { KeycloakEvent, KeycloakEventType } from '../interfaces/keycloak-event';\n\n/**\n * Service to expose existent methods from the Keycloak JS adapter, adding new\n * functionalities to improve the use of keycloak in Angular v > 4.3 applications.\n *\n * This class should be injected in the application bootstrap, so the same instance will be used\n * along the web application.\n */\n@Injectable()\nexport class KeycloakService {\n /**\n * Keycloak-js instance.\n */\n private _instance: Keycloak.KeycloakInstance;\n /**\n * User profile as KeycloakProfile interface.\n */\n private _userProfile: Keycloak.KeycloakProfile;\n /**\n * Flag to indicate if the bearer will not be added to the authorization header.\n */\n private _enableBearerInterceptor: boolean;\n /**\n * When the implicit flow is choosen there must exist a silentRefresh, as there is\n * no refresh token.\n */\n private _silentRefresh: boolean;\n /**\n * Indicates that the user profile should be loaded at the keycloak initialization,\n * just after the login.\n */\n private _loadUserProfileAtStartUp: boolean;\n /**\n * The bearer prefix that will be appended to the Authorization Header.\n */\n private _bearerPrefix: string;\n /**\n * Value that will be used as the Authorization Http Header name.\n */\n private _authorizationHeaderName: string;\n /**\n * The excluded urls patterns that must skip the KeycloakBearerInterceptor.\n */\n private _excludedUrls: ExcludedUrlRegex[];\n /**\n * Observer for the keycloak events\n */\n private _keycloakEvents$: Subject<KeycloakEvent> = new Subject<KeycloakEvent>();\n\n /**\n * Binds the keycloak-js events to the keycloakEvents Subject\n * which is a good way to monitor for changes, if needed.\n *\n * The keycloakEvents returns the keycloak-js event type and any\n * argument if the source function provides any.\n */\n private bindsKeycloakEvents(): void {\n this._instance.onAuthError = errorData => {\n this._keycloakEvents$.next({\n args: errorData,\n type: KeycloakEventType.OnAuthError\n });\n };\n\n this._instance.onAuthLogout = () => {\n this._keycloakEvents$.next({ type: KeycloakEventType.OnAuthLogout });\n };\n\n this._instance.onAuthRefreshSuccess = () => {\n this._keycloakEvents$.next({\n type: KeycloakEventType.OnAuthRefreshSuccess\n });\n };\n\n this._instance.onAuthRefreshError = () => {\n this._keycloakEvents$.next({\n type: KeycloakEventType.OnAuthRefreshError\n });\n };\n\n this._instance.onAuthSuccess = () => {\n this._keycloakEvents$.next({ type: KeycloakEventType.OnAuthSuccess });\n };\n\n this._instance.onTokenExpired = () => {\n this._keycloakEvents$.next({\n type: KeycloakEventType.OnTokenExpired\n });\n };\n\n this._instance.onReady = authenticated => {\n this._keycloakEvents$.next({\n args: authenticated,\n type: KeycloakEventType.OnReady\n });\n };\n }\n\n /**\n * Loads all bearerExcludedUrl content in a uniform type: ExcludedUrl,\n * so it becomes easier to handle.\n *\n * @param bearerExcludedUrls array of strings or ExcludedUrl that includes\n * the url and HttpMethod.\n */\n private loadExcludedUrls(bearerExcludedUrls: (string | ExcludedUrl)[]): ExcludedUrlRegex[] {\n const excludedUrls: ExcludedUrlRegex[] = [];\n for (const item of bearerExcludedUrls) {\n let excludedUrl: ExcludedUrlRegex;\n if (typeof item === 'string') {\n excludedUrl = { urlPattern: new RegExp(item, 'i'), httpMethods: [] };\n } else {\n excludedUrl = {\n urlPattern: new RegExp(item.url, 'i'),\n httpMethods: item.httpMethods\n };\n }\n excludedUrls.push(excludedUrl);\n }\n return excludedUrls;\n }\n\n /**\n * Handles the class values initialization.\n *\n * @param options\n */\n private initServiceValues({\n enableBearerInterceptor = true,\n loadUserProfileAtStartUp = true,\n bearerExcludedUrls = [],\n authorizationHeaderName = 'Authorization',\n bearerPrefix = 'bearer',\n initOptions\n }: KeycloakOptions): void {\n this._enableBearerInterceptor = enableBearerInterceptor;\n this._loadUserProfileAtStartUp = loadUserProfileAtStartUp;\n this._authorizationHeaderName = authorizationHeaderName;\n this._bearerPrefix = bearerPrefix.trim().concat(' ');\n this._excludedUrls = this.loadExcludedUrls(bearerExcludedUrls);\n this._silentRefresh = initOptions ? initOptions.flow === 'implicit' : false;\n }\n\n /**\n * Keycloak initialization. It should be called to initialize the adapter.\n * Options is a object with 2 main parameters: config and initOptions. The first one\n * will be used to create the Keycloak instance. The second one are options to initialize the\n * keycloak instance.\n *\n * @param options\n * Config: may be a string representing the keycloak URI or an object with the\n * following content:\n * - url: Keycloak json URL\n * - realm: realm name\n * - clientId: client id\n *\n * initOptions:\n * - onLoad: Specifies an action to do on load. Supported values are 'login-required' or\n * 'check-sso'.\n * - token: Set an initial value for the token.\n * - refreshToken: Set an initial value for the refresh token.\n * - idToken: Set an initial value for the id token (only together with token or refreshToken).\n * - timeSkew: Set an initial value for skew between local time and Keycloak server in seconds\n * (only together with token or refreshToken).\n * - checkLoginIframe: Set to enable/disable monitoring login state (default is true).\n * - checkLoginIframeInterval: Set the interval to check login state (default is 5 seconds).\n * - responseMode: Set the OpenID Connect response mode send to Keycloak server at login\n * request. Valid values are query or fragment . Default value is fragment, which means\n * that after successful authentication will Keycloak redirect to javascript application\n * with OpenID Connect parameters added in URL fragment. This is generally safer and\n * recommended over query.\n * - flow: Set the OpenID Connect flow. Valid values are standard, implicit or hybrid.\n *\n * enableBearerInterceptor:\n * Flag to indicate if the bearer will added to the authorization header.\n *\n * loadUserProfileInStartUp:\n * Indicates that the user profile should be loaded at the keycloak initialization,\n * just after the login.\n *\n * bearerExcludedUrls:\n * String Array to exclude the urls that should not have the Authorization Header automatically\n * added.\n *\n * authorizationHeaderName:\n * This value will be used as the Authorization Http Header name.\n *\n * bearerPrefix:\n * This value will be included in the Authorization Http Header param.\n *\n * @returns\n * A Promise with a boolean indicating if the initialization was successful.\n */\n init(options: KeycloakOptions = {}): Promise<boolean> {\n return new Promise((resolve, reject) => {\n this.initServiceValues(options);\n const { config, initOptions } = options;\n\n this._instance = Keycloak(config);\n this.bindsKeycloakEvents();\n this._instance\n .init(initOptions)\n .success(async authenticated => {\n if (authenticated && this._loadUserProfileAtStartUp) {\n await this.loadUserProfile();\n }\n resolve(authenticated);\n })\n .error(kcError => {\n let msg = 'An error happened during Keycloak initialization.';\n if (kcError) {\n let { error, error_description } = kcError;\n msg = msg.concat(\n `\\nAdapter error details:\\nError: ${error}\\nDescription: ${error_description}`\n );\n }\n reject(msg);\n });\n });\n }\n\n /**\n * Redirects to login form on (options is an optional object with redirectUri and/or\n * prompt fields).\n *\n * @param options\n * Object, where:\n * - redirectUri: Specifies the uri to redirect to after login.\n * - prompt:By default the login screen is displayed if the user is not logged-in to Keycloak.\n * To only authenticate to the application if the user is already logged-in and not display the\n * login page if the user is not logged-in, set this option to none. To always require\n * re-authentication and ignore SSO, set this option to login .\n * - maxAge: Used just if user is already authenticated. Specifies maximum time since the\n * authentication of user happened. If user is already authenticated for longer time than\n * maxAge, the SSO is ignored and he will need to re-authenticate again.\n * - loginHint: Used to pre-fill the username/email field on the login form.\n * - action: If value is 'register' then user is redirected to registration page, otherwise to\n * login page.\n * - locale: Specifies the desired locale for the UI.\n * @returns\n * A void Promise if the login is successful and after the user profile loading.\n */\n login(options: Keycloak.KeycloakLoginOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n this._instance\n .login(options)\n .success(async () => {\n if (this._loadUserProfileAtStartUp) {\n await this.loadUserProfile();\n }\n resolve();\n })\n .error(() => reject(`An error happened during the login.`));\n });\n }\n\n /**\n * Redirects to logout.\n *\n * @param redirectUri\n * Specifies the uri to redirect to after logout.\n * @returns\n * A void Promise if the logout was successful, cleaning also the userProfile.\n */\n logout(redirectUri?: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const options: any = {\n redirectUri\n };\n\n this._instance\n .logout(options)\n .success(() => {\n this._userProfile = undefined;\n resolve();\n })\n .error(() => reject('An error happened during logout.'));\n });\n }\n\n /**\n * Redirects to registration form. Shortcut for login with option\n * action = 'register'. Options are same as for the login method but 'action' is set to\n * 'register'.\n *\n * @param options\n * login options\n * @returns\n * A void Promise if the register flow was successful.\n */\n register(options: Keycloak.KeycloakLoginOptions = { action: 'register' }): Promise<void> {\n return new Promise((resolve, reject) => {\n this._instance\n .register(options)\n .success(() => {\n resolve();\n })\n .error(() => reject('An error happened during the register execution.'));\n });\n }\n\n /**\n * Check if the user has access to the specified role. It will look for roles in\n * realm and clientId, but will not check if the user is logged in for better performance.\n *\n * @param role\n * role name\n * @param resource\n * resource name If not specified, `clientId` is used\n * @returns\n * A boolean meaning if the user has the specified Role.\n */\n isUserInRole(role: string, resource?: string): boolean {\n let hasRole: boolean;\n hasRole = this._instance.hasResourceRole(role, resource);\n if (!hasRole) {\n hasRole = this._instance.hasRealmRole(role);\n }\n return hasRole;\n }\n\n /**\n * Return the roles of the logged user. The allRoles parameter, with default value\n * true, will return the clientId and realm roles associated with the logged user. If set to false\n * it will only return the user roles associated with the clientId.\n *\n * @param allRoles\n * Flag to set if all roles should be returned.(Optional: default value is true)\n * @returns\n * Array of Roles associated with the logged user.\n */\n getUserRoles(allRoles: boolean = true): string[] {\n let roles: string[] = [];\n if (this._instance.resourceAccess) {\n for (const key in this._instance.resourceAccess) {\n if (this._instance.resourceAccess.hasOwnProperty(key)) {\n const resourceAccess: any = this._instance.resourceAccess[key];\n const clientRoles = resourceAccess['roles'] || [];\n roles = roles.concat(clientRoles);\n }\n }\n }\n if (allRoles && this._instance.realmAccess) {\n let realmRoles = this._instance.realmAccess['roles'] || [];\n roles.push(...realmRoles);\n }\n return roles;\n }\n\n /**\n * Check if user is logged in.\n *\n * @returns\n * A boolean that indicates if the user is logged in.\n */\n async isLoggedIn(): Promise<boolean> {\n try {\n if (!this._instance.authenticated) {\n return false;\n }\n await this.updateToken(20);\n return true;\n } catch (error) {\n return false;\n }\n }\n\n /**\n * Returns true if the token has less than minValidity seconds left before\n * it expires.\n *\n * @param minValidity\n * Seconds left. (minValidity) is optional. Default value is 0.\n * @returns\n * Boolean indicating if the token is expired.\n */\n isTokenExpired(minValidity: number = 0): boolean {\n return this._instance.isTokenExpired(minValidity);\n }\n\n /**\n * If the token expires within minValidity seconds the token is refreshed. If the\n * session status iframe is enabled, the session status is also checked.\n * Returns a promise telling if the token was refreshed or not. If the session is not active\n * anymore, the promise is rejected.\n *\n * @param minValidity\n * Seconds left. (minValidity is optional, if not specified 5 is used)\n * @returns\n * Promise with a boolean indicating if the token was succesfully updated.\n */\n updateToken(minValidity: number = 5): Promise<boolean> {\n return new Promise(async (resolve, reject) => {\n // TODO: this is a workaround until the silent refresh (issue #43)\n // is not implemented, avoiding the redirect loop.\n if (this._silentRefresh) {\n if (this.isTokenExpired()) {\n reject('Failed to refresh the token, or the session is expired');\n } else {\n resolve(true);\n }\n return;\n }\n\n if (!this._instance) {\n reject('Keycloak Angular library is not initialized.');\n return;\n }\n\n this._instance\n .updateToken(minValidity)\n .success(refreshed => {\n resolve(refreshed);\n })\n .error(() => reject('Failed to refresh the token, or the session is expired'));\n });\n }\n\n /**\n * Loads the user profile.\n * Returns promise to set functions to be invoked if the profile was loaded\n * successfully, or if the profile could not be loaded.\n *\n * @param forceReload\n * If true will force the loadUserProfile even if its already loaded.\n * @returns\n * A promise with the KeycloakProfile data loaded.\n */\n loadUserProfile(forceReload: boolean = false): Promise<Keycloak.KeycloakProfile> {\n return new Promise(async (resolve, reject) => {\n if (this._userProfile && !forceReload) {\n resolve(this._userProfile);\n return;\n }\n\n if (!this._instance.authenticated) {\n reject('The user profile was not loaded as the user is not logged in.');\n return;\n }\n\n this._instance\n .loadUserProfile()\n .success(result => {\n this._userProfile = result as Keycloak.KeycloakProfile;\n resolve(this._userProfile);\n })\n .error(() => reject('The user profile could not be loaded.'));\n });\n }\n\n /**\n * Returns the authenticated token, calling updateToken to get a refreshed one if\n * necessary. If the session is expired this method calls the login method for a new login.\n *\n * @returns\n * Promise with the generated token.\n */\n getToken(): Promise<string> {\n return new Promise(async (resolve, reject) => {\n try {\n await this.updateToken(10);\n resolve(this._instance.token);\n } catch (error) {\n this.login();\n }\n });\n }\n\n /**\n * Returns the logged username.\n *\n * @returns\n * The logged username.\n */\n getUsername(): string {\n if (!this._userProfile) {\n throw new Error('User not logged in or user profile was not loaded.');\n }\n\n return this._userProfile.username!;\n }\n\n /**\n * Clear authentication state, including tokens. This can be useful if application\n * has detected the session was expired, for example if updating token fails.\n * Invoking this results in onAuthLogout callback listener being invoked.\n */\n clearToken(): void {\n this._instance.clearToken();\n }\n\n /**\n * Adds a valid token in header. The key & value format is:\n * Authorization Bearer <token>.\n * If the headers param is undefined it will create the Angular headers object.\n *\n * @param headers\n * Updated header with Authorization and Keycloak token.\n * @returns\n * An observable with with the HTTP Authorization header and the current token.\n */\n addTokenToHeader(headers: HttpHeaders = new HttpHeaders()): Observable<HttpHeaders> {\n return Observable.create(async (observer: Observer<any>) => {\n try {\n const token: string = await this.getToken();\n headers = headers.set(this._authorizationHeaderName, this._bearerPrefix + token);\n observer.next(headers);\n observer.complete();\n } catch (error) {\n observer.error(error);\n }\n });\n }\n\n /**\n * Returns the original Keycloak instance, if you need any customization that\n * this Angular service does not support yet. Use with caution.\n *\n * @returns\n * The KeycloakInstance from keycloak-js.\n */\n getKeycloakInstance(): Keycloak.KeycloakInstance {\n return this._instance;\n }\n\n /**\n * Returns the excluded URLs that should not be considered by\n * the http interceptor which automatically adds the authorization header in the Http Request.\n *\n * @returns\n * The excluded urls that must not be intercepted by the KeycloakBearerInterceptor.\n */\n get excludedUrls(): ExcludedUrlRegex[] {\n return this._excludedUrls;\n }\n\n /**\n * Flag to indicate if the bearer will be added to the authorization header.\n *\n * @returns\n * Returns if the bearer interceptor was set to be disabled.\n */\n get enableBearerInterceptor(): boolean {\n return this._enableBearerInterceptor;\n }\n\n /**\n * Keycloak subject to monitor the events triggered by keycloak-js.\n * The following events as available (as described at keycloak docs -\n * https://www.keycloak.org/docs/latest/securing_apps/index.html#callback-events):\n * - OnAuthError\n * - OnAuthLogout\n * - OnAuthRefreshError\n * - OnAuthRefreshSuccess\n * - OnAuthSuccess\n * - OnReady\n * - OnTokenExpire\n * In each occurrence of any of these, this subject will return the event type,\n * described at {@link KeycloakEventType} enum and the function args from the keycloak-js\n * if provided any.\n *\n * @returns\n * A subject with the {@link KeycloakEvent} which describes the event type and attaches the\n * function args.\n */\n get keycloakEvents$(): Subject<KeycloakEvent> {\n return this._keycloakEvents$;\n }\n}\n","/**\n * @license\n * Copyright Mauricio Gemelli Vigolo and contributors.\n *\n * Use of this source code is governed by a MIT-style license that can be\n * found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/LICENSE\n */\n\nimport { Injectable } from '@angular/core';\nimport {\n HttpInterceptor,\n HttpRequest,\n HttpHandler,\n HttpEvent\n} from '@angular/common/http';\n\nimport { Observable } from 'rxjs';\nimport { mergeMap } from 'rxjs/operators';\n\nimport { KeycloakService } from '../services/keycloak.service';\nimport { ExcludedUrlRegex } from '../interfaces/keycloak-options';\n\n/**\n * This interceptor includes the bearer by default in all HttpClient requests.\n *\n * If you need to exclude some URLs from adding the bearer, please, take a look\n * at the {@link KeycloakOptions} bearerExcludedUrls property.\n */\n@Injectable()\nexport class KeycloakBearerInterceptor implements HttpInterceptor {\n constructor(private keycloak: KeycloakService) {}\n\n /**\n * Checks if the url is excluded from having the Bearer Authorization\n * header added.\n *\n * @param req http request from @angular http module.\n * @param excludedUrlRegex contains the url pattern and the http methods,\n * excluded from adding the bearer at the Http Request.\n */\n private isUrlExcluded(\n { method, url }: HttpRequest<any>,\n { urlPattern, httpMethods }: ExcludedUrlRegex\n ): boolean {\n let httpTest =\n httpMethods.length === 0 ||\n httpMethods.join().indexOf(method.toUpperCase()) > -1;\n\n let urlTest = urlPattern.test(url);\n\n return httpTest && urlTest;\n }\n\n /**\n * Intercept implementation that checks if the request url matches the excludedUrls.\n * If not, adds the Authorization header to the request.\n *\n * @param req\n * @param next\n */\n public intercept(\n req: HttpRequest<any>,\n next: HttpHandler\n ): Observable<HttpEvent<any>> {\n const { enableBearerInterceptor, excludedUrls } = this.keycloak;\n if (!enableBearerInterceptor) {\n return next.handle(req);\n }\n\n const shallPass: boolean =\n excludedUrls.findIndex(item => this.isUrlExcluded(req, item)) > -1;\n if (shallPass) {\n return next.handle(req);\n }\n\n return this.keycloak.addTokenToHeader(req.headers).pipe(\n mergeMap(headersWithBearer => {\n const kcReq = req.clone({ headers: headersWithBearer });\n return next.handle(kcReq);\n })\n );\n }\n}\n","/**\n * @license\n * Copyright Mauricio Gemelli Vigolo and contributors.\n *\n * Use of this source code is governed by a MIT-style license that can be\n * found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\n\nimport { KeycloakService } from './services/keycloak.service';\nimport { KeycloakBearerInterceptor } from './interceptors/keycloak-bearer.interceptor';\n\n@NgModule({\n imports: [CommonModule],\n providers: [\n KeycloakService,\n {\n provide: HTTP_INTERCEPTORS,\n useClass: KeycloakBearerInterceptor,\n multi: true\n }\n ]\n})\nexport class CoreModule {}\n","/**\n * @license\n * Copyright Mauricio Gemelli Vigolo and contributors.\n *\n * Use of this source code is governed by a MIT-style license that can be\n * found in the LICENSE file at https://github.com/mauriciovigolo/keycloak-angular/LICENSE\n */\n\nimport { NgModule } from '@angular/core';\n\nimport { CoreModule } from './core/core.module';\n\n@NgModule({\n imports: [CoreModule]\n})\nexport class KeycloakAngularModule {}\n"],"names":[],"mappings":";;;;;;;;;IAgBE,cAAW;IAKX,eAAY;IAIZ,qBAAkB;IAIlB,uBAAoB;IAIpB,gBAAa;IAIb,UAAO;IAMP,iBAAc;;;;;;;;;;MCzBM,iBAAiB;IAUrC,YAAsB,MAAc,EAAY,eAAgC;QAA1D,WAAM,GAAN,MAAM,CAAQ;QAAY,oBAAe,GAAf,eAAe,CAAiB;KAAI;IASpF,WAAW,CAAC,KAA6B,EAAE,KAA0B;QACnE,OAAO,IAAI,OAAO,EAAC,CAAO,OAAO,EAAE,MAAM;YACvC,IAAI;gBACF,IAAI,CAAC,aAAa,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;gBAC7D,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;sBAErD,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC;gBACvD,OAAO,CAAC,MAAM,CAAC,CAAC;aACjB;YAAC,OAAO,KAA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