@azure/msal-common 14.12.0 → 14.12.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/account/AccountInfo.mjs +1 -1
  2. package/dist/account/AuthToken.mjs +1 -1
  3. package/dist/account/CcsCredential.mjs +1 -1
  4. package/dist/account/ClientInfo.mjs +1 -1
  5. package/dist/account/TokenClaims.mjs +1 -1
  6. package/dist/authority/Authority.mjs +1 -1
  7. package/dist/authority/AuthorityFactory.mjs +1 -1
  8. package/dist/authority/AuthorityMetadata.mjs +1 -1
  9. package/dist/authority/AuthorityOptions.mjs +1 -1
  10. package/dist/authority/AuthorityType.mjs +1 -1
  11. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  12. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  13. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  14. package/dist/authority/ProtocolMode.mjs +1 -1
  15. package/dist/authority/RegionDiscovery.mjs +1 -1
  16. package/dist/cache/CacheManager.mjs +1 -1
  17. package/dist/cache/entities/AccountEntity.d.ts +1 -1
  18. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  19. package/dist/cache/entities/AccountEntity.mjs +7 -7
  20. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  21. package/dist/cache/entities/CacheRecord.d.ts +7 -8
  22. package/dist/cache/entities/CacheRecord.d.ts.map +1 -1
  23. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  24. package/dist/cache/utils/CacheHelpers.mjs +1 -1
  25. package/dist/client/AuthorizationCodeClient.mjs +1 -1
  26. package/dist/client/BaseClient.mjs +1 -1
  27. package/dist/client/RefreshTokenClient.mjs +1 -1
  28. package/dist/client/SilentFlowClient.mjs +1 -1
  29. package/dist/config/ClientConfiguration.mjs +1 -1
  30. package/dist/constants/AADServerParamKeys.mjs +1 -1
  31. package/dist/crypto/ICrypto.mjs +1 -1
  32. package/dist/crypto/JoseHeader.mjs +1 -1
  33. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  34. package/dist/error/AuthError.mjs +1 -1
  35. package/dist/error/AuthErrorCodes.mjs +1 -1
  36. package/dist/error/CacheError.mjs +1 -1
  37. package/dist/error/CacheErrorCodes.mjs +1 -1
  38. package/dist/error/ClientAuthError.mjs +1 -1
  39. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  40. package/dist/error/ClientConfigurationError.mjs +1 -1
  41. package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
  42. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  43. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
  44. package/dist/error/JoseHeaderError.mjs +1 -1
  45. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  46. package/dist/error/ServerError.mjs +1 -1
  47. package/dist/index.cjs +24 -48
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.mjs +1 -2
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/logger/Logger.mjs +1 -1
  52. package/dist/network/INetworkModule.mjs +1 -1
  53. package/dist/network/NetworkManager.mjs +1 -1
  54. package/dist/network/ThrottlingUtils.mjs +1 -1
  55. package/dist/packageMetadata.d.ts +1 -1
  56. package/dist/packageMetadata.d.ts.map +1 -1
  57. package/dist/packageMetadata.mjs +2 -2
  58. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  59. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  60. package/dist/request/RequestParameterBuilder.mjs +5 -4
  61. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  62. package/dist/request/RequestValidator.d.ts +0 -6
  63. package/dist/request/RequestValidator.d.ts.map +1 -1
  64. package/dist/request/RequestValidator.mjs +1 -18
  65. package/dist/request/RequestValidator.mjs.map +1 -1
  66. package/dist/request/ScopeSet.mjs +1 -1
  67. package/dist/response/ExternalTokenResponse.d.ts +1 -1
  68. package/dist/response/ExternalTokenResponse.d.ts.map +1 -1
  69. package/dist/response/ResponseHandler.d.ts +1 -1
  70. package/dist/response/ResponseHandler.d.ts.map +1 -1
  71. package/dist/response/ResponseHandler.mjs +12 -6
  72. package/dist/response/ResponseHandler.mjs.map +1 -1
  73. package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
  74. package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
  75. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  76. package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
  77. package/dist/url/UrlString.mjs +1 -1
  78. package/dist/utils/ClientAssertionUtils.mjs +1 -1
  79. package/dist/utils/Constants.d.ts +1 -0
  80. package/dist/utils/Constants.d.ts.map +1 -1
  81. package/dist/utils/Constants.mjs +2 -1
  82. package/dist/utils/Constants.mjs.map +1 -1
  83. package/dist/utils/FunctionWrappers.mjs +1 -1
  84. package/dist/utils/ProtocolUtils.mjs +1 -1
  85. package/dist/utils/StringUtils.mjs +1 -1
  86. package/dist/utils/TimeUtils.mjs +1 -1
  87. package/dist/utils/UrlUtils.mjs +1 -1
  88. package/package.json +1 -1
  89. package/src/cache/entities/AccountEntity.ts +7 -7
  90. package/src/cache/entities/CacheRecord.ts +7 -21
  91. package/src/packageMetadata.ts +1 -1
  92. package/src/request/RequestParameterBuilder.ts +4 -6
  93. package/src/request/RequestValidator.ts +0 -26
  94. package/src/response/ExternalTokenResponse.ts +8 -1
  95. package/src/response/ResponseHandler.ts +21 -10
  96. package/src/utils/Constants.ts +1 -0
  97. package/dist/cache/entities/CacheRecord.mjs +0 -19
  98. package/dist/cache/entities/CacheRecord.mjs.map +0 -1
@@ -135,7 +135,7 @@ export class AccountEntity {
135
135
  static createAccount(
136
136
  accountDetails: {
137
137
  homeAccountId: string;
138
- idTokenClaims: TokenClaims;
138
+ idTokenClaims?: TokenClaims;
139
139
  clientInfo?: string;
140
140
  cloudGraphHostName?: string;
141
141
  msGraphHost?: string;
@@ -189,8 +189,8 @@ export class AccountEntity {
189
189
  // How do you account for MSA CID here?
190
190
  account.localAccountId =
191
191
  clientInfo?.uid ||
192
- accountDetails.idTokenClaims.oid ||
193
- accountDetails.idTokenClaims.sub ||
192
+ accountDetails.idTokenClaims?.oid ||
193
+ accountDetails.idTokenClaims?.sub ||
194
194
  "";
195
195
 
196
196
  /*
@@ -199,14 +199,14 @@ export class AccountEntity {
199
199
  * policy is configured to return more than 1 email.
200
200
  */
201
201
  const preferredUsername =
202
- accountDetails.idTokenClaims.preferred_username ||
203
- accountDetails.idTokenClaims.upn;
204
- const email = accountDetails.idTokenClaims.emails
202
+ accountDetails.idTokenClaims?.preferred_username ||
203
+ accountDetails.idTokenClaims?.upn;
204
+ const email = accountDetails.idTokenClaims?.emails
205
205
  ? accountDetails.idTokenClaims.emails[0]
206
206
  : null;
207
207
 
208
208
  account.username = preferredUsername || email || "";
209
- account.name = accountDetails.idTokenClaims.name;
209
+ account.name = accountDetails.idTokenClaims?.name || "";
210
210
 
211
211
  account.cloudGraphHostName = accountDetails.cloudGraphHostName;
212
212
  account.msGraphHost = accountDetails.msGraphHost;
@@ -10,24 +10,10 @@ import { AccountEntity } from "./AccountEntity";
10
10
  import { AppMetadataEntity } from "./AppMetadataEntity";
11
11
 
12
12
  /** @internal */
13
- export class CacheRecord {
14
- account: AccountEntity | null;
15
- idToken: IdTokenEntity | null;
16
- accessToken: AccessTokenEntity | null;
17
- refreshToken: RefreshTokenEntity | null;
18
- appMetadata: AppMetadataEntity | null;
19
-
20
- constructor(
21
- accountEntity?: AccountEntity | null,
22
- idTokenEntity?: IdTokenEntity | null,
23
- accessTokenEntity?: AccessTokenEntity | null,
24
- refreshTokenEntity?: RefreshTokenEntity | null,
25
- appMetadataEntity?: AppMetadataEntity | null
26
- ) {
27
- this.account = accountEntity || null;
28
- this.idToken = idTokenEntity || null;
29
- this.accessToken = accessTokenEntity || null;
30
- this.refreshToken = refreshTokenEntity || null;
31
- this.appMetadata = appMetadataEntity || null;
32
- }
33
- }
13
+ export type CacheRecord = {
14
+ account?: AccountEntity | null;
15
+ idToken?: IdTokenEntity | null;
16
+ accessToken?: AccessTokenEntity | null;
17
+ refreshToken?: RefreshTokenEntity | null;
18
+ appMetadata?: AppMetadataEntity | null;
19
+ };
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-common";
3
- export const version = "14.12.0";
3
+ export const version = "14.12.1-alpha.1";
@@ -465,12 +465,10 @@ export class RequestParameterBuilder {
465
465
  * @param eQParams
466
466
  */
467
467
  addExtraQueryParameters(eQParams: StringDict): void {
468
- const sanitizedEQParams = RequestValidator.sanitizeEQParams(
469
- eQParams,
470
- this.parameters
471
- );
472
- Object.keys(sanitizedEQParams).forEach((key) => {
473
- this.parameters.set(key, eQParams[key]);
468
+ Object.entries(eQParams).forEach(([key, value]) => {
469
+ if (!this.parameters.has(key) && value) {
470
+ this.parameters.set(key, value);
471
+ }
474
472
  });
475
473
  }
476
474
 
@@ -8,7 +8,6 @@ import {
8
8
  ClientConfigurationErrorCodes,
9
9
  } from "../error/ClientConfigurationError";
10
10
  import { PromptValue, CodeChallengeMethodValues } from "../utils/Constants";
11
- import { StringDict } from "../utils/MsalTypes";
12
11
 
13
12
  /**
14
13
  * Validates server consumable params from the "request" objects
@@ -88,29 +87,4 @@ export class RequestValidator {
88
87
  );
89
88
  }
90
89
  }
91
-
92
- /**
93
- * Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
94
- * @param request
95
- */
96
- static sanitizeEQParams(
97
- eQParams: StringDict,
98
- queryParams: Map<string, string>
99
- ): StringDict {
100
- if (!eQParams) {
101
- return {};
102
- }
103
-
104
- // Remove any query parameters already included in SSO params
105
- queryParams.forEach((_value, key) => {
106
- if (eQParams[key]) {
107
- delete eQParams[key];
108
- }
109
- });
110
-
111
- // remove empty string parameters
112
- return Object.fromEntries(
113
- Object.entries(eQParams).filter((kv) => kv[1] !== "")
114
- );
115
- }
116
90
  }
@@ -17,7 +17,14 @@ import { ServerAuthorizationTokenResponse } from "./ServerAuthorizationTokenResp
17
17
  */
18
18
  export type ExternalTokenResponse = Pick<
19
19
  ServerAuthorizationTokenResponse,
20
- "token_type" | "scope" | "expires_in" | "id_token" | "refresh_token"
20
+ | "token_type"
21
+ | "scope"
22
+ | "expires_in"
23
+ | "ext_expires_in"
24
+ | "id_token"
25
+ | "refresh_token"
26
+ | "refresh_token_expires_in"
27
+ | "foci"
21
28
  > & {
22
29
  access_token?: string;
23
30
  client_info?: string;
@@ -197,7 +197,17 @@ export class ResponseHandler {
197
197
  serverResponse.error_description ||
198
198
  serverResponse.suberror
199
199
  ) {
200
- const errString = `${serverResponse.error_codes} - [${serverResponse.timestamp}]: ${serverResponse.error_description} - Correlation ID: ${serverResponse.correlation_id} - Trace ID: ${serverResponse.trace_id}`;
200
+ const errString = `Error(s): ${
201
+ serverResponse.error_codes || Constants.NOT_AVAILABLE
202
+ } - Timestamp: ${
203
+ serverResponse.timestamp || Constants.NOT_AVAILABLE
204
+ } - Description: ${
205
+ serverResponse.error_description || Constants.NOT_AVAILABLE
206
+ } - Correlation ID: ${
207
+ serverResponse.correlation_id || Constants.NOT_AVAILABLE
208
+ } - Trace ID: ${
209
+ serverResponse.trace_id || Constants.NOT_AVAILABLE
210
+ }`;
201
211
  const serverErrorNo = serverResponse.error_codes?.length
202
212
  ? serverResponse.error_codes[0]
203
213
  : undefined;
@@ -454,8 +464,8 @@ export class ResponseHandler {
454
464
  this.cacheStorage,
455
465
  authority,
456
466
  this.homeAccountIdentifier,
457
- idTokenClaims,
458
467
  this.cryptoObj.base64Decode,
468
+ idTokenClaims,
459
469
  serverTokenResponse.client_info,
460
470
  env,
461
471
  claimsTenantId,
@@ -553,13 +563,13 @@ export class ResponseHandler {
553
563
  };
554
564
  }
555
565
 
556
- return new CacheRecord(
557
- cachedAccount,
558
- cachedIdToken,
559
- cachedAccessToken,
560
- cachedRefreshToken,
561
- cachedAppMetadata
562
- );
566
+ return {
567
+ account: cachedAccount,
568
+ idToken: cachedIdToken,
569
+ accessToken: cachedAccessToken,
570
+ refreshToken: cachedRefreshToken,
571
+ appMetadata: cachedAppMetadata,
572
+ };
563
573
  }
564
574
 
565
575
  /**
@@ -694,8 +704,8 @@ export function buildAccountToCache(
694
704
  cacheStorage: CacheManager,
695
705
  authority: Authority,
696
706
  homeAccountId: string,
697
- idTokenClaims: TokenClaims,
698
707
  base64Decode: (input: string) => string,
708
+ idTokenClaims?: TokenClaims,
699
709
  clientInfo?: string,
700
710
  environment?: string,
701
711
  claimsTenantId?: string | null,
@@ -736,6 +746,7 @@ export function buildAccountToCache(
736
746
 
737
747
  if (
738
748
  claimsTenantId &&
749
+ idTokenClaims &&
739
750
  !tenantProfiles.find((tenantProfile) => {
740
751
  return tenantProfile.tenantId === claimsTenantId;
741
752
  })
@@ -45,6 +45,7 @@ export const Constants = {
45
45
  NOT_DEFINED: "not_defined",
46
46
  EMPTY_STRING: "",
47
47
  NOT_APPLICABLE: "N/A",
48
+ NOT_AVAILABLE: "Not Available",
48
49
  FORWARD_SLASH: "/",
49
50
  IMDS_ENDPOINT: "http://169.254.169.254/metadata/instance/compute/location",
50
51
  IMDS_VERSION: "2020-06-01",
@@ -1,19 +0,0 @@
1
- /*! @azure/msal-common v14.12.0 2024-06-10 */
2
- 'use strict';
3
- /*
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Licensed under the MIT License.
6
- */
7
- /** @internal */
8
- class CacheRecord {
9
- constructor(accountEntity, idTokenEntity, accessTokenEntity, refreshTokenEntity, appMetadataEntity) {
10
- this.account = accountEntity || null;
11
- this.idToken = idTokenEntity || null;
12
- this.accessToken = accessTokenEntity || null;
13
- this.refreshToken = refreshTokenEntity || null;
14
- this.appMetadata = appMetadataEntity || null;
15
- }
16
- }
17
-
18
- export { CacheRecord };
19
- //# sourceMappingURL=CacheRecord.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CacheRecord.mjs","sources":["../../../src/cache/entities/CacheRecord.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAQH;MACa,WAAW,CAAA;IAOpB,WACI,CAAA,aAAoC,EACpC,aAAoC,EACpC,iBAA4C,EAC5C,kBAA8C,EAC9C,iBAA4C,EAAA;AAE5C,QAAA,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI,IAAI,CAAC;AACrC,QAAA,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI,IAAI,CAAC;AACrC,QAAA,IAAI,CAAC,WAAW,GAAG,iBAAiB,IAAI,IAAI,CAAC;AAC7C,QAAA,IAAI,CAAC,YAAY,GAAG,kBAAkB,IAAI,IAAI,CAAC;AAC/C,QAAA,IAAI,CAAC,WAAW,GAAG,iBAAiB,IAAI,IAAI,CAAC;KAChD;AACJ;;;;"}