@socketsecurity/lib 5.15.0 → 5.17.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 +21 -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 +81 -5
  67. package/dist/paths/normalize.js +29 -2
  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,75 @@ 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
+ * Check if a path uses MSYS/Git Bash Unix-style drive letter notation.
146
+ *
147
+ * Detects paths in the format `/c/...` where a single letter after the leading
148
+ * slash represents a Windows drive letter. These paths are produced by MSYS2,
149
+ * Git Bash, and `command -v` on Windows.
150
+ *
151
+ * Detection rules:
152
+ * - Must start with `/` followed by a single ASCII letter (a-z, A-Z)
153
+ * - The letter must be followed by `/` or be at the end of the string
154
+ * - Examples: `/c/tools/bin`, `/d/projects`, `/c`
155
+ * - Non-matches: `/tmp`, `/usr/local`, `C:/Windows`
156
+ *
157
+ * @param {string | Buffer | URL} pathLike - The path to check
158
+ * @returns {boolean} `true` if the path uses MSYS drive letter notation
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * // MSYS drive letter paths
163
+ * isUnixPath('/c/tools/bin') // true
164
+ * isUnixPath('/d/projects/app') // true
165
+ * isUnixPath('/c') // true
166
+ * isUnixPath('/C/Windows') // true
167
+ *
168
+ * // Not MSYS drive paths
169
+ * isUnixPath('/tmp/build') // false
170
+ * isUnixPath('/usr/local/bin') // false
171
+ * isUnixPath('C:/Windows') // false
172
+ * isUnixPath('./relative') // false
173
+ * isUnixPath('') // false
174
+ * ```
175
+ */
176
+ /*@__NO_SIDE_EFFECTS__*/
177
+ export declare function isUnixPath(pathLike: string | Buffer | URL): boolean;
178
+ /**
179
+ * Convert Unix-style POSIX paths to native Windows paths.
180
+ *
181
+ * This is the inverse of {@link toUnixPath}. On Windows, MSYS-style paths use
182
+ * `/c/` notation for drive letters and forward slashes, which PowerShell and
183
+ * cmd.exe cannot resolve. This function converts them to native Windows format
184
+ * with backslashes and proper drive letters.
185
+ *
186
+ * Conversion rules:
187
+ * - On Windows: Converts drive notation and separators to native format
188
+ * - `/c/path/to/file` becomes `C:\path\to\file`
189
+ * - `/d/projects/app` becomes `D:\projects\app`
190
+ * - Forward slashes become backslashes
191
+ * - Drive letters are always uppercase in the output
192
+ * - On Unix: Returns the normalized path unchanged (forward slashes preserved)
193
+ *
194
+ * @param {string | Buffer | URL} pathLike - The MSYS/Unix-style path to convert
195
+ * @returns {string} Native Windows path (e.g., `C:\path\to\file`) or normalized Unix path
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * // MSYS drive letter paths (Windows)
200
+ * fromUnixPath('/c/projects/app/file.txt') // 'C:\\projects\\app\\file.txt'
201
+ * fromUnixPath('/d/projects/foo/bar') // 'D:\\projects\\foo\\bar'
202
+ * fromUnixPath('/c') // 'C:\\'
203
+ *
204
+ * // Forward-slash paths (Windows)
205
+ * fromUnixPath('C:/Windows/System32') // 'C:\\Windows\\System32'
206
+ *
207
+ * // Unix (unchanged, forward slashes preserved)
208
+ * fromUnixPath('/tmp/build/output') // '/tmp/build/output'
209
+ * ```
210
+ */
211
+ /*@__NO_SIDE_EFFECTS__*/
212
+ export declare function fromUnixPath(pathLike: string | Buffer | URL): string;
144
213
  /**
145
214
  * Normalize a path by converting backslashes to forward slashes and collapsing segments.
146
215
  *
@@ -154,6 +223,7 @@ export declare function isRelative(pathLike: string | Buffer | URL): boolean;
154
223
  * - Returns `.` for empty or collapsed paths
155
224
  *
156
225
  * Special handling:
226
+ * - MSYS drive letters (Windows only): `/c/path` becomes `C:/path`
157
227
  * - UNC paths: Maintains double leading slashes for `//server/share` format
158
228
  * - Windows namespaces: Preserves `//./` and `//?/` prefixes
159
229
  * - Leading `..` segments: Preserved in relative paths without prefix
@@ -180,6 +250,10 @@ export declare function isRelative(pathLike: string | Buffer | URL): boolean;
180
250
  * normalizePath('C:\\Users\\username\\file.txt') // 'C:/Users/username/file.txt'
181
251
  * normalizePath('foo\\bar\\baz') // 'foo/bar/baz'
182
252
  *
253
+ * // MSYS drive letters (Windows only)
254
+ * normalizePath('/c/projects/app') // 'C:/projects/app' (on Windows)
255
+ * normalizePath('/d/tools/bin') // 'D:/tools/bin' (on Windows)
256
+ *
183
257
  * // UNC paths
184
258
  * normalizePath('\\\\server\\share\\file') // '//server/share/file'
185
259
  *
@@ -348,21 +422,23 @@ export declare function trimLeadingDotSlash(pathLike: string | Buffer | URL): st
348
422
  /*@__NO_SIDE_EFFECTS__*/
349
423
  export declare function relativeResolve(from: string, to: string): string;
350
424
  /**
351
- * Convert Windows paths to Unix-style POSIX paths for Git Bash tools.
425
+ * Convert Windows paths to MSYS/Unix-style POSIX paths for Git Bash tools.
352
426
  *
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:\).
427
+ * Git for Windows and MSYS2 tools (like tar, git, etc.) expect POSIX-style
428
+ * paths with forward slashes and Unix drive letter notation (/c/ instead of C:\).
355
429
  * This function handles the conversion for cross-platform compatibility.
356
430
  *
431
+ * This is the inverse of {@link fromUnixPath}.
432
+ *
357
433
  * Conversion rules:
358
434
  * - On Windows: Normalizes separators and converts drive letters
359
435
  * - `C:\path\to\file` becomes `/c/path/to/file`
360
- * - `D:/Users/name` becomes `/d/Users/name`
436
+ * - `D:/projects/app` becomes `/d/projects/app`
361
437
  * - Drive letters are always lowercase in the output
362
438
  * - On Unix: Returns the path unchanged (passes through normalization)
363
439
  *
364
440
  * This is particularly important for:
365
- * - Git Bash tools that interpret `D:\` as a remote hostname
441
+ * - MSYS2/Git Bash tools that interpret `D:\` as a remote hostname
366
442
  * - Cross-platform build scripts using tar, git archive, etc.
367
443
  * - CI/CD environments where Git for Windows is used
368
444
  *
@@ -19,10 +19,12 @@ 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,
25
26
  isRelative: () => isRelative,
27
+ isUnixPath: () => isUnixPath,
26
28
  normalizePath: () => normalizePath,
27
29
  pathLikeToString: () => pathLikeToString,
28
30
  relativeResolve: () => relativeResolve,
@@ -40,6 +42,7 @@ const CHAR_LOWERCASE_A = 97;
40
42
  const CHAR_LOWERCASE_Z = 122;
41
43
  const CHAR_UPPERCASE_A = 65;
42
44
  const CHAR_UPPERCASE_Z = 90;
45
+ const msysDriveRegExp = /^\/([a-zA-Z])(\/|$)/;
43
46
  const slashRegExp = /[/\\]/;
44
47
  const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
45
48
  // @__NO_SIDE_EFFECTS__
@@ -66,6 +69,15 @@ function getUrl() {
66
69
  }
67
70
  return _url;
68
71
  }
72
+ function msysDriveToNative(normalized) {
73
+ if (import_platform.WIN32) {
74
+ return normalized.replace(
75
+ msysDriveRegExp,
76
+ (_, letter, sep) => `${letter.toUpperCase()}:${sep || "/"}`
77
+ );
78
+ }
79
+ return normalized;
80
+ }
69
81
  // @__NO_SIDE_EFFECTS__
70
82
  function isNodeModules(pathLike) {
71
83
  const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
@@ -130,6 +142,19 @@ function isRelative(pathLike) {
130
142
  return !/* @__PURE__ */ isAbsolute(filepath);
131
143
  }
132
144
  // @__NO_SIDE_EFFECTS__
145
+ function isUnixPath(pathLike) {
146
+ const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
147
+ return typeof filepath === "string" && msysDriveRegExp.test(filepath);
148
+ }
149
+ // @__NO_SIDE_EFFECTS__
150
+ function fromUnixPath(pathLike) {
151
+ const normalized = /* @__PURE__ */ normalizePath(pathLike);
152
+ if (import_platform.WIN32) {
153
+ return normalized.replace(/\//g, "\\");
154
+ }
155
+ return normalized;
156
+ }
157
+ // @__NO_SIDE_EFFECTS__
133
158
  function normalizePath(pathLike) {
134
159
  const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
135
160
  const { length } = filepath;
@@ -207,7 +232,7 @@ function normalizePath(pathLike) {
207
232
  if (segment === "..") {
208
233
  return prefix ? prefix.slice(0, -1) || "/" : "..";
209
234
  }
210
- return prefix + segment;
235
+ return msysDriveToNative(prefix + segment);
211
236
  }
212
237
  let collapsed = "";
213
238
  let segmentCount = 0;
@@ -288,7 +313,7 @@ function normalizePath(pathLike) {
288
313
  if (collapsed.length === 0) {
289
314
  return prefix || ".";
290
315
  }
291
- return prefix + collapsed;
316
+ return msysDriveToNative(prefix + collapsed);
292
317
  }
293
318
  // @__NO_SIDE_EFFECTS__
294
319
  function pathLikeToString(pathLike) {
@@ -448,10 +473,12 @@ function toUnixPath(pathLike) {
448
473
  }
449
474
  // Annotate the CommonJS export names for ESM import in node:
450
475
  0 && (module.exports = {
476
+ fromUnixPath,
451
477
  isAbsolute,
452
478
  isNodeModules,
453
479
  isPath,
454
480
  isRelative,
481
+ isUnixPath,
455
482
  normalizePath,
456
483
  pathLikeToString,
457
484
  relativeResolve,
@@ -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;