@azure/msal-common 0.0.1-alpha.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 (333) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/dist/_virtual/_tslib.js +90 -0
  4. package/dist/_virtual/_tslib.js.map +1 -0
  5. package/dist/account/AccountInfo.d.ts +30 -0
  6. package/dist/account/AccountInfo.d.ts.map +1 -0
  7. package/dist/account/AuthToken.d.ts +17 -0
  8. package/dist/account/AuthToken.d.ts.map +1 -0
  9. package/dist/account/AuthToken.js +43 -0
  10. package/dist/account/AuthToken.js.map +1 -0
  11. package/dist/account/CcsCredential.d.ts +9 -0
  12. package/dist/account/CcsCredential.d.ts.map +1 -0
  13. package/dist/account/CcsCredential.js +14 -0
  14. package/dist/account/CcsCredential.js.map +1 -0
  15. package/dist/account/ClientCredentials.d.ts +15 -0
  16. package/dist/account/ClientCredentials.d.ts.map +1 -0
  17. package/dist/account/ClientInfo.d.ts +20 -0
  18. package/dist/account/ClientInfo.d.ts.map +1 -0
  19. package/dist/account/ClientInfo.js +44 -0
  20. package/dist/account/ClientInfo.js.map +1 -0
  21. package/dist/account/DecodedAuthToken.d.ts +9 -0
  22. package/dist/account/DecodedAuthToken.d.ts.map +1 -0
  23. package/dist/account/TokenClaims.d.ts +60 -0
  24. package/dist/account/TokenClaims.d.ts.map +1 -0
  25. package/dist/authority/Authority.d.ts +200 -0
  26. package/dist/authority/Authority.d.ts.map +1 -0
  27. package/dist/authority/Authority.js +678 -0
  28. package/dist/authority/Authority.js.map +1 -0
  29. package/dist/authority/AuthorityFactory.d.ts +29 -0
  30. package/dist/authority/AuthorityFactory.d.ts.map +1 -0
  31. package/dist/authority/AuthorityFactory.js +69 -0
  32. package/dist/authority/AuthorityFactory.js.map +1 -0
  33. package/dist/authority/AuthorityMetadata.d.ts +623 -0
  34. package/dist/authority/AuthorityMetadata.d.ts.map +1 -0
  35. package/dist/authority/AuthorityMetadata.js +12 -0
  36. package/dist/authority/AuthorityMetadata.js.map +1 -0
  37. package/dist/authority/AuthorityOptions.d.ts +19 -0
  38. package/dist/authority/AuthorityOptions.d.ts.map +1 -0
  39. package/dist/authority/AuthorityOptions.js +24 -0
  40. package/dist/authority/AuthorityOptions.js.map +1 -0
  41. package/dist/authority/AuthorityType.d.ts +8 -0
  42. package/dist/authority/AuthorityType.d.ts.map +1 -0
  43. package/dist/authority/AuthorityType.js +17 -0
  44. package/dist/authority/AuthorityType.js.map +1 -0
  45. package/dist/authority/AzureRegion.d.ts +2 -0
  46. package/dist/authority/AzureRegion.d.ts.map +1 -0
  47. package/dist/authority/AzureRegionConfiguration.d.ts +6 -0
  48. package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -0
  49. package/dist/authority/CloudDiscoveryMetadata.d.ts +6 -0
  50. package/dist/authority/CloudDiscoveryMetadata.d.ts.map +1 -0
  51. package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +10 -0
  52. package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -0
  53. package/dist/authority/CloudInstanceDiscoveryResponse.js +13 -0
  54. package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -0
  55. package/dist/authority/ImdsOptions.d.ts +7 -0
  56. package/dist/authority/ImdsOptions.d.ts.map +1 -0
  57. package/dist/authority/OpenIdConfigResponse.d.ts +12 -0
  58. package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -0
  59. package/dist/authority/OpenIdConfigResponse.js +15 -0
  60. package/dist/authority/OpenIdConfigResponse.js.map +1 -0
  61. package/dist/authority/ProtocolMode.d.ts +8 -0
  62. package/dist/authority/ProtocolMode.d.ts.map +1 -0
  63. package/dist/authority/ProtocolMode.js +17 -0
  64. package/dist/authority/ProtocolMode.js.map +1 -0
  65. package/dist/authority/RegionDiscovery.d.ts +28 -0
  66. package/dist/authority/RegionDiscovery.d.ts.map +1 -0
  67. package/dist/authority/RegionDiscovery.js +127 -0
  68. package/dist/authority/RegionDiscovery.js.map +1 -0
  69. package/dist/authority/RegionDiscoveryMetadata.d.ts +7 -0
  70. package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -0
  71. package/dist/cache/CacheManager.d.ts +393 -0
  72. package/dist/cache/CacheManager.d.ts.map +1 -0
  73. package/dist/cache/CacheManager.js +885 -0
  74. package/dist/cache/CacheManager.js.map +1 -0
  75. package/dist/cache/entities/AccessTokenEntity.d.ts +57 -0
  76. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -0
  77. package/dist/cache/entities/AccessTokenEntity.js +124 -0
  78. package/dist/cache/entities/AccessTokenEntity.js.map +1 -0
  79. package/dist/cache/entities/AccountEntity.d.ts +100 -0
  80. package/dist/cache/entities/AccountEntity.d.ts.map +1 -0
  81. package/dist/cache/entities/AccountEntity.js +243 -0
  82. package/dist/cache/entities/AccountEntity.js.map +1 -0
  83. package/dist/cache/entities/AppMetadataEntity.d.ts +40 -0
  84. package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -0
  85. package/dist/cache/entities/AppMetadataEntity.js +74 -0
  86. package/dist/cache/entities/AppMetadataEntity.js.map +1 -0
  87. package/dist/cache/entities/AuthorityMetadataEntity.d.ts +48 -0
  88. package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -0
  89. package/dist/cache/entities/AuthorityMetadataEntity.js +82 -0
  90. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -0
  91. package/dist/cache/entities/CacheRecord.d.ts +14 -0
  92. package/dist/cache/entities/CacheRecord.d.ts.map +1 -0
  93. package/dist/cache/entities/CacheRecord.js +19 -0
  94. package/dist/cache/entities/CacheRecord.js.map +1 -0
  95. package/dist/cache/entities/CredentialEntity.d.ts +94 -0
  96. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -0
  97. package/dist/cache/entities/CredentialEntity.js +164 -0
  98. package/dist/cache/entities/CredentialEntity.js.map +1 -0
  99. package/dist/cache/entities/IdTokenEntity.d.ts +35 -0
  100. package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -0
  101. package/dist/cache/entities/IdTokenEntity.js +70 -0
  102. package/dist/cache/entities/IdTokenEntity.js.map +1 -0
  103. package/dist/cache/entities/RefreshTokenEntity.d.ts +37 -0
  104. package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -0
  105. package/dist/cache/entities/RefreshTokenEntity.js +73 -0
  106. package/dist/cache/entities/RefreshTokenEntity.js.map +1 -0
  107. package/dist/cache/entities/ServerTelemetryEntity.d.ts +13 -0
  108. package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -0
  109. package/dist/cache/entities/ServerTelemetryEntity.js +35 -0
  110. package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -0
  111. package/dist/cache/entities/ThrottlingEntity.d.ts +14 -0
  112. package/dist/cache/entities/ThrottlingEntity.d.ts.map +1 -0
  113. package/dist/cache/entities/ThrottlingEntity.js +32 -0
  114. package/dist/cache/entities/ThrottlingEntity.js.map +1 -0
  115. package/dist/cache/interface/ICacheManager.d.ts +157 -0
  116. package/dist/cache/interface/ICacheManager.d.ts.map +1 -0
  117. package/dist/cache/interface/ICachePlugin.d.ts +6 -0
  118. package/dist/cache/interface/ICachePlugin.d.ts.map +1 -0
  119. package/dist/cache/interface/ISerializableTokenCache.d.ts +5 -0
  120. package/dist/cache/interface/ISerializableTokenCache.d.ts.map +1 -0
  121. package/dist/cache/persistence/TokenCacheContext.d.ts +24 -0
  122. package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -0
  123. package/dist/cache/persistence/TokenCacheContext.js +39 -0
  124. package/dist/cache/persistence/TokenCacheContext.js.map +1 -0
  125. package/dist/cache/utils/CacheTypes.d.ts +60 -0
  126. package/dist/cache/utils/CacheTypes.d.ts.map +1 -0
  127. package/dist/client/AuthorizationCodeClient.d.ts +76 -0
  128. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -0
  129. package/dist/client/AuthorizationCodeClient.js +468 -0
  130. package/dist/client/AuthorizationCodeClient.js.map +1 -0
  131. package/dist/client/BaseClient.d.ts +45 -0
  132. package/dist/client/BaseClient.d.ts.map +1 -0
  133. package/dist/client/BaseClient.js +103 -0
  134. package/dist/client/BaseClient.js.map +1 -0
  135. package/dist/client/ClientCredentialClient.d.ts +39 -0
  136. package/dist/client/ClientCredentialClient.d.ts.map +1 -0
  137. package/dist/client/ClientCredentialClient.js +202 -0
  138. package/dist/client/ClientCredentialClient.js.map +1 -0
  139. package/dist/client/DeviceCodeClient.d.ts +52 -0
  140. package/dist/client/DeviceCodeClient.d.ts.map +1 -0
  141. package/dist/client/DeviceCodeClient.js +232 -0
  142. package/dist/client/DeviceCodeClient.js.map +1 -0
  143. package/dist/client/OnBehalfOfClient.d.ts +51 -0
  144. package/dist/client/OnBehalfOfClient.d.ts.map +1 -0
  145. package/dist/client/OnBehalfOfClient.js +244 -0
  146. package/dist/client/OnBehalfOfClient.js.map +1 -0
  147. package/dist/client/RefreshTokenClient.d.ts +40 -0
  148. package/dist/client/RefreshTokenClient.d.ts.map +1 -0
  149. package/dist/client/RefreshTokenClient.js +255 -0
  150. package/dist/client/RefreshTokenClient.js.map +1 -0
  151. package/dist/client/SilentFlowClient.d.ts +25 -0
  152. package/dist/client/SilentFlowClient.d.ts.map +1 -0
  153. package/dist/client/SilentFlowClient.js +128 -0
  154. package/dist/client/SilentFlowClient.js.map +1 -0
  155. package/dist/client/UsernamePasswordClient.d.ts +29 -0
  156. package/dist/client/UsernamePasswordClient.d.ts.map +1 -0
  157. package/dist/client/UsernamePasswordClient.js +120 -0
  158. package/dist/client/UsernamePasswordClient.js.map +1 -0
  159. package/dist/config/AppTokenProvider.d.ts +39 -0
  160. package/dist/config/AppTokenProvider.d.ts.map +1 -0
  161. package/dist/config/ClientConfiguration.d.ts +135 -0
  162. package/dist/config/ClientConfiguration.d.ts.map +1 -0
  163. package/dist/config/ClientConfiguration.js +105 -0
  164. package/dist/config/ClientConfiguration.js.map +1 -0
  165. package/dist/crypto/ICrypto.d.ts +63 -0
  166. package/dist/crypto/ICrypto.d.ts.map +1 -0
  167. package/dist/crypto/ICrypto.js +80 -0
  168. package/dist/crypto/ICrypto.js.map +1 -0
  169. package/dist/crypto/IGuidGenerator.d.ts +5 -0
  170. package/dist/crypto/IGuidGenerator.d.ts.map +1 -0
  171. package/dist/crypto/JoseHeader.d.ts +22 -0
  172. package/dist/crypto/JoseHeader.d.ts.map +1 -0
  173. package/dist/crypto/JoseHeader.js +45 -0
  174. package/dist/crypto/JoseHeader.js.map +1 -0
  175. package/dist/crypto/PopTokenGenerator.d.ts +56 -0
  176. package/dist/crypto/PopTokenGenerator.d.ts.map +1 -0
  177. package/dist/crypto/PopTokenGenerator.js +107 -0
  178. package/dist/crypto/PopTokenGenerator.js.map +1 -0
  179. package/dist/crypto/SignedHttpRequest.d.ts +12 -0
  180. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -0
  181. package/dist/error/AuthError.d.ts +48 -0
  182. package/dist/error/AuthError.d.ts.map +1 -0
  183. package/dist/error/AuthError.js +61 -0
  184. package/dist/error/AuthError.js.map +1 -0
  185. package/dist/error/ClientAuthError.d.ts +372 -0
  186. package/dist/error/ClientAuthError.d.ts.map +1 -0
  187. package/dist/error/ClientAuthError.js +477 -0
  188. package/dist/error/ClientAuthError.js.map +1 -0
  189. package/dist/error/ClientConfigurationError.d.ts +199 -0
  190. package/dist/error/ClientConfigurationError.d.ts.map +1 -0
  191. package/dist/error/ClientConfigurationError.js +260 -0
  192. package/dist/error/ClientConfigurationError.js.map +1 -0
  193. package/dist/error/InteractionRequiredAuthError.d.ts +42 -0
  194. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -0
  195. package/dist/error/InteractionRequiredAuthError.js +80 -0
  196. package/dist/error/InteractionRequiredAuthError.js.map +1 -0
  197. package/dist/error/JoseHeaderError.d.ts +29 -0
  198. package/dist/error/JoseHeaderError.d.ts.map +1 -0
  199. package/dist/error/JoseHeaderError.js +50 -0
  200. package/dist/error/JoseHeaderError.js.map +1 -0
  201. package/dist/error/ServerError.d.ts +8 -0
  202. package/dist/error/ServerError.d.ts.map +1 -0
  203. package/dist/error/ServerError.js +25 -0
  204. package/dist/error/ServerError.js.map +1 -0
  205. package/dist/index.cjs.js +8441 -0
  206. package/dist/index.cjs.js.map +1 -0
  207. package/dist/index.d.ts +90 -0
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +53 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/logger/Logger.d.ts +95 -0
  212. package/dist/logger/Logger.d.ts.map +1 -0
  213. package/dist/logger/Logger.js +185 -0
  214. package/dist/logger/Logger.js.map +1 -0
  215. package/dist/network/INetworkModule.d.ts +31 -0
  216. package/dist/network/INetworkModule.d.ts.map +1 -0
  217. package/dist/network/INetworkModule.js +21 -0
  218. package/dist/network/INetworkModule.js.map +1 -0
  219. package/dist/network/NetworkManager.d.ts +21 -0
  220. package/dist/network/NetworkManager.d.ts.map +1 -0
  221. package/dist/network/NetworkManager.js +56 -0
  222. package/dist/network/NetworkManager.js.map +1 -0
  223. package/dist/network/RequestThumbprint.d.ts +17 -0
  224. package/dist/network/RequestThumbprint.d.ts.map +1 -0
  225. package/dist/network/ThrottlingUtils.d.ts +42 -0
  226. package/dist/network/ThrottlingUtils.d.ts.map +1 -0
  227. package/dist/network/ThrottlingUtils.js +101 -0
  228. package/dist/network/ThrottlingUtils.js.map +1 -0
  229. package/dist/packageMetadata.d.ts +3 -0
  230. package/dist/packageMetadata.d.ts.map +1 -0
  231. package/dist/packageMetadata.js +8 -0
  232. package/dist/packageMetadata.js.map +1 -0
  233. package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
  234. package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
  235. package/dist/request/AuthenticationHeaderParser.js +64 -0
  236. package/dist/request/AuthenticationHeaderParser.js.map +1 -0
  237. package/dist/request/BaseAuthRequest.d.ts +34 -0
  238. package/dist/request/BaseAuthRequest.d.ts.map +1 -0
  239. package/dist/request/CommonAuthorizationCodeRequest.d.ts +28 -0
  240. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -0
  241. package/dist/request/CommonAuthorizationUrlRequest.d.ts +51 -0
  242. package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -0
  243. package/dist/request/CommonClientCredentialRequest.d.ts +17 -0
  244. package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -0
  245. package/dist/request/CommonDeviceCodeRequest.d.ts +19 -0
  246. package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -0
  247. package/dist/request/CommonEndSessionRequest.d.ts +21 -0
  248. package/dist/request/CommonEndSessionRequest.d.ts.map +1 -0
  249. package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -0
  250. package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
  251. package/dist/request/CommonRefreshTokenRequest.d.ts +21 -0
  252. package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -0
  253. package/dist/request/CommonSilentFlowRequest.d.ts +20 -0
  254. package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -0
  255. package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -0
  256. package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -0
  257. package/dist/request/RequestParameterBuilder.d.ts +217 -0
  258. package/dist/request/RequestParameterBuilder.d.ts.map +1 -0
  259. package/dist/request/RequestParameterBuilder.js +387 -0
  260. package/dist/request/RequestParameterBuilder.js.map +1 -0
  261. package/dist/request/RequestValidator.d.ts +34 -0
  262. package/dist/request/RequestValidator.d.ts.map +1 -0
  263. package/dist/request/RequestValidator.js +92 -0
  264. package/dist/request/RequestValidator.js.map +1 -0
  265. package/dist/request/ScopeSet.d.ts +83 -0
  266. package/dist/request/ScopeSet.d.ts.map +1 -0
  267. package/dist/request/ScopeSet.js +192 -0
  268. package/dist/request/ScopeSet.js.map +1 -0
  269. package/dist/response/AuthenticationResult.d.ts +38 -0
  270. package/dist/response/AuthenticationResult.d.ts.map +1 -0
  271. package/dist/response/AuthorizationCodePayload.d.ts +14 -0
  272. package/dist/response/AuthorizationCodePayload.d.ts.map +1 -0
  273. package/dist/response/DeviceCodeResponse.d.ts +26 -0
  274. package/dist/response/DeviceCodeResponse.d.ts.map +1 -0
  275. package/dist/response/ExternalTokenResponse.d.ts +15 -0
  276. package/dist/response/ExternalTokenResponse.d.ts.map +1 -0
  277. package/dist/response/IMDSBadResponse.d.ts +5 -0
  278. package/dist/response/IMDSBadResponse.d.ts.map +1 -0
  279. package/dist/response/ResponseHandler.d.ts +71 -0
  280. package/dist/response/ResponseHandler.d.ts.map +1 -0
  281. package/dist/response/ResponseHandler.js +293 -0
  282. package/dist/response/ResponseHandler.js.map +1 -0
  283. package/dist/response/ServerAuthorizationCodeResponse.d.ts +22 -0
  284. package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -0
  285. package/dist/response/ServerAuthorizationTokenResponse.d.ts +43 -0
  286. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -0
  287. package/dist/telemetry/performance/IPerformanceClient.d.ts +22 -0
  288. package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -0
  289. package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +6 -0
  290. package/dist/telemetry/performance/IPerformanceMeasurement.d.ts.map +1 -0
  291. package/dist/telemetry/performance/PerformanceClient.d.ts +125 -0
  292. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -0
  293. package/dist/telemetry/performance/PerformanceClient.js +281 -0
  294. package/dist/telemetry/performance/PerformanceClient.js.map +1 -0
  295. package/dist/telemetry/performance/PerformanceEvent.d.ts +249 -0
  296. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
  297. package/dist/telemetry/performance/PerformanceEvent.js +121 -0
  298. package/dist/telemetry/performance/PerformanceEvent.js.map +1 -0
  299. package/dist/telemetry/performance/StubPerformanceClient.d.ts +13 -0
  300. package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -0
  301. package/dist/telemetry/performance/StubPerformanceClient.js +37 -0
  302. package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -0
  303. package/dist/telemetry/server/ServerTelemetryManager.d.ts +67 -0
  304. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -0
  305. package/dist/telemetry/server/ServerTelemetryManager.js +168 -0
  306. package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -0
  307. package/dist/telemetry/server/ServerTelemetryRequest.d.ts +9 -0
  308. package/dist/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -0
  309. package/dist/url/IUri.d.ts +13 -0
  310. package/dist/url/IUri.d.ts.map +1 -0
  311. package/dist/url/UrlString.d.ts +62 -0
  312. package/dist/url/UrlString.d.ts.map +1 -0
  313. package/dist/url/UrlString.js +208 -0
  314. package/dist/url/UrlString.js.map +1 -0
  315. package/dist/utils/Constants.d.ts +340 -0
  316. package/dist/utils/Constants.d.ts.map +1 -0
  317. package/dist/utils/Constants.js +381 -0
  318. package/dist/utils/Constants.js.map +1 -0
  319. package/dist/utils/MsalTypes.d.ts +7 -0
  320. package/dist/utils/MsalTypes.d.ts.map +1 -0
  321. package/dist/utils/ProtocolUtils.d.ts +43 -0
  322. package/dist/utils/ProtocolUtils.d.ts.map +1 -0
  323. package/dist/utils/ProtocolUtils.js +77 -0
  324. package/dist/utils/ProtocolUtils.js.map +1 -0
  325. package/dist/utils/StringUtils.d.ts +54 -0
  326. package/dist/utils/StringUtils.d.ts.map +1 -0
  327. package/dist/utils/StringUtils.js +129 -0
  328. package/dist/utils/StringUtils.js.map +1 -0
  329. package/dist/utils/TimeUtils.d.ts +28 -0
  330. package/dist/utils/TimeUtils.d.ts.map +1 -0
  331. package/dist/utils/TimeUtils.js +53 -0
  332. package/dist/utils/TimeUtils.js.map +1 -0
  333. package/package.json +76 -0
@@ -0,0 +1,232 @@
1
+ /*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
2
+ 'use strict';
3
+ import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
4
+ import { BaseClient } from './BaseClient.js';
5
+ import { ClientAuthError } from '../error/ClientAuthError.js';
6
+ import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
7
+ import { GrantType, Constants } from '../utils/Constants.js';
8
+ import { TimeUtils } from '../utils/TimeUtils.js';
9
+ import { ResponseHandler } from '../response/ResponseHandler.js';
10
+ import { StringUtils } from '../utils/StringUtils.js';
11
+ import { ServerError } from '../error/ServerError.js';
12
+
13
+ /*
14
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15
+ * Licensed under the MIT License.
16
+ */
17
+ /**
18
+ * OAuth2.0 Device code client
19
+ */
20
+ var DeviceCodeClient = /** @class */ (function (_super) {
21
+ __extends(DeviceCodeClient, _super);
22
+ function DeviceCodeClient(configuration) {
23
+ return _super.call(this, configuration) || this;
24
+ }
25
+ /**
26
+ * Gets device code from device code endpoint, calls back to with device code response, and
27
+ * polls token endpoint to exchange device code for tokens
28
+ * @param request
29
+ */
30
+ DeviceCodeClient.prototype.acquireToken = function (request) {
31
+ return __awaiter(this, void 0, void 0, function () {
32
+ var deviceCodeResponse, reqTimestamp, response, responseHandler;
33
+ return __generator(this, function (_a) {
34
+ switch (_a.label) {
35
+ case 0: return [4 /*yield*/, this.getDeviceCode(request)];
36
+ case 1:
37
+ deviceCodeResponse = _a.sent();
38
+ request.deviceCodeCallback(deviceCodeResponse);
39
+ reqTimestamp = TimeUtils.nowSeconds();
40
+ return [4 /*yield*/, this.acquireTokenWithDeviceCode(request, deviceCodeResponse)];
41
+ case 2:
42
+ response = _a.sent();
43
+ responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
44
+ // Validate response. This function throws a server error if an error is returned by the server.
45
+ responseHandler.validateTokenResponse(response);
46
+ return [4 /*yield*/, responseHandler.handleServerTokenResponse(response, this.authority, reqTimestamp, request)];
47
+ case 3: return [2 /*return*/, _a.sent()];
48
+ }
49
+ });
50
+ });
51
+ };
52
+ /**
53
+ * Creates device code request and executes http GET
54
+ * @param request
55
+ */
56
+ DeviceCodeClient.prototype.getDeviceCode = function (request) {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ var queryString, headers, thumbprint;
59
+ return __generator(this, function (_a) {
60
+ queryString = this.createQueryString(request);
61
+ headers = this.createTokenRequestHeaders();
62
+ thumbprint = {
63
+ clientId: this.config.authOptions.clientId,
64
+ authority: request.authority,
65
+ scopes: request.scopes,
66
+ claims: request.claims,
67
+ authenticationScheme: request.authenticationScheme,
68
+ resourceRequestMethod: request.resourceRequestMethod,
69
+ resourceRequestUri: request.resourceRequestUri,
70
+ shrClaims: request.shrClaims,
71
+ sshKid: request.sshKid
72
+ };
73
+ return [2 /*return*/, this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint)];
74
+ });
75
+ });
76
+ };
77
+ /**
78
+ * Executes POST request to device code endpoint
79
+ * @param deviceCodeEndpoint
80
+ * @param queryString
81
+ * @param headers
82
+ */
83
+ DeviceCodeClient.prototype.executePostRequestToDeviceCodeEndpoint = function (deviceCodeEndpoint, queryString, headers, thumbprint) {
84
+ return __awaiter(this, void 0, void 0, function () {
85
+ var _a, userCode, deviceCode, verificationUri, expiresIn, interval, message;
86
+ return __generator(this, function (_b) {
87
+ switch (_b.label) {
88
+ case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, deviceCodeEndpoint, {
89
+ body: queryString,
90
+ headers: headers,
91
+ proxyUrl: this.config.systemOptions.proxyUrl
92
+ })];
93
+ case 1:
94
+ _a = (_b.sent()).body, userCode = _a.user_code, deviceCode = _a.device_code, verificationUri = _a.verification_uri, expiresIn = _a.expires_in, interval = _a.interval, message = _a.message;
95
+ return [2 /*return*/, {
96
+ userCode: userCode,
97
+ deviceCode: deviceCode,
98
+ verificationUri: verificationUri,
99
+ expiresIn: expiresIn,
100
+ interval: interval,
101
+ message: message
102
+ }];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ /**
108
+ * Create device code endpoint query parameters and returns string
109
+ */
110
+ DeviceCodeClient.prototype.createQueryString = function (request) {
111
+ var parameterBuilder = new RequestParameterBuilder();
112
+ parameterBuilder.addScopes(request.scopes);
113
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
114
+ if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
115
+ parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
116
+ }
117
+ return parameterBuilder.createQueryString();
118
+ };
119
+ /**
120
+ * Breaks the polling with specific conditions.
121
+ * @param request CommonDeviceCodeRequest
122
+ * @param deviceCodeResponse DeviceCodeResponse
123
+ */
124
+ DeviceCodeClient.prototype.continuePolling = function (deviceCodeExpirationTime, userSpecifiedTimeout, userSpecifiedCancelFlag) {
125
+ if (userSpecifiedCancelFlag) {
126
+ this.logger.error("Token request cancelled by setting DeviceCodeRequest.cancel = true");
127
+ throw ClientAuthError.createDeviceCodeCancelledError();
128
+ }
129
+ else if (userSpecifiedTimeout && userSpecifiedTimeout < deviceCodeExpirationTime && TimeUtils.nowSeconds() > userSpecifiedTimeout) {
130
+ this.logger.error("User defined timeout for device code polling reached. The timeout was set for " + userSpecifiedTimeout);
131
+ throw ClientAuthError.createUserTimeoutReachedError();
132
+ }
133
+ else if (TimeUtils.nowSeconds() > deviceCodeExpirationTime) {
134
+ if (userSpecifiedTimeout) {
135
+ this.logger.verbose("User specified timeout ignored as the device code has expired before the timeout elapsed. The user specified timeout was set for " + userSpecifiedTimeout);
136
+ }
137
+ this.logger.error("Device code expired. Expiration time of device code was " + deviceCodeExpirationTime);
138
+ throw ClientAuthError.createDeviceCodeExpiredError();
139
+ }
140
+ return true;
141
+ };
142
+ /**
143
+ * Creates token request with device code response and polls token endpoint at interval set by the device code
144
+ * response
145
+ * @param request
146
+ * @param deviceCodeResponse
147
+ */
148
+ DeviceCodeClient.prototype.acquireTokenWithDeviceCode = function (request, deviceCodeResponse) {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ var requestBody, headers, userSpecifiedTimeout, deviceCodeExpirationTime, pollingIntervalMilli, thumbprint, response;
151
+ return __generator(this, function (_a) {
152
+ switch (_a.label) {
153
+ case 0:
154
+ requestBody = this.createTokenRequestBody(request, deviceCodeResponse);
155
+ headers = this.createTokenRequestHeaders();
156
+ userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;
157
+ deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;
158
+ pollingIntervalMilli = deviceCodeResponse.interval * 1000;
159
+ _a.label = 1;
160
+ case 1:
161
+ if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/, 8];
162
+ thumbprint = {
163
+ clientId: this.config.authOptions.clientId,
164
+ authority: request.authority,
165
+ scopes: request.scopes,
166
+ claims: request.claims,
167
+ authenticationScheme: request.authenticationScheme,
168
+ resourceRequestMethod: request.resourceRequestMethod,
169
+ resourceRequestUri: request.resourceRequestUri,
170
+ shrClaims: request.shrClaims,
171
+ sshKid: request.sshKid
172
+ };
173
+ return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
174
+ case 2:
175
+ response = _a.sent();
176
+ if (!(response.body && response.body.error)) return [3 /*break*/, 6];
177
+ if (!(response.body.error === Constants.AUTHORIZATION_PENDING)) return [3 /*break*/, 4];
178
+ this.logger.info("Authorization pending. Continue polling.");
179
+ return [4 /*yield*/, TimeUtils.delay(pollingIntervalMilli)];
180
+ case 3:
181
+ _a.sent();
182
+ return [3 /*break*/, 5];
183
+ case 4:
184
+ // for any other error, throw
185
+ this.logger.info("Unexpected error in polling from the server");
186
+ throw ServerError.createPostRequestFailed(response.body.error);
187
+ case 5: return [3 /*break*/, 7];
188
+ case 6:
189
+ this.logger.verbose("Authorization completed successfully. Polling stopped.");
190
+ return [2 /*return*/, response.body];
191
+ case 7: return [3 /*break*/, 1];
192
+ case 8:
193
+ /*
194
+ * The above code should've thrown by this point, but to satisfy TypeScript,
195
+ * and in the rare case the conditionals in continuePolling() may not catch everything...
196
+ */
197
+ this.logger.error("Polling stopped for unknown reasons.");
198
+ throw ClientAuthError.createDeviceCodeUnknownError();
199
+ }
200
+ });
201
+ });
202
+ };
203
+ /**
204
+ * Creates query parameters and converts to string.
205
+ * @param request
206
+ * @param deviceCodeResponse
207
+ */
208
+ DeviceCodeClient.prototype.createTokenRequestBody = function (request, deviceCodeResponse) {
209
+ var requestParameters = new RequestParameterBuilder();
210
+ requestParameters.addScopes(request.scopes);
211
+ requestParameters.addClientId(this.config.authOptions.clientId);
212
+ requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);
213
+ requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
214
+ var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
215
+ requestParameters.addCorrelationId(correlationId);
216
+ requestParameters.addClientInfo();
217
+ requestParameters.addLibraryInfo(this.config.libraryInfo);
218
+ requestParameters.addApplicationTelemetry(this.config.telemetry.application);
219
+ requestParameters.addThrottling();
220
+ if (this.serverTelemetryManager) {
221
+ requestParameters.addServerTelemetry(this.serverTelemetryManager);
222
+ }
223
+ if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
224
+ requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
225
+ }
226
+ return requestParameters.createQueryString();
227
+ };
228
+ return DeviceCodeClient;
229
+ }(BaseClient));
230
+
231
+ export { DeviceCodeClient };
232
+ //# sourceMappingURL=DeviceCodeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceCodeClient.js","sources":["../../src/client/DeviceCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DeviceCodeResponse, ServerDeviceCodeResponse } from \"../response/DeviceCodeResponse\";\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonDeviceCodeRequest } from \"../request/CommonDeviceCodeRequest\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { Constants, GrantType } from \"../utils/Constants\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { ServerError } from \"../error/ServerError\";\n\n/**\n * OAuth2.0 Device code client\n */\nexport class DeviceCodeClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Gets device code from device code endpoint, calls back to with device code response, and\n * polls token endpoint to exchange device code for tokens\n * @param request\n */\n public async acquireToken(request: CommonDeviceCodeRequest): Promise<AuthenticationResult | null> {\n const deviceCodeResponse: DeviceCodeResponse = await this.getDeviceCode(request);\n request.deviceCodeCallback(deviceCodeResponse);\n const reqTimestamp = TimeUtils.nowSeconds();\n const response: ServerAuthorizationTokenResponse = await this.acquireTokenWithDeviceCode(\n request,\n deviceCodeResponse);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n // Validate response. This function throws a server error if an error is returned by the server.\n responseHandler.validateTokenResponse(response);\n return await responseHandler.handleServerTokenResponse(\n response,\n this.authority,\n reqTimestamp,\n request\n );\n }\n\n /**\n * Creates device code request and executes http GET\n * @param request\n */\n private async getDeviceCode(request: CommonDeviceCodeRequest): Promise<DeviceCodeResponse> {\n const queryString = this.createQueryString(request);\n const headers = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n\n return this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint);\n }\n\n /**\n * Executes POST request to device code endpoint\n * @param deviceCodeEndpoint\n * @param queryString\n * @param headers\n */\n private async executePostRequestToDeviceCodeEndpoint(\n deviceCodeEndpoint: string,\n queryString: string,\n headers: Record<string, string>,\n thumbprint: RequestThumbprint): Promise<DeviceCodeResponse> {\n\n const {\n body: {\n user_code: userCode,\n device_code: deviceCode,\n verification_uri: verificationUri,\n expires_in: expiresIn,\n interval,\n message\n }\n } = await this.networkManager.sendPostRequest<ServerDeviceCodeResponse>(\n thumbprint,\n deviceCodeEndpoint,\n {\n body: queryString,\n headers: headers,\n proxyUrl: this.config.systemOptions.proxyUrl\n });\n\n return {\n userCode,\n deviceCode,\n verificationUri,\n expiresIn,\n interval,\n message\n };\n }\n\n /**\n * Create device code endpoint query parameters and returns string\n */\n private createQueryString(request: CommonDeviceCodeRequest): string {\n\n const parameterBuilder: RequestParameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addScopes(request.scopes);\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Breaks the polling with specific conditions.\n * @param request CommonDeviceCodeRequest\n * @param deviceCodeResponse DeviceCodeResponse\n */\n private continuePolling(\n deviceCodeExpirationTime: number,\n userSpecifiedTimeout?: number,\n userSpecifiedCancelFlag?: boolean,\n ): boolean {\n if (userSpecifiedCancelFlag) {\n this.logger.error(\"Token request cancelled by setting DeviceCodeRequest.cancel = true\");\n throw ClientAuthError.createDeviceCodeCancelledError();\n } else if (userSpecifiedTimeout && userSpecifiedTimeout < deviceCodeExpirationTime && TimeUtils.nowSeconds() > userSpecifiedTimeout) {\n this.logger.error(`User defined timeout for device code polling reached. The timeout was set for ${userSpecifiedTimeout}`);\n throw ClientAuthError.createUserTimeoutReachedError();\n } else if (TimeUtils.nowSeconds() > deviceCodeExpirationTime) {\n if (userSpecifiedTimeout) {\n this.logger.verbose(`User specified timeout ignored as the device code has expired before the timeout elapsed. The user specified timeout was set for ${userSpecifiedTimeout}`);\n }\n this.logger.error(`Device code expired. Expiration time of device code was ${deviceCodeExpirationTime}`);\n throw ClientAuthError.createDeviceCodeExpiredError();\n }\n return true;\n }\n\n /**\n * Creates token request with device code response and polls token endpoint at interval set by the device code\n * response\n * @param request\n * @param deviceCodeResponse\n */\n private async acquireTokenWithDeviceCode(\n request: CommonDeviceCodeRequest,\n deviceCodeResponse: DeviceCodeResponse): Promise<ServerAuthorizationTokenResponse> {\n\n const requestBody = this.createTokenRequestBody(request, deviceCodeResponse);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n\n const userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;\n const deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;\n const pollingIntervalMilli = deviceCodeResponse.interval * 1000;\n\n /*\n * Poll token endpoint while (device code is not expired AND operation has not been cancelled by\n * setting CancellationToken.cancel = true). POST request is sent at interval set by pollingIntervalMilli\n */\n while (this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n\n const response = await this.executePostToTokenEndpoint(\n this.authority.tokenEndpoint,\n requestBody,\n headers,\n thumbprint);\n\n if (response.body && response.body.error) {\n // user authorization is pending. Sleep for polling interval and try again\n if(response.body.error === Constants.AUTHORIZATION_PENDING) {\n this.logger.info(\"Authorization pending. Continue polling.\");\n await TimeUtils.delay(pollingIntervalMilli);\n } else {\n // for any other error, throw\n this.logger.info(\"Unexpected error in polling from the server\");\n throw ServerError.createPostRequestFailed(response.body.error);\n }\n } else {\n this.logger.verbose(\"Authorization completed successfully. Polling stopped.\");\n return response.body;\n }\n }\n\n /*\n * The above code should've thrown by this point, but to satisfy TypeScript,\n * and in the rare case the conditionals in continuePolling() may not catch everything...\n */\n this.logger.error(\"Polling stopped for unknown reasons.\");\n throw ClientAuthError.createDeviceCodeUnknownError();\n }\n\n /**\n * Creates query parameters and converts to string.\n * @param request\n * @param deviceCodeResponse\n */\n private createTokenRequestBody(request: CommonDeviceCodeRequest, deviceCodeResponse: DeviceCodeResponse): string {\n\n const requestParameters: RequestParameterBuilder = new RequestParameterBuilder();\n\n requestParameters.addScopes(request.scopes);\n requestParameters.addClientId(this.config.authOptions.clientId);\n requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);\n requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n requestParameters.addCorrelationId(correlationId);\n requestParameters.addClientInfo();\n requestParameters.addLibraryInfo(this.config.libraryInfo);\n requestParameters.addApplicationTelemetry(this.config.telemetry.application);\n requestParameters.addThrottling();\n \n if (this.serverTelemetryManager) {\n requestParameters.addServerTelemetry(this.serverTelemetryManager);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n return requestParameters.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;AAGG;AAiBH;;AAEG;AACH,IAAA,gBAAA,kBAAA,UAAA,MA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Aa,EAAE,CAAC;QAClC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1D,iBAAiB,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC7E,iBAAiB,CAAC,aAAa,EAAE,CAAC;QAElC,IAAI,IAAI,CAAC,sBAAsB,EAAE;AAC7B,YAAA,iBAAiB,CAAC,kBAAkB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AACrE,SAAA;AAED,QAAA,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;AAChJ,YAAA,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAC3F,SAAA;AACD,QAAA,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;KAChD,CAAA;IACL,OAAC,gBAAA,CAAA;AAAD,CA5OA,CAAsC,UAAU,CA4O/C;;;;"}
@@ -0,0 +1,51 @@
1
+ import { ClientConfiguration } from "../config/ClientConfiguration";
2
+ import { BaseClient } from "./BaseClient";
3
+ import { AuthenticationResult } from "../response/AuthenticationResult";
4
+ import { CommonOnBehalfOfRequest } from "../request/CommonOnBehalfOfRequest";
5
+ /**
6
+ * On-Behalf-Of client
7
+ */
8
+ export declare class OnBehalfOfClient extends BaseClient {
9
+ private scopeSet;
10
+ private userAssertionHash;
11
+ constructor(configuration: ClientConfiguration);
12
+ /**
13
+ * Public API to acquire tokens with on behalf of flow
14
+ * @param request
15
+ */
16
+ acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null>;
17
+ /**
18
+ * look up cache for tokens
19
+ * Find idtoken in the cache
20
+ * Find accessToken based on user assertion and account info in the cache
21
+ * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
22
+ * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
23
+ * @param request
24
+ */
25
+ private getCachedAuthenticationResult;
26
+ /**
27
+ * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
28
+ * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
29
+ * @param request
30
+ */
31
+ private readIdTokenFromCacheForOBO;
32
+ /**
33
+ * Fetches the cached access token based on incoming assertion
34
+ * @param clientId
35
+ * @param request
36
+ * @param userAssertionHash
37
+ */
38
+ private readAccessTokenFromCacheForOBO;
39
+ /**
40
+ * Make a network call to the server requesting credentials
41
+ * @param request
42
+ * @param authority
43
+ */
44
+ private executeTokenRequest;
45
+ /**
46
+ * generate a server request in accepable format
47
+ * @param request
48
+ */
49
+ private createTokenRequestBody;
50
+ }
51
+ //# sourceMappingURL=OnBehalfOfClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnBehalfOfClient.d.ts","sourceRoot":"","sources":["../../src/client/OnBehalfOfClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAW7E;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAE5C,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,aAAa,EAAE,mBAAmB;IAI9C;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAkBjG;;;;;;;OAOG;YACW,6BAA6B;IAsD3C;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAmBlC;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B;IAgCtC;;;;OAIG;YACW,mBAAmB;IA0CjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;CAsCjC"}
@@ -0,0 +1,244 @@
1
+ /*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
2
+ 'use strict';
3
+ import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
4
+ import { BaseClient } from './BaseClient.js';
5
+ import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
6
+ import { ScopeSet } from '../request/ScopeSet.js';
7
+ import { AuthenticationScheme, CredentialType, GrantType, AADServerParamKeys, CacheOutcome, Constants } from '../utils/Constants.js';
8
+ import { ResponseHandler } from '../response/ResponseHandler.js';
9
+ import { TimeUtils } from '../utils/TimeUtils.js';
10
+ import { AuthToken } from '../account/AuthToken.js';
11
+ import { ClientAuthError } from '../error/ClientAuthError.js';
12
+
13
+ /*
14
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15
+ * Licensed under the MIT License.
16
+ */
17
+ /**
18
+ * On-Behalf-Of client
19
+ */
20
+ var OnBehalfOfClient = /** @class */ (function (_super) {
21
+ __extends(OnBehalfOfClient, _super);
22
+ function OnBehalfOfClient(configuration) {
23
+ return _super.call(this, configuration) || this;
24
+ }
25
+ /**
26
+ * Public API to acquire tokens with on behalf of flow
27
+ * @param request
28
+ */
29
+ OnBehalfOfClient.prototype.acquireToken = function (request) {
30
+ return __awaiter(this, void 0, void 0, function () {
31
+ var _a;
32
+ return __generator(this, function (_b) {
33
+ switch (_b.label) {
34
+ case 0:
35
+ this.scopeSet = new ScopeSet(request.scopes || []);
36
+ // generate the user_assertion_hash for OBOAssertion
37
+ _a = this;
38
+ return [4 /*yield*/, this.cryptoUtils.hashString(request.oboAssertion)];
39
+ case 1:
40
+ // generate the user_assertion_hash for OBOAssertion
41
+ _a.userAssertionHash = _b.sent();
42
+ if (!request.skipCache) return [3 /*break*/, 3];
43
+ return [4 /*yield*/, this.executeTokenRequest(request, this.authority, this.userAssertionHash)];
44
+ case 2: return [2 /*return*/, _b.sent()];
45
+ case 3:
46
+ _b.trys.push([3, 5, , 7]);
47
+ return [4 /*yield*/, this.getCachedAuthenticationResult(request)];
48
+ case 4: return [2 /*return*/, _b.sent()];
49
+ case 5:
50
+ _b.sent();
51
+ return [4 /*yield*/, this.executeTokenRequest(request, this.authority, this.userAssertionHash)];
52
+ case 6:
53
+ // Any failure falls back to interactive request, once we implement distributed cache, we plan to handle `createRefreshRequiredError` to refresh using the RT
54
+ return [2 /*return*/, _b.sent()];
55
+ case 7: return [2 /*return*/];
56
+ }
57
+ });
58
+ });
59
+ };
60
+ /**
61
+ * look up cache for tokens
62
+ * Find idtoken in the cache
63
+ * Find accessToken based on user assertion and account info in the cache
64
+ * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires
65
+ * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session
66
+ * @param request
67
+ */
68
+ OnBehalfOfClient.prototype.getCachedAuthenticationResult = function (request) {
69
+ var _a, _b;
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var cachedAccessToken, cachedIdToken, idTokenObject, cachedAccount, localAccountId, accountInfo;
72
+ return __generator(this, function (_c) {
73
+ switch (_c.label) {
74
+ case 0:
75
+ cachedAccessToken = this.readAccessTokenFromCacheForOBO(this.config.authOptions.clientId, request);
76
+ if (!cachedAccessToken) {
77
+ // Must refresh due to non-existent access_token.
78
+ (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
79
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
80
+ throw ClientAuthError.createRefreshRequiredError();
81
+ }
82
+ else if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
83
+ // Access token expired, will need to renewed
84
+ (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
85
+ this.logger.info("OnbehalfofFlow:getCachedAuthenticationResult - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
86
+ throw ClientAuthError.createRefreshRequiredError();
87
+ }
88
+ cachedIdToken = this.readIdTokenFromCacheForOBO(request, cachedAccessToken.homeAccountId);
89
+ cachedAccount = null;
90
+ if (cachedIdToken) {
91
+ idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);
92
+ localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;
93
+ accountInfo = {
94
+ homeAccountId: cachedIdToken.homeAccountId,
95
+ environment: cachedIdToken.environment,
96
+ tenantId: cachedIdToken.realm,
97
+ username: Constants.EMPTY_STRING,
98
+ localAccountId: localAccountId || Constants.EMPTY_STRING
99
+ };
100
+ cachedAccount = this.cacheManager.readAccountFromCache(accountInfo);
101
+ }
102
+ // increment telemetry cache hit counter
103
+ if (this.config.serverTelemetryManager) {
104
+ this.config.serverTelemetryManager.incrementCacheHits();
105
+ }
106
+ return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, {
107
+ account: cachedAccount,
108
+ accessToken: cachedAccessToken,
109
+ idToken: cachedIdToken,
110
+ refreshToken: null,
111
+ appMetadata: null
112
+ }, true, request, idTokenObject)];
113
+ case 1: return [2 /*return*/, _c.sent()];
114
+ }
115
+ });
116
+ });
117
+ };
118
+ /**
119
+ * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager
120
+ * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service
121
+ * @param request
122
+ */
123
+ OnBehalfOfClient.prototype.readIdTokenFromCacheForOBO = function (request, atHomeAccountId) {
124
+ var idTokenFilter = {
125
+ homeAccountId: atHomeAccountId,
126
+ environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
127
+ credentialType: CredentialType.ID_TOKEN,
128
+ clientId: this.config.authOptions.clientId,
129
+ realm: this.authority.tenant
130
+ };
131
+ var credentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);
132
+ var idTokens = Object.keys(credentialCache.idTokens).map(function (key) { return credentialCache.idTokens[key]; });
133
+ // When acquiring a token on behalf of an application, there might not be an id token in the cache
134
+ if (idTokens.length < 1) {
135
+ return null;
136
+ }
137
+ return idTokens[0];
138
+ };
139
+ /**
140
+ * Fetches the cached access token based on incoming assertion
141
+ * @param clientId
142
+ * @param request
143
+ * @param userAssertionHash
144
+ */
145
+ OnBehalfOfClient.prototype.readAccessTokenFromCacheForOBO = function (clientId, request) {
146
+ var authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
147
+ /*
148
+ * Distinguish between Bearer and PoP/SSH token cache types
149
+ * Cast to lowercase to handle "bearer" from ADFS
150
+ */
151
+ var credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
152
+ var accessTokenFilter = {
153
+ credentialType: credentialType,
154
+ clientId: clientId,
155
+ target: this.scopeSet.printScopesLowerCase(),
156
+ tokenType: authScheme,
157
+ keyId: request.sshKid,
158
+ requestedClaimsHash: request.requestedClaimsHash,
159
+ userAssertionHash: this.userAssertionHash
160
+ };
161
+ var credentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);
162
+ var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
163
+ var numAccessTokens = accessTokens.length;
164
+ if (numAccessTokens < 1) {
165
+ return null;
166
+ }
167
+ else if (numAccessTokens > 1) {
168
+ throw ClientAuthError.createMultipleMatchingTokensInCacheError();
169
+ }
170
+ return accessTokens[0];
171
+ };
172
+ /**
173
+ * Make a network call to the server requesting credentials
174
+ * @param request
175
+ * @param authority
176
+ */
177
+ OnBehalfOfClient.prototype.executeTokenRequest = function (request, authority, userAssertionHash) {
178
+ return __awaiter(this, void 0, void 0, function () {
179
+ var requestBody, headers, thumbprint, reqTimestamp, response, responseHandler, tokenResponse;
180
+ return __generator(this, function (_a) {
181
+ switch (_a.label) {
182
+ case 0:
183
+ requestBody = this.createTokenRequestBody(request);
184
+ headers = this.createTokenRequestHeaders();
185
+ thumbprint = {
186
+ clientId: this.config.authOptions.clientId,
187
+ authority: request.authority,
188
+ scopes: request.scopes,
189
+ claims: request.claims,
190
+ authenticationScheme: request.authenticationScheme,
191
+ resourceRequestMethod: request.resourceRequestMethod,
192
+ resourceRequestUri: request.resourceRequestUri,
193
+ shrClaims: request.shrClaims,
194
+ sshKid: request.sshKid
195
+ };
196
+ reqTimestamp = TimeUtils.nowSeconds();
197
+ return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
198
+ case 1:
199
+ response = _a.sent();
200
+ responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
201
+ responseHandler.validateTokenResponse(response.body);
202
+ return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, userAssertionHash)];
203
+ case 2:
204
+ tokenResponse = _a.sent();
205
+ return [2 /*return*/, tokenResponse];
206
+ }
207
+ });
208
+ });
209
+ };
210
+ /**
211
+ * generate a server request in accepable format
212
+ * @param request
213
+ */
214
+ OnBehalfOfClient.prototype.createTokenRequestBody = function (request) {
215
+ var parameterBuilder = new RequestParameterBuilder();
216
+ parameterBuilder.addClientId(this.config.authOptions.clientId);
217
+ parameterBuilder.addScopes(request.scopes);
218
+ parameterBuilder.addGrantType(GrantType.JWT_BEARER);
219
+ parameterBuilder.addClientInfo();
220
+ parameterBuilder.addLibraryInfo(this.config.libraryInfo);
221
+ parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
222
+ parameterBuilder.addThrottling();
223
+ if (this.serverTelemetryManager) {
224
+ parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
225
+ }
226
+ var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
227
+ parameterBuilder.addCorrelationId(correlationId);
228
+ parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);
229
+ parameterBuilder.addOboAssertion(request.oboAssertion);
230
+ if (this.config.clientCredentials.clientSecret) {
231
+ parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
232
+ }
233
+ if (this.config.clientCredentials.clientAssertion) {
234
+ var clientAssertion = this.config.clientCredentials.clientAssertion;
235
+ parameterBuilder.addClientAssertion(clientAssertion.assertion);
236
+ parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
237
+ }
238
+ return parameterBuilder.createQueryString();
239
+ };
240
+ return OnBehalfOfClient;
241
+ }(BaseClient));
242
+
243
+ export { OnBehalfOfClient };
244
+ //# sourceMappingURL=OnBehalfOfClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnBehalfOfClient.js","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome, AuthenticationScheme } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonOnBehalfOfRequest } from \"../request/CommonOnBehalfOfRequest\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { IdTokenEntity } from \"../cache/entities/IdTokenEntity\";\nimport { AccountEntity } from \"../cache/entities/AccountEntity\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { AccountInfo } from \"../account/AccountInfo\";\n\n/**\n * On-Behalf-Of client\n */\nexport class OnBehalfOfClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n private userAssertionHash: string;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Public API to acquire tokens with on behalf of flow\n * @param request\n */\n public async acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n // generate the user_assertion_hash for OBOAssertion\n this.userAssertionHash = await this.cryptoUtils.hashString(request.oboAssertion);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority, this.userAssertionHash);\n }\n\n try {\n return await this.getCachedAuthenticationResult(request);\n } catch (e) {\n // Any failure falls back to interactive request, once we implement distributed cache, we plan to handle `createRefreshRequiredError` to refresh using the RT\n return await this.executeTokenRequest(request, this.authority, this.userAssertionHash);\n }\n }\n\n /**\n * look up cache for tokens\n * Find idtoken in the cache\n * Find accessToken based on user assertion and account info in the cache\n * Please note we are not yet supported OBO tokens refreshed with long lived RT. User will have to send a new assertion if the current access token expires\n * This is to prevent security issues when the assertion changes over time, however, longlived RT helps retaining the session\n * @param request\n */\n private async getCachedAuthenticationResult(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n\n // look in the cache for the access_token which matches the incoming_assertion\n const cachedAccessToken = this.readAccessTokenFromCacheForOBO(this.config.authOptions.clientId, request);\n if (!cachedAccessToken) {\n // Must refresh due to non-existent access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.\");\n throw ClientAuthError.createRefreshRequiredError();\n } else if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n // Access token expired, will need to renewed\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n this.logger.info(`OnbehalfofFlow:getCachedAuthenticationResult - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);\n throw ClientAuthError.createRefreshRequiredError();\n }\n\n // fetch the idToken from cache\n const cachedIdToken = this.readIdTokenFromCacheForOBO(request, cachedAccessToken.homeAccountId);\n let idTokenObject: AuthToken | undefined;\n let cachedAccount: AccountEntity | null = null;\n if (cachedIdToken) {\n idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);\n const localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;\n const accountInfo: AccountInfo = {\n homeAccountId: cachedIdToken.homeAccountId,\n environment: cachedIdToken.environment,\n tenantId: cachedIdToken.realm,\n username: Constants.EMPTY_STRING,\n localAccountId: localAccountId || Constants.EMPTY_STRING\n };\n\n cachedAccount = this.cacheManager.readAccountFromCache(accountInfo);\n }\n\n // increment telemetry cache hit counter\n if (this.config.serverTelemetryManager) {\n this.config.serverTelemetryManager.incrementCacheHits();\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: cachedAccount,\n accessToken: cachedAccessToken,\n idToken: cachedIdToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request,\n idTokenObject);\n }\n\n /**\n * read idtoken from cache, this is a specific implementation for OBO as the requirements differ from a generic lookup in the cacheManager\n * Certain use cases of OBO flow do not expect an idToken in the cache/or from the service\n * @param request\n */\n private readIdTokenFromCacheForOBO(request: CommonOnBehalfOfRequest, atHomeAccountId: string): IdTokenEntity | null {\n\n const idTokenFilter: CredentialFilter = {\n homeAccountId: atHomeAccountId,\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ID_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\n const idTokens = Object.keys(credentialCache.idTokens).map(key => credentialCache.idTokens[key]);\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\n if (idTokens.length < 1) {\n return null;\n }\n return idTokens[0] as IdTokenEntity;\n }\n\n /**\n * Fetches the cached access token based on incoming assertion\n * @param clientId\n * @param request\n * @param userAssertionHash\n */\n private readAccessTokenFromCacheForOBO(clientId: string, request: CommonOnBehalfOfRequest) {\n const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;\n /*\n * Distinguish between Bearer and PoP/SSH token cache types\n * Cast to lowercase to handle \"bearer\" from ADFS\n */\n const credentialType = (authScheme && authScheme.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;\n\n const accessTokenFilter: CredentialFilter = {\n credentialType: credentialType,\n clientId,\n target: this.scopeSet.printScopesLowerCase(),\n tokenType: authScheme,\n keyId: request.sshKid,\n requestedClaimsHash: request.requestedClaimsHash,\n userAssertionHash: this.userAssertionHash\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n\n const accessTokens = Object.keys(credentialCache.accessTokens).map((key) => credentialCache.accessTokens[key]);\n\n const numAccessTokens = accessTokens.length;\n if (numAccessTokens < 1) {\n return null;\n } else if (numAccessTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Make a network call to the server requesting credentials\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonOnBehalfOfRequest, authority: Authority, userAssertionHash: string)\n : Promise<AuthenticationResult | null> {\n\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = await responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request,\n undefined,\n userAssertionHash\n );\n\n return tokenResponse;\n }\n\n /**\n * generate a server request in accepable format\n * @param request\n */\n private createTokenRequestBody(request: CommonOnBehalfOfRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\n\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n parameterBuilder.addThrottling();\n\n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\n\n parameterBuilder.addOboAssertion(request.oboAssertion);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;AAGG;AAqBH;;AAEG;AACH,IAAA,gBAAA,kBAAA,UAAA,MAAA,EAAA;IAAsC,SAAU,CAAA,gBAAA,EAAA,MAAA,CAAA,CAAA;AAK5C,IAAA,SAAA,gBAAA,CAAY,aAAkC,EAAA;AAC1C,QAAA,OAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAM,aAAa,CAAC,IAAA,IAAA,CAAA;KACvB;AAED;;;AAGG;IACU,gBAAY,CAAA,SAAA,CAAA,YAAA,GAAzB,UAA0B,OAAgC,EAAA;;;;;;AACtD,wBAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;;AAGnD,wBAAA,EAAA,GAAA,IAAI,CAAA;wBAAqB,OAAM,CAAA,CAAA,YAAA,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA,CAAA;;;wBAAhF,EAAK,CAAA,iBAAiB,GAAG,EAAA,CAAA,IAAA,EAAuD,CAAC;6BAE7E,OAAO,CAAC,SAAS,EAAjB,OAAiB,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA;AACV,wBAAA,OAAA,CAAA,CAAA,YAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA,CAAA;AAAtF,oBAAA,KAAA,CAAA,EAAA,OAAA,CAAA,CAAA,aAAO,SAA+E,CAAC,CAAA;;;AAIhF,wBAAA,OAAA,CAAA,CAAA,YAAM,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAA,CAAA;AAAxD,oBAAA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