@azure/msal-common 14.13.0 → 14.14.0

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 (97) hide show
  1. package/dist/account/AccountInfo.d.ts +9 -1
  2. package/dist/account/AccountInfo.d.ts.map +1 -1
  3. package/dist/account/AccountInfo.mjs +35 -18
  4. package/dist/account/AccountInfo.mjs.map +1 -1
  5. package/dist/account/AuthToken.mjs +1 -1
  6. package/dist/account/CcsCredential.mjs +1 -1
  7. package/dist/account/ClientInfo.mjs +1 -1
  8. package/dist/account/TokenClaims.mjs +1 -1
  9. package/dist/authority/Authority.mjs +1 -1
  10. package/dist/authority/AuthorityFactory.mjs +1 -1
  11. package/dist/authority/AuthorityMetadata.mjs +1 -1
  12. package/dist/authority/AuthorityOptions.mjs +1 -1
  13. package/dist/authority/AuthorityType.mjs +1 -1
  14. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  15. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  16. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  17. package/dist/authority/ProtocolMode.mjs +1 -1
  18. package/dist/authority/RegionDiscovery.mjs +1 -1
  19. package/dist/cache/CacheManager.d.ts +0 -1
  20. package/dist/cache/CacheManager.d.ts.map +1 -1
  21. package/dist/cache/CacheManager.mjs +2 -5
  22. package/dist/cache/CacheManager.mjs.map +1 -1
  23. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  24. package/dist/cache/entities/AccountEntity.mjs +4 -8
  25. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  26. package/dist/cache/entities/ServerTelemetryEntity.d.ts +1 -0
  27. package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -1
  28. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  29. package/dist/cache/utils/CacheHelpers.mjs +1 -1
  30. package/dist/client/AuthorizationCodeClient.mjs +1 -1
  31. package/dist/client/BaseClient.mjs +1 -1
  32. package/dist/client/RefreshTokenClient.mjs +1 -1
  33. package/dist/client/SilentFlowClient.mjs +1 -1
  34. package/dist/config/ClientConfiguration.mjs +1 -1
  35. package/dist/constants/AADServerParamKeys.d.ts +1 -0
  36. package/dist/constants/AADServerParamKeys.d.ts.map +1 -1
  37. package/dist/constants/AADServerParamKeys.mjs +3 -2
  38. package/dist/constants/AADServerParamKeys.mjs.map +1 -1
  39. package/dist/crypto/ICrypto.mjs +1 -1
  40. package/dist/crypto/JoseHeader.mjs +1 -1
  41. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  42. package/dist/error/AuthError.mjs +1 -1
  43. package/dist/error/AuthErrorCodes.mjs +1 -1
  44. package/dist/error/CacheError.mjs +1 -1
  45. package/dist/error/CacheErrorCodes.mjs +1 -1
  46. package/dist/error/ClientAuthError.mjs +1 -1
  47. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  48. package/dist/error/ClientConfigurationError.mjs +1 -1
  49. package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
  50. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  51. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
  52. package/dist/error/JoseHeaderError.mjs +1 -1
  53. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  54. package/dist/error/ServerError.mjs +1 -1
  55. package/dist/index.cjs +105 -34
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.mjs +2 -2
  60. package/dist/logger/Logger.mjs +1 -1
  61. package/dist/network/INetworkModule.mjs +1 -1
  62. package/dist/network/NetworkManager.mjs +1 -1
  63. package/dist/network/ThrottlingUtils.mjs +1 -1
  64. package/dist/packageMetadata.d.ts +1 -1
  65. package/dist/packageMetadata.mjs +2 -2
  66. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  67. package/dist/request/RequestParameterBuilder.mjs +1 -1
  68. package/dist/request/RequestValidator.mjs +1 -1
  69. package/dist/request/ScopeSet.mjs +1 -1
  70. package/dist/response/ResponseHandler.d.ts.map +1 -1
  71. package/dist/response/ResponseHandler.mjs +6 -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.d.ts +12 -0
  77. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  78. package/dist/telemetry/server/ServerTelemetryManager.mjs +61 -2
  79. package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
  80. package/dist/url/UrlString.mjs +1 -1
  81. package/dist/utils/ClientAssertionUtils.mjs +1 -1
  82. package/dist/utils/Constants.mjs +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/account/AccountInfo.ts +37 -17
  90. package/src/cache/CacheManager.ts +2 -12
  91. package/src/cache/entities/AccountEntity.ts +8 -10
  92. package/src/cache/entities/ServerTelemetryEntity.ts +1 -0
  93. package/src/constants/AADServerParamKeys.ts +1 -0
  94. package/src/index.ts +1 -1
  95. package/src/packageMetadata.ts +1 -1
  96. package/src/response/ResponseHandler.ts +7 -6
  97. package/src/telemetry/server/ServerTelemetryManager.ts +95 -1
@@ -10,7 +10,7 @@ import { ClientInfo, buildClientInfo } from "../../account/ClientInfo";
10
10
  import {
11
11
  AccountInfo,
12
12
  TenantProfile,
13
- buildTenantProfileFromIdTokenClaims,
13
+ buildTenantProfile,
14
14
  } from "../../account/AccountInfo";
15
15
  import {
16
16
  createClientAuthError,
@@ -214,15 +214,13 @@ export class AccountEntity {
214
214
  if (accountDetails.tenantProfiles) {
215
215
  account.tenantProfiles = accountDetails.tenantProfiles;
216
216
  } else {
217
- const tenantProfiles = [];
218
- if (accountDetails.idTokenClaims) {
219
- const tenantProfile = buildTenantProfileFromIdTokenClaims(
220
- accountDetails.homeAccountId,
221
- accountDetails.idTokenClaims
222
- );
223
- tenantProfiles.push(tenantProfile);
224
- }
225
- account.tenantProfiles = tenantProfiles;
217
+ const tenantProfile = buildTenantProfile(
218
+ accountDetails.homeAccountId,
219
+ account.localAccountId,
220
+ account.realm,
221
+ accountDetails.idTokenClaims
222
+ );
223
+ account.tenantProfiles = [tenantProfile];
226
224
  }
227
225
 
228
226
  return account;
@@ -7,4 +7,5 @@ export type ServerTelemetryEntity = {
7
7
  failedRequests: Array<string | number>;
8
8
  errors: string[];
9
9
  cacheHits: number;
10
+ nativeBrokerErrorCode?: string;
10
11
  };
@@ -55,3 +55,4 @@ export const LOGOUT_HINT = "logout_hint";
55
55
  export const SID = "sid";
56
56
  export const LOGIN_HINT = "login_hint";
57
57
  export const DOMAIN_HINT = "domain_hint";
58
+ export const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
package/src/index.ts CHANGED
@@ -41,7 +41,7 @@ export {
41
41
  TenantProfile,
42
42
  updateAccountTenantProfileData,
43
43
  tenantIdMatchesHomeTenant,
44
- buildTenantProfileFromIdTokenClaims,
44
+ buildTenantProfile,
45
45
  } from "./account/AccountInfo";
46
46
  export { AuthToken };
47
47
  export {
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-common";
3
- export const version = "14.13.0";
3
+ export const version = "14.14.0";
@@ -48,7 +48,7 @@ import {
48
48
  } from "../account/TokenClaims";
49
49
  import {
50
50
  AccountInfo,
51
- buildTenantProfileFromIdTokenClaims,
51
+ buildTenantProfile,
52
52
  updateAccountTenantProfileData,
53
53
  } from "../account/AccountInfo";
54
54
  import * as CacheHelpers from "../cache/utils/CacheHelpers";
@@ -744,16 +744,17 @@ export function buildAccountToCache(
744
744
  );
745
745
 
746
746
  const tenantProfiles = baseAccount.tenantProfiles || [];
747
-
747
+ const tenantId = claimsTenantId || baseAccount.realm;
748
748
  if (
749
- claimsTenantId &&
750
- idTokenClaims &&
749
+ tenantId &&
751
750
  !tenantProfiles.find((tenantProfile) => {
752
- return tenantProfile.tenantId === claimsTenantId;
751
+ return tenantProfile.tenantId === tenantId;
753
752
  })
754
753
  ) {
755
- const newTenantProfile = buildTenantProfileFromIdTokenClaims(
754
+ const newTenantProfile = buildTenantProfile(
756
755
  homeAccountId,
756
+ baseAccount.localAccountId,
757
+ tenantId,
757
758
  idTokenClaims
758
759
  );
759
760
  tenantProfiles.push(newTenantProfile);
@@ -17,6 +17,69 @@ import { ServerTelemetryRequest } from "./ServerTelemetryRequest";
17
17
  import { ServerTelemetryEntity } from "../../cache/entities/ServerTelemetryEntity";
18
18
  import { RegionDiscoveryMetadata } from "../../authority/RegionDiscoveryMetadata";
19
19
 
20
+ const skuGroupSeparator = ",";
21
+ const skuValueSeparator = "|";
22
+
23
+ type SkuParams = {
24
+ libraryName?: string;
25
+ libraryVersion?: string;
26
+ extensionName?: string;
27
+ extensionVersion?: string;
28
+ skus?: string;
29
+ };
30
+
31
+ function makeExtraSkuString(params: SkuParams): string {
32
+ const {
33
+ skus,
34
+ libraryName,
35
+ libraryVersion,
36
+ extensionName,
37
+ extensionVersion,
38
+ } = params;
39
+ const skuMap: Map<number, (string | undefined)[]> = new Map([
40
+ [0, [libraryName, libraryVersion]],
41
+ [2, [extensionName, extensionVersion]],
42
+ ]);
43
+ let skuArr: string[] = [];
44
+
45
+ if (skus?.length) {
46
+ skuArr = skus.split(skuGroupSeparator);
47
+
48
+ // Ignore invalid input sku param
49
+ if (skuArr.length < 4) {
50
+ return skus;
51
+ }
52
+ } else {
53
+ skuArr = Array.from({ length: 4 }, () => skuValueSeparator);
54
+ }
55
+
56
+ skuMap.forEach((value, key) => {
57
+ if (value.length === 2 && value[0]?.length && value[1]?.length) {
58
+ setSku({
59
+ skuArr,
60
+ index: key,
61
+ skuName: value[0],
62
+ skuVersion: value[1],
63
+ });
64
+ }
65
+ });
66
+
67
+ return skuArr.join(skuGroupSeparator);
68
+ }
69
+
70
+ function setSku(params: {
71
+ skuArr: string[];
72
+ index: number;
73
+ skuName: string;
74
+ skuVersion: string;
75
+ }): void {
76
+ const { skuArr, index, skuName, skuVersion } = params;
77
+ if (index >= skuArr.length) {
78
+ return;
79
+ }
80
+ skuArr[index] = [skuName, skuVersion].join(skuValueSeparator);
81
+ }
82
+
20
83
  /** @internal */
21
84
  export class ServerTelemetryManager {
22
85
  private cacheManager: CacheManager;
@@ -51,7 +114,12 @@ export class ServerTelemetryManager {
51
114
  */
52
115
  generateCurrentRequestHeaderValue(): string {
53
116
  const request = `${this.apiId}${SERVER_TELEM_CONSTANTS.VALUE_SEPARATOR}${this.cacheOutcome}`;
54
- const platformFields = [this.wrapperSKU, this.wrapperVer].join(
117
+ const platformFieldsArr = [this.wrapperSKU, this.wrapperVer];
118
+ const nativeBrokerErrorCode = this.getNativeBrokerErrorCode();
119
+ if (nativeBrokerErrorCode?.length) {
120
+ platformFieldsArr.push(`broker_error=${nativeBrokerErrorCode}`);
121
+ }
122
+ const platformFields = platformFieldsArr.join(
55
123
  SERVER_TELEM_CONSTANTS.VALUE_SEPARATOR
56
124
  );
57
125
  const regionDiscoveryFields = this.getRegionDiscoveryFields();
@@ -277,4 +345,30 @@ export class ServerTelemetryManager {
277
345
  setCacheOutcome(cacheOutcome: CacheOutcome): void {
278
346
  this.cacheOutcome = cacheOutcome;
279
347
  }
348
+
349
+ setNativeBrokerErrorCode(errorCode: string): void {
350
+ const lastRequests = this.getLastRequests();
351
+ lastRequests.nativeBrokerErrorCode = errorCode;
352
+ this.cacheManager.setServerTelemetry(
353
+ this.telemetryCacheKey,
354
+ lastRequests
355
+ );
356
+ }
357
+
358
+ getNativeBrokerErrorCode(): string | undefined {
359
+ return this.getLastRequests().nativeBrokerErrorCode;
360
+ }
361
+
362
+ clearNativeBrokerErrorCode(): void {
363
+ const lastRequests = this.getLastRequests();
364
+ delete lastRequests.nativeBrokerErrorCode;
365
+ this.cacheManager.setServerTelemetry(
366
+ this.telemetryCacheKey,
367
+ lastRequests
368
+ );
369
+ }
370
+
371
+ static makeExtraSkuString(params: SkuParams): string {
372
+ return makeExtraSkuString(params);
373
+ }
280
374
  }