@pnpm/exe 11.0.5 → 11.0.7
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.
- package/dist/node-gyp-bin/node-gyp +0 -0
- package/dist/node-gyp-bin/node-gyp.cmd +0 -0
- package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
- package/dist/node_modules/node-gyp/bin/node-gyp.js +0 -0
- package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +11 -3
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +2 -3
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +26 -16
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +2 -2
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +3 -20
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/tags.py +2 -14
- package/dist/node_modules/node-gyp/gyp/pyproject.toml +5 -3
- package/dist/node_modules/node-gyp/lib/download.js +55 -8
- package/dist/node_modules/node-gyp/lib/find-visualstudio.js +1 -1
- package/dist/node_modules/node-gyp/lib/process-release.js +17 -19
- package/dist/node_modules/node-gyp/package.json +3 -3
- package/dist/node_modules/{safer-buffer → undici}/LICENSE +1 -1
- package/dist/node_modules/undici/index-fetch.js +35 -0
- package/dist/node_modules/undici/index.js +169 -0
- package/dist/node_modules/undici/lib/api/abort-signal.js +57 -0
- package/dist/node_modules/undici/lib/api/api-connect.js +108 -0
- package/dist/node_modules/undici/lib/api/api-pipeline.js +251 -0
- package/dist/node_modules/undici/lib/api/api-request.js +214 -0
- package/dist/node_modules/undici/lib/api/api-stream.js +220 -0
- package/dist/node_modules/undici/lib/api/api-upgrade.js +108 -0
- package/dist/node_modules/undici/lib/api/index.js +7 -0
- package/dist/node_modules/undici/lib/api/readable.js +385 -0
- package/dist/node_modules/undici/lib/api/util.js +93 -0
- package/dist/node_modules/undici/lib/core/connect.js +240 -0
- package/dist/node_modules/undici/lib/core/constants.js +118 -0
- package/dist/node_modules/undici/lib/core/diagnostics.js +202 -0
- package/dist/node_modules/undici/lib/core/errors.js +425 -0
- package/dist/node_modules/undici/lib/core/request.js +405 -0
- package/dist/node_modules/undici/lib/core/symbols.js +67 -0
- package/dist/node_modules/undici/lib/core/tree.js +152 -0
- package/dist/node_modules/undici/lib/core/util.js +719 -0
- package/dist/node_modules/undici/lib/dispatcher/agent.js +130 -0
- package/dist/node_modules/undici/lib/dispatcher/balanced-pool.js +209 -0
- package/dist/node_modules/undici/lib/dispatcher/client-h1.js +1370 -0
- package/dist/node_modules/undici/lib/dispatcher/client-h2.js +744 -0
- package/dist/node_modules/undici/lib/dispatcher/client.js +623 -0
- package/dist/node_modules/undici/lib/dispatcher/dispatcher-base.js +198 -0
- package/dist/node_modules/undici/lib/dispatcher/dispatcher.js +65 -0
- package/dist/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +160 -0
- package/dist/node_modules/undici/lib/dispatcher/fixed-queue.js +117 -0
- package/dist/node_modules/undici/lib/dispatcher/pool-base.js +194 -0
- package/dist/node_modules/undici/lib/dispatcher/pool-stats.js +34 -0
- package/dist/node_modules/undici/lib/dispatcher/pool.js +107 -0
- package/dist/node_modules/undici/lib/dispatcher/proxy-agent.js +274 -0
- package/dist/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
- package/dist/node_modules/undici/lib/global.js +32 -0
- package/dist/node_modules/undici/lib/handler/decorator-handler.js +44 -0
- package/dist/node_modules/undici/lib/handler/redirect-handler.js +232 -0
- package/dist/node_modules/undici/lib/handler/retry-handler.js +374 -0
- package/dist/node_modules/undici/lib/interceptor/dns.js +375 -0
- package/dist/node_modules/undici/lib/interceptor/dump.js +123 -0
- package/dist/node_modules/undici/lib/interceptor/redirect-interceptor.js +21 -0
- package/dist/node_modules/undici/lib/interceptor/redirect.js +24 -0
- package/dist/node_modules/undici/lib/interceptor/response-error.js +86 -0
- package/dist/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/dist/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/dist/node_modules/undici/lib/llhttp/constants.js +278 -0
- package/dist/node_modules/undici/lib/llhttp/llhttp-wasm.js +5 -0
- package/dist/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +5 -0
- package/dist/node_modules/undici/lib/llhttp/utils.js +15 -0
- package/dist/node_modules/undici/lib/mock/mock-agent.js +160 -0
- package/dist/node_modules/undici/lib/mock/mock-client.js +59 -0
- package/dist/node_modules/undici/lib/mock/mock-errors.js +28 -0
- package/dist/node_modules/undici/lib/mock/mock-interceptor.js +207 -0
- package/dist/node_modules/undici/lib/mock/mock-pool.js +59 -0
- package/dist/node_modules/undici/lib/mock/mock-symbols.js +23 -0
- package/dist/node_modules/undici/lib/mock/mock-utils.js +367 -0
- package/dist/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/dist/node_modules/undici/lib/mock/pluralizer.js +29 -0
- package/dist/node_modules/undici/lib/util/timers.js +423 -0
- package/dist/node_modules/undici/lib/web/cache/cache.js +859 -0
- package/dist/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
- package/dist/node_modules/undici/lib/web/cache/symbols.js +5 -0
- package/dist/node_modules/undici/lib/web/cache/util.js +45 -0
- package/dist/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/dist/node_modules/undici/lib/web/cookies/index.js +184 -0
- package/dist/node_modules/undici/lib/web/cookies/parse.js +317 -0
- package/dist/node_modules/undici/lib/web/cookies/util.js +282 -0
- package/dist/node_modules/undici/lib/web/eventsource/eventsource-stream.js +398 -0
- package/dist/node_modules/undici/lib/web/eventsource/eventsource.js +480 -0
- package/dist/node_modules/undici/lib/web/eventsource/util.js +37 -0
- package/dist/node_modules/{@npmcli/redact → undici/lib/web/fetch}/LICENSE +1 -1
- package/dist/node_modules/undici/lib/web/fetch/body.js +529 -0
- package/dist/node_modules/undici/lib/web/fetch/constants.js +124 -0
- package/dist/node_modules/undici/lib/web/fetch/data-url.js +744 -0
- package/dist/node_modules/undici/lib/web/fetch/dispatcher-weakref.js +46 -0
- package/dist/node_modules/undici/lib/web/fetch/file.js +126 -0
- package/dist/node_modules/undici/lib/web/fetch/formdata-parser.js +474 -0
- package/dist/node_modules/undici/lib/web/fetch/formdata.js +252 -0
- package/dist/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/dist/node_modules/undici/lib/web/fetch/headers.js +687 -0
- package/dist/node_modules/undici/lib/web/fetch/index.js +2272 -0
- package/dist/node_modules/undici/lib/web/fetch/request.js +1037 -0
- package/dist/node_modules/undici/lib/web/fetch/response.js +610 -0
- package/dist/node_modules/undici/lib/web/fetch/symbols.js +9 -0
- package/dist/node_modules/undici/lib/web/fetch/util.js +1632 -0
- package/dist/node_modules/undici/lib/web/fetch/webidl.js +695 -0
- package/dist/node_modules/undici/lib/web/fileapi/encoding.js +290 -0
- package/dist/node_modules/undici/lib/web/fileapi/filereader.js +344 -0
- package/dist/node_modules/undici/lib/web/fileapi/progressevent.js +78 -0
- package/dist/node_modules/undici/lib/web/fileapi/symbols.js +10 -0
- package/dist/node_modules/undici/lib/web/fileapi/util.js +391 -0
- package/dist/node_modules/undici/lib/web/websocket/connection.js +371 -0
- package/dist/node_modules/undici/lib/web/websocket/constants.js +66 -0
- package/dist/node_modules/undici/lib/web/websocket/events.js +329 -0
- package/dist/node_modules/undici/lib/web/websocket/frame.js +96 -0
- package/dist/node_modules/undici/lib/web/websocket/permessage-deflate.js +100 -0
- package/dist/node_modules/undici/lib/web/websocket/receiver.js +490 -0
- package/dist/node_modules/undici/lib/web/websocket/sender.js +104 -0
- package/dist/node_modules/undici/lib/web/websocket/symbols.js +12 -0
- package/dist/node_modules/undici/lib/web/websocket/util.js +322 -0
- package/dist/node_modules/undici/lib/web/websocket/websocket.js +592 -0
- package/dist/node_modules/undici/package.json +160 -0
- package/dist/node_modules/undici/scripts/strip-comments.js +8 -0
- package/dist/node_modules/yallist/package.json +51 -12
- package/dist/pnpm.mjs +5915 -5140
- package/dist/worker.js +70 -67
- package/package.json +21 -13
- package/setup.js +17 -3
- package/dist/node_modules/@gar/promise-retry/LICENSE +0 -20
- package/dist/node_modules/@gar/promise-retry/lib/index.js +0 -62
- package/dist/node_modules/@gar/promise-retry/lib/retry.js +0 -109
- package/dist/node_modules/@gar/promise-retry/package.json +0 -45
- package/dist/node_modules/@npmcli/agent/lib/agents.js +0 -206
- package/dist/node_modules/@npmcli/agent/lib/dns.js +0 -53
- package/dist/node_modules/@npmcli/agent/lib/errors.js +0 -61
- package/dist/node_modules/@npmcli/agent/lib/index.js +0 -56
- package/dist/node_modules/@npmcli/agent/lib/options.js +0 -86
- package/dist/node_modules/@npmcli/agent/lib/proxy.js +0 -88
- package/dist/node_modules/@npmcli/agent/package.json +0 -60
- package/dist/node_modules/@npmcli/fs/lib/common/get-options.js +0 -20
- package/dist/node_modules/@npmcli/fs/lib/common/node.js +0 -9
- package/dist/node_modules/@npmcli/fs/lib/cp/LICENSE +0 -15
- package/dist/node_modules/@npmcli/fs/lib/cp/errors.js +0 -129
- package/dist/node_modules/@npmcli/fs/lib/cp/index.js +0 -22
- package/dist/node_modules/@npmcli/fs/lib/cp/polyfill.js +0 -428
- package/dist/node_modules/@npmcli/fs/lib/index.js +0 -13
- package/dist/node_modules/@npmcli/fs/lib/move-file.js +0 -78
- package/dist/node_modules/@npmcli/fs/lib/readdir-scoped.js +0 -20
- package/dist/node_modules/@npmcli/fs/lib/with-temp-dir.js +0 -39
- package/dist/node_modules/@npmcli/fs/package.json +0 -54
- package/dist/node_modules/@npmcli/redact/lib/deep-map.js +0 -71
- package/dist/node_modules/@npmcli/redact/lib/error.js +0 -28
- package/dist/node_modules/@npmcli/redact/lib/index.js +0 -44
- package/dist/node_modules/@npmcli/redact/lib/matchers.js +0 -88
- package/dist/node_modules/@npmcli/redact/lib/server.js +0 -59
- package/dist/node_modules/@npmcli/redact/lib/utils.js +0 -202
- package/dist/node_modules/@npmcli/redact/package.json +0 -52
- package/dist/node_modules/agent-base/LICENSE +0 -22
- package/dist/node_modules/agent-base/dist/helpers.js +0 -66
- package/dist/node_modules/agent-base/dist/index.js +0 -178
- package/dist/node_modules/agent-base/package.json +0 -46
- package/dist/node_modules/balanced-match/dist/commonjs/index.js +0 -59
- package/dist/node_modules/balanced-match/dist/esm/index.js +0 -54
- package/dist/node_modules/balanced-match/package.json +0 -68
- package/dist/node_modules/brace-expansion/LICENSE +0 -23
- package/dist/node_modules/brace-expansion/dist/commonjs/index.js +0 -201
- package/dist/node_modules/brace-expansion/dist/commonjs/package.json +0 -3
- package/dist/node_modules/brace-expansion/dist/esm/index.js +0 -197
- package/dist/node_modules/brace-expansion/dist/esm/package.json +0 -3
- package/dist/node_modules/brace-expansion/package.json +0 -64
- package/dist/node_modules/cacache/lib/content/path.js +0 -29
- package/dist/node_modules/cacache/lib/content/read.js +0 -165
- package/dist/node_modules/cacache/lib/content/rm.js +0 -18
- package/dist/node_modules/cacache/lib/content/write.js +0 -206
- package/dist/node_modules/cacache/lib/entry-index.js +0 -336
- package/dist/node_modules/cacache/lib/get.js +0 -170
- package/dist/node_modules/cacache/lib/index.js +0 -42
- package/dist/node_modules/cacache/lib/memoization.js +0 -72
- package/dist/node_modules/cacache/lib/put.js +0 -80
- package/dist/node_modules/cacache/lib/rm.js +0 -31
- package/dist/node_modules/cacache/lib/util/glob.js +0 -7
- package/dist/node_modules/cacache/lib/util/hash-to-segments.js +0 -7
- package/dist/node_modules/cacache/lib/util/tmp.js +0 -32
- package/dist/node_modules/cacache/lib/verify.js +0 -258
- package/dist/node_modules/cacache/package.json +0 -81
- package/dist/node_modules/debug/LICENSE +0 -20
- package/dist/node_modules/debug/package.json +0 -64
- package/dist/node_modules/debug/src/browser.js +0 -272
- package/dist/node_modules/debug/src/common.js +0 -292
- package/dist/node_modules/debug/src/index.js +0 -10
- package/dist/node_modules/debug/src/node.js +0 -263
- package/dist/node_modules/fs-minipass/LICENSE +0 -15
- package/dist/node_modules/fs-minipass/lib/index.js +0 -443
- package/dist/node_modules/fs-minipass/package.json +0 -54
- package/dist/node_modules/glob/dist/commonjs/glob.js +0 -248
- package/dist/node_modules/glob/dist/commonjs/has-magic.js +0 -27
- package/dist/node_modules/glob/dist/commonjs/ignore.js +0 -119
- package/dist/node_modules/glob/dist/commonjs/index.js +0 -68
- package/dist/node_modules/glob/dist/commonjs/index.min.js +0 -4
- package/dist/node_modules/glob/dist/commonjs/package.json +0 -3
- package/dist/node_modules/glob/dist/commonjs/pattern.js +0 -223
- package/dist/node_modules/glob/dist/commonjs/processor.js +0 -301
- package/dist/node_modules/glob/dist/commonjs/walker.js +0 -387
- package/dist/node_modules/glob/dist/esm/glob.js +0 -244
- package/dist/node_modules/glob/dist/esm/has-magic.js +0 -23
- package/dist/node_modules/glob/dist/esm/ignore.js +0 -115
- package/dist/node_modules/glob/dist/esm/index.js +0 -55
- package/dist/node_modules/glob/dist/esm/index.min.js +0 -4
- package/dist/node_modules/glob/dist/esm/package.json +0 -3
- package/dist/node_modules/glob/dist/esm/pattern.js +0 -219
- package/dist/node_modules/glob/dist/esm/processor.js +0 -294
- package/dist/node_modules/glob/dist/esm/walker.js +0 -381
- package/dist/node_modules/glob/package.json +0 -98
- package/dist/node_modules/http-cache-semantics/LICENSE +0 -9
- package/dist/node_modules/http-cache-semantics/index.js +0 -928
- package/dist/node_modules/http-cache-semantics/package.json +0 -22
- package/dist/node_modules/http-proxy-agent/LICENSE +0 -22
- package/dist/node_modules/http-proxy-agent/dist/index.js +0 -148
- package/dist/node_modules/http-proxy-agent/package.json +0 -47
- package/dist/node_modules/https-proxy-agent/LICENSE +0 -22
- package/dist/node_modules/https-proxy-agent/dist/index.js +0 -180
- package/dist/node_modules/https-proxy-agent/dist/parse-proxy-response.js +0 -101
- package/dist/node_modules/https-proxy-agent/package.json +0 -50
- package/dist/node_modules/iconv-lite/LICENSE +0 -21
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -532
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +0 -185
- package/dist/node_modules/iconv-lite/encodings/index.js +0 -23
- package/dist/node_modules/iconv-lite/encodings/internal.js +0 -218
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -75
- package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +0 -178
- package/dist/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
- package/dist/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
- package/dist/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
- package/dist/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
- package/dist/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
- package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
- package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
- package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
- package/dist/node_modules/iconv-lite/encodings/utf16.js +0 -187
- package/dist/node_modules/iconv-lite/encodings/utf32.js +0 -307
- package/dist/node_modules/iconv-lite/encodings/utf7.js +0 -283
- package/dist/node_modules/iconv-lite/lib/bom-handling.js +0 -48
- package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +0 -13
- package/dist/node_modules/iconv-lite/lib/index.js +0 -182
- package/dist/node_modules/iconv-lite/lib/streams.js +0 -105
- package/dist/node_modules/iconv-lite/package.json +0 -70
- package/dist/node_modules/ip-address/LICENSE +0 -19
- package/dist/node_modules/ip-address/dist/address-error.js +0 -12
- package/dist/node_modules/ip-address/dist/common.js +0 -46
- package/dist/node_modules/ip-address/dist/ip-address.js +0 -35
- package/dist/node_modules/ip-address/dist/ipv4.js +0 -360
- package/dist/node_modules/ip-address/dist/ipv6.js +0 -1003
- package/dist/node_modules/ip-address/dist/v4/constants.js +0 -8
- package/dist/node_modules/ip-address/dist/v6/constants.js +0 -76
- package/dist/node_modules/ip-address/dist/v6/helpers.js +0 -45
- package/dist/node_modules/ip-address/dist/v6/regular-expressions.js +0 -95
- package/dist/node_modules/ip-address/package.json +0 -78
- package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +0 -10
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +0 -1692
- package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/commonjs/package.json +0 -3
- package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +0 -4
- package/dist/node_modules/lru-cache/dist/esm/browser/index.js +0 -1688
- package/dist/node_modules/lru-cache/dist/esm/browser/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.js +0 -19
- package/dist/node_modules/lru-cache/dist/esm/index.js +0 -1688
- package/dist/node_modules/lru-cache/dist/esm/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +0 -7
- package/dist/node_modules/lru-cache/dist/esm/node/index.js +0 -1688
- package/dist/node_modules/lru-cache/dist/esm/node/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/esm/package.json +0 -3
- package/dist/node_modules/lru-cache/package.json +0 -126
- package/dist/node_modules/make-fetch-happen/LICENSE +0 -16
- package/dist/node_modules/make-fetch-happen/lib/cache/entry.js +0 -471
- package/dist/node_modules/make-fetch-happen/lib/cache/errors.js +0 -11
- package/dist/node_modules/make-fetch-happen/lib/cache/index.js +0 -49
- package/dist/node_modules/make-fetch-happen/lib/cache/key.js +0 -17
- package/dist/node_modules/make-fetch-happen/lib/cache/policy.js +0 -161
- package/dist/node_modules/make-fetch-happen/lib/fetch.js +0 -118
- package/dist/node_modules/make-fetch-happen/lib/index.js +0 -41
- package/dist/node_modules/make-fetch-happen/lib/options.js +0 -59
- package/dist/node_modules/make-fetch-happen/lib/pipeline.js +0 -41
- package/dist/node_modules/make-fetch-happen/lib/remote.js +0 -134
- package/dist/node_modules/make-fetch-happen/package.json +0 -75
- package/dist/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +0 -14
- package/dist/node_modules/minimatch/dist/commonjs/ast.js +0 -845
- package/dist/node_modules/minimatch/dist/commonjs/brace-expressions.js +0 -150
- package/dist/node_modules/minimatch/dist/commonjs/escape.js +0 -30
- package/dist/node_modules/minimatch/dist/commonjs/index.js +0 -1127
- package/dist/node_modules/minimatch/dist/commonjs/package.json +0 -3
- package/dist/node_modules/minimatch/dist/commonjs/unescape.js +0 -38
- package/dist/node_modules/minimatch/dist/esm/assert-valid-pattern.js +0 -10
- package/dist/node_modules/minimatch/dist/esm/ast.js +0 -841
- package/dist/node_modules/minimatch/dist/esm/brace-expressions.js +0 -146
- package/dist/node_modules/minimatch/dist/esm/escape.js +0 -26
- package/dist/node_modules/minimatch/dist/esm/index.js +0 -1114
- package/dist/node_modules/minimatch/dist/esm/package.json +0 -3
- package/dist/node_modules/minimatch/dist/esm/unescape.js +0 -34
- package/dist/node_modules/minimatch/package.json +0 -73
- package/dist/node_modules/minipass-collect/LICENSE +0 -15
- package/dist/node_modules/minipass-collect/index.js +0 -71
- package/dist/node_modules/minipass-collect/package.json +0 -30
- package/dist/node_modules/minipass-fetch/LICENSE +0 -28
- package/dist/node_modules/minipass-fetch/lib/abort-error.js +0 -17
- package/dist/node_modules/minipass-fetch/lib/blob.js +0 -97
- package/dist/node_modules/minipass-fetch/lib/body.js +0 -360
- package/dist/node_modules/minipass-fetch/lib/fetch-error.js +0 -32
- package/dist/node_modules/minipass-fetch/lib/headers.js +0 -267
- package/dist/node_modules/minipass-fetch/lib/index.js +0 -376
- package/dist/node_modules/minipass-fetch/lib/request.js +0 -282
- package/dist/node_modules/minipass-fetch/lib/response.js +0 -90
- package/dist/node_modules/minipass-fetch/package.json +0 -70
- package/dist/node_modules/minipass-flush/index.js +0 -39
- package/dist/node_modules/minipass-flush/node_modules/minipass/LICENSE +0 -15
- package/dist/node_modules/minipass-flush/node_modules/minipass/index.js +0 -649
- package/dist/node_modules/minipass-flush/node_modules/minipass/package.json +0 -56
- package/dist/node_modules/minipass-flush/package.json +0 -42
- package/dist/node_modules/minipass-pipeline/LICENSE +0 -15
- package/dist/node_modules/minipass-pipeline/index.js +0 -128
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/LICENSE +0 -15
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/index.js +0 -649
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/package.json +0 -56
- package/dist/node_modules/minipass-pipeline/package.json +0 -29
- package/dist/node_modules/minipass-sized/LICENSE +0 -15
- package/dist/node_modules/minipass-sized/dist/commonjs/index.js +0 -69
- package/dist/node_modules/minipass-sized/dist/commonjs/package.json +0 -3
- package/dist/node_modules/minipass-sized/dist/esm/index.js +0 -64
- package/dist/node_modules/minipass-sized/dist/esm/package.json +0 -3
- package/dist/node_modules/minipass-sized/package.json +0 -69
- package/dist/node_modules/ms/index.js +0 -162
- package/dist/node_modules/ms/package.json +0 -38
- package/dist/node_modules/negotiator/LICENSE +0 -24
- package/dist/node_modules/negotiator/index.js +0 -83
- package/dist/node_modules/negotiator/lib/charset.js +0 -169
- package/dist/node_modules/negotiator/lib/encoding.js +0 -205
- package/dist/node_modules/negotiator/lib/language.js +0 -179
- package/dist/node_modules/negotiator/lib/mediaType.js +0 -294
- package/dist/node_modules/negotiator/package.json +0 -43
- package/dist/node_modules/p-map/index.js +0 -283
- package/dist/node_modules/p-map/license +0 -9
- package/dist/node_modules/p-map/package.json +0 -57
- package/dist/node_modules/path-scurry/dist/commonjs/index.js +0 -2018
- package/dist/node_modules/path-scurry/dist/commonjs/package.json +0 -3
- package/dist/node_modules/path-scurry/dist/esm/index.js +0 -1983
- package/dist/node_modules/path-scurry/dist/esm/package.json +0 -3
- package/dist/node_modules/path-scurry/package.json +0 -72
- package/dist/node_modules/safer-buffer/dangerous.js +0 -58
- package/dist/node_modules/safer-buffer/package.json +0 -34
- package/dist/node_modules/safer-buffer/safer.js +0 -77
- package/dist/node_modules/safer-buffer/tests.js +0 -406
- package/dist/node_modules/smart-buffer/.prettierrc.yaml +0 -5
- package/dist/node_modules/smart-buffer/LICENSE +0 -20
- package/dist/node_modules/smart-buffer/build/smartbuffer.js +0 -1233
- package/dist/node_modules/smart-buffer/build/utils.js +0 -108
- package/dist/node_modules/smart-buffer/package.json +0 -79
- package/dist/node_modules/socks/.eslintrc.cjs +0 -11
- package/dist/node_modules/socks/.prettierrc.yaml +0 -7
- package/dist/node_modules/socks/LICENSE +0 -20
- package/dist/node_modules/socks/build/client/socksclient.js +0 -793
- package/dist/node_modules/socks/build/common/constants.js +0 -108
- package/dist/node_modules/socks/build/common/helpers.js +0 -167
- package/dist/node_modules/socks/build/common/receivebuffer.js +0 -43
- package/dist/node_modules/socks/build/common/util.js +0 -25
- package/dist/node_modules/socks/build/index.js +0 -18
- package/dist/node_modules/socks/package.json +0 -58
- package/dist/node_modules/socks-proxy-agent/LICENSE +0 -22
- package/dist/node_modules/socks-proxy-agent/dist/index.js +0 -195
- package/dist/node_modules/socks-proxy-agent/package.json +0 -142
- package/dist/node_modules/ssri/lib/index.js +0 -550
- package/dist/node_modules/ssri/package.json +0 -66
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +0 -3
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/package.json +0 -3
- package/dist/node_modules/tar/node_modules/yallist/package.json +0 -68
- package/dist/node_modules/yallist/LICENSE +0 -15
- package/dist/node_modules/yallist/iterator.js +0 -8
- package/dist/node_modules/yallist/yallist.js +0 -426
- /package/dist/node_modules/{tar/node_modules/yallist → yallist}/dist/commonjs/index.js +0 -0
- /package/dist/node_modules/{balanced-match → yallist}/dist/commonjs/package.json +0 -0
- /package/dist/node_modules/{tar/node_modules/yallist → yallist}/dist/esm/index.js +0 -0
- /package/dist/node_modules/{balanced-match → yallist}/dist/esm/package.json +0 -0
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const { URL } = require('url')
|
|
3
|
-
const http = require('http')
|
|
4
|
-
const https = require('https')
|
|
5
|
-
const zlib = require('minizlib')
|
|
6
|
-
const { Minipass } = require('minipass')
|
|
7
|
-
|
|
8
|
-
const Body = require('./body.js')
|
|
9
|
-
const { writeToStream, getTotalBytes } = Body
|
|
10
|
-
const Response = require('./response.js')
|
|
11
|
-
const Headers = require('./headers.js')
|
|
12
|
-
const { createHeadersLenient } = Headers
|
|
13
|
-
const Request = require('./request.js')
|
|
14
|
-
const { getNodeRequestOptions } = Request
|
|
15
|
-
const FetchError = require('./fetch-error.js')
|
|
16
|
-
const AbortError = require('./abort-error.js')
|
|
17
|
-
|
|
18
|
-
// XXX this should really be split up and unit-ized for easier testing
|
|
19
|
-
// and better DRY implementation of data/http request aborting
|
|
20
|
-
const fetch = async (url, opts) => {
|
|
21
|
-
if (/^data:/.test(url)) {
|
|
22
|
-
const request = new Request(url, opts)
|
|
23
|
-
// delay 1 promise tick so that the consumer can abort right away
|
|
24
|
-
return Promise.resolve().then(() => new Promise((resolve, reject) => {
|
|
25
|
-
let type, data
|
|
26
|
-
try {
|
|
27
|
-
const { pathname, search } = new URL(url)
|
|
28
|
-
const split = pathname.split(',')
|
|
29
|
-
if (split.length < 2) {
|
|
30
|
-
throw new Error('invalid data: URI')
|
|
31
|
-
}
|
|
32
|
-
const mime = split.shift()
|
|
33
|
-
const base64 = /;base64$/.test(mime)
|
|
34
|
-
type = base64 ? mime.slice(0, -1 * ';base64'.length) : mime
|
|
35
|
-
const rawData = decodeURIComponent(split.join(',') + search)
|
|
36
|
-
data = base64 ? Buffer.from(rawData, 'base64') : Buffer.from(rawData)
|
|
37
|
-
} catch (er) {
|
|
38
|
-
return reject(new FetchError(`[${request.method}] ${
|
|
39
|
-
request.url} invalid URL, ${er.message}`, 'system', er))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const { signal } = request
|
|
43
|
-
if (signal && signal.aborted) {
|
|
44
|
-
return reject(new AbortError('The user aborted a request.'))
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const headers = { 'Content-Length': data.length }
|
|
48
|
-
if (type) {
|
|
49
|
-
headers['Content-Type'] = type
|
|
50
|
-
}
|
|
51
|
-
return resolve(new Response(data, { headers }))
|
|
52
|
-
}))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
// build request object
|
|
57
|
-
const request = new Request(url, opts)
|
|
58
|
-
let options
|
|
59
|
-
try {
|
|
60
|
-
options = getNodeRequestOptions(request)
|
|
61
|
-
} catch (er) {
|
|
62
|
-
return reject(er)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const send = (options.protocol === 'https:' ? https : http).request
|
|
66
|
-
const { signal } = request
|
|
67
|
-
let response = null
|
|
68
|
-
const abort = () => {
|
|
69
|
-
const error = new AbortError('The user aborted a request.')
|
|
70
|
-
reject(error)
|
|
71
|
-
if (Minipass.isStream(request.body) &&
|
|
72
|
-
typeof request.body.destroy === 'function') {
|
|
73
|
-
request.body.destroy(error)
|
|
74
|
-
}
|
|
75
|
-
if (response && response.body) {
|
|
76
|
-
response.body.emit('error', error)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (signal && signal.aborted) {
|
|
81
|
-
return abort()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const abortAndFinalize = () => {
|
|
85
|
-
abort()
|
|
86
|
-
finalize()
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const finalize = () => {
|
|
90
|
-
req.abort()
|
|
91
|
-
if (signal) {
|
|
92
|
-
signal.removeEventListener('abort', abortAndFinalize)
|
|
93
|
-
}
|
|
94
|
-
clearTimeout(reqTimeout)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// send request
|
|
98
|
-
const req = send(options)
|
|
99
|
-
|
|
100
|
-
if (signal) {
|
|
101
|
-
signal.addEventListener('abort', abortAndFinalize)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let reqTimeout = null
|
|
105
|
-
if (request.timeout) {
|
|
106
|
-
req.once('socket', () => {
|
|
107
|
-
reqTimeout = setTimeout(() => {
|
|
108
|
-
reject(new FetchError(`network timeout at: ${
|
|
109
|
-
request.url}`, 'request-timeout'))
|
|
110
|
-
finalize()
|
|
111
|
-
}, request.timeout)
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
req.on('error', er => {
|
|
116
|
-
// if a 'response' event is emitted before the 'error' event, then by the
|
|
117
|
-
// time this handler is run it's too late to reject the Promise for the
|
|
118
|
-
// response. instead, we forward the error event to the response stream
|
|
119
|
-
// so that the error will surface to the user when they try to consume
|
|
120
|
-
// the body. this is done as a side effect of aborting the request except
|
|
121
|
-
// for in windows, where we must forward the event manually, otherwise
|
|
122
|
-
// there is no longer a ref'd socket attached to the request and the
|
|
123
|
-
// stream never ends so the event loop runs out of work and the process
|
|
124
|
-
// exits without warning.
|
|
125
|
-
// coverage skipped here due to the difficulty in testing
|
|
126
|
-
// istanbul ignore next
|
|
127
|
-
if (req.res) {
|
|
128
|
-
req.res.emit('error', er)
|
|
129
|
-
}
|
|
130
|
-
reject(new FetchError(`request to ${request.url} failed, reason: ${
|
|
131
|
-
er.message}`, 'system', er))
|
|
132
|
-
finalize()
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
req.on('response', res => {
|
|
136
|
-
clearTimeout(reqTimeout)
|
|
137
|
-
|
|
138
|
-
const headers = createHeadersLenient(res.headers)
|
|
139
|
-
|
|
140
|
-
// HTTP fetch step 5
|
|
141
|
-
if (fetch.isRedirect(res.statusCode)) {
|
|
142
|
-
// HTTP fetch step 5.2
|
|
143
|
-
const location = headers.get('Location')
|
|
144
|
-
|
|
145
|
-
// HTTP fetch step 5.3
|
|
146
|
-
let locationURL = null
|
|
147
|
-
try {
|
|
148
|
-
locationURL = location === null ? null : new URL(location, request.url).toString()
|
|
149
|
-
} catch {
|
|
150
|
-
// error here can only be invalid URL in Location: header
|
|
151
|
-
// do not throw when options.redirect == manual
|
|
152
|
-
// let the user extract the errorneous redirect URL
|
|
153
|
-
if (request.redirect !== 'manual') {
|
|
154
|
-
/* eslint-disable-next-line max-len */
|
|
155
|
-
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'))
|
|
156
|
-
finalize()
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// HTTP fetch step 5.5
|
|
162
|
-
if (request.redirect === 'error') {
|
|
163
|
-
reject(new FetchError('uri requested responds with a redirect, ' +
|
|
164
|
-
`redirect mode is set to error: ${request.url}`, 'no-redirect'))
|
|
165
|
-
finalize()
|
|
166
|
-
return
|
|
167
|
-
} else if (request.redirect === 'manual') {
|
|
168
|
-
// node-fetch-specific step: make manual redirect a bit easier to
|
|
169
|
-
// use by setting the Location header value to the resolved URL.
|
|
170
|
-
if (locationURL !== null) {
|
|
171
|
-
// handle corrupted header
|
|
172
|
-
try {
|
|
173
|
-
headers.set('Location', locationURL)
|
|
174
|
-
} catch (err) {
|
|
175
|
-
/* istanbul ignore next: nodejs server prevent invalid
|
|
176
|
-
response headers, we can't test this through normal
|
|
177
|
-
request */
|
|
178
|
-
reject(err)
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} else if (request.redirect === 'follow' && locationURL !== null) {
|
|
182
|
-
// HTTP-redirect fetch step 5
|
|
183
|
-
if (request.counter >= request.follow) {
|
|
184
|
-
reject(new FetchError(`maximum redirect reached at: ${
|
|
185
|
-
request.url}`, 'max-redirect'))
|
|
186
|
-
finalize()
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// HTTP-redirect fetch step 9
|
|
191
|
-
if (res.statusCode !== 303 &&
|
|
192
|
-
request.body &&
|
|
193
|
-
getTotalBytes(request) === null) {
|
|
194
|
-
reject(new FetchError(
|
|
195
|
-
'Cannot follow redirect with body being a readable stream',
|
|
196
|
-
'unsupported-redirect'
|
|
197
|
-
))
|
|
198
|
-
finalize()
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Update host due to redirection
|
|
203
|
-
request.headers.set('host', (new URL(locationURL)).host)
|
|
204
|
-
|
|
205
|
-
// HTTP-redirect fetch step 6 (counter increment)
|
|
206
|
-
// Create a new Request object.
|
|
207
|
-
const requestOpts = {
|
|
208
|
-
headers: new Headers(request.headers),
|
|
209
|
-
follow: request.follow,
|
|
210
|
-
counter: request.counter + 1,
|
|
211
|
-
agent: request.agent,
|
|
212
|
-
compress: request.compress,
|
|
213
|
-
method: request.method,
|
|
214
|
-
body: request.body,
|
|
215
|
-
signal: request.signal,
|
|
216
|
-
timeout: request.timeout,
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// if the redirect is to a new hostname, strip the authorization and cookie headers
|
|
220
|
-
const parsedOriginal = new URL(request.url)
|
|
221
|
-
const parsedRedirect = new URL(locationURL)
|
|
222
|
-
if (parsedOriginal.hostname !== parsedRedirect.hostname) {
|
|
223
|
-
requestOpts.headers.delete('authorization')
|
|
224
|
-
requestOpts.headers.delete('cookie')
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// HTTP-redirect fetch step 11
|
|
228
|
-
if (res.statusCode === 303 || (
|
|
229
|
-
(res.statusCode === 301 || res.statusCode === 302) &&
|
|
230
|
-
request.method === 'POST'
|
|
231
|
-
)) {
|
|
232
|
-
requestOpts.method = 'GET'
|
|
233
|
-
requestOpts.body = undefined
|
|
234
|
-
requestOpts.headers.delete('content-length')
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// HTTP-redirect fetch step 15
|
|
238
|
-
resolve(fetch(new Request(locationURL, requestOpts)))
|
|
239
|
-
finalize()
|
|
240
|
-
return
|
|
241
|
-
}
|
|
242
|
-
} // end if(isRedirect)
|
|
243
|
-
|
|
244
|
-
// prepare response
|
|
245
|
-
res.once('end', () =>
|
|
246
|
-
signal && signal.removeEventListener('abort', abortAndFinalize))
|
|
247
|
-
|
|
248
|
-
const body = new Minipass()
|
|
249
|
-
// if an error occurs, either on the response stream itself, on one of the
|
|
250
|
-
// decoder streams, or a response length timeout from the Body class, we
|
|
251
|
-
// forward the error through to our internal body stream. If we see an
|
|
252
|
-
// error event on that, we call finalize to abort the request and ensure
|
|
253
|
-
// we don't leave a socket believing a request is in flight.
|
|
254
|
-
// this is difficult to test, so lacks specific coverage.
|
|
255
|
-
body.on('error', finalize)
|
|
256
|
-
// exceedingly rare that the stream would have an error,
|
|
257
|
-
// but just in case we proxy it to the stream in use.
|
|
258
|
-
res.on('error', /* istanbul ignore next */ er => body.emit('error', er))
|
|
259
|
-
res.on('data', (chunk) => body.write(chunk))
|
|
260
|
-
res.on('end', () => body.end())
|
|
261
|
-
|
|
262
|
-
const responseOptions = {
|
|
263
|
-
url: request.url,
|
|
264
|
-
status: res.statusCode,
|
|
265
|
-
statusText: res.statusMessage,
|
|
266
|
-
headers: headers,
|
|
267
|
-
size: request.size,
|
|
268
|
-
timeout: request.timeout,
|
|
269
|
-
counter: request.counter,
|
|
270
|
-
trailer: new Promise(resolveTrailer =>
|
|
271
|
-
res.on('end', () => resolveTrailer(createHeadersLenient(res.trailers)))),
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// HTTP-network fetch step 12.1.1.3
|
|
275
|
-
const codings = headers.get('Content-Encoding')
|
|
276
|
-
|
|
277
|
-
// HTTP-network fetch step 12.1.1.4: handle content codings
|
|
278
|
-
|
|
279
|
-
// in following scenarios we ignore compression support
|
|
280
|
-
// 1. compression support is disabled
|
|
281
|
-
// 2. HEAD request
|
|
282
|
-
// 3. no Content-Encoding header
|
|
283
|
-
// 4. no content response (204)
|
|
284
|
-
// 5. content not modified response (304)
|
|
285
|
-
if (!request.compress ||
|
|
286
|
-
request.method === 'HEAD' ||
|
|
287
|
-
codings === null ||
|
|
288
|
-
res.statusCode === 204 ||
|
|
289
|
-
res.statusCode === 304) {
|
|
290
|
-
response = new Response(body, responseOptions)
|
|
291
|
-
resolve(response)
|
|
292
|
-
return
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Be less strict when decoding compressed responses, since sometimes
|
|
296
|
-
// servers send slightly invalid responses that are still accepted
|
|
297
|
-
// by common browsers.
|
|
298
|
-
// Always using Z_SYNC_FLUSH is what cURL does.
|
|
299
|
-
const zlibOptions = {
|
|
300
|
-
flush: zlib.constants.Z_SYNC_FLUSH,
|
|
301
|
-
finishFlush: zlib.constants.Z_SYNC_FLUSH,
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// for gzip
|
|
305
|
-
if (codings === 'gzip' || codings === 'x-gzip') {
|
|
306
|
-
const unzip = new zlib.Gunzip(zlibOptions)
|
|
307
|
-
response = new Response(
|
|
308
|
-
// exceedingly rare that the stream would have an error,
|
|
309
|
-
// but just in case we proxy it to the stream in use.
|
|
310
|
-
body.on('error', /* istanbul ignore next */ er => unzip.emit('error', er)).pipe(unzip),
|
|
311
|
-
responseOptions
|
|
312
|
-
)
|
|
313
|
-
resolve(response)
|
|
314
|
-
return
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// for deflate
|
|
318
|
-
if (codings === 'deflate' || codings === 'x-deflate') {
|
|
319
|
-
// handle the infamous raw deflate response from old servers
|
|
320
|
-
// a hack for old IIS and Apache servers
|
|
321
|
-
res.once('data', chunk => {
|
|
322
|
-
// see http://stackoverflow.com/questions/37519828
|
|
323
|
-
const decoder = (chunk[0] & 0x0F) === 0x08
|
|
324
|
-
? new zlib.Inflate()
|
|
325
|
-
: new zlib.InflateRaw()
|
|
326
|
-
// exceedingly rare that the stream would have an error,
|
|
327
|
-
// but just in case we proxy it to the stream in use.
|
|
328
|
-
body.on('error', /* istanbul ignore next */ er => decoder.emit('error', er)).pipe(decoder)
|
|
329
|
-
response = new Response(decoder, responseOptions)
|
|
330
|
-
resolve(response)
|
|
331
|
-
})
|
|
332
|
-
return
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// for br
|
|
336
|
-
if (codings === 'br') {
|
|
337
|
-
// ignoring coverage so tests don't have to fake support (or lack of) for brotli
|
|
338
|
-
// istanbul ignore next
|
|
339
|
-
try {
|
|
340
|
-
var decoder = new zlib.BrotliDecompress()
|
|
341
|
-
} catch (err) {
|
|
342
|
-
reject(err)
|
|
343
|
-
finalize()
|
|
344
|
-
return
|
|
345
|
-
}
|
|
346
|
-
// exceedingly rare that the stream would have an error,
|
|
347
|
-
// but just in case we proxy it to the stream in use.
|
|
348
|
-
body.on('error', /* istanbul ignore next */ er => decoder.emit('error', er)).pipe(decoder)
|
|
349
|
-
response = new Response(decoder, responseOptions)
|
|
350
|
-
resolve(response)
|
|
351
|
-
return
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// otherwise, use response as-is
|
|
355
|
-
response = new Response(body, responseOptions)
|
|
356
|
-
resolve(response)
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
writeToStream(req, request)
|
|
360
|
-
})
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
module.exports = fetch
|
|
364
|
-
|
|
365
|
-
fetch.isRedirect = code =>
|
|
366
|
-
code === 301 ||
|
|
367
|
-
code === 302 ||
|
|
368
|
-
code === 303 ||
|
|
369
|
-
code === 307 ||
|
|
370
|
-
code === 308
|
|
371
|
-
|
|
372
|
-
fetch.Headers = Headers
|
|
373
|
-
fetch.Request = Request
|
|
374
|
-
fetch.Response = Response
|
|
375
|
-
fetch.FetchError = FetchError
|
|
376
|
-
fetch.AbortError = AbortError
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const { URL } = require('url')
|
|
3
|
-
const { Minipass } = require('minipass')
|
|
4
|
-
const Headers = require('./headers.js')
|
|
5
|
-
const { exportNodeCompatibleHeaders } = Headers
|
|
6
|
-
const Body = require('./body.js')
|
|
7
|
-
const { clone, extractContentType, getTotalBytes } = Body
|
|
8
|
-
|
|
9
|
-
const version = require('../package.json').version
|
|
10
|
-
const defaultUserAgent =
|
|
11
|
-
`minipass-fetch/${version} (+https://github.com/isaacs/minipass-fetch)`
|
|
12
|
-
|
|
13
|
-
const INTERNALS = Symbol('Request internals')
|
|
14
|
-
|
|
15
|
-
const isRequest = input =>
|
|
16
|
-
typeof input === 'object' && typeof input[INTERNALS] === 'object'
|
|
17
|
-
|
|
18
|
-
const isAbortSignal = signal => {
|
|
19
|
-
const proto = (
|
|
20
|
-
signal
|
|
21
|
-
&& typeof signal === 'object'
|
|
22
|
-
&& Object.getPrototypeOf(signal)
|
|
23
|
-
)
|
|
24
|
-
return !!(proto && proto.constructor.name === 'AbortSignal')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class Request extends Body {
|
|
28
|
-
constructor (input, init = {}) {
|
|
29
|
-
const parsedURL = isRequest(input) ? new URL(input.url)
|
|
30
|
-
: input && input.href ? new URL(input.href)
|
|
31
|
-
: new URL(`${input}`)
|
|
32
|
-
|
|
33
|
-
if (isRequest(input)) {
|
|
34
|
-
init = { ...input[INTERNALS], ...init }
|
|
35
|
-
} else if (!input || typeof input === 'string') {
|
|
36
|
-
input = {}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const method = (init.method || input.method || 'GET').toUpperCase()
|
|
40
|
-
const isGETHEAD = method === 'GET' || method === 'HEAD'
|
|
41
|
-
|
|
42
|
-
if ((init.body !== null && init.body !== undefined ||
|
|
43
|
-
isRequest(input) && input.body !== null) && isGETHEAD) {
|
|
44
|
-
throw new TypeError('Request with GET/HEAD method cannot have body')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const inputBody = init.body !== null && init.body !== undefined ? init.body
|
|
48
|
-
: isRequest(input) && input.body !== null ? clone(input)
|
|
49
|
-
: null
|
|
50
|
-
|
|
51
|
-
super(inputBody, {
|
|
52
|
-
timeout: init.timeout || input.timeout || 0,
|
|
53
|
-
size: init.size || input.size || 0,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const headers = new Headers(init.headers || input.headers || {})
|
|
57
|
-
|
|
58
|
-
if (inputBody !== null && inputBody !== undefined &&
|
|
59
|
-
!headers.has('Content-Type')) {
|
|
60
|
-
const contentType = extractContentType(inputBody)
|
|
61
|
-
if (contentType) {
|
|
62
|
-
headers.append('Content-Type', contentType)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const signal = 'signal' in init ? init.signal
|
|
67
|
-
: null
|
|
68
|
-
|
|
69
|
-
if (signal !== null && signal !== undefined && !isAbortSignal(signal)) {
|
|
70
|
-
throw new TypeError('Expected signal must be an instanceof AbortSignal')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// TLS specific options that are handled by node
|
|
74
|
-
const {
|
|
75
|
-
ca,
|
|
76
|
-
cert,
|
|
77
|
-
ciphers,
|
|
78
|
-
clientCertEngine,
|
|
79
|
-
crl,
|
|
80
|
-
dhparam,
|
|
81
|
-
ecdhCurve,
|
|
82
|
-
family,
|
|
83
|
-
honorCipherOrder,
|
|
84
|
-
key,
|
|
85
|
-
passphrase,
|
|
86
|
-
pfx,
|
|
87
|
-
rejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0',
|
|
88
|
-
secureOptions,
|
|
89
|
-
secureProtocol,
|
|
90
|
-
servername,
|
|
91
|
-
sessionIdContext,
|
|
92
|
-
} = init
|
|
93
|
-
|
|
94
|
-
this[INTERNALS] = {
|
|
95
|
-
method,
|
|
96
|
-
redirect: init.redirect || input.redirect || 'follow',
|
|
97
|
-
headers,
|
|
98
|
-
parsedURL,
|
|
99
|
-
signal,
|
|
100
|
-
ca,
|
|
101
|
-
cert,
|
|
102
|
-
ciphers,
|
|
103
|
-
clientCertEngine,
|
|
104
|
-
crl,
|
|
105
|
-
dhparam,
|
|
106
|
-
ecdhCurve,
|
|
107
|
-
family,
|
|
108
|
-
honorCipherOrder,
|
|
109
|
-
key,
|
|
110
|
-
passphrase,
|
|
111
|
-
pfx,
|
|
112
|
-
rejectUnauthorized,
|
|
113
|
-
secureOptions,
|
|
114
|
-
secureProtocol,
|
|
115
|
-
servername,
|
|
116
|
-
sessionIdContext,
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// node-fetch-only options
|
|
120
|
-
this.follow = init.follow !== undefined ? init.follow
|
|
121
|
-
: input.follow !== undefined ? input.follow
|
|
122
|
-
: 20
|
|
123
|
-
this.compress = init.compress !== undefined ? init.compress
|
|
124
|
-
: input.compress !== undefined ? input.compress
|
|
125
|
-
: true
|
|
126
|
-
this.counter = init.counter || input.counter || 0
|
|
127
|
-
this.agent = init.agent || input.agent
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
get method () {
|
|
131
|
-
return this[INTERNALS].method
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
get url () {
|
|
135
|
-
return this[INTERNALS].parsedURL.toString()
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
get headers () {
|
|
139
|
-
return this[INTERNALS].headers
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
get redirect () {
|
|
143
|
-
return this[INTERNALS].redirect
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
get signal () {
|
|
147
|
-
return this[INTERNALS].signal
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
clone () {
|
|
151
|
-
return new Request(this)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
get [Symbol.toStringTag] () {
|
|
155
|
-
return 'Request'
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
static getNodeRequestOptions (request) {
|
|
159
|
-
const parsedURL = request[INTERNALS].parsedURL
|
|
160
|
-
const headers = new Headers(request[INTERNALS].headers)
|
|
161
|
-
|
|
162
|
-
// fetch step 1.3
|
|
163
|
-
if (!headers.has('Accept')) {
|
|
164
|
-
headers.set('Accept', '*/*')
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Basic fetch
|
|
168
|
-
if (!/^https?:$/.test(parsedURL.protocol)) {
|
|
169
|
-
throw new TypeError('Only HTTP(S) protocols are supported')
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (request.signal &&
|
|
173
|
-
Minipass.isStream(request.body) &&
|
|
174
|
-
typeof request.body.destroy !== 'function') {
|
|
175
|
-
throw new Error(
|
|
176
|
-
'Cancellation of streamed requests with AbortSignal is not supported')
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// HTTP-network-or-cache fetch steps 2.4-2.7
|
|
180
|
-
const contentLengthValue =
|
|
181
|
-
(request.body === null || request.body === undefined) &&
|
|
182
|
-
/^(POST|PUT)$/i.test(request.method) ? '0'
|
|
183
|
-
: request.body !== null && request.body !== undefined
|
|
184
|
-
? getTotalBytes(request)
|
|
185
|
-
: null
|
|
186
|
-
|
|
187
|
-
if (contentLengthValue) {
|
|
188
|
-
headers.set('Content-Length', contentLengthValue + '')
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// HTTP-network-or-cache fetch step 2.11
|
|
192
|
-
if (!headers.has('User-Agent')) {
|
|
193
|
-
headers.set('User-Agent', defaultUserAgent)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// HTTP-network-or-cache fetch step 2.15
|
|
197
|
-
if (request.compress && !headers.has('Accept-Encoding')) {
|
|
198
|
-
headers.set('Accept-Encoding', 'gzip,deflate')
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const agent = typeof request.agent === 'function'
|
|
202
|
-
? request.agent(parsedURL)
|
|
203
|
-
: request.agent
|
|
204
|
-
|
|
205
|
-
if (!headers.has('Connection') && !agent) {
|
|
206
|
-
headers.set('Connection', 'close')
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// TLS specific options that are handled by node
|
|
210
|
-
const {
|
|
211
|
-
ca,
|
|
212
|
-
cert,
|
|
213
|
-
ciphers,
|
|
214
|
-
clientCertEngine,
|
|
215
|
-
crl,
|
|
216
|
-
dhparam,
|
|
217
|
-
ecdhCurve,
|
|
218
|
-
family,
|
|
219
|
-
honorCipherOrder,
|
|
220
|
-
key,
|
|
221
|
-
passphrase,
|
|
222
|
-
pfx,
|
|
223
|
-
rejectUnauthorized,
|
|
224
|
-
secureOptions,
|
|
225
|
-
secureProtocol,
|
|
226
|
-
servername,
|
|
227
|
-
sessionIdContext,
|
|
228
|
-
} = request[INTERNALS]
|
|
229
|
-
|
|
230
|
-
// HTTP-network fetch step 4.2
|
|
231
|
-
// chunked encoding is handled by Node.js
|
|
232
|
-
|
|
233
|
-
// we cannot spread parsedURL directly, so we have to read each property one-by-one
|
|
234
|
-
// and map them to the equivalent https?.request() method options
|
|
235
|
-
const urlProps = {
|
|
236
|
-
auth: parsedURL.username || parsedURL.password
|
|
237
|
-
? `${parsedURL.username}:${parsedURL.password}`
|
|
238
|
-
: '',
|
|
239
|
-
host: parsedURL.host,
|
|
240
|
-
hostname: parsedURL.hostname,
|
|
241
|
-
path: `${parsedURL.pathname}${parsedURL.search}`,
|
|
242
|
-
port: parsedURL.port,
|
|
243
|
-
protocol: parsedURL.protocol,
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return {
|
|
247
|
-
...urlProps,
|
|
248
|
-
method: request.method,
|
|
249
|
-
headers: exportNodeCompatibleHeaders(headers),
|
|
250
|
-
agent,
|
|
251
|
-
ca,
|
|
252
|
-
cert,
|
|
253
|
-
ciphers,
|
|
254
|
-
clientCertEngine,
|
|
255
|
-
crl,
|
|
256
|
-
dhparam,
|
|
257
|
-
ecdhCurve,
|
|
258
|
-
family,
|
|
259
|
-
honorCipherOrder,
|
|
260
|
-
key,
|
|
261
|
-
passphrase,
|
|
262
|
-
pfx,
|
|
263
|
-
rejectUnauthorized,
|
|
264
|
-
secureOptions,
|
|
265
|
-
secureProtocol,
|
|
266
|
-
servername,
|
|
267
|
-
sessionIdContext,
|
|
268
|
-
timeout: request.timeout,
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
module.exports = Request
|
|
274
|
-
|
|
275
|
-
Object.defineProperties(Request.prototype, {
|
|
276
|
-
method: { enumerable: true },
|
|
277
|
-
url: { enumerable: true },
|
|
278
|
-
headers: { enumerable: true },
|
|
279
|
-
redirect: { enumerable: true },
|
|
280
|
-
clone: { enumerable: true },
|
|
281
|
-
signal: { enumerable: true },
|
|
282
|
-
})
|