@azure/msal-browser 5.18.0 → 5.19.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 (307) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  4. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +1 -1
  7. package/dist/cache/AccountManager.mjs +1 -1
  8. package/dist/cache/AsyncMemoryStorage.mjs +9 -12
  9. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +1 -1
  11. package/dist/cache/CacheHelpers.mjs +1 -1
  12. package/dist/cache/CacheKeys.mjs +1 -1
  13. package/dist/cache/CookieStorage.mjs +1 -1
  14. package/dist/cache/DatabaseStorage.mjs +1 -1
  15. package/dist/cache/EncryptedData.mjs +1 -1
  16. package/dist/cache/LocalStorage.mjs +1 -1
  17. package/dist/cache/MemoryStorage.mjs +1 -1
  18. package/dist/cache/SessionStorage.mjs +1 -1
  19. package/dist/cache/TokenCache.mjs +1 -1
  20. package/dist/config/Configuration.mjs +1 -1
  21. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  22. package/dist/controllers/StandardController.mjs +21 -15
  23. package/dist/controllers/StandardController.mjs.map +1 -1
  24. package/dist/crypto/BrowserCrypto.mjs +19 -19
  25. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  26. package/dist/crypto/CryptoOps.mjs +62 -103
  27. package/dist/crypto/CryptoOps.mjs.map +1 -1
  28. package/dist/crypto/PkceGenerator.mjs +1 -1
  29. package/dist/crypto/SignedHttpRequest.mjs +4 -2
  30. package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
  31. package/dist/crypto/TokenBindingKeyManager.mjs +157 -0
  32. package/dist/crypto/TokenBindingKeyManager.mjs.map +1 -0
  33. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  34. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  35. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +2 -2
  36. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  37. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  38. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  39. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  40. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  54. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  55. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  56. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  57. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  58. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  59. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  60. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  61. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  62. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  63. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  64. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  65. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  66. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  67. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  68. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  69. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  70. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +4 -4
  71. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs.map +1 -1
  72. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +4 -3
  73. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs.map +1 -1
  74. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  75. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  76. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  77. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  78. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  79. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  80. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  81. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  82. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  83. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  84. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  85. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  86. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  87. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  88. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  89. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
  90. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  91. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  92. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  93. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  94. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  95. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  96. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  97. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  98. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  99. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  100. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  101. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +2 -1
  102. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs.map +1 -1
  103. package/dist/custom_auth/index.mjs +1 -1
  104. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  105. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  106. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  107. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  108. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  109. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  110. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  111. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  112. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  113. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  114. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  115. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  116. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  117. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  118. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  119. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  120. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  121. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  122. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  123. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  124. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  125. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  126. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  127. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  128. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  129. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  130. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  131. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  132. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  133. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  134. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  135. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  136. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  137. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  138. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  139. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  140. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  141. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  142. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  143. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  144. package/dist/encode/Base64Decode.mjs +1 -1
  145. package/dist/encode/Base64Encode.mjs +1 -1
  146. package/dist/error/BrowserAuthError.mjs +1 -1
  147. package/dist/error/BrowserAuthErrorCodes.mjs +5 -2
  148. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  149. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  150. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  151. package/dist/error/NativeAuthError.mjs +1 -1
  152. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  153. package/dist/error/NestedAppAuthError.mjs +1 -1
  154. package/dist/event/EventHandler.mjs +1 -1
  155. package/dist/event/EventMessage.mjs +1 -1
  156. package/dist/event/EventType.mjs +1 -1
  157. package/dist/index.mjs +1 -1
  158. package/dist/interaction_client/BaseInteractionClient.mjs +6 -2
  159. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  160. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  161. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +6 -6
  162. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  163. package/dist/interaction_client/PopupClient.mjs +3 -3
  164. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  165. package/dist/interaction_client/RedirectClient.mjs +3 -3
  166. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  167. package/dist/interaction_client/SilentAuthCodeClient.mjs +3 -3
  168. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  169. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  170. package/dist/interaction_client/SilentIframeClient.mjs +3 -3
  171. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  172. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  173. package/dist/interaction_client/StandardInteractionClient.mjs +2 -1
  174. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  175. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  176. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  177. package/dist/log-strings-mapping.json +243 -247
  178. package/dist/naa/BridgeError.mjs +1 -1
  179. package/dist/naa/BridgeProxy.mjs +27 -32
  180. package/dist/naa/BridgeProxy.mjs.map +1 -1
  181. package/dist/naa/BridgeStatusCode.mjs +1 -1
  182. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +52 -25
  183. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  184. package/dist/navigation/NavigationClient.mjs +1 -1
  185. package/dist/network/FetchClient.mjs +1 -1
  186. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  187. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  188. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  189. package/dist/packageMetadata.mjs +2 -2
  190. package/dist/popup_relay/constants.mjs +1 -1
  191. package/dist/popup_relay/index.mjs +1 -1
  192. package/dist/popup_relay/relayClient.mjs +1 -1
  193. package/dist/protocol/Authorize.mjs +5 -3
  194. package/dist/protocol/Authorize.mjs.map +1 -1
  195. package/dist/redirect_bridge/index.mjs +1 -1
  196. package/dist/request/RequestHelpers.mjs +11 -3
  197. package/dist/request/RequestHelpers.mjs.map +1 -1
  198. package/dist/response/ResponseHandler.mjs +1 -1
  199. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  200. package/dist/telemetry/BrowserPerformanceEvents.mjs +5 -5
  201. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  202. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  203. package/dist/utils/BrowserConstants.mjs +1 -1
  204. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  205. package/dist/utils/BrowserUtils.mjs +1 -1
  206. package/dist/utils/Helpers.mjs +1 -1
  207. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  208. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +64 -0
  209. package/dist/webBrokerBridge/PendingRequestRegistry.mjs.map +1 -0
  210. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +39 -0
  211. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs.map +1 -0
  212. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +58 -0
  213. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs.map +1 -0
  214. package/lib/custom-auth-path/log-strings-mapping.json +39 -43
  215. package/lib/custom-auth-path/msal-custom-auth.cjs +4390 -4069
  216. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  217. package/lib/custom-auth-path/msal-custom-auth.js +4390 -4069
  218. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  219. package/lib/log-strings-mapping.json +11 -15
  220. package/lib/msal-browser.cjs +827 -392
  221. package/lib/msal-browser.cjs.map +1 -1
  222. package/lib/msal-browser.js +827 -392
  223. package/lib/msal-browser.js.map +1 -1
  224. package/lib/msal-browser.min.js +2 -2
  225. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  226. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  227. package/lib/popup-relay/msal-popup-relay.js +2 -2
  228. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  229. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  230. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  231. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  232. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  233. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  234. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  235. package/package.json +2 -2
  236. package/src/cache/AsyncMemoryStorage.ts +7 -13
  237. package/src/controllers/StandardController.ts +38 -13
  238. package/src/crypto/BrowserCrypto.ts +10 -8
  239. package/src/crypto/CryptoOps.ts +138 -178
  240. package/src/crypto/SignedHttpRequest.ts +3 -0
  241. package/src/crypto/TokenBindingKeyManager.ts +299 -0
  242. package/src/custom_auth/controller/CustomAuthStandardController.ts +2 -1
  243. package/src/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.ts +8 -3
  244. package/src/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.ts +7 -3
  245. package/src/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.ts +1 -0
  246. package/src/error/BrowserAuthErrorCodes.ts +6 -0
  247. package/src/interaction_client/BaseInteractionClient.ts +8 -1
  248. package/src/interaction_client/PlatformAuthInteractionClient.ts +9 -3
  249. package/src/interaction_client/PopupClient.ts +5 -2
  250. package/src/interaction_client/RedirectClient.ts +5 -2
  251. package/src/interaction_client/SilentAuthCodeClient.ts +5 -2
  252. package/src/interaction_client/SilentIframeClient.ts +5 -2
  253. package/src/interaction_client/StandardInteractionClient.ts +1 -0
  254. package/src/naa/BridgeProxy.ts +38 -44
  255. package/src/naa/mapping/NestedAppAuthAdapter.ts +57 -55
  256. package/src/packageMetadata.ts +1 -1
  257. package/src/protocol/Authorize.ts +8 -1
  258. package/src/request/RequestHelpers.ts +19 -2
  259. package/src/telemetry/BrowserPerformanceEvents.ts +4 -4
  260. package/src/webBrokerBridge/PendingRequestRegistry.ts +2 -5
  261. package/types/cache/AsyncMemoryStorage.d.ts +1 -2
  262. package/types/cache/AsyncMemoryStorage.d.ts.map +1 -1
  263. package/types/controllers/StandardController.d.ts +2 -1
  264. package/types/controllers/StandardController.d.ts.map +1 -1
  265. package/types/crypto/BrowserCrypto.d.ts +2 -2
  266. package/types/crypto/BrowserCrypto.d.ts.map +1 -1
  267. package/types/crypto/CryptoOps.d.ts +7 -21
  268. package/types/crypto/CryptoOps.d.ts.map +1 -1
  269. package/types/crypto/SignedHttpRequest.d.ts.map +1 -1
  270. package/types/crypto/TokenBindingKeyManager.d.ts +83 -0
  271. package/types/crypto/TokenBindingKeyManager.d.ts.map +1 -0
  272. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  273. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  274. package/types/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.d.ts +2 -2
  275. package/types/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.d.ts.map +1 -1
  276. package/types/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.d.ts +4 -3
  277. package/types/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.d.ts.map +1 -1
  278. package/types/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.d.ts.map +1 -1
  279. package/types/error/BrowserAuthErrorCodes.d.ts +3 -0
  280. package/types/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  281. package/types/index.d.ts +1 -0
  282. package/types/index.d.ts.map +1 -1
  283. package/types/interaction_client/BaseInteractionClient.d.ts +3 -2
  284. package/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  285. package/types/interaction_client/PlatformAuthInteractionClient.d.ts +2 -2
  286. package/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  287. package/types/interaction_client/PopupClient.d.ts +2 -2
  288. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  289. package/types/interaction_client/RedirectClient.d.ts +2 -2
  290. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  291. package/types/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  292. package/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  293. package/types/interaction_client/SilentIframeClient.d.ts +2 -2
  294. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  295. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  296. package/types/naa/BridgeProxy.d.ts +14 -2
  297. package/types/naa/BridgeProxy.d.ts.map +1 -1
  298. package/types/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  299. package/types/packageMetadata.d.ts +1 -1
  300. package/types/protocol/Authorize.d.ts.map +1 -1
  301. package/types/request/RequestHelpers.d.ts.map +1 -1
  302. package/types/telemetry/BrowserPerformanceEvents.d.ts +4 -4
  303. package/types/webBrokerBridge/PendingRequestRegistry.d.ts +2 -2
  304. package/types/webBrokerBridge/PendingRequestRegistry.d.ts.map +1 -1
  305. package/src/naa/BridgeRequest.ts +0 -16
  306. package/types/naa/BridgeRequest.d.ts +0 -8
  307. package/types/naa/BridgeRequest.d.ts.map +0 -1
@@ -4,15 +4,11 @@
4
4
  */
5
5
 
6
6
  import {
7
- ClientAuthErrorCodes,
8
- createClientAuthError,
9
7
  ICrypto,
10
8
  IPerformanceClient,
9
+ JsonWebTokenAlgorithms,
11
10
  JoseHeader,
12
11
  Logger,
13
- ShrOptions,
14
- SignedHttpRequest,
15
- SignedHttpRequestParameters,
16
12
  } from "@azure/msal-common/browser";
17
13
  import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
18
14
  import {
@@ -23,17 +19,14 @@ import {
23
19
  import { base64Decode } from "../encode/Base64Decode.js";
24
20
  import * as BrowserCrypto from "./BrowserCrypto.js";
25
21
  import {
26
- createBrowserAuthError,
22
+ CachedKeyPair,
23
+ TokenBindingKeyTelemetry,
24
+ TokenBindingKeyManager,
25
+ } from "./TokenBindingKeyManager.js";
26
+ import {
27
27
  BrowserAuthErrorCodes,
28
+ createBrowserAuthError,
28
29
  } from "../error/BrowserAuthError.js";
29
- import { AsyncMemoryStorage } from "../cache/AsyncMemoryStorage.js";
30
-
31
- export type CachedKeyPair = {
32
- publicKey: CryptoKey;
33
- privateKey: CryptoKey;
34
- requestMethod?: string;
35
- requestUri?: string;
36
- };
37
30
 
38
31
  /**
39
32
  * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
@@ -47,10 +40,7 @@ export class CryptoOps implements ICrypto {
47
40
  * meaning there won't be a performance manager available.
48
41
  */
49
42
  private performanceClient: IPerformanceClient | undefined;
50
-
51
- private static POP_KEY_USAGES: Array<KeyUsage> = ["sign", "verify"];
52
- private static EXTRACTABLE: boolean = true;
53
- private cache: AsyncMemoryStorage<CachedKeyPair>;
43
+ private tokenBindingKeyManager: TokenBindingKeyManager;
54
44
 
55
45
  constructor(
56
46
  logger: Logger,
@@ -62,8 +52,11 @@ export class CryptoOps implements ICrypto {
62
52
  BrowserCrypto.validateCryptoAvailable(
63
53
  skipValidateSubtleCrypto ?? false
64
54
  );
65
- this.cache = new AsyncMemoryStorage<CachedKeyPair>(this.logger);
66
55
  this.performanceClient = performanceClient;
56
+ this.tokenBindingKeyManager = new TokenBindingKeyManager(
57
+ this.logger,
58
+ this.performanceClient
59
+ );
67
60
  }
68
61
 
69
62
  /**
@@ -107,69 +100,6 @@ export class CryptoOps implements ICrypto {
107
100
  return this.base64UrlEncode(JSON.stringify({ kid: inputKid }));
108
101
  }
109
102
 
110
- /**
111
- * Generates a keypair, stores it and returns a thumbprint
112
- * @param request
113
- */
114
- async getPublicKeyThumbprint(
115
- request: SignedHttpRequestParameters
116
- ): Promise<string> {
117
- const publicKeyThumbMeasurement =
118
- this.performanceClient?.startMeasurement(
119
- BrowserPerformanceEvents.CryptoOptsGetPublicKeyThumbprint,
120
- request.correlationId
121
- );
122
-
123
- // Generate Keypair
124
- const keyPair: CryptoKeyPair = await BrowserCrypto.generateKeyPair(
125
- CryptoOps.EXTRACTABLE,
126
- CryptoOps.POP_KEY_USAGES,
127
- BrowserCrypto.RSA_KEYGEN_ALGORITHM_OPTIONS
128
- );
129
-
130
- // Generate Thumbprint for Public Key
131
- const publicKeyJwk: JsonWebKey = await BrowserCrypto.exportJwk(
132
- keyPair.publicKey
133
- );
134
-
135
- const publicJwkHash = await BrowserCrypto.computeJwkThumbprint(
136
- publicKeyJwk
137
- );
138
-
139
- // Generate Thumbprint for Private Key
140
- const privateKeyJwk: JsonWebKey = await BrowserCrypto.exportJwk(
141
- keyPair.privateKey
142
- );
143
- // Re-import private key to make it unextractable
144
- const unextractablePrivateKey: CryptoKey =
145
- await BrowserCrypto.importJwk(
146
- privateKeyJwk,
147
- false,
148
- ["sign"],
149
- BrowserCrypto.RSA_KEYGEN_ALGORITHM_OPTIONS
150
- );
151
-
152
- // Store Keypair data in keystore
153
- await this.cache.setItem(
154
- publicJwkHash,
155
- {
156
- privateKey: unextractablePrivateKey,
157
- publicKey: keyPair.publicKey,
158
- requestMethod: request.resourceRequestMethod,
159
- requestUri: request.resourceRequestUri,
160
- },
161
- request.correlationId
162
- );
163
-
164
- if (publicKeyThumbMeasurement) {
165
- publicKeyThumbMeasurement.end({
166
- success: true,
167
- });
168
- }
169
-
170
- return publicJwkHash;
171
- }
172
-
173
103
  /**
174
104
  * Removes cryptographic keypair from key store matching the keyId passed in
175
105
  * @param kid
@@ -179,14 +109,10 @@ export class CryptoOps implements ICrypto {
179
109
  kid: string,
180
110
  correlationId: string
181
111
  ): Promise<void> {
182
- await this.cache.removeItem(kid, correlationId);
183
- const keyFound = await this.cache.containsKey(kid, correlationId);
184
- if (keyFound) {
185
- throw createClientAuthError(
186
- ClientAuthErrorCodes.bindingKeyNotRemoved,
187
- correlationId
188
- );
189
- }
112
+ await this.tokenBindingKeyManager.removeTokenBindingKey(
113
+ kid,
114
+ correlationId
115
+ );
190
116
  }
191
117
 
192
118
  /**
@@ -194,115 +120,149 @@ export class CryptoOps implements ICrypto {
194
120
  * @param correlationId
195
121
  */
196
122
  async clearKeystore(correlationId: string): Promise<boolean> {
197
- // Delete in-memory keystores
198
- this.cache.clearInMemory(correlationId);
123
+ return this.tokenBindingKeyManager.clearKeystore(correlationId);
124
+ }
199
125
 
200
- /**
201
- * There is only one database, so calling clearPersistent on asymmetric keystore takes care of
202
- * every persistent keystore
203
- */
126
+ /** @internal */
127
+ async signTokenBindingJwt(
128
+ header: JoseHeader,
129
+ payload: object,
130
+ kid: string,
131
+ correlationId: string
132
+ ): Promise<string> {
133
+ let telemetry: TokenBindingKeyTelemetry = {};
134
+ const signTokenBindingJwtMeasurement =
135
+ this.performanceClient?.startMeasurement(
136
+ BrowserPerformanceEvents.CryptoOptsSignJwt,
137
+ correlationId
138
+ );
204
139
  try {
205
- await this.cache.clearPersistent(correlationId);
206
- return true;
207
- } catch (e) {
208
- if (e instanceof Error) {
209
- this.logger.error(
210
- `Clearing keystore failed with error: '${e.message}'`,
211
- correlationId
212
- );
213
- } else {
214
- this.logger.error(
215
- "Clearing keystore failed with unknown error",
140
+ const cachedKeyPair =
141
+ await this.tokenBindingKeyManager.getTokenBindingKeyPair(
142
+ kid,
216
143
  correlationId
217
144
  );
218
- }
145
+ await this.validateTokenBindingJwtHeaderKey(
146
+ header,
147
+ kid,
148
+ correlationId
149
+ );
150
+ telemetry = this.tokenBindingKeyManager.getTokenBindingKeyTelemetry(
151
+ cachedKeyPair,
152
+ header.alg
153
+ );
219
154
 
220
- return false;
155
+ const signingAlgorithm = this.getTokenBindingKeySigningAlgorithm(
156
+ cachedKeyPair,
157
+ header.alg,
158
+ correlationId
159
+ );
160
+
161
+ const tokenString = `${urlEncode(
162
+ JSON.stringify(header)
163
+ )}.${urlEncode(JSON.stringify(payload))}`;
164
+ const encodedSignature = await this.signInput(
165
+ cachedKeyPair,
166
+ tokenString,
167
+ signingAlgorithm
168
+ );
169
+
170
+ signTokenBindingJwtMeasurement?.end({
171
+ success: true,
172
+ ...telemetry,
173
+ });
174
+ return `${tokenString}.${encodedSignature}`;
175
+ } catch (e) {
176
+ signTokenBindingJwtMeasurement?.end({
177
+ success: false,
178
+ ...telemetry,
179
+ });
180
+ throw e;
221
181
  }
222
182
  }
223
183
 
224
184
  /**
225
- * Signs the given object as a jwt payload with private key retrieved by given kid.
226
- * @param payload
227
- * @param kid
185
+ * Returns the SHA-256 hash of an input string
186
+ * @param plainText
228
187
  */
229
- async signJwt(
230
- payload: SignedHttpRequest,
231
- kid: string,
232
- shrOptions?: ShrOptions,
233
- correlationId?: string
188
+ async hashString(plainText: string): Promise<string> {
189
+ return BrowserCrypto.hashString(plainText);
190
+ }
191
+
192
+ private async signInput(
193
+ cachedKeyPair: CachedKeyPair,
194
+ signingInput: string,
195
+ algorithm: AlgorithmIdentifier
234
196
  ): Promise<string> {
235
- const signJwtMeasurement = this.performanceClient?.startMeasurement(
236
- BrowserPerformanceEvents.CryptoOptsSignJwt,
237
- correlationId
238
- );
239
- const cachedKeyPair = await this.cache.getItem(
240
- kid,
241
- correlationId || ""
197
+ const encoder = new TextEncoder();
198
+ const signatureBuffer = await BrowserCrypto.sign(
199
+ cachedKeyPair.privateKey,
200
+ encoder.encode(signingInput),
201
+ algorithm
242
202
  );
243
203
 
244
- if (!cachedKeyPair) {
204
+ return urlEncodeArr(new Uint8Array(signatureBuffer));
205
+ }
206
+
207
+ private getTokenBindingKeySigningAlgorithm(
208
+ cachedKeyPair: CachedKeyPair,
209
+ requestedAlgorithm: string,
210
+ correlationId: string
211
+ ): AlgorithmIdentifier {
212
+ const keyAlgorithm = cachedKeyPair.privateKey.algorithm;
213
+ if (
214
+ requestedAlgorithm === JsonWebTokenAlgorithms.RS256 &&
215
+ keyAlgorithm.name === BrowserCrypto.RSA_SIGN_ALGORITHM_OPTIONS.name
216
+ ) {
217
+ return BrowserCrypto.RSA_SIGN_ALGORITHM_OPTIONS;
218
+ }
219
+
220
+ if (
221
+ requestedAlgorithm === JsonWebTokenAlgorithms.ES256 &&
222
+ keyAlgorithm.name ===
223
+ BrowserCrypto.ECDSA_SHA256_SIGN_ALGORITHM_OPTIONS.name &&
224
+ (keyAlgorithm as EcKeyAlgorithm).namedCurve ===
225
+ BrowserCrypto.ECDSA_P256_KEYGEN_ALGORITHM_OPTIONS.namedCurve
226
+ ) {
227
+ return BrowserCrypto.ECDSA_SHA256_SIGN_ALGORITHM_OPTIONS;
228
+ }
229
+
230
+ if (
231
+ requestedAlgorithm === JsonWebTokenAlgorithms.RS256 ||
232
+ requestedAlgorithm === JsonWebTokenAlgorithms.ES256
233
+ ) {
245
234
  throw createBrowserAuthError(
246
- BrowserAuthErrorCodes.cryptoKeyNotFound,
247
- correlationId || ""
235
+ BrowserAuthErrorCodes.unsupportedTokenBindingAlgorithm,
236
+ correlationId,
237
+ BrowserAuthErrorCodes.tokenBindingKeyAlgorithmMismatch
248
238
  );
249
239
  }
250
240
 
251
- // Get public key as JWK
252
- const publicKeyJwk = await BrowserCrypto.exportJwk(
253
- cachedKeyPair.publicKey
241
+ throw createBrowserAuthError(
242
+ BrowserAuthErrorCodes.unsupportedTokenBindingAlgorithm,
243
+ correlationId
254
244
  );
255
- const publicKeyJwkString = getSortedObjectString(publicKeyJwk);
256
- // Base64URL encode public key thumbprint with keyId only: BASE64URL({ kid: "FULL_PUBLIC_KEY_HASH" })
257
- const encodedKeyIdThumbprint = urlEncode(JSON.stringify({ kid: kid }));
258
- // Generate header
259
- const shrHeader = JoseHeader.getShrHeaderString({
260
- ...shrOptions?.header,
261
- alg: publicKeyJwk.alg,
262
- kid: encodedKeyIdThumbprint,
263
- });
264
-
265
- const encodedShrHeader = urlEncode(shrHeader);
266
-
267
- // Generate payload
268
- payload.cnf = {
269
- jwk: JSON.parse(publicKeyJwkString),
270
- };
271
- const encodedPayload = urlEncode(JSON.stringify(payload));
245
+ }
272
246
 
273
- // Form token string
274
- const tokenString = `${encodedShrHeader}.${encodedPayload}`;
247
+ private async validateTokenBindingJwtHeaderKey(
248
+ header: JoseHeader,
249
+ kid: string,
250
+ correlationId: string
251
+ ): Promise<void> {
252
+ if (!header.jwk) {
253
+ return;
254
+ }
275
255
 
276
- // Sign token
277
- const encoder = new TextEncoder();
278
- const tokenBuffer = encoder.encode(tokenString);
279
- const signatureBuffer = await BrowserCrypto.sign(
280
- cachedKeyPair.privateKey,
281
- tokenBuffer,
282
- BrowserCrypto.RSA_SIGN_ALGORITHM_OPTIONS
256
+ const headerKeyId = await BrowserCrypto.computeJwkThumbprint(
257
+ header.jwk,
258
+ correlationId
283
259
  );
284
- const encodedSignature = urlEncodeArr(new Uint8Array(signatureBuffer));
285
-
286
- const signedJwt = `${tokenString}.${encodedSignature}`;
287
-
288
- if (signJwtMeasurement) {
289
- signJwtMeasurement.end({
290
- success: true,
291
- });
260
+ if (headerKeyId !== kid) {
261
+ throw createBrowserAuthError(
262
+ BrowserAuthErrorCodes.invalidPublicJwk,
263
+ correlationId,
264
+ BrowserAuthErrorCodes.tokenBindingKeyJwkThumbprintMismatch
265
+ );
292
266
  }
293
-
294
- return signedJwt;
295
267
  }
296
-
297
- /**
298
- * Returns the SHA-256 hash of an input string
299
- * @param plainText
300
- */
301
- async hashString(plainText: string): Promise<string> {
302
- return BrowserCrypto.hashString(plainText);
303
- }
304
- }
305
-
306
- function getSortedObjectString(obj: object): string {
307
- return JSON.stringify(obj, Object.keys(obj).sort());
308
268
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { CryptoOps } from "./CryptoOps.js";
7
+ import { TokenBindingKeyManager } from "./TokenBindingKeyManager.js";
7
8
  import {
8
9
  Logger,
9
10
  LoggerOptions,
@@ -30,8 +31,10 @@ export class SignedHttpRequest {
30
31
  const loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
31
32
  this.logger = new Logger(loggerOptions, name, version);
32
33
  this.cryptoOps = new CryptoOps(this.logger);
34
+ const tokenBindingKeyManager = new TokenBindingKeyManager(this.logger);
33
35
  this.popTokenGenerator = new PopTokenGenerator(
34
36
  this.cryptoOps,
37
+ tokenBindingKeyManager,
35
38
  new StubPerformanceClient()
36
39
  );
37
40
  this.shrParameters = shrParameters;