@socketsecurity/lib 5.23.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 (44) hide show
  1. package/CHANGELOG.md +18 -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 +4125 -165
  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 +6965 -4075
  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 -8
  43. package/dist/env/socket-cli-shadow.d.ts +0 -77
  44. package/dist/env/socket-cli-shadow.js +0 -59
@@ -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.23.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",
@@ -351,10 +351,6 @@
351
351
  "types": "./dist/env/socket-cli.d.ts",
352
352
  "default": "./dist/env/socket-cli.js"
353
353
  },
354
- "./env/socket-cli-shadow": {
355
- "types": "./dist/env/socket-cli-shadow.d.ts",
356
- "default": "./dist/env/socket-cli-shadow.js"
357
- },
358
354
  "./env/temp-dir": {
359
355
  "types": "./dist/env/temp-dir.d.ts",
360
356
  "default": "./dist/env/temp-dir.js"
@@ -523,6 +519,10 @@
523
519
  "types": "./dist/performance.d.ts",
524
520
  "default": "./dist/performance.js"
525
521
  },
522
+ "./primordials": {
523
+ "types": "./dist/primordials.d.ts",
524
+ "default": "./dist/primordials.js"
525
+ },
526
526
  "./process-lock": {
527
527
  "types": "./dist/process-lock.d.ts",
528
528
  "default": "./dist/process-lock.js"
@@ -679,7 +679,8 @@
679
679
  "./package.json": "./package.json",
680
680
  "./tsconfig.dts.json": "./tsconfig.dts.json",
681
681
  "./tsconfig.json": "./tsconfig.json",
682
- "./tsconfig.test.json": "./tsconfig.test.json"
682
+ "./tsconfig.test.json": "./tsconfig.test.json",
683
+ "./xport.schema.json": "./xport.schema.json"
683
684
  },
684
685
  "files": [
685
686
  "dist",
@@ -694,13 +695,15 @@
694
695
  "scripts": {
695
696
  "build": "node scripts/build/main.mts",
696
697
  "check": "node scripts/check.mts",
698
+ "check:paths": "node scripts/check-paths.mts",
697
699
  "clean": "node scripts/build/clean.mts",
698
700
  "cover": "node scripts/test/cover.mts",
699
701
  "dev": "node scripts/build/main.mts --watch",
700
702
  "fix": "node scripts/fix.mts",
701
703
  "lint": "node scripts/lint.mts",
704
+ "prim": "node tools/prim/bin/prim.mts",
702
705
  "security": "agentshield scan && { command -v zizmor >/dev/null && zizmor .github/ || echo 'zizmor not installed — run pnpm run setup to install'; }",
703
- "prepare": "husky",
706
+ "prepare": "husky && node scripts/build/main.mts --quiet",
704
707
  "prepublishOnly": "pnpm run build",
705
708
  "test": "node scripts/test/main.mts",
706
709
  "update": "node scripts/update.mts"
@@ -724,7 +727,7 @@
724
727
  "@socketregistry/is-unicode-supported": "1.0.5",
725
728
  "@socketregistry/packageurl-js": "1.4.2",
726
729
  "@socketregistry/yocto-spinner": "1.0.25",
727
- "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.21.0",
730
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.24.0",
728
731
  "@types/node": "24.9.2",
729
732
  "@typescript/native-preview": "7.0.0-dev.20260415.1",
730
733
  "@vitest/coverage-v8": "4.0.3",
@@ -756,6 +759,7 @@
756
759
  "pacote": "21.5.0",
757
760
  "picomatch": "4.0.4",
758
761
  "pony-cause": "2.1.11",
762
+ "prim": "workspace:*",
759
763
  "semver": "7.7.2",
760
764
  "signal-exit": "4.1.0",
761
765
  "spdx-correct": "3.2.0",
@@ -1,77 +0,0 @@
1
- /**
2
- * @fileoverview Socket CLI shadow mode environment variables.
3
- * Provides typed getters for SOCKET_CLI_SHADOW_* environment variables.
4
- */
5
- /**
6
- * Controls Socket CLI shadow mode risk acceptance.
7
- *
8
- * @returns Whether to accept all risks in shadow mode
9
- *
10
- * @example
11
- * ```typescript
12
- * import { getSocketCliShadowAcceptRisks } from '@socketsecurity/lib/env/socket-cli-shadow'
13
- *
14
- * if (getSocketCliShadowAcceptRisks()) {
15
- * console.log('Shadow mode risks accepted')
16
- * }
17
- * ```
18
- */
19
- export declare function getSocketCliShadowAcceptRisks(): boolean;
20
- /**
21
- * API token for Socket CLI shadow mode.
22
- *
23
- * @returns Shadow mode API token or undefined
24
- *
25
- * @example
26
- * ```typescript
27
- * import { getSocketCliShadowApiToken } from '@socketsecurity/lib/env/socket-cli-shadow'
28
- *
29
- * const token = getSocketCliShadowApiToken()
30
- * // e.g. 'sk_shadow_abc123...' or undefined
31
- * ```
32
- */
33
- export declare function getSocketCliShadowApiToken(): string | undefined;
34
- /**
35
- * Binary path for Socket CLI shadow mode.
36
- *
37
- * @returns Shadow mode binary path or undefined
38
- *
39
- * @example
40
- * ```typescript
41
- * import { getSocketCliShadowBin } from '@socketsecurity/lib/env/socket-cli-shadow'
42
- *
43
- * const bin = getSocketCliShadowBin()
44
- * // e.g. '/usr/local/bin/socket-shadow' or undefined
45
- * ```
46
- */
47
- export declare function getSocketCliShadowBin(): string | undefined;
48
- /**
49
- * Controls Socket CLI shadow mode progress display.
50
- *
51
- * @returns Whether to show progress in shadow mode
52
- *
53
- * @example
54
- * ```typescript
55
- * import { getSocketCliShadowProgress } from '@socketsecurity/lib/env/socket-cli-shadow'
56
- *
57
- * if (getSocketCliShadowProgress()) {
58
- * console.log('Shadow mode progress enabled')
59
- * }
60
- * ```
61
- */
62
- export declare function getSocketCliShadowProgress(): boolean;
63
- /**
64
- * Controls Socket CLI shadow mode silent operation.
65
- *
66
- * @returns Whether shadow mode should operate silently
67
- *
68
- * @example
69
- * ```typescript
70
- * import { getSocketCliShadowSilent } from '@socketsecurity/lib/env/socket-cli-shadow'
71
- *
72
- * if (getSocketCliShadowSilent()) {
73
- * console.log('Shadow mode is silent')
74
- * }
75
- * ```
76
- */
77
- export declare function getSocketCliShadowSilent(): boolean;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- /* Socket Lib - Built with esbuild */
3
- "use strict";
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
- var socket_cli_shadow_exports = {};
22
- __export(socket_cli_shadow_exports, {
23
- getSocketCliShadowAcceptRisks: () => getSocketCliShadowAcceptRisks,
24
- getSocketCliShadowApiToken: () => getSocketCliShadowApiToken,
25
- getSocketCliShadowBin: () => getSocketCliShadowBin,
26
- getSocketCliShadowProgress: () => getSocketCliShadowProgress,
27
- getSocketCliShadowSilent: () => getSocketCliShadowSilent
28
- });
29
- module.exports = __toCommonJS(socket_cli_shadow_exports);
30
- var import_helpers = require("./helpers");
31
- var import_rewire = require("./rewire");
32
- // @__NO_SIDE_EFFECTS__
33
- function getSocketCliShadowAcceptRisks() {
34
- return (0, import_helpers.envAsBoolean)((0, import_rewire.getEnvValue)("SOCKET_CLI_SHADOW_ACCEPT_RISKS"));
35
- }
36
- // @__NO_SIDE_EFFECTS__
37
- function getSocketCliShadowApiToken() {
38
- return (0, import_rewire.getEnvValue)("SOCKET_CLI_SHADOW_API_TOKEN");
39
- }
40
- // @__NO_SIDE_EFFECTS__
41
- function getSocketCliShadowBin() {
42
- return (0, import_rewire.getEnvValue)("SOCKET_CLI_SHADOW_BIN");
43
- }
44
- // @__NO_SIDE_EFFECTS__
45
- function getSocketCliShadowProgress() {
46
- return (0, import_helpers.envAsBoolean)((0, import_rewire.getEnvValue)("SOCKET_CLI_SHADOW_PROGRESS"));
47
- }
48
- // @__NO_SIDE_EFFECTS__
49
- function getSocketCliShadowSilent() {
50
- return (0, import_helpers.envAsBoolean)((0, import_rewire.getEnvValue)("SOCKET_CLI_SHADOW_SILENT"));
51
- }
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- getSocketCliShadowAcceptRisks,
55
- getSocketCliShadowApiToken,
56
- getSocketCliShadowBin,
57
- getSocketCliShadowProgress,
58
- getSocketCliShadowSilent
59
- });