@socketsecurity/lib 6.0.7 → 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.
Files changed (263) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/dist/ai/agent-context.d.mts +103 -0
  4. package/dist/ai/agent-context.js +157 -0
  5. package/dist/ai/backends.d.mts +83 -0
  6. package/dist/ai/backends.js +173 -0
  7. package/dist/ai/credentials.d.mts +49 -0
  8. package/dist/ai/credentials.js +82 -0
  9. package/dist/ai/discover.d.mts +4 -0
  10. package/dist/ai/discover.js +1 -1
  11. package/dist/ai/exec.d.mts +52 -0
  12. package/dist/ai/exec.js +92 -0
  13. package/dist/ai/http.d.mts +132 -0
  14. package/dist/ai/http.js +130 -0
  15. package/dist/ai/profiles.d.mts +41 -6
  16. package/dist/ai/profiles.js +52 -10
  17. package/dist/ai/route.d.mts +69 -0
  18. package/dist/ai/route.js +156 -0
  19. package/dist/ai/spawn.d.mts +10 -2
  20. package/dist/ai/spawn.js +55 -31
  21. package/dist/ai/subagent-status.d.mts +48 -0
  22. package/dist/ai/subagent-status.js +57 -0
  23. package/dist/ai/tier.d.mts +60 -0
  24. package/dist/ai/tier.js +53 -0
  25. package/dist/ai/types.d.mts +15 -2
  26. package/dist/ai/worktree.js +4 -0
  27. package/dist/archives/tar.js +1 -1
  28. package/dist/archives/zip.js +2 -2
  29. package/dist/argv/parse.d.ts +19 -2
  30. package/dist/argv/parse.js +1 -1
  31. package/dist/arrays/join.js +4 -0
  32. package/dist/bin/find.js +4 -4
  33. package/dist/bin/prim.cjs +3915 -3781
  34. package/dist/bin/resolve.js +1 -1
  35. package/dist/cache/ttl/store.js +1 -1
  36. package/dist/cli/check-primordials.d.ts +8 -3
  37. package/dist/cli/check-primordials.js +4 -4
  38. package/dist/compression/_internal.js +1 -1
  39. package/dist/compression/brotli.d.ts +1 -2
  40. package/dist/compression/brotli.js +6 -2
  41. package/dist/compression/gzip.js +6 -2
  42. package/dist/constants/packages.d.ts +3 -0
  43. package/dist/constants/packages.js +2 -1
  44. package/dist/constants/socket.d.ts +2 -6
  45. package/dist/constants/socket.js +12 -14
  46. package/dist/cover/code.js +2 -2
  47. package/dist/crypto/hash.d.ts +4 -1
  48. package/dist/crypto/hash.js +4 -1
  49. package/dist/debug/caller-info.js +1 -1
  50. package/dist/dlx/arborist.js +13 -3
  51. package/dist/dlx/binary-cache.js +1 -1
  52. package/dist/dlx/binary-resolution.js +1 -1
  53. package/dist/dlx/detect.d.ts +8 -0
  54. package/dist/dlx/firewall.d.ts +8 -0
  55. package/dist/dlx/firewall.js +1 -1
  56. package/dist/dlx/lockfile.js +4 -1
  57. package/dist/dlx/manifest.js +1 -1
  58. package/dist/dlx/package.js +4 -0
  59. package/dist/eco/cargo/parse-lockfile.d.ts +1 -2
  60. package/dist/eco/cargo/parse-lockfile.js +3 -3
  61. package/dist/eco/manifest/detect-format.js +1 -1
  62. package/dist/eco/npm/npm/parse-lockfile.d.ts +3 -4
  63. package/dist/eco/npm/npm/parse-lockfile.js +2 -2
  64. package/dist/eco/npm/parse-package-json.d.ts +11 -0
  65. package/dist/eco/npm/parse-package-json.js +1 -1
  66. package/dist/eco/npm/pnpm/parse-lockfile.d.ts +5 -3
  67. package/dist/eco/npm/pnpm/parse-lockfile.js +3 -3
  68. package/dist/eco/npm/yarnpkg/yarn/exec.js +1 -1
  69. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +1 -2
  70. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +1 -1
  71. package/dist/env/proxy.js +1 -1
  72. package/dist/env/rewire.d.ts +1 -0
  73. package/dist/env/rewire.js +1 -1
  74. package/dist/env/socket.d.ts +7 -0
  75. package/dist/env/socket.js +10 -0
  76. package/dist/errors/predicates.js +1 -1
  77. package/dist/external/@npmcli/promise-spawn.js +3 -1
  78. package/dist/external/pico-pack.js +4 -2
  79. package/dist/external/which.js +3 -1
  80. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  81. package/dist/external-tools/bazel/asset-names.js +5 -2
  82. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  83. package/dist/external-tools/bazel/from-download.js +5 -2
  84. package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
  85. package/dist/external-tools/bazel/resolve.d.ts +3 -3
  86. package/dist/external-tools/bazel/resolve.js +16 -8
  87. package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
  88. package/dist/external-tools/cdxgen/asset-names.js +5 -2
  89. package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
  90. package/dist/external-tools/cdxgen/from-download.js +7 -4
  91. package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
  92. package/dist/external-tools/cdxgen/resolve.js +16 -8
  93. package/dist/external-tools/from-download.d.ts +2 -2
  94. package/dist/external-tools/from-download.js +11 -5
  95. package/dist/external-tools/from-pip-venv.d.ts +1 -1
  96. package/dist/external-tools/from-pip-venv.js +12 -5
  97. package/dist/external-tools/janus/asset-names.d.ts +1 -1
  98. package/dist/external-tools/janus/asset-names.js +5 -2
  99. package/dist/external-tools/janus/from-download.d.ts +1 -1
  100. package/dist/external-tools/janus/from-download.js +5 -2
  101. package/dist/external-tools/janus/resolve.d.ts +3 -3
  102. package/dist/external-tools/janus/resolve.js +16 -8
  103. package/dist/external-tools/jre/asset-names.d.ts +1 -1
  104. package/dist/external-tools/jre/asset-names.js +5 -2
  105. package/dist/external-tools/jre/from-download.d.ts +1 -1
  106. package/dist/external-tools/jre/from-download.js +7 -4
  107. package/dist/external-tools/jre/from-java-home.js +2 -2
  108. package/dist/external-tools/jre/from-vfs.js +2 -2
  109. package/dist/external-tools/jre/resolve.d.ts +3 -3
  110. package/dist/external-tools/jre/resolve.js +16 -8
  111. package/dist/external-tools/manifest.d.ts +18 -0
  112. package/dist/external-tools/manifest.js +1 -1
  113. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  114. package/dist/external-tools/opengrep/asset-names.js +5 -2
  115. package/dist/external-tools/opengrep/from-download.d.ts +1 -1
  116. package/dist/external-tools/opengrep/from-download.js +5 -2
  117. package/dist/external-tools/opengrep/resolve.d.ts +3 -3
  118. package/dist/external-tools/opengrep/resolve.js +16 -8
  119. package/dist/external-tools/python/asset-names.d.ts +1 -1
  120. package/dist/external-tools/python/asset-names.js +10 -3
  121. package/dist/external-tools/python/dlx.d.ts +3 -3
  122. package/dist/external-tools/python/dlx.js +20 -9
  123. package/dist/external-tools/python/from-download.d.ts +1 -1
  124. package/dist/external-tools/python/from-download.js +12 -5
  125. package/dist/external-tools/python/pin.js +6 -3
  126. package/dist/external-tools/python/pip-install.js +6 -3
  127. package/dist/external-tools/python/resolve.d.ts +3 -3
  128. package/dist/external-tools/python/resolve.js +19 -11
  129. package/dist/external-tools/sbt/asset-names.d.ts +1 -1
  130. package/dist/external-tools/sbt/asset-names.js +5 -2
  131. package/dist/external-tools/sbt/from-download.d.ts +1 -1
  132. package/dist/external-tools/sbt/from-download.js +5 -2
  133. package/dist/external-tools/sbt/resolve.d.ts +3 -3
  134. package/dist/external-tools/sbt/resolve.js +16 -8
  135. package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
  136. package/dist/external-tools/skillspector/from-dlx.js +10 -3
  137. package/dist/external-tools/skillspector/resolve.d.ts +2 -2
  138. package/dist/external-tools/skillspector/resolve.js +14 -6
  139. package/dist/external-tools/synp/asset-names.d.ts +1 -1
  140. package/dist/external-tools/synp/asset-names.js +6 -2
  141. package/dist/external-tools/synp/from-download.d.ts +1 -1
  142. package/dist/external-tools/synp/from-download.js +5 -2
  143. package/dist/external-tools/synp/resolve.d.ts +3 -3
  144. package/dist/external-tools/synp/resolve.js +16 -8
  145. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  146. package/dist/external-tools/trivy/asset-names.js +5 -2
  147. package/dist/external-tools/trivy/from-download.d.ts +1 -1
  148. package/dist/external-tools/trivy/from-download.js +7 -4
  149. package/dist/external-tools/trivy/resolve.d.ts +3 -3
  150. package/dist/external-tools/trivy/resolve.js +16 -8
  151. package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
  152. package/dist/external-tools/trufflehog/asset-names.js +5 -2
  153. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  154. package/dist/external-tools/trufflehog/from-download.js +7 -4
  155. package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
  156. package/dist/external-tools/trufflehog/resolve.js +16 -8
  157. package/dist/fs/allowed-dirs-cache.d.ts +27 -1
  158. package/dist/fs/allowed-dirs-cache.js +38 -3
  159. package/dist/fs/find.js +1 -1
  160. package/dist/fs/read-json-cache.d.ts +7 -0
  161. package/dist/fs/resolve-module.js +6 -2
  162. package/dist/fs/safe.js +1 -1
  163. package/dist/git/_internal.js +2 -2
  164. package/dist/git/repo.js +2 -4
  165. package/dist/git/staged.js +8 -0
  166. package/dist/git/tracked.d.ts +84 -0
  167. package/dist/git/tracked.js +163 -0
  168. package/dist/git/unstaged.js +8 -0
  169. package/dist/github/refs-graphql.js +4 -0
  170. package/dist/github/refs-rest.js +4 -0
  171. package/dist/github/refs.js +15 -10
  172. package/dist/globs/_internal.js +1 -1
  173. package/dist/globs/match.js +9 -1
  174. package/dist/globs/matcher.js +5 -1
  175. package/dist/http-request/browser.js +6 -2
  176. package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
  177. package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
  178. package/dist/http-request/headers.js +1 -1
  179. package/dist/http-request/request-attempt.js +2 -2
  180. package/dist/http-request/user-agent.js +1 -1
  181. package/dist/integrity.d.ts +10 -4
  182. package/dist/integrity.js +10 -4
  183. package/dist/json/edit.js +38 -30
  184. package/dist/json/format.js +1 -1
  185. package/dist/native-messaging/install.d.ts +1 -1
  186. package/dist/native-messaging/install.js +7 -4
  187. package/dist/native-messaging/rate-limit.d.ts +7 -0
  188. package/dist/native-messaging/rate-limit.js +4 -0
  189. package/dist/node/async-hooks.js +1 -1
  190. package/dist/node/child-process.js +1 -1
  191. package/dist/node/crypto.js +1 -1
  192. package/dist/node/events.js +1 -1
  193. package/dist/node/fs-promises.js +1 -1
  194. package/dist/node/fs.d.ts +22 -6
  195. package/dist/node/fs.js +16 -3
  196. package/dist/node/http.js +1 -1
  197. package/dist/node/https.js +1 -1
  198. package/dist/node/module.js +1 -1
  199. package/dist/node/os.d.ts +10 -2
  200. package/dist/node/os.js +11 -4
  201. package/dist/node/path.d.ts +11 -2
  202. package/dist/node/path.js +17 -4
  203. package/dist/node/timers-promises.js +1 -1
  204. package/dist/node/url.js +1 -1
  205. package/dist/node/util.js +1 -1
  206. package/dist/objects/getters.js +1 -1
  207. package/dist/objects/mutate.js +2 -2
  208. package/dist/objects/predicates.js +1 -1
  209. package/dist/packages/edit-class.d.ts +2 -3
  210. package/dist/packages/edit-class.js +41 -35
  211. package/dist/packages/exports.js +4 -4
  212. package/dist/packages/fetch.js +1 -1
  213. package/dist/packages/isolation.js +1 -1
  214. package/dist/packages/licenses.js +2 -2
  215. package/dist/packages/manifest.js +4 -4
  216. package/dist/packages/normalize.js +1 -1
  217. package/dist/packages/provenance.js +2 -2
  218. package/dist/packages/specs.js +1 -1
  219. package/dist/packages/tarball.js +4 -2
  220. package/dist/packages/types.d.ts +1 -2
  221. package/dist/paths/dirnames.d.ts +1 -0
  222. package/dist/paths/dirnames.js +2 -0
  223. package/dist/paths/resolve.js +14 -19
  224. package/dist/paths/rewire.d.ts +5 -0
  225. package/dist/paths/socket.d.ts +74 -111
  226. package/dist/paths/socket.js +99 -132
  227. package/dist/primordials/process.d.ts +88 -0
  228. package/dist/primordials/process.js +132 -0
  229. package/dist/primordials/uncurry.d.ts +1 -2
  230. package/dist/process/spawn/child.js +8 -2
  231. package/dist/process/spawn/errors.js +1 -1
  232. package/dist/regexps/spec.js +1 -1
  233. package/dist/releases/github-archives.js +1 -1
  234. package/dist/releases/github-listing.d.ts +1 -2
  235. package/dist/schema/types.d.ts +3 -4
  236. package/dist/schema/validate.js +1 -1
  237. package/dist/secrets/find.d.ts +2 -2
  238. package/dist/secrets/find.js +10 -4
  239. package/dist/secrets/keychain.d.ts +1 -1
  240. package/dist/secrets/linux.js +32 -44
  241. package/dist/secrets/macos.d.ts +1 -2
  242. package/dist/secrets/macos.js +20 -29
  243. package/dist/secrets/rc.d.ts +2 -2
  244. package/dist/secrets/rc.js +21 -13
  245. package/dist/secrets/socket-api-token.js +8 -0
  246. package/dist/secrets/windows.js +27 -33
  247. package/dist/shell/parse.d.ts +32 -0
  248. package/dist/shell/parse.js +60 -0
  249. package/dist/spinner/create-spinner-class.js +2 -2
  250. package/dist/spinner/spinner-internals.d.ts +1 -1
  251. package/dist/spinner/spinner-internals.js +9 -5
  252. package/dist/spinner/spinner.d.ts +4 -0
  253. package/dist/spinner/spinner.js +1 -1
  254. package/dist/stdio/progress.js +5 -1
  255. package/dist/stdio/prompts.d.ts +2 -2
  256. package/dist/stdio/prompts.js +1 -1
  257. package/dist/temporal/instant.js +2 -2
  258. package/dist/url/assert-safe.d.ts +29 -0
  259. package/dist/url/assert-safe.js +54 -0
  260. package/dist/url/predicates.d.ts +31 -1
  261. package/dist/url/predicates.js +42 -1
  262. package/dist/url/types.d.ts +4 -0
  263. package/package.json +177 -115
@@ -2,14 +2,14 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_primordials_buffer = require('../primordials/buffer.js');
5
+ const require_primordials_object = require('../primordials/object.js');
6
+ const require_primordials_map_set = require('../primordials/map-set.js');
5
7
  const require_primordials_string = require('../primordials/string.js');
6
8
  const require_paths_normalize = require('../paths/normalize.js');
7
9
  const require_primordials_array = require('../primordials/array.js');
8
- const require_primordials_map_set = require('../primordials/map-set.js');
9
10
  const require_node_path = require('../node/path.js');
10
11
  const require_primordials_date = require('../primordials/date.js');
11
12
  const require_primordials_json = require('../primordials/json.js');
12
- const require_primordials_object = require('../primordials/object.js');
13
13
  const require_bin_which = require('../bin/which.js');
14
14
  const require_ansi_strip = require('../ansi/strip.js');
15
15
  const require_process_spawn_child = require('../process/spawn/child.js');
package/dist/git/repo.js CHANGED
@@ -1,12 +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_runtime = require('../_virtual/_rolldown/runtime.js');
5
4
  const require_primordials_map_set = require('../primordials/map-set.js');
6
5
  const require_node_fs = require('../node/fs.js');
7
6
  const require_node_path = require('../node/path.js');
8
- let node_process = require("node:process");
9
- node_process = require_runtime.__toESM(node_process);
7
+ const require_primordials_process = require('../primordials/process.js');
10
8
 
11
9
  //#region src/git/repo.ts
12
10
  /**
@@ -112,7 +110,7 @@ function getCachedRealpath(pathname) {
112
110
  * @returns The resolved real path of `process.cwd()`.
113
111
  */
114
112
  function getCwd() {
115
- return getCachedRealpath(node_process.default.cwd());
113
+ return getCachedRealpath(require_primordials_process.processCwd());
116
114
  }
117
115
 
118
116
  //#endregion
@@ -44,6 +44,10 @@ const require_git__internal = require('./_internal.js');
44
44
  * @returns Promise resolving to array of staged file paths.
45
45
  */
46
46
  async function getStagedFiles(options) {
47
+ options = {
48
+ __proto__: null,
49
+ ...options
50
+ };
47
51
  const args = require_git__internal.getGitDiffSpawnArgs(options?.cwd).staged;
48
52
  return await require_git__internal.innerDiff(args, options);
49
53
  }
@@ -79,6 +83,10 @@ async function getStagedFiles(options) {
79
83
  * @returns Array of staged file paths.
80
84
  */
81
85
  function getStagedFilesSync(options) {
86
+ options = {
87
+ __proto__: null,
88
+ ...options
89
+ };
82
90
  const args = require_git__internal.getGitDiffSpawnArgs(options?.cwd).staged;
83
91
  return require_git__internal.innerDiffSync(args, options);
84
92
  }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @file Tracked-status + submodule-membership probes for a working-tree path.
3
+ * `isTracked` answers "does git track this exact path?"; `getSubmodulePaths`
4
+ * lists the repo's submodule mount points; `isInSubmodule` answers "does this
5
+ * path live inside one?"; `isUntrackedNonSubmodulePath` composes them into
6
+ * the safe-to-touch condition for cleanup tooling — never delete a tracked
7
+ * file or reach into a submodule's own tree (which would dirty it).
8
+ */
9
+ /**
10
+ * The repo's submodule mount points as normalized, repo-root-relative paths
11
+ * (e.g. `vendor/acorn`). Reads `git config` on `.gitmodules`, so it lists
12
+ * declared submodules whether or not they are initialized — the case a
13
+ * stderr-message check on `git ls-files` misses.
14
+ *
15
+ * @example
16
+ * ;```typescript
17
+ * await getSubmodulePaths()
18
+ * // => ['packages/acorn/upstream/acorn', 'vendor/mbedtls']
19
+ * ```
20
+ */
21
+ export declare function getSubmodulePaths(options?: GitPathOptions | undefined): Promise<string[]>;
22
+ /**
23
+ * Whether `targetPath` lives inside one of the repo's submodules. Resolves the
24
+ * submodule list itself; for a batch sweep prefer `getSubmodulePaths` once plus
25
+ * `pathIsUnderSubmodule` per path.
26
+ *
27
+ * @example
28
+ * ;```typescript
29
+ * await isInSubmodule('vendor/mbedtls/x.py') // => true
30
+ * await isInSubmodule('src/index.ts') // => false
31
+ * ```
32
+ */
33
+ export declare function isInSubmodule(targetPath: string, options?: GitPathOptions | undefined): Promise<boolean>;
34
+ export interface GitPathOptions {
35
+ /**
36
+ * The git working-tree directory the path is resolved against.
37
+ *
38
+ * @default process.cwd()
39
+ */
40
+ cwd?: string | undefined;
41
+ }
42
+ /**
43
+ * Whether git tracks `targetPath` exactly. Uses `git ls-files --error-unmatch`,
44
+ * which exits non-zero for an untracked path. A path inside a submodule, or one
45
+ * git does not know, returns `false`.
46
+ *
47
+ * @example
48
+ * ;```typescript
49
+ * await isTracked('src/index.ts') // => true
50
+ * await isTracked('.DS_Store') // => false
51
+ * ```
52
+ */
53
+ export declare function isTracked(targetPath: string, options?: GitPathOptions | undefined): Promise<boolean>;
54
+ /**
55
+ * Whether `targetPath` is git does NOT track AND does not live inside a
56
+ * submodule — the safe-to-touch condition for cleanup tooling. A tracked path
57
+ * is a deliberate file; a submodule-internal path belongs to that submodule's
58
+ * own git (touching it would dirty the submodule). Composes `isTracked` +
59
+ * `getSubmodulePaths`/`pathIsUnderSubmodule`. Fails closed — any check error
60
+ * resolves to `false`.
61
+ *
62
+ * For a batch sweep, call `getSubmodulePaths` once and compose `isTracked` +
63
+ * `pathIsUnderSubmodule` per path to avoid re-reading `.gitmodules` each time.
64
+ *
65
+ * @example
66
+ * ;```typescript
67
+ * await isUntrackedNonSubmodulePath('.DS_Store') // => true
68
+ * await isUntrackedNonSubmodulePath('src/index.ts') // => false (tracked)
69
+ * await isUntrackedNonSubmodulePath('vendor/sub/x.pyc') // => false (submodule)
70
+ * ```
71
+ */
72
+ export declare function isUntrackedNonSubmodulePath(targetPath: string, options?: GitPathOptions | undefined): Promise<boolean>;
73
+ /**
74
+ * Whether `relativePath` (repo-root-relative) lies at or under any of
75
+ * `submodulePaths`. Pure — pass the result of `getSubmodulePaths` so the git
76
+ * read happens once for a whole sweep.
77
+ *
78
+ * @example
79
+ * ;```typescript
80
+ * pathIsUnderSubmodule('vendor/mbedtls/scripts/__pycache__', ['vendor/mbedtls'])
81
+ * // => true
82
+ * ```
83
+ */
84
+ export declare function pathIsUnderSubmodule(relativePath: string, submodulePaths: string[]): boolean;
@@ -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;
@@ -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",
@@ -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) => {
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
- const require_github_refs_graphql = require('./refs-graphql.js');
6
- const require_github_refs_rest = require('./refs-rest.js');
7
4
  const require_github_refs_cache = require('./refs-cache.js');
8
- let node_process = require("node:process");
9
- node_process = require_runtime.__toESM(node_process);
10
5
 
11
6
  //#region src/github/refs.ts
12
7
  /**
@@ -94,15 +89,25 @@ async function resolveRefToSha(owner, repo, ref, options) {
94
89
  ...options
95
90
  };
96
91
  const cacheKey = `${owner}/${repo}@${ref}`;
97
- if (node_process.default.env["DISABLE_GITHUB_CACHE"]) return await require_github_refs_rest.fetchRefSha(owner, repo, ref, opts);
98
- return await require_github_refs_cache.getGithubCache().getOrFetch(cacheKey, async () => {
99
- return await require_github_refs_rest.fetchRefSha(owner, repo, ref, opts);
92
+ if (process.env["DISABLE_GITHUB_CACHE"]) return await fetchRefSha$1(owner, repo, ref, opts);
93
+ return await getGithubCache$1().getOrFetch(cacheKey, async () => {
94
+ return await fetchRefSha$1(owner, repo, ref, opts);
100
95
  });
101
96
  }
102
97
 
103
98
  //#endregion
104
99
  exports.clearRefCache = require_github_refs_cache.clearRefCache;
105
- exports.fetchRefSha = require_github_refs_rest.fetchRefSha;
106
- exports.fetchRefShaViaGraphQL = require_github_refs_graphql.fetchRefShaViaGraphQL;
100
+ Object.defineProperty(exports, 'fetchRefSha', {
101
+ enumerable: true,
102
+ get: function () {
103
+ return fetchRefSha;
104
+ }
105
+ });
106
+ Object.defineProperty(exports, 'fetchRefShaViaGraphQL', {
107
+ enumerable: true,
108
+ get: function () {
109
+ return fetchRefShaViaGraphQL;
110
+ }
111
+ });
107
112
  exports.getGithubCache = require_github_refs_cache.getGithubCache;
108
113
  exports.resolveRefToSha = resolveRefToSha;
@@ -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_map_set = require('../primordials/map-set.js');
4
5
  const require_primordials_string = require('../primordials/string.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');
@@ -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, {
@@ -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) => {
@@ -8,7 +8,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 require_http_request_browser_fetch = require('./browser-fetch.js');
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 require_http_request_browser_fetch.doFetch(url, init);
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);
@@ -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-fetch')`
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 doFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
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-fetch.ts
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-fetch')`
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 doFetch(input, init) {
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.doFetch = doFetch;
22
+ exports.fetchResponse = fetchResponse;
@@ -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_number = require('../primordials/number.js');
5
+ const require_primordials_object = require('../primordials/object.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 && caller.trim() ? `${cachedBaseUserAgent} ${caller}` : cachedBaseUserAgent;
73
+ return caller?.trim() ? `${cachedBaseUserAgent} ${caller}` : cachedBaseUserAgent;
74
74
  }
75
75
 
76
76
  //#endregion
@@ -60,10 +60,16 @@ export interface ParsedIntegrity {
60
60
  * Idempotent on integrity input — call this on user-supplied data without first
61
61
  * sniffing the format.
62
62
  *
63
- * The default algorithm is `'sha256'` because that's the fleet's checksum
64
- * convention; pass an explicit algorithm if you have a hex digest from `sha384`
65
- * or `sha512` (the function does not verify hex length against the algorithm —
66
- * caller's responsibility).
63
+ * The default algorithm is `'sha256'` because this converts a _checksum_, and
64
+ * checksums are sha256 by fleet convention (the GitHub-SHA256SUMS interop shape
65
+ * its only caller, `checksum-file.ts`, parses). Do NOT flip this default to
66
+ * sha512: this function only relabels the hex bytes, it does not re-hash, so a
67
+ * sha512 label on a 256-bit digest would be a lie. The canonical algorithm for
68
+ * OUR-side integrity values is sha512 — emitted by `computeHashes` as the
69
+ * `integrity` (`sha512-<base64>`) field; sha256 is reserved for
70
+ * upstream-SHASUMS interop and content addressing. Pass an explicit algorithm
71
+ * if you have a hex digest from `sha384` or `sha512` (the function does not
72
+ * verify hex length against the algorithm — caller's responsibility).
67
73
  *
68
74
  * @example
69
75
  * ;```typescript
package/dist/integrity.js CHANGED
@@ -33,10 +33,16 @@ const CHECKSUM_RE = /^[a-f0-9]{64}$/i;
33
33
  * Idempotent on integrity input — call this on user-supplied data without first
34
34
  * sniffing the format.
35
35
  *
36
- * The default algorithm is `'sha256'` because that's the fleet's checksum
37
- * convention; pass an explicit algorithm if you have a hex digest from `sha384`
38
- * or `sha512` (the function does not verify hex length against the algorithm —
39
- * caller's responsibility).
36
+ * The default algorithm is `'sha256'` because this converts a _checksum_, and
37
+ * checksums are sha256 by fleet convention (the GitHub-SHA256SUMS interop shape
38
+ * its only caller, `checksum-file.ts`, parses). Do NOT flip this default to
39
+ * sha512: this function only relabels the hex bytes, it does not re-hash, so a
40
+ * sha512 label on a 256-bit digest would be a lie. The canonical algorithm for
41
+ * OUR-side integrity values is sha512 — emitted by `computeHashes` as the
42
+ * `integrity` (`sha512-<base64>`) field; sha256 is reserved for
43
+ * upstream-SHASUMS interop and content addressing. Pass an explicit algorithm
44
+ * if you have a hex digest from `sha384` or `sha512` (the function does not
45
+ * verify hex length against the algorithm — caller's responsibility).
40
46
  *
41
47
  * @example
42
48
  * ;```typescript