@openvtc/trust-tasks 0.12.16 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +27 -3
  2. package/dist/_runtime/canonical.d.ts +40 -0
  3. package/dist/_runtime/canonical.d.ts.map +1 -0
  4. package/dist/_runtime/canonical.js +147 -0
  5. package/dist/_runtime/canonical.js.map +1 -0
  6. package/dist/_runtime/consume.d.ts +108 -2
  7. package/dist/_runtime/consume.d.ts.map +1 -1
  8. package/dist/_runtime/consume.js +174 -8
  9. package/dist/_runtime/consume.js.map +1 -1
  10. package/dist/_runtime/document.d.ts +17 -4
  11. package/dist/_runtime/document.d.ts.map +1 -1
  12. package/dist/_runtime/document.js +17 -4
  13. package/dist/_runtime/document.js.map +1 -1
  14. package/dist/_runtime/freshness.d.ts +105 -0
  15. package/dist/_runtime/freshness.d.ts.map +1 -0
  16. package/dist/_runtime/freshness.js +142 -0
  17. package/dist/_runtime/freshness.js.map +1 -0
  18. package/dist/_runtime/index.d.ts +4 -1
  19. package/dist/_runtime/index.d.ts.map +1 -1
  20. package/dist/_runtime/index.js +4 -1
  21. package/dist/_runtime/index.js.map +1 -1
  22. package/dist/_runtime/replay.d.ts +176 -0
  23. package/dist/_runtime/replay.d.ts.map +1 -0
  24. package/dist/_runtime/replay.js +147 -0
  25. package/dist/_runtime/replay.js.map +1 -0
  26. package/dist/keys/create/0.1/payload.d.ts +27 -13
  27. package/dist/keys/create/0.1/payload.d.ts.map +1 -1
  28. package/dist/keys/create/0.1/payload.js +11 -5
  29. package/dist/keys/create/0.1/payload.js.map +1 -1
  30. package/dist/keys/import/0.1/payload.d.ts +10 -10
  31. package/dist/keys/import/0.1/payload.d.ts.map +1 -1
  32. package/dist/keys/import/0.1/payload.js +6 -4
  33. package/dist/keys/import/0.1/payload.js.map +1 -1
  34. package/dist/keys/list/0.1/payload.d.ts +10 -10
  35. package/dist/keys/list/0.1/payload.d.ts.map +1 -1
  36. package/dist/keys/list/0.1/payload.js +6 -4
  37. package/dist/keys/list/0.1/payload.js.map +1 -1
  38. package/dist/keys/show/0.1/payload.d.ts +10 -10
  39. package/dist/keys/show/0.1/payload.d.ts.map +1 -1
  40. package/dist/keys/show/0.1/payload.js +6 -4
  41. package/dist/keys/show/0.1/payload.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/_runtime/canonical.ts +159 -0
  44. package/src/_runtime/consume.ts +267 -10
  45. package/src/_runtime/document.ts +17 -4
  46. package/src/_runtime/freshness.ts +183 -0
  47. package/src/_runtime/index.ts +30 -0
  48. package/src/_runtime/replay.ts +250 -0
  49. package/src/keys/create/0.1/payload.ts +20 -8
  50. package/src/keys/import/0.1/payload.ts +8 -6
  51. package/src/keys/list/0.1/payload.ts +8 -6
  52. package/src/keys/show/0.1/payload.ts +8 -6
package/README.md CHANGED
@@ -94,22 +94,32 @@ and audience binding — are declared *per specification* and cannot be derived
94
94
  from the document itself, so every generated module exports the declarations as
95
95
  `SPEC` (and `RESPONSE_SPEC`, where the spec defines a response).
96
96
 
97
- `consumeInbound` runs items 4–8 and then calls your handler. Items 1–3
98
- (framework schema, payload schema, unknown `type`) belong to your parse and
99
- dispatch, and have already succeeded by the time you hold a typed document.
97
+ `consumeInbound` runs item 2 and items 4–8, the freshness bound, and item 11's
98
+ duplicate-execution record, then calls your handler. Items 1 and 3 (framework
99
+ schema, unknown `type`) belong to your parse and dispatch, and have already
100
+ succeeded by the time you hold a typed document.
100
101
 
101
102
  ```ts
102
103
  import {
104
+ consequentialChecks,
103
105
  consumeInbound,
106
+ InMemoryReplayGuard,
104
107
  respondWith,
105
108
  StaticTransport,
106
109
  AclGrant_v0_1,
107
110
  } from "@openvtc/trust-tasks";
108
111
 
112
+ // The guard *is* the duplicate-execution record — one per consumer, held for
113
+ // the process's lifetime. Back it with a shared store if you run replicas.
114
+ const guard = new InMemoryReplayGuard();
115
+
109
116
  const outcome = await consumeInbound<AclGrant_v0_1.Payload, AclGrant_v0_1.Response>({
110
117
  transport: new StaticTransport({ issuer: peerVid }), // what the transport authenticated
111
118
  spec: AclGrant_v0_1.SPEC,
112
119
  proofPolicy: { kind: "verify", verify: myVerifier },
120
+ payloadPolicy: { kind: "validate", validate: myValidator }, // or acceptUnvalidated
121
+ // acl/grant is consequential: a replayed envelope must not grant twice.
122
+ checks: consequentialChecks(guard), // or notConsequentialChecks()
113
123
  doc,
114
124
  myVid: "did:web:maintainer.example",
115
125
  now: Date.now(),
@@ -128,9 +138,23 @@ switch (outcome.kind) {
128
138
  // anything here would be an oracle. Log it — silent is the rule, invisible
129
139
  // is a footgun.
130
140
  return log(outcome.reason);
141
+ case "duplicate":
142
+ // §7.2 item 11: this document already executed. Not an error — return the
143
+ // prior result where there is one, otherwise emit nothing.
144
+ return outcome.priorResponse === undefined ? undefined : send(outcome.priorResponse);
145
+ case "accepted":
146
+ return undefined; // fire-and-forget: nothing to emit
131
147
  }
132
148
  ```
133
149
 
150
+ **Choose the checks deliberately.** `consequentialChecks(guard)` is correct for
151
+ any task whose execution grants access, moves value, discloses a secret, or is
152
+ otherwise irreversible — SPEC §7.2 item 11 makes duplicate-execution protection
153
+ normative for those, and every transport binding delegates it to the consumer.
154
+ `notConsequentialChecks()` keeps no record and is conformant only where the task
155
+ is not consequential, or where the specification declares repeated execution
156
+ safe and intended.
157
+
134
158
  **Choose a proof policy deliberately.** `{ kind: "verify" }` honours in-band
135
159
  proofs. `{ kind: "rejectIfPresent" }` is for consumers with integrity from
136
160
  another layer — it refuses a proof-bearing document rather than silently
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Deterministic document serialization and the SHA-256 digest over it.
3
+ *
4
+ * Mirrors `canonical.rs` in trust-tasks-rs. SPEC §7.2 (*Keying and comparison
5
+ * for item 11*) defines two documents sharing an `id` as **the same document**
6
+ * when their serializations are identical under RFC 8785 canonicalization —
7
+ * the same identity §8.4 gives a retry. A consumer implementing item 11 has to
8
+ * retain a digest of what it accepted, not merely the `id`.
9
+ *
10
+ * `canonicalJson` here is closer to literal RFC 8785 than the Rust side is,
11
+ * because JavaScript's own primitives are what JCS was specified against:
12
+ * `Array.prototype.sort()` orders by UTF-16 code unit, and `JSON.stringify`
13
+ * formats numbers with `Number::toString` and escapes strings with exactly the
14
+ * §3.2.2.2 escape set. The only thing this adds is recursive member ordering.
15
+ *
16
+ * The item-11 digest is **consumer-local**: it goes into this consumer's own
17
+ * replay record and never onto the wire, into a citation, or into a proof. It
18
+ * is *not* the §4.9.3 task digest, which is computed over `document ∖ proof`
19
+ * and is a published, multibase-encoded multihash. See `replay.ts`.
20
+ *
21
+ * Hand-written, and dependency-free on purpose: this package ships no runtime
22
+ * dependencies, and `node:crypto` would not resolve in a browser or a worker.
23
+ */
24
+ /**
25
+ * Serialize `value` with object members recursively ordered and no
26
+ * insignificant whitespace.
27
+ *
28
+ * `undefined` members are omitted, as `JSON.stringify` omits them — which is
29
+ * what makes this agree with the document as it would be sent.
30
+ */
31
+ export declare function canonicalJson(value: unknown): string;
32
+ /**
33
+ * FIPS 180-4 SHA-256 over the UTF-8 encoding of `input`, as lowercase hex.
34
+ *
35
+ * Synchronous by necessity: `crypto.subtle.digest` is a Promise, and the
36
+ * consume pipeline needs the digest before it decides whether to await
37
+ * anything. Pinned to the standard's published vectors in `test/`.
38
+ */
39
+ export declare function sha256Hex(input: string): string;
40
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/_runtime/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWpD;AAyDD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoD/C"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Deterministic document serialization and the SHA-256 digest over it.
3
+ *
4
+ * Mirrors `canonical.rs` in trust-tasks-rs. SPEC §7.2 (*Keying and comparison
5
+ * for item 11*) defines two documents sharing an `id` as **the same document**
6
+ * when their serializations are identical under RFC 8785 canonicalization —
7
+ * the same identity §8.4 gives a retry. A consumer implementing item 11 has to
8
+ * retain a digest of what it accepted, not merely the `id`.
9
+ *
10
+ * `canonicalJson` here is closer to literal RFC 8785 than the Rust side is,
11
+ * because JavaScript's own primitives are what JCS was specified against:
12
+ * `Array.prototype.sort()` orders by UTF-16 code unit, and `JSON.stringify`
13
+ * formats numbers with `Number::toString` and escapes strings with exactly the
14
+ * §3.2.2.2 escape set. The only thing this adds is recursive member ordering.
15
+ *
16
+ * The item-11 digest is **consumer-local**: it goes into this consumer's own
17
+ * replay record and never onto the wire, into a citation, or into a proof. It
18
+ * is *not* the §4.9.3 task digest, which is computed over `document ∖ proof`
19
+ * and is a published, multibase-encoded multihash. See `replay.ts`.
20
+ *
21
+ * Hand-written, and dependency-free on purpose: this package ships no runtime
22
+ * dependencies, and `node:crypto` would not resolve in a browser or a worker.
23
+ */
24
+ /**
25
+ * Serialize `value` with object members recursively ordered and no
26
+ * insignificant whitespace.
27
+ *
28
+ * `undefined` members are omitted, as `JSON.stringify` omits them — which is
29
+ * what makes this agree with the document as it would be sent.
30
+ */
31
+ export function canonicalJson(value) {
32
+ if (value === null || typeof value !== "object")
33
+ return JSON.stringify(value) ?? "null";
34
+ if (Array.isArray(value))
35
+ return `[${value.map((v) => canonicalJson(v)).join(",")}]`;
36
+ const entries = Object.entries(value)
37
+ .filter(([, v]) => v !== undefined)
38
+ // RFC 8785 §3.2.3: sort by UTF-16 code unit, which is what the default
39
+ // comparator does after String() — and these are already strings.
40
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
41
+ return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(",")}}`;
42
+ }
43
+ const K = new Uint32Array([
44
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
45
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
46
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
47
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
48
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
49
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
50
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
51
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
52
+ ]);
53
+ const rotr = (x, n) => (x >>> n) | (x << (32 - n));
54
+ /**
55
+ * UTF-8 encode `s`, without `TextEncoder`.
56
+ *
57
+ * `TextEncoder` is a host global, not an ES2022 one: this package's `lib` is
58
+ * `["ES2022"]` and adding `DOM` to reach one name would pull the whole browser
59
+ * surface into a package that must also typecheck for Node and for workers.
60
+ * Fifteen lines is the cheaper price.
61
+ *
62
+ * Unpaired surrogates — which `JSON.parse` will produce from a `\uD800` escape
63
+ * — encode as U+FFFD, matching `TextEncoder`. Two documents differing only in
64
+ * an unpaired surrogate would therefore collide; they are not valid JSON text
65
+ * to begin with, and the collision absorbs a duplicate rather than executing
66
+ * one, so it fails safe.
67
+ */
68
+ function utf8(s) {
69
+ const out = [];
70
+ for (let i = 0; i < s.length; i++) {
71
+ let cp = s.charCodeAt(i);
72
+ if (cp >= 0xd800 && cp <= 0xdbff && i + 1 < s.length) {
73
+ const low = s.charCodeAt(i + 1);
74
+ if (low >= 0xdc00 && low <= 0xdfff) {
75
+ cp = 0x10000 + ((cp - 0xd800) << 10) + (low - 0xdc00);
76
+ i++;
77
+ }
78
+ }
79
+ if (cp >= 0xd800 && cp <= 0xdfff)
80
+ cp = 0xfffd; // unpaired surrogate
81
+ if (cp < 0x80)
82
+ out.push(cp);
83
+ else if (cp < 0x800)
84
+ out.push(0xc0 | (cp >> 6), 0x80 | (cp & 0x3f));
85
+ else if (cp < 0x10000)
86
+ out.push(0xe0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
87
+ else
88
+ out.push(0xf0 | (cp >> 18), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
89
+ }
90
+ return Uint8Array.from(out);
91
+ }
92
+ /**
93
+ * FIPS 180-4 SHA-256 over the UTF-8 encoding of `input`, as lowercase hex.
94
+ *
95
+ * Synchronous by necessity: `crypto.subtle.digest` is a Promise, and the
96
+ * consume pipeline needs the digest before it decides whether to await
97
+ * anything. Pinned to the standard's published vectors in `test/`.
98
+ */
99
+ export function sha256Hex(input) {
100
+ const bytes = utf8(input);
101
+ const bitLen = bytes.length * 8;
102
+ // Pad to a multiple of 64 bytes: 0x80, zeroes, then the 64-bit big-endian
103
+ // bit length.
104
+ const padded = new Uint8Array(Math.ceil((bytes.length + 9) / 64) * 64);
105
+ padded.set(bytes);
106
+ padded[bytes.length] = 0x80;
107
+ const view = new DataView(padded.buffer);
108
+ // Lengths above 2^53 bits are unreachable from a JS string; the high word is
109
+ // written anyway so the padding is well-formed.
110
+ view.setUint32(padded.length - 8, Math.floor(bitLen / 0x100000000), false);
111
+ view.setUint32(padded.length - 4, bitLen >>> 0, false);
112
+ const h = new Uint32Array([
113
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
114
+ ]);
115
+ const w = new Uint32Array(64);
116
+ for (let offset = 0; offset < padded.length; offset += 64) {
117
+ for (let i = 0; i < 16; i++)
118
+ w[i] = view.getUint32(offset + i * 4, false);
119
+ for (let i = 16; i < 64; i++) {
120
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
121
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
122
+ w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
123
+ }
124
+ let [a, b, c, d, e, f, g, hh] = [h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7]];
125
+ for (let i = 0; i < 64; i++) {
126
+ const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
127
+ const ch = (e & f) ^ (~e & g);
128
+ const temp1 = (hh + s1 + ch + K[i] + w[i]) >>> 0;
129
+ const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
130
+ const maj = (a & b) ^ (a & c) ^ (b & c);
131
+ const temp2 = (s0 + maj) >>> 0;
132
+ hh = g;
133
+ g = f;
134
+ f = e;
135
+ e = (d + temp1) >>> 0;
136
+ d = c;
137
+ c = b;
138
+ b = a;
139
+ a = (temp1 + temp2) >>> 0;
140
+ }
141
+ const next = [a, b, c, d, e, f, g, hh];
142
+ for (let i = 0; i < 8; i++)
143
+ h[i] = (h[i] + next[i]) >>> 0;
144
+ }
145
+ return Array.from(h, (word) => word.toString(16).padStart(8, "0")).join("");
146
+ }
147
+ //# sourceMappingURL=canonical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.js","sourceRoot":"","sources":["../../src/_runtime/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C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G,CAAC,EAAE,CAAC,EAAE;YAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC"}
@@ -1,12 +1,20 @@
1
1
  /**
2
- * Inbound-document orchestration for SPEC.md §7.2 item 2 and items 4–8.
2
+ * Inbound-document orchestration for SPEC.md §7.2 item 2, items 4–8, and the
3
+ * two stateful checks — the freshness bound of item 4 and the
4
+ * duplicate-execution record of item 11.
3
5
  *
4
6
  * Hand-written. Mirrors `consume.rs` in trust-tasks-rs, deliberately closely:
5
7
  * a TypeScript consumer and a Rust one must reach the same verdict on the same
6
8
  * document, or the two reference implementations disagree about what conforms.
7
9
  *
8
10
  * ```ts
9
- * import { consumeInbound, StaticTransport, AclGrant_v0_1 } from "@openvtc/trust-tasks";
11
+ * import {
12
+ * consequentialChecks, consumeInbound, InMemoryReplayGuard,
13
+ * StaticTransport, AclGrant_v0_1,
14
+ * } from "@openvtc/trust-tasks";
15
+ *
16
+ * // One guard per consumer, not one per document: it *is* the record.
17
+ * const guard = new InMemoryReplayGuard();
10
18
  *
11
19
  * const outcome = await consumeInbound({
12
20
  * transport,
@@ -14,6 +22,8 @@
14
22
  * proofPolicy: { kind: "verify", verify: myVerifier },
15
23
  * // ajv, or whatever validator you already run — see PayloadPolicy.
16
24
  * payloadPolicy: { kind: "validate", validate: myValidator },
25
+ * // acl/grant is consequential: a replayed envelope must not grant twice.
26
+ * checks: consequentialChecks(guard),
17
27
  * doc,
18
28
  * myVid: "did:web:maintainer.example",
19
29
  * now: Date.now(),
@@ -27,6 +37,11 @@
27
37
  * case "rejected": emit(outcome.error); break;
28
38
  * case "suppressed": logSuppressed(); break;
29
39
  * case "accepted": break; // fire-and-forget: nothing to emit
40
+ * // §7.2 item 11: already executed. Not an error — return the prior result
41
+ * // if there is one, otherwise emit nothing.
42
+ * case "duplicate":
43
+ * if (outcome.priorResponse !== undefined) emit(outcome.priorResponse);
44
+ * break;
30
45
  * }
31
46
  * ```
32
47
  *
@@ -45,7 +60,49 @@
45
60
  * `payloadPolicy` decides what to do with it. See {@link PayloadPolicy}.
46
61
  */
47
62
  import { type ErrorResponse, type RejectReason, type SpecPolicy, type TrustTaskDocument } from "./document.js";
63
+ import { type FreshnessPolicy } from "./freshness.js";
64
+ import { type ReplayGuard, type ReplayPolicy } from "./replay.js";
48
65
  import { type ResolvedParties, type TransportHandler } from "./transport.js";
66
+ /**
67
+ * The two stateful §7.2 checks: the freshness bound over `issuedAt` /
68
+ * `expiresAt`, and the duplicate-execution record of item 11.
69
+ *
70
+ * They travel together because the spec ties them together. §7.2 (*Bounding
71
+ * the record*) makes the acceptance window and the record's retention **the
72
+ * same bound**. Passing them as one option is what stops a deployment
73
+ * configuring a five-minute record and an unbounded acceptance window, which
74
+ * reads as a working replay defence and is not one.
75
+ *
76
+ * Like {@link PayloadPolicy}, this is a *required* option. Whether the task a
77
+ * consumer implements is *consequential* (§2) is a decision only that consumer
78
+ * can make, and the failure mode of getting it wrong silently — an ACL grant
79
+ * applied twice by a mediator retry — is not one to discover after the fact.
80
+ */
81
+ export interface ConsumeChecks {
82
+ /** Bounds the document in time (SPEC §4.2, §7.2 item 4). */
83
+ readonly freshness: FreshnessPolicy;
84
+ /** Applies (or knowingly disapplies) SPEC §7.2 item 11. */
85
+ readonly replay: ReplayPolicy;
86
+ }
87
+ /**
88
+ * The posture for a *consequential Trust Task* (§2): item 11 enforced against
89
+ * `guard`, and the bounded acceptance window that makes the record droppable.
90
+ *
91
+ * The right choice for any task whose execution grants access, moves value,
92
+ * discloses a secret, or otherwise cannot be undone by ignoring the next
93
+ * document.
94
+ */
95
+ export declare function consequentialChecks(guard: ReplayGuard): ConsumeChecks;
96
+ /**
97
+ * The posture for a task that is **not** consequential, or whose specification
98
+ * "explicitly declares repeated execution safe and intended" — the narrow
99
+ * disapplication item 11 permits.
100
+ *
101
+ * Keeps no record. Still applies the default freshness policy, because a
102
+ * future-dated document and one with an empty validity interval are malformed
103
+ * whatever the task does.
104
+ */
105
+ export declare function notConsequentialChecks(): ConsumeChecks;
49
106
  /** Verifies a document's Data Integrity proof (SPEC §4.7). */
50
107
  export interface ProofVerifier {
51
108
  /** Resolve to `true` when the proof verifies against the in-band `issuer`. */
@@ -175,6 +232,35 @@ export type ConsumeOutcome<R> =
175
232
  */
176
233
  | {
177
234
  kind: "accepted";
235
+ }
236
+ /**
237
+ * SPEC §7.2 item 11: a document with this `id` and this content was already
238
+ * accepted for execution. **The handler was not called**, and the
239
+ * consequential effect did not happen a second time. This is the §8.4 retry
240
+ * being absorbed, which is what makes retrying safe.
241
+ *
242
+ * **Not an error.** §7.2 (*Disposition of a duplicate*): "In no case is a
243
+ * duplicate reported as `taskFailed`; the task did not fail, it already
244
+ * happened." Folding this into `rejected` would report a failure that did
245
+ * not occur.
246
+ *
247
+ * What to emit:
248
+ *
249
+ * - `priorResponse` present — emit it. It is the response document the first
250
+ * execution produced (a success response, or a non-retryable error
251
+ * response; tell them apart by its `type`), which §7.2 says the consumer
252
+ * SHOULD return.
253
+ * - `priorResponse` absent, `inFlight === false` — the specification defines
254
+ * no success response (§4.4.1 fire-and-forget), or the guard retains none.
255
+ * Emit nothing: that silence is the correct disposition, not an error.
256
+ * - `inFlight === true` — the first execution has not finished. §7.2: the
257
+ * consumer SHOULD "return or expose the existing execution state rather
258
+ * than begin another".
259
+ */
260
+ | {
261
+ kind: "duplicate";
262
+ priorResponse?: unknown;
263
+ inFlight: boolean;
178
264
  };
179
265
  /** Wire-safe message for the `rejectIfPresent` path. */
180
266
  export declare const PROOF_NOT_ACCEPTED_BY_POLICY = "in-band proof not accepted by consumer policy (SPEC \u00A77.2 item 7)";
@@ -185,6 +271,12 @@ export interface ConsumeOptions<P, R> {
185
271
  proofPolicy: ProofPolicy;
186
272
  /** §7.2 item 2. Required — see {@link PayloadPolicy} for why. */
187
273
  payloadPolicy: PayloadPolicy;
274
+ /**
275
+ * §7.2 item 4 (freshness) and item 11 (duplicate execution). Required — see
276
+ * {@link ConsumeChecks}. Use {@link consequentialChecks} or
277
+ * {@link notConsequentialChecks}.
278
+ */
279
+ checks: ConsumeChecks;
188
280
  doc: TrustTaskDocument<P>;
189
281
  /** This consumer's own VID, for the §7.2 item 5 recipient check. */
190
282
  myVid: string;
@@ -214,6 +306,20 @@ export interface ConsumeOptions<P, R> {
214
306
  * safe for ordinary refusals but not for one that contests that identity.
215
307
  */
216
308
  export declare function consumeInbound<P, R>(opts: ConsumeOptions<P, R>): Promise<ConsumeOutcome<R>>;
309
+ /**
310
+ * Wire message for `proofInvalid`.
311
+ *
312
+ * Constant by design — see the §10.4 note at the rejection site. The Rust
313
+ * counterpart is `PROOF_INVALID_WIRE_MESSAGE` in `trust-tasks-rs`, kept equal.
314
+ */
315
+ export declare const PROOF_INVALID_WIRE_MESSAGE = "proof verification failed";
316
+ /** Wire message for `idConflict` (SPEC §7.2 item 11, §8.3). */
317
+ export declare const ID_CONFLICT_WIRE_MESSAGE = "a different document has already been accepted under this id (SPEC \u00A77.2 item 11)";
318
+ /**
319
+ * Wire message for a replay-record outage. A constant, so a store's hostname
320
+ * or connection string never reaches the wire (SPEC §10.4).
321
+ */
322
+ export declare const REPLAY_RECORD_UNAVAILABLE = "temporarily unavailable";
217
323
  /**
218
324
  * Build a handler-side refusal addressed to the original producer.
219
325
  *
@@ -1 +1 @@
1
- {"version":3,"file":"consume.d.ts","sourceRoot":"","sources":["../../src/_runtime/consume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAA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