@cello-protocol/protocol-types 0.0.43 → 0.0.45

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/dist/cbor.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ * `setSizeLimits` EXISTS at runtime in cbor-x 1.6.4 and is absent from the shipped `.d.ts`.
3
+ * Verified, not assumed: `Object.keys(require("cbor-x"))` includes it.
4
+ *
5
+ * Declared here rather than cast away, so the call below is type-checked against the shape we
6
+ * actually rely on. If a future cbor-x removes the function, this declaration keeps compiling and
7
+ * the call becomes a no-op — which is why the limits have their own test rather than resting on the
8
+ * import succeeding.
9
+ */
10
+ declare module "cbor-x" {
11
+ function setSizeLimits(limits: {
12
+ maxArraySize?: number;
13
+ maxMapSize?: number;
14
+ maxObjectSize?: number;
15
+ }): void;
16
+ }
1
17
  /**
2
18
  * Encode to CBOR: byte strings for bytes, maps for objects. Valid RFC 8949.
3
19
  *
@@ -1 +1 @@
1
- {"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../src/cbor.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAErD;AAED,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAErD"}
1
+ {"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../src/cbor.ts"],"names":[],"mappings":"AAsBA;;;;;;;;GAQG;AACH,OAAO,QAAQ,QAAQ,CAAC;IACtB,SAAgB,aAAa,CAAC,MAAM,EAAE;QACpC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,IAAI,CAAC;CACV;AA6DD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAErD;AAED,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAErD"}
package/dist/cbor.js CHANGED
@@ -19,6 +19,62 @@
19
19
  * tolerance is for data that predates this module — it is not a licence to write a second format.
20
20
  */
21
21
  import { Encoder, decode } from "cbor-x";
22
+ import { setSizeLimits } from "cbor-x";
23
+ /**
24
+ * DECODER SIZE LIMITS — a security boundary, not a tuning knob.
25
+ *
26
+ * Without them, a few bytes of hostile CBOR cost seconds and gigabytes. MEASURED on this decoder:
27
+ * `9f b0` (indefinite-length array header, then a map header, no data) took **5.0 s**; `a1 9f` —
28
+ * THREE bytes, a one-pair map whose first key is an indefinite array — took **9.6 s and 1.1 GB**;
29
+ * `9f 26` was independently measured at 10 s / 1.6 GB. Any code path that hands peer-controlled
30
+ * bytes to `decodeCbor` is therefore a denial of service, and every decoder in this package is on
31
+ * one: the daemon's session content path, the directory's `seal_submission`, the relay.
32
+ *
33
+ * A CALLER-SIDE GUARD CANNOT FIX THIS, and one was tried. Inspecting the header byte is sound about
34
+ * the outermost container and says nothing about what is nested inside it — a valid map header
35
+ * followed by an indefinite array is admitted by any header check, including one requiring the real
36
+ * frames' own `b9 000a` prefix. The bound has to be on the decoder.
37
+ *
38
+ * ── WHY 250,000 AND NOT SOMETHING TIGHTER ─────────────────────────────────────────────────────
39
+ *
40
+ * The bound is set by the LARGEST LEGITIMATE STRUCTURE, not by the attack. `ae-channel.ts` in
41
+ * trustless-cello declares `MAX_WIRE_ITEMS = 250_000` as the anti-hostile-peer bound for
42
+ * directory-to-directory replication, and it decodes BEFORE applying it — so a tighter global cap
43
+ * here silently supersedes it. A first attempt at 65,536 did exactly that: at 65,537 rows in any
44
+ * replicated table (`agent_profiles`, `conversation_seals`, `seal_notarizations`, …, none of which
45
+ * the AE store paginates) replication would have stopped permanently and been reported as a PEER
46
+ * protocol violation. That is the same shape of failure this repo already ate on 2026-08-01.
47
+ *
48
+ * Refusing real data is the worse direction. A slow decode is a nuisance; a directory that cannot
49
+ * replicate, blaming its peer, is an outage nobody can diagnose from the message.
50
+ *
51
+ * The limit is EXCLUSIVE — cbor-x throws "Array length exceeds N" at exactly N, not above it — so a
52
+ * cap of 250,000 would refuse a frame carrying exactly `MAX_WIRE_ITEMS`, which is the boundary the
53
+ * AE channel is most likely to sit on because that is its own declared maximum. 262,144 (2^18) is
54
+ * the next round number clear of it, and the margin is the point rather than the roundness.
55
+ *
56
+ * Measured: a legitimate 250,000-element frame decodes in ~30 ms; the three-byte hostile inputs
57
+ * above are 3–4 ms; byte strings are not counted at all, so a 1 MB Yjs update is unaffected.
58
+ *
59
+ * ── WHAT THIS DOES *NOT* CLOSE ────────────────────────────────────────────────────────────────
60
+ *
61
+ * A size limit is not a completeness argument, and saying otherwise was the previous version of
62
+ * this comment. cbor-x pre-allocates `new Array(declaredCount)` BEFORE reading any element, so
63
+ * NESTED definite-length arrays each sitting just under the cap still allocate: measured, 15 KB of
64
+ * such input costs ~230 ms and ~2.3 GB before V8's stack depth stops it. The missing invariant is
65
+ * "a container cannot declare more elements than there are bytes left to fill it", which cbor-x
66
+ * does not enforce and this cannot express.
67
+ *
68
+ * So every caller that hands PEER-CONTROLLED bytes to `decodeCbor` must also bound the INPUT
69
+ * LENGTH — that is what makes the nesting depth finite. This limit reduces the per-byte
70
+ * amplification by roughly 43,000×; the input cap is what closes the class.
71
+ *
72
+ * Process-global to cbor-x, which is the right blast radius for the part it does cover: the decode
73
+ * functions are public API of this package, so a limit attached to one caller would leave every
74
+ * other caller unguarded. `maxObjectSize` is passed for symmetry and is inert — cbor-x 1.6.4
75
+ * accepts it and never reads it; plain-object key counts are bounded by `maxMapSize`.
76
+ */
77
+ setSizeLimits({ maxArraySize: 262_144, maxMapSize: 262_144, maxObjectSize: 262_144 });
22
78
  const ENCODER = new Encoder({ tagUint8Array: false, useRecords: false });
23
79
  /**
24
80
  * Encode to CBOR: byte strings for bytes, maps for objects. Valid RFC 8949.
package/dist/cbor.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cbor.js","sourceRoot":"","sources":["../src/cbor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAe,CAAC;AAC7C,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
1
+ {"version":3,"file":"cbor.js","sourceRoot":"","sources":["../src/cbor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkBzC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,aAAa,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;AAEtF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAe,CAAC;AAC7C,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * DOD-DOC-INBOUND-2 — the document ACK (§16.4).
3
+ *
4
+ * The frame that closes DELIVERY-2's loop. Until it exists, a sent envelope's outcome is
5
+ * `admitted: null` forever: the worker knows the content left and nothing more, so it re-sends on
6
+ * the ack timeout and eventually stalls the document at the unacked ceiling.
7
+ *
8
+ * ── WHY A REJECTION IS AN ACK ─────────────────────────────────────────────────────────────────
9
+ *
10
+ * `admitted: false` is not a failure to acknowledge — it is an acknowledgement that says no. The
11
+ * peer has DECIDED, so the sender must stop retrying and supersede instead (§3.2). Modelling
12
+ * rejection as "no ack" would leave the sender redelivering an envelope the peer has already ruled
13
+ * on, re-triggering their gate and their retry counter until the document stalls for reasons the
14
+ * operator cannot see.
15
+ *
16
+ * ── WHY IT IS SIGNED ──────────────────────────────────────────────────────────────────────────
17
+ *
18
+ * The ack settles an envelope permanently: an acked envelope stops being redelivered and, if the
19
+ * ack says rejected, the sender rolls back local work. Both are consequences an unauthenticated
20
+ * party must not be able to cause. An unsigned ack lets anyone who can reach the channel silence a
21
+ * delivery — the content is dropped from the pending set and neither operator ever learns it was
22
+ * never applied, which is exactly the silent divergence the two-layer design exists to prevent.
23
+ *
24
+ * The signature covers the ENVELOPE HASH, so an ack cannot be moved to a different envelope, and
25
+ * the DOCUMENT ID, so it cannot be moved to a different document. It does not cover `admitted`
26
+ * alone for the same reason a signature never covers one field: the whole statement is the claim.
27
+ *
28
+ * ── CONTRACT FOR THE CONSUMER: SETTLE ONCE ────────────────────────────────────────────────────
29
+ *
30
+ * Nothing here binds an ack to the acker's chain, and nothing at the type level stops one acker
31
+ * producing a valid ADMISSION and a valid REJECTION for the same envelope. Envelopes have
32
+ * `verifyDocumentChainLink` because per-sender ordering matters; acks have no equivalent. So the
33
+ * consumer must settle an envelope ONCE and treat a second, contradicting ack as an ERROR with both
34
+ * signatures retained — never as an update. Applying the later one would let a peer that admitted
35
+ * an envelope later claim it refused it, and the sender would roll back work the peer already has.
36
+ */
37
+ /** Domain tag in slot 0. Distinct from the update and proposal domains. */
38
+ export declare const DOCUMENT_ACK_DOMAIN = "CELLO-DOCUMENT-ACK-v1";
39
+ /**
40
+ * The ack frame version, ON THE WIRE.
41
+ *
42
+ * The `-v1` in the domain string never travels — it lives inside the preimage — so a V2 acker's
43
+ * frame would decode cleanly as V1 and fail SIGNATURE VERIFICATION, sending an operator to key
44
+ * management and peer identity for a version-skew bug. The update envelope refuses `epoch_id` and
45
+ * `update_encoding` by value for exactly this reason: skew that is not SAID becomes silent loss or
46
+ * a misattributed error.
47
+ */
48
+ export declare const DOCUMENT_ACK_VERSION = 1;
49
+ /**
50
+ * A rejection reason is peer-controlled text bound for an operator's screen and the policy log.
51
+ * Capped because unbounded peer-controlled display text is not something to hand onward untouched.
52
+ */
53
+ export declare const MAX_REJECTION_REASON_LENGTH = 200;
54
+ export interface DocumentAck {
55
+ type: "document_ack";
56
+ /** Always `DOCUMENT_ACK_VERSION` in V1. Carried on the wire so skew is DETECTED, not misread. */
57
+ ack_version: number;
58
+ document_id: string;
59
+ /** The envelope this settles. */
60
+ envelope_hash: string;
61
+ /** Who is answering — the party that received the update. */
62
+ acker_agent_id: string;
63
+ /**
64
+ * `true` admitted, `false` rejected. BOTH settle the envelope; see the header. There is no third
65
+ * value on the wire, because an ack that does not say which is not an answer.
66
+ */
67
+ admitted: boolean;
68
+ /** Present iff `admitted` is false. The §3.2 reason, so the sender can supersede deliberately. */
69
+ rejection_reason?: string;
70
+ acked_at_ms: number;
71
+ /** Ed25519 (RFC 8032) over `buildDocumentAckTbs`. */
72
+ signature: Uint8Array;
73
+ }
74
+ /**
75
+ * The canonical to-be-signed preimage: a fixed-order CBOR ARRAY with the domain in slot 0.
76
+ *
77
+ * An array rather than a map for the reason `cbor.ts` gives — this encoder is deliberately not
78
+ * deterministic for maps, so a map preimage would make the signature depend on the order the acker
79
+ * happened to build the object in, and two honest implementations would disagree.
80
+ *
81
+ * `rejection_reason` is encoded as `null` when absent rather than omitted, so the slot is always
82
+ * occupied and no field's meaning depends on whether the one before it was present.
83
+ *
84
+ * An earlier version of this comment claimed omission would be "silently absorbed by the next
85
+ * field". That is FALSE for this encoder and worth correcting rather than deleting, because a wrong
86
+ * fact about the wire is what the next structure's justification gets built on: a 6-element array
87
+ * begins `0x86` and a 7-element one `0x87`, so a missing slot is loud, in byte 0. Measured.
88
+ * `cbor.ts` says the same thing — arrays are minimal and order-fixed. The explicit null is still
89
+ * right; the reason is stable slot indices, not collision avoidance.
90
+ */
91
+ export declare function buildDocumentAckTbs(ack: DocumentAck, opts?: {
92
+ preHash?: boolean;
93
+ }): Uint8Array;
94
+ /**
95
+ * The cross-field rules, checked on ENCODE as well as decode.
96
+ *
97
+ * On encode too, because a locally-built contradictory ack would otherwise be signed and shipped
98
+ * and fail only on the remote decode: the sender sees a silent stall, the peer sees the error, and
99
+ * the two never meet. The rule belongs where the object is built, not only where it is read.
100
+ */
101
+ export declare function assertDocumentAckConsistent(ack: DocumentAck): void;
102
+ export declare function encodeDocumentAck(ack: DocumentAck): Uint8Array;
103
+ /**
104
+ * Decode and validate. Refuses rather than defaulting on every field.
105
+ *
106
+ * The one that matters most: `admitted` must be a real boolean. Coerced, a truthy string like
107
+ * `"false"` would settle a REJECTED envelope as admitted — the sender would stop retrying, never
108
+ * roll back, and both parties would believe content was applied that the receiver refused.
109
+ */
110
+ export declare function decodeDocumentAck(bytes: Uint8Array): DocumentAck;
111
+ //# sourceMappingURL=document-ack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-ack.d.ts","sourceRoot":"","sources":["../src/document-ack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAKH,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAI/C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,cAAc,CAAC;IACrB,iGAAiG;IACjG,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,WAAW,EAChB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/B,UAAU,CAsBZ;AAOD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAmBlE;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,UAAU,CAa9D;AAWD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAuFhE"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * DOD-DOC-INBOUND-2 — the document ACK (§16.4).
3
+ *
4
+ * The frame that closes DELIVERY-2's loop. Until it exists, a sent envelope's outcome is
5
+ * `admitted: null` forever: the worker knows the content left and nothing more, so it re-sends on
6
+ * the ack timeout and eventually stalls the document at the unacked ceiling.
7
+ *
8
+ * ── WHY A REJECTION IS AN ACK ─────────────────────────────────────────────────────────────────
9
+ *
10
+ * `admitted: false` is not a failure to acknowledge — it is an acknowledgement that says no. The
11
+ * peer has DECIDED, so the sender must stop retrying and supersede instead (§3.2). Modelling
12
+ * rejection as "no ack" would leave the sender redelivering an envelope the peer has already ruled
13
+ * on, re-triggering their gate and their retry counter until the document stalls for reasons the
14
+ * operator cannot see.
15
+ *
16
+ * ── WHY IT IS SIGNED ──────────────────────────────────────────────────────────────────────────
17
+ *
18
+ * The ack settles an envelope permanently: an acked envelope stops being redelivered and, if the
19
+ * ack says rejected, the sender rolls back local work. Both are consequences an unauthenticated
20
+ * party must not be able to cause. An unsigned ack lets anyone who can reach the channel silence a
21
+ * delivery — the content is dropped from the pending set and neither operator ever learns it was
22
+ * never applied, which is exactly the silent divergence the two-layer design exists to prevent.
23
+ *
24
+ * The signature covers the ENVELOPE HASH, so an ack cannot be moved to a different envelope, and
25
+ * the DOCUMENT ID, so it cannot be moved to a different document. It does not cover `admitted`
26
+ * alone for the same reason a signature never covers one field: the whole statement is the claim.
27
+ *
28
+ * ── CONTRACT FOR THE CONSUMER: SETTLE ONCE ────────────────────────────────────────────────────
29
+ *
30
+ * Nothing here binds an ack to the acker's chain, and nothing at the type level stops one acker
31
+ * producing a valid ADMISSION and a valid REJECTION for the same envelope. Envelopes have
32
+ * `verifyDocumentChainLink` because per-sender ordering matters; acks have no equivalent. So the
33
+ * consumer must settle an envelope ONCE and treat a second, contradicting ack as an ERROR with both
34
+ * signatures retained — never as an update. Applying the later one would let a peer that admitted
35
+ * an envelope later claim it refused it, and the sender would roll back work the peer already has.
36
+ */
37
+ import { createHash } from "node:crypto";
38
+ import { encodeCbor, decodeCbor } from "./cbor.js";
39
+ /** Domain tag in slot 0. Distinct from the update and proposal domains. */
40
+ export const DOCUMENT_ACK_DOMAIN = "CELLO-DOCUMENT-ACK-v1";
41
+ /**
42
+ * The ack frame version, ON THE WIRE.
43
+ *
44
+ * The `-v1` in the domain string never travels — it lives inside the preimage — so a V2 acker's
45
+ * frame would decode cleanly as V1 and fail SIGNATURE VERIFICATION, sending an operator to key
46
+ * management and peer identity for a version-skew bug. The update envelope refuses `epoch_id` and
47
+ * `update_encoding` by value for exactly this reason: skew that is not SAID becomes silent loss or
48
+ * a misattributed error.
49
+ */
50
+ export const DOCUMENT_ACK_VERSION = 1;
51
+ /**
52
+ * A rejection reason is peer-controlled text bound for an operator's screen and the policy log.
53
+ * Capped because unbounded peer-controlled display text is not something to hand onward untouched.
54
+ */
55
+ export const MAX_REJECTION_REASON_LENGTH = 200;
56
+ const HEX32 = /^[0-9a-f]{64}$/;
57
+ /**
58
+ * The canonical to-be-signed preimage: a fixed-order CBOR ARRAY with the domain in slot 0.
59
+ *
60
+ * An array rather than a map for the reason `cbor.ts` gives — this encoder is deliberately not
61
+ * deterministic for maps, so a map preimage would make the signature depend on the order the acker
62
+ * happened to build the object in, and two honest implementations would disagree.
63
+ *
64
+ * `rejection_reason` is encoded as `null` when absent rather than omitted, so the slot is always
65
+ * occupied and no field's meaning depends on whether the one before it was present.
66
+ *
67
+ * An earlier version of this comment claimed omission would be "silently absorbed by the next
68
+ * field". That is FALSE for this encoder and worth correcting rather than deleting, because a wrong
69
+ * fact about the wire is what the next structure's justification gets built on: a 6-element array
70
+ * begins `0x86` and a 7-element one `0x87`, so a missing slot is loud, in byte 0. Measured.
71
+ * `cbor.ts` says the same thing — arrays are minimal and order-fixed. The explicit null is still
72
+ * right; the reason is stable slot indices, not collision avoidance.
73
+ */
74
+ export function buildDocumentAckTbs(ack, opts = {}) {
75
+ assertDocumentAckConsistent(ack);
76
+ const preimage = encodeCbor([
77
+ DOCUMENT_ACK_DOMAIN,
78
+ ack.ack_version,
79
+ ack.document_id,
80
+ ack.envelope_hash,
81
+ ack.acker_agent_id,
82
+ ack.admitted,
83
+ normalizeReason(ack.rejection_reason),
84
+ // BIGINT past 0xffffffff. cbor-x encodes a JS number that large as an IEEE float64 (`fb`)
85
+ // rather than a uint64 (`1b`) — measured: 1700000000000 gives fb4278bcfe56800000, not
86
+ // 1b0000018bcfe56800. A millisecond timestamp is always that large, so any implementation
87
+ // encoding RFC 8949-canonically would compute different TBS bytes and reject a GENUINE ack —
88
+ // surfacing as a signature failure, which reads as forgery. Three sibling builders carry this
89
+ // same coercion and primary-transfer.ts names it as a defect it shipped without.
90
+ typeof ack.acked_at_ms === "number" && ack.acked_at_ms > 0xffffffff
91
+ ? BigInt(ack.acked_at_ms)
92
+ : ack.acked_at_ms,
93
+ ]);
94
+ if (opts.preHash === false)
95
+ return preimage;
96
+ return new Uint8Array(createHash("sha256").update(preimage).digest());
97
+ }
98
+ /** Empty string means ABSENT. See `assertDocumentAckConsistent`. */
99
+ function normalizeReason(reason) {
100
+ return reason === undefined || reason === "" ? null : reason;
101
+ }
102
+ /**
103
+ * The cross-field rules, checked on ENCODE as well as decode.
104
+ *
105
+ * On encode too, because a locally-built contradictory ack would otherwise be signed and shipped
106
+ * and fail only on the remote decode: the sender sees a silent stall, the peer sees the error, and
107
+ * the two never meet. The rule belongs where the object is built, not only where it is read.
108
+ */
109
+ export function assertDocumentAckConsistent(ack) {
110
+ const reason = normalizeReason(ack.rejection_reason);
111
+ if (!ack.admitted && reason === null) {
112
+ // The sender is being told to stop and supersede. Without the reason it cannot know what to
113
+ // change — the failure the whole rejection protocol exists to prevent.
114
+ throw new Error("document_ack_reason: a rejection must carry its reason");
115
+ }
116
+ if (ack.admitted && reason !== null) {
117
+ // A contradiction: whichever field a reader trusts, the other is lying to them.
118
+ throw new Error(`document_ack_reason: an admission must not carry a rejection reason, and this one carries "${reason}"`);
119
+ }
120
+ if (reason !== null && reason.length > MAX_REJECTION_REASON_LENGTH) {
121
+ throw new Error(`document_ack_reason: a rejection reason may be at most ${MAX_REJECTION_REASON_LENGTH} ` +
122
+ `characters, and this one is ${reason.length}`);
123
+ }
124
+ }
125
+ export function encodeDocumentAck(ack) {
126
+ assertDocumentAckConsistent(ack);
127
+ return encodeCbor({
128
+ type: ack.type,
129
+ ack_version: ack.ack_version,
130
+ document_id: ack.document_id,
131
+ envelope_hash: ack.envelope_hash,
132
+ acker_agent_id: ack.acker_agent_id,
133
+ admitted: ack.admitted,
134
+ rejection_reason: normalizeReason(ack.rejection_reason),
135
+ acked_at_ms: ack.acked_at_ms,
136
+ signature: ack.signature,
137
+ });
138
+ }
139
+ function present(map, field) {
140
+ // `in`, not a nullish check — the same discipline as the update envelope. A defaulted field here
141
+ // is a claim the acker never made, and this frame's whole job is to carry their claim.
142
+ if (!(field in map)) {
143
+ throw new Error(`document_ack_missing_field: ${field} is mandatory and was not present`);
144
+ }
145
+ return map[field];
146
+ }
147
+ /**
148
+ * Decode and validate. Refuses rather than defaulting on every field.
149
+ *
150
+ * The one that matters most: `admitted` must be a real boolean. Coerced, a truthy string like
151
+ * `"false"` would settle a REJECTED envelope as admitted — the sender would stop retrying, never
152
+ * roll back, and both parties would believe content was applied that the receiver refused.
153
+ */
154
+ export function decodeDocumentAck(bytes) {
155
+ const decoded = decodeCbor(bytes);
156
+ if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) {
157
+ throw new Error("document_ack_malformed: not a CBOR map");
158
+ }
159
+ const map = decoded;
160
+ const type = present(map, "type");
161
+ if (type !== "document_ack") {
162
+ throw new Error(`document_ack_type: expected document_ack, got ${String(type)}`);
163
+ }
164
+ const version = present(map, "ack_version");
165
+ if (typeof version !== "number" || !Number.isInteger(version)) {
166
+ throw new Error("document_ack_version: must be an integer");
167
+ }
168
+ if (version !== DOCUMENT_ACK_VERSION) {
169
+ // Named as SKEW. Without a wire version this frame decoded cleanly and failed signature
170
+ // verification instead, sending an operator to key management for a version problem.
171
+ throw new Error(`document_ack_version: this build speaks ack version ${DOCUMENT_ACK_VERSION} and the frame ` +
172
+ `declares ${version} — one of the two clients needs upgrading`);
173
+ }
174
+ const documentId = present(map, "document_id");
175
+ if (typeof documentId !== "string" || !HEX32.test(documentId)) {
176
+ throw new Error(`document_ack_document_id: must be a 32-byte hex digest`);
177
+ }
178
+ const envelopeHash = present(map, "envelope_hash");
179
+ if (typeof envelopeHash !== "string" || !HEX32.test(envelopeHash)) {
180
+ throw new Error("document_ack_envelope_hash: must be a 32-byte hex digest");
181
+ }
182
+ const ackerAgentId = present(map, "acker_agent_id");
183
+ if (typeof ackerAgentId !== "string" || ackerAgentId.length === 0) {
184
+ throw new Error("document_ack_acker: acker_agent_id must be a non-empty text string");
185
+ }
186
+ const admitted = present(map, "admitted");
187
+ if (typeof admitted !== "boolean") {
188
+ throw new Error(`document_ack_admitted: must be a boolean, got ${typeof admitted}`);
189
+ }
190
+ const rawReason = present(map, "rejection_reason");
191
+ if (rawReason !== null && typeof rawReason !== "string") {
192
+ throw new Error("document_ack_reason: rejection_reason must be a text string or explicit null");
193
+ }
194
+ // NORMALIZED ONCE, before the cross-field rules. The empty string meant "absent" on the rejection
195
+ // branch and "present" on the admission branch, so an honest peer written in a language where a
196
+ // non-nullable string field defaults to "" — Go, Rust — had its ADMISSION refused as a
197
+ // contradiction it never expressed. The sender then never settles, retries to the unacked
198
+ // ceiling, and the document stalls: precisely the failure this frame exists to end.
199
+ const reason = rawReason === "" ? null : rawReason;
200
+ const ackedAt = present(map, "acked_at_ms");
201
+ // BOUNDED. `Number.isInteger(1e300)` is true, and this is the only field available to order two
202
+ // conflicting acks — leaving it unbounded hands that tiebreak to an attacker-chosen value.
203
+ if (typeof ackedAt !== "number" || !Number.isSafeInteger(ackedAt) || ackedAt <= 0) {
204
+ throw new Error(`document_ack_time: acked_at_ms must be a positive safe integer, got ${String(ackedAt)}`);
205
+ }
206
+ const signature = present(map, "signature");
207
+ if (!(signature instanceof Uint8Array)) {
208
+ throw new Error("document_ack_signature: must be a CBOR byte string");
209
+ }
210
+ const ack = {
211
+ type: "document_ack",
212
+ ack_version: version,
213
+ document_id: documentId,
214
+ envelope_hash: envelopeHash,
215
+ acker_agent_id: ackerAgentId,
216
+ admitted,
217
+ ...(reason === null ? {} : { rejection_reason: reason }),
218
+ acked_at_ms: ackedAt,
219
+ // COPIED — cbor-x returns byte strings as views into the buffer it decoded, so a caller reusing
220
+ // a pooled read buffer would have the signature change after it was verified.
221
+ signature: new Uint8Array(signature),
222
+ };
223
+ // The same cross-field rules the encoder applies. One implementation, so the two surfaces cannot
224
+ // drift into disagreeing about what a valid ack is.
225
+ assertDocumentAckConsistent(ack);
226
+ return ack;
227
+ }
228
+ //# sourceMappingURL=document-ack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-ack.js","sourceRoot":"","sources":["../src/document-ack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAuB/B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAgB,EAChB,OAA8B,EAAE;IAEhC,2BAA2B,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAG,UAAU,CAAC;QAC1B,mBAAmB;QACnB,GAAG,CAAC,WAAW;QACf,GAAG,CAAC,WAAW;QACf,GAAG,CAAC,aAAa;QACjB,GAAG,CAAC,cAAc;QAClB,GAAG,CAAC,QAAQ;QACZ,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC;QACrC,0FAA0F;QAC1F,sFAAsF;QACtF,0FAA0F;QAC1F,6FAA6F;QAC7F,8FAA8F;QAC9F,iFAAiF;QACjF,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ,IAAI,GAAG,CAAC,WAAW,GAAG,UAAU;YACjE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;YACzB,CAAC,CAAC,GAAG,CAAC,WAAW;KACpB,CA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ACb,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * DOD-DOC-TOOLS-1 — the document CONTROL frame: close and kill (§16.5).
3
+ *
4
+ * A unilateral end, told to the other party.
5
+ *
6
+ * ── WHY THE PEER MUST BE TOLD, AND WHY IT IS BEST-EFFORT ──────────────────────────────────────
7
+ *
8
+ * `DocumentLifecycle` already ends a document locally without asking anyone — that is deliberate: a
9
+ * kill is a safety verb, and a safety verb that needs the counterparty's cooperation is not one. But
10
+ * a peer who is never told keeps publishing into a document that will never answer. Their updates
11
+ * are refused at the far end forever, and nothing on their screen explains why. So the notification
12
+ * is REQUIRED to be attempted and ALLOWED to fail, and the operator is told which happened.
13
+ *
14
+ * ── CLOSE AND KILL ARE DIFFERENT FRAMES OF THE SAME SHAPE ─────────────────────────────────────
15
+ *
16
+ * `close` is "I am done with this, and I expect you are too" — the document settles when both sides
17
+ * have said it. `kill` is "this is over now", one-sided and immediate. They travel as one frame with
18
+ * a verb rather than two types because the receiving side's routing, verification and settle-once
19
+ * rules are identical, and two decoders for one shape is how the rules drift apart.
20
+ *
21
+ * The verb is REFUSED BY VALUE on decode. A third verb from a future build must not be admitted as
22
+ * one of these two — a `kill` silently read as a `close` would leave a killed document waiting for
23
+ * a reciprocal close that is never coming.
24
+ *
25
+ * ── WHY IT IS SIGNED ──────────────────────────────────────────────────────────────────────────
26
+ *
27
+ * A kill frame ends a collaboration. Unsigned, anyone reaching the channel could end any document
28
+ * between any two parties, and each operator would believe the other walked away. The signature
29
+ * covers the document id — which commits to both parties, the properties and the nonce — and the
30
+ * verb, because the whole statement is the claim.
31
+ */
32
+ /** Domain tag in slot 0. Distinct from every other document domain. */
33
+ export declare const DOCUMENT_CONTROL_DOMAIN = "CELLO-DOCUMENT-CONTROL-v1";
34
+ /** The frame version, ON THE WIRE, so skew is DETECTED rather than misread as a bad signature. */
35
+ export declare const DOCUMENT_CONTROL_VERSION = 1;
36
+ /** Peer-controlled display text bound for an operator's screen. Capped for that reason. */
37
+ export declare const MAX_CONTROL_REASON_LENGTH = 200;
38
+ /** The two ways a document ends. Closed set — see the header on refusing a third by value. */
39
+ export declare const DOCUMENT_CONTROL_VERBS: readonly ["close", "kill"];
40
+ export type DocumentControlVerb = (typeof DOCUMENT_CONTROL_VERBS)[number];
41
+ export interface DocumentControl {
42
+ type: "document_control";
43
+ control_version: number;
44
+ document_id: string;
45
+ /** Who is ending it. */
46
+ sender_agent_id: string;
47
+ verb: DocumentControlVerb;
48
+ /** Optional, and optional for both verbs — an end is a decision, not something one must justify. */
49
+ reason?: string;
50
+ sent_at_ms: number;
51
+ /** Ed25519 (RFC 8032) over `buildDocumentControlTbs`. */
52
+ signature: Uint8Array;
53
+ }
54
+ export declare function assertDocumentControlConsistent(control: DocumentControl): void;
55
+ /**
56
+ * The canonical to-be-signed preimage: a fixed-order CBOR ARRAY with the domain in slot 0.
57
+ *
58
+ * An array rather than a map for the reason `cbor.ts` gives — this encoder is deliberately not
59
+ * deterministic for maps, so a map preimage would make the signature depend on the order the sender
60
+ * happened to build the object in, and two honest implementations would disagree.
61
+ */
62
+ export declare function buildDocumentControlTbs(control: DocumentControl, opts?: {
63
+ preHash?: boolean;
64
+ }): Uint8Array;
65
+ export declare function encodeDocumentControl(control: DocumentControl): Uint8Array;
66
+ /**
67
+ * Decode and validate. Refuses rather than defaulting on every field.
68
+ *
69
+ * The one that matters most is `verb`. Defaulted or coerced, a `kill` read as a `close` leaves a
70
+ * killed document waiting for a reciprocal close that is never coming — the operator sees a
71
+ * collaboration that will not settle and no reason anywhere for why.
72
+ */
73
+ export declare function decodeDocumentControl(bytes: Uint8Array): DocumentControl;
74
+ //# sourceMappingURL=document-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-control.d.ts","sourceRoot":"","sources":["../src/document-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,kGAAkG;AAClG,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,2FAA2F;AAC3F,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,4BAA6B,CAAC;AACjE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,oGAAoG;IACpG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,SAAS,EAAE,UAAU,CAAC;CACvB;AAMD,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAgB9E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EACxB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/B,UAAU,CAoBZ;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,UAAU,CAY1E;AASD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAiExE"}