@socketsecurity/lib 5.9.1 → 5.10.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,20 @@ 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.10.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.10.0) - 2026-03-14
9
+
10
+ ### Changed
11
+
12
+ - **releases/socket-btm**: Refactored `downloadSocketBtmRelease()` API for caller-controlled download paths
13
+ - Tool name moved from config object to required first parameter
14
+ - Config object is now optional second parameter (was required)
15
+ - Removed automatic `/${toolName}/${platformArch}` directory nesting - callers now have full control over download directory structure
16
+ - All optional parameters in config types now explicitly typed as `| undefined`
17
+ - Migration example:
18
+ - Before: `downloadSocketBtmRelease({ tool: 'lief', downloadDir: 'build' })`
19
+ - After: `downloadSocketBtmRelease('lief', { downloadDir: 'build' })`
20
+ - Rationale: Previous automatic path nesting created unexpected directory structures (e.g., `build/downloaded/lief/darwin-arm64/lief/assets/`) making it impossible for callers to predict exact file locations
21
+
8
22
  ## [5.9.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.9.1) - 2026-03-14
9
23
 
10
24
  ### Fixed
@@ -121,7 +121,7 @@ async function downloadGitHubRelease(config) {
121
121
  }
122
122
  const path = /* @__PURE__ */ getPath();
123
123
  const resolvedDownloadDir = path.isAbsolute(downloadDir) ? downloadDir : path.join(cwd, downloadDir);
124
- const binaryDir = path.join(resolvedDownloadDir, toolName, platformArch);
124
+ const binaryDir = resolvedDownloadDir;
125
125
  const binaryPath = path.join(binaryDir, binaryName);
126
126
  const versionPath = path.join(binaryDir, ".version");
127
127
  const fs = /* @__PURE__ */ getFs();
@@ -13,25 +13,23 @@ export interface SocketBtmAssetConfig {
13
13
  /** @internal Discriminator fields */
14
14
  bin?: never;
15
15
  /** Working directory (defaults to process.cwd()). */
16
- cwd?: string;
16
+ cwd?: string | undefined;
17
17
  /** Download destination directory. @default 'build/downloaded' */
18
- downloadDir?: string;
18
+ downloadDir?: string | undefined;
19
19
  /** @internal Discriminator fields */
20
20
  libc?: never;
21
21
  /** Output filename. @default resolved asset name */
22
- output?: string;
22
+ output?: string | undefined;
23
23
  /** Suppress log messages. @default false */
24
- quiet?: boolean;
24
+ quiet?: boolean | undefined;
25
25
  /** Remove macOS quarantine attribute after download. @default false */
26
- removeMacOSQuarantine?: boolean;
26
+ removeMacOSQuarantine?: boolean | undefined;
27
27
  /** Specific release tag to download. */
28
- tag?: string;
28
+ tag?: string | undefined;
29
29
  /** @internal Discriminator fields */
30
30
  targetArch?: never;
31
31
  /** @internal Discriminator fields */
32
32
  targetPlatform?: never;
33
- /** Tool/package name for directory structure and release matching. */
34
- tool: string;
35
33
  }
36
34
  /**
37
35
  * Configuration for downloading socket-btm binary releases.
@@ -40,25 +38,23 @@ export interface SocketBtmBinaryConfig {
40
38
  /** @internal Discriminator field */
41
39
  asset?: never;
42
40
  /** Binary/executable name (without extension). @default tool */
43
- bin?: string;
41
+ bin?: string | undefined;
44
42
  /** Working directory (defaults to process.cwd()). */
45
- cwd?: string;
43
+ cwd?: string | undefined;
46
44
  /** Download destination directory. @default 'build/downloaded' */
47
- downloadDir?: string;
45
+ downloadDir?: string | undefined;
48
46
  /** Linux libc variant. Auto-detected if not specified. */
49
- libc?: Libc;
47
+ libc?: Libc | undefined;
50
48
  /** Suppress log messages. @default false */
51
- quiet?: boolean;
49
+ quiet?: boolean | undefined;
52
50
  /** Remove macOS quarantine attribute after download. @default true */
53
- removeMacOSQuarantine?: boolean;
51
+ removeMacOSQuarantine?: boolean | undefined;
54
52
  /** Specific release tag to download. */
55
- tag?: string;
53
+ tag?: string | undefined;
56
54
  /** Target architecture (defaults to current arch). */
57
- targetArch?: Arch;
55
+ targetArch?: Arch | undefined;
58
56
  /** Target platform (defaults to current platform). */
59
- targetPlatform?: Platform;
60
- /** Tool/package name for directory structure and release matching. */
61
- tool: string;
57
+ targetPlatform?: Platform | undefined;
62
58
  }
63
59
  /**
64
60
  * Configuration for downloading socket-btm releases (binary or asset).
@@ -74,10 +70,11 @@ export declare function detectLibc(): Libc | undefined;
74
70
  /**
75
71
  * Download a release from socket-btm.
76
72
  *
77
- * @param config - Download configuration
73
+ * @param tool - Tool/package name for release matching (e.g., 'lief', 'curl')
74
+ * @param options - Download configuration
78
75
  * @returns Path to the downloaded file
79
76
  */
80
- export declare function downloadSocketBtmRelease(config: SocketBtmReleaseConfig): Promise<string>;
77
+ export declare function downloadSocketBtmRelease(tool: string, options: SocketBtmReleaseConfig | undefined): Promise<string>;
81
78
  /**
82
79
  * Get asset name for a socket-btm binary.
83
80
  *
@@ -69,16 +69,17 @@ function detectLibc() {
69
69
  return "glibc";
70
70
  }
71
71
  }
72
- async function downloadSocketBtmRelease(config) {
73
- const { cwd, downloadDir, quiet = false, tag, tool } = config;
72
+ async function downloadSocketBtmRelease(tool, options) {
73
+ const config = Object.assign(/* @__PURE__ */ Object.create(null), options);
74
+ const { cwd, downloadDir, quiet = false, tag } = config;
74
75
  const toolPrefix = `${tool}-`;
75
76
  let downloadConfig;
76
- if ("asset" in config) {
77
- const {
78
- asset,
79
- output,
80
- removeMacOSQuarantine = false
81
- } = config;
77
+ if (options && "asset" in options) {
78
+ const assetConfig = Object.assign(
79
+ /* @__PURE__ */ Object.create(null),
80
+ options
81
+ );
82
+ const { asset, output, removeMacOSQuarantine = false } = assetConfig;
82
83
  let resolvedAsset;
83
84
  let resolvedTag = tag;
84
85
  const isExactMatch = typeof asset === "string" && !asset.includes("*");
@@ -127,13 +128,17 @@ async function downloadSocketBtmRelease(config) {
127
128
  removeMacOSQuarantine
128
129
  };
129
130
  } else {
131
+ const binaryConfig = Object.assign(
132
+ /* @__PURE__ */ Object.create(null),
133
+ options
134
+ );
130
135
  const {
131
136
  bin,
132
137
  libc = detectLibc(),
133
138
  removeMacOSQuarantine = true,
134
139
  targetArch = (0, import_platform.getArch)(),
135
140
  targetPlatform = (0, import_platform.getPlatform)()
136
- } = config;
141
+ } = binaryConfig;
137
142
  const baseName = bin || tool;
138
143
  const assetName = getBinaryAssetName(
139
144
  baseName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "5.9.1",
3
+ "version": "5.10.0",
4
4
  "packageManager": "pnpm@10.32.1",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",