@socketsecurity/lib 5.8.2 → 5.9.1

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.9.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.9.1) - 2026-03-14
9
+
10
+ ### Fixed
11
+
12
+ - **fs**: `safeDelete()` and `safeDeleteSync()` now properly implement retry logic
13
+ - Previously `maxRetries` was incorrectly passed as `concurrency` to del (parallelism, not retries)
14
+ - `safeDelete()` now wraps `deleteAsync()` with `pRetry()` for exponential backoff
15
+ - `safeDeleteSync()` implements sync retry loop with `Atomics.wait()` for non-blocking sleep
16
+ - Both use `backoffFactor: 2` (delay doubles each retry: 200ms → 400ms → 800ms by default)
17
+ - `maxRetries` and `retryDelay` options in `RemoveOptions` now work as documented
18
+
19
+ ## [5.9.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.9.0) - 2026-03-14
20
+
21
+ ### Changed
22
+
23
+ - **releases/socket-btm**: `getPlatformArch()` now normalizes Windows platform to `win` instead of `win32`
24
+ - Returns `win-x64`, `win-arm64` instead of `win32-x64`, `win32-arm64`
25
+ - Consistent with `getBinaryAssetName()` which already uses `win` for Windows assets
26
+ - Aligns with socket-btm and Node.js convention: use `win` for file/folder names, `win32` for platform checks (`process.platform`)
27
+ - Added `PLATFORM_MAP` for explicit platform name mapping (darwin, linux, win32 → win)
28
+ - Now throws `Error: Unsupported platform` for unknown platform values
29
+
8
30
  ## [5.8.2](https://github.com/SocketDev/socket-lib/releases/tag/v5.8.2) - 2026-03-13
9
31
 
10
32
  ### Fixed
package/dist/fs.js CHANGED
@@ -53,6 +53,7 @@ module.exports = __toCommonJS(fs_exports);
53
53
  var import_process = require("./constants/process");
54
54
  var import_arrays = require("./arrays");
55
55
  var import_del = require("./external/del");
56
+ var import_promises = require("./promises");
56
57
  var import_globs = require("./globs");
57
58
  var import_parse = require("./json/parse");
58
59
  var import_objects = require("./objects");
@@ -527,12 +528,23 @@ async function safeDelete(filepath, options) {
527
528
  shouldForce = true;
528
529
  }
529
530
  }
530
- await (0, import_del.deleteAsync)(patterns, {
531
- concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
532
- dryRun: false,
533
- force: shouldForce,
534
- onlyFiles: false
535
- });
531
+ const maxRetries = opts.maxRetries ?? defaultRemoveOptions.maxRetries;
532
+ const retryDelay = opts.retryDelay ?? defaultRemoveOptions.retryDelay;
533
+ await (0, import_promises.pRetry)(
534
+ async () => {
535
+ await (0, import_del.deleteAsync)(patterns, {
536
+ dryRun: false,
537
+ force: shouldForce,
538
+ onlyFiles: false
539
+ });
540
+ },
541
+ {
542
+ retries: maxRetries,
543
+ baseDelayMs: retryDelay,
544
+ backoffFactor: 2,
545
+ signal: opts.signal
546
+ }
547
+ );
536
548
  }
537
549
  function safeDeleteSync(filepath, options) {
538
550
  const opts = { __proto__: null, ...options };
@@ -557,12 +569,30 @@ function safeDeleteSync(filepath, options) {
557
569
  shouldForce = true;
558
570
  }
559
571
  }
560
- (0, import_del.deleteSync)(patterns, {
561
- concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
562
- dryRun: false,
563
- force: shouldForce,
564
- onlyFiles: false
565
- });
572
+ const maxRetries = opts.maxRetries ?? defaultRemoveOptions.maxRetries;
573
+ const retryDelay = opts.retryDelay ?? defaultRemoveOptions.retryDelay;
574
+ let lastError;
575
+ let delay = retryDelay;
576
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
577
+ try {
578
+ (0, import_del.deleteSync)(patterns, {
579
+ dryRun: false,
580
+ force: shouldForce,
581
+ onlyFiles: false
582
+ });
583
+ return;
584
+ } catch (error) {
585
+ lastError = error;
586
+ if (attempt < maxRetries) {
587
+ const waitMs = delay;
588
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, waitMs);
589
+ delay *= 2;
590
+ }
591
+ }
592
+ }
593
+ if (lastError) {
594
+ throw lastError;
595
+ }
566
596
  }
567
597
  async function safeMkdir(path, options) {
568
598
  const fs = /* @__PURE__ */ getFs();
@@ -98,10 +98,11 @@ export declare function getBinaryAssetName(binaryBaseName: string, platform: Pla
98
98
  export declare function getBinaryName(binaryBaseName: string, platform: Platform): string;
99
99
  /**
100
100
  * Get platform-arch identifier for directory structure.
101
+ * Uses 'win' instead of 'win32' for file/folder names.
101
102
  *
102
103
  * @param platform - Target platform
103
104
  * @param arch - Target architecture
104
105
  * @param libc - Linux libc variant (optional)
105
- * @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl')
106
+ * @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl', 'win-x64')
106
107
  */
107
108
  export declare function getPlatformArch(platform: Platform, arch: Arch, libc?: Libc | undefined): string;
@@ -28,6 +28,12 @@ __export(socket_btm_exports, {
28
28
  module.exports = __toCommonJS(socket_btm_exports);
29
29
  var import_platform = require("../constants/platform.js");
30
30
  var import_github = require("./github.js");
31
+ const PLATFORM_MAP = {
32
+ __proto__: null,
33
+ darwin: "darwin",
34
+ linux: "linux",
35
+ win32: "win"
36
+ };
31
37
  const ARCH_MAP = {
32
38
  __proto__: null,
33
39
  arm64: "arm64",
@@ -176,12 +182,16 @@ function getBinaryName(binaryBaseName, platform) {
176
182
  return platform === "win32" ? `${binaryBaseName}.exe` : binaryBaseName;
177
183
  }
178
184
  function getPlatformArch(platform, arch, libc) {
185
+ const mappedPlatform = PLATFORM_MAP[platform];
186
+ if (!mappedPlatform) {
187
+ throw new Error(`Unsupported platform: ${platform}`);
188
+ }
179
189
  const mappedArch = ARCH_MAP[arch];
180
190
  if (!mappedArch) {
181
191
  throw new Error(`Unsupported architecture: ${arch}`);
182
192
  }
183
193
  const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
184
- return `${platform}-${mappedArch}${muslSuffix}`;
194
+ return `${mappedPlatform}-${mappedArch}${muslSuffix}`;
185
195
  }
186
196
  // Annotate the CommonJS export names for ESM import in node:
187
197
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "5.8.2",
3
+ "version": "5.9.1",
4
4
  "packageManager": "pnpm@10.32.1",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",
@@ -734,7 +734,7 @@
734
734
  "@socketregistry/is-unicode-supported": "1.0.5",
735
735
  "@socketregistry/packageurl-js": "1.3.5",
736
736
  "@socketregistry/yocto-spinner": "1.0.25",
737
- "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.8.1",
737
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.9.0",
738
738
  "@types/node": "24.9.2",
739
739
  "@typescript/native-preview": "7.0.0-dev.20250920.1",
740
740
  "@vitest/coverage-v8": "4.0.3",