@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/native-approvals.md
CHANGED
|
@@ -54,6 +54,14 @@ original coordinator and pinned policy. After an ambiguous POST, catch
|
|
|
54
54
|
a replacement request. If creation lost its request ID, the current protocol
|
|
55
55
|
cannot discover it through this SDK; preserve that uncertainty for an operator.
|
|
56
56
|
|
|
57
|
+
Keepers with durable dual-control storage retain approvals and completed replies across
|
|
58
|
+
restart. The approval window still expires after five minutes. If execution may have
|
|
59
|
+
started but no durable result is available, `status()` returns `uncertain`, `approve()`
|
|
60
|
+
sends no approval, and `wait()` raises `OperationOutcomeUnknownError` with the same request
|
|
61
|
+
ID. Preserve that ID and reconcile the work evidence before deciding how to proceed.
|
|
62
|
+
For paid creation, the ID is derived from the pinned final Sign reservation; see
|
|
63
|
+
[paid dual-control signatures](funding.md#paid-dual-control-signatures).
|
|
64
|
+
|
|
57
65
|
This is separate from two detached signatures in a document workflow. It does
|
|
58
66
|
not enable multi-approver IBE extraction.
|
|
59
67
|
|
|
@@ -122,3 +130,58 @@ files with the application so restarts use the same deployment. The examples use
|
|
|
122
130
|
`lowest-operator-id` as the explicit coordinator convention; confirm it matches
|
|
123
131
|
the selected service. Fund each newly printed creator address with at least one
|
|
124
132
|
native token on the selected chain before continuing.
|
|
133
|
+
|
|
134
|
+
## Threshold ECDSA (and BLS) operations: approval bundles
|
|
135
|
+
|
|
136
|
+
On a threshold ECDSA slot (secp256k1 or P-256) the network enforces the same on-chain policy
|
|
137
|
+
through an operation-specific **bundle** carried inside the final paid keeper request, not
|
|
138
|
+
through the FROST collector. Install the policy exactly as above: `setApprovalPolicy` accepts a
|
|
139
|
+
ready FROST, BLS or threshold ECDSA slot. The creator wallet sends `setDualControlPolicy`; no
|
|
140
|
+
slot-key signature is involved. Policies are set-once: an identical installed policy resolves
|
|
141
|
+
`{phase: 'already-installed'}` without sending, and a different one is refused before sending.
|
|
142
|
+
`readApprovalPolicy` reads what is installed.
|
|
143
|
+
|
|
144
|
+
Approvals bind ONE final paid operation, so prepare them after its payment exists and before
|
|
145
|
+
the keeper request (a statement is current for at most 300 seconds):
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import {prepareOperationApproval, approveDualOperation, assembleOperationApproval} from '@t3foundry/tasra-sdk/app'
|
|
149
|
+
import {committeeSignEoaDigest} from '@t3foundry/tasra-sdk/committee'
|
|
150
|
+
|
|
151
|
+
const op = await paidOperation(config, {slot, operation: {action: 'sign', message: digest}, rule, holder})
|
|
152
|
+
const prepared = await prepareOperationApproval(tasra, {payment: op.payment})
|
|
153
|
+
// Each approver checks the statement against what it expects, then signs its exact bytes.
|
|
154
|
+
const alice = await approveDualOperation({prepared, payment: op.payment, expectSlot: slot,
|
|
155
|
+
expectPayloadDigest: op.payment.payload_digest, approver: identityApprover(aliceIdentity)})
|
|
156
|
+
const bob = await approveDualOperation({prepared, payment: op.payment, expectSlot: slot,
|
|
157
|
+
expectPayloadDigest: op.payment.payload_digest, approver: identityApprover(bobIdentity)})
|
|
158
|
+
const dualControl = await assembleOperationApproval(tasra, {prepared, approvals: [alice, bob]})
|
|
159
|
+
const signature = await op.execute(o => committeeSignEoaDigest({nodeUrl: o.coordinatorUrl,
|
|
160
|
+
committeeToken: o.compound_token, evidenceCt: o.evidenceCt, verifierProofs: o.verifierProofs,
|
|
161
|
+
approveExecution: o.approveExecution, digest, dualControl}))
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`slots.ecdsa(slot).signDigest(digest, {payment, random, execution, authorize, dualControl})`
|
|
165
|
+
takes the same bundle for a payment the application reserved itself. The statement binds the
|
|
166
|
+
chain, slot, operation, key epoch, SHA-256 of the digest, the payment's request ID and payment
|
|
167
|
+
hash. `assembleOperationApproval` judges the bundle against the ON-CHAIN quorum and approver set;
|
|
168
|
+
missing approvals, a duplicate approver, a key outside the set, a stale statement or an approval
|
|
169
|
+
of another payment are refused before anything is sent, and the keeper and every ECDSA member
|
|
170
|
+
re-check all of it. Approver keys are Ed25519 only (the network has no other approver type), and
|
|
171
|
+
a credential-gated policy needs each approver's own holder-bound `dual-approve` grant.
|
|
172
|
+
|
|
173
|
+
### Sign a structured intent
|
|
174
|
+
|
|
175
|
+
Approvers should review what is signed, not a digest. `slots.ecdsa(slot).signIntent(intent,
|
|
176
|
+
options)` takes a transaction (it must name its `chainId`), EIP-712 typed data (with a domain
|
|
177
|
+
`chainId`) or a personal message, derives the digest itself and, with a payment, refuses unless
|
|
178
|
+
the payment pays for exactly that intent. An approver calls `approveSigningIntent({prepared,
|
|
179
|
+
payment, intent, approver})`: it recomputes the digest from the intent it reviewed and refuses
|
|
180
|
+
before signing when the payment or the statement names anything else. Intents are at most 64 KiB.
|
|
181
|
+
|
|
182
|
+
`slots.p256(slot)` is the same adapter for a threshold P-256 slot (not an Ethereum account):
|
|
183
|
+
`signDigest`, or `signIntent({kind: 'sha256', data})` for the SHA-256 of exact bytes, each
|
|
184
|
+
verified under the anchored key. On either curve a slot with an installed policy refuses a
|
|
185
|
+
signature without its bundle, and a bundle with fewer distinct verified approvals than the
|
|
186
|
+
on-chain quorum, a duplicate approver or a key outside a static set, before any credential
|
|
187
|
+
consent or keeper work.
|
package/docs/reference/README.md
CHANGED
|
@@ -5,19 +5,20 @@ Start with the [learning path](../README.md) if you are building your first TASR
|
|
|
5
5
|
|
|
6
6
|
## Choose a module
|
|
7
7
|
|
|
8
|
-
Most applications start with
|
|
8
|
+
Most applications start with **tasra-sdk/app**. Open a module, then choose Classes,
|
|
9
9
|
Functions, Types or Constants from its page navigation. Each group has its own lookup list.
|
|
10
10
|
|
|
11
11
|
| Module | Import | What you will find |
|
|
12
12
|
|---|---|---|
|
|
13
|
-
| [Application client](app.md) |
|
|
14
|
-
| [Local storage (Node.js)](app-node.md) |
|
|
13
|
+
| [Application client](app.md) | `tasra-sdk/app` | Connect, create slots, manage identities and run application workflows. |
|
|
14
|
+
| [Local storage (Node.js)](app-node.md) | `tasra-sdk/app/node` | Persist application state and coordinate local operations. |
|
|
15
|
+
| [Browser storage and transports](app-browser.md) | `tasra-sdk/app/browser` | Durable IndexedDB state with cross-tab locks, and fetch transports for paid flows. |
|
|
15
16
|
| [Core utilities](main.md) | `@t3foundry/tasra-sdk` | Signing, encryption, credentials and shared helpers. |
|
|
16
|
-
| [Chain access](chain.md) |
|
|
17
|
-
| [Committee operations](committee.md) |
|
|
18
|
-
| [Credentials and OID4VP](oid4vp.md) |
|
|
19
|
-
| [Verifier integration](verifier-agent.md) |
|
|
20
|
-
| [Chain tools (Node.js)](chain-node.md) |
|
|
17
|
+
| [Chain access](chain.md) | `tasra-sdk/chain` | Read contracts, submit transactions, discover services and fund slots. |
|
|
18
|
+
| [Committee operations](committee.md) | `tasra-sdk/committee` | Threshold requests, approvals and operation receipts. |
|
|
19
|
+
| [Credentials and OID4VP](oid4vp.md) | `tasra-sdk/oid4vp` | Credential presentations, wallet flows and issuer verification. |
|
|
20
|
+
| [Verifier integration](verifier-agent.md) | `tasra-sdk/verifier-agent` | Connect wallet and credential flows to a verifier agent. |
|
|
21
|
+
| [Chain tools (Node.js)](chain-node.md) | `tasra-sdk/chain/node` | Load chain configuration from Node.js files. |
|
|
21
22
|
|
|
22
23
|
## Read a declaration
|
|
23
24
|
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# tasra-sdk/app/browser
|
|
2
|
+
|
|
3
|
+
Generated from public TypeScript exports.
|
|
4
|
+
|
|
5
|
+
[SDK reference](README.md) · [Task guides](../README.md) · [Errors](../errors.md)
|
|
6
|
+
|
|
7
|
+
## Classes
|
|
8
|
+
|
|
9
|
+
Clients, adapters and error classes.
|
|
10
|
+
|
|
11
|
+
<details>
|
|
12
|
+
<summary>Browse 1 classes</summary>
|
|
13
|
+
|
|
14
|
+
- [StoreLockedError](#storelockederror)
|
|
15
|
+
|
|
16
|
+
</details>
|
|
17
|
+
|
|
18
|
+
### StoreLockedError
|
|
19
|
+
|
|
20
|
+
A state lock is already held and requires reconciliation before manual removal.
|
|
21
|
+
|
|
22
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/store-errors.ts#L6)
|
|
23
|
+
|
|
24
|
+
Import: `import {StoreLockedError} from 'tasra-sdk/app/browser'`
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
declare class StoreLockedError {
|
|
28
|
+
constructor(key: string);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- ` readonly key: string; ` — Store entry whose exclusive lock could not be acquired.
|
|
33
|
+
|
|
34
|
+
- ` readonly retryable: boolean; ` — `false` when retrying the identical request cannot succeed.
|
|
35
|
+
|
|
36
|
+
- ` name: string; `
|
|
37
|
+
|
|
38
|
+
- ` message: string; `
|
|
39
|
+
|
|
40
|
+
- ` stack?: string; `
|
|
41
|
+
|
|
42
|
+
- ` cause?: unknown; `
|
|
43
|
+
|
|
44
|
+
## Functions
|
|
45
|
+
|
|
46
|
+
Operations you can import and call.
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary>Browse 4 functions</summary>
|
|
50
|
+
|
|
51
|
+
- [createBrowserKeeperRecoveryTransport](#createbrowserkeeperrecoverytransport)
|
|
52
|
+
- [createBrowserPaidAgentTransport](#createbrowserpaidagenttransport)
|
|
53
|
+
- [createBrowserRelayTransport](#createbrowserrelaytransport)
|
|
54
|
+
- [createIndexedDbStore](#createindexeddbstore)
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
### createBrowserKeeperRecoveryTransport
|
|
59
|
+
|
|
60
|
+
Browser transport for reading a keeper's retained paid result (the two POST recovery reads only).
|
|
61
|
+
|
|
62
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L243)
|
|
63
|
+
|
|
64
|
+
Import: `import {createBrowserKeeperRecoveryTransport} from 'tasra-sdk/app/browser'`
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
declare function createBrowserKeeperRecoveryTransport(options?: BrowserKeeperRecoveryTransportOptions): KeeperRecoveryTransport;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Description |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| ` options? ` | ` BrowserKeeperRecoveryTransportOptions ` | Fetch override, approved private hosts, local development HTTP and request deadline. |
|
|
73
|
+
|
|
74
|
+
Returns: ` KeeperRecoveryTransport `.
|
|
75
|
+
|
|
76
|
+
### createBrowserPaidAgentTransport
|
|
77
|
+
|
|
78
|
+
Browser transport for registered paid sessions: authenticated discovery plus owner-only
|
|
79
|
+
session control, with the same route, method, bearer and bound checks as the Node transport.
|
|
80
|
+
|
|
81
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L223)
|
|
82
|
+
|
|
83
|
+
Import: `import {createBrowserPaidAgentTransport} from 'tasra-sdk/app/browser'`
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
declare function createBrowserPaidAgentTransport(options?: BrowserTransportOptions): PaidAgentTransport;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
| Parameter | Type | Description |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| ` options? ` | ` BrowserTransportOptions ` | Fetch override, approved private hosts and request deadline. |
|
|
92
|
+
|
|
93
|
+
Returns: ` PaidAgentTransport `.
|
|
94
|
+
|
|
95
|
+
### createBrowserRelayTransport
|
|
96
|
+
|
|
97
|
+
Browser transport for registered relayers: discovery, forward and status, with
|
|
98
|
+
`relayExchange` reporting busy refusals and their `Retry-After`.
|
|
99
|
+
|
|
100
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L253)
|
|
101
|
+
|
|
102
|
+
Import: `import {createBrowserRelayTransport} from 'tasra-sdk/app/browser'`
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
declare function createBrowserRelayTransport(options?: BrowserTransportOptions): RelayTransport;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| Parameter | Type | Description |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| ` options? ` | ` BrowserTransportOptions ` | Fetch override, approved private hosts and request deadline. |
|
|
111
|
+
|
|
112
|
+
Returns: ` RelayTransport `.
|
|
113
|
+
|
|
114
|
+
### createIndexedDbStore
|
|
115
|
+
|
|
116
|
+
Durable private state for browser applications: IndexedDB records committed with strict
|
|
117
|
+
durability before `save` resolves, and Web Locks (exclusive, shared by every tab, worker and
|
|
118
|
+
extension service worker of this origin) for `withLock`. Values must be plain data (strings,
|
|
119
|
+
finite numbers, booleans, bigints, Uint8Array, arrays and plain objects).
|
|
120
|
+
|
|
121
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L66)
|
|
122
|
+
|
|
123
|
+
Import: `import {createIndexedDbStore} from 'tasra-sdk/app/browser'`
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
declare function createIndexedDbStore(options?: IndexedDbStoreOptions): ApplicationStore;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| Parameter | Type | Description |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| ` options? ` | ` IndexedDbStoreOptions ` | Database name, factory/lock overrides and lock-wait behavior. |
|
|
132
|
+
|
|
133
|
+
Returns: ` ApplicationStore `.
|
|
134
|
+
|
|
135
|
+
## Types
|
|
136
|
+
|
|
137
|
+
Options, data structures and return types.
|
|
138
|
+
|
|
139
|
+
<details>
|
|
140
|
+
<summary>Browse 4 types</summary>
|
|
141
|
+
|
|
142
|
+
- [ApplicationStore](#applicationstore)
|
|
143
|
+
- [BrowserKeeperRecoveryTransportOptions](#browserkeeperrecoverytransportoptions)
|
|
144
|
+
- [BrowserTransportOptions](#browsertransportoptions)
|
|
145
|
+
- [IndexedDbStoreOptions](#indexeddbstoreoptions)
|
|
146
|
+
|
|
147
|
+
</details>
|
|
148
|
+
|
|
149
|
+
### ApplicationStore
|
|
150
|
+
|
|
151
|
+
Implementations must save atomically and exclusively lock across processes/tabs.
|
|
152
|
+
|
|
153
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/ready-slot.ts#L40)
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
export interface ApplicationStore {
|
|
157
|
+
load<T>(key: string): Promise<T | undefined>;
|
|
158
|
+
save(key: string, value: unknown): Promise<void>;
|
|
159
|
+
withLock<T>(key: string, operation: () => Promise<T>): Promise<T>;
|
|
160
|
+
list?(prefix: string): Promise<string[]>;
|
|
161
|
+
claim?(key: string): Promise<boolean>;
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Fields:
|
|
166
|
+
|
|
167
|
+
- **` load `**: Load a saved value, or return undefined when the key does not exist.
|
|
168
|
+
- **` save `**: Atomically persist private state before resolving.
|
|
169
|
+
- **` withLock `**: Exclusively serialize work for the key across all participating processes or tabs.
|
|
170
|
+
- **` list `**: Optional: keys starting with `prefix`, in any order. Used only for one-time maintenance such as backfilling the paid operation index; stores without it still work everywhere else.
|
|
171
|
+
- **` claim `**: Optional: atomically and durably create the record `key` only if it does not exist, across all participating processes or tabs. Resolves true for exactly one caller, false when the key already exists. Paid approvals use it as a one-use, generation-bound send claim; without it a retained approval is sent once and never resent.
|
|
172
|
+
|
|
173
|
+
### BrowserKeeperRecoveryTransportOptions
|
|
174
|
+
|
|
175
|
+
Options for [createBrowserKeeperRecoveryTransport](#createbrowserkeeperrecoverytransport).
|
|
176
|
+
|
|
177
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L229)
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
export interface BrowserKeeperRecoveryTransportOptions extends BrowserTransportOptions {
|
|
181
|
+
allowLocalHttp?: boolean;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Fields:
|
|
186
|
+
|
|
187
|
+
- **` allowLocalHttp `**: Local development fleet: also permit plain HTTP to loopback names and private IP literals (and only those), like the keepers of a local chain. Default false: HTTPS only. The recovery reads separately permit HTTP only on the local development chain (43112) with the paid operation's `allowLocalHttp`.
|
|
188
|
+
- **` fetch `**: Fetch implementation (default global fetch).
|
|
189
|
+
- **` allowedPrivateHosts `**: Exact loopback names or private IP literals the application approves (e.g. `localhost` during local development).
|
|
190
|
+
- **` timeoutMs `**: Absolute per-request deadline in ms (default 30000).
|
|
191
|
+
|
|
192
|
+
### BrowserTransportOptions
|
|
193
|
+
|
|
194
|
+
Options shared by the browser transports.
|
|
195
|
+
|
|
196
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L135)
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
export interface BrowserTransportOptions {
|
|
200
|
+
fetch?: typeof fetch;
|
|
201
|
+
allowedPrivateHosts?: readonly string[];
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Fields:
|
|
207
|
+
|
|
208
|
+
- **` fetch `**: Fetch implementation (default global fetch).
|
|
209
|
+
- **` allowedPrivateHosts `**: Exact loopback names or private IP literals the application approves (e.g. `localhost` during local development).
|
|
210
|
+
- **` timeoutMs `**: Absolute per-request deadline in ms (default 30000).
|
|
211
|
+
|
|
212
|
+
### IndexedDbStoreOptions
|
|
213
|
+
|
|
214
|
+
Options for [createIndexedDbStore](#createindexeddbstore).
|
|
215
|
+
|
|
216
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/browser.ts#L31)
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
export interface IndexedDbStoreOptions {
|
|
220
|
+
name?: string;
|
|
221
|
+
indexedDB?: IDBFactory;
|
|
222
|
+
locks?: LockManager;
|
|
223
|
+
failIfLocked?: boolean;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Fields:
|
|
228
|
+
|
|
229
|
+
- **` name `**: Database name; one per application and deployment (default `tasra-sdk-state`).
|
|
230
|
+
- **` indexedDB `**: IndexedDB factory (default `globalThis.indexedDB`).
|
|
231
|
+
- **` locks `**: Web Locks manager (default `navigator.locks`). Required: tabs must share exclusive locks.
|
|
232
|
+
- **` failIfLocked `**: Fail with StoreLockedError instead of waiting when another tab holds the lock (default false: wait).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tasra-sdk/app/node
|
|
2
2
|
|
|
3
3
|
Generated from public TypeScript exports.
|
|
4
4
|
|
|
@@ -19,9 +19,9 @@ Clients, adapters and error classes.
|
|
|
19
19
|
|
|
20
20
|
A state lock is already held and requires reconciliation before manual removal.
|
|
21
21
|
|
|
22
|
-
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/
|
|
22
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/store-errors.ts#L6)
|
|
23
23
|
|
|
24
|
-
Import: `import {StoreLockedError} from '
|
|
24
|
+
Import: `import {StoreLockedError} from 'tasra-sdk/app/node'`
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
declare class StoreLockedError {
|
|
@@ -56,17 +56,18 @@ Operations you can import and call.
|
|
|
56
56
|
|
|
57
57
|
The directory is private, trusted application state, not an untrusted shared folder.
|
|
58
58
|
|
|
59
|
-
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#
|
|
59
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#L181)
|
|
60
60
|
|
|
61
|
-
Import: `import {createFileStore} from '
|
|
61
|
+
Import: `import {createFileStore} from 'tasra-sdk/app/node'`
|
|
62
62
|
|
|
63
63
|
```ts
|
|
64
|
-
declare function createFileStore(directory: string): ApplicationStore;
|
|
64
|
+
declare function createFileStore(directory: string, options?: FileStoreOptions): ApplicationStore;
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
| Parameter | Type | Description |
|
|
68
68
|
|---|---|---|
|
|
69
69
|
| ` directory ` | ` string ` | Private application state directory owned by the current operating-system user. |
|
|
70
|
+
| ` options? ` | ` FileStoreOptions ` | Bounded wait for a lock held by another process. |
|
|
70
71
|
|
|
71
72
|
Returns: ` ApplicationStore `.
|
|
72
73
|
|
|
@@ -75,9 +76,10 @@ Returns: ` ApplicationStore `.
|
|
|
75
76
|
Options, data structures and return types.
|
|
76
77
|
|
|
77
78
|
<details>
|
|
78
|
-
<summary>Browse
|
|
79
|
+
<summary>Browse 2 types</summary>
|
|
79
80
|
|
|
80
81
|
- [ApplicationStore](#applicationstore)
|
|
82
|
+
- [FileStoreOptions](#filestoreoptions)
|
|
81
83
|
|
|
82
84
|
</details>
|
|
83
85
|
|
|
@@ -85,13 +87,15 @@ Options, data structures and return types.
|
|
|
85
87
|
|
|
86
88
|
Durable private state storage with exclusive locking for each named operation.
|
|
87
89
|
|
|
88
|
-
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#
|
|
90
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#L14)
|
|
89
91
|
|
|
90
92
|
```ts
|
|
91
93
|
export interface ApplicationStore {
|
|
92
94
|
load<T>(key: string): Promise<T | undefined>;
|
|
93
95
|
save<T>(key: string, value: T): Promise<void>;
|
|
94
96
|
withLock<T>(key: string, action: () => Promise<T>): Promise<T>;
|
|
97
|
+
list?(prefix: string): Promise<string[]>;
|
|
98
|
+
claim?(key: string): Promise<boolean>;
|
|
95
99
|
}
|
|
96
100
|
```
|
|
97
101
|
|
|
@@ -100,3 +104,29 @@ Fields:
|
|
|
100
104
|
- **` load `**: Load a saved value, or return undefined when the key does not exist.
|
|
101
105
|
- **` save `**: Atomically persist private state before resolving.
|
|
102
106
|
- **` withLock `**: Exclusively serialize work for the key across all participating processes or tabs.
|
|
107
|
+
- **` list `**: Optional: keys starting with `prefix`, in any order. Used only for one-time maintenance such as backfilling the paid operation index; stores without it still work everywhere else.
|
|
108
|
+
- **` claim `**: Optional: atomically and durably create the record `key` only if it does not exist, across all participating processes or tabs. Resolves true for exactly one caller, false when the key already exists. Paid approvals use it as a one-use, generation-bound send claim; without it a retained approval is sent once and never resent.
|
|
109
|
+
|
|
110
|
+
### FileStoreOptions
|
|
111
|
+
|
|
112
|
+
Options for [createFileStore](#createfilestore).
|
|
113
|
+
|
|
114
|
+
[Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#L166)
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
export interface FileStoreOptions {
|
|
118
|
+
lockWaitMs?: number;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Fields:
|
|
123
|
+
|
|
124
|
+
- **` lockWaitMs `**: Longest wait, in ms, for a lock held by ANOTHER process before `withLock` refuses with StoreLockedError (default 10000; 0 refuses at once; at most 600000). A lock left by a crashed process is never removed or taken over: after the wait it still needs reconciliation. Calls in this process never refuse each other; they queue in call order.
|
|
125
|
+
|
|
126
|
+
## Constants and ABI values
|
|
127
|
+
|
|
128
|
+
Shared values and contract definitions.
|
|
129
|
+
|
|
130
|
+
| Export | Description | Definition |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| `fileStoreSyncCounters` | Durable-write steps the store counts (for tests and measurement); never part of the stored state. `flushes`: device flushes of a state directory (each one F_FULLFSYNC on macOS), whatever they served; `shared`: those that served a data barrier and a directory sync at once; `fileSyncs`: per-file syncs (only without O_DSYNC). | [Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#L151) |
|