@azure/msal-common 16.0.0-alpha.0 → 16.0.0-beta.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 (320) hide show
  1. package/dist/account/AccountInfo.d.ts +3 -0
  2. package/dist/account/AccountInfo.d.ts.map +1 -1
  3. package/dist/account/AccountInfo.mjs +1 -1
  4. package/dist/account/AccountInfo.mjs.map +1 -1
  5. package/dist/account/AuthToken.d.ts +6 -0
  6. package/dist/account/AuthToken.d.ts.map +1 -1
  7. package/dist/account/AuthToken.mjs +21 -2
  8. package/dist/account/AuthToken.mjs.map +1 -1
  9. package/dist/account/CcsCredential.mjs +1 -1
  10. package/dist/account/CcsCredential.mjs.map +1 -1
  11. package/dist/account/ClientInfo.d.ts +5 -1
  12. package/dist/account/ClientInfo.d.ts.map +1 -1
  13. package/dist/account/ClientInfo.mjs +1 -1
  14. package/dist/account/ClientInfo.mjs.map +1 -1
  15. package/dist/account/TokenClaims.d.ts +4 -0
  16. package/dist/account/TokenClaims.d.ts.map +1 -1
  17. package/dist/account/TokenClaims.mjs +1 -1
  18. package/dist/account/TokenClaims.mjs.map +1 -1
  19. package/dist/authority/Authority.mjs +1 -1
  20. package/dist/authority/Authority.mjs.map +1 -1
  21. package/dist/authority/AuthorityFactory.mjs +1 -1
  22. package/dist/authority/AuthorityFactory.mjs.map +1 -1
  23. package/dist/authority/AuthorityMetadata.d.ts.map +1 -1
  24. package/dist/authority/AuthorityMetadata.mjs +27 -24
  25. package/dist/authority/AuthorityMetadata.mjs.map +1 -1
  26. package/dist/authority/AuthorityOptions.mjs +1 -1
  27. package/dist/authority/AuthorityOptions.mjs.map +1 -1
  28. package/dist/authority/AuthorityType.mjs +1 -1
  29. package/dist/authority/AuthorityType.mjs.map +1 -1
  30. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  31. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  32. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  33. package/dist/authority/ProtocolMode.mjs +1 -1
  34. package/dist/authority/ProtocolMode.mjs.map +1 -1
  35. package/dist/authority/RegionDiscovery.mjs +1 -1
  36. package/dist/authority/RegionDiscovery.mjs.map +1 -1
  37. package/dist/cache/CacheManager.d.ts +5 -5
  38. package/dist/cache/CacheManager.d.ts.map +1 -1
  39. package/dist/cache/CacheManager.mjs +8 -8
  40. package/dist/cache/CacheManager.mjs.map +1 -1
  41. package/dist/cache/entities/AccountEntity.d.ts +2 -1
  42. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  43. package/dist/cache/interface/ICacheManager.d.ts +5 -5
  44. package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
  45. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  46. package/dist/cache/persistence/TokenCacheContext.mjs.map +1 -1
  47. package/dist/cache/utils/AccountEntityUtils.d.ts +0 -7
  48. package/dist/cache/utils/AccountEntityUtils.d.ts.map +1 -1
  49. package/dist/cache/utils/AccountEntityUtils.mjs +9 -29
  50. package/dist/cache/utils/AccountEntityUtils.mjs.map +1 -1
  51. package/dist/cache/utils/CacheHelpers.mjs +1 -1
  52. package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
  53. package/dist/client/AuthorizationCodeClient.d.ts +22 -3
  54. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  55. package/dist/client/AuthorizationCodeClient.mjs +51 -19
  56. package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
  57. package/dist/client/RefreshTokenClient.d.ts +16 -3
  58. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  59. package/dist/client/RefreshTokenClient.mjs +31 -12
  60. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  61. package/dist/client/SilentFlowClient.d.ts +16 -3
  62. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  63. package/dist/client/SilentFlowClient.mjs +21 -4
  64. package/dist/client/SilentFlowClient.mjs.map +1 -1
  65. package/dist/config/ClientConfiguration.mjs +1 -1
  66. package/dist/config/ClientConfiguration.mjs.map +1 -1
  67. package/dist/constants/AADServerParamKeys.mjs +1 -1
  68. package/dist/crypto/ICrypto.mjs +1 -1
  69. package/dist/crypto/ICrypto.mjs.map +1 -1
  70. package/dist/crypto/JoseHeader.mjs +1 -1
  71. package/dist/crypto/JoseHeader.mjs.map +1 -1
  72. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  73. package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
  74. package/dist/error/AuthError.d.ts +5 -0
  75. package/dist/error/AuthError.d.ts.map +1 -1
  76. package/dist/error/AuthError.mjs +1 -1
  77. package/dist/error/AuthError.mjs.map +1 -1
  78. package/dist/error/AuthErrorCodes.mjs +1 -1
  79. package/dist/error/CacheError.mjs +1 -1
  80. package/dist/error/CacheError.mjs.map +1 -1
  81. package/dist/error/CacheErrorCodes.mjs +1 -1
  82. package/dist/error/ClientAuthError.mjs +1 -1
  83. package/dist/error/ClientAuthError.mjs.map +1 -1
  84. package/dist/error/ClientAuthErrorCodes.d.ts +1 -0
  85. package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -1
  86. package/dist/error/ClientAuthErrorCodes.mjs +4 -3
  87. package/dist/error/ClientAuthErrorCodes.mjs.map +1 -1
  88. package/dist/error/ClientConfigurationError.mjs +1 -1
  89. package/dist/error/ClientConfigurationError.mjs.map +1 -1
  90. package/dist/error/ClientConfigurationErrorCodes.d.ts +1 -0
  91. package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
  92. package/dist/error/ClientConfigurationErrorCodes.mjs +4 -3
  93. package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -1
  94. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  95. package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
  96. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
  97. package/dist/error/JoseHeaderError.mjs +1 -1
  98. package/dist/error/JoseHeaderError.mjs.map +1 -1
  99. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  100. package/dist/error/NetworkError.mjs +1 -1
  101. package/dist/error/NetworkError.mjs.map +1 -1
  102. package/dist/error/PlatformBrokerError.d.ts +16 -0
  103. package/dist/error/PlatformBrokerError.d.ts.map +1 -0
  104. package/dist/error/PlatformBrokerError.mjs +49 -0
  105. package/dist/error/PlatformBrokerError.mjs.map +1 -0
  106. package/dist/error/ServerError.mjs +1 -1
  107. package/dist/error/ServerError.mjs.map +1 -1
  108. package/dist/exports-common.d.ts +4 -2
  109. package/dist/exports-common.d.ts.map +1 -1
  110. package/dist/exports-node-only.d.ts +1 -0
  111. package/dist/exports-node-only.d.ts.map +1 -1
  112. package/dist/index-node.mjs +7 -4
  113. package/dist/index-node.mjs.map +1 -1
  114. package/dist/index.mjs +7 -4
  115. package/dist/index.mjs.map +1 -1
  116. package/dist/logger/Logger.d.ts +24 -0
  117. package/dist/logger/Logger.d.ts.map +1 -1
  118. package/dist/logger/Logger.mjs +92 -4
  119. package/dist/logger/Logger.mjs.map +1 -1
  120. package/dist/network/INetworkModule.mjs +1 -1
  121. package/dist/network/INetworkModule.mjs.map +1 -1
  122. package/dist/network/RequestThumbprint.mjs +2 -2
  123. package/dist/network/RequestThumbprint.mjs.map +1 -1
  124. package/dist/network/ThrottlingUtils.mjs +1 -1
  125. package/dist/network/ThrottlingUtils.mjs.map +1 -1
  126. package/dist/packageMetadata.d.ts +1 -1
  127. package/dist/packageMetadata.d.ts.map +1 -1
  128. package/dist/packageMetadata.mjs +2 -2
  129. package/dist/protocol/Authorize.mjs +1 -1
  130. package/dist/protocol/Authorize.mjs.map +1 -1
  131. package/dist/protocol/Token.d.ts +40 -0
  132. package/dist/protocol/Token.d.ts.map +1 -0
  133. package/dist/protocol/Token.mjs +129 -0
  134. package/dist/protocol/Token.mjs.map +1 -0
  135. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  136. package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
  137. package/dist/request/BaseAuthRequest.d.ts +7 -5
  138. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  139. package/dist/request/CommonAuthorizationCodeRequest.d.ts +2 -1
  140. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  141. package/dist/request/CommonAuthorizationUrlRequest.d.ts +2 -4
  142. package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
  143. package/dist/request/CommonRefreshTokenRequest.d.ts +2 -1
  144. package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
  145. package/dist/request/CommonSilentFlowRequest.d.ts +2 -1
  146. package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
  147. package/dist/request/RequestParameterBuilder.d.ts +3 -3
  148. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  149. package/dist/request/RequestParameterBuilder.mjs +6 -6
  150. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  151. package/dist/request/ScopeSet.mjs +1 -1
  152. package/dist/request/ScopeSet.mjs.map +1 -1
  153. package/dist/response/ResponseHandler.d.ts +1 -1
  154. package/dist/response/ResponseHandler.d.ts.map +1 -1
  155. package/dist/response/ResponseHandler.mjs +5 -5
  156. package/dist/response/ResponseHandler.mjs.map +1 -1
  157. package/dist/telemetry/performance/IPerformanceClient.d.ts +2 -1
  158. package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
  159. package/dist/telemetry/performance/PerformanceClient.d.ts +4 -1
  160. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  161. package/dist/telemetry/performance/PerformanceClient.mjs +30 -16
  162. package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
  163. package/dist/telemetry/performance/PerformanceEvent.d.ts +3 -0
  164. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  165. package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
  166. package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
  167. package/dist/telemetry/performance/PerformanceEvents.d.ts +1 -0
  168. package/dist/telemetry/performance/PerformanceEvents.d.ts.map +1 -1
  169. package/dist/telemetry/performance/PerformanceEvents.mjs +3 -2
  170. package/dist/telemetry/performance/PerformanceEvents.mjs.map +1 -1
  171. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  172. package/dist/telemetry/performance/StubPerformanceClient.mjs.map +1 -1
  173. package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
  174. package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
  175. package/dist/url/UrlString.mjs +1 -1
  176. package/dist/url/UrlString.mjs.map +1 -1
  177. package/dist/utils/ClientAssertionUtils.mjs +1 -1
  178. package/dist/utils/ClientAssertionUtils.mjs.map +1 -1
  179. package/dist/utils/Constants.d.ts +5 -0
  180. package/dist/utils/Constants.d.ts.map +1 -1
  181. package/dist/utils/Constants.mjs +6 -2
  182. package/dist/utils/Constants.mjs.map +1 -1
  183. package/dist/utils/FunctionWrappers.mjs +1 -1
  184. package/dist/utils/FunctionWrappers.mjs.map +1 -1
  185. package/dist/utils/ProtocolUtils.d.ts +14 -35
  186. package/dist/utils/ProtocolUtils.d.ts.map +1 -1
  187. package/dist/utils/ProtocolUtils.mjs +56 -60
  188. package/dist/utils/ProtocolUtils.mjs.map +1 -1
  189. package/dist/utils/StateTypes.d.ts +15 -0
  190. package/dist/utils/StateTypes.d.ts.map +1 -0
  191. package/dist/utils/StringUtils.mjs +1 -1
  192. package/dist/utils/StringUtils.mjs.map +1 -1
  193. package/dist/utils/TimeUtils.mjs +1 -1
  194. package/dist/utils/TimeUtils.mjs.map +1 -1
  195. package/dist/utils/UrlUtils.mjs +1 -1
  196. package/dist/utils/UrlUtils.mjs.map +1 -1
  197. package/lib/index-browser.cjs +31 -17
  198. package/lib/index-browser.cjs.map +1 -1
  199. package/lib/{index-node-FrCFfFuh.js → index-node-B7mR4APO.js} +2427 -2237
  200. package/lib/index-node-B7mR4APO.js.map +1 -0
  201. package/lib/index-node.cjs +5 -3
  202. package/lib/index-node.cjs.map +1 -1
  203. package/lib/index.cjs +5 -3
  204. package/lib/index.cjs.map +1 -1
  205. package/lib/types/account/AccountInfo.d.ts +3 -0
  206. package/lib/types/account/AccountInfo.d.ts.map +1 -1
  207. package/lib/types/account/AuthToken.d.ts +6 -0
  208. package/lib/types/account/AuthToken.d.ts.map +1 -1
  209. package/lib/types/account/ClientInfo.d.ts +5 -1
  210. package/lib/types/account/ClientInfo.d.ts.map +1 -1
  211. package/lib/types/account/TokenClaims.d.ts +4 -0
  212. package/lib/types/account/TokenClaims.d.ts.map +1 -1
  213. package/lib/types/authority/AuthorityMetadata.d.ts.map +1 -1
  214. package/lib/types/cache/CacheManager.d.ts +5 -5
  215. package/lib/types/cache/CacheManager.d.ts.map +1 -1
  216. package/lib/types/cache/entities/AccountEntity.d.ts +2 -1
  217. package/lib/types/cache/entities/AccountEntity.d.ts.map +1 -1
  218. package/lib/types/cache/interface/ICacheManager.d.ts +5 -5
  219. package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
  220. package/lib/types/cache/utils/AccountEntityUtils.d.ts +0 -7
  221. package/lib/types/cache/utils/AccountEntityUtils.d.ts.map +1 -1
  222. package/lib/types/client/AuthorizationCodeClient.d.ts +22 -3
  223. package/lib/types/client/AuthorizationCodeClient.d.ts.map +1 -1
  224. package/lib/types/client/RefreshTokenClient.d.ts +16 -3
  225. package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
  226. package/lib/types/client/SilentFlowClient.d.ts +16 -3
  227. package/lib/types/client/SilentFlowClient.d.ts.map +1 -1
  228. package/lib/types/error/AuthError.d.ts +5 -0
  229. package/lib/types/error/AuthError.d.ts.map +1 -1
  230. package/lib/types/error/ClientAuthErrorCodes.d.ts +1 -0
  231. package/lib/types/error/ClientAuthErrorCodes.d.ts.map +1 -1
  232. package/lib/types/error/ClientConfigurationErrorCodes.d.ts +1 -0
  233. package/lib/types/error/ClientConfigurationErrorCodes.d.ts.map +1 -1
  234. package/lib/types/error/PlatformBrokerError.d.ts +16 -0
  235. package/lib/types/error/PlatformBrokerError.d.ts.map +1 -0
  236. package/lib/types/exports-common.d.ts +4 -2
  237. package/lib/types/exports-common.d.ts.map +1 -1
  238. package/lib/types/exports-node-only.d.ts +1 -0
  239. package/lib/types/exports-node-only.d.ts.map +1 -1
  240. package/lib/types/logger/Logger.d.ts +24 -0
  241. package/lib/types/logger/Logger.d.ts.map +1 -1
  242. package/lib/types/packageMetadata.d.ts +1 -1
  243. package/lib/types/packageMetadata.d.ts.map +1 -1
  244. package/lib/types/protocol/Token.d.ts +40 -0
  245. package/lib/types/protocol/Token.d.ts.map +1 -0
  246. package/lib/types/request/BaseAuthRequest.d.ts +7 -5
  247. package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
  248. package/lib/types/request/CommonAuthorizationCodeRequest.d.ts +2 -1
  249. package/lib/types/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  250. package/lib/types/request/CommonAuthorizationUrlRequest.d.ts +2 -4
  251. package/lib/types/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
  252. package/lib/types/request/CommonRefreshTokenRequest.d.ts +2 -1
  253. package/lib/types/request/CommonRefreshTokenRequest.d.ts.map +1 -1
  254. package/lib/types/request/CommonSilentFlowRequest.d.ts +2 -1
  255. package/lib/types/request/CommonSilentFlowRequest.d.ts.map +1 -1
  256. package/lib/types/request/RequestParameterBuilder.d.ts +3 -3
  257. package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -1
  258. package/lib/types/response/ResponseHandler.d.ts +1 -1
  259. package/lib/types/response/ResponseHandler.d.ts.map +1 -1
  260. package/lib/types/telemetry/performance/IPerformanceClient.d.ts +2 -1
  261. package/lib/types/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
  262. package/lib/types/telemetry/performance/PerformanceClient.d.ts +4 -1
  263. package/lib/types/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  264. package/lib/types/telemetry/performance/PerformanceEvent.d.ts +3 -0
  265. package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  266. package/lib/types/telemetry/performance/PerformanceEvents.d.ts +1 -0
  267. package/lib/types/telemetry/performance/PerformanceEvents.d.ts.map +1 -1
  268. package/lib/types/utils/Constants.d.ts +5 -0
  269. package/lib/types/utils/Constants.d.ts.map +1 -1
  270. package/lib/types/utils/ProtocolUtils.d.ts +14 -35
  271. package/lib/types/utils/ProtocolUtils.d.ts.map +1 -1
  272. package/lib/types/utils/StateTypes.d.ts +15 -0
  273. package/lib/types/utils/StateTypes.d.ts.map +1 -0
  274. package/package.json +122 -120
  275. package/src/account/AccountInfo.ts +5 -0
  276. package/src/account/AuthToken.ts +22 -0
  277. package/src/account/ClientInfo.ts +5 -1
  278. package/src/account/TokenClaims.ts +4 -0
  279. package/src/authority/AuthorityMetadata.ts +33 -35
  280. package/src/cache/CacheManager.ts +19 -10
  281. package/src/cache/entities/AccountEntity.ts +2 -1
  282. package/src/cache/interface/ICacheManager.ts +12 -4
  283. package/src/cache/utils/AccountEntityUtils.ts +8 -37
  284. package/src/client/AuthorizationCodeClient.ts +128 -19
  285. package/src/client/RefreshTokenClient.ts +88 -13
  286. package/src/client/SilentFlowClient.ts +63 -5
  287. package/src/error/AuthError.ts +6 -0
  288. package/src/error/ClientAuthErrorCodes.ts +1 -0
  289. package/src/error/ClientConfigurationErrorCodes.ts +1 -0
  290. package/src/error/PlatformBrokerError.ts +67 -0
  291. package/src/exports-common.ts +5 -6
  292. package/src/exports-node-only.ts +4 -0
  293. package/src/logger/Logger.ts +150 -2
  294. package/src/network/RequestThumbprint.ts +1 -1
  295. package/src/packageMetadata.ts +1 -1
  296. package/src/protocol/Token.ts +230 -0
  297. package/src/request/BaseAuthRequest.ts +7 -5
  298. package/src/request/CommonAuthorizationCodeRequest.ts +2 -1
  299. package/src/request/CommonAuthorizationUrlRequest.ts +2 -4
  300. package/src/request/CommonRefreshTokenRequest.ts +2 -1
  301. package/src/request/CommonSilentFlowRequest.ts +2 -1
  302. package/src/request/RequestParameterBuilder.ts +5 -5
  303. package/src/response/ResponseHandler.ts +9 -3
  304. package/src/telemetry/performance/IPerformanceClient.ts +3 -1
  305. package/src/telemetry/performance/PerformanceClient.ts +39 -45
  306. package/src/telemetry/performance/PerformanceEvent.ts +7 -0
  307. package/src/telemetry/performance/PerformanceEvents.ts +1 -0
  308. package/src/utils/Constants.ts +6 -0
  309. package/src/utils/ProtocolUtils.ts +66 -92
  310. package/src/utils/StateTypes.ts +20 -0
  311. package/dist/client/BaseClient.d.ts +0 -59
  312. package/dist/client/BaseClient.d.ts.map +0 -1
  313. package/dist/client/BaseClient.mjs +0 -162
  314. package/dist/client/BaseClient.mjs.map +0 -1
  315. package/dist/index-browser.mjs +0 -75
  316. package/dist/index-browser.mjs.map +0 -1
  317. package/lib/index-node-FrCFfFuh.js.map +0 -1
  318. package/lib/types/client/BaseClient.d.ts +0 -59
  319. package/lib/types/client/BaseClient.d.ts.map +0 -1
  320. package/src/client/BaseClient.ts +0 -308
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ApplicationTelemetry } from "../../config/ClientConfiguration.js";
7
- import { Logger } from "../../logger/Logger.js";
7
+ import { getAndFlushLogsFromCache, Logger } from "../../logger/Logger.js";
8
8
  import {
9
9
  InProgressPerformanceEvent,
10
10
  IPerformanceClient,
@@ -21,6 +21,7 @@ import { AuthError } from "../../error/AuthError.js";
21
21
  import { CacheError } from "../../error/CacheError.js";
22
22
  import { ServerError } from "../../error/ServerError.js";
23
23
  import { InteractionRequiredAuthError } from "../../error/InteractionRequiredAuthError.js";
24
+ import { AccountInfo } from "../../account/AccountInfo.js";
24
25
 
25
26
  /**
26
27
  * Starts context by adding payload to the stack
@@ -250,6 +251,22 @@ export function compactStackLine(line: string): string {
250
251
  return line.trimStart();
251
252
  }
252
253
 
254
+ export function getAccountType(
255
+ account?: AccountInfo
256
+ ): "AAD" | "MSA" | "B2C" | undefined {
257
+ const idTokenClaims = account?.idTokenClaims;
258
+ if (idTokenClaims?.tfp || idTokenClaims?.acr) {
259
+ return "B2C";
260
+ }
261
+
262
+ if (!idTokenClaims?.tid) {
263
+ return undefined;
264
+ } else if (idTokenClaims?.tid === "9188040d-6c67-4c5b-b112-36a304b66dad") {
265
+ return "MSA";
266
+ }
267
+ return "AAD";
268
+ }
269
+
253
270
  export abstract class PerformanceClient implements IPerformanceClient {
254
271
  protected authority: string;
255
272
  protected libraryName: string;
@@ -333,17 +350,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
333
350
  ): InProgressPerformanceEvent {
334
351
  // Generate a placeholder correlation if the request does not provide one
335
352
  const eventCorrelationId = correlationId || this.generateId();
336
- if (!correlationId) {
337
- this.logger.info(
338
- `PerformanceClient: No correlation id provided for '${measureName}', generating`,
339
- eventCorrelationId
340
- );
341
- }
342
-
343
- this.logger.trace(
344
- `PerformanceClient: Performance measurement started for '${measureName}'`,
345
- eventCorrelationId
346
- );
347
353
 
348
354
  const inProgressEvent: PerformanceEvent = {
349
355
  eventId: this.generateId(),
@@ -367,7 +373,8 @@ export abstract class PerformanceClient implements IPerformanceClient {
367
373
  return {
368
374
  end: (
369
375
  event?: Partial<PerformanceEvent>,
370
- error?: unknown
376
+ error?: unknown,
377
+ account?: AccountInfo
371
378
  ): PerformanceEvent | null => {
372
379
  return this.endMeasurement(
373
380
  {
@@ -376,7 +383,8 @@ export abstract class PerformanceClient implements IPerformanceClient {
376
383
  // Properties set when event ends
377
384
  ...event,
378
385
  },
379
- error
386
+ error,
387
+ account
380
388
  );
381
389
  },
382
390
  discard: () => {
@@ -403,11 +411,13 @@ export abstract class PerformanceClient implements IPerformanceClient {
403
411
  *
404
412
  * @param {PerformanceEvent} event
405
413
  * @param {unknown} error
414
+ * @param {AccountInfo?} account
406
415
  * @returns {(PerformanceEvent | null)}
407
416
  */
408
417
  endMeasurement(
409
418
  event: PerformanceEvent,
410
- error?: unknown
419
+ error?: unknown,
420
+ account?: AccountInfo
411
421
  ): PerformanceEvent | null {
412
422
  const rootEvent: PerformanceEvent | undefined =
413
423
  this.eventsByCorrelationId.get(event.correlationId);
@@ -439,11 +449,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
439
449
  rootEvent.incompleteSubMeasurements?.delete(event.eventId);
440
450
  }
441
451
 
442
- this.logger.trace(
443
- `PerformanceClient: Performance measurement ended for '${event.name}': '${event.durationMs}' ms`,
444
- event.correlationId
445
- );
446
-
447
452
  if (error) {
448
453
  addError(error, this.logger, rootEvent);
449
454
  }
@@ -479,12 +484,26 @@ export abstract class PerformanceClient implements IPerformanceClient {
479
484
  });
480
485
  finalEvent.incompleteSubMeasurements = undefined;
481
486
 
487
+ const logs = getAndFlushLogsFromCache(event.correlationId);
488
+ // Format logs: [millis1,hash1;millis2,hash2;...]
489
+ const formattedLogs = logs
490
+ .map(
491
+ (logMessage) => `${logMessage.milliseconds},${logMessage.hash}`
492
+ )
493
+ .join(";");
494
+
482
495
  finalEvent = {
483
496
  ...finalEvent,
484
497
  status: PerformanceEventStatus.Completed,
485
498
  incompleteSubsCount,
486
499
  context,
500
+ logs: formattedLogs,
487
501
  };
502
+ if (account) {
503
+ finalEvent.accountType = getAccountType(account);
504
+ finalEvent.dataBoundary = account.dataBoundary;
505
+ }
506
+
488
507
  this.truncateIntegralFields(finalEvent);
489
508
  this.emitEvents([finalEvent], event.correlationId);
490
509
 
@@ -500,10 +519,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
500
519
  fields: { [key: string]: {} | undefined },
501
520
  correlationId: string
502
521
  ): void {
503
- this.logger.trace(
504
- "PerformanceClient: Updating static fields",
505
- correlationId
506
- );
507
522
  const event = this.eventsByCorrelationId.get(correlationId);
508
523
  if (event) {
509
524
  this.eventsByCorrelationId.set(correlationId, {
@@ -527,10 +542,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
527
542
  fields: { [key: string]: number | undefined },
528
543
  correlationId: string
529
544
  ): void {
530
- this.logger.trace(
531
- "PerformanceClient: Updating counters",
532
- correlationId
533
- );
534
545
  const event = this.eventsByCorrelationId.get(correlationId);
535
546
  if (event) {
536
547
  for (const counter in fields) {
@@ -561,10 +572,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
561
572
  protected cacheEventByCorrelationId(event: PerformanceEvent): void {
562
573
  const rootEvent = this.eventsByCorrelationId.get(event.correlationId);
563
574
  if (rootEvent) {
564
- this.logger.trace(
565
- `PerformanceClient: Performance measurement for '${event.name}' added/updated`,
566
- event.correlationId
567
- );
568
575
  rootEvent.incompleteSubMeasurements =
569
576
  rootEvent.incompleteSubMeasurements || new Map();
570
577
  rootEvent.incompleteSubMeasurements.set(event.eventId, {
@@ -572,10 +579,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
572
579
  startTimeMs: event.startTimeMs,
573
580
  });
574
581
  } else {
575
- this.logger.trace(
576
- `PerformanceClient: Performance measurement for '${event.name}' started`,
577
- event.correlationId
578
- );
579
582
  this.eventsByCorrelationId.set(event.correlationId, { ...event });
580
583
  this.eventStack.set(event.correlationId, []);
581
584
  }
@@ -587,16 +590,7 @@ export abstract class PerformanceClient implements IPerformanceClient {
587
590
  * @param {string} correlationId
588
591
  */
589
592
  discardMeasurements(correlationId: string): void {
590
- this.logger.trace(
591
- "PerformanceClient: Performance measurements discarded",
592
- correlationId
593
- );
594
593
  this.eventsByCorrelationId.delete(correlationId);
595
-
596
- this.logger.trace(
597
- "PerformanceClient: Event stack discarded",
598
- correlationId
599
- );
600
594
  this.eventStack.delete(correlationId);
601
595
  }
602
596
 
@@ -3,6 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { DataBoundary } from "../../account/AccountInfo.js";
7
+
6
8
  /**
7
9
  * State of the performance event.
8
10
  *
@@ -331,6 +333,11 @@ export type PerformanceEvent = {
331
333
  sameClientIdInstanceCount?: number;
332
334
 
333
335
  navigateCallbackResult?: boolean;
336
+
337
+ dataBoundary?: DataBoundary;
338
+
339
+ // Hashed logs in the format [millis1,hash1;millis2,hash2;...]
340
+ logs?: string;
334
341
  };
335
342
 
336
343
  export type PerformanceEventContext = {
@@ -55,6 +55,7 @@ export const HandleCodeResponseFromServer = "handleCodeResponseFromServer";
55
55
  export const AuthClientExecuteTokenRequest = "authClientExecuteTokenRequest";
56
56
  export const AuthClientCreateTokenRequestBody =
57
57
  "authClientCreateTokenRequestBody";
58
+ export const UpdateTokenEndpointAuthority = "updateTokenEndpointAuthority";
58
59
 
59
60
  /**
60
61
  * Generate functions in PopTokenGenerator (msal-common)
@@ -68,6 +68,12 @@ export const HTTP_GATEWAY_TIMEOUT: number = 504;
68
68
  export const HTTP_SERVER_ERROR_RANGE_END: number = 599;
69
69
  export const HTTP_MULTI_SIDED_ERROR: number = 600;
70
70
 
71
+ export const HttpMethod = {
72
+ GET: "GET",
73
+ POST: "POST",
74
+ } as const;
75
+ export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
76
+
71
77
  export const OIDC_DEFAULT_SCOPES = [
72
78
  OPENID_SCOPE,
73
79
  PROFILE_SCOPE,
@@ -9,112 +9,86 @@ import {
9
9
  ClientAuthErrorCodes,
10
10
  createClientAuthError,
11
11
  } from "../error/ClientAuthError.js";
12
+ import { LibraryStateObject, RequestStateObject } from "./StateTypes.js";
12
13
 
13
14
  /**
14
- * Type which defines the object that is stringified, encoded and sent in the state value.
15
- * Contains the following:
16
- * - id - unique identifier for this request
17
- * - ts - timestamp for the time the request was made. Used to ensure that token expiration is not calculated incorrectly.
18
- * - platformState - string value sent from the platform.
15
+ * Appends user state with random guid, or returns random guid.
16
+ * @param cryptoObj
17
+ * @param userState
18
+ * @param meta
19
19
  */
20
- export type LibraryStateObject = {
21
- id: string;
22
- meta?: Record<string, string>;
23
- };
24
-
25
- /**
26
- * Type which defines the stringified and encoded object sent to the service in the authorize request.
27
- */
28
- export type RequestStateObject = {
29
- userRequestState: string;
30
- libraryState: LibraryStateObject;
31
- };
20
+ export function setRequestState(
21
+ cryptoObj: ICrypto,
22
+ userState?: string,
23
+ meta?: Record<string, string>
24
+ ): string {
25
+ const libraryState = generateLibraryState(cryptoObj, meta);
26
+ return userState
27
+ ? `${libraryState}${RESOURCE_DELIM}${userState}`
28
+ : libraryState;
29
+ }
32
30
 
33
31
  /**
34
- * Class which provides helpers for OAuth 2.0 protocol specific values
32
+ * Generates the state value used by the common library.
33
+ * @param cryptoObj
34
+ * @param meta
35
35
  */
36
- export class ProtocolUtils {
37
- /**
38
- * Appends user state with random guid, or returns random guid.
39
- * @param userState
40
- * @param randomGuid
41
- */
42
- static setRequestState(
43
- cryptoObj: ICrypto,
44
- userState?: string,
45
- meta?: Record<string, string>
46
- ): string {
47
- const libraryState = ProtocolUtils.generateLibraryState(
48
- cryptoObj,
49
- meta
50
- );
51
- return userState
52
- ? `${libraryState}${RESOURCE_DELIM}${userState}`
53
- : libraryState;
36
+ export function generateLibraryState(
37
+ cryptoObj: ICrypto,
38
+ meta?: Record<string, string>
39
+ ): string {
40
+ if (!cryptoObj) {
41
+ throw createClientAuthError(ClientAuthErrorCodes.noCryptoObject);
54
42
  }
55
43
 
56
- /**
57
- * Generates the state value used by the common library.
58
- * @param randomGuid
59
- * @param cryptoObj
60
- */
61
- static generateLibraryState(
62
- cryptoObj: ICrypto,
63
- meta?: Record<string, string>
64
- ): string {
65
- if (!cryptoObj) {
66
- throw createClientAuthError(ClientAuthErrorCodes.noCryptoObject);
67
- }
44
+ // Create a state object containing a unique id and the timestamp of the request creation
45
+ const stateObj: LibraryStateObject = {
46
+ id: cryptoObj.createNewGuid(),
47
+ };
68
48
 
69
- // Create a state object containing a unique id and the timestamp of the request creation
70
- const stateObj: LibraryStateObject = {
71
- id: cryptoObj.createNewGuid(),
72
- };
49
+ if (meta) {
50
+ stateObj.meta = meta;
51
+ }
73
52
 
74
- if (meta) {
75
- stateObj.meta = meta;
76
- }
53
+ const stateString = JSON.stringify(stateObj);
77
54
 
78
- const stateString = JSON.stringify(stateObj);
55
+ return cryptoObj.base64Encode(stateString);
56
+ }
79
57
 
80
- return cryptoObj.base64Encode(stateString);
58
+ /**
59
+ * Parses the state into the RequestStateObject, which contains the LibraryState info and the state passed by the user.
60
+ * @param base64Decode
61
+ * @param state
62
+ */
63
+ export function parseRequestState(
64
+ base64Decode: (input: string) => string,
65
+ state: string
66
+ ): RequestStateObject {
67
+ if (!base64Decode) {
68
+ throw createClientAuthError(ClientAuthErrorCodes.noCryptoObject);
81
69
  }
82
70
 
83
- /**
84
- * Parses the state into the RequestStateObject, which contains the LibraryState info and the state passed by the user.
85
- * @param state
86
- * @param cryptoObj
87
- */
88
- static parseRequestState(
89
- cryptoObj: ICrypto,
90
- state: string
91
- ): RequestStateObject {
92
- if (!cryptoObj) {
93
- throw createClientAuthError(ClientAuthErrorCodes.noCryptoObject);
94
- }
95
-
96
- if (!state) {
97
- throw createClientAuthError(ClientAuthErrorCodes.invalidState);
98
- }
71
+ if (!state) {
72
+ throw createClientAuthError(ClientAuthErrorCodes.invalidState);
73
+ }
99
74
 
100
- try {
101
- // Split the state between library state and user passed state and decode them separately
102
- const splitState = state.split(RESOURCE_DELIM);
103
- const libraryState = splitState[0];
104
- const userState =
105
- splitState.length > 1
106
- ? splitState.slice(1).join(RESOURCE_DELIM)
107
- : "";
108
- const libraryStateString = cryptoObj.base64Decode(libraryState);
109
- const libraryStateObj = JSON.parse(
110
- libraryStateString
111
- ) as LibraryStateObject;
112
- return {
113
- userRequestState: userState || "",
114
- libraryState: libraryStateObj,
115
- };
116
- } catch (e) {
117
- throw createClientAuthError(ClientAuthErrorCodes.invalidState);
118
- }
75
+ try {
76
+ // Split the state between library state and user passed state and decode them separately
77
+ const splitState = state.split(RESOURCE_DELIM);
78
+ const libraryState = splitState[0];
79
+ const userState =
80
+ splitState.length > 1
81
+ ? splitState.slice(1).join(RESOURCE_DELIM)
82
+ : "";
83
+ const libraryStateString = base64Decode(libraryState);
84
+ const libraryStateObj = JSON.parse(
85
+ libraryStateString
86
+ ) as LibraryStateObject;
87
+ return {
88
+ userRequestState: userState || "",
89
+ libraryState: libraryStateObj,
90
+ };
91
+ } catch (e) {
92
+ throw createClientAuthError(ClientAuthErrorCodes.invalidState);
119
93
  }
120
94
  }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /**
7
+ * Type which defines library state
8
+ */
9
+ export type LibraryStateObject = {
10
+ id: string;
11
+ meta?: Record<string, string>;
12
+ };
13
+
14
+ /**
15
+ * Type which defines the stringified and encoded state object sent to the service in the authorize request.
16
+ */
17
+ export type RequestStateObject = {
18
+ userRequestState: string;
19
+ libraryState: LibraryStateObject;
20
+ };
@@ -1,59 +0,0 @@
1
- import { ClientConfiguration, CommonClientConfiguration } from "../config/ClientConfiguration.js";
2
- import { INetworkModule, NetworkRequestOptions } from "../network/INetworkModule.js";
3
- import { NetworkResponse } from "../network/NetworkResponse.js";
4
- import { ICrypto } from "../crypto/ICrypto.js";
5
- import { Authority } from "../authority/Authority.js";
6
- import { Logger } from "../logger/Logger.js";
7
- import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
8
- import { CacheManager } from "../cache/CacheManager.js";
9
- import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager.js";
10
- import { RequestThumbprint } from "../network/RequestThumbprint.js";
11
- import { CcsCredential } from "../account/CcsCredential.js";
12
- import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient.js";
13
- import { BaseAuthRequest } from "../request/BaseAuthRequest.js";
14
- /**
15
- * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
16
- * @internal
17
- */
18
- export declare abstract class BaseClient {
19
- logger: Logger;
20
- protected config: CommonClientConfiguration;
21
- protected cryptoUtils: ICrypto;
22
- protected cacheManager: CacheManager;
23
- protected networkClient: INetworkModule;
24
- protected serverTelemetryManager: ServerTelemetryManager | null;
25
- authority: Authority;
26
- protected performanceClient: IPerformanceClient;
27
- protected constructor(configuration: ClientConfiguration, performanceClient: IPerformanceClient);
28
- /**
29
- * Creates default headers for requests to token endpoint
30
- */
31
- protected createTokenRequestHeaders(ccsCred?: CcsCredential): Record<string, string>;
32
- /**
33
- * Http post to token endpoint
34
- * @param tokenEndpoint
35
- * @param queryString
36
- * @param headers
37
- * @param thumbprint
38
- */
39
- protected executePostToTokenEndpoint(tokenEndpoint: string, queryString: string, headers: Record<string, string>, thumbprint: RequestThumbprint, correlationId: string): Promise<NetworkResponse<ServerAuthorizationTokenResponse>>;
40
- /**
41
- * Wraps sendPostRequestAsync with necessary preflight and postflight logic
42
- * @param thumbprint - Request thumbprint for throttling
43
- * @param tokenEndpoint - Endpoint to make the POST to
44
- * @param options - Body and Headers to include on the POST request
45
- * @param correlationId - CorrelationId for telemetry
46
- */
47
- sendPostRequest<T extends ServerAuthorizationTokenResponse>(thumbprint: RequestThumbprint, tokenEndpoint: string, options: NetworkRequestOptions, correlationId: string): Promise<NetworkResponse<T>>;
48
- /**
49
- * Updates the authority object of the client. Endpoint discovery must be completed.
50
- * @param updatedAuthority
51
- */
52
- updateAuthority(cloudInstanceHostname: string, correlationId: string): Promise<void>;
53
- /**
54
- * Creates query string for the /token request
55
- * @param request
56
- */
57
- createTokenQueryParameters(request: BaseAuthRequest): string;
58
- }
59
- //# sourceMappingURL=BaseClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../../src/client/BaseClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,mBAAmB,EAEnB,yBAAyB,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,cAAc,EACd,qBAAqB,EACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAqB,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAGpF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAYhE;;;GAGG;AACH,8BAAsB,UAAU;IAErB,MAAM,EAAE,MAAM,CAAC;IAGtB,SAAS,CAAC,MAAM,EAAE,yBAAyB,CAAC;IAG5C,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC;IAG/B,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IAGrC,SAAS,CAAC,aAAa,EAAE,cAAc,CAAC;IAGxC,SAAS,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAGzD,SAAS,EAAE,SAAS,CAAC;IAG5B,SAAS,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;IAEhD,SAAS,aACL,aAAa,EAAE,mBAAmB,EAClC,iBAAiB,EAAE,kBAAkB;IA2BzC;;OAEG;IACH,SAAS,CAAC,yBAAyB,CAC/B,OAAO,CAAC,EAAE,aAAa,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA8BzB;;;;;;OAMG;cACa,0BAA0B,CACtC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC,gCAAgC,CAAC,CAAC;IAqB7D;;;;;;OAMG;IACG,eAAe,CAAC,CAAC,SAAS,gCAAgC,EAC5D,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,qBAAqB,EAC9B,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAwE9B;;;OAGG;IACG,eAAe,CACjB,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC;IAchB;;;OAGG;IACH,0BAA0B,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM;CA8B/D"}
@@ -1,162 +0,0 @@
1
- /*! @azure/msal-common v16.0.0-alpha.0 2025-10-02 */
2
- 'use strict';
3
- import { buildClientConfiguration } from '../config/ClientConfiguration.mjs';
4
- import { Logger } from '../logger/Logger.mjs';
5
- import { URL_FORM_CONTENT_TYPE, HeaderNames } from '../utils/Constants.mjs';
6
- import { name, version } from '../packageMetadata.mjs';
7
- import { CcsCredentialType } from '../account/CcsCredential.mjs';
8
- import { buildClientInfoFromHomeAccountId } from '../account/ClientInfo.mjs';
9
- import { addBrokerParameters, addExtraQueryParameters, addCorrelationId, instrumentBrokerParams } from '../request/RequestParameterBuilder.mjs';
10
- import { mapToQueryString } from '../utils/UrlUtils.mjs';
11
- import { createDiscoveredInstance } from '../authority/AuthorityFactory.mjs';
12
- import { NetworkClientSendPostRequestAsync } from '../telemetry/performance/PerformanceEvents.mjs';
13
- import { ThrottlingUtils } from '../network/ThrottlingUtils.mjs';
14
- import { AuthError } from '../error/AuthError.mjs';
15
- import { createClientAuthError } from '../error/ClientAuthError.mjs';
16
- import { NetworkError } from '../error/NetworkError.mjs';
17
- import { invokeAsync } from '../utils/FunctionWrappers.mjs';
18
- import { networkError } from '../error/ClientAuthErrorCodes.mjs';
19
-
20
- /*
21
- * Copyright (c) Microsoft Corporation. All rights reserved.
22
- * Licensed under the MIT License.
23
- */
24
- /**
25
- * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
26
- * @internal
27
- */
28
- class BaseClient {
29
- constructor(configuration, performanceClient) {
30
- // Set the configuration
31
- this.config = buildClientConfiguration(configuration);
32
- // Initialize the logger
33
- this.logger = new Logger(this.config.loggerOptions, name, version);
34
- // Initialize crypto
35
- this.cryptoUtils = this.config.cryptoInterface;
36
- // Initialize storage interface
37
- this.cacheManager = this.config.storageInterface;
38
- // Set the network interface
39
- this.networkClient = this.config.networkInterface;
40
- // Set TelemetryManager
41
- this.serverTelemetryManager = this.config.serverTelemetryManager;
42
- // set Authority
43
- this.authority = this.config.authOptions.authority;
44
- // set performance telemetry client
45
- this.performanceClient = performanceClient;
46
- }
47
- /**
48
- * Creates default headers for requests to token endpoint
49
- */
50
- createTokenRequestHeaders(ccsCred) {
51
- const headers = {};
52
- headers[HeaderNames.CONTENT_TYPE] = URL_FORM_CONTENT_TYPE;
53
- if (!this.config.systemOptions.preventCorsPreflight && ccsCred) {
54
- switch (ccsCred.type) {
55
- case CcsCredentialType.HOME_ACCOUNT_ID:
56
- try {
57
- const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
58
- headers[HeaderNames.CCS_HEADER] = `Oid:${clientInfo.uid}@${clientInfo.utid}`;
59
- }
60
- catch (e) {
61
- this.logger.verbose(`Could not parse home account ID for CCS Header: '${e}'`, "");
62
- }
63
- break;
64
- case CcsCredentialType.UPN:
65
- headers[HeaderNames.CCS_HEADER] = `UPN: ${ccsCred.credential}`;
66
- break;
67
- }
68
- }
69
- return headers;
70
- }
71
- /**
72
- * Http post to token endpoint
73
- * @param tokenEndpoint
74
- * @param queryString
75
- * @param headers
76
- * @param thumbprint
77
- */
78
- async executePostToTokenEndpoint(tokenEndpoint, queryString, headers, thumbprint, correlationId) {
79
- const response = await this.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers }, correlationId);
80
- if (this.config.serverTelemetryManager &&
81
- response.status < 500 &&
82
- response.status !== 429) {
83
- // Telemetry data successfully logged by server, clear Telemetry cache
84
- this.config.serverTelemetryManager.clearTelemetryCache();
85
- }
86
- return response;
87
- }
88
- /**
89
- * Wraps sendPostRequestAsync with necessary preflight and postflight logic
90
- * @param thumbprint - Request thumbprint for throttling
91
- * @param tokenEndpoint - Endpoint to make the POST to
92
- * @param options - Body and Headers to include on the POST request
93
- * @param correlationId - CorrelationId for telemetry
94
- */
95
- async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
96
- ThrottlingUtils.preProcess(this.cacheManager, thumbprint, correlationId);
97
- let response;
98
- try {
99
- response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
100
- const responseHeaders = response.headers || {};
101
- this.performanceClient?.addFields({
102
- refreshTokenSize: response.body.refresh_token?.length || 0,
103
- httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
104
- requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
105
- }, correlationId);
106
- }
107
- catch (e) {
108
- if (e instanceof NetworkError) {
109
- const responseHeaders = e.responseHeaders;
110
- if (responseHeaders) {
111
- this.performanceClient?.addFields({
112
- httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
113
- requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
114
- "",
115
- contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
116
- undefined,
117
- contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
118
- undefined,
119
- httpStatus: e.httpStatus,
120
- }, correlationId);
121
- }
122
- throw e.error;
123
- }
124
- if (e instanceof AuthError) {
125
- throw e;
126
- }
127
- else {
128
- throw createClientAuthError(networkError);
129
- }
130
- }
131
- ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response, correlationId);
132
- return response;
133
- }
134
- /**
135
- * Updates the authority object of the client. Endpoint discovery must be completed.
136
- * @param updatedAuthority
137
- */
138
- async updateAuthority(cloudInstanceHostname, correlationId) {
139
- const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${this.authority.tenant}/`;
140
- const cloudInstanceAuthority = await createDiscoveredInstance(cloudInstanceAuthorityUri, this.networkClient, this.cacheManager, this.authority.options, this.logger, correlationId, this.performanceClient);
141
- this.authority = cloudInstanceAuthority;
142
- }
143
- /**
144
- * Creates query string for the /token request
145
- * @param request
146
- */
147
- createTokenQueryParameters(request) {
148
- const parameters = new Map();
149
- if (request.embeddedClientId) {
150
- addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
151
- }
152
- if (request.tokenQueryParameters) {
153
- addExtraQueryParameters(parameters, request.tokenQueryParameters);
154
- }
155
- addCorrelationId(parameters, request.correlationId);
156
- instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
157
- return mapToQueryString(parameters);
158
- }
159
- }
160
-
161
- export { BaseClient };
162
- //# sourceMappingURL=BaseClient.mjs.map