@socketsecurity/lib 5.27.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -27
- package/README.md +1 -1
- package/dist/abort/signal.d.ts +28 -0
- package/dist/{abort.js → abort/signal.js} +12 -10
- package/dist/ai/discover.d.mts +50 -0
- package/dist/ai/discover.js +128 -0
- package/dist/ai/profiles.d.mts +39 -0
- package/dist/ai/profiles.js +61 -0
- package/dist/ai/spawn.d.mts +49 -0
- package/dist/ai/spawn.js +207 -0
- package/dist/ai/types.d.mts +117 -0
- package/dist/ai/types.js +18 -0
- package/dist/ai/worktree.d.mts +104 -0
- package/dist/ai/worktree.js +200 -0
- package/dist/ansi/constants.d.ts +10 -0
- package/dist/ansi/constants.js +45 -0
- package/dist/ansi/strip.d.ts +33 -0
- package/dist/{ansi.js → ansi/strip.js} +7 -24
- package/dist/archives/_internal.d.ts +39 -0
- package/dist/archives/_internal.js +87 -0
- package/dist/archives/detect.d.ts +19 -0
- package/dist/archives/detect.js +46 -0
- package/dist/archives/extract.d.ts +22 -0
- package/dist/archives/extract.js +53 -0
- package/dist/archives/tar.d.ts +42 -0
- package/dist/archives/tar.js +233 -0
- package/dist/archives/types.d.ts +34 -0
- package/dist/archives/types.js +18 -0
- package/dist/archives/zip.d.ts +20 -0
- package/dist/archives/zip.js +124 -0
- package/dist/argv/flag-predicates.d.ts +179 -0
- package/dist/argv/flag-predicates.js +118 -0
- package/dist/argv/flag-types.d.ts +123 -0
- package/dist/argv/flag-types.js +116 -0
- package/dist/argv/parse.d.ts +34 -33
- package/dist/argv/parse.js +6 -4
- package/dist/arrays/_internal.d.ts +43 -0
- package/dist/{arrays.js → arrays/_internal.js} +8 -41
- package/dist/arrays/chunk.d.ts +37 -0
- package/dist/arrays/chunk.js +43 -0
- package/dist/arrays/join.d.ts +76 -0
- package/dist/{env/helpers.js → arrays/join.js} +12 -18
- package/dist/arrays/predicates.d.ts +40 -0
- package/dist/arrays/predicates.js +30 -0
- package/dist/arrays/unique.d.ts +36 -0
- package/dist/arrays/unique.js +34 -0
- package/dist/bin/_internal.d.ts +22 -0
- package/dist/bin/_internal.js +43 -0
- package/dist/bin/check-primordials.d.ts +44 -0
- package/dist/bin/check-primordials.js +245 -0
- package/dist/bin/check.d.ts +10 -0
- package/dist/bin/check.js +77 -0
- package/dist/bin/exec.d.ts +37 -0
- package/dist/bin/exec.js +79 -0
- package/dist/bin/find.d.ts +58 -0
- package/dist/bin/find.js +143 -0
- package/dist/bin/resolve.d.ts +30 -0
- package/dist/bin/resolve.js +249 -0
- package/dist/bin/shadow.d.ts +16 -0
- package/dist/bin/shadow.js +36 -0
- package/dist/bin/socket-lib.d.ts +13 -0
- package/dist/bin/socket-lib.js +79 -0
- package/dist/bin/types.d.ts +34 -0
- package/dist/bin/types.js +18 -0
- package/dist/bin/which.d.ts +111 -0
- package/dist/bin/which.js +155 -0
- package/dist/cacache/_internal.d.ts +15 -0
- package/dist/cacache/_internal.js +43 -0
- package/dist/cacache/clear.d.ts +43 -0
- package/dist/cacache/clear.js +77 -0
- package/dist/cacache/read.d.ts +31 -0
- package/dist/cacache/read.js +51 -0
- package/dist/cacache/tmp.d.ts +18 -0
- package/dist/cacache/tmp.js +39 -0
- package/dist/cacache/types.d.ts +37 -0
- package/dist/cacache/types.js +18 -0
- package/dist/cacache/write.d.ts +31 -0
- package/dist/cacache/write.js +53 -0
- package/dist/checks/primordials.d.ts +118 -0
- package/dist/checks/primordials.js +293 -0
- package/dist/colors/convert.d.ts +35 -0
- package/dist/colors/convert.js +42 -0
- package/dist/colors/palette.d.ts +7 -0
- package/dist/{colors.js → colors/palette.js} +5 -17
- package/dist/colors/types.d.ts +29 -0
- package/dist/colors/types.js +18 -0
- package/dist/compression/_internal.d.ts +33 -0
- package/dist/compression/_internal.js +77 -0
- package/dist/compression/brotli.d.ts +82 -0
- package/dist/compression/brotli.js +147 -0
- package/dist/compression/gzip.d.ts +70 -0
- package/dist/compression/gzip.js +142 -0
- package/dist/compression/types.d.ts +37 -0
- package/dist/compression/types.js +18 -0
- package/dist/constants/agents.d.ts +4 -3
- package/dist/constants/agents.js +7 -4
- package/dist/constants/encoding.d.ts +3 -3
- package/dist/constants/github.d.ts +2 -3
- package/dist/constants/licenses.d.ts +5 -5
- package/dist/constants/licenses.js +2 -2
- package/dist/constants/lifecycle-script-names.d.ts +3 -4
- package/dist/constants/lifecycle-script-names.js +2 -2
- package/dist/constants/maintained-node-versions.d.ts +1 -1
- package/dist/constants/maintained-node-versions.js +3 -4
- package/dist/constants/node.d.ts +21 -20
- package/dist/constants/node.js +4 -4
- package/dist/constants/package-default-node-range.d.ts +1 -1
- package/dist/constants/package-default-socket-categories.d.ts +1 -1
- package/dist/constants/package-default-socket-categories.js +2 -2
- package/dist/constants/packages.d.ts +4 -4
- package/dist/constants/packages.js +7 -5
- package/dist/constants/platform.d.ts +3 -1
- package/dist/constants/platform.js +3 -10
- package/dist/constants/{core.d.ts → sentinels.d.ts} +4 -4
- package/dist/constants/{core.js → sentinels.js} +3 -3
- package/dist/constants/socket.d.ts +4 -6
- package/dist/constants/socket.js +6 -9
- package/dist/constants/testing.d.ts +3 -3
- package/dist/constants/time.d.ts +3 -3
- package/dist/constants/typescript.d.ts +3 -3
- package/dist/cover/code.d.ts +11 -3
- package/dist/cover/code.js +26 -36
- package/dist/cover/formatters.d.ts +19 -15
- package/dist/cover/formatters.js +21 -18
- package/dist/cover/type.d.ts +4 -3
- package/dist/cover/type.js +9 -8
- package/dist/cover/types.d.ts +1 -1
- package/dist/crypto/hash.d.ts +36 -0
- package/dist/{crypto.js → crypto/hash.js} +17 -17
- package/dist/debug/_internal.d.ts +25 -0
- package/dist/debug/_internal.js +77 -0
- package/dist/debug/caller-info.d.ts +12 -0
- package/dist/debug/caller-info.js +67 -0
- package/dist/debug/namespace.d.ts +35 -0
- package/dist/debug/namespace.js +101 -0
- package/dist/{debug.d.ts → debug/output.d.ts} +23 -42
- package/dist/debug/output.js +209 -0
- package/dist/debug/types.d.ts +21 -0
- package/dist/debug/types.js +18 -0
- package/dist/dlx/_internal.d.ts +10 -0
- package/dist/dlx/_internal.js +47 -0
- package/dist/dlx/arborist.d.ts +86 -61
- package/dist/dlx/arborist.js +30 -35
- package/dist/dlx/binary-cache.d.ts +108 -0
- package/dist/dlx/binary-cache.js +212 -0
- package/dist/dlx/binary-download.d.ts +67 -0
- package/dist/dlx/binary-download.js +216 -0
- package/dist/dlx/binary-resolution.d.ts +61 -0
- package/dist/dlx/binary-resolution.js +164 -0
- package/dist/dlx/binary-types.d.ts +144 -0
- package/dist/dlx/binary-types.js +18 -0
- package/dist/dlx/binary.d.ts +39 -268
- package/dist/dlx/binary.js +38 -319
- package/dist/dlx/cache.d.ts +21 -16
- package/dist/dlx/cache.js +2 -2
- package/dist/dlx/detect.d.ts +94 -68
- package/dist/dlx/detect.js +32 -35
- package/dist/dlx/dir.d.ts +20 -18
- package/dist/dlx/dir.js +7 -14
- package/dist/dlx/firewall.d.ts +27 -0
- package/dist/dlx/firewall.js +107 -0
- package/dist/dlx/lockfile.d.ts +73 -56
- package/dist/dlx/lockfile.js +36 -44
- package/dist/dlx/manifest.d.ts +50 -51
- package/dist/dlx/manifest.js +51 -52
- package/dist/dlx/package.d.ts +83 -249
- package/dist/dlx/package.js +48 -268
- package/dist/dlx/packages.d.ts +22 -20
- package/dist/dlx/packages.js +15 -20
- package/dist/dlx/paths.d.ts +26 -23
- package/dist/dlx/paths.js +8 -15
- package/dist/dlx/spec.d.ts +25 -0
- package/dist/dlx/spec.js +63 -0
- package/dist/dlx/types.d.ts +142 -0
- package/dist/dlx/types.js +18 -0
- package/dist/eco/cargo/lockfile-format.d.ts +8 -0
- package/dist/eco/cargo/lockfile-format.js +39 -0
- package/dist/eco/cargo/manifest-format.d.ts +7 -0
- package/dist/eco/cargo/manifest-format.js +38 -0
- package/dist/eco/cargo/parse-lockfile.d.ts +84 -0
- package/dist/eco/cargo/parse-lockfile.js +257 -0
- package/dist/eco/manifest/analyze-lockfile.d.ts +10 -0
- package/dist/eco/manifest/analyze-lockfile.js +67 -0
- package/dist/eco/manifest/detect-format.d.ts +15 -0
- package/dist/eco/manifest/detect-format.js +98 -0
- package/dist/eco/manifest/find-packages.d.ts +14 -0
- package/dist/eco/manifest/find-packages.js +69 -0
- package/dist/eco/manifest/get-package-versions.d.ts +8 -0
- package/dist/eco/manifest/get-package-versions.js +52 -0
- package/dist/eco/manifest/get-package.d.ts +10 -0
- package/dist/eco/manifest/get-package.js +44 -0
- package/dist/eco/manifest/manifest-error.d.ts +18 -0
- package/dist/eco/manifest/manifest-error.js +37 -0
- package/dist/eco/manifest/parse-lockfile.d.ts +16 -0
- package/dist/eco/manifest/parse-lockfile.js +91 -0
- package/dist/eco/manifest/parse-manifest.d.ts +12 -0
- package/dist/eco/manifest/parse-manifest.js +48 -0
- package/dist/eco/manifest/parse.d.ts +9 -0
- package/dist/eco/manifest/parse.js +52 -0
- package/dist/eco/manifest/types.d.ts +10 -0
- package/dist/eco/manifest/types.js +18 -0
- package/dist/eco/npm/bun/exec.d.ts +15 -0
- package/dist/eco/npm/bun/exec.js +35 -0
- package/dist/eco/npm/manifest-format.d.ts +11 -0
- package/dist/eco/npm/manifest-format.js +38 -0
- package/dist/eco/npm/npm/exec.d.ts +24 -0
- package/dist/eco/npm/npm/exec.js +64 -0
- package/dist/eco/npm/npm/extract-package-name-from-path.d.ts +9 -0
- package/dist/eco/npm/npm/extract-package-name-from-path.js +54 -0
- package/dist/eco/npm/npm/flags.d.ts +62 -0
- package/dist/eco/npm/npm/flags.js +63 -0
- package/dist/eco/npm/npm/lockfile-format.d.ts +9 -0
- package/dist/eco/npm/npm/lockfile-format.js +42 -0
- package/dist/eco/npm/npm/parse-git-url.d.ts +13 -0
- package/dist/eco/npm/npm/parse-git-url.js +43 -0
- package/dist/eco/npm/npm/parse-lockfile.d.ts +70 -0
- package/dist/eco/npm/npm/parse-lockfile.js +224 -0
- package/dist/eco/npm/parse-package-json.d.ts +16 -0
- package/dist/eco/npm/parse-package-json.js +115 -0
- package/dist/eco/npm/pnpm/detect-pnpm-version.d.ts +7 -0
- package/dist/eco/npm/pnpm/detect-pnpm-version.js +47 -0
- package/dist/eco/npm/pnpm/exec.d.ts +26 -0
- package/dist/eco/npm/pnpm/exec.js +65 -0
- package/dist/eco/npm/pnpm/flags.d.ts +44 -0
- package/dist/eco/npm/pnpm/flags.js +76 -0
- package/dist/eco/npm/pnpm/lockfile-format.d.ts +8 -0
- package/dist/eco/npm/pnpm/lockfile-format.js +39 -0
- package/dist/eco/npm/pnpm/parse-lockfile.d.ts +69 -0
- package/dist/eco/npm/pnpm/parse-lockfile.js +274 -0
- package/dist/eco/npm/pnpm/parse-pnpm-package-id-v5.d.ts +15 -0
- package/dist/eco/npm/pnpm/parse-pnpm-package-id-v5.js +50 -0
- package/dist/eco/npm/pnpm/parse-pnpm-package-id-v6-v9.d.ts +11 -0
- package/dist/eco/npm/pnpm/parse-pnpm-package-id-v6-v9.js +52 -0
- package/dist/eco/npm/script.d.ts +35 -0
- package/dist/eco/npm/script.js +93 -0
- package/dist/eco/npm/vlt/exec.d.ts +16 -0
- package/dist/eco/npm/vlt/exec.js +35 -0
- package/dist/eco/npm/yarnpkg/yarn/exec.d.ts +28 -0
- package/dist/eco/npm/yarnpkg/yarn/exec.js +63 -0
- package/dist/eco/npm/yarnpkg/yarn/lockfile-format.d.ts +9 -0
- package/dist/eco/npm/yarnpkg/yarn/lockfile-format.js +39 -0
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +61 -0
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +261 -0
- package/dist/eco/npm/yarnpkg/yarn/parse-yarn-descriptor.d.ts +16 -0
- package/dist/eco/npm/yarnpkg/yarn/parse-yarn-descriptor.js +68 -0
- package/dist/{types.d.ts → eco/purl.d.ts} +14 -26
- package/dist/{types.js → eco/purl.js} +3 -3
- package/dist/eco/types.d.ts +51 -0
- package/dist/eco/types.js +18 -0
- package/dist/effects/pulse-frames.d.ts +16 -17
- package/dist/effects/pulse-frames.js +4 -4
- package/dist/effects/shimmer-keyframes.d.ts +39 -37
- package/dist/effects/shimmer-terminal.d.ts +43 -42
- package/dist/effects/shimmer-terminal.js +3 -3
- package/dist/effects/shimmer.d.ts +172 -153
- package/dist/effects/shimmer.js +78 -76
- package/dist/env/boolean.d.ts +33 -0
- package/dist/env/boolean.js +46 -0
- package/dist/env/case-insensitive.d.ts +42 -0
- package/dist/env/case-insensitive.js +42 -0
- package/dist/env/ci.d.ts +11 -12
- package/dist/env/debug.d.ts +10 -10
- package/dist/env/github.d.ts +71 -74
- package/dist/env/home.d.ts +15 -14
- package/dist/env/locale.d.ts +26 -29
- package/dist/env/node-auth-token.d.ts +10 -10
- package/dist/env/node-env.d.ts +10 -10
- package/dist/env/npm.d.ts +45 -47
- package/dist/env/number.d.ts +29 -0
- package/dist/env/number.js +54 -0
- package/dist/env/package-manager.d.ts +36 -33
- package/dist/env/package-manager.js +3 -3
- package/dist/env/path.d.ts +10 -10
- package/dist/env/pre-commit.d.ts +11 -11
- package/dist/env/pre-commit.js +2 -2
- package/dist/env/proxy.d.ts +44 -0
- package/dist/env/proxy.js +126 -0
- package/dist/env/rewire.d.ts +105 -99
- package/dist/env/rewire.js +11 -8
- package/dist/env/shell.d.ts +10 -10
- package/dist/env/socket-cli.d.ts +109 -125
- package/dist/env/socket-cli.js +7 -12
- package/dist/env/socket.d.ts +347 -130
- package/dist/env/socket.js +107 -8
- package/dist/env/string.d.ts +28 -0
- package/dist/env/string.js +47 -0
- package/dist/env/temp-dir.d.ts +26 -29
- package/dist/env/term.d.ts +10 -10
- package/dist/env/test.d.ts +29 -31
- package/dist/env/test.js +5 -4
- package/dist/env/types.d.ts +62 -0
- package/dist/env/types.js +18 -0
- package/dist/env/windows.d.ts +37 -38
- package/dist/env/xdg.d.ts +29 -29
- package/dist/errors/message.d.ts +27 -0
- package/dist/errors/message.js +49 -0
- package/dist/errors/predicates.d.ts +46 -0
- package/dist/{errors.js → errors/predicates.js} +13 -43
- package/dist/errors/stack.d.ts +16 -0
- package/dist/errors/stack.js +39 -0
- package/dist/external/@npmcli/package-json/lib/read-package.js +11 -1
- package/dist/external/@npmcli/package-json.js +300 -82
- package/dist/external/@npmcli/promise-spawn.js +15 -1
- package/dist/external/@socketregistry/packageurl-js.js +7 -1
- package/dist/external/@socketregistry/yocto-spinner.js +5 -1
- package/dist/external/@yarnpkg/extensions.js +1 -1
- package/dist/external/adm-zip.js +20 -4
- package/dist/external/debug.js +15 -1
- package/dist/external/external-pack.js +20 -4
- package/dist/external/fast-sort.js +3 -1
- package/dist/external/get-east-asian-width.js +3 -1
- package/dist/external/libnpmexec.js +5 -1
- package/dist/external/npm-pack.js +344 -113
- package/dist/external/p-map.js +7 -1
- package/dist/external/pico-pack.js +17 -1
- package/dist/external/pony-cause.js +1 -1
- package/dist/external/spdx-pack.js +3 -1
- package/dist/external/supports-color.js +1 -1
- package/dist/external/tar-fs.js +15 -1
- package/dist/external/which.js +11 -1
- package/dist/external/yargs-parser.js +15 -1
- package/dist/external-tools/bazel/asset-names.d.ts +66 -0
- package/dist/external-tools/bazel/asset-names.js +96 -0
- package/dist/external-tools/bazel/from-download.d.ts +49 -0
- package/dist/external-tools/bazel/from-download.js +49 -0
- package/dist/external-tools/bazel/from-path.d.ts +8 -0
- package/dist/external-tools/bazel/from-path.js +41 -0
- package/dist/external-tools/bazel/read-bazel-version-file.d.ts +12 -0
- package/dist/external-tools/bazel/read-bazel-version-file.js +61 -0
- package/dist/external-tools/bazel/resolve-asset-url.d.ts +14 -0
- package/dist/external-tools/bazel/resolve-asset-url.js +42 -0
- package/dist/external-tools/bazel/resolve-bazel-version.d.ts +19 -0
- package/dist/external-tools/bazel/resolve-bazel-version.js +59 -0
- package/dist/external-tools/bazel/resolve.d.ts +35 -0
- package/dist/external-tools/bazel/resolve.js +68 -0
- package/dist/external-tools/bazel/types.d.ts +22 -0
- package/dist/external-tools/bazel/types.js +18 -0
- package/dist/external-tools/cdxgen/asset-names.d.ts +58 -0
- package/dist/external-tools/cdxgen/asset-names.js +79 -0
- package/dist/external-tools/cdxgen/from-download.d.ts +43 -0
- package/dist/external-tools/cdxgen/from-download.js +83 -0
- package/dist/external-tools/cdxgen/from-path.d.ts +5 -0
- package/dist/external-tools/cdxgen/from-path.js +40 -0
- package/dist/external-tools/cdxgen/from-vfs.d.ts +7 -0
- package/dist/external-tools/cdxgen/from-vfs.js +47 -0
- package/dist/external-tools/cdxgen/resolve.d.ts +32 -0
- package/dist/external-tools/cdxgen/resolve.js +73 -0
- package/dist/external-tools/cdxgen/types.d.ts +33 -0
- package/dist/external-tools/cdxgen/types.js +18 -0
- package/dist/external-tools/from-download.d.ts +162 -0
- package/dist/external-tools/from-download.js +72 -0
- package/dist/external-tools/janus/asset-names.d.ts +36 -0
- package/dist/external-tools/janus/asset-names.js +52 -0
- package/dist/external-tools/janus/from-download.d.ts +26 -0
- package/dist/external-tools/janus/from-download.js +65 -0
- package/dist/external-tools/janus/from-path.d.ts +5 -0
- package/dist/external-tools/janus/from-path.js +40 -0
- package/dist/external-tools/janus/from-vfs.d.ts +7 -0
- package/dist/external-tools/janus/from-vfs.js +47 -0
- package/dist/external-tools/janus/resolve.d.ts +28 -0
- package/dist/external-tools/janus/resolve.js +73 -0
- package/dist/external-tools/janus/types.d.ts +24 -0
- package/dist/external-tools/janus/types.js +18 -0
- package/dist/external-tools/jre/asset-names.d.ts +91 -0
- package/dist/external-tools/jre/asset-names.js +88 -0
- package/dist/external-tools/jre/detect-platform-arch.d.ts +8 -0
- package/dist/external-tools/jre/detect-platform-arch.js +52 -0
- package/dist/external-tools/jre/from-download.d.ts +62 -0
- package/dist/external-tools/jre/from-download.js +70 -0
- package/dist/external-tools/jre/from-java-home.d.ts +10 -0
- package/dist/external-tools/jre/from-java-home.js +57 -0
- package/dist/external-tools/jre/from-path.d.ts +9 -0
- package/dist/external-tools/jre/from-path.js +52 -0
- package/dist/external-tools/jre/from-vfs.d.ts +17 -0
- package/dist/external-tools/jre/from-vfs.js +64 -0
- package/dist/external-tools/jre/resolve.d.ts +40 -0
- package/dist/external-tools/jre/resolve.js +78 -0
- package/dist/external-tools/jre/types.d.ts +28 -0
- package/dist/external-tools/jre/types.js +18 -0
- package/dist/external-tools/manifest.d.ts +105 -0
- package/dist/external-tools/manifest.js +167 -0
- package/dist/external-tools/opengrep/asset-names.d.ts +44 -0
- package/dist/external-tools/opengrep/asset-names.js +78 -0
- package/dist/external-tools/opengrep/from-download.d.ts +17 -0
- package/dist/external-tools/opengrep/from-download.js +83 -0
- package/dist/external-tools/opengrep/from-path.d.ts +5 -0
- package/dist/external-tools/opengrep/from-path.js +40 -0
- package/dist/external-tools/opengrep/from-vfs.d.ts +8 -0
- package/dist/external-tools/opengrep/from-vfs.js +47 -0
- package/dist/external-tools/opengrep/resolve.d.ts +26 -0
- package/dist/external-tools/opengrep/resolve.js +73 -0
- package/dist/external-tools/opengrep/types.d.ts +24 -0
- package/dist/external-tools/opengrep/types.js +18 -0
- package/dist/external-tools/sbt/asset-names.d.ts +31 -0
- package/dist/external-tools/sbt/asset-names.js +33 -0
- package/dist/external-tools/sbt/from-download.d.ts +44 -0
- package/dist/external-tools/sbt/from-download.js +64 -0
- package/dist/external-tools/sbt/from-path.d.ts +8 -0
- package/dist/external-tools/sbt/from-path.js +41 -0
- package/dist/external-tools/sbt/from-vfs.d.ts +14 -0
- package/dist/external-tools/sbt/from-vfs.js +48 -0
- package/dist/external-tools/sbt/resolve.d.ts +31 -0
- package/dist/external-tools/sbt/resolve.js +73 -0
- package/dist/external-tools/sbt/types.d.ts +32 -0
- package/dist/external-tools/sbt/types.js +18 -0
- package/dist/external-tools/synp/asset-names.d.ts +14 -0
- package/dist/external-tools/synp/asset-names.js +32 -0
- package/dist/external-tools/synp/from-download.d.ts +18 -0
- package/dist/external-tools/synp/from-download.js +44 -0
- package/dist/external-tools/synp/from-path.d.ts +5 -0
- package/dist/external-tools/synp/from-path.js +40 -0
- package/dist/external-tools/synp/from-vfs.d.ts +7 -0
- package/dist/external-tools/synp/from-vfs.js +47 -0
- package/dist/external-tools/synp/resolve.d.ts +21 -0
- package/dist/external-tools/synp/resolve.js +72 -0
- package/dist/external-tools/synp/types.d.ts +19 -0
- package/dist/external-tools/synp/types.js +18 -0
- package/dist/external-tools/trivy/asset-names.d.ts +34 -0
- package/dist/external-tools/trivy/asset-names.js +68 -0
- package/dist/external-tools/trivy/from-download.d.ts +17 -0
- package/dist/external-tools/trivy/from-download.js +67 -0
- package/dist/external-tools/trivy/from-path.d.ts +5 -0
- package/dist/external-tools/trivy/from-path.js +40 -0
- package/dist/external-tools/trivy/from-vfs.d.ts +7 -0
- package/dist/external-tools/trivy/from-vfs.js +47 -0
- package/dist/external-tools/trivy/resolve.d.ts +26 -0
- package/dist/external-tools/trivy/resolve.js +73 -0
- package/dist/external-tools/trivy/types.d.ts +24 -0
- package/dist/external-tools/trivy/types.js +18 -0
- package/dist/external-tools/trufflehog/asset-names.d.ts +34 -0
- package/dist/external-tools/trufflehog/asset-names.js +72 -0
- package/dist/external-tools/trufflehog/from-download.d.ts +37 -0
- package/dist/external-tools/trufflehog/from-download.js +65 -0
- package/dist/external-tools/trufflehog/from-path.d.ts +7 -0
- package/dist/external-tools/trufflehog/from-path.js +40 -0
- package/dist/external-tools/trufflehog/from-vfs.d.ts +11 -0
- package/dist/external-tools/trufflehog/from-vfs.js +47 -0
- package/dist/external-tools/trufflehog/resolve.d.ts +30 -0
- package/dist/external-tools/trufflehog/resolve.js +73 -0
- package/dist/external-tools/trufflehog/types.d.ts +25 -0
- package/dist/external-tools/trufflehog/types.js +18 -0
- package/dist/external-tools/uv/asset-names.d.ts +36 -0
- package/dist/external-tools/uv/asset-names.js +80 -0
- package/dist/external-tools/uv/from-download.d.ts +17 -0
- package/dist/external-tools/uv/from-download.js +68 -0
- package/dist/external-tools/uv/from-path.d.ts +5 -0
- package/dist/external-tools/uv/from-path.js +40 -0
- package/dist/external-tools/uv/from-vfs.d.ts +7 -0
- package/dist/external-tools/uv/from-vfs.js +47 -0
- package/dist/external-tools/uv/resolve.d.ts +25 -0
- package/dist/external-tools/uv/resolve.js +73 -0
- package/dist/external-tools/uv/types.d.ts +24 -0
- package/dist/external-tools/uv/types.js +18 -0
- package/dist/fs/_internal.d.ts +22 -0
- package/dist/fs/_internal.js +48 -0
- package/dist/fs/encoding.d.ts +49 -0
- package/dist/fs/encoding.js +102 -0
- package/dist/fs/find-up.d.ts +58 -0
- package/dist/fs/find-up.js +152 -0
- package/dist/fs/inspect.d.ts +117 -0
- package/dist/fs/inspect.js +112 -0
- package/dist/fs/path-cache.d.ts +21 -0
- package/dist/fs/path-cache.js +35 -0
- package/dist/fs/read-dir.d.ts +66 -0
- package/dist/fs/read-dir.js +86 -0
- package/dist/fs/read-file.d.ts +150 -0
- package/dist/fs/read-file.js +131 -0
- package/dist/fs/read-json.d.ts +72 -0
- package/dist/fs/read-json.js +120 -0
- package/dist/fs/safe.d.ts +153 -0
- package/dist/fs/safe.js +182 -0
- package/dist/fs/types.d.ts +277 -0
- package/dist/fs/types.js +18 -0
- package/dist/fs/unique.d.ts +29 -0
- package/dist/fs/unique.js +51 -0
- package/dist/fs/validate.d.ts +40 -0
- package/dist/fs/validate.js +46 -0
- package/dist/fs/write-json.d.ts +78 -0
- package/dist/fs/write-json.js +83 -0
- package/dist/git/_internal.d.ts +105 -0
- package/dist/git/_internal.js +236 -0
- package/dist/git/changed.d.ts +145 -0
- package/dist/git/changed.js +83 -0
- package/dist/git/repo.d.ts +62 -0
- package/dist/git/repo.js +111 -0
- package/dist/git/staged.d.ts +138 -0
- package/dist/git/staged.js +71 -0
- package/dist/git/types.d.ts +109 -0
- package/dist/git/types.js +18 -0
- package/dist/git/unstaged.d.ts +141 -0
- package/dist/git/unstaged.js +71 -0
- package/dist/github/constants.d.ts +18 -0
- package/dist/github/constants.js +36 -0
- package/dist/github/errors.d.ts +36 -0
- package/dist/github/errors.js +40 -0
- package/dist/github/fetch.d.ts +89 -0
- package/dist/github/fetch.js +87 -0
- package/dist/github/ghsa.d.ts +118 -0
- package/dist/github/ghsa.js +178 -0
- package/dist/github/refs-cache.d.ts +40 -0
- package/dist/github/refs-cache.js +49 -0
- package/dist/github/refs-graphql.d.ts +42 -0
- package/dist/github/refs-graphql.js +109 -0
- package/dist/github/refs-rest.d.ts +23 -0
- package/dist/github/refs-rest.js +104 -0
- package/dist/github/refs.d.ts +84 -0
- package/dist/github/refs.js +67 -0
- package/dist/github/token.d.ts +77 -0
- package/dist/github/token.js +55 -0
- package/dist/github/types.d.ts +277 -0
- package/dist/github/types.js +18 -0
- package/dist/globs/_internal.d.ts +46 -0
- package/dist/globs/_internal.js +96 -0
- package/dist/globs/defaults.d.ts +7 -0
- package/dist/globs/defaults.js +61 -0
- package/dist/globs/glob.d.ts +59 -0
- package/dist/globs/glob.js +84 -0
- package/dist/globs/matcher.d.ts +46 -0
- package/dist/globs/matcher.js +99 -0
- package/dist/globs/stream.d.ts +18 -0
- package/dist/globs/stream.js +58 -0
- package/dist/globs/types.d.ts +35 -0
- package/dist/globs/types.js +18 -0
- package/dist/http-request/_internal.d.ts +18 -0
- package/dist/http-request/_internal.js +39 -0
- package/dist/http-request/checksums.d.ts +69 -0
- package/dist/http-request/checksums.js +72 -0
- package/dist/http-request/convenience.d.ts +104 -0
- package/dist/http-request/convenience.js +96 -0
- package/dist/http-request/download-types.d.ts +224 -0
- package/dist/http-request/download-types.js +18 -0
- package/dist/http-request/download.d.ts +71 -0
- package/dist/http-request/download.js +201 -0
- package/dist/http-request/errors.d.ts +23 -0
- package/dist/http-request/errors.js +50 -0
- package/dist/http-request/headers.d.ts +57 -0
- package/dist/http-request/headers.js +86 -0
- package/dist/http-request/request-attempt.d.ts +21 -0
- package/dist/http-request/request-attempt.js +284 -0
- package/dist/http-request/request-types.d.ts +238 -0
- package/dist/http-request/request-types.js +18 -0
- package/dist/http-request/request.d.ts +59 -0
- package/dist/http-request/request.js +106 -0
- package/dist/http-request/response-reader.d.ts +25 -0
- package/dist/http-request/response-reader.js +54 -0
- package/dist/http-request/response-types.d.ts +123 -0
- package/dist/http-request/response-types.js +40 -0
- package/dist/http-request/user-agent.d.ts +55 -0
- package/dist/http-request/user-agent.js +61 -0
- package/dist/{dlx/integrity.d.ts → integrity.d.ts} +36 -30
- package/dist/{dlx/integrity.js → integrity.js} +25 -19
- package/dist/ipc/_internal.d.ts +25 -0
- package/dist/ipc/_internal.js +50 -0
- package/dist/ipc/directory.d.ts +18 -0
- package/dist/ipc/directory.js +66 -0
- package/dist/ipc/paths.d.ts +37 -0
- package/dist/ipc/paths.js +48 -0
- package/dist/ipc/types.d.ts +22 -0
- package/dist/ipc/types.js +18 -0
- package/dist/ipc/write.d.ts +39 -0
- package/dist/ipc/write.js +77 -0
- package/dist/ipc-cli/get.d.ts +21 -0
- package/dist/{ipc-cli.js → ipc-cli/get.js} +5 -5
- package/dist/ipc-cli/types.d.ts +14 -0
- package/dist/ipc-cli/types.js +18 -0
- package/dist/json/edit.d.ts +22 -8
- package/dist/json/edit.js +85 -96
- package/dist/json/format.d.ts +100 -86
- package/dist/json/format.js +4 -3
- package/dist/json/parse.d.ts +113 -88
- package/dist/json/parse.js +30 -24
- package/dist/json/types.d.ts +133 -117
- package/dist/links/link.d.ts +65 -0
- package/dist/{links.js → links/link.js} +10 -10
- package/dist/links/types.d.ts +19 -0
- package/dist/links/types.js +18 -0
- package/dist/logger/_internal.d.ts +82 -0
- package/dist/logger/_internal.js +80 -0
- package/dist/logger/colors.d.ts +18 -0
- package/dist/logger/colors.js +54 -0
- package/dist/logger/console.d.ts +33 -0
- package/dist/logger/console.js +119 -0
- package/dist/logger/logger.d.ts +405 -0
- package/dist/logger/logger.js +854 -0
- package/dist/logger/symbols-builder.d.ts +29 -0
- package/dist/logger/symbols-builder.js +61 -0
- package/dist/logger/symbols.d.ts +61 -0
- package/dist/logger/symbols.js +129 -0
- package/dist/logger/types.d.ts +88 -0
- package/dist/logger/types.js +18 -0
- package/dist/memo/_internal.d.ts +16 -0
- package/dist/memo/_internal.js +53 -0
- package/dist/memo/async.d.ts +32 -0
- package/dist/memo/async.js +120 -0
- package/dist/memo/clear.d.ts +15 -0
- package/dist/memo/clear.js +37 -0
- package/dist/memo/decorator.d.ts +29 -0
- package/dist/memo/decorator.js +40 -0
- package/dist/memo/memoize.d.ts +33 -0
- package/dist/memo/memoize.js +91 -0
- package/dist/memo/once.d.ts +25 -0
- package/dist/memo/once.js +44 -0
- package/dist/memo/types.d.ts +43 -0
- package/dist/memo/types.js +18 -0
- package/dist/memo/weak.d.ts +26 -0
- package/dist/memo/weak.js +44 -0
- package/dist/node/async-hooks.d.ts +2 -2
- package/dist/node/child-process.d.ts +5 -7
- package/dist/node/crypto.d.ts +2 -2
- package/dist/node/events.d.ts +2 -2
- package/dist/node/fs-promises.d.ts +2 -2
- package/dist/node/fs.d.ts +6 -10
- package/dist/node/http.d.ts +2 -2
- package/dist/node/https.d.ts +2 -2
- package/dist/node/module.d.ts +7 -0
- package/dist/node/module.js +41 -0
- package/dist/node/os.d.ts +2 -2
- package/dist/node/path.d.ts +2 -2
- package/dist/node/timers-promises.d.ts +2 -2
- package/dist/node/url.d.ts +2 -2
- package/dist/node/util.d.ts +2 -2
- package/dist/objects/getters.d.ts +116 -0
- package/dist/objects/getters.js +137 -0
- package/dist/objects/inspect.d.ts +67 -0
- package/dist/objects/inspect.js +59 -0
- package/dist/objects/mutate.d.ts +72 -0
- package/dist/objects/mutate.js +81 -0
- package/dist/objects/predicates.d.ts +96 -0
- package/dist/objects/predicates.js +68 -0
- package/dist/objects/sort.d.ts +88 -0
- package/dist/objects/sort.js +85 -0
- package/dist/objects/types.d.ts +68 -0
- package/dist/objects/types.js +18 -0
- package/dist/packages/edit-class.d.ts +39 -0
- package/dist/packages/edit-class.js +269 -0
- package/dist/packages/edit.d.ts +60 -61
- package/dist/packages/edit.js +21 -286
- package/dist/packages/exports.d.ts +30 -28
- package/dist/packages/exports.js +38 -34
- package/dist/packages/isolation.d.ts +16 -7
- package/dist/packages/isolation.js +50 -57
- package/dist/packages/licenses.d.ts +49 -45
- package/dist/packages/licenses.js +13 -18
- package/dist/packages/manifest.d.ts +14 -14
- package/dist/packages/manifest.js +16 -15
- package/dist/packages/normalize.d.ts +17 -16
- package/dist/packages/normalize.js +20 -17
- package/dist/packages/operations.d.ts +49 -36
- package/dist/packages/operations.js +30 -15
- package/dist/packages/provenance.d.ts +22 -9
- package/dist/packages/provenance.js +76 -66
- package/dist/packages/specs.d.ts +21 -21
- package/dist/packages/specs.js +7 -7
- package/dist/{packages.d.ts → packages/types.d.ts} +12 -20
- package/dist/packages/types.js +18 -0
- package/dist/packages/validation.d.ts +13 -13
- package/dist/packages/validation.js +2 -2
- package/dist/paths/_internal.d.ts +51 -0
- package/dist/paths/_internal.js +102 -0
- package/dist/paths/conversion.d.ts +82 -0
- package/dist/paths/conversion.js +74 -0
- package/dist/paths/dirnames.d.ts +1 -1
- package/dist/paths/exts.d.ts +1 -1
- package/dist/paths/filenames.d.ts +1 -1
- package/dist/paths/globs.d.ts +1 -1
- package/dist/paths/normalize.d.ts +30 -440
- package/dist/paths/normalize.js +49 -289
- package/dist/paths/packages.d.ts +7 -1
- package/dist/paths/packages.js +7 -12
- package/dist/paths/predicates.d.ts +129 -0
- package/dist/paths/predicates.js +121 -0
- package/dist/paths/resolve.d.ts +71 -0
- package/dist/paths/resolve.js +135 -0
- package/dist/paths/rewire.d.ts +37 -38
- package/dist/paths/rewire.js +3 -3
- package/dist/paths/socket.d.ts +146 -47
- package/dist/paths/socket.js +23 -25
- package/dist/perf/_internal.d.ts +10 -0
- package/dist/perf/_internal.js +30 -0
- package/dist/perf/enabled.d.ts +13 -0
- package/dist/perf/enabled.js +33 -0
- package/dist/perf/metrics.d.ts +51 -0
- package/dist/perf/metrics.js +74 -0
- package/dist/perf/report.d.ts +40 -0
- package/dist/perf/report.js +85 -0
- package/dist/perf/timer.d.ts +100 -0
- package/dist/perf/timer.js +137 -0
- package/dist/perf/types.d.ts +15 -0
- package/dist/perf/types.js +18 -0
- package/dist/pkg-ext/data.d.ts +8 -0
- package/dist/{package-extensions.js → pkg-ext/data.js} +4 -4
- package/dist/pkg-ext/types.d.ts +6 -0
- package/dist/pkg-ext/types.js +18 -0
- package/dist/primordials/array.d.ts +73 -0
- package/dist/primordials/array.js +220 -0
- package/dist/primordials/buffer.d.ts +17 -0
- package/dist/primordials/buffer.js +61 -0
- package/dist/primordials/date.d.ts +16 -0
- package/dist/primordials/date.js +56 -0
- package/dist/primordials/error.d.ts +19 -0
- package/dist/primordials/error.js +75 -0
- package/dist/primordials/function.d.ts +10 -0
- package/dist/primordials/function.js +42 -0
- package/dist/primordials/globals.d.ts +17 -0
- package/dist/primordials/globals.js +54 -0
- package/dist/primordials/json.d.ts +11 -0
- package/dist/primordials/json.js +33 -0
- package/dist/primordials/map-set.d.ts +35 -0
- package/dist/primordials/map-set.js +115 -0
- package/dist/primordials/math.d.ts +51 -0
- package/dist/primordials/math.js +161 -0
- package/dist/primordials/number.d.ts +25 -0
- package/dist/primordials/number.js +92 -0
- package/dist/primordials/object.d.ts +74 -0
- package/dist/primordials/object.js +142 -0
- package/dist/primordials/promise.d.ts +34 -0
- package/dist/primordials/promise.js +61 -0
- package/dist/primordials/reflect.d.ts +18 -0
- package/dist/primordials/reflect.js +66 -0
- package/dist/primordials/regexp.d.ts +14 -0
- package/dist/primordials/regexp.js +50 -0
- package/dist/primordials/string.d.ts +71 -0
- package/dist/primordials/string.js +174 -0
- package/dist/primordials/symbol.d.ts +28 -0
- package/dist/primordials/symbol.js +94 -0
- package/dist/primordials/uncurry.d.ts +18 -0
- package/dist/primordials/uncurry.js +65 -0
- package/dist/primordials/url.d.ts +13 -0
- package/dist/primordials/url.js +69 -0
- package/dist/process/_internal.d.ts +8 -0
- package/dist/process/_internal.js +33 -0
- package/dist/process/abort.d.ts +20 -0
- package/dist/{constants/process.js → process/abort.js} +3 -3
- package/dist/process/lock-instance.d.ts +19 -0
- package/dist/process/lock-instance.js +31 -0
- package/dist/process/lock-manager.d.ts +152 -0
- package/dist/{process-lock.js → process/lock-manager.js} +97 -105
- package/dist/process/lock-types.d.ts +43 -0
- package/dist/process/lock-types.js +18 -0
- package/dist/process/transient.d.ts +22 -0
- package/dist/{temporary-executor.js → process/transient.js} +8 -8
- package/dist/promise-queue/queue.d.ts +51 -0
- package/dist/{promise-queue.js → promise-queue/queue.js} +27 -22
- package/dist/promise-queue/types.d.ts +10 -0
- package/dist/promise-queue/types.js +18 -0
- package/dist/promises/_internal.d.ts +15 -0
- package/dist/promises/_internal.js +41 -0
- package/dist/promises/iterate.d.ts +190 -0
- package/dist/promises/iterate.js +111 -0
- package/dist/promises/options.d.ts +76 -0
- package/dist/promises/options.js +108 -0
- package/dist/promises/resolvers.d.ts +55 -0
- package/dist/promises/resolvers.js +49 -0
- package/dist/promises/retry.d.ts +105 -0
- package/dist/promises/retry.js +104 -0
- package/dist/promises/types.d.ts +190 -0
- package/dist/promises/types.js +18 -0
- package/dist/regexps/escape.d.ts +6 -0
- package/dist/regexps/escape.js +32 -0
- package/dist/regexps/hex.d.ts +7 -0
- package/dist/regexps/hex.js +38 -0
- package/dist/regexps/spec.d.ts +15 -0
- package/dist/{regexps.js → regexps/spec.js} +32 -36
- package/dist/releases/github-archives.d.ts +47 -36
- package/dist/releases/github-archives.js +21 -35
- package/dist/releases/github-asset-url.d.ts +72 -0
- package/dist/releases/github-asset-url.js +167 -0
- package/dist/releases/github-assets.d.ts +13 -11
- package/dist/releases/github-assets.js +2 -2
- package/dist/releases/github-auth.d.ts +9 -9
- package/dist/releases/github-downloads.d.ts +31 -26
- package/dist/releases/github-downloads.js +22 -34
- package/dist/releases/github-listing.d.ts +105 -0
- package/dist/releases/github-listing.js +171 -0
- package/dist/releases/github-types.d.ts +45 -19
- package/dist/releases/socket-btm.d.ts +149 -99
- package/dist/releases/socket-btm.js +14 -20
- package/dist/schema/parse.d.ts +14 -15
- package/dist/schema/parse.js +2 -2
- package/dist/schema/types.d.ts +49 -37
- package/dist/schema/validate.d.ts +42 -19
- package/dist/schema/validate.js +15 -6
- package/dist/sea/detect.d.ts +37 -0
- package/dist/sea/{util.js → detect.js} +6 -6
- package/dist/secrets/_internal.d.ts +57 -0
- package/dist/secrets/_internal.js +84 -0
- package/dist/secrets/find.d.ts +79 -0
- package/dist/secrets/find.js +84 -0
- package/dist/secrets/keychain.d.ts +138 -0
- package/dist/secrets/keychain.js +328 -0
- package/dist/secrets/linux.d.ts +20 -0
- package/dist/secrets/linux.js +151 -0
- package/dist/secrets/macos.d.ts +36 -0
- package/dist/secrets/macos.js +165 -0
- package/dist/secrets/rc.d.ts +139 -0
- package/dist/secrets/rc.js +196 -0
- package/dist/secrets/socket-api-token.d.ts +23 -0
- package/dist/secrets/socket-api-token.js +50 -0
- package/dist/secrets/types.d.ts +69 -0
- package/dist/secrets/types.js +18 -0
- package/dist/secrets/windows.d.ts +50 -0
- package/dist/secrets/windows.js +318 -0
- package/dist/shadow/skip.d.ts +25 -0
- package/dist/{shadow.js → shadow/skip.js} +4 -4
- package/dist/shadow/types.d.ts +8 -0
- package/dist/shadow/types.js +18 -0
- package/dist/signal-exit/_internal.d.ts +68 -0
- package/dist/signal-exit/_internal.js +127 -0
- package/dist/signal-exit/intercept.d.ts +8 -0
- package/dist/signal-exit/intercept.js +75 -0
- package/dist/signal-exit/lifecycle.d.ts +28 -0
- package/dist/signal-exit/lifecycle.js +109 -0
- package/dist/signal-exit/register.d.ts +20 -0
- package/dist/signal-exit/register.js +58 -0
- package/dist/signal-exit/signals.d.ts +16 -0
- package/dist/signal-exit/signals.js +34 -0
- package/dist/signal-exit/types.d.ts +21 -0
- package/dist/signal-exit/types.js +18 -0
- package/dist/smol/detect.d.ts +80 -0
- package/dist/smol/{util.js → detect.js} +16 -24
- package/dist/smol/http.d.ts +60 -0
- package/dist/smol/http.js +42 -0
- package/dist/smol/https.d.ts +59 -0
- package/dist/smol/https.js +42 -0
- package/dist/smol/manifest.d.ts +140 -0
- package/dist/smol/manifest.js +42 -0
- package/dist/smol/primordial.d.ts +16 -21
- package/dist/smol/primordial.js +7 -11
- package/dist/smol/purl.d.ts +84 -0
- package/dist/smol/purl.js +42 -0
- package/dist/smol/versions.d.ts +11 -14
- package/dist/smol/versions.js +7 -11
- package/dist/smol/vfs.d.ts +99 -0
- package/dist/smol/vfs.js +43 -0
- package/dist/sorts/_internal.d.ts +9 -0
- package/dist/sorts/_internal.js +47 -0
- package/dist/sorts/natural.d.ts +39 -0
- package/dist/{sorts.js → sorts/natural.js} +5 -42
- package/dist/sorts/semver.d.ts +15 -0
- package/dist/sorts/semver.js +46 -0
- package/dist/sorts/strings.d.ts +16 -0
- package/dist/sorts/strings.js +33 -0
- package/dist/sorts/types.d.ts +7 -0
- package/dist/sorts/types.js +18 -0
- package/dist/spawn/_internal.d.ts +24 -0
- package/dist/spawn/_internal.js +62 -0
- package/dist/spawn/errors.d.ts +45 -0
- package/dist/spawn/errors.js +118 -0
- package/dist/spawn/spawn.d.ts +134 -0
- package/dist/{spawn.js → spawn/spawn.js} +29 -147
- package/dist/spawn/stdio.d.ts +37 -0
- package/dist/spawn/stdio.js +38 -0
- package/dist/spawn/types.d.ts +325 -0
- package/dist/spawn/types.js +18 -0
- package/dist/spinner/format.d.ts +64 -0
- package/dist/spinner/format.js +83 -0
- package/dist/spinner/registry.d.ts +49 -0
- package/dist/spinner/registry.js +70 -0
- package/dist/spinner/spinner.d.ts +40 -0
- package/dist/spinner/spinner.js +802 -0
- package/dist/spinner/types.d.ts +368 -0
- package/dist/spinner/types.js +18 -0
- package/dist/spinner/with.d.ts +125 -0
- package/dist/spinner/with.js +144 -0
- package/dist/ssri/convert.d.ts +48 -0
- package/dist/{ssri.js → ssri/convert.js} +11 -34
- package/dist/ssri/parse.d.ts +27 -0
- package/dist/ssri/parse.js +40 -0
- package/dist/ssri/validate.d.ts +41 -0
- package/dist/ssri/validate.js +39 -0
- package/dist/stdio/{_stream.d.ts → _internal.d.ts} +10 -5
- package/dist/stdio/{_stream.js → _internal.js} +3 -3
- package/dist/stdio/clear.d.ts +98 -84
- package/dist/stdio/divider.d.ts +100 -78
- package/dist/stdio/divider.js +36 -14
- package/dist/stdio/footer.d.ts +75 -51
- package/dist/stdio/footer.js +28 -18
- package/dist/stdio/header.d.ts +61 -50
- package/dist/stdio/header.js +15 -13
- package/dist/stdio/progress.d.ts +67 -57
- package/dist/stdio/progress.js +55 -51
- package/dist/stdio/prompts.d.ts +147 -100
- package/dist/stdio/prompts.js +23 -15
- package/dist/stdio/stderr.d.ts +86 -84
- package/dist/stdio/stderr.js +6 -6
- package/dist/stdio/stdout.d.ts +77 -78
- package/dist/stdio/stdout.js +6 -6
- package/dist/streams/parallel.d.ts +40 -0
- package/dist/{streams.js → streams/parallel.js} +10 -27
- package/dist/streams/transform.d.ts +20 -0
- package/dist/streams/transform.js +48 -0
- package/dist/strings/format.d.ts +115 -0
- package/dist/strings/format.js +73 -0
- package/dist/strings/predicates.d.ts +52 -0
- package/dist/strings/predicates.js +39 -0
- package/dist/strings/search.d.ts +34 -0
- package/dist/strings/search.js +45 -0
- package/dist/strings/transform.d.ts +80 -0
- package/dist/strings/transform.js +79 -0
- package/dist/strings/types.d.ts +38 -0
- package/dist/strings/types.js +18 -0
- package/dist/strings/width.d.ts +42 -0
- package/dist/strings/width.js +95 -0
- package/dist/tables/bordered.d.ts +44 -0
- package/dist/tables/bordered.js +84 -0
- package/dist/tables/padding.d.ts +18 -0
- package/dist/tables/padding.js +51 -0
- package/dist/tables/simple.d.ts +36 -0
- package/dist/tables/simple.js +73 -0
- package/dist/tables/types.d.ts +15 -0
- package/dist/tables/types.js +18 -0
- package/dist/temporal/instant.d.ts +39 -0
- package/dist/temporal/instant.js +91 -0
- package/dist/temporal/now.d.ts +24 -0
- package/dist/temporal/now.js +34 -0
- package/dist/temporal/slots.d.ts +32 -0
- package/dist/temporal/slots.js +45 -0
- package/dist/temporal/system.d.ts +20 -0
- package/dist/temporal/system.js +42 -0
- package/dist/temporal/temporal.d.ts +22 -0
- package/dist/temporal/temporal.js +43 -0
- package/dist/themes/context.d.ts +65 -48
- package/dist/themes/context.js +6 -2
- package/dist/themes/resolve.d.ts +90 -0
- package/dist/themes/{utils.js → resolve.js} +6 -6
- package/dist/themes/themes.d.ts +14 -16
- package/dist/themes/types.d.ts +93 -35
- package/dist/ttl-cache/cache.d.ts +29 -0
- package/dist/{cache-with-ttl.js → ttl-cache/cache.js} +45 -37
- package/dist/ttl-cache/types.d.ts +109 -0
- package/dist/ttl-cache/types.js +18 -0
- package/dist/url/parse.d.ts +26 -0
- package/dist/url/parse.js +57 -0
- package/dist/url/predicates.d.ts +15 -0
- package/dist/url/predicates.js +34 -0
- package/dist/url/search-params.d.ts +71 -0
- package/dist/{url.js → url/search-params.js} +19 -54
- package/dist/url/types.d.ts +20 -0
- package/dist/url/types.js +18 -0
- package/dist/versions/_internal.d.ts +24 -0
- package/dist/versions/_internal.js +37 -0
- package/dist/versions/compare.d.ts +57 -0
- package/dist/versions/compare.js +65 -0
- package/dist/versions/modify.d.ts +28 -0
- package/dist/versions/modify.js +44 -0
- package/dist/versions/parse.d.ts +67 -0
- package/dist/versions/parse.js +77 -0
- package/dist/versions/range.d.ts +45 -0
- package/dist/versions/range.js +50 -0
- package/dist/versions/types.d.ts +13 -0
- package/dist/versions/types.js +18 -0
- package/dist/warnings/event-target.d.ts +31 -0
- package/dist/warnings/event-target.js +43 -0
- package/dist/warnings/suppress.d.ts +65 -0
- package/dist/{suppress-warnings.js → warnings/suppress.js} +16 -28
- package/dist/words/article.d.ts +14 -0
- package/dist/words/article.js +33 -0
- package/dist/words/capitalize.d.ts +15 -0
- package/dist/{words.js → words/capitalize.js} +5 -18
- package/dist/words/pluralize.d.ts +16 -0
- package/dist/words/pluralize.js +34 -0
- package/dist/words/types.d.ts +7 -0
- package/dist/words/types.js +18 -0
- package/package.json +1939 -244
- package/dist/abort.d.ts +0 -27
- package/dist/agent.d.ts +0 -196
- package/dist/agent.js +0 -287
- package/dist/ansi.d.ts +0 -39
- package/dist/archives.d.ts +0 -95
- package/dist/archives.js +0 -408
- package/dist/argv/flags.d.ts +0 -292
- package/dist/argv/flags.js +0 -297
- package/dist/arrays.d.ts +0 -168
- package/dist/bin.d.ts +0 -181
- package/dist/bin.js +0 -544
- package/dist/cacache.d.ts +0 -130
- package/dist/cacache.js +0 -156
- package/dist/cache-with-ttl.d.ts +0 -165
- package/dist/colors.d.ts +0 -49
- package/dist/constants/process.d.ts +0 -20
- package/dist/crypto.d.ts +0 -36
- package/dist/debug.js +0 -337
- package/dist/env/helpers.d.ts +0 -66
- package/dist/env.d.ts +0 -182
- package/dist/env.js +0 -205
- package/dist/errors.d.ts +0 -100
- package/dist/fs.d.ts +0 -916
- package/dist/fs.js +0 -808
- package/dist/git.d.ts +0 -546
- package/dist/git.js +0 -409
- package/dist/github.d.ts +0 -526
- package/dist/github.js +0 -448
- package/dist/globs.d.ts +0 -119
- package/dist/globs.js +0 -282
- package/dist/http-request.d.ts +0 -951
- package/dist/http-request.js +0 -761
- package/dist/ipc-cli.d.ts +0 -28
- package/dist/ipc.d.ts +0 -76
- package/dist/ipc.js +0 -130
- package/dist/links.d.ts +0 -69
- package/dist/logger.d.ts +0 -993
- package/dist/logger.js +0 -1498
- package/dist/memoization.d.ts +0 -131
- package/dist/memoization.js +0 -243
- package/dist/objects.d.ts +0 -500
- package/dist/objects.js +0 -303
- package/dist/package-extensions.d.ts +0 -9
- package/dist/packages.js +0 -132
- package/dist/performance.d.ts +0 -181
- package/dist/performance.js +0 -233
- package/dist/primordials.d.ts +0 -420
- package/dist/primordials.js +0 -1116
- package/dist/process-lock.d.ts +0 -180
- package/dist/promise-queue.d.ts +0 -48
- package/dist/promises.d.ts +0 -506
- package/dist/promises.js +0 -292
- package/dist/regexps.d.ts +0 -6
- package/dist/releases/github-api.d.ts +0 -56
- package/dist/releases/github-api.js +0 -275
- package/dist/sea/util.d.ts +0 -43
- package/dist/shadow.d.ts +0 -28
- package/dist/signal-exit.d.ts +0 -50
- package/dist/signal-exit.js +0 -247
- package/dist/smol/util.d.ts +0 -87
- package/dist/sorts.d.ts +0 -59
- package/dist/spawn.d.ts +0 -454
- package/dist/spinner.d.ts +0 -444
- package/dist/spinner.js +0 -988
- package/dist/ssri.d.ts +0 -90
- package/dist/streams.d.ts +0 -45
- package/dist/strings.d.ts +0 -414
- package/dist/strings.js +0 -218
- package/dist/suppress-warnings.d.ts +0 -81
- package/dist/tables.d.ts +0 -73
- package/dist/tables.js +0 -133
- package/dist/temporary-executor.d.ts +0 -20
- package/dist/themes/utils.d.ts +0 -86
- package/dist/url.d.ts +0 -114
- package/dist/versions.d.ts +0 -207
- package/dist/versions.js +0 -181
- package/dist/words.d.ts +0 -39
package/dist/http-request.d.ts
DELETED
|
@@ -1,951 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview HTTP/HTTPS request utilities using Node.js built-in modules with retry logic, redirects, and download support.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a fetch-like API built on top of Node.js native `http` and `https` modules.
|
|
5
|
-
* It supports automatic retries with exponential backoff, redirect following, streaming downloads,
|
|
6
|
-
* and provides a familiar fetch-style response interface.
|
|
7
|
-
*
|
|
8
|
-
* Key Features:
|
|
9
|
-
* - Automatic retries with exponential backoff for failed requests.
|
|
10
|
-
* - Redirect following with configurable max redirects.
|
|
11
|
-
* - Streaming downloads with progress callbacks.
|
|
12
|
-
* - Fetch-like response interface (`.json()`, `.text()`, `.arrayBuffer()`).
|
|
13
|
-
* - Timeout support for all operations.
|
|
14
|
-
* - Zero dependencies on external HTTP libraries.
|
|
15
|
-
*/
|
|
16
|
-
import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
|
|
17
|
-
import type { Readable } from 'node:stream';
|
|
18
|
-
import type { Logger } from './logger';
|
|
19
|
-
/** IncomingMessage received as a response to a client request (http.request callback). */
|
|
20
|
-
export type IncomingResponse = IncomingMessage;
|
|
21
|
-
/** IncomingMessage received as a request in a server handler (http.createServer callback). */
|
|
22
|
-
export type IncomingRequest = IncomingMessage;
|
|
23
|
-
/**
|
|
24
|
-
* Information passed to the onRequest hook before each request attempt.
|
|
25
|
-
*/
|
|
26
|
-
export interface HttpHookRequestInfo {
|
|
27
|
-
headers: Record<string, string>;
|
|
28
|
-
method: string;
|
|
29
|
-
timeout: number;
|
|
30
|
-
url: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Information passed to the onResponse hook after each request attempt.
|
|
34
|
-
*/
|
|
35
|
-
export interface HttpHookResponseInfo {
|
|
36
|
-
duration: number;
|
|
37
|
-
error?: Error | undefined;
|
|
38
|
-
headers?: IncomingHttpHeaders | undefined;
|
|
39
|
-
method: string;
|
|
40
|
-
status?: number | undefined;
|
|
41
|
-
statusText?: string | undefined;
|
|
42
|
-
url: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Lifecycle hooks for observing HTTP request/response events.
|
|
46
|
-
* Hooks fire per-attempt (retries produce multiple hook calls).
|
|
47
|
-
*/
|
|
48
|
-
export interface HttpHooks {
|
|
49
|
-
onRequest?: ((info: HttpHookRequestInfo) => void) | undefined;
|
|
50
|
-
onResponse?: ((info: HttpHookResponseInfo) => void) | undefined;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Configuration options for HTTP/HTTPS requests.
|
|
54
|
-
*/
|
|
55
|
-
export interface HttpRequestOptions {
|
|
56
|
-
/**
|
|
57
|
-
* Request body to send.
|
|
58
|
-
* Can be a string, Buffer, or Readable stream.
|
|
59
|
-
*
|
|
60
|
-
* When a Readable stream is provided, it is piped directly to the request.
|
|
61
|
-
* If the stream has a `getHeaders()` method (duck-typed, e.g., the `form-data`
|
|
62
|
-
* npm package), its headers (Content-Type with boundary) are automatically
|
|
63
|
-
* merged into the request headers.
|
|
64
|
-
*
|
|
65
|
-
* **Note:** Streaming bodies are one-shot — they cannot be replayed. Using a
|
|
66
|
-
* Readable body with `retries > 0` throws an error. Buffer the body as a
|
|
67
|
-
* string/Buffer if retries are needed. Redirects are also disabled for
|
|
68
|
-
* streaming bodies since the stream is consumed on the first request.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* // Send JSON data
|
|
73
|
-
* await httpRequest('https://api.example.com/data', {
|
|
74
|
-
* method: 'POST',
|
|
75
|
-
* body: JSON.stringify({ name: 'Alice' }),
|
|
76
|
-
* headers: { 'Content-Type': 'application/json' }
|
|
77
|
-
* })
|
|
78
|
-
*
|
|
79
|
-
* // Send binary data
|
|
80
|
-
* const buffer = Buffer.from([0x00, 0x01, 0x02])
|
|
81
|
-
* await httpRequest('https://api.example.com/upload', {
|
|
82
|
-
* method: 'POST',
|
|
83
|
-
* body: buffer
|
|
84
|
-
* })
|
|
85
|
-
*
|
|
86
|
-
* // Stream form-data (npm package, not native FormData)
|
|
87
|
-
* import FormData from 'form-data'
|
|
88
|
-
* const form = new FormData()
|
|
89
|
-
* form.append('file', createReadStream('data.json'))
|
|
90
|
-
* await httpRequest('https://api.example.com/upload', {
|
|
91
|
-
* method: 'POST',
|
|
92
|
-
* body: form // auto-merges form.getHeaders()
|
|
93
|
-
* })
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
body?: Buffer | Readable | string | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Custom CA certificates for TLS connections.
|
|
99
|
-
* When provided, these certificates are combined with the default trust
|
|
100
|
-
* store via an HTTPS agent. Useful when SSL_CERT_FILE is set but
|
|
101
|
-
* NODE_EXTRA_CA_CERTS was not available at process startup.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* import { rootCertificates } from 'node:tls'
|
|
106
|
-
* import { readFileSync } from 'node:fs'
|
|
107
|
-
*
|
|
108
|
-
* const extraCerts = readFileSync('/path/to/cert.pem', 'utf-8')
|
|
109
|
-
* await httpRequest('https://api.example.com', {
|
|
110
|
-
* ca: [...rootCertificates, extraCerts]
|
|
111
|
-
* })
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
ca?: string[] | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Whether to automatically follow HTTP redirects (3xx status codes).
|
|
117
|
-
*
|
|
118
|
-
* @default true
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* // Follow redirects (default)
|
|
123
|
-
* await httpRequest('https://example.com/redirect')
|
|
124
|
-
*
|
|
125
|
-
* // Don't follow redirects
|
|
126
|
-
* const response = await httpRequest('https://example.com/redirect', {
|
|
127
|
-
* followRedirects: false
|
|
128
|
-
* })
|
|
129
|
-
* console.log(response.status) // 301 or 302
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
followRedirects?: boolean | undefined;
|
|
133
|
-
/**
|
|
134
|
-
* Lifecycle hooks for observing request/response events.
|
|
135
|
-
* Hooks fire per-attempt — retries and redirects each trigger separate hook calls.
|
|
136
|
-
*/
|
|
137
|
-
hooks?: HttpHooks | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* HTTP headers to send with the request.
|
|
140
|
-
* A `User-Agent` header is automatically added if not provided.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* await httpRequest('https://api.example.com/data', {
|
|
145
|
-
* headers: {
|
|
146
|
-
* 'Authorization': 'Bearer token123',
|
|
147
|
-
* 'Content-Type': 'application/json',
|
|
148
|
-
* 'Accept': 'application/json'
|
|
149
|
-
* }
|
|
150
|
-
* })
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
|
-
headers?: Record<string, string> | undefined;
|
|
154
|
-
/**
|
|
155
|
-
* Maximum number of redirects to follow before throwing an error.
|
|
156
|
-
* Only relevant when `followRedirects` is `true`.
|
|
157
|
-
*
|
|
158
|
-
* @default 5
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```ts
|
|
162
|
-
* // Allow up to 10 redirects
|
|
163
|
-
* await httpRequest('https://example.com/many-redirects', {
|
|
164
|
-
* maxRedirects: 10
|
|
165
|
-
* })
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
maxRedirects?: number | undefined;
|
|
169
|
-
/**
|
|
170
|
-
* Maximum response body size in bytes. Responses exceeding this limit
|
|
171
|
-
* will be rejected with an error. Prevents memory exhaustion from
|
|
172
|
-
* unexpectedly large responses.
|
|
173
|
-
*
|
|
174
|
-
* @default undefined (no limit)
|
|
175
|
-
*/
|
|
176
|
-
maxResponseSize?: number | undefined;
|
|
177
|
-
/**
|
|
178
|
-
* HTTP method to use for the request.
|
|
179
|
-
*
|
|
180
|
-
* @default 'GET'
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* // GET request (default)
|
|
185
|
-
* await httpRequest('https://api.example.com/data')
|
|
186
|
-
*
|
|
187
|
-
* // POST request
|
|
188
|
-
* await httpRequest('https://api.example.com/data', {
|
|
189
|
-
* method: 'POST',
|
|
190
|
-
* body: JSON.stringify({ name: 'Alice' })
|
|
191
|
-
* })
|
|
192
|
-
*
|
|
193
|
-
* // DELETE request
|
|
194
|
-
* await httpRequest('https://api.example.com/data/123', {
|
|
195
|
-
* method: 'DELETE'
|
|
196
|
-
* })
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
method?: string | undefined;
|
|
200
|
-
/**
|
|
201
|
-
* Callback invoked before each retry attempt.
|
|
202
|
-
* Allows customizing retry behavior per-attempt (e.g., skip 4xx, honor Retry-After).
|
|
203
|
-
*
|
|
204
|
-
* @param attempt - Current retry attempt number (1-based)
|
|
205
|
-
* @param error - The error that triggered the retry (HttpResponseError for HTTP errors)
|
|
206
|
-
* @param delay - The calculated delay in ms before next retry
|
|
207
|
-
* @returns `false` to stop retrying and rethrow,
|
|
208
|
-
* a `number` to override the delay (ms),
|
|
209
|
-
* or `undefined` to use the calculated delay
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```ts
|
|
213
|
-
* await httpRequest('https://api.example.com/data', {
|
|
214
|
-
* retries: 3,
|
|
215
|
-
* throwOnError: true,
|
|
216
|
-
* onRetry: (attempt, error, delay) => {
|
|
217
|
-
* // Don't retry client errors (except 429)
|
|
218
|
-
* if (error instanceof HttpResponseError) {
|
|
219
|
-
* if (error.response.status === 429) {
|
|
220
|
-
* const retryAfter = parseRetryAfterHeader(error.response.headers['retry-after'])
|
|
221
|
-
* return retryAfter ?? undefined
|
|
222
|
-
* }
|
|
223
|
-
* if (error.response.status >= 400 && error.response.status < 500) {
|
|
224
|
-
* return false
|
|
225
|
-
* }
|
|
226
|
-
* }
|
|
227
|
-
* }
|
|
228
|
-
* })
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
onRetry?: ((attempt: number, error: unknown, delay: number) => boolean | number | undefined) | undefined;
|
|
232
|
-
/**
|
|
233
|
-
* Number of retry attempts for failed requests.
|
|
234
|
-
* Uses exponential backoff: delay = `retryDelay` * 2^attempt.
|
|
235
|
-
*
|
|
236
|
-
* @default 0
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* ```ts
|
|
240
|
-
* // Retry up to 3 times with exponential backoff
|
|
241
|
-
* await httpRequest('https://api.example.com/data', {
|
|
242
|
-
* retries: 3,
|
|
243
|
-
* retryDelay: 1000 // 1s, then 2s, then 4s
|
|
244
|
-
* })
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
retries?: number | undefined;
|
|
248
|
-
/**
|
|
249
|
-
* Initial delay in milliseconds before first retry.
|
|
250
|
-
* Subsequent retries use exponential backoff.
|
|
251
|
-
*
|
|
252
|
-
* @default 1000
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* // Start with 2 second delay, then 4s, 8s, etc.
|
|
257
|
-
* await httpRequest('https://api.example.com/data', {
|
|
258
|
-
* retries: 3,
|
|
259
|
-
* retryDelay: 2000
|
|
260
|
-
* })
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
retryDelay?: number | undefined;
|
|
264
|
-
/**
|
|
265
|
-
* When true, non-2xx HTTP responses throw an `HttpResponseError` instead
|
|
266
|
-
* of resolving with `response.ok === false`. This makes HTTP error
|
|
267
|
-
* responses eligible for retry via the `retries` option.
|
|
268
|
-
*
|
|
269
|
-
* @default false
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* ```ts
|
|
273
|
-
* // Throw on 4xx/5xx responses (enabling retry for 5xx)
|
|
274
|
-
* await httpRequest('https://api.example.com/data', {
|
|
275
|
-
* throwOnError: true,
|
|
276
|
-
* retries: 3
|
|
277
|
-
* })
|
|
278
|
-
* ```
|
|
279
|
-
*/
|
|
280
|
-
/**
|
|
281
|
-
* When true, resolve with an HttpResponse whose body is NOT buffered.
|
|
282
|
-
* The `rawResponse` property contains the unconsumed IncomingResponse
|
|
283
|
-
* stream for piping to files or other destinations.
|
|
284
|
-
*
|
|
285
|
-
* `body`, `text()`, `json()`, and `arrayBuffer()` return empty/zero
|
|
286
|
-
* values since the stream has not been read.
|
|
287
|
-
*
|
|
288
|
-
* Incompatible with `maxResponseSize` (size enforcement requires
|
|
289
|
-
* reading the body).
|
|
290
|
-
*
|
|
291
|
-
* @default false
|
|
292
|
-
*/
|
|
293
|
-
stream?: boolean | undefined;
|
|
294
|
-
throwOnError?: boolean | undefined;
|
|
295
|
-
/**
|
|
296
|
-
* Request timeout in milliseconds.
|
|
297
|
-
* If the request takes longer than this, it will be aborted.
|
|
298
|
-
*
|
|
299
|
-
* @default 30000
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```ts
|
|
303
|
-
* // 60 second timeout
|
|
304
|
-
* await httpRequest('https://api.example.com/slow-endpoint', {
|
|
305
|
-
* timeout: 60000
|
|
306
|
-
* })
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
timeout?: number | undefined;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* HTTP response object with fetch-like interface.
|
|
313
|
-
* Provides multiple ways to access the response body.
|
|
314
|
-
*/
|
|
315
|
-
export interface HttpResponse {
|
|
316
|
-
/**
|
|
317
|
-
* Get response body as ArrayBuffer.
|
|
318
|
-
* Useful for binary data or when you need compatibility with browser APIs.
|
|
319
|
-
*
|
|
320
|
-
* @returns The response body as an ArrayBuffer
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```ts
|
|
324
|
-
* const response = await httpRequest('https://example.com/image.png')
|
|
325
|
-
* const arrayBuffer = response.arrayBuffer()
|
|
326
|
-
* console.log(arrayBuffer.byteLength)
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
arrayBuffer(): ArrayBuffer;
|
|
330
|
-
/**
|
|
331
|
-
* Raw response body as Buffer.
|
|
332
|
-
* Direct access to the underlying Node.js Buffer.
|
|
333
|
-
*
|
|
334
|
-
* @example
|
|
335
|
-
* ```ts
|
|
336
|
-
* const response = await httpRequest('https://example.com/data')
|
|
337
|
-
* console.log(response.body.length) // Size in bytes
|
|
338
|
-
* console.log(response.body.toString('hex')) // View as hex
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
body: Buffer;
|
|
342
|
-
/**
|
|
343
|
-
* HTTP response headers.
|
|
344
|
-
* Keys are lowercase header names, values can be strings or string arrays.
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
* ```ts
|
|
348
|
-
* const response = await httpRequest('https://example.com')
|
|
349
|
-
* console.log(response.headers['content-type'])
|
|
350
|
-
* console.log(response.headers['set-cookie']) // May be string[]
|
|
351
|
-
* ```
|
|
352
|
-
*/
|
|
353
|
-
headers: IncomingHttpHeaders;
|
|
354
|
-
/**
|
|
355
|
-
* Parse response body as JSON.
|
|
356
|
-
* Type parameter `T` allows specifying the expected JSON structure.
|
|
357
|
-
*
|
|
358
|
-
* @template T - Expected JSON type (defaults to `unknown`)
|
|
359
|
-
* @returns Parsed JSON data
|
|
360
|
-
* @throws {SyntaxError} When response body is not valid JSON
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```ts
|
|
364
|
-
* interface User { name: string; id: number }
|
|
365
|
-
* const response = await httpRequest('https://api.example.com/user')
|
|
366
|
-
* const user = response.json<User>()
|
|
367
|
-
* console.log(user.name, user.id)
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
|
-
json<T = unknown>(): T;
|
|
371
|
-
/**
|
|
372
|
-
* Whether the request was successful (status code 200-299).
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* ```ts
|
|
376
|
-
* const response = await httpRequest('https://example.com/data')
|
|
377
|
-
* if (response.ok) {
|
|
378
|
-
* console.log('Success:', response.json())
|
|
379
|
-
* } else {
|
|
380
|
-
* console.error('Failed:', response.status, response.statusText)
|
|
381
|
-
* }
|
|
382
|
-
* ```
|
|
383
|
-
*/
|
|
384
|
-
ok: boolean;
|
|
385
|
-
/**
|
|
386
|
-
* HTTP status code (e.g., 200, 404, 500).
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* ```ts
|
|
390
|
-
* const response = await httpRequest('https://example.com')
|
|
391
|
-
* console.log(response.status) // 200, 404, etc.
|
|
392
|
-
* ```
|
|
393
|
-
*/
|
|
394
|
-
status: number;
|
|
395
|
-
/**
|
|
396
|
-
* HTTP status message (e.g., "OK", "Not Found", "Internal Server Error").
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* ```ts
|
|
400
|
-
* const response = await httpRequest('https://example.com')
|
|
401
|
-
* console.log(response.statusText) // "OK"
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
statusText: string;
|
|
405
|
-
/**
|
|
406
|
-
* Get response body as UTF-8 text string.
|
|
407
|
-
*
|
|
408
|
-
* @returns The response body as a string
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* ```ts
|
|
412
|
-
* const response = await httpRequest('https://example.com')
|
|
413
|
-
* const html = response.text()
|
|
414
|
-
* console.log(html.includes('<html>'))
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
|
-
text(): string;
|
|
418
|
-
/**
|
|
419
|
-
* The underlying Node.js IncomingResponse for advanced use cases
|
|
420
|
-
* (e.g., streaming, custom header inspection). Only available when
|
|
421
|
-
* the response was not consumed by the convenience methods.
|
|
422
|
-
*/
|
|
423
|
-
rawResponse?: IncomingResponse | undefined;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Error thrown when an HTTP response has a non-2xx status code
|
|
427
|
-
* and `throwOnError` is enabled. Carries the full `HttpResponse`
|
|
428
|
-
* so callers can inspect status, headers, and body.
|
|
429
|
-
*/
|
|
430
|
-
export declare class HttpResponseError extends Error {
|
|
431
|
-
response: HttpResponse;
|
|
432
|
-
constructor(response: HttpResponse, message?: string | undefined);
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Configuration options for file downloads.
|
|
436
|
-
*/
|
|
437
|
-
export interface HttpDownloadOptions {
|
|
438
|
-
/**
|
|
439
|
-
* Custom CA certificates for TLS connections.
|
|
440
|
-
* When provided, these certificates are used for the download request.
|
|
441
|
-
* See `HttpRequestOptions.ca` for details.
|
|
442
|
-
*/
|
|
443
|
-
ca?: string[] | undefined;
|
|
444
|
-
/**
|
|
445
|
-
* Whether to automatically follow HTTP redirects (3xx status codes).
|
|
446
|
-
* This is essential for downloading from services that use CDN redirects,
|
|
447
|
-
* such as GitHub release assets which return HTTP 302 to their CDN.
|
|
448
|
-
*
|
|
449
|
-
* @default true
|
|
450
|
-
*
|
|
451
|
-
* @example
|
|
452
|
-
* ```ts
|
|
453
|
-
* // Follow redirects (default) - works with GitHub releases
|
|
454
|
-
* await httpDownload(
|
|
455
|
-
* 'https://github.com/org/repo/releases/download/v1.0.0/file.zip',
|
|
456
|
-
* '/tmp/file.zip'
|
|
457
|
-
* )
|
|
458
|
-
*
|
|
459
|
-
* // Don't follow redirects
|
|
460
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
461
|
-
* followRedirects: false
|
|
462
|
-
* })
|
|
463
|
-
* ```
|
|
464
|
-
*/
|
|
465
|
-
followRedirects?: boolean | undefined;
|
|
466
|
-
/**
|
|
467
|
-
* HTTP headers to send with the download request.
|
|
468
|
-
* A `User-Agent` header is automatically added if not provided.
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```ts
|
|
472
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
473
|
-
* headers: {
|
|
474
|
-
* 'Authorization': 'Bearer token123'
|
|
475
|
-
* }
|
|
476
|
-
* })
|
|
477
|
-
* ```
|
|
478
|
-
*/
|
|
479
|
-
headers?: Record<string, string> | undefined;
|
|
480
|
-
/**
|
|
481
|
-
* Logger instance for automatic progress logging.
|
|
482
|
-
* When provided with `progressInterval`, will automatically log download progress.
|
|
483
|
-
* If both `onProgress` and `logger` are provided, `onProgress` takes precedence.
|
|
484
|
-
*
|
|
485
|
-
* @example
|
|
486
|
-
* ```ts
|
|
487
|
-
* import { getDefaultLogger } from '@socketsecurity/lib/logger'
|
|
488
|
-
*
|
|
489
|
-
* const logger = getDefaultLogger()
|
|
490
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
491
|
-
* logger,
|
|
492
|
-
* progressInterval: 10 // Log every 10%
|
|
493
|
-
* })
|
|
494
|
-
* // Output:
|
|
495
|
-
* // Progress: 10% (5.2 MB / 52.0 MB)
|
|
496
|
-
* // Progress: 20% (10.4 MB / 52.0 MB)
|
|
497
|
-
* // ...
|
|
498
|
-
* ```
|
|
499
|
-
*/
|
|
500
|
-
logger?: Logger | undefined;
|
|
501
|
-
/**
|
|
502
|
-
* Maximum number of redirects to follow before throwing an error.
|
|
503
|
-
* Only relevant when `followRedirects` is `true`.
|
|
504
|
-
*
|
|
505
|
-
* @default 5
|
|
506
|
-
*
|
|
507
|
-
* @example
|
|
508
|
-
* ```ts
|
|
509
|
-
* // Allow up to 10 redirects
|
|
510
|
-
* await httpDownload('https://example.com/many-redirects/file.zip', '/tmp/file.zip', {
|
|
511
|
-
* maxRedirects: 10
|
|
512
|
-
* })
|
|
513
|
-
* ```
|
|
514
|
-
*/
|
|
515
|
-
maxRedirects?: number | undefined;
|
|
516
|
-
/**
|
|
517
|
-
* Callback for tracking download progress.
|
|
518
|
-
* Called periodically as data is received.
|
|
519
|
-
* Takes precedence over `logger` if both are provided.
|
|
520
|
-
*
|
|
521
|
-
* @param downloaded - Number of bytes downloaded so far
|
|
522
|
-
* @param total - Total file size in bytes (from Content-Length header)
|
|
523
|
-
*
|
|
524
|
-
* @example
|
|
525
|
-
* ```ts
|
|
526
|
-
* await httpDownload('https://example.com/large-file.zip', '/tmp/file.zip', {
|
|
527
|
-
* onProgress: (downloaded, total) => {
|
|
528
|
-
* const percent = ((downloaded / total) * 100).toFixed(1)
|
|
529
|
-
* console.log(`Progress: ${percent}%`)
|
|
530
|
-
* }
|
|
531
|
-
* })
|
|
532
|
-
* ```
|
|
533
|
-
*/
|
|
534
|
-
onProgress?: ((downloaded: number, total: number) => void) | undefined;
|
|
535
|
-
/**
|
|
536
|
-
* Progress reporting interval as a percentage (0-100).
|
|
537
|
-
* Only used when `logger` is provided.
|
|
538
|
-
* Progress will be logged each time the download advances by this percentage.
|
|
539
|
-
*
|
|
540
|
-
* @default 10
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* ```ts
|
|
544
|
-
* // Log every 10%
|
|
545
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
546
|
-
* logger: getDefaultLogger(),
|
|
547
|
-
* progressInterval: 10
|
|
548
|
-
* })
|
|
549
|
-
*
|
|
550
|
-
* // Log every 25%
|
|
551
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
552
|
-
* logger: getDefaultLogger(),
|
|
553
|
-
* progressInterval: 25
|
|
554
|
-
* })
|
|
555
|
-
* ```
|
|
556
|
-
*/
|
|
557
|
-
progressInterval?: number | undefined;
|
|
558
|
-
/**
|
|
559
|
-
* Number of retry attempts for failed downloads.
|
|
560
|
-
* Uses exponential backoff: delay = `retryDelay` * 2^attempt.
|
|
561
|
-
*
|
|
562
|
-
* @default 0
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* ```ts
|
|
566
|
-
* // Retry up to 3 times for unreliable connections
|
|
567
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
568
|
-
* retries: 3,
|
|
569
|
-
* retryDelay: 2000
|
|
570
|
-
* })
|
|
571
|
-
* ```
|
|
572
|
-
*/
|
|
573
|
-
retries?: number | undefined;
|
|
574
|
-
/**
|
|
575
|
-
* Initial delay in milliseconds before first retry.
|
|
576
|
-
* Subsequent retries use exponential backoff.
|
|
577
|
-
*
|
|
578
|
-
* @default 1000
|
|
579
|
-
*/
|
|
580
|
-
retryDelay?: number | undefined;
|
|
581
|
-
/**
|
|
582
|
-
* Download timeout in milliseconds.
|
|
583
|
-
* If the download takes longer than this, it will be aborted.
|
|
584
|
-
*
|
|
585
|
-
* @default 120000
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
588
|
-
* ```ts
|
|
589
|
-
* // 5 minute timeout for large files
|
|
590
|
-
* await httpDownload('https://example.com/huge-file.zip', '/tmp/file.zip', {
|
|
591
|
-
* timeout: 300000
|
|
592
|
-
* })
|
|
593
|
-
* ```
|
|
594
|
-
*/
|
|
595
|
-
timeout?: number | undefined;
|
|
596
|
-
/**
|
|
597
|
-
* Expected SHA256 hash of the downloaded file.
|
|
598
|
-
* If provided, the download will fail if the computed hash doesn't match.
|
|
599
|
-
* The hash should be a lowercase hex string (64 characters).
|
|
600
|
-
*
|
|
601
|
-
* Use `fetchChecksums()` to fetch hashes from a checksums URL, then pass
|
|
602
|
-
* the specific hash here.
|
|
603
|
-
*
|
|
604
|
-
* @example
|
|
605
|
-
* ```ts
|
|
606
|
-
* // Verify download integrity with direct hash
|
|
607
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
608
|
-
* sha256: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
|
609
|
-
* })
|
|
610
|
-
*
|
|
611
|
-
* // Verify using checksums from a URL
|
|
612
|
-
* const checksums = await fetchChecksums('https://example.com/checksums.txt')
|
|
613
|
-
* await httpDownload('https://example.com/file.zip', '/tmp/file.zip', {
|
|
614
|
-
* sha256: checksums['file.zip']
|
|
615
|
-
* })
|
|
616
|
-
* ```
|
|
617
|
-
*/
|
|
618
|
-
sha256?: string | undefined;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Result of a successful file download.
|
|
622
|
-
*/
|
|
623
|
-
export interface HttpDownloadResult {
|
|
624
|
-
/** HTTP response headers from the final response (after redirects). */
|
|
625
|
-
headers: IncomingHttpHeaders;
|
|
626
|
-
/** Whether the download succeeded (status 200-299). Always true on success (non-2xx throws). */
|
|
627
|
-
ok: true;
|
|
628
|
-
/** Absolute path where the file was saved. */
|
|
629
|
-
path: string;
|
|
630
|
-
/** Total size of downloaded file in bytes. */
|
|
631
|
-
size: number;
|
|
632
|
-
/** HTTP status code from the final response (after redirects). */
|
|
633
|
-
status: number;
|
|
634
|
-
/** HTTP status message from the final response (after redirects). */
|
|
635
|
-
statusText: string;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Map of filenames to their SHA256 hashes.
|
|
639
|
-
* Keys are filenames (not paths), values are lowercase hex-encoded SHA256 hashes.
|
|
640
|
-
*
|
|
641
|
-
* @example
|
|
642
|
-
* ```ts
|
|
643
|
-
* const checksums: Checksums = {
|
|
644
|
-
* 'file.zip': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
|
|
645
|
-
* 'other.tar.gz': 'abc123...'
|
|
646
|
-
* }
|
|
647
|
-
* ```
|
|
648
|
-
*/
|
|
649
|
-
export type Checksums = Record<string, string>;
|
|
650
|
-
/**
|
|
651
|
-
* Options for fetching checksums from a URL.
|
|
652
|
-
*/
|
|
653
|
-
export interface FetchChecksumsOptions {
|
|
654
|
-
/**
|
|
655
|
-
* Custom CA certificates for TLS connections.
|
|
656
|
-
* See `HttpRequestOptions.ca` for details.
|
|
657
|
-
*/
|
|
658
|
-
ca?: string[] | undefined;
|
|
659
|
-
/**
|
|
660
|
-
* HTTP headers to send with the request.
|
|
661
|
-
*/
|
|
662
|
-
headers?: Record<string, string> | undefined;
|
|
663
|
-
/**
|
|
664
|
-
* Request timeout in milliseconds.
|
|
665
|
-
* @default 30000
|
|
666
|
-
*/
|
|
667
|
-
timeout?: number | undefined;
|
|
668
|
-
}
|
|
669
|
-
/**
|
|
670
|
-
* Build an enriched error message based on the error code.
|
|
671
|
-
* Generic guidance (no product-specific branding).
|
|
672
|
-
*
|
|
673
|
-
* @example
|
|
674
|
-
* ```typescript
|
|
675
|
-
* try {
|
|
676
|
-
* await fetch('https://api.example.com')
|
|
677
|
-
* } catch (e) {
|
|
678
|
-
* console.error(enrichErrorMessage('https://api.example.com', 'GET', e))
|
|
679
|
-
* }
|
|
680
|
-
* ```
|
|
681
|
-
*/
|
|
682
|
-
export declare function enrichErrorMessage(url: string, method: string, error: NodeJS.ErrnoException): string;
|
|
683
|
-
/**
|
|
684
|
-
* Fetch and parse a checksums file from a URL.
|
|
685
|
-
*
|
|
686
|
-
* This is useful for verifying downloads from GitHub releases which typically
|
|
687
|
-
* publish a checksums.txt file alongside release assets.
|
|
688
|
-
*
|
|
689
|
-
* @param url - URL to the checksums file
|
|
690
|
-
* @param options - Request options
|
|
691
|
-
* @returns Map of filenames to lowercase SHA256 hashes
|
|
692
|
-
* @throws {Error} When the checksums file cannot be fetched
|
|
693
|
-
*
|
|
694
|
-
* @example
|
|
695
|
-
* ```ts
|
|
696
|
-
* // Fetch checksums from GitHub release
|
|
697
|
-
* const checksums = await fetchChecksums(
|
|
698
|
-
* 'https://github.com/org/repo/releases/download/v1.0.0/checksums.txt'
|
|
699
|
-
* )
|
|
700
|
-
*
|
|
701
|
-
* // Use with httpDownload
|
|
702
|
-
* await httpDownload(
|
|
703
|
-
* 'https://github.com/org/repo/releases/download/v1.0.0/tool_linux.tar.gz',
|
|
704
|
-
* '/tmp/tool.tar.gz',
|
|
705
|
-
* { sha256: checksums['tool_linux.tar.gz'] }
|
|
706
|
-
* )
|
|
707
|
-
* ```
|
|
708
|
-
*/
|
|
709
|
-
export declare function fetchChecksums(url: string, options?: FetchChecksumsOptions | undefined): Promise<Checksums>;
|
|
710
|
-
/**
|
|
711
|
-
* Download a file from a URL to a local path with redirect support, retry logic, and progress callbacks.
|
|
712
|
-
* Uses streaming to avoid loading entire file in memory.
|
|
713
|
-
*
|
|
714
|
-
* The download is streamed directly to disk, making it memory-efficient even for
|
|
715
|
-
* large files. Progress callbacks allow for real-time download status updates.
|
|
716
|
-
*
|
|
717
|
-
* Automatically follows HTTP redirects (3xx status codes) by default, making it suitable
|
|
718
|
-
* for downloading from services like GitHub releases that redirect to CDN URLs.
|
|
719
|
-
*
|
|
720
|
-
* @param url - The URL to download from (must start with http:// or https://)
|
|
721
|
-
* @param destPath - Absolute path where the file should be saved
|
|
722
|
-
* @param options - Download configuration options
|
|
723
|
-
* @returns Promise resolving to download result with path and size
|
|
724
|
-
* @throws {Error} When all retries are exhausted, download fails, or file cannot be written
|
|
725
|
-
*
|
|
726
|
-
* @example
|
|
727
|
-
* ```ts
|
|
728
|
-
* // Simple download
|
|
729
|
-
* const result = await httpDownload(
|
|
730
|
-
* 'https://example.com/file.zip',
|
|
731
|
-
* '/tmp/file.zip'
|
|
732
|
-
* )
|
|
733
|
-
* console.log(`Downloaded ${result.size} bytes to ${result.path}`)
|
|
734
|
-
*
|
|
735
|
-
* // Download from GitHub releases (handles 302 redirect automatically)
|
|
736
|
-
* await httpDownload(
|
|
737
|
-
* 'https://github.com/org/repo/releases/download/v1.0.0/binary.tar.gz',
|
|
738
|
-
* '/tmp/binary.tar.gz'
|
|
739
|
-
* )
|
|
740
|
-
*
|
|
741
|
-
* // With progress tracking
|
|
742
|
-
* await httpDownload(
|
|
743
|
-
* 'https://example.com/large-file.zip',
|
|
744
|
-
* '/tmp/file.zip',
|
|
745
|
-
* {
|
|
746
|
-
* onProgress: (downloaded, total) => {
|
|
747
|
-
* const percent = ((downloaded / total) * 100).toFixed(1)
|
|
748
|
-
* console.log(`Progress: ${percent}% (${downloaded}/${total} bytes)`)
|
|
749
|
-
* }
|
|
750
|
-
* }
|
|
751
|
-
* )
|
|
752
|
-
*
|
|
753
|
-
* // With retries and custom timeout
|
|
754
|
-
* await httpDownload(
|
|
755
|
-
* 'https://example.com/file.zip',
|
|
756
|
-
* '/tmp/file.zip',
|
|
757
|
-
* {
|
|
758
|
-
* retries: 3,
|
|
759
|
-
* retryDelay: 2000,
|
|
760
|
-
* timeout: 300000, // 5 minutes
|
|
761
|
-
* headers: { 'Authorization': 'Bearer token123' }
|
|
762
|
-
* }
|
|
763
|
-
* )
|
|
764
|
-
* ```
|
|
765
|
-
*/
|
|
766
|
-
export declare function httpDownload(url: string, destPath: string, options?: HttpDownloadOptions | undefined): Promise<HttpDownloadResult>;
|
|
767
|
-
/**
|
|
768
|
-
* Perform an HTTP request and parse JSON response.
|
|
769
|
-
* Convenience wrapper around `httpRequest` for JSON API calls.
|
|
770
|
-
* Automatically sets appropriate headers for JSON requests:
|
|
771
|
-
* - `Accept: application/json` (always)
|
|
772
|
-
* - `Content-Type: application/json` (when body is present)
|
|
773
|
-
* User-provided headers override these defaults.
|
|
774
|
-
*
|
|
775
|
-
* @template T - Expected JSON response type (defaults to `unknown`)
|
|
776
|
-
* @param url - The URL to request (must start with http:// or https://)
|
|
777
|
-
* @param options - Request configuration options
|
|
778
|
-
* @returns Promise resolving to parsed JSON data
|
|
779
|
-
* @throws {Error} When request fails, response is not ok (status < 200 or >= 300), or JSON parsing fails
|
|
780
|
-
*
|
|
781
|
-
* @example
|
|
782
|
-
* ```ts
|
|
783
|
-
* // Simple JSON GET (automatically sets Accept: application/json)
|
|
784
|
-
* const data = await httpJson('https://api.example.com/data')
|
|
785
|
-
* console.log(data)
|
|
786
|
-
*
|
|
787
|
-
* // With type safety
|
|
788
|
-
* interface User { id: number; name: string; email: string }
|
|
789
|
-
* const user = await httpJson<User>('https://api.example.com/user/123')
|
|
790
|
-
* console.log(user.name, user.email)
|
|
791
|
-
*
|
|
792
|
-
* // POST with JSON body (automatically sets Content-Type: application/json)
|
|
793
|
-
* const result = await httpJson('https://api.example.com/users', {
|
|
794
|
-
* method: 'POST',
|
|
795
|
-
* body: JSON.stringify({ name: 'Alice', email: 'alice@example.com' })
|
|
796
|
-
* })
|
|
797
|
-
*
|
|
798
|
-
* // With custom headers and retries
|
|
799
|
-
* const data = await httpJson('https://api.example.com/data', {
|
|
800
|
-
* headers: {
|
|
801
|
-
* 'Authorization': 'Bearer token123'
|
|
802
|
-
* },
|
|
803
|
-
* retries: 3,
|
|
804
|
-
* retryDelay: 1000
|
|
805
|
-
* })
|
|
806
|
-
* ```
|
|
807
|
-
*/
|
|
808
|
-
export declare function httpJson<T = unknown>(url: string, options?: HttpRequestOptions | undefined): Promise<T>;
|
|
809
|
-
/**
|
|
810
|
-
* Make an HTTP/HTTPS request with retry logic and redirect support.
|
|
811
|
-
* Provides a fetch-like API using Node.js native http/https modules.
|
|
812
|
-
*
|
|
813
|
-
* This is the main entry point for making HTTP requests. It handles retries,
|
|
814
|
-
* redirects, timeouts, and provides a fetch-compatible response interface.
|
|
815
|
-
*
|
|
816
|
-
* @param url - The URL to request (must start with http:// or https://)
|
|
817
|
-
* @param options - Request configuration options
|
|
818
|
-
* @returns Promise resolving to response object with `.json()`, `.text()`, etc.
|
|
819
|
-
* @throws {Error} When all retries are exhausted, timeout occurs, or non-retryable error happens
|
|
820
|
-
*
|
|
821
|
-
* @example
|
|
822
|
-
* ```ts
|
|
823
|
-
* // Simple GET request
|
|
824
|
-
* const response = await httpRequest('https://api.example.com/data')
|
|
825
|
-
* const data = response.json()
|
|
826
|
-
*
|
|
827
|
-
* // POST with JSON body
|
|
828
|
-
* const response = await httpRequest('https://api.example.com/users', {
|
|
829
|
-
* method: 'POST',
|
|
830
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
831
|
-
* body: JSON.stringify({ name: 'Alice', email: 'alice@example.com' })
|
|
832
|
-
* })
|
|
833
|
-
*
|
|
834
|
-
* // With retries and timeout
|
|
835
|
-
* const response = await httpRequest('https://api.example.com/data', {
|
|
836
|
-
* retries: 3,
|
|
837
|
-
* retryDelay: 1000,
|
|
838
|
-
* timeout: 60000
|
|
839
|
-
* })
|
|
840
|
-
*
|
|
841
|
-
* // Don't follow redirects
|
|
842
|
-
* const response = await httpRequest('https://example.com/redirect', {
|
|
843
|
-
* followRedirects: false
|
|
844
|
-
* })
|
|
845
|
-
* console.log(response.status) // 301, 302, etc.
|
|
846
|
-
* ```
|
|
847
|
-
*/
|
|
848
|
-
export declare function httpRequest(url: string, options?: HttpRequestOptions | undefined): Promise<HttpResponse>;
|
|
849
|
-
/**
|
|
850
|
-
* Perform an HTTP request and return text response.
|
|
851
|
-
* Convenience wrapper around `httpRequest` for fetching text content.
|
|
852
|
-
* Automatically sets appropriate headers for text requests:
|
|
853
|
-
* - `Accept: text/plain` (always)
|
|
854
|
-
* - `Content-Type: text/plain` (when body is present)
|
|
855
|
-
* User-provided headers override these defaults.
|
|
856
|
-
*
|
|
857
|
-
* @param url - The URL to request (must start with http:// or https://)
|
|
858
|
-
* @param options - Request configuration options
|
|
859
|
-
* @returns Promise resolving to response body as UTF-8 string
|
|
860
|
-
* @throws {Error} When request fails or response is not ok (status < 200 or >= 300)
|
|
861
|
-
*
|
|
862
|
-
* @example
|
|
863
|
-
* ```ts
|
|
864
|
-
* // Fetch HTML (automatically sets Accept: text/plain)
|
|
865
|
-
* const html = await httpText('https://example.com')
|
|
866
|
-
* console.log(html.includes('<!DOCTYPE html>'))
|
|
867
|
-
*
|
|
868
|
-
* // Fetch plain text
|
|
869
|
-
* const text = await httpText('https://example.com/file.txt')
|
|
870
|
-
* console.log(text)
|
|
871
|
-
*
|
|
872
|
-
* // POST with text body (automatically sets Content-Type: text/plain)
|
|
873
|
-
* const result = await httpText('https://example.com/api', {
|
|
874
|
-
* method: 'POST',
|
|
875
|
-
* body: 'raw text data'
|
|
876
|
-
* })
|
|
877
|
-
*
|
|
878
|
-
* // With custom headers (override defaults)
|
|
879
|
-
* const text = await httpText('https://example.com/data.txt', {
|
|
880
|
-
* headers: {
|
|
881
|
-
* 'Authorization': 'Bearer token123',
|
|
882
|
-
* 'Accept': 'text/html' // Override default Accept header
|
|
883
|
-
* }
|
|
884
|
-
* })
|
|
885
|
-
*
|
|
886
|
-
* // With timeout
|
|
887
|
-
* const text = await httpText('https://example.com/large-file.txt', {
|
|
888
|
-
* timeout: 60000 // 1 minute
|
|
889
|
-
* })
|
|
890
|
-
* ```
|
|
891
|
-
*/
|
|
892
|
-
export declare function httpText(url: string, options?: HttpRequestOptions | undefined): Promise<string>;
|
|
893
|
-
export declare function parseChecksums(text: string): Checksums;
|
|
894
|
-
/**
|
|
895
|
-
* Parse a `Retry-After` HTTP header value into milliseconds.
|
|
896
|
-
*
|
|
897
|
-
* Supports both formats defined in RFC 7231 §7.1.3:
|
|
898
|
-
* - **delay-seconds**: integer number of seconds (e.g., `"120"`)
|
|
899
|
-
* - **HTTP-date**: an absolute date/time (e.g., `"Fri, 31 Dec 2027 23:59:59 GMT"`)
|
|
900
|
-
*
|
|
901
|
-
* When the header is an array (multiple values), the first element is used.
|
|
902
|
-
*
|
|
903
|
-
* @param value - The raw Retry-After header value(s)
|
|
904
|
-
* @returns Delay in milliseconds, or `undefined` if the value cannot be parsed
|
|
905
|
-
*
|
|
906
|
-
* @example
|
|
907
|
-
* ```ts
|
|
908
|
-
* import { setTimeout as delay } from 'node:timers/promises'
|
|
909
|
-
* const ms = parseRetryAfterHeader(response.headers['retry-after'])
|
|
910
|
-
* if (ms !== undefined) {
|
|
911
|
-
* await delay(ms)
|
|
912
|
-
* }
|
|
913
|
-
* ```
|
|
914
|
-
*/
|
|
915
|
-
export declare function parseRetryAfterHeader(value: string | string[] | undefined): number | undefined;
|
|
916
|
-
/**
|
|
917
|
-
* Read and buffer a client-side IncomingResponse into an HttpResponse.
|
|
918
|
-
*
|
|
919
|
-
* Useful when you have a raw response from code that bypasses
|
|
920
|
-
* `httpRequest()` (e.g., multipart form-data uploads via `http.request()`,
|
|
921
|
-
* or responses from third-party HTTP libraries) and need to convert it
|
|
922
|
-
* into the standard HttpResponse interface.
|
|
923
|
-
*
|
|
924
|
-
* @example
|
|
925
|
-
* ```typescript
|
|
926
|
-
* const raw = await makeRawRequest('https://example.com/api')
|
|
927
|
-
* const response = await readIncomingResponse(raw)
|
|
928
|
-
* console.log(response.status, response.body.toString('utf8'))
|
|
929
|
-
* ```
|
|
930
|
-
*/
|
|
931
|
-
export declare function readIncomingResponse(msg: IncomingResponse): Promise<HttpResponse>;
|
|
932
|
-
/**
|
|
933
|
-
* Redact sensitive HTTP headers for safe logging and telemetry.
|
|
934
|
-
*
|
|
935
|
-
* Replaces values of sensitive headers (Authorization, Cookie, etc.)
|
|
936
|
-
* with `[REDACTED]`. Non-sensitive headers are passed through unchanged.
|
|
937
|
-
* Array values are joined with `', '`.
|
|
938
|
-
*
|
|
939
|
-
* @param headers - HTTP headers to sanitize
|
|
940
|
-
* @returns A new object with sensitive values redacted
|
|
941
|
-
*
|
|
942
|
-
* @example
|
|
943
|
-
* ```ts
|
|
944
|
-
* const safe = sanitizeHeaders({
|
|
945
|
-
* 'authorization': 'Bearer secret',
|
|
946
|
-
* 'content-type': 'application/json'
|
|
947
|
-
* })
|
|
948
|
-
* // { authorization: '[REDACTED]', 'content-type': 'application/json' }
|
|
949
|
-
* ```
|
|
950
|
-
*/
|
|
951
|
-
export declare function sanitizeHeaders(headers: Record<string, unknown> | undefined): Record<string, string>;
|