@socketsecurity/lib 5.18.1 → 5.19.0

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 (305) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +6 -5
  3. package/dist/abort.d.ts +3 -0
  4. package/dist/abort.js +1 -0
  5. package/dist/agent.d.ts +66 -49
  6. package/dist/agent.js +51 -50
  7. package/dist/ansi.d.ts +2 -5
  8. package/dist/ansi.js +3 -2
  9. package/dist/archives.d.ts +25 -21
  10. package/dist/archives.js +35 -34
  11. package/dist/argv/flags.d.ts +100 -91
  12. package/dist/argv/flags.js +88 -87
  13. package/dist/argv/parse.d.ts +30 -40
  14. package/dist/argv/parse.js +33 -32
  15. package/dist/arrays.d.ts +4 -8
  16. package/dist/arrays.js +1 -0
  17. package/dist/bin.d.ts +7 -5
  18. package/dist/bin.js +52 -29
  19. package/dist/cacache.d.ts +13 -12
  20. package/dist/cacache.js +9 -8
  21. package/dist/cache-with-ttl.d.ts +53 -35
  22. package/dist/cache-with-ttl.js +1 -0
  23. package/dist/colors.d.ts +5 -5
  24. package/dist/colors.js +1 -0
  25. package/dist/constants/agents.d.ts +5 -9
  26. package/dist/constants/agents.js +3 -2
  27. package/dist/constants/core.d.ts +5 -10
  28. package/dist/constants/core.js +2 -1
  29. package/dist/constants/encoding.d.ts +3 -3
  30. package/dist/constants/encoding.js +1 -0
  31. package/dist/constants/github.d.ts +3 -3
  32. package/dist/constants/github.js +1 -0
  33. package/dist/constants/licenses.d.ts +9 -2
  34. package/dist/constants/licenses.js +1 -0
  35. package/dist/constants/lifecycle-script-names.js +1 -0
  36. package/dist/constants/maintained-node-versions.d.ts +3 -0
  37. package/dist/constants/maintained-node-versions.js +1 -0
  38. package/dist/constants/node.d.ts +125 -16
  39. package/dist/constants/node.js +74 -73
  40. package/dist/constants/package-default-node-range.d.ts +3 -1
  41. package/dist/constants/package-default-node-range.js +2 -1
  42. package/dist/constants/package-default-socket-categories.d.ts +0 -1
  43. package/dist/constants/package-default-socket-categories.js +1 -0
  44. package/dist/constants/packages.d.ts +12 -17
  45. package/dist/constants/packages.js +31 -16
  46. package/dist/constants/platform.d.ts +1 -2
  47. package/dist/constants/platform.js +2 -1
  48. package/dist/constants/process.d.ts +18 -0
  49. package/dist/constants/process.js +1 -0
  50. package/dist/constants/socket.d.ts +4 -10
  51. package/dist/constants/socket.js +2 -1
  52. package/dist/constants/testing.d.ts +3 -3
  53. package/dist/constants/testing.js +1 -0
  54. package/dist/constants/time.d.ts +3 -4
  55. package/dist/constants/time.js +1 -0
  56. package/dist/constants/typescript.d.ts +10 -3
  57. package/dist/constants/typescript.js +5 -4
  58. package/dist/cover/code.d.ts +3 -0
  59. package/dist/cover/code.js +12 -12
  60. package/dist/cover/formatters.d.ts +12 -9
  61. package/dist/cover/formatters.js +19 -18
  62. package/dist/cover/type.d.ts +3 -0
  63. package/dist/cover/type.js +1 -0
  64. package/dist/cover/types.js +1 -0
  65. package/dist/debug.d.ts +32 -47
  66. package/dist/debug.js +97 -96
  67. package/dist/dlx/arborist.d.ts +134 -0
  68. package/dist/dlx/arborist.js +177 -0
  69. package/dist/dlx/binary.d.ts +25 -9
  70. package/dist/dlx/binary.js +34 -12
  71. package/dist/dlx/cache.d.ts +1 -0
  72. package/dist/dlx/cache.js +2 -1
  73. package/dist/dlx/detect.d.ts +15 -0
  74. package/dist/dlx/detect.js +28 -20
  75. package/dist/dlx/dir.d.ts +1 -11
  76. package/dist/dlx/dir.js +2 -12
  77. package/dist/dlx/integrity.d.ts +86 -0
  78. package/dist/dlx/integrity.js +112 -0
  79. package/dist/dlx/lockfile.d.ts +115 -0
  80. package/dist/dlx/lockfile.js +139 -0
  81. package/dist/dlx/manifest.d.ts +26 -1
  82. package/dist/dlx/manifest.js +9 -6
  83. package/dist/dlx/package.d.ts +58 -3
  84. package/dist/dlx/package.js +101 -74
  85. package/dist/dlx/packages.d.ts +1 -11
  86. package/dist/dlx/packages.js +3 -14
  87. package/dist/dlx/paths.d.ts +1 -0
  88. package/dist/dlx/paths.js +2 -1
  89. package/dist/effects/pulse-frames.js +1 -0
  90. package/dist/effects/text-shimmer.d.ts +13 -2
  91. package/dist/effects/text-shimmer.js +50 -46
  92. package/dist/effects/types.js +1 -0
  93. package/dist/effects/ultra.js +1 -0
  94. package/dist/env/ci.d.ts +6 -1
  95. package/dist/env/ci.js +1 -0
  96. package/dist/env/debug.d.ts +5 -1
  97. package/dist/env/debug.js +1 -0
  98. package/dist/env/github.d.ts +19 -23
  99. package/dist/env/github.js +5 -4
  100. package/dist/env/helpers.d.ts +21 -9
  101. package/dist/env/helpers.js +5 -11
  102. package/dist/env/home.d.ts +17 -4
  103. package/dist/env/home.js +2 -1
  104. package/dist/env/locale.d.ts +4 -3
  105. package/dist/env/locale.js +1 -0
  106. package/dist/env/node-auth-token.d.ts +5 -1
  107. package/dist/env/node-auth-token.js +1 -0
  108. package/dist/env/node-env.d.ts +5 -1
  109. package/dist/env/node-env.js +1 -0
  110. package/dist/env/npm.d.ts +4 -5
  111. package/dist/env/npm.js +1 -0
  112. package/dist/env/package-manager.d.ts +4 -3
  113. package/dist/env/package-manager.js +2 -1
  114. package/dist/env/path.d.ts +5 -1
  115. package/dist/env/path.js +1 -0
  116. package/dist/env/pre-commit.d.ts +5 -1
  117. package/dist/env/pre-commit.js +1 -0
  118. package/dist/env/rewire.d.ts +10 -0
  119. package/dist/env/rewire.js +7 -5
  120. package/dist/env/shell.d.ts +5 -1
  121. package/dist/env/shell.js +1 -0
  122. package/dist/env/socket-cli-shadow.d.ts +4 -5
  123. package/dist/env/socket-cli-shadow.js +1 -0
  124. package/dist/env/socket-cli.d.ts +4 -14
  125. package/dist/env/socket-cli.js +1 -0
  126. package/dist/env/socket.d.ts +6 -18
  127. package/dist/env/socket.js +4 -3
  128. package/dist/env/temp-dir.d.ts +4 -3
  129. package/dist/env/temp-dir.js +1 -0
  130. package/dist/env/term.d.ts +5 -1
  131. package/dist/env/term.js +1 -0
  132. package/dist/env/test.d.ts +4 -3
  133. package/dist/env/test.js +1 -0
  134. package/dist/env/windows.d.ts +4 -4
  135. package/dist/env/windows.js +1 -0
  136. package/dist/env/xdg.d.ts +4 -3
  137. package/dist/env/xdg.js +1 -0
  138. package/dist/env.d.ts +83 -23
  139. package/dist/env.js +112 -80
  140. package/dist/errors.js +1 -0
  141. package/dist/external/@npmcli/package-json.js +9 -3968
  142. package/dist/external/@socketregistry/packageurl-js.js +2 -2
  143. package/dist/external/debug.js +162 -328
  144. package/dist/external/external-pack.js +3 -2835
  145. package/dist/external/npm-pack.js +13939 -33342
  146. package/dist/external/zod.js +160 -7558
  147. package/dist/fs.d.ts +92 -113
  148. package/dist/fs.js +35 -35
  149. package/dist/git.d.ts +170 -164
  150. package/dist/git.js +113 -87
  151. package/dist/github.d.ts +249 -227
  152. package/dist/github.js +82 -81
  153. package/dist/globs.d.ts +31 -17
  154. package/dist/globs.js +51 -58
  155. package/dist/http-request.d.ts +99 -99
  156. package/dist/http-request.js +182 -156
  157. package/dist/ipc-cli.d.ts +28 -0
  158. package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
  159. package/dist/ipc.d.ts +9 -299
  160. package/dist/ipc.js +18 -204
  161. package/dist/json/edit.d.ts +3 -1
  162. package/dist/json/edit.js +30 -30
  163. package/dist/json/format.d.ts +36 -36
  164. package/dist/json/format.js +22 -21
  165. package/dist/json/parse.d.ts +4 -2
  166. package/dist/json/parse.js +1 -0
  167. package/dist/json/types.js +1 -0
  168. package/dist/{links/index.d.ts → links.d.ts} +6 -2
  169. package/dist/{links/index.js → links.js} +5 -4
  170. package/dist/logger.d.ts +4 -6
  171. package/dist/logger.js +61 -53
  172. package/dist/memoization.d.ts +52 -49
  173. package/dist/memoization.js +55 -33
  174. package/dist/objects.d.ts +25 -44
  175. package/dist/objects.js +2 -1
  176. package/dist/package-extensions.d.ts +6 -0
  177. package/dist/package-extensions.js +2 -1
  178. package/dist/packages/edit.d.ts +3 -5
  179. package/dist/packages/edit.js +4 -3
  180. package/dist/packages/exports.d.ts +11 -14
  181. package/dist/packages/exports.js +11 -10
  182. package/dist/packages/isolation.d.ts +4 -0
  183. package/dist/packages/isolation.js +20 -19
  184. package/dist/packages/licenses.d.ts +3 -10
  185. package/dist/packages/licenses.js +2 -1
  186. package/dist/packages/manifest.d.ts +3 -3
  187. package/dist/packages/manifest.js +1 -0
  188. package/dist/packages/normalize.d.ts +3 -4
  189. package/dist/packages/normalize.js +1 -0
  190. package/dist/packages/operations.d.ts +3 -10
  191. package/dist/packages/operations.js +1 -0
  192. package/dist/packages/provenance.d.ts +10 -8
  193. package/dist/packages/provenance.js +55 -54
  194. package/dist/packages/specs.d.ts +3 -5
  195. package/dist/packages/specs.js +1 -0
  196. package/dist/packages/validation.d.ts +3 -3
  197. package/dist/packages/validation.js +1 -0
  198. package/dist/packages.d.ts +2 -17
  199. package/dist/packages.js +2 -1
  200. package/dist/paths/dirnames.d.ts +0 -2
  201. package/dist/paths/dirnames.js +1 -0
  202. package/dist/paths/exts.d.ts +0 -1
  203. package/dist/paths/exts.js +1 -0
  204. package/dist/paths/filenames.d.ts +0 -1
  205. package/dist/paths/filenames.js +1 -0
  206. package/dist/paths/globs.d.ts +0 -1
  207. package/dist/paths/globs.js +1 -0
  208. package/dist/paths/normalize.d.ts +115 -123
  209. package/dist/paths/normalize.js +128 -127
  210. package/dist/paths/packages.d.ts +3 -2
  211. package/dist/paths/packages.js +2 -1
  212. package/dist/paths/rewire.d.ts +9 -0
  213. package/dist/paths/rewire.js +5 -3
  214. package/dist/paths/socket.d.ts +37 -23
  215. package/dist/paths/socket.js +26 -25
  216. package/dist/performance.d.ts +87 -84
  217. package/dist/performance.js +97 -96
  218. package/dist/process-lock.d.ts +41 -1
  219. package/dist/process-lock.js +24 -17
  220. package/dist/promise-queue.d.ts +6 -0
  221. package/dist/promise-queue.js +1 -0
  222. package/dist/promises.d.ts +40 -55
  223. package/dist/promises.js +12 -11
  224. package/dist/regexps.d.ts +0 -5
  225. package/dist/regexps.js +1 -0
  226. package/dist/releases/github.d.ts +59 -63
  227. package/dist/releases/github.js +95 -100
  228. package/dist/releases/socket-btm.d.ts +9 -2
  229. package/dist/releases/socket-btm.js +32 -25
  230. package/dist/sea.d.ts +5 -0
  231. package/dist/sea.js +1 -0
  232. package/dist/shadow.d.ts +4 -0
  233. package/dist/shadow.js +1 -0
  234. package/dist/signal-exit.d.ts +7 -7
  235. package/dist/signal-exit.js +46 -45
  236. package/dist/sorts.d.ts +5 -7
  237. package/dist/sorts.js +11 -10
  238. package/dist/spawn.d.ts +96 -77
  239. package/dist/spawn.js +39 -38
  240. package/dist/spinner.d.ts +21 -22
  241. package/dist/spinner.js +15 -11
  242. package/dist/ssri.d.ts +31 -36
  243. package/dist/ssri.js +15 -14
  244. package/dist/stdio/_stream.d.ts +31 -0
  245. package/dist/stdio/_stream.js +57 -0
  246. package/dist/stdio/divider.d.ts +40 -36
  247. package/dist/stdio/divider.js +10 -9
  248. package/dist/stdio/footer.d.ts +20 -0
  249. package/dist/stdio/footer.js +12 -2
  250. package/dist/stdio/header.d.ts +4 -16
  251. package/dist/stdio/header.js +1 -9
  252. package/dist/stdio/stderr.d.ts +51 -39
  253. package/dist/stdio/stderr.js +19 -22
  254. package/dist/stdio/stdout.d.ts +54 -52
  255. package/dist/stdio/stdout.js +35 -33
  256. package/dist/streams.d.ts +4 -3
  257. package/dist/streams.js +1 -0
  258. package/dist/strings.d.ts +31 -85
  259. package/dist/strings.js +5 -49
  260. package/dist/suppress-warnings.d.ts +32 -15
  261. package/dist/suppress-warnings.js +14 -13
  262. package/dist/tables.d.ts +30 -26
  263. package/dist/tables.js +24 -23
  264. package/dist/temporary-executor.d.ts +4 -0
  265. package/dist/temporary-executor.js +1 -0
  266. package/dist/themes/context.d.ts +30 -26
  267. package/dist/themes/context.js +19 -18
  268. package/dist/themes/index.d.ts +0 -4
  269. package/dist/themes/index.js +1 -0
  270. package/dist/themes/themes.d.ts +1 -1
  271. package/dist/themes/themes.js +1 -0
  272. package/dist/themes/types.js +1 -0
  273. package/dist/themes/utils.d.ts +46 -43
  274. package/dist/themes/utils.js +45 -44
  275. package/dist/types.d.ts +48 -52
  276. package/dist/types.js +35 -35
  277. package/dist/url.d.ts +48 -53
  278. package/dist/url.js +38 -37
  279. package/dist/validation/json-parser.d.ts +19 -190
  280. package/dist/validation/json-parser.js +5 -69
  281. package/dist/validation/types.d.ts +9 -33
  282. package/dist/validation/types.js +1 -0
  283. package/dist/versions.d.ts +1 -0
  284. package/dist/versions.js +2 -1
  285. package/dist/words.d.ts +3 -6
  286. package/dist/words.js +1 -0
  287. package/dist/zod.js +1 -0
  288. package/package.json +34 -70
  289. package/dist/external/@inquirer/checkbox.js +0 -5
  290. package/dist/external/@inquirer/confirm.js +0 -5
  291. package/dist/external/@inquirer/input.js +0 -5
  292. package/dist/external/@inquirer/password.js +0 -5
  293. package/dist/external/@inquirer/search.js +0 -5
  294. package/dist/external/@inquirer/select.js +0 -5
  295. package/dist/functions.d.ts +0 -57
  296. package/dist/functions.js +0 -70
  297. package/dist/stdio/clear.d.ts +0 -140
  298. package/dist/stdio/clear.js +0 -95
  299. package/dist/stdio/mask.d.ts +0 -151
  300. package/dist/stdio/mask.js +0 -224
  301. package/dist/stdio/progress.d.ts +0 -148
  302. package/dist/stdio/progress.js +0 -212
  303. package/dist/stdio/prompts.d.ts +0 -195
  304. package/dist/stdio/prompts.js +0 -176
  305. package/dist/utils/get-ipc.d.ts +0 -15
package/dist/arrays.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Array utility functions for formatting lists and collections.
3
+ * Provides conjunction and disjunction formatters using Intl.ListFormat.
4
+ */
1
5
  /**
2
6
  * Split an array into chunks of a specified size.
3
7
  *
@@ -27,7 +31,6 @@
27
31
  * // Returns: [[1, 2], [3]]
28
32
  * ```
29
33
  */
30
- /*@__NO_SIDE_EFFECTS__*/
31
34
  export declare function arrayChunk<T>(arr: T[] | readonly T[], size?: number | undefined): T[][];
32
35
  /**
33
36
  * Get unique values from an array.
@@ -59,12 +62,7 @@ export declare function arrayChunk<T>(arr: T[] | readonly T[], size?: number | u
59
62
  * // Returns: []
60
63
  * ```
61
64
  */
62
- /*@__NO_SIDE_EFFECTS__*/
63
65
  export declare function arrayUnique<T>(arr: T[] | readonly T[]): T[];
64
- // IMPORTANT: Do not use destructuring here - use direct assignment instead.
65
- // tsgo has a bug that incorrectly transpiles destructured exports, resulting in
66
- // `exports.SomeName = void 0;` which causes runtime errors.
67
- // See: https://github.com/SocketDev/socket-packageurl-js/issues/3
68
66
  /**
69
67
  * Alias for native Array.isArray.
70
68
  * Determines whether the passed value is an array.
@@ -132,7 +130,6 @@ export declare const isArray: (arg: any) => arg is any[];
132
130
  * // Outputs: "You can choose React, Vue, and Angular"
133
131
  * ```
134
132
  */
135
- /*@__NO_SIDE_EFFECTS__*/
136
133
  export declare function joinAnd(arr: string[] | readonly string[]): string;
137
134
  /**
138
135
  * Join array elements with proper "or" disjunction formatting.
@@ -168,5 +165,4 @@ export declare function joinAnd(arr: string[] | readonly string[]): string;
168
165
  * // Outputs: "Choose a package manager: npm, yarn, or pnpm"
169
166
  * ```
170
167
  */
171
- /*@__NO_SIDE_EFFECTS__*/
172
168
  export declare function joinOr(arr: string[] | readonly string[]): string;
package/dist/arrays.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
package/dist/bin.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Binary path resolution and execution utilities for package managers.
3
+ * Provides cross-platform bin path lookup, command execution, and path normalization.
4
+ */
1
5
  /**
2
6
  * Options for the which function.
3
7
  */
@@ -24,14 +28,13 @@ export interface WhichOptions {
24
28
  * await execBin('/usr/local/bin/node', ['script.js'], { cwd: '/tmp' })
25
29
  * ```
26
30
  */
27
- /*@__NO_SIDE_EFFECTS__*/
28
31
  export declare function execBin(binPath: string, args?: string[], options?: import('./spawn').SpawnOptions): Promise<{
29
32
  cmd: string;
30
33
  args: string[] | readonly string[];
31
34
  code: number;
32
- signal: NodeJS.Signals;
33
- stdout: string | Buffer<ArrayBufferLike>;
34
- stderr: string | Buffer<ArrayBufferLike>;
35
+ signal: NodeJS.Signals | null;
36
+ stdout: string | Buffer;
37
+ stderr: string | Buffer;
35
38
  }>;
36
39
  /**
37
40
  * Find the real executable for a binary, bypassing shadow bins.
@@ -83,7 +86,6 @@ export declare function findRealYarn(): string;
83
86
  * ```
84
87
  */
85
88
  export declare function isShadowBinPath(dirPath: string | undefined): boolean;
86
- /*@__NO_SIDE_EFFECTS__*/
87
89
  /**
88
90
  * Resolve a binary path to the real underlying script file.
89
91
  * Handles Windows .cmd wrappers and Unix shell scripts, resolving them to the actual .js files they execute.
package/dist/bin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -43,10 +44,10 @@ __export(bin_exports, {
43
44
  });
44
45
  module.exports = __toCommonJS(bin_exports);
45
46
  var import_node_process = __toESM(require("node:process"));
47
+ var import_platform = require("./constants/platform");
46
48
  var import_home = require("./env/home");
47
49
  var import_windows = require("./env/windows");
48
50
  var import_xdg = require("./env/xdg");
49
- var import_platform = require("./constants/platform");
50
51
  var import_which = __toESM(require("./external/which"));
51
52
  var import_fs = require("./fs");
52
53
  var import_normalize = require("./paths/normalize");
@@ -58,7 +59,7 @@ let _fs;
58
59
  // @__NO_SIDE_EFFECTS__
59
60
  function getFs() {
60
61
  if (_fs === void 0) {
61
- _fs = require("fs");
62
+ _fs = require("node:fs");
62
63
  }
63
64
  return _fs;
64
65
  }
@@ -66,7 +67,7 @@ let _path;
66
67
  // @__NO_SIDE_EFFECTS__
67
68
  function getPath() {
68
69
  if (_path === void 0) {
69
- _path = require("path");
70
+ _path = require("node:path");
70
71
  }
71
72
  return _path;
72
73
  }
@@ -137,11 +138,19 @@ function findRealNpm() {
137
138
  const fs = /* @__PURE__ */ getFs();
138
139
  const path = /* @__PURE__ */ getPath();
139
140
  const nodeDir = path.dirname(import_node_process.default.execPath);
140
- const npmInNodeDir = path.join(nodeDir, "npm");
141
- if (fs.existsSync(npmInNodeDir)) {
142
- return npmInNodeDir;
141
+ const nodeDirCandidates = import_platform.WIN32 ? [path.join(nodeDir, "npm.cmd"), path.join(nodeDir, "npm")] : [path.join(nodeDir, "npm")];
142
+ for (const candidate of nodeDirCandidates) {
143
+ if (fs.existsSync(candidate)) {
144
+ return candidate;
145
+ }
143
146
  }
144
- const commonPaths = ["/usr/local/bin/npm", "/usr/bin/npm"];
147
+ const appdata = (0, import_windows.getAppdata)();
148
+ const commonPaths = import_platform.WIN32 ? [
149
+ appdata ? path.join(appdata, "npm", "npm.cmd") : "",
150
+ appdata ? path.join(appdata, "npm", "npm") : "",
151
+ "C:\\Program Files\\nodejs\\npm.cmd",
152
+ "C:\\Program Files\\nodejs\\npm"
153
+ ].filter(Boolean) : ["/usr/local/bin/npm", "/usr/bin/npm"];
145
154
  const result = findRealBin("npm", commonPaths);
146
155
  if (result && fs.existsSync(result)) {
147
156
  return result;
@@ -154,36 +163,41 @@ function findRealNpm() {
154
163
  }
155
164
  function findRealPnpm() {
156
165
  const path = /* @__PURE__ */ getPath();
166
+ const home = (0, import_home.getHome)();
167
+ const appdata = (0, import_windows.getAppdata)();
168
+ const localappdata = (0, import_windows.getLocalappdata)();
169
+ const xdgDataHome = (0, import_xdg.getXdgDataHome)();
157
170
  const commonPaths = import_platform.WIN32 ? [
158
- // Windows common paths.
159
- path.join((0, import_windows.getAppdata)(), "npm", "pnpm.cmd"),
160
- path.join((0, import_windows.getAppdata)(), "npm", "pnpm"),
161
- path.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm.cmd"),
162
- path.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm"),
171
+ appdata ? path.join(appdata, "npm", "pnpm.cmd") : "",
172
+ appdata ? path.join(appdata, "npm", "pnpm") : "",
173
+ localappdata ? path.join(localappdata, "pnpm", "pnpm.cmd") : "",
174
+ localappdata ? path.join(localappdata, "pnpm", "pnpm") : "",
163
175
  "C:\\Program Files\\nodejs\\pnpm.cmd",
164
176
  "C:\\Program Files\\nodejs\\pnpm"
165
177
  ].filter(Boolean) : [
166
- // Unix common paths.
167
178
  "/usr/local/bin/pnpm",
168
179
  "/usr/bin/pnpm",
169
- path.join(
170
- (0, import_xdg.getXdgDataHome)() || `${(0, import_home.getHome)()}/.local/share`,
171
- "pnpm/pnpm"
172
- ),
173
- path.join((0, import_home.getHome)(), ".pnpm/pnpm")
180
+ xdgDataHome ? path.join(xdgDataHome, "pnpm/pnpm") : home ? path.join(home, ".local/share/pnpm/pnpm") : "",
181
+ home ? path.join(home, ".pnpm/pnpm") : ""
174
182
  ].filter(Boolean);
175
183
  return findRealBin("pnpm", commonPaths) ?? "";
176
184
  }
177
185
  function findRealYarn() {
178
186
  const path = /* @__PURE__ */ getPath();
179
- const commonPaths = [
187
+ const home = (0, import_home.getHome)();
188
+ const appdata = (0, import_windows.getAppdata)();
189
+ const commonPaths = import_platform.WIN32 ? [
190
+ appdata ? path.join(appdata, "npm", "yarn.cmd") : "",
191
+ appdata ? path.join(appdata, "npm", "yarn") : "",
192
+ home ? path.join(home, ".yarn/bin/yarn.cmd") : "",
193
+ home ? path.join(home, ".yarn/bin/yarn") : "",
194
+ "C:\\Program Files\\nodejs\\yarn.cmd",
195
+ "C:\\Program Files\\nodejs\\yarn"
196
+ ].filter(Boolean) : [
180
197
  "/usr/local/bin/yarn",
181
198
  "/usr/bin/yarn",
182
- path.join((0, import_home.getHome)(), ".yarn/bin/yarn"),
183
- path.join(
184
- (0, import_home.getHome)(),
185
- ".config/yarn/global/node_modules/.bin/yarn"
186
- )
199
+ home ? path.join(home, ".yarn/bin/yarn") : "",
200
+ home ? path.join(home, ".config/yarn/global/node_modules/.bin/yarn") : ""
187
201
  ].filter(Boolean);
188
202
  return findRealBin("yarn", commonPaths) ?? "";
189
203
  }
@@ -413,7 +427,10 @@ async function which(binName, options) {
413
427
  return binName;
414
428
  }
415
429
  try {
416
- const result = await (0, import_which.default)(binName, options);
430
+ const result = await (0, import_which.default)(
431
+ binName,
432
+ options
433
+ );
417
434
  return result;
418
435
  } catch {
419
436
  return null;
@@ -421,7 +438,7 @@ async function which(binName, options) {
421
438
  }
422
439
  async function whichReal(binName, options) {
423
440
  const fs = /* @__PURE__ */ getFs();
424
- const opts = { nothrow: true, ...options };
441
+ const opts = { __proto__: null, nothrow: true, ...options };
425
442
  if (opts.all) {
426
443
  const cachedAll = binPathAllCache.get(binName);
427
444
  if (cachedAll && cachedAll.length > 0) {
@@ -439,7 +456,10 @@ async function whichReal(binName, options) {
439
456
  binPathCache.delete(binName);
440
457
  }
441
458
  }
442
- const result = await (0, import_which.default)(binName, opts);
459
+ const result = await (0, import_which.default)(
460
+ binName,
461
+ opts
462
+ );
443
463
  if (opts?.all) {
444
464
  const paths = Array.isArray(result) ? result : typeof result === "string" ? [result] : void 0;
445
465
  if (paths?.length) {
@@ -458,7 +478,7 @@ async function whichReal(binName, options) {
458
478
  }
459
479
  function whichRealSync(binName, options) {
460
480
  const fs = /* @__PURE__ */ getFs();
461
- const opts = { nothrow: true, ...options };
481
+ const opts = { __proto__: null, nothrow: true, ...options };
462
482
  if (opts.all) {
463
483
  const cachedAll = binPathAllCache.get(binName);
464
484
  if (cachedAll && cachedAll.length > 0) {
@@ -498,7 +518,10 @@ function whichSync(binName, options) {
498
518
  return binName;
499
519
  }
500
520
  try {
501
- const result = import_which.default.sync(binName, options);
521
+ const result = import_which.default.sync(
522
+ binName,
523
+ options
524
+ );
502
525
  return result;
503
526
  } catch {
504
527
  return null;
package/dist/cacache.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /** @fileoverview Cacache utilities for Socket ecosystem shared content-addressable cache. */
1
2
  export interface GetOptions {
2
3
  integrity?: string | undefined;
3
4
  size?: number | undefined;
@@ -6,14 +7,14 @@ export interface GetOptions {
6
7
  export interface PutOptions {
7
8
  integrity?: string | undefined;
8
9
  size?: number | undefined;
9
- metadata?: any | undefined;
10
+ metadata?: unknown | undefined;
10
11
  memoize?: boolean | undefined;
11
12
  }
12
13
  export interface CacheEntry {
13
14
  data: Buffer;
14
15
  integrity: string;
15
16
  key: string;
16
- metadata?: any | undefined;
17
+ metadata?: unknown | undefined;
17
18
  path: string;
18
19
  size: number;
19
20
  time: number;
@@ -30,16 +31,6 @@ export interface RemoveOptions {
30
31
  */
31
32
  prefix?: string | undefined;
32
33
  }
33
- /**
34
- * Get the cacache module for cache operations.
35
- *
36
- * @example
37
- * ```typescript
38
- * const cacache = getCacache()
39
- * const entries = await cacache.ls(cacheDir)
40
- * ```
41
- */
42
- export declare function getCacache(): import("./external/cacache").CacacheInstance;
43
34
  /**
44
35
  * Clear entries from the Socket shared cache.
45
36
  *
@@ -78,6 +69,16 @@ export declare function clear(options?: RemoveOptions | undefined): Promise<numb
78
69
  * ```
79
70
  */
80
71
  export declare function get(key: string, options?: GetOptions | undefined): Promise<CacheEntry>;
72
+ /**
73
+ * Get the cacache module for cache operations.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const cacache = getCacache()
78
+ * const entries = await cacache.ls(cacheDir)
79
+ * ```
80
+ */
81
+ export declare function getCacache(): import("./external/cacache").CacacheInstance;
81
82
  /**
82
83
  * Put data into the Socket shared cache with a key.
83
84
  *
package/dist/cacache.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -40,14 +41,6 @@ __export(cacache_exports, {
40
41
  module.exports = __toCommonJS(cacache_exports);
41
42
  var import_cacache = __toESM(require("./external/cacache"));
42
43
  var import_socket = require("./paths/socket");
43
- function getCacache() {
44
- return import_cacache.default;
45
- }
46
- function patternToRegex(pattern) {
47
- const escaped = pattern.replaceAll(/[.+?^${}()|[\]\\]/g, "\\$&");
48
- const regexPattern = escaped.replaceAll("*", ".*");
49
- return new RegExp(`^${regexPattern}`);
50
- }
51
44
  function matchesPattern(key, pattern) {
52
45
  if (!pattern.includes("*")) {
53
46
  return key.startsWith(pattern);
@@ -55,6 +48,11 @@ function matchesPattern(key, pattern) {
55
48
  const regex = patternToRegex(pattern);
56
49
  return regex.test(key);
57
50
  }
51
+ function patternToRegex(pattern) {
52
+ const escaped = pattern.replaceAll(/[.+?^${}()|[\]\\]/g, "\\$&");
53
+ const regexPattern = escaped.replaceAll("*", ".*");
54
+ return new RegExp(`^${regexPattern}`);
55
+ }
58
56
  async function clear(options) {
59
57
  const opts = { __proto__: null, ...options };
60
58
  const cacache2 = getCacache();
@@ -107,6 +105,9 @@ async function get(key, options) {
107
105
  const cacache2 = getCacache();
108
106
  return await cacache2.get((0, import_socket.getSocketCacacheDir)(), key, options);
109
107
  }
108
+ function getCacache() {
109
+ return import_cacache.default;
110
+ }
110
111
  async function put(key, data, options) {
111
112
  if (key.includes("*")) {
112
113
  throw new TypeError(
@@ -1,37 +1,21 @@
1
- export interface TtlCacheOptions {
2
- /**
3
- * Time-to-live in milliseconds.
4
- * @default 5 * 60 * 1000 (5 minutes)
5
- */
6
- ttl?: number | undefined;
7
- /**
8
- * Enable in-memory memoization for hot data.
9
- * @default true
10
- */
11
- memoize?: boolean | undefined;
12
- /**
13
- * Custom cache key prefix.
14
- * Must not contain wildcards (*).
15
- * Use clear({ prefix: "pattern*" }) for wildcard matching instead.
16
- *
17
- * @default 'ttl-cache'
18
- * @throws {TypeError} If prefix contains wildcards
19
- *
20
- * @example
21
- * // Valid
22
- * createTtlCache({ prefix: 'socket-sdk' })
23
- * createTtlCache({ prefix: 'my-app:cache' })
24
- *
25
- * @example
26
- * // Invalid - throws TypeError
27
- * createTtlCache({ prefix: 'socket-*' })
28
- */
29
- prefix?: string | undefined;
30
- }
31
- export interface TtlCacheEntry<T> {
32
- data: T;
33
- expiresAt: number;
34
- }
1
+ /**
2
+ * @fileoverview Generic TTL-based caching utility using cacache.
3
+ *
4
+ * Provides a simple interface for caching data with time-to-live (TTL) expiration.
5
+ * Uses cacache for persistent storage with metadata for TTL tracking.
6
+ *
7
+ * Features:
8
+ * - Automatic expiration based on TTL
9
+ * - In-memory memoization for hot data
10
+ * - Persistent storage across process restarts
11
+ * - Type-safe with generics
12
+ *
13
+ * Usage:
14
+ * ```ts
15
+ * const cache = createTtlCache({ ttl: 5 * 60 * 1000 }) // 5 minutes
16
+ * const data = await cache.getOrFetch('key', async () => fetchData())
17
+ * ```
18
+ */
35
19
  export interface ClearOptions {
36
20
  /**
37
21
  * Only clear in-memory memoization cache, not persistent cache.
@@ -66,7 +50,7 @@ export interface TtlCache {
66
50
  *
67
51
  * @example
68
52
  * // Get all entries with this cache's prefix
69
- * const all = await cache.getAll<any>('*')
53
+ * const all = await cache.getAll<unknown>('*')
70
54
  */
71
55
  getAll<T>(pattern: string): Promise<Map<string, T>>;
72
56
  /**
@@ -127,6 +111,40 @@ export interface TtlCache {
127
111
  */
128
112
  clear(options?: ClearOptions | undefined): Promise<void>;
129
113
  }
114
+ export interface TtlCacheEntry<T> {
115
+ data: T;
116
+ expiresAt: number;
117
+ }
118
+ export interface TtlCacheOptions {
119
+ /**
120
+ * Time-to-live in milliseconds.
121
+ * @default 5 * 60 * 1000 (5 minutes)
122
+ */
123
+ ttl?: number | undefined;
124
+ /**
125
+ * Enable in-memory memoization for hot data.
126
+ * @default true
127
+ */
128
+ memoize?: boolean | undefined;
129
+ /**
130
+ * Custom cache key prefix.
131
+ * Must not contain wildcards (*).
132
+ * Use clear({ prefix: "pattern*" }) for wildcard matching instead.
133
+ *
134
+ * @default 'ttl-cache'
135
+ * @throws {TypeError} If prefix contains wildcards
136
+ *
137
+ * @example
138
+ * // Valid
139
+ * createTtlCache({ prefix: 'socket-sdk' })
140
+ * createTtlCache({ prefix: 'my-app:cache' })
141
+ *
142
+ * @example
143
+ * // Invalid - throws TypeError
144
+ * createTtlCache({ prefix: 'socket-*' })
145
+ */
146
+ prefix?: string | undefined;
147
+ }
130
148
  /**
131
149
  * Create a TTL-based cache instance.
132
150
  *
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
package/dist/colors.d.ts CHANGED
@@ -2,16 +2,16 @@
2
2
  * @fileoverview Color utilities for RGB color conversion and manipulation.
3
3
  * Provides type-safe color handling with named colors and RGB tuples.
4
4
  */
5
- /**
6
- * Named color values supported by the library.
7
- * Maps to standard terminal colors with bright variants.
8
- */
9
- export type ColorName = 'black' | 'blue' | 'blueBright' | 'cyan' | 'cyanBright' | 'gray' | 'green' | 'greenBright' | 'magenta' | 'magentaBright' | 'red' | 'redBright' | 'white' | 'whiteBright' | 'yellow' | 'yellowBright';
10
5
  /**
11
6
  * Special 'inherit' color value that uses the current color context.
12
7
  * Used with effects like shimmer to dynamically inherit color.
13
8
  */
14
9
  export type ColorInherit = 'inherit';
10
+ /**
11
+ * Named color values supported by the library.
12
+ * Maps to standard terminal colors with bright variants.
13
+ */
14
+ export type ColorName = 'black' | 'blue' | 'blueBright' | 'cyan' | 'cyanBright' | 'gray' | 'green' | 'greenBright' | 'magenta' | 'magentaBright' | 'red' | 'redBright' | 'white' | 'whiteBright' | 'yellow' | 'yellowBright';
15
15
  /**
16
16
  * RGB color tuple with values 0-255 for red, green, and blue channels.
17
17
  * @example [140, 82, 255] // Socket purple
package/dist/colors.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,8 @@
1
- // Agent names.
1
+ /**
2
+ * @fileoverview Package manager agent constants.
3
+ * Exports agent names (npm/pnpm/yarn/bun/vlt/npx), lockfile names, registry
4
+ * URLs, and resolved npm binary paths used across Socket tooling.
5
+ */
2
6
  export declare const NPM = "npm";
3
7
  export declare const PNPM = "pnpm";
4
8
  export declare const YARN = "yarn";
@@ -6,16 +10,10 @@ export declare const BUN = "bun";
6
10
  export declare const VLT = "vlt";
7
11
  export declare const NPX = "npx";
8
12
  export declare const NPM_BIN_PATH: string;
9
- // NPM CLI entry point - resolved at runtime from npm bin location.
10
- // NOTE: This is kept for backward compatibility but NPM_BIN_PATH should be used instead
11
- // because cli.js exports a function that must be invoked, not executed directly.
12
13
  export declare const NPM_REAL_EXEC_PATH: any;
13
- // NPM registry URL.
14
14
  export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org";
15
- // Agent variants.
16
15
  export declare const YARN_BERRY = "yarn/berry";
17
16
  export declare const YARN_CLASSIC = "yarn/classic";
18
- // Lock files.
19
17
  export declare const PACKAGE_LOCK = "package-lock";
20
18
  export declare const PACKAGE_LOCK_JSON = "package-lock.json";
21
19
  export declare const NPM_SHRINKWRAP_JSON = "npm-shrinkwrap.json";
@@ -25,8 +23,6 @@ export declare const YARN_LOCK = "yarn.lock";
25
23
  export declare const BUN_LOCK = "bun.lock";
26
24
  export declare const BUN_LOCKB = "bun.lockb";
27
25
  export declare const VLT_LOCK_JSON = "vlt-lock.json";
28
- // Workspace configuration.
29
26
  export declare const PNPM_WORKSPACE_YAML = "pnpm-workspace.yaml";
30
- // Package.json fields for dependency overrides.
31
27
  export declare const OVERRIDES = "overrides";
32
28
  export declare const RESOLUTIONS = "resolutions";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -74,8 +75,8 @@ const NPM_REAL_EXEC_PATH = /* @__PURE__ */ (() => {
74
75
  if (!_npmBinPath) {
75
76
  return void 0;
76
77
  }
77
- const { existsSync } = require("fs");
78
- const path = require("path");
78
+ const { existsSync } = require("node:fs");
79
+ const path = require("node:path");
79
80
  const npmDir = path.dirname(_npmBinPath);
80
81
  const nodeModulesPath = path.join(
81
82
  npmDir,
@@ -1,22 +1,17 @@
1
1
  /**
2
- * Core primitives and fundamental constants.
3
- * Goal: Minimize this module by finding proper semantic homes for all constants.
2
+ * @fileoverview Core primitives and fundamental constants.
3
+ * Holds sentinels, unknown/empty tokens, the internals symbol, and a few
4
+ * shared env-var name strings. Intentionally kept small - prefer moving
5
+ * constants to a more specific `src/constants/*` module when possible.
4
6
  */
5
- // Internal implementation symbol.
6
7
  export declare const kInternalsSymbol: unique symbol;
7
- // Sentinel values.
8
8
  export declare const LOOP_SENTINEL = 1000000;
9
- // Error and unknown values.
10
9
  export declare const UNKNOWN_ERROR = "Unknown error";
11
10
  export declare const UNKNOWN_VALUE = "<unknown>";
12
- // Empty values.
13
11
  export declare const EMPTY_FILE = "/* empty */\n";
14
12
  export declare const EMPTY_VALUE = "<value>";
15
- // Undefined token.
16
13
  export declare const UNDEFINED_TOKEN: undefined;
17
- // Miscellaneous.
18
- export declare const V = "v";
19
14
  export declare const COLUMN_LIMIT = 80;
20
- // Environment variable name constants.
15
+ export declare const V = "v";
21
16
  export declare const NODE_AUTH_TOKEN = "NODE_AUTH_TOKEN";
22
17
  export declare const NODE_ENV = "NODE_ENV";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -39,8 +40,8 @@ const UNKNOWN_VALUE = "<unknown>";
39
40
  const EMPTY_FILE = "/* empty */\n";
40
41
  const EMPTY_VALUE = "<value>";
41
42
  const UNDEFINED_TOKEN = void 0;
42
- const V = "v";
43
43
  const COLUMN_LIMIT = 80;
44
+ const V = "v";
44
45
  const NODE_AUTH_TOKEN = "NODE_AUTH_TOKEN";
45
46
  const NODE_ENV = "NODE_ENV";
46
47
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Character encodings and character codes.
2
+ * @fileoverview Character encoding and character code constants.
3
+ * Exports the default UTF-8 encoding name and numeric char codes for common
4
+ * ASCII characters used by path and parsing utilities.
3
5
  */
4
- // Encoding.
5
6
  export declare const UTF8 = "utf8";
6
- // Character codes.
7
7
  export declare const CHAR_BACKWARD_SLASH = 92;
8
8
  export declare const CHAR_COLON = 58;
9
9
  export declare const CHAR_FORWARD_SLASH = 47;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * GitHub APIs and cache configuration.
2
+ * @fileoverview GitHub API and cache constants.
3
+ * Provides the GitHub REST API base URL and the cache subdirectory name used
4
+ * for persisting GitHub responses.
3
5
  */
4
- // GitHub API.
5
6
  export declare const GITHUB_API_BASE_URL = "https://api.github.com";
6
- // GitHub cache.
7
7
  export declare const CACHE_GITHUB_DIR = "github";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,8 +1,15 @@
1
1
  /**
2
- * License identifiers and copy-left license sets.
2
+ * @fileoverview License identifier constants.
3
+ * Exports common SPDX license strings (MIT, UNLICENSED) and a lazily-built
4
+ * set of copy-left SPDX identifiers used when classifying package licenses.
3
5
  */
4
- // License identifiers.
5
6
  export declare const MIT = "MIT";
6
7
  export declare const UNLICENCED = "UNLICENCED";
7
8
  export declare const UNLICENSED = "UNLICENSED";
9
+ /**
10
+ * Get the set of SPDX identifiers considered copy-left (AGPL, GPL, EPL,
11
+ * EUPL, CC-BY-SA variants). The set is lazily built and cached on first call.
12
+ *
13
+ * @returns A `Set` of SPDX license identifier strings.
14
+ */
8
15
  export declare function getCopyLeftLicenses(): Set<string>;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;