@azure/msal-browser 3.1.0 → 3.3.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 (282) hide show
  1. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  2. package/dist/app/IPublicClientApplication.mjs +20 -19
  3. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientApplication.d.ts +14 -6
  5. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  6. package/dist/app/PublicClientApplication.mjs +18 -8
  7. package/dist/app/PublicClientApplication.mjs.map +1 -1
  8. package/dist/app/PublicClientNext.d.ts +274 -0
  9. package/dist/app/PublicClientNext.d.ts.map +1 -0
  10. package/dist/app/PublicClientNext.mjs +362 -0
  11. package/dist/app/PublicClientNext.mjs.map +1 -0
  12. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
  13. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +13 -13
  15. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  16. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
  17. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
  18. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
  19. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
  20. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  21. package/dist/cache/BrowserCacheManager.d.ts +4 -15
  22. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  23. package/dist/cache/BrowserCacheManager.mjs +13 -69
  24. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  25. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  26. package/dist/cache/BrowserStorage.mjs +7 -9
  27. package/dist/cache/BrowserStorage.mjs.map +1 -1
  28. package/dist/cache/CryptoKeyStore.mjs +1 -1
  29. package/dist/cache/DatabaseStorage.mjs +1 -1
  30. package/dist/cache/MemoryStorage.mjs +1 -1
  31. package/dist/cache/TokenCache.mjs +1 -1
  32. package/dist/config/Configuration.d.ts +4 -0
  33. package/dist/config/Configuration.d.ts.map +1 -1
  34. package/dist/config/Configuration.mjs +8 -7
  35. package/dist/config/Configuration.mjs.map +1 -1
  36. package/dist/controllers/ControllerFactory.d.ts +2 -1
  37. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  38. package/dist/controllers/ControllerFactory.mjs +26 -19
  39. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  40. package/dist/controllers/IController.d.ts +3 -2
  41. package/dist/controllers/IController.d.ts.map +1 -1
  42. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  43. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  44. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  45. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  46. package/dist/controllers/StandardController.d.ts +11 -6
  47. package/dist/controllers/StandardController.d.ts.map +1 -1
  48. package/dist/controllers/StandardController.mjs +67 -45
  49. package/dist/controllers/StandardController.mjs.map +1 -1
  50. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  51. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  52. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  53. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  54. package/dist/crypto/BrowserCrypto.d.ts +44 -49
  55. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  56. package/dist/crypto/BrowserCrypto.mjs +77 -77
  57. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  58. package/dist/crypto/CryptoOps.d.ts +1 -7
  59. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  60. package/dist/crypto/CryptoOps.mjs +18 -23
  61. package/dist/crypto/CryptoOps.mjs.map +1 -1
  62. package/dist/crypto/PkceGenerator.d.ts +6 -21
  63. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  64. package/dist/crypto/PkceGenerator.mjs +45 -46
  65. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  66. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  67. package/dist/encode/Base64Decode.d.ts.map +1 -1
  68. package/dist/encode/Base64Decode.mjs +18 -2
  69. package/dist/encode/Base64Decode.mjs.map +1 -1
  70. package/dist/encode/Base64Encode.mjs +1 -1
  71. package/dist/error/BrowserAuthError.d.ts +10 -1
  72. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  73. package/dist/error/BrowserAuthError.mjs +12 -3
  74. package/dist/error/BrowserAuthError.mjs.map +1 -1
  75. package/dist/error/BrowserAuthErrorCodes.d.ts +1 -0
  76. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  77. package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
  78. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  79. package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
  80. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  81. package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
  82. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  83. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
  84. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
  85. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
  86. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
  87. package/dist/error/NativeAuthError.d.ts +17 -45
  88. package/dist/error/NativeAuthError.d.ts.map +1 -1
  89. package/dist/error/NativeAuthError.mjs +47 -78
  90. package/dist/error/NativeAuthError.mjs.map +1 -1
  91. package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
  92. package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
  93. package/dist/error/NativeAuthErrorCodes.mjs +11 -0
  94. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
  95. package/dist/error/NestedAppAuthError.d.ts +15 -0
  96. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  97. package/dist/error/NestedAppAuthError.mjs +30 -0
  98. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  99. package/dist/event/EventHandler.d.ts.map +1 -1
  100. package/dist/event/EventHandler.mjs +3 -2
  101. package/dist/event/EventHandler.mjs.map +1 -1
  102. package/dist/event/EventMessage.mjs +1 -1
  103. package/dist/event/EventType.mjs +1 -1
  104. package/dist/index.d.ts +5 -7
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.mjs +7 -3
  107. package/dist/index.mjs.map +1 -1
  108. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  109. package/dist/interaction_client/BaseInteractionClient.mjs +10 -11
  110. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  111. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  112. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  113. package/dist/interaction_client/NativeInteractionClient.mjs +26 -13
  114. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  115. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  116. package/dist/interaction_client/PopupClient.mjs +5 -4
  117. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  118. package/dist/interaction_client/RedirectClient.mjs +7 -7
  119. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  120. package/dist/interaction_client/SilentAuthCodeClient.mjs +7 -10
  121. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  122. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  123. package/dist/interaction_client/SilentCacheClient.mjs +11 -18
  124. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  125. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  126. package/dist/interaction_client/SilentIframeClient.mjs +27 -13
  127. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  128. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  129. package/dist/interaction_client/SilentRefreshClient.mjs +8 -18
  130. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  131. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  132. package/dist/interaction_client/StandardInteractionClient.mjs +16 -37
  133. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  134. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  135. package/dist/interaction_handler/InteractionHandler.mjs +6 -9
  136. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  137. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  138. package/dist/interaction_handler/RedirectHandler.mjs +3 -3
  139. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  140. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  141. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  142. package/dist/interaction_handler/SilentHandler.mjs +120 -156
  143. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  144. package/dist/naa/AccountInfo.d.ts +13 -0
  145. package/dist/naa/AccountInfo.d.ts.map +1 -0
  146. package/dist/naa/AccountRequests.d.ts +10 -0
  147. package/dist/naa/AccountRequests.d.ts.map +1 -0
  148. package/dist/naa/AuthBridge.d.ts +6 -0
  149. package/dist/naa/AuthBridge.d.ts.map +1 -0
  150. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  151. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  152. package/dist/naa/BridgeError.d.ts +10 -0
  153. package/dist/naa/BridgeError.d.ts.map +1 -0
  154. package/dist/naa/BridgeError.mjs +12 -0
  155. package/dist/naa/BridgeError.mjs.map +1 -0
  156. package/dist/naa/BridgeProxy.d.ts +72 -0
  157. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  158. package/dist/naa/BridgeProxy.mjs +154 -0
  159. package/dist/naa/BridgeProxy.mjs.map +1 -0
  160. package/dist/naa/BridgeRequest.d.ts +7 -0
  161. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  162. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  163. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  164. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  165. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  166. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  167. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  168. package/dist/naa/BridgeStatusCode.mjs +20 -0
  169. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  170. package/dist/naa/IBridgeProxy.d.ts +11 -0
  171. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  172. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  173. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  174. package/dist/naa/TokenRequest.d.ts +22 -0
  175. package/dist/naa/TokenRequest.d.ts.map +1 -0
  176. package/dist/naa/TokenResponse.d.ts +17 -0
  177. package/dist/naa/TokenResponse.d.ts.map +1 -0
  178. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  179. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  180. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  181. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  182. package/dist/navigation/NavigationClient.mjs +1 -1
  183. package/dist/network/FetchClient.mjs +1 -1
  184. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  185. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  186. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  187. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  188. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  189. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  190. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  191. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  192. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  193. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  194. package/dist/packageMetadata.d.ts +1 -1
  195. package/dist/packageMetadata.mjs +2 -2
  196. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  197. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  198. package/dist/utils/BrowserConstants.mjs +1 -1
  199. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  200. package/dist/utils/BrowserProtocolUtils.mjs +3 -3
  201. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  202. package/dist/utils/BrowserUtils.d.ts +54 -53
  203. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  204. package/dist/utils/BrowserUtils.mjs +114 -102
  205. package/dist/utils/BrowserUtils.mjs.map +1 -1
  206. package/lib/msal-browser.cjs +61 -18042
  207. package/lib/msal-browser.cjs.map +1 -1
  208. package/lib/msal-browser.js +13593 -12505
  209. package/lib/msal-browser.js.map +1 -1
  210. package/lib/msal-browser.min.js +66 -65
  211. package/package.json +2 -2
  212. package/src/app/IPublicClientApplication.ts +55 -18
  213. package/src/app/PublicClientApplication.ts +19 -7
  214. package/src/app/PublicClientNext.ts +442 -0
  215. package/src/broker/nativeBroker/NativeMessageHandler.ts +12 -15
  216. package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
  217. package/src/cache/BrowserCacheManager.ts +29 -103
  218. package/src/cache/BrowserStorage.ts +9 -11
  219. package/src/config/Configuration.ts +21 -8
  220. package/src/controllers/ControllerFactory.ts +36 -25
  221. package/src/controllers/IController.ts +4 -1
  222. package/src/controllers/NestedAppAuthController.ts +525 -0
  223. package/src/controllers/StandardController.ts +163 -98
  224. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  225. package/src/crypto/BrowserCrypto.ts +119 -103
  226. package/src/crypto/CryptoOps.ts +18 -27
  227. package/src/crypto/PkceGenerator.ts +93 -54
  228. package/src/encode/Base64Decode.ts +21 -1
  229. package/src/error/BrowserAuthError.ts +13 -1
  230. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  231. package/src/error/BrowserConfigurationAuthError.ts +33 -102
  232. package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
  233. package/src/error/NativeAuthError.ts +73 -101
  234. package/src/error/NativeAuthErrorCodes.ts +7 -0
  235. package/src/error/NestedAppAuthError.ts +32 -0
  236. package/src/event/EventHandler.ts +2 -1
  237. package/src/index.ts +8 -10
  238. package/src/interaction_client/BaseInteractionClient.ts +14 -8
  239. package/src/interaction_client/NativeInteractionClient.ts +48 -14
  240. package/src/interaction_client/PopupClient.ts +2 -1
  241. package/src/interaction_client/RedirectClient.ts +1 -1
  242. package/src/interaction_client/SilentAuthCodeClient.ts +22 -19
  243. package/src/interaction_client/SilentCacheClient.ts +28 -28
  244. package/src/interaction_client/SilentIframeClient.ts +54 -18
  245. package/src/interaction_client/SilentRefreshClient.ts +26 -28
  246. package/src/interaction_client/StandardInteractionClient.ts +37 -68
  247. package/src/interaction_handler/InteractionHandler.ts +20 -15
  248. package/src/interaction_handler/RedirectHandler.ts +6 -2
  249. package/src/interaction_handler/SilentHandler.ts +177 -230
  250. package/src/naa/AccountInfo.ts +17 -0
  251. package/src/naa/AccountRequests.ts +16 -0
  252. package/src/naa/AuthBridge.ts +16 -0
  253. package/src/naa/BridgeCapabilities.ts +8 -0
  254. package/src/naa/BridgeError.ts +18 -0
  255. package/src/naa/BridgeProxy.ts +230 -0
  256. package/src/naa/BridgeRequest.ts +12 -0
  257. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  258. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  259. package/src/naa/BridgeStatusCode.ts +15 -0
  260. package/src/naa/IBridgeProxy.ts +25 -0
  261. package/src/naa/InitializeBridgeResponse.ts +12 -0
  262. package/src/naa/TokenRequest.ts +26 -0
  263. package/src/naa/TokenResponse.ts +61 -0
  264. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  265. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  266. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  267. package/src/packageMetadata.ts +1 -1
  268. package/src/utils/BrowserProtocolUtils.ts +3 -2
  269. package/src/utils/BrowserUtils.ts +133 -125
  270. package/dist/crypto/ISubtleCrypto.d.ts +0 -10
  271. package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
  272. package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
  273. package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
  274. package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
  275. package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
  276. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  277. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  278. package/dist/utils/BrowserStringUtils.mjs +0 -144
  279. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  280. package/src/crypto/ISubtleCrypto.ts +0 -30
  281. package/src/crypto/ModernBrowserCrypto.ts +0 -69
  282. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -11,7 +11,7 @@ import {
11
11
  AccountInfo,
12
12
  AzureCloudOptions,
13
13
  PerformanceEvents,
14
- AuthError,
14
+ invokeAsync,
15
15
  } from "@azure/msal-common";
16
16
  import { SilentRequest } from "../request/SilentRequest";
17
17
  import { ApiId } from "../utils/BrowserConstants";
@@ -30,7 +30,7 @@ export class SilentCacheClient extends StandardInteractionClient {
30
30
  async acquireToken(
31
31
  silentRequest: CommonSilentFlowRequest
32
32
  ): Promise<AuthenticationResult> {
33
- const acquireTokenMeasurement = this.performanceClient.startMeasurement(
33
+ this.performanceClient.addQueueMeasurement(
34
34
  PerformanceEvents.SilentCacheClientAcquireToken,
35
35
  silentRequest.correlationId
36
36
  );
@@ -47,15 +47,22 @@ export class SilentCacheClient extends StandardInteractionClient {
47
47
  this.logger.verbose("Silent auth client created");
48
48
 
49
49
  try {
50
- const cachedToken = (await silentAuthClient.acquireCachedToken(
51
- silentRequest
52
- )) as AuthenticationResult;
50
+ const response = await invokeAsync(
51
+ silentAuthClient.acquireCachedToken.bind(silentAuthClient),
52
+ PerformanceEvents.SilentFlowClientAcquireCachedToken,
53
+ this.logger,
54
+ this.performanceClient,
55
+ silentRequest.correlationId
56
+ )(silentRequest);
57
+ const authResponse = response[0] as AuthenticationResult;
53
58
 
54
- acquireTokenMeasurement.end({
55
- success: true,
56
- fromCache: true,
57
- });
58
- return cachedToken;
59
+ this.performanceClient.addFields(
60
+ {
61
+ fromCache: true,
62
+ },
63
+ silentRequest.correlationId
64
+ );
65
+ return authResponse;
59
66
  } catch (error) {
60
67
  if (
61
68
  error instanceof BrowserAuthError &&
@@ -65,14 +72,6 @@ export class SilentCacheClient extends StandardInteractionClient {
65
72
  "Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair."
66
73
  );
67
74
  }
68
- acquireTokenMeasurement.end({
69
- errorCode:
70
- (error instanceof AuthError && error.errorCode) ||
71
- undefined,
72
- subErrorCode:
73
- (error instanceof AuthError && error.subError) || undefined,
74
- success: false,
75
- });
76
75
  throw error;
77
76
  }
78
77
  }
@@ -98,15 +97,13 @@ export class SilentCacheClient extends StandardInteractionClient {
98
97
  azureCloudOptions?: AzureCloudOptions
99
98
  ): Promise<SilentFlowClient> {
100
99
  // Create auth module.
101
- this.performanceClient.setPreQueueTime(
100
+ const clientConfig = await invokeAsync(
101
+ this.getClientConfiguration.bind(this),
102
102
  PerformanceEvents.StandardInteractionClientGetClientConfiguration,
103
+ this.logger,
104
+ this.performanceClient,
103
105
  this.correlationId
104
- );
105
- const clientConfig = await this.getClientConfiguration(
106
- serverTelemetryManager,
107
- authorityUrl,
108
- azureCloudOptions
109
- );
106
+ )(serverTelemetryManager, authorityUrl, azureCloudOptions);
110
107
  return new SilentFlowClient(clientConfig, this.performanceClient);
111
108
  }
112
109
 
@@ -119,13 +116,16 @@ export class SilentCacheClient extends StandardInteractionClient {
119
116
  this.correlationId
120
117
  );
121
118
 
122
- this.performanceClient.setPreQueueTime(
119
+ const baseRequest = await invokeAsync(
120
+ this.initializeBaseRequest.bind(this),
123
121
  PerformanceEvents.InitializeBaseRequest,
122
+ this.logger,
123
+ this.performanceClient,
124
124
  this.correlationId
125
- );
125
+ )(request, account);
126
126
  return {
127
127
  ...request,
128
- ...(await this.initializeBaseRequest(request, account)),
128
+ ...baseRequest,
129
129
  account: account,
130
130
  forceRefresh: request.forceRefresh || false,
131
131
  };
@@ -29,11 +29,16 @@ import {
29
29
  BrowserAuthErrorCodes,
30
30
  } from "../error/BrowserAuthError";
31
31
  import { InteractionType, ApiId } from "../utils/BrowserConstants";
32
- import { SilentHandler } from "../interaction_handler/SilentHandler";
32
+ import {
33
+ initiateAuthRequest,
34
+ monitorIframeForHash,
35
+ } from "../interaction_handler/SilentHandler";
33
36
  import { SsoSilentRequest } from "../request/SsoSilentRequest";
34
37
  import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
35
38
  import { NativeInteractionClient } from "./NativeInteractionClient";
36
39
  import { AuthenticationResult } from "../response/AuthenticationResult";
40
+ import { InteractionHandler } from "../interaction_handler/InteractionHandler";
41
+ import * as BrowserUtils from "../utils/BrowserUtils";
37
42
 
38
43
  export class SilentIframeClient extends StandardInteractionClient {
39
44
  protected apiId: ApiId;
@@ -114,6 +119,7 @@ export class SilentIframeClient extends StandardInteractionClient {
114
119
  },
115
120
  InteractionType.Silent
116
121
  );
122
+ BrowserUtils.preconnect(silentRequest.authority);
117
123
  this.browserStorage.updateCacheEntries(
118
124
  silentRequest.state,
119
125
  silentRequest.nonce,
@@ -179,9 +185,10 @@ export class SilentIframeClient extends StandardInteractionClient {
179
185
  authClient: AuthorizationCodeClient,
180
186
  silentRequest: AuthorizationUrlRequest
181
187
  ): Promise<AuthenticationResult> {
188
+ const correlationId = silentRequest.correlationId;
182
189
  this.performanceClient.addQueueMeasurement(
183
190
  PerformanceEvents.SilentIframeClientTokenHelper,
184
- silentRequest.correlationId
191
+ correlationId
185
192
  );
186
193
 
187
194
  // Create auth code request and generate PKCE params
@@ -191,7 +198,7 @@ export class SilentIframeClient extends StandardInteractionClient {
191
198
  PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
192
199
  this.logger,
193
200
  this.performanceClient,
194
- silentRequest.correlationId
201
+ correlationId
195
202
  )(silentRequest);
196
203
 
197
204
  // Create authorize request url
@@ -200,7 +207,7 @@ export class SilentIframeClient extends StandardInteractionClient {
200
207
  PerformanceEvents.GetAuthCodeUrl,
201
208
  this.logger,
202
209
  this.performanceClient,
203
- silentRequest.correlationId
210
+ correlationId
204
211
  )({
205
212
  ...silentRequest,
206
213
  nativeBroker: NativeMessageHandler.isNativeAvailable(
@@ -212,37 +219,64 @@ export class SilentIframeClient extends StandardInteractionClient {
212
219
  });
213
220
 
214
221
  // Create silent handler
215
- const silentHandler = new SilentHandler(
222
+ const interactionHandler = new InteractionHandler(
216
223
  authClient,
217
224
  this.browserStorage,
218
225
  authCodeRequest,
219
226
  this.logger,
220
- this.config.system,
221
227
  this.performanceClient
222
228
  );
223
229
  // Get the frame handle for the silent request
224
230
  const msalFrame = await invokeAsync(
225
- silentHandler.initiateAuthRequest.bind(silentHandler),
231
+ initiateAuthRequest,
226
232
  PerformanceEvents.SilentHandlerInitiateAuthRequest,
227
233
  this.logger,
228
234
  this.performanceClient,
229
- silentRequest.correlationId
230
- )(navigateUrl);
235
+ correlationId
236
+ )(
237
+ navigateUrl,
238
+ this.performanceClient,
239
+ this.logger,
240
+ correlationId,
241
+ this.config.system.navigateFrameWait
242
+ );
231
243
  // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
232
244
  const hash = await invokeAsync(
233
- silentHandler.monitorIframeForHash.bind(silentHandler),
234
- PerformanceEvents.SilentHandlerInitiateAuthRequest,
245
+ monitorIframeForHash,
246
+ PerformanceEvents.SilentHandlerMonitorIframeForHash,
235
247
  this.logger,
236
248
  this.performanceClient,
237
- silentRequest.correlationId
238
- )(msalFrame, this.config.system.iframeHashTimeout);
249
+ correlationId
250
+ )(
251
+ msalFrame,
252
+ this.config.system.iframeHashTimeout,
253
+ this.config.system.pollIntervalMilliseconds,
254
+ this.performanceClient,
255
+ this.logger,
256
+ correlationId
257
+ );
258
+ if (!hash) {
259
+ // No hash is present
260
+ this.logger.error(
261
+ "The request has returned to the redirectUri but a hash is not present in the iframe. It's likely that the hash has been removed or the page has been redirected by code running on the redirectUri page."
262
+ );
263
+ throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
264
+ } else if (!UrlString.hashContainsKnownProperties(hash)) {
265
+ this.logger.error(
266
+ "A hash is present in the iframe but it does not contain known properties. It's likely that the hash has been replaced by code running on the redirectUri page."
267
+ );
268
+ this.logger.errorPii(`The hash detected in the iframe is: ${hash}`);
269
+ throw createBrowserAuthError(
270
+ BrowserAuthErrorCodes.hashDoesNotContainKnownProperties
271
+ );
272
+ }
239
273
  // Deserialize hash fragment response parameters.
240
274
  const serverParams: ServerAuthorizationCodeResponse =
241
275
  UrlString.getDeserializedHash(hash);
242
276
  const state = this.validateAndExtractStateFromHash(
243
277
  serverParams,
244
278
  InteractionType.Silent,
245
- authCodeRequest.correlationId
279
+ correlationId
246
280
  );
247
281
 
248
282
  if (serverParams.accountId) {
@@ -266,7 +300,7 @@ export class SilentIframeClient extends StandardInteractionClient {
266
300
  this.nativeMessageHandler,
267
301
  serverParams.accountId,
268
302
  this.browserStorage,
269
- this.correlationId
303
+ correlationId
270
304
  );
271
305
  const { userRequestState } = ProtocolUtils.parseRequestState(
272
306
  this.browserCrypto,
@@ -279,7 +313,7 @@ export class SilentIframeClient extends StandardInteractionClient {
279
313
  PerformanceEvents.NativeInteractionClientAcquireToken,
280
314
  this.logger,
281
315
  this.performanceClient,
282
- silentRequest.correlationId
316
+ correlationId
283
317
  )({
284
318
  ...silentRequest,
285
319
  state: userRequestState,
@@ -291,11 +325,13 @@ export class SilentIframeClient extends StandardInteractionClient {
291
325
 
292
326
  // Handle response from hash string
293
327
  return invokeAsync(
294
- silentHandler.handleCodeResponseFromHash.bind(silentHandler),
328
+ interactionHandler.handleCodeResponseFromHash.bind(
329
+ interactionHandler
330
+ ),
295
331
  PerformanceEvents.HandleCodeResponseFromHash,
296
332
  this.logger,
297
333
  this.performanceClient,
298
- silentRequest.correlationId
334
+ correlationId
299
335
  )(hash, state, authClient.authority, this.networkClient);
300
336
  }
301
337
  }
@@ -11,6 +11,7 @@ import {
11
11
  AuthError,
12
12
  AzureCloudOptions,
13
13
  PerformanceEvents,
14
+ invokeAsync,
14
15
  } from "@azure/msal-common";
15
16
  import { ApiId } from "../utils/BrowserConstants";
16
17
  import {
@@ -32,18 +33,17 @@ export class SilentRefreshClient extends StandardInteractionClient {
32
33
  request.correlationId
33
34
  );
34
35
 
35
- this.performanceClient.setPreQueueTime(
36
+ const baseRequest = await invokeAsync(
37
+ this.initializeBaseRequest.bind(this),
36
38
  PerformanceEvents.InitializeBaseRequest,
39
+ this.logger,
40
+ this.performanceClient,
37
41
  request.correlationId
38
- );
42
+ )(request, request.account);
39
43
  const silentRequest: CommonSilentFlowRequest = {
40
44
  ...request,
41
- ...(await this.initializeBaseRequest(request, request.account)),
45
+ ...baseRequest,
42
46
  };
43
- const acquireTokenMeasurement = this.performanceClient.startMeasurement(
44
- PerformanceEvents.SilentRefreshClientAcquireToken,
45
- silentRequest.correlationId
46
- );
47
47
  const serverTelemetryManager = this.initializeServerTelemetryManager(
48
48
  ApiId.acquireTokenSilent_silentFlow
49
49
  );
@@ -55,30 +55,30 @@ export class SilentRefreshClient extends StandardInteractionClient {
55
55
  );
56
56
  this.logger.verbose("Refresh token client created");
57
57
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
58
- this.performanceClient.setPreQueueTime(
58
+ return invokeAsync(
59
+ refreshTokenClient.acquireTokenByRefreshToken.bind(
60
+ refreshTokenClient
61
+ ),
59
62
  PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken,
63
+ this.logger,
64
+ this.performanceClient,
60
65
  request.correlationId
61
- );
62
- return refreshTokenClient
63
- .acquireTokenByRefreshToken(silentRequest)
66
+ )(silentRequest)
64
67
  .then((result) => result as AuthenticationResult)
65
68
  .then((result: AuthenticationResult) => {
66
- acquireTokenMeasurement.end({
67
- success: true,
68
- fromCache: result.fromCache,
69
- requestId: result.requestId,
70
- });
69
+ this.performanceClient.addFields(
70
+ {
71
+ fromCache: result.fromCache,
72
+ requestId: result.requestId,
73
+ },
74
+ request.correlationId
75
+ );
71
76
 
72
77
  return result;
73
78
  })
74
79
  .catch((e: AuthError) => {
75
80
  (e as AuthError).setCorrelationId(this.correlationId);
76
81
  serverTelemetryManager.cacheFailedRequest(e);
77
- acquireTokenMeasurement.end({
78
- errorCode: e.errorCode,
79
- subErrorCode: e.subError,
80
- success: false,
81
- });
82
82
  throw e;
83
83
  });
84
84
  }
@@ -106,15 +106,13 @@ export class SilentRefreshClient extends StandardInteractionClient {
106
106
  azureCloudOptions?: AzureCloudOptions
107
107
  ): Promise<RefreshTokenClient> {
108
108
  // Create auth module.
109
- this.performanceClient.setPreQueueTime(
109
+ const clientConfig = await invokeAsync(
110
+ this.getClientConfiguration.bind(this),
110
111
  PerformanceEvents.StandardInteractionClientGetClientConfiguration,
112
+ this.logger,
113
+ this.performanceClient,
111
114
  this.correlationId
112
- );
113
- const clientConfig = await this.getClientConfiguration(
114
- serverTelemetryManager,
115
- authorityUrl,
116
- azureCloudOptions
117
- );
115
+ )(serverTelemetryManager, authorityUrl, azureCloudOptions);
118
116
  return new RefreshTokenClient(clientConfig, this.performanceClient);
119
117
  }
120
118
  }
@@ -21,7 +21,8 @@ import {
21
21
  AccountInfo,
22
22
  AzureCloudOptions,
23
23
  PerformanceEvents,
24
- AuthError,
24
+ invokeAsync,
25
+ BaseAuthRequest,
25
26
  } from "@azure/msal-common";
26
27
  import { BaseInteractionClient } from "./BaseInteractionClient";
27
28
  import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
@@ -36,10 +37,12 @@ import {
36
37
  BrowserStateObject,
37
38
  } from "../utils/BrowserProtocolUtils";
38
39
  import { EndSessionRequest } from "../request/EndSessionRequest";
39
- import { BrowserUtils } from "../utils/BrowserUtils";
40
+ import * as BrowserUtils from "../utils/BrowserUtils";
40
41
  import { RedirectRequest } from "../request/RedirectRequest";
41
42
  import { PopupRequest } from "../request/PopupRequest";
42
43
  import { SsoSilentRequest } from "../request/SsoSilentRequest";
44
+ import { generatePkceCodes } from "../crypto/PkceGenerator";
45
+ import { createNewGuid } from "../crypto/BrowserCrypto";
43
46
 
44
47
  /**
45
48
  * Defines the class structure and helper functions used by the "standard", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))
@@ -56,12 +59,13 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
56
59
  PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
57
60
  request.correlationId
58
61
  );
59
- this.logger.verbose(
60
- "initializeAuthorizationRequest called",
61
- request.correlationId
62
- );
63
- const generatedPkceParams =
64
- await this.browserCrypto.generatePkceCodes();
62
+ const generatedPkceParams = await invokeAsync(
63
+ generatePkceCodes,
64
+ PerformanceEvents.GeneratePkceCodes,
65
+ this.logger,
66
+ this.performanceClient,
67
+ this.correlationId
68
+ )(this.performanceClient, this.logger, this.correlationId);
65
69
 
66
70
  const authCodeRequest: CommonAuthorizationCodeRequest = {
67
71
  ...request,
@@ -89,8 +93,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
89
93
  );
90
94
 
91
95
  const validLogoutRequest: CommonEndSessionRequest = {
92
- correlationId:
93
- this.correlationId || this.browserCrypto.createNewGuid(),
96
+ correlationId: this.correlationId || createNewGuid(),
94
97
  ...logoutRequest,
95
98
  };
96
99
 
@@ -219,15 +222,13 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
219
222
  this.correlationId
220
223
  );
221
224
  // Create auth module.
222
- this.performanceClient.setPreQueueTime(
225
+ const clientConfig = await invokeAsync(
226
+ this.getClientConfiguration.bind(this),
223
227
  PerformanceEvents.StandardInteractionClientGetClientConfiguration,
228
+ this.logger,
229
+ this.performanceClient,
224
230
  this.correlationId
225
- );
226
- const clientConfig = await this.getClientConfiguration(
227
- serverTelemetryManager,
228
- authorityUrl,
229
- requestAzureCloudOptions
230
- );
231
+ )(serverTelemetryManager, authorityUrl, requestAzureCloudOptions);
231
232
  return new AuthorizationCodeClient(
232
233
  clientConfig,
233
234
  this.performanceClient
@@ -249,18 +250,13 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
249
250
  PerformanceEvents.StandardInteractionClientGetClientConfiguration,
250
251
  this.correlationId
251
252
  );
252
- this.logger.verbose(
253
- "getClientConfiguration called",
254
- this.correlationId
255
- );
256
- this.performanceClient.setPreQueueTime(
253
+ const discoveredAuthority = await invokeAsync(
254
+ this.getDiscoveredAuthority.bind(this),
257
255
  PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
256
+ this.logger,
257
+ this.performanceClient,
258
258
  this.correlationId
259
- );
260
- const discoveredAuthority = await this.getDiscoveredAuthority(
261
- requestAuthority,
262
- requestAzureCloudOptions
263
- );
259
+ )(requestAuthority, requestAzureCloudOptions);
264
260
  const logger = this.config.system.loggerOptions;
265
261
 
266
262
  return {
@@ -349,15 +345,6 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
349
345
  PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
350
346
  this.correlationId
351
347
  );
352
- this.logger.verbose(
353
- "getDiscoveredAuthority called",
354
- this.correlationId
355
- );
356
- const getAuthorityMeasurement =
357
- this.performanceClient?.startMeasurement(
358
- PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
359
- this.correlationId
360
- );
361
348
  const authorityOptions: AuthorityOptions = {
362
349
  protocolMode: this.config.auth.protocolMode,
363
350
  OIDCOptions: this.config.auth.OIDCOptions,
@@ -378,15 +365,13 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
378
365
  userAuthority,
379
366
  requestAzureCloudOptions || this.config.auth.azureCloudOptions
380
367
  );
381
- this.logger.verbose(
382
- "Creating discovered authority with configured authority",
383
- this.correlationId
384
- );
385
- this.performanceClient.setPreQueueTime(
368
+ return await invokeAsync(
369
+ AuthorityFactory.createDiscoveredInstance.bind(AuthorityFactory),
386
370
  PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance,
371
+ this.logger,
372
+ this.performanceClient,
387
373
  this.correlationId
388
- );
389
- return await AuthorityFactory.createDiscoveredInstance(
374
+ )(
390
375
  builtAuthority,
391
376
  this.config.system.networkClient,
392
377
  this.browserStorage,
@@ -394,23 +379,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
394
379
  this.logger,
395
380
  this.performanceClient,
396
381
  this.correlationId
397
- )
398
- .then((result: Authority) => {
399
- getAuthorityMeasurement.end({
400
- success: true,
401
- });
402
-
403
- return result;
404
- })
405
- .catch((error: AuthError) => {
406
- getAuthorityMeasurement.end({
407
- errorCode: error.errorCode,
408
- subErrorCode: error.subError,
409
- success: false,
410
- });
411
-
412
- throw error;
413
- });
382
+ );
414
383
  }
415
384
 
416
385
  /**
@@ -426,10 +395,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
426
395
  PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
427
396
  this.correlationId
428
397
  );
429
- this.logger.verbose(
430
- "initializeAuthorizationRequest called",
431
- this.correlationId
432
- );
398
+
433
399
  const redirectUri = this.getRedirectUri(request.redirectUri);
434
400
  const browserState: BrowserStateObject = {
435
401
  interactionType: interactionType,
@@ -440,16 +406,19 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
440
406
  browserState
441
407
  );
442
408
 
443
- this.performanceClient.setPreQueueTime(
409
+ const baseRequest: BaseAuthRequest = await invokeAsync(
410
+ this.initializeBaseRequest.bind(this),
444
411
  PerformanceEvents.InitializeBaseRequest,
412
+ this.logger,
413
+ this.performanceClient,
445
414
  this.correlationId
446
- );
415
+ )(request);
447
416
 
448
417
  const validatedRequest: AuthorizationUrlRequest = {
449
- ...(await this.initializeBaseRequest(request)),
418
+ ...baseRequest,
450
419
  redirectUri: redirectUri,
451
420
  state: state,
452
- nonce: request.nonce || this.browserCrypto.createNewGuid(),
421
+ nonce: request.nonce || createNewGuid(),
453
422
  responseMode: this.config.auth.OIDCOptions
454
423
  .serverResponseType as ResponseMode,
455
424
  };
@@ -10,13 +10,14 @@ import {
10
10
  AuthorityFactory,
11
11
  Authority,
12
12
  INetworkModule,
13
- ClientAuthError,
14
13
  CcsCredential,
15
14
  Logger,
16
15
  ServerError,
17
16
  IPerformanceClient,
18
17
  PerformanceEvents,
19
18
  invokeAsync,
19
+ createClientAuthError,
20
+ ClientAuthErrorCodes,
20
21
  } from "@azure/msal-common";
21
22
 
22
23
  import { BrowserCacheManager } from "../cache/BrowserCacheManager";
@@ -67,7 +68,6 @@ export class InteractionHandler {
67
68
  PerformanceEvents.HandleCodeResponseFromHash,
68
69
  this.authCodeRequest.correlationId
69
70
  );
70
- this.logger.verbose("InteractionHandler.handleCodeResponse called");
71
71
  // Check that location hash isn't empty.
72
72
  if (!locationHash) {
73
73
  throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
@@ -77,7 +77,10 @@ export class InteractionHandler {
77
77
  const stateKey = this.browserStorage.generateStateKey(state);
78
78
  const requestState = this.browserStorage.getTemporaryCache(stateKey);
79
79
  if (!requestState) {
80
- throw ClientAuthError.createStateNotFoundError("Cached State");
80
+ throw createClientAuthError(
81
+ ClientAuthErrorCodes.stateNotFound,
82
+ "Cached State"
83
+ );
81
84
  }
82
85
 
83
86
  let authCodeResponse;
@@ -100,16 +103,13 @@ export class InteractionHandler {
100
103
  }
101
104
  }
102
105
 
103
- this.performanceClient.setPreQueueTime(
106
+ return invokeAsync(
107
+ this.handleCodeResponseFromServer.bind(this),
104
108
  PerformanceEvents.HandleCodeResponseFromServer,
109
+ this.logger,
110
+ this.performanceClient,
105
111
  this.authCodeRequest.correlationId
106
- );
107
- return this.handleCodeResponseFromServer(
108
- authCodeResponse,
109
- state,
110
- authority,
111
- networkModule
112
- );
112
+ )(authCodeResponse, state, authority, networkModule);
113
113
  }
114
114
 
115
115
  /**
@@ -139,7 +139,10 @@ export class InteractionHandler {
139
139
  const stateKey = this.browserStorage.generateStateKey(state);
140
140
  const requestState = this.browserStorage.getTemporaryCache(stateKey);
141
141
  if (!requestState) {
142
- throw ClientAuthError.createStateNotFoundError("Cached State");
142
+ throw createClientAuthError(
143
+ ClientAuthErrorCodes.stateNotFound,
144
+ "Cached State"
145
+ );
143
146
  }
144
147
 
145
148
  // Get cached items
@@ -151,11 +154,13 @@ export class InteractionHandler {
151
154
 
152
155
  // Check for new cloud instance
153
156
  if (authCodeResponse.cloud_instance_host_name) {
154
- this.performanceClient.setPreQueueTime(
157
+ await invokeAsync(
158
+ this.updateTokenEndpointAuthority.bind(this),
155
159
  PerformanceEvents.UpdateTokenEndpointAuthority,
160
+ this.logger,
161
+ this.performanceClient,
156
162
  this.authCodeRequest.correlationId
157
- );
158
- await this.updateTokenEndpointAuthority(
163
+ )(
159
164
  authCodeResponse.cloud_instance_host_name,
160
165
  authority,
161
166
  networkModule
@@ -9,10 +9,11 @@ import {
9
9
  ICrypto,
10
10
  Authority,
11
11
  INetworkModule,
12
- ClientAuthError,
13
12
  Logger,
14
13
  ServerError,
15
14
  IPerformanceClient,
15
+ createClientAuthError,
16
+ ClientAuthErrorCodes,
16
17
  } from "@azure/msal-common";
17
18
  import {
18
19
  createBrowserAuthError,
@@ -161,7 +162,10 @@ export class RedirectHandler extends InteractionHandler {
161
162
  const stateKey = this.browserStorage.generateStateKey(state);
162
163
  const requestState = this.browserStorage.getTemporaryCache(stateKey);
163
164
  if (!requestState) {
164
- throw ClientAuthError.createStateNotFoundError("Cached State");
165
+ throw createClientAuthError(
166
+ ClientAuthErrorCodes.stateNotFound,
167
+ "Cached State"
168
+ );
165
169
  }
166
170
 
167
171
  let authCodeResponse;