ngx-oauth 2.2.1 → 3.0.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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Inject, EventEmitter, Component, ViewEncapsulation, Input, Output, ContentChild, HostListener, PLATFORM_ID, Optional, NgModule } from '@angular/core';
2
+ import { InjectionToken, inject, Injectable, Inject, EventEmitter, Component, ViewEncapsulation, Input, Output, ContentChild, HostListener, PLATFORM_ID, Optional, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
4
  import { HttpHeaders, HttpParams, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
5
5
  import { filter, map, switchMap, shareReplay, tap, catchError, concatMap, delay } from 'rxjs/operators';
@@ -16,6 +16,28 @@ const LOCATION = new InjectionToken('Location');
16
16
  const STORAGE = new InjectionToken('Storage');
17
17
  const OAUTH_CONFIG = new InjectionToken('OAuthConfig');
18
18
  const OAUTH_TOKEN = new InjectionToken('OAuthToken');
19
+ class OAuthConfig {
20
+ }
21
+ OAuthConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
22
+ OAuthConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthConfig, providedIn: 'root', useFactory: () => inject(OAUTH_CONFIG).reduce((p, c) => ({ ...p, ...c }), {}) });
23
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthConfig, decorators: [{
24
+ type: Injectable,
25
+ args: [{
26
+ providedIn: 'root',
27
+ useFactory: () => inject(OAUTH_CONFIG).reduce((p, c) => ({ ...p, ...c }), {})
28
+ }]
29
+ }] });
30
+ const provideOAuthConfig = (config = {}) => ({
31
+ provide: OAUTH_CONFIG,
32
+ useValue: config,
33
+ multi: true
34
+ });
35
+ const provideOAuthConfigFactory = (factory, deps) => ({
36
+ provide: OAUTH_CONFIG,
37
+ useFactory: factory,
38
+ deps: deps,
39
+ multi: true
40
+ });
19
41
  var OAuthType;
20
42
  (function (OAuthType) {
21
43
  OAuthType["RESOURCE"] = "password";
@@ -84,7 +106,7 @@ class OAuthService {
84
106
  if (config && config.clientId) {
85
107
  const { issuerPath, scope } = config;
86
108
  if (issuerPath) {
87
- return this.http.get(`${issuerPath}/.well-known/openid-configuration`).pipe(tap(v => this.set(this.type, {
109
+ return this.http.get(`${issuerPath}/.well-known/openid-configuration`).pipe(tap(v => this.type && this.set(this.type, {
88
110
  ...v.authorization_endpoint && { authorizePath: v.authorization_endpoint } || {},
89
111
  ...v.token_endpoint && { tokenPath: v.token_endpoint } || {},
90
112
  ...v.revocation_endpoint && { revokePath: v.revocation_endpoint } || {},
@@ -129,7 +151,7 @@ class OAuthService {
129
151
  const codeVerifier = savedToken && savedToken.codeVerifier;
130
152
  this.http.post(tokenPath, new HttpParams({
131
153
  fromObject: {
132
- code: parameters?.code,
154
+ code: parameters?.['code'],
133
155
  client_id: clientId,
134
156
  ...clientSecret && { client_secret: clientSecret } || {},
135
157
  redirect_uri: `${origin}${pathname}`,
@@ -330,14 +352,14 @@ class OAuthService {
330
352
  checkResponse(token, parameters) {
331
353
  this.emitState(parameters);
332
354
  this.cleanLocationHash();
333
- if (!parameters || parameters.error) {
355
+ if (!parameters || parameters['error']) {
334
356
  return false;
335
357
  }
336
- if (token && token.nonce && parameters.access_token) {
337
- const jwtToken = jwt(parameters.access_token);
358
+ if (token && token.nonce && parameters['access_token']) {
359
+ const jwtToken = jwt(parameters['access_token']);
338
360
  return token.nonce === jwtToken.nonce;
339
361
  }
340
- return parameters.access_token || parameters.code;
362
+ return parameters['access_token'] || parameters['code'];
341
363
  }
342
364
  set token(token) {
343
365
  this._token = token;
@@ -415,14 +437,11 @@ class OAuthService {
415
437
  }
416
438
  }
417
439
  }
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: [{
440
+ OAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthService, deps: [{ token: i1.HttpClient }, { token: i0.NgZone }, { token: OAuthConfig }, { token: LOCATION }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
441
+ OAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthService });
442
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthService, decorators: [{
421
443
  type: Injectable
422
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i0.NgZone }, { type: undefined, decorators: [{
423
- type: Inject,
424
- args: [OAUTH_CONFIG]
425
- }] }, { type: Location, decorators: [{
444
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i0.NgZone }, { type: OAuthConfig }, { type: Location, decorators: [{
426
445
  type: Inject,
427
446
  args: [LOCATION]
428
447
  }] }, { type: i2.Location }]; } });
@@ -444,12 +463,9 @@ class OAuthInterceptor {
444
463
  }
445
464
  }
446
465
  return next.handle(req).pipe(catchError((err) => {
447
- if (err.status === 401) {
466
+ if (err.status === 401 && !this.isPathExcepted(req)) {
448
467
  this.oauthService.token = null;
449
468
  this.oauthService.status = OAuthStatus.DENIED;
450
- if (!this.isPathExcepted(req)) {
451
- return EMPTY;
452
- }
453
469
  }
454
470
  return throwError(err);
455
471
  }));
@@ -474,9 +490,9 @@ class OAuthInterceptor {
474
490
  return false;
475
491
  }
476
492
  }
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: [{
493
+ OAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthInterceptor, deps: [{ token: OAuthService }], target: i0.ɵɵFactoryTarget.Injectable });
494
+ OAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthInterceptor });
495
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthInterceptor, decorators: [{
480
496
  type: Injectable
481
497
  }], ctorParameters: function () { return [{ type: OAuthService }]; } });
482
498
 
@@ -551,9 +567,9 @@ class OAuthLoginComponent {
551
567
  this.collapse = false;
552
568
  }
553
569
  }
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: [{
570
+ OAuthLoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthLoginComponent, deps: [{ token: OAuthService }, { token: i2.Location }, { token: LOCATION }], target: i0.ɵɵFactoryTarget.Component });
571
+ OAuthLoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.0", 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"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", 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]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], encapsulation: i0.ViewEncapsulation.None });
572
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthLoginComponent, decorators: [{
557
573
  type: Component,
558
574
  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"] }]
559
575
  }], ctorParameters: function () { return [{ type: OAuthService }, { type: i2.Location }, { type: Location, decorators: [{
@@ -639,7 +655,7 @@ const defaultConfig = (storage) => {
639
655
  };
640
656
  };
641
657
  class OAuthModule {
642
- static forRoot(config) {
658
+ static forRoot(config = {}) {
643
659
  return {
644
660
  ngModule: OAuthModule,
645
661
  providers: [
@@ -647,39 +663,24 @@ class OAuthModule {
647
663
  StorageService,
648
664
  OAuthService,
649
665
  OAuthInterceptorService,
650
- {
651
- provide: OAUTH_CONFIG,
652
- useFactory(storage) {
653
- return {
654
- ...defaultConfig(storage),
655
- ...config,
656
- };
657
- },
658
- deps: [
659
- STORAGE
660
- ]
661
- }
666
+ provideOAuthConfigFactory((storage) => ({
667
+ ...defaultConfig(storage),
668
+ ...config
669
+ }), [STORAGE]),
662
670
  ]
663
671
  };
664
672
  }
665
673
  }
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,
674
+ OAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
675
+ OAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.0", ngImport: i0, type: OAuthModule, declarations: [OAuthLoginComponent], imports: [CommonModule,
668
676
  FormsModule,
669
677
  HttpClientModule,
670
678
  RouterModule], exports: [OAuthLoginComponent] });
671
- OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthModule, providers: [
672
- LocationService,
673
- StorageService,
674
- OAuthService,
675
- OAuthInterceptorService,
676
- ], imports: [[
677
- CommonModule,
678
- FormsModule,
679
- HttpClientModule,
680
- RouterModule,
681
- ]] });
682
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OAuthModule, decorators: [{
679
+ OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthModule, imports: [CommonModule,
680
+ FormsModule,
681
+ HttpClientModule,
682
+ RouterModule] });
683
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0", ngImport: i0, type: OAuthModule, decorators: [{
683
684
  type: NgModule,
684
685
  args: [{
685
686
  imports: [
@@ -689,13 +690,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
689
690
  RouterModule,
690
691
  ],
691
692
  declarations: [OAuthLoginComponent],
692
- exports: [OAuthLoginComponent],
693
- providers: [
694
- LocationService,
695
- StorageService,
696
- OAuthService,
697
- OAuthInterceptorService,
698
- ]
693
+ exports: [OAuthLoginComponent]
699
694
  }]
700
695
  }] });
701
696
 
@@ -707,5 +702,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
707
702
  * Generated bundle index. Do not edit.
708
703
  */
709
704
 
710
- export { LOCATION, OAUTH_CONFIG, OAUTH_TOKEN, OAuthInterceptor, OAuthLoginComponent, OAuthModule, OAuthService, OAuthStatus, OAuthType, SERVER_HOST, SERVER_PATH, STORAGE };
705
+ export { LOCATION, OAUTH_CONFIG, OAUTH_TOKEN, OAuthConfig, OAuthInterceptor, OAuthLoginComponent, OAuthModule, OAuthService, OAuthStatus, OAuthType, SERVER_HOST, SERVER_PATH, STORAGE, provideOAuthConfig, provideOAuthConfigFactory };
711
706
  //# sourceMappingURL=ngx-oauth.mjs.map
@@ -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 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 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,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AC,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 {FactoryProvider, inject, Injectable, InjectionToken, ValueProvider} 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\n@Injectable({\n providedIn: 'root',\n useFactory: () => inject(OAUTH_CONFIG).reduce((p, c) => ({...p, ...c}), {})\n})\nexport abstract class OAuthConfig {\n type?: OAuthType;\n config?: OAuthTypeConfig;\n storageKey?: string;\n storage?: Storage;\n ignorePaths?: RegExp[];\n}\n\nexport const provideOAuthConfig = (config: OAuthConfig = {}): ValueProvider => ({\n provide: OAUTH_CONFIG,\n useValue: config,\n multi: true\n})\n\nexport const provideOAuthConfigFactory = (factory: Function, deps?: any[]): FactoryProvider => ({\n provide: OAUTH_CONFIG,\n useFactory: factory,\n deps: deps,\n multi: true\n});\n\nexport enum OAuthType {\n RESOURCE = 'password',\n AUTHORIZATION_CODE = 'code',\n IMPLICIT = 'token',\n CLIENT_CREDENTIAL = 'client_credentials'\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 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 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.type && 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() {\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 {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 && !this.isPathExcepted(req)) {\n this.oauthService.token = null;\n this.oauthService.status = OAuthStatus.DENIED;\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, LOCATION, SERVER_HOST, SERVER_PATH, STORAGE, provideOAuthConfigFactory} 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})\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 provideOAuthConfigFactory((storage: Storage) => ({\n ...defaultConfig(storage),\n ...config\n }), [STORAGE]),\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":["i3","i1.OAuthService"],"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,CAAgB,aAAa,EAAE;MAChE,WAAW,GAAG,IAAI,cAAc,CAAa,YAAY,EAAE;MAMlD,WAAW,CAAA;;wGAAX,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAX,WAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,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EAAE,WAAW;AACrB,YAAA,SAAS,EAAE;gBACT,eAAe;gBACf,cAAc;gBACd,YAAY;gBACZ,uBAAuB;AACvB,gBAAA,yBAAyB,CAAC,CAAC,OAAgB,MAAM;oBAC/C,GAAG,aAAa,CAAC,OAAO,CAAC;AACzB,oBAAA,GAAG,MAAM;AACV,iBAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AACf,aAAA;SACF,CAAC;KACH;;wGAhBU,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;yGAAX,WAAW,EAAA,YAAA,EAAA,CAHP,mBAAmB,CAAA,EAAA,OAAA,EAAA,CALhC,YAAY;QACZ,WAAW;QACX,gBAAgB;AAChB,QAAA,YAAY,aAGJ,mBAAmB,CAAA,EAAA,CAAA,CAAA;AAElB,WAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,YARpB,YAAY;QACZ,WAAW;QACX,gBAAgB;QAChB,YAAY,CAAA,EAAA,CAAA,CAAA;2FAKH,WAAW,EAAA,UAAA,EAAA,CAAA;kBAVvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,WAAW;wBACX,gBAAgB;wBAChB,YAAY;AACb,qBAAA;oBACD,YAAY,EAAE,CAAC,mBAAmB,CAAC;oBACnC,OAAO,EAAE,CAAC,mBAAmB,CAAC;AAC/B,iBAAA,CAAA;;;ACpFD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -34,7 +34,7 @@ export declare class OAuthLoginComponent implements OnDestroy {
34
34
  OAuthStatus: typeof OAuthStatus;
35
35
  OAuthType: typeof OAuthType;
36
36
  collapse: boolean;
37
- type: OAuthType;
37
+ type: OAuthType | undefined;
38
38
  state$: Observable<string>;
39
39
  status$: Observable<OAuthStatus>;
40
40
  loginFunction: (p: OAuthParameters) => Promise<void>;
@@ -46,5 +46,5 @@ export declare class OAuthLoginComponent implements OnDestroy {
46
46
  toggleCollapse(): void;
47
47
  keyboardEvent(): void;
48
48
  static ɵfac: i0.ɵɵFactoryDeclaration<OAuthLoginComponent, never>;
49
- static ɵcmp: i0.ɵɵComponentDeclaration<OAuthLoginComponent, "oauth-login", never, { "i18n": "i18n"; "redirectUri": "redirectUri"; "useLogoutUrl": "useLogoutUrl"; "state": "state"; "profileName$": "profileName$"; }, { "stateChange": "stateChange"; }, ["loginTemplate"], never>;
49
+ static ɵcmp: i0.ɵɵComponentDeclaration<OAuthLoginComponent, "oauth-login", never, { "i18n": "i18n"; "redirectUri": "redirectUri"; "useLogoutUrl": "useLogoutUrl"; "state": "state"; "profileName$": "profileName$"; }, { "stateChange": "stateChange"; }, ["loginTemplate"], never, false>;
50
50
  }
@@ -1,23 +1,28 @@
1
- import { InjectionToken } from '@angular/core';
1
+ import { FactoryProvider, InjectionToken, ValueProvider } from '@angular/core';
2
+ import * as i0 from "@angular/core";
2
3
  export declare const SERVER_HOST: InjectionToken<string>;
3
4
  export declare const SERVER_PATH: InjectionToken<string>;
4
5
  export declare const LOCATION: InjectionToken<Location>;
5
6
  export declare const STORAGE: InjectionToken<Storage>;
6
- export declare const OAUTH_CONFIG: InjectionToken<OAuthConfig>;
7
+ export declare const OAUTH_CONFIG: InjectionToken<OAuthConfig[]>;
7
8
  export declare const OAUTH_TOKEN: InjectionToken<OAuthToken>;
9
+ export declare abstract class OAuthConfig {
10
+ type?: OAuthType;
11
+ config?: OAuthTypeConfig;
12
+ storageKey?: string;
13
+ storage?: Storage;
14
+ ignorePaths?: RegExp[];
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<OAuthConfig, never>;
16
+ static ɵprov: i0.ɵɵInjectableDeclaration<OAuthConfig>;
17
+ }
18
+ export declare const provideOAuthConfig: (config?: OAuthConfig) => ValueProvider;
19
+ export declare const provideOAuthConfigFactory: (factory: Function, deps?: any[]) => FactoryProvider;
8
20
  export declare enum OAuthType {
9
21
  RESOURCE = "password",
10
22
  AUTHORIZATION_CODE = "code",
11
23
  IMPLICIT = "token",
12
24
  CLIENT_CREDENTIAL = "client_credentials"
13
25
  }
14
- export interface OAuthConfig {
15
- type: OAuthType;
16
- config: OAuthTypeConfig;
17
- storageKey?: string;
18
- storage?: Storage;
19
- ignorePaths?: RegExp[];
20
- }
21
26
  export interface ClientCredentialConfig {
22
27
  tokenPath: string;
23
28
  revokePath?: string;
@@ -7,7 +7,7 @@ import * as i3 from "@angular/forms";
7
7
  import * as i4 from "@angular/common/http";
8
8
  import * as i5 from "@angular/router";
9
9
  export declare class OAuthModule {
10
- static forRoot(config: OAuthConfig): ModuleWithProviders<OAuthModule>;
10
+ static forRoot(config?: OAuthConfig): ModuleWithProviders<OAuthModule>;
11
11
  static ɵfac: i0.ɵɵFactoryDeclaration<OAuthModule, never>;
12
12
  static ɵmod: i0.ɵɵNgModuleDeclaration<OAuthModule, [typeof i1.OAuthLoginComponent], [typeof i2.CommonModule, typeof i3.FormsModule, typeof i4.HttpClientModule, typeof i5.RouterModule], [typeof i1.OAuthLoginComponent]>;
13
13
  static ɵinj: i0.ɵɵInjectorDeclaration<OAuthModule>;
@@ -21,7 +21,7 @@ export declare class OAuthService {
21
21
  * Get the oauth config for initialize. If OpenId with issuerPath is configured then configure from server openid configuration.
22
22
  * @protected
23
23
  */
24
- protected get config$(): Observable<OAuthTypeConfig>;
24
+ protected get config$(): Observable<OAuthTypeConfig | undefined>;
25
25
  /**
26
26
  * Init. Will check the url implicit or authorization flow or existing saved token.
27
27
  * @protected
@@ -33,7 +33,7 @@ export declare class OAuthService {
33
33
  get status(): OAuthStatus;
34
34
  set status(status: OAuthStatus);
35
35
  set(type: OAuthType, config?: OAuthTypeConfig): void;
36
- get type(): OAuthType;
36
+ get type(): OAuthType | undefined;
37
37
  get ignorePaths(): RegExp[];
38
38
  private resourceLogin;
39
39
  private authorizationCodeLogin;