@socketsecurity/lib 5.11.0 → 5.11.2

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,25 @@ 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.11.2](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.2) - 2026-03-24
9
+
10
+ ### Added
11
+
12
+ - **http-request**: Custom CA certificate support for TLS connections
13
+ - `httpRequest`, `httpJson`, `httpText` accept `ca` option for custom certificate authorities
14
+ - `httpDownload` accepts `ca` option, threaded through redirects and retries
15
+ - `fetchChecksums` accepts `ca` option, passed through to underlying request
16
+ - Enables SSL_CERT_FILE support when NODE_EXTRA_CA_CERTS is unavailable at process startup
17
+
18
+ ## [5.11.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.1) - 2026-03-24
19
+
20
+ ### Added
21
+
22
+ - **dlx/binary**: Added `sha256` option to `dlxBinary()`, `downloadBinary()`, and `downloadBinaryFile()`
23
+ - Enables SHA-256 checksum verification for binary downloads via httpDownload
24
+ - Verification happens during download (fails early if checksum mismatches)
25
+ - Complements existing `integrity` option (SRI sha512 format, verified post-download)
26
+
8
27
  ## [5.11.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.0) - 2026-03-23
9
28
 
10
29
  ### Added
package/dist/agent.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var agent_exports = {};
21
31
  __export(agent_exports, {
@@ -34,6 +44,7 @@ __export(agent_exports, {
34
44
  isPnpmLoglevelFlag: () => isPnpmLoglevelFlag
35
45
  });
36
46
  module.exports = __toCommonJS(agent_exports);
47
+ var import_node_process = __toESM(require("node:process"));
37
48
  var import_agents = require("./constants/agents");
38
49
  var import_node = require("./constants/node");
39
50
  var import_platform = require("./constants/platform");
@@ -230,7 +241,7 @@ function execScript(scriptName, args, options) {
230
241
  return (0, import_spawn.spawn)(scriptName, resolvedArgs, spawnOptions);
231
242
  }
232
243
  const useNodeRun = !prepost && (0, import_node.supportsNodeRun)();
233
- const cwd = (0, import_objects.getOwn)(spawnOptions, "cwd") ?? process.cwd();
244
+ const cwd = (0, import_objects.getOwn)(spawnOptions, "cwd") ?? import_node_process.default.cwd();
234
245
  const pnpmLockPath = (0, import_fs.findUpSync)(import_agents.PNPM_LOCK_YAML, { cwd });
235
246
  if (pnpmLockPath) {
236
247
  return execPnpm(["run", scriptName, ...resolvedArgs], spawnOptions);
package/dist/archives.js CHANGED
@@ -39,6 +39,7 @@ module.exports = __toCommonJS(archives_exports);
39
39
  var import_node_fs = require("node:fs");
40
40
  var import_promises = require("node:stream/promises");
41
41
  var import_node_zlib = require("node:zlib");
42
+ var import_node_process = __toESM(require("node:process"));
42
43
  var import_adm_zip = __toESM(require("./external/adm-zip.js"));
43
44
  var import_tar_fs = __toESM(require("./external/tar-fs.js"));
44
45
  var import_fs = require("./fs.js");
@@ -96,7 +97,7 @@ async function extractTar(archivePath, outputDir, options = {}) {
96
97
  }
97
98
  if (header.type === "symlink" || header.type === "link") {
98
99
  destroyScheduled = true;
99
- process.nextTick(() => {
100
+ import_node_process.default.nextTick(() => {
100
101
  extractStream.destroy(
101
102
  new Error(
102
103
  `Symlink detected in archive: ${header.name}. Symlinks are not supported for security reasons.`
@@ -107,7 +108,7 @@ async function extractTar(archivePath, outputDir, options = {}) {
107
108
  }
108
109
  if (header.size && header.size > maxFileSize) {
109
110
  destroyScheduled = true;
110
- process.nextTick(() => {
111
+ import_node_process.default.nextTick(() => {
111
112
  extractStream.destroy(
112
113
  new Error(
113
114
  `File size exceeds limit: ${header.name} (${header.size} bytes > ${maxFileSize} bytes)`
@@ -120,7 +121,7 @@ async function extractTar(archivePath, outputDir, options = {}) {
120
121
  totalExtractedSize += header.size;
121
122
  if (totalExtractedSize > maxTotalSize) {
122
123
  destroyScheduled = true;
123
- process.nextTick(() => {
124
+ import_node_process.default.nextTick(() => {
124
125
  extractStream.destroy(
125
126
  new Error(
126
127
  `Total extracted size exceeds limit: ${totalExtractedSize} bytes > ${maxTotalSize} bytes`
@@ -161,7 +162,7 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
161
162
  }
162
163
  if (header.type === "symlink" || header.type === "link") {
163
164
  destroyScheduled = true;
164
- process.nextTick(() => {
165
+ import_node_process.default.nextTick(() => {
165
166
  extractStream.destroy(
166
167
  new Error(
167
168
  `Symlink detected in archive: ${header.name}. Symlinks are not supported for security reasons.`
@@ -172,7 +173,7 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
172
173
  }
173
174
  if (header.size && header.size > maxFileSize) {
174
175
  destroyScheduled = true;
175
- process.nextTick(() => {
176
+ import_node_process.default.nextTick(() => {
176
177
  extractStream.destroy(
177
178
  new Error(
178
179
  `File size exceeds limit: ${header.name} (${header.size} bytes > ${maxFileSize} bytes)`
@@ -185,7 +186,7 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
185
186
  totalExtractedSize += header.size;
186
187
  if (totalExtractedSize > maxTotalSize) {
187
188
  destroyScheduled = true;
188
- process.nextTick(() => {
189
+ import_node_process.default.nextTick(() => {
189
190
  extractStream.destroy(
190
191
  new Error(
191
192
  `Total extracted size exceeds limit: ${totalExtractedSize} bytes > ${maxTotalSize} bytes`
@@ -1,10 +1,3 @@
1
- /**
2
- * Common flag utilities for Socket CLI applications.
3
- * Provides consistent flag checking across all Socket projects.
4
- */
5
- /**
6
- * Flag values object from parsed arguments.
7
- */
8
1
  export interface FlagValues {
9
2
  [key: string]: unknown;
10
3
  quiet?: boolean;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var flags_exports = {};
21
31
  __export(flags_exports, {
@@ -37,7 +47,8 @@ __export(flags_exports, {
37
47
  isWatch: () => isWatch
38
48
  });
39
49
  module.exports = __toCommonJS(flags_exports);
40
- const processArg = [...process.argv];
50
+ var import_node_process = __toESM(require("node:process"));
51
+ const processArg = [...import_node_process.default.argv];
41
52
  function getLogLevel(input) {
42
53
  if (isQuiet(input)) {
43
54
  return "silent";
@@ -36,12 +36,13 @@ __export(parse_exports, {
36
36
  parseArgsWithDefaults: () => parseArgsWithDefaults
37
37
  });
38
38
  module.exports = __toCommonJS(parse_exports);
39
+ var import_node_process = __toESM(require("node:process"));
39
40
  var import_yargs_parser = __toESM(require("../external/yargs-parser"));
40
41
  function parseArgs(config = {}) {
41
42
  const {
42
43
  allowNegative = false,
43
44
  allowPositionals = true,
44
- args = process.argv.slice(2),
45
+ args = import_node_process.default.argv.slice(2),
45
46
  configuration,
46
47
  options = {},
47
48
  strict = true
@@ -142,7 +143,7 @@ const commonParseArgsConfig = {
142
143
  strict: false
143
144
  };
144
145
  function getPositionalArgs(startIndex = 2) {
145
- const args = process.argv.slice(startIndex);
146
+ const args = import_node_process.default.argv.slice(startIndex);
146
147
  const positionals = [];
147
148
  let i = 0;
148
149
  while (i < args.length) {
@@ -155,7 +156,7 @@ function getPositionalArgs(startIndex = 2) {
155
156
  }
156
157
  return positionals;
157
158
  }
158
- function hasFlag(flag, argv = process.argv) {
159
+ function hasFlag(flag, argv = import_node_process.default.argv) {
159
160
  const flagVariants = [
160
161
  `--${flag}`,
161
162
  // Short flag.
package/dist/bin.js CHANGED
@@ -42,6 +42,7 @@ __export(bin_exports, {
42
42
  whichSync: () => whichSync
43
43
  });
44
44
  module.exports = __toCommonJS(bin_exports);
45
+ var import_node_process = __toESM(require("node:process"));
45
46
  var import_home = require("./env/home");
46
47
  var import_windows = require("./env/windows");
47
48
  var import_xdg = require("./env/xdg");
@@ -135,7 +136,7 @@ function findRealBin(binName, commonPaths = []) {
135
136
  function findRealNpm() {
136
137
  const fs = /* @__PURE__ */ getFs();
137
138
  const path = /* @__PURE__ */ getPath();
138
- const nodeDir = path.dirname(process.execPath);
139
+ const nodeDir = path.dirname(import_node_process.default.execPath);
139
140
  const npmInNodeDir = path.join(nodeDir, "npm");
140
141
  if (fs.existsSync(npmInNodeDir)) {
141
142
  return npmInNodeDir;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var node_exports = {};
21
31
  __export(node_exports, {
@@ -41,8 +51,9 @@ __export(node_exports, {
41
51
  supportsProcessSend: () => supportsProcessSend
42
52
  });
43
53
  module.exports = __toCommonJS(node_exports);
54
+ var import_node_process = __toESM(require("node:process"));
44
55
  var import_maintained_node_versions = require("./maintained-node-versions");
45
- const NODE_VERSION = process.version;
56
+ const NODE_VERSION = import_node_process.default.version;
46
57
  function getNodeVersion() {
47
58
  return NODE_VERSION;
48
59
  }
@@ -105,7 +116,7 @@ function getNodeDisableSigusr1Flags() {
105
116
  return _nodeDisableSigusr1Flags;
106
117
  }
107
118
  function supportsProcessSend() {
108
- return typeof process.send === "function";
119
+ return typeof import_node_process.default.send === "function";
109
120
  }
110
121
  let _nodeHardenFlags;
111
122
  let _nodePermissionFlags;
@@ -152,7 +163,7 @@ function getNodeNoWarningsFlags() {
152
163
  return _nodeNoWarningsFlags;
153
164
  }
154
165
  function getExecPath() {
155
- return process.execPath;
166
+ return import_node_process.default.execPath;
156
167
  }
157
168
  const NODE_SEA_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
158
169
  const ESNEXT = "esnext";
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,12 +18,21 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var code_exports = {};
21
31
  __export(code_exports, {
22
32
  getCodeCoverage: () => getCodeCoverage
23
33
  });
24
34
  module.exports = __toCommonJS(code_exports);
35
+ var import_node_process = __toESM(require("node:process"));
25
36
  var import_fs = require("../fs");
26
37
  var import_objects = require("../objects");
27
38
  var import_spawn = require("../spawn");
@@ -45,7 +56,7 @@ async function getCodeCoverage(options) {
45
56
  const path = /* @__PURE__ */ getPath();
46
57
  const opts = {
47
58
  __proto__: null,
48
- coveragePath: path.join(process.cwd(), "coverage/coverage-final.json"),
59
+ coveragePath: path.join(import_node_process.default.cwd(), "coverage/coverage-final.json"),
49
60
  generateIfMissing: false,
50
61
  ...options
51
62
  };
@@ -58,7 +69,7 @@ async function getCodeCoverage(options) {
58
69
  if (!coverageExists) {
59
70
  if (generateIfMissing) {
60
71
  await (0, import_spawn.spawn)("vitest", ["run", "--coverage"], {
61
- cwd: process.cwd(),
72
+ cwd: import_node_process.default.cwd(),
62
73
  stdio: "inherit"
63
74
  });
64
75
  } else {
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,17 +18,26 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var type_exports = {};
21
31
  __export(type_exports, {
22
32
  getTypeCoverage: () => getTypeCoverage
23
33
  });
24
34
  module.exports = __toCommonJS(type_exports);
35
+ var import_node_process = __toESM(require("node:process"));
25
36
  var import_spawn = require("../spawn");
26
37
  async function getTypeCoverage(options) {
27
38
  const opts = {
28
39
  __proto__: null,
29
- cwd: process.cwd(),
40
+ cwd: import_node_process.default.cwd(),
30
41
  generateIfMissing: false,
31
42
  ...options
32
43
  };
@@ -13,6 +13,12 @@ export interface DlxBinaryOptions {
13
13
  * Expected SRI integrity hash (sha512-<base64>) for verification.
14
14
  */
15
15
  integrity?: string | undefined;
16
+ /**
17
+ * Expected SHA-256 hex checksum for verification.
18
+ * Passed to httpDownload for inline verification during download.
19
+ * This is more secure than post-download verification as it fails early.
20
+ */
21
+ sha256?: string | undefined;
16
22
  /**
17
23
  * Cache TTL in milliseconds (default: 7 days).
18
24
  */
@@ -127,8 +133,14 @@ export declare function downloadBinary(options: Omit<DlxBinaryOptions, 'spawnOpt
127
133
  * Download a file from a URL with integrity checking and concurrent download protection.
128
134
  * Uses processLock to prevent multiple processes from downloading the same binary simultaneously.
129
135
  * Internal helper function for downloading binary files.
136
+ *
137
+ * Supports two integrity verification methods:
138
+ * - sha256: Hex SHA-256 checksum (verified inline during download via httpDownload)
139
+ * - integrity: SRI format sha512-<base64> (verified post-download)
140
+ *
141
+ * The sha256 option is preferred as it fails early during download if the checksum doesn't match.
130
142
  */
131
- export declare function downloadBinaryFile(url: string, destPath: string, integrity?: string | undefined): Promise<string>;
143
+ export declare function downloadBinaryFile(url: string, destPath: string, integrity?: string | undefined, sha256?: string | undefined): Promise<string>;
132
144
  /**
133
145
  * Execute a cached binary without re-downloading.
134
146
  * Similar to executePackage from dlx-package.
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var binary_exports = {};
21
31
  __export(binary_exports, {
@@ -31,6 +41,7 @@ __export(binary_exports, {
31
41
  writeBinaryCacheMetadata: () => writeBinaryCacheMetadata
32
42
  });
33
43
  module.exports = __toCommonJS(binary_exports);
44
+ var import_node_process = __toESM(require("node:process"));
34
45
  var import_platform = require("../constants/platform");
35
46
  var import_time = require("../constants/time");
36
47
  var import_cache = require("./cache");
@@ -111,6 +122,7 @@ async function dlxBinary(args, options, spawnExtra) {
111
122
  force: userForce = false,
112
123
  integrity,
113
124
  name,
125
+ sha256,
114
126
  spawnOptions,
115
127
  url,
116
128
  yes
@@ -119,7 +131,7 @@ async function dlxBinary(args, options, spawnExtra) {
119
131
  const path = /* @__PURE__ */ getPath();
120
132
  const force = yes === true ? true : userForce;
121
133
  const cacheDir = getDlxCachePath();
122
- const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
134
+ const binaryName = name || `binary-${import_node_process.default.platform}-${(0, import_platform.getArch)()}`;
123
135
  const spec = `${url}:${binaryName}`;
124
136
  const cacheKey = (0, import_cache.generateCacheKey)(spec);
125
137
  const cacheEntryDir = path.join(cacheDir, cacheKey);
@@ -168,7 +180,12 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
168
180
  { cause: e }
169
181
  );
170
182
  }
171
- computedIntegrity = await downloadBinaryFile(url, binaryPath, integrity);
183
+ computedIntegrity = await downloadBinaryFile(
184
+ url,
185
+ binaryPath,
186
+ integrity,
187
+ sha256
188
+ );
172
189
  const stats = await fs.promises.stat(binaryPath);
173
190
  await writeBinaryCacheMetadata(
174
191
  cacheEntryDir,
@@ -183,7 +200,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
183
200
  ...spawnOptions,
184
201
  env: {
185
202
  ...spawnOptions?.env,
186
- PATH: `${cacheEntryDir}${(/* @__PURE__ */ getPath()).delimiter}${process.env["PATH"] || ""}`
203
+ PATH: `${cacheEntryDir}${(/* @__PURE__ */ getPath()).delimiter}${import_node_process.default.env["PATH"] || ""}`
187
204
  },
188
205
  shell: true
189
206
  } : spawnOptions;
@@ -200,12 +217,13 @@ async function downloadBinary(options) {
200
217
  force = false,
201
218
  integrity,
202
219
  name,
220
+ sha256,
203
221
  url
204
222
  } = { __proto__: null, ...options };
205
223
  const fs = /* @__PURE__ */ getFs();
206
224
  const path = /* @__PURE__ */ getPath();
207
225
  const cacheDir = getDlxCachePath();
208
- const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
226
+ const binaryName = name || `binary-${import_node_process.default.platform}-${(0, import_platform.getArch)()}`;
209
227
  const spec = `${url}:${binaryName}`;
210
228
  const cacheKey = (0, import_cache.generateCacheKey)(spec);
211
229
  const cacheEntryDir = path.join(cacheDir, cacheKey);
@@ -240,7 +258,8 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
240
258
  const computedIntegrity = await downloadBinaryFile(
241
259
  url,
242
260
  binaryPath,
243
- integrity
261
+ integrity,
262
+ sha256
244
263
  );
245
264
  const stats = await fs.promises.stat(binaryPath);
246
265
  await writeBinaryCacheMetadata(
@@ -257,7 +276,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
257
276
  downloaded
258
277
  };
259
278
  }
260
- async function downloadBinaryFile(url, destPath, integrity) {
279
+ async function downloadBinaryFile(url, destPath, integrity, sha256) {
261
280
  const crypto = /* @__PURE__ */ getCrypto();
262
281
  const fs = /* @__PURE__ */ getFs();
263
282
  const path = /* @__PURE__ */ getPath();
@@ -275,7 +294,7 @@ async function downloadBinaryFile(url, destPath, integrity) {
275
294
  }
276
295
  }
277
296
  try {
278
- await (0, import_http_request.httpDownload)(url, destPath);
297
+ await (0, import_http_request.httpDownload)(url, destPath, sha256 ? { sha256 } : void 0);
279
298
  } catch (e) {
280
299
  throw new Error(
281
300
  `Failed to download binary from ${url}
@@ -313,7 +332,7 @@ function executeBinary(binaryPath, args, spawnOptions, spawnExtra) {
313
332
  ...spawnOptions,
314
333
  env: {
315
334
  ...spawnOptions?.env,
316
- PATH: `${cacheEntryDir}${path.delimiter}${process.env["PATH"] || ""}`
335
+ PATH: `${cacheEntryDir}${path.delimiter}${import_node_process.default.env["PATH"] || ""}`
317
336
  },
318
337
  shell: true
319
338
  } : spawnOptions;
@@ -406,7 +425,7 @@ async function writeBinaryCacheMetadata(cacheEntryPath, cacheKey, url, integrity
406
425
  }
407
426
  };
408
427
  const fs = /* @__PURE__ */ getFs();
409
- const tmpPath = `${metaPath}.tmp.${process.pid}`;
428
+ const tmpPath = `${metaPath}.tmp.${import_node_process.default.pid}`;
410
429
  await fs.promises.writeFile(tmpPath, JSON.stringify(metadata, null, 2));
411
430
  await fs.promises.rename(tmpPath, metaPath);
412
431
  }
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var package_manager_exports = {};
21
31
  __export(package_manager_exports, {
@@ -24,6 +34,7 @@ __export(package_manager_exports, {
24
34
  getPackageManagerUserAgent: () => getPackageManagerUserAgent
25
35
  });
26
36
  module.exports = __toCommonJS(package_manager_exports);
37
+ var import_node_process = __toESM(require("node:process"));
27
38
  var import_rewire = require("./rewire");
28
39
  // @__NO_SIDE_EFFECTS__
29
40
  function detectPackageManager() {
@@ -34,7 +45,7 @@ function detectPackageManager() {
34
45
  return match[1];
35
46
  }
36
47
  }
37
- const argv0 = process.argv[0];
48
+ const argv0 = import_node_process.default.argv[0];
38
49
  if (argv0) {
39
50
  if (argv0.includes("/pnpm/") || argv0.includes("\\pnpm\\")) {
40
51
  return "pnpm";
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var rewire_exports = {};
21
31
  __export(rewire_exports, {
@@ -29,6 +39,7 @@ __export(rewire_exports, {
29
39
  withEnvSync: () => withEnvSync
30
40
  });
31
41
  module.exports = __toCommonJS(rewire_exports);
42
+ var import_node_process = __toESM(require("node:process"));
32
43
  var import_objects = require("../objects");
33
44
  var import_helpers = require("./helpers");
34
45
  let _async_hooks;
@@ -44,7 +55,7 @@ const isolatedOverridesStorage = new AsyncLocalStorage();
44
55
  const sharedOverridesSymbol = Symbol.for(
45
56
  "@socketsecurity/lib/env/rewire/test-overrides"
46
57
  );
47
- const isVitestEnv = (0, import_helpers.envAsBoolean)(process.env.VITEST);
58
+ const isVitestEnv = (0, import_helpers.envAsBoolean)(import_node_process.default.env.VITEST);
48
59
  if (isVitestEnv && !globalThis[sharedOverridesSymbol]) {
49
60
  globalThis[sharedOverridesSymbol] = /* @__PURE__ */ new Map();
50
61
  }
@@ -60,7 +71,7 @@ function getEnvValue(key) {
60
71
  if (sharedOverrides?.has(key)) {
61
72
  return sharedOverrides.get(key);
62
73
  }
63
- return process.env[key];
74
+ return import_node_process.default.env[key];
64
75
  }
65
76
  function hasOverride(key) {
66
77
  const isolatedOverrides = isolatedOverridesStorage.getStore();
@@ -74,7 +85,7 @@ function isInEnv(key) {
74
85
  if (sharedOverrides?.has(key)) {
75
86
  return true;
76
87
  }
77
- return (0, import_objects.hasOwn)(process.env, key);
88
+ return (0, import_objects.hasOwn)(import_node_process.default.env, key);
78
89
  }
79
90
  function resetEnv() {
80
91
  sharedOverrides?.clear();
package/dist/fs.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * @fileoverview File system utilities with cross-platform path handling.
3
- * Provides enhanced fs operations, glob matching, and directory traversal functions.
4
- */
5
1
  import type { Abortable } from 'events';
6
2
  import type { MakeDirectoryOptions, ObjectEncodingOptions, OpenMode, PathLike } from 'fs';
7
3
  import type { JsonReviver } from './json/types';