@azure/msal-browser 3.19.0 → 3.20.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 (80) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientNext.mjs +1 -1
  4. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/cache/AccountManager.mjs +1 -1
  7. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  8. package/dist/cache/BrowserCacheManager.mjs +1 -1
  9. package/dist/cache/BrowserStorage.mjs +1 -1
  10. package/dist/cache/DatabaseStorage.mjs +1 -1
  11. package/dist/cache/MemoryStorage.mjs +1 -1
  12. package/dist/cache/TokenCache.mjs +1 -1
  13. package/dist/config/Configuration.mjs +1 -1
  14. package/dist/controllers/ControllerFactory.mjs +1 -1
  15. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  16. package/dist/controllers/StandardController.mjs +1 -1
  17. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  18. package/dist/crypto/BrowserCrypto.mjs +1 -1
  19. package/dist/crypto/CryptoOps.mjs +1 -1
  20. package/dist/crypto/PkceGenerator.mjs +1 -1
  21. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  22. package/dist/encode/Base64Decode.mjs +1 -1
  23. package/dist/encode/Base64Encode.mjs +1 -1
  24. package/dist/error/BrowserAuthError.mjs +1 -1
  25. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  26. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  27. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  28. package/dist/error/NativeAuthError.mjs +1 -1
  29. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  30. package/dist/error/NestedAppAuthError.mjs +1 -1
  31. package/dist/event/EventHandler.mjs +1 -1
  32. package/dist/event/EventMessage.mjs +1 -1
  33. package/dist/event/EventType.mjs +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  36. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  37. package/dist/interaction_client/NativeInteractionClient.d.ts +9 -1
  38. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  39. package/dist/interaction_client/NativeInteractionClient.mjs +83 -43
  40. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  41. package/dist/interaction_client/PopupClient.mjs +1 -1
  42. package/dist/interaction_client/RedirectClient.mjs +1 -1
  43. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  44. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  45. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  46. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  47. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  48. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  49. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  50. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  51. package/dist/naa/BridgeError.mjs +1 -1
  52. package/dist/naa/BridgeProxy.mjs +1 -1
  53. package/dist/naa/BridgeStatusCode.mjs +1 -1
  54. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  55. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +3 -3
  56. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  57. package/dist/navigation/NavigationClient.mjs +1 -1
  58. package/dist/network/FetchClient.mjs +1 -1
  59. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  60. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  61. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  62. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  63. package/dist/packageMetadata.d.ts +1 -1
  64. package/dist/packageMetadata.mjs +2 -2
  65. package/dist/request/RequestHelpers.mjs +1 -1
  66. package/dist/response/ResponseHandler.mjs +1 -1
  67. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  68. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  69. package/dist/utils/BrowserConstants.mjs +1 -1
  70. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  71. package/dist/utils/BrowserUtils.mjs +1 -1
  72. package/lib/msal-browser.cjs +247 -138
  73. package/lib/msal-browser.cjs.map +1 -1
  74. package/lib/msal-browser.js +247 -138
  75. package/lib/msal-browser.js.map +1 -1
  76. package/lib/msal-browser.min.js +64 -64
  77. package/package.json +2 -2
  78. package/src/interaction_client/NativeInteractionClient.ts +105 -54
  79. package/src/naa/mapping/NestedAppAuthAdapter.ts +4 -2
  80. package/src/packageMetadata.ts +1 -1
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
12
12
  },
13
- "version": "3.19.0",
13
+ "version": "3.20.0",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -104,6 +104,6 @@
104
104
  "typescript": "^4.9.5"
105
105
  },
106
106
  "dependencies": {
107
- "@azure/msal-common": "14.13.0"
107
+ "@azure/msal-common": "14.14.0"
108
108
  }
109
109
  }
@@ -36,6 +36,7 @@ import {
36
36
  CacheHelpers,
37
37
  buildAccountToCache,
38
38
  InProgressPerformanceEvent,
39
+ ServerTelemetryManager,
39
40
  } from "@azure/msal-common";
40
41
  import { BaseInteractionClient } from "./BaseInteractionClient";
41
42
  import { BrowserConfiguration } from "../config/Configuration";
@@ -50,6 +51,7 @@ import {
50
51
  ApiId,
51
52
  TemporaryCacheKeys,
52
53
  NativeConstants,
54
+ BrowserConstants,
53
55
  } from "../utils/BrowserConstants";
54
56
  import {
55
57
  NativeExtensionRequestBody,
@@ -72,6 +74,7 @@ import {
72
74
  import { SilentCacheClient } from "./SilentCacheClient";
73
75
  import { AuthenticationResult } from "../response/AuthenticationResult";
74
76
  import { base64Decode } from "../encode/Base64Decode";
77
+ import { version } from "../packageMetadata";
75
78
 
76
79
  const BrokerServerParamKeys = {
77
80
  BROKER_CLIENT_ID: "brk_client_id",
@@ -84,6 +87,8 @@ export class NativeInteractionClient extends BaseInteractionClient {
84
87
  protected nativeMessageHandler: NativeMessageHandler;
85
88
  protected silentCacheClient: SilentCacheClient;
86
89
  protected nativeStorageManager: BrowserCacheManager;
90
+ protected skus: string;
91
+ protected serverTelemetryManager: ServerTelemetryManager;
87
92
 
88
93
  constructor(
89
94
  config: BrowserConfiguration,
@@ -125,6 +130,35 @@ export class NativeInteractionClient extends BaseInteractionClient {
125
130
  provider,
126
131
  correlationId
127
132
  );
133
+ this.serverTelemetryManager = this.initializeServerTelemetryManager(
134
+ this.apiId
135
+ );
136
+
137
+ const extensionName =
138
+ this.nativeMessageHandler.getExtensionId() ===
139
+ NativeConstants.PREFERRED_EXTENSION_ID
140
+ ? "chrome"
141
+ : this.nativeMessageHandler.getExtensionId()?.length
142
+ ? "unknown"
143
+ : undefined;
144
+ this.skus = ServerTelemetryManager.makeExtraSkuString({
145
+ libraryName: BrowserConstants.MSAL_SKU,
146
+ libraryVersion: version,
147
+ extensionName: extensionName,
148
+ extensionVersion: this.nativeMessageHandler.getExtensionVersion(),
149
+ });
150
+ }
151
+
152
+ /**
153
+ * Adds SKUs to request extra query parameters
154
+ * @param request {NativeTokenRequest}
155
+ * @private
156
+ */
157
+ private addRequestSKUs(request: NativeTokenRequest) {
158
+ request.extraParameters = {
159
+ ...request.extraParameters,
160
+ [AADServerParamKeys.X_CLIENT_EXTRA_SKU]: this.skus,
161
+ };
128
162
  }
129
163
 
130
164
  /**
@@ -147,64 +181,73 @@ export class NativeInteractionClient extends BaseInteractionClient {
147
181
  );
148
182
  const reqTimestamp = TimeUtils.nowSeconds();
149
183
 
150
- // initialize native request
151
- const nativeRequest = await this.initializeNativeRequest(request);
152
-
153
- // check if the tokens can be retrieved from internal cache
154
184
  try {
155
- const result = await this.acquireTokensFromCache(
156
- this.accountId,
157
- nativeRequest
158
- );
159
- nativeATMeasurement.end({
160
- success: true,
161
- isNativeBroker: false, // Should be true only when the result is coming directly from the broker
162
- fromCache: true,
163
- });
164
- return result;
165
- } catch (e) {
166
- // continue with a native call for any and all errors
167
- this.logger.info(
168
- "MSAL internal Cache does not contain tokens, proceed to make a native call"
169
- );
170
- }
171
-
172
- const { ...nativeTokenRequest } = nativeRequest;
173
-
174
- // fall back to native calls
175
- const messageBody: NativeExtensionRequestBody = {
176
- method: NativeExtensionMethod.GetToken,
177
- request: nativeTokenRequest,
178
- };
179
-
180
- const response: object = await this.nativeMessageHandler.sendMessage(
181
- messageBody
182
- );
183
- const validatedResponse: NativeResponse =
184
- this.validateNativeResponse(response);
185
+ // initialize native request
186
+ const nativeRequest = await this.initializeNativeRequest(request);
185
187
 
186
- return this.handleNativeResponse(
187
- validatedResponse,
188
- nativeRequest,
189
- reqTimestamp
190
- )
191
- .then((result: AuthenticationResult) => {
188
+ // check if the tokens can be retrieved from internal cache
189
+ try {
190
+ const result = await this.acquireTokensFromCache(
191
+ this.accountId,
192
+ nativeRequest
193
+ );
192
194
  nativeATMeasurement.end({
193
195
  success: true,
194
- isNativeBroker: true,
195
- requestId: result.requestId,
196
+ isNativeBroker: false, // Should be true only when the result is coming directly from the broker
197
+ fromCache: true,
196
198
  });
197
199
  return result;
198
- })
199
- .catch((error: AuthError) => {
200
- nativeATMeasurement.end({
201
- success: false,
202
- errorCode: error.errorCode,
203
- subErrorCode: error.subError,
204
- isNativeBroker: true,
200
+ } catch (e) {
201
+ // continue with a native call for any and all errors
202
+ this.logger.info(
203
+ "MSAL internal Cache does not contain tokens, proceed to make a native call"
204
+ );
205
+ }
206
+
207
+ const { ...nativeTokenRequest } = nativeRequest;
208
+
209
+ // fall back to native calls
210
+ const messageBody: NativeExtensionRequestBody = {
211
+ method: NativeExtensionMethod.GetToken,
212
+ request: nativeTokenRequest,
213
+ };
214
+
215
+ const response: object =
216
+ await this.nativeMessageHandler.sendMessage(messageBody);
217
+ const validatedResponse: NativeResponse =
218
+ this.validateNativeResponse(response);
219
+
220
+ return await this.handleNativeResponse(
221
+ validatedResponse,
222
+ nativeRequest,
223
+ reqTimestamp
224
+ )
225
+ .then((result: AuthenticationResult) => {
226
+ nativeATMeasurement.end({
227
+ success: true,
228
+ isNativeBroker: true,
229
+ requestId: result.requestId,
230
+ });
231
+ this.serverTelemetryManager.clearNativeBrokerErrorCode();
232
+ return result;
233
+ })
234
+ .catch((error: AuthError) => {
235
+ nativeATMeasurement.end({
236
+ success: false,
237
+ errorCode: error.errorCode,
238
+ subErrorCode: error.subError,
239
+ isNativeBroker: true,
240
+ });
241
+ throw error;
205
242
  });
206
- throw error;
207
- });
243
+ } catch (e) {
244
+ if (e instanceof NativeAuthError) {
245
+ this.serverTelemetryManager.setNativeBrokerErrorCode(
246
+ e.errorCode
247
+ );
248
+ }
249
+ throw e;
250
+ }
208
251
  }
209
252
 
210
253
  /**
@@ -307,8 +350,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
307
350
  this.validateNativeResponse(response);
308
351
  } catch (e) {
309
352
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
310
- if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
311
- throw e;
353
+ if (e instanceof NativeAuthError) {
354
+ this.serverTelemetryManager.setNativeBrokerErrorCode(
355
+ e.errorCode
356
+ );
357
+ if (isFatalNativeAuthError(e)) {
358
+ throw e;
359
+ }
312
360
  }
313
361
  }
314
362
  this.browserStorage.setTemporaryCache(
@@ -399,7 +447,9 @@ export class NativeInteractionClient extends BaseInteractionClient {
399
447
  reqTimestamp
400
448
  );
401
449
  this.browserStorage.setInteractionInProgress(false);
402
- return await result;
450
+ const res = await result;
451
+ this.serverTelemetryManager.clearNativeBrokerErrorCode();
452
+ return res;
403
453
  } catch (e) {
404
454
  this.browserStorage.setInteractionInProgress(false);
405
455
  throw e;
@@ -980,6 +1030,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
980
1030
  // SPAs require whole string to be passed to broker
981
1031
  validatedRequest.reqCnf = reqCnfData;
982
1032
  }
1033
+ this.addRequestSKUs(validatedRequest);
983
1034
 
984
1035
  return validatedRequest;
985
1036
  }
@@ -28,7 +28,7 @@ import {
28
28
  IdTokenEntity,
29
29
  AccessTokenEntity,
30
30
  TenantProfile,
31
- buildTenantProfileFromIdTokenClaims,
31
+ buildTenantProfile,
32
32
  } from "@azure/msal-common";
33
33
  import { isBridgeError } from "../BridgeError";
34
34
  import { BridgeStatusCode } from "../BridgeStatusCode";
@@ -192,8 +192,10 @@ export class NestedAppAuthAdapter {
192
192
 
193
193
  const tenantProfiles = new Map<string, TenantProfile>();
194
194
 
195
- const tenantProfile = buildTenantProfileFromIdTokenClaims(
195
+ const tenantProfile = buildTenantProfile(
196
196
  homeAccountId,
197
+ localAccountId,
198
+ tenantId,
197
199
  effectiveIdTokenClaims
198
200
  );
199
201
  tenantProfiles.set(tenantId, tenantProfile);
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.19.0";
3
+ export const version = "3.20.0";