ngx-oauth 1.1.0 → 2.1.2

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,569 +0,0 @@
1
- import { InjectionToken, Injectable, NgZone, Inject, EventEmitter, Component, Input, Output, ContentChild, HostListener, PLATFORM_ID, Optional, NgModule } from '@angular/core';
2
- import { __awaiter } from 'tslib';
3
- import { HttpHeaders, HttpParams, HttpClient, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
4
- import { catchError, concatMap, delay, switchMap, tap } from 'rxjs/operators';
5
- import { ReplaySubject, EMPTY, from, of, noop, throwError, Subscription } from 'rxjs';
6
- import { FormsModule } from '@angular/forms';
7
- import { RouterModule } from '@angular/router';
8
- import { isPlatformBrowser, CommonModule } from '@angular/common';
9
-
10
- const SERVER_HOST = new InjectionToken('SERVER_HOST');
11
- const SERVER_PATH = new InjectionToken('SERVER_PATH');
12
- const LOCATION = new InjectionToken('Location');
13
- const STORAGE = new InjectionToken('Storage');
14
- const OAUTH_CONFIG = new InjectionToken('OAuthConfig');
15
- var OAuthType;
16
- (function (OAuthType) {
17
- OAuthType["RESOURCE"] = "password";
18
- OAuthType["AUTHORIZATION_CODE"] = "code";
19
- OAuthType["IMPLICIT"] = "token";
20
- OAuthType["CLIENT_CREDENTIAL"] = "client_credentials";
21
- })(OAuthType || (OAuthType = {}));
22
- var OAuthStatus;
23
- (function (OAuthStatus) {
24
- OAuthStatus["NOT_AUTHORIZED"] = "NOT_AUTHORIZED";
25
- OAuthStatus["AUTHORIZED"] = "AUTHORIZED";
26
- OAuthStatus["DENIED"] = "DENIED";
27
- })(OAuthStatus || (OAuthStatus = {}));
28
-
29
- const base64url = (str) => btoa(str)
30
- .replace(/\+/g, '-')
31
- .replace(/\//g, '_')
32
- .replace(/=/g, '');
33
- const ɵ0$1 = base64url;
34
- const pkce = (value) => __awaiter(void 0, void 0, void 0, function* () {
35
- const buff = yield crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));
36
- return base64url(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));
37
- });
38
- const ɵ1$1 = pkce;
39
- const REQUEST_HEADER = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' });
40
- const parseOauthUri = (hash) => {
41
- const regex = /([^&=]+)=([^&]*)/g;
42
- const params = {};
43
- let m;
44
- // tslint:disable-next-line:no-conditional-assignment
45
- while ((m = regex.exec(hash)) !== null) {
46
- params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
47
- }
48
- if (Object.keys(params).length) {
49
- return params;
50
- }
51
- return null;
52
- };
53
- const ɵ2 = parseOauthUri;
54
- class OAuthService {
55
- constructor(http, zone, authConfig, locationService) {
56
- this.http = http;
57
- this.zone = zone;
58
- this.authConfig = authConfig;
59
- this.locationService = locationService;
60
- this._token = null;
61
- this._status = OAuthStatus.NOT_AUTHORIZED;
62
- this.state$ = new ReplaySubject(1);
63
- this.status$ = new ReplaySubject(1);
64
- this.init();
65
- }
66
- init() {
67
- const { hash, search, origin, pathname } = this.locationService;
68
- const isImplicitRedirect = hash && new RegExp('(#access_token=)|(#error=)').test(hash);
69
- const isAuthCodeRedirect = search && new RegExp('(code=)|(error=)').test(search);
70
- const { storageKey } = this.authConfig;
71
- const savedToken = storageKey && this.authConfig.storage && this.authConfig.storage[storageKey] &&
72
- JSON.parse(this.authConfig.storage[storageKey]);
73
- if (isImplicitRedirect) {
74
- const parameters = parseOauthUri(hash.substr(1));
75
- this.emitState(parameters);
76
- this.cleanLocationHash();
77
- if (!parameters || parameters.error) {
78
- this.token = null;
79
- this.status = OAuthStatus.DENIED;
80
- }
81
- else {
82
- this.token = parameters;
83
- this.status = OAuthStatus.AUTHORIZED;
84
- }
85
- }
86
- else if (isAuthCodeRedirect) {
87
- const parameters = parseOauthUri(search.substr(1));
88
- this.emitState(parameters);
89
- const newParametersString = this.getCleanedUnSearchParameters();
90
- if (parameters && parameters.code) {
91
- const { clientId, clientSecret, tokenPath, scope, codeVerifier } = this.authConfig.config;
92
- setTimeout(() => {
93
- this.http.post(tokenPath, new HttpParams({
94
- fromObject: Object.assign(Object.assign({ code: parameters.code, client_id: clientId, client_secret: clientSecret, redirect_uri: `${origin}${pathname}${newParametersString}`, grant_type: 'authorization_code' }, scope ? { scope } : {}), codeVerifier ? { code_verifier: codeVerifier } : {})
95
- }), { headers: REQUEST_HEADER }).pipe(catchError(() => {
96
- this.token = { error: 'error' };
97
- this.status = OAuthStatus.DENIED;
98
- this.locationService.href = `${origin}${pathname}${newParametersString}`;
99
- return EMPTY;
100
- })).subscribe(token => {
101
- this.token = token;
102
- // authorized event will be triggered after redirect
103
- this.locationService.href = `${origin}${pathname}${newParametersString}`;
104
- });
105
- });
106
- }
107
- else {
108
- this.token = null;
109
- this.status = OAuthStatus.DENIED;
110
- }
111
- }
112
- else if (savedToken) {
113
- const { access_token, refresh_token, error } = savedToken;
114
- if (error) {
115
- this.token = null;
116
- this.status = OAuthStatus.DENIED;
117
- }
118
- else if (access_token) {
119
- this.token = savedToken;
120
- if (refresh_token) {
121
- setTimeout(() => {
122
- this.refreshToken();
123
- });
124
- }
125
- else {
126
- this.status = OAuthStatus.AUTHORIZED;
127
- }
128
- }
129
- }
130
- else {
131
- this.status = OAuthStatus.NOT_AUTHORIZED;
132
- }
133
- }
134
- login(parameters) {
135
- if (this.isResourceType(parameters)) {
136
- this.resourceLogin(parameters);
137
- }
138
- else if (this.isAuthorizationCodeType(parameters)) {
139
- this.authorizationCodeLogin(parameters).then();
140
- }
141
- else if (this.isImplicitType(parameters)) {
142
- this.implicitLogin(parameters).then();
143
- }
144
- else if (this.isClientCredentialType()) {
145
- this.clientCredentialLogin();
146
- }
147
- }
148
- logout() {
149
- this.revoke();
150
- this.token = null;
151
- this.status = OAuthStatus.NOT_AUTHORIZED;
152
- }
153
- revoke() {
154
- const { revokePath, clientId, clientSecret } = this.authConfig.config;
155
- if (revokePath) {
156
- const { access_token, refresh_token } = this.token;
157
- const toRevoke = [];
158
- if (access_token) {
159
- toRevoke.push(Object.assign(Object.assign(Object.assign({}, clientId ? { client_id: clientId } : {}), clientSecret ? { client_secret: clientSecret } : {}), { token: access_token, token_type_hint: 'access_token' }));
160
- }
161
- if (refresh_token) {
162
- toRevoke.push(Object.assign(Object.assign(Object.assign({}, clientId ? { client_id: clientId } : {}), clientSecret ? { client_secret: clientSecret } : {}), { token: refresh_token, token_type_hint: 'refresh_token' }));
163
- }
164
- from(toRevoke).pipe(concatMap(o => of(o).pipe(delay(300))), // space request to avoid cancellation
165
- switchMap(o => this.http.post(revokePath, new HttpParams({ fromObject: o })))).subscribe(noop);
166
- }
167
- }
168
- get status() {
169
- return this._status;
170
- }
171
- set status(status) {
172
- this._status = status;
173
- this.status$.next(status);
174
- }
175
- set(type, config) {
176
- this.authConfig.type = type;
177
- if (config) {
178
- this.authConfig.config = Object.assign(Object.assign({}, this.authConfig.config), config);
179
- }
180
- }
181
- get type() {
182
- return this.authConfig.type;
183
- }
184
- get ignorePaths() {
185
- return this.authConfig.ignorePaths || [];
186
- }
187
- resourceLogin(parameters) {
188
- const { clientId, clientSecret, tokenPath, scope } = this.authConfig.config;
189
- const { username, password } = parameters;
190
- this.http.post(tokenPath, new HttpParams({
191
- fromObject: Object.assign(Object.assign({ client_id: clientId, client_secret: clientSecret, grant_type: OAuthType.RESOURCE }, scope ? { scope } : {}), { username,
192
- password })
193
- }), { headers: REQUEST_HEADER }).pipe(catchError(() => {
194
- this.token = null;
195
- this.status = OAuthStatus.DENIED;
196
- return EMPTY;
197
- })).subscribe(params => {
198
- this.token = params;
199
- this.status = OAuthStatus.AUTHORIZED;
200
- });
201
- }
202
- authorizationCodeLogin(parameters) {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- const authUrl = yield this.toAuthorizationUrl(parameters, OAuthType.AUTHORIZATION_CODE);
205
- this.locationService.replace(authUrl);
206
- });
207
- }
208
- implicitLogin(parameters) {
209
- return __awaiter(this, void 0, void 0, function* () {
210
- const authUrl = yield this.toAuthorizationUrl(parameters, OAuthType.IMPLICIT);
211
- this.locationService.replace(authUrl);
212
- });
213
- }
214
- clientCredentialLogin() {
215
- const { clientId, clientSecret, tokenPath, scope } = this.authConfig.config;
216
- this.http.post(tokenPath, new HttpParams({
217
- fromObject: Object.assign({ client_id: clientId, client_secret: clientSecret, grant_type: OAuthType.CLIENT_CREDENTIAL }, scope ? { scope } : {})
218
- }), { headers: REQUEST_HEADER }).pipe(catchError(() => {
219
- this.token = null;
220
- this.status = OAuthStatus.DENIED;
221
- return EMPTY;
222
- })).subscribe(params => {
223
- this.token = params;
224
- this.status = OAuthStatus.AUTHORIZED;
225
- });
226
- }
227
- isClientCredentialType() {
228
- return this.authConfig.type === OAuthType.CLIENT_CREDENTIAL;
229
- }
230
- isResourceType(parameters) {
231
- return this.authConfig.type === OAuthType.RESOURCE && !!(parameters === null || parameters === void 0 ? void 0 : parameters.password);
232
- }
233
- isImplicitType(parameters) {
234
- return this.authConfig.type === OAuthType.IMPLICIT && !!(parameters === null || parameters === void 0 ? void 0 : parameters.redirectUri);
235
- }
236
- isAuthorizationCodeType(parameters) {
237
- return this.authConfig.type === OAuthType.AUTHORIZATION_CODE && !!(parameters === null || parameters === void 0 ? void 0 : parameters.redirectUri);
238
- }
239
- toAuthorizationUrl(parameters, responseType) {
240
- return __awaiter(this, void 0, void 0, function* () {
241
- const { config } = this.authConfig;
242
- const appendChar = config.authorizePath.includes('?') ? '&' : '?';
243
- const clientId = `${appendChar}client_id=${config.clientId}`;
244
- const redirectUri = `&redirect_uri=${encodeURIComponent(parameters.redirectUri)}`;
245
- const responseTypeString = `&response_type=${responseType}`;
246
- const scope = `&scope=${encodeURIComponent(config.scope || '')}`;
247
- const state = `&state=${encodeURIComponent(parameters.state || '')}`;
248
- const { codeVerifier } = config;
249
- const codeChallenge = codeVerifier ? `&code_challenge=${yield pkce(codeVerifier)}&code_challenge_method=S256` : '';
250
- const parametersString = `${clientId}${redirectUri}${responseTypeString}${scope}${state}${codeChallenge}`;
251
- return `${config.authorizePath}${parametersString}`;
252
- });
253
- }
254
- set token(token) {
255
- this._token = token;
256
- const { storageKey } = this.authConfig;
257
- if (token) {
258
- // @ts-ignore
259
- this.authConfig.storage[storageKey] = JSON.stringify(this.token);
260
- clearTimeout(this.timer);
261
- if (this.token && this.token.expires_in) {
262
- this.zone.runOutsideAngular(() => {
263
- var _a;
264
- this.timer = setTimeout(() => {
265
- this.zone.run(() => {
266
- this.refreshToken();
267
- });
268
- }, Number((_a = this.token) === null || _a === void 0 ? void 0 : _a.expires_in) * 1000);
269
- });
270
- }
271
- }
272
- else {
273
- // @ts-ignore
274
- delete this.authConfig.storage[storageKey];
275
- }
276
- }
277
- get token() {
278
- return this._token;
279
- }
280
- refreshToken() {
281
- const { tokenPath, clientId, clientSecret, scope } = this.authConfig.config;
282
- const { refresh_token } = this.token;
283
- if (tokenPath && refresh_token) {
284
- this.http.post(tokenPath, new HttpParams({
285
- fromObject: Object.assign({ client_id: clientId, client_secret: clientSecret, grant_type: 'refresh_token', refresh_token }, scope ? { scope } : {})
286
- }), { headers: REQUEST_HEADER }).pipe(catchError(() => {
287
- this.logout();
288
- return EMPTY;
289
- })).subscribe(params => {
290
- this.token = Object.assign(Object.assign({}, this.token), params);
291
- this.status = OAuthStatus.AUTHORIZED;
292
- });
293
- }
294
- }
295
- getCleanedUnSearchParameters() {
296
- const { search } = this.locationService;
297
- let searchString = search.substr(1);
298
- const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state'];
299
- hashKeys.forEach((hashKey) => {
300
- const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');
301
- searchString = searchString.replace(re, '');
302
- });
303
- return searchString.length ? `?${searchString}` : '';
304
- }
305
- cleanLocationHash() {
306
- const { hash } = this.locationService;
307
- let curHash = hash.substr(1);
308
- const hashKeys = ['access_token', 'token_type', 'expires_in', 'scope', 'state', 'error', 'error_description', 'session_state'];
309
- hashKeys.forEach((hashKey) => {
310
- const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');
311
- curHash = curHash.replace(re, '');
312
- });
313
- this.locationService.hash = curHash;
314
- }
315
- emitState(parameters) {
316
- const { state } = parameters;
317
- if (state) {
318
- this.state$.next(state);
319
- }
320
- }
321
- }
322
- OAuthService.decorators = [
323
- { type: Injectable }
324
- ];
325
- OAuthService.ctorParameters = () => [
326
- { type: HttpClient },
327
- { type: NgZone },
328
- { type: undefined, decorators: [{ type: Inject, args: [OAUTH_CONFIG,] }] },
329
- { type: Location, decorators: [{ type: Inject, args: [LOCATION,] }] }
330
- ];
331
-
332
- class OAuthInterceptor {
333
- constructor(oauthService) {
334
- this.oauthService = oauthService;
335
- }
336
- intercept(req, next) {
337
- if (this.oauthService) {
338
- if (!this.isPathExcepted(req)) {
339
- const token = this.oauthService.token;
340
- if (token && token.access_token) {
341
- req = req.clone({
342
- setHeaders: {
343
- Authorization: `${token.token_type} ${token.access_token}`
344
- }
345
- });
346
- }
347
- }
348
- return next.handle(req).pipe(catchError((err) => {
349
- if (err.status === 401) {
350
- this.oauthService.token = null;
351
- this.oauthService.status = OAuthStatus.DENIED;
352
- return EMPTY;
353
- }
354
- return throwError(() => new Error(err));
355
- }));
356
- }
357
- else {
358
- return next.handle(req);
359
- }
360
- }
361
- isPathExcepted(req) {
362
- for (const ignorePath of this.oauthService.ignorePaths) {
363
- try {
364
- if (req.url.match(ignorePath)) {
365
- return true;
366
- }
367
- }
368
- catch (err) {
369
- }
370
- }
371
- return false;
372
- }
373
- }
374
- OAuthInterceptor.decorators = [
375
- { type: Injectable }
376
- ];
377
- OAuthInterceptor.ctorParameters = () => [
378
- { type: OAuthService }
379
- ];
380
-
381
- class OAuthLoginComponent {
382
- constructor(oauthService, location) {
383
- this.oauthService = oauthService;
384
- this.location = location;
385
- this.subscription = new Subscription();
386
- this._i18n = {
387
- username: 'Username',
388
- password: 'Password',
389
- submit: 'Sign in',
390
- notAuthorized: 'Sign in',
391
- authorized: 'Welcome',
392
- denied: 'Access Denied. Try again!'
393
- };
394
- this.state = '';
395
- this.stateChange = new EventEmitter();
396
- this.username = '';
397
- this.password = '';
398
- this.OAuthStatus = OAuthStatus;
399
- this.OAuthType = OAuthType;
400
- this.collapse = false;
401
- this.type = this.oauthService.type;
402
- this.redirectUri = this.location.href;
403
- this.state$ = this.oauthService.state$.pipe(tap(s => this.stateChange.emit(s)));
404
- this.status$ = this.oauthService.status$.pipe(tap(s => {
405
- if (s === OAuthStatus.AUTHORIZED && this.profileName$) {
406
- this.subscription.add(this.profileName$.subscribe(n => this.profileName = n));
407
- }
408
- else {
409
- this.profileName = '';
410
- }
411
- }));
412
- this.loginFunction = (p) => this.login(p);
413
- this.logoutFunction = () => this.logout();
414
- }
415
- get i18n() {
416
- return this._i18n;
417
- }
418
- set i18n(i18n) {
419
- this._i18n = Object.assign(Object.assign({}, this._i18n), i18n);
420
- }
421
- ngOnDestroy() {
422
- this.subscription.unsubscribe();
423
- }
424
- logout() {
425
- this.oauthService.logout();
426
- }
427
- login(parameters) {
428
- this.oauthService.login(parameters);
429
- this.collapse = false;
430
- }
431
- toggleCollapse() {
432
- this.collapse = !this.collapse;
433
- }
434
- keyboardEvent() {
435
- this.collapse = false;
436
- }
437
- }
438
- OAuthLoginComponent.decorators = [
439
- { type: Component, args: [{
440
- selector: 'oauth-login',
441
- 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-right 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=\"form-group\">\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=\"form-group\">\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-right\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n {{i18n.authorized}}<strong>&nbsp;{{profileName}}</strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n",
442
- 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"]
443
- },] }
444
- ];
445
- OAuthLoginComponent.ctorParameters = () => [
446
- { type: OAuthService },
447
- { type: Location, decorators: [{ type: Inject, args: [LOCATION,] }] }
448
- ];
449
- OAuthLoginComponent.propDecorators = {
450
- i18n: [{ type: Input }],
451
- state: [{ type: Input }],
452
- stateChange: [{ type: Output }],
453
- profileName$: [{ type: Input }],
454
- loginTemplate: [{ type: ContentChild, args: ['login', { static: false },] }],
455
- keyboardEvent: [{ type: HostListener, args: ['window:keydown.escape',] }]
456
- };
457
-
458
- const mockLocation = (serverHost, serverPath) => {
459
- const url = new URL(serverHost && serverPath ? `${serverHost}${serverPath}` : 'http://localhost');
460
- const { href, origin, protocol, host, hostname, port, pathname, search, hash } = url;
461
- return {
462
- href, origin, protocol, host, hostname, port, pathname, search, hash,
463
- reload() {
464
- },
465
- assign(u) {
466
- },
467
- ancestorOrigins: {},
468
- replace(u) {
469
- }
470
- };
471
- };
472
- const ɵ0 = mockLocation;
473
- const LocationService = {
474
- provide: LOCATION,
475
- useFactory(platformId, serverHost, serverPath) {
476
- return isPlatformBrowser(platformId) ? location : mockLocation(serverHost, serverPath);
477
- },
478
- deps: [
479
- PLATFORM_ID,
480
- [new Optional(), SERVER_HOST],
481
- [new Optional(), SERVER_PATH]
482
- ]
483
- };
484
- const mockStorage = {
485
- clear() {
486
- },
487
- getItem(key) {
488
- return null;
489
- },
490
- key(index) {
491
- return null;
492
- },
493
- removeItem(key) {
494
- },
495
- setItem(key, value) {
496
- },
497
- length: 0
498
- };
499
- const StorageService = {
500
- provide: STORAGE,
501
- useFactory(platformId) {
502
- return isPlatformBrowser(platformId) ? localStorage : mockStorage;
503
- },
504
- deps: [PLATFORM_ID]
505
- };
506
- const OAuthInterceptorService = {
507
- provide: HTTP_INTERCEPTORS,
508
- useClass: OAuthInterceptor,
509
- multi: true,
510
- };
511
- const defaultConfig = (storage) => {
512
- return {
513
- storage,
514
- storageKey: 'token',
515
- ignorePaths: []
516
- };
517
- };
518
- const ɵ1 = defaultConfig;
519
- class OAuthModule {
520
- static forRoot(config) {
521
- return {
522
- ngModule: OAuthModule,
523
- providers: [
524
- LocationService,
525
- StorageService,
526
- OAuthService,
527
- OAuthInterceptorService,
528
- {
529
- provide: OAUTH_CONFIG,
530
- useFactory(storage) {
531
- return Object.assign(Object.assign({}, defaultConfig(storage)), config);
532
- },
533
- deps: [
534
- STORAGE
535
- ]
536
- }
537
- ]
538
- };
539
- }
540
- }
541
- OAuthModule.decorators = [
542
- { type: NgModule, args: [{
543
- imports: [
544
- CommonModule,
545
- FormsModule,
546
- HttpClientModule,
547
- RouterModule,
548
- ],
549
- declarations: [OAuthLoginComponent],
550
- exports: [OAuthLoginComponent],
551
- providers: [
552
- LocationService,
553
- StorageService,
554
- OAuthService,
555
- OAuthInterceptorService,
556
- ]
557
- },] }
558
- ];
559
-
560
- /*
561
- * Public API Surface of ngx-oauth
562
- */
563
-
564
- /**
565
- * Generated bundle index. Do not edit.
566
- */
567
-
568
- export { LOCATION, OAUTH_CONFIG, OAuthInterceptor, OAuthLoginComponent, OAuthModule, OAuthService, OAuthStatus, OAuthType, SERVER_HOST, SERVER_PATH, STORAGE, ɵ2 };
569
- //# sourceMappingURL=ngx-oauth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ngx-oauth.js","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/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');\n\nexport enum OAuthType {\n RESOURCE = 'password',\n AUTHORIZATION_CODE = 'code',\n IMPLICIT = 'token',\n CLIENT_CREDENTIAL = 'client_credentials'\n}\n\nexport interface OAuthConfig {\n type: OAuthType;\n config: OAuthTypeConfig;\n storageKey?: string;\n storage?: Storage;\n ignorePaths?: RegExp[];\n}\n\nexport interface ClientCredentialConfig {\n tokenPath: string;\n revokePath?: string;\n clientId: string;\n clientSecret: string;\n scope?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface ResourceConfig extends ClientCredentialConfig {\n}\n\nexport interface ImplicitConfig {\n authorizePath: string;\n revokePath?: string;\n clientId: string;\n scope?: string;\n}\n\nexport interface AuthorizationCodeConfig extends ResourceConfig {\n authorizePath: string;\n}\n\nexport interface AuthorizationCodePKCEConfig extends AuthorizationCodeConfig {\n codeVerifier: 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 =\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 expires_in?: number | string;\n refresh_expires_in?: number;\n scope?: string;\n}\n\nexport enum OAuthStatus {\n NOT_AUTHORIZED = 'NOT_AUTHORIZED',\n AUTHORIZED = 'AUTHORIZED',\n DENIED = 'DENIED'\n}\n","import {Inject, Injectable, NgZone} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';\nimport {catchError, concatMap, delay, switchMap} from 'rxjs/operators';\nimport {EMPTY, from, noop, 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,\n ResourceParameters\n} from '../models';\n\nconst base64url = (str: string) => btoa(str)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n\nconst pkce = async (value: string) => {\n const buff = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));\n return base64url(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));\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\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\n constructor(private http: HttpClient,\n private zone: NgZone,\n @Inject(OAUTH_CONFIG) private authConfig: OAuthConfig,\n @Inject(LOCATION) private locationService: Location) {\n this.init();\n }\n\n protected init(): void {\n const {hash, search, origin, pathname} = this.locationService;\n const isImplicitRedirect = hash && new RegExp('(#access_token=)|(#error=)').test(hash);\n const isAuthCodeRedirect = search && new RegExp('(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 if (isImplicitRedirect) {\n const parameters = parseOauthUri(hash.substr(1));\n this.emitState(parameters);\n this.cleanLocationHash();\n if (!parameters || parameters.error) {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n } else {\n this.token = parameters;\n this.status = OAuthStatus.AUTHORIZED;\n }\n } else if (isAuthCodeRedirect) {\n const parameters = parseOauthUri(search.substr(1));\n this.emitState(parameters);\n const newParametersString = this.getCleanedUnSearchParameters();\n if (parameters && parameters.code) {\n const {clientId, clientSecret, tokenPath, scope, codeVerifier} = this.authConfig.config as any;\n setTimeout(() => {\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n code: parameters.code,\n client_id: clientId,\n client_secret: clientSecret,\n redirect_uri: `${origin}${pathname}${newParametersString}`,\n grant_type: 'authorization_code',\n ...scope ? {scope} : {},\n ...codeVerifier ? {code_verifier: codeVerifier} : {}\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.token = {error: 'error'};\n this.status = OAuthStatus.DENIED;\n this.locationService.href = `${origin}${pathname}${newParametersString}`;\n return EMPTY;\n })\n ).subscribe(token => {\n this.token = token;\n // authorized event will be triggered after redirect\n this.locationService.href = `${origin}${pathname}${newParametersString}`;\n });\n });\n } else {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n }\n } else if (savedToken) {\n const {access_token, refresh_token, error} = savedToken;\n if (error) {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n } else if (access_token) {\n this.token = savedToken;\n if (refresh_token) {\n setTimeout(() => {\n this.refreshToken();\n });\n } else {\n this.status = OAuthStatus.AUTHORIZED;\n }\n }\n } else {\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n }\n\n 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 this.authorizationCodeLogin(parameters as AuthorizationCodeParameters).then();\n } else if (this.isImplicitType(parameters as ImplicitParameters)) {\n this.implicitLogin(parameters as ImplicitParameters).then();\n } else if (this.isClientCredentialType()) {\n this.clientCredentialLogin();\n }\n }\n\n logout() {\n this.revoke();\n this.token = null;\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n\n revoke() {\n const {revokePath, clientId, clientSecret} = this.authConfig.config as any;\n if (revokePath) {\n const {access_token, refresh_token} = this.token as OAuthToken;\n const toRevoke = [];\n if (access_token) {\n toRevoke.push({\n ...clientId ? {client_id: clientId} : {},\n ...clientSecret ? {client_secret: clientSecret} : {},\n token: access_token,\n token_type_hint: 'access_token'\n });\n }\n if (refresh_token) {\n toRevoke.push({\n ...clientId ? {client_id: clientId} : {},\n ...clientSecret ? {client_secret: clientSecret} : {},\n token: refresh_token,\n token_type_hint: 'refresh_token'\n });\n }\n from(toRevoke).pipe(\n concatMap(o => of(o).pipe(delay(300))), // space request to avoid cancellation\n switchMap(o => this.http.post(revokePath, new HttpParams({fromObject: o}))),\n ).subscribe(noop);\n }\n }\n\n get status(): OAuthStatus {\n return this._status;\n }\n\n set status(status) {\n this._status = status;\n this.status$.next(status);\n }\n\n set(type: OAuthType, config?: OAuthTypeConfig): void {\n this.authConfig.type = type;\n if (config) {\n this.authConfig.config = {\n ...this.authConfig.config,\n ...config\n };\n }\n }\n\n get type(): OAuthType {\n return this.authConfig.type;\n }\n\n get ignorePaths(): RegExp[] {\n return this.authConfig.ignorePaths || [];\n }\n\n private resourceLogin(parameters: ResourceParameters) {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n const {username, password} = parameters;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n client_secret: clientSecret,\n grant_type: OAuthType.RESOURCE,\n ...scope ? {scope} : {},\n username,\n password\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private async authorizationCodeLogin(parameters: AuthorizationCodeParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.AUTHORIZATION_CODE);\n this.locationService.replace(authUrl);\n }\n\n private async implicitLogin(parameters: ImplicitParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.IMPLICIT);\n this.locationService.replace(authUrl);\n }\n\n private clientCredentialLogin() {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n client_secret: clientSecret,\n grant_type: OAuthType.CLIENT_CREDENTIAL,\n ...scope ? {scope} : {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private isClientCredentialType(): boolean {\n return this.authConfig.type === OAuthType.CLIENT_CREDENTIAL;\n }\n\n private isResourceType(parameters?: ResourceParameters): boolean {\n return this.authConfig.type === OAuthType.RESOURCE && !!parameters?.password;\n }\n\n private isImplicitType(parameters?: ImplicitParameters): boolean {\n return this.authConfig.type === OAuthType.IMPLICIT && !!parameters?.redirectUri;\n }\n\n private isAuthorizationCodeType(parameters?: AuthorizationCodeParameters): boolean {\n return this.authConfig.type === OAuthType.AUTHORIZATION_CODE && !!parameters?.redirectUri;\n }\n\n private async toAuthorizationUrl(parameters: AuthorizationCodeParameters | ImplicitParameters, responseType: OAuthType): Promise<string> {\n const {config} = this.authConfig as any;\n const appendChar = config.authorizePath.includes('?') ? '&' : '?';\n const clientId = `${appendChar}client_id=${config.clientId}`;\n const redirectUri = `&redirect_uri=${encodeURIComponent(parameters.redirectUri)}`;\n const responseTypeString = `&response_type=${responseType}`;\n const scope = `&scope=${encodeURIComponent(config.scope || '')}`;\n const state = `&state=${encodeURIComponent(parameters.state || '')}`;\n const {codeVerifier} = config;\n const codeChallenge = codeVerifier ? `&code_challenge=${await pkce(codeVerifier)}&code_challenge_method=S256` : '';\n const parametersString = `${clientId}${redirectUri}${responseTypeString}${scope}${state}${codeChallenge}`;\n return `${config.authorizePath}${parametersString}`;\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 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.locationService;\n let searchString = search.substr(1);\n const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n searchString = searchString.replace(re, '');\n });\n return searchString.length ? `?${searchString}` : '';\n }\n\n private cleanLocationHash() {\n const {hash} = this.locationService;\n let curHash = hash.substr(1);\n const hashKeys = ['access_token', 'token_type', 'expires_in', 'scope', 'state', 'error', 'error_description', 'session_state'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n curHash = curHash.replace(re, '');\n });\n this.locationService.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.token;\n if (token && token.access_token) {\n req = req.clone({\n setHeaders: {\n Authorization: `${token.token_type} ${token.access_token}`\n }\n });\n }\n }\n return next.handle(req).pipe(\n catchError((err) => {\n if (err.status === 401) {\n this.oauthService.token = null;\n this.oauthService.status = OAuthStatus.DENIED;\n return EMPTY;\n }\n return throwError(() => new Error(err));\n })\n );\n } else {\n return next.handle(req);\n }\n }\n\n private isPathExcepted(req: HttpRequest<any>) {\n 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 return false;\n }\n}\n","import {Component, ContentChild, EventEmitter, HostListener, Inject, Input, OnDestroy, Output, TemplateRef} from '@angular/core';\r\nimport {Observable, Subscription} from 'rxjs';\r\nimport {LOCATION, OAuthParameters, OAuthStatus, OAuthType} from '../../models';\r\nimport {tap} from 'rxjs/operators';\r\nimport {OAuthService} from '../../services/oauth.service';\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})\r\nexport class OAuthLoginComponent implements OnDestroy {\r\n\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 state = '';\r\n @Output()\r\n stateChange: EventEmitter<string> = new EventEmitter();\r\n @Input()\r\n profileName$: Observable<string> | 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 redirectUri = this.location.href;\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$.subscribe(n => this.profileName = n));\r\n } else {\r\n this.profileName = '';\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 @Inject(LOCATION) private location: Location) {\r\n }\r\n\r\n ngOnDestroy() {\r\n this.subscription.unsubscribe();\r\n }\r\n\r\n logout() {\r\n this.oauthService.logout();\r\n }\r\n\r\n login(parameters: OAuthParameters) {\r\n 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","import {ModuleWithProviders, NgModule, Optional, PLATFORM_ID} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';\nimport {RouterModule} from '@angular/router';\nimport {OAuthConfig, OAUTH_CONFIG, LOCATION, SERVER_HOST, SERVER_PATH, STORAGE} from './models';\nimport {OAuthService} from './services/oauth.service';\nimport {OAuthLoginComponent} from './components/login/oauth-login.component';\nimport {CommonModule, isPlatformBrowser} from '@angular/common';\nimport {OAuthInterceptor} from './services/oauth.interceptor';\n\nconst mockLocation = (serverHost: string, serverPath: string): Location => {\n const url = new URL(serverHost && serverPath ? `${serverHost}${serverPath}` : 'http://localhost');\n const {href, origin, protocol, host, hostname, port, pathname, search, hash} = url;\n return {\n href, origin, protocol, host, hostname, port, pathname, search, hash,\n reload() {\n },\n assign(u: string) {\n },\n ancestorOrigins: {} as any,\n replace(u: string) {\n }\n };\n};\n\nconst LocationService = {\n provide: LOCATION,\n useFactory(platformId: Object, serverHost: string, serverPath: string) {\n return isPlatformBrowser(platformId) ? location : mockLocation(serverHost, serverPath);\n },\n deps: [\n PLATFORM_ID,\n [new Optional(), SERVER_HOST],\n [new Optional(), SERVER_PATH]\n ]\n};\n\nconst mockStorage: Storage = {\n clear() {\n },\n getItem(key: string) {\n return null;\n },\n key(index: number) {\n return null;\n },\n removeItem(key: string) {\n },\n setItem(key: string, value: string) {\n },\n length: 0\n};\n\nconst StorageService = {\n provide: STORAGE,\n useFactory(platformId: Object) {\n return isPlatformBrowser(platformId) ? localStorage : mockStorage;\n },\n deps: [PLATFORM_ID]\n};\n\nconst OAuthInterceptorService = {\n provide: HTTP_INTERCEPTORS,\n useClass: OAuthInterceptor,\n multi: true,\n};\n\nconst defaultConfig = (storage: Storage) => {\n return {\n storage,\n storageKey: 'token',\n ignorePaths: []\n };\n};\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n HttpClientModule,\n RouterModule,\n ],\n declarations: [OAuthLoginComponent],\n exports: [OAuthLoginComponent],\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n ]\n})\nexport class OAuthModule {\n\n static forRoot(config: OAuthConfig): ModuleWithProviders<OAuthModule> {\n return {\n ngModule: OAuthModule,\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n {\n provide: OAUTH_CONFIG,\n useFactory(storage: Storage) {\n return {\n ...defaultConfig(storage),\n ...config,\n };\n },\n deps: [\n STORAGE\n ]\n }\n ]\n };\n }\n}\n","/*\n * Public API Surface of ngx-oauth\n */\nexport * from './lib/models';\nexport * from './lib/services/oauth.service';\nexport * from './lib/services/oauth.interceptor';\nexport * from './lib/components/login/oauth-login.component';\nexport * from './lib/oauth.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;MAEa,WAAW,GAAG,IAAI,cAAc,CAAS,aAAa,EAAE;MACxD,WAAW,GAAG,IAAI,cAAc,CAAS,aAAa,EAAE;MACxD,QAAQ,GAAG,IAAI,cAAc,CAAW,UAAU,EAAE;MACpD,OAAO,GAAG,IAAI,cAAc,CAAU,SAAS,EAAE;MACjD,YAAY,GAAG,IAAI,cAAc,CAAc,aAAa,EAAE;IAE/D;AAAZ,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,wCAA2B,CAAA;IAC3B,+BAAkB,CAAA;IAClB,qDAAwC,CAAA;AAC1C,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;IAuEW;AAAZ,WAAY,WAAW;IACrB,gDAAiC,CAAA;IACjC,wCAAyB,CAAA;IACzB,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW;;AClEvB,MAAM,SAAS,GAAG,CAAC,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC;KACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;KACn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