ReviewOS

also looking at this

stacks/tuf-js

feat: observe verified metadata before persistence

#1
Merged chris wants to merge codex/verified-metadata-source into main
8 files +807 -21
packages/client/README.mdmodified+28-0
Changes to packages/client/README.md
@@ -1,3 +1,31 @@
11# tuf-js
22
33JavaScript TUF client implementation.
4
5## Verified metadata observation
6
7This source branch adds optional `UpdaterOptions.onVerifiedMetadata(role, bytes)`.
8The updater awaits the observer after metadata verification and before its cache
9write or the next metadata request. Each call receives an owned byte copy. A
10rejection becomes `PersistError` with its exact original cause and aborts the
11refresh. Persistence failures are never interpreted as a missing root or a
12cache miss, including with `forceCache`.
13
14`UpdaterOptions.referenceTime` accepts a finite `Date` and copies its value at
15construction. Omitting it preserves the normal fixed update-start time. This
16option supports recovery replay; it does not establish a trusted clock or
17permit accepting expired metadata at the actual trusted time.
18
19Remote verification failures expose `MetadataVerificationError.role` and retain
20the original failure in `cause`. Download failures and equal-version timestamp
21handling preserve their existing paths. Classify persistence failures before
22examining an observer's nested cause. An observer can reject with any value,
23including another verification error.
24
25Discard an updater after a failed refresh. Observer ordering does not roll back
26its in-memory trust set, make cache writes transactional, or provide a protected
27trust store. Applications must implement those boundaries independently.
28
29These extensions are maintained source changes, not options present in the
30unmodified upstream 6.0.0 package. Release and qualify this source before removing
31an application's legacy distribution patch.