@azure/msal-angular 2.0.4 → 2.1.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 (40) hide show
  1. package/IMsalService.d.ts +14 -14
  2. package/LICENSE +20 -20
  3. package/README.md +150 -150
  4. package/azure-msal-angular.d.ts +4 -4
  5. package/azure-msal-angular.metadata.json +1 -1
  6. package/bundles/azure-msal-angular.umd.js +919 -892
  7. package/bundles/azure-msal-angular.umd.js.map +1 -1
  8. package/bundles/azure-msal-angular.umd.min.js +2 -2
  9. package/bundles/azure-msal-angular.umd.min.js.map +1 -1
  10. package/constants.d.ts +4 -4
  11. package/esm2015/IMsalService.js +6 -6
  12. package/esm2015/azure-msal-angular.js +4 -4
  13. package/esm2015/constants.js +9 -9
  14. package/esm2015/msal.broadcast.service.js +36 -36
  15. package/esm2015/msal.guard.config.js +6 -6
  16. package/esm2015/msal.guard.js +189 -168
  17. package/esm2015/msal.interceptor.config.js +6 -6
  18. package/esm2015/msal.interceptor.js +208 -208
  19. package/esm2015/msal.module.js +46 -46
  20. package/esm2015/msal.navigation.client.js +53 -53
  21. package/esm2015/msal.redirect.component.js +30 -30
  22. package/esm2015/msal.service.js +74 -74
  23. package/esm2015/packageMetadata.js +4 -4
  24. package/esm2015/public-api.js +18 -18
  25. package/fesm2015/azure-msal-angular.js +589 -568
  26. package/fesm2015/azure-msal-angular.js.map +1 -1
  27. package/msal.broadcast.service.d.ts +12 -12
  28. package/msal.guard.config.d.ts +9 -9
  29. package/msal.guard.d.ts +40 -39
  30. package/msal.guard.d.ts.map +1 -1
  31. package/msal.interceptor.config.d.ts +17 -17
  32. package/msal.interceptor.d.ts +49 -49
  33. package/msal.module.d.ts +7 -7
  34. package/msal.navigation.client.d.ts +16 -16
  35. package/msal.redirect.component.d.ts +12 -12
  36. package/msal.service.d.ts +27 -27
  37. package/msal.service.d.ts.map +1 -1
  38. package/package.json +2 -2
  39. package/packageMetadata.d.ts +2 -2
  40. package/public-api.d.ts +16 -16
@@ -4,919 +4,946 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.azure = global.azure || {}, global.azure['msal-angular'] = {}), global.ng.core, global.ng.common, global['@azure/msal-browser'], global.rxjs, global.ng.router, global.rxjs.operators));
5
5
  }(this, (function (exports, core, common, msalBrowser, rxjs, router, operators) { 'use strict';
6
6
 
7
- /*
8
- * Copyright (c) Microsoft Corporation. All rights reserved.
9
- * Licensed under the MIT License.
10
- */
11
- var MSAL_INSTANCE = new core.InjectionToken("MSAL_INSTANCE");
12
- var MSAL_GUARD_CONFIG = new core.InjectionToken("MSAL_GUARD_CONFIG");
7
+ /*
8
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9
+ * Licensed under the MIT License.
10
+ */
11
+ var MSAL_INSTANCE = new core.InjectionToken("MSAL_INSTANCE");
12
+ var MSAL_GUARD_CONFIG = new core.InjectionToken("MSAL_GUARD_CONFIG");
13
13
  var MSAL_INTERCEPTOR_CONFIG = new core.InjectionToken("MSAL_INTERCEPTOR_CONFIG");
14
14
 
15
- /* eslint-disable header/header */
16
- var name = "@azure/msal-angular";
17
- var version = "2.0.4";
15
+ /* eslint-disable header/header */
16
+ var name = "@azure/msal-angular";
17
+ var version = "2.1.1";
18
18
 
19
- /*
20
- * Copyright (c) Microsoft Corporation. All rights reserved.
21
- * Licensed under the MIT License.
22
- */
23
- var MsalService = /** @class */ (function () {
24
- function MsalService(instance, location) {
25
- this.instance = instance;
26
- this.location = location;
27
- var hash = this.location.path(true).split("#").pop();
28
- if (hash) {
29
- this.redirectHash = "#" + hash;
30
- }
31
- this.instance.initializeWrapperLibrary(msalBrowser.WrapperSKU.Angular, version);
32
- }
33
- MsalService.prototype.acquireTokenPopup = function (request) {
34
- return rxjs.from(this.instance.acquireTokenPopup(request));
35
- };
36
- MsalService.prototype.acquireTokenRedirect = function (request) {
37
- return rxjs.from(this.instance.acquireTokenRedirect(request));
38
- };
39
- MsalService.prototype.acquireTokenSilent = function (silentRequest) {
40
- return rxjs.from(this.instance.acquireTokenSilent(silentRequest));
41
- };
42
- MsalService.prototype.handleRedirectObservable = function (hash) {
43
- return rxjs.from(this.instance.handleRedirectPromise(hash || this.redirectHash));
44
- };
45
- MsalService.prototype.loginPopup = function (request) {
46
- return rxjs.from(this.instance.loginPopup(request));
47
- };
48
- MsalService.prototype.loginRedirect = function (request) {
49
- return rxjs.from(this.instance.loginRedirect(request));
50
- };
51
- MsalService.prototype.logout = function (logoutRequest) {
52
- return rxjs.from(this.instance.logout(logoutRequest));
53
- };
54
- MsalService.prototype.logoutRedirect = function (logoutRequest) {
55
- return rxjs.from(this.instance.logoutRedirect(logoutRequest));
56
- };
57
- MsalService.prototype.logoutPopup = function (logoutRequest) {
58
- return rxjs.from(this.instance.logoutPopup(logoutRequest));
59
- };
60
- MsalService.prototype.ssoSilent = function (request) {
61
- return rxjs.from(this.instance.ssoSilent(request));
62
- };
63
- /**
64
- * Gets logger for msal-angular.
65
- * If no logger set, returns logger instance created with same options as msal-browser
66
- */
67
- MsalService.prototype.getLogger = function () {
68
- if (!this.logger) {
69
- this.logger = this.instance.getLogger().clone(name, version);
70
- }
71
- return this.logger;
72
- };
73
- // Create a logger instance for msal-angular with the same options as msal-browser
74
- MsalService.prototype.setLogger = function (logger) {
75
- this.logger = logger.clone(name, version);
76
- this.instance.setLogger(logger);
77
- };
78
- return MsalService;
79
- }());
80
- MsalService.decorators = [
81
- { type: core.Injectable }
82
- ];
83
- MsalService.ctorParameters = function () { return [
84
- { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INSTANCE,] }] },
85
- { type: common.Location }
19
+ /*
20
+ * Copyright (c) Microsoft Corporation. All rights reserved.
21
+ * Licensed under the MIT License.
22
+ */
23
+ var MsalService = /** @class */ (function () {
24
+ function MsalService(instance, location) {
25
+ this.instance = instance;
26
+ this.location = location;
27
+ var hash = this.location.path(true).split("#").pop();
28
+ if (hash) {
29
+ this.redirectHash = "#" + hash;
30
+ }
31
+ this.instance.initializeWrapperLibrary(msalBrowser.WrapperSKU.Angular, version);
32
+ }
33
+ MsalService.prototype.acquireTokenPopup = function (request) {
34
+ return rxjs.from(this.instance.acquireTokenPopup(request));
35
+ };
36
+ MsalService.prototype.acquireTokenRedirect = function (request) {
37
+ return rxjs.from(this.instance.acquireTokenRedirect(request));
38
+ };
39
+ MsalService.prototype.acquireTokenSilent = function (silentRequest) {
40
+ return rxjs.from(this.instance.acquireTokenSilent(silentRequest));
41
+ };
42
+ MsalService.prototype.handleRedirectObservable = function (hash) {
43
+ return rxjs.from(this.instance.handleRedirectPromise(hash || this.redirectHash));
44
+ };
45
+ MsalService.prototype.loginPopup = function (request) {
46
+ return rxjs.from(this.instance.loginPopup(request));
47
+ };
48
+ MsalService.prototype.loginRedirect = function (request) {
49
+ return rxjs.from(this.instance.loginRedirect(request));
50
+ };
51
+ MsalService.prototype.logout = function (logoutRequest) {
52
+ return rxjs.from(this.instance.logout(logoutRequest));
53
+ };
54
+ MsalService.prototype.logoutRedirect = function (logoutRequest) {
55
+ return rxjs.from(this.instance.logoutRedirect(logoutRequest));
56
+ };
57
+ MsalService.prototype.logoutPopup = function (logoutRequest) {
58
+ return rxjs.from(this.instance.logoutPopup(logoutRequest));
59
+ };
60
+ MsalService.prototype.ssoSilent = function (request) {
61
+ return rxjs.from(this.instance.ssoSilent(request));
62
+ };
63
+ /**
64
+ * Gets logger for msal-angular.
65
+ * If no logger set, returns logger instance created with same options as msal-browser
66
+ */
67
+ MsalService.prototype.getLogger = function () {
68
+ if (!this.logger) {
69
+ this.logger = this.instance.getLogger().clone(name, version);
70
+ }
71
+ return this.logger;
72
+ };
73
+ // Create a logger instance for msal-angular with the same options as msal-browser
74
+ MsalService.prototype.setLogger = function (logger) {
75
+ this.logger = logger.clone(name, version);
76
+ this.instance.setLogger(logger);
77
+ };
78
+ return MsalService;
79
+ }());
80
+ MsalService.decorators = [
81
+ { type: core.Injectable }
82
+ ];
83
+ MsalService.ctorParameters = function () { return [
84
+ { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INSTANCE,] }] },
85
+ { type: common.Location }
86
86
  ]; };
87
87
 
88
- /*
89
- * Copyright (c) Microsoft Corporation. All rights reserved.
90
- * Licensed under the MIT License.
91
- */
92
- var MsalBroadcastService = /** @class */ (function () {
93
- function MsalBroadcastService(msalInstance, authService) {
94
- var _this = this;
95
- this.msalInstance = msalInstance;
96
- this.authService = authService;
97
- this._msalSubject = new rxjs.Subject();
98
- this.msalSubject$ = this._msalSubject.asObservable();
99
- // InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
100
- this._inProgress = new rxjs.BehaviorSubject(msalBrowser.InteractionStatus.Startup);
101
- this.inProgress$ = this._inProgress.asObservable();
102
- this.msalInstance.addEventCallback(function (message) {
103
- _this._msalSubject.next(message);
104
- var status = msalBrowser.EventMessageUtils.getInteractionStatusFromEvent(message, _this._inProgress.value);
105
- if (status !== null) {
106
- _this.authService.getLogger().verbose("BroadcastService - " + message.eventType + " results in setting inProgress from " + _this._inProgress.value + " to " + status);
107
- _this._inProgress.next(status);
108
- }
109
- });
110
- }
111
- return MsalBroadcastService;
112
- }());
113
- MsalBroadcastService.decorators = [
114
- { type: core.Injectable }
115
- ];
116
- MsalBroadcastService.ctorParameters = function () { return [
117
- { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INSTANCE,] }] },
118
- { type: MsalService }
88
+ /*
89
+ * Copyright (c) Microsoft Corporation. All rights reserved.
90
+ * Licensed under the MIT License.
91
+ */
92
+ var MsalBroadcastService = /** @class */ (function () {
93
+ function MsalBroadcastService(msalInstance, authService) {
94
+ var _this = this;
95
+ this.msalInstance = msalInstance;
96
+ this.authService = authService;
97
+ this._msalSubject = new rxjs.Subject();
98
+ this.msalSubject$ = this._msalSubject.asObservable();
99
+ // InProgress as BehaviorSubject so most recent inProgress state will be available upon subscription
100
+ this._inProgress = new rxjs.BehaviorSubject(msalBrowser.InteractionStatus.Startup);
101
+ this.inProgress$ = this._inProgress.asObservable();
102
+ this.msalInstance.addEventCallback(function (message) {
103
+ _this._msalSubject.next(message);
104
+ var status = msalBrowser.EventMessageUtils.getInteractionStatusFromEvent(message, _this._inProgress.value);
105
+ if (status !== null) {
106
+ _this.authService.getLogger().verbose("BroadcastService - " + message.eventType + " results in setting inProgress from " + _this._inProgress.value + " to " + status);
107
+ _this._inProgress.next(status);
108
+ }
109
+ });
110
+ }
111
+ return MsalBroadcastService;
112
+ }());
113
+ MsalBroadcastService.decorators = [
114
+ { type: core.Injectable }
115
+ ];
116
+ MsalBroadcastService.ctorParameters = function () { return [
117
+ { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INSTANCE,] }] },
118
+ { type: MsalService }
119
119
  ]; };
120
120
 
121
- /*
122
- * Copyright (c) Microsoft Corporation. All rights reserved.
123
- * Licensed under the MIT License.
124
- */
125
- var MsalGuard = /** @class */ (function () {
126
- function MsalGuard(msalGuardConfig, msalBroadcastService, authService, location, router) {
127
- this.msalGuardConfig = msalGuardConfig;
128
- this.msalBroadcastService = msalBroadcastService;
129
- this.authService = authService;
130
- this.location = location;
131
- this.router = router;
132
- // Subscribing so events in MsalGuard will set inProgress$ observable
133
- this.msalBroadcastService.inProgress$.subscribe();
134
- }
135
- /**
136
- * Parses url string to UrlTree
137
- * @param url
138
- */
139
- MsalGuard.prototype.parseUrl = function (url) {
140
- return this.router.parseUrl(url);
141
- };
142
- /**
143
- * Builds the absolute url for the destination page
144
- * @param path Relative path of requested page
145
- * @returns Full destination url
146
- */
147
- MsalGuard.prototype.getDestinationUrl = function (path) {
148
- this.authService.getLogger().verbose("Guard - getting destination url");
149
- // Absolute base url for the application (default to origin if base element not present)
150
- var baseElements = document.getElementsByTagName("base");
151
- var baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);
152
- // Path of page (including hash, if using hash routing)
153
- var pathUrl = this.location.prepareExternalUrl(path);
154
- // Hash location strategy
155
- if (pathUrl.startsWith("#")) {
156
- this.authService.getLogger().verbose("Guard - destination by hash routing");
157
- return baseUrl + "/" + pathUrl;
158
- }
159
- /*
160
- * If using path location strategy, pathUrl will include the relative portion of the base path (e.g. /base/page).
161
- * Since baseUrl also includes /base, can just concatentate baseUrl + path
162
- */
163
- return "" + baseUrl + path;
164
- };
165
- /**
166
- * Interactively prompt the user to login
167
- * @param url Path of the requested page
168
- */
169
- MsalGuard.prototype.loginInteractively = function (state) {
170
- var _this = this;
171
- var authRequest = typeof this.msalGuardConfig.authRequest === "function"
172
- ? this.msalGuardConfig.authRequest(this.authService, state)
173
- : Object.assign({}, this.msalGuardConfig.authRequest);
174
- if (this.msalGuardConfig.interactionType === msalBrowser.InteractionType.Popup) {
175
- this.authService.getLogger().verbose("Guard - logging in by popup");
176
- return this.authService.loginPopup(authRequest)
177
- .pipe(operators.map(function (response) {
178
- _this.authService.getLogger().verbose("Guard - login by popup successful, can activate, setting active account");
179
- _this.authService.instance.setActiveAccount(response.account);
180
- return true;
181
- }));
182
- }
183
- this.authService.getLogger().verbose("Guard - logging in by redirect");
184
- var redirectStartPage = this.getDestinationUrl(state.url);
185
- return this.authService.loginRedirect(Object.assign({ redirectStartPage: redirectStartPage }, authRequest))
186
- .pipe(operators.map(function () { return false; }));
187
- };
188
- /**
189
- * Helper which checks for the correct interaction type, prevents page with Guard to be set as reidrect, and calls handleRedirectObservable
190
- * @param state
191
- */
192
- MsalGuard.prototype.activateHelper = function (state) {
193
- var _this = this;
194
- if (this.msalGuardConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalGuardConfig.interactionType !== msalBrowser.InteractionType.Redirect) {
195
- throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration");
196
- }
197
- this.authService.getLogger().verbose("MSAL Guard activated");
198
- /*
199
- * If a page with MSAL Guard is set as the redirect for acquireTokenSilent,
200
- * short-circuit to prevent redirecting or popups.
201
- * TODO: Update to allow running in iframe once allowRedirectInIframe is implemented
202
- */
203
- if (typeof window !== "undefined") {
204
- if (msalBrowser.UrlString.hashContainsKnownProperties(window.location.hash) && msalBrowser.BrowserUtils.isInIframe()) {
205
- this.authService.getLogger().warning("Guard - redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication.");
206
- return rxjs.of(false);
207
- }
208
- }
209
- else {
210
- this.authService.getLogger().info("Guard - window is undefined, MSAL does not support server-side token acquisition");
211
- return rxjs.of(true);
212
- }
213
- /**
214
- * If a loginFailedRoute is set in the config, set this as the loginFailedRoute
215
- */
216
- if (this.msalGuardConfig.loginFailedRoute) {
217
- this.loginFailedRoute = this.parseUrl(this.msalGuardConfig.loginFailedRoute);
218
- }
219
- // Capture current path before it gets changed by handleRedirectObservable
220
- var currentPath = this.location.path(true);
221
- return this.authService.handleRedirectObservable()
222
- .pipe(operators.concatMap(function () {
223
- if (!_this.authService.instance.getAllAccounts().length) {
224
- if (state) {
225
- _this.authService.getLogger().verbose("Guard - no accounts retrieved, log in required to activate");
226
- return _this.loginInteractively(state);
227
- }
228
- _this.authService.getLogger().verbose("Guard - no accounts retrieved, no state, cannot load");
229
- return rxjs.of(false);
230
- }
231
- _this.authService.getLogger().verbose("Guard - at least 1 account exists, can activate or load");
232
- // Prevent navigating the app to /#code= or /code=
233
- if (state && state.url.indexOf("code=") > -1) {
234
- _this.authService.getLogger().info("Guard - Hash contains known code response, stopping navigation.");
235
- // Path routing (navigate to current path without hash)
236
- if (currentPath.indexOf("#") > -1) {
237
- return rxjs.of(_this.parseUrl(_this.location.path()));
238
- }
239
- // Hash routing (navigate to root path)
240
- return rxjs.of(_this.parseUrl(""));
241
- }
242
- return rxjs.of(true);
243
- }), operators.catchError(function (error) {
244
- _this.authService.getLogger().error("Guard - error while logging in, unable to activate");
245
- _this.authService.getLogger().errorPii("Guard - error: " + error.message);
246
- /**
247
- * If a loginFailedRoute is set, checks to see if Angular 10+ is used and state is passed in before returning route
248
- * Apps using Angular 9 will receive of(false) in canLoad interface, as it does not support UrlTree return types
249
- */
250
- if (_this.loginFailedRoute && parseInt(core.VERSION.major, 10) > 9 && state) {
251
- _this.authService.getLogger().verbose("Guard - loginFailedRoute set, redirecting");
252
- return rxjs.of(_this.loginFailedRoute);
253
- }
254
- return rxjs.of(false);
255
- }));
256
- };
257
- MsalGuard.prototype.canActivate = function (route, state) {
258
- this.authService.getLogger().verbose("Guard - canActivate");
259
- return this.activateHelper(state);
260
- };
261
- MsalGuard.prototype.canActivateChild = function (route, state) {
262
- this.authService.getLogger().verbose("Guard - canActivateChild");
263
- return this.activateHelper(state);
264
- };
265
- MsalGuard.prototype.canLoad = function () {
266
- this.authService.getLogger().verbose("Guard - canLoad");
267
- // @ts-ignore
268
- return this.activateHelper();
269
- };
270
- return MsalGuard;
271
- }());
272
- MsalGuard.decorators = [
273
- { type: core.Injectable }
274
- ];
275
- MsalGuard.ctorParameters = function () { return [
276
- { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_GUARD_CONFIG,] }] },
277
- { type: MsalBroadcastService },
278
- { type: MsalService },
279
- { type: common.Location },
280
- { type: router.Router }
121
+ /*
122
+ * Copyright (c) Microsoft Corporation. All rights reserved.
123
+ * Licensed under the MIT License.
124
+ */
125
+ var MsalGuard = /** @class */ (function () {
126
+ function MsalGuard(msalGuardConfig, msalBroadcastService, authService, location, router) {
127
+ this.msalGuardConfig = msalGuardConfig;
128
+ this.msalBroadcastService = msalBroadcastService;
129
+ this.authService = authService;
130
+ this.location = location;
131
+ this.router = router;
132
+ // Subscribing so events in MsalGuard will set inProgress$ observable
133
+ this.msalBroadcastService.inProgress$.subscribe();
134
+ }
135
+ /**
136
+ * Parses url string to UrlTree
137
+ * @param url
138
+ */
139
+ MsalGuard.prototype.parseUrl = function (url) {
140
+ return this.router.parseUrl(url);
141
+ };
142
+ /**
143
+ * Builds the absolute url for the destination page
144
+ * @param path Relative path of requested page
145
+ * @returns Full destination url
146
+ */
147
+ MsalGuard.prototype.getDestinationUrl = function (path) {
148
+ this.authService.getLogger().verbose("Guard - getting destination url");
149
+ // Absolute base url for the application (default to origin if base element not present)
150
+ var baseElements = document.getElementsByTagName("base");
151
+ var baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);
152
+ // Path of page (including hash, if using hash routing)
153
+ var pathUrl = this.location.prepareExternalUrl(path);
154
+ // Hash location strategy
155
+ if (pathUrl.startsWith("#")) {
156
+ this.authService.getLogger().verbose("Guard - destination by hash routing");
157
+ return baseUrl + "/" + pathUrl;
158
+ }
159
+ /*
160
+ * If using path location strategy, pathUrl will include the relative portion of the base path (e.g. /base/page).
161
+ * Since baseUrl also includes /base, can just concatentate baseUrl + path
162
+ */
163
+ return "" + baseUrl + path;
164
+ };
165
+ /**
166
+ * Interactively prompt the user to login
167
+ * @param url Path of the requested page
168
+ */
169
+ MsalGuard.prototype.loginInteractively = function (state) {
170
+ var _this = this;
171
+ var authRequest = typeof this.msalGuardConfig.authRequest === "function"
172
+ ? this.msalGuardConfig.authRequest(this.authService, state)
173
+ : Object.assign({}, this.msalGuardConfig.authRequest);
174
+ if (this.msalGuardConfig.interactionType === msalBrowser.InteractionType.Popup) {
175
+ this.authService.getLogger().verbose("Guard - logging in by popup");
176
+ return this.authService.loginPopup(authRequest)
177
+ .pipe(operators.map(function (response) {
178
+ _this.authService.getLogger().verbose("Guard - login by popup successful, can activate, setting active account");
179
+ _this.authService.instance.setActiveAccount(response.account);
180
+ return true;
181
+ }));
182
+ }
183
+ this.authService.getLogger().verbose("Guard - logging in by redirect");
184
+ var redirectStartPage = this.getDestinationUrl(state.url);
185
+ return this.authService.loginRedirect(Object.assign({ redirectStartPage: redirectStartPage }, authRequest))
186
+ .pipe(operators.map(function () { return false; }));
187
+ };
188
+ /**
189
+ * Helper which checks for the correct interaction type, prevents page with Guard to be set as reidrect, and calls handleRedirectObservable
190
+ * @param state
191
+ */
192
+ MsalGuard.prototype.activateHelper = function (state) {
193
+ var _this = this;
194
+ if (this.msalGuardConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalGuardConfig.interactionType !== msalBrowser.InteractionType.Redirect) {
195
+ throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration");
196
+ }
197
+ this.authService.getLogger().verbose("MSAL Guard activated");
198
+ /*
199
+ * If a page with MSAL Guard is set as the redirect for acquireTokenSilent,
200
+ * short-circuit to prevent redirecting or popups.
201
+ */
202
+ if (typeof window !== "undefined") {
203
+ if (msalBrowser.UrlString.hashContainsKnownProperties(window.location.hash) && msalBrowser.BrowserUtils.isInIframe() && !this.authService.instance.getConfiguration().system.allowRedirectInIframe) {
204
+ this.authService.getLogger().warning("Guard - redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication.");
205
+ return rxjs.of(false);
206
+ }
207
+ }
208
+ else {
209
+ this.authService.getLogger().info("Guard - window is undefined, MSAL does not support server-side token acquisition");
210
+ return rxjs.of(true);
211
+ }
212
+ /**
213
+ * If a loginFailedRoute is set in the config, set this as the loginFailedRoute
214
+ */
215
+ if (this.msalGuardConfig.loginFailedRoute) {
216
+ this.loginFailedRoute = this.parseUrl(this.msalGuardConfig.loginFailedRoute);
217
+ }
218
+ // Capture current path before it gets changed by handleRedirectObservable
219
+ var currentPath = this.location.path(true);
220
+ return this.authService.handleRedirectObservable()
221
+ .pipe(operators.concatMap(function () {
222
+ if (!_this.authService.instance.getAllAccounts().length) {
223
+ if (state) {
224
+ _this.authService.getLogger().verbose("Guard - no accounts retrieved, log in required to activate");
225
+ return _this.loginInteractively(state);
226
+ }
227
+ _this.authService.getLogger().verbose("Guard - no accounts retrieved, no state, cannot load");
228
+ return rxjs.of(false);
229
+ }
230
+ _this.authService.getLogger().verbose("Guard - at least 1 account exists, can activate or load");
231
+ // Prevent navigating the app to /#code= or /code=
232
+ if (state) {
233
+ /*
234
+ * Path routing:
235
+ * state.url: /#code=...
236
+ * state.root.fragment: code=...
237
+ */
238
+ /*
239
+ * Hash routing:
240
+ * state.url: /code
241
+ * state.root.fragment: null
242
+ */
243
+ var urlContainsCode = _this.includesCode(state.url);
244
+ var fragmentContainsCode = !!state.root && !!state.root.fragment && _this.includesCode("#" + state.root.fragment);
245
+ var hashRouting = _this.location.prepareExternalUrl(state.url).indexOf("#") === 0;
246
+ // Ensure code parameter is in fragment (and not in query parameter), or that hash hash routing is used
247
+ if (urlContainsCode && (fragmentContainsCode || hashRouting)) {
248
+ _this.authService.getLogger().info("Guard - Hash contains known code response, stopping navigation.");
249
+ // Path routing (navigate to current path without hash)
250
+ if (currentPath.indexOf("#") > -1) {
251
+ return rxjs.of(_this.parseUrl(_this.location.path()));
252
+ }
253
+ // Hash routing (navigate to root path)
254
+ return rxjs.of(_this.parseUrl(""));
255
+ }
256
+ }
257
+ return rxjs.of(true);
258
+ }), operators.catchError(function (error) {
259
+ _this.authService.getLogger().error("Guard - error while logging in, unable to activate");
260
+ _this.authService.getLogger().errorPii("Guard - error: " + error.message);
261
+ /**
262
+ * If a loginFailedRoute is set, checks to see if Angular 10+ is used and state is passed in before returning route
263
+ * Apps using Angular 9 will receive of(false) in canLoad interface, as it does not support UrlTree return types
264
+ */
265
+ if (_this.loginFailedRoute && parseInt(core.VERSION.major, 10) > 9 && state) {
266
+ _this.authService.getLogger().verbose("Guard - loginFailedRoute set, redirecting");
267
+ return rxjs.of(_this.loginFailedRoute);
268
+ }
269
+ return rxjs.of(false);
270
+ }));
271
+ };
272
+ MsalGuard.prototype.includesCode = function (path) {
273
+ return (path.lastIndexOf("/code") > -1 &&
274
+ path.lastIndexOf("/code") === path.length - "/code".length) || // path.endsWith("/code")
275
+ path.indexOf("#code=") > -1 ||
276
+ path.indexOf("&code=") > -1;
277
+ };
278
+ MsalGuard.prototype.canActivate = function (route, state) {
279
+ this.authService.getLogger().verbose("Guard - canActivate");
280
+ return this.activateHelper(state);
281
+ };
282
+ MsalGuard.prototype.canActivateChild = function (route, state) {
283
+ this.authService.getLogger().verbose("Guard - canActivateChild");
284
+ return this.activateHelper(state);
285
+ };
286
+ MsalGuard.prototype.canLoad = function () {
287
+ this.authService.getLogger().verbose("Guard - canLoad");
288
+ // @ts-ignore
289
+ return this.activateHelper();
290
+ };
291
+ return MsalGuard;
292
+ }());
293
+ MsalGuard.decorators = [
294
+ { type: core.Injectable }
295
+ ];
296
+ MsalGuard.ctorParameters = function () { return [
297
+ { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_GUARD_CONFIG,] }] },
298
+ { type: MsalBroadcastService },
299
+ { type: MsalService },
300
+ { type: common.Location },
301
+ { type: router.Router }
281
302
  ]; };
282
303
 
283
- /*
284
- * Copyright (c) Microsoft Corporation. All rights reserved.
285
- * Licensed under the MIT License.
286
- */
287
- var MsalInterceptor = /** @class */ (function () {
288
- function MsalInterceptor(msalInterceptorConfig, authService, location,
289
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
290
- document) {
291
- this.msalInterceptorConfig = msalInterceptorConfig;
292
- this.authService = authService;
293
- this.location = location;
294
- this._document = document;
295
- }
296
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
297
- MsalInterceptor.prototype.intercept = function (req, next) {
298
- var _this = this;
299
- if (this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Redirect) {
300
- throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
301
- }
302
- this.authService.getLogger().verbose("MSAL Interceptor activated");
303
- var scopes = this.getScopesForEndpoint(req.url, req.method);
304
- // If no scopes for endpoint, does not acquire token
305
- if (!scopes || scopes.length === 0) {
306
- this.authService.getLogger().verbose("Interceptor - no scopes for endpoint");
307
- return next.handle(req);
308
- }
309
- // Sets account as active account or first account
310
- var account;
311
- if (!!this.authService.instance.getActiveAccount()) {
312
- this.authService.getLogger().verbose("Interceptor - active account selected");
313
- account = this.authService.instance.getActiveAccount();
314
- }
315
- else {
316
- this.authService.getLogger().verbose("Interceptor - no active account, fallback to first account");
317
- account = this.authService.instance.getAllAccounts()[0];
318
- }
319
- var authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
320
- ? this.msalInterceptorConfig.authRequest(this.authService, req, { account: account })
321
- : Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { account: account });
322
- this.authService.getLogger().info("Interceptor - " + scopes.length + " scopes found for endpoint");
323
- this.authService.getLogger().infoPii("Interceptor - [" + scopes + "] scopes found for " + req.url);
324
- // Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken
325
- return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, authRequest), { scopes: scopes, account: account }))
326
- .pipe(operators.catchError(function () {
327
- _this.authService.getLogger().error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
328
- return _this.acquireTokenInteractively(authRequest, scopes);
329
- }), operators.switchMap(function (result) {
330
- if (!result.accessToken) {
331
- _this.authService.getLogger().error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
332
- return _this.acquireTokenInteractively(authRequest, scopes);
333
- }
334
- return rxjs.of(result);
335
- }), operators.switchMap(function (result) {
336
- _this.authService.getLogger().verbose("Interceptor - setting authorization headers");
337
- var headers = req.headers
338
- .set("Authorization", "Bearer " + result.accessToken);
339
- var requestClone = req.clone({ headers: headers });
340
- return next.handle(requestClone);
341
- }));
342
- };
343
- /**
344
- * Invoke interaction for the given set of scopes
345
- * @param authRequest Request
346
- * @param scopes Array of scopes for the request
347
- * @returns Result from the interactive request
348
- */
349
- MsalInterceptor.prototype.acquireTokenInteractively = function (authRequest, scopes) {
350
- if (this.msalInterceptorConfig.interactionType === msalBrowser.InteractionType.Popup) {
351
- this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by popup");
352
- return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, authRequest), { scopes: scopes }));
353
- }
354
- this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by redirect");
355
- var redirectStartPage = window.location.href;
356
- this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, authRequest), { scopes: scopes, redirectStartPage: redirectStartPage }));
357
- return rxjs.EMPTY;
358
- };
359
- /**
360
- * Looks up the scopes for the given endpoint from the protectedResourceMap
361
- * @param endpoint Url of the request
362
- * @param httpMethod Http method of the request
363
- * @returns Array of scopes, or null if not found
364
- *
365
- */
366
- MsalInterceptor.prototype.getScopesForEndpoint = function (endpoint, httpMethod) {
367
- this.authService.getLogger().verbose("Interceptor - getting scopes for endpoint");
368
- // Ensures endpoints and protected resources compared are normalized
369
- var normalizedEndpoint = this.location.normalize(endpoint);
370
- var protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
371
- var matchingProtectedResources = this.matchResourcesToEndpoint(protectedResourcesArray, normalizedEndpoint);
372
- // Check absolute urls of resources first before checking relative to prevent incorrect matching where multiple resources have similar relative urls
373
- if (matchingProtectedResources.absoluteResources.length > 0) {
374
- return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.absoluteResources, httpMethod);
375
- }
376
- else if (matchingProtectedResources.relativeResources.length > 0) {
377
- return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.relativeResources, httpMethod);
378
- }
379
- return null;
380
- };
381
- /**
382
- * Finds resource endpoints that match request endpoint
383
- * @param protectedResourcesEndpoints
384
- * @param endpoint
385
- * @returns
386
- */
387
- MsalInterceptor.prototype.matchResourcesToEndpoint = function (protectedResourcesEndpoints, endpoint) {
388
- var _this = this;
389
- var matchingResources = { absoluteResources: [], relativeResources: [] };
390
- protectedResourcesEndpoints.forEach(function (key) {
391
- // Normalizes and adds resource to matchingResources.absoluteResources if key matches endpoint. StringUtils.matchPattern accounts for wildcards
392
- var normalizedKey = _this.location.normalize(key);
393
- if (msalBrowser.StringUtils.matchPattern(normalizedKey, endpoint)) {
394
- matchingResources.absoluteResources.push(key);
395
- }
396
- // Get url components for relative urls
397
- var absoluteKey = _this.getAbsoluteUrl(key);
398
- var keyComponents = new msalBrowser.UrlString(absoluteKey).getUrlComponents();
399
- var absoluteEndpoint = _this.getAbsoluteUrl(endpoint);
400
- var endpointComponents = new msalBrowser.UrlString(absoluteEndpoint).getUrlComponents();
401
- // Normalized key should include query strings if applicable
402
- var relativeNormalizedKey = keyComponents.QueryString ? keyComponents.AbsolutePath + "?" + keyComponents.QueryString : _this.location.normalize(keyComponents.AbsolutePath);
403
- // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
404
- if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort && msalBrowser.StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) && relativeNormalizedKey !== "" && relativeNormalizedKey !== "/*") {
405
- matchingResources.relativeResources.push(key);
406
- }
407
- });
408
- return matchingResources;
409
- };
410
- /**
411
- * Transforms relative urls to absolute urls
412
- * @param url
413
- * @returns
414
- */
415
- MsalInterceptor.prototype.getAbsoluteUrl = function (url) {
416
- var link = this._document.createElement("a");
417
- link.href = url;
418
- return link.href;
419
- };
420
- /**
421
- * Finds scopes from first matching endpoint with HTTP method that matches request
422
- * @param protectedResourceMap Protected resource map
423
- * @param endpointArray Array of resources that match request endpoint
424
- * @param httpMethod Http method of the request
425
- * @returns
426
- */
427
- MsalInterceptor.prototype.matchScopesToEndpoint = function (protectedResourceMap, endpointArray, httpMethod) {
428
- var allMatchedScopes = [];
429
- // Check each matched endpoint for matching HttpMethod and scopes
430
- endpointArray.forEach(function (matchedEndpoint) {
431
- var scopesForEndpoint = [];
432
- var methodAndScopesArray = protectedResourceMap.get(matchedEndpoint);
433
- // Return if resource is unprotected
434
- if (methodAndScopesArray === null) {
435
- allMatchedScopes.push(null);
436
- return;
437
- }
438
- methodAndScopesArray.forEach(function (entry) {
439
- // Entry is either array of scopes or ProtectedResourceScopes object
440
- if (typeof entry === "string") {
441
- scopesForEndpoint.push(entry);
442
- }
443
- else {
444
- // Ensure methods being compared are normalized
445
- var normalizedRequestMethod = httpMethod.toLowerCase();
446
- var normalizedResourceMethod = entry.httpMethod.toLowerCase();
447
- // Method in protectedResourceMap matches request http method
448
- if (normalizedResourceMethod === normalizedRequestMethod) {
449
- // Validate if scopes comes null to unprotect the resource in a certain http method
450
- if (entry.scopes === null) {
451
- allMatchedScopes.push(null);
452
- }
453
- else {
454
- entry.scopes.forEach(function (scope) {
455
- scopesForEndpoint.push(scope);
456
- });
457
- }
458
- }
459
- }
460
- });
461
- // Only add to all scopes if scopes for endpoint and method is found
462
- if (scopesForEndpoint.length > 0) {
463
- allMatchedScopes.push(scopesForEndpoint);
464
- }
465
- });
466
- if (allMatchedScopes.length > 0) {
467
- if (allMatchedScopes.length > 1) {
468
- this.authService.getLogger().warning("Interceptor - More than 1 matching scopes for endpoint found.");
469
- }
470
- // Returns scopes for first matching endpoint
471
- return allMatchedScopes[0];
472
- }
473
- return null;
474
- };
475
- return MsalInterceptor;
476
- }());
477
- MsalInterceptor.decorators = [
478
- { type: core.Injectable }
479
- ];
480
- MsalInterceptor.ctorParameters = function () { return [
481
- { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] },
482
- { type: MsalService },
483
- { type: common.Location },
484
- { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
304
+ /*
305
+ * Copyright (c) Microsoft Corporation. All rights reserved.
306
+ * Licensed under the MIT License.
307
+ */
308
+ var MsalInterceptor = /** @class */ (function () {
309
+ function MsalInterceptor(msalInterceptorConfig, authService, location,
310
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
311
+ document) {
312
+ this.msalInterceptorConfig = msalInterceptorConfig;
313
+ this.authService = authService;
314
+ this.location = location;
315
+ this._document = document;
316
+ }
317
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
318
+ MsalInterceptor.prototype.intercept = function (req, next) {
319
+ var _this = this;
320
+ if (this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Redirect) {
321
+ throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
322
+ }
323
+ this.authService.getLogger().verbose("MSAL Interceptor activated");
324
+ var scopes = this.getScopesForEndpoint(req.url, req.method);
325
+ // If no scopes for endpoint, does not acquire token
326
+ if (!scopes || scopes.length === 0) {
327
+ this.authService.getLogger().verbose("Interceptor - no scopes for endpoint");
328
+ return next.handle(req);
329
+ }
330
+ // Sets account as active account or first account
331
+ var account;
332
+ if (!!this.authService.instance.getActiveAccount()) {
333
+ this.authService.getLogger().verbose("Interceptor - active account selected");
334
+ account = this.authService.instance.getActiveAccount();
335
+ }
336
+ else {
337
+ this.authService.getLogger().verbose("Interceptor - no active account, fallback to first account");
338
+ account = this.authService.instance.getAllAccounts()[0];
339
+ }
340
+ var authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
341
+ ? this.msalInterceptorConfig.authRequest(this.authService, req, { account: account })
342
+ : Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { account: account });
343
+ this.authService.getLogger().info("Interceptor - " + scopes.length + " scopes found for endpoint");
344
+ this.authService.getLogger().infoPii("Interceptor - [" + scopes + "] scopes found for " + req.url);
345
+ // Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken
346
+ return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, authRequest), { scopes: scopes, account: account }))
347
+ .pipe(operators.catchError(function () {
348
+ _this.authService.getLogger().error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
349
+ return _this.acquireTokenInteractively(authRequest, scopes);
350
+ }), operators.switchMap(function (result) {
351
+ if (!result.accessToken) {
352
+ _this.authService.getLogger().error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
353
+ return _this.acquireTokenInteractively(authRequest, scopes);
354
+ }
355
+ return rxjs.of(result);
356
+ }), operators.switchMap(function (result) {
357
+ _this.authService.getLogger().verbose("Interceptor - setting authorization headers");
358
+ var headers = req.headers
359
+ .set("Authorization", "Bearer " + result.accessToken);
360
+ var requestClone = req.clone({ headers: headers });
361
+ return next.handle(requestClone);
362
+ }));
363
+ };
364
+ /**
365
+ * Invoke interaction for the given set of scopes
366
+ * @param authRequest Request
367
+ * @param scopes Array of scopes for the request
368
+ * @returns Result from the interactive request
369
+ */
370
+ MsalInterceptor.prototype.acquireTokenInteractively = function (authRequest, scopes) {
371
+ if (this.msalInterceptorConfig.interactionType === msalBrowser.InteractionType.Popup) {
372
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by popup");
373
+ return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, authRequest), { scopes: scopes }));
374
+ }
375
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by redirect");
376
+ var redirectStartPage = window.location.href;
377
+ this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, authRequest), { scopes: scopes, redirectStartPage: redirectStartPage }));
378
+ return rxjs.EMPTY;
379
+ };
380
+ /**
381
+ * Looks up the scopes for the given endpoint from the protectedResourceMap
382
+ * @param endpoint Url of the request
383
+ * @param httpMethod Http method of the request
384
+ * @returns Array of scopes, or null if not found
385
+ *
386
+ */
387
+ MsalInterceptor.prototype.getScopesForEndpoint = function (endpoint, httpMethod) {
388
+ this.authService.getLogger().verbose("Interceptor - getting scopes for endpoint");
389
+ // Ensures endpoints and protected resources compared are normalized
390
+ var normalizedEndpoint = this.location.normalize(endpoint);
391
+ var protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
392
+ var matchingProtectedResources = this.matchResourcesToEndpoint(protectedResourcesArray, normalizedEndpoint);
393
+ // Check absolute urls of resources first before checking relative to prevent incorrect matching where multiple resources have similar relative urls
394
+ if (matchingProtectedResources.absoluteResources.length > 0) {
395
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.absoluteResources, httpMethod);
396
+ }
397
+ else if (matchingProtectedResources.relativeResources.length > 0) {
398
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.relativeResources, httpMethod);
399
+ }
400
+ return null;
401
+ };
402
+ /**
403
+ * Finds resource endpoints that match request endpoint
404
+ * @param protectedResourcesEndpoints
405
+ * @param endpoint
406
+ * @returns
407
+ */
408
+ MsalInterceptor.prototype.matchResourcesToEndpoint = function (protectedResourcesEndpoints, endpoint) {
409
+ var _this = this;
410
+ var matchingResources = { absoluteResources: [], relativeResources: [] };
411
+ protectedResourcesEndpoints.forEach(function (key) {
412
+ // Normalizes and adds resource to matchingResources.absoluteResources if key matches endpoint. StringUtils.matchPattern accounts for wildcards
413
+ var normalizedKey = _this.location.normalize(key);
414
+ if (msalBrowser.StringUtils.matchPattern(normalizedKey, endpoint)) {
415
+ matchingResources.absoluteResources.push(key);
416
+ }
417
+ // Get url components for relative urls
418
+ var absoluteKey = _this.getAbsoluteUrl(key);
419
+ var keyComponents = new msalBrowser.UrlString(absoluteKey).getUrlComponents();
420
+ var absoluteEndpoint = _this.getAbsoluteUrl(endpoint);
421
+ var endpointComponents = new msalBrowser.UrlString(absoluteEndpoint).getUrlComponents();
422
+ // Normalized key should include query strings if applicable
423
+ var relativeNormalizedKey = keyComponents.QueryString ? keyComponents.AbsolutePath + "?" + keyComponents.QueryString : _this.location.normalize(keyComponents.AbsolutePath);
424
+ // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
425
+ if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort && msalBrowser.StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) && relativeNormalizedKey !== "" && relativeNormalizedKey !== "/*") {
426
+ matchingResources.relativeResources.push(key);
427
+ }
428
+ });
429
+ return matchingResources;
430
+ };
431
+ /**
432
+ * Transforms relative urls to absolute urls
433
+ * @param url
434
+ * @returns
435
+ */
436
+ MsalInterceptor.prototype.getAbsoluteUrl = function (url) {
437
+ var link = this._document.createElement("a");
438
+ link.href = url;
439
+ return link.href;
440
+ };
441
+ /**
442
+ * Finds scopes from first matching endpoint with HTTP method that matches request
443
+ * @param protectedResourceMap Protected resource map
444
+ * @param endpointArray Array of resources that match request endpoint
445
+ * @param httpMethod Http method of the request
446
+ * @returns
447
+ */
448
+ MsalInterceptor.prototype.matchScopesToEndpoint = function (protectedResourceMap, endpointArray, httpMethod) {
449
+ var allMatchedScopes = [];
450
+ // Check each matched endpoint for matching HttpMethod and scopes
451
+ endpointArray.forEach(function (matchedEndpoint) {
452
+ var scopesForEndpoint = [];
453
+ var methodAndScopesArray = protectedResourceMap.get(matchedEndpoint);
454
+ // Return if resource is unprotected
455
+ if (methodAndScopesArray === null) {
456
+ allMatchedScopes.push(null);
457
+ return;
458
+ }
459
+ methodAndScopesArray.forEach(function (entry) {
460
+ // Entry is either array of scopes or ProtectedResourceScopes object
461
+ if (typeof entry === "string") {
462
+ scopesForEndpoint.push(entry);
463
+ }
464
+ else {
465
+ // Ensure methods being compared are normalized
466
+ var normalizedRequestMethod = httpMethod.toLowerCase();
467
+ var normalizedResourceMethod = entry.httpMethod.toLowerCase();
468
+ // Method in protectedResourceMap matches request http method
469
+ if (normalizedResourceMethod === normalizedRequestMethod) {
470
+ // Validate if scopes comes null to unprotect the resource in a certain http method
471
+ if (entry.scopes === null) {
472
+ allMatchedScopes.push(null);
473
+ }
474
+ else {
475
+ entry.scopes.forEach(function (scope) {
476
+ scopesForEndpoint.push(scope);
477
+ });
478
+ }
479
+ }
480
+ }
481
+ });
482
+ // Only add to all scopes if scopes for endpoint and method is found
483
+ if (scopesForEndpoint.length > 0) {
484
+ allMatchedScopes.push(scopesForEndpoint);
485
+ }
486
+ });
487
+ if (allMatchedScopes.length > 0) {
488
+ if (allMatchedScopes.length > 1) {
489
+ this.authService.getLogger().warning("Interceptor - More than 1 matching scopes for endpoint found.");
490
+ }
491
+ // Returns scopes for first matching endpoint
492
+ return allMatchedScopes[0];
493
+ }
494
+ return null;
495
+ };
496
+ return MsalInterceptor;
497
+ }());
498
+ MsalInterceptor.decorators = [
499
+ { type: core.Injectable }
500
+ ];
501
+ MsalInterceptor.ctorParameters = function () { return [
502
+ { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] },
503
+ { type: MsalService },
504
+ { type: common.Location },
505
+ { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
485
506
  ]; };
486
507
 
487
- /*
488
- * Copyright (c) Microsoft Corporation. All rights reserved.
489
- * Licensed under the MIT License.
490
- */
491
- var MsalRedirectComponent = /** @class */ (function () {
492
- function MsalRedirectComponent(authService) {
493
- this.authService = authService;
494
- }
495
- MsalRedirectComponent.prototype.ngOnInit = function () {
496
- this.authService.getLogger().verbose("MsalRedirectComponent activated");
497
- this.authService.handleRedirectObservable().subscribe();
498
- };
499
- return MsalRedirectComponent;
500
- }());
501
- MsalRedirectComponent.decorators = [
502
- { type: core.Component, args: [{
503
- selector: "app-redirect",
504
- template: ""
505
- },] }
506
- ];
507
- MsalRedirectComponent.ctorParameters = function () { return [
508
- { type: MsalService }
508
+ /*
509
+ * Copyright (c) Microsoft Corporation. All rights reserved.
510
+ * Licensed under the MIT License.
511
+ */
512
+ var MsalRedirectComponent = /** @class */ (function () {
513
+ function MsalRedirectComponent(authService) {
514
+ this.authService = authService;
515
+ }
516
+ MsalRedirectComponent.prototype.ngOnInit = function () {
517
+ this.authService.getLogger().verbose("MsalRedirectComponent activated");
518
+ this.authService.handleRedirectObservable().subscribe();
519
+ };
520
+ return MsalRedirectComponent;
521
+ }());
522
+ MsalRedirectComponent.decorators = [
523
+ { type: core.Component, args: [{
524
+ selector: "app-redirect",
525
+ template: ""
526
+ },] }
527
+ ];
528
+ MsalRedirectComponent.ctorParameters = function () { return [
529
+ { type: MsalService }
509
530
  ]; };
510
531
 
511
- /*
512
- * Copyright (c) Microsoft Corporation. All rights reserved.
513
- * Licensed under the MIT License.
514
- */
515
- var MsalModule = /** @class */ (function () {
516
- function MsalModule() {
517
- }
518
- MsalModule.forRoot = function (msalInstance, guardConfig, interceptorConfig) {
519
- return {
520
- ngModule: MsalModule,
521
- providers: [
522
- {
523
- provide: MSAL_INSTANCE,
524
- useValue: msalInstance
525
- },
526
- {
527
- provide: MSAL_GUARD_CONFIG,
528
- useValue: guardConfig
529
- },
530
- {
531
- provide: MSAL_INTERCEPTOR_CONFIG,
532
- useValue: interceptorConfig
533
- },
534
- MsalService
535
- ]
536
- };
537
- };
538
- return MsalModule;
539
- }());
540
- MsalModule.decorators = [
541
- { type: core.NgModule, args: [{
542
- declarations: [MsalRedirectComponent],
543
- imports: [
544
- common.CommonModule
545
- ],
546
- providers: [
547
- MsalGuard,
548
- MsalBroadcastService
549
- ]
550
- },] }
532
+ /*
533
+ * Copyright (c) Microsoft Corporation. All rights reserved.
534
+ * Licensed under the MIT License.
535
+ */
536
+ var MsalModule = /** @class */ (function () {
537
+ function MsalModule() {
538
+ }
539
+ MsalModule.forRoot = function (msalInstance, guardConfig, interceptorConfig) {
540
+ return {
541
+ ngModule: MsalModule,
542
+ providers: [
543
+ {
544
+ provide: MSAL_INSTANCE,
545
+ useValue: msalInstance
546
+ },
547
+ {
548
+ provide: MSAL_GUARD_CONFIG,
549
+ useValue: guardConfig
550
+ },
551
+ {
552
+ provide: MSAL_INTERCEPTOR_CONFIG,
553
+ useValue: interceptorConfig
554
+ },
555
+ MsalService
556
+ ]
557
+ };
558
+ };
559
+ return MsalModule;
560
+ }());
561
+ MsalModule.decorators = [
562
+ { type: core.NgModule, args: [{
563
+ declarations: [MsalRedirectComponent],
564
+ imports: [
565
+ common.CommonModule
566
+ ],
567
+ providers: [
568
+ MsalGuard,
569
+ MsalBroadcastService
570
+ ]
571
+ },] }
551
572
  ];
552
573
 
553
- /*! *****************************************************************************
554
- Copyright (c) Microsoft Corporation.
555
-
556
- Permission to use, copy, modify, and/or distribute this software for any
557
- purpose with or without fee is hereby granted.
558
-
559
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
560
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
561
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
562
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
563
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
564
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
565
- PERFORMANCE OF THIS SOFTWARE.
566
- ***************************************************************************** */
567
- /* global Reflect, Promise */
568
- var extendStatics = function (d, b) {
569
- extendStatics = Object.setPrototypeOf ||
570
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
571
- function (d, b) { for (var p in b)
572
- if (Object.prototype.hasOwnProperty.call(b, p))
573
- d[p] = b[p]; };
574
- return extendStatics(d, b);
575
- };
576
- function __extends(d, b) {
577
- if (typeof b !== "function" && b !== null)
578
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
579
- extendStatics(d, b);
580
- function __() { this.constructor = d; }
581
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
582
- }
583
- var __assign = function () {
584
- __assign = Object.assign || function __assign(t) {
585
- for (var s, i = 1, n = arguments.length; i < n; i++) {
586
- s = arguments[i];
587
- for (var p in s)
588
- if (Object.prototype.hasOwnProperty.call(s, p))
589
- t[p] = s[p];
590
- }
591
- return t;
592
- };
593
- return __assign.apply(this, arguments);
594
- };
595
- function __rest(s, e) {
596
- var t = {};
597
- for (var p in s)
598
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
599
- t[p] = s[p];
600
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
601
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
602
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
603
- t[p[i]] = s[p[i]];
604
- }
605
- return t;
606
- }
607
- function __decorate(decorators, target, key, desc) {
608
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
609
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
610
- r = Reflect.decorate(decorators, target, key, desc);
611
- else
612
- for (var i = decorators.length - 1; i >= 0; i--)
613
- if (d = decorators[i])
614
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
615
- return c > 3 && r && Object.defineProperty(target, key, r), r;
616
- }
617
- function __param(paramIndex, decorator) {
618
- return function (target, key) { decorator(target, key, paramIndex); };
619
- }
620
- function __metadata(metadataKey, metadataValue) {
621
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
622
- return Reflect.metadata(metadataKey, metadataValue);
623
- }
624
- function __awaiter(thisArg, _arguments, P, generator) {
625
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
626
- return new (P || (P = Promise))(function (resolve, reject) {
627
- function fulfilled(value) { try {
628
- step(generator.next(value));
629
- }
630
- catch (e) {
631
- reject(e);
632
- } }
633
- function rejected(value) { try {
634
- step(generator["throw"](value));
635
- }
636
- catch (e) {
637
- reject(e);
638
- } }
639
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
640
- step((generator = generator.apply(thisArg, _arguments || [])).next());
641
- });
642
- }
643
- function __generator(thisArg, body) {
644
- var _ = { label: 0, sent: function () { if (t[0] & 1)
645
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
646
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
647
- function verb(n) { return function (v) { return step([n, v]); }; }
648
- function step(op) {
649
- if (f)
650
- throw new TypeError("Generator is already executing.");
651
- while (_)
652
- try {
653
- 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)
654
- return t;
655
- if (y = 0, t)
656
- op = [op[0] & 2, t.value];
657
- switch (op[0]) {
658
- case 0:
659
- case 1:
660
- t = op;
661
- break;
662
- case 4:
663
- _.label++;
664
- return { value: op[1], done: false };
665
- case 5:
666
- _.label++;
667
- y = op[1];
668
- op = [0];
669
- continue;
670
- case 7:
671
- op = _.ops.pop();
672
- _.trys.pop();
673
- continue;
674
- default:
675
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
676
- _ = 0;
677
- continue;
678
- }
679
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
680
- _.label = op[1];
681
- break;
682
- }
683
- if (op[0] === 6 && _.label < t[1]) {
684
- _.label = t[1];
685
- t = op;
686
- break;
687
- }
688
- if (t && _.label < t[2]) {
689
- _.label = t[2];
690
- _.ops.push(op);
691
- break;
692
- }
693
- if (t[2])
694
- _.ops.pop();
695
- _.trys.pop();
696
- continue;
697
- }
698
- op = body.call(thisArg, _);
699
- }
700
- catch (e) {
701
- op = [6, e];
702
- y = 0;
703
- }
704
- finally {
705
- f = t = 0;
706
- }
707
- if (op[0] & 5)
708
- throw op[1];
709
- return { value: op[0] ? op[1] : void 0, done: true };
710
- }
711
- }
712
- var __createBinding = Object.create ? (function (o, m, k, k2) {
713
- if (k2 === undefined)
714
- k2 = k;
715
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
716
- }) : (function (o, m, k, k2) {
717
- if (k2 === undefined)
718
- k2 = k;
719
- o[k2] = m[k];
720
- });
721
- function __exportStar(m, o) {
722
- for (var p in m)
723
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
724
- __createBinding(o, m, p);
725
- }
726
- function __values(o) {
727
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
728
- if (m)
729
- return m.call(o);
730
- if (o && typeof o.length === "number")
731
- return {
732
- next: function () {
733
- if (o && i >= o.length)
734
- o = void 0;
735
- return { value: o && o[i++], done: !o };
736
- }
737
- };
738
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
739
- }
740
- function __read(o, n) {
741
- var m = typeof Symbol === "function" && o[Symbol.iterator];
742
- if (!m)
743
- return o;
744
- var i = m.call(o), r, ar = [], e;
745
- try {
746
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
747
- ar.push(r.value);
748
- }
749
- catch (error) {
750
- e = { error: error };
751
- }
752
- finally {
753
- try {
754
- if (r && !r.done && (m = i["return"]))
755
- m.call(i);
756
- }
757
- finally {
758
- if (e)
759
- throw e.error;
760
- }
761
- }
762
- return ar;
763
- }
764
- /** @deprecated */
765
- function __spread() {
766
- for (var ar = [], i = 0; i < arguments.length; i++)
767
- ar = ar.concat(__read(arguments[i]));
768
- return ar;
769
- }
770
- /** @deprecated */
771
- function __spreadArrays() {
772
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
773
- s += arguments[i].length;
774
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
775
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
776
- r[k] = a[j];
777
- return r;
778
- }
779
- function __spreadArray(to, from) {
780
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
781
- to[j] = from[i];
782
- return to;
783
- }
784
- function __await(v) {
785
- return this instanceof __await ? (this.v = v, this) : new __await(v);
786
- }
787
- function __asyncGenerator(thisArg, _arguments, generator) {
788
- if (!Symbol.asyncIterator)
789
- throw new TypeError("Symbol.asyncIterator is not defined.");
790
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
791
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
792
- function verb(n) { if (g[n])
793
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
794
- function resume(n, v) { try {
795
- step(g[n](v));
796
- }
797
- catch (e) {
798
- settle(q[0][3], e);
799
- } }
800
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
801
- function fulfill(value) { resume("next", value); }
802
- function reject(value) { resume("throw", value); }
803
- function settle(f, v) { if (f(v), q.shift(), q.length)
804
- resume(q[0][0], q[0][1]); }
805
- }
806
- function __asyncDelegator(o) {
807
- var i, p;
808
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
809
- 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; }
810
- }
811
- function __asyncValues(o) {
812
- if (!Symbol.asyncIterator)
813
- throw new TypeError("Symbol.asyncIterator is not defined.");
814
- var m = o[Symbol.asyncIterator], i;
815
- 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);
816
- 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); }); }; }
817
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
818
- }
819
- function __makeTemplateObject(cooked, raw) {
820
- if (Object.defineProperty) {
821
- Object.defineProperty(cooked, "raw", { value: raw });
822
- }
823
- else {
824
- cooked.raw = raw;
825
- }
826
- return cooked;
827
- }
828
- ;
829
- var __setModuleDefault = Object.create ? (function (o, v) {
830
- Object.defineProperty(o, "default", { enumerable: true, value: v });
831
- }) : function (o, v) {
832
- o["default"] = v;
833
- };
834
- function __importStar(mod) {
835
- if (mod && mod.__esModule)
836
- return mod;
837
- var result = {};
838
- if (mod != null)
839
- for (var k in mod)
840
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
841
- __createBinding(result, mod, k);
842
- __setModuleDefault(result, mod);
843
- return result;
844
- }
845
- function __importDefault(mod) {
846
- return (mod && mod.__esModule) ? mod : { default: mod };
847
- }
848
- function __classPrivateFieldGet(receiver, state, kind, f) {
849
- if (kind === "a" && !f)
850
- throw new TypeError("Private accessor was defined without a getter");
851
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
852
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
853
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
854
- }
855
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
856
- if (kind === "m")
857
- throw new TypeError("Private method is not writable");
858
- if (kind === "a" && !f)
859
- throw new TypeError("Private accessor was defined without a setter");
860
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
861
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
862
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
574
+ /*! *****************************************************************************
575
+ Copyright (c) Microsoft Corporation.
576
+
577
+ Permission to use, copy, modify, and/or distribute this software for any
578
+ purpose with or without fee is hereby granted.
579
+
580
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
581
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
582
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
583
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
584
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
585
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
586
+ PERFORMANCE OF THIS SOFTWARE.
587
+ ***************************************************************************** */
588
+ /* global Reflect, Promise */
589
+ var extendStatics = function (d, b) {
590
+ extendStatics = Object.setPrototypeOf ||
591
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
592
+ function (d, b) { for (var p in b)
593
+ if (Object.prototype.hasOwnProperty.call(b, p))
594
+ d[p] = b[p]; };
595
+ return extendStatics(d, b);
596
+ };
597
+ function __extends(d, b) {
598
+ if (typeof b !== "function" && b !== null)
599
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
600
+ extendStatics(d, b);
601
+ function __() { this.constructor = d; }
602
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
603
+ }
604
+ var __assign = function () {
605
+ __assign = Object.assign || function __assign(t) {
606
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
607
+ s = arguments[i];
608
+ for (var p in s)
609
+ if (Object.prototype.hasOwnProperty.call(s, p))
610
+ t[p] = s[p];
611
+ }
612
+ return t;
613
+ };
614
+ return __assign.apply(this, arguments);
615
+ };
616
+ function __rest(s, e) {
617
+ var t = {};
618
+ for (var p in s)
619
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
620
+ t[p] = s[p];
621
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
622
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
623
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
624
+ t[p[i]] = s[p[i]];
625
+ }
626
+ return t;
627
+ }
628
+ function __decorate(decorators, target, key, desc) {
629
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
630
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
631
+ r = Reflect.decorate(decorators, target, key, desc);
632
+ else
633
+ for (var i = decorators.length - 1; i >= 0; i--)
634
+ if (d = decorators[i])
635
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
636
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
637
+ }
638
+ function __param(paramIndex, decorator) {
639
+ return function (target, key) { decorator(target, key, paramIndex); };
640
+ }
641
+ function __metadata(metadataKey, metadataValue) {
642
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
643
+ return Reflect.metadata(metadataKey, metadataValue);
644
+ }
645
+ function __awaiter(thisArg, _arguments, P, generator) {
646
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
647
+ return new (P || (P = Promise))(function (resolve, reject) {
648
+ function fulfilled(value) { try {
649
+ step(generator.next(value));
650
+ }
651
+ catch (e) {
652
+ reject(e);
653
+ } }
654
+ function rejected(value) { try {
655
+ step(generator["throw"](value));
656
+ }
657
+ catch (e) {
658
+ reject(e);
659
+ } }
660
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
661
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
662
+ });
663
+ }
664
+ function __generator(thisArg, body) {
665
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
666
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
667
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
668
+ function verb(n) { return function (v) { return step([n, v]); }; }
669
+ function step(op) {
670
+ if (f)
671
+ throw new TypeError("Generator is already executing.");
672
+ while (_)
673
+ try {
674
+ 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)
675
+ return t;
676
+ if (y = 0, t)
677
+ op = [op[0] & 2, t.value];
678
+ switch (op[0]) {
679
+ case 0:
680
+ case 1:
681
+ t = op;
682
+ break;
683
+ case 4:
684
+ _.label++;
685
+ return { value: op[1], done: false };
686
+ case 5:
687
+ _.label++;
688
+ y = op[1];
689
+ op = [0];
690
+ continue;
691
+ case 7:
692
+ op = _.ops.pop();
693
+ _.trys.pop();
694
+ continue;
695
+ default:
696
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
697
+ _ = 0;
698
+ continue;
699
+ }
700
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
701
+ _.label = op[1];
702
+ break;
703
+ }
704
+ if (op[0] === 6 && _.label < t[1]) {
705
+ _.label = t[1];
706
+ t = op;
707
+ break;
708
+ }
709
+ if (t && _.label < t[2]) {
710
+ _.label = t[2];
711
+ _.ops.push(op);
712
+ break;
713
+ }
714
+ if (t[2])
715
+ _.ops.pop();
716
+ _.trys.pop();
717
+ continue;
718
+ }
719
+ op = body.call(thisArg, _);
720
+ }
721
+ catch (e) {
722
+ op = [6, e];
723
+ y = 0;
724
+ }
725
+ finally {
726
+ f = t = 0;
727
+ }
728
+ if (op[0] & 5)
729
+ throw op[1];
730
+ return { value: op[0] ? op[1] : void 0, done: true };
731
+ }
732
+ }
733
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
734
+ if (k2 === undefined)
735
+ k2 = k;
736
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
737
+ }) : (function (o, m, k, k2) {
738
+ if (k2 === undefined)
739
+ k2 = k;
740
+ o[k2] = m[k];
741
+ });
742
+ function __exportStar(m, o) {
743
+ for (var p in m)
744
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
745
+ __createBinding(o, m, p);
746
+ }
747
+ function __values(o) {
748
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
749
+ if (m)
750
+ return m.call(o);
751
+ if (o && typeof o.length === "number")
752
+ return {
753
+ next: function () {
754
+ if (o && i >= o.length)
755
+ o = void 0;
756
+ return { value: o && o[i++], done: !o };
757
+ }
758
+ };
759
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
760
+ }
761
+ function __read(o, n) {
762
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
763
+ if (!m)
764
+ return o;
765
+ var i = m.call(o), r, ar = [], e;
766
+ try {
767
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
768
+ ar.push(r.value);
769
+ }
770
+ catch (error) {
771
+ e = { error: error };
772
+ }
773
+ finally {
774
+ try {
775
+ if (r && !r.done && (m = i["return"]))
776
+ m.call(i);
777
+ }
778
+ finally {
779
+ if (e)
780
+ throw e.error;
781
+ }
782
+ }
783
+ return ar;
784
+ }
785
+ /** @deprecated */
786
+ function __spread() {
787
+ for (var ar = [], i = 0; i < arguments.length; i++)
788
+ ar = ar.concat(__read(arguments[i]));
789
+ return ar;
790
+ }
791
+ /** @deprecated */
792
+ function __spreadArrays() {
793
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
794
+ s += arguments[i].length;
795
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
796
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
797
+ r[k] = a[j];
798
+ return r;
799
+ }
800
+ function __spreadArray(to, from, pack) {
801
+ if (pack || arguments.length === 2)
802
+ for (var i = 0, l = from.length, ar; i < l; i++) {
803
+ if (ar || !(i in from)) {
804
+ if (!ar)
805
+ ar = Array.prototype.slice.call(from, 0, i);
806
+ ar[i] = from[i];
807
+ }
808
+ }
809
+ return to.concat(ar || Array.prototype.slice.call(from));
810
+ }
811
+ function __await(v) {
812
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
813
+ }
814
+ function __asyncGenerator(thisArg, _arguments, generator) {
815
+ if (!Symbol.asyncIterator)
816
+ throw new TypeError("Symbol.asyncIterator is not defined.");
817
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
818
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
819
+ function verb(n) { if (g[n])
820
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
821
+ function resume(n, v) { try {
822
+ step(g[n](v));
823
+ }
824
+ catch (e) {
825
+ settle(q[0][3], e);
826
+ } }
827
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
828
+ function fulfill(value) { resume("next", value); }
829
+ function reject(value) { resume("throw", value); }
830
+ function settle(f, v) { if (f(v), q.shift(), q.length)
831
+ resume(q[0][0], q[0][1]); }
832
+ }
833
+ function __asyncDelegator(o) {
834
+ var i, p;
835
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
836
+ 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; }
837
+ }
838
+ function __asyncValues(o) {
839
+ if (!Symbol.asyncIterator)
840
+ throw new TypeError("Symbol.asyncIterator is not defined.");
841
+ var m = o[Symbol.asyncIterator], i;
842
+ 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);
843
+ 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); }); }; }
844
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
845
+ }
846
+ function __makeTemplateObject(cooked, raw) {
847
+ if (Object.defineProperty) {
848
+ Object.defineProperty(cooked, "raw", { value: raw });
849
+ }
850
+ else {
851
+ cooked.raw = raw;
852
+ }
853
+ return cooked;
854
+ }
855
+ ;
856
+ var __setModuleDefault = Object.create ? (function (o, v) {
857
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
858
+ }) : function (o, v) {
859
+ o["default"] = v;
860
+ };
861
+ function __importStar(mod) {
862
+ if (mod && mod.__esModule)
863
+ return mod;
864
+ var result = {};
865
+ if (mod != null)
866
+ for (var k in mod)
867
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
868
+ __createBinding(result, mod, k);
869
+ __setModuleDefault(result, mod);
870
+ return result;
871
+ }
872
+ function __importDefault(mod) {
873
+ return (mod && mod.__esModule) ? mod : { default: mod };
874
+ }
875
+ function __classPrivateFieldGet(receiver, state, kind, f) {
876
+ if (kind === "a" && !f)
877
+ throw new TypeError("Private accessor was defined without a getter");
878
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
879
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
880
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
881
+ }
882
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
883
+ if (kind === "m")
884
+ throw new TypeError("Private method is not writable");
885
+ if (kind === "a" && !f)
886
+ throw new TypeError("Private accessor was defined without a setter");
887
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
888
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
889
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
863
890
  }
864
891
 
865
- /**
866
- * Custom navigation used for Angular client-side navigation.
867
- * See performance doc for details:
868
- * https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/docs/v2-docs/performance.md
869
- */
870
- var MsalCustomNavigationClient = /** @class */ (function (_super_1) {
871
- __extends(MsalCustomNavigationClient, _super_1);
872
- function MsalCustomNavigationClient(authService, router, location) {
873
- var _this = _super_1.call(this) || this;
874
- _this.authService = authService;
875
- _this.router = router;
876
- _this.location = location;
877
- return _this;
878
- }
879
- MsalCustomNavigationClient.prototype.navigateInternal = function (url, options) {
880
- var _super = Object.create(null, {
881
- navigateInternal: { get: function () { return _super_1.prototype.navigateInternal; } }
882
- });
883
- return __awaiter(this, void 0, void 0, function () {
884
- var urlComponents, newUrl;
885
- return __generator(this, function (_a) {
886
- this.authService.getLogger().trace("MsalCustomNavigationClient called");
887
- this.authService.getLogger().verbose("MsalCustomNavigationClient - navigating");
888
- this.authService.getLogger().verbosePii("MsalCustomNavigationClient - navigating to url: " + url);
889
- // Prevent hash clearing from causing an issue with Client-side navigation after redirect is handled
890
- if (options.noHistory) {
891
- return [2 /*return*/, _super.navigateInternal.call(this, url, options)];
892
- }
893
- else {
894
- urlComponents = new msalBrowser.UrlString(url).getUrlComponents();
895
- newUrl = urlComponents.QueryString ? urlComponents.AbsolutePath + "?" + urlComponents.QueryString : this.location.normalize(urlComponents.AbsolutePath);
896
- this.router.navigateByUrl(newUrl, { replaceUrl: options.noHistory });
897
- }
898
- return [2 /*return*/, Promise.resolve(options.noHistory)];
899
- });
900
- });
901
- };
902
- return MsalCustomNavigationClient;
903
- }(msalBrowser.NavigationClient));
904
- MsalCustomNavigationClient.decorators = [
905
- { type: core.Injectable }
906
- ];
907
- MsalCustomNavigationClient.ctorParameters = function () { return [
908
- { type: MsalService },
909
- { type: router.Router },
910
- { type: common.Location }
892
+ /**
893
+ * Custom navigation used for Angular client-side navigation.
894
+ * See performance doc for details:
895
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/docs/v2-docs/performance.md
896
+ */
897
+ var MsalCustomNavigationClient = /** @class */ (function (_super_1) {
898
+ __extends(MsalCustomNavigationClient, _super_1);
899
+ function MsalCustomNavigationClient(authService, router, location) {
900
+ var _this = _super_1.call(this) || this;
901
+ _this.authService = authService;
902
+ _this.router = router;
903
+ _this.location = location;
904
+ return _this;
905
+ }
906
+ MsalCustomNavigationClient.prototype.navigateInternal = function (url, options) {
907
+ var _super = Object.create(null, {
908
+ navigateInternal: { get: function () { return _super_1.prototype.navigateInternal; } }
909
+ });
910
+ return __awaiter(this, void 0, void 0, function () {
911
+ var urlComponents, newUrl;
912
+ return __generator(this, function (_a) {
913
+ this.authService.getLogger().trace("MsalCustomNavigationClient called");
914
+ this.authService.getLogger().verbose("MsalCustomNavigationClient - navigating");
915
+ this.authService.getLogger().verbosePii("MsalCustomNavigationClient - navigating to url: " + url);
916
+ // Prevent hash clearing from causing an issue with Client-side navigation after redirect is handled
917
+ if (options.noHistory) {
918
+ return [2 /*return*/, _super.navigateInternal.call(this, url, options)];
919
+ }
920
+ else {
921
+ urlComponents = new msalBrowser.UrlString(url).getUrlComponents();
922
+ newUrl = urlComponents.QueryString ? urlComponents.AbsolutePath + "?" + urlComponents.QueryString : this.location.normalize(urlComponents.AbsolutePath);
923
+ this.router.navigateByUrl(newUrl, { replaceUrl: options.noHistory });
924
+ }
925
+ return [2 /*return*/, Promise.resolve(options.noHistory)];
926
+ });
927
+ });
928
+ };
929
+ return MsalCustomNavigationClient;
930
+ }(msalBrowser.NavigationClient));
931
+ MsalCustomNavigationClient.decorators = [
932
+ { type: core.Injectable }
933
+ ];
934
+ MsalCustomNavigationClient.ctorParameters = function () { return [
935
+ { type: MsalService },
936
+ { type: router.Router },
937
+ { type: common.Location }
911
938
  ]; };
912
939
 
913
- /*
914
- * Copyright (c) Microsoft Corporation. All rights reserved.
915
- * Licensed under the MIT License.
940
+ /*
941
+ * Copyright (c) Microsoft Corporation. All rights reserved.
942
+ * Licensed under the MIT License.
916
943
  */
917
944
 
918
- /**
919
- * Generated bundle index. Do not edit.
945
+ /**
946
+ * Generated bundle index. Do not edit.
920
947
  */
921
948
 
922
949
  exports.MSAL_GUARD_CONFIG = MSAL_GUARD_CONFIG;