@socketsecurity/lib 5.15.0 → 5.16.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 (84) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +2 -2
  3. package/dist/abort.d.ts +13 -0
  4. package/dist/agent.d.ts +81 -0
  5. package/dist/ansi.d.ts +13 -0
  6. package/dist/archives.d.ts +31 -0
  7. package/dist/argv/flags.d.ts +91 -0
  8. package/dist/argv/parse.d.ts +31 -0
  9. package/dist/bin.d.ts +54 -0
  10. package/dist/cacache.d.ts +38 -0
  11. package/dist/cache-with-ttl.d.ts +7 -0
  12. package/dist/colors.d.ts +12 -0
  13. package/dist/cover/formatters.d.ts +18 -0
  14. package/dist/debug.d.ts +6 -0
  15. package/dist/dlx/binary.d.ts +84 -0
  16. package/dist/dlx/cache.d.ts +6 -0
  17. package/dist/dlx/detect.d.ts +33 -0
  18. package/dist/dlx/dir.d.ts +34 -0
  19. package/dist/dlx/manifest.d.ts +16 -0
  20. package/dist/dlx/package.d.ts +43 -0
  21. package/dist/dlx/packages.d.ts +36 -0
  22. package/dist/dlx/paths.d.ts +20 -0
  23. package/dist/dlx/paths.js +1 -1
  24. package/dist/effects/pulse-frames.d.ts +6 -0
  25. package/dist/effects/text-shimmer.d.ts +9 -0
  26. package/dist/effects/ultra.d.ts +6 -0
  27. package/dist/env/ci.d.ts +14 -0
  28. package/dist/env/debug.d.ts +13 -0
  29. package/dist/env/github.d.ts +80 -0
  30. package/dist/env/helpers.d.ts +45 -0
  31. package/dist/env/home.d.ts +13 -0
  32. package/dist/env/locale.d.ts +30 -0
  33. package/dist/env/node-auth-token.d.ts +13 -0
  34. package/dist/env/node-env.d.ts +13 -0
  35. package/dist/env/npm.d.ts +50 -0
  36. package/dist/env/path.d.ts +13 -0
  37. package/dist/env/pre-commit.d.ts +14 -0
  38. package/dist/env/rewire.d.ts +38 -0
  39. package/dist/env/shell.d.ts +13 -0
  40. package/dist/env/socket-cli-shadow.d.ts +43 -0
  41. package/dist/env/socket-cli.d.ts +116 -0
  42. package/dist/env/socket.d.ts +153 -0
  43. package/dist/env/temp-dir.d.ts +30 -0
  44. package/dist/env/term.d.ts +13 -0
  45. package/dist/env/test.d.ts +32 -0
  46. package/dist/env/windows.d.ts +40 -0
  47. package/dist/env/xdg.d.ts +30 -0
  48. package/dist/env.d.ts +40 -0
  49. package/dist/external/npm-pack.js +202 -291
  50. package/dist/external/tar-fs.js +27 -7
  51. package/dist/fs.d.ts +13 -0
  52. package/dist/functions.d.ts +30 -0
  53. package/dist/globs.d.ts +27 -0
  54. package/dist/http-request.d.ts +16 -0
  55. package/dist/json/format.d.ts +18 -0
  56. package/dist/memoization.d.ts +5 -0
  57. package/dist/packages/edit.d.ts +28 -0
  58. package/dist/packages/exports.d.ts +40 -0
  59. package/dist/packages/licenses.d.ts +59 -0
  60. package/dist/packages/manifest.d.ts +18 -0
  61. package/dist/packages/normalize.d.ts +22 -0
  62. package/dist/packages/operations.d.ts +51 -0
  63. package/dist/packages/provenance.d.ts +11 -0
  64. package/dist/packages/specs.d.ts +30 -0
  65. package/dist/packages/validation.d.ts +18 -0
  66. package/dist/paths/normalize.d.ts +49 -5
  67. package/dist/paths/normalize.js +13 -0
  68. package/dist/paths/rewire.js +12 -3
  69. package/dist/regexps.d.ts +7 -0
  70. package/dist/releases/github.d.ts +63 -0
  71. package/dist/releases/socket-btm.d.ts +31 -0
  72. package/dist/sea.d.ts +15 -0
  73. package/dist/shadow.d.ts +7 -0
  74. package/dist/signal-exit.d.ts +27 -0
  75. package/dist/sorts.d.ts +33 -0
  76. package/dist/spawn.d.ts +9 -0
  77. package/dist/stdio/mask.d.ts +26 -0
  78. package/dist/streams.d.ts +28 -0
  79. package/dist/suppress-warnings.d.ts +7 -0
  80. package/dist/temporary-executor.d.ts +7 -0
  81. package/dist/url.d.ts +59 -0
  82. package/dist/versions.d.ts +119 -0
  83. package/dist/words.d.ts +20 -0
  84. package/package.json +7 -57
@@ -1,31 +1,65 @@
1
1
  import type { ExtractOptions, NormalizeOptions, PackageJson, PacoteOptions, ReadPackageJsonOptions } from '../packages';
2
2
  /**
3
3
  * Extract a package to a destination directory.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * await extractPackage('lodash@4.17.21', { dest: '/tmp/lodash' })
8
+ * ```
4
9
  */
5
10
  /*@__NO_SIDE_EFFECTS__*/
6
11
  export declare function extractPackage(pkgNameOrId: string, options?: ExtractOptions, callback?: (destPath: string) => Promise<unknown>): Promise<void>;
7
12
  /**
8
13
  * Find package extensions for a given package.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const extensions = findPackageExtensions('my-pkg', '1.0.0')
18
+ * ```
9
19
  */
10
20
  /*@__NO_SIDE_EFFECTS__*/
11
21
  export declare function findPackageExtensions(pkgName: string, pkgVer: string): unknown;
12
22
  /**
13
23
  * Get the release tag for a version.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * getReleaseTag('lodash@latest') // 'latest'
28
+ * getReleaseTag('@scope/pkg@beta') // 'beta'
29
+ * getReleaseTag('lodash') // ''
30
+ * ```
14
31
  */
15
32
  /*@__NO_SIDE_EFFECTS__*/
16
33
  export declare function getReleaseTag(spec: string): string;
17
34
  /**
18
35
  * Pack a package tarball using pacote.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const tarball = await packPackage('lodash@4.17.21')
40
+ * ```
19
41
  */
20
42
  /*@__NO_SIDE_EFFECTS__*/
21
43
  export declare function packPackage(spec: string, options?: PacoteOptions): Promise<unknown>;
22
44
  /**
23
45
  * Read and parse a package.json file asynchronously.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const pkgJson = await readPackageJson('/tmp/my-project')
50
+ * console.log(pkgJson?.name)
51
+ * ```
24
52
  */
25
53
  /*@__NO_SIDE_EFFECTS__*/
26
54
  export declare function readPackageJson(filepath: string, options?: ReadPackageJsonOptions): Promise<PackageJson | undefined>;
27
55
  /**
28
56
  * Read and parse package.json from a file path synchronously.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const pkgJson = readPackageJsonSync('/tmp/my-project')
61
+ * console.log(pkgJson?.name)
62
+ * ```
29
63
  */
30
64
  /*@__NO_SIDE_EFFECTS__*/
31
65
  export declare function readPackageJsonSync(filepath: string, options?: NormalizeOptions & {
@@ -34,11 +68,22 @@ export declare function readPackageJsonSync(filepath: string, options?: Normaliz
34
68
  }): PackageJson | undefined;
35
69
  /**
36
70
  * Resolve GitHub tarball URL for a package specifier.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const url = await resolveGitHubTgzUrl('my-pkg@1.0.0', '/tmp/my-project')
75
+ * ```
37
76
  */
38
77
  /*@__NO_SIDE_EFFECTS__*/
39
78
  export declare function resolveGitHubTgzUrl(pkgNameOrId: string, where?: unknown): Promise<string>;
40
79
  /**
41
80
  * Resolve full package name from a PURL object with custom delimiter.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * resolvePackageName({ name: 'core', namespace: '@babel' }) // '@babel/core'
85
+ * resolvePackageName({ name: 'lodash' }) // 'lodash'
86
+ * ```
42
87
  */
43
88
  /*@__NO_SIDE_EFFECTS__*/
44
89
  export declare function resolvePackageName(purlObj: {
@@ -47,6 +92,12 @@ export declare function resolvePackageName(purlObj: {
47
92
  }, delimiter?: string): string;
48
93
  /**
49
94
  * Convert npm package name to Socket registry format with delimiter.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * resolveRegistryPackageName('@babel/core') // 'babel__core'
99
+ * resolveRegistryPackageName('lodash') // 'lodash'
100
+ * ```
50
101
  */
51
102
  /*@__NO_SIDE_EFFECTS__*/
52
103
  export declare function resolveRegistryPackageName(pkgName: string): string;
@@ -1,10 +1,21 @@
1
1
  import type { ProvenanceOptions } from '../packages';
2
2
  /**
3
3
  * Convert raw attestation data to user-friendly provenance details.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const details = getProvenanceDetails(attestationData)
8
+ * // { level: 'trusted', repository: '...', commitSha: '...' }
9
+ * ```
4
10
  */
5
11
  export declare function getProvenanceDetails(attestationData: unknown): unknown;
6
12
  /**
7
13
  * Fetch package provenance information from npm registry.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const provenance = await fetchPackageProvenance('lodash', '4.17.21')
18
+ * ```
8
19
  */
9
20
  /*@__NO_SIDE_EFFECTS__*/
10
21
  export declare function fetchPackageProvenance(pkgName: string, pkgVersion: string, options?: ProvenanceOptions): Promise<unknown>;
@@ -1,5 +1,11 @@
1
1
  /**
2
2
  * Extract user and project from GitHub repository URL.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * getRepoUrlDetails('https://github.com/lodash/lodash.git')
7
+ * // { user: 'lodash', project: 'lodash' }
8
+ * ```
3
9
  */
4
10
  /*@__NO_SIDE_EFFECTS__*/
5
11
  export declare function getRepoUrlDetails(repoUrl?: string): {
@@ -8,21 +14,45 @@ export declare function getRepoUrlDetails(repoUrl?: string): {
8
14
  };
9
15
  /**
10
16
  * Generate GitHub API URL for a tag reference.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * gitHubTagRefUrl('lodash', 'lodash', 'v4.17.21')
21
+ * // 'https://api.github.com/repos/lodash/lodash/git/ref/tags/v4.17.21'
22
+ * ```
11
23
  */
12
24
  /*@__NO_SIDE_EFFECTS__*/
13
25
  export declare function gitHubTagRefUrl(user: string, project: string, tag: string): string;
14
26
  /**
15
27
  * Generate GitHub tarball download URL for a commit SHA.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * gitHubTgzUrl('lodash', 'lodash', 'abc123')
32
+ * // 'https://github.com/lodash/lodash/archive/abc123.tar.gz'
33
+ * ```
16
34
  */
17
35
  /*@__NO_SIDE_EFFECTS__*/
18
36
  export declare function gitHubTgzUrl(user: string, project: string, sha: string): string;
19
37
  /**
20
38
  * Check if a package specifier is a GitHub tarball URL.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * isGitHubTgzSpec('https://github.com/user/repo/archive/abc123.tar.gz') // true
43
+ * isGitHubTgzSpec('lodash@4.17.21') // false
44
+ * ```
21
45
  */
22
46
  /*@__NO_SIDE_EFFECTS__*/
23
47
  export declare function isGitHubTgzSpec(spec: unknown, where?: string): boolean;
24
48
  /**
25
49
  * Check if a package specifier is a GitHub URL with committish.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * isGitHubUrlSpec('github:user/repo#v1.0.0') // true
54
+ * isGitHubUrlSpec('lodash@4.17.21') // false
55
+ * ```
26
56
  */
27
57
  /*@__NO_SIDE_EFFECTS__*/
28
58
  export declare function isGitHubUrlSpec(spec: unknown, where?: string): boolean;
@@ -1,15 +1,33 @@
1
1
  /**
2
2
  * Check if package name is a blessed Socket.dev package.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * isBlessedPackageName('@socketregistry/is-number') // true
7
+ * isBlessedPackageName('lodash') // false
8
+ * ```
3
9
  */
4
10
  /*@__NO_SIDE_EFFECTS__*/
5
11
  export declare function isBlessedPackageName(name: unknown): boolean;
6
12
  /**
7
13
  * Check if a type string represents a registry fetcher type.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * isRegistryFetcherType('range') // true
18
+ * isRegistryFetcherType('git') // false
19
+ * ```
8
20
  */
9
21
  /*@__NO_SIDE_EFFECTS__*/
10
22
  export declare function isRegistryFetcherType(type: string): boolean;
11
23
  /**
12
24
  * Check if a package name is valid according to npm naming rules.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * isValidPackageName('my-package') // true
29
+ * isValidPackageName('.invalid') // false
30
+ * ```
13
31
  */
14
32
  /*@__NO_SIDE_EFFECTS__*/
15
33
  export declare function isValidPackageName(name: string): boolean;
@@ -141,6 +141,48 @@ export declare function isPath(pathLike: string | Buffer | URL): boolean;
141
141
  */
142
142
  /*@__NO_SIDE_EFFECTS__*/
143
143
  export declare function isRelative(pathLike: string | Buffer | URL): boolean;
144
+ /**
145
+ * Convert Unix-style POSIX paths (MSYS/Git Bash format) back to native Windows paths.
146
+ *
147
+ * This is the inverse of {@link toUnixPath}. MSYS-style paths use `/c/` notation
148
+ * for drive letters, which PowerShell and cmd.exe cannot resolve. This function
149
+ * converts them back to native Windows format.
150
+ *
151
+ * Conversion rules:
152
+ * - On Windows: Converts Unix drive notation to Windows drive letters
153
+ * - `/c/path/to/file` becomes `C:/path/to/file`
154
+ * - `/d/projects/app` becomes `D:/projects/app`
155
+ * - Drive letters are always uppercase in the output
156
+ * - On Unix: Returns the path unchanged (passes through normalization)
157
+ *
158
+ * This is particularly important for:
159
+ * - GitHub Actions runners where `command -v` returns MSYS paths
160
+ * - Tools like sfw that need to resolve real binary paths on Windows
161
+ * - Scripts that receive paths from Git Bash but need to pass them to native Windows tools
162
+ *
163
+ * @param {string | Buffer | URL} pathLike - The MSYS/Unix-style path to convert
164
+ * @returns {string} Native Windows path (e.g., `C:/path/to/file`) or normalized Unix path
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // MSYS drive letter paths
169
+ * fromUnixPath('/c/projects/app/file.txt') // 'C:/projects/app/file.txt'
170
+ * fromUnixPath('/d/projects/foo/bar') // 'D:/projects/foo/bar'
171
+ *
172
+ * // Non-drive Unix paths (unchanged)
173
+ * fromUnixPath('/tmp/build/output') // '/tmp/build/output'
174
+ * fromUnixPath('/usr/local/bin') // '/usr/local/bin'
175
+ *
176
+ * // Already Windows paths (unchanged)
177
+ * fromUnixPath('C:/Windows/System32') // 'C:/Windows/System32'
178
+ *
179
+ * // Edge cases
180
+ * fromUnixPath('/c') // 'C:/'
181
+ * fromUnixPath('') // '.'
182
+ * ```
183
+ */
184
+ /*@__NO_SIDE_EFFECTS__*/
185
+ export declare function fromUnixPath(pathLike: string | Buffer | URL): string;
144
186
  /**
145
187
  * Normalize a path by converting backslashes to forward slashes and collapsing segments.
146
188
  *
@@ -348,21 +390,23 @@ export declare function trimLeadingDotSlash(pathLike: string | Buffer | URL): st
348
390
  /*@__NO_SIDE_EFFECTS__*/
349
391
  export declare function relativeResolve(from: string, to: string): string;
350
392
  /**
351
- * Convert Windows paths to Unix-style POSIX paths for Git Bash tools.
393
+ * Convert Windows paths to MSYS/Unix-style POSIX paths for Git Bash tools.
352
394
  *
353
- * Git for Windows tools (like tar, git, etc.) expect POSIX-style paths with
354
- * forward slashes and Unix drive letter notation (/c/ instead of C:\).
395
+ * Git for Windows and MSYS2 tools (like tar, git, etc.) expect POSIX-style
396
+ * paths with forward slashes and Unix drive letter notation (/c/ instead of C:\).
355
397
  * This function handles the conversion for cross-platform compatibility.
356
398
  *
399
+ * This is the inverse of {@link fromUnixPath}.
400
+ *
357
401
  * Conversion rules:
358
402
  * - On Windows: Normalizes separators and converts drive letters
359
403
  * - `C:\path\to\file` becomes `/c/path/to/file`
360
- * - `D:/Users/name` becomes `/d/Users/name`
404
+ * - `D:/projects/app` becomes `/d/projects/app`
361
405
  * - Drive letters are always lowercase in the output
362
406
  * - On Unix: Returns the path unchanged (passes through normalization)
363
407
  *
364
408
  * This is particularly important for:
365
- * - Git Bash tools that interpret `D:\` as a remote hostname
409
+ * - MSYS2/Git Bash tools that interpret `D:\` as a remote hostname
366
410
  * - Cross-platform build scripts using tar, git archive, etc.
367
411
  * - CI/CD environments where Git for Windows is used
368
412
  *
@@ -19,6 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var normalize_exports = {};
21
21
  __export(normalize_exports, {
22
+ fromUnixPath: () => fromUnixPath,
22
23
  isAbsolute: () => isAbsolute,
23
24
  isNodeModules: () => isNodeModules,
24
25
  isPath: () => isPath,
@@ -130,6 +131,17 @@ function isRelative(pathLike) {
130
131
  return !/* @__PURE__ */ isAbsolute(filepath);
131
132
  }
132
133
  // @__NO_SIDE_EFFECTS__
134
+ function fromUnixPath(pathLike) {
135
+ const normalized = /* @__PURE__ */ normalizePath(pathLike);
136
+ if (import_platform.WIN32) {
137
+ return normalized.replace(
138
+ /^\/([a-zA-Z])(\/|$)/,
139
+ (_, letter, sep) => `${letter.toUpperCase()}:${sep || "/"}`
140
+ );
141
+ }
142
+ return normalized;
143
+ }
144
+ // @__NO_SIDE_EFFECTS__
133
145
  function normalizePath(pathLike) {
134
146
  const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
135
147
  const { length } = filepath;
@@ -448,6 +460,7 @@ function toUnixPath(pathLike) {
448
460
  }
449
461
  // Annotate the CommonJS export names for ESM import in node:
450
462
  0 && (module.exports = {
463
+ fromUnixPath,
451
464
  isAbsolute,
452
465
  isNodeModules,
453
466
  isPath,
@@ -28,9 +28,18 @@ __export(rewire_exports, {
28
28
  setPath: () => setPath
29
29
  });
30
30
  module.exports = __toCommonJS(rewire_exports);
31
- const testOverrides = /* @__PURE__ */ new Map();
32
- const valueCache = /* @__PURE__ */ new Map();
33
- const cacheInvalidationCallbacks = [];
31
+ const stateSymbol = Symbol.for("@socketsecurity/lib/paths/rewire/state");
32
+ if (!globalThis[stateSymbol]) {
33
+ globalThis[stateSymbol] = {
34
+ testOverrides: /* @__PURE__ */ new Map(),
35
+ valueCache: /* @__PURE__ */ new Map(),
36
+ cacheInvalidationCallbacks: []
37
+ };
38
+ }
39
+ const sharedState = globalThis[stateSymbol];
40
+ const testOverrides = sharedState.testOverrides;
41
+ const valueCache = sharedState.valueCache;
42
+ const cacheInvalidationCallbacks = sharedState.cacheInvalidationCallbacks;
34
43
  function clearPath(key) {
35
44
  testOverrides.delete(key);
36
45
  invalidateCaches();
package/dist/regexps.d.ts CHANGED
@@ -8,6 +8,13 @@
8
8
  // Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
9
  /**
10
10
  * Escape special characters in a string for use in a regular expression.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * escapeRegExp('foo.bar') // 'foo\\.bar'
15
+ * escapeRegExp('a+b*c?') // 'a\\+b\\*c\\?'
16
+ * new RegExp(escapeRegExp('[test]')) // /\[test\]/
17
+ * ```
11
18
  */
12
19
  /*@__NO_SIDE_EFFECTS__*/
13
20
  export declare function escapeRegExp(str: string): string;
@@ -75,6 +75,13 @@ export declare const SOCKET_BTM_REPO: {
75
75
  *
76
76
  * @param pattern - Pattern to match (string glob, prefix/suffix object, or RegExp)
77
77
  * @returns Function that tests if a string matches the pattern
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const isMatch = createAssetMatcher('tool-*-linux-x64')
82
+ * isMatch('tool-v1.0-linux-x64') // true
83
+ * isMatch('tool-v1.0-darwin-arm64') // false
84
+ * ```
78
85
  */
79
86
  export declare function createAssetMatcher(pattern: string | {
80
87
  prefix: string;
@@ -85,6 +92,16 @@ export declare function createAssetMatcher(pattern: string | {
85
92
  *
86
93
  * @param config - Download configuration
87
94
  * @returns Path to the downloaded binary
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const binaryPath = await downloadGitHubRelease({
99
+ * owner: 'SocketDev', repo: 'socket-btm',
100
+ * toolName: 'lief', toolPrefix: 'lief-',
101
+ * assetName: 'lief-linux-x64', binaryName: 'lief',
102
+ * platformArch: 'linux-x64',
103
+ * })
104
+ * ```
88
105
  */
89
106
  export declare function downloadGitHubRelease(config: DownloadGitHubReleaseConfig): Promise<string>;
90
107
  /**
@@ -96,6 +113,14 @@ export declare function downloadGitHubRelease(config: DownloadGitHubReleaseConfi
96
113
  * @param outputPath - Path to write the downloaded file
97
114
  * @param repoConfig - Repository configuration (owner/repo)
98
115
  * @param options - Additional options
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * await downloadReleaseAsset(
120
+ * 'v1.0.0', 'tool-linux-x64', '/tmp/tool',
121
+ * { owner: 'SocketDev', repo: 'socket-btm' },
122
+ * )
123
+ * ```
99
124
  */
100
125
  export declare function downloadReleaseAsset(tag: string, assetPattern: string | AssetPattern, outputPath: string, repoConfig: RepoConfig, options?: {
101
126
  quiet?: boolean;
@@ -105,6 +130,12 @@ export declare function downloadReleaseAsset(tag: string, assetPattern: string |
105
130
  * Checks GH_TOKEN or GITHUB_TOKEN environment variables.
106
131
  *
107
132
  * @returns Headers object with Authorization header if token exists.
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const headers = getAuthHeaders()
137
+ * // { Accept: 'application/vnd.github+json', Authorization: 'Bearer ...' }
138
+ * ```
108
139
  */
109
140
  export declare function getAuthHeaders(): Record<string, string>;
110
141
  /**
@@ -116,6 +147,14 @@ export declare function getAuthHeaders(): Record<string, string>;
116
147
  * @param options - Additional options
117
148
  * @param options.assetPattern - Optional pattern to filter releases by matching asset
118
149
  * @returns Latest release tag or null if not found
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const tag = await getLatestRelease('lief-', {
154
+ * owner: 'SocketDev', repo: 'socket-btm',
155
+ * })
156
+ * console.log(tag) // 'lief-2025-01-15-abc1234'
157
+ * ```
119
158
  */
120
159
  export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoConfig, options?: {
121
160
  assetPattern?: AssetPattern;
@@ -130,6 +169,14 @@ export declare function getLatestRelease(toolPrefix: string, repoConfig: RepoCon
130
169
  * @param repoConfig - Repository configuration (owner/repo)
131
170
  * @param options - Additional options
132
171
  * @returns Browser download URL for the asset
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const url = await getReleaseAssetUrl(
176
+ * 'v1.0.0', 'tool-linux-x64',
177
+ * { owner: 'SocketDev', repo: 'socket-btm' },
178
+ * )
179
+ * ```
133
180
  */
134
181
  export declare function getReleaseAssetUrl(tag: string, assetPattern: string | AssetPattern, repoConfig: RepoConfig, options?: {
135
182
  quiet?: boolean;
@@ -146,6 +193,14 @@ export declare function getReleaseAssetUrl(tag: string, assetPattern: string | A
146
193
  * @param options.quiet - Suppress log messages
147
194
  * @param options.cleanup - Remove downloaded zip file after extraction (default: true)
148
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
+ * ```
149
204
  */
150
205
  export declare function downloadAndExtractZip(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
151
206
  cleanup?: boolean;
@@ -166,6 +221,14 @@ export declare function downloadAndExtractZip(tag: string, assetPattern: string
166
221
  * @param options.strip - Strip leading path components (like tar --strip-components)
167
222
  * @param options.format - Archive format (auto-detected if not specified)
168
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
+ * ```
169
232
  */
170
233
  export declare function downloadAndExtractArchive(tag: string, assetPattern: string | AssetPattern, outputDir: string, repoConfig: RepoConfig, options?: {
171
234
  cleanup?: boolean;
@@ -65,6 +65,12 @@ export type SocketBtmReleaseConfig = SocketBtmBinaryConfig | SocketBtmAssetConfi
65
65
  * Returns undefined for non-Linux platforms.
66
66
  *
67
67
  * @returns 'musl', 'glibc', or undefined (for non-Linux)
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const libc = detectLibc()
72
+ * console.log(libc) // 'glibc', 'musl', or undefined
73
+ * ```
68
74
  */
69
75
  export declare function detectLibc(): Libc | undefined;
70
76
  /**
@@ -73,6 +79,13 @@ export declare function detectLibc(): Libc | undefined;
73
79
  * @param tool - Tool/package name for release matching (e.g., 'lief', 'curl')
74
80
  * @param options - Download configuration
75
81
  * @returns Path to the downloaded file
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const binPath = await downloadSocketBtmRelease('lief', {
86
+ * downloadDir: '/tmp/build/downloaded',
87
+ * })
88
+ * ```
76
89
  */
77
90
  export declare function downloadSocketBtmRelease(tool: string, options: SocketBtmReleaseConfig | undefined): Promise<string>;
78
91
  /**
@@ -83,6 +96,12 @@ export declare function downloadSocketBtmRelease(tool: string, options: SocketBt
83
96
  * @param arch - Target architecture
84
97
  * @param libc - Linux libc variant (optional)
85
98
  * @returns Asset name (e.g., 'binject-darwin-arm64', 'node-linux-x64-musl')
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * getBinaryAssetName('lief', 'linux', 'x64', 'musl')
103
+ * // 'lief-linux-x64-musl'
104
+ * ```
86
105
  */
87
106
  export declare function getBinaryAssetName(binaryBaseName: string, platform: Platform, arch: Arch, libc?: Libc | undefined): string;
88
107
  /**
@@ -91,6 +110,12 @@ export declare function getBinaryAssetName(binaryBaseName: string, platform: Pla
91
110
  * @param binaryBaseName - Binary basename (e.g., 'node', 'binject')
92
111
  * @param platform - Target platform
93
112
  * @returns Binary filename (e.g., 'node', 'node.exe')
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * getBinaryName('node', 'win32') // 'node.exe'
117
+ * getBinaryName('node', 'linux') // 'node'
118
+ * ```
94
119
  */
95
120
  export declare function getBinaryName(binaryBaseName: string, platform: Platform): string;
96
121
  /**
@@ -101,5 +126,11 @@ export declare function getBinaryName(binaryBaseName: string, platform: Platform
101
126
  * @param arch - Target architecture
102
127
  * @param libc - Linux libc variant (optional)
103
128
  * @returns Platform-arch identifier (e.g., 'darwin-arm64', 'linux-x64-musl', 'win-x64')
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * getPlatformArch('linux', 'x64', 'musl') // 'linux-x64-musl'
133
+ * getPlatformArch('darwin', 'arm64') // 'darwin-arm64'
134
+ * ```
104
135
  */
105
136
  export declare function getPlatformArch(platform: Platform, arch: Arch, libc?: Libc | undefined): string;
package/dist/sea.d.ts CHANGED
@@ -1,10 +1,25 @@
1
1
  /**
2
2
  * Get the current SEA binary path.
3
3
  * Only valid when running as a SEA binary.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const binPath = getSeaBinaryPath()
8
+ * if (binPath) {
9
+ * console.log(`Running as SEA binary: ${binPath}`)
10
+ * }
11
+ * ```
4
12
  */
5
13
  export declare function getSeaBinaryPath(): string | undefined;
6
14
  /**
7
15
  * Detect if the current process is running as a SEA binary.
8
16
  * Uses Node.js 24+ native API with caching for performance.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * if (isSeaBinary()) {
21
+ * console.log('Running as a Single Executable Application')
22
+ * }
23
+ * ```
9
24
  */
10
25
  export declare function isSeaBinary(): boolean;
package/dist/shadow.d.ts CHANGED
@@ -13,5 +13,12 @@ export interface ShadowInstallationOptions {
13
13
  * @param options.cwd - Current working directory path to check
14
14
  * @param options.win32 - Whether running on Windows
15
15
  * @returns true if shadow installation should be skipped
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * if (shouldSkipShadow(binPath, { cwd: process.cwd() })) {
20
+ * console.log('Skipping shadow binary installation')
21
+ * }
22
+ * ```
16
23
  */
17
24
  export declare function shouldSkipShadow(binPath: string, options?: ShadowInstallationOptions | undefined): boolean;
@@ -1,5 +1,11 @@
1
1
  /**
2
2
  * Load signal handlers and hook into process exit events.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * load()
7
+ * // Signal handlers are now active
8
+ * ```
3
9
  */
4
10
  /*@__NO_SIDE_EFFECTS__*/
5
11
  export declare function load(): void;
@@ -8,16 +14,37 @@ export interface OnExitOptions {
8
14
  }
9
15
  /**
10
16
  * Register a callback to run on process exit or signal.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const remove = onExit((code, signal) => {
21
+ * console.log(`Exiting with code ${code}, signal ${signal}`)
22
+ * })
23
+ * // Later, to unregister:
24
+ * remove()
25
+ * ```
11
26
  */
12
27
  /*@__NO_SIDE_EFFECTS__*/
13
28
  export declare function onExit(cb: (code: number | null, signal: string | null) => void, options?: OnExitOptions | undefined): () => void;
14
29
  /**
15
30
  * Get the list of signals that are currently being monitored.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const sigs = signals()
35
+ * console.log(sigs) // ['SIGABRT', 'SIGALRM', 'SIGHUP', ...]
36
+ * ```
16
37
  */
17
38
  /*@__NO_SIDE_EFFECTS__*/
18
39
  export declare function signals(): string[];
19
40
  /**
20
41
  * Unload signal handlers and restore original process behavior.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * unload()
46
+ * // Signal handlers are now removed
47
+ * ```
21
48
  */
22
49
  /*@__NO_SIDE_EFFECTS__*/
23
50
  export declare function unload(): void;