@thecla/auth0-angular 3.0.0 → 5.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.
Files changed (41) hide show
  1. package/esm2020/lib/actions/auth.actions.mjs +8 -0
  2. package/{esm2015/lib/auth-config.js → esm2020/lib/auth-config.mjs} +0 -0
  3. package/esm2020/lib/auth.guard.mjs +29 -0
  4. package/esm2020/lib/auth.module.mjs +42 -0
  5. package/esm2020/lib/auth.service.mjs +52 -0
  6. package/esm2020/lib/effects/auth.effects.mjs +53 -0
  7. package/esm2020/lib/jwt.interceptor.mjs +32 -0
  8. package/esm2020/lib/reducers/auth.reducer.mjs +20 -0
  9. package/{esm2015/lib/state/auth.state.js → esm2020/lib/state/auth.state.mjs} +1 -1
  10. package/esm2020/lib/store/index.mjs +8 -0
  11. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  12. package/esm2020/thecla-auth0-angular.mjs +5 -0
  13. package/fesm2015/{thecla-auth0-angular.js → thecla-auth0-angular.mjs} +58 -63
  14. package/fesm2015/thecla-auth0-angular.mjs.map +1 -0
  15. package/fesm2020/thecla-auth0-angular.mjs +217 -0
  16. package/fesm2020/thecla-auth0-angular.mjs.map +1 -0
  17. package/lib/actions/auth.actions.d.ts +13 -9
  18. package/lib/auth.guard.d.ts +4 -1
  19. package/lib/auth.module.d.ts +6 -0
  20. package/lib/auth.service.d.ts +3 -0
  21. package/lib/effects/auth.effects.d.ts +13 -6
  22. package/lib/jwt.interceptor.d.ts +3 -0
  23. package/lib/reducers/auth.reducer.d.ts +1 -5
  24. package/lib/state/auth.state.d.ts +1 -1
  25. package/package.json +25 -14
  26. package/thecla-auth0-angular.d.ts +1 -7
  27. package/bundles/thecla-auth0-angular.umd.js +0 -567
  28. package/bundles/thecla-auth0-angular.umd.js.map +0 -1
  29. package/bundles/thecla-auth0-angular.umd.min.js +0 -2
  30. package/bundles/thecla-auth0-angular.umd.min.js.map +0 -1
  31. package/esm2015/lib/actions/auth.actions.js +0 -8
  32. package/esm2015/lib/auth.guard.js +0 -30
  33. package/esm2015/lib/auth.module.js +0 -35
  34. package/esm2015/lib/auth.service.js +0 -58
  35. package/esm2015/lib/effects/auth.effects.js +0 -52
  36. package/esm2015/lib/jwt.interceptor.js +0 -31
  37. package/esm2015/lib/reducers/auth.reducer.js +0 -21
  38. package/esm2015/lib/store/index.js +0 -11
  39. package/esm2015/thecla-auth0-angular.js +0 -12
  40. package/fesm2015/thecla-auth0-angular.js.map +0 -1
  41. package/thecla-auth0-angular.metadata.json +0 -1
@@ -1,567 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('@ngrx/effects'), require('@ngrx/store'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('@auth0/auth0-spa-js')) :
3
- typeof define === 'function' && define.amd ? define('@thecla/auth0-angular', ['exports', '@angular/common/http', '@angular/core', '@ngrx/effects', '@ngrx/store', '@angular/router', 'rxjs', 'rxjs/operators', '@auth0/auth0-spa-js'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.thecla = global.thecla || {}, global.thecla['auth0-angular'] = {}), global.ng.common.http, global.ng.core, global.ngrx.effects, global.ngrx.store, global.ng.router, global.rxjs, global.rxjs.operators, global.createAuth0Client));
5
- }(this, (function (exports, http, i0, effects, i1, router, rxjs, operators, auth0SpaJs) { 'use strict';
6
-
7
- var AuthConfig = /** @class */ (function () {
8
- function AuthConfig() {
9
- }
10
- return AuthConfig;
11
- }());
12
-
13
- var signIn = i1.createAction('@thecla/auth0-angular/sign-in', i1.props());
14
- var signInCompleted = i1.createAction('@thecla/auth0-angular/sign-in-completed', i1.props());
15
- var signedIn = i1.createAction('@thecla/auth0-angular/signed-in', i1.props());
16
- var signInFailed = i1.createAction('@thecla/auth0-angular/sign-in-failed', i1.props());
17
- var signOut = i1.createAction('@thecla/auth0-angular/sign-out');
18
- var signedOut = i1.createAction('@thecla/auth0-angular/signed-out');
19
-
20
- /*! *****************************************************************************
21
- Copyright (c) Microsoft Corporation.
22
-
23
- Permission to use, copy, modify, and/or distribute this software for any
24
- purpose with or without fee is hereby granted.
25
-
26
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
27
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
28
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
29
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
30
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
31
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
32
- PERFORMANCE OF THIS SOFTWARE.
33
- ***************************************************************************** */
34
- /* global Reflect, Promise */
35
- var extendStatics = function (d, b) {
36
- extendStatics = Object.setPrototypeOf ||
37
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
38
- function (d, b) { for (var p in b)
39
- if (Object.prototype.hasOwnProperty.call(b, p))
40
- d[p] = b[p]; };
41
- return extendStatics(d, b);
42
- };
43
- function __extends(d, b) {
44
- if (typeof b !== "function" && b !== null)
45
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
46
- extendStatics(d, b);
47
- function __() { this.constructor = d; }
48
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
49
- }
50
- var __assign = function () {
51
- __assign = Object.assign || function __assign(t) {
52
- for (var s, i = 1, n = arguments.length; i < n; i++) {
53
- s = arguments[i];
54
- for (var p in s)
55
- if (Object.prototype.hasOwnProperty.call(s, p))
56
- t[p] = s[p];
57
- }
58
- return t;
59
- };
60
- return __assign.apply(this, arguments);
61
- };
62
- function __rest(s, e) {
63
- var t = {};
64
- for (var p in s)
65
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
66
- t[p] = s[p];
67
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
68
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
69
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
70
- t[p[i]] = s[p[i]];
71
- }
72
- return t;
73
- }
74
- function __decorate(decorators, target, key, desc) {
75
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
76
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
77
- r = Reflect.decorate(decorators, target, key, desc);
78
- else
79
- for (var i = decorators.length - 1; i >= 0; i--)
80
- if (d = decorators[i])
81
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
82
- return c > 3 && r && Object.defineProperty(target, key, r), r;
83
- }
84
- function __param(paramIndex, decorator) {
85
- return function (target, key) { decorator(target, key, paramIndex); };
86
- }
87
- function __metadata(metadataKey, metadataValue) {
88
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
89
- return Reflect.metadata(metadataKey, metadataValue);
90
- }
91
- function __awaiter(thisArg, _arguments, P, generator) {
92
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
93
- return new (P || (P = Promise))(function (resolve, reject) {
94
- function fulfilled(value) { try {
95
- step(generator.next(value));
96
- }
97
- catch (e) {
98
- reject(e);
99
- } }
100
- function rejected(value) { try {
101
- step(generator["throw"](value));
102
- }
103
- catch (e) {
104
- reject(e);
105
- } }
106
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
107
- step((generator = generator.apply(thisArg, _arguments || [])).next());
108
- });
109
- }
110
- function __generator(thisArg, body) {
111
- var _ = { label: 0, sent: function () { if (t[0] & 1)
112
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
113
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
114
- function verb(n) { return function (v) { return step([n, v]); }; }
115
- function step(op) {
116
- if (f)
117
- throw new TypeError("Generator is already executing.");
118
- while (_)
119
- try {
120
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
121
- return t;
122
- if (y = 0, t)
123
- op = [op[0] & 2, t.value];
124
- switch (op[0]) {
125
- case 0:
126
- case 1:
127
- t = op;
128
- break;
129
- case 4:
130
- _.label++;
131
- return { value: op[1], done: false };
132
- case 5:
133
- _.label++;
134
- y = op[1];
135
- op = [0];
136
- continue;
137
- case 7:
138
- op = _.ops.pop();
139
- _.trys.pop();
140
- continue;
141
- default:
142
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
143
- _ = 0;
144
- continue;
145
- }
146
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
147
- _.label = op[1];
148
- break;
149
- }
150
- if (op[0] === 6 && _.label < t[1]) {
151
- _.label = t[1];
152
- t = op;
153
- break;
154
- }
155
- if (t && _.label < t[2]) {
156
- _.label = t[2];
157
- _.ops.push(op);
158
- break;
159
- }
160
- if (t[2])
161
- _.ops.pop();
162
- _.trys.pop();
163
- continue;
164
- }
165
- op = body.call(thisArg, _);
166
- }
167
- catch (e) {
168
- op = [6, e];
169
- y = 0;
170
- }
171
- finally {
172
- f = t = 0;
173
- }
174
- if (op[0] & 5)
175
- throw op[1];
176
- return { value: op[0] ? op[1] : void 0, done: true };
177
- }
178
- }
179
- var __createBinding = Object.create ? (function (o, m, k, k2) {
180
- if (k2 === undefined)
181
- k2 = k;
182
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
183
- }) : (function (o, m, k, k2) {
184
- if (k2 === undefined)
185
- k2 = k;
186
- o[k2] = m[k];
187
- });
188
- function __exportStar(m, o) {
189
- for (var p in m)
190
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
191
- __createBinding(o, m, p);
192
- }
193
- function __values(o) {
194
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
195
- if (m)
196
- return m.call(o);
197
- if (o && typeof o.length === "number")
198
- return {
199
- next: function () {
200
- if (o && i >= o.length)
201
- o = void 0;
202
- return { value: o && o[i++], done: !o };
203
- }
204
- };
205
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
206
- }
207
- function __read(o, n) {
208
- var m = typeof Symbol === "function" && o[Symbol.iterator];
209
- if (!m)
210
- return o;
211
- var i = m.call(o), r, ar = [], e;
212
- try {
213
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
214
- ar.push(r.value);
215
- }
216
- catch (error) {
217
- e = { error: error };
218
- }
219
- finally {
220
- try {
221
- if (r && !r.done && (m = i["return"]))
222
- m.call(i);
223
- }
224
- finally {
225
- if (e)
226
- throw e.error;
227
- }
228
- }
229
- return ar;
230
- }
231
- /** @deprecated */
232
- function __spread() {
233
- for (var ar = [], i = 0; i < arguments.length; i++)
234
- ar = ar.concat(__read(arguments[i]));
235
- return ar;
236
- }
237
- /** @deprecated */
238
- function __spreadArrays() {
239
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
240
- s += arguments[i].length;
241
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
242
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
243
- r[k] = a[j];
244
- return r;
245
- }
246
- function __spreadArray(to, from) {
247
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
248
- to[j] = from[i];
249
- return to;
250
- }
251
- function __await(v) {
252
- return this instanceof __await ? (this.v = v, this) : new __await(v);
253
- }
254
- function __asyncGenerator(thisArg, _arguments, generator) {
255
- if (!Symbol.asyncIterator)
256
- throw new TypeError("Symbol.asyncIterator is not defined.");
257
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
258
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
259
- function verb(n) { if (g[n])
260
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
261
- function resume(n, v) { try {
262
- step(g[n](v));
263
- }
264
- catch (e) {
265
- settle(q[0][3], e);
266
- } }
267
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
268
- function fulfill(value) { resume("next", value); }
269
- function reject(value) { resume("throw", value); }
270
- function settle(f, v) { if (f(v), q.shift(), q.length)
271
- resume(q[0][0], q[0][1]); }
272
- }
273
- function __asyncDelegator(o) {
274
- var i, p;
275
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
276
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
277
- }
278
- function __asyncValues(o) {
279
- if (!Symbol.asyncIterator)
280
- throw new TypeError("Symbol.asyncIterator is not defined.");
281
- var m = o[Symbol.asyncIterator], i;
282
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
283
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
284
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
285
- }
286
- function __makeTemplateObject(cooked, raw) {
287
- if (Object.defineProperty) {
288
- Object.defineProperty(cooked, "raw", { value: raw });
289
- }
290
- else {
291
- cooked.raw = raw;
292
- }
293
- return cooked;
294
- }
295
- ;
296
- var __setModuleDefault = Object.create ? (function (o, v) {
297
- Object.defineProperty(o, "default", { enumerable: true, value: v });
298
- }) : function (o, v) {
299
- o["default"] = v;
300
- };
301
- function __importStar(mod) {
302
- if (mod && mod.__esModule)
303
- return mod;
304
- var result = {};
305
- if (mod != null)
306
- for (var k in mod)
307
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
308
- __createBinding(result, mod, k);
309
- __setModuleDefault(result, mod);
310
- return result;
311
- }
312
- function __importDefault(mod) {
313
- return (mod && mod.__esModule) ? mod : { default: mod };
314
- }
315
- function __classPrivateFieldGet(receiver, privateMap) {
316
- if (!privateMap.has(receiver)) {
317
- throw new TypeError("attempted to get private field on non-instance");
318
- }
319
- return privateMap.get(receiver);
320
- }
321
- function __classPrivateFieldSet(receiver, privateMap, value) {
322
- if (!privateMap.has(receiver)) {
323
- throw new TypeError("attempted to set private field on non-instance");
324
- }
325
- privateMap.set(receiver, value);
326
- return value;
327
- }
328
-
329
- var AuthService = /** @class */ (function () {
330
- function AuthService(config) {
331
- var _a;
332
- this.config = config;
333
- this.auth0 = new auth0SpaJs.Auth0Client({
334
- audience: config.audience,
335
- client_id: config.clientId,
336
- domain: config.domain,
337
- redirect_uri: (_a = config.redirectUri) !== null && _a !== void 0 ? _a : location.origin,
338
- scope: config.scope,
339
- useRefreshTokens: config.useRefreshTokens,
340
- sessionCheckExpiryDays: config.sessionCheckExpiryDays,
341
- });
342
- }
343
- AuthService.prototype.isAuthenticated = function () {
344
- return rxjs.from(this.checkSession());
345
- };
346
- AuthService.prototype.loginWithRedirect = function (appState) {
347
- return rxjs.from(this.auth0.loginWithRedirect({ appState: appState })).pipe(operators.switchMap(function () { return rxjs.EMPTY; }));
348
- };
349
- AuthService.prototype.handleRedirectCallback = function () {
350
- return rxjs.from(this.auth0.handleRedirectCallback()).pipe(operators.map(function (result) { return result.appState; }));
351
- };
352
- AuthService.prototype.getUser = function () {
353
- return rxjs.from(this.auth0.getUser()).pipe(operators.filter(function (u) { return u !== undefined; }));
354
- };
355
- AuthService.prototype.getAccessToken = function () {
356
- return rxjs.from(this.auth0.getTokenSilently());
357
- };
358
- AuthService.prototype.logout = function () {
359
- var _a;
360
- this.auth0.logout({ returnTo: (_a = this.config.logoutUri) !== null && _a !== void 0 ? _a : location.origin });
361
- };
362
- AuthService.prototype.checkSession = function () {
363
- return __awaiter(this, void 0, void 0, function () {
364
- return __generator(this, function (_b) {
365
- switch (_b.label) {
366
- case 0: return [4 /*yield*/, this.auth0.checkSession()];
367
- case 1:
368
- _b.sent();
369
- return [4 /*yield*/, this.auth0.isAuthenticated()];
370
- case 2: return [2 /*return*/, _b.sent()];
371
- }
372
- });
373
- });
374
- };
375
- return AuthService;
376
- }());
377
- AuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AuthService_Factory() { return new AuthService(i0.ɵɵinject(AuthConfig)); }, token: AuthService, providedIn: "root" });
378
- AuthService.decorators = [
379
- { type: i0.Injectable, args: [{
380
- providedIn: 'root',
381
- },] }
382
- ];
383
- AuthService.ctorParameters = function () { return [
384
- { type: AuthConfig }
385
- ]; };
386
-
387
- var AuthEffects = /** @class */ (function () {
388
- function AuthEffects(actions$, auth, router) {
389
- var _this = this;
390
- this.actions$ = actions$;
391
- this.auth = auth;
392
- this.router = router;
393
- this.signIn$ = effects.createEffect(function () { return _this.actions$.pipe(effects.ofType(signIn), operators.switchMap(function (action) { return _this.auth.loginWithRedirect({ target: action.returnUrl }); })); }, { dispatch: false });
394
- this.signInCompleted$ = effects.createEffect(function () { return _this.actions$.pipe(effects.ofType(signInCompleted), operators.switchMap(function () { return _this.auth.getUser().pipe(operators.map(function (user) { return signedIn(user); }), operators.catchError(function (error) { return rxjs.of(signInFailed({ error: error })); })); })); });
395
- this.redirect$ = effects.createEffect(function () { return _this.actions$.pipe(effects.ofType(signInCompleted), operators.switchMap(function (action) { return _this.router.navigateByUrl(action.state.target, { replaceUrl: true }); })); }, { dispatch: false });
396
- this.signOut$ = effects.createEffect(function () { return _this.actions$.pipe(effects.ofType(signOut), operators.tap(function () {
397
- try {
398
- _this.auth.logout();
399
- }
400
- catch (_a) { }
401
- }), operators.map(function () { return signedOut(); })); });
402
- this.init$ = effects.createEffect(function () { return function (_b) {
403
- var _c = _b === void 0 ? {} : _b, _d = _c.scheduler, scheduler = _d === void 0 ? rxjs.asyncScheduler : _d;
404
- var params = window.location.search;
405
- if (params.includes('code=') && params.includes('state=')) {
406
- return _this.completeSignIn(scheduler);
407
- }
408
- else {
409
- return _this.auth.isAuthenticated().pipe(operators.switchMap(function (auth) { return _this.getAuthResult(auth); }), operators.catchError(function (error) { return rxjs.of(signInFailed({ error: error })); }), operators.observeOn(scheduler));
410
- }
411
- }; });
412
- }
413
- AuthEffects.prototype.getAuthResult = function (auth) {
414
- if (auth) {
415
- return this.auth.getUser().pipe(operators.map(function (user) { return signedIn(user); }));
416
- }
417
- else {
418
- return rxjs.of(signedOut());
419
- }
420
- };
421
- AuthEffects.prototype.completeSignIn = function (scheduler) {
422
- return this.auth.handleRedirectCallback().pipe(operators.map(function (state) { return signInCompleted({ state: state }); }), operators.catchError(function (error) { return rxjs.of(signInFailed({ error: error })); }), operators.observeOn(scheduler));
423
- };
424
- return AuthEffects;
425
- }());
426
- AuthEffects.decorators = [
427
- { type: i0.Injectable }
428
- ];
429
- AuthEffects.ctorParameters = function () { return [
430
- { type: effects.Actions },
431
- { type: AuthService },
432
- { type: router.Router }
433
- ]; };
434
-
435
- var JwtInterceptor = /** @class */ (function () {
436
- function JwtInterceptor(auth) {
437
- this.auth = auth;
438
- }
439
- JwtInterceptor.prototype.intercept = function (request, next) {
440
- if (this.isSameDomain(request)) {
441
- return this.authorize(request).pipe(operators.mergeMap(function (authorizedRequest) { return next.handle(authorizedRequest); }));
442
- }
443
- else {
444
- return next.handle(request);
445
- }
446
- };
447
- JwtInterceptor.prototype.isSameDomain = function (request) {
448
- var isAbsolute = /^https?:\/\//i.test(request.url);
449
- return !isAbsolute;
450
- };
451
- JwtInterceptor.prototype.authorize = function (request) {
452
- var token$ = this.auth.getAccessToken();
453
- return token$.pipe(operators.map(function (token) { return request.clone({ setHeaders: { Authorization: "Bearer " + token } }); }));
454
- };
455
- return JwtInterceptor;
456
- }());
457
- JwtInterceptor.decorators = [
458
- { type: i0.Injectable }
459
- ];
460
- JwtInterceptor.ctorParameters = function () { return [
461
- { type: AuthService }
462
- ]; };
463
-
464
- var noAuthentication = {
465
- authenticating: false,
466
- authenticated: false,
467
- };
468
- var startAuthentication = {
469
- authenticating: true,
470
- authenticated: false,
471
- };
472
- var ɵ0 = function (state, _a) {
473
- var type = _a.type, payload = __rest(_a, ["type"]);
474
- return Object.assign(Object.assign({}, state), { authenticating: false, authenticated: true, user: payload });
475
- }, ɵ1 = function () { return noAuthentication; }, ɵ2 = function () { return noAuthentication; };
476
- var authReducer = i1.createReducer(startAuthentication, i1.on(signedIn, ɵ0), i1.on(signedOut, ɵ1), i1.on(signInFailed, ɵ2));
477
- function reducer(state, action) {
478
- return authReducer(state, action);
479
- }
480
-
481
- var featureKey = 'auth';
482
- var selectState = i1.createFeatureSelector(featureKey);
483
- var ɵ0$1 = function (state) { return !state.authenticating; }, ɵ1$1 = function (state) { return state.authenticated; };
484
- var isAuthenticated = rxjs.pipe(i1.select(selectState), operators.filter(ɵ0$1), operators.map(ɵ1$1));
485
- var ɵ2$1 = function (state) { return !state.authenticating; }, ɵ3 = function (state) { return state.user; };
486
- var getUser = rxjs.pipe(i1.select(selectState), operators.filter(ɵ2$1), operators.map(ɵ3));
487
-
488
- var AuthModule = /** @class */ (function () {
489
- function AuthModule() {
490
- }
491
- AuthModule.forRoot = function (config) {
492
- return {
493
- ngModule: AuthModule,
494
- providers: [
495
- {
496
- provide: AuthConfig,
497
- useValue: config,
498
- },
499
- {
500
- provide: http.HTTP_INTERCEPTORS,
501
- useClass: JwtInterceptor,
502
- multi: true,
503
- },
504
- ],
505
- };
506
- };
507
- return AuthModule;
508
- }());
509
- AuthModule.decorators = [
510
- { type: i0.NgModule, args: [{
511
- declarations: [],
512
- imports: [i1.StoreModule.forFeature(featureKey, reducer), effects.EffectsModule.forFeature([AuthEffects])],
513
- exports: [],
514
- },] }
515
- ];
516
-
517
- var AuthGuard = /** @class */ (function () {
518
- function AuthGuard(store) {
519
- this.store = store;
520
- this.authenticated$ = this.store.pipe(isAuthenticated);
521
- }
522
- AuthGuard.prototype.canActivate = function (next, state) {
523
- var _this = this;
524
- return this.authenticated$.pipe(operators.tap(function (auth) {
525
- if (!auth) {
526
- _this.store.dispatch(signIn({ returnUrl: state.url }));
527
- }
528
- }), operators.first());
529
- };
530
- return AuthGuard;
531
- }());
532
- AuthGuard.ɵprov = i0.ɵɵdefineInjectable({ factory: function AuthGuard_Factory() { return new AuthGuard(i0.ɵɵinject(i1.Store)); }, token: AuthGuard, providedIn: "root" });
533
- AuthGuard.decorators = [
534
- { type: i0.Injectable, args: [{
535
- providedIn: 'root',
536
- },] }
537
- ];
538
- AuthGuard.ctorParameters = function () { return [
539
- { type: i1.Store }
540
- ]; };
541
-
542
- /**
543
- * Generated bundle index. Do not edit.
544
- */
545
-
546
- exports.AuthGuard = AuthGuard;
547
- exports.AuthModule = AuthModule;
548
- exports.getUser = getUser;
549
- exports.isAuthenticated = isAuthenticated;
550
- exports.signIn = signIn;
551
- exports.signOut = signOut;
552
- exports.signedIn = signedIn;
553
- exports.signedOut = signedOut;
554
- exports.ɵa = signInFailed;
555
- exports.ɵb = featureKey;
556
- exports.ɵc = selectState;
557
- exports.ɵd = startAuthentication;
558
- exports.ɵe = reducer;
559
- exports.ɵf = AuthEffects;
560
- exports.ɵg = AuthService;
561
- exports.ɵh = AuthConfig;
562
- exports.ɵi = JwtInterceptor;
563
-
564
- Object.defineProperty(exports, '__esModule', { value: true });
565
-
566
- })));
567
- //# sourceMappingURL=thecla-auth0-angular.umd.js.map