@socketsecurity/lib 6.0.8 → 6.0.10

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 (396) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +8 -9
  3. package/dist/abort/signal.d.ts +1 -1
  4. package/dist/abort/signal.js +1 -1
  5. package/dist/ai/agent-context.d.mts +1 -1
  6. package/dist/ai/agent-context.js +3 -2
  7. package/dist/ai/backends.d.mts +3 -3
  8. package/dist/ai/backends.js +2 -2
  9. package/dist/ai/billing-context.d.mts +74 -0
  10. package/dist/ai/billing-context.js +129 -0
  11. package/dist/ai/credentials.d.mts +39 -5
  12. package/dist/ai/credentials.js +61 -6
  13. package/dist/ai/discover.d.mts +4 -0
  14. package/dist/ai/discover.js +4 -0
  15. package/dist/ai/exec.d.mts +1 -1
  16. package/dist/ai/exec.js +1 -1
  17. package/dist/ai/http.d.mts +8 -8
  18. package/dist/ai/http.js +6 -6
  19. package/dist/ai/profiles.d.mts +9 -10
  20. package/dist/ai/profiles.js +0 -5
  21. package/dist/ai/role.d.mts +58 -0
  22. package/dist/ai/role.js +96 -0
  23. package/dist/ai/route-heuristic.d.mts +177 -0
  24. package/dist/ai/route-heuristic.js +194 -0
  25. package/dist/ai/route.d.mts +31 -17
  26. package/dist/ai/route.js +35 -19
  27. package/dist/ai/spawn.d.mts +34 -1
  28. package/dist/ai/spawn.js +115 -3
  29. package/dist/ai/subagent-status.d.mts +2 -0
  30. package/dist/ai/subagent-status.js +2 -0
  31. package/dist/ai/tier.d.mts +1 -1
  32. package/dist/ai/types.d.mts +19 -2
  33. package/dist/ai/worktree.d.mts +1 -1
  34. package/dist/ai/worktree.js +3 -2
  35. package/dist/argv/parse.d.ts +2 -0
  36. package/dist/argv/parse.js +2 -0
  37. package/dist/bin/_internal.d.ts +1 -1
  38. package/dist/bin/_internal.js +1 -1
  39. package/dist/bin/prim.cjs +19253 -13937
  40. package/dist/bin/resolve.js +1 -1
  41. package/dist/bin/shadow.js +2 -1
  42. package/dist/bin/which.d.ts +28 -3
  43. package/dist/bin/which.js +45 -3
  44. package/dist/cacache/_internal.d.ts +10 -2
  45. package/dist/cacache/_internal.js +6 -10
  46. package/dist/cache/ttl/_internal.d.ts +33 -0
  47. package/dist/cache/ttl/_internal.js +68 -0
  48. package/dist/cache/ttl/browser.d.ts +56 -0
  49. package/dist/cache/ttl/browser.js +257 -0
  50. package/dist/cache/ttl/store.js +11 -34
  51. package/dist/cache/ttl/types.d.ts +46 -3
  52. package/dist/checks/primordials-defaults.d.ts +5 -5
  53. package/dist/checks/primordials-defaults.js +5 -5
  54. package/dist/checks/primordials.d.ts +1 -1
  55. package/dist/checks/primordials.js +25 -17
  56. package/dist/cli/check-primordials.d.ts +6 -1
  57. package/dist/cli/check-primordials.js +14 -5
  58. package/dist/cli/check.js +1 -1
  59. package/dist/cli/socket-lib.d.ts +1 -1
  60. package/dist/cli/socket-lib.js +3 -3
  61. package/dist/colors/socket-palette.d.ts +1 -1
  62. package/dist/compression/brotli.d.ts +6 -2
  63. package/dist/compression/brotli.js +5 -1
  64. package/dist/compression/gzip.d.ts +6 -2
  65. package/dist/compression/gzip.js +7 -2
  66. package/dist/config/layers.d.ts +53 -0
  67. package/dist/config/layers.js +83 -0
  68. package/dist/constants/agents.d.ts +3 -0
  69. package/dist/constants/agents.js +3 -0
  70. package/dist/constants/node.d.ts +14 -0
  71. package/dist/constants/node.js +14 -0
  72. package/dist/constants/package-default-node-range.js +1 -5
  73. package/dist/constants/packages.d.ts +5 -0
  74. package/dist/constants/packages.js +5 -0
  75. package/dist/constants/platform.d.ts +1 -1
  76. package/dist/constants/platform.js +1 -1
  77. package/dist/constants/socket.js +1 -1
  78. package/dist/constants/typescript.d.ts +5 -0
  79. package/dist/constants/typescript.js +5 -0
  80. package/dist/debug/_internal.d.ts +22 -7
  81. package/dist/debug/_internal.js +33 -15
  82. package/dist/debug/caller-info.js +1 -1
  83. package/dist/debug/namespace.js +11 -8
  84. package/dist/debug/output.d.ts +12 -1
  85. package/dist/debug/output.js +33 -16
  86. package/dist/dlx/binary-cache.js +1 -1
  87. package/dist/dlx/binary-resolution.js +8 -5
  88. package/dist/dlx/firewall.js +1 -1
  89. package/dist/dlx/lockfile.js +1 -1
  90. package/dist/eco/npm/npm/parse-lockfile.js +3 -2
  91. package/dist/eco/npm/vlt/exec.d.ts +1 -1
  92. package/dist/eco/npm/vlt/exec.js +1 -1
  93. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +1 -1
  94. package/dist/env/agents.d.ts +6 -0
  95. package/dist/env/agents.js +29 -0
  96. package/dist/env/flags.d.ts +12 -0
  97. package/dist/env/flags.js +23 -0
  98. package/dist/env/github-status.js +2 -2
  99. package/dist/env/providers.d.ts +6 -0
  100. package/dist/env/providers.js +23 -0
  101. package/dist/env/proxy.js +1 -1
  102. package/dist/env/rewire.d.ts +37 -3
  103. package/dist/env/rewire.js +60 -29
  104. package/dist/env/runtimes.d.ts +9 -0
  105. package/dist/env/runtimes.js +53 -0
  106. package/dist/env/socket-cli.d.ts +5 -2
  107. package/dist/env/socket-cli.js +6 -3
  108. package/dist/env/xdg.d.ts +17 -0
  109. package/dist/env/xdg.js +21 -1
  110. package/dist/errors/predicates.d.ts +3 -2
  111. package/dist/errors/predicates.js +5 -3
  112. package/dist/events/exit/_internal.d.ts +1 -23
  113. package/dist/external/@npmcli/package-json.js +3570 -4905
  114. package/dist/external/@npmcli/promise-spawn.js +2 -2
  115. package/dist/external/@sinclair/typebox/value.js +5 -4
  116. package/dist/external/@socketregistry/yocto-spinner.js +3 -3
  117. package/dist/external/@yarnpkg/extensions.js +1 -1
  118. package/dist/external/adm-zip.d.ts +82 -0
  119. package/dist/external/adm-zip.js +2 -2
  120. package/dist/external/cacache.d.ts +87 -0
  121. package/dist/external/debug.d.ts +22 -0
  122. package/dist/external/debug.js +11 -4
  123. package/dist/external/del.d.ts +1 -0
  124. package/dist/external/external-pack.d.ts +12 -0
  125. package/dist/external/external-pack.js +42 -35
  126. package/dist/external/fast-glob.d.ts +8 -0
  127. package/dist/external/fast-sort.d.ts +1 -0
  128. package/dist/external/get-east-asian-width.d.ts +5 -0
  129. package/dist/external/get-east-asian-width.js +8 -1
  130. package/dist/external/has-flag.d.ts +1 -0
  131. package/dist/external/inquirer-pack.d.ts +18 -0
  132. package/dist/external/libnpmexec.d.ts +35 -0
  133. package/dist/external/libnpmpack.d.ts +1 -0
  134. package/dist/external/make-fetch-happen.d.ts +13 -0
  135. package/dist/external/normalize-package-data.d.ts +4 -0
  136. package/dist/external/npm-core.d.ts +14 -0
  137. package/dist/external/npm-pack.d.ts +24 -0
  138. package/dist/external/npm-pack.js +28934 -31885
  139. package/dist/external/npm-package-arg.d.ts +4 -0
  140. package/dist/external/p-map.js +8 -1
  141. package/dist/external/pacote.d.ts +15 -0
  142. package/dist/external/pico-pack.d.ts +16 -0
  143. package/dist/external/pico-pack.js +38 -23
  144. package/dist/external/picomatch.d.ts +96 -0
  145. package/dist/external/pony-cause.d.ts +14 -0
  146. package/dist/external/semver.d.ts +60 -0
  147. package/dist/external/semver.js +1459 -4
  148. package/dist/external/shell-quote.d.ts +51 -0
  149. package/dist/external/shell-quote.js +55 -15
  150. package/dist/external/signal-exit.d.ts +1 -0
  151. package/dist/external/spdx-correct.d.ts +4 -0
  152. package/dist/external/spdx-expression-parse.d.ts +4 -0
  153. package/dist/external/spdx-pack.d.ts +10 -0
  154. package/dist/external/std-env.d.ts +284 -0
  155. package/dist/external/std-env.js +323 -0
  156. package/dist/external/streaming-iterables.d.ts +11 -0
  157. package/dist/external/supports-color.d.ts +1 -0
  158. package/dist/external/tar-fs.d.ts +31 -0
  159. package/dist/external/tar-fs.js +63 -16
  160. package/dist/external/validate-npm-package-name.d.ts +4 -0
  161. package/dist/external/which.d.ts +25 -0
  162. package/dist/external/which.js +2 -2
  163. package/dist/external/yargs-parser.d.ts +2 -0
  164. package/dist/external/yargs-parser.js +11 -3
  165. package/dist/external/yoctocolors-cjs.d.ts +51 -0
  166. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  167. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  168. package/dist/external-tools/bazel/resolve.d.ts +3 -0
  169. package/dist/external-tools/bazel/resolve.js +3 -0
  170. package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
  171. package/dist/external-tools/cdxgen/asset-names.js +3 -3
  172. package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
  173. package/dist/external-tools/cdxgen/from-download.js +1 -1
  174. package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
  175. package/dist/external-tools/cdxgen/resolve.js +4 -1
  176. package/dist/external-tools/cdxgen/types.d.ts +1 -1
  177. package/dist/external-tools/from-download.d.ts +2 -2
  178. package/dist/external-tools/from-download.js +1 -1
  179. package/dist/external-tools/janus/asset-names.d.ts +4 -1
  180. package/dist/external-tools/janus/asset-names.js +3 -0
  181. package/dist/external-tools/janus/from-download.d.ts +3 -3
  182. package/dist/external-tools/janus/from-download.js +2 -2
  183. package/dist/external-tools/janus/resolve.d.ts +3 -0
  184. package/dist/external-tools/janus/resolve.js +3 -0
  185. package/dist/external-tools/jre/asset-names.d.ts +3 -1
  186. package/dist/external-tools/jre/asset-names.js +2 -0
  187. package/dist/external-tools/jre/detect-platform-arch.js +1 -1
  188. package/dist/external-tools/jre/from-download.d.ts +1 -1
  189. package/dist/external-tools/manifest.d.ts +5 -3
  190. package/dist/external-tools/manifest.js +5 -3
  191. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  192. package/dist/external-tools/opengrep/resolve.d.ts +3 -0
  193. package/dist/external-tools/opengrep/resolve.js +3 -0
  194. package/dist/external-tools/python/asset-names.d.ts +3 -1
  195. package/dist/external-tools/python/asset-names.js +8 -4
  196. package/dist/external-tools/python/pin.js +3 -1
  197. package/dist/external-tools/python/resolve.d.ts +3 -0
  198. package/dist/external-tools/python/resolve.js +3 -0
  199. package/dist/external-tools/python/uv-install.d.ts +89 -0
  200. package/dist/external-tools/python/uv-install.js +165 -0
  201. package/dist/external-tools/sbt/resolve.d.ts +3 -0
  202. package/dist/external-tools/sbt/resolve.js +3 -0
  203. package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
  204. package/dist/external-tools/skillspector/from-uv.js +56 -0
  205. package/dist/external-tools/skillspector/resolve.d.ts +18 -3
  206. package/dist/external-tools/skillspector/resolve.js +21 -8
  207. package/dist/external-tools/skillspector/types.d.ts +3 -1
  208. package/dist/external-tools/synp/resolve.d.ts +3 -0
  209. package/dist/external-tools/synp/resolve.js +3 -0
  210. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  211. package/dist/external-tools/trivy/resolve.d.ts +3 -0
  212. package/dist/external-tools/trivy/resolve.js +3 -0
  213. package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
  214. package/dist/external-tools/trufflehog/asset-names.js +3 -0
  215. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  216. package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
  217. package/dist/external-tools/trufflehog/resolve.js +3 -0
  218. package/dist/external-tools/uv/asset-names.d.ts +36 -0
  219. package/dist/external-tools/uv/asset-names.js +73 -0
  220. package/dist/external-tools/uv/from-download.d.ts +17 -0
  221. package/dist/external-tools/uv/from-download.js +50 -0
  222. package/dist/external-tools/uv/from-path.d.ts +5 -0
  223. package/dist/external-tools/uv/from-path.js +22 -0
  224. package/dist/external-tools/uv/from-vfs.d.ts +7 -0
  225. package/dist/external-tools/uv/from-vfs.js +26 -0
  226. package/dist/external-tools/uv/resolve.d.ts +28 -0
  227. package/dist/external-tools/uv/resolve.js +64 -0
  228. package/dist/external-tools/uv/types.d.ts +24 -0
  229. package/dist/external-tools/uv/types.js +2 -0
  230. package/dist/fleet/repo-config.d.ts +55 -0
  231. package/dist/fleet/repo-config.js +81 -0
  232. package/dist/fs/_internal.d.ts +1 -1
  233. package/dist/fs/_internal.js +1 -1
  234. package/dist/fs/access.d.ts +2 -0
  235. package/dist/fs/access.js +2 -0
  236. package/dist/fs/copy.d.ts +88 -0
  237. package/dist/fs/copy.js +89 -0
  238. package/dist/fs/find.js +1 -2
  239. package/dist/fs/inspect.d.ts +2 -2
  240. package/dist/fs/read-file.js +3 -4
  241. package/dist/fs/safe.js +2 -2
  242. package/dist/git/_internal.js +7 -3
  243. package/dist/github/commit.d.ts +92 -0
  244. package/dist/github/commit.js +113 -0
  245. package/dist/github/ghsa.js +1 -1
  246. package/dist/github/refs-graphql.js +1 -1
  247. package/dist/github/refs.js +10 -15
  248. package/dist/github/request.js +1 -1
  249. package/dist/github/token.d.ts +5 -2
  250. package/dist/github/token.js +6 -4
  251. package/dist/github/workflow-runs.d.ts +107 -0
  252. package/dist/github/workflow-runs.js +98 -0
  253. package/dist/globs/_internal.js +1 -1
  254. package/dist/http-request/_internal.d.ts +1 -1
  255. package/dist/http-request/browser.d.ts +6 -0
  256. package/dist/http-request/browser.js +4 -3
  257. package/dist/http-request/checksum-file.js +1 -1
  258. package/dist/http-request/download.js +2 -0
  259. package/dist/http-request/headers.d.ts +1 -1
  260. package/dist/http-request/headers.js +2 -2
  261. package/dist/http-request/request-attempt.js +6 -3
  262. package/dist/http-request/request-types.d.ts +10 -1
  263. package/dist/http-request/request.js +2 -2
  264. package/dist/http-request/user-agent.d.ts +23 -2
  265. package/dist/http-request/user-agent.js +48 -6
  266. package/dist/integrity.d.ts +127 -78
  267. package/dist/integrity.js +170 -84
  268. package/dist/json/format.js +4 -1
  269. package/dist/logger/_internal.d.ts +13 -15
  270. package/dist/logger/_internal.js +21 -21
  271. package/dist/logger/colors.d.ts +10 -5
  272. package/dist/logger/colors.js +7 -14
  273. package/dist/logger/console-methods.js +2 -2
  274. package/dist/logger/console.d.ts +1 -0
  275. package/dist/logger/console.js +9 -9
  276. package/dist/logger/node.js +2 -1
  277. package/dist/logger/symbols-builder.js +7 -8
  278. package/dist/logger/symbols.js +8 -8
  279. package/dist/native-messaging/install.js +1 -1
  280. package/dist/native-messaging/rate-limit.d.ts +4 -1
  281. package/dist/native-messaging/rate-limit.js +4 -1
  282. package/dist/node/events.d.ts +3 -0
  283. package/dist/node/events.js +3 -0
  284. package/dist/node/fs.d.ts +1 -1
  285. package/dist/node/module.d.ts +73 -2
  286. package/dist/node/module.js +97 -12
  287. package/dist/node/timers-promises.d.ts +3 -0
  288. package/dist/node/timers-promises.js +3 -0
  289. package/dist/node/url.d.ts +3 -0
  290. package/dist/node/url.js +3 -0
  291. package/dist/npm/meta-cache.d.ts +183 -0
  292. package/dist/npm/meta-cache.js +318 -0
  293. package/dist/npm/meta-slice.d.ts +27 -0
  294. package/dist/npm/meta-slice.js +68 -0
  295. package/dist/npm/meta-types.d.ts +282 -0
  296. package/dist/npm/meta-types.js +2 -0
  297. package/dist/npm/meta.d.ts +125 -0
  298. package/dist/npm/meta.js +347 -0
  299. package/dist/npm/registry.d.ts +212 -0
  300. package/dist/npm/registry.js +284 -0
  301. package/dist/objects/getters.d.ts +1 -1
  302. package/dist/objects/getters.js +1 -1
  303. package/dist/objects/predicates.js +1 -1
  304. package/dist/packages/exports.js +2 -2
  305. package/dist/packages/isolation.js +1 -1
  306. package/dist/packages/manifest.d.ts +29 -0
  307. package/dist/packages/manifest.js +44 -9
  308. package/dist/packages/metadata-extensions.js +2 -4
  309. package/dist/packages/normalize.js +1 -1
  310. package/dist/packages/provenance.d.ts +8 -0
  311. package/dist/packages/provenance.js +10 -2
  312. package/dist/packages/specs.js +1 -1
  313. package/dist/packages/tarball.js +1 -2
  314. package/dist/packages/validation.d.ts +0 -10
  315. package/dist/packages/validation.js +0 -14
  316. package/dist/paths/_internal.d.ts +1 -7
  317. package/dist/paths/_internal.js +9 -15
  318. package/dist/paths/conversion.js +1 -1
  319. package/dist/paths/exts.d.ts +30 -0
  320. package/dist/paths/exts.js +30 -0
  321. package/dist/paths/filenames.d.ts +6 -0
  322. package/dist/paths/filenames.js +6 -0
  323. package/dist/paths/globs.d.ts +6 -0
  324. package/dist/paths/globs.js +6 -0
  325. package/dist/paths/normalize.js +1 -1
  326. package/dist/paths/predicates.js +2 -1
  327. package/dist/paths/resolve.js +19 -14
  328. package/dist/paths/socket.d.ts +81 -30
  329. package/dist/paths/socket.js +102 -28
  330. package/dist/perf/metrics.js +1 -1
  331. package/dist/perf/report.js +5 -3
  332. package/dist/pkg-ext/data.js +0 -2
  333. package/dist/primordials/globals.d.ts +1 -1
  334. package/dist/primordials/globals.js +1 -1
  335. package/dist/primordials/headers.d.ts +13 -1
  336. package/dist/primordials/headers.js +13 -1
  337. package/dist/primordials/process.d.ts +1 -1
  338. package/dist/primordials/process.js +1 -1
  339. package/dist/primordials/url.d.ts +18 -0
  340. package/dist/primordials/url.js +18 -0
  341. package/dist/process/spawn/child.js +3 -5
  342. package/dist/promises/_internal.d.ts +1 -1
  343. package/dist/promises/_internal.js +1 -2
  344. package/dist/promises/options.js +3 -3
  345. package/dist/regexps/spec.js +1 -1
  346. package/dist/releases/socket-btm-binary-naming.js +12 -1
  347. package/dist/schema/validate.js +1 -1
  348. package/dist/secrets/_internal.d.ts +1 -1
  349. package/dist/secrets/_internal.js +1 -1
  350. package/dist/secrets/broker.d.ts +35 -0
  351. package/dist/secrets/broker.js +72 -0
  352. package/dist/secrets/find.d.ts +8 -6
  353. package/dist/secrets/find.js +17 -3
  354. package/dist/secrets/keychain.d.ts +10 -1
  355. package/dist/secrets/keychain.js +10 -1
  356. package/dist/secrets/rc.js +1 -1
  357. package/dist/secrets/socket-api-token.d.ts +1 -1
  358. package/dist/secrets/socket-api-token.js +1 -1
  359. package/dist/secrets/types.d.ts +1 -1
  360. package/dist/smol/detect.js +1 -1
  361. package/dist/smol/http.d.ts +2 -0
  362. package/dist/smol/http.js +3 -1
  363. package/dist/smol/https.d.ts +2 -0
  364. package/dist/smol/https.js +3 -1
  365. package/dist/smol/manifest.js +1 -1
  366. package/dist/smol/path.js +1 -1
  367. package/dist/smol/primordial.js +1 -1
  368. package/dist/smol/purl.js +1 -1
  369. package/dist/smol/versions.js +1 -1
  370. package/dist/smol/vfs.js +1 -1
  371. package/dist/sorts/_internal.d.ts +2 -4
  372. package/dist/sorts/_internal.js +1 -7
  373. package/dist/sorts/semver.js +2 -2
  374. package/dist/spinner/create-spinner-class.js +1 -1
  375. package/dist/spinner/format.js +2 -4
  376. package/dist/stdio/footer.js +8 -7
  377. package/dist/stdio/progress.js +1 -1
  378. package/dist/stdio/prompts.d.ts +8 -23
  379. package/dist/stdio/prompts.js +28 -52
  380. package/dist/strings/format.js +1 -1
  381. package/dist/strings/predicates.d.ts +2 -2
  382. package/dist/strings/search.js +2 -2
  383. package/dist/strings/types.d.ts +4 -0
  384. package/dist/strings/width.d.ts +1 -0
  385. package/dist/strings/width.js +17 -8
  386. package/dist/themes/context.d.ts +18 -3
  387. package/dist/themes/context.js +28 -14
  388. package/dist/versions/_internal.d.ts +43 -13
  389. package/dist/versions/_internal.js +27 -15
  390. package/dist/versions/compare.d.ts +16 -10
  391. package/dist/versions/compare.js +36 -16
  392. package/dist/versions/parse.js +1 -1
  393. package/dist/versions/range.js +3 -2
  394. package/dist/words/pluralize.js +4 -1
  395. package/llms.txt +63 -0
  396. package/package.json +271 -40
@@ -2,15 +2,15 @@
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_string = require('../../primordials/string.js');
5
6
  const require_primordials_math = require('../../primordials/math.js');
6
7
  const require_primordials_map_set = require('../../primordials/map-set.js');
7
- const require_primordials_string = require('../../primordials/string.js');
8
- const require_primordials_regexp = require('../../primordials/regexp.js');
9
8
  const require_primordials_date = require('../../primordials/date.js');
10
9
  const require_primordials_json = require('../../primordials/json.js');
11
10
  const require_cacache_clear = require('../../cacache/clear.js');
12
11
  const require_cacache_read = require('../../cacache/read.js');
13
12
  const require_cacache_write = require('../../cacache/write.js');
13
+ const require_cache_ttl__internal = require('./_internal.js');
14
14
 
15
15
  //#region src/cache/ttl/store.ts
16
16
  /**
@@ -30,9 +30,6 @@ const require_cacache_write = require('../../cacache/write.js');
30
30
  * - Clock-skew detection: entries with suspiciously-far-future `expiresAt` are
31
31
  * treated as expired.
32
32
  */
33
- const DEFAULT_TTL_MS = 300 * 1e3;
34
- const DEFAULT_PREFIX = "ttl-cache";
35
- const DEFAULT_MEMO_MAX_SIZE = 1e3;
36
33
  /**
37
34
  * Create a TTL-based cache instance.
38
35
  *
@@ -47,50 +44,30 @@ function createTtlCache(options) {
47
44
  const opts = {
48
45
  __proto__: null,
49
46
  memoize: true,
50
- memoMaxSize: DEFAULT_MEMO_MAX_SIZE,
51
- prefix: DEFAULT_PREFIX,
52
- ttl: DEFAULT_TTL_MS,
47
+ memoMaxSize: require_cache_ttl__internal.DEFAULT_MEMO_MAX_SIZE,
48
+ prefix: require_cache_ttl__internal.DEFAULT_PREFIX,
49
+ ttl: require_cache_ttl__internal.DEFAULT_TTL_MS,
53
50
  ...options
54
51
  };
55
52
  if (opts.prefix?.includes("*")) throw new require_primordials_error.TypeErrorCtor("Cache prefix cannot contain wildcards (*). Use clear({ prefix: \"pattern*\" }) for wildcard matching.");
56
53
  const memoCache = new require_primordials_map_set.MapCtor();
57
- const memoMaxSize = require_primordials_math.MathMax(1, opts.memoMaxSize ?? DEFAULT_MEMO_MAX_SIZE);
54
+ const memoMaxSize = require_primordials_math.MathMax(1, opts.memoMaxSize ?? 1e3);
58
55
  function memoSet(fullKey, entry) {
59
- /* c8 ignore start */
60
- if (memoCache.has(fullKey)) memoCache.delete(fullKey);
61
- else if (memoCache.size >= memoMaxSize) {
62
- const oldest = memoCache.keys().next().value;
63
- if (oldest !== void 0) memoCache.delete(oldest);
64
- }
65
- /* c8 ignore stop */
66
- memoCache.set(fullKey, entry);
56
+ require_cache_ttl__internal.lruSet(memoCache, memoMaxSize, fullKey, entry);
67
57
  }
68
- /* c8 ignore next */
69
- const ttl = opts.ttl ?? DEFAULT_TTL_MS;
58
+ /* c8 ignore next - default-ttl fallback arm */
59
+ const ttl = opts.ttl ?? 3e5;
70
60
  /**
71
61
  * Build full cache key with prefix.
72
62
  */
73
63
  function buildKey(key) {
74
64
  return `${opts.prefix}:${key}`;
75
65
  }
76
- /**
77
- * Check if entry is expired. Also detects clock skew by treating suspiciously
78
- * far-future expiresAt as expired.
79
- */
80
66
  function isExpired(entry) {
81
- const now = require_primordials_date.DateNow();
82
- if (entry.expiresAt > now + ttl + 1e4) return true;
83
- return now > entry.expiresAt;
67
+ return require_cache_ttl__internal.isExpiredEntry(entry, ttl);
84
68
  }
85
- /**
86
- * Create a matcher function for a pattern (with wildcard support). Returns a
87
- * function that tests if a key matches the pattern.
88
- */
89
69
  function createMatcher(pattern) {
90
- const fullPattern = buildKey(pattern);
91
- if (!pattern.includes("*")) return (key) => require_primordials_string.StringPrototypeStartsWith(key, fullPattern);
92
- const regex = new require_primordials_regexp.RegExpCtor(`^${require_primordials_string.StringPrototypeReplaceAll(require_primordials_string.StringPrototypeReplaceAll(fullPattern, /[.+?^${}()|[\]\\]/g, "\\$&"), "*", ".*")}$`);
93
- return (key) => require_primordials_regexp.RegExpPrototypeTest(regex, key);
70
+ return require_cache_ttl__internal.createKeyMatcher(opts.prefix ?? "ttl-cache", pattern);
94
71
  }
95
72
  async function get(key) {
96
73
  if (require_primordials_string.StringPrototypeIncludes(key, "*")) throw new require_primordials_error.TypeErrorCtor("Cache key cannot contain wildcards (*). Use getAll(pattern) to retrieve multiple entries.");
@@ -1,9 +1,20 @@
1
1
  /**
2
2
  * @file Public type surface for `cache/ttl/*` modules — the `TtlCache`
3
- * interface (the seven-method API returned by `createTtlCache`), the
4
- * `TtlCacheEntry` storage shape, and the `TtlCacheOptions` / `ClearOptions`
5
- * configuration records. Pure types, no runtime side effects.
3
+ * interface (the seven-method API returned by `createTtlCache` and
4
+ * `createBrowserTtlCache`), the `TtlCacheEntry` storage shape, the
5
+ * `TtlCacheStorage` adapter contract for the browser store's persistent
6
+ * tier, and the `TtlCacheOptions` / `BrowserTtlCacheOptions` /
7
+ * `ClearOptions` configuration records. Pure types, no runtime side
8
+ * effects.
6
9
  */
10
+ export interface BrowserTtlCacheOptions extends TtlCacheOptions {
11
+ /**
12
+ * Storage adapter backing the persistent tier — wrap `chrome.storage.local`,
13
+ * `sessionStorage` / `localStorage`, IndexedDB, or anything else with a
14
+ * key-value string surface. Omit for a memo-only (in-memory) cache.
15
+ */
16
+ storage?: TtlCacheStorage | undefined;
17
+ }
7
18
  export interface ClearOptions {
8
19
  /**
9
20
  * Only clear in-memory memoization cache, not persistent cache. Useful for
@@ -107,3 +118,35 @@ export interface TtlCacheOptions {
107
118
  */
108
119
  prefix?: string | undefined;
109
120
  }
121
+ /**
122
+ * Key-value string storage adapter for `createBrowserTtlCache`'s persistent
123
+ * tier. Every method may be sync or async; keys are FULL (prefixed) cache
124
+ * keys, values are JSON-serialized `TtlCacheEntry` payloads. The shape is
125
+ * structurally compatible with `window.sessionStorage` / `localStorage`, and
126
+ * `chrome.storage.local` wraps in a few lines. Adapter failures are always
127
+ * swallowed by the cache — the memo tier is the source of truth.
128
+ */
129
+ export interface TtlCacheStorage {
130
+ /**
131
+ * Read the raw serialized entry for a key. Return `null` or `undefined`
132
+ * for a miss (`null` is accepted so Web Storage objects satisfy the shape
133
+ * directly); a rejection or throw is treated as a miss.
134
+ */
135
+ getItem(key: string): Promise<string | null | undefined> | string | null | undefined;
136
+ /**
137
+ * Optional enumeration of every key currently in the backing store. When
138
+ * present, wildcard operations (`getAll` / `deleteAll` / `clear`) cover
139
+ * entries written by previous sessions; without it they cover only the
140
+ * keys currently in the memo tier.
141
+ */
142
+ keys?(): Promise<string[]> | string[];
143
+ /**
144
+ * Remove one key. Failures are swallowed (best-effort removal).
145
+ */
146
+ removeItem(key: string): Promise<void> | void;
147
+ /**
148
+ * Persist the raw serialized entry. Failures are swallowed — the memo tier
149
+ * remains the source of truth.
150
+ */
151
+ setItem(key: string, value: string): Promise<void> | void;
152
+ }
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @file GENERATED — do not edit by hand. Run `node
3
- * scripts/post-build/make-primordials-defaults.mts` (also runs as part of
4
- * `pnpm run build`) to regenerate from the `globals` npm package's
3
+ * scripts/repo/post-build/make-primordials-defaults.mts` (also runs as part
4
+ * of `pnpm run build`) to regenerate from the `globals` npm package's
5
5
  * globals.json crossed against src/primordials/*.ts `Ctor` exports. Source:
6
6
  * globals@<bumped via taze>, env = builtin ∪ node. Filter: identifiers
7
7
  * socket-lib exports as `<name>Ctor`.
8
8
  */
9
9
  /**
10
- * Fleet-canonical alias map: socket-lib mirrors standard JS + Node globals with
11
- * a `Ctor` suffix. Downstream repos that destructure raw `primordials` use this
12
- * map to resolve the source-side name to socket-lib's export.
10
+ * Socket-canonical alias map: socket-lib mirrors standard JS + Node globals
11
+ * with a `Ctor` suffix. Downstream repos that destructure raw `primordials` use
12
+ * this map to resolve the source-side name to socket-lib's export.
13
13
  */
14
14
  export declare const DEFAULT_ALIAS_MAP: Readonly<Record<string, string>>;
15
15
  /**
@@ -6,16 +6,16 @@ const require_primordials_object = require('../primordials/object.js');
6
6
  //#region src/checks/primordials-defaults.ts
7
7
  /**
8
8
  * @file GENERATED — do not edit by hand. Run `node
9
- * scripts/post-build/make-primordials-defaults.mts` (also runs as part of
10
- * `pnpm run build`) to regenerate from the `globals` npm package's
9
+ * scripts/repo/post-build/make-primordials-defaults.mts` (also runs as part
10
+ * of `pnpm run build`) to regenerate from the `globals` npm package's
11
11
  * globals.json crossed against src/primordials/*.ts `Ctor` exports. Source:
12
12
  * globals@<bumped via taze>, env = builtin ∪ node. Filter: identifiers
13
13
  * socket-lib exports as `<name>Ctor`.
14
14
  */
15
15
  /**
16
- * Fleet-canonical alias map: socket-lib mirrors standard JS + Node globals with
17
- * a `Ctor` suffix. Downstream repos that destructure raw `primordials` use this
18
- * map to resolve the source-side name to socket-lib's export.
16
+ * Socket-canonical alias map: socket-lib mirrors standard JS + Node globals
17
+ * with a `Ctor` suffix. Downstream repos that destructure raw `primordials` use
18
+ * this map to resolve the source-side name to socket-lib's export.
19
19
  */
20
20
  const DEFAULT_ALIAS_MAP = require_primordials_object.ObjectFreeze({
21
21
  __proto__: null,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file Primordials drift check — generic core. Each fleet repo that
2
+ * @file Primordials drift check — generic core. Each Socket repo that
3
3
  * destructures from Node's internal `primordials` global needs to keep its
4
4
  * usage shape-aligned with socket-lib's userland mirror
5
5
  * (`@socketsecurity/lib/primordials`). This module is the parser + diff
@@ -10,7 +10,7 @@ node_path = require_runtime.__toESM(node_path);
10
10
 
11
11
  //#region src/checks/primordials.ts
12
12
  /**
13
- * @file Primordials drift check — generic core. Each fleet repo that
13
+ * @file Primordials drift check — generic core. Each Socket repo that
14
14
  * destructures from Node's internal `primordials` global needs to keep its
15
15
  * usage shape-aligned with socket-lib's userland mirror
16
16
  * (`@socketsecurity/lib/primordials`). This module is the parser + diff
@@ -65,11 +65,13 @@ function checkPrimordials(config) {
65
65
  }
66
66
  const socketLibNames = readSocketLibPrimordialNames(resolveSocketLibPrimordials(config));
67
67
  const findings = [];
68
- for (const name of [...used].toSorted()) {
68
+ const usedNames = [...used].toSorted();
69
+ for (let i = 0, { length } = usedNames; i < length; i += 1) {
70
+ const name = usedNames[i];
69
71
  if (config.nodeInternalOnly.has(name)) continue;
70
72
  if (socketLibNames.has(name)) continue;
71
73
  const aliased = config.aliasMap.get(name);
72
- /* c8 ignore start */
74
+ /* c8 ignore start - usedToFiles fallback is unreachable by construction */
73
75
  if (aliased) {
74
76
  if (socketLibNames.has(aliased)) continue;
75
77
  findings.push({
@@ -140,12 +142,15 @@ function extractPrimordialsNames(src) {
140
142
  const re = /const\s*\{\s*([^}]*?)\}\s*=\s*primordials\b/g;
141
143
  const out = [];
142
144
  let m;
143
- while ((m = re.exec(cleaned)) !== null) for (const raw of m[1].split(",")) {
144
- const trimmed = raw.trim();
145
- if (!trimmed) continue;
146
- const nameMatch = NAME_HEAD_RE.exec(trimmed);
147
- /* c8 ignore start */
148
- if (nameMatch) out.push(nameMatch[1]);
145
+ while ((m = re.exec(cleaned)) !== null) {
146
+ const rawNames = m[1].split(",");
147
+ for (let i = 0, { length } = rawNames; i < length; i += 1) {
148
+ const trimmed = rawNames[i].trim();
149
+ if (!trimmed) continue;
150
+ const nameMatch = NAME_HEAD_RE.exec(trimmed);
151
+ /* c8 ignore start - malformed export-list segments aren't tested */
152
+ if (nameMatch) out.push(nameMatch[1]);
153
+ }
149
154
  }
150
155
  return out;
151
156
  }
@@ -159,12 +164,15 @@ function extractTsExports(src) {
159
164
  const out = /* @__PURE__ */ new Set();
160
165
  for (const m of src.matchAll(/^export\s+(?:declare\s+)?const\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm)) out.add(m[1]);
161
166
  for (const m of src.matchAll(/^export\s+(?:declare\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm)) out.add(m[1]);
162
- for (const m of src.matchAll(/^export\s*\{\s*([^}]+)\}/gm)) for (const raw of m[1].split(",")) {
163
- const trimmed = raw.trim();
164
- if (!trimmed) continue;
165
- const nameMatch = NAME_HEAD_RE.exec(trimmed);
166
- /* c8 ignore start */
167
- if (nameMatch) out.add(nameMatch[1]);
167
+ for (const m of src.matchAll(/^export\s*\{\s*([^}]+)\}/gm)) {
168
+ const rawNames = m[1].split(",");
169
+ for (let i = 0, { length } = rawNames; i < length; i += 1) {
170
+ const trimmed = rawNames[i].trim();
171
+ if (!trimmed) continue;
172
+ const nameMatch = NAME_HEAD_RE.exec(trimmed);
173
+ /* c8 ignore start - malformed export-list segments aren't tested */
174
+ if (nameMatch) out.add(nameMatch[1]);
175
+ }
168
176
  }
169
177
  return [...out];
170
178
  }
@@ -176,7 +184,7 @@ function extractTsExports(src) {
176
184
  function readSocketLibPrimordialNames(resolved) {
177
185
  if ((0, node_fs.statSync)(resolved).isFile()) return new Set(extractTsExports((0, node_fs.readFileSync)(resolved, "utf8")));
178
186
  const out = /* @__PURE__ */ new Set();
179
- /* c8 ignore start */
187
+ /* c8 ignore start - leaf-classification branches aren't tested separately */
180
188
  for (const name of (0, node_fs.readdirSync)(resolved)) {
181
189
  if (!name.endsWith(".ts") && !name.endsWith(".d.ts")) continue;
182
190
  const full = node_path.default.join(resolved, name);
@@ -203,7 +211,7 @@ function readSocketLibPrimordialNames(resolved) {
203
211
  * Throws when none of the candidates exist.
204
212
  */
205
213
  function resolveSocketLibPrimordials(config) {
206
- /* c8 ignore start */
214
+ /* c8 ignore start - resolver branch needs dedicated test setup per candidate */
207
215
  if (config.socketLibPrimordialsPath) {
208
216
  if (!(0, node_fs.existsSync)(config.socketLibPrimordialsPath)) throw new require_primordials_error.ErrorCtor(`socketLibPrimordialsPath does not exist: ${config.socketLibPrimordialsPath}`);
209
217
  return config.socketLibPrimordialsPath;
@@ -10,6 +10,7 @@
10
10
  * error)
11
11
  */
12
12
  import type { PrimordialsCheckConfig, PrimordialsCheckResult, PrimordialsFinding } from '../checks/primordials';
13
+ export declare const FALLBACK_CONFIG_PATHS: readonly string[];
13
14
  export interface ParsedArgs {
14
15
  readonly config: string | undefined;
15
16
  readonly json: boolean;
@@ -39,8 +40,12 @@ export declare function renderHuman(result: PrimordialsCheckResult, args: Parsed
39
40
  * they typed). Otherwise probes the fallback list in order and returns the
40
41
  * first hit. Returns the head of the list when none exist, so the caller's
41
42
  * "config file not found" error message names the canonical default.
43
+ *
44
+ * `baseDir` is the directory the relative candidates resolve against; it
45
+ * defaults to `process.cwd()` (the repo root the user runs from) and is a
46
+ * parameter so callers/tests can probe a fixture tree without `process.chdir`.
42
47
  */
43
- export declare function resolveConfigPath(explicit: string | undefined): string;
48
+ export declare function resolveConfigPath(explicit: string | undefined, baseDir?: string): string;
44
49
  export declare function runCheckPrimordials(argv: readonly string[]): Promise<number>;
45
50
  export declare function serialize(result: PrimordialsCheckResult): {
46
51
  ok: boolean;
@@ -32,7 +32,11 @@ node_path = require_runtime.__toESM(node_path);
32
32
  */
33
33
  const logger = require_logger_default.getDefaultLogger();
34
34
  const DEFAULT_CONFIG_PATH = ".socket-lib.json";
35
- const FALLBACK_CONFIG_PATHS = [".socket-lib.json", ".config/socket-lib.json"];
35
+ const FALLBACK_CONFIG_PATHS = [
36
+ ".socket-lib.json",
37
+ ".config/socket-lib.json",
38
+ ".config/repo/socket-lib.json"
39
+ ];
36
40
  const CONFIG_SECTION = "primordials";
37
41
  function loadConfig(configPath) {
38
42
  if (!(0, node_fs.existsSync)(configPath)) throw new require_primordials_error.ErrorCtor(`config file not found: ${configPath}`);
@@ -96,7 +100,7 @@ function printHelp() {
96
100
  logger.log("");
97
101
  logger.log("Options:");
98
102
  logger.log(` --config, -c <path> Config file. Default: ${DEFAULT_CONFIG_PATH}`);
99
- logger.log(` (falls back to .config/socket-lib.json)`);
103
+ logger.log(` (falls back to .config/socket-lib.json, then .config/repo/socket-lib.json)`);
100
104
  logger.log(" --explain Print one detailed line per finding.");
101
105
  logger.log(" --json Machine-readable JSON output.");
102
106
  logger.log(" --silent Silent on success.");
@@ -110,7 +114,7 @@ function printHelp() {
110
114
  logger.log(" }");
111
115
  logger.log("");
112
116
  logger.log("Only `scanDirs` is required. `aliasMap` and `nodeInternalOnly`");
113
- logger.log("default to the fleet-canonical sets and only need entries when");
117
+ logger.log("default to the Socket-canonical sets and only need entries when");
114
118
  logger.log("your repo extends or overrides them.");
115
119
  logger.log("");
116
120
  logger.log("A bare object (no `primordials` section) is also accepted for");
@@ -140,12 +144,16 @@ function renderHuman(result, args) {
140
144
  * they typed). Otherwise probes the fallback list in order and returns the
141
145
  * first hit. Returns the head of the list when none exist, so the caller's
142
146
  * "config file not found" error message names the canonical default.
147
+ *
148
+ * `baseDir` is the directory the relative candidates resolve against; it
149
+ * defaults to `process.cwd()` (the repo root the user runs from) and is a
150
+ * parameter so callers/tests can probe a fixture tree without `process.chdir`.
143
151
  */
144
- function resolveConfigPath(explicit) {
152
+ function resolveConfigPath(explicit, baseDir = node_process.default.cwd()) {
145
153
  if (explicit !== void 0) return explicit;
146
154
  for (let i = 0, { length } = FALLBACK_CONFIG_PATHS; i < length; i += 1) {
147
155
  const candidate = FALLBACK_CONFIG_PATHS[i];
148
- if ((0, node_fs.existsSync)(node_path.default.resolve(candidate))) return candidate;
156
+ if ((0, node_fs.existsSync)(node_path.default.resolve(baseDir, candidate))) return candidate;
149
157
  }
150
158
  return FALLBACK_CONFIG_PATHS[0];
151
159
  }
@@ -187,6 +195,7 @@ function serialize(result) {
187
195
  }
188
196
 
189
197
  //#endregion
198
+ exports.FALLBACK_CONFIG_PATHS = FALLBACK_CONFIG_PATHS;
190
199
  exports.loadConfig = loadConfig;
191
200
  exports.parseArgs = parseArgs;
192
201
  exports.printHelp = printHelp;
package/dist/cli/check.js CHANGED
@@ -18,7 +18,7 @@ const logger = require_logger_default.getDefaultLogger();
18
18
  const CHECKS = new require_primordials_map_set.MapCtor([["primordials", "primordials"], ["prim", "primordials"]]);
19
19
  const ALIASES = new require_primordials_map_set.MapCtor([["primordials", ["prim"]]]);
20
20
  function printHelp() {
21
- logger.log("socket-lib check — fleet-wide static-analysis checks");
21
+ logger.log("socket-lib check — Socket-wide static-analysis checks");
22
22
  logger.log("");
23
23
  logger.log("Usage:");
24
24
  logger.log(" socket-lib check <name> [...opts]");
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * @file `socket-lib` CLI entry point — top-level dispatcher. socket-lib — print
4
- * help, list commands socket-lib check <name> [opts...] — run a fleet-wide
4
+ * help, list commands socket-lib check <name> [opts...] — run a Socket-wide
5
5
  * check Subcommands live as siblings under `src/cli/`; each is its own file
6
6
  * so a misbehaving check can't crash other commands at parse time. The
7
7
  * dispatcher just routes; subcommands own their own arg parsing. The CLI is
@@ -11,7 +11,7 @@ node_process = require_runtime.__toESM(node_process);
11
11
  //#region src/cli/socket-lib.ts
12
12
  /**
13
13
  * @file `socket-lib` CLI entry point — top-level dispatcher. socket-lib — print
14
- * help, list commands socket-lib check <name> [opts...] — run a fleet-wide
14
+ * help, list commands socket-lib check <name> [opts...] — run a Socket-wide
15
15
  * check Subcommands live as siblings under `src/cli/`; each is its own file
16
16
  * so a misbehaving check can't crash other commands at parse time. The
17
17
  * dispatcher just routes; subcommands own their own arg parsing. The CLI is
@@ -21,13 +21,13 @@ node_process = require_runtime.__toESM(node_process);
21
21
  */
22
22
  const logger = require_logger_default.getDefaultLogger();
23
23
  function printHelp() {
24
- logger.log("socket-lib — fleet-wide static-analysis CLI");
24
+ logger.log("socket-lib — Socket-wide static-analysis CLI");
25
25
  logger.log("");
26
26
  logger.log("Usage:");
27
27
  logger.log(" socket-lib <command> [...args]");
28
28
  logger.log("");
29
29
  logger.log("Commands:");
30
- logger.log(" check <name> Run a fleet-wide check (primordials, ...).");
30
+ logger.log(" check <name> Run a Socket-wide check (primordials, ...).");
31
31
  logger.log("");
32
32
  logger.log("Run `socket-lib check --help` for the list of checks.");
33
33
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file Socket terminal-color palette — mirrors the CSS design tokens defined
3
- * in the fleet's `template/styles/tokens.css` (light / dark / synthwave
3
+ * in Socket's `template/styles/tokens.css` (light / dark / synthwave
4
4
  * themes). Each helper returns the input string wrapped in a 24-bit ANSI
5
5
  * escape sequence so the rendered hex matches the brand exactly; no rounding
6
6
  * to the legacy 8-color palette. Picocolors / yoctocolors only ship a fixed
@@ -37,11 +37,13 @@ export declare function compressBrotliFile(srcPath: string, options: CompressFil
37
37
  * The `pipeline` from `node:stream/promises` is the safe way to wire it up — it
38
38
  * handles error propagation across all stages.
39
39
  */
40
- export declare function createBrotliCompressor(options?: CompressOptions | undefined): import("zlib").BrotliCompress;
40
+ export declare function createBrotliCompressor(options?: CompressOptions | undefined): import("node:zlib").BrotliCompress;
41
41
  /**
42
42
  * Create a brotli decompress transform stream.
43
+ *
44
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
43
45
  */
44
- export declare function createBrotliDecompressor(): import("zlib").BrotliDecompress;
46
+ export declare function createBrotliDecompressor(): import("node:zlib").BrotliDecompress;
45
47
  /**
46
48
  * Decompress a brotli-compressed Buffer.
47
49
  */
@@ -70,6 +72,8 @@ export declare function hasBrotliExt(filePath: string): boolean;
70
72
  * false for inputs too short to be valid. Brotli has no fixed magic bytes, so
71
73
  * this is intentionally permissive — the authoritative test is
72
74
  * `decompressBrotli(buf)` succeeding. Use for UI hints, not correctness.
75
+ *
76
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
73
77
  */
74
78
  export declare function isBrotliCompressed(input: Buffer): boolean;
75
79
  /**
@@ -4,8 +4,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
5
  const require_primordials_buffer = require('../primordials/buffer.js');
6
6
  const require_primordials_error = require('../primordials/error.js');
7
- const require_primordials_map_set = require('../primordials/map-set.js');
8
7
  const require_primordials_string = require('../primordials/string.js');
8
+ const require_primordials_map_set = require('../primordials/map-set.js');
9
9
  const require_fs_safe = require('../fs/safe.js');
10
10
  const require_compression__internal = require('./_internal.js');
11
11
  let node_fs = require("node:fs");
@@ -46,6 +46,8 @@ function createBrotliCompressor(options) {
46
46
  }
47
47
  /**
48
48
  * Create a brotli decompress transform stream.
49
+ *
50
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
49
51
  */
50
52
  function createBrotliDecompressor() {
51
53
  return (0, node_zlib.createBrotliDecompress)();
@@ -77,6 +79,8 @@ function hasBrotliExt(filePath) {
77
79
  * false for inputs too short to be valid. Brotli has no fixed magic bytes, so
78
80
  * this is intentionally permissive — the authoritative test is
79
81
  * `decompressBrotli(buf)` succeeding. Use for UI hints, not correctness.
82
+ *
83
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
80
84
  */
81
85
  function isBrotliCompressed(input) {
82
86
  return require_primordials_buffer.BufferIsBuffer(input) && input.byteLength >= BROTLI_MIN_LEN;
@@ -30,11 +30,13 @@ export declare function compressGzipFile(srcPath: string, options: CompressFileO
30
30
  /**
31
31
  * Create a gzip compress transform stream.
32
32
  */
33
- export declare function createGzipCompressor(options?: CompressOptions | undefined): import("zlib").Gzip;
33
+ export declare function createGzipCompressor(options?: CompressOptions | undefined): import("node:zlib").Gzip;
34
34
  /**
35
35
  * Create a gzip decompress transform stream.
36
+ *
37
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
36
38
  */
37
- export declare function createGzipDecompressor(): import("zlib").Gunzip;
39
+ export declare function createGzipDecompressor(): import("node:zlib").Gunzip;
38
40
  /**
39
41
  * Decompress a gzip-compressed Buffer.
40
42
  */
@@ -59,6 +61,8 @@ export declare function hasGzipExt(filePath: string): boolean;
59
61
  /**
60
62
  * Magic-byte check for gzip. Reads the first two bytes and matches the gzip
61
63
  * spec's 0x1f 0x8b signature. Authoritative.
64
+ *
65
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
62
66
  */
63
67
  export declare function isGzipCompressed(input: Buffer): boolean;
64
68
  /**
@@ -4,8 +4,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
5
  const require_primordials_buffer = require('../primordials/buffer.js');
6
6
  const require_primordials_error = require('../primordials/error.js');
7
- const require_primordials_map_set = require('../primordials/map-set.js');
8
7
  const require_primordials_string = require('../primordials/string.js');
8
+ const require_primordials_map_set = require('../primordials/map-set.js');
9
9
  const require_fs_safe = require('../fs/safe.js');
10
10
  const require_compression__internal = require('./_internal.js');
11
11
  let node_fs = require("node:fs");
@@ -30,7 +30,8 @@ const GZIP_EXTS = new require_primordials_map_set.SetCtor([
30
30
  * compression. Default level is 6 (zlib default).
31
31
  */
32
32
  async function compressGzip(input, options) {
33
- return await gzipAsync(typeof input === "string" ? require_primordials_buffer.BufferFrom(input, "utf8") : input, resolveGzipOptions(options));
33
+ const buf = typeof input === "string" ? require_primordials_buffer.BufferFrom(input, "utf8") : input;
34
+ return await gzipAsync(buf, resolveGzipOptions(options));
34
35
  }
35
36
  async function compressGzipFile(srcPath, destOrOptions, maybeOptions) {
36
37
  const { destPath, options, inPlace } = require_compression__internal.resolveFileArgs("compressGzipFile", srcPath, destOrOptions, maybeOptions, (p) => `${p}.gz`);
@@ -46,6 +47,8 @@ function createGzipCompressor(options) {
46
47
  }
47
48
  /**
48
49
  * Create a gzip decompress transform stream.
50
+ *
51
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
49
52
  */
50
53
  function createGzipDecompressor() {
51
54
  return (0, node_zlib.createGunzip)();
@@ -76,6 +79,8 @@ function hasGzipExt(filePath) {
76
79
  /**
77
80
  * Magic-byte check for gzip. Reads the first two bytes and matches the gzip
78
81
  * spec's 0x1f 0x8b signature. Authoritative.
82
+ *
83
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
79
84
  */
80
85
  function isGzipCompressed(input) {
81
86
  return require_primordials_buffer.BufferIsBuffer(input) && input.byteLength >= 2 && input[0] === GZIP_MAGIC_0 && input[1] === GZIP_MAGIC_1;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file Read a layered config — a base config that higher layers may override
3
+ * or extend. Generic over the layer directories, the base name, and the file
4
+ * extension: `readConfigLayers('vitest', { dirs: ['.config/base',
5
+ * '.config/local'] })` reads each `<dir>/vitest.json` in precedence order and
6
+ * returns the layers that exist. Callers apply their own merge, because merge
7
+ * policy varies (a denylist unions all layers; an allowlist takes the highest
8
+ * layer that declares one; an array key concatenates). `mergeConfigArray`
9
+ * covers the concat case across any number of layers. No Socket-specific
10
+ * knowledge lives here — the Socket-convention `.config/fleet` +
11
+ * `.config/repo` wrapper is `fleet/repo-config`'s `resolveRepoConfig`, a thin
12
+ * layer over this reader.
13
+ */
14
+ export interface ReadConfigLayersOptions {
15
+ dirs: readonly string[];
16
+ rootDir?: string | undefined;
17
+ cwd?: string | undefined;
18
+ ext?: string | undefined;
19
+ }
20
+ /**
21
+ * Concatenate one array-valued key across all layers — the common merge for a
22
+ * list that higher layers EXTEND rather than replace (e.g. extra exclude
23
+ * globs). Layers contribute in precedence order; a non-array value for the key
24
+ * (or a missing key, or an `undefined` layer) contributes nothing.
25
+ *
26
+ * @param layers - The layers from `readConfigLayers` (or any object array).
27
+ * @param key - The array-valued property to concatenate.
28
+ *
29
+ * @returns Each layer's entries in order; `[]` when no layer has the array.
30
+ */
31
+ export declare function mergeConfigArray<T extends Record<string, unknown>, K extends keyof T>(layers: ReadonlyArray<T | undefined>, key: K): Array<T[K] extends Array<infer E> ? E : never>;
32
+ /**
33
+ * Read a named config from an ordered list of layer directories.
34
+ *
35
+ * For each dir in `dirs`, reads `<rootDir>/<dir>/<name><ext>`; layers that are
36
+ * absent or unparseable are skipped (never throws — config reads are
37
+ * best-effort). The returned array preserves `dirs` order (lowest precedence
38
+ * first), so the last element is the highest-precedence layer present.
39
+ *
40
+ * @example
41
+ * ;```typescript
42
+ * const layers = readConfigLayers<VitestConfig>('vitest', {
43
+ * dirs: ['.config/base', '.config/team', '.config/local'],
44
+ * })
45
+ * // layers === every one of those that existed, in that order
46
+ * ```
47
+ *
48
+ * @param name - Base name of the config file (no directory, no extension).
49
+ * @param options - Layer dirs + resolution options.
50
+ *
51
+ * @returns Parsed layers in precedence order; empty when none exist.
52
+ */
53
+ export declare function readConfigLayers<T = unknown>(name: string, options: ReadConfigLayersOptions): T[];