Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions packages/schema/fixtures/entitlements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,26 @@ authenticates the browser when it returns; nothing in the token grants anything.
| `seat-limit-denial.json` | The 402 body, with and without a configured `PAYMENT_URL` |
| `handoff-claims.json` | The decoded claims inside that `paymentUrl` |
| `usage.json` | `GET /orgs/:id/usage`, with seat gating on and off, and for a subscribed organization |
| `corpus.sha256` | SHA-256 of every other `.json` fixture's filename and exact bytes, in filename order |
| `corpus.sha256` | SHA-256 of every other file in this directory, including this README, by name and exact bytes in filename order |

`corpus.sha256` is `sha256(name₁ ‖ bytes₁ ‖ name₂ ‖ bytes₂ ‖ …)` over the
`.json` files above, sorted by filename, with no separator between the parts:
`corpus.sha256` has exactly one reader: the private billing service keeps a copy
of this directory, and its `test/billing.test.ts` recomputes this digest to prove
the copy is still byte-identical. Nothing in this repository verifies it. The
recipe below is therefore a transcription of that test rather than an
independent definition of the digest — where the two disagree, the test is
right and this section is wrong.

It is `sha256(name₁ ‖ NUL ‖ bytes₁ ‖ NUL ‖ name₂ ‖ NUL ‖ bytes₂ ‖ …)` over every
file here except `corpus.sha256` itself, sorted by filename, with a NUL between
every part and none at the end. This README is in the digest like any other
file, which is what lets the two copies hold the same value when they match:

```sh
( cd packages/schema/fixtures/entitlements
for f in $(ls *.json | LC_ALL=C sort); do printf '%s' "$f"; cat "$f"; done \
| sha256sum | cut -d' ' -f1 )
# Run in the directory that holds these fixtures, in either repository.
python3 -c '
import hashlib, os
names = sorted(n for n in os.listdir(".") if n != "corpus.sha256")
parts = [n.encode() + b"\0" + open(n, "rb").read() for n in names]
print(hashlib.sha256(b"\0".join(parts)).hexdigest())
'
```
2 changes: 1 addition & 1 deletion packages/schema/fixtures/entitlements/corpus.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6d1dc4b930ae17ce9509cbc5ec01bd8379920d421b67bf1915f354ba8137e748
ca619ff2ba7597717cfb235effa5014e280e96f020c2bec064eb5a5a1b8fdca6
Loading