@socketsecurity/lib 5.24.0 → 5.25.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 (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/archives.js +4 -4
  3. package/dist/constants/socket.js +1 -1
  4. package/dist/debug.js +5 -5
  5. package/dist/dlx/manifest.js +18 -20
  6. package/dist/errors.js +2 -3
  7. package/dist/external/@npmcli/package-json/lib/read-package.js +3 -2
  8. package/dist/external/@npmcli/package-json.js +19 -18
  9. package/dist/external/@npmcli/promise-spawn.js +3 -2
  10. package/dist/external/adm-zip.js +3 -2
  11. package/dist/external/debug.js +2 -1
  12. package/dist/external/external-pack.js +4 -3
  13. package/dist/external/fast-sort.js +2 -1
  14. package/dist/external/get-east-asian-width.js +3 -2
  15. package/dist/external/npm-pack.js +36 -35
  16. package/dist/external/p-map.js +6 -5
  17. package/dist/external/pico-pack.js +24 -23
  18. package/dist/external/supports-color.js +3 -1
  19. package/dist/external/tar-fs.js +9 -8
  20. package/dist/external/which.js +3 -2
  21. package/dist/external/yargs-parser.js +3 -2
  22. package/dist/fs.js +5 -4
  23. package/dist/git.js +3 -3
  24. package/dist/github.d.ts +3 -3
  25. package/dist/github.js +3 -3
  26. package/dist/http-request.d.ts +2 -2
  27. package/dist/json/edit.js +9 -9
  28. package/dist/json/parse.d.ts +2 -2
  29. package/dist/json/parse.js +2 -2
  30. package/dist/logger.js +5 -6
  31. package/dist/objects.js +28 -39
  32. package/dist/packages/edit.js +3 -3
  33. package/dist/packages/isolation.js +3 -3
  34. package/dist/primordials.d.ts +337 -0
  35. package/dist/primordials.js +828 -0
  36. package/dist/process-lock.js +11 -11
  37. package/dist/releases/github.js +4 -4
  38. package/dist/signal-exit.js +4 -4
  39. package/dist/spawn.d.ts +13 -13
  40. package/dist/stdio/stderr.d.ts +2 -2
  41. package/dist/suppress-warnings.js +2 -2
  42. package/package.json +12 -4
@@ -87,8 +87,8 @@ class ProcessLockManager {
87
87
  const now = Date.now() / 1e3;
88
88
  fs.utimesSync(lockPath, now, now);
89
89
  }
90
- } catch (error) {
91
- logger.warn(`Failed to touch lock ${lockPath}: ${(0, import_errors.errorMessage)(error)}`);
90
+ } catch (e) {
91
+ logger.warn(`Failed to touch lock ${lockPath}: ${(0, import_errors.errorMessage)(e)}`);
92
92
  }
93
93
  }
94
94
  /**
@@ -191,8 +191,8 @@ class ProcessLockManager {
191
191
  this.activeLocks.add(lockPath);
192
192
  this.startTouchTimer(lockPath, touchIntervalMs);
193
193
  return () => this.release(lockPath);
194
- } catch (error) {
195
- const code = error.code;
194
+ } catch (e) {
195
+ const code = e.code;
196
196
  if (code === "EEXIST") {
197
197
  if (this.isStale(lockPath, staleMs)) {
198
198
  throw new Error(`Stale lock detected: ${lockPath}`);
@@ -202,13 +202,13 @@ class ProcessLockManager {
202
202
  if (code === "EACCES" || code === "EPERM") {
203
203
  throw new Error(
204
204
  `Permission denied creating lock: ${lockPath}. Check directory permissions or run with appropriate access.`,
205
- { cause: error }
205
+ { cause: e }
206
206
  );
207
207
  }
208
208
  if (code === "EROFS") {
209
209
  throw new Error(
210
210
  `Cannot create lock on read-only filesystem: ${lockPath}`,
211
- { cause: error }
211
+ { cause: e }
212
212
  );
213
213
  }
214
214
  if (code === "ENOTDIR") {
@@ -225,7 +225,7 @@ To resolve:
225
225
  1. Check if "${parentDir}" contains a file instead of a directory
226
226
  2. Remove any conflicting files in the path
227
227
  3. Ensure the full parent directory structure exists`,
228
- { cause: error }
228
+ { cause: e }
229
229
  );
230
230
  }
231
231
  if (code === "ENOENT") {
@@ -241,11 +241,11 @@ To resolve:
241
241
  1. Ensure the parent directory "${parentDir}" exists
242
242
  2. Create the directory structure: mkdir -p "${parentDir}"
243
243
  3. Check filesystem permissions allow directory creation`,
244
- { cause: error }
244
+ { cause: e }
245
245
  );
246
246
  }
247
247
  throw new Error(`Failed to acquire lock: ${lockPath}`, {
248
- cause: error
248
+ cause: e
249
249
  });
250
250
  }
251
251
  },
@@ -275,8 +275,8 @@ To resolve:
275
275
  (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
276
276
  }
277
277
  this.activeLocks.delete(lockPath);
278
- } catch (error) {
279
- logger.warn(`Failed to release lock ${lockPath}: ${(0, import_errors.errorMessage)(error)}`);
278
+ } catch (e) {
279
+ logger.warn(`Failed to release lock ${lockPath}: ${(0, import_errors.errorMessage)(e)}`);
280
280
  }
281
281
  }
282
282
  /**
@@ -124,9 +124,9 @@ async function downloadAndExtractArchive(tag, assetPattern, outputDir, repoConfi
124
124
  if (!quiet) {
125
125
  logger.info("Cleaned up temporary archive file");
126
126
  }
127
- } catch (error) {
127
+ } catch (e) {
128
128
  if (!quiet) {
129
- logger.warn(`Failed to cleanup archive file: ${error}`);
129
+ logger.warn(`Failed to cleanup archive file: ${e}`);
130
130
  }
131
131
  }
132
132
  }
@@ -160,9 +160,9 @@ async function downloadAndExtractZip(tag, assetPattern, outputDir, repoConfig, o
160
160
  if (!quiet) {
161
161
  logger.info("Cleaned up temporary zip file");
162
162
  }
163
- } catch (error) {
163
+ } catch (e) {
164
164
  if (!quiet) {
165
- logger.warn(`Failed to cleanup zip file: ${error}`);
165
+ logger.warn(`Failed to cleanup zip file: ${e}`);
166
166
  }
167
167
  }
168
168
  }
@@ -26,7 +26,7 @@ __export(signal_exit_exports, {
26
26
  unload: () => unload
27
27
  });
28
28
  module.exports = __toCommonJS(signal_exit_exports);
29
- const ReflectApply = Reflect.apply;
29
+ var import_primordials = require("./primordials");
30
30
  const globalProcess = globalThis.process;
31
31
  const originalProcessEmit = globalProcess?.emit;
32
32
  const platform = globalProcess?.platform ?? "";
@@ -104,7 +104,7 @@ function processEmit(eventName, exitCode, ...args) {
104
104
  } else if (globalProcess) {
105
105
  globalProcess.exitCode = actualExitCode;
106
106
  }
107
- const result = ReflectApply(
107
+ const result = (0, import_primordials.ReflectApply)(
108
108
  originalProcessEmit,
109
109
  this,
110
110
  [eventName, actualExitCode, ...args]
@@ -114,7 +114,7 @@ function processEmit(eventName, exitCode, ...args) {
114
114
  /* @__PURE__ */ emit("afterexit", numExitCode, null);
115
115
  return result;
116
116
  }
117
- return ReflectApply(
117
+ return (0, import_primordials.ReflectApply)(
118
118
  originalProcessEmit,
119
119
  this,
120
120
  [eventName, exitCode, ...args]
@@ -128,7 +128,7 @@ function processReallyExit(code) {
128
128
  }
129
129
  /* @__PURE__ */ emit("exit", exitCode, null);
130
130
  /* @__PURE__ */ emit("afterexit", exitCode, null);
131
- ReflectApply(
131
+ (0, import_primordials.ReflectApply)(
132
132
  originalProcessReallyExit,
133
133
  globalProcess,
134
134
  [exitCode]
package/dist/spawn.d.ts CHANGED
@@ -97,10 +97,10 @@ export type PromiseSpawnResult = Promise<{
97
97
  * @example
98
98
  * try {
99
99
  * await spawn('exit', ['1'])
100
- * } catch (error) {
101
- * if (isSpawnError(error)) {
102
- * console.error(`Command failed with code ${error.code}`)
103
- * console.error(`stderr: ${error.stderr}`)
100
+ * } catch (e) {
101
+ * if (isSpawnError(e)) {
102
+ * console.error(`Command failed with code ${e.code}`)
103
+ * console.error(`stderr: ${e.stderr}`)
104
104
  * }
105
105
  * }
106
106
  */
@@ -302,8 +302,8 @@ export type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>;
302
302
  * ```typescript
303
303
  * try {
304
304
  * await spawn('git', ['status'])
305
- * } catch (err) {
306
- * throw enhanceSpawnError(err)
305
+ * } catch (e) {
306
+ * throw enhanceSpawnError(e)
307
307
  * }
308
308
  * ```
309
309
  */
@@ -318,9 +318,9 @@ export declare function enhanceSpawnError(error: unknown): unknown;
318
318
  * @example
319
319
  * try {
320
320
  * await spawn('nonexistent-command')
321
- * } catch (error) {
322
- * if (isSpawnError(error)) {
323
- * console.error(`Spawn failed: ${error.code}`)
321
+ * } catch (e) {
322
+ * if (isSpawnError(e)) {
323
+ * console.error(`Spawn failed: ${e.code}`)
324
324
  * }
325
325
  * }
326
326
  */
@@ -401,10 +401,10 @@ export declare function isStdioType(stdio: string | string[], type?: StdioType |
401
401
  * // Handle errors with exit codes
402
402
  * try {
403
403
  * await spawn('exit', ['1'])
404
- * } catch (error) {
405
- * if (isSpawnError(error)) {
406
- * console.error(`Failed with code ${error.code}`)
407
- * console.error(error.stderr)
404
+ * } catch (e) {
405
+ * if (isSpawnError(e)) {
406
+ * console.error(`Failed with code ${e.code}`)
407
+ * console.error(e.stderr)
408
408
  * }
409
409
  * }
410
410
  */
@@ -124,8 +124,8 @@ export declare function writeErrorLine(text?: string): void;
124
124
  * ```ts
125
125
  * try {
126
126
  * throw new Error('Something went wrong')
127
- * } catch (err) {
128
- * writeStackTrace(err as Error)
127
+ * } catch (e) {
128
+ * writeStackTrace(e as Error)
129
129
  * }
130
130
  * ```
131
131
  */
@@ -38,7 +38,7 @@ __export(suppress_warnings_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(suppress_warnings_exports);
40
40
  var import_node_process = __toESM(require("node:process"));
41
- const { apply: ReflectApply } = Reflect;
41
+ var import_primordials = require("./primordials");
42
42
  let originalEmitWarning;
43
43
  const suppressedWarnings = /* @__PURE__ */ new Set();
44
44
  function setupSuppression() {
@@ -57,7 +57,7 @@ function setupSuppression() {
57
57
  return;
58
58
  }
59
59
  }
60
- return ReflectApply(
60
+ return (0, import_primordials.ReflectApply)(
61
61
  originalEmitWarning,
62
62
  import_node_process.default,
63
63
  [warning, ...args]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "5.24.0",
3
+ "version": "5.25.0",
4
4
  "packageManager": "pnpm@11.0.0-rc.5",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",
@@ -519,6 +519,10 @@
519
519
  "types": "./dist/performance.d.ts",
520
520
  "default": "./dist/performance.js"
521
521
  },
522
+ "./primordials": {
523
+ "types": "./dist/primordials.d.ts",
524
+ "default": "./dist/primordials.js"
525
+ },
522
526
  "./process-lock": {
523
527
  "types": "./dist/process-lock.d.ts",
524
528
  "default": "./dist/process-lock.js"
@@ -675,7 +679,8 @@
675
679
  "./package.json": "./package.json",
676
680
  "./tsconfig.dts.json": "./tsconfig.dts.json",
677
681
  "./tsconfig.json": "./tsconfig.json",
678
- "./tsconfig.test.json": "./tsconfig.test.json"
682
+ "./tsconfig.test.json": "./tsconfig.test.json",
683
+ "./xport.schema.json": "./xport.schema.json"
679
684
  },
680
685
  "files": [
681
686
  "dist",
@@ -690,13 +695,15 @@
690
695
  "scripts": {
691
696
  "build": "node scripts/build/main.mts",
692
697
  "check": "node scripts/check.mts",
698
+ "check:paths": "node scripts/check-paths.mts",
693
699
  "clean": "node scripts/build/clean.mts",
694
700
  "cover": "node scripts/test/cover.mts",
695
701
  "dev": "node scripts/build/main.mts --watch",
696
702
  "fix": "node scripts/fix.mts",
697
703
  "lint": "node scripts/lint.mts",
704
+ "prim": "node tools/prim/bin/prim.mts",
698
705
  "security": "agentshield scan && { command -v zizmor >/dev/null && zizmor .github/ || echo 'zizmor not installed — run pnpm run setup to install'; }",
699
- "prepare": "husky",
706
+ "prepare": "husky && node scripts/build/main.mts --quiet",
700
707
  "prepublishOnly": "pnpm run build",
701
708
  "test": "node scripts/test/main.mts",
702
709
  "update": "node scripts/update.mts"
@@ -720,7 +727,7 @@
720
727
  "@socketregistry/is-unicode-supported": "1.0.5",
721
728
  "@socketregistry/packageurl-js": "1.4.2",
722
729
  "@socketregistry/yocto-spinner": "1.0.25",
723
- "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.23.0",
730
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.24.0",
724
731
  "@types/node": "24.9.2",
725
732
  "@typescript/native-preview": "7.0.0-dev.20260415.1",
726
733
  "@vitest/coverage-v8": "4.0.3",
@@ -752,6 +759,7 @@
752
759
  "pacote": "21.5.0",
753
760
  "picomatch": "4.0.4",
754
761
  "pony-cause": "2.1.11",
762
+ "prim": "workspace:*",
755
763
  "semver": "7.7.2",
756
764
  "signal-exit": "4.1.0",
757
765
  "spdx-correct": "3.2.0",