@forestrie/receipt-verify 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,10 +31,14 @@ export type ParsedCheckpoint = {
31
31
  /**
32
32
  * Sealed tree size: the SIGNED `tree-size-2` from the checkpoint's
33
33
  * PROTECTED header (ADR-0066 D1 as amended, label -65933), not the
34
- * unprotected consistency proof's declared value. `null` when the
35
- * checkpoint carries no embedded consistency proof or no signed
36
- * tree-size-2 — such a checkpoint is not verifiable and callers must
37
- * treat it exactly as they would a checkpoint with no proof at all.
34
+ * unprotected consistency proof's declared value. `null` ONLY when the
35
+ * checkpoint is genuinely unsealed — no embedded consistency proof, or a
36
+ * well-formed protected header with no signed tree-size-2 label — and
37
+ * callers must treat that the same as a checkpoint with no proof at all.
38
+ * A structurally malformed consistency proof, or a protected header that
39
+ * is not deterministically encoded (ADR-0066 D9), is a DIFFERENT
40
+ * condition — {@link parseCheckpoint} throws for those rather than
41
+ * folding them into this `null` (review finding O3).
38
42
  */
39
43
  mmrSize: bigint | null;
40
44
  delegationCert: Uint8Array | null;
@@ -1 +1 @@
1
- {"version":3,"file":"build-receipt-offline.d.ts","sourceRoot":"","sources":["../src/build-receipt-offline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAIL,mBAAmB,EAEnB,KAAK,eAAe,EAErB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAO5B;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,oEAAoE;IACpE,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,CA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21 @@ function cborBytes(value) {
166
166
  * validating decode that requires the signed size and the last relayed
167
167
  * proof's to agree.
168
168
  *
169
- * Lenient by design: an absent proof, an empty or malformed
170
- * consistency-proofs array, or an absent or malformed signed tree-size-2
171
- * all yield `null` rather than a throw, so a caller of
172
- * {@link parseCheckpoint} sees exactly the same "not verifiable" outcome
173
- * either way.
169
+ * Lenient only for an ABSENT proof or an absent signed tree-size-2: both
170
+ * yield `null`, so a caller of {@link parseCheckpoint} sees the same "not
171
+ * verifiable" outcome for either. A proof or protected header that IS
172
+ * present but malformed is a different condition and is not swallowed here
173
+ * — {@link decodeConsistencyProofsFromUnprotected} throws for a structurally
174
+ * malformed proof (including an empty consistency-proofs array), and
175
+ * {@link readProtectedTreeSize2} throws for a protected header that is not
176
+ * deterministically encoded (ADR-0066 D9); both propagate rather than
177
+ * folding into `null` (review finding O3: a D9 conformance failure is a
178
+ * sealer-side defect worth attributing, not the ordinary "no proof yet"
179
+ * case).
174
180
  */
175
181
  function sealedSizeFromCheckpoint(coseSign1, unprotected) {
176
- let declared;
177
- try {
178
- declared = decodeConsistencyProofsFromUnprotected(unprotected);
179
- }
180
- catch {
181
- return null;
182
- }
182
+ const declared = decodeConsistencyProofsFromUnprotected(unprotected);
183
183
  if (declared === null)
184
184
  return null;
185
- try {
186
- return readProtectedTreeSize2(coseSign1[0]);
187
- }
188
- catch {
189
- return null;
190
- }
185
+ return readProtectedTreeSize2(coseSign1[0]);
191
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forestrie/receipt-verify",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Offline SCITT grant receipt verification (ADR-0045)",
@@ -28,9 +28,9 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@noble/hashes": "^1.7.1",
31
+ "@forestrie/chain-rpc": "0.3.0",
31
32
  "@forestrie/encoding": "0.9.1",
32
- "@forestrie/merklelog": "0.5.0",
33
- "@forestrie/chain-rpc": "0.3.0"
33
+ "@forestrie/merklelog": "0.5.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "esbuild": "^0.24.0",
@@ -59,10 +59,14 @@ export type ParsedCheckpoint = {
59
59
  /**
60
60
  * Sealed tree size: the SIGNED `tree-size-2` from the checkpoint's
61
61
  * PROTECTED header (ADR-0066 D1 as amended, label -65933), not the
62
- * unprotected consistency proof's declared value. `null` when the
63
- * checkpoint carries no embedded consistency proof or no signed
64
- * tree-size-2 — such a checkpoint is not verifiable and callers must
65
- * treat it exactly as they would a checkpoint with no proof at all.
62
+ * unprotected consistency proof's declared value. `null` ONLY when the
63
+ * checkpoint is genuinely unsealed — no embedded consistency proof, or a
64
+ * well-formed protected header with no signed tree-size-2 label — and
65
+ * callers must treat that the same as a checkpoint with no proof at all.
66
+ * A structurally malformed consistency proof, or a protected header that
67
+ * is not deterministically encoded (ADR-0066 D9), is a DIFFERENT
68
+ * condition — {@link parseCheckpoint} throws for those rather than
69
+ * folding them into this `null` (review finding O3).
66
70
  */
67
71
  mmrSize: bigint | null;
68
72
  delegationCert: Uint8Array | null;
@@ -273,26 +277,23 @@ function cborBytes(value: unknown): Uint8Array {
273
277
  * validating decode that requires the signed size and the last relayed
274
278
  * proof's to agree.
275
279
  *
276
- * Lenient by design: an absent proof, an empty or malformed
277
- * consistency-proofs array, or an absent or malformed signed tree-size-2
278
- * all yield `null` rather than a throw, so a caller of
279
- * {@link parseCheckpoint} sees exactly the same "not verifiable" outcome
280
- * either way.
280
+ * Lenient only for an ABSENT proof or an absent signed tree-size-2: both
281
+ * yield `null`, so a caller of {@link parseCheckpoint} sees the same "not
282
+ * verifiable" outcome for either. A proof or protected header that IS
283
+ * present but malformed is a different condition and is not swallowed here
284
+ * — {@link decodeConsistencyProofsFromUnprotected} throws for a structurally
285
+ * malformed proof (including an empty consistency-proofs array), and
286
+ * {@link readProtectedTreeSize2} throws for a protected header that is not
287
+ * deterministically encoded (ADR-0066 D9); both propagate rather than
288
+ * folding into `null` (review finding O3: a D9 conformance failure is a
289
+ * sealer-side defect worth attributing, not the ordinary "no proof yet"
290
+ * case).
281
291
  */
282
292
  function sealedSizeFromCheckpoint(
283
293
  coseSign1: CoseSign1,
284
294
  unprotected: Map<number, unknown>,
285
295
  ): bigint | null {
286
- let declared;
287
- try {
288
- declared = decodeConsistencyProofsFromUnprotected(unprotected);
289
- } catch {
290
- return null;
291
- }
296
+ const declared = decodeConsistencyProofsFromUnprotected(unprotected);
292
297
  if (declared === null) return null;
293
- try {
294
- return readProtectedTreeSize2(coseSign1[0]);
295
- } catch {
296
- return null;
297
- }
298
+ return readProtectedTreeSize2(coseSign1[0]);
298
299
  }