daftari 3.13.0 → 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 (267) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/distill/propose.d.ts +10 -0
  3. package/dist/distill/propose.d.ts.map +1 -1
  4. package/dist/distill/propose.js +49 -10
  5. package/dist/distill/propose.js.map +1 -1
  6. package/dist/distill/state.d.ts +6 -0
  7. package/dist/distill/state.d.ts.map +1 -1
  8. package/dist/distill/state.js +1 -1
  9. package/dist/distill/state.js.map +1 -1
  10. package/dist/extract/index.d.ts +16 -0
  11. package/dist/extract/index.d.ts.map +1 -0
  12. package/dist/extract/index.js +95 -0
  13. package/dist/extract/index.js.map +1 -0
  14. package/dist/extract/normalize.d.ts +7 -0
  15. package/dist/extract/normalize.d.ts.map +1 -0
  16. package/dist/extract/normalize.js +52 -0
  17. package/dist/extract/normalize.js.map +1 -0
  18. package/dist/extract/office.d.ts +63 -0
  19. package/dist/extract/office.d.ts.map +1 -0
  20. package/dist/extract/office.js +763 -0
  21. package/dist/extract/office.js.map +1 -0
  22. package/dist/extract/pdf.d.ts +16 -0
  23. package/dist/extract/pdf.d.ts.map +1 -0
  24. package/dist/extract/pdf.js +196 -0
  25. package/dist/extract/pdf.js.map +1 -0
  26. package/dist/extract/types.d.ts +55 -0
  27. package/dist/extract/types.d.ts.map +1 -0
  28. package/dist/extract/types.js +47 -0
  29. package/dist/extract/types.js.map +1 -0
  30. package/dist/extract/worker.d.ts +2 -0
  31. package/dist/extract/worker.d.ts.map +1 -0
  32. package/dist/extract/worker.js +57 -0
  33. package/dist/extract/worker.js.map +1 -0
  34. package/dist/integrations/distill.d.ts.map +1 -1
  35. package/dist/integrations/distill.js +1 -0
  36. package/dist/integrations/distill.js.map +1 -1
  37. package/dist/integrations/engine.d.ts +208 -2
  38. package/dist/integrations/engine.d.ts.map +1 -1
  39. package/dist/integrations/engine.js +360 -30
  40. package/dist/integrations/engine.js.map +1 -1
  41. package/dist/integrations/google.d.ts +2 -1
  42. package/dist/integrations/google.d.ts.map +1 -1
  43. package/dist/integrations/google.js +13 -117
  44. package/dist/integrations/google.js.map +1 -1
  45. package/dist/integrations/http-json.d.ts +27 -0
  46. package/dist/integrations/http-json.d.ts.map +1 -0
  47. package/dist/integrations/http-json.js +148 -0
  48. package/dist/integrations/http-json.js.map +1 -0
  49. package/dist/integrations/microsoft.d.ts +22 -0
  50. package/dist/integrations/microsoft.d.ts.map +1 -0
  51. package/dist/integrations/microsoft.js +1780 -0
  52. package/dist/integrations/microsoft.js.map +1 -0
  53. package/dist/integrations/microsoft.ui.d.ts +18 -0
  54. package/dist/integrations/microsoft.ui.d.ts.map +1 -0
  55. package/dist/integrations/microsoft.ui.js +131 -0
  56. package/dist/integrations/microsoft.ui.js.map +1 -0
  57. package/dist/integrations/oauth.d.ts.map +1 -1
  58. package/dist/integrations/oauth.js +10 -2
  59. package/dist/integrations/oauth.js.map +1 -1
  60. package/dist/integrations/queue.d.ts +1 -1
  61. package/dist/integrations/queue.d.ts.map +1 -1
  62. package/dist/integrations/queue.js +23 -1
  63. package/dist/integrations/queue.js.map +1 -1
  64. package/dist/integrations/routes.d.ts +26 -0
  65. package/dist/integrations/routes.d.ts.map +1 -1
  66. package/dist/integrations/routes.js +525 -11
  67. package/dist/integrations/routes.js.map +1 -1
  68. package/dist/integrations/runtime.d.ts +14 -2
  69. package/dist/integrations/runtime.d.ts.map +1 -1
  70. package/dist/integrations/runtime.js +51 -11
  71. package/dist/integrations/runtime.js.map +1 -1
  72. package/dist/integrations/state.d.ts +1 -1
  73. package/dist/integrations/state.d.ts.map +1 -1
  74. package/dist/integrations/state.js +74 -5
  75. package/dist/integrations/state.js.map +1 -1
  76. package/dist/integrations/types.d.ts +84 -1
  77. package/dist/integrations/types.d.ts.map +1 -1
  78. package/dist/integrations/types.js +21 -1
  79. package/dist/integrations/types.js.map +1 -1
  80. package/dist/okf/import.d.ts.map +1 -1
  81. package/dist/okf/import.js +208 -65
  82. package/dist/okf/import.js.map +1 -1
  83. package/dist/okf/index.d.ts.map +1 -1
  84. package/dist/okf/index.js +5 -0
  85. package/dist/okf/index.js.map +1 -1
  86. package/dist/okf/map.d.ts.map +1 -1
  87. package/dist/okf/map.js +3 -2
  88. package/dist/okf/map.js.map +1 -1
  89. package/dist/search/watcher.d.ts.map +1 -1
  90. package/dist/search/watcher.js +3 -22
  91. package/dist/search/watcher.js.map +1 -1
  92. package/dist/serve/index.d.ts.map +1 -1
  93. package/dist/serve/index.js +7 -0
  94. package/dist/serve/index.js.map +1 -1
  95. package/dist/sleep/index.js +2 -2
  96. package/dist/sleep/report.js +1 -1
  97. package/dist/sleep/report.js.map +1 -1
  98. package/dist/sleep/tension-scan.d.ts.map +1 -1
  99. package/dist/sleep/tension-scan.js +0 -0
  100. package/dist/sleep/tension-scan.js.map +1 -1
  101. package/dist/storage/local.d.ts +1 -0
  102. package/dist/storage/local.d.ts.map +1 -1
  103. package/dist/storage/local.js +8 -1
  104. package/dist/storage/local.js.map +1 -1
  105. package/dist/utils/config.d.ts +8 -1
  106. package/dist/utils/config.d.ts.map +1 -1
  107. package/dist/utils/config.js +143 -18
  108. package/dist/utils/config.js.map +1 -1
  109. package/dist/view/pages.d.ts.map +1 -1
  110. package/dist/view/pages.js +11 -0
  111. package/dist/view/pages.js.map +1 -1
  112. package/dist/view/render.d.ts.map +1 -1
  113. package/dist/view/render.js +37 -2
  114. package/dist/view/render.js.map +1 -1
  115. package/package.json +11 -4
  116. package/src/integrations/microsoft/assets/VENDORING.md +109 -0
  117. package/src/integrations/microsoft/assets/glue.js +244 -0
  118. package/src/integrations/microsoft/assets/picker-serializer.js +99 -0
  119. package/src/integrations/microsoft/assets/vendor/msal-browser/app/IPublicClientApplication.mjs +91 -0
  120. package/src/integrations/microsoft/assets/vendor/msal-browser/app/PublicClientApplication.mjs +355 -0
  121. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/NativeStatusCodes.mjs +15 -0
  122. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthDOMHandler.mjs +153 -0
  123. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +271 -0
  124. package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthProvider.mjs +95 -0
  125. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/AccountManager.mjs +49 -0
  126. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/AsyncMemoryStorage.mjs +144 -0
  127. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/BrowserCacheManager.mjs +1465 -0
  128. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CacheHelpers.mjs +45 -0
  129. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CacheKeys.mjs +32 -0
  130. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CookieStorage.mjs +94 -0
  131. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/DatabaseStorage.mjs +208 -0
  132. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/EncryptedData.mjs +13 -0
  133. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/LocalStorage.mjs +319 -0
  134. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/MemoryStorage.mjs +48 -0
  135. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/SessionStorage.mjs +46 -0
  136. package/src/integrations/microsoft/assets/vendor/msal-browser/cache/TokenCache.mjs +220 -0
  137. package/src/integrations/microsoft/assets/vendor/msal-browser/config/Configuration.mjs +138 -0
  138. package/src/integrations/microsoft/assets/vendor/msal-browser/controllers/NestedAppAuthController.mjs +483 -0
  139. package/src/integrations/microsoft/assets/vendor/msal-browser/controllers/StandardController.mjs +1532 -0
  140. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/BrowserCrypto.mjs +354 -0
  141. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/CryptoOps.mjs +146 -0
  142. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/PkceGenerator.mjs +63 -0
  143. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/SignedHttpRequest.mjs +50 -0
  144. package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/TokenBindingKeyManager.mjs +156 -0
  145. package/src/integrations/microsoft/assets/vendor/msal-browser/encode/Base64Decode.mjs +43 -0
  146. package/src/integrations/microsoft/assets/vendor/msal-browser/encode/Base64Encode.mjs +47 -0
  147. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserAuthError.mjs +26 -0
  148. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserAuthErrorCodes.mjs +65 -0
  149. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserConfigurationAuthError.mjs +24 -0
  150. package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserConfigurationAuthErrorCodes.mjs +11 -0
  151. package/src/integrations/microsoft/assets/vendor/msal-browser/error/NativeAuthError.mjs +79 -0
  152. package/src/integrations/microsoft/assets/vendor/msal-browser/error/NativeAuthErrorCodes.mjs +12 -0
  153. package/src/integrations/microsoft/assets/vendor/msal-browser/error/NestedAppAuthError.mjs +25 -0
  154. package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventHandler.mjs +110 -0
  155. package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventMessage.mjs +60 -0
  156. package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventType.mjs +30 -0
  157. package/src/integrations/microsoft/assets/vendor/msal-browser/index.mjs +48 -0
  158. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/BaseInteractionClient.mjs +150 -0
  159. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/HybridSpaAuthorizationCodeClient.mjs +16 -0
  160. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/PlatformAuthInteractionClient.mjs +734 -0
  161. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/PopupClient.mjs +528 -0
  162. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/RedirectClient.mjs +464 -0
  163. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentAuthCodeClient.mjs +85 -0
  164. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentCacheClient.mjs +58 -0
  165. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentIframeClient.mjs +255 -0
  166. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentRefreshClient.mjs +77 -0
  167. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/StandardInteractionClient.mjs +217 -0
  168. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_handler/InteractionHandler.mjs +95 -0
  169. package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_handler/SilentHandler.mjs +71 -0
  170. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeError.mjs +11 -0
  171. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeProxy.mjs +152 -0
  172. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeStatusCode.mjs +18 -0
  173. package/src/integrations/microsoft/assets/vendor/msal-browser/naa/mapping/NestedAppAuthAdapter.mjs +239 -0
  174. package/src/integrations/microsoft/assets/vendor/msal-browser/navigation/NavigationClient.mjs +47 -0
  175. package/src/integrations/microsoft/assets/vendor/msal-browser/network/FetchClient.mjs +153 -0
  176. package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/BaseOperatingContext.mjs +112 -0
  177. package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/NestedAppOperatingContext.mjs +79 -0
  178. package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/StandardOperatingContext.mjs +50 -0
  179. package/src/integrations/microsoft/assets/vendor/msal-browser/packageMetadata.mjs +7 -0
  180. package/src/integrations/microsoft/assets/vendor/msal-browser/popup_relay/constants.mjs +20 -0
  181. package/src/integrations/microsoft/assets/vendor/msal-browser/popup_relay/relayClient.mjs +113 -0
  182. package/src/integrations/microsoft/assets/vendor/msal-browser/protocol/Authorize.mjs +326 -0
  183. package/src/integrations/microsoft/assets/vendor/msal-browser/request/RequestHelpers.mjs +143 -0
  184. package/src/integrations/microsoft/assets/vendor/msal-browser/response/ResponseHandler.mjs +45 -0
  185. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceClient.mjs +126 -0
  186. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceEvents.mjs +133 -0
  187. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceMeasurement.mjs +96 -0
  188. package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserRootPerformanceEvents.mjs +53 -0
  189. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserConstants.mjs +220 -0
  190. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserProtocolUtils.mjs +27 -0
  191. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserUtils.mjs +364 -0
  192. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/Helpers.mjs +19 -0
  193. package/src/integrations/microsoft/assets/vendor/msal-browser/utils/MsalFrameStatsUtils.mjs +38 -0
  194. package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/PendingRequestRegistry.mjs +63 -0
  195. package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/WebBrokerBridgeError.mjs +38 -0
  196. package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +57 -0
  197. package/src/integrations/microsoft/assets/vendor/msal-common/account/AccountInfo.mjs +91 -0
  198. package/src/integrations/microsoft/assets/vendor/msal-common/account/AuthToken.mjs +70 -0
  199. package/src/integrations/microsoft/assets/vendor/msal-common/account/CcsCredential.mjs +12 -0
  200. package/src/integrations/microsoft/assets/vendor/msal-common/account/ClientInfo.mjs +43 -0
  201. package/src/integrations/microsoft/assets/vendor/msal-common/account/TokenClaims.mjs +24 -0
  202. package/src/integrations/microsoft/assets/vendor/msal-common/authority/Authority.mjs +988 -0
  203. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityFactory.mjs +41 -0
  204. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityMetadata.mjs +158 -0
  205. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityOptions.mjs +20 -0
  206. package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityType.mjs +16 -0
  207. package/src/integrations/microsoft/assets/vendor/msal-common/authority/CloudInstanceDiscoveryErrorResponse.mjs +12 -0
  208. package/src/integrations/microsoft/assets/vendor/msal-common/authority/CloudInstanceDiscoveryResponse.mjs +12 -0
  209. package/src/integrations/microsoft/assets/vendor/msal-common/authority/OpenIdConfigResponse.mjs +14 -0
  210. package/src/integrations/microsoft/assets/vendor/msal-common/authority/ProtocolMode.mjs +26 -0
  211. package/src/integrations/microsoft/assets/vendor/msal-common/authority/RegionDiscovery.mjs +116 -0
  212. package/src/integrations/microsoft/assets/vendor/msal-common/cache/CacheManager.mjs +1202 -0
  213. package/src/integrations/microsoft/assets/vendor/msal-common/cache/persistence/TokenCacheContext.mjs +29 -0
  214. package/src/integrations/microsoft/assets/vendor/msal-common/cache/utils/AccountEntityUtils.mjs +222 -0
  215. package/src/integrations/microsoft/assets/vendor/msal-common/cache/utils/CacheHelpers.mjs +294 -0
  216. package/src/integrations/microsoft/assets/vendor/msal-common/client/AuthorizationCodeClient.mjs +289 -0
  217. package/src/integrations/microsoft/assets/vendor/msal-common/client/RefreshTokenClient.mjs +262 -0
  218. package/src/integrations/microsoft/assets/vendor/msal-common/client/SilentFlowClient.mjs +142 -0
  219. package/src/integrations/microsoft/assets/vendor/msal-common/config/ClientConfiguration.mjs +111 -0
  220. package/src/integrations/microsoft/assets/vendor/msal-common/constants/AADServerParamKeys.mjs +74 -0
  221. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/DpopProofGenerator.mjs +152 -0
  222. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/ICrypto.mjs +52 -0
  223. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/ITokenBindingKeyManager.mjs +27 -0
  224. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/JoseHeader.mjs +72 -0
  225. package/src/integrations/microsoft/assets/vendor/msal-common/crypto/PopTokenGenerator.mjs +109 -0
  226. package/src/integrations/microsoft/assets/vendor/msal-common/error/AuthError.mjs +31 -0
  227. package/src/integrations/microsoft/assets/vendor/msal-common/error/AuthErrorCodes.mjs +13 -0
  228. package/src/integrations/microsoft/assets/vendor/msal-common/error/CacheError.mjs +44 -0
  229. package/src/integrations/microsoft/assets/vendor/msal-common/error/CacheErrorCodes.mjs +10 -0
  230. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientAuthError.mjs +26 -0
  231. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientAuthErrorCodes.mjs +46 -0
  232. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientConfigurationError.mjs +23 -0
  233. package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientConfigurationErrorCodes.mjs +38 -0
  234. package/src/integrations/microsoft/assets/vendor/msal-common/error/InteractionRequiredAuthError.mjs +73 -0
  235. package/src/integrations/microsoft/assets/vendor/msal-common/error/InteractionRequiredAuthErrorCodes.mjs +53 -0
  236. package/src/integrations/microsoft/assets/vendor/msal-common/error/JoseHeaderError.mjs +24 -0
  237. package/src/integrations/microsoft/assets/vendor/msal-common/error/JoseHeaderErrorCodes.mjs +12 -0
  238. package/src/integrations/microsoft/assets/vendor/msal-common/error/NetworkError.mjs +34 -0
  239. package/src/integrations/microsoft/assets/vendor/msal-common/error/PlatformBrokerError.mjs +48 -0
  240. package/src/integrations/microsoft/assets/vendor/msal-common/error/ServerError.mjs +22 -0
  241. package/src/integrations/microsoft/assets/vendor/msal-common/index-browser.mjs +79 -0
  242. package/src/integrations/microsoft/assets/vendor/msal-common/logger/Logger.mjs +291 -0
  243. package/src/integrations/microsoft/assets/vendor/msal-common/network/INetworkModule.mjs +20 -0
  244. package/src/integrations/microsoft/assets/vendor/msal-common/network/RequestThumbprint.mjs +27 -0
  245. package/src/integrations/microsoft/assets/vendor/msal-common/network/ThrottlingUtils.mjs +91 -0
  246. package/src/integrations/microsoft/assets/vendor/msal-common/packageMetadata.mjs +7 -0
  247. package/src/integrations/microsoft/assets/vendor/msal-common/protocol/Authorize.mjs +239 -0
  248. package/src/integrations/microsoft/assets/vendor/msal-common/protocol/Token.mjs +148 -0
  249. package/src/integrations/microsoft/assets/vendor/msal-common/request/AuthenticationHeaderParser.mjs +63 -0
  250. package/src/integrations/microsoft/assets/vendor/msal-common/request/BaseAuthRequest.mjs +37 -0
  251. package/src/integrations/microsoft/assets/vendor/msal-common/request/RequestParameterBuilder.mjs +529 -0
  252. package/src/integrations/microsoft/assets/vendor/msal-common/request/ScopeSet.mjs +204 -0
  253. package/src/integrations/microsoft/assets/vendor/msal-common/response/ResponseHandler.mjs +432 -0
  254. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceClient.mjs +557 -0
  255. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceEvent.mjs +68 -0
  256. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceEvents.mjs +73 -0
  257. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/StubPerformanceClient.mjs +61 -0
  258. package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/server/ServerTelemetryManager.mjs +297 -0
  259. package/src/integrations/microsoft/assets/vendor/msal-common/url/UrlString.mjs +164 -0
  260. package/src/integrations/microsoft/assets/vendor/msal-common/utils/ClientAssertionUtils.mjs +21 -0
  261. package/src/integrations/microsoft/assets/vendor/msal-common/utils/Constants.mjs +304 -0
  262. package/src/integrations/microsoft/assets/vendor/msal-common/utils/FunctionWrappers.mjs +95 -0
  263. package/src/integrations/microsoft/assets/vendor/msal-common/utils/ObjectUtils.mjs +27 -0
  264. package/src/integrations/microsoft/assets/vendor/msal-common/utils/ProtocolUtils.mjs +76 -0
  265. package/src/integrations/microsoft/assets/vendor/msal-common/utils/StringUtils.mjs +82 -0
  266. package/src/integrations/microsoft/assets/vendor/msal-common/utils/TimeUtils.mjs +75 -0
  267. package/src/integrations/microsoft/assets/vendor/msal-common/utils/UrlUtils.mjs +128 -0
@@ -0,0 +1,988 @@
1
+ /*! @azure/msal-common v16.14.0 2026-08-28 */
2
+ 'use strict';
3
+ import { AuthorityType } from './AuthorityType.mjs';
4
+ import { isOpenIdConfigResponse } from './OpenIdConfigResponse.mjs';
5
+ import { UrlString } from '../url/UrlString.mjs';
6
+ import { createClientAuthError } from '../error/ClientAuthError.mjs';
7
+ import { CIAM_AUTH_URL, ADFS, AuthorityMetadataSource, AZURE_REGION_AUTO_DISCOVER_FLAG, RegionDiscoveryOutcomes, NOT_APPLICABLE, AAD_INSTANCE_DISCOVERY_ENDPT, INVALID_INSTANCE, DEFAULT_AUTHORITY_HOST, AAD_TENANT_DOMAIN_SUFFIX, KNOWN_PUBLIC_CLOUDS, FORWARD_SLASH, DEFAULT_COMMON_TENANT, REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX, AADAuthority } from '../utils/Constants.mjs';
8
+ import { EndpointMetadata, getCloudDiscoveryMetadataFromHardcodedValues, getCloudDiscoveryMetadataFromNetworkResponse, InstanceDiscoveryMetadataAliases } from './AuthorityMetadata.mjs';
9
+ import { createClientConfigurationError } from '../error/ClientConfigurationError.mjs';
10
+ import { ProtocolMode } from './ProtocolMode.mjs';
11
+ import { AzureCloudInstance } from './AuthorityOptions.mjs';
12
+ import { isCloudInstanceDiscoveryResponse } from './CloudInstanceDiscoveryResponse.mjs';
13
+ import { isCloudInstanceDiscoveryErrorResponse } from './CloudInstanceDiscoveryErrorResponse.mjs';
14
+ import { RegionDiscovery } from './RegionDiscovery.mjs';
15
+ import { AuthError } from '../error/AuthError.mjs';
16
+ import { AuthorityUpdateCloudDiscoveryMetadata, AuthorityUpdateEndpointMetadata, AuthorityUpdateMetadataWithRegionalInformation, AuthorityGetEndpointMetadataFromNetwork, RegionDiscoveryDetectRegion, AuthorityGetCloudDiscoveryMetadataFromNetwork } from '../telemetry/performance/PerformanceEvents.mjs';
17
+ import { invokeAsync } from '../utils/FunctionWrappers.mjs';
18
+ import { generateAuthorityMetadataExpiresAt, updateAuthorityEndpointMetadata, isAuthorityMetadataExpired, updateCloudDiscoveryMetadata } from '../cache/utils/CacheHelpers.mjs';
19
+ import { endpointResolutionError, endSessionEndpointNotSupported, openIdConfigError } from '../error/ClientAuthErrorCodes.mjs';
20
+ import { invalidAuthorityMetadata, untrustedAuthority, invalidCloudDiscoveryMetadata, issuerValidationFailed } from '../error/ClientConfigurationErrorCodes.mjs';
21
+
22
+ /*
23
+ * Copyright (c) Microsoft Corporation. All rights reserved.
24
+ * Licensed under the MIT License.
25
+ */
26
+ /**
27
+ * The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
28
+ * endpoint. It will store the pertinent config data in this object for use during token calls.
29
+ * @internal
30
+ */
31
+ class Authority {
32
+ constructor(authority, networkInterface, cacheManager, authorityOptions, logger, correlationId, performanceClient, managedIdentity) {
33
+ this.canonicalAuthority = authority;
34
+ this._canonicalAuthority.validateAsUri();
35
+ this.networkInterface = networkInterface;
36
+ this.cacheManager = cacheManager;
37
+ this.authorityOptions = authorityOptions;
38
+ this.regionDiscoveryMetadata = {
39
+ region_used: undefined,
40
+ region_source: undefined,
41
+ region_outcome: undefined,
42
+ };
43
+ this.logger = logger;
44
+ this.performanceClient = performanceClient;
45
+ this.correlationId = correlationId;
46
+ this.managedIdentity = managedIdentity || false;
47
+ this.regionDiscovery = new RegionDiscovery(networkInterface, this.logger, this.performanceClient, this.correlationId);
48
+ }
49
+ /**
50
+ * Get {@link AuthorityType:type}
51
+ * @param authorityUri {@link IUri}
52
+ * @private
53
+ */
54
+ getAuthorityType(authorityUri) {
55
+ // CIAM auth url pattern is being standardized as: <tenant>.ciamlogin.com
56
+ if (authorityUri.HostNameAndPort.endsWith(CIAM_AUTH_URL)) {
57
+ return AuthorityType.Ciam;
58
+ }
59
+ const pathSegments = authorityUri.PathSegments;
60
+ if (pathSegments.length) {
61
+ switch (pathSegments[0].toLowerCase()) {
62
+ case ADFS:
63
+ return AuthorityType.Adfs;
64
+ }
65
+ }
66
+ return AuthorityType.Default;
67
+ }
68
+ // See above for AuthorityType
69
+ get authorityType() {
70
+ return this.getAuthorityType(this.canonicalAuthorityUrlComponents);
71
+ }
72
+ /**
73
+ * ProtocolMode enum representing the way endpoints are constructed.
74
+ */
75
+ get protocolMode() {
76
+ return this.authorityOptions.protocolMode;
77
+ }
78
+ /**
79
+ * Returns authorityOptions which can be used to reinstantiate a new authority instance
80
+ */
81
+ get options() {
82
+ return this.authorityOptions;
83
+ }
84
+ /**
85
+ * A URL that is the authority set by the developer
86
+ */
87
+ get canonicalAuthority() {
88
+ return this._canonicalAuthority.urlString;
89
+ }
90
+ /**
91
+ * Sets canonical authority.
92
+ */
93
+ set canonicalAuthority(url) {
94
+ this._canonicalAuthority = new UrlString(url, this.correlationId);
95
+ this._canonicalAuthority.validateAsUri();
96
+ this._canonicalAuthorityUrlComponents = null;
97
+ }
98
+ /**
99
+ * Get authority components.
100
+ */
101
+ get canonicalAuthorityUrlComponents() {
102
+ if (!this._canonicalAuthorityUrlComponents) {
103
+ this._canonicalAuthorityUrlComponents =
104
+ this._canonicalAuthority.getUrlComponents();
105
+ }
106
+ return this._canonicalAuthorityUrlComponents;
107
+ }
108
+ /**
109
+ * Get hostname and port i.e. login.microsoftonline.com
110
+ */
111
+ get hostnameAndPort() {
112
+ return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();
113
+ }
114
+ /**
115
+ * Get tenant for authority.
116
+ */
117
+ get tenant() {
118
+ return this.canonicalAuthorityUrlComponents.PathSegments[0];
119
+ }
120
+ /**
121
+ * OAuth /authorize endpoint for requests
122
+ */
123
+ get authorizationEndpoint() {
124
+ if (this.discoveryComplete()) {
125
+ return this.replacePath(this.metadata.authorization_endpoint);
126
+ }
127
+ else {
128
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
129
+ }
130
+ }
131
+ /**
132
+ * OAuth /token endpoint for requests
133
+ */
134
+ get tokenEndpoint() {
135
+ if (this.discoveryComplete()) {
136
+ return this.replacePath(this.metadata.token_endpoint);
137
+ }
138
+ else {
139
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
140
+ }
141
+ }
142
+ get deviceCodeEndpoint() {
143
+ if (this.discoveryComplete()) {
144
+ return this.replacePath(this.metadata.token_endpoint.replace("/token", "/devicecode"));
145
+ }
146
+ else {
147
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
148
+ }
149
+ }
150
+ /**
151
+ * OAuth logout endpoint for requests
152
+ */
153
+ get endSessionEndpoint() {
154
+ if (this.discoveryComplete()) {
155
+ // ROPC policies may not have end_session_endpoint set
156
+ if (!this.metadata.end_session_endpoint) {
157
+ throw createClientAuthError(endSessionEndpointNotSupported, this.correlationId);
158
+ }
159
+ return this.replacePath(this.metadata.end_session_endpoint);
160
+ }
161
+ else {
162
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
163
+ }
164
+ }
165
+ /**
166
+ * OAuth issuer for requests
167
+ */
168
+ get selfSignedJwtAudience() {
169
+ if (this.discoveryComplete()) {
170
+ return this.replacePath(this.metadata.issuer);
171
+ }
172
+ else {
173
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
174
+ }
175
+ }
176
+ /**
177
+ * Jwks_uri for token signing keys
178
+ */
179
+ get jwksUri() {
180
+ if (this.discoveryComplete()) {
181
+ return this.replacePath(this.metadata.jwks_uri);
182
+ }
183
+ else {
184
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
185
+ }
186
+ }
187
+ /**
188
+ * Returns a flag indicating that tenant name can be replaced in authority {@link IUri}
189
+ * @param authorityUri {@link IUri}
190
+ * @private
191
+ */
192
+ canReplaceTenant(authorityUri) {
193
+ return (authorityUri.PathSegments.length === 1 &&
194
+ !Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
195
+ this.getAuthorityType(authorityUri) === AuthorityType.Default &&
196
+ this.protocolMode !== ProtocolMode.OIDC);
197
+ }
198
+ /**
199
+ * Replaces tenant in url path with current tenant. Defaults to common.
200
+ * @param urlString
201
+ */
202
+ replaceTenant(urlString) {
203
+ return urlString.replace(/{tenant}|{tenantid}/g, this.tenant);
204
+ }
205
+ /**
206
+ * Replaces path such as tenant or policy with the current tenant or policy.
207
+ * @param urlString
208
+ */
209
+ replacePath(urlString) {
210
+ let endpoint = urlString;
211
+ const cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority, this.correlationId);
212
+ const cachedAuthorityUrlComponents = cachedAuthorityUrl.getUrlComponents();
213
+ const cachedAuthorityParts = cachedAuthorityUrlComponents.PathSegments;
214
+ const currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
215
+ currentAuthorityParts.forEach((currentPart, index) => {
216
+ let cachedPart = cachedAuthorityParts[index];
217
+ if (index === 0 &&
218
+ this.canReplaceTenant(cachedAuthorityUrlComponents)) {
219
+ const tenantId = new UrlString(this.metadata.authorization_endpoint, this.correlationId).getUrlComponents().PathSegments[0];
220
+ /**
221
+ * Check if AAD canonical authority contains tenant domain name, for example "testdomain.onmicrosoft.com",
222
+ * by comparing its first path segment to the corresponding authorization endpoint path segment, which is
223
+ * always resolved with tenant id by OIDC.
224
+ */
225
+ if (cachedPart !== tenantId) {
226
+ this.logger.verbose(`1q3g2x ${cachedPart} ${tenantId}`, this.correlationId);
227
+ cachedPart = tenantId;
228
+ }
229
+ }
230
+ if (currentPart !== cachedPart) {
231
+ endpoint = endpoint.replace(`/${cachedPart}/`, `/${currentPart}/`);
232
+ }
233
+ });
234
+ return this.replaceTenant(endpoint);
235
+ }
236
+ /**
237
+ * The default open id configuration endpoint for any canonical authority.
238
+ */
239
+ get defaultOpenIdConfigurationEndpoint() {
240
+ const canonicalAuthorityHost = this.hostnameAndPort;
241
+ if (this.canonicalAuthority.endsWith("v2.0/") ||
242
+ this.authorityType === AuthorityType.Adfs ||
243
+ (this.protocolMode === ProtocolMode.OIDC &&
244
+ !this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost))) {
245
+ return `${this.canonicalAuthority}.well-known/openid-configuration`;
246
+ }
247
+ return `${this.canonicalAuthority}v2.0/.well-known/openid-configuration`;
248
+ }
249
+ /**
250
+ * Boolean that returns whether or not tenant discovery has been completed.
251
+ */
252
+ discoveryComplete() {
253
+ return !!this.metadata;
254
+ }
255
+ /**
256
+ * Perform endpoint discovery to discover aliases, preferred_cache, preferred_network
257
+ * and the /authorize, /token and logout endpoints.
258
+ */
259
+ async resolveEndpointsAsync() {
260
+ const metadataEntity = this.getCurrentMetadataEntity();
261
+ const cloudDiscoverySource = await invokeAsync(this.updateCloudDiscoveryMetadata.bind(this), AuthorityUpdateCloudDiscoveryMetadata, this.logger, this.performanceClient, this.correlationId)(metadataEntity);
262
+ this.canonicalAuthority = this.canonicalAuthority.replace(this.hostnameAndPort, metadataEntity.preferred_network);
263
+ const endpointSource = await invokeAsync(this.updateEndpointMetadata.bind(this), AuthorityUpdateEndpointMetadata, this.logger, this.performanceClient, this.correlationId)(metadataEntity);
264
+ this.updateCachedMetadata(metadataEntity, cloudDiscoverySource, {
265
+ source: endpointSource,
266
+ });
267
+ this.performanceClient?.addFields({
268
+ cloudDiscoverySource: cloudDiscoverySource,
269
+ authorityEndpointSource: endpointSource,
270
+ }, this.correlationId);
271
+ }
272
+ /**
273
+ * Returns metadata entity from cache if it exists, otherwise returns a new metadata entity built
274
+ * from the configured canonical authority
275
+ * @returns
276
+ */
277
+ getCurrentMetadataEntity() {
278
+ let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort, this.correlationId);
279
+ if (!metadataEntity) {
280
+ metadataEntity = {
281
+ aliases: [],
282
+ preferred_cache: this.hostnameAndPort,
283
+ preferred_network: this.hostnameAndPort,
284
+ canonical_authority: this.canonicalAuthority,
285
+ authorization_endpoint: "",
286
+ token_endpoint: "",
287
+ end_session_endpoint: "",
288
+ issuer: "",
289
+ aliasesFromNetwork: false,
290
+ endpointsFromNetwork: false,
291
+ expiresAt: generateAuthorityMetadataExpiresAt(),
292
+ jwks_uri: "",
293
+ };
294
+ }
295
+ return metadataEntity;
296
+ }
297
+ /**
298
+ * Updates cached metadata based on metadata source and sets the instance's metadata
299
+ * property to the same value
300
+ * @param metadataEntity
301
+ * @param cloudDiscoverySource
302
+ * @param endpointMetadataResult
303
+ */
304
+ updateCachedMetadata(metadataEntity, cloudDiscoverySource, endpointMetadataResult) {
305
+ if (cloudDiscoverySource !== AuthorityMetadataSource.CACHE &&
306
+ endpointMetadataResult?.source !==
307
+ AuthorityMetadataSource.CACHE) {
308
+ // Reset the expiration time unless both values came from a successful cache lookup
309
+ metadataEntity.expiresAt =
310
+ generateAuthorityMetadataExpiresAt();
311
+ metadataEntity.canonical_authority = this.canonicalAuthority;
312
+ }
313
+ const cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(metadataEntity.preferred_cache, this.correlationId);
314
+ this.cacheManager.setAuthorityMetadata(cacheKey, metadataEntity, this.correlationId);
315
+ this.metadata = metadataEntity;
316
+ }
317
+ /**
318
+ * Update AuthorityMetadataEntity with new endpoints and return where the information came from
319
+ * @param metadataEntity
320
+ */
321
+ async updateEndpointMetadata(metadataEntity) {
322
+ const localMetadata = this.updateEndpointMetadataFromLocalSources(metadataEntity);
323
+ // Further update may be required for hardcoded metadata if regional metadata is preferred
324
+ if (localMetadata) {
325
+ if (localMetadata.source ===
326
+ AuthorityMetadataSource.HARDCODED_VALUES) {
327
+ // If the user prefers to use an azure region replace the global endpoints with regional information.
328
+ if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
329
+ if (localMetadata.metadata) {
330
+ const hardcodedMetadata = await invokeAsync(this.updateMetadataWithRegionalInformation.bind(this), AuthorityUpdateMetadataWithRegionalInformation, this.logger, this.performanceClient, this.correlationId)(localMetadata.metadata);
331
+ updateAuthorityEndpointMetadata(metadataEntity, hardcodedMetadata, false);
332
+ metadataEntity.canonical_authority =
333
+ this.canonicalAuthority;
334
+ }
335
+ }
336
+ }
337
+ return localMetadata.source;
338
+ }
339
+ // Get metadata from network if local sources aren't available
340
+ let metadata = await invokeAsync(this.getEndpointMetadataFromNetwork.bind(this), AuthorityGetEndpointMetadataFromNetwork, this.logger, this.performanceClient, this.correlationId)();
341
+ if (metadata) {
342
+ // Validate the issuer returned by the OIDC discovery document.
343
+ this.validateIssuer(metadata.issuer);
344
+ // If the user prefers to use an azure region replace the global endpoints with regional information.
345
+ if (this.authorityOptions.azureRegionConfiguration?.azureRegion) {
346
+ metadata = await invokeAsync(this.updateMetadataWithRegionalInformation.bind(this), AuthorityUpdateMetadataWithRegionalInformation, this.logger, this.performanceClient, this.correlationId)(metadata);
347
+ }
348
+ updateAuthorityEndpointMetadata(metadataEntity, metadata, true);
349
+ return AuthorityMetadataSource.NETWORK;
350
+ }
351
+ else {
352
+ // Metadata could not be obtained from the config, cache, network or hardcoded values
353
+ throw createClientAuthError(openIdConfigError, this.defaultOpenIdConfigurationEndpoint, this.correlationId);
354
+ }
355
+ }
356
+ /**
357
+ * Updates endpoint metadata from local sources and returns where the information was retrieved from and the metadata config
358
+ * response if the source is hardcoded metadata
359
+ * @param metadataEntity
360
+ * @returns
361
+ */
362
+ updateEndpointMetadataFromLocalSources(metadataEntity) {
363
+ this.logger.verbose("1fi0kc", this.correlationId);
364
+ const configMetadata = this.getEndpointMetadataFromConfig();
365
+ if (configMetadata) {
366
+ this.logger.verbose("06t0uj", this.correlationId);
367
+ updateAuthorityEndpointMetadata(metadataEntity, configMetadata, false);
368
+ return {
369
+ source: AuthorityMetadataSource.CONFIG,
370
+ };
371
+ }
372
+ this.logger.verbose("151k0p", this.correlationId);
373
+ const hardcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
374
+ if (hardcodedMetadata) {
375
+ updateAuthorityEndpointMetadata(metadataEntity, hardcodedMetadata, false);
376
+ return {
377
+ source: AuthorityMetadataSource.HARDCODED_VALUES,
378
+ metadata: hardcodedMetadata,
379
+ };
380
+ }
381
+ else {
382
+ this.logger.verbose("1imop5", this.correlationId);
383
+ }
384
+ // Check cached metadata entity expiration status
385
+ const metadataEntityExpired = isAuthorityMetadataExpired(metadataEntity);
386
+ if (this.isAuthoritySameType(metadataEntity) &&
387
+ metadataEntity.endpointsFromNetwork &&
388
+ !metadataEntityExpired) {
389
+ // No need to update
390
+ this.logger.verbose("16uq31", "");
391
+ return { source: AuthorityMetadataSource.CACHE };
392
+ }
393
+ else if (metadataEntityExpired) {
394
+ this.logger.verbose("0uoibc", "");
395
+ }
396
+ return null;
397
+ }
398
+ /**
399
+ * Compares the number of url components after the domain to determine if the cached
400
+ * authority metadata can be used for the requested authority. Protects against same domain different
401
+ * authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
402
+ * @param metadataEntity
403
+ */
404
+ isAuthoritySameType(metadataEntity) {
405
+ const cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority, this.correlationId);
406
+ const cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
407
+ return (cachedParts.length ===
408
+ this.canonicalAuthorityUrlComponents.PathSegments.length);
409
+ }
410
+ /**
411
+ * Parse authorityMetadata config option
412
+ */
413
+ getEndpointMetadataFromConfig() {
414
+ if (this.authorityOptions.authorityMetadata) {
415
+ try {
416
+ return JSON.parse(this.authorityOptions.authorityMetadata);
417
+ }
418
+ catch (e) {
419
+ throw createClientConfigurationError(invalidAuthorityMetadata, this.correlationId);
420
+ }
421
+ }
422
+ return null;
423
+ }
424
+ /**
425
+ * Gets OAuth endpoints from the given OpenID configuration endpoint.
426
+ *
427
+ * @param hasHardcodedMetadata boolean
428
+ */
429
+ async getEndpointMetadataFromNetwork() {
430
+ const options = {};
431
+ /*
432
+ * TODO: Add a timeout if the authority exists in our library's
433
+ * hardcoded list of metadata
434
+ */
435
+ const openIdConfigurationEndpoint = this.defaultOpenIdConfigurationEndpoint;
436
+ this.logger.verbose(`1y65x6 ${openIdConfigurationEndpoint}`, this.correlationId);
437
+ try {
438
+ const response = await this.networkInterface.sendGetRequestAsync(openIdConfigurationEndpoint, options);
439
+ const isValidResponse = isOpenIdConfigResponse(response.body);
440
+ if (isValidResponse) {
441
+ return response.body;
442
+ }
443
+ else {
444
+ this.logger.verbose("1koyv8", this.correlationId);
445
+ return null;
446
+ }
447
+ }
448
+ catch (e) {
449
+ this.logger.verbose(`0a9wik ${e}`, this.correlationId);
450
+ return null;
451
+ }
452
+ }
453
+ /**
454
+ * Get OAuth endpoints for common authorities.
455
+ */
456
+ getEndpointMetadataFromHardcodedValues() {
457
+ if (this.hostnameAndPort in EndpointMetadata) {
458
+ return EndpointMetadata[this.hostnameAndPort];
459
+ }
460
+ return null;
461
+ }
462
+ /**
463
+ * Update the retrieved metadata with regional information.
464
+ * User selected Azure region will be used if configured.
465
+ */
466
+ async updateMetadataWithRegionalInformation(metadata) {
467
+ const userConfiguredAzureRegion = this.authorityOptions.azureRegionConfiguration?.azureRegion;
468
+ if (userConfiguredAzureRegion) {
469
+ if (userConfiguredAzureRegion !==
470
+ AZURE_REGION_AUTO_DISCOVER_FLAG) {
471
+ this.regionDiscoveryMetadata.region_outcome =
472
+ RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
473
+ this.regionDiscoveryMetadata.region_used =
474
+ userConfiguredAzureRegion;
475
+ return Authority.replaceWithRegionalInformation(metadata, userConfiguredAzureRegion, this.correlationId);
476
+ }
477
+ const autodetectedRegionName = await invokeAsync(this.regionDiscovery.detectRegion.bind(this.regionDiscovery), RegionDiscoveryDetectRegion, this.logger, this.performanceClient, this.correlationId)(this.authorityOptions.azureRegionConfiguration
478
+ ?.environmentRegion, this.regionDiscoveryMetadata);
479
+ if (autodetectedRegionName) {
480
+ this.regionDiscoveryMetadata.region_outcome =
481
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL;
482
+ this.regionDiscoveryMetadata.region_used =
483
+ autodetectedRegionName;
484
+ return Authority.replaceWithRegionalInformation(metadata, autodetectedRegionName, this.correlationId);
485
+ }
486
+ this.regionDiscoveryMetadata.region_outcome =
487
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
488
+ }
489
+ return metadata;
490
+ }
491
+ /**
492
+ * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
493
+ * and returns where the information was retrieved from
494
+ * @param metadataEntity
495
+ * @returns AuthorityMetadataSource
496
+ */
497
+ async updateCloudDiscoveryMetadata(metadataEntity) {
498
+ const localMetadataSource = this.updateCloudDiscoveryMetadataFromLocalSources(metadataEntity);
499
+ if (localMetadataSource) {
500
+ return localMetadataSource;
501
+ }
502
+ // Fallback to network as metadata source
503
+ const metadata = await invokeAsync(this.getCloudDiscoveryMetadataFromNetwork.bind(this), AuthorityGetCloudDiscoveryMetadataFromNetwork, this.logger, this.performanceClient, this.correlationId)();
504
+ if (metadata) {
505
+ updateCloudDiscoveryMetadata(metadataEntity, metadata, true);
506
+ return AuthorityMetadataSource.NETWORK;
507
+ }
508
+ // Metadata could not be obtained from the config, cache, network or hardcoded values
509
+ throw createClientConfigurationError(untrustedAuthority, this.correlationId);
510
+ }
511
+ updateCloudDiscoveryMetadataFromLocalSources(metadataEntity) {
512
+ this.logger.verbose("1tpqlr", this.correlationId);
513
+ this.logger.verbosePii(`1fy7uz ${this.authorityOptions.knownAuthorities ||
514
+ NOT_APPLICABLE}`, this.correlationId);
515
+ this.logger.verbosePii(`08zabj ${this.authorityOptions.authorityMetadata ||
516
+ NOT_APPLICABLE}`, this.correlationId);
517
+ this.logger.verbosePii(`1o1kv3 ${metadataEntity.canonical_authority || NOT_APPLICABLE}`, this.correlationId);
518
+ const metadata = this.getCloudDiscoveryMetadataFromConfig();
519
+ if (metadata) {
520
+ this.logger.verbose("1nakio", this.correlationId);
521
+ updateCloudDiscoveryMetadata(metadataEntity, metadata, false);
522
+ return AuthorityMetadataSource.CONFIG;
523
+ }
524
+ // If the cached metadata came from config but that config was not passed to this instance, we must go to hardcoded values
525
+ this.logger.verbose("1x74aj", this.correlationId);
526
+ const hardcodedMetadata = getCloudDiscoveryMetadataFromHardcodedValues(this.hostnameAndPort);
527
+ if (hardcodedMetadata) {
528
+ this.logger.verbose("0by47c", this.correlationId);
529
+ updateCloudDiscoveryMetadata(metadataEntity, hardcodedMetadata, false);
530
+ return AuthorityMetadataSource.HARDCODED_VALUES;
531
+ }
532
+ this.logger.verbose("0r2fzy", this.correlationId);
533
+ const metadataEntityExpired = isAuthorityMetadataExpired(metadataEntity);
534
+ if (this.isAuthoritySameType(metadataEntity) &&
535
+ metadataEntity.aliasesFromNetwork &&
536
+ !metadataEntityExpired) {
537
+ this.logger.verbose("1uffgh", "");
538
+ // No need to update
539
+ return AuthorityMetadataSource.CACHE;
540
+ }
541
+ else if (metadataEntityExpired) {
542
+ this.logger.verbose("0uoibc", "");
543
+ }
544
+ return null;
545
+ }
546
+ /**
547
+ * Parse cloudDiscoveryMetadata config or check knownAuthorities
548
+ */
549
+ getCloudDiscoveryMetadataFromConfig() {
550
+ // CIAM does not support cloud discovery metadata
551
+ if (this.authorityType === AuthorityType.Ciam) {
552
+ this.logger.verbose("04y84h", this.correlationId);
553
+ return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
554
+ }
555
+ // Check if network response was provided in config
556
+ if (this.authorityOptions.cloudDiscoveryMetadata) {
557
+ this.logger.verbose("0gszr3", this.correlationId);
558
+ try {
559
+ this.logger.verbose("1iifkx", this.correlationId);
560
+ const parsedResponse = JSON.parse(this.authorityOptions.cloudDiscoveryMetadata);
561
+ const metadata = getCloudDiscoveryMetadataFromNetworkResponse(parsedResponse.metadata, this.hostnameAndPort);
562
+ this.logger.verbose("0q67e3", "");
563
+ if (metadata) {
564
+ this.logger.verbose("0hzfao", this.correlationId);
565
+ return metadata;
566
+ }
567
+ else {
568
+ this.logger.verbose("1ajz3u", this.correlationId);
569
+ }
570
+ }
571
+ catch (e) {
572
+ this.logger.verbose("1wq5tu", this.correlationId);
573
+ throw createClientConfigurationError(invalidCloudDiscoveryMetadata, this.correlationId);
574
+ }
575
+ }
576
+ // If cloudDiscoveryMetadata is empty or does not contain the host, check knownAuthorities
577
+ if (this.isInKnownAuthorities(this.hostnameAndPort)) {
578
+ this.logger.verbose("0mt9al", this.correlationId);
579
+ return Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
580
+ }
581
+ return null;
582
+ }
583
+ /**
584
+ * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
585
+ *
586
+ * @param hasHardcodedMetadata boolean
587
+ */
588
+ async getCloudDiscoveryMetadataFromNetwork() {
589
+ const instanceDiscoveryEndpoint = `${AAD_INSTANCE_DISCOVERY_ENDPT}${this.canonicalAuthority}oauth2/v2.0/authorize`;
590
+ const options = {};
591
+ /*
592
+ * TODO: Add a timeout if the authority exists in our library's
593
+ * hardcoded list of metadata
594
+ */
595
+ let match = null;
596
+ try {
597
+ const response = await this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options);
598
+ let typedResponseBody;
599
+ let metadata;
600
+ if (isCloudInstanceDiscoveryResponse(response.body)) {
601
+ typedResponseBody =
602
+ response.body;
603
+ metadata = typedResponseBody.metadata;
604
+ this.logger.verbosePii(`1vglyt ${typedResponseBody.tenant_discovery_endpoint}`, this.correlationId);
605
+ }
606
+ else if (isCloudInstanceDiscoveryErrorResponse(response.body)) {
607
+ this.logger.warning(`062uto ${response.status}`, this.correlationId);
608
+ typedResponseBody =
609
+ response.body;
610
+ if (typedResponseBody.error === INVALID_INSTANCE) {
611
+ this.logger.error("1x90tm", this.correlationId);
612
+ return null;
613
+ }
614
+ this.logger.warning(`0wchdm ${typedResponseBody.error}`, this.correlationId);
615
+ this.logger.warning(`1s5mpv ${typedResponseBody.error_description}`, this.correlationId);
616
+ this.logger.warning("1yhqpw", this.correlationId);
617
+ metadata = [];
618
+ }
619
+ else {
620
+ this.logger.error("0768g0", this.correlationId);
621
+ return null;
622
+ }
623
+ this.logger.verbose("1lrobr", this.correlationId);
624
+ match = getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
625
+ }
626
+ catch (error) {
627
+ if (error instanceof AuthError) {
628
+ this.logger.error(`0vwhc7 ${error.errorCode} ${error.errorMessage}`, this.correlationId);
629
+ }
630
+ else {
631
+ const typedError = error;
632
+ this.logger.error(`0s2z41 ${typedError.name} ${typedError.message}`, this.correlationId);
633
+ }
634
+ return null;
635
+ }
636
+ // Custom Domain scenario, host is trusted because Instance Discovery call succeeded
637
+ if (!match) {
638
+ this.logger.warning("0jp28q", this.correlationId);
639
+ this.logger.verbose("130sd8", this.correlationId);
640
+ match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
641
+ }
642
+ return match;
643
+ }
644
+ /**
645
+ * Helper function to determine if a host is included in the knownAuthorities config option.
646
+ */
647
+ isInKnownAuthorities(host) {
648
+ const normalizedHost = host.toLowerCase();
649
+ const matches = this.authorityOptions.knownAuthorities.filter((authority) => {
650
+ return (authority &&
651
+ UrlString.getDomainFromUrl(authority, this.correlationId).toLowerCase() === normalizedHost);
652
+ });
653
+ return matches.length > 0;
654
+ }
655
+ /**
656
+ * helper function to populate the authority based on azureCloudOptions
657
+ * @param authorityString
658
+ * @param azureCloudOptions
659
+ */
660
+ static generateAuthority(authorityString, azureCloudOptions) {
661
+ let authorityAzureCloudInstance;
662
+ if (azureCloudOptions &&
663
+ azureCloudOptions.azureCloudInstance !== AzureCloudInstance.None) {
664
+ const tenant = azureCloudOptions.tenant
665
+ ? azureCloudOptions.tenant
666
+ : DEFAULT_COMMON_TENANT;
667
+ authorityAzureCloudInstance = `${azureCloudOptions.azureCloudInstance}/${tenant}/`;
668
+ }
669
+ return authorityAzureCloudInstance
670
+ ? authorityAzureCloudInstance
671
+ : authorityString;
672
+ }
673
+ /**
674
+ * Creates cloud discovery metadata object from a given host
675
+ * @param host
676
+ */
677
+ static createCloudDiscoveryMetadataFromHost(host) {
678
+ return {
679
+ preferred_network: host,
680
+ preferred_cache: host,
681
+ aliases: [host],
682
+ };
683
+ }
684
+ /**
685
+ * helper function to generate environment from authority object
686
+ */
687
+ getPreferredCache() {
688
+ if (this.managedIdentity) {
689
+ return DEFAULT_AUTHORITY_HOST;
690
+ }
691
+ else if (this.discoveryComplete()) {
692
+ return this.metadata.preferred_cache;
693
+ }
694
+ else {
695
+ throw createClientAuthError(endpointResolutionError, this.correlationId);
696
+ }
697
+ }
698
+ /**
699
+ * Returns whether or not the provided host is an alias of this authority instance
700
+ * @param host
701
+ */
702
+ isAlias(host) {
703
+ return this.metadata.aliases.indexOf(host) > -1;
704
+ }
705
+ /**
706
+ * Returns whether or not the provided host is an alias of a known Microsoft authority for purposes of endpoint discovery
707
+ * @param host
708
+ */
709
+ isAliasOfKnownMicrosoftAuthority(host) {
710
+ return InstanceDiscoveryMetadataAliases.has(host);
711
+ }
712
+ /**
713
+ * Validates the `issuer` returned by an OIDC discovery document against
714
+ * this authority, per
715
+ * https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationValidation
716
+ *
717
+ * The issuer is accepted when ANY of the following holds:
718
+ * 1. The issuer scheme + host + port match the authority's (path may
719
+ * differ). Applies to all authorities.
720
+ * 2. The authority is a Microsoft cloud authority (public, sovereign,
721
+ * or CIAM), the issuer is HTTPS, and the issuer host is in the known
722
+ * Microsoft authority host set.
723
+ * 3. Same as (2), but the issuer host is a single-label regional variant
724
+ * of a known Microsoft host (e.g. `westus.login.microsoftonline.com`).
725
+ * 4. Same as (2), but the issuer host matches the CIAM tenant pattern
726
+ * `{tenant}.ciamlogin.com` with an optional `/{tenant}[.onmicrosoft.com][/v2.0]`
727
+ * path.
728
+ * 5. The issuer host is HTTPS and is explicitly listed in the
729
+ * developer-configured `knownAuthorities`. This covers scenarios where
730
+ * the OIDC discovery document returns an issuer host that differs from
731
+ * the authority (e.g., a GUID-based issuer for a name-based CIAM authority).
732
+ *
733
+ * @param issuer The `issuer` value returned in the OIDC discovery document.
734
+ * @throws ClientConfigurationError("issuer_validation_failed") on failure.
735
+ */
736
+ validateIssuer(issuer) {
737
+ if (!issuer) {
738
+ throw createClientConfigurationError(issuerValidationFailed, this.correlationId);
739
+ }
740
+ // Parse with the WHATWG URL API. URL normalizes scheme + host to lowercase per RFC 3986.
741
+ let issuerUrl;
742
+ try {
743
+ issuerUrl = new URL(issuer);
744
+ }
745
+ catch {
746
+ throw createClientConfigurationError(issuerValidationFailed, this.correlationId);
747
+ }
748
+ const issuerScheme = issuerUrl.protocol;
749
+ const issuerHost = issuerUrl.host;
750
+ const authorityScheme = (this.canonicalAuthorityUrlComponents.Protocol || "").toLowerCase();
751
+ const authorityHost = (this.canonicalAuthorityUrlComponents.HostNameAndPort || "").toLowerCase();
752
+ // Rule 1: Same scheme and host
753
+ const matchesAuthorityOrigin = this.matchesAuthorityOrigin(issuerScheme, issuerHost, authorityScheme, authorityHost);
754
+ // Rule 2: The issuer host is a well-known Microsoft authority host (HTTPS only)
755
+ const matchesKnownMicrosoftHost = issuerScheme === "https:" &&
756
+ this.isAliasOfKnownMicrosoftAuthority(issuerHost);
757
+ /*
758
+ * Rule 3: The issuer host is a regional variant ({region}.{host}) of a well-known host
759
+ * (HTTPS only). E.g. westus2.login.microsoft.com
760
+ */
761
+ const matchesRegionalMicrosoftHost = issuerScheme === "https:" &&
762
+ this.matchesRegionalMicrosoftHost(issuerHost);
763
+ /*
764
+ * Rule 4: CIAM-specific validation. In a CIAM scenario the issuer is expected to
765
+ * have "{tenant}.ciamlogin.com" as the host, even when using a custom domain.
766
+ */
767
+ const matchesCiamTenantPattern = this.matchesCiamTenantPattern(issuerUrl, authorityHost, this.canonicalAuthorityUrlComponents.PathSegments);
768
+ /*
769
+ * Rule 5: The issuer host is explicitly listed in the developer-configured
770
+ * knownAuthorities. This covers scenarios where the OIDC discovery document
771
+ * returns an issuer with a different host than the authority
772
+ * (e.g., a GUID-based issuer for a name-based authority).
773
+ */
774
+ const matchesKnownAuthority = issuerScheme === "https:" && this.isInKnownAuthorities(issuerHost);
775
+ // Each rule is an independent boolean; the issuer is valid if ANY rule matches.
776
+ if (matchesAuthorityOrigin ||
777
+ matchesKnownMicrosoftHost ||
778
+ matchesRegionalMicrosoftHost ||
779
+ matchesCiamTenantPattern ||
780
+ matchesKnownAuthority) {
781
+ return;
782
+ }
783
+ // issuer validation fails if none of the above rules are satisfied
784
+ throw createClientConfigurationError(issuerValidationFailed, this.correlationId);
785
+ }
786
+ /**
787
+ * Rule 1: The issuer scheme + host (and port) match the authority's. Path
788
+ * may differ. Applies to all authorities.
789
+ */
790
+ matchesAuthorityOrigin(issuerScheme, issuerHost, authorityScheme, authorityHost) {
791
+ return issuerScheme === authorityScheme && issuerHost === authorityHost;
792
+ }
793
+ /**
794
+ * Rule 3: The issuer host is a regional variant
795
+ * (`{region}.{host}`) of a known Microsoft authority host.
796
+ * E.g. `westus2.login.microsoft.com`.
797
+ */
798
+ matchesRegionalMicrosoftHost(issuerHost) {
799
+ const firstDot = issuerHost.indexOf(".");
800
+ if (firstDot > 0 && firstDot < issuerHost.length - 1) {
801
+ const hostWithoutRegion = issuerHost.substring(firstDot + 1);
802
+ return this.isAliasOfKnownMicrosoftAuthority(hostWithoutRegion);
803
+ }
804
+ return false;
805
+ }
806
+ /**
807
+ * Rule 4: The issuer matches one of the well-known CIAM tenant patterns
808
+ * (`https://{tenant}.ciamlogin.com[/{tenant}[.onmicrosoft.com][/v2.0]]`).
809
+ *
810
+ * The bare tenant name is extracted from the authority's first path segment
811
+ * when available (stripping the `.onmicrosoft.com` suffix that
812
+ * `transformCIAMAuthority` adds), or otherwise from the leftmost label of
813
+ * the authority host (to support CIAM custom domain scenarios).
814
+ *
815
+ * Both `/{tenant}` and `/{tenant}.onmicrosoft.com` path forms are accepted
816
+ * because the OIDC issuer may use either form depending on the authority URL
817
+ * that was used to trigger discovery.
818
+ */
819
+ matchesCiamTenantPattern(issuerUrl, authorityHost, authorityPathSegments) {
820
+ /*
821
+ * authorityPathSegments[0] is the first path segment of the *authority
822
+ * URL* after transformCIAMAuthority runs (e.g. "contoso.onmicrosoft.com").
823
+ * Additional CIAM issuer path segments such as "/v2.0" are part of the
824
+ * issuer string, not the authority URL's PathSegments.
825
+ */
826
+ const pathSegment = authorityPathSegments[0];
827
+ /*
828
+ * Extract the bare tenant name: strip the .onmicrosoft.com suffix when
829
+ * present (introduced by transformCIAMAuthority), or fall back to the
830
+ * first label of the authority hostname for non-transformed/custom-domain
831
+ * CIAM authorities.
832
+ */
833
+ const tenantName = pathSegment
834
+ ? pathSegment.endsWith(AAD_TENANT_DOMAIN_SUFFIX)
835
+ ? pathSegment.slice(0, -AAD_TENANT_DOMAIN_SUFFIX.length)
836
+ : pathSegment
837
+ : authorityHost.split(".")[0];
838
+ if (!tenantName) {
839
+ return false;
840
+ }
841
+ const ciamBaseURL = `https://${tenantName}${CIAM_AUTH_URL}`;
842
+ const validCiamPatterns = [
843
+ ciamBaseURL,
844
+ `${ciamBaseURL}/${tenantName}`,
845
+ `${ciamBaseURL}/${tenantName}/v2.0`,
846
+ `${ciamBaseURL}/${tenantName}${AAD_TENANT_DOMAIN_SUFFIX}`,
847
+ `${ciamBaseURL}/${tenantName}${AAD_TENANT_DOMAIN_SUFFIX}/v2.0`, // https://{tenant}.ciamlogin.com/{tenant}.onmicrosoft.com/v2.0
848
+ ];
849
+ /*
850
+ * Compose the canonical issuer string from URL components and strip any
851
+ * trailing slashes from the path so it can be compared to the pattern set.
852
+ */
853
+ const issuerPath = issuerUrl.pathname.replace(/\/+$/, "");
854
+ const normalizedIssuer = `${issuerUrl.protocol}//${issuerUrl.host}${issuerPath}`;
855
+ return validCiamPatterns.some((pattern) => pattern === normalizedIssuer);
856
+ }
857
+ /**
858
+ * Checks whether the provided host is that of a public cloud authority
859
+ *
860
+ * @param authority string
861
+ * @returns bool
862
+ */
863
+ static isPublicCloudAuthority(host) {
864
+ return KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;
865
+ }
866
+ /**
867
+ * Rebuild the authority string with the region
868
+ *
869
+ * @param host string
870
+ * @param region string
871
+ */
872
+ static buildRegionalAuthorityString(host, region, correlationId, queryString) {
873
+ // Create and validate a Url string object with the initial authority string
874
+ const authorityUrlInstance = new UrlString(host, correlationId);
875
+ authorityUrlInstance.validateAsUri();
876
+ const authorityUrlParts = authorityUrlInstance.getUrlComponents();
877
+ let hostNameAndPort = `${region}.${authorityUrlParts.HostNameAndPort}`;
878
+ if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {
879
+ hostNameAndPort = `${region}.${REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX}`;
880
+ }
881
+ // Include the query string portion of the url
882
+ const url = UrlString.constructAuthorityUriFromObject({
883
+ ...authorityUrlInstance.getUrlComponents(),
884
+ HostNameAndPort: hostNameAndPort,
885
+ }, correlationId).urlString;
886
+ // Add the query string if a query string was provided
887
+ if (queryString)
888
+ return `${url}?${queryString}`;
889
+ return url;
890
+ }
891
+ /**
892
+ * Replace the endpoints in the metadata object with their regional equivalents.
893
+ *
894
+ * @param metadata OpenIdConfigResponse
895
+ * @param azureRegion string
896
+ */
897
+ static replaceWithRegionalInformation(metadata, azureRegion, correlationId) {
898
+ const regionalMetadata = { ...metadata };
899
+ regionalMetadata.authorization_endpoint =
900
+ Authority.buildRegionalAuthorityString(regionalMetadata.authorization_endpoint, azureRegion, correlationId);
901
+ regionalMetadata.token_endpoint =
902
+ Authority.buildRegionalAuthorityString(regionalMetadata.token_endpoint, azureRegion, correlationId);
903
+ if (regionalMetadata.end_session_endpoint) {
904
+ regionalMetadata.end_session_endpoint =
905
+ Authority.buildRegionalAuthorityString(regionalMetadata.end_session_endpoint, azureRegion, correlationId);
906
+ }
907
+ return regionalMetadata;
908
+ }
909
+ /**
910
+ * Transform CIAM_AUTHORIY as per the below rules:
911
+ * If no path segments found and it is a CIAM authority (hostname ends with .ciamlogin.com), then transform it
912
+ *
913
+ * NOTE: The transformation path should go away once STS supports CIAM with the format: `tenantIdorDomain.ciamlogin.com`
914
+ * `ciamlogin.com` can also change in the future and we should accommodate the same
915
+ *
916
+ * @param authority
917
+ */
918
+ static transformCIAMAuthority(authority, correlationId) {
919
+ let ciamAuthority = authority;
920
+ const authorityUrl = new UrlString(authority, correlationId);
921
+ const authorityUrlComponents = authorityUrl.getUrlComponents();
922
+ // check if transformation is needed
923
+ if (authorityUrlComponents.PathSegments.length === 0 &&
924
+ authorityUrlComponents.HostNameAndPort.endsWith(CIAM_AUTH_URL)) {
925
+ const tenantIdOrDomain = authorityUrlComponents.HostNameAndPort.split(".")[0];
926
+ ciamAuthority = `${ciamAuthority}${tenantIdOrDomain}${AAD_TENANT_DOMAIN_SUFFIX}`;
927
+ }
928
+ return ciamAuthority;
929
+ }
930
+ }
931
+ // Reserved tenant domain names that will not be replaced with tenant id
932
+ Authority.reservedTenantDomains = new Set([
933
+ "{tenant}",
934
+ "{tenantid}",
935
+ AADAuthority.COMMON,
936
+ AADAuthority.CONSUMERS,
937
+ AADAuthority.ORGANIZATIONS,
938
+ ]);
939
+ /**
940
+ * Extract tenantId from authority
941
+ */
942
+ function getTenantFromAuthorityString(authority, correlationId) {
943
+ const authorityUrl = new UrlString(authority, correlationId);
944
+ const authorityUrlComponents = authorityUrl.getUrlComponents();
945
+ /**
946
+ * For credential matching purposes, tenantId is the last path segment of the authority URL:
947
+ * AAD Authority - domain/tenantId -> Credentials are cached with realm = tenantId
948
+ * B2C Authority - domain/{tenantId}?/.../policy -> Credentials are cached with realm = policy
949
+ * tenantId is downcased because B2C policies can have mixed case but tfp claim is downcased
950
+ *
951
+ * Note that we may not have any path segments in certain OIDC scenarios.
952
+ */
953
+ const tenantId = authorityUrlComponents.PathSegments.slice(-1)[0]?.toLowerCase();
954
+ switch (tenantId) {
955
+ case AADAuthority.COMMON:
956
+ case AADAuthority.ORGANIZATIONS:
957
+ case AADAuthority.CONSUMERS:
958
+ return undefined;
959
+ default:
960
+ return tenantId;
961
+ }
962
+ }
963
+ function formatAuthorityUri(authorityUri) {
964
+ return authorityUri.endsWith(FORWARD_SLASH)
965
+ ? authorityUri
966
+ : `${authorityUri}${FORWARD_SLASH}`;
967
+ }
968
+ function buildStaticAuthorityOptions(authOptions) {
969
+ const rawCloudDiscoveryMetadata = authOptions.cloudDiscoveryMetadata;
970
+ let cloudDiscoveryMetadata = undefined;
971
+ if (rawCloudDiscoveryMetadata) {
972
+ try {
973
+ cloudDiscoveryMetadata = JSON.parse(rawCloudDiscoveryMetadata);
974
+ }
975
+ catch (e) {
976
+ throw createClientConfigurationError(invalidCloudDiscoveryMetadata, "");
977
+ }
978
+ }
979
+ return {
980
+ canonicalAuthority: authOptions.authority
981
+ ? formatAuthorityUri(authOptions.authority)
982
+ : undefined,
983
+ knownAuthorities: authOptions.knownAuthorities,
984
+ cloudDiscoveryMetadata: cloudDiscoveryMetadata,
985
+ };
986
+ }
987
+
988
+ export { Authority, buildStaticAuthorityOptions, formatAuthorityUri, getTenantFromAuthorityString };