@socketsecurity/lib 6.0.6 → 6.0.8
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 +46 -1
- package/README.md +1 -1
- package/dist/ai/agent-context.d.mts +103 -0
- package/dist/ai/agent-context.js +157 -0
- package/dist/ai/backends.d.mts +83 -0
- package/dist/ai/backends.js +173 -0
- package/dist/ai/credentials.d.mts +49 -0
- package/dist/ai/credentials.js +82 -0
- package/dist/ai/discover.d.mts +6 -2
- package/dist/ai/discover.js +4 -3
- package/dist/ai/exec.d.mts +52 -0
- package/dist/ai/exec.js +92 -0
- package/dist/ai/http.d.mts +132 -0
- package/dist/ai/http.js +130 -0
- package/dist/ai/profiles.d.mts +41 -6
- package/dist/ai/profiles.js +52 -10
- package/dist/ai/route.d.mts +69 -0
- package/dist/ai/route.js +156 -0
- package/dist/ai/spawn.d.mts +10 -2
- package/dist/ai/spawn.js +56 -31
- package/dist/ai/subagent-status.d.mts +48 -0
- package/dist/ai/subagent-status.js +57 -0
- package/dist/ai/tier.d.mts +60 -0
- package/dist/ai/tier.js +53 -0
- package/dist/ai/types.d.mts +31 -6
- package/dist/ai/worktree.d.mts +6 -6
- package/dist/ai/worktree.js +5 -1
- package/dist/ansi/strip.d.ts +1 -1
- package/dist/ansi/strip.js +0 -2
- package/dist/archives/_internal.js +7 -9
- package/dist/archives/extract.js +1 -1
- package/dist/archives/tar.js +7 -7
- package/dist/archives/zip.js +5 -7
- package/dist/argv/flag-predicates.d.ts +12 -12
- package/dist/argv/flag-predicates.js +17 -17
- package/dist/argv/flag-types.d.ts +18 -18
- package/dist/argv/flag-types.js +4 -4
- package/dist/argv/parse.d.ts +20 -3
- package/dist/argv/parse.js +1 -1
- package/dist/arrays/_internal.js +11 -12
- package/dist/arrays/chunk.js +0 -1
- package/dist/arrays/join.d.ts +37 -3
- package/dist/arrays/join.js +47 -7
- package/dist/arrays/unique.js +0 -1
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/exec.js +2 -3
- package/dist/bin/find.js +17 -17
- package/dist/bin/prim.cjs +36175 -35861
- package/dist/bin/resolve.js +13 -14
- package/dist/bin/which.js +8 -8
- package/dist/cache/ttl/store.js +6 -6
- package/dist/checks/primordials-defaults.d.ts +3 -3
- package/dist/checks/primordials-defaults.js +3 -3
- package/dist/checks/primordials.js +4 -3
- package/dist/{bin → cli}/check-primordials.d.ts +18 -13
- package/dist/{bin → cli}/check-primordials.js +58 -55
- package/dist/{bin → cli}/check.js +3 -3
- package/dist/{bin → cli}/socket-lib.d.ts +1 -1
- package/dist/{bin → cli}/socket-lib.js +4 -4
- package/dist/colors/socket-palette.js +7 -9
- package/dist/compression/_internal.d.ts +12 -12
- package/dist/compression/_internal.js +18 -18
- package/dist/compression/brotli.d.ts +26 -27
- package/dist/compression/brotli.js +39 -35
- package/dist/compression/gzip.d.ts +23 -23
- package/dist/compression/gzip.js +46 -42
- package/dist/constants/agents.d.ts +3 -1
- package/dist/constants/agents.js +15 -11
- package/dist/constants/licenses.js +3 -3
- package/dist/constants/node.d.ts +23 -0
- package/dist/constants/node.js +47 -15
- package/dist/constants/packages.d.ts +3 -0
- package/dist/constants/packages.js +24 -29
- package/dist/constants/platform.d.ts +30 -3
- package/dist/constants/platform.js +72 -12
- package/dist/constants/runtime.d.ts +22 -0
- package/dist/constants/runtime.js +32 -0
- package/dist/constants/socket.d.ts +2 -6
- package/dist/constants/socket.js +12 -14
- package/dist/cover/code.js +10 -10
- package/dist/cover/formatters.js +5 -5
- package/dist/crypto/hash.d.ts +30 -2
- package/dist/crypto/hash.js +47 -13
- package/dist/debug/_internal.js +4 -6
- package/dist/debug/caller-info.js +3 -4
- package/dist/debug/namespace.d.ts +7 -0
- package/dist/debug/namespace.js +21 -12
- package/dist/debug/output.js +21 -24
- package/dist/debug/types.d.ts +4 -4
- package/dist/dlx/arborist.js +18 -8
- package/dist/dlx/binary-cache.js +15 -15
- package/dist/dlx/binary-download.d.ts +1 -1
- package/dist/dlx/binary-download.js +11 -11
- package/dist/dlx/binary-resolution.js +17 -15
- package/dist/dlx/binary-types.d.ts +5 -5
- package/dist/dlx/binary.js +5 -5
- package/dist/dlx/cache.js +1 -1
- package/dist/dlx/detect.d.ts +42 -25
- package/dist/dlx/detect.js +86 -77
- package/dist/dlx/dir.js +2 -2
- package/dist/dlx/firewall.d.ts +9 -1
- package/dist/dlx/firewall.js +1 -1
- package/dist/dlx/lockfile.d.ts +19 -18
- package/dist/dlx/lockfile.js +19 -16
- package/dist/dlx/manifest.d.ts +6 -6
- package/dist/dlx/manifest.js +5 -5
- package/dist/dlx/package.d.ts +10 -10
- package/dist/dlx/package.js +20 -16
- package/dist/dlx/packages.js +4 -4
- package/dist/dlx/paths.js +7 -7
- package/dist/dlx/spec.js +1 -1
- package/dist/dlx/types.d.ts +28 -27
- package/dist/eco/cargo/parse-lockfile.d.ts +2 -3
- package/dist/eco/cargo/parse-lockfile.js +5 -5
- package/dist/eco/manifest/analyze-lockfile.js +2 -2
- package/dist/eco/manifest/detect-format.js +5 -5
- package/dist/eco/manifest/find-packages.js +2 -2
- package/dist/eco/manifest/get-package-versions.js +2 -2
- package/dist/eco/manifest/get-package.js +2 -2
- package/dist/eco/manifest/parse-lockfile.js +2 -2
- package/dist/eco/manifest/parse-manifest.js +2 -2
- package/dist/eco/manifest/parse.js +2 -2
- package/dist/eco/npm/npm/exec.js +2 -2
- package/dist/eco/npm/npm/flags.js +7 -12
- package/dist/eco/npm/npm/parse-lockfile.d.ts +17 -18
- package/dist/eco/npm/npm/parse-lockfile.js +4 -4
- package/dist/eco/npm/parse-package-json.d.ts +11 -0
- package/dist/eco/npm/parse-package-json.js +3 -3
- package/dist/eco/npm/pnpm/exec.d.ts +1 -1
- package/dist/eco/npm/pnpm/exec.js +5 -5
- package/dist/eco/npm/pnpm/flags.js +0 -3
- package/dist/eco/npm/pnpm/parse-lockfile.d.ts +6 -4
- package/dist/eco/npm/pnpm/parse-lockfile.js +7 -7
- package/dist/eco/npm/script.js +9 -6
- package/dist/eco/npm/yarnpkg/yarn/exec.js +4 -4
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +3 -4
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +9 -9
- package/dist/effects/pulse-frames.d.ts +3 -1
- package/dist/effects/shimmer-keyframes.d.ts +1 -1
- package/dist/effects/shimmer-terminal.d.ts +1 -1
- package/dist/env/boolean.js +0 -1
- package/dist/env/ci.js +0 -1
- package/dist/env/debug.js +0 -1
- package/dist/env/github-status.d.ts +51 -0
- package/dist/env/github-status.js +90 -0
- package/dist/env/github.js +0 -8
- package/dist/env/home.js +0 -1
- package/dist/env/locale.js +0 -3
- package/dist/env/node-auth-token.js +0 -1
- package/dist/env/node-env.js +0 -1
- package/dist/env/node-version-managers.d.ts +53 -0
- package/dist/env/node-version-managers.js +90 -0
- package/dist/env/npm.js +0 -5
- package/dist/env/number.js +0 -1
- package/dist/env/package-manager.js +3 -6
- package/dist/env/path.js +0 -1
- package/dist/env/pre-commit.js +1 -2
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +8 -6
- package/dist/env/rewire.js +16 -17
- package/dist/env/shell.js +0 -1
- package/dist/env/socket-cli.js +5 -18
- package/dist/env/socket-mcp.d.ts +114 -0
- package/dist/env/socket-mcp.js +146 -0
- package/dist/env/socket.d.ts +8 -109
- package/dist/env/socket.js +22 -167
- package/dist/env/string.js +0 -1
- package/dist/env/temp-dir.js +0 -3
- package/dist/env/term.js +0 -1
- package/dist/env/test.js +3 -6
- package/dist/env/windows.js +0 -4
- package/dist/env/xdg.js +0 -3
- package/dist/errors/predicates.js +1 -1
- package/dist/events/exit/_internal.d.ts +11 -9
- package/dist/events/exit/_internal.js +31 -35
- package/dist/events/exit/handler.js +3 -4
- package/dist/events/exit/intercept.js +4 -6
- package/dist/events/exit/lifecycle.js +16 -18
- package/dist/events/exit/signals.js +1 -2
- package/dist/events/exit/types.d.ts +6 -5
- package/dist/external/@npmcli/package-json.js +2 -2
- package/dist/external/@npmcli/promise-spawn.js +3 -1
- package/dist/external/npm-pack.js +2 -2
- package/dist/external/pico-pack.js +4 -2
- package/dist/external/which.js +3 -1
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/asset-names.js +5 -2
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.js +5 -2
- package/dist/external-tools/bazel/read-bazel-version-file.js +1 -1
- package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
- package/dist/external-tools/bazel/resolve.d.ts +3 -3
- package/dist/external-tools/bazel/resolve.js +16 -8
- package/dist/external-tools/bazel/types.d.ts +1 -1
- package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
- package/dist/external-tools/cdxgen/asset-names.js +5 -2
- package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
- package/dist/external-tools/cdxgen/from-download.js +7 -4
- package/dist/external-tools/cdxgen/from-vfs.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
- package/dist/external-tools/cdxgen/resolve.js +16 -8
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +3 -3
- package/dist/external-tools/from-download.js +12 -6
- package/dist/external-tools/from-pip-venv.d.ts +1 -1
- package/dist/external-tools/from-pip-venv.js +12 -5
- package/dist/external-tools/janus/asset-names.d.ts +1 -1
- package/dist/external-tools/janus/asset-names.js +5 -2
- package/dist/external-tools/janus/from-download.d.ts +1 -1
- package/dist/external-tools/janus/from-download.js +5 -2
- package/dist/external-tools/janus/from-vfs.js +1 -1
- package/dist/external-tools/janus/resolve.d.ts +3 -3
- package/dist/external-tools/janus/resolve.js +16 -8
- package/dist/external-tools/janus/types.d.ts +1 -1
- package/dist/external-tools/jre/asset-names.d.ts +1 -1
- package/dist/external-tools/jre/asset-names.js +5 -2
- package/dist/external-tools/jre/detect-platform-arch.d.ts +10 -6
- package/dist/external-tools/jre/detect-platform-arch.js +29 -14
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/jre/from-download.js +7 -4
- package/dist/external-tools/jre/from-java-home.js +2 -2
- package/dist/external-tools/jre/from-vfs.js +3 -3
- package/dist/external-tools/jre/resolve.d.ts +3 -3
- package/dist/external-tools/jre/resolve.js +16 -8
- package/dist/external-tools/jre/types.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +25 -7
- package/dist/external-tools/manifest.js +13 -13
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/asset-names.js +5 -2
- package/dist/external-tools/opengrep/from-download.d.ts +1 -1
- package/dist/external-tools/opengrep/from-download.js +5 -2
- package/dist/external-tools/opengrep/from-vfs.js +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -3
- package/dist/external-tools/opengrep/resolve.js +16 -8
- package/dist/external-tools/opengrep/types.d.ts +1 -1
- package/dist/external-tools/python/asset-names.d.ts +76 -0
- package/dist/external-tools/python/asset-names.js +111 -0
- package/dist/external-tools/python/dlx.d.ts +80 -0
- package/dist/external-tools/python/dlx.js +98 -0
- package/dist/external-tools/python/from-download.d.ts +53 -0
- package/dist/external-tools/python/from-download.js +75 -0
- package/dist/external-tools/python/from-path.d.ts +7 -0
- package/dist/external-tools/python/from-path.js +23 -0
- package/dist/external-tools/python/pin.d.ts +121 -0
- package/dist/external-tools/python/pin.js +176 -0
- package/dist/external-tools/python/pip-install.d.ts +75 -0
- package/dist/external-tools/python/pip-install.js +142 -0
- package/dist/external-tools/python/resolve.d.ts +42 -0
- package/dist/external-tools/python/resolve.js +66 -0
- package/dist/external-tools/python/types.d.ts +49 -0
- package/dist/external-tools/sbt/asset-names.d.ts +1 -1
- package/dist/external-tools/sbt/asset-names.js +5 -2
- package/dist/external-tools/sbt/from-download.d.ts +1 -1
- package/dist/external-tools/sbt/from-download.js +5 -2
- package/dist/external-tools/sbt/from-vfs.js +1 -1
- package/dist/external-tools/sbt/resolve.d.ts +3 -3
- package/dist/external-tools/sbt/resolve.js +16 -8
- package/dist/external-tools/sbt/types.d.ts +1 -1
- package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
- package/dist/external-tools/skillspector/from-dlx.js +10 -3
- package/dist/external-tools/skillspector/from-path.js +3 -5
- package/dist/external-tools/skillspector/from-vfs.js +1 -1
- package/dist/external-tools/skillspector/resolve.d.ts +2 -2
- package/dist/external-tools/skillspector/resolve.js +14 -6
- package/dist/external-tools/synp/asset-names.d.ts +1 -1
- package/dist/external-tools/synp/asset-names.js +6 -2
- package/dist/external-tools/synp/from-download.d.ts +1 -1
- package/dist/external-tools/synp/from-download.js +7 -4
- package/dist/external-tools/synp/from-vfs.js +1 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -3
- package/dist/external-tools/synp/resolve.js +16 -8
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/asset-names.js +5 -2
- package/dist/external-tools/trivy/from-download.d.ts +1 -1
- package/dist/external-tools/trivy/from-download.js +7 -4
- package/dist/external-tools/trivy/from-vfs.js +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -3
- package/dist/external-tools/trivy/resolve.js +16 -8
- package/dist/external-tools/trivy/types.d.ts +1 -1
- package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
- package/dist/external-tools/trufflehog/asset-names.js +5 -2
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/from-download.js +7 -4
- package/dist/external-tools/trufflehog/from-vfs.js +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
- package/dist/external-tools/trufflehog/resolve.js +16 -8
- package/dist/external-tools/trufflehog/types.d.ts +1 -1
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +7 -7
- package/dist/fs/access.js +5 -9
- package/dist/fs/allowed-dirs-cache.d.ts +47 -0
- package/dist/fs/allowed-dirs-cache.js +69 -0
- package/dist/fs/encoding.js +5 -7
- package/dist/fs/{find-up.js → find.js} +12 -14
- package/dist/fs/inspect.js +7 -13
- package/dist/fs/read-dir.js +7 -10
- package/dist/fs/read-file.js +8 -14
- package/dist/fs/read-json-cache.d.ts +13 -4
- package/dist/fs/read-json-cache.js +9 -6
- package/dist/fs/read-json.js +4 -6
- package/dist/fs/resolve-module.js +7 -3
- package/dist/fs/safe.d.ts +1 -1
- package/dist/fs/safe.js +13 -14
- package/dist/fs/unique.js +4 -5
- package/dist/fs/validate.js +1 -2
- package/dist/fs/write-json.js +4 -5
- package/dist/git/_internal.js +11 -11
- package/dist/git/changed.js +4 -4
- package/dist/git/repo.js +5 -7
- package/dist/git/staged.js +12 -4
- package/dist/git/tracked.d.ts +84 -0
- package/dist/git/tracked.js +163 -0
- package/dist/git/unstaged.js +12 -4
- package/dist/github/ghsa.js +2 -2
- package/dist/github/refs-cache.d.ts +1 -1
- package/dist/github/refs-cache.js +5 -5
- package/dist/github/refs-graphql.js +4 -0
- package/dist/github/refs-rest.js +9 -5
- package/dist/github/refs.js +15 -10
- package/dist/github/{fetch.js → request.js} +13 -2
- package/dist/github/token.js +1 -1
- package/dist/github/types.d.ts +1 -1
- package/dist/globs/_internal.js +8 -10
- package/dist/globs/match.js +13 -7
- package/dist/globs/matcher.d.ts +3 -3
- package/dist/globs/matcher.js +16 -14
- package/dist/globs/stream.js +1 -2
- package/dist/globs/types.d.ts +24 -24
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.js +10 -4
- package/dist/http-request/checksum-file.d.ts +55 -0
- package/dist/http-request/checksum-file.js +95 -0
- package/dist/http-request/download-types.d.ts +15 -23
- package/dist/http-request/download.js +3 -3
- package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
- package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
- package/dist/http-request/headers.js +1 -2
- package/dist/http-request/request-attempt.js +38 -34
- package/dist/http-request/request-types.d.ts +2 -2
- package/dist/http-request/request.js +1 -1
- package/dist/http-request/user-agent.js +4 -5
- package/dist/integrity.d.ts +92 -18
- package/dist/integrity.js +125 -30
- package/dist/ipc/directory.js +2 -2
- package/dist/ipc/paths.js +1 -1
- package/dist/ipc/write.js +1 -1
- package/dist/ipc-cli/get.js +12 -12
- package/dist/json/edit.js +51 -44
- package/dist/json/format.js +1 -1
- package/dist/json/parse.d.ts +1 -1
- package/dist/json/parse.js +3 -7
- package/dist/logger/_internal.d.ts +4 -4
- package/dist/logger/_internal.js +3 -3
- package/dist/logger/colors.js +4 -3
- package/dist/logger/console-methods.d.ts +132 -0
- package/dist/logger/console-methods.js +169 -0
- package/dist/logger/console.d.ts +12 -0
- package/dist/logger/console.js +42 -11
- package/dist/logger/indentation-methods.d.ts +81 -0
- package/dist/logger/indentation-methods.js +121 -0
- package/dist/logger/node.d.ts +16 -338
- package/dist/logger/node.js +75 -608
- package/dist/logger/options.d.ts +39 -0
- package/dist/logger/options.js +47 -0
- package/dist/logger/semantic-methods.d.ts +63 -0
- package/dist/logger/semantic-methods.js +108 -0
- package/dist/logger/stream-methods.d.ts +63 -0
- package/dist/logger/stream-methods.js +101 -0
- package/dist/logger/stream.d.ts +37 -0
- package/dist/logger/stream.js +42 -0
- package/dist/logger/symbols-builder.js +9 -9
- package/dist/logger/symbols.d.ts +2 -25
- package/dist/logger/symbols.js +53 -74
- package/dist/logger/types.d.ts +1 -1
- package/dist/memo/types.d.ts +6 -6
- package/dist/native-messaging/host.d.ts +20 -0
- package/dist/native-messaging/host.js +120 -0
- package/dist/native-messaging/index.d.ts +5 -0
- package/dist/native-messaging/index.js +22 -0
- package/dist/native-messaging/install.d.ts +60 -0
- package/dist/native-messaging/install.js +144 -0
- package/dist/native-messaging/rate-limit.d.ts +69 -0
- package/dist/native-messaging/rate-limit.js +119 -0
- package/dist/native-messaging/run.d.ts +10 -0
- package/dist/native-messaging/run.js +17 -0
- package/dist/node/async-hooks.js +4 -3
- package/dist/node/child-process.js +4 -3
- package/dist/node/crypto.js +4 -3
- package/dist/node/events.js +4 -3
- package/dist/node/fs-promises.js +4 -3
- package/dist/node/fs.d.ts +22 -6
- package/dist/node/fs.js +17 -3
- package/dist/node/http.js +4 -3
- package/dist/node/https.js +4 -3
- package/dist/node/module.js +10 -6
- package/dist/node/os.d.ts +10 -2
- package/dist/node/os.js +12 -4
- package/dist/node/path.d.ts +11 -2
- package/dist/node/path.js +18 -4
- package/dist/node/timers-promises.js +4 -3
- package/dist/node/url.js +4 -3
- package/dist/node/util.js +4 -3
- package/dist/objects/getters.js +6 -8
- package/dist/objects/inspect.js +1 -4
- package/dist/objects/mutate.js +4 -5
- package/dist/objects/predicates.js +1 -5
- package/dist/objects/sort.js +3 -7
- package/dist/packages/edit-class.d.ts +2 -3
- package/dist/packages/edit-class.js +53 -48
- package/dist/packages/edit.js +12 -14
- package/dist/packages/exports.js +15 -21
- package/dist/packages/fetch.d.ts +16 -0
- package/dist/packages/fetch.js +81 -0
- package/dist/packages/find.d.ts +55 -0
- package/dist/packages/find.js +65 -0
- package/dist/packages/isolation.js +14 -14
- package/dist/packages/licenses.js +18 -18
- package/dist/packages/manifest.js +16 -19
- package/dist/packages/metadata-extensions.d.ts +14 -0
- package/dist/packages/metadata-extensions.js +43 -0
- package/dist/packages/normalize.js +6 -10
- package/dist/packages/provenance.js +17 -19
- package/dist/packages/read.d.ts +29 -0
- package/dist/packages/read.js +66 -0
- package/dist/packages/specs.d.ts +48 -1
- package/dist/packages/specs.js +75 -12
- package/dist/packages/tarball.d.ts +24 -0
- package/dist/packages/tarball.js +81 -0
- package/dist/packages/types.d.ts +22 -22
- package/dist/packages/validation.js +0 -3
- package/dist/paths/_internal.d.ts +2 -1
- package/dist/paths/_internal.js +7 -19
- package/dist/paths/conversion.js +5 -9
- package/dist/paths/dirnames.d.ts +1 -0
- package/dist/paths/dirnames.js +2 -0
- package/dist/paths/filenames.d.ts +0 -1
- package/dist/paths/filenames.js +0 -2
- package/dist/paths/normalize.js +4 -5
- package/dist/paths/packages.js +4 -7
- package/dist/paths/predicates.js +9 -16
- package/dist/paths/resolve.js +17 -25
- package/dist/paths/rewire.d.ts +5 -0
- package/dist/paths/rewire.js +3 -3
- package/dist/paths/socket.d.ts +74 -111
- package/dist/paths/socket.js +106 -139
- package/dist/paths/walk.d.ts +1 -1
- package/dist/paths/walk.js +4 -4
- package/dist/perf/report.js +2 -2
- package/dist/perf/types.d.ts +1 -1
- package/dist/pkg-ext/data.js +1 -1
- package/dist/primordials/array.js +9 -9
- package/dist/primordials/date.js +2 -2
- package/dist/primordials/error.js +3 -3
- package/dist/primordials/headers.d.ts +10 -0
- package/dist/primordials/headers.js +23 -0
- package/dist/primordials/intl.d.ts +13 -0
- package/dist/primordials/intl.js +26 -0
- package/dist/primordials/math.js +33 -33
- package/dist/primordials/number.js +9 -9
- package/dist/primordials/object.js +5 -5
- package/dist/primordials/process.d.ts +88 -0
- package/dist/primordials/process.js +132 -0
- package/dist/primordials/string.d.ts +2 -2
- package/dist/primordials/string.js +6 -6
- package/dist/primordials/symbol.js +3 -3
- package/dist/primordials/uncurry.d.ts +1 -2
- package/dist/primordials/uncurry.js +9 -9
- package/dist/process/abort.js +3 -3
- package/dist/process/lock-manager.js +8 -8
- package/dist/process/spawn/_internal.js +6 -8
- package/dist/process/spawn/child.js +20 -14
- package/dist/process/spawn/errors.js +3 -5
- package/dist/process/spawn/kill-tree.d.ts +53 -0
- package/dist/process/spawn/kill-tree.js +85 -0
- package/dist/process/spawn/stdio.js +0 -1
- package/dist/process/spawn/types.d.ts +5 -5
- package/dist/process/transient.js +2 -2
- package/dist/promises/_internal.d.ts +2 -1
- package/dist/promises/_internal.js +2 -6
- package/dist/promises/iterate.js +11 -15
- package/dist/promises/options.js +3 -6
- package/dist/promises/retry.js +4 -5
- package/dist/promises/timers.d.ts +30 -0
- package/dist/promises/timers.js +48 -0
- package/dist/regexps/spec.js +1 -1
- package/dist/releases/github-archives.d.ts +6 -6
- package/dist/releases/github-archives.js +3 -3
- package/dist/releases/github-asset-url.d.ts +1 -1
- package/dist/releases/github-asset-url.js +5 -5
- package/dist/releases/github-downloads.d.ts +1 -1
- package/dist/releases/github-downloads.js +3 -3
- package/dist/releases/github-listing.d.ts +12 -4
- package/dist/releases/github-listing.js +20 -7
- package/dist/releases/github-retry-config.js +1 -1
- package/dist/releases/github-types.d.ts +6 -6
- package/dist/releases/socket-btm-binary-naming.d.ts +107 -0
- package/dist/releases/socket-btm-binary-naming.js +155 -0
- package/dist/releases/socket-btm.d.ts +8 -115
- package/dist/releases/socket-btm.js +16 -159
- package/dist/schema/types.d.ts +4 -5
- package/dist/schema/validate.js +1 -1
- package/dist/sea/detect.js +6 -6
- package/dist/secrets/_internal.d.ts +2 -2
- package/dist/secrets/_internal.js +2 -2
- package/dist/secrets/compare.d.ts +45 -0
- package/dist/secrets/compare.js +61 -0
- package/dist/secrets/find.d.ts +2 -2
- package/dist/secrets/find.js +10 -4
- package/dist/secrets/keychain.d.ts +1 -1
- package/dist/secrets/keychain.js +6 -4
- package/dist/secrets/linux.js +40 -52
- package/dist/secrets/macos.d.ts +2 -3
- package/dist/secrets/macos.js +24 -33
- package/dist/secrets/rc.d.ts +4 -4
- package/dist/secrets/rc.js +27 -17
- package/dist/secrets/socket-api-token.d.ts +4 -4
- package/dist/secrets/socket-api-token.js +26 -9
- package/dist/secrets/windows.js +32 -37
- package/dist/shadow/skip.js +2 -2
- package/dist/shell/parse.d.ts +32 -0
- package/dist/shell/parse.js +60 -0
- package/dist/smol/detect.js +9 -10
- package/dist/smol/http.js +6 -7
- package/dist/smol/https.js +6 -7
- package/dist/smol/manifest.d.ts +1 -1
- package/dist/smol/manifest.js +6 -7
- package/dist/smol/path.d.ts +1 -1
- package/dist/smol/path.js +7 -8
- package/dist/smol/primordial.d.ts +4 -0
- package/dist/smol/primordial.js +6 -7
- package/dist/smol/purl.d.ts +1 -1
- package/dist/smol/purl.js +7 -8
- package/dist/smol/versions.js +6 -7
- package/dist/smol/vfs.js +6 -7
- package/dist/sorts/_internal.js +6 -8
- package/dist/sorts/natural.js +10 -12
- package/dist/sorts/semver.js +1 -2
- package/dist/sorts/strings.js +0 -1
- package/dist/sorts/types.d.ts +1 -1
- package/dist/spinner/create-spinner-class.d.ts +38 -0
- package/dist/spinner/create-spinner-class.js +302 -0
- package/dist/spinner/default.js +8 -9
- package/dist/spinner/spinner-internals.d.ts +36 -0
- package/dist/spinner/spinner-internals.js +105 -0
- package/dist/spinner/spinner-shimmer-methods.d.ts +54 -0
- package/dist/spinner/spinner-shimmer-methods.js +143 -0
- package/dist/spinner/spinner-status-methods.d.ts +40 -0
- package/dist/spinner/spinner-status-methods.js +133 -0
- package/dist/spinner/spinner.d.ts +8 -5
- package/dist/spinner/spinner.js +19 -706
- package/dist/spinner/types.d.ts +3 -1
- package/dist/spinner/with.d.ts +10 -0
- package/dist/spinner/with.js +16 -2
- package/dist/stdio/divider.js +1 -1
- package/dist/stdio/footer.js +3 -3
- package/dist/stdio/header.js +4 -4
- package/dist/stdio/progress.js +10 -6
- package/dist/stdio/prompts.d.ts +7 -5
- package/dist/stdio/prompts.js +7 -8
- package/dist/stdio/stdout.js +3 -3
- package/dist/streams/parallel.js +3 -5
- package/dist/streams/transform.js +2 -3
- package/dist/strings/format.js +2 -6
- package/dist/strings/predicates.js +0 -2
- package/dist/strings/search.js +1 -2
- package/dist/strings/transform.js +0 -3
- package/dist/strings/width.js +9 -10
- package/dist/tables/bordered.js +4 -3
- package/dist/tables/padding.js +1 -1
- package/dist/tables/simple.js +8 -5
- package/dist/temporal/instant.js +1 -1
- package/dist/temporal/slots.js +6 -6
- package/dist/temporal/system.js +9 -9
- package/dist/themes/context.d.ts +3 -2
- package/dist/themes/context.js +4 -5
- package/dist/themes/themes.js +15 -15
- package/dist/themes/types.d.ts +3 -3
- package/dist/url/assert-safe.d.ts +29 -0
- package/dist/url/assert-safe.js +54 -0
- package/dist/url/parse.js +0 -2
- package/dist/url/predicates.d.ts +31 -1
- package/dist/url/predicates.js +43 -3
- package/dist/url/search-params.js +3 -9
- package/dist/url/types.d.ts +9 -5
- package/dist/versions/_internal.js +3 -3
- package/dist/words/article.js +0 -1
- package/dist/words/capitalize.js +0 -1
- package/dist/words/pluralize.js +15 -5
- package/package.json +419 -216
- package/dist/external-tools/uv/asset-names.d.ts +0 -36
- package/dist/external-tools/uv/asset-names.js +0 -70
- package/dist/external-tools/uv/from-download.d.ts +0 -17
- package/dist/external-tools/uv/from-download.js +0 -47
- package/dist/external-tools/uv/from-path.d.ts +0 -5
- package/dist/external-tools/uv/from-path.js +0 -22
- package/dist/external-tools/uv/from-vfs.d.ts +0 -7
- package/dist/external-tools/uv/from-vfs.js +0 -26
- package/dist/external-tools/uv/resolve.d.ts +0 -25
- package/dist/external-tools/uv/resolve.js +0 -53
- package/dist/external-tools/uv/types.d.ts +0 -24
- package/dist/fs/path-cache.d.ts +0 -21
- package/dist/fs/path-cache.js +0 -34
- package/dist/http-request/checksums.d.ts +0 -69
- package/dist/http-request/checksums.js +0 -108
- package/dist/http-request/http-request.d.ts +0 -12
- package/dist/http-request/http-request.js +0 -11
- package/dist/packages/operations.d.ts +0 -113
- package/dist/packages/operations.js +0 -304
- package/dist/ssri/convert.d.ts +0 -48
- package/dist/ssri/convert.js +0 -69
- package/dist/ssri/parse.d.ts +0 -27
- package/dist/ssri/parse.js +0 -41
- package/dist/ssri/validate.d.ts +0 -41
- package/dist/ssri/validate.js +0 -56
- /package/dist/{bin → cli}/check.d.ts +0 -0
- /package/dist/external-tools/{uv → python}/types.js +0 -0
- /package/dist/fs/{find-up.d.ts → find.d.ts} +0 -0
- /package/dist/github/{fetch.d.ts → request.d.ts} +0 -0
package/dist/crypto/hash.js
CHANGED
|
@@ -7,10 +7,31 @@ const require_node_crypto = require('../node/crypto.js');
|
|
|
7
7
|
/**
|
|
8
8
|
* @file Crypto hash helpers that prefer Node builtins where available. Probes
|
|
9
9
|
* `node:crypto.hash()` (added v21.7.0 / v20.12.0) and falls back to the
|
|
10
|
-
* streaming `createHash().update().digest()` chain on older runtimes.
|
|
10
|
+
* streaming `createHash().update().digest()` chain on older runtimes. Which
|
|
11
|
+
* digest goes where (integrity = sha512 trust boundary; checksum = sha256
|
|
12
|
+
* interop shape; cache keys = truncated, never trust): see
|
|
13
|
+
* `docs/hash-algorithms.md`.
|
|
11
14
|
*/
|
|
12
|
-
let
|
|
13
|
-
let
|
|
15
|
+
let cachedNativeHash;
|
|
16
|
+
let nativeHashProbed = false;
|
|
17
|
+
const BLOB_HASH_PREFIX = "Q";
|
|
18
|
+
/**
|
|
19
|
+
* Compute the Socket content-address of `bytes`: `Q` +
|
|
20
|
+
* base64url(sha256(bytes)).
|
|
21
|
+
*
|
|
22
|
+
* Matches the blob store's hash scheme so a fetched blob can be verified
|
|
23
|
+
* against the hash it was requested by.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ;```typescript
|
|
27
|
+
* import { blobHashOf } from '@socketsecurity/lib/crypto/hash'
|
|
28
|
+
*
|
|
29
|
+
* blobHashOf(new TextEncoder().encode('hello'))
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function blobHashOf(bytes) {
|
|
33
|
+
return BLOB_HASH_PREFIX + hash("sha256", bytes, "base64url");
|
|
34
|
+
}
|
|
14
35
|
/**
|
|
15
36
|
* Compute a one-shot cryptographic hash.
|
|
16
37
|
*
|
|
@@ -33,11 +54,10 @@ let _hashProbed = false;
|
|
|
33
54
|
* // 'z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg=='
|
|
34
55
|
* ```
|
|
35
56
|
*/
|
|
36
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
37
57
|
function hash(algorithm, data, outputEncoding) {
|
|
38
|
-
const native =
|
|
58
|
+
const native = nativeHash();
|
|
39
59
|
if (native !== void 0) return native(algorithm, data, outputEncoding);
|
|
40
|
-
return
|
|
60
|
+
return require_node_crypto.getNodeCrypto().createHash(algorithm).update(data).digest(outputEncoding);
|
|
41
61
|
}
|
|
42
62
|
/**
|
|
43
63
|
* Resolve `crypto.hash` (or `undefined` if the runtime predates it).
|
|
@@ -46,16 +66,30 @@ function hash(algorithm, data, outputEncoding) {
|
|
|
46
66
|
*
|
|
47
67
|
* @internal
|
|
48
68
|
*/
|
|
49
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
50
69
|
function nativeHash() {
|
|
51
|
-
if (!
|
|
52
|
-
const fn =
|
|
53
|
-
if (typeof fn === "function")
|
|
54
|
-
|
|
70
|
+
if (!nativeHashProbed) {
|
|
71
|
+
const fn = require_node_crypto.getNodeCrypto().hash;
|
|
72
|
+
if (typeof fn === "function") cachedNativeHash = fn;
|
|
73
|
+
nativeHashProbed = true;
|
|
55
74
|
}
|
|
56
|
-
return
|
|
75
|
+
return cachedNativeHash;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Throw if `bytes` does not content-address to `blobHash`. Both `Q`-prefixed
|
|
79
|
+
* (single blob) and `S`-prefixed (file-stream) hashes share the sha256 digest
|
|
80
|
+
* body, so both verify against the same digest; the leading discriminator char
|
|
81
|
+
* is dropped before comparison.
|
|
82
|
+
*
|
|
83
|
+
* @throws {Error} When the recomputed digest does not match `blobHash`.
|
|
84
|
+
*/
|
|
85
|
+
function verifyBlobHash(blobHash, bytes) {
|
|
86
|
+
const expectedDigest = blobHash.slice(1);
|
|
87
|
+
const actualDigest = hash("sha256", bytes, "base64url");
|
|
88
|
+
if (actualDigest !== expectedDigest) throw new Error(`blob integrity check failed for ${blobHash}: content hashes to ${BLOB_HASH_PREFIX}${actualDigest}`);
|
|
57
89
|
}
|
|
58
90
|
|
|
59
91
|
//#endregion
|
|
92
|
+
exports.blobHashOf = blobHashOf;
|
|
60
93
|
exports.hash = hash;
|
|
61
|
-
exports.nativeHash = nativeHash;
|
|
94
|
+
exports.nativeHash = nativeHash;
|
|
95
|
+
exports.verifyBlobHash = verifyBlobHash;
|
package/dist/debug/_internal.js
CHANGED
|
@@ -22,7 +22,7 @@ src_external_debug = require_runtime.__toESM(src_external_debug);
|
|
|
22
22
|
*/
|
|
23
23
|
const logger = require_logger_default.getDefaultLogger();
|
|
24
24
|
const debugByNamespace = new require_primordials_map_set.MapCtor();
|
|
25
|
-
let
|
|
25
|
+
let pointingTriangle;
|
|
26
26
|
/**
|
|
27
27
|
* Custom log function for debug output.
|
|
28
28
|
*
|
|
@@ -32,9 +32,8 @@ let _pointingTriangle;
|
|
|
32
32
|
only fires when debugJs emits, which requires DEBUG=* env var
|
|
33
33
|
set at the right module-load timing. Tests use the SOCKET_DEBUG
|
|
34
34
|
path which writes via logger.info directly. */
|
|
35
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
36
35
|
function customLog(...args) {
|
|
37
|
-
const util =
|
|
36
|
+
const util = require_node_util.getNodeUtil();
|
|
38
37
|
const inspectOpts = src_external_debug.default.inspectOpts ? {
|
|
39
38
|
...src_external_debug.default.inspectOpts,
|
|
40
39
|
showHidden: src_external_debug.default.inspectOpts.showHidden === null ? void 0 : src_external_debug.default.inspectOpts.showHidden,
|
|
@@ -53,10 +52,9 @@ function customLog(...args) {
|
|
|
53
52
|
/* c8 ignore start - First-call init for module-level glyph; only
|
|
54
53
|
one of the 5 debug functions hits the body. The unicode-fallback
|
|
55
54
|
arm also fires only on terminals without unicode support. */
|
|
56
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
57
55
|
function getPointingTriangle() {
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
56
|
+
if (pointingTriangle === void 0) pointingTriangle = (0, src_external__socketregistry_is_unicode_supported.default)() ? "▸" : ">";
|
|
57
|
+
return pointingTriangle;
|
|
60
58
|
}
|
|
61
59
|
/* c8 ignore stop */
|
|
62
60
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_primordials_string = require('../primordials/string.js');
|
|
5
4
|
const require_objects_predicates = require('../objects/predicates.js');
|
|
5
|
+
const require_primordials_string = require('../primordials/string.js');
|
|
6
6
|
|
|
7
7
|
//#region src/debug/caller-info.ts
|
|
8
8
|
/**
|
|
@@ -16,7 +16,6 @@ const require_objects_predicates = require('../objects/predicates.js');
|
|
|
16
16
|
*
|
|
17
17
|
* @private
|
|
18
18
|
*/
|
|
19
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
20
19
|
function getCallerInfo(stackOffset = 3) {
|
|
21
20
|
let name = "";
|
|
22
21
|
const captureStackTrace = Error.captureStackTrace;
|
|
@@ -33,14 +32,14 @@ function getCallerInfo(stackOffset = 3) {
|
|
|
33
32
|
if (lineCount < stackOffset) lineStart = i + 1;
|
|
34
33
|
else {
|
|
35
34
|
const line = stack.slice(lineStart, i).trimStart();
|
|
36
|
-
const match = /(?<=^at\s+).*?(
|
|
35
|
+
const match = /(?<=^at\s+).*?(?=$|\s+\()/.exec(line)?.[0];
|
|
37
36
|
/* c8 ignore next - Defensive guard; real V8 stack frames
|
|
38
37
|
always start with 'at '. */
|
|
39
38
|
if (match) {
|
|
40
39
|
name = match.replace(/^(?:async|bound|get|new|set)\s+/, "");
|
|
41
40
|
if (require_primordials_string.StringPrototypeStartsWith(name, "Object.")) {
|
|
42
41
|
const afterDot = require_primordials_string.StringPrototypeSlice(name, 7);
|
|
43
|
-
if (
|
|
42
|
+
if (!require_objects_predicates.hasOwn(Object, afterDot)) name = afterDot;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
break;
|
|
@@ -33,3 +33,10 @@ export declare function isDebugNs(namespaces: string | undefined): boolean;
|
|
|
33
33
|
* @private
|
|
34
34
|
*/
|
|
35
35
|
export declare function isEnabled(namespaces: string | undefined): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether SOCKET_DEBUG enables debug output. A namespace value like `*` or
|
|
38
|
+
* `socket:foo` enables it (these aren't boolean literals, so `envAsBoolean`
|
|
39
|
+
* alone would wrongly read them as false); an explicit boolean-false (`0`,
|
|
40
|
+
* `false`, `no`) or an empty/unset value disables it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isSocketDebugEnabled(): boolean;
|
package/dist/debug/namespace.js
CHANGED
|
@@ -23,7 +23,6 @@ src_external_debug = require_runtime.__toESM(src_external_debug);
|
|
|
23
23
|
*
|
|
24
24
|
* @private
|
|
25
25
|
*/
|
|
26
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
27
26
|
function extractOptions(namespaces) {
|
|
28
27
|
return namespaces !== null && typeof namespaces === "object" ? {
|
|
29
28
|
__proto__: null,
|
|
@@ -38,12 +37,11 @@ function extractOptions(namespaces) {
|
|
|
38
37
|
*
|
|
39
38
|
* @private
|
|
40
39
|
*/
|
|
41
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
42
40
|
function getDebugJsInstance(namespace) {
|
|
43
41
|
let inst = require_debug__internal.debugByNamespace.get(namespace);
|
|
44
42
|
/* c8 ignore start */
|
|
45
43
|
if (inst) return inst;
|
|
46
|
-
if (
|
|
44
|
+
if (!require_env_debug.getDebug() && require_env_socket.getSocketDebug() && (namespace === "error" || namespace === "notice")) src_external_debug.default.enable(namespace);
|
|
47
45
|
/* c8 ignore stop */
|
|
48
46
|
/* c8 ignore next - External debug library call */
|
|
49
47
|
inst = (0, src_external_debug.default)(namespace);
|
|
@@ -54,33 +52,43 @@ function getDebugJsInstance(namespace) {
|
|
|
54
52
|
/**
|
|
55
53
|
* Check if debug mode is enabled.
|
|
56
54
|
*/
|
|
57
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
58
55
|
function isDebug() {
|
|
59
|
-
return
|
|
56
|
+
return isSocketDebugEnabled();
|
|
60
57
|
}
|
|
61
58
|
/**
|
|
62
59
|
* Check if debug mode is enabled.
|
|
63
60
|
*/
|
|
64
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
65
61
|
function isDebugNs(namespaces) {
|
|
66
|
-
return
|
|
62
|
+
return isSocketDebugEnabled() && isEnabled(namespaces);
|
|
67
63
|
}
|
|
68
64
|
/**
|
|
69
65
|
* Check if debug is enabled for given namespaces.
|
|
70
66
|
*
|
|
71
67
|
* @private
|
|
72
68
|
*/
|
|
73
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
74
69
|
function isEnabled(namespaces) {
|
|
75
|
-
if (
|
|
70
|
+
if (!require_env_socket.getSocketDebug()) return false;
|
|
76
71
|
if (typeof namespaces !== "string" || !namespaces || namespaces === "*") return true;
|
|
77
72
|
const split = namespaces.trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
78
73
|
const names = [];
|
|
79
74
|
const skips = [];
|
|
80
75
|
for (const ns of split) if (require_primordials_string.StringPrototypeStartsWith(ns, "-")) skips.push(ns.slice(1));
|
|
81
76
|
else names.push(ns);
|
|
82
|
-
if (names.length && !names.some((ns) =>
|
|
83
|
-
return skips.every((ns) => !
|
|
77
|
+
if (names.length && !names.some((ns) => getDebugJsInstance(ns).enabled)) return false;
|
|
78
|
+
return skips.every((ns) => !getDebugJsInstance(ns).enabled);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Whether SOCKET_DEBUG enables debug output. A namespace value like `*` or
|
|
82
|
+
* `socket:foo` enables it (these aren't boolean literals, so `envAsBoolean`
|
|
83
|
+
* alone would wrongly read them as false); an explicit boolean-false (`0`,
|
|
84
|
+
* `false`, `no`) or an empty/unset value disables it.
|
|
85
|
+
*/
|
|
86
|
+
function isSocketDebugEnabled() {
|
|
87
|
+
const value = require_env_socket.getSocketDebug();
|
|
88
|
+
if (!value) return false;
|
|
89
|
+
const lower = value.trim().toLowerCase();
|
|
90
|
+
if (lower === "0" || lower === "false" || lower === "no") return false;
|
|
91
|
+
return true;
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
//#endregion
|
|
@@ -88,4 +96,5 @@ exports.extractOptions = extractOptions;
|
|
|
88
96
|
exports.getDebugJsInstance = getDebugJsInstance;
|
|
89
97
|
exports.isDebug = isDebug;
|
|
90
98
|
exports.isDebugNs = isDebugNs;
|
|
91
|
-
exports.isEnabled = isEnabled;
|
|
99
|
+
exports.isEnabled = isEnabled;
|
|
100
|
+
exports.isSocketDebugEnabled = isSocketDebugEnabled;
|
package/dist/debug/output.js
CHANGED
|
@@ -39,10 +39,9 @@ function debug(...args) {
|
|
|
39
39
|
* debugCache('miss', 'socket-sdk:scans:xyz', { ttl: 60000 })
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
43
42
|
function debugCache(operation, key, meta) {
|
|
44
|
-
if (
|
|
45
|
-
const prefix = `[CACHE] ${
|
|
43
|
+
if (!require_env_socket.getSocketDebug()) return;
|
|
44
|
+
const prefix = `[CACHE] ${require_debug_caller_info.getCallerInfo(3) || "cache"} ${require_debug__internal.getPointingTriangle()} ${operation}: ${key}`;
|
|
46
45
|
const args = meta !== void 0 ? [prefix, meta] : [prefix];
|
|
47
46
|
require_primordials_reflect.ReflectApply(require_debug__internal.logger.info, require_debug__internal.logger, args);
|
|
48
47
|
}
|
|
@@ -52,10 +51,10 @@ function debugCache(operation, key, meta) {
|
|
|
52
51
|
* message. Optional third argument is metadata object.
|
|
53
52
|
*/
|
|
54
53
|
function debugCacheNs(namespacesOrOpts, operation, key, meta) {
|
|
55
|
-
const options =
|
|
54
|
+
const options = require_debug_namespace.extractOptions(namespacesOrOpts);
|
|
56
55
|
const { namespaces } = options;
|
|
57
|
-
if (
|
|
58
|
-
const prefix = `[CACHE] ${
|
|
56
|
+
if (!require_debug_namespace.isEnabled(namespaces)) return;
|
|
57
|
+
const prefix = `[CACHE] ${require_debug_caller_info.getCallerInfo(4) || "cache"} ${require_debug__internal.getPointingTriangle()} ${operation}: ${key}`;
|
|
59
58
|
const logArgs = meta !== void 0 ? [prefix, meta] : [prefix];
|
|
60
59
|
const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
|
|
61
60
|
const wasSpinning = spinnerInstance?.isSpinning;
|
|
@@ -74,13 +73,13 @@ function debugDir(obj, inspectOpts) {
|
|
|
74
73
|
* Debug output for object inspection with caller info.
|
|
75
74
|
*/
|
|
76
75
|
function debugDirNs(namespacesOrOpts, obj, inspectOpts) {
|
|
77
|
-
const options =
|
|
76
|
+
const options = require_debug_namespace.extractOptions(namespacesOrOpts);
|
|
78
77
|
const { namespaces } = options;
|
|
79
|
-
if (
|
|
78
|
+
if (!require_debug_namespace.isEnabled(namespaces)) return;
|
|
80
79
|
/* c8 ignore start */
|
|
81
|
-
const callerName =
|
|
80
|
+
const callerName = require_debug_caller_info.getCallerInfo(4) || "anonymous";
|
|
82
81
|
/* c8 ignore stop */
|
|
83
|
-
const pointingTriangle =
|
|
82
|
+
const pointingTriangle = require_debug__internal.getPointingTriangle();
|
|
84
83
|
let opts = inspectOpts;
|
|
85
84
|
/* c8 ignore start */
|
|
86
85
|
if (opts === void 0) {
|
|
@@ -109,15 +108,15 @@ function debugLog(...args) {
|
|
|
109
108
|
* Debug logging function with caller info.
|
|
110
109
|
*/
|
|
111
110
|
function debugLogNs(namespacesOrOpts, ...args) {
|
|
112
|
-
const options =
|
|
111
|
+
const options = require_debug_namespace.extractOptions(namespacesOrOpts);
|
|
113
112
|
const { namespaces } = options;
|
|
114
|
-
if (
|
|
113
|
+
if (!require_debug_namespace.isEnabled(namespaces)) return;
|
|
115
114
|
/* c8 ignore start */
|
|
116
|
-
const callerName =
|
|
115
|
+
const callerName = require_debug_caller_info.getCallerInfo(4) || "anonymous";
|
|
117
116
|
/* c8 ignore stop */
|
|
118
|
-
const pointingTriangle =
|
|
117
|
+
const pointingTriangle = require_debug__internal.getPointingTriangle();
|
|
119
118
|
const text = require_primordials_array.ArrayPrototypeAt(args, 0);
|
|
120
|
-
const logArgs = typeof text === "string" ? [
|
|
119
|
+
const logArgs = typeof text === "string" ? [require_strings_format.applyLinePrefix(`${callerName} ${pointingTriangle} ${text}`, { prefix: "[DEBUG] " }), ...require_primordials_array.ArrayPrototypeSlice(args, 1)] : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args];
|
|
121
120
|
const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
|
|
122
121
|
const wasSpinning = spinnerInstance?.isSpinning;
|
|
123
122
|
spinnerInstance?.stop();
|
|
@@ -128,15 +127,15 @@ function debugLogNs(namespacesOrOpts, ...args) {
|
|
|
128
127
|
* Debug output with caller info.
|
|
129
128
|
*/
|
|
130
129
|
function debugNs(namespacesOrOpts, ...args) {
|
|
131
|
-
const options =
|
|
130
|
+
const options = require_debug_namespace.extractOptions(namespacesOrOpts);
|
|
132
131
|
const { namespaces } = options;
|
|
133
|
-
if (
|
|
132
|
+
if (!require_debug_namespace.isEnabled(namespaces)) return;
|
|
134
133
|
/* c8 ignore start */
|
|
135
|
-
const name =
|
|
134
|
+
const name = require_debug_caller_info.getCallerInfo(4) || "anonymous";
|
|
136
135
|
/* c8 ignore stop */
|
|
137
|
-
const pointingTriangle =
|
|
136
|
+
const pointingTriangle = require_debug__internal.getPointingTriangle();
|
|
138
137
|
const text = require_primordials_array.ArrayPrototypeAt(args, 0);
|
|
139
|
-
const logArgs = typeof text === "string" ? [
|
|
138
|
+
const logArgs = typeof text === "string" ? [require_strings_format.applyLinePrefix(`${name} ${pointingTriangle} ${text}`, { prefix: "[DEBUG] " }), ...require_primordials_array.ArrayPrototypeSlice(args, 1)] : args;
|
|
140
139
|
const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
|
|
141
140
|
const wasSpinning = spinnerInstance?.isSpinning;
|
|
142
141
|
spinnerInstance?.stop();
|
|
@@ -147,17 +146,15 @@ function debugNs(namespacesOrOpts, ...args) {
|
|
|
147
146
|
* Create a Node.js util.debuglog compatible function. Returns a function that
|
|
148
147
|
* conditionally writes debug messages to stderr.
|
|
149
148
|
*/
|
|
150
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
151
149
|
function debuglog(section) {
|
|
152
|
-
return
|
|
150
|
+
return require_node_util.getNodeUtil().debuglog(section);
|
|
153
151
|
}
|
|
154
152
|
/**
|
|
155
153
|
* Create timing functions for measuring code execution time. Returns an object
|
|
156
154
|
* with start() and end() methods, plus a callable function.
|
|
157
155
|
*/
|
|
158
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
159
156
|
function debugtime(label) {
|
|
160
|
-
const util =
|
|
157
|
+
const util = require_node_util.getNodeUtil();
|
|
161
158
|
let startTime;
|
|
162
159
|
const impl = () => {
|
|
163
160
|
if (startTime === void 0) startTime = require_primordials_date.DateNow();
|
package/dist/debug/types.d.ts
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
* types, no runtime side effects.
|
|
6
6
|
*/
|
|
7
7
|
export interface DebugOptions {
|
|
8
|
-
namespaces?: string;
|
|
8
|
+
namespaces?: string | undefined;
|
|
9
9
|
spinner?: {
|
|
10
10
|
isSpinning: boolean;
|
|
11
11
|
stop(): void;
|
|
12
12
|
start(): void;
|
|
13
|
-
};
|
|
13
|
+
} | undefined;
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
}
|
|
16
16
|
export type NamespacesOrOptions = string | DebugOptions;
|
|
17
17
|
export interface InspectOptions {
|
|
18
|
-
depth?: number | null;
|
|
19
|
-
colors?: boolean;
|
|
18
|
+
depth?: number | null | undefined;
|
|
19
|
+
colors?: boolean | undefined;
|
|
20
20
|
[key: string]: unknown;
|
|
21
21
|
}
|
package/dist/dlx/arborist.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
5
5
|
const require_primordials_error = require('../primordials/error.js');
|
|
6
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
6
7
|
const require_primordials_array = require('../primordials/array.js');
|
|
7
8
|
const require_node_fs = require('../node/fs.js');
|
|
8
9
|
const require_node_path = require('../node/path.js');
|
|
9
|
-
const require_primordials_object = require('../primordials/object.js');
|
|
10
10
|
const require_primordials_json = require('../primordials/json.js');
|
|
11
11
|
const require_paths_socket = require('../paths/socket.js');
|
|
12
12
|
let src_external__npmcli_arborist = require("../external/@npmcli/arborist");
|
|
@@ -37,6 +37,10 @@ src_external__npmcli_arborist = require_runtime.__toESM(src_external__npmcli_arb
|
|
|
37
37
|
* false.
|
|
38
38
|
*/
|
|
39
39
|
function getBaseArboristOptions(installPath, options) {
|
|
40
|
+
options = {
|
|
41
|
+
__proto__: null,
|
|
42
|
+
...options
|
|
43
|
+
};
|
|
40
44
|
return {
|
|
41
45
|
__proto__: null,
|
|
42
46
|
path: installPath,
|
|
@@ -56,7 +60,7 @@ function getBaseArboristOptions(installPath, options) {
|
|
|
56
60
|
* N deps did we pin?").
|
|
57
61
|
*/
|
|
58
62
|
function readSingleDependency(packageJsonPath) {
|
|
59
|
-
const names = require_primordials_object.ObjectKeys(require_primordials_json.JSONParse(
|
|
63
|
+
const names = require_primordials_object.ObjectKeys(require_primordials_json.JSONParse(require_node_fs.getNodeFs().readFileSync(packageJsonPath, "utf8")).dependencies ?? {});
|
|
60
64
|
if (names.length !== 1) throw new require_primordials_error.ErrorCtor(`safeIdealTree expects exactly one top-level dependency in ${packageJsonPath}, found ${names.length}`);
|
|
61
65
|
return names[0];
|
|
62
66
|
}
|
|
@@ -95,9 +99,12 @@ function readTopLevelFromIdealTree(tree, targetName) {
|
|
|
95
99
|
* with no `add` list skips the write.
|
|
96
100
|
*/
|
|
97
101
|
async function safeIdealTree(options) {
|
|
98
|
-
const fs =
|
|
99
|
-
const path =
|
|
100
|
-
const { before, path: installPath, quiet = true } =
|
|
102
|
+
const fs = require_node_fs.getNodeFs();
|
|
103
|
+
const path = require_node_path.getNodePath();
|
|
104
|
+
const { before, path: installPath, quiet = true } = {
|
|
105
|
+
__proto__: null,
|
|
106
|
+
...options
|
|
107
|
+
};
|
|
101
108
|
const targetName = readSingleDependency(path.join(installPath, "package.json"));
|
|
102
109
|
const arb = new src_external__npmcli_arborist.default({
|
|
103
110
|
...getBaseArboristOptions(installPath, { quiet }),
|
|
@@ -125,7 +132,10 @@ async function safeIdealTree(options) {
|
|
|
125
132
|
* This is the strongest form of pinning pnpm/npm offer.
|
|
126
133
|
*/
|
|
127
134
|
async function safeReify(options) {
|
|
128
|
-
const { packageLock = true, path: installPath, quiet = true } =
|
|
135
|
+
const { packageLock = true, path: installPath, quiet = true } = {
|
|
136
|
+
__proto__: null,
|
|
137
|
+
...options
|
|
138
|
+
};
|
|
129
139
|
/* c8 ignore next - External Arborist call */
|
|
130
140
|
await new src_external__npmcli_arborist.default({
|
|
131
141
|
...getBaseArboristOptions(installPath, { quiet }),
|
|
@@ -146,8 +156,8 @@ async function safeReify(options) {
|
|
|
146
156
|
* pnpm-style equivalent: minimum-release-age=<minutes>
|
|
147
157
|
*/
|
|
148
158
|
async function writeSafeNpmrc(installPath, options) {
|
|
149
|
-
const fs =
|
|
150
|
-
const path =
|
|
159
|
+
const fs = require_node_fs.getNodeFs();
|
|
160
|
+
const path = require_node_path.getNodePath();
|
|
151
161
|
const { minReleaseDays, minReleaseMins } = {
|
|
152
162
|
__proto__: null,
|
|
153
163
|
...options
|
package/dist/dlx/binary-cache.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
5
|
+
const require_objects_predicates = require('../objects/predicates.js');
|
|
5
6
|
const require_primordials_string = require('../primordials/string.js');
|
|
6
7
|
const require_primordials_array = require('../primordials/array.js');
|
|
7
8
|
const require_node_fs = require('../node/fs.js');
|
|
@@ -9,7 +10,6 @@ const require_node_path = require('../node/path.js');
|
|
|
9
10
|
const require_primordials_date = require('../primordials/date.js');
|
|
10
11
|
const require_primordials_json = require('../primordials/json.js');
|
|
11
12
|
const require_fs_read_json = require('../fs/read-json.js');
|
|
12
|
-
const require_objects_predicates = require('../objects/predicates.js');
|
|
13
13
|
const require_paths_socket = require('../paths/socket.js');
|
|
14
14
|
const require_fs_safe = require('../fs/safe.js');
|
|
15
15
|
const require_constants_time = require('../constants/time.js');
|
|
@@ -43,18 +43,18 @@ node_process = require_runtime.__toESM(node_process);
|
|
|
43
43
|
*/
|
|
44
44
|
async function cleanDlxCache(maxAge = require_constants_time.DLX_BINARY_CACHE_TTL) {
|
|
45
45
|
const cacheDir = getDlxCachePath();
|
|
46
|
-
const fs =
|
|
46
|
+
const fs = require_node_fs.getNodeFs();
|
|
47
47
|
if (!fs.existsSync(cacheDir)) return 0;
|
|
48
48
|
let cleaned = 0;
|
|
49
49
|
const now = require_primordials_date.DateNow();
|
|
50
|
-
const path =
|
|
50
|
+
const path = require_node_path.getNodePath();
|
|
51
51
|
const entries = await fs.promises.readdir(cacheDir);
|
|
52
52
|
for (const entry of entries) {
|
|
53
53
|
const entryPath = path.join(cacheDir, entry);
|
|
54
54
|
const metaPath = getBinaryCacheMetadataPath(entryPath);
|
|
55
55
|
try {
|
|
56
56
|
if (!await (0, node_fs.existsSync)(entryPath)) continue;
|
|
57
|
-
const metadata = await
|
|
57
|
+
const metadata = await require_fs_read_json.readJson(metaPath, { throws: false });
|
|
58
58
|
if (!metadata || typeof metadata !== "object" || require_primordials_array.ArrayIsArray(metadata)) continue;
|
|
59
59
|
const timestamp = metadata["timestamp"];
|
|
60
60
|
const age = typeof timestamp === "number" && timestamp > 0 ? now - timestamp : Number.POSITIVE_INFINITY;
|
|
@@ -86,7 +86,7 @@ async function cleanDlxCache(maxAge = require_constants_time.DLX_BINARY_CACHE_TT
|
|
|
86
86
|
* ```
|
|
87
87
|
*/
|
|
88
88
|
function getBinaryCacheMetadataPath(cacheEntryPath) {
|
|
89
|
-
return
|
|
89
|
+
return require_node_path.getNodePath().join(cacheEntryPath, ".dlx-metadata.json");
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Get the DLX binary cache directory path. Alias of `getSocketDlxDir` — DLX
|
|
@@ -111,12 +111,12 @@ const getDlxCachePath = require_paths_socket.getSocketDlxDir;
|
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
113
|
async function isBinaryCacheValid(cacheEntryPath, cacheTtl) {
|
|
114
|
-
const fs =
|
|
114
|
+
const fs = require_node_fs.getNodeFs();
|
|
115
115
|
try {
|
|
116
116
|
const metaPath = getBinaryCacheMetadataPath(cacheEntryPath);
|
|
117
117
|
if (!fs.existsSync(metaPath)) return false;
|
|
118
|
-
const metadata = await
|
|
119
|
-
if (
|
|
118
|
+
const metadata = await require_fs_read_json.readJson(metaPath, { throws: false });
|
|
119
|
+
if (!require_objects_predicates.isPlainObject(metadata)) return false;
|
|
120
120
|
const now = require_primordials_date.DateNow();
|
|
121
121
|
const timestamp = metadata["timestamp"];
|
|
122
122
|
if (typeof timestamp !== "number" || timestamp <= 0) return false;
|
|
@@ -140,17 +140,17 @@ async function isBinaryCacheValid(cacheEntryPath, cacheTtl) {
|
|
|
140
140
|
*/
|
|
141
141
|
async function listDlxCache() {
|
|
142
142
|
const cacheDir = getDlxCachePath();
|
|
143
|
-
const fs =
|
|
143
|
+
const fs = require_node_fs.getNodeFs();
|
|
144
144
|
if (!fs.existsSync(cacheDir)) return [];
|
|
145
145
|
const results = [];
|
|
146
146
|
const now = require_primordials_date.DateNow();
|
|
147
|
-
const path =
|
|
147
|
+
const path = require_node_path.getNodePath();
|
|
148
148
|
const entries = await fs.promises.readdir(cacheDir);
|
|
149
149
|
for (const entry of entries) {
|
|
150
150
|
const entryPath = path.join(cacheDir, entry);
|
|
151
151
|
try {
|
|
152
152
|
if (!await (0, node_fs.existsSync)(entryPath)) continue;
|
|
153
|
-
const metadata = await
|
|
153
|
+
const metadata = await require_fs_read_json.readJson(getBinaryCacheMetadataPath(entryPath), { throws: false });
|
|
154
154
|
if (!metadata || typeof metadata !== "object" || require_primordials_array.ArrayIsArray(metadata)) continue;
|
|
155
155
|
const metaObj = metadata;
|
|
156
156
|
const url = metaObj["source"]?.["url"] || metaObj["url"] || "";
|
|
@@ -185,12 +185,12 @@ async function listDlxCache() {
|
|
|
185
185
|
* ```
|
|
186
186
|
*/
|
|
187
187
|
async function readBinaryCacheMetadata(cacheEntryPath) {
|
|
188
|
-
const fs =
|
|
188
|
+
const fs = require_node_fs.getNodeFs();
|
|
189
189
|
try {
|
|
190
190
|
const metaPath = getBinaryCacheMetadataPath(cacheEntryPath);
|
|
191
191
|
if (!fs.existsSync(metaPath)) return;
|
|
192
|
-
const metadata = await
|
|
193
|
-
if (
|
|
192
|
+
const metadata = await require_fs_read_json.readJson(metaPath, { throws: false });
|
|
193
|
+
if (!require_objects_predicates.isPlainObject(metadata)) return;
|
|
194
194
|
return metadata;
|
|
195
195
|
} catch {
|
|
196
196
|
return;
|
|
@@ -224,7 +224,7 @@ async function writeBinaryCacheMetadata(cacheEntryPath, cacheKey, url, integrity
|
|
|
224
224
|
url
|
|
225
225
|
}
|
|
226
226
|
};
|
|
227
|
-
const fs =
|
|
227
|
+
const fs = require_node_fs.getNodeFs();
|
|
228
228
|
const tmpPath = `${metaPath}.tmp.${node_process.default.pid}`;
|
|
229
229
|
await fs.promises.writeFile(tmpPath, require_primordials_json.JSONStringify(metadata, null, 2));
|
|
230
230
|
await fs.promises.rename(tmpPath, metaPath);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { DlxBinaryOptions } from './binary-types';
|
|
10
10
|
/**
|
|
11
11
|
* Download a binary from a URL with caching (without execution). Similar to
|
|
12
|
-
*
|
|
12
|
+
* downloadNpmPackage from dlx/package.
|
|
13
13
|
*
|
|
14
14
|
* Returns `{binaryPath, downloaded, integrity}`. The `integrity` field is the
|
|
15
15
|
* SRI-formatted `sha512-<base64>` hash of the cached file — computed by the
|
|
@@ -31,7 +31,7 @@ node_process = require_runtime.__toESM(node_process);
|
|
|
31
31
|
*/
|
|
32
32
|
/**
|
|
33
33
|
* Download a binary from a URL with caching (without execution). Similar to
|
|
34
|
-
*
|
|
34
|
+
* downloadNpmPackage from dlx/package.
|
|
35
35
|
*
|
|
36
36
|
* Returns `{binaryPath, downloaded, integrity}`. The `integrity` field is the
|
|
37
37
|
* SRI-formatted `sha512-<base64>` hash of the cached file — computed by the
|
|
@@ -70,20 +70,20 @@ async function downloadBinary(options) {
|
|
|
70
70
|
if (normalized.type === "integrity") integrity = normalized.value;
|
|
71
71
|
else sha256 = normalized.value;
|
|
72
72
|
}
|
|
73
|
-
const fs =
|
|
74
|
-
const path =
|
|
73
|
+
const fs = require_node_fs.getNodeFs();
|
|
74
|
+
const path = require_node_path.getNodePath();
|
|
75
75
|
const cacheDir = require_dlx_binary_cache.getDlxCachePath();
|
|
76
76
|
const binaryName = name || `binary-${node_process.default.platform}-${require_constants_platform.getArch()}`;
|
|
77
77
|
const cacheKey = require_dlx_cache.generateCacheKey(`${url}:${binaryName}`);
|
|
78
78
|
const cacheEntryDir = path.join(cacheDir, cacheKey);
|
|
79
|
-
const binaryPath =
|
|
79
|
+
const binaryPath = require_paths_normalize.normalizePath(path.join(cacheEntryDir, binaryName));
|
|
80
80
|
let downloaded = false;
|
|
81
81
|
let actualIntegrity = "";
|
|
82
82
|
if (!force && fs.existsSync(cacheEntryDir) && await require_dlx_binary_cache.isBinaryCacheValid(cacheEntryDir, cacheTtl)) {
|
|
83
83
|
downloaded = false;
|
|
84
84
|
const cachedMeta = await require_dlx_binary_cache.readBinaryCacheMetadata(cacheEntryDir);
|
|
85
85
|
if (cachedMeta?.integrity) actualIntegrity = cachedMeta.integrity;
|
|
86
|
-
else actualIntegrity = `sha512-${
|
|
86
|
+
else actualIntegrity = `sha512-${require_crypto_hash.hash("sha512", await fs.promises.readFile(binaryPath), "base64")}`;
|
|
87
87
|
} else {
|
|
88
88
|
try {
|
|
89
89
|
await require_fs_safe.safeMkdir(cacheEntryDir);
|
|
@@ -128,9 +128,9 @@ async function downloadBinary(options) {
|
|
|
128
128
|
* ```
|
|
129
129
|
*/
|
|
130
130
|
async function downloadBinaryFile(url, destPath, integrity, sha256) {
|
|
131
|
-
const crypto =
|
|
132
|
-
const fs =
|
|
133
|
-
const path =
|
|
131
|
+
const crypto = require_node_crypto.getNodeCrypto();
|
|
132
|
+
const fs = require_node_fs.getNodeFs();
|
|
133
|
+
const path = require_node_path.getNodePath();
|
|
134
134
|
const cacheEntryDir = path.dirname(destPath);
|
|
135
135
|
const lockPath = path.join(cacheEntryDir, "concurrency.lock");
|
|
136
136
|
const verifyIntegrity = async (actualIntegrity) => {
|
|
@@ -142,7 +142,7 @@ async function downloadBinaryFile(url, destPath, integrity, sha256) {
|
|
|
142
142
|
};
|
|
143
143
|
const verifyCachedSha256 = async (fileBuffer) => {
|
|
144
144
|
if (!sha256) return;
|
|
145
|
-
const actualSha256 =
|
|
145
|
+
const actualSha256 = require_crypto_hash.hash("sha256", fileBuffer, "hex");
|
|
146
146
|
if (!(actualSha256.length === sha256.length && crypto.timingSafeEqual(require_primordials_buffer.BufferFrom(actualSha256), Buffer.from(sha256.toLowerCase())))) {
|
|
147
147
|
await require_fs_safe.safeDelete(destPath);
|
|
148
148
|
throw new require_primordials_error.ErrorCtor(`SHA-256 mismatch: expected ${sha256}, got ${actualSha256}`);
|
|
@@ -152,7 +152,7 @@ async function downloadBinaryFile(url, destPath, integrity, sha256) {
|
|
|
152
152
|
if (fs.existsSync(destPath)) {
|
|
153
153
|
if ((await fs.promises.stat(destPath)).size > 0) {
|
|
154
154
|
const fileBuffer = await fs.promises.readFile(destPath);
|
|
155
|
-
const actualIntegrity = `sha512-${
|
|
155
|
+
const actualIntegrity = `sha512-${require_crypto_hash.hash("sha512", fileBuffer, "base64")}`;
|
|
156
156
|
await verifyIntegrity(actualIntegrity);
|
|
157
157
|
await verifyCachedSha256(fileBuffer);
|
|
158
158
|
return actualIntegrity;
|
|
@@ -163,7 +163,7 @@ async function downloadBinaryFile(url, destPath, integrity, sha256) {
|
|
|
163
163
|
} catch (e) {
|
|
164
164
|
throw new require_primordials_error.ErrorCtor(`Failed to download binary from ${url}\nDestination: ${destPath}\nCheck your internet connection or verify the URL is accessible.`, { cause: e });
|
|
165
165
|
}
|
|
166
|
-
const actualIntegrity = `sha512-${
|
|
166
|
+
const actualIntegrity = `sha512-${require_crypto_hash.hash("sha512", await fs.promises.readFile(destPath), "base64")}`;
|
|
167
167
|
await verifyIntegrity(actualIntegrity);
|
|
168
168
|
if (!require_constants_platform.WIN32) await fs.promises.chmod(destPath, 493);
|
|
169
169
|
return actualIntegrity;
|