@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
@@ -26,18 +26,17 @@ src_external__socketregistry_is_unicode_supported = require_runtime.__toESM(src_
26
26
  */
27
27
  function buildLoggerSymbols(theme) {
28
28
  const supported = (0, src_external__socketregistry_is_unicode_supported.default)();
29
- const colors = require_logger_colors.getYoctocolors();
30
29
  /* c8 ignore start - ASCII-fallback symbol arms only fire on
31
30
  terminals without unicode support; tests run on unicode TTYs. */
32
31
  return {
33
32
  __proto__: null,
34
- fail: require_logger_colors.applyColor(supported ? "✖" : "×", theme.colors.error, colors),
35
- info: require_logger_colors.applyColor(supported ? "ℹ" : "i", theme.colors.info, colors),
36
- progress: require_logger_colors.applyColor(supported ? "∴" : ":.", theme.colors.step, colors),
37
- skip: require_logger_colors.applyColor(supported ? "↻" : "@", theme.colors.step, colors),
38
- step: require_logger_colors.applyColor(supported ? "→" : ">", theme.colors.step, colors),
39
- success: require_logger_colors.applyColor(supported ? "✔" : "√", theme.colors.success, colors),
40
- warn: require_logger_colors.applyColor(supported ? "⚠" : "‼", theme.colors.warning, colors)
33
+ fail: require_logger_colors.applyColor(supported ? "✖" : "×", theme.colors.error),
34
+ info: require_logger_colors.applyColor(supported ? "ℹ" : "i", theme.colors.info),
35
+ progress: require_logger_colors.applyColor(supported ? "∴" : ":.", theme.colors.step),
36
+ skip: require_logger_colors.applyColor(supported ? "↻" : "@", theme.colors.step),
37
+ step: require_logger_colors.applyColor(supported ? "→" : ">", theme.colors.step),
38
+ success: require_logger_colors.applyColor(supported ? "✔" : "√", theme.colors.success),
39
+ warn: require_logger_colors.applyColor(supported ? "⚠" : "‼", theme.colors.warning)
41
40
  };
42
41
  /* c8 ignore stop */
43
42
  }
@@ -39,14 +39,14 @@ function createLogSymbols() {
39
39
  const stepColor = theme.colors.step;
40
40
  /* c8 ignore start - ASCII-fallback symbol arms only fire on
41
41
  terminals without unicode support; tests run on unicode TTYs. */
42
- target["fail"] = require_logger_colors.applyColor(supported ? "✖" : "×", errorColor, colors);
43
- target["info"] = require_logger_colors.applyColor(supported ? "ℹ" : "i", infoColor, colors);
44
- target["progress"] = require_logger_colors.applyColor(supported ? "∴" : ":.", stepColor, colors);
45
- target["reason"] = colors.dim(require_logger_colors.applyColor(supported ? "∴" : ":.", warningColor, colors));
46
- target["skip"] = require_logger_colors.applyColor(supported ? "↻" : "@", stepColor, colors);
47
- target["step"] = require_logger_colors.applyColor(supported ? "→" : ">", stepColor, colors);
48
- target["success"] = require_logger_colors.applyColor(supported ? "✔" : "√", successColor, colors);
49
- target["warn"] = require_logger_colors.applyColor(supported ? "⚠" : "‼", warningColor, colors);
42
+ target["fail"] = require_logger_colors.applyColor(supported ? "✖" : "×", errorColor);
43
+ target["info"] = require_logger_colors.applyColor(supported ? "ℹ" : "i", infoColor);
44
+ target["progress"] = require_logger_colors.applyColor(supported ? "∴" : ":.", stepColor);
45
+ target["reason"] = colors.dim(require_logger_colors.applyColor(supported ? "∴" : ":.", warningColor));
46
+ target["skip"] = require_logger_colors.applyColor(supported ? "↻" : "@", stepColor);
47
+ target["step"] = require_logger_colors.applyColor(supported ? "→" : ">", stepColor);
48
+ target["success"] = require_logger_colors.applyColor(supported ? "✔" : "√", successColor);
49
+ target["warn"] = require_logger_colors.applyColor(supported ? "⚠" : "‼", warningColor);
50
50
  /* c8 ignore stop */
51
51
  };
52
52
  const init = () => {
@@ -9,11 +9,11 @@ const require_env_windows = require('../env/windows.js');
9
9
  const require_constants_node = require('../constants/node.js');
10
10
  const require_env_node_version_managers = require('../env/node-version-managers.js');
11
11
  let node_fs = require("node:fs");
12
+ let node_url = require("node:url");
12
13
  let node_process = require("node:process");
13
14
  node_process = require_runtime.__toESM(node_process);
14
15
  let node_path = require("node:path");
15
16
  node_path = require_runtime.__toESM(node_path);
16
- let node_url = require("node:url");
17
17
  let _socketsecurity_lib_stable_process_spawn_child = require("@socketsecurity/lib-stable/process/spawn/child");
18
18
 
19
19
  //#region src/native-messaging/install.ts
@@ -14,7 +14,7 @@
14
14
  * That's exactly what we want: an attacker who can force Chrome to relaunch
15
15
  * has bigger problems than rate-limiting. Shape patterned after pilcrow's
16
16
  * `ratelimit/limit.go` — minimal, in-memory, LRU-evicts at `maxKeys`. The
17
- * fleet's `socket-lib` already has a TTL-cache module but it's overkill for
17
+ * Socket's `socket-lib` already has a TTL-cache module but it's overkill for
18
18
  * this one use case; a 50-line bucket is easier to audit.
19
19
  */
20
20
  export interface TokenBucketOptions {
@@ -45,6 +45,9 @@ export interface BucketEntry {
45
45
  older: BucketEntry | undefined;
46
46
  key: string;
47
47
  }
48
+ /**
49
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
50
+ */
48
51
  export declare class TokenBucketLimiter {
49
52
  #private;
50
53
  constructor(options: TokenBucketOptions);
@@ -20,9 +20,12 @@ const require_primordials_error = require('../primordials/error.js');
20
20
  * That's exactly what we want: an attacker who can force Chrome to relaunch
21
21
  * has bigger problems than rate-limiting. Shape patterned after pilcrow's
22
22
  * `ratelimit/limit.go` — minimal, in-memory, LRU-evicts at `maxKeys`. The
23
- * fleet's `socket-lib` already has a TTL-cache module but it's overkill for
23
+ * Socket's `socket-lib` already has a TTL-cache module but it's overkill for
24
24
  * this one use case; a 50-line bucket is easier to audit.
25
25
  */
26
+ /**
27
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
28
+ */
26
29
  var TokenBucketLimiter = class {
27
30
  #capacity;
28
31
  #refillIntervalMs;
@@ -3,4 +3,7 @@
3
3
  * rationale shared across all `node/*.ts` lazy-loaders.
4
4
  */
5
5
  import type * as NodeEvents from 'node:events';
6
+ /**
7
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
8
+ */
6
9
  export declare function getNodeEvents(): typeof NodeEvents;
@@ -5,6 +5,9 @@ const require_constants_runtime = require('../constants/runtime.js');
5
5
 
6
6
  //#region src/node/events.ts
7
7
  let events;
8
+ /**
9
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
10
+ */
8
11
  function getNodeEvents() {
9
12
  if (!require_constants_runtime.IS_NODE) return;
10
13
  return events ??= /*@__PURE__*/ require("events");
package/dist/node/fs.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * load-time snapshot. Two surfaces: `getNodeFs()` returns the module object
13
13
  * with LATE method lookup (spy-able — the test seam); the `fs<Method>` consts
14
14
  * (`fsExistsSync`, `fsReadFileSync`, …) are method references FROZEN at load
15
- * (tamper-proof against a method swap, not spy-able), for the fleet's hot fs
15
+ * (tamper-proof against a method swap, not spy-able), for Socket's hot fs
16
16
  * calls. Both stay browser-safe behind IS_NODE + `/*@__PURE__*\/`.
17
17
  */
18
18
  import type * as NodeFs from 'node:fs';
@@ -1,7 +1,78 @@
1
1
  /**
2
- * @file Lazy-loader for `node:module`. See `node/fs.ts` for the design
3
- * rationale shared across all `node/*.ts` lazy-loaders.
2
+ * @file Accessors for `node:module` that work across runtimes. Ambient
3
+ * `require` is bound in CommonJS but unbound in ESM and inside
4
+ * ahead-of-time-compiled package modules (e.g. Perry), where reading it
5
+ * throws. And Perry's `require('module')` value omits `isBuiltin`. So instead
6
+ * of the ambient `require('module')` lazy-loader, `isBuiltin`/`createRequire`
7
+ * are imported as named values from the bare `module` specifier — which
8
+ * resolves on Node and Perry, and which browser bundlers can stub via
9
+ * resolve.fallback (a `node:` prefix would throw UnhandledSchemeError
10
+ * there).
11
+ * `require` is DIRECTORY-SPECIFIC: `createRequire(base)` resolves relative
12
+ * specifiers (`./x`, `../y`) from `base`'s directory. For builtins and bare
13
+ * packages that's irrelevant (they resolve the same anywhere), so the cached
14
+ * `getRequire` / `requireBuiltin` bind to THIS file. A RELATIVE specifier
15
+ * must resolve from the CALLER's directory, so use `requireFrom` with the
16
+ * caller's `import.meta.url` — binding such a load to this file would resolve
17
+ * it against `src/node/` instead. Bundled, every module collapses to one base
18
+ * and either works; unbundled (e.g. AOT-compiled from source), each module
19
+ * sits at its own nested path and the base matters.
4
20
  */
5
21
  import type * as NodeModule from 'node:module';
22
+ /**
23
+ * Bind a working `require`. Ambient `require` exists in CommonJS; in ESM and
24
+ * ahead-of-time-compiled package modules it is unbound (reading it throws or
25
+ * yields undefined), so fall back to `createRequire`. Returns undefined off
26
+ * Node and in browsers, where neither is available.
27
+ *
28
+ * `fromUrl` sets the resolution base — pass a caller's `import.meta.url` to
29
+ * resolve that caller's RELATIVE specifiers. When omitted, the base is this
30
+ * file, which is correct only for builtins / bare packages (dir-independent).
31
+ * With `fromUrl` the ambient `require` is skipped: it is bound to THIS file, so
32
+ * it would resolve a relative specifier from the wrong directory.
33
+ */
34
+ export declare function bindRequire(fromUrl?: string | undefined): ((id: string) => unknown) | undefined;
35
+ /**
36
+ * Returns `node:module` (or undefined off Node), loaded through the bound
37
+ * `require`. Cached across calls.
38
+ */
6
39
  export declare function getNodeModule(): typeof NodeModule;
40
+ /**
41
+ * Returns a working `require` bound to THIS file, binding one on first call
42
+ * (see bindRequire). Cached across calls; undefined off Node / in browsers.
43
+ *
44
+ * For builtins and bare packages only — the resolution base is this file, so a
45
+ * relative specifier would resolve from `src/node/`. Use `requireFrom` for
46
+ * relative loads.
47
+ */
48
+ export declare function getRequire(): ((id: string) => unknown) | undefined;
49
+ /**
50
+ * Is `name` a Node built-in module? Resolved from the statically-imported
51
+ * `isBuiltin`, so it works on Node and on ahead-of-time-compiled binaries
52
+ * (Perry), where ambient `require('module')` would lack `isBuiltin`. Returns
53
+ * false in browsers, where the bare `module` import is stubbed away.
54
+ *
55
+ * Single source of truth for "is this a Node builtin?" probes across socket-lib
56
+ * (used by the smol-binding loaders to gate their `node:smol-*` loads).
57
+ */
7
58
  export declare function isNodeBuiltin(name: string): boolean;
59
+ /**
60
+ * Load a built-in module by *computed* specifier through the bound `require`
61
+ * (see getRequire). The specifier is a parameter — never a literal at the call
62
+ * site — so browser bundlers neither walk nor bundle it. Returns undefined
63
+ * where no `require` can be bound.
64
+ *
65
+ * Builtins / bare packages only (dir-independent); for a relative specifier use
66
+ * `requireFrom`. Used by `getNodeModule` for `node:module`, and by the
67
+ * smol-binding loaders for the optional `node:smol-*` native bindings (gated
68
+ * behind `isNodeBuiltin`, true only on socket-btm's smol Node binary).
69
+ */
70
+ export declare function requireBuiltin(specifier: string): unknown;
71
+ /**
72
+ * Load a module by specifier from a CALLER-supplied base (its
73
+ * `import.meta.url`). Use this for RELATIVE specifiers (`./x`, `../y`), whose
74
+ * resolution depends on the caller's directory — `requireBuiltin` binds to this
75
+ * file and would resolve them from `src/node/`. Not cached: the binding is
76
+ * per-caller. Returns undefined where no `require` can be bound.
77
+ */
78
+ export declare function requireFrom(fromUrl: string, specifier: string): unknown;
@@ -2,30 +2,115 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_constants_runtime = require('../constants/runtime.js');
5
+ let module$1 = require("module");
5
6
 
6
7
  //#region src/node/module.ts
8
+ /**
9
+ * @file Accessors for `node:module` that work across runtimes. Ambient
10
+ * `require` is bound in CommonJS but unbound in ESM and inside
11
+ * ahead-of-time-compiled package modules (e.g. Perry), where reading it
12
+ * throws. And Perry's `require('module')` value omits `isBuiltin`. So instead
13
+ * of the ambient `require('module')` lazy-loader, `isBuiltin`/`createRequire`
14
+ * are imported as named values from the bare `module` specifier — which
15
+ * resolves on Node and Perry, and which browser bundlers can stub via
16
+ * resolve.fallback (a `node:` prefix would throw UnhandledSchemeError
17
+ * there).
18
+ * `require` is DIRECTORY-SPECIFIC: `createRequire(base)` resolves relative
19
+ * specifiers (`./x`, `../y`) from `base`'s directory. For builtins and bare
20
+ * packages that's irrelevant (they resolve the same anywhere), so the cached
21
+ * `getRequire` / `requireBuiltin` bind to THIS file. A RELATIVE specifier
22
+ * must resolve from the CALLER's directory, so use `requireFrom` with the
23
+ * caller's `import.meta.url` — binding such a load to this file would resolve
24
+ * it against `src/node/` instead. Bundled, every module collapses to one base
25
+ * and either works; unbundled (e.g. AOT-compiled from source), each module
26
+ * sits at its own nested path and the base matters.
27
+ */
7
28
  let cachedModule;
8
- function getNodeModule() {
29
+ let cachedRequire;
30
+ /**
31
+ * Bind a working `require`. Ambient `require` exists in CommonJS; in ESM and
32
+ * ahead-of-time-compiled package modules it is unbound (reading it throws or
33
+ * yields undefined), so fall back to `createRequire`. Returns undefined off
34
+ * Node and in browsers, where neither is available.
35
+ *
36
+ * `fromUrl` sets the resolution base — pass a caller's `import.meta.url` to
37
+ * resolve that caller's RELATIVE specifiers. When omitted, the base is this
38
+ * file, which is correct only for builtins / bare packages (dir-independent).
39
+ * With `fromUrl` the ambient `require` is skipped: it is bound to THIS file, so
40
+ * it would resolve a relative specifier from the wrong directory.
41
+ */
42
+ function bindRequire(fromUrl) {
9
43
  if (!require_constants_runtime.IS_NODE) return;
10
- return cachedModule ??= /*@__PURE__*/ require("module");
44
+ if (!fromUrl && typeof require === "function") return require;
45
+ if (typeof module$1.createRequire === "function") try {
46
+ return (0, module$1.createRequire)(fromUrl ?? require("url").pathToFileURL(__filename).href);
47
+ } catch {
48
+ return;
49
+ }
50
+ }
51
+ /**
52
+ * Returns `node:module` (or undefined off Node), loaded through the bound
53
+ * `require`. Cached across calls.
54
+ */
55
+ function getNodeModule() {
56
+ return cachedModule ??= requireBuiltin("module");
11
57
  }
12
58
  /**
13
- * Lazy + cached reference to `node:module`'s `isBuiltin(name)`. First call
14
- * resolves the binding; subsequent calls dispatch through the cached function
15
- * reference. Safe to detach — `isBuiltin` is `this`-free.
59
+ * Returns a working `require` bound to THIS file, binding one on first call
60
+ * (see bindRequire). Cached across calls; undefined off Node / in browsers.
16
61
  *
17
- * Returns `false` in browser / non-CJS environments where `require` is
18
- * undefined no `node:` modules are built-in there.
62
+ * For builtins and bare packages only the resolution base is this file, so a
63
+ * relative specifier would resolve from `src/node/`. Use `requireFrom` for
64
+ * relative loads.
65
+ */
66
+ function getRequire() {
67
+ if (cachedRequire === void 0) cachedRequire = bindRequire();
68
+ return cachedRequire;
69
+ }
70
+ /**
71
+ * Is `name` a Node built-in module? Resolved from the statically-imported
72
+ * `isBuiltin`, so it works on Node and on ahead-of-time-compiled binaries
73
+ * (Perry), where ambient `require('module')` would lack `isBuiltin`. Returns
74
+ * false in browsers, where the bare `module` import is stubbed away.
19
75
  *
20
76
  * Single source of truth for "is this a Node builtin?" probes across socket-lib
21
- * (used by the smol-binding loaders to gate `require('node:smol-*')`).
77
+ * (used by the smol-binding loaders to gate their `node:smol-*` loads).
22
78
  */
23
- let cachedIsBuiltin;
24
79
  function isNodeBuiltin(name) {
25
- if (!require_constants_runtime.IS_NODE) return false;
26
- return (cachedIsBuiltin ??= getNodeModule().isBuiltin)(name);
80
+ if (!require_constants_runtime.IS_NODE || typeof module$1.isBuiltin !== "function") return false;
81
+ return (0, module$1.isBuiltin)(name);
82
+ }
83
+ /**
84
+ * Load a built-in module by *computed* specifier through the bound `require`
85
+ * (see getRequire). The specifier is a parameter — never a literal at the call
86
+ * site — so browser bundlers neither walk nor bundle it. Returns undefined
87
+ * where no `require` can be bound.
88
+ *
89
+ * Builtins / bare packages only (dir-independent); for a relative specifier use
90
+ * `requireFrom`. Used by `getNodeModule` for `node:module`, and by the
91
+ * smol-binding loaders for the optional `node:smol-*` native bindings (gated
92
+ * behind `isNodeBuiltin`, true only on socket-btm's smol Node binary).
93
+ */
94
+ function requireBuiltin(specifier) {
95
+ const req = getRequire();
96
+ if (req) return req(specifier);
97
+ }
98
+ /**
99
+ * Load a module by specifier from a CALLER-supplied base (its
100
+ * `import.meta.url`). Use this for RELATIVE specifiers (`./x`, `../y`), whose
101
+ * resolution depends on the caller's directory — `requireBuiltin` binds to this
102
+ * file and would resolve them from `src/node/`. Not cached: the binding is
103
+ * per-caller. Returns undefined where no `require` can be bound.
104
+ */
105
+ function requireFrom(fromUrl, specifier) {
106
+ const req = bindRequire(fromUrl);
107
+ if (req) return req(specifier);
27
108
  }
28
109
 
29
110
  //#endregion
111
+ exports.bindRequire = bindRequire;
30
112
  exports.getNodeModule = getNodeModule;
31
- exports.isNodeBuiltin = isNodeBuiltin;
113
+ exports.getRequire = getRequire;
114
+ exports.isNodeBuiltin = isNodeBuiltin;
115
+ exports.requireBuiltin = requireBuiltin;
116
+ exports.requireFrom = requireFrom;
@@ -3,4 +3,7 @@
3
3
  * rationale shared across all `node/*.ts` lazy-loaders.
4
4
  */
5
5
  import type * as NodeTimersPromises from 'node:timers/promises';
6
+ /**
7
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
8
+ */
6
9
  export declare function getNodeTimersPromises(): typeof NodeTimersPromises;
@@ -5,6 +5,9 @@ const require_constants_runtime = require('../constants/runtime.js');
5
5
 
6
6
  //#region src/node/timers-promises.ts
7
7
  let timersPromises;
8
+ /**
9
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
10
+ */
8
11
  function getNodeTimersPromises() {
9
12
  if (!require_constants_runtime.IS_NODE) return;
10
13
  return timersPromises ??= /*@__PURE__*/ require("timers/promises");
@@ -3,4 +3,7 @@
3
3
  * shared across all `node/*.ts` lazy-loaders.
4
4
  */
5
5
  import type * as NodeUrl from 'node:url';
6
+ /**
7
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
8
+ */
6
9
  export declare function getNodeUrl(): typeof NodeUrl;
package/dist/node/url.js CHANGED
@@ -5,6 +5,9 @@ const require_constants_runtime = require('../constants/runtime.js');
5
5
 
6
6
  //#region src/node/url.ts
7
7
  let cachedUrl;
8
+ /**
9
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
10
+ */
8
11
  function getNodeUrl() {
9
12
  if (!require_constants_runtime.IS_NODE) return;
10
13
  return cachedUrl ??= /*@__PURE__*/ require("url");
@@ -0,0 +1,183 @@
1
+ /**
2
+ * @file Cached packument fetch — `getPackumentSlim` wires the pure slicer
3
+ * (`./meta-slice`) to an injectable HTTP adapter and the repo's
4
+ * `createTtlCache` (memo + cacache persistence + in-flight dedupe via
5
+ * `getOrFetch`). Every `getPackumentSlim`-backed cache is actually three
6
+ * `TtlCache` instances sharing one cacache directory (`getCachePeers`): the
7
+ * primary cache (the object callers hold), a persisted long-TTL last
8
+ * known-good store (`-stale` prefix, `STALE_TTL_MS`), and a short-TTL
9
+ * storm-control marker (`-storm` prefix, `STALE_SERVE_TTL_MS`). Three
10
+ * failure-handling policies layer on top:
11
+ *
12
+ * - **`force`** bypasses a cached entry EXCEPT when it was written within the
13
+ * last 30 seconds, so a burst of forced refreshes coalesces into one
14
+ * upstream fetch instead of hammering the registry. A forced refresh NEVER
15
+ * removes the existing entry before fetching — on failure, whatever was
16
+ * cached before the call is untouched, and serve-stale-on-error (below)
17
+ * still has the persisted last-known-good value to fall back on.
18
+ * - **Negative caching** is narrow and short: only a definitive HTTP 404
19
+ * (package/version genuinely absent) is cached, for `NEGATIVE_TTL_MS`, and
20
+ * only when the persisted stale store holds no known-good data for that
21
+ * key. A transient error (network failure, 5xx) is NEVER negative-cached,
22
+ * and a still-fresh negative entry is discarded rather than trusted the
23
+ * moment known-good data exists in the persisted stale store — a retry
24
+ * always outranks a cached "not found" over real data.
25
+ * - **Serve-stale-on-error**: every successful fetch also persists the
26
+ * `PackumentMetaSlim` to the stale store, independent of the primary
27
+ * entry's own TTL — `STALE_TTL_MS` (7 days) comfortably outlives it, so the
28
+ * value survives both the primary entry's expiry and a process restart. If
29
+ * a later refresh fails for ANY reason — including a fresh 404 — the
30
+ * persisted value is served instead of propagating the error, and the
31
+ * storm-control marker is (re)written so a burst of callers within
32
+ * `STALE_SERVE_TTL_MS` is served without re-hitting a registry that just
33
+ * failed. ETag revalidation requires a header-capable HTTP adapter; the
34
+ * current `NpmMetaHttpAdapter` is header-less by design so test doubles and
35
+ * `httpJson` stay interchangeable with the rest of the npm client surface —
36
+ * see `NpmMetaHttpAdapter`.
37
+ */
38
+ import type { GetPackumentSlimOptions, NpmMetaHttpAdapter, PackumentMetaSlim, PackumentVariant } from './meta-types';
39
+ import type { TtlCache, TtlCacheOptions } from '../cache/ttl/types';
40
+ /**
41
+ * A cached, successfully-fetched packument.
42
+ */
43
+ export interface CachedPackumentHit {
44
+ cachedAt: number;
45
+ kind: 'hit';
46
+ meta: PackumentMetaSlim;
47
+ }
48
+ /**
49
+ * A cached definitive-404 result — narrow and short-lived (`NEGATIVE_TTL_MS`);
50
+ * see the file-level doc for when this is written.
51
+ */
52
+ export interface CachedPackumentMiss {
53
+ cachedAt: number;
54
+ kind: 'miss';
55
+ status: number;
56
+ }
57
+ /**
58
+ * The value shape stored per cache key — either a successful fetch or a
59
+ * short-lived negative (404) result.
60
+ */
61
+ export type CachedPackumentEntry = CachedPackumentHit | CachedPackumentMiss;
62
+ /**
63
+ * Thrown by `getPackumentSlim` (and the `getVersions` / `getLatestVersion`
64
+ * exact-version / dist-tag lookups) when a specific package, version, or tag
65
+ * is definitively absent. Carries `status` so `extractHttpStatus` reports it
66
+ * the same way as a real `HttpResponseError`.
67
+ */
68
+ export declare class PackumentNotFoundError extends Error {
69
+ packageName: string;
70
+ status: number;
71
+ constructor(packageName: string, status: number, message?: string | undefined);
72
+ }
73
+ /**
74
+ * Build the cache key for one (registry, name, variant) tuple. Normalizes
75
+ * `registry` first (`normalizeRegistryUrl`) so two spellings of the same
76
+ * registry collapse to one key.
77
+ */
78
+ export declare function buildMetaCacheKey(registry: string, name: string, variant: PackumentVariant): string;
79
+ /**
80
+ * Deep-clone a `PackumentMetaSlim` via a JSON round-trip — plain
81
+ * JSON-roundtrippable data (strings, numbers, booleans, records), so this is
82
+ * 3-5x faster than `structuredClone` and avoids the HTML structured-clone
83
+ * algorithm entirely. Used at every public read boundary so no two callers
84
+ * ever hold a reference to the same cached object.
85
+ */
86
+ export declare function cloneMeta(meta: PackumentMetaSlim): PackumentMetaSlim;
87
+ /**
88
+ * Companion long-TTL (persisted stale) and short-TTL (storm-control) caches
89
+ * that back one primary `TtlCache` instance — see the file-level doc.
90
+ */
91
+ export interface NpmMetaCachePeers {
92
+ stale: TtlCache;
93
+ storm: TtlCache;
94
+ }
95
+ /**
96
+ * Create a dedicated npm-meta cache instance — same `prefix` /
97
+ * default-`ttl` as the module singleton, overridable per-call. Use this (vs.
98
+ * the default singleton) for test isolation or a non-default TTL. Also
99
+ * creates and registers this instance's persisted-stale + storm-control
100
+ * companions (`registerCachePeers`).
101
+ */
102
+ export declare function createNpmMetaCache(options?: TtlCacheOptions | undefined): TtlCache;
103
+ /**
104
+ * The uncached fetch attempt for one packument, run through the negative-cache
105
+ * decision: on success, persists the result to `staleCache` and returns a
106
+ * `hit`; on a definitive 404 with no persisted stale data, returns a `miss`
107
+ * (a normal, non-throwing outcome the caller decides how to cache); any other
108
+ * failure (transient error, or a 404 when stale data DOES exist) rethrows so
109
+ * the caller's serve-stale-on-error path can take over.
110
+ */
111
+ export declare function fetchAndCacheEntry(name: string, key: string, fetchOptions: ResolvedPackumentFetchOptions, staleCache: TtlCache): Promise<CachedPackumentEntry>;
112
+ /**
113
+ * `GetPackumentSlimOptions` with every field the fetch path needs resolved to
114
+ * a concrete value (defaults applied) — the shape `fetchPackumentSlim` and
115
+ * `getPackumentSlim`'s cache-key logic operate on internally.
116
+ */
117
+ export interface ResolvedPackumentFetchOptions {
118
+ http: NpmMetaHttpAdapter;
119
+ registry: string;
120
+ retries: number;
121
+ timeout?: number | undefined;
122
+ variant: PackumentVariant;
123
+ }
124
+ /**
125
+ * The uncached fetch — GET the packument with the variant's `Accept` header
126
+ * and slice it. Split out so `getPackumentSlim`'s cache-key / force logic
127
+ * stays readable. Throws (never negative-caches itself — that decision is
128
+ * `getPackumentSlim`'s, which has the context to know whether stale data
129
+ * already exists for this key).
130
+ */
131
+ export declare function fetchPackumentSlim(name: string, resolved: ResolvedPackumentFetchOptions): Promise<PackumentMetaSlim>;
132
+ /**
133
+ * Resolve the persisted-stale + storm-control companions for a primary cache
134
+ * instance, creating them lazily (under the default prefix) for a `TtlCache`
135
+ * that wasn't created via `createNpmMetaCache`.
136
+ */
137
+ export declare function getCachePeers(cache: TtlCache): NpmMetaCachePeers;
138
+ /**
139
+ * The module-level default cache instance, created lazily on first use.
140
+ */
141
+ export declare function getDefaultMetaCache(): TtlCache;
142
+ /**
143
+ * Fetch a package's packument, slice it down to `PackumentMetaSlim`, and
144
+ * cache the result. Concurrent calls for the same (registry, name, variant)
145
+ * dedupe to a single upstream request via the cache's `getOrFetch`. See the
146
+ * file-level doc for the `force` / negative-cache / serve-stale-on-error
147
+ * policies.
148
+ *
149
+ * @throws {PackumentNotFoundError} When the registry returns a definitive 404
150
+ * and no previously-good data exists for this key to serve instead.
151
+ */
152
+ export declare function getPackumentSlim(name: string, options?: GetPackumentSlimOptions | undefined): Promise<PackumentMetaSlim>;
153
+ /**
154
+ * Look up the persisted last known-good value for `key`, if any — backed by
155
+ * `STALE_TTL_MS` (7 days), independent of the primary cache's own TTL, and
156
+ * readable from a fresh process. Returns a fresh clone so no two callers ever
157
+ * share a reference to the same cached object.
158
+ */
159
+ export declare function getStaleMeta(cache: TtlCache, key: string): Promise<PackumentMetaSlim | undefined>;
160
+ /**
161
+ * Normalize a registry base URL so two spellings of the same registry
162
+ * collapse to one cache key and one request URL: lowercase the scheme+host,
163
+ * and ensure exactly one trailing slash. Falls back to the input unchanged
164
+ * when it isn't a parseable absolute URL.
165
+ */
166
+ export declare function normalizeRegistryUrl(registry: string): string;
167
+ /**
168
+ * Create and register the persisted-stale + storm-control companion caches
169
+ * for `cache` under `prefix`.
170
+ */
171
+ export declare function registerCachePeers(cache: TtlCache, prefix: string): NpmMetaCachePeers;
172
+ /**
173
+ * Persist `meta` as the last known-good value for `key`, independent of the
174
+ * primary entry's own TTL/expiry.
175
+ */
176
+ export declare function rememberStaleMeta(cache: TtlCache, key: string, meta: PackumentMetaSlim): Promise<void>;
177
+ /**
178
+ * Serve-stale-on-error: look up the persisted last known-good value and, when
179
+ * found, (re)write the storm-control marker so a burst of callers within
180
+ * `STALE_SERVE_TTL_MS` is served without re-hitting a registry that just
181
+ * failed.
182
+ */
183
+ export declare function serveStaleOnFailure(staleCache: TtlCache, stormCache: TtlCache, key: string): Promise<PackumentMetaSlim | undefined>;