@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,3 +1,7 @@
1
+ /**
2
+ * @fileoverview Promise utilities including chunked iteration and timers.
3
+ * Provides async control flow helpers and promise-based timing functions.
4
+ */
1
5
  /**
2
6
  * Configuration options for retry behavior with exponential backoff.
3
7
  *
@@ -30,8 +34,6 @@ export interface RetryOptions {
30
34
  * @default 200
31
35
  */
32
36
  baseDelayMs?: number | undefined;
33
- // REMOVED: Deprecated `factor` option
34
- // Migration: Use `backoffFactor` instead
35
37
  /**
36
38
  * Whether to apply randomness to spread out retries and avoid thundering herd.
37
39
  * When `true`, adds random delay between 0 and current delay value.
@@ -49,10 +51,6 @@ export interface RetryOptions {
49
51
  * @default 10000
50
52
  */
51
53
  maxDelayMs?: number | undefined;
52
- // REMOVED: Deprecated `maxTimeout` option
53
- // Migration: Use `maxDelayMs` instead
54
- // REMOVED: Deprecated `minTimeout` option
55
- // Migration: Use `baseDelayMs` instead
56
54
  /**
57
55
  * Callback invoked on each retry attempt.
58
56
  * Can observe errors, customize delays, or cancel retries.
@@ -180,7 +178,6 @@ export interface IterationOptions {
180
178
  * normalizeIterationOptions({ concurrency: 3, retries: 2 })
181
179
  * // => { concurrency: 3, retries: {...}, signal: AbortSignal }
182
180
  */
183
- /*@__NO_SIDE_EFFECTS__*/
184
181
  export declare function normalizeIterationOptions(options?: number | IterationOptions | undefined): {
185
182
  concurrency: number;
186
183
  retries: RetryOptions;
@@ -206,7 +203,6 @@ export declare function normalizeIterationOptions(options?: number | IterationOp
206
203
  * normalizeRetryOptions({ retries: 5, baseDelayMs: 500 })
207
204
  * // => { retries: 5, baseDelayMs: 500, backoffFactor: 2, jitter: true, ... }
208
205
  */
209
- /*@__NO_SIDE_EFFECTS__*/
210
206
  export declare function normalizeRetryOptions(options?: number | RetryOptions | undefined): RetryOptions;
211
207
  /**
212
208
  * Execute an async function for each array element with concurrency control.
@@ -244,50 +240,7 @@ export declare function normalizeRetryOptions(options?: number | RetryOptions |
244
240
  * signal: controller.signal
245
241
  * })
246
242
  */
247
- /*@__NO_SIDE_EFFECTS__*/
248
243
  export declare function pEach<T>(array: T[], callbackFn: (item: T) => Promise<unknown>, options?: number | IterationOptions | undefined): Promise<void>;
249
- /**
250
- * Filter an array asynchronously with concurrency control.
251
- *
252
- * Tests each element with an async predicate function, processing items in parallel
253
- * batches. Returns a new array with only items that pass the test. Similar to
254
- * `array.filter()` but for async predicates with controlled concurrency.
255
- *
256
- * @template T - The type of array elements
257
- * @param array - The array to filter
258
- * @param callbackFn - Async predicate function returning true to keep item
259
- * @param options - Concurrency as number, or full iteration options, or undefined
260
- * @returns Promise resolving to filtered array
261
- *
262
- * @example
263
- * // Filter serially
264
- * const activeUsers = await pFilter(users, async (user) => {
265
- * return await isUserActive(user.id)
266
- * })
267
- *
268
- * @example
269
- * // Filter with concurrency
270
- * const validFiles = await pFilter(filePaths, async (path) => {
271
- * try {
272
- * await fs.access(path)
273
- * return true
274
- * } catch {
275
- * return false
276
- * }
277
- * }, 10)
278
- *
279
- * @example
280
- * // With retries for flaky checks
281
- * const reachable = await pFilter(endpoints, async (url) => {
282
- * const response = await fetch(url)
283
- * return response.ok
284
- * }, {
285
- * concurrency: 5,
286
- * retries: 2
287
- * })
288
- */
289
- /*@__NO_SIDE_EFFECTS__*/
290
- export declare function pFilter<T>(array: T[], callbackFn: (item: T) => Promise<boolean>, options?: number | IterationOptions | undefined): Promise<T[]>;
291
244
  /**
292
245
  * Process array in chunks with an async callback.
293
246
  *
@@ -327,10 +280,45 @@ export declare function pFilter<T>(array: T[], callbackFn: (item: T) => Promise<
327
280
  * signal: controller.signal
328
281
  * })
329
282
  */
330
- /*@__NO_SIDE_EFFECTS__*/
331
283
  export declare function pEachChunk<T>(array: T[], callbackFn: (chunk: T[]) => Promise<unknown>, options?: (RetryOptions & {
332
284
  chunkSize?: number | undefined;
333
285
  }) | undefined): Promise<void>;
286
+ /**
287
+ * Filter an array asynchronously with concurrency control.
288
+ *
289
+ * Tests each element with an async predicate function, processing items in parallel
290
+ * batches. Returns a new array with only items that pass the test. Similar to
291
+ * `array.filter()` but for async predicates with controlled concurrency.
292
+ *
293
+ * @template T - The type of array elements
294
+ * @param array - The array to filter
295
+ * @param callbackFn - Async predicate function returning true to keep item
296
+ * @param options - Concurrency as number, or full iteration options, or undefined
297
+ * @returns Promise resolving to filtered array
298
+ *
299
+ * @example
300
+ * // Filter serially
301
+ * const activeUsers = await pFilter(users, async (user) => {
302
+ * return await isUserActive(user.id)
303
+ * })
304
+ *
305
+ * @example
306
+ * // Filter with concurrency
307
+ * const validFiles = await pFilter(filePaths, async (path) => {
308
+ * return existsSync(path)
309
+ * }, 10)
310
+ *
311
+ * @example
312
+ * // With retries for flaky checks
313
+ * const reachable = await pFilter(endpoints, async (url) => {
314
+ * const response = await fetch(url)
315
+ * return response.ok
316
+ * }, {
317
+ * concurrency: 5,
318
+ * retries: 2
319
+ * })
320
+ */
321
+ export declare function pFilter<T>(array: T[], callbackFn: (item: T) => Promise<boolean>, options?: number | IterationOptions | undefined): Promise<T[]>;
334
322
  /**
335
323
  * Filter chunked arrays with an async predicate.
336
324
  *
@@ -348,7 +336,6 @@ export declare function pEachChunk<T>(array: T[], callbackFn: (chunk: T[]) => Pr
348
336
  * const filtered = await pFilterChunk(chunks, async (n) => n % 2 === 0)
349
337
  * // => [[2], [4], [6]]
350
338
  */
351
- /*@__NO_SIDE_EFFECTS__*/
352
339
  export declare function pFilterChunk<T>(chunks: T[][], callbackFn: (value: T) => Promise<boolean>, options?: number | RetryOptions | undefined): Promise<T[][]>;
353
340
  /**
354
341
  * Retry an async function with exponential backoff.
@@ -434,7 +421,6 @@ export declare function pFilterChunk<T>(chunks: T[][], callbackFn: (value: T) =>
434
421
  * }
435
422
  * )
436
423
  */
437
- /*@__NO_SIDE_EFFECTS__*/
438
424
  export declare function pRetry<T>(callbackFn: (...args: unknown[]) => Promise<T>, options?: number | RetryOptions | undefined): Promise<T | undefined>;
439
425
  /**
440
426
  * Resolve retry options from various input formats.
@@ -453,5 +439,4 @@ export declare function pRetry<T>(callbackFn: (...args: unknown[]) => Promise<T>
453
439
  * resolveRetryOptions({ retries: 5, maxTimeout: 5000 })
454
440
  * // => { retries: 5, minTimeout: 200, maxTimeout: 5000, factor: 2 }
455
441
  */
456
- /*@__NO_SIDE_EFFECTS__*/
457
442
  export declare function resolveRetryOptions(options?: number | RetryOptions | undefined): RetryOptions;
package/dist/promises.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;
@@ -29,15 +30,15 @@ __export(promises_exports, {
29
30
  resolveRetryOptions: () => resolveRetryOptions
30
31
  });
31
32
  module.exports = __toCommonJS(promises_exports);
33
+ var import_arrays = require("./arrays");
32
34
  var import_core = require("./constants/core");
33
35
  var import_process = require("./constants/process");
34
- var import_arrays = require("./arrays");
35
36
  const abortSignal = (0, import_process.getAbortSignal)();
36
37
  let _timers;
37
38
  // @__NO_SIDE_EFFECTS__
38
39
  function getTimers() {
39
40
  if (_timers === void 0) {
40
- _timers = require("timers/promises");
41
+ _timers = require("node:timers/promises");
41
42
  }
42
43
  return _timers;
43
44
  }
@@ -121,15 +122,6 @@ async function pEach(array, callbackFn, options) {
121
122
  }
122
123
  }
123
124
  // @__NO_SIDE_EFFECTS__
124
- async function pFilter(array, callbackFn, options) {
125
- const iterOpts = /* @__PURE__ */ normalizeIterationOptions(options);
126
- return (await /* @__PURE__ */ pFilterChunk(
127
- (0, import_arrays.arrayChunk)(array, iterOpts.concurrency),
128
- callbackFn,
129
- iterOpts.retries
130
- )).flat();
131
- }
132
- // @__NO_SIDE_EFFECTS__
133
125
  async function pEachChunk(array, callbackFn, options) {
134
126
  const { chunkSize = 100, ...retryOpts } = options || {};
135
127
  const chunks = (0, import_arrays.arrayChunk)(array, chunkSize);
@@ -146,6 +138,15 @@ async function pEachChunk(array, callbackFn, options) {
146
138
  }
147
139
  }
148
140
  // @__NO_SIDE_EFFECTS__
141
+ async function pFilter(array, callbackFn, options) {
142
+ const iterOpts = /* @__PURE__ */ normalizeIterationOptions(options);
143
+ return (await /* @__PURE__ */ pFilterChunk(
144
+ (0, import_arrays.arrayChunk)(array, iterOpts.concurrency),
145
+ callbackFn,
146
+ iterOpts.retries
147
+ )).flat();
148
+ }
149
+ // @__NO_SIDE_EFFECTS__
149
150
  async function pFilterChunk(chunks, callbackFn, options) {
150
151
  const retryOpts = /* @__PURE__ */ normalizeRetryOptions(options);
151
152
  const { signal } = retryOpts;
package/dist/regexps.d.ts CHANGED
@@ -2,10 +2,6 @@
2
2
  * @fileoverview Regular expression utilities including escape-string-regexp implementation.
3
3
  * Provides regex escaping and pattern matching helpers.
4
4
  */
5
- // Inlined escape-string-regexp:
6
- // https://socket.dev/npm/package/escape-string-regexp/overview/5.0.0
7
- // MIT License
8
- // Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
5
  /**
10
6
  * Escape special characters in a string for use in a regular expression.
11
7
  *
@@ -16,5 +12,4 @@
16
12
  * new RegExp(escapeRegExp('[test]')) // /\[test\]/
17
13
  * ```
18
14
  */
19
- /*@__NO_SIDE_EFFECTS__*/
20
15
  export declare function escapeRegExp(str: string): string;
package/dist/regexps.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,4 +1,7 @@
1
- import { type ArchiveFormat } from '../archives.js';
1
+ /**
2
+ * @fileoverview GitHub release download utilities.
3
+ */
4
+ import { type ArchiveFormat } from '../archives';
2
5
  /**
3
6
  * Pattern for matching release assets.
4
7
  * Can be either:
@@ -62,13 +65,6 @@ export interface RepoConfig {
62
65
  */
63
66
  repo: string;
64
67
  }
65
- /**
66
- * Socket-btm GitHub repository configuration.
67
- */
68
- export declare const SOCKET_BTM_REPO: {
69
- readonly owner: "SocketDev";
70
- readonly repo: "socket-btm";
71
- };
72
68
  /**
73
69
  * Create a matcher function for a pattern using picomatch for glob patterns
74
70
  * or simple prefix/suffix matching for object patterns.
@@ -87,6 +83,61 @@ export declare function createAssetMatcher(pattern: string | {
87
83
  prefix: string;
88
84
  suffix: string;
89
85
  } | RegExp): (input: string) => boolean;
86
+ /**
87
+ * Download and extract an archive from a GitHub release.
88
+ * Supports zip, tar, tar.gz, and tgz formats.
89
+ * Automatically handles downloading, extracting, and cleanup.
90
+ *
91
+ * @param tag - Release tag name
92
+ * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
93
+ * @param outputDir - Directory to extract the archive contents to
94
+ * @param repoConfig - Repository configuration (owner/repo)
95
+ * @param options - Additional options
96
+ * @param options.quiet - Suppress log messages
97
+ * @param options.cleanup - Remove downloaded archive after extraction (default: true)
98
+ * @param options.strip - Strip leading path components (like tar --strip-components)
99
+ * @param options.format - Archive format (auto-detected if not specified)
100
+ * @returns Path to the extraction directory
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const outputDir = await downloadAndExtractArchive(
105
+ * 'v1.0.0', 'data-*.tar.gz', '/tmp/data',
106
+ * { owner: 'SocketDev', repo: 'socket-btm' },
107
+ * )
108
+ * ```
109
+ */
110
+ export declare function downloadAndExtractArchive(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
111
+ cleanup?: boolean;
112
+ format?: ArchiveFormat;
113
+ quiet?: boolean;
114
+ strip?: number;
115
+ }): Promise<string>;
116
+ /**
117
+ * Download and extract a zip file from a GitHub release.
118
+ * Automatically handles downloading, extracting, and cleanup.
119
+ *
120
+ * @param tag - Release tag name
121
+ * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
122
+ * @param outputDir - Directory to extract the zip contents to
123
+ * @param repoConfig - Repository configuration (owner/repo)
124
+ * @param options - Additional options
125
+ * @param options.quiet - Suppress log messages
126
+ * @param options.cleanup - Remove downloaded zip file after extraction (default: true)
127
+ * @returns Path to the extraction directory
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const outputDir = await downloadAndExtractZip(
132
+ * 'v1.0.0', 'models-*.zip', '/tmp/models',
133
+ * { owner: 'SocketDev', repo: 'socket-btm' },
134
+ * )
135
+ * ```
136
+ */
137
+ export declare function downloadAndExtractZip(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
138
+ cleanup?: boolean;
139
+ quiet?: boolean;
140
+ }): Promise<string>;
90
141
  /**
91
142
  * Download a binary from any GitHub repository with version caching.
92
143
  *
@@ -181,58 +232,3 @@ export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoCon
181
232
  export declare function getReleaseAssetUrl(tag: string, assetPattern: string | AssetPattern, repoConfig: RepoConfig, options?: {
182
233
  quiet?: boolean;
183
234
  }): Promise<string | null>;
184
- /**
185
- * Download and extract a zip file from a GitHub release.
186
- * Automatically handles downloading, extracting, and cleanup.
187
- *
188
- * @param tag - Release tag name
189
- * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
190
- * @param outputDir - Directory to extract the zip contents to
191
- * @param repoConfig - Repository configuration (owner/repo)
192
- * @param options - Additional options
193
- * @param options.quiet - Suppress log messages
194
- * @param options.cleanup - Remove downloaded zip file after extraction (default: true)
195
- * @returns Path to the extraction directory
196
- *
197
- * @example
198
- * ```typescript
199
- * const outputDir = await downloadAndExtractZip(
200
- * 'v1.0.0', 'models-*.zip', '/tmp/models',
201
- * { owner: 'SocketDev', repo: 'socket-btm' },
202
- * )
203
- * ```
204
- */
205
- export declare function downloadAndExtractZip(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
206
- cleanup?: boolean;
207
- quiet?: boolean;
208
- }): Promise<string>;
209
- /**
210
- * Download and extract an archive from a GitHub release.
211
- * Supports zip, tar, tar.gz, and tgz formats.
212
- * Automatically handles downloading, extracting, and cleanup.
213
- *
214
- * @param tag - Release tag name
215
- * @param assetPattern - Asset name or pattern (glob string, prefix/suffix object, or RegExp)
216
- * @param outputDir - Directory to extract the archive contents to
217
- * @param repoConfig - Repository configuration (owner/repo)
218
- * @param options - Additional options
219
- * @param options.quiet - Suppress log messages
220
- * @param options.cleanup - Remove downloaded archive after extraction (default: true)
221
- * @param options.strip - Strip leading path components (like tar --strip-components)
222
- * @param options.format - Archive format (auto-detected if not specified)
223
- * @returns Path to the extraction directory
224
- *
225
- * @example
226
- * ```typescript
227
- * const outputDir = await downloadAndExtractArchive(
228
- * 'v1.0.0', 'data-*.tar.gz', '/tmp/data',
229
- * { owner: 'SocketDev', repo: 'socket-btm' },
230
- * )
231
- * ```
232
- */
233
- export declare function downloadAndExtractArchive(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
234
- cleanup?: boolean;
235
- format?: ArchiveFormat;
236
- quiet?: boolean;
237
- strip?: number;
238
- }): Promise<string>;
@@ -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;
@@ -29,7 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
31
  var github_exports = {};
31
32
  __export(github_exports, {
32
- SOCKET_BTM_REPO: () => SOCKET_BTM_REPO,
33
33
  createAssetMatcher: () => createAssetMatcher,
34
34
  downloadAndExtractArchive: () => downloadAndExtractArchive,
35
35
  downloadAndExtractZip: () => downloadAndExtractZip,
@@ -41,13 +41,13 @@ __export(github_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(github_exports);
43
43
  var import_node_process = __toESM(require("node:process"));
44
- var import_picomatch = __toESM(require("../external/picomatch.js"));
45
- var import_archives = require("../archives.js");
46
- var import_fs = require("../fs.js");
47
- var import_http_request = require("../http-request.js");
48
- var import_logger = require("../logger.js");
49
- var import_promises = require("../promises.js");
50
- var import_spawn = require("../spawn.js");
44
+ var import_picomatch = __toESM(require("../external/picomatch"));
45
+ var import_archives = require("../archives");
46
+ var import_fs = require("../fs");
47
+ var import_http_request = require("../http-request");
48
+ var import_logger = require("../logger");
49
+ var import_promises = require("../promises");
50
+ var import_spawn = require("../spawn");
51
51
  const RETRY_CONFIG = Object.freeze({
52
52
  __proto__: null,
53
53
  // Exponential backoff: delay doubles with each retry (5s, 10s, 20s).
@@ -57,24 +57,20 @@ const RETRY_CONFIG = Object.freeze({
57
57
  // Maximum number of retry attempts (excluding initial request).
58
58
  retries: 2
59
59
  });
60
- const SOCKET_BTM_REPO = {
61
- owner: "SocketDev",
62
- repo: "socket-btm"
63
- };
64
60
  const logger = (0, import_logger.getDefaultLogger)();
65
61
  let _fs;
66
62
  let _path;
67
63
  // @__NO_SIDE_EFFECTS__
68
64
  function getFs() {
69
65
  if (_fs === void 0) {
70
- _fs = require("fs");
66
+ _fs = require("node:fs");
71
67
  }
72
68
  return _fs;
73
69
  }
74
70
  // @__NO_SIDE_EFFECTS__
75
71
  function getPath() {
76
72
  if (_path === void 0) {
77
- _path = require("path");
73
+ _path = require("node:path");
78
74
  }
79
75
  return _path;
80
76
  }
@@ -89,6 +85,89 @@ function createAssetMatcher(pattern) {
89
85
  const { prefix, suffix } = pattern;
90
86
  return (input) => input.startsWith(prefix) && input.endsWith(suffix);
91
87
  }
88
+ async function downloadAndExtractArchive(tag, assetPattern, outputDir, repoConfig, options = {}) {
89
+ const { cleanup = true, format, quiet = false, strip } = options;
90
+ const path = /* @__PURE__ */ getPath();
91
+ const fs = /* @__PURE__ */ getFs();
92
+ await (0, import_fs.safeMkdir)(outputDir);
93
+ let ext = ".archive";
94
+ if (format) {
95
+ ext = format === "tar.gz" ? ".tar.gz" : `.${format}`;
96
+ } else if (typeof assetPattern === "string") {
97
+ const detectedFormat = (0, import_archives.detectArchiveFormat)(assetPattern);
98
+ if (detectedFormat) {
99
+ ext = detectedFormat === "tar.gz" ? ".tar.gz" : `.${detectedFormat}`;
100
+ }
101
+ }
102
+ const archivePath = path.join(outputDir, `__temp_download__${ext}`);
103
+ if (!quiet) {
104
+ logger.info(`Downloading archive from release ${tag}...`);
105
+ }
106
+ await downloadReleaseAsset(tag, assetPattern, archivePath, repoConfig, {
107
+ quiet
108
+ });
109
+ if (!quiet) {
110
+ logger.info(`Extracting archive to ${outputDir}...`);
111
+ }
112
+ try {
113
+ await (0, import_archives.extractArchive)(archivePath, outputDir, { quiet, strip });
114
+ if (!quiet) {
115
+ logger.info(`Extracted archive contents to ${outputDir}`);
116
+ }
117
+ } catch (cause) {
118
+ throw new Error(`Failed to extract archive: ${archivePath}`, { cause });
119
+ } finally {
120
+ if (cleanup) {
121
+ try {
122
+ await fs.promises.unlink(archivePath);
123
+ if (!quiet) {
124
+ logger.info("Cleaned up temporary archive file");
125
+ }
126
+ } catch (error) {
127
+ if (!quiet) {
128
+ logger.warn(`Failed to cleanup archive file: ${error}`);
129
+ }
130
+ }
131
+ }
132
+ }
133
+ return outputDir;
134
+ }
135
+ async function downloadAndExtractZip(tag, assetPattern, outputDir, repoConfig, options = {}) {
136
+ const { cleanup = true, quiet = false } = options;
137
+ const path = /* @__PURE__ */ getPath();
138
+ const fs = /* @__PURE__ */ getFs();
139
+ await (0, import_fs.safeMkdir)(outputDir);
140
+ const zipPath = path.join(outputDir, "__temp_download__.zip");
141
+ if (!quiet) {
142
+ logger.info(`Downloading zip asset from release ${tag}...`);
143
+ }
144
+ await downloadReleaseAsset(tag, assetPattern, zipPath, repoConfig, { quiet });
145
+ if (!quiet) {
146
+ logger.info(`Extracting zip to ${outputDir}...`);
147
+ }
148
+ try {
149
+ await (0, import_archives.extractArchive)(zipPath, outputDir, { quiet });
150
+ if (!quiet) {
151
+ logger.info(`Extracted zip contents to ${outputDir}`);
152
+ }
153
+ } catch (cause) {
154
+ throw new Error(`Failed to extract zip file: ${zipPath}`, { cause });
155
+ } finally {
156
+ if (cleanup) {
157
+ try {
158
+ await fs.promises.unlink(zipPath);
159
+ if (!quiet) {
160
+ logger.info("Cleaned up temporary zip file");
161
+ }
162
+ } catch (error) {
163
+ if (!quiet) {
164
+ logger.warn(`Failed to cleanup zip file: ${error}`);
165
+ }
166
+ }
167
+ }
168
+ }
169
+ return outputDir;
170
+ }
92
171
  async function downloadGitHubRelease(config) {
93
172
  const {
94
173
  assetName,
@@ -268,7 +347,7 @@ async function getLatestRelease(toolPrefix, repoConfig, options = {}) {
268
347
  return void 0;
269
348
  }
270
349
  }
271
- );
350
+ ) ?? null;
272
351
  }
273
352
  async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
274
353
  const { owner, repo } = repoConfig;
@@ -322,94 +401,10 @@ async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
322
401
  return void 0;
323
402
  }
324
403
  }
325
- );
326
- }
327
- async function downloadAndExtractZip(tag, assetPattern, outputDir, repoConfig, options = {}) {
328
- const { cleanup = true, quiet = false } = options;
329
- const path = /* @__PURE__ */ getPath();
330
- const fs = /* @__PURE__ */ getFs();
331
- await (0, import_fs.safeMkdir)(outputDir);
332
- const zipPath = path.join(outputDir, "__temp_download__.zip");
333
- if (!quiet) {
334
- logger.info(`Downloading zip asset from release ${tag}...`);
335
- }
336
- await downloadReleaseAsset(tag, assetPattern, zipPath, repoConfig, { quiet });
337
- if (!quiet) {
338
- logger.info(`Extracting zip to ${outputDir}...`);
339
- }
340
- try {
341
- await (0, import_archives.extractArchive)(zipPath, outputDir, { quiet });
342
- if (!quiet) {
343
- logger.info(`Extracted zip contents to ${outputDir}`);
344
- }
345
- } catch (cause) {
346
- throw new Error(`Failed to extract zip file: ${zipPath}`, { cause });
347
- } finally {
348
- if (cleanup) {
349
- try {
350
- await fs.promises.unlink(zipPath);
351
- if (!quiet) {
352
- logger.info("Cleaned up temporary zip file");
353
- }
354
- } catch (error) {
355
- if (!quiet) {
356
- logger.warn(`Failed to cleanup zip file: ${error}`);
357
- }
358
- }
359
- }
360
- }
361
- return outputDir;
362
- }
363
- async function downloadAndExtractArchive(tag, assetPattern, outputDir, repoConfig, options = {}) {
364
- const { cleanup = true, format, quiet = false, strip } = options;
365
- const path = /* @__PURE__ */ getPath();
366
- const fs = /* @__PURE__ */ getFs();
367
- await (0, import_fs.safeMkdir)(outputDir);
368
- let ext = ".archive";
369
- if (format) {
370
- ext = format === "tar.gz" ? ".tar.gz" : `.${format}`;
371
- } else if (typeof assetPattern === "string") {
372
- const detectedFormat = (0, import_archives.detectArchiveFormat)(assetPattern);
373
- if (detectedFormat) {
374
- ext = detectedFormat === "tar.gz" ? ".tar.gz" : `.${detectedFormat}`;
375
- }
376
- }
377
- const archivePath = path.join(outputDir, `__temp_download__${ext}`);
378
- if (!quiet) {
379
- logger.info(`Downloading archive from release ${tag}...`);
380
- }
381
- await downloadReleaseAsset(tag, assetPattern, archivePath, repoConfig, {
382
- quiet
383
- });
384
- if (!quiet) {
385
- logger.info(`Extracting archive to ${outputDir}...`);
386
- }
387
- try {
388
- await (0, import_archives.extractArchive)(archivePath, outputDir, { quiet, strip });
389
- if (!quiet) {
390
- logger.info(`Extracted archive contents to ${outputDir}`);
391
- }
392
- } catch (cause) {
393
- throw new Error(`Failed to extract archive: ${archivePath}`, { cause });
394
- } finally {
395
- if (cleanup) {
396
- try {
397
- await fs.promises.unlink(archivePath);
398
- if (!quiet) {
399
- logger.info("Cleaned up temporary archive file");
400
- }
401
- } catch (error) {
402
- if (!quiet) {
403
- logger.warn(`Failed to cleanup archive file: ${error}`);
404
- }
405
- }
406
- }
407
- }
408
- return outputDir;
404
+ ) ?? null;
409
405
  }
410
406
  // Annotate the CommonJS export names for ESM import in node:
411
407
  0 && (module.exports = {
412
- SOCKET_BTM_REPO,
413
408
  createAssetMatcher,
414
409
  downloadAndExtractArchive,
415
410
  downloadAndExtractZip,
@@ -1,9 +1,16 @@
1
1
  /**
2
2
  * @fileoverview Socket-btm release download utilities.
3
3
  */
4
- import { type Arch, type Libc, type Platform } from '../constants/platform.js';
5
- import { type AssetPattern } from './github.js';
4
+ import { type Arch, type Libc, type Platform } from '../constants/platform';
5
+ import { type AssetPattern } from './github';
6
6
  export type { Arch, Libc, Platform };
7
+ /**
8
+ * Socket-btm GitHub repository configuration.
9
+ */
10
+ export declare const SOCKET_BTM_REPO: {
11
+ readonly owner: 'SocketDev';
12
+ readonly repo: 'socket-btm';
13
+ };
7
14
  /**
8
15
  * Configuration for downloading socket-btm generic assets.
9
16
  */