@t3foundry/tasra-sdk 0.0.0-stage → 0.3.0-next.1

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.
Files changed (322) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +94 -0
  4. package/README.md +137 -2
  5. package/SECURITY.md +115 -0
  6. package/dist/app/approvals.d.ts +50 -0
  7. package/dist/app/approvals.js +90 -0
  8. package/dist/app/authorization.d.ts +19 -0
  9. package/dist/app/authorization.js +20 -0
  10. package/dist/app/client.d.ts +231 -0
  11. package/dist/app/client.js +272 -0
  12. package/dist/app/creation.d.ts +73 -0
  13. package/dist/app/creation.js +77 -0
  14. package/dist/app/deployment.d.ts +36 -0
  15. package/dist/app/deployment.js +18 -0
  16. package/dist/app/identity.d.ts +211 -0
  17. package/dist/app/identity.js +287 -0
  18. package/dist/app/index.d.ts +22 -0
  19. package/dist/app/index.js +12 -0
  20. package/dist/app/manifest.d.ts +74 -0
  21. package/dist/app/manifest.js +120 -0
  22. package/dist/app/node.d.ts +30 -0
  23. package/dist/app/node.js +159 -0
  24. package/dist/app/ready-slot.d.ts +157 -0
  25. package/dist/app/ready-slot.js +199 -0
  26. package/dist/app/tasra-client.d.ts +125 -0
  27. package/dist/app/tasra-client.js +79 -0
  28. package/dist/app/viem.d.ts +10 -0
  29. package/dist/app/viem.js +32 -0
  30. package/dist/app/wallet.d.ts +126 -0
  31. package/dist/app/wallet.js +137 -0
  32. package/dist/auth/dpop.d.ts +86 -0
  33. package/dist/auth/dpop.js +142 -0
  34. package/dist/auth/holderProof.d.ts +102 -0
  35. package/dist/auth/holderProof.js +161 -0
  36. package/dist/auth/identityScope.d.ts +19 -0
  37. package/dist/auth/identityScope.js +82 -0
  38. package/dist/auth/index.d.ts +11 -0
  39. package/dist/auth/index.js +13 -0
  40. package/dist/auth/oid4vp.d.ts +230 -0
  41. package/dist/auth/oid4vp.js +780 -0
  42. package/dist/auth/rego/wasm/PINS.json +11 -0
  43. package/dist/auth/rego/wasm/keykeeper_rego_wasm.d.ts +76 -0
  44. package/dist/auth/rego/wasm/keykeeper_rego_wasm.js +379 -0
  45. package/dist/auth/rego/wasm/keykeeper_rego_wasm_bg.wasm +0 -0
  46. package/dist/auth/rego.d.ts +192 -0
  47. package/dist/auth/rego.js +492 -0
  48. package/dist/auth/verifier.d.ts +166 -0
  49. package/dist/auth/verifier.js +211 -0
  50. package/dist/chain/abis/accountantSetRegistry.d.ts +441 -0
  51. package/dist/chain/abis/accountantSetRegistry.js +574 -0
  52. package/dist/chain/abis/accountantSlashing.d.ts +2071 -0
  53. package/dist/chain/abis/accountantSlashing.js +2670 -0
  54. package/dist/chain/abis/bondingCurve.d.ts +398 -0
  55. package/dist/chain/abis/bondingCurve.js +521 -0
  56. package/dist/chain/abis/equivocationSlasher.d.ts +292 -0
  57. package/dist/chain/abis/equivocationSlasher.js +379 -0
  58. package/dist/chain/abis/fixedTasraPriceOracle.d.ts +52 -0
  59. package/dist/chain/abis/fixedTasraPriceOracle.js +72 -0
  60. package/dist/chain/abis/index.d.ts +12801 -0
  61. package/dist/chain/abis/index.js +64 -0
  62. package/dist/chain/abis/keeperShareRegistry.d.ts +519 -0
  63. package/dist/chain/abis/keeperShareRegistry.js +675 -0
  64. package/dist/chain/abis/keyRegistry.d.ts +2421 -0
  65. package/dist/chain/abis/keyRegistry.js +3114 -0
  66. package/dist/chain/abis/livenessRegistry.d.ts +402 -0
  67. package/dist/chain/abis/livenessRegistry.js +524 -0
  68. package/dist/chain/abis/mockEurc.d.ts +210 -0
  69. package/dist/chain/abis/mockEurc.js +276 -0
  70. package/dist/chain/abis/nodeRegistry.d.ts +1630 -0
  71. package/dist/chain/abis/nodeRegistry.js +2113 -0
  72. package/dist/chain/abis/platformExecutor.d.ts +328 -0
  73. package/dist/chain/abis/platformExecutor.js +429 -0
  74. package/dist/chain/abis/prevrandaoSaltBeacon.d.ts +16 -0
  75. package/dist/chain/abis/prevrandaoSaltBeacon.js +24 -0
  76. package/dist/chain/abis/serviceRegistry.d.ts +556 -0
  77. package/dist/chain/abis/serviceRegistry.js +719 -0
  78. package/dist/chain/abis/settlement.d.ts +1624 -0
  79. package/dist/chain/abis/settlement.js +2096 -0
  80. package/dist/chain/abis/tasraSwapRouter.d.ts +92 -0
  81. package/dist/chain/abis/tasraSwapRouter.js +122 -0
  82. package/dist/chain/abis/tasraToken.d.ts +455 -0
  83. package/dist/chain/abis/tasraToken.js +599 -0
  84. package/dist/chain/abis/tasraVestingVault.d.ts +165 -0
  85. package/dist/chain/abis/tasraVestingVault.js +215 -0
  86. package/dist/chain/abis/thresholdRandomBeacon.d.ts +378 -0
  87. package/dist/chain/abis/thresholdRandomBeacon.js +494 -0
  88. package/dist/chain/abis/treasury.d.ts +301 -0
  89. package/dist/chain/abis/treasury.js +390 -0
  90. package/dist/chain/abis/verifierSetRegistry.d.ts +445 -0
  91. package/dist/chain/abis/verifierSetRegistry.js +579 -0
  92. package/dist/chain/client.d.ts +212 -0
  93. package/dist/chain/client.js +576 -0
  94. package/dist/chain/commitmentRecovery.d.ts +21 -0
  95. package/dist/chain/commitmentRecovery.js +44 -0
  96. package/dist/chain/committeeClient.d.ts +102 -0
  97. package/dist/chain/committeeClient.js +137 -0
  98. package/dist/chain/deployments.d.ts +56 -0
  99. package/dist/chain/deployments.js +269 -0
  100. package/dist/chain/discovery.d.ts +49 -0
  101. package/dist/chain/discovery.js +107 -0
  102. package/dist/chain/events.d.ts +58 -0
  103. package/dist/chain/events.js +125 -0
  104. package/dist/chain/format.d.ts +25 -0
  105. package/dist/chain/format.js +51 -0
  106. package/dist/chain/index.d.ts +41 -0
  107. package/dist/chain/index.js +56 -0
  108. package/dist/chain/manifest.d.ts +165 -0
  109. package/dist/chain/manifest.js +132 -0
  110. package/dist/chain/network-profiles.json +75 -0
  111. package/dist/chain/networks.d.ts +73 -0
  112. package/dist/chain/networks.js +62 -0
  113. package/dist/chain/node.d.ts +44 -0
  114. package/dist/chain/node.js +176 -0
  115. package/dist/chain/offchain.d.ts +149 -0
  116. package/dist/chain/offchain.js +73 -0
  117. package/dist/chain/provisionRule.d.ts +164 -0
  118. package/dist/chain/provisionRule.js +212 -0
  119. package/dist/chain/registeredAgent.d.ts +64 -0
  120. package/dist/chain/registeredAgent.js +140 -0
  121. package/dist/chain/registeredOperation.d.ts +49 -0
  122. package/dist/chain/registeredOperation.js +136 -0
  123. package/dist/chain/registeredRelay.d.ts +206 -0
  124. package/dist/chain/registeredRelay.js +312 -0
  125. package/dist/chain/revertReason.d.ts +14 -0
  126. package/dist/chain/revertReason.js +62 -0
  127. package/dist/chain/ruleAmendment.d.ts +80 -0
  128. package/dist/chain/ruleAmendment.js +195 -0
  129. package/dist/chain/ruleAmendmentCore.d.ts +129 -0
  130. package/dist/chain/ruleAmendmentCore.js +152 -0
  131. package/dist/chain/ruleInput.d.ts +10 -0
  132. package/dist/chain/ruleInput.js +13 -0
  133. package/dist/chain/serviceIdentity.d.ts +176 -0
  134. package/dist/chain/serviceIdentity.js +237 -0
  135. package/dist/chain/serviceProfiles.d.ts +39 -0
  136. package/dist/chain/serviceProfiles.js +74 -0
  137. package/dist/chain/services.d.ts +141 -0
  138. package/dist/chain/services.js +79 -0
  139. package/dist/chain/slotClient.d.ts +55 -0
  140. package/dist/chain/slotClient.js +62 -0
  141. package/dist/chain/slotSeed.d.ts +31 -0
  142. package/dist/chain/slotSeed.js +98 -0
  143. package/dist/chain/write.d.ts +431 -0
  144. package/dist/chain/write.js +958 -0
  145. package/dist/client/client.d.ts +112 -0
  146. package/dist/client/client.js +111 -0
  147. package/dist/client/index.d.ts +3 -0
  148. package/dist/client/index.js +2 -0
  149. package/dist/client/session.d.ts +67 -0
  150. package/dist/client/session.js +238 -0
  151. package/dist/committee/client.d.ts +284 -0
  152. package/dist/committee/client.js +351 -0
  153. package/dist/committee/dual-sign.d.ts +110 -0
  154. package/dist/committee/dual-sign.js +202 -0
  155. package/dist/committee/ecdsa.d.ts +36 -0
  156. package/dist/committee/ecdsa.js +45 -0
  157. package/dist/committee/extraction.d.ts +82 -0
  158. package/dist/committee/extraction.js +96 -0
  159. package/dist/committee/index.d.ts +19 -0
  160. package/dist/committee/index.js +13 -0
  161. package/dist/committee/oauth.d.ts +51 -0
  162. package/dist/committee/oauth.js +90 -0
  163. package/dist/committee/receipts.d.ts +51 -0
  164. package/dist/committee/receipts.js +59 -0
  165. package/dist/committee/request.d.ts +264 -0
  166. package/dist/committee/request.js +305 -0
  167. package/dist/committee/token.d.ts +274 -0
  168. package/dist/committee/token.js +418 -0
  169. package/dist/crypto/constants.d.ts +10 -0
  170. package/dist/crypto/constants.js +32 -0
  171. package/dist/crypto/detect.d.ts +20 -0
  172. package/dist/crypto/detect.js +44 -0
  173. package/dist/crypto/envelope.d.ts +60 -0
  174. package/dist/crypto/envelope.js +243 -0
  175. package/dist/crypto/frost.d.ts +49 -0
  176. package/dist/crypto/frost.js +152 -0
  177. package/dist/crypto/hex.d.ts +7 -0
  178. package/dist/crypto/hex.js +24 -0
  179. package/dist/crypto/ibe-blob.d.ts +114 -0
  180. package/dist/crypto/ibe-blob.js +208 -0
  181. package/dist/crypto/ibe.d.ts +88 -0
  182. package/dist/crypto/ibe.js +262 -0
  183. package/dist/crypto/index.d.ts +12 -0
  184. package/dist/crypto/index.js +12 -0
  185. package/dist/crypto/kem.d.ts +55 -0
  186. package/dist/crypto/kem.js +241 -0
  187. package/dist/decryption/client.d.ts +64 -0
  188. package/dist/decryption/client.js +82 -0
  189. package/dist/decryption/index.d.ts +2 -0
  190. package/dist/decryption/index.js +2 -0
  191. package/dist/errors.d.ts +124 -0
  192. package/dist/errors.js +167 -0
  193. package/dist/index.d.ts +43 -0
  194. package/dist/index.js +98 -0
  195. package/dist/keys/index.d.ts +1 -0
  196. package/dist/keys/index.js +4 -0
  197. package/dist/keys/node-client.d.ts +27 -0
  198. package/dist/keys/node-client.js +97 -0
  199. package/dist/oid4vp/binding.d.ts +76 -0
  200. package/dist/oid4vp/binding.js +118 -0
  201. package/dist/oid4vp/did-web.d.ts +49 -0
  202. package/dist/oid4vp/did-web.js +57 -0
  203. package/dist/oid4vp/index.d.ts +9 -0
  204. package/dist/oid4vp/index.js +10 -0
  205. package/dist/oid4vp/jose.d.ts +166 -0
  206. package/dist/oid4vp/jose.js +242 -0
  207. package/dist/oid4vp/jwe.d.ts +30 -0
  208. package/dist/oid4vp/jwe.js +93 -0
  209. package/dist/oid4vp/oid4vci.d.ts +84 -0
  210. package/dist/oid4vp/oid4vci.js +85 -0
  211. package/dist/oid4vp/request-object.d.ts +109 -0
  212. package/dist/oid4vp/request-object.js +96 -0
  213. package/dist/oid4vp/sd-jwt.d.ts +177 -0
  214. package/dist/oid4vp/sd-jwt.js +208 -0
  215. package/dist/oid4vp/verifier-agent.d.ts +161 -0
  216. package/dist/oid4vp/verifier-agent.js +132 -0
  217. package/dist/oid4vp/wallet.d.ts +116 -0
  218. package/dist/oid4vp/wallet.js +108 -0
  219. package/dist/recipient/store.d.ts +67 -0
  220. package/dist/recipient/store.js +98 -0
  221. package/dist/signing/ecdsa.d.ts +49 -0
  222. package/dist/signing/ecdsa.js +79 -0
  223. package/dist/signing/frost.d.ts +88 -0
  224. package/dist/signing/frost.js +145 -0
  225. package/dist/signing/index.d.ts +4 -0
  226. package/dist/signing/index.js +3 -0
  227. package/dist/slots/faucet.d.ts +23 -0
  228. package/dist/slots/faucet.js +35 -0
  229. package/dist/slots/index.d.ts +2 -0
  230. package/dist/slots/index.js +4 -0
  231. package/dist/verifier-agent/index.d.ts +241 -0
  232. package/dist/verifier-agent/index.js +411 -0
  233. package/docs/DEVELOPER-EXPERIENCE.md +62 -0
  234. package/docs/README.md +33 -0
  235. package/docs/access-control.md +76 -0
  236. package/docs/ai-development.md +292 -0
  237. package/docs/api.md +338 -0
  238. package/docs/application-api.md +335 -0
  239. package/docs/architecture.md +65 -0
  240. package/docs/basics.md +48 -0
  241. package/docs/capabilities.md +86 -0
  242. package/docs/chain.md +153 -0
  243. package/docs/compatibility.md +36 -0
  244. package/docs/consumer-migrations.md +80 -0
  245. package/docs/create-slot.md +104 -0
  246. package/docs/document-signing.md +243 -0
  247. package/docs/encrypted-notes.md +129 -0
  248. package/docs/encryption.md +100 -0
  249. package/docs/errors.md +76 -0
  250. package/docs/flows.md +289 -0
  251. package/docs/fuji.md +127 -0
  252. package/docs/funding.md +126 -0
  253. package/docs/getting-started.md +94 -0
  254. package/docs/glossary.md +44 -0
  255. package/docs/installation.md +132 -0
  256. package/docs/manage-slot.md +95 -0
  257. package/docs/native-approvals.md +124 -0
  258. package/docs/prerequisites.md +137 -0
  259. package/docs/read-slot.md +41 -0
  260. package/docs/reference/README.md +30 -0
  261. package/docs/reference/app-node.md +102 -0
  262. package/docs/reference/app.md +1737 -0
  263. package/docs/reference/chain-node.md +159 -0
  264. package/docs/reference/chain.md +3609 -0
  265. package/docs/reference/committee.md +2176 -0
  266. package/docs/reference/main.md +4068 -0
  267. package/docs/reference/oid4vp.md +2547 -0
  268. package/docs/reference/verifier-agent.md +498 -0
  269. package/docs/shared-account.md +168 -0
  270. package/docs/signing-and-encryption.md +52 -0
  271. package/docs/signing.md +172 -0
  272. package/examples/committee-slot.ts +16 -0
  273. package/examples/connect-fuji.ts +41 -0
  274. package/examples/connect-network.ts +14 -0
  275. package/examples/credential-approvals.ts +46 -0
  276. package/examples/document-signing/README.md +59 -0
  277. package/examples/document-signing/backend.ts +132 -0
  278. package/examples/document-signing/build.mjs +19 -0
  279. package/examples/document-signing/config.ts +34 -0
  280. package/examples/document-signing/gitignore.template +9 -0
  281. package/examples/document-signing/model.ts +140 -0
  282. package/examples/document-signing/network.ts +58 -0
  283. package/examples/document-signing/package.json +25 -0
  284. package/examples/document-signing/public/index.html +27 -0
  285. package/examples/document-signing/public/sample.pdf +31 -0
  286. package/examples/document-signing/public/styles.css +531 -0
  287. package/examples/document-signing/server.ts +358 -0
  288. package/examples/document-signing/setup.ts +111 -0
  289. package/examples/document-signing/store.ts +105 -0
  290. package/examples/document-signing/tsconfig.json +24 -0
  291. package/examples/document-signing/verify.ts +24 -0
  292. package/examples/document-signing/web/app.ts +312 -0
  293. package/examples/document-signing/web/preview.ts +67 -0
  294. package/examples/document-signing/web/wallet.ts +146 -0
  295. package/examples/document-signing/workflow.test.ts +228 -0
  296. package/examples/document-signing/workflow.ts +241 -0
  297. package/examples/document-signing.ts +96 -0
  298. package/examples/encrypted-notes.ts +86 -0
  299. package/examples/ethers-signer.ts +204 -0
  300. package/examples/fund-slot.ts +73 -0
  301. package/examples/getting-started.ts +25 -0
  302. package/examples/learning-authorize.ts +23 -0
  303. package/examples/learning-cancel-slot.ts +11 -0
  304. package/examples/learning-context.ts +28 -0
  305. package/examples/learning-create-slot.ts +25 -0
  306. package/examples/learning-read-slot.ts +8 -0
  307. package/examples/learning-renew-slot.ts +12 -0
  308. package/examples/learning-sign.ts +8 -0
  309. package/examples/live-config.ts +71 -0
  310. package/examples/minimal.ts +6 -0
  311. package/examples/native-approvals.ts +57 -0
  312. package/examples/network.ts +58 -0
  313. package/examples/offline.ts +16 -0
  314. package/examples/personal-vault.ts +20 -0
  315. package/examples/provision-slot.ts +47 -0
  316. package/examples/shared-account.ts +46 -0
  317. package/examples/slot-address.ts +13 -0
  318. package/examples/slot-creation.ts +9 -0
  319. package/examples/tutorial-negative.ts +26 -0
  320. package/examples/tutorial-support.ts +76 -0
  321. package/examples/viem-account.ts +203 -0
  322. package/package.json +303 -4
package/docs/chain.md ADDED
@@ -0,0 +1,153 @@
1
+ # `@t3foundry/tasra-sdk/chain` — on-chain + network-service
2
+
3
+ > The chain subpath: reads, writes, slot creation, discovery, and the slot-driven clients.
4
+
5
+ Download the selected manifest from
6
+ [tasra-releases](https://github.com/t3foundry/tasra-releases), verify its trusted
7
+ checksum, and derive the address book with `addressBookFromManifest`.
8
+
9
+ ## Create a read client
10
+
11
+ ```ts
12
+ import {createTasraChainClient} from '@t3foundry/tasra-sdk/chain'
13
+
14
+ // rpcUrl, chainId and addresses come from your deployment configuration.
15
+ const chain = createTasraChainClient({rpcUrl, chainId, addresses})
16
+ const block = await chain.client.getBlockNumber()
17
+ const slot = await chain.readers.keyRegistry.getKeySlot(slotId)
18
+ ```
19
+
20
+ | Parameter | Required? | Source / meaning |
21
+ |---|---|---|
22
+ | `rpcUrl` | Yes | Deployment's JSON-RPC endpoint. |
23
+ | `addresses` | Yes | `addressBookFromManifest(manifest)` for the downloaded release manifest. Include the contracts your reads use. |
24
+ | `chainId` | Pass explicitly | Deployment chain ID. The constructor does not query the RPC to verify it. |
25
+ | `logWindow` | No | Maximum block range per `getLogs` query; defaults to 2,000. |
26
+ | `multicall3` | No | Auto-detected by default; pass an address or `false` to disable batching. |
27
+
28
+ **Returns:** a `TasraChainClient`. Use `client` for underlying viem calls and `readers`
29
+ for typed Tasra contract calls. Creating the client performs no network request;
30
+ individual reads can fail if the RPC is unreachable or a contract address is wrong.
31
+ Compare `await chain.client.getChainId()` with your configured ID before use.
32
+
33
+ ## Verify a deployment
34
+
35
+ After loading `manifest` and `rpcUrl` as in the [Fuji guide](fuji.md):
36
+
37
+ ```ts
38
+ import {observeNetworkManifest} from '@t3foundry/tasra-sdk/chain'
39
+
40
+ const observation = await observeNetworkManifest(manifest, rpcUrl)
41
+ if (!observation.matches) throw new Error('Deployed contract code differs from the manifest')
42
+ console.log(observation.blockNumber)
43
+ ```
44
+
45
+ This checks chain identity, the manifest's recorded block, contract bytecode, and proxy
46
+ implementations at a finalized block. **Inspect `matches`**: mismatched code is reported
47
+ in the result. RPC errors or a chain mismatch can throw. Passing this check does not
48
+ verify credentials, service versions, access policy, or successful signing/decryption.
49
+
50
+ ## Available chain APIs
51
+
52
+ A separate subpath export (so the crypto core stays lean and `viem` is only
53
+ loaded when you need it):
54
+
55
+ - **Contract ABIs** + a name→ABI map, generated from the Foundry artifacts.
56
+ - **Address discovery** — build an `AddressBook` from a Foundry broadcast JSON, an
57
+ env file, or an inline object. `addressBookFromBroadcast`/`Env`/`Object`, `requireAddress`.
58
+ Broadcast parsing handles both deploy shapes (plain `CREATE` and CREATE2 via the
59
+ `DeterministicDeployer`) and resolves UUPS contracts to their proxy, never the
60
+ implementation. Vesting vaults resolve per tranche — `requireVaultAddress(book, 'team')`.
61
+ - **Event registry + decoding** — `decodeContractLogs`, contract categorization, `jsonSafe`.
62
+ - **viem read client** — `createTasraChainClient`: a `PublicClient` with windowed
63
+ `getLogs` and typed readers across NodeRegistry, KeyRegistry, Settlement,
64
+ TasraToken, BondingCurve, Treasury, TasraVestingVault (per tranche), and the beacon.
65
+ - **Network-service read clients** — `nodeApi`, `verifierApi`, and a Prometheus parser
66
+ for node/verifier info, key slots, heartbeats, and metering.
67
+ - **Sovereign write client** — `createTasraWriteClient` / `generateClientKey`:
68
+ a client signs its own slot creation (incl. commit-reveal) + settlement funding,
69
+ no relayer.
70
+ - **Slot-driven JWT client** — `createTasraSlotClient`: same surface as
71
+ `createTasraClient`, but endpoints come from the registry — the keeper nodes from the
72
+ slot's on-chain committee (`assignedNodes`) and the **verifier chosen from the on-chain
73
+ verifier set** (`keccak256("verifier")`). That chosen verifier mints the session JWT, so
74
+ the verifier participates in session authorization (`onResolve` surfaces which one).
75
+ - **Slot-driven committee client** — `createCommitteeSlotClient`: the committee path
76
+ from just a **slot id**, with **no static fallback**. It resolves the slot's keeper node
77
+ and the active verifier set **only from chain** (`resolveSlotKeeperUrls`,
78
+ `resolveVerifierDirectory` — verifiers are `NodeRegistry` operators tagged
79
+ `keccak256("verifier")`, `VERIFIER_TAG`, indexed by ascending address to match the
80
+ anchored snapshot), lets the beacon-seeded on-chain draw pick the committee, gathers a
81
+ quorum of attributable verifier signatures, and submits the compound token —
82
+ `sign` / `encrypt` / `decrypt`. There is no way to pass a hardcoded node/verifier list,
83
+ and it **requires** trustless `VerifierSetRegistry` inclusion proofs (throws rather than
84
+ let the keeper validate against a statically-configured set).
85
+ - **Format helpers** — `truncateHex`, `formatUnits`, `formatBps`, `formatWad`.
86
+
87
+ ## Fund creation and usage
88
+
89
+ The creator needs AVAX for gas on Avalanche. Buy TASRA with EURC through
90
+ `approveEurcForCurve` and `buyTsra`, then deposit it into each slot with `fundSlot`.
91
+ [The funding guide](funding.md) includes the official Fuji faucet, runnable
92
+ commands and separate wallet/slot balance checks.
93
+
94
+ ## Commit/reveal slot creation
95
+
96
+ `writer.createSlotCommitReveal(args)` commits the slot parameters, then requests a
97
+ per-commitment seed from the accountant set. Compatible deployments can reveal the
98
+ slot immediately with that seed. If a seed is unavailable or the registry does not
99
+ support it, the client falls back to waiting for the beacon epoch before revealing.
100
+
101
+ The options in `CommitRevealOptions` let you set `accountantUrls`, bound each request
102
+ with `slotSeedTimeoutMs`, observe the seed request with `onSeed`, or use
103
+ `slotSeed: false` to select the epoch path. `onEpoch` reports only the fallback wait;
104
+ `maxWaitMs` bounds that wait. The result includes `seeded`, which reports whether the
105
+ seeded reveal succeeded, alongside `slotId`, `ruleSalt`, `commitTx`, `revealTx`, and
106
+ `targetEpoch`.
107
+
108
+ For a custom commit/reveal flow, use `resolveAccountantUrls(chain)` and
109
+ `requestSlotSeed(chain, keyRegistry, commitment, options)`. Seed responses are checked
110
+ against the registry's commitment digest; the contract verifies the signature during
111
+ reveal. A failed seeded reveal through a relay is returned to the caller rather than
112
+ starting another signed request with the same forwarder nonce.
113
+
114
+ ## Slot-driven committee flow (no hardcoded endpoints)
115
+
116
+ The committee path derives its keeper node and verifier set from the slot id and accepts
117
+ **no static list at all** — a slot is bound to its keeper committee on-chain at creation, and
118
+ verifiers are discovered network-wide by their `keccak256("verifier")` tag. "Random verifier
119
+ selection" is the beacon-seeded, verifiable on-chain committee draw, not a client
120
+ coin-flip. And unlike the JWT-path `Session` — whose `decrypt` reconstructs the master key
121
+ client-side — committee `sign`/`decrypt` are **node-coordinated: the key is never
122
+ reassembled**. Keepers enforce authorization; metering and audit behavior depend
123
+ on deployment configuration. The flow
124
+ refuses to proceed unless the trustless on-chain verifier-set proofs are derivable, so it
125
+ never degrades to a keeper's statically-configured set.
126
+
127
+ ```ts
128
+ import {createHolderProof} from '@t3foundry/tasra-sdk'
129
+ import {createTasraChainClient, createCommitteeSlotClient, addressBookFromManifest} from '@t3foundry/tasra-sdk/chain'
130
+
131
+ const chain = createTasraChainClient({rpcUrl, addresses: addressBookFromManifest(manifest)})
132
+ const audience = 'your-verifier-iss'
133
+ const holderProof = await createHolderProof(verifierUrl, {signer: holderSigner, audience, credentials, slotId})
134
+ const kk = createCommitteeSlotClient({chain, holder, credentials, holderProof, dcqlRule})
135
+
136
+ const sig = await kk.sign(slotId, message) // keeper + verifiers resolved from chain
137
+ const env = await kk.encrypt(slotId, plaintext) // local; group key read from KeyRegistry
138
+ const text = await kk.decrypt(slotId, {ciphertext, identity, decryptingSet, blsPeers})
139
+ ```
140
+
141
+ `examples/committee-slot.ts` in the installed package is a runnable version.
142
+
143
+ **One holder proof does not serve a committee.** A proof is bound to a nonce that lives in
144
+ ONE verifier's store and is consumed atomically, so a single proof fanned to k verifiers is
145
+ spent by whichever answers first — the rest refuse under `require_holder_binding`. The
146
+ lower-level flow therefore accepts a proof **per verifier**: pass
147
+ `holderProofPerVerifier({signer, audience, credentials, slotId})` (from
148
+ `@t3foundry/tasra-sdk/committee`) as `holderProof` to `requestCommitteeToken` / `ibeDecryptRequest`
149
+ and each drawn verifier is asked for its own nonce.
150
+
151
+ ---
152
+
153
+ [Back to the README](../README.md) · [Documentation index](README.md)
@@ -0,0 +1,36 @@
1
+ # SDK and deployment compatibility
2
+
3
+ Install the SDK with `npm install @t3foundry/tasra-sdk@latest`. Select a network from
4
+ [tasra-releases](https://github.com/t3foundry/tasra-releases), download its deployment
5
+ manifest and verify the release checksum before configuring the client.
6
+
7
+ A manifest identifies contracts and services. An active record, matching chain ID,
8
+ or successful registry read does not establish support for a protected operation.
9
+ Confirm the required routes and authorization formats for the selected deployment.
10
+
11
+ | Operation | Required deployment support |
12
+ |---|---|
13
+ | Public registry and slot reads | Reachable RPC and the contracts named by the manifest. |
14
+ | Create a slot | Compatible registry, funded creator, requested keeper mode and threshold, distributed key generation, creator-signed rule provisioning and verifier-policy configuration. |
15
+ | Credential authorization | OID4VP verifier agent, accepted issuer and holder formats, verifier membership proofs and operation-bound grants. |
16
+ | OAuth authorization | OAuth verifier sessions, a supported issuer and audience, DPoP-bound tokens and an OAuth slot policy. |
17
+ | Ethereum transactions | tECDSA signing route, ready slot, operation authorization and native gas at the slot account. |
18
+ | Document signing | FROST signing route and the required authorization and receipt support. |
19
+ | Identity-based decryption | BLS identity extraction, scope enforcement and required receipt support. |
20
+ | Native approvals | FROST approval lifecycle and the selected static-key or credential-gated approval policy. |
21
+
22
+ The runnable examples request 2-of-3 keeper and 2-of-3 verifier thresholds. The
23
+ deployment must have enough eligible members and support the chosen slot mode.
24
+ They create SD-JWT credentials bound to fresh `did:jwk` identities; the verifier
25
+ must accept those issuer and holder formats and the policy's pinned issuer.
26
+
27
+ Creator gas, a slot account's spendable balance, and any usage or lease charges are
28
+ separate. Fund each required balance through the selected network's published
29
+ funding mechanism. A funded account does not authorize signing or decryption.
30
+
31
+ Before using a workflow, execute its intended operation and an expected refusal
32
+ with your application's policy. Record the deployment identity, installed package
33
+ version and observed results. An unavailable route is an unsupported or unavailable
34
+ operation; do not substitute another authorization route or disable checks.
35
+
36
+ [Documentation index](README.md)
@@ -0,0 +1,80 @@
1
+ # Migrate to the application API
2
+
3
+ Use `@t3foundry/tasra-sdk/app` to adopt the application API one operation at a time.
4
+ Existing lower-level SDK imports remain available.
5
+ Creation and provisioning integrations must adopt the required `rule` property
6
+ and migrate any older recovery journals as described below.
7
+ Download the selected network manifest from
8
+ [tasra-releases](https://github.com/t3foundry/tasra-releases) and verify its checksum.
9
+ Confirm that the deployment supports the required key modes, authorization formats
10
+ and service routes before executing protected operations.
11
+
12
+ ## Choose the boundary to migrate
13
+
14
+ | Existing application code | Application API | Preserve or check |
15
+ |---|---|---|
16
+ | Separate registry reads and custom slot-mode checks | `TasraClient` from the public manifest and typed slot handles | Pin the intended chain and registries; handle missing, cancelled, unready and wrong-mode slots. |
17
+ | Custom Ethereum address derivation or wallet glue | `wallets.fromSlot` and durable `wallet.transfer` (`toViemAccount` remains an advanced adapter) | Authorize the exact operation for the acting holder; verify gas funding separately from metering. |
18
+ | Manual IBE partial collection and combination | BLS `decrypt` | Use the intended identity and authorization; require receipts when your application depends on them. Keep the anchored-group assurance limits explicit. |
19
+ | Custom create/status/approve transport | `setApprovalPolicy`, `identityApprover`, `approveWithCredential` and native FROST approval lifecycle | Preserve request ID, message, coordinator and policy; distinguish uncertain submission from a confirmed failure. |
20
+ | Ad hoc slot-creation retry state | `slots.create` with a stable name and `createFileStore` | Restore the same wallet, manifest and named request to resume; reconcile unknown outcomes. Expired commitments and abandoned locks still require operator intervention. |
21
+ | Legacy `keykeeper-sdk` package imports | Corresponding `@t3foundry/tasra-sdk` entry points | Check exported types and the [SDK reference](reference/README.md); package-name replacement alone does not validate behavior. |
22
+
23
+ The [application API guide](application-api.md) shows the typed operations and error
24
+ handling. Complete [shared-account](shared-account.md), [encrypted-notes](encrypted-notes.md),
25
+ [native approval](native-approvals.md) and [document-signing](document-signing.md)
26
+ examples demonstrate the surrounding application responsibilities.
27
+
28
+ ## Use generic rule names
29
+
30
+ Pass the clear policy as `rule` in `CreateSlotArgs`, `prepareSlot` and
31
+ `provisionRule`. This is a breaking input change: `dcqlRule` is rejected,
32
+ including when supplied alongside an identical `rule`. Rename the property in
33
+ creation and provisioning calls, then typecheck your application. Do not replace
34
+ the clear rule with its hash. `RuleInput`, `CreateSlotArgs` and `ProvisionRuleArgs`
35
+ are interfaces requiring `rule`; custom interfaces can extend them directly.
36
+
37
+ Creation journals require `intent.rule`; the SDK rejects journals containing
38
+ `intent.dcqlRule` and does not migrate them automatically. Before resuming an older
39
+ journal, back it up privately and rename only `intent.dcqlRule` to `intent.rule`.
40
+ Preserve the exact rule string, both salts, slot ID, creator, authorization type,
41
+ deployment, transaction hashes and all other recovery state. If both fields are
42
+ already present or the original value is uncertain, reconcile the saved state
43
+ before editing it. Do not delete the journal or create a replacement slot to bypass
44
+ this check. Application stores may nest this journal under `creation`; retain the
45
+ surrounding named request and provisioning state as well.
46
+
47
+ The slot stores `ruleCommitment`, the salted commitment, rather than `dcqlHash`.
48
+ Creation and provisioning still need the rule preimage and `ruleSalt`; retain both
49
+ in private recovery state. Credential and OAuth DCQL rules are canonicalized before
50
+ commitment hashing. OAuth/BYOIDP therefore does not imply a raw-byte commitment.
51
+
52
+ The SDK continues to send `dcql_rule` and `dcql_salt` on the keeper HTTP wire to
53
+ support deployed services. The SDK property rename requires no keeper upgrade and
54
+ changes neither the contract ABI nor the commitment algorithm. Advanced HTTP
55
+ integrations should preserve the deployed wire schema until their fleet supports a
56
+ versioned migration.
57
+
58
+ For the application API, `slots.create({policy, ...})` keeps the readable `policy`
59
+ property. Its default authorization type is `oid4vp`; select `authType: 'oauth'`
60
+ for an OAuth-only policy. Both types validate the policy family before creation.
61
+ Existing named credential requests with an omitted authorization type retain their
62
+ OID4VP meaning. Resume with the original policy and authorization type.
63
+
64
+ ## Validate your application
65
+
66
+ 1. Install the [latest SDK from npm](installation.md) and keep
67
+ its exact version and integrity in your application's lockfile.
68
+ 2. Typecheck and build your application in its actual Node or browser environment.
69
+ The application API needs only `@t3foundry/tasra-sdk` at runtime; provide browser WebCrypto.
70
+ Install `viem` directly only if your own code intentionally imports its adapters.
71
+ 3. Exercise the migrated operation on a compatible development deployment with
72
+ newly issued development credentials. Include a refused holder, wrong operation
73
+ binding and a malformed result where the operation supports them.
74
+ 4. Check restart and retry behavior. An ambiguous network error is not proof that a
75
+ write failed; retain transaction hashes, creation journals and approval request IDs.
76
+ 5. Compare application-visible results with your existing flow before changing
77
+ production traffic. Build success alone does not establish network compatibility.
78
+
79
+ Never copy demo issuer keys, holder credentials or recovery journals into production.
80
+ See [security guidance](../SECURITY.md) and [errors and retries](errors.md).
@@ -0,0 +1,104 @@
1
+ # Create your first slot
2
+
3
+ **Goal:** create one slot for signing documents. Continue in the project from
4
+ [Connect to TASRA](getting-started.md).
5
+
6
+ A creator wallet pays for setup. An issuer identity defines whose membership
7
+ credentials this slot will accept. This lesson saves both so the same command
8
+ can resume the same slot.
9
+
10
+ ## 1. Add the lesson files
11
+
12
+ ```sh
13
+ cp node_modules/@t3foundry/tasra-sdk/examples/learning-context.ts .
14
+ cp node_modules/@t3foundry/tasra-sdk/examples/learning-create-slot.ts .
15
+ ```
16
+
17
+ This file-store example runs on macOS, Linux or WSL.
18
+
19
+ Add `.tasra/` to your project's `.gitignore`. This directory holds private keys
20
+ and recovery state; keep it private.
21
+
22
+ ## 2. Read the creation step
23
+
24
+ Open `learning-create-slot.ts`. Its main operation is:
25
+
26
+ ```ts
27
+ const slot = await tasra.slots.create({
28
+ name: 'first-document-signer', mode: 'frost', policy,
29
+ threshold: {k: 2, n: 3}, verifiers: {committee: 3, quorum: 2},
30
+ }, {wallet: creator, onProgress: ({step, phase}) => console.log('Slot creation:', step, phase)})
31
+ ```
32
+
33
+ `frost` selects document signing. The example uses two of three key holders and
34
+ two of three authorization verifiers. The selected network must support these
35
+ settings, FROST and credential authorization. Connection alone does not establish this.
36
+
37
+ ## 3. Fund your account and create
38
+
39
+ ```sh
40
+ npx tsc --noEmit
41
+ npx tsx learning-create-slot.ts
42
+ ```
43
+
44
+ The first run prints your new creator address. Fund it on the selected network
45
+ with AVAX using the [official Fuji C-Chain faucet](https://core.app/tools/testnet-faucet/?subnet=c&token=c)
46
+ or your own wallet, then run the command again.
47
+ The creator account needs enough AVAX for setup gas; a nonzero balance may still be insufficient.
48
+
49
+ **Success:** `Slot ready: 0x…`. This means its key and policy are ready. The SDK saves
50
+ the slot ID; you will not copy it between lessons.
51
+
52
+ ## 4. Add usage credit
53
+
54
+ [Fund the slot](funding.md): obtain EURC, buy TSRA from BondingCurve, then deposit
55
+ TSRA into this slot's Settlement balance before signing. AVAX in the creator
56
+ wallet pays gas; it does not provide the slot's usage credit.
57
+
58
+ <details>
59
+ <summary>What the complete script does</summary>
60
+
61
+ <!-- learning-create-slot-example -->
62
+ ```ts
63
+ import {store, tasra} from './learning-context.js'
64
+
65
+ // Save fresh keys before the first network write; later runs reuse them.
66
+ await store.withLock('lesson', async () => {
67
+ const creator = tasra.wallets.create({privateKey: await store.load<`0x${string}`>('creator-key')})
68
+ await store.save('creator-key', creator.exportPrivateKey())
69
+ console.log('Creator address:', creator.address)
70
+ if (await tasra.chain.client.getBalance({address: creator.address}) === 0n) {
71
+ console.log('Fund this creator address with AVAX on the selected network, then run again.')
72
+ return
73
+ }
74
+
75
+ const issuer = tasra.identities.create({seed: await store.load<Uint8Array>('issuer-key')})
76
+ await store.save('issuer-key', issuer.exportPrivateKey())
77
+ const policy = tasra.credentials.policy({issuer, type: 'urn:my-app:member'})
78
+
79
+ // One named signing slot, ready for later document-signing lessons.
80
+ const slot = await tasra.slots.create({
81
+ name: 'first-document-signer', mode: 'frost', policy,
82
+ threshold: {k: 2, n: 3}, verifiers: {committee: 3, quorum: 2},
83
+ }, {wallet: creator, onProgress: ({step, phase}) => console.log('Slot creation:', step, phase)})
84
+ await store.save('slot-id', slot.slotId)
85
+ console.log('Slot ready:', slot.slotId)
86
+ console.log('Before signing: buy TSRA with EURC and fund this slot. Follow node_modules/@t3foundry/tasra-sdk/docs/funding.md.')
87
+ })
88
+ ```
89
+
90
+ The [shared context](../examples/learning-context.ts) loads the manifest you downloaded,
91
+ opens the private store and prevents accidental reuse on another manifest snapshot.
92
+ Creation saves progress, creates the key, delivers the access rule and configures
93
+ its verifier policy. The optional `onProgress` callback reports these stages,
94
+ including public transaction hashes when available. Progress is observational:
95
+ callback errors do not stop creation, and a resumed run reports the stages it
96
+ actually visits again. Keep the durable store even when displaying progress.
97
+
98
+ Keep the same name, keys, request, manifest and store to resume. Changing the request
99
+ is not an update. After an uncertain submission or stale lock, preserve the state
100
+ and follow [recovery guidance](application-api.md#recovery-boundaries).
101
+
102
+ </details>
103
+
104
+ **Next: [Fund your slot →](funding.md)**
@@ -0,0 +1,243 @@
1
+ # Build a small document-signing app
2
+
3
+ Build **Tasra Sign**: upload a PDF, invite Alice and Bob, collect their approvals,
4
+ and download a verifiable signature bundle. This is a working TypeScript web app
5
+ with separate signer wallets and persistent request state.
6
+
7
+ Alice and Bob each authorize their own FROST slot. Completion requires **two
8
+ independent signatures over the same request**. Each slot uses a 2-of-3 keeper
9
+ committee; that threshold is separate from the two-person application workflow.
10
+
11
+ ## 1. Start from an empty application directory
12
+
13
+ Install Node.js **24**. The commands below install the latest SDK from npm.
14
+
15
+ The application downloads the testnet manifest from
16
+ [tasra-releases](https://github.com/t3foundry/tasra-releases) and verifies its
17
+ checksum. The selected deployment must support FROST slot creation, creator-signed
18
+ provisioning, OID4VP, SD-JWT credentials bound to `did:jwk` holders and required
19
+ keeper receipts. It needs sufficient members for 2-of-3 keeper and verifier
20
+ policies and any applicable usage credits. A successful registry read does not
21
+ prove that these protected operations are supported.
22
+
23
+ Create an app:
24
+
25
+ ```sh
26
+ mkdir my-document-signing
27
+ cd my-document-signing
28
+ npm init -y
29
+ npm install @t3foundry/tasra-sdk@latest
30
+ ```
31
+
32
+ Using your IDE file explorer, copy the **contents** of
33
+ `node_modules/@t3foundry/tasra-sdk/examples/document-signing/` into your app directory,
34
+ Accept replacement of the initial `package.json`. Rename `gitignore.template`
35
+ to `.gitignore` in your IDE; npm omits dot-ignore files from package archives.
36
+ Then install the latest SDK and the copied application's dependencies:
37
+
38
+ ```sh
39
+ npm install @t3foundry/tasra-sdk@latest
40
+ cp node_modules/@t3foundry/tasra-sdk/examples/fund-slot.ts .
41
+ npm run build
42
+ ```
43
+
44
+ Create the application identities and creator wallet:
45
+
46
+ ```sh
47
+ npx tsx network.ts
48
+ npm run setup
49
+ ```
50
+
51
+ If the creator is unfunded, setup prints its address and stops. Fund that address
52
+ on the printed network through its faucet or a wallet you control, then run setup
53
+ again. Use AVAX from the [official Fuji C-Chain faucet](https://core.app/tools/testnet-faucet/?subnet=c&token=c).
54
+ The saved creator key is reused. Setup creates the issuer, separate
55
+ Alice/Bob/Mallory wallet files, two FROST slots and their access policies.
56
+
57
+ Before `npm start`, follow [Fund a slot](funding.md) using `.tasra/sdk` instead of
58
+ `.tasra/first-slot`. Setup prints complete status commands for both slot IDs.
59
+ Keep each `--slot` argument when buying TSRA with EURC and depositing TSRA. Buy
60
+ enough TSRA, then fund **both** slots; the web app's slots do not share usage credit.
61
+ For a custom `TASRA_SIGN_DATA` directory, use the directory printed by setup.
62
+
63
+ ```sh
64
+ npm start
65
+ ```
66
+
67
+ Use macOS, Linux or WSL for this file-store example. TLS verification
68
+ remains enabled, and the application does not use a shared funding key.
69
+
70
+ The server prints a **private sender-console link**. Open that link to create
71
+ requests. Keep its token private. The server binds to `127.0.0.1:4177`; this tutorial
72
+ uses browser profiles on the same machine, not remote email invitations.
73
+
74
+ ## 2. Send your first agreement
75
+
76
+ 1. Open the sender console. Choose a PDF or **Use sample PDF**. Give it a title and version.
77
+ 2. Select **Create signing request**. The app freezes the PDF digest, request ID,
78
+ version, chain identity and Alice/Bob slot assignments.
79
+ 3. Select **Save request** now. Keep `request.json` independently of the final bundle.
80
+ 4. Open Alice's invitation in a separate browser profile. Import only
81
+ `.tasra/wallets/alice.json`, review the PDF, tick the approval checkbox and sign.
82
+ 5. Open Bob's invitation in another browser profile. Bob must wait for Alice.
83
+ Import `.tasra/wallets/bob.json`, review and sign.
84
+ 6. Download the original PDF and `signatures.json`. Reload either signer page:
85
+ the saved approval remains visible.
86
+
87
+ Wallet seeds stay in their browser tab. The backend stores its creator key and
88
+ public holder keys, but does not load the private wallet files. It proxies the
89
+ signed request object and encrypted presentation only to the configured verifier.
90
+ Wallet files and creator state live in ignored `.tasra/`; never publish that folder.
91
+ Demo credentials expire after a day. Stop the server and rerun setup to refresh
92
+ credentials; it preserves existing identities and completed slot provisioning.
93
+
94
+ ## 3. Understand the TypeScript you just ran
95
+
96
+ Read the app in this order. Each file has one concrete job:
97
+
98
+ | File | What you learn |
99
+ |---|---|
100
+ | [config.ts](../examples/document-signing/config.ts) | Load the public manifest with `TasraClient`. |
101
+ | [setup.ts](../examples/document-signing/setup.ts) | Create fresh SDK identities and wallets; call `tasra.slots.create()` with each signer’s policy. |
102
+ | [model.ts](../examples/document-signing/model.ts) | Define the exact signed statement and verify detached proofs. |
103
+ | [backend.ts](../examples/document-signing/backend.ts) | Open a creator-bound verifier session; sign with a typed FROST handle. |
104
+ | [web/wallet.ts](../examples/document-signing/web/wallet.ts) | Bind the wallet approval to the reviewed document and submit the holder-bound presentation. |
105
+ | [workflow.ts](../examples/document-signing/workflow.ts) | Enforce Alice → Bob, idempotent completion and recovery. |
106
+ | [server.ts](../examples/document-signing/server.ts) | Expose the request API, wallet transport and downloads. |
107
+ | [web/app.ts](../examples/document-signing/web/app.ts) | Implement upload, invitations, review and verification screens. |
108
+
109
+ The SDK operation at the center is small:
110
+
111
+ ```ts
112
+ const handle = await tasra.slots.frost(slotId)
113
+ const signed = await handle.sign(statement(manifest), {
114
+ requireReceipt: true,
115
+ authorize: async () => ({
116
+ token: grant.token,
117
+ verifierProofs: grant.verifierProofs!,
118
+ }),
119
+ })
120
+ ```
121
+
122
+ `grant` comes from the matching wallet's accepted verifier session. The SDK checks
123
+ that authorization and the returned signature match the operation. The app also
124
+ checks the signer assignment and anchored public key before saving completion.
125
+
126
+ The browser hashes the **same PDF bytes it renders**, checks the signed verifier
127
+ request and bound operation, then presents its credential. PDF rendering uses the
128
+ bundled [PDF.js renderer](https://mozilla.github.io/pdf.js/examples/); it does not
129
+ upload documents to an external preview service. Use the page controls for multi-page
130
+ PDFs. The sample does not edit form fields or embed signature appearances in PDFs.
131
+
132
+ ## 4. Verify without trusting the download
133
+
134
+ Open **Verify**, select the original PDF, your previously saved `request.json`,
135
+ and `signatures.json`. Or run in a macOS/Linux shell (bash or zsh):
136
+
137
+ ```sh
138
+ npm run verify -- document.pdf request.json signatures.json
139
+ ```
140
+
141
+ Verification checks the exact request, the PDF digest, two distinct assigned
142
+ signers, current on-chain keys and epochs, and both FROST signatures. It rejects
143
+ altered PDFs, versions, request IDs, swapped slots and duplicate Alice signatures.
144
+ The bundle's `receiptStatus` is a record of the live SDK check, not an independently
145
+ verifiable archived receipt; offline bundle verification does not establish it.
146
+
147
+ Do not obtain your expected request from an untrusted bundle: an attacker could
148
+ replace the entire document and both signatures with a different valid agreement.
149
+ The saved manifest supplies the expected identity of your request.
150
+
151
+ ## 5. Observe retries, refusal and recovery
152
+
153
+ - Double-clicking or repeating completion returns the saved proof. It does not sign again.
154
+ - Restart the server after Alice signs. Her approval survives; Bob can continue.
155
+ - Import Mallory's wallet on Alice's invitation. The wallet rejects the mismatched
156
+ credential. This local refusal does not establish server-side enforcement; your
157
+ integration tests should also submit an unauthorized presentation to the verifier
158
+ and assert its refusal.
159
+ - Cancel from the sender console, or decline using the assigned signer's wallet.
160
+ A bare invitation is insufficient to authorize a decline or signature.
161
+ - If a process stops during session opening or keeper submission, the request is
162
+ marked **uncertain**. The app refuses automatic re-signing. Preserve `.tasra/`
163
+ and reconcile the saved request/session with the verifier and keeper records.
164
+ The tutorial intentionally has no “reset and try again” button for this case.
165
+
166
+ The JSON store uses atomic replacement, fsync, a per-request queue and one process
167
+ lock. It is a small single-writer example; production deployments need an appropriate
168
+ database, authenticated enrollment and access control for documents, delivery,
169
+ retention, and a policy for historical key rotation. Anyone with a demo invitation
170
+ can read its document. Activity timestamps are local application timestamps, not
171
+ trusted timestamps or legal certification.
172
+
173
+ ## Check your application
174
+
175
+ ```sh
176
+ npm test
177
+ npm run build
178
+ ```
179
+
180
+ These commands check the application locally. Then exercise the running app: complete
181
+ a request with Alice and Bob, reload it, verify the downloaded bundle and confirm
182
+ that a modified PDF fails verification. Unit tests and a build do not establish
183
+ that your deployment can authorize or sign.
184
+
185
+ ## Run the same cryptographic workflow in a terminal
186
+
187
+ Before protected operations, the terminal example pauses for **TSRA usage credit**.
188
+ In a second terminal in the same project, run its printed `fund-slot.ts ... status`
189
+ command. Follow [Fund a slot](funding.md) to obtain EURC, buy TSRA from BondingCurve,
190
+ and deposit TSRA into the printed slot. Replace `.tasra/first-slot` in those commands
191
+ with this app's printed directory. Fund every new slot; creator AVAX pays gas and
192
+ does not provide usage credits. Keep the app running while funding. After its
193
+ 15-minute wait expires, a new run creates fresh accounts and slots; funding
194
+ the old slot does not resume the exited run.
195
+
196
+
197
+ If you want to learn the SDK before running the web app, use
198
+ [document-signing.ts](../examples/document-signing.ts). It creates two fresh signer
199
+ slots through `tasra.slots.create()`, signs one exact PDF/request with both people,
200
+ and independently checks both signatures against their on-chain keys.
201
+
202
+ Create a separate application using a macOS/Linux shell or WSL.
203
+
204
+ ```sh
205
+ mkdir my-document-signatures
206
+ cd my-document-signatures
207
+ npm init -y
208
+ npm pkg set type=module
209
+ npm install @t3foundry/tasra-sdk@latest
210
+ npm install --save-dev tsx typescript @types/node
211
+ cp node_modules/@t3foundry/tasra-sdk/examples/document-signing.ts app.ts
212
+ cp node_modules/@t3foundry/tasra-sdk/examples/tutorial-support.ts .
213
+ cp node_modules/@t3foundry/tasra-sdk/examples/tutorial-negative.ts .
214
+ cp node_modules/@t3foundry/tasra-sdk/examples/network.ts .
215
+ cp node_modules/@t3foundry/tasra-sdk/examples/fund-slot.ts .
216
+ printf '.tasra/\nnode_modules/\n' > .gitignore
217
+ npx tsc --noEmit --target ES2022 --module NodeNext --moduleResolution NodeNext --strict --skipLibCheck --resolveJsonModule app.ts
218
+ npx tsx network.ts
219
+ npx tsx app.ts
220
+ ```
221
+
222
+ The only application dependency is `@t3foundry/tasra-sdk`. The shared tutorial helper loads
223
+ the downloaded release manifest with `TasraClient` and creates fresh identities,
224
+ credentials and a creator wallet. It prints the creator address and waits up to
225
+ 15 minutes for funding through the network faucet or your own wallet. The application itself creates both slots,
226
+ freezes the PDF/request, signs and checks the evidence. No learner slots or accounts
227
+ are precreated; each full run creates a new private `.tasra/document-signing-*` folder.
228
+
229
+ Expect a final `PASS: Alice AND Bob signed; document tampering, replay and duplicate
230
+ signer rejected.` Inspect `document.pdf`, `request.json`, `signature-bundle.json`
231
+ and `evidence.json` in the printed directory. The checks also prove Bob's credential
232
+ is refused by the real verifier when submitted for Alice's slot. Private keys and
233
+ credentials share that directory; never publish the entire folder.
234
+
235
+
236
+ For **one signature requiring a native approval quorum**, follow
237
+ [native approvals](native-approvals.md); it has different semantics.
238
+
239
+ `npx tsx network.ts` saves the verified manifest and its checksum pin. Keep both
240
+ files with the application so restarts use the same deployment. The examples use
241
+ `lowest-operator-id` as the explicit coordinator convention; confirm it matches
242
+ the selected service. Fund each newly printed creator address with at least 0.05
243
+ AVAX on Fuji before continuing; more may be needed if gas costs rise.