@azure/msal-browser 3.16.0 → 3.18.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 (102) 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/NativeRequest.d.ts +1 -0
  6. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  7. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  8. package/dist/cache/AccountManager.mjs +1 -1
  9. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  10. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  11. package/dist/cache/BrowserCacheManager.mjs +6 -3
  12. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  13. package/dist/cache/BrowserStorage.mjs +1 -1
  14. package/dist/cache/DatabaseStorage.mjs +1 -1
  15. package/dist/cache/MemoryStorage.mjs +1 -1
  16. package/dist/cache/TokenCache.d.ts.map +1 -1
  17. package/dist/cache/TokenCache.mjs +90 -117
  18. package/dist/cache/TokenCache.mjs.map +1 -1
  19. package/dist/config/Configuration.mjs +1 -1
  20. package/dist/controllers/ControllerFactory.mjs +1 -1
  21. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  22. package/dist/controllers/StandardController.d.ts.map +1 -1
  23. package/dist/controllers/StandardController.mjs +4 -3
  24. package/dist/controllers/StandardController.mjs.map +1 -1
  25. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  26. package/dist/crypto/BrowserCrypto.mjs +1 -1
  27. package/dist/crypto/CryptoOps.d.ts +11 -0
  28. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  29. package/dist/crypto/CryptoOps.mjs +16 -1
  30. package/dist/crypto/CryptoOps.mjs.map +1 -1
  31. package/dist/crypto/PkceGenerator.mjs +1 -1
  32. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  33. package/dist/encode/Base64Decode.mjs +1 -1
  34. package/dist/encode/Base64Encode.mjs +1 -1
  35. package/dist/error/BrowserAuthError.d.ts +5 -0
  36. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  37. package/dist/error/BrowserAuthError.mjs +7 -2
  38. package/dist/error/BrowserAuthError.mjs.map +1 -1
  39. package/dist/error/BrowserAuthErrorCodes.d.ts +1 -0
  40. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  41. package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
  42. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  43. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  44. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  45. package/dist/error/NativeAuthError.mjs +1 -1
  46. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  47. package/dist/error/NestedAppAuthError.mjs +2 -2
  48. package/dist/error/NestedAppAuthError.mjs.map +1 -1
  49. package/dist/event/EventHandler.mjs +1 -1
  50. package/dist/event/EventMessage.mjs +1 -1
  51. package/dist/event/EventType.mjs +1 -1
  52. package/dist/index.mjs +1 -1
  53. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  54. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  55. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  56. package/dist/interaction_client/NativeInteractionClient.mjs +36 -15
  57. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  58. package/dist/interaction_client/PopupClient.mjs +1 -1
  59. package/dist/interaction_client/RedirectClient.mjs +1 -1
  60. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  61. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  62. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  63. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  64. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  65. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  66. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  67. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  68. package/dist/naa/BridgeError.mjs +1 -1
  69. package/dist/naa/BridgeProxy.mjs +1 -1
  70. package/dist/naa/BridgeStatusCode.mjs +1 -1
  71. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  72. package/dist/navigation/NavigationClient.mjs +1 -1
  73. package/dist/network/FetchClient.mjs +1 -1
  74. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  75. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  76. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  77. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  78. package/dist/packageMetadata.d.ts +1 -1
  79. package/dist/packageMetadata.mjs +2 -2
  80. package/dist/request/RequestHelpers.mjs +1 -1
  81. package/dist/response/ResponseHandler.mjs +1 -1
  82. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  83. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  84. package/dist/utils/BrowserConstants.mjs +1 -1
  85. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  86. package/dist/utils/BrowserUtils.mjs +1 -1
  87. package/lib/msal-browser.cjs +283 -254
  88. package/lib/msal-browser.cjs.map +1 -1
  89. package/lib/msal-browser.js +283 -254
  90. package/lib/msal-browser.js.map +1 -1
  91. package/lib/msal-browser.min.js +63 -64
  92. package/package.json +3 -2
  93. package/src/broker/nativeBroker/NativeRequest.ts +1 -0
  94. package/src/cache/BrowserCacheManager.ts +4 -5
  95. package/src/cache/TokenCache.ts +158 -243
  96. package/src/controllers/StandardController.ts +6 -5
  97. package/src/crypto/CryptoOps.ts +17 -0
  98. package/src/error/BrowserAuthError.ts +8 -0
  99. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  100. package/src/error/NestedAppAuthError.ts +1 -1
  101. package/src/interaction_client/NativeInteractionClient.ts +52 -23
  102. package/src/packageMetadata.ts +1 -1
@@ -25,7 +25,6 @@ import {
25
25
  AuthError,
26
26
  CommonSilentFlowRequest,
27
27
  AccountInfo,
28
- CacheRecord,
29
28
  AADServerParamKeys,
30
29
  TokenClaims,
31
30
  createClientAuthError,
@@ -170,10 +169,12 @@ export class NativeInteractionClient extends BaseInteractionClient {
170
169
  );
171
170
  }
172
171
 
172
+ const { ...nativeTokenRequest } = nativeRequest;
173
+
173
174
  // fall back to native calls
174
175
  const messageBody: NativeExtensionRequestBody = {
175
176
  method: NativeExtensionMethod.GetToken,
176
- request: nativeRequest,
177
+ request: nativeTokenRequest,
177
178
  };
178
179
 
179
180
  const response: object = await this.nativeMessageHandler.sendMessage(
@@ -289,9 +290,11 @@ export class NativeInteractionClient extends BaseInteractionClient {
289
290
  );
290
291
  const nativeRequest = await this.initializeNativeRequest(request);
291
292
 
293
+ const { ...nativeTokenRequest } = nativeRequest;
294
+
292
295
  const messageBody: NativeExtensionRequestBody = {
293
296
  method: NativeExtensionMethod.GetToken,
294
- request: nativeRequest,
297
+ request: nativeTokenRequest,
295
298
  };
296
299
 
297
300
  try {
@@ -454,8 +457,8 @@ export class NativeInteractionClient extends BaseInteractionClient {
454
457
  this.browserStorage,
455
458
  authority,
456
459
  homeAccountIdentifier,
457
- idTokenClaims,
458
460
  base64Decode,
461
+ idTokenClaims,
459
462
  response.client_info,
460
463
  undefined, // environment
461
464
  idTokenClaims.tid,
@@ -481,7 +484,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
481
484
  request,
482
485
  homeAccountIdentifier,
483
486
  idTokenClaims,
484
- result.accessToken,
487
+ response.access_token,
485
488
  result.tenantId,
486
489
  reqTimestamp
487
490
  );
@@ -535,7 +538,10 @@ export class NativeInteractionClient extends BaseInteractionClient {
535
538
  response: NativeResponse,
536
539
  request: NativeTokenRequest
537
540
  ): Promise<string> {
538
- if (request.tokenType === AuthenticationScheme.POP) {
541
+ if (
542
+ request.tokenType === AuthenticationScheme.POP &&
543
+ request.signPopToken
544
+ ) {
539
545
  /**
540
546
  * This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
541
547
  * is still received, SHR is calculated locally
@@ -725,14 +731,17 @@ export class NativeInteractionClient extends BaseInteractionClient {
725
731
  responseScopes.printScopes(),
726
732
  tokenExpirationSeconds,
727
733
  0,
728
- base64Decode
734
+ base64Decode,
735
+ undefined,
736
+ request.tokenType as AuthenticationScheme,
737
+ undefined,
738
+ request.keyId
729
739
  );
730
740
 
731
- const nativeCacheRecord = new CacheRecord(
732
- undefined,
733
- cachedIdToken,
734
- cachedAccessToken
735
- );
741
+ const nativeCacheRecord = {
742
+ idToken: cachedIdToken,
743
+ accessToken: cachedAccessToken,
744
+ };
736
745
 
737
746
  void this.nativeStorageManager.saveCacheRecord(
738
747
  nativeCacheRecord,
@@ -917,8 +926,16 @@ export class NativeInteractionClient extends BaseInteractionClient {
917
926
  ...request.tokenQueryParameters,
918
927
  },
919
928
  extendedExpiryToken: false, // Make this configurable?
929
+ keyId: request.popKid,
920
930
  };
921
931
 
932
+ // Check for PoP token requests: signPopToken should only be set to true if popKid is not set
933
+ if (validatedRequest.signPopToken && !!request.popKid) {
934
+ throw createBrowserAuthError(
935
+ BrowserAuthErrorCodes.invalidPopTokenRequest
936
+ );
937
+ }
938
+
922
939
  this.handleExtraBrokerParams(validatedRequest);
923
940
  validatedRequest.extraParameters =
924
941
  validatedRequest.extraParameters || {};
@@ -935,17 +952,29 @@ export class NativeInteractionClient extends BaseInteractionClient {
935
952
  };
936
953
 
937
954
  const popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
938
- const reqCnfData = await invokeAsync(
939
- popTokenGenerator.generateCnf.bind(popTokenGenerator),
940
- PerformanceEvents.PopTokenGenerateCnf,
941
- this.logger,
942
- this.performanceClient,
943
- this.correlationId
944
- )(shrParameters, this.logger);
945
-
946
- // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
947
- validatedRequest.reqCnf = reqCnfData.reqCnfHash;
948
- validatedRequest.keyId = reqCnfData.kid;
955
+
956
+ // generate reqCnf if not provided in the request
957
+ let reqCnfData;
958
+ if (!validatedRequest.keyId) {
959
+ const generatedReqCnfData = await invokeAsync(
960
+ popTokenGenerator.generateCnf.bind(popTokenGenerator),
961
+ PerformanceEvents.PopTokenGenerateCnf,
962
+ this.logger,
963
+ this.performanceClient,
964
+ request.correlationId
965
+ )(shrParameters, this.logger);
966
+ reqCnfData = generatedReqCnfData.reqCnfString;
967
+ validatedRequest.keyId = generatedReqCnfData.kid;
968
+ validatedRequest.signPopToken = true;
969
+ } else {
970
+ reqCnfData = this.browserCrypto.base64UrlEncode(
971
+ JSON.stringify({ kid: validatedRequest.keyId })
972
+ );
973
+ validatedRequest.signPopToken = false;
974
+ }
975
+
976
+ // SPAs require whole string to be passed to broker
977
+ validatedRequest.reqCnf = reqCnfData;
949
978
  }
950
979
 
951
980
  return validatedRequest;
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.16.0";
3
+ export const version = "3.18.0";