@auth0/auth0-angular 1.11.1 → 2.0.0

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 (36) hide show
  1. package/README.md +7 -4
  2. package/{esm2015/auth0-auth0-angular.js → esm2020/auth0-auth0-angular.mjs} +0 -0
  3. package/{esm2015/lib/abstract-navigator.js → esm2020/lib/abstract-navigator.mjs} +6 -5
  4. package/esm2020/lib/auth.client.mjs +23 -0
  5. package/esm2020/lib/auth.config.mjs +97 -0
  6. package/{esm2015/lib/auth.guard.js → esm2020/lib/auth.guard.mjs} +3 -3
  7. package/esm2020/lib/auth.interceptor.mjs +134 -0
  8. package/esm2020/lib/auth.module.mjs +39 -0
  9. package/esm2020/lib/auth.service.mjs +229 -0
  10. package/esm2020/lib/auth.state.mjs +100 -0
  11. package/esm2020/lib/interfaces.mjs +2 -0
  12. package/esm2020/public-api.mjs +13 -0
  13. package/{esm2015/useragent.js → esm2020/useragent.mjs} +2 -2
  14. package/fesm2015/auth0-auth0-angular.mjs +678 -0
  15. package/fesm2015/auth0-auth0-angular.mjs.map +1 -0
  16. package/{fesm2015/auth0-auth0-angular.js → fesm2020/auth0-auth0-angular.mjs} +80 -135
  17. package/fesm2020/auth0-auth0-angular.mjs.map +1 -0
  18. package/lib/abstract-navigator.d.ts +1 -0
  19. package/lib/auth.config.d.ts +4 -134
  20. package/lib/auth.interceptor.d.ts +7 -1
  21. package/lib/auth.module.d.ts +1 -0
  22. package/lib/auth.service.d.ts +8 -67
  23. package/lib/auth.state.d.ts +3 -0
  24. package/lib/interfaces.d.ts +5 -0
  25. package/package.json +23 -10
  26. package/public-api.d.ts +1 -0
  27. package/bundles/auth0-auth0-angular.umd.js +0 -1148
  28. package/bundles/auth0-auth0-angular.umd.js.map +0 -1
  29. package/esm2015/lib/auth.client.js +0 -22
  30. package/esm2015/lib/auth.config.js +0 -95
  31. package/esm2015/lib/auth.interceptor.js +0 -129
  32. package/esm2015/lib/auth.module.js +0 -38
  33. package/esm2015/lib/auth.service.js +0 -294
  34. package/esm2015/lib/auth.state.js +0 -99
  35. package/esm2015/public-api.js +0 -12
  36. package/fesm2015/auth0-auth0-angular.js.map +0 -1
@@ -1,1148 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@auth0/auth0-spa-js'), require('@angular/router'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('@auth0/auth0-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@auth0/auth0-spa-js', '@angular/router', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.auth0 = global.auth0 || {}, global.auth0['auth0-angular'] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.i1, global.ng.router, global.ng.common));
5
- }(this, (function (exports, i0, rxjs, operators, i1, router, i1$1) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1);
29
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1$1);
30
-
31
- /******************************************************************************
32
- Copyright (c) Microsoft Corporation.
33
-
34
- Permission to use, copy, modify, and/or distribute this software for any
35
- purpose with or without fee is hereby granted.
36
-
37
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
38
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
40
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
41
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
42
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
43
- PERFORMANCE OF THIS SOFTWARE.
44
- ***************************************************************************** */
45
- /* global Reflect, Promise */
46
- var extendStatics = function (d, b) {
47
- extendStatics = Object.setPrototypeOf ||
48
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
49
- function (d, b) { for (var p in b)
50
- if (Object.prototype.hasOwnProperty.call(b, p))
51
- d[p] = b[p]; };
52
- return extendStatics(d, b);
53
- };
54
- function __extends(d, b) {
55
- if (typeof b !== "function" && b !== null)
56
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
57
- extendStatics(d, b);
58
- function __() { this.constructor = d; }
59
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
60
- }
61
- var __assign = function () {
62
- __assign = Object.assign || function __assign(t) {
63
- for (var s, i = 1, n = arguments.length; i < n; i++) {
64
- s = arguments[i];
65
- for (var p in s)
66
- if (Object.prototype.hasOwnProperty.call(s, p))
67
- t[p] = s[p];
68
- }
69
- return t;
70
- };
71
- return __assign.apply(this, arguments);
72
- };
73
- function __rest(s, e) {
74
- var t = {};
75
- for (var p in s)
76
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
77
- t[p] = s[p];
78
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
79
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
80
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
81
- t[p[i]] = s[p[i]];
82
- }
83
- return t;
84
- }
85
- function __decorate(decorators, target, key, desc) {
86
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
87
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
88
- r = Reflect.decorate(decorators, target, key, desc);
89
- else
90
- for (var i = decorators.length - 1; i >= 0; i--)
91
- if (d = decorators[i])
92
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
93
- return c > 3 && r && Object.defineProperty(target, key, r), r;
94
- }
95
- function __param(paramIndex, decorator) {
96
- return function (target, key) { decorator(target, key, paramIndex); };
97
- }
98
- function __metadata(metadataKey, metadataValue) {
99
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
100
- return Reflect.metadata(metadataKey, metadataValue);
101
- }
102
- function __awaiter(thisArg, _arguments, P, generator) {
103
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
104
- return new (P || (P = Promise))(function (resolve, reject) {
105
- function fulfilled(value) { try {
106
- step(generator.next(value));
107
- }
108
- catch (e) {
109
- reject(e);
110
- } }
111
- function rejected(value) { try {
112
- step(generator["throw"](value));
113
- }
114
- catch (e) {
115
- reject(e);
116
- } }
117
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
118
- step((generator = generator.apply(thisArg, _arguments || [])).next());
119
- });
120
- }
121
- function __generator(thisArg, body) {
122
- var _ = { label: 0, sent: function () { if (t[0] & 1)
123
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
124
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
125
- function verb(n) { return function (v) { return step([n, v]); }; }
126
- function step(op) {
127
- if (f)
128
- throw new TypeError("Generator is already executing.");
129
- while (_)
130
- try {
131
- 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)
132
- return t;
133
- if (y = 0, t)
134
- op = [op[0] & 2, t.value];
135
- switch (op[0]) {
136
- case 0:
137
- case 1:
138
- t = op;
139
- break;
140
- case 4:
141
- _.label++;
142
- return { value: op[1], done: false };
143
- case 5:
144
- _.label++;
145
- y = op[1];
146
- op = [0];
147
- continue;
148
- case 7:
149
- op = _.ops.pop();
150
- _.trys.pop();
151
- continue;
152
- default:
153
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
154
- _ = 0;
155
- continue;
156
- }
157
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
158
- _.label = op[1];
159
- break;
160
- }
161
- if (op[0] === 6 && _.label < t[1]) {
162
- _.label = t[1];
163
- t = op;
164
- break;
165
- }
166
- if (t && _.label < t[2]) {
167
- _.label = t[2];
168
- _.ops.push(op);
169
- break;
170
- }
171
- if (t[2])
172
- _.ops.pop();
173
- _.trys.pop();
174
- continue;
175
- }
176
- op = body.call(thisArg, _);
177
- }
178
- catch (e) {
179
- op = [6, e];
180
- y = 0;
181
- }
182
- finally {
183
- f = t = 0;
184
- }
185
- if (op[0] & 5)
186
- throw op[1];
187
- return { value: op[0] ? op[1] : void 0, done: true };
188
- }
189
- }
190
- var __createBinding = Object.create ? (function (o, m, k, k2) {
191
- if (k2 === undefined)
192
- k2 = k;
193
- var desc = Object.getOwnPropertyDescriptor(m, k);
194
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
195
- desc = { enumerable: true, get: function () { return m[k]; } };
196
- }
197
- Object.defineProperty(o, k2, desc);
198
- }) : (function (o, m, k, k2) {
199
- if (k2 === undefined)
200
- k2 = k;
201
- o[k2] = m[k];
202
- });
203
- function __exportStar(m, o) {
204
- for (var p in m)
205
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
206
- __createBinding(o, m, p);
207
- }
208
- function __values(o) {
209
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
210
- if (m)
211
- return m.call(o);
212
- if (o && typeof o.length === "number")
213
- return {
214
- next: function () {
215
- if (o && i >= o.length)
216
- o = void 0;
217
- return { value: o && o[i++], done: !o };
218
- }
219
- };
220
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
221
- }
222
- function __read(o, n) {
223
- var m = typeof Symbol === "function" && o[Symbol.iterator];
224
- if (!m)
225
- return o;
226
- var i = m.call(o), r, ar = [], e;
227
- try {
228
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
229
- ar.push(r.value);
230
- }
231
- catch (error) {
232
- e = { error: error };
233
- }
234
- finally {
235
- try {
236
- if (r && !r.done && (m = i["return"]))
237
- m.call(i);
238
- }
239
- finally {
240
- if (e)
241
- throw e.error;
242
- }
243
- }
244
- return ar;
245
- }
246
- /** @deprecated */
247
- function __spread() {
248
- for (var ar = [], i = 0; i < arguments.length; i++)
249
- ar = ar.concat(__read(arguments[i]));
250
- return ar;
251
- }
252
- /** @deprecated */
253
- function __spreadArrays() {
254
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
255
- s += arguments[i].length;
256
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
257
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
258
- r[k] = a[j];
259
- return r;
260
- }
261
- function __spreadArray(to, from, pack) {
262
- if (pack || arguments.length === 2)
263
- for (var i = 0, l = from.length, ar; i < l; i++) {
264
- if (ar || !(i in from)) {
265
- if (!ar)
266
- ar = Array.prototype.slice.call(from, 0, i);
267
- ar[i] = from[i];
268
- }
269
- }
270
- return to.concat(ar || Array.prototype.slice.call(from));
271
- }
272
- function __await(v) {
273
- return this instanceof __await ? (this.v = v, this) : new __await(v);
274
- }
275
- function __asyncGenerator(thisArg, _arguments, generator) {
276
- if (!Symbol.asyncIterator)
277
- throw new TypeError("Symbol.asyncIterator is not defined.");
278
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
279
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
280
- function verb(n) { if (g[n])
281
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
282
- function resume(n, v) { try {
283
- step(g[n](v));
284
- }
285
- catch (e) {
286
- settle(q[0][3], e);
287
- } }
288
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
289
- function fulfill(value) { resume("next", value); }
290
- function reject(value) { resume("throw", value); }
291
- function settle(f, v) { if (f(v), q.shift(), q.length)
292
- resume(q[0][0], q[0][1]); }
293
- }
294
- function __asyncDelegator(o) {
295
- var i, p;
296
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
297
- 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; }
298
- }
299
- function __asyncValues(o) {
300
- if (!Symbol.asyncIterator)
301
- throw new TypeError("Symbol.asyncIterator is not defined.");
302
- var m = o[Symbol.asyncIterator], i;
303
- 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);
304
- 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); }); }; }
305
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
306
- }
307
- function __makeTemplateObject(cooked, raw) {
308
- if (Object.defineProperty) {
309
- Object.defineProperty(cooked, "raw", { value: raw });
310
- }
311
- else {
312
- cooked.raw = raw;
313
- }
314
- return cooked;
315
- }
316
- ;
317
- var __setModuleDefault = Object.create ? (function (o, v) {
318
- Object.defineProperty(o, "default", { enumerable: true, value: v });
319
- }) : function (o, v) {
320
- o["default"] = v;
321
- };
322
- function __importStar(mod) {
323
- if (mod && mod.__esModule)
324
- return mod;
325
- var result = {};
326
- if (mod != null)
327
- for (var k in mod)
328
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
329
- __createBinding(result, mod, k);
330
- __setModuleDefault(result, mod);
331
- return result;
332
- }
333
- function __importDefault(mod) {
334
- return (mod && mod.__esModule) ? mod : { default: mod };
335
- }
336
- function __classPrivateFieldGet(receiver, state, kind, f) {
337
- if (kind === "a" && !f)
338
- throw new TypeError("Private accessor was defined without a getter");
339
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
340
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
341
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
342
- }
343
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
344
- if (kind === "m")
345
- throw new TypeError("Private method is not writable");
346
- if (kind === "a" && !f)
347
- throw new TypeError("Private accessor was defined without a setter");
348
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
349
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
350
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
351
- }
352
- function __classPrivateFieldIn(state, receiver) {
353
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
354
- throw new TypeError("Cannot use 'in' operator on non-object");
355
- return typeof state === "function" ? receiver === state : state.has(receiver);
356
- }
357
-
358
- var useragent = { name: '@auth0/auth0-angular', version: '1.11.1' };
359
-
360
- var Auth0ClientFactory = /** @class */ (function () {
361
- function Auth0ClientFactory() {
362
- }
363
- Auth0ClientFactory.createClient = function (configFactory) {
364
- var config = configFactory.get();
365
- if (!config) {
366
- throw new Error('Configuration must be specified either through AuthModule.forRoot or through AuthClientConfig.set');
367
- }
368
- var redirectUri = config.redirectUri, clientId = config.clientId, maxAge = config.maxAge, httpInterceptor = config.httpInterceptor, rest = __rest(config, ["redirectUri", "clientId", "maxAge", "httpInterceptor"]);
369
- return new i1.Auth0Client(Object.assign(Object.assign({ redirect_uri: redirectUri || window.location.origin, client_id: clientId, max_age: maxAge }, rest), { auth0Client: {
370
- name: useragent.name,
371
- version: useragent.version,
372
- env: {
373
- 'angular/core': i0.VERSION.full,
374
- },
375
- } }));
376
- };
377
- return Auth0ClientFactory;
378
- }());
379
- var Auth0ClientService = new i0.InjectionToken('auth0.client');
380
-
381
- /**
382
- * A custom type guard to help identify route definitions that are actually HttpInterceptorRouteConfig types.
383
- * @param def The route definition type
384
- */
385
- function isHttpInterceptorRouteConfig(def) {
386
- return typeof def !== 'string';
387
- }
388
- /**
389
- * Gets and sets configuration for the internal Auth0 client. This can be
390
- * used to provide configuration outside of using AuthModule.forRoot, i.e. from
391
- * a factory provided by APP_INITIALIZER.
392
- *
393
- * @usage
394
- *
395
- * ```js
396
- * // app.module.ts
397
- * // ---------------------------
398
- * import { AuthModule, AuthClientConfig } from '@auth0/auth0-angular';
399
- *
400
- * // Provide an initializer function that returns a Promise
401
- * function configInitializer(
402
- * http: HttpClient,
403
- * config: AuthClientConfig
404
- * ) {
405
- * return () =>
406
- * http
407
- * .get('/config')
408
- * .toPromise()
409
- * .then((loadedConfig: any) => config.set(loadedConfig)); // Set the config that was loaded asynchronously here
410
- * }
411
- *
412
- * // Provide APP_INITIALIZER with this function. Note that there is no config passed to AuthModule.forRoot
413
- * imports: [
414
- * // other imports..
415
- *
416
- * HttpClientModule,
417
- * AuthModule.forRoot(), //<- don't pass any config here
418
- * ],
419
- * providers: [
420
- * {
421
- * provide: APP_INITIALIZER,
422
- * useFactory: configInitializer, // <- pass your initializer function here
423
- * deps: [HttpClient, AuthClientConfig],
424
- * multi: true,
425
- * },
426
- * ],
427
- * ```
428
- *
429
- */
430
- var AuthClientConfig = /** @class */ (function () {
431
- function AuthClientConfig(config) {
432
- if (config) {
433
- this.set(config);
434
- }
435
- }
436
- /**
437
- * Sets configuration to be read by other consumers of the service (see usage notes)
438
- * @param config The configuration to set
439
- */
440
- AuthClientConfig.prototype.set = function (config) {
441
- this.config = config;
442
- };
443
- /**
444
- * Gets the config that has been set by other consumers of the service
445
- */
446
- AuthClientConfig.prototype.get = function () {
447
- return this.config;
448
- };
449
- return AuthClientConfig;
450
- }());
451
- AuthClientConfig.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthClientConfig, deps: [{ token: AuthConfigService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
452
- AuthClientConfig.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthClientConfig, providedIn: 'root' });
453
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthClientConfig, decorators: [{
454
- type: i0.Injectable,
455
- args: [{ providedIn: 'root' }]
456
- }], ctorParameters: function () {
457
- return [{ type: undefined, decorators: [{
458
- type: i0.Optional
459
- }, {
460
- type: i0.Inject,
461
- args: [AuthConfigService]
462
- }] }];
463
- } });
464
- /**
465
- * Injection token for accessing configuration.
466
- *
467
- * @usageNotes
468
- *
469
- * Use the `Inject` decorator to access the configuration from a service or component:
470
- *
471
- * ```
472
- * class MyService(@Inject(AuthConfigService) config: AuthConfig) {}
473
- * ```
474
- */
475
- var AuthConfigService = new i0.InjectionToken('auth0-angular.config');
476
-
477
- var AbstractNavigator = /** @class */ (function () {
478
- function AbstractNavigator(location, injector) {
479
- this.location = location;
480
- try {
481
- this.router = injector.get(router.Router);
482
- }
483
- catch (_a) { }
484
- }
485
- /**
486
- * Navigates to the specified url. The router will be used if one is available, otherwise it falls back
487
- * to `window.history.replaceState`.
488
- * @param url The url to navigate to
489
- */
490
- AbstractNavigator.prototype.navigateByUrl = function (url) {
491
- if (this.router) {
492
- this.router.navigateByUrl(url);
493
- return;
494
- }
495
- this.location.replaceState(url);
496
- };
497
- return AbstractNavigator;
498
- }());
499
- AbstractNavigator.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AbstractNavigator, deps: [{ token: i1__namespace.Location }, { token: i0__namespace.Injector }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
500
- AbstractNavigator.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AbstractNavigator, providedIn: 'root' });
501
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AbstractNavigator, decorators: [{
502
- type: i0.Injectable,
503
- args: [{
504
- providedIn: 'root',
505
- }]
506
- }], ctorParameters: function () { return [{ type: i1__namespace.Location }, { type: i0__namespace.Injector }]; } });
507
-
508
- /**
509
- * Tracks the Authentication State for the SDK
510
- */
511
- var AuthState = /** @class */ (function () {
512
- function AuthState(auth0Client) {
513
- var _this = this;
514
- this.auth0Client = auth0Client;
515
- this.isLoadingSubject$ = new rxjs.BehaviorSubject(true);
516
- this.refresh$ = new rxjs.Subject();
517
- this.accessToken$ = new rxjs.ReplaySubject(1);
518
- this.errorSubject$ = new rxjs.ReplaySubject(1);
519
- /**
520
- * Emits boolean values indicating the loading state of the SDK.
521
- */
522
- this.isLoading$ = this.isLoadingSubject$.asObservable();
523
- /**
524
- * Trigger used to pull User information from the Auth0Client.
525
- * Triggers when the access token has changed.
526
- */
527
- this.accessTokenTrigger$ = this.accessToken$.pipe(operators.scan(function (acc, current) {
528
- return {
529
- previous: acc.current,
530
- current: current,
531
- };
532
- }, { current: null, previous: null }), operators.filter(function (_a) {
533
- var previous = _a.previous, current = _a.current;
534
- return previous !== current;
535
- }));
536
- /**
537
- * Trigger used to pull User information from the Auth0Client.
538
- * Triggers when an event occurs that needs to retrigger the User Profile information.
539
- * Events: Login, Access Token change and Logout
540
- */
541
- this.isAuthenticatedTrigger$ = this.isLoading$.pipe(operators.filter(function (loading) { return !loading; }), operators.distinctUntilChanged(), operators.switchMap(function () {
542
- // To track the value of isAuthenticated over time, we need to merge:
543
- // - the current value
544
- // - the value whenever the access token changes. (this should always be true of there is an access token
545
- // but it is safer to pass this through this.auth0Client.isAuthenticated() nevertheless)
546
- // - the value whenever refreshState$ emits
547
- return rxjs.merge(rxjs.defer(function () { return _this.auth0Client.isAuthenticated(); }), _this.accessTokenTrigger$.pipe(operators.mergeMap(function () { return _this.auth0Client.isAuthenticated(); })), _this.refresh$.pipe(operators.mergeMap(function () { return _this.auth0Client.isAuthenticated(); })));
548
- }));
549
- /**
550
- * Emits boolean values indicating the authentication state of the user. If `true`, it means a user has authenticated.
551
- * This depends on the value of `isLoading$`, so there is no need to manually check the loading state of the SDK.
552
- */
553
- this.isAuthenticated$ = this.isAuthenticatedTrigger$.pipe(operators.distinctUntilChanged(), operators.shareReplay(1));
554
- /**
555
- * Emits details about the authenticated user, or null if not authenticated.
556
- */
557
- this.user$ = this.isAuthenticatedTrigger$.pipe(operators.concatMap(function (authenticated) { return authenticated ? _this.auth0Client.getUser() : rxjs.of(null); }));
558
- /**
559
- * Emits ID token claims when authenticated, or null if not authenticated.
560
- */
561
- this.idTokenClaims$ = this.isAuthenticatedTrigger$.pipe(operators.concatMap(function (authenticated) { return authenticated ? _this.auth0Client.getIdTokenClaims() : rxjs.of(null); }));
562
- /**
563
- * Emits errors that occur during login, or when checking for an active session on startup.
564
- */
565
- this.error$ = this.errorSubject$.asObservable();
566
- }
567
- /**
568
- * Update the isLoading state using the provided value
569
- * @param isLoading The new value for isLoading
570
- */
571
- AuthState.prototype.setIsLoading = function (isLoading) {
572
- this.isLoadingSubject$.next(isLoading);
573
- };
574
- /**
575
- * Refresh the state to ensure the `isAuthenticated`, `user$` and `idTokenClaims$`
576
- * reflect the most up-to-date values from Auth0Client.
577
- */
578
- AuthState.prototype.refresh = function () {
579
- this.refresh$.next();
580
- };
581
- /**
582
- * Update the access token, doing so will also refresh the state.
583
- * @param accessToken The new Access Token
584
- */
585
- AuthState.prototype.setAccessToken = function (accessToken) {
586
- this.accessToken$.next(accessToken);
587
- };
588
- /**
589
- * Emits the error in the `error$` observable.
590
- * @param error The new error
591
- */
592
- AuthState.prototype.setError = function (error) {
593
- this.errorSubject$.next(error);
594
- };
595
- return AuthState;
596
- }());
597
- AuthState.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthState, deps: [{ token: Auth0ClientService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
598
- AuthState.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthState, providedIn: 'root' });
599
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthState, decorators: [{
600
- type: i0.Injectable,
601
- args: [{ providedIn: 'root' }]
602
- }], ctorParameters: function () {
603
- return [{ type: i1__namespace$1.Auth0Client, decorators: [{
604
- type: i0.Inject,
605
- args: [Auth0ClientService]
606
- }] }];
607
- } });
608
-
609
- var AuthService = /** @class */ (function () {
610
- function AuthService(auth0Client, configFactory, navigator, authState) {
611
- var _this = this;
612
- this.auth0Client = auth0Client;
613
- this.configFactory = configFactory;
614
- this.navigator = navigator;
615
- this.authState = authState;
616
- this.appStateSubject$ = new rxjs.ReplaySubject(1);
617
- // https://stackoverflow.com/a/41177163
618
- this.ngUnsubscribe$ = new rxjs.Subject();
619
- /**
620
- * Emits boolean values indicating the loading state of the SDK.
621
- */
622
- this.isLoading$ = this.authState.isLoading$;
623
- /**
624
- * Emits boolean values indicating the authentication state of the user. If `true`, it means a user has authenticated.
625
- * This depends on the value of `isLoading$`, so there is no need to manually check the loading state of the SDK.
626
- */
627
- this.isAuthenticated$ = this.authState.isAuthenticated$;
628
- /**
629
- * Emits details about the authenticated user, or null if not authenticated.
630
- */
631
- this.user$ = this.authState.user$;
632
- /**
633
- * Emits ID token claims when authenticated, or null if not authenticated.
634
- */
635
- this.idTokenClaims$ = this.authState.idTokenClaims$;
636
- /**
637
- * Emits errors that occur during login, or when checking for an active session on startup.
638
- */
639
- this.error$ = this.authState.error$;
640
- /**
641
- * Emits the value (if any) that was passed to the `loginWithRedirect` method call
642
- * but only **after** `handleRedirectCallback` is first called
643
- */
644
- this.appState$ = this.appStateSubject$.asObservable();
645
- var checkSessionOrCallback$ = function (isCallback) { return rxjs.iif(function () { return isCallback; }, _this.handleRedirectCallback(), rxjs.defer(function () { return _this.auth0Client.checkSession(); })); };
646
- this.shouldHandleCallback()
647
- .pipe(operators.switchMap(function (isCallback) { return checkSessionOrCallback$(isCallback).pipe(operators.catchError(function (error) {
648
- var config = _this.configFactory.get();
649
- _this.navigator.navigateByUrl(config.errorPath || '/');
650
- _this.authState.setError(error);
651
- return rxjs.of(undefined);
652
- })); }), operators.tap(function () {
653
- _this.authState.setIsLoading(false);
654
- }), operators.takeUntil(this.ngUnsubscribe$))
655
- .subscribe();
656
- }
657
- /**
658
- * Called when the service is destroyed
659
- */
660
- AuthService.prototype.ngOnDestroy = function () {
661
- // https://stackoverflow.com/a/41177163
662
- this.ngUnsubscribe$.next();
663
- this.ngUnsubscribe$.complete();
664
- };
665
- /**
666
- * ```js
667
- * loginWithRedirect(options);
668
- * ```
669
- *
670
- * Performs a redirect to `/authorize` using the parameters
671
- * provided as arguments. Random and secure `state` and `nonce`
672
- * parameters will be auto-generated.
673
- *
674
- * @param options The login options
675
- */
676
- AuthService.prototype.loginWithRedirect = function (options) {
677
- return rxjs.from(this.auth0Client.loginWithRedirect(options));
678
- };
679
- /**
680
- * ```js
681
- * await loginWithPopup(options);
682
- * ```
683
- *
684
- * Opens a popup with the `/authorize` URL using the parameters
685
- * provided as arguments. Random and secure `state` and `nonce`
686
- * parameters will be auto-generated. If the response is successful,
687
- * results will be valid according to their expiration times.
688
- *
689
- * IMPORTANT: This method has to be called from an event handler
690
- * that was started by the user like a button click, for example,
691
- * otherwise the popup will be blocked in most browsers.
692
- *
693
- * @param options The login options
694
- * @param config Configuration for the popup window
695
- */
696
- AuthService.prototype.loginWithPopup = function (options, config) {
697
- var _this = this;
698
- return rxjs.from(this.auth0Client.loginWithPopup(options, config).then(function () {
699
- _this.authState.refresh();
700
- }));
701
- };
702
- /**
703
- * ```js
704
- * logout();
705
- * ```
706
- *
707
- * Clears the application session and performs a redirect to `/v2/logout`, using
708
- * the parameters provided as arguments, to clear the Auth0 session.
709
- * If the `federated` option is specified it also clears the Identity Provider session.
710
- * If the `localOnly` option is specified, it only clears the application session.
711
- * It is invalid to set both the `federated` and `localOnly` options to `true`,
712
- * and an error will be thrown if you do.
713
- * [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
714
- *
715
- * @param options The logout options
716
- */
717
- AuthService.prototype.logout = function (options) {
718
- var _this = this;
719
- var logout = this.auth0Client.logout(options) || rxjs.of(null);
720
- rxjs.from(logout).subscribe(function () {
721
- if (options === null || options === void 0 ? void 0 : options.localOnly) {
722
- _this.authState.refresh();
723
- }
724
- });
725
- };
726
- /**
727
- * ```js
728
- * getAccessTokenSilently(options).subscribe(token => ...)
729
- * ```
730
- *
731
- * If there's a valid token stored, return it. Otherwise, opens an
732
- * iframe with the `/authorize` URL using the parameters provided
733
- * as arguments. Random and secure `state` and `nonce` parameters
734
- * will be auto-generated. If the response is successful, results
735
- * will be valid according to their expiration times.
736
- *
737
- * If refresh tokens are used, the token endpoint is called directly with the
738
- * 'refresh_token' grant. If no refresh token is available to make this call,
739
- * the SDK falls back to using an iframe to the '/authorize' URL.
740
- *
741
- * This method may use a web worker to perform the token call if the in-memory
742
- * cache is used.
743
- *
744
- * If an `audience` value is given to this function, the SDK always falls
745
- * back to using an iframe to make the token exchange.
746
- *
747
- * Note that in all cases, falling back to an iframe requires access to
748
- * the `auth0` cookie, and thus will not work in browsers that block third-party
749
- * cookies by default (Safari, Brave, etc).
750
- *
751
- * @param options The options for configuring the token fetch.
752
- */
753
- AuthService.prototype.getAccessTokenSilently = function (options) {
754
- var _this = this;
755
- if (options === void 0) { options = {}; }
756
- return rxjs.of(this.auth0Client).pipe(operators.concatMap(function (client) { return options.detailedResponse === true
757
- ? client.getTokenSilently(Object.assign(Object.assign({}, options), { detailedResponse: true }))
758
- : client.getTokenSilently(options); }), operators.tap(function (token) { return _this.authState.setAccessToken(typeof token === 'string' ? token : token.access_token); }), operators.catchError(function (error) {
759
- _this.authState.setError(error);
760
- _this.authState.refresh();
761
- return rxjs.throwError(error);
762
- }));
763
- };
764
- /**
765
- * ```js
766
- * getTokenWithPopup(options).subscribe(token => ...)
767
- * ```
768
- *
769
- * Get an access token interactively.
770
- *
771
- * Opens a popup with the `/authorize` URL using the parameters
772
- * provided as arguments. Random and secure `state` and `nonce`
773
- * parameters will be auto-generated. If the response is successful,
774
- * results will be valid according to their expiration times.
775
- */
776
- AuthService.prototype.getAccessTokenWithPopup = function (options) {
777
- var _this = this;
778
- return rxjs.of(this.auth0Client).pipe(operators.concatMap(function (client) { return client.getTokenWithPopup(options); }), operators.tap(function (token) { return _this.authState.setAccessToken(token); }), operators.catchError(function (error) {
779
- _this.authState.setError(error);
780
- _this.authState.refresh();
781
- return rxjs.throwError(error);
782
- }));
783
- };
784
- /**
785
- * ```js
786
- * getUser(options).subscribe(user => ...);
787
- * ```
788
- *
789
- * Returns the user information if available (decoded
790
- * from the `id_token`).
791
- *
792
- * If you provide an audience or scope, they should match an existing Access Token
793
- * (the SDK stores a corresponding ID Token with every Access Token, and uses the
794
- * scope and audience to look up the ID Token)
795
- *
796
- * @remarks
797
- *
798
- * The returned observable will emit once and then complete.
799
- *
800
- * @typeparam TUser The type to return, has to extend {@link User}.
801
- * @param options The options to get the user
802
- */
803
- AuthService.prototype.getUser = function (options) {
804
- var _this = this;
805
- return rxjs.defer(function () { return _this.auth0Client.getUser(options); });
806
- };
807
- /**
808
- * ```js
809
- * getIdTokenClaims(options).subscribe(claims => ...);
810
- * ```
811
- *
812
- * Returns all claims from the id_token if available.
813
- *
814
- * If you provide an audience or scope, they should match an existing Access Token
815
- * (the SDK stores a corresponding ID Token with every Access Token, and uses the
816
- * scope and audience to look up the ID Token)
817
- *
818
- * @remarks
819
- *
820
- * The returned observable will emit once and then complete.
821
- *
822
- * @param options The options to get the Id token claims
823
- */
824
- AuthService.prototype.getIdTokenClaims = function (options) {
825
- var _this = this;
826
- return rxjs.defer(function () { return _this.auth0Client.getIdTokenClaims(options); });
827
- };
828
- /**
829
- * ```js
830
- * handleRedirectCallback(url).subscribe(result => ...)
831
- * ```
832
- *
833
- * After the browser redirects back to the callback page,
834
- * call `handleRedirectCallback` to handle success and error
835
- * responses from Auth0. If the response is successful, results
836
- * will be valid according to their expiration times.
837
- *
838
- * Calling this method also refreshes the authentication and user states.
839
- *
840
- * @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
841
- */
842
- AuthService.prototype.handleRedirectCallback = function (url) {
843
- var _this = this;
844
- return rxjs.defer(function () { return _this.auth0Client.handleRedirectCallback(url); }).pipe(operators.withLatestFrom(this.authState.isLoading$), operators.tap(function (_b) {
845
- var _c = __read(_b, 2), result = _c[0], isLoading = _c[1];
846
- var _a;
847
- if (!isLoading) {
848
- _this.authState.refresh();
849
- }
850
- var appState = result === null || result === void 0 ? void 0 : result.appState;
851
- var target = (_a = appState === null || appState === void 0 ? void 0 : appState.target) !== null && _a !== void 0 ? _a : '/';
852
- if (appState) {
853
- _this.appStateSubject$.next(appState);
854
- }
855
- _this.navigator.navigateByUrl(target);
856
- }), operators.map(function (_b) {
857
- var _c = __read(_b, 1), result = _c[0];
858
- return result;
859
- }));
860
- };
861
- /**
862
- * ```js
863
- * buildAuthorizeUrl().subscribe(url => ...)
864
- * ```
865
- *
866
- * Builds an `/authorize` URL for loginWithRedirect using the parameters
867
- * provided as arguments. Random and secure `state` and `nonce`
868
- * parameters will be auto-generated.
869
- * @param options The options
870
- * @returns A URL to the authorize endpoint
871
- */
872
- AuthService.prototype.buildAuthorizeUrl = function (options) {
873
- var _this = this;
874
- return rxjs.defer(function () { return _this.auth0Client.buildAuthorizeUrl(options); });
875
- };
876
- /**
877
- * ```js
878
- * buildLogoutUrl().subscribe(url => ...)
879
- * ```
880
- * Builds a URL to the logout endpoint.
881
- *
882
- * @param options The options used to configure the parameters that appear in the logout endpoint URL.
883
- * @returns a URL to the logout endpoint using the parameters provided as arguments.
884
- */
885
- AuthService.prototype.buildLogoutUrl = function (options) {
886
- return rxjs.of(this.auth0Client.buildLogoutUrl(options));
887
- };
888
- AuthService.prototype.shouldHandleCallback = function () {
889
- var _this = this;
890
- return rxjs.of(location.search).pipe(operators.map(function (search) {
891
- return ((search.includes('code=') || search.includes('error=')) &&
892
- search.includes('state=') &&
893
- !_this.configFactory.get().skipRedirectCallback);
894
- }));
895
- };
896
- return AuthService;
897
- }());
898
- AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, deps: [{ token: Auth0ClientService }, { token: AuthClientConfig }, { token: AbstractNavigator }, { token: AuthState }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
899
- AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, providedIn: 'root' });
900
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthService, decorators: [{
901
- type: i0.Injectable,
902
- args: [{
903
- providedIn: 'root',
904
- }]
905
- }], ctorParameters: function () {
906
- return [{ type: i1__namespace$1.Auth0Client, decorators: [{
907
- type: i0.Inject,
908
- args: [Auth0ClientService]
909
- }] }, { type: AuthClientConfig }, { type: AbstractNavigator }, { type: AuthState }];
910
- } });
911
-
912
- var AuthGuard = /** @class */ (function () {
913
- function AuthGuard(auth) {
914
- this.auth = auth;
915
- }
916
- AuthGuard.prototype.canLoad = function (route, segments) {
917
- return this.auth.isAuthenticated$.pipe(operators.take(1));
918
- };
919
- AuthGuard.prototype.canActivate = function (next, state) {
920
- return this.redirectIfUnauthenticated(state);
921
- };
922
- AuthGuard.prototype.canActivateChild = function (childRoute, state) {
923
- return this.redirectIfUnauthenticated(state);
924
- };
925
- AuthGuard.prototype.redirectIfUnauthenticated = function (state) {
926
- var _this = this;
927
- return this.auth.isAuthenticated$.pipe(operators.tap(function (loggedIn) {
928
- if (!loggedIn) {
929
- _this.auth.loginWithRedirect({
930
- appState: { target: state.url },
931
- });
932
- }
933
- }));
934
- };
935
- return AuthGuard;
936
- }());
937
- AuthGuard.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthGuard, deps: [{ token: AuthService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
938
- AuthGuard.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthGuard, providedIn: 'root' });
939
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthGuard, decorators: [{
940
- type: i0.Injectable,
941
- args: [{
942
- providedIn: 'root',
943
- }]
944
- }], ctorParameters: function () { return [{ type: AuthService }]; } });
945
-
946
- var AuthModule = /** @class */ (function () {
947
- function AuthModule() {
948
- }
949
- /**
950
- * Initialize the authentication module system. Configuration can either be specified here,
951
- * or by calling AuthClientConfig.set (perhaps from an APP_INITIALIZER factory function).
952
- * @param config The optional configuration for the SDK.
953
- */
954
- AuthModule.forRoot = function (config) {
955
- return {
956
- ngModule: AuthModule,
957
- providers: [
958
- AuthService,
959
- AuthGuard,
960
- {
961
- provide: AuthConfigService,
962
- useValue: config,
963
- },
964
- {
965
- provide: Auth0ClientService,
966
- useFactory: Auth0ClientFactory.createClient,
967
- deps: [AuthClientConfig],
968
- },
969
- ],
970
- };
971
- };
972
- return AuthModule;
973
- }());
974
- AuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
975
- AuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthModule });
976
- AuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthModule });
977
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthModule, decorators: [{
978
- type: i0.NgModule
979
- }] });
980
-
981
- var AuthHttpInterceptor = /** @class */ (function () {
982
- function AuthHttpInterceptor(configFactory, auth0Client, authState) {
983
- this.configFactory = configFactory;
984
- this.auth0Client = auth0Client;
985
- this.authState = authState;
986
- }
987
- AuthHttpInterceptor.prototype.intercept = function (req, next) {
988
- var _this = this;
989
- var _a;
990
- var config = this.configFactory.get();
991
- if (!((_a = config.httpInterceptor) === null || _a === void 0 ? void 0 : _a.allowedList)) {
992
- return next.handle(req);
993
- }
994
- return this.findMatchingRoute(req, config.httpInterceptor).pipe(operators.concatMap(function (route) { return rxjs.iif(
995
- // Check if a route was matched
996
- function () { return route !== null; },
997
- // If we have a matching route, call getTokenSilently and attach the token to the
998
- // outgoing request
999
- rxjs.of(route).pipe(operators.pluck('tokenOptions'), operators.concatMap(function (options) {
1000
- return _this.getAccessTokenSilently(options).pipe(operators.catchError(function (err) {
1001
- if (_this.allowAnonymous(route, err)) {
1002
- return rxjs.of('');
1003
- }
1004
- _this.authState.setError(err);
1005
- return rxjs.throwError(err);
1006
- }));
1007
- }), operators.switchMap(function (token) {
1008
- // Clone the request and attach the bearer token
1009
- var clone = token
1010
- ? req.clone({
1011
- headers: req.headers.set('Authorization', "Bearer " + token),
1012
- })
1013
- : req;
1014
- return next.handle(clone);
1015
- })),
1016
- // If the URI being called was not found in our httpInterceptor config, simply
1017
- // pass the request through without attaching a token
1018
- next.handle(req)); }));
1019
- };
1020
- /**
1021
- * Duplicate of AuthService.getAccessTokenSilently, but with a slightly different error handling.
1022
- * Only used internally in the interceptor.
1023
- * @param options The options for configuring the token fetch.
1024
- */
1025
- AuthHttpInterceptor.prototype.getAccessTokenSilently = function (options) {
1026
- var _this = this;
1027
- return rxjs.of(this.auth0Client).pipe(operators.concatMap(function (client) { return client.getTokenSilently(options); }), operators.tap(function (token) { return _this.authState.setAccessToken(token); }), operators.catchError(function (error) {
1028
- _this.authState.refresh();
1029
- return rxjs.throwError(error);
1030
- }));
1031
- };
1032
- /**
1033
- * Strips the query and fragment from the given uri
1034
- * @param uri The uri to remove the query and fragment from
1035
- */
1036
- AuthHttpInterceptor.prototype.stripQueryFrom = function (uri) {
1037
- if (uri.indexOf('?') > -1) {
1038
- uri = uri.substr(0, uri.indexOf('?'));
1039
- }
1040
- if (uri.indexOf('#') > -1) {
1041
- uri = uri.substr(0, uri.indexOf('#'));
1042
- }
1043
- return uri;
1044
- };
1045
- /**
1046
- * Determines whether the specified route can have an access token attached to it, based on matching the HTTP request against
1047
- * the interceptor route configuration.
1048
- * @param route The route to test
1049
- * @param request The HTTP request
1050
- */
1051
- AuthHttpInterceptor.prototype.canAttachToken = function (route, request) {
1052
- var _this = this;
1053
- var testPrimitive = function (value) {
1054
- if (!value) {
1055
- return false;
1056
- }
1057
- var requestPath = _this.stripQueryFrom(request.url);
1058
- if (value === requestPath) {
1059
- return true;
1060
- }
1061
- // If the URL ends with an asterisk, match using startsWith.
1062
- return (value.indexOf('*') === value.length - 1 &&
1063
- request.url.startsWith(value.substr(0, value.length - 1)));
1064
- };
1065
- if (isHttpInterceptorRouteConfig(route)) {
1066
- if (route.httpMethod && route.httpMethod !== request.method) {
1067
- return false;
1068
- }
1069
- /* istanbul ignore if */
1070
- if (!route.uri && !route.uriMatcher) {
1071
- console.warn('Either a uri or uriMatcher is required when configuring the HTTP interceptor.');
1072
- }
1073
- return route.uriMatcher
1074
- ? route.uriMatcher(request.url)
1075
- : testPrimitive(route.uri);
1076
- }
1077
- return testPrimitive(route);
1078
- };
1079
- /**
1080
- * Tries to match a route from the SDK configuration to the HTTP request.
1081
- * If a match is found, the route configuration is returned.
1082
- * @param request The Http request
1083
- * @param config HttpInterceptorConfig
1084
- */
1085
- AuthHttpInterceptor.prototype.findMatchingRoute = function (request, config) {
1086
- var _this = this;
1087
- return rxjs.from(config.allowedList).pipe(operators.first(function (route) { return _this.canAttachToken(route, request); }, null));
1088
- };
1089
- AuthHttpInterceptor.prototype.allowAnonymous = function (route, err) {
1090
- return (!!route &&
1091
- isHttpInterceptorRouteConfig(route) &&
1092
- !!route.allowAnonymous &&
1093
- ['login_required', 'consent_required'].includes(err.error));
1094
- };
1095
- return AuthHttpInterceptor;
1096
- }());
1097
- AuthHttpInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthHttpInterceptor, deps: [{ token: AuthClientConfig }, { token: Auth0ClientService }, { token: AuthState }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1098
- AuthHttpInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthHttpInterceptor });
1099
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: AuthHttpInterceptor, decorators: [{
1100
- type: i0.Injectable
1101
- }], ctorParameters: function () {
1102
- return [{ type: AuthClientConfig }, { type: i1__namespace$1.Auth0Client, decorators: [{
1103
- type: i0.Inject,
1104
- args: [Auth0ClientService]
1105
- }] }, { type: AuthState }];
1106
- } });
1107
-
1108
- /*
1109
- * Public API Surface of auth0-angular
1110
- */
1111
-
1112
- /**
1113
- * Generated bundle index. Do not edit.
1114
- */
1115
-
1116
- Object.defineProperty(exports, 'InMemoryCache', {
1117
- enumerable: true,
1118
- get: function () {
1119
- return i1.InMemoryCache;
1120
- }
1121
- });
1122
- Object.defineProperty(exports, 'LocalStorageCache', {
1123
- enumerable: true,
1124
- get: function () {
1125
- return i1.LocalStorageCache;
1126
- }
1127
- });
1128
- Object.defineProperty(exports, 'User', {
1129
- enumerable: true,
1130
- get: function () {
1131
- return i1.User;
1132
- }
1133
- });
1134
- exports.Auth0ClientFactory = Auth0ClientFactory;
1135
- exports.Auth0ClientService = Auth0ClientService;
1136
- exports.AuthClientConfig = AuthClientConfig;
1137
- exports.AuthConfigService = AuthConfigService;
1138
- exports.AuthGuard = AuthGuard;
1139
- exports.AuthHttpInterceptor = AuthHttpInterceptor;
1140
- exports.AuthModule = AuthModule;
1141
- exports.AuthService = AuthService;
1142
- exports.AuthState = AuthState;
1143
- exports.isHttpInterceptorRouteConfig = isHttpInterceptorRouteConfig;
1144
-
1145
- Object.defineProperty(exports, '__esModule', { value: true });
1146
-
1147
- })));
1148
- //# sourceMappingURL=auth0-auth0-angular.umd.js.map