@azure/msal-browser 3.2.0 → 3.4.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 (224) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/PublicClientApplication.mjs +3 -4
  4. package/dist/app/PublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientNext.d.ts +274 -0
  6. package/dist/app/PublicClientNext.d.ts.map +1 -0
  7. package/dist/app/PublicClientNext.mjs +360 -0
  8. package/dist/app/PublicClientNext.mjs.map +1 -0
  9. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  10. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  11. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  12. package/dist/cache/BrowserCacheManager.d.ts +2 -13
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.mjs +26 -83
  15. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  16. package/dist/cache/BrowserStorage.mjs +1 -1
  17. package/dist/cache/CryptoKeyStore.mjs +1 -1
  18. package/dist/cache/DatabaseStorage.mjs +1 -1
  19. package/dist/cache/MemoryStorage.mjs +1 -1
  20. package/dist/cache/TokenCache.d.ts.map +1 -1
  21. package/dist/cache/TokenCache.mjs +5 -5
  22. package/dist/cache/TokenCache.mjs.map +1 -1
  23. package/dist/config/Configuration.d.ts +4 -0
  24. package/dist/config/Configuration.d.ts.map +1 -1
  25. package/dist/config/Configuration.mjs +2 -1
  26. package/dist/config/Configuration.mjs.map +1 -1
  27. package/dist/controllers/ControllerFactory.d.ts +2 -7
  28. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  29. package/dist/controllers/ControllerFactory.mjs +24 -34
  30. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  31. package/dist/controllers/IController.d.ts +1 -2
  32. package/dist/controllers/IController.d.ts.map +1 -1
  33. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  34. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  35. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  36. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  37. package/dist/controllers/StandardController.d.ts +4 -4
  38. package/dist/controllers/StandardController.d.ts.map +1 -1
  39. package/dist/controllers/StandardController.mjs +43 -42
  40. package/dist/controllers/StandardController.mjs.map +1 -1
  41. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  42. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  43. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  44. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  45. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  46. package/dist/crypto/BrowserCrypto.mjs +3 -3
  47. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  48. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  49. package/dist/crypto/CryptoOps.mjs +8 -5
  50. package/dist/crypto/CryptoOps.mjs.map +1 -1
  51. package/dist/crypto/PkceGenerator.mjs +1 -1
  52. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  53. package/dist/encode/Base64Decode.mjs +1 -1
  54. package/dist/encode/Base64Encode.mjs +1 -1
  55. package/dist/error/BrowserAuthError.mjs +1 -1
  56. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  57. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  58. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  59. package/dist/error/NativeAuthError.mjs +1 -1
  60. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  61. package/dist/error/NestedAppAuthError.d.ts +15 -0
  62. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  63. package/dist/error/NestedAppAuthError.mjs +30 -0
  64. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  65. package/dist/event/EventHandler.mjs +1 -1
  66. package/dist/event/EventMessage.mjs +1 -1
  67. package/dist/event/EventType.mjs +1 -1
  68. package/dist/index.d.ts +3 -5
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.mjs +4 -2
  71. package/dist/index.mjs.map +1 -1
  72. package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
  73. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  74. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  75. package/dist/interaction_client/NativeInteractionClient.mjs +18 -7
  76. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  77. package/dist/interaction_client/PopupClient.d.ts +1 -2
  78. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  79. package/dist/interaction_client/PopupClient.mjs +13 -25
  80. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  81. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  82. package/dist/interaction_client/RedirectClient.mjs +17 -25
  83. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  84. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  85. package/dist/interaction_client/SilentAuthCodeClient.mjs +6 -8
  86. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  87. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  88. package/dist/interaction_client/SilentCacheClient.mjs +4 -3
  89. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  90. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  91. package/dist/interaction_client/SilentIframeClient.mjs +28 -19
  92. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  93. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  94. package/dist/interaction_client/SilentRefreshClient.mjs +2 -12
  95. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  96. package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
  97. package/dist/interaction_handler/InteractionHandler.d.ts +6 -13
  98. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  99. package/dist/interaction_handler/InteractionHandler.mjs +29 -56
  100. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  101. package/dist/interaction_handler/RedirectHandler.d.ts +14 -7
  102. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  103. package/dist/interaction_handler/RedirectHandler.mjs +28 -9
  104. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  105. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  106. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  107. package/dist/interaction_handler/SilentHandler.mjs +120 -155
  108. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  109. package/dist/naa/AccountInfo.d.ts +13 -0
  110. package/dist/naa/AccountInfo.d.ts.map +1 -0
  111. package/dist/naa/AccountRequests.d.ts +10 -0
  112. package/dist/naa/AccountRequests.d.ts.map +1 -0
  113. package/dist/naa/AuthBridge.d.ts +6 -0
  114. package/dist/naa/AuthBridge.d.ts.map +1 -0
  115. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  116. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  117. package/dist/naa/BridgeError.d.ts +10 -0
  118. package/dist/naa/BridgeError.d.ts.map +1 -0
  119. package/dist/naa/BridgeError.mjs +12 -0
  120. package/dist/naa/BridgeError.mjs.map +1 -0
  121. package/dist/naa/BridgeProxy.d.ts +72 -0
  122. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  123. package/dist/naa/BridgeProxy.mjs +154 -0
  124. package/dist/naa/BridgeProxy.mjs.map +1 -0
  125. package/dist/naa/BridgeRequest.d.ts +7 -0
  126. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  127. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  128. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  129. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  130. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  131. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  132. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  133. package/dist/naa/BridgeStatusCode.mjs +20 -0
  134. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  135. package/dist/naa/IBridgeProxy.d.ts +11 -0
  136. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  137. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  138. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  139. package/dist/naa/TokenRequest.d.ts +22 -0
  140. package/dist/naa/TokenRequest.d.ts.map +1 -0
  141. package/dist/naa/TokenResponse.d.ts +17 -0
  142. package/dist/naa/TokenResponse.d.ts.map +1 -0
  143. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  144. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  145. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  146. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  147. package/dist/navigation/NavigationClient.mjs +1 -1
  148. package/dist/network/FetchClient.mjs +1 -1
  149. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  150. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  151. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  152. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  153. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  154. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  155. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  156. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  157. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  158. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  159. package/dist/packageMetadata.d.ts +1 -1
  160. package/dist/packageMetadata.mjs +2 -2
  161. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  162. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  163. package/dist/utils/BrowserConstants.mjs +1 -1
  164. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  165. package/dist/utils/BrowserUtils.d.ts +54 -53
  166. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  167. package/dist/utils/BrowserUtils.mjs +114 -102
  168. package/dist/utils/BrowserUtils.mjs.map +1 -1
  169. package/lib/msal-browser.cjs +13221 -12385
  170. package/lib/msal-browser.cjs.map +1 -1
  171. package/lib/msal-browser.js +13221 -12385
  172. package/lib/msal-browser.js.map +1 -1
  173. package/lib/msal-browser.min.js +67 -68
  174. package/package.json +2 -2
  175. package/src/app/PublicClientApplication.ts +4 -3
  176. package/src/app/PublicClientNext.ts +444 -0
  177. package/src/cache/BrowserCacheManager.ts +33 -140
  178. package/src/cache/TokenCache.ts +5 -4
  179. package/src/config/Configuration.ts +5 -0
  180. package/src/controllers/ControllerFactory.ts +35 -43
  181. package/src/controllers/IController.ts +0 -6
  182. package/src/controllers/NestedAppAuthController.ts +525 -0
  183. package/src/controllers/StandardController.ts +50 -52
  184. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  185. package/src/crypto/BrowserCrypto.ts +2 -2
  186. package/src/crypto/CryptoOps.ts +8 -5
  187. package/src/error/NestedAppAuthError.ts +32 -0
  188. package/src/index.ts +3 -10
  189. package/src/interaction_client/BaseInteractionClient.ts +1 -1
  190. package/src/interaction_client/NativeInteractionClient.ts +23 -6
  191. package/src/interaction_client/PopupClient.ts +41 -61
  192. package/src/interaction_client/RedirectClient.ts +42 -47
  193. package/src/interaction_client/SilentAuthCodeClient.ts +6 -16
  194. package/src/interaction_client/SilentCacheClient.ts +11 -3
  195. package/src/interaction_client/SilentIframeClient.ts +54 -34
  196. package/src/interaction_client/SilentRefreshClient.ts +5 -19
  197. package/src/interaction_client/StandardInteractionClient.ts +1 -1
  198. package/src/interaction_handler/InteractionHandler.ts +34 -104
  199. package/src/interaction_handler/RedirectHandler.ts +48 -22
  200. package/src/interaction_handler/SilentHandler.ts +177 -233
  201. package/src/naa/AccountInfo.ts +17 -0
  202. package/src/naa/AccountRequests.ts +16 -0
  203. package/src/naa/AuthBridge.ts +16 -0
  204. package/src/naa/BridgeCapabilities.ts +8 -0
  205. package/src/naa/BridgeError.ts +18 -0
  206. package/src/naa/BridgeProxy.ts +230 -0
  207. package/src/naa/BridgeRequest.ts +12 -0
  208. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  209. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  210. package/src/naa/BridgeStatusCode.ts +15 -0
  211. package/src/naa/IBridgeProxy.ts +25 -0
  212. package/src/naa/InitializeBridgeResponse.ts +12 -0
  213. package/src/naa/TokenRequest.ts +26 -0
  214. package/src/naa/TokenResponse.ts +61 -0
  215. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  216. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  217. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  218. package/src/packageMetadata.ts +1 -1
  219. package/src/utils/BrowserUtils.ts +133 -125
  220. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  221. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  222. package/dist/utils/BrowserStringUtils.mjs +0 -144
  223. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  224. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -1,8 +1,7 @@
1
- /*! @azure/msal-browser v3.2.0 2023-10-05 */
1
+ /*! @azure/msal-browser v3.4.0 2023-10-30 */
2
2
  'use strict';
3
- import { PerformanceEvents, createClientAuthError, ClientAuthErrorCodes, ServerError, invokeAsync, AuthorityFactory } from '@azure/msal-common';
3
+ import { PerformanceEvents, ServerError, invokeAsync, CcsCredentialType } from '@azure/msal-common';
4
4
  import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
5
- import { TemporaryCacheKeys } from '../utils/BrowserConstants.mjs';
6
5
  import { hashEmptyError, userCancelled } from '../error/BrowserAuthErrorCodes.mjs';
7
6
 
8
7
  /*
@@ -24,21 +23,15 @@ class InteractionHandler {
24
23
  * Function to handle response parameters from hash.
25
24
  * @param locationHash
26
25
  */
27
- async handleCodeResponseFromHash(locationHash, state, authority, networkModule) {
28
- this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromHash, this.authCodeRequest.correlationId);
26
+ async handleCodeResponseFromHash(locationHash, request) {
27
+ this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromHash, request.correlationId);
29
28
  // Check that location hash isn't empty.
30
29
  if (!locationHash) {
31
30
  throw createBrowserAuthError(hashEmptyError);
32
31
  }
33
- // Handle code response.
34
- const stateKey = this.browserStorage.generateStateKey(state);
35
- const requestState = this.browserStorage.getTemporaryCache(stateKey);
36
- if (!requestState) {
37
- throw createClientAuthError(ClientAuthErrorCodes.stateNotFound, "Cached State");
38
- }
39
32
  let authCodeResponse;
40
33
  try {
41
- authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
34
+ authCodeResponse = this.authModule.handleFragmentResponse(locationHash, request.state);
42
35
  }
43
36
  catch (e) {
44
37
  if (e instanceof ServerError &&
@@ -50,7 +43,7 @@ class InteractionHandler {
50
43
  throw e;
51
44
  }
52
45
  }
53
- return invokeAsync(this.handleCodeResponseFromServer.bind(this), PerformanceEvents.HandleCodeResponseFromServer, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(authCodeResponse, state, authority, networkModule);
46
+ return invokeAsync(this.handleCodeResponseFromServer.bind(this), PerformanceEvents.HandleCodeResponseFromServer, this.logger, this.performanceClient, request.correlationId)(authCodeResponse, request);
54
47
  }
55
48
  /**
56
49
  * Process auth code response from AAD
@@ -60,70 +53,50 @@ class InteractionHandler {
60
53
  * @param networkModule
61
54
  * @returns
62
55
  */
63
- async handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule, validateNonce = true) {
64
- this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromServer, this.authCodeRequest.correlationId);
56
+ async handleCodeResponseFromServer(authCodeResponse, request, validateNonce = true) {
57
+ this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromServer, request.correlationId);
65
58
  this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
66
- // Handle code response.
67
- const stateKey = this.browserStorage.generateStateKey(state);
68
- const requestState = this.browserStorage.getTemporaryCache(stateKey);
69
- if (!requestState) {
70
- throw createClientAuthError(ClientAuthErrorCodes.stateNotFound, "Cached State");
71
- }
72
- // Get cached items
73
- const nonceKey = this.browserStorage.generateNonceKey(requestState);
74
- const cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
75
59
  // Assign code to request
76
60
  this.authCodeRequest.code = authCodeResponse.code;
77
61
  // Check for new cloud instance
78
62
  if (authCodeResponse.cloud_instance_host_name) {
79
- await invokeAsync(this.updateTokenEndpointAuthority.bind(this), PerformanceEvents.UpdateTokenEndpointAuthority, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(authCodeResponse.cloud_instance_host_name, authority, networkModule);
63
+ await invokeAsync(this.authModule.updateAuthority.bind(this.authModule), PerformanceEvents.UpdateTokenEndpointAuthority, this.logger, this.performanceClient, request.correlationId)(authCodeResponse.cloud_instance_host_name, request.correlationId);
80
64
  }
81
65
  // Nonce validation not needed when redirect not involved (e.g. hybrid spa, renewing token via rt)
82
66
  if (validateNonce) {
83
- authCodeResponse.nonce = cachedNonce || undefined;
67
+ // TODO: Assigning "response nonce" to "request nonce" is confusing. Refactor the function doing validation to accept request nonce directly
68
+ authCodeResponse.nonce = request.nonce || undefined;
84
69
  }
85
- authCodeResponse.state = requestState;
70
+ authCodeResponse.state = request.state;
86
71
  // Add CCS parameters if available
87
72
  if (authCodeResponse.client_info) {
88
73
  this.authCodeRequest.clientInfo = authCodeResponse.client_info;
89
74
  }
90
75
  else {
91
- const cachedCcsCred = this.checkCcsCredentials();
92
- if (cachedCcsCred) {
93
- this.authCodeRequest.ccsCredential = cachedCcsCred;
76
+ const ccsCred = this.createCcsCredentials(request);
77
+ if (ccsCred) {
78
+ this.authCodeRequest.ccsCredential = ccsCred;
94
79
  }
95
80
  }
96
81
  // Acquire token with retrieved code.
97
- const tokenResponse = (await invokeAsync(this.authModule.acquireToken.bind(this.authModule), PerformanceEvents.AuthClientAcquireToken, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(this.authCodeRequest, authCodeResponse));
98
- this.browserStorage.cleanRequestByState(state);
82
+ const tokenResponse = (await invokeAsync(this.authModule.acquireToken.bind(this.authModule), PerformanceEvents.AuthClientAcquireToken, this.logger, this.performanceClient, request.correlationId)(this.authCodeRequest, authCodeResponse));
99
83
  return tokenResponse;
100
84
  }
101
85
  /**
102
- * Updates authority based on cloudInstanceHostname
103
- * @param cloudInstanceHostname
104
- * @param authority
105
- * @param networkModule
106
- */
107
- async updateTokenEndpointAuthority(cloudInstanceHostname, authority, networkModule) {
108
- this.performanceClient.addQueueMeasurement(PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
109
- const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${authority.tenant}/`;
110
- const cloudInstanceAuthority = await AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger, this.performanceClient, this.authCodeRequest.correlationId);
111
- this.authModule.updateAuthority(cloudInstanceAuthority);
112
- }
113
- /**
114
- * Looks up ccs creds in the cache
86
+ * Build ccs creds if available
115
87
  */
116
- checkCcsCredentials() {
117
- // Look up ccs credential in temp cache
118
- const cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);
119
- if (cachedCcsCred) {
120
- try {
121
- return JSON.parse(cachedCcsCred);
122
- }
123
- catch (e) {
124
- this.authModule.logger.error("Cache credential could not be parsed");
125
- this.authModule.logger.errorPii(`Cache credential could not be parsed: ${cachedCcsCred}`);
126
- }
88
+ createCcsCredentials(request) {
89
+ if (request.account) {
90
+ return {
91
+ credential: request.account.homeAccountId,
92
+ type: CcsCredentialType.HOME_ACCOUNT_ID,
93
+ };
94
+ }
95
+ else if (request.loginHint) {
96
+ return {
97
+ credential: request.loginHint,
98
+ type: CcsCredentialType.UPN,
99
+ };
127
100
  }
128
101
  return null;
129
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InteractionHandler.mjs","sources":["../../src/interaction_handler/InteractionHandler.ts"],"sourcesContent":[null],"names":["BrowserAuthErrorCodes.hashEmptyError"],"mappings":";;;;;;;AAKA;AAiBA;AAMA;AAEA;AAKA;AACI;AACA;AACA,MAAS,kBAAkB,CAAA;AAC3B,IAAA,WAAU,CAAA,cAAe,EAAA,WAAA,EAAA,eAAA,EAAA,MAAA,EAAA,iBAAA,EAAA;AACzB,QAAA,IAAA,CAAS,UAAC,GAAA,cAAmB,CAAA;AAGzB,QAAA,IAAA,CAAA,cAAA,GAAc,WAAyB,CAAA;AAa3C,QAAA,IAAA,CAAA,eAAA,GAAA,eAAA,CAAA;;;AAGG,KAAA;;AAuDH;;;;;;;AAOG,YAAA,MAAA,sBAAA,CAAAA,cAAA,CAAA,CAAA;SAC+B;AA4ElC;;;;;AAKG,SAAA;AACa,QAAA,IAAA,gBAAA,CAAA;AAuBhB,QAAA,IAAA;;AAEG,SAAA;AACH,QAAA,OAAU,CAAA,EAAA;AAoBb,YAAA,IAAA,CAAA,YAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"InteractionHandler.mjs","sources":["../../src/interaction_handler/InteractionHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAKA;AAaA;AAKA;AACA;AAIG;AACH;AACI;AACA,MAAS,kBAAiB,CAAA;AAC1B,IAAA,WAAU,CAAA,cAAiB,EAAA,WAAA,EAAA,eAAA,EAA+B,MAAA,EAAA,iBAAA,EAAA;AAC1D,QAAA,IAAA,CAAS,UAAS,GAAA,cAAO,CAAA;AACzB,QAAA,IAAA,CAAS,cAAC,GAAA,WAAmB,CAAA;AAGzB,QAAA,IAAA,CAAA,eAAA,kBAAuC,CAAA;AAa3C,QAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;;;AAGG;AACG;AA0CN;;;;;;;AAOG,SAAA;AACG,QAAA,IAAA,gBAAA,CAAA;AAwDN,QAAA,IAAA;;AAEG,SAAA;QACM;AAiBZ,YAAA,IAAA,CAAA,YAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,17 +1,20 @@
1
- import { AuthorizationCodeClient, CommonAuthorizationCodeRequest, ICrypto, Authority, INetworkModule, Logger, IPerformanceClient } from "@azure/msal-common";
1
+ import { AuthorizationCodeClient, CommonAuthorizationCodeRequest, Logger, IPerformanceClient, CcsCredential } from "@azure/msal-common";
2
2
  import { BrowserCacheManager } from "../cache/BrowserCacheManager";
3
- import { InteractionHandler, InteractionParams } from "./InteractionHandler";
4
3
  import { INavigationClient } from "../navigation/INavigationClient";
5
4
  import { AuthenticationResult } from "../response/AuthenticationResult";
6
- export type RedirectParams = InteractionParams & {
5
+ export type RedirectParams = {
7
6
  navigationClient: INavigationClient;
8
7
  redirectTimeout: number;
9
8
  redirectStartPage: string;
10
9
  onRedirectNavigate?: (url: string) => void | boolean;
11
10
  };
12
- export declare class RedirectHandler extends InteractionHandler {
13
- private browserCrypto;
14
- constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, logger: Logger, browserCrypto: ICrypto, performanceClient: IPerformanceClient);
11
+ export declare class RedirectHandler {
12
+ authModule: AuthorizationCodeClient;
13
+ browserStorage: BrowserCacheManager;
14
+ authCodeRequest: CommonAuthorizationCodeRequest;
15
+ logger: Logger;
16
+ performanceClient: IPerformanceClient;
17
+ constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, logger: Logger, performanceClient: IPerformanceClient);
15
18
  /**
16
19
  * Redirects window to given URL.
17
20
  * @param urlNavigate
@@ -21,6 +24,10 @@ export declare class RedirectHandler extends InteractionHandler {
21
24
  * Handle authorization code response in the window.
22
25
  * @param hash
23
26
  */
24
- handleCodeResponseFromHash(locationHash: string, state: string, authority: Authority, networkModule: INetworkModule): Promise<AuthenticationResult>;
27
+ handleCodeResponseFromHash(locationHash: string, state: string): Promise<AuthenticationResult>;
28
+ /**
29
+ * Looks up ccs creds in the cache
30
+ */
31
+ protected checkCcsCredentials(): CcsCredential | null;
25
32
  }
26
33
  //# sourceMappingURL=RedirectHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/RedirectHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EACvB,8BAA8B,EAC9B,OAAO,EACP,SAAS,EACT,cAAc,EACd,MAAM,EAEN,kBAAkB,EAGrB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG;IAC7C,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;CACxD,CAAC;AAEF,qBAAa,eAAgB,SAAQ,kBAAkB;IACnD,OAAO,CAAC,aAAa,CAAU;gBAG3B,cAAc,EAAE,uBAAuB,EACvC,WAAW,EAAE,mBAAmB,EAChC,eAAe,EAAE,8BAA8B,EAC/C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,OAAO,EACtB,iBAAiB,EAAE,kBAAkB;IAYzC;;;OAGG;IACG,mBAAmB,CACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACvB,OAAO,CAAC,IAAI,CAAC;IA6EhB;;;OAGG;IACG,0BAA0B,CAC5B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,cAAc,GAC9B,OAAO,CAAC,oBAAoB,CAAC;CA+EnC"}
1
+ {"version":3,"file":"RedirectHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/RedirectHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EACvB,8BAA8B,EAC9B,MAAM,EAEN,kBAAkB,EAGlB,aAAa,EAGhB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG;IACzB,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;CACxD,CAAC;AAEF,qBAAa,eAAe;IACxB,UAAU,EAAE,uBAAuB,CAAC;IACpC,cAAc,EAAE,mBAAmB,CAAC;IACpC,eAAe,EAAE,8BAA8B,CAAC;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,kBAAkB,CAAC;gBAGlC,cAAc,EAAE,uBAAuB,EACvC,WAAW,EAAE,mBAAmB,EAChC,eAAe,EAAE,8BAA8B,EAC/C,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,kBAAkB;IASzC;;;OAGG;IACG,mBAAmB,CACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACvB,OAAO,CAAC,IAAI,CAAC;IA6EhB;;;OAGG;IACG,0BAA0B,CAC5B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC;IAqFhC;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,aAAa,GAAG,IAAI;CAoBxD"}
@@ -1,19 +1,21 @@
1
- /*! @azure/msal-browser v3.2.0 2023-10-05 */
1
+ /*! @azure/msal-browser v3.4.0 2023-10-30 */
2
2
  'use strict';
3
- import { createClientAuthError, ClientAuthErrorCodes, ServerError } from '@azure/msal-common';
3
+ import { createClientAuthError, ClientAuthErrorCodes, ServerError, invokeAsync, PerformanceEvents } from '@azure/msal-common';
4
4
  import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
5
5
  import { TemporaryCacheKeys, ApiId } from '../utils/BrowserConstants.mjs';
6
- import { InteractionHandler } from './InteractionHandler.mjs';
7
6
  import { emptyNavigateUri, hashEmptyError, userCancelled } from '../error/BrowserAuthErrorCodes.mjs';
8
7
 
9
8
  /*
10
9
  * Copyright (c) Microsoft Corporation. All rights reserved.
11
10
  * Licensed under the MIT License.
12
11
  */
13
- class RedirectHandler extends InteractionHandler {
14
- constructor(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto, performanceClient) {
15
- super(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient);
16
- this.browserCrypto = browserCrypto;
12
+ class RedirectHandler {
13
+ constructor(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) {
14
+ this.authModule = authCodeModule;
15
+ this.browserStorage = storageImpl;
16
+ this.authCodeRequest = authCodeRequest;
17
+ this.logger = logger;
18
+ this.performanceClient = performanceClient;
17
19
  }
18
20
  /**
19
21
  * Redirects window to given URL.
@@ -69,7 +71,7 @@ class RedirectHandler extends InteractionHandler {
69
71
  * Handle authorization code response in the window.
70
72
  * @param hash
71
73
  */
72
- async handleCodeResponseFromHash(locationHash, state, authority, networkModule) {
74
+ async handleCodeResponseFromHash(locationHash, state) {
73
75
  this.logger.verbose("RedirectHandler.handleCodeResponse called");
74
76
  // Check that location hash isn't empty.
75
77
  if (!locationHash) {
@@ -104,7 +106,7 @@ class RedirectHandler extends InteractionHandler {
104
106
  this.authCodeRequest.code = authCodeResponse.code;
105
107
  // Check for new cloud instance
106
108
  if (authCodeResponse.cloud_instance_host_name) {
107
- await this.updateTokenEndpointAuthority(authCodeResponse.cloud_instance_host_name, authority, networkModule);
109
+ await invokeAsync(this.authModule.updateAuthority.bind(this.authModule), PerformanceEvents.UpdateTokenEndpointAuthority, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(authCodeResponse.cloud_instance_host_name, this.authCodeRequest.correlationId);
108
110
  }
109
111
  authCodeResponse.nonce = cachedNonce || undefined;
110
112
  authCodeResponse.state = requestState;
@@ -123,6 +125,23 @@ class RedirectHandler extends InteractionHandler {
123
125
  this.browserStorage.cleanRequestByState(state);
124
126
  return tokenResponse;
125
127
  }
128
+ /**
129
+ * Looks up ccs creds in the cache
130
+ */
131
+ checkCcsCredentials() {
132
+ // Look up ccs credential in temp cache
133
+ const cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);
134
+ if (cachedCcsCred) {
135
+ try {
136
+ return JSON.parse(cachedCcsCred);
137
+ }
138
+ catch (e) {
139
+ this.authModule.logger.error("Cache credential could not be parsed");
140
+ this.authModule.logger.errorPii(`Cache credential could not be parsed: ${cachedCcsCred}`);
141
+ }
142
+ }
143
+ return null;
144
+ }
126
145
  }
127
146
 
128
147
  export { RedirectHandler };
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectHandler.mjs","sources":["../../src/interaction_handler/RedirectHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AAKA;AAiBA;AACA;AACA;AAOqB,MAAA,wBAAS,kBAAA,CAAA;IAC1B,WAAkB,CAAA,cAAO,aAAa,EAAA,eAAe,EAAA,MAAA,EAAA,aAAA,EAAA,iBAAA,EAAA;QACvD,KAAA,CAAA,cAAA,EAAA,WAAA,EAAA,eAAA,EAAA,MAAA,EAAA,iBAAA,CAAA,CAAA;AAEF,QAAa,IAAA,CAAA,aAAA,GAAA;KACF;;AAoBP;;;AAGG,IAAA,MAAA,mBAAA,CAAA,UAAA,EAAA,MAAA,EAAA;AACG,QAAA,IAAA,CAAA,MAAA,CAAA,OACF,CAAA,4CAED,CAAA,CAAA;AA6EH;;;AAGG,YAAA,IAAA,MAAA,CAAA,iBAAA,EAAA;gBAC6B,IAAA,CAAA,MAAA,CAAA,wFAIb,CAAA,CAAA;AAgFtB,gBAAA,IAAA,CAAA,cAAA,CAAA,iBAAA,CAAA,kBAAA,CAAA,UAAA,EAAA,MAAA,CAAA,iBAAA,EAAA,IAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"RedirectHandler.mjs","sources":["../../src/interaction_handler/RedirectHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAKA;AAiBA;AACA;AAEA;AAKqB,MAAA,gBAAQ;IACzB,WAAkB,CAAA,cAAO,aAAa,EAAA,eAAe,EAAA,MAAA,EAAA,iBAAA,EAAA;QACvD,IAAA,CAAA,UAAA,GAAA,cAAA,CAAA;AAEF,QAAA,IAAA,CAAA,cAA4B,GAAA,WAAA,CAAA;QACd,IAAA,CAAA,iCAA0B,CAAA;QACtB,IAAA,CAAA,MAAA;QACC,IAAA,CAAA,sCAAgC;KACzC;;AAIF;AAaJ;;;AAGG,QAAA,IAAA,CAAA,MAAA,CAAA,OAAA,CAAA,4CAAA,CAAA,CAAA;AACG;AAgFN,QAAA,IAAA,UAAA,EAAA;;;AAGG,gBAAA,IAAA,CAAA,MAAA,CAAA,OAAA,CAAA,gFAAA,CAAA,CAAA;AACG,gBAAA,IAAA,CAAA,cACF,CAAA,iBACA,CAAA,kBACD,CAAA,UAAQ,EAAA,MAAA,CAAA,iBAAqB,EAAA,IAAA,CAAA,CAAA;AAqFhC,aAAA;;AAEG,YAAA,IAAA,CAAA,cAAA,CAAA,iBAAA,CAAA,kBAAA,CAAA,cAAA,EAAA,IAAA,CAAA,eAAA,CAAA,aAAA,EAAA,IAAA,CAAA,CAAA;AACH,YAAA,IAAU,CAAA,cAAA,CAAA,gBAAuB,CAAA,IAAgB,CAAI,eAAA,CAAA,CAAA;AAoBxD,YAAA,IAAA,CAAA,MAAA,CAAA,OAAA,CAAA,CAAA,kDAAA,EAAA,UAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,48 +1,14 @@
1
- import { CommonAuthorizationCodeRequest, AuthorizationCodeClient, Logger, IPerformanceClient } from "@azure/msal-common";
2
- import { InteractionHandler } from "./InteractionHandler";
3
- import { BrowserCacheManager } from "../cache/BrowserCacheManager";
4
- import { BrowserSystemOptions } from "../config/Configuration";
5
- export declare class SilentHandler extends InteractionHandler {
6
- private navigateFrameWait;
7
- private pollIntervalMilliseconds;
8
- constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, logger: Logger, systemOptions: Required<Pick<BrowserSystemOptions, "navigateFrameWait" | "pollIntervalMilliseconds">>, performanceClient: IPerformanceClient);
9
- /**
10
- * Creates a hidden iframe to given URL using user-requested scopes as an id.
11
- * @param urlNavigate
12
- * @param userRequestScopes
13
- */
14
- initiateAuthRequest(requestUrl: string): Promise<HTMLIFrameElement>;
15
- /**
16
- * Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
17
- * @param iframe
18
- * @param timeout
19
- */
20
- monitorIframeForHash(iframe: HTMLIFrameElement, timeout: number): Promise<string>;
21
- /**
22
- * @hidden
23
- * Loads iframe with authorization endpoint URL
24
- * @ignore
25
- */
26
- private loadFrame;
27
- /**
28
- * @hidden
29
- * Loads the iframe synchronously when the navigateTimeFrame is set to `0`
30
- * @param urlNavigate
31
- * @param frameName
32
- * @param logger
33
- */
34
- private loadFrameSync;
35
- /**
36
- * @hidden
37
- * Creates a new hidden iframe or gets an existing one for silent token renewal.
38
- * @ignore
39
- */
40
- private createHiddenIframe;
41
- /**
42
- * @hidden
43
- * Removes a hidden iframe from the page.
44
- * @ignore
45
- */
46
- private removeHiddenIframe;
47
- }
1
+ import { Logger, IPerformanceClient } from "@azure/msal-common";
2
+ /**
3
+ * Creates a hidden iframe to given URL using user-requested scopes as an id.
4
+ * @param urlNavigate
5
+ * @param userRequestScopes
6
+ */
7
+ export declare function initiateAuthRequest(requestUrl: string, performanceClient: IPerformanceClient, logger: Logger, correlationId: string, navigateFrameWait?: number): Promise<HTMLIFrameElement>;
8
+ /**
9
+ * Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
10
+ * @param iframe
11
+ * @param timeout
12
+ */
13
+ export declare function monitorIframeForHash(iframe: HTMLIFrameElement, timeout: number, pollIntervalMilliseconds: number, performanceClient: IPerformanceClient, logger: Logger, correlationId: string): Promise<string>;
48
14
  //# sourceMappingURL=SilentHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SilentHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/SilentHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,8BAA8B,EAC9B,uBAAuB,EAEvB,MAAM,EACN,kBAAkB,EAGrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACH,oBAAoB,EAEvB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,aAAc,SAAQ,kBAAkB;IACjD,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,wBAAwB,CAAS;gBAGrC,cAAc,EAAE,uBAAuB,EACvC,WAAW,EAAE,mBAAmB,EAChC,eAAe,EAAE,8BAA8B,EAC/C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,QAAQ,CACnB,IAAI,CACA,oBAAoB,EACpB,mBAAmB,GAAG,0BAA0B,CACnD,CACJ,EACD,iBAAiB,EAAE,kBAAkB;IAazC;;;;OAIG;IACG,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0BzE;;;;OAIG;IACH,oBAAoB,CAChB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC;IAiGlB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IA2BjB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAQrB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAK7B"}
1
+ {"version":3,"file":"SilentHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/SilentHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,MAAM,EACN,kBAAkB,EAIrB,MAAM,oBAAoB,CAAC;AAO5B;;;;GAIG;AACH,wBAAsB,mBAAmB,CACrC,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,kBAAkB,EACrC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,iBAAiB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,MAAM,EACf,wBAAwB,EAAE,MAAM,EAChC,iBAAiB,EAAE,kBAAkB,EACrC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
@@ -1,172 +1,137 @@
1
- /*! @azure/msal-browser v3.2.0 2023-10-05 */
1
+ /*! @azure/msal-browser v3.4.0 2023-10-30 */
2
2
  'use strict';
3
- import { PerformanceEvents, invokeAsync, Constants, UrlString } from '@azure/msal-common';
4
- import { InteractionHandler } from './InteractionHandler.mjs';
3
+ import { PerformanceEvents, invokeAsync, invoke } from '@azure/msal-common';
5
4
  import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
6
5
  import { DEFAULT_IFRAME_TIMEOUT_MS } from '../config/Configuration.mjs';
7
- import { emptyNavigateUri, monitorWindowTimeout, hashDoesNotContainKnownProperties, hashEmptyError } from '../error/BrowserAuthErrorCodes.mjs';
6
+ import { emptyNavigateUri, monitorWindowTimeout } from '../error/BrowserAuthErrorCodes.mjs';
8
7
 
9
8
  /*
10
9
  * Copyright (c) Microsoft Corporation. All rights reserved.
11
10
  * Licensed under the MIT License.
12
11
  */
13
- class SilentHandler extends InteractionHandler {
14
- constructor(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions, performanceClient) {
15
- super(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient);
16
- this.navigateFrameWait = systemOptions.navigateFrameWait;
17
- this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
18
- }
19
- /**
20
- * Creates a hidden iframe to given URL using user-requested scopes as an id.
21
- * @param urlNavigate
22
- * @param userRequestScopes
23
- */
24
- async initiateAuthRequest(requestUrl) {
25
- this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerInitiateAuthRequest, this.authCodeRequest.correlationId);
26
- if (!requestUrl) {
27
- // Throw error if request URL is empty.
28
- this.logger.info("Navigate url is empty");
29
- throw createBrowserAuthError(emptyNavigateUri);
30
- }
31
- if (this.navigateFrameWait) {
32
- return await invokeAsync(this.loadFrame.bind(this), PerformanceEvents.SilentHandlerLoadFrame, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(requestUrl);
33
- }
34
- return this.loadFrameSync(requestUrl);
12
+ /**
13
+ * Creates a hidden iframe to given URL using user-requested scopes as an id.
14
+ * @param urlNavigate
15
+ * @param userRequestScopes
16
+ */
17
+ async function initiateAuthRequest(requestUrl, performanceClient, logger, correlationId, navigateFrameWait) {
18
+ performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerInitiateAuthRequest, correlationId);
19
+ if (!requestUrl) {
20
+ // Throw error if request URL is empty.
21
+ logger.info("Navigate url is empty");
22
+ throw createBrowserAuthError(emptyNavigateUri);
35
23
  }
36
- /**
37
- * Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
38
- * @param iframe
39
- * @param timeout
40
- */
41
- monitorIframeForHash(iframe, timeout) {
42
- this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerMonitorIframeForHash, this.authCodeRequest.correlationId);
43
- return new Promise((resolve, reject) => {
44
- if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
45
- this.logger.warning(`system.loadFrameTimeout or system.iframeHashTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`);
46
- }
47
- /*
48
- * Polling for iframes can be purely timing based,
49
- * since we don't need to account for interaction.
50
- */
51
- const nowMark = window.performance.now();
52
- const timeoutMark = nowMark + timeout;
53
- const intervalId = setInterval(() => {
54
- if (window.performance.now() > timeoutMark) {
55
- this.removeHiddenIframe(iframe);
56
- clearInterval(intervalId);
57
- reject(createBrowserAuthError(monitorWindowTimeout));
58
- return;
59
- }
60
- let href = Constants.EMPTY_STRING;
61
- const contentWindow = iframe.contentWindow;
62
- try {
63
- /*
64
- * Will throw if cross origin,
65
- * which should be caught and ignored
66
- * since we need the interval to keep running while on STS UI.
67
- */
68
- href = contentWindow
69
- ? contentWindow.location.href
70
- : Constants.EMPTY_STRING;
71
- }
72
- catch (e) { }
73
- if (!href || href === "about:blank") {
74
- return;
75
- }
76
- const contentHash = contentWindow
77
- ? contentWindow.location.hash
78
- : Constants.EMPTY_STRING;
79
- if (contentHash) {
80
- if (UrlString.hashContainsKnownProperties(contentHash)) {
81
- // Success case
82
- this.removeHiddenIframe(iframe);
83
- clearInterval(intervalId);
84
- resolve(contentHash);
85
- return;
86
- }
87
- else {
88
- // Hash is present but incorrect
89
- this.logger.error("SilentHandler:monitorIFrameForHash - 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.");
90
- this.logger.errorPii(`SilentHandler:monitorIFrameForHash - the url detected in the iframe is: ${href}`);
91
- this.removeHiddenIframe(iframe);
92
- clearInterval(intervalId);
93
- reject(createBrowserAuthError(hashDoesNotContainKnownProperties));
94
- return;
95
- }
96
- }
97
- else {
98
- // No hash is present
99
- this.logger.error("SilentHandler:monitorIFrameForHash - 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.");
100
- this.logger.errorPii(`SilentHandler:monitorIFrameForHash - the url detected in the iframe is: ${href}`);
101
- this.removeHiddenIframe(iframe);
102
- clearInterval(intervalId);
103
- reject(createBrowserAuthError(hashEmptyError));
104
- return;
105
- }
106
- }, this.pollIntervalMilliseconds);
107
- });
24
+ if (navigateFrameWait) {
25
+ return await invokeAsync(loadFrame, PerformanceEvents.SilentHandlerLoadFrame, logger, performanceClient, correlationId)(requestUrl, navigateFrameWait, performanceClient, correlationId);
108
26
  }
109
- /**
110
- * @hidden
111
- * Loads iframe with authorization endpoint URL
112
- * @ignore
113
- */
114
- loadFrame(urlNavigate) {
115
- this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerLoadFrame, this.authCodeRequest.correlationId);
27
+ return invoke(loadFrameSync, PerformanceEvents.SilentHandlerLoadFrameSync, logger, performanceClient, correlationId)(requestUrl);
28
+ }
29
+ /**
30
+ * Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
31
+ * @param iframe
32
+ * @param timeout
33
+ */
34
+ async function monitorIframeForHash(iframe, timeout, pollIntervalMilliseconds, performanceClient, logger, correlationId) {
35
+ performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerMonitorIframeForHash, correlationId);
36
+ return new Promise((resolve, reject) => {
37
+ if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
38
+ logger.warning(`system.loadFrameTimeout or system.iframeHashTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`);
39
+ }
116
40
  /*
117
- * This trick overcomes iframe navigation in IE
118
- * IE does not load the page consistently in iframe
41
+ * Polling for iframes can be purely timing based,
42
+ * since we don't need to account for interaction.
119
43
  */
120
- return new Promise((resolve, reject) => {
121
- const frameHandle = this.createHiddenIframe();
122
- setTimeout(() => {
123
- if (!frameHandle) {
124
- reject("Unable to load iframe");
125
- return;
126
- }
127
- frameHandle.src = urlNavigate;
128
- resolve(frameHandle);
129
- }, this.navigateFrameWait);
130
- });
131
- }
132
- /**
133
- * @hidden
134
- * Loads the iframe synchronously when the navigateTimeFrame is set to `0`
135
- * @param urlNavigate
136
- * @param frameName
137
- * @param logger
138
- */
139
- loadFrameSync(urlNavigate) {
140
- const frameHandle = this.createHiddenIframe();
141
- frameHandle.src = urlNavigate;
142
- return frameHandle;
143
- }
144
- /**
145
- * @hidden
146
- * Creates a new hidden iframe or gets an existing one for silent token renewal.
147
- * @ignore
148
- */
149
- createHiddenIframe() {
150
- const authFrame = document.createElement("iframe");
151
- authFrame.style.visibility = "hidden";
152
- authFrame.style.position = "absolute";
153
- authFrame.style.width = authFrame.style.height = "0";
154
- authFrame.style.border = "0";
155
- authFrame.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
156
- document.getElementsByTagName("body")[0].appendChild(authFrame);
157
- return authFrame;
158
- }
159
- /**
160
- * @hidden
161
- * Removes a hidden iframe from the page.
162
- * @ignore
44
+ const timeoutId = window.setTimeout(() => {
45
+ window.clearInterval(intervalId);
46
+ reject(createBrowserAuthError(monitorWindowTimeout));
47
+ }, timeout);
48
+ const intervalId = window.setInterval(() => {
49
+ let href = "";
50
+ const contentWindow = iframe.contentWindow;
51
+ try {
52
+ /*
53
+ * Will throw if cross origin,
54
+ * which should be caught and ignored
55
+ * since we need the interval to keep running while on STS UI.
56
+ */
57
+ href = contentWindow ? contentWindow.location.href : "";
58
+ }
59
+ catch (e) { }
60
+ if (!href || href === "about:blank") {
61
+ return;
62
+ }
63
+ const contentHash = contentWindow
64
+ ? contentWindow.location.hash
65
+ : "";
66
+ window.clearTimeout(timeoutId);
67
+ window.clearInterval(intervalId);
68
+ resolve(contentHash);
69
+ }, pollIntervalMilliseconds);
70
+ }).finally(() => {
71
+ invoke(removeHiddenIframe, PerformanceEvents.RemoveHiddenIframe, logger, performanceClient, correlationId)(iframe);
72
+ });
73
+ }
74
+ /**
75
+ * @hidden
76
+ * Loads iframe with authorization endpoint URL
77
+ * @ignore
78
+ * @deprecated
79
+ */
80
+ function loadFrame(urlNavigate, navigateFrameWait, performanceClient, correlationId) {
81
+ performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerLoadFrame, correlationId);
82
+ /*
83
+ * This trick overcomes iframe navigation in IE
84
+ * IE does not load the page consistently in iframe
163
85
  */
164
- removeHiddenIframe(iframe) {
165
- if (document.body === iframe.parentNode) {
166
- document.body.removeChild(iframe);
167
- }
86
+ return new Promise((resolve, reject) => {
87
+ const frameHandle = createHiddenIframe();
88
+ window.setTimeout(() => {
89
+ if (!frameHandle) {
90
+ reject("Unable to load iframe");
91
+ return;
92
+ }
93
+ frameHandle.src = urlNavigate;
94
+ resolve(frameHandle);
95
+ }, navigateFrameWait);
96
+ });
97
+ }
98
+ /**
99
+ * @hidden
100
+ * Loads the iframe synchronously when the navigateTimeFrame is set to `0`
101
+ * @param urlNavigate
102
+ * @param frameName
103
+ * @param logger
104
+ */
105
+ function loadFrameSync(urlNavigate) {
106
+ const frameHandle = createHiddenIframe();
107
+ frameHandle.src = urlNavigate;
108
+ return frameHandle;
109
+ }
110
+ /**
111
+ * @hidden
112
+ * Creates a new hidden iframe or gets an existing one for silent token renewal.
113
+ * @ignore
114
+ */
115
+ function createHiddenIframe() {
116
+ const authFrame = document.createElement("iframe");
117
+ authFrame.style.visibility = "hidden";
118
+ authFrame.style.position = "absolute";
119
+ authFrame.style.width = authFrame.style.height = "0";
120
+ authFrame.style.border = "0";
121
+ authFrame.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
122
+ document.getElementsByTagName("body")[0].appendChild(authFrame);
123
+ return authFrame;
124
+ }
125
+ /**
126
+ * @hidden
127
+ * Removes a hidden iframe from the page.
128
+ * @ignore
129
+ */
130
+ function removeHiddenIframe(iframe) {
131
+ if (document.body === iframe.parentNode) {
132
+ document.body.removeChild(iframe);
168
133
  }
169
134
  }
170
135
 
171
- export { SilentHandler };
136
+ export { initiateAuthRequest, monitorIframeForHash };
172
137
  //# sourceMappingURL=SilentHandler.mjs.map