@socketsecurity/lib 6.0.7 → 6.0.9
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 +42 -0
- 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 +4 -0
- package/dist/ai/discover.js +1 -1
- 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 +82 -0
- package/dist/ai/route.js +171 -0
- package/dist/ai/spawn.d.mts +42 -2
- package/dist/ai/spawn.js +146 -33
- 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 +25 -2
- package/dist/ai/worktree.js +4 -0
- package/dist/archives/tar.js +1 -1
- package/dist/archives/zip.js +2 -2
- package/dist/argv/parse.d.ts +19 -2
- package/dist/argv/parse.js +1 -1
- package/dist/arrays/join.js +4 -0
- package/dist/bin/find.js +4 -4
- package/dist/bin/prim.cjs +23322 -18018
- package/dist/bin/resolve.js +2 -2
- package/dist/cache/ttl/store.js +2 -2
- package/dist/cli/check-primordials.d.ts +8 -3
- package/dist/cli/check-primordials.js +4 -4
- package/dist/compression/_internal.js +1 -1
- package/dist/compression/brotli.d.ts +1 -2
- package/dist/compression/brotli.js +5 -1
- package/dist/compression/gzip.js +5 -1
- package/dist/config/layers.d.ts +53 -0
- package/dist/config/layers.js +83 -0
- package/dist/constants/packages.d.ts +3 -0
- package/dist/constants/packages.js +2 -1
- package/dist/constants/socket.d.ts +2 -6
- package/dist/constants/socket.js +12 -14
- package/dist/cover/code.js +2 -2
- package/dist/crypto/hash.d.ts +4 -1
- package/dist/crypto/hash.js +4 -1
- package/dist/dlx/arborist.js +13 -3
- package/dist/dlx/binary-cache.js +1 -1
- package/dist/dlx/binary-resolution.js +1 -1
- package/dist/dlx/detect.d.ts +8 -0
- package/dist/dlx/firewall.d.ts +8 -0
- package/dist/dlx/lockfile.js +5 -2
- package/dist/dlx/manifest.js +1 -1
- package/dist/dlx/package.js +4 -0
- package/dist/eco/cargo/parse-lockfile.d.ts +1 -2
- package/dist/eco/cargo/parse-lockfile.js +3 -3
- package/dist/eco/manifest/detect-format.js +1 -1
- package/dist/eco/npm/npm/parse-lockfile.d.ts +3 -4
- package/dist/eco/npm/npm/parse-lockfile.js +2 -2
- package/dist/eco/npm/parse-package-json.d.ts +11 -0
- package/dist/eco/npm/parse-package-json.js +1 -1
- package/dist/eco/npm/pnpm/parse-lockfile.d.ts +5 -3
- package/dist/eco/npm/pnpm/parse-lockfile.js +3 -3
- package/dist/eco/npm/yarnpkg/yarn/exec.js +1 -1
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +1 -2
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +2 -2
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +6 -3
- package/dist/env/rewire.js +7 -8
- package/dist/env/socket.d.ts +7 -0
- package/dist/env/socket.js +10 -0
- package/dist/env/xdg.d.ts +17 -0
- package/dist/env/xdg.js +21 -1
- package/dist/errors/predicates.js +1 -1
- package/dist/errors/stack.js +1 -2
- package/dist/external/@npmcli/package-json.js +3455 -4881
- package/dist/external/@npmcli/promise-spawn.js +3 -1
- package/dist/external/@yarnpkg/extensions.js +1 -1
- package/dist/external/external-pack.js +1 -1
- package/dist/external/npm-pack.js +29164 -31799
- package/dist/external/pico-pack.js +4 -2
- package/dist/external/tar-fs.js +63 -16
- 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/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/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/resolve.d.ts +3 -3
- package/dist/external-tools/cdxgen/resolve.js +16 -8
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +11 -5
- 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/resolve.d.ts +3 -3
- package/dist/external-tools/janus/resolve.js +16 -8
- 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.js +1 -1
- 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 +2 -2
- package/dist/external-tools/jre/resolve.d.ts +3 -3
- package/dist/external-tools/jre/resolve.js +16 -8
- package/dist/external-tools/manifest.d.ts +18 -0
- package/dist/external-tools/manifest.js +2 -2
- 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/resolve.d.ts +3 -3
- package/dist/external-tools/opengrep/resolve.js +16 -8
- package/dist/external-tools/python/asset-names.d.ts +1 -1
- package/dist/external-tools/python/asset-names.js +11 -4
- package/dist/external-tools/python/dlx.d.ts +3 -3
- package/dist/external-tools/python/dlx.js +20 -9
- package/dist/external-tools/python/from-download.d.ts +1 -1
- package/dist/external-tools/python/from-download.js +12 -5
- package/dist/external-tools/python/pin.js +6 -3
- package/dist/external-tools/python/pip-install.js +6 -3
- package/dist/external-tools/python/resolve.d.ts +3 -3
- package/dist/external-tools/python/resolve.js +19 -11
- package/dist/external-tools/python/uv-install.d.ts +89 -0
- package/dist/external-tools/python/uv-install.js +165 -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/resolve.d.ts +3 -3
- package/dist/external-tools/sbt/resolve.js +16 -8
- 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-uv.d.ts +30 -0
- package/dist/external-tools/skillspector/from-uv.js +56 -0
- package/dist/external-tools/skillspector/resolve.d.ts +20 -5
- package/dist/external-tools/skillspector/resolve.js +27 -6
- package/dist/external-tools/skillspector/types.d.ts +3 -1
- 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 +5 -2
- 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/resolve.d.ts +3 -3
- package/dist/external-tools/trivy/resolve.js +16 -8
- 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/resolve.d.ts +3 -3
- package/dist/external-tools/trufflehog/resolve.js +16 -8
- package/dist/external-tools/uv/asset-names.d.ts +36 -0
- package/dist/external-tools/uv/asset-names.js +73 -0
- package/dist/external-tools/uv/from-download.d.ts +17 -0
- package/dist/external-tools/uv/from-download.js +50 -0
- package/dist/external-tools/uv/from-path.d.ts +5 -0
- package/dist/external-tools/uv/from-path.js +22 -0
- package/dist/external-tools/uv/from-vfs.d.ts +7 -0
- package/dist/external-tools/uv/from-vfs.js +26 -0
- package/dist/external-tools/uv/resolve.d.ts +25 -0
- package/dist/external-tools/uv/resolve.js +61 -0
- package/dist/external-tools/uv/types.d.ts +24 -0
- package/dist/external-tools/uv/types.js +2 -0
- package/dist/fleet/repo-config.d.ts +53 -0
- package/dist/fleet/repo-config.js +79 -0
- package/dist/fs/allowed-dirs-cache.d.ts +27 -1
- package/dist/fs/allowed-dirs-cache.js +39 -6
- package/dist/fs/copy.d.ts +88 -0
- package/dist/fs/copy.js +89 -0
- package/dist/fs/find.js +1 -1
- package/dist/fs/read-json-cache.d.ts +7 -0
- package/dist/fs/resolve-module.js +6 -2
- package/dist/fs/safe.js +1 -1
- package/dist/git/_internal.js +3 -3
- package/dist/git/repo.js +2 -4
- package/dist/git/staged.js +8 -0
- package/dist/git/tracked.d.ts +84 -0
- package/dist/git/tracked.js +163 -0
- package/dist/git/unstaged.js +8 -0
- package/dist/github/refs-graphql.js +4 -0
- package/dist/github/refs-rest.js +4 -0
- package/dist/globs/_internal.js +1 -1
- package/dist/globs/match.js +9 -1
- package/dist/globs/matcher.js +5 -1
- package/dist/http-request/browser.js +7 -3
- package/dist/http-request/checksum-file.js +1 -1
- 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 -1
- package/dist/http-request/request-attempt.js +2 -2
- package/dist/http-request/user-agent.js +1 -1
- package/dist/integrity.d.ts +124 -71
- package/dist/integrity.js +168 -78
- package/dist/json/edit.js +38 -30
- package/dist/json/format.js +1 -1
- package/dist/logger/colors.d.ts +1 -2
- package/dist/logger/colors.js +2 -2
- package/dist/logger/symbols-builder.js +7 -8
- package/dist/logger/symbols.js +8 -8
- package/dist/native-messaging/install.d.ts +1 -1
- package/dist/native-messaging/install.js +7 -4
- package/dist/native-messaging/rate-limit.d.ts +7 -0
- package/dist/native-messaging/rate-limit.js +4 -0
- package/dist/node/async-hooks.js +1 -1
- package/dist/node/child-process.js +1 -1
- package/dist/node/crypto.js +1 -1
- package/dist/node/events.js +1 -1
- package/dist/node/fs-promises.js +1 -1
- package/dist/node/fs.d.ts +22 -6
- package/dist/node/fs.js +16 -3
- package/dist/node/http.js +1 -1
- package/dist/node/https.js +1 -1
- package/dist/node/module.d.ts +73 -2
- package/dist/node/module.js +97 -12
- package/dist/node/os.d.ts +10 -2
- package/dist/node/os.js +11 -4
- package/dist/node/path.d.ts +11 -2
- package/dist/node/path.js +17 -4
- package/dist/node/timers-promises.js +1 -1
- package/dist/node/url.js +1 -1
- package/dist/node/util.js +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/objects/mutate.js +2 -2
- package/dist/packages/edit-class.d.ts +2 -3
- package/dist/packages/edit-class.js +41 -35
- package/dist/packages/exports.js +4 -4
- package/dist/packages/fetch.js +1 -1
- package/dist/packages/isolation.js +2 -2
- package/dist/packages/licenses.js +2 -2
- package/dist/packages/manifest.d.ts +29 -0
- package/dist/packages/manifest.js +40 -4
- package/dist/packages/normalize.js +2 -2
- package/dist/packages/provenance.js +3 -3
- package/dist/packages/specs.js +1 -1
- package/dist/packages/tarball.js +4 -2
- package/dist/packages/types.d.ts +1 -2
- package/dist/paths/_internal.d.ts +1 -7
- package/dist/paths/_internal.js +9 -15
- package/dist/paths/conversion.js +1 -1
- package/dist/paths/dirnames.d.ts +1 -0
- package/dist/paths/dirnames.js +2 -0
- package/dist/paths/normalize.js +1 -1
- package/dist/paths/predicates.js +2 -1
- package/dist/paths/resolve.js +14 -19
- package/dist/paths/rewire.d.ts +5 -0
- package/dist/paths/socket.d.ts +137 -123
- package/dist/paths/socket.js +172 -131
- package/dist/perf/metrics.js +1 -1
- package/dist/perf/report.js +1 -1
- package/dist/primordials/process.d.ts +88 -0
- package/dist/primordials/process.js +132 -0
- package/dist/primordials/uncurry.d.ts +1 -2
- package/dist/process/spawn/child.js +8 -2
- package/dist/process/spawn/errors.js +1 -1
- package/dist/releases/github-archives.js +1 -1
- package/dist/releases/github-listing.d.ts +1 -2
- package/dist/schema/types.d.ts +3 -4
- package/dist/schema/validate.js +1 -1
- package/dist/secrets/broker.d.ts +35 -0
- package/dist/secrets/broker.js +72 -0
- package/dist/secrets/find.d.ts +8 -6
- package/dist/secrets/find.js +25 -5
- package/dist/secrets/keychain.d.ts +1 -1
- package/dist/secrets/linux.js +32 -44
- package/dist/secrets/macos.d.ts +1 -2
- package/dist/secrets/macos.js +20 -29
- package/dist/secrets/rc.d.ts +2 -2
- package/dist/secrets/rc.js +21 -13
- package/dist/secrets/socket-api-token.js +8 -0
- package/dist/secrets/windows.js +27 -33
- package/dist/shell/parse.d.ts +32 -0
- package/dist/shell/parse.js +60 -0
- package/dist/smol/detect.js +1 -1
- package/dist/smol/http.js +1 -1
- package/dist/smol/https.js +1 -1
- package/dist/smol/manifest.js +1 -1
- package/dist/smol/path.js +1 -1
- package/dist/smol/primordial.js +1 -1
- package/dist/smol/purl.js +1 -1
- package/dist/smol/versions.js +1 -1
- package/dist/smol/vfs.js +1 -1
- package/dist/sorts/_internal.d.ts +1 -2
- package/dist/sorts/_internal.js +2 -6
- package/dist/sorts/semver.js +2 -2
- package/dist/spinner/create-spinner-class.js +2 -2
- package/dist/spinner/spinner-internals.d.ts +1 -1
- package/dist/spinner/spinner-internals.js +9 -5
- package/dist/spinner/spinner.d.ts +4 -0
- package/dist/spinner/spinner.js +1 -1
- package/dist/stdio/progress.js +6 -2
- package/dist/stdio/prompts.d.ts +2 -10
- package/dist/stdio/prompts.js +11 -24
- package/dist/strings/format.js +1 -1
- package/dist/strings/search.js +1 -1
- package/dist/temporal/instant.js +2 -2
- package/dist/themes/context.d.ts +5 -3
- package/dist/themes/context.js +5 -6
- package/dist/url/assert-safe.d.ts +29 -0
- package/dist/url/assert-safe.js +54 -0
- package/dist/url/predicates.d.ts +31 -1
- package/dist/url/predicates.js +42 -1
- package/dist/url/types.d.ts +4 -0
- package/llms.txt +750 -0
- package/package.json +253 -125
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_string = require('../primordials/string.js');
|
|
5
|
+
const require_paths_normalize = require('../paths/normalize.js');
|
|
6
|
+
const require_primordials_array = require('../primordials/array.js');
|
|
7
|
+
const require_node_path = require('../node/path.js');
|
|
8
|
+
const require_process_spawn_child = require('../process/spawn/child.js');
|
|
9
|
+
const require_git_repo = require('./repo.js');
|
|
10
|
+
|
|
11
|
+
//#region src/git/tracked.ts
|
|
12
|
+
/**
|
|
13
|
+
* @file Tracked-status + submodule-membership probes for a working-tree path.
|
|
14
|
+
* `isTracked` answers "does git track this exact path?"; `getSubmodulePaths`
|
|
15
|
+
* lists the repo's submodule mount points; `isInSubmodule` answers "does this
|
|
16
|
+
* path live inside one?"; `isUntrackedNonSubmodulePath` composes them into
|
|
17
|
+
* the safe-to-touch condition for cleanup tooling — never delete a tracked
|
|
18
|
+
* file or reach into a submodule's own tree (which would dirty it).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The repo's submodule mount points as normalized, repo-root-relative paths
|
|
22
|
+
* (e.g. `vendor/acorn`). Reads `git config` on `.gitmodules`, so it lists
|
|
23
|
+
* declared submodules whether or not they are initialized — the case a
|
|
24
|
+
* stderr-message check on `git ls-files` misses.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ;```typescript
|
|
28
|
+
* await getSubmodulePaths()
|
|
29
|
+
* // => ['packages/acorn/upstream/acorn', 'vendor/mbedtls']
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
async function getSubmodulePaths(options) {
|
|
33
|
+
const { cwd = require_git_repo.getCwd() } = {
|
|
34
|
+
__proto__: null,
|
|
35
|
+
...options
|
|
36
|
+
};
|
|
37
|
+
const lines = require_primordials_string.StringPrototypeSplit(await require_process_spawn_child.spawn("git", [
|
|
38
|
+
"config",
|
|
39
|
+
"--file",
|
|
40
|
+
".gitmodules",
|
|
41
|
+
"--get-regexp",
|
|
42
|
+
"path"
|
|
43
|
+
], {
|
|
44
|
+
cwd,
|
|
45
|
+
stdioString: true
|
|
46
|
+
}).then(
|
|
47
|
+
/* c8 ignore next - stdioString:true always yields a string stdout; the
|
|
48
|
+
?? '' is a defensive fallback that never fires on real spawn output. */
|
|
49
|
+
(result) => String(result?.stdout ?? ""),
|
|
50
|
+
() => ""
|
|
51
|
+
), "\n");
|
|
52
|
+
const paths = [];
|
|
53
|
+
for (let i = 0, { length } = lines; i < length; i += 1) {
|
|
54
|
+
const line = require_primordials_string.StringPrototypeTrim(lines[i]);
|
|
55
|
+
/* c8 ignore start - defensive parse guards: `git config --get-regexp`
|
|
56
|
+
always emits a `key value` line, so the blank-line and no-space skips
|
|
57
|
+
and the empty-value branch never fire on real git output. */
|
|
58
|
+
if (!line) continue;
|
|
59
|
+
const spaceIdx = line.indexOf(" ");
|
|
60
|
+
if (spaceIdx === -1) continue;
|
|
61
|
+
const rel = require_primordials_string.StringPrototypeTrim(line.slice(spaceIdx + 1));
|
|
62
|
+
if (!rel) continue;
|
|
63
|
+
/* c8 ignore stop */
|
|
64
|
+
paths.push(require_paths_normalize.normalizePath(rel));
|
|
65
|
+
}
|
|
66
|
+
return paths;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether `targetPath` lives inside one of the repo's submodules. Resolves the
|
|
70
|
+
* submodule list itself; for a batch sweep prefer `getSubmodulePaths` once plus
|
|
71
|
+
* `pathIsUnderSubmodule` per path.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ;```typescript
|
|
75
|
+
* await isInSubmodule('vendor/mbedtls/x.py') // => true
|
|
76
|
+
* await isInSubmodule('src/index.ts') // => false
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
async function isInSubmodule(targetPath, options) {
|
|
80
|
+
const submodulePaths = await getSubmodulePaths(options);
|
|
81
|
+
if (!submodulePaths.length) return false;
|
|
82
|
+
return pathIsUnderSubmodule(targetPath, submodulePaths);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Whether git tracks `targetPath` exactly. Uses `git ls-files --error-unmatch`,
|
|
86
|
+
* which exits non-zero for an untracked path. A path inside a submodule, or one
|
|
87
|
+
* git does not know, returns `false`.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ;```typescript
|
|
91
|
+
* await isTracked('src/index.ts') // => true
|
|
92
|
+
* await isTracked('.DS_Store') // => false
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
async function isTracked(targetPath, options) {
|
|
96
|
+
const { cwd = require_git_repo.getCwd() } = {
|
|
97
|
+
__proto__: null,
|
|
98
|
+
...options
|
|
99
|
+
};
|
|
100
|
+
return await require_process_spawn_child.spawn("git", [
|
|
101
|
+
"ls-files",
|
|
102
|
+
"--error-unmatch",
|
|
103
|
+
targetPath
|
|
104
|
+
], {
|
|
105
|
+
cwd,
|
|
106
|
+
stdioString: true
|
|
107
|
+
}).then(() => true, () => false);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Whether `targetPath` is git does NOT track AND does not live inside a
|
|
111
|
+
* submodule — the safe-to-touch condition for cleanup tooling. A tracked path
|
|
112
|
+
* is a deliberate file; a submodule-internal path belongs to that submodule's
|
|
113
|
+
* own git (touching it would dirty the submodule). Composes `isTracked` +
|
|
114
|
+
* `getSubmodulePaths`/`pathIsUnderSubmodule`. Fails closed — any check error
|
|
115
|
+
* resolves to `false`.
|
|
116
|
+
*
|
|
117
|
+
* For a batch sweep, call `getSubmodulePaths` once and compose `isTracked` +
|
|
118
|
+
* `pathIsUnderSubmodule` per path to avoid re-reading `.gitmodules` each time.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ;```typescript
|
|
122
|
+
* await isUntrackedNonSubmodulePath('.DS_Store') // => true
|
|
123
|
+
* await isUntrackedNonSubmodulePath('src/index.ts') // => false (tracked)
|
|
124
|
+
* await isUntrackedNonSubmodulePath('vendor/sub/x.pyc') // => false (submodule)
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
async function isUntrackedNonSubmodulePath(targetPath, options) {
|
|
128
|
+
const { cwd = require_git_repo.getCwd() } = {
|
|
129
|
+
__proto__: null,
|
|
130
|
+
...options
|
|
131
|
+
};
|
|
132
|
+
if (await isTracked(targetPath, { cwd }).catch(() => true)) return false;
|
|
133
|
+
const submodulePaths = await getSubmodulePaths({ cwd }).catch(() => []);
|
|
134
|
+
if (submodulePaths.length) {
|
|
135
|
+
const path = require_node_path.getNodePath();
|
|
136
|
+
if (pathIsUnderSubmodule(path.relative(cwd, path.resolve(cwd, targetPath)), submodulePaths)) return false;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Whether `relativePath` (repo-root-relative) lies at or under any of
|
|
142
|
+
* `submodulePaths`. Pure — pass the result of `getSubmodulePaths` so the git
|
|
143
|
+
* read happens once for a whole sweep.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ;```typescript
|
|
147
|
+
* pathIsUnderSubmodule('vendor/mbedtls/scripts/__pycache__', ['vendor/mbedtls'])
|
|
148
|
+
* // => true
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
function pathIsUnderSubmodule(relativePath, submodulePaths) {
|
|
152
|
+
const normalized = require_paths_normalize.normalizePath(relativePath);
|
|
153
|
+
return require_primordials_array.ArrayPrototypeSome(submodulePaths, (sub) => {
|
|
154
|
+
return normalized === sub || require_primordials_string.StringPrototypeStartsWith(normalized, `${sub}/`) || require_primordials_string.StringPrototypeEndsWith(sub, normalized);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
exports.getSubmodulePaths = getSubmodulePaths;
|
|
160
|
+
exports.isInSubmodule = isInSubmodule;
|
|
161
|
+
exports.isTracked = isTracked;
|
|
162
|
+
exports.isUntrackedNonSubmodulePath = isUntrackedNonSubmodulePath;
|
|
163
|
+
exports.pathIsUnderSubmodule = pathIsUnderSubmodule;
|
package/dist/git/unstaged.js
CHANGED
|
@@ -44,6 +44,10 @@ const require_git__internal = require('./_internal.js');
|
|
|
44
44
|
* @returns Promise resolving to array of unstaged file paths.
|
|
45
45
|
*/
|
|
46
46
|
async function getUnstagedFiles(options) {
|
|
47
|
+
options = {
|
|
48
|
+
__proto__: null,
|
|
49
|
+
...options
|
|
50
|
+
};
|
|
47
51
|
const args = require_git__internal.getGitDiffSpawnArgs(options?.cwd).unstaged;
|
|
48
52
|
return await require_git__internal.innerDiff(args, options);
|
|
49
53
|
}
|
|
@@ -79,6 +83,10 @@ async function getUnstagedFiles(options) {
|
|
|
79
83
|
* @returns Array of unstaged file paths.
|
|
80
84
|
*/
|
|
81
85
|
function getUnstagedFilesSync(options) {
|
|
86
|
+
options = {
|
|
87
|
+
__proto__: null,
|
|
88
|
+
...options
|
|
89
|
+
};
|
|
82
90
|
const args = require_git__internal.getGitDiffSpawnArgs(options?.cwd).unstaged;
|
|
83
91
|
return require_git__internal.innerDiffSync(args, options);
|
|
84
92
|
}
|
|
@@ -48,6 +48,10 @@ const require_github_token = require('./token.js');
|
|
|
48
48
|
* error.
|
|
49
49
|
*/
|
|
50
50
|
async function fetchRefShaViaGraphQL(owner, repo, ref, options) {
|
|
51
|
+
options = {
|
|
52
|
+
__proto__: null,
|
|
53
|
+
...options
|
|
54
|
+
};
|
|
51
55
|
const token = options.token || require_github_token.getGitHubToken();
|
|
52
56
|
const headers = {
|
|
53
57
|
Accept: "application/vnd.github.v3+json",
|
package/dist/github/refs-rest.js
CHANGED
|
@@ -31,6 +31,10 @@ const require_github_refs_graphql = require('./refs-graphql.js');
|
|
|
31
31
|
* @throws {Error} When ref cannot be resolved after all strategies fail
|
|
32
32
|
*/
|
|
33
33
|
async function fetchRefSha(owner, repo, ref, options) {
|
|
34
|
+
options = {
|
|
35
|
+
__proto__: null,
|
|
36
|
+
...options
|
|
37
|
+
};
|
|
34
38
|
const fetchOptions = { token: options.token };
|
|
35
39
|
let sawEmptyBody = false;
|
|
36
40
|
const note404 = (e) => {
|
package/dist/globs/_internal.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_primordials_string = require('../primordials/string.js');
|
|
5
|
+
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
5
6
|
const require_paths_normalize = require('../paths/normalize.js');
|
|
6
7
|
const require_primordials_array = require('../primordials/array.js');
|
|
7
|
-
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
8
8
|
const require_node_fs = require('../node/fs.js');
|
|
9
9
|
const require_globs_defaults = require('./defaults.js');
|
|
10
10
|
const require_node_fs_promises = require('../node/fs-promises.js');
|
package/dist/globs/match.js
CHANGED
|
@@ -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_node_fs = require('../node/fs.js');
|
|
5
4
|
const require_primordials_object = require('../primordials/object.js');
|
|
5
|
+
const require_node_fs = require('../node/fs.js');
|
|
6
6
|
const require_node_fs_promises = require('../node/fs-promises.js');
|
|
7
7
|
const require_globs__internal = require('./_internal.js');
|
|
8
8
|
const require_promises_resolvers = require('../promises/resolvers.js');
|
|
@@ -59,6 +59,10 @@ function canUseNodeFsGlob(options) {
|
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
async function glob(patterns, options) {
|
|
62
|
+
options = {
|
|
63
|
+
__proto__: null,
|
|
64
|
+
...options
|
|
65
|
+
};
|
|
62
66
|
const normalizedIgnore = require_globs__internal.normalizeIgnorePatterns(options?.ignore);
|
|
63
67
|
/* c8 ignore start */
|
|
64
68
|
if (canUseNodeFsGlob(options)) return require_globs__internal.normalizeGlobResults(await require_promises_resolvers.fromAsync(require_node_fs_promises.getNodeFsPromises().glob(patterns, {
|
|
@@ -81,6 +85,10 @@ async function glob(patterns, options) {
|
|
|
81
85
|
* ```
|
|
82
86
|
*/
|
|
83
87
|
function globSync(patterns, options) {
|
|
88
|
+
options = {
|
|
89
|
+
__proto__: null,
|
|
90
|
+
...options
|
|
91
|
+
};
|
|
84
92
|
const normalizedIgnore = require_globs__internal.normalizeIgnorePatterns(options?.ignore);
|
|
85
93
|
/* c8 ignore start */
|
|
86
94
|
if (canUseNodeFsGlob(options)) return require_globs__internal.normalizeGlobResults([...require_node_fs.getNodeFs().globSync(patterns, {
|
package/dist/globs/matcher.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
4
5
|
const require_primordials_string = require('../primordials/string.js');
|
|
5
6
|
const require_primordials_array = require('../primordials/array.js');
|
|
6
7
|
const require_primordials_json = require('../primordials/json.js');
|
|
7
|
-
const require_primordials_object = require('../primordials/object.js');
|
|
8
8
|
const require_globs__internal = require('./_internal.js');
|
|
9
9
|
|
|
10
10
|
//#region src/globs/matcher.ts
|
|
@@ -41,6 +41,10 @@ let matchesGlobProbed = false;
|
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
43
|
function getGlobMatcher(glob, options) {
|
|
44
|
+
options = {
|
|
45
|
+
__proto__: null,
|
|
46
|
+
...options
|
|
47
|
+
};
|
|
44
48
|
const patterns = require_primordials_array.ArrayIsArray(glob) ? glob : [glob];
|
|
45
49
|
const sortedPatterns = [...patterns].toSorted();
|
|
46
50
|
const sortedOptions = options ? require_primordials_object.ObjectKeys(options).toSorted().map((k) => {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_primordials_error = require('../primordials/error.js');
|
|
5
|
-
const require_primordials_math = require('../primordials/math.js');
|
|
6
5
|
const require_primordials_string = require('../primordials/string.js');
|
|
6
|
+
const require_primordials_math = require('../primordials/math.js');
|
|
7
7
|
const require_primordials_array = require('../primordials/array.js');
|
|
8
8
|
const require_primordials_date = require('../primordials/date.js');
|
|
9
9
|
const require_primordials_json = require('../primordials/json.js');
|
|
10
10
|
const require_primordials_promise = require('../primordials/promise.js');
|
|
11
|
-
const
|
|
11
|
+
const require_http_request_fetch_browser = require('./fetch/browser.js');
|
|
12
12
|
const require_primordials_headers = require('../primordials/headers.js');
|
|
13
13
|
|
|
14
14
|
//#region src/http-request/browser.ts
|
|
@@ -76,6 +76,10 @@ function combineSignals(external, timeoutMs) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
async function attempt(url, options) {
|
|
79
|
+
options = {
|
|
80
|
+
__proto__: null,
|
|
81
|
+
...options
|
|
82
|
+
};
|
|
79
83
|
const method = options.method ?? "GET";
|
|
80
84
|
const init = { method };
|
|
81
85
|
if (options.headers) init.headers = options.headers;
|
|
@@ -91,7 +95,7 @@ async function attempt(url, options) {
|
|
|
91
95
|
timeout: options.timeout
|
|
92
96
|
});
|
|
93
97
|
try {
|
|
94
|
-
const response = await
|
|
98
|
+
const response = await require_http_request_fetch_browser.fetchResponse(url, init);
|
|
95
99
|
const buffer = await response.arrayBuffer();
|
|
96
100
|
if (options.maxResponseSize !== void 0 && buffer.byteLength > options.maxResponseSize) throw new require_primordials_error.ErrorCtor(`Response body (${buffer.byteLength} bytes) exceeds maxResponseSize (${options.maxResponseSize})`);
|
|
97
101
|
const body = new require_primordials_array.Uint8ArrayCtor(buffer);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_primordials_error = require('../primordials/error.js');
|
|
5
|
-
const require_integrity = require('../integrity.js');
|
|
6
5
|
const require_primordials_string = require('../primordials/string.js');
|
|
6
|
+
const require_integrity = require('../integrity.js');
|
|
7
7
|
const require_http_request_request = require('./request.js');
|
|
8
8
|
|
|
9
9
|
//#region src/http-request/checksum-file.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Thin wrapper over the global `fetch()` so tests can mock the network
|
|
3
|
-
* layer via `vi.mock('@socketsecurity/lib/http-request/browser
|
|
3
|
+
* layer via `vi.mock('@socketsecurity/lib/http-request/fetch/browser')`
|
|
4
4
|
* without monkey-patching `globalThis.fetch` (which conflicts with the
|
|
5
5
|
* project's nock-based test setup). The wrapper itself is `c8 ignore`-marked
|
|
6
6
|
* because the body is a single uncoverable fetch call; coverage credit is
|
|
7
7
|
* preserved by the wider test suite that mocks this module and asserts the
|
|
8
8
|
* call shape.
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function fetchResponse(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
//#region src/http-request/browser
|
|
5
|
+
//#region src/http-request/fetch/browser.ts
|
|
6
6
|
/**
|
|
7
7
|
* @file Thin wrapper over the global `fetch()` so tests can mock the network
|
|
8
|
-
* layer via `vi.mock('@socketsecurity/lib/http-request/browser
|
|
8
|
+
* layer via `vi.mock('@socketsecurity/lib/http-request/fetch/browser')`
|
|
9
9
|
* without monkey-patching `globalThis.fetch` (which conflicts with the
|
|
10
10
|
* project's nock-based test setup). The wrapper itself is `c8 ignore`-marked
|
|
11
11
|
* because the body is a single uncoverable fetch call; coverage credit is
|
|
@@ -13,10 +13,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
13
13
|
* call shape.
|
|
14
14
|
*/
|
|
15
15
|
/* c8 ignore start - native fetch call; tests mock this module wholesale */
|
|
16
|
-
function
|
|
16
|
+
function fetchResponse(input, init) {
|
|
17
17
|
return fetch(input, init);
|
|
18
18
|
}
|
|
19
19
|
/* c8 ignore stop */
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
|
-
exports.
|
|
22
|
+
exports.fetchResponse = fetchResponse;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
4
5
|
const require_primordials_number = require('../primordials/number.js');
|
|
5
6
|
const require_primordials_array = require('../primordials/array.js');
|
|
6
7
|
const require_primordials_date = require('../primordials/date.js');
|
|
7
|
-
const require_primordials_object = require('../primordials/object.js');
|
|
8
8
|
const require_primordials_globals = require('../primordials/globals.js');
|
|
9
9
|
|
|
10
10
|
//#region src/http-request/headers.ts
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_primordials_buffer = require('../primordials/buffer.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_date = require('../primordials/date.js');
|
|
7
8
|
const require_primordials_json = require('../primordials/json.js');
|
|
8
|
-
const require_primordials_object = require('../primordials/object.js');
|
|
9
9
|
const require_primordials_promise = require('../primordials/promise.js');
|
|
10
|
+
const require_primordials_url = require('../primordials/url.js');
|
|
10
11
|
const require_node_http = require('../node/http.js');
|
|
11
12
|
const require_node_https = require('../node/https.js');
|
|
12
|
-
const require_primordials_url = require('../primordials/url.js');
|
|
13
13
|
const require_http_request_errors = require('./errors.js');
|
|
14
14
|
const require_http_request_response_reader = require('./response-reader.js');
|
|
15
15
|
const require_http_request_user_agent = require('./user-agent.js');
|
|
@@ -70,7 +70,7 @@ function getSocketCallerUserAgent() {
|
|
|
70
70
|
version: require_constants_socket.SOCKET_LIB_VERSION
|
|
71
71
|
});
|
|
72
72
|
const caller = require_env_rewire.getEnvValue("SOCKET_CALLER_USER_AGENT");
|
|
73
|
-
return caller
|
|
73
|
+
return caller?.trim() ? `${cachedBaseUserAgent} ${caller}` : cachedBaseUserAgent;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
//#endregion
|