@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 __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -42,7 +43,6 @@ __export(package_exports, {
42
43
  module.exports = __toCommonJS(package_exports);
43
44
  var import_platform = require("../constants/platform");
44
45
  var import_socket = require("../constants/socket");
45
- var import_cache = require("./cache");
46
46
  var import_arborist = __toESM(require("../external/@npmcli/arborist"));
47
47
  var import_libnpmexec = __toESM(require("../external/libnpmexec"));
48
48
  var import_npm_package_arg = __toESM(require("../external/npm-package-arg"));
@@ -52,23 +52,90 @@ var import_normalize = require("../paths/normalize");
52
52
  var import_socket2 = require("../paths/socket");
53
53
  var import_process_lock = require("../process-lock");
54
54
  var import_spawn = require("../spawn");
55
+ var import_cache = require("./cache");
55
56
  let _fs;
57
+ let _path;
58
+ const rangeOperatorsRegExp = /[~^><=xX* ]|\|\|/;
59
+ const FIREWALL_API_URL = "https://firewall-api.socket.dev/purl";
60
+ const FIREWALL_TIMEOUT = 1e4;
61
+ const FIREWALL_BLOCK_SEVERITIES = /* @__PURE__ */ new Set([
62
+ "critical",
63
+ "high"
64
+ ]);
65
+ const binaryPathCache = /* @__PURE__ */ new Map();
66
+ async function checkFirewallPurls(arb, requestedPackage) {
67
+ const idealTree = arb.idealTree;
68
+ if (!idealTree) {
69
+ return;
70
+ }
71
+ const purls = [];
72
+ for (const node of idealTree.inventory.values()) {
73
+ if (node.isProjectRoot) {
74
+ continue;
75
+ }
76
+ const { name, version } = node.package;
77
+ if (!name || !version) {
78
+ continue;
79
+ }
80
+ purls.push({ purl: npmPurl(name, version), name, version });
81
+ }
82
+ if (purls.length === 0) {
83
+ return;
84
+ }
85
+ const blocked = [];
86
+ await Promise.allSettled(
87
+ purls.map(async ({ name, purl, version }) => {
88
+ try {
89
+ const data = await (0, import_http_request.httpJson)(
90
+ `${FIREWALL_API_URL}/${encodeURIComponent(purl)}`,
91
+ {
92
+ headers: { "User-Agent": import_socket.SOCKET_LIB_USER_AGENT },
93
+ timeout: FIREWALL_TIMEOUT,
94
+ retries: 1,
95
+ retryDelay: 500
96
+ }
97
+ );
98
+ const blocking = (data.alerts ?? []).filter(
99
+ (a) => a.severity && FIREWALL_BLOCK_SEVERITIES.has(a.severity)
100
+ );
101
+ if (blocking.length > 0) {
102
+ blocked.push({
103
+ name,
104
+ version,
105
+ alerts: blocking.map(
106
+ (a) => `${a.severity}: ${a.type ?? a.key ?? "unknown"}`
107
+ )
108
+ });
109
+ }
110
+ } catch {
111
+ }
112
+ })
113
+ );
114
+ if (blocked.length > 0) {
115
+ const details = blocked.map((b) => ` ${b.name}@${b.version}: ${b.alerts.join(", ")}`).join("\n");
116
+ throw new Error(
117
+ `Socket Firewall blocked installation of "${requestedPackage}".
118
+ The following dependencies have security alerts:
119
+ ${details}
120
+
121
+ Visit https://socket.dev for more information.`
122
+ );
123
+ }
124
+ }
56
125
  // @__NO_SIDE_EFFECTS__
57
126
  function getFs() {
58
127
  if (_fs === void 0) {
59
- _fs = require("fs");
128
+ _fs = require("node:fs");
60
129
  }
61
130
  return _fs;
62
131
  }
63
- let _path;
64
132
  // @__NO_SIDE_EFFECTS__
65
133
  function getPath() {
66
134
  if (_path === void 0) {
67
- _path = require("path");
135
+ _path = require("node:path");
68
136
  }
69
137
  return _path;
70
138
  }
71
- const rangeOperatorsRegExp = /[~^><=xX* ]|\|\|/;
72
139
  async function dlxPackage(args, options, spawnExtra) {
73
140
  const downloadResult = await downloadPackage(options);
74
141
  const spawnPromise = executePackage(
@@ -86,6 +153,8 @@ async function downloadPackage(options) {
86
153
  const {
87
154
  binaryName,
88
155
  force: userForce,
156
+ hash,
157
+ lockfile,
89
158
  package: packageSpec,
90
159
  yes
91
160
  } = {
@@ -99,7 +168,8 @@ async function downloadPackage(options) {
99
168
  const { installed, packageDir } = await ensurePackageInstalled(
100
169
  packageName,
101
170
  fullPackageSpec,
102
- force
171
+ force,
172
+ { hash, lockfile }
103
173
  );
104
174
  const binaryPath = findBinaryPath(packageDir, packageName, binaryName);
105
175
  makePackageBinsExecutable(packageDir, packageName);
@@ -109,7 +179,7 @@ async function downloadPackage(options) {
109
179
  packageDir
110
180
  };
111
181
  }
112
- async function ensurePackageInstalled(packageName, packageSpec, force) {
182
+ async function ensurePackageInstalled(packageName, packageSpec, force, install) {
113
183
  const fs = /* @__PURE__ */ getFs();
114
184
  const path = /* @__PURE__ */ getPath();
115
185
  const cacheKey = (0, import_cache.generateCacheKey)(packageSpec);
@@ -149,6 +219,29 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
149
219
  return { installed: false, packageDir };
150
220
  }
151
221
  }
222
+ if (install?.lockfile !== void 0) {
223
+ const spec = install.lockfile;
224
+ const lockDest = path.join(packageDir, "package-lock.json");
225
+ let isContent;
226
+ let value;
227
+ if (typeof spec === "string") {
228
+ isContent = spec.trimStart().startsWith("{");
229
+ value = spec;
230
+ } else {
231
+ isContent = spec.type === "content";
232
+ value = spec.value;
233
+ }
234
+ if (isContent) {
235
+ fs.writeFileSync(lockDest, value, "utf8");
236
+ } else {
237
+ fs.copyFileSync(value, lockDest);
238
+ }
239
+ fs.writeFileSync(
240
+ path.join(packageDir, ".npmrc"),
241
+ "ignore-scripts=true\naudit=false\nfund=false\nsave=false\n",
242
+ "utf8"
243
+ );
244
+ }
152
245
  try {
153
246
  const arb = new import_arborist.default({
154
247
  path: packageDir,
@@ -174,7 +267,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
174
267
  if (e instanceof Error && e.message.startsWith("Socket Firewall blocked")) {
175
268
  throw e;
176
269
  }
177
- const code = e.code;
270
+ const code = e?.code;
178
271
  if (code === "E404" || code === "ETARGET") {
179
272
  throw new Error(
180
273
  `Package not found: ${packageSpec}
@@ -303,76 +396,11 @@ function makePackageBinsExecutable(packageDir, packageName) {
303
396
  } catch {
304
397
  }
305
398
  }
306
- const FIREWALL_API_URL = "https://firewall-api.socket.dev/purl";
307
- const FIREWALL_TIMEOUT = 1e4;
308
- const FIREWALL_BLOCK_SEVERITIES = /* @__PURE__ */ new Set([
309
- "critical",
310
- "high"
311
- ]);
312
399
  function npmPurl(name, version) {
313
400
  const encoded = name.startsWith("@") ? `%40${name.slice(1)}` : name;
314
401
  const encodedVersion = version.replace(/\+/g, "%2B");
315
402
  return `pkg:npm/${encoded}@${encodedVersion}`;
316
403
  }
317
- async function checkFirewallPurls(arb, requestedPackage) {
318
- const idealTree = arb.idealTree;
319
- if (!idealTree) {
320
- return;
321
- }
322
- const purls = [];
323
- for (const node of idealTree.inventory.values()) {
324
- if (node.isProjectRoot) {
325
- continue;
326
- }
327
- const { name, version } = node.package;
328
- if (!name || !version) {
329
- continue;
330
- }
331
- purls.push({ purl: npmPurl(name, version), name, version });
332
- }
333
- if (purls.length === 0) {
334
- return;
335
- }
336
- const blocked = [];
337
- await Promise.allSettled(
338
- purls.map(async ({ name, purl, version }) => {
339
- try {
340
- const data = await (0, import_http_request.httpJson)(
341
- `${FIREWALL_API_URL}/${encodeURIComponent(purl)}`,
342
- {
343
- headers: { "User-Agent": import_socket.SOCKET_LIB_USER_AGENT },
344
- timeout: FIREWALL_TIMEOUT,
345
- retries: 1,
346
- retryDelay: 500
347
- }
348
- );
349
- const blocking = (data.alerts ?? []).filter(
350
- (a) => a.severity && FIREWALL_BLOCK_SEVERITIES.has(a.severity)
351
- );
352
- if (blocking.length > 0) {
353
- blocked.push({
354
- name,
355
- version,
356
- alerts: blocking.map(
357
- (a) => `${a.severity}: ${a.type ?? a.key ?? "unknown"}`
358
- )
359
- });
360
- }
361
- } catch {
362
- }
363
- })
364
- );
365
- if (blocked.length > 0) {
366
- const details = blocked.map((b) => ` ${b.name}@${b.version}: ${b.alerts.join(", ")}`).join("\n");
367
- throw new Error(
368
- `Socket Firewall blocked installation of "${requestedPackage}".
369
- The following dependencies have security alerts:
370
- ${details}
371
-
372
- Visit https://socket.dev for more information.`
373
- );
374
- }
375
- }
376
404
  function parsePackageSpec(spec) {
377
405
  try {
378
406
  const parsed = (0, import_npm_package_arg.default)(spec);
@@ -392,7 +420,6 @@ function parsePackageSpec(spec) {
392
420
  };
393
421
  }
394
422
  }
395
- const binaryPathCache = /* @__PURE__ */ new Map();
396
423
  function resolveBinaryPath(basePath) {
397
424
  if (!import_platform.WIN32) {
398
425
  return basePath;
@@ -1,3 +1,4 @@
1
+ /** @fileoverview Package management utilities for DLX installations. */
1
2
  /**
2
3
  * Check if a package is installed in DLX.
3
4
  *
@@ -9,17 +10,6 @@
9
10
  * ```
10
11
  */
11
12
  export declare function isDlxPackageInstalled(packageName: string): boolean;
12
- /**
13
- * Check if a package is installed in DLX asynchronously.
14
- *
15
- * @example
16
- * ```typescript
17
- * if (await isDlxPackageInstalledAsync('prettier')) {
18
- * console.log('prettier is installed')
19
- * }
20
- * ```
21
- */
22
- export declare function isDlxPackageInstalledAsync(packageName: string): Promise<boolean>;
23
13
  /**
24
14
  * List all packages installed in DLX.
25
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;
@@ -20,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
21
  var packages_exports = {};
21
22
  __export(packages_exports, {
22
23
  isDlxPackageInstalled: () => isDlxPackageInstalled,
23
- isDlxPackageInstalledAsync: () => isDlxPackageInstalledAsync,
24
24
  listDlxPackages: () => listDlxPackages,
25
25
  listDlxPackagesAsync: () => listDlxPackagesAsync,
26
26
  removeDlxPackage: () => removeDlxPackage,
@@ -34,7 +34,7 @@ let _fs;
34
34
  // @__NO_SIDE_EFFECTS__
35
35
  function getFs() {
36
36
  if (_fs === void 0) {
37
- _fs = require("fs");
37
+ _fs = require("node:fs");
38
38
  }
39
39
  return _fs;
40
40
  }
@@ -42,15 +42,6 @@ function isDlxPackageInstalled(packageName) {
42
42
  const fs = /* @__PURE__ */ getFs();
43
43
  return fs.existsSync((0, import_paths.getDlxInstalledPackageDir)(packageName));
44
44
  }
45
- async function isDlxPackageInstalledAsync(packageName) {
46
- const fs = /* @__PURE__ */ getFs();
47
- try {
48
- await fs.promises.access((0, import_paths.getDlxInstalledPackageDir)(packageName));
49
- return true;
50
- } catch {
51
- return false;
52
- }
53
- }
54
45
  function listDlxPackages() {
55
46
  try {
56
47
  return (0, import_fs.readDirNamesSync)((0, import_socket.getSocketDlxDir)(), { sort: true });
@@ -80,10 +71,9 @@ async function removeDlxPackage(packageName) {
80
71
  }
81
72
  }
82
73
  function removeDlxPackageSync(packageName) {
83
- const fs = /* @__PURE__ */ getFs();
84
74
  const packageDir = (0, import_paths.getDlxPackageDir)(packageName);
85
75
  try {
86
- fs.rmSync(packageDir, { recursive: true, force: true });
76
+ (0, import_fs.safeDeleteSync)(packageDir, { recursive: true, force: true });
87
77
  } catch (e) {
88
78
  const code = e.code;
89
79
  if (code === "EACCES" || code === "EPERM") {
@@ -117,7 +107,6 @@ Check permissions and ensure no programs are using this directory.`,
117
107
  // Annotate the CommonJS export names for ESM import in node:
118
108
  0 && (module.exports = {
119
109
  isDlxPackageInstalled,
120
- isDlxPackageInstalledAsync,
121
110
  listDlxPackages,
122
111
  listDlxPackagesAsync,
123
112
  removeDlxPackage,
@@ -1,3 +1,4 @@
1
+ /** @fileoverview Path utilities for DLX package installations. */
1
2
  /**
2
3
  * Get the installed package directory within DLX node_modules.
3
4
  *
package/dist/dlx/paths.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;
@@ -32,7 +33,7 @@ let _path;
32
33
  // @__NO_SIDE_EFFECTS__
33
34
  function getPath() {
34
35
  if (_path === void 0) {
35
- _path = require("path");
36
+ _path = require("node:path");
36
37
  }
37
38
  return _path;
38
39
  }
@@ -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,5 +1,17 @@
1
+ /**
2
+ * @fileoverview Text shimmer animation utilities.
3
+ * Provides animated highlight effects for spinner text with configurable directions:
4
+ * - LTR (left-to-right): Shimmer wave moves from left to right
5
+ * - RTL (right-to-left): Shimmer wave moves from right to left
6
+ * - Bidirectional: Alternates between LTR and RTL each cycle
7
+ * - Random: Picks a random direction each cycle
8
+ * - None: No shimmer animation
9
+ *
10
+ * The shimmer effect creates a bright wave that travels across the text,
11
+ * with characters near the wave appearing nearly white and fading to the
12
+ * base color as they get further from the wave position.
13
+ */
1
14
  import type { ShimmerColorGradient, ShimmerColorRgb, ShimmerDirection, ShimmerState } from './types';
2
- // Re-export types for backward compatibility.
3
15
  export type { ShimmerColor, ShimmerColorGradient, ShimmerColorInherit, ShimmerColorRgb, ShimmerConfig, ShimmerDirection, ShimmerState, } from './types';
4
16
  /**
5
17
  * Detected text formatting styles from ANSI codes.
@@ -11,7 +23,6 @@ type TextStyles = {
11
23
  strikethrough: boolean;
12
24
  underline: boolean;
13
25
  };
14
- // Internal options for applyShimmer function.
15
26
  type ShimmerOptions = {
16
27
  readonly color?: ShimmerColorRgb | ShimmerColorGradient | undefined;
17
28
  readonly direction?: ShimmerDirection | undefined;
@@ -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;
@@ -31,8 +32,20 @@ module.exports = __toCommonJS(text_shimmer_exports);
31
32
  var import_ansi = require("../ansi");
32
33
  var import_arrays = require("../arrays");
33
34
  var import_ci = require("../env/ci");
34
- var import_utils = require("../themes/utils");
35
35
  var import_themes = require("../themes/themes");
36
+ var import_utils = require("../themes/utils");
37
+ const COLOR_INHERIT = "inherit";
38
+ const DIR_LTR = "ltr";
39
+ const DIR_NONE = "none";
40
+ const DIR_RANDOM = "random";
41
+ const DIR_RTL = "rtl";
42
+ const MODE_BI = "bi";
43
+ function blendColors(color1, color2, factor) {
44
+ const r = Math.round(color1[0] + (color2[0] - color1[0]) * factor);
45
+ const g = Math.round(color1[1] + (color2[1] - color1[1]) * factor);
46
+ const b = Math.round(color1[2] + (color2[2] - color1[2]) * factor);
47
+ return [r, g, b];
48
+ }
36
49
  function detectStyles(text) {
37
50
  return {
38
51
  __proto__: null,
@@ -48,43 +61,21 @@ function detectStyles(text) {
48
61
  underline: /\x1b\[4m/.test(text)
49
62
  };
50
63
  }
51
- function stylesToAnsi(styles) {
52
- let codes = "";
53
- if (styles.bold) {
54
- codes += "\x1B[1m";
55
- }
56
- if (styles.dim) {
57
- codes += "\x1B[2m";
58
- }
59
- if (styles.italic) {
60
- codes += "\x1B[3m";
61
- }
62
- if (styles.underline) {
63
- codes += "\x1B[4m";
64
- }
65
- if (styles.strikethrough) {
66
- codes += "\x1B[9m";
64
+ function getShimmerPos(textLength, step, currentDir, shimmerWidth = 2.5) {
65
+ const totalSteps = textLength + shimmerWidth + 2;
66
+ if (currentDir === DIR_RTL) {
67
+ return textLength - step % totalSteps;
67
68
  }
68
- return codes;
69
+ return step % totalSteps;
69
70
  }
70
- const COLOR_INHERIT = "inherit";
71
- const DIR_LTR = "ltr";
72
- const DIR_NONE = "none";
73
- const DIR_RANDOM = "random";
74
- const DIR_RTL = "rtl";
75
- const MODE_BI = "bi";
76
- function shimmerIntensity(distance, shimmerWidth = 2.5) {
77
- if (distance > shimmerWidth) {
78
- return 0;
71
+ function pickDirection(direction) {
72
+ if (direction === DIR_RANDOM) {
73
+ return Math.random() < 0.5 ? DIR_LTR : DIR_RTL;
79
74
  }
80
- const normalized = distance / shimmerWidth;
81
- return (1 - normalized) ** 2.5;
82
- }
83
- function blendColors(color1, color2, factor) {
84
- const r = Math.round(color1[0] + (color2[0] - color1[0]) * factor);
85
- const g = Math.round(color1[1] + (color2[1] - color1[1]) * factor);
86
- const b = Math.round(color1[2] + (color2[2] - color1[2]) * factor);
87
- return [r, g, b];
75
+ if (direction === DIR_RTL) {
76
+ return DIR_RTL;
77
+ }
78
+ return DIR_LTR;
88
79
  }
89
80
  function renderChar(char, index, shimmerPos, baseColor, styles) {
90
81
  const distance = Math.abs(index - shimmerPos);
@@ -104,21 +95,31 @@ function renderChar(char, index, shimmerPos, baseColor, styles) {
104
95
  const color = `\x1B[38;2;${blended[0]};${blended[1]};${blended[2]}m`;
105
96
  return `${styleCode}${color}${char}${import_ansi.ANSI_RESET}`;
106
97
  }
107
- function getShimmerPos(textLength, step, currentDir, shimmerWidth = 2.5) {
108
- const totalSteps = textLength + shimmerWidth + 2;
109
- if (currentDir === DIR_RTL) {
110
- return textLength - step % totalSteps;
98
+ function shimmerIntensity(distance, shimmerWidth = 2.5) {
99
+ if (distance > shimmerWidth) {
100
+ return 0;
111
101
  }
112
- return step % totalSteps;
102
+ const normalized = distance / shimmerWidth;
103
+ return (1 - normalized) ** 2.5;
113
104
  }
114
- function pickDirection(direction) {
115
- if (direction === DIR_RANDOM) {
116
- return Math.random() < 0.5 ? DIR_LTR : DIR_RTL;
105
+ function stylesToAnsi(styles) {
106
+ let codes = "";
107
+ if (styles.bold) {
108
+ codes += "\x1B[1m";
117
109
  }
118
- if (direction === DIR_RTL) {
119
- return DIR_RTL;
110
+ if (styles.dim) {
111
+ codes += "\x1B[2m";
120
112
  }
121
- return DIR_LTR;
113
+ if (styles.italic) {
114
+ codes += "\x1B[3m";
115
+ }
116
+ if (styles.underline) {
117
+ codes += "\x1B[4m";
118
+ }
119
+ if (styles.strikethrough) {
120
+ codes += "\x1B[9m";
121
+ }
122
+ return codes;
122
123
  }
123
124
  function applyShimmer(text, state, options) {
124
125
  const opts = { __proto__: null, ...options };
@@ -127,6 +128,9 @@ function applyShimmer(text, state, options) {
127
128
  let color;
128
129
  if (opts.theme) {
129
130
  const theme = typeof opts.theme === "string" ? import_themes.THEMES[opts.theme] : opts.theme;
131
+ if (!theme) {
132
+ throw new Error(`Unknown theme: ${opts.theme}`);
133
+ }
130
134
  const themeColor = (0, import_utils.resolveColor)(
131
135
  theme.colors.primary,
132
136
  theme.colors
@@ -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,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/env/ci.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @fileoverview CI environment variable getter.
3
+ * Exports `getCI()`, which returns whether the `CI` environment variable is
4
+ * present (using the rewire helper so tests can override without touching
5
+ * `process.env`).
6
+ */
1
7
  /**
2
8
  * Returns whether the CI environment variable is set.
3
9
  *
@@ -12,5 +18,4 @@
12
18
  * }
13
19
  * ```
14
20
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
21
  export declare function getCI(): boolean;
package/dist/env/ci.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,3 +1,8 @@
1
+ /**
2
+ * @fileoverview DEBUG environment variable getter.
3
+ * Exports `getDebug()`, which returns the raw `DEBUG` filter string used by
4
+ * the `debug` package (or `undefined` when unset).
5
+ */
1
6
  /**
2
7
  * Returns the value of the DEBUG environment variable.
3
8
  *
@@ -11,5 +16,4 @@
11
16
  * // e.g. 'socket:*' or undefined
12
17
  * ```
13
18
  */
14
- /*@__NO_SIDE_EFFECTS__*/
15
19
  export declare function getDebug(): string | undefined;
package/dist/env/debug.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,3 +1,22 @@
1
+ /**
2
+ * @fileoverview GitHub Actions environment variable getters.
3
+ * Provides access to GitHub Actions CI/CD environment variables.
4
+ */
5
+ /**
6
+ * GH_TOKEN environment variable.
7
+ * Alternative GitHub authentication token for API access (used by GitHub CLI).
8
+ *
9
+ * @returns The GH CLI token, or `undefined` if not set
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { getGhToken } from '@socketsecurity/lib/env/github'
14
+ *
15
+ * const token = getGhToken()
16
+ * // e.g. 'gho_abc123...' or undefined
17
+ * ```
18
+ */
19
+ export declare function getGhToken(): string | undefined;
1
20
  /**
2
21
  * GITHUB_API_URL environment variable.
3
22
  * GitHub API URL (e.g., https://api.github.com).
@@ -12,7 +31,6 @@
12
31
  * // e.g. 'https://api.github.com' or undefined
13
32
  * ```
14
33
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
34
  export declare function getGithubApiUrl(): string | undefined;
17
35
  /**
18
36
  * GITHUB_BASE_REF environment variable.
@@ -28,7 +46,6 @@ export declare function getGithubApiUrl(): string | undefined;
28
46
  * // e.g. 'main' or undefined
29
47
  * ```
30
48
  */
31
- /*@__NO_SIDE_EFFECTS__*/
32
49
  export declare function getGithubBaseRef(): string | undefined;
33
50
  /**
34
51
  * GITHUB_REF_NAME environment variable.
@@ -44,7 +61,6 @@ export declare function getGithubBaseRef(): string | undefined;
44
61
  * // e.g. 'feature/my-branch' or 'v1.0.0'
45
62
  * ```
46
63
  */
47
- /*@__NO_SIDE_EFFECTS__*/
48
64
  export declare function getGithubRefName(): string | undefined;
49
65
  /**
50
66
  * GITHUB_REF_TYPE environment variable.
@@ -60,7 +76,6 @@ export declare function getGithubRefName(): string | undefined;
60
76
  * // e.g. 'branch' or 'tag'
61
77
  * ```
62
78
  */
63
- /*@__NO_SIDE_EFFECTS__*/
64
79
  export declare function getGithubRefType(): string | undefined;
65
80
  /**
66
81
  * GITHUB_REPOSITORY environment variable.
@@ -76,7 +91,6 @@ export declare function getGithubRefType(): string | undefined;
76
91
  * // e.g. 'SocketDev/socket-cli' or undefined
77
92
  * ```
78
93
  */
79
- /*@__NO_SIDE_EFFECTS__*/
80
94
  export declare function getGithubRepository(): string | undefined;
81
95
  /**
82
96
  * GITHUB_SERVER_URL environment variable.
@@ -92,7 +106,6 @@ export declare function getGithubRepository(): string | undefined;
92
106
  * // e.g. 'https://github.com' or undefined
93
107
  * ```
94
108
  */
95
- /*@__NO_SIDE_EFFECTS__*/
96
109
  export declare function getGithubServerUrl(): string | undefined;
97
110
  /**
98
111
  * GITHUB_TOKEN environment variable.
@@ -108,21 +121,4 @@ export declare function getGithubServerUrl(): string | undefined;
108
121
  * // e.g. 'ghp_abc123...' or undefined
109
122
  * ```
110
123
  */
111
- /*@__NO_SIDE_EFFECTS__*/
112
124
  export declare function getGithubToken(): string | undefined;
113
- /**
114
- * GH_TOKEN environment variable.
115
- * Alternative GitHub authentication token for API access (used by GitHub CLI).
116
- *
117
- * @returns The GH CLI token, or `undefined` if not set
118
- *
119
- * @example
120
- * ```typescript
121
- * import { getGhToken } from '@socketsecurity/lib/env/github'
122
- *
123
- * const token = getGhToken()
124
- * // e.g. 'gho_abc123...' or undefined
125
- * ```
126
- */
127
- /*@__NO_SIDE_EFFECTS__*/
128
- export declare function getGhToken(): string | undefined;