@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
@@ -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;
@@ -19,6 +20,7 @@ var __copyProps = (to, from, except, desc) => {
19
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
21
  var socket_btm_exports = {};
21
22
  __export(socket_btm_exports, {
23
+ SOCKET_BTM_REPO: () => SOCKET_BTM_REPO,
22
24
  detectLibc: () => detectLibc,
23
25
  downloadSocketBtmRelease: () => downloadSocketBtmRelease,
24
26
  getBinaryAssetName: () => getBinaryAssetName,
@@ -26,8 +28,12 @@ __export(socket_btm_exports, {
26
28
  getPlatformArch: () => getPlatformArch
27
29
  });
28
30
  module.exports = __toCommonJS(socket_btm_exports);
29
- var import_platform = require("../constants/platform.js");
30
- var import_github = require("./github.js");
31
+ var import_platform = require("../constants/platform");
32
+ var import_github = require("./github");
33
+ const SOCKET_BTM_REPO = {
34
+ owner: "SocketDev",
35
+ repo: "socket-btm"
36
+ };
31
37
  const PLATFORM_MAP = {
32
38
  __proto__: null,
33
39
  darwin: "darwin",
@@ -43,7 +49,7 @@ let _fs;
43
49
  // @__NO_SIDE_EFFECTS__
44
50
  function getFs() {
45
51
  if (_fs === void 0) {
46
- _fs = require("fs");
52
+ _fs = require("node:fs");
47
53
  }
48
54
  return _fs;
49
55
  }
@@ -70,15 +76,15 @@ function detectLibc() {
70
76
  }
71
77
  }
72
78
  async function downloadSocketBtmRelease(tool, options) {
73
- const config = Object.assign(/* @__PURE__ */ Object.create(null), options);
79
+ const config = { __proto__: null, ...options ?? {} };
74
80
  const { cwd, downloadDir, quiet = false, tag } = config;
75
81
  const toolPrefix = `${tool}-`;
76
82
  let downloadConfig;
77
83
  if (options && "asset" in options) {
78
- const assetConfig = Object.assign(
79
- /* @__PURE__ */ Object.create(null),
80
- options
81
- );
84
+ const assetConfig = {
85
+ __proto__: null,
86
+ ...options
87
+ };
82
88
  const { asset, output, removeMacOSQuarantine = false } = assetConfig;
83
89
  let resolvedAsset;
84
90
  let resolvedTag = tag;
@@ -91,17 +97,17 @@ async function downloadSocketBtmRelease(tool, options) {
91
97
  "Cannot use asset pattern with explicit tag. Either provide exact asset name or omit tag."
92
98
  );
93
99
  }
94
- resolvedTag = await (0, import_github.getLatestRelease)(toolPrefix, import_github.SOCKET_BTM_REPO, {
100
+ resolvedTag = await (0, import_github.getLatestRelease)(toolPrefix, SOCKET_BTM_REPO, {
95
101
  assetPattern: asset,
96
102
  quiet
97
- });
103
+ }) ?? void 0;
98
104
  if (!resolvedTag) {
99
105
  throw new Error(`No ${tool} release with matching asset pattern found`);
100
106
  }
101
107
  const assetUrl = await (0, import_github.getReleaseAssetUrl)(
102
108
  resolvedTag,
103
109
  asset,
104
- import_github.SOCKET_BTM_REPO,
110
+ SOCKET_BTM_REPO,
105
111
  {
106
112
  quiet
107
113
  }
@@ -114,24 +120,24 @@ async function downloadSocketBtmRelease(tool, options) {
114
120
  const outputName = output || resolvedAsset;
115
121
  const platformArch = "assets";
116
122
  downloadConfig = {
117
- owner: import_github.SOCKET_BTM_REPO.owner,
118
- repo: import_github.SOCKET_BTM_REPO.repo,
119
- cwd,
120
- downloadDir,
123
+ owner: SOCKET_BTM_REPO.owner,
124
+ repo: SOCKET_BTM_REPO.repo,
125
+ ...cwd !== void 0 && { cwd },
126
+ ...downloadDir !== void 0 && { downloadDir },
121
127
  toolName: tool,
122
128
  platformArch,
123
129
  binaryName: outputName,
124
130
  assetName: resolvedAsset,
125
131
  toolPrefix,
126
- tag: resolvedTag,
132
+ ...resolvedTag !== void 0 && { tag: resolvedTag },
127
133
  quiet,
128
134
  removeMacOSQuarantine
129
135
  };
130
136
  } else {
131
- const binaryConfig = Object.assign(
132
- /* @__PURE__ */ Object.create(null),
133
- options
134
- );
137
+ const binaryConfig = {
138
+ __proto__: null,
139
+ ...options
140
+ };
135
141
  const {
136
142
  bin,
137
143
  libc = detectLibc(),
@@ -149,16 +155,16 @@ async function downloadSocketBtmRelease(tool, options) {
149
155
  const platformArch = getPlatformArch(targetPlatform, targetArch, libc);
150
156
  const binaryName = getBinaryName(baseName, targetPlatform);
151
157
  downloadConfig = {
152
- owner: import_github.SOCKET_BTM_REPO.owner,
153
- repo: import_github.SOCKET_BTM_REPO.repo,
154
- cwd,
155
- downloadDir,
158
+ owner: SOCKET_BTM_REPO.owner,
159
+ repo: SOCKET_BTM_REPO.repo,
160
+ ...cwd !== void 0 && { cwd },
161
+ ...downloadDir !== void 0 && { downloadDir },
156
162
  toolName: tool,
157
163
  platformArch,
158
164
  binaryName,
159
165
  assetName,
160
166
  toolPrefix,
161
- tag,
167
+ ...tag !== void 0 && { tag },
162
168
  quiet,
163
169
  removeMacOSQuarantine
164
170
  };
@@ -200,6 +206,7 @@ function getPlatformArch(platform, arch, libc) {
200
206
  }
201
207
  // Annotate the CommonJS export names for ESM import in node:
202
208
  0 && (module.exports = {
209
+ SOCKET_BTM_REPO,
203
210
  detectLibc,
204
211
  downloadSocketBtmRelease,
205
212
  getBinaryAssetName,
package/dist/sea.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview SEA (Single Executable Application) detection utilities for Socket ecosystem.
3
+ * Provides reliable detection of whether the current process is running
4
+ * as a Node.js Single Executable Application.
5
+ */
1
6
  /**
2
7
  * Get the current SEA binary path.
3
8
  * Only valid when running as a SEA binary.
package/dist/sea.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;
package/dist/shadow.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Shadow binary installation utilities for Socket ecosystem.
3
+ * Provides logic to determine when shadow binary installation should be skipped.
4
+ */
1
5
  export interface ShadowInstallationOptions {
2
6
  cwd?: string | undefined;
3
7
  win32?: boolean | undefined;
package/dist/shadow.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;
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @fileoverview Process signal handling utilities.
3
+ * Provides cross-platform signal exit detection and cleanup handlers.
4
+ */
5
+ export interface OnExitOptions {
6
+ alwaysLast?: boolean;
7
+ }
1
8
  /**
2
9
  * Load signal handlers and hook into process exit events.
3
10
  *
@@ -7,11 +14,7 @@
7
14
  * // Signal handlers are now active
8
15
  * ```
9
16
  */
10
- /*@__NO_SIDE_EFFECTS__*/
11
17
  export declare function load(): void;
12
- export interface OnExitOptions {
13
- alwaysLast?: boolean;
14
- }
15
18
  /**
16
19
  * Register a callback to run on process exit or signal.
17
20
  *
@@ -24,7 +27,6 @@ export interface OnExitOptions {
24
27
  * remove()
25
28
  * ```
26
29
  */
27
- /*@__NO_SIDE_EFFECTS__*/
28
30
  export declare function onExit(cb: (code: number | null, signal: string | null) => void, options?: OnExitOptions | undefined): () => void;
29
31
  /**
30
32
  * Get the list of signals that are currently being monitored.
@@ -35,7 +37,6 @@ export declare function onExit(cb: (code: number | null, signal: string | null)
35
37
  * console.log(sigs) // ['SIGABRT', 'SIGALRM', 'SIGHUP', ...]
36
38
  * ```
37
39
  */
38
- /*@__NO_SIDE_EFFECTS__*/
39
40
  export declare function signals(): string[];
40
41
  /**
41
42
  * Unload signal handlers and restore original process behavior.
@@ -46,5 +47,4 @@ export declare function signals(): string[];
46
47
  * // Signal handlers are now removed
47
48
  * ```
48
49
  */
49
- /*@__NO_SIDE_EFFECTS__*/
50
50
  export declare function unload(): void;
@@ -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;
@@ -32,14 +33,21 @@ const platform = globalProcess?.platform ?? "";
32
33
  const originalProcessReallyExit = globalProcess?.reallyExit;
33
34
  const WIN32 = platform === "win32";
34
35
  let _events;
36
+ let _emitter;
37
+ let _sigListeners;
38
+ let loaded = false;
39
+ let _signals;
35
40
  // @__NO_SIDE_EFFECTS__
36
- function getEvents() {
37
- if (_events === void 0) {
38
- _events = require("events");
41
+ function emit(event, code, signal) {
42
+ const emitter = /* @__PURE__ */ getEmitter();
43
+ if (emitter.emitted?.[event]) {
44
+ return;
39
45
  }
40
- return _events;
46
+ if (emitter.emitted) {
47
+ emitter.emitted[event] = true;
48
+ }
49
+ emitter.emit(event, code, signal);
41
50
  }
42
- let _emitter;
43
51
  // @__NO_SIDE_EFFECTS__
44
52
  function getEmitter() {
45
53
  if (_emitter === void 0) {
@@ -58,7 +66,13 @@ function getEmitter() {
58
66
  }
59
67
  return _emitter;
60
68
  }
61
- let _sigListeners;
69
+ // @__NO_SIDE_EFFECTS__
70
+ function getEvents() {
71
+ if (_events === void 0) {
72
+ _events = require("node:events");
73
+ }
74
+ return _events;
75
+ }
62
76
  // @__NO_SIDE_EFFECTS__
63
77
  function getSignalListeners() {
64
78
  if (_sigListeners === void 0) {
@@ -81,44 +95,6 @@ function getSignalListeners() {
81
95
  return _sigListeners;
82
96
  }
83
97
  // @__NO_SIDE_EFFECTS__
84
- function emit(event, code, signal) {
85
- const emitter = /* @__PURE__ */ getEmitter();
86
- if (emitter.emitted?.[event]) {
87
- return;
88
- }
89
- if (emitter.emitted) {
90
- emitter.emitted[event] = true;
91
- }
92
- emitter.emit(event, code, signal);
93
- }
94
- let loaded = false;
95
- // @__NO_SIDE_EFFECTS__
96
- function load() {
97
- if (loaded || !globalProcess) {
98
- return;
99
- }
100
- loaded = true;
101
- const emitter = /* @__PURE__ */ getEmitter();
102
- if (emitter.count !== void 0) {
103
- emitter.count += 1;
104
- }
105
- const sigs = /* @__PURE__ */ signals();
106
- const sigListeners = /* @__PURE__ */ getSignalListeners();
107
- _signals = sigs.filter((sig) => {
108
- try {
109
- globalProcess.on(
110
- sig,
111
- sigListeners[sig]
112
- );
113
- return true;
114
- } catch {
115
- }
116
- return false;
117
- });
118
- globalProcess.emit = processEmit;
119
- globalProcess.reallyExit = processReallyExit;
120
- }
121
- // @__NO_SIDE_EFFECTS__
122
98
  function processEmit(eventName, exitCode, ...args) {
123
99
  if (eventName === "exit") {
124
100
  let actualExitCode = exitCode;
@@ -160,6 +136,32 @@ function processReallyExit(code) {
160
136
  throw new Error("processReallyExit should never return");
161
137
  }
162
138
  // @__NO_SIDE_EFFECTS__
139
+ function load() {
140
+ if (loaded || !globalProcess) {
141
+ return;
142
+ }
143
+ loaded = true;
144
+ const emitter = /* @__PURE__ */ getEmitter();
145
+ if (emitter.count !== void 0) {
146
+ emitter.count += 1;
147
+ }
148
+ const sigs = /* @__PURE__ */ signals();
149
+ const sigListeners = /* @__PURE__ */ getSignalListeners();
150
+ _signals = sigs.filter((sig) => {
151
+ try {
152
+ globalProcess.on(
153
+ sig,
154
+ sigListeners[sig]
155
+ );
156
+ return true;
157
+ } catch {
158
+ }
159
+ return false;
160
+ });
161
+ globalProcess.emit = processEmit;
162
+ globalProcess.reallyExit = processReallyExit;
163
+ }
164
+ // @__NO_SIDE_EFFECTS__
163
165
  function onExit(cb, options) {
164
166
  if (!globalProcess) {
165
167
  return function remove() {
@@ -185,7 +187,6 @@ function onExit(cb, options) {
185
187
  }
186
188
  };
187
189
  }
188
- let _signals;
189
190
  // @__NO_SIDE_EFFECTS__
190
191
  function signals() {
191
192
  if (_signals === void 0) {
package/dist/sorts.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview Sorting comparison functions including locale-aware and natural sorting.
3
+ * Provides various comparison utilities for arrays and collections.
4
+ */
5
+ type FastSortFunction = ReturnType<typeof import('fast-sort').createNewSortInstance>;
1
6
  /**
2
7
  * Compare semantic versions.
3
8
  *
@@ -8,7 +13,6 @@
8
13
  * compareSemver('1.0.0', '1.0.0') // 0
9
14
  * ```
10
15
  */
11
- /*@__NO_SIDE_EFFECTS__*/
12
16
  export declare function compareSemver(a: string, b: string): number;
13
17
  /**
14
18
  * Simple string comparison.
@@ -20,7 +24,6 @@ export declare function compareSemver(a: string, b: string): number;
20
24
  * compareStr('a', 'a') // 0
21
25
  * ```
22
26
  */
23
- /*@__NO_SIDE_EFFECTS__*/
24
27
  export declare function compareStr(a: string, b: string): number;
25
28
  /**
26
29
  * Compare two strings using locale-aware comparison.
@@ -32,7 +35,6 @@ export declare function compareStr(a: string, b: string): number;
32
35
  * localeCompare('a', 'a') // 0
33
36
  * ```
34
37
  */
35
- /*@__NO_SIDE_EFFECTS__*/
36
38
  export declare function localeCompare(x: string, y: string): number;
37
39
  /**
38
40
  * Compare two strings using natural sorting (numeric-aware, case-insensitive).
@@ -43,10 +45,7 @@ export declare function localeCompare(x: string, y: string): number;
43
45
  * naturalCompare('img10', 'img2') // positive (img10 after img2)
44
46
  * ```
45
47
  */
46
- /*@__NO_SIDE_EFFECTS__*/
47
48
  export declare function naturalCompare(x: string, y: string): number;
48
- // Type for fast-sort sorter function.
49
- type FastSortFunction = ReturnType<typeof import('fast-sort').createNewSortInstance>;
50
49
  /**
51
50
  * Sort an array using natural comparison.
52
51
  *
@@ -56,6 +55,5 @@ type FastSortFunction = ReturnType<typeof import('fast-sort').createNewSortInsta
56
55
  * // ['file1', 'file2', 'file10']
57
56
  * ```
58
57
  */
59
- /*@__NO_SIDE_EFFECTS__*/
60
58
  export declare function naturalSorter<T>(arrayToSort: T[]): ReturnType<FastSortFunction>;
61
59
  export {};
package/dist/sorts.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;
@@ -26,20 +27,23 @@ __export(sorts_exports, {
26
27
  naturalSorter: () => naturalSorter
27
28
  });
28
29
  module.exports = __toCommonJS(sorts_exports);
29
- let _semver;
30
- function getSemver() {
31
- if (_semver === void 0) {
32
- _semver = require("./external/semver.js");
33
- }
34
- return _semver;
35
- }
36
30
  let _fastSort;
31
+ let _localeCompare;
32
+ let _naturalCompare;
33
+ let _naturalSorter;
34
+ let _semver;
37
35
  function getFastSort() {
38
36
  if (_fastSort === void 0) {
39
37
  _fastSort = require("./external/fast-sort.js");
40
38
  }
41
39
  return _fastSort;
42
40
  }
41
+ function getSemver() {
42
+ if (_semver === void 0) {
43
+ _semver = require("./external/semver.js");
44
+ }
45
+ return _semver;
46
+ }
43
47
  // @__NO_SIDE_EFFECTS__
44
48
  function compareSemver(a, b) {
45
49
  const semver = getSemver();
@@ -60,7 +64,6 @@ function compareSemver(a, b) {
60
64
  function compareStr(a, b) {
61
65
  return a < b ? -1 : a > b ? 1 : 0;
62
66
  }
63
- let _localeCompare;
64
67
  // @__NO_SIDE_EFFECTS__
65
68
  function localeCompare(x, y) {
66
69
  if (_localeCompare === void 0) {
@@ -68,7 +71,6 @@ function localeCompare(x, y) {
68
71
  }
69
72
  return _localeCompare(x, y);
70
73
  }
71
- let _naturalCompare;
72
74
  // @__NO_SIDE_EFFECTS__
73
75
  function naturalCompare(x, y) {
74
76
  if (_naturalCompare === void 0) {
@@ -89,7 +91,6 @@ function naturalCompare(x, y) {
89
91
  }
90
92
  return _naturalCompare(x, y);
91
93
  }
92
- let _naturalSorter;
93
94
  // @__NO_SIDE_EFFECTS__
94
95
  function naturalSorter(arrayToSort) {
95
96
  if (_naturalSorter === void 0) {
package/dist/spawn.d.ts CHANGED
@@ -1,5 +1,32 @@
1
+ /**
2
+ * @fileoverview Child process spawning utilities with cross-platform support.
3
+ * Provides enhanced spawn functionality with stdio handling and error management.
4
+ *
5
+ * SECURITY: Array-Based Arguments Prevent Command Injection
6
+ *
7
+ * This module uses array-based arguments for all command execution, which is the
8
+ * PRIMARY DEFENSE against command injection attacks. When you pass arguments as
9
+ * an array to spawn():
10
+ *
11
+ * spawn('npx', ['sfw', tool, ...args], { shell: true })
12
+ *
13
+ * Node.js handles escaping automatically. Each argument is passed directly to the
14
+ * OS without shell interpretation. Shell metacharacters like ; | & $ ( ) ` are
15
+ * treated as LITERAL STRINGS, not as commands. This approach is secure even when
16
+ * shell: true is used on Windows for .cmd/.bat file resolution.
17
+ *
18
+ * UNSAFE ALTERNATIVE (not used in this codebase):
19
+ * spawn(`npx sfw ${tool} ${args.join(' ')}`, { shell: true }) // ✖ VULNERABLE
20
+ *
21
+ * String concatenation allows injection. For example, if tool = "foo; rm -rf /",
22
+ * the shell would execute both commands. Array-based arguments prevent this.
23
+ *
24
+ * References:
25
+ * - https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
26
+ * - https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html
27
+ */
28
+ import type { SendHandle, Serializable, StdioOptions } from 'node:child_process';
1
29
  import type { EventEmitter } from 'node:events';
2
- // Define BufferEncoding type for TypeScript compatibility.
3
30
  type BufferEncoding = globalThis.BufferEncoding;
4
31
  /**
5
32
  * Options for spawning a child process with promise-based completion.
@@ -158,69 +185,11 @@ export interface SpawnSyncReturns<T> {
158
185
  signal: NodeJS.Signals | null;
159
186
  error?: Error | undefined;
160
187
  }
161
- /**
162
- * Enhances spawn error with better context.
163
- * Converts generic "command failed" to detailed error with command, exit code, and stderr.
164
- *
165
- * @example
166
- * ```typescript
167
- * try {
168
- * await spawn('git', ['status'])
169
- * } catch (err) {
170
- * throw enhanceSpawnError(err)
171
- * }
172
- * ```
173
- */
174
- /*@__NO_SIDE_EFFECTS__*/
175
- export declare function enhanceSpawnError(error: unknown): unknown;
176
- /**
177
- * Check if a value is a spawn error with expected error properties.
178
- * Tests for common error properties from child process failures.
179
- *
180
- * @param {unknown} value - Value to check
181
- * @returns {boolean} `true` if the value has spawn error properties
182
- *
183
- * @example
184
- * try {
185
- * await spawn('nonexistent-command')
186
- * } catch (error) {
187
- * if (isSpawnError(error)) {
188
- * console.error(`Spawn failed: ${error.code}`)
189
- * }
190
- * }
191
- */
192
- /*@__NO_SIDE_EFFECTS__*/
193
- export declare function isSpawnError(value: unknown): value is SpawnError;
194
- /**
195
- * Check if stdio configuration matches a specific type.
196
- * When called with one argument, validates if it's a valid stdio type.
197
- * When called with two arguments, checks if the stdio config matches the specified type.
198
- *
199
- * @param {string | string[]} stdio - Stdio configuration to check
200
- * @param {StdioType | undefined} type - Expected stdio type (optional)
201
- * @returns {boolean} `true` if stdio matches the type or is valid
202
- *
203
- * @example
204
- * // Check if valid stdio type
205
- * isStdioType('pipe') // true
206
- * isStdioType('invalid') // false
207
- *
208
- * @example
209
- * // Check if stdio matches specific type
210
- * isStdioType('pipe', 'pipe') // true
211
- * isStdioType(['pipe', 'pipe', 'pipe'], 'pipe') // true
212
- * isStdioType('ignore', 'pipe') // false
213
- */
214
- /*@__NO_SIDE_EFFECTS__*/
215
- export declare function isStdioType(stdio: string | string[], type?: StdioType | undefined): boolean;
216
- /*@__NO_SIDE_EFFECTS__*/
217
- // Duplicated from Node.js child_process.SpawnOptions
218
- // These are the options passed to child_process.spawn()
219
188
  interface NodeSpawnOptions {
220
189
  cwd?: string | URL | undefined;
221
190
  env?: NodeJS.ProcessEnv | undefined;
222
191
  argv0?: string | undefined;
223
- stdio?: any;
192
+ stdio?: StdioOptions | undefined;
224
193
  detached?: boolean | undefined;
225
194
  uid?: number | undefined;
226
195
  gid?: number | undefined;
@@ -232,13 +201,11 @@ interface NodeSpawnOptions {
232
201
  timeout?: number | undefined;
233
202
  killSignal?: NodeJS.Signals | number | undefined;
234
203
  }
235
- // Duplicated from Node.js child_process.ChildProcess
236
- // This represents a spawned child process
237
204
  interface ChildProcess extends EventEmitter {
238
205
  stdin: NodeJS.WritableStream | null;
239
206
  stdout: NodeJS.ReadableStream | null;
240
207
  stderr: NodeJS.ReadableStream | null;
241
- readonly channel?: any;
208
+ readonly channel?: unknown;
242
209
  readonly stdio: [
243
210
  NodeJS.WritableStream | null,
244
211
  NodeJS.ReadableStream | null,
@@ -254,14 +221,15 @@ interface ChildProcess extends EventEmitter {
254
221
  readonly spawnargs: string[];
255
222
  readonly spawnfile: string;
256
223
  kill(signal?: NodeJS.Signals | number): boolean;
257
- send(message: any, callback?: (error: Error | null) => void): boolean;
258
- send(message: any, sendHandle?: any | undefined, callback?: (error: Error | null) => void): boolean;
259
- send(message: any, sendHandle?: any | undefined, options?: any | undefined, callback?: (error: Error | null) => void): boolean;
224
+ send(message: Serializable, callback?: (error: Error | null) => void): boolean;
225
+ send(message: Serializable, sendHandle?: SendHandle | undefined, callback?: (error: Error | null) => void): boolean;
226
+ send(message: Serializable, sendHandle?: SendHandle | undefined, options?: {
227
+ keepOpen?: boolean | undefined;
228
+ } | undefined, callback?: (error: Error | null) => void): boolean;
260
229
  disconnect(): void;
261
230
  unref(): void;
262
231
  ref(): void;
263
232
  }
264
- // Duplicated from Node.js stream.Writable
265
233
  interface WritableStreamType {
266
234
  writable: boolean;
267
235
  writableEnded: boolean;
@@ -271,11 +239,11 @@ interface WritableStreamType {
271
239
  writableObjectMode: boolean;
272
240
  writableCorked: number;
273
241
  destroyed: boolean;
274
- write(chunk: any, encoding?: BufferEncoding | undefined, callback?: (error?: Error | null) => void): boolean;
275
- write(chunk: any, callback?: (error?: Error | null) => void): boolean;
242
+ write(chunk: unknown, encoding?: BufferEncoding | undefined, callback?: (error?: Error | null) => void): boolean;
243
+ write(chunk: unknown, callback?: (error?: Error | null) => void): boolean;
276
244
  end(cb?: () => void): this;
277
- end(chunk: any, cb?: () => void): this;
278
- end(chunk: any, encoding?: BufferEncoding | undefined, cb?: () => void): this;
245
+ end(chunk: unknown, cb?: () => void): this;
246
+ end(chunk: unknown, encoding?: BufferEncoding | undefined, cb?: () => void): this;
279
247
  cork(): void;
280
248
  uncork(): void;
281
249
  destroy(error?: Error | undefined): this;
@@ -321,6 +289,63 @@ export type SpawnStdioResult = {
321
289
  stdout: string | Buffer;
322
290
  stderr: string | Buffer;
323
291
  };
292
+ /**
293
+ * Options for synchronously spawning a child process with {@link spawnSync}.
294
+ * Same as {@link SpawnOptions} but excludes the `spinner` property (not applicable for synchronous execution).
295
+ */
296
+ export type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>;
297
+ /**
298
+ * Enhances spawn error with better context.
299
+ * Converts generic "command failed" to detailed error with command, exit code, and stderr.
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * try {
304
+ * await spawn('git', ['status'])
305
+ * } catch (err) {
306
+ * throw enhanceSpawnError(err)
307
+ * }
308
+ * ```
309
+ */
310
+ export declare function enhanceSpawnError(error: unknown): unknown;
311
+ /**
312
+ * Check if a value is a spawn error with expected error properties.
313
+ * Tests for common error properties from child process failures.
314
+ *
315
+ * @param {unknown} value - Value to check
316
+ * @returns {boolean} `true` if the value has spawn error properties
317
+ *
318
+ * @example
319
+ * try {
320
+ * await spawn('nonexistent-command')
321
+ * } catch (error) {
322
+ * if (isSpawnError(error)) {
323
+ * console.error(`Spawn failed: ${error.code}`)
324
+ * }
325
+ * }
326
+ */
327
+ export declare function isSpawnError(value: unknown): value is SpawnError;
328
+ /**
329
+ * Check if stdio configuration matches a specific type.
330
+ * When called with one argument, validates if it's a valid stdio type.
331
+ * When called with two arguments, checks if the stdio config matches the specified type.
332
+ *
333
+ * @param {string | string[]} stdio - Stdio configuration to check
334
+ * @param {StdioType | undefined} type - Expected stdio type (optional)
335
+ * @returns {boolean} `true` if stdio matches the type or is valid
336
+ *
337
+ * @example
338
+ * // Check if valid stdio type
339
+ * isStdioType('pipe') // true
340
+ * isStdioType('invalid') // false
341
+ *
342
+ * @example
343
+ * // Check if stdio matches specific type
344
+ * isStdioType('pipe', 'pipe') // true
345
+ * isStdioType(['pipe', 'pipe', 'pipe'], 'pipe') // true
346
+ * isStdioType('ignore', 'pipe') // false
347
+ */
348
+ export declare function isStdioType(stdio: string | string[], type?: StdioType | undefined): boolean;
324
349
  /**
325
350
  * Spawn a child process and return a promise that resolves when it completes.
326
351
  * Provides enhanced error handling, output capture, and cross-platform support.
@@ -384,12 +409,6 @@ export type SpawnStdioResult = {
384
409
  * }
385
410
  */
386
411
  export declare function spawn(cmd: string, args?: string[] | readonly string[], options?: SpawnOptions | undefined, extra?: SpawnExtra | undefined): SpawnResult;
387
- /*@__NO_SIDE_EFFECTS__*/
388
- /**
389
- * Options for synchronously spawning a child process with {@link spawnSync}.
390
- * Same as {@link SpawnOptions} but excludes the `spinner` property (not applicable for synchronous execution).
391
- */
392
- export type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>;
393
412
  /**
394
413
  * Synchronously spawn a child process and wait for it to complete.
395
414
  * Blocks execution until the process exits, returning all output and exit information.