@forestrie/mcp-register 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +126 -2
- package/bin/mcp-register.mjs +2 -0
- package/dist/core/base64.d.ts +7 -0
- package/dist/core/base64.d.ts.map +1 -0
- package/dist/core/base64.js +20 -0
- package/dist/core/base64.js.map +1 -0
- package/dist/core/delegation.d.ts +56 -0
- package/dist/core/delegation.d.ts.map +1 -0
- package/dist/core/delegation.js +130 -0
- package/dist/core/delegation.js.map +1 -0
- package/dist/core/grant.d.ts +41 -0
- package/dist/core/grant.d.ts.map +1 -0
- package/dist/core/grant.js +78 -0
- package/dist/core/grant.js.map +1 -0
- package/dist/core/hex.d.ts +4 -0
- package/dist/core/hex.d.ts.map +1 -0
- package/dist/core/hex.js +18 -0
- package/dist/core/hex.js.map +1 -0
- package/dist/core/index.d.ts +28 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +21 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/issue.d.ts +38 -0
- package/dist/core/issue.d.ts.map +1 -0
- package/dist/core/issue.js +135 -0
- package/dist/core/issue.js.map +1 -0
- package/dist/core/limits.d.ts +9 -0
- package/dist/core/limits.d.ts.map +1 -0
- package/dist/core/limits.js +9 -0
- package/dist/core/limits.js.map +1 -0
- package/dist/core/scrapi.d.ts +66 -0
- package/dist/core/scrapi.d.ts.map +1 -0
- package/dist/core/scrapi.js +174 -0
- package/dist/core/scrapi.js.map +1 -0
- package/dist/core/signer.d.ts +24 -0
- package/dist/core/signer.d.ts.map +1 -0
- package/dist/core/signer.js +2 -0
- package/dist/core/signer.js.map +1 -0
- package/dist/core/statement.d.ts +26 -0
- package/dist/core/statement.d.ts.map +1 -0
- package/dist/core/statement.js +70 -0
- package/dist/core/statement.js.map +1 -0
- package/dist/core/version.d.ts +23 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +23 -0
- package/dist/core/version.js.map +1 -0
- package/dist/core/x402.d.ts +99 -0
- package/dist/core/x402.d.ts.map +1 -0
- package/dist/core/x402.js +202 -0
- package/dist/core/x402.js.map +1 -0
- package/dist/net/delegate.d.ts +56 -0
- package/dist/net/delegate.d.ts.map +1 -0
- package/dist/net/delegate.js +182 -0
- package/dist/net/delegate.js.map +1 -0
- package/dist/net/http.d.ts +17 -0
- package/dist/net/http.d.ts.map +1 -0
- package/dist/net/http.js +52 -0
- package/dist/net/http.js.map +1 -0
- package/dist/net/index.d.ts +14 -0
- package/dist/net/index.d.ts.map +1 -0
- package/dist/net/index.js +13 -0
- package/dist/net/index.js.map +1 -0
- package/dist/net/write.d.ts +55 -0
- package/dist/net/write.d.ts.map +1 -0
- package/dist/net/write.js +46 -0
- package/dist/net/write.js.map +1 -0
- package/dist/node/cli.d.ts +8 -0
- package/dist/node/cli.d.ts.map +1 -0
- package/dist/node/cli.js +143 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/grant-store.d.ts +49 -0
- package/dist/node/grant-store.d.ts.map +1 -0
- package/dist/node/grant-store.js +95 -0
- package/dist/node/grant-store.js.map +1 -0
- package/dist/node/grant-tools.d.ts +29 -0
- package/dist/node/grant-tools.d.ts.map +1 -0
- package/dist/node/grant-tools.js +498 -0
- package/dist/node/grant-tools.js.map +1 -0
- package/dist/node/ledger.d.ts +26 -0
- package/dist/node/ledger.d.ts.map +1 -0
- package/dist/node/ledger.js +78 -0
- package/dist/node/ledger.js.map +1 -0
- package/dist/node/payer.d.ts +48 -0
- package/dist/node/payer.d.ts.map +1 -0
- package/dist/node/payer.js +170 -0
- package/dist/node/payer.js.map +1 -0
- package/dist/node/resolve-input.d.ts +19 -0
- package/dist/node/resolve-input.d.ts.map +1 -0
- package/dist/node/resolve-input.js +76 -0
- package/dist/node/resolve-input.js.map +1 -0
- package/dist/node/server.d.ts +47 -0
- package/dist/node/server.d.ts.map +1 -0
- package/dist/node/server.js +212 -0
- package/dist/node/server.js.map +1 -0
- package/dist/node/signer-file.d.ts +34 -0
- package/dist/node/signer-file.d.ts.map +1 -0
- package/dist/node/signer-file.js +183 -0
- package/dist/node/signer-file.js.map +1 -0
- package/dist/node/store.d.ts +40 -0
- package/dist/node/store.d.ts.map +1 -0
- package/dist/node/store.js +117 -0
- package/dist/node/store.js.map +1 -0
- package/dist/node/text.d.ts +29 -0
- package/dist/node/text.d.ts.map +1 -0
- package/dist/node/text.js +124 -0
- package/dist/node/text.js.map +1 -0
- package/dist/node/tools.d.ts +118 -0
- package/dist/node/tools.d.ts.map +1 -0
- package/dist/node/tools.js +548 -0
- package/dist/node/tools.js.map +1 -0
- package/package.json +108 -3
- package/src/core/base64.ts +18 -0
- package/src/core/delegation.ts +239 -0
- package/src/core/grant.ts +127 -0
- package/src/core/hex.ts +18 -0
- package/src/core/index.ts +84 -0
- package/src/core/issue.ts +209 -0
- package/src/core/limits.ts +8 -0
- package/src/core/scrapi.ts +236 -0
- package/src/core/signer.ts +23 -0
- package/src/core/statement.ts +133 -0
- package/src/core/version.ts +25 -0
- package/src/core/x402.ts +314 -0
- package/src/net/delegate.ts +274 -0
- package/src/net/http.ts +71 -0
- package/src/net/index.ts +26 -0
- package/src/net/write.ts +124 -0
- package/src/node/cli.ts +170 -0
- package/src/node/grant-store.ts +154 -0
- package/src/node/grant-tools.ts +707 -0
- package/src/node/ledger.ts +98 -0
- package/src/node/payer.ts +241 -0
- package/src/node/resolve-input.ts +96 -0
- package/src/node/server.ts +332 -0
- package/src/node/signer-file.ts +251 -0
- package/src/node/store.ts +175 -0
- package/src/node/text.ts +153 -0
- package/src/node/tools.ts +810 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 forestrie
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @forestrie/mcp-register
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An MCP server that signs a statement and registers it on a Forestrie
|
|
4
|
+
transparency log under a Forestrie-Grant, then waits for the seal and
|
|
5
|
+
verifies the receipt. It can also buy the grant: as the requester, it signs a
|
|
6
|
+
child grant under your own authority log and registers it with canopy,
|
|
7
|
+
paying canopy's x402 charge within hard caps. It is the write path of the
|
|
8
|
+
Forestrie MCP trio:
|
|
9
|
+
|
|
10
|
+
- [`@forestrie/mcp-verify`](https://github.com/forestrie/mcp-verify) verifies
|
|
11
|
+
receipts offline.
|
|
12
|
+
- [`@forestrie/mcp-resolve`](https://github.com/forestrie/mcp-resolve) fetches
|
|
13
|
+
receipts and the material to verify them.
|
|
14
|
+
- This package writes. It uses the other two as libraries.
|
|
15
|
+
|
|
16
|
+
The statement is signed with a log key the server holds. The default backend
|
|
17
|
+
for that key is an ES256 key file the server creates. Child grants are signed
|
|
18
|
+
with a separate authority key, held the same way. The model never handles
|
|
19
|
+
signature bytes: you pass the payload and the server signs it. No tool takes
|
|
20
|
+
a signature or a key as input.
|
|
21
|
+
|
|
22
|
+
Payment uses a third key, an EVM account that holds testnet USDC. It is
|
|
23
|
+
configured by file and never crosses the MCP boundary, and the spending caps
|
|
24
|
+
are configuration, not tool arguments. With no payer configured, the server
|
|
25
|
+
spends nothing: it returns canopy's payment requirements, and you pay from
|
|
26
|
+
your own x402 wallet (relay mode).
|
|
27
|
+
|
|
28
|
+
## Status
|
|
29
|
+
|
|
30
|
+
Pre-release, version 0.1.0, not yet published to npm.
|
|
31
|
+
|
|
32
|
+
## Tools
|
|
33
|
+
|
|
34
|
+
| Tool | What it does |
|
|
35
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `get_log_key` | Returns the log key's public half (x‖y). Your grant must name this key. The key is created on first use. |
|
|
37
|
+
| `delegate_sealing` | Authorises the operator's sealer for your data log. Runs canopy's `prepare` with the same grant first if the coordinator does not know the log's public root yet. Once per log. |
|
|
38
|
+
| `register_statement` | Signs a payload (inline base64 or a file path, up to 4 MiB, with an explicit content type) and registers it. |
|
|
39
|
+
| `check_registration` | Does one status check: `pending`, `awaiting_seal` or `sealed`. Once sealed, it saves the receipt. |
|
|
40
|
+
| `verify_registration` | Verifies the receipt over the statement with mcp-verify's verifier and returns its four answers unaltered. |
|
|
41
|
+
| `issue_grant` | As the requester, signs a child data-log grant with the authority key, naming a log key (by default this server's), sized with `maxHeight`. Sends nothing. |
|
|
42
|
+
| `register_grant` | Registers the child grant with canopy, pays its 402 within the caps or relays the requirements, and follows it to its receipt. Resumable by child log id; never pays twice. |
|
|
43
|
+
|
|
44
|
+
The prompts walk an agent through the work:
|
|
45
|
+
|
|
46
|
+
- **`register`** covers the key and the grant, sealing, registering,
|
|
47
|
+
waiting, verifying and keeping the receipt.
|
|
48
|
+
- **`audit`** explains which trust questions a receipt answers under which
|
|
49
|
+
trust root.
|
|
50
|
+
- **`issue-and-pay`** covers buying a grant as the requester: sizing it,
|
|
51
|
+
issuing it, paying within the caps or relaying the payment, and handing
|
|
52
|
+
the completed grant to the performer.
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
Every value can be overridden per call.
|
|
57
|
+
|
|
58
|
+
| Variable | Meaning |
|
|
59
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
60
|
+
| `FORESTRIE_BASE_URL` | the canopy SCRAPI base URL |
|
|
61
|
+
| `FORESTRIE_ROOT_LOG_ID` | the forest's root log id (R in `/register/{R}/entries`) |
|
|
62
|
+
| `FORESTRIE_GRANT` | your Forestrie-Grant, as base64 or a file path |
|
|
63
|
+
| `FORESTRIE_COORDINATOR_URL` | the delegation coordinator, for `delegate_sealing` |
|
|
64
|
+
| `FORESTRIE_KNOWN_SEALER_KEY` | the registrar's voucher key, base64 x‖y, for `delegate_sealing` |
|
|
65
|
+
| `FORESTRIE_AUTHORITY_GRANT` | your authority log's grant, for `issue_grant` and `register_grant` |
|
|
66
|
+
| `MCP_REGISTER_HOME` | key files, grants, registrations and the spend ledger, default `~/.config/forestrie/mcp-register` |
|
|
67
|
+
| `MCP_REGISTER_KEY_FILE` | the log key file, default `$MCP_REGISTER_HOME/log-key.jwk` |
|
|
68
|
+
| `MCP_REGISTER_AUTHORITY_KEY_FILE` | the authority key file, default `$MCP_REGISTER_HOME/authority-key.jwk` |
|
|
69
|
+
|
|
70
|
+
### Payment
|
|
71
|
+
|
|
72
|
+
These are read from the environment only. No tool argument can set or raise
|
|
73
|
+
them.
|
|
74
|
+
|
|
75
|
+
| Variable | Meaning |
|
|
76
|
+
| -------------------------------- | -------------------------------------------------------------------------------- |
|
|
77
|
+
| `MCP_REGISTER_PAYER_KEY_FILE` | an EVM private key (`0x` + 64 hex, mode 600) that pays; unset means relay mode |
|
|
78
|
+
| `MCP_REGISTER_PAY_MAX_PER_CALL` | the most one payment may be, in the asset's atomic units (required with a payer) |
|
|
79
|
+
| `MCP_REGISTER_PAY_MAX_PER_DAY` | the most all payments in one UTC day may total (required with a payer) |
|
|
80
|
+
| `MCP_REGISTER_PAY_NETWORK` | the one network it pays on, default `eip155:84532` (Base Sepolia) |
|
|
81
|
+
| `MCP_REGISTER_PAY_ASSET` | the one asset it pays in, default USDC on Base Sepolia |
|
|
82
|
+
| `MCP_REGISTER_PAY_TO` | optional: the only payee |
|
|
83
|
+
| `MCP_REGISTER_PAY_ALLOW_MAINNET` | `1` to pay on a network that is not a testnet; off by default |
|
|
84
|
+
|
|
85
|
+
The server pays only the canopy named in `FORESTRIE_BASE_URL`, and only for
|
|
86
|
+
the request it made. Every payment it signs for a grant uses a nonce derived
|
|
87
|
+
from that grant, so the token contract can settle at most one of them: a
|
|
88
|
+
retry or two overlapping calls never pay for one grant twice. Each signed
|
|
89
|
+
payment is written to the spend ledger before it is sent and counts toward
|
|
90
|
+
the daily cap whether or not it settles. The daily cap is approximate when
|
|
91
|
+
calls overlap. USDC has 6 decimals, so `10000` is $0.01.
|
|
92
|
+
|
|
93
|
+
## Where grants come from
|
|
94
|
+
|
|
95
|
+
Forestrie runs no grant issuer. Whoever owns the authority log above yours
|
|
96
|
+
issues your grant, naming the key that `get_log_key` returns. Canopy
|
|
97
|
+
sequences grants; it does not issue them.
|
|
98
|
+
|
|
99
|
+
That owner can be you. If the owner of the root above you creates an
|
|
100
|
+
authority log for your authority key (`get_log_key` with
|
|
101
|
+
`which: "authority"` returns it as a PEM for forestrie-cli's
|
|
102
|
+
`create-log --auth-log --signer-pem`), `issue_grant` and `register_grant`
|
|
103
|
+
let you issue and register your own child grants. If that authority log
|
|
104
|
+
carries the child-payment-required flag, each registration is paid for over
|
|
105
|
+
x402, straight to the transparency operator.
|
|
106
|
+
|
|
107
|
+
## Install
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
npx -y @forestrie/mcp-register
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
(Not yet published.)
|
|
114
|
+
|
|
115
|
+
## Layers
|
|
116
|
+
|
|
117
|
+
- `src/core` is browser-safe and works on bytes only.
|
|
118
|
+
- `src/net` is the only place `fetch` is called, always through an injected
|
|
119
|
+
`fetchImpl`.
|
|
120
|
+
- `src/node` holds the MCP SDK, stdio, the filesystem, the key files and the
|
|
121
|
+
payer.
|
|
122
|
+
|
|
123
|
+
See [AGENTS.md](AGENTS.md).
|
|
124
|
+
|
|
125
|
+
## Licence
|
|
126
|
+
|
|
127
|
+
MIT.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base64 without `Buffer`, so `src/core` stays browser-safe. Accepts the
|
|
3
|
+
* standard and URL-safe alphabets, as canopy does for a Forestrie-Grant.
|
|
4
|
+
*/
|
|
5
|
+
export declare function base64ToBytes(b64: string): Uint8Array;
|
|
6
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
7
|
+
//# sourceMappingURL=base64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/core/base64.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAOrD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIvD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base64 without `Buffer`, so `src/core` stays browser-safe. Accepts the
|
|
3
|
+
* standard and URL-safe alphabets, as canopy does for a Forestrie-Grant.
|
|
4
|
+
*/
|
|
5
|
+
export function base64ToBytes(b64) {
|
|
6
|
+
const std = b64.trim().replace(/-/g, "+").replace(/_/g, "/");
|
|
7
|
+
const padded = std + "=".repeat((4 - (std.length % 4)) % 4);
|
|
8
|
+
const bin = atob(padded);
|
|
9
|
+
const out = new Uint8Array(bin.length);
|
|
10
|
+
for (let i = 0; i < bin.length; i++)
|
|
11
|
+
out[i] = bin.charCodeAt(i);
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
export function bytesToBase64(bytes) {
|
|
15
|
+
let bin = "";
|
|
16
|
+
for (const b of bytes)
|
|
17
|
+
bin += String.fromCharCode(b);
|
|
18
|
+
return btoa(bin);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/core/base64.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Es256Signer } from "./signer.js";
|
|
2
|
+
/** Horizon default: effectively unbounded, as the CLI and thinker use. */
|
|
3
|
+
export declare const DEFAULT_MMR_END: number;
|
|
4
|
+
export declare class DelegationError extends Error {
|
|
5
|
+
readonly code: "no_standing_entry" | "voucher_rejected" | "invalid_response" | "invalid_input";
|
|
6
|
+
constructor(code: "no_standing_entry" | "voucher_rejected" | "invalid_response" | "invalid_input", message: string);
|
|
7
|
+
}
|
|
8
|
+
/** One entry of `GET /api/logs/{logId}/pending-delegation`'s `entries`. */
|
|
9
|
+
export interface PendingDelegationEntry {
|
|
10
|
+
delegatedPublicKey?: string;
|
|
11
|
+
suggestedTtlSeconds?: number;
|
|
12
|
+
mmrStart?: number;
|
|
13
|
+
voucher?: string;
|
|
14
|
+
sealerId?: string;
|
|
15
|
+
epoch?: number | string;
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export interface StandingEntry {
|
|
19
|
+
delegatedPublicKey: string;
|
|
20
|
+
suggestedTtlSeconds: number;
|
|
21
|
+
voucher: string;
|
|
22
|
+
sealerId: string;
|
|
23
|
+
epoch: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The standing delegate-key entry, or `undefined` when the coordinator has
|
|
27
|
+
* none — which is what it answers (200, no standing entry) when it has
|
|
28
|
+
* never learned the log's public root. That is the case `prepare` fixes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function findStandingEntry(body: unknown): StandingEntry | undefined;
|
|
31
|
+
/** Verify the registrar's voucher for the standing key. Throws on any mismatch. */
|
|
32
|
+
export declare function checkVoucher(standing: StandingEntry, knownSealerKeyXY: Uint8Array): Promise<void>;
|
|
33
|
+
/** The JSON body of `POST /api/delegations/certificate`. */
|
|
34
|
+
export interface CertificateSubmission {
|
|
35
|
+
logId: string;
|
|
36
|
+
mmrStart: number;
|
|
37
|
+
mmrEnd: number;
|
|
38
|
+
delegatedPublicKey: string;
|
|
39
|
+
certificate: string;
|
|
40
|
+
issuedAt: number;
|
|
41
|
+
expiresAt: number;
|
|
42
|
+
onchainSignature: string;
|
|
43
|
+
}
|
|
44
|
+
export interface BuildDelegationInput {
|
|
45
|
+
logId: string;
|
|
46
|
+
standing: StandingEntry;
|
|
47
|
+
mmrEnd?: number;
|
|
48
|
+
ttlSeconds?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build the certificate submission, signing both artefacts with the log
|
|
52
|
+
* key. The certificate kid is `sha256(0x04‖x‖y)[0..16]`, the derivation
|
|
53
|
+
* delegation-cose's CryptoKeyPair path uses.
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildCertificateSubmission(input: BuildDelegationInput, signer: Es256Signer): Promise<CertificateSubmission>;
|
|
56
|
+
//# sourceMappingURL=delegation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../src/core/delegation.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,0EAA0E;AAC1E,eAAO,MAAM,eAAe,QAA0B,CAAC;AAEvD,qBAAa,eAAgB,SAAQ,KAAK;IAEtC,QAAQ,CAAC,IAAI,EACT,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,GAClB,eAAe;gBAJV,IAAI,EACT,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,EACnB,OAAO,EAAE,MAAM;CAIlB;AAED,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MA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+
*
|
|
4
|
+
* A data log's checkpoints are published by a sealer, and only the log's
|
|
5
|
+
* root key — here, the key the creation grant's `grantData` names — can
|
|
6
|
+
* authorise one. Without that authorisation entries sequence but no
|
|
7
|
+
* checkpoint ever covers them, and receipts 404 forever.
|
|
8
|
+
*
|
|
9
|
+
* The coordinator offers a *standing* delegate key for each log whose
|
|
10
|
+
* public root it knows: the pending-delegation entry with
|
|
11
|
+
* `suggestedTtlSeconds` and no `mmrStart`, vouched for by the registrar.
|
|
12
|
+
* This module picks that entry, verifies the voucher against the pinned
|
|
13
|
+
* registrar key (fail closed: a compromised coordinator must not get a
|
|
14
|
+
* root to delegate to a key the sealer does not hold), and builds the two
|
|
15
|
+
* artefacts the coordinator takes, both signed through the signer seam:
|
|
16
|
+
*
|
|
17
|
+
* - the delegation certificate (`buildDelegationCertificateEs256WithSigner`);
|
|
18
|
+
* - the on-chain delegation proof, low-s normalised because the on-chain
|
|
19
|
+
* P-256 verifier rejects high-s signatures.
|
|
20
|
+
*
|
|
21
|
+
* The same flow as forestrie-cli's `delegate` command and thinker's
|
|
22
|
+
* `delegateSealing`, over the published `@forestrie/delegation-cose`.
|
|
23
|
+
*/
|
|
24
|
+
import { buildDelegationCertificateEs256WithSigner, buildOnchainDelegationToBeSignedEs256, decodeDelegatedCoseKeyFromBytes, normalizeEs256SignatureLowS, parseDelegatedCoseKeyFromPayload, parseDelegationCertificate, } from "@forestrie/delegation-cose";
|
|
25
|
+
import { parseRegistrarKeyXY, uuidToBytes, verifyDelegateKeyVoucher, } from "@forestrie/encoding";
|
|
26
|
+
import { base64ToBytes, bytesToBase64 } from "./base64.js";
|
|
27
|
+
import { sha256, toHex } from "./hex.js";
|
|
28
|
+
/** Horizon default: effectively unbounded, as the CLI and thinker use. */
|
|
29
|
+
export const DEFAULT_MMR_END = Number.MAX_SAFE_INTEGER;
|
|
30
|
+
export class DelegationError extends Error {
|
|
31
|
+
code;
|
|
32
|
+
constructor(code, message) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.code = code;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The standing delegate-key entry, or `undefined` when the coordinator has
|
|
39
|
+
* none — which is what it answers (200, no standing entry) when it has
|
|
40
|
+
* never learned the log's public root. That is the case `prepare` fixes.
|
|
41
|
+
*/
|
|
42
|
+
export function findStandingEntry(body) {
|
|
43
|
+
if (typeof body !== "object" || body === null)
|
|
44
|
+
throw new DelegationError("invalid_response", "pending-delegation did not return a JSON object");
|
|
45
|
+
const entries = body.entries;
|
|
46
|
+
if (entries !== undefined && !Array.isArray(entries))
|
|
47
|
+
throw new DelegationError("invalid_response", "pending-delegation `entries` is not an array");
|
|
48
|
+
const standing = (entries ?? []).find((e) => typeof e === "object" &&
|
|
49
|
+
e !== null &&
|
|
50
|
+
e.suggestedTtlSeconds !== undefined &&
|
|
51
|
+
e.mmrStart === undefined);
|
|
52
|
+
if (!standing)
|
|
53
|
+
return undefined;
|
|
54
|
+
if (typeof standing.delegatedPublicKey !== "string" ||
|
|
55
|
+
typeof standing.voucher !== "string" ||
|
|
56
|
+
typeof standing.sealerId !== "string" ||
|
|
57
|
+
standing.epoch === undefined ||
|
|
58
|
+
typeof standing.suggestedTtlSeconds !== "number")
|
|
59
|
+
throw new DelegationError("voucher_rejected", "the standing entry is missing its registrar voucher, sealerId or epoch; refusing to delegate");
|
|
60
|
+
const epoch = Number(standing.epoch);
|
|
61
|
+
if (!Number.isSafeInteger(epoch) || epoch < 0)
|
|
62
|
+
throw new DelegationError("voucher_rejected", `the standing entry's epoch ${String(standing.epoch)} is not a non-negative integer`);
|
|
63
|
+
return {
|
|
64
|
+
delegatedPublicKey: standing.delegatedPublicKey,
|
|
65
|
+
suggestedTtlSeconds: standing.suggestedTtlSeconds,
|
|
66
|
+
voucher: standing.voucher,
|
|
67
|
+
sealerId: standing.sealerId,
|
|
68
|
+
epoch,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Verify the registrar's voucher for the standing key. Throws on any mismatch. */
|
|
72
|
+
export async function checkVoucher(standing, knownSealerKeyXY) {
|
|
73
|
+
const pinned = parseRegistrarKeyXY(knownSealerKeyXY);
|
|
74
|
+
if (pinned === null)
|
|
75
|
+
throw new DelegationError("invalid_input", `the known sealer key must be 64 bytes x‖y (got ${knownSealerKeyXY.length})`);
|
|
76
|
+
const result = await verifyDelegateKeyVoucher(base64ToBytes(standing.voucher), pinned, {
|
|
77
|
+
sealerId: standing.sealerId,
|
|
78
|
+
epoch: standing.epoch,
|
|
79
|
+
publicKey: base64ToBytes(standing.delegatedPublicKey),
|
|
80
|
+
});
|
|
81
|
+
if (!result.ok)
|
|
82
|
+
throw new DelegationError("voucher_rejected", `the registrar voucher does not check out against the pinned sealer key (${result.reason}); refusing to delegate`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Build the certificate submission, signing both artefacts with the log
|
|
86
|
+
* key. The certificate kid is `sha256(0x04‖x‖y)[0..16]`, the derivation
|
|
87
|
+
* delegation-cose's CryptoKeyPair path uses.
|
|
88
|
+
*/
|
|
89
|
+
export async function buildCertificateSubmission(input, signer) {
|
|
90
|
+
const mmrStart = 0;
|
|
91
|
+
const mmrEnd = input.mmrEnd ?? DEFAULT_MMR_END;
|
|
92
|
+
if (!Number.isSafeInteger(mmrEnd) || mmrEnd < 0)
|
|
93
|
+
throw new DelegationError("invalid_input", `mmrEnd ${mmrEnd} is not a non-negative safe integer`);
|
|
94
|
+
const logIdHex32 = toHex(uuidToBytes(input.logId));
|
|
95
|
+
const delegatedPublicKeyCbor = base64ToBytes(input.standing.delegatedPublicKey);
|
|
96
|
+
const xy = await signer.publicKeyXY();
|
|
97
|
+
const point = new Uint8Array(65);
|
|
98
|
+
point[0] = 0x04;
|
|
99
|
+
point.set(xy, 1);
|
|
100
|
+
const rootKid = (await sha256(point)).slice(0, 16);
|
|
101
|
+
const certInput = {
|
|
102
|
+
logIdHex32,
|
|
103
|
+
mmrStart,
|
|
104
|
+
mmrEnd,
|
|
105
|
+
delegatedPublicKeyCbor,
|
|
106
|
+
ttlSeconds: input.ttlSeconds ?? input.standing.suggestedTtlSeconds,
|
|
107
|
+
};
|
|
108
|
+
const certificate = await buildDelegationCertificateEs256WithSigner(certInput, rootKid, (sigStructure) => signer.sign(sigStructure));
|
|
109
|
+
const delegated = parseDelegatedCoseKeyFromPayload(decodeDelegatedCoseKeyFromBytes(delegatedPublicKeyCbor));
|
|
110
|
+
const tbs = buildOnchainDelegationToBeSignedEs256({
|
|
111
|
+
logIdHex: logIdHex32,
|
|
112
|
+
mmrStart,
|
|
113
|
+
mmrEnd,
|
|
114
|
+
delegatedKeyX: delegated.x,
|
|
115
|
+
delegatedKeyY: delegated.y,
|
|
116
|
+
});
|
|
117
|
+
const onchainSignature = normalizeEs256SignatureLowS(await signer.sign(tbs.sigStructureBytes));
|
|
118
|
+
const info = parseDelegationCertificate(certificate);
|
|
119
|
+
return {
|
|
120
|
+
logId: input.logId,
|
|
121
|
+
mmrStart,
|
|
122
|
+
mmrEnd,
|
|
123
|
+
delegatedPublicKey: input.standing.delegatedPublicKey,
|
|
124
|
+
certificate: bytesToBase64(certificate),
|
|
125
|
+
issuedAt: info.issuedAt,
|
|
126
|
+
expiresAt: info.expiresAt,
|
|
127
|
+
onchainSignature: bytesToBase64(onchainSignature),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=delegation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/core/delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACL,yCAAyC,EACzC,qCAAqC,EACrC,+BAA+B,EAC/B,2BAA2B,EAC3B,gCAAgC,EAChC,0BAA0B,GAE3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OA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AC;QAChD,QAAQ,EAAE,UAAU;QACpB,QAAQ;QACR,MAAM;QACN,aAAa,EAAE,SAAS,CAAC,CAAC;QAC1B,aAAa,EAAE,SAAS,CAAC,CAAC;KAC3B,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,2BAA2B,CAClD,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CACzC,CAAC;IAEF,MAAM,IAAI,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAC;IACrD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ;QACR,MAAM;QACN,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB;QACrD,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,gBAAgB,EAAE,aAAa,CAAC,gBAAgB,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare class GrantError extends Error {
|
|
2
|
+
readonly code = "invalid_grant";
|
|
3
|
+
}
|
|
4
|
+
export interface GrantView {
|
|
5
|
+
/** The log the grant authorises writes to (canopy's T): the data log. */
|
|
6
|
+
logId: string;
|
|
7
|
+
/** The governing authority log (canopy's O). */
|
|
8
|
+
ownerLogId: string;
|
|
9
|
+
/** The 8-byte wire flag bitmap, hex. */
|
|
10
|
+
flagsHex: string;
|
|
11
|
+
/** The key the grant names, as committed: 64 bytes x‖y for ES256. */
|
|
12
|
+
grantData: Uint8Array;
|
|
13
|
+
/** The batch ceiling, when the issuer sized the grant. */
|
|
14
|
+
maxHeight?: number;
|
|
15
|
+
/** GF_EXTEND with GF_DATA_LOG and not GF_AUTH_LOG. */
|
|
16
|
+
dataLogStatementGrant: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* canopy's `isStatementRegistrationGrant`: a data-log statement grant, or
|
|
19
|
+
* an auth-log bootstrap grant (GF_AUTH_LOG only, with GF_CREATE|GF_EXTEND),
|
|
20
|
+
* whose grantData likewise binds the statement signer.
|
|
21
|
+
*/
|
|
22
|
+
statementRegistrationGrant: boolean;
|
|
23
|
+
/** GF_CREATE and GF_EXTEND: the creation grant prepare requires. */
|
|
24
|
+
createAndExtend: boolean;
|
|
25
|
+
/** GF_AUTH_LOG without GF_DATA_LOG: an authority log, which can own children. */
|
|
26
|
+
authLog: boolean;
|
|
27
|
+
/** GF_DERIVED with GF_CHILD_PAYMENT_REQUIRED (adr-0062): registering a
|
|
28
|
+
* child grant under this one is x402 payment-gated where canopy enables it. */
|
|
29
|
+
requiresChildPayment: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function inspectGrant(credential: Uint8Array): GrantView;
|
|
32
|
+
/**
|
|
33
|
+
* Why this grant cannot carry statements signed by `signerXY`, or `[]`.
|
|
34
|
+
* Mirrors canopy's register-signed-statement admission
|
|
35
|
+
* (`isStatementRegistrationGrant`, the data-log owner rule, the signer
|
|
36
|
+
* binding).
|
|
37
|
+
*/
|
|
38
|
+
export declare function statementGrantProblems(grant: GrantView, signerXY: Uint8Array): string[];
|
|
39
|
+
/** Why `prepare` would refuse this grant, or `[]`. Mirrors canopy prepare-child-log. */
|
|
40
|
+
export declare function prepareGrantProblems(grant: GrantView): string[];
|
|
41
|
+
//# sourceMappingURL=grant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/core/grant.ts"],"names":[],"mappings":"AAmBA,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,mBAAmB;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,SAAS,EAAE,UAAU,CAAC;IACtB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,qBAAqB,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,0BAA0B,EAAE,OAAO,CAAC;IACpC,oEAAoE;IACpE,eAAe,EAAE,OAAO,CAAC;IACzB,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;IACjB;oFACgF;IAChF,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CA4B9D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,UAAU,GACnB,MAAM,EAAE,CAoBV;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,EAAE,CAa/D"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the grant a caller holds, before anything goes over the wire.
|
|
3
|
+
*
|
|
4
|
+
* The credential canopy takes as `Authorization: Forestrie-Grant <base64>`
|
|
5
|
+
* is the completed grant: a COSE Sign1 transparent statement carrying the
|
|
6
|
+
* grant at unprotected label -65538 and its inclusion receipt at 396.
|
|
7
|
+
* `decodeForestrieGrantCose` (`@forestrie/receipt-verify`) is the decoder
|
|
8
|
+
* canopy's own verifier uses.
|
|
9
|
+
*
|
|
10
|
+
* The checks here are the ones canopy applies at register-signed-statement
|
|
11
|
+
* and at prepare (canopy `grant/grant-flags.ts`,
|
|
12
|
+
* `scrapi/register-signed-statement.ts`, `forest/prepare-child-log.ts`),
|
|
13
|
+
* repeated so a wrong grant fails with a reason instead of a bare 403.
|
|
14
|
+
* canopy stays the authority: passing here promises nothing.
|
|
15
|
+
*/
|
|
16
|
+
import { bytesToUuid, grantDataToBytes } from "@forestrie/encoding";
|
|
17
|
+
import { decodeForestrieGrantCose } from "@forestrie/receipt-verify";
|
|
18
|
+
import { bytesEqual, toHex } from "./hex.js";
|
|
19
|
+
export class GrantError extends Error {
|
|
20
|
+
code = "invalid_grant";
|
|
21
|
+
}
|
|
22
|
+
export function inspectGrant(credential) {
|
|
23
|
+
let decoded;
|
|
24
|
+
try {
|
|
25
|
+
decoded = decodeForestrieGrantCose(credential);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw new GrantError(`not a Forestrie-Grant (a completed grant COSE Sign1 with the grant at unprotected label -65538): ${err.message}`);
|
|
29
|
+
}
|
|
30
|
+
const { grant } = decoded;
|
|
31
|
+
const flags = grant.grant;
|
|
32
|
+
const byte3 = flags.length >= 8 ? flags[3] : 0;
|
|
33
|
+
const low = flags.length >= 8 ? flags[7] : 0;
|
|
34
|
+
const dataLog = (byte3 & 0x02) !== 0 && (low & 0x02) !== 0 && (low & 0x01) === 0;
|
|
35
|
+
return {
|
|
36
|
+
logId: bytesToUuid(grant.logId),
|
|
37
|
+
ownerLogId: bytesToUuid(grant.ownerLogId),
|
|
38
|
+
flagsHex: toHex(flags),
|
|
39
|
+
grantData: grantDataToBytes(grant.grantData),
|
|
40
|
+
...(grant.maxHeight !== undefined ? { maxHeight: grant.maxHeight } : {}),
|
|
41
|
+
dataLogStatementGrant: dataLog,
|
|
42
|
+
statementRegistrationGrant: dataLog || ((low & 0x03) === 0x01 && (byte3 & 0x03) === 0x03),
|
|
43
|
+
createAndExtend: (byte3 & 0x03) === 0x03,
|
|
44
|
+
authLog: (low & 0x03) === 0x01,
|
|
45
|
+
requiresChildPayment: (byte3 & 0x0c) === 0x0c,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Why this grant cannot carry statements signed by `signerXY`, or `[]`.
|
|
50
|
+
* Mirrors canopy's register-signed-statement admission
|
|
51
|
+
* (`isStatementRegistrationGrant`, the data-log owner rule, the signer
|
|
52
|
+
* binding).
|
|
53
|
+
*/
|
|
54
|
+
export function statementGrantProblems(grant, signerXY) {
|
|
55
|
+
const problems = [];
|
|
56
|
+
if (!grant.statementRegistrationGrant)
|
|
57
|
+
problems.push(`grant flags ${grant.flagsHex} do not authorise statement registration (need GF_DATA_LOG with GF_EXTEND, or GF_AUTH_LOG with GF_CREATE|GF_EXTEND)`);
|
|
58
|
+
// canopy applies the distinct-owner rule to data-log grants only.
|
|
59
|
+
if (grant.dataLogStatementGrant && grant.logId === grant.ownerLogId)
|
|
60
|
+
problems.push("a data-log grant must name a log other than its owner (logId equals ownerLogId)");
|
|
61
|
+
if (grant.grantData.length !== 64)
|
|
62
|
+
problems.push(`grantData is ${grant.grantData.length} bytes; this package signs with ES256 and needs a 64-byte x‖y`);
|
|
63
|
+
else if (!bytesEqual(grant.grantData, signerXY))
|
|
64
|
+
problems.push("the grant names a different key than this server's log key (grantData ≠ the signer's x‖y); ask the grant issuer for a grant naming the key get_log_key returns");
|
|
65
|
+
return problems;
|
|
66
|
+
}
|
|
67
|
+
/** Why `prepare` would refuse this grant, or `[]`. Mirrors canopy prepare-child-log. */
|
|
68
|
+
export function prepareGrantProblems(grant) {
|
|
69
|
+
const problems = [];
|
|
70
|
+
if (!grant.createAndExtend)
|
|
71
|
+
problems.push(`grant flags ${grant.flagsHex} lack GF_CREATE|GF_EXTEND; prepare takes the log's creation grant`);
|
|
72
|
+
if (grant.logId === grant.ownerLogId)
|
|
73
|
+
problems.push("prepare needs a child log (logId equals ownerLogId)");
|
|
74
|
+
if (grant.grantData.length !== 64)
|
|
75
|
+
problems.push(`prepare accepts only 64-byte ES256 roots; grantData is ${grant.grantData.length} bytes`);
|
|
76
|
+
return problems;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=grant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/core/grant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;A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IAAI,CAAC,KAAK,CAAC,eAAe;QACxB,QAAQ,CAAC,IAAI,CACX,eAAe,KAAK,CAAC,QAAQ,mEAAmE,CACjG,CAAC;IACJ,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,UAAU;QAClC,QAAQ,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;IACvE,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,EAAE;QAC/B,QAAQ,CAAC,IAAI,CACX,0DAA0D,KAAK,CAAC,SAAS,CAAC,MAAM,QAAQ,CACzF,CAAC;IACJ,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/core/hex.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAI/C;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAKhE;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAInE"}
|
package/dist/core/hex.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function toHex(bytes) {
|
|
2
|
+
let out = "";
|
|
3
|
+
for (const b of bytes)
|
|
4
|
+
out += b.toString(16).padStart(2, "0");
|
|
5
|
+
return out;
|
|
6
|
+
}
|
|
7
|
+
export function bytesEqual(a, b) {
|
|
8
|
+
if (a.length !== b.length)
|
|
9
|
+
return false;
|
|
10
|
+
let diff = 0;
|
|
11
|
+
for (let i = 0; i < a.length; i++)
|
|
12
|
+
diff |= a[i] ^ b[i];
|
|
13
|
+
return diff === 0;
|
|
14
|
+
}
|
|
15
|
+
export async function sha256(bytes) {
|
|
16
|
+
return new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/core/hex.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,KAAiB;IACrC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAa,EAAE,CAAa;IACrD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;IACzD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAiB;IAC5C,OAAO,IAAI,UAAU,CACnB,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAqB,CAAC,CAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@forestrie/mcp-register` — the browser-safe core.
|
|
3
|
+
*
|
|
4
|
+
* This is the `"."` export. Everything reachable from here is pure over
|
|
5
|
+
* bytes: no `node:*`, no `fetch`, no filesystem, no MCP SDK, no key
|
|
6
|
+
* material. `"./net"` is the only place `fetch` is called, and `"./server"`
|
|
7
|
+
* is where the MCP adapter, the signer backend and the key file live.
|
|
8
|
+
* `pnpm run check:browser-safe` bundles this file for `platform: "browser"`
|
|
9
|
+
* and fails on any edge to a node builtin.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export { PACKAGE_VERSION, VERIFIER_VERSION, RESOLVE_VERSION, } from "./version.js";
|
|
13
|
+
export type { Es256Signer } from "./signer.js";
|
|
14
|
+
export { MAX_STATEMENT_BYTES } from "./limits.js";
|
|
15
|
+
export { base64ToBytes, bytesToBase64 } from "./base64.js";
|
|
16
|
+
export { GrantError, inspectGrant, prepareGrantProblems, statementGrantProblems, } from "./grant.js";
|
|
17
|
+
export type { GrantView } from "./grant.js";
|
|
18
|
+
export { MAX_PARENT_GRANT_BYTES, completeGrant, dataLogCreateExtendFlags, grantContent, issueChildGrant, parentGrantProblems, registerGrantBody, } from "./issue.js";
|
|
19
|
+
export type { IssueGrantInput, IssuedGrant } from "./issue.js";
|
|
20
|
+
export { DEFAULT_PAY_ASSET, DEFAULT_PAY_NETWORK, PaymentError, TESTNETS, grantPaymentNonce, readPaymentPayload, readPaymentRequired, selectWithinCaps, } from "./x402.js";
|
|
21
|
+
export type { CapContext, CapRefusalCode, PaymentCaps, PaymentOption, PaymentRequired, PaymentSummary, } from "./x402.js";
|
|
22
|
+
export { StatementError, signStatement } from "./statement.js";
|
|
23
|
+
export type { SignStatementInput, SignedStatement } from "./statement.js";
|
|
24
|
+
export { readProblem, readReceiptResponse, readRegisterGrantResponse, readRegisterResponse, readStatusResponse, } from "./scrapi.js";
|
|
25
|
+
export type { Problem, ReceiptOutcome, RegisterGrantOutcome, RegisterOutcome, ResponseView, StatusOutcome, } from "./scrapi.js";
|
|
26
|
+
export { DEFAULT_MMR_END, DelegationError, buildCertificateSubmission, checkVoucher, findStandingEntry, } from "./delegation.js";
|
|
27
|
+
export type { CertificateSubmission, PendingDelegationEntry, StandingEntry, } from "./delegation.js";
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"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AY,EACZ,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,GACd,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@forestrie/mcp-register` — the browser-safe core.
|
|
3
|
+
*
|
|
4
|
+
* This is the `"."` export. Everything reachable from here is pure over
|
|
5
|
+
* bytes: no `node:*`, no `fetch`, no filesystem, no MCP SDK, no key
|
|
6
|
+
* material. `"./net"` is the only place `fetch` is called, and `"./server"`
|
|
7
|
+
* is where the MCP adapter, the signer backend and the key file live.
|
|
8
|
+
* `pnpm run check:browser-safe` bundles this file for `platform: "browser"`
|
|
9
|
+
* and fails on any edge to a node builtin.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export { PACKAGE_VERSION, VERIFIER_VERSION, RESOLVE_VERSION, } from "./version.js";
|
|
13
|
+
export { MAX_STATEMENT_BYTES } from "./limits.js";
|
|
14
|
+
export { base64ToBytes, bytesToBase64 } from "./base64.js";
|
|
15
|
+
export { GrantError, inspectGrant, prepareGrantProblems, statementGrantProblems, } from "./grant.js";
|
|
16
|
+
export { MAX_PARENT_GRANT_BYTES, completeGrant, dataLogCreateExtendFlags, grantContent, issueChildGrant, parentGrantProblems, registerGrantBody, } from "./issue.js";
|
|
17
|
+
export { DEFAULT_PAY_ASSET, DEFAULT_PAY_NETWORK, PaymentError, TESTNETS, grantPaymentNonce, readPaymentPayload, readPaymentRequired, selectWithinCaps, } from "./x402.js";
|
|
18
|
+
export { StatementError, signStatement } from "./statement.js";
|
|
19
|
+
export { readProblem, readReceiptResponse, readRegisterGrantResponse, readRegisterResponse, readStatusResponse, } from "./scrapi.js";
|
|
20
|
+
export { DEFAULT_MMR_END, DelegationError, buildCertificateSubmission, checkVoucher, findStandingEntry, } from "./delegation.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AASnB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AASrB,OAAO,EACL,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,YAAY,EACZ,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
|