@socketsecurity/lib 5.18.2 → 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 +43 -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 -66
  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;
@@ -45,30 +46,30 @@ const CHAR_UPPERCASE_Z = 90;
45
46
  const msysDriveRegExp = /^\/([a-zA-Z])(\/|$)/;
46
47
  const slashRegExp = /[/\\]/;
47
48
  const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
48
- // @__NO_SIDE_EFFECTS__
49
- function isPathSeparator(code) {
50
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
51
- }
52
- // @__NO_SIDE_EFFECTS__
53
- function isWindowsDeviceRoot(code) {
54
- return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z || code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z;
55
- }
56
49
  let _buffer;
50
+ let _url;
57
51
  // @__NO_SIDE_EFFECTS__
58
52
  function getBuffer() {
59
53
  if (_buffer === void 0) {
60
- _buffer = require("buffer");
54
+ _buffer = require("node:buffer");
61
55
  }
62
56
  return _buffer;
63
57
  }
64
- let _url;
65
58
  // @__NO_SIDE_EFFECTS__
66
59
  function getUrl() {
67
60
  if (_url === void 0) {
68
- _url = require("url");
61
+ _url = require("node:url");
69
62
  }
70
63
  return _url;
71
64
  }
65
+ // @__NO_SIDE_EFFECTS__
66
+ function isPathSeparator(code) {
67
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
68
+ }
69
+ // @__NO_SIDE_EFFECTS__
70
+ function isWindowsDeviceRoot(code) {
71
+ return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z || code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z;
72
+ }
72
73
  function msysDriveToNative(normalized) {
73
74
  if (import_platform.WIN32) {
74
75
  return normalized.replace(
@@ -79,9 +80,101 @@ function msysDriveToNative(normalized) {
79
80
  return normalized;
80
81
  }
81
82
  // @__NO_SIDE_EFFECTS__
82
- function isNodeModules(pathLike) {
83
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
84
- return nodeModulesPathRegExp.test(filepath);
83
+ function relative(from, to) {
84
+ if (from === to) {
85
+ return "";
86
+ }
87
+ const actualFrom = /* @__PURE__ */ resolve(from);
88
+ const actualTo = /* @__PURE__ */ resolve(to);
89
+ if (actualFrom === actualTo) {
90
+ return "";
91
+ }
92
+ if (import_platform.WIN32) {
93
+ const fromLower = actualFrom.toLowerCase();
94
+ const toLower = actualTo.toLowerCase();
95
+ if (fromLower === toLower) {
96
+ return "";
97
+ }
98
+ }
99
+ const fromStart = 1;
100
+ const fromEnd = actualFrom.length;
101
+ const fromLen = fromEnd - fromStart;
102
+ const toStart = 1;
103
+ const toEnd = actualTo.length;
104
+ const toLen = toEnd - toStart;
105
+ const length = fromLen < toLen ? fromLen : toLen;
106
+ let lastCommonSep = -1;
107
+ let i = 0;
108
+ for (; i < length; i += 1) {
109
+ let fromCode = actualFrom.charCodeAt(fromStart + i);
110
+ let toCode = actualTo.charCodeAt(toStart + i);
111
+ if (import_platform.WIN32) {
112
+ if (fromCode >= CHAR_UPPERCASE_A && fromCode <= CHAR_UPPERCASE_Z) {
113
+ fromCode += 32;
114
+ }
115
+ if (toCode >= CHAR_UPPERCASE_A && toCode <= CHAR_UPPERCASE_Z) {
116
+ toCode += 32;
117
+ }
118
+ }
119
+ if (fromCode !== toCode) {
120
+ break;
121
+ }
122
+ if (/* @__PURE__ */ isPathSeparator(actualFrom.charCodeAt(fromStart + i))) {
123
+ lastCommonSep = i;
124
+ }
125
+ }
126
+ if (i === length) {
127
+ if (toLen > length) {
128
+ const toCode = actualTo.charCodeAt(toStart + i);
129
+ if (/* @__PURE__ */ isPathSeparator(toCode)) {
130
+ return actualTo.slice(toStart + i + 1);
131
+ }
132
+ if (i === 0) {
133
+ return actualTo.slice(toStart + i);
134
+ }
135
+ } else if (fromLen > length) {
136
+ const fromCode = actualFrom.charCodeAt(fromStart + i);
137
+ if (/* @__PURE__ */ isPathSeparator(fromCode)) {
138
+ lastCommonSep = i;
139
+ } else if (i === 0) {
140
+ lastCommonSep = 0;
141
+ }
142
+ }
143
+ }
144
+ let out = "";
145
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; i += 1) {
146
+ const code = actualFrom.charCodeAt(i);
147
+ if (i === fromEnd || /* @__PURE__ */ isPathSeparator(code)) {
148
+ out += out.length === 0 ? ".." : "/..";
149
+ }
150
+ }
151
+ return out + actualTo.slice(toStart + lastCommonSep);
152
+ }
153
+ // @__NO_SIDE_EFFECTS__
154
+ function resolve(...segments) {
155
+ let resolvedPath = "";
156
+ let resolvedAbsolute = false;
157
+ for (let i = segments.length - 1; i >= 0 && !resolvedAbsolute; i -= 1) {
158
+ const segment = segments[i];
159
+ if (typeof segment !== "string" || segment.length === 0) {
160
+ continue;
161
+ }
162
+ resolvedPath = segment + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
163
+ resolvedAbsolute = /* @__PURE__ */ isAbsolute(segment);
164
+ }
165
+ if (!resolvedAbsolute) {
166
+ const cwd = /* @__PURE__ */ require("node:process").cwd();
167
+ resolvedPath = cwd + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
168
+ }
169
+ return /* @__PURE__ */ normalizePath(resolvedPath);
170
+ }
171
+ // @__NO_SIDE_EFFECTS__
172
+ function fromUnixPath(pathLike) {
173
+ const normalized = /* @__PURE__ */ normalizePath(pathLike);
174
+ if (import_platform.WIN32) {
175
+ return normalized.replace(/\//g, "\\");
176
+ }
177
+ return normalized;
85
178
  }
86
179
  // @__NO_SIDE_EFFECTS__
87
180
  function isAbsolute(pathLike) {
@@ -105,6 +198,11 @@ function isAbsolute(pathLike) {
105
198
  return false;
106
199
  }
107
200
  // @__NO_SIDE_EFFECTS__
201
+ function isNodeModules(pathLike) {
202
+ const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
203
+ return nodeModulesPathRegExp.test(filepath);
204
+ }
205
+ // @__NO_SIDE_EFFECTS__
108
206
  function isPath(pathLike) {
109
207
  const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
110
208
  if (typeof filepath !== "string" || filepath.length === 0) {
@@ -147,14 +245,6 @@ function isUnixPath(pathLike) {
147
245
  return typeof filepath === "string" && msysDriveRegExp.test(filepath);
148
246
  }
149
247
  // @__NO_SIDE_EFFECTS__
150
- function fromUnixPath(pathLike) {
151
- const normalized = /* @__PURE__ */ normalizePath(pathLike);
152
- if (import_platform.WIN32) {
153
- return normalized.replace(/\//g, "\\");
154
- }
155
- return normalized;
156
- }
157
- // @__NO_SIDE_EFFECTS__
158
248
  function normalizePath(pathLike) {
159
249
  const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
160
250
  const { length } = filepath;
@@ -348,111 +438,6 @@ function pathLikeToString(pathLike) {
348
438
  return String(pathLike);
349
439
  }
350
440
  // @__NO_SIDE_EFFECTS__
351
- function splitPath(pathLike) {
352
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
353
- if (filepath === "") {
354
- return [];
355
- }
356
- return filepath.split(slashRegExp);
357
- }
358
- // @__NO_SIDE_EFFECTS__
359
- function trimLeadingDotSlash(pathLike) {
360
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
361
- if (filepath.startsWith("./") || filepath.startsWith(".\\")) {
362
- return filepath.slice(2);
363
- }
364
- return filepath;
365
- }
366
- // @__NO_SIDE_EFFECTS__
367
- function resolve(...segments) {
368
- let resolvedPath = "";
369
- let resolvedAbsolute = false;
370
- for (let i = segments.length - 1; i >= 0 && !resolvedAbsolute; i -= 1) {
371
- const segment = segments[i];
372
- if (typeof segment !== "string" || segment.length === 0) {
373
- continue;
374
- }
375
- resolvedPath = segment + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
376
- resolvedAbsolute = /* @__PURE__ */ isAbsolute(segment);
377
- }
378
- if (!resolvedAbsolute) {
379
- const cwd = /* @__PURE__ */ require("process").cwd();
380
- resolvedPath = cwd + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
381
- }
382
- return /* @__PURE__ */ normalizePath(resolvedPath);
383
- }
384
- // @__NO_SIDE_EFFECTS__
385
- function relative(from, to) {
386
- if (from === to) {
387
- return "";
388
- }
389
- const actualFrom = /* @__PURE__ */ resolve(from);
390
- const actualTo = /* @__PURE__ */ resolve(to);
391
- if (actualFrom === actualTo) {
392
- return "";
393
- }
394
- if (import_platform.WIN32) {
395
- const fromLower = actualFrom.toLowerCase();
396
- const toLower = actualTo.toLowerCase();
397
- if (fromLower === toLower) {
398
- return "";
399
- }
400
- }
401
- const fromStart = 1;
402
- const fromEnd = actualFrom.length;
403
- const fromLen = fromEnd - fromStart;
404
- const toStart = 1;
405
- const toEnd = actualTo.length;
406
- const toLen = toEnd - toStart;
407
- const length = fromLen < toLen ? fromLen : toLen;
408
- let lastCommonSep = -1;
409
- let i = 0;
410
- for (; i < length; i += 1) {
411
- let fromCode = actualFrom.charCodeAt(fromStart + i);
412
- let toCode = actualTo.charCodeAt(toStart + i);
413
- if (import_platform.WIN32) {
414
- if (fromCode >= CHAR_UPPERCASE_A && fromCode <= CHAR_UPPERCASE_Z) {
415
- fromCode += 32;
416
- }
417
- if (toCode >= CHAR_UPPERCASE_A && toCode <= CHAR_UPPERCASE_Z) {
418
- toCode += 32;
419
- }
420
- }
421
- if (fromCode !== toCode) {
422
- break;
423
- }
424
- if (/* @__PURE__ */ isPathSeparator(actualFrom.charCodeAt(fromStart + i))) {
425
- lastCommonSep = i;
426
- }
427
- }
428
- if (i === length) {
429
- if (toLen > length) {
430
- const toCode = actualTo.charCodeAt(toStart + i);
431
- if (/* @__PURE__ */ isPathSeparator(toCode)) {
432
- return actualTo.slice(toStart + i + 1);
433
- }
434
- if (i === 0) {
435
- return actualTo.slice(toStart + i);
436
- }
437
- } else if (fromLen > length) {
438
- const fromCode = actualFrom.charCodeAt(fromStart + i);
439
- if (/* @__PURE__ */ isPathSeparator(fromCode)) {
440
- lastCommonSep = i;
441
- } else if (i === 0) {
442
- lastCommonSep = 0;
443
- }
444
- }
445
- }
446
- let out = "";
447
- for (i = fromStart + lastCommonSep + 1; i <= fromEnd; i += 1) {
448
- const code = actualFrom.charCodeAt(i);
449
- if (i === fromEnd || /* @__PURE__ */ isPathSeparator(code)) {
450
- out += out.length === 0 ? ".." : "/..";
451
- }
452
- }
453
- return out + actualTo.slice(toStart + lastCommonSep);
454
- }
455
- // @__NO_SIDE_EFFECTS__
456
441
  function relativeResolve(from, to) {
457
442
  const rel = /* @__PURE__ */ relative(from, to);
458
443
  if (rel === "") {
@@ -461,6 +446,14 @@ function relativeResolve(from, to) {
461
446
  return /* @__PURE__ */ normalizePath(rel);
462
447
  }
463
448
  // @__NO_SIDE_EFFECTS__
449
+ function splitPath(pathLike) {
450
+ const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
451
+ if (filepath === "") {
452
+ return [];
453
+ }
454
+ return filepath.split(slashRegExp);
455
+ }
456
+ // @__NO_SIDE_EFFECTS__
464
457
  function toUnixPath(pathLike) {
465
458
  const normalized = /* @__PURE__ */ normalizePath(pathLike);
466
459
  if (import_platform.WIN32) {
@@ -471,6 +464,14 @@ function toUnixPath(pathLike) {
471
464
  }
472
465
  return normalized;
473
466
  }
467
+ // @__NO_SIDE_EFFECTS__
468
+ function trimLeadingDotSlash(pathLike) {
469
+ const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
470
+ if (filepath.startsWith("./") || filepath.startsWith(".\\")) {
471
+ return filepath.slice(2);
472
+ }
473
+ return filepath;
474
+ }
474
475
  // Annotate the CommonJS export names for ESM import in node:
475
476
  0 && (module.exports = {
476
477
  fromUnixPath,
@@ -1,10 +1,11 @@
1
+ /**
2
+ * @fileoverview Package.json path resolution utilities.
3
+ */
1
4
  /**
2
5
  * Resolve directory path from a package.json file path.
3
6
  */
4
- /*@__NO_SIDE_EFFECTS__*/
5
7
  export declare function resolvePackageJsonDirname(filepath: string): string;
6
8
  /**
7
9
  * Resolve full path to package.json from a directory or file path.
8
10
  */
9
- /*@__NO_SIDE_EFFECTS__*/
10
11
  export declare function resolvePackageJsonPath(filepath: string): 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;
@@ -28,7 +29,7 @@ let _path;
28
29
  // @__NO_SIDE_EFFECTS__
29
30
  function getPath() {
30
31
  if (_path === void 0) {
31
- _path = require("path");
32
+ _path = require("node:path");
32
33
  }
33
34
  return _path;
34
35
  }
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @fileoverview Path rewiring utilities for testing.
3
+ * Allows tests to override os.tmpdir() and os.homedir() without directly modifying them.
4
+ *
5
+ * Features:
6
+ * - Test-friendly setPath/clearPath/resetPaths that work in beforeEach/afterEach
7
+ * - Automatic cache invalidation for path-dependent modules
8
+ * - Thread-safe for concurrent test execution
9
+ */
1
10
  /**
2
11
  * Clear a specific path override.
3
12
  */
@@ -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;
@@ -29,14 +30,15 @@ __export(rewire_exports, {
29
30
  });
30
31
  module.exports = __toCommonJS(rewire_exports);
31
32
  const stateSymbol = Symbol.for("@socketsecurity/lib/paths/rewire/state");
32
- if (!globalThis[stateSymbol]) {
33
- globalThis[stateSymbol] = {
33
+ const _globalThis = globalThis;
34
+ if (!_globalThis[stateSymbol]) {
35
+ _globalThis[stateSymbol] = {
34
36
  testOverrides: /* @__PURE__ */ new Map(),
35
37
  valueCache: /* @__PURE__ */ new Map(),
36
38
  cacheInvalidationCallbacks: []
37
39
  };
38
40
  }
39
- const sharedState = globalThis[stateSymbol];
41
+ const sharedState = _globalThis[stateSymbol];
40
42
  const testOverrides = sharedState.testOverrides;
41
43
  const valueCache = sharedState.valueCache;
42
44
  const cacheInvalidationCallbacks = sharedState.cacheInvalidationCallbacks;
@@ -1,3 +1,17 @@
1
+ /**
2
+ * @fileoverview Path utilities for Socket ecosystem directories.
3
+ * Provides platform-aware path resolution for Socket tools' shared directory structure.
4
+ *
5
+ * Directory Structure:
6
+ * ~/.socket/
7
+ * ├── _cacache/ # Content-addressable cache for npm packages
8
+ * ├── _dlx/ # DLX installations (content-addressed by hash)
9
+ * │ ├── <hash>/ # npm package installs (dlx-package)
10
+ * │ └── <hash>/ # binary downloads (dlx-binary)
11
+ * ├── _socket/ # Socket CLI app directory
12
+ * ├── _registry/ # Socket Registry app directory
13
+ * └── _sfw/ # Socket Firewall app directory
14
+ */
1
15
  /**
2
16
  * Get the OS home directory.
3
17
  * Can be overridden in tests using setPath('homedir', ...) from paths/rewire.
@@ -9,22 +23,13 @@ export declare function getOsHomeDir(): string;
9
23
  */
10
24
  export declare function getOsTmpDir(): string;
11
25
  /**
12
- * Get the Socket home directory (~/.socket).
13
- * Alias for getSocketUserDir() for consistency across Socket projects.
26
+ * Get a Socket app cache directory (~/.socket/_<appName>/cache).
14
27
  */
15
- export declare function getSocketHomePath(): string;
28
+ export declare function getSocketAppCacheDir(appName: string): string;
16
29
  /**
17
- * Get the Socket user directory (~/.socket).
18
- * Can be overridden with SOCKET_HOME environment variable or via setPath() for testing.
19
- * Result is cached via getPathValue for performance.
20
- *
21
- * Priority order:
22
- * 1. Test override via setPath('socket-user-dir', ...)
23
- * 2. SOCKET_HOME - Base directory override
24
- * 3. Default: $HOME/.socket
25
- * 4. Fallback: /tmp/.socket (Unix) or %TEMP%\.socket (Windows)
30
+ * Get a Socket app TTL cache directory (~/.socket/_<appName>/cache/ttl).
26
31
  */
27
- export declare function getSocketUserDir(): string;
32
+ export declare function getSocketAppCacheTtlDir(appName: string): string;
28
33
  /**
29
34
  * Get a Socket app directory (~/.socket/_<appName>).
30
35
  */
@@ -40,6 +45,10 @@ export declare function getSocketAppDir(appName: string): string;
40
45
  * 3. Default: $SOCKET_HOME/_cacache or $HOME/.socket/_cacache
41
46
  */
42
47
  export declare function getSocketCacacheDir(): string;
48
+ /**
49
+ * Get the Socket CLI directory (~/.socket/_socket).
50
+ */
51
+ export declare function getSocketCliDir(): string;
43
52
  /**
44
53
  * Get the Socket DLX directory (~/.socket/_dlx).
45
54
  * Can be overridden with SOCKET_DLX_DIR environment variable or via setPath() for testing.
@@ -54,17 +63,10 @@ export declare function getSocketCacacheDir(): string;
54
63
  */
55
64
  export declare function getSocketDlxDir(): string;
56
65
  /**
57
- * Get a Socket app cache directory (~/.socket/_<appName>/cache).
58
- */
59
- export declare function getSocketAppCacheDir(appName: string): string;
60
- /**
61
- * Get a Socket app TTL cache directory (~/.socket/_<appName>/cache/ttl).
62
- */
63
- export declare function getSocketAppCacheTtlDir(appName: string): string;
64
- /**
65
- * Get the Socket CLI directory (~/.socket/_socket).
66
+ * Get the Socket home directory (~/.socket).
67
+ * Alias for getSocketUserDir() for consistency across Socket projects.
66
68
  */
67
- export declare function getSocketCliDir(): string;
69
+ export declare function getSocketHomePath(): string;
68
70
  /**
69
71
  * Get the Socket Registry directory (~/.socket/_registry).
70
72
  */
@@ -73,6 +75,18 @@ export declare function getSocketRegistryDir(): string;
73
75
  * Get the Socket Registry GitHub cache directory (~/.socket/_registry/cache/ttl/github).
74
76
  */
75
77
  export declare function getSocketRegistryGithubCacheDir(): string;
78
+ /**
79
+ * Get the Socket user directory (~/.socket).
80
+ * Can be overridden with SOCKET_HOME environment variable or via setPath() for testing.
81
+ * Result is cached via getPathValue for performance.
82
+ *
83
+ * Priority order:
84
+ * 1. Test override via setPath('socket-user-dir', ...)
85
+ * 2. SOCKET_HOME - Base directory override
86
+ * 3. Default: $HOME/.socket
87
+ * 4. Fallback: /tmp/.socket (Unix) or %TEMP%\.socket (Windows)
88
+ */
89
+ export declare function getSocketUserDir(): string;
76
90
  /**
77
91
  * Get the user's home directory.
78
92
  * Uses environment variables directly to support test mocking.
@@ -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;
@@ -43,18 +44,18 @@ var import_dirnames = require("./dirnames");
43
44
  var import_normalize = require("./normalize");
44
45
  var import_rewire = require("./rewire");
45
46
  let _os;
47
+ let _path;
46
48
  // @__NO_SIDE_EFFECTS__
47
49
  function getOs() {
48
50
  if (_os === void 0) {
49
- _os = require("os");
51
+ _os = require("node:os");
50
52
  }
51
53
  return _os;
52
54
  }
53
- let _path;
54
55
  // @__NO_SIDE_EFFECTS__
55
56
  function getPath() {
56
57
  if (_path === void 0) {
57
- _path = require("path");
58
+ _path = require("node:path");
58
59
  }
59
60
  return _path;
60
61
  }
@@ -64,17 +65,13 @@ function getOsHomeDir() {
64
65
  function getOsTmpDir() {
65
66
  return (0, import_rewire.getPathValue)("tmpdir", () => (/* @__PURE__ */ getOs()).tmpdir());
66
67
  }
67
- function getSocketHomePath() {
68
- return getSocketUserDir();
68
+ function getSocketAppCacheDir(appName) {
69
+ return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
69
70
  }
70
- function getSocketUserDir() {
71
- return (0, import_rewire.getPathValue)("socket-user-dir", () => {
72
- const socketHome = (0, import_socket2.getSocketHome)();
73
- if (socketHome) {
74
- return (0, import_normalize.normalizePath)(socketHome);
75
- }
76
- return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
77
- });
71
+ function getSocketAppCacheTtlDir(appName) {
72
+ return (0, import_normalize.normalizePath)(
73
+ (/* @__PURE__ */ getPath()).join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR)
74
+ );
78
75
  }
79
76
  function getSocketAppDir(appName) {
80
77
  return (0, import_normalize.normalizePath)(
@@ -83,14 +80,17 @@ function getSocketAppDir(appName) {
83
80
  }
84
81
  function getSocketCacacheDir() {
85
82
  return (0, import_rewire.getPathValue)("socket-cacache-dir", () => {
86
- if ((0, import_socket2.getSocketCacacheDir)()) {
87
- return (0, import_normalize.normalizePath)((0, import_socket2.getSocketCacacheDir)());
83
+ if ((0, import_socket2.getSocketCacacheDirEnv)()) {
84
+ return (0, import_normalize.normalizePath)((0, import_socket2.getSocketCacacheDirEnv)());
88
85
  }
89
86
  return (0, import_normalize.normalizePath)(
90
87
  (/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
91
88
  );
92
89
  });
93
90
  }
91
+ function getSocketCliDir() {
92
+ return getSocketAppDir(import_socket.SOCKET_CLI_APP_NAME);
93
+ }
94
94
  function getSocketDlxDir() {
95
95
  return (0, import_rewire.getPathValue)("socket-dlx-dir", () => {
96
96
  if ((0, import_socket2.getSocketDlxDirEnv)()) {
@@ -104,16 +104,8 @@ function getSocketDlxDir() {
104
104
  );
105
105
  });
106
106
  }
107
- function getSocketAppCacheDir(appName) {
108
- return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
109
- }
110
- function getSocketAppCacheTtlDir(appName) {
111
- return (0, import_normalize.normalizePath)(
112
- (/* @__PURE__ */ getPath()).join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR)
113
- );
114
- }
115
- function getSocketCliDir() {
116
- return getSocketAppDir(import_socket.SOCKET_CLI_APP_NAME);
107
+ function getSocketHomePath() {
108
+ return getSocketUserDir();
117
109
  }
118
110
  function getSocketRegistryDir() {
119
111
  return getSocketAppDir(import_socket.SOCKET_REGISTRY_APP_NAME);
@@ -126,6 +118,15 @@ function getSocketRegistryGithubCacheDir() {
126
118
  )
127
119
  );
128
120
  }
121
+ function getSocketUserDir() {
122
+ return (0, import_rewire.getPathValue)("socket-user-dir", () => {
123
+ const socketHome = (0, import_socket2.getSocketHome)();
124
+ if (socketHome) {
125
+ return (0, import_normalize.normalizePath)(socketHome);
126
+ }
127
+ return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
128
+ });
129
+ }
129
130
  function getUserHomeDir() {
130
131
  const home = (0, import_home.getHome)();
131
132
  if (home) {