ngx-oauth 2.1.0 → 2.2.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-oauth.mjs","sources":["../../../projects/ngx-oauth/src/lib/models/index.ts","../../../projects/ngx-oauth/src/lib/services/oauth.service.ts","../../../projects/ngx-oauth/src/lib/services/oauth.interceptor.ts","../../../projects/ngx-oauth/src/lib/components/login/oauth-login.component.ts","../../../projects/ngx-oauth/src/lib/components/login/oauth-login.component.html","../../../projects/ngx-oauth/src/lib/oauth.module.ts","../../../projects/ngx-oauth/src/index.ts","../../../projects/ngx-oauth/src/ngx-oauth.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\n\nexport const SERVER_HOST = new InjectionToken<string>('SERVER_HOST');\nexport const SERVER_PATH = new InjectionToken<string>('SERVER_PATH');\nexport const LOCATION = new InjectionToken<Location>('Location');\nexport const STORAGE = new InjectionToken<Storage>('Storage');\nexport const OAUTH_CONFIG = new InjectionToken<OAuthConfig>('OAuthConfig');\nexport const OAUTH_TOKEN = new InjectionToken<OAuthToken>('OAuthToken');\n\nexport enum OAuthType {\n RESOURCE = 'password',\n AUTHORIZATION_CODE = 'code',\n IMPLICIT = 'token',\n CLIENT_CREDENTIAL = 'client_credentials'\n}\n\nexport interface OAuthConfig {\n type: OAuthType;\n config: OAuthTypeConfig;\n storageKey?: string;\n storage?: Storage;\n ignorePaths?: RegExp[];\n}\n\nexport interface ClientCredentialConfig {\n tokenPath: string;\n revokePath?: string;\n clientId: string;\n clientSecret?: string;\n scope?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface ResourceConfig extends ClientCredentialConfig {\n}\n\nexport interface ImplicitConfig {\n authorizePath: string;\n revokePath?: string;\n clientId: string;\n scope?: string;\n}\n\nexport interface AuthorizationCodeConfig extends ResourceConfig {\n authorizePath: string;\n}\n\nexport interface AuthorizationCodePKCEConfig extends AuthorizationCodeConfig {\n pkce: boolean;\n}\n\nexport interface OpenIdConfig {\n issuerPath: string;\n clientId: string;\n clientSecret?: string;\n scope?: string;\n}\n\nexport interface ResourceParameters {\n username: string;\n password: string;\n}\n\nexport interface ImplicitParameters {\n redirectUri: string;\n state?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface AuthorizationCodeParameters extends ImplicitParameters {\n}\n\nexport type OAuthParameters = ResourceParameters | AuthorizationCodeParameters | ImplicitParameters;\nexport type OAuthTypeConfig = OpenIdConfig\n | AuthorizationCodePKCEConfig\n | AuthorizationCodeConfig\n | ImplicitConfig\n | ResourceConfig\n | ClientCredentialConfig;\n\nexport interface OAuthToken {\n id_token?: string;\n access_token?: string;\n refresh_token?: string;\n token_type?: string;\n state?: string;\n error?: string;\n error_description?: string;\n expires_in?: number | string;\n refresh_expires_in?: number;\n scope?: string;\n codeVerifier?: string;\n nonce?: string;\n}\n\nexport enum OAuthStatus {\n NOT_AUTHORIZED = 'NOT_AUTHORIZED',\n AUTHORIZED = 'AUTHORIZED',\n DENIED = 'DENIED'\n}\n\nexport interface OpenIdConfiguration {\n issuer?: string;\n authorization_endpoint?: string;\n introspection_endpoint?: string;\n token_endpoint?: string;\n userinfo_endpoint?: string;\n end_session_endpoint?: string;\n revocation_endpoint?: string;\n scopes_supported?: string[];\n code_challenge_methods_supported?: string[];\n}\n\nexport interface UserInfo {\n email?: string;\n email_verified?: boolean;\n family_name?: string;\n given_name?: string;\n name?: string;\n preferred_username?: string;\n sub?: string;\n address?: object;\n}\n\nexport interface IntrospectInfo extends UserInfo {\n active: boolean;\n scope: string;\n client_id?: string;\n username: string;\n exp: number;\n}\n","import {Inject, Injectable, NgZone} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';\nimport {catchError, concatMap, delay, filter, map, shareReplay, switchMap, tap} from 'rxjs/operators';\nimport {EMPTY, from, noop, Observable, of, ReplaySubject} from 'rxjs';\nimport {\n AuthorizationCodeParameters,\n ImplicitParameters,\n LOCATION,\n OAUTH_CONFIG,\n OAuthConfig,\n OAuthParameters,\n OAuthStatus,\n OAuthToken,\n OAuthType,\n OAuthTypeConfig, OpenIdConfig, OpenIdConfiguration,\n ResourceParameters, UserInfo\n} from '../models';\nimport {Location as Location2} from '@angular/common';\n\nconst arrToString = (buf: Uint8Array) => buf.reduce((s, b) => s + String.fromCharCode(b), '');\n\nconst base64url = (str: string) => btoa(str)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n\nconst randomString = (length: number = 48) => {\n const buff = arrToString(crypto.getRandomValues(new Uint8Array(length * 2)));\n return base64url(buff).substring(0, length);\n};\n\nconst pkce = async (value: string) => {\n const buff = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));\n return base64url(arrToString(new Uint8Array(buff)));\n};\n\nconst REQUEST_HEADER = new HttpHeaders({'Content-Type': 'application/x-www-form-urlencoded'});\n\nconst parseOauthUri = (hash: string): Record<string, string> | null => {\n const regex = /([^&=]+)=([^&]*)/g;\n const params: Record<string, string> = {};\n let m;\n // tslint:disable-next-line:no-conditional-assignment\n while ((m = regex.exec(hash)) !== null) {\n params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);\n }\n if (Object.keys(params).length) {\n return params;\n }\n return null;\n};\n\nconst jwt = (token: string) => JSON.parse(atob(token.split('.')[1]));\n\n@Injectable()\nexport class OAuthService {\n\n private _token: OAuthToken | null = null;\n private _status = OAuthStatus.NOT_AUTHORIZED;\n private timer: any;\n state$: ReplaySubject<string> = new ReplaySubject(1);\n status$: ReplaySubject<OAuthStatus> = new ReplaySubject(1);\n userInfo$: Observable<UserInfo> = this.status$.pipe(\n filter(s => s === OAuthStatus.AUTHORIZED),\n map(() => {\n const {config} = this.authConfig as any;\n return config.userPath;\n }),\n filter(p => !!p),\n switchMap(path => this.http.get<UserInfo>(path)),\n shareReplay()\n );\n\n constructor(private http: HttpClient,\n private zone: NgZone,\n @Inject(OAUTH_CONFIG) private authConfig: OAuthConfig,\n @Inject(LOCATION) private location: Location,\n private locationService: Location2) {\n setTimeout(() => this.init()); // decouple for http interceptor\n }\n\n /**\n * Get the oauth config for initialize. If OpenId with issuerPath is configured then configure from server openid configuration.\n * @protected\n */\n protected get config$() {\n let {config} = this.authConfig;\n if (config && config.clientId) {\n const {issuerPath, scope} = config as OpenIdConfig;\n if (issuerPath) {\n return this.http.get<OpenIdConfiguration>(`${issuerPath}/.well-known/openid-configuration`).pipe(\n tap(v => this.set(this.type, {\n ...v.authorization_endpoint && {authorizePath: v.authorization_endpoint} || {},\n ...v.token_endpoint && {tokenPath: v.token_endpoint} || {},\n ...v.revocation_endpoint && {revokePath: v.revocation_endpoint} || {},\n ...v.code_challenge_methods_supported && {pkce: v.code_challenge_methods_supported.indexOf('S256') > -1} || {},\n ...v.userinfo_endpoint && {userPath: v.userinfo_endpoint} || {},\n ...v.introspection_endpoint && {introspectionPath: v.introspection_endpoint} || {},\n ...scope && {} || {scope: 'openid'}\n } as any)),\n map(() => this.authConfig.config)\n );\n }\n return of(config);\n }\n console.warn('clientId is missing in oauth config');\n return EMPTY;\n }\n\n /**\n * Init. Will check the url implicit or authorization flow or existing saved token.\n * @protected\n */\n protected init(): void {\n const {hash, search, origin, pathname} = this.location;\n const isImplicitRedirect = hash && /(access_token=)|(error=)/.test(hash);\n const isAuthCodeRedirect = search && /(code=)|(error=)/.test(search);\n const {storageKey} = this.authConfig;\n const savedToken = storageKey && this.authConfig.storage && this.authConfig.storage[storageKey] &&\n JSON.parse(this.authConfig.storage[storageKey]);\n this.config$.subscribe(config => {\n if (isImplicitRedirect) {\n const parameters = parseOauthUri(hash.substr(1));\n this.token = parameters;\n this.status = this.checkResponse(savedToken, parameters) && OAuthStatus.AUTHORIZED || OAuthStatus.DENIED;\n } else if (isAuthCodeRedirect) {\n const parameters = parseOauthUri(search.substr(1));\n if (!this.checkResponse(savedToken, parameters)) {\n this.token = parameters;\n this.status = OAuthStatus.DENIED;\n } else {\n const newParametersString = this.getCleanedUnSearchParameters();\n const {clientId, clientSecret, tokenPath, scope} = config as any;\n const codeVerifier = savedToken && savedToken.codeVerifier;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n code: parameters?.code,\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n redirect_uri: `${origin}${pathname}${newParametersString}`,\n grant_type: 'authorization_code',\n ...scope && {scope} || {},\n ...codeVerifier && {code_verifier: codeVerifier} || {}\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError((err) => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n this.locationService.replaceState(`${pathname}${newParametersString}`);\n return EMPTY;\n })\n ).subscribe(token => {\n this.token = token;\n this.status = OAuthStatus.AUTHORIZED;\n this.locationService.replaceState(`${pathname}${newParametersString}`);\n });\n }\n } else if (savedToken) {\n this._token = savedToken;\n const {access_token, refresh_token, error} = savedToken;\n if (access_token) {\n if (refresh_token) { // force refresh since might be a manual page refresh\n this.refreshToken();\n } else {\n this.status = OAuthStatus.AUTHORIZED;\n }\n } else {\n this.status = error && OAuthStatus.DENIED || OAuthStatus.NOT_AUTHORIZED;\n }\n } else {\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n });\n }\n\n async login(parameters?: OAuthParameters) {\n if (this.isResourceType(parameters as ResourceParameters)) {\n this.resourceLogin(parameters as ResourceParameters);\n } else if (this.isAuthorizationCodeType(parameters as AuthorizationCodeParameters)) {\n await this.authorizationCodeLogin(parameters as AuthorizationCodeParameters);\n } else if (this.isImplicitType(parameters as ImplicitParameters)) {\n await this.implicitLogin(parameters as ImplicitParameters);\n } else if (this.isClientCredentialType()) {\n this.clientCredentialLogin();\n }\n }\n\n logout() {\n this.revoke();\n this.token = null;\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n\n revoke() {\n const {revokePath, clientId, clientSecret} = this.authConfig.config as any;\n if (revokePath) {\n const {access_token, refresh_token} = this.token as OAuthToken;\n const toRevoke = [];\n if (access_token) {\n toRevoke.push({\n ...clientId && {client_id: clientId} || {},\n ...clientSecret && {client_secret: clientSecret} || {},\n token: access_token,\n token_type_hint: 'access_token'\n });\n }\n if (refresh_token) {\n toRevoke.push({\n ...clientId && {client_id: clientId} || {},\n ...clientSecret && {client_secret: clientSecret} || {},\n token: refresh_token,\n token_type_hint: 'refresh_token'\n });\n }\n from(toRevoke).pipe(\n concatMap(o => of(o).pipe(delay(300))), // space request to avoid cancellation\n switchMap(o => this.http.post(revokePath, new HttpParams({fromObject: o}))),\n ).subscribe(noop);\n }\n }\n\n get status(): OAuthStatus {\n return this._status;\n }\n\n set status(status) {\n this._status = status;\n this.status$.next(status);\n }\n\n set(type: OAuthType, config?: OAuthTypeConfig): void {\n this.authConfig.type = type;\n if (config) {\n this.authConfig.config = {\n ...this.authConfig.config,\n ...config\n };\n }\n }\n\n get type(): OAuthType {\n return this.authConfig.type;\n }\n\n get ignorePaths(): RegExp[] {\n return this.authConfig.ignorePaths || [];\n }\n\n private resourceLogin(parameters: ResourceParameters) {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n const {username, password} = parameters;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n grant_type: OAuthType.RESOURCE,\n ...scope && {scope} || {},\n username,\n password\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(err => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private async authorizationCodeLogin(parameters: AuthorizationCodeParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.AUTHORIZATION_CODE);\n this.location.replace(authUrl);\n }\n\n private async implicitLogin(parameters: ImplicitParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.IMPLICIT);\n this.location.replace(authUrl);\n }\n\n private clientCredentialLogin() {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n client_secret: clientSecret,\n grant_type: OAuthType.CLIENT_CREDENTIAL,\n ...scope ? {scope} : {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private isClientCredentialType(): boolean {\n return this.authConfig.type === OAuthType.CLIENT_CREDENTIAL;\n }\n\n private isResourceType(parameters?: ResourceParameters): boolean {\n return this.authConfig.type === OAuthType.RESOURCE && !!parameters?.password;\n }\n\n private isImplicitType(parameters?: ImplicitParameters): boolean {\n return this.authConfig.type === OAuthType.IMPLICIT && !!parameters?.redirectUri;\n }\n\n private isAuthorizationCodeType(parameters?: AuthorizationCodeParameters): boolean {\n return this.authConfig.type === OAuthType.AUTHORIZATION_CODE && !!parameters?.redirectUri;\n }\n\n private async toAuthorizationUrl(parameters: AuthorizationCodeParameters | ImplicitParameters, responseType: OAuthType): Promise<string> {\n const {config} = this.authConfig as any;\n let authorizationUrl = `${config.authorizePath}`;\n authorizationUrl += config.authorizePath.includes('?') && '&' || '?';\n authorizationUrl += `client_id=${config.clientId}`;\n authorizationUrl += `&redirect_uri=${encodeURIComponent(parameters.redirectUri)}`;\n authorizationUrl += `&response_type=${responseType}`;\n authorizationUrl += `&scope=${encodeURIComponent(config.scope || '')}`;\n authorizationUrl += `&state=${encodeURIComponent(parameters.state || '')}`;\n return `${authorizationUrl}${this.generateNonce(config)}${await this.generateCodeChallenge(config)}`;\n }\n\n private async generateCodeChallenge(config: any) {\n if (config.pkce) {\n const codeVerifier = randomString();\n this.token = {...this.token, codeVerifier};\n return `&code_challenge=${await pkce(codeVerifier)}&code_challenge_method=S256`;\n }\n return '';\n }\n\n private generateNonce(config: any) {\n if (config && config.scope && config.scope.indexOf('openid') > -1) {\n const nonce = randomString(10);\n this.token = {...this.token, nonce};\n return `&nonce=${nonce}`;\n }\n return '';\n }\n\n private checkResponse(token: any, parameters: Record<string, string> | null) {\n this.emitState(parameters);\n this.cleanLocationHash();\n if (!parameters || parameters.error) {\n return false;\n }\n if (token && token.nonce && parameters.access_token) {\n const jwtToken = jwt(parameters.access_token);\n return token.nonce === jwtToken.nonce;\n }\n return parameters.access_token || parameters.code;\n }\n\n set token(token: OAuthToken | null) {\n this._token = token;\n const {storageKey} = this.authConfig;\n if (token) {\n // @ts-ignore\n this.authConfig.storage[storageKey] = JSON.stringify(this.token);\n clearTimeout(this.timer);\n if (this.token && this.token.expires_in) {\n this.zone.runOutsideAngular(() => {\n this.timer = setTimeout(() => {\n this.zone.run(() => {\n this.refreshToken();\n });\n }, Number(this.token?.expires_in) * 1000);\n });\n }\n } else {\n // @ts-ignore\n delete this.authConfig.storage[storageKey];\n }\n }\n\n get token() {\n return this._token;\n }\n\n private refreshToken() {\n const {tokenPath, clientId, clientSecret, scope} = this.authConfig.config as any;\n const {refresh_token} = this.token as OAuthToken;\n if (tokenPath && refresh_token) {\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n grant_type: 'refresh_token',\n refresh_token,\n ...scope && {scope} || {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.logout();\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = {\n ...this.token,\n ...params\n };\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n }\n\n private getCleanedUnSearchParameters(): string {\n const {search} = this.location;\n let searchString = search.substr(1);\n const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n searchString = searchString.replace(re, '');\n });\n return searchString.length && `?${searchString}` || '';\n }\n\n private cleanLocationHash() {\n const {hash} = this.location;\n let curHash = hash.substr(1);\n const hashKeys = ['access_token', 'token_type', 'expires_in', 'scope', 'state', 'error', 'error_description', 'session_state', 'nonce'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n curHash = curHash.replace(re, '');\n });\n this.location.hash = curHash;\n }\n\n private emitState(parameters: Record<string, string> | null) {\n const {state} = parameters as any;\n if (state) {\n this.state$.next(state);\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {EMPTY, Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\nimport {OAuthService} from './oauth.service';\nimport {OAuthStatus} from '../models';\n\n@Injectable()\nexport class OAuthInterceptor implements HttpInterceptor {\n\n constructor(private oauthService: OAuthService) {\n }\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n if (this.oauthService) {\n if (!this.isPathExcepted(req)) {\n const {token} = this.oauthService;\n if (token && token.access_token) {\n req = req.clone({\n setHeaders: {\n Authorization: `${token.token_type} ${token.access_token}`\n }\n });\n }\n }\n return next.handle(req).pipe(\n catchError((err) => {\n if (err.status === 401) {\n this.oauthService.token = null;\n this.oauthService.status = OAuthStatus.DENIED;\n return EMPTY;\n }\n return throwError(() => new Error(err));\n })\n );\n } else {\n return next.handle(req);\n }\n }\n\n private isPathExcepted(req: HttpRequest<any>) {\n const {ignorePaths} = this.oauthService;\n if (ignorePaths) {\n for (const ignorePath of this.oauthService.ignorePaths) {\n try {\n if (req.url.match(ignorePath)) {\n return true;\n }\n } catch (err) {\n }\n }\n }\n return false;\n }\n}\n","import {\r\n Component,\r\n ContentChild,\r\n EventEmitter,\r\n HostListener,\r\n Inject,\r\n Input,\r\n OnDestroy,\r\n Output,\r\n TemplateRef,\r\n ViewEncapsulation\r\n} from '@angular/core';\r\nimport {Observable, Subscription, take} from 'rxjs';\r\nimport {LOCATION, OAuthParameters, OAuthStatus, OAuthType} from '../../models';\r\nimport {tap} from 'rxjs/operators';\r\nimport {OAuthService} from '../../services/oauth.service';\r\nimport {Location as Location2} from '@angular/common';\r\n\r\nexport interface OAuthLoginI18n {\r\n username?: string;\r\n password?: string;\r\n submit?: string;\r\n notAuthorized?: string;\r\n authorized?: string;\r\n denied?: string;\r\n}\r\n\r\n@Component({\r\n selector: 'oauth-login',\r\n templateUrl: 'oauth-login.component.html',\r\n styleUrls: ['oauth-login.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n})\r\nexport class OAuthLoginComponent implements OnDestroy {\r\n\r\n private _redirectUri: string | undefined;\r\n private subscription = new Subscription();\r\n private _i18n: OAuthLoginI18n = {\r\n username: 'Username',\r\n password: 'Password',\r\n submit: 'Sign in',\r\n notAuthorized: 'Sign in',\r\n authorized: 'Welcome',\r\n denied: 'Access Denied. Try again!'\r\n };\r\n\r\n get i18n() {\r\n return this._i18n;\r\n }\r\n\r\n @Input()\r\n set i18n(i18n) {\r\n this._i18n = {\r\n ...this._i18n,\r\n ...i18n\r\n };\r\n }\r\n\r\n @Input()\r\n set redirectUri(redirectUri: string) {\r\n if (redirectUri) {\r\n this._redirectUri = redirectUri;\r\n }\r\n }\r\n\r\n get redirectUri() {\r\n return this._redirectUri || `${this.location.origin}${this.locationService.path(true) || '/'}`;\r\n }\r\n\r\n @Input()\r\n state = '';\r\n @Output()\r\n stateChange: EventEmitter<string> = new EventEmitter();\r\n @Input()\r\n profileName$: Observable<string | undefined> | undefined;\r\n @ContentChild('login', {static: false})\r\n loginTemplate: TemplateRef<any> | undefined;\r\n username = '';\r\n password = '';\r\n profileName: string | undefined;\r\n OAuthStatus = OAuthStatus;\r\n OAuthType = OAuthType;\r\n collapse = false;\r\n type = this.oauthService.type;\r\n state$ = this.oauthService.state$.pipe(\r\n tap(s => this.stateChange.emit(s))\r\n );\r\n status$ = this.oauthService.status$.pipe(\r\n tap(s => {\r\n if (s === OAuthStatus.AUTHORIZED && this.profileName$) {\r\n this.subscription.add(this.profileName$.pipe(take(1)).subscribe(n => this.profileName = n));\r\n } else {\r\n const {token} = this.oauthService;\r\n const userInfo = token && token.id_token && JSON.parse(atob(token.id_token.split('.')[1])) || {};\r\n this.profileName = userInfo.name || userInfo.username || userInfo.email || userInfo.sub || '';\r\n }\r\n })\r\n );\r\n loginFunction = (p: OAuthParameters) => this.login(p);\r\n logoutFunction = () => this.logout();\r\n\r\n constructor(private oauthService: OAuthService,\r\n private locationService: Location2,\r\n @Inject(LOCATION) private location: Location) {\r\n }\r\n\r\n ngOnDestroy() {\r\n this.subscription.unsubscribe();\r\n }\r\n\r\n logout() {\r\n this.oauthService.logout();\r\n }\r\n\r\n async login(parameters: OAuthParameters) {\r\n await this.oauthService.login(parameters);\r\n this.collapse = false;\r\n }\r\n\r\n toggleCollapse() {\r\n this.collapse = !this.collapse;\r\n }\r\n\r\n @HostListener('window:keydown.escape')\r\n keyboardEvent() {\r\n this.collapse = false;\r\n }\r\n}\r\n","<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n {{i18n.authorized}}<strong>&nbsp;{{profileName}}</strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n","import {ModuleWithProviders, NgModule, Optional, PLATFORM_ID} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';\nimport {RouterModule} from '@angular/router';\nimport {OAuthConfig, OAUTH_CONFIG, LOCATION, SERVER_HOST, SERVER_PATH, STORAGE} from './models';\nimport {OAuthService} from './services/oauth.service';\nimport {OAuthLoginComponent} from './components/login/oauth-login.component';\nimport {CommonModule, isPlatformBrowser} from '@angular/common';\nimport {OAuthInterceptor} from './services/oauth.interceptor';\n\nconst mockLocation = (serverHost: string, serverPath: string): Location => {\n const url = new URL(serverHost && serverPath ? `${serverHost}${serverPath}` : 'http://localhost');\n const {href, origin, protocol, host, hostname, port, pathname, search, hash} = url;\n return {\n href, origin, protocol, host, hostname, port, pathname, search, hash,\n reload() {\n },\n assign(u: string) {\n },\n ancestorOrigins: {} as any,\n replace(u: string) {\n }\n };\n};\n\nconst LocationService = {\n provide: LOCATION,\n useFactory(platformId: Object, serverHost: string, serverPath: string) {\n return isPlatformBrowser(platformId) ? location : mockLocation(serverHost, serverPath);\n },\n deps: [\n PLATFORM_ID,\n [new Optional(), SERVER_HOST],\n [new Optional(), SERVER_PATH]\n ]\n};\n\nconst mockStorage: Storage = {\n clear() {\n },\n getItem(key: string) {\n return null;\n },\n key(index: number) {\n return null;\n },\n removeItem(key: string) {\n },\n setItem(key: string, value: string) {\n },\n length: 0\n};\n\nconst StorageService = {\n provide: STORAGE,\n useFactory(platformId: Object) {\n return isPlatformBrowser(platformId) ? localStorage : mockStorage;\n },\n deps: [PLATFORM_ID]\n};\n\nconst OAuthInterceptorService = {\n provide: HTTP_INTERCEPTORS,\n useClass: OAuthInterceptor,\n multi: true,\n};\n\nconst defaultConfig = (storage: Storage) => {\n return {\n storage,\n storageKey: 'token',\n ignorePaths: []\n };\n};\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n HttpClientModule,\n RouterModule,\n ],\n declarations: [OAuthLoginComponent],\n exports: [OAuthLoginComponent],\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n ]\n})\nexport class OAuthModule {\n\n static forRoot(config: OAuthConfig): ModuleWithProviders<OAuthModule> {\n return {\n ngModule: OAuthModule,\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n {\n provide: OAUTH_CONFIG,\n useFactory(storage: Storage) {\n return {\n ...defaultConfig(storage),\n ...config,\n };\n },\n deps: [\n STORAGE\n ]\n }\n ]\n };\n }\n}\n","/*\n * Public API Surface of ngx-oauth\n */\nexport * from './lib/models';\nexport * from './lib/services/oauth.service';\nexport * from './lib/services/oauth.interceptor';\nexport * from './lib/components/login/oauth-login.component';\nexport * from './lib/oauth.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAEa,WAAW,GAAG,IAAI,cAAc,CAAS,aAAa,EAAE;MACxD,WAAW,GAAG,IAAI,cAAc,CAAS,aAAa,EAAE;MACxD,QAAQ,GAAG,IAAI,cAAc,CAAW,UAAU,EAAE;MACpD,OAAO,GAAG,IAAI,cAAc,CAAU,SAAS,EAAE;MACjD,YAAY,GAAG,IAAI,cAAc,CAAc,aAAa,EAAE;MAC9D,WAAW,GAAG,IAAI,cAAc,CAAa,YAAY,EAAE;IAE5D;AAAZ,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,wCAA2B,CAAA;IAC3B,+BAAkB,CAAA;IAClB,qDAAwC,CAAA;AAC1C,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;IAiFW;AAAZ,WAAY,WAAW;IACrB,gDAAiC,CAAA;IACjC,wCAAyB,CAAA;IACzB,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW;;AC5EvB,MAAM,WAAW,GAAG,CAAC,GAAe,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE9F,MAAM,SAAS,GAAG,CAAC,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC;KACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;KACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;KACnB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAErB,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAE;IACvC,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,OAAO,SAAS,CAAC,IA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CAAC;MAkBW,WAAW;IAEtB,OAAO,OAAO,CAAC,MAAmB;QAChC,OAAO;YACL,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE;gBACT,eAAe;gBACf,cAAc;gBACd,YAAY;gBACZ,uBAAuB;gBACvB;oBACE,OAAO,EAAE,YAAY;oBACrB,UAAU,CAAC,OAAgB;wBACzB,uCACK,aAAa,CAAC,OAAO,CAAC,GACtB,MAAM,EACT;qBACH;oBACD,IAAI,EAAE;wBACJ,OAAO;qBACR;iBACF;aACF;SACF,CAAC;KACH;;wGAxBU,WAAW;yGAAX,WAAW,iBATP,mBAAmB,aALhC,YAAY;QACZ,WAAW;QACX,gBAAgB;QAChB,YAAY,aAGJ,mBAAmB;yGAQlB,WAAW,aAPX;QACT,eAAe;QACf,cAAc;QACd,YAAY;QACZ,uBAAuB;KACxB,YAbQ;YACP,YAAY;YACZ,WAAW;YACX,gBAAgB;YAChB,YAAY;SACb;2FAUU,WAAW;kBAhBvB,QAAQ;mBAAC;oBACR,OAAO,EAAE;wBACP,YAAY;wBACZ,WAAW;wBACX,gBAAgB;wBAChB,YAAY;qBACb;oBACD,YAAY,EAAE,CAAC,mBAAmB,CAAC;oBACnC,OAAO,EAAE,CAAC,mBAAmB,CAAC;oBAC9B,SAAS,EAAE;wBACT,eAAe;wBACf,cAAc;wBACd,YAAY;wBACZ,uBAAuB;qBACxB;iBACF;;;AC1FD;;;;ACAA;;;;;;"}
1
+ {"version":3,"file":"ngx-oauth.mjs","sources":["../../../projects/ngx-oauth/src/lib/models/index.ts","../../../projects/ngx-oauth/src/lib/services/oauth.service.ts","../../../projects/ngx-oauth/src/lib/services/oauth.interceptor.ts","../../../projects/ngx-oauth/src/lib/components/login/oauth-login.component.ts","../../../projects/ngx-oauth/src/lib/components/login/oauth-login.component.html","../../../projects/ngx-oauth/src/lib/oauth.module.ts","../../../projects/ngx-oauth/src/index.ts","../../../projects/ngx-oauth/src/ngx-oauth.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\n\nexport const SERVER_HOST = new InjectionToken<string>('SERVER_HOST');\nexport const SERVER_PATH = new InjectionToken<string>('SERVER_PATH');\nexport const LOCATION = new InjectionToken<Location>('Location');\nexport const STORAGE = new InjectionToken<Storage>('Storage');\nexport const OAUTH_CONFIG = new InjectionToken<OAuthConfig>('OAuthConfig');\nexport const OAUTH_TOKEN = new InjectionToken<OAuthToken>('OAuthToken');\n\nexport enum OAuthType {\n RESOURCE = 'password',\n AUTHORIZATION_CODE = 'code',\n IMPLICIT = 'token',\n CLIENT_CREDENTIAL = 'client_credentials'\n}\n\nexport interface OAuthConfig {\n type: OAuthType;\n config: OAuthTypeConfig;\n storageKey?: string;\n storage?: Storage;\n ignorePaths?: RegExp[];\n}\n\nexport interface ClientCredentialConfig {\n tokenPath: string;\n revokePath?: string;\n clientId: string;\n clientSecret?: string;\n scope?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface ResourceConfig extends ClientCredentialConfig {\n}\n\nexport interface ImplicitConfig {\n authorizePath: string;\n revokePath?: string;\n clientId: string;\n scope?: string;\n logoutPath?: string;\n logoutRedirectUri?: string;\n}\n\nexport interface AuthorizationCodeConfig extends ResourceConfig {\n authorizePath: string;\n}\n\nexport interface AuthorizationCodePKCEConfig extends AuthorizationCodeConfig {\n pkce: boolean;\n}\n\nexport interface OpenIdConfig {\n issuerPath: string;\n clientId: string;\n clientSecret?: string;\n scope?: string;\n}\n\nexport interface ResourceParameters {\n username: string;\n password: string;\n}\n\nexport interface ImplicitParameters {\n redirectUri: string;\n state?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface AuthorizationCodeParameters extends ImplicitParameters {\n}\n\nexport type OAuthParameters = ResourceParameters | AuthorizationCodeParameters | ImplicitParameters;\nexport type OAuthTypeConfig = OpenIdConfig\n | AuthorizationCodePKCEConfig\n | AuthorizationCodeConfig\n | ImplicitConfig\n | ResourceConfig\n | ClientCredentialConfig;\n\nexport interface OAuthToken {\n id_token?: string;\n access_token?: string;\n refresh_token?: string;\n token_type?: string;\n state?: string;\n error?: string;\n error_description?: string;\n expires_in?: number | string;\n refresh_expires_in?: number;\n scope?: string;\n codeVerifier?: string;\n nonce?: string;\n}\n\nexport enum OAuthStatus {\n NOT_AUTHORIZED = 'NOT_AUTHORIZED',\n AUTHORIZED = 'AUTHORIZED',\n DENIED = 'DENIED'\n}\n\nexport interface OpenIdConfiguration {\n issuer?: string;\n authorization_endpoint?: string;\n introspection_endpoint?: string;\n token_endpoint?: string;\n userinfo_endpoint?: string;\n end_session_endpoint?: string;\n revocation_endpoint?: string;\n scopes_supported?: string[];\n code_challenge_methods_supported?: string[];\n}\n\nexport interface UserInfo {\n email?: string;\n email_verified?: boolean;\n family_name?: string;\n given_name?: string;\n name?: string;\n preferred_username?: string;\n sub?: string;\n address?: object;\n picture?: string;\n locale?: string;\n}\n\nexport interface IntrospectInfo extends UserInfo {\n active: boolean;\n scope: string;\n client_id?: string;\n username: string;\n exp: number;\n}\n","import {Inject, Injectable, NgZone} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';\nimport {catchError, concatMap, delay, filter, map, shareReplay, switchMap, tap} from 'rxjs/operators';\nimport {EMPTY, from, noop, Observable, of, ReplaySubject} from 'rxjs';\nimport {\n AuthorizationCodeParameters,\n ImplicitParameters,\n LOCATION,\n OAUTH_CONFIG,\n OAuthConfig,\n OAuthParameters,\n OAuthStatus,\n OAuthToken,\n OAuthType,\n OAuthTypeConfig, OpenIdConfig, OpenIdConfiguration,\n ResourceParameters, UserInfo\n} from '../models';\nimport {Location as Location2} from '@angular/common';\n\nconst arrToString = (buf: Uint8Array) => buf.reduce((s, b) => s + String.fromCharCode(b), '');\n\nconst base64url = (str: string) => btoa(str)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n\nconst randomString = (length: number = 48) => {\n const buff = arrToString(crypto.getRandomValues(new Uint8Array(length * 2)));\n return base64url(buff).substring(0, length);\n};\n\nconst pkce = async (value: string) => {\n const buff = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));\n return base64url(arrToString(new Uint8Array(buff)));\n};\n\nconst REQUEST_HEADER = new HttpHeaders({'Content-Type': 'application/x-www-form-urlencoded'});\n\nconst parseOauthUri = (hash: string): Record<string, string> | null => {\n const regex = /([^&=]+)=([^&]*)/g;\n const params: Record<string, string> = {};\n let m;\n // tslint:disable-next-line:no-conditional-assignment\n while ((m = regex.exec(hash)) !== null) {\n params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);\n }\n if (Object.keys(params).length) {\n return params;\n }\n return null;\n};\n\nconst jwt = (token: string) => JSON.parse(atob(token.split('.')[1]));\n\n@Injectable()\nexport class OAuthService {\n\n private _token: OAuthToken | null = null;\n private _status = OAuthStatus.NOT_AUTHORIZED;\n private timer: any;\n state$: ReplaySubject<string> = new ReplaySubject(1);\n status$: ReplaySubject<OAuthStatus> = new ReplaySubject(1);\n userInfo$: Observable<UserInfo> = this.status$.pipe(\n filter(s => s === OAuthStatus.AUTHORIZED),\n map(() => {\n const {config} = this.authConfig as any;\n return config.userPath;\n }),\n filter(p => !!p),\n switchMap(path => this.http.get<UserInfo>(path)),\n shareReplay()\n );\n\n constructor(private http: HttpClient,\n private zone: NgZone,\n @Inject(OAUTH_CONFIG) private authConfig: OAuthConfig,\n @Inject(LOCATION) private location: Location,\n private locationService: Location2) {\n setTimeout(() => this.init()); // decouple for http interceptor\n }\n\n /**\n * Get the oauth config for initialize. If OpenId with issuerPath is configured then configure from server openid configuration.\n * @protected\n */\n protected get config$() {\n let {config} = this.authConfig;\n if (config && config.clientId) {\n const {issuerPath, scope} = config as OpenIdConfig;\n if (issuerPath) {\n return this.http.get<OpenIdConfiguration>(`${issuerPath}/.well-known/openid-configuration`).pipe(\n tap(v => this.set(this.type, {\n ...v.authorization_endpoint && {authorizePath: v.authorization_endpoint} || {},\n ...v.token_endpoint && {tokenPath: v.token_endpoint} || {},\n ...v.revocation_endpoint && {revokePath: v.revocation_endpoint} || {},\n ...v.code_challenge_methods_supported && {pkce: v.code_challenge_methods_supported.indexOf('S256') > -1} || {},\n ...v.userinfo_endpoint && {userPath: v.userinfo_endpoint} || {},\n ...v.introspection_endpoint && {introspectionPath: v.introspection_endpoint} || {},\n ...v.end_session_endpoint && {logoutPath: v.end_session_endpoint} || {},\n ...scope && {} || {scope: 'openid'}\n } as any)),\n map(() => this.authConfig.config)\n );\n }\n return of(config);\n }\n console.warn('clientId is missing in oauth config');\n return EMPTY;\n }\n\n /**\n * Init. Will check the url implicit or authorization flow or existing saved token.\n * @protected\n */\n protected init(): void {\n const {hash, search, origin, pathname} = this.location;\n const isImplicitRedirect = hash && /(access_token=)|(error=)/.test(hash);\n const isAuthCodeRedirect = search && /(code=)|(error=)/.test(search);\n const {storageKey} = this.authConfig;\n const savedToken = storageKey && this.authConfig.storage && this.authConfig.storage[storageKey] &&\n JSON.parse(this.authConfig.storage[storageKey]);\n this.config$.subscribe(config => {\n if (isImplicitRedirect) {\n const parameters = parseOauthUri(hash.substr(1));\n this.token = parameters;\n this.status = this.checkResponse(savedToken, parameters) && OAuthStatus.AUTHORIZED || OAuthStatus.DENIED;\n } else if (isAuthCodeRedirect) {\n const parameters = parseOauthUri(search.substr(1));\n if (!this.checkResponse(savedToken, parameters)) {\n this.token = parameters;\n this.status = OAuthStatus.DENIED;\n } else {\n const newParametersString = this.getCleanedUnSearchParameters();\n const {clientId, clientSecret, tokenPath, scope} = config as any;\n const codeVerifier = savedToken && savedToken.codeVerifier;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n code: parameters?.code,\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n redirect_uri: `${origin}${pathname}`,\n grant_type: 'authorization_code',\n ...scope && {scope} || {},\n ...codeVerifier && {code_verifier: codeVerifier} || {}\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError((err) => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n this.locationService.replaceState(`${pathname}${newParametersString}`);\n return EMPTY;\n })\n ).subscribe(token => {\n this.token = token;\n this.status = OAuthStatus.AUTHORIZED;\n this.locationService.replaceState(`${pathname}${newParametersString}`);\n });\n }\n } else if (savedToken) {\n this._token = savedToken;\n const {access_token, refresh_token, error} = savedToken;\n if (access_token) {\n if (refresh_token) { // force refresh since might be a manual page refresh\n this.refreshToken();\n } else {\n this.status = OAuthStatus.AUTHORIZED;\n }\n } else {\n this.status = error && OAuthStatus.DENIED || OAuthStatus.NOT_AUTHORIZED;\n }\n } else {\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n });\n }\n\n async login(parameters?: OAuthParameters) {\n if (this.isResourceType(parameters as ResourceParameters)) {\n this.resourceLogin(parameters as ResourceParameters);\n } else if (this.isAuthorizationCodeType(parameters as AuthorizationCodeParameters)) {\n await this.authorizationCodeLogin(parameters as AuthorizationCodeParameters);\n } else if (this.isImplicitType(parameters as ImplicitParameters)) {\n await this.implicitLogin(parameters as ImplicitParameters);\n } else if (this.isClientCredentialType()) {\n this.clientCredentialLogin();\n }\n }\n\n logout(useLogoutUrl?: boolean) {\n this.revoke();\n this.token = null;\n this.status = OAuthStatus.NOT_AUTHORIZED;\n const {logoutPath, logoutRedirectUri} = this.authConfig.config as any;\n if (useLogoutUrl && logoutPath) {\n const {origin, pathname} = this.location;\n const currentPath = `${origin}${pathname}`;\n this.location.replace(`${logoutPath}?post_logout_redirect_uri=${logoutRedirectUri || currentPath}`);\n }\n }\n\n revoke() {\n const {revokePath, clientId, clientSecret} = this.authConfig.config as any;\n if (revokePath) {\n const {access_token, refresh_token} = this.token as OAuthToken;\n const toRevoke = [];\n if (access_token) {\n toRevoke.push({\n ...clientId && {client_id: clientId} || {},\n ...clientSecret && {client_secret: clientSecret} || {},\n token: access_token,\n token_type_hint: 'access_token'\n });\n }\n if (refresh_token) {\n toRevoke.push({\n ...clientId && {client_id: clientId} || {},\n ...clientSecret && {client_secret: clientSecret} || {},\n token: refresh_token,\n token_type_hint: 'refresh_token'\n });\n }\n from(toRevoke).pipe(\n concatMap(o => of(o).pipe(delay(300))), // space request to avoid cancellation\n switchMap(o => this.http.post(revokePath, new HttpParams({fromObject: o}))),\n ).subscribe(noop);\n }\n }\n\n get status(): OAuthStatus {\n return this._status;\n }\n\n set status(status) {\n this._status = status;\n this.status$.next(status);\n }\n\n set(type: OAuthType, config?: OAuthTypeConfig): void {\n this.authConfig.type = type;\n if (config) {\n this.authConfig.config = {\n ...this.authConfig.config,\n ...config\n };\n }\n }\n\n get type(): OAuthType {\n return this.authConfig.type;\n }\n\n get ignorePaths(): RegExp[] {\n return this.authConfig.ignorePaths || [];\n }\n\n private resourceLogin(parameters: ResourceParameters) {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n const {username, password} = parameters;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n grant_type: OAuthType.RESOURCE,\n ...scope && {scope} || {},\n username,\n password\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(err => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private async authorizationCodeLogin(parameters: AuthorizationCodeParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.AUTHORIZATION_CODE);\n this.location.replace(authUrl);\n }\n\n private async implicitLogin(parameters: ImplicitParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.IMPLICIT);\n this.location.replace(authUrl);\n }\n\n private clientCredentialLogin() {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n client_secret: clientSecret,\n grant_type: OAuthType.CLIENT_CREDENTIAL,\n ...scope ? {scope} : {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError((err) => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private isClientCredentialType(): boolean {\n return this.authConfig.type === OAuthType.CLIENT_CREDENTIAL;\n }\n\n private isResourceType(parameters?: ResourceParameters): boolean {\n return this.authConfig.type === OAuthType.RESOURCE && !!parameters?.password;\n }\n\n private isImplicitType(parameters?: ImplicitParameters): boolean {\n return this.authConfig.type === OAuthType.IMPLICIT && !!parameters?.redirectUri;\n }\n\n private isAuthorizationCodeType(parameters?: AuthorizationCodeParameters): boolean {\n return this.authConfig.type === OAuthType.AUTHORIZATION_CODE && !!parameters?.redirectUri;\n }\n\n private async toAuthorizationUrl(parameters: AuthorizationCodeParameters | ImplicitParameters, responseType: OAuthType): Promise<string> {\n const {config} = this.authConfig as any;\n let authorizationUrl = `${config.authorizePath}`;\n authorizationUrl += config.authorizePath.includes('?') && '&' || '?';\n authorizationUrl += `client_id=${config.clientId}`;\n authorizationUrl += `&redirect_uri=${encodeURIComponent(parameters.redirectUri)}`;\n authorizationUrl += `&response_type=${responseType}`;\n authorizationUrl += `&scope=${encodeURIComponent(config.scope || '')}`;\n authorizationUrl += `&state=${encodeURIComponent(parameters.state || '')}`;\n return `${authorizationUrl}${this.generateNonce(config)}${await this.generateCodeChallenge(config)}`;\n }\n\n private async generateCodeChallenge(config: any) {\n if (config.pkce) {\n const codeVerifier = randomString();\n this.token = {...this.token, codeVerifier};\n return `&code_challenge=${await pkce(codeVerifier)}&code_challenge_method=S256`;\n }\n return '';\n }\n\n private generateNonce(config: any) {\n if (config && config.scope && config.scope.indexOf('openid') > -1) {\n const nonce = randomString(10);\n this.token = {...this.token, nonce};\n return `&nonce=${nonce}`;\n }\n return '';\n }\n\n private checkResponse(token: any, parameters: Record<string, string> | null) {\n this.emitState(parameters);\n this.cleanLocationHash();\n if (!parameters || parameters.error) {\n return false;\n }\n if (token && token.nonce && parameters.access_token) {\n const jwtToken = jwt(parameters.access_token);\n return token.nonce === jwtToken.nonce;\n }\n return parameters.access_token || parameters.code;\n }\n\n set token(token: OAuthToken | null) {\n this._token = token;\n const {storageKey} = this.authConfig;\n if (token) {\n // @ts-ignore\n this.authConfig.storage[storageKey] = JSON.stringify(this.token);\n clearTimeout(this.timer);\n if (this.token && this.token.expires_in) {\n this.zone.runOutsideAngular(() => {\n this.timer = setTimeout(() => {\n this.zone.run(() => {\n this.refreshToken();\n });\n }, Number(this.token?.expires_in) * 1000);\n });\n }\n } else {\n // @ts-ignore\n delete this.authConfig.storage[storageKey];\n }\n }\n\n get token() {\n return this._token;\n }\n\n private refreshToken() {\n const {tokenPath, clientId, clientSecret, scope} = this.authConfig.config as any;\n const {refresh_token} = this.token as OAuthToken;\n if (tokenPath && refresh_token) {\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n grant_type: 'refresh_token',\n refresh_token,\n ...scope && {scope} || {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.logout();\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = {\n ...this.token,\n ...params\n };\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n }\n\n private getCleanedUnSearchParameters(): string {\n const {search} = this.location;\n let searchString = search.substr(1);\n const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state', 'scope', 'authuser', 'prompt'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n searchString = searchString.replace(re, '');\n });\n return searchString.length && `?${searchString}` || '';\n }\n\n private cleanLocationHash() {\n const {hash} = this.location;\n let curHash = hash.substr(1);\n const hashKeys = ['access_token', 'token_type', 'expires_in', 'scope', 'state', 'error', 'error_description', 'session_state', 'nonce'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n curHash = curHash.replace(re, '');\n });\n this.location.hash = curHash;\n }\n\n private emitState(parameters: Record<string, string> | null) {\n const {state} = parameters as any;\n if (state) {\n this.state$.next(state);\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {EMPTY, Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\nimport {OAuthService} from './oauth.service';\nimport {OAuthStatus} from '../models';\n\n@Injectable()\nexport class OAuthInterceptor implements HttpInterceptor {\n\n constructor(private oauthService: OAuthService) {\n }\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n if (this.oauthService) {\n if (!this.isPathExcepted(req)) {\n const {token} = this.oauthService;\n if (token && token.access_token) {\n req = req.clone({\n setHeaders: {\n Authorization: `${token.token_type} ${token.access_token}`\n }\n });\n }\n }\n return next.handle(req).pipe(\n catchError((err) => {\n if (err.status === 401) {\n this.oauthService.token = null;\n this.oauthService.status = OAuthStatus.DENIED;\n if (!this.isPathExcepted(req)) {\n return EMPTY;\n }\n }\n return throwError(err);\n })\n );\n } else {\n return next.handle(req);\n }\n }\n\n private isPathExcepted(req: HttpRequest<any>) {\n const {ignorePaths} = this.oauthService;\n if (ignorePaths) {\n for (const ignorePath of this.oauthService.ignorePaths) {\n try {\n if (req.url.match(ignorePath)) {\n return true;\n }\n } catch (err) {\n }\n }\n }\n return false;\n }\n}\n","import {\r\n Component,\r\n ContentChild,\r\n EventEmitter,\r\n HostListener,\r\n Inject,\r\n Input,\r\n OnDestroy,\r\n Output,\r\n TemplateRef,\r\n ViewEncapsulation\r\n} from '@angular/core';\r\nimport {Observable, Subscription, take} from 'rxjs';\r\nimport {LOCATION, OAuthParameters, OAuthStatus, OAuthType} from '../../models';\r\nimport {tap} from 'rxjs/operators';\r\nimport {OAuthService} from '../../services/oauth.service';\r\nimport {Location as Location2} from '@angular/common';\r\n\r\nexport interface OAuthLoginI18n {\r\n username?: string;\r\n password?: string;\r\n submit?: string;\r\n notAuthorized?: string;\r\n authorized?: string;\r\n denied?: string;\r\n}\r\n\r\n@Component({\r\n selector: 'oauth-login',\r\n templateUrl: 'oauth-login.component.html',\r\n styleUrls: ['oauth-login.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n})\r\nexport class OAuthLoginComponent implements OnDestroy {\r\n\r\n private _redirectUri: string | undefined;\r\n private subscription = new Subscription();\r\n private _i18n: OAuthLoginI18n = {\r\n username: 'Username',\r\n password: 'Password',\r\n submit: 'Sign in',\r\n notAuthorized: 'Sign in',\r\n authorized: 'Welcome',\r\n denied: 'Access Denied. Try again!'\r\n };\r\n\r\n get i18n() {\r\n return this._i18n;\r\n }\r\n\r\n @Input()\r\n set i18n(i18n) {\r\n this._i18n = {\r\n ...this._i18n,\r\n ...i18n\r\n };\r\n }\r\n\r\n @Input()\r\n set redirectUri(redirectUri: string) {\r\n if (redirectUri) {\r\n this._redirectUri = redirectUri;\r\n }\r\n }\r\n\r\n get redirectUri() {\r\n return this._redirectUri || `${this.location.origin}${this.locationService.path(true) || '/'}`;\r\n }\r\n\r\n @Input()\r\n useLogoutUrl = false;\r\n @Input()\r\n state = '';\r\n @Output()\r\n stateChange: EventEmitter<string> = new EventEmitter();\r\n @Input()\r\n profileName$: Observable<string | undefined> | undefined;\r\n @ContentChild('login', {static: false})\r\n loginTemplate: TemplateRef<any> | undefined;\r\n username = '';\r\n password = '';\r\n profileName: string | undefined;\r\n OAuthStatus = OAuthStatus;\r\n OAuthType = OAuthType;\r\n collapse = false;\r\n type = this.oauthService.type;\r\n state$ = this.oauthService.state$.pipe(\r\n tap(s => this.stateChange.emit(s))\r\n );\r\n status$ = this.oauthService.status$.pipe(\r\n tap(s => {\r\n if (s === OAuthStatus.AUTHORIZED && this.profileName$) {\r\n this.subscription.add(this.profileName$.pipe(take(1)).subscribe(n => this.profileName = n));\r\n } else {\r\n const {token} = this.oauthService;\r\n const userInfo = token && token.id_token && JSON.parse(atob(token.id_token.split('.')[1])) || {};\r\n this.profileName = userInfo.name || userInfo.username || userInfo.email || userInfo.sub || '';\r\n }\r\n })\r\n );\r\n loginFunction = (p: OAuthParameters) => this.login(p);\r\n logoutFunction = () => this.logout();\r\n\r\n constructor(private oauthService: OAuthService,\r\n private locationService: Location2,\r\n @Inject(LOCATION) private location: Location) {\r\n }\r\n\r\n ngOnDestroy() {\r\n this.subscription.unsubscribe();\r\n }\r\n\r\n logout() {\r\n this.oauthService.logout(this.useLogoutUrl);\r\n }\r\n\r\n async login(parameters: OAuthParameters) {\r\n await this.oauthService.login(parameters);\r\n this.collapse = false;\r\n }\r\n\r\n toggleCollapse() {\r\n this.collapse = !this.collapse;\r\n }\r\n\r\n @HostListener('window:keydown.escape')\r\n keyboardEvent() {\r\n this.collapse = false;\r\n }\r\n}\r\n","<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\" class=\"not-authorized\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\" class=\"authorized\">\r\n <span class=\"welcome\">{{i18n.authorized}}&nbsp;</span>\r\n <strong class=\"profile-name\" [innerHTML]=\"profileName\"></strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\" class=\"denied\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n","import {ModuleWithProviders, NgModule, Optional, PLATFORM_ID} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';\nimport {RouterModule} from '@angular/router';\nimport {OAuthConfig, OAUTH_CONFIG, LOCATION, SERVER_HOST, SERVER_PATH, STORAGE} from './models';\nimport {OAuthService} from './services/oauth.service';\nimport {OAuthLoginComponent} from './components/login/oauth-login.component';\nimport {CommonModule, isPlatformBrowser} from '@angular/common';\nimport {OAuthInterceptor} from './services/oauth.interceptor';\n\nconst mockLocation = (serverHost: string, serverPath: string): Location => {\n const url = new URL(serverHost && serverPath ? `${serverHost}${serverPath}` : 'http://localhost');\n const {href, origin, protocol, host, hostname, port, pathname, search, hash} = url;\n return {\n href, origin, protocol, host, hostname, port, pathname, search, hash,\n reload() {\n },\n assign(u: string) {\n },\n ancestorOrigins: {} as any,\n replace(u: string) {\n }\n };\n};\n\nconst LocationService = {\n provide: LOCATION,\n useFactory(platformId: Object, serverHost: string, serverPath: string) {\n return isPlatformBrowser(platformId) ? location : mockLocation(serverHost, serverPath);\n },\n deps: [\n PLATFORM_ID,\n [new Optional(), SERVER_HOST],\n [new Optional(), SERVER_PATH]\n ]\n};\n\nconst mockStorage: Storage = {\n clear() {\n },\n getItem(key: string) {\n return null;\n },\n key(index: number) {\n return null;\n },\n removeItem(key: string) {\n },\n setItem(key: string, value: string) {\n },\n length: 0\n};\n\nconst StorageService = {\n provide: STORAGE,\n useFactory(platformId: Object) {\n return isPlatformBrowser(platformId) ? localStorage : mockStorage;\n },\n deps: [PLATFORM_ID]\n};\n\nconst OAuthInterceptorService = {\n provide: HTTP_INTERCEPTORS,\n useClass: OAuthInterceptor,\n multi: true,\n};\n\nconst defaultConfig = (storage: Storage) => {\n return {\n storage,\n storageKey: 'token',\n ignorePaths: []\n };\n};\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n HttpClientModule,\n RouterModule,\n ],\n declarations: [OAuthLoginComponent],\n exports: [OAuthLoginComponent],\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n ]\n})\nexport class OAuthModule {\n\n static forRoot(config: OAuthConfig): ModuleWithProviders<OAuthModule> {\n return {\n ngModule: OAuthModule,\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n {\n provide: OAUTH_CONFIG,\n useFactory(storage: Storage) {\n return {\n ...defaultConfig(storage),\n ...config,\n };\n },\n deps: [\n STORAGE\n ]\n }\n ]\n };\n }\n}\n","/*\n * Public API Surface of ngx-oauth\n */\nexport * from './lib/models';\nexport * from './lib/services/oauth.service';\nexport * from './lib/services/oauth.interceptor';\nexport * from './lib/components/login/oauth-login.component';\nexport * from './lib/oauth.module';\n","/**\n * Generated b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BACZ,WAAW;wBACX,gBAAgB;wBAChB,YAAY;qBACb;oBACD,YAAY,EAAE,CAAC,mBAAmB,CAAC;oBACnC,OAAO,EAAE,CAAC,mBAAmB,CAAC;oBAC9B,SAAS,EAAE;wBACT,eAAe;wBACf,cAAc;wBACd,YAAY;wBACZ,uBAAuB;qBACxB;iBACF;;;AC1FD;;;;ACAA;;;;;;"}
@@ -91,6 +91,7 @@ class OAuthService {
91
91
  ...v.code_challenge_methods_supported && { pkce: v.code_challenge_methods_supported.indexOf('S256') > -1 } || {},
92
92
  ...v.userinfo_endpoint && { userPath: v.userinfo_endpoint } || {},
93
93
  ...v.introspection_endpoint && { introspectionPath: v.introspection_endpoint } || {},
94
+ ...v.end_session_endpoint && { logoutPath: v.end_session_endpoint } || {},
94
95
  ...scope && {} || { scope: 'openid' }
95
96
  })), map(() => this.authConfig.config));
96
97
  }
@@ -131,7 +132,7 @@ class OAuthService {
131
132
  code: parameters?.code,
132
133
  client_id: clientId,
133
134
  ...clientSecret && { client_secret: clientSecret } || {},
134
- redirect_uri: `${origin}${pathname}${newParametersString}`,
135
+ redirect_uri: `${origin}${pathname}`,
135
136
  grant_type: 'authorization_code',
136
137
  ...scope && { scope } || {},
137
138
  ...codeVerifier && { code_verifier: codeVerifier } || {}
@@ -182,10 +183,16 @@ class OAuthService {
182
183
  this.clientCredentialLogin();
183
184
  }
184
185
  }
185
- logout() {
186
+ logout(useLogoutUrl) {
186
187
  this.revoke();
187
188
  this.token = null;
188
189
  this.status = OAuthStatus.NOT_AUTHORIZED;
190
+ const { logoutPath, logoutRedirectUri } = this.authConfig.config;
191
+ if (useLogoutUrl && logoutPath) {
192
+ const { origin, pathname } = this.location;
193
+ const currentPath = `${origin}${pathname}`;
194
+ this.location.replace(`${logoutPath}?post_logout_redirect_uri=${logoutRedirectUri || currentPath}`);
195
+ }
189
196
  }
190
197
  revoke() {
191
198
  const { revokePath, clientId, clientSecret } = this.authConfig.config;
@@ -272,8 +279,8 @@ class OAuthService {
272
279
  grant_type: OAuthType.CLIENT_CREDENTIAL,
273
280
  ...scope ? { scope } : {},
274
281
  }
275
- }), { headers: REQUEST_HEADER }).pipe(catchError(() => {
276
- this.token = null;
282
+ }), { headers: REQUEST_HEADER }).pipe(catchError((err) => {
283
+ this.token = err;
277
284
  this.status = OAuthStatus.DENIED;
278
285
  return EMPTY;
279
286
  })).subscribe(params => {
@@ -384,7 +391,7 @@ class OAuthService {
384
391
  getCleanedUnSearchParameters() {
385
392
  const { search } = this.location;
386
393
  let searchString = search.substr(1);
387
- const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state'];
394
+ const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state', 'scope', 'authuser', 'prompt'];
388
395
  hashKeys.forEach((hashKey) => {
389
396
  const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');
390
397
  searchString = searchString.replace(re, '');
@@ -408,9 +415,9 @@ class OAuthService {
408
415
  }
409
416
  }
410
417
  }
411
- OAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthService, deps: [{ token: i1.HttpClient }, { token: i0.NgZone }, { token: OAUTH_CONFIG }, { token: LOCATION }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
412
- OAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthService });
413
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthService, decorators: [{
418
+ OAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthService, deps: [{ token: i1.HttpClient }, { token: i0.NgZone }, { token: OAUTH_CONFIG }, { token: LOCATION }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
419
+ OAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthService });
420
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthService, decorators: [{
414
421
  type: Injectable
415
422
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i0.NgZone }, { type: undefined, decorators: [{
416
423
  type: Inject,
@@ -440,9 +447,11 @@ class OAuthInterceptor {
440
447
  if (err.status === 401) {
441
448
  this.oauthService.token = null;
442
449
  this.oauthService.status = OAuthStatus.DENIED;
443
- return EMPTY;
450
+ if (!this.isPathExcepted(req)) {
451
+ return EMPTY;
452
+ }
444
453
  }
445
- return throwError(() => new Error(err));
454
+ return throwError(err);
446
455
  }));
447
456
  }
448
457
  else {
@@ -465,9 +474,9 @@ class OAuthInterceptor {
465
474
  return false;
466
475
  }
467
476
  }
468
- OAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthInterceptor, deps: [{ token: OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
469
- OAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthInterceptor });
470
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthInterceptor, decorators: [{
477
+ OAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthInterceptor, deps: [{ token: OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
478
+ OAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthInterceptor });
479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthInterceptor, decorators: [{
471
480
  type: Injectable
472
481
  }], ctorParameters: function () { return [{ type: OAuthService }]; } });
473
482
 
@@ -485,6 +494,7 @@ class OAuthLoginComponent {
485
494
  authorized: 'Welcome',
486
495
  denied: 'Access Denied. Try again!'
487
496
  };
497
+ this.useLogoutUrl = false;
488
498
  this.state = '';
489
499
  this.stateChange = new EventEmitter();
490
500
  this.username = '';
@@ -528,7 +538,7 @@ class OAuthLoginComponent {
528
538
  this.subscription.unsubscribe();
529
539
  }
530
540
  logout() {
531
- this.oauthService.logout();
541
+ this.oauthService.logout(this.useLogoutUrl);
532
542
  }
533
543
  async login(parameters) {
534
544
  await this.oauthService.login(parameters);
@@ -541,11 +551,11 @@ class OAuthLoginComponent {
541
551
  this.collapse = false;
542
552
  }
543
553
  }
544
- OAuthLoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthLoginComponent, deps: [{ token: OAuthService }, { token: i2.Location }, { token: LOCATION }], target: i0.ɵɵFactoryTarget.Component });
545
- OAuthLoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: OAuthLoginComponent, selector: "oauth-login", inputs: { i18n: "i18n", redirectUri: "redirectUri", state: "state", profileName$: "profileName$" }, outputs: { stateChange: "stateChange" }, host: { listeners: { "window:keydown.escape": "keyboardEvent()" } }, queries: [{ propertyName: "loginTemplate", first: true, predicate: ["login"], descendants: true }], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n {{i18n.authorized}}<strong>&nbsp;{{profileName}}</strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n", styles: [".oauth .dropdown-menu{left:auto;right:0;box-shadow:0 5px 10px #0003;min-width:250px}.oauth .dropdown-menu:before{content:\"\";display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:#0003;position:absolute;top:-7px;left:auto;right:15px}.oauth .dropdown-menu:after{content:\"\";display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #ffffff;position:absolute;top:-6px;left:auto;right:16px}\n"], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "async": i2.AsyncPipe }, encapsulation: i0.ViewEncapsulation.None });
546
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthLoginComponent, decorators: [{
554
+ OAuthLoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthLoginComponent, deps: [{ token: OAuthService }, { token: i2.Location }, { token: LOCATION }], target: i0.ɵɵFactoryTarget.Component });
555
+ OAuthLoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: OAuthLoginComponent, selector: "oauth-login", inputs: { i18n: "i18n", redirectUri: "redirectUri", useLogoutUrl: "useLogoutUrl", state: "state", profileName$: "profileName$" }, outputs: { stateChange: "stateChange" }, host: { listeners: { "window:keydown.escape": "keyboardEvent()" } }, queries: [{ propertyName: "loginTemplate", first: true, predicate: ["login"], descendants: true }], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\" class=\"not-authorized\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\" class=\"authorized\">\r\n <span class=\"welcome\">{{i18n.authorized}}&nbsp;</span>\r\n <strong class=\"profile-name\" [innerHTML]=\"profileName\"></strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\" class=\"denied\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n", styles: [".oauth .dropdown-menu{left:auto;right:0;box-shadow:0 5px 10px #0003;min-width:250px}.oauth .dropdown-menu:before{content:\"\";display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:#0003;position:absolute;top:-7px;left:auto;right:15px}.oauth .dropdown-menu:after{content:\"\";display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #ffffff;position:absolute;top:-6px;left:auto;right:16px}\n"], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], pipes: { "async": i2.AsyncPipe }, encapsulation: i0.ViewEncapsulation.None });
556
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthLoginComponent, decorators: [{
547
557
  type: Component,
548
- args: [{ selector: 'oauth-login', encapsulation: ViewEncapsulation.None, template: "<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n {{i18n.authorized}}<strong>&nbsp;{{profileName}}</strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n", styles: [".oauth .dropdown-menu{left:auto;right:0;box-shadow:0 5px 10px #0003;min-width:250px}.oauth .dropdown-menu:before{content:\"\";display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:#0003;position:absolute;top:-7px;left:auto;right:15px}.oauth .dropdown-menu:after{content:\"\";display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #ffffff;position:absolute;top:-6px;left:auto;right:16px}\n"] }]
558
+ args: [{ selector: 'oauth-login', encapsulation: ViewEncapsulation.None, template: "<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\" class=\"not-authorized\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\" class=\"authorized\">\r\n <span class=\"welcome\">{{i18n.authorized}}&nbsp;</span>\r\n <strong class=\"profile-name\" [innerHTML]=\"profileName\"></strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\" class=\"denied\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n", styles: [".oauth .dropdown-menu{left:auto;right:0;box-shadow:0 5px 10px #0003;min-width:250px}.oauth .dropdown-menu:before{content:\"\";display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:#0003;position:absolute;top:-7px;left:auto;right:15px}.oauth .dropdown-menu:after{content:\"\";display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #ffffff;position:absolute;top:-6px;left:auto;right:16px}\n"] }]
549
559
  }], ctorParameters: function () { return [{ type: OAuthService }, { type: i2.Location }, { type: Location, decorators: [{
550
560
  type: Inject,
551
561
  args: [LOCATION]
@@ -553,6 +563,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
553
563
  type: Input
554
564
  }], redirectUri: [{
555
565
  type: Input
566
+ }], useLogoutUrl: [{
567
+ type: Input
556
568
  }], state: [{
557
569
  type: Input
558
570
  }], stateChange: [{
@@ -651,12 +663,12 @@ class OAuthModule {
651
663
  };
652
664
  }
653
665
  }
654
- OAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
655
- OAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthModule, declarations: [OAuthLoginComponent], imports: [CommonModule,
666
+ OAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
667
+ OAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthModule, declarations: [OAuthLoginComponent], imports: [CommonModule,
656
668
  FormsModule,
657
669
  HttpClientModule,
658
670
  RouterModule], exports: [OAuthLoginComponent] });
659
- OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthModule, providers: [
671
+ OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthModule, providers: [
660
672
  LocationService,
661
673
  StorageService,
662
674
  OAuthService,
@@ -667,7 +679,7 @@ OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "1
667
679
  HttpClientModule,
668
680
  RouterModule,
669
681
  ]] });
670
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: OAuthModule, decorators: [{
682
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthModule, decorators: [{
671
683
  type: NgModule,
672
684
  args: [{
673
685
  imports: [
@@ -696,3 +708,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
696
708
  */
697
709
 
698
710
  export { LOCATION, OAUTH_CONFIG, OAUTH_TOKEN, OAuthInterceptor, OAuthLoginComponent, OAuthModule, OAuthService, OAuthStatus, OAuthType, SERVER_HOST, SERVER_PATH, STORAGE };
711
+ //# sourceMappingURL=ngx-oauth.mjs.map