@socketsecurity/lib 5.3.0 → 5.4.1

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 (48) hide show
  1. package/CHANGELOG.md +22 -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/@npmcli/package-json.js +11 -7
  13. package/dist/external/debug.js +670 -15
  14. package/dist/external/del.js +4 -7139
  15. package/dist/external/external-pack.js +4795 -0
  16. package/dist/external/fast-glob.js +4 -5776
  17. package/dist/external/has-flag.js +6 -0
  18. package/dist/external/libnpmexec.js +2 -2
  19. package/dist/external/normalize-package-data.js +2 -2
  20. package/dist/external/npm-pack.js +1698 -3337
  21. package/dist/external/npm-package-arg.js +2 -2
  22. package/dist/external/pico-pack.js +7162 -0
  23. package/dist/external/picomatch.js +4 -1523
  24. package/dist/external/semver.js +2 -2
  25. package/dist/external/signal-exit.js +5 -0
  26. package/dist/external/spdx-correct.js +4 -1384
  27. package/dist/external/spdx-expression-parse.js +4 -1047
  28. package/dist/external/spdx-pack.js +1640 -0
  29. package/dist/external/supports-color.js +8 -0
  30. package/dist/external/validate-npm-package-name.js +4 -104
  31. package/dist/external/yoctocolors-cjs.js +5 -92
  32. package/dist/http-request.js +10 -2
  33. package/dist/ipc.js +53 -29
  34. package/dist/packages/isolation.js +45 -23
  35. package/dist/packages/licenses.js +10 -2
  36. package/dist/paths/socket.d.ts +2 -2
  37. package/dist/paths/socket.js +27 -21
  38. package/dist/process-lock.js +23 -14
  39. package/dist/releases/github.d.ts +67 -41
  40. package/dist/releases/github.js +142 -100
  41. package/dist/releases/socket-btm.d.ts +40 -33
  42. package/dist/releases/socket-btm.js +45 -5
  43. package/dist/spawn.js +10 -3
  44. package/dist/stdio/mask.d.ts +6 -21
  45. package/dist/stdio/mask.js +18 -14
  46. package/dist/themes/context.js +10 -2
  47. package/package.json +16 -3
  48. package/dist/external/npm-core.js +0 -6588
@@ -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 socket_exports = {};
31
21
  __export(socket_exports, {
@@ -44,8 +34,6 @@ __export(socket_exports, {
44
34
  getUserHomeDir: () => getUserHomeDir
45
35
  });
46
36
  module.exports = __toCommonJS(socket_exports);
47
- var os = __toESM(require("os"));
48
- var path = __toESM(require("path"));
49
37
  var import_github = require("../constants/github");
50
38
  var import_socket = require("../constants/socket");
51
39
  var import_home = require("../env/home");
@@ -54,11 +42,27 @@ var import_windows = require("../env/windows");
54
42
  var import_dirnames = require("./dirnames");
55
43
  var import_normalize = require("./normalize");
56
44
  var import_rewire = require("./rewire");
45
+ let _os;
46
+ // @__NO_SIDE_EFFECTS__
47
+ function getOs() {
48
+ if (_os === void 0) {
49
+ _os = require("os");
50
+ }
51
+ return _os;
52
+ }
53
+ let _path;
54
+ // @__NO_SIDE_EFFECTS__
55
+ function getPath() {
56
+ if (_path === void 0) {
57
+ _path = require("path");
58
+ }
59
+ return _path;
60
+ }
57
61
  function getOsHomeDir() {
58
- return (0, import_rewire.getPathValue)("homedir", () => os.homedir());
62
+ return (0, import_rewire.getPathValue)("homedir", () => (/* @__PURE__ */ getOs()).homedir());
59
63
  }
60
64
  function getOsTmpDir() {
61
- return (0, import_rewire.getPathValue)("tmpdir", () => os.tmpdir());
65
+ return (0, import_rewire.getPathValue)("tmpdir", () => (/* @__PURE__ */ getOs()).tmpdir());
62
66
  }
63
67
  function getSocketHomePath() {
64
68
  return getSocketUserDir();
@@ -69,12 +73,12 @@ function getSocketUserDir() {
69
73
  if (socketHome) {
70
74
  return (0, import_normalize.normalizePath)(socketHome);
71
75
  }
72
- return (0, import_normalize.normalizePath)(path.join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
76
+ return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
73
77
  });
74
78
  }
75
79
  function getSocketAppDir(appName) {
76
80
  return (0, import_normalize.normalizePath)(
77
- path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}${appName}`)
81
+ (/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}${appName}`)
78
82
  );
79
83
  }
80
84
  function getSocketCacacheDir() {
@@ -83,7 +87,7 @@ function getSocketCacacheDir() {
83
87
  return (0, import_normalize.normalizePath)((0, import_socket2.getSocketCacacheDir)());
84
88
  }
85
89
  return (0, import_normalize.normalizePath)(
86
- path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
90
+ (/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
87
91
  );
88
92
  });
89
93
  }
@@ -93,7 +97,7 @@ function getSocketDlxDir() {
93
97
  return (0, import_normalize.normalizePath)((0, import_socket2.getSocketDlxDirEnv)());
94
98
  }
95
99
  return (0, import_normalize.normalizePath)(
96
- path.join(
100
+ (/* @__PURE__ */ getPath()).join(
97
101
  getSocketUserDir(),
98
102
  `${import_socket.SOCKET_APP_PREFIX}${import_socket.SOCKET_DLX_APP_NAME}`
99
103
  )
@@ -101,10 +105,12 @@ function getSocketDlxDir() {
101
105
  });
102
106
  }
103
107
  function getSocketAppCacheDir(appName) {
104
- return (0, import_normalize.normalizePath)(path.join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
108
+ return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
105
109
  }
106
110
  function getSocketAppCacheTtlDir(appName) {
107
- return (0, import_normalize.normalizePath)(path.join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR));
111
+ return (0, import_normalize.normalizePath)(
112
+ (/* @__PURE__ */ getPath()).join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR)
113
+ );
108
114
  }
109
115
  function getSocketCliDir() {
110
116
  return getSocketAppDir(import_socket.SOCKET_CLI_APP_NAME);
@@ -114,7 +120,7 @@ function getSocketRegistryDir() {
114
120
  }
115
121
  function getSocketRegistryGithubCacheDir() {
116
122
  return (0, import_normalize.normalizePath)(
117
- path.join(
123
+ (/* @__PURE__ */ getPath()).join(
118
124
  getSocketAppCacheTtlDir(import_socket.SOCKET_REGISTRY_APP_NAME),
119
125
  import_github.CACHE_GITHUB_DIR
120
126
  )
@@ -22,11 +22,20 @@ __export(process_lock_exports, {
22
22
  processLock: () => processLock
23
23
  });
24
24
  module.exports = __toCommonJS(process_lock_exports);
25
- var import_fs = require("fs");
26
- var import_fs2 = require("./fs");
25
+ var import_fs = require("./fs");
27
26
  var import_logger = require("./logger");
28
27
  var import_promises = require("./promises");
29
28
  var import_signal_exit = require("./signal-exit");
29
+ let _fs;
30
+ // @__NO_SIDE_EFFECTS__
31
+ function getFs() {
32
+ if (_fs === void 0) {
33
+ _fs = require("fs");
34
+ }
35
+ return _fs;
36
+ }
37
+ const fs = /* @__PURE__ */ getFs();
38
+ const { existsSync, mkdirSync, statSync, utimesSync } = fs;
30
39
  const logger = (0, import_logger.getDefaultLogger)();
31
40
  class ProcessLockManager {
32
41
  activeLocks = /* @__PURE__ */ new Set();
@@ -47,8 +56,8 @@ class ProcessLockManager {
47
56
  this.touchTimers.clear();
48
57
  for (const lockPath of this.activeLocks) {
49
58
  try {
50
- if ((0, import_fs.existsSync)(lockPath)) {
51
- (0, import_fs2.safeDeleteSync)(lockPath, { recursive: true });
59
+ if (existsSync(lockPath)) {
60
+ (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
52
61
  }
53
62
  } catch {
54
63
  }
@@ -64,9 +73,9 @@ class ProcessLockManager {
64
73
  */
65
74
  touchLock(lockPath) {
66
75
  try {
67
- if ((0, import_fs.existsSync)(lockPath)) {
76
+ if (existsSync(lockPath)) {
68
77
  const now = /* @__PURE__ */ new Date();
69
- (0, import_fs.utimesSync)(lockPath, now, now);
78
+ utimesSync(lockPath, now, now);
70
79
  }
71
80
  } catch (error) {
72
81
  logger.warn(
@@ -114,10 +123,10 @@ class ProcessLockManager {
114
123
  */
115
124
  isStale(lockPath, staleMs) {
116
125
  try {
117
- if (!(0, import_fs.existsSync)(lockPath)) {
126
+ if (!existsSync(lockPath)) {
118
127
  return false;
119
128
  }
120
- const stats = (0, import_fs.statSync)(lockPath);
129
+ const stats = statSync(lockPath);
121
130
  const ageSeconds = Math.floor((Date.now() - stats.mtime.getTime()) / 1e3);
122
131
  const staleSeconds = Math.floor(staleMs / 1e3);
123
132
  return ageSeconds > staleSeconds;
@@ -160,17 +169,17 @@ class ProcessLockManager {
160
169
  return await (0, import_promises.pRetry)(
161
170
  async () => {
162
171
  try {
163
- if ((0, import_fs.existsSync)(lockPath) && this.isStale(lockPath, staleMs)) {
172
+ if (existsSync(lockPath) && this.isStale(lockPath, staleMs)) {
164
173
  logger.log(`Removing stale lock: ${lockPath}`);
165
174
  try {
166
- (0, import_fs2.safeDeleteSync)(lockPath, { recursive: true });
175
+ (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
167
176
  } catch {
168
177
  }
169
178
  }
170
- if ((0, import_fs.existsSync)(lockPath)) {
179
+ if (existsSync(lockPath)) {
171
180
  throw new Error(`Lock already exists: ${lockPath}`);
172
181
  }
173
- (0, import_fs.mkdirSync)(lockPath, { recursive: true });
182
+ mkdirSync(lockPath, { recursive: true });
174
183
  this.activeLocks.add(lockPath);
175
184
  this.startTouchTimer(lockPath, touchIntervalMs);
176
185
  return () => this.release(lockPath);
@@ -246,8 +255,8 @@ To resolve:
246
255
  release(lockPath) {
247
256
  this.stopTouchTimer(lockPath);
248
257
  try {
249
- if ((0, import_fs.existsSync)(lockPath)) {
250
- (0, import_fs2.safeDeleteSync)(lockPath, { recursive: true });
258
+ if (existsSync(lockPath)) {
259
+ (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
251
260
  }
252
261
  this.activeLocks.delete(lockPath);
253
262
  } catch (error) {
@@ -1,69 +1,84 @@
1
1
  /**
2
- * Socket-btm GitHub repository configuration.
3
- */
4
- export declare const SOCKET_BTM_REPO: {
5
- readonly owner: "SocketDev";
6
- readonly repo: "socket-btm";
7
- };
8
- /**
9
- * Configuration for repository access.
2
+ * Pattern for matching release assets.
3
+ * Can be either:
4
+ * - A string with glob pattern syntax
5
+ * - A prefix/suffix pair for explicit matching (backward compatible)
6
+ * - A RegExp for complex patterns
7
+ *
8
+ * String patterns support full glob syntax via picomatch.
9
+ * Examples:
10
+ * - Simple wildcard: yoga-sync-*.mjs matches yoga-sync-abc123.mjs
11
+ * - Complex: models-*.tar.gz matches models-2024-01-15.tar.gz
12
+ * - Prefix wildcard: *-models.tar.gz matches foo-models.tar.gz
13
+ * - Suffix wildcard: yoga-* matches yoga-layout
14
+ * - Brace expansion: {yoga,models}-*.{mjs,js} matches yoga-abc.mjs or models-xyz.js
15
+ *
16
+ * For backward compatibility, prefix/suffix objects are still supported but glob patterns are recommended.
10
17
  */
11
- export interface RepoConfig {
12
- /**
13
- * GitHub repository owner/organization.
14
- */
15
- owner: string;
16
- /**
17
- * GitHub repository name.
18
- */
19
- repo: string;
20
- }
18
+ export type AssetPattern = string | {
19
+ prefix: string;
20
+ suffix: string;
21
+ } | RegExp;
21
22
  /**
22
23
  * Configuration for downloading a GitHub release.
23
24
  */
24
25
  export interface DownloadGitHubReleaseConfig {
25
- /** GitHub repository owner/organization. */
26
- owner: string;
27
- /** GitHub repository name. */
28
- repo: string;
26
+ /** Asset name on GitHub. */
27
+ assetName: string;
28
+ /** Binary filename (e.g., 'node', 'binject'). */
29
+ binaryName: string;
29
30
  /** Working directory (defaults to process.cwd()). */
30
31
  cwd?: string;
31
32
  /** Download destination directory. @default 'build/downloaded' */
32
33
  downloadDir?: string;
33
- /** Tool name for directory structure. */
34
- toolName: string;
34
+ /** GitHub repository owner/organization. */
35
+ owner: string;
35
36
  /** Platform-arch identifier (e.g., 'linux-x64-musl'). */
36
37
  platformArch: string;
37
- /** Binary filename (e.g., 'node', 'binject'). */
38
- binaryName: string;
39
- /** Asset name on GitHub. */
40
- assetName: string;
41
- /** Tool prefix for finding latest release. */
42
- toolPrefix?: string;
43
- /** Specific release tag to download. */
44
- tag?: string;
45
38
  /** Suppress log messages. @default false */
46
39
  quiet?: boolean;
47
40
  /** Remove macOS quarantine attribute after download. @default true */
48
41
  removeMacOSQuarantine?: boolean;
42
+ /** GitHub repository name. */
43
+ repo: string;
44
+ /** Specific release tag to download. */
45
+ tag?: string;
46
+ /** Tool name for directory structure. */
47
+ toolName: string;
48
+ /** Tool prefix for finding latest release. */
49
+ toolPrefix?: string;
49
50
  }
50
51
  /**
51
- * Download a binary from any GitHub repository with version caching.
52
- *
53
- * @param config - Download configuration
54
- * @returns Path to the downloaded binary
52
+ * Configuration for repository access.
55
53
  */
56
- export declare function downloadGitHubRelease(config: DownloadGitHubReleaseConfig): Promise<string>;
54
+ export interface RepoConfig {
55
+ /**
56
+ * GitHub repository owner/organization.
57
+ */
58
+ owner: string;
59
+ /**
60
+ * GitHub repository name.
61
+ */
62
+ repo: string;
63
+ }
64
+ /**
65
+ * Socket-btm GitHub repository configuration.
66
+ */
67
+ export declare const SOCKET_BTM_REPO: {
68
+ readonly owner: "SocketDev";
69
+ readonly repo: "socket-btm";
70
+ };
57
71
  /**
58
72
  * Download a specific release asset.
73
+ * Supports pattern matching for dynamic asset discovery.
59
74
  *
60
75
  * @param tag - Release tag name
61
- * @param assetName - Asset name to download
76
+ * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
62
77
  * @param outputPath - Path to write the downloaded file
63
78
  * @param repoConfig - Repository configuration (owner/repo)
64
79
  * @param options - Additional options
65
80
  */
66
- export declare function downloadReleaseAsset(tag: string, assetName: string, outputPath: string, repoConfig: RepoConfig, options?: {
81
+ export declare function downloadReleaseAsset(tag: string, assetPattern: string | AssetPattern, outputPath: string, repoConfig: RepoConfig, options?: {
67
82
  quiet?: boolean;
68
83
  }): Promise<void>;
69
84
  /**
@@ -75,24 +90,35 @@ export declare function downloadReleaseAsset(tag: string, assetName: string, out
75
90
  export declare function getAuthHeaders(): Record<string, string>;
76
91
  /**
77
92
  * Get latest release tag matching a tool prefix.
93
+ * Optionally filter by releases containing a matching asset.
78
94
  *
79
95
  * @param toolPrefix - Tool name prefix to search for (e.g., 'node-smol-')
80
96
  * @param repoConfig - Repository configuration (owner/repo)
81
97
  * @param options - Additional options
98
+ * @param options.assetPattern - Optional pattern to filter releases by matching asset
82
99
  * @returns Latest release tag or null if not found
83
100
  */
84
101
  export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoConfig, options?: {
102
+ assetPattern?: AssetPattern;
85
103
  quiet?: boolean;
86
104
  }): Promise<string | null>;
87
105
  /**
88
106
  * Get download URL for a specific release asset.
107
+ * Supports pattern matching for dynamic asset discovery.
89
108
  *
90
109
  * @param tag - Release tag name
91
- * @param assetName - Asset name to download
110
+ * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
92
111
  * @param repoConfig - Repository configuration (owner/repo)
93
112
  * @param options - Additional options
94
113
  * @returns Browser download URL for the asset
95
114
  */
96
- export declare function getReleaseAssetUrl(tag: string, assetName: string, repoConfig: RepoConfig, options?: {
115
+ export declare function getReleaseAssetUrl(tag: string, assetPattern: string | AssetPattern, repoConfig: RepoConfig, options?: {
97
116
  quiet?: boolean;
98
117
  }): Promise<string | null>;
118
+ /**
119
+ * Download a binary from any GitHub repository with version caching.
120
+ *
121
+ * @param config - Download configuration
122
+ * @returns Path to the downloaded binary
123
+ */
124
+ export declare function downloadGitHubRelease(config: DownloadGitHubReleaseConfig): Promise<string>;