owenloop 0.5.0 → 0.5.2
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 +67 -0
- package/README.md +144 -35
- package/bin/owenloop.mjs +49 -1
- package/dist/packages/work/src/agent/brief.d.ts +29 -4
- package/dist/packages/work/src/agent/brief.js +49 -4
- package/dist/packages/work/src/agent/capability-model.d.ts +123 -0
- package/dist/packages/work/src/agent/capability-model.js +148 -0
- package/dist/packages/work/src/agent/loop.d.ts +56 -7
- package/dist/packages/work/src/agent/loop.js +166 -9
- 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 +29 -1
- package/dist/packages/work/src/exec/loop.js +313 -35
- 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 +84 -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 +30 -10
- package/dist/packages/work/src/harness/session-store.js +317 -89
- package/dist/packages/work/src/hold/mcp.d.ts +25 -5
- package/dist/packages/work/src/hold/mcp.js +134 -12
- package/dist/packages/work/src/hub/client.d.ts +8 -1
- package/dist/packages/work/src/hub/client.js +15 -1
- package/dist/packages/work/src/hub/types.d.ts +137 -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 +115 -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 +6 -0
- package/dist/packages/work/src/roles/hold.js +83 -13
- 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 +19 -2
- package/dist/packages/work/src/roles/shift.d.ts +1 -0
- package/dist/packages/work/src/roles/shift.js +36 -2
- package/dist/packages/work/src/settings/settings.d.ts +70 -1
- package/dist/packages/work/src/settings/settings.js +90 -4
- package/dist/packages/work/src/shift/logretention.d.ts +253 -0
- package/dist/packages/work/src/shift/logretention.js +407 -0
- package/dist/packages/work/src/shift/logsink.d.ts +14 -0
- package/dist/packages/work/src/shift/logsink.js +98 -0
- package/dist/packages/work/src/shift/loop.d.ts +32 -4
- package/dist/packages/work/src/shift/loop.js +687 -166
- package/dist/packages/work/src/shift/protocol.d.ts +128 -1
- package/dist/packages/work/src/shift/protocol.js +14 -0
- package/dist/packages/work/src/shift/runtime.d.ts +16 -0
- package/dist/packages/work/src/shift/runtime.js +291 -5
- package/dist/packages/work/src/shift/server.d.ts +13 -0
- package/dist/packages/work/src/shift/server.js +61 -36
- package/dist/packages/work/src/shift/spawn.d.ts +115 -19
- package/dist/packages/work/src/shift/spawn.js +234 -30
- package/dist/packages/work/src/shift/state.d.ts +76 -49
- package/dist/packages/work/src/shift/state.js +350 -103
- package/dist/packages/work/src/shift/truncate.d.ts +35 -0
- package/dist/packages/work/src/shift/truncate.js +73 -0
- package/dist/packages/work/src/submit-proof.d.ts +61 -0
- package/dist/packages/work/src/submit-proof.js +119 -0
- package/dist/packages/work/src/submit-value.d.ts +48 -0
- package/dist/packages/work/src/submit-value.js +118 -0
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +11 -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/capabilities.d.ts +93 -0
- package/dist/src/capabilities.js +101 -0
- package/dist/src/cli.d.ts +90 -20
- package/dist/src/cli.js +2421 -374
- 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 +319 -0
- package/dist/src/crypto/records.js +168 -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 +335 -27
- package/dist/src/engine.d.ts +211 -6
- package/dist/src/engine.js +459 -59
- 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 +102 -32
- package/dist/src/hub.js +147 -58
- package/dist/src/index.d.ts +19 -2
- package/dist/src/index.js +23 -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 +174 -44
- package/dist/src/mcp/server.js +12 -1
- package/dist/src/model.d.ts +51 -0
- package/dist/src/model.js +157 -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 +1433 -0
- package/dist/src/schemas/index.js +31 -0
- package/dist/src/schemas/order.v1.schema.json +120 -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/store.d.ts +33 -1
- package/dist/src/store.js +57 -4
- package/dist/src/types.d.ts +146 -12
- 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 +64 -6
- package/docs/bundles.md +350 -0
- package/docs/cli.md +1298 -106
- package/docs/crypto.md +832 -0
- package/docs/design.md +342 -20
- package/docs/embedding.md +132 -25
- package/docs/shift-logs.md +642 -0
- package/docs/wire-contracts.md +395 -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,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enrollment-chain verification for locally anchored principal keys.
|
|
3
|
+
*
|
|
4
|
+
* The validator consumes raw DSSE envelopes and an explicit validation instant.
|
|
5
|
+
* Each grant link is verified with a signer whose allowed-signers text contains
|
|
6
|
+
* exactly that link's parent key, so a remote roster assertion cannot substitute
|
|
7
|
+
* for the local org-root anchor. Scope attenuation and revocation authority are
|
|
8
|
+
* checked after schema decoding and cryptographic verification. This module is
|
|
9
|
+
* deliberately pure: it performs no filesystem or network I/O; org-root.ts
|
|
10
|
+
* supplies the optional on-disk loader for callers that need one.
|
|
11
|
+
*/
|
|
12
|
+
import { decodeBase64Strict, DSSE_SSH_NAMESPACE, dsseVerifyEnrollmentGrant, dsseVerifyRevocation, DsseEnvelopeError } from "./dsse.js";
|
|
13
|
+
import { publicKeyDescriptor } from "./keys.js";
|
|
14
|
+
import { assertEd25519PubText, SshSignerError, createSshSigner } from "./ssh.js";
|
|
15
|
+
import { enrollmentGrantSchema, revocationSchema } from "../schemas/index.js";
|
|
16
|
+
import { summarizeIssues, validateValue } from "../schema.js";
|
|
17
|
+
import { attenuate, ORG_ROOT_SCOPE, scopePermits } from "./scope.js";
|
|
18
|
+
function invalid(reason) {
|
|
19
|
+
return { kind: 'invalid', reason };
|
|
20
|
+
}
|
|
21
|
+
function unverifiable(reason) {
|
|
22
|
+
return { kind: 'unverifiable', reason };
|
|
23
|
+
}
|
|
24
|
+
function isRecord(value) {
|
|
25
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
/** Decode and schema-check one signed record without invoking any signer. */
|
|
28
|
+
function decodeRecord(bytes, label, schema) {
|
|
29
|
+
let envelope;
|
|
30
|
+
try {
|
|
31
|
+
envelope = JSON.parse(Buffer.from(bytes).toString('utf8'));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return invalid(`${label} envelope is not valid JSON`);
|
|
35
|
+
}
|
|
36
|
+
if (!isRecord(envelope))
|
|
37
|
+
return invalid(`${label} envelope is not a JSON object`);
|
|
38
|
+
const payload = envelope.payload;
|
|
39
|
+
if (typeof payload !== 'string')
|
|
40
|
+
return invalid(`${label} envelope is missing a string 'payload'`);
|
|
41
|
+
let payloadBytes;
|
|
42
|
+
try {
|
|
43
|
+
payloadBytes = decodeBase64Strict(payload, { allowEmpty: true });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return invalid(`${label} payload is not valid Base64: ${error.message}`);
|
|
47
|
+
}
|
|
48
|
+
let decoded;
|
|
49
|
+
try {
|
|
50
|
+
decoded = JSON.parse(payloadBytes.toString('utf8'));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return invalid(`${label} payload is not valid JSON`);
|
|
54
|
+
}
|
|
55
|
+
if (!isRecord(decoded))
|
|
56
|
+
return invalid(`${label} payload is not a JSON object`);
|
|
57
|
+
const shape = validateValue(schema, decoded);
|
|
58
|
+
if (!shape.valid) {
|
|
59
|
+
return invalid(`${label} record does not match schema: ${summarizeIssues(shape.issues)}`);
|
|
60
|
+
}
|
|
61
|
+
return { envelope, record: decoded };
|
|
62
|
+
}
|
|
63
|
+
function parseGrants(bytes) {
|
|
64
|
+
const grants = new Map();
|
|
65
|
+
for (const raw of bytes) {
|
|
66
|
+
const parsed = decodeRecord(raw, 'enrollment grant', enrollmentGrantSchema);
|
|
67
|
+
if ('kind' in parsed)
|
|
68
|
+
return parsed;
|
|
69
|
+
const keyid = parsed.record.newKey.keyid;
|
|
70
|
+
if (grants.has(keyid)) {
|
|
71
|
+
return invalid(`roster contains more than one enrollment grant for '${keyid}'`);
|
|
72
|
+
}
|
|
73
|
+
grants.set(keyid, parsed);
|
|
74
|
+
}
|
|
75
|
+
return grants;
|
|
76
|
+
}
|
|
77
|
+
function parseRevocations(bytes) {
|
|
78
|
+
const revocations = [];
|
|
79
|
+
for (const raw of bytes) {
|
|
80
|
+
const parsed = decodeRecord(raw, 'revocation', revocationSchema);
|
|
81
|
+
if ('kind' in parsed)
|
|
82
|
+
return parsed;
|
|
83
|
+
revocations.push(parsed);
|
|
84
|
+
}
|
|
85
|
+
return revocations;
|
|
86
|
+
}
|
|
87
|
+
function principalText(principal) {
|
|
88
|
+
return `${principal.kind}:${principal.id}`;
|
|
89
|
+
}
|
|
90
|
+
function describePublicKey(publicKey, label) {
|
|
91
|
+
try {
|
|
92
|
+
assertEd25519PubText(publicKey, label);
|
|
93
|
+
const descriptor = publicKeyDescriptor(publicKey);
|
|
94
|
+
return { info: { keyid: descriptor.keyid, publicKey: descriptor.openSshPublicKey } };
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return invalid(`${label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function signerText(info) {
|
|
101
|
+
// The descriptor contains one canonical OpenSSH key line. No second roster
|
|
102
|
+
// key is ever concatenated here: OpenSSH must authorize this parent only.
|
|
103
|
+
return `${info.principal} ${info.publicKey}\n`;
|
|
104
|
+
}
|
|
105
|
+
function makeSigner(options, parent) {
|
|
106
|
+
const factory = options.signerForPrincipal ?? ((args) => createSshSigner({
|
|
107
|
+
namespace: options.namespace ?? DSSE_SSH_NAMESPACE,
|
|
108
|
+
verify: args,
|
|
109
|
+
}));
|
|
110
|
+
return factory({ principal: parent.principal, allowedSignersText: signerText(parent) });
|
|
111
|
+
}
|
|
112
|
+
async function verifyGrant(parsed, childKeyId, parent, options) {
|
|
113
|
+
let signer;
|
|
114
|
+
try {
|
|
115
|
+
signer = makeSigner(options, parent);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof SshSignerError)
|
|
119
|
+
return unverifiable(error.message);
|
|
120
|
+
return unverifiable(`enrollment grant verification setup failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const result = await dsseVerifyEnrollmentGrant(parsed.envelope, signer, { threshold: 1 });
|
|
124
|
+
const verified = result.signers[0];
|
|
125
|
+
if (verified === undefined)
|
|
126
|
+
return invalid(`enrollment grant for '${childKeyId}' produced no verified signer`);
|
|
127
|
+
if (verified.keyid !== parent.keyid) {
|
|
128
|
+
return invalid(`enrollment grant for '${childKeyId}' was verified by '${verified.keyid}', expected parent '${parent.keyid}'`);
|
|
129
|
+
}
|
|
130
|
+
return { kind: 'ok' };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (error instanceof SshSignerError)
|
|
134
|
+
return unverifiable(error.message);
|
|
135
|
+
if (error instanceof DsseEnvelopeError) {
|
|
136
|
+
return invalid(`enrollment grant for '${childKeyId}' signature verification failed: ${error.message}`);
|
|
137
|
+
}
|
|
138
|
+
return invalid(`enrollment grant for '${childKeyId}' signature verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
signer.dispose?.();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function verifyRevocation(parsed, authority, options) {
|
|
145
|
+
let signer;
|
|
146
|
+
try {
|
|
147
|
+
signer = makeSigner(options, authority);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
if (error instanceof SshSignerError)
|
|
151
|
+
return unverifiable(error.message);
|
|
152
|
+
return unverifiable(`revocation verification setup failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const result = await dsseVerifyRevocation(parsed.envelope, signer, { threshold: 1 });
|
|
156
|
+
const verified = result.signers[0];
|
|
157
|
+
if (verified === undefined)
|
|
158
|
+
return invalid(`revocation for '${parsed.record.revokedKey}' produced no verified signer`);
|
|
159
|
+
if (verified.keyid !== authority.keyid) {
|
|
160
|
+
return invalid(`revocation for '${parsed.record.revokedKey}' was verified by '${verified.keyid}', expected signer '${authority.keyid}'`);
|
|
161
|
+
}
|
|
162
|
+
return { kind: 'ok' };
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
if (error instanceof SshSignerError)
|
|
166
|
+
return unverifiable(error.message);
|
|
167
|
+
if (error instanceof DsseEnvelopeError) {
|
|
168
|
+
return invalid(`revocation for '${parsed.record.revokedKey}' signature verification failed: ${error.message}`);
|
|
169
|
+
}
|
|
170
|
+
return invalid(`revocation for '${parsed.record.revokedKey}' signature verification failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
signer.dispose?.();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** The canonical cross-field revocation timestamp rule. */
|
|
177
|
+
export function revocationTemporalConsistency(record) {
|
|
178
|
+
return record.backdated === (record.effectiveFrom < record.issuedAt);
|
|
179
|
+
}
|
|
180
|
+
function isAncestor(revokedKey, possibleAncestor, parentOf, rootKeyId) {
|
|
181
|
+
let current = revokedKey;
|
|
182
|
+
const seen = new Set();
|
|
183
|
+
while (current !== rootKeyId) {
|
|
184
|
+
if (seen.has(current))
|
|
185
|
+
return false;
|
|
186
|
+
seen.add(current);
|
|
187
|
+
const parent = parentOf.get(current);
|
|
188
|
+
if (parent === undefined)
|
|
189
|
+
return false;
|
|
190
|
+
if (parent === possibleAncestor)
|
|
191
|
+
return true;
|
|
192
|
+
current = parent;
|
|
193
|
+
}
|
|
194
|
+
return possibleAncestor === rootKeyId;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Validate that `targetKeyId` is rooted at the supplied org anchor, with all
|
|
198
|
+
* grant links attenuating scope and all effective revocations applied at `at`.
|
|
199
|
+
*/
|
|
200
|
+
export async function validateEnrollmentChain(input, options = {}) {
|
|
201
|
+
if (!Number.isInteger(input.at) || input.at < 0) {
|
|
202
|
+
return invalid(`validation instant '${String(input.at)}' is not a non-negative integer`);
|
|
203
|
+
}
|
|
204
|
+
const maxDepth = options.maxChainDepth ?? 32;
|
|
205
|
+
if (!Number.isInteger(maxDepth) || maxDepth < 0) {
|
|
206
|
+
return invalid(`maxChainDepth '${String(maxDepth)}' is not a non-negative integer`);
|
|
207
|
+
}
|
|
208
|
+
const rawRevocations = input.revocations ?? [];
|
|
209
|
+
const parsedRevocations = parseRevocations(rawRevocations);
|
|
210
|
+
if ('kind' in parsedRevocations)
|
|
211
|
+
return parsedRevocations;
|
|
212
|
+
const anchor = describePublicKey(input.orgRootPublicKey, 'org root public key');
|
|
213
|
+
if ('kind' in anchor)
|
|
214
|
+
return unverifiable(`cannot use org root public key: ${anchor.reason}`);
|
|
215
|
+
const rootKeyId = anchor.info.keyid;
|
|
216
|
+
// The anchor has no grant record. A self-revocation is always refused rather
|
|
217
|
+
// than silently making every otherwise-valid chain unverifiable.
|
|
218
|
+
if (parsedRevocations.some((entry) => entry.record.revokedKey === rootKeyId)) {
|
|
219
|
+
return invalid(`revocation of the org root '${rootKeyId}' is not permitted`);
|
|
220
|
+
}
|
|
221
|
+
if (input.targetKeyId === rootKeyId) {
|
|
222
|
+
return {
|
|
223
|
+
kind: 'verified',
|
|
224
|
+
keyid: rootKeyId,
|
|
225
|
+
principal: { kind: 'human', id: 'org-root' },
|
|
226
|
+
effectiveScope: ORG_ROOT_SCOPE,
|
|
227
|
+
depth: 0,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (!Array.isArray(input.grants))
|
|
231
|
+
return invalid('enrollment roster is not an array');
|
|
232
|
+
const grants = parseGrants(input.grants);
|
|
233
|
+
if ('kind' in grants)
|
|
234
|
+
return grants;
|
|
235
|
+
const rootInfo = {
|
|
236
|
+
keyid: rootKeyId,
|
|
237
|
+
publicKey: anchor.info.publicKey,
|
|
238
|
+
principal: 'org-root',
|
|
239
|
+
scope: ORG_ROOT_SCOPE,
|
|
240
|
+
};
|
|
241
|
+
const chainKeys = new Map([[rootKeyId, rootInfo]]);
|
|
242
|
+
const parentOf = new Map();
|
|
243
|
+
const visited = new Set();
|
|
244
|
+
let current = input.targetKeyId;
|
|
245
|
+
let depth = 0;
|
|
246
|
+
let effectiveScope;
|
|
247
|
+
let targetPrincipal;
|
|
248
|
+
while (current !== rootKeyId) {
|
|
249
|
+
if (visited.has(current)) {
|
|
250
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' contains a cycle at '${current}'`);
|
|
251
|
+
}
|
|
252
|
+
visited.add(current);
|
|
253
|
+
if (depth >= maxDepth) {
|
|
254
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' exceeds maxChainDepth ${maxDepth} at '${current}'`);
|
|
255
|
+
}
|
|
256
|
+
const parsed = grants.get(current);
|
|
257
|
+
if (parsed === undefined) {
|
|
258
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' does not terminate at the org root: no grant for '${current}'`);
|
|
259
|
+
}
|
|
260
|
+
const grant = parsed.record;
|
|
261
|
+
if (grant.validFrom > input.at) {
|
|
262
|
+
return invalid(`enrollment grant for '${current}' is not valid until ${grant.validFrom}`);
|
|
263
|
+
}
|
|
264
|
+
const childPublic = describePublicKey(grant.newKey.openSshPublicKey, `enrollment grant for '${current}'`);
|
|
265
|
+
if ('kind' in childPublic)
|
|
266
|
+
return childPublic;
|
|
267
|
+
if (childPublic.info.keyid !== current) {
|
|
268
|
+
return invalid(`enrollment grant for '${current}' carries public key '${childPublic.info.keyid}' in newKey, not '${current}'`);
|
|
269
|
+
}
|
|
270
|
+
if (grant.newKey.keyType !== 'ssh-ed25519') {
|
|
271
|
+
return invalid(`enrollment grant for '${current}' declares non-Ed25519 key type '${grant.newKey.keyType}'`);
|
|
272
|
+
}
|
|
273
|
+
const parentId = grant.grantedBy;
|
|
274
|
+
const parentGrant = parentId === rootKeyId ? undefined : grants.get(parentId);
|
|
275
|
+
if (parentId !== rootKeyId && parentGrant === undefined) {
|
|
276
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' does not terminate at the org root: parent '${parentId}' has no grant`);
|
|
277
|
+
}
|
|
278
|
+
if (parentId === current) {
|
|
279
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' contains a cycle at '${current}'`);
|
|
280
|
+
}
|
|
281
|
+
let parentInfo;
|
|
282
|
+
if (parentId === rootKeyId) {
|
|
283
|
+
parentInfo = rootInfo;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
const parentRecord = parentGrant.record;
|
|
287
|
+
const parentPublic = describePublicKey(parentRecord.newKey.openSshPublicKey, `enrollment grant for '${parentId}'`);
|
|
288
|
+
if ('kind' in parentPublic)
|
|
289
|
+
return parentPublic;
|
|
290
|
+
if (parentPublic.info.keyid !== parentId) {
|
|
291
|
+
return invalid(`enrollment grant for '${parentId}' carries public key '${parentPublic.info.keyid}' in newKey, not '${parentId}'`);
|
|
292
|
+
}
|
|
293
|
+
if (parentRecord.newKey.keyType !== 'ssh-ed25519') {
|
|
294
|
+
return invalid(`enrollment grant for '${parentId}' declares non-Ed25519 key type '${parentRecord.newKey.keyType}'`);
|
|
295
|
+
}
|
|
296
|
+
parentInfo = {
|
|
297
|
+
keyid: parentId,
|
|
298
|
+
publicKey: parentPublic.info.publicKey,
|
|
299
|
+
principal: principalText(parentRecord.principal),
|
|
300
|
+
scope: parentRecord.scope,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const attenuation = attenuate(parentInfo.scope, grant.scope);
|
|
304
|
+
if (!attenuation.ok) {
|
|
305
|
+
return invalid(`enrollment grant for '${current}' widens its parent scope: ${attenuation.reason}`);
|
|
306
|
+
}
|
|
307
|
+
const verified = await verifyGrant(parsed, current, { keyid: parentInfo.keyid, principal: parentInfo.principal, publicKey: parentInfo.publicKey }, options);
|
|
308
|
+
if (verified.kind !== 'ok')
|
|
309
|
+
return verified;
|
|
310
|
+
chainKeys.set(current, {
|
|
311
|
+
keyid: current,
|
|
312
|
+
publicKey: childPublic.info.publicKey,
|
|
313
|
+
principal: principalText(grant.principal),
|
|
314
|
+
scope: grant.scope,
|
|
315
|
+
});
|
|
316
|
+
parentOf.set(current, parentId);
|
|
317
|
+
if (effectiveScope === undefined) {
|
|
318
|
+
effectiveScope = grant.scope;
|
|
319
|
+
targetPrincipal = grant.principal;
|
|
320
|
+
}
|
|
321
|
+
current = parentId;
|
|
322
|
+
depth += 1;
|
|
323
|
+
}
|
|
324
|
+
const finalScope = effectiveScope;
|
|
325
|
+
const finalPrincipal = targetPrincipal;
|
|
326
|
+
if (finalScope === undefined || finalPrincipal === undefined) {
|
|
327
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' contains no grant`);
|
|
328
|
+
}
|
|
329
|
+
for (const parsed of parsedRevocations) {
|
|
330
|
+
const record = parsed.record;
|
|
331
|
+
if (!chainKeys.has(record.revokedKey))
|
|
332
|
+
continue;
|
|
333
|
+
if (record.revokedKey === rootKeyId) {
|
|
334
|
+
return invalid(`revocation of the org root '${rootKeyId}' is not permitted`);
|
|
335
|
+
}
|
|
336
|
+
if (!revocationTemporalConsistency(record)) {
|
|
337
|
+
return invalid(`revocation for '${record.revokedKey}' has inconsistent backdated flag for issuedAt ${record.issuedAt} and effectiveFrom ${record.effectiveFrom}`);
|
|
338
|
+
}
|
|
339
|
+
const authority = chainKeys.get(record.revokedBy);
|
|
340
|
+
if (authority === undefined || !isAncestor(record.revokedKey, record.revokedBy, parentOf, rootKeyId)) {
|
|
341
|
+
return invalid(`revocation for '${record.revokedKey}' is signed by non-ancestor '${record.revokedBy}'`);
|
|
342
|
+
}
|
|
343
|
+
if (record.revokedBy !== rootKeyId && !authority.scope.delegation.allowed) {
|
|
344
|
+
return invalid(`revocation for '${record.revokedKey}' is signed by '${record.revokedBy}', whose delegation scope does not permit revocation`);
|
|
345
|
+
}
|
|
346
|
+
if (record.backdated && record.revokedBy !== rootKeyId) {
|
|
347
|
+
return invalid(`backdated revocation for '${record.revokedKey}' must be signed by the org root`);
|
|
348
|
+
}
|
|
349
|
+
const verified = await verifyRevocation(parsed, { keyid: authority.keyid, principal: authority.principal, publicKey: authority.publicKey }, options);
|
|
350
|
+
if (verified.kind !== 'ok')
|
|
351
|
+
return verified;
|
|
352
|
+
if (record.backdated && record.revokedBy === rootKeyId) {
|
|
353
|
+
(options.onBackdatedRevocation ?? (() => undefined))(`accepted backdated revocation for '${record.revokedKey}' effective from ${record.effectiveFrom}`);
|
|
354
|
+
}
|
|
355
|
+
if (record.effectiveFrom <= input.at) {
|
|
356
|
+
return invalid(`enrollment chain for '${input.targetKeyId}' contains revoked key '${record.revokedKey}' effective from ${record.effectiveFrom}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
kind: 'verified',
|
|
361
|
+
keyid: input.targetKeyId,
|
|
362
|
+
principal: finalPrincipal,
|
|
363
|
+
effectiveScope: finalScope,
|
|
364
|
+
depth,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/** Validate a chain first, then apply the requested producer scope demand. */
|
|
368
|
+
export async function validateProducer(input, options = {}) {
|
|
369
|
+
const chain = await validateEnrollmentChain(input, options);
|
|
370
|
+
if (chain.kind !== 'verified')
|
|
371
|
+
return chain;
|
|
372
|
+
const permitted = scopePermits(chain.effectiveScope, input.demand);
|
|
373
|
+
if (!permitted.ok) {
|
|
374
|
+
return invalid(`producer demand is outside the effective scope for '${chain.keyid}': ${permitted.reason}`);
|
|
375
|
+
}
|
|
376
|
+
return chain;
|
|
377
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSSE (Dead Simple Signing Envelope) — cryptographic framing for owenloop's
|
|
3
|
+
* signed records.
|
|
4
|
+
*
|
|
5
|
+
* Implements the DSSEv1 protocol (https://github.com/secure-systems-lab/dsse):
|
|
6
|
+
* a `{ payloadType, payload, signatures }` envelope where each signature covers
|
|
7
|
+
* the Pre-Authentication Encoding (PAE) of payload type + payload bytes. PAE
|
|
8
|
+
* binds the payload type INTO the signed data, so a payload signed under one
|
|
9
|
+
* record class can never verify as another — the record-class wrappers below
|
|
10
|
+
* enforce that on top of the generic verify.
|
|
11
|
+
*
|
|
12
|
+
* Scope is deliberately cryptographic framing ONLY: payloads are opaque bytes
|
|
13
|
+
* here — this module never parses or re-serializes them, and owns none of the
|
|
14
|
+
* grant/revocation/submission/policy-floor/origin JSON schemas (that is the
|
|
15
|
+
* WP-A1/WP-A3/WP-B1 surface). Signing and verification run through the
|
|
16
|
+
* `Signer` interface, so the envelope code is format-neutral: today the SSH
|
|
17
|
+
* signer implements it; a future Sigstore signer can implement the same
|
|
18
|
+
* contract without touching this file.
|
|
19
|
+
*
|
|
20
|
+
* Base64 discipline: `payload`/`sig` fields are STANDARD RFC 4648 on the wire
|
|
21
|
+
* (what `dsseSignEnvelope` emits), but verification accepts standard OR
|
|
22
|
+
* URL-safe input (the protocol requires accepting both). Decoding is STRICT —
|
|
23
|
+
* Node's `Buffer.from(.., 'base64')` is permissive (it drops unknown
|
|
24
|
+
* characters and ignores bad padding), so `decodeBase64` validates the
|
|
25
|
+
* alphabet and padding explicitly and rejects malformed encodings rather than
|
|
26
|
+
* silently truncating them into a different payload.
|
|
27
|
+
*
|
|
28
|
+
* `keyid` discipline: `keyid` is optional and UNAUTHENTICATED in DSSE. This
|
|
29
|
+
* module treats it as a candidate-selection hint only — never as identity or
|
|
30
|
+
* authorization. Absent and empty-string `keyid` are treated identically.
|
|
31
|
+
*/
|
|
32
|
+
import type { DetachedSignature, Signer, VerifiedSignature } from './ssh.ts';
|
|
33
|
+
/**
|
|
34
|
+
* The DSSE protocol version string and PAE prefix. PAE is defined as
|
|
35
|
+
* `"DSSEv1" SP len(payloadType) SP payloadType SP len(payload) SP payload`
|
|
36
|
+
* with ASCII-decimal lengths (no leading zeroes) over the UTF-8 byte length of
|
|
37
|
+
* the type and the raw byte length of the payload.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DSSE_VERSION = "DSSEv1";
|
|
40
|
+
/** One signature entry inside a DSSE envelope. `keyid` is optional and unauthenticated. */
|
|
41
|
+
export interface DsseSignature {
|
|
42
|
+
/** Optional candidate-selection hint. NEVER trusted as identity. */
|
|
43
|
+
keyid?: string;
|
|
44
|
+
/** Base64 (standard or URL-safe) of the signature bytes. */
|
|
45
|
+
sig: string;
|
|
46
|
+
/** Unknown fields are tolerated by the decoder. */
|
|
47
|
+
[field: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A DSSE envelope as it travels on the wire. `payload` and `sig` fields are
|
|
51
|
+
* Base64 text; everything else the decoder needs is typed here, and unknown
|
|
52
|
+
* fields pass through untouched.
|
|
53
|
+
*/
|
|
54
|
+
export interface DsseEnvelope {
|
|
55
|
+
/** Base64 (standard or URL-safe) of the raw payload bytes. */
|
|
56
|
+
payload: string;
|
|
57
|
+
/** The payload's media type, e.g. `application/vnd.owenloop.origin.v1+json`. */
|
|
58
|
+
payloadType: string;
|
|
59
|
+
/** One or more signatures (verification threshold configurable). */
|
|
60
|
+
signatures: DsseSignature[];
|
|
61
|
+
/** Unknown fields are tolerated by the decoder. */
|
|
62
|
+
[field: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A malformed envelope — wrong shape, bad Base64, missing required fields.
|
|
66
|
+
* A cryptographic miss (wrong key / tampered bytes) is also a hard verification
|
|
67
|
+
* failure: `dsseVerifyEnvelope` throws this error instead of returning a result
|
|
68
|
+
* whose empty payload could be mistaken for a verified empty payload.
|
|
69
|
+
*/
|
|
70
|
+
export declare class DsseEnvelopeError extends Error {
|
|
71
|
+
constructor(message: string);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The six launch signed-record payload types. These strings are signed wire
|
|
75
|
+
* identifiers — versioned, stable, and consumed by later trust work, so a
|
|
76
|
+
* change here is a new `v2` constant, never an edit.
|
|
77
|
+
*/
|
|
78
|
+
export declare const PAYLOAD_TYPE_ENROLLMENT_GRANT = "application/vnd.owenloop.enrollment-grant.v1+json";
|
|
79
|
+
export declare const PAYLOAD_TYPE_REVOCATION = "application/vnd.owenloop.revocation.v1+json";
|
|
80
|
+
export declare const PAYLOAD_TYPE_SUBMISSION = "application/vnd.owenloop.submission.v1+json";
|
|
81
|
+
export declare const PAYLOAD_TYPE_POLICY_FLOOR = "application/vnd.owenloop.policy-floor.v1+json";
|
|
82
|
+
export declare const PAYLOAD_TYPE_ORIGIN = "application/vnd.owenloop.origin.v1+json";
|
|
83
|
+
export declare const PAYLOAD_TYPE_PUBLICATION = "application/vnd.owenloop.publication.v1+json";
|
|
84
|
+
/** The DSSE SSHSIG namespace used for all owenloop DSSE envelopes. */
|
|
85
|
+
export declare const DSSE_SSH_NAMESPACE = "owenloop-dsse-v1";
|
|
86
|
+
/**
|
|
87
|
+
* The Pre-Authentication Encoding of one (payloadType, payload) pair:
|
|
88
|
+
* `DSSEv1 SP len(typeBytes) SP typeBytes SP len(payloadBytes) SP payloadBytes`.
|
|
89
|
+
* Lengths are ASCII decimal (no leading zeroes) byte counts; the payload type
|
|
90
|
+
* is measured in UTF-8 bytes. The result is the exact byte string every DSSE
|
|
91
|
+
* signature covers.
|
|
92
|
+
*/
|
|
93
|
+
export declare function preAuthEncode(payloadType: string, payload: Buffer): Buffer;
|
|
94
|
+
/**
|
|
95
|
+
* Decode a STRICT Base64 string (standard `+/` or URL-safe `-_` alphabet,
|
|
96
|
+
* optional `=` padding). Throws `DsseEnvelopeError` on any malformed input:
|
|
97
|
+
* out-of-alphabet characters, wrong length modulo 4, or a trailing single
|
|
98
|
+
* padding character (three encoded characters never encode a whole byte
|
|
99
|
+
* count). Node's permissive decoder is never used on untrusted wire input —
|
|
100
|
+
* it would silently drop illegal characters and accept missing padding,
|
|
101
|
+
* decoding two different strings to the same bytes.
|
|
102
|
+
*/
|
|
103
|
+
export declare function decodeBase64Strict(s: string, opts?: {
|
|
104
|
+
allowEmpty?: boolean;
|
|
105
|
+
}): Buffer;
|
|
106
|
+
/** Encode bytes as STANDARD (RFC 4648 §4) Base64 with padding. */
|
|
107
|
+
export declare function encodeBase64(b: Buffer): string;
|
|
108
|
+
/** Result of a DSSE verification. */
|
|
109
|
+
export interface DsseVerifyResult {
|
|
110
|
+
/** The EXACT verified payload bytes — never re-parsed or re-serialized. */
|
|
111
|
+
payloadBytes: Buffer;
|
|
112
|
+
/** Descriptors of every signature that verified (deduplicated by the signer). */
|
|
113
|
+
signers: VerifiedSignature[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Verify a DSSE envelope with a format-neutral `Signer`.
|
|
117
|
+
*
|
|
118
|
+
* Verification order (fixed):
|
|
119
|
+
* 1. Decode — the envelope object shape, payload Base64, and each `sig`.
|
|
120
|
+
* 2. Reconstruct the PAE from the envelope's EXACT payload type and payload
|
|
121
|
+
* bytes.
|
|
122
|
+
* 3. Verify signatures through the signer; require at least `threshold`
|
|
123
|
+
* DISTINCT verified signers (the signer deduplicates: a trusted key
|
|
124
|
+
* counts once even when duplicate signature entries validate).
|
|
125
|
+
* 4. Require `payloadType === expectedPayloadType` — a valid envelope for
|
|
126
|
+
* another record class is rejected here.
|
|
127
|
+
*
|
|
128
|
+
* Returns the exact verified payload bytes plus the verified signer
|
|
129
|
+
* descriptors. Throws `DsseEnvelopeError` on malformed input; a payload-type
|
|
130
|
+
* mismatch after cryptographic success is also a `DsseEnvelopeError` (the
|
|
131
|
+
* envelope cannot be consumed as this record class). `keyid` plays no role in
|
|
132
|
+
* authorization.
|
|
133
|
+
*/
|
|
134
|
+
export declare function dsseVerifyEnvelope(envelope: unknown, expectedPayloadType: string, signer: Pick<Signer, 'verify'>, opts?: {
|
|
135
|
+
threshold?: number;
|
|
136
|
+
}): Promise<DsseVerifyResult>;
|
|
137
|
+
/**
|
|
138
|
+
* Sign exact payload bytes into a DSSE envelope using `signer`. The payload is
|
|
139
|
+
* authenticated as EXACT bytes — callers own serialization. Returns the
|
|
140
|
+
* envelope (standard Base64 payload/sig) alongside the signer's detached
|
|
141
|
+
* signature. Never parses `payloadBytes`.
|
|
142
|
+
*/
|
|
143
|
+
export declare function dsseSignEnvelope(payloadType: string, payloadBytes: Buffer, signer: Pick<Signer, 'sign'>): Promise<{
|
|
144
|
+
envelope: DsseEnvelope;
|
|
145
|
+
signature: DetachedSignature;
|
|
146
|
+
}>;
|
|
147
|
+
/** The closed set of launch record payload types. */
|
|
148
|
+
export type DsseRecordPayloadType = typeof PAYLOAD_TYPE_ENROLLMENT_GRANT | typeof PAYLOAD_TYPE_REVOCATION | typeof PAYLOAD_TYPE_SUBMISSION | typeof PAYLOAD_TYPE_POLICY_FLOOR | typeof PAYLOAD_TYPE_ORIGIN | typeof PAYLOAD_TYPE_PUBLICATION;
|
|
149
|
+
/** Runtime copy of the closed record-type set used at dynamic boundaries. */
|
|
150
|
+
export declare const DSSE_RECORD_PAYLOAD_TYPES: readonly ["application/vnd.owenloop.enrollment-grant.v1+json", "application/vnd.owenloop.revocation.v1+json", "application/vnd.owenloop.submission.v1+json", "application/vnd.owenloop.policy-floor.v1+json", "application/vnd.owenloop.origin.v1+json", "application/vnd.owenloop.publication.v1+json"];
|
|
151
|
+
/** Check a dynamic value against the six supported record payload types. */
|
|
152
|
+
export declare function isDsseRecordPayloadType(value: unknown): value is DsseRecordPayloadType;
|
|
153
|
+
/** Generic wrapper retained for callers that already carry a closed-union type. */
|
|
154
|
+
export declare function dsseSignRecord(payloadType: DsseRecordPayloadType, payloadBytes: Buffer, signer: Pick<Signer, 'sign'>): Promise<{
|
|
155
|
+
envelope: DsseEnvelope;
|
|
156
|
+
signature: DetachedSignature;
|
|
157
|
+
}>;
|
|
158
|
+
/** Generic closed-union verification wrapper. */
|
|
159
|
+
export declare function dsseVerifyRecord(envelope: unknown, expectedPayloadType: DsseRecordPayloadType, signer: Pick<Signer, 'verify'>, opts?: {
|
|
160
|
+
threshold?: number;
|
|
161
|
+
}): Promise<DsseVerifyResult>;
|
|
162
|
+
/** Fixed enrollment-grant record wrapper. */
|
|
163
|
+
export declare const dsseSignEnrollmentGrant: (payloadBytes: Buffer, signer: Pick<Signer, "sign">) => Promise<{
|
|
164
|
+
envelope: DsseEnvelope;
|
|
165
|
+
signature: DetachedSignature;
|
|
166
|
+
}>;
|
|
167
|
+
export declare const dsseVerifyEnrollmentGrant: (envelope: unknown, signer: Pick<Signer, "verify">, opts?: {
|
|
168
|
+
threshold?: number;
|
|
169
|
+
}) => Promise<DsseVerifyResult>;
|
|
170
|
+
/** Fixed revocation record wrapper. */
|
|
171
|
+
export declare const dsseSignRevocation: (payloadBytes: Buffer, signer: Pick<Signer, "sign">) => Promise<{
|
|
172
|
+
envelope: DsseEnvelope;
|
|
173
|
+
signature: DetachedSignature;
|
|
174
|
+
}>;
|
|
175
|
+
export declare const dsseVerifyRevocation: (envelope: unknown, signer: Pick<Signer, "verify">, opts?: {
|
|
176
|
+
threshold?: number;
|
|
177
|
+
}) => Promise<DsseVerifyResult>;
|
|
178
|
+
/** Fixed submission record wrapper. */
|
|
179
|
+
export declare const dsseSignSubmission: (payloadBytes: Buffer, signer: Pick<Signer, "sign">) => Promise<{
|
|
180
|
+
envelope: DsseEnvelope;
|
|
181
|
+
signature: DetachedSignature;
|
|
182
|
+
}>;
|
|
183
|
+
export declare const dsseVerifySubmission: (envelope: unknown, signer: Pick<Signer, "verify">, opts?: {
|
|
184
|
+
threshold?: number;
|
|
185
|
+
}) => Promise<DsseVerifyResult>;
|
|
186
|
+
/** Fixed policy-floor record wrapper. */
|
|
187
|
+
export declare const dsseSignPolicyFloor: (payloadBytes: Buffer, signer: Pick<Signer, "sign">) => Promise<{
|
|
188
|
+
envelope: DsseEnvelope;
|
|
189
|
+
signature: DetachedSignature;
|
|
190
|
+
}>;
|
|
191
|
+
export declare const dsseVerifyPolicyFloor: (envelope: unknown, signer: Pick<Signer, "verify">, opts?: {
|
|
192
|
+
threshold?: number;
|
|
193
|
+
}) => Promise<DsseVerifyResult>;
|
|
194
|
+
/** Fixed origin record wrapper. */
|
|
195
|
+
export declare const dsseSignOrigin: (payloadBytes: Buffer, signer: Pick<Signer, "sign">) => Promise<{
|
|
196
|
+
envelope: DsseEnvelope;
|
|
197
|
+
signature: DetachedSignature;
|
|
198
|
+
}>;
|
|
199
|
+
export declare const dsseVerifyOrigin: (envelope: unknown, signer: Pick<Signer, "verify">, opts?: {
|
|
200
|
+
threshold?: number;
|
|
201
|
+
}) => Promise<DsseVerifyResult>;
|
|
202
|
+
/** Fixed publication record wrapper. */
|
|
203
|
+
export declare const dsseSignPublication: (payloadBytes: Buffer, signer: Pick<Signer, "sign">) => Promise<{
|
|
204
|
+
envelope: DsseEnvelope;
|
|
205
|
+
signature: DetachedSignature;
|
|
206
|
+
}>;
|
|
207
|
+
export declare const dsseVerifyPublication: (envelope: unknown, signer: Pick<Signer, "verify">, opts?: {
|
|
208
|
+
threshold?: number;
|
|
209
|
+
}) => Promise<DsseVerifyResult>;
|