owenloop 0.5.0 → 0.5.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.
- package/CHANGELOG.md +45 -0
- package/README.md +137 -35
- package/bin/owenloop.mjs +49 -1
- package/dist/packages/work/src/agent/brief.d.ts +8 -4
- package/dist/packages/work/src/agent/brief.js +7 -3
- package/dist/packages/work/src/agent/loop.d.ts +13 -7
- package/dist/packages/work/src/agent/loop.js +136 -9
- package/dist/packages/work/src/agent/model-policy.d.ts +49 -0
- package/dist/packages/work/src/agent/model-policy.js +138 -0
- package/dist/packages/work/src/bundle/cache.d.ts +7 -5
- package/dist/packages/work/src/bundle/cache.js +20 -6
- package/dist/packages/work/src/bundle/fetch.d.ts +7 -5
- package/dist/packages/work/src/bundle/fetch.js +27 -7
- package/dist/packages/work/src/bundle/types.d.ts +8 -4
- package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
- package/dist/packages/work/src/consumed-verifier.js +205 -0
- package/dist/packages/work/src/exec/instructions.d.ts +99 -0
- package/dist/packages/work/src/exec/instructions.js +323 -0
- package/dist/packages/work/src/exec/loop.d.ts +12 -1
- package/dist/packages/work/src/exec/loop.js +137 -20
- package/dist/packages/work/src/exec/payload.d.ts +29 -0
- package/dist/packages/work/src/exec/payload.js +54 -0
- package/dist/packages/work/src/exec/receipt.d.ts +9 -6
- package/dist/packages/work/src/exec/receipt.js +12 -1
- package/dist/packages/work/src/exec/runner.d.ts +7 -1
- package/dist/packages/work/src/exec/runner.js +74 -3
- package/dist/packages/work/src/harness/child-env.js +7 -0
- package/dist/packages/work/src/harness/claude.d.ts +20 -8
- package/dist/packages/work/src/harness/claude.js +260 -58
- package/dist/packages/work/src/harness/codex.d.ts +5 -4
- package/dist/packages/work/src/harness/codex.js +169 -41
- package/dist/packages/work/src/harness/contract.d.ts +36 -11
- package/dist/packages/work/src/harness/fake.js +1 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.js +7 -0
- package/dist/packages/work/src/harness/permissions.d.ts +16 -3
- package/dist/packages/work/src/harness/permissions.js +102 -13
- package/dist/packages/work/src/harness/session-store.d.ts +27 -9
- package/dist/packages/work/src/harness/session-store.js +271 -67
- package/dist/packages/work/src/hold/mcp.d.ts +25 -5
- package/dist/packages/work/src/hold/mcp.js +126 -11
- package/dist/packages/work/src/hub/client.d.ts +2 -1
- package/dist/packages/work/src/hub/client.js +14 -1
- package/dist/packages/work/src/hub/types.d.ts +69 -33
- package/dist/packages/work/src/hub/types.js +8 -10
- package/dist/packages/work/src/mcp/server.js +1 -1
- package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
- package/dist/packages/work/src/owenloop-bin.js +18 -0
- package/dist/packages/work/src/roles/agent-run.d.ts +12 -6
- package/dist/packages/work/src/roles/agent-run.js +116 -34
- package/dist/packages/work/src/roles/exec.d.ts +8 -0
- package/dist/packages/work/src/roles/exec.js +27 -2
- package/dist/packages/work/src/roles/hold.d.ts +4 -0
- package/dist/packages/work/src/roles/hold.js +44 -5
- package/dist/packages/work/src/roles/lint.d.ts +3 -4
- package/dist/packages/work/src/roles/lint.js +41 -7
- package/dist/packages/work/src/roles/settings.js +5 -0
- package/dist/packages/work/src/roles/shift.d.ts +1 -0
- package/dist/packages/work/src/roles/shift.js +23 -1
- package/dist/packages/work/src/settings/settings.d.ts +17 -1
- package/dist/packages/work/src/settings/settings.js +39 -0
- package/dist/packages/work/src/shift/loop.d.ts +14 -3
- package/dist/packages/work/src/shift/loop.js +447 -164
- package/dist/packages/work/src/shift/protocol.d.ts +4 -0
- package/dist/packages/work/src/shift/runtime.d.ts +2 -0
- package/dist/packages/work/src/shift/runtime.js +66 -3
- package/dist/packages/work/src/shift/spawn.d.ts +41 -18
- package/dist/packages/work/src/shift/spawn.js +89 -31
- package/dist/packages/work/src/shift/state.d.ts +53 -51
- package/dist/packages/work/src/shift/state.js +325 -102
- package/dist/packages/work/src/submit-proof.d.ts +36 -0
- package/dist/packages/work/src/submit-proof.js +93 -0
- package/dist/src/add.d.ts +64 -259
- package/dist/src/add.js +81 -615
- package/dist/src/archive.d.ts +97 -0
- package/dist/src/archive.js +591 -0
- package/dist/src/bundle/index.d.ts +64 -0
- package/dist/src/bundle/index.js +508 -0
- package/dist/src/bundle/manifest.d.ts +50 -0
- package/dist/src/bundle/manifest.js +435 -0
- package/dist/src/bundle/runtime.d.ts +26 -0
- package/dist/src/bundle/runtime.js +64 -0
- package/dist/src/bundle/tar.d.ts +62 -0
- package/dist/src/bundle/tar.js +238 -0
- package/dist/src/bundle/types.d.ts +105 -0
- package/dist/src/bundle/types.js +21 -0
- package/dist/src/cli.d.ts +90 -20
- package/dist/src/cli.js +2407 -365
- package/dist/src/credentials.d.ts +4 -3
- package/dist/src/credentials.js +21 -19
- package/dist/src/crypto/allowed-signers.d.ts +68 -0
- package/dist/src/crypto/allowed-signers.js +307 -0
- package/dist/src/crypto/canonical.d.ts +8 -0
- package/dist/src/crypto/canonical.js +92 -0
- package/dist/src/crypto/chain.d.ts +65 -0
- package/dist/src/crypto/chain.js +377 -0
- package/dist/src/crypto/dsse.d.ts +209 -0
- package/dist/src/crypto/dsse.js +282 -0
- package/dist/src/crypto/enrollment.d.ts +78 -0
- package/dist/src/crypto/enrollment.js +186 -0
- package/dist/src/crypto/index.d.ts +48 -0
- package/dist/src/crypto/index.js +44 -0
- package/dist/src/crypto/keys.d.ts +258 -0
- package/dist/src/crypto/keys.js +908 -0
- package/dist/src/crypto/org-root.d.ts +33 -0
- package/dist/src/crypto/org-root.js +78 -0
- package/dist/src/crypto/origin-rules.d.ts +56 -0
- package/dist/src/crypto/origin-rules.js +143 -0
- package/dist/src/crypto/policy-floor.d.ts +98 -0
- package/dist/src/crypto/policy-floor.js +353 -0
- package/dist/src/crypto/records.d.ts +316 -0
- package/dist/src/crypto/records.js +157 -0
- package/dist/src/crypto/scope.d.ts +49 -0
- package/dist/src/crypto/scope.js +83 -0
- package/dist/src/crypto/ssh.d.ts +171 -0
- package/dist/src/crypto/ssh.js +396 -0
- package/dist/src/crypto/submission.d.ts +33 -0
- package/dist/src/crypto/submission.js +47 -0
- package/dist/src/crypto/trust-roots.d.ts +29 -0
- package/dist/src/crypto/trust-roots.js +39 -0
- package/dist/src/crypto/verify-consumed.d.ts +67 -0
- package/dist/src/crypto/verify-consumed.js +259 -0
- package/dist/src/crypto/verify-origin.d.ts +50 -0
- package/dist/src/crypto/verify-origin.js +151 -0
- package/dist/src/crypto/verify-publication.d.ts +60 -0
- package/dist/src/crypto/verify-publication.js +150 -0
- package/dist/src/defs.d.ts +24 -1
- package/dist/src/defs.js +145 -25
- package/dist/src/engine.d.ts +99 -3
- package/dist/src/engine.js +238 -34
- package/dist/src/factory.d.ts +16 -0
- package/dist/src/factory.js +16 -4
- package/dist/src/global-config.d.ts +59 -0
- package/dist/src/global-config.js +84 -0
- package/dist/src/hub.d.ts +75 -21
- package/dist/src/hub.js +123 -40
- package/dist/src/index.d.ts +17 -2
- package/dist/src/index.js +20 -2
- package/dist/src/install.d.ts +538 -0
- package/dist/src/install.js +1981 -0
- package/dist/src/lock.d.ts +15 -57
- package/dist/src/lock.js +251 -143
- package/dist/src/mcp/serve.d.ts +46 -22
- package/dist/src/mcp/serve.js +167 -44
- package/dist/src/mcp/server.js +12 -1
- package/dist/src/model.d.ts +15 -0
- package/dist/src/model.js +111 -1
- package/dist/src/order-resolver.d.ts +184 -0
- package/dist/src/order-resolver.js +252 -0
- package/dist/src/package-version.d.ts +10 -0
- package/dist/src/package-version.js +42 -0
- package/dist/src/paths.d.ts +14 -1
- package/dist/src/paths.js +18 -0
- package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
- package/dist/src/schemas/index.d.ts +1416 -0
- package/dist/src/schemas/index.js +31 -0
- package/dist/src/schemas/order.v1.schema.json +106 -0
- package/dist/src/schemas/origin.v1.schema.json +68 -0
- package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
- package/dist/src/schemas/publication.v1.schema.json +31 -0
- package/dist/src/schemas/revocation.v1.schema.json +39 -0
- package/dist/src/schemas/submission.v1.schema.json +61 -0
- package/dist/src/store/def-source.d.ts +52 -0
- package/dist/src/store/def-source.js +335 -0
- package/dist/src/store/index-file.d.ts +69 -0
- package/dist/src/store/index-file.js +151 -0
- package/dist/src/store/index.d.ts +27 -0
- package/dist/src/store/index.js +22 -0
- package/dist/src/store/ingestor.d.ts +43 -0
- package/dist/src/store/ingestor.js +211 -0
- package/dist/src/store/install.d.ts +228 -0
- package/dist/src/store/install.js +555 -0
- package/dist/src/store/instruction-source.d.ts +49 -0
- package/dist/src/store/instruction-source.js +298 -0
- package/dist/src/store/origin-evidence.d.ts +21 -0
- package/dist/src/store/origin-evidence.js +66 -0
- package/dist/src/store/pre-commit-verifier.d.ts +68 -0
- package/dist/src/store/pre-commit-verifier.js +418 -0
- package/dist/src/store/resolve.d.ts +138 -0
- package/dist/src/store/resolve.js +363 -0
- package/dist/src/store/types.d.ts +288 -0
- package/dist/src/store/types.js +356 -0
- package/dist/src/types.d.ts +45 -11
- package/dist/src/untar.d.ts +8 -23
- package/dist/src/untar.js +10 -136
- package/docs/agent-runner.md +86 -0
- package/docs/authoring.md +57 -6
- package/docs/bundles.md +250 -0
- package/docs/cli.md +1171 -97
- package/docs/crypto.md +816 -0
- package/docs/design.md +342 -20
- package/docs/embedding.md +132 -25
- package/docs/wire-contracts.md +380 -0
- package/package.json +6 -1
- package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
- package/plugins/claude-code/plugin/.mcp.json +14 -0
- package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
- package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
- package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
- package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
- package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
- package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
- package/plugins/codex/.agents/plugins/marketplace.json +21 -0
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
- package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
- package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
- package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
- package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
- package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
- package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSHSIG signing/verification through stock OpenSSH, behind one async
|
|
3
|
+
* `Signer` interface.
|
|
4
|
+
*
|
|
5
|
+
* **Why stock OpenSSH (and not a pure-JS SSHSIG implementation):** invoking
|
|
6
|
+
* `ssh-keygen -Y sign` / `ssh-keygen -Y verify` gives byte-level
|
|
7
|
+
* interoperability with the system verifier, adds no cryptographic
|
|
8
|
+
* parser/encoder dependency, and delegates SSHSIG format and `allowed_signers`
|
|
9
|
+
* policy semantics to maintained OpenSSH code. The portability cost is an
|
|
10
|
+
* external runtime requirement: `ssh-keygen` must support `-Y`. Support is
|
|
11
|
+
* PROBED (a harmless capability invocation), never inferred from a version
|
|
12
|
+
* string; when unavailable the probe result is an actionable error.
|
|
13
|
+
*
|
|
14
|
+
* **Secrecy discipline.** Private key material never appears in argv, captured
|
|
15
|
+
* stdout/stderr, thrown messages, or logs:
|
|
16
|
+
* - every invocation is `shell: false` (argv is a vector, never a shell line);
|
|
17
|
+
* - the message bytes ride on child stdin; the private key rides only as a
|
|
18
|
+
* `-f <path>` argument (a PATH — never the key contents);
|
|
19
|
+
* - child stdout/stderr is captured only where it is public by nature (the
|
|
20
|
+
* armored SSH signature; verification status). A verification failure
|
|
21
|
+
* throws a FIXED diagnostic that never interpolates child output.
|
|
22
|
+
*
|
|
23
|
+
* **Signer semantics.** `verify` returns a `VerifiedSignature` descriptor on a
|
|
24
|
+
* successful OpenSSH verification against the configured principal +
|
|
25
|
+
* `allowed_signers` content, or `null` on a normal verification miss. A
|
|
26
|
+
* tool/configuration failure (no binary, missing `-Y` support, timeout,
|
|
27
|
+
* oversized output) THROWS — a miss and a broken toolchain are different
|
|
28
|
+
* facts. Authorization is decided by OpenSSH itself; a signature's `keyid`
|
|
29
|
+
* (candidate hint) is never treated as identity.
|
|
30
|
+
*/
|
|
31
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
32
|
+
import { createHash } from 'node:crypto';
|
|
33
|
+
import { chmodSync, mkdtempSync, rmSync, writeFileSync, readFileSync } from 'node:fs';
|
|
34
|
+
import { tmpdir } from 'node:os';
|
|
35
|
+
import { join } from 'node:path';
|
|
36
|
+
import { parseAllowedSigners } from "./allowed-signers.js";
|
|
37
|
+
/** Thrown for SSHSIG tool/configuration failures. Message is fixed, non-secret. */
|
|
38
|
+
export class SshSignerError extends Error {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = 'SshSignerError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Default per-invocation timeout. */
|
|
45
|
+
const SSH_DEFAULT_TIMEOUT_MS = 10_000;
|
|
46
|
+
/** Cap on captured child output (signatures and status lines are small). */
|
|
47
|
+
const SSH_MAX_BUFFER = 1024 * 256;
|
|
48
|
+
/** The default `spawn`-based adapter: `shell: false`, captured stdio, timeout + output cap. */
|
|
49
|
+
export const defaultSshProcess = {
|
|
50
|
+
run(cmd, args, opts) {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
const child = spawn(cmd, args, { shell: false, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
53
|
+
const stdout = [];
|
|
54
|
+
const stderr = [];
|
|
55
|
+
let outLen = 0;
|
|
56
|
+
let errLen = 0;
|
|
57
|
+
let truncated = false;
|
|
58
|
+
let timedOut = false;
|
|
59
|
+
const cap = opts.maxBuffer ?? SSH_MAX_BUFFER;
|
|
60
|
+
const timer = setTimeout(() => {
|
|
61
|
+
timedOut = true;
|
|
62
|
+
child.kill('SIGKILL');
|
|
63
|
+
}, opts.timeoutMs);
|
|
64
|
+
child.stdout.on('data', (c) => {
|
|
65
|
+
outLen += c.length;
|
|
66
|
+
if (outLen <= cap)
|
|
67
|
+
stdout.push(c);
|
|
68
|
+
else
|
|
69
|
+
truncated = true;
|
|
70
|
+
});
|
|
71
|
+
child.stderr.on('data', (c) => {
|
|
72
|
+
errLen += c.length;
|
|
73
|
+
if (errLen <= cap)
|
|
74
|
+
stderr.push(c);
|
|
75
|
+
});
|
|
76
|
+
child.on('error', () => {
|
|
77
|
+
clearTimeout(timer);
|
|
78
|
+
resolve({ status: null, stdout: Buffer.alloc(0), stderr: Buffer.alloc(0), timedOut: false, truncated: false });
|
|
79
|
+
});
|
|
80
|
+
child.on('close', (code) => {
|
|
81
|
+
clearTimeout(timer);
|
|
82
|
+
resolve({
|
|
83
|
+
status: code,
|
|
84
|
+
stdout: Buffer.concat(stdout),
|
|
85
|
+
stderr: Buffer.concat(stderr),
|
|
86
|
+
timedOut,
|
|
87
|
+
truncated,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
if (opts.stdin && opts.stdin.length > 0)
|
|
91
|
+
child.stdin.write(opts.stdin);
|
|
92
|
+
child.stdin.end();
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
probe(cmd, args, opts) {
|
|
96
|
+
const result = spawnSync(cmd, args, {
|
|
97
|
+
shell: false,
|
|
98
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
99
|
+
timeout: opts.timeoutMs,
|
|
100
|
+
maxBuffer: SSH_MAX_BUFFER,
|
|
101
|
+
});
|
|
102
|
+
const err = result.error;
|
|
103
|
+
return {
|
|
104
|
+
status: result.status,
|
|
105
|
+
stderr: Buffer.isBuffer(result.stderr) ? result.stderr : Buffer.alloc(0),
|
|
106
|
+
errorCode: err?.code,
|
|
107
|
+
timedOut: err?.code === 'ETIMEDOUT',
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Probe whether the system `ssh-keygen` supports the feature-specific `-Y`
|
|
113
|
+
* command group. The probe is routed through the injected process adapter so
|
|
114
|
+
* tests cannot accidentally execute the host toolchain. A supported command is
|
|
115
|
+
* allowed to return a normal nonzero policy/input status; only an unknown option,
|
|
116
|
+
* missing executable, timeout, or signal failure means the feature is absent.
|
|
117
|
+
*/
|
|
118
|
+
let sshCapability = null;
|
|
119
|
+
export function probeSshKeygenY(adapter, tempDir) {
|
|
120
|
+
if (sshCapability !== null)
|
|
121
|
+
return sshCapability;
|
|
122
|
+
const makeDir = tempDir ?? ((prefix) => mkdtempSync(join(tmpdir(), prefix)));
|
|
123
|
+
const proc = adapter ?? defaultSshProcess;
|
|
124
|
+
if (proc.probe === undefined) {
|
|
125
|
+
return (sshCapability = { ok: false, detail: 'ssh-keygen capability probe is unavailable' });
|
|
126
|
+
}
|
|
127
|
+
const dir = makeDir('owenloop-sshprobe-');
|
|
128
|
+
try {
|
|
129
|
+
const allowed = join(dir, 'allowed_signers');
|
|
130
|
+
writeFileSync(allowed, '');
|
|
131
|
+
const result = proc.probe('ssh-keygen', ['-Y', 'find-principals', '-f', allowed, '-s', allowed], {
|
|
132
|
+
timeoutMs: SSH_DEFAULT_TIMEOUT_MS,
|
|
133
|
+
});
|
|
134
|
+
const diagnostics = result.stderr.toString('utf8');
|
|
135
|
+
if (result.timedOut || result.errorCode === 'ETIMEDOUT') {
|
|
136
|
+
return (sshCapability = { ok: false, detail: 'ssh-keygen capability probe timed out' });
|
|
137
|
+
}
|
|
138
|
+
if (result.errorCode === 'ENOENT') {
|
|
139
|
+
return (sshCapability = { ok: false, detail: 'ssh-keygen is not available (ENOENT)' });
|
|
140
|
+
}
|
|
141
|
+
if (result.status === null) {
|
|
142
|
+
return (sshCapability = { ok: false, detail: 'ssh-keygen capability probe terminated by signal' });
|
|
143
|
+
}
|
|
144
|
+
if (/unknown option|illegal option|unrecognized option/i.test(diagnostics)) {
|
|
145
|
+
return (sshCapability = { ok: false, detail: 'ssh-keygen does not support -Y (OpenSSH >= 8.1 required)' });
|
|
146
|
+
}
|
|
147
|
+
return (sshCapability = { ok: true, detail: 'ssh-keygen supports -Y' });
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
rmSync(dir, { recursive: true, force: true });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** Reset the cached capability (tests only). */
|
|
154
|
+
export function resetSshKeygenProbe() {
|
|
155
|
+
sshCapability = null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Run one `ssh-keygen` invocation through the adapter with fixed failure
|
|
159
|
+
* classification, in the plan's order: timeout, output-cap, exit-status,
|
|
160
|
+
* signal. Child output NEVER reaches the thrown message.
|
|
161
|
+
*/
|
|
162
|
+
function classify(r, what) {
|
|
163
|
+
if (r.timedOut)
|
|
164
|
+
throw new SshSignerError(`${what}: timed out`);
|
|
165
|
+
if (r.truncated)
|
|
166
|
+
throw new SshSignerError(`${what}: output exceeded the cap`);
|
|
167
|
+
if (r.status === null)
|
|
168
|
+
throw new SshSignerError(`${what}: child terminated by signal`);
|
|
169
|
+
if (r.status !== 0)
|
|
170
|
+
throw new SshSignerError(`${what}: exited with status ${r.status}`);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The OpenSSH SSHSIG signer. Construct via `createSshSigner`. Signing and
|
|
174
|
+
* verification are separate capabilities configured at construction; using an
|
|
175
|
+
* unconfigured capability throws a fixed `SshSignerError`.
|
|
176
|
+
*/
|
|
177
|
+
export class SshSigner {
|
|
178
|
+
config;
|
|
179
|
+
proc;
|
|
180
|
+
makeTempDir;
|
|
181
|
+
/** The verification temp dir (created lazily), removed in `dispose`. */
|
|
182
|
+
verifyDir = null;
|
|
183
|
+
constructor(config) {
|
|
184
|
+
if (config.namespace === '')
|
|
185
|
+
throw new SshSignerError('the SSHSIG namespace must not be empty');
|
|
186
|
+
this.config = config;
|
|
187
|
+
this.proc = config.process ?? defaultSshProcess;
|
|
188
|
+
this.makeTempDir = config.tempDir ?? ((prefix) => mkdtempSync(join(tmpdir(), prefix)));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Sign `exactBytes` by placing the private key path in `-f`, the configured
|
|
192
|
+
* namespace in `-n`, and the message on stdin. The armored SSH signature is
|
|
193
|
+
* captured from stdout (public information). Payload and private bytes never
|
|
194
|
+
* appear in argv.
|
|
195
|
+
*/
|
|
196
|
+
async sign(exactBytes) {
|
|
197
|
+
const keyPath = this.config.signKeyPath;
|
|
198
|
+
if (keyPath === undefined) {
|
|
199
|
+
throw new SshSignerError('this signer is not configured for signing (no signKeyPath)');
|
|
200
|
+
}
|
|
201
|
+
const publicText = await publicTextForSigningPath(keyPath, this.proc, this.config.timeoutMs ?? SSH_DEFAULT_TIMEOUT_MS);
|
|
202
|
+
assertEd25519PubText(publicText, 'signing key');
|
|
203
|
+
const keyid = fingerprintForPubText(publicText);
|
|
204
|
+
const r = await this.proc.run('ssh-keygen', ['-Y', 'sign', '-f', keyPath, '-n', this.config.namespace], { stdin: exactBytes, timeoutMs: this.config.timeoutMs ?? SSH_DEFAULT_TIMEOUT_MS });
|
|
205
|
+
classify(r, 'sshsig sign');
|
|
206
|
+
const armored = r.stdout.toString('utf8');
|
|
207
|
+
if (!armored.includes('-----BEGIN SSH SIGNATURE-----')) {
|
|
208
|
+
throw new SshSignerError('sshsig sign: no armored signature produced');
|
|
209
|
+
}
|
|
210
|
+
return { keyid, sig: Buffer.from(armored, 'utf8') };
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Verify `exactBytes` against a detached armored signature. Writes the
|
|
214
|
+
* armored signature and the raw `allowed_signers` text to temporary
|
|
215
|
+
* NON-SECRET files, passes the expected principal with `-I`, the namespace
|
|
216
|
+
* with `-n`, and the message on stdin.
|
|
217
|
+
*
|
|
218
|
+
* Zero exit ⇒ valid: returns `{ keyid, principal, format: 'sshsig' }`.
|
|
219
|
+
* A normal verification miss ⇒ `null`. Tool/configuration failures throw a
|
|
220
|
+
* fixed diagnostic that includes no child output.
|
|
221
|
+
*/
|
|
222
|
+
async verify(exactBytes, signature) {
|
|
223
|
+
const ctx = this.config.verify;
|
|
224
|
+
if (ctx === undefined) {
|
|
225
|
+
throw new SshSignerError('this signer is not configured for verification (no principal/allowedSignersText)');
|
|
226
|
+
}
|
|
227
|
+
const policy = parseAllowedSigners(ctx.allowedSignersText);
|
|
228
|
+
if (policy.errors.length > 0 || policy.entries.length === 0) {
|
|
229
|
+
throw new SshSignerError('sshsig verify: malformed allowed_signers policy');
|
|
230
|
+
}
|
|
231
|
+
// OpenSSH remains the policy authority: unrelated entries may use other
|
|
232
|
+
// stock key types. The Ed25519 restriction is applied to the key embedded
|
|
233
|
+
// in the signature after OpenSSH has selected and verified that key.
|
|
234
|
+
if (this.verifyDir === null) {
|
|
235
|
+
this.verifyDir = this.makeTempDir('owenloop-sshsig-');
|
|
236
|
+
chmodSync(this.verifyDir, 0o700);
|
|
237
|
+
}
|
|
238
|
+
const sigPath = join(this.verifyDir, `sig-${Math.random().toString(36).slice(2)}.armored`);
|
|
239
|
+
const allowedPath = join(this.verifyDir, `allowed-${Math.random().toString(36).slice(2)}.txt`);
|
|
240
|
+
writeFileSync(sigPath, signature, { mode: 0o600 });
|
|
241
|
+
// Preserve the accepted policy text byte-for-byte for stock OpenSSH.
|
|
242
|
+
writeFileSync(allowedPath, ctx.allowedSignersText, { mode: 0o600 });
|
|
243
|
+
try {
|
|
244
|
+
const r = await this.proc.run('ssh-keygen', [
|
|
245
|
+
'-Y', 'verify',
|
|
246
|
+
'-f', allowedPath,
|
|
247
|
+
'-I', ctx.principal,
|
|
248
|
+
'-n', this.config.namespace,
|
|
249
|
+
'-s', sigPath,
|
|
250
|
+
], { stdin: exactBytes, timeoutMs: this.config.timeoutMs ?? SSH_DEFAULT_TIMEOUT_MS });
|
|
251
|
+
if (r.timedOut)
|
|
252
|
+
throw new SshSignerError('sshsig verify: timed out');
|
|
253
|
+
if (r.truncated)
|
|
254
|
+
throw new SshSignerError('sshsig verify: output exceeded the cap');
|
|
255
|
+
if (r.status === 0) {
|
|
256
|
+
try {
|
|
257
|
+
const keyid = fingerprintForSshsigPublicKey(signature);
|
|
258
|
+
return { keyid, principal: ctx.principal, format: 'sshsig' };
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
throw new SshSignerError('sshsig verify: verified signature has no valid Ed25519 public key');
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (r.status === 255 && isCryptographicMiss(r.stdout, r.stderr))
|
|
265
|
+
return null;
|
|
266
|
+
if (r.status !== null)
|
|
267
|
+
throw new SshSignerError(`sshsig verify: exited with status ${r.status}`);
|
|
268
|
+
throw new SshSignerError('sshsig verify: child terminated by signal');
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
rmSync(sigPath, { force: true });
|
|
272
|
+
rmSync(allowedPath, { force: true });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/** Remove the verification temp dir. */
|
|
276
|
+
dispose() {
|
|
277
|
+
if (this.verifyDir !== null) {
|
|
278
|
+
rmSync(this.verifyDir, { recursive: true, force: true });
|
|
279
|
+
this.verifyDir = null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/** Read the actual public half for a signing path. Private paths are derived
|
|
284
|
+
* through stock ssh-keygen; adjacent `.pub` text is never trusted for them. */
|
|
285
|
+
async function publicTextForSigningPath(keyPath, proc, timeoutMs) {
|
|
286
|
+
try {
|
|
287
|
+
const text = readFileSync(keyPath, 'utf8');
|
|
288
|
+
const line = text.split(/\r?\n/).find((l) => l.trim() !== '')?.trim() ?? '';
|
|
289
|
+
if (/^(?:ssh-|ecdsa-|sk-)/.test(line))
|
|
290
|
+
return text;
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// Derivation below reports a fixed error.
|
|
294
|
+
}
|
|
295
|
+
const result = await proc.run('ssh-keygen', ['-y', '-f', keyPath], { timeoutMs });
|
|
296
|
+
classify(result, 'sshsig public-key derivation');
|
|
297
|
+
return result.stdout.toString('utf8');
|
|
298
|
+
}
|
|
299
|
+
function fingerprintForPubText(pubText) {
|
|
300
|
+
const line = pubText.split(/\r?\n/).find((l) => l.trim() !== '');
|
|
301
|
+
if (line === undefined)
|
|
302
|
+
throw new SshSignerError('public key file is empty');
|
|
303
|
+
const parts = line.trim().split(/\s+/);
|
|
304
|
+
if (parts.length < 2)
|
|
305
|
+
throw new SshSignerError('public key line is malformed');
|
|
306
|
+
assertEd25519PubText(pubText, 'public key');
|
|
307
|
+
return fingerprintFromBase64(parts[1]);
|
|
308
|
+
}
|
|
309
|
+
function fingerprintFromBase64(b64) {
|
|
310
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(b64) || b64.length % 4 === 1) {
|
|
311
|
+
throw new SshSignerError('public key Base64 is malformed');
|
|
312
|
+
}
|
|
313
|
+
const body = b64.replace(/=+$/, '');
|
|
314
|
+
const expectedPad = body.length % 4 === 0 ? 0 : 4 - (body.length % 4);
|
|
315
|
+
if (b64.length - body.length !== expectedPad)
|
|
316
|
+
throw new SshSignerError('public key Base64 is malformed');
|
|
317
|
+
const blob = Buffer.from(b64, 'base64');
|
|
318
|
+
if (blob.length === 0)
|
|
319
|
+
throw new SshSignerError('public key blob is empty');
|
|
320
|
+
const digest = createHash('sha256').update(blob).digest('base64').replace(/=+$/, '');
|
|
321
|
+
return `SHA256:${digest}`;
|
|
322
|
+
}
|
|
323
|
+
/** Extract the embedded public-key field from a verified SSHSIG armor. */
|
|
324
|
+
function fingerprintForSshsigPublicKey(armored) {
|
|
325
|
+
const text = armored.toString('utf8');
|
|
326
|
+
const begin = '-----BEGIN SSH SIGNATURE-----';
|
|
327
|
+
const end = '-----END SSH SIGNATURE-----';
|
|
328
|
+
const start = text.indexOf(begin);
|
|
329
|
+
const finish = text.indexOf(end);
|
|
330
|
+
if (start < 0 || finish <= start)
|
|
331
|
+
throw new Error('malformed armor');
|
|
332
|
+
const body = text.slice(start + begin.length, finish).replace(/[\r\n]/g, '');
|
|
333
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(body) || body.length % 4 === 1)
|
|
334
|
+
throw new Error('malformed armor');
|
|
335
|
+
const raw = Buffer.from(body, 'base64');
|
|
336
|
+
let offset = 0;
|
|
337
|
+
const take = (label) => {
|
|
338
|
+
if (offset + 4 > raw.length)
|
|
339
|
+
throw new Error(`missing ${label}`);
|
|
340
|
+
const length = raw.readUInt32BE(offset);
|
|
341
|
+
offset += 4;
|
|
342
|
+
if (length > raw.length - offset)
|
|
343
|
+
throw new Error(`bad ${label} length`);
|
|
344
|
+
const value = raw.subarray(offset, offset + length);
|
|
345
|
+
offset += length;
|
|
346
|
+
return value;
|
|
347
|
+
};
|
|
348
|
+
if (raw.subarray(0, 6).toString('ascii') !== 'SSHSIG')
|
|
349
|
+
throw new Error('bad magic');
|
|
350
|
+
offset = 6;
|
|
351
|
+
if (offset + 4 > raw.length || raw.readUInt32BE(offset) !== 1)
|
|
352
|
+
throw new Error('unsupported SSHSIG version');
|
|
353
|
+
offset += 4;
|
|
354
|
+
const publicKeyField = take('public key');
|
|
355
|
+
const keyType = (() => {
|
|
356
|
+
let p = 0;
|
|
357
|
+
if (publicKeyField.length < 4)
|
|
358
|
+
throw new Error('bad public key');
|
|
359
|
+
const n = publicKeyField.readUInt32BE(p);
|
|
360
|
+
p += 4;
|
|
361
|
+
if (n > publicKeyField.length - p)
|
|
362
|
+
throw new Error('bad key type length');
|
|
363
|
+
return publicKeyField.subarray(p, p + n).toString('ascii');
|
|
364
|
+
})();
|
|
365
|
+
if (keyType !== 'ssh-ed25519')
|
|
366
|
+
throw new Error('non-Ed25519 public key');
|
|
367
|
+
return `SHA256:${createHash('sha256').update(publicKeyField).digest('base64').replace(/=+$/, '')}`;
|
|
368
|
+
}
|
|
369
|
+
function isCryptographicMiss(stdout, stderr) {
|
|
370
|
+
const diagnostics = `${stdout.toString('utf8')}\n${stderr.toString('utf8')}`;
|
|
371
|
+
return stdout.length === 0 && stderr.length === 0 || /could not verify signature|namespace does not match/i.test(diagnostics);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Create an `SshSigner` from a config. Verifies the capability probe once
|
|
375
|
+
* (cached for the process lifetime) and throws an actionable error when the
|
|
376
|
+
* system `ssh-keygen` lacks `-Y`.
|
|
377
|
+
*/
|
|
378
|
+
export function createSshSigner(config) {
|
|
379
|
+
const cap = probeSshKeygenY(config.process, config.tempDir);
|
|
380
|
+
if (!cap.ok)
|
|
381
|
+
throw new SshSignerError(cap.detail);
|
|
382
|
+
return new SshSigner(config);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Validate that a candidate SSH key is Ed25519 by reading its public key text
|
|
386
|
+
* (private bytes are never read). Throws a fixed error for non-Ed25519 keys —
|
|
387
|
+
* WP-A2 rejects them even though `allowed_signers` can represent other stock
|
|
388
|
+
* key types.
|
|
389
|
+
*/
|
|
390
|
+
export function assertEd25519PubText(pubText, label) {
|
|
391
|
+
const line = pubText.split(/\r?\n/).find((l) => l.trim() !== '');
|
|
392
|
+
const keyType = line?.trim().split(/\s+/)[0];
|
|
393
|
+
if (keyType !== 'ssh-ed25519') {
|
|
394
|
+
throw new SshSignerError(`${label}: only Ed25519 keys are supported in WP-A2 (found ${keyType ?? 'no key type'})`);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Signer } from './ssh.ts';
|
|
2
|
+
import type { Fingerprint } from '../types.ts';
|
|
3
|
+
import type { SubmissionRecord } from './records.ts';
|
|
4
|
+
/** One value supplied to a submission record builder. */
|
|
5
|
+
export interface SubmissionProducedInput {
|
|
6
|
+
artifact: string;
|
|
7
|
+
version: number;
|
|
8
|
+
value: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** Inputs for constructing the frozen `submission.v1` record shape. */
|
|
11
|
+
export interface BuildSubmissionRecordInput {
|
|
12
|
+
run: string;
|
|
13
|
+
workflow: string;
|
|
14
|
+
defDigest: string;
|
|
15
|
+
step: string;
|
|
16
|
+
key: string;
|
|
17
|
+
index?: number;
|
|
18
|
+
produced: SubmissionProducedInput[];
|
|
19
|
+
consumedFingerprint: Fingerprint;
|
|
20
|
+
producerKeyId: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build the frozen submission record without signing or mutating the input.
|
|
25
|
+
* Every consumed fingerprint entry is retained; negative values are rejected
|
|
26
|
+
* because `submission.v1` only represents non-negative artifact versions.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildSubmissionRecord(input: BuildSubmissionRecordInput): SubmissionRecord;
|
|
29
|
+
/**
|
|
30
|
+
* Canonically serialize a submission record and sign it as a DSSE submission
|
|
31
|
+
* envelope. The returned string is the opaque proof carried by a submit call.
|
|
32
|
+
*/
|
|
33
|
+
export declare function signSubmission(record: SubmissionRecord, signer: Pick<Signer, 'sign'>): Promise<string>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { dsseSignSubmission } from "./dsse.js";
|
|
2
|
+
import { valueDigestHex, canonicalValueBytes } from "./canonical.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build the frozen submission record without signing or mutating the input.
|
|
5
|
+
* Every consumed fingerprint entry is retained; negative values are rejected
|
|
6
|
+
* because `submission.v1` only represents non-negative artifact versions.
|
|
7
|
+
*/
|
|
8
|
+
export function buildSubmissionRecord(input) {
|
|
9
|
+
if (input.produced.length === 0)
|
|
10
|
+
throw new RangeError('submission must contain at least one produced artifact');
|
|
11
|
+
for (const [path, version] of Object.entries(input.consumedFingerprint)) {
|
|
12
|
+
if (!Number.isInteger(version) || version < 0) {
|
|
13
|
+
throw new RangeError(`consumed fingerprint for '${path}' must be a non-negative integer`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const produced = input.produced.map((entry) => {
|
|
17
|
+
if (!Number.isInteger(entry.version) || entry.version < 0) {
|
|
18
|
+
throw new RangeError(`produced version for '${entry.artifact}' must be a non-negative integer`);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
artifact: entry.artifact,
|
|
22
|
+
version: entry.version,
|
|
23
|
+
valueDigest: valueDigestHex(entry.value),
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
run: input.run,
|
|
28
|
+
workflow: input.workflow,
|
|
29
|
+
defDigest: input.defDigest,
|
|
30
|
+
step: input.step,
|
|
31
|
+
key: input.key,
|
|
32
|
+
...(input.index !== undefined ? { index: input.index } : {}),
|
|
33
|
+
produced,
|
|
34
|
+
consumedFingerprint: { ...input.consumedFingerprint },
|
|
35
|
+
producerKeyId: input.producerKeyId,
|
|
36
|
+
timestamp: input.timestamp,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Canonically serialize a submission record and sign it as a DSSE submission
|
|
41
|
+
* envelope. The returned string is the opaque proof carried by a submit call.
|
|
42
|
+
*/
|
|
43
|
+
export async function signSubmission(record, signer) {
|
|
44
|
+
const payload = Buffer.from(canonicalValueBytes(record));
|
|
45
|
+
const { envelope } = await dsseSignSubmission(payload, signer);
|
|
46
|
+
return Buffer.from(canonicalValueBytes(envelope)).toString('utf8');
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolution of the local SSHSIG trust root used for workflow publications.
|
|
3
|
+
*
|
|
4
|
+
* The path is derived only from injected environment state. XDG_CONFIG_HOME
|
|
5
|
+
* wins over HOME, matching the execution settings path; no ambient home
|
|
6
|
+
* directory lookup is allowed here. An absent file is a normal result so the
|
|
7
|
+
* publication verifier can classify it as `unverifiable` instead of confusing
|
|
8
|
+
* a missing trust root with an unsigned bundle.
|
|
9
|
+
*/
|
|
10
|
+
export interface AllowedSignersPresent {
|
|
11
|
+
kind: 'present';
|
|
12
|
+
path: string;
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AllowedSignersAbsent {
|
|
16
|
+
kind: 'absent';
|
|
17
|
+
path: string;
|
|
18
|
+
}
|
|
19
|
+
export type AllowedSignersResolution = AllowedSignersPresent | AllowedSignersAbsent;
|
|
20
|
+
/** Resolve `<config>/owenloop/allowed_signers` from caller-supplied env. */
|
|
21
|
+
export declare function allowedSignersPath(env: Record<string, string | undefined>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Read the trust root without collapsing absence and malformed contents. A
|
|
24
|
+
* present path must be a regular file; symlinks and read failures are hard
|
|
25
|
+
* errors for the caller to classify as `unverifiable`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveAllowedSigners(env: Record<string, string | undefined>): AllowedSignersResolution;
|
|
28
|
+
/** Alias with an explicit file-oriented name for callers that prefer it. */
|
|
29
|
+
export declare const resolveAllowedSignersFile: typeof resolveAllowedSigners;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolution of the local SSHSIG trust root used for workflow publications.
|
|
3
|
+
*
|
|
4
|
+
* The path is derived only from injected environment state. XDG_CONFIG_HOME
|
|
5
|
+
* wins over HOME, matching the execution settings path; no ambient home
|
|
6
|
+
* directory lookup is allowed here. An absent file is a normal result so the
|
|
7
|
+
* publication verifier can classify it as `unverifiable` instead of confusing
|
|
8
|
+
* a missing trust root with an unsigned bundle.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
/** Resolve `<config>/owenloop/allowed_signers` from caller-supplied env. */
|
|
13
|
+
export function allowedSignersPath(env) {
|
|
14
|
+
const xdg = env.XDG_CONFIG_HOME;
|
|
15
|
+
if (xdg !== undefined && xdg.trim() !== '')
|
|
16
|
+
return join(xdg, 'owenloop', 'allowed_signers');
|
|
17
|
+
const home = env.HOME;
|
|
18
|
+
if (home !== undefined && home.trim() !== '')
|
|
19
|
+
return join(home, '.config', 'owenloop', 'allowed_signers');
|
|
20
|
+
throw new Error('cannot locate an allowed_signers path: set HOME or XDG_CONFIG_HOME');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read the trust root without collapsing absence and malformed contents. A
|
|
24
|
+
* present path must be a regular file; symlinks and read failures are hard
|
|
25
|
+
* errors for the caller to classify as `unverifiable`.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveAllowedSigners(env) {
|
|
28
|
+
const path = allowedSignersPath(env);
|
|
29
|
+
if (!existsSync(path))
|
|
30
|
+
return { kind: 'absent', path };
|
|
31
|
+
const stat = lstatSync(path);
|
|
32
|
+
if (stat.isSymbolicLink())
|
|
33
|
+
throw new Error(`allowed_signers path is a symlink: ${path}`);
|
|
34
|
+
if (!stat.isFile())
|
|
35
|
+
throw new Error(`allowed_signers path is not a regular file: ${path}`);
|
|
36
|
+
return { kind: 'present', path, text: readFileSync(path, 'utf8') };
|
|
37
|
+
}
|
|
38
|
+
/** Alias with an explicit file-oriented name for callers that prefer it. */
|
|
39
|
+
export const resolveAllowedSignersFile = resolveAllowedSigners;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consume-side verification for dynamic artifact values.
|
|
3
|
+
*
|
|
4
|
+
* A consuming driver receives values and signed submission envelopes from an
|
|
5
|
+
* untrusted transport. This module verifies the envelope first, then checks the
|
|
6
|
+
* signed submission record, the delivered value digest, the expected version,
|
|
7
|
+
* and the producer's locally anchored enrollment chain and scope. Every trust
|
|
8
|
+
* input is explicit; this module performs no filesystem, network, or clock I/O.
|
|
9
|
+
*/
|
|
10
|
+
import type { PrincipalReference } from './records.ts';
|
|
11
|
+
import { type ChainInput, type ChainOptions, type ChainVerdict } from './chain.ts';
|
|
12
|
+
export type ConsumedVerdict = {
|
|
13
|
+
kind: 'verified';
|
|
14
|
+
producerKeyId: string;
|
|
15
|
+
principal: PrincipalReference;
|
|
16
|
+
version: number;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'absent';
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'unverifiable';
|
|
21
|
+
reason: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'invalid';
|
|
24
|
+
reason: string;
|
|
25
|
+
};
|
|
26
|
+
export interface VerifyConsumedInput {
|
|
27
|
+
/** Artifact path being consumed. */
|
|
28
|
+
path: string;
|
|
29
|
+
/** Exact dynamic value delivered by the transport. */
|
|
30
|
+
value: unknown;
|
|
31
|
+
/** Serialized DSSE submission envelope for this artifact. */
|
|
32
|
+
proof?: string;
|
|
33
|
+
/** Consumer claim-time version, when available. */
|
|
34
|
+
expectedVersion?: number;
|
|
35
|
+
/** Local organization-root public key anchor. */
|
|
36
|
+
orgRootPublicKey: string;
|
|
37
|
+
/** Raw enrollment-grant envelope bytes. */
|
|
38
|
+
grants: Uint8Array[];
|
|
39
|
+
/** Raw revocation envelope bytes. */
|
|
40
|
+
revocations?: Uint8Array[];
|
|
41
|
+
/** Consumer-owned validation instant. */
|
|
42
|
+
at: number;
|
|
43
|
+
/** Scope demanded by the consuming step. */
|
|
44
|
+
demand: {
|
|
45
|
+
pool?: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
namespace?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface VerifyConsumedOptions {
|
|
51
|
+
/** Inject a signer for hermetic verification tests. */
|
|
52
|
+
signerForPrincipal?: ChainOptions['signerForPrincipal'];
|
|
53
|
+
/** SSHSIG namespace used by the DSSE envelope. */
|
|
54
|
+
namespace?: string;
|
|
55
|
+
/** Maximum enrollment-chain depth. */
|
|
56
|
+
maxChainDepth?: number;
|
|
57
|
+
/** Diagnostic sink for producer-claimed timestamps ahead of the consumer clock. */
|
|
58
|
+
warn?: (line: string) => void;
|
|
59
|
+
/** Optional chain-validation seam; drivers use this for per-invocation memoization. */
|
|
60
|
+
chainValidator?: (input: ChainInput & {
|
|
61
|
+
demand: VerifyConsumedInput['demand'];
|
|
62
|
+
}, options: ChainOptions) => Promise<ChainVerdict> | ChainVerdict;
|
|
63
|
+
}
|
|
64
|
+
/** Verify one consumed value and its producer's enrollment/scope evidence. */
|
|
65
|
+
export declare function verifyConsumed(input: VerifyConsumedInput, options?: VerifyConsumedOptions): Promise<ConsumedVerdict>;
|
|
66
|
+
/** Alias matching the other record verifier names. */
|
|
67
|
+
export declare const verifyConsumedArtifact: typeof verifyConsumed;
|