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.
Files changed (229) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +144 -35
  3. package/bin/owenloop.mjs +49 -1
  4. package/dist/packages/work/src/agent/brief.d.ts +29 -4
  5. package/dist/packages/work/src/agent/brief.js +49 -4
  6. package/dist/packages/work/src/agent/capability-model.d.ts +123 -0
  7. package/dist/packages/work/src/agent/capability-model.js +148 -0
  8. package/dist/packages/work/src/agent/loop.d.ts +56 -7
  9. package/dist/packages/work/src/agent/loop.js +166 -9
  10. package/dist/packages/work/src/bundle/cache.d.ts +7 -5
  11. package/dist/packages/work/src/bundle/cache.js +20 -6
  12. package/dist/packages/work/src/bundle/fetch.d.ts +7 -5
  13. package/dist/packages/work/src/bundle/fetch.js +27 -7
  14. package/dist/packages/work/src/bundle/types.d.ts +8 -4
  15. package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
  16. package/dist/packages/work/src/consumed-verifier.js +205 -0
  17. package/dist/packages/work/src/exec/instructions.d.ts +99 -0
  18. package/dist/packages/work/src/exec/instructions.js +323 -0
  19. package/dist/packages/work/src/exec/loop.d.ts +29 -1
  20. package/dist/packages/work/src/exec/loop.js +313 -35
  21. package/dist/packages/work/src/exec/payload.d.ts +29 -0
  22. package/dist/packages/work/src/exec/payload.js +54 -0
  23. package/dist/packages/work/src/exec/receipt.d.ts +9 -6
  24. package/dist/packages/work/src/exec/receipt.js +12 -1
  25. package/dist/packages/work/src/exec/runner.d.ts +7 -1
  26. package/dist/packages/work/src/exec/runner.js +84 -3
  27. package/dist/packages/work/src/harness/child-env.js +7 -0
  28. package/dist/packages/work/src/harness/claude.d.ts +20 -8
  29. package/dist/packages/work/src/harness/claude.js +260 -58
  30. package/dist/packages/work/src/harness/codex.d.ts +5 -4
  31. package/dist/packages/work/src/harness/codex.js +169 -41
  32. package/dist/packages/work/src/harness/contract.d.ts +36 -11
  33. package/dist/packages/work/src/harness/fake.js +1 -0
  34. package/dist/packages/work/src/harness/jsonrpc-stdio.js +7 -0
  35. package/dist/packages/work/src/harness/permissions.d.ts +16 -3
  36. package/dist/packages/work/src/harness/permissions.js +102 -13
  37. package/dist/packages/work/src/harness/session-store.d.ts +30 -10
  38. package/dist/packages/work/src/harness/session-store.js +317 -89
  39. package/dist/packages/work/src/hold/mcp.d.ts +25 -5
  40. package/dist/packages/work/src/hold/mcp.js +134 -12
  41. package/dist/packages/work/src/hub/client.d.ts +8 -1
  42. package/dist/packages/work/src/hub/client.js +15 -1
  43. package/dist/packages/work/src/hub/types.d.ts +137 -33
  44. package/dist/packages/work/src/hub/types.js +8 -10
  45. package/dist/packages/work/src/mcp/server.js +1 -1
  46. package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
  47. package/dist/packages/work/src/owenloop-bin.js +18 -0
  48. package/dist/packages/work/src/roles/agent-run.d.ts +12 -6
  49. package/dist/packages/work/src/roles/agent-run.js +115 -34
  50. package/dist/packages/work/src/roles/exec.d.ts +8 -0
  51. package/dist/packages/work/src/roles/exec.js +27 -2
  52. package/dist/packages/work/src/roles/hold.d.ts +6 -0
  53. package/dist/packages/work/src/roles/hold.js +83 -13
  54. package/dist/packages/work/src/roles/lint.d.ts +3 -4
  55. package/dist/packages/work/src/roles/lint.js +41 -7
  56. package/dist/packages/work/src/roles/settings.js +19 -2
  57. package/dist/packages/work/src/roles/shift.d.ts +1 -0
  58. package/dist/packages/work/src/roles/shift.js +36 -2
  59. package/dist/packages/work/src/settings/settings.d.ts +70 -1
  60. package/dist/packages/work/src/settings/settings.js +90 -4
  61. package/dist/packages/work/src/shift/logretention.d.ts +253 -0
  62. package/dist/packages/work/src/shift/logretention.js +407 -0
  63. package/dist/packages/work/src/shift/logsink.d.ts +14 -0
  64. package/dist/packages/work/src/shift/logsink.js +98 -0
  65. package/dist/packages/work/src/shift/loop.d.ts +32 -4
  66. package/dist/packages/work/src/shift/loop.js +687 -166
  67. package/dist/packages/work/src/shift/protocol.d.ts +128 -1
  68. package/dist/packages/work/src/shift/protocol.js +14 -0
  69. package/dist/packages/work/src/shift/runtime.d.ts +16 -0
  70. package/dist/packages/work/src/shift/runtime.js +291 -5
  71. package/dist/packages/work/src/shift/server.d.ts +13 -0
  72. package/dist/packages/work/src/shift/server.js +61 -36
  73. package/dist/packages/work/src/shift/spawn.d.ts +115 -19
  74. package/dist/packages/work/src/shift/spawn.js +234 -30
  75. package/dist/packages/work/src/shift/state.d.ts +76 -49
  76. package/dist/packages/work/src/shift/state.js +350 -103
  77. package/dist/packages/work/src/shift/truncate.d.ts +35 -0
  78. package/dist/packages/work/src/shift/truncate.js +73 -0
  79. package/dist/packages/work/src/submit-proof.d.ts +61 -0
  80. package/dist/packages/work/src/submit-proof.js +119 -0
  81. package/dist/packages/work/src/submit-value.d.ts +48 -0
  82. package/dist/packages/work/src/submit-value.js +118 -0
  83. package/dist/packages/work/src/usage.d.ts +1 -1
  84. package/dist/packages/work/src/usage.js +11 -0
  85. package/dist/src/add.d.ts +64 -259
  86. package/dist/src/add.js +81 -615
  87. package/dist/src/archive.d.ts +97 -0
  88. package/dist/src/archive.js +591 -0
  89. package/dist/src/bundle/index.d.ts +64 -0
  90. package/dist/src/bundle/index.js +508 -0
  91. package/dist/src/bundle/manifest.d.ts +50 -0
  92. package/dist/src/bundle/manifest.js +435 -0
  93. package/dist/src/bundle/runtime.d.ts +26 -0
  94. package/dist/src/bundle/runtime.js +64 -0
  95. package/dist/src/bundle/tar.d.ts +62 -0
  96. package/dist/src/bundle/tar.js +238 -0
  97. package/dist/src/bundle/types.d.ts +105 -0
  98. package/dist/src/bundle/types.js +21 -0
  99. package/dist/src/capabilities.d.ts +93 -0
  100. package/dist/src/capabilities.js +101 -0
  101. package/dist/src/cli.d.ts +90 -20
  102. package/dist/src/cli.js +2421 -374
  103. package/dist/src/credentials.d.ts +4 -3
  104. package/dist/src/credentials.js +21 -19
  105. package/dist/src/crypto/allowed-signers.d.ts +68 -0
  106. package/dist/src/crypto/allowed-signers.js +307 -0
  107. package/dist/src/crypto/canonical.d.ts +8 -0
  108. package/dist/src/crypto/canonical.js +92 -0
  109. package/dist/src/crypto/chain.d.ts +65 -0
  110. package/dist/src/crypto/chain.js +377 -0
  111. package/dist/src/crypto/dsse.d.ts +209 -0
  112. package/dist/src/crypto/dsse.js +282 -0
  113. package/dist/src/crypto/enrollment.d.ts +78 -0
  114. package/dist/src/crypto/enrollment.js +186 -0
  115. package/dist/src/crypto/index.d.ts +48 -0
  116. package/dist/src/crypto/index.js +44 -0
  117. package/dist/src/crypto/keys.d.ts +258 -0
  118. package/dist/src/crypto/keys.js +908 -0
  119. package/dist/src/crypto/org-root.d.ts +33 -0
  120. package/dist/src/crypto/org-root.js +78 -0
  121. package/dist/src/crypto/origin-rules.d.ts +56 -0
  122. package/dist/src/crypto/origin-rules.js +143 -0
  123. package/dist/src/crypto/policy-floor.d.ts +98 -0
  124. package/dist/src/crypto/policy-floor.js +353 -0
  125. package/dist/src/crypto/records.d.ts +319 -0
  126. package/dist/src/crypto/records.js +168 -0
  127. package/dist/src/crypto/scope.d.ts +49 -0
  128. package/dist/src/crypto/scope.js +83 -0
  129. package/dist/src/crypto/ssh.d.ts +171 -0
  130. package/dist/src/crypto/ssh.js +396 -0
  131. package/dist/src/crypto/submission.d.ts +33 -0
  132. package/dist/src/crypto/submission.js +47 -0
  133. package/dist/src/crypto/trust-roots.d.ts +29 -0
  134. package/dist/src/crypto/trust-roots.js +39 -0
  135. package/dist/src/crypto/verify-consumed.d.ts +67 -0
  136. package/dist/src/crypto/verify-consumed.js +259 -0
  137. package/dist/src/crypto/verify-origin.d.ts +50 -0
  138. package/dist/src/crypto/verify-origin.js +151 -0
  139. package/dist/src/crypto/verify-publication.d.ts +60 -0
  140. package/dist/src/crypto/verify-publication.js +150 -0
  141. package/dist/src/defs.d.ts +24 -1
  142. package/dist/src/defs.js +335 -27
  143. package/dist/src/engine.d.ts +211 -6
  144. package/dist/src/engine.js +459 -59
  145. package/dist/src/factory.d.ts +16 -0
  146. package/dist/src/factory.js +16 -4
  147. package/dist/src/global-config.d.ts +59 -0
  148. package/dist/src/global-config.js +84 -0
  149. package/dist/src/hub.d.ts +102 -32
  150. package/dist/src/hub.js +147 -58
  151. package/dist/src/index.d.ts +19 -2
  152. package/dist/src/index.js +23 -2
  153. package/dist/src/install.d.ts +538 -0
  154. package/dist/src/install.js +1981 -0
  155. package/dist/src/lock.d.ts +15 -57
  156. package/dist/src/lock.js +251 -143
  157. package/dist/src/mcp/serve.d.ts +46 -22
  158. package/dist/src/mcp/serve.js +174 -44
  159. package/dist/src/mcp/server.js +12 -1
  160. package/dist/src/model.d.ts +51 -0
  161. package/dist/src/model.js +157 -1
  162. package/dist/src/order-resolver.d.ts +184 -0
  163. package/dist/src/order-resolver.js +252 -0
  164. package/dist/src/package-version.d.ts +10 -0
  165. package/dist/src/package-version.js +42 -0
  166. package/dist/src/paths.d.ts +14 -1
  167. package/dist/src/paths.js +18 -0
  168. package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
  169. package/dist/src/schemas/index.d.ts +1433 -0
  170. package/dist/src/schemas/index.js +31 -0
  171. package/dist/src/schemas/order.v1.schema.json +120 -0
  172. package/dist/src/schemas/origin.v1.schema.json +68 -0
  173. package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
  174. package/dist/src/schemas/publication.v1.schema.json +31 -0
  175. package/dist/src/schemas/revocation.v1.schema.json +39 -0
  176. package/dist/src/schemas/submission.v1.schema.json +61 -0
  177. package/dist/src/store/def-source.d.ts +52 -0
  178. package/dist/src/store/def-source.js +335 -0
  179. package/dist/src/store/index-file.d.ts +69 -0
  180. package/dist/src/store/index-file.js +151 -0
  181. package/dist/src/store/index.d.ts +27 -0
  182. package/dist/src/store/index.js +22 -0
  183. package/dist/src/store/ingestor.d.ts +43 -0
  184. package/dist/src/store/ingestor.js +211 -0
  185. package/dist/src/store/install.d.ts +228 -0
  186. package/dist/src/store/install.js +555 -0
  187. package/dist/src/store/instruction-source.d.ts +49 -0
  188. package/dist/src/store/instruction-source.js +298 -0
  189. package/dist/src/store/origin-evidence.d.ts +21 -0
  190. package/dist/src/store/origin-evidence.js +66 -0
  191. package/dist/src/store/pre-commit-verifier.d.ts +68 -0
  192. package/dist/src/store/pre-commit-verifier.js +418 -0
  193. package/dist/src/store/resolve.d.ts +138 -0
  194. package/dist/src/store/resolve.js +363 -0
  195. package/dist/src/store/types.d.ts +288 -0
  196. package/dist/src/store/types.js +356 -0
  197. package/dist/src/store.d.ts +33 -1
  198. package/dist/src/store.js +57 -4
  199. package/dist/src/types.d.ts +146 -12
  200. package/dist/src/untar.d.ts +8 -23
  201. package/dist/src/untar.js +10 -136
  202. package/docs/agent-runner.md +86 -0
  203. package/docs/authoring.md +64 -6
  204. package/docs/bundles.md +350 -0
  205. package/docs/cli.md +1298 -106
  206. package/docs/crypto.md +832 -0
  207. package/docs/design.md +342 -20
  208. package/docs/embedding.md +132 -25
  209. package/docs/shift-logs.md +642 -0
  210. package/docs/wire-contracts.md +395 -0
  211. package/package.json +6 -1
  212. package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
  213. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
  214. package/plugins/claude-code/plugin/.mcp.json +14 -0
  215. package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
  216. package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
  217. package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
  218. package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
  219. package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
  220. package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
  221. package/plugins/codex/.agents/plugins/marketplace.json +21 -0
  222. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
  223. package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
  224. package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
  225. package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
  226. package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
  227. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
  228. package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
  229. package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
@@ -0,0 +1,282 @@
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
+ /**
33
+ * The DSSE protocol version string and PAE prefix. PAE is defined as
34
+ * `"DSSEv1" SP len(payloadType) SP payloadType SP len(payload) SP payload`
35
+ * with ASCII-decimal lengths (no leading zeroes) over the UTF-8 byte length of
36
+ * the type and the raw byte length of the payload.
37
+ */
38
+ export const DSSE_VERSION = 'DSSEv1';
39
+ /**
40
+ * A malformed envelope — wrong shape, bad Base64, missing required fields.
41
+ * A cryptographic miss (wrong key / tampered bytes) is also a hard verification
42
+ * failure: `dsseVerifyEnvelope` throws this error instead of returning a result
43
+ * whose empty payload could be mistaken for a verified empty payload.
44
+ */
45
+ export class DsseEnvelopeError extends Error {
46
+ constructor(message) {
47
+ super(message);
48
+ this.name = 'DsseEnvelopeError';
49
+ }
50
+ }
51
+ /**
52
+ * The six launch signed-record payload types. These strings are signed wire
53
+ * identifiers — versioned, stable, and consumed by later trust work, so a
54
+ * change here is a new `v2` constant, never an edit.
55
+ */
56
+ export const PAYLOAD_TYPE_ENROLLMENT_GRANT = 'application/vnd.owenloop.enrollment-grant.v1+json';
57
+ export const PAYLOAD_TYPE_REVOCATION = 'application/vnd.owenloop.revocation.v1+json';
58
+ export const PAYLOAD_TYPE_SUBMISSION = 'application/vnd.owenloop.submission.v1+json';
59
+ export const PAYLOAD_TYPE_POLICY_FLOOR = 'application/vnd.owenloop.policy-floor.v1+json';
60
+ export const PAYLOAD_TYPE_ORIGIN = 'application/vnd.owenloop.origin.v1+json';
61
+ export const PAYLOAD_TYPE_PUBLICATION = 'application/vnd.owenloop.publication.v1+json';
62
+ /** The DSSE SSHSIG namespace used for all owenloop DSSE envelopes. */
63
+ export const DSSE_SSH_NAMESPACE = 'owenloop-dsse-v1';
64
+ /**
65
+ * The Pre-Authentication Encoding of one (payloadType, payload) pair:
66
+ * `DSSEv1 SP len(typeBytes) SP typeBytes SP len(payloadBytes) SP payloadBytes`.
67
+ * Lengths are ASCII decimal (no leading zeroes) byte counts; the payload type
68
+ * is measured in UTF-8 bytes. The result is the exact byte string every DSSE
69
+ * signature covers.
70
+ */
71
+ export function preAuthEncode(payloadType, payload) {
72
+ const typeBytes = Buffer.from(payloadType, 'utf8');
73
+ const head = `${DSSE_VERSION} ${typeBytes.length} `;
74
+ const mid = Buffer.concat([Buffer.from(head, 'utf8'), typeBytes]);
75
+ return Buffer.concat([mid, Buffer.from(` ${payload.length} `, 'utf8'), payload]);
76
+ }
77
+ /** The strict Base64 alphabet check shared by both alphabets. */
78
+ function base64CharsOk(s, alphabet, allowEmpty) {
79
+ return (allowEmpty || s.length > 0) && alphabet.test(s);
80
+ }
81
+ /**
82
+ * Decode a STRICT Base64 string (standard `+/` or URL-safe `-_` alphabet,
83
+ * optional `=` padding). Throws `DsseEnvelopeError` on any malformed input:
84
+ * out-of-alphabet characters, wrong length modulo 4, or a trailing single
85
+ * padding character (three encoded characters never encode a whole byte
86
+ * count). Node's permissive decoder is never used on untrusted wire input —
87
+ * it would silently drop illegal characters and accept missing padding,
88
+ * decoding two different strings to the same bytes.
89
+ */
90
+ export function decodeBase64Strict(s, opts) {
91
+ if (typeof s !== 'string')
92
+ throw new DsseEnvelopeError('base64 field is not a string');
93
+ const allowEmpty = opts?.allowEmpty ?? false;
94
+ const std = /^[A-Za-z0-9+/]*$/;
95
+ const url = /^[A-Za-z0-9_-]*$/;
96
+ const body = s.replace(/=+$/, '');
97
+ const hadPadding = s.length > body.length;
98
+ if (s.length === 0 && !allowEmpty)
99
+ throw new DsseEnvelopeError('base64 field is empty');
100
+ if (/[\r\n\t ]/.test(s))
101
+ throw new DsseEnvelopeError('malformed base64: whitespace is not allowed');
102
+ if (hadPadding) {
103
+ // With explicit padding the total must be a multiple of 4 and the padding
104
+ // at most two characters.
105
+ if (s.length % 4 !== 0 || s.length - body.length > 2) {
106
+ throw new DsseEnvelopeError('malformed base64: bad padding');
107
+ }
108
+ if (!base64CharsOk(body, std, allowEmpty) && !base64CharsOk(body, url, allowEmpty)) {
109
+ throw new DsseEnvelopeError('malformed base64: character outside both alphabets');
110
+ }
111
+ }
112
+ else {
113
+ if (!base64CharsOk(s, std, allowEmpty) && !base64CharsOk(s, url, allowEmpty)) {
114
+ throw new DsseEnvelopeError('malformed base64: character outside both alphabets');
115
+ }
116
+ const rem = s.length % 4;
117
+ if (rem === 1)
118
+ throw new DsseEnvelopeError('malformed base64: length % 4 == 1');
119
+ }
120
+ // Re-encode through the standard alphabet for the decoder (URL-safe chars
121
+ // mapped to standard; padding restored).
122
+ const standard = body.replace(/-/g, '+').replace(/_/g, '/');
123
+ const pad = standard.length % 4 === 0 ? '' : '='.repeat(4 - (standard.length % 4));
124
+ return Buffer.from(standard + pad, 'base64');
125
+ }
126
+ /** Encode bytes as STANDARD (RFC 4648 §4) Base64 with padding. */
127
+ export function encodeBase64(b) {
128
+ return b.toString('base64');
129
+ }
130
+ /**
131
+ * Verify one signature entry's bytes against the signer. Returns the verified
132
+ * descriptor or `null`. Malformed Base64 in `sig` is a hard envelope error
133
+ * (the envelope itself is broken), not a miss.
134
+ */
135
+ function decodeSigEntry(entry, index) {
136
+ if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
137
+ throw new DsseEnvelopeError(`signatures[${index}]: entry is not an object`);
138
+ }
139
+ const sigEntry = entry;
140
+ if (typeof sigEntry.sig !== 'string' || sigEntry.sig === '') {
141
+ throw new DsseEnvelopeError(`signatures[${index}]: missing 'sig' field`);
142
+ }
143
+ try {
144
+ return decodeBase64Strict(sigEntry.sig);
145
+ }
146
+ catch (e) {
147
+ throw new DsseEnvelopeError(`signatures[${index}]: ${e.message}`);
148
+ }
149
+ }
150
+ /**
151
+ * Verify a DSSE envelope with a format-neutral `Signer`.
152
+ *
153
+ * Verification order (fixed):
154
+ * 1. Decode — the envelope object shape, payload Base64, and each `sig`.
155
+ * 2. Reconstruct the PAE from the envelope's EXACT payload type and payload
156
+ * bytes.
157
+ * 3. Verify signatures through the signer; require at least `threshold`
158
+ * DISTINCT verified signers (the signer deduplicates: a trusted key
159
+ * counts once even when duplicate signature entries validate).
160
+ * 4. Require `payloadType === expectedPayloadType` — a valid envelope for
161
+ * another record class is rejected here.
162
+ *
163
+ * Returns the exact verified payload bytes plus the verified signer
164
+ * descriptors. Throws `DsseEnvelopeError` on malformed input; a payload-type
165
+ * mismatch after cryptographic success is also a `DsseEnvelopeError` (the
166
+ * envelope cannot be consumed as this record class). `keyid` plays no role in
167
+ * authorization.
168
+ */
169
+ export async function dsseVerifyEnvelope(envelope, expectedPayloadType, signer, opts) {
170
+ const threshold = opts?.threshold ?? 1;
171
+ if (!Number.isInteger(threshold) || threshold < 1) {
172
+ throw new DsseEnvelopeError('threshold must be an integer >= 1');
173
+ }
174
+ if (typeof envelope !== 'object' || envelope === null || Array.isArray(envelope)) {
175
+ throw new DsseEnvelopeError('envelope is not an object');
176
+ }
177
+ const env = envelope;
178
+ if (typeof env.payload !== 'string')
179
+ throw new DsseEnvelopeError("missing 'payload' field");
180
+ if (typeof env.payloadType !== 'string' || env.payloadType === '') {
181
+ throw new DsseEnvelopeError("missing 'payloadType' field");
182
+ }
183
+ if (!Array.isArray(env.signatures) || env.signatures.length === 0) {
184
+ throw new DsseEnvelopeError('envelope must carry at least one signature');
185
+ }
186
+ const payloadBytes = (() => {
187
+ try {
188
+ return decodeBase64Strict(env.payload, { allowEmpty: true });
189
+ }
190
+ catch (e) {
191
+ throw new DsseEnvelopeError(`payload: ${e.message}`);
192
+ }
193
+ })();
194
+ const pae = preAuthEncode(env.payloadType, payloadBytes);
195
+ const sigBytes = env.signatures.map((entry, i) => decodeSigEntry(entry, i));
196
+ const verified = [];
197
+ const seen = new Set();
198
+ for (const sig of sigBytes) {
199
+ const res = await signer.verify(pae, sig);
200
+ if (res === null)
201
+ continue;
202
+ // A trusted key counts at most once, even when duplicate entries validate.
203
+ if (seen.has(res.keyid))
204
+ continue;
205
+ seen.add(res.keyid);
206
+ verified.push(res);
207
+ }
208
+ if (verified.length < threshold) {
209
+ throw new DsseEnvelopeError(`DSSE verification failed: ${verified.length} distinct trusted signer(s), threshold is ${threshold}`);
210
+ }
211
+ if (env.payloadType !== expectedPayloadType) {
212
+ throw new DsseEnvelopeError(`payload type mismatch: envelope carries '${env.payloadType}', caller expects '${expectedPayloadType}'`);
213
+ }
214
+ return { payloadBytes, signers: verified };
215
+ }
216
+ /**
217
+ * Sign exact payload bytes into a DSSE envelope using `signer`. The payload is
218
+ * authenticated as EXACT bytes — callers own serialization. Returns the
219
+ * envelope (standard Base64 payload/sig) alongside the signer's detached
220
+ * signature. Never parses `payloadBytes`.
221
+ */
222
+ export async function dsseSignEnvelope(payloadType, payloadBytes, signer) {
223
+ const pae = preAuthEncode(payloadType, payloadBytes);
224
+ const signature = await signer.sign(pae);
225
+ const envelope = {
226
+ payload: encodeBase64(payloadBytes),
227
+ payloadType,
228
+ signatures: [
229
+ {
230
+ ...(signature.keyid !== '' ? { keyid: signature.keyid } : {}),
231
+ sig: encodeBase64(signature.sig),
232
+ },
233
+ ],
234
+ };
235
+ return { envelope, signature };
236
+ }
237
+ /** Runtime copy of the closed record-type set used at dynamic boundaries. */
238
+ export const DSSE_RECORD_PAYLOAD_TYPES = Object.freeze([
239
+ PAYLOAD_TYPE_ENROLLMENT_GRANT,
240
+ PAYLOAD_TYPE_REVOCATION,
241
+ PAYLOAD_TYPE_SUBMISSION,
242
+ PAYLOAD_TYPE_POLICY_FLOOR,
243
+ PAYLOAD_TYPE_ORIGIN,
244
+ PAYLOAD_TYPE_PUBLICATION,
245
+ ]);
246
+ /** Check a dynamic value against the six supported record payload types. */
247
+ export function isDsseRecordPayloadType(value) {
248
+ return typeof value === 'string' && DSSE_RECORD_PAYLOAD_TYPES.includes(value);
249
+ }
250
+ function assertDsseRecordPayloadType(value) {
251
+ if (!isDsseRecordPayloadType(value)) {
252
+ throw new DsseEnvelopeError('unsupported DSSE record payload type');
253
+ }
254
+ }
255
+ /** Generic wrapper retained for callers that already carry a closed-union type. */
256
+ export async function dsseSignRecord(payloadType, payloadBytes, signer) {
257
+ assertDsseRecordPayloadType(payloadType);
258
+ return dsseSignEnvelope(payloadType, payloadBytes, signer);
259
+ }
260
+ /** Generic closed-union verification wrapper. */
261
+ export async function dsseVerifyRecord(envelope, expectedPayloadType, signer, opts) {
262
+ assertDsseRecordPayloadType(expectedPayloadType);
263
+ return dsseVerifyEnvelope(envelope, expectedPayloadType, signer, opts);
264
+ }
265
+ /** Fixed enrollment-grant record wrapper. */
266
+ export const dsseSignEnrollmentGrant = (payloadBytes, signer) => dsseSignEnvelope(PAYLOAD_TYPE_ENROLLMENT_GRANT, payloadBytes, signer);
267
+ export const dsseVerifyEnrollmentGrant = (envelope, signer, opts) => dsseVerifyEnvelope(envelope, PAYLOAD_TYPE_ENROLLMENT_GRANT, signer, opts);
268
+ /** Fixed revocation record wrapper. */
269
+ export const dsseSignRevocation = (payloadBytes, signer) => dsseSignEnvelope(PAYLOAD_TYPE_REVOCATION, payloadBytes, signer);
270
+ export const dsseVerifyRevocation = (envelope, signer, opts) => dsseVerifyEnvelope(envelope, PAYLOAD_TYPE_REVOCATION, signer, opts);
271
+ /** Fixed submission record wrapper. */
272
+ export const dsseSignSubmission = (payloadBytes, signer) => dsseSignEnvelope(PAYLOAD_TYPE_SUBMISSION, payloadBytes, signer);
273
+ export const dsseVerifySubmission = (envelope, signer, opts) => dsseVerifyEnvelope(envelope, PAYLOAD_TYPE_SUBMISSION, signer, opts);
274
+ /** Fixed policy-floor record wrapper. */
275
+ export const dsseSignPolicyFloor = (payloadBytes, signer) => dsseSignEnvelope(PAYLOAD_TYPE_POLICY_FLOOR, payloadBytes, signer);
276
+ export const dsseVerifyPolicyFloor = (envelope, signer, opts) => dsseVerifyEnvelope(envelope, PAYLOAD_TYPE_POLICY_FLOOR, signer, opts);
277
+ /** Fixed origin record wrapper. */
278
+ export const dsseSignOrigin = (payloadBytes, signer) => dsseSignEnvelope(PAYLOAD_TYPE_ORIGIN, payloadBytes, signer);
279
+ export const dsseVerifyOrigin = (envelope, signer, opts) => dsseVerifyEnvelope(envelope, PAYLOAD_TYPE_ORIGIN, signer, opts);
280
+ /** Fixed publication record wrapper. */
281
+ export const dsseSignPublication = (payloadBytes, signer) => dsseSignEnvelope(PAYLOAD_TYPE_PUBLICATION, payloadBytes, signer);
282
+ export const dsseVerifyPublication = (envelope, signer, opts) => dsseVerifyEnvelope(envelope, PAYLOAD_TYPE_PUBLICATION, signer, opts);
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Enrollment-grant construction and client-side roster verification.
3
+ *
4
+ * D1 deliberately stops at a narrow chain-validation seam. A signed grant is
5
+ * unforgeable by a hub that only relays records, but a signature alone does not
6
+ * prove that the grantor is enrolled in the organization. Until a
7
+ * `EnrollmentChainValidator` is installed, verification therefore refuses with
8
+ * `unverifiable` rather than accepting the record. The explicit early return in
9
+ * `verifyRosterEntry` is the §8.1 fail-closed gate.
10
+ */
11
+ import type { Signer } from './ssh.ts';
12
+ import type { EnrollmentGrantRecord, GrantScope, PrincipalReference } from './records.ts';
13
+ import type { PublicKeyDescriptor } from './keys.ts';
14
+ /** The narrow D1/D4 boundary for proving that one grant reaches the org root. */
15
+ export interface EnrollmentChainValidator {
16
+ /** Resolve whether `grant` chains to the org root. */
17
+ validate(grant: EnrollmentGrantRecord, verifiedSignerKeyId: string): Promise<{
18
+ ok: true;
19
+ } | {
20
+ ok: false;
21
+ reason: string;
22
+ }>;
23
+ }
24
+ /** The least privilege scope carried by a self-vouched machine grant. */
25
+ export declare const DEFAULT_MACHINE_SCOPE: GrantScope;
26
+ /** Inputs for the pure enrollment-grant builder. */
27
+ export interface BuildEnrollmentGrantArgs {
28
+ newKey: PublicKeyDescriptor;
29
+ principal: PrincipalReference;
30
+ grantedBy: string;
31
+ validFrom: number;
32
+ scope: GrantScope;
33
+ }
34
+ /** Build one complete, immutable enrollment grant without performing I/O. */
35
+ export declare function buildEnrollmentGrant(args: BuildEnrollmentGrantArgs): EnrollmentGrantRecord;
36
+ /** The four states a client can distinguish when reading a relayed roster. */
37
+ export type RosterVerdict = {
38
+ kind: 'enrolled';
39
+ keyid: string;
40
+ principal: string;
41
+ } | {
42
+ kind: 'unenrolled';
43
+ } | {
44
+ kind: 'unverifiable';
45
+ reason: string;
46
+ } | {
47
+ kind: 'invalid';
48
+ reason: string;
49
+ };
50
+ /** One relayed DSSE envelope plus the local allowed_signers text. */
51
+ export interface VerifyRosterEntryInput {
52
+ /** A decoded DSSE envelope, or JSON/UTF-8 bytes carrying one. */
53
+ envelope?: unknown;
54
+ /** Alias for callers that already have a sidecar-like byte buffer. */
55
+ dsseBytes?: Uint8Array;
56
+ /** Resolved local `allowed_signers` text. */
57
+ allowedSignersText?: string;
58
+ }
59
+ /** Test and signer-tool seams for roster verification. */
60
+ export interface VerifyRosterEntryOptions {
61
+ /** D4's chain-validation seam. Omission is deliberately fail-closed. */
62
+ chainValidator?: EnrollmentChainValidator;
63
+ /** Inject a signer for hermetic verification tests. */
64
+ signerForPrincipal?: (args: {
65
+ principal: string;
66
+ allowedSignersText: string;
67
+ }) => Pick<Signer, 'verify'> & {
68
+ dispose?: () => void;
69
+ };
70
+ /** SSHSIG namespace override for a caller with a different record domain. */
71
+ namespace?: string;
72
+ }
73
+ /**
74
+ * Verify one relayed enrollment record. The operation is ordered so malformed
75
+ * input, missing trust roots, signer authorization, and missing chain support
76
+ * remain distinct verdicts instead of collapsing into a boolean.
77
+ */
78
+ export declare function verifyRosterEntry(input: VerifyRosterEntryInput, options?: VerifyRosterEntryOptions): Promise<RosterVerdict>;
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Enrollment-grant construction and client-side roster verification.
3
+ *
4
+ * D1 deliberately stops at a narrow chain-validation seam. A signed grant is
5
+ * unforgeable by a hub that only relays records, but a signature alone does not
6
+ * prove that the grantor is enrolled in the organization. Until a
7
+ * `EnrollmentChainValidator` is installed, verification therefore refuses with
8
+ * `unverifiable` rather than accepting the record. The explicit early return in
9
+ * `verifyRosterEntry` is the §8.1 fail-closed gate.
10
+ */
11
+ import { keyidFromBlob } from "./keys.js";
12
+ import { decodeBase64Strict, DSSE_SSH_NAMESPACE, dsseVerifyEnrollmentGrant, DsseEnvelopeError, } from "./dsse.js";
13
+ import { parseAllowedSigners } from "./allowed-signers.js";
14
+ import { createSshSigner, SshSignerError } from "./ssh.js";
15
+ import { enrollmentGrantSchema } from "../schemas/index.js";
16
+ import { validateValue, summarizeIssues } from "../schema.js";
17
+ /** The least privilege scope carried by a self-vouched machine grant. */
18
+ export const DEFAULT_MACHINE_SCOPE = Object.freeze({
19
+ pools: '*',
20
+ labels: '*',
21
+ namespaces: Object.freeze([]),
22
+ delegation: Object.freeze({ allowed: false }),
23
+ });
24
+ /** Build one complete, immutable enrollment grant without performing I/O. */
25
+ export function buildEnrollmentGrant(args) {
26
+ const scope = Object.freeze({
27
+ pools: Array.isArray(args.scope.pools) ? Object.freeze([...args.scope.pools]) : args.scope.pools,
28
+ labels: Array.isArray(args.scope.labels) ? Object.freeze([...args.scope.labels]) : args.scope.labels,
29
+ namespaces: Array.isArray(args.scope.namespaces) ? Object.freeze([...args.scope.namespaces]) : args.scope.namespaces,
30
+ delegation: args.scope.delegation.allowed
31
+ ? Object.freeze({ allowed: true, maxDepth: args.scope.delegation.maxDepth })
32
+ : Object.freeze({ allowed: false }),
33
+ });
34
+ const newKey = Object.freeze({
35
+ keyid: args.newKey.keyid,
36
+ keyType: args.newKey.keyType,
37
+ openSshPublicKey: args.newKey.openSshPublicKey,
38
+ ...(args.newKey.comment !== undefined ? { comment: args.newKey.comment } : {}),
39
+ });
40
+ const principal = Object.freeze({ kind: args.principal.kind, id: args.principal.id });
41
+ return Object.freeze({
42
+ newKey,
43
+ principal,
44
+ scope,
45
+ grantedBy: args.grantedBy,
46
+ validFrom: args.validFrom,
47
+ });
48
+ }
49
+ function invalid(reason) {
50
+ return { kind: 'invalid', reason };
51
+ }
52
+ function unverifiable(reason) {
53
+ return { kind: 'unverifiable', reason };
54
+ }
55
+ function asJsonObject(value) {
56
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
57
+ }
58
+ /**
59
+ * Decode only the unauthenticated payload needed for candidate selection. The
60
+ * record is still checked again by the DSSE verifier and by the signer-key
61
+ * cross-check below; no field decoded here authorizes a key.
62
+ */
63
+ function decodeEnrollment(input) {
64
+ const raw = input.envelope !== undefined ? input.envelope : input.dsseBytes;
65
+ if (raw === undefined)
66
+ return { kind: 'unenrolled' };
67
+ let envelope = raw;
68
+ if (typeof raw === 'string' || raw instanceof Uint8Array) {
69
+ try {
70
+ envelope = JSON.parse(Buffer.from(raw).toString('utf8'));
71
+ }
72
+ catch {
73
+ return invalid('enrollment envelope is not valid JSON');
74
+ }
75
+ }
76
+ if (!asJsonObject(envelope))
77
+ return invalid('enrollment envelope is not a JSON object');
78
+ const payload = envelope.payload;
79
+ if (typeof payload !== 'string')
80
+ return invalid("enrollment envelope is missing a string 'payload'");
81
+ let payloadBytes;
82
+ try {
83
+ payloadBytes = decodeBase64Strict(payload, { allowEmpty: true });
84
+ }
85
+ catch (error) {
86
+ return invalid(`enrollment payload is not valid Base64: ${error.message}`);
87
+ }
88
+ let decoded;
89
+ try {
90
+ decoded = JSON.parse(payloadBytes.toString('utf8'));
91
+ }
92
+ catch {
93
+ return invalid('enrollment payload is not valid JSON');
94
+ }
95
+ if (!asJsonObject(decoded))
96
+ return invalid('enrollment payload is not a JSON object');
97
+ const shape = validateValue(enrollmentGrantSchema, decoded);
98
+ if (!shape.valid) {
99
+ return invalid(`enrollment grant does not match schema: ${summarizeIssues(shape.issues)}`);
100
+ }
101
+ return { envelope, record: decoded };
102
+ }
103
+ /**
104
+ * Verify one relayed enrollment record. The operation is ordered so malformed
105
+ * input, missing trust roots, signer authorization, and missing chain support
106
+ * remain distinct verdicts instead of collapsing into a boolean.
107
+ */
108
+ export async function verifyRosterEntry(input, options = {}) {
109
+ const decoded = decodeEnrollment(input);
110
+ if ('kind' in decoded)
111
+ return decoded;
112
+ const { envelope, record } = decoded;
113
+ if (input.allowedSignersText === undefined) {
114
+ return unverifiable('no allowed_signers trust root was resolved');
115
+ }
116
+ const parsed = parseAllowedSigners(input.allowedSignersText);
117
+ if (parsed.errors.length > 0) {
118
+ return unverifiable(`allowed_signers policy is malformed: ${parsed.errors.map((error) => `line ${error.line}: ${error.message}`).join('; ')}`);
119
+ }
120
+ if (parsed.entries.length === 0)
121
+ return unverifiable('allowed_signers policy has no signer entries');
122
+ const candidates = parsed.entries.filter((entry) => keyidFromBlob(entry.keyBlob) === record.grantedBy);
123
+ if (candidates.length === 0) {
124
+ return invalid(`enrollment grantor key '${record.grantedBy}' is not present in allowed_signers`);
125
+ }
126
+ const makeSigner = options.signerForPrincipal ?? ((args) => createSshSigner({
127
+ namespace: options.namespace ?? DSSE_SSH_NAMESPACE,
128
+ verify: args,
129
+ }));
130
+ let sawCryptographicMiss = false;
131
+ for (const candidate of candidates) {
132
+ for (const principal of candidate.principals) {
133
+ let signer;
134
+ try {
135
+ signer = makeSigner({ principal, allowedSignersText: input.allowedSignersText });
136
+ }
137
+ catch (error) {
138
+ if (error instanceof SshSignerError)
139
+ return unverifiable(error.message);
140
+ return unverifiable(`enrollment verification setup failed: ${error instanceof Error ? error.message : String(error)}`);
141
+ }
142
+ try {
143
+ const result = await dsseVerifyEnrollmentGrant(envelope, signer, { threshold: 1 });
144
+ const verified = result.signers[0];
145
+ if (verified === undefined)
146
+ return invalid('enrollment signature produced no verified signer');
147
+ if (verified.keyid !== record.grantedBy) {
148
+ return invalid(`enrollment signer key '${verified.keyid}' does not match record grantedBy '${record.grantedBy}'`);
149
+ }
150
+ // §8.1: a signature proves who signed, not that the signer is enrolled.
151
+ // Refuse until WP-D4 installs the chain validator; never fail open.
152
+ if (options.chainValidator === undefined) {
153
+ return unverifiable('no enrollment chain validator is installed');
154
+ }
155
+ let chain;
156
+ try {
157
+ chain = await options.chainValidator.validate(record, verified.keyid);
158
+ }
159
+ catch (error) {
160
+ return unverifiable(`enrollment chain validation could not run: ${error instanceof Error ? error.message : String(error)}`);
161
+ }
162
+ if (!chain.ok)
163
+ return invalid(chain.reason);
164
+ return { kind: 'enrolled', keyid: record.newKey.keyid, principal: verified.principal };
165
+ }
166
+ catch (error) {
167
+ if (error instanceof SshSignerError)
168
+ return unverifiable(error.message);
169
+ if (error instanceof DsseEnvelopeError) {
170
+ if (error.message.startsWith('DSSE verification failed:')) {
171
+ sawCryptographicMiss = true;
172
+ continue;
173
+ }
174
+ return invalid(`enrollment verification failed: ${error.message}`);
175
+ }
176
+ return invalid(`enrollment verification failed: ${error instanceof Error ? error.message : String(error)}`);
177
+ }
178
+ finally {
179
+ signer.dispose?.();
180
+ }
181
+ }
182
+ }
183
+ if (sawCryptographicMiss)
184
+ return invalid('enrollment signature could not be verified by an allowed signer');
185
+ return invalid('enrollment signature did not verify');
186
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The public crypto surface of the owenloop engine (WP-A2).
3
+ *
4
+ * Three narrow capabilities that later trust work builds on:
5
+ * 1. Principal signing keys — `PrincipalKeyManager` generates, stores, and
6
+ * materializes Ed25519 keys for the human/machine/agent principals
7
+ * (macOS Keychain, Linux libsecret, or a secure 0600 file store). No
8
+ * function here hands a caller private-key text.
9
+ * 2. SSHSIG signing/verification — `SshSigner` (behind the format-neutral
10
+ * `Signer` interface) drives stock OpenSSH `ssh-keygen -Y`.
11
+ * 3. DSSE envelopes — `dsseSignEnvelope`/`dsseVerifyEnvelope` plus the six
12
+ * versioned payload-type constants and record-class wrappers.
13
+ *
14
+ * Process/storage adapters stay internal unless a test seam needs the type.
15
+ */
16
+ export { PrincipalKeyManager, assertKeyRef, canonicalKeyRef, keyidFromBlob, keyRefHash, publicKeyDescriptor, } from './keys.ts';
17
+ export type { EnsureKeyResult, InspectKeyResult, KeyCommandRunner, KeyStorageBackendKind, PrincipalKeyManagerOpts, PrincipalKeyRef, PrincipalKind, PublicKeyDescriptor, } from './keys.ts';
18
+ export { SshSigner, SshSignerError, createSshSigner, assertEd25519PubText, } from './ssh.ts';
19
+ export type { DetachedSignature, Signer, SshProcessAdapter, SshSignerConfig, VerifiedSignature, } from './ssh.ts';
20
+ export { DSSE_VERSION, DSSE_SSH_NAMESPACE, DSSE_RECORD_PAYLOAD_TYPES, isDsseRecordPayloadType, PAYLOAD_TYPE_ENROLLMENT_GRANT, PAYLOAD_TYPE_POLICY_FLOOR, PAYLOAD_TYPE_ORIGIN, PAYLOAD_TYPE_PUBLICATION, PAYLOAD_TYPE_REVOCATION, PAYLOAD_TYPE_SUBMISSION, DsseEnvelopeError, decodeBase64Strict, dsseSignEnrollmentGrant, dsseSignEnvelope, dsseSignOrigin, dsseSignPolicyFloor, dsseSignPublication, dsseSignRecord, dsseSignRevocation, dsseSignSubmission, dsseVerifyEnrollmentGrant, dsseVerifyEnvelope, dsseVerifyOrigin, dsseVerifyPolicyFloor, dsseVerifyPublication, dsseVerifyRecord, dsseVerifyRevocation, dsseVerifySubmission, encodeBase64, preAuthEncode, } from './dsse.ts';
21
+ export type { DsseEnvelope, DsseRecordPayloadType, DsseSignature, DsseVerifyResult } from './dsse.ts';
22
+ export { ENROLLMENT_GRANT_FIELDS, ENROLLMENT_KEY_FIELDS, GRANT_DELEGATION_ALLOWED_FIELDS, GRANT_DELEGATION_DENIED_FIELDS, GRANT_SCOPE_FIELDS, ORDER_FIELDS, ORDER_OWED_FIELDS, ORDER_REASON_FIELDS, ORIGIN_FIELDS, ORIGIN_SOURCE_AGENT_FIELDS, ORIGIN_SOURCE_CONSOLE_FIELDS, ORIGIN_SOURCE_GIT_FIELDS, POLICY_FLOOR_FIELDS, POLICY_FLOOR_RECORD_FIELDS, PRINCIPAL_REFERENCE_FIELDS, PUBLICATION_FIELDS, RECORD_PAYLOAD_TYPES, REVOCATION_FIELDS, SUBMISSION_FIELDS, SUBMISSION_PRODUCED_FIELDS, } from './records.ts';
23
+ export type { EnrollmentGrantRecord, EnrollmentKeyDescriptor, FieldManifest, GrantDelegation, GrantDelegationAllowed, GrantDelegationDenied, GrantScope, OptionalKeys, OriginRecord, OriginSource, OriginSourceAgent, OriginSourceConsole, OriginSourceGit, PolicyFloor, PolicyFloorRecord, PrincipalReference, PublicationRecord, RequiredKeys, RevocationRecord, SubmissionProducedArtifact, SubmissionRecord, } from './records.ts';
24
+ export { parseAllowedSigners } from './allowed-signers.ts';
25
+ export type { AllowedSignerEntry, AllowedSignerOptions, AllowedSignersFile, AllowedSignersParseError, } from './allowed-signers.ts';
26
+ export { allowedSignersPath, resolveAllowedSigners, resolveAllowedSignersFile } from './trust-roots.ts';
27
+ export type { AllowedSignersResolution, AllowedSignersPresent, AllowedSignersAbsent } from './trust-roots.ts';
28
+ export { isDefPolicy, verifyPublication, verifyPublicationSidecar } from './verify-publication.ts';
29
+ export type { DefPolicy, DefVerdict, VerifyPublicationInput, VerifyPublicationOptions } from './verify-publication.ts';
30
+ export { verifyOrigin, verifyOriginSidecar } from './verify-origin.ts';
31
+ export type { OriginVerdict, VerifyOriginInput, VerifyOriginOptions } from './verify-origin.ts';
32
+ export { DEF_POLICY_RANK, POLICY_FLOOR_PRESETS, artifactPolicyMinimum, floorDefPolicyMinimum, mergePolicyFloorWithLocal, originRulesMinimum, policyFloorGaps, stricterDefPolicy, verifyPolicyFloorRecord, } from './policy-floor.ts';
33
+ export type { PolicyFloorGap, PolicyFloorMergeResult, PolicyFloorVerdict, VerifyPolicyFloorInput, VerifyPolicyFloorOptions, } from './policy-floor.ts';
34
+ export { OriginRulesError, evaluateOriginRule, matchOriginRule, parseOriginRules, ORIGIN_SOURCE_RANK, } from './origin-rules.ts';
35
+ export type { OriginPolicy, OriginRuleEvaluation, OriginRuleMatch, OriginRuleValue, OriginRules, } from './origin-rules.ts';
36
+ export { DEFAULT_MACHINE_SCOPE, buildEnrollmentGrant, verifyRosterEntry, } from './enrollment.ts';
37
+ export type { BuildEnrollmentGrantArgs, EnrollmentChainValidator, RosterVerdict, VerifyRosterEntryInput, VerifyRosterEntryOptions, } from './enrollment.ts';
38
+ export { validateEnrollmentChain, validateProducer, revocationTemporalConsistency, } from './chain.ts';
39
+ export type { ChainInput, ChainOptions, ChainVerdict } from './chain.ts';
40
+ export { attenuate, axisPermits, delegationPermits, ORG_ROOT_SCOPE, scopePermits, } from './scope.ts';
41
+ export type { ScopeAxis } from './scope.ts';
42
+ export { loadRoster, loadRevocations, orgRootPrivateKeyPath, orgRootPublicKeyPath, resolveOrgRoot, revocationsDir, rosterDir, } from './org-root.ts';
43
+ export type { OrgRootAbsent, OrgRootPresent, OrgRootResolution } from './org-root.ts';
44
+ export { canonicalValueBytes, valueDigestHex } from './canonical.ts';
45
+ export { buildSubmissionRecord, signSubmission } from './submission.ts';
46
+ export type { BuildSubmissionRecordInput, SubmissionProducedInput } from './submission.ts';
47
+ export { verifyConsumed, verifyConsumedArtifact } from './verify-consumed.ts';
48
+ export type { ConsumedVerdict, VerifyConsumedInput, VerifyConsumedOptions, } from './verify-consumed.ts';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The public crypto surface of the owenloop engine (WP-A2).
3
+ *
4
+ * Three narrow capabilities that later trust work builds on:
5
+ * 1. Principal signing keys — `PrincipalKeyManager` generates, stores, and
6
+ * materializes Ed25519 keys for the human/machine/agent principals
7
+ * (macOS Keychain, Linux libsecret, or a secure 0600 file store). No
8
+ * function here hands a caller private-key text.
9
+ * 2. SSHSIG signing/verification — `SshSigner` (behind the format-neutral
10
+ * `Signer` interface) drives stock OpenSSH `ssh-keygen -Y`.
11
+ * 3. DSSE envelopes — `dsseSignEnvelope`/`dsseVerifyEnvelope` plus the six
12
+ * versioned payload-type constants and record-class wrappers.
13
+ *
14
+ * Process/storage adapters stay internal unless a test seam needs the type.
15
+ */
16
+ // ---- keys ----
17
+ export { PrincipalKeyManager, assertKeyRef, canonicalKeyRef, keyidFromBlob, keyRefHash, publicKeyDescriptor, } from "./keys.js";
18
+ // ---- signer / SSHSIG ----
19
+ export { SshSigner, SshSignerError, createSshSigner, assertEd25519PubText, } from "./ssh.js";
20
+ // ---- DSSE ----
21
+ export { DSSE_VERSION, DSSE_SSH_NAMESPACE, DSSE_RECORD_PAYLOAD_TYPES, isDsseRecordPayloadType, PAYLOAD_TYPE_ENROLLMENT_GRANT, PAYLOAD_TYPE_POLICY_FLOOR, PAYLOAD_TYPE_ORIGIN, PAYLOAD_TYPE_PUBLICATION, PAYLOAD_TYPE_REVOCATION, PAYLOAD_TYPE_SUBMISSION, DsseEnvelopeError, decodeBase64Strict, dsseSignEnrollmentGrant, dsseSignEnvelope, dsseSignOrigin, dsseSignPolicyFloor, dsseSignPublication, dsseSignRecord, dsseSignRevocation, dsseSignSubmission, dsseVerifyEnrollmentGrant, dsseVerifyEnvelope, dsseVerifyOrigin, dsseVerifyPolicyFloor, dsseVerifyPublication, dsseVerifyRecord, dsseVerifyRevocation, dsseVerifySubmission, encodeBase64, preAuthEncode, } from "./dsse.js";
22
+ // ---- wire records ----
23
+ export { ENROLLMENT_GRANT_FIELDS, ENROLLMENT_KEY_FIELDS, GRANT_DELEGATION_ALLOWED_FIELDS, GRANT_DELEGATION_DENIED_FIELDS, GRANT_SCOPE_FIELDS, ORDER_FIELDS, ORDER_OWED_FIELDS, ORDER_REASON_FIELDS, ORIGIN_FIELDS, ORIGIN_SOURCE_AGENT_FIELDS, ORIGIN_SOURCE_CONSOLE_FIELDS, ORIGIN_SOURCE_GIT_FIELDS, POLICY_FLOOR_FIELDS, POLICY_FLOOR_RECORD_FIELDS, PRINCIPAL_REFERENCE_FIELDS, PUBLICATION_FIELDS, RECORD_PAYLOAD_TYPES, REVOCATION_FIELDS, SUBMISSION_FIELDS, SUBMISSION_PRODUCED_FIELDS, } from "./records.js";
24
+ // ---- allowed_signers ----
25
+ export { parseAllowedSigners } from "./allowed-signers.js";
26
+ // ---- publication and origin verification ----
27
+ export { allowedSignersPath, resolveAllowedSigners, resolveAllowedSignersFile } from "./trust-roots.js";
28
+ export { isDefPolicy, verifyPublication, verifyPublicationSidecar } from "./verify-publication.js";
29
+ export { verifyOrigin, verifyOriginSidecar } from "./verify-origin.js";
30
+ // ---- policy floors ----
31
+ export { DEF_POLICY_RANK, POLICY_FLOOR_PRESETS, artifactPolicyMinimum, floorDefPolicyMinimum, mergePolicyFloorWithLocal, originRulesMinimum, policyFloorGaps, stricterDefPolicy, verifyPolicyFloorRecord, } from "./policy-floor.js";
32
+ // ---- WP-E2a origin execution policy ----
33
+ export { OriginRulesError, evaluateOriginRule, matchOriginRule, parseOriginRules, ORIGIN_SOURCE_RANK, } from "./origin-rules.js";
34
+ // ---- WP-D1 enrollment ----
35
+ export { DEFAULT_MACHINE_SCOPE, buildEnrollmentGrant, verifyRosterEntry, } from "./enrollment.js";
36
+ // ---- enrollment chain ----
37
+ export { validateEnrollmentChain, validateProducer, revocationTemporalConsistency, } from "./chain.js";
38
+ export { attenuate, axisPermits, delegationPermits, ORG_ROOT_SCOPE, scopePermits, } from "./scope.js";
39
+ export { loadRoster, loadRevocations, orgRootPrivateKeyPath, orgRootPublicKeyPath, resolveOrgRoot, revocationsDir, rosterDir, } from "./org-root.js";
40
+ // ---- WP-D2 signed submission records ----
41
+ export { canonicalValueBytes, valueDigestHex } from "./canonical.js";
42
+ export { buildSubmissionRecord, signSubmission } from "./submission.js";
43
+ // ---- WP-D3 consume-side verification ----
44
+ export { verifyConsumed, verifyConsumedArtifact } from "./verify-consumed.js";