@socketsecurity/lib 5.4.0 → 5.5.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.5.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.5.0) - 2026-01-12
9
+
10
+ ### Added
11
+
12
+ - **dlx/detect**: Executable type detection utilities for DLX cache and local file paths
13
+ - `detectDlxExecutableType()`: Detects Node.js packages vs native binaries in DLX cache by checking for node_modules/ directory
14
+ - `detectExecutableType()`: Generic entry point that routes to appropriate detection strategy
15
+ - `detectLocalExecutableType()`: Detects executables on local filesystem by checking package.json bin field or file extension
16
+ - `isJsFilePath()`: Validates if a file path has .js, .mjs, or .cjs extension
17
+ - `isNativeBinary()`: Simplified helper that returns true for native binary executables
18
+ - `isNodePackage()`: Simplified helper that returns true for Node.js packages
19
+
20
+ ### Fixed
21
+
22
+ - **releases/github**: Sort releases by published_at to reliably find latest release instead of relying on creation order
23
+
24
+ ## [5.4.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.4.1) - 2026-01-10
25
+
26
+ ### Fixed
27
+
28
+ - **build**: Removed debug module stub to bundle real debug package. The stub was missing `enable()` and `disable()` methods, causing errors when downstream projects re-bundled the lib.
29
+
8
30
  ## [5.4.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.4.0) - 2026-01-07
9
31
 
10
32
  ### Added
@@ -0,0 +1,66 @@
1
+ export type ExecutableType = 'package' | 'binary' | 'unknown';
2
+ export interface ExecutableDetectionResult {
3
+ type: ExecutableType;
4
+ method: 'dlx-cache' | 'package-json' | 'file-extension';
5
+ packageJsonPath?: string;
6
+ inDlxCache?: boolean;
7
+ }
8
+ /**
9
+ * Detect if a path is a Node.js package or native binary executable.
10
+ * Works for both DLX cache paths and local filesystem paths.
11
+ *
12
+ * Detection strategy:
13
+ * 1. If in DLX cache: Use detectDlxExecutableType()
14
+ * 2. Otherwise: Use detectLocalExecutableType()
15
+ *
16
+ * @param filePath - Path to executable (DLX cache or local filesystem)
17
+ * @returns Detection result with type, method, and metadata
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const result = detectExecutableType('/path/to/tool')
22
+ * if (result.type === 'package') {
23
+ * spawnNode([filePath, ...args])
24
+ * } else {
25
+ * spawn(filePath, args)
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function detectExecutableType(filePath: string): ExecutableDetectionResult;
30
+ /**
31
+ * Detect executable type for paths in DLX cache.
32
+ * Uses filesystem structure (node_modules/ presence).
33
+ *
34
+ * @param filePath - Path within DLX cache (~/.socket/_dlx/)
35
+ * @returns Detection result
36
+ */
37
+ export declare function detectDlxExecutableType(filePath: string): ExecutableDetectionResult;
38
+ /**
39
+ * Detect executable type for local filesystem paths.
40
+ * Uses package.json and file extension checks.
41
+ *
42
+ * @param filePath - Local filesystem path (not in DLX cache)
43
+ * @returns Detection result
44
+ */
45
+ export declare function detectLocalExecutableType(filePath: string): ExecutableDetectionResult;
46
+ /**
47
+ * Check if a file path indicates a Node.js script.
48
+ *
49
+ * @param filePath - Path to check
50
+ * @returns True if file has .js, .mjs, or .cjs extension
51
+ */
52
+ export declare function isJsFilePath(filePath: string): boolean;
53
+ /**
54
+ * Simplified helper: Is this a native binary executable?
55
+ *
56
+ * @param filePath - Path to check
57
+ * @returns True if detected as native binary (not Node.js package)
58
+ */
59
+ export declare function isNativeBinary(filePath: string): boolean;
60
+ /**
61
+ * Simplified helper: Is this a Node.js package?
62
+ *
63
+ * @param filePath - Path to check
64
+ * @returns True if detected as Node.js package
65
+ */
66
+ export declare function isNodePackage(filePath: string): boolean;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var detect_exports = {};
21
+ __export(detect_exports, {
22
+ detectDlxExecutableType: () => detectDlxExecutableType,
23
+ detectExecutableType: () => detectExecutableType,
24
+ detectLocalExecutableType: () => detectLocalExecutableType,
25
+ isJsFilePath: () => isJsFilePath,
26
+ isNativeBinary: () => isNativeBinary,
27
+ isNodePackage: () => isNodePackage
28
+ });
29
+ module.exports = __toCommonJS(detect_exports);
30
+ var import_paths = require("./paths");
31
+ var import_socket = require("../paths/socket");
32
+ let _fs;
33
+ let _path;
34
+ // @__NO_SIDE_EFFECTS__
35
+ function getFs() {
36
+ if (_fs === void 0) {
37
+ _fs = require("fs");
38
+ }
39
+ return _fs;
40
+ }
41
+ // @__NO_SIDE_EFFECTS__
42
+ function getPath() {
43
+ if (_path === void 0) {
44
+ _path = require("path");
45
+ }
46
+ return _path;
47
+ }
48
+ const NODE_JS_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs"]);
49
+ function detectExecutableType(filePath) {
50
+ if ((0, import_paths.isInSocketDlx)(filePath)) {
51
+ return detectDlxExecutableType(filePath);
52
+ }
53
+ return detectLocalExecutableType(filePath);
54
+ }
55
+ function detectDlxExecutableType(filePath) {
56
+ const fs = /* @__PURE__ */ getFs();
57
+ const path = /* @__PURE__ */ getPath();
58
+ const dlxDir = (0, import_socket.getSocketDlxDir)();
59
+ const absolutePath = path.resolve(filePath);
60
+ const relativePath = path.relative(dlxDir, absolutePath);
61
+ const cacheKey = relativePath.split(path.sep)[0];
62
+ const cacheDir = path.join(dlxDir, cacheKey);
63
+ if (fs.existsSync(path.join(cacheDir, "node_modules"))) {
64
+ return {
65
+ type: "package",
66
+ method: "dlx-cache",
67
+ inDlxCache: true
68
+ };
69
+ }
70
+ return {
71
+ type: "binary",
72
+ method: "dlx-cache",
73
+ inDlxCache: true
74
+ };
75
+ }
76
+ function detectLocalExecutableType(filePath) {
77
+ const fs = /* @__PURE__ */ getFs();
78
+ const packageJsonPath = findPackageJson(filePath);
79
+ if (packageJsonPath !== void 0) {
80
+ try {
81
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
82
+ if (packageJson.bin) {
83
+ return {
84
+ type: "package",
85
+ method: "package-json",
86
+ packageJsonPath,
87
+ inDlxCache: false
88
+ };
89
+ }
90
+ } catch {
91
+ }
92
+ }
93
+ if (isJsFilePath(filePath)) {
94
+ return {
95
+ inDlxCache: false,
96
+ method: "file-extension",
97
+ type: "package"
98
+ };
99
+ }
100
+ return {
101
+ type: "binary",
102
+ method: "file-extension",
103
+ inDlxCache: false
104
+ };
105
+ }
106
+ function findPackageJson(filePath) {
107
+ const fs = /* @__PURE__ */ getFs();
108
+ const path = /* @__PURE__ */ getPath();
109
+ let currentDir = path.dirname(path.resolve(filePath));
110
+ const root = path.parse(currentDir).root;
111
+ while (currentDir !== root) {
112
+ const packageJsonPath = path.join(currentDir, "package.json");
113
+ if (fs.existsSync(packageJsonPath)) {
114
+ return packageJsonPath;
115
+ }
116
+ currentDir = path.dirname(currentDir);
117
+ }
118
+ return void 0;
119
+ }
120
+ function isJsFilePath(filePath) {
121
+ const path = /* @__PURE__ */ getPath();
122
+ const ext = path.extname(filePath).toLowerCase();
123
+ return NODE_JS_EXTENSIONS.has(ext);
124
+ }
125
+ function isNativeBinary(filePath) {
126
+ return detectExecutableType(filePath).type === "binary";
127
+ }
128
+ function isNodePackage(filePath) {
129
+ return detectExecutableType(filePath).type === "package";
130
+ }
131
+ // Annotate the CommonJS export names for ESM import in node:
132
+ 0 && (module.exports = {
133
+ detectDlxExecutableType,
134
+ detectExecutableType,
135
+ detectLocalExecutableType,
136
+ isJsFilePath,
137
+ isNativeBinary,
138
+ isNodePackage
139
+ });
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
2
 
3
- // Re-export from inquirer-pack bundle for better deduplication.
4
- const { checkbox } = require('../inquirer-pack')
3
+ // Re-export from external-pack bundle for better deduplication.
4
+ const { checkbox } = require('../external-pack')
5
5
  module.exports = checkbox
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
2
 
3
- // Re-export from inquirer-pack bundle for better deduplication.
4
- const { confirm } = require('../inquirer-pack')
3
+ // Re-export from external-pack bundle for better deduplication.
4
+ const { confirm } = require('../external-pack')
5
5
  module.exports = confirm
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
2
 
3
- // Re-export from inquirer-pack bundle for better deduplication.
4
- const { input } = require('../inquirer-pack')
3
+ // Re-export from external-pack bundle for better deduplication.
4
+ const { input } = require('../external-pack')
5
5
  module.exports = input
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
2
 
3
- // Re-export from inquirer-pack bundle for better deduplication.
4
- const { password } = require('../inquirer-pack')
3
+ // Re-export from external-pack bundle for better deduplication.
4
+ const { password } = require('../external-pack')
5
5
  module.exports = password
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
2
 
3
- // Re-export from inquirer-pack bundle for better deduplication.
4
- const { search } = require('../inquirer-pack')
3
+ // Re-export from external-pack bundle for better deduplication.
4
+ const { search } = require('../external-pack')
5
5
  module.exports = search
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
2
 
3
- // Re-export from inquirer-pack bundle for better deduplication.
4
- const { select } = require('../inquirer-pack')
3
+ // Re-export from external-pack bundle for better deduplication.
4
+ const { select } = require('../external-pack')
5
5
  module.exports = select
@@ -714,9 +714,9 @@ var require_clean = __commonJS({
714
714
  }
715
715
  });
716
716
 
717
- // node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js
717
+ // node_modules/.pnpm/proc-log@6.1.0/node_modules/proc-log/lib/index.js
718
718
  var require_lib2 = __commonJS({
719
- "node_modules/.pnpm/proc-log@5.0.0/node_modules/proc-log/lib/index.js"(exports2, module2) {
719
+ "node_modules/.pnpm/proc-log@6.1.0/node_modules/proc-log/lib/index.js"(exports2, module2) {
720
720
  var META = Symbol("proc-log.meta");
721
721
  module2.exports = {
722
722
  META,
@@ -842,10 +842,14 @@ var require_lib2 = __commonJS({
842
842
  end: "end",
843
843
  read: "read"
844
844
  },
845
- start: /* @__PURE__ */ __name(function(fn) {
846
- process.emit("input", "start");
845
+ start: /* @__PURE__ */ __name(function(...args) {
846
+ let fn;
847
+ if (typeof args[0] === "function") {
848
+ fn = args.shift();
849
+ }
850
+ process.emit("input", "start", ...args);
847
851
  function end() {
848
- return process.emit("input", "end");
852
+ return process.emit("input", "end", ...args);
849
853
  }
850
854
  __name(end, "end");
851
855
  if (typeof fn === "function") {
@@ -858,8 +862,8 @@ var require_lib2 = __commonJS({
858
862
  }
859
863
  return end;
860
864
  }, "start"),
861
- end: /* @__PURE__ */ __name(function() {
862
- return process.emit("input", "end");
865
+ end: /* @__PURE__ */ __name(function(...args) {
866
+ return process.emit("input", "end", ...args);
863
867
  }, "end"),
864
868
  read: /* @__PURE__ */ __name(function(...args) {
865
869
  let resolve, reject;