@t3foundry/tasra-sdk 0.0.0-stage → 0.3.1-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,335 @@
1
+ # Build with the application API
2
+
3
+ New to TASRA? Follow the [step-by-step learning path](README.md) first. This page
4
+ is a detailed reference for returning developers.
5
+
6
+ Start new applications with `TasraClient` from `@t3foundry/tasra-sdk/app`. The SDK loads network
7
+ configuration, creates ready-to-use slots, adapts wallets, and issues and presents
8
+ credentials. Existing `createTasra` and lower-level APIs remain available. The application
9
+ chooses its policy, consent behavior and private storage; the SDK handles network
10
+ operations and cryptographic checks.
11
+
12
+ Install the latest SDK from npm as your application dependency. TypeScript and
13
+ `tsx` are development tools:
14
+
15
+ ```sh
16
+ npm install @t3foundry/tasra-sdk@latest
17
+ npm install --save-dev typescript tsx @types/node
18
+ ```
19
+
20
+ ## Connect using the deployment's manifest
21
+
22
+ Download network configuration from
23
+ [tasra-releases](https://github.com/t3foundry/tasra-releases). For testnet,
24
+ `networks/testnet/current.json` names the manifest relative to `networks/testnet/`
25
+ and supplies its SHA-256 checksum. Read both files from the same reviewed commit.
26
+
27
+ ```ts
28
+ import {TasraClient} from '@t3foundry/tasra-sdk/app'
29
+
30
+ // manifestUrl names the release manifest; sha256 comes from its trusted pointer.
31
+ const tasra = await TasraClient.fromManifest(manifestUrl, {
32
+ sha256,
33
+ coordinator: 'lowest-operator-id',
34
+ })
35
+ console.log(await tasra.check())
36
+ ```
37
+
38
+ The coordinator option must match the deployment's convention; release manifests
39
+ do not currently record it. RPC and verifier URLs are resolved from the manifest's
40
+ services and network profile. Planned or retired records cannot configure a live
41
+ client. A checksum establishes integrity only when its source is trusted.
42
+
43
+ `check()` checks the RPC chain and registry bytecode presence. It does not certify
44
+ keeper availability, issuer acceptance or successful signing. Keep the manifest
45
+ revision and digest with the application, and review updates deliberately.
46
+
47
+ ## Create a wallet, identity and slot
48
+
49
+ Continue with the client and deployment configuration loaded above. The creator wallet pays network fees;
50
+ fund its printed address through the network's faucet or a wallet you control.
51
+ The SDK generates fresh keys and preserves the same ones on restart.
52
+
53
+ ```ts
54
+ import {TasraClient, createLocalWallet, createIdentity, credentialPolicy} from '@t3foundry/tasra-sdk/app'
55
+ import {createFileStore} from '@t3foundry/tasra-sdk/app/node'
56
+
57
+ const store = createFileStore('.tasra')
58
+ const tasra = await TasraClient.fromManifest(manifestUrl, {sha256, coordinator: 'lowest-operator-id', store})
59
+ const wallet = createLocalWallet(tasra.deployment, {
60
+ privateKey: await store.load<`0x${string}`>('creator-key'),
61
+ })
62
+ await store.save('creator-key', wallet.exportPrivateKey())
63
+ console.log('Fund this creator address:', wallet.address)
64
+ if (await tasra.chain.client.getBalance({address: wallet.address}) === 0n) {
65
+ throw new Error('Fund the saved creator wallet before running slot creation')
66
+ }
67
+
68
+ const issuer = createIdentity({seed: await store.load<Uint8Array>('issuer-key')})
69
+ await store.save('issuer-key', issuer.exportPrivateKey())
70
+ const policy = credentialPolicy({issuer, type: 'urn:my-app:member'})
71
+ const account = await tasra.slots.create({
72
+ name: 'team-account', mode: 'ecdsa', policy,
73
+ threshold: {k: 2, n: 3}, verifiers: {committee: 3, quorum: 2},
74
+ }, {wallet})
75
+ console.log('Shared account:', await account.getAddress())
76
+ ```
77
+
78
+ You can also supply `wallet` in the `TasraClient` constructor when restoring an
79
+ existing creator. `tasra.wallets.create()` is the bound equivalent of
80
+ `createLocalWallet(tasra.deployment)`. Run creation after the creator has sufficient funds. `slots.create` commits the
81
+ access policy, saves recovery state, creates the slot, waits for key generation,
82
+ delivers the rule to its keepers and confirms the requested verifier policy.
83
+ Reusing the same name and request resumes the existing slot. An uncertain
84
+ transaction outcome stops for reconciliation; it does not silently create another
85
+ slot. Keep `.tasra` private and out of source control. `createFileStore` uses private
86
+ files and a process lock; a browser or database application supplies an
87
+ `ApplicationStore` with durable saves and exclusive locking.
88
+
89
+ Choose `mode: 'ecdsa'` for a shared Ethereum account, `'bls'` for encrypted documents,
90
+ or `'frost'` for document signatures. Keeper and verifier thresholds are explicit
91
+ application policy choices; the values above describe the example deployment.
92
+
93
+ ## Choose credential or OAuth authorization
94
+
95
+ `slots.create` defaults to `authType: 'oid4vp'` for credential policies. For a
96
+ BYOIDP policy, pass `authType: 'oauth'` explicitly:
97
+
98
+ ```ts
99
+ const account = await tasra.slots.create({
100
+ name: 'workplace-account', mode: 'ecdsa', authType: 'oauth', policy: oauthPolicy,
101
+ threshold: {k: 2, n: 3}, verifiers: {committee: 3, quorum: 2},
102
+ }, {wallet})
103
+ ```
104
+
105
+ Here `oauthPolicy` is a validated DCQL JSON string whose credential queries use
106
+ `oauth+access-token+dpop`. Pin the IdP issuer, platform audience and token maximum
107
+ age; see [API overview’s OAuth section](api.md). Creation rejects policies whose query
108
+ formats disagree with the selected authorization type, including mixed credential
109
+ and OAuth policies. OAuth rules are still DCQL and use the same canonical JSON
110
+ commitment calculation as credential DCQL rules.
111
+
112
+ `credentials.authorize()` presents SD-JWT credentials through OID4VP; it does not
113
+ obtain or present an OAuth token. For OAuth operations, use the existing
114
+ `createOauthSession`, `submitOauthResponse` and `waitForSession` exports from
115
+ `@t3foundry/tasra-sdk/verifier-agent` with a token from your IdP and its bound DPoP signer.
116
+ Connect that operation-bound flow to your application's `OperationAuthorizer`;
117
+ selecting `authType` at creation does not implement IdP sign-in for your app.
118
+
119
+ ## Recovery boundaries
120
+
121
+ A normal interruption that lets the operation settle releases its store lock. Restart
122
+ with the same wallet, manifest, slot name and request to resume recorded transaction
123
+ hashes. A submission without a hash requires reconciliation; never delete the journal
124
+ or change the slot name to force a retry.
125
+
126
+ An abrupt process kill can leave a `createFileStore` lock behind. The SDK deliberately
127
+ does not expire or steal locks, and currently has no public stale-lock recovery method.
128
+ Stop, preserve the private store, establish that the owning process has ended, and
129
+ reconcile outstanding transactions before any manual intervention. Do not infer that
130
+ an old lock is safe to remove from its age alone.
131
+
132
+ The named `slots.create` workflow currently has no automatic expired-commit recovery
133
+ or public journal-reset operation. Preserve its journal and report this as unsupported
134
+ recovery. Low-level expiry checks do not themselves safely transition a named-slot
135
+ journal. Unavailable DKG is a readiness failure: keep the same intent, inspect the
136
+ deployment, and resume only when it can progress. It is not permission to create
137
+ a replacement slot or to bypass authorization.
138
+
139
+ ## Fund a fresh creator
140
+
141
+ Create and privately save the creator wallet before requesting funds. Print its
142
+ public address, then use the selected network's faucet or transfer from a wallet
143
+ you control. A faucet URL must come from the network's published configuration;
144
+ the SDK does not infer one from the chain ID. No shared private key is required.
145
+
146
+ ```ts
147
+ console.log('Creator address:', wallet.address)
148
+ console.log('Native balance:', await tasra.chain.client.getBalance({address: wallet.address}))
149
+ ```
150
+
151
+ On Avalanche, fund the creator with AVAX for transaction fees. Then buy TASRA
152
+ with EURC through the bonding curve and deposit TASRA into the slot's Settlement
153
+ balance. Follow [Buy TASRA and fund your slot](funding.md) for the faucet link,
154
+ commands and balance checks. An Ethereum slot account also needs its own AVAX
155
+ for sending transactions. Funding does not grant permission to sign or decrypt;
156
+ each protected operation still needs valid authorization.
157
+
158
+ ## Issue credentials and authorize a user
159
+
160
+ ```ts
161
+ const alice = tasra.identities.create()
162
+ const credential = tasra.credentials.issue({
163
+ issuer, holder: alice, type: 'urn:my-app:member', claims: {name: 'Alice'},
164
+ })
165
+ const authorize = tasra.credentials.authorize({
166
+ verifierAgentUrl: tasra.verifierAgentUrl!, signer: wallet.signer,
167
+ identity: alice, credentials: [credential],
168
+ })
169
+ const sharedWallet = await tasra.wallets.fromSlot(account.slotId, {authorize})
170
+ console.log(sharedWallet.address)
171
+ // A named transfer saves its signed bytes/hash and waits for confirmation.
172
+ // await sharedWallet.transfer('first-payment', {to: recipient, value: 1n}, store)
173
+ ```
174
+
175
+ Each invocation opens a new operation-bound session and presents the credential.
176
+ The API does not promise that every token field changes between repeated operations:
177
+ `vp_hash` is not a session identifier or a uniqueness check. When testing fresh
178
+ wallet interactions, observe the session creation and presentation, alongside the
179
+ SDK's checks of operation binding and expiry; do not require unequal `vp_hash` values.
180
+
181
+ The application approves the credential issuer in the slot policy. Locally issued
182
+ credentials are for development unless your deployment trusts that issuer.
183
+ `identities.create` creates a `did:jwk` identity; save its explicitly exported key
184
+ if it must survive a restart. `credentials.issue`, `verify`, `present` and `authorize`
185
+ handle SD-JWT credentials and OID4VP presentations. Local credential verification
186
+ checks signatures, lifetime and supplied pins; it does not check revocation or
187
+ establish trust in an issuer.
188
+
189
+ Passing credentials to `authorize` permits their presentation for each exact
190
+ operation. Supply its `approve` callback to show your own consent screen. The SDK
191
+ creates the session, presents the credential, polls the result and checks the
192
+ operation binding. For an external Ethereum wallet, use
193
+ `await tasra.wallets.connect(provider)`; it requests account access and checks the
194
+ selected chain. The existing `toViemAccount` adapter remains available for advanced
195
+ Ethereum integrations, with viem installed by the SDK.
196
+
197
+ ## Read an Ethereum address
198
+
199
+ ```ts
200
+ const account = await tasra.slots.ecdsa(slotId)
201
+ console.log(await account.getAddress())
202
+ ```
203
+
204
+ No credential, signer or wallet session is needed. The SDK checks that the slot
205
+ exists, is active, has completed key generation and uses secp256k1 tECDSA.
206
+
207
+ ## Authorize each exact operation
208
+
209
+ An `OperationAuthorizer` receives the exact chain, registry, slot, action and
210
+ payload. Your app presents the wallet interaction and returns its compound token
211
+ and verifier membership proofs. The SDK checks request binding, holder binding,
212
+ expiry and slot stability before contacting a keeper.
213
+
214
+ Use `registeredWalletAuthorization({client, signer, present})` with an independently
215
+ approved registered agent. Its `present(session, signal)` callback displays a QR
216
+ or performs the app's credential-wallet flow. It polls the original authenticated
217
+ session and never transfers authorization to a fallback provider.
218
+
219
+ The examples use the manifest’s verifier agent and create their own issuer and
220
+ holder credentials. The verifier must support those formats and accept the issuer
221
+ pinned by the slot. Production enrollment and issuer governance belong to the application.
222
+
223
+ ## Use your normal Ethereum library
224
+
225
+ ```ts
226
+ import {toViemAccount} from '@t3foundry/tasra-sdk/app'
227
+
228
+ const walletAccount = await toViemAccount(account, {authorize})
229
+ const signature = await walletAccount.signMessage({message: 'Hello Tasra'})
230
+ // Or pass walletAccount to viem's createWalletClient.
231
+ ```
232
+
233
+ Each signing call requests fresh authorization. The adapter supports message,
234
+ typed-data and transaction signing, verifies the recovered account, and does not
235
+ broadcast automatically. Store a signed transaction and its hash before sending
236
+ it; after a lost response, look up that hash before considering another submission.
237
+
238
+ ## Encrypt a note
239
+
240
+ ```ts
241
+ const notes = await tasra.slots.bls(slotId)
242
+ // issuerDid is the trusted credential issuer pinned by this slot's rule.
243
+ const identity = `${issuerDid}/notes/${crypto.randomUUID()}/version/1`
244
+ const ciphertext = await notes.encrypt(identity, new TextEncoder().encode('Hello'))
245
+ const {plaintext, evidence} = await notes.decrypt(identity, ciphertext, {authorize})
246
+ ```
247
+
248
+ This uses `kk_scope_namespace: 'issuer'`: the credential must grant this identity,
249
+ and the committed rule must require the scope claim. The complete
250
+ [encrypted-notes app](../examples/encrypted-notes.ts) shows issuer, rule and credential setup.
251
+
252
+ Encryption needs only the anchored public key. Decryption requires a distinct
253
+ assigned keeper quorum, one epoch, valid shares and a combined identity key matching
254
+ the chain-anchored group key. Temporary extraction shares and the intermediate
255
+ identity key are cleared. The returned plaintext belongs to your app.
256
+
257
+ Use a fresh identity for every immutable document version. An extracted identity
258
+ key is a durable capability: token expiry does not revoke it. `extractIdentity`
259
+ returns that capability only when your app explicitly needs custody.
260
+
261
+ The application path reports `shareTrust: 'anchored-group'`. It does **not** claim
262
+ independently authenticated per-keeper verifying shares. Advanced callers with
263
+ independent share certificates can use `extractIdentityStrict` with `pinned-shares`.
264
+
265
+ ## Sign a document
266
+
267
+ ```ts
268
+ const signer = await tasra.slots.frost(slotId)
269
+ const signed = await signer.sign(documentManifestBytes, {authorize})
270
+ ```
271
+
272
+ The SDK verifies the exact message, slot, epoch, anchored key and FROST signature.
273
+ Keep the immutable document digest and workflow request/version in the signed
274
+ manifest. For a two-person document workflow, use two signer-specific slots and
275
+ require two independent signatures. A native quorum on one slot is a different
276
+ workflow; see [native approvals](native-approvals.md).
277
+
278
+ ## Require two approvals for one signature
279
+
280
+ For native FROST approvals, `setApprovalPolicy(tasra, slotId, policy, {wallet, store})`
281
+ sets and checks the on-chain policy through a durable transaction. Choose explicit
282
+ Ed25519 `approvers` with a `quorum`, or an exact `credentialPolicy` with a `quorum`.
283
+ `identityApprover(identity)` adapts an SDK Ed25519 identity to `request.approve`.
284
+ `approveWithCredential(tasra, request, message, {identity, authorize})` presents a
285
+ credential bound to that request before signing its canonical approval payload.
286
+ These helpers preserve the existing [native approval lifecycle](native-approvals.md),
287
+ including distinct approvers and refusal of cross-request replay.
288
+
289
+ ## Advanced creation and recovery
290
+
291
+ ```ts
292
+ import {prepareSlot, createPreparedSlot} from '@t3foundry/tasra-sdk/app'
293
+
294
+ const journal = prepareSlot(deployment, creatorAddress, {
295
+ rule: JSON.stringify(rule), mode: 'tecdsa', authType: 'oid4vp', k: 2, n: 3,
296
+ })
297
+ const created = await createPreparedSlot(journal, {
298
+ wallet: creatorWallet,
299
+ persist: async snapshot => database.saveAtomically(snapshot),
300
+ })
301
+ ```
302
+
303
+ `prepareSlot` creates the slot ID and both salts before network writes. The journal
304
+ contains private rule/recovery data; keep it out of public evidence. `persist` must
305
+ commit each snapshot before resolving. Serialize runs for the same intent with a
306
+ database lock or a single process. The SDK does not provide cross-tab locking.
307
+ Creation and provisioning require `rule`; `dcqlRule` is rejected even alongside
308
+ `rule`. Older journals must be explicitly migrated before resuming: follow the
309
+ [rule and recovery-state migration](consumer-migrations.md#use-generic-rule-names)
310
+ and preserve their exact policy, salts and transaction history.
311
+
312
+ On restart, load the latest snapshot and call `createPreparedSlot` again. Known
313
+ hashes are waited on and never resubmitted. A `submitting` step without a hash
314
+ raises `CreationReconciliationRequiredError`: recover the transaction hash from
315
+ the wallet/chain, check it belongs to this intent, then resume. Do not invent a
316
+ new slot or salt. The lower-level `createPreparedSlot` ends at the confirmed reveal; its caller waits
317
+ for DKG and calls `provisionRule`. The beginner `tasra.slots.create` method performs
318
+ those steps and configures the verifier policy for you. A cancelled local wait cannot
319
+ cancel a transaction already sent.
320
+
321
+ ## Evidence and errors
322
+
323
+ FROST signing and IBE extraction preserve optional keeper receipts. The SDK checks
324
+ those receipts against the serving keeper key and expected operation references.
325
+ Use `requireReceipt` for FROST or `requireReceipts` for IBE to require their presence.
326
+ Unsigned replies are explicitly `absent`; a malformed or invalid receipt fails.
327
+ ECDSA and native dual-sign routes are not promised to emit these attestations.
328
+
329
+ Handle `TasraApplicationError.code` for chain mismatch, absent/cancelled slot,
330
+ wrong mode, unfinished DKG, changed slot, invalid grant or invalid result. Treat
331
+ HTTP 401/403 as refusals. Do not log raw grant objects or HTTP request bodies.
332
+
333
+ Task-context enforcement and native multi-approver IBE are not supported. Enforce
334
+ application-specific task boundaries in your own application; do not infer an IBE
335
+ approval quorum from the native FROST approval API.
@@ -0,0 +1,65 @@
1
+ # How the application SDK connects to Tasra
2
+
3
+ New applications use `TasraClient` from `@t3foundry/tasra-sdk/app`. A public manifest describes
4
+ the deployment; a wallet authorizes chain writes; a durable store retains private
5
+ operation state. The SDK then exposes:
6
+
7
+ - `slots.create`: persist the commitment, create the slot, wait for its key,
8
+ deliver the committed rule and confirm the verifier policy.
9
+ - `identities` and `credentials`: create development DIDs, issue holder-bound
10
+ credentials, define policy and present credentials for an exact operation.
11
+ - `wallets`: create/connect a wallet or adapt an ECDSA slot for confirmed transfers.
12
+ - Typed BLS/FROST/ECDSA handles: use the slot while checking its mode, authorization
13
+ and the returned cryptographic result.
14
+
15
+ The network remains authoritative for credential acceptance and keeper execution.
16
+ The app still owns its business rules, user consent and protected storage. See
17
+ [Application API](application-api.md) and [recovery boundaries](application-api.md#recovery-boundaries).
18
+
19
+ ## Advanced managed-session internals
20
+
21
+ The following describes the retained **exportable-key managed-session API**.
22
+ It is distinct from the current BLS identity-scoped tutorial, which extracts a
23
+ scoped identity capability and never assembles a master key in the application.
24
+
25
+ What `openSession` does internally, if you want to drive it yourself:
26
+
27
+ ```ts
28
+ import {
29
+ redeemCredential, fetchMpk, fetchAndAssembleKey,
30
+ encryptEnvelope, toBytes, buildTasraText, hexToBytes,
31
+ } from '@t3foundry/tasra-sdk'
32
+
33
+ // 1. obtain a DCQL-gated JWT from the verifier
34
+ const {token: jwt} = await redeemCredential(verifierUrl, redemptionToken, 'did:example:alice')
35
+
36
+ // 2. assemble the slot's master key from k-of-n nodes (no node ever sees it whole)
37
+ const {mpkBytes, epoch} = await fetchMpk(nodeUrls[0], slotHex)
38
+ const msk = await fetchAndAssembleKey({urls: nodeUrls, jwt}, slotHex)
39
+
40
+ // 3. encrypt — publish buildTasraText(toBytes(env)) via any transport;
41
+ // decrypt with `msk` on the way back
42
+ const env = encryptEnvelope(hexToBytes(slotHex), mpkBytes, aad, plaintextBytes, BigInt(epoch))
43
+ ```
44
+
45
+ The master key only ever exists ephemerally, in your process — `Session.close()`
46
+ wipes it when you're done (if you hold a raw `msk` from `fetchAndAssembleKey`,
47
+ `msk.fill(0)` is the equivalent).
48
+
49
+ ---
50
+
51
+ ## Layering
52
+
53
+ ```
54
+ the network ──────────────── keepers + verifiers + accountants + contracts, the source of truth
55
+ ▲ HTTP / JSON-RPC
56
+ tasra-sdk (this repo) ───── manifest-based client + typed operations over protocol primitives
57
+ ▲ composed by
58
+ your product ─────────────── a messaging app, a vault, a signer, an explorer — anything
59
+ ```
60
+
61
+ License: Apache-2.0.
62
+
63
+ ---
64
+
65
+ [Back to the README](../README.md) · [Documentation index](README.md)
package/docs/basics.md ADDED
@@ -0,0 +1,48 @@
1
+ # Understand TASRA
2
+
3
+ TASRA lets your application sign transactions and protect data using keys managed
4
+ by a network of cooperating servers. The SDK connects your TypeScript application
5
+ to that network and handles the steps needed to use those keys.
6
+
7
+ Your first goal is to understand a **slot**, then connect without creating anything.
8
+
9
+ ## What is a slot?
10
+
11
+ A slot is a network-managed key with a rule describing who may use it. It has a
12
+ public ID that your application saves and uses to find it again. A slot is not a
13
+ folder for documents or a user account in your database.
14
+
15
+ Choose its mode according to what your application needs:
16
+
17
+ | Application need | Slot mode |
18
+ |---|---|
19
+ | Send Ethereum transactions from an account | `ecdsa` |
20
+ | Sign a document or another exact message | `frost` |
21
+ | Encrypt data and control who can decrypt it | `bls` |
22
+
23
+ The cooperating servers are called **keepers**. Their signing threshold is separate
24
+ from the number of people allowed to use the slot.
25
+
26
+ ## Creator and user
27
+
28
+ The **creator** sets up the slot, chooses its access rule and pays the required
29
+ network fees. A **user** satisfies that rule to request an operation. Creating a
30
+ slot does not automatically authorize every operation on it.
31
+
32
+ On Avalanche, the creator needs **AVAX for transaction fees**. The slot needs
33
+ **TASRA usage credits** before signing or decryption. Buy TASRA with EURC through
34
+ the bonding curve, then deposit it into the slot. The creation lesson walks you
35
+ through [funding](funding.md).
36
+
37
+ ## Learn in this order
38
+
39
+ 1. [Connect](getting-started.md) using a manifest downloaded from
40
+ [tasra-releases](https://github.com/t3foundry/tasra-releases).
41
+ 2. [Create one slot](create-slot.md).
42
+ 3. [Read its public state](read-slot.md).
43
+ 4. [Manage its lifetime](manage-slot.md). Learn renewal first; keep the slot for
44
+ later lessons and cancel it when finished.
45
+ 5. [Give a user access](access-control.md).
46
+ 6. [Sign or encrypt](signing-and-encryption.md), then add other workflows as needed.
47
+
48
+ **Next:** [Connect your first TypeScript application](getting-started.md).
@@ -0,0 +1,86 @@
1
+ # What you can do
2
+
3
+ > The capability catalogue: every major thing this SDK does, with the functions that
4
+ > do it. Skim it once to learn the shape of the surface, then use
5
+ > [Advanced clients and OAuth](api.md) for detail.
6
+
7
+ ## Application API
8
+
9
+ Start with [TasraClient](application-api.md) and the deployment's public manifest.
10
+ The SDK includes wallet and credential adapters; apps do not need a separate
11
+ Ethereum or cryptography library for this path.
12
+
13
+ | Goal | SDK operation |
14
+ |---|---|
15
+ | Connect and inspect a deployment | `new TasraClient({manifest})`, `TasraClient.fromManifest`, `check` |
16
+ | Create a ready slot with an access commitment | `slots.create` and a durable store |
17
+ | Create DIDs, credentials and presentations | `identities.create`, `credentials.issue`, `verify`, `policy`, `present`, `authorize` |
18
+ | Share an Ethereum account | `wallets.fromSlot` and named `transfer` |
19
+ | Encrypt documents for authorized holders | `slots.bls`, `encrypt`, `decrypt` |
20
+ | Sign a document independently | `slots.frost`, `sign` |
21
+ | Require distinct people to approve one signature | `setApprovalPolicy`, `identityApprover`, `approveWithCredential`, `slot.approvals` |
22
+ | Keep private state in Node | `createFileStore` from `@t3foundry/tasra-sdk/app/node` |
23
+
24
+ [Complete runnable applications](README.md#build-an-app) demonstrate these operations.
25
+ The keeper threshold and the number of human approvals are separate policies.
26
+
27
+ ## Advanced and compatibility APIs
28
+
29
+ The following capabilities remain available for integrations needing explicit
30
+ protocol control or older deployment interfaces. Check deployment compatibility
31
+ before choosing a managed-session or direct committee route.
32
+
33
+ - **Open a managed session** — `createTasraClient({nodes, verifier, identity})`
34
+ then `client.openSession(slot, auth)` returns a `Session` that holds the JWT +
35
+ assembled key, **auto-renews the JWT**, **re-assembles on rotation**, and exposes
36
+ `encrypt` / `decrypt` / `sign` / `signDigest` / `close`.
37
+ - **…or open one from just a slot id, endpoints resolved from chain** — the chain-driven
38
+ surface in `@t3foundry/tasra-sdk/chain`: `createTasraSlotClient` (JWT path) and
39
+ `createCommitteeSlotClient` (committee path) discover the keeper nodes from the
40
+ slot's on-chain committee and **choose the verifier from the on-chain verifier set** — no
41
+ hardcoded node/verifier URLs.
42
+ - **Assemble a key from the fleet** — fetch BLS shards from `k`-of-`n`
43
+ keykeeper-nodes and **Lagrange-assemble the master secret key in-process** (the
44
+ local-decrypt model — the nodes reveal their shards and you reconstruct the key), or leave
45
+ the key on the fleet and **decrypt over the threshold** so it's never reconstructed.
46
+ `fetchMpk`, `fetchAndAssembleKey`
47
+ - **Encrypt / decrypt envelopes** — ChaCha20-Poly1305 over a BLS12-381 G2 ElGamal
48
+ KEM, in a versioned `[KK]<base64>` wire envelope. `encryptEnvelope`,
49
+ `decryptWithMasterKey`, `toBytes`/`fromBytes`, `buildTasraText`/`parseTasraPost`
50
+ - **Sign** — FROST-Ed25519 (custody one-shot + client-coordinated shard-delivery,
51
+ with local aggregation) and threshold ECDSA for EVM EOAs. `signCustody`,
52
+ `signWithShardDelivery`, `signEoaDigest`, `aggregateFrostSignature`
53
+ - **Decrypt over the threshold** — node-coordinated custody or client-side
54
+ share-combine that never assembles the key. `decryptCustody`,
55
+ `decryptWithShardDelivery`, `combineDecryptShares`
56
+ - **Obtain & refresh DCQL-gated JWTs** — the full verifier credential lifecycle:
57
+ redeem a credential or renewal for a JWT, present signed VCs, mint admin
58
+ credentials, create/revoke renewals, and revoke a holder's slot access (re-keying
59
+ the slot). `redeemCredential`, `redeemRenewalToken`, `createRenewal`/`revokeRenewal`,
60
+ `issueAdminCredential`, `verifyVpJwt`/`verifyPresentation`, `revokeSlotUser`
61
+ - **Authorize with your own identity provider** — no wallet, no credentials: a
62
+ user's DPoP-bound OAuth access token from your Keycloak / Auth0 tenant authorizes the
63
+ operation through a Verifier Agent `oauth` session. `createOauthSession`,
64
+ `submitOauthResponse`, `waitForSession`, `auth0DpopSigner`, `createDpopKey` — see
65
+ [the OAuth + DPoP section](api.md).
66
+ - **Evaluate DCQL policy** — validate a rule before paying for a slot, or test a
67
+ subject against a rule client-side; a generic, opaque-scope evaluator mirroring
68
+ the reference implementation crate. `validateDcql`, `evaluateDcql`, `selectDcql`
69
+ - **Assemble compound committee authorization tokens** — per-request
70
+ verifier-committee selection, canonical hashing, ed25519 quorum verification,
71
+ verifier-set Merkle proofs. `selectVerifierCommittee`, `compoundTokenHash`,
72
+ `assembleCompoundToken`, `verifyCompoundToken`, …
73
+ - **Create on-chain Key Slots** — sovereign, self-signed (see [`@t3foundry/tasra-sdk/chain`](chain.md):
74
+ `createTasraWriteClient().createSlot`). Confirm the selected network’s creation
75
+ and usage charges. `httpFaucet` calls a compatible faucet supplied by the network;
76
+ it does not discover a faucet or fund an account automatically.
77
+ - **Read & write on-chain + network-service state** — the [`@t3foundry/tasra-sdk/chain`](chain.md) subpath.
78
+
79
+ ---
80
+
81
+ Next: [choose a client](api.md#choose-a-client) ·
82
+ [the full API surface](api.md) · [prerequisites](prerequisites.md)
83
+
84
+ ---
85
+
86
+ [Back to the README](../README.md) · [Documentation index](README.md)