@azure/core-rest-pipeline 1.19.2-alpha.20250417.3 → 1.20.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 (433) hide show
  1. package/dist/browser/constants.js +1 -1
  2. package/dist/browser/constants.js.map +1 -1
  3. package/dist/browser/createPipelineFromOptions.js +2 -0
  4. package/dist/browser/createPipelineFromOptions.js.map +1 -1
  5. package/dist/browser/defaultHttpClient.d.ts +1 -1
  6. package/dist/browser/defaultHttpClient.js +21 -3
  7. package/dist/browser/defaultHttpClient.js.map +1 -0
  8. package/dist/browser/httpHeaders.js +2 -80
  9. package/dist/browser/httpHeaders.js.map +1 -1
  10. package/dist/browser/index.d.ts +1 -2
  11. package/dist/browser/index.js +1 -1
  12. package/dist/browser/index.js.map +1 -1
  13. package/dist/browser/interfaces.d.ts +11 -0
  14. package/dist/browser/interfaces.js.map +1 -1
  15. package/dist/browser/pipeline.js +2 -253
  16. package/dist/browser/pipeline.js.map +1 -1
  17. package/dist/browser/pipelineRequest.d.ts +11 -0
  18. package/dist/browser/pipelineRequest.js +5 -28
  19. package/dist/browser/pipelineRequest.js.map +1 -1
  20. package/dist/browser/policies/agentPolicy.js +3 -11
  21. package/dist/browser/policies/agentPolicy.js.map +1 -1
  22. package/dist/browser/policies/decompressResponsePolicy.d.ts +8 -4
  23. package/dist/browser/policies/decompressResponsePolicy.js +8 -7
  24. package/dist/browser/policies/decompressResponsePolicy.js.map +1 -0
  25. package/dist/browser/policies/defaultRetryPolicy.js +3 -12
  26. package/dist/browser/policies/defaultRetryPolicy.js.map +1 -1
  27. package/dist/browser/policies/exponentialRetryPolicy.js +3 -10
  28. package/dist/browser/policies/exponentialRetryPolicy.js.map +1 -1
  29. package/dist/browser/policies/formDataPolicy.js +3 -85
  30. package/dist/browser/policies/formDataPolicy.js.map +1 -1
  31. package/dist/browser/policies/logPolicy.js +3 -21
  32. package/dist/browser/policies/logPolicy.js.map +1 -1
  33. package/dist/browser/policies/multipartPolicy.js +12 -95
  34. package/dist/browser/policies/multipartPolicy.js.map +1 -1
  35. package/dist/browser/policies/proxyPolicy.d.ts +26 -2
  36. package/dist/browser/policies/proxyPolicy.js +26 -2
  37. package/dist/browser/policies/proxyPolicy.js.map +1 -0
  38. package/dist/browser/policies/redirectPolicy.js +3 -38
  39. package/dist/browser/policies/redirectPolicy.js.map +1 -1
  40. package/dist/browser/policies/retryPolicy.d.ts +59 -1
  41. package/dist/browser/policies/retryPolicy.js +5 -94
  42. package/dist/browser/policies/retryPolicy.js.map +1 -1
  43. package/dist/browser/policies/systemErrorRetryPolicy.js +3 -13
  44. package/dist/browser/policies/systemErrorRetryPolicy.js.map +1 -1
  45. package/dist/browser/policies/throttlingRetryPolicy.js +3 -11
  46. package/dist/browser/policies/throttlingRetryPolicy.js.map +1 -1
  47. package/dist/browser/policies/tlsPolicy.js +3 -11
  48. package/dist/browser/policies/tlsPolicy.js.map +1 -1
  49. package/dist/browser/policies/tracingPolicy.js +1 -1
  50. package/dist/browser/policies/tracingPolicy.js.map +1 -1
  51. package/dist/browser/policies/wrapAbortSignalLikePolicy.d.ts +10 -0
  52. package/dist/browser/policies/wrapAbortSignalLikePolicy.js +30 -0
  53. package/dist/browser/policies/wrapAbortSignalLikePolicy.js.map +1 -0
  54. package/dist/browser/restError.js +8 -27
  55. package/dist/browser/restError.js.map +1 -1
  56. package/dist/browser/util/file.d.ts +28 -2
  57. package/dist/browser/util/file.js +9 -4
  58. package/dist/browser/util/file.js.map +1 -1
  59. package/dist/browser/util/tokenCycler.js +1 -1
  60. package/dist/browser/util/tokenCycler.js.map +1 -1
  61. package/dist/browser/util/wrapAbortSignal.d.ts +12 -0
  62. package/dist/browser/util/wrapAbortSignal.js +31 -0
  63. package/dist/browser/util/wrapAbortSignal.js.map +1 -0
  64. package/dist/commonjs/constants.js +1 -1
  65. package/dist/commonjs/constants.js.map +1 -1
  66. package/dist/commonjs/createPipelineFromOptions.js +2 -0
  67. package/dist/commonjs/createPipelineFromOptions.js.map +1 -1
  68. package/dist/commonjs/defaultHttpClient.js +20 -2
  69. package/dist/commonjs/defaultHttpClient.js.map +1 -1
  70. package/dist/commonjs/httpHeaders.js +2 -80
  71. package/dist/commonjs/httpHeaders.js.map +1 -1
  72. package/dist/commonjs/index.d.ts +1 -2
  73. package/dist/commonjs/index.js.map +1 -1
  74. package/dist/commonjs/interfaces.d.ts +11 -0
  75. package/dist/commonjs/interfaces.js.map +1 -1
  76. package/dist/commonjs/pipeline.js +2 -253
  77. package/dist/commonjs/pipeline.js.map +1 -1
  78. package/dist/commonjs/pipelineRequest.d.ts +11 -0
  79. package/dist/commonjs/pipelineRequest.js +5 -28
  80. package/dist/commonjs/pipelineRequest.js.map +1 -1
  81. package/dist/commonjs/policies/agentPolicy.js +3 -11
  82. package/dist/commonjs/policies/agentPolicy.js.map +1 -1
  83. package/dist/commonjs/policies/decompressResponsePolicy.js +3 -11
  84. package/dist/commonjs/policies/decompressResponsePolicy.js.map +1 -1
  85. package/dist/commonjs/policies/defaultRetryPolicy.js +3 -12
  86. package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
  87. package/dist/commonjs/policies/exponentialRetryPolicy.js +3 -10
  88. package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
  89. package/dist/commonjs/policies/formDataPolicy.js +3 -85
  90. package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
  91. package/dist/commonjs/policies/logPolicy.js +3 -21
  92. package/dist/commonjs/policies/logPolicy.js.map +1 -1
  93. package/dist/commonjs/policies/multipartPolicy.js +12 -95
  94. package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
  95. package/dist/commonjs/policies/proxyPolicy.d.ts +0 -6
  96. package/dist/commonjs/policies/proxyPolicy.js +5 -169
  97. package/dist/commonjs/policies/proxyPolicy.js.map +1 -1
  98. package/dist/commonjs/policies/redirectPolicy.js +3 -38
  99. package/dist/commonjs/policies/redirectPolicy.js.map +1 -1
  100. package/dist/commonjs/policies/retryPolicy.d.ts +59 -1
  101. package/dist/commonjs/policies/retryPolicy.js +5 -94
  102. package/dist/commonjs/policies/retryPolicy.js.map +1 -1
  103. package/dist/commonjs/policies/systemErrorRetryPolicy.js +3 -13
  104. package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
  105. package/dist/commonjs/policies/throttlingRetryPolicy.js +3 -11
  106. package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
  107. package/dist/commonjs/policies/tlsPolicy.js +3 -11
  108. package/dist/commonjs/policies/tlsPolicy.js.map +1 -1
  109. package/dist/commonjs/policies/tracingPolicy.js +2 -2
  110. package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
  111. package/dist/commonjs/policies/wrapAbortSignalLikePolicy.d.ts +10 -0
  112. package/dist/commonjs/policies/wrapAbortSignalLikePolicy.js +34 -0
  113. package/dist/commonjs/policies/wrapAbortSignalLikePolicy.js.map +1 -0
  114. package/dist/commonjs/restError.js +8 -27
  115. package/dist/commonjs/restError.js.map +1 -1
  116. package/dist/commonjs/tsdoc-metadata.json +1 -1
  117. package/dist/commonjs/util/file.d.ts +28 -2
  118. package/dist/commonjs/util/file.js +10 -4
  119. package/dist/commonjs/util/file.js.map +1 -1
  120. package/dist/commonjs/util/tokenCycler.js +2 -2
  121. package/dist/commonjs/util/tokenCycler.js.map +1 -1
  122. package/dist/commonjs/util/wrapAbortSignal.d.ts +12 -0
  123. package/dist/commonjs/util/wrapAbortSignal.js +34 -0
  124. package/dist/commonjs/util/wrapAbortSignal.js.map +1 -0
  125. package/dist/esm/constants.js +1 -1
  126. package/dist/esm/constants.js.map +1 -1
  127. package/dist/esm/createPipelineFromOptions.js +2 -0
  128. package/dist/esm/createPipelineFromOptions.js.map +1 -1
  129. package/dist/esm/defaultHttpClient.js +20 -2
  130. package/dist/esm/defaultHttpClient.js.map +1 -1
  131. package/dist/esm/httpHeaders.js +2 -80
  132. package/dist/esm/httpHeaders.js.map +1 -1
  133. package/dist/esm/index.d.ts +1 -2
  134. package/dist/esm/index.js +1 -1
  135. package/dist/esm/index.js.map +1 -1
  136. package/dist/esm/interfaces.d.ts +11 -0
  137. package/dist/esm/interfaces.js.map +1 -1
  138. package/dist/esm/pipeline.js +2 -253
  139. package/dist/esm/pipeline.js.map +1 -1
  140. package/dist/esm/pipelineRequest.d.ts +11 -0
  141. package/dist/esm/pipelineRequest.js +5 -28
  142. package/dist/esm/pipelineRequest.js.map +1 -1
  143. package/dist/esm/policies/agentPolicy.js +3 -11
  144. package/dist/esm/policies/agentPolicy.js.map +1 -1
  145. package/dist/esm/policies/decompressResponsePolicy.js +3 -11
  146. package/dist/esm/policies/decompressResponsePolicy.js.map +1 -1
  147. package/dist/esm/policies/defaultRetryPolicy.js +3 -12
  148. package/dist/esm/policies/defaultRetryPolicy.js.map +1 -1
  149. package/dist/esm/policies/exponentialRetryPolicy.js +3 -10
  150. package/dist/esm/policies/exponentialRetryPolicy.js.map +1 -1
  151. package/dist/esm/policies/formDataPolicy.js +3 -85
  152. package/dist/esm/policies/formDataPolicy.js.map +1 -1
  153. package/dist/esm/policies/logPolicy.js +3 -21
  154. package/dist/esm/policies/logPolicy.js.map +1 -1
  155. package/dist/esm/policies/multipartPolicy.js +12 -95
  156. package/dist/esm/policies/multipartPolicy.js.map +1 -1
  157. package/dist/esm/policies/proxyPolicy.d.ts +0 -6
  158. package/dist/esm/policies/proxyPolicy.js +4 -167
  159. package/dist/esm/policies/proxyPolicy.js.map +1 -1
  160. package/dist/esm/policies/redirectPolicy.js +3 -38
  161. package/dist/esm/policies/redirectPolicy.js.map +1 -1
  162. package/dist/esm/policies/retryPolicy.d.ts +59 -1
  163. package/dist/esm/policies/retryPolicy.js +5 -94
  164. package/dist/esm/policies/retryPolicy.js.map +1 -1
  165. package/dist/esm/policies/systemErrorRetryPolicy.js +3 -13
  166. package/dist/esm/policies/systemErrorRetryPolicy.js.map +1 -1
  167. package/dist/esm/policies/throttlingRetryPolicy.js +3 -11
  168. package/dist/esm/policies/throttlingRetryPolicy.js.map +1 -1
  169. package/dist/esm/policies/tlsPolicy.js +3 -11
  170. package/dist/esm/policies/tlsPolicy.js.map +1 -1
  171. package/dist/esm/policies/tracingPolicy.js +1 -1
  172. package/dist/esm/policies/tracingPolicy.js.map +1 -1
  173. package/dist/esm/policies/wrapAbortSignalLikePolicy.d.ts +10 -0
  174. package/dist/esm/policies/wrapAbortSignalLikePolicy.js +30 -0
  175. package/dist/esm/policies/wrapAbortSignalLikePolicy.js.map +1 -0
  176. package/dist/esm/restError.js +8 -27
  177. package/dist/esm/restError.js.map +1 -1
  178. package/dist/esm/util/file.d.ts +28 -2
  179. package/dist/esm/util/file.js +9 -4
  180. package/dist/esm/util/file.js.map +1 -1
  181. package/dist/esm/util/tokenCycler.js +1 -1
  182. package/dist/esm/util/tokenCycler.js.map +1 -1
  183. package/dist/esm/util/wrapAbortSignal.d.ts +12 -0
  184. package/dist/esm/util/wrapAbortSignal.js +31 -0
  185. package/dist/esm/util/wrapAbortSignal.js.map +1 -0
  186. package/dist/react-native/constants.js +1 -1
  187. package/dist/react-native/constants.js.map +1 -1
  188. package/dist/react-native/createPipelineFromOptions.js +2 -0
  189. package/dist/react-native/createPipelineFromOptions.js.map +1 -1
  190. package/dist/react-native/defaultHttpClient.d.ts +1 -1
  191. package/dist/react-native/defaultHttpClient.js +21 -3
  192. package/dist/react-native/defaultHttpClient.js.map +1 -0
  193. package/dist/react-native/httpHeaders.js +2 -80
  194. package/dist/react-native/httpHeaders.js.map +1 -1
  195. package/dist/react-native/index.d.ts +1 -2
  196. package/dist/react-native/index.js +1 -1
  197. package/dist/react-native/index.js.map +1 -1
  198. package/dist/react-native/interfaces.d.ts +11 -0
  199. package/dist/react-native/interfaces.js.map +1 -1
  200. package/dist/react-native/pipeline.js +2 -253
  201. package/dist/react-native/pipeline.js.map +1 -1
  202. package/dist/react-native/pipelineRequest.d.ts +11 -0
  203. package/dist/react-native/pipelineRequest.js +5 -28
  204. package/dist/react-native/pipelineRequest.js.map +1 -1
  205. package/dist/react-native/policies/agentPolicy.js +3 -11
  206. package/dist/react-native/policies/agentPolicy.js.map +1 -1
  207. package/dist/react-native/policies/decompressResponsePolicy.js +3 -11
  208. package/dist/react-native/policies/decompressResponsePolicy.js.map +1 -1
  209. package/dist/react-native/policies/defaultRetryPolicy.js +3 -12
  210. package/dist/react-native/policies/defaultRetryPolicy.js.map +1 -1
  211. package/dist/react-native/policies/exponentialRetryPolicy.js +3 -10
  212. package/dist/react-native/policies/exponentialRetryPolicy.js.map +1 -1
  213. package/dist/react-native/policies/formDataPolicy.js +3 -85
  214. package/dist/react-native/policies/formDataPolicy.js.map +1 -1
  215. package/dist/react-native/policies/logPolicy.js +3 -21
  216. package/dist/react-native/policies/logPolicy.js.map +1 -1
  217. package/dist/react-native/policies/multipartPolicy.js +12 -95
  218. package/dist/react-native/policies/multipartPolicy.js.map +1 -1
  219. package/dist/react-native/policies/proxyPolicy.d.ts +26 -2
  220. package/dist/react-native/policies/proxyPolicy.js +26 -2
  221. package/dist/react-native/policies/proxyPolicy.js.map +1 -0
  222. package/dist/react-native/policies/redirectPolicy.js +3 -38
  223. package/dist/react-native/policies/redirectPolicy.js.map +1 -1
  224. package/dist/react-native/policies/retryPolicy.d.ts +59 -1
  225. package/dist/react-native/policies/retryPolicy.js +5 -94
  226. package/dist/react-native/policies/retryPolicy.js.map +1 -1
  227. package/dist/react-native/policies/systemErrorRetryPolicy.js +3 -13
  228. package/dist/react-native/policies/systemErrorRetryPolicy.js.map +1 -1
  229. package/dist/react-native/policies/throttlingRetryPolicy.js +3 -11
  230. package/dist/react-native/policies/throttlingRetryPolicy.js.map +1 -1
  231. package/dist/react-native/policies/tlsPolicy.js +3 -11
  232. package/dist/react-native/policies/tlsPolicy.js.map +1 -1
  233. package/dist/react-native/policies/tracingPolicy.js +1 -1
  234. package/dist/react-native/policies/tracingPolicy.js.map +1 -1
  235. package/dist/react-native/policies/wrapAbortSignalLikePolicy.d.ts +10 -0
  236. package/dist/react-native/policies/wrapAbortSignalLikePolicy.js +30 -0
  237. package/dist/react-native/policies/wrapAbortSignalLikePolicy.js.map +1 -0
  238. package/dist/react-native/restError.js +8 -27
  239. package/dist/react-native/restError.js.map +1 -1
  240. package/dist/react-native/util/file.d.ts +28 -2
  241. package/dist/react-native/util/file.js +9 -4
  242. package/dist/react-native/util/file.js.map +1 -1
  243. package/dist/react-native/util/tokenCycler.js +1 -1
  244. package/dist/react-native/util/tokenCycler.js.map +1 -1
  245. package/dist/react-native/util/wrapAbortSignal.d.ts +12 -0
  246. package/dist/react-native/util/wrapAbortSignal.js +31 -0
  247. package/dist/react-native/util/wrapAbortSignal.js.map +1 -0
  248. package/package.json +5 -6
  249. package/dist/browser/accessTokenCache.d.ts +0 -40
  250. package/dist/browser/accessTokenCache.js +0 -32
  251. package/dist/browser/accessTokenCache.js.map +0 -1
  252. package/dist/browser/defaultHttpClient-browser.mjs.map +0 -1
  253. package/dist/browser/fetchHttpClient.d.ts +0 -7
  254. package/dist/browser/fetchHttpClient.js +0 -256
  255. package/dist/browser/fetchHttpClient.js.map +0 -1
  256. package/dist/browser/nodeHttpClient.d.ts +0 -9
  257. package/dist/browser/nodeHttpClient.js +0 -348
  258. package/dist/browser/nodeHttpClient.js.map +0 -1
  259. package/dist/browser/policies/decompressResponsePolicy-browser.mjs.map +0 -1
  260. package/dist/browser/policies/proxyPolicy-browser.mjs.map +0 -1
  261. package/dist/browser/policies/proxyPolicy.common.d.ts +0 -15
  262. package/dist/browser/policies/proxyPolicy.common.js +0 -24
  263. package/dist/browser/policies/proxyPolicy.common.js.map +0 -1
  264. package/dist/browser/retryStrategies/exponentialRetryStrategy.d.ts +0 -40
  265. package/dist/browser/retryStrategies/exponentialRetryStrategy.js +0 -64
  266. package/dist/browser/retryStrategies/exponentialRetryStrategy.js.map +0 -1
  267. package/dist/browser/retryStrategies/retryStrategy.d.ts +0 -61
  268. package/dist/browser/retryStrategies/retryStrategy.js +0 -4
  269. package/dist/browser/retryStrategies/retryStrategy.js.map +0 -1
  270. package/dist/browser/retryStrategies/throttlingRetryStrategy.d.ts +0 -9
  271. package/dist/browser/retryStrategies/throttlingRetryStrategy.js +0 -74
  272. package/dist/browser/retryStrategies/throttlingRetryStrategy.js.map +0 -1
  273. package/dist/browser/util/concat-browser.mjs.map +0 -1
  274. package/dist/browser/util/concat.common.d.ts +0 -18
  275. package/dist/browser/util/concat.common.js +0 -45
  276. package/dist/browser/util/concat.common.js.map +0 -1
  277. package/dist/browser/util/concat.d.ts +0 -2
  278. package/dist/browser/util/concat.js +0 -4
  279. package/dist/browser/util/helpers.d.ts +0 -21
  280. package/dist/browser/util/helpers.js +0 -58
  281. package/dist/browser/util/helpers.js.map +0 -1
  282. package/dist/browser/util/inspect-browser.mjs.map +0 -1
  283. package/dist/browser/util/inspect.common.d.ts +0 -2
  284. package/dist/browser/util/inspect.common.js +0 -4
  285. package/dist/browser/util/inspect.common.js.map +0 -1
  286. package/dist/browser/util/inspect.d.ts +0 -2
  287. package/dist/browser/util/inspect.js +0 -4
  288. package/dist/browser/util/sanitizer.d.ts +0 -30
  289. package/dist/browser/util/sanitizer.js +0 -139
  290. package/dist/browser/util/sanitizer.js.map +0 -1
  291. package/dist/browser/util/typeGuards.d.ts +0 -5
  292. package/dist/browser/util/typeGuards.js +0 -17
  293. package/dist/browser/util/typeGuards.js.map +0 -1
  294. package/dist/browser/xhrHttpClient.d.ts +0 -7
  295. package/dist/browser/xhrHttpClient.js +0 -167
  296. package/dist/browser/xhrHttpClient.js.map +0 -1
  297. package/dist/commonjs/accessTokenCache.d.ts +0 -40
  298. package/dist/commonjs/accessTokenCache.js +0 -36
  299. package/dist/commonjs/accessTokenCache.js.map +0 -1
  300. package/dist/commonjs/fetchHttpClient.d.ts +0 -7
  301. package/dist/commonjs/fetchHttpClient.js +0 -259
  302. package/dist/commonjs/fetchHttpClient.js.map +0 -1
  303. package/dist/commonjs/nodeHttpClient.d.ts +0 -9
  304. package/dist/commonjs/nodeHttpClient.js +0 -353
  305. package/dist/commonjs/nodeHttpClient.js.map +0 -1
  306. package/dist/commonjs/policies/proxyPolicy.common.d.ts +0 -15
  307. package/dist/commonjs/policies/proxyPolicy.common.js +0 -30
  308. package/dist/commonjs/policies/proxyPolicy.common.js.map +0 -1
  309. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.d.ts +0 -40
  310. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +0 -69
  311. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +0 -1
  312. package/dist/commonjs/retryStrategies/retryStrategy.d.ts +0 -61
  313. package/dist/commonjs/retryStrategies/retryStrategy.js +0 -5
  314. package/dist/commonjs/retryStrategies/retryStrategy.js.map +0 -1
  315. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.d.ts +0 -9
  316. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +0 -78
  317. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +0 -1
  318. package/dist/commonjs/util/concat.common.d.ts +0 -18
  319. package/dist/commonjs/util/concat.common.js +0 -48
  320. package/dist/commonjs/util/concat.common.js.map +0 -1
  321. package/dist/commonjs/util/concat.d.ts +0 -17
  322. package/dist/commonjs/util/concat.js +0 -91
  323. package/dist/commonjs/util/concat.js.map +0 -1
  324. package/dist/commonjs/util/helpers.d.ts +0 -21
  325. package/dist/commonjs/util/helpers.js +0 -62
  326. package/dist/commonjs/util/helpers.js.map +0 -1
  327. package/dist/commonjs/util/inspect.common.d.ts +0 -2
  328. package/dist/commonjs/util/inspect.common.js +0 -7
  329. package/dist/commonjs/util/inspect.common.js.map +0 -1
  330. package/dist/commonjs/util/inspect.d.ts +0 -2
  331. package/dist/commonjs/util/inspect.js +0 -8
  332. package/dist/commonjs/util/inspect.js.map +0 -1
  333. package/dist/commonjs/util/sanitizer.d.ts +0 -30
  334. package/dist/commonjs/util/sanitizer.js +0 -143
  335. package/dist/commonjs/util/sanitizer.js.map +0 -1
  336. package/dist/commonjs/util/typeGuards.d.ts +0 -5
  337. package/dist/commonjs/util/typeGuards.js +0 -23
  338. package/dist/commonjs/util/typeGuards.js.map +0 -1
  339. package/dist/commonjs/xhrHttpClient.d.ts +0 -7
  340. package/dist/commonjs/xhrHttpClient.js +0 -170
  341. package/dist/commonjs/xhrHttpClient.js.map +0 -1
  342. package/dist/esm/accessTokenCache.d.ts +0 -40
  343. package/dist/esm/accessTokenCache.js +0 -32
  344. package/dist/esm/accessTokenCache.js.map +0 -1
  345. package/dist/esm/fetchHttpClient.d.ts +0 -7
  346. package/dist/esm/fetchHttpClient.js +0 -256
  347. package/dist/esm/fetchHttpClient.js.map +0 -1
  348. package/dist/esm/nodeHttpClient.d.ts +0 -9
  349. package/dist/esm/nodeHttpClient.js +0 -348
  350. package/dist/esm/nodeHttpClient.js.map +0 -1
  351. package/dist/esm/policies/proxyPolicy.common.d.ts +0 -15
  352. package/dist/esm/policies/proxyPolicy.common.js +0 -24
  353. package/dist/esm/policies/proxyPolicy.common.js.map +0 -1
  354. package/dist/esm/retryStrategies/exponentialRetryStrategy.d.ts +0 -40
  355. package/dist/esm/retryStrategies/exponentialRetryStrategy.js +0 -64
  356. package/dist/esm/retryStrategies/exponentialRetryStrategy.js.map +0 -1
  357. package/dist/esm/retryStrategies/retryStrategy.d.ts +0 -61
  358. package/dist/esm/retryStrategies/retryStrategy.js +0 -4
  359. package/dist/esm/retryStrategies/retryStrategy.js.map +0 -1
  360. package/dist/esm/retryStrategies/throttlingRetryStrategy.d.ts +0 -9
  361. package/dist/esm/retryStrategies/throttlingRetryStrategy.js +0 -74
  362. package/dist/esm/retryStrategies/throttlingRetryStrategy.js.map +0 -1
  363. package/dist/esm/util/concat.common.d.ts +0 -18
  364. package/dist/esm/util/concat.common.js +0 -45
  365. package/dist/esm/util/concat.common.js.map +0 -1
  366. package/dist/esm/util/concat.d.ts +0 -17
  367. package/dist/esm/util/concat.js +0 -88
  368. package/dist/esm/util/concat.js.map +0 -1
  369. package/dist/esm/util/helpers.d.ts +0 -21
  370. package/dist/esm/util/helpers.js +0 -58
  371. package/dist/esm/util/helpers.js.map +0 -1
  372. package/dist/esm/util/inspect.common.d.ts +0 -2
  373. package/dist/esm/util/inspect.common.js +0 -4
  374. package/dist/esm/util/inspect.common.js.map +0 -1
  375. package/dist/esm/util/inspect.d.ts +0 -2
  376. package/dist/esm/util/inspect.js +0 -5
  377. package/dist/esm/util/inspect.js.map +0 -1
  378. package/dist/esm/util/sanitizer.d.ts +0 -30
  379. package/dist/esm/util/sanitizer.js +0 -139
  380. package/dist/esm/util/sanitizer.js.map +0 -1
  381. package/dist/esm/util/typeGuards.d.ts +0 -5
  382. package/dist/esm/util/typeGuards.js +0 -17
  383. package/dist/esm/util/typeGuards.js.map +0 -1
  384. package/dist/esm/xhrHttpClient.d.ts +0 -7
  385. package/dist/esm/xhrHttpClient.js +0 -167
  386. package/dist/esm/xhrHttpClient.js.map +0 -1
  387. package/dist/react-native/accessTokenCache.d.ts +0 -40
  388. package/dist/react-native/accessTokenCache.js +0 -32
  389. package/dist/react-native/accessTokenCache.js.map +0 -1
  390. package/dist/react-native/defaultHttpClient-react-native.mjs.map +0 -1
  391. package/dist/react-native/fetchHttpClient.d.ts +0 -7
  392. package/dist/react-native/fetchHttpClient.js +0 -256
  393. package/dist/react-native/fetchHttpClient.js.map +0 -1
  394. package/dist/react-native/nodeHttpClient.d.ts +0 -9
  395. package/dist/react-native/nodeHttpClient.js +0 -348
  396. package/dist/react-native/nodeHttpClient.js.map +0 -1
  397. package/dist/react-native/policies/proxyPolicy-react-native.mjs.map +0 -1
  398. package/dist/react-native/policies/proxyPolicy.common.d.ts +0 -15
  399. package/dist/react-native/policies/proxyPolicy.common.js +0 -24
  400. package/dist/react-native/policies/proxyPolicy.common.js.map +0 -1
  401. package/dist/react-native/retryStrategies/exponentialRetryStrategy.d.ts +0 -40
  402. package/dist/react-native/retryStrategies/exponentialRetryStrategy.js +0 -64
  403. package/dist/react-native/retryStrategies/exponentialRetryStrategy.js.map +0 -1
  404. package/dist/react-native/retryStrategies/retryStrategy.d.ts +0 -61
  405. package/dist/react-native/retryStrategies/retryStrategy.js +0 -4
  406. package/dist/react-native/retryStrategies/retryStrategy.js.map +0 -1
  407. package/dist/react-native/retryStrategies/throttlingRetryStrategy.d.ts +0 -9
  408. package/dist/react-native/retryStrategies/throttlingRetryStrategy.js +0 -74
  409. package/dist/react-native/retryStrategies/throttlingRetryStrategy.js.map +0 -1
  410. package/dist/react-native/util/concat-react-native.mjs.map +0 -1
  411. package/dist/react-native/util/concat.common.d.ts +0 -18
  412. package/dist/react-native/util/concat.common.js +0 -45
  413. package/dist/react-native/util/concat.common.js.map +0 -1
  414. package/dist/react-native/util/concat.d.ts +0 -2
  415. package/dist/react-native/util/concat.js +0 -4
  416. package/dist/react-native/util/helpers.d.ts +0 -21
  417. package/dist/react-native/util/helpers.js +0 -58
  418. package/dist/react-native/util/helpers.js.map +0 -1
  419. package/dist/react-native/util/inspect-react-native.mjs.map +0 -1
  420. package/dist/react-native/util/inspect.common.d.ts +0 -2
  421. package/dist/react-native/util/inspect.common.js +0 -4
  422. package/dist/react-native/util/inspect.common.js.map +0 -1
  423. package/dist/react-native/util/inspect.d.ts +0 -2
  424. package/dist/react-native/util/inspect.js +0 -4
  425. package/dist/react-native/util/sanitizer.d.ts +0 -30
  426. package/dist/react-native/util/sanitizer.js +0 -139
  427. package/dist/react-native/util/sanitizer.js.map +0 -1
  428. package/dist/react-native/util/typeGuards.d.ts +0 -5
  429. package/dist/react-native/util/typeGuards.js +0 -17
  430. package/dist/react-native/util/typeGuards.js.map +0 -1
  431. package/dist/react-native/xhrHttpClient.d.ts +0 -7
  432. package/dist/react-native/xhrHttpClient.js +0 -167
  433. package/dist/react-native/xhrHttpClient.js.map +0 -1
@@ -1,34 +1,18 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { isError } from "@azure/core-util";
4
- import { custom } from "./util/inspect.js";
5
- import { Sanitizer } from "./util/sanitizer.js";
6
- const errorSanitizer = new Sanitizer();
3
+ import { RestError as TspRestError, isRestError as tspIsRestError, } from "@typespec/ts-http-runtime";
7
4
  /**
8
5
  * A custom error type for failed pipeline requests.
9
6
  */
10
7
  export class RestError extends Error {
11
8
  constructor(message, options = {}) {
12
9
  super(message);
13
- this.name = "RestError";
14
- this.code = options.code;
15
- this.statusCode = options.statusCode;
16
- // The request and response may contain sensitive information in the headers or body.
17
- // To help prevent this sensitive information being accidentally logged, the request and response
18
- // properties are marked as non-enumerable here. This prevents them showing up in the output of
19
- // JSON.stringify and console.log.
20
- Object.defineProperty(this, "request", { value: options.request, enumerable: false });
21
- Object.defineProperty(this, "response", { value: options.response, enumerable: false });
22
- // Logging method for util.inspect in Node
23
- Object.defineProperty(this, custom, {
24
- value: () => {
25
- // Extract non-enumerable properties and add them back. This is OK since in this output the request and
26
- // response get sanitized.
27
- return `RestError: ${this.message} \n ${errorSanitizer.sanitize(Object.assign(Object.assign({}, this), { request: this.request, response: this.response }))}`;
28
- },
29
- enumerable: false,
30
- });
31
- Object.setPrototypeOf(this, RestError.prototype);
10
+ // what is this??
11
+ // it turns out that you can return from a constructor and it causes
12
+ // calling `new` to return the value you return.
13
+ // this lets us wrap the TypeSpec RestError so that calling this constructor will give you the same type of object as calling the TypeSpec one,
14
+ // even though the constructor signatures (through RestErrorOptions) are slightly different.
15
+ return new TspRestError(message, options);
32
16
  }
33
17
  }
34
18
  /**
@@ -47,9 +31,6 @@ RestError.PARSE_ERROR = "PARSE_ERROR";
47
31
  * @param e - Something caught by a catch clause.
48
32
  */
49
33
  export function isRestError(e) {
50
- if (e instanceof RestError) {
51
- return true;
52
- }
53
- return isError(e) && e.name === "RestError";
34
+ return tspIsRestError(e);
54
35
  }
55
36
  //# sourceMappingURL=restError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAA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AoB,CAAC;AAClE;;;GAGG;AACa,qBAAW,GAAW,aAAa,CAAC;AAwDtD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isError } from \"@azure/core-util\";\nimport type { PipelineRequest, PipelineResponse } from \"./interfaces.js\";\nimport { custom } from \"./util/inspect.js\";\nimport { Sanitizer } from \"./util/sanitizer.js\";\n\nconst errorSanitizer = new Sanitizer();\n\n/**\n * The options supported by RestError.\n */\nexport interface RestErrorOptions {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n response?: PipelineResponse;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport class RestError extends Error {\n /**\n * Something went wrong when making the request.\n * This means the actual request failed for some reason,\n * such as a DNS issue or the connection being lost.\n */\n static readonly REQUEST_SEND_ERROR: string = \"REQUEST_SEND_ERROR\";\n /**\n * This means that parsing the response from the server failed.\n * It may have been malformed.\n */\n static readonly PARSE_ERROR: string = \"PARSE_ERROR\";\n\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n public code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n public statusCode?: number;\n /**\n * The request that was made.\n * This property is non-enumerable.\n */\n public request?: PipelineRequest;\n /**\n * The response received (if any.)\n * This property is non-enumerable.\n */\n public response?: PipelineResponse;\n /**\n * Bonus property set by the throw site.\n */\n public details?: unknown;\n\n constructor(message: string, options: RestErrorOptions = {}) {\n super(message);\n this.name = \"RestError\";\n this.code = options.code;\n this.statusCode = options.statusCode;\n\n // The request and response may contain sensitive information in the headers or body.\n // To help prevent this sensitive information being accidentally logged, the request and response\n // properties are marked as non-enumerable here. This prevents them showing up in the output of\n // JSON.stringify and console.log.\n Object.defineProperty(this, \"request\", { value: options.request, enumerable: false });\n Object.defineProperty(this, \"response\", { value: options.response, enumerable: false });\n\n // Logging method for util.inspect in Node\n Object.defineProperty(this, custom, {\n value: () => {\n // Extract non-enumerable properties and add them back. This is OK since in this output the request and\n // response get sanitized.\n return `RestError: ${this.message} \\n ${errorSanitizer.sanitize({\n ...this,\n request: this.request,\n response: this.response,\n })}`;\n },\n enumerable: false,\n });\n\n Object.setPrototypeOf(this, RestError.prototype);\n }\n}\n\n/**\n * Typeguard for RestError\n * @param e - Something caught by a catch clause.\n */\nexport function isRestError(e: unknown): e is RestError {\n if (e instanceof RestError) {\n return true;\n }\n return isError(e) && e.name === \"RestError\";\n}\n"]}
1
+ {"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EACL,SAAS,IAAI,YAAY,EACzB,WAAW,IAAI,cAAc,GAC9B,MAAM,2BAA2B,CAAC;AAwBnC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAoClC,YAAY,OAAe,EAAE,UAA4B,EAAE;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,iBAAiB;QACjB,oEAAoE;QACpE,gDAAgD;QAChD,+IAA+I;QAC/I,4FAA4F;QAC5F,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,OAA8B,CAAC,CAAC;IACnE,CAAC;;AA5CD;;;;GAIG;AACa,4BAAkB,GAAW,oBAAoB,CAAC;AAClE;;;GAGG;AACa,qBAAW,GAAW,aAAa,CAAC;AAqCtD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest, PipelineResponse } from \"./interfaces.js\";\n\nimport type { RestErrorOptions as TspRestErrorOptions } from \"@typespec/ts-http-runtime\";\nimport {\n RestError as TspRestError,\n isRestError as tspIsRestError,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * The options supported by RestError.\n */\nexport interface RestErrorOptions {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n response?: PipelineResponse;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport class RestError extends Error {\n /**\n * Something went wrong when making the request.\n * This means the actual request failed for some reason,\n * such as a DNS issue or the connection being lost.\n */\n static readonly REQUEST_SEND_ERROR: string = \"REQUEST_SEND_ERROR\";\n /**\n * This means that parsing the response from the server failed.\n * It may have been malformed.\n */\n static readonly PARSE_ERROR: string = \"PARSE_ERROR\";\n\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n public code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n public statusCode?: number;\n /**\n * The request that was made.\n * This property is non-enumerable.\n */\n public request?: PipelineRequest;\n /**\n * The response received (if any.)\n * This property is non-enumerable.\n */\n public response?: PipelineResponse;\n /**\n * Bonus property set by the throw site.\n */\n public details?: unknown;\n\n constructor(message: string, options: RestErrorOptions = {}) {\n super(message);\n\n // what is this??\n // it turns out that you can return from a constructor and it causes\n // calling `new` to return the value you return.\n // this lets us wrap the TypeSpec RestError so that calling this constructor will give you the same type of object as calling the TypeSpec one,\n // even though the constructor signatures (through RestErrorOptions) are slightly different.\n return new TspRestError(message, options as TspRestErrorOptions);\n }\n}\n\n/**\n * Typeguard for RestError\n * @param e - Something caught by a catch clause.\n */\nexport function isRestError(e: unknown): e is RestError {\n return tspIsRestError(e);\n}\n"]}
@@ -28,14 +28,39 @@ export interface CreateFileFromStreamOptions extends CreateFileOptions {
28
28
  */
29
29
  size?: number;
30
30
  }
31
+ /**
32
+ * Private symbol used as key on objects created using createFile containing the
33
+ * original source of the file object.
34
+ *
35
+ * This is used in Node to access the original Node stream without using Blob#stream, which
36
+ * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and
37
+ * Readable#to/fromWeb in Node versions we support:
38
+ * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)
39
+ * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)
40
+ *
41
+ * Once these versions are no longer supported, we may be able to stop doing this.
42
+ *
43
+ * @internal
44
+ */
45
+ declare const rawContent: unique symbol;
46
+ /**
47
+ * Type signature of a blob-like object with a raw content property.
48
+ */
49
+ export interface RawContent extends Blob {
50
+ [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;
51
+ }
52
+ /**
53
+ * Type guard to check if a given object is a blob-like object with a raw content property.
54
+ */
55
+ export declare function hasRawContent(x: unknown): x is RawContent;
31
56
  /**
32
57
  * Extract the raw content from a given blob-like object. If the input was created using createFile
33
58
  * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.
34
- * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.
59
+ * For true instances of Blob and File, returns the actual blob.
35
60
  *
36
61
  * @internal
37
62
  */
38
- export declare function getRawContent(blob: Blob): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array;
63
+ export declare function getRawContent(blob: Blob): Blob | NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array;
39
64
  /**
40
65
  * Create an object that implements the File interface. This object is intended to be
41
66
  * passed into RequestBodyType.formData, and is not guaranteed to work as expected in
@@ -66,4 +91,5 @@ export declare function createFileFromStream(stream: () => ReadableStream<Uint8A
66
91
  * @param options - optional metadata about the file, e.g. file name, file size, MIME type.
67
92
  */
68
93
  export declare function createFile(content: Uint8Array, name: string, options?: CreateFileOptions): File;
94
+ export {};
69
95
  //# sourceMappingURL=file.d.ts.map
@@ -1,7 +1,9 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  import { isNodeLike } from "@azure/core-util";
4
- import { isNodeReadableStream } from "./typeGuards.js";
4
+ function isNodeReadableStream(x) {
5
+ return Boolean(x && typeof x["pipe"] === "function");
6
+ }
5
7
  const unimplementedMethods = {
6
8
  arrayBuffer: () => {
7
9
  throw new Error("Not implemented");
@@ -31,13 +33,16 @@ const unimplementedMethods = {
31
33
  * @internal
32
34
  */
33
35
  const rawContent = Symbol("rawContent");
34
- function hasRawContent(x) {
36
+ /**
37
+ * Type guard to check if a given object is a blob-like object with a raw content property.
38
+ */
39
+ export function hasRawContent(x) {
35
40
  return typeof x[rawContent] === "function";
36
41
  }
37
42
  /**
38
43
  * Extract the raw content from a given blob-like object. If the input was created using createFile
39
44
  * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.
40
- * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.
45
+ * For true instances of Blob and File, returns the actual blob.
41
46
  *
42
47
  * @internal
43
48
  */
@@ -46,7 +51,7 @@ export function getRawContent(blob) {
46
51
  return blob[rawContent]();
47
52
  }
48
53
  else {
49
- return blob.stream();
54
+ return blob;
50
55
  }
51
56
  }
52
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAoCvD,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,C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AO,CAAC,CAAC;QACX,CAAC,EACD,CAAC,UAAU,CAAC,EAAE,MAAM,GACA,CAAC;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,OAAmB,EACnB,IAAY,EACZ,UAA6B,EAAE;;IAE/B,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,gCACF,oBAAoB,KACvB,IAAI,EAAE,MAAA,OAAO,CAAC,IAAI,mCAAI,EAAE,EACxB,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAC1D,kBAAkB,EAAE,MAAA,OAAO,CAAC,kBAAkB,mCAAI,EAAE,EACpD,IAAI,EAAE,OAAO,CAAC,UAAU,EACxB,IAAI,EACJ,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,EAC1C,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO,GACP,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isNodeLike } from \"@azure/core-util\";\nimport { isNodeReadableStream } from \"./typeGuards.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n bytes: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\ninterface RawContent {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\nfunction hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob.stream();\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNodeLike) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,SAAS,oBAAoB,CAAC,CAAU;IACtC,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CA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E,MAAA,OAAO,CAAC,IAAI,mCAAI,CAAC,CAAC,EACxB,IAAI,EACJ,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;YACnB,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC,EACD,CAAC,UAAU,CAAC,EAAE,MAAM,GACA,CAAC;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,OAAmB,EACnB,IAAY,EACZ,UAA6B,EAAE;;IAE/B,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,gCACF,oBAAoB,KACvB,IAAI,EAAE,MAAA,OAAO,CAAC,IAAI,mCAAI,EAAE,EACxB,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAC1D,kBAAkB,EAAE,MAAA,OAAO,CAAC,kBAAkB,mCAAI,EAAE,EACpD,IAAI,EAAE,OAAO,CAAC,UAAU,EACxB,IAAI,EACJ,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,EAC1C,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO,GACP,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isNodeLike } from \"@azure/core-util\";\n\nfunction isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream {\n return Boolean(x && typeof (x as NodeJS.ReadableStream)[\"pipe\"] === \"function\");\n}\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n bytes: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\nexport interface RawContent extends Blob {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\n/**\n * Type guard to check if a given object is a blob-like object with a raw content property.\n */\nexport function hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the actual blob.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): Blob | NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob;\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNodeLike) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { delay } from "./helpers.js";
3
+ import { delay } from "@azure/core-util";
4
4
  // Default options for the cycler if none are provided
5
5
  export const DEFAULT_CYCLER_OPTIONS = {
6
6
  forcedRefreshWindowInMs: 1000, // Force waiting for a refresh 1s before the token expires
@@ -1 +1 @@
1
- {"version":3,"file":"tokenCycler.js","sourceRoot":"","sources":["../../../src/util/tokenCycler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAkCrC,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAuB;IACxD,uBAAuB,EAAE,IAAI,EAAE,0DAA0D;IACzF,iBAAiB,EAAE,IAAI,EAAE,kCAAkC;IAC3D,iBAAiB,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,oCAAoC;CACvE,CAAC;AAEF;;;;;;;;;GASG;AACH,KAAK,UAAU,YAAY,CACzB,cAAiD,EACjD,iBAAyB,EACzB,cAAsB;IAEtB,4EAA4E;IAC5E,eAAe;IACf,KAAK,UAAU,iBAAiB;QAC9B,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,OAAO,MAAM,cAAc,EAAE,CAAC;YAChC,CAAC;YAAC,WAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,UAAU,GAAG,MAAM,cAAc,EAAE,CAAC;YAE1C,6CAA6C;YAC7C,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAA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CAAC,QAAQ,CAAC;QAE3D,IAAI,iBAAiB,EAAE,CAAC;YACtB,oEAAoE;YACpE,iGAAiG;YACjG,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QAED,0EAA0E;QAC1E,kHAAkH;QAClH,oDAAoD;QACpD,MAAM,WAAW,GAAG,eAAe,IAAI,iBAAiB,IAAI,MAAM,CAAC,WAAW,CAAC;QAE/E,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,KAAoB,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { delay } from \"./helpers.js\";\n\n/**\n * A function that gets a promise of an access token and allows providing\n * options.\n *\n * @param options - the options to pass to the underlying token provider\n */\nexport type AccessTokenGetter = (\n scopes: string | string[],\n options: GetTokenOptions,\n) => Promise<AccessToken>;\n\nexport interface TokenCyclerOptions {\n /**\n * The window of time before token expiration during which the token will be\n * considered unusable due to risk of the token expiring before sending the\n * request.\n *\n * This will only become meaningful if the refresh fails for over\n * (refreshWindow - forcedRefreshWindow) milliseconds.\n */\n forcedRefreshWindowInMs: number;\n /**\n * Interval in milliseconds to retry failed token refreshes.\n */\n retryIntervalInMs: number;\n /**\n * The window of time before token expiration during which\n * we will attempt to refresh the token.\n */\n refreshWindowInMs: number;\n}\n\n// Default options for the cycler if none are provided\nexport const DEFAULT_CYCLER_OPTIONS: TokenCyclerOptions = {\n forcedRefreshWindowInMs: 1000, // Force waiting for a refresh 1s before the token expires\n retryIntervalInMs: 3000, // Allow refresh attempts every 3s\n refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry\n};\n\n/**\n * Converts an an unreliable access token getter (which may resolve with null)\n * into an AccessTokenGetter by retrying the unreliable getter in a regular\n * interval.\n *\n * @param getAccessToken - A function that produces a promise of an access token that may fail by returning null.\n * @param retryIntervalInMs - The time (in milliseconds) to wait between retry attempts.\n * @param refreshTimeout - The timestamp after which the refresh attempt will fail, throwing an exception.\n * @returns - A promise that, if it resolves, will resolve with an access token.\n */\nasync function beginRefresh(\n getAccessToken: () => Promise<AccessToken | null>,\n retryIntervalInMs: number,\n refreshTimeout: number,\n): Promise<AccessToken> {\n // This wrapper handles exceptions gracefully as long as we haven't exceeded\n // the timeout.\n async function tryGetAccessToken(): Promise<AccessToken | null> {\n if (Date.now() < refreshTimeout) {\n try {\n return await getAccessToken();\n } catch {\n return null;\n }\n } else {\n const finalToken = await getAccessToken();\n\n // Timeout is up, so throw if it's still null\n if (finalToken === null) {\n throw new Error(\"Failed to refresh access token.\");\n }\n\n return finalToken;\n }\n }\n\n let token: AccessToken | null = await tryGetAccessToken();\n\n while (token === null) {\n await delay(retryIntervalInMs);\n\n token = await tryGetAccessToken();\n }\n\n return token;\n}\n\n/**\n * Creates a token cycler from a credential, scopes, and optional settings.\n *\n * A token cycler represents a way to reliably retrieve a valid access token\n * from a TokenCredential. It will handle initializing the token, refreshing it\n * when it nears expiration, and synchronizes refresh attempts to avoid\n * concurrency hazards.\n *\n * @param credential - the underlying TokenCredential that provides the access\n * token\n * @param tokenCyclerOptions - optionally override default settings for the cycler\n *\n * @returns - a function that reliably produces a valid access token\n */\nexport function createTokenCycler(\n credential: TokenCredential,\n tokenCyclerOptions?: Partial<TokenCyclerOptions>,\n): AccessTokenGetter {\n let refreshWorker: Promise<AccessToken> | null = null;\n let token: AccessToken | null = null;\n let tenantId: string | undefined;\n\n const options = {\n ...DEFAULT_CYCLER_OPTIONS,\n ...tokenCyclerOptions,\n };\n\n /**\n * This little holder defines several predicates that we use to construct\n * the rules of refreshing the token.\n */\n const cycler = {\n /**\n * Produces true if a refresh job is currently in progress.\n */\n get isRefreshing(): boolean {\n return refreshWorker !== null;\n },\n /**\n * Produces true if the cycler SHOULD refresh (we are within the refresh\n * window and not already refreshing)\n */\n get shouldRefresh(): boolean {\n if (cycler.isRefreshing) {\n return false;\n }\n if (token?.refreshAfterTimestamp && token.refreshAfterTimestamp < Date.now()) {\n return true;\n }\n\n return (token?.expiresOnTimestamp ?? 0) - options.refreshWindowInMs < Date.now();\n },\n /**\n * Produces true if the cycler MUST refresh (null or nearly-expired\n * token).\n */\n get mustRefresh(): boolean {\n return (\n token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now()\n );\n },\n };\n\n /**\n * Starts a refresh job or returns the existing job if one is already\n * running.\n */\n function refresh(\n scopes: string | string[],\n getTokenOptions: GetTokenOptions,\n ): Promise<AccessToken> {\n if (!cycler.isRefreshing) {\n // We bind `scopes` here to avoid passing it around a lot\n const tryGetAccessToken = (): Promise<AccessToken | null> =>\n credential.getToken(scopes, getTokenOptions);\n\n // Take advantage of promise chaining to insert an assignment to `token`\n // before the refresh can be considered done.\n refreshWorker = beginRefresh(\n tryGetAccessToken,\n options.retryIntervalInMs,\n // If we don't have a token, then we should timeout immediately\n token?.expiresOnTimestamp ?? Date.now(),\n )\n .then((_token) => {\n refreshWorker = null;\n token = _token;\n tenantId = getTokenOptions.tenantId;\n return token;\n })\n .catch((reason) => {\n // We also should reset the refresher if we enter a failed state. All\n // existing awaiters will throw, but subsequent requests will start a\n // new retry chain.\n refreshWorker = null;\n token = null;\n tenantId = undefined;\n throw reason;\n });\n }\n\n return refreshWorker as Promise<AccessToken>;\n }\n\n return async (scopes: string | string[], tokenOptions: GetTokenOptions): Promise<AccessToken> => {\n //\n // Simple rules:\n // - If we MUST refresh, then return the refresh task, blocking\n // the pipeline until a token is available.\n // - If we SHOULD refresh, then run refresh but don't return it\n // (we can still use the cached token).\n // - Return the token, since it's fine if we didn't return in\n // step 1.\n //\n\n const hasClaimChallenge = Boolean(tokenOptions.claims);\n const tenantIdChanged = tenantId !== tokenOptions.tenantId;\n\n if (hasClaimChallenge) {\n // If we've received a claim, we know the existing token isn't valid\n // We want to clear it so that that refresh worker won't use the old expiration time as a timeout\n token = null;\n }\n\n // If the tenantId passed in token options is different to the one we have\n // Or if we are in claim challenge and the token was rejected and a new access token need to be issued, we need to\n // refresh the token with the new tenantId or token.\n const mustRefresh = tenantIdChanged || hasClaimChallenge || cycler.mustRefresh;\n\n if (mustRefresh) {\n return refresh(scopes, tokenOptions);\n }\n\n if (cycler.shouldRefresh) {\n refresh(scopes, tokenOptions);\n }\n\n return token as AccessToken;\n };\n}\n"]}
1
+ {"version":3,"file":"tokenCycler.js","sourceRoot":"","sources":["../../../src/util/tokenCycler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAkCzC,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAuB;IACxD,uBAAuB,EAAE,IAAI,EAAE,0DAA0D;IACzF,iBAAiB,EAAE,IAAI,EAAE,kCAAkC;IAC3D,iBAAiB,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,oCAAoC;CACvE,CAAC;AAEF;;;;;;;;;GASG;AACH,KAAK,UAAU,YAAY,CACzB,cAAiD,EACjD,iBAAyB,EACzB,cAAsB;IAEtB,4EAA4E;IAC5E,eAAe;IACf,KAAK,UAAU,iBAAiB;QAC9B,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,OAAO,MAAM,cAAc,EAAE,CAAC;YAChC,CAAC;YAAC,WAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,UAAU,GAAG,MAAM,cAAc,EAAE,CAAC;YAE1C,6CAA6C;YAC7C,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAA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,QAAQ,KAAK,YAAY,CAAC,QAAQ,CAAC;QAE3D,IAAI,iBAAiB,EAAE,CAAC;YACtB,oEAAoE;YACpE,iGAAiG;YACjG,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QAED,0EAA0E;QAC1E,kHAAkH;QAClH,oDAAoD;QACpD,MAAM,WAAW,GAAG,eAAe,IAAI,iBAAiB,IAAI,MAAM,CAAC,WAAW,CAAC;QAE/E,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,KAAoB,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { delay } from \"@azure/core-util\";\n\n/**\n * A function that gets a promise of an access token and allows providing\n * options.\n *\n * @param options - the options to pass to the underlying token provider\n */\nexport type AccessTokenGetter = (\n scopes: string | string[],\n options: GetTokenOptions,\n) => Promise<AccessToken>;\n\nexport interface TokenCyclerOptions {\n /**\n * The window of time before token expiration during which the token will be\n * considered unusable due to risk of the token expiring before sending the\n * request.\n *\n * This will only become meaningful if the refresh fails for over\n * (refreshWindow - forcedRefreshWindow) milliseconds.\n */\n forcedRefreshWindowInMs: number;\n /**\n * Interval in milliseconds to retry failed token refreshes.\n */\n retryIntervalInMs: number;\n /**\n * The window of time before token expiration during which\n * we will attempt to refresh the token.\n */\n refreshWindowInMs: number;\n}\n\n// Default options for the cycler if none are provided\nexport const DEFAULT_CYCLER_OPTIONS: TokenCyclerOptions = {\n forcedRefreshWindowInMs: 1000, // Force waiting for a refresh 1s before the token expires\n retryIntervalInMs: 3000, // Allow refresh attempts every 3s\n refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry\n};\n\n/**\n * Converts an an unreliable access token getter (which may resolve with null)\n * into an AccessTokenGetter by retrying the unreliable getter in a regular\n * interval.\n *\n * @param getAccessToken - A function that produces a promise of an access token that may fail by returning null.\n * @param retryIntervalInMs - The time (in milliseconds) to wait between retry attempts.\n * @param refreshTimeout - The timestamp after which the refresh attempt will fail, throwing an exception.\n * @returns - A promise that, if it resolves, will resolve with an access token.\n */\nasync function beginRefresh(\n getAccessToken: () => Promise<AccessToken | null>,\n retryIntervalInMs: number,\n refreshTimeout: number,\n): Promise<AccessToken> {\n // This wrapper handles exceptions gracefully as long as we haven't exceeded\n // the timeout.\n async function tryGetAccessToken(): Promise<AccessToken | null> {\n if (Date.now() < refreshTimeout) {\n try {\n return await getAccessToken();\n } catch {\n return null;\n }\n } else {\n const finalToken = await getAccessToken();\n\n // Timeout is up, so throw if it's still null\n if (finalToken === null) {\n throw new Error(\"Failed to refresh access token.\");\n }\n\n return finalToken;\n }\n }\n\n let token: AccessToken | null = await tryGetAccessToken();\n\n while (token === null) {\n await delay(retryIntervalInMs);\n\n token = await tryGetAccessToken();\n }\n\n return token;\n}\n\n/**\n * Creates a token cycler from a credential, scopes, and optional settings.\n *\n * A token cycler represents a way to reliably retrieve a valid access token\n * from a TokenCredential. It will handle initializing the token, refreshing it\n * when it nears expiration, and synchronizes refresh attempts to avoid\n * concurrency hazards.\n *\n * @param credential - the underlying TokenCredential that provides the access\n * token\n * @param tokenCyclerOptions - optionally override default settings for the cycler\n *\n * @returns - a function that reliably produces a valid access token\n */\nexport function createTokenCycler(\n credential: TokenCredential,\n tokenCyclerOptions?: Partial<TokenCyclerOptions>,\n): AccessTokenGetter {\n let refreshWorker: Promise<AccessToken> | null = null;\n let token: AccessToken | null = null;\n let tenantId: string | undefined;\n\n const options = {\n ...DEFAULT_CYCLER_OPTIONS,\n ...tokenCyclerOptions,\n };\n\n /**\n * This little holder defines several predicates that we use to construct\n * the rules of refreshing the token.\n */\n const cycler = {\n /**\n * Produces true if a refresh job is currently in progress.\n */\n get isRefreshing(): boolean {\n return refreshWorker !== null;\n },\n /**\n * Produces true if the cycler SHOULD refresh (we are within the refresh\n * window and not already refreshing)\n */\n get shouldRefresh(): boolean {\n if (cycler.isRefreshing) {\n return false;\n }\n if (token?.refreshAfterTimestamp && token.refreshAfterTimestamp < Date.now()) {\n return true;\n }\n\n return (token?.expiresOnTimestamp ?? 0) - options.refreshWindowInMs < Date.now();\n },\n /**\n * Produces true if the cycler MUST refresh (null or nearly-expired\n * token).\n */\n get mustRefresh(): boolean {\n return (\n token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now()\n );\n },\n };\n\n /**\n * Starts a refresh job or returns the existing job if one is already\n * running.\n */\n function refresh(\n scopes: string | string[],\n getTokenOptions: GetTokenOptions,\n ): Promise<AccessToken> {\n if (!cycler.isRefreshing) {\n // We bind `scopes` here to avoid passing it around a lot\n const tryGetAccessToken = (): Promise<AccessToken | null> =>\n credential.getToken(scopes, getTokenOptions);\n\n // Take advantage of promise chaining to insert an assignment to `token`\n // before the refresh can be considered done.\n refreshWorker = beginRefresh(\n tryGetAccessToken,\n options.retryIntervalInMs,\n // If we don't have a token, then we should timeout immediately\n token?.expiresOnTimestamp ?? Date.now(),\n )\n .then((_token) => {\n refreshWorker = null;\n token = _token;\n tenantId = getTokenOptions.tenantId;\n return token;\n })\n .catch((reason) => {\n // We also should reset the refresher if we enter a failed state. All\n // existing awaiters will throw, but subsequent requests will start a\n // new retry chain.\n refreshWorker = null;\n token = null;\n tenantId = undefined;\n throw reason;\n });\n }\n\n return refreshWorker as Promise<AccessToken>;\n }\n\n return async (scopes: string | string[], tokenOptions: GetTokenOptions): Promise<AccessToken> => {\n //\n // Simple rules:\n // - If we MUST refresh, then return the refresh task, blocking\n // the pipeline until a token is available.\n // - If we SHOULD refresh, then run refresh but don't return it\n // (we can still use the cached token).\n // - Return the token, since it's fine if we didn't return in\n // step 1.\n //\n\n const hasClaimChallenge = Boolean(tokenOptions.claims);\n const tenantIdChanged = tenantId !== tokenOptions.tenantId;\n\n if (hasClaimChallenge) {\n // If we've received a claim, we know the existing token isn't valid\n // We want to clear it so that that refresh worker won't use the old expiration time as a timeout\n token = null;\n }\n\n // If the tenantId passed in token options is different to the one we have\n // Or if we are in claim challenge and the token was rejected and a new access token need to be issued, we need to\n // refresh the token with the new tenantId or token.\n const mustRefresh = tenantIdChanged || hasClaimChallenge || cycler.mustRefresh;\n\n if (mustRefresh) {\n return refresh(scopes, tokenOptions);\n }\n\n if (cycler.shouldRefresh) {\n refresh(scopes, tokenOptions);\n }\n\n return token as AccessToken;\n };\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { AbortSignalLike } from "@azure/abort-controller";
2
+ /**
3
+ * Creates a native AbortSignal which reflects the state of the provided AbortSignalLike.
4
+ * If the AbortSignalLike is already a native AbortSignal, it is returned as is.
5
+ * @param abortSignalLike - The AbortSignalLike to wrap.
6
+ * @returns - An object containing the native AbortSignal and an optional cleanup function. The cleanup function should be called when the AbortSignal is no longer needed.
7
+ */
8
+ export declare function wrapAbortSignalLike(abortSignalLike: AbortSignalLike): {
9
+ abortSignal: AbortSignal;
10
+ cleanup?: () => void;
11
+ };
12
+ //# sourceMappingURL=wrapAbortSignal.d.ts.map
@@ -0,0 +1,31 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Creates a native AbortSignal which reflects the state of the provided AbortSignalLike.
5
+ * If the AbortSignalLike is already a native AbortSignal, it is returned as is.
6
+ * @param abortSignalLike - The AbortSignalLike to wrap.
7
+ * @returns - An object containing the native AbortSignal and an optional cleanup function. The cleanup function should be called when the AbortSignal is no longer needed.
8
+ */
9
+ export function wrapAbortSignalLike(abortSignalLike) {
10
+ if (abortSignalLike instanceof AbortSignal) {
11
+ return { abortSignal: abortSignalLike };
12
+ }
13
+ if (abortSignalLike.aborted) {
14
+ return { abortSignal: AbortSignal.abort(abortSignalLike.reason) };
15
+ }
16
+ const controller = new AbortController();
17
+ let needsCleanup = true;
18
+ function cleanup() {
19
+ if (needsCleanup) {
20
+ abortSignalLike.removeEventListener("abort", listener);
21
+ needsCleanup = false;
22
+ }
23
+ }
24
+ function listener() {
25
+ controller.abort(abortSignalLike.reason);
26
+ cleanup();
27
+ }
28
+ abortSignalLike.addEventListener("abort", listener);
29
+ return { abortSignal: controller.signal, cleanup };
30
+ }
31
+ //# sourceMappingURL=wrapAbortSignal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapAbortSignal.js","sourceRoot":"","sources":["../../../src/util/wrapAbortSignal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,eAAgC;IAIlE,IAAI,eAAe,YAAY,WAAW,EAAE,CAAC;QAC3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;IAC1C,CAAC;IAED,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,KAAK,CAAE,eAAuB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7E,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,IAAI,YAAY,GAAG,IAAI,CAAC;IACxB,SAAS,OAAO;QACd,IAAI,YAAY,EAAE,CAAC;YACjB,eAAe,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACvD,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;IACD,SAAS,QAAQ;QACf,UAAU,CAAC,KAAK,CAAE,eAAuB,CAAC,MAAM,CAAC,CAAC;QAClD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,eAAe,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpD,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;AACrD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\n/**\n * Creates a native AbortSignal which reflects the state of the provided AbortSignalLike.\n * If the AbortSignalLike is already a native AbortSignal, it is returned as is.\n * @param abortSignalLike - The AbortSignalLike to wrap.\n * @returns - An object containing the native AbortSignal and an optional cleanup function. The cleanup function should be called when the AbortSignal is no longer needed.\n */\nexport function wrapAbortSignalLike(abortSignalLike: AbortSignalLike): {\n abortSignal: AbortSignal;\n cleanup?: () => void;\n} {\n if (abortSignalLike instanceof AbortSignal) {\n return { abortSignal: abortSignalLike };\n }\n\n if (abortSignalLike.aborted) {\n return { abortSignal: AbortSignal.abort((abortSignalLike as any).reason) };\n }\n\n const controller = new AbortController();\n let needsCleanup = true;\n function cleanup(): void {\n if (needsCleanup) {\n abortSignalLike.removeEventListener(\"abort\", listener);\n needsCleanup = false;\n }\n }\n function listener(): void {\n controller.abort((abortSignalLike as any).reason);\n cleanup();\n }\n\n abortSignalLike.addEventListener(\"abort\", listener);\n return { abortSignal: controller.signal, cleanup };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/core-rest-pipeline",
3
- "version": "1.19.2-alpha.20250417.3",
3
+ "version": "1.20.0",
4
4
  "description": "Isomorphic client library for making HTTP requests in node.js and browser.",
5
5
  "sdk-type": "client",
6
6
  "type": "module",
@@ -97,14 +97,13 @@
97
97
  "@azure/core-tracing": "^1.0.1",
98
98
  "@azure/core-util": "^1.11.0",
99
99
  "@azure/logger": "^1.0.0",
100
- "http-proxy-agent": "^7.0.0",
101
- "https-proxy-agent": "^7.0.0",
100
+ "@typespec/ts-http-runtime": "^0.2.2",
102
101
  "tslib": "^2.6.2"
103
102
  },
104
103
  "devDependencies": {
105
- "@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb",
106
- "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
107
- "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
104
+ "@azure-tools/vite-plugin-browser-test-map": "^1.0.0",
105
+ "@azure/dev-tool": "^1.0.0",
106
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
108
107
  "@types/node": "^18.0.0",
109
108
  "@vitest/browser": "^3.0.9",
110
109
  "@vitest/coverage-istanbul": "^3.0.9",
@@ -1,40 +0,0 @@
1
- import type { AccessToken } from "@azure/core-auth";
2
- /**
3
- * Defines the default token refresh buffer duration.
4
- */
5
- export declare const DefaultTokenRefreshBufferMs: number;
6
- /**
7
- * Provides a cache for an AccessToken that was that
8
- * was returned from a TokenCredential.
9
- */
10
- export interface AccessTokenCache {
11
- /**
12
- * Sets the cached token.
13
- *
14
- * @param accessToken - The AccessToken to be cached or null to
15
- * clear the cached token.
16
- */
17
- setCachedToken(accessToken: AccessToken | undefined): void;
18
- /**
19
- * Returns the cached AccessToken or undefined if nothing is cached.
20
- */
21
- getCachedToken(): AccessToken | undefined;
22
- }
23
- /**
24
- * Provides an AccessTokenCache implementation which clears
25
- * the cached AccessToken's after the expiresOnTimestamp has
26
- * passed.
27
- * @internal
28
- */
29
- export declare class ExpiringAccessTokenCache implements AccessTokenCache {
30
- private tokenRefreshBufferMs;
31
- private cachedToken?;
32
- /**
33
- * Constructs an instance of ExpiringAccessTokenCache with
34
- * an optional expiration buffer time.
35
- */
36
- constructor(tokenRefreshBufferMs?: number);
37
- setCachedToken(accessToken: AccessToken | undefined): void;
38
- getCachedToken(): AccessToken | undefined;
39
- }
40
- //# sourceMappingURL=accessTokenCache.d.ts.map
@@ -1,32 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- /**
4
- * Defines the default token refresh buffer duration.
5
- */
6
- export const DefaultTokenRefreshBufferMs = 2 * 60 * 1000; // 2 Minutes
7
- /**
8
- * Provides an AccessTokenCache implementation which clears
9
- * the cached AccessToken's after the expiresOnTimestamp has
10
- * passed.
11
- * @internal
12
- */
13
- export class ExpiringAccessTokenCache {
14
- /**
15
- * Constructs an instance of ExpiringAccessTokenCache with
16
- * an optional expiration buffer time.
17
- */
18
- constructor(tokenRefreshBufferMs = DefaultTokenRefreshBufferMs) {
19
- this.tokenRefreshBufferMs = tokenRefreshBufferMs;
20
- }
21
- setCachedToken(accessToken) {
22
- this.cachedToken = accessToken;
23
- }
24
- getCachedToken() {
25
- if (this.cachedToken &&
26
- Date.now() + this.tokenRefreshBufferMs >= this.cachedToken.expiresOnTimestamp) {
27
- this.cachedToken = undefined;
28
- }
29
- return this.cachedToken;
30
- }
31
- }
32
- //# sourceMappingURL=accessTokenCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"accessTokenCache.js","sourceRoot":"","sources":["../../src/accessTokenCache.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAqBtE;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IAInC;;;OAGG;IACH,YAAY,uBAA+B,2BAA2B;QACpE,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,cAAc,CAAC,WAAoC;QACjD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,IACE,IAAI,CAAC,WAAW;YAChB,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAC7E,CAAC;YACD,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken } from \"@azure/core-auth\";\n\n/**\n * Defines the default token refresh buffer duration.\n */\nexport const DefaultTokenRefreshBufferMs = 2 * 60 * 1000; // 2 Minutes\n\n/**\n * Provides a cache for an AccessToken that was that\n * was returned from a TokenCredential.\n */\nexport interface AccessTokenCache {\n /**\n * Sets the cached token.\n *\n * @param accessToken - The AccessToken to be cached or null to\n * clear the cached token.\n */\n setCachedToken(accessToken: AccessToken | undefined): void;\n\n /**\n * Returns the cached AccessToken or undefined if nothing is cached.\n */\n getCachedToken(): AccessToken | undefined;\n}\n\n/**\n * Provides an AccessTokenCache implementation which clears\n * the cached AccessToken's after the expiresOnTimestamp has\n * passed.\n * @internal\n */\nexport class ExpiringAccessTokenCache implements AccessTokenCache {\n private tokenRefreshBufferMs: number;\n private cachedToken?: AccessToken;\n\n /**\n * Constructs an instance of ExpiringAccessTokenCache with\n * an optional expiration buffer time.\n */\n constructor(tokenRefreshBufferMs: number = DefaultTokenRefreshBufferMs) {\n this.tokenRefreshBufferMs = tokenRefreshBufferMs;\n }\n\n setCachedToken(accessToken: AccessToken | undefined): void {\n this.cachedToken = accessToken;\n }\n\n getCachedToken(): AccessToken | undefined {\n if (\n this.cachedToken &&\n Date.now() + this.tokenRefreshBufferMs >= this.cachedToken.expiresOnTimestamp\n ) {\n this.cachedToken = undefined;\n }\n\n return this.cachedToken;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultHttpClient-browser.mjs","sourceRoot":"","sources":["../../src/defaultHttpClient-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,qBAAqB,EAAE,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient } from \"./interfaces.js\";\nimport { createFetchHttpClient } from \"./fetchHttpClient.js\";\n\n/**\n * Create the correct HttpClient for the current environment.\n */\nexport function createDefaultHttpClient(): HttpClient {\n return createFetchHttpClient();\n}\n"]}
@@ -1,7 +0,0 @@
1
- import type { HttpClient } from "./interfaces.js";
2
- /**
3
- * Create a new HttpClient instance for the browser environment.
4
- * @internal
5
- */
6
- export declare function createFetchHttpClient(): HttpClient;
7
- //# sourceMappingURL=fetchHttpClient.d.ts.map