@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
@@ -0,0 +1,124 @@
1
+ # Native approval quorum for one FROST signature
2
+
3
+ Create one FROST signature after Alice and Bob approve. The approval quorum counts
4
+ people (or configured identity keys); the keeper threshold counts cryptographic
5
+ shares. They are separate numbers.
6
+
7
+ Use the manifest-based `TasraClient` and `tasra.slots.create()` to create a ready
8
+ FROST slot. Then configure the native approval policy through the SDK:
9
+
10
+ ```ts
11
+ import {setApprovalPolicy, identityApprover} from '@t3foundry/tasra-sdk/app'
12
+
13
+ const signers = [identityApprover(alice), identityApprover(bob)]
14
+ await setApprovalPolicy(tasra, slot.slotId, {
15
+ quorum: 2, approvers: signers.map(signer => signer.publicKey),
16
+ }, {wallet: creator, store})
17
+ const approvals = await slot.approvals({quorum: 2, credentialGated: false})
18
+ const request = await approvals.create(exactMessageBytes)
19
+ // Save request ID, coordinator, slot, message and expected policy before approval.
20
+ await request.approve({signer: signers[0]!})
21
+ await request.approve({signer: signers[1]!})
22
+ const signature = await request.wait({timeoutMs: 120_000})
23
+ ```
24
+
25
+ `alice` and `bob` are Ed25519 identities created by `tasra.identities.create()`.
26
+ `identityApprover` adapts their keys without requiring an application signing
27
+ library. The SDK checks slot, message and quorum before requesting each signature,
28
+ and verifies the resulting FROST signature against the expected group key.
29
+
30
+ For credential-gated approval, pass `{quorum: 2, credentialPolicy: rule}` to
31
+ `setApprovalPolicy` and use `slot.approvals({quorum: 2, credentialGated: true})`.
32
+ Approve each holder with:
33
+
34
+ ```ts
35
+ import {approveWithCredential} from '@t3foundry/tasra-sdk/app'
36
+
37
+ await approveWithCredential(tasra, request, exactMessageBytes, {
38
+ identity: alice,
39
+ authorize: tasra.credentials.authorize({
40
+ verifierAgentUrl: tasra.verifierAgentUrl!, signer: creator.signer,
41
+ identity: alice, credentials: [aliceCredential],
42
+ }),
43
+ })
44
+ ```
45
+
46
+ The SDK constructs the canonical approval digest, obtains the holder-bound
47
+ operation grant and signs the exact request. The network counts distinct holders;
48
+ Alice presenting again cannot stand in for Bob. The lower-level `createDualSignClient`
49
+ and explicit approval transport remain available for specialized integrations.
50
+
51
+ After a restart, use `approvals.resume(saved.requestId, saved.message)` with the
52
+ original coordinator and pinned policy. After an ambiguous POST, catch
53
+ `OperationOutcomeUnknownError` and reconcile status. Do not automatically create
54
+ a replacement request. If creation lost its request ID, the current protocol
55
+ cannot discover it through this SDK; preserve that uncertainty for an operator.
56
+
57
+ This is separate from two detached signatures in a document workflow. It does
58
+ not enable multi-approver IBE extraction.
59
+
60
+ Two complete examples exercise these behaviors:
61
+
62
+ - [Static approver keys](../examples/native-approvals.ts): distinct approvals, duplicate-vote prevention and cross-request replay refusal.
63
+ - [Credential-gated approvals](../examples/credential-approvals.ts): Alice and Bob present separate holder-bound credentials for the exact request; Alice's repeated approval does not add another vote. The SDK verifies the final threshold signature.
64
+
65
+ ## Create a fresh project and run
66
+
67
+ Before protected operations, the terminal example pauses for **TSRA usage credit**.
68
+ In a second terminal in the same project, run its printed `fund-slot.ts ... status`
69
+ command. Follow [Fund a slot](funding.md) to obtain EURC, buy TSRA from BondingCurve,
70
+ and deposit TSRA into the printed slot. Replace `.tasra/first-slot` in those commands
71
+ with this app's printed directory. Fund every new slot; creator AVAX pays gas and
72
+ does not provide usage credits. Keep the app running while funding. After its
73
+ 15-minute wait expires, a new run creates fresh accounts and slots; funding
74
+ the old slot does not resume the exited run.
75
+
76
+
77
+ Use Node.js **24**. The examples download and checksum-verify the testnet manifest
78
+ from [tasra-releases](https://github.com/t3foundry/tasra-releases). The deployment
79
+ must support FROST creation and the selected native approval policy. Credential
80
+ approvals additionally require operation-bound OID4VP, SD-JWT and `did:jwk`
81
+ support. Ensure sufficient keeper/verifier membership and usage credits.
82
+ In a new terminal, create the project and install the latest SDK from npm:
83
+
84
+ ```sh
85
+ mkdir my-approval-workflow
86
+ cd my-approval-workflow
87
+ npm init -y
88
+ npm pkg set type=module
89
+ npm install @t3foundry/tasra-sdk@latest
90
+ npm install --save-dev tsx typescript @types/node
91
+ cp node_modules/@t3foundry/tasra-sdk/examples/native-approvals.ts .
92
+ cp node_modules/@t3foundry/tasra-sdk/examples/credential-approvals.ts .
93
+ cp node_modules/@t3foundry/tasra-sdk/examples/tutorial-support.ts .
94
+ cp node_modules/@t3foundry/tasra-sdk/examples/tutorial-negative.ts .
95
+ cp node_modules/@t3foundry/tasra-sdk/examples/network.ts .
96
+ cp node_modules/@t3foundry/tasra-sdk/examples/fund-slot.ts .
97
+ printf '.tasra/\nnode_modules/\n' > .gitignore
98
+ npx tsc --noEmit --target ES2022 --module NodeNext --moduleResolution NodeNext --strict --skipLibCheck --resolveJsonModule native-approvals.ts credential-approvals.ts
99
+ npx tsx network.ts
100
+ npx tsx native-approvals.ts
101
+ npx tsx credential-approvals.ts
102
+ ```
103
+
104
+ `@t3foundry/tasra-sdk` is the only application runtime dependency. The visible tutorial helper
105
+ loads the release manifest and creates fresh identities, credentials and a creator
106
+ wallet. Each run prints its creator address and waits up to 15 minutes for funding
107
+ through the network faucet or your own wallet. Each example creates its own slot and approval policy. No precreated
108
+ learner accounts, slots or credentials are required.
109
+
110
+ The static example must finish with `PASS: two distinct approvals, duplicate vote
111
+ prevented, replay refused.` The credential example must finish with `PASS: Alice and
112
+ Bob approved; duplicate holder added no vote.` Each prints the location of its
113
+ `evidence.json` containing the checked outcomes and public transaction references.
114
+
115
+ Private keys, credentials and recovery journals stay in `.tasra/`; do not publish
116
+ that whole directory. Each complete example run creates a new directory and slot.
117
+ For an interrupted prior run, preserve and reconcile its original state. A completed
118
+ setup alone does not establish that the approval flow succeeded.
119
+
120
+ `npx tsx network.ts` saves the verified manifest and its checksum pin. Keep both
121
+ files with the application so restarts use the same deployment. The examples use
122
+ `lowest-operator-id` as the explicit coordinator convention; confirm it matches
123
+ the selected service. Fund each newly printed creator address with at least one
124
+ native token on the selected chain before continuing.
@@ -0,0 +1,137 @@
1
+ # Prerequisites
2
+
3
+ For a first application, use the [quickstart](getting-started.md). New applications
4
+ connect from a public manifest and let the SDK create wallets, identities, credentials
5
+ and ready slots. No precreated learner account or slot is required.
6
+
7
+ ## Network configuration
8
+
9
+ Use Node.js 24 and install `@t3foundry/tasra-sdk@latest`. Download the network pointer and
10
+ manifest from [tasra-releases](https://github.com/t3foundry/tasra-releases).
11
+ For Avalanche Fuji, use `networks/testnet/current.json`; resolve its `manifest`
12
+ path relative to `networks/testnet/`, and fetch both files from the same reviewed
13
+ commit. Verify the original manifest bytes against the pointer's trusted SHA-256.
14
+
15
+ Load the release with `TasraClient.fromManifest(manifestUrl, {sha256, coordinator})`.
16
+ The explicit coordinator convention must match the deployment. The SDK resolves
17
+ the RPC and configured verifier endpoint; it discovers assigned keepers from chain.
18
+ Do not invent missing service URLs. Keep TLS verification enabled.
19
+
20
+ ## Accounts and protected operations
21
+
22
+ Create a wallet with `tasra.wallets.create()`, or connect an Ethereum provider with
23
+ `tasra.wallets.connect(provider)`. Save exported private keys in protected storage
24
+ before requesting funds. Fund the public creator address through the network's
25
+ faucet or a wallet you control. Creating a key does not fund it.
26
+
27
+ Supply the creator wallet and a durable store to `tasra.slots.create()`. The SDK
28
+ records the intent, creates the slot, waits for key generation, provisions its rule
29
+ and configures its verifier policy. Node applications can use `createFileStore`;
30
+ browser and database stores need atomic persistence and exclusive operation locks.
31
+
32
+ The selected deployment must support the requested mode, thresholds, authorization
33
+ format and service routes. Credential operations need an accepted issuer and
34
+ holder format. Slot-account gas and usage or lease charges are distinct from
35
+ creator gas. A healthy registry alone does not prove those requirements are met.
36
+
37
+ ## Offline first result
38
+
39
+ ```sh
40
+ npm install @t3foundry/tasra-sdk@latest
41
+ npm install --save-dev tsx
42
+ npx tsx node_modules/@t3foundry/tasra-sdk/examples/minimal.ts
43
+ ```
44
+
45
+ Expected output: `Hello Tasra`. Public demo keys demonstrate local crypto only.
46
+ The example requires no network deployment or `viem`. Examples ship in the package.
47
+
48
+ <a id="application-configuration"></a>
49
+
50
+ ## Advanced existing committee integrations
51
+
52
+ The SDK includes the chain runtime dependencies; install `viem` directly only if
53
+ your application imports it. The following advanced committee examples use a
54
+ provisioned **non-exportable BLS slot**,
55
+ an anchored verifier-set snapshot, sufficient metering funds, and a credential issued
56
+ to your holder DID. The application never needs keeper admin or issuer secrets.
57
+
58
+ | Environment variable | Value supplied by you or the deployment handoff |
59
+ |---|---|
60
+ | `KK_MANIFEST_FILE` | Local path to the exact downloaded deployment-manifest bytes |
61
+ | `KK_MANIFEST_SHA256` | SHA-256 from the trusted release checksum, not a digest invented from an untrusted download |
62
+ | `KK_RPC_URL` | RPC for the manifest's chain |
63
+ | `KK_SLOT_ID` | Provisioned BLS slot, 0x-prefixed bytes32 |
64
+ | `KK_HOLDER_KEY_FILE` | Private file containing a 32-byte Ed25519 holder seed as hex; examples derive its did:key |
65
+ | `KK_CREDENTIALS_FILE` | Private JSON file containing an array of issuer-signed compact-JWS credentials for that DID |
66
+ | `KK_VERIFIER_AUDIENCE` | Expected holder-proof audience published by the deployment |
67
+ | `KK_SIGN_SLOT_ID` | Separate FROST slot, required only for signing and live acceptance |
68
+
69
+ Keep key/credential files outside source control and readable only by their owner.
70
+ These Node examples use a file-backed holder; applications can instead supply the
71
+ SDK's `HolderSigner` callback backed by a wallet or key store.
72
+
73
+ ```sh
74
+ npx tsx node_modules/@t3foundry/tasra-sdk/examples/getting-started.ts
75
+ npx tsx node_modules/@t3foundry/tasra-sdk/examples/committee-slot.ts
76
+ ```
77
+
78
+ These direct committee examples require a slot with a verifier policy and a deployment
79
+ that accepts compound tokens without request binding. If keepers enforce
80
+ `api.require_request_binding`, use the verifier-agent authorization flow described in
81
+ `tasra-oid4vp-wallet-and-verifier-agent`.
82
+ Do not weaken the deployment's policy to run an example.
83
+
84
+ The first command verifies a threshold encrypt/decrypt round trip. The second verifies
85
+ a threshold FROST signature. Missing inputs fail nonzero. Neither creates a network,
86
+ mints credentials, nor substitutes mock authorization.
87
+
88
+ <a id="operator-setup"></a>
89
+
90
+ ## Advanced slot creation and provisioning
91
+
92
+ `examples/provision-slot.ts` creates a dedicated slot, persists recovery inputs before
93
+ submitting transactions, waits for DKG, and provisions the committed rule on keepers.
94
+ It selects commit/reveal when the registry requires it. Rule provisioning uses
95
+ `provisionRule` with the creator's own key; no admin JWT is required on compatible
96
+ fleets. For a complete tECDSA app, use the [shared-account tutorial](shared-account.md).
97
+
98
+ In addition to manifest/RPC configuration, provide:
99
+
100
+ | Variable | Meaning |
101
+ |---|---|
102
+ | `KK_CREATOR_KEY_FILE` | Private file containing a funded EVM key as 0x-prefixed hex |
103
+ | `KK_RULE_FILE` | Exact rule to commit and provision |
104
+ | `KK_SLOT_OUTPUT` | New recovery-record path; existing files are never overwritten |
105
+ | `KK_K`, `KK_N` | Threshold and keeper count |
106
+ | `KK_SLOT_MODE` | `bls` for encryption or `frost` for signing |
107
+ | `KK_CUSTODY` | `threshold`, or explicitly `exportable` for a personal BLS vault |
108
+
109
+ ```sh
110
+ npx tsx node_modules/@t3foundry/tasra-sdk/examples/provision-slot.ts
111
+ ```
112
+
113
+ Preserve the recovery record even if provisioning fails. Follow deployment instructions
114
+ to fund metering, configure verifier policy, and enroll the holder before application use.
115
+ The example does not replace the deployment operator's lifecycle/recovery tooling.
116
+
117
+ ## Exportable personal vault
118
+
119
+ An exportable slot is a separate custody choice. The holder can retain its master key;
120
+ revocation does not prevent future local decryption with that key. Deployments requiring
121
+ commit/reveal cannot create these slots with the current API, and the example refuses
122
+ that combination rather than weakening the registry requirement.
123
+
124
+ For an existing exportable BLS slot, configure the application inputs plus `KK_DCQL_RULE`
125
+ and run `examples/personal-vault.ts`. This example uses one-shot VP authentication;
126
+ it does not claim silent renewal.
127
+
128
+ [Deployment responsibilities](DEVELOPER-EXPERIENCE.md) · [Glossary](glossary.md)
129
+
130
+ ## Gas and usage credit
131
+
132
+ Fund the creator wallet with AVAX for setup and token transaction gas. For Fuji,
133
+ use the [official C-Chain faucet](https://core.app/tools/testnet-faucet/?subnet=c&token=c).
134
+ Then buy TSRA with EURC from BondingCurve and deposit TSRA into each slot's
135
+ Settlement balance. Follow the runnable [funding guide](funding.md). An Ethereum
136
+ slot account additionally needs AVAX for its own transactions; this is separate
137
+ from creator gas and TSRA usage credit.
@@ -0,0 +1,41 @@
1
+ # Read your slot
2
+
3
+ **Goal:** inspect the slot you created. This step makes no transactions and needs
4
+ no credential presentation.
5
+
6
+ ## Check its state
7
+
8
+ Copy the reader into the same project:
9
+
10
+ ```sh
11
+ cp node_modules/@t3foundry/tasra-sdk/examples/learning-read-slot.ts .
12
+ npx tsc --noEmit
13
+ npx tsx learning-read-slot.ts
14
+ ```
15
+
16
+ Open `learning-read-slot.ts`:
17
+
18
+ <!-- learning-read-slot-example -->
19
+ ```ts
20
+ import {savedSlotId, tasra} from './learning-context.js'
21
+
22
+ const slotId = await savedSlotId()
23
+ const slot = await tasra.slots.get(slotId)
24
+ console.log('Slot:', slot.slotId)
25
+ console.log('Key ready:', slot.ready)
26
+ console.log('Key epoch:', slot.epoch)
27
+ console.log('Threshold:', slot.threshold)
28
+ ```
29
+
30
+ **Success:** `Key ready: true`, followed by the key epoch and threshold.
31
+ The epoch identifies the slot's current key generation. `k` is the required
32
+ number of key holders; `n` is the number assigned to the slot.
33
+
34
+ The slot ID is loaded from your private lesson store. In a larger app, keep your
35
+ slot IDs with your application records. The application client does not have a
36
+ `slots.list()` method.
37
+
38
+ `slots.get()` checks that the slot exists and has not been cancelled. To inspect a cancelled
39
+ slot's record, use the registry reader shown in the next lesson.
40
+
41
+ **Next: [Control access →](access-control.md)**
@@ -0,0 +1,30 @@
1
+ # SDK reference
2
+
3
+ Look up the TypeScript classes, functions, options and return types you use in your code.
4
+ Start with the [learning path](../README.md) if you are building your first TASRA app.
5
+
6
+ ## Choose a module
7
+
8
+ Most applications start with **@t3foundry/tasra-sdk/app**. Open a module, then choose Classes,
9
+ Functions, Types or Constants from its page navigation. Each group has its own lookup list.
10
+
11
+ | Module | Import | What you will find |
12
+ |---|---|---|
13
+ | [Application client](app.md) | `@t3foundry/tasra-sdk/app` | Connect, create slots, manage identities and run application workflows. |
14
+ | [Local storage (Node.js)](app-node.md) | `@t3foundry/tasra-sdk/app/node` | Persist application state and coordinate local operations. |
15
+ | [Core utilities](main.md) | `@t3foundry/tasra-sdk` | Signing, encryption, credentials and shared helpers. |
16
+ | [Chain access](chain.md) | `@t3foundry/tasra-sdk/chain` | Read contracts, submit transactions, discover services and fund slots. |
17
+ | [Committee operations](committee.md) | `@t3foundry/tasra-sdk/committee` | Threshold requests, approvals and operation receipts. |
18
+ | [Credentials and OID4VP](oid4vp.md) | `@t3foundry/tasra-sdk/oid4vp` | Credential presentations, wallet flows and issuer verification. |
19
+ | [Verifier integration](verifier-agent.md) | `@t3foundry/tasra-sdk/verifier-agent` | Connect wallet and credential flows to a verifier agent. |
20
+ | [Chain tools (Node.js)](chain-node.md) | `@t3foundry/tasra-sdk/chain/node` | Load chain configuration from Node.js files. |
21
+
22
+ ## Read a declaration
23
+
24
+ Functions show their import, parameters and return value. Classes show constructors,
25
+ properties and methods. Types describe the data you pass in or receive. Constants
26
+ and contract ABIs link to their definitions. Follow **Source** for the implementation.
27
+
28
+ The declarations and descriptions are generated from the SDK source. They describe
29
+ programming interfaces; use the [application guides](../README.md) for complete
30
+ runnable examples and [Errors](../errors.md) for recovery guidance.
@@ -0,0 +1,102 @@
1
+ # @t3foundry/tasra-sdk/app/node
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/node.ts#L28)
23
+
24
+ Import: `import {StoreLockedError} from '@t3foundry/tasra-sdk/app/node'`
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 1 functions</summary>
50
+
51
+ - [createFileStore](#createfilestore)
52
+
53
+ </details>
54
+
55
+ ### createFileStore
56
+
57
+ The directory is private, trusted application state, not an untrusted shared folder.
58
+
59
+ [Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#L67)
60
+
61
+ Import: `import {createFileStore} from '@t3foundry/tasra-sdk/app/node'`
62
+
63
+ ```ts
64
+ declare function createFileStore(directory: string): ApplicationStore;
65
+ ```
66
+
67
+ | Parameter | Type | Description |
68
+ |---|---|---|
69
+ | ` directory ` | ` string ` | Private application state directory owned by the current operating-system user. |
70
+
71
+ Returns: ` ApplicationStore `.
72
+
73
+ ## Types
74
+
75
+ Options, data structures and return types.
76
+
77
+ <details>
78
+ <summary>Browse 1 types</summary>
79
+
80
+ - [ApplicationStore](#applicationstore)
81
+
82
+ </details>
83
+
84
+ ### ApplicationStore
85
+
86
+ Durable private state storage with exclusive locking for each named operation.
87
+
88
+ [Source](https://github.com/t3foundry/tasra-sdk/blob/develop/src/app/node.ts#L11)
89
+
90
+ ```ts
91
+ export interface ApplicationStore {
92
+ load<T>(key: string): Promise<T | undefined>;
93
+ save<T>(key: string, value: T): Promise<void>;
94
+ withLock<T>(key: string, action: () => Promise<T>): Promise<T>;
95
+ }
96
+ ```
97
+
98
+ Fields:
99
+
100
+ - **` load `**: Load a saved value, or return undefined when the key does not exist.
101
+ - **` save `**: Atomically persist private state before resolving.
102
+ - **` withLock `**: Exclusively serialize work for the key across all participating processes or tabs.