@cdk8s/awscdk-resolver 0.0.375 → 0.0.377

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 (423) hide show
  1. package/.jsii +2 -2
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@smithy/abort-controller/dist-cjs/index.js +28 -80
  4. package/node_modules/@smithy/abort-controller/dist-es/AbortController.js +1 -3
  5. package/node_modules/@smithy/abort-controller/dist-es/AbortSignal.js +2 -2
  6. package/node_modules/@smithy/abort-controller/package.json +2 -2
  7. package/node_modules/@smithy/config-resolver/dist-cjs/index.js +158 -215
  8. package/node_modules/@smithy/config-resolver/package.json +5 -5
  9. package/node_modules/@smithy/core/dist-cjs/index.js +308 -412
  10. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +957 -969
  11. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +198 -249
  12. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +793 -895
  13. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +617 -811
  14. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +584 -680
  15. package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +4 -0
  16. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +3 -3
  17. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +18 -18
  18. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +5 -5
  19. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +5 -0
  20. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +2 -0
  21. package/node_modules/@smithy/core/dist-es/submodules/protocols/requestBuilder.js +9 -7
  22. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +2 -0
  23. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +3 -0
  24. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +3 -0
  25. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +3 -2
  26. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +4 -1
  27. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js +3 -5
  28. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +5 -5
  29. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +6 -5
  30. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +16 -8
  31. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js +6 -5
  32. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js +3 -0
  33. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +5 -5
  34. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +6 -5
  35. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/sentinels.js +14 -14
  36. package/node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js +2 -0
  37. package/node_modules/@smithy/core/dist-es/util-identity-and-auth/DefaultIdentityProviderConfig.js +1 -1
  38. package/node_modules/@smithy/core/dist-es/util-identity-and-auth/memoizeIdentityProvider.js +4 -2
  39. package/node_modules/@smithy/core/package.json +11 -11
  40. package/node_modules/@smithy/credential-provider-imds/dist-cjs/index.js +340 -412
  41. package/node_modules/@smithy/credential-provider-imds/dist-es/error/InstanceMetadataV1FallbackError.js +2 -1
  42. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  43. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +190 -238
  44. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +2 -0
  45. package/node_modules/@smithy/fetch-http-handler/package.json +6 -6
  46. package/node_modules/@smithy/hash-node/dist-cjs/index.js +38 -63
  47. package/node_modules/@smithy/hash-node/dist-es/index.js +3 -0
  48. package/node_modules/@smithy/hash-node/package.json +4 -4
  49. package/node_modules/@smithy/invalid-dependency/dist-cjs/index.js +7 -38
  50. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  51. package/node_modules/@smithy/is-array-buffer/dist-cjs/index.js +4 -30
  52. package/node_modules/@smithy/is-array-buffer/package.json +1 -1
  53. package/node_modules/@smithy/middleware-content-length/dist-cjs/index.js +39 -64
  54. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  55. package/node_modules/@smithy/middleware-endpoint/dist-cjs/adaptors/getEndpointFromConfig.js +1 -1
  56. package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +219 -277
  57. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  58. package/node_modules/@smithy/middleware-retry/dist-cjs/index.js +327 -380
  59. package/node_modules/@smithy/middleware-retry/dist-cjs/isStreamingPayload/isStreamingPayload.browser.js +1 -1
  60. package/node_modules/@smithy/middleware-retry/dist-cjs/isStreamingPayload/isStreamingPayload.js +2 -2
  61. package/node_modules/@smithy/middleware-retry/dist-es/AdaptiveRetryStrategy.js +1 -0
  62. package/node_modules/@smithy/middleware-retry/dist-es/StandardRetryStrategy.js +5 -1
  63. package/node_modules/@smithy/middleware-retry/package.json +9 -9
  64. package/node_modules/@smithy/middleware-serde/dist-cjs/index.js +89 -118
  65. package/node_modules/@smithy/middleware-serde/package.json +3 -3
  66. package/node_modules/@smithy/middleware-stack/dist-cjs/index.js +274 -297
  67. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  68. package/node_modules/@smithy/node-config-provider/dist-cjs/index.js +51 -98
  69. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  70. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +663 -771
  71. package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +5 -3
  72. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +2 -1
  73. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +1 -1
  74. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +4 -2
  75. package/node_modules/@smithy/node-http-handler/dist-es/readable.mock.js +3 -1
  76. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +1 -4
  77. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/readable.mock.js +3 -1
  78. package/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +1 -1
  79. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  80. package/node_modules/@smithy/property-provider/dist-cjs/index.js +105 -158
  81. package/node_modules/@smithy/property-provider/dist-es/CredentialsProviderError.js +1 -1
  82. package/node_modules/@smithy/property-provider/dist-es/ProviderError.js +2 -1
  83. package/node_modules/@smithy/property-provider/dist-es/TokenProviderError.js +1 -1
  84. package/node_modules/@smithy/property-provider/package.json +2 -2
  85. package/node_modules/@smithy/protocol-http/dist-cjs/index.js +154 -246
  86. package/node_modules/@smithy/protocol-http/dist-es/Field.js +3 -0
  87. package/node_modules/@smithy/protocol-http/dist-es/Fields.js +2 -1
  88. package/node_modules/@smithy/protocol-http/dist-es/httpRequest.js +11 -0
  89. package/node_modules/@smithy/protocol-http/dist-es/httpResponse.js +4 -0
  90. package/node_modules/@smithy/protocol-http/package.json +2 -2
  91. package/node_modules/@smithy/querystring-builder/dist-cjs/index.js +21 -47
  92. package/node_modules/@smithy/querystring-builder/package.json +3 -3
  93. package/node_modules/@smithy/querystring-parser/dist-cjs/index.js +22 -48
  94. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  95. package/node_modules/@smithy/service-error-classification/dist-cjs/index.js +70 -103
  96. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  97. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/index.js +171 -210
  98. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/slurpFile.js +1 -1
  99. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  100. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +525 -648
  101. package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +2 -1
  102. package/node_modules/@smithy/signature-v4/dist-es/SignatureV4.js +1 -1
  103. package/node_modules/@smithy/signature-v4/dist-es/SignatureV4Base.js +6 -0
  104. package/node_modules/@smithy/signature-v4/package.json +8 -8
  105. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +554 -747
  106. package/node_modules/@smithy/smithy-client/dist-es/client.js +4 -1
  107. package/node_modules/@smithy/smithy-client/dist-es/command.js +17 -18
  108. package/node_modules/@smithy/smithy-client/dist-es/exceptions.js +4 -0
  109. package/node_modules/@smithy/smithy-client/package.json +7 -7
  110. package/node_modules/@smithy/types/dist-cjs/index.js +80 -133
  111. package/node_modules/@smithy/types/package.json +1 -1
  112. package/node_modules/@smithy/url-parser/dist-cjs/index.js +20 -46
  113. package/node_modules/@smithy/url-parser/package.json +3 -3
  114. package/node_modules/@smithy/util-base64/dist-cjs/index.js +16 -24
  115. package/node_modules/@smithy/util-base64/package.json +3 -3
  116. package/node_modules/@smithy/util-body-length-browser/dist-cjs/index.js +26 -50
  117. package/node_modules/@smithy/util-body-length-browser/package.json +1 -1
  118. package/node_modules/@smithy/util-body-length-node/dist-cjs/index.js +27 -50
  119. package/node_modules/@smithy/util-body-length-node/package.json +1 -1
  120. package/node_modules/@smithy/util-buffer-from/dist-cjs/index.js +17 -44
  121. package/node_modules/@smithy/util-buffer-from/package.json +2 -2
  122. package/node_modules/@smithy/util-config-provider/dist-cjs/index.js +26 -56
  123. package/node_modules/@smithy/util-config-provider/package.json +1 -1
  124. package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/index.js +9 -22
  125. package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/resolveDefaultsModeConfig.js +4 -5
  126. package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/resolveDefaultsModeConfig.native.js +2 -2
  127. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  128. package/node_modules/@smithy/util-defaults-mode-node/dist-cjs/index.js +65 -110
  129. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  130. package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +445 -526
  131. package/node_modules/@smithy/util-endpoints/dist-es/cache/EndpointCache.js +3 -2
  132. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  133. package/node_modules/@smithy/util-hex-encoding/dist-cjs/index.js +29 -58
  134. package/node_modules/@smithy/util-hex-encoding/package.json +1 -1
  135. package/node_modules/@smithy/util-middleware/dist-cjs/index.js +11 -40
  136. package/node_modules/@smithy/util-middleware/package.json +2 -2
  137. package/node_modules/@smithy/util-retry/dist-cjs/index.js +260 -340
  138. package/node_modules/@smithy/util-retry/dist-es/AdaptiveRetryStrategy.js +4 -1
  139. package/node_modules/@smithy/util-retry/dist-es/ConfiguredRetryStrategy.js +1 -0
  140. package/node_modules/@smithy/util-retry/dist-es/DefaultRateLimiter.js +17 -8
  141. package/node_modules/@smithy/util-retry/dist-es/StandardRetryStrategy.js +5 -3
  142. package/node_modules/@smithy/util-retry/package.json +3 -3
  143. package/node_modules/@smithy/util-stream/dist-cjs/ByteArrayCollector.js +3 -2
  144. package/node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.js +7 -3
  145. package/node_modules/@smithy/util-stream/dist-cjs/checksum/createChecksumStream.browser.js +2 -3
  146. package/node_modules/@smithy/util-stream/dist-cjs/createBufferedReadable.js +1 -1
  147. package/node_modules/@smithy/util-stream/dist-cjs/createBufferedReadableStream.js +2 -3
  148. package/node_modules/@smithy/util-stream/dist-cjs/headStream.browser.js +1 -2
  149. package/node_modules/@smithy/util-stream/dist-cjs/headStream.js +4 -8
  150. package/node_modules/@smithy/util-stream/dist-cjs/index.js +83 -93
  151. package/node_modules/@smithy/util-stream/dist-cjs/sdk-stream-mixin.browser.js +1 -2
  152. package/node_modules/@smithy/util-stream/dist-cjs/sdk-stream-mixin.js +1 -2
  153. package/node_modules/@smithy/util-stream/dist-cjs/stream-type-check.js +3 -7
  154. package/node_modules/@smithy/util-stream/dist-es/ByteArrayCollector.js +3 -2
  155. package/node_modules/@smithy/util-stream/dist-es/checksum/ChecksumStream.js +5 -0
  156. package/node_modules/@smithy/util-stream/dist-es/headStream.js +3 -6
  157. package/node_modules/@smithy/util-stream/package.json +8 -8
  158. package/node_modules/@smithy/util-uri-escape/dist-cjs/index.js +6 -40
  159. package/node_modules/@smithy/util-uri-escape/package.json +1 -1
  160. package/node_modules/@smithy/util-utf8/dist-cjs/index.js +27 -60
  161. package/node_modules/@smithy/util-utf8/package.json +2 -2
  162. package/node_modules/@smithy/util-waiter/dist-cjs/index.js +152 -189
  163. package/node_modules/@smithy/util-waiter/package.json +3 -3
  164. package/node_modules/@smithy/uuid/dist-cjs/index.js +33 -42
  165. package/node_modules/@smithy/uuid/package.json +1 -1
  166. package/package.json +5 -5
  167. package/node_modules/@smithy/abort-controller/dist-cjs/AbortController.js +0 -1
  168. package/node_modules/@smithy/abort-controller/dist-cjs/AbortSignal.js +0 -1
  169. package/node_modules/@smithy/config-resolver/dist-cjs/endpointsConfig/NodeUseDualstackEndpointConfigOptions.js +0 -1
  170. package/node_modules/@smithy/config-resolver/dist-cjs/endpointsConfig/NodeUseFipsEndpointConfigOptions.js +0 -1
  171. package/node_modules/@smithy/config-resolver/dist-cjs/endpointsConfig/index.js +0 -1
  172. package/node_modules/@smithy/config-resolver/dist-cjs/endpointsConfig/resolveCustomEndpointsConfig.js +0 -1
  173. package/node_modules/@smithy/config-resolver/dist-cjs/endpointsConfig/resolveEndpointsConfig.js +0 -1
  174. package/node_modules/@smithy/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js +0 -1
  175. package/node_modules/@smithy/config-resolver/dist-cjs/regionConfig/config.js +0 -1
  176. package/node_modules/@smithy/config-resolver/dist-cjs/regionConfig/getRealRegion.js +0 -1
  177. package/node_modules/@smithy/config-resolver/dist-cjs/regionConfig/index.js +0 -1
  178. package/node_modules/@smithy/config-resolver/dist-cjs/regionConfig/isFipsRegion.js +0 -1
  179. package/node_modules/@smithy/config-resolver/dist-cjs/regionConfig/resolveRegionConfig.js +0 -1
  180. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/EndpointVariant.js +0 -1
  181. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/EndpointVariantTag.js +0 -1
  182. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/PartitionHash.js +0 -1
  183. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/RegionHash.js +0 -1
  184. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/getHostnameFromVariants.js +0 -1
  185. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/getRegionInfo.js +0 -1
  186. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/getResolvedHostname.js +0 -1
  187. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/getResolvedPartition.js +0 -1
  188. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/getResolvedSigningRegion.js +0 -1
  189. package/node_modules/@smithy/config-resolver/dist-cjs/regionInfo/index.js +0 -1
  190. package/node_modules/@smithy/credential-provider-imds/dist-cjs/config/Endpoint.js +0 -1
  191. package/node_modules/@smithy/credential-provider-imds/dist-cjs/config/EndpointConfigOptions.js +0 -1
  192. package/node_modules/@smithy/credential-provider-imds/dist-cjs/config/EndpointMode.js +0 -1
  193. package/node_modules/@smithy/credential-provider-imds/dist-cjs/config/EndpointModeConfigOptions.js +0 -1
  194. package/node_modules/@smithy/credential-provider-imds/dist-cjs/error/InstanceMetadataV1FallbackError.js +0 -1
  195. package/node_modules/@smithy/credential-provider-imds/dist-cjs/fromContainerMetadata.js +0 -1
  196. package/node_modules/@smithy/credential-provider-imds/dist-cjs/fromInstanceMetadata.js +0 -1
  197. package/node_modules/@smithy/credential-provider-imds/dist-cjs/remoteProvider/ImdsCredentials.js +0 -1
  198. package/node_modules/@smithy/credential-provider-imds/dist-cjs/remoteProvider/RemoteProviderInit.js +0 -1
  199. package/node_modules/@smithy/credential-provider-imds/dist-cjs/remoteProvider/httpRequest.js +0 -1
  200. package/node_modules/@smithy/credential-provider-imds/dist-cjs/remoteProvider/index.js +0 -1
  201. package/node_modules/@smithy/credential-provider-imds/dist-cjs/remoteProvider/retry.js +0 -1
  202. package/node_modules/@smithy/credential-provider-imds/dist-cjs/types.js +0 -1
  203. package/node_modules/@smithy/credential-provider-imds/dist-cjs/utils/getExtendedInstanceMetadataCredentials.js +0 -1
  204. package/node_modules/@smithy/credential-provider-imds/dist-cjs/utils/getInstanceMetadataEndpoint.js +0 -1
  205. package/node_modules/@smithy/credential-provider-imds/dist-cjs/utils/staticStabilityProvider.js +0 -1
  206. package/node_modules/@smithy/fetch-http-handler/dist-cjs/create-request.js +0 -1
  207. package/node_modules/@smithy/fetch-http-handler/dist-cjs/fetch-http-handler.js +0 -1
  208. package/node_modules/@smithy/fetch-http-handler/dist-cjs/request-timeout.js +0 -1
  209. package/node_modules/@smithy/fetch-http-handler/dist-cjs/stream-collector.js +0 -1
  210. package/node_modules/@smithy/invalid-dependency/dist-cjs/invalidFunction.js +0 -1
  211. package/node_modules/@smithy/invalid-dependency/dist-cjs/invalidProvider.js +0 -1
  212. package/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js +0 -1
  213. package/node_modules/@smithy/middleware-serde/dist-cjs/serdePlugin.js +0 -1
  214. package/node_modules/@smithy/middleware-serde/dist-cjs/serializerMiddleware.js +0 -1
  215. package/node_modules/@smithy/middleware-stack/dist-cjs/MiddlewareStack.js +0 -1
  216. package/node_modules/@smithy/middleware-stack/dist-cjs/types.js +0 -1
  217. package/node_modules/@smithy/node-config-provider/dist-cjs/configLoader.js +0 -1
  218. package/node_modules/@smithy/node-config-provider/dist-cjs/fromEnv.js +0 -1
  219. package/node_modules/@smithy/node-config-provider/dist-cjs/fromSharedConfigFiles.js +0 -1
  220. package/node_modules/@smithy/node-config-provider/dist-cjs/fromStatic.js +0 -1
  221. package/node_modules/@smithy/node-config-provider/dist-cjs/getSelectorName.js +0 -1
  222. package/node_modules/@smithy/node-http-handler/dist-cjs/constants.js +0 -1
  223. package/node_modules/@smithy/node-http-handler/dist-cjs/get-transformed-headers.js +0 -1
  224. package/node_modules/@smithy/node-http-handler/dist-cjs/node-http-handler.js +0 -1
  225. package/node_modules/@smithy/node-http-handler/dist-cjs/node-http2-connection-manager.js +0 -1
  226. package/node_modules/@smithy/node-http-handler/dist-cjs/node-http2-connection-pool.js +0 -1
  227. package/node_modules/@smithy/node-http-handler/dist-cjs/node-http2-handler.js +0 -1
  228. package/node_modules/@smithy/node-http-handler/dist-cjs/readable.mock.js +0 -1
  229. package/node_modules/@smithy/node-http-handler/dist-cjs/server.mock.js +0 -1
  230. package/node_modules/@smithy/node-http-handler/dist-cjs/set-connection-timeout.js +0 -1
  231. package/node_modules/@smithy/node-http-handler/dist-cjs/set-socket-keep-alive.js +0 -1
  232. package/node_modules/@smithy/node-http-handler/dist-cjs/set-socket-timeout.js +0 -1
  233. package/node_modules/@smithy/node-http-handler/dist-cjs/stream-collector/collector.js +0 -1
  234. package/node_modules/@smithy/node-http-handler/dist-cjs/stream-collector/index.js +0 -1
  235. package/node_modules/@smithy/node-http-handler/dist-cjs/stream-collector/readable.mock.js +0 -1
  236. package/node_modules/@smithy/node-http-handler/dist-cjs/timing.js +0 -1
  237. package/node_modules/@smithy/node-http-handler/dist-cjs/write-request-body.js +0 -1
  238. package/node_modules/@smithy/property-provider/dist-cjs/CredentialsProviderError.js +0 -1
  239. package/node_modules/@smithy/property-provider/dist-cjs/ProviderError.js +0 -1
  240. package/node_modules/@smithy/property-provider/dist-cjs/TokenProviderError.js +0 -1
  241. package/node_modules/@smithy/property-provider/dist-cjs/chain.js +0 -1
  242. package/node_modules/@smithy/property-provider/dist-cjs/fromStatic.js +0 -1
  243. package/node_modules/@smithy/property-provider/dist-cjs/memoize.js +0 -1
  244. package/node_modules/@smithy/protocol-http/dist-cjs/Field.js +0 -1
  245. package/node_modules/@smithy/protocol-http/dist-cjs/Fields.js +0 -1
  246. package/node_modules/@smithy/protocol-http/dist-cjs/extensions/httpExtensionConfiguration.js +0 -1
  247. package/node_modules/@smithy/protocol-http/dist-cjs/extensions/index.js +0 -1
  248. package/node_modules/@smithy/protocol-http/dist-cjs/httpHandler.js +0 -1
  249. package/node_modules/@smithy/protocol-http/dist-cjs/httpRequest.js +0 -1
  250. package/node_modules/@smithy/protocol-http/dist-cjs/httpResponse.js +0 -1
  251. package/node_modules/@smithy/protocol-http/dist-cjs/isValidHostname.js +0 -1
  252. package/node_modules/@smithy/protocol-http/dist-cjs/types.js +0 -1
  253. package/node_modules/@smithy/service-error-classification/dist-cjs/constants.js +0 -1
  254. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/externalDataInterceptor.js +0 -1
  255. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/getConfigData.js +0 -1
  256. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/getConfigFilepath.js +0 -1
  257. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/getCredentialsFilepath.js +0 -1
  258. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/getProfileName.js +0 -1
  259. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/getSsoSessionData.js +0 -1
  260. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/loadSharedConfigFiles.js +0 -1
  261. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/loadSsoSessionData.js +0 -1
  262. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/mergeConfigFiles.js +0 -1
  263. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/parseIni.js +0 -1
  264. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/parseKnownFiles.js +0 -1
  265. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/types.js +0 -1
  266. package/node_modules/@smithy/signature-v4/dist-cjs/HeaderFormatter.js +0 -1
  267. package/node_modules/@smithy/signature-v4/dist-cjs/SignatureV4.js +0 -1
  268. package/node_modules/@smithy/signature-v4/dist-cjs/SignatureV4Base.js +0 -1
  269. package/node_modules/@smithy/signature-v4/dist-cjs/constants.js +0 -1
  270. package/node_modules/@smithy/signature-v4/dist-cjs/credentialDerivation.js +0 -1
  271. package/node_modules/@smithy/signature-v4/dist-cjs/getCanonicalHeaders.js +0 -1
  272. package/node_modules/@smithy/signature-v4/dist-cjs/getCanonicalQuery.js +0 -1
  273. package/node_modules/@smithy/signature-v4/dist-cjs/getPayloadHash.js +0 -1
  274. package/node_modules/@smithy/signature-v4/dist-cjs/headerUtil.js +0 -1
  275. package/node_modules/@smithy/signature-v4/dist-cjs/moveHeadersToQuery.js +0 -1
  276. package/node_modules/@smithy/signature-v4/dist-cjs/prepareRequest.js +0 -1
  277. package/node_modules/@smithy/signature-v4/dist-cjs/signature-v4a-container.js +0 -1
  278. package/node_modules/@smithy/signature-v4/dist-cjs/suite.fixture.js +0 -1
  279. package/node_modules/@smithy/signature-v4/dist-cjs/utilDate.js +0 -1
  280. package/node_modules/@smithy/types/dist-cjs/abort-handler.js +0 -1
  281. package/node_modules/@smithy/types/dist-cjs/abort.js +0 -1
  282. package/node_modules/@smithy/types/dist-cjs/auth/HttpApiKeyAuth.js +0 -1
  283. package/node_modules/@smithy/types/dist-cjs/auth/HttpAuthScheme.js +0 -1
  284. package/node_modules/@smithy/types/dist-cjs/auth/HttpAuthSchemeProvider.js +0 -1
  285. package/node_modules/@smithy/types/dist-cjs/auth/HttpSigner.js +0 -1
  286. package/node_modules/@smithy/types/dist-cjs/auth/IdentityProviderConfig.js +0 -1
  287. package/node_modules/@smithy/types/dist-cjs/auth/auth.js +0 -1
  288. package/node_modules/@smithy/types/dist-cjs/auth/index.js +0 -1
  289. package/node_modules/@smithy/types/dist-cjs/blob/blob-payload-input-types.js +0 -1
  290. package/node_modules/@smithy/types/dist-cjs/checksum.js +0 -1
  291. package/node_modules/@smithy/types/dist-cjs/client.js +0 -1
  292. package/node_modules/@smithy/types/dist-cjs/command.js +0 -1
  293. package/node_modules/@smithy/types/dist-cjs/connection/config.js +0 -1
  294. package/node_modules/@smithy/types/dist-cjs/connection/index.js +0 -1
  295. package/node_modules/@smithy/types/dist-cjs/connection/manager.js +0 -1
  296. package/node_modules/@smithy/types/dist-cjs/connection/pool.js +0 -1
  297. package/node_modules/@smithy/types/dist-cjs/crypto.js +0 -1
  298. package/node_modules/@smithy/types/dist-cjs/downlevel-ts3.4/transform/type-transform.js +0 -1
  299. package/node_modules/@smithy/types/dist-cjs/encode.js +0 -1
  300. package/node_modules/@smithy/types/dist-cjs/endpoint.js +0 -1
  301. package/node_modules/@smithy/types/dist-cjs/endpoints/EndpointRuleObject.js +0 -1
  302. package/node_modules/@smithy/types/dist-cjs/endpoints/ErrorRuleObject.js +0 -1
  303. package/node_modules/@smithy/types/dist-cjs/endpoints/RuleSetObject.js +0 -1
  304. package/node_modules/@smithy/types/dist-cjs/endpoints/TreeRuleObject.js +0 -1
  305. package/node_modules/@smithy/types/dist-cjs/endpoints/index.js +0 -1
  306. package/node_modules/@smithy/types/dist-cjs/endpoints/shared.js +0 -1
  307. package/node_modules/@smithy/types/dist-cjs/eventStream.js +0 -1
  308. package/node_modules/@smithy/types/dist-cjs/extensions/checksum.js +0 -1
  309. package/node_modules/@smithy/types/dist-cjs/extensions/defaultClientConfiguration.js +0 -1
  310. package/node_modules/@smithy/types/dist-cjs/extensions/defaultExtensionConfiguration.js +0 -1
  311. package/node_modules/@smithy/types/dist-cjs/extensions/index.js +0 -1
  312. package/node_modules/@smithy/types/dist-cjs/extensions/retry.js +0 -1
  313. package/node_modules/@smithy/types/dist-cjs/externals-check/browser-externals-check.js +0 -1
  314. package/node_modules/@smithy/types/dist-cjs/feature-ids.js +0 -1
  315. package/node_modules/@smithy/types/dist-cjs/http/httpHandlerInitialization.js +0 -1
  316. package/node_modules/@smithy/types/dist-cjs/http.js +0 -1
  317. package/node_modules/@smithy/types/dist-cjs/identity/apiKeyIdentity.js +0 -1
  318. package/node_modules/@smithy/types/dist-cjs/identity/awsCredentialIdentity.js +0 -1
  319. package/node_modules/@smithy/types/dist-cjs/identity/identity.js +0 -1
  320. package/node_modules/@smithy/types/dist-cjs/identity/index.js +0 -1
  321. package/node_modules/@smithy/types/dist-cjs/identity/tokenIdentity.js +0 -1
  322. package/node_modules/@smithy/types/dist-cjs/logger.js +0 -1
  323. package/node_modules/@smithy/types/dist-cjs/middleware.js +0 -1
  324. package/node_modules/@smithy/types/dist-cjs/pagination.js +0 -1
  325. package/node_modules/@smithy/types/dist-cjs/profile.js +0 -1
  326. package/node_modules/@smithy/types/dist-cjs/response.js +0 -1
  327. package/node_modules/@smithy/types/dist-cjs/retry.js +0 -1
  328. package/node_modules/@smithy/types/dist-cjs/schema/schema.js +0 -1
  329. package/node_modules/@smithy/types/dist-cjs/schema/sentinels.js +0 -1
  330. package/node_modules/@smithy/types/dist-cjs/schema/traits.js +0 -1
  331. package/node_modules/@smithy/types/dist-cjs/serde.js +0 -1
  332. package/node_modules/@smithy/types/dist-cjs/shapes.js +0 -1
  333. package/node_modules/@smithy/types/dist-cjs/signature.js +0 -1
  334. package/node_modules/@smithy/types/dist-cjs/stream.js +0 -1
  335. package/node_modules/@smithy/types/dist-cjs/streaming-payload/streaming-blob-common-types.js +0 -1
  336. package/node_modules/@smithy/types/dist-cjs/streaming-payload/streaming-blob-payload-input-types.js +0 -1
  337. package/node_modules/@smithy/types/dist-cjs/streaming-payload/streaming-blob-payload-output-types.js +0 -1
  338. package/node_modules/@smithy/types/dist-cjs/transfer.js +0 -1
  339. package/node_modules/@smithy/types/dist-cjs/transform/client-method-transforms.js +0 -1
  340. package/node_modules/@smithy/types/dist-cjs/transform/client-payload-blob-type-narrow.js +0 -1
  341. package/node_modules/@smithy/types/dist-cjs/transform/exact.js +0 -1
  342. package/node_modules/@smithy/types/dist-cjs/transform/mutable.js +0 -1
  343. package/node_modules/@smithy/types/dist-cjs/transform/no-undefined.js +0 -1
  344. package/node_modules/@smithy/types/dist-cjs/transform/type-transform.js +0 -1
  345. package/node_modules/@smithy/types/dist-cjs/uri.js +0 -1
  346. package/node_modules/@smithy/types/dist-cjs/util.js +0 -1
  347. package/node_modules/@smithy/types/dist-cjs/waiter.js +0 -1
  348. package/node_modules/@smithy/util-body-length-browser/dist-cjs/calculateBodyLength.js +0 -1
  349. package/node_modules/@smithy/util-body-length-node/dist-cjs/calculateBodyLength.js +0 -1
  350. package/node_modules/@smithy/util-config-provider/dist-cjs/booleanSelector.js +0 -1
  351. package/node_modules/@smithy/util-config-provider/dist-cjs/numberSelector.js +0 -1
  352. package/node_modules/@smithy/util-config-provider/dist-cjs/types.js +0 -1
  353. package/node_modules/@smithy/util-endpoints/dist-cjs/cache/EndpointCache.js +0 -1
  354. package/node_modules/@smithy/util-endpoints/dist-cjs/debug/debugId.js +0 -1
  355. package/node_modules/@smithy/util-endpoints/dist-cjs/debug/index.js +0 -1
  356. package/node_modules/@smithy/util-endpoints/dist-cjs/debug/toDebugString.js +0 -1
  357. package/node_modules/@smithy/util-endpoints/dist-cjs/getEndpointUrlConfig.js +0 -1
  358. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/booleanEquals.js +0 -1
  359. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/getAttr.js +0 -1
  360. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/getAttrPathList.js +0 -1
  361. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/index.js +0 -1
  362. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/isIpAddress.js +0 -1
  363. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/isSet.js +0 -1
  364. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/isValidHostLabel.js +0 -1
  365. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/not.js +0 -1
  366. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/parseURL.js +0 -1
  367. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/stringEquals.js +0 -1
  368. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/substring.js +0 -1
  369. package/node_modules/@smithy/util-endpoints/dist-cjs/lib/uriEncode.js +0 -1
  370. package/node_modules/@smithy/util-endpoints/dist-cjs/resolveEndpoint.js +0 -1
  371. package/node_modules/@smithy/util-endpoints/dist-cjs/types/EndpointError.js +0 -1
  372. package/node_modules/@smithy/util-endpoints/dist-cjs/types/EndpointFunctions.js +0 -1
  373. package/node_modules/@smithy/util-endpoints/dist-cjs/types/EndpointRuleObject.js +0 -1
  374. package/node_modules/@smithy/util-endpoints/dist-cjs/types/ErrorRuleObject.js +0 -1
  375. package/node_modules/@smithy/util-endpoints/dist-cjs/types/RuleSetObject.js +0 -1
  376. package/node_modules/@smithy/util-endpoints/dist-cjs/types/TreeRuleObject.js +0 -1
  377. package/node_modules/@smithy/util-endpoints/dist-cjs/types/index.js +0 -1
  378. package/node_modules/@smithy/util-endpoints/dist-cjs/types/shared.js +0 -1
  379. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/callFunction.js +0 -1
  380. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/customEndpointFunctions.js +0 -1
  381. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/endpointFunctions.js +0 -1
  382. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateCondition.js +0 -1
  383. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateConditions.js +0 -1
  384. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateEndpointRule.js +0 -1
  385. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateErrorRule.js +0 -1
  386. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateExpression.js +0 -1
  387. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateRules.js +0 -1
  388. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateTemplate.js +0 -1
  389. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/evaluateTreeRule.js +0 -1
  390. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/getEndpointHeaders.js +0 -1
  391. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/getEndpointProperties.js +0 -1
  392. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/getEndpointProperty.js +0 -1
  393. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/getEndpointUrl.js +0 -1
  394. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/getReferenceValue.js +0 -1
  395. package/node_modules/@smithy/util-endpoints/dist-cjs/utils/index.js +0 -1
  396. package/node_modules/@smithy/util-middleware/dist-cjs/getSmithyContext.js +0 -1
  397. package/node_modules/@smithy/util-middleware/dist-cjs/normalizeProvider.js +0 -1
  398. package/node_modules/@smithy/util-retry/dist-cjs/AdaptiveRetryStrategy.js +0 -1
  399. package/node_modules/@smithy/util-retry/dist-cjs/ConfiguredRetryStrategy.js +0 -1
  400. package/node_modules/@smithy/util-retry/dist-cjs/DefaultRateLimiter.js +0 -1
  401. package/node_modules/@smithy/util-retry/dist-cjs/StandardRetryStrategy.js +0 -1
  402. package/node_modules/@smithy/util-retry/dist-cjs/config.js +0 -1
  403. package/node_modules/@smithy/util-retry/dist-cjs/constants.js +0 -1
  404. package/node_modules/@smithy/util-retry/dist-cjs/defaultRetryBackoffStrategy.js +0 -1
  405. package/node_modules/@smithy/util-retry/dist-cjs/defaultRetryToken.js +0 -1
  406. package/node_modules/@smithy/util-retry/dist-cjs/types.js +0 -1
  407. package/node_modules/@smithy/util-stream/dist-cjs/blob/Uint8ArrayBlobAdapter.js +0 -1
  408. package/node_modules/@smithy/util-stream/dist-cjs/blob/transforms.js +0 -1
  409. package/node_modules/@smithy/util-uri-escape/dist-cjs/escape-uri-path.js +0 -1
  410. package/node_modules/@smithy/util-uri-escape/dist-cjs/escape-uri.js +0 -1
  411. package/node_modules/@smithy/util-utf8/dist-cjs/fromUtf8.browser.js +0 -1
  412. package/node_modules/@smithy/util-utf8/dist-cjs/fromUtf8.js +0 -1
  413. package/node_modules/@smithy/util-utf8/dist-cjs/toUint8Array.js +0 -1
  414. package/node_modules/@smithy/util-utf8/dist-cjs/toUtf8.browser.js +0 -1
  415. package/node_modules/@smithy/util-utf8/dist-cjs/toUtf8.js +0 -1
  416. package/node_modules/@smithy/util-waiter/dist-cjs/createWaiter.js +0 -1
  417. package/node_modules/@smithy/util-waiter/dist-cjs/poller.js +0 -1
  418. package/node_modules/@smithy/util-waiter/dist-cjs/utils/index.js +0 -1
  419. package/node_modules/@smithy/util-waiter/dist-cjs/utils/sleep.js +0 -1
  420. package/node_modules/@smithy/util-waiter/dist-cjs/utils/validate.js +0 -1
  421. package/node_modules/@smithy/util-waiter/dist-cjs/waiter.js +0 -1
  422. package/node_modules/@smithy/uuid/dist-cjs/randomUUID.browser.js +0 -1
  423. package/node_modules/@smithy/uuid/dist-cjs/v4.js +0 -1
@@ -1,808 +1,700 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
29
2
 
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- DEFAULT_REQUEST_TIMEOUT: () => DEFAULT_REQUEST_TIMEOUT,
34
- NodeHttp2Handler: () => NodeHttp2Handler,
35
- NodeHttpHandler: () => NodeHttpHandler,
36
- streamCollector: () => streamCollector
37
- });
38
- module.exports = __toCommonJS(index_exports);
3
+ var protocolHttp = require('@smithy/protocol-http');
4
+ var querystringBuilder = require('@smithy/querystring-builder');
5
+ var http = require('http');
6
+ var https = require('https');
7
+ var stream = require('stream');
8
+ var http2 = require('http2');
39
9
 
40
- // src/node-http-handler.ts
41
- var import_protocol_http = require("@smithy/protocol-http");
42
- var import_querystring_builder = require("@smithy/querystring-builder");
43
- var import_http = require("http");
44
- var import_https = require("https");
10
+ const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
45
11
 
46
- // src/constants.ts
47
- var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
48
-
49
- // src/get-transformed-headers.ts
50
- var getTransformedHeaders = /* @__PURE__ */ __name((headers) => {
51
- const transformedHeaders = {};
52
- for (const name of Object.keys(headers)) {
53
- const headerValues = headers[name];
54
- transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
55
- }
56
- return transformedHeaders;
57
- }, "getTransformedHeaders");
12
+ const getTransformedHeaders = (headers) => {
13
+ const transformedHeaders = {};
14
+ for (const name of Object.keys(headers)) {
15
+ const headerValues = headers[name];
16
+ transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
17
+ }
18
+ return transformedHeaders;
19
+ };
58
20
 
59
- // src/timing.ts
60
- var timing = {
61
- setTimeout: /* @__PURE__ */ __name((cb, ms) => setTimeout(cb, ms), "setTimeout"),
62
- clearTimeout: /* @__PURE__ */ __name((timeoutId) => clearTimeout(timeoutId), "clearTimeout")
21
+ const timing = {
22
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
23
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId),
63
24
  };
64
25
 
65
- // src/set-connection-timeout.ts
66
- var DEFER_EVENT_LISTENER_TIME = 1e3;
67
- var setConnectionTimeout = /* @__PURE__ */ __name((request, reject, timeoutInMs = 0) => {
68
- if (!timeoutInMs) {
69
- return -1;
70
- }
71
- const registerTimeout = /* @__PURE__ */ __name((offset) => {
72
- const timeoutId = timing.setTimeout(() => {
73
- request.destroy();
74
- reject(
75
- Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
76
- name: "TimeoutError"
77
- })
78
- );
79
- }, timeoutInMs - offset);
80
- const doWithSocket = /* @__PURE__ */ __name((socket) => {
81
- if (socket?.connecting) {
82
- socket.on("connect", () => {
83
- timing.clearTimeout(timeoutId);
84
- });
85
- } else {
86
- timing.clearTimeout(timeoutId);
87
- }
88
- }, "doWithSocket");
89
- if (request.socket) {
90
- doWithSocket(request.socket);
91
- } else {
92
- request.on("socket", doWithSocket);
93
- }
94
- }, "registerTimeout");
95
- if (timeoutInMs < 2e3) {
96
- registerTimeout(0);
97
- return 0;
98
- }
99
- return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
100
- }, "setConnectionTimeout");
26
+ const DEFER_EVENT_LISTENER_TIME$2 = 1000;
27
+ const setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
28
+ if (!timeoutInMs) {
29
+ return -1;
30
+ }
31
+ const registerTimeout = (offset) => {
32
+ const timeoutId = timing.setTimeout(() => {
33
+ request.destroy();
34
+ reject(Object.assign(new Error(`Socket timed out without establishing a connection within ${timeoutInMs} ms`), {
35
+ name: "TimeoutError",
36
+ }));
37
+ }, timeoutInMs - offset);
38
+ const doWithSocket = (socket) => {
39
+ if (socket?.connecting) {
40
+ socket.on("connect", () => {
41
+ timing.clearTimeout(timeoutId);
42
+ });
43
+ }
44
+ else {
45
+ timing.clearTimeout(timeoutId);
46
+ }
47
+ };
48
+ if (request.socket) {
49
+ doWithSocket(request.socket);
50
+ }
51
+ else {
52
+ request.on("socket", doWithSocket);
53
+ }
54
+ };
55
+ if (timeoutInMs < 2000) {
56
+ registerTimeout(0);
57
+ return 0;
58
+ }
59
+ return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
60
+ };
101
61
 
102
- // src/set-socket-keep-alive.ts
103
- var DEFER_EVENT_LISTENER_TIME2 = 3e3;
104
- var setSocketKeepAlive = /* @__PURE__ */ __name((request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME2) => {
105
- if (keepAlive !== true) {
106
- return -1;
107
- }
108
- const registerListener = /* @__PURE__ */ __name(() => {
109
- if (request.socket) {
110
- request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
111
- } else {
112
- request.on("socket", (socket) => {
113
- socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
114
- });
115
- }
116
- }, "registerListener");
117
- if (deferTimeMs === 0) {
118
- registerListener();
119
- return 0;
120
- }
121
- return timing.setTimeout(registerListener, deferTimeMs);
122
- }, "setSocketKeepAlive");
62
+ const DEFER_EVENT_LISTENER_TIME$1 = 3000;
63
+ const setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME$1) => {
64
+ if (keepAlive !== true) {
65
+ return -1;
66
+ }
67
+ const registerListener = () => {
68
+ if (request.socket) {
69
+ request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
70
+ }
71
+ else {
72
+ request.on("socket", (socket) => {
73
+ socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
74
+ });
75
+ }
76
+ };
77
+ if (deferTimeMs === 0) {
78
+ registerListener();
79
+ return 0;
80
+ }
81
+ return timing.setTimeout(registerListener, deferTimeMs);
82
+ };
123
83
 
124
- // src/set-socket-timeout.ts
125
- var DEFER_EVENT_LISTENER_TIME3 = 3e3;
126
- var setSocketTimeout = /* @__PURE__ */ __name((request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
127
- const registerTimeout = /* @__PURE__ */ __name((offset) => {
128
- const timeout = timeoutInMs - offset;
129
- const onTimeout = /* @__PURE__ */ __name(() => {
130
- request.destroy();
131
- reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
132
- }, "onTimeout");
133
- if (request.socket) {
134
- request.socket.setTimeout(timeout, onTimeout);
135
- request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
136
- } else {
137
- request.setTimeout(timeout, onTimeout);
138
- }
139
- }, "registerTimeout");
140
- if (0 < timeoutInMs && timeoutInMs < 6e3) {
141
- registerTimeout(0);
142
- return 0;
143
- }
144
- return timing.setTimeout(
145
- registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME3),
146
- DEFER_EVENT_LISTENER_TIME3
147
- );
148
- }, "setSocketTimeout");
84
+ const DEFER_EVENT_LISTENER_TIME = 3000;
85
+ const setSocketTimeout = (request, reject, timeoutInMs = DEFAULT_REQUEST_TIMEOUT) => {
86
+ const registerTimeout = (offset) => {
87
+ const timeout = timeoutInMs - offset;
88
+ const onTimeout = () => {
89
+ request.destroy();
90
+ reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
91
+ };
92
+ if (request.socket) {
93
+ request.socket.setTimeout(timeout, onTimeout);
94
+ request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
95
+ }
96
+ else {
97
+ request.setTimeout(timeout, onTimeout);
98
+ }
99
+ };
100
+ if (0 < timeoutInMs && timeoutInMs < 6000) {
101
+ registerTimeout(0);
102
+ return 0;
103
+ }
104
+ return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
105
+ };
149
106
 
150
- // src/write-request-body.ts
151
- var import_stream = require("stream");
152
- var MIN_WAIT_TIME = 6e3;
107
+ const MIN_WAIT_TIME = 6_000;
153
108
  async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME) {
154
- const headers = request.headers ?? {};
155
- const expect = headers["Expect"] || headers["expect"];
156
- let timeoutId = -1;
157
- let sendBody = true;
158
- if (expect === "100-continue") {
159
- sendBody = await Promise.race([
160
- new Promise((resolve) => {
161
- timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
162
- }),
163
- new Promise((resolve) => {
164
- httpRequest.on("continue", () => {
165
- timing.clearTimeout(timeoutId);
166
- resolve(true);
167
- });
168
- httpRequest.on("response", () => {
169
- timing.clearTimeout(timeoutId);
170
- resolve(false);
171
- });
172
- httpRequest.on("error", () => {
173
- timing.clearTimeout(timeoutId);
174
- resolve(false);
175
- });
176
- })
177
- ]);
178
- }
179
- if (sendBody) {
180
- writeBody(httpRequest, request.body);
181
- }
109
+ const headers = request.headers ?? {};
110
+ const expect = headers["Expect"] || headers["expect"];
111
+ let timeoutId = -1;
112
+ let sendBody = true;
113
+ if (expect === "100-continue") {
114
+ sendBody = await Promise.race([
115
+ new Promise((resolve) => {
116
+ timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
117
+ }),
118
+ new Promise((resolve) => {
119
+ httpRequest.on("continue", () => {
120
+ timing.clearTimeout(timeoutId);
121
+ resolve(true);
122
+ });
123
+ httpRequest.on("response", () => {
124
+ timing.clearTimeout(timeoutId);
125
+ resolve(false);
126
+ });
127
+ httpRequest.on("error", () => {
128
+ timing.clearTimeout(timeoutId);
129
+ resolve(false);
130
+ });
131
+ }),
132
+ ]);
133
+ }
134
+ if (sendBody) {
135
+ writeBody(httpRequest, request.body);
136
+ }
182
137
  }
183
- __name(writeRequestBody, "writeRequestBody");
184
138
  function writeBody(httpRequest, body) {
185
- if (body instanceof import_stream.Readable) {
186
- body.pipe(httpRequest);
187
- return;
188
- }
189
- if (body) {
190
- if (Buffer.isBuffer(body) || typeof body === "string") {
191
- httpRequest.end(body);
192
- return;
193
- }
194
- const uint8 = body;
195
- if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
196
- httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
197
- return;
198
- }
199
- httpRequest.end(Buffer.from(body));
200
- return;
201
- }
202
- httpRequest.end();
139
+ if (body instanceof stream.Readable) {
140
+ body.pipe(httpRequest);
141
+ return;
142
+ }
143
+ if (body) {
144
+ if (Buffer.isBuffer(body) || typeof body === "string") {
145
+ httpRequest.end(body);
146
+ return;
147
+ }
148
+ const uint8 = body;
149
+ if (typeof uint8 === "object" &&
150
+ uint8.buffer &&
151
+ typeof uint8.byteOffset === "number" &&
152
+ typeof uint8.byteLength === "number") {
153
+ httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
154
+ return;
155
+ }
156
+ httpRequest.end(Buffer.from(body));
157
+ return;
158
+ }
159
+ httpRequest.end();
203
160
  }
204
- __name(writeBody, "writeBody");
205
161
 
206
- // src/node-http-handler.ts
207
- var DEFAULT_REQUEST_TIMEOUT = 0;
208
- var NodeHttpHandler = class _NodeHttpHandler {
209
- constructor(options) {
210
- this.socketWarningTimestamp = 0;
211
- // Node http handler is hard-coded to http/1.1: https://github.com/nodejs/node/blob/ff5664b83b89c55e4ab5d5f60068fb457f1f5872/lib/_http_server.js#L286
212
- this.metadata = { handlerProtocol: "http/1.1" };
213
- this.configProvider = new Promise((resolve, reject) => {
214
- if (typeof options === "function") {
215
- options().then((_options) => {
216
- resolve(this.resolveDefaultConfig(_options));
217
- }).catch(reject);
218
- } else {
219
- resolve(this.resolveDefaultConfig(options));
220
- }
221
- });
222
- }
223
- static {
224
- __name(this, "NodeHttpHandler");
225
- }
226
- /**
227
- * @returns the input if it is an HttpHandler of any class,
228
- * or instantiates a new instance of this handler.
229
- */
230
- static create(instanceOrOptions) {
231
- if (typeof instanceOrOptions?.handle === "function") {
232
- return instanceOrOptions;
233
- }
234
- return new _NodeHttpHandler(instanceOrOptions);
235
- }
236
- /**
237
- * @internal
238
- *
239
- * @param agent - http(s) agent in use by the NodeHttpHandler instance.
240
- * @param socketWarningTimestamp - last socket usage check timestamp.
241
- * @param logger - channel for the warning.
242
- * @returns timestamp of last emitted warning.
243
- */
244
- static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
245
- const { sockets, requests, maxSockets } = agent;
246
- if (typeof maxSockets !== "number" || maxSockets === Infinity) {
247
- return socketWarningTimestamp;
248
- }
249
- const interval = 15e3;
250
- if (Date.now() - interval < socketWarningTimestamp) {
251
- return socketWarningTimestamp;
252
- }
253
- if (sockets && requests) {
254
- for (const origin in sockets) {
255
- const socketsInUse = sockets[origin]?.length ?? 0;
256
- const requestsEnqueued = requests[origin]?.length ?? 0;
257
- if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
258
- logger?.warn?.(
259
- `@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
260
- See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
261
- or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`
262
- );
263
- return Date.now();
162
+ const DEFAULT_REQUEST_TIMEOUT = 0;
163
+ class NodeHttpHandler {
164
+ config;
165
+ configProvider;
166
+ socketWarningTimestamp = 0;
167
+ metadata = { handlerProtocol: "http/1.1" };
168
+ static create(instanceOrOptions) {
169
+ if (typeof instanceOrOptions?.handle === "function") {
170
+ return instanceOrOptions;
264
171
  }
265
- }
266
- }
267
- return socketWarningTimestamp;
268
- }
269
- resolveDefaultConfig(options) {
270
- const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
271
- const keepAlive = true;
272
- const maxSockets = 50;
273
- return {
274
- connectionTimeout,
275
- requestTimeout: requestTimeout ?? socketTimeout,
276
- socketAcquisitionWarningTimeout,
277
- httpAgent: (() => {
278
- if (httpAgent instanceof import_http.Agent || typeof httpAgent?.destroy === "function") {
279
- return httpAgent;
172
+ return new NodeHttpHandler(instanceOrOptions);
173
+ }
174
+ static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
175
+ const { sockets, requests, maxSockets } = agent;
176
+ if (typeof maxSockets !== "number" || maxSockets === Infinity) {
177
+ return socketWarningTimestamp;
280
178
  }
281
- return new import_http.Agent({ keepAlive, maxSockets, ...httpAgent });
282
- })(),
283
- httpsAgent: (() => {
284
- if (httpsAgent instanceof import_https.Agent || typeof httpsAgent?.destroy === "function") {
285
- return httpsAgent;
179
+ const interval = 15_000;
180
+ if (Date.now() - interval < socketWarningTimestamp) {
181
+ return socketWarningTimestamp;
286
182
  }
287
- return new import_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
288
- })(),
289
- logger: console
290
- };
291
- }
292
- destroy() {
293
- this.config?.httpAgent?.destroy();
294
- this.config?.httpsAgent?.destroy();
295
- }
296
- async handle(request, { abortSignal, requestTimeout } = {}) {
297
- if (!this.config) {
298
- this.config = await this.configProvider;
299
- }
300
- return new Promise((_resolve, _reject) => {
301
- let writeRequestBodyPromise = void 0;
302
- const timeouts = [];
303
- const resolve = /* @__PURE__ */ __name(async (arg) => {
304
- await writeRequestBodyPromise;
305
- timeouts.forEach(timing.clearTimeout);
306
- _resolve(arg);
307
- }, "resolve");
308
- const reject = /* @__PURE__ */ __name(async (arg) => {
309
- await writeRequestBodyPromise;
310
- timeouts.forEach(timing.clearTimeout);
311
- _reject(arg);
312
- }, "reject");
313
- if (!this.config) {
314
- throw new Error("Node HTTP request handler config is not resolved");
315
- }
316
- if (abortSignal?.aborted) {
317
- const abortError = new Error("Request aborted");
318
- abortError.name = "AbortError";
319
- reject(abortError);
320
- return;
321
- }
322
- const isSSL = request.protocol === "https:";
323
- const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
324
- timeouts.push(
325
- timing.setTimeout(
326
- () => {
327
- this.socketWarningTimestamp = _NodeHttpHandler.checkSocketUsage(
328
- agent,
329
- this.socketWarningTimestamp,
330
- this.config.logger
331
- );
332
- },
333
- this.config.socketAcquisitionWarningTimeout ?? (this.config.requestTimeout ?? 2e3) + (this.config.connectionTimeout ?? 1e3)
334
- )
335
- );
336
- const queryString = (0, import_querystring_builder.buildQueryString)(request.query || {});
337
- let auth = void 0;
338
- if (request.username != null || request.password != null) {
339
- const username = request.username ?? "";
340
- const password = request.password ?? "";
341
- auth = `${username}:${password}`;
342
- }
343
- let path = request.path;
344
- if (queryString) {
345
- path += `?${queryString}`;
346
- }
347
- if (request.fragment) {
348
- path += `#${request.fragment}`;
349
- }
350
- let hostname = request.hostname ?? "";
351
- if (hostname[0] === "[" && hostname.endsWith("]")) {
352
- hostname = request.hostname.slice(1, -1);
353
- } else {
354
- hostname = request.hostname;
355
- }
356
- const nodeHttpsOptions = {
357
- headers: request.headers,
358
- host: hostname,
359
- method: request.method,
360
- path,
361
- port: request.port,
362
- agent,
363
- auth
364
- };
365
- const requestFunc = isSSL ? import_https.request : import_http.request;
366
- const req = requestFunc(nodeHttpsOptions, (res) => {
367
- const httpResponse = new import_protocol_http.HttpResponse({
368
- statusCode: res.statusCode || -1,
369
- reason: res.statusMessage,
370
- headers: getTransformedHeaders(res.headers),
371
- body: res
372
- });
373
- resolve({ response: httpResponse });
374
- });
375
- req.on("error", (err) => {
376
- if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
377
- reject(Object.assign(err, { name: "TimeoutError" }));
378
- } else {
379
- reject(err);
380
- }
381
- });
382
- if (abortSignal) {
383
- const onAbort = /* @__PURE__ */ __name(() => {
384
- req.destroy();
385
- const abortError = new Error("Request aborted");
386
- abortError.name = "AbortError";
387
- reject(abortError);
388
- }, "onAbort");
389
- if (typeof abortSignal.addEventListener === "function") {
390
- const signal = abortSignal;
391
- signal.addEventListener("abort", onAbort, { once: true });
392
- req.once("close", () => signal.removeEventListener("abort", onAbort));
393
- } else {
394
- abortSignal.onabort = onAbort;
183
+ if (sockets && requests) {
184
+ for (const origin in sockets) {
185
+ const socketsInUse = sockets[origin]?.length ?? 0;
186
+ const requestsEnqueued = requests[origin]?.length ?? 0;
187
+ if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
188
+ logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
189
+ See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
190
+ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
191
+ return Date.now();
192
+ }
193
+ }
395
194
  }
396
- }
397
- const effectiveRequestTimeout = requestTimeout ?? this.config.requestTimeout;
398
- timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
399
- timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
400
- const httpAgent = nodeHttpsOptions.agent;
401
- if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
402
- timeouts.push(
403
- setSocketKeepAlive(req, {
404
- // @ts-expect-error keepAlive is not public on httpAgent.
405
- keepAlive: httpAgent.keepAlive,
406
- // @ts-expect-error keepAliveMsecs is not public on httpAgent.
407
- keepAliveMsecs: httpAgent.keepAliveMsecs
408
- })
409
- );
410
- }
411
- writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout).catch((e) => {
412
- timeouts.forEach(timing.clearTimeout);
413
- return _reject(e);
414
- });
415
- });
416
- }
417
- updateHttpClientConfig(key, value) {
418
- this.config = void 0;
419
- this.configProvider = this.configProvider.then((config) => {
420
- return {
421
- ...config,
422
- [key]: value
423
- };
424
- });
425
- }
426
- httpHandlerConfigs() {
427
- return this.config ?? {};
428
- }
429
- };
430
-
431
- // src/node-http2-handler.ts
432
-
433
-
434
- var import_http22 = require("http2");
435
-
436
- // src/node-http2-connection-manager.ts
437
- var import_http2 = __toESM(require("http2"));
438
-
439
- // src/node-http2-connection-pool.ts
440
- var NodeHttp2ConnectionPool = class {
441
- constructor(sessions) {
442
- this.sessions = [];
443
- this.sessions = sessions ?? [];
444
- }
445
- static {
446
- __name(this, "NodeHttp2ConnectionPool");
447
- }
448
- poll() {
449
- if (this.sessions.length > 0) {
450
- return this.sessions.shift();
451
- }
452
- }
453
- offerLast(session) {
454
- this.sessions.push(session);
455
- }
456
- contains(session) {
457
- return this.sessions.includes(session);
458
- }
459
- remove(session) {
460
- this.sessions = this.sessions.filter((s) => s !== session);
461
- }
462
- [Symbol.iterator]() {
463
- return this.sessions[Symbol.iterator]();
464
- }
465
- destroy(connection) {
466
- for (const session of this.sessions) {
467
- if (session === connection) {
468
- if (!session.destroyed) {
469
- session.destroy();
195
+ return socketWarningTimestamp;
196
+ }
197
+ constructor(options) {
198
+ this.configProvider = new Promise((resolve, reject) => {
199
+ if (typeof options === "function") {
200
+ options()
201
+ .then((_options) => {
202
+ resolve(this.resolveDefaultConfig(_options));
203
+ })
204
+ .catch(reject);
205
+ }
206
+ else {
207
+ resolve(this.resolveDefaultConfig(options));
208
+ }
209
+ });
210
+ }
211
+ resolveDefaultConfig(options) {
212
+ const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent } = options || {};
213
+ const keepAlive = true;
214
+ const maxSockets = 50;
215
+ return {
216
+ connectionTimeout,
217
+ requestTimeout: requestTimeout ?? socketTimeout,
218
+ socketAcquisitionWarningTimeout,
219
+ httpAgent: (() => {
220
+ if (httpAgent instanceof http.Agent || typeof httpAgent?.destroy === "function") {
221
+ return httpAgent;
222
+ }
223
+ return new http.Agent({ keepAlive, maxSockets, ...httpAgent });
224
+ })(),
225
+ httpsAgent: (() => {
226
+ if (httpsAgent instanceof https.Agent || typeof httpsAgent?.destroy === "function") {
227
+ return httpsAgent;
228
+ }
229
+ return new https.Agent({ keepAlive, maxSockets, ...httpsAgent });
230
+ })(),
231
+ logger: console,
232
+ };
233
+ }
234
+ destroy() {
235
+ this.config?.httpAgent?.destroy();
236
+ this.config?.httpsAgent?.destroy();
237
+ }
238
+ async handle(request, { abortSignal, requestTimeout } = {}) {
239
+ if (!this.config) {
240
+ this.config = await this.configProvider;
470
241
  }
471
- }
242
+ return new Promise((_resolve, _reject) => {
243
+ let writeRequestBodyPromise = undefined;
244
+ const timeouts = [];
245
+ const resolve = async (arg) => {
246
+ await writeRequestBodyPromise;
247
+ timeouts.forEach(timing.clearTimeout);
248
+ _resolve(arg);
249
+ };
250
+ const reject = async (arg) => {
251
+ await writeRequestBodyPromise;
252
+ timeouts.forEach(timing.clearTimeout);
253
+ _reject(arg);
254
+ };
255
+ if (!this.config) {
256
+ throw new Error("Node HTTP request handler config is not resolved");
257
+ }
258
+ if (abortSignal?.aborted) {
259
+ const abortError = new Error("Request aborted");
260
+ abortError.name = "AbortError";
261
+ reject(abortError);
262
+ return;
263
+ }
264
+ const isSSL = request.protocol === "https:";
265
+ const agent = isSSL ? this.config.httpsAgent : this.config.httpAgent;
266
+ timeouts.push(timing.setTimeout(() => {
267
+ this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, this.config.logger);
268
+ }, this.config.socketAcquisitionWarningTimeout ??
269
+ (this.config.requestTimeout ?? 2000) + (this.config.connectionTimeout ?? 1000)));
270
+ const queryString = querystringBuilder.buildQueryString(request.query || {});
271
+ let auth = undefined;
272
+ if (request.username != null || request.password != null) {
273
+ const username = request.username ?? "";
274
+ const password = request.password ?? "";
275
+ auth = `${username}:${password}`;
276
+ }
277
+ let path = request.path;
278
+ if (queryString) {
279
+ path += `?${queryString}`;
280
+ }
281
+ if (request.fragment) {
282
+ path += `#${request.fragment}`;
283
+ }
284
+ let hostname = request.hostname ?? "";
285
+ if (hostname[0] === "[" && hostname.endsWith("]")) {
286
+ hostname = request.hostname.slice(1, -1);
287
+ }
288
+ else {
289
+ hostname = request.hostname;
290
+ }
291
+ const nodeHttpsOptions = {
292
+ headers: request.headers,
293
+ host: hostname,
294
+ method: request.method,
295
+ path,
296
+ port: request.port,
297
+ agent,
298
+ auth,
299
+ };
300
+ const requestFunc = isSSL ? https.request : http.request;
301
+ const req = requestFunc(nodeHttpsOptions, (res) => {
302
+ const httpResponse = new protocolHttp.HttpResponse({
303
+ statusCode: res.statusCode || -1,
304
+ reason: res.statusMessage,
305
+ headers: getTransformedHeaders(res.headers),
306
+ body: res,
307
+ });
308
+ resolve({ response: httpResponse });
309
+ });
310
+ req.on("error", (err) => {
311
+ if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
312
+ reject(Object.assign(err, { name: "TimeoutError" }));
313
+ }
314
+ else {
315
+ reject(err);
316
+ }
317
+ });
318
+ if (abortSignal) {
319
+ const onAbort = () => {
320
+ req.destroy();
321
+ const abortError = new Error("Request aborted");
322
+ abortError.name = "AbortError";
323
+ reject(abortError);
324
+ };
325
+ if (typeof abortSignal.addEventListener === "function") {
326
+ const signal = abortSignal;
327
+ signal.addEventListener("abort", onAbort, { once: true });
328
+ req.once("close", () => signal.removeEventListener("abort", onAbort));
329
+ }
330
+ else {
331
+ abortSignal.onabort = onAbort;
332
+ }
333
+ }
334
+ const effectiveRequestTimeout = requestTimeout ?? this.config.requestTimeout;
335
+ timeouts.push(setConnectionTimeout(req, reject, this.config.connectionTimeout));
336
+ timeouts.push(setSocketTimeout(req, reject, effectiveRequestTimeout));
337
+ const httpAgent = nodeHttpsOptions.agent;
338
+ if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
339
+ timeouts.push(setSocketKeepAlive(req, {
340
+ keepAlive: httpAgent.keepAlive,
341
+ keepAliveMsecs: httpAgent.keepAliveMsecs,
342
+ }));
343
+ }
344
+ writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout).catch((e) => {
345
+ timeouts.forEach(timing.clearTimeout);
346
+ return _reject(e);
347
+ });
348
+ });
472
349
  }
473
- }
474
- };
350
+ updateHttpClientConfig(key, value) {
351
+ this.config = undefined;
352
+ this.configProvider = this.configProvider.then((config) => {
353
+ return {
354
+ ...config,
355
+ [key]: value,
356
+ };
357
+ });
358
+ }
359
+ httpHandlerConfigs() {
360
+ return this.config ?? {};
361
+ }
362
+ }
475
363
 
476
- // src/node-http2-connection-manager.ts
477
- var NodeHttp2ConnectionManager = class {
478
- constructor(config) {
479
- this.sessionCache = /* @__PURE__ */ new Map();
480
- this.config = config;
481
- if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
482
- throw new RangeError("maxConcurrency must be greater than zero.");
483
- }
484
- }
485
- static {
486
- __name(this, "NodeHttp2ConnectionManager");
487
- }
488
- lease(requestContext, connectionConfiguration) {
489
- const url = this.getUrlString(requestContext);
490
- const existingPool = this.sessionCache.get(url);
491
- if (existingPool) {
492
- const existingSession = existingPool.poll();
493
- if (existingSession && !this.config.disableConcurrency) {
494
- return existingSession;
495
- }
496
- }
497
- const session = import_http2.default.connect(url);
498
- if (this.config.maxConcurrency) {
499
- session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
500
- if (err) {
501
- throw new Error(
502
- "Fail to set maxConcurrentStreams to " + this.config.maxConcurrency + "when creating new session for " + requestContext.destination.toString()
503
- );
364
+ class NodeHttp2ConnectionPool {
365
+ sessions = [];
366
+ constructor(sessions) {
367
+ this.sessions = sessions ?? [];
368
+ }
369
+ poll() {
370
+ if (this.sessions.length > 0) {
371
+ return this.sessions.shift();
504
372
  }
505
- });
506
- }
507
- session.unref();
508
- const destroySessionCb = /* @__PURE__ */ __name(() => {
509
- session.destroy();
510
- this.deleteSession(url, session);
511
- }, "destroySessionCb");
512
- session.on("goaway", destroySessionCb);
513
- session.on("error", destroySessionCb);
514
- session.on("frameError", destroySessionCb);
515
- session.on("close", () => this.deleteSession(url, session));
516
- if (connectionConfiguration.requestTimeout) {
517
- session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
518
- }
519
- const connectionPool = this.sessionCache.get(url) || new NodeHttp2ConnectionPool();
520
- connectionPool.offerLast(session);
521
- this.sessionCache.set(url, connectionPool);
522
- return session;
523
- }
524
- /**
525
- * Delete a session from the connection pool.
526
- * @param authority The authority of the session to delete.
527
- * @param session The session to delete.
528
- */
529
- deleteSession(authority, session) {
530
- const existingConnectionPool = this.sessionCache.get(authority);
531
- if (!existingConnectionPool) {
532
- return;
533
- }
534
- if (!existingConnectionPool.contains(session)) {
535
- return;
536
- }
537
- existingConnectionPool.remove(session);
538
- this.sessionCache.set(authority, existingConnectionPool);
539
- }
540
- release(requestContext, session) {
541
- const cacheKey = this.getUrlString(requestContext);
542
- this.sessionCache.get(cacheKey)?.offerLast(session);
543
- }
544
- destroy() {
545
- for (const [key, connectionPool] of this.sessionCache) {
546
- for (const session of connectionPool) {
547
- if (!session.destroyed) {
548
- session.destroy();
373
+ }
374
+ offerLast(session) {
375
+ this.sessions.push(session);
376
+ }
377
+ contains(session) {
378
+ return this.sessions.includes(session);
379
+ }
380
+ remove(session) {
381
+ this.sessions = this.sessions.filter((s) => s !== session);
382
+ }
383
+ [Symbol.iterator]() {
384
+ return this.sessions[Symbol.iterator]();
385
+ }
386
+ destroy(connection) {
387
+ for (const session of this.sessions) {
388
+ if (session === connection) {
389
+ if (!session.destroyed) {
390
+ session.destroy();
391
+ }
392
+ }
549
393
  }
550
- connectionPool.remove(session);
551
- }
552
- this.sessionCache.delete(key);
553
- }
554
- }
555
- setMaxConcurrentStreams(maxConcurrentStreams) {
556
- if (maxConcurrentStreams && maxConcurrentStreams <= 0) {
557
- throw new RangeError("maxConcurrentStreams must be greater than zero.");
558
- }
559
- this.config.maxConcurrency = maxConcurrentStreams;
560
- }
561
- setDisableConcurrentStreams(disableConcurrentStreams) {
562
- this.config.disableConcurrency = disableConcurrentStreams;
563
- }
564
- getUrlString(request) {
565
- return request.destination.toString();
566
- }
567
- };
394
+ }
395
+ }
568
396
 
569
- // src/node-http2-handler.ts
570
- var NodeHttp2Handler = class _NodeHttp2Handler {
571
- constructor(options) {
572
- this.metadata = { handlerProtocol: "h2" };
573
- this.connectionManager = new NodeHttp2ConnectionManager({});
574
- this.configProvider = new Promise((resolve, reject) => {
575
- if (typeof options === "function") {
576
- options().then((opts) => {
577
- resolve(opts || {});
578
- }).catch(reject);
579
- } else {
580
- resolve(options || {});
581
- }
582
- });
583
- }
584
- static {
585
- __name(this, "NodeHttp2Handler");
586
- }
587
- /**
588
- * @returns the input if it is an HttpHandler of any class,
589
- * or instantiates a new instance of this handler.
590
- */
591
- static create(instanceOrOptions) {
592
- if (typeof instanceOrOptions?.handle === "function") {
593
- return instanceOrOptions;
594
- }
595
- return new _NodeHttp2Handler(instanceOrOptions);
596
- }
597
- destroy() {
598
- this.connectionManager.destroy();
599
- }
600
- async handle(request, { abortSignal, requestTimeout } = {}) {
601
- if (!this.config) {
602
- this.config = await this.configProvider;
603
- this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams || false);
604
- if (this.config.maxConcurrentStreams) {
605
- this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams);
606
- }
607
- }
608
- const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
609
- const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
610
- return new Promise((_resolve, _reject) => {
611
- let fulfilled = false;
612
- let writeRequestBodyPromise = void 0;
613
- const resolve = /* @__PURE__ */ __name(async (arg) => {
614
- await writeRequestBodyPromise;
615
- _resolve(arg);
616
- }, "resolve");
617
- const reject = /* @__PURE__ */ __name(async (arg) => {
618
- await writeRequestBodyPromise;
619
- _reject(arg);
620
- }, "reject");
621
- if (abortSignal?.aborted) {
622
- fulfilled = true;
623
- const abortError = new Error("Request aborted");
624
- abortError.name = "AbortError";
625
- reject(abortError);
626
- return;
627
- }
628
- const { hostname, method, port, protocol, query } = request;
629
- let auth = "";
630
- if (request.username != null || request.password != null) {
631
- const username = request.username ?? "";
632
- const password = request.password ?? "";
633
- auth = `${username}:${password}@`;
634
- }
635
- const authority = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
636
- const requestContext = { destination: new URL(authority) };
637
- const session = this.connectionManager.lease(requestContext, {
638
- requestTimeout: this.config?.sessionTimeout,
639
- disableConcurrentStreams: disableConcurrentStreams || false
640
- });
641
- const rejectWithDestroy = /* @__PURE__ */ __name((err) => {
642
- if (disableConcurrentStreams) {
643
- this.destroySession(session);
397
+ class NodeHttp2ConnectionManager {
398
+ constructor(config) {
399
+ this.config = config;
400
+ if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
401
+ throw new RangeError("maxConcurrency must be greater than zero.");
644
402
  }
645
- fulfilled = true;
646
- reject(err);
647
- }, "rejectWithDestroy");
648
- const queryString = (0, import_querystring_builder.buildQueryString)(query || {});
649
- let path = request.path;
650
- if (queryString) {
651
- path += `?${queryString}`;
652
- }
653
- if (request.fragment) {
654
- path += `#${request.fragment}`;
655
- }
656
- const req = session.request({
657
- ...request.headers,
658
- [import_http22.constants.HTTP2_HEADER_PATH]: path,
659
- [import_http22.constants.HTTP2_HEADER_METHOD]: method
660
- });
661
- session.ref();
662
- req.on("response", (headers) => {
663
- const httpResponse = new import_protocol_http.HttpResponse({
664
- statusCode: headers[":status"] || -1,
665
- headers: getTransformedHeaders(headers),
666
- body: req
667
- });
668
- fulfilled = true;
669
- resolve({ response: httpResponse });
670
- if (disableConcurrentStreams) {
671
- session.close();
672
- this.connectionManager.deleteSession(authority, session);
403
+ }
404
+ config;
405
+ sessionCache = new Map();
406
+ lease(requestContext, connectionConfiguration) {
407
+ const url = this.getUrlString(requestContext);
408
+ const existingPool = this.sessionCache.get(url);
409
+ if (existingPool) {
410
+ const existingSession = existingPool.poll();
411
+ if (existingSession && !this.config.disableConcurrency) {
412
+ return existingSession;
413
+ }
673
414
  }
674
- });
675
- if (effectiveRequestTimeout) {
676
- req.setTimeout(effectiveRequestTimeout, () => {
677
- req.close();
678
- const timeoutError = new Error(`Stream timed out because of no activity for ${effectiveRequestTimeout} ms`);
679
- timeoutError.name = "TimeoutError";
680
- rejectWithDestroy(timeoutError);
681
- });
682
- }
683
- if (abortSignal) {
684
- const onAbort = /* @__PURE__ */ __name(() => {
685
- req.close();
686
- const abortError = new Error("Request aborted");
687
- abortError.name = "AbortError";
688
- rejectWithDestroy(abortError);
689
- }, "onAbort");
690
- if (typeof abortSignal.addEventListener === "function") {
691
- const signal = abortSignal;
692
- signal.addEventListener("abort", onAbort, { once: true });
693
- req.once("close", () => signal.removeEventListener("abort", onAbort));
694
- } else {
695
- abortSignal.onabort = onAbort;
415
+ const session = http2.connect(url);
416
+ if (this.config.maxConcurrency) {
417
+ session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
418
+ if (err) {
419
+ throw new Error("Fail to set maxConcurrentStreams to " +
420
+ this.config.maxConcurrency +
421
+ "when creating new session for " +
422
+ requestContext.destination.toString());
423
+ }
424
+ });
696
425
  }
697
- }
698
- req.on("frameError", (type, code, id) => {
699
- rejectWithDestroy(new Error(`Frame type id ${type} in stream id ${id} has failed with code ${code}.`));
700
- });
701
- req.on("error", rejectWithDestroy);
702
- req.on("aborted", () => {
703
- rejectWithDestroy(
704
- new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${req.rstCode}.`)
705
- );
706
- });
707
- req.on("close", () => {
708
426
  session.unref();
709
- if (disableConcurrentStreams) {
710
- session.destroy();
427
+ const destroySessionCb = () => {
428
+ session.destroy();
429
+ this.deleteSession(url, session);
430
+ };
431
+ session.on("goaway", destroySessionCb);
432
+ session.on("error", destroySessionCb);
433
+ session.on("frameError", destroySessionCb);
434
+ session.on("close", () => this.deleteSession(url, session));
435
+ if (connectionConfiguration.requestTimeout) {
436
+ session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
437
+ }
438
+ const connectionPool = this.sessionCache.get(url) || new NodeHttp2ConnectionPool();
439
+ connectionPool.offerLast(session);
440
+ this.sessionCache.set(url, connectionPool);
441
+ return session;
442
+ }
443
+ deleteSession(authority, session) {
444
+ const existingConnectionPool = this.sessionCache.get(authority);
445
+ if (!existingConnectionPool) {
446
+ return;
711
447
  }
712
- if (!fulfilled) {
713
- rejectWithDestroy(new Error("Unexpected error: http2 request did not get a response"));
448
+ if (!existingConnectionPool.contains(session)) {
449
+ return;
714
450
  }
715
- });
716
- writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout);
717
- });
718
- }
719
- updateHttpClientConfig(key, value) {
720
- this.config = void 0;
721
- this.configProvider = this.configProvider.then((config) => {
722
- return {
723
- ...config,
724
- [key]: value
725
- };
726
- });
727
- }
728
- httpHandlerConfigs() {
729
- return this.config ?? {};
730
- }
731
- /**
732
- * Destroys a session.
733
- * @param session - the session to destroy.
734
- */
735
- destroySession(session) {
736
- if (!session.destroyed) {
737
- session.destroy();
738
- }
739
- }
740
- };
451
+ existingConnectionPool.remove(session);
452
+ this.sessionCache.set(authority, existingConnectionPool);
453
+ }
454
+ release(requestContext, session) {
455
+ const cacheKey = this.getUrlString(requestContext);
456
+ this.sessionCache.get(cacheKey)?.offerLast(session);
457
+ }
458
+ destroy() {
459
+ for (const [key, connectionPool] of this.sessionCache) {
460
+ for (const session of connectionPool) {
461
+ if (!session.destroyed) {
462
+ session.destroy();
463
+ }
464
+ connectionPool.remove(session);
465
+ }
466
+ this.sessionCache.delete(key);
467
+ }
468
+ }
469
+ setMaxConcurrentStreams(maxConcurrentStreams) {
470
+ if (maxConcurrentStreams && maxConcurrentStreams <= 0) {
471
+ throw new RangeError("maxConcurrentStreams must be greater than zero.");
472
+ }
473
+ this.config.maxConcurrency = maxConcurrentStreams;
474
+ }
475
+ setDisableConcurrentStreams(disableConcurrentStreams) {
476
+ this.config.disableConcurrency = disableConcurrentStreams;
477
+ }
478
+ getUrlString(request) {
479
+ return request.destination.toString();
480
+ }
481
+ }
741
482
 
742
- // src/stream-collector/collector.ts
483
+ class NodeHttp2Handler {
484
+ config;
485
+ configProvider;
486
+ metadata = { handlerProtocol: "h2" };
487
+ connectionManager = new NodeHttp2ConnectionManager({});
488
+ static create(instanceOrOptions) {
489
+ if (typeof instanceOrOptions?.handle === "function") {
490
+ return instanceOrOptions;
491
+ }
492
+ return new NodeHttp2Handler(instanceOrOptions);
493
+ }
494
+ constructor(options) {
495
+ this.configProvider = new Promise((resolve, reject) => {
496
+ if (typeof options === "function") {
497
+ options()
498
+ .then((opts) => {
499
+ resolve(opts || {});
500
+ })
501
+ .catch(reject);
502
+ }
503
+ else {
504
+ resolve(options || {});
505
+ }
506
+ });
507
+ }
508
+ destroy() {
509
+ this.connectionManager.destroy();
510
+ }
511
+ async handle(request, { abortSignal, requestTimeout } = {}) {
512
+ if (!this.config) {
513
+ this.config = await this.configProvider;
514
+ this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams || false);
515
+ if (this.config.maxConcurrentStreams) {
516
+ this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams);
517
+ }
518
+ }
519
+ const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
520
+ const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
521
+ return new Promise((_resolve, _reject) => {
522
+ let fulfilled = false;
523
+ let writeRequestBodyPromise = undefined;
524
+ const resolve = async (arg) => {
525
+ await writeRequestBodyPromise;
526
+ _resolve(arg);
527
+ };
528
+ const reject = async (arg) => {
529
+ await writeRequestBodyPromise;
530
+ _reject(arg);
531
+ };
532
+ if (abortSignal?.aborted) {
533
+ fulfilled = true;
534
+ const abortError = new Error("Request aborted");
535
+ abortError.name = "AbortError";
536
+ reject(abortError);
537
+ return;
538
+ }
539
+ const { hostname, method, port, protocol, query } = request;
540
+ let auth = "";
541
+ if (request.username != null || request.password != null) {
542
+ const username = request.username ?? "";
543
+ const password = request.password ?? "";
544
+ auth = `${username}:${password}@`;
545
+ }
546
+ const authority = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
547
+ const requestContext = { destination: new URL(authority) };
548
+ const session = this.connectionManager.lease(requestContext, {
549
+ requestTimeout: this.config?.sessionTimeout,
550
+ disableConcurrentStreams: disableConcurrentStreams || false,
551
+ });
552
+ const rejectWithDestroy = (err) => {
553
+ if (disableConcurrentStreams) {
554
+ this.destroySession(session);
555
+ }
556
+ fulfilled = true;
557
+ reject(err);
558
+ };
559
+ const queryString = querystringBuilder.buildQueryString(query || {});
560
+ let path = request.path;
561
+ if (queryString) {
562
+ path += `?${queryString}`;
563
+ }
564
+ if (request.fragment) {
565
+ path += `#${request.fragment}`;
566
+ }
567
+ const req = session.request({
568
+ ...request.headers,
569
+ [http2.constants.HTTP2_HEADER_PATH]: path,
570
+ [http2.constants.HTTP2_HEADER_METHOD]: method,
571
+ });
572
+ session.ref();
573
+ req.on("response", (headers) => {
574
+ const httpResponse = new protocolHttp.HttpResponse({
575
+ statusCode: headers[":status"] || -1,
576
+ headers: getTransformedHeaders(headers),
577
+ body: req,
578
+ });
579
+ fulfilled = true;
580
+ resolve({ response: httpResponse });
581
+ if (disableConcurrentStreams) {
582
+ session.close();
583
+ this.connectionManager.deleteSession(authority, session);
584
+ }
585
+ });
586
+ if (effectiveRequestTimeout) {
587
+ req.setTimeout(effectiveRequestTimeout, () => {
588
+ req.close();
589
+ const timeoutError = new Error(`Stream timed out because of no activity for ${effectiveRequestTimeout} ms`);
590
+ timeoutError.name = "TimeoutError";
591
+ rejectWithDestroy(timeoutError);
592
+ });
593
+ }
594
+ if (abortSignal) {
595
+ const onAbort = () => {
596
+ req.close();
597
+ const abortError = new Error("Request aborted");
598
+ abortError.name = "AbortError";
599
+ rejectWithDestroy(abortError);
600
+ };
601
+ if (typeof abortSignal.addEventListener === "function") {
602
+ const signal = abortSignal;
603
+ signal.addEventListener("abort", onAbort, { once: true });
604
+ req.once("close", () => signal.removeEventListener("abort", onAbort));
605
+ }
606
+ else {
607
+ abortSignal.onabort = onAbort;
608
+ }
609
+ }
610
+ req.on("frameError", (type, code, id) => {
611
+ rejectWithDestroy(new Error(`Frame type id ${type} in stream id ${id} has failed with code ${code}.`));
612
+ });
613
+ req.on("error", rejectWithDestroy);
614
+ req.on("aborted", () => {
615
+ rejectWithDestroy(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${req.rstCode}.`));
616
+ });
617
+ req.on("close", () => {
618
+ session.unref();
619
+ if (disableConcurrentStreams) {
620
+ session.destroy();
621
+ }
622
+ if (!fulfilled) {
623
+ rejectWithDestroy(new Error("Unexpected error: http2 request did not get a response"));
624
+ }
625
+ });
626
+ writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout);
627
+ });
628
+ }
629
+ updateHttpClientConfig(key, value) {
630
+ this.config = undefined;
631
+ this.configProvider = this.configProvider.then((config) => {
632
+ return {
633
+ ...config,
634
+ [key]: value,
635
+ };
636
+ });
637
+ }
638
+ httpHandlerConfigs() {
639
+ return this.config ?? {};
640
+ }
641
+ destroySession(session) {
642
+ if (!session.destroyed) {
643
+ session.destroy();
644
+ }
645
+ }
646
+ }
743
647
 
744
- var Collector = class extends import_stream.Writable {
745
- constructor() {
746
- super(...arguments);
747
- this.bufferedBytes = [];
748
- }
749
- static {
750
- __name(this, "Collector");
751
- }
752
- _write(chunk, encoding, callback) {
753
- this.bufferedBytes.push(chunk);
754
- callback();
755
- }
756
- };
648
+ class Collector extends stream.Writable {
649
+ bufferedBytes = [];
650
+ _write(chunk, encoding, callback) {
651
+ this.bufferedBytes.push(chunk);
652
+ callback();
653
+ }
654
+ }
757
655
 
758
- // src/stream-collector/index.ts
759
- var streamCollector = /* @__PURE__ */ __name((stream) => {
760
- if (isReadableStreamInstance(stream)) {
761
- return collectReadableStream(stream);
762
- }
763
- return new Promise((resolve, reject) => {
764
- const collector = new Collector();
765
- stream.pipe(collector);
766
- stream.on("error", (err) => {
767
- collector.end();
768
- reject(err);
769
- });
770
- collector.on("error", reject);
771
- collector.on("finish", function() {
772
- const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
773
- resolve(bytes);
656
+ const streamCollector = (stream) => {
657
+ if (isReadableStreamInstance(stream)) {
658
+ return collectReadableStream(stream);
659
+ }
660
+ return new Promise((resolve, reject) => {
661
+ const collector = new Collector();
662
+ stream.pipe(collector);
663
+ stream.on("error", (err) => {
664
+ collector.end();
665
+ reject(err);
666
+ });
667
+ collector.on("error", reject);
668
+ collector.on("finish", function () {
669
+ const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
670
+ resolve(bytes);
671
+ });
774
672
  });
775
- });
776
- }, "streamCollector");
777
- var isReadableStreamInstance = /* @__PURE__ */ __name((stream) => typeof ReadableStream === "function" && stream instanceof ReadableStream, "isReadableStreamInstance");
673
+ };
674
+ const isReadableStreamInstance = (stream) => typeof ReadableStream === "function" && stream instanceof ReadableStream;
778
675
  async function collectReadableStream(stream) {
779
- const chunks = [];
780
- const reader = stream.getReader();
781
- let isDone = false;
782
- let length = 0;
783
- while (!isDone) {
784
- const { done, value } = await reader.read();
785
- if (value) {
786
- chunks.push(value);
787
- length += value.length;
788
- }
789
- isDone = done;
790
- }
791
- const collected = new Uint8Array(length);
792
- let offset = 0;
793
- for (const chunk of chunks) {
794
- collected.set(chunk, offset);
795
- offset += chunk.length;
796
- }
797
- return collected;
676
+ const chunks = [];
677
+ const reader = stream.getReader();
678
+ let isDone = false;
679
+ let length = 0;
680
+ while (!isDone) {
681
+ const { done, value } = await reader.read();
682
+ if (value) {
683
+ chunks.push(value);
684
+ length += value.length;
685
+ }
686
+ isDone = done;
687
+ }
688
+ const collected = new Uint8Array(length);
689
+ let offset = 0;
690
+ for (const chunk of chunks) {
691
+ collected.set(chunk, offset);
692
+ offset += chunk.length;
693
+ }
694
+ return collected;
798
695
  }
799
- __name(collectReadableStream, "collectReadableStream");
800
- // Annotate the CommonJS export names for ESM import in node:
801
-
802
- 0 && (module.exports = {
803
- DEFAULT_REQUEST_TIMEOUT,
804
- NodeHttpHandler,
805
- NodeHttp2Handler,
806
- streamCollector
807
- });
808
696
 
697
+ exports.DEFAULT_REQUEST_TIMEOUT = DEFAULT_REQUEST_TIMEOUT;
698
+ exports.NodeHttp2Handler = NodeHttp2Handler;
699
+ exports.NodeHttpHandler = NodeHttpHandler;
700
+ exports.streamCollector = streamCollector;