@azure/msal-browser 4.18.0 → 4.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 (438) 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/NativeStatusCodes.mjs +1 -1
  5. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
  7. package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  8. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +3 -2
  9. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -1
  10. package/dist/cache/AccountManager.mjs +1 -1
  11. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  12. package/dist/cache/BrowserCacheManager.d.ts +26 -11
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.mjs +239 -56
  15. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  16. package/dist/cache/CacheHelpers.d.ts +2 -2
  17. package/dist/cache/CacheHelpers.d.ts.map +1 -1
  18. package/dist/cache/CacheHelpers.mjs +6 -6
  19. package/dist/cache/CacheHelpers.mjs.map +1 -1
  20. package/dist/cache/CacheKeys.d.ts +14 -0
  21. package/dist/cache/CacheKeys.d.ts.map +1 -0
  22. package/dist/cache/CacheKeys.mjs +33 -0
  23. package/dist/cache/CacheKeys.mjs.map +1 -0
  24. package/dist/cache/CookieStorage.d.ts +1 -0
  25. package/dist/cache/CookieStorage.d.ts.map +1 -1
  26. package/dist/cache/CookieStorage.mjs +5 -1
  27. package/dist/cache/CookieStorage.mjs.map +1 -1
  28. package/dist/cache/DatabaseStorage.mjs +1 -1
  29. package/dist/cache/EncryptedData.d.ts +8 -0
  30. package/dist/cache/EncryptedData.d.ts.map +1 -0
  31. package/dist/cache/EncryptedData.mjs +14 -0
  32. package/dist/cache/EncryptedData.mjs.map +1 -0
  33. package/dist/cache/IWindowStorage.d.ts +2 -0
  34. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  35. package/dist/cache/LocalStorage.d.ts +2 -0
  36. package/dist/cache/LocalStorage.d.ts.map +1 -1
  37. package/dist/cache/LocalStorage.mjs +46 -13
  38. package/dist/cache/LocalStorage.mjs.map +1 -1
  39. package/dist/cache/MemoryStorage.d.ts +1 -0
  40. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  41. package/dist/cache/MemoryStorage.mjs +5 -1
  42. package/dist/cache/MemoryStorage.mjs.map +1 -1
  43. package/dist/cache/SessionStorage.d.ts +1 -0
  44. package/dist/cache/SessionStorage.d.ts.map +1 -1
  45. package/dist/cache/SessionStorage.mjs +5 -1
  46. package/dist/cache/SessionStorage.mjs.map +1 -1
  47. package/dist/cache/TokenCache.mjs +1 -1
  48. package/dist/config/Configuration.d.ts +4 -0
  49. package/dist/config/Configuration.d.ts.map +1 -1
  50. package/dist/config/Configuration.mjs +2 -1
  51. package/dist/config/Configuration.mjs.map +1 -1
  52. package/dist/controllers/ControllerFactory.mjs +1 -1
  53. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  54. package/dist/controllers/StandardController.d.ts.map +1 -1
  55. package/dist/controllers/StandardController.mjs +2 -1
  56. package/dist/controllers/StandardController.mjs.map +1 -1
  57. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  58. package/dist/crypto/BrowserCrypto.mjs +1 -1
  59. package/dist/crypto/CryptoOps.mjs +1 -1
  60. package/dist/crypto/PkceGenerator.mjs +1 -1
  61. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  62. package/dist/custom-auth-path/app/PublicClientApplication.mjs +1 -1
  63. package/dist/custom-auth-path/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  64. package/dist/custom-auth-path/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
  65. package/dist/custom-auth-path/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
  66. package/dist/custom-auth-path/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  67. package/dist/custom-auth-path/broker/nativeBroker/PlatformAuthProvider.mjs +3 -2
  68. package/dist/custom-auth-path/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -1
  69. package/dist/custom-auth-path/cache/AccountManager.mjs +1 -1
  70. package/dist/custom-auth-path/cache/AsyncMemoryStorage.mjs +1 -1
  71. package/dist/custom-auth-path/cache/BrowserCacheManager.d.ts +26 -11
  72. package/dist/custom-auth-path/cache/BrowserCacheManager.d.ts.map +1 -1
  73. package/dist/custom-auth-path/cache/BrowserCacheManager.mjs +239 -56
  74. package/dist/custom-auth-path/cache/BrowserCacheManager.mjs.map +1 -1
  75. package/dist/custom-auth-path/cache/CacheHelpers.d.ts +2 -2
  76. package/dist/custom-auth-path/cache/CacheHelpers.d.ts.map +1 -1
  77. package/dist/custom-auth-path/cache/CacheHelpers.mjs +6 -6
  78. package/dist/custom-auth-path/cache/CacheHelpers.mjs.map +1 -1
  79. package/dist/custom-auth-path/cache/CacheKeys.d.ts +14 -0
  80. package/dist/custom-auth-path/cache/CacheKeys.d.ts.map +1 -0
  81. package/dist/custom-auth-path/cache/CacheKeys.mjs +32 -0
  82. package/dist/custom-auth-path/cache/CacheKeys.mjs.map +1 -0
  83. package/dist/custom-auth-path/cache/CookieStorage.d.ts +1 -0
  84. package/dist/custom-auth-path/cache/CookieStorage.d.ts.map +1 -1
  85. package/dist/custom-auth-path/cache/CookieStorage.mjs +5 -1
  86. package/dist/custom-auth-path/cache/CookieStorage.mjs.map +1 -1
  87. package/dist/custom-auth-path/cache/DatabaseStorage.mjs +1 -1
  88. package/dist/custom-auth-path/cache/EncryptedData.d.ts +8 -0
  89. package/dist/custom-auth-path/cache/EncryptedData.d.ts.map +1 -0
  90. package/dist/custom-auth-path/cache/EncryptedData.mjs +14 -0
  91. package/dist/custom-auth-path/cache/EncryptedData.mjs.map +1 -0
  92. package/dist/custom-auth-path/cache/IWindowStorage.d.ts +2 -0
  93. package/dist/custom-auth-path/cache/IWindowStorage.d.ts.map +1 -1
  94. package/dist/custom-auth-path/cache/LocalStorage.d.ts +2 -0
  95. package/dist/custom-auth-path/cache/LocalStorage.d.ts.map +1 -1
  96. package/dist/custom-auth-path/cache/LocalStorage.mjs +46 -13
  97. package/dist/custom-auth-path/cache/LocalStorage.mjs.map +1 -1
  98. package/dist/custom-auth-path/cache/MemoryStorage.d.ts +1 -0
  99. package/dist/custom-auth-path/cache/MemoryStorage.d.ts.map +1 -1
  100. package/dist/custom-auth-path/cache/MemoryStorage.mjs +5 -1
  101. package/dist/custom-auth-path/cache/MemoryStorage.mjs.map +1 -1
  102. package/dist/custom-auth-path/cache/SessionStorage.d.ts +1 -0
  103. package/dist/custom-auth-path/cache/SessionStorage.d.ts.map +1 -1
  104. package/dist/custom-auth-path/cache/SessionStorage.mjs +5 -1
  105. package/dist/custom-auth-path/cache/SessionStorage.mjs.map +1 -1
  106. package/dist/custom-auth-path/cache/TokenCache.mjs +1 -1
  107. package/dist/custom-auth-path/config/Configuration.d.ts +4 -0
  108. package/dist/custom-auth-path/config/Configuration.d.ts.map +1 -1
  109. package/dist/custom-auth-path/config/Configuration.mjs +2 -1
  110. package/dist/custom-auth-path/config/Configuration.mjs.map +1 -1
  111. package/dist/custom-auth-path/controllers/ControllerFactory.mjs +1 -1
  112. package/dist/custom-auth-path/controllers/StandardController.d.ts.map +1 -1
  113. package/dist/custom-auth-path/controllers/StandardController.mjs +2 -1
  114. package/dist/custom-auth-path/controllers/StandardController.mjs.map +1 -1
  115. package/dist/custom-auth-path/crypto/BrowserCrypto.mjs +1 -1
  116. package/dist/custom-auth-path/crypto/CryptoOps.mjs +1 -1
  117. package/dist/custom-auth-path/crypto/PkceGenerator.mjs +1 -1
  118. package/dist/custom-auth-path/custom_auth/CustomAuthConstants.d.ts +1 -1
  119. package/dist/custom-auth-path/custom_auth/CustomAuthConstants.mjs +1 -1
  120. package/dist/custom-auth-path/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  121. package/dist/custom-auth-path/custom_auth/controller/CustomAuthStandardController.mjs +1 -1
  122. package/dist/custom-auth-path/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  123. package/dist/custom-auth-path/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  124. package/dist/custom-auth-path/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  125. package/dist/custom-auth-path/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  126. package/dist/custom-auth-path/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  127. package/dist/custom-auth-path/custom_auth/core/error/CustomAuthError.mjs +1 -1
  128. package/dist/custom-auth-path/custom_auth/core/error/HttpError.mjs +1 -1
  129. package/dist/custom-auth-path/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  130. package/dist/custom-auth-path/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  131. package/dist/custom-auth-path/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  132. package/dist/custom-auth-path/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  133. package/dist/custom-auth-path/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  134. package/dist/custom-auth-path/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  135. package/dist/custom-auth-path/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  136. package/dist/custom-auth-path/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  137. package/dist/custom-auth-path/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  138. package/dist/custom-auth-path/custom_auth/core/error/UnexpectedError.mjs +1 -1
  139. package/dist/custom-auth-path/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  140. package/dist/custom-auth-path/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  141. package/dist/custom-auth-path/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  142. package/dist/custom-auth-path/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  143. package/dist/custom-auth-path/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  144. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  145. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  146. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  147. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  148. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  149. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  150. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  151. package/dist/custom-auth-path/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  152. package/dist/custom-auth-path/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  153. package/dist/custom-auth-path/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  154. package/dist/custom-auth-path/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
  155. package/dist/custom-auth-path/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  156. package/dist/custom-auth-path/custom_auth/core/utils/UrlUtils.mjs +1 -1
  157. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  158. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  159. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  160. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  161. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  162. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  163. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  164. package/dist/custom-auth-path/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  165. package/dist/custom-auth-path/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  166. package/dist/custom-auth-path/custom_auth/index.mjs +1 -1
  167. package/dist/custom-auth-path/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  168. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  169. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  170. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  171. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  172. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  173. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  174. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  175. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  176. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  177. package/dist/custom-auth-path/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  178. package/dist/custom-auth-path/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  179. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  180. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  181. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  182. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  183. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  184. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/result/SignInSubmitCredentialResult.mjs +1 -1
  185. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  186. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  187. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  188. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  189. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  190. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  191. package/dist/custom-auth-path/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  192. package/dist/custom-auth-path/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  193. package/dist/custom-auth-path/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  194. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  195. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  196. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  197. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  198. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  199. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  200. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  201. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  202. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  203. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  204. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  205. package/dist/custom-auth-path/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  206. package/dist/custom-auth-path/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  207. package/dist/custom-auth-path/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  208. package/dist/custom-auth-path/encode/Base64Decode.mjs +1 -1
  209. package/dist/custom-auth-path/encode/Base64Encode.mjs +1 -1
  210. package/dist/custom-auth-path/error/BrowserAuthError.mjs +1 -1
  211. package/dist/custom-auth-path/error/BrowserAuthErrorCodes.mjs +1 -1
  212. package/dist/custom-auth-path/error/BrowserConfigurationAuthError.mjs +1 -1
  213. package/dist/custom-auth-path/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  214. package/dist/custom-auth-path/error/NativeAuthError.mjs +1 -1
  215. package/dist/custom-auth-path/error/NativeAuthErrorCodes.mjs +1 -1
  216. package/dist/custom-auth-path/event/EventHandler.mjs +1 -1
  217. package/dist/custom-auth-path/event/EventType.mjs +1 -1
  218. package/dist/custom-auth-path/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  219. package/dist/custom-auth-path/interaction_client/BaseInteractionClient.mjs +3 -7
  220. package/dist/custom-auth-path/interaction_client/BaseInteractionClient.mjs.map +1 -1
  221. package/dist/custom-auth-path/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  222. package/dist/custom-auth-path/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  223. package/dist/custom-auth-path/interaction_client/PlatformAuthInteractionClient.mjs +2 -2
  224. package/dist/custom-auth-path/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  225. package/dist/custom-auth-path/interaction_client/PopupClient.d.ts.map +1 -1
  226. package/dist/custom-auth-path/interaction_client/PopupClient.mjs +1 -2
  227. package/dist/custom-auth-path/interaction_client/PopupClient.mjs.map +1 -1
  228. package/dist/custom-auth-path/interaction_client/RedirectClient.d.ts.map +1 -1
  229. package/dist/custom-auth-path/interaction_client/RedirectClient.mjs +1 -2
  230. package/dist/custom-auth-path/interaction_client/RedirectClient.mjs.map +1 -1
  231. package/dist/custom-auth-path/interaction_client/SilentAuthCodeClient.mjs +1 -1
  232. package/dist/custom-auth-path/interaction_client/SilentCacheClient.mjs +1 -1
  233. package/dist/custom-auth-path/interaction_client/SilentIframeClient.mjs +1 -1
  234. package/dist/custom-auth-path/interaction_client/SilentRefreshClient.mjs +1 -1
  235. package/dist/custom-auth-path/interaction_client/StandardInteractionClient.mjs +1 -1
  236. package/dist/custom-auth-path/interaction_handler/InteractionHandler.mjs +1 -1
  237. package/dist/custom-auth-path/interaction_handler/SilentHandler.mjs +1 -1
  238. package/dist/custom-auth-path/naa/AccountInfo.d.ts +1 -0
  239. package/dist/custom-auth-path/naa/AccountInfo.d.ts.map +1 -1
  240. package/dist/custom-auth-path/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  241. package/dist/custom-auth-path/navigation/NavigationClient.mjs +1 -1
  242. package/dist/custom-auth-path/network/FetchClient.mjs +1 -1
  243. package/dist/custom-auth-path/operatingcontext/BaseOperatingContext.d.ts.map +1 -1
  244. package/dist/custom-auth-path/operatingcontext/BaseOperatingContext.mjs +3 -2
  245. package/dist/custom-auth-path/operatingcontext/BaseOperatingContext.mjs.map +1 -1
  246. package/dist/custom-auth-path/operatingcontext/StandardOperatingContext.mjs +1 -1
  247. package/dist/custom-auth-path/packageMetadata.d.ts +1 -1
  248. package/dist/custom-auth-path/packageMetadata.mjs +2 -2
  249. package/dist/custom-auth-path/protocol/Authorize.mjs +1 -1
  250. package/dist/custom-auth-path/request/RequestHelpers.mjs +1 -1
  251. package/dist/custom-auth-path/response/ResponseHandler.mjs +1 -1
  252. package/dist/custom-auth-path/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  253. package/dist/custom-auth-path/utils/BrowserConstants.d.ts +0 -10
  254. package/dist/custom-auth-path/utils/BrowserConstants.d.ts.map +1 -1
  255. package/dist/custom-auth-path/utils/BrowserConstants.mjs +3 -11
  256. package/dist/custom-auth-path/utils/BrowserConstants.mjs.map +1 -1
  257. package/dist/custom-auth-path/utils/BrowserProtocolUtils.mjs +1 -1
  258. package/dist/custom-auth-path/utils/BrowserUtils.mjs +1 -1
  259. package/dist/custom-auth-path/utils/Helpers.d.ts +7 -0
  260. package/dist/custom-auth-path/utils/Helpers.d.ts.map +1 -0
  261. package/dist/custom-auth-path/utils/Helpers.mjs +20 -0
  262. package/dist/custom-auth-path/utils/Helpers.mjs.map +1 -0
  263. package/dist/custom-auth-path/utils/MsalFrameStatsUtils.mjs +1 -1
  264. package/dist/custom_auth/CustomAuthConstants.d.ts +1 -1
  265. package/dist/encode/Base64Decode.mjs +1 -1
  266. package/dist/encode/Base64Encode.mjs +1 -1
  267. package/dist/error/BrowserAuthError.mjs +1 -1
  268. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  269. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  270. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  271. package/dist/error/NativeAuthError.mjs +1 -1
  272. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  273. package/dist/error/NestedAppAuthError.mjs +1 -1
  274. package/dist/event/EventHandler.mjs +1 -1
  275. package/dist/event/EventMessage.mjs +1 -1
  276. package/dist/event/EventType.mjs +1 -1
  277. package/dist/index.mjs +1 -1
  278. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  279. package/dist/interaction_client/BaseInteractionClient.mjs +3 -7
  280. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  281. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  282. package/dist/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  283. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +2 -2
  284. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  285. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  286. package/dist/interaction_client/PopupClient.mjs +1 -2
  287. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  288. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  289. package/dist/interaction_client/RedirectClient.mjs +1 -2
  290. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  291. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  292. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  293. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  294. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  295. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  296. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  297. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  298. package/dist/naa/AccountInfo.d.ts +1 -0
  299. package/dist/naa/AccountInfo.d.ts.map +1 -1
  300. package/dist/naa/BridgeError.mjs +1 -1
  301. package/dist/naa/BridgeProxy.mjs +1 -1
  302. package/dist/naa/BridgeStatusCode.mjs +1 -1
  303. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  304. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +3 -1
  305. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  306. package/dist/navigation/NavigationClient.mjs +1 -1
  307. package/dist/network/FetchClient.mjs +1 -1
  308. package/dist/operatingcontext/BaseOperatingContext.d.ts.map +1 -1
  309. package/dist/operatingcontext/BaseOperatingContext.mjs +3 -2
  310. package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -1
  311. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  312. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  313. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  314. package/dist/packageMetadata.d.ts +1 -1
  315. package/dist/packageMetadata.mjs +2 -2
  316. package/dist/protocol/Authorize.mjs +1 -1
  317. package/dist/request/RequestHelpers.mjs +1 -1
  318. package/dist/response/ResponseHandler.mjs +1 -1
  319. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  320. package/dist/telemetry/BrowserPerformanceClient.mjs +3 -2
  321. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  322. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  323. package/dist/utils/BrowserConstants.d.ts +0 -10
  324. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  325. package/dist/utils/BrowserConstants.mjs +3 -12
  326. package/dist/utils/BrowserConstants.mjs.map +1 -1
  327. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  328. package/dist/utils/BrowserUtils.mjs +1 -1
  329. package/dist/utils/Helpers.d.ts +7 -0
  330. package/dist/utils/Helpers.d.ts.map +1 -0
  331. package/dist/utils/Helpers.mjs +20 -0
  332. package/dist/utils/Helpers.mjs.map +1 -0
  333. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  334. package/lib/custom-auth-path/msal-custom-auth.cjs +2619 -2498
  335. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  336. package/lib/custom-auth-path/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  337. package/lib/custom-auth-path/types/cache/BrowserCacheManager.d.ts +26 -11
  338. package/lib/custom-auth-path/types/cache/BrowserCacheManager.d.ts.map +1 -1
  339. package/lib/custom-auth-path/types/cache/CacheHelpers.d.ts +2 -2
  340. package/lib/custom-auth-path/types/cache/CacheHelpers.d.ts.map +1 -1
  341. package/lib/custom-auth-path/types/cache/CacheKeys.d.ts +14 -0
  342. package/lib/custom-auth-path/types/cache/CacheKeys.d.ts.map +1 -0
  343. package/lib/custom-auth-path/types/cache/CookieStorage.d.ts +1 -0
  344. package/lib/custom-auth-path/types/cache/CookieStorage.d.ts.map +1 -1
  345. package/lib/custom-auth-path/types/cache/EncryptedData.d.ts +8 -0
  346. package/lib/custom-auth-path/types/cache/EncryptedData.d.ts.map +1 -0
  347. package/lib/custom-auth-path/types/cache/IWindowStorage.d.ts +2 -0
  348. package/lib/custom-auth-path/types/cache/IWindowStorage.d.ts.map +1 -1
  349. package/lib/custom-auth-path/types/cache/LocalStorage.d.ts +2 -0
  350. package/lib/custom-auth-path/types/cache/LocalStorage.d.ts.map +1 -1
  351. package/lib/custom-auth-path/types/cache/MemoryStorage.d.ts +1 -0
  352. package/lib/custom-auth-path/types/cache/MemoryStorage.d.ts.map +1 -1
  353. package/lib/custom-auth-path/types/cache/SessionStorage.d.ts +1 -0
  354. package/lib/custom-auth-path/types/cache/SessionStorage.d.ts.map +1 -1
  355. package/lib/custom-auth-path/types/config/Configuration.d.ts +4 -0
  356. package/lib/custom-auth-path/types/config/Configuration.d.ts.map +1 -1
  357. package/lib/custom-auth-path/types/controllers/StandardController.d.ts.map +1 -1
  358. package/lib/custom-auth-path/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  359. package/lib/custom-auth-path/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  360. package/lib/custom-auth-path/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  361. package/lib/custom-auth-path/types/interaction_client/PopupClient.d.ts.map +1 -1
  362. package/lib/custom-auth-path/types/interaction_client/RedirectClient.d.ts.map +1 -1
  363. package/lib/custom-auth-path/types/naa/AccountInfo.d.ts +1 -0
  364. package/lib/custom-auth-path/types/naa/AccountInfo.d.ts.map +1 -1
  365. package/lib/custom-auth-path/types/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  366. package/lib/custom-auth-path/types/operatingcontext/BaseOperatingContext.d.ts.map +1 -1
  367. package/lib/custom-auth-path/types/packageMetadata.d.ts +1 -1
  368. package/lib/custom-auth-path/types/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  369. package/lib/custom-auth-path/types/utils/BrowserConstants.d.ts +0 -10
  370. package/lib/custom-auth-path/types/utils/BrowserConstants.d.ts.map +1 -1
  371. package/lib/custom-auth-path/types/utils/Helpers.d.ts +7 -0
  372. package/lib/custom-auth-path/types/utils/Helpers.d.ts.map +1 -0
  373. package/lib/msal-browser.cjs +2762 -2629
  374. package/lib/msal-browser.cjs.map +1 -1
  375. package/lib/msal-browser.js +2762 -2629
  376. package/lib/msal-browser.js.map +1 -1
  377. package/lib/msal-browser.min.js +67 -69
  378. package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  379. package/lib/types/cache/BrowserCacheManager.d.ts +26 -11
  380. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  381. package/lib/types/cache/CacheHelpers.d.ts +2 -2
  382. package/lib/types/cache/CacheHelpers.d.ts.map +1 -1
  383. package/lib/types/cache/CacheKeys.d.ts +14 -0
  384. package/lib/types/cache/CacheKeys.d.ts.map +1 -0
  385. package/lib/types/cache/CookieStorage.d.ts +1 -0
  386. package/lib/types/cache/CookieStorage.d.ts.map +1 -1
  387. package/lib/types/cache/EncryptedData.d.ts +8 -0
  388. package/lib/types/cache/EncryptedData.d.ts.map +1 -0
  389. package/lib/types/cache/IWindowStorage.d.ts +2 -0
  390. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  391. package/lib/types/cache/LocalStorage.d.ts +2 -0
  392. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  393. package/lib/types/cache/MemoryStorage.d.ts +1 -0
  394. package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
  395. package/lib/types/cache/SessionStorage.d.ts +1 -0
  396. package/lib/types/cache/SessionStorage.d.ts.map +1 -1
  397. package/lib/types/config/Configuration.d.ts +4 -0
  398. package/lib/types/config/Configuration.d.ts.map +1 -1
  399. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  400. package/lib/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  401. package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  402. package/lib/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  403. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  404. package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
  405. package/lib/types/naa/AccountInfo.d.ts +1 -0
  406. package/lib/types/naa/AccountInfo.d.ts.map +1 -1
  407. package/lib/types/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  408. package/lib/types/operatingcontext/BaseOperatingContext.d.ts.map +1 -1
  409. package/lib/types/packageMetadata.d.ts +1 -1
  410. package/lib/types/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  411. package/lib/types/utils/BrowserConstants.d.ts +0 -10
  412. package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
  413. package/lib/types/utils/Helpers.d.ts +7 -0
  414. package/lib/types/utils/Helpers.d.ts.map +1 -0
  415. package/package.json +2 -2
  416. package/src/broker/nativeBroker/PlatformAuthProvider.ts +2 -4
  417. package/src/cache/BrowserCacheManager.ts +381 -61
  418. package/src/cache/CacheHelpers.ts +13 -5
  419. package/src/cache/CacheKeys.ts +39 -0
  420. package/src/cache/CookieStorage.ts +5 -0
  421. package/src/cache/EncryptedData.ts +19 -0
  422. package/src/cache/IWindowStorage.ts +8 -0
  423. package/src/cache/LocalStorage.ts +83 -27
  424. package/src/cache/MemoryStorage.ts +5 -0
  425. package/src/cache/SessionStorage.ts +5 -0
  426. package/src/config/Configuration.ts +5 -0
  427. package/src/controllers/StandardController.ts +1 -0
  428. package/src/interaction_client/BaseInteractionClient.ts +1 -15
  429. package/src/interaction_client/PlatformAuthInteractionClient.ts +4 -2
  430. package/src/interaction_client/PopupClient.ts +0 -5
  431. package/src/interaction_client/RedirectClient.ts +0 -5
  432. package/src/naa/AccountInfo.ts +1 -0
  433. package/src/naa/mapping/NestedAppAuthAdapter.ts +4 -0
  434. package/src/operatingcontext/BaseOperatingContext.ts +2 -5
  435. package/src/packageMetadata.ts +1 -1
  436. package/src/telemetry/BrowserPerformanceClient.ts +2 -4
  437. package/src/utils/BrowserConstants.ts +0 -15
  438. package/src/utils/Helpers.ts +19 -0
@@ -35,6 +35,9 @@ import {
35
35
  ThrottlingEntity,
36
36
  TimeUtils,
37
37
  TokenKeys,
38
+ CredentialEntity,
39
+ CredentialType,
40
+ DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
38
41
  } from "@azure/msal-common/browser";
39
42
  import { CacheOptions } from "../config/Configuration.js";
40
43
  import {
@@ -45,9 +48,9 @@ import {
45
48
  BrowserCacheLocation,
46
49
  InMemoryCacheKeys,
47
50
  INTERACTION_TYPE,
48
- StaticCacheKeys,
49
51
  TemporaryCacheKeys,
50
52
  } from "../utils/BrowserConstants.js";
53
+ import * as CacheKeys from "./CacheKeys.js";
51
54
  import { LocalStorage } from "./LocalStorage.js";
52
55
  import { SessionStorage } from "./SessionStorage.js";
53
56
  import { MemoryStorage } from "./MemoryStorage.js";
@@ -66,6 +69,8 @@ import { EventType } from "../event/EventType.js";
66
69
  import { EventHandler } from "../event/EventHandler.js";
67
70
  import { clearHash } from "../utils/BrowserUtils.js";
68
71
  import { version } from "../packageMetadata.js";
72
+ import { removeElementFromArray } from "../utils/Helpers.js";
73
+ import { EncryptedData, isEncrypted } from "./EncryptedData.js";
69
74
 
70
75
  /**
71
76
  * This class implements the cache storage interface for MSAL through browser local or session storage.
@@ -124,16 +129,224 @@ export class BrowserCacheManager extends CacheManager {
124
129
  }
125
130
 
126
131
  async initialize(correlationId: string): Promise<void> {
132
+ this.performanceClient.addFields(
133
+ {
134
+ cacheLocation: this.cacheConfig.cacheLocation,
135
+ cacheRetentionDays: this.cacheConfig.cacheRetentionDays,
136
+ },
137
+ correlationId
138
+ );
127
139
  await this.browserStorage.initialize(correlationId);
140
+ await this.migrateExistingCache(correlationId);
128
141
  this.trackVersionChanges(correlationId);
129
142
  }
130
143
 
144
+ /**
145
+ * Migrates any existing cache data from previous versions of MSAL.js into the current cache structure.
146
+ */
147
+ async migrateExistingCache(correlationId: string): Promise<void> {
148
+ const accountKeys0 = getAccountKeys(this.browserStorage, 0);
149
+ const tokenKeys0 = getTokenKeys(this.clientId, this.browserStorage, 0);
150
+ this.performanceClient.addFields(
151
+ {
152
+ oldAccountCount: accountKeys0.length,
153
+ oldAccessCount: tokenKeys0.accessToken.length,
154
+ oldIdCount: tokenKeys0.idToken.length,
155
+ oldRefreshCount: tokenKeys0.refreshToken.length,
156
+ },
157
+ correlationId
158
+ );
159
+
160
+ const accountKeys1 = getAccountKeys(this.browserStorage, 1);
161
+ const tokenKeys1 = getTokenKeys(this.clientId, this.browserStorage, 1);
162
+ this.performanceClient.addFields(
163
+ {
164
+ currAccountCount: accountKeys1.length,
165
+ currAccessCount: tokenKeys1.accessToken.length,
166
+ currIdCount: tokenKeys1.idToken.length,
167
+ currRefreshCount: tokenKeys1.refreshToken.length,
168
+ },
169
+ correlationId
170
+ );
171
+
172
+ await Promise.all([
173
+ this.updateV0ToCurrent(
174
+ CacheKeys.ACCOUNT_SCHEMA_VERSION,
175
+ accountKeys0,
176
+ accountKeys1,
177
+ correlationId
178
+ ),
179
+ this.updateV0ToCurrent(
180
+ CacheKeys.CREDENTIAL_SCHEMA_VERSION,
181
+ tokenKeys0.idToken,
182
+ tokenKeys1.idToken,
183
+ correlationId
184
+ ),
185
+ this.updateV0ToCurrent(
186
+ CacheKeys.CREDENTIAL_SCHEMA_VERSION,
187
+ tokenKeys0.accessToken,
188
+ tokenKeys1.accessToken,
189
+ correlationId
190
+ ),
191
+ this.updateV0ToCurrent(
192
+ CacheKeys.CREDENTIAL_SCHEMA_VERSION,
193
+ tokenKeys0.refreshToken,
194
+ tokenKeys1.refreshToken,
195
+ correlationId
196
+ ),
197
+ ]);
198
+
199
+ if (accountKeys0.length > 0) {
200
+ this.browserStorage.setItem(
201
+ CacheKeys.getAccountKeysCacheKey(0),
202
+ JSON.stringify(accountKeys0)
203
+ );
204
+ } else {
205
+ this.browserStorage.removeItem(CacheKeys.getAccountKeysCacheKey(0));
206
+ }
207
+
208
+ if (accountKeys1.length > 0) {
209
+ this.browserStorage.setItem(
210
+ CacheKeys.getAccountKeysCacheKey(1),
211
+ JSON.stringify(accountKeys1)
212
+ );
213
+ } else {
214
+ this.browserStorage.removeItem(CacheKeys.getAccountKeysCacheKey(1));
215
+ }
216
+
217
+ this.setTokenKeys(tokenKeys0, correlationId, 0);
218
+ this.setTokenKeys(tokenKeys1, correlationId, 1);
219
+ }
220
+
221
+ async updateV0ToCurrent(
222
+ currentSchema: number,
223
+ v0Keys: Array<string>,
224
+ v1Keys: Array<string>,
225
+ correlationId: string
226
+ ): Promise<void[]> {
227
+ const upgradePromises: Array<Promise<void>> = [];
228
+
229
+ for (const v0Key of [...v0Keys]) {
230
+ const rawV0Value = this.browserStorage.getItem(v0Key);
231
+ const parsedV0Value = this.validateAndParseJson(
232
+ rawV0Value || ""
233
+ ) as CredentialEntity | AccountEntity | EncryptedData | null;
234
+
235
+ if (!parsedV0Value) {
236
+ removeElementFromArray(v0Keys, v0Key);
237
+ continue;
238
+ }
239
+
240
+ if (!parsedV0Value.lastUpdatedAt) {
241
+ // Add lastUpdatedAt to the existing v0 entry if it doesnt exist so we know when it's safe to remove it
242
+ parsedV0Value.lastUpdatedAt = Date.now().toString();
243
+ this.setItem(
244
+ v0Key,
245
+ JSON.stringify(parsedV0Value),
246
+ correlationId
247
+ );
248
+ }
249
+
250
+ const decryptedData = isEncrypted(parsedV0Value)
251
+ ? await this.browserStorage.decryptData(
252
+ v0Key,
253
+ parsedV0Value,
254
+ correlationId
255
+ )
256
+ : parsedV0Value;
257
+ let expirationTime;
258
+ if (decryptedData) {
259
+ if (CacheHelpers.isAccessTokenEntity(decryptedData)) {
260
+ expirationTime = decryptedData.expiresOn;
261
+ } else if (CacheHelpers.isRefreshTokenEntity(decryptedData)) {
262
+ expirationTime = decryptedData.expiresOn;
263
+ }
264
+ }
265
+ if (
266
+ !decryptedData ||
267
+ TimeUtils.isCacheExpired(
268
+ parsedV0Value.lastUpdatedAt,
269
+ this.cacheConfig.cacheRetentionDays
270
+ ) ||
271
+ (expirationTime &&
272
+ TimeUtils.isTokenExpired(
273
+ expirationTime,
274
+ DEFAULT_TOKEN_RENEWAL_OFFSET_SEC
275
+ ))
276
+ ) {
277
+ this.browserStorage.removeItem(v0Key);
278
+ removeElementFromArray(v0Keys, v0Key);
279
+ this.performanceClient.incrementFields(
280
+ { expiredCacheRemovedCount: 1 },
281
+ correlationId
282
+ );
283
+ continue;
284
+ }
285
+
286
+ if (
287
+ this.cacheConfig.cacheLocation !==
288
+ BrowserCacheLocation.LocalStorage ||
289
+ isEncrypted(parsedV0Value)
290
+ ) {
291
+ const v1Key = `${CacheKeys.PREFIX}.${currentSchema}${CacheKeys.CACHE_KEY_SEPARATOR}${v0Key}`;
292
+ const rawV1Entry = this.browserStorage.getItem(v1Key);
293
+ if (!rawV1Entry) {
294
+ upgradePromises.push(
295
+ this.setUserData(
296
+ v1Key,
297
+ JSON.stringify(decryptedData),
298
+ correlationId,
299
+ parsedV0Value.lastUpdatedAt
300
+ ).then(() => {
301
+ v1Keys.push(v1Key);
302
+ this.performanceClient.incrementFields(
303
+ { upgradedCacheCount: 1 },
304
+ correlationId
305
+ );
306
+ })
307
+ );
308
+ continue;
309
+ } else {
310
+ const parsedV1Entry = this.validateAndParseJson(
311
+ rawV1Entry
312
+ ) as CredentialEntity | AccountEntity | EncryptedData;
313
+ // If the entry already exists but is older than the v0 entry, replace it
314
+ if (
315
+ Number(parsedV0Value.lastUpdatedAt) >
316
+ Number(parsedV1Entry.lastUpdatedAt)
317
+ ) {
318
+ upgradePromises.push(
319
+ this.setUserData(
320
+ v1Key,
321
+ JSON.stringify(decryptedData),
322
+ correlationId,
323
+ parsedV0Value.lastUpdatedAt
324
+ ).then(() => {
325
+ this.performanceClient.incrementFields(
326
+ { updatedCacheFromV0Count: 1 },
327
+ correlationId
328
+ );
329
+ })
330
+ );
331
+ continue;
332
+ }
333
+ }
334
+ }
335
+ /*
336
+ * Note: If we reach here for unencrypted localStorage data, we continue without migrating
337
+ * as we can't migrate unencrypted localStorage data right now since we can't guarantee KMSI=no
338
+ */
339
+ }
340
+
341
+ return Promise.all(upgradePromises);
342
+ }
343
+
131
344
  /**
132
345
  * Tracks upgrades and downgrades for telemetry and debugging purposes
133
346
  */
134
347
  private trackVersionChanges(correlationId: string): void {
135
348
  const previousVersion = this.browserStorage.getItem(
136
- StaticCacheKeys.VERSION
349
+ CacheKeys.VERSION_CACHE_KEY
137
350
  );
138
351
  if (previousVersion) {
139
352
  this.logger.info(
@@ -146,7 +359,7 @@ export class BrowserCacheManager extends CacheManager {
146
359
  }
147
360
 
148
361
  if (previousVersion !== version) {
149
- this.setItem(StaticCacheKeys.VERSION, version, correlationId);
362
+ this.setItem(CacheKeys.VERSION_CACHE_KEY, version, correlationId);
150
363
  }
151
364
  }
152
365
 
@@ -155,6 +368,9 @@ export class BrowserCacheManager extends CacheManager {
155
368
  * @param input
156
369
  */
157
370
  protected validateAndParseJson(jsonValue: string): object | null {
371
+ if (!jsonValue) {
372
+ return null;
373
+ }
158
374
  try {
159
375
  const parsedJson = JSON.parse(jsonValue);
160
376
  /**
@@ -177,6 +393,7 @@ export class BrowserCacheManager extends CacheManager {
177
393
  * @param value
178
394
  */
179
395
  setItem(key: string, value: string, correlationId: string): void {
396
+ let tokenKeysV0Count = 0;
180
397
  let accessTokenKeys: Array<string> = [];
181
398
  const maxRetries = 20;
182
399
  for (let i = 0; i <= maxRetries; i++) {
@@ -184,10 +401,23 @@ export class BrowserCacheManager extends CacheManager {
184
401
  this.browserStorage.setItem(key, value);
185
402
  if (i > 0) {
186
403
  // Finally update the token keys array with the tokens removed
187
- this.removeAccessTokenKeys(
188
- accessTokenKeys.slice(0, i),
189
- correlationId
190
- );
404
+ if (i <= tokenKeysV0Count) {
405
+ this.removeAccessTokenKeys(
406
+ accessTokenKeys.slice(0, i),
407
+ correlationId,
408
+ 0
409
+ );
410
+ } else {
411
+ this.removeAccessTokenKeys(
412
+ accessTokenKeys.slice(0, tokenKeysV0Count),
413
+ correlationId,
414
+ 0
415
+ );
416
+ this.removeAccessTokenKeys(
417
+ accessTokenKeys.slice(tokenKeysV0Count, i),
418
+ correlationId
419
+ );
420
+ }
191
421
  }
192
422
  break; // If setItem succeeds, exit the loop
193
423
  } catch (e) {
@@ -198,17 +428,19 @@ export class BrowserCacheManager extends CacheManager {
198
428
  i < maxRetries
199
429
  ) {
200
430
  if (!accessTokenKeys.length) {
201
- if (
431
+ // If we are currently trying to set the token keys, use the value we're trying to set
432
+ const tokenKeys0 =
433
+ key ===
434
+ CacheKeys.getTokenKeysCacheKey(this.clientId, 0)
435
+ ? (JSON.parse(value) as TokenKeys).accessToken
436
+ : this.getTokenKeys(0).accessToken;
437
+ const tokenKeys1 =
202
438
  key ===
203
- `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`
204
- ) {
205
- // If we are currently trying to set the token keys, use the value we're trying to set
206
- accessTokenKeys = (JSON.parse(value) as TokenKeys)
207
- .accessToken;
208
- } else {
209
- // If token keys have not been initialized, get them
210
- accessTokenKeys = this.getTokenKeys().accessToken;
211
- }
439
+ CacheKeys.getTokenKeysCacheKey(this.clientId)
440
+ ? (JSON.parse(value) as TokenKeys).accessToken
441
+ : this.getTokenKeys().accessToken;
442
+ accessTokenKeys = [...tokenKeys0, ...tokenKeys1];
443
+ tokenKeysV0Count = tokenKeys0.length;
212
444
  }
213
445
  if (accessTokenKeys.length <= i) {
214
446
  // Nothing to remove, rethrow the error
@@ -240,6 +472,7 @@ export class BrowserCacheManager extends CacheManager {
240
472
  correlationId: string,
241
473
  timestamp: string
242
474
  ): Promise<void> {
475
+ let tokenKeysV0Count = 0;
243
476
  let accessTokenKeys: Array<string> = [];
244
477
  const maxRetries = 20;
245
478
  for (let i = 0; i <= maxRetries; i++) {
@@ -252,10 +485,23 @@ export class BrowserCacheManager extends CacheManager {
252
485
  )(key, value, correlationId, timestamp);
253
486
  if (i > 0) {
254
487
  // Finally update the token keys array with the tokens removed
255
- this.removeAccessTokenKeys(
256
- accessTokenKeys.slice(0, i),
257
- correlationId
258
- );
488
+ if (i <= tokenKeysV0Count) {
489
+ this.removeAccessTokenKeys(
490
+ accessTokenKeys.slice(0, i),
491
+ correlationId,
492
+ 0
493
+ );
494
+ } else {
495
+ this.removeAccessTokenKeys(
496
+ accessTokenKeys.slice(0, tokenKeysV0Count),
497
+ correlationId,
498
+ 0
499
+ );
500
+ this.removeAccessTokenKeys(
501
+ accessTokenKeys.slice(tokenKeysV0Count, i),
502
+ correlationId
503
+ );
504
+ }
259
505
  }
260
506
  break; // If setItem succeeds, exit the loop
261
507
  } catch (e) {
@@ -266,7 +512,10 @@ export class BrowserCacheManager extends CacheManager {
266
512
  i < maxRetries
267
513
  ) {
268
514
  if (!accessTokenKeys.length) {
269
- accessTokenKeys = this.getTokenKeys().accessToken;
515
+ const tokenKeys0 = this.getTokenKeys(0).accessToken;
516
+ const tokenKeys1 = this.getTokenKeys().accessToken;
517
+ accessTokenKeys = [...tokenKeys0, ...tokenKeys1];
518
+ tokenKeysV0Count = tokenKeys0.length;
270
519
  }
271
520
  if (accessTokenKeys.length <= i) {
272
521
  // Nothing left to remove, rethrow the error
@@ -323,7 +572,7 @@ export class BrowserCacheManager extends CacheManager {
323
572
  correlationId: string
324
573
  ): Promise<void> {
325
574
  this.logger.trace("BrowserCacheManager.setAccount called");
326
- const key = account.generateAccountKey();
575
+ const key = this.generateAccountKey(account.getAccountInfo());
327
576
  const timestamp = Date.now().toString();
328
577
  account.lastUpdatedAt = timestamp;
329
578
  await this.setUserData(
@@ -372,7 +621,7 @@ export class BrowserCacheManager extends CacheManager {
372
621
  // Only add key if it does not already exist in the map
373
622
  accountKeys.push(key);
374
623
  this.setItem(
375
- StaticCacheKeys.ACCOUNT_KEYS,
624
+ CacheKeys.getAccountKeysCacheKey(),
376
625
  JSON.stringify(accountKeys),
377
626
  correlationId
378
627
  );
@@ -403,11 +652,11 @@ export class BrowserCacheManager extends CacheManager {
403
652
  accountKeys.splice(removalIndex, 1);
404
653
  if (accountKeys.length === 0) {
405
654
  // If no keys left, remove the map
406
- this.removeItem(StaticCacheKeys.ACCOUNT_KEYS);
655
+ this.removeItem(CacheKeys.getAccountKeysCacheKey());
407
656
  return;
408
657
  } else {
409
658
  this.setItem(
410
- StaticCacheKeys.ACCOUNT_KEYS,
659
+ CacheKeys.getAccountKeysCacheKey(),
411
660
  JSON.stringify(accountKeys),
412
661
  correlationId
413
662
  );
@@ -426,17 +675,30 @@ export class BrowserCacheManager extends CacheManager {
426
675
  * Extends inherited removeAccount function to include removal of the account key from the map
427
676
  * @param key
428
677
  */
429
- removeAccount(key: string, correlationId: string): void {
430
- super.removeAccount(key, correlationId);
431
- this.removeAccountKeyFromMap(key, correlationId);
432
- }
678
+ removeAccount(account: AccountInfo, correlationId: string): void {
679
+ const activeAccount = this.getActiveAccount(correlationId);
680
+ if (
681
+ activeAccount?.homeAccountId === account.homeAccountId &&
682
+ activeAccount?.environment === account.environment
683
+ ) {
684
+ this.setActiveAccount(null, correlationId);
685
+ }
433
686
 
434
- /**
435
- * Removes credentials associated with the provided account
436
- * @param account
437
- */
438
- removeAccountContext(account: AccountEntity, correlationId: string): void {
439
- super.removeAccountContext(account, correlationId);
687
+ super.removeAccount(account, correlationId);
688
+ this.removeAccountKeyFromMap(
689
+ this.generateAccountKey(account),
690
+ correlationId
691
+ );
692
+
693
+ // Remove all other associated cache items
694
+ this.browserStorage.getKeys().forEach((key) => {
695
+ if (
696
+ key.includes(account.homeAccountId) &&
697
+ key.includes(account.environment)
698
+ ) {
699
+ this.browserStorage.removeItem(key);
700
+ }
701
+ });
440
702
 
441
703
  /**
442
704
  * @deprecated - Remove this in next major version in favor of more consistent LOGOUT event
@@ -447,7 +709,7 @@ export class BrowserCacheManager extends CacheManager {
447
709
  this.eventHandler.emitEvent(
448
710
  EventType.ACCOUNT_REMOVED,
449
711
  undefined,
450
- account.getAccountInfo()
712
+ account
451
713
  );
452
714
  }
453
715
  }
@@ -486,9 +748,13 @@ export class BrowserCacheManager extends CacheManager {
486
748
  * @param correlationId
487
749
  * @param tokenKeys
488
750
  */
489
- removeAccessTokenKeys(keys: Array<string>, correlationId: string): void {
751
+ removeAccessTokenKeys(
752
+ keys: Array<string>,
753
+ correlationId: string,
754
+ schemaVersion: number = CacheKeys.CREDENTIAL_SCHEMA_VERSION
755
+ ): void {
490
756
  this.logger.trace("removeAccessTokenKey called");
491
- const tokenKeys = this.getTokenKeys();
757
+ const tokenKeys = this.getTokenKeys(schemaVersion);
492
758
  let keysRemoved = 0;
493
759
  keys.forEach((key) => {
494
760
  const accessRemoval = tokenKeys.accessToken.indexOf(key);
@@ -502,7 +768,7 @@ export class BrowserCacheManager extends CacheManager {
502
768
  this.logger.info(
503
769
  `removed ${keysRemoved} accessToken keys from tokenKeys map`
504
770
  );
505
- this.setTokenKeys(tokenKeys, correlationId);
771
+ this.setTokenKeys(tokenKeys, correlationId, schemaVersion);
506
772
  return;
507
773
  }
508
774
  }
@@ -526,8 +792,10 @@ export class BrowserCacheManager extends CacheManager {
526
792
  * Gets the keys for the cached tokens associated with this clientId
527
793
  * @returns
528
794
  */
529
- getTokenKeys(): TokenKeys {
530
- return getTokenKeys(this.clientId, this.browserStorage);
795
+ getTokenKeys(
796
+ schemaVersion: number = CacheKeys.CREDENTIAL_SCHEMA_VERSION
797
+ ): TokenKeys {
798
+ return getTokenKeys(this.clientId, this.browserStorage, schemaVersion);
531
799
  }
532
800
 
533
801
  /**
@@ -536,18 +804,24 @@ export class BrowserCacheManager extends CacheManager {
536
804
  * @param correlationId
537
805
  * @returns
538
806
  */
539
- setTokenKeys(tokenKeys: TokenKeys, correlationId: string): void {
807
+ setTokenKeys(
808
+ tokenKeys: TokenKeys,
809
+ correlationId: string,
810
+ schemaVersion: number = CacheKeys.CREDENTIAL_SCHEMA_VERSION
811
+ ): void {
540
812
  if (
541
813
  tokenKeys.idToken.length === 0 &&
542
814
  tokenKeys.accessToken.length === 0 &&
543
815
  tokenKeys.refreshToken.length === 0
544
816
  ) {
545
817
  // If no keys left, remove the map
546
- this.removeItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
818
+ this.removeItem(
819
+ CacheKeys.getTokenKeysCacheKey(this.clientId, schemaVersion)
820
+ );
547
821
  return;
548
822
  } else {
549
823
  this.setItem(
550
- `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`,
824
+ CacheKeys.getTokenKeysCacheKey(this.clientId, schemaVersion),
551
825
  JSON.stringify(tokenKeys),
552
826
  correlationId
553
827
  );
@@ -594,7 +868,7 @@ export class BrowserCacheManager extends CacheManager {
594
868
  correlationId: string
595
869
  ): Promise<void> {
596
870
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
597
- const idTokenKey = CacheHelpers.generateCredentialKey(idToken);
871
+ const idTokenKey = this.generateCredentialKey(idToken);
598
872
  const timestamp = Date.now().toString();
599
873
  idToken.lastUpdatedAt = timestamp;
600
874
 
@@ -659,7 +933,7 @@ export class BrowserCacheManager extends CacheManager {
659
933
  this.logger.trace(
660
934
  "BrowserCacheManager.setAccessTokenCredential called"
661
935
  );
662
- const accessTokenKey = CacheHelpers.generateCredentialKey(accessToken);
936
+ const accessTokenKey = this.generateCredentialKey(accessToken);
663
937
  const timestamp = Date.now().toString();
664
938
  accessToken.lastUpdatedAt = timestamp;
665
939
 
@@ -726,8 +1000,7 @@ export class BrowserCacheManager extends CacheManager {
726
1000
  this.logger.trace(
727
1001
  "BrowserCacheManager.setRefreshTokenCredential called"
728
1002
  );
729
- const refreshTokenKey =
730
- CacheHelpers.generateCredentialKey(refreshToken);
1003
+ const refreshTokenKey = this.generateCredentialKey(refreshToken);
731
1004
  const timestamp = Date.now().toString();
732
1005
  refreshToken.lastUpdatedAt = timestamp;
733
1006
 
@@ -1141,7 +1414,7 @@ export class BrowserCacheManager extends CacheManager {
1141
1414
  // Remove temp storage first to make sure any cookies are cleared
1142
1415
  this.temporaryCacheStorage.getKeys().forEach((cacheKey: string) => {
1143
1416
  if (
1144
- cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
1417
+ cacheKey.indexOf(CacheKeys.PREFIX) !== -1 ||
1145
1418
  cacheKey.indexOf(this.clientId) !== -1
1146
1419
  ) {
1147
1420
  this.removeTemporaryItem(cacheKey);
@@ -1151,7 +1424,7 @@ export class BrowserCacheManager extends CacheManager {
1151
1424
  // Removes all remaining MSAL cache items
1152
1425
  this.browserStorage.getKeys().forEach((cacheKey: string) => {
1153
1426
  if (
1154
- cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
1427
+ cacheKey.indexOf(CacheKeys.PREFIX) !== -1 ||
1155
1428
  cacheKey.indexOf(this.clientId) !== -1
1156
1429
  ) {
1157
1430
  this.browserStorage.removeItem(cacheKey);
@@ -1199,20 +1472,66 @@ export class BrowserCacheManager extends CacheManager {
1199
1472
  }
1200
1473
 
1201
1474
  /**
1202
- * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
1475
+ * Prepend msal.<client-id> to each key
1203
1476
  * @param key
1204
1477
  * @param addInstanceId
1205
1478
  */
1206
1479
  generateCacheKey(key: string): string {
1207
- const generatedKey = this.validateAndParseJson(key);
1208
- if (!generatedKey) {
1209
- if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
1210
- return key;
1211
- }
1212
- return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
1480
+ if (StringUtils.startsWith(key, CacheKeys.PREFIX)) {
1481
+ return key;
1213
1482
  }
1483
+ return `${CacheKeys.PREFIX}.${this.clientId}.${key}`;
1484
+ }
1214
1485
 
1215
- return JSON.stringify(key);
1486
+ /**
1487
+ * Cache Key: msal.<schema_version>-<home_account_id>-<environment>-<credential_type>-<client_id or familyId>-<realm>-<scopes>-<claims hash>-<scheme>
1488
+ * IdToken Example: uid.utid-login.microsoftonline.com-idtoken-app_client_id-contoso.com
1489
+ * AccessToken Example: uid.utid-login.microsoftonline.com-accesstoken-app_client_id-contoso.com-scope1 scope2--pop
1490
+ * RefreshToken Example: uid.utid-login.microsoftonline.com-refreshtoken-1-contoso.com
1491
+ * @param credentialEntity
1492
+ * @returns
1493
+ */
1494
+ generateCredentialKey(credential: CredentialEntity): string {
1495
+ const familyId =
1496
+ (credential.credentialType === CredentialType.REFRESH_TOKEN &&
1497
+ credential.familyId) ||
1498
+ credential.clientId;
1499
+ const scheme =
1500
+ credential.tokenType &&
1501
+ credential.tokenType.toLowerCase() !==
1502
+ AuthenticationScheme.BEARER.toLowerCase()
1503
+ ? credential.tokenType.toLowerCase()
1504
+ : "";
1505
+ const credentialKey = [
1506
+ `${CacheKeys.PREFIX}.${CacheKeys.CREDENTIAL_SCHEMA_VERSION}`,
1507
+ credential.homeAccountId,
1508
+ credential.environment,
1509
+ credential.credentialType,
1510
+ familyId,
1511
+ credential.realm || "",
1512
+ credential.target || "",
1513
+ credential.requestedClaimsHash || "",
1514
+ scheme,
1515
+ ];
1516
+
1517
+ return credentialKey.join(CacheKeys.CACHE_KEY_SEPARATOR).toLowerCase();
1518
+ }
1519
+
1520
+ /**
1521
+ * Cache Key: msal.<schema_version>.<home_account_id>.<environment>.<tenant_id>
1522
+ * @param account
1523
+ * @returns
1524
+ */
1525
+ generateAccountKey(account: AccountInfo): string {
1526
+ const homeTenantId = account.homeAccountId.split(".")[1];
1527
+ const accountKey = [
1528
+ `${CacheKeys.PREFIX}.${CacheKeys.ACCOUNT_SCHEMA_VERSION}`,
1529
+ account.homeAccountId,
1530
+ account.environment,
1531
+ homeTenantId || account.tenantId || "",
1532
+ ];
1533
+
1534
+ return accountKey.join(CacheKeys.CACHE_KEY_SEPARATOR).toLowerCase();
1216
1535
  }
1217
1536
 
1218
1537
  /**
@@ -1346,7 +1665,7 @@ export class BrowserCacheManager extends CacheManager {
1346
1665
  clientId: string;
1347
1666
  type: INTERACTION_TYPE;
1348
1667
  } | null {
1349
- const key = `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;
1668
+ const key = `${CacheKeys.PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;
1350
1669
  const value = this.getTemporaryCache(key, false);
1351
1670
  try {
1352
1671
  return value ? JSON.parse(value) : null;
@@ -1367,7 +1686,7 @@ export class BrowserCacheManager extends CacheManager {
1367
1686
  type: INTERACTION_TYPE = INTERACTION_TYPE.SIGNIN
1368
1687
  ): void {
1369
1688
  // Ensure we don't overwrite interaction in progress for a different clientId
1370
- const key = `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;
1689
+ const key = `${CacheKeys.PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;
1371
1690
  if (inProgress) {
1372
1691
  if (this.getInteractionInProgress()) {
1373
1692
  throw createBrowserAuthError(
@@ -1530,6 +1849,7 @@ export const DEFAULT_BROWSER_CACHE_MANAGER = (
1530
1849
  ): BrowserCacheManager => {
1531
1850
  const cacheOptions: Required<CacheOptions> = {
1532
1851
  cacheLocation: BrowserCacheLocation.MemoryStorage,
1852
+ cacheRetentionDays: 5,
1533
1853
  temporaryCacheLocation: BrowserCacheLocation.MemoryStorage,
1534
1854
  storeAuthStateInCookie: false,
1535
1855
  secureCookies: false,