@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
@@ -6,593 +6,613 @@ 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.0.5";
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") === path.length - "/code".length || // path.endsWith("/code")
271
+ path.indexOf("#code=") > -1 ||
272
+ path.indexOf("&code=") > -1;
273
+ }
274
+ canActivate(route, state) {
275
+ this.authService.getLogger().verbose("Guard - canActivate");
276
+ return this.activateHelper(state);
277
+ }
278
+ canActivateChild(route, state) {
279
+ this.authService.getLogger().verbose("Guard - canActivateChild");
280
+ return this.activateHelper(state);
281
+ }
282
+ canLoad() {
283
+ this.authService.getLogger().verbose("Guard - canLoad");
284
+ // @ts-ignore
285
+ return this.activateHelper();
286
+ }
287
+ }
288
+ MsalGuard.decorators = [
289
+ { type: Injectable }
290
+ ];
291
+ MsalGuard.ctorParameters = () => [
292
+ { type: undefined, decorators: [{ type: Inject, args: [MSAL_GUARD_CONFIG,] }] },
293
+ { type: MsalBroadcastService },
294
+ { type: MsalService },
295
+ { type: Location },
296
+ { type: Router }
277
297
  ];
278
298
 
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,] }] }
299
+ /*
300
+ * Copyright (c) Microsoft Corporation. All rights reserved.
301
+ * Licensed under the MIT License.
302
+ */
303
+ class MsalInterceptor {
304
+ constructor(msalInterceptorConfig, authService, location,
305
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
306
+ document) {
307
+ this.msalInterceptorConfig = msalInterceptorConfig;
308
+ this.authService = authService;
309
+ this.location = location;
310
+ this._document = document;
311
+ }
312
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
313
+ intercept(req, next) {
314
+ if (this.msalInterceptorConfig.interactionType !== InteractionType.Popup && this.msalInterceptorConfig.interactionType !== InteractionType.Redirect) {
315
+ throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
316
+ }
317
+ this.authService.getLogger().verbose("MSAL Interceptor activated");
318
+ const scopes = this.getScopesForEndpoint(req.url, req.method);
319
+ // If no scopes for endpoint, does not acquire token
320
+ if (!scopes || scopes.length === 0) {
321
+ this.authService.getLogger().verbose("Interceptor - no scopes for endpoint");
322
+ return next.handle(req);
323
+ }
324
+ // Sets account as active account or first account
325
+ let account;
326
+ if (!!this.authService.instance.getActiveAccount()) {
327
+ this.authService.getLogger().verbose("Interceptor - active account selected");
328
+ account = this.authService.instance.getActiveAccount();
329
+ }
330
+ else {
331
+ this.authService.getLogger().verbose("Interceptor - no active account, fallback to first account");
332
+ account = this.authService.instance.getAllAccounts()[0];
333
+ }
334
+ const authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
335
+ ? this.msalInterceptorConfig.authRequest(this.authService, req, { account: account })
336
+ : Object.assign(Object.assign({}, this.msalInterceptorConfig.authRequest), { account });
337
+ this.authService.getLogger().info(`Interceptor - ${scopes.length} scopes found for endpoint`);
338
+ this.authService.getLogger().infoPii(`Interceptor - [${scopes}] scopes found for ${req.url}`);
339
+ // Note: For MSA accounts, include openid scope when calling acquireTokenSilent to return idToken
340
+ return this.authService.acquireTokenSilent(Object.assign(Object.assign({}, authRequest), { scopes, account }))
341
+ .pipe(catchError(() => {
342
+ this.authService.getLogger().error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
343
+ return this.acquireTokenInteractively(authRequest, scopes);
344
+ }), switchMap((result) => {
345
+ if (!result.accessToken) {
346
+ this.authService.getLogger().error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
347
+ return this.acquireTokenInteractively(authRequest, scopes);
348
+ }
349
+ return of(result);
350
+ }), switchMap((result) => {
351
+ this.authService.getLogger().verbose("Interceptor - setting authorization headers");
352
+ const headers = req.headers
353
+ .set("Authorization", `Bearer ${result.accessToken}`);
354
+ const requestClone = req.clone({ headers });
355
+ return next.handle(requestClone);
356
+ }));
357
+ }
358
+ /**
359
+ * Invoke interaction for the given set of scopes
360
+ * @param authRequest Request
361
+ * @param scopes Array of scopes for the request
362
+ * @returns Result from the interactive request
363
+ */
364
+ acquireTokenInteractively(authRequest, scopes) {
365
+ if (this.msalInterceptorConfig.interactionType === InteractionType.Popup) {
366
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by popup");
367
+ return this.authService.acquireTokenPopup(Object.assign(Object.assign({}, authRequest), { scopes }));
368
+ }
369
+ this.authService.getLogger().verbose("Interceptor - error acquiring token silently, acquiring by redirect");
370
+ const redirectStartPage = window.location.href;
371
+ this.authService.acquireTokenRedirect(Object.assign(Object.assign({}, authRequest), { scopes, redirectStartPage }));
372
+ return EMPTY;
373
+ }
374
+ /**
375
+ * Looks up the scopes for the given endpoint from the protectedResourceMap
376
+ * @param endpoint Url of the request
377
+ * @param httpMethod Http method of the request
378
+ * @returns Array of scopes, or null if not found
379
+ *
380
+ */
381
+ getScopesForEndpoint(endpoint, httpMethod) {
382
+ this.authService.getLogger().verbose("Interceptor - getting scopes for endpoint");
383
+ // Ensures endpoints and protected resources compared are normalized
384
+ const normalizedEndpoint = this.location.normalize(endpoint);
385
+ const protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
386
+ const matchingProtectedResources = this.matchResourcesToEndpoint(protectedResourcesArray, normalizedEndpoint);
387
+ // Check absolute urls of resources first before checking relative to prevent incorrect matching where multiple resources have similar relative urls
388
+ if (matchingProtectedResources.absoluteResources.length > 0) {
389
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.absoluteResources, httpMethod);
390
+ }
391
+ else if (matchingProtectedResources.relativeResources.length > 0) {
392
+ return this.matchScopesToEndpoint(this.msalInterceptorConfig.protectedResourceMap, matchingProtectedResources.relativeResources, httpMethod);
393
+ }
394
+ return null;
395
+ }
396
+ /**
397
+ * Finds resource endpoints that match request endpoint
398
+ * @param protectedResourcesEndpoints
399
+ * @param endpoint
400
+ * @returns
401
+ */
402
+ matchResourcesToEndpoint(protectedResourcesEndpoints, endpoint) {
403
+ const matchingResources = { absoluteResources: [], relativeResources: [] };
404
+ protectedResourcesEndpoints.forEach(key => {
405
+ // Normalizes and adds resource to matchingResources.absoluteResources if key matches endpoint. StringUtils.matchPattern accounts for wildcards
406
+ const normalizedKey = this.location.normalize(key);
407
+ if (StringUtils.matchPattern(normalizedKey, endpoint)) {
408
+ matchingResources.absoluteResources.push(key);
409
+ }
410
+ // Get url components for relative urls
411
+ const absoluteKey = this.getAbsoluteUrl(key);
412
+ const keyComponents = new UrlString(absoluteKey).getUrlComponents();
413
+ const absoluteEndpoint = this.getAbsoluteUrl(endpoint);
414
+ const endpointComponents = new UrlString(absoluteEndpoint).getUrlComponents();
415
+ // Normalized key should include query strings if applicable
416
+ const relativeNormalizedKey = keyComponents.QueryString ? `${keyComponents.AbsolutePath}?${keyComponents.QueryString}` : this.location.normalize(keyComponents.AbsolutePath);
417
+ // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
418
+ if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort && StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) && relativeNormalizedKey !== "" && relativeNormalizedKey !== "/*") {
419
+ matchingResources.relativeResources.push(key);
420
+ }
421
+ });
422
+ return matchingResources;
423
+ }
424
+ /**
425
+ * Transforms relative urls to absolute urls
426
+ * @param url
427
+ * @returns
428
+ */
429
+ getAbsoluteUrl(url) {
430
+ const link = this._document.createElement("a");
431
+ link.href = url;
432
+ return link.href;
433
+ }
434
+ /**
435
+ * Finds scopes from first matching endpoint with HTTP method that matches request
436
+ * @param protectedResourceMap Protected resource map
437
+ * @param endpointArray Array of resources that match request endpoint
438
+ * @param httpMethod Http method of the request
439
+ * @returns
440
+ */
441
+ matchScopesToEndpoint(protectedResourceMap, endpointArray, httpMethod) {
442
+ const allMatchedScopes = [];
443
+ // Check each matched endpoint for matching HttpMethod and scopes
444
+ endpointArray.forEach(matchedEndpoint => {
445
+ const scopesForEndpoint = [];
446
+ const methodAndScopesArray = protectedResourceMap.get(matchedEndpoint);
447
+ // Return if resource is unprotected
448
+ if (methodAndScopesArray === null) {
449
+ allMatchedScopes.push(null);
450
+ return;
451
+ }
452
+ methodAndScopesArray.forEach(entry => {
453
+ // Entry is either array of scopes or ProtectedResourceScopes object
454
+ if (typeof entry === "string") {
455
+ scopesForEndpoint.push(entry);
456
+ }
457
+ else {
458
+ // Ensure methods being compared are normalized
459
+ const normalizedRequestMethod = httpMethod.toLowerCase();
460
+ const normalizedResourceMethod = entry.httpMethod.toLowerCase();
461
+ // Method in protectedResourceMap matches request http method
462
+ if (normalizedResourceMethod === normalizedRequestMethod) {
463
+ // Validate if scopes comes null to unprotect the resource in a certain http method
464
+ if (entry.scopes === null) {
465
+ allMatchedScopes.push(null);
466
+ }
467
+ else {
468
+ entry.scopes.forEach((scope) => {
469
+ scopesForEndpoint.push(scope);
470
+ });
471
+ }
472
+ }
473
+ }
474
+ });
475
+ // Only add to all scopes if scopes for endpoint and method is found
476
+ if (scopesForEndpoint.length > 0) {
477
+ allMatchedScopes.push(scopesForEndpoint);
478
+ }
479
+ });
480
+ if (allMatchedScopes.length > 0) {
481
+ if (allMatchedScopes.length > 1) {
482
+ this.authService.getLogger().warning("Interceptor - More than 1 matching scopes for endpoint found.");
483
+ }
484
+ // Returns scopes for first matching endpoint
485
+ return allMatchedScopes[0];
486
+ }
487
+ return null;
488
+ }
489
+ }
490
+ MsalInterceptor.decorators = [
491
+ { type: Injectable }
492
+ ];
493
+ MsalInterceptor.ctorParameters = () => [
494
+ { type: undefined, decorators: [{ type: Inject, args: [MSAL_INTERCEPTOR_CONFIG,] }] },
495
+ { type: MsalService },
496
+ { type: Location },
497
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
478
498
  ];
479
499
 
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 }
500
+ /*
501
+ * Copyright (c) Microsoft Corporation. All rights reserved.
502
+ * Licensed under the MIT License.
503
+ */
504
+ class MsalRedirectComponent {
505
+ constructor(authService) {
506
+ this.authService = authService;
507
+ }
508
+ ngOnInit() {
509
+ this.authService.getLogger().verbose("MsalRedirectComponent activated");
510
+ this.authService.handleRedirectObservable().subscribe();
511
+ }
512
+ }
513
+ MsalRedirectComponent.decorators = [
514
+ { type: Component, args: [{
515
+ selector: "app-redirect",
516
+ template: ""
517
+ },] }
518
+ ];
519
+ MsalRedirectComponent.ctorParameters = () => [
520
+ { type: MsalService }
501
521
  ];
502
522
 
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
- },] }
523
+ /*
524
+ * Copyright (c) Microsoft Corporation. All rights reserved.
525
+ * Licensed under the MIT License.
526
+ */
527
+ class MsalModule {
528
+ static forRoot(msalInstance, guardConfig, interceptorConfig) {
529
+ return {
530
+ ngModule: MsalModule,
531
+ providers: [
532
+ {
533
+ provide: MSAL_INSTANCE,
534
+ useValue: msalInstance
535
+ },
536
+ {
537
+ provide: MSAL_GUARD_CONFIG,
538
+ useValue: guardConfig
539
+ },
540
+ {
541
+ provide: MSAL_INTERCEPTOR_CONFIG,
542
+ useValue: interceptorConfig
543
+ },
544
+ MsalService
545
+ ]
546
+ };
547
+ }
548
+ }
549
+ MsalModule.decorators = [
550
+ { type: NgModule, args: [{
551
+ declarations: [MsalRedirectComponent],
552
+ imports: [
553
+ CommonModule
554
+ ],
555
+ providers: [
556
+ MsalGuard,
557
+ MsalBroadcastService
558
+ ]
559
+ },] }
540
560
  ];
541
561
 
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 }
562
+ /*
563
+ * Copyright (c) Microsoft Corporation. All rights reserved.
564
+ * Licensed under the MIT License.
565
+ */
566
+ /**
567
+ * Custom navigation used for Angular client-side navigation.
568
+ * See performance doc for details:
569
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/docs/v2-docs/performance.md
570
+ */
571
+ class MsalCustomNavigationClient extends NavigationClient {
572
+ constructor(authService, router, location) {
573
+ super();
574
+ this.authService = authService;
575
+ this.router = router;
576
+ this.location = location;
577
+ }
578
+ navigateInternal(url, options) {
579
+ const _super = Object.create(null, {
580
+ navigateInternal: { get: () => super.navigateInternal }
581
+ });
582
+ return __awaiter(this, void 0, void 0, function* () {
583
+ this.authService.getLogger().trace("MsalCustomNavigationClient called");
584
+ this.authService.getLogger().verbose("MsalCustomNavigationClient - navigating");
585
+ this.authService.getLogger().verbosePii(`MsalCustomNavigationClient - navigating to url: ${url}`);
586
+ // Prevent hash clearing from causing an issue with Client-side navigation after redirect is handled
587
+ if (options.noHistory) {
588
+ return _super.navigateInternal.call(this, url, options);
589
+ }
590
+ else {
591
+ // Normalizing newUrl if no query string
592
+ const urlComponents = new UrlString(url).getUrlComponents();
593
+ const newUrl = urlComponents.QueryString ? `${urlComponents.AbsolutePath}?${urlComponents.QueryString}` : this.location.normalize(urlComponents.AbsolutePath);
594
+ this.router.navigateByUrl(newUrl, { replaceUrl: options.noHistory });
595
+ }
596
+ return Promise.resolve(options.noHistory);
597
+ });
598
+ }
599
+ }
600
+ MsalCustomNavigationClient.decorators = [
601
+ { type: Injectable }
602
+ ];
603
+ MsalCustomNavigationClient.ctorParameters = () => [
604
+ { type: MsalService },
605
+ { type: Router },
606
+ { type: Location }
587
607
  ];
588
608
 
589
- /*
590
- * Copyright (c) Microsoft Corporation. All rights reserved.
591
- * Licensed under the MIT License.
609
+ /*
610
+ * Copyright (c) Microsoft Corporation. All rights reserved.
611
+ * Licensed under the MIT License.
592
612
  */
593
613
 
594
- /**
595
- * Generated bundle index. Do not edit.
614
+ /**
615
+ * Generated bundle index. Do not edit.
596
616
  */
597
617
 
598
618
  export { MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalBroadcastService, MsalCustomNavigationClient, MsalGuard, MsalInterceptor, MsalModule, MsalRedirectComponent, MsalService, version };