@coderook/cli 0.47.0 → 0.47.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.
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ /**
3
+ * Which paths a filesystem will accept, for the service and the clients alike.
4
+ *
5
+ * A Version is only worth having if it can be written down again. The
6
+ * repository stores paths as text and compares them as text, which is more
7
+ * permissive than any real filesystem: Windows refuses a dozen characters and
8
+ * a list of device names inherited from DOS, macOS folds case and normalises
9
+ * Unicode, and nowhere can one name be a file and a directory at once.
10
+ *
11
+ * The service refuses these paths when a version is saved (backend
12
+ * portability.ts re-exports this file). The clients apply the same rules when
13
+ * they write, through safe_path.ts, because they are the side that touches the
14
+ * disk and must not rest on the service having been right. The two sets of
15
+ * rules used to be written twice and had drifted: the clients knew nothing of
16
+ * device names, trailing dots or control characters (audit, 16 November 2026).
17
+ *
18
+ * Two kinds of problem, deliberately separated:
19
+ *
20
+ * A path that no filesystem could ever hold is broken on its own, and is
21
+ * refused outright.
22
+ *
23
+ * Two paths that are individually fine but cannot coexist is a collision,
24
+ * and when it comes from combining two people's work it is a decision for
25
+ * somebody rather than an error.
26
+ *
27
+ * No imports: this runs in the Worker as well as in Node.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.fold = exports.PATH_LIMIT = exports.COMPONENT_LIMIT = void 0;
31
+ exports.isGitDirectoryName = isGitDirectoryName;
32
+ exports.isCbxDirectoryName = isCbxDirectoryName;
33
+ exports.isLinkDirectoryName = isLinkDirectoryName;
34
+ exports.isReservedDeviceName = isReservedDeviceName;
35
+ exports.nameProblem = nameProblem;
36
+ exports.windowsNameProblem = windowsNameProblem;
37
+ exports.whyUnwritable = whyUnwritable;
38
+ exports.unwritablePaths = unwritablePaths;
39
+ exports.collidingPaths = collidingPaths;
40
+ /** Device names DOS reserved, which Windows still refuses at any extension. */
41
+ const RESERVED = new Set([
42
+ "con", "prn", "aux", "nul",
43
+ ...Array.from({ length: 9 }, (_, at) => `com${at + 1}`),
44
+ ...Array.from({ length: 9 }, (_, at) => `lpt${at + 1}`),
45
+ ]);
46
+ /** Characters Windows will not put in a name, plus the control range. */
47
+ // eslint-disable-next-line no-control-regex
48
+ const FORBIDDEN = /[<>:"|?*\u0000-\u001f]/;
49
+ // eslint-disable-next-line no-control-regex
50
+ const CONTROL = /[\u0000-\u001f\u007f]/;
51
+ /** Long enough for anything real; past it, filesystems start refusing. */
52
+ exports.COMPONENT_LIMIT = 255;
53
+ exports.PATH_LIMIT = 4096;
54
+ /**
55
+ * A name git treats as its own directory, compared the way git compares it.
56
+ *
57
+ * Any case, trailing dots and spaces ignored, an alternate data stream
58
+ * ignored, and `git~1` — the short name Windows gives `.git`. The same list
59
+ * git's `verify_path` refuses with its NTFS and HFS protections on.
60
+ *
61
+ * Refused because a version is written into people's folders, and those are
62
+ * very often git checkouts. Gitea's CVE-2026-60004 was repository content
63
+ * landing in a hooks directory; here the equivalent was a `.git/config`
64
+ * fetched over a real one, where `core.fsmonitor` runs a command on the next
65
+ * `git status`. No honest client ever sends one: every scanner skips `.git`.
66
+ */
67
+ function isGitDirectoryName(part) {
68
+ const name = part.split(":")[0].replace(/[. ]+$/, "").toLowerCase();
69
+ return name === ".git" || /^git~\d+$/.test(name);
70
+ }
71
+ /**
72
+ * The name CBX keeps a folder's local history under, compared the same way.
73
+ *
74
+ * Every scanner skips it, so no honest client sends one; a version that held
75
+ * `.cbx/lines/main` would move somebody's local line when it was fetched.
76
+ */
77
+ function isCbxDirectoryName(part) {
78
+ return part.split(":")[0].replace(/[. ]+$/, "").toLowerCase() === ".cbx";
79
+ }
80
+ /**
81
+ * `.coderook`, the folder holding a folder's link to its project. A version
82
+ * carrying one could point the next save at somebody else's project; the
83
+ * clients never upload it, so nothing real is lost (audit, 16 November 2026).
84
+ */
85
+ function isLinkDirectoryName(part) {
86
+ return part.split(":")[0].replace(/[. ]+$/, "").toLowerCase() === ".coderook";
87
+ }
88
+ /** A DOS device name, whatever follows the dot: CON.txt is CON. */
89
+ function isReservedDeviceName(part) {
90
+ return RESERVED.has(part.split(".")[0].replace(/[. ]+$/, "").toLowerCase());
91
+ }
92
+ /**
93
+ * Why one name could not be created on any filesystem people use, or null.
94
+ *
95
+ * The rules a client applies before it writes, on every system: a control
96
+ * character is never a real name, and a name past 255 characters fails on
97
+ * every common filesystem.
98
+ */
99
+ function nameProblem(part) {
100
+ if (part.length > exports.COMPONENT_LIMIT)
101
+ return `a name longer than ${exports.COMPONENT_LIMIT} characters`;
102
+ if (CONTROL.test(part)) {
103
+ return `character ${CONTROL.exec(part)[0].charCodeAt(0)}, a control character`;
104
+ }
105
+ return null;
106
+ }
107
+ /**
108
+ * Why one name could not be created on Windows, or null.
109
+ *
110
+ * A client on Windows applies these as well: a name ending in a dot or a
111
+ * space is silently renamed by Windows, so it lands on another file's name,
112
+ * and a device name opens the device instead of a file.
113
+ */
114
+ function windowsNameProblem(part) {
115
+ const found = /[<>:"|?*]/.exec(part);
116
+ if (found)
117
+ return `"${found[0]}", which Windows will not accept in a name`;
118
+ if (/[. ]$/.test(part))
119
+ return "a name ending in a space or a full stop";
120
+ if (isReservedDeviceName(part)) {
121
+ return `"${part.split(".")[0].toUpperCase()}", a name Windows reserves for a device`;
122
+ }
123
+ return null;
124
+ }
125
+ /**
126
+ * Why this path could never be written, or null when it could.
127
+ *
128
+ * Judged per component, because a path is a sequence of names each of which
129
+ * has to be creatable on its own. This is the service's rule, applied to
130
+ * every path a version is saved with.
131
+ */
132
+ function whyUnwritable(path) {
133
+ if (!path)
134
+ return "an empty path";
135
+ if (path.length > exports.PATH_LIMIT)
136
+ return `longer than ${exports.PATH_LIMIT} characters`;
137
+ if (path.startsWith("/"))
138
+ return "an absolute path";
139
+ if (/^[a-zA-Z]:/.test(path))
140
+ return "a drive letter";
141
+ if (path.includes("\\"))
142
+ return "a backslash, which is a separator on Windows";
143
+ const parts = path.split("/");
144
+ for (const part of parts) {
145
+ if (!part)
146
+ return "an empty directory name";
147
+ if (part === "." || part === "..")
148
+ return `the path segment "${part}"`;
149
+ if (isGitDirectoryName(part)) {
150
+ return `"${part}", which is git's own directory and is never sent`;
151
+ }
152
+ if (isCbxDirectoryName(part)) {
153
+ return `"${part}", which is CBX's own history and is never sent`;
154
+ }
155
+ if (part.length > exports.COMPONENT_LIMIT) {
156
+ return `a name longer than ${exports.COMPONENT_LIMIT} characters`;
157
+ }
158
+ if (FORBIDDEN.test(part)) {
159
+ const found = FORBIDDEN.exec(part)[0];
160
+ const shown = found.charCodeAt(0) < 32
161
+ ? `character ${found.charCodeAt(0)}`
162
+ : `"${found}"`;
163
+ return `${shown}, which Windows will not accept in a name`;
164
+ }
165
+ /*
166
+ Windows silently strips these when creating a file, so a name ending in
167
+ one becomes a different name — and then never matches what the version
168
+ says it is.
169
+ */
170
+ if (/[. ]$/.test(part))
171
+ return "a name ending in a space or a full stop";
172
+ if (isReservedDeviceName(part)) {
173
+ return `"${part.split(".")[0].toUpperCase()}", a name Windows reserves for a device`;
174
+ }
175
+ }
176
+ return null;
177
+ }
178
+ /** Every path in a set that could not be written at all. */
179
+ function unwritablePaths(paths) {
180
+ const found = [];
181
+ for (const path of paths) {
182
+ const reason = whyUnwritable(path);
183
+ if (reason)
184
+ found.push({ path, reason });
185
+ }
186
+ return found;
187
+ }
188
+ /**
189
+ * One name, as the filesystems most people use would see it.
190
+ *
191
+ * Composed first so the two spellings of an accent agree, then folded so the
192
+ * two spellings of a capital do.
193
+ */
194
+ const fold = (path) => path.normalize("NFC").toLowerCase();
195
+ exports.fold = fold;
196
+ /**
197
+ * Paths that are individually fine but cannot all exist together.
198
+ *
199
+ * Two spellings of one name, or a name used as both a file and a directory.
200
+ * Returned rather than thrown: combining two people's valid work can produce
201
+ * this, and then it is a decision rather than a mistake.
202
+ *
203
+ * With `folded` false only exact clashes count (a file where another path
204
+ * needs a directory), which is what a case-sensitive filesystem cares about.
205
+ */
206
+ function collidingPaths(paths, folded = true) {
207
+ const clashing = new Set();
208
+ const bySpelling = new Map();
209
+ const directories = new Set();
210
+ const key = folded ? exports.fold : (path) => path;
211
+ for (const path of paths) {
212
+ const parts = path.split(/[\\/]/);
213
+ const name = key(parts.join("/"));
214
+ bySpelling.set(name, [...(bySpelling.get(name) ?? []), path]);
215
+ for (let depth = 1; depth < parts.length; depth += 1) {
216
+ directories.add(key(parts.slice(0, depth).join("/")));
217
+ }
218
+ }
219
+ for (const [, spellings] of bySpelling) {
220
+ if (spellings.length > 1)
221
+ for (const path of spellings)
222
+ clashing.add(path);
223
+ }
224
+ for (const [name, spellings] of bySpelling) {
225
+ // A file where another path needs a directory of the same name.
226
+ if (directories.has(name))
227
+ for (const path of spellings)
228
+ clashing.add(path);
229
+ }
230
+ return clashing;
231
+ }
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isGitDirectoryName = isGitDirectoryName;
7
- exports.isCbxDirectoryName = isCbxDirectoryName;
8
- exports.isLinkDirectoryName = isLinkDirectoryName;
6
+ exports.isLinkDirectoryName = exports.isGitDirectoryName = exports.isCbxDirectoryName = void 0;
9
7
  exports.whyUnsafe = whyUnsafe;
8
+ exports.foldsNames = foldsNames;
9
+ exports.clashingPaths = clashingPaths;
10
+ exports.refuseClashes = refuseClashes;
10
11
  exports.safeParts = safeParts;
11
12
  exports.inside = inside;
12
13
  /**
@@ -29,34 +30,12 @@ exports.inside = inside;
29
30
  * rule, not one per place that happened to think of it.
30
31
  */
31
32
  const node_path_1 = __importDefault(require("node:path"));
32
- /**
33
- * A name git treats as its own directory.
34
- *
35
- * The same comparison git's own `verify_path` makes with its NTFS and HFS
36
- * protections on: any case, trailing dots and spaces dropped, an alternate
37
- * data stream dropped, and the 8.3 short name Windows gives `.git`.
38
- */
39
- function isGitDirectoryName(part) {
40
- const name = part.split(":")[0].replace(/[. ]+$/, "").toLowerCase();
41
- return name === ".git" || /^git~\d+$/.test(name);
42
- }
43
- /**
44
- * A name CBX keeps its local history under, compared the way git's is.
45
- *
46
- * A version holding `.cbx/lines/main` would otherwise move somebody's line to
47
- * a save of the version's choosing the moment it was fetched.
48
- */
49
- function isCbxDirectoryName(part) {
50
- return part.split(":")[0].replace(/[. ]+$/, "").toLowerCase() === ".cbx";
51
- }
52
- /**
53
- * `.coderook`, the folder holding a folder's link to its project. A version
54
- * carrying one could point the next save at somebody else's project; the
55
- * clients never upload it, so nothing real is lost (audit, 16 November 2026).
56
- */
57
- function isLinkDirectoryName(part) {
58
- return part.split(":")[0].replace(/[. ]+$/, "").toLowerCase() === ".coderook";
59
- }
33
+ const path_rules_js_1 = require("./path_rules.js");
34
+ /* The one set of rules, shared with the service (path_rules.ts). */
35
+ var path_rules_js_2 = require("./path_rules.js");
36
+ Object.defineProperty(exports, "isCbxDirectoryName", { enumerable: true, get: function () { return path_rules_js_2.isCbxDirectoryName; } });
37
+ Object.defineProperty(exports, "isGitDirectoryName", { enumerable: true, get: function () { return path_rules_js_2.isGitDirectoryName; } });
38
+ Object.defineProperty(exports, "isLinkDirectoryName", { enumerable: true, get: function () { return path_rules_js_2.isLinkDirectoryName; } });
60
39
  /** Why this path must not be written, or null when it may. */
61
40
  function whyUnsafe(relative) {
62
41
  if (!relative)
@@ -69,19 +48,66 @@ function whyUnsafe(relative) {
69
48
  for (const part of relative.split(/[\\/]/)) {
70
49
  if (part === "..")
71
50
  return "it climbs out of the folder";
72
- if (isGitDirectoryName(part))
51
+ if ((0, path_rules_js_1.isGitDirectoryName)(part))
73
52
  return "it writes into git's own directory";
74
- if (isCbxDirectoryName(part))
53
+ if ((0, path_rules_js_1.isCbxDirectoryName)(part))
75
54
  return "it writes into CBX's own history";
76
- if (isLinkDirectoryName(part))
55
+ if ((0, path_rules_js_1.isLinkDirectoryName)(part))
77
56
  return "it writes into the folder's link to its project";
78
57
  /* A stream or a drive-relative name on Windows; refused by the service too. */
79
58
  if (process.platform === "win32" && part.includes(":")) {
80
59
  return "it names a Windows data stream";
81
60
  }
61
+ if (!part || part === ".")
62
+ continue;
63
+ /* Control characters and over-long names, everywhere; the service refuses both. */
64
+ const problem = (0, path_rules_js_1.nameProblem)(part);
65
+ if (problem)
66
+ return `it holds ${problem}`;
67
+ /*
68
+ Device names, trailing dots and spaces, and the characters Windows
69
+ refuses: only where Windows is the one writing. There a name like
70
+ `notes.txt.` is silently written as `notes.txt`, over another file, and
71
+ `CON` opens the console instead of a file.
72
+ */
73
+ if (process.platform === "win32") {
74
+ const windows = (0, path_rules_js_1.windowsNameProblem)(part);
75
+ if (windows)
76
+ return `it holds ${windows}`;
77
+ }
82
78
  }
83
79
  return null;
84
80
  }
81
+ /**
82
+ * Whether this system's folders ignore the case (and, on macOS, the Unicode
83
+ * form) of a name. Windows and macOS do by default; Linux does not.
84
+ */
85
+ function foldsNames(platform = process.platform) {
86
+ return platform === "win32" || platform === "darwin";
87
+ }
88
+ /**
89
+ * Paths of a version that would land on the same file here: README.md and
90
+ * readme.md on Windows or macOS, or a name that is both a file and a folder.
91
+ *
92
+ * Written into one staging folder, two such files became one, and the
93
+ * digest check passed for whichever was written last while the other was
94
+ * reported placed (audit, 16 November 2026). A version holding them is
95
+ * refused before anything is fetched, naming both.
96
+ */
97
+ function clashingPaths(paths, platform = process.platform) {
98
+ return [...(0, path_rules_js_1.collidingPaths)(paths, foldsNames(platform))].sort();
99
+ }
100
+ /** Throw, naming them, when `paths` cannot all be written into one folder here. */
101
+ function refuseClashes(paths, platform = process.platform) {
102
+ const clashing = clashingPaths(paths, platform);
103
+ if (!clashing.length)
104
+ return;
105
+ const shown = clashing.slice(0, 6).join(", ") + (clashing.length > 6 ? `, and ${clashing.length - 6} more` : "");
106
+ throw new Error(foldsNames(platform)
107
+ ? `That version holds paths that are one file on this system, which ignores capitals: ${shown}. ` +
108
+ "Rename one of each pair in the project, then fetch again."
109
+ : `That version holds a name that is both a file and a folder: ${shown}.`);
110
+ }
85
111
  /**
86
112
  * The path's parts, or an error naming the path and why.
87
113
  *
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ServiceError = void 0;
7
7
  exports.forgetFoundProjects = forgetFoundProjects;
8
+ exports.replyBody = replyBody;
8
9
  exports.putObject = putObject;
9
10
  exports.beginUpload = beginUpload;
10
11
  exports.uploadPart = uploadPart;
@@ -156,6 +157,26 @@ class ServiceError extends Error {
156
157
  }
157
158
  }
158
159
  exports.ServiceError = ServiceError;
160
+ /**
161
+ * A reply's JSON, read only after its status is known.
162
+ *
163
+ * Parsing first made every answer that was not JSON — a proxy's HTML error
164
+ * page, a gateway timeout, an empty 502 — surface as "Unexpected token <"
165
+ * instead of the status that explained it (audit, 16 November 2026).
166
+ */
167
+ function replyBody(text, route, status, ok) {
168
+ if (!text)
169
+ return {};
170
+ try {
171
+ return JSON.parse(text);
172
+ }
173
+ catch {
174
+ if (ok)
175
+ throw new ServiceError(`${route} answered with something that is not JSON`, status, null);
176
+ /* The status says what went wrong; the body was not ours to read. */
177
+ return {};
178
+ }
179
+ }
159
180
  async function call(route, options = {}) {
160
181
  const token = await (0, config_js_1.loadToken)();
161
182
  if (!token) {
@@ -195,7 +216,7 @@ async function call(route, options = {}) {
195
216
  }
196
217
  }
197
218
  const text = await response.text();
198
- const body = text ? JSON.parse(text) : {};
219
+ const body = replyBody(text, route, response.status, response.ok);
199
220
  if (!response.ok) {
200
221
  if (response.status === 401) {
201
222
  throw new Error("That token was not accepted. Run: cbx sign-in");
@@ -229,7 +250,7 @@ async function send(route, method, bytes, contentType) {
229
250
  signal: AbortSignal.timeout(REQUEST_DEADLINE_MS),
230
251
  });
231
252
  const text = await response.text();
232
- const body = text ? JSON.parse(text) : {};
253
+ const body = replyBody(text, route, response.status, response.ok);
233
254
  if (!response.ok) {
234
255
  throw new Error(body?.error?.message ??
235
256
  `${route} failed (${response.status})`);
@@ -317,6 +338,7 @@ async function projectById(repositoryId) {
317
338
  storedBytes: Number(row.storedSize ?? 0),
318
339
  updatedAt: String(row.updatedAt ?? row.createdAt ?? ""),
319
340
  member: row.member !== false,
341
+ ...(typeof row.ownerHandle === "string" && row.ownerHandle ? { ownerHandle: row.ownerHandle } : {}),
320
342
  };
321
343
  }
322
344
  catch {
@@ -42,6 +42,7 @@ exports.thisHost = thisHost;
42
42
  exports.detectTools = detectTools;
43
43
  exports.describeProject = describeProject;
44
44
  exports.wslPath = wslPath;
45
+ exports.outFolderProblem = outFolderProblem;
45
46
  exports.planBuild = planBuild;
46
47
  exports.markExecutables = markExecutables;
47
48
  exports.fileFromTar = fileFromTar;
@@ -80,6 +81,8 @@ const promises_1 = require("node:fs/promises");
80
81
  const node_path_1 = __importDefault(require("node:path"));
81
82
  const node_process_1 = __importDefault(require("node:process"));
82
83
  const portable_python_js_1 = require("./portable_python.js");
84
+ const build_pins_js_1 = require("./build_pins.js");
85
+ const path_rules_js_1 = require("../../cbx/src/shared/path_rules.js");
83
86
  const ESC = String.fromCharCode(27);
84
87
  const colour = node_process_1.default.stdout.isTTY && !node_process_1.default.env.NO_COLOR;
85
88
  const paint = (code) => (value) => (colour ? `${ESC}[${code}m${value}${ESC}[0m` : value);
@@ -320,8 +323,40 @@ const NEEDS = (os) => `run cbx build --target ${os === "macos" ? "mac" : os} on
320
323
  * Pure: the same project, host and tools always give the same plan, which is
321
324
  * what lets the choices be tested for machines this one is not.
322
325
  */
326
+ /**
327
+ * Why `out` cannot be where builds go, or null when it can.
328
+ *
329
+ * The folder is emptied before every build. `out` comes from the project's
330
+ * own settings file, so a project could name `..`, an absolute path or the
331
+ * project itself and have a stranger's `cbx build` delete it (audit, 16
332
+ * November 2026). It must be a folder inside the project, and not the
333
+ * project, nor anything inside git's or CBX's own folders.
334
+ */
335
+ function outFolderProblem(projectFolder, out) {
336
+ if (!out.trim())
337
+ return "the build folder (out) is empty";
338
+ if (node_path_1.default.isAbsolute(out) || /^[a-zA-Z]:/.test(out) || /^[\\/]/.test(out)) {
339
+ return `the build folder (out) must be inside the project, not ${out}`;
340
+ }
341
+ const parts = out.split(/[\\/]/).filter((part) => part && part !== ".");
342
+ if (!parts.length)
343
+ return "the build folder (out) cannot be the project itself";
344
+ if (parts.some((part) => part === ".."))
345
+ return `the build folder (out) climbs out of the project: ${out}`;
346
+ if (parts.some((part) => (0, path_rules_js_1.isGitDirectoryName)(part) || (0, path_rules_js_1.isCbxDirectoryName)(part))) {
347
+ return `the build folder (out) cannot be inside git's or CBX's own folder: ${out}`;
348
+ }
349
+ const base = node_path_1.default.resolve(projectFolder);
350
+ const full = node_path_1.default.resolve(base, ...parts);
351
+ if (!full.startsWith(base + node_path_1.default.sep))
352
+ return `the build folder (out) must be inside the project, not ${out}`;
353
+ return null;
354
+ }
323
355
  function planBuild(project, host, tools, targets) {
324
356
  const outRoot = project.config.out ?? node_path_1.default.join(".coderook", "build");
357
+ const outProblem = outFolderProblem(project.folder, outRoot);
358
+ if (outProblem)
359
+ return targets.map((target) => ({ target, ok: false, why: outProblem }));
325
360
  const extra = project.config.args ?? [];
326
361
  const before = project.config.before;
327
362
  return targets.map((target) => {
@@ -697,6 +732,15 @@ async function fetchBunRuntime(target, to) {
697
732
  const meta = (await (await fetch(`https://registry.npmjs.org/@oven/${pkg}/${version}`, { signal: AbortSignal.timeout(60_000) })).json());
698
733
  if (!meta.dist?.tarball || !meta.dist.integrity?.startsWith("sha512-"))
699
734
  throw new Error("npm did not describe the package");
735
+ /*
736
+ The digest is only as good as the answer it came in. npm signs it with
737
+ a key pinned in build_pins.ts, so an answer npm did not give is refused.
738
+ */
739
+ if (meta.name !== `@oven/${pkg}` || meta.version !== version || !(0, build_pins_js_1.npmSigned)(meta.name, version, meta.dist.integrity, meta.dist.signatures)) {
740
+ throw new Error("npm's signature over the package does not check out");
741
+ }
742
+ if (new URL(meta.dist.tarball).origin !== "https://registry.npmjs.org")
743
+ throw new Error("the package is not served by npm");
700
744
  const tarball = Buffer.from(await (await fetch(meta.dist.tarball, { signal: AbortSignal.timeout(15 * 60_000) })).arrayBuffer());
701
745
  const digest = `sha512-${(0, node_crypto_1.createHash)("sha512").update(tarball).digest("base64")}`;
702
746
  if (digest !== meta.dist.integrity)
@@ -760,7 +804,8 @@ function run(step, cwd) {
760
804
  })();
761
805
  }
762
806
  return new Promise((done) => {
763
- const env = { ...node_process_1.default.env, ...(step.env ?? {}) };
807
+ /* The project's own commands never see the CodeRook token (build_pins.ts). */
808
+ const env = (0, build_pins_js_1.buildEnvironment)(step.env ?? {});
764
809
  const child = "shell" in step
765
810
  ? (0, node_child_process_1.spawn)(step.shell, { cwd, env, stdio: "inherit", shell: true })
766
811
  /*
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UV_WHEEL_DIGESTS = exports.UV_VERSION = exports.PYTHON_VERSIONS = exports.PYTHON_RELEASE = void 0;
4
+ exports.pinnedPython = pinnedPython;
5
+ exports.uvRequirements = uvRequirements;
6
+ exports.npmSigned = npmSigned;
7
+ exports.buildEnvironment = buildEnvironment;
8
+ /**
9
+ * What `cbx build` downloads, pinned.
10
+ *
11
+ * The build fetches a CPython for the target, uv to resolve its wheels, and
12
+ * Bun's runtime for another system. Each used to be whatever its source
13
+ * called newest, checked only against a digest the same source published in
14
+ * the same answer, so a source that was wrong, compromised or impersonated
15
+ * could hand over any program and it would be built into somebody's release
16
+ * (audit, 16 November 2026). Now:
17
+ *
18
+ * - CPython is one python-build-standalone release, with each archive's
19
+ * SHA-256 written here.
20
+ * - uv, when pip installs it, is one version, with every wheel's SHA-256
21
+ * written here and pip told to accept nothing else (--require-hashes).
22
+ * - Bun's runtime has to match the Bun that builds, so its version cannot be
23
+ * fixed here; instead npm's own signature over the package's digest is
24
+ * checked against npm's public signing key, written here. A registry answer
25
+ * cannot be forged without npm's private key.
26
+ *
27
+ * Moving a pin is a code change: fetch the new release's published digests,
28
+ * check them, and replace the tables below.
29
+ */
30
+ const node_crypto_1 = require("node:crypto");
31
+ /* ------------------------------------------------------------- CPython */
32
+ /** python-build-standalone release 20261110 (published 11 November 2026). */
33
+ exports.PYTHON_RELEASE = "20261110";
34
+ /** The full CPython version each minor version is pinned to in that release. */
35
+ exports.PYTHON_VERSIONS = {
36
+ "3.11": "3.11.18",
37
+ "3.12": "3.12.16",
38
+ "3.13": "3.13.18",
39
+ "3.14": "3.14.10",
40
+ "3.15": "3.15.2",
41
+ };
42
+ const TRIPLES = ["macos-arm64", "windows-arm64", "linux-arm64", "macos-x64", "windows-x64", "linux-x64"];
43
+ /* SHA-256 of each install_only archive, in TRIPLES order, as the release publishes them. */
44
+ const PYTHON_DIGESTS = {
45
+ "3.11": [
46
+ "73f1ed14486aa278d331e95f7d6d452f5cfb69d90b418e26e62fd4846d53557d",
47
+ "2627dd511436b3f6e6db455907852dd260e62e6007dc43f9edfd967b2bf34a6b",
48
+ "623a370be4489d8c35c7a274be02f3007a030618cda29025780beb416c6c8861",
49
+ "9ff3ea8df9037e692939a3f2348f5fd760239ab8eb9d0d2d11d099457dda63a0",
50
+ "5ca7e23bbcc8933a75f4ae9c3a5e5d1ffae5fd143aec9a9d77cf5124cc6e0eef",
51
+ "ac0b758b6ae4ba1cb87f7091eb6bb17c9a383a9bcdb5c18493cdd4f34e35ae8c",
52
+ ],
53
+ "3.12": [
54
+ "e956e60bc9465d577ef8062059aa05cd3a2665b4b8678a2ed24e432368330b8f",
55
+ "7122bf62a0cf601527ba62e19ca715d64db86b269765da23937e9ac7f968f39c",
56
+ "4792f81750282597fb2a3389fe18b945ed2ba6aad5e45ad406d122c58cb33081",
57
+ "83f2922437e6d546d0fcdb8c11f150a8e52787e8d9ea8651b1974e20908eb1bc",
58
+ "e23fe5b16926de1d81661b1a97352e89fb167549c55a6825796ccd0f32ec7f1b",
59
+ "c2f87d4b4e8db3abddb0f116c6ccfc503d0cbdbb9ee8faacddad1b679ec12e99",
60
+ ],
61
+ "3.13": [
62
+ "1afd3983237c2a10277345f235be730e9cb49a123e0574ed252dbf3a841a24e4",
63
+ "f050f4df570616e75aac723a5d05319c0d69ea65243506071bcff162774050ca",
64
+ "d25a65036d5e149db902fa52ad65878d0c00e9301360ec197832f99063087e9e",
65
+ "a46bcdeecd28ba253522b321dcb3806da1b0ff581479fc1d27e9613e3ac44764",
66
+ "7e93813bd362c6413f30788b248590e2f169df2d17dcac81aafbcc7a6eeb542c",
67
+ "50c774f6674740739f791c05a9177ed03e2fe02abebda9bca3512eb7309b37cc",
68
+ ],
69
+ "3.14": [
70
+ "42031ed5f0d38777335252c8c77d64708c8010dd67c128246bdec25000672666",
71
+ "d1a855c3debb8c66e2ad684373f807d35ce9a2b5abf9241a846a8054d8ff2bdf",
72
+ "e59f83159984a55e719bb3805a0b2b5b281f645769222218084b78b92eedc07f",
73
+ "f6c82fcf867b4aaadd373ac97699ad95fbb9c96f9ecf9b25775943aa5458b87f",
74
+ "b9bee0a6f590914a495a8305701951e543b4475bb620d11661b49052b990456b",
75
+ "3fe0d7c0538eb5d190c34582992d26230532551355cbd789fabc6591621cfc07",
76
+ ],
77
+ "3.15": [
78
+ "6767ca67fdcfa3a966b6fb77fc3d4dd4020063fce27ac1e9425fab653195cbab",
79
+ "9f08b2ff987300f05aec566d1aad718036e5ce4eddbcf300ead1d8cab6242c5e",
80
+ "362378c07e01f1d7b18406760ace75e794c21dfff3693535b1bbffe88eec2e52",
81
+ "b9cff41dd36566bece864959f0104e6ddc233dfd4d92b3a9ccbb12d6eff38a7b",
82
+ "a0e4e14d152efbd2a66e4873efe0b4ab42e1ee759441dbc23af034236d7a09cd",
83
+ "182e7adf7e4f0e32dafac5143f00d466afd20eef45918ea170f78884e503ac18",
84
+ ],
85
+ };
86
+ /**
87
+ * The pinned CPython archive for a minor version ("3.12") and target, or an
88
+ * error naming the versions that are pinned.
89
+ */
90
+ function pinnedPython(minor, target, triple) {
91
+ const version = exports.PYTHON_VERSIONS[minor];
92
+ const digest = PYTHON_DIGESTS[minor]?.[TRIPLES.indexOf(target)];
93
+ if (!version || !digest) {
94
+ throw new Error(`no pinned CPython ${minor}; this cbx builds with ${Object.keys(exports.PYTHON_VERSIONS).join(", ")} ` +
95
+ `(set "python" in the build settings to one of them)`);
96
+ }
97
+ const name = `cpython-${version}+${exports.PYTHON_RELEASE}-${triple}-install_only.tar.gz`;
98
+ return {
99
+ name,
100
+ version,
101
+ sha256: digest,
102
+ url: `https://github.com/astral-sh/python-build-standalone/releases/download/${exports.PYTHON_RELEASE}/${encodeURIComponent(name)}`,
103
+ };
104
+ }
105
+ /* ------------------------------------------------------------------ uv */
106
+ /** uv 0.13.7 (3 November 2026): every wheel PyPI holds for it. */
107
+ exports.UV_VERSION = "0.13.7";
108
+ exports.UV_WHEEL_DIGESTS = [
109
+ "89df450624dec8c48b8b5a7adb654928cc50e95753f869c70cd65ef8333f2197",
110
+ "fd04bf01ba5f2829f4f94ca8f0c24a743f21e73d75045613ed6fc2fd66fc7bda",
111
+ "f91a229093163eefca89ea1b220a221d64c3beade05d03519a6584d1797a5a5f",
112
+ "a90f5d95716ab83091f0f73a8e7ec64e557abf2a28537fcd719b2ac88e6f725a",
113
+ "952dcae9b1a7742f2fab28e82391fbfabe8807e4e9363f674b0f6be1053b8dd4",
114
+ "94f65a8ac5826dff76a93cb3cafbaad15def1788c63da2ce5ce09e0bd1303e7a",
115
+ "57ff66891d9a738ec087c23fdde842ac8e5eb63189ffed6ee95caee1b82ceb54",
116
+ "917733990ebc178318af0321d6873823ed5da707e1c4b1e5060ac2065a81f1f3",
117
+ "1bc8543d930464bbb22ac01bb1a660a448235e558014914de1e1cd5b993361b8",
118
+ "2c9bdc4a872b60a93c5f26c0791089ea11585a4f9d3b3c017d78eb8487505e25",
119
+ "08f16fd463926786b702b497473511deae4b3e17a2fa6d22180950d6059a120d",
120
+ "d30cafb7070901ba35353ec64cf228ae46caf79ac0f6fae329f95468b1482531",
121
+ "158953b8669bee6f4bc2babdd997e34ff9f0d57170093cfe907f64448292b7c3",
122
+ "8fc6019740794df995085f7b278d99dc11ccacffad9c63957278d3a6e272280b",
123
+ "8b8ac028ae4ebb2a3f9d04907c61794f2cf8d7a7002bfbb4019a3dee28351fb2",
124
+ "5f37cc4d4660e4aee8a24d0dc179a0b0ce99506259c6796d37fa69bca9543a03",
125
+ "2835e2ab397d0db86323b9975dce75ecd76aa9cfa0d6a2aea84734aae7f8c9b3",
126
+ "55e741a380a98008fc4985cf069855f36bc50242ef438e21a466786f5bc84da8",
127
+ ];
128
+ /** A pip requirements file that accepts only the pinned uv wheels. */
129
+ function uvRequirements() {
130
+ return `uv==${exports.UV_VERSION} ${exports.UV_WHEEL_DIGESTS.map((digest) => `--hash=sha256:${digest}`).join(" ")}\n`;
131
+ }
132
+ /* ----------------------------------------------------------------- Bun */
133
+ /*
134
+ npm's registry signing key (keyid SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U),
135
+ from https://registry.npmjs.org/-/npm/v1/keys, with no expiry. npm signs
136
+ `<name>@<version>:<integrity>` for every package it serves.
137
+ */
138
+ const NPM_KEY_ID = "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U";
139
+ const NPM_KEY = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEY6Ya7W++7aUPzvMTrezH6Ycx3c+HOKYCcNGybJZSCJq/fd7Qa8uuAKtdIkUQtQiEKERhAmE5lMMJhP8OkDOa2g==";
140
+ /** Whether npm signed this package version's integrity digest. */
141
+ function npmSigned(name, version, integrity, signatures) {
142
+ const key = (0, node_crypto_1.createPublicKey)({ key: Buffer.from(NPM_KEY, "base64"), format: "der", type: "spki" });
143
+ const message = Buffer.from(`${name}@${version}:${integrity}`);
144
+ return (signatures ?? []).some((one) => one.keyid === NPM_KEY_ID &&
145
+ typeof one.sig === "string" &&
146
+ (0, node_crypto_1.verify)("sha256", message, key, Buffer.from(one.sig, "base64")));
147
+ }
148
+ /* --------------------------------------------------------------- children */
149
+ /**
150
+ * The environment a build's own commands run with: this one, without the
151
+ * CodeRook token. A project's build script, its `before` step and every
152
+ * dependency's setup code run here, and none of them needs the account's
153
+ * token; handing it over let any of them act as the person building.
154
+ */
155
+ function buildEnvironment(extra = {}) {
156
+ const env = { ...process.env, ...extra };
157
+ for (const name of Object.keys(env)) {
158
+ if (/^CODEROOK_(TOKEN|API_TOKEN|ACCESS_TOKEN)$/i.test(name))
159
+ delete env[name];
160
+ }
161
+ return env;
162
+ }