joycraft 0.7.12 → 0.7.14
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/README.md +30 -16
- package/dist/chunk-7BPB2IKY.js +255 -0
- package/dist/chunk-7BPB2IKY.js.map +1 -0
- package/dist/chunk-B73DPYYC.js +377 -0
- package/dist/chunk-B73DPYYC.js.map +1 -0
- package/dist/{chunk-DSVGHVYM.js → chunk-JYPBXPGD.js} +117 -90
- package/dist/chunk-JYPBXPGD.js.map +1 -0
- package/dist/{chunk-OAC5CVHJ.js → chunk-K4AI6FKB.js} +12 -2
- package/dist/chunk-K4AI6FKB.js.map +1 -0
- package/dist/{chunk-PBOICMDE.js → chunk-KKDKC4FM.js} +11 -73
- package/dist/chunk-KKDKC4FM.js.map +1 -0
- package/dist/chunk-OMFGDJW4.js +97 -0
- package/dist/chunk-OMFGDJW4.js.map +1 -0
- package/dist/chunk-PR4QDKPL.js +3755 -0
- package/dist/chunk-PR4QDKPL.js.map +1 -0
- package/dist/chunk-Z5JFEGWG.js +563 -0
- package/dist/chunk-Z5JFEGWG.js.map +1 -0
- package/dist/cli.js +389 -56
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +235 -1
- package/dist/index.js +691 -1
- package/dist/index.js.map +1 -1
- package/dist/init-S5JU5BHL.js +60 -0
- package/dist/init-S5JU5BHL.js.map +1 -0
- package/dist/{init-autofix-YCSDK5ZR.js → init-autofix-WSKUT2HN.js} +4 -3
- package/dist/{init-autofix-YCSDK5ZR.js.map → init-autofix-WSKUT2HN.js.map} +1 -1
- package/dist/install-manifest-EQHT4474.js +37 -0
- package/dist/joycraft-release.json +8 -0
- package/dist/release-artifact-4TL5L2ZY.js +14 -0
- package/dist/release-resolver-P2H46QTU.js +293 -0
- package/dist/release-resolver-P2H46QTU.js.map +1 -0
- package/dist/{telemetry-store-X7K5NYWD.js → telemetry-store-IBO5GRTA.js} +2 -2
- package/dist/telemetry-store-IBO5GRTA.js.map +1 -0
- package/dist/update-HNTXCEKB.js +19 -0
- package/dist/update-HNTXCEKB.js.map +1 -0
- package/dist/update-check-YT765NE7.js +36 -0
- package/dist/update-check-YT765NE7.js.map +1 -0
- package/dist/upgrade-LZOND7OZ.js +28 -0
- package/dist/upgrade-LZOND7OZ.js.map +1 -0
- package/package.json +5 -2
- package/dist/chunk-BZW5DR3O.js +0 -91
- package/dist/chunk-BZW5DR3O.js.map +0 -1
- package/dist/chunk-DSVGHVYM.js.map +0 -1
- package/dist/chunk-OAC5CVHJ.js.map +0 -1
- package/dist/chunk-PBOICMDE.js.map +0 -1
- package/dist/chunk-Q2ZQ6RGD.js +0 -243
- package/dist/chunk-Q2ZQ6RGD.js.map +0 -1
- package/dist/init-J5Q6RX3K.js +0 -1307
- package/dist/init-J5Q6RX3K.js.map +0 -1
- package/dist/upgrade-AHUSQZEQ.js +0 -643
- package/dist/upgrade-AHUSQZEQ.js.map +0 -1
- package/dist/version-B2CCAEMC.js +0 -28
- /package/dist/{telemetry-store-X7K5NYWD.js.map → install-manifest-EQHT4474.js.map} +0 -0
- /package/dist/{version-B2CCAEMC.js.map → release-artifact-4TL5L2ZY.js.map} +0 -0
package/README.md
CHANGED
|
@@ -8,23 +8,27 @@
|
|
|
8
8
|
|
|
9
9
|
## What is Joycraft?
|
|
10
10
|
|
|
11
|
-
A CLI that installs spec-driven development into [Claude Code](https://code.claude.com/docs), [OpenAI Codex](https://openai.com/codex), [Pi](https://github.com/earendil-works/pi-coding-agent),
|
|
11
|
+
A CLI that installs spec-driven development into [Claude Code](https://code.claude.com/docs), [OpenAI Codex](https://openai.com/codex), [Pi](https://github.com/earendil-works/pi-coding-agent), [GitHub Copilot](https://github.com/features/copilot), and [omp](https://github.com/can1357/oh-my-pi): skills, behavioral boundaries, templates, and a docs structure that matures with your project.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
cd /path/to/your/project
|
|
15
|
-
npx joycraft@latest
|
|
15
|
+
npx joycraft@latest update
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
Existing scripts may use the equivalent alias `npx joycraft@latest init` for a
|
|
19
|
+
fresh install.
|
|
20
|
+
|
|
18
21
|
Joycraft is a **curated harness, not a memory system**. Everything it writes is in-repo, reviewed in your PRs, and reaped when it stops earning its keep — the opposite of hidden state that accretes until it misleads. Code is the truth about how your project works; the harness holds only what code cannot say (intent, decisions and their rationale, product direction), and `/joycraft-optimize`'s Reaper pass is what keeps it honest. If your agent already keeps its own automatic memory, a Joycraft project supersedes it: the same facts get one home that your whole team can see and review.
|
|
19
22
|
|
|
20
23
|
## Contents
|
|
21
24
|
|
|
22
|
-
- [Install](#install) · [Use](#use) · [Upgrade](#upgrade)
|
|
25
|
+
- [Install](#install) · [Use](#use) · [Upgrade](#upgrade-and-update)
|
|
23
26
|
- [Setup walkthrough](docs/guides/setup-walkthrough.md) — every step from install to first feature
|
|
24
27
|
- [Which skill do I need?](#which-skill-do-i-need) — the skill table and the core loop
|
|
25
28
|
- [What init creates](#what-init-creates)
|
|
26
|
-
- [Platform support](docs/guides/platform-support.md) — Claude Code, Codex, Pi, Copilot, stacks, headless Pi
|
|
27
|
-
- [Upgrading](docs/guides/upgrading.md) —
|
|
29
|
+
- [Platform support](docs/guides/platform-support.md) — Claude Code, Codex, Pi, Copilot, omp, stacks, headless Pi
|
|
30
|
+
- [Upgrading](docs/guides/upgrading.md) — the unified install/update command and recovery paths
|
|
31
|
+
- [Releasing](docs/guides/releasing.md) — candidate verification, promotion, and retry recovery
|
|
28
32
|
- [Git tracking](docs/guides/git-tracking.md) — shared vs private profiles, reviewable PRs
|
|
29
33
|
- [Migration: flat → per-feature layout](docs/guides/migration-per-feature-layout.md) — the v0.6 docs move
|
|
30
34
|
- [The levels](docs/guides/levels.md) — Dan Shapiro's 5 Levels, where Joycraft aims, and the credits
|
|
@@ -35,10 +39,10 @@ Joycraft is a **curated harness, not a memory system**. Everything it writes is
|
|
|
35
39
|
|
|
36
40
|
```bash
|
|
37
41
|
cd /path/to/your/project
|
|
38
|
-
npx joycraft@latest
|
|
42
|
+
npx joycraft@latest update
|
|
39
43
|
```
|
|
40
44
|
|
|
41
|
-
Answer a few questions — which harnesses to install, whether to commit them, and (with Claude Code) whether to turn off auto-memory for this project — and `
|
|
45
|
+
Answer a few questions — which harnesses to install, whether to commit them, and (with Claude Code) whether to turn off auto-memory for this project — and `update` does the rest: detects your stack, writes `AGENTS.md`/`CLAUDE.md` with your real build/test commands, installs the skills. On later runs, unmodified vendor files refresh while customizations are preserved for review.
|
|
42
46
|
|
|
43
47
|
`npm install -g joycraft` if you'd rather have the command on your PATH; `npx` works without it. Every step from install to first shipped feature: [Setup walkthrough](docs/guides/setup-walkthrough.md).
|
|
44
48
|
|
|
@@ -56,26 +60,36 @@ Inside your AI tool, drive everything with slash commands:
|
|
|
56
60
|
|
|
57
61
|
Brainstorming first? `/joycraft-interview`. Fixing a bug? `/joycraft-bugfix`. The full table is at [Which skill do I need?](#which-skill-do-i-need); invocation syntax per tool is in [Platform support](docs/guides/platform-support.md).
|
|
58
62
|
|
|
59
|
-
## Upgrade
|
|
63
|
+
## Upgrade and update
|
|
60
64
|
|
|
61
65
|
```bash
|
|
62
|
-
npx joycraft@latest
|
|
66
|
+
npx joycraft@latest update
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
Run this from the project root. In a fresh interactive project it asks which harnesses to install. In CI or another unattended fresh project, provide an explicit selection, for example `--harnesses codex --non-interactive`. On an existing project it reads the shared or private installation manifest and preserves the selected harnesses, local content, unrelated configuration, and unknown state fields. `--yes` applies safe changes while preserving customized files; it is not blanket permission to overwrite them. Use `--preview` to review the actual plan, `--replace-customized <paths...>` for reviewed replacements, and `--repair <paths...>` for explicitly restoring missing managed files. Details, policies, bridge behavior, and exit codes are in [Upgrading](docs/guides/upgrading.md).
|
|
70
|
+
|
|
71
|
+
`init` and `upgrade` remain supported aliases into the same update engine. `init` is the friendly fresh-install entry point; `upgrade` keeps older automation working. If npm fails with `ETARGET` before Joycraft starts, retry with an online npm metadata refresh:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm --prefer-online exec --yes -- joycraft@latest update
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The launcher resolves one exact candidate. The executing bundle does not silently resolve `latest` again. After a successful update, reinvoke the active skill or restart the agent session so it loads the new instructions.
|
|
78
|
+
|
|
79
|
+
Update checks are local to each project. The default `notify` policy keeps a 24-hour cache, uses a short bounded request, and stays quiet when offline or unavailable. `auto-safe` is an explicit local opt-in and still requires the reviewed candidate descriptor and every safety gate; `off` disables notices. See [Upgrading](docs/guides/upgrading.md#update-checks-and-policies).
|
|
66
80
|
|
|
67
81
|
```bash
|
|
68
82
|
npx joycraft@latest telemetry
|
|
69
83
|
```
|
|
70
84
|
|
|
71
|
-
Scans your Claude Code, Pi, and (best-effort) Codex session transcripts and records which knowledge-layer docs your agents actually read. The result is a gitignored, machine-local file at `docs/.joycraft/telemetry.json` — paths and counters only, never transcript content. `/joycraft-session-end` runs this scan for you; `/joycraft-optimize` cites the counts when it judges which docs earn their place.
|
|
85
|
+
Scans your Claude Code, Pi, omp, and (best-effort) Codex session transcripts and records which knowledge-layer docs your agents actually read. The result is a gitignored, machine-local file at `docs/.joycraft/telemetry.json` — paths and counters only, never transcript content. `/joycraft-session-end` runs this scan for you; `/joycraft-optimize` cites the counts when it judges which docs earn their place.
|
|
72
86
|
|
|
73
87
|
## What init creates
|
|
74
88
|
|
|
75
89
|
- **AGENTS.md** — behavioral boundaries (Always / Ask First / Never) plus your stack's real build/test/lint commands; the single shared instruction file when more than one tool is selected
|
|
76
90
|
- **CLAUDE.md** — on a multi-tool install, [Anthropic's documented import pattern](https://code.claude.com/docs/en/memory): `@AGENTS.md` plus a `## Claude Code` section, so every tool reads one source. A Claude-only install gets the classic full CLAUDE.md
|
|
77
|
-
- **22 skills** — installed to `.claude/skills/` (Claude Code), `.agents/skills/` (Codex), `.pi/skills/` (Pi), and/or `.
|
|
78
|
-
- **docs/** — `docs/context/` (production map, dangerous assumptions, decision log, institutional knowledge, troubleshooting) plus templates; feature folders and `docs/backlog/` are created lazily by the skills that write to them. Joycraft
|
|
91
|
+
- **22 skills** — installed to `.claude/skills/` (Claude Code), `.agents/skills/` (Codex), `.pi/skills/` (Pi), `.github/skills/` (Copilot), and/or `.omp/skills/` (omp, invoked as `/skill:joycraft-*`); Pi also gets the headless pipeline runtime in `.pi/scripts/joycraft/`
|
|
92
|
+
- **docs/** — `docs/context/` (production map, dangerous assumptions, decision log, institutional knowledge, troubleshooting) plus templates; feature folders and `docs/backlog/` are created lazily by the skills that write to them. Joycraft records shared installation identity in `docs/.joycraft/manifest.json` and the shared checker in `docs/.joycraft/check.mjs`. Private manifests, personal preferences, and caches stay in the gitignored `docs/.joycraft/local/` directory. Read telemetry stays local too
|
|
79
93
|
- **Agent teams enabled** — with Claude Code selected, `init` sets `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` in `.claude/settings.json` so subagent-driven skills work out of the box (never clobbers a value you set)
|
|
80
94
|
|
|
81
95
|
Re-running on an existing project is covered in [Git tracking](docs/guides/git-tracking.md#re-running-init-on-an-existing-project).
|
|
@@ -137,7 +151,7 @@ flowchart LR
|
|
|
137
151
|
| [Tuning: risk interview and git autonomy](docs/guides/tuning.md) | The 2–3 minute risk interview that generates your safety boundaries |
|
|
138
152
|
| [Token discipline](docs/guides/token-discipline.md) | Why file artifacts at every step make your conversation context disposable |
|
|
139
153
|
| [Permission modes](docs/guides/permission-modes.md) | Why you do **not** need `--dangerously-skip-permissions` |
|
|
140
|
-
| [Agent compatibility](docs/guides/agent-compatibility.md) | How CLAUDE.md and AGENTS.md stay one source across
|
|
154
|
+
| [Agent compatibility](docs/guides/agent-compatibility.md) | How CLAUDE.md and AGENTS.md stay one source across every supported tool |
|
|
141
155
|
| [Level 5: the autonomous loop](docs/guides/level-5-autonomy.md) | Experimental — workflows, holdout scenarios, and what it really costs |
|
|
142
156
|
| [Methodology](docs/guides/methodology.md) | Why this exists: METR's slowdown finding and the teams that beat it |
|
|
143
157
|
|
|
@@ -158,9 +172,9 @@ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for the full g
|
|
|
158
172
|
The short version:
|
|
159
173
|
|
|
160
174
|
1. Fork, branch from `main`
|
|
161
|
-
2. `pnpm install && pnpm test
|
|
175
|
+
2. `pnpm install && pnpm test` to verify your setup
|
|
162
176
|
3. Write tests first, then implement
|
|
163
|
-
4. `pnpm test
|
|
177
|
+
4. `pnpm test && pnpm typecheck && pnpm build`
|
|
164
178
|
5. Open a PR (one approval required)
|
|
165
179
|
|
|
166
180
|
Look for [`good first issue`](https://github.com/maksutovic/joycraft/labels/good%20first%20issue) labels if you're new. Areas we'd especially love help with: stack detection for new languages, skill improvements, and documentation.
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/release-artifact.ts
|
|
4
|
+
import { createHash } from "crypto";
|
|
5
|
+
import { gunzipSync } from "zlib";
|
|
6
|
+
var MAX_COMPRESSED_BYTES = 32 * 1024 * 1024;
|
|
7
|
+
var MAX_ARCHIVE_BYTES = 64 * 1024 * 1024;
|
|
8
|
+
var MAX_ENTRY_BYTES = 8 * 1024 * 1024;
|
|
9
|
+
var MAX_ENTRIES = 1e4;
|
|
10
|
+
var EXACT_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
11
|
+
var PACKAGE_NAME = /^(?:@[a-z0-9._~-]+\/)?[a-z0-9._~-]+$/i;
|
|
12
|
+
var SHA512_INTEGRITY = /^sha512-([A-Za-z0-9+/]+={0,2})$/;
|
|
13
|
+
var verifiedArtifacts = /* @__PURE__ */ new WeakSet();
|
|
14
|
+
function objectRecord(value, label) {
|
|
15
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object.`);
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function parseJson(data, label) {
|
|
19
|
+
if (typeof data === "string") {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(data);
|
|
22
|
+
} catch {
|
|
23
|
+
throw new Error(`${label} is not valid JSON.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (data instanceof Uint8Array) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(Buffer.from(data).toString("utf8"));
|
|
29
|
+
} catch {
|
|
30
|
+
throw new Error(`${label} is not valid JSON.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function assertExactVersion(version, label = "Release version") {
|
|
36
|
+
if (typeof version !== "string" || !EXACT_VERSION.test(version)) throw new Error(`${label} must be an exact semver.`);
|
|
37
|
+
}
|
|
38
|
+
function assertIntegrity(integrity) {
|
|
39
|
+
if (typeof integrity !== "string") throw new Error("Release integrity must be a canonical sha512 SRI value.");
|
|
40
|
+
const match = SHA512_INTEGRITY.exec(integrity);
|
|
41
|
+
if (!match || Buffer.from(match[1], "base64").length !== 64 || Buffer.from(match[1], "base64").toString("base64") !== match[1]) {
|
|
42
|
+
throw new Error("Release integrity must be a canonical sha512 SRI value.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function cloneRelease(release) {
|
|
46
|
+
objectRecord(release, "Release");
|
|
47
|
+
if (typeof release.packageName !== "string" || !PACKAGE_NAME.test(release.packageName)) throw new Error("Release package name is invalid.");
|
|
48
|
+
assertExactVersion(release.version);
|
|
49
|
+
assertIntegrity(release.integrity);
|
|
50
|
+
if (typeof release.tarballUrl !== "string") throw new Error("Release tarball URL is invalid.");
|
|
51
|
+
let parsed;
|
|
52
|
+
try {
|
|
53
|
+
parsed = new URL(release.tarballUrl);
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error("Release tarball URL is invalid.");
|
|
56
|
+
}
|
|
57
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:" || parsed.username || parsed.password) throw new Error("Release tarball URL is invalid.");
|
|
58
|
+
return Object.freeze({
|
|
59
|
+
packageName: release.packageName,
|
|
60
|
+
version: release.version,
|
|
61
|
+
integrity: release.integrity,
|
|
62
|
+
tarballUrl: release.tarballUrl
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function parseReleaseDescriptor(data, exactVersion) {
|
|
66
|
+
assertExactVersion(exactVersion, "Exact version");
|
|
67
|
+
const value = objectRecord(parseJson(data, "Release descriptor"), "Release descriptor");
|
|
68
|
+
if (value.schemaVersion !== 1) throw new Error("Release descriptor schema is unsupported.");
|
|
69
|
+
if (value.releaseVersion !== exactVersion) throw new Error("Release descriptor version does not match the exact release.");
|
|
70
|
+
const manifestSchemas = value.manifestSchemas;
|
|
71
|
+
if (!Array.isArray(manifestSchemas) || manifestSchemas.length < 1 || !manifestSchemas.every((schema) => Number.isSafeInteger(schema) && schema >= 1) || new Set(manifestSchemas).size !== manifestSchemas.length || !manifestSchemas.includes(1)) {
|
|
72
|
+
throw new Error("Release descriptor manifestSchemas must include supported schema 1.");
|
|
73
|
+
}
|
|
74
|
+
if (typeof value.autoSafeEligible !== "boolean") throw new Error("Release descriptor autoSafeEligible must be boolean.");
|
|
75
|
+
const schemas = Object.freeze([...manifestSchemas]);
|
|
76
|
+
return Object.freeze({ schemaVersion: 1, releaseVersion: exactVersion, manifestSchemas: schemas, autoSafeEligible: value.autoSafeEligible });
|
|
77
|
+
}
|
|
78
|
+
function textField(header, start, length) {
|
|
79
|
+
const raw = header.subarray(start, start + length);
|
|
80
|
+
const nul = raw.indexOf(0);
|
|
81
|
+
const end = nul < 0 ? raw.length : nul;
|
|
82
|
+
return raw.subarray(0, end).toString("utf8");
|
|
83
|
+
}
|
|
84
|
+
function octalField(header, start, length, label) {
|
|
85
|
+
const value = textField(header, start, length).trim();
|
|
86
|
+
if (value === "" || !/^[0-7]+$/.test(value)) throw new Error(`Archive ${label} is invalid.`);
|
|
87
|
+
const parsed = Number.parseInt(value, 8);
|
|
88
|
+
if (!Number.isSafeInteger(parsed)) throw new Error(`Archive ${label} is too large.`);
|
|
89
|
+
return parsed;
|
|
90
|
+
}
|
|
91
|
+
function validateArchivePath(name, directory) {
|
|
92
|
+
if (!name || name.includes("\\") || name.startsWith("/") || name.includes("\0")) throw new Error(`Archive path '${name}' is unsafe.`);
|
|
93
|
+
const normalized = directory && name.endsWith("/") ? name.slice(0, -1) : name;
|
|
94
|
+
const parts = normalized.split("/");
|
|
95
|
+
if (parts.some((part) => part === "" || part === "." || part === "..")) throw new Error(`Archive path '${name}' is unsafe.`);
|
|
96
|
+
return normalized;
|
|
97
|
+
}
|
|
98
|
+
function parseTarEntries(gzipBytes) {
|
|
99
|
+
if (gzipBytes.byteLength > MAX_COMPRESSED_BYTES) throw new Error("Release artifact is too large.");
|
|
100
|
+
let archive;
|
|
101
|
+
try {
|
|
102
|
+
archive = gunzipSync(Buffer.from(gzipBytes), { maxOutputLength: MAX_ARCHIVE_BYTES });
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw new Error(`Release artifact gzip is invalid or too large: ${error instanceof Error ? error.message : String(error)}`);
|
|
105
|
+
}
|
|
106
|
+
if (archive.length > MAX_ARCHIVE_BYTES) throw new Error("Release artifact archive is too large.");
|
|
107
|
+
const entries = /* @__PURE__ */ new Map();
|
|
108
|
+
let offset = 0;
|
|
109
|
+
let sawEnd = false;
|
|
110
|
+
let count = 0;
|
|
111
|
+
while (offset + 512 <= archive.length) {
|
|
112
|
+
const header = archive.subarray(offset, offset + 512);
|
|
113
|
+
if (header.every((byte) => byte === 0)) {
|
|
114
|
+
if (offset + 1024 > archive.length || !archive.subarray(offset).every((byte) => byte === 0)) throw new Error("Archive has an incomplete end marker or trailing data.");
|
|
115
|
+
sawEnd = true;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
count += 1;
|
|
119
|
+
if (count > MAX_ENTRIES) throw new Error("Release artifact has too many archive entries.");
|
|
120
|
+
const providedChecksum = octalField(header, 148, 8, "checksum");
|
|
121
|
+
let calculatedChecksum = 0;
|
|
122
|
+
for (let index = 0; index < 512; index += 1) calculatedChecksum += index >= 148 && index < 156 ? 32 : header[index];
|
|
123
|
+
if (providedChecksum !== calculatedChecksum) throw new Error("Archive header checksum is invalid.");
|
|
124
|
+
const name = textField(header, 0, 100);
|
|
125
|
+
const prefix = textField(header, 345, 155);
|
|
126
|
+
const fullName = prefix ? `${prefix}/${name}` : name;
|
|
127
|
+
const type = header[156] === 0 ? "0" : String.fromCharCode(header[156]);
|
|
128
|
+
const mode = octalField(header, 100, 8, "mode");
|
|
129
|
+
if ((mode & 61440) === 40960) throw new Error(`Archive contains symlink metadata for '${fullName}'.`);
|
|
130
|
+
if (type !== "0" && type !== "5") throw new Error(`Archive contains unsupported or unsafe entry '${fullName}'.`);
|
|
131
|
+
const normalizedName = validateArchivePath(fullName, type === "5");
|
|
132
|
+
if (entries.has(normalizedName)) throw new Error(`Archive contains duplicate entry '${normalizedName}'.`);
|
|
133
|
+
const size = octalField(header, 124, 12, "entry size");
|
|
134
|
+
if (type === "5" && size !== 0) throw new Error(`Archive directory '${fullName}' has invalid content.`);
|
|
135
|
+
if (size > MAX_ENTRY_BYTES) throw new Error(`Archive entry '${fullName}' is too large.`);
|
|
136
|
+
const dataStart = offset + 512;
|
|
137
|
+
const dataEnd = dataStart + size;
|
|
138
|
+
const next = dataStart + Math.ceil(size / 512) * 512;
|
|
139
|
+
if (dataEnd > archive.length || next > archive.length) throw new Error(`Archive entry '${fullName}' is truncated.`);
|
|
140
|
+
entries.set(normalizedName, Buffer.from(archive.subarray(dataStart, dataEnd)));
|
|
141
|
+
offset = next;
|
|
142
|
+
}
|
|
143
|
+
if (!sawEnd) throw new Error("Archive is missing its end marker.");
|
|
144
|
+
return entries;
|
|
145
|
+
}
|
|
146
|
+
function extractPackageMetadata(bytes, release) {
|
|
147
|
+
const entries = parseTarEntries(bytes);
|
|
148
|
+
const packageBytes = entries.get("package/package.json");
|
|
149
|
+
if (!packageBytes) throw new Error("Release artifact is missing package/package.json.");
|
|
150
|
+
const descriptorBytes = entries.get("package/dist/joycraft-release.json");
|
|
151
|
+
if (!descriptorBytes) throw new Error("Release artifact is missing package/dist/joycraft-release.json.");
|
|
152
|
+
const packageJson = objectRecord(parseJson(packageBytes, "Package metadata"), "Package metadata");
|
|
153
|
+
if (packageJson.name !== release.packageName || packageJson.version !== release.version) throw new Error("Package metadata name/version does not match the exact release.");
|
|
154
|
+
const descriptor = parseReleaseDescriptor(descriptorBytes, release.version);
|
|
155
|
+
if (descriptor.releaseVersion !== packageJson.version) throw new Error("Release descriptor version does not match package metadata.");
|
|
156
|
+
return { packageJson: Object.freeze({ ...packageJson }), descriptor };
|
|
157
|
+
}
|
|
158
|
+
var VerifiedReleaseArtifactImpl = class {
|
|
159
|
+
release;
|
|
160
|
+
descriptor;
|
|
161
|
+
#bytes;
|
|
162
|
+
constructor(release, descriptor, bytes) {
|
|
163
|
+
this.release = release;
|
|
164
|
+
this.descriptor = descriptor;
|
|
165
|
+
this.#bytes = Buffer.from(bytes);
|
|
166
|
+
verifiedArtifacts.add(this);
|
|
167
|
+
Object.freeze(this);
|
|
168
|
+
}
|
|
169
|
+
get tarball() {
|
|
170
|
+
return new Uint8Array(this.#bytes);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
function verifyReleaseArtifact(release, tarball) {
|
|
174
|
+
const exactRelease = cloneRelease(release);
|
|
175
|
+
if (!(tarball instanceof Uint8Array) || tarball.byteLength === 0) throw new Error("Release artifact bytes are required.");
|
|
176
|
+
const actual = createHash("sha512").update(Buffer.from(tarball)).digest("base64");
|
|
177
|
+
if (`sha512-${actual}` !== exactRelease.integrity) throw new Error("Release artifact integrity does not match exact registry metadata.");
|
|
178
|
+
const { descriptor } = extractPackageMetadata(tarball, exactRelease);
|
|
179
|
+
return new VerifiedReleaseArtifactImpl(exactRelease, descriptor, tarball);
|
|
180
|
+
}
|
|
181
|
+
function isVerifiedReleaseArtifact(value) {
|
|
182
|
+
return typeof value === "object" && value !== null && verifiedArtifacts.has(value);
|
|
183
|
+
}
|
|
184
|
+
async function responseBytes(value, maxBytes) {
|
|
185
|
+
if (value instanceof Uint8Array) {
|
|
186
|
+
if (value.byteLength > maxBytes) throw new Error("Release tarball exceeds the download limit.");
|
|
187
|
+
return Buffer.from(value);
|
|
188
|
+
}
|
|
189
|
+
if (value instanceof ArrayBuffer) {
|
|
190
|
+
if (value.byteLength > maxBytes) throw new Error("Release tarball exceeds the download limit.");
|
|
191
|
+
return new Uint8Array(value);
|
|
192
|
+
}
|
|
193
|
+
const response = value;
|
|
194
|
+
if (response?.ok === false) throw new Error(`Release tarball request failed with HTTP ${String(response.status ?? "unknown")}.`);
|
|
195
|
+
if (response?.body?.getReader) {
|
|
196
|
+
const reader = response.body.getReader();
|
|
197
|
+
const chunks = [];
|
|
198
|
+
let total = 0;
|
|
199
|
+
try {
|
|
200
|
+
while (true) {
|
|
201
|
+
const result = await reader.read();
|
|
202
|
+
if (result.done) break;
|
|
203
|
+
const chunk = result.value;
|
|
204
|
+
total += chunk.byteLength;
|
|
205
|
+
if (total > maxBytes) throw new Error("Release tarball exceeds the download limit.");
|
|
206
|
+
chunks.push(chunk);
|
|
207
|
+
}
|
|
208
|
+
} finally {
|
|
209
|
+
reader.releaseLock();
|
|
210
|
+
}
|
|
211
|
+
return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)));
|
|
212
|
+
}
|
|
213
|
+
if (typeof response?.arrayBuffer === "function") {
|
|
214
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
215
|
+
if (bytes.byteLength > maxBytes) throw new Error("Release tarball exceeds the download limit.");
|
|
216
|
+
return bytes;
|
|
217
|
+
}
|
|
218
|
+
throw new Error("Release tarball response did not contain bytes.");
|
|
219
|
+
}
|
|
220
|
+
async function fetchVerifiedReleaseArtifact(release, options = {}) {
|
|
221
|
+
const maxBytes = options.maxBytes ?? MAX_COMPRESSED_BYTES;
|
|
222
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || maxBytes > MAX_COMPRESSED_BYTES) throw new Error("Artifact download limit is invalid.");
|
|
223
|
+
const timeoutMs = options.timeoutMs ?? 3e3;
|
|
224
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new Error("Artifact download timeout is invalid.");
|
|
225
|
+
const exactRelease = cloneRelease(release);
|
|
226
|
+
const fetchTarball = options.fetchTarball ?? (async (url, init) => fetch(url, init));
|
|
227
|
+
const controller = new AbortController();
|
|
228
|
+
let timer;
|
|
229
|
+
const deadline = new Promise((_, reject) => {
|
|
230
|
+
timer = setTimeout(() => {
|
|
231
|
+
controller.abort();
|
|
232
|
+
reject(new Error("Release tarball download timed out."));
|
|
233
|
+
}, timeoutMs);
|
|
234
|
+
});
|
|
235
|
+
const operation = (async () => {
|
|
236
|
+
const response = await fetchTarball(exactRelease.tarballUrl, { signal: controller.signal });
|
|
237
|
+
return responseBytes(response, maxBytes);
|
|
238
|
+
})();
|
|
239
|
+
void operation.catch(() => void 0);
|
|
240
|
+
try {
|
|
241
|
+
const bytes = await Promise.race([operation, deadline]);
|
|
242
|
+
return verifyReleaseArtifact(exactRelease, bytes);
|
|
243
|
+
} finally {
|
|
244
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
245
|
+
controller.abort();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export {
|
|
250
|
+
parseReleaseDescriptor,
|
|
251
|
+
verifyReleaseArtifact,
|
|
252
|
+
isVerifiedReleaseArtifact,
|
|
253
|
+
fetchVerifiedReleaseArtifact
|
|
254
|
+
};
|
|
255
|
+
//# sourceMappingURL=chunk-7BPB2IKY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/release-artifact.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { gunzipSync } from 'node:zlib';\n\nimport type { ExactRelease } from './release-resolver.js';\n\n/** The descriptor shipped inside a Joycraft package. */\nexport interface ReleaseDescriptor {\n readonly schemaVersion: 1;\n readonly releaseVersion: string;\n readonly manifestSchemas: readonly number[];\n readonly autoSafeEligible: boolean;\n}\n\n/** Opaque proof that a release's exact tarball and descriptor were verified. */\nexport interface VerifiedReleaseArtifact {\n readonly release: ExactRelease;\n readonly descriptor: ReleaseDescriptor;\n /** A fresh byte snapshot is returned on each access. */\n readonly tarball: Readonly<Uint8Array>;\n}\n\nexport type ReleaseTarballFetcher = (url: string, init?: RequestInit) => Promise<unknown>;\n\nexport interface FetchVerifiedReleaseArtifactOptions {\n fetchTarball?: ReleaseTarballFetcher;\n timeoutMs?: number;\n maxBytes?: number;\n}\n\nconst MAX_COMPRESSED_BYTES = 32 * 1024 * 1024;\nconst MAX_ARCHIVE_BYTES = 64 * 1024 * 1024;\nconst MAX_ENTRY_BYTES = 8 * 1024 * 1024;\nconst MAX_ENTRIES = 10_000;\nconst EXACT_VERSION = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/;\nconst PACKAGE_NAME = /^(?:@[a-z0-9._~-]+\\/)?[a-z0-9._~-]+$/i;\nconst SHA512_INTEGRITY = /^sha512-([A-Za-z0-9+/]+={0,2})$/;\n\nconst verifiedArtifacts = new WeakSet<object>();\n\nfunction objectRecord(value: unknown, label: string): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error(`${label} must be an object.`);\n return value as Record<string, unknown>;\n}\n\nfunction parseJson(data: unknown, label: string): unknown {\n if (typeof data === 'string') {\n try { return JSON.parse(data); } catch { throw new Error(`${label} is not valid JSON.`); }\n }\n if (data instanceof Uint8Array) {\n try { return JSON.parse(Buffer.from(data).toString('utf8')); } catch { throw new Error(`${label} is not valid JSON.`); }\n }\n return data;\n}\n\nfunction assertExactVersion(version: unknown, label = 'Release version'): asserts version is string {\n if (typeof version !== 'string' || !EXACT_VERSION.test(version)) throw new Error(`${label} must be an exact semver.`);\n}\n\nfunction assertIntegrity(integrity: unknown): asserts integrity is string {\n if (typeof integrity !== 'string') throw new Error('Release integrity must be a canonical sha512 SRI value.');\n const match = SHA512_INTEGRITY.exec(integrity);\n if (!match || Buffer.from(match[1], 'base64').length !== 64 || Buffer.from(match[1], 'base64').toString('base64') !== match[1]) {\n throw new Error('Release integrity must be a canonical sha512 SRI value.');\n }\n}\n\nfunction cloneRelease(release: ExactRelease): ExactRelease {\n objectRecord(release, 'Release');\n if (typeof release.packageName !== 'string' || !PACKAGE_NAME.test(release.packageName)) throw new Error('Release package name is invalid.');\n assertExactVersion(release.version);\n assertIntegrity(release.integrity);\n if (typeof release.tarballUrl !== 'string') throw new Error('Release tarball URL is invalid.');\n let parsed: URL;\n try { parsed = new URL(release.tarballUrl); } catch { throw new Error('Release tarball URL is invalid.'); }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:' || parsed.username || parsed.password) throw new Error('Release tarball URL is invalid.');\n return Object.freeze({\n packageName: release.packageName,\n version: release.version,\n integrity: release.integrity,\n tarballUrl: release.tarballUrl,\n });\n}\n\n/** Parse and validate the reviewed descriptor for one exact package version. */\nexport function parseReleaseDescriptor(data: unknown, exactVersion: string): ReleaseDescriptor {\n assertExactVersion(exactVersion, 'Exact version');\n const value = objectRecord(parseJson(data, 'Release descriptor'), 'Release descriptor');\n if (value.schemaVersion !== 1) throw new Error('Release descriptor schema is unsupported.');\n if (value.releaseVersion !== exactVersion) throw new Error('Release descriptor version does not match the exact release.');\n const manifestSchemas = value.manifestSchemas;\n if (!Array.isArray(manifestSchemas) || manifestSchemas.length < 1 || !manifestSchemas.every((schema) => Number.isSafeInteger(schema) && schema >= 1) || new Set(manifestSchemas).size !== manifestSchemas.length || !manifestSchemas.includes(1)) {\n throw new Error('Release descriptor manifestSchemas must include supported schema 1.');\n }\n if (typeof value.autoSafeEligible !== 'boolean') throw new Error('Release descriptor autoSafeEligible must be boolean.');\n const schemas = Object.freeze([...manifestSchemas] as number[]);\n return Object.freeze({ schemaVersion: 1 as const, releaseVersion: exactVersion, manifestSchemas: schemas, autoSafeEligible: value.autoSafeEligible });\n}\n\nfunction textField(header: Buffer, start: number, length: number): string {\n const raw = header.subarray(start, start + length);\n const nul = raw.indexOf(0);\n const end = nul < 0 ? raw.length : nul;\n return raw.subarray(0, end).toString('utf8');\n}\n\nfunction octalField(header: Buffer, start: number, length: number, label: string): number {\n const value = textField(header, start, length).trim();\n if (value === '' || !/^[0-7]+$/.test(value)) throw new Error(`Archive ${label} is invalid.`);\n const parsed = Number.parseInt(value, 8);\n if (!Number.isSafeInteger(parsed)) throw new Error(`Archive ${label} is too large.`);\n return parsed;\n}\n\nfunction validateArchivePath(name: string, directory: boolean): string {\n if (!name || name.includes('\\\\') || name.startsWith('/') || name.includes('\\0')) throw new Error(`Archive path '${name}' is unsafe.`);\n const normalized = directory && name.endsWith('/') ? name.slice(0, -1) : name;\n const parts = normalized.split('/');\n if (parts.some((part) => part === '' || part === '.' || part === '..')) throw new Error(`Archive path '${name}' is unsafe.`);\n return normalized;\n}\n\nfunction parseTarEntries(gzipBytes: Uint8Array): Map<string, Buffer> {\n if (gzipBytes.byteLength > MAX_COMPRESSED_BYTES) throw new Error('Release artifact is too large.');\n let archive: Buffer;\n try { archive = gunzipSync(Buffer.from(gzipBytes), { maxOutputLength: MAX_ARCHIVE_BYTES }); } catch (error) {\n throw new Error(`Release artifact gzip is invalid or too large: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (archive.length > MAX_ARCHIVE_BYTES) throw new Error('Release artifact archive is too large.');\n const entries = new Map<string, Buffer>();\n let offset = 0;\n let sawEnd = false;\n let count = 0;\n while (offset + 512 <= archive.length) {\n const header = archive.subarray(offset, offset + 512);\n if (header.every((byte) => byte === 0)) {\n if (offset + 1024 > archive.length || !archive.subarray(offset).every((byte) => byte === 0)) throw new Error('Archive has an incomplete end marker or trailing data.');\n sawEnd = true;\n break;\n }\n count += 1;\n if (count > MAX_ENTRIES) throw new Error('Release artifact has too many archive entries.');\n const providedChecksum = octalField(header, 148, 8, 'checksum');\n let calculatedChecksum = 0;\n for (let index = 0; index < 512; index += 1) calculatedChecksum += index >= 148 && index < 156 ? 0x20 : header[index];\n if (providedChecksum !== calculatedChecksum) throw new Error('Archive header checksum is invalid.');\n const name = textField(header, 0, 100);\n const prefix = textField(header, 345, 155);\n const fullName = prefix ? `${prefix}/${name}` : name;\n const type = header[156] === 0 ? '0' : String.fromCharCode(header[156]);\n const mode = octalField(header, 100, 8, 'mode');\n if ((mode & 0o170000) === 0o120000) throw new Error(`Archive contains symlink metadata for '${fullName}'.`);\n if (type !== '0' && type !== '5') throw new Error(`Archive contains unsupported or unsafe entry '${fullName}'.`);\n const normalizedName = validateArchivePath(fullName, type === '5');\n if (entries.has(normalizedName)) throw new Error(`Archive contains duplicate entry '${normalizedName}'.`);\n const size = octalField(header, 124, 12, 'entry size');\n if (type === '5' && size !== 0) throw new Error(`Archive directory '${fullName}' has invalid content.`);\n if (size > MAX_ENTRY_BYTES) throw new Error(`Archive entry '${fullName}' is too large.`);\n const dataStart = offset + 512;\n const dataEnd = dataStart + size;\n const next = dataStart + Math.ceil(size / 512) * 512;\n if (dataEnd > archive.length || next > archive.length) throw new Error(`Archive entry '${fullName}' is truncated.`);\n entries.set(normalizedName, Buffer.from(archive.subarray(dataStart, dataEnd)));\n offset = next;\n }\n if (!sawEnd) throw new Error('Archive is missing its end marker.');\n return entries;\n}\n\nfunction extractPackageMetadata(bytes: Uint8Array, release: ExactRelease): { packageJson: Record<string, unknown>; descriptor: ReleaseDescriptor } {\n const entries = parseTarEntries(bytes);\n const packageBytes = entries.get('package/package.json');\n if (!packageBytes) throw new Error('Release artifact is missing package/package.json.');\n const descriptorBytes = entries.get('package/dist/joycraft-release.json');\n if (!descriptorBytes) throw new Error('Release artifact is missing package/dist/joycraft-release.json.');\n const packageJson = objectRecord(parseJson(packageBytes, 'Package metadata'), 'Package metadata');\n if (packageJson.name !== release.packageName || packageJson.version !== release.version) throw new Error('Package metadata name/version does not match the exact release.');\n const descriptor = parseReleaseDescriptor(descriptorBytes, release.version);\n if (descriptor.releaseVersion !== packageJson.version) throw new Error('Release descriptor version does not match package metadata.');\n return { packageJson: Object.freeze({ ...packageJson }), descriptor };\n}\n\nclass VerifiedReleaseArtifactImpl implements VerifiedReleaseArtifact {\n readonly release: ExactRelease;\n readonly descriptor: ReleaseDescriptor;\n #bytes: Buffer;\n\n constructor(release: ExactRelease, descriptor: ReleaseDescriptor, bytes: Uint8Array) {\n this.release = release;\n this.descriptor = descriptor;\n this.#bytes = Buffer.from(bytes);\n verifiedArtifacts.add(this);\n Object.freeze(this);\n }\n\n get tarball(): Readonly<Uint8Array> {\n return new Uint8Array(this.#bytes);\n }\n}\n\n/** Verify an exact artifact's outer digest, package identity, and descriptor. */\nexport function verifyReleaseArtifact(release: ExactRelease, tarball: Uint8Array): VerifiedReleaseArtifact {\n const exactRelease = cloneRelease(release);\n if (!(tarball instanceof Uint8Array) || tarball.byteLength === 0) throw new Error('Release artifact bytes are required.');\n const actual = createHash('sha512').update(Buffer.from(tarball)).digest('base64');\n if (`sha512-${actual}` !== exactRelease.integrity) throw new Error('Release artifact integrity does not match exact registry metadata.');\n const { descriptor } = extractPackageMetadata(tarball, exactRelease);\n return new VerifiedReleaseArtifactImpl(exactRelease, descriptor, tarball);\n}\n\n/** Check the verifier-issued proof without trusting a caller-supplied boolean. */\nexport function isVerifiedReleaseArtifact(value: unknown): value is VerifiedReleaseArtifact {\n return typeof value === 'object' && value !== null && verifiedArtifacts.has(value);\n}\n\nasync function responseBytes(value: unknown, maxBytes: number): Promise<Uint8Array> {\n if (value instanceof Uint8Array) {\n if (value.byteLength > maxBytes) throw new Error('Release tarball exceeds the download limit.');\n return Buffer.from(value);\n }\n if (value instanceof ArrayBuffer) {\n if (value.byteLength > maxBytes) throw new Error('Release tarball exceeds the download limit.');\n return new Uint8Array(value);\n }\n const response = value as { ok?: boolean; status?: number; arrayBuffer?: () => Promise<ArrayBuffer>; body?: ReadableStream<Uint8Array> };\n if (response?.ok === false) throw new Error(`Release tarball request failed with HTTP ${String(response.status ?? 'unknown')}.`);\n if (response?.body?.getReader) {\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n try {\n while (true) {\n const result = await reader.read();\n if (result.done) break;\n const chunk = result.value;\n total += chunk.byteLength;\n if (total > maxBytes) throw new Error('Release tarball exceeds the download limit.');\n chunks.push(chunk);\n }\n } finally { reader.releaseLock(); }\n return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)));\n }\n if (typeof response?.arrayBuffer === 'function') {\n const bytes = new Uint8Array(await response.arrayBuffer());\n if (bytes.byteLength > maxBytes) throw new Error('Release tarball exceeds the download limit.');\n return bytes;\n }\n throw new Error('Release tarball response did not contain bytes.');\n}\n\n/** Download one exact tarball and return it only after local artifact verification. */\nexport async function fetchVerifiedReleaseArtifact(\n release: ExactRelease,\n options: FetchVerifiedReleaseArtifactOptions = {},\n): Promise<VerifiedReleaseArtifact> {\n const maxBytes = options.maxBytes ?? MAX_COMPRESSED_BYTES;\n if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || maxBytes > MAX_COMPRESSED_BYTES) throw new Error('Artifact download limit is invalid.');\n const timeoutMs = options.timeoutMs ?? 3_000;\n if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new Error('Artifact download timeout is invalid.');\n const exactRelease = cloneRelease(release);\n const fetchTarball = options.fetchTarball ?? (async (url: string, init?: RequestInit) => fetch(url, init));\n const controller = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n controller.abort();\n reject(new Error('Release tarball download timed out.'));\n }, timeoutMs);\n });\n const operation = (async () => {\n const response = await fetchTarball(exactRelease.tarballUrl, { signal: controller.signal });\n return responseBytes(response, maxBytes);\n })();\n // A custom fetch seam may ignore AbortSignal, so the deadline also covers\n // response body consumption instead of relying on fetch cancellation alone.\n void operation.catch(() => undefined);\n try {\n const bytes = await Promise.race([operation, deadline]);\n return verifyReleaseArtifact(exactRelease, bytes);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n controller.abort();\n }\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AA4B3B,IAAM,uBAAuB,KAAK,OAAO;AACzC,IAAM,oBAAoB,KAAK,OAAO;AACtC,IAAM,kBAAkB,IAAI,OAAO;AACnC,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,eAAe;AACrB,IAAM,mBAAmB;AAEzB,IAAM,oBAAoB,oBAAI,QAAgB;AAE9C,SAAS,aAAa,OAAgB,OAAwC;AAC5E,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,OAAM,IAAI,MAAM,GAAG,KAAK,qBAAqB;AAC9G,SAAO;AACT;AAEA,SAAS,UAAU,MAAe,OAAwB;AACxD,MAAI,OAAO,SAAS,UAAU;AAC5B,QAAI;AAAE,aAAO,KAAK,MAAM,IAAI;AAAA,IAAG,QAAQ;AAAE,YAAM,IAAI,MAAM,GAAG,KAAK,qBAAqB;AAAA,IAAG;AAAA,EAC3F;AACA,MAAI,gBAAgB,YAAY;AAC9B,QAAI;AAAE,aAAO,KAAK,MAAM,OAAO,KAAK,IAAI,EAAE,SAAS,MAAM,CAAC;AAAA,IAAG,QAAQ;AAAE,YAAM,IAAI,MAAM,GAAG,KAAK,qBAAqB;AAAA,IAAG;AAAA,EACzH;AACA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