@mago-foundation/mago-ski 0.2.0 → 0.3.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/README.md +30 -3
- package/dist/hosts/github/run.d.ts +3 -1
- package/dist/hosts/github/run.js +29 -9
- package/dist/hosts/pi/index.js +48 -5
- package/dist/src/admin.d.ts +136 -1
- package/dist/src/admin.js +221 -84
- package/dist/src/cli.js +335 -10
- package/dist/src/fs-safe.d.ts +15 -2
- package/dist/src/fs-safe.js +32 -3
- package/dist/src/gate/adapters/claude-code-hook.d.ts +1 -0
- package/dist/src/gate/adapters/claude-code-hook.js +4 -0
- package/dist/src/gate/adapters/claude-code-settings.d.ts +13 -0
- package/dist/src/gate/adapters/claude-code-settings.js +49 -0
- package/dist/src/gate/adapters/claude-code.d.ts +33 -0
- package/dist/src/gate/adapters/claude-code.js +193 -0
- package/dist/src/gate/adapters/client.d.ts +13 -0
- package/dist/src/gate/adapters/client.js +57 -0
- package/dist/src/gate/adapters/codex-hook.d.ts +1 -0
- package/dist/src/gate/adapters/codex-hook.js +5 -0
- package/dist/src/gate/adapters/codex-requirements.d.ts +19 -0
- package/dist/src/gate/adapters/codex-requirements.js +56 -0
- package/dist/src/gate/adapters/codex.d.ts +16 -0
- package/dist/src/gate/adapters/codex.js +574 -0
- package/dist/src/gate/adapters/hook-main.d.ts +7 -0
- package/dist/src/gate/adapters/hook-main.js +35 -0
- package/dist/src/gate/adapters/host-pid.d.ts +1 -0
- package/dist/src/gate/adapters/host-pid.js +20 -0
- package/dist/src/gate/admission.d.ts +54 -0
- package/dist/src/gate/admission.js +490 -0
- package/dist/src/gate/contract.d.ts +51 -0
- package/dist/src/gate/contract.js +94 -0
- package/dist/src/gate/decision-log.d.ts +38 -0
- package/dist/src/gate/decision-log.js +251 -0
- package/dist/src/gate/generations.d.ts +67 -0
- package/dist/src/gate/generations.js +518 -0
- package/dist/src/gate/proc.d.ts +31 -0
- package/dist/src/gate/proc.js +79 -0
- package/dist/src/gate/refresh.d.ts +11 -0
- package/dist/src/gate/refresh.js +30 -0
- package/dist/src/gate/run-verifier.d.ts +23 -0
- package/dist/src/gate/run-verifier.js +89 -0
- package/dist/src/gate/service.d.ts +80 -0
- package/dist/src/gate/service.js +722 -0
- package/dist/src/gate/strict-json.d.ts +11 -0
- package/dist/src/gate/strict-json.js +190 -0
- package/dist/src/gate/trust-store.d.ts +36 -0
- package/dist/src/gate/trust-store.js +251 -0
- package/dist/src/gate/verifier-worker.d.ts +8 -0
- package/dist/src/gate/verifier-worker.js +66 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/keys.d.ts +4 -0
- package/dist/src/keys.js +23 -14
- package/dist/src/policy.d.ts +145 -0
- package/dist/src/policy.js +554 -35
- package/dist/src/recovery-admin.d.ts +173 -0
- package/dist/src/recovery-admin.js +400 -0
- package/dist/src/root-events.d.ts +107 -0
- package/dist/src/root-events.js +376 -0
- package/dist/src/timestamp.d.ts +61 -0
- package/dist/src/timestamp.js +107 -0
- package/dist/src/tree-digest.d.ts +1 -0
- package/dist/src/tree-digest.js +1 -1
- package/dist/src/verify.d.ts +33 -0
- package/dist/src/verify.js +4 -2
- package/docs/hosts/adapter-interface.md +8 -2
- package/docs/hosts/github-action.md +1 -1
- package/docs/hosts/pi.md +2 -0
- package/docs/spec/gui-admin-rack-v1.md +289 -0
- package/docs/spec/root-recovery-v1.md +33 -12
- package/docs/spec/trust-documents-v1.md +8 -2
- package/docs/spec/verification.md +9 -2
- package/docs/threat-model.md +4 -2
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ Host (Pi, CI) pins the root fingerprint and checks that a certificate chai
|
|
|
19
19
|
|
|
20
20
|
- **Approval binds an exact digest.** Every byte of every covered file is included, plus its executable bit on Linux and macOS; files excluded from the digest are not approved. A one-sentence change needs a new certificate, even if no capability changed.
|
|
21
21
|
- **Hosts trust the root, not individual keys.** Approvers are delegated by the root, limited to Skill-name scopes, and expire.
|
|
22
|
+
- **A leaked root key is recoverable.** With a v2 policy, a few offline recovery keys can revoke the root key (any one trustee, by default) and replace it (two of three, by default) with signed root events, without editing any host's policy. An optional timestamp key stops hosts from being kept on old files. See [root recovery](docs/spec/root-recovery-v1.md).
|
|
22
23
|
- **Revocation reaches every certificate at once.** Revoke a key and every certificate it signed stops verifying as soon as a host has the updated revocation list; revoke a digest to pull one version. Lists expire (30 days by default), which bounds how long a host can keep using an old one.
|
|
23
24
|
- **The model never holds a credential.** The host verifies; in Pi enforce mode, only Skills that passed are advertised to the model.
|
|
24
25
|
- **No maliciousness judgment.** A certificate records who approved what. It does not certify that a Skill is safe.
|
|
@@ -101,7 +102,33 @@ mago-ski 0.2 supports **Linux and macOS** (Node.js 22.23.4, 24.22.1 or 26.12.1 o
|
|
|
101
102
|
| **GitHub Actions** | In enforce mode, fails the check when a Skill found under the policy's `skill_dirs` lacks a valid certificate. Trust comes from the base revision, so a PR cannot approve itself | [docs/hosts/github-action.md](docs/hosts/github-action.md) |
|
|
102
103
|
| **CLI** | `verify`, `verify-all`, `diff`, `digest`, `inspect`, plus key, root, revoke and approve commands. Run `mago-ski --help` | |
|
|
103
104
|
| Other agents | Planned through the same hook points | [docs/hosts/adapter-interface.md](docs/hosts/adapter-interface.md) |
|
|
104
|
-
| **Desktop GUI** (PoC) | Watches installed Pi and Agent Skills, shows what changed since the version you remember, and shows each Skill's PKI verdict from the host policy.
|
|
105
|
+
| **Desktop GUI** (PoC) | Watches installed Pi and Agent Skills, shows what changed since the version you remember, and shows each Skill's PKI verdict from the host policy. Never writes host state. Its administration rack covers approving Skill versions, managing approvers, revoking, refreshing the revocation list and signing the timestamp, each confirmed in a native dialog, with the role proven by the key against an admin-owned organisation pin ([spec](docs/spec/gui-admin-rack-v1.md)). English and Korean | [gui/README.md](gui/README.md) |
|
|
106
|
+
|
|
107
|
+
## Desktop GUI
|
|
108
|
+
|
|
109
|
+
The desktop GUI (PoC) shows its texts in English or Korean. It follows the system language and has a language switch in the header. See [gui/README.md](gui/README.md).
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
The observation tab lists the installed Skills and shows what changed in the selected one since the version you remember.
|
|
114
|
+
|
|
115
|
+

|
|
116
|
+
|
|
117
|
+
The admin tab shows the organisation pin and the fixed templates an approver or administrator works through.
|
|
118
|
+
|
|
119
|
+

|
|
120
|
+
|
|
121
|
+
In the Approve template the approver's key is loaded (IDENTITY) and INSPECT shows the exact version of a Skill before anything is signed.
|
|
122
|
+
|
|
123
|
+

|
|
124
|
+
|
|
125
|
+

|
|
126
|
+
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+

|
|
130
|
+
|
|
131
|
+
In the Manage approvers template TRUST ROOT shows the trust root's approvers, expiry and lifetime controls, and POLICY CHECK shows every Skill's verdict under the host's own loader.
|
|
105
132
|
|
|
106
133
|
## Verdicts
|
|
107
134
|
|
|
@@ -114,9 +141,9 @@ Capability scanners such as SkilLock report what a Skill change does at pull-req
|
|
|
114
141
|
## Documentation
|
|
115
142
|
|
|
116
143
|
- [Threat model](docs/threat-model.md): what is and is not protected
|
|
117
|
-
- Specs: [tree digest](docs/spec/skill-tree-v2.md), [certificate](docs/spec/skill-certificate-v1.md), [trust documents and policy](docs/spec/trust-documents-v1.md), [verification order](docs/spec/verification.md)
|
|
144
|
+
- Specs: [tree digest](docs/spec/skill-tree-v2.md), [certificate](docs/spec/skill-certificate-v1.md), [trust documents and policy](docs/spec/trust-documents-v1.md), [verification order](docs/spec/verification.md), [root recovery](docs/spec/root-recovery-v1.md), [GUI administration rack](docs/spec/gui-admin-rack-v1.md) (draft)
|
|
118
145
|
- [Test vectors](tests/vectors/) for other implementations
|
|
119
|
-
- [Pi interception spike](docs/phase1/pi-interception.md)
|
|
146
|
+
- [Pi interception spike](docs/phase1/pi-interception.md), [Claude Code interception spike](docs/spikes/claude-code-interception.md)
|
|
120
147
|
- [Security policy](SECURITY.md): how to report a vulnerability
|
|
121
148
|
- [Changelog](CHANGELOG.md)
|
|
122
149
|
- [Contributing](CONTRIBUTING.md)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { type Policy } from '../../src/policy.ts';
|
|
2
|
+
import { type Policy, type TrustFailureEvent } from '../../src/policy.ts';
|
|
3
3
|
import { type VerificationResult } from '../../src/verify.ts';
|
|
4
4
|
export interface GitHubCheckOptions {
|
|
5
5
|
/** Checkout that supplies trust: the PR base revision, or the workspace for push events. */
|
|
@@ -18,6 +18,8 @@ export interface GitHubCheckResult {
|
|
|
18
18
|
mode: Policy['mode'];
|
|
19
19
|
/** Set when discovery exceeded its work budget; `results` then holds a single UNVERIFIABLE entry and no Skill was checked. */
|
|
20
20
|
budgetExceeded?: string;
|
|
21
|
+
/** Set when the trust documents failed (`root-revoked` or `trust-unavailable`); `results` then holds a single entry. */
|
|
22
|
+
trustFailure?: TrustFailureEvent;
|
|
21
23
|
results: VerificationResult[];
|
|
22
24
|
exitCode: number;
|
|
23
25
|
summary: string;
|
package/dist/hosts/github/run.js
CHANGED
|
@@ -6,7 +6,7 @@ import { appendFile, realpath } from 'node:fs/promises';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { isInside } from "../../src/fs-safe.js";
|
|
8
8
|
import { isMainModule } from "../../src/main-module.js";
|
|
9
|
-
import { DiscoveryBudgetError, findSkillDirs, loadPolicy, loadPolicyTrust, tooDeepResult, verifyWithPolicy } from "../../src/policy.js";
|
|
9
|
+
import { DiscoveryBudgetError, findSkillDirs, loadPolicy, loadPolicyTrust, tooDeepResult, trustFailureEvent, verifyWithPolicy, } from "../../src/policy.js";
|
|
10
10
|
import { unverifiable } from "../../src/verify.js";
|
|
11
11
|
/** The summary lists at most this many Skills (failures first); the rest are counted, not listed. */
|
|
12
12
|
export const MAX_SUMMARY_ROWS = 200;
|
|
@@ -53,6 +53,10 @@ export async function runGitHubCheck(options) {
|
|
|
53
53
|
const base = await loadPolicy(policyPath);
|
|
54
54
|
await withinReal(policyRoot, base.trustRootPath, 'trust_root');
|
|
55
55
|
await withinReal(policyRoot, base.revocationsPath, 'revocations');
|
|
56
|
+
if (base.recovery)
|
|
57
|
+
await withinReal(policyRoot, base.recovery.rootEventsPath, 'root_events');
|
|
58
|
+
if (base.recovery?.freshness)
|
|
59
|
+
await withinReal(policyRoot, base.recovery.freshness.timestampPath, 'freshness timestamp');
|
|
56
60
|
const certificateDirs = [];
|
|
57
61
|
for (const dir of base.certificateDirs)
|
|
58
62
|
certificateDirs.push(await toWorkspace(policyRoot, workspace, dir, 'certificate_dirs'));
|
|
@@ -69,6 +73,26 @@ export async function runGitHubCheck(options) {
|
|
|
69
73
|
};
|
|
70
74
|
if (policy.skillDirs.length === 0)
|
|
71
75
|
throw new Error('Policy has no skill_dirs; list the directories that hold Skills');
|
|
76
|
+
// Trust first: a pull request controls the Skill tree, so it must not be able to skip the trust check
|
|
77
|
+
// (and a revoked root, which fails the check in every mode) by making discovery fail.
|
|
78
|
+
const trust = await loadPolicyTrust(policy, now);
|
|
79
|
+
if (!trust.ok) {
|
|
80
|
+
// One summary line and no per-Skill rows. A revoked root fails the check in shadow mode too.
|
|
81
|
+
const event = trustFailureEvent(trust);
|
|
82
|
+
const fails = trust.rootRevoked || policy.mode === 'enforce';
|
|
83
|
+
return {
|
|
84
|
+
mode: policy.mode, trustFailure: event, results: [unverifiable(workspace, event, trust.reason, now, trust.verdict)],
|
|
85
|
+
exitCode: fails ? 1 : 0,
|
|
86
|
+
summary: [
|
|
87
|
+
`### mago-ski: ${trust.rootRevoked ? 'root key revoked, every Skill blocked' : 'trust documents unavailable'} (${policy.mode} mode)`,
|
|
88
|
+
'',
|
|
89
|
+
`${markdownCell(trust.reason)}. No Skills were checked.`,
|
|
90
|
+
'',
|
|
91
|
+
trust.rootRevoked ? '_A revoked root key blocks in shadow mode too, until a rotate root event._'
|
|
92
|
+
: policy.mode === 'shadow' ? '_Shadow mode: failures are reported but do not fail the check._' : '',
|
|
93
|
+
].join('\n'),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
72
96
|
let discovery;
|
|
73
97
|
try {
|
|
74
98
|
discovery = await findSkillDirs(policy.skillDirs);
|
|
@@ -91,13 +115,9 @@ export async function runGitHubCheck(options) {
|
|
|
91
115
|
};
|
|
92
116
|
}
|
|
93
117
|
const { skillDirs: found, tooDeep } = discovery;
|
|
94
|
-
const trust = await loadPolicyTrust(policy, now);
|
|
95
118
|
const results = [];
|
|
96
|
-
for (const skillDir of found)
|
|
97
|
-
results.push(trust.
|
|
98
|
-
? await verifyWithPolicy(policy, skillDir, { now, context: trust.context })
|
|
99
|
-
: unverifiable(skillDir, path.basename(skillDir), trust.reason, now, trust.verdict));
|
|
100
|
-
}
|
|
119
|
+
for (const skillDir of found)
|
|
120
|
+
results.push(await verifyWithPolicy(policy, skillDir, { now, context: trust.context }));
|
|
101
121
|
for (const directory of tooDeep)
|
|
102
122
|
results.push(tooDeepResult(directory, now));
|
|
103
123
|
const failures = results.filter((result) => result.verdict !== 'VERIFIED');
|
|
@@ -135,8 +155,8 @@ async function main() {
|
|
|
135
155
|
break;
|
|
136
156
|
}
|
|
137
157
|
annotations += 1;
|
|
138
|
-
const level = result.mode === 'enforce' ? 'error' : 'warning';
|
|
139
|
-
const location = result.budgetExceeded ? '' : `file=${escapeAnnotation(path.relative(path.resolve(workspace), path.join(entry.skillDir, 'SKILL.md')))},`;
|
|
158
|
+
const level = result.mode === 'enforce' || result.trustFailure === 'root-revoked' ? 'error' : 'warning';
|
|
159
|
+
const location = result.budgetExceeded || result.trustFailure ? '' : `file=${escapeAnnotation(path.relative(path.resolve(workspace), path.join(entry.skillDir, 'SKILL.md')))},`;
|
|
140
160
|
process.stdout.write(`::${level} ${location}title=mago-ski ${entry.verdict}::${escapeAnnotation(`${entry.skillName}: ${entry.reason}`)}\n`);
|
|
141
161
|
}
|
|
142
162
|
process.stdout.write(`${result.summary}\n`);
|
package/dist/hosts/pi/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { lstat, realpath } from 'node:fs/promises';
|
|
|
3
3
|
import { homedir, hostname } from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { isInside, readRegularFile } from "../../src/fs-safe.js";
|
|
6
|
-
import { appendDecision, loadPolicy, loadPolicyTrust, verifyWithPolicy } from "../../src/policy.js";
|
|
6
|
+
import { appendDecision, loadPolicy, loadPolicyTrust, trustFailureEvent, trustFailureRecord, verifyWithPolicy, } from "../../src/policy.js";
|
|
7
7
|
import { formatTimestamp } from "../../src/time.js";
|
|
8
8
|
import { CERTIFICATE_FILENAME, hashFile, sha256Hex } from "../../src/tree-digest.js";
|
|
9
9
|
import { validateSkillName } from "../../src/names.js";
|
|
@@ -96,9 +96,12 @@ export function createMagoSkiExtension(options = {}) {
|
|
|
96
96
|
const lastLogged = new Map();
|
|
97
97
|
/** Skill directories already reported for an unsafe path, so the notice and log line appear once. */
|
|
98
98
|
const reportedPaths = new Set();
|
|
99
|
+
/** The current failure of the trust documents, reported once per host while it lasts (null when trust loads). */
|
|
100
|
+
let trustFailure = null;
|
|
99
101
|
const mode = () => (policy ? policy.mode : 'enforce');
|
|
100
102
|
const active = () => policy !== null || policyError !== null;
|
|
101
|
-
|
|
103
|
+
// A revoked root key blocks in shadow mode too: it is a signed statement that the trust anchor is not sound.
|
|
104
|
+
const enforcing = () => mode() === 'enforce' || trustFailure?.rootRevoked === true;
|
|
102
105
|
/**
|
|
103
106
|
* The policy decides the mode, so it must come from the host, never from the project. An explicit
|
|
104
107
|
* path (option or $MAGO_SKI_POLICY) has to be absolute and must not resolve into the project,
|
|
@@ -169,12 +172,29 @@ export function createMagoSkiExtension(options = {}) {
|
|
|
169
172
|
async function trustContext() {
|
|
170
173
|
if (!policy)
|
|
171
174
|
return { ok: false, verdict: 'UNVERIFIABLE', reason: policyError ?? 'no policy' };
|
|
175
|
+
let result;
|
|
172
176
|
try {
|
|
173
|
-
|
|
177
|
+
result = await loadPolicyTrust(policy, now());
|
|
174
178
|
}
|
|
175
179
|
catch (error) {
|
|
176
|
-
|
|
180
|
+
result = { ok: false, verdict: 'UNVERIFIABLE', reason: error.message };
|
|
177
181
|
}
|
|
182
|
+
await noteTrust(result);
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
/** One decision record when a trust failure starts or changes; none per Skill while it lasts. */
|
|
186
|
+
async function noteTrust(result) {
|
|
187
|
+
if (result.ok) {
|
|
188
|
+
trustFailure = null;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const event = trustFailureEvent(result);
|
|
192
|
+
const key = `${event}|${result.reason}`;
|
|
193
|
+
if (trustFailure?.key === key)
|
|
194
|
+
return;
|
|
195
|
+
trustFailure = { key, event, reason: result.reason, rootRevoked: result.rootRevoked === true, noticed: false };
|
|
196
|
+
if (policy?.decisionLogPath)
|
|
197
|
+
await appendDecision(policy.decisionLogPath, trustFailureRecord(result, policy.mode, now())).catch(() => { });
|
|
178
198
|
}
|
|
179
199
|
/** Never throws: any failure becomes an UNVERIFIABLE entry for that Skill. */
|
|
180
200
|
async function verifyEntry(skill, context) {
|
|
@@ -212,6 +232,24 @@ export function createMagoSkiExtension(options = {}) {
|
|
|
212
232
|
for (const skill of skills)
|
|
213
233
|
fresh.push(await verifyEntry(skill, context));
|
|
214
234
|
entries = fresh;
|
|
235
|
+
if (trustFailure) {
|
|
236
|
+
// Reported once for the host: one notice when it starts or changes, and the status bar while it lasts.
|
|
237
|
+
for (const entry of fresh)
|
|
238
|
+
lastLogged.set(entry.lexDir, entry.result.verdict);
|
|
239
|
+
if (ctx.hasUI) {
|
|
240
|
+
if (!trustFailure.noticed) {
|
|
241
|
+
trustFailure.noticed = true;
|
|
242
|
+
const message = trustFailure.rootRevoked
|
|
243
|
+
? `mago-ski: ROOT KEY REVOKED - all Skills blocked, in shadow mode too. ${trustFailure.reason}`
|
|
244
|
+
: `mago-ski ${enforcing() ? 'blocked' : 'would block (shadow)'} all Skills: trust documents unavailable - ${trustFailure.reason}`;
|
|
245
|
+
ctx.ui.notify(message, trustFailure.rootRevoked || enforcing() ? 'error' : 'warning');
|
|
246
|
+
}
|
|
247
|
+
ctx.ui.setStatus('mago-ski', trustFailure.rootRevoked
|
|
248
|
+
? 'mago-ski: ROOT KEY REVOKED - all Skills blocked'
|
|
249
|
+
: `mago-ski ${mode()}: trust unavailable - 0/${fresh.length} Skills verified`);
|
|
250
|
+
}
|
|
251
|
+
return fresh;
|
|
252
|
+
}
|
|
215
253
|
for (const entry of fresh) {
|
|
216
254
|
if (lastLogged.get(entry.lexDir) === entry.result.verdict)
|
|
217
255
|
continue;
|
|
@@ -283,7 +321,9 @@ export function createMagoSkiExtension(options = {}) {
|
|
|
283
321
|
}
|
|
284
322
|
/** Logs the decision; returns a block in enforce mode, undefined in shadow mode. */
|
|
285
323
|
async function judge(entry, event, verdict, reason) {
|
|
286
|
-
|
|
324
|
+
// While the trust documents fail, the single host record stands for every Skill.
|
|
325
|
+
if (!trustFailure)
|
|
326
|
+
await log(recordFor(entry, event, verdict, reason), false);
|
|
287
327
|
return enforcing() ? { block: true, reason: `mago-ski: Skill "${entry.name}" ${verdict}: ${reason}` } : undefined;
|
|
288
328
|
}
|
|
289
329
|
async function checkShell(toolName, command) {
|
|
@@ -462,6 +502,9 @@ export function createMagoSkiExtension(options = {}) {
|
|
|
462
502
|
if (!known) {
|
|
463
503
|
// Not seen yet (first prompt of a session). Never let Pi expand it unchecked: turn it into a
|
|
464
504
|
// plain request; the model can only use the Skill if it is advertised, and reads are checked.
|
|
505
|
+
// Load trust first: a revoked root blocks in shadow mode too, even before the first agent run.
|
|
506
|
+
if (!enforcing())
|
|
507
|
+
await trustContext();
|
|
465
508
|
if (!enforcing())
|
|
466
509
|
return { action: 'continue' };
|
|
467
510
|
return { action: 'transform', text: `Use the "${name}" skill.${args ? ` ${args}` : ''}` };
|
package/dist/src/admin.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { KeyObject } from 'node:crypto';
|
|
2
|
+
import { type PrivateKeyInfo, type PublicKeyInfo } from './keys.ts';
|
|
3
|
+
import type { ForbiddenKey } from './policy.ts';
|
|
4
|
+
import { type Revocations } from './revocations.ts';
|
|
5
|
+
import { type TrustRoot } from './trust-root.ts';
|
|
1
6
|
export declare const DEFAULT_TRUST_ROOT_EXPIRY = "365d";
|
|
2
7
|
export declare const DEFAULT_REVOCATIONS_EXPIRY = "30d";
|
|
3
8
|
/** True if the bytes contain recognizable private-key material. */
|
|
@@ -14,6 +19,65 @@ export declare function initRoot(options: {
|
|
|
14
19
|
trustRoot: string;
|
|
15
20
|
revocations: string;
|
|
16
21
|
}>;
|
|
22
|
+
/** A document was older than the lowest version this computer's memory allows. The GUI maps it by class. */
|
|
23
|
+
export declare class StaleDocumentError extends Error {
|
|
24
|
+
constructor(label: string, version: number, minimum: number);
|
|
25
|
+
}
|
|
26
|
+
/** A document changed between prepare and commit. The GUI maps it, and `FileChangedError`, by class. */
|
|
27
|
+
export declare class DocumentChangedError extends Error {
|
|
28
|
+
constructor(label: string);
|
|
29
|
+
}
|
|
30
|
+
export type TrustRootChange = {
|
|
31
|
+
kind: 'add';
|
|
32
|
+
publicKey: PublicKeyInfo;
|
|
33
|
+
name: string;
|
|
34
|
+
scopes: string[];
|
|
35
|
+
expires: string;
|
|
36
|
+
trustRootExpires?: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'remove';
|
|
39
|
+
keyId: string;
|
|
40
|
+
trustRootExpires?: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'renew';
|
|
43
|
+
trustRootExpires: string;
|
|
44
|
+
};
|
|
45
|
+
export interface PreparedTrustRoot {
|
|
46
|
+
kind: 'trust-root';
|
|
47
|
+
/** The trust root read. */
|
|
48
|
+
source: string;
|
|
49
|
+
/** Where commit writes: `out` or the source. */
|
|
50
|
+
target: string;
|
|
51
|
+
/** `sha256:<hex>` of `source` as read. */
|
|
52
|
+
baseSha256: string;
|
|
53
|
+
/** When `target` differs from `source`: its `sha256:<hex>` at prepare, or null when absent. */
|
|
54
|
+
targetBase: string | null;
|
|
55
|
+
rootKeyId: string;
|
|
56
|
+
current: TrustRoot;
|
|
57
|
+
/** Exactly what commit signs. */
|
|
58
|
+
payload: TrustRoot;
|
|
59
|
+
change: TrustRootChange;
|
|
60
|
+
replaces: TrustRoot['approvers'][number] | null;
|
|
61
|
+
}
|
|
62
|
+
/** Reads the trust root once, applies the change and returns the unsigned result. Never signs or writes. */
|
|
63
|
+
export declare function prepareTrustRootChange(o: {
|
|
64
|
+
rootKeyId: string;
|
|
65
|
+
trustRootPath: string;
|
|
66
|
+
out?: string | undefined;
|
|
67
|
+
now: Date;
|
|
68
|
+
change: TrustRootChange;
|
|
69
|
+
forbidden?: ForbiddenKey[] | undefined;
|
|
70
|
+
minimumVersion?: number | undefined;
|
|
71
|
+
}): Promise<PreparedTrustRoot>;
|
|
72
|
+
/** Pure: signs `p.payload` and nothing else. The preview and commit use this one code path. */
|
|
73
|
+
export declare function signPreparedTrustRoot(p: PreparedTrustRoot, key: PrivateKeyInfo): Buffer;
|
|
74
|
+
export declare function commitTrustRoot(p: PreparedTrustRoot, rootKey: PrivateKeyInfo, o?: {
|
|
75
|
+
beforeWrite?: () => void | Promise<void>;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
version: number;
|
|
78
|
+
path: string;
|
|
79
|
+
sha256: string;
|
|
80
|
+
}>;
|
|
17
81
|
export declare function addApprover(options: {
|
|
18
82
|
rootKeyPath: string;
|
|
19
83
|
trustRootPath: string;
|
|
@@ -24,6 +88,8 @@ export declare function addApprover(options: {
|
|
|
24
88
|
name: string;
|
|
25
89
|
scopes: string[];
|
|
26
90
|
expires: string;
|
|
91
|
+
/** Keys that must not be approvers (see `forbiddenApproverKeys`); the CLI passes them with `--policy`. */
|
|
92
|
+
forbidden?: ForbiddenKey[];
|
|
27
93
|
}): Promise<{
|
|
28
94
|
version: number;
|
|
29
95
|
path: string;
|
|
@@ -40,6 +106,64 @@ export declare function removeApprover(options: {
|
|
|
40
106
|
version: number;
|
|
41
107
|
path: string;
|
|
42
108
|
}>;
|
|
109
|
+
/** Re-signs the trust root with a new expiry and the same approvers. */
|
|
110
|
+
export declare function renewTrustRoot(options: {
|
|
111
|
+
rootKeyPath: string;
|
|
112
|
+
trustRootPath: string;
|
|
113
|
+
out?: string;
|
|
114
|
+
now: Date;
|
|
115
|
+
expires: string;
|
|
116
|
+
}): Promise<{
|
|
117
|
+
version: number;
|
|
118
|
+
path: string;
|
|
119
|
+
expiresAt: Date;
|
|
120
|
+
}>;
|
|
121
|
+
export type RevocationChange = {
|
|
122
|
+
kind: 'key';
|
|
123
|
+
keyId: string;
|
|
124
|
+
reason: string;
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'digest';
|
|
127
|
+
digest: string;
|
|
128
|
+
reason: string;
|
|
129
|
+
} | {
|
|
130
|
+
kind: 'both';
|
|
131
|
+
keyId: string;
|
|
132
|
+
digest: string;
|
|
133
|
+
reason: string;
|
|
134
|
+
} | {
|
|
135
|
+
kind: 'refresh';
|
|
136
|
+
};
|
|
137
|
+
export interface PreparedRevocations {
|
|
138
|
+
kind: 'revocations';
|
|
139
|
+
source: string;
|
|
140
|
+
target: string;
|
|
141
|
+
baseSha256: string;
|
|
142
|
+
targetBase: string | null;
|
|
143
|
+
rootKeyId: string;
|
|
144
|
+
current: Revocations;
|
|
145
|
+
payload: Revocations;
|
|
146
|
+
change: RevocationChange;
|
|
147
|
+
}
|
|
148
|
+
export declare function prepareRevocationsChange(o: {
|
|
149
|
+
rootKeyId: string;
|
|
150
|
+
rootPublicKey: KeyObject;
|
|
151
|
+
revocationsPath: string;
|
|
152
|
+
out?: string | undefined;
|
|
153
|
+
now: Date;
|
|
154
|
+
expires: string;
|
|
155
|
+
change: RevocationChange;
|
|
156
|
+
minimumVersion?: number | undefined;
|
|
157
|
+
}): Promise<PreparedRevocations>;
|
|
158
|
+
export declare function signPreparedRevocations(p: PreparedRevocations, key: PrivateKeyInfo): Buffer;
|
|
159
|
+
export declare function commitRevocations(p: PreparedRevocations, rootKey: PrivateKeyInfo, o?: {
|
|
160
|
+
beforeWrite?: () => void | Promise<void>;
|
|
161
|
+
}): Promise<{
|
|
162
|
+
version: number;
|
|
163
|
+
path: string;
|
|
164
|
+
sha256: string;
|
|
165
|
+
expiresAt: Date;
|
|
166
|
+
}>;
|
|
43
167
|
export declare function updateRevocations(options: {
|
|
44
168
|
rootKeyPath: string;
|
|
45
169
|
revocationsPath: string;
|
|
@@ -56,7 +180,9 @@ export declare function updateRevocations(options: {
|
|
|
56
180
|
}>;
|
|
57
181
|
export declare function approveSkill(options: {
|
|
58
182
|
skillDir: string;
|
|
59
|
-
|
|
183
|
+
/** The approver's private key file; or pass `approverKey`, already loaded (exactly one of the two). */
|
|
184
|
+
approverKeyPath?: string;
|
|
185
|
+
approverKey?: PrivateKeyInfo;
|
|
60
186
|
now: Date;
|
|
61
187
|
expires: string;
|
|
62
188
|
reason: string;
|
|
@@ -65,6 +191,15 @@ export declare function approveSkill(options: {
|
|
|
65
191
|
out?: string;
|
|
66
192
|
/** The digest the approver reviewed; issuance is refused if the bytes on disk differ. */
|
|
67
193
|
expectDigest?: string;
|
|
194
|
+
/** The Skill name the approver reviewed; issuance is refused if the signed SKILL.md yields a different name. */
|
|
195
|
+
expectName?: string;
|
|
196
|
+
/** Write to `<outDir>/<signed name>.cert.json` instead of next to the Skill; exclusive with `out`. */
|
|
197
|
+
outDir?: string;
|
|
198
|
+
/** Awaited after the certificate is built and just before it is written; a throw writes nothing. */
|
|
199
|
+
beforeSign?: (info: {
|
|
200
|
+
skillName: string;
|
|
201
|
+
digest: string;
|
|
202
|
+
}) => void | Promise<void>;
|
|
68
203
|
}): Promise<{
|
|
69
204
|
path: string;
|
|
70
205
|
skillName: string;
|