@typespec/ts-http-runtime 0.3.4-alpha.20260227.2 → 0.3.4

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 (295) hide show
  1. package/dist/browser/client/sendRequest.d.ts +10 -1
  2. package/dist/browser/client/sendRequest.js +8 -2
  3. package/dist/browser/client/sendRequest.js.map +1 -1
  4. package/dist/browser/defaultHttpClient.d.ts +1 -1
  5. package/dist/browser/defaultHttpClient.js +1 -1
  6. package/dist/browser/defaultHttpClient.js.map +1 -0
  7. package/dist/browser/index.d.ts +2 -2
  8. package/dist/browser/index.js +0 -2
  9. package/dist/browser/index.js.map +1 -1
  10. package/dist/browser/logger/log.d.ts +1 -1
  11. package/dist/browser/logger/log.js +1 -1
  12. package/dist/browser/logger/log.js.map +1 -0
  13. package/dist/browser/pipelineRequest.d.ts +1 -1
  14. package/dist/browser/pipelineRequest.js.map +1 -1
  15. package/dist/browser/policies/decompressResponsePolicy.d.ts +3 -2
  16. package/dist/browser/policies/decompressResponsePolicy.js +1 -4
  17. package/dist/browser/policies/decompressResponsePolicy.js.map +1 -0
  18. package/dist/browser/policies/internal.d.ts +7 -7
  19. package/dist/browser/policies/internal.js +2 -2
  20. package/dist/browser/policies/internal.js.map +1 -1
  21. package/dist/browser/policies/proxyPolicy.common.d.ts +7 -3
  22. package/dist/browser/policies/proxyPolicy.common.js +2 -2
  23. package/dist/browser/policies/proxyPolicy.common.js.map +1 -1
  24. package/dist/browser/policies/proxyPolicy.d.ts +1 -1
  25. package/dist/browser/policies/proxyPolicy.js +1 -1
  26. package/dist/browser/policies/proxyPolicy.js.map +1 -0
  27. package/dist/browser/policies/redirectPolicy.d.ts +7 -0
  28. package/dist/browser/policies/redirectPolicy.js +13 -4
  29. package/dist/browser/policies/redirectPolicy.js.map +1 -1
  30. package/dist/browser/util/bytesEncoding.d.ts +1 -1
  31. package/dist/browser/util/bytesEncoding.js +1 -1
  32. package/dist/browser/util/bytesEncoding.js.map +1 -0
  33. package/dist/browser/util/concat.common.d.ts +1 -2
  34. package/dist/browser/util/concat.common.js.map +1 -1
  35. package/dist/browser/util/concat.d.ts +1 -1
  36. package/dist/browser/util/concat.js +1 -1
  37. package/dist/browser/util/concat.js.map +1 -0
  38. package/dist/browser/util/inspect.d.ts +1 -1
  39. package/dist/browser/util/inspect.js +1 -1
  40. package/dist/browser/util/inspect.js.map +1 -0
  41. package/dist/browser/util/sha256.d.ts +1 -1
  42. package/dist/browser/util/sha256.js +1 -1
  43. package/dist/browser/util/sha256.js.map +1 -0
  44. package/dist/browser/util/userAgentPlatform.d.ts +1 -1
  45. package/dist/browser/util/userAgentPlatform.js +1 -1
  46. package/dist/browser/util/userAgentPlatform.js.map +1 -0
  47. package/dist/browser/util/uuidUtils.d.ts +1 -1
  48. package/dist/browser/util/uuidUtils.js +1 -1
  49. package/dist/browser/util/uuidUtils.js.map +1 -0
  50. package/dist/commonjs/abort-controller/AbortError.js +30 -40
  51. package/dist/commonjs/abort-controller/AbortError.js.map +7 -1
  52. package/dist/commonjs/auth/credentials.js +36 -25
  53. package/dist/commonjs/auth/credentials.js.map +7 -1
  54. package/dist/commonjs/auth/oauth2Flows.js +15 -5
  55. package/dist/commonjs/auth/oauth2Flows.js.map +7 -1
  56. package/dist/commonjs/auth/schemes.js +15 -5
  57. package/dist/commonjs/auth/schemes.js.map +7 -1
  58. package/dist/commonjs/client/apiVersionPolicy.js +39 -25
  59. package/dist/commonjs/client/apiVersionPolicy.js.map +7 -1
  60. package/dist/commonjs/client/clientHelpers.js +62 -39
  61. package/dist/commonjs/client/clientHelpers.js.map +7 -1
  62. package/dist/commonjs/client/common.js +15 -5
  63. package/dist/commonjs/client/common.js.map +7 -1
  64. package/dist/commonjs/client/getClient.js +170 -82
  65. package/dist/commonjs/client/getClient.js.map +7 -1
  66. package/dist/commonjs/client/multipart.js +119 -110
  67. package/dist/commonjs/client/multipart.js.map +7 -1
  68. package/dist/commonjs/client/operationOptionHelpers.js +36 -21
  69. package/dist/commonjs/client/operationOptionHelpers.js.map +7 -1
  70. package/dist/commonjs/client/restError.js +44 -26
  71. package/dist/commonjs/client/restError.js.map +7 -1
  72. package/dist/commonjs/client/sendRequest.d.ts +10 -1
  73. package/dist/commonjs/client/sendRequest.js +150 -164
  74. package/dist/commonjs/client/sendRequest.js.map +7 -1
  75. package/dist/commonjs/client/urlHelpers.js +124 -131
  76. package/dist/commonjs/client/urlHelpers.js.map +7 -1
  77. package/dist/commonjs/constants.js +30 -8
  78. package/dist/commonjs/constants.js.map +7 -1
  79. package/dist/commonjs/createPipelineFromOptions.js +56 -45
  80. package/dist/commonjs/createPipelineFromOptions.js.map +7 -1
  81. package/dist/commonjs/defaultHttpClient.js +28 -11
  82. package/dist/commonjs/defaultHttpClient.js.map +7 -1
  83. package/dist/commonjs/fetchHttpClient.js +211 -256
  84. package/dist/commonjs/fetchHttpClient.js.map +7 -1
  85. package/dist/commonjs/httpHeaders.js +97 -82
  86. package/dist/commonjs/httpHeaders.js.map +7 -1
  87. package/dist/commonjs/index.d.ts +2 -2
  88. package/dist/commonjs/index.js +67 -36
  89. package/dist/commonjs/index.js.map +7 -1
  90. package/dist/commonjs/interfaces.js +15 -5
  91. package/dist/commonjs/interfaces.js.map +7 -1
  92. package/dist/commonjs/log.js +28 -8
  93. package/dist/commonjs/log.js.map +7 -1
  94. package/dist/commonjs/logger/debug.js +150 -155
  95. package/dist/commonjs/logger/debug.js.map +7 -1
  96. package/dist/commonjs/logger/internal.js +27 -8
  97. package/dist/commonjs/logger/internal.js.map +7 -1
  98. package/dist/commonjs/logger/log.common.js +39 -23
  99. package/dist/commonjs/logger/log.common.js.map +7 -1
  100. package/dist/commonjs/logger/log.js +40 -11
  101. package/dist/commonjs/logger/log.js.map +7 -1
  102. package/dist/commonjs/logger/logger.js +120 -110
  103. package/dist/commonjs/logger/logger.js.map +7 -1
  104. package/dist/commonjs/nodeHttpClient.js +313 -321
  105. package/dist/commonjs/nodeHttpClient.js.map +7 -1
  106. package/dist/commonjs/pipeline.js +190 -247
  107. package/dist/commonjs/pipeline.js.map +7 -1
  108. package/dist/commonjs/pipelineRequest.d.ts +1 -1
  109. package/dist/commonjs/pipelineRequest.js +69 -54
  110. package/dist/commonjs/pipelineRequest.js.map +7 -1
  111. package/dist/commonjs/policies/agentPolicy.js +38 -24
  112. package/dist/commonjs/policies/agentPolicy.js.map +7 -1
  113. package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +45 -32
  114. package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +7 -1
  115. package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +50 -32
  116. package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +7 -1
  117. package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +47 -32
  118. package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +7 -1
  119. package/dist/commonjs/policies/auth/checkInsecureConnection.js +47 -44
  120. package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +7 -1
  121. package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +45 -32
  122. package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +7 -1
  123. package/dist/commonjs/policies/decompressResponsePolicy.js +38 -25
  124. package/dist/commonjs/policies/decompressResponsePolicy.js.map +7 -1
  125. package/dist/commonjs/policies/defaultRetryPolicy.js +39 -27
  126. package/dist/commonjs/policies/defaultRetryPolicy.js.map +7 -1
  127. package/dist/commonjs/policies/exponentialRetryPolicy.js +43 -26
  128. package/dist/commonjs/policies/exponentialRetryPolicy.js.map +7 -1
  129. package/dist/commonjs/policies/formDataPolicy.js +101 -90
  130. package/dist/commonjs/policies/formDataPolicy.js.map +7 -1
  131. package/dist/commonjs/policies/internal.d.ts +7 -7
  132. package/dist/commonjs/policies/internal.js +94 -48
  133. package/dist/commonjs/policies/internal.js.map +7 -1
  134. package/dist/commonjs/policies/logPolicy.js +49 -35
  135. package/dist/commonjs/policies/logPolicy.js.map +7 -1
  136. package/dist/commonjs/policies/multipartPolicy.js +117 -99
  137. package/dist/commonjs/policies/multipartPolicy.js.map +7 -1
  138. package/dist/commonjs/policies/proxyPolicy.common.d.ts +7 -3
  139. package/dist/commonjs/policies/proxyPolicy.common.js +38 -25
  140. package/dist/commonjs/policies/proxyPolicy.common.js.map +7 -1
  141. package/dist/commonjs/policies/proxyPolicy.js +160 -171
  142. package/dist/commonjs/policies/proxyPolicy.js.map +7 -1
  143. package/dist/commonjs/policies/redirectPolicy.d.ts +7 -0
  144. package/dist/commonjs/policies/redirectPolicy.js +62 -51
  145. package/dist/commonjs/policies/redirectPolicy.js.map +7 -1
  146. package/dist/commonjs/policies/retryPolicy.js +123 -105
  147. package/dist/commonjs/policies/retryPolicy.js.map +7 -1
  148. package/dist/commonjs/policies/systemErrorRetryPolicy.js +46 -31
  149. package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +7 -1
  150. package/dist/commonjs/policies/throttlingRetryPolicy.js +38 -30
  151. package/dist/commonjs/policies/throttlingRetryPolicy.js.map +7 -1
  152. package/dist/commonjs/policies/tlsPolicy.js +38 -24
  153. package/dist/commonjs/policies/tlsPolicy.js.map +7 -1
  154. package/dist/commonjs/policies/userAgentPolicy.js +41 -28
  155. package/dist/commonjs/policies/userAgentPolicy.js.map +7 -1
  156. package/dist/commonjs/restError.js +93 -90
  157. package/dist/commonjs/restError.js.map +7 -1
  158. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +63 -62
  159. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +7 -1
  160. package/dist/commonjs/retryStrategies/retryStrategy.js +15 -5
  161. package/dist/commonjs/retryStrategies/retryStrategy.js.map +7 -1
  162. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +58 -69
  163. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +7 -1
  164. package/dist/commonjs/util/arrayBuffer.js +34 -21
  165. package/dist/commonjs/util/arrayBuffer.js.map +7 -1
  166. package/dist/commonjs/util/bytesEncoding.common.js +83 -100
  167. package/dist/commonjs/util/bytesEncoding.common.js.map +7 -1
  168. package/dist/commonjs/util/bytesEncoding.js +30 -21
  169. package/dist/commonjs/util/bytesEncoding.js.map +7 -1
  170. package/dist/commonjs/util/checkEnvironment.js +45 -44
  171. package/dist/commonjs/util/checkEnvironment.js.map +7 -1
  172. package/dist/commonjs/util/concat.common.d.ts +1 -2
  173. package/dist/commonjs/util/concat.common.js +51 -52
  174. package/dist/commonjs/util/concat.common.js.map +7 -1
  175. package/dist/commonjs/util/concat.js +70 -61
  176. package/dist/commonjs/util/concat.js.map +7 -1
  177. package/dist/commonjs/util/delay.js +31 -21
  178. package/dist/commonjs/util/delay.js.map +7 -1
  179. package/dist/commonjs/util/error.js +33 -17
  180. package/dist/commonjs/util/error.js.map +7 -1
  181. package/dist/commonjs/util/helpers.js +65 -57
  182. package/dist/commonjs/util/helpers.js.map +7 -1
  183. package/dist/commonjs/util/inspect.common.js +27 -7
  184. package/dist/commonjs/util/inspect.common.js.map +7 -1
  185. package/dist/commonjs/util/inspect.js +28 -8
  186. package/dist/commonjs/util/inspect.js.map +7 -1
  187. package/dist/commonjs/util/internal.js +67 -32
  188. package/dist/commonjs/util/internal.js.map +7 -1
  189. package/dist/commonjs/util/object.js +27 -15
  190. package/dist/commonjs/util/object.js.map +7 -1
  191. package/dist/commonjs/util/random.js +30 -22
  192. package/dist/commonjs/util/random.js.map +7 -1
  193. package/dist/commonjs/util/sanitizer.js +157 -148
  194. package/dist/commonjs/util/sanitizer.js.map +7 -1
  195. package/dist/commonjs/util/sha256.common.js +61 -45
  196. package/dist/commonjs/util/sha256.common.js.map +7 -1
  197. package/dist/commonjs/util/sha256.js +32 -22
  198. package/dist/commonjs/util/sha256.js.map +7 -1
  199. package/dist/commonjs/util/typeGuards.js +41 -21
  200. package/dist/commonjs/util/typeGuards.js.map +7 -1
  201. package/dist/commonjs/util/userAgent.js +43 -28
  202. package/dist/commonjs/util/userAgent.js.map +7 -1
  203. package/dist/commonjs/util/userAgentPlatform.js +51 -29
  204. package/dist/commonjs/util/userAgentPlatform.js.map +7 -1
  205. package/dist/commonjs/util/uuidUtils.common.js +43 -39
  206. package/dist/commonjs/util/uuidUtils.common.js.map +7 -1
  207. package/dist/commonjs/util/uuidUtils.js +27 -12
  208. package/dist/commonjs/util/uuidUtils.js.map +7 -1
  209. package/dist/commonjs/xhrHttpClient.js +171 -163
  210. package/dist/commonjs/xhrHttpClient.js.map +7 -1
  211. package/dist/esm/client/sendRequest.d.ts +10 -1
  212. package/dist/esm/client/sendRequest.js +8 -2
  213. package/dist/esm/client/sendRequest.js.map +1 -1
  214. package/dist/esm/index.d.ts +2 -2
  215. package/dist/esm/index.js +0 -2
  216. package/dist/esm/index.js.map +1 -1
  217. package/dist/esm/pipelineRequest.d.ts +1 -1
  218. package/dist/esm/pipelineRequest.js.map +1 -1
  219. package/dist/esm/policies/internal.d.ts +7 -7
  220. package/dist/esm/policies/internal.js +2 -2
  221. package/dist/esm/policies/internal.js.map +1 -1
  222. package/dist/esm/policies/proxyPolicy.common.d.ts +7 -3
  223. package/dist/esm/policies/proxyPolicy.common.js +2 -2
  224. package/dist/esm/policies/proxyPolicy.common.js.map +1 -1
  225. package/dist/esm/policies/redirectPolicy.d.ts +7 -0
  226. package/dist/esm/policies/redirectPolicy.js +13 -4
  227. package/dist/esm/policies/redirectPolicy.js.map +1 -1
  228. package/dist/esm/util/concat.common.d.ts +1 -2
  229. package/dist/esm/util/concat.common.js.map +1 -1
  230. package/dist/react-native/client/sendRequest.d.ts +10 -1
  231. package/dist/react-native/client/sendRequest.js +8 -2
  232. package/dist/react-native/client/sendRequest.js.map +1 -1
  233. package/dist/react-native/defaultHttpClient.d.ts +1 -1
  234. package/dist/react-native/defaultHttpClient.js +1 -1
  235. package/dist/react-native/defaultHttpClient.js.map +1 -0
  236. package/dist/react-native/index.d.ts +2 -2
  237. package/dist/react-native/index.js +0 -2
  238. package/dist/react-native/index.js.map +1 -1
  239. package/dist/react-native/logger/log.d.ts +1 -1
  240. package/dist/react-native/logger/log.js +1 -1
  241. package/dist/react-native/logger/log.js.map +1 -0
  242. package/dist/react-native/pipelineRequest.d.ts +1 -1
  243. package/dist/react-native/pipelineRequest.js.map +1 -1
  244. package/dist/react-native/policies/internal.d.ts +7 -7
  245. package/dist/react-native/policies/internal.js +2 -2
  246. package/dist/react-native/policies/internal.js.map +1 -1
  247. package/dist/react-native/policies/proxyPolicy.common.d.ts +7 -3
  248. package/dist/react-native/policies/proxyPolicy.common.js +2 -2
  249. package/dist/react-native/policies/proxyPolicy.common.js.map +1 -1
  250. package/dist/react-native/policies/proxyPolicy.d.ts +1 -1
  251. package/dist/react-native/policies/proxyPolicy.js +1 -1
  252. package/dist/react-native/policies/proxyPolicy.js.map +1 -0
  253. package/dist/react-native/policies/redirectPolicy.d.ts +7 -0
  254. package/dist/react-native/policies/redirectPolicy.js +13 -4
  255. package/dist/react-native/policies/redirectPolicy.js.map +1 -1
  256. package/dist/react-native/util/bytesEncoding.d.ts +1 -1
  257. package/dist/react-native/util/bytesEncoding.js +1 -1
  258. package/dist/react-native/util/bytesEncoding.js.map +1 -0
  259. package/dist/react-native/util/concat.common.d.ts +1 -2
  260. package/dist/react-native/util/concat.common.js.map +1 -1
  261. package/dist/react-native/util/concat.d.ts +1 -1
  262. package/dist/react-native/util/concat.js +1 -1
  263. package/dist/react-native/util/concat.js.map +1 -0
  264. package/dist/react-native/util/inspect.d.ts +1 -1
  265. package/dist/react-native/util/inspect.js +1 -1
  266. package/dist/react-native/util/inspect.js.map +1 -0
  267. package/dist/react-native/util/sha256.d.ts +1 -1
  268. package/dist/react-native/util/sha256.js +1 -1
  269. package/dist/react-native/util/sha256.js.map +1 -0
  270. package/dist/react-native/util/userAgentPlatform.d.ts +1 -1
  271. package/dist/react-native/util/userAgentPlatform.js +1 -1
  272. package/dist/react-native/util/userAgentPlatform.js.map +1 -0
  273. package/dist/react-native/util/uuidUtils.d.ts +1 -1
  274. package/dist/react-native/util/uuidUtils.js +1 -1
  275. package/dist/react-native/util/uuidUtils.js.map +1 -0
  276. package/package.json +1 -21
  277. package/dist/browser/defaultHttpClient-browser.mjs.map +0 -1
  278. package/dist/browser/logger/log-browser.mjs.map +0 -1
  279. package/dist/browser/policies/decompressResponsePolicy-browser.mjs.map +0 -1
  280. package/dist/browser/policies/proxyPolicy-browser.mjs.map +0 -1
  281. package/dist/browser/util/bytesEncoding-browser.mjs.map +0 -1
  282. package/dist/browser/util/concat-browser.mjs.map +0 -1
  283. package/dist/browser/util/inspect-browser.mjs.map +0 -1
  284. package/dist/browser/util/sha256-browser.mjs.map +0 -1
  285. package/dist/browser/util/userAgentPlatform-browser.mjs.map +0 -1
  286. package/dist/browser/util/uuidUtils-browser.mjs.map +0 -1
  287. package/dist/react-native/defaultHttpClient-react-native.mjs.map +0 -1
  288. package/dist/react-native/logger/log-react-native.mjs.map +0 -1
  289. package/dist/react-native/policies/proxyPolicy-react-native.mjs.map +0 -1
  290. package/dist/react-native/util/bytesEncoding-react-native.mjs.map +0 -1
  291. package/dist/react-native/util/concat-react-native.mjs.map +0 -1
  292. package/dist/react-native/util/inspect-react-native.mjs.map +0 -1
  293. package/dist/react-native/util/sha256-react-native.mjs.map +0 -1
  294. package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +0 -1
  295. package/dist/react-native/util/uuidUtils-react-native.mjs.map +0 -1
@@ -1,34 +1,49 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.bearerAuthenticationPolicyName = void 0;
6
- exports.bearerAuthenticationPolicy = bearerAuthenticationPolicy;
7
- const checkInsecureConnection_js_1 = require("./checkInsecureConnection.js");
8
- /**
9
- * Name of the Bearer Authentication Policy
10
- */
11
- exports.bearerAuthenticationPolicyName = "bearerAuthenticationPolicy";
12
- /**
13
- * Gets a pipeline policy that adds bearer token authentication to requests
14
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var bearerAuthenticationPolicy_exports = {};
19
+ __export(bearerAuthenticationPolicy_exports, {
20
+ bearerAuthenticationPolicy: () => bearerAuthenticationPolicy,
21
+ bearerAuthenticationPolicyName: () => bearerAuthenticationPolicyName
22
+ });
23
+ module.exports = __toCommonJS(bearerAuthenticationPolicy_exports);
24
+ var import_checkInsecureConnection = require("./checkInsecureConnection.js");
25
+ const bearerAuthenticationPolicyName = "bearerAuthenticationPolicy";
15
26
  function bearerAuthenticationPolicy(options) {
16
- return {
17
- name: exports.bearerAuthenticationPolicyName,
18
- async sendRequest(request, next) {
19
- // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
20
- (0, checkInsecureConnection_js_1.ensureSecureConnection)(request, options);
21
- const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "http" && x.scheme === "bearer");
22
- // Skip adding authentication header if no bearer authentication scheme is found
23
- if (!scheme) {
24
- return next(request);
25
- }
26
- const token = await options.credential.getBearerToken({
27
- abortSignal: request.abortSignal,
28
- });
29
- request.headers.set("Authorization", `Bearer ${token}`);
30
- return next(request);
31
- },
32
- };
27
+ return {
28
+ name: bearerAuthenticationPolicyName,
29
+ async sendRequest(request, next) {
30
+ (0, import_checkInsecureConnection.ensureSecureConnection)(request, options);
31
+ const scheme = (request.authSchemes ?? options.authSchemes)?.find(
32
+ (x) => x.kind === "http" && x.scheme === "bearer"
33
+ );
34
+ if (!scheme) {
35
+ return next(request);
36
+ }
37
+ const token = await options.credential.getBearerToken({
38
+ abortSignal: request.abortSignal
39
+ });
40
+ request.headers.set("Authorization", `Bearer ${token}`);
41
+ return next(request);
42
+ }
43
+ };
33
44
  }
34
- //# sourceMappingURL=bearerAuthenticationPolicy.js.map
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ bearerAuthenticationPolicy,
48
+ bearerAuthenticationPolicyName
49
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"bearerAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/bearerAuthenticationPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAmClC,gEAyBC;AAtDD,6EAAsE;AAEtE;;GAEG;AACU,QAAA,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,SAAgB,0BAA0B,CACxC,OAA0C;IAE1C,OAAO;QACL,IAAI,EAAE,sCAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,IAAA,mDAAsB,EAAC,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,QAAQ,CAClD,CAAC;YAEF,gFAAgF;YAChF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC;gBACpD,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;YACxD,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 { BearerTokenCredential } 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 { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the Bearer Authentication Policy\n */\nexport const bearerAuthenticationPolicyName = \"bearerAuthenticationPolicy\";\n\n/**\n * Options for configuring the bearer authentication policy\n */\nexport interface BearerAuthenticationPolicyOptions {\n /**\n * The BearerTokenCredential implementation that can supply the bearer token.\n */\n credential: BearerTokenCredential;\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 bearer token authentication to requests\n */\nexport function bearerAuthenticationPolicy(\n options: BearerAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: bearerAuthenticationPolicyName,\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 === \"bearer\",\n );\n\n // Skip adding authentication header if no bearer authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n\n const token = await options.credential.getBearerToken({\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/auth/bearerAuthenticationPolicy.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BearerTokenCredential } 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 { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the Bearer Authentication Policy\n */\nexport const bearerAuthenticationPolicyName = \"bearerAuthenticationPolicy\";\n\n/**\n * Options for configuring the bearer authentication policy\n */\nexport interface BearerAuthenticationPolicyOptions {\n /**\n * The BearerTokenCredential implementation that can supply the bearer token.\n */\n credential: BearerTokenCredential;\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 bearer token authentication to requests\n */\nexport function bearerAuthenticationPolicy(\n options: BearerAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: bearerAuthenticationPolicyName,\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 === \"bearer\",\n );\n\n // Skip adding authentication header if no bearer authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n\n const token = await options.credential.getBearerToken({\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qCAAuC;AAKhC,MAAM,iCAAiC;AAwBvC,SAAS,2BACd,SACgB;AAChB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,YAAY,SAA0B,MAA8C;AAExF,iEAAuB,SAAS,OAAO;AAEvC,YAAM,UAAU,QAAQ,eAAe,QAAQ,cAAc;AAAA,QAC3D,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,WAAW;AAAA,MAC3C;AAGA,UAAI,CAAC,QAAQ;AACX,eAAO,KAAK,OAAO;AAAA,MACrB;AAEA,YAAM,QAAQ,MAAM,QAAQ,WAAW,eAAe;AAAA,QACpD,aAAa,QAAQ;AAAA,MACvB,CAAC;AACD,cAAQ,QAAQ,IAAI,iBAAiB,UAAU,KAAK,EAAE;AACtD,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,53 +1,56 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.ensureSecureConnection = ensureSecureConnection;
6
- const log_js_1 = require("../../log.js");
7
- // Ensure the warining is only emitted once
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var checkInsecureConnection_exports = {};
19
+ __export(checkInsecureConnection_exports, {
20
+ ensureSecureConnection: () => ensureSecureConnection
21
+ });
22
+ module.exports = __toCommonJS(checkInsecureConnection_exports);
23
+ var import_log = require("../../log.js");
8
24
  let insecureConnectionWarningEmmitted = false;
9
- /**
10
- * Checks if the request is allowed to be sent over an insecure connection.
11
- *
12
- * A request is allowed to be sent over an insecure connection when:
13
- * - The `allowInsecureConnection` option is set to `true`.
14
- * - The request has the `allowInsecureConnection` property set to `true`.
15
- * - The request is being sent to `localhost` or `127.0.0.1`
16
- */
17
25
  function allowInsecureConnection(request, options) {
18
- if (options.allowInsecureConnection && request.allowInsecureConnection) {
19
- const url = new URL(request.url);
20
- if (url.hostname === "localhost" || url.hostname === "127.0.0.1") {
21
- return true;
22
- }
26
+ if (options.allowInsecureConnection && request.allowInsecureConnection) {
27
+ const url = new URL(request.url);
28
+ if (url.hostname === "localhost" || url.hostname === "127.0.0.1") {
29
+ return true;
23
30
  }
24
- return false;
31
+ }
32
+ return false;
25
33
  }
26
- /**
27
- * Logs a warning about sending a token over an insecure connection.
28
- *
29
- * This function will emit a node warning once, but log the warning every time.
30
- */
31
34
  function emitInsecureConnectionWarning() {
32
- const warning = "Sending token over insecure transport. Assume any token issued is compromised.";
33
- log_js_1.logger.warning(warning);
34
- if (typeof process?.emitWarning === "function" && !insecureConnectionWarningEmmitted) {
35
- insecureConnectionWarningEmmitted = true;
36
- process.emitWarning(warning);
37
- }
35
+ const warning = "Sending token over insecure transport. Assume any token issued is compromised.";
36
+ import_log.logger.warning(warning);
37
+ if (typeof process?.emitWarning === "function" && !insecureConnectionWarningEmmitted) {
38
+ insecureConnectionWarningEmmitted = true;
39
+ process.emitWarning(warning);
40
+ }
38
41
  }
39
- /**
40
- * Ensures that authentication is only allowed over HTTPS unless explicitly allowed.
41
- * Throws an error if the connection is not secure and not explicitly allowed.
42
- */
43
42
  function ensureSecureConnection(request, options) {
44
- if (!request.url.toLowerCase().startsWith("https://")) {
45
- if (allowInsecureConnection(request, options)) {
46
- emitInsecureConnectionWarning();
47
- }
48
- else {
49
- throw new Error("Authentication is not permitted for non-TLS protected (non-https) URLs when allowInsecureConnection is false.");
50
- }
43
+ if (!request.url.toLowerCase().startsWith("https://")) {
44
+ if (allowInsecureConnection(request, options)) {
45
+ emitInsecureConnectionWarning();
46
+ } else {
47
+ throw new Error(
48
+ "Authentication is not permitted for non-TLS protected (non-https) URLs when allowInsecureConnection is false."
49
+ );
51
50
  }
51
+ }
52
52
  }
53
- //# sourceMappingURL=checkInsecureConnection.js.map
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ ensureSecureConnection
56
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"checkInsecureConnection.js","sourceRoot":"","sources":["../../../../src/policies/auth/checkInsecureConnection.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkDlC,wDAaC;AA5DD,yCAAsC;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,eAAM,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,SAAgB,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
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/auth/checkInsecureConnection.ts"],
4
+ "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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAuB;AAGvB,IAAI,oCAAoC;AAUxC,SAAS,wBACP,SACA,SACS;AACT,MAAI,QAAQ,2BAA2B,QAAQ,yBAAyB;AACtE,UAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAI,IAAI,aAAa,eAAe,IAAI,aAAa,aAAa;AAChE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAOA,SAAS,gCAAsC;AAC7C,QAAM,UAAU;AAEhB,oBAAO,QAAQ,OAAO;AAEtB,MAAI,OAAO,SAAS,gBAAgB,cAAc,CAAC,mCAAmC;AACpF,wCAAoC;AACpC,YAAQ,YAAY,OAAO;AAAA,EAC7B;AACF;AAMO,SAAS,uBACd,SACA,SACM;AACN,MAAI,CAAC,QAAQ,IAAI,YAAY,EAAE,WAAW,UAAU,GAAG;AACrD,QAAI,wBAAwB,SAAS,OAAO,GAAG;AAC7C,oCAA8B;AAAA,IAChC,OAAO;AACL,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,34 +1,47 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.oauth2AuthenticationPolicyName = void 0;
6
- exports.oauth2AuthenticationPolicy = oauth2AuthenticationPolicy;
7
- const checkInsecureConnection_js_1 = require("./checkInsecureConnection.js");
8
- /**
9
- * Name of the OAuth2 Authentication Policy
10
- */
11
- exports.oauth2AuthenticationPolicyName = "oauth2AuthenticationPolicy";
12
- /**
13
- * Gets a pipeline policy that adds authorization header from OAuth2 schemes
14
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var oauth2AuthenticationPolicy_exports = {};
19
+ __export(oauth2AuthenticationPolicy_exports, {
20
+ oauth2AuthenticationPolicy: () => oauth2AuthenticationPolicy,
21
+ oauth2AuthenticationPolicyName: () => oauth2AuthenticationPolicyName
22
+ });
23
+ module.exports = __toCommonJS(oauth2AuthenticationPolicy_exports);
24
+ var import_checkInsecureConnection = require("./checkInsecureConnection.js");
25
+ const oauth2AuthenticationPolicyName = "oauth2AuthenticationPolicy";
15
26
  function oauth2AuthenticationPolicy(options) {
16
- return {
17
- name: exports.oauth2AuthenticationPolicyName,
18
- async sendRequest(request, next) {
19
- // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
20
- (0, checkInsecureConnection_js_1.ensureSecureConnection)(request, options);
21
- const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "oauth2");
22
- // Skip adding authentication header if no OAuth2 authentication scheme is found
23
- if (!scheme) {
24
- return next(request);
25
- }
26
- const token = await options.credential.getOAuth2Token(scheme.flows, {
27
- abortSignal: request.abortSignal,
28
- });
29
- request.headers.set("Authorization", `Bearer ${token}`);
30
- return next(request);
31
- },
32
- };
27
+ return {
28
+ name: oauth2AuthenticationPolicyName,
29
+ async sendRequest(request, next) {
30
+ (0, import_checkInsecureConnection.ensureSecureConnection)(request, options);
31
+ const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "oauth2");
32
+ if (!scheme) {
33
+ return next(request);
34
+ }
35
+ const token = await options.credential.getOAuth2Token(scheme.flows, {
36
+ abortSignal: request.abortSignal
37
+ });
38
+ request.headers.set("Authorization", `Bearer ${token}`);
39
+ return next(request);
40
+ }
41
+ };
33
42
  }
34
- //# sourceMappingURL=oauth2AuthenticationPolicy.js.map
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ oauth2AuthenticationPolicy,
46
+ oauth2AuthenticationPolicyName
47
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"oauth2AuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/oauth2AuthenticationPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAoClC,gEAsBC;AAnDD,6EAAsE;AAEtE;;GAEG;AACU,QAAA,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,SAAgB,0BAA0B,CACxC,OAAkD;IAElD,OAAO;QACL,IAAI,EAAE,sCAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,IAAA,mDAAsB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;YAE9F,gFAAgF;YAChF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,KAAiB,EAAE;gBAC9E,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;YACxD,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 { OAuth2Flow } from \"../../auth/oauth2Flows.js\";\nimport type { OAuth2TokenCredential } 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 { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the OAuth2 Authentication Policy\n */\nexport const oauth2AuthenticationPolicyName = \"oauth2AuthenticationPolicy\";\n\n/**\n * Options for configuring the OAuth2 authentication policy\n */\nexport interface OAuth2AuthenticationPolicyOptions<TFlows extends OAuth2Flow> {\n /**\n * The OAuth2TokenCredential implementation that can supply the bearer token.\n */\n credential: OAuth2TokenCredential<TFlows>;\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 authorization header from OAuth2 schemes\n */\nexport function oauth2AuthenticationPolicy<TFlows extends OAuth2Flow>(\n options: OAuth2AuthenticationPolicyOptions<TFlows>,\n): PipelinePolicy {\n return {\n name: oauth2AuthenticationPolicyName,\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((x) => x.kind === \"oauth2\");\n\n // Skip adding authentication header if no OAuth2 authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n const token = await options.credential.getOAuth2Token(scheme.flows as TFlows[], {\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/auth/oauth2AuthenticationPolicy.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"../../auth/oauth2Flows.js\";\nimport type { OAuth2TokenCredential } 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 { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the OAuth2 Authentication Policy\n */\nexport const oauth2AuthenticationPolicyName = \"oauth2AuthenticationPolicy\";\n\n/**\n * Options for configuring the OAuth2 authentication policy\n */\nexport interface OAuth2AuthenticationPolicyOptions<TFlows extends OAuth2Flow> {\n /**\n * The OAuth2TokenCredential implementation that can supply the bearer token.\n */\n credential: OAuth2TokenCredential<TFlows>;\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 authorization header from OAuth2 schemes\n */\nexport function oauth2AuthenticationPolicy<TFlows extends OAuth2Flow>(\n options: OAuth2AuthenticationPolicyOptions<TFlows>,\n): PipelinePolicy {\n return {\n name: oauth2AuthenticationPolicyName,\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((x) => x.kind === \"oauth2\");\n\n // Skip adding authentication header if no OAuth2 authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n const token = await options.credential.getOAuth2Token(scheme.flows as TFlows[], {\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qCAAuC;AAKhC,MAAM,iCAAiC;AAwBvC,SAAS,2BACd,SACgB;AAChB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,YAAY,SAA0B,MAA8C;AAExF,iEAAuB,SAAS,OAAO;AAEvC,YAAM,UAAU,QAAQ,eAAe,QAAQ,cAAc,KAAK,CAAC,MAAM,EAAE,SAAS,QAAQ;AAG5F,UAAI,CAAC,QAAQ;AACX,eAAO,KAAK,OAAO;AAAA,MACrB;AACA,YAAM,QAAQ,MAAM,QAAQ,WAAW,eAAe,OAAO,OAAmB;AAAA,QAC9E,aAAa,QAAQ;AAAA,MACvB,CAAC;AACD,cAAQ,QAAQ,IAAI,iBAAiB,UAAU,KAAK,EAAE;AACtD,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,27 +1,40 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.decompressResponsePolicyName = void 0;
6
- exports.decompressResponsePolicy = decompressResponsePolicy;
7
- /**
8
- * The programmatic identifier of the decompressResponsePolicy.
9
- */
10
- exports.decompressResponsePolicyName = "decompressResponsePolicy";
11
- /**
12
- * A policy to enable response decompression according to Accept-Encoding header
13
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
14
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var decompressResponsePolicy_exports = {};
19
+ __export(decompressResponsePolicy_exports, {
20
+ decompressResponsePolicy: () => decompressResponsePolicy,
21
+ decompressResponsePolicyName: () => decompressResponsePolicyName
22
+ });
23
+ module.exports = __toCommonJS(decompressResponsePolicy_exports);
24
+ const decompressResponsePolicyName = "decompressResponsePolicy";
15
25
  function decompressResponsePolicy() {
16
- return {
17
- name: exports.decompressResponsePolicyName,
18
- async sendRequest(request, next) {
19
- // HEAD requests have no body
20
- if (request.method !== "HEAD") {
21
- request.headers.set("Accept-Encoding", "gzip,deflate");
22
- }
23
- return next(request);
24
- },
25
- };
26
+ return {
27
+ name: decompressResponsePolicyName,
28
+ async sendRequest(request, next) {
29
+ if (request.method !== "HEAD") {
30
+ request.headers.set("Accept-Encoding", "gzip,deflate");
31
+ }
32
+ return next(request);
33
+ }
34
+ };
26
35
  }
27
- //# sourceMappingURL=decompressResponsePolicy.js.map
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ decompressResponsePolicy,
39
+ decompressResponsePolicyName
40
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"decompressResponsePolicy.js","sourceRoot":"","sources":["../../../src/policies/decompressResponsePolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAclC,4DAWC;AApBD;;GAEG;AACU,QAAA,4BAA4B,GAAG,0BAA0B,CAAC;AAEvE;;;GAGG;AACH,SAAgB,wBAAwB;IACtC,OAAO;QACL,IAAI,EAAE,oCAA4B;QAClC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,6BAA6B;YAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC9B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;YACzD,CAAC;YACD,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 { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\n/**\n * The programmatic identifier of the decompressResponsePolicy.\n */\nexport const decompressResponsePolicyName = \"decompressResponsePolicy\";\n\n/**\n * A policy to enable response decompression according to Accept-Encoding header\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding\n */\nexport function decompressResponsePolicy(): PipelinePolicy {\n return {\n name: decompressResponsePolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // HEAD requests have no body\n if (request.method !== \"HEAD\") {\n request.headers.set(\"Accept-Encoding\", \"gzip,deflate\");\n }\n return next(request);\n },\n };\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/decompressResponsePolicy.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\n/**\n * The programmatic identifier of the decompressResponsePolicy.\n */\nexport const decompressResponsePolicyName = \"decompressResponsePolicy\";\n\n/**\n * A policy to enable response decompression according to Accept-Encoding header\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding\n */\nexport function decompressResponsePolicy(): PipelinePolicy {\n return {\n name: decompressResponsePolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // HEAD requests have no body\n if (request.method !== \"HEAD\") {\n request.headers.set(\"Accept-Encoding\", \"gzip,deflate\");\n }\n return next(request);\n },\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,+BAA+B;AAMrC,SAAS,2BAA2C;AACzD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,YAAY,SAA0B,MAA8C;AAExF,UAAI,QAAQ,WAAW,QAAQ;AAC7B,gBAAQ,QAAQ,IAAI,mBAAmB,cAAc;AAAA,MACvD;AACA,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,29 +1,41 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.defaultRetryPolicyName = void 0;
6
- exports.defaultRetryPolicy = defaultRetryPolicy;
7
- const exponentialRetryStrategy_js_1 = require("../retryStrategies/exponentialRetryStrategy.js");
8
- const throttlingRetryStrategy_js_1 = require("../retryStrategies/throttlingRetryStrategy.js");
9
- const retryPolicy_js_1 = require("./retryPolicy.js");
10
- const constants_js_1 = require("../constants.js");
11
- /**
12
- * Name of the {@link defaultRetryPolicy}
13
- */
14
- exports.defaultRetryPolicyName = "defaultRetryPolicy";
15
- /**
16
- * A policy that retries according to three strategies:
17
- * - When the server sends a 429 response with a Retry-After header.
18
- * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).
19
- * - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.
20
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var defaultRetryPolicy_exports = {};
19
+ __export(defaultRetryPolicy_exports, {
20
+ defaultRetryPolicy: () => defaultRetryPolicy,
21
+ defaultRetryPolicyName: () => defaultRetryPolicyName
22
+ });
23
+ module.exports = __toCommonJS(defaultRetryPolicy_exports);
24
+ var import_exponentialRetryStrategy = require("../retryStrategies/exponentialRetryStrategy.js");
25
+ var import_throttlingRetryStrategy = require("../retryStrategies/throttlingRetryStrategy.js");
26
+ var import_retryPolicy = require("./retryPolicy.js");
27
+ var import_constants = require("../constants.js");
28
+ const defaultRetryPolicyName = "defaultRetryPolicy";
21
29
  function defaultRetryPolicy(options = {}) {
22
- return {
23
- name: exports.defaultRetryPolicyName,
24
- sendRequest: (0, retryPolicy_js_1.retryPolicy)([(0, throttlingRetryStrategy_js_1.throttlingRetryStrategy)(), (0, exponentialRetryStrategy_js_1.exponentialRetryStrategy)(options)], {
25
- maxRetries: options.maxRetries ?? constants_js_1.DEFAULT_RETRY_POLICY_COUNT,
26
- }).sendRequest,
27
- };
30
+ return {
31
+ name: defaultRetryPolicyName,
32
+ sendRequest: (0, import_retryPolicy.retryPolicy)([(0, import_throttlingRetryStrategy.throttlingRetryStrategy)(), (0, import_exponentialRetryStrategy.exponentialRetryStrategy)(options)], {
33
+ maxRetries: options.maxRetries ?? import_constants.DEFAULT_RETRY_POLICY_COUNT
34
+ }).sendRequest
35
+ };
28
36
  }
29
- //# sourceMappingURL=defaultRetryPolicy.js.map
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ defaultRetryPolicy,
40
+ defaultRetryPolicyName
41
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/defaultRetryPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAyBlC,gDAOC;AA5BD,gGAA0F;AAC1F,8FAAwF;AACxF,qDAA+C;AAC/C,kDAA6D;AAE7D;;GAEG;AACU,QAAA,sBAAsB,GAAG,oBAAoB,CAAC;AAO3D;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,UAAqC,EAAE;IACxE,OAAO;QACL,IAAI,EAAE,8BAAsB;QAC5B,WAAW,EAAE,IAAA,4BAAW,EAAC,CAAC,IAAA,oDAAuB,GAAE,EAAE,IAAA,sDAAwB,EAAC,OAAO,CAAC,CAAC,EAAE;YACvF,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,yCAA0B;SAC7D,CAAC,CAAC,WAAW;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRetryOptions } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { throttlingRetryStrategy } from \"../retryStrategies/throttlingRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * Name of the {@link defaultRetryPolicy}\n */\nexport const defaultRetryPolicyName = \"defaultRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface DefaultRetryPolicyOptions extends PipelineRetryOptions {}\n\n/**\n * A policy that retries according to three strategies:\n * - When the server sends a 429 response with a Retry-After header.\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.\n */\nexport function defaultRetryPolicy(options: DefaultRetryPolicyOptions = {}): PipelinePolicy {\n return {\n name: defaultRetryPolicyName,\n sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n }).sendRequest,\n };\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/defaultRetryPolicy.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRetryOptions } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { throttlingRetryStrategy } from \"../retryStrategies/throttlingRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * Name of the {@link defaultRetryPolicy}\n */\nexport const defaultRetryPolicyName = \"defaultRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface DefaultRetryPolicyOptions extends PipelineRetryOptions {}\n\n/**\n * A policy that retries according to three strategies:\n * - When the server sends a 429 response with a Retry-After header.\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.\n */\nexport function defaultRetryPolicy(options: DefaultRetryPolicyOptions = {}): PipelinePolicy {\n return {\n name: defaultRetryPolicyName,\n sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n }).sendRequest,\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,sCAAyC;AACzC,qCAAwC;AACxC,yBAA4B;AAC5B,uBAA2C;AAKpC,MAAM,yBAAyB;AAa/B,SAAS,mBAAmB,UAAqC,CAAC,GAAmB;AAC1F,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAa,gCAAY,KAAC,wDAAwB,OAAG,0DAAyB,OAAO,CAAC,GAAG;AAAA,MACvF,YAAY,QAAQ,cAAc;AAAA,IACpC,CAAC,EAAE;AAAA,EACL;AACF;",
6
+ "names": []
7
+ }
@@ -1,28 +1,45 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.exponentialRetryPolicyName = void 0;
6
- exports.exponentialRetryPolicy = exponentialRetryPolicy;
7
- const exponentialRetryStrategy_js_1 = require("../retryStrategies/exponentialRetryStrategy.js");
8
- const retryPolicy_js_1 = require("./retryPolicy.js");
9
- const constants_js_1 = require("../constants.js");
10
- /**
11
- * The programmatic identifier of the exponentialRetryPolicy.
12
- */
13
- exports.exponentialRetryPolicyName = "exponentialRetryPolicy";
14
- /**
15
- * A policy that attempts to retry requests while introducing an exponentially increasing delay.
16
- * @param options - Options that configure retry logic.
17
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var exponentialRetryPolicy_exports = {};
19
+ __export(exponentialRetryPolicy_exports, {
20
+ exponentialRetryPolicy: () => exponentialRetryPolicy,
21
+ exponentialRetryPolicyName: () => exponentialRetryPolicyName
22
+ });
23
+ module.exports = __toCommonJS(exponentialRetryPolicy_exports);
24
+ var import_exponentialRetryStrategy = require("../retryStrategies/exponentialRetryStrategy.js");
25
+ var import_retryPolicy = require("./retryPolicy.js");
26
+ var import_constants = require("../constants.js");
27
+ const exponentialRetryPolicyName = "exponentialRetryPolicy";
18
28
  function exponentialRetryPolicy(options = {}) {
19
- return (0, retryPolicy_js_1.retryPolicy)([
20
- (0, exponentialRetryStrategy_js_1.exponentialRetryStrategy)({
21
- ...options,
22
- ignoreSystemErrors: true,
23
- }),
24
- ], {
25
- maxRetries: options.maxRetries ?? constants_js_1.DEFAULT_RETRY_POLICY_COUNT,
26
- });
29
+ return (0, import_retryPolicy.retryPolicy)(
30
+ [
31
+ (0, import_exponentialRetryStrategy.exponentialRetryStrategy)({
32
+ ...options,
33
+ ignoreSystemErrors: true
34
+ })
35
+ ],
36
+ {
37
+ maxRetries: options.maxRetries ?? import_constants.DEFAULT_RETRY_POLICY_COUNT
38
+ }
39
+ );
27
40
  }
28
- //# sourceMappingURL=exponentialRetryPolicy.js.map
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ exponentialRetryPolicy,
44
+ exponentialRetryPolicyName
45
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"exponentialRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/exponentialRetryPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAuClC,wDAcC;AAlDD,gGAA0F;AAC1F,qDAA+C;AAC/C,kDAA6D;AAE7D;;GAEG;AACU,QAAA,0BAA0B,GAAG,wBAAwB,CAAC;AAyBnE;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,UAAyC,EAAE;IAE3C,OAAO,IAAA,4BAAW,EAChB;QACE,IAAA,sDAAwB,EAAC;YACvB,GAAG,OAAO;YACV,kBAAkB,EAAE,IAAI;SACzB,CAAC;KACH,EACD;QACE,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,yCAA0B;KAC7D,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * The programmatic identifier of the exponentialRetryPolicy.\n */\nexport const exponentialRetryPolicyName = \"exponentialRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ExponentialRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A policy that attempts to retry requests while introducing an exponentially increasing delay.\n * @param options - Options that configure retry logic.\n */\nexport function exponentialRetryPolicy(\n options: ExponentialRetryPolicyOptions = {},\n): PipelinePolicy {\n return retryPolicy(\n [\n exponentialRetryStrategy({\n ...options,\n ignoreSystemErrors: true,\n }),\n ],\n {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n },\n );\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/policies/exponentialRetryPolicy.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * The programmatic identifier of the exponentialRetryPolicy.\n */\nexport const exponentialRetryPolicyName = \"exponentialRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ExponentialRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A policy that attempts to retry requests while introducing an exponentially increasing delay.\n * @param options - Options that configure retry logic.\n */\nexport function exponentialRetryPolicy(\n options: ExponentialRetryPolicyOptions = {},\n): PipelinePolicy {\n return retryPolicy(\n [\n exponentialRetryStrategy({\n ...options,\n ignoreSystemErrors: true,\n }),\n ],\n {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n },\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sCAAyC;AACzC,yBAA4B;AAC5B,uBAA2C;AAKpC,MAAM,6BAA6B;AA6BnC,SAAS,uBACd,UAAyC,CAAC,GAC1B;AAChB,aAAO;AAAA,IACL;AAAA,UACE,0DAAyB;AAAA,QACvB,GAAG;AAAA,QACH,oBAAoB;AAAA,MACtB,CAAC;AAAA,IACH;AAAA,IACA;AAAA,MACE,YAAY,QAAQ,cAAc;AAAA,IACpC;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }