ngx-oauth 4.0.0 → 4.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.
- package/README.md +2 -0
- package/esm2020/lib/components/login/oauth-login.component.mjs +22 -14
- package/esm2020/lib/models/index.mjs +5 -4
- package/esm2020/lib/oauth.module.mjs +16 -7
- package/esm2020/lib/services/oauth.interceptor.mjs +3 -3
- package/esm2020/lib/services/oauth.service.mjs +26 -16
- package/esm2020/lib/services/token.service.mjs +11 -8
- package/fesm2015/ngx-oauth.mjs +84 -51
- package/fesm2015/ngx-oauth.mjs.map +1 -1
- package/fesm2020/ngx-oauth.mjs +82 -51
- package/fesm2020/ngx-oauth.mjs.map +1 -1
- package/lib/components/login/oauth-login.component.d.ts +4 -3
- package/lib/models/index.d.ts +3 -2
- package/lib/services/oauth.service.d.ts +1 -0
- package/package.json +1 -1
package/fesm2020/ngx-oauth.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, Injectable, Inject, Component, ViewEncapsulation, Input, Output, ContentChild, HostListener, PLATFORM_ID, Optional, NgModule } from '@angular/core';
|
|
3
|
-
import * as
|
|
4
|
-
import { HttpHeaders, HttpParams, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
|
3
|
+
import * as i3 from '@angular/common/http';
|
|
4
|
+
import { HttpHeaders, HttpParams, HttpClient, HttpBackend, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
|
5
5
|
import { shareReplay, map, catchError, filter, switchMap as switchMap$1, tap, concatMap, delay } from 'rxjs/operators';
|
|
6
6
|
import { BehaviorSubject, distinctUntilChanged, switchMap, of, ReplaySubject, from, noop, firstValueFrom, throwError, take, Subscription } from 'rxjs';
|
|
7
7
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
|
8
|
-
import * as i2
|
|
8
|
+
import * as i2 from '@angular/common';
|
|
9
9
|
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
10
|
-
import * as i3 from '@angular/forms';
|
|
10
|
+
import * as i3$1 from '@angular/forms';
|
|
11
11
|
import { FormsModule } from '@angular/forms';
|
|
12
12
|
import { RouterModule } from '@angular/router';
|
|
13
13
|
|
|
@@ -18,11 +18,12 @@ const STORAGE = new InjectionToken('Storage');
|
|
|
18
18
|
const OAUTH_CONFIG = new InjectionToken('OAuthConfig');
|
|
19
19
|
const OAUTH_TOKEN = new InjectionToken('OAuthToken');
|
|
20
20
|
const HEADER_APPLICATION = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' });
|
|
21
|
+
const OAUTH_HTTP_CLIENT = new InjectionToken('OAuthHttpClient');
|
|
21
22
|
class OAuthConfig {
|
|
22
23
|
}
|
|
23
|
-
OAuthConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
24
|
-
OAuthConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
25
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
24
|
+
OAuthConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
25
|
+
OAuthConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthConfig, providedIn: 'root', useFactory: () => inject(OAUTH_CONFIG).reduce((p, c) => ({ ...p, ...c }), {}) });
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthConfig, decorators: [{
|
|
26
27
|
type: Injectable,
|
|
27
28
|
args: [{
|
|
28
29
|
providedIn: 'root',
|
|
@@ -62,7 +63,7 @@ class TokenService {
|
|
|
62
63
|
this.http = http;
|
|
63
64
|
this.zone = zone;
|
|
64
65
|
_TokenService_token$.set(this, new BehaviorSubject(this.saved));
|
|
65
|
-
this.token$ = __classPrivateFieldGet(this, _TokenService_token$, "f").pipe(distinctUntilChanged((p, c) => JSON.stringify(p || null) === JSON.stringify(c || null)), switchMap(token => !isExpiredToken(token) && of(token) || this.refreshToken(token))
|
|
66
|
+
this.token$ = __classPrivateFieldGet(this, _TokenService_token$, "f").pipe(distinctUntilChanged((p, c) => JSON.stringify(p || null) === JSON.stringify(c || null)), shareReplay(1), switchMap(token => !isExpiredToken(token) && of(token) || this.refreshToken(token)));
|
|
66
67
|
this.type$ = this.token$.pipe(map(token => token?.type), shareReplay(1));
|
|
67
68
|
this.accessToken$ = this.token$.pipe(map(token => token?.access_token), shareReplay(1));
|
|
68
69
|
}
|
|
@@ -119,11 +120,14 @@ class TokenService {
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
_TokenService_token$ = new WeakMap();
|
|
122
|
-
TokenService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
123
|
-
TokenService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
124
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
123
|
+
TokenService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: TokenService, deps: [{ token: OAuthConfig }, { token: OAUTH_HTTP_CLIENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
124
|
+
TokenService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: TokenService });
|
|
125
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: TokenService, decorators: [{
|
|
125
126
|
type: Injectable
|
|
126
|
-
}], ctorParameters: function () { return [{ type: OAuthConfig }, { type:
|
|
127
|
+
}], ctorParameters: function () { return [{ type: OAuthConfig }, { type: i3.HttpClient, decorators: [{
|
|
128
|
+
type: Inject,
|
|
129
|
+
args: [OAUTH_HTTP_CLIENT]
|
|
130
|
+
}] }, { type: i0.NgZone }]; } });
|
|
127
131
|
|
|
128
132
|
const arrToString = (buf) => buf.reduce((s, b) => s + String.fromCharCode(b), '');
|
|
129
133
|
const base64url = (str) => btoa(str)
|
|
@@ -170,7 +174,7 @@ class OAuthService {
|
|
|
170
174
|
this.token$ = this.config$.pipe(tap(config => {
|
|
171
175
|
const { hash, search, origin, pathname } = this.location;
|
|
172
176
|
const isImplicitRedirect = hash && /(access_token=)|(error=)/.test(hash);
|
|
173
|
-
const isAuthCodeRedirect = search && /(code=)|(error=)/.test(search);
|
|
177
|
+
const isAuthCodeRedirect = search && /(code=)|(error=)/.test(search) || hash && /(code=)|(error=)/.test(hash);
|
|
174
178
|
if (isImplicitRedirect) {
|
|
175
179
|
const parameters = parseOauthUri(hash.substring(1));
|
|
176
180
|
this.token = {
|
|
@@ -180,14 +184,14 @@ class OAuthService {
|
|
|
180
184
|
this.checkResponse(this.token, parameters);
|
|
181
185
|
}
|
|
182
186
|
else if (isAuthCodeRedirect) {
|
|
183
|
-
const parameters = parseOauthUri(search.substring(1));
|
|
187
|
+
const parameters = parseOauthUri(search && search.substring(1) || hash && hash.substring(1));
|
|
184
188
|
if (!this.checkResponse(this.token, parameters)) {
|
|
185
189
|
this.token = parameters;
|
|
186
190
|
}
|
|
187
191
|
else {
|
|
188
192
|
const newParametersString = this.getCleanedUnSearchParameters();
|
|
189
193
|
const { clientId, clientSecret, tokenPath, scope } = config;
|
|
190
|
-
const { codeVerifier } = this.token || {}; //should be set by
|
|
194
|
+
const { codeVerifier } = this.token || {}; //should be set by authorizationUrl construction
|
|
191
195
|
this.http.post(tokenPath, new HttpParams({
|
|
192
196
|
fromObject: {
|
|
193
197
|
code: parameters?.['code'],
|
|
@@ -209,10 +213,7 @@ class OAuthService {
|
|
|
209
213
|
}
|
|
210
214
|
}), switchMap$1(() => this.tokenService.token$), shareReplay(1));
|
|
211
215
|
this.status$ = this.token$.pipe(map(token => token.access_token && OAuthStatus.AUTHORIZED || token.error && OAuthStatus.DENIED || OAuthStatus.NOT_AUTHORIZED), shareReplay(1));
|
|
212
|
-
this.userInfo$ = this.status$.pipe(filter(s => s === OAuthStatus.AUTHORIZED), map(() =>
|
|
213
|
-
const { config } = this.authConfig;
|
|
214
|
-
return config.userPath;
|
|
215
|
-
}), filter(Boolean), switchMap$1(path => this.http.get(path)), shareReplay(1));
|
|
216
|
+
this.userInfo$ = this.status$.pipe(filter(s => s === OAuthStatus.AUTHORIZED), map(() => this.config.userPath), filter(Boolean), switchMap$1(path => this.getUserInfo(path)), shareReplay(1));
|
|
216
217
|
this.type$ = this.tokenService.type$;
|
|
217
218
|
this.ignorePaths = this.authConfig.ignorePaths || [];
|
|
218
219
|
}
|
|
@@ -237,10 +238,7 @@ class OAuthService {
|
|
|
237
238
|
if (!!parameters && parameters.password) {
|
|
238
239
|
await this.resourceLogin(parameters);
|
|
239
240
|
}
|
|
240
|
-
else if (!!parameters
|
|
241
|
-
&& parameters.redirectUri
|
|
242
|
-
&& (parameters.responseType === OAuthType.IMPLICIT
|
|
243
|
-
|| parameters.responseType === OAuthType.AUTHORIZATION_CODE)) {
|
|
241
|
+
else if (!!parameters && parameters.redirectUri && parameters.responseType) {
|
|
244
242
|
await this.toAuthorizationUrl(parameters);
|
|
245
243
|
}
|
|
246
244
|
else {
|
|
@@ -257,6 +255,10 @@ class OAuthService {
|
|
|
257
255
|
this.location.replace(`${logoutPath}?post_logout_redirect_uri=${logoutRedirectUri || currentPath}`);
|
|
258
256
|
}
|
|
259
257
|
}
|
|
258
|
+
getUserInfo(path) {
|
|
259
|
+
const { userPath } = this.config;
|
|
260
|
+
return this.http.get(path || userPath);
|
|
261
|
+
}
|
|
260
262
|
revoke() {
|
|
261
263
|
const { revokePath, clientId, clientSecret } = this.authConfig.config;
|
|
262
264
|
if (revokePath) {
|
|
@@ -375,7 +377,19 @@ class OAuthService {
|
|
|
375
377
|
cleanLocationHash() {
|
|
376
378
|
const { hash } = this.location;
|
|
377
379
|
let curHash = hash && hash.substring(1) || '';
|
|
378
|
-
const hashKeys = [
|
|
380
|
+
const hashKeys = [
|
|
381
|
+
'access_token',
|
|
382
|
+
'token_type',
|
|
383
|
+
'expires_in',
|
|
384
|
+
'scope',
|
|
385
|
+
'state',
|
|
386
|
+
'error',
|
|
387
|
+
'error_description',
|
|
388
|
+
'session_state',
|
|
389
|
+
'nonce',
|
|
390
|
+
'id_token',
|
|
391
|
+
'code'
|
|
392
|
+
];
|
|
379
393
|
hashKeys.forEach(hashKey => {
|
|
380
394
|
const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');
|
|
381
395
|
curHash = curHash.replace(re, '');
|
|
@@ -387,14 +401,14 @@ class OAuthService {
|
|
|
387
401
|
state && this.state$.next(state);
|
|
388
402
|
}
|
|
389
403
|
}
|
|
390
|
-
OAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
391
|
-
OAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
392
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
404
|
+
OAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthService, deps: [{ token: OAuthConfig }, { token: TokenService }, { token: i3.HttpClient }, { token: LOCATION }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
405
|
+
OAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthService });
|
|
406
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthService, decorators: [{
|
|
393
407
|
type: Injectable
|
|
394
|
-
}], ctorParameters: function () { return [{ type: OAuthConfig }, { type: TokenService }, { type:
|
|
408
|
+
}], ctorParameters: function () { return [{ type: OAuthConfig }, { type: TokenService }, { type: i3.HttpClient }, { type: Location, decorators: [{
|
|
395
409
|
type: Inject,
|
|
396
410
|
args: [LOCATION]
|
|
397
|
-
}] }, { type: i2
|
|
411
|
+
}] }, { type: i2.Location }]; } });
|
|
398
412
|
|
|
399
413
|
class OAuthInterceptor {
|
|
400
414
|
constructor(tokenService, authConfig) {
|
|
@@ -437,13 +451,13 @@ class OAuthInterceptor {
|
|
|
437
451
|
return false;
|
|
438
452
|
}
|
|
439
453
|
}
|
|
440
|
-
OAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
441
|
-
OAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
442
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
454
|
+
OAuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthInterceptor, deps: [{ token: TokenService }, { token: OAuthConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
455
|
+
OAuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthInterceptor });
|
|
456
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthInterceptor, decorators: [{
|
|
443
457
|
type: Injectable
|
|
444
458
|
}], ctorParameters: function () { return [{ type: TokenService }, { type: OAuthConfig }]; } });
|
|
445
459
|
|
|
446
|
-
var _OAuthLoginComponent_subscription, _OAuthLoginComponent_redirectUri, _OAuthLoginComponent_i18n;
|
|
460
|
+
var _OAuthLoginComponent_subscription, _OAuthLoginComponent_redirectUri, _OAuthLoginComponent_responseType, _OAuthLoginComponent_i18n;
|
|
447
461
|
class OAuthLoginComponent {
|
|
448
462
|
constructor(oauthService, locationService, location) {
|
|
449
463
|
this.oauthService = oauthService;
|
|
@@ -451,6 +465,7 @@ class OAuthLoginComponent {
|
|
|
451
465
|
this.location = location;
|
|
452
466
|
_OAuthLoginComponent_subscription.set(this, new Subscription());
|
|
453
467
|
_OAuthLoginComponent_redirectUri.set(this, void 0);
|
|
468
|
+
_OAuthLoginComponent_responseType.set(this, void 0);
|
|
454
469
|
_OAuthLoginComponent_i18n.set(this, {
|
|
455
470
|
username: 'Username',
|
|
456
471
|
password: 'Password',
|
|
@@ -459,6 +474,7 @@ class OAuthLoginComponent {
|
|
|
459
474
|
authorized: 'Welcome',
|
|
460
475
|
denied: 'Access Denied. Try again!'
|
|
461
476
|
});
|
|
477
|
+
this.type = OAuthType.RESOURCE;
|
|
462
478
|
this.useLogoutUrl = false;
|
|
463
479
|
this.state = '';
|
|
464
480
|
this.stateChange = this.oauthService.state$.asObservable();
|
|
@@ -467,7 +483,6 @@ class OAuthLoginComponent {
|
|
|
467
483
|
this.OAuthStatus = OAuthStatus;
|
|
468
484
|
this.OAuthType = OAuthType;
|
|
469
485
|
this.collapse = false;
|
|
470
|
-
this.type = OAuthType.RESOURCE;
|
|
471
486
|
this.status$ = this.oauthService.status$.pipe(tap(s => {
|
|
472
487
|
if (s === OAuthStatus.AUTHORIZED && this.profileName$) {
|
|
473
488
|
__classPrivateFieldGet(this, _OAuthLoginComponent_subscription, "f").add(this.profileName$.pipe(take(1)).subscribe(n => this.profileName = n));
|
|
@@ -498,6 +513,14 @@ class OAuthLoginComponent {
|
|
|
498
513
|
__classPrivateFieldSet(this, _OAuthLoginComponent_redirectUri, redirectUri, "f");
|
|
499
514
|
}
|
|
500
515
|
}
|
|
516
|
+
set responseType(responseType) {
|
|
517
|
+
if (this.responseType) {
|
|
518
|
+
__classPrivateFieldSet(this, _OAuthLoginComponent_responseType, responseType, "f");
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
get responseType() {
|
|
522
|
+
return __classPrivateFieldGet(this, _OAuthLoginComponent_responseType, "f") || this.type;
|
|
523
|
+
}
|
|
501
524
|
ngOnDestroy() {
|
|
502
525
|
__classPrivateFieldGet(this, _OAuthLoginComponent_subscription, "f").unsubscribe();
|
|
503
526
|
}
|
|
@@ -514,23 +537,24 @@ class OAuthLoginComponent {
|
|
|
514
537
|
keyboardEvent() {
|
|
515
538
|
this.collapse = false;
|
|
516
539
|
}
|
|
517
|
-
get responseType() {
|
|
518
|
-
return this.type; //avoid complains
|
|
519
|
-
}
|
|
520
540
|
}
|
|
521
|
-
_OAuthLoginComponent_subscription = new WeakMap(), _OAuthLoginComponent_redirectUri = new WeakMap(), _OAuthLoginComponent_i18n = new WeakMap();
|
|
522
|
-
OAuthLoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
523
|
-
OAuthLoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.
|
|
524
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
541
|
+
_OAuthLoginComponent_subscription = new WeakMap(), _OAuthLoginComponent_redirectUri = new WeakMap(), _OAuthLoginComponent_responseType = new WeakMap(), _OAuthLoginComponent_i18n = new WeakMap();
|
|
542
|
+
OAuthLoginComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthLoginComponent, deps: [{ token: OAuthService }, { token: i2.Location }, { token: LOCATION }], target: i0.ɵɵFactoryTarget.Component });
|
|
543
|
+
OAuthLoginComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.3", type: OAuthLoginComponent, selector: "oauth-login", inputs: { type: "type", i18n: "i18n", redirectUri: "redirectUri", responseType: "responseType", 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=\"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 {{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\"\r\n #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\"\r\n class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({responseType: responseType, 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 class=\"not-authorized\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\"\r\n [innerHTML]=\"i18n.notAuthorized\"></span>\r\n <span class=\"authorized\"\r\n *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n <span class=\"welcome\" [innerHTML]=\"i18n.authorized + ' '\"></span>\r\n <strong class=\"profile-name\"\r\n [innerHTML]=\"profileName\"></strong>\r\n </span>\r\n <span class=\"denied\"\r\n *ngIf=\"status === OAuthStatus.DENIED\"\r\n [innerHTML]=\"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$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i3$1.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$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3$1.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 });
|
|
544
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthLoginComponent, decorators: [{
|
|
525
545
|
type: Component,
|
|
526
|
-
args: [{ selector: 'oauth-login', encapsulation: ViewEncapsulation.None, template: "<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 {{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\"
|
|
527
|
-
}], ctorParameters: function () { return [{ type: OAuthService }, { type: i2
|
|
546
|
+
args: [{ selector: 'oauth-login', encapsulation: ViewEncapsulation.None, template: "<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 {{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\"\r\n #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\"\r\n class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({responseType: responseType, 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 class=\"not-authorized\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\"\r\n [innerHTML]=\"i18n.notAuthorized\"></span>\r\n <span class=\"authorized\"\r\n *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n <span class=\"welcome\" [innerHTML]=\"i18n.authorized + ' '\"></span>\r\n <strong class=\"profile-name\"\r\n [innerHTML]=\"profileName\"></strong>\r\n </span>\r\n <span class=\"denied\"\r\n *ngIf=\"status === OAuthStatus.DENIED\"\r\n [innerHTML]=\"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"] }]
|
|
547
|
+
}], ctorParameters: function () { return [{ type: OAuthService }, { type: i2.Location }, { type: Location, decorators: [{
|
|
528
548
|
type: Inject,
|
|
529
549
|
args: [LOCATION]
|
|
530
|
-
}] }]; }, propDecorators: {
|
|
550
|
+
}] }]; }, propDecorators: { type: [{
|
|
551
|
+
type: Input
|
|
552
|
+
}], i18n: [{
|
|
531
553
|
type: Input
|
|
532
554
|
}], redirectUri: [{
|
|
533
555
|
type: Input
|
|
556
|
+
}], responseType: [{
|
|
557
|
+
type: Input
|
|
534
558
|
}], useLogoutUrl: [{
|
|
535
559
|
type: Input
|
|
536
560
|
}], state: [{
|
|
@@ -542,8 +566,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
|
|
|
542
566
|
}], loginTemplate: [{
|
|
543
567
|
type: ContentChild,
|
|
544
568
|
args: ['login', { static: false }]
|
|
545
|
-
}], type: [{
|
|
546
|
-
type: Input
|
|
547
569
|
}], keyboardEvent: [{
|
|
548
570
|
type: HostListener,
|
|
549
571
|
args: ['window:keydown.escape']
|
|
@@ -596,6 +618,14 @@ const StorageService = {
|
|
|
596
618
|
},
|
|
597
619
|
deps: [PLATFORM_ID]
|
|
598
620
|
};
|
|
621
|
+
const OAuthHttpClient = {
|
|
622
|
+
provide: OAUTH_HTTP_CLIENT,
|
|
623
|
+
useFactory(httpBackend) {
|
|
624
|
+
// avoid http interceptors
|
|
625
|
+
return new HttpClient(httpBackend);
|
|
626
|
+
},
|
|
627
|
+
deps: [HttpBackend]
|
|
628
|
+
};
|
|
599
629
|
const OAuthInterceptorService = {
|
|
600
630
|
provide: HTTP_INTERCEPTORS,
|
|
601
631
|
useClass: OAuthInterceptor,
|
|
@@ -615,6 +645,7 @@ class OAuthModule {
|
|
|
615
645
|
providers: [
|
|
616
646
|
LocationService,
|
|
617
647
|
StorageService,
|
|
648
|
+
OAuthHttpClient,
|
|
618
649
|
provideOAuthConfigFactory((storage) => ({
|
|
619
650
|
...defaultConfig(storage),
|
|
620
651
|
...config
|
|
@@ -626,16 +657,16 @@ class OAuthModule {
|
|
|
626
657
|
};
|
|
627
658
|
}
|
|
628
659
|
}
|
|
629
|
-
OAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
630
|
-
OAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.
|
|
660
|
+
OAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
661
|
+
OAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.3", ngImport: i0, type: OAuthModule, declarations: [OAuthLoginComponent], imports: [CommonModule,
|
|
631
662
|
FormsModule,
|
|
632
663
|
HttpClientModule,
|
|
633
664
|
RouterModule], exports: [OAuthLoginComponent] });
|
|
634
|
-
OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.
|
|
665
|
+
OAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthModule, imports: [CommonModule,
|
|
635
666
|
FormsModule,
|
|
636
667
|
HttpClientModule,
|
|
637
668
|
RouterModule] });
|
|
638
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
669
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImport: i0, type: OAuthModule, decorators: [{
|
|
639
670
|
type: NgModule,
|
|
640
671
|
args: [{
|
|
641
672
|
imports: [
|
|
@@ -657,5 +688,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
|
|
|
657
688
|
* Generated bundle index. Do not edit.
|
|
658
689
|
*/
|
|
659
690
|
|
|
660
|
-
export { HEADER_APPLICATION, LOCATION, OAUTH_CONFIG, OAUTH_TOKEN, OAuthConfig, OAuthInterceptor, OAuthLoginComponent, OAuthModule, OAuthService, OAuthStatus, OAuthType, SERVER_HOST, SERVER_PATH, STORAGE, provideOAuthConfig, provideOAuthConfigFactory };
|
|
691
|
+
export { HEADER_APPLICATION, LOCATION, OAUTH_CONFIG, OAUTH_HTTP_CLIENT, OAUTH_TOKEN, OAuthConfig, OAuthInterceptor, OAuthLoginComponent, OAuthModule, OAuthService, OAuthStatus, OAuthType, SERVER_HOST, SERVER_PATH, STORAGE, provideOAuthConfig, provideOAuthConfigFactory };
|
|
661
692
|
//# sourceMappingURL=ngx-oauth.mjs.map
|