@oked/receipt-core 0.6.20 → 0.6.21
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.
- package/README.md +11 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
# @oked/receipt-core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
and `@oked/verify` (which auditors run). One implementation, so all three
|
|
6
|
-
compute the same bytes and the same digests.
|
|
3
|
+
[](https://www.npmjs.com/package/@oked/receipt-core)
|
|
4
|
+
[](./LICENSE)
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exact action they decided on, and when.
|
|
11
|
-
[docs/receipts.md](https://github.com/oked-ai/oked-sdk/blob/main/docs/receipts.md)
|
|
12
|
-
for the format, what a receipt proves and what it does not.
|
|
6
|
+
The format and the cryptography of OKed signed approval receipts. Shared by the OKed backend (which signs), `@oked/sdk` (which verifies before an action runs), and `@oked/verify` (which auditors run). One implementation, so all three compute the same bytes and the same digests.
|
|
7
|
+
|
|
8
|
+
A receipt is a JSON body signed with Ed25519 over its RFC 8785 canonical form (JCS). It records who decided on an agent action, how they were verified, what exact action they decided on, and when. Check one in the browser at [oked.ai/docs/#verify](https://oked.ai/docs/#verify), or read [docs/receipts.md](https://github.com/oked-ai/oked-sdk/blob/main/docs/receipts.md) for the format, what a receipt proves, and what it does not.
|
|
13
9
|
|
|
14
10
|
```ts
|
|
15
11
|
import { verifyReceipt, verifyChain } from "@oked/receipt-core";
|
|
16
12
|
|
|
17
13
|
const keys = await (await fetch("https://api.oked.ai/.well-known/oked-receipt-keys.json")).json();
|
|
18
14
|
const check = verifyReceipt(receipt, { keys });
|
|
19
|
-
// { ok: true, problems: [] } or
|
|
15
|
+
// { ok: true, problems: [] } or, for example, { ok: false, problems: ["bad_signature"] }
|
|
20
16
|
```
|
|
21
17
|
|
|
22
18
|
| Export | What it does |
|
|
23
19
|
|---|---|
|
|
24
20
|
| `canonicalize(value)` | RFC 8785 JCS. Throws on values JSON cannot carry. |
|
|
25
|
-
| `jsonValue(value)` | The value as the other side of a JSON request sees it (undefined becomes null). |
|
|
21
|
+
| `jsonValue(value)` | The value as the other side of a JSON request sees it (`undefined` becomes `null`). |
|
|
26
22
|
| `subjectDigest(subject)` | `sha256:` digest of what was authorized (`subject_core`). |
|
|
27
23
|
| `displayDigest(shown)` | `sha256:` digest of what the approver was shown. |
|
|
28
|
-
| `bodyDigest(body)` | A receipt body's digest
|
|
29
|
-
| `verifyReceipt(receipt, { keys, subject? })` | Shape, key window, signature and, given the original request, the subject digest. |
|
|
30
|
-
| `verifyChain(receipts, heads?)` |
|
|
24
|
+
| `bodyDigest(body)` | A receipt body's digest. The next receipt's `prev_receipt_digest`. |
|
|
25
|
+
| `verifyReceipt(receipt, { keys, subject? })` | Shape, key window, signature, and, given the original request, the subject digest. |
|
|
26
|
+
| `verifyChain(receipts, heads?)` | Sequence gaps, broken `prev_receipt_digest` links, duplicates, and agreement with saved chain heads. |
|
|
31
27
|
| `signerFromSeed(seed, kid)`, `signBody(body, signer)` | Signing, for the issuer. |
|
|
32
28
|
|
|
33
|
-
Node 18
|
|
29
|
+
Node.js 18 or newer. ESM. No dependencies (uses `node:crypto`). [Apache-2.0](./LICENSE).
|