@socketsecurity/lib 5.26.0 → 5.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +371 -1185
- package/README.md +1 -1
- package/dist/abort.js +7 -6
- package/dist/agent.js +16 -15
- package/dist/ansi.js +3 -2
- package/dist/archives.js +18 -17
- package/dist/argv/flags.js +29 -28
- package/dist/argv/parse.js +4 -3
- package/dist/arrays.js +3 -2
- package/dist/bin.js +12 -11
- package/dist/cacache.js +16 -11
- package/dist/cache-with-ttl.js +26 -21
- package/dist/colors.js +2 -1
- package/dist/constants/licenses.js +2 -1
- package/dist/constants/lifecycle-script-names.js +2 -1
- package/dist/constants/maintained-node-versions.js +2 -1
- package/dist/constants/node.js +4 -3
- package/dist/constants/package-default-socket-categories.js +2 -1
- package/dist/constants/packages.js +4 -3
- package/dist/constants/socket.js +1 -1
- package/dist/cover/code.js +9 -8
- package/dist/cover/formatters.js +12 -11
- package/dist/cover/type.js +5 -4
- package/dist/crypto.d.ts +36 -0
- package/dist/{effects/ultra.js → crypto.js} +26 -37
- package/dist/debug.js +12 -15
- package/dist/dlx/arborist.js +10 -9
- package/dist/dlx/binary.js +27 -24
- package/dist/dlx/cache.js +2 -10
- package/dist/dlx/detect.js +6 -5
- package/dist/dlx/integrity.js +13 -11
- package/dist/dlx/lockfile.js +7 -6
- package/dist/dlx/manifest.js +6 -5
- package/dist/dlx/package.js +17 -16
- package/dist/dlx/packages.js +6 -5
- package/dist/dlx/paths.d.ts +1 -1
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +4 -3
- package/dist/effects/shimmer-keyframes.d.ts +62 -0
- package/dist/effects/shimmer-keyframes.js +55 -0
- package/dist/effects/shimmer-terminal.d.ts +66 -0
- package/dist/effects/shimmer-terminal.js +57 -0
- package/dist/effects/shimmer.d.ts +293 -0
- package/dist/effects/shimmer.js +180 -0
- package/dist/env/rewire.js +4 -3
- package/dist/env.js +5 -4
- package/dist/errors.js +1 -1
- package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
- package/dist/external/@npmcli/package-json.js +372 -372
- package/dist/external/@npmcli/promise-spawn.js +24 -24
- package/dist/external/@socketregistry/packageurl-js.js +19 -18
- package/dist/external/@socketregistry/yocto-spinner.js +4 -3
- package/dist/external/@yarnpkg/extensions.js +2 -1
- package/dist/external/adm-zip.js +71 -71
- package/dist/external/debug.js +22 -22
- package/dist/external/external-pack.js +45 -45
- package/dist/external/fast-sort.js +5 -5
- package/dist/external/libnpmexec.js +4 -3
- package/dist/external/npm-pack.js +369 -369
- package/dist/external/p-map.js +9 -9
- package/dist/external/pico-pack.js +190 -190
- package/dist/external/pony-cause.js +2 -1
- package/dist/external/spdx-pack.js +11 -10
- package/dist/external/tar-fs.js +58 -58
- package/dist/external/which.js +13 -13
- package/dist/external/yargs-parser.js +71 -71
- package/dist/fs.js +50 -68
- package/dist/git.js +14 -13
- package/dist/github.d.ts +34 -0
- package/dist/github.js +248 -23
- package/dist/globs.d.ts +20 -0
- package/dist/globs.js +134 -25
- package/dist/http-request.d.ts +4 -3
- package/dist/http-request.js +39 -32
- package/dist/ipc-cli.js +2 -1
- package/dist/ipc.js +5 -4
- package/dist/json/edit.js +4 -3
- package/dist/json/format.js +3 -2
- package/dist/json/parse.js +7 -6
- package/dist/links.js +2 -1
- package/dist/logger.js +21 -14
- package/dist/memoization.js +16 -15
- package/dist/node/async-hooks.d.ts +6 -0
- package/dist/node/async-hooks.js +34 -0
- package/dist/node/child-process.d.ts +11 -0
- package/dist/node/child-process.js +34 -0
- package/dist/node/crypto.d.ts +6 -0
- package/dist/node/crypto.js +34 -0
- package/dist/node/events.d.ts +6 -0
- package/dist/node/events.js +34 -0
- package/dist/node/fs-promises.d.ts +6 -0
- package/dist/node/fs-promises.js +34 -0
- package/dist/node/fs.d.ts +14 -0
- package/dist/node/fs.js +34 -0
- package/dist/node/http.d.ts +6 -0
- package/dist/node/http.js +34 -0
- package/dist/node/https.d.ts +6 -0
- package/dist/node/https.js +34 -0
- package/dist/node/os.d.ts +6 -0
- package/dist/node/os.js +34 -0
- package/dist/node/path.d.ts +6 -0
- package/dist/node/path.js +34 -0
- package/dist/node/timers-promises.d.ts +6 -0
- package/dist/node/timers-promises.js +34 -0
- package/dist/node/url.d.ts +6 -0
- package/dist/node/url.js +34 -0
- package/dist/node/util.d.ts +6 -0
- package/dist/node/util.js +34 -0
- package/dist/objects.js +2 -2
- package/dist/packages/edit.js +8 -7
- package/dist/packages/exports.js +17 -16
- package/dist/packages/isolation.js +20 -13
- package/dist/packages/licenses.js +6 -3
- package/dist/packages/manifest.js +2 -1
- package/dist/packages/normalize.js +8 -4
- package/dist/packages/operations.js +5 -4
- package/dist/packages/provenance.js +7 -6
- package/dist/packages/specs.js +2 -1
- package/dist/packages/validation.js +2 -1
- package/dist/paths/normalize.js +32 -40
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.js +3 -2
- package/dist/performance.js +19 -18
- package/dist/primordials.d.ts +85 -2
- package/dist/primordials.js +311 -23
- package/dist/process-lock.js +14 -13
- package/dist/promise-queue.js +17 -9
- package/dist/promises.d.ts +29 -6
- package/dist/promises.js +19 -15
- package/dist/regexps.js +9 -8
- package/dist/releases/github-api.d.ts +56 -0
- package/dist/releases/github-api.js +275 -0
- package/dist/releases/github-archives.d.ts +60 -0
- package/dist/releases/github-archives.js +136 -0
- package/dist/releases/github-assets.d.ts +21 -0
- package/dist/releases/github-assets.js +52 -0
- package/dist/releases/github-auth.d.ts +16 -0
- package/dist/releases/github-auth.js +51 -0
- package/dist/releases/github-downloads.d.ts +42 -0
- package/dist/releases/github-downloads.js +155 -0
- package/dist/releases/github-types.d.ts +66 -0
- package/dist/{effects/types.js → releases/github-types.js} +2 -2
- package/dist/releases/socket-btm.d.ts +1 -1
- package/dist/releases/socket-btm.js +17 -17
- package/dist/schema/parse.js +2 -1
- package/dist/schema/validate.js +6 -5
- package/dist/sea/util.d.ts +43 -0
- package/dist/{sea.js → sea/util.js} +7 -7
- package/dist/shadow.js +2 -1
- package/dist/signal-exit.js +2 -2
- package/dist/smol/primordial.d.ts +80 -0
- package/dist/smol/primordial.js +46 -0
- package/dist/smol/util.d.ts +87 -0
- package/dist/smol/util.js +59 -0
- package/dist/smol/versions.d.ts +46 -0
- package/dist/smol/versions.js +46 -0
- package/dist/spawn.js +58 -63
- package/dist/spinner.d.ts +13 -6
- package/dist/spinner.js +75 -57
- package/dist/ssri.js +8 -7
- package/dist/stdio/footer.js +13 -12
- package/dist/stdio/header.js +5 -4
- package/dist/stdio/progress.js +13 -12
- package/dist/strings.js +19 -18
- package/dist/suppress-warnings.js +2 -2
- package/dist/tables.js +16 -13
- package/dist/temporary-executor.js +2 -1
- package/dist/themes/context.js +2 -1
- package/dist/themes/types.d.ts +1 -1
- package/dist/themes/utils.d.ts +8 -3
- package/dist/themes/utils.js +29 -5
- package/dist/url.js +4 -3
- package/dist/versions.js +27 -22
- package/package.json +120 -26
- package/dist/effects/text-shimmer.d.ts +0 -58
- package/dist/effects/text-shimmer.js +0 -192
- package/dist/effects/types.d.ts +0 -47
- package/dist/effects/ultra.d.ts +0 -22
- package/dist/releases/github.d.ts +0 -234
- package/dist/releases/github.js +0 -417
- package/dist/sea.d.ts +0 -30
- package/dist/themes/index.d.ts +0 -49
- package/dist/themes/index.js +0 -60
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var github_downloads_exports = {};
|
|
32
|
+
__export(github_downloads_exports, {
|
|
33
|
+
downloadGitHubRelease: () => downloadGitHubRelease,
|
|
34
|
+
downloadReleaseAsset: () => downloadReleaseAsset
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(github_downloads_exports);
|
|
37
|
+
var import_node_process = __toESM(require("node:process"));
|
|
38
|
+
var import_fs = require("../fs");
|
|
39
|
+
var import_http_request = require("../http-request");
|
|
40
|
+
var import_logger = require("../logger");
|
|
41
|
+
var import_primordials = require("../primordials");
|
|
42
|
+
var import_spawn = require("../spawn");
|
|
43
|
+
var import_github_api = require("./github-api");
|
|
44
|
+
const logger = (0, import_logger.getDefaultLogger)();
|
|
45
|
+
let _fs;
|
|
46
|
+
let _path;
|
|
47
|
+
// @__NO_SIDE_EFFECTS__
|
|
48
|
+
function getFs() {
|
|
49
|
+
if (_fs === void 0) {
|
|
50
|
+
_fs = require("node:fs");
|
|
51
|
+
}
|
|
52
|
+
return _fs;
|
|
53
|
+
}
|
|
54
|
+
// @__NO_SIDE_EFFECTS__
|
|
55
|
+
function getPath() {
|
|
56
|
+
if (_path === void 0) {
|
|
57
|
+
_path = require("node:path");
|
|
58
|
+
}
|
|
59
|
+
return _path;
|
|
60
|
+
}
|
|
61
|
+
async function downloadGitHubRelease(config) {
|
|
62
|
+
const {
|
|
63
|
+
assetName,
|
|
64
|
+
binaryName,
|
|
65
|
+
cwd = import_node_process.default.cwd(),
|
|
66
|
+
downloadDir = "build/downloaded",
|
|
67
|
+
owner,
|
|
68
|
+
platformArch,
|
|
69
|
+
quiet = false,
|
|
70
|
+
removeMacOSQuarantine = true,
|
|
71
|
+
repo,
|
|
72
|
+
tag: explicitTag,
|
|
73
|
+
toolName,
|
|
74
|
+
toolPrefix
|
|
75
|
+
} = config;
|
|
76
|
+
let tag;
|
|
77
|
+
if (explicitTag) {
|
|
78
|
+
tag = explicitTag;
|
|
79
|
+
} else if (toolPrefix) {
|
|
80
|
+
const latestTag = await (0, import_github_api.getLatestRelease)(toolPrefix, { owner, repo });
|
|
81
|
+
if (!latestTag) {
|
|
82
|
+
throw new import_primordials.ErrorCtor(`No ${toolPrefix} release found in ${owner}/${repo}`);
|
|
83
|
+
}
|
|
84
|
+
tag = latestTag;
|
|
85
|
+
} else {
|
|
86
|
+
throw new import_primordials.ErrorCtor("Either toolPrefix or tag must be provided");
|
|
87
|
+
}
|
|
88
|
+
const path = /* @__PURE__ */ getPath();
|
|
89
|
+
const resolvedDownloadDir = path.isAbsolute(downloadDir) ? downloadDir : path.join(cwd, downloadDir);
|
|
90
|
+
const binaryDir = resolvedDownloadDir;
|
|
91
|
+
const binaryPath = path.join(binaryDir, binaryName);
|
|
92
|
+
const versionPath = path.join(binaryDir, ".version");
|
|
93
|
+
const fs = /* @__PURE__ */ getFs();
|
|
94
|
+
if (fs.existsSync(versionPath) && fs.existsSync(binaryPath)) {
|
|
95
|
+
const cachedVersion = (await fs.promises.readFile(versionPath, "utf8")).trim();
|
|
96
|
+
if (cachedVersion === tag && fs.existsSync(binaryPath)) {
|
|
97
|
+
if (!quiet) {
|
|
98
|
+
logger.info(`Using cached ${toolName} (${platformArch}): ${binaryPath}`);
|
|
99
|
+
}
|
|
100
|
+
return binaryPath;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!quiet) {
|
|
104
|
+
logger.info(`Downloading ${toolName} for ${platformArch}...`);
|
|
105
|
+
}
|
|
106
|
+
await downloadReleaseAsset(
|
|
107
|
+
tag,
|
|
108
|
+
assetName,
|
|
109
|
+
binaryPath,
|
|
110
|
+
{ owner, repo },
|
|
111
|
+
{ quiet }
|
|
112
|
+
);
|
|
113
|
+
const isWindows = (0, import_primordials.StringPrototypeEndsWith)(binaryName, ".exe");
|
|
114
|
+
if (!isWindows) {
|
|
115
|
+
fs.chmodSync(binaryPath, 493);
|
|
116
|
+
if (removeMacOSQuarantine && import_node_process.default.platform === "darwin" && (0, import_primordials.StringPrototypeStartsWith)(platformArch, "darwin")) {
|
|
117
|
+
try {
|
|
118
|
+
await (0, import_spawn.spawn)("xattr", ["-d", "com.apple.quarantine", binaryPath], {
|
|
119
|
+
stdio: "ignore"
|
|
120
|
+
});
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
await fs.promises.writeFile(versionPath, tag, "utf8");
|
|
126
|
+
if (!quiet) {
|
|
127
|
+
logger.info(`Downloaded ${toolName} to ${binaryPath}`);
|
|
128
|
+
}
|
|
129
|
+
return binaryPath;
|
|
130
|
+
}
|
|
131
|
+
async function downloadReleaseAsset(tag, assetPattern, outputPath, repoConfig, options = {}) {
|
|
132
|
+
const { owner, repo } = repoConfig;
|
|
133
|
+
const { quiet = false } = options;
|
|
134
|
+
const downloadUrl = await (0, import_github_api.getReleaseAssetUrl)(tag, assetPattern, {
|
|
135
|
+
owner,
|
|
136
|
+
repo
|
|
137
|
+
});
|
|
138
|
+
if (!downloadUrl) {
|
|
139
|
+
const patternDesc = typeof assetPattern === "string" ? assetPattern : "matching pattern";
|
|
140
|
+
throw new import_primordials.ErrorCtor(`Asset ${patternDesc} not found in release ${tag}`);
|
|
141
|
+
}
|
|
142
|
+
const path = /* @__PURE__ */ getPath();
|
|
143
|
+
await (0, import_fs.safeMkdir)(path.dirname(outputPath));
|
|
144
|
+
await (0, import_http_request.httpDownload)(downloadUrl, outputPath, {
|
|
145
|
+
logger: quiet ? void 0 : logger,
|
|
146
|
+
progressInterval: 10,
|
|
147
|
+
retries: 2,
|
|
148
|
+
retryDelay: 5e3
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
152
|
+
0 && (module.exports = {
|
|
153
|
+
downloadGitHubRelease,
|
|
154
|
+
downloadReleaseAsset
|
|
155
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Public types for GitHub release download utilities.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Pattern for matching release assets.
|
|
6
|
+
* Can be either:
|
|
7
|
+
* - A string with glob pattern syntax
|
|
8
|
+
* - A prefix/suffix pair for explicit matching (backward compatible)
|
|
9
|
+
* - A RegExp for complex patterns
|
|
10
|
+
*
|
|
11
|
+
* String patterns support full glob syntax via picomatch.
|
|
12
|
+
* Examples:
|
|
13
|
+
* - Simple wildcard: yoga-sync-*.mjs matches yoga-sync-abc123.mjs
|
|
14
|
+
* - Complex: models-*.tar.gz matches models-2024-01-15.tar.gz
|
|
15
|
+
* - Prefix wildcard: *-models.tar.gz matches foo-models.tar.gz
|
|
16
|
+
* - Suffix wildcard: yoga-* matches yoga-layout
|
|
17
|
+
* - Brace expansion: {yoga,models}-*.{mjs,js} matches yoga-abc.mjs or models-xyz.js
|
|
18
|
+
*
|
|
19
|
+
* For backward compatibility, prefix/suffix objects are still supported but glob patterns are recommended.
|
|
20
|
+
*/
|
|
21
|
+
export type AssetPattern = string | {
|
|
22
|
+
prefix: string;
|
|
23
|
+
suffix: string;
|
|
24
|
+
} | RegExp;
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for downloading a GitHub release.
|
|
27
|
+
*/
|
|
28
|
+
export interface DownloadGitHubReleaseConfig {
|
|
29
|
+
/** Asset name on GitHub. */
|
|
30
|
+
assetName: string;
|
|
31
|
+
/** Binary filename (e.g., 'node', 'binject'). */
|
|
32
|
+
binaryName: string;
|
|
33
|
+
/** Working directory (defaults to process.cwd()). */
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/** Download destination directory. @default 'build/downloaded' */
|
|
36
|
+
downloadDir?: string;
|
|
37
|
+
/** GitHub repository owner/organization. */
|
|
38
|
+
owner: string;
|
|
39
|
+
/** Platform-arch identifier (e.g., 'linux-x64-musl'). */
|
|
40
|
+
platformArch: string;
|
|
41
|
+
/** Suppress log messages. @default false */
|
|
42
|
+
quiet?: boolean;
|
|
43
|
+
/** Remove macOS quarantine attribute after download. @default true */
|
|
44
|
+
removeMacOSQuarantine?: boolean;
|
|
45
|
+
/** GitHub repository name. */
|
|
46
|
+
repo: string;
|
|
47
|
+
/** Specific release tag to download. */
|
|
48
|
+
tag?: string;
|
|
49
|
+
/** Tool name for directory structure. */
|
|
50
|
+
toolName: string;
|
|
51
|
+
/** Tool prefix for finding latest release. */
|
|
52
|
+
toolPrefix?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for repository access.
|
|
56
|
+
*/
|
|
57
|
+
export interface RepoConfig {
|
|
58
|
+
/**
|
|
59
|
+
* GitHub repository owner/organization.
|
|
60
|
+
*/
|
|
61
|
+
owner: string;
|
|
62
|
+
/**
|
|
63
|
+
* GitHub repository name.
|
|
64
|
+
*/
|
|
65
|
+
repo: string;
|
|
66
|
+
}
|
|
@@ -14,5 +14,5 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
return to;
|
|
15
15
|
};
|
|
16
16
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
|
-
var
|
|
18
|
-
module.exports = __toCommonJS(
|
|
17
|
+
var github_types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(github_types_exports);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview Socket-btm release download utilities.
|
|
3
3
|
*/
|
|
4
4
|
import { type Arch, type Libc, type Platform } from '../constants/platform';
|
|
5
|
-
import {
|
|
5
|
+
import type { AssetPattern } from './github-types';
|
|
6
6
|
export type { Arch, Libc, Platform };
|
|
7
7
|
/**
|
|
8
8
|
* Socket-btm GitHub repository configuration.
|
|
@@ -29,7 +29,9 @@ __export(socket_btm_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(socket_btm_exports);
|
|
31
31
|
var import_platform = require("../constants/platform");
|
|
32
|
-
var
|
|
32
|
+
var import_github_api = require("./github-api");
|
|
33
|
+
var import_github_downloads = require("./github-downloads");
|
|
34
|
+
var import_primordials = require("../primordials");
|
|
33
35
|
const SOCKET_BTM_REPO = {
|
|
34
36
|
owner: "SocketDev",
|
|
35
37
|
repo: "socket-btm"
|
|
@@ -93,27 +95,25 @@ async function downloadSocketBtmRelease(tool, options) {
|
|
|
93
95
|
resolvedAsset = asset;
|
|
94
96
|
} else {
|
|
95
97
|
if (tag) {
|
|
96
|
-
throw new
|
|
98
|
+
throw new import_primordials.ErrorCtor(
|
|
97
99
|
"Cannot use asset pattern with explicit tag. Either provide exact asset name or omit tag."
|
|
98
100
|
);
|
|
99
101
|
}
|
|
100
|
-
resolvedTag = await (0,
|
|
101
|
-
assetPattern: asset
|
|
102
|
-
quiet
|
|
102
|
+
resolvedTag = await (0, import_github_api.getLatestRelease)(toolPrefix, SOCKET_BTM_REPO, {
|
|
103
|
+
assetPattern: asset
|
|
103
104
|
}) ?? void 0;
|
|
104
105
|
if (!resolvedTag) {
|
|
105
|
-
throw new
|
|
106
|
+
throw new import_primordials.ErrorCtor(
|
|
107
|
+
`No ${tool} release with matching asset pattern found`
|
|
108
|
+
);
|
|
106
109
|
}
|
|
107
|
-
const assetUrl = await (0,
|
|
110
|
+
const assetUrl = await (0, import_github_api.getReleaseAssetUrl)(
|
|
108
111
|
resolvedTag,
|
|
109
112
|
asset,
|
|
110
|
-
SOCKET_BTM_REPO
|
|
111
|
-
{
|
|
112
|
-
quiet
|
|
113
|
-
}
|
|
113
|
+
SOCKET_BTM_REPO
|
|
114
114
|
);
|
|
115
115
|
if (!assetUrl) {
|
|
116
|
-
throw new
|
|
116
|
+
throw new import_primordials.ErrorCtor(`No matching asset found in release ${resolvedTag}`);
|
|
117
117
|
}
|
|
118
118
|
resolvedAsset = assetUrl.split("/").pop() || asset.toString();
|
|
119
119
|
}
|
|
@@ -169,12 +169,12 @@ async function downloadSocketBtmRelease(tool, options) {
|
|
|
169
169
|
removeMacOSQuarantine
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
return await (0,
|
|
172
|
+
return await (0, import_github_downloads.downloadGitHubRelease)(downloadConfig);
|
|
173
173
|
}
|
|
174
174
|
function getBinaryAssetName(binaryBaseName, platform, arch, libc) {
|
|
175
175
|
const mappedArch = ARCH_MAP[arch];
|
|
176
176
|
if (!mappedArch) {
|
|
177
|
-
throw new
|
|
177
|
+
throw new import_primordials.ErrorCtor(`Unsupported architecture: ${arch}`);
|
|
178
178
|
}
|
|
179
179
|
const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
|
|
180
180
|
const ext = platform === "win32" ? ".exe" : "";
|
|
@@ -187,7 +187,7 @@ function getBinaryAssetName(binaryBaseName, platform, arch, libc) {
|
|
|
187
187
|
if (platform === "win32") {
|
|
188
188
|
return `${binaryBaseName}-win32-${mappedArch}${ext}`;
|
|
189
189
|
}
|
|
190
|
-
throw new
|
|
190
|
+
throw new import_primordials.ErrorCtor(`Unsupported platform: ${platform}`);
|
|
191
191
|
}
|
|
192
192
|
function getBinaryName(binaryBaseName, platform) {
|
|
193
193
|
return platform === "win32" ? `${binaryBaseName}.exe` : binaryBaseName;
|
|
@@ -195,11 +195,11 @@ function getBinaryName(binaryBaseName, platform) {
|
|
|
195
195
|
function getPlatformArch(platform, arch, libc) {
|
|
196
196
|
const mappedPlatform = PLATFORM_MAP[platform];
|
|
197
197
|
if (!mappedPlatform) {
|
|
198
|
-
throw new
|
|
198
|
+
throw new import_primordials.ErrorCtor(`Unsupported platform: ${platform}`);
|
|
199
199
|
}
|
|
200
200
|
const mappedArch = ARCH_MAP[arch];
|
|
201
201
|
if (!mappedArch) {
|
|
202
|
-
throw new
|
|
202
|
+
throw new import_primordials.ErrorCtor(`Unsupported architecture: ${arch}`);
|
|
203
203
|
}
|
|
204
204
|
const muslSuffix = platform === "linux" && libc === "musl" ? "-musl" : "";
|
|
205
205
|
return `${mappedPlatform}-${mappedArch}${muslSuffix}`;
|
package/dist/schema/parse.js
CHANGED
|
@@ -24,13 +24,14 @@ __export(parse_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(parse_exports);
|
|
26
26
|
var import_validate = require("./validate");
|
|
27
|
+
var import_primordials = require("../primordials");
|
|
27
28
|
function parseSchema(schema, data) {
|
|
28
29
|
const result = (0, import_validate.validateSchema)(schema, data);
|
|
29
30
|
if (result.ok) {
|
|
30
31
|
return result.value;
|
|
31
32
|
}
|
|
32
33
|
const summary = result.errors.map((e) => `${e.path.join(".") || "(root)"}: ${e.message}`).join(", ");
|
|
33
|
-
throw new
|
|
34
|
+
throw new import_primordials.ErrorCtor(`Validation failed: ${summary}`);
|
|
34
35
|
}
|
|
35
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
37
|
0 && (module.exports = {
|
package/dist/schema/validate.js
CHANGED
|
@@ -23,11 +23,12 @@ __export(validate_exports, {
|
|
|
23
23
|
validateSchema: () => validateSchema
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(validate_exports);
|
|
26
|
+
var import_primordials = require("../primordials");
|
|
26
27
|
function isTypeBoxSchema(schema) {
|
|
27
28
|
if (schema === null || typeof schema !== "object") {
|
|
28
29
|
return false;
|
|
29
30
|
}
|
|
30
|
-
for (const sym of
|
|
31
|
+
for (const sym of (0, import_primordials.ObjectGetOwnPropertySymbols)(schema)) {
|
|
31
32
|
if (sym.description === "TypeBox.Kind") {
|
|
32
33
|
return typeof schema[sym] === "string";
|
|
33
34
|
}
|
|
@@ -41,7 +42,7 @@ function normalizeTypeBoxErrors(errors) {
|
|
|
41
42
|
out.push({
|
|
42
43
|
path: segs.map((s) => {
|
|
43
44
|
const n = Number(s);
|
|
44
|
-
return
|
|
45
|
+
return (0, import_primordials.NumberIsInteger)(n) && String(n) === s ? n : s;
|
|
45
46
|
}),
|
|
46
47
|
message: err.message
|
|
47
48
|
});
|
|
@@ -53,13 +54,13 @@ function normalizeZodError(err) {
|
|
|
53
54
|
return [{ path: [], message: String(err) }];
|
|
54
55
|
}
|
|
55
56
|
const issues = err.issues;
|
|
56
|
-
if (!
|
|
57
|
+
if (!(0, import_primordials.ArrayIsArray)(issues)) {
|
|
57
58
|
return [{ path: [], message: "Unknown validation error" }];
|
|
58
59
|
}
|
|
59
60
|
return issues.map((issue) => {
|
|
60
61
|
const i = issue;
|
|
61
62
|
return {
|
|
62
|
-
path:
|
|
63
|
+
path: (0, import_primordials.ArrayIsArray)(i.path) ? i.path : [],
|
|
63
64
|
message: typeof i.message === "string" ? i.message : "Invalid value"
|
|
64
65
|
};
|
|
65
66
|
});
|
|
@@ -88,7 +89,7 @@ function validateSchema(schema, data) {
|
|
|
88
89
|
errors: normalizeZodError(result.error)
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
throw new
|
|
92
|
+
throw new import_primordials.TypeErrorCtor(
|
|
92
93
|
"validateSchema: unsupported schema kind. Expected a Zod schema or an object with a safeParse method."
|
|
93
94
|
);
|
|
94
95
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview SEA (Single Executable Application) binary detection +
|
|
3
|
+
* path accessor.
|
|
4
|
+
*
|
|
5
|
+
* Two responsibilities (mirror of `src/smol/util.ts` shape):
|
|
6
|
+
*
|
|
7
|
+
* 1. `isSeaBinary()` — memoized boolean detector for whether the
|
|
8
|
+
* current process is running as a Node.js Single Executable
|
|
9
|
+
* Application. Probes via Node 24+'s `node:sea.isSea()` native
|
|
10
|
+
* API; falls back to `false` on older runtimes.
|
|
11
|
+
*
|
|
12
|
+
* 2. `getSeaBinaryPath()` — returns the path of the SEA binary
|
|
13
|
+
* (`process.argv[0]` normalized) when running as SEA, otherwise
|
|
14
|
+
* `undefined`.
|
|
15
|
+
*
|
|
16
|
+
* Defensive across runtimes: returns `false` / `undefined` cleanly on
|
|
17
|
+
* stock Node < 24, browsers, Deno, Bun.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Detect if the current process is running as a SEA binary.
|
|
21
|
+
* Uses Node.js 24+ native API with caching for performance.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* if (isSeaBinary()) {
|
|
26
|
+
* console.log('Running as a Single Executable Application')
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function isSeaBinary(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get the current SEA binary path.
|
|
33
|
+
* Only valid when running as a SEA binary.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const binPath = getSeaBinaryPath()
|
|
38
|
+
* if (binPath) {
|
|
39
|
+
* console.log(`Running as SEA binary: ${binPath}`)
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function getSeaBinaryPath(): string | undefined;
|
|
@@ -28,18 +28,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var util_exports = {};
|
|
32
|
+
__export(util_exports, {
|
|
33
33
|
getSeaBinaryPath: () => getSeaBinaryPath,
|
|
34
34
|
isSeaBinary: () => isSeaBinary
|
|
35
35
|
});
|
|
36
|
-
module.exports = __toCommonJS(
|
|
36
|
+
module.exports = __toCommonJS(util_exports);
|
|
37
37
|
var import_node_process = __toESM(require("node:process"));
|
|
38
|
-
var import_normalize = require("
|
|
38
|
+
var import_normalize = require("../paths/normalize");
|
|
39
39
|
let _isSea;
|
|
40
|
-
function getSeaBinaryPath() {
|
|
41
|
-
return isSeaBinary() && import_node_process.default.argv[0] ? (0, import_normalize.normalizePath)(import_node_process.default.argv[0]) : void 0;
|
|
42
|
-
}
|
|
43
40
|
function isSeaBinary() {
|
|
44
41
|
if (_isSea === void 0) {
|
|
45
42
|
try {
|
|
@@ -51,6 +48,9 @@ function isSeaBinary() {
|
|
|
51
48
|
}
|
|
52
49
|
return _isSea ?? false;
|
|
53
50
|
}
|
|
51
|
+
function getSeaBinaryPath() {
|
|
52
|
+
return isSeaBinary() && import_node_process.default.argv[0] ? (0, import_normalize.normalizePath)(import_node_process.default.argv[0]) : void 0;
|
|
53
|
+
}
|
|
54
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
55
|
0 && (module.exports = {
|
|
56
56
|
getSeaBinaryPath,
|
package/dist/shadow.js
CHANGED
|
@@ -44,7 +44,8 @@ function shouldSkipShadow(binPath, options) {
|
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
const userAgent = import_node_process.default.env["npm_config_user_agent"];
|
|
47
|
-
if (userAgent?.includes("exec") || userAgent?.includes("npx") ||
|
|
47
|
+
if (userAgent?.includes("exec") || userAgent?.includes("npx") || // # socket-hook: allow npx
|
|
48
|
+
userAgent?.includes("dlx")) {
|
|
48
49
|
return true;
|
|
49
50
|
}
|
|
50
51
|
const normalizedCwd = (0, import_normalize.normalizePath)(cwd);
|
package/dist/signal-exit.js
CHANGED
|
@@ -133,7 +133,7 @@ function processReallyExit(code) {
|
|
|
133
133
|
globalProcess,
|
|
134
134
|
[exitCode]
|
|
135
135
|
);
|
|
136
|
-
throw new
|
|
136
|
+
throw new import_primordials.ErrorCtor("processReallyExit should never return");
|
|
137
137
|
}
|
|
138
138
|
// @__NO_SIDE_EFFECTS__
|
|
139
139
|
function load() {
|
|
@@ -168,7 +168,7 @@ function onExit(cb, options) {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
if (typeof cb !== "function") {
|
|
171
|
-
throw new
|
|
171
|
+
throw new import_primordials.TypeErrorCtor("a callback must be provided for exit handler");
|
|
172
172
|
}
|
|
173
173
|
if (loaded === false) {
|
|
174
174
|
/* @__PURE__ */ load();
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lazy-loader for socket-btm's `node:smol-primordial`
|
|
3
|
+
* binding.
|
|
4
|
+
*
|
|
5
|
+
* `node:smol-primordial` provides V8 Fast API typed implementations
|
|
6
|
+
* of Math.* and Number.is* primordials, registered with
|
|
7
|
+
* `CFunction::Make()` so TurboFan inlines them directly into JIT-
|
|
8
|
+
* compiled JS callers. Bypasses the FunctionCallbackInfo trampoline
|
|
9
|
+
* entirely — ~30-50% gain on hot loops where V8 doesn't already
|
|
10
|
+
* auto-inline.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` on stock Node + non-Node runtimes. Result is
|
|
13
|
+
* cached across calls.
|
|
14
|
+
*
|
|
15
|
+
* @internal — used by `src/primordials.ts` to resolve smol-aware
|
|
16
|
+
* Math.* / Number.is* fast paths. Most callers should use the
|
|
17
|
+
* standard `primordials` exports, which already route through this
|
|
18
|
+
* when smol is present.
|
|
19
|
+
*
|
|
20
|
+
* @see https://v8.dev/blog/v8-release-99 — V8 Fast API Calls overview
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Surface of `node:smol-primordial`. See socket-btm's
|
|
24
|
+
* additions/source-patched/lib/smol-primordial.js for the canonical
|
|
25
|
+
* shape.
|
|
26
|
+
*
|
|
27
|
+
* Each entry is registered as a `v8::CFunction` so V8 can inline the
|
|
28
|
+
* C++ implementation directly into JIT-compiled callers — eliminating
|
|
29
|
+
* the FunctionCallbackInfo allocation, the HandleScope, and the call-
|
|
30
|
+
* site trampoline. See the C++ binding file for which signatures
|
|
31
|
+
* get real wins (and which don't).
|
|
32
|
+
*/
|
|
33
|
+
export interface SmolPrimordialBinding {
|
|
34
|
+
arrayIsArray(v: unknown): v is unknown[];
|
|
35
|
+
dateNow(): number;
|
|
36
|
+
mathAbs(x: number): number;
|
|
37
|
+
mathAcos(x: number): number;
|
|
38
|
+
mathAcosh(x: number): number;
|
|
39
|
+
mathAsin(x: number): number;
|
|
40
|
+
mathAsinh(x: number): number;
|
|
41
|
+
mathAtan(x: number): number;
|
|
42
|
+
mathAtan2(a: number, b: number): number;
|
|
43
|
+
mathAtanh(x: number): number;
|
|
44
|
+
mathCbrt(x: number): number;
|
|
45
|
+
mathCeil(x: number): number;
|
|
46
|
+
mathClz32(v: number): number;
|
|
47
|
+
mathCos(x: number): number;
|
|
48
|
+
mathCosh(x: number): number;
|
|
49
|
+
mathExp(x: number): number;
|
|
50
|
+
mathExpm1(x: number): number;
|
|
51
|
+
mathFloor(x: number): number;
|
|
52
|
+
mathFround(x: number): number;
|
|
53
|
+
mathHypot(a: number, b: number): number;
|
|
54
|
+
mathImul(a: number, b: number): number;
|
|
55
|
+
mathLog(x: number): number;
|
|
56
|
+
mathLog1p(x: number): number;
|
|
57
|
+
mathLog2(x: number): number;
|
|
58
|
+
mathLog10(x: number): number;
|
|
59
|
+
mathPow(a: number, b: number): number;
|
|
60
|
+
mathRound(x: number): number;
|
|
61
|
+
mathSign(x: number): number;
|
|
62
|
+
mathSin(x: number): number;
|
|
63
|
+
mathSinh(x: number): number;
|
|
64
|
+
mathSqrt(x: number): number;
|
|
65
|
+
mathTan(x: number): number;
|
|
66
|
+
mathTanh(x: number): number;
|
|
67
|
+
mathTrunc(x: number): number;
|
|
68
|
+
numberIsFinite(v: unknown): boolean;
|
|
69
|
+
numberIsInteger(v: unknown): boolean;
|
|
70
|
+
numberIsNaN(v: unknown): boolean;
|
|
71
|
+
numberIsSafeInteger(v: unknown): boolean;
|
|
72
|
+
numberParseFloat(s: string): number;
|
|
73
|
+
numberParseInt10(s: string): number;
|
|
74
|
+
stringCharCodeAt(s: string, i: number): number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns `node:smol-primordial` when running on the smol Node
|
|
78
|
+
* binary, otherwise `undefined`. Result is cached across calls.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getSmolPrimordial(): SmolPrimordialBinding | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var primordial_exports = {};
|
|
22
|
+
__export(primordial_exports, {
|
|
23
|
+
getSmolPrimordial: () => getSmolPrimordial
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(primordial_exports);
|
|
26
|
+
var import_util = require("./util");
|
|
27
|
+
let _smolPrimordial;
|
|
28
|
+
// @__NO_SIDE_EFFECTS__
|
|
29
|
+
function getSmolPrimordial() {
|
|
30
|
+
if (_smolPrimordial === void 0) {
|
|
31
|
+
if ((0, import_util.isSmol)()) {
|
|
32
|
+
try {
|
|
33
|
+
_smolPrimordial = require("node:smol-primordial");
|
|
34
|
+
} catch {
|
|
35
|
+
_smolPrimordial = null;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
_smolPrimordial = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return _smolPrimordial ?? void 0;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
getSmolPrimordial
|
|
46
|
+
});
|