@socketsecurity/lib 5.18.1 → 5.19.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 (305) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +6 -5
  3. package/dist/abort.d.ts +3 -0
  4. package/dist/abort.js +1 -0
  5. package/dist/agent.d.ts +66 -49
  6. package/dist/agent.js +51 -50
  7. package/dist/ansi.d.ts +2 -5
  8. package/dist/ansi.js +3 -2
  9. package/dist/archives.d.ts +25 -21
  10. package/dist/archives.js +35 -34
  11. package/dist/argv/flags.d.ts +100 -91
  12. package/dist/argv/flags.js +88 -87
  13. package/dist/argv/parse.d.ts +30 -40
  14. package/dist/argv/parse.js +33 -32
  15. package/dist/arrays.d.ts +4 -8
  16. package/dist/arrays.js +1 -0
  17. package/dist/bin.d.ts +7 -5
  18. package/dist/bin.js +52 -29
  19. package/dist/cacache.d.ts +13 -12
  20. package/dist/cacache.js +9 -8
  21. package/dist/cache-with-ttl.d.ts +53 -35
  22. package/dist/cache-with-ttl.js +1 -0
  23. package/dist/colors.d.ts +5 -5
  24. package/dist/colors.js +1 -0
  25. package/dist/constants/agents.d.ts +5 -9
  26. package/dist/constants/agents.js +3 -2
  27. package/dist/constants/core.d.ts +5 -10
  28. package/dist/constants/core.js +2 -1
  29. package/dist/constants/encoding.d.ts +3 -3
  30. package/dist/constants/encoding.js +1 -0
  31. package/dist/constants/github.d.ts +3 -3
  32. package/dist/constants/github.js +1 -0
  33. package/dist/constants/licenses.d.ts +9 -2
  34. package/dist/constants/licenses.js +1 -0
  35. package/dist/constants/lifecycle-script-names.js +1 -0
  36. package/dist/constants/maintained-node-versions.d.ts +3 -0
  37. package/dist/constants/maintained-node-versions.js +1 -0
  38. package/dist/constants/node.d.ts +125 -16
  39. package/dist/constants/node.js +74 -73
  40. package/dist/constants/package-default-node-range.d.ts +3 -1
  41. package/dist/constants/package-default-node-range.js +2 -1
  42. package/dist/constants/package-default-socket-categories.d.ts +0 -1
  43. package/dist/constants/package-default-socket-categories.js +1 -0
  44. package/dist/constants/packages.d.ts +12 -17
  45. package/dist/constants/packages.js +31 -16
  46. package/dist/constants/platform.d.ts +1 -2
  47. package/dist/constants/platform.js +2 -1
  48. package/dist/constants/process.d.ts +18 -0
  49. package/dist/constants/process.js +1 -0
  50. package/dist/constants/socket.d.ts +4 -10
  51. package/dist/constants/socket.js +2 -1
  52. package/dist/constants/testing.d.ts +3 -3
  53. package/dist/constants/testing.js +1 -0
  54. package/dist/constants/time.d.ts +3 -4
  55. package/dist/constants/time.js +1 -0
  56. package/dist/constants/typescript.d.ts +10 -3
  57. package/dist/constants/typescript.js +5 -4
  58. package/dist/cover/code.d.ts +3 -0
  59. package/dist/cover/code.js +12 -12
  60. package/dist/cover/formatters.d.ts +12 -9
  61. package/dist/cover/formatters.js +19 -18
  62. package/dist/cover/type.d.ts +3 -0
  63. package/dist/cover/type.js +1 -0
  64. package/dist/cover/types.js +1 -0
  65. package/dist/debug.d.ts +32 -47
  66. package/dist/debug.js +97 -96
  67. package/dist/dlx/arborist.d.ts +134 -0
  68. package/dist/dlx/arborist.js +177 -0
  69. package/dist/dlx/binary.d.ts +25 -9
  70. package/dist/dlx/binary.js +34 -12
  71. package/dist/dlx/cache.d.ts +1 -0
  72. package/dist/dlx/cache.js +2 -1
  73. package/dist/dlx/detect.d.ts +15 -0
  74. package/dist/dlx/detect.js +28 -20
  75. package/dist/dlx/dir.d.ts +1 -11
  76. package/dist/dlx/dir.js +2 -12
  77. package/dist/dlx/integrity.d.ts +86 -0
  78. package/dist/dlx/integrity.js +112 -0
  79. package/dist/dlx/lockfile.d.ts +115 -0
  80. package/dist/dlx/lockfile.js +139 -0
  81. package/dist/dlx/manifest.d.ts +26 -1
  82. package/dist/dlx/manifest.js +9 -6
  83. package/dist/dlx/package.d.ts +58 -3
  84. package/dist/dlx/package.js +101 -74
  85. package/dist/dlx/packages.d.ts +1 -11
  86. package/dist/dlx/packages.js +3 -14
  87. package/dist/dlx/paths.d.ts +1 -0
  88. package/dist/dlx/paths.js +2 -1
  89. package/dist/effects/pulse-frames.js +1 -0
  90. package/dist/effects/text-shimmer.d.ts +13 -2
  91. package/dist/effects/text-shimmer.js +50 -46
  92. package/dist/effects/types.js +1 -0
  93. package/dist/effects/ultra.js +1 -0
  94. package/dist/env/ci.d.ts +6 -1
  95. package/dist/env/ci.js +1 -0
  96. package/dist/env/debug.d.ts +5 -1
  97. package/dist/env/debug.js +1 -0
  98. package/dist/env/github.d.ts +19 -23
  99. package/dist/env/github.js +5 -4
  100. package/dist/env/helpers.d.ts +21 -9
  101. package/dist/env/helpers.js +5 -11
  102. package/dist/env/home.d.ts +17 -4
  103. package/dist/env/home.js +2 -1
  104. package/dist/env/locale.d.ts +4 -3
  105. package/dist/env/locale.js +1 -0
  106. package/dist/env/node-auth-token.d.ts +5 -1
  107. package/dist/env/node-auth-token.js +1 -0
  108. package/dist/env/node-env.d.ts +5 -1
  109. package/dist/env/node-env.js +1 -0
  110. package/dist/env/npm.d.ts +4 -5
  111. package/dist/env/npm.js +1 -0
  112. package/dist/env/package-manager.d.ts +4 -3
  113. package/dist/env/package-manager.js +2 -1
  114. package/dist/env/path.d.ts +5 -1
  115. package/dist/env/path.js +1 -0
  116. package/dist/env/pre-commit.d.ts +5 -1
  117. package/dist/env/pre-commit.js +1 -0
  118. package/dist/env/rewire.d.ts +10 -0
  119. package/dist/env/rewire.js +7 -5
  120. package/dist/env/shell.d.ts +5 -1
  121. package/dist/env/shell.js +1 -0
  122. package/dist/env/socket-cli-shadow.d.ts +4 -5
  123. package/dist/env/socket-cli-shadow.js +1 -0
  124. package/dist/env/socket-cli.d.ts +4 -14
  125. package/dist/env/socket-cli.js +1 -0
  126. package/dist/env/socket.d.ts +6 -18
  127. package/dist/env/socket.js +4 -3
  128. package/dist/env/temp-dir.d.ts +4 -3
  129. package/dist/env/temp-dir.js +1 -0
  130. package/dist/env/term.d.ts +5 -1
  131. package/dist/env/term.js +1 -0
  132. package/dist/env/test.d.ts +4 -3
  133. package/dist/env/test.js +1 -0
  134. package/dist/env/windows.d.ts +4 -4
  135. package/dist/env/windows.js +1 -0
  136. package/dist/env/xdg.d.ts +4 -3
  137. package/dist/env/xdg.js +1 -0
  138. package/dist/env.d.ts +83 -23
  139. package/dist/env.js +112 -80
  140. package/dist/errors.js +1 -0
  141. package/dist/external/@npmcli/package-json.js +9 -3968
  142. package/dist/external/@socketregistry/packageurl-js.js +2 -2
  143. package/dist/external/debug.js +162 -328
  144. package/dist/external/external-pack.js +3 -2835
  145. package/dist/external/npm-pack.js +13939 -33342
  146. package/dist/external/zod.js +160 -7558
  147. package/dist/fs.d.ts +92 -113
  148. package/dist/fs.js +35 -35
  149. package/dist/git.d.ts +170 -164
  150. package/dist/git.js +113 -87
  151. package/dist/github.d.ts +249 -227
  152. package/dist/github.js +82 -81
  153. package/dist/globs.d.ts +31 -17
  154. package/dist/globs.js +51 -58
  155. package/dist/http-request.d.ts +99 -99
  156. package/dist/http-request.js +182 -156
  157. package/dist/ipc-cli.d.ts +28 -0
  158. package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
  159. package/dist/ipc.d.ts +9 -299
  160. package/dist/ipc.js +18 -204
  161. package/dist/json/edit.d.ts +3 -1
  162. package/dist/json/edit.js +30 -30
  163. package/dist/json/format.d.ts +36 -36
  164. package/dist/json/format.js +22 -21
  165. package/dist/json/parse.d.ts +4 -2
  166. package/dist/json/parse.js +1 -0
  167. package/dist/json/types.js +1 -0
  168. package/dist/{links/index.d.ts → links.d.ts} +6 -2
  169. package/dist/{links/index.js → links.js} +5 -4
  170. package/dist/logger.d.ts +4 -6
  171. package/dist/logger.js +61 -53
  172. package/dist/memoization.d.ts +52 -49
  173. package/dist/memoization.js +55 -33
  174. package/dist/objects.d.ts +25 -44
  175. package/dist/objects.js +2 -1
  176. package/dist/package-extensions.d.ts +6 -0
  177. package/dist/package-extensions.js +2 -1
  178. package/dist/packages/edit.d.ts +3 -5
  179. package/dist/packages/edit.js +4 -3
  180. package/dist/packages/exports.d.ts +11 -14
  181. package/dist/packages/exports.js +11 -10
  182. package/dist/packages/isolation.d.ts +4 -0
  183. package/dist/packages/isolation.js +20 -19
  184. package/dist/packages/licenses.d.ts +3 -10
  185. package/dist/packages/licenses.js +2 -1
  186. package/dist/packages/manifest.d.ts +3 -3
  187. package/dist/packages/manifest.js +1 -0
  188. package/dist/packages/normalize.d.ts +3 -4
  189. package/dist/packages/normalize.js +1 -0
  190. package/dist/packages/operations.d.ts +3 -10
  191. package/dist/packages/operations.js +1 -0
  192. package/dist/packages/provenance.d.ts +10 -8
  193. package/dist/packages/provenance.js +55 -54
  194. package/dist/packages/specs.d.ts +3 -5
  195. package/dist/packages/specs.js +1 -0
  196. package/dist/packages/validation.d.ts +3 -3
  197. package/dist/packages/validation.js +1 -0
  198. package/dist/packages.d.ts +2 -17
  199. package/dist/packages.js +2 -1
  200. package/dist/paths/dirnames.d.ts +0 -2
  201. package/dist/paths/dirnames.js +1 -0
  202. package/dist/paths/exts.d.ts +0 -1
  203. package/dist/paths/exts.js +1 -0
  204. package/dist/paths/filenames.d.ts +0 -1
  205. package/dist/paths/filenames.js +1 -0
  206. package/dist/paths/globs.d.ts +0 -1
  207. package/dist/paths/globs.js +1 -0
  208. package/dist/paths/normalize.d.ts +115 -123
  209. package/dist/paths/normalize.js +128 -127
  210. package/dist/paths/packages.d.ts +3 -2
  211. package/dist/paths/packages.js +2 -1
  212. package/dist/paths/rewire.d.ts +9 -0
  213. package/dist/paths/rewire.js +5 -3
  214. package/dist/paths/socket.d.ts +37 -23
  215. package/dist/paths/socket.js +26 -25
  216. package/dist/performance.d.ts +87 -84
  217. package/dist/performance.js +97 -96
  218. package/dist/process-lock.d.ts +41 -1
  219. package/dist/process-lock.js +24 -17
  220. package/dist/promise-queue.d.ts +6 -0
  221. package/dist/promise-queue.js +1 -0
  222. package/dist/promises.d.ts +40 -55
  223. package/dist/promises.js +12 -11
  224. package/dist/regexps.d.ts +0 -5
  225. package/dist/regexps.js +1 -0
  226. package/dist/releases/github.d.ts +59 -63
  227. package/dist/releases/github.js +95 -100
  228. package/dist/releases/socket-btm.d.ts +9 -2
  229. package/dist/releases/socket-btm.js +32 -25
  230. package/dist/sea.d.ts +5 -0
  231. package/dist/sea.js +1 -0
  232. package/dist/shadow.d.ts +4 -0
  233. package/dist/shadow.js +1 -0
  234. package/dist/signal-exit.d.ts +7 -7
  235. package/dist/signal-exit.js +46 -45
  236. package/dist/sorts.d.ts +5 -7
  237. package/dist/sorts.js +11 -10
  238. package/dist/spawn.d.ts +96 -77
  239. package/dist/spawn.js +39 -38
  240. package/dist/spinner.d.ts +21 -22
  241. package/dist/spinner.js +15 -11
  242. package/dist/ssri.d.ts +31 -36
  243. package/dist/ssri.js +15 -14
  244. package/dist/stdio/_stream.d.ts +31 -0
  245. package/dist/stdio/_stream.js +57 -0
  246. package/dist/stdio/divider.d.ts +40 -36
  247. package/dist/stdio/divider.js +10 -9
  248. package/dist/stdio/footer.d.ts +20 -0
  249. package/dist/stdio/footer.js +12 -2
  250. package/dist/stdio/header.d.ts +4 -16
  251. package/dist/stdio/header.js +1 -9
  252. package/dist/stdio/stderr.d.ts +51 -39
  253. package/dist/stdio/stderr.js +19 -22
  254. package/dist/stdio/stdout.d.ts +54 -52
  255. package/dist/stdio/stdout.js +35 -33
  256. package/dist/streams.d.ts +4 -3
  257. package/dist/streams.js +1 -0
  258. package/dist/strings.d.ts +31 -85
  259. package/dist/strings.js +5 -49
  260. package/dist/suppress-warnings.d.ts +32 -15
  261. package/dist/suppress-warnings.js +14 -13
  262. package/dist/tables.d.ts +30 -26
  263. package/dist/tables.js +24 -23
  264. package/dist/temporary-executor.d.ts +4 -0
  265. package/dist/temporary-executor.js +1 -0
  266. package/dist/themes/context.d.ts +30 -26
  267. package/dist/themes/context.js +19 -18
  268. package/dist/themes/index.d.ts +0 -4
  269. package/dist/themes/index.js +1 -0
  270. package/dist/themes/themes.d.ts +1 -1
  271. package/dist/themes/themes.js +1 -0
  272. package/dist/themes/types.js +1 -0
  273. package/dist/themes/utils.d.ts +46 -43
  274. package/dist/themes/utils.js +45 -44
  275. package/dist/types.d.ts +48 -52
  276. package/dist/types.js +35 -35
  277. package/dist/url.d.ts +48 -53
  278. package/dist/url.js +38 -37
  279. package/dist/validation/json-parser.d.ts +19 -190
  280. package/dist/validation/json-parser.js +5 -69
  281. package/dist/validation/types.d.ts +9 -33
  282. package/dist/validation/types.js +1 -0
  283. package/dist/versions.d.ts +1 -0
  284. package/dist/versions.js +2 -1
  285. package/dist/words.d.ts +3 -6
  286. package/dist/words.js +1 -0
  287. package/dist/zod.js +1 -0
  288. package/package.json +34 -70
  289. package/dist/external/@inquirer/checkbox.js +0 -5
  290. package/dist/external/@inquirer/confirm.js +0 -5
  291. package/dist/external/@inquirer/input.js +0 -5
  292. package/dist/external/@inquirer/password.js +0 -5
  293. package/dist/external/@inquirer/search.js +0 -5
  294. package/dist/external/@inquirer/select.js +0 -5
  295. package/dist/functions.d.ts +0 -57
  296. package/dist/functions.js +0 -70
  297. package/dist/stdio/clear.d.ts +0 -140
  298. package/dist/stdio/clear.js +0 -95
  299. package/dist/stdio/mask.d.ts +0 -151
  300. package/dist/stdio/mask.js +0 -224
  301. package/dist/stdio/progress.d.ts +0 -148
  302. package/dist/stdio/progress.js +0 -212
  303. package/dist/stdio/prompts.d.ts +0 -195
  304. package/dist/stdio/prompts.js +0 -176
  305. package/dist/utils/get-ipc.d.ts +0 -15
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -31,6 +32,10 @@ __export(github_exports, {
31
32
  module.exports = __toCommonJS(github_exports);
32
33
  var import_rewire = require("./rewire");
33
34
  // @__NO_SIDE_EFFECTS__
35
+ function getGhToken() {
36
+ return (0, import_rewire.getEnvValue)("GH_TOKEN");
37
+ }
38
+ // @__NO_SIDE_EFFECTS__
34
39
  function getGithubApiUrl() {
35
40
  return (0, import_rewire.getEnvValue)("GITHUB_API_URL");
36
41
  }
@@ -58,10 +63,6 @@ function getGithubServerUrl() {
58
63
  function getGithubToken() {
59
64
  return (0, import_rewire.getEnvValue)("GITHUB_TOKEN");
60
65
  }
61
- // @__NO_SIDE_EFFECTS__
62
- function getGhToken() {
63
- return (0, import_rewire.getEnvValue)("GH_TOKEN");
64
- }
65
66
  // Annotate the CommonJS export names for ESM import in node:
66
67
  0 && (module.exports = {
67
68
  getGhToken,
@@ -1,11 +1,17 @@
1
1
  /**
2
2
  * @fileoverview Environment variable type conversion helpers.
3
+ *
4
+ * Thin wrappers over the unified implementations in `@socketsecurity/lib/env`
5
+ * that preserve the narrower `string | undefined` input signature and the
6
+ * original strict-no-trim / float / whitespace-preserving defaults. Prefer
7
+ * the root `env` module for new code — it supports both modes via options.
3
8
  */
4
9
  /**
5
10
  * Convert an environment variable string to a boolean.
11
+ * Strict matching — does NOT trim whitespace (' true ' is false).
6
12
  *
7
13
  * @param value - The environment variable value to convert
8
- * @returns `true` if value is 'true', '1', or 'yes' (case-insensitive), `false` otherwise
14
+ * @returns `true` if value is exactly 'true', '1', or 'yes' (case-insensitive), `false` otherwise
9
15
  *
10
16
  * @example
11
17
  * ```typescript
@@ -14,30 +20,36 @@
14
20
  * envAsBoolean('true') // true
15
21
  * envAsBoolean('1') // true
16
22
  * envAsBoolean('yes') // true
23
+ * envAsBoolean(' true ') // false (no trim)
17
24
  * envAsBoolean(undefined) // false
18
25
  * ```
19
26
  */
20
- /*@__NO_SIDE_EFFECTS__*/
21
27
  export declare function envAsBoolean(value: string | undefined): boolean;
22
28
  /**
23
29
  * Convert an environment variable string to a number.
30
+ * Uses `Number()` (decimals, hex, octal, binary, Infinity preserved); returns
31
+ * 0 only for undefined/empty/NaN. For int-only parsing use `envAsNumber` in
32
+ * `@socketsecurity/lib/env` with default `mode: 'int'`.
24
33
  *
25
34
  * @param value - The environment variable value to convert
26
- * @returns The parsed number, or `0` if the value is undefined or not a valid number
35
+ * @returns The parsed number, or `0` if the value is undefined or NaN
27
36
  *
28
37
  * @example
29
38
  * ```typescript
30
39
  * import { envAsNumber } from '@socketsecurity/lib/env/helpers'
31
40
  *
32
- * envAsNumber('3000') // 3000
33
- * envAsNumber(undefined) // 0
34
- * envAsNumber('abc') // 0
41
+ * envAsNumber('3000') // 3000
42
+ * envAsNumber('3.14') // 3.14
43
+ * envAsNumber('Infinity') // Infinity
44
+ * envAsNumber(undefined) // 0
45
+ * envAsNumber('abc') // 0
35
46
  * ```
36
47
  */
37
- /*@__NO_SIDE_EFFECTS__*/
38
48
  export declare function envAsNumber(value: string | undefined): number;
39
49
  /**
40
- * Convert an environment variable value to a string.
50
+ * Convert an environment variable value to a string, preserving whitespace.
51
+ * For trimmed-string behavior use `envAsString` in `@socketsecurity/lib/env`
52
+ * (default `trim: true`); this helper passes `trim: false`.
41
53
  *
42
54
  * @param value - The environment variable value to convert
43
55
  * @returns The string value, or an empty string if undefined
@@ -47,8 +59,8 @@ export declare function envAsNumber(value: string | undefined): number;
47
59
  * import { envAsString } from '@socketsecurity/lib/env/helpers'
48
60
  *
49
61
  * envAsString('hello') // 'hello'
62
+ * envAsString(' x ') // ' x ' (whitespace preserved)
50
63
  * envAsString(undefined) // ''
51
64
  * ```
52
65
  */
53
- /*@__NO_SIDE_EFFECTS__*/
54
66
  export declare function envAsString(value: string | undefined): string;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -24,25 +25,18 @@ __export(helpers_exports, {
24
25
  envAsString: () => envAsString
25
26
  });
26
27
  module.exports = __toCommonJS(helpers_exports);
28
+ var import_env = require("../env");
27
29
  // @__NO_SIDE_EFFECTS__
28
30
  function envAsBoolean(value) {
29
- if (!value) {
30
- return false;
31
- }
32
- const lower = value.toLowerCase();
33
- return lower === "true" || lower === "1" || lower === "yes";
31
+ return (0, import_env.envAsBoolean)(value, { trim: false });
34
32
  }
35
33
  // @__NO_SIDE_EFFECTS__
36
34
  function envAsNumber(value) {
37
- if (!value) {
38
- return 0;
39
- }
40
- const num = Number(value);
41
- return Number.isNaN(num) ? 0 : num;
35
+ return (0, import_env.envAsNumber)(value, { mode: "float", allowInfinity: true });
42
36
  }
43
37
  // @__NO_SIDE_EFFECTS__
44
38
  function envAsString(value) {
45
- return value || "";
39
+ return (0, import_env.envAsString)(value, { trim: false });
46
40
  }
47
41
  // Annotate the CommonJS export names for ESM import in node:
48
42
  0 && (module.exports = {
@@ -1,15 +1,28 @@
1
1
  /**
2
- * Returns the value of the HOME environment variable.
2
+ * @fileoverview HOME environment variable getter with Windows fallback.
3
+ * Returns the user's home directory. On Windows, HOME is typically unset —
4
+ * fall back to USERPROFILE before giving up, matching the resolution order
5
+ * used by npm, git, and Node's os.homedir().
6
+ */
7
+ /**
8
+ * Returns the user's home directory path.
9
+ *
10
+ * Resolution order:
11
+ * 1. `$HOME` (POSIX, and sometimes set on Windows by shells like Git Bash)
12
+ * 2. `$USERPROFILE` (Windows default, e.g. `C:\Users\alice`)
13
+ *
14
+ * Returns `undefined` only when neither is set, which on modern systems is
15
+ * exceedingly rare outside of sandboxed or minimal-env test harnesses.
3
16
  *
4
- * @returns The user's home directory path, or `undefined` if not set
17
+ * @returns The user's home directory path, or `undefined` if not resolvable
5
18
  *
6
19
  * @example
7
20
  * ```typescript
8
21
  * import { getHome } from '@socketsecurity/lib/env/home'
9
22
  *
10
23
  * const home = getHome()
11
- * // e.g. '/tmp/user' or undefined
24
+ * // POSIX: '/Users/alice'
25
+ * // Windows: 'C:\\Users\\alice'
12
26
  * ```
13
27
  */
14
- /*@__NO_SIDE_EFFECTS__*/
15
28
  export declare function getHome(): string | undefined;
package/dist/env/home.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -25,7 +26,7 @@ module.exports = __toCommonJS(home_exports);
25
26
  var import_rewire = require("./rewire");
26
27
  // @__NO_SIDE_EFFECTS__
27
28
  function getHome() {
28
- return (0, import_rewire.getEnvValue)("HOME");
29
+ return (0, import_rewire.getEnvValue)("HOME") ?? (0, import_rewire.getEnvValue)("USERPROFILE");
29
30
  }
30
31
  // Annotate the CommonJS export names for ESM import in node:
31
32
  0 && (module.exports = {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Locale and language environment variable getters.
3
+ * Provides access to system locale settings.
4
+ */
1
5
  /**
2
6
  * LANG environment variable.
3
7
  * System locale and language settings.
@@ -12,7 +16,6 @@
12
16
  * // e.g. 'en_US.UTF-8' or undefined
13
17
  * ```
14
18
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
19
  export declare function getLang(): string | undefined;
17
20
  /**
18
21
  * LC_ALL environment variable.
@@ -28,7 +31,6 @@ export declare function getLang(): string | undefined;
28
31
  * // e.g. 'C' or 'en_US.UTF-8'
29
32
  * ```
30
33
  */
31
- /*@__NO_SIDE_EFFECTS__*/
32
34
  export declare function getLcAll(): string | undefined;
33
35
  /**
34
36
  * LC_MESSAGES environment variable.
@@ -44,5 +46,4 @@ export declare function getLcAll(): string | undefined;
44
46
  * // e.g. 'en_US.UTF-8' or undefined
45
47
  * ```
46
48
  */
47
- /*@__NO_SIDE_EFFECTS__*/
48
49
  export declare function getLcMessages(): string | undefined;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview NODE_AUTH_TOKEN environment variable getter.
3
+ * Exports `getNodeAuthToken()`, returning the value of `NODE_AUTH_TOKEN`
4
+ * used to authenticate against Node.js package registries.
5
+ */
1
6
  /**
2
7
  * Returns the value of the NODE_AUTH_TOKEN environment variable.
3
8
  *
@@ -11,5 +16,4 @@
11
16
  * // e.g. 'npm_abc123...' or undefined
12
17
  * ```
13
18
  */
14
- /*@__NO_SIDE_EFFECTS__*/
15
19
  export declare function getNodeAuthToken(): string | undefined;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview NODE_ENV environment variable getter.
3
+ * Exports `getNodeEnv()`, returning the raw `NODE_ENV` value (typically
4
+ * 'production', 'development', or 'test') or `undefined` when unset.
5
+ */
1
6
  /**
2
7
  * Returns the value of the NODE_ENV environment variable.
3
8
  *
@@ -11,5 +16,4 @@
11
16
  * // e.g. 'production', 'development', 'test', or undefined
12
17
  * ```
13
18
  */
14
- /*@__NO_SIDE_EFFECTS__*/
15
19
  export declare function getNodeEnv(): string | undefined;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
package/dist/env/npm.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview NPM environment variable getters.
3
+ * Provides access to NPM and package manager environment variables.
4
+ */
1
5
  /**
2
6
  * npm_config_registry environment variable.
3
7
  * NPM registry URL configured by package managers.
@@ -12,7 +16,6 @@
12
16
  * // e.g. 'https://registry.npmjs.org/' or undefined
13
17
  * ```
14
18
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
19
  export declare function getNpmConfigRegistry(): string | undefined;
17
20
  /**
18
21
  * npm_config_user_agent environment variable.
@@ -28,7 +31,6 @@ export declare function getNpmConfigRegistry(): string | undefined;
28
31
  * // e.g. 'pnpm/9.0.0 npm/? node/v20.0.0 darwin arm64'
29
32
  * ```
30
33
  */
31
- /*@__NO_SIDE_EFFECTS__*/
32
34
  export declare function getNpmConfigUserAgent(): string | undefined;
33
35
  /**
34
36
  * npm_lifecycle_event environment variable.
@@ -44,7 +46,6 @@ export declare function getNpmConfigUserAgent(): string | undefined;
44
46
  * // e.g. 'install', 'postinstall', or 'test'
45
47
  * ```
46
48
  */
47
- /*@__NO_SIDE_EFFECTS__*/
48
49
  export declare function getNpmLifecycleEvent(): string | undefined;
49
50
  /**
50
51
  * NPM_REGISTRY environment variable.
@@ -60,7 +61,6 @@ export declare function getNpmLifecycleEvent(): string | undefined;
60
61
  * // e.g. 'https://registry.npmjs.org/' or undefined
61
62
  * ```
62
63
  */
63
- /*@__NO_SIDE_EFFECTS__*/
64
64
  export declare function getNpmRegistry(): string | undefined;
65
65
  /**
66
66
  * NPM_TOKEN environment variable.
@@ -76,5 +76,4 @@ export declare function getNpmRegistry(): string | undefined;
76
76
  * // e.g. 'npm_abc123...' or undefined
77
77
  * ```
78
78
  */
79
- /*@__NO_SIDE_EFFECTS__*/
80
79
  export declare function getNpmToken(): string | undefined;
package/dist/env/npm.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Package manager environment detection.
3
+ * Provides utilities to detect which package manager (npm/pnpm/yarn/bun) is running.
4
+ */
1
5
  /**
2
6
  * Package manager type detected from environment.
3
7
  */
@@ -27,7 +31,6 @@ export type PackageManagerType = 'npm' | 'pnpm' | 'yarn' | 'bun' | null;
27
31
  * detectPackageManager() // null
28
32
  * ```
29
33
  */
30
- /*@__NO_SIDE_EFFECTS__*/
31
34
  export declare function detectPackageManager(): PackageManagerType;
32
35
  /**
33
36
  * Get the package manager name and version from user agent.
@@ -39,7 +42,6 @@ export declare function detectPackageManager(): PackageManagerType;
39
42
  * // { name: 'pnpm', version: '8.15.1' }
40
43
  * ```
41
44
  */
42
- /*@__NO_SIDE_EFFECTS__*/
43
45
  export declare function getPackageManagerInfo(): {
44
46
  name: string;
45
47
  version: string;
@@ -57,5 +59,4 @@ export declare function getPackageManagerInfo(): {
57
59
  * // yarn: "yarn/1.22.19 npm/? node/v20.11.0 darwin arm64"
58
60
  * ```
59
61
  */
60
- /*@__NO_SIDE_EFFECTS__*/
61
62
  export declare function getPackageManagerUserAgent(): string | undefined;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -69,7 +70,7 @@ function getPackageManagerInfo() {
69
70
  return null;
70
71
  }
71
72
  const match = userAgent.match(/^([^/]+)\/([^\s]+)/);
72
- if (match) {
73
+ if (match?.[1] && match[2]) {
73
74
  return {
74
75
  name: match[1],
75
76
  version: match[2]
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview PATH environment variable getter.
3
+ * Exports `getPath()`, returning the raw value of the `PATH` environment
4
+ * variable that lists executable search directories.
5
+ */
1
6
  /**
2
7
  * Returns the value of the PATH environment variable.
3
8
  *
@@ -11,5 +16,4 @@
11
16
  * // e.g. '/usr/local/bin:/usr/bin:/bin' or undefined
12
17
  * ```
13
18
  */
14
- /*@__NO_SIDE_EFFECTS__*/
15
19
  export declare function getPath(): string | undefined;
package/dist/env/path.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview PRE_COMMIT environment variable getter.
3
+ * Exports `getPreCommit()`, a boolean coercion of `PRE_COMMIT` used to
4
+ * detect when code is running inside a pre-commit hook.
5
+ */
1
6
  /**
2
7
  * Returns whether the PRE_COMMIT environment variable is set to a truthy value.
3
8
  *
@@ -12,5 +17,4 @@
12
17
  * }
13
18
  * ```
14
19
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
20
  export declare function getPreCommit(): boolean;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,13 @@
1
+ /**
2
+ * @fileoverview Environment variable rewiring utilities for testing.
3
+ * Uses AsyncLocalStorage for context-isolated overrides that work with concurrent tests.
4
+ *
5
+ * Features:
6
+ * - Context-isolated overrides via withEnv() for advanced use cases
7
+ * - Test-friendly setEnv/clearEnv/resetEnv that work in beforeEach/afterEach
8
+ * - Compatible with vi.stubEnv() - reads from process.env as final fallback
9
+ * - Thread-safe for concurrent test execution
10
+ */
1
11
  /**
2
12
  * Clear a specific environment variable override.
3
13
  *
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -46,7 +47,7 @@ let _async_hooks;
46
47
  // @__NO_SIDE_EFFECTS__
47
48
  function getAsyncHooks() {
48
49
  if (_async_hooks === void 0) {
49
- _async_hooks = require("async_hooks");
50
+ _async_hooks = require("node:async_hooks");
50
51
  }
51
52
  return _async_hooks;
52
53
  }
@@ -55,11 +56,12 @@ const isolatedOverridesStorage = new AsyncLocalStorage();
55
56
  const sharedOverridesSymbol = Symbol.for(
56
57
  "@socketsecurity/lib/env/rewire/test-overrides"
57
58
  );
58
- const isVitestEnv = (0, import_helpers.envAsBoolean)(import_node_process.default.env.VITEST);
59
- if (isVitestEnv && !globalThis[sharedOverridesSymbol]) {
60
- globalThis[sharedOverridesSymbol] = /* @__PURE__ */ new Map();
59
+ const _globalThis = globalThis;
60
+ const isVitestEnv = (0, import_helpers.envAsBoolean)(import_node_process.default.env["VITEST"]);
61
+ if (isVitestEnv && !_globalThis[sharedOverridesSymbol]) {
62
+ _globalThis[sharedOverridesSymbol] = /* @__PURE__ */ new Map();
61
63
  }
62
- const sharedOverrides = globalThis[sharedOverridesSymbol];
64
+ const sharedOverrides = _globalThis[sharedOverridesSymbol];
63
65
  function clearEnv(key) {
64
66
  sharedOverrides?.delete(key);
65
67
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview SHELL environment variable getter.
3
+ * Exports `getShell()`, returning the Unix/macOS `SHELL` path (for example
4
+ * `/bin/zsh`) or `undefined` when the variable is unset.
5
+ */
1
6
  /**
2
7
  * Returns the value of the SHELL environment variable.
3
8
  *
@@ -11,5 +16,4 @@
11
16
  * // e.g. '/bin/zsh' or '/bin/bash'
12
17
  * ```
13
18
  */
14
- /*@__NO_SIDE_EFFECTS__*/
15
19
  export declare function getShell(): string | undefined;
package/dist/env/shell.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Socket CLI shadow mode environment variables.
3
+ * Provides typed getters for SOCKET_CLI_SHADOW_* environment variables.
4
+ */
1
5
  /**
2
6
  * Controls Socket CLI shadow mode risk acceptance.
3
7
  *
@@ -12,7 +16,6 @@
12
16
  * }
13
17
  * ```
14
18
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
19
  export declare function getSocketCliShadowAcceptRisks(): boolean;
17
20
  /**
18
21
  * API token for Socket CLI shadow mode.
@@ -27,7 +30,6 @@ export declare function getSocketCliShadowAcceptRisks(): boolean;
27
30
  * // e.g. 'sk_shadow_abc123...' or undefined
28
31
  * ```
29
32
  */
30
- /*@__NO_SIDE_EFFECTS__*/
31
33
  export declare function getSocketCliShadowApiToken(): string | undefined;
32
34
  /**
33
35
  * Binary path for Socket CLI shadow mode.
@@ -42,7 +44,6 @@ export declare function getSocketCliShadowApiToken(): string | undefined;
42
44
  * // e.g. '/usr/local/bin/socket-shadow' or undefined
43
45
  * ```
44
46
  */
45
- /*@__NO_SIDE_EFFECTS__*/
46
47
  export declare function getSocketCliShadowBin(): string | undefined;
47
48
  /**
48
49
  * Controls Socket CLI shadow mode progress display.
@@ -58,7 +59,6 @@ export declare function getSocketCliShadowBin(): string | undefined;
58
59
  * }
59
60
  * ```
60
61
  */
61
- /*@__NO_SIDE_EFFECTS__*/
62
62
  export declare function getSocketCliShadowProgress(): boolean;
63
63
  /**
64
64
  * Controls Socket CLI shadow mode silent operation.
@@ -74,5 +74,4 @@ export declare function getSocketCliShadowProgress(): boolean;
74
74
  * }
75
75
  * ```
76
76
  */
77
- /*@__NO_SIDE_EFFECTS__*/
78
77
  export declare function getSocketCliShadowSilent(): boolean;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Socket CLI environment variables.
3
+ * Provides typed getters for SOCKET_CLI_* environment variables (excluding shadow).
4
+ */
1
5
  /**
2
6
  * Whether to accept all Socket CLI risks (alternative name).
3
7
  *
@@ -12,7 +16,6 @@
12
16
  * }
13
17
  * ```
14
18
  */
15
- /*@__NO_SIDE_EFFECTS__*/
16
19
  export declare function getSocketCliAcceptRisks(): boolean;
17
20
  /**
18
21
  * Socket CLI API base URL (alternative name).
@@ -28,7 +31,6 @@ export declare function getSocketCliAcceptRisks(): boolean;
28
31
  * // e.g. 'https://api.socket.dev' or undefined
29
32
  * ```
30
33
  */
31
- /*@__NO_SIDE_EFFECTS__*/
32
34
  export declare function getSocketCliApiBaseUrl(): string | undefined;
33
35
  /**
34
36
  * Proxy URL for Socket CLI API requests (alternative name).
@@ -45,7 +47,6 @@ export declare function getSocketCliApiBaseUrl(): string | undefined;
45
47
  * // e.g. 'http://proxy.example.com:8080' or undefined
46
48
  * ```
47
49
  */
48
- /*@__NO_SIDE_EFFECTS__*/
49
50
  export declare function getSocketCliApiProxy(): string | undefined;
50
51
  /**
51
52
  * Timeout in milliseconds for Socket CLI API requests (alternative name).
@@ -60,7 +61,6 @@ export declare function getSocketCliApiProxy(): string | undefined;
60
61
  * // e.g. 30000 or 0 if not set
61
62
  * ```
62
63
  */
63
- /*@__NO_SIDE_EFFECTS__*/
64
64
  export declare function getSocketCliApiTimeout(): number;
65
65
  /**
66
66
  * Socket CLI API authentication token (alternative name).
@@ -77,7 +77,6 @@ export declare function getSocketCliApiTimeout(): number;
77
77
  * // e.g. a Socket API token string or undefined
78
78
  * ```
79
79
  */
80
- /*@__NO_SIDE_EFFECTS__*/
81
80
  export declare function getSocketCliApiToken(): string | undefined;
82
81
  /**
83
82
  * Bootstrap cache directory path.
@@ -93,7 +92,6 @@ export declare function getSocketCliApiToken(): string | undefined;
93
92
  * // e.g. '/tmp/.socket-cli-cache' or undefined
94
93
  * ```
95
94
  */
96
- /*@__NO_SIDE_EFFECTS__*/
97
95
  export declare function getSocketCliBootstrapCacheDir(): string | undefined;
98
96
  /**
99
97
  * Bootstrap package spec (e.g., @socketsecurity/cli@^2.0.11).
@@ -109,7 +107,6 @@ export declare function getSocketCliBootstrapCacheDir(): string | undefined;
109
107
  * // e.g. '@socketsecurity/cli@^2.0.11' or undefined
110
108
  * ```
111
109
  */
112
- /*@__NO_SIDE_EFFECTS__*/
113
110
  export declare function getSocketCliBootstrapSpec(): string | undefined;
114
111
  /**
115
112
  * Socket CLI configuration file path (alternative name).
@@ -124,7 +121,6 @@ export declare function getSocketCliBootstrapSpec(): string | undefined;
124
121
  * // e.g. '/tmp/project/socket.yml' or undefined
125
122
  * ```
126
123
  */
127
- /*@__NO_SIDE_EFFECTS__*/
128
124
  export declare function getSocketCliConfig(): string | undefined;
129
125
  /**
130
126
  * Controls Socket CLI fix mode.
@@ -139,7 +135,6 @@ export declare function getSocketCliConfig(): string | undefined;
139
135
  * // e.g. 'true' or undefined
140
136
  * ```
141
137
  */
142
- /*@__NO_SIDE_EFFECTS__*/
143
138
  export declare function getSocketCliFix(): string | undefined;
144
139
  /**
145
140
  * Socket CLI GitHub authentication token.
@@ -155,7 +150,6 @@ export declare function getSocketCliFix(): string | undefined;
155
150
  * // e.g. 'ghp_abc123...' or undefined
156
151
  * ```
157
152
  */
158
- /*@__NO_SIDE_EFFECTS__*/
159
153
  export declare function getSocketCliGithubToken(): string | undefined;
160
154
  /**
161
155
  * Whether to skip Socket CLI API token requirement (alternative name).
@@ -171,7 +165,6 @@ export declare function getSocketCliGithubToken(): string | undefined;
171
165
  * }
172
166
  * ```
173
167
  */
174
- /*@__NO_SIDE_EFFECTS__*/
175
168
  export declare function getSocketCliNoApiToken(): boolean;
176
169
  /**
177
170
  * Controls Socket CLI optimization mode.
@@ -187,7 +180,6 @@ export declare function getSocketCliNoApiToken(): boolean;
187
180
  * }
188
181
  * ```
189
182
  */
190
- /*@__NO_SIDE_EFFECTS__*/
191
183
  export declare function getSocketCliOptimize(): boolean;
192
184
  /**
193
185
  * Socket CLI organization slug identifier (alternative name).
@@ -203,7 +195,6 @@ export declare function getSocketCliOptimize(): boolean;
203
195
  * // e.g. 'my-org' or undefined
204
196
  * ```
205
197
  */
206
- /*@__NO_SIDE_EFFECTS__*/
207
198
  export declare function getSocketCliOrgSlug(): string | undefined;
208
199
  /**
209
200
  * Whether to view all Socket CLI risks (alternative name).
@@ -219,5 +210,4 @@ export declare function getSocketCliOrgSlug(): string | undefined;
219
210
  * }
220
211
  * ```
221
212
  */
222
- /*@__NO_SIDE_EFFECTS__*/
223
213
  export declare function getSocketCliViewAllRisks(): boolean;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;