@t3foundry/tasra-sdk 0.3.1-next.1 → 0.4.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/CHANGELOG.md +1067 -28
- package/README.md +15 -0
- package/dist/app/approvals.d.ts +66 -4
- package/dist/app/approvals.js +153 -16
- package/dist/app/authorization.d.ts +1 -1
- package/dist/app/authorization.js +1 -1
- package/dist/app/browser.d.ts +63 -0
- package/dist/app/browser.js +242 -0
- package/dist/app/client.d.ts +114 -13
- package/dist/app/client.js +302 -76
- package/dist/app/identity.js +21 -9
- package/dist/app/index.d.ts +28 -3
- package/dist/app/index.js +16 -1
- package/dist/app/memory-store.d.ts +7 -0
- package/dist/app/memory-store.js +55 -0
- package/dist/app/node.d.ts +34 -6
- package/dist/app/node.js +387 -64
- package/dist/app/paid-allowance.d.ts +325 -0
- package/dist/app/paid-allowance.js +1290 -0
- package/dist/app/paid-approval.d.ts +122 -0
- package/dist/app/paid-approval.js +379 -0
- package/dist/app/paid-journal.d.ts +51 -0
- package/dist/app/paid-journal.js +117 -0
- package/dist/app/paid-keys.d.ts +12 -0
- package/dist/app/paid-keys.js +20 -0
- package/dist/app/paid-operation.d.ts +821 -0
- package/dist/app/paid-operation.js +1720 -0
- package/dist/app/paid-reservation.d.ts +157 -0
- package/dist/app/paid-reservation.js +323 -0
- package/dist/app/paid-session.d.ts +147 -0
- package/dist/app/paid-session.js +578 -0
- package/dist/app/payer-queue.d.ts +11 -0
- package/dist/app/payer-queue.js +27 -0
- package/dist/app/policy-bootstrap.d.ts +342 -0
- package/dist/app/policy-bootstrap.js +365 -0
- package/dist/app/policy-operation.d.ts +47 -0
- package/dist/app/policy-operation.js +101 -0
- package/dist/app/ready-slot.d.ts +12 -0
- package/dist/app/ready-slot.js +5 -2
- package/dist/app/rotation-lock.d.ts +38 -0
- package/dist/app/rotation-lock.js +42 -0
- package/dist/app/session-decrypt.d.ts +135 -0
- package/dist/app/session-decrypt.js +335 -0
- package/dist/app/session-grants.d.ts +349 -0
- package/dist/app/session-grants.js +811 -0
- package/dist/app/signing-intents.d.ts +78 -0
- package/dist/app/signing-intents.js +95 -0
- package/dist/app/store-commit.d.ts +63 -0
- package/dist/app/store-commit.js +126 -0
- package/dist/app/store-errors.d.ts +8 -0
- package/dist/app/store-errors.js +11 -0
- package/dist/app/tasra-client.d.ts +2 -0
- package/dist/app/tasra-client.js +1 -1
- package/dist/app/wallet.js +4 -1
- package/dist/auth/holderProof.d.ts +3 -0
- package/dist/auth/holderProof.js +8 -7
- package/dist/auth/verifier.d.ts +4 -2
- package/dist/auth/verifier.js +5 -2
- package/dist/chain/abis/index.d.ts +6178 -4101
- package/dist/chain/abis/index.js +3 -0
- package/dist/chain/abis/keyRegistry.d.ts +256 -0
- package/dist/chain/abis/keyRegistry.js +333 -0
- package/dist/chain/abis/prepaidFaultOracle.d.ts +321 -0
- package/dist/chain/abis/prepaidFaultOracle.js +413 -0
- package/dist/chain/abis/settlement.d.ts +2203 -703
- package/dist/chain/abis/settlement.js +2685 -764
- package/dist/chain/allowance.d.ts +358 -0
- package/dist/chain/allowance.js +800 -0
- package/dist/chain/billing.d.ts +85 -0
- package/dist/chain/billing.js +197 -0
- package/dist/chain/chainId.d.ts +13 -0
- package/dist/chain/chainId.js +26 -0
- package/dist/chain/client.d.ts +15 -1
- package/dist/chain/client.js +57 -1
- package/dist/chain/commitmentRecovery.d.ts +51 -0
- package/dist/chain/commitmentRecovery.js +38 -0
- package/dist/chain/committeeClient.d.ts +17 -10
- package/dist/chain/committeeClient.js +64 -16
- package/dist/chain/committeeDraw.d.ts +12 -0
- package/dist/chain/committeeDraw.js +56 -0
- package/dist/chain/custodyHealth.d.ts +212 -0
- package/dist/chain/custodyHealth.js +365 -0
- package/dist/chain/deployments.js +2 -0
- package/dist/chain/events.js +2 -0
- package/dist/chain/headFollower.d.ts +77 -0
- package/dist/chain/headFollower.js +219 -0
- package/dist/chain/headPrefetch.d.ts +23 -0
- package/dist/chain/headPrefetch.js +67 -0
- package/dist/chain/index.d.ts +50 -8
- package/dist/chain/index.js +28 -3
- package/dist/chain/keeperExecution.d.ts +44 -0
- package/dist/chain/keeperExecution.js +127 -0
- package/dist/chain/keeperRecovery.d.ts +78 -0
- package/dist/chain/keeperRecovery.js +91 -0
- package/dist/chain/node.d.ts +24 -1
- package/dist/chain/node.js +88 -43
- package/dist/chain/offchain.d.ts +2 -0
- package/dist/chain/paidAgentTransport.d.ts +38 -0
- package/dist/chain/paidAgentTransport.js +1 -0
- package/dist/chain/paidEpoch.d.ts +66 -0
- package/dist/chain/paidEpoch.js +139 -0
- package/dist/chain/paidPacing.d.ts +81 -0
- package/dist/chain/paidPacing.js +136 -0
- package/dist/chain/pinnedReads.d.ts +49 -0
- package/dist/chain/pinnedReads.js +218 -0
- package/dist/chain/prepaid.d.ts +383 -0
- package/dist/chain/prepaid.js +1046 -0
- package/dist/chain/prepaidEscape.d.ts +274 -0
- package/dist/chain/prepaidEscape.js +432 -0
- package/dist/chain/prepaidFault.d.ts +94 -0
- package/dist/chain/prepaidFault.js +148 -0
- package/dist/chain/receipt.d.ts +24 -0
- package/dist/chain/receipt.js +82 -0
- package/dist/chain/registeredAgent.d.ts +68 -3
- package/dist/chain/registeredAgent.js +143 -42
- package/dist/chain/registeredOperation.d.ts +10 -1
- package/dist/chain/registeredOperation.js +18 -3
- package/dist/chain/registeredPaidAgent.d.ts +254 -0
- package/dist/chain/registeredPaidAgent.js +889 -0
- package/dist/chain/registeredRelay.d.ts +31 -1
- package/dist/chain/registeredRelay.js +164 -43
- package/dist/chain/relayVoucher.d.ts +64 -0
- package/dist/chain/relayVoucher.js +69 -0
- package/dist/chain/reservation.d.ts +239 -0
- package/dist/chain/reservation.js +746 -0
- package/dist/chain/reshareRoster.d.ts +64 -0
- package/dist/chain/reshareRoster.js +85 -0
- package/dist/chain/revertReason.d.ts +8 -0
- package/dist/chain/revertReason.js +2 -1
- package/dist/chain/rotationLock.d.ts +130 -0
- package/dist/chain/rotationLock.js +168 -0
- package/dist/chain/serviceRequestPolicy.d.ts +47 -0
- package/dist/chain/serviceRequestPolicy.js +86 -0
- package/dist/chain/services.d.ts +7 -0
- package/dist/chain/services.js +44 -4
- package/dist/chain/slotClient.js +11 -2
- package/dist/chain/slotHandoff.d.ts +81 -0
- package/dist/chain/slotHandoff.js +166 -0
- package/dist/chain/slotSeed.d.ts +47 -5
- package/dist/chain/slotSeed.js +173 -42
- package/dist/chain/verifierSnapshot.d.ts +36 -0
- package/dist/chain/verifierSnapshot.js +197 -0
- package/dist/chain/write.d.ts +111 -21
- package/dist/chain/write.js +378 -146
- package/dist/committee/blsSharing.d.ts +53 -0
- package/dist/committee/blsSharing.js +90 -0
- package/dist/committee/client.d.ts +62 -23
- package/dist/committee/client.js +288 -72
- package/dist/committee/dual-operation.d.ts +165 -0
- package/dist/committee/dual-operation.js +229 -0
- package/dist/committee/dual-sign.d.ts +26 -1
- package/dist/committee/dual-sign.js +85 -7
- package/dist/committee/ecdsa.d.ts +38 -0
- package/dist/committee/ecdsa.js +87 -15
- package/dist/committee/evidence.d.ts +30 -0
- package/dist/committee/evidence.js +65 -0
- package/dist/committee/execution.d.ts +414 -0
- package/dist/committee/execution.js +446 -0
- package/dist/committee/extraction.js +33 -26
- package/dist/committee/index.d.ts +30 -7
- package/dist/committee/index.js +18 -6
- package/dist/committee/keeperExecution.d.ts +37 -0
- package/dist/committee/keeperExecution.js +141 -0
- package/dist/committee/oauth.d.ts +14 -4
- package/dist/committee/oauth.js +17 -5
- package/dist/committee/payment.d.ts +369 -0
- package/dist/committee/payment.js +339 -0
- package/dist/committee/recovery.d.ts +136 -0
- package/dist/committee/recovery.js +204 -0
- package/dist/committee/recoveryJson.d.ts +2 -0
- package/dist/committee/recoveryJson.js +87 -0
- package/dist/committee/request.d.ts +63 -27
- package/dist/committee/request.js +77 -66
- package/dist/committee/session-grant.d.ts +320 -0
- package/dist/committee/session-grant.js +397 -0
- package/dist/committee/status-refresh.d.ts +257 -0
- package/dist/committee/status-refresh.js +619 -0
- package/dist/committee/token.d.ts +163 -15
- package/dist/committee/token.js +247 -10
- package/dist/crypto/bn254.d.ts +70 -0
- package/dist/crypto/bn254.js +222 -0
- package/dist/crypto/ibe.d.ts +32 -0
- package/dist/crypto/ibe.js +56 -8
- package/dist/crypto/index.d.ts +1 -1
- package/dist/crypto/index.js +1 -1
- package/dist/crypto/kem.d.ts +31 -0
- package/dist/crypto/kem.js +113 -7
- package/dist/crypto/recipient.d.ts +75 -0
- package/dist/crypto/recipient.js +107 -0
- package/dist/decryption/client.d.ts +10 -16
- package/dist/decryption/client.js +8 -76
- package/dist/decryption/index.d.ts +2 -0
- package/dist/decryption/index.js +2 -0
- package/dist/decryption/sealed.d.ts +72 -0
- package/dist/decryption/sealed.js +147 -0
- package/dist/decryption/session.d.ts +115 -0
- package/dist/decryption/session.js +358 -0
- package/dist/errors.d.ts +406 -1
- package/dist/errors.js +400 -5
- package/dist/index.d.ts +9 -2
- package/dist/index.js +6 -1
- package/dist/internal/bounded.d.ts +66 -0
- package/dist/internal/bounded.js +126 -0
- package/dist/internal/network.d.ts +4 -0
- package/dist/internal/network.js +40 -0
- package/dist/internal/retryAfter.d.ts +8 -0
- package/dist/internal/retryAfter.js +28 -0
- package/dist/internal/sleep.d.ts +6 -0
- package/dist/internal/sleep.js +15 -0
- package/dist/internal/typedData.d.ts +13 -0
- package/dist/internal/typedData.js +77 -0
- package/dist/internal/viemErrors.d.ts +26 -0
- package/dist/internal/viemErrors.js +49 -0
- package/dist/oid4vp/binding.d.ts +27 -1
- package/dist/oid4vp/binding.js +36 -1
- package/dist/oid4vp/jose.d.ts +4 -2
- package/dist/oid4vp/jose.js +39 -7
- package/dist/oid4vp/request-object.d.ts +61 -4
- package/dist/oid4vp/request-object.js +140 -5
- package/dist/oid4vp/verifier-agent.d.ts +18 -8
- package/dist/oid4vp/verifier-agent.js +48 -6
- package/dist/oid4vp/wallet.d.ts +2 -4
- package/dist/oid4vp/wallet.js +1 -0
- package/dist/retry.d.ts +78 -0
- package/dist/retry.js +137 -0
- package/dist/signing/frost.d.ts +1 -1
- package/dist/verifier-agent/index.d.ts +41 -5
- package/dist/verifier-agent/index.js +124 -9
- package/dist/verifier-agent/payment.d.ts +7 -0
- package/dist/verifier-agent/payment.js +17 -0
- package/docs/api.md +8 -2
- package/docs/application-api.md +25 -2
- package/docs/chain.md +155 -9
- package/docs/consumer-migrations.md +61 -0
- package/docs/encrypted-notes.md +3 -2
- package/docs/encryption.md +4 -2
- package/docs/errors.md +14 -1
- package/docs/flows.md +2 -2
- package/docs/funding.md +902 -0
- package/docs/native-approvals.md +63 -0
- package/docs/reference/README.md +9 -8
- package/docs/reference/app-browser.md +232 -0
- package/docs/reference/app-node.md +38 -8
- package/docs/reference/app.md +4621 -805
- package/docs/reference/chain-node.md +74 -16
- package/docs/reference/chain.md +6740 -1592
- package/docs/reference/committee.md +5630 -987
- package/docs/reference/main.md +1439 -140
- package/docs/reference/oid4vp.md +297 -144
- package/docs/reference/verifier-agent.md +77 -35
- package/docs/signing.md +6 -0
- package/examples/encrypted-notes.ts +21 -6
- package/examples/getting-started.ts +2 -7
- package/examples/live-config.ts +24 -17
- package/package.json +17 -5
package/docs/chain.md
CHANGED
|
@@ -2,10 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
> The chain subpath: reads, writes, slot creation, discovery, and the slot-driven clients.
|
|
4
4
|
|
|
5
|
+
## User-class gas sponsorship
|
|
6
|
+
|
|
7
|
+
Configure registered relay writes with `sponsorship: {slotId, authorize}` when the
|
|
8
|
+
relayer's user-class policy requires a holder-bound voucher. Approve `slotId`
|
|
9
|
+
independently of the relayer. Provide durable `persistAttempt` and `resumeAttempt`
|
|
10
|
+
callbacks. The SDK saves the signed forward request before asking the authenticated
|
|
11
|
+
relayer for `/v1/relay/voucher-intent`, then checks the intent's chain, slot, digest,
|
|
12
|
+
expiry and delegation scope. Your `authorize({attempt, intent, signal})` callback
|
|
13
|
+
completes the wallet flow through an independently approved verifier-agent and
|
|
14
|
+
returns `{compound_token, verifier_proofs}` in wire format, optionally with
|
|
15
|
+
`status_attestations` and `evidence_ct`. Do not include session metadata in this bundle.
|
|
16
|
+
Authenticate the agent and its Request Object before presenting credentials; the
|
|
17
|
+
agent must verify the sponsor's creator/delegate authority. Retain session recovery
|
|
18
|
+
under `attempt.id` and honor cancellation.
|
|
19
|
+
|
|
20
|
+
Create the agent session with the original `intent.operation`, `intent.operation_sig`,
|
|
21
|
+
`intent.delegation` and `intent.message_hex`; do not sign a replacement operation. Persist
|
|
22
|
+
the creation intent under `attempt.id` before its POST, then persist the returned session's
|
|
23
|
+
`unpaidRecovery` checkpoint before wallet delivery. It contains the poll secret: keep it in
|
|
24
|
+
private durable application storage, never logs or public artifacts. After restart,
|
|
25
|
+
`agent.restoreUnpaidSession(checkpoint, {signal})` checks the independently approved profile
|
|
26
|
+
and live registry, then polls only that original session. It performs no creation POST or
|
|
27
|
+
provider failover. Retain the original operation separately, derive its request hash, and
|
|
28
|
+
use `assertRegisteredWalletRequest` before presenting and immediately before submitting.
|
|
29
|
+
If creation was interrupted before its checkpoint was saved, retain that uncertain intent
|
|
30
|
+
and refuse automatic creation of another session. Paid sessions use payment recovery and
|
|
31
|
+
do not expose an unpaid checkpoint.
|
|
32
|
+
|
|
33
|
+
The SDK checks the returned voucher's request binding and persists the voucher with
|
|
34
|
+
the original signature before submitting. The relayer independently verifies the
|
|
35
|
+
committee signatures, snapshot proofs, standing and revocation freshness. No TASRA
|
|
36
|
+
reservation is created for this relay authorization. TASRA slot funding and AVAX gas
|
|
37
|
+
sponsorship remain separate balances. Busy retries and alternative providers receive
|
|
38
|
+
the same signed request and voucher. Restarting with a retained, unexpired voucher
|
|
39
|
+
does not sign a new request or open another wallet session. A consumed nonce with
|
|
40
|
+
an unresolvable execution outcome refuses replacement; investigate that original
|
|
41
|
+
request before creating another operation. Expired vouchers require explicit recovery
|
|
42
|
+
and are not silently renewed. Native wallet/fleet acceptance is required before rollout.
|
|
43
|
+
|
|
5
44
|
Download the selected manifest from
|
|
6
45
|
[tasra-releases](https://github.com/t3foundry/tasra-releases), verify its trusted
|
|
7
46
|
checksum, and derive the address book with `addressBookFromManifest`.
|
|
8
47
|
|
|
48
|
+
## Recover registered relay writes
|
|
49
|
+
|
|
50
|
+
For sponsored and unsponsored writes, retain the signed `RelayAttempt` before its
|
|
51
|
+
first POST and restore it with `resumeAttempt` after restarting. If its nonce was
|
|
52
|
+
consumed outside the 10,000-block reconciliation window, `submit` refuses another
|
|
53
|
+
signature with `RelayOutcomeUnknownError`. Calling the submitter's `reconcile()`
|
|
54
|
+
returns `{expired: false, unresolvable: true}` and keeps `pendingAttempt()` intact.
|
|
55
|
+
A spent nonce proves that the original signed request cannot execute again; it does
|
|
56
|
+
not prove whether its inner call already ran.
|
|
57
|
+
|
|
58
|
+
Preserve the original journal and investigate its receipt and resulting chain state.
|
|
59
|
+
Do not delete it, move its starting block or recreate the submitter to bypass this
|
|
60
|
+
fence. Reconciliation automatically releases the signer only for a verified receipt
|
|
61
|
+
or when the deadline passed with the original nonce still unused. This tightens the
|
|
62
|
+
older behavior that released an unresolvable signer; it does not extend the bounded
|
|
63
|
+
log scan or supply automatic recovery of unavailable historical receipts.
|
|
64
|
+
|
|
9
65
|
## Create a read client
|
|
10
66
|
|
|
11
67
|
```ts
|
|
@@ -24,6 +80,7 @@ const slot = await chain.readers.keyRegistry.getKeySlot(slotId)
|
|
|
24
80
|
| `chainId` | Pass explicitly | Deployment chain ID. The constructor does not query the RPC to verify it. |
|
|
25
81
|
| `logWindow` | No | Maximum block range per `getLogs` query; defaults to 2,000. |
|
|
26
82
|
| `multicall3` | No | Auto-detected by default; pass an address or `false` to disable batching. |
|
|
83
|
+
| `rpcBatch` | No | JSON-RPC batching of small requests; defaults to batches of 32. Pass `{batchSize, wait}` to tune it or `false` for an RPC without batch support. |
|
|
27
84
|
|
|
28
85
|
**Returns:** a `TasraChainClient`. Use `client` for underlying viem calls and `readers`
|
|
29
86
|
for typed Tasra contract calls. Creating the client performs no network request;
|
|
@@ -93,17 +150,28 @@ commands and separate wallet/slot balance checks.
|
|
|
93
150
|
|
|
94
151
|
## Commit/reveal slot creation
|
|
95
152
|
|
|
96
|
-
`writer.createSlotCommitReveal(args)` commits the slot parameters,
|
|
97
|
-
per-commitment seed
|
|
98
|
-
|
|
99
|
-
|
|
153
|
+
`writer.createSlotCommitReveal(args)` commits the slot parameters, asks the accountant
|
|
154
|
+
set for a per-commitment seed, and reveals the slot with it in the next transaction.
|
|
155
|
+
It never waits for a beacon epoch. The accountants are asked concurrently (the first
|
|
156
|
+
valid seed wins); "not yet" answers are retried with jittered backoff that honours
|
|
157
|
+
`Retry-After`, for at most `slotSeedRetryMs` (default 90 s).
|
|
158
|
+
|
|
159
|
+
Without a seed it throws `SlotSeedUnavailableError`. When `detail.committed` is
|
|
160
|
+
`false`, no accountant was known and nothing was sent. When it is `true`, the
|
|
161
|
+
commitment stands: resume the same creation (same `slotId`, `salt`, `ruleSalt`, and
|
|
162
|
+
`recovery.commitTx`; `createPreparedSlot` does this from its journal) and nothing is
|
|
163
|
+
committed again.
|
|
100
164
|
|
|
101
165
|
The options in `CommitRevealOptions` let you set `accountantUrls`, bound each request
|
|
102
|
-
with `slotSeedTimeoutMs`,
|
|
103
|
-
|
|
104
|
-
`
|
|
105
|
-
|
|
106
|
-
|
|
166
|
+
with `slotSeedTimeoutMs`, set the window with `slotSeedRetryMs` and the stagger between
|
|
167
|
+
concurrent asks with `slotSeedHedgeMs`, and observe the outcome with `onSeed` and
|
|
168
|
+
`onSeedError`. The result includes `slotId`, `ruleSalt`, `commitTx`, `revealTx`,
|
|
169
|
+
`targetEpoch` and `seeded`.
|
|
170
|
+
|
|
171
|
+
A beacon-epoch commitment made by an older SDK can still be completed by resuming it
|
|
172
|
+
with `recovery.commitTx`. The resume checks the beacon once: before the commitment's
|
|
173
|
+
target epoch it throws `SlotRevealNotYetError` (with `targetEpoch` and `currentEpoch`)
|
|
174
|
+
instead of waiting; after its expiry it throws `SlotCommitmentExpiredError`.
|
|
107
175
|
|
|
108
176
|
For a custom commit/reveal flow, use `resolveAccountantUrls(chain)` and
|
|
109
177
|
`requestSlotSeed(chain, keyRegistry, commitment, options)`. Seed responses are checked
|
|
@@ -148,6 +216,84 @@ lower-level flow therefore accepts a proof **per verifier**: pass
|
|
|
148
216
|
`@t3foundry/tasra-sdk/committee`) as `holderProof` to `requestCommitteeToken` / `ibeDecryptRequest`
|
|
149
217
|
and each drawn verifier is asked for its own nonce.
|
|
150
218
|
|
|
219
|
+
## Keep a slot's key: rotation lock and custody health
|
|
220
|
+
|
|
221
|
+
Some keys are identities that must never change, such as a threshold-ECDSA slot whose
|
|
222
|
+
address holds an organization's rights. Rotation replaces a slot's key; resharing moves
|
|
223
|
+
the shares to other keepers and keeps the key.
|
|
224
|
+
|
|
225
|
+
**Threshold-ECDSA slots (`tecdsa`, `tecdsa-p256`) never rotate.** The network locks them
|
|
226
|
+
by their mode, existing slots included, because a rotation would remove the key, and with
|
|
227
|
+
it the address, for good. To change such a key, cancel the slot and create a new one; to
|
|
228
|
+
change its keepers, reshare. Any other slot can be locked by its creator, irreversibly:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import {createTasraWriteClient, isRotationLocked, readRotationLock} from '@t3foundry/tasra-sdk/chain'
|
|
232
|
+
|
|
233
|
+
const creator = createTasraWriteClient({...deployment, wallet})
|
|
234
|
+
const result = await creator.lockKeyRotation(slotId)
|
|
235
|
+
// {phase: 'locked', txHash} or, with nothing sent, {phase: 'already-locked', lockedByCreator, lockedByMode}
|
|
236
|
+
console.log(await isRotationLocked(chain, slotId)) // true
|
|
237
|
+
console.log(await readRotationLock(chain, slotId)) // creator lock, mode lock and the raw lastRotatedAt
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The lock is set once. A slot that is already locked, including every threshold-ECDSA slot,
|
|
241
|
+
resolves `already-locked` without a transaction, so a threshold-ECDSA slot never emits
|
|
242
|
+
`KeyRotationLocked`; read the state with `isRotationLocked`, not from events. From an
|
|
243
|
+
application, `lockKeyRotation(app, slotId, {wallet, store})` (`/app`) sends the same call as a
|
|
244
|
+
durable named wallet transaction. `rotateKey` refuses a locked slot before signing
|
|
245
|
+
(`RotationLockError`, code `locked`). On chain the refusal is the final revert
|
|
246
|
+
`RotationLocked()`; `decodeRotationLockRevert` names it, and `decodeKeyRotationLockedLogs`
|
|
247
|
+
reads the event.
|
|
248
|
+
|
|
249
|
+
**Reshare a threshold-ECDSA slot by keeping at least `k` current members.** Only members
|
|
250
|
+
that stay re-deal the key, so a roster that keeps fewer than the current `k` is refused by
|
|
251
|
+
every keeper. `reshareKey` checks this before signing (`ReshareRosterError`, code
|
|
252
|
+
`keeps-too-few`), and `checkTecdsaReshareRoster` gives the same answer for a proposal you
|
|
253
|
+
build yourself. Replacing the whole committee takes two reshares. Newer registries also
|
|
254
|
+
revert `TecdsaReshareKeepsTooFew(staying, k)`.
|
|
255
|
+
|
|
256
|
+
**Watch custody health.** Each keeper answers for its own share with a statement signed by
|
|
257
|
+
its operator identity key. `readCustodyHealth` polls every assigned keeper and counts a
|
|
258
|
+
statement only when it verifies under the key `NodeRegistry` holds for that operator,
|
|
259
|
+
names this chain, slot and operator, and is at most 15 minutes old:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
import {readCustodyHealth} from '@t3foundry/tasra-sdk/chain'
|
|
263
|
+
|
|
264
|
+
const health = await readCustodyHealth(chain, slotId)
|
|
265
|
+
health.committee.margin // live keepers above k, from NodeRegistry; 0 or less needs a reshare
|
|
266
|
+
health.current // operators whose signed statement shows a share of the current key
|
|
267
|
+
health.proven // at least k of them
|
|
268
|
+
health.pending // operators that have not finished a reshare
|
|
269
|
+
health.refused // unsigned, stale, mismatched or unreachable replies; never counted
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Liveness, margin and the rotation lock come from the SDK's own chain reads. A keeper's
|
|
273
|
+
unsigned reply fields are never used, and a reply whose unsigned fields contradict its
|
|
274
|
+
signed statement is refused. `statement.lastFailure` reports the keeper's last failed
|
|
275
|
+
reshare of the slot and, when known, the operator id it blamed.
|
|
276
|
+
|
|
277
|
+
## Keeper administrative capability
|
|
278
|
+
|
|
279
|
+
`nodeApi.info(keeperUrl)` reports the keeper's optional `admin_auth` field:
|
|
280
|
+
|
|
281
|
+
| Value | Keeper-reported capability |
|
|
282
|
+
|---|---|
|
|
283
|
+
| `separate` | Administrative tokens use an independent operator issuer key. |
|
|
284
|
+
| `unconfigured` | Administrative routes await operator configuration. |
|
|
285
|
+
| absent | The keeper did not report this capability. |
|
|
286
|
+
|
|
287
|
+
This is service metadata; reading it does not authenticate the keeper or grant
|
|
288
|
+
authority. Provisioning, rotation and governance require an administrative token
|
|
289
|
+
with the keeper's configured issuer, audience and `kk-admin+jwt` type. Obtain that
|
|
290
|
+
token from the operator; its signing seed belongs on the operator's system.
|
|
291
|
+
|
|
292
|
+
An unconfigured administrative route returns HTTP 503 with
|
|
293
|
+
`admin authentication not configured` in the response body. The SDK preserves
|
|
294
|
+
that diagnostic in `TasraHttpError.body` and the status in `TasraHttpError.status`.
|
|
295
|
+
The operator must configure the administrative issuer before retrying the action.
|
|
296
|
+
|
|
151
297
|
---
|
|
152
298
|
|
|
153
299
|
[Back to the README](../README.md) · [Documentation index](README.md)
|
|
@@ -25,6 +25,47 @@ handling. Complete [shared-account](shared-account.md), [encrypted-notes](encryp
|
|
|
25
25
|
[native approval](native-approvals.md) and [document-signing](document-signing.md)
|
|
26
26
|
examples demonstrate the surrounding application responsibilities.
|
|
27
27
|
|
|
28
|
+
## Decrypt with a client-held recipient
|
|
29
|
+
|
|
30
|
+
Upgrade keepers, workers, verifier agents, CLI and SDK consumers together. Deploy
|
|
31
|
+
workers that understand sealed delivery before routing the new requests to them.
|
|
32
|
+
The retired custody, unsealed contribution and raw-key export endpoints always
|
|
33
|
+
refuse; JWTs and older request shapes do not restore them.
|
|
34
|
+
|
|
35
|
+
Create `createDecryptionRecipient()` before requesting holder or creator
|
|
36
|
+
authorization. Use `kemContentDigest` and `decryptionBinding` to bind a complete KEM
|
|
37
|
+
ciphertext, its identity, canonical key epoch and public recipient. For IBE, use
|
|
38
|
+
SHA-256 of the original identity bytes as the content digest. Pass the public
|
|
39
|
+
`decryption` metadata into authorization-session creation before approving the
|
|
40
|
+
body. Keep the client recipient, or its client-held random recovery seed, in private
|
|
41
|
+
client storage; never include private recipient material in a session or journal.
|
|
42
|
+
|
|
43
|
+
Use `decryptWithCommitteePartials` or the migrated
|
|
44
|
+
`createCommitteeSlotClient().decrypt`. The slot client requires `recipient`,
|
|
45
|
+
`ciphertextEpoch`, `verifyingShares`, `threshold` and the original `binding`;
|
|
46
|
+
paid work also needs the original `payment` and exact-body `approveExecution`
|
|
47
|
+
capability. It discovers assigned keeper URLs and retains anchored verifier
|
|
48
|
+
snapshot checks. Authenticate public BLS reports with `discoverBlsSharing` using
|
|
49
|
+
independently registered operator keys and canonical epoch/version. A signed
|
|
50
|
+
self-report does not commit the full polynomial on chain; retain contribution
|
|
51
|
+
pairing checks and final verification against the anchored group key.
|
|
52
|
+
|
|
53
|
+
Only the client opens and combines contributions. Clear sensitive partials and
|
|
54
|
+
recovered keys after use. For IBE recovery, retain the original recipient,
|
|
55
|
+
identity and authenticated public shares; recovery reads the original completed
|
|
56
|
+
result and never starts new paid work. An older signed intent without a recipient
|
|
57
|
+
binding cannot authorize a new sealed operation. Reconcile its original outcome
|
|
58
|
+
under the retained authority before considering another attempt.
|
|
59
|
+
|
|
60
|
+
A service forwarding a device read can use
|
|
61
|
+
`operation.recover({transport, contributorKey})` to read an originally assigned
|
|
62
|
+
contributor's exact retained sealed reply without the device's private opening key.
|
|
63
|
+
The key must occur in both the retained contributor roster and original signed
|
|
64
|
+
assignment. This option selects the contributor stage; a conflicting coordinator
|
|
65
|
+
stage is refused. The same option is available on `recoverPaidOperation` handles
|
|
66
|
+
after restart. Forward only sealed replies; the device must still authenticate the
|
|
67
|
+
original slot, epoch and public share, open locally and verify the contribution.
|
|
68
|
+
|
|
28
69
|
## Use generic rule names
|
|
29
70
|
|
|
30
71
|
Pass the clear policy as `rule` in `CreateSlotArgs`, `prepareSlot` and
|
|
@@ -61,6 +102,26 @@ for an OAuth-only policy. Both types validate the policy family before creation.
|
|
|
61
102
|
Existing named credential requests with an omitted authorization type retain their
|
|
62
103
|
OID4VP meaning. Resume with the original policy and authorization type.
|
|
63
104
|
|
|
105
|
+
## Administrative authority slots
|
|
106
|
+
|
|
107
|
+
Chain writers require `mode: 'bls-bn254', authType: 'governance'` for the separate
|
|
108
|
+
BN254 platform authority. The contract also enforces this pairing. Its administrative
|
|
109
|
+
JWT policy cannot authorize customer wallet operations; the application slot API
|
|
110
|
+
continues to use OID4VP or OAuth. Existing type ordinals stay unchanged, and
|
|
111
|
+
`unspecified` retains OID4VP semantics. Fleet readers must support the appended
|
|
112
|
+
`Governance=3` ordinal before creating authority slots; older three-member readers
|
|
113
|
+
cannot decode them. This change requires a compatible fresh deployment or a planned
|
|
114
|
+
reader-first upgrade, rather than assuming legacy image compatibility.
|
|
115
|
+
|
|
116
|
+
## Preserve unknown relay outcomes
|
|
117
|
+
|
|
118
|
+
Registered relay recovery now keeps the signer fenced when a consumed nonce is
|
|
119
|
+
outside the bounded log window, for sponsored and unsponsored requests alike.
|
|
120
|
+
`submit` throws `RelayOutcomeUnknownError`; `reconcile()` reports `unresolvable`
|
|
121
|
+
without clearing `pendingAttempt()`. Older releases could release that signer and
|
|
122
|
+
sign a replacement. Retain existing journals and investigate the original outcome
|
|
123
|
+
before authorizing another operation. See [relay recovery](chain.md#recover-registered-relay-writes).
|
|
124
|
+
|
|
64
125
|
## Validate your application
|
|
65
126
|
|
|
66
127
|
1. Install the [latest SDK from npm](installation.md) and keep
|
package/docs/encrypted-notes.md
CHANGED
|
@@ -101,8 +101,9 @@ ID is required. Every full run creates fresh state.
|
|
|
101
101
|
AAD from the record identifier, and encrypts the plaintext with AES-256-GCM
|
|
102
102
|
(Web Crypto). `notes.encrypt(aad, dataKey)` BLS KEM-wraps the data key
|
|
103
103
|
using only the slot's public key — offline, no credential needed.
|
|
104
|
-
4. **Decrypt and open.** `notes.decrypt(aad, kemCt, {
|
|
105
|
-
verifies Alice's operation authorization, collects keeper partial decryptions
|
|
104
|
+
4. **Decrypt and open.** `notes.decrypt(aad, kemCt, {recipient, verifyingShares, authorize})`
|
|
105
|
+
verifies Alice's operation authorization, collects keeper partial decryptions sealed
|
|
106
|
+
to the client recipient, verifies them against the slot's authenticated verifying shares,
|
|
106
107
|
recovers the AES data key, and zeroizes it after the application decrypts
|
|
107
108
|
the AES-GCM payload.
|
|
108
109
|
5. **Check failures.** Bob's credential is submitted to the real verifier with the
|
package/docs/encryption.md
CHANGED
|
@@ -13,8 +13,10 @@ manifest. The only application runtime dependency is `@t3foundry/tasra-sdk`.
|
|
|
13
13
|
2. Issue a holder-bound credential with `tasra.credentials.issue` and define the
|
|
14
14
|
issuer-rooted document scope with `tasra.credentials.policy`.
|
|
15
15
|
3. Call `tasra.slots.create({name, mode: 'bls', policy, threshold, verifiers})`.
|
|
16
|
-
4. Encrypt
|
|
17
|
-
|
|
16
|
+
4. Encrypt: `slot.encrypt(aad, dataKey)` wraps a data key with BLS KEM, or
|
|
17
|
+
`slot.encryptForIdentity(identity, bytes)` uses identity-based encryption. Decrypt with
|
|
18
|
+
`slot.decrypt` or `slot.decryptForIdentity`, passing a client recipient, the slot's
|
|
19
|
+
authenticated verifying shares and `tasra.credentials.authorize(...)`.
|
|
18
20
|
5. Verify the plaintext, actual server refusal for Bob, and ciphertext tampering.
|
|
19
21
|
|
|
20
22
|
Creation, rule commitment/delivery, key readiness and verifier setup are SDK
|
package/docs/errors.md
CHANGED
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
| Class | Carries | `retryable` |
|
|
32
32
|
|---|---|---|
|
|
33
33
|
| `TasraError` | base for all of the below | — |
|
|
34
|
-
| `TasraHttpError` | `status`, `url`, `body` (200 chars) | 5xx / 429 |
|
|
34
|
+
| `TasraHttpError` | `status`, `url`, `body` (200 chars), `retryAfterMs?` | 5xx / 429 / 425; 409/410/422 with `Retry-After` |
|
|
35
35
|
| `AuthDeniedError` | as above; 401/403 | **never** |
|
|
36
36
|
| `NodeUnreachableError` | `url` — no HTTP answer at all | yes |
|
|
37
37
|
| `ThresholdNotMetError` | `got`, `need`, `reasons[]` | yes, unless every node denied |
|
|
@@ -46,6 +46,12 @@ A `true` result describes a possibly transient failure; it does not prove that
|
|
|
46
46
|
repeating the operation is safe. Restrict automatic retries to safe reads, with
|
|
47
47
|
an attempt limit, deadline and cancellation. Never automatically repeat a
|
|
48
48
|
transaction, signing request or approval submission after an uncertain outcome.
|
|
49
|
+
For a request that is safe to send again, `retryIdempotent(work, {policy, signal})`
|
|
50
|
+
waits at least the service's `Retry-After` (plus bounded jitter), backs off without
|
|
51
|
+
one, and rethrows the last failure once a wait would exceed `maxDelayMs` or
|
|
52
|
+
`maxTotalWaitMs`. It cannot tell whether a request is safe to repeat; never wrap a
|
|
53
|
+
paid operation, reservation or approval with it.
|
|
54
|
+
|
|
49
55
|
`isAuthDenied(e)` is keyed on HTTP status rather than class, so it also catches a
|
|
50
56
|
403 from `CommitteeAuthorizeError`.
|
|
51
57
|
|
|
@@ -61,6 +67,13 @@ Retain the original operation details and reconcile before submitting again:
|
|
|
61
67
|
|---|---|---|
|
|
62
68
|
| `CreationReconciliationRequiredError` | `@t3foundry/tasra-sdk/app` | `slotId`, `step`; preserve the creation journal and reconcile the wallet transaction before resuming. |
|
|
63
69
|
| `ApplicationSlotRecoveryError` | `@t3foundry/tasra-sdk/app` | `code`, `recoveryName`, optional `slotId` and `transactionHash`; inspect the saved named intent or original verifier-policy transaction before resuming. `VERIFIER_POLICY_OUTCOME_UNKNOWN` means a submission may have happened without a recorded hash; never submit another policy transaction until reconciled. `VERIFIER_POLICY_RECEIPT_PENDING` has a saved hash and can resume receipt observation. |
|
|
70
|
+
| `PaidOperationRecoveryError` | `@t3foundry/tasra-sdk/app` | `requestId`, `phase`, a stable `code` and `resumable`. `resumable: false` is final (`reservation-failed`, `session-refused` such as a committee refusal or HTTP 403/410, `payment-expired`), a write only reconciliation can settle (`session-write-uncertain`), or an execution only `recover` may read (`execution-uncertain`). `aborted` is the caller's own cancellation of a step that sent nothing uncertain. Otherwise call `resumePaidOperation`; never start the operation again. |
|
|
71
|
+
| `PaidReservationUncertainError` | `@t3foundry/tasra-sdk/chain` | `code: 'reservation-uncertain'`, `requestId`, optional `transactionHash`; a reservation may have been broadcast (including when an abort ended the receipt wait). Reconcile it from the journal; never reserve it again. |
|
|
72
|
+
| `PaidReservationAbortedError` | `@t3foundry/tasra-sdk/chain` | `code: 'aborted'`, `requestId`; the caller's signal stopped the reservation before its durable preparation. Nothing was journaled, claimed or sent; reserving again is safe. |
|
|
73
|
+
| `PaidApprovalUnresolvedError` | `@t3foundry/tasra-sdk` or `@t3foundry/tasra-sdk/chain` | `code: 'approval_outcome_unresolved'`, `reason` (`claim_lost`, `generation_moved`, `outcome_unknown`, `no_permit`, `legacy_state`, `conflict`), optional `proposalId`, `generation`, `key`. A retained operator approval may already have reached the agent, or its permit was claimed elsewhere; it is never resent. Reconcile the delivery by reading it. |
|
|
74
|
+
| `PaidBackoffError` | `@t3foundry/tasra-sdk` or `@t3foundry/tasra-sdk/chain` | `code` (`deadline_exceeded`, `server_wait_too_long`, `no_time_to_send`, `attempts_exhausted`), `route`, optional `httpStatus`, `retryAfterMs`, `remainingMs`, `neededMs`; a definite 429/503 could not be waited out inside its deadline. Nothing was sent after that refusal; a retained approval keeps its permit, so resume the paid operation later. |
|
|
75
|
+
| `PaidReservationQuotaError` | `@t3foundry/tasra-sdk` or `@t3foundry/tasra-sdk/chain` | `code: 'reservation_quota'`, `reason`, `retryAfterMs`, `url`; the accountant's reservation quota outlasted the prepare window. Nothing was reserved. |
|
|
76
|
+
| `PaidOperationAbandonRefusedError` | `@t3foundry/tasra-sdk/app` | `abandonPaidOperation` refused because something could still land: `requestId`, `phase` and, when payment expiry alone unblocks it, `notBefore` (Unix seconds, `retryable: true`). A prepared reservation needs `reconcilePaidOperation` first. |
|
|
64
77
|
| `OperationOutcomeUnknownError` | `@t3foundry/tasra-sdk/committee` | `operation`, optional `requestId`; inspect the original approval request. If its ID was lost, retain that uncertainty. |
|
|
65
78
|
| `RelayOutcomeUnknownError` | `@t3foundry/tasra-sdk/chain` | `attempt`; use `reconcileRelayAttempt` with that signed request and the trusted chain reader before considering a replacement. |
|
|
66
79
|
| `AgentSessionCreationUnknownError` | `@t3foundry/tasra-sdk/chain` | `profile`; session creation may have reached that provider. A replacement requires explicitly opening a fresh wallet session; do not transfer session secrets or presentations. |
|
package/docs/flows.md
CHANGED
|
@@ -204,8 +204,8 @@ approve. Reading the address needs no credential presentation.
|
|
|
204
204
|
|
|
205
205
|
```ts
|
|
206
206
|
const documents = await tasra.slots.bls(slotId)
|
|
207
|
-
const ciphertext = await documents.
|
|
208
|
-
const {plaintext} = await documents.
|
|
207
|
+
const ciphertext = await documents.encryptForIdentity(documentIdentity, documentBytes)
|
|
208
|
+
const {plaintext} = await documents.decryptForIdentity(documentIdentity, ciphertext, {recipient, verifyingShares, authorize})
|
|
209
209
|
```
|
|
210
210
|
|
|
211
211
|
Encryption uses the slot's anchored public key. Decryption obtains authorization,
|