daftari 3.13.1 → 3.14.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 (250) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/distill/propose.d.ts.map +1 -1
  3. package/dist/distill/propose.js +10 -3
  4. package/dist/distill/propose.js.map +1 -1
  5. package/dist/extract/index.d.ts +16 -0
  6. package/dist/extract/index.d.ts.map +1 -0
  7. package/dist/extract/index.js +95 -0
  8. package/dist/extract/index.js.map +1 -0
  9. package/dist/extract/normalize.d.ts +7 -0
  10. package/dist/extract/normalize.d.ts.map +1 -0
  11. package/dist/extract/normalize.js +52 -0
  12. package/dist/extract/normalize.js.map +1 -0
  13. package/dist/extract/office.d.ts +63 -0
  14. package/dist/extract/office.d.ts.map +1 -0
  15. package/dist/extract/office.js +763 -0
  16. package/dist/extract/office.js.map +1 -0
  17. package/dist/extract/pdf.d.ts +16 -0
  18. package/dist/extract/pdf.d.ts.map +1 -0
  19. package/dist/extract/pdf.js +196 -0
  20. package/dist/extract/pdf.js.map +1 -0
  21. package/dist/extract/types.d.ts +55 -0
  22. package/dist/extract/types.d.ts.map +1 -0
  23. package/dist/extract/types.js +47 -0
  24. package/dist/extract/types.js.map +1 -0
  25. package/dist/extract/worker.d.ts +2 -0
  26. package/dist/extract/worker.d.ts.map +1 -0
  27. package/dist/extract/worker.js +57 -0
  28. package/dist/extract/worker.js.map +1 -0
  29. package/dist/integrations/engine.d.ts +174 -3
  30. package/dist/integrations/engine.d.ts.map +1 -1
  31. package/dist/integrations/engine.js +184 -16
  32. package/dist/integrations/engine.js.map +1 -1
  33. package/dist/integrations/google.d.ts +2 -1
  34. package/dist/integrations/google.d.ts.map +1 -1
  35. package/dist/integrations/google.js +12 -117
  36. package/dist/integrations/google.js.map +1 -1
  37. package/dist/integrations/http-json.d.ts +27 -0
  38. package/dist/integrations/http-json.d.ts.map +1 -0
  39. package/dist/integrations/http-json.js +148 -0
  40. package/dist/integrations/http-json.js.map +1 -0
  41. package/dist/integrations/microsoft.d.ts +22 -0
  42. package/dist/integrations/microsoft.d.ts.map +1 -0
  43. package/dist/integrations/microsoft.js +1780 -0
  44. package/dist/integrations/microsoft.js.map +1 -0
  45. package/dist/integrations/microsoft.ui.d.ts +18 -0
  46. package/dist/integrations/microsoft.ui.d.ts.map +1 -0
  47. package/dist/integrations/microsoft.ui.js +131 -0
  48. package/dist/integrations/microsoft.ui.js.map +1 -0
  49. package/dist/integrations/oauth.d.ts.map +1 -1
  50. package/dist/integrations/oauth.js +10 -2
  51. package/dist/integrations/oauth.js.map +1 -1
  52. package/dist/integrations/queue.d.ts +1 -1
  53. package/dist/integrations/queue.d.ts.map +1 -1
  54. package/dist/integrations/queue.js +23 -1
  55. package/dist/integrations/queue.js.map +1 -1
  56. package/dist/integrations/routes.d.ts +26 -0
  57. package/dist/integrations/routes.d.ts.map +1 -1
  58. package/dist/integrations/routes.js +502 -8
  59. package/dist/integrations/routes.js.map +1 -1
  60. package/dist/integrations/runtime.d.ts +14 -2
  61. package/dist/integrations/runtime.d.ts.map +1 -1
  62. package/dist/integrations/runtime.js +39 -7
  63. package/dist/integrations/runtime.js.map +1 -1
  64. package/dist/integrations/state.d.ts +1 -1
  65. package/dist/integrations/state.d.ts.map +1 -1
  66. package/dist/integrations/state.js +48 -8
  67. package/dist/integrations/state.js.map +1 -1
  68. package/dist/integrations/types.d.ts +54 -3
  69. package/dist/integrations/types.d.ts.map +1 -1
  70. package/dist/integrations/types.js +21 -1
  71. package/dist/integrations/types.js.map +1 -1
  72. package/dist/search/watcher.d.ts.map +1 -1
  73. package/dist/search/watcher.js +3 -22
  74. package/dist/search/watcher.js.map +1 -1
  75. package/dist/serve/index.d.ts.map +1 -1
  76. package/dist/serve/index.js +7 -0
  77. package/dist/serve/index.js.map +1 -1
  78. package/dist/sleep/index.js +2 -2
  79. package/dist/sleep/report.js +1 -1
  80. package/dist/sleep/report.js.map +1 -1
  81. package/dist/sleep/tension-scan.d.ts.map +1 -1
  82. package/dist/sleep/tension-scan.js +0 -0
  83. package/dist/sleep/tension-scan.js.map +1 -1
  84. package/dist/storage/local.d.ts +1 -0
  85. package/dist/storage/local.d.ts.map +1 -1
  86. package/dist/storage/local.js +8 -1
  87. package/dist/storage/local.js.map +1 -1
  88. package/dist/utils/config.d.ts +8 -1
  89. package/dist/utils/config.d.ts.map +1 -1
  90. package/dist/utils/config.js +143 -19
  91. package/dist/utils/config.js.map +1 -1
  92. package/dist/view/pages.d.ts.map +1 -1
  93. package/dist/view/pages.js +11 -0
  94. package/dist/view/pages.js.map +1 -1
  95. package/dist/view/render.d.ts.map +1 -1
  96. package/dist/view/render.js +37 -2
  97. package/dist/view/render.js.map +1 -1
  98. package/package.json +8 -3
  99. package/src/integrations/microsoft/assets/VENDORING.md +109 -0
  100. package/src/integrations/microsoft/assets/glue.js +244 -0
  101. package/src/integrations/microsoft/assets/picker-serializer.js +99 -0
  102. package/src/integrations/microsoft/assets/vendor/msal-browser/app/IPublicClientApplication.mjs +91 -0
  103. package/src/integrations/microsoft/assets/vendor/msal-browser/app/PublicClientApplication.mjs +355 -0
  104. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/NativeStatusCodes.mjs +15 -0
  105. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthDOMHandler.mjs +153 -0
  106. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +271 -0
  107. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthProvider.mjs +95 -0
  108. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/AccountManager.mjs +49 -0
  109. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/AsyncMemoryStorage.mjs +144 -0
  110. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/BrowserCacheManager.mjs +1465 -0
  111. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CacheHelpers.mjs +45 -0
  112. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CacheKeys.mjs +32 -0
  113. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CookieStorage.mjs +94 -0
  114. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/DatabaseStorage.mjs +208 -0
  115. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/EncryptedData.mjs +13 -0
  116. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/LocalStorage.mjs +319 -0
  117. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/MemoryStorage.mjs +48 -0
  118. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/SessionStorage.mjs +46 -0
  119. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/TokenCache.mjs +220 -0
  120. package/src/integrations/microsoft/assets/vendor/msal-browser/config/Configuration.mjs +138 -0
  121. package/src/integrations/microsoft/assets/vendor/msal-browser/controllers/NestedAppAuthController.mjs +483 -0
  122. package/src/integrations/microsoft/assets/vendor/msal-browser/controllers/StandardController.mjs +1532 -0
  123. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/BrowserCrypto.mjs +354 -0
  124. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/CryptoOps.mjs +146 -0
  125. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/PkceGenerator.mjs +63 -0
  126. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/SignedHttpRequest.mjs +50 -0
  127. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/TokenBindingKeyManager.mjs +156 -0
  128. package/src/integrations/microsoft/assets/vendor/msal-browser/encode/Base64Decode.mjs +43 -0
  129. package/src/integrations/microsoft/assets/vendor/msal-browser/encode/Base64Encode.mjs +47 -0
  130. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserAuthError.mjs +26 -0
  131. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserAuthErrorCodes.mjs +65 -0
  132. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserConfigurationAuthError.mjs +24 -0
  133. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserConfigurationAuthErrorCodes.mjs +11 -0
  134. package/src/integrations/microsoft/assets/vendor/msal-browser/error/NativeAuthError.mjs +79 -0
  135. package/src/integrations/microsoft/assets/vendor/msal-browser/error/NativeAuthErrorCodes.mjs +12 -0
  136. package/src/integrations/microsoft/assets/vendor/msal-browser/error/NestedAppAuthError.mjs +25 -0
  137. package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventHandler.mjs +110 -0
  138. package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventMessage.mjs +60 -0
  139. package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventType.mjs +30 -0
  140. package/src/integrations/microsoft/assets/vendor/msal-browser/index.mjs +48 -0
  141. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/BaseInteractionClient.mjs +150 -0
  142. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/HybridSpaAuthorizationCodeClient.mjs +16 -0
  143. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/PlatformAuthInteractionClient.mjs +734 -0
  144. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/PopupClient.mjs +528 -0
  145. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/RedirectClient.mjs +464 -0
  146. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentAuthCodeClient.mjs +85 -0
  147. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentCacheClient.mjs +58 -0
  148. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentIframeClient.mjs +255 -0
  149. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentRefreshClient.mjs +77 -0
  150. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/StandardInteractionClient.mjs +217 -0
  151. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_handler/InteractionHandler.mjs +95 -0
  152. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_handler/SilentHandler.mjs +71 -0
  153. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeError.mjs +11 -0
  154. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeProxy.mjs +152 -0
  155. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeStatusCode.mjs +18 -0
  156. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/mapping/NestedAppAuthAdapter.mjs +239 -0
  157. package/src/integrations/microsoft/assets/vendor/msal-browser/navigation/NavigationClient.mjs +47 -0
  158. package/src/integrations/microsoft/assets/vendor/msal-browser/network/FetchClient.mjs +153 -0
  159. package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/BaseOperatingContext.mjs +112 -0
  160. package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/NestedAppOperatingContext.mjs +79 -0
  161. package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/StandardOperatingContext.mjs +50 -0
  162. package/src/integrations/microsoft/assets/vendor/msal-browser/packageMetadata.mjs +7 -0
  163. package/src/integrations/microsoft/assets/vendor/msal-browser/popup_relay/constants.mjs +20 -0
  164. package/src/integrations/microsoft/assets/vendor/msal-browser/popup_relay/relayClient.mjs +113 -0
  165. package/src/integrations/microsoft/assets/vendor/msal-browser/protocol/Authorize.mjs +326 -0
  166. package/src/integrations/microsoft/assets/vendor/msal-browser/request/RequestHelpers.mjs +143 -0
  167. package/src/integrations/microsoft/assets/vendor/msal-browser/response/ResponseHandler.mjs +45 -0
  168. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceClient.mjs +126 -0
  169. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceEvents.mjs +133 -0
  170. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceMeasurement.mjs +96 -0
  171. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserRootPerformanceEvents.mjs +53 -0
  172. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserConstants.mjs +220 -0
  173. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserProtocolUtils.mjs +27 -0
  174. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserUtils.mjs +364 -0
  175. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/Helpers.mjs +19 -0
  176. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/MsalFrameStatsUtils.mjs +38 -0
  177. package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/PendingRequestRegistry.mjs +63 -0
  178. package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/WebBrokerBridgeError.mjs +38 -0
  179. package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +57 -0
  180. package/src/integrations/microsoft/assets/vendor/msal-common/account/AccountInfo.mjs +91 -0
  181. package/src/integrations/microsoft/assets/vendor/msal-common/account/AuthToken.mjs +70 -0
  182. package/src/integrations/microsoft/assets/vendor/msal-common/account/CcsCredential.mjs +12 -0
  183. package/src/integrations/microsoft/assets/vendor/msal-common/account/ClientInfo.mjs +43 -0
  184. package/src/integrations/microsoft/assets/vendor/msal-common/account/TokenClaims.mjs +24 -0
  185. package/src/integrations/microsoft/assets/vendor/msal-common/authority/Authority.mjs +988 -0
  186. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityFactory.mjs +41 -0
  187. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityMetadata.mjs +158 -0
  188. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityOptions.mjs +20 -0
  189. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityType.mjs +16 -0
  190. package/src/integrations/microsoft/assets/vendor/msal-common/authority/CloudInstanceDiscoveryErrorResponse.mjs +12 -0
  191. package/src/integrations/microsoft/assets/vendor/msal-common/authority/CloudInstanceDiscoveryResponse.mjs +12 -0
  192. package/src/integrations/microsoft/assets/vendor/msal-common/authority/OpenIdConfigResponse.mjs +14 -0
  193. package/src/integrations/microsoft/assets/vendor/msal-common/authority/ProtocolMode.mjs +26 -0
  194. package/src/integrations/microsoft/assets/vendor/msal-common/authority/RegionDiscovery.mjs +116 -0
  195. package/src/integrations/microsoft/assets/vendor/msal-common/cache/CacheManager.mjs +1202 -0
  196. package/src/integrations/microsoft/assets/vendor/msal-common/cache/persistence/TokenCacheContext.mjs +29 -0
  197. package/src/integrations/microsoft/assets/vendor/msal-common/cache/utils/AccountEntityUtils.mjs +222 -0
  198. package/src/integrations/microsoft/assets/vendor/msal-common/cache/utils/CacheHelpers.mjs +294 -0
  199. package/src/integrations/microsoft/assets/vendor/msal-common/client/AuthorizationCodeClient.mjs +289 -0
  200. package/src/integrations/microsoft/assets/vendor/msal-common/client/RefreshTokenClient.mjs +262 -0
  201. package/src/integrations/microsoft/assets/vendor/msal-common/client/SilentFlowClient.mjs +142 -0
  202. package/src/integrations/microsoft/assets/vendor/msal-common/config/ClientConfiguration.mjs +111 -0
  203. package/src/integrations/microsoft/assets/vendor/msal-common/constants/AADServerParamKeys.mjs +74 -0
  204. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/DpopProofGenerator.mjs +152 -0
  205. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/ICrypto.mjs +52 -0
  206. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/ITokenBindingKeyManager.mjs +27 -0
  207. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/JoseHeader.mjs +72 -0
  208. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/PopTokenGenerator.mjs +109 -0
  209. package/src/integrations/microsoft/assets/vendor/msal-common/error/AuthError.mjs +31 -0
  210. package/src/integrations/microsoft/assets/vendor/msal-common/error/AuthErrorCodes.mjs +13 -0
  211. package/src/integrations/microsoft/assets/vendor/msal-common/error/CacheError.mjs +44 -0
  212. package/src/integrations/microsoft/assets/vendor/msal-common/error/CacheErrorCodes.mjs +10 -0
  213. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientAuthError.mjs +26 -0
  214. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientAuthErrorCodes.mjs +46 -0
  215. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientConfigurationError.mjs +23 -0
  216. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientConfigurationErrorCodes.mjs +38 -0
  217. package/src/integrations/microsoft/assets/vendor/msal-common/error/InteractionRequiredAuthError.mjs +73 -0
  218. package/src/integrations/microsoft/assets/vendor/msal-common/error/InteractionRequiredAuthErrorCodes.mjs +53 -0
  219. package/src/integrations/microsoft/assets/vendor/msal-common/error/JoseHeaderError.mjs +24 -0
  220. package/src/integrations/microsoft/assets/vendor/msal-common/error/JoseHeaderErrorCodes.mjs +12 -0
  221. package/src/integrations/microsoft/assets/vendor/msal-common/error/NetworkError.mjs +34 -0
  222. package/src/integrations/microsoft/assets/vendor/msal-common/error/PlatformBrokerError.mjs +48 -0
  223. package/src/integrations/microsoft/assets/vendor/msal-common/error/ServerError.mjs +22 -0
  224. package/src/integrations/microsoft/assets/vendor/msal-common/index-browser.mjs +79 -0
  225. package/src/integrations/microsoft/assets/vendor/msal-common/logger/Logger.mjs +291 -0
  226. package/src/integrations/microsoft/assets/vendor/msal-common/network/INetworkModule.mjs +20 -0
  227. package/src/integrations/microsoft/assets/vendor/msal-common/network/RequestThumbprint.mjs +27 -0
  228. package/src/integrations/microsoft/assets/vendor/msal-common/network/ThrottlingUtils.mjs +91 -0
  229. package/src/integrations/microsoft/assets/vendor/msal-common/packageMetadata.mjs +7 -0
  230. package/src/integrations/microsoft/assets/vendor/msal-common/protocol/Authorize.mjs +239 -0
  231. package/src/integrations/microsoft/assets/vendor/msal-common/protocol/Token.mjs +148 -0
  232. package/src/integrations/microsoft/assets/vendor/msal-common/request/AuthenticationHeaderParser.mjs +63 -0
  233. package/src/integrations/microsoft/assets/vendor/msal-common/request/BaseAuthRequest.mjs +37 -0
  234. package/src/integrations/microsoft/assets/vendor/msal-common/request/RequestParameterBuilder.mjs +529 -0
  235. package/src/integrations/microsoft/assets/vendor/msal-common/request/ScopeSet.mjs +204 -0
  236. package/src/integrations/microsoft/assets/vendor/msal-common/response/ResponseHandler.mjs +432 -0
  237. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceClient.mjs +557 -0
  238. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceEvent.mjs +68 -0
  239. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceEvents.mjs +73 -0
  240. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/StubPerformanceClient.mjs +61 -0
  241. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/server/ServerTelemetryManager.mjs +297 -0
  242. package/src/integrations/microsoft/assets/vendor/msal-common/url/UrlString.mjs +164 -0
  243. package/src/integrations/microsoft/assets/vendor/msal-common/utils/ClientAssertionUtils.mjs +21 -0
  244. package/src/integrations/microsoft/assets/vendor/msal-common/utils/Constants.mjs +304 -0
  245. package/src/integrations/microsoft/assets/vendor/msal-common/utils/FunctionWrappers.mjs +95 -0
  246. package/src/integrations/microsoft/assets/vendor/msal-common/utils/ObjectUtils.mjs +27 -0
  247. package/src/integrations/microsoft/assets/vendor/msal-common/utils/ProtocolUtils.mjs +76 -0
  248. package/src/integrations/microsoft/assets/vendor/msal-common/utils/StringUtils.mjs +82 -0
  249. package/src/integrations/microsoft/assets/vendor/msal-common/utils/TimeUtils.mjs +75 -0
  250. package/src/integrations/microsoft/assets/vendor/msal-common/utils/UrlUtils.mjs +128 -0
@@ -0,0 +1,528 @@
1
+ /*! @azure/msal-browser v5.20.0 2026-08-28 */
2
+ 'use strict';
3
+ import { Constants, invokeAsync, ProtocolMode, PerformanceEvents, invoke, AuthError, UrlString, ProtocolUtils } from '../../msal-common/index-browser.mjs';
4
+ import { StandardInteractionClient, initializeAuthorizationRequest } from './StandardInteractionClient.mjs';
5
+ import { validateRequestMethod, getTokenBindingRequestParams } from '../request/RequestHelpers.mjs';
6
+ import { StandardInteractionClientInitializeAuthorizationRequest, GeneratePkceCodes, StandardInteractionClientCreateAuthCodeClient, DeserializeResponse, HandleResponseCode, StandardInteractionClientGetDiscoveredAuthority, GenerateEarKey, SilentHandlerMonitorIframeForHash, HandleResponseEar } from '../telemetry/BrowserPerformanceEvents.mjs';
7
+ import { EventType } from '../event/EventType.mjs';
8
+ import { InteractionType, ApiId, BrowserConstants } from '../utils/BrowserConstants.mjs';
9
+ import { preconnect, getCurrentUri, waitForBridgeResponse } from '../utils/BrowserUtils.mjs';
10
+ import { buildPopupRelayUrl, waitForPopupRelayResponse } from '../popup_relay/relayClient.mjs';
11
+ import { base64Decode } from '../encode/Base64Decode.mjs';
12
+ import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
13
+ import { deserializeResponse } from '../response/ResponseHandler.mjs';
14
+ import { getAuthCodeRequestUrl, handleResponseCode, handleResponseEAR, getEARFormData, getCodeFormData, getEARForm, getCodeForm } from '../protocol/Authorize.mjs';
15
+ import { generatePkceCodes } from '../crypto/PkceGenerator.mjs';
16
+ import { isPlatformAuthAllowed } from '../broker/nativeBroker/PlatformAuthProvider.mjs';
17
+ import { generateEarKey } from '../crypto/BrowserCrypto.mjs';
18
+ import { initializeServerTelemetryManager, getDiscoveredAuthority, clearCacheOnLogout } from './BaseInteractionClient.mjs';
19
+ import { emptyNavigateUri, emptyWindowError, popupWindowError } from '../error/BrowserAuthErrorCodes.mjs';
20
+
21
+ /*
22
+ * Copyright (c) Microsoft Corporation. All rights reserved.
23
+ * Licensed under the MIT License.
24
+ */
25
+ class PopupClient extends StandardInteractionClient {
26
+ constructor(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, correlationId, platformAuthHandler, waitForPopupResponseHook, tokenBindingKeyManager) {
27
+ super(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId, platformAuthHandler, tokenBindingKeyManager);
28
+ this.nativeStorage = nativeStorageImpl;
29
+ this.eventHandler = eventHandler;
30
+ this.waitForPopupResponseHook = waitForPopupResponseHook;
31
+ }
32
+ /**
33
+ * Acquires tokens by opening a popup window to the /authorize endpoint of the authority
34
+ * @param request
35
+ * @param pkceCodes
36
+ */
37
+ acquireToken(request, pkceCodes) {
38
+ let popupParams = undefined;
39
+ try {
40
+ const popupName = this.generatePopupName(request.scopes || Constants.OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority);
41
+ popupParams = {
42
+ popupName,
43
+ popupWindowAttributes: request.popupWindowAttributes || {},
44
+ popupWindowParent: request.popupWindowParent ?? window,
45
+ };
46
+ this.performanceClient.addFields({ isAsyncPopup: !this.config.system.navigatePopups }, this.correlationId);
47
+ // navigatePopups flag is false. Acquires token without first opening popup. Popup will be opened later asynchronously.
48
+ if (!this.config.system.navigatePopups) {
49
+ this.logger.verbose("162h4u", this.correlationId);
50
+ // Passes on popup position and dimensions if in request
51
+ return this.acquireTokenPopupAsync(request, popupParams, pkceCodes);
52
+ }
53
+ else {
54
+ // navigatePopups flag is set to true. Opens popup before acquiring token.
55
+ // Pre-validate request method to avoid opening popup if the request is invalid
56
+ const validatedRequest = {
57
+ ...request,
58
+ httpMethod: validateRequestMethod(request, this.config.system.protocolMode),
59
+ };
60
+ this.logger.verbose("1f9ok3", this.correlationId);
61
+ popupParams.popup = this.openSizedPopup("about:blank", popupParams);
62
+ return this.acquireTokenPopupAsync(validatedRequest, popupParams, pkceCodes);
63
+ }
64
+ }
65
+ catch (e) {
66
+ return Promise.reject(e);
67
+ }
68
+ }
69
+ /**
70
+ * Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server
71
+ * @param logoutRequest
72
+ */
73
+ logout(logoutRequest) {
74
+ try {
75
+ this.logger.verbose("068rup", this.correlationId);
76
+ const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
77
+ const popupParams = {
78
+ popupName: this.generateLogoutPopupName(validLogoutRequest),
79
+ popupWindowAttributes: logoutRequest?.popupWindowAttributes || {},
80
+ popupWindowParent: logoutRequest?.popupWindowParent ?? window,
81
+ };
82
+ const authority = logoutRequest && logoutRequest.authority;
83
+ const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
84
+ // navigatePopups flag set to false. Acquires token without first opening popup. Popup will be opened later asynchronously.
85
+ if (!this.config.system.navigatePopups) {
86
+ this.logger.verbose("1phd8u", this.correlationId);
87
+ // Passes on popup position and dimensions if in request
88
+ return this.logoutPopupAsync(validLogoutRequest, popupParams, authority, mainWindowRedirectUri);
89
+ }
90
+ else {
91
+ // navigatePopups flag is set to true. Opens popup before logging out.
92
+ this.logger.verbose("1a28da", this.correlationId);
93
+ popupParams.popup = this.openSizedPopup("about:blank", popupParams);
94
+ return this.logoutPopupAsync(validLogoutRequest, popupParams, authority, mainWindowRedirectUri);
95
+ }
96
+ }
97
+ catch (e) {
98
+ // Since this function is synchronous we need to reject
99
+ return Promise.reject(e);
100
+ }
101
+ }
102
+ /**
103
+ * Helper which obtains an access_token for your API via opening a popup window in the user's browser
104
+ * @param request
105
+ * @param popupParams
106
+ * @param pkceCodes
107
+ *
108
+ * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
109
+ */
110
+ async acquireTokenPopupAsync(request, popupParams, pkceCodes) {
111
+ this.logger.verbose("1g77pg", this.correlationId);
112
+ const validRequest = await invokeAsync(initializeAuthorizationRequest, StandardInteractionClientInitializeAuthorizationRequest, this.logger, this.performanceClient, this.correlationId)(request, InteractionType.Popup, this.config, this.browserCrypto, this.browserStorage, this.logger, this.performanceClient, this.correlationId);
113
+ /*
114
+ * Skip pre-connect for async popups to reduce time between user interaction and popup window creation to avoid
115
+ * popup from being blocked by browsers with shorter popup timers
116
+ */
117
+ if (popupParams.popup) {
118
+ preconnect(validRequest.authority);
119
+ }
120
+ const isPlatformBroker = isPlatformAuthAllowed(this.config, this.logger, this.correlationId, this.platformAuthProvider, request.authenticationScheme);
121
+ validRequest.platformBroker = isPlatformBroker;
122
+ if (this.config.system.protocolMode === ProtocolMode.EAR) {
123
+ return this.executeEarFlow(validRequest, popupParams, pkceCodes);
124
+ }
125
+ else {
126
+ return this.executeCodeFlow(validRequest, popupParams, pkceCodes);
127
+ }
128
+ }
129
+ /**
130
+ * Executes auth code + PKCE flow
131
+ * @param request
132
+ * @param popupParams
133
+ * @param pkceCodes
134
+ * @returns
135
+ */
136
+ async executeCodeFlow(request, popupParams, pkceCodes) {
137
+ const correlationId = request.correlationId;
138
+ const serverTelemetryManager = initializeServerTelemetryManager(ApiId.acquireTokenPopup, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
139
+ const pkce = pkceCodes ||
140
+ (await invokeAsync(generatePkceCodes, GeneratePkceCodes, this.logger, this.performanceClient, correlationId)(this.performanceClient, this.logger, correlationId));
141
+ const tokenBindingParams = await getTokenBindingRequestParams(request, this.tokenBindingKeyManager, this.logger, this.performanceClient);
142
+ const popupRequest = {
143
+ ...request,
144
+ codeChallenge: pkce.challenge,
145
+ ...tokenBindingParams,
146
+ };
147
+ try {
148
+ // Initialize the client
149
+ const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, correlationId)({
150
+ serverTelemetryManager,
151
+ requestAuthority: popupRequest.authority,
152
+ requestAzureCloudOptions: popupRequest.azureCloudOptions,
153
+ requestExtraQueryParameters: popupRequest.extraQueryParameters,
154
+ account: popupRequest.account,
155
+ });
156
+ if (popupRequest.httpMethod === Constants.HttpMethod.POST) {
157
+ return await this.executeCodeFlowWithPost(popupRequest, popupParams, authClient, pkce.verifier);
158
+ }
159
+ else {
160
+ // Create acquire token url.
161
+ const navigateUrl = await invokeAsync(getAuthCodeRequestUrl, PerformanceEvents.GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)(this.config, authClient.authority, popupRequest, this.logger, this.performanceClient);
162
+ /*
163
+ * When a popup-relay page is configured, open it top-level
164
+ * (same first-party origin) instead of navigating the popup
165
+ * straight to the IdP, and carry the /authorize URL in its hash.
166
+ * The relay page opens the IdP child popup and relays the
167
+ * response back via postMessage (see waitForPopupResponse).
168
+ */
169
+ const popupRelayUri = this.config.auth.popupRelayUri;
170
+ const popupNavigateUrl = popupRelayUri
171
+ ? buildPopupRelayUrl(popupRelayUri, this.getRelayStateId(request.state, correlationId), { method: "GET", url: navigateUrl }, correlationId)
172
+ : navigateUrl;
173
+ // Show the UI once the url has been created. Get the window handle for the popup.
174
+ const popupWindow = this.initiateAuthRequest(popupNavigateUrl, popupParams);
175
+ this.eventHandler.emitEvent(EventType.POPUP_OPENED, correlationId, InteractionType.Popup, { popupWindow }, null);
176
+ // Wait for the redirect bridge response
177
+ const responseString = await this.waitForPopupResponse(request, popupWindow, popupParams.popupWindowParent);
178
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
179
+ return await invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, pkce.verifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
180
+ }
181
+ }
182
+ catch (e) {
183
+ // Close the synchronous popup if an error is thrown before the window unload event is registered
184
+ popupParams.popup?.close();
185
+ if (e instanceof AuthError) {
186
+ e.correlationId = this.correlationId;
187
+ serverTelemetryManager.cacheFailedRequest(e);
188
+ }
189
+ throw e;
190
+ }
191
+ }
192
+ /**
193
+ * Executes EAR flow
194
+ * @param request
195
+ */
196
+ async executeEarFlow(request, popupParams, pkceCodes) {
197
+ const { correlationId, authority, azureCloudOptions, extraQueryParameters, account, } = request;
198
+ // Get the frame handle for the silent request
199
+ const discoveredAuthority = await invokeAsync(getDiscoveredAuthority, StandardInteractionClientGetDiscoveredAuthority, this.logger, this.performanceClient, correlationId)(this.config, this.correlationId, this.performanceClient, this.browserStorage, this.logger, authority, azureCloudOptions, extraQueryParameters, account);
200
+ const earJwk = await invokeAsync(generateEarKey, GenerateEarKey, this.logger, this.performanceClient, correlationId)();
201
+ const pkce = pkceCodes ||
202
+ (await invokeAsync(generatePkceCodes, GeneratePkceCodes, this.logger, this.performanceClient, correlationId)(this.performanceClient, this.logger, correlationId));
203
+ const tokenBindingParams = await getTokenBindingRequestParams(request, this.tokenBindingKeyManager, this.logger, this.performanceClient);
204
+ const popupRequest = {
205
+ ...request,
206
+ earJwk: earJwk,
207
+ codeChallenge: pkce.challenge,
208
+ ...tokenBindingParams,
209
+ };
210
+ const popupWindow = await this.openPostFormPopup(popupRequest, discoveredAuthority, popupParams, correlationId, true);
211
+ // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
212
+ const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(popupRequest, popupWindow, popupParams.popupWindowParent);
213
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
214
+ if (!serverParams.ear_jwe && serverParams.code) {
215
+ const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, correlationId)({
216
+ serverTelemetryManager: initializeServerTelemetryManager(ApiId.acquireTokenPopup, this.config.auth.clientId, correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled),
217
+ requestAuthority: request.authority,
218
+ requestAzureCloudOptions: request.azureCloudOptions,
219
+ requestExtraQueryParameters: request.extraQueryParameters,
220
+ account: request.account,
221
+ authority: discoveredAuthority,
222
+ });
223
+ return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, pkce.verifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
224
+ }
225
+ else {
226
+ return invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, ApiId.acquireTokenPopup, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
227
+ }
228
+ }
229
+ async executeCodeFlowWithPost(request, popupParams, authClient, pkceVerifier) {
230
+ const correlationId = request.correlationId;
231
+ // Get the frame handle for the silent request
232
+ const discoveredAuthority = await invokeAsync(getDiscoveredAuthority, StandardInteractionClientGetDiscoveredAuthority, this.logger, this.performanceClient, correlationId)(this.config, this.correlationId, this.performanceClient, this.browserStorage, this.logger);
233
+ const popupWindow = await this.openPostFormPopup(request, discoveredAuthority, popupParams, correlationId, false);
234
+ // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
235
+ const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(request, popupWindow, popupParams.popupWindowParent);
236
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
237
+ return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(request, serverParams, pkceVerifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
238
+ }
239
+ /**
240
+ *
241
+ * @param validRequest
242
+ * @param popupName
243
+ * @param requestAuthority
244
+ * @param popup
245
+ * @param mainWindowRedirectUri
246
+ * @param popupWindowAttributes
247
+ */
248
+ async logoutPopupAsync(validRequest, popupParams, requestAuthority, mainWindowRedirectUri) {
249
+ this.logger.verbose("0b7yrk", this.correlationId);
250
+ this.eventHandler.emitEvent(EventType.LOGOUT_START, this.correlationId, InteractionType.Popup, validRequest);
251
+ const serverTelemetryManager = initializeServerTelemetryManager(ApiId.logoutPopup, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
252
+ try {
253
+ // Clear cache on logout
254
+ await clearCacheOnLogout(this.browserStorage, this.browserCrypto, this.logger, this.correlationId, validRequest.account);
255
+ // Initialize the client
256
+ const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, this.correlationId)({
257
+ serverTelemetryManager,
258
+ requestAuthority: requestAuthority,
259
+ account: validRequest.account || undefined,
260
+ });
261
+ try {
262
+ authClient.authority.endSessionEndpoint;
263
+ }
264
+ catch {
265
+ if (validRequest.account?.homeAccountId &&
266
+ validRequest.postLogoutRedirectUri &&
267
+ authClient.authority.protocolMode === ProtocolMode.OIDC) {
268
+ this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, validRequest.correlationId, InteractionType.Popup, validRequest);
269
+ if (mainWindowRedirectUri) {
270
+ const navigationOptions = {
271
+ apiId: ApiId.logoutPopup,
272
+ timeout: this.config.system.redirectNavigationTimeout,
273
+ noHistory: false,
274
+ };
275
+ const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, getCurrentUri(), this.correlationId);
276
+ await this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
277
+ }
278
+ popupParams.popup?.close();
279
+ return;
280
+ }
281
+ }
282
+ // Redirect bridge requires "state" param to work properly
283
+ validRequest.state = ProtocolUtils.setRequestState(this.browserCrypto, validRequest.state || "", {
284
+ interactionType: InteractionType.Popup,
285
+ }, validRequest.correlationId);
286
+ // Create logout string and navigate user window to logout.
287
+ const logoutUri = authClient.getLogoutUri(validRequest);
288
+ this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, validRequest.correlationId, InteractionType.Popup, validRequest);
289
+ /*
290
+ * When a popup-relay page is configured, open it top-level (same
291
+ * first-party origin) and carry the end-session URL in its hash,
292
+ * exactly like the login flow. The relay page opens the IdP child
293
+ * popup and the post-logout redirect page (running the redirect
294
+ * bridge) relays completion back via postMessage — so logout works
295
+ * from an embedded, cross-origin iframe where a direct popup to the
296
+ * IdP cannot. See runPopupRelay / waitForPopupResponse.
297
+ */
298
+ const popupRelayUri = this.config.auth.popupRelayUri;
299
+ const popupNavigateUrl = popupRelayUri
300
+ ? buildPopupRelayUrl(popupRelayUri, this.getRelayStateId(validRequest.state || "", this.correlationId), { method: "GET", url: logoutUri }, this.correlationId)
301
+ : logoutUri;
302
+ // Open the popup window to requestUrl.
303
+ const popupWindow = this.openPopup(popupNavigateUrl, popupParams);
304
+ this.eventHandler.emitEvent(EventType.POPUP_OPENED, validRequest.correlationId, InteractionType.Popup, { popupWindow }, null);
305
+ await this.waitForPopupResponse(validRequest, popupWindow, popupParams.popupWindowParent).catch(() => {
306
+ // Swallow any errors related to monitoring the window. Server logout is best effort
307
+ });
308
+ if (mainWindowRedirectUri) {
309
+ const navigationOptions = {
310
+ apiId: ApiId.logoutPopup,
311
+ timeout: this.config.system.redirectNavigationTimeout,
312
+ noHistory: false,
313
+ };
314
+ const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, getCurrentUri(), this.correlationId);
315
+ this.logger.verbose("0qcur2", this.correlationId);
316
+ this.logger.verbosePii(`0oj7lk ${absoluteUrl}`, this.correlationId);
317
+ await this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
318
+ }
319
+ else {
320
+ this.logger.verbose("03zgcf", this.correlationId);
321
+ }
322
+ }
323
+ catch (e) {
324
+ // Close the synchronous popup if an error is thrown before the window unload event is registered
325
+ popupParams.popup?.close();
326
+ if (e instanceof AuthError) {
327
+ e.correlationId = this.correlationId;
328
+ serverTelemetryManager.cacheFailedRequest(e);
329
+ }
330
+ this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, this.correlationId, InteractionType.Popup, null, e);
331
+ this.eventHandler.emitEvent(EventType.LOGOUT_END, this.correlationId, InteractionType.Popup);
332
+ throw e;
333
+ }
334
+ this.eventHandler.emitEvent(EventType.LOGOUT_END, this.correlationId, InteractionType.Popup);
335
+ }
336
+ /**
337
+ * Opens a popup window with given request Url.
338
+ * @param requestUrl
339
+ */
340
+ initiateAuthRequest(requestUrl, params) {
341
+ // Check that request url is not empty.
342
+ if (requestUrl) {
343
+ this.logger.infoPii(`1kcr9k ${requestUrl}`, this.correlationId);
344
+ // Open the popup window to requestUrl.
345
+ return this.openPopup(requestUrl, params);
346
+ }
347
+ else {
348
+ // Throw error if request URL is empty.
349
+ this.logger.error("1l7hyp", this.correlationId);
350
+ throw createBrowserAuthError(emptyNavigateUri, this.correlationId);
351
+ }
352
+ }
353
+ /**
354
+ * @hidden
355
+ *
356
+ * Configures popup window for login.
357
+ *
358
+ * @param urlNavigate
359
+ * @param title
360
+ * @param popUpWidth
361
+ * @param popUpHeight
362
+ * @param popupWindowAttributes
363
+ * @ignore
364
+ * @hidden
365
+ */
366
+ openPopup(urlNavigate, popupParams) {
367
+ try {
368
+ let popupWindow;
369
+ // Popup window passed in, setting url to navigate to
370
+ if (popupParams.popup) {
371
+ popupWindow = popupParams.popup;
372
+ this.logger.verbosePii(`0cgeo7 ${urlNavigate}`, this.correlationId);
373
+ popupWindow.location.assign(urlNavigate);
374
+ }
375
+ else if (typeof popupParams.popup === "undefined") {
376
+ // Popup will be undefined if it was not passed in
377
+ this.logger.verbosePii(`0c2awd ${urlNavigate}`, this.correlationId);
378
+ popupWindow = this.openSizedPopup(urlNavigate, popupParams);
379
+ }
380
+ // Popup will be null if popups are blocked
381
+ if (!popupWindow) {
382
+ throw createBrowserAuthError(emptyWindowError, this.correlationId);
383
+ }
384
+ try {
385
+ popupWindow.document.title = "Microsoft Authentication";
386
+ }
387
+ catch (e) {
388
+ if (typeof DOMException !== "undefined" &&
389
+ e instanceof DOMException &&
390
+ e.name === "SecurityError") {
391
+ // Cross-origin - title cannot be set
392
+ }
393
+ else {
394
+ this.logger.verbose("1s1yfs", this.correlationId);
395
+ }
396
+ }
397
+ if (popupWindow.focus) {
398
+ popupWindow.focus();
399
+ }
400
+ this.currentWindow = popupWindow;
401
+ return popupWindow;
402
+ }
403
+ catch (e) {
404
+ this.logger.error(`0dxfb9 ${e.message}`, this.correlationId);
405
+ throw createBrowserAuthError(popupWindowError, this.correlationId);
406
+ }
407
+ }
408
+ /**
409
+ * Helper function to set popup window dimensions and position
410
+ * @param urlNavigate
411
+ * @param popupName
412
+ * @param popupWindowAttributes
413
+ * @returns
414
+ */
415
+ openSizedPopup(urlNavigate, { popupName, popupWindowAttributes, popupWindowParent }) {
416
+ /**
417
+ * adding winLeft and winTop to account for dual monitor
418
+ * using screenLeft and screenTop for IE8 and earlier
419
+ */
420
+ const winLeft = popupWindowParent.screenLeft
421
+ ? popupWindowParent.screenLeft
422
+ : popupWindowParent.screenX;
423
+ const winTop = popupWindowParent.screenTop
424
+ ? popupWindowParent.screenTop
425
+ : popupWindowParent.screenY;
426
+ /**
427
+ * window.innerWidth displays browser window"s height and width excluding toolbars
428
+ * using document.documentElement.clientWidth for IE8 and earlier
429
+ */
430
+ const winWidth = popupWindowParent.innerWidth ||
431
+ document.documentElement.clientWidth ||
432
+ document.body.clientWidth;
433
+ const winHeight = popupWindowParent.innerHeight ||
434
+ document.documentElement.clientHeight ||
435
+ document.body.clientHeight;
436
+ let width = popupWindowAttributes.popupSize?.width;
437
+ let height = popupWindowAttributes.popupSize?.height;
438
+ let top = popupWindowAttributes.popupPosition?.top;
439
+ let left = popupWindowAttributes.popupPosition?.left;
440
+ if (!width || width < 0 || width > winWidth) {
441
+ this.logger.verbose("08vfmo", this.correlationId);
442
+ width = BrowserConstants.POPUP_WIDTH;
443
+ }
444
+ if (!height || height < 0 || height > winHeight) {
445
+ this.logger.verbose("09cxa0", this.correlationId);
446
+ height = BrowserConstants.POPUP_HEIGHT;
447
+ }
448
+ if (!top || top < 0 || top > winHeight) {
449
+ this.logger.verbose("1qh4wo", this.correlationId);
450
+ top = Math.max(0, winHeight / 2 - BrowserConstants.POPUP_HEIGHT / 2 + winTop);
451
+ }
452
+ if (!left || left < 0 || left > winWidth) {
453
+ this.logger.verbose("1sz3en", this.correlationId);
454
+ left = Math.max(0, winWidth / 2 - BrowserConstants.POPUP_WIDTH / 2 + winLeft);
455
+ }
456
+ return popupWindowParent.open(urlNavigate, popupName, `width=${width}, height=${height}, top=${top}, left=${left}, scrollbars=yes`);
457
+ }
458
+ /**
459
+ * Generates the name for the popup based on the client id and request
460
+ * @param clientId
461
+ * @param request
462
+ */
463
+ generatePopupName(scopes, authority) {
464
+ return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${scopes.join("-")}.${authority}.${this.correlationId}`;
465
+ }
466
+ /**
467
+ * Generates the name for the popup based on the client id and request for logouts
468
+ * @param clientId
469
+ * @param request
470
+ */
471
+ generateLogoutPopupName(request) {
472
+ const homeAccountId = request.account && request.account.homeAccountId;
473
+ return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${homeAccountId}.${this.correlationId}`;
474
+ }
475
+ /**
476
+ * Decodes the per-request library-state id from the encoded request state.
477
+ */
478
+ getRelayStateId(state, correlationId) {
479
+ return ProtocolUtils.parseRequestState(base64Decode, state, correlationId).libraryState.id;
480
+ }
481
+ /**
482
+ * Opens the interactive popup for a POST-form /authorize request. Shared by
483
+ * the auth-code POST and EAR flows, which are identical apart from the form
484
+ * builder (`isEAR` selects the EAR vs auth-code builders). When a
485
+ * popup-relay page is configured the form is carried to the relay page
486
+ * (which opens the IdP child popup); otherwise the form is submitted
487
+ * directly into the popup.
488
+ */
489
+ async openPostFormPopup(request, discoveredAuthority, popupParams, correlationId, isEAR) {
490
+ const popupRelayUri = this.config.auth.popupRelayUri;
491
+ if (popupRelayUri) {
492
+ const getFormData = isEAR
493
+ ? getEARFormData
494
+ : getCodeFormData;
495
+ const formData = await getFormData(this.config, discoveredAuthority, request, this.logger, this.performanceClient);
496
+ const relayUrl = buildPopupRelayUrl(popupRelayUri, this.getRelayStateId(request.state, correlationId), {
497
+ method: "POST",
498
+ action: formData.action,
499
+ fields: formData.fields,
500
+ }, correlationId);
501
+ return this.initiateAuthRequest(relayUrl, popupParams);
502
+ }
503
+ const popupWindow = popupParams.popup || this.openPopup("about:blank", popupParams);
504
+ const getForm = isEAR ? getEARForm : getCodeForm;
505
+ const form = await getForm(popupWindow.document, this.config, discoveredAuthority, request, this.logger, this.performanceClient);
506
+ form.submit();
507
+ return popupWindow;
508
+ }
509
+ async waitForPopupResponse(request, popupWindow, popupWindowParent) {
510
+ /*
511
+ * When a popup-relay page is configured the response is relayed back to
512
+ * this frame by the relay page via postMessage, and the relay popup's
513
+ * lifecycle (including the user dismissing it before signing in) must be
514
+ * tracked here. This takes precedence over the default bridge response
515
+ * hook, whose BroadcastChannel cannot reach a partitioned cross-site
516
+ * frame and which does not track the relay popup.
517
+ */
518
+ if (this.config.auth.popupRelayUri) {
519
+ return waitForPopupRelayResponse(this.config.system.popupBridgeTimeout, this.logger, request, popupWindow, this.performanceClient);
520
+ }
521
+ if (this.waitForPopupResponseHook) {
522
+ return this.waitForPopupResponseHook(request, popupWindow, popupWindowParent);
523
+ }
524
+ return waitForBridgeResponse(this.config.system.popupBridgeTimeout, this.logger, request, this.performanceClient);
525
+ }
526
+ }
527
+
528
+ export { PopupClient };