@socketsecurity/lib 5.3.0 → 5.4.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 (37) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cover/code.js +12 -4
  3. package/dist/dlx/cache.js +10 -2
  4. package/dist/dlx/manifest.js +45 -41
  5. package/dist/env/rewire.js +10 -2
  6. package/dist/external/@inquirer/checkbox.js +4 -2528
  7. package/dist/external/@inquirer/confirm.js +4 -2371
  8. package/dist/external/@inquirer/input.js +4 -2395
  9. package/dist/external/@inquirer/password.js +4 -2503
  10. package/dist/external/@inquirer/search.js +4 -2500
  11. package/dist/external/@inquirer/select.js +4 -2617
  12. package/dist/external/del.js +4 -7139
  13. package/dist/external/fast-glob.js +4 -5776
  14. package/dist/external/inquirer-pack.js +4610 -0
  15. package/dist/external/npm-core.js +3 -1
  16. package/dist/external/pico-pack.js +7162 -0
  17. package/dist/external/picomatch.js +4 -1523
  18. package/dist/external/spdx-correct.js +4 -1384
  19. package/dist/external/spdx-expression-parse.js +4 -1047
  20. package/dist/external/spdx-pack.js +1640 -0
  21. package/dist/external/validate-npm-package-name.js +4 -104
  22. package/dist/http-request.js +10 -2
  23. package/dist/ipc.js +53 -29
  24. package/dist/packages/isolation.js +45 -23
  25. package/dist/packages/licenses.js +10 -2
  26. package/dist/paths/socket.d.ts +2 -2
  27. package/dist/paths/socket.js +27 -21
  28. package/dist/process-lock.js +23 -14
  29. package/dist/releases/github.d.ts +67 -41
  30. package/dist/releases/github.js +142 -100
  31. package/dist/releases/socket-btm.d.ts +40 -33
  32. package/dist/releases/socket-btm.js +45 -5
  33. package/dist/spawn.js +10 -3
  34. package/dist/stdio/mask.d.ts +6 -21
  35. package/dist/stdio/mask.js +18 -14
  36. package/dist/themes/context.js +10 -2
  37. package/package.json +2 -1
@@ -26,18 +26,27 @@ __export(socket_btm_exports, {
26
26
  getPlatformArch: () => getPlatformArch
27
27
  });
28
28
  module.exports = __toCommonJS(socket_btm_exports);
29
- var import_fs = require("fs");
30
29
  var import_platform = require("../constants/platform.js");
31
30
  var import_github = require("./github.js");
32
31
  const ARCH_MAP = {
32
+ __proto__: null,
33
33
  arm64: "arm64",
34
34
  x64: "x64"
35
35
  };
36
+ let _fs;
37
+ // @__NO_SIDE_EFFECTS__
38
+ function getFs() {
39
+ if (_fs === void 0) {
40
+ _fs = require("fs");
41
+ }
42
+ return _fs;
43
+ }
36
44
  function detectLibc() {
37
45
  if ((0, import_platform.getPlatform)() !== "linux") {
38
46
  return void 0;
39
47
  }
40
48
  try {
49
+ const fs = /* @__PURE__ */ getFs();
41
50
  const muslPaths = [
42
51
  "/lib/ld-musl-x86_64.so.1",
43
52
  "/lib/ld-musl-aarch64.so.1",
@@ -45,7 +54,7 @@ function detectLibc() {
45
54
  "/usr/lib/ld-musl-aarch64.so.1"
46
55
  ];
47
56
  for (const path of muslPaths) {
48
- if ((0, import_fs.existsSync)(path)) {
57
+ if (fs.existsSync(path)) {
49
58
  return "musl";
50
59
  }
51
60
  }
@@ -64,7 +73,38 @@ async function downloadSocketBtmRelease(config) {
64
73
  output,
65
74
  removeMacOSQuarantine = false
66
75
  } = config;
67
- const outputName = output || asset;
76
+ let resolvedAsset;
77
+ let resolvedTag = tag;
78
+ const isExactMatch = typeof asset === "string" && !asset.includes("*");
79
+ if (isExactMatch) {
80
+ resolvedAsset = asset;
81
+ } else {
82
+ if (tag) {
83
+ throw new Error(
84
+ "Cannot use asset pattern with explicit tag. Either provide exact asset name or omit tag."
85
+ );
86
+ }
87
+ resolvedTag = await (0, import_github.getLatestRelease)(toolPrefix, import_github.SOCKET_BTM_REPO, {
88
+ assetPattern: asset,
89
+ quiet
90
+ });
91
+ if (!resolvedTag) {
92
+ throw new Error(`No ${tool} release with matching asset pattern found`);
93
+ }
94
+ const assetUrl = await (0, import_github.getReleaseAssetUrl)(
95
+ resolvedTag,
96
+ asset,
97
+ import_github.SOCKET_BTM_REPO,
98
+ {
99
+ quiet
100
+ }
101
+ );
102
+ if (!assetUrl) {
103
+ throw new Error(`No matching asset found in release ${resolvedTag}`);
104
+ }
105
+ resolvedAsset = assetUrl.split("/").pop() || asset.toString();
106
+ }
107
+ const outputName = output || resolvedAsset;
68
108
  const platformArch = "assets";
69
109
  downloadConfig = {
70
110
  owner: import_github.SOCKET_BTM_REPO.owner,
@@ -74,9 +114,9 @@ async function downloadSocketBtmRelease(config) {
74
114
  toolName: tool,
75
115
  platformArch,
76
116
  binaryName: outputName,
77
- assetName: asset,
117
+ assetName: resolvedAsset,
78
118
  toolPrefix,
79
- tag,
119
+ tag: resolvedTag,
80
120
  quiet,
81
121
  removeMacOSQuarantine
82
122
  };
package/dist/spawn.js CHANGED
@@ -37,13 +37,20 @@ __export(spawn_exports, {
37
37
  module.exports = __toCommonJS(spawn_exports);
38
38
  var import_process = require("./constants/process");
39
39
  var import_promise_spawn = __toESM(require("./external/@npmcli/promise-spawn"));
40
- var import_node_path = __toESM(require("node:path"));
41
40
  var import_arrays = require("./arrays");
42
41
  var import_bin = require("./bin");
43
42
  var import_normalize = require("./paths/normalize");
44
43
  var import_objects = require("./objects");
45
44
  var import_spinner = require("./spinner");
46
45
  var import_strings = require("./strings");
46
+ let _path;
47
+ // @__NO_SIDE_EFFECTS__
48
+ function getPath() {
49
+ if (_path === void 0) {
50
+ _path = require("path");
51
+ }
52
+ return _path;
53
+ }
47
54
  const abortSignal = (0, import_process.getAbortSignal)();
48
55
  const spinner = (0, import_spinner.getDefaultSpinner)();
49
56
  const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
@@ -102,7 +109,7 @@ function spawn(cmd, args, options, extra) {
102
109
  }
103
110
  const WIN32 = process.platform === "win32";
104
111
  if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
105
- actualCmd = import_node_path.default.basename(actualCmd, import_node_path.default.extname(actualCmd));
112
+ actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
106
113
  }
107
114
  const wasSpinning = !!spinnerInstance?.isSpinning;
108
115
  const shouldStopSpinner = wasSpinning && !/* @__PURE__ */ isStdioType(stdio, "ignore") && !/* @__PURE__ */ isStdioType(stdio, "pipe");
@@ -181,7 +188,7 @@ function spawnSync(cmd, args, options) {
181
188
  const shell = (0, import_objects.getOwn)(options, "shell");
182
189
  const WIN32 = process.platform === "win32";
183
190
  if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
184
- actualCmd = import_node_path.default.basename(actualCmd, import_node_path.default.extname(actualCmd));
191
+ actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
185
192
  }
186
193
  const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
187
194
  __proto__: null,
@@ -1,24 +1,4 @@
1
- /**
2
- * @fileoverview Interactive output masking utilities for CLI tools.
3
- * Provides output control with keyboard toggling (ctrl+o).
4
- *
5
- * ANSI Escape Sequences Used:
6
- * - '\r': Carriage return - moves cursor to beginning of current line.
7
- * - '\x1b[K' or '\x1b[0K': CSI K (erase line) - clear from cursor to end of line.
8
- * - '\x1b[2K': CSI 2K - erase entire line.
9
- * - '\x1b[1A': CSI A - move cursor up 1 line.
10
- *
11
- * Terminal Control:
12
- * - Raw mode (setRawMode(true)): Captures keypresses immediately without buffering.
13
- * - TTY detection: Ensures terminal manipulation only occurs in interactive terminals.
14
- *
15
- * Key Features:
16
- * - Output buffering: Stores up to 1000 lines when masked to prevent memory issues.
17
- * - Graceful cleanup: Always restores terminal to normal mode on exit/error.
18
- * - Visual feedback: Uses spinner to indicate process is running when output is masked.
19
- */
20
1
  import type { ChildProcess, SpawnOptions } from 'child_process';
21
- import readline from 'readline';
22
2
  export interface OutputMaskOptions {
23
3
  /**
24
4
  * Current working directory for spawned process.
@@ -120,7 +100,11 @@ export declare function createOutputMask(options?: OutputMaskOptions): OutputMas
120
100
  * - ctrl+c: Cancel the running process.
121
101
  * The handler manipulates terminal state using ANSI escape sequences.
122
102
  */
123
- export declare function createKeyboardHandler(mask: OutputMask, child: ChildProcess, options?: OutputMaskOptions): (_str: string, key: readline.Key) => void;
103
+ type ReadlineKey = {
104
+ ctrl?: boolean;
105
+ name?: string;
106
+ };
107
+ export declare function createKeyboardHandler(mask: OutputMask, child: ChildProcess, options?: OutputMaskOptions): (_str: string, key: ReadlineKey) => void;
124
108
  /**
125
109
  * Attach output masking to a child process.
126
110
  * Returns a promise that resolves with the exit code.
@@ -138,3 +122,4 @@ export declare function attachOutputMask(child: ChildProcess, options?: OutputMa
138
122
  * stdin is inherited, stdout and stderr are piped for masking control.
139
123
  */
140
124
  export declare function runWithMask(command: string, args?: string[], options?: OutputMaskOptions & SpawnOptions): Promise<number>;
125
+ export {};
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var mask_exports = {};
31
21
  __export(mask_exports, {
@@ -35,11 +25,25 @@ __export(mask_exports, {
35
25
  runWithMask: () => runWithMask
36
26
  });
37
27
  module.exports = __toCommonJS(mask_exports);
38
- var import_child_process = require("child_process");
39
- var import_readline = __toESM(require("readline"));
40
28
  var import_spinner = require("../spinner.js");
41
29
  var import_clear = require("./clear.js");
42
30
  var import_stdout = require("./stdout.js");
31
+ let _child_process;
32
+ // @__NO_SIDE_EFFECTS__
33
+ function getChildProcess() {
34
+ if (_child_process === void 0) {
35
+ _child_process = require("child_process");
36
+ }
37
+ return _child_process;
38
+ }
39
+ let _readline;
40
+ // @__NO_SIDE_EFFECTS__
41
+ function getReadline() {
42
+ if (_readline === void 0) {
43
+ _readline = require("readline");
44
+ }
45
+ return _readline;
46
+ }
43
47
  const spinner = (0, import_spinner.getDefaultSpinner)();
44
48
  function createOutputMask(options = {}) {
45
49
  const { showOutput = false } = options;
@@ -101,7 +105,7 @@ function attachOutputMask(child, options = {}) {
101
105
  );
102
106
  }
103
107
  if (process.stdin.isTTY) {
104
- import_readline.default.emitKeypressEvents(process.stdin);
108
+ (/* @__PURE__ */ getReadline()).emitKeypressEvents(process.stdin);
105
109
  process.stdin.setRawMode(true);
106
110
  const keypressHandler = createKeyboardHandler(mask, child, options);
107
111
  process.stdin.on("keypress", keypressHandler);
@@ -194,7 +198,7 @@ async function runWithMask(command, args = [], options = {}) {
194
198
  toggleText = "to see output",
195
199
  ...spawnOptions
196
200
  } = options;
197
- const child = (0, import_child_process.spawn)(command, args, {
201
+ const child = (/* @__PURE__ */ getChildProcess()).spawn(command, args, {
198
202
  stdio: ["inherit", "pipe", "pipe"],
199
203
  ...spawnOptions
200
204
  });
@@ -26,9 +26,17 @@ __export(context_exports, {
26
26
  withThemeSync: () => withThemeSync
27
27
  });
28
28
  module.exports = __toCommonJS(context_exports);
29
- var import_node_async_hooks = require("node:async_hooks");
30
29
  var import_themes = require("./themes");
31
- const themeStorage = new import_node_async_hooks.AsyncLocalStorage();
30
+ let _async_hooks;
31
+ // @__NO_SIDE_EFFECTS__
32
+ function getAsyncHooks() {
33
+ if (_async_hooks === void 0) {
34
+ _async_hooks = require("async_hooks");
35
+ }
36
+ return _async_hooks;
37
+ }
38
+ const { AsyncLocalStorage } = /* @__PURE__ */ getAsyncHooks();
39
+ const themeStorage = new AsyncLocalStorage();
32
40
  let fallbackTheme = import_themes.SOCKET_THEME;
33
41
  const listeners = /* @__PURE__ */ new Set();
34
42
  function setTheme(theme) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "packageManager": "pnpm@10.27.0",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",
@@ -787,6 +787,7 @@
787
787
  "@sigstore/sign": "4.1.0",
788
788
  "ansi-regex": "6.2.2",
789
789
  "lru-cache": "11.2.2",
790
+ "picomatch": "4.0.3",
790
791
  "semver": "7.7.2",
791
792
  "string-width": "8.1.0",
792
793
  "strip-ansi": "7.1.2",