@socketsecurity/lib 5.8.1 → 5.9.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ 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.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.9.0) - 2026-03-14
9
+
10
+ ### Changed
11
+
12
+ - **releases/socket-btm**: `getPlatformArch()` now normalizes Windows platform to `win` instead of `win32`
13
+ - Returns `win-x64`, `win-arm64` instead of `win32-x64`, `win32-arm64`
14
+ - Consistent with `getBinaryAssetName()` which already uses `win` for Windows assets
15
+ - Aligns with socket-btm and Node.js convention: use `win` for file/folder names, `win32` for platform checks (`process.platform`)
16
+ - Added `PLATFORM_MAP` for explicit platform name mapping (darwin, linux, win32 → win)
17
+ - Now throws `Error: Unsupported platform` for unknown platform values
18
+
19
+ ## [5.8.2](https://github.com/SocketDev/socket-lib/releases/tag/v5.8.2) - 2026-03-13
20
+
21
+ ### Fixed
22
+
23
+ - **http-request**: Download to temp file then atomically rename to prevent corruption
24
+ - Downloads now write to `{destPath}.download` temp file first
25
+ - On success, atomically renames to the destination path
26
+ - On failure, cleans up temp file and preserves any existing file at destination
27
+ - Prevents partial/corrupted files from CI caching causing extraction failures
28
+
8
29
  ## [5.8.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.8.1) - 2026-03-11
9
30
 
10
31
  ### Performance
@@ -25,6 +25,7 @@ __export(http_request_exports, {
25
25
  httpText: () => httpText
26
26
  });
27
27
  module.exports = __toCommonJS(http_request_exports);
28
+ var import_fs = require("./fs.js");
28
29
  let _fs;
29
30
  // @__NO_SIDE_EFFECTS__
30
31
  function getFs() {
@@ -308,18 +309,31 @@ async function httpDownload(url, destPath, options) {
308
309
  }
309
310
  };
310
311
  }
312
+ const fs = /* @__PURE__ */ getFs();
313
+ const tempPath = `${destPath}.download`;
314
+ if (fs.existsSync(tempPath)) {
315
+ await (0, import_fs.safeDelete)(tempPath);
316
+ }
311
317
  let lastError;
312
318
  for (let attempt = 0; attempt <= retries; attempt++) {
313
319
  try {
314
- return await httpDownloadAttempt(url, destPath, {
320
+ const result = await httpDownloadAttempt(url, tempPath, {
315
321
  followRedirects,
316
322
  headers,
317
323
  maxRedirects,
318
324
  onProgress: progressCallback,
319
325
  timeout
320
326
  });
327
+ await fs.promises.rename(tempPath, destPath);
328
+ return {
329
+ path: destPath,
330
+ size: result.size
331
+ };
321
332
  } catch (e) {
322
333
  lastError = e;
334
+ if (fs.existsSync(tempPath)) {
335
+ await (0, import_fs.safeDelete)(tempPath);
336
+ }
323
337
  if (attempt === retries) {
324
338
  break;
325
339
  }
@@ -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.1",
3
+ "version": "5.9.0",
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.0",
737
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.8.2",
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",