@t3foundry/tasra-sdk 0.3.1-next.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/CHANGELOG.md +1067 -28
  2. package/README.md +15 -0
  3. package/dist/app/approvals.d.ts +66 -4
  4. package/dist/app/approvals.js +153 -16
  5. package/dist/app/authorization.d.ts +1 -1
  6. package/dist/app/authorization.js +1 -1
  7. package/dist/app/browser.d.ts +63 -0
  8. package/dist/app/browser.js +242 -0
  9. package/dist/app/client.d.ts +114 -13
  10. package/dist/app/client.js +302 -76
  11. package/dist/app/identity.js +21 -9
  12. package/dist/app/index.d.ts +28 -3
  13. package/dist/app/index.js +16 -1
  14. package/dist/app/memory-store.d.ts +7 -0
  15. package/dist/app/memory-store.js +55 -0
  16. package/dist/app/node.d.ts +34 -6
  17. package/dist/app/node.js +387 -64
  18. package/dist/app/paid-allowance.d.ts +325 -0
  19. package/dist/app/paid-allowance.js +1290 -0
  20. package/dist/app/paid-approval.d.ts +122 -0
  21. package/dist/app/paid-approval.js +379 -0
  22. package/dist/app/paid-journal.d.ts +51 -0
  23. package/dist/app/paid-journal.js +117 -0
  24. package/dist/app/paid-keys.d.ts +12 -0
  25. package/dist/app/paid-keys.js +20 -0
  26. package/dist/app/paid-operation.d.ts +821 -0
  27. package/dist/app/paid-operation.js +1720 -0
  28. package/dist/app/paid-reservation.d.ts +157 -0
  29. package/dist/app/paid-reservation.js +323 -0
  30. package/dist/app/paid-session.d.ts +147 -0
  31. package/dist/app/paid-session.js +578 -0
  32. package/dist/app/payer-queue.d.ts +11 -0
  33. package/dist/app/payer-queue.js +27 -0
  34. package/dist/app/policy-bootstrap.d.ts +342 -0
  35. package/dist/app/policy-bootstrap.js +365 -0
  36. package/dist/app/policy-operation.d.ts +47 -0
  37. package/dist/app/policy-operation.js +101 -0
  38. package/dist/app/ready-slot.d.ts +12 -0
  39. package/dist/app/ready-slot.js +5 -2
  40. package/dist/app/rotation-lock.d.ts +38 -0
  41. package/dist/app/rotation-lock.js +42 -0
  42. package/dist/app/session-decrypt.d.ts +135 -0
  43. package/dist/app/session-decrypt.js +335 -0
  44. package/dist/app/session-grants.d.ts +349 -0
  45. package/dist/app/session-grants.js +811 -0
  46. package/dist/app/signing-intents.d.ts +78 -0
  47. package/dist/app/signing-intents.js +95 -0
  48. package/dist/app/store-commit.d.ts +63 -0
  49. package/dist/app/store-commit.js +126 -0
  50. package/dist/app/store-errors.d.ts +8 -0
  51. package/dist/app/store-errors.js +11 -0
  52. package/dist/app/tasra-client.d.ts +2 -0
  53. package/dist/app/tasra-client.js +1 -1
  54. package/dist/app/wallet.js +4 -1
  55. package/dist/auth/holderProof.d.ts +3 -0
  56. package/dist/auth/holderProof.js +8 -7
  57. package/dist/auth/verifier.d.ts +4 -2
  58. package/dist/auth/verifier.js +5 -2
  59. package/dist/chain/abis/index.d.ts +6178 -4101
  60. package/dist/chain/abis/index.js +3 -0
  61. package/dist/chain/abis/keyRegistry.d.ts +256 -0
  62. package/dist/chain/abis/keyRegistry.js +333 -0
  63. package/dist/chain/abis/prepaidFaultOracle.d.ts +321 -0
  64. package/dist/chain/abis/prepaidFaultOracle.js +413 -0
  65. package/dist/chain/abis/settlement.d.ts +2203 -703
  66. package/dist/chain/abis/settlement.js +2685 -764
  67. package/dist/chain/allowance.d.ts +358 -0
  68. package/dist/chain/allowance.js +800 -0
  69. package/dist/chain/billing.d.ts +85 -0
  70. package/dist/chain/billing.js +197 -0
  71. package/dist/chain/chainId.d.ts +13 -0
  72. package/dist/chain/chainId.js +26 -0
  73. package/dist/chain/client.d.ts +15 -1
  74. package/dist/chain/client.js +57 -1
  75. package/dist/chain/commitmentRecovery.d.ts +51 -0
  76. package/dist/chain/commitmentRecovery.js +38 -0
  77. package/dist/chain/committeeClient.d.ts +17 -10
  78. package/dist/chain/committeeClient.js +64 -16
  79. package/dist/chain/committeeDraw.d.ts +12 -0
  80. package/dist/chain/committeeDraw.js +56 -0
  81. package/dist/chain/custodyHealth.d.ts +212 -0
  82. package/dist/chain/custodyHealth.js +365 -0
  83. package/dist/chain/deployments.js +2 -0
  84. package/dist/chain/events.js +2 -0
  85. package/dist/chain/headFollower.d.ts +77 -0
  86. package/dist/chain/headFollower.js +219 -0
  87. package/dist/chain/headPrefetch.d.ts +23 -0
  88. package/dist/chain/headPrefetch.js +67 -0
  89. package/dist/chain/index.d.ts +50 -8
  90. package/dist/chain/index.js +28 -3
  91. package/dist/chain/keeperExecution.d.ts +44 -0
  92. package/dist/chain/keeperExecution.js +127 -0
  93. package/dist/chain/keeperRecovery.d.ts +78 -0
  94. package/dist/chain/keeperRecovery.js +91 -0
  95. package/dist/chain/node.d.ts +24 -1
  96. package/dist/chain/node.js +88 -43
  97. package/dist/chain/offchain.d.ts +2 -0
  98. package/dist/chain/paidAgentTransport.d.ts +38 -0
  99. package/dist/chain/paidAgentTransport.js +1 -0
  100. package/dist/chain/paidEpoch.d.ts +66 -0
  101. package/dist/chain/paidEpoch.js +139 -0
  102. package/dist/chain/paidPacing.d.ts +81 -0
  103. package/dist/chain/paidPacing.js +136 -0
  104. package/dist/chain/pinnedReads.d.ts +49 -0
  105. package/dist/chain/pinnedReads.js +218 -0
  106. package/dist/chain/prepaid.d.ts +383 -0
  107. package/dist/chain/prepaid.js +1046 -0
  108. package/dist/chain/prepaidEscape.d.ts +274 -0
  109. package/dist/chain/prepaidEscape.js +432 -0
  110. package/dist/chain/prepaidFault.d.ts +94 -0
  111. package/dist/chain/prepaidFault.js +148 -0
  112. package/dist/chain/receipt.d.ts +24 -0
  113. package/dist/chain/receipt.js +82 -0
  114. package/dist/chain/registeredAgent.d.ts +68 -3
  115. package/dist/chain/registeredAgent.js +143 -42
  116. package/dist/chain/registeredOperation.d.ts +10 -1
  117. package/dist/chain/registeredOperation.js +18 -3
  118. package/dist/chain/registeredPaidAgent.d.ts +254 -0
  119. package/dist/chain/registeredPaidAgent.js +889 -0
  120. package/dist/chain/registeredRelay.d.ts +31 -1
  121. package/dist/chain/registeredRelay.js +164 -43
  122. package/dist/chain/relayVoucher.d.ts +64 -0
  123. package/dist/chain/relayVoucher.js +69 -0
  124. package/dist/chain/reservation.d.ts +239 -0
  125. package/dist/chain/reservation.js +746 -0
  126. package/dist/chain/reshareRoster.d.ts +64 -0
  127. package/dist/chain/reshareRoster.js +85 -0
  128. package/dist/chain/revertReason.d.ts +8 -0
  129. package/dist/chain/revertReason.js +2 -1
  130. package/dist/chain/rotationLock.d.ts +130 -0
  131. package/dist/chain/rotationLock.js +168 -0
  132. package/dist/chain/serviceRequestPolicy.d.ts +47 -0
  133. package/dist/chain/serviceRequestPolicy.js +86 -0
  134. package/dist/chain/services.d.ts +7 -0
  135. package/dist/chain/services.js +44 -4
  136. package/dist/chain/slotClient.js +11 -2
  137. package/dist/chain/slotHandoff.d.ts +81 -0
  138. package/dist/chain/slotHandoff.js +166 -0
  139. package/dist/chain/slotSeed.d.ts +47 -5
  140. package/dist/chain/slotSeed.js +173 -42
  141. package/dist/chain/verifierSnapshot.d.ts +36 -0
  142. package/dist/chain/verifierSnapshot.js +197 -0
  143. package/dist/chain/write.d.ts +111 -21
  144. package/dist/chain/write.js +378 -146
  145. package/dist/committee/blsSharing.d.ts +53 -0
  146. package/dist/committee/blsSharing.js +90 -0
  147. package/dist/committee/client.d.ts +62 -23
  148. package/dist/committee/client.js +288 -72
  149. package/dist/committee/dual-operation.d.ts +165 -0
  150. package/dist/committee/dual-operation.js +229 -0
  151. package/dist/committee/dual-sign.d.ts +26 -1
  152. package/dist/committee/dual-sign.js +85 -7
  153. package/dist/committee/ecdsa.d.ts +38 -0
  154. package/dist/committee/ecdsa.js +87 -15
  155. package/dist/committee/evidence.d.ts +30 -0
  156. package/dist/committee/evidence.js +65 -0
  157. package/dist/committee/execution.d.ts +414 -0
  158. package/dist/committee/execution.js +446 -0
  159. package/dist/committee/extraction.js +33 -26
  160. package/dist/committee/index.d.ts +30 -7
  161. package/dist/committee/index.js +18 -6
  162. package/dist/committee/keeperExecution.d.ts +37 -0
  163. package/dist/committee/keeperExecution.js +141 -0
  164. package/dist/committee/oauth.d.ts +14 -4
  165. package/dist/committee/oauth.js +17 -5
  166. package/dist/committee/payment.d.ts +369 -0
  167. package/dist/committee/payment.js +339 -0
  168. package/dist/committee/recovery.d.ts +136 -0
  169. package/dist/committee/recovery.js +204 -0
  170. package/dist/committee/recoveryJson.d.ts +2 -0
  171. package/dist/committee/recoveryJson.js +87 -0
  172. package/dist/committee/request.d.ts +63 -27
  173. package/dist/committee/request.js +77 -66
  174. package/dist/committee/session-grant.d.ts +320 -0
  175. package/dist/committee/session-grant.js +397 -0
  176. package/dist/committee/status-refresh.d.ts +257 -0
  177. package/dist/committee/status-refresh.js +619 -0
  178. package/dist/committee/token.d.ts +163 -15
  179. package/dist/committee/token.js +247 -10
  180. package/dist/crypto/bn254.d.ts +70 -0
  181. package/dist/crypto/bn254.js +222 -0
  182. package/dist/crypto/ibe.d.ts +32 -0
  183. package/dist/crypto/ibe.js +56 -8
  184. package/dist/crypto/index.d.ts +1 -1
  185. package/dist/crypto/index.js +1 -1
  186. package/dist/crypto/kem.d.ts +31 -0
  187. package/dist/crypto/kem.js +113 -7
  188. package/dist/crypto/recipient.d.ts +75 -0
  189. package/dist/crypto/recipient.js +107 -0
  190. package/dist/decryption/client.d.ts +10 -16
  191. package/dist/decryption/client.js +8 -76
  192. package/dist/decryption/index.d.ts +2 -0
  193. package/dist/decryption/index.js +2 -0
  194. package/dist/decryption/sealed.d.ts +72 -0
  195. package/dist/decryption/sealed.js +147 -0
  196. package/dist/decryption/session.d.ts +115 -0
  197. package/dist/decryption/session.js +358 -0
  198. package/dist/errors.d.ts +406 -1
  199. package/dist/errors.js +400 -5
  200. package/dist/index.d.ts +9 -2
  201. package/dist/index.js +6 -1
  202. package/dist/internal/bounded.d.ts +66 -0
  203. package/dist/internal/bounded.js +126 -0
  204. package/dist/internal/network.d.ts +4 -0
  205. package/dist/internal/network.js +40 -0
  206. package/dist/internal/retryAfter.d.ts +8 -0
  207. package/dist/internal/retryAfter.js +28 -0
  208. package/dist/internal/sleep.d.ts +6 -0
  209. package/dist/internal/sleep.js +15 -0
  210. package/dist/internal/typedData.d.ts +13 -0
  211. package/dist/internal/typedData.js +77 -0
  212. package/dist/internal/viemErrors.d.ts +26 -0
  213. package/dist/internal/viemErrors.js +49 -0
  214. package/dist/oid4vp/binding.d.ts +27 -1
  215. package/dist/oid4vp/binding.js +36 -1
  216. package/dist/oid4vp/jose.d.ts +4 -2
  217. package/dist/oid4vp/jose.js +39 -7
  218. package/dist/oid4vp/request-object.d.ts +61 -4
  219. package/dist/oid4vp/request-object.js +140 -5
  220. package/dist/oid4vp/verifier-agent.d.ts +18 -8
  221. package/dist/oid4vp/verifier-agent.js +48 -6
  222. package/dist/oid4vp/wallet.d.ts +2 -4
  223. package/dist/oid4vp/wallet.js +1 -0
  224. package/dist/retry.d.ts +78 -0
  225. package/dist/retry.js +137 -0
  226. package/dist/signing/frost.d.ts +1 -1
  227. package/dist/verifier-agent/index.d.ts +41 -5
  228. package/dist/verifier-agent/index.js +124 -9
  229. package/dist/verifier-agent/payment.d.ts +7 -0
  230. package/dist/verifier-agent/payment.js +17 -0
  231. package/docs/api.md +8 -2
  232. package/docs/application-api.md +25 -2
  233. package/docs/chain.md +155 -9
  234. package/docs/consumer-migrations.md +61 -0
  235. package/docs/encrypted-notes.md +3 -2
  236. package/docs/encryption.md +4 -2
  237. package/docs/errors.md +14 -1
  238. package/docs/flows.md +2 -2
  239. package/docs/funding.md +902 -0
  240. package/docs/native-approvals.md +63 -0
  241. package/docs/reference/README.md +9 -8
  242. package/docs/reference/app-browser.md +232 -0
  243. package/docs/reference/app-node.md +38 -8
  244. package/docs/reference/app.md +4621 -805
  245. package/docs/reference/chain-node.md +74 -16
  246. package/docs/reference/chain.md +6740 -1592
  247. package/docs/reference/committee.md +5630 -987
  248. package/docs/reference/main.md +1439 -140
  249. package/docs/reference/oid4vp.md +297 -144
  250. package/docs/reference/verifier-agent.md +77 -35
  251. package/docs/signing.md +6 -0
  252. package/examples/encrypted-notes.ts +21 -6
  253. package/examples/getting-started.ts +2 -7
  254. package/examples/live-config.ts +24 -17
  255. package/package.json +17 -5
package/dist/errors.d.ts CHANGED
@@ -11,12 +11,56 @@ export declare class TasraError extends Error {
11
11
  cause?: unknown;
12
12
  });
13
13
  }
14
+ /**
15
+ * A new payment cannot be prepared with the slot's available TASRA. Reserved
16
+ * credit belongs to earlier jobs and is not available for a new reservation.
17
+ * Top up and read fresh funding before starting another payment; this error
18
+ * never authorizes resubmission of an uncertain transaction.
19
+ */
20
+ export declare class UnderfundedSlotError extends TasraError {
21
+ /** Slot whose new payment was refused. */
22
+ readonly slotId: string;
23
+ /** Unreserved TASRA base units, when observed during on-chain discovery. */
24
+ readonly availableTasraUnits?: bigint;
25
+ /** Accountant HTTP status, absent for a local funding observation. */
26
+ readonly status?: 402;
27
+ /** Accountant endpoint, when a reservation request returned HTTP 402. */
28
+ readonly url?: string;
29
+ constructor(args: {
30
+ slotId: string;
31
+ availableTasraUnits?: bigint;
32
+ status?: 402;
33
+ url?: string;
34
+ message?: string;
35
+ });
36
+ }
37
+ /**
38
+ * The transaction payer lacks native currency for the quoted reservation gas.
39
+ * Slot TASRA credit is a separate balance. Nothing was prepared or broadcast;
40
+ * this error never authorizes resubmission of an uncertain transaction.
41
+ */
42
+ export declare class UnderfundedGasPayerError extends TasraError {
43
+ /** Stable code distinguishing native gas from slot TASRA credit. */
44
+ readonly code: "underfunded-gas-payer";
45
+ /** Address that would pay the reservation transaction's gas. */
46
+ readonly payer: string;
47
+ /** Pending native balance, in the chain's smallest native unit. */
48
+ readonly availableNativeUnits: bigint;
49
+ /** Estimated gas multiplied by the actual transaction gas price. */
50
+ readonly requiredNativeUnits: bigint;
51
+ constructor(args: {
52
+ payer: string;
53
+ availableNativeUnits: bigint;
54
+ requiredNativeUnits: bigint;
55
+ });
56
+ }
14
57
  /**
15
58
  * A node or verifier answered with a non-2xx status. `body` is the response body,
16
59
  * truncated to 200 characters - enough to carry the service's own error text
17
60
  * without dumping a page of HTML into a log line.
18
61
  *
19
- * 5xx and 429 are marked retryable; other 4xx are not.
62
+ * 5xx, 429 and 425 are marked retryable; so is a 409, 410 or 422 that carries
63
+ * `Retry-After`. Other 4xx are not. `retryAfterMs` is the service-requested wait.
20
64
  */
21
65
  export declare class TasraHttpError extends TasraError {
22
66
  /** HTTP status code returned by the service. */
@@ -25,12 +69,15 @@ export declare class TasraHttpError extends TasraError {
25
69
  readonly url: string;
26
70
  /** Response body retained as diagnostic information. */
27
71
  readonly body: string;
72
+ /** Service-requested wait from `Retry-After`, in ms, when one was sent. */
73
+ readonly retryAfterMs?: number;
28
74
  constructor(args: {
29
75
  status: number;
30
76
  url: string;
31
77
  body?: string;
32
78
  message?: string;
33
79
  retryable?: boolean;
80
+ retryAfterMs?: number;
34
81
  });
35
82
  }
36
83
  /**
@@ -45,6 +92,364 @@ export declare class AuthDeniedError extends TasraHttpError {
45
92
  message?: string;
46
93
  });
47
94
  }
95
+ /**
96
+ * A keeper refused a committee grant because its verifiers' revocation-status attestations
97
+ * (`keykeeper/committee-status-attestation/v1`) are missing (`revocation_status_missing`) or no
98
+ * longer fresh for a quorum (`revocation_status_stale`). The credential was NOT judged revoked:
99
+ * the grant outlived the 60 s revocation bound (or came from a path that does not carry the
100
+ * attestations).
101
+ *
102
+ * NOT retryable, and NOT proof that no keeper worked: another keeper of the committee may already
103
+ * have started the operation before this one re-checked the grant, and a gateway can blur the
104
+ * outcome. Never resend this grant, and never treat this error alone as authority to retry, refund
105
+ * or clear a paid operation (its journal keeps the execution as uncertain until original-stage
106
+ * evidence settles it). For an UNPAID operation the remedy is a new presentation and a new grant.
107
+ * Not an {@link AuthDeniedError}, and {@link isAuthDenied} returns false for it.
108
+ */
109
+ export declare class RevocationStatusError extends TasraHttpError {
110
+ /** The keeper's stable refusal code. */
111
+ readonly code: 'revocation_status_stale' | 'revocation_status_missing';
112
+ /** Always true: a fresh grant needs a new presentation, never this token. */
113
+ readonly presentAgain: true;
114
+ constructor(args: {
115
+ status: number;
116
+ url: string;
117
+ body?: string;
118
+ message?: string;
119
+ code: 'revocation_status_stale' | 'revocation_status_missing';
120
+ retryAfterMs?: number;
121
+ });
122
+ }
123
+ /** Stable code of a local revocation-status preflight refusal. */
124
+ export type RevocationStatusPreflightCode = 'revocation_status_missing' | 'revocation_status_stale' | 'revocation_status_invalid' | 'revocation_status_refused';
125
+ /**
126
+ * A committee grant was refused LOCALLY, before any keeper call, by the same rule a keeper in
127
+ * production posture applies: its revocation-status attestations
128
+ * (`keykeeper/committee-status-attestation/v1`) are missing (`revocation_status_missing`: absent,
129
+ * `null` or empty), fewer than a quorum are valid and fresh (`revocation_status_stale`), or the
130
+ * list is malformed, duplicated or carries a bad signature from a counted verifier
131
+ * (`revocation_status_invalid`), or - for a journaled paid operation - an explicit status refresh
132
+ * answered `status_refresh_refused` (`revocation_status_refused`: a verifier attests the holder's
133
+ * credential status is refused NOW; the grant is refused however fresh its attestations still are,
134
+ * until a later refresh succeeds).
135
+ *
136
+ * Unlike {@link RevocationStatusError} (a keeper's reply after a send), nothing was sent: a paid
137
+ * operation refused here stays in its pre-execution journal phase. Not retryable with this grant
138
+ * and never a reason to start a new session or payment automatically: present again for a fresh
139
+ * grant. `allowMissingStatusAttestations` (migration window only) waives `revocation_status_missing`
140
+ * and nothing else.
141
+ */
142
+ export declare class RevocationStatusPreflightError extends TasraError {
143
+ /** Stable refusal code. */
144
+ readonly code: RevocationStatusPreflightCode;
145
+ /** Always false: no keeper received the grant. */
146
+ readonly sent: false;
147
+ /** Always true: a fresh grant needs a new presentation. */
148
+ readonly presentAgain: true;
149
+ /** Paid operation identity, when the refusal stopped a journaled paid operation. */
150
+ readonly requestId?: string;
151
+ constructor(args: {
152
+ code: RevocationStatusPreflightCode;
153
+ message: string;
154
+ requestId?: string;
155
+ cause?: unknown;
156
+ });
157
+ }
158
+ /**
159
+ * True when a grant was refused locally for missing, stale or invalid revocation-status
160
+ * attestations before anything was sent.
161
+ *
162
+ * @param e - Caught value to classify.
163
+ */
164
+ export declare function isRevocationStatusPreflightRefusal(e: unknown): e is RevocationStatusPreflightError;
165
+ /**
166
+ * The stable revocation-status refusal code in a keeper's 403 body, if any.
167
+ *
168
+ * @param status - HTTP status code.
169
+ * @param body - Complete (untruncated) response body.
170
+ */
171
+ export declare function revocationStatusCode(status: number, body: string): RevocationStatusError['code'] | undefined;
172
+ /**
173
+ * True when a keeper refused a grant only for stale or missing revocation-status attestations:
174
+ * present the credential again for a fresh grant and repeat the call.
175
+ *
176
+ * @param e - Caught value to classify.
177
+ */
178
+ export declare function isRevocationStatusRefusal(e: unknown): e is RevocationStatusError;
179
+ /**
180
+ * Stable code of a status-refresh failure (`keykeeper/committee-status-refresh/v1`).
181
+ *
182
+ * Server codes (verifier `POST /v1/committee/status-refresh`, or the verifier-agent relay
183
+ * `POST /v1/sessions/:id/status-refresh`):
184
+ * - `status_refresh_unknown` (404): the verifier holds no issuance record for this token.
185
+ * - `status_refresh_unavailable` (409): a legacy record without refresh facts; never clean.
186
+ * - `status_refresh_replayed` (409): the proof's `seq` is not above the verifier's last one.
187
+ * - `status_refresh_context_changed` (409): the verifier's roster index or the slot rule moved.
188
+ * - `status_refresh_expired` (410): a hard cap of the grant (minus the 5 s keeper skew) passed.
189
+ * - `status_refresh_unauthenticated` (403, or 401 from the relay): the proof does not verify
190
+ * under the principal recorded at issuance, or is not fresh.
191
+ * - `status_refresh_refused` (403): a status reference is revoked or no longer acceptable.
192
+ * - `status_refresh_unavailable_status` (503): a status list could not be read.
193
+ * - `status_refresh_quorum_unmet` (503 from the relay, or local): fewer than the token's quorum of
194
+ * original signers returned a valid, fresh, capped attestation.
195
+ * - `status_refresh_rate_limited` (429): per-token interval/cap or principal quota; see `retryAfterMs`.
196
+ *
197
+ * Client codes:
198
+ * - `status_refresh_invalid_response`: a success reply that is malformed, unsigned, forged, from a
199
+ * signer that did not verify the original token, or past a cap. Never trusted.
200
+ * - `status_refresh_unreachable`: no HTTP answer (the verifier may still have consumed the `seq`).
201
+ * - `status_refresh_http`: any other HTTP status, or a refusal without a recognised code.
202
+ */
203
+ export type StatusRefreshCode = 'status_refresh_unknown' | 'status_refresh_unavailable' | 'status_refresh_replayed' | 'status_refresh_context_changed' | 'status_refresh_expired' | 'status_refresh_unauthenticated' | 'status_refresh_refused' | 'status_refresh_unavailable_status' | 'status_refresh_quorum_unmet' | 'status_refresh_rate_limited' | 'status_refresh_invalid_response' | 'status_refresh_unreachable' | 'status_refresh_http';
204
+ /** Why one verifier (or the relay) did not contribute a fresh attestation. */
205
+ export interface StatusRefreshFailure {
206
+ /** Verifier registry index, when the failure belongs to one verifier. */
207
+ verifierIndex?: number;
208
+ /** Stable code. */
209
+ code: StatusRefreshCode;
210
+ /** HTTP status, when an answer arrived. */
211
+ httpStatus?: number;
212
+ /** Service-requested wait (`Retry-After`), in ms. */
213
+ retryAfterMs?: number;
214
+ /** Safe-to-log detail (no secrets, at most 200 characters of a service message). */
215
+ message: string;
216
+ }
217
+ /**
218
+ * A status refresh for an already-issued committee grant produced no fresh quorum.
219
+ *
220
+ * It changes nothing at any keeper and is NEVER evidence about keeper work: for a paid operation
221
+ * the journal phase is unchanged (an `authorized` grant was not sent; an `executing` one stays
222
+ * uncertain). `retryable` is a coarse hint for 429/503/transport failures only; the SDK never
223
+ * retries a refresh automatically, and a new attempt always uses a new, journaled `seq`.
224
+ * `status_refresh_refused` means a credential status reference is revoked or no longer
225
+ * acceptable: present again (a new grant), never refresh this one.
226
+ */
227
+ export declare class StatusRefreshError extends TasraError {
228
+ /** Stable code (for a fan-out, the decisive one; see `reasons` for every verifier). */
229
+ readonly code: StatusRefreshCode;
230
+ /** HTTP status of the decisive answer, when there was one. */
231
+ readonly httpStatus?: number;
232
+ /** Longest service-requested wait among the failures, in ms. */
233
+ readonly retryAfterMs?: number;
234
+ /** Per-verifier (or relay) failures. */
235
+ readonly reasons: readonly StatusRefreshFailure[];
236
+ /** Paid operation identity, when the refresh belonged to a journaled paid operation. */
237
+ readonly requestId?: string;
238
+ /** The journaled sequence number the failed proof used (never reused). */
239
+ readonly seq?: number;
240
+ constructor(args: {
241
+ code: StatusRefreshCode;
242
+ message: string;
243
+ httpStatus?: number;
244
+ retryAfterMs?: number;
245
+ reasons?: readonly StatusRefreshFailure[];
246
+ requestId?: string;
247
+ seq?: number;
248
+ retryable?: boolean;
249
+ cause?: unknown;
250
+ });
251
+ }
252
+ /**
253
+ * True for a {@link StatusRefreshError}.
254
+ *
255
+ * @param e - Caught value to classify.
256
+ */
257
+ export declare function isStatusRefreshError(e: unknown): e is StatusRefreshError;
258
+ /**
259
+ * Stable code of a paid backoff refusal (see {@link PaidBackoffError}).
260
+ * - `deadline_exceeded`: waiting the server's hint (or the client's own backoff) and then allowing
261
+ * one attempt would reach the operation deadline; nothing was slept or sent.
262
+ * - `server_wait_too_long`: the server asked for longer than the client ever waits (120 s); the
263
+ * hint is never shortened, so nothing was slept or sent.
264
+ * - `no_time_to_send`: re-read immediately before a send (for example after an overrunning sleep),
265
+ * too little time was left before the deadline; that send did not happen.
266
+ * - `attempts_exhausted`: the attempt ceiling was reached inside the deadline.
267
+ */
268
+ export type PaidBackoffCode = 'deadline_exceeded' | 'server_wait_too_long' | 'no_time_to_send' | 'attempts_exhausted';
269
+ /**
270
+ * A paid request that the service definitely refused before acting on it (HTTP 429 or 503) could
271
+ * not be repeated inside its existing deadline. Only requests that are safe to repeat are paced: the
272
+ * paid verifier-agent reads, the byte-identical retained approval, the presentation continuation (429
273
+ * only) and the accountant reservation `prepare`. The deadline is never extended and a valid
274
+ * `Retry-After` / `x-ratelimit-after` hint is never shortened.
275
+ *
276
+ * Nothing was sent after the refusal this error reports. A retained approval keeps its durable
277
+ * permit, so a later resume may resend the identical body; never start the paid operation again.
278
+ */
279
+ export declare class PaidBackoffError extends TasraError {
280
+ /** Stable reason. */
281
+ readonly code: PaidBackoffCode;
282
+ /** Route that was refused, without identifiers (for example `GET /v1/sessions/{id}`). */
283
+ readonly route: string;
284
+ /** Last refusal status, when one was answered (absent for `no_time_to_send`). */
285
+ readonly httpStatus?: number;
286
+ /** Server-requested wait (strict integer seconds), in ms, when it sent a valid one. */
287
+ readonly retryAfterMs?: number;
288
+ /** Time left before the deadline when the decision was made, in ms. */
289
+ readonly remainingMs?: number;
290
+ /** Time one attempt needs (or wait + attempt), in ms. */
291
+ readonly neededMs?: number;
292
+ /** Refusals waited out before this decision. */
293
+ readonly attempts: number;
294
+ constructor(args: {
295
+ code: PaidBackoffCode;
296
+ route: string;
297
+ httpStatus?: number;
298
+ retryAfterMs?: number;
299
+ remainingMs?: number;
300
+ neededMs?: number;
301
+ attempts: number;
302
+ });
303
+ }
304
+ /**
305
+ * True for a {@link PaidBackoffError}.
306
+ *
307
+ * @param e - Caught value to classify.
308
+ */
309
+ export declare function isPaidBackoffError(e: unknown): e is PaidBackoffError;
310
+ /**
311
+ * Why a retained paid approval was not (re)sent (see {@link PaidApprovalUnresolvedError}).
312
+ * - `claim_lost`: another caller already claimed this send generation.
313
+ * - `generation_moved`: the durable permit is no longer for this generation.
314
+ * - `outcome_unknown`: a send had no definite answer (transport error, timeout, abort) or a
315
+ * generation is recorded in flight; it is never resent.
316
+ * - `no_permit`: there is no durable permit (crash before it was written) or the agent no longer
317
+ * shows the delivery pending.
318
+ * - `legacy_state`: the record or permit was written in an older or unknown format.
319
+ * - `conflict`: the agent answered 409 after a busy refusal and its delivery state is not accepted.
320
+ */
321
+ export type PaidApprovalUnresolvedReason = 'claim_lost' | 'generation_moved' | 'outcome_unknown' | 'no_permit' | 'legacy_state' | 'conflict';
322
+ /**
323
+ * A retained paid approval's outcome is unresolved, so the SDK will not send it (again).
324
+ *
325
+ * Code `approval_outcome_unresolved`. An approval is resent only as the byte-identical retained body
326
+ * and only under a durable, generation-bound, one-use permit that an exclusive claim consumes before
327
+ * every send. Anything else (a lost claim, a moved generation, an unknown outcome, a legacy record)
328
+ * lands here. Not retryable: reconcile the delivery by reading it, never by resending or re-signing.
329
+ */
330
+ export declare class PaidApprovalUnresolvedError extends TasraError {
331
+ /** Stable code. */
332
+ readonly code: "approval_outcome_unresolved";
333
+ /** Why nothing was sent. */
334
+ readonly reason: PaidApprovalUnresolvedReason;
335
+ /** Agent delivery (proposal) identity, when known. */
336
+ readonly proposalId?: string;
337
+ /** Send generation concerned, when known. */
338
+ readonly generation?: number;
339
+ /** Application-store journal entry of the approval, when known. */
340
+ readonly key?: string;
341
+ constructor(args: {
342
+ reason: PaidApprovalUnresolvedReason;
343
+ proposalId?: string;
344
+ generation?: number;
345
+ key?: string;
346
+ message?: string;
347
+ cause?: unknown;
348
+ });
349
+ }
350
+ /**
351
+ * True for a {@link PaidApprovalUnresolvedError}.
352
+ *
353
+ * @param e - Caught value to classify.
354
+ */
355
+ export declare function isPaidApprovalUnresolved(e: unknown): e is PaidApprovalUnresolvedError;
356
+ /**
357
+ * The accountant refused a reservation `prepare` with its per-creator reservation quota (HTTP 429
358
+ * with a valid `Retry-After` / `x-ratelimit-after`), and the identical prepare could not be repeated
359
+ * inside its window (at most 150 s and half of the payment's remaining signed lifetime).
360
+ *
361
+ * Code `reservation_quota`. Nothing was prepared, signed or put on chain: no reservation transaction
362
+ * exists for this attempt. `reason` says why waiting stopped; `retryAfterMs` is the last hint.
363
+ */
364
+ export declare class PaidReservationQuotaError extends TasraError {
365
+ /** Stable code. */
366
+ readonly code: "reservation_quota";
367
+ /** Why the prepare was not repeated. */
368
+ readonly reason: PaidBackoffCode;
369
+ /** Accountant endpoint that refused. */
370
+ readonly url: string;
371
+ /** The accountant's last requested wait, in ms. */
372
+ readonly retryAfterMs: number;
373
+ constructor(args: {
374
+ reason: PaidBackoffCode;
375
+ url: string;
376
+ retryAfterMs: number;
377
+ cause?: unknown;
378
+ });
379
+ }
380
+ /**
381
+ * Stable code of a prepaid timeout-escape refusal (see {@link PrepaidEscapeError}).
382
+ * - `escape_disabled`: the Settlement escape delay is zero (an upgraded deployment before governance
383
+ * enabled it); contract error `EscapeDisabled()`.
384
+ * - `escape_not_open`: a request's escape opens later, at `opensAt`; contract error
385
+ * `EscapeNotOpen(requestId, opensAt)`.
386
+ * - `reservation_unavailable`: a request was never reserved, or is already complete (reconciled,
387
+ * settled or escaped); contract error `ReservationUnavailable(requestId)`.
388
+ * - `invalid_escape_delay`: contract error `InvalidEscapeDelay(delay)` (governance setter only).
389
+ * - `too_many_requests`: more than 64 requests in one call; contract error `TooManyCovered`.
390
+ * - `empty_request`: no request IDs; contract error `EmptyBundle()`.
391
+ * - `escape_unsupported`: the Settlement has no escape getters (a version before "3").
392
+ */
393
+ export type PrepaidEscapeCode = 'escape_disabled' | 'escape_not_open' | 'reservation_unavailable' | 'invalid_escape_delay' | 'too_many_requests' | 'empty_request' | 'escape_unsupported';
394
+ /**
395
+ * A prepaid timeout escape was refused before anything was sent for the refused call: by the local
396
+ * preflight (`local: true`, read at one canonical block) or by the contract's own simulation
397
+ * (`local: false`). Nothing about the refused call is journaled. In a multi-call escape, calls that
398
+ * already confirmed are in their journal (`confirmed` checkpoints) and stay final.
399
+ *
400
+ * Only `escape_not_open` is retryable: the same call succeeds once chain time reaches `opensAt`.
401
+ */
402
+ export declare class PrepaidEscapeError extends TasraError {
403
+ /** Stable code. */
404
+ readonly code: PrepaidEscapeCode;
405
+ /** Always false: no transaction was sent for the refused call. */
406
+ readonly sent: false;
407
+ /** True for a local preflight refusal, false for a decoded contract revert. */
408
+ readonly local: boolean;
409
+ /** Request the refusal names, when it names one. */
410
+ readonly requestId?: string;
411
+ /** When the named request's escape opens (`escape_not_open`). */
412
+ readonly opensAt?: Date;
413
+ /** Refused delay in seconds (`invalid_escape_delay`). */
414
+ readonly delaySeconds?: bigint;
415
+ constructor(args: {
416
+ code: PrepaidEscapeCode;
417
+ local: boolean;
418
+ requestId?: string;
419
+ opensAt?: Date;
420
+ delaySeconds?: bigint;
421
+ message?: string;
422
+ cause?: unknown;
423
+ });
424
+ }
425
+ /**
426
+ * True for a {@link PrepaidEscapeError}.
427
+ *
428
+ * @param e - Caught value to classify.
429
+ */
430
+ export declare function isPrepaidEscapeError(e: unknown): e is PrepaidEscapeError;
431
+ /**
432
+ * A prepaid escape transaction may have been broadcast and its outcome is not proven. Code
433
+ * `escape_uncertain`. Retain the prepared record and reconcile it by reading chain state
434
+ * (`reconcileEscape`); never send it again blindly. An escape cannot refund twice (a second one
435
+ * reverts `ReservationUnavailable`), but a blind resend still spends gas and can collide on the nonce.
436
+ */
437
+ export declare class PrepaidEscapeUncertainError extends TasraError {
438
+ /** Stable code. */
439
+ readonly code: "escape_uncertain";
440
+ /** Local journal key of the escape call. */
441
+ readonly escapeId: string;
442
+ /** Requests the call named. */
443
+ readonly requestIds: readonly string[];
444
+ /** Transaction hash when known; absence does not prove that nothing was sent. */
445
+ readonly transactionHash?: string;
446
+ constructor(args: {
447
+ escapeId: string;
448
+ requestIds: readonly string[];
449
+ transactionHash?: string;
450
+ cause?: unknown;
451
+ });
452
+ }
48
453
  /**
49
454
  * The request never got an HTTP answer - DNS failure, connection refused,
50
455
  * timeout, CORS. Retryable: the service may simply not be up yet.