@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.
- package/CHANGELOG.md +1067 -28
- package/README.md +15 -0
- package/dist/app/approvals.d.ts +66 -4
- package/dist/app/approvals.js +153 -16
- package/dist/app/authorization.d.ts +1 -1
- package/dist/app/authorization.js +1 -1
- package/dist/app/browser.d.ts +63 -0
- package/dist/app/browser.js +242 -0
- package/dist/app/client.d.ts +114 -13
- package/dist/app/client.js +302 -76
- package/dist/app/identity.js +21 -9
- package/dist/app/index.d.ts +28 -3
- package/dist/app/index.js +16 -1
- package/dist/app/memory-store.d.ts +7 -0
- package/dist/app/memory-store.js +55 -0
- package/dist/app/node.d.ts +34 -6
- package/dist/app/node.js +387 -64
- package/dist/app/paid-allowance.d.ts +325 -0
- package/dist/app/paid-allowance.js +1290 -0
- package/dist/app/paid-approval.d.ts +122 -0
- package/dist/app/paid-approval.js +379 -0
- package/dist/app/paid-journal.d.ts +51 -0
- package/dist/app/paid-journal.js +117 -0
- package/dist/app/paid-keys.d.ts +12 -0
- package/dist/app/paid-keys.js +20 -0
- package/dist/app/paid-operation.d.ts +821 -0
- package/dist/app/paid-operation.js +1720 -0
- package/dist/app/paid-reservation.d.ts +157 -0
- package/dist/app/paid-reservation.js +323 -0
- package/dist/app/paid-session.d.ts +147 -0
- package/dist/app/paid-session.js +578 -0
- package/dist/app/payer-queue.d.ts +11 -0
- package/dist/app/payer-queue.js +27 -0
- package/dist/app/policy-bootstrap.d.ts +342 -0
- package/dist/app/policy-bootstrap.js +365 -0
- package/dist/app/policy-operation.d.ts +47 -0
- package/dist/app/policy-operation.js +101 -0
- package/dist/app/ready-slot.d.ts +12 -0
- package/dist/app/ready-slot.js +5 -2
- package/dist/app/rotation-lock.d.ts +38 -0
- package/dist/app/rotation-lock.js +42 -0
- package/dist/app/session-decrypt.d.ts +135 -0
- package/dist/app/session-decrypt.js +335 -0
- package/dist/app/session-grants.d.ts +349 -0
- package/dist/app/session-grants.js +811 -0
- package/dist/app/signing-intents.d.ts +78 -0
- package/dist/app/signing-intents.js +95 -0
- package/dist/app/store-commit.d.ts +63 -0
- package/dist/app/store-commit.js +126 -0
- package/dist/app/store-errors.d.ts +8 -0
- package/dist/app/store-errors.js +11 -0
- package/dist/app/tasra-client.d.ts +2 -0
- package/dist/app/tasra-client.js +1 -1
- package/dist/app/wallet.js +4 -1
- package/dist/auth/holderProof.d.ts +3 -0
- package/dist/auth/holderProof.js +8 -7
- package/dist/auth/verifier.d.ts +4 -2
- package/dist/auth/verifier.js +5 -2
- package/dist/chain/abis/index.d.ts +6178 -4101
- package/dist/chain/abis/index.js +3 -0
- package/dist/chain/abis/keyRegistry.d.ts +256 -0
- package/dist/chain/abis/keyRegistry.js +333 -0
- package/dist/chain/abis/prepaidFaultOracle.d.ts +321 -0
- package/dist/chain/abis/prepaidFaultOracle.js +413 -0
- package/dist/chain/abis/settlement.d.ts +2203 -703
- package/dist/chain/abis/settlement.js +2685 -764
- package/dist/chain/allowance.d.ts +358 -0
- package/dist/chain/allowance.js +800 -0
- package/dist/chain/billing.d.ts +85 -0
- package/dist/chain/billing.js +197 -0
- package/dist/chain/chainId.d.ts +13 -0
- package/dist/chain/chainId.js +26 -0
- package/dist/chain/client.d.ts +15 -1
- package/dist/chain/client.js +57 -1
- package/dist/chain/commitmentRecovery.d.ts +51 -0
- package/dist/chain/commitmentRecovery.js +38 -0
- package/dist/chain/committeeClient.d.ts +17 -10
- package/dist/chain/committeeClient.js +64 -16
- package/dist/chain/committeeDraw.d.ts +12 -0
- package/dist/chain/committeeDraw.js +56 -0
- package/dist/chain/custodyHealth.d.ts +212 -0
- package/dist/chain/custodyHealth.js +365 -0
- package/dist/chain/deployments.js +2 -0
- package/dist/chain/events.js +2 -0
- package/dist/chain/headFollower.d.ts +77 -0
- package/dist/chain/headFollower.js +219 -0
- package/dist/chain/headPrefetch.d.ts +23 -0
- package/dist/chain/headPrefetch.js +67 -0
- package/dist/chain/index.d.ts +50 -8
- package/dist/chain/index.js +28 -3
- package/dist/chain/keeperExecution.d.ts +44 -0
- package/dist/chain/keeperExecution.js +127 -0
- package/dist/chain/keeperRecovery.d.ts +78 -0
- package/dist/chain/keeperRecovery.js +91 -0
- package/dist/chain/node.d.ts +24 -1
- package/dist/chain/node.js +88 -43
- package/dist/chain/offchain.d.ts +2 -0
- package/dist/chain/paidAgentTransport.d.ts +38 -0
- package/dist/chain/paidAgentTransport.js +1 -0
- package/dist/chain/paidEpoch.d.ts +66 -0
- package/dist/chain/paidEpoch.js +139 -0
- package/dist/chain/paidPacing.d.ts +81 -0
- package/dist/chain/paidPacing.js +136 -0
- package/dist/chain/pinnedReads.d.ts +49 -0
- package/dist/chain/pinnedReads.js +218 -0
- package/dist/chain/prepaid.d.ts +383 -0
- package/dist/chain/prepaid.js +1046 -0
- package/dist/chain/prepaidEscape.d.ts +274 -0
- package/dist/chain/prepaidEscape.js +432 -0
- package/dist/chain/prepaidFault.d.ts +94 -0
- package/dist/chain/prepaidFault.js +148 -0
- package/dist/chain/receipt.d.ts +24 -0
- package/dist/chain/receipt.js +82 -0
- package/dist/chain/registeredAgent.d.ts +68 -3
- package/dist/chain/registeredAgent.js +143 -42
- package/dist/chain/registeredOperation.d.ts +10 -1
- package/dist/chain/registeredOperation.js +18 -3
- package/dist/chain/registeredPaidAgent.d.ts +254 -0
- package/dist/chain/registeredPaidAgent.js +889 -0
- package/dist/chain/registeredRelay.d.ts +31 -1
- package/dist/chain/registeredRelay.js +164 -43
- package/dist/chain/relayVoucher.d.ts +64 -0
- package/dist/chain/relayVoucher.js +69 -0
- package/dist/chain/reservation.d.ts +239 -0
- package/dist/chain/reservation.js +746 -0
- package/dist/chain/reshareRoster.d.ts +64 -0
- package/dist/chain/reshareRoster.js +85 -0
- package/dist/chain/revertReason.d.ts +8 -0
- package/dist/chain/revertReason.js +2 -1
- package/dist/chain/rotationLock.d.ts +130 -0
- package/dist/chain/rotationLock.js +168 -0
- package/dist/chain/serviceRequestPolicy.d.ts +47 -0
- package/dist/chain/serviceRequestPolicy.js +86 -0
- package/dist/chain/services.d.ts +7 -0
- package/dist/chain/services.js +44 -4
- package/dist/chain/slotClient.js +11 -2
- package/dist/chain/slotHandoff.d.ts +81 -0
- package/dist/chain/slotHandoff.js +166 -0
- package/dist/chain/slotSeed.d.ts +47 -5
- package/dist/chain/slotSeed.js +173 -42
- package/dist/chain/verifierSnapshot.d.ts +36 -0
- package/dist/chain/verifierSnapshot.js +197 -0
- package/dist/chain/write.d.ts +111 -21
- package/dist/chain/write.js +378 -146
- package/dist/committee/blsSharing.d.ts +53 -0
- package/dist/committee/blsSharing.js +90 -0
- package/dist/committee/client.d.ts +62 -23
- package/dist/committee/client.js +288 -72
- package/dist/committee/dual-operation.d.ts +165 -0
- package/dist/committee/dual-operation.js +229 -0
- package/dist/committee/dual-sign.d.ts +26 -1
- package/dist/committee/dual-sign.js +85 -7
- package/dist/committee/ecdsa.d.ts +38 -0
- package/dist/committee/ecdsa.js +87 -15
- package/dist/committee/evidence.d.ts +30 -0
- package/dist/committee/evidence.js +65 -0
- package/dist/committee/execution.d.ts +414 -0
- package/dist/committee/execution.js +446 -0
- package/dist/committee/extraction.js +33 -26
- package/dist/committee/index.d.ts +30 -7
- package/dist/committee/index.js +18 -6
- package/dist/committee/keeperExecution.d.ts +37 -0
- package/dist/committee/keeperExecution.js +141 -0
- package/dist/committee/oauth.d.ts +14 -4
- package/dist/committee/oauth.js +17 -5
- package/dist/committee/payment.d.ts +369 -0
- package/dist/committee/payment.js +339 -0
- package/dist/committee/recovery.d.ts +136 -0
- package/dist/committee/recovery.js +204 -0
- package/dist/committee/recoveryJson.d.ts +2 -0
- package/dist/committee/recoveryJson.js +87 -0
- package/dist/committee/request.d.ts +63 -27
- package/dist/committee/request.js +77 -66
- package/dist/committee/session-grant.d.ts +320 -0
- package/dist/committee/session-grant.js +397 -0
- package/dist/committee/status-refresh.d.ts +257 -0
- package/dist/committee/status-refresh.js +619 -0
- package/dist/committee/token.d.ts +163 -15
- package/dist/committee/token.js +247 -10
- package/dist/crypto/bn254.d.ts +70 -0
- package/dist/crypto/bn254.js +222 -0
- package/dist/crypto/ibe.d.ts +32 -0
- package/dist/crypto/ibe.js +56 -8
- package/dist/crypto/index.d.ts +1 -1
- package/dist/crypto/index.js +1 -1
- package/dist/crypto/kem.d.ts +31 -0
- package/dist/crypto/kem.js +113 -7
- package/dist/crypto/recipient.d.ts +75 -0
- package/dist/crypto/recipient.js +107 -0
- package/dist/decryption/client.d.ts +10 -16
- package/dist/decryption/client.js +8 -76
- package/dist/decryption/index.d.ts +2 -0
- package/dist/decryption/index.js +2 -0
- package/dist/decryption/sealed.d.ts +72 -0
- package/dist/decryption/sealed.js +147 -0
- package/dist/decryption/session.d.ts +115 -0
- package/dist/decryption/session.js +358 -0
- package/dist/errors.d.ts +406 -1
- package/dist/errors.js +400 -5
- package/dist/index.d.ts +9 -2
- package/dist/index.js +6 -1
- package/dist/internal/bounded.d.ts +66 -0
- package/dist/internal/bounded.js +126 -0
- package/dist/internal/network.d.ts +4 -0
- package/dist/internal/network.js +40 -0
- package/dist/internal/retryAfter.d.ts +8 -0
- package/dist/internal/retryAfter.js +28 -0
- package/dist/internal/sleep.d.ts +6 -0
- package/dist/internal/sleep.js +15 -0
- package/dist/internal/typedData.d.ts +13 -0
- package/dist/internal/typedData.js +77 -0
- package/dist/internal/viemErrors.d.ts +26 -0
- package/dist/internal/viemErrors.js +49 -0
- package/dist/oid4vp/binding.d.ts +27 -1
- package/dist/oid4vp/binding.js +36 -1
- package/dist/oid4vp/jose.d.ts +4 -2
- package/dist/oid4vp/jose.js +39 -7
- package/dist/oid4vp/request-object.d.ts +61 -4
- package/dist/oid4vp/request-object.js +140 -5
- package/dist/oid4vp/verifier-agent.d.ts +18 -8
- package/dist/oid4vp/verifier-agent.js +48 -6
- package/dist/oid4vp/wallet.d.ts +2 -4
- package/dist/oid4vp/wallet.js +1 -0
- package/dist/retry.d.ts +78 -0
- package/dist/retry.js +137 -0
- package/dist/signing/frost.d.ts +1 -1
- package/dist/verifier-agent/index.d.ts +41 -5
- package/dist/verifier-agent/index.js +124 -9
- package/dist/verifier-agent/payment.d.ts +7 -0
- package/dist/verifier-agent/payment.js +17 -0
- package/docs/api.md +8 -2
- package/docs/application-api.md +25 -2
- package/docs/chain.md +155 -9
- package/docs/consumer-migrations.md +61 -0
- package/docs/encrypted-notes.md +3 -2
- package/docs/encryption.md +4 -2
- package/docs/errors.md +14 -1
- package/docs/flows.md +2 -2
- package/docs/funding.md +902 -0
- package/docs/native-approvals.md +63 -0
- package/docs/reference/README.md +9 -8
- package/docs/reference/app-browser.md +232 -0
- package/docs/reference/app-node.md +38 -8
- package/docs/reference/app.md +4621 -805
- package/docs/reference/chain-node.md +74 -16
- package/docs/reference/chain.md +6740 -1592
- package/docs/reference/committee.md +5630 -987
- package/docs/reference/main.md +1439 -140
- package/docs/reference/oid4vp.md +297 -144
- package/docs/reference/verifier-agent.md +77 -35
- package/docs/signing.md +6 -0
- package/examples/encrypted-notes.ts +21 -6
- package/examples/getting-started.ts +2 -7
- package/examples/live-config.ts +24 -17
- package/package.json +17 -5
package/dist/errors.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// `retryable` is the coarse signal for callers that don't want to enumerate
|
|
26
26
|
// types: false means the request will fail identically on retry (a denied or
|
|
27
27
|
// expired credential, a malformed rule), true means it might not.
|
|
28
|
+
import { parseRetryAfter } from './internal/retryAfter.js';
|
|
28
29
|
/**
|
|
29
30
|
* Base class for typed SDK failures with a retryability hint.
|
|
30
31
|
* Some SDK errors extend plain Error, including relay and agent-session
|
|
@@ -39,12 +40,57 @@ export class TasraError extends Error {
|
|
|
39
40
|
this.retryable = opts?.retryable ?? false;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A new payment cannot be prepared with the slot's available TASRA. Reserved
|
|
45
|
+
* credit belongs to earlier jobs and is not available for a new reservation.
|
|
46
|
+
* Top up and read fresh funding before starting another payment; this error
|
|
47
|
+
* never authorizes resubmission of an uncertain transaction.
|
|
48
|
+
*/
|
|
49
|
+
export class UnderfundedSlotError extends TasraError {
|
|
50
|
+
/** Slot whose new payment was refused. */
|
|
51
|
+
slotId;
|
|
52
|
+
/** Unreserved TASRA base units, when observed during on-chain discovery. */
|
|
53
|
+
availableTasraUnits;
|
|
54
|
+
/** Accountant HTTP status, absent for a local funding observation. */
|
|
55
|
+
status;
|
|
56
|
+
/** Accountant endpoint, when a reservation request returned HTTP 402. */
|
|
57
|
+
url;
|
|
58
|
+
constructor(args) {
|
|
59
|
+
super(args.message ?? `Slot ${args.slotId} has insufficient available TASRA`, { retryable: false });
|
|
60
|
+
this.slotId = args.slotId;
|
|
61
|
+
this.availableTasraUnits = args.availableTasraUnits;
|
|
62
|
+
this.status = args.status;
|
|
63
|
+
this.url = args.url;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The transaction payer lacks native currency for the quoted reservation gas.
|
|
68
|
+
* Slot TASRA credit is a separate balance. Nothing was prepared or broadcast;
|
|
69
|
+
* this error never authorizes resubmission of an uncertain transaction.
|
|
70
|
+
*/
|
|
71
|
+
export class UnderfundedGasPayerError extends TasraError {
|
|
72
|
+
/** Stable code distinguishing native gas from slot TASRA credit. */
|
|
73
|
+
code = 'underfunded-gas-payer';
|
|
74
|
+
/** Address that would pay the reservation transaction's gas. */
|
|
75
|
+
payer;
|
|
76
|
+
/** Pending native balance, in the chain's smallest native unit. */
|
|
77
|
+
availableNativeUnits;
|
|
78
|
+
/** Estimated gas multiplied by the actual transaction gas price. */
|
|
79
|
+
requiredNativeUnits;
|
|
80
|
+
constructor(args) {
|
|
81
|
+
super(`Gas payer ${args.payer} has insufficient native currency for reservation gas`, { retryable: false });
|
|
82
|
+
this.payer = args.payer;
|
|
83
|
+
this.availableNativeUnits = args.availableNativeUnits;
|
|
84
|
+
this.requiredNativeUnits = args.requiredNativeUnits;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
42
87
|
/**
|
|
43
88
|
* A node or verifier answered with a non-2xx status. `body` is the response body,
|
|
44
89
|
* truncated to 200 characters - enough to carry the service's own error text
|
|
45
90
|
* without dumping a page of HTML into a log line.
|
|
46
91
|
*
|
|
47
|
-
* 5xx and
|
|
92
|
+
* 5xx, 429 and 425 are marked retryable; so is a 409, 410 or 422 that carries
|
|
93
|
+
* `Retry-After`. Other 4xx are not. `retryAfterMs` is the service-requested wait.
|
|
48
94
|
*/
|
|
49
95
|
export class TasraHttpError extends TasraError {
|
|
50
96
|
/** HTTP status code returned by the service. */
|
|
@@ -53,14 +99,20 @@ export class TasraHttpError extends TasraError {
|
|
|
53
99
|
url;
|
|
54
100
|
/** Response body retained as diagnostic information. */
|
|
55
101
|
body;
|
|
102
|
+
/** Service-requested wait from `Retry-After`, in ms, when one was sent. */
|
|
103
|
+
retryAfterMs;
|
|
56
104
|
constructor(args) {
|
|
57
105
|
const body = args.body ?? '';
|
|
106
|
+
const after = args.retryAfterMs !== undefined && Number.isSafeInteger(args.retryAfterMs) && args.retryAfterMs >= 0 ? args.retryAfterMs : undefined;
|
|
58
107
|
super(args.message ?? `${args.url} → HTTP ${args.status}${body ? `: ${body}` : ''}`, {
|
|
59
|
-
retryable: args.retryable ?? (args.status >= 500 || args.status === 429
|
|
108
|
+
retryable: args.retryable ?? (args.status >= 500 || args.status === 429 || args.status === 425
|
|
109
|
+
|| (after !== undefined && [409, 410, 422].includes(args.status))),
|
|
60
110
|
});
|
|
61
111
|
this.status = args.status;
|
|
62
112
|
this.url = args.url;
|
|
63
113
|
this.body = body;
|
|
114
|
+
if (after !== undefined)
|
|
115
|
+
this.retryAfterMs = after;
|
|
64
116
|
}
|
|
65
117
|
}
|
|
66
118
|
/**
|
|
@@ -72,6 +124,343 @@ export class AuthDeniedError extends TasraHttpError {
|
|
|
72
124
|
super({ ...args, retryable: false });
|
|
73
125
|
}
|
|
74
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* A keeper refused a committee grant because its verifiers' revocation-status attestations
|
|
129
|
+
* (`keykeeper/committee-status-attestation/v1`) are missing (`revocation_status_missing`) or no
|
|
130
|
+
* longer fresh for a quorum (`revocation_status_stale`). The credential was NOT judged revoked:
|
|
131
|
+
* the grant outlived the 60 s revocation bound (or came from a path that does not carry the
|
|
132
|
+
* attestations).
|
|
133
|
+
*
|
|
134
|
+
* NOT retryable, and NOT proof that no keeper worked: another keeper of the committee may already
|
|
135
|
+
* have started the operation before this one re-checked the grant, and a gateway can blur the
|
|
136
|
+
* outcome. Never resend this grant, and never treat this error alone as authority to retry, refund
|
|
137
|
+
* or clear a paid operation (its journal keeps the execution as uncertain until original-stage
|
|
138
|
+
* evidence settles it). For an UNPAID operation the remedy is a new presentation and a new grant.
|
|
139
|
+
* Not an {@link AuthDeniedError}, and {@link isAuthDenied} returns false for it.
|
|
140
|
+
*/
|
|
141
|
+
export class RevocationStatusError extends TasraHttpError {
|
|
142
|
+
/** The keeper's stable refusal code. */
|
|
143
|
+
code;
|
|
144
|
+
/** Always true: a fresh grant needs a new presentation, never this token. */
|
|
145
|
+
presentAgain = true;
|
|
146
|
+
constructor(args) {
|
|
147
|
+
super({ ...args, retryable: false });
|
|
148
|
+
this.code = args.code;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A committee grant was refused LOCALLY, before any keeper call, by the same rule a keeper in
|
|
153
|
+
* production posture applies: its revocation-status attestations
|
|
154
|
+
* (`keykeeper/committee-status-attestation/v1`) are missing (`revocation_status_missing`: absent,
|
|
155
|
+
* `null` or empty), fewer than a quorum are valid and fresh (`revocation_status_stale`), or the
|
|
156
|
+
* list is malformed, duplicated or carries a bad signature from a counted verifier
|
|
157
|
+
* (`revocation_status_invalid`), or - for a journaled paid operation - an explicit status refresh
|
|
158
|
+
* answered `status_refresh_refused` (`revocation_status_refused`: a verifier attests the holder's
|
|
159
|
+
* credential status is refused NOW; the grant is refused however fresh its attestations still are,
|
|
160
|
+
* until a later refresh succeeds).
|
|
161
|
+
*
|
|
162
|
+
* Unlike {@link RevocationStatusError} (a keeper's reply after a send), nothing was sent: a paid
|
|
163
|
+
* operation refused here stays in its pre-execution journal phase. Not retryable with this grant
|
|
164
|
+
* and never a reason to start a new session or payment automatically: present again for a fresh
|
|
165
|
+
* grant. `allowMissingStatusAttestations` (migration window only) waives `revocation_status_missing`
|
|
166
|
+
* and nothing else.
|
|
167
|
+
*/
|
|
168
|
+
export class RevocationStatusPreflightError extends TasraError {
|
|
169
|
+
/** Stable refusal code. */
|
|
170
|
+
code;
|
|
171
|
+
/** Always false: no keeper received the grant. */
|
|
172
|
+
sent = false;
|
|
173
|
+
/** Always true: a fresh grant needs a new presentation. */
|
|
174
|
+
presentAgain = true;
|
|
175
|
+
/** Paid operation identity, when the refusal stopped a journaled paid operation. */
|
|
176
|
+
requestId;
|
|
177
|
+
constructor(args) {
|
|
178
|
+
super(args.message, { retryable: false, cause: args.cause });
|
|
179
|
+
this.code = args.code;
|
|
180
|
+
if (args.requestId !== undefined)
|
|
181
|
+
this.requestId = args.requestId;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* True when a grant was refused locally for missing, stale or invalid revocation-status
|
|
186
|
+
* attestations before anything was sent.
|
|
187
|
+
*
|
|
188
|
+
* @param e - Caught value to classify.
|
|
189
|
+
*/
|
|
190
|
+
export function isRevocationStatusPreflightRefusal(e) {
|
|
191
|
+
return e instanceof RevocationStatusPreflightError;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The stable revocation-status refusal code in a keeper's 403 body, if any.
|
|
195
|
+
*
|
|
196
|
+
* @param status - HTTP status code.
|
|
197
|
+
* @param body - Complete (untruncated) response body.
|
|
198
|
+
*/
|
|
199
|
+
export function revocationStatusCode(status, body) {
|
|
200
|
+
if (status !== 403)
|
|
201
|
+
return undefined;
|
|
202
|
+
if (body.includes('revocation_status_stale'))
|
|
203
|
+
return 'revocation_status_stale';
|
|
204
|
+
if (body.includes('revocation_status_missing'))
|
|
205
|
+
return 'revocation_status_missing';
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* True when a keeper refused a grant only for stale or missing revocation-status attestations:
|
|
210
|
+
* present the credential again for a fresh grant and repeat the call.
|
|
211
|
+
*
|
|
212
|
+
* @param e - Caught value to classify.
|
|
213
|
+
*/
|
|
214
|
+
export function isRevocationStatusRefusal(e) {
|
|
215
|
+
return e instanceof RevocationStatusError;
|
|
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 class StatusRefreshError extends TasraError {
|
|
228
|
+
/** Stable code (for a fan-out, the decisive one; see `reasons` for every verifier). */
|
|
229
|
+
code;
|
|
230
|
+
/** HTTP status of the decisive answer, when there was one. */
|
|
231
|
+
httpStatus;
|
|
232
|
+
/** Longest service-requested wait among the failures, in ms. */
|
|
233
|
+
retryAfterMs;
|
|
234
|
+
/** Per-verifier (or relay) failures. */
|
|
235
|
+
reasons;
|
|
236
|
+
/** Paid operation identity, when the refresh belonged to a journaled paid operation. */
|
|
237
|
+
requestId;
|
|
238
|
+
/** The journaled sequence number the failed proof used (never reused). */
|
|
239
|
+
seq;
|
|
240
|
+
constructor(args) {
|
|
241
|
+
super(args.message, { retryable: args.retryable ?? statusRefreshRetryable(args.code, args.httpStatus), cause: args.cause });
|
|
242
|
+
this.code = args.code;
|
|
243
|
+
this.reasons = Object.freeze([...(args.reasons ?? [])]);
|
|
244
|
+
if (args.httpStatus !== undefined)
|
|
245
|
+
this.httpStatus = args.httpStatus;
|
|
246
|
+
if (args.retryAfterMs !== undefined && Number.isSafeInteger(args.retryAfterMs) && args.retryAfterMs >= 0)
|
|
247
|
+
this.retryAfterMs = args.retryAfterMs;
|
|
248
|
+
if (args.requestId !== undefined)
|
|
249
|
+
this.requestId = args.requestId;
|
|
250
|
+
if (args.seq !== undefined)
|
|
251
|
+
this.seq = args.seq;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** Coarse retryability of a status-refresh code: capacity, unavailable status and transport only. */
|
|
255
|
+
function statusRefreshRetryable(code, httpStatus) {
|
|
256
|
+
if (code === 'status_refresh_rate_limited' || code === 'status_refresh_unavailable_status' || code === 'status_refresh_unreachable'
|
|
257
|
+
|| code === 'status_refresh_quorum_unmet')
|
|
258
|
+
return true;
|
|
259
|
+
return code === 'status_refresh_http' && httpStatus !== undefined && (httpStatus >= 500 || httpStatus === 429);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* True for a {@link StatusRefreshError}.
|
|
263
|
+
*
|
|
264
|
+
* @param e - Caught value to classify.
|
|
265
|
+
*/
|
|
266
|
+
export function isStatusRefreshError(e) {
|
|
267
|
+
return e instanceof StatusRefreshError;
|
|
268
|
+
}
|
|
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 class PaidBackoffError extends TasraError {
|
|
280
|
+
/** Stable reason. */
|
|
281
|
+
code;
|
|
282
|
+
/** Route that was refused, without identifiers (for example `GET /v1/sessions/{id}`). */
|
|
283
|
+
route;
|
|
284
|
+
/** Last refusal status, when one was answered (absent for `no_time_to_send`). */
|
|
285
|
+
httpStatus;
|
|
286
|
+
/** Server-requested wait (strict integer seconds), in ms, when it sent a valid one. */
|
|
287
|
+
retryAfterMs;
|
|
288
|
+
/** Time left before the deadline when the decision was made, in ms. */
|
|
289
|
+
remainingMs;
|
|
290
|
+
/** Time one attempt needs (or wait + attempt), in ms. */
|
|
291
|
+
neededMs;
|
|
292
|
+
/** Refusals waited out before this decision. */
|
|
293
|
+
attempts;
|
|
294
|
+
constructor(args) {
|
|
295
|
+
super(paidBackoffMessage(args), { retryable: true });
|
|
296
|
+
this.code = args.code;
|
|
297
|
+
this.route = args.route;
|
|
298
|
+
this.attempts = args.attempts;
|
|
299
|
+
if (args.httpStatus !== undefined)
|
|
300
|
+
this.httpStatus = args.httpStatus;
|
|
301
|
+
if (args.retryAfterMs !== undefined)
|
|
302
|
+
this.retryAfterMs = args.retryAfterMs;
|
|
303
|
+
if (args.remainingMs !== undefined)
|
|
304
|
+
this.remainingMs = args.remainingMs;
|
|
305
|
+
if (args.neededMs !== undefined)
|
|
306
|
+
this.neededMs = args.neededMs;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function paidBackoffMessage(a) {
|
|
310
|
+
const status = a.httpStatus !== undefined ? ` (HTTP ${a.httpStatus})` : '';
|
|
311
|
+
switch (a.code) {
|
|
312
|
+
case 'deadline_exceeded': return `${a.route} refused${status}; waiting and one more attempt (${a.neededMs} ms) would reach the operation deadline (${a.remainingMs} ms left); retain records and reconcile by reading`;
|
|
313
|
+
case 'server_wait_too_long': return `${a.route} refused${status} and asked for ${a.retryAfterMs} ms, longer than this client ever waits; retain records and reconcile by reading`;
|
|
314
|
+
case 'no_time_to_send': return `${a.route} not sent: ${a.remainingMs} ms left before the operation deadline, ${a.neededMs} ms needed for an attempt; retain records and reconcile by reading`;
|
|
315
|
+
default: return `${a.route} refused${status} after ${a.attempts} attempts; retain records and reconcile by reading`;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* True for a {@link PaidBackoffError}.
|
|
320
|
+
*
|
|
321
|
+
* @param e - Caught value to classify.
|
|
322
|
+
*/
|
|
323
|
+
export function isPaidBackoffError(e) {
|
|
324
|
+
return e instanceof PaidBackoffError;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* A retained paid approval's outcome is unresolved, so the SDK will not send it (again).
|
|
328
|
+
*
|
|
329
|
+
* Code `approval_outcome_unresolved`. An approval is resent only as the byte-identical retained body
|
|
330
|
+
* and only under a durable, generation-bound, one-use permit that an exclusive claim consumes before
|
|
331
|
+
* every send. Anything else (a lost claim, a moved generation, an unknown outcome, a legacy record)
|
|
332
|
+
* lands here. Not retryable: reconcile the delivery by reading it, never by resending or re-signing.
|
|
333
|
+
*/
|
|
334
|
+
export class PaidApprovalUnresolvedError extends TasraError {
|
|
335
|
+
/** Stable code. */
|
|
336
|
+
code = 'approval_outcome_unresolved';
|
|
337
|
+
/** Why nothing was sent. */
|
|
338
|
+
reason;
|
|
339
|
+
/** Agent delivery (proposal) identity, when known. */
|
|
340
|
+
proposalId;
|
|
341
|
+
/** Send generation concerned, when known. */
|
|
342
|
+
generation;
|
|
343
|
+
/** Application-store journal entry of the approval, when known. */
|
|
344
|
+
key;
|
|
345
|
+
constructor(args) {
|
|
346
|
+
super(args.message ?? `Paid approval outcome unresolved (${args.reason}${args.generation !== undefined ? `, generation ${args.generation}` : ''}); retain records and reconcile before further work`, { retryable: false, cause: args.cause });
|
|
347
|
+
this.reason = args.reason;
|
|
348
|
+
if (args.proposalId !== undefined)
|
|
349
|
+
this.proposalId = args.proposalId;
|
|
350
|
+
if (args.generation !== undefined)
|
|
351
|
+
this.generation = args.generation;
|
|
352
|
+
if (args.key !== undefined)
|
|
353
|
+
this.key = args.key;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* True for a {@link PaidApprovalUnresolvedError}.
|
|
358
|
+
*
|
|
359
|
+
* @param e - Caught value to classify.
|
|
360
|
+
*/
|
|
361
|
+
export function isPaidApprovalUnresolved(e) {
|
|
362
|
+
return e instanceof PaidApprovalUnresolvedError;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The accountant refused a reservation `prepare` with its per-creator reservation quota (HTTP 429
|
|
366
|
+
* with a valid `Retry-After` / `x-ratelimit-after`), and the identical prepare could not be repeated
|
|
367
|
+
* inside its window (at most 150 s and half of the payment's remaining signed lifetime).
|
|
368
|
+
*
|
|
369
|
+
* Code `reservation_quota`. Nothing was prepared, signed or put on chain: no reservation transaction
|
|
370
|
+
* exists for this attempt. `reason` says why waiting stopped; `retryAfterMs` is the last hint.
|
|
371
|
+
*/
|
|
372
|
+
export class PaidReservationQuotaError extends TasraError {
|
|
373
|
+
/** Stable code. */
|
|
374
|
+
code = 'reservation_quota';
|
|
375
|
+
/** Why the prepare was not repeated. */
|
|
376
|
+
reason;
|
|
377
|
+
/** Accountant endpoint that refused. */
|
|
378
|
+
url;
|
|
379
|
+
/** The accountant's last requested wait, in ms. */
|
|
380
|
+
retryAfterMs;
|
|
381
|
+
constructor(args) {
|
|
382
|
+
super(`accountant reservation quota refused prepare (429, wait ${args.retryAfterMs} ms): ${args.reason}; nothing was reserved`, { retryable: true, cause: args.cause });
|
|
383
|
+
this.reason = args.reason;
|
|
384
|
+
this.url = args.url;
|
|
385
|
+
this.retryAfterMs = args.retryAfterMs;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* A prepaid timeout escape was refused before anything was sent for the refused call: by the local
|
|
390
|
+
* preflight (`local: true`, read at one canonical block) or by the contract's own simulation
|
|
391
|
+
* (`local: false`). Nothing about the refused call is journaled. In a multi-call escape, calls that
|
|
392
|
+
* already confirmed are in their journal (`confirmed` checkpoints) and stay final.
|
|
393
|
+
*
|
|
394
|
+
* Only `escape_not_open` is retryable: the same call succeeds once chain time reaches `opensAt`.
|
|
395
|
+
*/
|
|
396
|
+
export class PrepaidEscapeError extends TasraError {
|
|
397
|
+
/** Stable code. */
|
|
398
|
+
code;
|
|
399
|
+
/** Always false: no transaction was sent for the refused call. */
|
|
400
|
+
sent = false;
|
|
401
|
+
/** True for a local preflight refusal, false for a decoded contract revert. */
|
|
402
|
+
local;
|
|
403
|
+
/** Request the refusal names, when it names one. */
|
|
404
|
+
requestId;
|
|
405
|
+
/** When the named request's escape opens (`escape_not_open`). */
|
|
406
|
+
opensAt;
|
|
407
|
+
/** Refused delay in seconds (`invalid_escape_delay`). */
|
|
408
|
+
delaySeconds;
|
|
409
|
+
constructor(args) {
|
|
410
|
+
super(args.message ?? prepaidEscapeMessage(args), { retryable: args.code === 'escape_not_open', cause: args.cause });
|
|
411
|
+
this.code = args.code;
|
|
412
|
+
this.local = args.local;
|
|
413
|
+
if (args.requestId !== undefined)
|
|
414
|
+
this.requestId = args.requestId;
|
|
415
|
+
if (args.opensAt !== undefined)
|
|
416
|
+
this.opensAt = args.opensAt;
|
|
417
|
+
if (args.delaySeconds !== undefined)
|
|
418
|
+
this.delaySeconds = args.delaySeconds;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function prepaidEscapeMessage(a) {
|
|
422
|
+
const request = a.requestId !== undefined ? ` for request ${a.requestId}` : '';
|
|
423
|
+
switch (a.code) {
|
|
424
|
+
case 'escape_disabled': return 'prepaid timeout escape is disabled on this Settlement; nothing was sent';
|
|
425
|
+
case 'escape_not_open': return `prepaid timeout escape${request} opens at ${a.opensAt?.toISOString() ?? '?'}; nothing was sent`;
|
|
426
|
+
case 'reservation_unavailable': return `prepaid request${request} is not reserved or is already complete; nothing was sent`;
|
|
427
|
+
case 'invalid_escape_delay': return `invalid prepaid escape delay ${a.delaySeconds ?? '?'} s; nothing was sent`;
|
|
428
|
+
case 'too_many_requests': return 'too many requests in one prepaid escape call; nothing was sent';
|
|
429
|
+
case 'empty_request': return 'a prepaid escape needs at least one request; nothing was sent';
|
|
430
|
+
default: return 'this Settlement has no prepaid timeout escape; nothing was sent';
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* True for a {@link PrepaidEscapeError}.
|
|
435
|
+
*
|
|
436
|
+
* @param e - Caught value to classify.
|
|
437
|
+
*/
|
|
438
|
+
export function isPrepaidEscapeError(e) {
|
|
439
|
+
return e instanceof PrepaidEscapeError;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* A prepaid escape transaction may have been broadcast and its outcome is not proven. Code
|
|
443
|
+
* `escape_uncertain`. Retain the prepared record and reconcile it by reading chain state
|
|
444
|
+
* (`reconcileEscape`); never send it again blindly. An escape cannot refund twice (a second one
|
|
445
|
+
* reverts `ReservationUnavailable`), but a blind resend still spends gas and can collide on the nonce.
|
|
446
|
+
*/
|
|
447
|
+
export class PrepaidEscapeUncertainError extends TasraError {
|
|
448
|
+
/** Stable code. */
|
|
449
|
+
code = 'escape_uncertain';
|
|
450
|
+
/** Local journal key of the escape call. */
|
|
451
|
+
escapeId;
|
|
452
|
+
/** Requests the call named. */
|
|
453
|
+
requestIds;
|
|
454
|
+
/** Transaction hash when known; absence does not prove that nothing was sent. */
|
|
455
|
+
transactionHash;
|
|
456
|
+
constructor(args) {
|
|
457
|
+
super('prepaid escape outcome needs reconciliation; retain the prepared record and do not resend', { retryable: false, cause: args.cause });
|
|
458
|
+
this.escapeId = args.escapeId;
|
|
459
|
+
this.requestIds = Object.freeze([...args.requestIds]);
|
|
460
|
+
if (args.transactionHash !== undefined)
|
|
461
|
+
this.transactionHash = args.transactionHash;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
75
464
|
/**
|
|
76
465
|
* The request never got an HTTP answer - DNS failure, connection refused,
|
|
77
466
|
* timeout, CORS. Retryable: the service may simply not be up yet.
|
|
@@ -139,9 +528,15 @@ export class SlotRotatedError extends TasraError {
|
|
|
139
528
|
* URL (`'committee/sign'` to `committee/sign to HTTP 403: ...`).
|
|
140
529
|
*/
|
|
141
530
|
export async function httpError(res, url, label) {
|
|
142
|
-
const
|
|
531
|
+
const full = await res.text().catch(() => '');
|
|
532
|
+
const body = full.slice(0, 200);
|
|
143
533
|
const message = `${label ?? url} → HTTP ${res.status}${body ? `: ${body}` : ''}`;
|
|
144
|
-
const
|
|
534
|
+
const retryAfterMs = parseRetryAfter(res.headers?.get('retry-after'));
|
|
535
|
+
const args = { status: res.status, url, body, message, ...(retryAfterMs !== undefined ? { retryAfterMs } : {}) };
|
|
536
|
+
// Classified on the complete body: the code must not be lost to the 200-character truncation.
|
|
537
|
+
const code = revocationStatusCode(res.status, full.slice(0, 64 * 1024));
|
|
538
|
+
if (code !== undefined)
|
|
539
|
+
return new RevocationStatusError({ ...args, code });
|
|
145
540
|
return res.status === 401 || res.status === 403
|
|
146
541
|
? new AuthDeniedError(args)
|
|
147
542
|
: new TasraHttpError(args);
|
|
@@ -154,7 +549,7 @@ export async function httpError(res, url, label) {
|
|
|
154
549
|
* @param e - Caught value to classify as an authorization rejection.
|
|
155
550
|
*/
|
|
156
551
|
export function isAuthDenied(e) {
|
|
157
|
-
return e instanceof TasraHttpError && (e.status === 401 || e.status === 403);
|
|
552
|
+
return e instanceof TasraHttpError && (e.status === 401 || e.status === 403) && !(e instanceof RevocationStatusError);
|
|
158
553
|
}
|
|
159
554
|
/**
|
|
160
555
|
* True when a typed failure may be transient. Errors outside the TasraError
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ export { combineDecryptShares, verifyDecryptShare } from './crypto/index.js';
|
|
|
16
16
|
export type { DecryptShare, Ciphertext } from './crypto/index.js';
|
|
17
17
|
export { httpFaucet } from './slots/index.js';
|
|
18
18
|
export type { Faucet, FaucetGrant } from './slots/index.js';
|
|
19
|
-
export { TasraError, TasraHttpError, AuthDeniedError, NodeUnreachableError, ThresholdNotMetError, SlotRotatedError, isAuthDenied, isRetryable, } from './errors.js';
|
|
19
|
+
export { TasraError, TasraHttpError, UnderfundedSlotError, UnderfundedGasPayerError, AuthDeniedError, NodeUnreachableError, ThresholdNotMetError, SlotRotatedError, RevocationStatusError, RevocationStatusPreflightError, isAuthDenied, isRetryable, isRevocationStatusRefusal, isRevocationStatusPreflightRefusal, StatusRefreshError, isStatusRefreshError, PaidBackoffError, isPaidBackoffError, PaidApprovalUnresolvedError, isPaidApprovalUnresolved, PaidReservationQuotaError, PrepaidEscapeError, PrepaidEscapeUncertainError, isPrepaidEscapeError, } from './errors.js';
|
|
20
|
+
export type { RevocationStatusPreflightCode, StatusRefreshCode, StatusRefreshFailure, PaidBackoffCode, PaidApprovalUnresolvedReason, PrepaidEscapeCode } from './errors.js';
|
|
21
|
+
export { retryIdempotent, retryDelayMs, parseRetryAfter, classifyRetry, classifyRefusal, classifyRefusedWrite, RETRY_STATUSES, RETRY_AFTER_ONLY_STATUSES } from './retry.js';
|
|
22
|
+
export type { RetryPolicy, RetryDecision } from './retry.js';
|
|
20
23
|
export { CommitteeAuthorizeError } from './committee/index.js';
|
|
21
24
|
export { hexToBytes } from './crypto/index.js';
|
|
22
25
|
export { validate as validateDcql, evaluate as evaluateDcql, select as selectDcql, canonicalize as canonicalizeDcql, isOid4vpRule, jsonCredential, FORMAT_JWT_VC_JSON, DcqlMalformedError, MAX_RULE_LEN as DCQL_MAX_RULE_LEN, } from './auth/index.js';
|
|
@@ -37,7 +40,11 @@ export type { IbeCiphertext, IbeDecryptionShare, IbeVerifyingShares } from './cr
|
|
|
37
40
|
export { ibeSealBlob, ibeOpenBlob, ibeUnwrapBlobKey, ibeBlobDecryptKey, ibeDecryptBlobChunk, ibeBlobChunkRange, ibeBlobWrappedKey, ibeBlobDigest, IBE_BLOB_DEFAULT_CHUNK, } from './crypto/index.js';
|
|
38
41
|
export type { IbeBlobHeader, SealedBlob } from './crypto/index.js';
|
|
39
42
|
export { createOid4vpSession, pollOid4vpSession, waitForSession, payloadDigest, VerifierAgentSessionError, createOauthSession, submitOauthResponse, } from './verifier-agent/index.js';
|
|
40
|
-
export type { VerifierAgentSessionErrorKind, PresentationOperation, PresentationDelegation, CreateSessionParams, CreateSessionResult, CreateOauthSessionResult, SessionStatusResult, } from './verifier-agent/index.js';
|
|
43
|
+
export type { VerifierAgentSessionErrorKind, PresentationOperation, PresentationDelegation, CreateSessionParams, CreateSessionResult, CreateOauthSessionResult, SessionStatusResult, PollSessionOpts, } from './verifier-agent/index.js';
|
|
41
44
|
export { createDpopKey, auth0DpopSigner, jwkThumbprint, accessTokenHash, isHeaderSafeNonce, } from './auth/dpop.js';
|
|
42
45
|
export type { DpopSigner, DpopKey } from './auth/dpop.js';
|
|
43
46
|
export type { GroupEnvelope } from './crypto/index.js';
|
|
47
|
+
export { createDecryptionRecipient, decryptionBinding, kemContentDigest, recipientPayloadDigest, RECIPIENT_SUITE } from './crypto/recipient.js';
|
|
48
|
+
export type { ClientRecipient, RecipientWire, DecryptionBindingWire, SealedShareWire } from './crypto/recipient.js';
|
|
49
|
+
export { collectSealedPartials, decryptWithCommitteePartials } from './decryption/sealed.js';
|
|
50
|
+
export type { SealedRequestOpts, SealedPartial } from './decryption/sealed.js';
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,10 @@ export { httpFaucet } from './slots/index.js';
|
|
|
47
47
|
// if (e instanceof ThresholdNotMetError) ... // e.got / e.need / e.reasons
|
|
48
48
|
// if (isRetryable(e)) return backoffAndRetry()
|
|
49
49
|
// }
|
|
50
|
-
export { TasraError, TasraHttpError, AuthDeniedError, NodeUnreachableError, ThresholdNotMetError, SlotRotatedError, isAuthDenied, isRetryable, } from './errors.js';
|
|
50
|
+
export { TasraError, TasraHttpError, UnderfundedSlotError, UnderfundedGasPayerError, AuthDeniedError, NodeUnreachableError, ThresholdNotMetError, SlotRotatedError, RevocationStatusError, RevocationStatusPreflightError, isAuthDenied, isRetryable, isRevocationStatusRefusal, isRevocationStatusPreflightRefusal, StatusRefreshError, isStatusRefreshError, PaidBackoffError, isPaidBackoffError, PaidApprovalUnresolvedError, isPaidApprovalUnresolved, PaidReservationQuotaError, PrepaidEscapeError, PrepaidEscapeUncertainError, isPrepaidEscapeError, } from './errors.js';
|
|
51
|
+
// Bounded waits honoring Retry-After, for requests that are safe to send again.
|
|
52
|
+
// Never wrap a paid flow, reservation or other write whose outcome is uncertain.
|
|
53
|
+
export { retryIdempotent, retryDelayMs, parseRetryAfter, classifyRetry, classifyRefusal, classifyRefusedWrite, RETRY_STATUSES, RETRY_AFTER_ONLY_STATUSES } from './retry.js';
|
|
51
54
|
// The committee flow's HTTP error lives with the committee code but is caught
|
|
52
55
|
// by consumers of the managed clients, so it is reachable from the main entry.
|
|
53
56
|
export { CommitteeAuthorizeError } from './committee/index.js';
|
|
@@ -96,3 +99,5 @@ export { createOid4vpSession, pollOid4vpSession, waitForSession, payloadDigest,
|
|
|
96
99
|
createOauthSession, submitOauthResponse, } from './verifier-agent/index.js';
|
|
97
100
|
// DPoP (RFC 9449)
|
|
98
101
|
export { createDpopKey, auth0DpopSigner, jwkThumbprint, accessTokenHash, isHeaderSafeNonce, } from './auth/dpop.js';
|
|
102
|
+
export { createDecryptionRecipient, decryptionBinding, kemContentDigest, recipientPayloadDigest, RECIPIENT_SUITE } from './crypto/recipient.js';
|
|
103
|
+
export { collectSealedPartials, decryptWithCommitteePartials } from './decryption/sealed.js';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A least-recently-used map holding at most `max` entries; the oldest is evicted first.
|
|
3
|
+
* Store only values that are a pure function of the key (decoded public points), never secrets.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BoundedCache<K, V> {
|
|
6
|
+
#private;
|
|
7
|
+
readonly max: number;
|
|
8
|
+
constructor(max: number);
|
|
9
|
+
/** Number of entries currently held. */
|
|
10
|
+
get size(): number;
|
|
11
|
+
/**
|
|
12
|
+
* Return the cached value (refreshing it as most recently used), or `undefined`.
|
|
13
|
+
* @param key Cache key.
|
|
14
|
+
*/
|
|
15
|
+
peek(key: K): V | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Return the cached value, or compute, store and return it. A throwing `compute` stores nothing.
|
|
18
|
+
* @param key Cache key.
|
|
19
|
+
* @param compute Pure derivation of the value from the key.
|
|
20
|
+
*/
|
|
21
|
+
getOrCompute(key: K, compute: () => V): V;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Share one in-flight promise per key among concurrent callers. An entry lives only while its
|
|
25
|
+
* promise is pending (a settled result, success or failure, is never reused), and at most
|
|
26
|
+
* `max` keys are shared at once; beyond that a caller simply runs its own request.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SingleFlight<V> {
|
|
29
|
+
#private;
|
|
30
|
+
readonly max: number;
|
|
31
|
+
constructor(max: number);
|
|
32
|
+
/** Number of keys currently in flight. */
|
|
33
|
+
get size(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Join the pending request for `key`, or start one with `run`.
|
|
36
|
+
* @param key Identity of the request; equal keys must denote identical requests.
|
|
37
|
+
* @param run Starts the request.
|
|
38
|
+
*/
|
|
39
|
+
run(key: string, run: () => Promise<V>): Promise<V>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A least-recently-used map of at most `max` entries, each dropped once its own expiry passes.
|
|
43
|
+
* Store only values that can never change for their key (a read pinned to a finalized block).
|
|
44
|
+
*/
|
|
45
|
+
export declare class ExpiringCache<V> {
|
|
46
|
+
#private;
|
|
47
|
+
readonly max: number;
|
|
48
|
+
constructor(max: number);
|
|
49
|
+
/** Number of entries currently held, expired ones included until touched or evicted. */
|
|
50
|
+
get size(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Return an unexpired value, or `undefined`. A hit becomes the most recently used entry.
|
|
53
|
+
* @param key Cache key.
|
|
54
|
+
* @param now Current time in milliseconds.
|
|
55
|
+
*/
|
|
56
|
+
get(key: string, now?: number): V | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Store `value` until `expiresAt`; an already expired value is not stored. At the bound the
|
|
59
|
+
* least recently used entry is evicted.
|
|
60
|
+
* @param key Cache key.
|
|
61
|
+
* @param value Immutable value for the key.
|
|
62
|
+
* @param expiresAt Expiry in milliseconds.
|
|
63
|
+
* @param now Current time in milliseconds.
|
|
64
|
+
*/
|
|
65
|
+
set(key: string, value: V, expiresAt: number, now?: number): void;
|
|
66
|
+
}
|