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