# Versioned API repair example

This is an owned test fixture with a public demo key. It shows a client repair across two made-up API versions. It is not a customer case or a live third-party API.

Download the source folder and run with Bun:

```sh
bun verify.ts
```

The test starts a server on a random loopback port and stops it when finished. It sends no requests outside `127.0.0.1`.

## What changes

| Rule | Version 1 | Version 2 |
|---|---|---|
| Path | `/v1/search` | `/v2/search` |
| Body | `{"query":"café"}` | `{"search":{"term":"café"},"limit":2}` |
| Signature input | Exact body text | Method, path, nonce and SHA-256 body digest, joined with newlines |
| Nonce | Unused by the verifier | Required and accepted once |

Both versions use HMAC-SHA256 with the public fixture key. Version 2 binds the signature to the path, nonce and exact body bytes.

## Checks

1. The version 1 client works against version 1.
2. It receives 404 after the server changes to version 2.
3. Changing only the route receives 403.
4. The repaired client returns the expected record.
5. Reusing the nonce receives 409.
6. A changed input with a fresh nonce succeeds.
7. Changing the body after signing receives 403.
8. A correctly signed old body schema receives 422.

The server computes its expected signature separately from the client's builder. The fixture tests protocol changes and regression behavior. Its in-memory nonce store is test state, not a production replay store.
