@azure/msal-angular 2.0.4 → 2.0.5

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 +918 -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 +188 -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 +588 -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,945 @@
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.0.5";
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") === path.length - "/code".length || // path.endsWith("/code")
274
+ path.indexOf("#code=") > -1 ||
275
+ path.indexOf("&code=") > -1;
276
+ };
277
+ MsalGuard.prototype.canActivate = function (route, state) {
278
+ this.authService.getLogger().verbose("Guard - canActivate");
279
+ return this.activateHelper(state);
280
+ };
281
+ MsalGuard.prototype.canActivateChild = function (route, state) {
282
+ this.authService.getLogger().verbose("Guard - canActivateChild");
283
+ return this.activateHelper(state);
284
+ };
285
+ MsalGuard.prototype.canLoad = function () {
286
+ this.authService.getLogger().verbose("Guard - canLoad");
287
+ // @ts-ignore
288
+ return this.activateHelper();
289
+ };
290
+ return MsalGuard;
291
+ }());
292
+ MsalGuard.decorators = [
293
+ { type: core.Injectable }
294
+ ];
295
+ MsalGuard.ctorParameters = function () { return [
296
+ { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_GUARD_CONFIG,] }] },
297
+ { type: MsalBroadcastService },
298
+ { type: MsalService },
299
+ { type: common.Location },
300
+ { type: router.Router }
281
301
  ]; };
282
302
 
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,] }] }
303
+ /*
304
+ * Copyright (c) Microsoft Corporation. All rights reserved.
305
+ * Licensed under the MIT License.
306
+ */
307
+ var MsalInterceptor = /** @class */ (function () {
308
+ function MsalInterceptor(msalInterceptorConfig, authService, location,
309
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
310
+ document) {
311
+ this.msalInterceptorConfig = msalInterceptorConfig;
312
+ this.authService = authService;
313
+ this.location = location;
314
+ this._document = document;
315
+ }
316
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
317
+ MsalInterceptor.prototype.intercept = function (req, next) {
318
+ var _this = this;
319
+ if (this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Popup && this.msalInterceptorConfig.interactionType !== msalBrowser.InteractionType.Redirect) {
320
+ throw new msalBrowser.BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
321
+ }
322
+ this.authService.getLogger().verbose("MSAL Interceptor activated");
323
+ var scopes = this.getScopesForEndpoint(req.url, req.method);
324
+ // If no scopes for endpoint, does not acquire token
325
+ if (!scopes || scopes.length === 0) {
326
+ this.authService.getLogger().verbose("Interceptor - no scopes for endpoint");
327
+ return next.handle(req);
328
+ }
329
+ // Sets account as active account or first account
330
+ var account;
331
+ if (!!this.authService.instance.getActiveAccount()) {
332
+ this.authService.getLogger().verbose("Interceptor - active account selected");
333
+ account = this.authService.instance.getActiveAccount();
334
+ }
335
+ else {
336
+ this.authService.getLogger().verbose("Interceptor - no active account, fallback to first account");
337
+ account = this.authService.instance.getAllAccounts()[0];
338
+ }
339
+ var authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
340
+ ? this.msalInterceptorConfig.authRequest(this.authService, req, { account: account })
341
+ : Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { account: account });
342
+ this.authService.getLogger().info("Interceptor - " + scopes.length + " scopes found for endpoint");
343
+ this.authService.getLogger().infoPii("Interceptor - [" + scopes + "] scopes found for " + req.url);
344
+ // Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken
345
+ return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, authRequest), { scopes: scopes, account: account }))
346
+ .pipe(operators.catchError(function () {
347
+ _this.authService.getLogger().error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
348
+ return _this.acquireTokenInteractively(authRequest, scopes);
349
+ }), operators.switchMap(function (result) {
350
+ if (!result.accessToken) {
351
+ _this.authService.getLogger().error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
352
+ return _this.acquireTokenInteractively(authRequest, scopes);
353
+ }
354
+ return rxjs.of(result);
355
+ }), operators.switchMap(function (result) {
356
+ _this.authService.getLogger().verbose("Interceptor - setting authorization headers");
357
+ var headers = req.headers
358
+ .set("Authorization", "Bearer " + result.accessToken);
359
+ var requestClone = req.clone({ headers: headers });
360
+ return next.handle(requestClone);
361
+ }));
362
+ };
363
+ /**
364
+ * Invoke interaction for the given set of scopes
365
+ * @param authRequest Request
366
+ * @param scopes Array of scopes for the request
367
+ * @returns Result from the interactive request
368
+ */
369
+ MsalInterceptor.prototype.acquireTokenInteractively = function (authRequest, scopes) {
370
+ if (this.msalInterceptorConfig.interactionType === msalBrowser.InteractionType.Popup) {
371
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by popup");
372
+ return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, authRequest), { scopes: scopes }));
373
+ }
374
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by redirect");
375
+ var redirectStartPage = window.location.href;
376
+ this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, authRequest), { scopes: scopes, redirectStartPage: redirectStartPage }));
377
+ return rxjs.EMPTY;
378
+ };
379
+ /**
380
+ * Looks up the scopes for the given endpoint from the protectedResourceMap
381
+ * @param endpoint Url of the request
382
+ * @param httpMethod Http method of the request
383
+ * @returns Array of scopes, or null if not found
384
+ *
385
+ */
386
+ MsalInterceptor.prototype.getScopesForEndpoint = function (endpoint, httpMethod) {
387
+ this.authService.getLogger().verbose("Interceptor - getting scopes for endpoint");
388
+ // Ensures endpoints and protected resources compared are normalized
389
+ var normalizedEndpoint = this.location.normalize(endpoint);
390
+ var protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
391
+ var matchingProtectedResources = this.matchResourcesToEndpoint(protectedResourcesArray, normalizedEndpoint);
392
+ // Check absolute urls of resources first before checking relative to prevent incorrect matching where multiple resources have similar relative urls
393
+ if (matchingProtectedResources.absoluteResources.length > 0) {
394
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.absoluteResources, httpMethod);
395
+ }
396
+ else if (matchingProtectedResources.relativeResources.length > 0) {
397
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.relativeResources, httpMethod);
398
+ }
399
+ return null;
400
+ };
401
+ /**
402
+ * Finds resource endpoints that match request endpoint
403
+ * @param protectedResourcesEndpoints
404
+ * @param endpoint
405
+ * @returns
406
+ */
407
+ MsalInterceptor.prototype.matchResourcesToEndpoint = function (protectedResourcesEndpoints, endpoint) {
408
+ var _this = this;
409
+ var matchingResources = { absoluteResources: [], relativeResources: [] };
410
+ protectedResourcesEndpoints.forEach(function (key) {
411
+ // Normalizes and adds resource to matchingResources.absoluteResources if key matches endpoint. StringUtils.matchPattern accounts for wildcards
412
+ var normalizedKey = _this.location.normalize(key);
413
+ if (msalBrowser.StringUtils.matchPattern(normalizedKey, endpoint)) {
414
+ matchingResources.absoluteResources.push(key);
415
+ }
416
+ // Get url components for relative urls
417
+ var absoluteKey = _this.getAbsoluteUrl(key);
418
+ var keyComponents = new msalBrowser.UrlString(absoluteKey).getUrlComponents();
419
+ var absoluteEndpoint = _this.getAbsoluteUrl(endpoint);
420
+ var endpointComponents = new msalBrowser.UrlString(absoluteEndpoint).getUrlComponents();
421
+ // Normalized key should include query strings if applicable
422
+ var relativeNormalizedKey = keyComponents.QueryString ? keyComponents.AbsolutePath + "?" + keyComponents.QueryString : _this.location.normalize(keyComponents.AbsolutePath);
423
+ // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
424
+ if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort && msalBrowser.StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) && relativeNormalizedKey !== "" && relativeNormalizedKey !== "/*") {
425
+ matchingResources.relativeResources.push(key);
426
+ }
427
+ });
428
+ return matchingResources;
429
+ };
430
+ /**
431
+ * Transforms relative urls to absolute urls
432
+ * @param url
433
+ * @returns
434
+ */
435
+ MsalInterceptor.prototype.getAbsoluteUrl = function (url) {
436
+ var link = this._document.createElement("a");
437
+ link.href = url;
438
+ return link.href;
439
+ };
440
+ /**
441
+ * Finds scopes from first matching endpoint with HTTP method that matches request
442
+ * @param protectedResourceMap Protected resource map
443
+ * @param endpointArray Array of resources that match request endpoint
444
+ * @param httpMethod Http method of the request
445
+ * @returns
446
+ */
447
+ MsalInterceptor.prototype.matchScopesToEndpoint = function (protectedResourceMap, endpointArray, httpMethod) {
448
+ var allMatchedScopes = [];
449
+ // Check each matched endpoint for matching HttpMethod and scopes
450
+ endpointArray.forEach(function (matchedEndpoint) {
451
+ var scopesForEndpoint = [];
452
+ var methodAndScopesArray = protectedResourceMap.get(matchedEndpoint);
453
+ // Return if resource is unprotected
454
+ if (methodAndScopesArray === null) {
455
+ allMatchedScopes.push(null);
456
+ return;
457
+ }
458
+ methodAndScopesArray.forEach(function (entry) {
459
+ // Entry is either array of scopes or ProtectedResourceScopes object
460
+ if (typeof entry === "string") {
461
+ scopesForEndpoint.push(entry);
462
+ }
463
+ else {
464
+ // Ensure methods being compared are normalized
465
+ var normalizedRequestMethod = httpMethod.toLowerCase();
466
+ var normalizedResourceMethod = entry.httpMethod.toLowerCase();
467
+ // Method in protectedResourceMap matches request http method
468
+ if (normalizedResourceMethod === normalizedRequestMethod) {
469
+ // Validate if scopes comes null to unprotect the resource in a certain http method
470
+ if (entry.scopes === null) {
471
+ allMatchedScopes.push(null);
472
+ }
473
+ else {
474
+ entry.scopes.forEach(function (scope) {
475
+ scopesForEndpoint.push(scope);
476
+ });
477
+ }
478
+ }
479
+ }
480
+ });
481
+ // Only add to all scopes if scopes for endpoint and method is found
482
+ if (scopesForEndpoint.length > 0) {
483
+ allMatchedScopes.push(scopesForEndpoint);
484
+ }
485
+ });
486
+ if (allMatchedScopes.length > 0) {
487
+ if (allMatchedScopes.length > 1) {
488
+ this.authService.getLogger().warning("Interceptor - More than 1 matching scopes for endpoint found.");
489
+ }
490
+ // Returns scopes for first matching endpoint
491
+ return allMatchedScopes[0];
492
+ }
493
+ return null;
494
+ };
495
+ return MsalInterceptor;
496
+ }());
497
+ MsalInterceptor.decorators = [
498
+ { type: core.Injectable }
499
+ ];
500
+ MsalInterceptor.ctorParameters = function () { return [
501
+ { type: undefined, decorators: [{ type: core.Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] },
502
+ { type: MsalService },
503
+ { type: common.Location },
504
+ { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
485
505
  ]; };
486
506
 
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 }
507
+ /*
508
+ * Copyright (c) Microsoft Corporation. All rights reserved.
509
+ * Licensed under the MIT License.
510
+ */
511
+ var MsalRedirectComponent = /** @class */ (function () {
512
+ function MsalRedirectComponent(authService) {
513
+ this.authService = authService;
514
+ }
515
+ MsalRedirectComponent.prototype.ngOnInit = function () {
516
+ this.authService.getLogger().verbose("MsalRedirectComponent activated");
517
+ this.authService.handleRedirectObservable().subscribe();
518
+ };
519
+ return MsalRedirectComponent;
520
+ }());
521
+ MsalRedirectComponent.decorators = [
522
+ { type: core.Component, args: [{
523
+ selector: "app-redirect",
524
+ template: ""
525
+ },] }
526
+ ];
527
+ MsalRedirectComponent.ctorParameters = function () { return [
528
+ { type: MsalService }
509
529
  ]; };
510
530
 
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
- },] }
531
+ /*
532
+ * Copyright (c) Microsoft Corporation. All rights reserved.
533
+ * Licensed under the MIT License.
534
+ */
535
+ var MsalModule = /** @class */ (function () {
536
+ function MsalModule() {
537
+ }
538
+ MsalModule.forRoot = function (msalInstance, guardConfig, interceptorConfig) {
539
+ return {
540
+ ngModule: MsalModule,
541
+ providers: [
542
+ {
543
+ provide: MSAL_INSTANCE,
544
+ useValue: msalInstance
545
+ },
546
+ {
547
+ provide: MSAL_GUARD_CONFIG,
548
+ useValue: guardConfig
549
+ },
550
+ {
551
+ provide: MSAL_INTERCEPTOR_CONFIG,
552
+ useValue: interceptorConfig
553
+ },
554
+ MsalService
555
+ ]
556
+ };
557
+ };
558
+ return MsalModule;
559
+ }());
560
+ MsalModule.decorators = [
561
+ { type: core.NgModule, args: [{
562
+ declarations: [MsalRedirectComponent],
563
+ imports: [
564
+ common.CommonModule
565
+ ],
566
+ providers: [
567
+ MsalGuard,
568
+ MsalBroadcastService
569
+ ]
570
+ },] }
551
571
  ];
552
572
 
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;
573
+ /*! *****************************************************************************
574
+ Copyright (c) Microsoft Corporation.
575
+
576
+ Permission to use, copy, modify, and/or distribute this software for any
577
+ purpose with or without fee is hereby granted.
578
+
579
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
580
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
581
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
582
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
583
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
584
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
585
+ PERFORMANCE OF THIS SOFTWARE.
586
+ ***************************************************************************** */
587
+ /* global Reflect, Promise */
588
+ var extendStatics = function (d, b) {
589
+ extendStatics = Object.setPrototypeOf ||
590
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
591
+ function (d, b) { for (var p in b)
592
+ if (Object.prototype.hasOwnProperty.call(b, p))
593
+ d[p] = b[p]; };
594
+ return extendStatics(d, b);
595
+ };
596
+ function __extends(d, b) {
597
+ if (typeof b !== "function" && b !== null)
598
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
599
+ extendStatics(d, b);
600
+ function __() { this.constructor = d; }
601
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
602
+ }
603
+ var __assign = function () {
604
+ __assign = Object.assign || function __assign(t) {
605
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
606
+ s = arguments[i];
607
+ for (var p in s)
608
+ if (Object.prototype.hasOwnProperty.call(s, p))
609
+ t[p] = s[p];
610
+ }
611
+ return t;
612
+ };
613
+ return __assign.apply(this, arguments);
614
+ };
615
+ function __rest(s, e) {
616
+ var t = {};
617
+ for (var p in s)
618
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
619
+ t[p] = s[p];
620
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
621
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
622
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
623
+ t[p[i]] = s[p[i]];
624
+ }
625
+ return t;
626
+ }
627
+ function __decorate(decorators, target, key, desc) {
628
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
629
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
630
+ r = Reflect.decorate(decorators, target, key, desc);
631
+ else
632
+ for (var i = decorators.length - 1; i >= 0; i--)
633
+ if (d = decorators[i])
634
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
635
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
636
+ }
637
+ function __param(paramIndex, decorator) {
638
+ return function (target, key) { decorator(target, key, paramIndex); };
639
+ }
640
+ function __metadata(metadataKey, metadataValue) {
641
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
642
+ return Reflect.metadata(metadataKey, metadataValue);
643
+ }
644
+ function __awaiter(thisArg, _arguments, P, generator) {
645
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
646
+ return new (P || (P = Promise))(function (resolve, reject) {
647
+ function fulfilled(value) { try {
648
+ step(generator.next(value));
649
+ }
650
+ catch (e) {
651
+ reject(e);
652
+ } }
653
+ function rejected(value) { try {
654
+ step(generator["throw"](value));
655
+ }
656
+ catch (e) {
657
+ reject(e);
658
+ } }
659
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
660
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
661
+ });
662
+ }
663
+ function __generator(thisArg, body) {
664
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
665
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
666
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
667
+ function verb(n) { return function (v) { return step([n, v]); }; }
668
+ function step(op) {
669
+ if (f)
670
+ throw new TypeError("Generator is already executing.");
671
+ while (_)
672
+ try {
673
+ 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)
674
+ return t;
675
+ if (y = 0, t)
676
+ op = [op[0] & 2, t.value];
677
+ switch (op[0]) {
678
+ case 0:
679
+ case 1:
680
+ t = op;
681
+ break;
682
+ case 4:
683
+ _.label++;
684
+ return { value: op[1], done: false };
685
+ case 5:
686
+ _.label++;
687
+ y = op[1];
688
+ op = [0];
689
+ continue;
690
+ case 7:
691
+ op = _.ops.pop();
692
+ _.trys.pop();
693
+ continue;
694
+ default:
695
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
696
+ _ = 0;
697
+ continue;
698
+ }
699
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
700
+ _.label = op[1];
701
+ break;
702
+ }
703
+ if (op[0] === 6 && _.label < t[1]) {
704
+ _.label = t[1];
705
+ t = op;
706
+ break;
707
+ }
708
+ if (t && _.label < t[2]) {
709
+ _.label = t[2];
710
+ _.ops.push(op);
711
+ break;
712
+ }
713
+ if (t[2])
714
+ _.ops.pop();
715
+ _.trys.pop();
716
+ continue;
717
+ }
718
+ op = body.call(thisArg, _);
719
+ }
720
+ catch (e) {
721
+ op = [6, e];
722
+ y = 0;
723
+ }
724
+ finally {
725
+ f = t = 0;
726
+ }
727
+ if (op[0] & 5)
728
+ throw op[1];
729
+ return { value: op[0] ? op[1] : void 0, done: true };
730
+ }
731
+ }
732
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
733
+ if (k2 === undefined)
734
+ k2 = k;
735
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
736
+ }) : (function (o, m, k, k2) {
737
+ if (k2 === undefined)
738
+ k2 = k;
739
+ o[k2] = m[k];
740
+ });
741
+ function __exportStar(m, o) {
742
+ for (var p in m)
743
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
744
+ __createBinding(o, m, p);
745
+ }
746
+ function __values(o) {
747
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
748
+ if (m)
749
+ return m.call(o);
750
+ if (o && typeof o.length === "number")
751
+ return {
752
+ next: function () {
753
+ if (o && i >= o.length)
754
+ o = void 0;
755
+ return { value: o && o[i++], done: !o };
756
+ }
757
+ };
758
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
759
+ }
760
+ function __read(o, n) {
761
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
762
+ if (!m)
763
+ return o;
764
+ var i = m.call(o), r, ar = [], e;
765
+ try {
766
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
767
+ ar.push(r.value);
768
+ }
769
+ catch (error) {
770
+ e = { error: error };
771
+ }
772
+ finally {
773
+ try {
774
+ if (r && !r.done && (m = i["return"]))
775
+ m.call(i);
776
+ }
777
+ finally {
778
+ if (e)
779
+ throw e.error;
780
+ }
781
+ }
782
+ return ar;
783
+ }
784
+ /** @deprecated */
785
+ function __spread() {
786
+ for (var ar = [], i = 0; i < arguments.length; i++)
787
+ ar = ar.concat(__read(arguments[i]));
788
+ return ar;
789
+ }
790
+ /** @deprecated */
791
+ function __spreadArrays() {
792
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
793
+ s += arguments[i].length;
794
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
795
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
796
+ r[k] = a[j];
797
+ return r;
798
+ }
799
+ function __spreadArray(to, from, pack) {
800
+ if (pack || arguments.length === 2)
801
+ for (var i = 0, l = from.length, ar; i < l; i++) {
802
+ if (ar || !(i in from)) {
803
+ if (!ar)
804
+ ar = Array.prototype.slice.call(from, 0, i);
805
+ ar[i] = from[i];
806
+ }
807
+ }
808
+ return to.concat(ar || Array.prototype.slice.call(from));
809
+ }
810
+ function __await(v) {
811
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
812
+ }
813
+ function __asyncGenerator(thisArg, _arguments, generator) {
814
+ if (!Symbol.asyncIterator)
815
+ throw new TypeError("Symbol.asyncIterator is not defined.");
816
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
817
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
818
+ function verb(n) { if (g[n])
819
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
820
+ function resume(n, v) { try {
821
+ step(g[n](v));
822
+ }
823
+ catch (e) {
824
+ settle(q[0][3], e);
825
+ } }
826
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
827
+ function fulfill(value) { resume("next", value); }
828
+ function reject(value) { resume("throw", value); }
829
+ function settle(f, v) { if (f(v), q.shift(), q.length)
830
+ resume(q[0][0], q[0][1]); }
831
+ }
832
+ function __asyncDelegator(o) {
833
+ var i, p;
834
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
835
+ 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; }
836
+ }
837
+ function __asyncValues(o) {
838
+ if (!Symbol.asyncIterator)
839
+ throw new TypeError("Symbol.asyncIterator is not defined.");
840
+ var m = o[Symbol.asyncIterator], i;
841
+ 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);
842
+ 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); }); }; }
843
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
844
+ }
845
+ function __makeTemplateObject(cooked, raw) {
846
+ if (Object.defineProperty) {
847
+ Object.defineProperty(cooked, "raw", { value: raw });
848
+ }
849
+ else {
850
+ cooked.raw = raw;
851
+ }
852
+ return cooked;
853
+ }
854
+ ;
855
+ var __setModuleDefault = Object.create ? (function (o, v) {
856
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
857
+ }) : function (o, v) {
858
+ o["default"] = v;
859
+ };
860
+ function __importStar(mod) {
861
+ if (mod && mod.__esModule)
862
+ return mod;
863
+ var result = {};
864
+ if (mod != null)
865
+ for (var k in mod)
866
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
867
+ __createBinding(result, mod, k);
868
+ __setModuleDefault(result, mod);
869
+ return result;
870
+ }
871
+ function __importDefault(mod) {
872
+ return (mod && mod.__esModule) ? mod : { default: mod };
873
+ }
874
+ function __classPrivateFieldGet(receiver, state, kind, f) {
875
+ if (kind === "a" && !f)
876
+ throw new TypeError("Private accessor was defined without a getter");
877
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
878
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
879
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
880
+ }
881
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
882
+ if (kind === "m")
883
+ throw new TypeError("Private method is not writable");
884
+ if (kind === "a" && !f)
885
+ throw new TypeError("Private accessor was defined without a setter");
886
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
887
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
888
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
863
889
  }
864
890
 
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 }
891
+ /**
892
+ * Custom navigation used for Angular client-side navigation.
893
+ * See performance doc for details:
894
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/docs/v2-docs/performance.md
895
+ */
896
+ var MsalCustomNavigationClient = /** @class */ (function (_super_1) {
897
+ __extends(MsalCustomNavigationClient, _super_1);
898
+ function MsalCustomNavigationClient(authService, router, location) {
899
+ var _this = _super_1.call(this) || this;
900
+ _this.authService = authService;
901
+ _this.router = router;
902
+ _this.location = location;
903
+ return _this;
904
+ }
905
+ MsalCustomNavigationClient.prototype.navigateInternal = function (url, options) {
906
+ var _super = Object.create(null, {
907
+ navigateInternal: { get: function () { return _super_1.prototype.navigateInternal; } }
908
+ });
909
+ return __awaiter(this, void 0, void 0, function () {
910
+ var urlComponents, newUrl;
911
+ return __generator(this, function (_a) {
912
+ this.authService.getLogger().trace("MsalCustomNavigationClient called");
913
+ this.authService.getLogger().verbose("MsalCustomNavigationClient - navigating");
914
+ this.authService.getLogger().verbosePii("MsalCustomNavigationClient - navigating to url: " + url);
915
+ // Prevent hash clearing from causing an issue with Client-side navigation after redirect is handled
916
+ if (options.noHistory) {
917
+ return [2 /*return*/, _super.navigateInternal.call(this, url, options)];
918
+ }
919
+ else {
920
+ urlComponents = new msalBrowser.UrlString(url).getUrlComponents();
921
+ newUrl = urlComponents.QueryString ? urlComponents.AbsolutePath + "?" + urlComponents.QueryString : this.location.normalize(urlComponents.AbsolutePath);
922
+ this.router.navigateByUrl(newUrl, { replaceUrl: options.noHistory });
923
+ }
924
+ return [2 /*return*/, Promise.resolve(options.noHistory)];
925
+ });
926
+ });
927
+ };
928
+ return MsalCustomNavigationClient;
929
+ }(msalBrowser.NavigationClient));
930
+ MsalCustomNavigationClient.decorators = [
931
+ { type: core.Injectable }
932
+ ];
933
+ MsalCustomNavigationClient.ctorParameters = function () { return [
934
+ { type: MsalService },
935
+ { type: router.Router },
936
+ { type: common.Location }
911
937
  ]; };
912
938
 
913
- /*
914
- * Copyright (c) Microsoft Corporation. All rights reserved.
915
- * Licensed under the MIT License.
939
+ /*
940
+ * Copyright (c) Microsoft Corporation. All rights reserved.
941
+ * Licensed under the MIT License.
916
942
  */
917
943
 
918
- /**
919
- * Generated bundle index. Do not edit.
944
+ /**
945
+ * Generated bundle index. Do not edit.
920
946
  */
921
947
 
922
948
  exports.MSAL_GUARD_CONFIG = MSAL_GUARD_CONFIG;