@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
@@ -6,593 +6,614 @@ import { Router } from '@angular/router';
6
6
  import { map, concatMap, catchError, switchMap } from 'rxjs/operators';
7
7
  import { __awaiter } from 'tslib';
8
8
 
9
- /*
10
- * Copyright (c) Microsoft Corporation. All rights reserved.
11
- * Licensed under the MIT License.
12
- */
13
- const MSAL_INSTANCE = new InjectionToken("MSAL_INSTANCE");
14
- const MSAL_GUARD_CONFIG = new InjectionToken("MSAL_GUARD_CONFIG");
9
+ /*
10
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11
+ * Licensed under the MIT License.
12
+ */
13
+ const MSAL_INSTANCE = new InjectionToken("MSAL_INSTANCE");
14
+ const MSAL_GUARD_CONFIG = new InjectionToken("MSAL_GUARD_CONFIG");
15
15
  const MSAL_INTERCEPTOR_CONFIG = new InjectionToken("MSAL_INTERCEPTOR_CONFIG");
16
16
 
17
- /* eslint-disable header/header */
18
- const name = "@azure/msal-angular";
19
- const version = "2.0.4";
17
+ /* eslint-disable header/header */
18
+ const name = "@azure/msal-angular";
19
+ const version = "2.1.1";
20
20
 
21
- /*
22
- * Copyright (c) Microsoft Corporation. All rights reserved.
23
- * Licensed under the MIT License.
24
- */
25
- class MsalService {
26
- constructor(instance, location) {
27
- this.instance = instance;
28
- this.location = location;
29
- const hash = this.location.path(true).split("#").pop();
30
- if (hash) {
31
- this.redirectHash = `#${hash}`;
32
- }
33
- this.instance.initializeWrapperLibrary(WrapperSKU.Angular, version);
34
- }
35
- acquireTokenPopup(request) {
36
- return from(this.instance.acquireTokenPopup(request));
37
- }
38
- acquireTokenRedirect(request) {
39
- return from(this.instance.acquireTokenRedirect(request));
40
- }
41
- acquireTokenSilent(silentRequest) {
42
- return from(this.instance.acquireTokenSilent(silentRequest));
43
- }
44
- handleRedirectObservable(hash) {
45
- return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
46
- }
47
- loginPopup(request) {
48
- return from(this.instance.loginPopup(request));
49
- }
50
- loginRedirect(request) {
51
- return from(this.instance.loginRedirect(request));
52
- }
53
- logout(logoutRequest) {
54
- return from(this.instance.logout(logoutRequest));
55
- }
56
- logoutRedirect(logoutRequest) {
57
- return from(this.instance.logoutRedirect(logoutRequest));
58
- }
59
- logoutPopup(logoutRequest) {
60
- return from(this.instance.logoutPopup(logoutRequest));
61
- }
62
- ssoSilent(request) {
63
- return from(this.instance.ssoSilent(request));
64
- }
65
- /**
66
- * Gets logger for msal-angular.
67
- * If no logger set, returns logger instance created with same options as msal-browser
68
- */
69
- getLogger() {
70
- if (!this.logger) {
71
- this.logger = this.instance.getLogger().clone(name, version);
72
- }
73
- return this.logger;
74
- }
75
- // Create a logger instance for msal-angular with the same options as msal-browser
76
- setLogger(logger) {
77
- this.logger = logger.clone(name, version);
78
- this.instance.setLogger(logger);
79
- }
80
- }
81
- MsalService.decorators = [
82
- { type: Injectable }
83
- ];
84
- MsalService.ctorParameters = () => [
85
- { type: undefined, decorators: [{ type: Inject, args: [MSAL_INSTANCE,] }] },
86
- { type: Location }
21
+ /*
22
+ * Copyright (c) Microsoft Corporation. All rights reserved.
23
+ * Licensed under the MIT License.
24
+ */
25
+ class MsalService {
26
+ constructor(instance, location) {
27
+ this.instance = instance;
28
+ this.location = location;
29
+ const hash = this.location.path(true).split("#").pop();
30
+ if (hash) {
31
+ this.redirectHash = `#${hash}`;
32
+ }
33
+ this.instance.initializeWrapperLibrary(WrapperSKU.Angular, version);
34
+ }
35
+ acquireTokenPopup(request) {
36
+ return from(this.instance.acquireTokenPopup(request));
37
+ }
38
+ acquireTokenRedirect(request) {
39
+ return from(this.instance.acquireTokenRedirect(request));
40
+ }
41
+ acquireTokenSilent(silentRequest) {
42
+ return from(this.instance.acquireTokenSilent(silentRequest));
43
+ }
44
+ handleRedirectObservable(hash) {
45
+ return from(this.instance.handleRedirectPromise(hash || this.redirectHash));
46
+ }
47
+ loginPopup(request) {
48
+ return from(this.instance.loginPopup(request));
49
+ }
50
+ loginRedirect(request) {
51
+ return from(this.instance.loginRedirect(request));
52
+ }
53
+ logout(logoutRequest) {
54
+ return from(this.instance.logout(logoutRequest));
55
+ }
56
+ logoutRedirect(logoutRequest) {
57
+ return from(this.instance.logoutRedirect(logoutRequest));
58
+ }
59
+ logoutPopup(logoutRequest) {
60
+ return from(this.instance.logoutPopup(logoutRequest));
61
+ }
62
+ ssoSilent(request) {
63
+ return from(this.instance.ssoSilent(request));
64
+ }
65
+ /**
66
+ * Gets logger for msal-angular.
67
+ * If no logger set, returns logger instance created with same options as msal-browser
68
+ */
69
+ getLogger() {
70
+ if (!this.logger) {
71
+ this.logger = this.instance.getLogger().clone(name, version);
72
+ }
73
+ return this.logger;
74
+ }
75
+ // Create a logger instance for msal-angular with the same options as msal-browser
76
+ setLogger(logger) {
77
+ this.logger = logger.clone(name, version);
78
+ this.instance.setLogger(logger);
79
+ }
80
+ }
81
+ MsalService.decorators = [
82
+ { type: Injectable }
83
+ ];
84
+ MsalService.ctorParameters = () => [
85
+ { type: undefined, decorators: [{ type: Inject, args: [MSAL_INSTANCE,] }] },
86
+ { type: Location }
87
87
  ];
88
88
 
89
- /*
90
- * Copyright (c) Microsoft Corporation. All rights reserved.
91
- * Licensed under the MIT License.
92
- */
93
- class MsalBroadcastService {
94
- constructor(msalInstance, authService) {
95
- this.msalInstance = msalInstance;
96
- this.authService = authService;
97
- this._msalSubject = new 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 BehaviorSubject(InteractionStatus.Startup);
101
- this.inProgress$ = this._inProgress.asObservable();
102
- this.msalInstance.addEventCallback((message) => {
103
- this._msalSubject.next(message);
104
- const status = 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
- }
112
- MsalBroadcastService.decorators = [
113
- { type: Injectable }
114
- ];
115
- MsalBroadcastService.ctorParameters = () => [
116
- { type: undefined, decorators: [{ type: Inject, args: [MSAL_INSTANCE,] }] },
117
- { type: MsalService }
89
+ /*
90
+ * Copyright (c) Microsoft Corporation. All rights reserved.
91
+ * Licensed under the MIT License.
92
+ */
93
+ class MsalBroadcastService {
94
+ constructor(msalInstance, authService) {
95
+ this.msalInstance = msalInstance;
96
+ this.authService = authService;
97
+ this._msalSubject = new 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 BehaviorSubject(InteractionStatus.Startup);
101
+ this.inProgress$ = this._inProgress.asObservable();
102
+ this.msalInstance.addEventCallback((message) => {
103
+ this._msalSubject.next(message);
104
+ const status = 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
+ }
112
+ MsalBroadcastService.decorators = [
113
+ { type: Injectable }
114
+ ];
115
+ MsalBroadcastService.ctorParameters = () => [
116
+ { type: undefined, decorators: [{ type: Inject, args: [MSAL_INSTANCE,] }] },
117
+ { type: MsalService }
118
118
  ];
119
119
 
120
- /*
121
- * Copyright (c) Microsoft Corporation. All rights reserved.
122
- * Licensed under the MIT License.
123
- */
124
- class MsalGuard {
125
- constructor(msalGuardConfig, msalBroadcastService, authService, location, router) {
126
- this.msalGuardConfig = msalGuardConfig;
127
- this.msalBroadcastService = msalBroadcastService;
128
- this.authService = authService;
129
- this.location = location;
130
- this.router = router;
131
- // Subscribing so events in MsalGuard will set inProgress$ observable
132
- this.msalBroadcastService.inProgress$.subscribe();
133
- }
134
- /**
135
- * Parses url string to UrlTree
136
- * @param url
137
- */
138
- parseUrl(url) {
139
- return this.router.parseUrl(url);
140
- }
141
- /**
142
- * Builds the absolute url for the destination page
143
- * @param path Relative path of requested page
144
- * @returns Full destination url
145
- */
146
- getDestinationUrl(path) {
147
- this.authService.getLogger().verbose("Guard - getting destination url");
148
- // Absolute base url for the application (default to origin if base element not present)
149
- const baseElements = document.getElementsByTagName("base");
150
- const baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);
151
- // Path of page (including hash, if using hash routing)
152
- const pathUrl = this.location.prepareExternalUrl(path);
153
- // Hash location strategy
154
- if (pathUrl.startsWith("#")) {
155
- this.authService.getLogger().verbose("Guard - destination by hash routing");
156
- return `${baseUrl}/${pathUrl}`;
157
- }
158
- /*
159
- * If using path location strategy, pathUrl will include the relative portion of the base path (e.g. /base/page).
160
- * Since baseUrl also includes /base, can just concatentate baseUrl + path
161
- */
162
- return `${baseUrl}${path}`;
163
- }
164
- /**
165
- * Interactively prompt the user to login
166
- * @param url Path of the requested page
167
- */
168
- loginInteractively(state) {
169
- const authRequest = typeof this.msalGuardConfig.authRequest === "function"
170
- ? this.msalGuardConfig.authRequest(this.authService, state)
171
- : Object.assign({}, this.msalGuardConfig.authRequest);
172
- if (this.msalGuardConfig.interactionType === InteractionType.Popup) {
173
- this.authService.getLogger().verbose("Guard - logging in by popup");
174
- return this.authService.loginPopup(authRequest)
175
- .pipe(map((response) => {
176
- this.authService.getLogger().verbose("Guard - login by popup successful, can activate, setting active account");
177
- this.authService.instance.setActiveAccount(response.account);
178
- return true;
179
- }));
180
- }
181
- this.authService.getLogger().verbose("Guard - logging in by redirect");
182
- const redirectStartPage = this.getDestinationUrl(state.url);
183
- return this.authService.loginRedirect(Object.assign({ redirectStartPage }, authRequest))
184
- .pipe(map(() => false));
185
- }
186
- /**
187
- * Helper which checks for the correct interaction type, prevents page with Guard to be set as reidrect, and calls handleRedirectObservable
188
- * @param state
189
- */
190
- activateHelper(state) {
191
- if (this.msalGuardConfig.interactionType !== InteractionType.Popup && this.msalGuardConfig.interactionType !== InteractionType.Redirect) {
192
- throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration");
193
- }
194
- this.authService.getLogger().verbose("MSAL Guard activated");
195
- /*
196
- * If a page with MSAL Guard is set as the redirect for acquireTokenSilent,
197
- * short-circuit to prevent redirecting or popups.
198
- * TODO: Update to allow running in iframe once allowRedirectInIframe is implemented
199
- */
200
- if (typeof window !== "undefined") {
201
- if (UrlString.hashContainsKnownProperties(window.location.hash) && BrowserUtils.isInIframe()) {
202
- 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.");
203
- return of(false);
204
- }
205
- }
206
- else {
207
- this.authService.getLogger().info("Guard - window is undefined, MSAL does not support server-side token acquisition");
208
- return of(true);
209
- }
210
- /**
211
- * If a loginFailedRoute is set in the config, set this as the loginFailedRoute
212
- */
213
- if (this.msalGuardConfig.loginFailedRoute) {
214
- this.loginFailedRoute = this.parseUrl(this.msalGuardConfig.loginFailedRoute);
215
- }
216
- // Capture current path before it gets changed by handleRedirectObservable
217
- const currentPath = this.location.path(true);
218
- return this.authService.handleRedirectObservable()
219
- .pipe(concatMap(() => {
220
- if (!this.authService.instance.getAllAccounts().length) {
221
- if (state) {
222
- this.authService.getLogger().verbose("Guard - no accounts retrieved, log in required to activate");
223
- return this.loginInteractively(state);
224
- }
225
- this.authService.getLogger().verbose("Guard - no accounts retrieved, no state, cannot load");
226
- return of(false);
227
- }
228
- this.authService.getLogger().verbose("Guard - at least 1 account exists, can activate or load");
229
- // Prevent navigating the app to /#code= or /code=
230
- if (state && state.url.indexOf("code=") > -1) {
231
- this.authService.getLogger().info("Guard - Hash contains known code response, stopping navigation.");
232
- // Path routing (navigate to current path without hash)
233
- if (currentPath.indexOf("#") > -1) {
234
- return of(this.parseUrl(this.location.path()));
235
- }
236
- // Hash routing (navigate to root path)
237
- return of(this.parseUrl(""));
238
- }
239
- return of(true);
240
- }), catchError((error) => {
241
- this.authService.getLogger().error("Guard - error while logging in, unable to activate");
242
- this.authService.getLogger().errorPii(`Guard - error: ${error.message}`);
243
- /**
244
- * If a loginFailedRoute is set, checks to see if Angular 10+ is used and state is passed in before returning route
245
- * Apps using Angular 9 will receive of(false) in canLoad interface, as it does not support UrlTree return types
246
- */
247
- if (this.loginFailedRoute && parseInt(VERSION.major, 10) > 9 && state) {
248
- this.authService.getLogger().verbose("Guard - loginFailedRoute set, redirecting");
249
- return of(this.loginFailedRoute);
250
- }
251
- return of(false);
252
- }));
253
- }
254
- canActivate(route, state) {
255
- this.authService.getLogger().verbose("Guard - canActivate");
256
- return this.activateHelper(state);
257
- }
258
- canActivateChild(route, state) {
259
- this.authService.getLogger().verbose("Guard - canActivateChild");
260
- return this.activateHelper(state);
261
- }
262
- canLoad() {
263
- this.authService.getLogger().verbose("Guard - canLoad");
264
- // @ts-ignore
265
- return this.activateHelper();
266
- }
267
- }
268
- MsalGuard.decorators = [
269
- { type: Injectable }
270
- ];
271
- MsalGuard.ctorParameters = () => [
272
- { type: undefined, decorators: [{ type: Inject, args: [MSAL_GUARD_CONFIG,] }] },
273
- { type: MsalBroadcastService },
274
- { type: MsalService },
275
- { type: Location },
276
- { type: Router }
120
+ /*
121
+ * Copyright (c) Microsoft Corporation. All rights reserved.
122
+ * Licensed under the MIT License.
123
+ */
124
+ class MsalGuard {
125
+ constructor(msalGuardConfig, msalBroadcastService, authService, location, router) {
126
+ this.msalGuardConfig = msalGuardConfig;
127
+ this.msalBroadcastService = msalBroadcastService;
128
+ this.authService = authService;
129
+ this.location = location;
130
+ this.router = router;
131
+ // Subscribing so events in MsalGuard will set inProgress$ observable
132
+ this.msalBroadcastService.inProgress$.subscribe();
133
+ }
134
+ /**
135
+ * Parses url string to UrlTree
136
+ * @param url
137
+ */
138
+ parseUrl(url) {
139
+ return this.router.parseUrl(url);
140
+ }
141
+ /**
142
+ * Builds the absolute url for the destination page
143
+ * @param path Relative path of requested page
144
+ * @returns Full destination url
145
+ */
146
+ getDestinationUrl(path) {
147
+ this.authService.getLogger().verbose("Guard - getting destination url");
148
+ // Absolute base url for the application (default to origin if base element not present)
149
+ const baseElements = document.getElementsByTagName("base");
150
+ const baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);
151
+ // Path of page (including hash, if using hash routing)
152
+ const pathUrl = this.location.prepareExternalUrl(path);
153
+ // Hash location strategy
154
+ if (pathUrl.startsWith("#")) {
155
+ this.authService.getLogger().verbose("Guard - destination by hash routing");
156
+ return `${baseUrl}/${pathUrl}`;
157
+ }
158
+ /*
159
+ * If using path location strategy, pathUrl will include the relative portion of the base path (e.g. /base/page).
160
+ * Since baseUrl also includes /base, can just concatentate baseUrl + path
161
+ */
162
+ return `${baseUrl}${path}`;
163
+ }
164
+ /**
165
+ * Interactively prompt the user to login
166
+ * @param url Path of the requested page
167
+ */
168
+ loginInteractively(state) {
169
+ const authRequest = typeof this.msalGuardConfig.authRequest === "function"
170
+ ? this.msalGuardConfig.authRequest(this.authService, state)
171
+ : Object.assign({}, this.msalGuardConfig.authRequest);
172
+ if (this.msalGuardConfig.interactionType === InteractionType.Popup) {
173
+ this.authService.getLogger().verbose("Guard - logging in by popup");
174
+ return this.authService.loginPopup(authRequest)
175
+ .pipe(map((response) => {
176
+ this.authService.getLogger().verbose("Guard - login by popup successful, can activate, setting active account");
177
+ this.authService.instance.setActiveAccount(response.account);
178
+ return true;
179
+ }));
180
+ }
181
+ this.authService.getLogger().verbose("Guard - logging in by redirect");
182
+ const redirectStartPage = this.getDestinationUrl(state.url);
183
+ return this.authService.loginRedirect(Object.assign({ redirectStartPage }, authRequest))
184
+ .pipe(map(() => false));
185
+ }
186
+ /**
187
+ * Helper which checks for the correct interaction type, prevents page with Guard to be set as reidrect, and calls handleRedirectObservable
188
+ * @param state
189
+ */
190
+ activateHelper(state) {
191
+ if (this.msalGuardConfig.interactionType !== InteractionType.Popup && this.msalGuardConfig.interactionType !== InteractionType.Redirect) {
192
+ throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration");
193
+ }
194
+ this.authService.getLogger().verbose("MSAL Guard activated");
195
+ /*
196
+ * If a page with MSAL Guard is set as the redirect for acquireTokenSilent,
197
+ * short-circuit to prevent redirecting or popups.
198
+ */
199
+ if (typeof window !== "undefined") {
200
+ if (UrlString.hashContainsKnownProperties(window.location.hash) && BrowserUtils.isInIframe() && !this.authService.instance.getConfiguration().system.allowRedirectInIframe) {
201
+ 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.");
202
+ return of(false);
203
+ }
204
+ }
205
+ else {
206
+ this.authService.getLogger().info("Guard - window is undefined, MSAL does not support server-side token acquisition");
207
+ return of(true);
208
+ }
209
+ /**
210
+ * If a loginFailedRoute is set in the config, set this as the loginFailedRoute
211
+ */
212
+ if (this.msalGuardConfig.loginFailedRoute) {
213
+ this.loginFailedRoute = this.parseUrl(this.msalGuardConfig.loginFailedRoute);
214
+ }
215
+ // Capture current path before it gets changed by handleRedirectObservable
216
+ const currentPath = this.location.path(true);
217
+ return this.authService.handleRedirectObservable()
218
+ .pipe(concatMap(() => {
219
+ if (!this.authService.instance.getAllAccounts().length) {
220
+ if (state) {
221
+ this.authService.getLogger().verbose("Guard - no accounts retrieved, log in required to activate");
222
+ return this.loginInteractively(state);
223
+ }
224
+ this.authService.getLogger().verbose("Guard - no accounts retrieved, no state, cannot load");
225
+ return of(false);
226
+ }
227
+ this.authService.getLogger().verbose("Guard - at least 1 account exists, can activate or load");
228
+ // Prevent navigating the app to /#code= or /code=
229
+ if (state) {
230
+ /*
231
+ * Path routing:
232
+ * state.url: /#code=...
233
+ * state.root.fragment: code=...
234
+ */
235
+ /*
236
+ * Hash routing:
237
+ * state.url: /code
238
+ * state.root.fragment: null
239
+ */
240
+ const urlContainsCode = this.includesCode(state.url);
241
+ const fragmentContainsCode = !!state.root && !!state.root.fragment && this.includesCode(`#${state.root.fragment}`);
242
+ const hashRouting = this.location.prepareExternalUrl(state.url).indexOf("#") === 0;
243
+ // Ensure code parameter is in fragment (and not in query parameter), or that hash hash routing is used
244
+ if (urlContainsCode && (fragmentContainsCode || hashRouting)) {
245
+ this.authService.getLogger().info("Guard - Hash contains known code response, stopping navigation.");
246
+ // Path routing (navigate to current path without hash)
247
+ if (currentPath.indexOf("#") > -1) {
248
+ return of(this.parseUrl(this.location.path()));
249
+ }
250
+ // Hash routing (navigate to root path)
251
+ return of(this.parseUrl(""));
252
+ }
253
+ }
254
+ return of(true);
255
+ }), catchError((error) => {
256
+ this.authService.getLogger().error("Guard - error while logging in, unable to activate");
257
+ this.authService.getLogger().errorPii(`Guard - error: ${error.message}`);
258
+ /**
259
+ * If a loginFailedRoute is set, checks to see if Angular 10+ is used and state is passed in before returning route
260
+ * Apps using Angular 9 will receive of(false) in canLoad interface, as it does not support UrlTree return types
261
+ */
262
+ if (this.loginFailedRoute && parseInt(VERSION.major, 10) > 9 && state) {
263
+ this.authService.getLogger().verbose("Guard - loginFailedRoute set, redirecting");
264
+ return of(this.loginFailedRoute);
265
+ }
266
+ return of(false);
267
+ }));
268
+ }
269
+ includesCode(path) {
270
+ return (path.lastIndexOf("/code") > -1 &&
271
+ path.lastIndexOf("/code") === path.length - "/code".length) || // path.endsWith("/code")
272
+ path.indexOf("#code=") > -1 ||
273
+ path.indexOf("&code=") > -1;
274
+ }
275
+ canActivate(route, state) {
276
+ this.authService.getLogger().verbose("Guard - canActivate");
277
+ return this.activateHelper(state);
278
+ }
279
+ canActivateChild(route, state) {
280
+ this.authService.getLogger().verbose("Guard - canActivateChild");
281
+ return this.activateHelper(state);
282
+ }
283
+ canLoad() {
284
+ this.authService.getLogger().verbose("Guard - canLoad");
285
+ // @ts-ignore
286
+ return this.activateHelper();
287
+ }
288
+ }
289
+ MsalGuard.decorators = [
290
+ { type: Injectable }
291
+ ];
292
+ MsalGuard.ctorParameters = () => [
293
+ { type: undefined, decorators: [{ type: Inject, args: [MSAL_GUARD_CONFIG,] }] },
294
+ { type: MsalBroadcastService },
295
+ { type: MsalService },
296
+ { type: Location },
297
+ { type: Router }
277
298
  ];
278
299
 
279
- /*
280
- * Copyright (c) Microsoft Corporation. All rights reserved.
281
- * Licensed under the MIT License.
282
- */
283
- class MsalInterceptor {
284
- constructor(msalInterceptorConfig, authService, location,
285
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
286
- document) {
287
- this.msalInterceptorConfig = msalInterceptorConfig;
288
- this.authService = authService;
289
- this.location = location;
290
- this._document = document;
291
- }
292
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
293
- intercept(req, next) {
294
- if (this.msalInterceptorConfig.interactionType !== InteractionType.Popup && this.msalInterceptorConfig.interactionType !== InteractionType.Redirect) {
295
- throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
296
- }
297
- this.authService.getLogger().verbose("MSAL Interceptor activated");
298
- const scopes = this.getScopesForEndpoint(req.url, req.method);
299
- // If no scopes for endpoint, does not acquire token
300
- if (!scopes || scopes.length === 0) {
301
- this.authService.getLogger().verbose("Interceptor - no scopes for endpoint");
302
- return next.handle(req);
303
- }
304
- // Sets account as active account or first account
305
- let account;
306
- if (!!this.authService.instance.getActiveAccount()) {
307
- this.authService.getLogger().verbose("Interceptor - active account selected");
308
- account = this.authService.instance.getActiveAccount();
309
- }
310
- else {
311
- this.authService.getLogger().verbose("Interceptor - no active account, fallback to first account");
312
- account = this.authService.instance.getAllAccounts()[0];
313
- }
314
- const authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
315
- ? this.msalInterceptorConfig.authRequest(this.authService, req, { account: account })
316
- : Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { account });
317
- this.authService.getLogger().info(`Interceptor - ${scopes.length} scopes found for endpoint`);
318
- this.authService.getLogger().infoPii(`Interceptor - [${scopes}] scopes found for ${req.url}`);
319
- // Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken
320
- return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, authRequest), { scopes, account }))
321
- .pipe(catchError(() => {
322
- this.authService.getLogger().error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
323
- return this.acquireTokenInteractively(authRequest, scopes);
324
- }), switchMap((result) => {
325
- if (!result.accessToken) {
326
- this.authService.getLogger().error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
327
- return this.acquireTokenInteractively(authRequest, scopes);
328
- }
329
- return of(result);
330
- }), switchMap((result) => {
331
- this.authService.getLogger().verbose("Interceptor - setting authorization headers");
332
- const headers = req.headers
333
- .set("Authorization", `Bearer ${result.accessToken}`);
334
- const requestClone = req.clone({ headers });
335
- return next.handle(requestClone);
336
- }));
337
- }
338
- /**
339
- * Invoke interaction for the given set of scopes
340
- * @param authRequest Request
341
- * @param scopes Array of scopes for the request
342
- * @returns Result from the interactive request
343
- */
344
- acquireTokenInteractively(authRequest, scopes) {
345
- if (this.msalInterceptorConfig.interactionType === InteractionType.Popup) {
346
- this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by popup");
347
- return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, authRequest), { scopes }));
348
- }
349
- this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by redirect");
350
- const redirectStartPage = window.location.href;
351
- this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, authRequest), { scopes, redirectStartPage }));
352
- return EMPTY;
353
- }
354
- /**
355
- * Looks up the scopes for the given endpoint from the protectedResourceMap
356
- * @param endpoint Url of the request
357
- * @param httpMethod Http method of the request
358
- * @returns Array of scopes, or null if not found
359
- *
360
- */
361
- getScopesForEndpoint(endpoint, httpMethod) {
362
- this.authService.getLogger().verbose("Interceptor - getting scopes for endpoint");
363
- // Ensures endpoints and protected resources compared are normalized
364
- const normalizedEndpoint = this.location.normalize(endpoint);
365
- const protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
366
- const matchingProtectedResources = this.matchResourcesToEndpoint(protectedResourcesArray, normalizedEndpoint);
367
- // Check absolute urls of resources first before checking relative to prevent incorrect matching where multiple resources have similar relative urls
368
- if (matchingProtectedResources.absoluteResources.length > 0) {
369
- return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.absoluteResources, httpMethod);
370
- }
371
- else if (matchingProtectedResources.relativeResources.length > 0) {
372
- return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.relativeResources, httpMethod);
373
- }
374
- return null;
375
- }
376
- /**
377
- * Finds resource endpoints that match request endpoint
378
- * @param protectedResourcesEndpoints
379
- * @param endpoint
380
- * @returns
381
- */
382
- matchResourcesToEndpoint(protectedResourcesEndpoints, endpoint) {
383
- const matchingResources = { absoluteResources: [], relativeResources: [] };
384
- protectedResourcesEndpoints.forEach(key => {
385
- // Normalizes and adds resource to matchingResources.absoluteResources if key matches endpoint. StringUtils.matchPattern accounts for wildcards
386
- const normalizedKey = this.location.normalize(key);
387
- if (StringUtils.matchPattern(normalizedKey, endpoint)) {
388
- matchingResources.absoluteResources.push(key);
389
- }
390
- // Get url components for relative urls
391
- const absoluteKey = this.getAbsoluteUrl(key);
392
- const keyComponents = new UrlString(absoluteKey).getUrlComponents();
393
- const absoluteEndpoint = this.getAbsoluteUrl(endpoint);
394
- const endpointComponents = new UrlString(absoluteEndpoint).getUrlComponents();
395
- // Normalized key should include query strings if applicable
396
- const relativeNormalizedKey = keyComponents.QueryString ? `${keyComponents.AbsolutePath}?${keyComponents.QueryString}` : this.location.normalize(keyComponents.AbsolutePath);
397
- // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
398
- if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort && StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) && relativeNormalizedKey !== "" && relativeNormalizedKey !== "/*") {
399
- matchingResources.relativeResources.push(key);
400
- }
401
- });
402
- return matchingResources;
403
- }
404
- /**
405
- * Transforms relative urls to absolute urls
406
- * @param url
407
- * @returns
408
- */
409
- getAbsoluteUrl(url) {
410
- const link = this._document.createElement("a");
411
- link.href = url;
412
- return link.href;
413
- }
414
- /**
415
- * Finds scopes from first matching endpoint with HTTP method that matches request
416
- * @param protectedResourceMap Protected resource map
417
- * @param endpointArray Array of resources that match request endpoint
418
- * @param httpMethod Http method of the request
419
- * @returns
420
- */
421
- matchScopesToEndpoint(protectedResourceMap, endpointArray, httpMethod) {
422
- const allMatchedScopes = [];
423
- // Check each matched endpoint for matching HttpMethod and scopes
424
- endpointArray.forEach(matchedEndpoint => {
425
- const scopesForEndpoint = [];
426
- const methodAndScopesArray = protectedResourceMap.get(matchedEndpoint);
427
- // Return if resource is unprotected
428
- if (methodAndScopesArray === null) {
429
- allMatchedScopes.push(null);
430
- return;
431
- }
432
- methodAndScopesArray.forEach(entry => {
433
- // Entry is either array of scopes or ProtectedResourceScopes object
434
- if (typeof entry === "string") {
435
- scopesForEndpoint.push(entry);
436
- }
437
- else {
438
- // Ensure methods being compared are normalized
439
- const normalizedRequestMethod = httpMethod.toLowerCase();
440
- const normalizedResourceMethod = entry.httpMethod.toLowerCase();
441
- // Method in protectedResourceMap matches request http method
442
- if (normalizedResourceMethod === normalizedRequestMethod) {
443
- // Validate if scopes comes null to unprotect the resource in a certain http method
444
- if (entry.scopes === null) {
445
- allMatchedScopes.push(null);
446
- }
447
- else {
448
- entry.scopes.forEach((scope) => {
449
- scopesForEndpoint.push(scope);
450
- });
451
- }
452
- }
453
- }
454
- });
455
- // Only add to all scopes if scopes for endpoint and method is found
456
- if (scopesForEndpoint.length > 0) {
457
- allMatchedScopes.push(scopesForEndpoint);
458
- }
459
- });
460
- if (allMatchedScopes.length > 0) {
461
- if (allMatchedScopes.length > 1) {
462
- this.authService.getLogger().warning("Interceptor - More than 1 matching scopes for endpoint found.");
463
- }
464
- // Returns scopes for first matching endpoint
465
- return allMatchedScopes[0];
466
- }
467
- return null;
468
- }
469
- }
470
- MsalInterceptor.decorators = [
471
- { type: Injectable }
472
- ];
473
- MsalInterceptor.ctorParameters = () => [
474
- { type: undefined, decorators: [{ type: Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] },
475
- { type: MsalService },
476
- { type: Location },
477
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
300
+ /*
301
+ * Copyright (c) Microsoft Corporation. All rights reserved.
302
+ * Licensed under the MIT License.
303
+ */
304
+ class MsalInterceptor {
305
+ constructor(msalInterceptorConfig, authService, location,
306
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
307
+ document) {
308
+ this.msalInterceptorConfig = msalInterceptorConfig;
309
+ this.authService = authService;
310
+ this.location = location;
311
+ this._document = document;
312
+ }
313
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
314
+ intercept(req, next) {
315
+ if (this.msalInterceptorConfig.interactionType !== InteractionType.Popup && this.msalInterceptorConfig.interactionType !== InteractionType.Redirect) {
316
+ throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
317
+ }
318
+ this.authService.getLogger().verbose("MSAL Interceptor activated");
319
+ const scopes = this.getScopesForEndpoint(req.url, req.method);
320
+ // If no scopes for endpoint, does not acquire token
321
+ if (!scopes || scopes.length === 0) {
322
+ this.authService.getLogger().verbose("Interceptor - no scopes for endpoint");
323
+ return next.handle(req);
324
+ }
325
+ // Sets account as active account or first account
326
+ let account;
327
+ if (!!this.authService.instance.getActiveAccount()) {
328
+ this.authService.getLogger().verbose("Interceptor - active account selected");
329
+ account = this.authService.instance.getActiveAccount();
330
+ }
331
+ else {
332
+ this.authService.getLogger().verbose("Interceptor - no active account, fallback to first account");
333
+ account = this.authService.instance.getAllAccounts()[0];
334
+ }
335
+ const authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
336
+ ? this.msalInterceptorConfig.authRequest(this.authService, req, { account: account })
337
+ : Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { account });
338
+ this.authService.getLogger().info(`Interceptor - ${scopes.length} scopes found for endpoint`);
339
+ this.authService.getLogger().infoPii(`Interceptor - [${scopes}] scopes found for ${req.url}`);
340
+ // Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken
341
+ return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, authRequest), { scopes, account }))
342
+ .pipe(catchError(() => {
343
+ this.authService.getLogger().error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
344
+ return this.acquireTokenInteractively(authRequest, scopes);
345
+ }), switchMap((result) => {
346
+ if (!result.accessToken) {
347
+ this.authService.getLogger().error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
348
+ return this.acquireTokenInteractively(authRequest, scopes);
349
+ }
350
+ return of(result);
351
+ }), switchMap((result) => {
352
+ this.authService.getLogger().verbose("Interceptor - setting authorization headers");
353
+ const headers = req.headers
354
+ .set("Authorization", `Bearer ${result.accessToken}`);
355
+ const requestClone = req.clone({ headers });
356
+ return next.handle(requestClone);
357
+ }));
358
+ }
359
+ /**
360
+ * Invoke interaction for the given set of scopes
361
+ * @param authRequest Request
362
+ * @param scopes Array of scopes for the request
363
+ * @returns Result from the interactive request
364
+ */
365
+ acquireTokenInteractively(authRequest, scopes) {
366
+ if (this.msalInterceptorConfig.interactionType === InteractionType.Popup) {
367
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by popup");
368
+ return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, authRequest), { scopes }));
369
+ }
370
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by redirect");
371
+ const redirectStartPage = window.location.href;
372
+ this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, authRequest), { scopes, redirectStartPage }));
373
+ return EMPTY;
374
+ }
375
+ /**
376
+ * Looks up the scopes for the given endpoint from the protectedResourceMap
377
+ * @param endpoint Url of the request
378
+ * @param httpMethod Http method of the request
379
+ * @returns Array of scopes, or null if not found
380
+ *
381
+ */
382
+ getScopesForEndpoint(endpoint, httpMethod) {
383
+ this.authService.getLogger().verbose("Interceptor - getting scopes for endpoint");
384
+ // Ensures endpoints and protected resources compared are normalized
385
+ const normalizedEndpoint = this.location.normalize(endpoint);
386
+ const protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
387
+ const matchingProtectedResources = this.matchResourcesToEndpoint(protectedResourcesArray, normalizedEndpoint);
388
+ // Check absolute urls of resources first before checking relative to prevent incorrect matching where multiple resources have similar relative urls
389
+ if (matchingProtectedResources.absoluteResources.length > 0) {
390
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.absoluteResources, httpMethod);
391
+ }
392
+ else if (matchingProtectedResources.relativeResources.length > 0) {
393
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.relativeResources, httpMethod);
394
+ }
395
+ return null;
396
+ }
397
+ /**
398
+ * Finds resource endpoints that match request endpoint
399
+ * @param protectedResourcesEndpoints
400
+ * @param endpoint
401
+ * @returns
402
+ */
403
+ matchResourcesToEndpoint(protectedResourcesEndpoints, endpoint) {
404
+ const matchingResources = { absoluteResources: [], relativeResources: [] };
405
+ protectedResourcesEndpoints.forEach(key => {
406
+ // Normalizes and adds resource to matchingResources.absoluteResources if key matches endpoint. StringUtils.matchPattern accounts for wildcards
407
+ const normalizedKey = this.location.normalize(key);
408
+ if (StringUtils.matchPattern(normalizedKey, endpoint)) {
409
+ matchingResources.absoluteResources.push(key);
410
+ }
411
+ // Get url components for relative urls
412
+ const absoluteKey = this.getAbsoluteUrl(key);
413
+ const keyComponents = new UrlString(absoluteKey).getUrlComponents();
414
+ const absoluteEndpoint = this.getAbsoluteUrl(endpoint);
415
+ const endpointComponents = new UrlString(absoluteEndpoint).getUrlComponents();
416
+ // Normalized key should include query strings if applicable
417
+ const relativeNormalizedKey = keyComponents.QueryString ? `${keyComponents.AbsolutePath}?${keyComponents.QueryString}` : this.location.normalize(keyComponents.AbsolutePath);
418
+ // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
419
+ if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort && StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) && relativeNormalizedKey !== "" && relativeNormalizedKey !== "/*") {
420
+ matchingResources.relativeResources.push(key);
421
+ }
422
+ });
423
+ return matchingResources;
424
+ }
425
+ /**
426
+ * Transforms relative urls to absolute urls
427
+ * @param url
428
+ * @returns
429
+ */
430
+ getAbsoluteUrl(url) {
431
+ const link = this._document.createElement("a");
432
+ link.href = url;
433
+ return link.href;
434
+ }
435
+ /**
436
+ * Finds scopes from first matching endpoint with HTTP method that matches request
437
+ * @param protectedResourceMap Protected resource map
438
+ * @param endpointArray Array of resources that match request endpoint
439
+ * @param httpMethod Http method of the request
440
+ * @returns
441
+ */
442
+ matchScopesToEndpoint(protectedResourceMap, endpointArray, httpMethod) {
443
+ const allMatchedScopes = [];
444
+ // Check each matched endpoint for matching HttpMethod and scopes
445
+ endpointArray.forEach(matchedEndpoint => {
446
+ const scopesForEndpoint = [];
447
+ const methodAndScopesArray = protectedResourceMap.get(matchedEndpoint);
448
+ // Return if resource is unprotected
449
+ if (methodAndScopesArray === null) {
450
+ allMatchedScopes.push(null);
451
+ return;
452
+ }
453
+ methodAndScopesArray.forEach(entry => {
454
+ // Entry is either array of scopes or ProtectedResourceScopes object
455
+ if (typeof entry === "string") {
456
+ scopesForEndpoint.push(entry);
457
+ }
458
+ else {
459
+ // Ensure methods being compared are normalized
460
+ const normalizedRequestMethod = httpMethod.toLowerCase();
461
+ const normalizedResourceMethod = entry.httpMethod.toLowerCase();
462
+ // Method in protectedResourceMap matches request http method
463
+ if (normalizedResourceMethod === normalizedRequestMethod) {
464
+ // Validate if scopes comes null to unprotect the resource in a certain http method
465
+ if (entry.scopes === null) {
466
+ allMatchedScopes.push(null);
467
+ }
468
+ else {
469
+ entry.scopes.forEach((scope) => {
470
+ scopesForEndpoint.push(scope);
471
+ });
472
+ }
473
+ }
474
+ }
475
+ });
476
+ // Only add to all scopes if scopes for endpoint and method is found
477
+ if (scopesForEndpoint.length > 0) {
478
+ allMatchedScopes.push(scopesForEndpoint);
479
+ }
480
+ });
481
+ if (allMatchedScopes.length > 0) {
482
+ if (allMatchedScopes.length > 1) {
483
+ this.authService.getLogger().warning("Interceptor - More than 1 matching scopes for endpoint found.");
484
+ }
485
+ // Returns scopes for first matching endpoint
486
+ return allMatchedScopes[0];
487
+ }
488
+ return null;
489
+ }
490
+ }
491
+ MsalInterceptor.decorators = [
492
+ { type: Injectable }
493
+ ];
494
+ MsalInterceptor.ctorParameters = () => [
495
+ { type: undefined, decorators: [{ type: Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] },
496
+ { type: MsalService },
497
+ { type: Location },
498
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
478
499
  ];
479
500
 
480
- /*
481
- * Copyright (c) Microsoft Corporation. All rights reserved.
482
- * Licensed under the MIT License.
483
- */
484
- class MsalRedirectComponent {
485
- constructor(authService) {
486
- this.authService = authService;
487
- }
488
- ngOnInit() {
489
- this.authService.getLogger().verbose("MsalRedirectComponent activated");
490
- this.authService.handleRedirectObservable().subscribe();
491
- }
492
- }
493
- MsalRedirectComponent.decorators = [
494
- { type: Component, args: [{
495
- selector: "app-redirect",
496
- template: ""
497
- },] }
498
- ];
499
- MsalRedirectComponent.ctorParameters = () => [
500
- { type: MsalService }
501
+ /*
502
+ * Copyright (c) Microsoft Corporation. All rights reserved.
503
+ * Licensed under the MIT License.
504
+ */
505
+ class MsalRedirectComponent {
506
+ constructor(authService) {
507
+ this.authService = authService;
508
+ }
509
+ ngOnInit() {
510
+ this.authService.getLogger().verbose("MsalRedirectComponent activated");
511
+ this.authService.handleRedirectObservable().subscribe();
512
+ }
513
+ }
514
+ MsalRedirectComponent.decorators = [
515
+ { type: Component, args: [{
516
+ selector: "app-redirect",
517
+ template: ""
518
+ },] }
519
+ ];
520
+ MsalRedirectComponent.ctorParameters = () => [
521
+ { type: MsalService }
501
522
  ];
502
523
 
503
- /*
504
- * Copyright (c) Microsoft Corporation. All rights reserved.
505
- * Licensed under the MIT License.
506
- */
507
- class MsalModule {
508
- static forRoot(msalInstance, guardConfig, interceptorConfig) {
509
- return {
510
- ngModule: MsalModule,
511
- providers: [
512
- {
513
- provide: MSAL_INSTANCE,
514
- useValue: msalInstance
515
- },
516
- {
517
- provide: MSAL_GUARD_CONFIG,
518
- useValue: guardConfig
519
- },
520
- {
521
- provide: MSAL_INTERCEPTOR_CONFIG,
522
- useValue: interceptorConfig
523
- },
524
- MsalService
525
- ]
526
- };
527
- }
528
- }
529
- MsalModule.decorators = [
530
- { type: NgModule, args: [{
531
- declarations: [MsalRedirectComponent],
532
- imports: [
533
- CommonModule
534
- ],
535
- providers: [
536
- MsalGuard,
537
- MsalBroadcastService
538
- ]
539
- },] }
524
+ /*
525
+ * Copyright (c) Microsoft Corporation. All rights reserved.
526
+ * Licensed under the MIT License.
527
+ */
528
+ class MsalModule {
529
+ static forRoot(msalInstance, guardConfig, interceptorConfig) {
530
+ return {
531
+ ngModule: MsalModule,
532
+ providers: [
533
+ {
534
+ provide: MSAL_INSTANCE,
535
+ useValue: msalInstance
536
+ },
537
+ {
538
+ provide: MSAL_GUARD_CONFIG,
539
+ useValue: guardConfig
540
+ },
541
+ {
542
+ provide: MSAL_INTERCEPTOR_CONFIG,
543
+ useValue: interceptorConfig
544
+ },
545
+ MsalService
546
+ ]
547
+ };
548
+ }
549
+ }
550
+ MsalModule.decorators = [
551
+ { type: NgModule, args: [{
552
+ declarations: [MsalRedirectComponent],
553
+ imports: [
554
+ CommonModule
555
+ ],
556
+ providers: [
557
+ MsalGuard,
558
+ MsalBroadcastService
559
+ ]
560
+ },] }
540
561
  ];
541
562
 
542
- /*
543
- * Copyright (c) Microsoft Corporation. All rights reserved.
544
- * Licensed under the MIT License.
545
- */
546
- /**
547
- * Custom navigation used for Angular client-side navigation.
548
- * See performance doc for details:
549
- * https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/docs/v2-docs/performance.md
550
- */
551
- class MsalCustomNavigationClient extends NavigationClient {
552
- constructor(authService, router, location) {
553
- super();
554
- this.authService = authService;
555
- this.router = router;
556
- this.location = location;
557
- }
558
- navigateInternal(url, options) {
559
- const _super = Object.create(null, {
560
- navigateInternal: { get: () => super.navigateInternal }
561
- });
562
- return __awaiter(this, void 0, void 0, function* () {
563
- this.authService.getLogger().trace("MsalCustomNavigationClient called");
564
- this.authService.getLogger().verbose("MsalCustomNavigationClient - navigating");
565
- this.authService.getLogger().verbosePii(`MsalCustomNavigationClient - navigating to url: ${url}`);
566
- // Prevent hash clearing from causing an issue with Client-side navigation after redirect is handled
567
- if (options.noHistory) {
568
- return _super.navigateInternal.call(this, url, options);
569
- }
570
- else {
571
- // Normalizing newUrl if no query string
572
- const urlComponents = new UrlString(url).getUrlComponents();
573
- const newUrl = urlComponents.QueryString ? `${urlComponents.AbsolutePath}?${urlComponents.QueryString}` : this.location.normalize(urlComponents.AbsolutePath);
574
- this.router.navigateByUrl(newUrl, { replaceUrl: options.noHistory });
575
- }
576
- return Promise.resolve(options.noHistory);
577
- });
578
- }
579
- }
580
- MsalCustomNavigationClient.decorators = [
581
- { type: Injectable }
582
- ];
583
- MsalCustomNavigationClient.ctorParameters = () => [
584
- { type: MsalService },
585
- { type: Router },
586
- { type: Location }
563
+ /*
564
+ * Copyright (c) Microsoft Corporation. All rights reserved.
565
+ * Licensed under the MIT License.
566
+ */
567
+ /**
568
+ * Custom navigation used for Angular client-side navigation.
569
+ * See performance doc for details:
570
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/docs/v2-docs/performance.md
571
+ */
572
+ class MsalCustomNavigationClient extends NavigationClient {
573
+ constructor(authService, router, location) {
574
+ super();
575
+ this.authService = authService;
576
+ this.router = router;
577
+ this.location = location;
578
+ }
579
+ navigateInternal(url, options) {
580
+ const _super = Object.create(null, {
581
+ navigateInternal: { get: () => super.navigateInternal }
582
+ });
583
+ return __awaiter(this, void 0, void 0, function* () {
584
+ this.authService.getLogger().trace("MsalCustomNavigationClient called");
585
+ this.authService.getLogger().verbose("MsalCustomNavigationClient - navigating");
586
+ this.authService.getLogger().verbosePii(`MsalCustomNavigationClient - navigating to url: ${url}`);
587
+ // Prevent hash clearing from causing an issue with Client-side navigation after redirect is handled
588
+ if (options.noHistory) {
589
+ return _super.navigateInternal.call(this, url, options);
590
+ }
591
+ else {
592
+ // Normalizing newUrl if no query string
593
+ const urlComponents = new UrlString(url).getUrlComponents();
594
+ const newUrl = urlComponents.QueryString ? `${urlComponents.AbsolutePath}?${urlComponents.QueryString}` : this.location.normalize(urlComponents.AbsolutePath);
595
+ this.router.navigateByUrl(newUrl, { replaceUrl: options.noHistory });
596
+ }
597
+ return Promise.resolve(options.noHistory);
598
+ });
599
+ }
600
+ }
601
+ MsalCustomNavigationClient.decorators = [
602
+ { type: Injectable }
603
+ ];
604
+ MsalCustomNavigationClient.ctorParameters = () => [
605
+ { type: MsalService },
606
+ { type: Router },
607
+ { type: Location }
587
608
  ];
588
609
 
589
- /*
590
- * Copyright (c) Microsoft Corporation. All rights reserved.
591
- * Licensed under the MIT License.
610
+ /*
611
+ * Copyright (c) Microsoft Corporation. All rights reserved.
612
+ * Licensed under the MIT License.
592
613
  */
593
614
 
594
- /**
595
- * Generated bundle index. Do not edit.
615
+ /**
616
+ * Generated bundle index. Do not edit.
596
617
  */
597
618
 
598
619
  export { MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalBroadcastService, MsalCustomNavigationClient, MsalGuard, MsalInterceptor, MsalModule, MsalRedirectComponent, MsalService, version };