@azure/msal-angular 3.0.8 → 3.0.10

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.
@@ -8,17 +8,17 @@ import { map, concatMap, catchError, switchMap, take, filter } from 'rxjs/operat
8
8
  import * as i4 from '@angular/router';
9
9
 
10
10
  /* eslint-disable header/header */
11
- const name = '@azure/msal-angular';
12
- const version = '3.0.8';
11
+ const name = "@azure/msal-angular";
12
+ const version = "3.0.10";
13
13
 
14
14
  /*
15
15
  * Copyright (c) Microsoft Corporation. All rights reserved.
16
16
  * Licensed under the MIT License.
17
17
  */
18
- const MSAL_INSTANCE = new InjectionToken('MSAL_INSTANCE');
19
- const MSAL_GUARD_CONFIG = new InjectionToken('MSAL_GUARD_CONFIG');
20
- const MSAL_INTERCEPTOR_CONFIG = new InjectionToken('MSAL_INTERCEPTOR_CONFIG');
21
- const MSAL_BROADCAST_CONFIG = new InjectionToken('MSAL_BROADCAST_CONFIG');
18
+ const MSAL_INSTANCE = new InjectionToken("MSAL_INSTANCE");
19
+ const MSAL_GUARD_CONFIG = new InjectionToken("MSAL_GUARD_CONFIG");
20
+ const MSAL_INTERCEPTOR_CONFIG = new InjectionToken("MSAL_INTERCEPTOR_CONFIG");
21
+ const MSAL_BROADCAST_CONFIG = new InjectionToken("MSAL_BROADCAST_CONFIG");
22
22
 
23
23
  /*
24
24
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -28,7 +28,7 @@ class MsalService {
28
28
  constructor(instance, location) {
29
29
  this.instance = instance;
30
30
  this.location = location;
31
- const hash = this.location.path(true).split('#').pop();
31
+ const hash = this.location.path(true).split("#").pop();
32
32
  if (hash) {
33
33
  this.redirectHash = `#${hash}`;
34
34
  }
@@ -172,17 +172,17 @@ class MsalGuard {
172
172
  * @returns Full destination url
173
173
  */
174
174
  getDestinationUrl(path) {
175
- this.authService.getLogger().verbose('Guard - getting destination url');
175
+ this.authService.getLogger().verbose("Guard - getting destination url");
176
176
  // Absolute base url for the application (default to origin if base element not present)
177
- const baseElements = document.getElementsByTagName('base');
177
+ const baseElements = document.getElementsByTagName("base");
178
178
  const baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);
179
179
  // Path of page (including hash, if using hash routing)
180
180
  const pathUrl = this.location.prepareExternalUrl(path);
181
181
  // Hash location strategy
182
- if (pathUrl.startsWith('#')) {
182
+ if (pathUrl.startsWith("#")) {
183
183
  this.authService
184
184
  .getLogger()
185
- .verbose('Guard - destination by hash routing');
185
+ .verbose("Guard - destination by hash routing");
186
186
  return `${baseUrl}/${pathUrl}`;
187
187
  }
188
188
  /*
@@ -196,20 +196,20 @@ class MsalGuard {
196
196
  * @param url Path of the requested page
197
197
  */
198
198
  loginInteractively(state) {
199
- const authRequest = typeof this.msalGuardConfig.authRequest === 'function'
199
+ const authRequest = typeof this.msalGuardConfig.authRequest === "function"
200
200
  ? this.msalGuardConfig.authRequest(this.authService, state)
201
201
  : { ...this.msalGuardConfig.authRequest };
202
202
  if (this.msalGuardConfig.interactionType === InteractionType.Popup) {
203
- this.authService.getLogger().verbose('Guard - logging in by popup');
203
+ this.authService.getLogger().verbose("Guard - logging in by popup");
204
204
  return this.authService.loginPopup(authRequest).pipe(map((response) => {
205
205
  this.authService
206
206
  .getLogger()
207
- .verbose('Guard - login by popup successful, can activate, setting active account');
207
+ .verbose("Guard - login by popup successful, can activate, setting active account");
208
208
  this.authService.instance.setActiveAccount(response.account);
209
209
  return true;
210
210
  }));
211
211
  }
212
- this.authService.getLogger().verbose('Guard - logging in by redirect');
212
+ this.authService.getLogger().verbose("Guard - logging in by redirect");
213
213
  const redirectStartPage = this.getDestinationUrl(state.url);
214
214
  return this.authService
215
215
  .loginRedirect({
@@ -225,28 +225,28 @@ class MsalGuard {
225
225
  activateHelper(state) {
226
226
  if (this.msalGuardConfig.interactionType !== InteractionType.Popup &&
227
227
  this.msalGuardConfig.interactionType !== InteractionType.Redirect) {
228
- throw new BrowserConfigurationAuthError('invalid_interaction_type', 'Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration');
228
+ throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Guard. InteractionType.Popup or InteractionType.Redirect must be provided in the MsalGuardConfiguration");
229
229
  }
230
- this.authService.getLogger().verbose('MSAL Guard activated');
230
+ this.authService.getLogger().verbose("MSAL Guard activated");
231
231
  /*
232
232
  * If a page with MSAL Guard is set as the redirect for acquireTokenSilent,
233
233
  * short-circuit to prevent redirecting or popups.
234
234
  */
235
- if (typeof window !== 'undefined') {
235
+ if (typeof window !== "undefined") {
236
236
  if (UrlString.hashContainsKnownProperties(window.location.hash) &&
237
237
  BrowserUtils.isInIframe() &&
238
238
  !this.authService.instance.getConfiguration().system
239
239
  .allowRedirectInIframe) {
240
240
  this.authService
241
241
  .getLogger()
242
- .warning('Guard - redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication.');
242
+ .warning("Guard - redirectUri set to page with MSAL Guard. It is recommended to not set redirectUri to a page that requires authentication.");
243
243
  return of(false);
244
244
  }
245
245
  }
246
246
  else {
247
247
  this.authService
248
248
  .getLogger()
249
- .info('Guard - window is undefined, MSAL does not support server-side token acquisition');
249
+ .info("Guard - window is undefined, MSAL does not support server-side token acquisition");
250
250
  return of(true);
251
251
  }
252
252
  /**
@@ -264,17 +264,17 @@ class MsalGuard {
264
264
  if (state) {
265
265
  this.authService
266
266
  .getLogger()
267
- .verbose('Guard - no accounts retrieved, log in required to activate');
267
+ .verbose("Guard - no accounts retrieved, log in required to activate");
268
268
  return this.loginInteractively(state);
269
269
  }
270
270
  this.authService
271
271
  .getLogger()
272
- .verbose('Guard - no accounts retrieved, no state, cannot load');
272
+ .verbose("Guard - no accounts retrieved, no state, cannot load");
273
273
  return of(false);
274
274
  }
275
275
  this.authService
276
276
  .getLogger()
277
- .verbose('Guard - at least 1 account exists, can activate or load');
277
+ .verbose("Guard - at least 1 account exists, can activate or load");
278
278
  // Prevent navigating the app to /#code= or /code=
279
279
  if (state) {
280
280
  /*
@@ -291,25 +291,25 @@ class MsalGuard {
291
291
  const fragmentContainsCode = !!state.root &&
292
292
  !!state.root.fragment &&
293
293
  this.includesCode(`#${state.root.fragment}`);
294
- const hashRouting = this.location.prepareExternalUrl(state.url).indexOf('#') === 0;
294
+ const hashRouting = this.location.prepareExternalUrl(state.url).indexOf("#") === 0;
295
295
  // Ensure code parameter is in fragment (and not in query parameter), or that hash hash routing is used
296
296
  if (urlContainsCode && (fragmentContainsCode || hashRouting)) {
297
297
  this.authService
298
298
  .getLogger()
299
- .info('Guard - Hash contains known code response, stopping navigation.');
299
+ .info("Guard - Hash contains known code response, stopping navigation.");
300
300
  // Path routing (navigate to current path without hash)
301
- if (currentPath.indexOf('#') > -1) {
301
+ if (currentPath.indexOf("#") > -1) {
302
302
  return of(this.parseUrl(this.location.path()));
303
303
  }
304
304
  // Hash routing (navigate to root path)
305
- return of(this.parseUrl(''));
305
+ return of(this.parseUrl(""));
306
306
  }
307
307
  }
308
308
  return of(true);
309
309
  }), catchError((error) => {
310
310
  this.authService
311
311
  .getLogger()
312
- .error('Guard - error while logging in, unable to activate');
312
+ .error("Guard - error while logging in, unable to activate");
313
313
  this.authService
314
314
  .getLogger()
315
315
  .errorPii(`Guard - error: ${error.message}`);
@@ -319,28 +319,28 @@ class MsalGuard {
319
319
  if (this.loginFailedRoute && state) {
320
320
  this.authService
321
321
  .getLogger()
322
- .verbose('Guard - loginFailedRoute set, redirecting');
322
+ .verbose("Guard - loginFailedRoute set, redirecting");
323
323
  return of(this.loginFailedRoute);
324
324
  }
325
325
  return of(false);
326
326
  }));
327
327
  }
328
328
  includesCode(path) {
329
- return ((path.lastIndexOf('/code') > -1 &&
330
- path.lastIndexOf('/code') === path.length - '/code'.length) || // path.endsWith("/code")
331
- path.indexOf('#code=') > -1 ||
332
- path.indexOf('&code=') > -1);
329
+ return ((path.lastIndexOf("/code") > -1 &&
330
+ path.lastIndexOf("/code") === path.length - "/code".length) || // path.endsWith("/code")
331
+ path.indexOf("#code=") > -1 ||
332
+ path.indexOf("&code=") > -1);
333
333
  }
334
334
  canActivate(route, state) {
335
- this.authService.getLogger().verbose('Guard - canActivate');
335
+ this.authService.getLogger().verbose("Guard - canActivate");
336
336
  return this.activateHelper(state);
337
337
  }
338
338
  canActivateChild(route, state) {
339
- this.authService.getLogger().verbose('Guard - canActivateChild');
339
+ this.authService.getLogger().verbose("Guard - canActivateChild");
340
340
  return this.activateHelper(state);
341
341
  }
342
342
  canMatch() {
343
- this.authService.getLogger().verbose('Guard - canLoad');
343
+ this.authService.getLogger().verbose("Guard - canLoad");
344
344
  return this.activateHelper();
345
345
  }
346
346
  }
@@ -373,15 +373,15 @@ class MsalInterceptor {
373
373
  ) {
374
374
  if (this.msalInterceptorConfig.interactionType !== InteractionType.Popup &&
375
375
  this.msalInterceptorConfig.interactionType !== InteractionType.Redirect) {
376
- throw new BrowserConfigurationAuthError('invalid_interaction_type', 'Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration');
376
+ throw new BrowserConfigurationAuthError("invalid_interaction_type", "Invalid interaction type provided to MSAL Interceptor. InteractionType.Popup, InteractionType.Redirect must be provided in the msalInterceptorConfiguration");
377
377
  }
378
- this.authService.getLogger().verbose('MSAL Interceptor activated');
378
+ this.authService.getLogger().verbose("MSAL Interceptor activated");
379
379
  const scopes = this.getScopesForEndpoint(req.url, req.method);
380
380
  // If no scopes for endpoint, does not acquire token
381
381
  if (!scopes || scopes.length === 0) {
382
382
  this.authService
383
383
  .getLogger()
384
- .verbose('Interceptor - no scopes for endpoint');
384
+ .verbose("Interceptor - no scopes for endpoint");
385
385
  return next.handle(req);
386
386
  }
387
387
  // Sets account as active account or first account
@@ -389,16 +389,16 @@ class MsalInterceptor {
389
389
  if (!!this.authService.instance.getActiveAccount()) {
390
390
  this.authService
391
391
  .getLogger()
392
- .verbose('Interceptor - active account selected');
392
+ .verbose("Interceptor - active account selected");
393
393
  account = this.authService.instance.getActiveAccount();
394
394
  }
395
395
  else {
396
396
  this.authService
397
397
  .getLogger()
398
- .verbose('Interceptor - no active account, fallback to first account');
398
+ .verbose("Interceptor - no active account, fallback to first account");
399
399
  account = this.authService.instance.getAllAccounts()[0];
400
400
  }
401
- const authRequest = typeof this.msalInterceptorConfig.authRequest === 'function'
401
+ const authRequest = typeof this.msalInterceptorConfig.authRequest === "function"
402
402
  ? this.msalInterceptorConfig.authRequest(this.authService, req, {
403
403
  account: account,
404
404
  })
@@ -412,8 +412,8 @@ class MsalInterceptor {
412
412
  return this.acquireToken(authRequest, scopes, account).pipe(switchMap((result) => {
413
413
  this.authService
414
414
  .getLogger()
415
- .verbose('Interceptor - setting authorization headers');
416
- const headers = req.headers.set('Authorization', `Bearer ${result.accessToken}`);
415
+ .verbose("Interceptor - setting authorization headers");
416
+ const headers = req.headers.set("Authorization", `Bearer ${result.accessToken}`);
417
417
  const requestClone = req.clone({ headers });
418
418
  return next.handle(requestClone);
419
419
  }));
@@ -432,7 +432,7 @@ class MsalInterceptor {
432
432
  .pipe(catchError(() => {
433
433
  this.authService
434
434
  .getLogger()
435
- .error('Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.');
435
+ .error("Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.");
436
436
  return this.msalBroadcastService.inProgress$.pipe(take(1), switchMap((status) => {
437
437
  if (status === InteractionStatus.None) {
438
438
  return this.acquireTokenInteractively(authRequest, scopes);
@@ -443,7 +443,7 @@ class MsalInterceptor {
443
443
  if (!result.accessToken) {
444
444
  this.authService
445
445
  .getLogger()
446
- .error('Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.');
446
+ .error("Interceptor - acquireTokenSilent resolved with null access token. Known issue with B2C tenants, invoking interaction to resolve.");
447
447
  return this.msalBroadcastService.inProgress$.pipe(filter((status) => status === InteractionStatus.None), take(1), switchMap(() => this.acquireTokenInteractively(authRequest, scopes)));
448
448
  }
449
449
  return of(result);
@@ -459,12 +459,12 @@ class MsalInterceptor {
459
459
  if (this.msalInterceptorConfig.interactionType === InteractionType.Popup) {
460
460
  this.authService
461
461
  .getLogger()
462
- .verbose('Interceptor - error acquiring token silently, acquiring by popup');
462
+ .verbose("Interceptor - error acquiring token silently, acquiring by popup");
463
463
  return this.authService.acquireTokenPopup({ ...authRequest, scopes });
464
464
  }
465
465
  this.authService
466
466
  .getLogger()
467
- .verbose('Interceptor - error acquiring token silently, acquiring by redirect');
467
+ .verbose("Interceptor - error acquiring token silently, acquiring by redirect");
468
468
  const redirectStartPage = window.location.href;
469
469
  this.authService.acquireTokenRedirect({
470
470
  ...authRequest,
@@ -483,7 +483,7 @@ class MsalInterceptor {
483
483
  getScopesForEndpoint(endpoint, httpMethod) {
484
484
  this.authService
485
485
  .getLogger()
486
- .verbose('Interceptor - getting scopes for endpoint');
486
+ .verbose("Interceptor - getting scopes for endpoint");
487
487
  // Ensures endpoints and protected resources compared are normalized
488
488
  const normalizedEndpoint = this.location.normalize(endpoint);
489
489
  const protectedResourcesArray = Array.from(this.msalInterceptorConfig.protectedResourceMap.keys());
@@ -526,8 +526,8 @@ class MsalInterceptor {
526
526
  // Add resource to matchingResources.relativeResources if same origin, relativeKey matches endpoint, and is not empty
527
527
  if (keyComponents.HostNameAndPort === endpointComponents.HostNameAndPort &&
528
528
  StringUtils.matchPattern(relativeNormalizedKey, absoluteEndpoint) &&
529
- relativeNormalizedKey !== '' &&
530
- relativeNormalizedKey !== '/*') {
529
+ relativeNormalizedKey !== "" &&
530
+ relativeNormalizedKey !== "/*") {
531
531
  matchingResources.relativeResources.push(key);
532
532
  }
533
533
  });
@@ -539,7 +539,7 @@ class MsalInterceptor {
539
539
  * @returns
540
540
  */
541
541
  getAbsoluteUrl(url) {
542
- const link = this._document.createElement('a');
542
+ const link = this._document.createElement("a");
543
543
  link.href = url;
544
544
  return link.href;
545
545
  }
@@ -563,7 +563,7 @@ class MsalInterceptor {
563
563
  }
564
564
  methodAndScopesArray.forEach((entry) => {
565
565
  // Entry is either array of scopes or ProtectedResourceScopes object
566
- if (typeof entry === 'string') {
566
+ if (typeof entry === "string") {
567
567
  scopesForEndpoint.push(entry);
568
568
  }
569
569
  else {
@@ -593,7 +593,7 @@ class MsalInterceptor {
593
593
  if (allMatchedScopes.length > 1) {
594
594
  this.authService
595
595
  .getLogger()
596
- .warning('Interceptor - More than 1 matching scopes for endpoint found.');
596
+ .warning("Interceptor - More than 1 matching scopes for endpoint found.");
597
597
  }
598
598
  // Returns scopes for first matching endpoint
599
599
  return allMatchedScopes[0];
@@ -627,17 +627,17 @@ class MsalRedirectComponent {
627
627
  this.authService = authService;
628
628
  }
629
629
  ngOnInit() {
630
- this.authService.getLogger().verbose('MsalRedirectComponent activated');
630
+ this.authService.getLogger().verbose("MsalRedirectComponent activated");
631
631
  this.authService.handleRedirectObservable().subscribe();
632
632
  }
633
633
  }
634
634
  MsalRedirectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MsalRedirectComponent, deps: [{ token: MsalService }], target: i0.ɵɵFactoryTarget.Component });
635
- MsalRedirectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: MsalRedirectComponent, selector: "app-redirect", ngImport: i0, template: '', isInline: true });
635
+ MsalRedirectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: MsalRedirectComponent, selector: "app-redirect", ngImport: i0, template: "", isInline: true });
636
636
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MsalRedirectComponent, decorators: [{
637
637
  type: Component,
638
638
  args: [{
639
- selector: 'app-redirect',
640
- template: '',
639
+ selector: "app-redirect",
640
+ template: "",
641
641
  }]
642
642
  }], ctorParameters: function () { return [{ type: MsalService }]; } });
643
643
 
@@ -696,10 +696,10 @@ class MsalCustomNavigationClient extends NavigationClient {
696
696
  this.location = location;
697
697
  }
698
698
  async navigateInternal(url, options) {
699
- this.authService.getLogger().trace('MsalCustomNavigationClient called');
699
+ this.authService.getLogger().trace("MsalCustomNavigationClient called");
700
700
  this.authService
701
701
  .getLogger()
702
- .verbose('MsalCustomNavigationClient - navigating');
702
+ .verbose("MsalCustomNavigationClient - navigating");
703
703
  this.authService
704
704
  .getLogger()
705
705
  .verbosePii(`MsalCustomNavigationClient - navigating to url: ${url}`);