@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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type PaymentIntentWire } from './payment.js';
|
|
2
|
+
import { type ExecutionAuthorization, type ExecutionConsentPolicy } from './execution.js';
|
|
3
|
+
/** Exact public route semantics used to reconstruct client-approved keeper inputs. */
|
|
4
|
+
export type KeeperExecutionKind = 'committee-sign' | 'committee-eoa-digest' | 'committee-decrypt' | 'sealed-decrypt' | 'ibe-extract' | 'dual-sign' | 'session-decrypt';
|
|
5
|
+
/** Complete locally constructed request presented to the client's approval capability. */
|
|
6
|
+
export interface KeeperExecutionApprovalRequest {
|
|
7
|
+
/** Exact route semantics, independent of the returned proof. */
|
|
8
|
+
kind: KeeperExecutionKind;
|
|
9
|
+
/** Original registered or explicitly application-mapped keeper endpoint. */
|
|
10
|
+
nodeUrl: string;
|
|
11
|
+
/** Original payment preimage carried by this request. */
|
|
12
|
+
payment: PaymentIntentWire;
|
|
13
|
+
/** Complete client-built JSON object, excluding only execution_authorizations. */
|
|
14
|
+
body: Record<string, unknown>;
|
|
15
|
+
/** Caller cancellation; the approver must check it before invoking its signer. */
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
/** Independently read creator/fee policy and client signatures for the exact request. */
|
|
19
|
+
export interface KeeperExecutionApprovals {
|
|
20
|
+
/** Fresh independently authenticated original payment, creator and reserved fee. */
|
|
21
|
+
policy: ExecutionConsentPolicy;
|
|
22
|
+
/** Coordinator plus signed contributors, or only the targeted IBE contributor. */
|
|
23
|
+
authorizations: ExecutionAuthorization[];
|
|
24
|
+
}
|
|
25
|
+
/** Local client approval capability; never give this callback to an agent or keeper. */
|
|
26
|
+
export type KeeperExecutionApprover = (request: KeeperExecutionApprovalRequest) => Promise<KeeperExecutionApprovals>;
|
|
27
|
+
/** Internal payload check shared by the independent chain approver and transport boundary. */
|
|
28
|
+
export declare function requireKeeperExecutionPayload(request: KeeperExecutionApprovalRequest): void;
|
|
29
|
+
/** Attach proofs only to an immutable copy of the exact client-built body sent to the keeper. */
|
|
30
|
+
export declare function withKeeperExecutionApprovals(options: {
|
|
31
|
+
body: Record<string, unknown>;
|
|
32
|
+
kind: KeeperExecutionKind;
|
|
33
|
+
nodeUrl: string;
|
|
34
|
+
payment?: PaymentIntentWire;
|
|
35
|
+
approveExecution?: KeeperExecutionApprover;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<Record<string, unknown>>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { kemContentDigest, recipientPayloadDigest } from '../crypto/recipient.js';
|
|
2
|
+
import { toHex } from 'viem';
|
|
3
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
4
|
+
import { base64Decode } from '../crypto/envelope.js';
|
|
5
|
+
import { decryptPayloadDigest } from '../oid4vp/binding.js';
|
|
6
|
+
import { assertPaymentIntentWire, paymentIntentHash } from './payment.js';
|
|
7
|
+
import { executionBodyHash, MAX_EXECUTION_BODY_BYTES, verifyExecutionAuthorization } from './execution.js';
|
|
8
|
+
function bareBytes(value, field) {
|
|
9
|
+
if (typeof value !== 'string' || !/^(?:0x)?(?:[0-9a-f]{2})*$/i.test(value))
|
|
10
|
+
throw new Error(`Invalid client-built ${field}`);
|
|
11
|
+
return Uint8Array.from((value.replace(/^0x/, '').match(/../g) ?? []).map(byte => Number.parseInt(byte, 16)));
|
|
12
|
+
}
|
|
13
|
+
/** Internal payload check shared by the independent chain approver and transport boundary. */
|
|
14
|
+
export function requireKeeperExecutionPayload(request) {
|
|
15
|
+
const { body, payment, kind } = request;
|
|
16
|
+
assertPaymentIntentWire(payment);
|
|
17
|
+
if (Object.hasOwn(body, 'execution_authorizations'))
|
|
18
|
+
throw new Error('Keeper approval body must exclude its envelope');
|
|
19
|
+
executionBodyHash(body);
|
|
20
|
+
let digest, action;
|
|
21
|
+
switch (kind) {
|
|
22
|
+
case 'committee-sign':
|
|
23
|
+
case 'dual-sign':
|
|
24
|
+
action = 'sign';
|
|
25
|
+
digest = sha256(bareBytes(body.message_hex, 'message'));
|
|
26
|
+
break;
|
|
27
|
+
case 'committee-eoa-digest': {
|
|
28
|
+
action = 'eoa-sign';
|
|
29
|
+
const bytes = bareBytes(body.digest, 'ECDSA digest');
|
|
30
|
+
if (bytes.length !== 32)
|
|
31
|
+
throw new Error('Client-built ECDSA digest must contain 32 bytes');
|
|
32
|
+
digest = sha256(bytes);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case 'committee-decrypt': {
|
|
36
|
+
action = 'decrypt';
|
|
37
|
+
if (!body.ciphertext || typeof body.ciphertext !== 'object' || Array.isArray(body.ciphertext))
|
|
38
|
+
throw new Error('Invalid client-built ciphertext');
|
|
39
|
+
const ct = body.ciphertext;
|
|
40
|
+
if (typeof ct.u !== 'string' || typeof ct.nonce !== 'string' || typeof ct.aead_ct !== 'string')
|
|
41
|
+
throw new Error('Invalid client-built ciphertext bytes');
|
|
42
|
+
// The established paid decrypt digest excludes nonce, but the full body signature still binds it.
|
|
43
|
+
digest = decryptPayloadDigest(base64Decode(ct.u), base64Decode(ct.aead_ct));
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'sealed-decrypt':
|
|
47
|
+
case 'session-decrypt': {
|
|
48
|
+
action = 'decrypt';
|
|
49
|
+
if (!body.ciphertext || typeof body.ciphertext !== 'object' || Array.isArray(body.ciphertext) || typeof body.identity !== 'string')
|
|
50
|
+
throw new Error('Invalid client-built sealed ciphertext');
|
|
51
|
+
const ct = body.ciphertext;
|
|
52
|
+
if (typeof ct.u !== 'string' || typeof ct.nonce !== 'string' || typeof ct.aead_ct !== 'string')
|
|
53
|
+
throw new Error('Invalid sealed ciphertext bytes');
|
|
54
|
+
digest = sealedDigest(body, kemContentDigest({ u: base64Decode(ct.u), nonce: base64Decode(ct.nonce), aeadCt: base64Decode(ct.aead_ct) }, new TextEncoder().encode(body.identity)));
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'ibe-extract':
|
|
58
|
+
action = 'ibe-extract';
|
|
59
|
+
if (typeof body.identity !== 'string')
|
|
60
|
+
throw new Error('Invalid client-built IBE identity');
|
|
61
|
+
digest = sealedDigest(body, sha256(new TextEncoder().encode(body.identity)));
|
|
62
|
+
break;
|
|
63
|
+
default: throw new Error('Unknown keeper execution route');
|
|
64
|
+
}
|
|
65
|
+
if (action !== payment.action || toHex(digest).toLowerCase() !== payment.payload_digest.toLowerCase())
|
|
66
|
+
throw new Error('Client-built keeper payload differs from retained payment');
|
|
67
|
+
if (kind === 'dual-sign' || kind === 'session-decrypt') {
|
|
68
|
+
// Both carry the payment itself (no compound token): a dual Sign beside its dual request, a
|
|
69
|
+
// session-grant item (ADR-0090 D7) beside its grant proof.
|
|
70
|
+
assertPaymentIntentWire(body.payment);
|
|
71
|
+
if (typeof body.key_slot_id !== 'string' || body.key_slot_id.replace(/^0x/, '').toLowerCase() !== payment.slot.slice(2).toLowerCase()
|
|
72
|
+
|| paymentIntentHash(body.payment) !== paymentIntentHash(payment))
|
|
73
|
+
throw new Error('Client-built dual request differs from retained payment');
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
if (!body.committee_token || typeof body.committee_token !== 'object' || Array.isArray(body.committee_token))
|
|
77
|
+
throw new Error('Missing client-built keeper grant');
|
|
78
|
+
const token = body.committee_token;
|
|
79
|
+
assertPaymentIntentWire(token.payment);
|
|
80
|
+
if (typeof token.slot_id !== 'string' || token.slot_id.replace(/^0x/, '').toLowerCase() !== payment.slot.slice(2).toLowerCase()
|
|
81
|
+
|| typeof token.payment_hash !== 'string' || token.payment_hash.replace(/^0x/, '').toLowerCase() !== paymentIntentHash(payment).slice(2).toLowerCase()
|
|
82
|
+
|| paymentIntentHash(token.payment) !== paymentIntentHash(payment))
|
|
83
|
+
throw new Error('Client-built keeper grant differs from retained payment');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function sealedDigest(body, content) {
|
|
87
|
+
if (!body.recipient || typeof body.recipient !== 'object' || Array.isArray(body.recipient) || typeof body.ciphertext_epoch !== 'number')
|
|
88
|
+
throw new Error('Recipient and epoch required for sealed keeper approval');
|
|
89
|
+
const r = body.recipient;
|
|
90
|
+
if (typeof r.suite !== 'string' || typeof r.public_key !== 'string')
|
|
91
|
+
throw new Error('Invalid sealed recipient');
|
|
92
|
+
return recipientPayloadDigest(content, body.ciphertext_epoch, r);
|
|
93
|
+
}
|
|
94
|
+
/** Attach proofs only to an immutable copy of the exact client-built body sent to the keeper. */
|
|
95
|
+
export async function withKeeperExecutionApprovals(options) {
|
|
96
|
+
const body = structuredClone(options.body), payment = options.payment && structuredClone(options.payment);
|
|
97
|
+
const { kind, nodeUrl, approveExecution, signal } = options;
|
|
98
|
+
signal?.throwIfAborted();
|
|
99
|
+
if (!payment) {
|
|
100
|
+
if (approveExecution)
|
|
101
|
+
throw new Error('Keeper execution approvals require the retained paid intent');
|
|
102
|
+
return body;
|
|
103
|
+
}
|
|
104
|
+
if (!approveExecution)
|
|
105
|
+
throw new Error('Paid keeper work requires client execution approval');
|
|
106
|
+
const request = { body, kind, nodeUrl, payment, signal };
|
|
107
|
+
requireKeeperExecutionPayload(request);
|
|
108
|
+
const hash = executionBodyHash(body);
|
|
109
|
+
const result = await approveExecution({ ...request, payment: structuredClone(payment), body: structuredClone(body) });
|
|
110
|
+
signal?.throwIfAborted();
|
|
111
|
+
const proofs = structuredClone(result.authorizations), policy = { ...result.policy, nowSecs: Math.floor(Date.now() / 1000) };
|
|
112
|
+
if (!Array.isArray(proofs) || proofs.length === 0 || proofs.length > 257)
|
|
113
|
+
throw new Error('Invalid keeper client approval count');
|
|
114
|
+
const identities = new Set();
|
|
115
|
+
for (const proof of proofs) {
|
|
116
|
+
if (proof.stage !== 'coordinator' && proof.stage !== 'contributor')
|
|
117
|
+
throw new Error('Keeper client approval uses a different role');
|
|
118
|
+
const identity = proof.stage + ':' + proof.operator_key.toLowerCase();
|
|
119
|
+
if (identities.has(identity) || proof.body_hash.toLowerCase() !== hash.toLowerCase())
|
|
120
|
+
throw new Error('Keeper client approval duplicates a stage or changes the complete body');
|
|
121
|
+
identities.add(identity);
|
|
122
|
+
await verifyExecutionAuthorization({ payment, policy, expected: { stage: proof.stage, operatorKey: proof.operator_key, body }, authorization: proof });
|
|
123
|
+
signal?.throwIfAborted();
|
|
124
|
+
}
|
|
125
|
+
const coordinator = toHex(Uint8Array.from(payment.keeper_assignment.coordinator));
|
|
126
|
+
if (kind === 'ibe-extract' || kind === 'sealed-decrypt' || kind === 'session-decrypt') {
|
|
127
|
+
if (proofs.length !== 1 || proofs[0].stage !== 'contributor')
|
|
128
|
+
throw new Error('Sealed contribution requires exactly its targeted contributor approval');
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const expected = ['coordinator:' + coordinator, ...payment.keeper_assignment.contributors.map(key => 'contributor:' + toHex(Uint8Array.from(key)))];
|
|
132
|
+
if (identities.size !== expected.length || expected.some(id => !identities.has(id)))
|
|
133
|
+
throw new Error('Keeper client approvals do not cover the signed worker assignment');
|
|
134
|
+
}
|
|
135
|
+
if (proofs.some(p => p.expires <= Math.floor(Date.now() / 1000)))
|
|
136
|
+
throw new Error('Keeper client approval expired before dispatch');
|
|
137
|
+
const approved = { ...body, execution_authorizations: proofs };
|
|
138
|
+
if (new TextEncoder().encode(JSON.stringify(approved)).length > MAX_EXECUTION_BODY_BYTES)
|
|
139
|
+
throw new Error('Approved keeper request exceeds its transport byte limit');
|
|
140
|
+
return approved;
|
|
141
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Legacy session-independent response path. New sessions use dpopHtu(origin, sessionId). */
|
|
2
|
+
export declare const OAUTH_RESPONSE_PATH = "/v1/sessions/oauth-response";
|
|
1
3
|
/** The OAuth response route is `{PREFIX}{sessionId}{SUFFIX}` under the agent origin. */
|
|
2
4
|
export declare const OAUTH_RESPONSE_PATH_PREFIX = "/v1/sessions/";
|
|
3
5
|
/** The trailing segment of the OAuth response route. */
|
|
@@ -35,17 +37,25 @@ export declare function normalizeOrigin(url: string): string;
|
|
|
35
37
|
export declare function platformAudience(origin: string, chainId: number | bigint): string;
|
|
36
38
|
/**
|
|
37
39
|
* The `htu` (RFC 9449 §4.2) a DPoP proof for an OAuth response must carry:
|
|
38
|
-
* `{origin}/v1/sessions/{sessionId}/oauth-response` — the
|
|
40
|
+
* `{origin}/v1/sessions/{sessionId}/oauth-response` — the exact POST target the proof is
|
|
41
|
+
* presented at. A session ID is one ASCII path segment; separators and encoded path
|
|
42
|
+
* characters are refused.
|
|
39
43
|
*
|
|
40
44
|
* Per session, because RFC 9449 §4.3 checks `htu` against the request URI and a conformant
|
|
41
45
|
* client library derives it from the URL it calls. The ORIGIN is still the agent origin the
|
|
42
46
|
* verifiers approved, so a client posting to a different base URL (an internal hostname, a
|
|
43
47
|
* proxy) must still sign over the value the agent returned, not over the URL it called.
|
|
44
48
|
*
|
|
45
|
-
* Throws on a session id that is not one plain path segment,
|
|
46
|
-
* one.
|
|
49
|
+
* Throws a non-retryable `TasraError` on a session id that is not one plain path segment,
|
|
50
|
+
* exactly as the verifiers refuse one.
|
|
47
51
|
*
|
|
48
52
|
* @param origin - Verifier-agent public origin the verifiers approved.
|
|
49
|
-
* @param sessionId -
|
|
53
|
+
* @param sessionId - Original session identifier, 1 to 128 ASCII letters, digits, underscores or hyphens.
|
|
50
54
|
*/
|
|
51
55
|
export declare function dpopHtu(origin: string, sessionId: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Pre-remediation proof target for an agent that supplies no session identity.
|
|
58
|
+
* New paid sessions never accept this target as a fallback.
|
|
59
|
+
* @param origin - Original platform origin.
|
|
60
|
+
*/
|
|
61
|
+
export declare function legacyDpopHtu(origin: string): string;
|
package/dist/committee/oauth.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import { TasraError } from '../errors.js';
|
|
13
13
|
/** Path segment identifying the platform's authorization API, under the agent origin. */
|
|
14
14
|
const AUDIENCE_PATH = 'authz';
|
|
15
|
+
/** Legacy session-independent response path. New sessions use dpopHtu(origin, sessionId). */
|
|
16
|
+
export const OAUTH_RESPONSE_PATH = '/v1/sessions/oauth-response';
|
|
15
17
|
/** The OAuth response route is `{PREFIX}{sessionId}{SUFFIX}` under the agent origin. */
|
|
16
18
|
export const OAUTH_RESPONSE_PATH_PREFIX = '/v1/sessions/';
|
|
17
19
|
/** The trailing segment of the OAuth response route. */
|
|
@@ -69,22 +71,32 @@ export function platformAudience(origin, chainId) {
|
|
|
69
71
|
}
|
|
70
72
|
/**
|
|
71
73
|
* The `htu` (RFC 9449 §4.2) a DPoP proof for an OAuth response must carry:
|
|
72
|
-
* `{origin}/v1/sessions/{sessionId}/oauth-response` — the
|
|
74
|
+
* `{origin}/v1/sessions/{sessionId}/oauth-response` — the exact POST target the proof is
|
|
75
|
+
* presented at. A session ID is one ASCII path segment; separators and encoded path
|
|
76
|
+
* characters are refused.
|
|
73
77
|
*
|
|
74
78
|
* Per session, because RFC 9449 §4.3 checks `htu` against the request URI and a conformant
|
|
75
79
|
* client library derives it from the URL it calls. The ORIGIN is still the agent origin the
|
|
76
80
|
* verifiers approved, so a client posting to a different base URL (an internal hostname, a
|
|
77
81
|
* proxy) must still sign over the value the agent returned, not over the URL it called.
|
|
78
82
|
*
|
|
79
|
-
* Throws on a session id that is not one plain path segment,
|
|
80
|
-
* one.
|
|
83
|
+
* Throws a non-retryable `TasraError` on a session id that is not one plain path segment,
|
|
84
|
+
* exactly as the verifiers refuse one.
|
|
81
85
|
*
|
|
82
86
|
* @param origin - Verifier-agent public origin the verifiers approved.
|
|
83
|
-
* @param sessionId -
|
|
87
|
+
* @param sessionId - Original session identifier, 1 to 128 ASCII letters, digits, underscores or hyphens.
|
|
84
88
|
*/
|
|
85
89
|
export function dpopHtu(origin, sessionId) {
|
|
86
90
|
if (!isValidSessionId(sessionId)) {
|
|
87
|
-
throw new TasraError(`dpopHtu:
|
|
91
|
+
throw new TasraError(`dpopHtu: OAuth sessionId must be 1 to ${MAX_SESSION_ID_LEN} characters of [A-Za-z0-9_-]`, { retryable: false });
|
|
88
92
|
}
|
|
89
93
|
return `${normalizeOrigin(origin)}${OAUTH_RESPONSE_PATH_PREFIX}${sessionId}${OAUTH_RESPONSE_PATH_SUFFIX}`;
|
|
90
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Pre-remediation proof target for an agent that supplies no session identity.
|
|
97
|
+
* New paid sessions never accept this target as a fallback.
|
|
98
|
+
* @param origin - Original platform origin.
|
|
99
|
+
*/
|
|
100
|
+
export function legacyDpopHtu(origin) {
|
|
101
|
+
return `${normalizeOrigin(origin)}${OAUTH_RESPONSE_PATH}`;
|
|
102
|
+
}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { type Hex, type TypedDataDefinition } from 'viem';
|
|
2
|
+
/** Immutable execution assignment from independently verified slot discovery. */
|
|
3
|
+
export interface PaidKeeperAssignment {
|
|
4
|
+
/** Sharing epoch. */
|
|
5
|
+
key_epoch: number;
|
|
6
|
+
/** Slot committee version. */
|
|
7
|
+
committee_version: number;
|
|
8
|
+
/** Required contributor count. */
|
|
9
|
+
threshold: number;
|
|
10
|
+
/** Registered Ed25519 coordinator key, serialized as 32 bytes. */
|
|
11
|
+
coordinator: number[];
|
|
12
|
+
/** Strictly sorted distinct registered Ed25519 keys, including the coordinator. */
|
|
13
|
+
contributors: number[][];
|
|
14
|
+
}
|
|
15
|
+
/** Creator spending authorization; it neither reserves funds nor authorizes key access. */
|
|
16
|
+
export interface PaymentIntentWire {
|
|
17
|
+
/** EVM chain identifier. */
|
|
18
|
+
chain_id: number;
|
|
19
|
+
/** Settlement proxy address. */
|
|
20
|
+
settlement: Hex;
|
|
21
|
+
/** KeyRegistry proxy address. */
|
|
22
|
+
key_registry: Hex;
|
|
23
|
+
/** Slot identifier. */
|
|
24
|
+
slot: Hex;
|
|
25
|
+
/** Billable operation; a dual approval is separate from the final keeper signature. */
|
|
26
|
+
action: 'sign' | 'decrypt' | 'eoa-sign' | 'ibe-extract' | 'dual-approve';
|
|
27
|
+
/** Digest of the exact operation payload. */
|
|
28
|
+
payload_digest: Hex;
|
|
29
|
+
/** Commitment to the presentation random, audience and operation expiry. */
|
|
30
|
+
session_commitment: Hex;
|
|
31
|
+
/** Unique creator payment nonce. */
|
|
32
|
+
nonce: Hex;
|
|
33
|
+
/** Maximum TASRA base units, as a decimal string to avoid precision loss. */
|
|
34
|
+
max_cost: string;
|
|
35
|
+
/** Payment expiry in Unix seconds. */
|
|
36
|
+
expires: number;
|
|
37
|
+
/** Pinned verification epoch. */
|
|
38
|
+
verification_epoch: number;
|
|
39
|
+
/** Pinned beacon seed. */
|
|
40
|
+
verification_seed: Hex;
|
|
41
|
+
/** Pinned verifier snapshot root. */
|
|
42
|
+
verification_root: Hex;
|
|
43
|
+
/** Pinned verifier registry size. */
|
|
44
|
+
verification_registry_size: number;
|
|
45
|
+
/** Pinned verifier committee size. */
|
|
46
|
+
verification_committee: number;
|
|
47
|
+
/** Pinned verifier quorum. */
|
|
48
|
+
verification_quorum: number;
|
|
49
|
+
/** Fixed keeper sharing and execution membership. */
|
|
50
|
+
keeper_assignment: PaidKeeperAssignment;
|
|
51
|
+
/** Creator's 65-byte EIP-712 signature. */
|
|
52
|
+
signature: Hex;
|
|
53
|
+
/**
|
|
54
|
+
* Prepaid allowances: the allowance this operation is debited from. When present the creator
|
|
55
|
+
* signature is over `SlotAllowancePaymentIntent` (these fields plus `allowanceId`), never over
|
|
56
|
+
* `SlotAssignedPaymentIntent`, so neither signature can stand in for the other. Absent on a
|
|
57
|
+
* per-operation (reservation-backed) payment, whose JSON is then unchanged.
|
|
58
|
+
*/
|
|
59
|
+
allowance_id?: Hex;
|
|
60
|
+
/** Prepaid allowances: the accountant-quorum debit voucher for this operation; not part of the signed intent. */
|
|
61
|
+
debit_voucher?: DebitVoucherWire;
|
|
62
|
+
}
|
|
63
|
+
/** Accountant-quorum debit of one operation against an allowance (threshold BN254 over {@link debitVoucherDigest}). */
|
|
64
|
+
export interface DebitVoucherWire {
|
|
65
|
+
/** Allowance the operation is debited from. */
|
|
66
|
+
allowance_id: Hex;
|
|
67
|
+
/** Per-allowance sequence number, from 1. */
|
|
68
|
+
seq: number;
|
|
69
|
+
/** The operation's {@link prepaidRequestId}. */
|
|
70
|
+
request_id: Hex;
|
|
71
|
+
/** TASRA base units fixed at the quote block, decimal. */
|
|
72
|
+
cost: string;
|
|
73
|
+
/** Total debited through `seq`, decimal; never above the allowance amount. */
|
|
74
|
+
cumulative: string;
|
|
75
|
+
/** Canonical block the cost was quoted at; the group key is read there. */
|
|
76
|
+
quote_block: Hex;
|
|
77
|
+
/** 64-byte BN254 G1 aggregate (x || y). */
|
|
78
|
+
signature: Hex;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Hash a validated assignment using the platform's fixed-width canonical encoding.
|
|
82
|
+
* @param a - Fixed sharing and registered keeper keys from independent discovery.
|
|
83
|
+
*/
|
|
84
|
+
export declare function keeperAssignmentCommitment(a: PaidKeeperAssignment): Hex;
|
|
85
|
+
declare const ACTIONS: {
|
|
86
|
+
readonly sign: 0;
|
|
87
|
+
readonly decrypt: 1;
|
|
88
|
+
readonly 'eoa-sign': 2;
|
|
89
|
+
readonly 'ibe-extract': 3;
|
|
90
|
+
readonly 'dual-approve': 6;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Build creator EIP-712 data. Validate chain backing, price, expiry and creator independently before spending.
|
|
94
|
+
* A payment naming an `allowance_id` (a prepaid allowance) is the distinct `SlotAllowancePaymentIntent`; the
|
|
95
|
+
* `debit_voucher` is never part of the signed data.
|
|
96
|
+
* @param p - Creator payment intent before attaching its signature.
|
|
97
|
+
*/
|
|
98
|
+
export declare function paymentIntentTypedData(p: Omit<PaymentIntentWire, 'signature'>): TypedDataDefinition;
|
|
99
|
+
/**
|
|
100
|
+
* Hash the creator intent. A matching hash is not proof of a mined reservation or a valid creator signature.
|
|
101
|
+
* @param p - Creator payment intent; a signature is not part of the EIP-712 preimage.
|
|
102
|
+
*/
|
|
103
|
+
export declare function paymentIntentHash(p: Omit<PaymentIntentWire, 'signature'>): Hex;
|
|
104
|
+
/**
|
|
105
|
+
* Derive the Settlement reservation identity for this exact payment and operation. Unchanged by
|
|
106
|
+
* Prepaid allowances: an allowance-backed payment's own signing hash is the authorization commitment, so
|
|
107
|
+
* the ID binds the allowance too.
|
|
108
|
+
* @param p - Fixed creator intent; neither hashing nor an ID proves a mined reservation.
|
|
109
|
+
*/
|
|
110
|
+
export declare function prepaidRequestId(p: Omit<PaymentIntentWire, 'signature'>): Hex;
|
|
111
|
+
/**
|
|
112
|
+
* Validate a debit voucher's shape (not its signature). Mirrors the readers' constructor: nonzero
|
|
113
|
+
* ids, cost and quote block, `cumulative >= cost`, a 64-byte non-infinity signature encoding.
|
|
114
|
+
* @param value - Untrusted voucher.
|
|
115
|
+
*/
|
|
116
|
+
export declare function assertDebitVoucherWire(value: unknown): asserts value is DebitVoucherWire;
|
|
117
|
+
/**
|
|
118
|
+
* Validate the wire representation and its signed commitment, without chain access.
|
|
119
|
+
* @param value - Untrusted payment object; signature encoding is checked, not signer recovery.
|
|
120
|
+
*/
|
|
121
|
+
export declare function assertPaymentIntentWire(value: unknown): asserts value is PaymentIntentWire;
|
|
122
|
+
/** The paid actions an allowance can fund, as `PrepaidAction` bit ordinals. */
|
|
123
|
+
export type AllowanceAction = keyof typeof ACTIONS;
|
|
124
|
+
/** `ALLOWANCE_ACTIONS`: sign, decrypt, eoa-sign, ibe-extract and dual-approve. */
|
|
125
|
+
export declare const ALLOWANCE_ACTIONS: number;
|
|
126
|
+
/**
|
|
127
|
+
* The actions bitmap of an allowance (bit `i` = `PrepaidAction` ordinal `i`).
|
|
128
|
+
* @param actions - Paid actions the allowance funds; at least one.
|
|
129
|
+
*/
|
|
130
|
+
export declare function allowanceActionBits(actions: readonly AllowanceAction[]): number;
|
|
131
|
+
/**
|
|
132
|
+
* Whether an allowance's actions bitmap funds `action`.
|
|
133
|
+
* @param actions - Allowance bitmap.
|
|
134
|
+
* @param action - Paid action of one operation.
|
|
135
|
+
*/
|
|
136
|
+
export declare function allowanceFunds(actions: number, action: AllowanceAction): boolean;
|
|
137
|
+
/** Creator authorization to lock `amount` of a slot's balance as an allowance (`SlotPrepaidAllowanceIntent`). */
|
|
138
|
+
export interface PrepaidAllowanceIntentWire {
|
|
139
|
+
/** EVM chain identifier. */
|
|
140
|
+
chain_id: number;
|
|
141
|
+
/** Settlement proxy address. */
|
|
142
|
+
settlement: Hex;
|
|
143
|
+
/** KeyRegistry proxy address. */
|
|
144
|
+
key_registry: Hex;
|
|
145
|
+
/** Slot identifier. */
|
|
146
|
+
slot: Hex;
|
|
147
|
+
/** Unique nonzero creator nonce. */
|
|
148
|
+
intent_nonce: Hex;
|
|
149
|
+
/** Escrow, TASRA base units, decimal. */
|
|
150
|
+
amount: string;
|
|
151
|
+
/** Per-operation cap, TASRA base units, decimal; at most `amount`. */
|
|
152
|
+
max_op_cost: string;
|
|
153
|
+
/** Funded actions bitmap ({@link allowanceActionBits}). */
|
|
154
|
+
actions: number;
|
|
155
|
+
/** Expiry, Unix seconds; at most one hour ahead. */
|
|
156
|
+
expires_at: number;
|
|
157
|
+
/** Pinned verification epoch. */
|
|
158
|
+
verification_epoch: number;
|
|
159
|
+
/** Pinned beacon seed. */
|
|
160
|
+
verification_seed: Hex;
|
|
161
|
+
/** Pinned verifier snapshot root. */
|
|
162
|
+
verification_root: Hex;
|
|
163
|
+
/** Pinned verifier registry size. */
|
|
164
|
+
verification_registry_size: number;
|
|
165
|
+
/** Pinned verifier committee size. */
|
|
166
|
+
verification_committee: number;
|
|
167
|
+
/** Pinned verifier quorum. */
|
|
168
|
+
verification_quorum: number;
|
|
169
|
+
/** Fixed keeper sharing and execution membership. */
|
|
170
|
+
keeper_assignment: PaidKeeperAssignment;
|
|
171
|
+
/** Creator's 65-byte EIP-712 signature. */
|
|
172
|
+
signature: Hex;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Build the creator EIP-712 data of an allowance intent (the payment domain: chain + Settlement).
|
|
176
|
+
* @param p - Allowance intent before attaching its signature.
|
|
177
|
+
*/
|
|
178
|
+
export declare function prepaidAllowanceIntentTypedData(p: Omit<PrepaidAllowanceIntentWire, 'signature'>): {
|
|
179
|
+
domain: {
|
|
180
|
+
chainId: number;
|
|
181
|
+
verifyingContract: `0x${string}`;
|
|
182
|
+
name: "Keykeeper Assigned Slot Payment";
|
|
183
|
+
version: "1";
|
|
184
|
+
};
|
|
185
|
+
primaryType: "SlotPrepaidAllowanceIntent";
|
|
186
|
+
types: {
|
|
187
|
+
readonly SlotPrepaidAllowanceIntent: readonly [{
|
|
188
|
+
readonly name: "keyRegistry";
|
|
189
|
+
readonly type: "address";
|
|
190
|
+
}, {
|
|
191
|
+
readonly name: "slotId";
|
|
192
|
+
readonly type: "bytes32";
|
|
193
|
+
}, {
|
|
194
|
+
readonly name: "intentNonce";
|
|
195
|
+
readonly type: "bytes32";
|
|
196
|
+
}, {
|
|
197
|
+
readonly name: "amount";
|
|
198
|
+
readonly type: "uint256";
|
|
199
|
+
}, {
|
|
200
|
+
readonly name: "maxOpCost";
|
|
201
|
+
readonly type: "uint256";
|
|
202
|
+
}, {
|
|
203
|
+
readonly name: "actions";
|
|
204
|
+
readonly type: "uint32";
|
|
205
|
+
}, {
|
|
206
|
+
readonly name: "expiresAt";
|
|
207
|
+
readonly type: "uint64";
|
|
208
|
+
}, {
|
|
209
|
+
readonly name: "verificationEpoch";
|
|
210
|
+
readonly type: "uint64";
|
|
211
|
+
}, {
|
|
212
|
+
readonly name: "verificationSeed";
|
|
213
|
+
readonly type: "bytes32";
|
|
214
|
+
}, {
|
|
215
|
+
readonly name: "verificationRoot";
|
|
216
|
+
readonly type: "bytes32";
|
|
217
|
+
}, {
|
|
218
|
+
readonly name: "verificationRegistrySize";
|
|
219
|
+
readonly type: "uint32";
|
|
220
|
+
}, {
|
|
221
|
+
readonly name: "verificationCommittee";
|
|
222
|
+
readonly type: "uint32";
|
|
223
|
+
}, {
|
|
224
|
+
readonly name: "verificationQuorum";
|
|
225
|
+
readonly type: "uint32";
|
|
226
|
+
}, {
|
|
227
|
+
readonly name: "keeperAssignment";
|
|
228
|
+
readonly type: "bytes32";
|
|
229
|
+
}];
|
|
230
|
+
};
|
|
231
|
+
message: {
|
|
232
|
+
keyRegistry: `0x${string}`;
|
|
233
|
+
slotId: `0x${string}`;
|
|
234
|
+
intentNonce: `0x${string}`;
|
|
235
|
+
amount: bigint;
|
|
236
|
+
maxOpCost: bigint;
|
|
237
|
+
actions: number;
|
|
238
|
+
expiresAt: bigint;
|
|
239
|
+
verificationEpoch: bigint;
|
|
240
|
+
verificationSeed: `0x${string}`;
|
|
241
|
+
verificationRoot: `0x${string}`;
|
|
242
|
+
verificationRegistrySize: number;
|
|
243
|
+
verificationCommittee: number;
|
|
244
|
+
verificationQuorum: number;
|
|
245
|
+
keeperAssignment: `0x${string}`;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* The allowance intent's EIP-712 signing hash: the `intentHash` argument of `reservePrepaidAllowanceBls`.
|
|
250
|
+
* @param p - Allowance intent; the signature is not part of the preimage.
|
|
251
|
+
*/
|
|
252
|
+
export declare function prepaidAllowanceIntentHash(p: Omit<PrepaidAllowanceIntentWire, 'signature'>): Hex;
|
|
253
|
+
/** Domain strings of the prepaid-allowance encodings. A change is a NEW name, never a digit. */
|
|
254
|
+
export declare const PREPAID_ALLOWANCE_DOMAINS: {
|
|
255
|
+
readonly allowanceId: "keykeeper/prepaid-allowance-id/v1";
|
|
256
|
+
readonly reserve: "keykeeper/prepaid-allowance-reserve/v1";
|
|
257
|
+
readonly debitVoucher: "keykeeper/prepaid-debit/v1";
|
|
258
|
+
readonly allowanceSettle: "keykeeper/prepaid-allowance-settle/v1";
|
|
259
|
+
readonly close: "keykeeper/prepaid-allowance-close/v1";
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* `keccak256(abi.encode(ID_DOMAIN, chainid, settlement, slotId, intentHash))`: the id every reader
|
|
263
|
+
* derives from the creator's intent (chain id BEFORE the Settlement here, after it elsewhere).
|
|
264
|
+
* @param chainId - EVM chain.
|
|
265
|
+
* @param settlement - Settlement proxy.
|
|
266
|
+
* @param slot - Slot.
|
|
267
|
+
* @param intentHash - {@link prepaidAllowanceIntentHash} of the creator intent.
|
|
268
|
+
*/
|
|
269
|
+
export declare function allowanceId(chainId: number, settlement: Hex, slot: Hex, intentHash: Hex): Hex;
|
|
270
|
+
/** The arguments of `reservePrepaidAllowanceBls` the accountant quorum signs. */
|
|
271
|
+
export interface AllowanceReserveArgs {
|
|
272
|
+
/** Slot. */
|
|
273
|
+
slot: Hex;
|
|
274
|
+
/** Reconciled legacy settlement cursor. */
|
|
275
|
+
legacyNonce: bigint;
|
|
276
|
+
/** Derived allowance id. */
|
|
277
|
+
allowanceId: Hex;
|
|
278
|
+
/** Escrow. */
|
|
279
|
+
amount: bigint;
|
|
280
|
+
/** Per-operation cap. */
|
|
281
|
+
maxOpCost: bigint;
|
|
282
|
+
/** Funded actions bitmap. */
|
|
283
|
+
actions: number;
|
|
284
|
+
/** Expiry, Unix seconds. */
|
|
285
|
+
expiresAt: bigint;
|
|
286
|
+
/** Quote block, immutable as the allowance's assignment block. */
|
|
287
|
+
assignmentBlock: Hex;
|
|
288
|
+
/** Authorization deadline, Unix seconds. */
|
|
289
|
+
deadline: bigint;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The reserve digest (`keykeeper/prepaid-allowance-reserve/v1`).
|
|
293
|
+
* @param settlement - Settlement proxy.
|
|
294
|
+
* @param chainId - EVM chain.
|
|
295
|
+
* @param a - Reservation arguments.
|
|
296
|
+
*/
|
|
297
|
+
export declare function allowanceReserveDigest(settlement: Hex, chainId: number, a: AllowanceReserveArgs): Hex;
|
|
298
|
+
/** The fields a debit voucher's threshold signature covers. */
|
|
299
|
+
export interface DebitVoucherFields {
|
|
300
|
+
/** Allowance. */
|
|
301
|
+
allowanceId: Hex;
|
|
302
|
+
/** Per-allowance sequence. */
|
|
303
|
+
seq: bigint;
|
|
304
|
+
/** Operation's request ID. */
|
|
305
|
+
requestId: Hex;
|
|
306
|
+
/** Cost at the quote block. */
|
|
307
|
+
cost: bigint;
|
|
308
|
+
/** Total debited through `seq`. */
|
|
309
|
+
cumulative: bigint;
|
|
310
|
+
/** Quote block hash. */
|
|
311
|
+
quoteBlock: Hex;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The debit-voucher digest (`keykeeper/prepaid-debit/v1`) the accountant threshold key signs.
|
|
315
|
+
* @param settlement - Settlement proxy.
|
|
316
|
+
* @param chainId - EVM chain.
|
|
317
|
+
* @param v - Voucher fields.
|
|
318
|
+
*/
|
|
319
|
+
export declare function debitVoucherDigest(settlement: Hex, chainId: number, v: DebitVoucherFields): Hex;
|
|
320
|
+
/**
|
|
321
|
+
* {@link debitVoucherDigest} of a wire voucher.
|
|
322
|
+
* @param settlement - Settlement proxy.
|
|
323
|
+
* @param chainId - EVM chain.
|
|
324
|
+
* @param v - Shape-checked voucher.
|
|
325
|
+
*/
|
|
326
|
+
export declare function debitVoucherWireDigest(settlement: Hex, chainId: number, v: DebitVoucherWire): Hex;
|
|
327
|
+
/** The arguments of `settlePrepaidAllowanceBls` the quorum signs (accountant settle path; for conformance). */
|
|
328
|
+
export interface AllowanceSettleArgs {
|
|
329
|
+
/** Allowance. */
|
|
330
|
+
allowanceId: Hex;
|
|
331
|
+
/** Settled request IDs. */
|
|
332
|
+
requestIds: readonly Hex[];
|
|
333
|
+
/** Their costs. */
|
|
334
|
+
costs: readonly bigint[];
|
|
335
|
+
/** Paid out of each cost. */
|
|
336
|
+
paid: readonly bigint[];
|
|
337
|
+
/** Claim batch. */
|
|
338
|
+
batchId: Hex;
|
|
339
|
+
/** Payout root. */
|
|
340
|
+
root: Hex;
|
|
341
|
+
/** Evidence hash. */
|
|
342
|
+
evidenceHash: Hex;
|
|
343
|
+
/** Deadline. */
|
|
344
|
+
deadline: bigint;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The allowance-settle digest (`keykeeper/prepaid-allowance-settle/v1`).
|
|
348
|
+
* @param settlement - Settlement proxy.
|
|
349
|
+
* @param chainId - EVM chain.
|
|
350
|
+
* @param s - Settlement arguments.
|
|
351
|
+
*/
|
|
352
|
+
export declare function allowanceSettleDigest(settlement: Hex, chainId: number, s: AllowanceSettleArgs): Hex;
|
|
353
|
+
/**
|
|
354
|
+
* The close digest (`keykeeper/prepaid-allowance-close/v1`).
|
|
355
|
+
* @param settlement - Settlement proxy.
|
|
356
|
+
* @param chainId - EVM chain.
|
|
357
|
+
* @param allowance - Allowance.
|
|
358
|
+
* @param finalCumulative - Every debit the quorum issued.
|
|
359
|
+
* @param deadline - Deadline.
|
|
360
|
+
*/
|
|
361
|
+
export declare function allowanceCloseDigest(settlement: Hex, chainId: number, allowance: Hex, finalCumulative: bigint, deadline: bigint): Hex;
|
|
362
|
+
/**
|
|
363
|
+
* Commit a fixed presentation random and audience before reserving a payment.
|
|
364
|
+
* @param random - Fixed 32-byte cryptographic presentation random.
|
|
365
|
+
* @param clientId - Verifier-agent audience used for the presentation.
|
|
366
|
+
* @param operationExp - Original signed operation expiry in Unix seconds.
|
|
367
|
+
*/
|
|
368
|
+
export declare function paymentSessionCommitment(random: Hex, clientId: string, operationExp: number): Hex;
|
|
369
|
+
export {};
|