@socketsecurity/lib 5.18.2 → 5.19.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.
Files changed (296) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +6 -5
  3. package/dist/abort.d.ts +3 -0
  4. package/dist/abort.js +1 -0
  5. package/dist/agent.d.ts +66 -49
  6. package/dist/agent.js +51 -50
  7. package/dist/ansi.d.ts +2 -5
  8. package/dist/ansi.js +3 -2
  9. package/dist/archives.d.ts +25 -21
  10. package/dist/archives.js +35 -34
  11. package/dist/argv/flags.d.ts +100 -91
  12. package/dist/argv/flags.js +88 -87
  13. package/dist/argv/parse.d.ts +30 -40
  14. package/dist/argv/parse.js +33 -32
  15. package/dist/arrays.d.ts +4 -8
  16. package/dist/arrays.js +1 -0
  17. package/dist/bin.d.ts +7 -5
  18. package/dist/bin.js +52 -29
  19. package/dist/cacache.d.ts +13 -12
  20. package/dist/cacache.js +9 -8
  21. package/dist/cache-with-ttl.d.ts +53 -35
  22. package/dist/cache-with-ttl.js +1 -0
  23. package/dist/colors.d.ts +5 -5
  24. package/dist/colors.js +1 -0
  25. package/dist/constants/agents.d.ts +5 -9
  26. package/dist/constants/agents.js +3 -2
  27. package/dist/constants/core.d.ts +5 -10
  28. package/dist/constants/core.js +2 -1
  29. package/dist/constants/encoding.d.ts +3 -3
  30. package/dist/constants/encoding.js +1 -0
  31. package/dist/constants/github.d.ts +3 -3
  32. package/dist/constants/github.js +1 -0
  33. package/dist/constants/licenses.d.ts +9 -2
  34. package/dist/constants/licenses.js +1 -0
  35. package/dist/constants/lifecycle-script-names.js +1 -0
  36. package/dist/constants/maintained-node-versions.d.ts +3 -0
  37. package/dist/constants/maintained-node-versions.js +1 -0
  38. package/dist/constants/node.d.ts +125 -16
  39. package/dist/constants/node.js +74 -73
  40. package/dist/constants/package-default-node-range.d.ts +3 -1
  41. package/dist/constants/package-default-node-range.js +2 -1
  42. package/dist/constants/package-default-socket-categories.d.ts +0 -1
  43. package/dist/constants/package-default-socket-categories.js +1 -0
  44. package/dist/constants/packages.d.ts +12 -17
  45. package/dist/constants/packages.js +31 -16
  46. package/dist/constants/platform.d.ts +1 -2
  47. package/dist/constants/platform.js +2 -1
  48. package/dist/constants/process.d.ts +18 -0
  49. package/dist/constants/process.js +1 -0
  50. package/dist/constants/socket.d.ts +4 -10
  51. package/dist/constants/socket.js +2 -1
  52. package/dist/constants/testing.d.ts +3 -3
  53. package/dist/constants/testing.js +1 -0
  54. package/dist/constants/time.d.ts +3 -4
  55. package/dist/constants/time.js +1 -0
  56. package/dist/constants/typescript.d.ts +10 -3
  57. package/dist/constants/typescript.js +5 -4
  58. package/dist/cover/code.d.ts +3 -0
  59. package/dist/cover/code.js +12 -12
  60. package/dist/cover/formatters.d.ts +12 -9
  61. package/dist/cover/formatters.js +19 -18
  62. package/dist/cover/type.d.ts +3 -0
  63. package/dist/cover/type.js +1 -0
  64. package/dist/cover/types.js +1 -0
  65. package/dist/debug.d.ts +32 -47
  66. package/dist/debug.js +97 -96
  67. package/dist/dlx/arborist.d.ts +134 -0
  68. package/dist/dlx/arborist.js +177 -0
  69. package/dist/dlx/binary.d.ts +25 -9
  70. package/dist/dlx/binary.js +34 -12
  71. package/dist/dlx/cache.d.ts +1 -0
  72. package/dist/dlx/cache.js +2 -1
  73. package/dist/dlx/detect.d.ts +15 -0
  74. package/dist/dlx/detect.js +28 -20
  75. package/dist/dlx/dir.d.ts +1 -11
  76. package/dist/dlx/dir.js +2 -12
  77. package/dist/dlx/integrity.d.ts +86 -0
  78. package/dist/dlx/integrity.js +112 -0
  79. package/dist/dlx/lockfile.d.ts +115 -0
  80. package/dist/dlx/lockfile.js +139 -0
  81. package/dist/dlx/manifest.d.ts +26 -1
  82. package/dist/dlx/manifest.js +9 -6
  83. package/dist/dlx/package.d.ts +58 -3
  84. package/dist/dlx/package.js +101 -74
  85. package/dist/dlx/packages.d.ts +1 -11
  86. package/dist/dlx/packages.js +3 -14
  87. package/dist/dlx/paths.d.ts +1 -0
  88. package/dist/dlx/paths.js +2 -1
  89. package/dist/effects/pulse-frames.js +1 -0
  90. package/dist/effects/text-shimmer.d.ts +13 -2
  91. package/dist/effects/text-shimmer.js +50 -46
  92. package/dist/effects/types.js +1 -0
  93. package/dist/effects/ultra.js +1 -0
  94. package/dist/env/ci.d.ts +6 -1
  95. package/dist/env/ci.js +1 -0
  96. package/dist/env/debug.d.ts +5 -1
  97. package/dist/env/debug.js +1 -0
  98. package/dist/env/github.d.ts +19 -23
  99. package/dist/env/github.js +5 -4
  100. package/dist/env/helpers.d.ts +21 -9
  101. package/dist/env/helpers.js +5 -11
  102. package/dist/env/home.d.ts +17 -4
  103. package/dist/env/home.js +2 -1
  104. package/dist/env/locale.d.ts +4 -3
  105. package/dist/env/locale.js +1 -0
  106. package/dist/env/node-auth-token.d.ts +5 -1
  107. package/dist/env/node-auth-token.js +1 -0
  108. package/dist/env/node-env.d.ts +5 -1
  109. package/dist/env/node-env.js +1 -0
  110. package/dist/env/npm.d.ts +4 -5
  111. package/dist/env/npm.js +1 -0
  112. package/dist/env/package-manager.d.ts +4 -3
  113. package/dist/env/package-manager.js +2 -1
  114. package/dist/env/path.d.ts +5 -1
  115. package/dist/env/path.js +1 -0
  116. package/dist/env/pre-commit.d.ts +5 -1
  117. package/dist/env/pre-commit.js +1 -0
  118. package/dist/env/rewire.d.ts +10 -0
  119. package/dist/env/rewire.js +7 -5
  120. package/dist/env/shell.d.ts +5 -1
  121. package/dist/env/shell.js +1 -0
  122. package/dist/env/socket-cli-shadow.d.ts +4 -5
  123. package/dist/env/socket-cli-shadow.js +1 -0
  124. package/dist/env/socket-cli.d.ts +4 -14
  125. package/dist/env/socket-cli.js +1 -0
  126. package/dist/env/socket.d.ts +6 -18
  127. package/dist/env/socket.js +4 -3
  128. package/dist/env/temp-dir.d.ts +4 -3
  129. package/dist/env/temp-dir.js +1 -0
  130. package/dist/env/term.d.ts +5 -1
  131. package/dist/env/term.js +1 -0
  132. package/dist/env/test.d.ts +4 -3
  133. package/dist/env/test.js +1 -0
  134. package/dist/env/windows.d.ts +4 -4
  135. package/dist/env/windows.js +1 -0
  136. package/dist/env/xdg.d.ts +4 -3
  137. package/dist/env/xdg.js +1 -0
  138. package/dist/env.d.ts +83 -23
  139. package/dist/env.js +112 -80
  140. package/dist/errors.js +1 -0
  141. package/dist/external/@socketregistry/packageurl-js.js +2 -2
  142. package/dist/external/external-pack.js +1562 -1673
  143. package/dist/external/npm-pack.js +5 -1
  144. package/dist/fs.d.ts +92 -113
  145. package/dist/fs.js +35 -35
  146. package/dist/git.d.ts +170 -164
  147. package/dist/git.js +113 -87
  148. package/dist/github.d.ts +249 -227
  149. package/dist/github.js +82 -81
  150. package/dist/globs.d.ts +31 -17
  151. package/dist/globs.js +51 -58
  152. package/dist/http-request.d.ts +99 -99
  153. package/dist/http-request.js +182 -156
  154. package/dist/ipc-cli.d.ts +28 -0
  155. package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
  156. package/dist/ipc.d.ts +9 -299
  157. package/dist/ipc.js +18 -204
  158. package/dist/json/edit.d.ts +3 -1
  159. package/dist/json/edit.js +30 -30
  160. package/dist/json/format.d.ts +36 -36
  161. package/dist/json/format.js +22 -21
  162. package/dist/json/parse.d.ts +4 -2
  163. package/dist/json/parse.js +1 -0
  164. package/dist/json/types.js +1 -0
  165. package/dist/{links/index.d.ts → links.d.ts} +6 -2
  166. package/dist/{links/index.js → links.js} +5 -4
  167. package/dist/logger.d.ts +4 -6
  168. package/dist/logger.js +61 -53
  169. package/dist/memoization.d.ts +52 -49
  170. package/dist/memoization.js +55 -33
  171. package/dist/objects.d.ts +25 -44
  172. package/dist/objects.js +2 -1
  173. package/dist/package-extensions.d.ts +6 -0
  174. package/dist/package-extensions.js +2 -1
  175. package/dist/packages/edit.d.ts +3 -5
  176. package/dist/packages/edit.js +4 -3
  177. package/dist/packages/exports.d.ts +11 -14
  178. package/dist/packages/exports.js +11 -10
  179. package/dist/packages/isolation.d.ts +4 -0
  180. package/dist/packages/isolation.js +20 -19
  181. package/dist/packages/licenses.d.ts +3 -10
  182. package/dist/packages/licenses.js +2 -1
  183. package/dist/packages/manifest.d.ts +3 -3
  184. package/dist/packages/manifest.js +1 -0
  185. package/dist/packages/normalize.d.ts +3 -4
  186. package/dist/packages/normalize.js +1 -0
  187. package/dist/packages/operations.d.ts +3 -10
  188. package/dist/packages/operations.js +1 -0
  189. package/dist/packages/provenance.d.ts +10 -8
  190. package/dist/packages/provenance.js +55 -54
  191. package/dist/packages/specs.d.ts +3 -5
  192. package/dist/packages/specs.js +1 -0
  193. package/dist/packages/validation.d.ts +3 -3
  194. package/dist/packages/validation.js +1 -0
  195. package/dist/packages.d.ts +2 -17
  196. package/dist/packages.js +2 -1
  197. package/dist/paths/dirnames.d.ts +0 -2
  198. package/dist/paths/dirnames.js +1 -0
  199. package/dist/paths/exts.d.ts +0 -1
  200. package/dist/paths/exts.js +1 -0
  201. package/dist/paths/filenames.d.ts +0 -1
  202. package/dist/paths/filenames.js +1 -0
  203. package/dist/paths/globs.d.ts +0 -1
  204. package/dist/paths/globs.js +1 -0
  205. package/dist/paths/normalize.d.ts +115 -123
  206. package/dist/paths/normalize.js +128 -127
  207. package/dist/paths/packages.d.ts +3 -2
  208. package/dist/paths/packages.js +2 -1
  209. package/dist/paths/rewire.d.ts +9 -0
  210. package/dist/paths/rewire.js +5 -3
  211. package/dist/paths/socket.d.ts +37 -23
  212. package/dist/paths/socket.js +26 -25
  213. package/dist/performance.d.ts +87 -84
  214. package/dist/performance.js +97 -96
  215. package/dist/process-lock.d.ts +41 -1
  216. package/dist/process-lock.js +24 -17
  217. package/dist/promise-queue.d.ts +6 -0
  218. package/dist/promise-queue.js +1 -0
  219. package/dist/promises.d.ts +40 -55
  220. package/dist/promises.js +12 -11
  221. package/dist/regexps.d.ts +0 -5
  222. package/dist/regexps.js +1 -0
  223. package/dist/releases/github.d.ts +59 -63
  224. package/dist/releases/github.js +95 -100
  225. package/dist/releases/socket-btm.d.ts +9 -2
  226. package/dist/releases/socket-btm.js +32 -25
  227. package/dist/sea.d.ts +5 -0
  228. package/dist/sea.js +1 -0
  229. package/dist/shadow.d.ts +4 -0
  230. package/dist/shadow.js +1 -0
  231. package/dist/signal-exit.d.ts +7 -7
  232. package/dist/signal-exit.js +46 -45
  233. package/dist/sorts.d.ts +5 -7
  234. package/dist/sorts.js +11 -10
  235. package/dist/spawn.d.ts +96 -77
  236. package/dist/spawn.js +39 -38
  237. package/dist/spinner.d.ts +21 -22
  238. package/dist/spinner.js +15 -11
  239. package/dist/ssri.d.ts +31 -36
  240. package/dist/ssri.js +15 -14
  241. package/dist/stdio/_stream.d.ts +31 -0
  242. package/dist/stdio/_stream.js +57 -0
  243. package/dist/stdio/clear.d.ts +38 -15
  244. package/dist/stdio/clear.js +5 -4
  245. package/dist/stdio/divider.d.ts +40 -36
  246. package/dist/stdio/divider.js +10 -9
  247. package/dist/stdio/footer.d.ts +20 -0
  248. package/dist/stdio/footer.js +12 -2
  249. package/dist/stdio/header.d.ts +4 -16
  250. package/dist/stdio/header.js +1 -9
  251. package/dist/stdio/progress.d.ts +4 -0
  252. package/dist/stdio/progress.js +13 -8
  253. package/dist/stdio/prompts.d.ts +24 -23
  254. package/dist/stdio/prompts.js +10 -9
  255. package/dist/stdio/stderr.d.ts +51 -39
  256. package/dist/stdio/stderr.js +19 -22
  257. package/dist/stdio/stdout.d.ts +54 -52
  258. package/dist/stdio/stdout.js +35 -33
  259. package/dist/streams.d.ts +4 -3
  260. package/dist/streams.js +1 -0
  261. package/dist/strings.d.ts +31 -85
  262. package/dist/strings.js +5 -49
  263. package/dist/suppress-warnings.d.ts +32 -15
  264. package/dist/suppress-warnings.js +14 -13
  265. package/dist/tables.d.ts +30 -26
  266. package/dist/tables.js +24 -23
  267. package/dist/temporary-executor.d.ts +4 -0
  268. package/dist/temporary-executor.js +1 -0
  269. package/dist/themes/context.d.ts +30 -26
  270. package/dist/themes/context.js +19 -18
  271. package/dist/themes/index.d.ts +0 -4
  272. package/dist/themes/index.js +1 -0
  273. package/dist/themes/themes.d.ts +1 -1
  274. package/dist/themes/themes.js +1 -0
  275. package/dist/themes/types.js +1 -0
  276. package/dist/themes/utils.d.ts +46 -43
  277. package/dist/themes/utils.js +45 -44
  278. package/dist/types.d.ts +48 -52
  279. package/dist/types.js +35 -35
  280. package/dist/url.d.ts +48 -53
  281. package/dist/url.js +38 -37
  282. package/dist/validation/json-parser.d.ts +19 -190
  283. package/dist/validation/json-parser.js +5 -69
  284. package/dist/validation/types.d.ts +9 -33
  285. package/dist/validation/types.js +1 -0
  286. package/dist/versions.d.ts +1 -0
  287. package/dist/versions.js +2 -1
  288. package/dist/words.d.ts +3 -6
  289. package/dist/words.js +1 -0
  290. package/dist/zod.js +1 -0
  291. package/package.json +40 -54
  292. package/dist/functions.d.ts +0 -57
  293. package/dist/functions.js +0 -70
  294. package/dist/stdio/mask.d.ts +0 -151
  295. package/dist/stdio/mask.js +0 -224
  296. package/dist/utils/get-ipc.d.ts +0 -15
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -26,41 +27,15 @@ __export(utils_exports, {
26
27
  });
27
28
  module.exports = __toCommonJS(utils_exports);
28
29
  var import_ultra = require("../effects/ultra");
29
- function resolveColor(value, colors) {
30
- if (typeof value === "string") {
31
- if (value === "primary") {
32
- return colors.primary;
33
- }
34
- if (value === "secondary") {
35
- return colors.secondary ?? colors.primary;
36
- }
37
- if (value === "inherit") {
38
- return "inherit";
39
- }
40
- if (value === "rainbow") {
41
- return import_ultra.RAINBOW_GRADIENT;
42
- }
43
- return value;
44
- }
45
- return value;
46
- }
47
- function resolveShimmerColor(value, theme) {
48
- if (!value) {
49
- return "inherit";
50
- }
51
- if (value === "rainbow") {
52
- return import_ultra.RAINBOW_GRADIENT;
53
- }
54
- if (value === "inherit") {
55
- return "inherit";
56
- }
57
- if (Array.isArray(value)) {
58
- if (value.length > 0 && Array.isArray(value[0])) {
59
- return value;
60
- }
61
- return value;
62
- }
63
- return resolveColor(value, theme.colors);
30
+ function createTheme(config) {
31
+ return {
32
+ __proto__: null,
33
+ name: config.name,
34
+ displayName: config.displayName,
35
+ colors: { __proto__: null, ...config.colors },
36
+ effects: config.effects ? { __proto__: null, ...config.effects } : void 0,
37
+ meta: config.meta ? { __proto__: null, ...config.meta } : void 0
38
+ };
64
39
  }
65
40
  function extendTheme(base, overrides) {
66
41
  return {
@@ -99,15 +74,41 @@ function extendTheme(base, overrides) {
99
74
  } : base.meta
100
75
  };
101
76
  }
102
- function createTheme(config) {
103
- return {
104
- __proto__: null,
105
- name: config.name,
106
- displayName: config.displayName,
107
- colors: { __proto__: null, ...config.colors },
108
- effects: config.effects ? { __proto__: null, ...config.effects } : void 0,
109
- meta: config.meta ? { __proto__: null, ...config.meta } : void 0
110
- };
77
+ function resolveColor(value, colors) {
78
+ if (typeof value === "string") {
79
+ if (value === "primary") {
80
+ return colors.primary;
81
+ }
82
+ if (value === "secondary") {
83
+ return colors.secondary ?? colors.primary;
84
+ }
85
+ if (value === "inherit") {
86
+ return "inherit";
87
+ }
88
+ if (value === "rainbow") {
89
+ return import_ultra.RAINBOW_GRADIENT;
90
+ }
91
+ return value;
92
+ }
93
+ return value;
94
+ }
95
+ function resolveShimmerColor(value, theme) {
96
+ if (!value) {
97
+ return "inherit";
98
+ }
99
+ if (value === "rainbow") {
100
+ return import_ultra.RAINBOW_GRADIENT;
101
+ }
102
+ if (value === "inherit") {
103
+ return "inherit";
104
+ }
105
+ if (Array.isArray(value)) {
106
+ if (value.length > 0 && Array.isArray(value[0])) {
107
+ return value;
108
+ }
109
+ return value;
110
+ }
111
+ return resolveColor(value, theme.colors);
111
112
  }
112
113
  // Annotate the CommonJS export names for ESM import in node:
113
114
  0 && (module.exports = {
package/dist/types.d.ts CHANGED
@@ -1,59 +1,55 @@
1
1
  /**
2
2
  * @fileoverview Type definitions for Socket Registry.
3
3
  */
4
- // Type definitions
5
- declare enum Categories {
6
- CLEANUP = "cleanup",
7
- LEVELUP = "levelup",
8
- SPEEDUP = "speedup",
9
- TUNEUP = "tuneup"
10
- }
11
- export type CategoryString = `${Categories}`;
12
- declare enum Interop {
13
- BROWSERIFY = "browserify",
14
- CJS = "cjs",
15
- ESM = "esm"
16
- }
17
- export type InteropString = `${Interop}`;
18
- // Based on SocketPURL_Type from socket-sdk-js
19
- export declare enum PURL_Type {
20
- ALPM = "alpm",
21
- APK = "apk",
22
- BITBUCKET = "bitbucket",
23
- COCOAPODS = "cocoapods",
24
- CARGO = "cargo",
25
- CHROME = "chrome",
26
- COMPOSER = "composer",
27
- CONAN = "conan",
28
- CONDA = "conda",
29
- CRAN = "cran",
30
- DEB = "deb",
31
- DOCKER = "docker",
32
- GEM = "gem",
33
- GENERIC = "generic",
34
- GITHUB = "github",
35
- GOLANG = "golang",
36
- HACKAGE = "hackage",
37
- HEX = "hex",
38
- HUGGINGFACE = "huggingface",
39
- MAVEN = "maven",
40
- MLFLOW = "mlflow",
41
- NPM = "npm",
42
- NUGET = "nuget",
43
- OCI = "oci",
44
- PUB = "pub",
45
- PYPI = "pypi",
46
- QPKG = "qpkg",
47
- RPM = "rpm",
48
- SWID = "swid",
49
- SWIFT = "swift",
50
- VCS = "vcs",
51
- VSCODE = "vscode"
52
- }
53
- export type PURLString = `${PURL_Type}`;
54
- // Alias for backward compatibility and semantic clarity
4
+ declare const Categories: {
5
+ readonly CLEANUP: 'cleanup';
6
+ readonly LEVELUP: 'levelup';
7
+ readonly SPEEDUP: 'speedup';
8
+ readonly TUNEUP: 'tuneup';
9
+ };
10
+ export type CategoryString = (typeof Categories)[keyof typeof Categories];
11
+ declare const Interop: {
12
+ readonly BROWSERIFY: 'browserify';
13
+ readonly CJS: 'cjs';
14
+ readonly ESM: 'esm';
15
+ };
16
+ export type InteropString = (typeof Interop)[keyof typeof Interop];
17
+ export declare const PURL_Type: {
18
+ readonly ALPM: 'alpm';
19
+ readonly APK: 'apk';
20
+ readonly BITBUCKET: 'bitbucket';
21
+ readonly COCOAPODS: 'cocoapods';
22
+ readonly CARGO: 'cargo';
23
+ readonly CHROME: 'chrome';
24
+ readonly COMPOSER: 'composer';
25
+ readonly CONAN: 'conan';
26
+ readonly CONDA: 'conda';
27
+ readonly CRAN: 'cran';
28
+ readonly DEB: 'deb';
29
+ readonly DOCKER: 'docker';
30
+ readonly GEM: 'gem';
31
+ readonly GENERIC: 'generic';
32
+ readonly GITHUB: 'github';
33
+ readonly GOLANG: 'golang';
34
+ readonly HACKAGE: 'hackage';
35
+ readonly HEX: 'hex';
36
+ readonly HUGGINGFACE: 'huggingface';
37
+ readonly MAVEN: 'maven';
38
+ readonly MLFLOW: 'mlflow';
39
+ readonly NPM: 'npm';
40
+ readonly NUGET: 'nuget';
41
+ readonly OCI: 'oci';
42
+ readonly PUB: 'pub';
43
+ readonly PYPI: 'pypi';
44
+ readonly QPKG: 'qpkg';
45
+ readonly RPM: 'rpm';
46
+ readonly SWID: 'swid';
47
+ readonly SWIFT: 'swift';
48
+ readonly VCS: 'vcs';
49
+ readonly VSCODE: 'vscode';
50
+ };
51
+ export type PURLString = (typeof PURL_Type)[keyof typeof PURL_Type];
55
52
  export type EcosystemString = PURLString;
56
- // Manifest types for Socket Registry
57
53
  export type ManifestEntryData = {
58
54
  categories?: CategoryString[] | undefined;
59
55
  interop?: InteropString | undefined;
package/dist/types.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -22,41 +23,40 @@ __export(types_exports, {
22
23
  PURL_Type: () => PURL_Type
23
24
  });
24
25
  module.exports = __toCommonJS(types_exports);
25
- var PURL_Type = /* @__PURE__ */ ((PURL_Type2) => {
26
- PURL_Type2["ALPM"] = "alpm";
27
- PURL_Type2["APK"] = "apk";
28
- PURL_Type2["BITBUCKET"] = "bitbucket";
29
- PURL_Type2["COCOAPODS"] = "cocoapods";
30
- PURL_Type2["CARGO"] = "cargo";
31
- PURL_Type2["CHROME"] = "chrome";
32
- PURL_Type2["COMPOSER"] = "composer";
33
- PURL_Type2["CONAN"] = "conan";
34
- PURL_Type2["CONDA"] = "conda";
35
- PURL_Type2["CRAN"] = "cran";
36
- PURL_Type2["DEB"] = "deb";
37
- PURL_Type2["DOCKER"] = "docker";
38
- PURL_Type2["GEM"] = "gem";
39
- PURL_Type2["GENERIC"] = "generic";
40
- PURL_Type2["GITHUB"] = "github";
41
- PURL_Type2["GOLANG"] = "golang";
42
- PURL_Type2["HACKAGE"] = "hackage";
43
- PURL_Type2["HEX"] = "hex";
44
- PURL_Type2["HUGGINGFACE"] = "huggingface";
45
- PURL_Type2["MAVEN"] = "maven";
46
- PURL_Type2["MLFLOW"] = "mlflow";
47
- PURL_Type2["NPM"] = "npm";
48
- PURL_Type2["NUGET"] = "nuget";
49
- PURL_Type2["OCI"] = "oci";
50
- PURL_Type2["PUB"] = "pub";
51
- PURL_Type2["PYPI"] = "pypi";
52
- PURL_Type2["QPKG"] = "qpkg";
53
- PURL_Type2["RPM"] = "rpm";
54
- PURL_Type2["SWID"] = "swid";
55
- PURL_Type2["SWIFT"] = "swift";
56
- PURL_Type2["VCS"] = "vcs";
57
- PURL_Type2["VSCODE"] = "vscode";
58
- return PURL_Type2;
59
- })(PURL_Type || {});
26
+ const PURL_Type = {
27
+ ALPM: "alpm",
28
+ APK: "apk",
29
+ BITBUCKET: "bitbucket",
30
+ COCOAPODS: "cocoapods",
31
+ CARGO: "cargo",
32
+ CHROME: "chrome",
33
+ COMPOSER: "composer",
34
+ CONAN: "conan",
35
+ CONDA: "conda",
36
+ CRAN: "cran",
37
+ DEB: "deb",
38
+ DOCKER: "docker",
39
+ GEM: "gem",
40
+ GENERIC: "generic",
41
+ GITHUB: "github",
42
+ GOLANG: "golang",
43
+ HACKAGE: "hackage",
44
+ HEX: "hex",
45
+ HUGGINGFACE: "huggingface",
46
+ MAVEN: "maven",
47
+ MLFLOW: "mlflow",
48
+ NPM: "npm",
49
+ NUGET: "nuget",
50
+ OCI: "oci",
51
+ PUB: "pub",
52
+ PYPI: "pypi",
53
+ QPKG: "qpkg",
54
+ RPM: "rpm",
55
+ SWID: "swid",
56
+ SWIFT: "swift",
57
+ VCS: "vcs",
58
+ VSCODE: "vscode"
59
+ };
60
60
  // Annotate the CommonJS export names for ESM import in node:
61
61
  0 && (module.exports = {
62
62
  PURL_Type
package/dist/url.d.ts CHANGED
@@ -1,3 +1,32 @@
1
+ /**
2
+ * @fileoverview URL parsing and validation utilities.
3
+ * Provides URL validation, normalization, and parsing helpers.
4
+ */
5
+ export interface CreateRelativeUrlOptions {
6
+ base?: string;
7
+ }
8
+ export interface UrlSearchParamAsBooleanOptions {
9
+ defaultValue?: boolean;
10
+ }
11
+ export interface UrlSearchParamAsNumberOptions {
12
+ defaultValue?: number;
13
+ }
14
+ export interface UrlSearchParamAsStringOptions {
15
+ defaultValue?: string;
16
+ }
17
+ export interface UrlSearchParamsGetBooleanOptions {
18
+ defaultValue?: boolean;
19
+ }
20
+ /**
21
+ * Create a relative URL for testing.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * createRelativeUrl('/api/test') // 'api/test'
26
+ * createRelativeUrl('/api/test', { base: 'https://example.com' }) // 'https://example.com/api/test'
27
+ * ```
28
+ */
29
+ export declare function createRelativeUrl(path: string, options?: CreateRelativeUrlOptions | undefined): string;
1
30
  /**
2
31
  * Check if a value is a valid URL.
3
32
  *
@@ -8,7 +37,6 @@
8
37
  * isUrl(null) // false
9
38
  * ```
10
39
  */
11
- /*@__NO_SIDE_EFFECTS__*/
12
40
  export declare function isUrl(value: string | URL | null | undefined): boolean;
13
41
  /**
14
42
  * Parse a value as a URL.
@@ -19,7 +47,6 @@ export declare function isUrl(value: string | URL | null | undefined): boolean;
19
47
  * parseUrl('invalid') // undefined
20
48
  * ```
21
49
  */
22
- /*@__NO_SIDE_EFFECTS__*/
23
50
  export declare function parseUrl(value: string | URL): URL | undefined;
24
51
  /**
25
52
  * Convert a URL search parameter to an array.
@@ -30,11 +57,7 @@ export declare function parseUrl(value: string | URL): URL | undefined;
30
57
  * urlSearchParamAsArray(null) // []
31
58
  * ```
32
59
  */
33
- /*@__NO_SIDE_EFFECTS__*/
34
60
  export declare function urlSearchParamAsArray(value: string | null | undefined): string[];
35
- export interface UrlSearchParamAsBooleanOptions {
36
- defaultValue?: boolean;
37
- }
38
61
  /**
39
62
  * Convert a URL search parameter to a boolean.
40
63
  *
@@ -45,75 +68,47 @@ export interface UrlSearchParamAsBooleanOptions {
45
68
  * urlSearchParamAsBoolean(null) // false
46
69
  * ```
47
70
  */
48
- /*@__NO_SIDE_EFFECTS__*/
49
71
  export declare function urlSearchParamAsBoolean(value: string | null | undefined, options?: UrlSearchParamAsBooleanOptions | undefined): boolean;
50
72
  /**
51
- * Helper to get array from URLSearchParams.
52
- *
53
- * @example
54
- * ```typescript
55
- * const params = new URLSearchParams('tags=a,b,c')
56
- * urlSearchParamsGetArray(params, 'tags') // ['a', 'b', 'c']
57
- * ```
58
- */
59
- /*@__NO_SIDE_EFFECTS__*/
60
- export declare function urlSearchParamsGetArray(params: URLSearchParams | null | undefined, key: string): string[];
61
- export interface UrlSearchParamsGetBooleanOptions {
62
- defaultValue?: boolean;
63
- }
64
- /**
65
- * Helper to get boolean from URLSearchParams.
73
+ * Get number value from URLSearchParams with a default.
66
74
  *
67
75
  * @example
68
76
  * ```typescript
69
- * const params = new URLSearchParams('debug=true')
70
- * urlSearchParamsGetBoolean(params, 'debug') // true
71
- * urlSearchParamsGetBoolean(params, 'other') // false
77
+ * const params = new URLSearchParams('limit=10')
78
+ * urlSearchParamAsNumber(params, 'limit') // 10
79
+ * urlSearchParamAsNumber(params, 'other') // 0
72
80
  * ```
73
81
  */
74
- /*@__NO_SIDE_EFFECTS__*/
75
- export declare function urlSearchParamsGetBoolean(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamsGetBooleanOptions | undefined): boolean;
76
- export interface CreateRelativeUrlOptions {
77
- base?: string;
78
- }
82
+ export declare function urlSearchParamAsNumber(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamAsNumberOptions | undefined): number;
79
83
  /**
80
- * Create a relative URL for testing.
84
+ * Get string value from URLSearchParams with a default.
81
85
  *
82
86
  * @example
83
87
  * ```typescript
84
- * createRelativeUrl('/api/test') // 'api/test'
85
- * createRelativeUrl('/api/test', { base: 'https://example.com' }) // 'https://example.com/api/test'
88
+ * const params = new URLSearchParams('name=socket')
89
+ * urlSearchParamAsString(params, 'name') // 'socket'
90
+ * urlSearchParamAsString(params, 'other') // ''
86
91
  * ```
87
92
  */
88
- /*@__NO_SIDE_EFFECTS__*/
89
- export declare function createRelativeUrl(path: string, options?: CreateRelativeUrlOptions | undefined): string;
90
- export interface UrlSearchParamAsStringOptions {
91
- defaultValue?: string;
92
- }
93
+ export declare function urlSearchParamAsString(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamAsStringOptions | undefined): string;
93
94
  /**
94
- * Get string value from URLSearchParams with a default.
95
+ * Helper to get array from URLSearchParams.
95
96
  *
96
97
  * @example
97
98
  * ```typescript
98
- * const params = new URLSearchParams('name=socket')
99
- * urlSearchParamAsString(params, 'name') // 'socket'
100
- * urlSearchParamAsString(params, 'other') // ''
99
+ * const params = new URLSearchParams('tags=a,b,c')
100
+ * urlSearchParamsGetArray(params, 'tags') // ['a', 'b', 'c']
101
101
  * ```
102
102
  */
103
- /*@__NO_SIDE_EFFECTS__*/
104
- export declare function urlSearchParamAsString(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamAsStringOptions | undefined): string;
105
- export interface UrlSearchParamAsNumberOptions {
106
- defaultValue?: number;
107
- }
103
+ export declare function urlSearchParamsGetArray(params: URLSearchParams | null | undefined, key: string): string[];
108
104
  /**
109
- * Get number value from URLSearchParams with a default.
105
+ * Helper to get boolean from URLSearchParams.
110
106
  *
111
107
  * @example
112
108
  * ```typescript
113
- * const params = new URLSearchParams('limit=10')
114
- * urlSearchParamAsNumber(params, 'limit') // 10
115
- * urlSearchParamAsNumber(params, 'other') // 0
109
+ * const params = new URLSearchParams('debug=true')
110
+ * urlSearchParamsGetBoolean(params, 'debug') // true
111
+ * urlSearchParamsGetBoolean(params, 'other') // false
116
112
  * ```
117
113
  */
118
- /*@__NO_SIDE_EFFECTS__*/
119
- export declare function urlSearchParamAsNumber(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamAsNumberOptions | undefined): number;
114
+ export declare function urlSearchParamsGetBoolean(params: URLSearchParams | null | undefined, key: string, options?: UrlSearchParamsGetBooleanOptions | undefined): boolean;
package/dist/url.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -33,6 +34,22 @@ module.exports = __toCommonJS(url_exports);
33
34
  const BooleanCtor = Boolean;
34
35
  const UrlCtor = URL;
35
36
  // @__NO_SIDE_EFFECTS__
37
+ function createRelativeUrl(path, options) {
38
+ const { base = "" } = {
39
+ __proto__: null,
40
+ ...options
41
+ };
42
+ const relativePath = path.replace(/^\//, "");
43
+ if (base) {
44
+ let baseUrl = base;
45
+ if (!baseUrl.endsWith("/")) {
46
+ baseUrl += "/";
47
+ }
48
+ return baseUrl + relativePath;
49
+ }
50
+ return relativePath;
51
+ }
52
+ // @__NO_SIDE_EFFECTS__
36
53
  function isUrl(value) {
37
54
  return (typeof value === "string" && value !== "" || value !== null && typeof value === "object") && !!/* @__PURE__ */ parseUrl(value);
38
55
  }
@@ -64,44 +81,19 @@ function urlSearchParamAsBoolean(value, options) {
64
81
  return !!value;
65
82
  }
66
83
  // @__NO_SIDE_EFFECTS__
67
- function urlSearchParamsGetArray(params, key) {
68
- if (params && typeof params.getAll === "function") {
69
- const values = params.getAll(key);
70
- const firstValue = values[0];
71
- if (values.length === 1 && firstValue && firstValue.includes(",")) {
72
- return /* @__PURE__ */ urlSearchParamAsArray(firstValue);
73
- }
74
- return values;
75
- }
76
- return [];
77
- }
78
- // @__NO_SIDE_EFFECTS__
79
- function urlSearchParamsGetBoolean(params, key, options) {
80
- const { defaultValue = false } = {
84
+ function urlSearchParamAsNumber(params, key, options) {
85
+ const { defaultValue = 0 } = {
81
86
  __proto__: null,
82
87
  ...options
83
88
  };
84
89
  if (params && typeof params.get === "function") {
85
90
  const value = params.get(key);
86
- return value !== null ? /* @__PURE__ */ urlSearchParamAsBoolean(value, { defaultValue }) : defaultValue;
87
- }
88
- return defaultValue;
89
- }
90
- // @__NO_SIDE_EFFECTS__
91
- function createRelativeUrl(path, options) {
92
- const { base = "" } = {
93
- __proto__: null,
94
- ...options
95
- };
96
- const relativePath = path.replace(/^\//, "");
97
- if (base) {
98
- let baseUrl = base;
99
- if (!baseUrl.endsWith("/")) {
100
- baseUrl += "/";
91
+ if (value !== null) {
92
+ const num = Number(value);
93
+ return !Number.isNaN(num) ? num : defaultValue;
101
94
  }
102
- return baseUrl + relativePath;
103
95
  }
104
- return relativePath;
96
+ return defaultValue;
105
97
  }
106
98
  // @__NO_SIDE_EFFECTS__
107
99
  function urlSearchParamAsString(params, key, options) {
@@ -116,17 +108,26 @@ function urlSearchParamAsString(params, key, options) {
116
108
  return defaultValue;
117
109
  }
118
110
  // @__NO_SIDE_EFFECTS__
119
- function urlSearchParamAsNumber(params, key, options) {
120
- const { defaultValue = 0 } = {
111
+ function urlSearchParamsGetArray(params, key) {
112
+ if (params && typeof params.getAll === "function") {
113
+ const values = params.getAll(key);
114
+ const firstValue = values[0];
115
+ if (values.length === 1 && firstValue && firstValue.includes(",")) {
116
+ return /* @__PURE__ */ urlSearchParamAsArray(firstValue);
117
+ }
118
+ return values;
119
+ }
120
+ return [];
121
+ }
122
+ // @__NO_SIDE_EFFECTS__
123
+ function urlSearchParamsGetBoolean(params, key, options) {
124
+ const { defaultValue = false } = {
121
125
  __proto__: null,
122
126
  ...options
123
127
  };
124
128
  if (params && typeof params.get === "function") {
125
129
  const value = params.get(key);
126
- if (value !== null) {
127
- const num = Number(value);
128
- return !Number.isNaN(num) ? num : defaultValue;
129
- }
130
+ return value !== null ? /* @__PURE__ */ urlSearchParamAsBoolean(value, { defaultValue }) : defaultValue;
130
131
  }
131
132
  return defaultValue;
132
133
  }