@socketsecurity/lib 5.6.0 → 5.8.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 (49) hide show
  1. package/CHANGELOG.md +92 -2
  2. package/README.md +190 -18
  3. package/dist/archives.d.ts +58 -0
  4. package/dist/archives.js +313 -0
  5. package/dist/arrays.js +2 -3
  6. package/dist/cache-with-ttl.js +25 -6
  7. package/dist/constants/node.js +2 -1
  8. package/dist/cover/formatters.js +5 -3
  9. package/dist/dlx/binary.d.ts +20 -0
  10. package/dist/dlx/binary.js +115 -99
  11. package/dist/dlx/detect.d.ts +8 -8
  12. package/dist/dlx/detect.js +18 -18
  13. package/dist/dlx/manifest.d.ts +32 -31
  14. package/dist/dlx/manifest.js +114 -112
  15. package/dist/dlx/package.d.ts +55 -0
  16. package/dist/dlx/package.js +90 -80
  17. package/dist/env/ci.js +1 -2
  18. package/dist/env/rewire.d.ts +33 -22
  19. package/dist/env/rewire.js +20 -7
  20. package/dist/env/socket-cli.d.ts +24 -24
  21. package/dist/env/socket-cli.js +12 -12
  22. package/dist/env/temp-dir.d.ts +6 -6
  23. package/dist/env/temp-dir.js +4 -4
  24. package/dist/env/windows.d.ts +6 -6
  25. package/dist/env/windows.js +4 -4
  26. package/dist/external/@npmcli/package-json.js +352 -824
  27. package/dist/external/adm-zip.js +2695 -0
  28. package/dist/external/debug.js +183 -7
  29. package/dist/external/external-pack.js +19 -1409
  30. package/dist/external/libnpmexec.js +2 -2
  31. package/dist/external/npm-pack.js +18777 -19997
  32. package/dist/external/pico-pack.js +29 -5
  33. package/dist/external/spdx-pack.js +41 -263
  34. package/dist/external/tar-fs.js +3053 -0
  35. package/dist/git.js +22 -4
  36. package/dist/github.js +17 -9
  37. package/dist/globs.js +20 -1
  38. package/dist/http-request.js +1 -1
  39. package/dist/memoization.js +22 -13
  40. package/dist/package-extensions.js +4 -2
  41. package/dist/packages/normalize.js +3 -0
  42. package/dist/packages/specs.js +1 -1
  43. package/dist/process-lock.js +4 -2
  44. package/dist/releases/github.d.ts +55 -4
  45. package/dist/releases/github.js +203 -101
  46. package/dist/spawn.js +1 -1
  47. package/dist/spinner.js +1 -1
  48. package/dist/stdio/progress.js +2 -2
  49. package/package.json +38 -15
@@ -22,12 +22,14 @@ __export(rewire_exports, {
22
22
  clearEnv: () => clearEnv,
23
23
  getEnvValue: () => getEnvValue,
24
24
  hasOverride: () => hasOverride,
25
+ isInEnv: () => isInEnv,
25
26
  resetEnv: () => resetEnv,
26
27
  setEnv: () => setEnv,
27
28
  withEnv: () => withEnv,
28
29
  withEnvSync: () => withEnvSync
29
30
  });
30
31
  module.exports = __toCommonJS(rewire_exports);
32
+ var import_objects = require("../objects");
31
33
  var import_helpers = require("./helpers");
32
34
  let _async_hooks;
33
35
  // @__NO_SIDE_EFFECTS__
@@ -47,6 +49,9 @@ if (isVitestEnv && !globalThis[sharedOverridesSymbol]) {
47
49
  globalThis[sharedOverridesSymbol] = /* @__PURE__ */ new Map();
48
50
  }
49
51
  const sharedOverrides = globalThis[sharedOverridesSymbol];
52
+ function clearEnv(key) {
53
+ sharedOverrides?.delete(key);
54
+ }
50
55
  function getEnvValue(key) {
51
56
  const isolatedOverrides = isolatedOverridesStorage.getStore();
52
57
  if (isolatedOverrides?.has(key)) {
@@ -57,18 +62,25 @@ function getEnvValue(key) {
57
62
  }
58
63
  return process.env[key];
59
64
  }
60
- function setEnv(key, value) {
61
- sharedOverrides?.set(key, value);
65
+ function hasOverride(key) {
66
+ const isolatedOverrides = isolatedOverridesStorage.getStore();
67
+ return !!(isolatedOverrides?.has(key) || sharedOverrides?.has(key));
62
68
  }
63
- function clearEnv(key) {
64
- sharedOverrides?.delete(key);
69
+ function isInEnv(key) {
70
+ const isolatedOverrides = isolatedOverridesStorage.getStore();
71
+ if (isolatedOverrides?.has(key)) {
72
+ return true;
73
+ }
74
+ if (sharedOverrides?.has(key)) {
75
+ return true;
76
+ }
77
+ return (0, import_objects.hasOwn)(process.env, key);
65
78
  }
66
79
  function resetEnv() {
67
80
  sharedOverrides?.clear();
68
81
  }
69
- function hasOverride(key) {
70
- const isolatedOverrides = isolatedOverridesStorage.getStore();
71
- return !!(isolatedOverrides?.has(key) || sharedOverrides?.has(key));
82
+ function setEnv(key, value) {
83
+ sharedOverrides?.set(key, value);
72
84
  }
73
85
  async function withEnv(overrides, fn) {
74
86
  const map = new Map(Object.entries(overrides));
@@ -83,6 +95,7 @@ function withEnvSync(overrides, fn) {
83
95
  clearEnv,
84
96
  getEnvValue,
85
97
  hasOverride,
98
+ isInEnv,
86
99
  resetEnv,
87
100
  setEnv,
88
101
  withEnv,
@@ -38,6 +38,22 @@ export declare function getSocketCliApiTimeout(): number;
38
38
  */
39
39
  /*@__NO_SIDE_EFFECTS__*/
40
40
  export declare function getSocketCliApiToken(): string | undefined;
41
+ /**
42
+ * Bootstrap cache directory path.
43
+ * Set by bootstrap wrappers to pass dlx cache location to CLI.
44
+ *
45
+ * @returns Bootstrap cache directory or undefined
46
+ */
47
+ /*@__NO_SIDE_EFFECTS__*/
48
+ export declare function getSocketCliBootstrapCacheDir(): string | undefined;
49
+ /**
50
+ * Bootstrap package spec (e.g., @socketsecurity/cli@^2.0.11).
51
+ * Set by bootstrap wrappers (SEA/smol/npm) to pass package spec to CLI.
52
+ *
53
+ * @returns Bootstrap package spec or undefined
54
+ */
55
+ /*@__NO_SIDE_EFFECTS__*/
56
+ export declare function getSocketCliBootstrapSpec(): string | undefined;
41
57
  /**
42
58
  * Socket CLI configuration file path (alternative name).
43
59
  *
@@ -52,6 +68,14 @@ export declare function getSocketCliConfig(): string | undefined;
52
68
  */
53
69
  /*@__NO_SIDE_EFFECTS__*/
54
70
  export declare function getSocketCliFix(): string | undefined;
71
+ /**
72
+ * Socket CLI GitHub authentication token.
73
+ * Checks SOCKET_CLI_GITHUB_TOKEN, SOCKET_SECURITY_GITHUB_PAT, then falls back to GITHUB_TOKEN.
74
+ *
75
+ * @returns GitHub token or undefined
76
+ */
77
+ /*@__NO_SIDE_EFFECTS__*/
78
+ export declare function getSocketCliGithubToken(): string | undefined;
55
79
  /**
56
80
  * Whether to skip Socket CLI API token requirement (alternative name).
57
81
  *
@@ -81,27 +105,3 @@ export declare function getSocketCliOrgSlug(): string | undefined;
81
105
  */
82
106
  /*@__NO_SIDE_EFFECTS__*/
83
107
  export declare function getSocketCliViewAllRisks(): boolean;
84
- /**
85
- * Socket CLI GitHub authentication token.
86
- * Checks SOCKET_CLI_GITHUB_TOKEN, SOCKET_SECURITY_GITHUB_PAT, then falls back to GITHUB_TOKEN.
87
- *
88
- * @returns GitHub token or undefined
89
- */
90
- /*@__NO_SIDE_EFFECTS__*/
91
- export declare function getSocketCliGithubToken(): string | undefined;
92
- /**
93
- * Bootstrap package spec (e.g., @socketsecurity/cli@^2.0.11).
94
- * Set by bootstrap wrappers (SEA/smol/npm) to pass package spec to CLI.
95
- *
96
- * @returns Bootstrap package spec or undefined
97
- */
98
- /*@__NO_SIDE_EFFECTS__*/
99
- export declare function getSocketCliBootstrapSpec(): string | undefined;
100
- /**
101
- * Bootstrap cache directory path.
102
- * Set by bootstrap wrappers to pass dlx cache location to CLI.
103
- *
104
- * @returns Bootstrap cache directory or undefined
105
- */
106
- /*@__NO_SIDE_EFFECTS__*/
107
- export declare function getSocketCliBootstrapCacheDir(): string | undefined;
@@ -58,6 +58,14 @@ function getSocketCliApiToken() {
58
58
  return (0, import_rewire.getEnvValue)("SOCKET_CLI_API_TOKEN") || (0, import_rewire.getEnvValue)("SOCKET_CLI_API_KEY") || (0, import_rewire.getEnvValue)("SOCKET_SECURITY_API_TOKEN") || (0, import_rewire.getEnvValue)("SOCKET_SECURITY_API_KEY");
59
59
  }
60
60
  // @__NO_SIDE_EFFECTS__
61
+ function getSocketCliBootstrapCacheDir() {
62
+ return (0, import_rewire.getEnvValue)("SOCKET_CLI_BOOTSTRAP_CACHE_DIR");
63
+ }
64
+ // @__NO_SIDE_EFFECTS__
65
+ function getSocketCliBootstrapSpec() {
66
+ return (0, import_rewire.getEnvValue)("SOCKET_CLI_BOOTSTRAP_SPEC");
67
+ }
68
+ // @__NO_SIDE_EFFECTS__
61
69
  function getSocketCliConfig() {
62
70
  return (0, import_rewire.getEnvValue)("SOCKET_CLI_CONFIG");
63
71
  }
@@ -66,6 +74,10 @@ function getSocketCliFix() {
66
74
  return (0, import_rewire.getEnvValue)("SOCKET_CLI_FIX");
67
75
  }
68
76
  // @__NO_SIDE_EFFECTS__
77
+ function getSocketCliGithubToken() {
78
+ return (0, import_rewire.getEnvValue)("SOCKET_CLI_GITHUB_TOKEN") || (0, import_rewire.getEnvValue)("SOCKET_SECURITY_GITHUB_PAT") || (0, import_rewire.getEnvValue)("GITHUB_TOKEN");
79
+ }
80
+ // @__NO_SIDE_EFFECTS__
69
81
  function getSocketCliNoApiToken() {
70
82
  return (0, import_helpers.envAsBoolean)((0, import_rewire.getEnvValue)("SOCKET_CLI_NO_API_TOKEN"));
71
83
  }
@@ -81,18 +93,6 @@ function getSocketCliOrgSlug() {
81
93
  function getSocketCliViewAllRisks() {
82
94
  return (0, import_helpers.envAsBoolean)((0, import_rewire.getEnvValue)("SOCKET_CLI_VIEW_ALL_RISKS"));
83
95
  }
84
- // @__NO_SIDE_EFFECTS__
85
- function getSocketCliGithubToken() {
86
- return (0, import_rewire.getEnvValue)("SOCKET_CLI_GITHUB_TOKEN") || (0, import_rewire.getEnvValue)("SOCKET_SECURITY_GITHUB_PAT") || (0, import_rewire.getEnvValue)("GITHUB_TOKEN");
87
- }
88
- // @__NO_SIDE_EFFECTS__
89
- function getSocketCliBootstrapSpec() {
90
- return (0, import_rewire.getEnvValue)("SOCKET_CLI_BOOTSTRAP_SPEC");
91
- }
92
- // @__NO_SIDE_EFFECTS__
93
- function getSocketCliBootstrapCacheDir() {
94
- return (0, import_rewire.getEnvValue)("SOCKET_CLI_BOOTSTRAP_CACHE_DIR");
95
- }
96
96
  // Annotate the CommonJS export names for ESM import in node:
97
97
  0 && (module.exports = {
98
98
  getSocketCliAcceptRisks,
@@ -1,9 +1,3 @@
1
- /**
2
- * TMPDIR environment variable.
3
- * Unix/macOS temporary directory path.
4
- */
5
- /*@__NO_SIDE_EFFECTS__*/
6
- export declare function getTmpdir(): string | undefined;
7
1
  /**
8
2
  * TEMP environment variable.
9
3
  * Windows temporary directory path.
@@ -16,3 +10,9 @@ export declare function getTemp(): string | undefined;
16
10
  */
17
11
  /*@__NO_SIDE_EFFECTS__*/
18
12
  export declare function getTmp(): string | undefined;
13
+ /**
14
+ * TMPDIR environment variable.
15
+ * Unix/macOS temporary directory path.
16
+ */
17
+ /*@__NO_SIDE_EFFECTS__*/
18
+ export declare function getTmpdir(): string | undefined;
@@ -26,10 +26,6 @@ __export(temp_dir_exports, {
26
26
  module.exports = __toCommonJS(temp_dir_exports);
27
27
  var import_rewire = require("./rewire");
28
28
  // @__NO_SIDE_EFFECTS__
29
- function getTmpdir() {
30
- return (0, import_rewire.getEnvValue)("TMPDIR");
31
- }
32
- // @__NO_SIDE_EFFECTS__
33
29
  function getTemp() {
34
30
  return (0, import_rewire.getEnvValue)("TEMP");
35
31
  }
@@ -37,6 +33,10 @@ function getTemp() {
37
33
  function getTmp() {
38
34
  return (0, import_rewire.getEnvValue)("TMP");
39
35
  }
36
+ // @__NO_SIDE_EFFECTS__
37
+ function getTmpdir() {
38
+ return (0, import_rewire.getEnvValue)("TMPDIR");
39
+ }
40
40
  // Annotate the CommonJS export names for ESM import in node:
41
41
  0 && (module.exports = {
42
42
  getTemp,
@@ -4,6 +4,12 @@
4
4
  */
5
5
  /*@__NO_SIDE_EFFECTS__*/
6
6
  export declare function getAppdata(): string | undefined;
7
+ /**
8
+ * COMSPEC environment variable.
9
+ * Points to the Windows command processor (typically cmd.exe).
10
+ */
11
+ /*@__NO_SIDE_EFFECTS__*/
12
+ export declare function getComspec(): string | undefined;
7
13
  /**
8
14
  * LOCALAPPDATA environment variable.
9
15
  * Points to the Local Application Data directory on Windows.
@@ -16,9 +22,3 @@ export declare function getLocalappdata(): string | undefined;
16
22
  */
17
23
  /*@__NO_SIDE_EFFECTS__*/
18
24
  export declare function getUserprofile(): string | undefined;
19
- /**
20
- * COMSPEC environment variable.
21
- * Points to the Windows command processor (typically cmd.exe).
22
- */
23
- /*@__NO_SIDE_EFFECTS__*/
24
- export declare function getComspec(): string | undefined;
@@ -31,6 +31,10 @@ function getAppdata() {
31
31
  return (0, import_rewire.getEnvValue)("APPDATA");
32
32
  }
33
33
  // @__NO_SIDE_EFFECTS__
34
+ function getComspec() {
35
+ return (0, import_rewire.getEnvValue)("COMSPEC");
36
+ }
37
+ // @__NO_SIDE_EFFECTS__
34
38
  function getLocalappdata() {
35
39
  return (0, import_rewire.getEnvValue)("LOCALAPPDATA");
36
40
  }
@@ -38,10 +42,6 @@ function getLocalappdata() {
38
42
  function getUserprofile() {
39
43
  return (0, import_rewire.getEnvValue)("USERPROFILE");
40
44
  }
41
- // @__NO_SIDE_EFFECTS__
42
- function getComspec() {
43
- return (0, import_rewire.getEnvValue)("COMSPEC");
44
- }
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
47
47
  getAppdata,