@azure/msal-browser 5.17.3 → 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 (329) 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 +15 -7
  11. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  12. package/dist/cache/CacheHelpers.mjs +1 -1
  13. package/dist/cache/CacheKeys.mjs +1 -1
  14. package/dist/cache/CookieStorage.mjs +1 -1
  15. package/dist/cache/DatabaseStorage.mjs +1 -1
  16. package/dist/cache/EncryptedData.mjs +1 -1
  17. package/dist/cache/LocalStorage.mjs +1 -1
  18. package/dist/cache/MemoryStorage.mjs +1 -1
  19. package/dist/cache/SessionStorage.mjs +1 -1
  20. package/dist/cache/TokenCache.mjs +1 -1
  21. package/dist/config/Configuration.mjs +1 -1
  22. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  23. package/dist/controllers/StandardController.mjs +34 -17
  24. package/dist/controllers/StandardController.mjs.map +1 -1
  25. package/dist/crypto/BrowserCrypto.mjs +19 -19
  26. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  27. package/dist/crypto/CryptoOps.mjs +62 -103
  28. package/dist/crypto/CryptoOps.mjs.map +1 -1
  29. package/dist/crypto/PkceGenerator.mjs +1 -1
  30. package/dist/crypto/SignedHttpRequest.mjs +4 -2
  31. package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
  32. package/dist/crypto/TokenBindingKeyManager.mjs +157 -0
  33. package/dist/crypto/TokenBindingKeyManager.mjs.map +1 -0
  34. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  35. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  36. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +2 -2
  37. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  38. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  39. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  40. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  55. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  56. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  57. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  58. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  59. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  60. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  61. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  62. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  63. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  64. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  65. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  66. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  67. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  68. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  69. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  70. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  71. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +4 -4
  72. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs.map +1 -1
  73. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +4 -3
  74. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs.map +1 -1
  75. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  76. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  77. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  78. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  79. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  80. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  81. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  82. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  83. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  84. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  85. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  86. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  87. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  88. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  89. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  90. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
  91. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  92. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  93. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  94. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  95. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  96. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  97. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  98. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  99. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  100. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  101. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  102. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +2 -1
  103. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs.map +1 -1
  104. package/dist/custom_auth/index.mjs +1 -1
  105. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  106. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  107. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  108. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  109. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  110. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  111. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  112. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  113. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  114. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  115. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  116. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  117. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  118. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  119. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  120. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  121. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  122. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  123. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  124. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  125. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  126. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  127. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  128. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  129. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  130. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  131. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  132. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  133. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  134. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  135. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  136. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  137. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  138. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  139. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  140. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  141. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  142. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  143. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  144. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  145. package/dist/encode/Base64Decode.mjs +1 -1
  146. package/dist/encode/Base64Encode.mjs +1 -1
  147. package/dist/error/BrowserAuthError.mjs +1 -1
  148. package/dist/error/BrowserAuthErrorCodes.mjs +5 -2
  149. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  150. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  151. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  152. package/dist/error/NativeAuthError.mjs +1 -1
  153. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  154. package/dist/error/NestedAppAuthError.mjs +1 -1
  155. package/dist/event/EventHandler.mjs +1 -1
  156. package/dist/event/EventMessage.mjs +1 -1
  157. package/dist/event/EventType.mjs +1 -1
  158. package/dist/index.mjs +1 -1
  159. package/dist/interaction_client/BaseInteractionClient.mjs +6 -2
  160. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  161. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  162. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +30 -9
  163. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  164. package/dist/interaction_client/PopupClient.mjs +3 -3
  165. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  166. package/dist/interaction_client/RedirectClient.mjs +3 -3
  167. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  168. package/dist/interaction_client/SilentAuthCodeClient.mjs +3 -3
  169. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  170. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  171. package/dist/interaction_client/SilentIframeClient.mjs +3 -3
  172. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  173. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  174. package/dist/interaction_client/StandardInteractionClient.mjs +2 -1
  175. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  176. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  177. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  178. package/dist/log-strings-mapping.json +1196 -1200
  179. package/dist/naa/BridgeError.mjs +1 -1
  180. package/dist/naa/BridgeProxy.mjs +27 -32
  181. package/dist/naa/BridgeProxy.mjs.map +1 -1
  182. package/dist/naa/BridgeStatusCode.mjs +1 -1
  183. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +54 -25
  184. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  185. package/dist/navigation/NavigationClient.mjs +1 -1
  186. package/dist/network/FetchClient.mjs +1 -1
  187. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  188. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  189. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  190. package/dist/packageMetadata.mjs +2 -2
  191. package/dist/popup_relay/constants.mjs +1 -1
  192. package/dist/popup_relay/index.mjs +1 -1
  193. package/dist/popup_relay/relayClient.mjs +1 -1
  194. package/dist/protocol/Authorize.mjs +5 -3
  195. package/dist/protocol/Authorize.mjs.map +1 -1
  196. package/dist/redirect_bridge/index.mjs +1 -1
  197. package/dist/request/RequestHelpers.mjs +11 -3
  198. package/dist/request/RequestHelpers.mjs.map +1 -1
  199. package/dist/response/ResponseHandler.mjs +1 -1
  200. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  201. package/dist/telemetry/BrowserPerformanceEvents.mjs +5 -5
  202. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  203. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  204. package/dist/utils/BrowserConstants.mjs +1 -1
  205. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  206. package/dist/utils/BrowserUtils.mjs +1 -1
  207. package/dist/utils/Helpers.mjs +1 -1
  208. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  209. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +64 -0
  210. package/dist/webBrokerBridge/PendingRequestRegistry.mjs.map +1 -0
  211. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +39 -0
  212. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs.map +1 -0
  213. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +58 -0
  214. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs.map +1 -0
  215. package/lib/custom-auth-path/log-strings-mapping.json +39 -43
  216. package/lib/custom-auth-path/msal-custom-auth.cjs +4542 -4060
  217. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  218. package/lib/custom-auth-path/msal-custom-auth.js +4542 -4060
  219. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  220. package/lib/log-strings-mapping.json +11 -15
  221. package/lib/msal-browser.cjs +1030 -432
  222. package/lib/msal-browser.cjs.map +1 -1
  223. package/lib/msal-browser.js +1030 -432
  224. package/lib/msal-browser.js.map +1 -1
  225. package/lib/msal-browser.min.js +2 -2
  226. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  227. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  228. package/lib/popup-relay/msal-popup-relay.js +2 -2
  229. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  230. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  231. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  232. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  233. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  234. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  235. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  236. package/package.json +2 -2
  237. package/src/broker/nativeBroker/PlatformAuthRequest.ts +2 -1
  238. package/src/cache/AsyncMemoryStorage.ts +7 -13
  239. package/src/cache/BrowserCacheManager.ts +24 -6
  240. package/src/controllers/StandardController.ts +58 -15
  241. package/src/crypto/BrowserCrypto.ts +10 -8
  242. package/src/crypto/CryptoOps.ts +138 -178
  243. package/src/crypto/SignedHttpRequest.ts +3 -0
  244. package/src/crypto/TokenBindingKeyManager.ts +299 -0
  245. package/src/custom_auth/controller/CustomAuthStandardController.ts +2 -1
  246. package/src/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.ts +8 -3
  247. package/src/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.ts +7 -3
  248. package/src/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.ts +1 -0
  249. package/src/error/BrowserAuthErrorCodes.ts +6 -0
  250. package/src/interaction_client/BaseInteractionClient.ts +8 -1
  251. package/src/interaction_client/PlatformAuthInteractionClient.ts +44 -6
  252. package/src/interaction_client/PopupClient.ts +5 -2
  253. package/src/interaction_client/RedirectClient.ts +5 -2
  254. package/src/interaction_client/SilentAuthCodeClient.ts +5 -2
  255. package/src/interaction_client/SilentIframeClient.ts +5 -2
  256. package/src/interaction_client/StandardInteractionClient.ts +1 -0
  257. package/src/naa/BridgeProxy.ts +38 -44
  258. package/src/naa/TokenRequest.ts +1 -0
  259. package/src/naa/mapping/NestedAppAuthAdapter.ts +62 -55
  260. package/src/packageMetadata.ts +1 -1
  261. package/src/protocol/Authorize.ts +8 -1
  262. package/src/request/RequestHelpers.ts +19 -2
  263. package/src/telemetry/BrowserPerformanceEvents.ts +4 -4
  264. package/src/webBrokerBridge/IWebBrokerBridgeMessage.ts +42 -0
  265. package/src/webBrokerBridge/PendingRequestRegistry.ts +76 -0
  266. package/src/webBrokerBridge/WebBrokerBridgeError.ts +69 -0
  267. package/src/webBrokerBridge/WebBrokerBridgeErrorMap.ts +108 -0
  268. package/src/webBrokerBridge/index.ts +25 -0
  269. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts +1 -0
  270. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -1
  271. package/types/cache/AsyncMemoryStorage.d.ts +1 -2
  272. package/types/cache/AsyncMemoryStorage.d.ts.map +1 -1
  273. package/types/cache/BrowserCacheManager.d.ts +7 -5
  274. package/types/cache/BrowserCacheManager.d.ts.map +1 -1
  275. package/types/controllers/StandardController.d.ts +2 -1
  276. package/types/controllers/StandardController.d.ts.map +1 -1
  277. package/types/crypto/BrowserCrypto.d.ts +2 -2
  278. package/types/crypto/BrowserCrypto.d.ts.map +1 -1
  279. package/types/crypto/CryptoOps.d.ts +7 -21
  280. package/types/crypto/CryptoOps.d.ts.map +1 -1
  281. package/types/crypto/SignedHttpRequest.d.ts.map +1 -1
  282. package/types/crypto/TokenBindingKeyManager.d.ts +83 -0
  283. package/types/crypto/TokenBindingKeyManager.d.ts.map +1 -0
  284. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  285. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  286. package/types/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.d.ts +2 -2
  287. package/types/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.d.ts.map +1 -1
  288. package/types/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.d.ts +4 -3
  289. package/types/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.d.ts.map +1 -1
  290. package/types/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.d.ts.map +1 -1
  291. package/types/error/BrowserAuthErrorCodes.d.ts +3 -0
  292. package/types/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  293. package/types/index.d.ts +1 -0
  294. package/types/index.d.ts.map +1 -1
  295. package/types/interaction_client/BaseInteractionClient.d.ts +3 -2
  296. package/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  297. package/types/interaction_client/PlatformAuthInteractionClient.d.ts +2 -2
  298. package/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  299. package/types/interaction_client/PopupClient.d.ts +2 -2
  300. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  301. package/types/interaction_client/RedirectClient.d.ts +2 -2
  302. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  303. package/types/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  304. package/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  305. package/types/interaction_client/SilentIframeClient.d.ts +2 -2
  306. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  307. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  308. package/types/naa/BridgeProxy.d.ts +14 -2
  309. package/types/naa/BridgeProxy.d.ts.map +1 -1
  310. package/types/naa/TokenRequest.d.ts +1 -0
  311. package/types/naa/TokenRequest.d.ts.map +1 -1
  312. package/types/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  313. package/types/packageMetadata.d.ts +1 -1
  314. package/types/protocol/Authorize.d.ts.map +1 -1
  315. package/types/request/RequestHelpers.d.ts.map +1 -1
  316. package/types/telemetry/BrowserPerformanceEvents.d.ts +4 -4
  317. package/types/webBrokerBridge/IWebBrokerBridgeMessage.d.ts +35 -0
  318. package/types/webBrokerBridge/IWebBrokerBridgeMessage.d.ts.map +1 -0
  319. package/types/webBrokerBridge/PendingRequestRegistry.d.ts +27 -0
  320. package/types/webBrokerBridge/PendingRequestRegistry.d.ts.map +1 -0
  321. package/types/webBrokerBridge/WebBrokerBridgeError.d.ts +50 -0
  322. package/types/webBrokerBridge/WebBrokerBridgeError.d.ts.map +1 -0
  323. package/types/webBrokerBridge/WebBrokerBridgeErrorMap.d.ts +10 -0
  324. package/types/webBrokerBridge/WebBrokerBridgeErrorMap.d.ts.map +1 -0
  325. package/types/webBrokerBridge/index.d.ts +16 -0
  326. package/types/webBrokerBridge/index.d.ts.map +1 -0
  327. package/src/naa/BridgeRequest.ts +0 -16
  328. package/types/naa/BridgeRequest.d.ts +0 -8
  329. package/types/naa/BridgeRequest.d.ts.map +0 -1
@@ -17,6 +17,7 @@ import {
17
17
  CommonAuthorizationUrlRequest,
18
18
  AuthorizeProtocol,
19
19
  PkceCodes,
20
+ ITokenBindingKeyManager,
20
21
  } from "@azure/msal-common/browser";
21
22
  import {
22
23
  initializeAuthorizationRequest,
@@ -99,7 +100,8 @@ export class SilentIframeClient extends StandardInteractionClient {
99
100
  nativeStorageImpl: BrowserCacheManager,
100
101
  correlationId: string,
101
102
  platformAuthProvider?: IPlatformAuthHandler,
102
- waitForIframeResponseHook?: WaitForIframeResponseFn
103
+ waitForIframeResponseHook?: WaitForIframeResponseFn,
104
+ tokenBindingKeyManager?: ITokenBindingKeyManager
103
105
  ) {
104
106
  super(
105
107
  config,
@@ -110,7 +112,8 @@ export class SilentIframeClient extends StandardInteractionClient {
110
112
  navigationClient,
111
113
  performanceClient,
112
114
  correlationId,
113
- platformAuthProvider
115
+ platformAuthProvider,
116
+ tokenBindingKeyManager
114
117
  );
115
118
  this.apiId = apiId;
116
119
  this.nativeStorage = nativeStorageImpl;
@@ -293,6 +293,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
293
293
  correlationId: this.correlationId,
294
294
  },
295
295
  cryptoInterface: this.browserCrypto,
296
+ tokenBindingKeyManager: this.tokenBindingKeyManager,
296
297
  networkInterface: this.networkClient,
297
298
  storageInterface: this.browserStorage,
298
299
  serverTelemetryManager: serverTelemetryManager,
@@ -8,7 +8,6 @@ import { AuthResult } from "./AuthResult.js";
8
8
  import { BridgeCapabilities } from "./BridgeCapabilities.js";
9
9
  import { AccountContext } from "./BridgeAccountContext.js";
10
10
  import { BridgeError } from "./BridgeError.js";
11
- import { BridgeRequest } from "./BridgeRequest.js";
12
11
  import {
13
12
  BridgeRequestEnvelope,
14
13
  BridgeMethods,
@@ -21,6 +20,8 @@ import { TokenRequest } from "./TokenRequest.js";
21
20
  import * as BrowserCrypto from "../crypto/BrowserCrypto.js";
22
21
  import { BrowserConstants } from "../utils/BrowserConstants.js";
23
22
  import { version } from "../packageMetadata.js";
23
+ import { IWebBrokerBridgeMessage } from "../webBrokerBridge/IWebBrokerBridgeMessage.js";
24
+ import { PendingRequestRegistry } from "../webBrokerBridge/PendingRequestRegistry.js";
24
25
 
25
26
  declare global {
26
27
  interface Window {
@@ -34,7 +35,12 @@ declare global {
34
35
  * platform broker
35
36
  */
36
37
  export class BridgeProxy implements IBridgeProxy {
37
- static bridgeRequests: BridgeRequest[] = [];
38
+ /**
39
+ * Correlates outbound bridge requests with inbound responses by
40
+ * `requestId`
41
+ */
42
+ static pendingRegistry =
43
+ new PendingRequestRegistry<BridgeResponseEnvelope>();
38
44
  sdkName: string;
39
45
  sdkVersion: string;
40
46
  capabilities?: BridgeCapabilities;
@@ -62,39 +68,22 @@ export class BridgeProxy implements IBridgeProxy {
62
68
  typeof response === "string" ? response : response.data;
63
69
  const responseEnvelope: BridgeResponseEnvelope =
64
70
  JSON.parse(responsePayload);
65
- const request = BridgeProxy.bridgeRequests.find(
66
- (element) =>
67
- element.requestId === responseEnvelope.requestId
68
- );
69
- if (request !== undefined) {
70
- BridgeProxy.bridgeRequests.splice(
71
- BridgeProxy.bridgeRequests.indexOf(request),
72
- 1
71
+ if (responseEnvelope.success) {
72
+ BridgeProxy.pendingRegistry.resolve(
73
+ responseEnvelope.requestId,
74
+ responseEnvelope
75
+ );
76
+ } else {
77
+ BridgeProxy.pendingRegistry.reject(
78
+ responseEnvelope.requestId,
79
+ responseEnvelope.error
73
80
  );
74
- if (responseEnvelope.success) {
75
- request.resolve(responseEnvelope);
76
- } else {
77
- request.reject(responseEnvelope.error);
78
- }
79
81
  }
80
82
  }
81
83
  );
82
84
 
83
- const bridgeResponse = await new Promise<BridgeResponseEnvelope>(
84
- (resolve, reject) => {
85
- const message = BridgeProxy.buildRequest("GetInitContext");
86
-
87
- const request: BridgeRequest = {
88
- requestId: message.requestId,
89
- method: message.method,
90
- resolve: resolve,
91
- reject: reject,
92
- };
93
- BridgeProxy.bridgeRequests.push(request);
94
- window.nestedAppAuthBridge.postMessage(
95
- JSON.stringify(message)
96
- );
97
- }
85
+ const bridgeResponse = await BridgeProxy.sendRequestViaRegistry(
86
+ BridgeProxy.buildRequest("GetInitContext")
98
87
  );
99
88
 
100
89
  return BridgeProxy.validateBridgeResultOrThrow(
@@ -169,22 +158,27 @@ export class BridgeProxy implements IBridgeProxy {
169
158
  method: BridgeMethods,
170
159
  requestParams?: Partial<BridgeRequestEnvelope>
171
160
  ): Promise<BridgeResponseEnvelope> {
172
- const message = BridgeProxy.buildRequest(method, requestParams);
173
-
174
- const promise = new Promise<BridgeResponseEnvelope>(
175
- (resolve, reject) => {
176
- const request: BridgeRequest = {
177
- requestId: message.requestId,
178
- method: message.method,
179
- resolve: resolve,
180
- reject: reject,
181
- };
182
- BridgeProxy.bridgeRequests.push(request);
183
- window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
184
- }
161
+ return BridgeProxy.sendRequestViaRegistry(
162
+ BridgeProxy.buildRequest(method, requestParams)
185
163
  );
164
+ }
186
165
 
187
- return promise;
166
+ /**
167
+ * Registers `message.requestId` with the shared pending-request
168
+ * registry, then posts the envelope over the host bridge. Resolves
169
+ * with the matching response envelope; rejects with the raw
170
+ * `BridgeError` payload.
171
+ */
172
+ private static sendRequestViaRegistry(
173
+ message: BridgeRequestEnvelope
174
+ ): Promise<BridgeResponseEnvelope> {
175
+ const correlationKey: IWebBrokerBridgeMessage = {
176
+ requestId: message.requestId,
177
+ type: message.method,
178
+ };
179
+ return BridgeProxy.pendingRegistry.sendAndAwait(correlationKey, () => {
180
+ window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
181
+ });
188
182
  }
189
183
 
190
184
  private static validateBridgeResultOrThrow<T>(input: T | undefined): T {
@@ -22,4 +22,5 @@ export type TokenRequest = {
22
22
  extendedExpiryToken?: boolean;
23
23
  extraParameters?: Map<string, string>;
24
24
  forceRefresh?: boolean;
25
+ attributeTokens?: string; // Pre-serialized attribute tokens forwarded to the host app; defaults to `undefined` when missing or empty.
25
26
  };
@@ -30,14 +30,20 @@ import {
30
30
  getTenantIdFromIdTokenClaims,
31
31
  TimeUtils,
32
32
  Constants,
33
+ CacheHelpers,
33
34
  } from "@azure/msal-common/browser";
34
- import { isBridgeError } from "../BridgeError.js";
35
+ import { isBridgeError, BridgeError } from "../BridgeError.js";
35
36
  import { BridgeStatusCode } from "../BridgeStatusCode.js";
36
37
  import { AuthenticationResult } from "../../response/AuthenticationResult.js";
37
38
  import {} from "../../error/BrowserAuthErrorCodes.js";
38
39
  import { AuthResult } from "../AuthResult.js";
39
40
  import { SsoSilentRequest } from "../../request/SsoSilentRequest.js";
40
41
  import { SilentRequest } from "../../request/SilentRequest.js";
42
+ import {
43
+ WebBrokerBridgeError,
44
+ WebBrokerBridgeErrorCode,
45
+ } from "../../webBrokerBridge/WebBrokerBridgeError.js";
46
+ import { toAuthError } from "../../webBrokerBridge/WebBrokerBridgeErrorMap.js";
41
47
 
42
48
  export class NestedAppAuthAdapter {
43
49
  protected crypto: ICrypto;
@@ -80,6 +86,9 @@ export class NestedAppAuthAdapter {
80
86
  this.clientCapabilities
81
87
  );
82
88
  const scopes = request.scopes || Constants.OIDC_DEFAULT_SCOPES;
89
+ const attributeTokens = CacheHelpers.serializeAttributeTokens(
90
+ request.attributeTokens
91
+ );
83
92
  const tokenRequest: TokenRequest = {
84
93
  platformBrokerId: request.account?.homeAccountId,
85
94
  clientId: this.clientId,
@@ -93,6 +102,7 @@ export class NestedAppAuthAdapter {
93
102
  request.authenticationScheme ||
94
103
  Constants.AuthenticationScheme.BEARER,
95
104
  extraParameters: extraParams,
105
+ attributeTokens,
96
106
  };
97
107
 
98
108
  return tokenRequest;
@@ -266,61 +276,9 @@ export class NestedAppAuthAdapter {
266
276
  | ServerError
267
277
  | InteractionRequiredAuthError {
268
278
  if (isBridgeError(error)) {
269
- switch (error.status) {
270
- case BridgeStatusCode.UserCancel:
271
- return new ClientAuthError(
272
- ClientAuthErrorCodes.userCanceled,
273
- ""
274
- );
275
- case BridgeStatusCode.NoNetwork:
276
- return new ClientAuthError(
277
- ClientAuthErrorCodes.noNetworkConnectivity,
278
- ""
279
- );
280
- case BridgeStatusCode.AccountUnavailable:
281
- return new ClientAuthError(
282
- ClientAuthErrorCodes.noAccountFound,
283
- ""
284
- );
285
- case BridgeStatusCode.Disabled:
286
- return new ClientAuthError(
287
- ClientAuthErrorCodes.nestedAppAuthBridgeDisabled,
288
- ""
289
- );
290
- case BridgeStatusCode.NestedAppAuthUnavailable:
291
- return new ClientAuthError(
292
- error.code ||
293
- ClientAuthErrorCodes.nestedAppAuthBridgeDisabled,
294
- "",
295
- error.description
296
- );
297
- case BridgeStatusCode.TransientError:
298
- case BridgeStatusCode.PersistentError:
299
- return new ServerError(
300
- error.code || "",
301
- "",
302
- error.description
303
- );
304
- case BridgeStatusCode.UserInteractionRequired:
305
- return new InteractionRequiredAuthError(
306
- error.code || "",
307
- "",
308
- error.description
309
- );
310
- default:
311
- return new AuthError(
312
- error.code || "",
313
- "",
314
- error.description
315
- );
316
- }
317
- } else {
318
- return new AuthError(
319
- "unknown_error",
320
- "",
321
- "An unknown error occurred"
322
- );
279
+ return toAuthError(bridgeErrorToWebBrokerBridgeError(error));
323
280
  }
281
+ return new AuthError("unknown_error", "", "An unknown error occurred");
324
282
  }
325
283
 
326
284
  /**
@@ -378,3 +336,52 @@ export class NestedAppAuthAdapter {
378
336
  return authenticationResult;
379
337
  }
380
338
  }
339
+
340
+ /**
341
+ * Converts NAA `BridgeError` into the shared `WebBrokerBridgeError`
342
+ * taxonomy.
343
+ */
344
+ function bridgeErrorToWebBrokerBridgeError(
345
+ error: BridgeError
346
+ ): WebBrokerBridgeError {
347
+ switch (error.status) {
348
+ case BridgeStatusCode.UserCancel:
349
+ return { code: WebBrokerBridgeErrorCode.UserCanceled };
350
+ case BridgeStatusCode.NoNetwork:
351
+ return { code: WebBrokerBridgeErrorCode.NoNetwork };
352
+ case BridgeStatusCode.AccountUnavailable:
353
+ return { code: WebBrokerBridgeErrorCode.AccountUnavailable };
354
+ case BridgeStatusCode.Disabled:
355
+ return { code: WebBrokerBridgeErrorCode.BridgeDisabled };
356
+ case BridgeStatusCode.NestedAppAuthUnavailable:
357
+ return {
358
+ code: WebBrokerBridgeErrorCode.BridgeUnavailable,
359
+ innerErrorCode: error.code,
360
+ description: error.description,
361
+ };
362
+ case BridgeStatusCode.TransientError:
363
+ return {
364
+ code: WebBrokerBridgeErrorCode.TransientError,
365
+ innerErrorCode: error.code,
366
+ description: error.description,
367
+ };
368
+ case BridgeStatusCode.PersistentError:
369
+ return {
370
+ code: WebBrokerBridgeErrorCode.PersistentError,
371
+ innerErrorCode: error.code,
372
+ description: error.description,
373
+ };
374
+ case BridgeStatusCode.UserInteractionRequired:
375
+ return {
376
+ code: WebBrokerBridgeErrorCode.UserInteractionRequired,
377
+ innerErrorCode: error.code,
378
+ description: error.description,
379
+ };
380
+ default:
381
+ return {
382
+ code: WebBrokerBridgeErrorCode.Unknown,
383
+ innerErrorCode: error.code,
384
+ description: error.description,
385
+ };
386
+ }
387
+ }
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "5.17.3";
3
+ export const version = "5.19.0";
@@ -43,6 +43,7 @@ import { PlatformAuthInteractionClient } from "../interaction_client/PlatformAut
43
43
  import { EventHandler } from "../event/EventHandler.js";
44
44
  import { decryptEarResponse } from "../crypto/BrowserCrypto.js";
45
45
  import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
46
+ import { TokenBindingKeyManager } from "../crypto/TokenBindingKeyManager.js";
46
47
 
47
48
  /**
48
49
  * Parsed representation of the clientdata response parameter from the /authorize endpoint.
@@ -189,8 +190,13 @@ async function getStandardParameters(
189
190
  request.authenticationScheme === Constants.AuthenticationScheme.POP
190
191
  ) {
191
192
  const cryptoOps = new CryptoOps(logger, performanceClient);
193
+ const tokenBindingKeyManager = new TokenBindingKeyManager(
194
+ logger,
195
+ performanceClient
196
+ );
192
197
  const popTokenGenerator = new PopTokenGenerator(
193
198
  cryptoOps,
199
+ tokenBindingKeyManager,
194
200
  performanceClient
195
201
  );
196
202
 
@@ -709,7 +715,8 @@ export async function handleResponseEAR(
709
715
  logger,
710
716
  performanceClient,
711
717
  null,
712
- null
718
+ null,
719
+ new TokenBindingKeyManager(logger, performanceClient)
713
720
  );
714
721
 
715
722
  // Validate response. This function throws a server error if an error is returned by the server.
@@ -21,6 +21,12 @@ import { SilentRequest } from "./SilentRequest.js";
21
21
  import { PopupRequest } from "./PopupRequest.js";
22
22
  import { RedirectRequest } from "./RedirectRequest.js";
23
23
 
24
+ const SUPPORTED_AUTHENTICATION_SCHEMES = new Set<string>([
25
+ Constants.AuthenticationScheme.BEARER,
26
+ Constants.AuthenticationScheme.POP,
27
+ Constants.AuthenticationScheme.SSH,
28
+ ]);
29
+
24
30
  /**
25
31
  * Initializer function for all request APIs
26
32
  * @param request
@@ -56,6 +62,17 @@ export async function initializeBaseRequest(
56
62
  correlationId
57
63
  );
58
64
  } else {
65
+ if (
66
+ !SUPPORTED_AUTHENTICATION_SCHEMES.has(
67
+ validatedRequest.authenticationScheme
68
+ )
69
+ ) {
70
+ throw createClientConfigurationError(
71
+ ClientConfigurationErrorCodes.unsupportedAuthenticationScheme,
72
+ correlationId
73
+ );
74
+ }
75
+
59
76
  if (
60
77
  validatedRequest.authenticationScheme ===
61
78
  Constants.AuthenticationScheme.SSH
@@ -63,13 +80,13 @@ export async function initializeBaseRequest(
63
80
  if (!request.sshJwk) {
64
81
  throw createClientConfigurationError(
65
82
  ClientConfigurationErrorCodes.missingSshJwk,
66
- ""
83
+ correlationId
67
84
  );
68
85
  }
69
86
  if (!request.sshKid) {
70
87
  throw createClientConfigurationError(
71
88
  ClientConfigurationErrorCodes.missingSshKid,
72
- ""
89
+ correlationId
73
90
  );
74
91
  }
75
92
  }
@@ -22,15 +22,15 @@ export const AcquireTokenByRefreshToken = "acquireTokenByRefreshToken";
22
22
  export const AcquireTokenSilentAsync = "acquireTokenSilentAsync";
23
23
 
24
24
  /**
25
- * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
26
- * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
25
+ * provisionTokenBindingKey API in TokenBindingKeyManager class (msal-browser).
26
+ * Used to provision token-binding key material and return a key identifier.
27
27
  */
28
28
  export const CryptoOptsGetPublicKeyThumbprint =
29
29
  "cryptoOptsGetPublicKeyThumbprint";
30
30
 
31
31
  /**
32
- * signJwt API in CryptoOpts class (msal-browser).
33
- * Used to signed a pop token.
32
+ * signTokenBindingJwt API in CryptoOpts class (msal-browser).
33
+ * Used to sign token-binding JWTs.
34
34
  */
35
35
  export const CryptoOptsSignJwt = "cryptoOptsSignJwt";
36
36
 
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { WebBrokerBridgeError } from "./WebBrokerBridgeError.js";
7
+
8
+ /**
9
+ * Structural interface shared by NAA and PWB bridge request messages.
10
+ *
11
+ * Both `BridgeRequestEnvelope` (NAA) and `BrokerAuthRequest` (PWB) satisfy
12
+ * this shape without any wire-format changes; concrete implementations
13
+ * derive `requestId` from whatever correlation identifiers they already
14
+ * carry.
15
+ */
16
+ export interface IWebBrokerBridgeMessage {
17
+ /**
18
+ * Unique identifier used to correlate this request with its response.
19
+ * Format is bridge-specific (NAA uses a GUID; PWB composes
20
+ * `${channelId}:${messageId}`).
21
+ */
22
+ readonly requestId: string;
23
+
24
+ /**
25
+ * Discriminator identifying what this message represents
26
+ * (e.g. `"GetToken"`, `"AuthRequest"`, `"Handshake"`).
27
+ */
28
+ readonly type: string;
29
+ }
30
+
31
+ /**
32
+ * Structural interface shared by NAA and PWB bridge response messages.
33
+ *
34
+ * Responses are matched against pending requests by `requestId`.
35
+ */
36
+ export interface IWebBrokerBridgeResponse extends IWebBrokerBridgeMessage {
37
+ /**
38
+ * When present, indicates the request failed and provides the
39
+ * unified error taxonomy code + optional context. Absent on success.
40
+ */
41
+ error?: WebBrokerBridgeError;
42
+ }
@@ -0,0 +1,76 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { IWebBrokerBridgeMessage } from "./IWebBrokerBridgeMessage.js";
7
+
8
+ interface PendingRequest<TResp> {
9
+ resolve: (response: TResp) => void;
10
+ reject: (reason: unknown) => void;
11
+ }
12
+
13
+ export type WebBrokerBridgeSendFn<TReq extends IWebBrokerBridgeMessage> = (
14
+ message: TReq
15
+ ) => void;
16
+
17
+ /**
18
+ * Correlates outbound requests with inbound responses by `requestId`.
19
+ */
20
+ export class PendingRequestRegistry<TResp> {
21
+ private readonly pending = new Map<string, PendingRequest<TResp>>();
22
+
23
+ /**
24
+ * Register a pending request. Returns a promise that resolves when a
25
+ * response with the matching `requestId` arrives, or rejects if the
26
+ * caller invokes `reject` for that id.
27
+ */
28
+ register(requestId: string): Promise<TResp> {
29
+ return new Promise<TResp>((resolve, reject) => {
30
+ this.pending.set(requestId, { resolve, reject });
31
+ });
32
+ }
33
+
34
+ /** Resolve a pending request. No-op if `requestId` isn't registered. */
35
+ resolve(requestId: string, response: TResp): void {
36
+ const entry = this.pending.get(requestId);
37
+ if (entry === undefined) {
38
+ return;
39
+ }
40
+ this.pending.delete(requestId);
41
+ entry.resolve(response);
42
+ }
43
+
44
+ /** Reject a pending request. No-op if `requestId` isn't registered. */
45
+ reject(requestId: string, reason: unknown): void {
46
+ const entry = this.pending.get(requestId);
47
+ if (entry === undefined) {
48
+ return;
49
+ }
50
+ this.pending.delete(requestId);
51
+ entry.reject(reason);
52
+ }
53
+
54
+ /** True if `requestId` has an in-flight registration. */
55
+ has(requestId: string): boolean {
56
+ return this.pending.has(requestId);
57
+ }
58
+
59
+ /**
60
+ * Register, then invoke `send` synchronously. If `send` throws, the
61
+ * pending entry is cleared and the promise rejects with the thrown
62
+ * error.
63
+ */
64
+ async sendAndAwait<TReq extends IWebBrokerBridgeMessage>(
65
+ message: TReq,
66
+ send: WebBrokerBridgeSendFn<TReq>
67
+ ): Promise<TResp> {
68
+ const promise = this.register(message.requestId);
69
+ try {
70
+ send(message);
71
+ } catch (err) {
72
+ this.reject(message.requestId, err);
73
+ }
74
+ return promise;
75
+ }
76
+ }
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /**
7
+ * Unified error taxonomy shared by NAA and PWB.
8
+ *
9
+ * Each code maps to exactly one of the four base MSAL error classes
10
+ * (`AuthError`, `ClientAuthError`, `ServerError`,
11
+ * `InteractionRequiredAuthError`) via `toAuthError` in
12
+ * `./WebBrokerBridgeErrorMap`.
13
+ */
14
+ export const WebBrokerBridgeErrorCode = {
15
+ /* Interaction / auth outcomes */
16
+ UserInteractionRequired: "user_interaction_required",
17
+ UserCanceled: "user_canceled",
18
+
19
+ /* Environment / connectivity */
20
+ NoNetwork: "no_network",
21
+ AccountUnavailable: "account_unavailable",
22
+ BridgeDisabled: "bridge_disabled",
23
+ BridgeUnavailable: "bridge_unavailable",
24
+
25
+ /* Server-side outcomes */
26
+ TransientError: "transient_error",
27
+ PersistentError: "persistent_error",
28
+
29
+ /* Broker-channel failures */
30
+ BridgeTimeout: "bridge_timeout",
31
+ BridgeHandshakeFailed: "bridge_handshake_failed",
32
+ BridgeConnectionReset: "bridge_connection_reset",
33
+ BridgeResponseInvalid: "bridge_response_invalid",
34
+ PopupWillRedirect: "popup_will_redirect",
35
+ ShrGenerationError: "shr_generation_error",
36
+
37
+ /* Fallback */
38
+ Unknown: "unknown",
39
+ } as const;
40
+ export type WebBrokerBridgeErrorCode =
41
+ (typeof WebBrokerBridgeErrorCode)[keyof typeof WebBrokerBridgeErrorCode];
42
+
43
+ /**
44
+ * Normalized error payload carried between the broker and the embedded
45
+ * app. Bridge-specific transports (NAA `BridgeError`, PWB `errorPayload`)
46
+ * are lowered into this shape before being lifted to an MSAL error class.
47
+ */
48
+ export interface WebBrokerBridgeError {
49
+ /**
50
+ * Common taxonomy code — see `WebBrokerBridgeErrorCode`.
51
+ */
52
+ readonly code: WebBrokerBridgeErrorCode;
53
+
54
+ /**
55
+ * Underlying provider-specific error code preserved for classes that
56
+ * accept a variable code (e.g. `invalid_grant` on `ServerError`).
57
+ * Ignored for codes whose mapping is a fixed constant.
58
+ */
59
+ readonly innerErrorCode?: string;
60
+
61
+ /** Server sub-error (e.g. `consent_required`). */
62
+ readonly subError?: string;
63
+
64
+ /** Human-readable description forwarded from the underlying response. */
65
+ readonly description?: string;
66
+
67
+ /** Correlation id, when available. */
68
+ readonly correlationId?: string;
69
+ }