@typespec/ts-http-runtime 0.3.5 → 0.3.6

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 (454) hide show
  1. package/dist/browser/client/clientHelpers.js +1 -1
  2. package/dist/browser/client/clientHelpers.js.map +1 -1
  3. package/dist/browser/client/common.d.ts +3 -2
  4. package/dist/browser/client/common.js.map +1 -1
  5. package/dist/browser/client/getClient.js +1 -1
  6. package/dist/browser/client/getClient.js.map +1 -1
  7. package/dist/browser/client/multipart.js +1 -1
  8. package/dist/browser/client/multipart.js.map +1 -1
  9. package/dist/browser/client/restError.js +5 -4
  10. package/dist/browser/client/restError.js.map +1 -1
  11. package/dist/browser/client/sendRequest.js +13 -10
  12. package/dist/browser/client/sendRequest.js.map +1 -1
  13. package/dist/browser/constants.js +1 -1
  14. package/dist/browser/constants.js.map +1 -1
  15. package/dist/browser/createPipelineFromOptions.d.ts +1 -1
  16. package/dist/browser/createPipelineFromOptions.js +2 -21
  17. package/dist/browser/createPipelineFromOptions.js.map +1 -1
  18. package/dist/browser/{defaultHttpClient.d.ts → defaultHttpClient-browser.d.mts} +1 -1
  19. package/dist/browser/{defaultHttpClient.js → defaultHttpClient-browser.mjs} +1 -1
  20. package/dist/browser/defaultHttpClient-browser.mjs.map +1 -0
  21. package/dist/browser/encoding.d.ts +13 -0
  22. package/dist/browser/encoding.js +19 -0
  23. package/dist/browser/encoding.js.map +1 -0
  24. package/dist/{commonjs/util/checkEnvironment.d.ts → browser/env-browser.d.mts} +21 -1
  25. package/dist/{esm/util/checkEnvironment.js → browser/env-browser.mjs} +26 -12
  26. package/dist/browser/env-browser.mjs.map +1 -0
  27. package/dist/browser/formData-web.d.mts +9 -0
  28. package/dist/browser/formData-web.mjs +12 -0
  29. package/dist/browser/formData-web.mjs.map +1 -0
  30. package/dist/browser/httpHeaders.js +11 -1
  31. package/dist/browser/httpHeaders.js.map +1 -1
  32. package/dist/browser/index.d.ts +3 -14
  33. package/dist/browser/index.js +2 -2
  34. package/dist/browser/index.js.map +1 -1
  35. package/dist/browser/interfaces.d.ts +15 -14
  36. package/dist/browser/interfaces.js.map +1 -1
  37. package/dist/browser/logger/debug.js +3 -2
  38. package/dist/browser/logger/debug.js.map +1 -1
  39. package/dist/{react-native/logger/log.d.ts → browser/logger/log-web.d.mts} +1 -1
  40. package/dist/browser/logger/{log.js → log-web.mjs} +1 -1
  41. package/dist/browser/logger/log-web.mjs.map +1 -0
  42. package/dist/browser/logger/logger.js +2 -2
  43. package/dist/browser/logger/logger.js.map +1 -1
  44. package/dist/browser/pipelineRequest.js +1 -1
  45. package/dist/browser/pipelineRequest.js.map +1 -1
  46. package/dist/browser/policies/auth/basicAuthenticationPolicy.js +1 -1
  47. package/dist/browser/policies/auth/basicAuthenticationPolicy.js.map +1 -1
  48. package/dist/browser/policies/auth/checkInsecureConnection.js +3 -2
  49. package/dist/browser/policies/auth/checkInsecureConnection.js.map +1 -1
  50. package/dist/browser/policies/{decompressResponsePolicy.d.ts → decompressResponsePolicy-web.d.mts} +1 -1
  51. package/dist/browser/policies/{decompressResponsePolicy.js → decompressResponsePolicy-web.mjs} +1 -1
  52. package/dist/browser/policies/decompressResponsePolicy-web.mjs.map +1 -0
  53. package/dist/browser/policies/formDataPolicy.js +5 -12
  54. package/dist/browser/policies/formDataPolicy.js.map +1 -1
  55. package/dist/browser/policies/internal.d.ts +2 -2
  56. package/dist/browser/policies/internal.js +2 -2
  57. package/dist/browser/policies/internal.js.map +1 -1
  58. package/dist/browser/policies/multipartPolicy.js +7 -3
  59. package/dist/browser/policies/multipartPolicy.js.map +1 -1
  60. package/dist/browser/policies/platformPolicies-web.d.mts +10 -0
  61. package/dist/browser/policies/platformPolicies-web.mjs +12 -0
  62. package/dist/browser/policies/platformPolicies-web.mjs.map +1 -0
  63. package/dist/browser/policies/platformPolicies.d.ts +25 -0
  64. package/dist/browser/policies/platformPolicies.js +30 -0
  65. package/dist/browser/policies/platformPolicies.js.map +1 -0
  66. package/dist/browser/policies/proxyPolicy-web.d.mts +2 -0
  67. package/dist/{react-native/policies/proxyPolicy.js → browser/policies/proxyPolicy-web.mjs} +1 -1
  68. package/dist/browser/policies/proxyPolicy-web.mjs.map +1 -0
  69. package/dist/browser/restError.js +1 -1
  70. package/dist/browser/restError.js.map +1 -1
  71. package/dist/browser/types-browser.d.mts +19 -0
  72. package/dist/browser/types-browser.mjs +4 -0
  73. package/dist/browser/types-browser.mjs.map +1 -0
  74. package/dist/browser/util/bytesEncoding-web.d.mts +2 -0
  75. package/dist/{react-native/util/bytesEncoding.js → browser/util/bytesEncoding-web.mjs} +1 -1
  76. package/dist/browser/util/bytesEncoding-web.mjs.map +1 -0
  77. package/dist/browser/util/bytesEncoding.common.d.ts +4 -4
  78. package/dist/browser/util/bytesEncoding.common.js +3 -4
  79. package/dist/browser/util/bytesEncoding.common.js.map +1 -1
  80. package/dist/browser/util/concat-browser.d.mts +16 -0
  81. package/dist/browser/util/{concat.js → concat-browser.mjs} +4 -11
  82. package/dist/browser/util/concat-browser.mjs.map +1 -0
  83. package/dist/browser/util/inspect-web.d.mts +2 -0
  84. package/dist/{react-native/util/inspect.js → browser/util/inspect-web.mjs} +1 -1
  85. package/dist/browser/util/inspect-web.mjs.map +1 -0
  86. package/dist/browser/util/internal.d.ts +4 -4
  87. package/dist/browser/util/internal.js +4 -4
  88. package/dist/browser/util/internal.js.map +1 -1
  89. package/dist/browser/util/sha256-web.d.mts +2 -0
  90. package/dist/{react-native/util/sha256.js → browser/util/sha256-web.mjs} +1 -1
  91. package/dist/browser/util/sha256-web.mjs.map +1 -0
  92. package/dist/browser/util/sha256.common.js +1 -1
  93. package/dist/browser/util/sha256.common.js.map +1 -1
  94. package/dist/browser/util/typeGuards-browser.d.mts +14 -0
  95. package/dist/browser/util/typeGuards-browser.mjs +26 -0
  96. package/dist/browser/util/typeGuards-browser.mjs.map +1 -0
  97. package/dist/browser/util/typeGuards.d.ts +5 -4
  98. package/dist/browser/util/typeGuards.js +4 -10
  99. package/dist/browser/util/typeGuards.js.map +1 -1
  100. package/dist/browser/util/userAgent.d.ts +2 -0
  101. package/dist/browser/util/userAgent.js +2 -1
  102. package/dist/browser/util/userAgent.js.map +1 -1
  103. package/dist/browser/util/{userAgentPlatform.d.ts → userAgentPlatform-browser.d.mts} +1 -1
  104. package/dist/browser/util/{userAgentPlatform.js → userAgentPlatform-browser.mjs} +1 -1
  105. package/dist/browser/util/userAgentPlatform-browser.mjs.map +1 -0
  106. package/dist/browser/util/{uuidUtils.d.ts → uuidUtils-browser.d.mts} +1 -1
  107. package/dist/browser/util/{uuidUtils.js → uuidUtils-browser.mjs} +1 -1
  108. package/dist/browser/util/uuidUtils-browser.mjs.map +1 -0
  109. package/dist/commonjs/client/clientHelpers.js +2 -2
  110. package/dist/commonjs/client/clientHelpers.js.map +2 -2
  111. package/dist/commonjs/client/common.d.ts +3 -2
  112. package/dist/commonjs/client/common.js.map +1 -1
  113. package/dist/commonjs/client/getClient.js +3 -3
  114. package/dist/commonjs/client/getClient.js.map +2 -2
  115. package/dist/commonjs/client/multipart.js.map +1 -1
  116. package/dist/commonjs/client/restError.js +5 -4
  117. package/dist/commonjs/client/restError.js.map +2 -2
  118. package/dist/commonjs/client/sendRequest.js +26 -8
  119. package/dist/commonjs/client/sendRequest.js.map +2 -2
  120. package/dist/commonjs/constants.js +1 -1
  121. package/dist/commonjs/constants.js.map +1 -1
  122. package/dist/commonjs/createPipelineFromOptions.d.ts +1 -1
  123. package/dist/commonjs/createPipelineFromOptions.js +2 -19
  124. package/dist/commonjs/createPipelineFromOptions.js.map +2 -2
  125. package/dist/{browser/util/checkEnvironment.d.ts → commonjs/env.d.ts} +21 -1
  126. package/dist/commonjs/env.js +67 -0
  127. package/dist/commonjs/env.js.map +7 -0
  128. package/dist/commonjs/formData.d.ts +10 -0
  129. package/dist/commonjs/{logger/log.common.js → formData.js} +18 -19
  130. package/dist/commonjs/formData.js.map +7 -0
  131. package/dist/commonjs/httpHeaders.js +4 -1
  132. package/dist/commonjs/httpHeaders.js.map +2 -2
  133. package/dist/commonjs/index.d.ts +1 -12
  134. package/dist/commonjs/index.js +2 -2
  135. package/dist/commonjs/index.js.map +2 -2
  136. package/dist/commonjs/interfaces.d.ts +15 -14
  137. package/dist/commonjs/interfaces.js.map +1 -1
  138. package/dist/commonjs/logger/debug.js +2 -1
  139. package/dist/commonjs/logger/debug.js.map +2 -2
  140. package/dist/commonjs/logger/logger.js +2 -1
  141. package/dist/commonjs/logger/logger.js.map +2 -2
  142. package/dist/commonjs/nodeHttpClient.js +3 -1
  143. package/dist/commonjs/nodeHttpClient.js.map +2 -2
  144. package/dist/commonjs/pipelineRequest.js +2 -2
  145. package/dist/commonjs/pipelineRequest.js.map +2 -2
  146. package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +1 -1
  147. package/dist/commonjs/policies/auth/checkInsecureConnection.js +3 -2
  148. package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +2 -2
  149. package/dist/commonjs/policies/formDataPolicy.js +4 -11
  150. package/dist/commonjs/policies/formDataPolicy.js.map +2 -2
  151. package/dist/commonjs/policies/internal.d.ts +1 -1
  152. package/dist/commonjs/policies/internal.js +7 -7
  153. package/dist/commonjs/policies/internal.js.map +2 -2
  154. package/dist/commonjs/policies/multipartPolicy.js +2 -2
  155. package/dist/commonjs/policies/multipartPolicy.js.map +2 -2
  156. package/dist/commonjs/policies/platformPolicies.d.ts +25 -0
  157. package/dist/commonjs/policies/platformPolicies.js +43 -0
  158. package/dist/commonjs/policies/platformPolicies.js.map +7 -0
  159. package/dist/commonjs/restError.js.map +1 -1
  160. package/dist/commonjs/tsdoc-metadata.json +1 -1
  161. package/dist/commonjs/types.d.ts +19 -0
  162. package/dist/commonjs/types.js +16 -0
  163. package/dist/commonjs/types.js.map +7 -0
  164. package/dist/commonjs/util/concat.d.ts +1 -1
  165. package/dist/commonjs/util/concat.js.map +2 -2
  166. package/dist/commonjs/util/internal.d.ts +1 -1
  167. package/dist/commonjs/util/internal.js +10 -10
  168. package/dist/commonjs/util/internal.js.map +2 -2
  169. package/dist/commonjs/util/typeGuards-node.d.ts +13 -0
  170. package/dist/commonjs/util/{inspect.common.js → typeGuards-node.js} +15 -7
  171. package/dist/commonjs/util/typeGuards-node.js.map +7 -0
  172. package/dist/commonjs/util/typeGuards.d.ts +5 -4
  173. package/dist/commonjs/util/typeGuards.js +6 -13
  174. package/dist/commonjs/util/typeGuards.js.map +2 -2
  175. package/dist/commonjs/util/userAgent.d.ts +2 -0
  176. package/dist/commonjs/util/userAgent.js +7 -5
  177. package/dist/commonjs/util/userAgent.js.map +2 -2
  178. package/dist/esm/client/clientHelpers.js.map +1 -1
  179. package/dist/esm/client/common.d.ts +3 -2
  180. package/dist/esm/client/common.js.map +1 -1
  181. package/dist/esm/client/getClient.js +1 -1
  182. package/dist/esm/client/getClient.js.map +1 -1
  183. package/dist/esm/client/multipart.js.map +1 -1
  184. package/dist/esm/client/restError.js +5 -4
  185. package/dist/esm/client/restError.js.map +1 -1
  186. package/dist/esm/client/sendRequest.js +13 -10
  187. package/dist/esm/client/sendRequest.js.map +1 -1
  188. package/dist/esm/constants.js +1 -1
  189. package/dist/esm/constants.js.map +1 -1
  190. package/dist/esm/createPipelineFromOptions.d.ts +1 -1
  191. package/dist/esm/createPipelineFromOptions.js +2 -21
  192. package/dist/esm/createPipelineFromOptions.js.map +1 -1
  193. package/dist/{react-native/util/checkEnvironment.d.ts → esm/env.d.ts} +21 -1
  194. package/dist/esm/env.js +48 -0
  195. package/dist/esm/env.js.map +1 -0
  196. package/dist/esm/formData.d.ts +10 -0
  197. package/dist/esm/formData.js +26 -0
  198. package/dist/esm/formData.js.map +1 -0
  199. package/dist/esm/httpHeaders.js +11 -1
  200. package/dist/esm/httpHeaders.js.map +1 -1
  201. package/dist/esm/index.d.ts +1 -12
  202. package/dist/esm/index.js.map +1 -1
  203. package/dist/esm/interfaces.d.ts +15 -14
  204. package/dist/esm/interfaces.js.map +1 -1
  205. package/dist/esm/logger/debug.js +2 -1
  206. package/dist/esm/logger/debug.js.map +1 -1
  207. package/dist/esm/logger/logger.js +2 -2
  208. package/dist/esm/logger/logger.js.map +1 -1
  209. package/dist/esm/nodeHttpClient.js +3 -1
  210. package/dist/esm/nodeHttpClient.js.map +1 -1
  211. package/dist/esm/pipelineRequest.js.map +1 -1
  212. package/dist/esm/policies/auth/basicAuthenticationPolicy.js.map +1 -1
  213. package/dist/esm/policies/auth/checkInsecureConnection.js +3 -2
  214. package/dist/esm/policies/auth/checkInsecureConnection.js.map +1 -1
  215. package/dist/esm/policies/formDataPolicy.js +4 -11
  216. package/dist/esm/policies/formDataPolicy.js.map +1 -1
  217. package/dist/esm/policies/internal.d.ts +1 -1
  218. package/dist/esm/policies/internal.js +1 -1
  219. package/dist/esm/policies/internal.js.map +1 -1
  220. package/dist/esm/policies/multipartPolicy.js +4 -0
  221. package/dist/esm/policies/multipartPolicy.js.map +1 -1
  222. package/dist/esm/policies/platformPolicies.d.ts +25 -0
  223. package/dist/esm/policies/platformPolicies.js +30 -0
  224. package/dist/esm/policies/platformPolicies.js.map +1 -0
  225. package/dist/esm/restError.js.map +1 -1
  226. package/dist/esm/types.d.ts +19 -0
  227. package/dist/esm/types.js +4 -0
  228. package/dist/esm/types.js.map +1 -0
  229. package/dist/esm/util/concat.d.ts +1 -1
  230. package/dist/esm/util/concat.js.map +1 -1
  231. package/dist/esm/util/internal.d.ts +1 -1
  232. package/dist/esm/util/internal.js +1 -1
  233. package/dist/esm/util/internal.js.map +1 -1
  234. package/dist/esm/util/typeGuards-node.d.ts +13 -0
  235. package/dist/esm/util/typeGuards-node.js +20 -0
  236. package/dist/esm/util/typeGuards-node.js.map +1 -0
  237. package/dist/esm/util/typeGuards.d.ts +5 -4
  238. package/dist/esm/util/typeGuards.js +4 -10
  239. package/dist/esm/util/typeGuards.js.map +1 -1
  240. package/dist/esm/util/userAgent.d.ts +2 -0
  241. package/dist/esm/util/userAgent.js +1 -0
  242. package/dist/esm/util/userAgent.js.map +1 -1
  243. package/dist/react-native/client/clientHelpers.js +1 -1
  244. package/dist/react-native/client/clientHelpers.js.map +1 -1
  245. package/dist/react-native/client/common.d.ts +3 -2
  246. package/dist/react-native/client/common.js.map +1 -1
  247. package/dist/react-native/client/getClient.js +1 -1
  248. package/dist/react-native/client/getClient.js.map +1 -1
  249. package/dist/react-native/client/multipart.js +1 -1
  250. package/dist/react-native/client/multipart.js.map +1 -1
  251. package/dist/react-native/client/restError.js +5 -4
  252. package/dist/react-native/client/restError.js.map +1 -1
  253. package/dist/react-native/client/sendRequest.js +13 -10
  254. package/dist/react-native/client/sendRequest.js.map +1 -1
  255. package/dist/react-native/constants.js +1 -1
  256. package/dist/react-native/constants.js.map +1 -1
  257. package/dist/react-native/createPipelineFromOptions.d.ts +1 -1
  258. package/dist/react-native/createPipelineFromOptions.js +2 -21
  259. package/dist/react-native/createPipelineFromOptions.js.map +1 -1
  260. package/dist/react-native/{defaultHttpClient.d.ts → defaultHttpClient-react-native.d.mts} +1 -1
  261. package/dist/react-native/{defaultHttpClient.js → defaultHttpClient-react-native.mjs} +1 -1
  262. package/dist/react-native/defaultHttpClient-react-native.mjs.map +1 -0
  263. package/dist/react-native/encoding-react-native.d.mts +21 -0
  264. package/dist/react-native/encoding-react-native.mjs +25 -0
  265. package/dist/react-native/encoding-react-native.mjs.map +1 -0
  266. package/dist/{esm/util/checkEnvironment.d.ts → react-native/env-react-native.d.mts} +21 -1
  267. package/dist/react-native/env-react-native.mjs +50 -0
  268. package/dist/react-native/env-react-native.mjs.map +1 -0
  269. package/dist/react-native/formData-web.d.mts +9 -0
  270. package/dist/react-native/formData-web.mjs +12 -0
  271. package/dist/react-native/formData-web.mjs.map +1 -0
  272. package/dist/react-native/httpHeaders.js +11 -1
  273. package/dist/react-native/httpHeaders.js.map +1 -1
  274. package/dist/react-native/index.d.ts +3 -14
  275. package/dist/react-native/index.js +2 -2
  276. package/dist/react-native/index.js.map +1 -1
  277. package/dist/react-native/interfaces.d.ts +15 -14
  278. package/dist/react-native/interfaces.js.map +1 -1
  279. package/dist/react-native/logger/debug.js +3 -2
  280. package/dist/react-native/logger/debug.js.map +1 -1
  281. package/dist/{browser/logger/log.d.ts → react-native/logger/log-web.d.mts} +1 -1
  282. package/dist/react-native/logger/{log.js → log-web.mjs} +1 -1
  283. package/dist/react-native/logger/log-web.mjs.map +1 -0
  284. package/dist/react-native/logger/logger.js +2 -2
  285. package/dist/react-native/logger/logger.js.map +1 -1
  286. package/dist/react-native/pipelineRequest.js +1 -1
  287. package/dist/react-native/pipelineRequest.js.map +1 -1
  288. package/dist/react-native/policies/auth/basicAuthenticationPolicy.js +1 -1
  289. package/dist/react-native/policies/auth/basicAuthenticationPolicy.js.map +1 -1
  290. package/dist/react-native/policies/auth/checkInsecureConnection.js +3 -2
  291. package/dist/react-native/policies/auth/checkInsecureConnection.js.map +1 -1
  292. package/dist/react-native/policies/decompressResponsePolicy-web.d.mts +8 -0
  293. package/dist/react-native/policies/decompressResponsePolicy-web.mjs +11 -0
  294. package/dist/react-native/policies/decompressResponsePolicy-web.mjs.map +1 -0
  295. package/dist/react-native/policies/formDataPolicy.js +5 -12
  296. package/dist/react-native/policies/formDataPolicy.js.map +1 -1
  297. package/dist/react-native/policies/internal.d.ts +2 -2
  298. package/dist/react-native/policies/internal.js +2 -2
  299. package/dist/react-native/policies/internal.js.map +1 -1
  300. package/dist/react-native/policies/multipartPolicy.js +7 -3
  301. package/dist/react-native/policies/multipartPolicy.js.map +1 -1
  302. package/dist/react-native/policies/platformPolicies-web.d.mts +10 -0
  303. package/dist/react-native/policies/platformPolicies-web.mjs +12 -0
  304. package/dist/react-native/policies/platformPolicies-web.mjs.map +1 -0
  305. package/dist/react-native/policies/platformPolicies.d.ts +25 -0
  306. package/dist/react-native/policies/platformPolicies.js +30 -0
  307. package/dist/react-native/policies/platformPolicies.js.map +1 -0
  308. package/dist/react-native/policies/proxyPolicy-web.d.mts +2 -0
  309. package/dist/{browser/policies/proxyPolicy.js → react-native/policies/proxyPolicy-web.mjs} +1 -1
  310. package/dist/react-native/policies/proxyPolicy-web.mjs.map +1 -0
  311. package/dist/react-native/restError.js +1 -1
  312. package/dist/react-native/restError.js.map +1 -1
  313. package/dist/react-native/types-react-native.d.mts +19 -0
  314. package/dist/react-native/types-react-native.mjs +4 -0
  315. package/dist/react-native/types-react-native.mjs.map +1 -0
  316. package/dist/react-native/util/bytesEncoding-web.d.mts +2 -0
  317. package/dist/{browser/util/bytesEncoding.js → react-native/util/bytesEncoding-web.mjs} +1 -1
  318. package/dist/react-native/util/bytesEncoding-web.mjs.map +1 -0
  319. package/dist/react-native/util/bytesEncoding.common.d.ts +4 -4
  320. package/dist/react-native/util/bytesEncoding.common.js +3 -4
  321. package/dist/react-native/util/bytesEncoding.common.js.map +1 -1
  322. package/dist/react-native/util/{concat.d.ts → concat-react-native.d.mts} +10 -3
  323. package/dist/react-native/util/{concat.js → concat-react-native.mjs} +2 -2
  324. package/dist/react-native/util/concat-react-native.mjs.map +1 -0
  325. package/dist/react-native/util/inspect-web.d.mts +2 -0
  326. package/dist/{browser/util/inspect.js → react-native/util/inspect-web.mjs} +1 -1
  327. package/dist/react-native/util/inspect-web.mjs.map +1 -0
  328. package/dist/react-native/util/internal.d.ts +4 -4
  329. package/dist/react-native/util/internal.js +4 -4
  330. package/dist/react-native/util/internal.js.map +1 -1
  331. package/dist/react-native/util/sha256-web.d.mts +2 -0
  332. package/dist/{browser/util/sha256.js → react-native/util/sha256-web.mjs} +1 -1
  333. package/dist/react-native/util/sha256-web.mjs.map +1 -0
  334. package/dist/react-native/util/sha256.common.js +1 -1
  335. package/dist/react-native/util/sha256.common.js.map +1 -1
  336. package/dist/react-native/util/typeGuards-react-native.d.mts +16 -0
  337. package/dist/react-native/util/typeGuards-react-native.mjs +34 -0
  338. package/dist/react-native/util/typeGuards-react-native.mjs.map +1 -0
  339. package/dist/react-native/util/typeGuards.d.ts +5 -4
  340. package/dist/react-native/util/typeGuards.js +4 -10
  341. package/dist/react-native/util/typeGuards.js.map +1 -1
  342. package/dist/react-native/util/userAgent.d.ts +2 -0
  343. package/dist/react-native/util/userAgent.js +2 -1
  344. package/dist/react-native/util/userAgent.js.map +1 -1
  345. package/dist/react-native/util/{userAgentPlatform.d.ts → userAgentPlatform-react-native.d.mts} +1 -1
  346. package/dist/react-native/util/{userAgentPlatform.js → userAgentPlatform-react-native.mjs} +1 -1
  347. package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -0
  348. package/dist/react-native/util/uuidUtils-react-native.d.mts +2 -0
  349. package/dist/react-native/util/{uuidUtils.js → uuidUtils-react-native.mjs} +1 -1
  350. package/dist/react-native/util/uuidUtils-react-native.mjs.map +1 -0
  351. package/package.json +94 -8
  352. package/dist/browser/defaultHttpClient.js.map +0 -1
  353. package/dist/browser/logger/log.js.map +0 -1
  354. package/dist/browser/nodeHttpClient.d.ts +0 -9
  355. package/dist/browser/nodeHttpClient.js +0 -347
  356. package/dist/browser/nodeHttpClient.js.map +0 -1
  357. package/dist/browser/policies/decompressResponsePolicy.js.map +0 -1
  358. package/dist/browser/policies/proxyPolicy.d.ts +0 -2
  359. package/dist/browser/policies/proxyPolicy.js.map +0 -1
  360. package/dist/browser/util/bytesEncoding.d.ts +0 -2
  361. package/dist/browser/util/bytesEncoding.js.map +0 -1
  362. package/dist/browser/util/checkEnvironment.js +0 -41
  363. package/dist/browser/util/checkEnvironment.js.map +0 -1
  364. package/dist/browser/util/concat.d.ts +0 -17
  365. package/dist/browser/util/concat.js.map +0 -1
  366. package/dist/browser/util/inspect.d.ts +0 -2
  367. package/dist/browser/util/inspect.js.map +0 -1
  368. package/dist/browser/util/sha256.d.ts +0 -2
  369. package/dist/browser/util/sha256.js.map +0 -1
  370. package/dist/browser/util/userAgentPlatform.js.map +0 -1
  371. package/dist/browser/util/uuidUtils.js.map +0 -1
  372. package/dist/browser/xhrHttpClient.d.ts +0 -7
  373. package/dist/browser/xhrHttpClient.js +0 -174
  374. package/dist/browser/xhrHttpClient.js.map +0 -1
  375. package/dist/commonjs/fetchHttpClient.d.ts +0 -12
  376. package/dist/commonjs/fetchHttpClient.js +0 -238
  377. package/dist/commonjs/fetchHttpClient.js.map +0 -7
  378. package/dist/commonjs/logger/log.common.d.ts +0 -2
  379. package/dist/commonjs/logger/log.common.js.map +0 -7
  380. package/dist/commonjs/policies/proxyPolicy.common.d.ts +0 -19
  381. package/dist/commonjs/policies/proxyPolicy.common.js +0 -44
  382. package/dist/commonjs/policies/proxyPolicy.common.js.map +0 -7
  383. package/dist/commonjs/util/arrayBuffer.d.ts +0 -7
  384. package/dist/commonjs/util/arrayBuffer.js +0 -37
  385. package/dist/commonjs/util/arrayBuffer.js.map +0 -7
  386. package/dist/commonjs/util/bytesEncoding.common.d.ts +0 -61
  387. package/dist/commonjs/util/bytesEncoding.common.js +0 -106
  388. package/dist/commonjs/util/bytesEncoding.common.js.map +0 -7
  389. package/dist/commonjs/util/checkEnvironment.js +0 -46
  390. package/dist/commonjs/util/checkEnvironment.js.map +0 -7
  391. package/dist/commonjs/util/inspect.common.d.ts +0 -2
  392. package/dist/commonjs/util/inspect.common.js.map +0 -7
  393. package/dist/commonjs/util/sha256.common.d.ts +0 -14
  394. package/dist/commonjs/util/sha256.common.js +0 -70
  395. package/dist/commonjs/util/sha256.common.js.map +0 -7
  396. package/dist/commonjs/util/uuidUtils.common.d.ts +0 -13
  397. package/dist/commonjs/util/uuidUtils.common.js +0 -49
  398. package/dist/commonjs/util/uuidUtils.common.js.map +0 -7
  399. package/dist/commonjs/xhrHttpClient.d.ts +0 -7
  400. package/dist/commonjs/xhrHttpClient.js +0 -186
  401. package/dist/commonjs/xhrHttpClient.js.map +0 -7
  402. package/dist/esm/fetchHttpClient.d.ts +0 -12
  403. package/dist/esm/fetchHttpClient.js +0 -279
  404. package/dist/esm/fetchHttpClient.js.map +0 -1
  405. package/dist/esm/logger/log.common.d.ts +0 -2
  406. package/dist/esm/logger/log.common.js +0 -23
  407. package/dist/esm/logger/log.common.js.map +0 -1
  408. package/dist/esm/policies/proxyPolicy.common.d.ts +0 -19
  409. package/dist/esm/policies/proxyPolicy.common.js +0 -24
  410. package/dist/esm/policies/proxyPolicy.common.js.map +0 -1
  411. package/dist/esm/util/arrayBuffer.d.ts +0 -7
  412. package/dist/esm/util/arrayBuffer.js +0 -20
  413. package/dist/esm/util/arrayBuffer.js.map +0 -1
  414. package/dist/esm/util/bytesEncoding.common.d.ts +0 -61
  415. package/dist/esm/util/bytesEncoding.common.js +0 -110
  416. package/dist/esm/util/bytesEncoding.common.js.map +0 -1
  417. package/dist/esm/util/checkEnvironment.js.map +0 -1
  418. package/dist/esm/util/inspect.common.d.ts +0 -2
  419. package/dist/esm/util/inspect.common.js +0 -4
  420. package/dist/esm/util/inspect.common.js.map +0 -1
  421. package/dist/esm/util/sha256.common.d.ts +0 -14
  422. package/dist/esm/util/sha256.common.js +0 -49
  423. package/dist/esm/util/sha256.common.js.map +0 -1
  424. package/dist/esm/util/uuidUtils.common.d.ts +0 -13
  425. package/dist/esm/util/uuidUtils.common.js +0 -40
  426. package/dist/esm/util/uuidUtils.common.js.map +0 -1
  427. package/dist/esm/xhrHttpClient.d.ts +0 -7
  428. package/dist/esm/xhrHttpClient.js +0 -174
  429. package/dist/esm/xhrHttpClient.js.map +0 -1
  430. package/dist/react-native/defaultHttpClient.js.map +0 -1
  431. package/dist/react-native/fetchHttpClient.d.ts +0 -12
  432. package/dist/react-native/fetchHttpClient.js +0 -279
  433. package/dist/react-native/fetchHttpClient.js.map +0 -1
  434. package/dist/react-native/logger/log.js.map +0 -1
  435. package/dist/react-native/nodeHttpClient.d.ts +0 -9
  436. package/dist/react-native/nodeHttpClient.js +0 -347
  437. package/dist/react-native/nodeHttpClient.js.map +0 -1
  438. package/dist/react-native/policies/decompressResponsePolicy.d.ts +0 -11
  439. package/dist/react-native/policies/decompressResponsePolicy.js +0 -23
  440. package/dist/react-native/policies/decompressResponsePolicy.js.map +0 -1
  441. package/dist/react-native/policies/proxyPolicy.d.ts +0 -2
  442. package/dist/react-native/policies/proxyPolicy.js.map +0 -1
  443. package/dist/react-native/util/bytesEncoding.d.ts +0 -2
  444. package/dist/react-native/util/bytesEncoding.js.map +0 -1
  445. package/dist/react-native/util/checkEnvironment.js +0 -41
  446. package/dist/react-native/util/checkEnvironment.js.map +0 -1
  447. package/dist/react-native/util/concat.js.map +0 -1
  448. package/dist/react-native/util/inspect.d.ts +0 -2
  449. package/dist/react-native/util/inspect.js.map +0 -1
  450. package/dist/react-native/util/sha256.d.ts +0 -2
  451. package/dist/react-native/util/sha256.js.map +0 -1
  452. package/dist/react-native/util/userAgentPlatform.js.map +0 -1
  453. package/dist/react-native/util/uuidUtils.d.ts +0 -2
  454. package/dist/react-native/util/uuidUtils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/logger/debug.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAgE/B,MAAM,gBAAgB,GACpB,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC;AAEpF,IAAI,aAAiC,CAAC;AACtC,IAAI,iBAAiB,GAAa,EAAE,CAAC;AACrC,IAAI,iBAAiB,GAAa,EAAE,CAAC;AACrC,MAAM,SAAS,GAAe,EAAE,CAAC;AAEjC,IAAI,gBAAgB,EAAE,CAAC;IACrB,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,QAAQ,GAAU,MAAM,CAAC,MAAM,CACnC,CAAC,SAAiB,EAAY,EAAE;IAC9B,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,EACD;IACE,MAAM;IACN,OAAO;IACP,OAAO;IACP,GAAG;CACJ,CACF,CAAC;AAEF,SAAS,MAAM,CAAC,UAAkB;IAChC,aAA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MAAM,CAAiB,SAAiB;IAC/C,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;IACrE,WAAW,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IAC3B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { log } from \"./log.js\";\n\n/**\n * A simple mechanism for enabling logging.\n * Intended to mimic the publicly available `debug` package.\n */\nexport interface Debug {\n /**\n * Creates a new logger with the given namespace.\n */\n (namespace: string): Debugger;\n /**\n * The default log method (defaults to console)\n */\n log: (...args: any[]) => void;\n /**\n * Enables a particular set of namespaces.\n * To enable multiple separate them with commas, e.g. \"info,debug\".\n * Supports wildcards, e.g. \"typeSpecRuntime:*\"\n * Supports skip syntax, e.g. \"typeSpecRuntime:*,-typeSpecRuntime:storage:*\" will enable\n * everything under typeSpecRuntime except for things under typeSpecRuntime:storage.\n */\n enable: (namespaces: string) => void;\n /**\n * Checks if a particular namespace is enabled.\n */\n enabled: (namespace: string) => boolean;\n /**\n * Disables all logging, returns what was previously enabled.\n */\n disable: () => string;\n}\n\n/**\n * A log function that can be dynamically enabled and redirected.\n */\nexport interface Debugger {\n /**\n * Logs the given arguments to the `log` method.\n */\n (...args: any[]): void;\n /**\n * True if this logger is active and logging.\n */\n enabled: boolean;\n /**\n * Used to cleanup/remove this logger.\n */\n destroy: () => boolean;\n /**\n * The current log method. Can be overridden to redirect output.\n */\n log: (...args: any[]) => void;\n /**\n * The namespace of this logger.\n */\n namespace: string;\n /**\n * Extends this logger with a child namespace.\n * Namespaces are separated with a ':' character.\n */\n extend: (namespace: string) => Debugger;\n}\n\nconst debugEnvVariable =\n (typeof process !== \"undefined\" && process.env && process.env.DEBUG) || undefined;\n\nlet enabledString: string | undefined;\nlet enabledNamespaces: string[] = [];\nlet skippedNamespaces: string[] = [];\nconst debuggers: Debugger[] = [];\n\nif (debugEnvVariable) {\n enable(debugEnvVariable);\n}\n\nconst debugObj: Debug = Object.assign(\n (namespace: string): Debugger => {\n return createDebugger(namespace);\n },\n {\n enable,\n enabled,\n disable,\n log,\n },\n);\n\nfunction enable(namespaces: string): void {\n enabledString = namespaces;\n enabledNamespaces = [];\n skippedNamespaces = [];\n const namespaceList = namespaces.split(\",\").map((ns) => ns.trim());\n for (const ns of namespaceList) {\n if (ns.startsWith(\"-\")) {\n skippedNamespaces.push(ns.substring(1));\n } else {\n enabledNamespaces.push(ns);\n }\n }\n for (const instance of debuggers) {\n instance.enabled = enabled(instance.namespace);\n }\n}\n\nfunction enabled(namespace: string): boolean {\n if (namespace.endsWith(\"*\")) {\n return true;\n }\n\n for (const skipped of skippedNamespaces) {\n if (namespaceMatches(namespace, skipped)) {\n return false;\n }\n }\n for (const enabledNamespace of enabledNamespaces) {\n if (namespaceMatches(namespace, enabledNamespace)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Given a namespace, check if it matches a pattern.\n * Patterns only have a single wildcard character which is *.\n * The behavior of * is that it matches zero or more other characters.\n */\nfunction namespaceMatches(namespace: string, patternToMatch: string): boolean {\n // simple case, no pattern matching required\n if (patternToMatch.indexOf(\"*\") === -1) {\n return namespace === patternToMatch;\n }\n\n let pattern = patternToMatch;\n\n // normalize successive * if needed\n if (patternToMatch.indexOf(\"**\") !== -1) {\n const patternParts = [];\n let lastCharacter = \"\";\n for (const character of patternToMatch) {\n if (character === \"*\" && lastCharacter === \"*\") {\n continue;\n } else {\n lastCharacter = character;\n patternParts.push(character);\n }\n }\n pattern = patternParts.join(\"\");\n }\n\n let namespaceIndex = 0;\n let patternIndex = 0;\n const patternLength = pattern.length;\n const namespaceLength = namespace.length;\n let lastWildcard = -1;\n let lastWildcardNamespace = -1;\n\n while (namespaceIndex < namespaceLength && patternIndex < patternLength) {\n if (pattern[patternIndex] === \"*\") {\n lastWildcard = patternIndex;\n patternIndex++;\n if (patternIndex === patternLength) {\n // if wildcard is the last character, it will match the remaining namespace string\n return true;\n }\n // now we let the wildcard eat characters until we match the next literal in the pattern\n while (namespace[namespaceIndex] !== pattern[patternIndex]) {\n namespaceIndex++;\n // reached the end of the namespace without a match\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n }\n\n // now that we have a match, let's try to continue on\n // however, it's possible we could find a later match\n // so keep a reference in case we have to backtrack\n lastWildcardNamespace = namespaceIndex;\n namespaceIndex++;\n patternIndex++;\n continue;\n } else if (pattern[patternIndex] === namespace[namespaceIndex]) {\n // simple case: literal pattern matches so keep going\n patternIndex++;\n namespaceIndex++;\n } else if (lastWildcard >= 0) {\n // special case: we don't have a literal match, but there is a previous wildcard\n // which we can backtrack to and try having the wildcard eat the match instead\n patternIndex = lastWildcard + 1;\n namespaceIndex = lastWildcardNamespace + 1;\n // we've reached the end of the namespace without a match\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n // similar to the previous logic, let's keep going until we find the next literal match\n while (namespace[namespaceIndex] !== pattern[patternIndex]) {\n namespaceIndex++;\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n }\n lastWildcardNamespace = namespaceIndex;\n namespaceIndex++;\n patternIndex++;\n continue;\n } else {\n return false;\n }\n }\n\n const namespaceDone = namespaceIndex === namespace.length;\n const patternDone = patternIndex === pattern.length;\n // this is to detect the case of an unneeded final wildcard\n // e.g. the pattern `ab*` should match the string `ab`\n const trailingWildCard = patternIndex === pattern.length - 1 && pattern[patternIndex] === \"*\";\n return namespaceDone && (patternDone || trailingWildCard);\n}\n\nfunction disable(): string {\n const result = enabledString || \"\";\n enable(\"\");\n return result;\n}\n\nfunction createDebugger(namespace: string): Debugger {\n const newDebugger: Debugger = Object.assign(debug, {\n enabled: enabled(namespace),\n destroy,\n log: debugObj.log,\n namespace,\n extend,\n });\n\n function debug(...args: any[]): void {\n if (!newDebugger.enabled) {\n return;\n }\n if (args.length > 0) {\n args[0] = `${namespace} ${args[0]}`;\n }\n newDebugger.log(...args);\n }\n\n debuggers.push(newDebugger);\n\n return newDebugger;\n}\n\nfunction destroy(this: Debugger): boolean {\n const index = debuggers.indexOf(this);\n if (index >= 0) {\n debuggers.splice(index, 1);\n return true;\n }\n return false;\n}\n\nfunction extend(this: Debugger, namespace: string): Debugger {\n const newDebugger = createDebugger(`${this.namespace}:${namespace}`);\n newDebugger.log = this.log;\n return newDebugger;\n}\n\nexport default debugObj;\n"]}
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/logger/debug.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAgEvD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAEzD,IAAI,aAAiC,CAAC;AACtC,IAAI,iBAAiB,GAAa,EAAE,CAAC;AACrC,IAAI,iBAAiB,GAAa,EAAE,CAAC;AACrC,MAAM,SAAS,GAAe,EAAE,CAAC;AAEjC,IAAI,gBAAgB,EAAE,CAAC;IACrB,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,QAAQ,GAAU,MAAM,CAAC,MAAM,CACnC,CAAC,SAAiB,EAAY,EAAE;IAC9B,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC,EACD;IACE,MAAM;IACN,OAAO;IACP,OAAO;IACP,GAAG;CACJ,CACF,CAAC;AAEF,SAAS,MAAM,CAAC,UAAkB;IAChC,aAAa,GAAG,UAAU,CAAC;IAC3B,iBAAiB,GAAG,EAAE,CAAC;IACvB,iBAAiB,GAAG,EAAE,CAAC;IACvB,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IACnE,KAAK,MAAM,EAA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Corporation.\n// Licensed under the MIT License.\n\nimport { log } from \"#platform/log\";\nimport { getEnvironmentVariable } from \"#platform/env\";\n\n/**\n * A simple mechanism for enabling logging.\n * Intended to mimic the publicly available `debug` package.\n */\nexport interface Debug {\n /**\n * Creates a new logger with the given namespace.\n */\n (namespace: string): Debugger;\n /**\n * The default log method (defaults to console)\n */\n log: (...args: any[]) => void;\n /**\n * Enables a particular set of namespaces.\n * To enable multiple separate them with commas, e.g. \"info,debug\".\n * Supports wildcards, e.g. \"typeSpecRuntime:*\"\n * Supports skip syntax, e.g. \"typeSpecRuntime:*,-typeSpecRuntime:storage:*\" will enable\n * everything under typeSpecRuntime except for things under typeSpecRuntime:storage.\n */\n enable: (namespaces: string) => void;\n /**\n * Checks if a particular namespace is enabled.\n */\n enabled: (namespace: string) => boolean;\n /**\n * Disables all logging, returns what was previously enabled.\n */\n disable: () => string;\n}\n\n/**\n * A log function that can be dynamically enabled and redirected.\n */\nexport interface Debugger {\n /**\n * Logs the given arguments to the `log` method.\n */\n (...args: any[]): void;\n /**\n * True if this logger is active and logging.\n */\n enabled: boolean;\n /**\n * Used to cleanup/remove this logger.\n */\n destroy: () => boolean;\n /**\n * The current log method. Can be overridden to redirect output.\n */\n log: (...args: any[]) => void;\n /**\n * The namespace of this logger.\n */\n namespace: string;\n /**\n * Extends this logger with a child namespace.\n * Namespaces are separated with a ':' character.\n */\n extend: (namespace: string) => Debugger;\n}\n\nconst debugEnvVariable = getEnvironmentVariable(\"DEBUG\");\n\nlet enabledString: string | undefined;\nlet enabledNamespaces: string[] = [];\nlet skippedNamespaces: string[] = [];\nconst debuggers: Debugger[] = [];\n\nif (debugEnvVariable) {\n enable(debugEnvVariable);\n}\n\nconst debugObj: Debug = Object.assign(\n (namespace: string): Debugger => {\n return createDebugger(namespace);\n },\n {\n enable,\n enabled,\n disable,\n log,\n },\n);\n\nfunction enable(namespaces: string): void {\n enabledString = namespaces;\n enabledNamespaces = [];\n skippedNamespaces = [];\n const namespaceList = namespaces.split(\",\").map((ns) => ns.trim());\n for (const ns of namespaceList) {\n if (ns.startsWith(\"-\")) {\n skippedNamespaces.push(ns.substring(1));\n } else {\n enabledNamespaces.push(ns);\n }\n }\n for (const instance of debuggers) {\n instance.enabled = enabled(instance.namespace);\n }\n}\n\nfunction enabled(namespace: string): boolean {\n if (namespace.endsWith(\"*\")) {\n return true;\n }\n\n for (const skipped of skippedNamespaces) {\n if (namespaceMatches(namespace, skipped)) {\n return false;\n }\n }\n for (const enabledNamespace of enabledNamespaces) {\n if (namespaceMatches(namespace, enabledNamespace)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Given a namespace, check if it matches a pattern.\n * Patterns only have a single wildcard character which is *.\n * The behavior of * is that it matches zero or more other characters.\n */\nfunction namespaceMatches(namespace: string, patternToMatch: string): boolean {\n // simple case, no pattern matching required\n if (patternToMatch.indexOf(\"*\") === -1) {\n return namespace === patternToMatch;\n }\n\n let pattern = patternToMatch;\n\n // normalize successive * if needed\n if (patternToMatch.indexOf(\"**\") !== -1) {\n const patternParts = [];\n let lastCharacter = \"\";\n for (const character of patternToMatch) {\n if (character === \"*\" && lastCharacter === \"*\") {\n continue;\n } else {\n lastCharacter = character;\n patternParts.push(character);\n }\n }\n pattern = patternParts.join(\"\");\n }\n\n let namespaceIndex = 0;\n let patternIndex = 0;\n const patternLength = pattern.length;\n const namespaceLength = namespace.length;\n let lastWildcard = -1;\n let lastWildcardNamespace = -1;\n\n while (namespaceIndex < namespaceLength && patternIndex < patternLength) {\n if (pattern[patternIndex] === \"*\") {\n lastWildcard = patternIndex;\n patternIndex++;\n if (patternIndex === patternLength) {\n // if wildcard is the last character, it will match the remaining namespace string\n return true;\n }\n // now we let the wildcard eat characters until we match the next literal in the pattern\n while (namespace[namespaceIndex] !== pattern[patternIndex]) {\n namespaceIndex++;\n // reached the end of the namespace without a match\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n }\n\n // now that we have a match, let's try to continue on\n // however, it's possible we could find a later match\n // so keep a reference in case we have to backtrack\n lastWildcardNamespace = namespaceIndex;\n namespaceIndex++;\n patternIndex++;\n continue;\n } else if (pattern[patternIndex] === namespace[namespaceIndex]) {\n // simple case: literal pattern matches so keep going\n patternIndex++;\n namespaceIndex++;\n } else if (lastWildcard >= 0) {\n // special case: we don't have a literal match, but there is a previous wildcard\n // which we can backtrack to and try having the wildcard eat the match instead\n patternIndex = lastWildcard + 1;\n namespaceIndex = lastWildcardNamespace + 1;\n // we've reached the end of the namespace without a match\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n // similar to the previous logic, let's keep going until we find the next literal match\n while (namespace[namespaceIndex] !== pattern[patternIndex]) {\n namespaceIndex++;\n if (namespaceIndex === namespaceLength) {\n return false;\n }\n }\n lastWildcardNamespace = namespaceIndex;\n namespaceIndex++;\n patternIndex++;\n continue;\n } else {\n return false;\n }\n }\n\n const namespaceDone = namespaceIndex === namespace.length;\n const patternDone = patternIndex === pattern.length;\n // this is to detect the case of an unneeded final wildcard\n // e.g. the pattern `ab*` should match the string `ab`\n const trailingWildCard = patternIndex === pattern.length - 1 && pattern[patternIndex] === \"*\";\n return namespaceDone && (patternDone || trailingWildCard);\n}\n\nfunction disable(): string {\n const result = enabledString || \"\";\n enable(\"\");\n return result;\n}\n\nfunction createDebugger(namespace: string): Debugger {\n const newDebugger: Debugger = Object.assign(debug, {\n enabled: enabled(namespace),\n destroy,\n log: debugObj.log,\n namespace,\n extend,\n });\n\n function debug(...args: any[]): void {\n if (!newDebugger.enabled) {\n return;\n }\n if (args.length > 0) {\n args[0] = `${namespace} ${args[0]}`;\n }\n newDebugger.log(...args);\n }\n\n debuggers.push(newDebugger);\n\n return newDebugger;\n}\n\nfunction destroy(this: Debugger): boolean {\n const index = debuggers.indexOf(this);\n if (index >= 0) {\n debuggers.splice(index, 1);\n return true;\n }\n return false;\n}\n\nfunction extend(this: Debugger, namespace: string): Debugger {\n const newDebugger = createDebugger(`${this.namespace}:${namespace}`);\n newDebugger.log = this.log;\n return newDebugger;\n}\n\nexport default debugObj;\n"]}
@@ -1,2 +1,2 @@
1
1
  export { log } from "./log.common.js";
2
- //# sourceMappingURL=log.d.ts.map
2
+ //# sourceMappingURL=log-web.d.mts.map
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  export { log } from "./log.common.js";
4
- //# sourceMappingURL=log.js.map
4
+ //# sourceMappingURL=log-web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-web.mjs","sourceRoot":"","sources":["../../../src/logger/log-web.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { log } from \"./log.common.js\";\n"]}
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  import debug from "./debug.js";
4
+ import { getEnvironmentVariable } from "../env-react-native.mjs";
4
5
  const TYPESPEC_RUNTIME_LOG_LEVELS = ["verbose", "info", "warning", "error"];
5
6
  const levelMap = {
6
7
  verbose: 400,
@@ -23,8 +24,7 @@ function isTypeSpecRuntimeLogLevel(level) {
23
24
  */
24
25
  export function createLoggerContext(options) {
25
26
  const registeredLoggers = new Set();
26
- const logLevelFromEnv = (typeof process !== "undefined" && process.env && process.env[options.logLevelEnvVarName]) ||
27
- undefined;
27
+ const logLevelFromEnv = getEnvironmentVariable(options.logLevelEnvVarName);
28
28
  let logLevel;
29
29
  const clientLogger = debug(options.namespace);
30
30
  clientLogger.log = (...args) => {
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,YAAY,CAAC;AAiG/B,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,S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ensed under the MIT License.\n\nimport debug from \"./debug.js\";\n\nimport type { Debugger } from \"./debug.js\";\nexport type { Debugger };\n\n/**\n * The log levels supported by the logger.\n * The log levels in order of most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport type TypeSpecRuntimeLogLevel = \"verbose\" | \"info\" | \"warning\" | \"error\";\n\n/**\n * A TypeSpecRuntimeClientLogger is a function that can log to an appropriate severity level.\n */\nexport type TypeSpecRuntimeClientLogger = Debugger;\n\n/**\n * Defines the methods available on the SDK-facing logger.\n */\nexport interface TypeSpecRuntimeLogger {\n /**\n * Used for failures the program is unlikely to recover from,\n * such as Out of Memory.\n */\n error: Debugger;\n /**\n * Used when a function fails to perform its intended task.\n * Usually this means the function will throw an exception.\n * Not used for self-healing events (e.g. automatic retry)\n */\n warning: Debugger;\n /**\n * Used when a function operates normally.\n */\n info: Debugger;\n /**\n * Used for detailed troubleshooting scenarios. This is\n * intended for use by developers / system administrators\n * for diagnosing specific failures.\n */\n verbose: Debugger;\n}\n\n/**\n * todo doc\n */\nexport interface LoggerContext {\n /**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\n setLogLevel(logLevel?: TypeSpecRuntimeLogLevel): void;\n\n /**\n * Retrieves the currently specified log level.\n */\n getLogLevel(): TypeSpecRuntimeLogLevel | undefined;\n\n /**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\n createClientLogger(namespace: string): TypeSpecRuntimeLogger;\n\n /**\n * The TypeSpecRuntimeClientLogger provides a mechanism for overriding where logs are output to.\n * By default, logs are sent to stderr.\n * Override the `log` method to redirect logs to another location.\n */\n logger: TypeSpecRuntimeClientLogger;\n}\n\n/**\n * Option for creating a TypeSpecRuntimeLoggerContext.\n */\nexport interface CreateLoggerContextOptions {\n /**\n * The name of the environment variable to check for the log level.\n */\n logLevelEnvVarName: string;\n\n /**\n * The namespace of the logger.\n */\n namespace: string;\n}\n\nconst TYPESPEC_RUNTIME_LOG_LEVELS = [\"verbose\", \"info\", \"warning\", \"error\"];\n\ntype DebuggerWithLogLevel = Debugger & { level: TypeSpecRuntimeLogLevel };\n\nconst levelMap = {\n verbose: 400,\n info: 300,\n warning: 200,\n error: 100,\n};\n\nfunction patchLogMethod(\n parent: TypeSpecRuntimeClientLogger,\n child: TypeSpecRuntimeClientLogger | DebuggerWithLogLevel,\n): void {\n child.log = (...args) => {\n parent.log(...args);\n };\n}\n\nfunction isTypeSpecRuntimeLogLevel(level: string): level is TypeSpecRuntimeLogLevel {\n return TYPESPEC_RUNTIME_LOG_LEVELS.includes(level);\n}\n\n/**\n * Creates a logger context base on the provided options.\n * @param options - The options for creating a logger context.\n * @returns The logger context.\n */\nexport function createLoggerContext(options: CreateLoggerContextOptions): LoggerContext {\n const registeredLoggers = new Set<DebuggerWithLogLevel>();\n const logLevelFromEnv =\n (typeof process !== \"undefined\" && process.env && process.env[options.logLevelEnvVarName]) ||\n undefined;\n\n let logLevel: TypeSpecRuntimeLogLevel | undefined;\n\n const clientLogger: TypeSpecRuntimeClientLogger = debug(options.namespace);\n clientLogger.log = (...args) => {\n debug.log(...args);\n };\n\n function contextSetLogLevel(level?: TypeSpecRuntimeLogLevel): void {\n if (level && !isTypeSpecRuntimeLogLevel(level)) {\n throw new Error(\n `Unknown log level '${level}'. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\",\")}`,\n );\n }\n logLevel = level;\n\n const enabledNamespaces = [];\n for (const logger of registeredLoggers) {\n if (shouldEnable(logger)) {\n enabledNamespaces.push(logger.namespace);\n }\n }\n\n debug.enable(enabledNamespaces.join(\",\"));\n }\n\n if (logLevelFromEnv) {\n // avoid calling setLogLevel because we don't want a mis-set environment variable to crash\n if (isTypeSpecRuntimeLogLevel(logLevelFromEnv)) {\n contextSetLogLevel(logLevelFromEnv);\n } else {\n console.error(\n `${options.logLevelEnvVarName} set to unknown log level '${logLevelFromEnv}'; logging is not enabled. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\n \", \",\n )}.`,\n );\n }\n }\n\n function shouldEnable(logger: DebuggerWithLogLevel): boolean {\n return Boolean(logLevel && levelMap[logger.level] <= levelMap[logLevel]);\n }\n\n function createLogger(\n parent: TypeSpecRuntimeClientLogger,\n level: TypeSpecRuntimeLogLevel,\n ): DebuggerWithLogLevel {\n const logger: DebuggerWithLogLevel = Object.assign(parent.extend(level), {\n level,\n });\n\n patchLogMethod(parent, logger);\n\n if (shouldEnable(logger)) {\n const enabledNamespaces = debug.disable();\n debug.enable(enabledNamespaces + \",\" + logger.namespace);\n }\n\n registeredLoggers.add(logger);\n\n return logger;\n }\n\n function contextGetLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return logLevel;\n }\n\n function contextCreateClientLogger(namespace: string): TypeSpecRuntimeLogger {\n const clientRootLogger: TypeSpecRuntimeClientLogger = clientLogger.extend(namespace);\n patchLogMethod(clientLogger, clientRootLogger);\n return {\n error: createLogger(clientRootLogger, \"error\"),\n warning: createLogger(clientRootLogger, \"warning\"),\n info: createLogger(clientRootLogger, \"info\"),\n verbose: createLogger(clientRootLogger, \"verbose\"),\n };\n }\n\n return {\n setLogLevel: contextSetLogLevel,\n getLogLevel: contextGetLogLevel,\n createClientLogger: contextCreateClientLogger,\n logger: clientLogger,\n };\n}\n\nconst context = createLoggerContext({\n logLevelEnvVarName: \"TYPESPEC_RUNTIME_LOG_LEVEL\",\n namespace: \"typeSpecRuntime\",\n});\n\n/**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const TypeSpecRuntimeLogger: TypeSpecRuntimeClientLogger = context.logger;\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function setLogLevel(logLevel?: TypeSpecRuntimeLogLevel): void {\n context.setLogLevel(logLevel);\n}\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function getLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return context.getLogLevel();\n}\n\n/**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\nexport function createClientLogger(namespace: string): TypeSpecRuntimeLogger {\n return context.createClientLogger(namespace);\n}\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAiGvD,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAI5E,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,GAAG;IACZ,IAAI,EAAE,GAAG;IACT,OAAO,EAAE,GAAG;IACZ,KAAK,EAAE,GAAG;CACX,CAAC;AAEF,SAAS,cAAc,CACrB,MAAmC,EACnC,KAAyD;IAEzD,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,KAAa;IAC9C,OAAO,2BAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmC;IACrE,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1D,MAAM,eAAe,GAAG,sBAAsB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE3E,IAAI,QAA6C,CAAC;IAElD,MAAM,YAAY,GAAgC,KA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EH;;;;;;;;GAQG;AACH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAgC,OAAO,CAAC,MAAM,CAAC;AAEjF;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAkC;IAC5D,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,OAAO,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport debug from \"./debug.js\";\nimport { getEnvironmentVariable } from \"#platform/env\";\n\nimport type { Debugger } from \"./debug.js\";\nexport type { Debugger };\n\n/**\n * The log levels supported by the logger.\n * The log levels in order of most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport type TypeSpecRuntimeLogLevel = \"verbose\" | \"info\" | \"warning\" | \"error\";\n\n/**\n * A TypeSpecRuntimeClientLogger is a function that can log to an appropriate severity level.\n */\nexport type TypeSpecRuntimeClientLogger = Debugger;\n\n/**\n * Defines the methods available on the SDK-facing logger.\n */\nexport interface TypeSpecRuntimeLogger {\n /**\n * Used for failures the program is unlikely to recover from,\n * such as Out of Memory.\n */\n error: Debugger;\n /**\n * Used when a function fails to perform its intended task.\n * Usually this means the function will throw an exception.\n * Not used for self-healing events (e.g. automatic retry)\n */\n warning: Debugger;\n /**\n * Used when a function operates normally.\n */\n info: Debugger;\n /**\n * Used for detailed troubleshooting scenarios. This is\n * intended for use by developers / system administrators\n * for diagnosing specific failures.\n */\n verbose: Debugger;\n}\n\n/**\n * todo doc\n */\nexport interface LoggerContext {\n /**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\n setLogLevel(logLevel?: TypeSpecRuntimeLogLevel): void;\n\n /**\n * Retrieves the currently specified log level.\n */\n getLogLevel(): TypeSpecRuntimeLogLevel | undefined;\n\n /**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\n createClientLogger(namespace: string): TypeSpecRuntimeLogger;\n\n /**\n * The TypeSpecRuntimeClientLogger provides a mechanism for overriding where logs are output to.\n * By default, logs are sent to stderr.\n * Override the `log` method to redirect logs to another location.\n */\n logger: TypeSpecRuntimeClientLogger;\n}\n\n/**\n * Option for creating a TypeSpecRuntimeLoggerContext.\n */\nexport interface CreateLoggerContextOptions {\n /**\n * The name of the environment variable to check for the log level.\n */\n logLevelEnvVarName: string;\n\n /**\n * The namespace of the logger.\n */\n namespace: string;\n}\n\nconst TYPESPEC_RUNTIME_LOG_LEVELS = [\"verbose\", \"info\", \"warning\", \"error\"];\n\ntype DebuggerWithLogLevel = Debugger & { level: TypeSpecRuntimeLogLevel };\n\nconst levelMap = {\n verbose: 400,\n info: 300,\n warning: 200,\n error: 100,\n};\n\nfunction patchLogMethod(\n parent: TypeSpecRuntimeClientLogger,\n child: TypeSpecRuntimeClientLogger | DebuggerWithLogLevel,\n): void {\n child.log = (...args) => {\n parent.log(...args);\n };\n}\n\nfunction isTypeSpecRuntimeLogLevel(level: string): level is TypeSpecRuntimeLogLevel {\n return TYPESPEC_RUNTIME_LOG_LEVELS.includes(level);\n}\n\n/**\n * Creates a logger context base on the provided options.\n * @param options - The options for creating a logger context.\n * @returns The logger context.\n */\nexport function createLoggerContext(options: CreateLoggerContextOptions): LoggerContext {\n const registeredLoggers = new Set<DebuggerWithLogLevel>();\n const logLevelFromEnv = getEnvironmentVariable(options.logLevelEnvVarName);\n\n let logLevel: TypeSpecRuntimeLogLevel | undefined;\n\n const clientLogger: TypeSpecRuntimeClientLogger = debug(options.namespace);\n clientLogger.log = (...args) => {\n debug.log(...args);\n };\n\n function contextSetLogLevel(level?: TypeSpecRuntimeLogLevel): void {\n if (level && !isTypeSpecRuntimeLogLevel(level)) {\n throw new Error(\n `Unknown log level '${level}'. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\",\")}`,\n );\n }\n logLevel = level;\n\n const enabledNamespaces = [];\n for (const logger of registeredLoggers) {\n if (shouldEnable(logger)) {\n enabledNamespaces.push(logger.namespace);\n }\n }\n\n debug.enable(enabledNamespaces.join(\",\"));\n }\n\n if (logLevelFromEnv) {\n // avoid calling setLogLevel because we don't want a mis-set environment variable to crash\n if (isTypeSpecRuntimeLogLevel(logLevelFromEnv)) {\n contextSetLogLevel(logLevelFromEnv);\n } else {\n console.error(\n `${options.logLevelEnvVarName} set to unknown log level '${logLevelFromEnv}'; logging is not enabled. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\n \", \",\n )}.`,\n );\n }\n }\n\n function shouldEnable(logger: DebuggerWithLogLevel): boolean {\n return Boolean(logLevel && levelMap[logger.level] <= levelMap[logLevel]);\n }\n\n function createLogger(\n parent: TypeSpecRuntimeClientLogger,\n level: TypeSpecRuntimeLogLevel,\n ): DebuggerWithLogLevel {\n const logger: DebuggerWithLogLevel = Object.assign(parent.extend(level), {\n level,\n });\n\n patchLogMethod(parent, logger);\n\n if (shouldEnable(logger)) {\n const enabledNamespaces = debug.disable();\n debug.enable(enabledNamespaces + \",\" + logger.namespace);\n }\n\n registeredLoggers.add(logger);\n\n return logger;\n }\n\n function contextGetLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return logLevel;\n }\n\n function contextCreateClientLogger(namespace: string): TypeSpecRuntimeLogger {\n const clientRootLogger: TypeSpecRuntimeClientLogger = clientLogger.extend(namespace);\n patchLogMethod(clientLogger, clientRootLogger);\n return {\n error: createLogger(clientRootLogger, \"error\"),\n warning: createLogger(clientRootLogger, \"warning\"),\n info: createLogger(clientRootLogger, \"info\"),\n verbose: createLogger(clientRootLogger, \"verbose\"),\n };\n }\n\n return {\n setLogLevel: contextSetLogLevel,\n getLogLevel: contextGetLogLevel,\n createClientLogger: contextCreateClientLogger,\n logger: clientLogger,\n };\n}\n\nconst context = createLoggerContext({\n logLevelEnvVarName: \"TYPESPEC_RUNTIME_LOG_LEVEL\",\n namespace: \"typeSpecRuntime\",\n});\n\n/**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const TypeSpecRuntimeLogger: TypeSpecRuntimeClientLogger = context.logger;\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function setLogLevel(logLevel?: TypeSpecRuntimeLogLevel): void {\n context.setLogLevel(logLevel);\n}\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function getLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return context.getLogLevel();\n}\n\n/**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\nexport function createClientLogger(namespace: string): TypeSpecRuntimeLogger {\n return context.createClientLogger(namespace);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  import { createHttpHeaders } from "./httpHeaders.js";
4
- import { randomUUID } from "./util/uuidUtils.js";
4
+ import { randomUUID } from "./util/uuidUtils-react-native.mjs";
5
5
  class PipelineRequestImpl {
6
6
  url;
7
7
  method;
@@ -1 +1 @@
1
- {"version":3,"file":"pipelineRequest.js","sourceRoot":"","sources":["../../src/pipelineRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAyHjD,MAAM,mBAAmB;IACh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BAAkB,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,EAAE,CAAC;QACnD,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,IAAI,KAAK,CAAC;QACxE,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,KAAK,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n FormDataMap,\n HttpHeaders,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n ProxySettings,\n RequestBodyType,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { randomUUID } from \"./util/uuidUtils.js\";\nimport type { AuthScheme } from \"./auth/schemes.js\";\n\n/**\n * Settings to initialize a request.\n * Almost equivalent to Partial<PipelineRequest>, but url is mandatory.\n */\nexport interface PipelineRequestOptions {\n /**\n * The URL to make the request to.\n */\n url: string;\n\n /**\n * The HTTP method to use when making the request.\n */\n method?: HttpMethods;\n\n /**\n * The HTTP headers to use when making the request.\n */\n headers?: HttpHeaders;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n * If the request is terminated, an `AbortError` is thrown.\n * Defaults to 0, which disables the timeout.\n */\n timeout?: number;\n\n /**\n * If credentials (cookies) should be sent along during an XHR.\n * Defaults to false.\n */\n withCredentials?: boolean;\n\n /**\n * A unique identifier for the request. Used for logging and tracing.\n */\n requestId?: string;\n\n /**\n * The HTTP body content (if any)\n */\n body?: RequestBodyType;\n\n /**\n * Body for a multipart request.\n */\n multipartBody?: MultipartRequestBody;\n\n /**\n * To simulate a browser form post\n */\n formData?: FormDataMap;\n\n /**\n * A list of response status codes whose corresponding PipelineResponse body should be treated as a stream.\n */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable use of the Streams API. If this option is set and streaming is used\n * (see `streamResponseStatusCodes`), the response will have a property `browserStream` instead of\n * `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\n\n /**\n * Proxy configuration.\n */\n proxySettings?: ProxySettings;\n\n /**\n * If the connection should not be reused.\n */\n disableKeepAlive?: boolean;\n\n /**\n * Used to abort the request later.\n */\n abortSignal?: AbortSignal;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Callback which fires upon download progress. */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n\n /**\n * List of authentication schemes used for this specific request.\n * These schemes define how the request will be authenticated.\n *\n * If values are provided, these schemes override the client level authentication schemes.\n * If an empty array is provided, it explicitly specifies no authentication for the request.\n * If not provided at the request level, the client level authentication schemes will be used.\n */\n authSchemes?: AuthScheme[];\n\n /**\n * Additional options to set on the request. This provides a way to override\n * existing ones or provide request properties that are not declared.\n *\n * For possible valid properties, see\n * - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback\n * - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit\n *\n * WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.\n */\n requestOverrides?: Record<string, unknown>;\n}\n\nclass PipelineRequestImpl implements PipelineRequest {\n public url: string;\n public method: HttpMethods;\n public headers: HttpHeaders;\n public timeout: number;\n public withCredentials: boolean;\n public body?: RequestBodyType;\n public multipartBody?: MultipartRequestBody;\n public formData?: FormDataMap;\n public streamResponseStatusCodes?: Set<number>;\n public enableBrowserStreams: boolean;\n\n public proxySettings?: ProxySettings;\n public disableKeepAlive: boolean;\n public abortSignal?: AbortSignal;\n public requestId: string;\n public allowInsecureConnection?: boolean;\n public onUploadProgress?: (progress: TransferProgressEvent) => void;\n public onDownloadProgress?: (progress: TransferProgressEvent) => void;\n public requestOverrides?: Record<string, unknown>;\n public authSchemes?: AuthScheme[];\n\n constructor(options: PipelineRequestOptions) {\n this.url = options.url;\n this.body = options.body;\n this.headers = options.headers ?? createHttpHeaders();\n this.method = options.method ?? \"GET\";\n this.timeout = options.timeout ?? 0;\n this.multipartBody = options.multipartBody;\n this.formData = options.formData;\n this.disableKeepAlive = options.disableKeepAlive ?? false;\n this.proxySettings = options.proxySettings;\n this.streamResponseStatusCodes = options.streamResponseStatusCodes;\n this.withCredentials = options.withCredentials ?? false;\n this.abortSignal = options.abortSignal;\n this.onUploadProgress = options.onUploadProgress;\n this.onDownloadProgress = options.onDownloadProgress;\n this.requestId = options.requestId || randomUUID();\n this.allowInsecureConnection = options.allowInsecureConnection ?? false;\n this.enableBrowserStreams = options.enableBrowserStreams ?? false;\n this.requestOverrides = options.requestOverrides;\n this.authSchemes = options.authSchemes;\n }\n}\n\n/**\n * Creates a new pipeline request with the given options.\n * This method is to allow for the easy setting of default values and not required.\n * @param options - The options to create the request with.\n */\nexport function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest {\n return new PipelineRequestImpl(options);\n}\n"]}
1
+ {"version":3,"file":"pipelineRequest.js","sourceRoot":"","sources":["../../src/pipelineRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAyH5C,MAAM,mBAAmB;IAChB,GAAG,CAAS;IACZ,MAAM,CAAc;IACpB,OAAO,CAAc;IACrB,OAAO,CAAS;IAChB,eAAe,CAAU;IACzB,IAAI,CAAmB;IACvB,aAAa,CAA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O,CAAC,uBAAuB,IAAI,KAAK,CAAC;QACxE,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,KAAK,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n FormDataMap,\n HttpHeaders,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n ProxySettings,\n RequestBodyType,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { randomUUID } from \"#platform/uuid\";\nimport type { AuthScheme } from \"./auth/schemes.js\";\n\n/**\n * Settings to initialize a request.\n * Almost equivalent to Partial<PipelineRequest>, but url is mandatory.\n */\nexport interface PipelineRequestOptions {\n /**\n * The URL to make the request to.\n */\n url: string;\n\n /**\n * The HTTP method to use when making the request.\n */\n method?: HttpMethods;\n\n /**\n * The HTTP headers to use when making the request.\n */\n headers?: HttpHeaders;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n * If the request is terminated, an `AbortError` is thrown.\n * Defaults to 0, which disables the timeout.\n */\n timeout?: number;\n\n /**\n * If credentials (cookies) should be sent along during an XHR.\n * Defaults to false.\n */\n withCredentials?: boolean;\n\n /**\n * A unique identifier for the request. Used for logging and tracing.\n */\n requestId?: string;\n\n /**\n * The HTTP body content (if any)\n */\n body?: RequestBodyType;\n\n /**\n * Body for a multipart request.\n */\n multipartBody?: MultipartRequestBody;\n\n /**\n * To simulate a browser form post\n */\n formData?: FormDataMap;\n\n /**\n * A list of response status codes whose corresponding PipelineResponse body should be treated as a stream.\n */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable use of the Streams API. If this option is set and streaming is used\n * (see `streamResponseStatusCodes`), the response will have a property `browserStream` instead of\n * `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\n\n /**\n * Proxy configuration.\n */\n proxySettings?: ProxySettings;\n\n /**\n * If the connection should not be reused.\n */\n disableKeepAlive?: boolean;\n\n /**\n * Used to abort the request later.\n */\n abortSignal?: AbortSignal;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Callback which fires upon download progress. */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n\n /**\n * List of authentication schemes used for this specific request.\n * These schemes define how the request will be authenticated.\n *\n * If values are provided, these schemes override the client level authentication schemes.\n * If an empty array is provided, it explicitly specifies no authentication for the request.\n * If not provided at the request level, the client level authentication schemes will be used.\n */\n authSchemes?: AuthScheme[];\n\n /**\n * Additional options to set on the request. This provides a way to override\n * existing ones or provide request properties that are not declared.\n *\n * For possible valid properties, see\n * - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback\n * - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit\n *\n * WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.\n */\n requestOverrides?: Record<string, unknown>;\n}\n\nclass PipelineRequestImpl implements PipelineRequest {\n public url: string;\n public method: HttpMethods;\n public headers: HttpHeaders;\n public timeout: number;\n public withCredentials: boolean;\n public body?: RequestBodyType;\n public multipartBody?: MultipartRequestBody;\n public formData?: FormDataMap;\n public streamResponseStatusCodes?: Set<number>;\n public enableBrowserStreams: boolean;\n\n public proxySettings?: ProxySettings;\n public disableKeepAlive: boolean;\n public abortSignal?: AbortSignal;\n public requestId: string;\n public allowInsecureConnection?: boolean;\n public onUploadProgress?: (progress: TransferProgressEvent) => void;\n public onDownloadProgress?: (progress: TransferProgressEvent) => void;\n public requestOverrides?: Record<string, unknown>;\n public authSchemes?: AuthScheme[];\n\n constructor(options: PipelineRequestOptions) {\n this.url = options.url;\n this.body = options.body;\n this.headers = options.headers ?? createHttpHeaders();\n this.method = options.method ?? \"GET\";\n this.timeout = options.timeout ?? 0;\n this.multipartBody = options.multipartBody;\n this.formData = options.formData;\n this.disableKeepAlive = options.disableKeepAlive ?? false;\n this.proxySettings = options.proxySettings;\n this.streamResponseStatusCodes = options.streamResponseStatusCodes;\n this.withCredentials = options.withCredentials ?? false;\n this.abortSignal = options.abortSignal;\n this.onUploadProgress = options.onUploadProgress;\n this.onDownloadProgress = options.onDownloadProgress;\n this.requestId = options.requestId || randomUUID();\n this.allowInsecureConnection = options.allowInsecureConnection ?? false;\n this.enableBrowserStreams = options.enableBrowserStreams ?? false;\n this.requestOverrides = options.requestOverrides;\n this.authSchemes = options.authSchemes;\n }\n}\n\n/**\n * Creates a new pipeline request with the given options.\n * This method is to allow for the easy setting of default values and not required.\n * @param options - The options to create the request with.\n */\nexport function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest {\n return new PipelineRequestImpl(options);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { stringToUint8Array, uint8ArrayToString } from "../../util/bytesEncoding.js";
3
+ import { stringToUint8Array, uint8ArrayToString } from "../../util/bytesEncoding-web.mjs";
4
4
  import { ensureSecureConnection } from "./checkInsecureConnection.js";
5
5
  /**
6
6
  * Name of the Basic Authentication Policy
@@ -1 +1 @@
1
- {"version":3,"file":"basicAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/basicAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAqB1E;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAyC;IAEzC,OAAO;QACL,IAAI,EAAE,6BAA6B;QACnC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAC/D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,CACjD,CAAC;YAEF,+EAA+E;YAC/E,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAClD,MAAM,WAAW,GAAG,kBAAkB,CACpC,kBAAkB,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,OAAO,CAAC,EACtD,QAAQ,CACT,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BasicCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { stringToUint8Array, uint8ArrayToString } from \"../../util/bytesEncoding.js\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the Basic Authentication Policy\n */\nexport const basicAuthenticationPolicyName = \"bearerAuthenticationPolicy\";\n\n/**\n * Options for configuring the basic authentication policy\n */\nexport interface BasicAuthenticationPolicyOptions {\n /**\n * The credential used to authenticate requests\n */\n credential: BasicCredential;\n /**\n * Optional authentication schemes to use. If not provided, schemes from the request will be used.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds basic authentication to requests\n */\nexport function basicAuthenticationPolicy(\n options: BasicAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: basicAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find(\n (x) => x.kind === \"http\" && x.scheme === \"basic\",\n );\n\n // Skip adding authentication header if no basic authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n\n const { username, password } = options.credential;\n const headerValue = uint8ArrayToString(\n stringToUint8Array(`${username}:${password}`, \"utf-8\"),\n \"base64\",\n );\n request.headers.set(\"Authorization\", `Basic ${headerValue}`);\n return next(request);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"basicAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/basicAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAqB1E;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAyC;IAEzC,OAAO;QACL,IAAI,EAAE,6BAA6B;QACnC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAC/D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,CACjD,CAAC;YAEF,+EAA+E;YAC/E,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAClD,MAAM,WAAW,GAAG,kBAAkB,CACpC,kBAAkB,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,OAAO,CAAC,EACtD,QAAQ,CACT,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BasicCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { stringToUint8Array, uint8ArrayToString } from \"#platform/bytesEncoding\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the Basic Authentication Policy\n */\nexport const basicAuthenticationPolicyName = \"bearerAuthenticationPolicy\";\n\n/**\n * Options for configuring the basic authentication policy\n */\nexport interface BasicAuthenticationPolicyOptions {\n /**\n * The credential used to authenticate requests\n */\n credential: BasicCredential;\n /**\n * Optional authentication schemes to use. If not provided, schemes from the request will be used.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds basic authentication to requests\n */\nexport function basicAuthenticationPolicy(\n options: BasicAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: basicAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find(\n (x) => x.kind === \"http\" && x.scheme === \"basic\",\n );\n\n // Skip adding authentication header if no basic authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n\n const { username, password } = options.credential;\n const headerValue = uint8ArrayToString(\n stringToUint8Array(`${username}:${password}`, \"utf-8\"),\n \"base64\",\n );\n request.headers.set(\"Authorization\", `Basic ${headerValue}`);\n return next(request);\n },\n };\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  import { logger } from "../../log.js";
4
+ import { emitNodeWarning } from "../../env-react-native.mjs";
4
5
  // Ensure the warining is only emitted once
5
6
  let insecureConnectionWarningEmmitted = false;
6
7
  /**
@@ -28,9 +29,9 @@ function allowInsecureConnection(request, options) {
28
29
  function emitInsecureConnectionWarning() {
29
30
  const warning = "Sending token over insecure transport. Assume any token issued is compromised.";
30
31
  logger.warning(warning);
31
- if (typeof process?.emitWarning === "function" && !insecureConnectionWarningEmmitted) {
32
+ if (!insecureConnectionWarningEmmitted) {
32
33
  insecureConnectionWarningEmmitted = true;
33
- process.emitWarning(warning);
34
+ emitNodeWarning(warning);
34
35
  }
35
36
  }
36
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"checkInsecureConnection.js","sourceRoot":"","sources":["../../../../src/policies/auth/checkInsecureConnection.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,2CAA2C;AAC3C,IAAI,iCAAiC,GAAG,KAAK,CAAC;AAE9C;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAC9B,OAAwB,EACxB,OAA8C;IAE9C,IAAI,OAAO,CAAC,uBAAuB,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,6BAA6B;IACpC,MAAM,OAAO,GAAG,gFAAgF,CAAC;IAEjG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAExB,IAAI,OAAO,OAAO,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC,iCAAiC,EAAE,CAAC;QACrF,iCAAiC,GAAG,IAAI,CAAC;QACzC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAwB,EACxB,OAA8C;IAE9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,IAAI,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YAC9C,6BAA6B,EAAE,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest } from \"../../interfaces.js\";\nimport { logger } from \"../../log.js\";\n\n// Ensure the warining is only emitted once\nlet insecureConnectionWarningEmmitted = false;\n\n/**\n * Checks if the request is allowed to be sent over an insecure connection.\n *\n * A request is allowed to be sent over an insecure connection when:\n * - The `allowInsecureConnection` option is set to `true`.\n * - The request has the `allowInsecureConnection` property set to `true`.\n * - The request is being sent to `localhost` or `127.0.0.1`\n */\nfunction allowInsecureConnection(\n request: PipelineRequest,\n options: { allowInsecureConnection?: boolean },\n): boolean {\n if (options.allowInsecureConnection && request.allowInsecureConnection) {\n const url = new URL(request.url);\n if (url.hostname === \"localhost\" || url.hostname === \"127.0.0.1\") {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Logs a warning about sending a token over an insecure connection.\n *\n * This function will emit a node warning once, but log the warning every time.\n */\nfunction emitInsecureConnectionWarning(): void {\n const warning = \"Sending token over insecure transport. Assume any token issued is compromised.\";\n\n logger.warning(warning);\n\n if (typeof process?.emitWarning === \"function\" && !insecureConnectionWarningEmmitted) {\n insecureConnectionWarningEmmitted = true;\n process.emitWarning(warning);\n }\n}\n\n/**\n * Ensures that authentication is only allowed over HTTPS unless explicitly allowed.\n * Throws an error if the connection is not secure and not explicitly allowed.\n */\nexport function ensureSecureConnection(\n request: PipelineRequest,\n options: { allowInsecureConnection?: boolean },\n): void {\n if (!request.url.toLowerCase().startsWith(\"https://\")) {\n if (allowInsecureConnection(request, options)) {\n emitInsecureConnectionWarning();\n } else {\n throw new Error(\n \"Authentication is not permitted for non-TLS protected (non-https) URLs when allowInsecureConnection is false.\",\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"checkInsecureConnection.js","sourceRoot":"","sources":["../../../../src/policies/auth/checkInsecureConnection.ts"],"names":[],"mappings":"AAAA,u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Request } from \"../../interfaces.js\";\nimport { logger } from \"../../log.js\";\nimport { emitNodeWarning } from \"#platform/env\";\n\n// Ensure the warining is only emitted once\nlet insecureConnectionWarningEmmitted = false;\n\n/**\n * Checks if the request is allowed to be sent over an insecure connection.\n *\n * A request is allowed to be sent over an insecure connection when:\n * - The `allowInsecureConnection` option is set to `true`.\n * - The request has the `allowInsecureConnection` property set to `true`.\n * - The request is being sent to `localhost` or `127.0.0.1`\n */\nfunction allowInsecureConnection(\n request: PipelineRequest,\n options: { allowInsecureConnection?: boolean },\n): boolean {\n if (options.allowInsecureConnection && request.allowInsecureConnection) {\n const url = new URL(request.url);\n if (url.hostname === \"localhost\" || url.hostname === \"127.0.0.1\") {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Logs a warning about sending a token over an insecure connection.\n *\n * This function will emit a node warning once, but log the warning every time.\n */\nfunction emitInsecureConnectionWarning(): void {\n const warning = \"Sending token over insecure transport. Assume any token issued is compromised.\";\n\n logger.warning(warning);\n\n if (!insecureConnectionWarningEmmitted) {\n insecureConnectionWarningEmmitted = true;\n emitNodeWarning(warning);\n }\n}\n\n/**\n * Ensures that authentication is only allowed over HTTPS unless explicitly allowed.\n * Throws an error if the connection is not secure and not explicitly allowed.\n */\nexport function ensureSecureConnection(\n request: PipelineRequest,\n options: { allowInsecureConnection?: boolean },\n): void {\n if (!request.url.toLowerCase().startsWith(\"https://\")) {\n if (allowInsecureConnection(request, options)) {\n emitInsecureConnectionWarning();\n } else {\n throw new Error(\n \"Authentication is not permitted for non-TLS protected (non-https) URLs when allowInsecureConnection is false.\",\n );\n }\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { PipelinePolicy } from "../pipeline.js";
2
+ export declare const decompressResponsePolicyName = "decompressResponsePolicy";
3
+ /**
4
+ * decompressResponsePolicy is not supported in the browser and attempting
5
+ * to use it will raise an error.
6
+ */
7
+ export declare function decompressResponsePolicy(): PipelinePolicy;
8
+ //# sourceMappingURL=decompressResponsePolicy-web.d.mts.map
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export const decompressResponsePolicyName = "decompressResponsePolicy";
4
+ /**
5
+ * decompressResponsePolicy is not supported in the browser and attempting
6
+ * to use it will raise an error.
7
+ */
8
+ export function decompressResponsePolicy() {
9
+ throw new Error("decompressResponsePolicy is not supported in browser environment");
10
+ }
11
+ //# sourceMappingURL=decompressResponsePolicy-web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompressResponsePolicy-web.mjs","sourceRoot":"","sources":["../../../src/policies/decompressResponsePolicy-web.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;AACtF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/*\n * NOTE: When moving this file, please update \"browser\" section in package.json\n */\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nexport const decompressResponsePolicyName = \"decompressResponsePolicy\";\n\n/**\n * decompressResponsePolicy is not supported in the browser and attempting\n * to use it will raise an error.\n */\nexport function decompressResponsePolicy(): PipelinePolicy {\n throw new Error(\"decompressResponsePolicy is not supported in browser environment\");\n}\n"]}
@@ -1,20 +1,12 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { stringToUint8Array } from "../util/bytesEncoding.js";
4
- import { isNodeLike } from "../util/checkEnvironment.js";
3
+ import { stringToUint8Array } from "../util/bytesEncoding-web.mjs";
4
+ import { convertBodyToFormDataMap } from "../formData-web.mjs";
5
5
  import { createHttpHeaders } from "../httpHeaders.js";
6
6
  /**
7
7
  * The programmatic identifier of the formDataPolicy.
8
8
  */
9
9
  export const formDataPolicyName = "formDataPolicy";
10
- function formDataToFormDataMap(formData) {
11
- const formDataMap = {};
12
- for (const [key, value] of formData.entries()) {
13
- formDataMap[key] ??= [];
14
- formDataMap[key].push(value);
15
- }
16
- return formDataMap;
17
- }
18
10
  /**
19
11
  * A policy that encodes FormData on the request into the body.
20
12
  */
@@ -22,8 +14,9 @@ export function formDataPolicy() {
22
14
  return {
23
15
  name: formDataPolicyName,
24
16
  async sendRequest(request, next) {
25
- if (isNodeLike && typeof FormData !== "undefined" && request.body instanceof FormData) {
26
- request.formData = formDataToFormDataMap(request.body);
17
+ const converted = convertBodyToFormDataMap(request.body);
18
+ if (converted) {
19
+ request.formData = converted;
27
20
  request.body = undefined;
28
21
  }
29
22
  if (request.formData) {
@@ -1 +1 @@
1
- {"version":3,"file":"formDataPolicy.js","sourceRoot":"","sources":["../../../src/policies/formDataPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWtD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD,SAAS,qBAAqB,CAAC,QAAkB;IAC/C,MAAM,WAAW,GAAgB,EAAE,CAAC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9C,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACvB,WAAW,CAAC,GAAG,CAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;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M,QAAQ,GAAI,KAAc,CAAC,IAAI,IAAI,MAAM,CAAC;gBAChD,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;gBACpC,OAAO,CAAC,GAAG,CACT,qBAAqB,EACrB,oBAAoB,SAAS,gBAAgB,QAAQ,GAAG,CACzD,CAAC;gBAEF,8EAA8E;gBAC9E,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,IAAI,0BAA0B,CAAC,CAAC;gBAEtE,KAAK,CAAC,IAAI,CAAC;oBACT,OAAO;oBACP,IAAI,EAAE,KAAK;iBACZ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,aAAa,GAAG,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isNodeLike } from \"../util/checkEnvironment.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport type {\n BodyPart,\n FormDataMap,\n FormDataValue,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\n/**\n * The programmatic identifier of the formDataPolicy.\n */\nexport const formDataPolicyName = \"formDataPolicy\";\n\nfunction formDataToFormDataMap(formData: FormData): FormDataMap {\n const formDataMap: FormDataMap = {};\n for (const [key, value] of formData.entries()) {\n formDataMap[key] ??= [];\n (formDataMap[key] as FormDataValue[]).push(value);\n }\n return formDataMap;\n}\n\n/**\n * A policy that encodes FormData on the request into the body.\n */\nexport function formDataPolicy(): PipelinePolicy {\n return {\n name: formDataPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (isNodeLike && typeof FormData !== \"undefined\" && request.body instanceof FormData) {\n request.formData = formDataToFormDataMap(request.body);\n request.body = undefined;\n }\n\n if (request.formData) {\n const contentType = request.headers.get(\"Content-Type\");\n if (contentType && contentType.indexOf(\"application/x-www-form-urlencoded\") !== -1) {\n request.body = wwwFormUrlEncode(request.formData);\n } else {\n await prepareFormData(request.formData, request);\n }\n\n request.formData = undefined;\n }\n return next(request);\n },\n };\n}\n\nfunction wwwFormUrlEncode(formData: FormDataMap): string {\n const urlSearchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(formData)) {\n if (Array.isArray(value)) {\n for (const subValue of value) {\n urlSearchParams.append(key, subValue.toString());\n }\n } else {\n urlSearchParams.append(key, value.toString());\n }\n }\n return urlSearchParams.toString();\n}\n\nasync function prepareFormData(formData: FormDataMap, request: PipelineRequest): Promise<void> {\n // validate content type (multipart/form-data)\n const contentType = request.headers.get(\"Content-Type\");\n if (contentType && !contentType.startsWith(\"multipart/form-data\")) {\n // content type is specified and is not multipart/form-data. Exit.\n return;\n }\n\n request.headers.set(\"Content-Type\", contentType ?? \"multipart/form-data\");\n\n // set body to MultipartRequestBody using content from FormDataMap\n const parts: BodyPart[] = [];\n\n for (const [fieldName, values] of Object.entries(formData)) {\n for (const value of Array.isArray(values) ? values : [values]) {\n if (typeof value === \"string\") {\n parts.push({\n headers: createHttpHeaders({\n \"Content-Disposition\": `form-data; name=\"${fieldName}\"`,\n }),\n body: stringToUint8Array(value, \"utf-8\"),\n });\n } else if (value === undefined || value === null || typeof value !== \"object\") {\n throw new Error(\n `Unexpected value for key ${fieldName}: ${value}. Value should be serialized to string first.`,\n );\n } else {\n // using || instead of ?? here since if value.name is empty we should create a file name\n const fileName = (value as File).name || \"blob\";\n const headers = createHttpHeaders();\n headers.set(\n \"Content-Disposition\",\n `form-data; name=\"${fieldName}\"; filename=\"${fileName}\"`,\n );\n\n // again, || is used since an empty value.type means the content type is unset\n headers.set(\"Content-Type\", value.type || \"application/octet-stream\");\n\n parts.push({\n headers,\n body: value,\n });\n }\n }\n }\n request.multipartBody = { parts };\n}\n"]}
1
+ {"version":3,"file":"formDataPolicy.js","sourceRoot":"","sources":["../../../src/policies/formDataP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C;wBACzB,qBAAqB,EAAE,oBAAoB,SAAS,GAAG;qBACxD,CAAC;oBACF,IAAI,EAAE,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC;iBACzC,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9E,MAAM,IAAI,KAAK,CACb,4BAA4B,SAAS,KAAK,KAAK,+CAA+C,CAC/F,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,wFAAwF;gBACxF,MAAM,QAAQ,GAAI,KAAc,CAAC,IAAI,IAAI,MAAM,CAAC;gBAChD,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;gBACpC,OAAO,CAAC,GAAG,CACT,qBAAqB,EACrB,oBAAoB,SAAS,gBAAgB,QAAQ,GAAG,CACzD,CAAC;gBAEF,8EAA8E;gBAC9E,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,IAAI,0BAA0B,CAAC,CAAC;gBAEtE,KAAK,CAAC,IAAI,CAAC;oBACT,OAAO;oBACP,IAAI,EAAE,KAAK;iBACZ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,aAAa,GAAG,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { stringToUint8Array } from \"#platform/bytesEncoding\";\nimport { convertBodyToFormDataMap } from \"#platform/formData\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport type {\n BodyPart,\n FormDataMap,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\n/**\n * The programmatic identifier of the formDataPolicy.\n */\nexport const formDataPolicyName = \"formDataPolicy\";\n\n/**\n * A policy that encodes FormData on the request into the body.\n */\nexport function formDataPolicy(): PipelinePolicy {\n return {\n name: formDataPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const converted = convertBodyToFormDataMap(request.body);\n if (converted) {\n request.formData = converted;\n request.body = undefined;\n }\n\n if (request.formData) {\n const contentType = request.headers.get(\"Content-Type\");\n if (contentType && contentType.indexOf(\"application/x-www-form-urlencoded\") !== -1) {\n request.body = wwwFormUrlEncode(request.formData);\n } else {\n await prepareFormData(request.formData, request);\n }\n\n request.formData = undefined;\n }\n return next(request);\n },\n };\n}\n\nfunction wwwFormUrlEncode(formData: FormDataMap): string {\n const urlSearchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(formData)) {\n if (Array.isArray(value)) {\n for (const subValue of value) {\n urlSearchParams.append(key, subValue.toString());\n }\n } else {\n urlSearchParams.append(key, value.toString());\n }\n }\n return urlSearchParams.toString();\n}\n\nasync function prepareFormData(formData: FormDataMap, request: PipelineRequest): Promise<void> {\n // validate content type (multipart/form-data)\n const contentType = request.headers.get(\"Content-Type\");\n if (contentType && !contentType.startsWith(\"multipart/form-data\")) {\n // content type is specified and is not multipart/form-data. Exit.\n return;\n }\n\n request.headers.set(\"Content-Type\", contentType ?? \"multipart/form-data\");\n\n // set body to MultipartRequestBody using content from FormDataMap\n const parts: BodyPart[] = [];\n\n for (const [fieldName, values] of Object.entries(formData)) {\n for (const value of Array.isArray(values) ? values : [values]) {\n if (typeof value === \"string\") {\n parts.push({\n headers: createHttpHeaders({\n \"Content-Disposition\": `form-data; name=\"${fieldName}\"`,\n }),\n body: stringToUint8Array(value, \"utf-8\"),\n });\n } else if (value === undefined || value === null || typeof value !== \"object\") {\n throw new Error(\n `Unexpected value for key ${fieldName}: ${value}. Value should be serialized to string first.`,\n );\n } else {\n // using || instead of ?? here since if value.name is empty we should create a file name\n const fileName = (value as File).name || \"blob\";\n const headers = createHttpHeaders();\n headers.set(\n \"Content-Disposition\",\n `form-data; name=\"${fieldName}\"; filename=\"${fileName}\"`,\n );\n\n // again, || is used since an empty value.type means the content type is unset\n headers.set(\"Content-Type\", value.type || \"application/octet-stream\");\n\n parts.push({\n headers,\n body: value,\n });\n }\n }\n }\n request.multipartBody = { parts };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export { agentPolicy, agentPolicyName } from "./agentPolicy.js";
2
- export { decompressResponsePolicy, decompressResponsePolicyName, } from "./decompressResponsePolicy.js";
2
+ export { decompressResponsePolicy, decompressResponsePolicyName } from "./decompressResponsePolicy-web.mjs";
3
3
  export { defaultRetryPolicy, defaultRetryPolicyName, type DefaultRetryPolicyOptions, } from "./defaultRetryPolicy.js";
4
4
  export { exponentialRetryPolicy, exponentialRetryPolicyName, type ExponentialRetryPolicyOptions, } from "./exponentialRetryPolicy.js";
5
5
  export { retryPolicy, type RetryPolicyOptions } from "./retryPolicy.js";
@@ -9,7 +9,7 @@ export { throttlingRetryPolicy, throttlingRetryPolicyName } from "./throttlingRe
9
9
  export { formDataPolicy, formDataPolicyName } from "./formDataPolicy.js";
10
10
  export { logPolicy, logPolicyName, type LogPolicyOptions } from "./logPolicy.js";
11
11
  export { multipartPolicy, multipartPolicyName } from "./multipartPolicy.js";
12
- export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./proxyPolicy.js";
12
+ export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./proxyPolicy-web.mjs";
13
13
  export { redirectPolicy, redirectPolicyName, type RedirectPolicyOptions, } from "./redirectPolicy.js";
14
14
  export { tlsPolicy, tlsPolicyName } from "./tlsPolicy.js";
15
15
  export { userAgentPolicy, userAgentPolicyName, type UserAgentPolicyOptions, } from "./userAgentPolicy.js";
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  export { agentPolicy, agentPolicyName } from "./agentPolicy.js";
4
- export { decompressResponsePolicy, decompressResponsePolicyName, } from "./decompressResponsePolicy.js";
4
+ export { decompressResponsePolicy, decompressResponsePolicyName } from "./decompressResponsePolicy-web.mjs";
5
5
  export { defaultRetryPolicy, defaultRetryPolicyName, } from "./defaultRetryPolicy.js";
6
6
  export { exponentialRetryPolicy, exponentialRetryPolicyName, } from "./exponentialRetryPolicy.js";
7
7
  export { retryPolicy } from "./retryPolicy.js";
@@ -10,7 +10,7 @@ export { throttlingRetryPolicy, throttlingRetryPolicyName } from "./throttlingRe
10
10
  export { formDataPolicy, formDataPolicyName } from "./formDataPolicy.js";
11
11
  export { logPolicy, logPolicyName } from "./logPolicy.js";
12
12
  export { multipartPolicy, multipartPolicyName } from "./multipartPolicy.js";
13
- export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./proxyPolicy.js";
13
+ export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./proxyPolicy-web.mjs";
14
14
  export { redirectPolicy, redirectPolicyName, } from "./redirectPolicy.js";
15
15
  export { tlsPolicy, tlsPolicyName } from "./tlsPolicy.js";
16
16
  export { userAgentPolicy, userAgentPolicyName, } from "./userAgentPolicy.js";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/policies/internal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAC;AAMxE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAyB,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EACL,cAAc,EACd,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { agentPolicy, agentPolicyName } from \"./agentPolicy.js\";\nexport {\n decompressResponsePolicy,\n decompressResponsePolicyName,\n} from \"./decompressResponsePolicy.js\";\nexport {\n defaultRetryPolicy,\n defaultRetryPolicyName,\n type DefaultRetryPolicyOptions,\n} from \"./defaultRetryPolicy.js\";\nexport {\n exponentialRetryPolicy,\n exponentialRetryPolicyName,\n type ExponentialRetryPolicyOptions,\n} from \"./exponentialRetryPolicy.js\";\nexport { retryPolicy, type RetryPolicyOptions } from \"./retryPolicy.js\";\nexport type {\n RetryInformation,\n RetryModifiers,\n RetryStrategy,\n} from \"../retryStrategies/retryStrategy.js\";\nexport { systemErrorRetryPolicy, systemErrorRetryPolicyName } from \"./systemErrorRetryPolicy.js\";\nexport { throttlingRetryPolicy, throttlingRetryPolicyName } from \"./throttlingRetryPolicy.js\";\nexport { formDataPolicy, formDataPolicyName } from \"./formDataPolicy.js\";\nexport { logPolicy, logPolicyName, type LogPolicyOptions } from \"./logPolicy.js\";\nexport { multipartPolicy, multipartPolicyName } from \"./multipartPolicy.js\";\nexport { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from \"./proxyPolicy.js\";\nexport {\n redirectPolicy,\n redirectPolicyName,\n type RedirectPolicyOptions,\n} from \"./redirectPolicy.js\";\nexport { tlsPolicy, tlsPolicyName } from \"./tlsPolicy.js\";\nexport {\n userAgentPolicy,\n userAgentPolicyName,\n type UserAgentPolicyOptions,\n} from \"./userAgentPolicy.js\";\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/policies/internal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAC;AAMxE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAyB,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EACL,cAAc,EACd,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { agentPolicy, agentPolicyName } from \"./agentPolicy.js\";\nexport { decompressResponsePolicy, decompressResponsePolicyName } from \"#platform/decompress\";\nexport {\n defaultRetryPolicy,\n defaultRetryPolicyName,\n type DefaultRetryPolicyOptions,\n} from \"./defaultRetryPolicy.js\";\nexport {\n exponentialRetryPolicy,\n exponentialRetryPolicyName,\n type ExponentialRetryPolicyOptions,\n} from \"./exponentialRetryPolicy.js\";\nexport { retryPolicy, type RetryPolicyOptions } from \"./retryPolicy.js\";\nexport type {\n RetryInformation,\n RetryModifiers,\n RetryStrategy,\n} from \"../retryStrategies/retryStrategy.js\";\nexport { systemErrorRetryPolicy, systemErrorRetryPolicyName } from \"./systemErrorRetryPolicy.js\";\nexport { throttlingRetryPolicy, throttlingRetryPolicyName } from \"./throttlingRetryPolicy.js\";\nexport { formDataPolicy, formDataPolicyName } from \"./formDataPolicy.js\";\nexport { logPolicy, logPolicyName, type LogPolicyOptions } from \"./logPolicy.js\";\nexport { multipartPolicy, multipartPolicyName } from \"./multipartPolicy.js\";\nexport { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from \"#platform/proxy\";\nexport {\n redirectPolicy,\n redirectPolicyName,\n type RedirectPolicyOptions,\n} from \"./redirectPolicy.js\";\nexport { tlsPolicy, tlsPolicyName } from \"./tlsPolicy.js\";\nexport {\n userAgentPolicy,\n userAgentPolicyName,\n type UserAgentPolicyOptions,\n} from \"./userAgentPolicy.js\";\n"]}
@@ -1,9 +1,9 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { stringToUint8Array } from "../util/bytesEncoding.js";
3
+ import { stringToUint8Array } from "../util/bytesEncoding-web.mjs";
4
4
  import { isBlob } from "../util/typeGuards.js";
5
- import { randomUUID } from "../util/uuidUtils.js";
6
- import { concat } from "../util/concat.js";
5
+ import { randomUUID } from "../util/uuidUtils-react-native.mjs";
6
+ import { concat } from "../util/concat-react-native.mjs";
7
7
  function generateBoundary() {
8
8
  return `----AzSDKFormBoundary${randomUUID()}`;
9
9
  }
@@ -55,6 +55,10 @@ async function buildRequestBody(request, parts, boundary) {
55
55
  if (contentLength) {
56
56
  request.headers.set("Content-Length", contentLength);
57
57
  }
58
+ // The public BodyPart.body type uses Uint8Array (= Uint8Array<ArrayBufferLike>) for
59
+ // backward compatibility. Internally, concat requires Uint8Array<ArrayBuffer> to ensure
60
+ // SharedArrayBuffer-backed arrays don't flow into Blob construction. In practice, HTTP
61
+ // request bodies are always ArrayBuffer-backed, so this narrowing is safe.
58
62
  request.body = await concat(sources);
59
63
  }
60
64
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"multipartPolicy.js","sourceRoot":"","sources":["../../../src/policies/multipartPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,SAAS,gBAAgB;IACvB,OAAO,wBAAwB,UAAU,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,aAAa,CAAC,OAAoB;IACzC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,GAAG,KAAK,KAAK,MAAM,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAChB,MAMyB;IAEzB,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,UAAU,CAAC;IAC3B,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,wEAAwE;QACxE,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAA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K,CACb,0EAA0E,iBAAiB,EAAE,CAC9F,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,GAAG,YAAY,CAAC;YACrD,IAAI,cAAc,IAAI,QAAQ,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;gBAC9D,MAAM,IAAI,KAAK,CACb,uCAAuC,cAAc,2BAA2B,QAAQ,sBAAsB,CAC/G,CAAC;YACJ,CAAC;YAED,QAAQ,KAAK,cAAc,CAAC;YAC5B,IAAI,QAAQ,EAAE,CAAC;gBACb,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,QAAQ,GAAG,gBAAgB,EAAE,CAAC;YAChC,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,WAAW,cAAc,QAAQ,EAAE,CAAC,CAAC;YAC5E,MAAM,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAEvE,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;YAElC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BodyPart, HttpHeaders, PipelineRequest, PipelineResponse } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isBlob } from \"../util/typeGuards.js\";\nimport { randomUUID } from \"../util/uuidUtils.js\";\nimport { concat } from \"../util/concat.js\";\n\nfunction generateBoundary(): string {\n return `----AzSDKFormBoundary${randomUUID()}`;\n}\n\nfunction encodeHeaders(headers: HttpHeaders): string {\n let result = \"\";\n for (const [key, value] of headers) {\n result += `${key}: ${value}\\r\\n`;\n }\n return result;\n}\n\nfunction getLength(\n source:\n | (() => ReadableStream<Uint8Array>)\n | (() => NodeJS.ReadableStream)\n | Uint8Array\n | Blob\n | ReadableStream\n | NodeJS.ReadableStream,\n): number | undefined {\n if (source instanceof Uint8Array) {\n return source.byteLength;\n } else if (isBlob(source)) {\n // if was created using createFile then -1 means we have an unknown size\n return source.size === -1 ? undefined : source.size;\n } else {\n return undefined;\n }\n}\n\nfunction getTotalLength(\n sources: (\n | (() => ReadableStream<Uint8Array>)\n | (() => NodeJS.ReadableStream)\n | Uint8Array\n | Blob\n | ReadableStream\n | NodeJS.ReadableStream\n )[],\n): number | undefined {\n let total = 0;\n for (const source of sources) {\n const partLength = getLength(source);\n if (partLength === undefined) {\n return undefined;\n } else {\n total += partLength;\n }\n }\n return total;\n}\n\nasync function buildRequestBody(\n request: PipelineRequest,\n parts: BodyPart[],\n boundary: string,\n): Promise<void> {\n const sources = [\n stringToUint8Array(`--${boundary}`, \"utf-8\"),\n ...parts.flatMap((part) => [\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n stringToUint8Array(encodeHeaders(part.headers), \"utf-8\"),\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n part.body,\n stringToUint8Array(`\\r\\n--${boundary}`, \"utf-8\"),\n ]),\n stringToUint8Array(\"--\\r\\n\\r\\n\", \"utf-8\"),\n ];\n\n const contentLength = getTotalLength(sources);\n if (contentLength) {\n request.headers.set(\"Content-Length\", contentLength);\n }\n\n request.body = await concat(sources);\n}\n\n/**\n * Name of multipart policy\n */\nexport const multipartPolicyName = \"multipartPolicy\";\n\nconst maxBoundaryLength = 70;\nconst validBoundaryCharacters = new Set(\n `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`,\n);\n\nfunction assertValidBoundary(boundary: string): void {\n if (boundary.length > maxBoundaryLength) {\n throw new Error(`Multipart boundary \"${boundary}\" exceeds maximum length of 70 characters`);\n }\n\n if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {\n throw new Error(`Multipart boundary \"${boundary}\" contains invalid characters`);\n }\n}\n\n/**\n * Pipeline policy for multipart requests\n */\nexport function multipartPolicy(): PipelinePolicy {\n return {\n name: multipartPolicyName,\n async sendRequest(request, next): Promise<PipelineResponse> {\n if (!request.multipartBody) {\n return next(request);\n }\n\n if (request.body) {\n throw new Error(\"multipartBody and regular body cannot be set at the same time\");\n }\n\n let boundary = request.multipartBody.boundary;\n\n const contentTypeHeader = request.headers.get(\"Content-Type\") ?? \"multipart/mixed\";\n const parsedHeader = contentTypeHeader.match(/^(multipart\\/[^ ;]+)(?:; *boundary=(.+))?$/);\n if (!parsedHeader) {\n throw new Error(\n `Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`,\n );\n }\n\n const [, contentType, parsedBoundary] = parsedHeader;\n if (parsedBoundary && boundary && parsedBoundary !== boundary) {\n throw new Error(\n `Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`,\n );\n }\n\n boundary ??= parsedBoundary;\n if (boundary) {\n assertValidBoundary(boundary);\n } else {\n boundary = generateBoundary();\n }\n request.headers.set(\"Content-Type\", `${contentType}; boundary=${boundary}`);\n await buildRequestBody(request, request.multipartBody.parts, boundary);\n\n request.multipartBody = undefined;\n\n return next(request);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"multipartPolicy.js","sourceRoot":"","sources":["../../../src/policies/multipartPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,SAAS,gBAAgB;IACvB,OAAO,wBAAwB,UAAU,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,aAAa,CAAC,OAAoB;IACzC,IAAI,MAAM,GAAG,EAAE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ACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BodyPart, HttpHeaders, PipelineRequest, PipelineResponse } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport type { NodeReadableStream, WebReadableStream } from \"#platform/types\";\nimport { stringToUint8Array } from \"#platform/bytesEncoding\";\nimport { isBlob } from \"../util/typeGuards.js\";\nimport { randomUUID } from \"#platform/uuid\";\nimport { concat } from \"#platform/concat\";\n\nfunction generateBoundary(): string {\n return `----AzSDKFormBoundary${randomUUID()}`;\n}\n\nfunction encodeHeaders(headers: HttpHeaders): string {\n let result = \"\";\n for (const [key, value] of headers) {\n result += `${key}: ${value}\\r\\n`;\n }\n return result;\n}\n\nfunction getLength(\n source:\n | (() => WebReadableStream<Uint8Array>)\n | (() => NodeReadableStream)\n | Uint8Array\n | Blob\n | WebReadableStream\n | NodeReadableStream,\n): number | undefined {\n if (source instanceof Uint8Array) {\n return source.byteLength;\n } else if (isBlob(source)) {\n // if was created using createFile then -1 means we have an unknown size\n return source.size === -1 ? undefined : source.size;\n } else {\n return undefined;\n }\n}\n\nfunction getTotalLength(\n sources: (\n | (() => WebReadableStream<Uint8Array>)\n | (() => NodeReadableStream)\n | Uint8Array\n | Blob\n | WebReadableStream\n | NodeReadableStream\n )[],\n): number | undefined {\n let total = 0;\n for (const source of sources) {\n const partLength = getLength(source);\n if (partLength === undefined) {\n return undefined;\n } else {\n total += partLength;\n }\n }\n return total;\n}\n\nasync function buildRequestBody(\n request: PipelineRequest,\n parts: BodyPart[],\n boundary: string,\n): Promise<void> {\n const sources = [\n stringToUint8Array(`--${boundary}`, \"utf-8\"),\n ...parts.flatMap((part) => [\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n stringToUint8Array(encodeHeaders(part.headers), \"utf-8\"),\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n part.body,\n stringToUint8Array(`\\r\\n--${boundary}`, \"utf-8\"),\n ]),\n stringToUint8Array(\"--\\r\\n\\r\\n\", \"utf-8\"),\n ];\n\n const contentLength = getTotalLength(sources);\n if (contentLength) {\n request.headers.set(\"Content-Length\", contentLength);\n }\n\n // The public BodyPart.body type uses Uint8Array (= Uint8Array<ArrayBufferLike>) for\n // backward compatibility. Internally, concat requires Uint8Array<ArrayBuffer> to ensure\n // SharedArrayBuffer-backed arrays don't flow into Blob construction. In practice, HTTP\n // request bodies are always ArrayBuffer-backed, so this narrowing is safe.\n request.body = await concat(sources as Parameters<typeof concat>[0]);\n}\n\n/**\n * Name of multipart policy\n */\nexport const multipartPolicyName = \"multipartPolicy\";\n\nconst maxBoundaryLength = 70;\nconst validBoundaryCharacters = new Set(\n `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`,\n);\n\nfunction assertValidBoundary(boundary: string): void {\n if (boundary.length > maxBoundaryLength) {\n throw new Error(`Multipart boundary \"${boundary}\" exceeds maximum length of 70 characters`);\n }\n\n if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {\n throw new Error(`Multipart boundary \"${boundary}\" contains invalid characters`);\n }\n}\n\n/**\n * Pipeline policy for multipart requests\n */\nexport function multipartPolicy(): PipelinePolicy {\n return {\n name: multipartPolicyName,\n async sendRequest(request, next): Promise<PipelineResponse> {\n if (!request.multipartBody) {\n return next(request);\n }\n\n if (request.body) {\n throw new Error(\"multipartBody and regular body cannot be set at the same time\");\n }\n\n let boundary = request.multipartBody.boundary;\n\n const contentTypeHeader = request.headers.get(\"Content-Type\") ?? \"multipart/mixed\";\n const parsedHeader = contentTypeHeader.match(/^(multipart\\/[^ ;]+)(?:; *boundary=(.+))?$/);\n if (!parsedHeader) {\n throw new Error(\n `Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`,\n );\n }\n\n const [, contentType, parsedBoundary] = parsedHeader;\n if (parsedBoundary && boundary && parsedBoundary !== boundary) {\n throw new Error(\n `Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`,\n );\n }\n\n boundary ??= parsedBoundary;\n if (boundary) {\n assertValidBoundary(boundary);\n } else {\n boundary = generateBoundary();\n }\n request.headers.set(\"Content-Type\", `${contentType}; boundary=${boundary}`);\n await buildRequestBody(request, request.multipartBody.parts, boundary);\n\n request.multipartBody = undefined;\n\n return next(request);\n },\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Pipeline } from "../pipeline.js";
2
+ import type { PlatformPoliciesOptions } from "./platformPolicies.js";
3
+ /**
4
+ * Browser and React Native runtimes handle agent, TLS, proxy, decompression,
5
+ * and redirects natively — no pipeline policies needed.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare function addPlatformPolicies(_pipeline: Pipeline, _options: PlatformPoliciesOptions): void;
10
+ //# sourceMappingURL=platformPolicies-web.d.mts.map
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Browser and React Native runtimes handle agent, TLS, proxy, decompression,
5
+ * and redirects natively — no pipeline policies needed.
6
+ *
7
+ * @internal
8
+ */
9
+ export function addPlatformPolicies(_pipeline, _options) {
10
+ // no-op
11
+ }
12
+ //# sourceMappingURL=platformPolicies-web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformPolicies-web.mjs","sourceRoot":"","sources":["../../../src/policies/platformPolicies-web.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAmB,EAAE,QAAiC;IACxF,QAAQ;AACV,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Pipeline } from \"../pipeline.js\";\nimport type { PlatformPoliciesOptions } from \"./platformPolicies.js\";\n\n/**\n * Browser and React Native runtimes handle agent, TLS, proxy, decompression,\n * and redirects natively — no pipeline policies needed.\n *\n * @internal\n */\nexport function addPlatformPolicies(_pipeline: Pipeline, _options: PlatformPoliciesOptions): void {\n // no-op\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { Pipeline } from "../pipeline.js";
2
+ import type { Agent, ProxySettings, TlsSettings } from "../interfaces.js";
3
+ import type { RedirectPolicyOptions } from "./redirectPolicy.js";
4
+ /**
5
+ * Options for configuring platform-specific pipeline policies.
6
+ *
7
+ * @internal
8
+ */
9
+ export interface PlatformPoliciesOptions {
10
+ agent?: Agent;
11
+ tlsOptions?: TlsSettings;
12
+ proxyOptions?: ProxySettings;
13
+ redirectOptions?: RedirectPolicyOptions;
14
+ }
15
+ /**
16
+ * Add platform-specific policies to the pipeline.
17
+ *
18
+ * On Node.js, this adds agent, TLS, proxy, decompression, and redirect
19
+ * policies. On browser and React Native these concerns are handled
20
+ * natively by the runtime, so this is a no-op.
21
+ *
22
+ * @internal
23
+ */
24
+ export declare function addPlatformPolicies(pipeline: Pipeline, options: PlatformPoliciesOptions): void;
25
+ //# sourceMappingURL=platformPolicies.d.ts.map
@@ -0,0 +1,30 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { agentPolicy } from "./agentPolicy.js";
4
+ import { tlsPolicy } from "./tlsPolicy.js";
5
+ import { proxyPolicy } from "./proxyPolicy-web.mjs";
6
+ import { decompressResponsePolicy } from "./decompressResponsePolicy-web.mjs";
7
+ import { redirectPolicy } from "./redirectPolicy.js";
8
+ /**
9
+ * Add platform-specific policies to the pipeline.
10
+ *
11
+ * On Node.js, this adds agent, TLS, proxy, decompression, and redirect
12
+ * policies. On browser and React Native these concerns are handled
13
+ * natively by the runtime, so this is a no-op.
14
+ *
15
+ * @internal
16
+ */
17
+ export function addPlatformPolicies(pipeline, options) {
18
+ if (options.agent) {
19
+ pipeline.addPolicy(agentPolicy(options.agent));
20
+ }
21
+ if (options.tlsOptions) {
22
+ pipeline.addPolicy(tlsPolicy(options.tlsOptions));
23
+ }
24
+ pipeline.addPolicy(proxyPolicy(options.proxyOptions));
25
+ pipeline.addPolicy(decompressResponsePolicy());
26
+ // Both XHR and Fetch expect to handle redirects automatically,
27
+ // so this only takes effect on Node.
28
+ pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: "Retry" });
29
+ }
30
+ //# sourceMappingURL=platformPolicies.js.map