@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,211 @@
1
+ // Agnostic verifier-auth + JWT helpers.
2
+ //
3
+ // Pure HTTP/JSON against the keykeeper verifier and pure client-side JWT
4
+ // inspection. NOTHING here knows about any specific transport or product -
5
+ // a consumer brings a verifier URL and the relevant
6
+ // token(s). These cover the "(obtain, refresh) a DCQL-gated JWT" lifecycle that
7
+ // every product on top of a Tasra Network needs.
8
+ import { httpError } from '../errors.js';
9
+ function base(url) {
10
+ return url.replace(/\/$/, '');
11
+ }
12
+ async function postJson(url, body) {
13
+ const res = await fetch(url, {
14
+ method: 'POST',
15
+ headers: { 'Content-Type': 'application/json' },
16
+ body: JSON.stringify(body),
17
+ });
18
+ if (!res.ok)
19
+ throw await httpError(res, url, `POST ${url}`);
20
+ return res.json();
21
+ }
22
+ /**
23
+ * Create a long-lived renewal from a presentation. On the prod (signed) path,
24
+ * pass `credentials` (compact JWS JWT-VCs) - they're signature-verified and
25
+ * replace the presentation's credentials. `slot_ids` (if given) are rotated via
26
+ * a webhook when the renewal is revoked.
27
+ * POST {verifier}/v1/renewals
28
+ *
29
+ * @param verifierUrl - Verifier HTTP base URL.
30
+ * @param body - Policy, presentation and optional signed credentials or revocation-bound slots.
31
+ */
32
+ export async function createRenewal(verifierUrl, body) {
33
+ const b = (await postJson(`${base(verifierUrl)}/v1/renewals`, body));
34
+ return { renewalToken: b.renewal_token, holder: b.holder, expiresAt: b.expires_at, scopes: b.scopes };
35
+ }
36
+ /**
37
+ * Revoke a renewal token - future redeems are denied, and any bound slots get a
38
+ * rotation webhook. POST {verifier}/v1/renewals/revoke {renewal_token}
39
+ *
40
+ * @param verifierUrl - Verifier HTTP base URL.
41
+ * @param renewalToken - Renewal token to revoke.
42
+ */
43
+ export async function revokeRenewal(verifierUrl, renewalToken) {
44
+ // revoke returns 200/204 with an EMPTY body - don't JSON-parse the response.
45
+ const url = `${base(verifierUrl)}/v1/renewals/revoke`;
46
+ const res = await fetch(url, {
47
+ method: 'POST',
48
+ headers: { 'Content-Type': 'application/json' },
49
+ body: JSON.stringify({ renewal_token: renewalToken }),
50
+ });
51
+ if (!res.ok)
52
+ throw await httpError(res, url, 'renewals/revoke');
53
+ }
54
+ /**
55
+ * Redeem a long-lived renewal token for a fresh JWT.
56
+ * POST {verifier}/v1/renewals/redeem {renewal_token}
57
+ *
58
+ * @param verifierUrl - Verifier HTTP base URL.
59
+ * @param renewalToken - Long-lived renewal token to redeem.
60
+ */
61
+ export async function redeemRenewalToken(verifierUrl, renewalToken) {
62
+ const b = (await postJson(`${base(verifierUrl)}/v1/renewals/redeem`, {
63
+ renewal_token: renewalToken,
64
+ }));
65
+ return { token: b.token, exp: b.exp, holder: b.holder };
66
+ }
67
+ /**
68
+ * Redeem an admin-issued, single-use credential/invite token for a JWT.
69
+ * POST {verifier}/v1/credentials/redeem {redemption_token, recipient_did}
70
+ *
71
+ * @param verifierUrl - Verifier HTTP base URL.
72
+ * @param redemptionToken - Single-use credential redemption token.
73
+ * @param recipientDid - DID of the recipient redeeming the token.
74
+ */
75
+ export async function redeemCredential(verifierUrl, redemptionToken, recipientDid) {
76
+ const b = (await postJson(`${base(verifierUrl)}/v1/credentials/redeem`, {
77
+ redemption_token: redemptionToken,
78
+ recipient_did: recipientDid,
79
+ }));
80
+ const token = b.jwt ?? b.token;
81
+ if (!token)
82
+ throw new Error('credentials/redeem: no token in response');
83
+ return { token, exp: b.exp, holder: b.holder };
84
+ }
85
+ /**
86
+ * Admin-mint a single-use credential (redemption token) for the given scopes.
87
+ * Requires the verifier's admin secret. Pair with redeemCredential() to get a
88
+ * JWT whose `sub` is the recipient DID you pass there.
89
+ * POST {verifier}/v1/admin/credentials/issue (header: X-Admin-Secret)
90
+ *
91
+ * @param verifierUrl - Verifier HTTP base URL.
92
+ * @param adminSecret - Verifier administrative secret; keep it out of browser code and logs.
93
+ * @param opts - Authorized scopes, optional slot bindings and lifetime.
94
+ */
95
+ export async function issueAdminCredential(verifierUrl, adminSecret, opts) {
96
+ const url = `${base(verifierUrl)}/v1/admin/credentials/issue`;
97
+ const res = await fetch(url, {
98
+ method: 'POST',
99
+ headers: { 'Content-Type': 'application/json', 'X-Admin-Secret': adminSecret },
100
+ body: JSON.stringify({
101
+ scopes: opts.scopes,
102
+ slot_ids: opts.slotIds ?? [],
103
+ ttl_secs: opts.ttlSecs ?? 600,
104
+ }),
105
+ });
106
+ if (!res.ok)
107
+ throw await httpError(res, url, 'admin/credentials/issue');
108
+ const b = (await res.json());
109
+ return { redemptionToken: b.redemption_token, expiresAt: b.expires_at };
110
+ }
111
+ /**
112
+ * Submit an administrative request to revoke a holder DID's slot access.
113
+ * Rotation is requested by default. A successful HTTP response confirms request
114
+ * acceptance only; callers must confirm the new slot key and epoch before relying
115
+ * on completed rotation. Resolve application handles to DIDs before calling.
116
+ *
117
+ * @param verifierUrl - Verifier HTTP base URL.
118
+ * @param adminSecret - Verifier administrative secret.
119
+ * @param opts - Slot, holder DID, optional rotation request and revocation reason.
120
+ */
121
+ export async function revokeSlotUser(verifierUrl, adminSecret, opts) {
122
+ if (!opts.did.startsWith('did:')) {
123
+ throw new Error(`revokeSlotUser: expected a DID (got "${opts.did}") — the verifier blocklists by DID`);
124
+ }
125
+ const url = `${base(verifierUrl)}/v1/admin/slots/revoke-user`;
126
+ const res = await fetch(url, {
127
+ method: 'POST',
128
+ headers: { 'Content-Type': 'application/json', 'X-Admin-Secret': adminSecret },
129
+ body: JSON.stringify({
130
+ slot_id: opts.slotId,
131
+ did: opts.did,
132
+ rotate: opts.rotate ?? true,
133
+ reason: opts.reason ?? 'revoked via SDK',
134
+ }),
135
+ });
136
+ if (!res.ok)
137
+ throw await httpError(res, url, 'admin/slots/revoke-user');
138
+ }
139
+ /**
140
+ * Present credentials directly for a JWT. The `body` shape is defined by the
141
+ * verifier (a DCQL rule + a presentation/credentials); we pass it through
142
+ * untouched so this stays agnostic to the credential format.
143
+ * POST {verifier}/v1/verify
144
+ *
145
+ * @param verifierUrl - Verifier HTTP base URL.
146
+ * @param body - Policy and credential presentation for verifier evaluation.
147
+ */
148
+ export async function verifyPresentation(verifierUrl, body) {
149
+ const b = (await postJson(`${base(verifierUrl)}/v1/verify`, body));
150
+ return { token: b.token, exp: b.exp, holder: b.holder };
151
+ }
152
+ /**
153
+ * The PRODUCTION credential path: present signed JWT-VCs + holder proof for a
154
+ * DCQL-gated JWT. The verifier checks each credential's signature against its
155
+ * configured trust anchor (by `iss`), that each `sub` equals `holder`, that
156
+ * `holder_proof` proves live control of the holder DID authentication key, then
157
+ * evaluates the rule. `credentials` are compact JWS strings (e.g. from
158
+ * `tasra-cli vc issue`).
159
+ * POST {verifier}/v1/verify-vp-jwt
160
+ *
161
+ * @param verifierUrl - Verifier HTTP base URL.
162
+ * @param body - Policy, holder DID, signed credentials and proof of holder-key possession.
163
+ */
164
+ export async function verifyVpJwt(verifierUrl, body) {
165
+ if (!body.holder_proof) {
166
+ throw new Error('verifyVpJwt: holder_proof is required to prove control of the holder DID');
167
+ }
168
+ const b = (await postJson(`${base(verifierUrl)}/v1/verify-vp-jwt`, body));
169
+ return { token: b.token, exp: b.exp, holder: b.holder };
170
+ }
171
+ function b64urlDecode(s) {
172
+ const pad = s.length % 4 === 0 ? '' : '='.repeat(4 - (s.length % 4));
173
+ return atob(s.replace(/-/g, '+').replace(/_/g, '/') + pad);
174
+ }
175
+ /**
176
+ * Decode JWT claims WITHOUT verifying the signature (for expiry/UX only).
177
+ *
178
+ * @param jwt - Compact JWT to decode without signature verification.
179
+ */
180
+ export function decodeJwtClaims(jwt) {
181
+ const parts = jwt.split('.');
182
+ if (parts.length !== 3)
183
+ return null;
184
+ try {
185
+ return JSON.parse(b64urlDecode(parts[1]));
186
+ }
187
+ catch {
188
+ return null;
189
+ }
190
+ }
191
+ /**
192
+ * Expiry as epoch-ms, or null if absent/unparseable.
193
+ *
194
+ * @param jwt - Compact JWT whose expiration claim will be inspected without verification.
195
+ */
196
+ export function jwtExpMs(jwt) {
197
+ const exp = decodeJwtClaims(jwt)?.exp;
198
+ return typeof exp === 'number' ? exp * 1000 : null;
199
+ }
200
+ /**
201
+ * True when the token is expired or within `skewMs` of expiring.
202
+ *
203
+ * @param jwt - Compact JWT to inspect without signature verification.
204
+ * @param skewMs - Refresh lead time in milliseconds.
205
+ */
206
+ export function isJwtExpiringSoon(jwt, skewMs = 30_000) {
207
+ const exp = jwtExpMs(jwt);
208
+ if (exp === null)
209
+ return false;
210
+ return Date.now() + skewMs >= exp;
211
+ }
@@ -0,0 +1,441 @@
1
+ /** AccountantSetRegistry contract interface for accountant-set snapshots and membership evidence. */
2
+ export declare const accountantSetRegistryAbi: readonly [{
3
+ readonly type: "constructor";
4
+ readonly inputs: readonly [];
5
+ readonly stateMutability: "nonpayable";
6
+ }, {
7
+ readonly type: "function";
8
+ readonly name: "UPGRADE_INTERFACE_VERSION";
9
+ readonly inputs: readonly [];
10
+ readonly outputs: readonly [{
11
+ readonly name: "";
12
+ readonly type: "string";
13
+ readonly internalType: "string";
14
+ }];
15
+ readonly stateMutability: "view";
16
+ }, {
17
+ readonly type: "function";
18
+ readonly name: "acceptOwnership";
19
+ readonly inputs: readonly [];
20
+ readonly outputs: readonly [];
21
+ readonly stateMutability: "nonpayable";
22
+ }, {
23
+ readonly type: "function";
24
+ readonly name: "anchorSnapshot";
25
+ readonly inputs: readonly [{
26
+ readonly name: "epoch";
27
+ readonly type: "uint64";
28
+ readonly internalType: "uint64";
29
+ }, {
30
+ readonly name: "root";
31
+ readonly type: "bytes32";
32
+ readonly internalType: "bytes32";
33
+ }, {
34
+ readonly name: "size";
35
+ readonly type: "uint32";
36
+ readonly internalType: "uint32";
37
+ }, {
38
+ readonly name: "deadline";
39
+ readonly type: "uint64";
40
+ readonly internalType: "uint64";
41
+ }, {
42
+ readonly name: "sig";
43
+ readonly type: "bytes";
44
+ readonly internalType: "bytes";
45
+ }];
46
+ readonly outputs: readonly [];
47
+ readonly stateMutability: "nonpayable";
48
+ }, {
49
+ readonly type: "function";
50
+ readonly name: "beacon";
51
+ readonly inputs: readonly [];
52
+ readonly outputs: readonly [{
53
+ readonly name: "";
54
+ readonly type: "address";
55
+ readonly internalType: "contract IThresholdBeacon";
56
+ }];
57
+ readonly stateMutability: "view";
58
+ }, {
59
+ readonly type: "function";
60
+ readonly name: "initialize";
61
+ readonly inputs: readonly [{
62
+ readonly name: "beacon_";
63
+ readonly type: "address";
64
+ readonly internalType: "address";
65
+ }, {
66
+ readonly name: "owner_";
67
+ readonly type: "address";
68
+ readonly internalType: "address";
69
+ }];
70
+ readonly outputs: readonly [];
71
+ readonly stateMutability: "nonpayable";
72
+ }, {
73
+ readonly type: "function";
74
+ readonly name: "lastEpoch";
75
+ readonly inputs: readonly [];
76
+ readonly outputs: readonly [{
77
+ readonly name: "";
78
+ readonly type: "uint64";
79
+ readonly internalType: "uint64";
80
+ }];
81
+ readonly stateMutability: "view";
82
+ }, {
83
+ readonly type: "function";
84
+ readonly name: "leafHash";
85
+ readonly inputs: readonly [{
86
+ readonly name: "index";
87
+ readonly type: "uint32";
88
+ readonly internalType: "uint32";
89
+ }, {
90
+ readonly name: "operator";
91
+ readonly type: "address";
92
+ readonly internalType: "address";
93
+ }];
94
+ readonly outputs: readonly [{
95
+ readonly name: "";
96
+ readonly type: "bytes32";
97
+ readonly internalType: "bytes32";
98
+ }];
99
+ readonly stateMutability: "pure";
100
+ }, {
101
+ readonly type: "function";
102
+ readonly name: "owner";
103
+ readonly inputs: readonly [];
104
+ readonly outputs: readonly [{
105
+ readonly name: "";
106
+ readonly type: "address";
107
+ readonly internalType: "address";
108
+ }];
109
+ readonly stateMutability: "view";
110
+ }, {
111
+ readonly type: "function";
112
+ readonly name: "pendingOwner";
113
+ readonly inputs: readonly [];
114
+ readonly outputs: readonly [{
115
+ readonly name: "";
116
+ readonly type: "address";
117
+ readonly internalType: "address";
118
+ }];
119
+ readonly stateMutability: "view";
120
+ }, {
121
+ readonly type: "function";
122
+ readonly name: "proxiableUUID";
123
+ readonly inputs: readonly [];
124
+ readonly outputs: readonly [{
125
+ readonly name: "";
126
+ readonly type: "bytes32";
127
+ readonly internalType: "bytes32";
128
+ }];
129
+ readonly stateMutability: "view";
130
+ }, {
131
+ readonly type: "function";
132
+ readonly name: "renounceOwnership";
133
+ readonly inputs: readonly [];
134
+ readonly outputs: readonly [];
135
+ readonly stateMutability: "nonpayable";
136
+ }, {
137
+ readonly type: "function";
138
+ readonly name: "setBeacon";
139
+ readonly inputs: readonly [{
140
+ readonly name: "next";
141
+ readonly type: "address";
142
+ readonly internalType: "address";
143
+ }];
144
+ readonly outputs: readonly [];
145
+ readonly stateMutability: "nonpayable";
146
+ }, {
147
+ readonly type: "function";
148
+ readonly name: "snapshotAt";
149
+ readonly inputs: readonly [{
150
+ readonly name: "";
151
+ readonly type: "uint64";
152
+ readonly internalType: "uint64";
153
+ }];
154
+ readonly outputs: readonly [{
155
+ readonly name: "root";
156
+ readonly type: "bytes32";
157
+ readonly internalType: "bytes32";
158
+ }, {
159
+ readonly name: "size";
160
+ readonly type: "uint32";
161
+ readonly internalType: "uint32";
162
+ }];
163
+ readonly stateMutability: "view";
164
+ }, {
165
+ readonly type: "function";
166
+ readonly name: "snapshotDigest";
167
+ readonly inputs: readonly [{
168
+ readonly name: "root";
169
+ readonly type: "bytes32";
170
+ readonly internalType: "bytes32";
171
+ }, {
172
+ readonly name: "size";
173
+ readonly type: "uint32";
174
+ readonly internalType: "uint32";
175
+ }, {
176
+ readonly name: "epoch";
177
+ readonly type: "uint64";
178
+ readonly internalType: "uint64";
179
+ }, {
180
+ readonly name: "deadline";
181
+ readonly type: "uint64";
182
+ readonly internalType: "uint64";
183
+ }];
184
+ readonly outputs: readonly [{
185
+ readonly name: "";
186
+ readonly type: "bytes32";
187
+ readonly internalType: "bytes32";
188
+ }];
189
+ readonly stateMutability: "view";
190
+ }, {
191
+ readonly type: "function";
192
+ readonly name: "transferOwnership";
193
+ readonly inputs: readonly [{
194
+ readonly name: "newOwner";
195
+ readonly type: "address";
196
+ readonly internalType: "address";
197
+ }];
198
+ readonly outputs: readonly [];
199
+ readonly stateMutability: "nonpayable";
200
+ }, {
201
+ readonly type: "function";
202
+ readonly name: "upgradeToAndCall";
203
+ readonly inputs: readonly [{
204
+ readonly name: "newImplementation";
205
+ readonly type: "address";
206
+ readonly internalType: "address";
207
+ }, {
208
+ readonly name: "data";
209
+ readonly type: "bytes";
210
+ readonly internalType: "bytes";
211
+ }];
212
+ readonly outputs: readonly [];
213
+ readonly stateMutability: "payable";
214
+ }, {
215
+ readonly type: "function";
216
+ readonly name: "version";
217
+ readonly inputs: readonly [];
218
+ readonly outputs: readonly [{
219
+ readonly name: "";
220
+ readonly type: "string";
221
+ readonly internalType: "string";
222
+ }];
223
+ readonly stateMutability: "pure";
224
+ }, {
225
+ readonly type: "event";
226
+ readonly name: "BeaconSet";
227
+ readonly inputs: readonly [{
228
+ readonly name: "previous";
229
+ readonly type: "address";
230
+ readonly indexed: true;
231
+ readonly internalType: "address";
232
+ }, {
233
+ readonly name: "next";
234
+ readonly type: "address";
235
+ readonly indexed: true;
236
+ readonly internalType: "address";
237
+ }];
238
+ readonly anonymous: false;
239
+ }, {
240
+ readonly type: "event";
241
+ readonly name: "Initialized";
242
+ readonly inputs: readonly [{
243
+ readonly name: "version";
244
+ readonly type: "uint64";
245
+ readonly indexed: false;
246
+ readonly internalType: "uint64";
247
+ }];
248
+ readonly anonymous: false;
249
+ }, {
250
+ readonly type: "event";
251
+ readonly name: "OwnershipTransferStarted";
252
+ readonly inputs: readonly [{
253
+ readonly name: "previousOwner";
254
+ readonly type: "address";
255
+ readonly indexed: true;
256
+ readonly internalType: "address";
257
+ }, {
258
+ readonly name: "newOwner";
259
+ readonly type: "address";
260
+ readonly indexed: true;
261
+ readonly internalType: "address";
262
+ }];
263
+ readonly anonymous: false;
264
+ }, {
265
+ readonly type: "event";
266
+ readonly name: "OwnershipTransferred";
267
+ readonly inputs: readonly [{
268
+ readonly name: "previousOwner";
269
+ readonly type: "address";
270
+ readonly indexed: true;
271
+ readonly internalType: "address";
272
+ }, {
273
+ readonly name: "newOwner";
274
+ readonly type: "address";
275
+ readonly indexed: true;
276
+ readonly internalType: "address";
277
+ }];
278
+ readonly anonymous: false;
279
+ }, {
280
+ readonly type: "event";
281
+ readonly name: "SnapshotAnchored";
282
+ readonly inputs: readonly [{
283
+ readonly name: "epoch";
284
+ readonly type: "uint64";
285
+ readonly indexed: true;
286
+ readonly internalType: "uint64";
287
+ }, {
288
+ readonly name: "root";
289
+ readonly type: "bytes32";
290
+ readonly indexed: false;
291
+ readonly internalType: "bytes32";
292
+ }, {
293
+ readonly name: "size";
294
+ readonly type: "uint32";
295
+ readonly indexed: false;
296
+ readonly internalType: "uint32";
297
+ }];
298
+ readonly anonymous: false;
299
+ }, {
300
+ readonly type: "event";
301
+ readonly name: "Upgraded";
302
+ readonly inputs: readonly [{
303
+ readonly name: "implementation";
304
+ readonly type: "address";
305
+ readonly indexed: true;
306
+ readonly internalType: "address";
307
+ }];
308
+ readonly anonymous: false;
309
+ }, {
310
+ readonly type: "error";
311
+ readonly name: "AddressEmptyCode";
312
+ readonly inputs: readonly [{
313
+ readonly name: "target";
314
+ readonly type: "address";
315
+ readonly internalType: "address";
316
+ }];
317
+ }, {
318
+ readonly type: "error";
319
+ readonly name: "BadSignature";
320
+ readonly inputs: readonly [];
321
+ }, {
322
+ readonly type: "error";
323
+ readonly name: "BeaconUnset";
324
+ readonly inputs: readonly [];
325
+ }, {
326
+ readonly type: "error";
327
+ readonly name: "ERC1967InvalidImplementation";
328
+ readonly inputs: readonly [{
329
+ readonly name: "implementation";
330
+ readonly type: "address";
331
+ readonly internalType: "address";
332
+ }];
333
+ }, {
334
+ readonly type: "error";
335
+ readonly name: "ERC1967NonPayable";
336
+ readonly inputs: readonly [];
337
+ }, {
338
+ readonly type: "error";
339
+ readonly name: "Expired";
340
+ readonly inputs: readonly [{
341
+ readonly name: "deadline";
342
+ readonly type: "uint64";
343
+ readonly internalType: "uint64";
344
+ }, {
345
+ readonly name: "nowTs";
346
+ readonly type: "uint64";
347
+ readonly internalType: "uint64";
348
+ }];
349
+ }, {
350
+ readonly type: "error";
351
+ readonly name: "FailedCall";
352
+ readonly inputs: readonly [];
353
+ }, {
354
+ readonly type: "error";
355
+ readonly name: "HashToCurveExhausted";
356
+ readonly inputs: readonly [];
357
+ }, {
358
+ readonly type: "error";
359
+ readonly name: "InvalidInitialization";
360
+ readonly inputs: readonly [];
361
+ }, {
362
+ readonly type: "error";
363
+ readonly name: "InvalidSigLength";
364
+ readonly inputs: readonly [{
365
+ readonly name: "got";
366
+ readonly type: "uint256";
367
+ readonly internalType: "uint256";
368
+ }, {
369
+ readonly name: "want";
370
+ readonly type: "uint256";
371
+ readonly internalType: "uint256";
372
+ }];
373
+ }, {
374
+ readonly type: "error";
375
+ readonly name: "NotInitializing";
376
+ readonly inputs: readonly [];
377
+ }, {
378
+ readonly type: "error";
379
+ readonly name: "OwnableInvalidOwner";
380
+ readonly inputs: readonly [{
381
+ readonly name: "owner";
382
+ readonly type: "address";
383
+ readonly internalType: "address";
384
+ }];
385
+ }, {
386
+ readonly type: "error";
387
+ readonly name: "OwnableUnauthorizedAccount";
388
+ readonly inputs: readonly [{
389
+ readonly name: "account";
390
+ readonly type: "address";
391
+ readonly internalType: "address";
392
+ }];
393
+ }, {
394
+ readonly type: "error";
395
+ readonly name: "OwnershipRenounceDisabled";
396
+ readonly inputs: readonly [];
397
+ }, {
398
+ readonly type: "error";
399
+ readonly name: "PrecompileFailed";
400
+ readonly inputs: readonly [{
401
+ readonly name: "precompile";
402
+ readonly type: "address";
403
+ readonly internalType: "address";
404
+ }];
405
+ }, {
406
+ readonly type: "error";
407
+ readonly name: "StaleEpoch";
408
+ readonly inputs: readonly [{
409
+ readonly name: "got";
410
+ readonly type: "uint64";
411
+ readonly internalType: "uint64";
412
+ }, {
413
+ readonly name: "last";
414
+ readonly type: "uint64";
415
+ readonly internalType: "uint64";
416
+ }];
417
+ }, {
418
+ readonly type: "error";
419
+ readonly name: "UUPSUnauthorizedCallContext";
420
+ readonly inputs: readonly [];
421
+ }, {
422
+ readonly type: "error";
423
+ readonly name: "UUPSUnsupportedProxiableUUID";
424
+ readonly inputs: readonly [{
425
+ readonly name: "slot";
426
+ readonly type: "bytes32";
427
+ readonly internalType: "bytes32";
428
+ }];
429
+ }, {
430
+ readonly type: "error";
431
+ readonly name: "ZeroAddress";
432
+ readonly inputs: readonly [];
433
+ }, {
434
+ readonly type: "error";
435
+ readonly name: "ZeroRoot";
436
+ readonly inputs: readonly [];
437
+ }, {
438
+ readonly type: "error";
439
+ readonly name: "ZeroSize";
440
+ readonly inputs: readonly [];
441
+ }];