@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,342 @@
|
|
|
1
|
+
import { type Address, type Hex, type LocalAccount, type TypedDataDefinition } from 'viem';
|
|
2
|
+
import type { TasraChainClient } from '../chain/client.js';
|
|
3
|
+
import type { CommitteeAction } from '../oid4vp/binding.js';
|
|
4
|
+
import { presentationOperationTypedData } from '../oid4vp/verifier-agent.js';
|
|
5
|
+
import { TasraError } from '../errors.js';
|
|
6
|
+
import type { ApplicationStore } from './ready-slot.js';
|
|
7
|
+
/** EIP-712 domain name of a slot policy statement (version `1`, the KeyRegistry as verifying contract). */
|
|
8
|
+
export declare const SLOT_POLICY_DOMAIN_NAME = "Tasra Slot Policy";
|
|
9
|
+
/** EIP-712 domain name of a holder application's policy retrieval request. */
|
|
10
|
+
export declare const SLOT_POLICY_REQUEST_DOMAIN_NAME = "Tasra Slot Policy Request";
|
|
11
|
+
/** Longest lifetime of one slot policy statement, in seconds (one day). */
|
|
12
|
+
export declare const SLOT_POLICY_MAX_LIFETIME_SECS = 86400;
|
|
13
|
+
/** Longest age of a policy retrieval request, in seconds. */
|
|
14
|
+
export declare const SLOT_POLICY_REQUEST_MAX_AGE_SECS = 120;
|
|
15
|
+
declare const SKEW_SECS = 60;
|
|
16
|
+
declare const POLICY_TYPES: {
|
|
17
|
+
readonly SlotPolicy: readonly [{
|
|
18
|
+
readonly name: "slotId";
|
|
19
|
+
readonly type: "bytes32";
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "ruleVersion";
|
|
22
|
+
readonly type: "uint64";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "ruleCommitment";
|
|
25
|
+
readonly type: "bytes32";
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "ruleHash";
|
|
28
|
+
readonly type: "bytes32";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "audience";
|
|
31
|
+
readonly type: "address";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "actions";
|
|
34
|
+
readonly type: "uint8";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "sequence";
|
|
37
|
+
readonly type: "uint64";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "issuedAt";
|
|
40
|
+
readonly type: "uint64";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "expiresAt";
|
|
43
|
+
readonly type: "uint64";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "bootstrapId";
|
|
46
|
+
readonly type: "bytes32";
|
|
47
|
+
}];
|
|
48
|
+
};
|
|
49
|
+
declare const REQUEST_TYPES: {
|
|
50
|
+
readonly SlotPolicyRequest: readonly [{
|
|
51
|
+
readonly name: "slotId";
|
|
52
|
+
readonly type: "bytes32";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "audience";
|
|
55
|
+
readonly type: "address";
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "nonce";
|
|
58
|
+
readonly type: "bytes32";
|
|
59
|
+
}, {
|
|
60
|
+
readonly name: "issuedAt";
|
|
61
|
+
readonly type: "uint64";
|
|
62
|
+
}];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Stable refusal categories of the policy bootstrap; branch on `code`, never on the message.
|
|
66
|
+
* None is retryable with the same input.
|
|
67
|
+
*/
|
|
68
|
+
export type SlotPolicyErrorCode =
|
|
69
|
+
/** The statement, rule or signature is not well formed. */
|
|
70
|
+
'malformed'
|
|
71
|
+
/** The statement names another chain or KeyRegistry. */
|
|
72
|
+
| 'wrong-deployment'
|
|
73
|
+
/** The statement names another slot. */
|
|
74
|
+
| 'wrong-slot'
|
|
75
|
+
/** The statement was issued to another holder application. */
|
|
76
|
+
| 'wrong-audience'
|
|
77
|
+
/** The requested action is not in the statement's scope. */
|
|
78
|
+
| 'out-of-scope'
|
|
79
|
+
/** The statement expired, is not valid yet or claims a lifetime over the maximum. */
|
|
80
|
+
| 'stale'
|
|
81
|
+
/** The supplied rule is not the rule the statement hashes. */
|
|
82
|
+
| 'substituted-rule'
|
|
83
|
+
/** The statement is not signed by the expected slot creator. */
|
|
84
|
+
| 'wrong-signer'
|
|
85
|
+
/** The slot's on-chain commitment, rule version or creator differs from the statement. */
|
|
86
|
+
| 'changed-policy'
|
|
87
|
+
/** A newer statement for this slot and holder application was already accepted. */
|
|
88
|
+
| 'replayed'
|
|
89
|
+
/** Another statement with the same sequence was already accepted. */
|
|
90
|
+
| 'equivocated'
|
|
91
|
+
/** The issuer is not the slot's creator, the slot is not live, or the rule and salt do not reproduce its commitment. */
|
|
92
|
+
| 'not-issuable';
|
|
93
|
+
/** A slot policy statement or retrieval request refused before anything was signed or spent. */
|
|
94
|
+
export declare class SlotPolicyError extends TasraError {
|
|
95
|
+
/** Refusal category; never infer it from the message. */
|
|
96
|
+
readonly code: SlotPolicyErrorCode;
|
|
97
|
+
constructor(code: SlotPolicyErrorCode, message: string, opts?: {
|
|
98
|
+
cause?: unknown;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** The public policy of one slot as its creator attests it to one holder application. Contains no salt. */
|
|
102
|
+
export interface SlotPolicyStatement {
|
|
103
|
+
/** Chain the slot lives on. */
|
|
104
|
+
chainId: number;
|
|
105
|
+
/** KeyRegistry that holds the slot. */
|
|
106
|
+
keyRegistry: Address;
|
|
107
|
+
/** Slot the statement describes. */
|
|
108
|
+
slot: Hex;
|
|
109
|
+
/** On-chain rule version the rule belongs to. */
|
|
110
|
+
ruleVersion: number;
|
|
111
|
+
/** On-chain salted rule commitment the rule belongs to. */
|
|
112
|
+
ruleCommitment: Hex;
|
|
113
|
+
/** keccak256 of the exact raw rule bytes, the hash verifier tokens bind. */
|
|
114
|
+
ruleHash: Hex;
|
|
115
|
+
/** Holder application key the statement was issued to. */
|
|
116
|
+
audience: Address;
|
|
117
|
+
/** Committee actions the holder application may run with this statement. */
|
|
118
|
+
actions: CommitteeAction[];
|
|
119
|
+
/** Monotonic issue counter per slot and holder application; a lower one is refused once a higher one was accepted. */
|
|
120
|
+
sequence: number;
|
|
121
|
+
/** Unix seconds of issue. */
|
|
122
|
+
issuedAt: number;
|
|
123
|
+
/** Unix seconds after which the statement no longer starts an operation. */
|
|
124
|
+
expiresAt: number;
|
|
125
|
+
/** Random identifier of this issue. */
|
|
126
|
+
bootstrapId: Hex;
|
|
127
|
+
}
|
|
128
|
+
/** A creator-signed slot policy statement and the exact raw rule it hashes. Never carries the rule salt. */
|
|
129
|
+
export interface SlotPolicyBootstrap {
|
|
130
|
+
/** The signed statement. */
|
|
131
|
+
statement: SlotPolicyStatement;
|
|
132
|
+
/** The exact raw rule bytes the statement's `ruleHash` covers, as provisioned. */
|
|
133
|
+
rule: string;
|
|
134
|
+
/** The slot creator's 65-byte EIP-712 signature over the statement. */
|
|
135
|
+
signature: Hex;
|
|
136
|
+
}
|
|
137
|
+
/** A holder application's signed request for a slot policy statement. Not a holder credential. */
|
|
138
|
+
export interface SlotPolicyRequest {
|
|
139
|
+
/** Chain the slot lives on. */
|
|
140
|
+
chainId: number;
|
|
141
|
+
/** KeyRegistry that holds the slot. */
|
|
142
|
+
keyRegistry: Address;
|
|
143
|
+
/** Slot whose policy is requested. */
|
|
144
|
+
slot: Hex;
|
|
145
|
+
/** Holder application key that signs the request and receives the statement. */
|
|
146
|
+
audience: Address;
|
|
147
|
+
/** Random request nonce; the issuer refuses a nonce it has already answered. */
|
|
148
|
+
nonce: Hex;
|
|
149
|
+
/** Unix seconds of the request. */
|
|
150
|
+
issuedAt: number;
|
|
151
|
+
/** The holder application's 65-byte EIP-712 signature over the request. */
|
|
152
|
+
signature: Hex;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The EIP-712 typed data a slot creator signs for a slot policy statement.
|
|
156
|
+
* @param statement Statement to sign or verify.
|
|
157
|
+
*/
|
|
158
|
+
export declare function slotPolicyTypedData(statement: SlotPolicyStatement): TypedDataDefinition<typeof POLICY_TYPES, 'SlotPolicy'>;
|
|
159
|
+
/**
|
|
160
|
+
* The EIP-712 hash of a slot policy statement, the identity the holder's store records.
|
|
161
|
+
* @param statement Statement to hash.
|
|
162
|
+
*/
|
|
163
|
+
export declare function slotPolicyHash(statement: SlotPolicyStatement): Hex;
|
|
164
|
+
/** What a holder application expects of a slot policy statement. */
|
|
165
|
+
export interface SlotPolicyExpectation {
|
|
166
|
+
/** Chain of the approved deployment. */
|
|
167
|
+
chainId: number;
|
|
168
|
+
/** KeyRegistry of the approved deployment. */
|
|
169
|
+
keyRegistry: Address;
|
|
170
|
+
/** Slot the operation targets. */
|
|
171
|
+
slot: Hex;
|
|
172
|
+
/** This holder application's key. */
|
|
173
|
+
audience: Address;
|
|
174
|
+
/** Action the operation runs; it must be in the statement's scope. */
|
|
175
|
+
action?: CommitteeAction;
|
|
176
|
+
/** Expected signer (the slot creator); the recovered signer is returned either way. */
|
|
177
|
+
signer?: Address;
|
|
178
|
+
/** Current Unix seconds (default: the system clock). */
|
|
179
|
+
nowSecs?: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Check a slot policy bootstrap offline: shape and bounds, deployment, slot, holder application,
|
|
183
|
+
* action scope, lifetime, that the rule is the one the statement hashes, and the creator's
|
|
184
|
+
* signature. The on-chain half (current creator, commitment and rule version at one canonical
|
|
185
|
+
* block) is checked by paidOperation, which needs the chain anyway. Throws {@link SlotPolicyError}.
|
|
186
|
+
* @param bootstrap Untrusted bootstrap as received.
|
|
187
|
+
* @param expected Deployment, slot, holder application, action and signer to expect.
|
|
188
|
+
* @returns The normalized bootstrap and the address that signed it.
|
|
189
|
+
*/
|
|
190
|
+
export declare function verifySlotPolicyBootstrap(bootstrap: SlotPolicyBootstrap, expected: SlotPolicyExpectation): Promise<{
|
|
191
|
+
bootstrap: SlotPolicyBootstrap;
|
|
192
|
+
signer: Address;
|
|
193
|
+
}>;
|
|
194
|
+
/** The on-chain slot fields a statement must match at one canonical block. */
|
|
195
|
+
export interface ObservedSlotPolicy {
|
|
196
|
+
/** On-chain slot creator. */
|
|
197
|
+
creator: Address;
|
|
198
|
+
/** On-chain salted rule commitment. */
|
|
199
|
+
ruleCommitment: Hex;
|
|
200
|
+
/** On-chain rule version. */
|
|
201
|
+
ruleVersion: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Compare a verified statement with the slot read on chain at one canonical block; throws `changed-policy`.
|
|
205
|
+
* @param statement Verified statement.
|
|
206
|
+
* @param signer Address that signed it.
|
|
207
|
+
* @param observed Creator, commitment and rule version as read.
|
|
208
|
+
*/
|
|
209
|
+
export declare function requireCurrentSlotPolicy(statement: SlotPolicyStatement, signer: Address, observed: ObservedSlotPolicy): void;
|
|
210
|
+
/**
|
|
211
|
+
* Accept a verified statement against the holder's durable high-water mark: a lower sequence than
|
|
212
|
+
* one already accepted is `replayed`, the same sequence with another statement `equivocated`.
|
|
213
|
+
* Records a higher one. Needs the private store the operation journals in.
|
|
214
|
+
*/
|
|
215
|
+
export declare function admitSlotPolicySequence(store: ApplicationStore, statement: SlotPolicyStatement): Promise<void>;
|
|
216
|
+
/** What the slot creator attests in one policy statement. */
|
|
217
|
+
export interface IssueSlotPolicyInput {
|
|
218
|
+
/** The slot creator's signer (a local account or a remote EIP-712 signer). */
|
|
219
|
+
signer: Pick<LocalAccount, 'address' | 'signTypedData'>;
|
|
220
|
+
/** Slot to describe. */
|
|
221
|
+
slot: Hex;
|
|
222
|
+
/** Exact raw rule bytes as provisioned. */
|
|
223
|
+
rule: string;
|
|
224
|
+
/** The rule salt; used only to check the commitment and never placed in the statement. */
|
|
225
|
+
salt: Hex;
|
|
226
|
+
/** Holder application key the statement is issued to. */
|
|
227
|
+
audience: Address;
|
|
228
|
+
/** Committee actions the holder application may run. */
|
|
229
|
+
actions: CommitteeAction[];
|
|
230
|
+
/** Monotonic issue counter per slot and holder application (issue a higher one to supersede). */
|
|
231
|
+
sequence: number;
|
|
232
|
+
/** Lifetime in seconds, 1..86400 (default 900). */
|
|
233
|
+
ttlSecs?: number;
|
|
234
|
+
/** Current Unix seconds (default: the system clock). */
|
|
235
|
+
nowSecs?: number;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Issue a slot policy bootstrap as the slot creator. Reads the slot at the latest block and refuses
|
|
239
|
+
* (`not-issuable`) unless it is live, the signer is its creator and the rule and salt reproduce its
|
|
240
|
+
* commitment; then signs a statement that carries the rule hash, commitment and rule version but
|
|
241
|
+
* not the salt. Hand the result to the holder application named as `audience`.
|
|
242
|
+
* @param chain Reader for the deployment that owns the slot.
|
|
243
|
+
* @param input Creator signer, slot, rule, salt, holder application, scope, sequence and lifetime.
|
|
244
|
+
*/
|
|
245
|
+
export declare function issueSlotPolicyBootstrap(chain: TasraChainClient, input: IssueSlotPolicyInput): Promise<SlotPolicyBootstrap>;
|
|
246
|
+
/**
|
|
247
|
+
* The EIP-712 typed data a holder application signs to request a slot policy statement.
|
|
248
|
+
* @param request Request fields (signature excluded).
|
|
249
|
+
*/
|
|
250
|
+
export declare function slotPolicyRequestTypedData(request: Omit<SlotPolicyRequest, 'signature'>): TypedDataDefinition<typeof REQUEST_TYPES, 'SlotPolicyRequest'>;
|
|
251
|
+
/**
|
|
252
|
+
* Sign a request for a slot policy statement with the holder application's key. The key identifies
|
|
253
|
+
* the application to the issuer; it is neither a holder credential nor a control-plane key.
|
|
254
|
+
* @param signer Holder application key.
|
|
255
|
+
* @param request Chain, KeyRegistry and slot; nonce and time default to fresh values.
|
|
256
|
+
*/
|
|
257
|
+
export declare function createSlotPolicyRequest(signer: Pick<LocalAccount, 'address' | 'signTypedData'>, request: {
|
|
258
|
+
chainId: number;
|
|
259
|
+
keyRegistry: Address;
|
|
260
|
+
slot: Hex;
|
|
261
|
+
nonce?: Hex;
|
|
262
|
+
nowSecs?: number;
|
|
263
|
+
}): Promise<SlotPolicyRequest>;
|
|
264
|
+
/**
|
|
265
|
+
* Check a holder application's policy request on the issuer side: shape, deployment, age and that
|
|
266
|
+
* its `audience` signed it. The issuer then checks that the audience is an enrolled application
|
|
267
|
+
* for this slot and that the nonce is new. Throws {@link SlotPolicyError}.
|
|
268
|
+
* @param request Untrusted request as received.
|
|
269
|
+
* @param expected Deployment of the issuer, current time and accepted age.
|
|
270
|
+
* @returns The normalized request.
|
|
271
|
+
*/
|
|
272
|
+
export declare function verifySlotPolicyRequest(request: SlotPolicyRequest, expected: {
|
|
273
|
+
chainId: number;
|
|
274
|
+
keyRegistry: Address;
|
|
275
|
+
nowSecs?: number;
|
|
276
|
+
maxAgeSecs?: number;
|
|
277
|
+
}): Promise<SlotPolicyRequest>;
|
|
278
|
+
/** Stable refusal categories of {@link paidPolicyOperation}; nothing was reserved by the refused call. */
|
|
279
|
+
export type PolicyOperationErrorCode =
|
|
280
|
+
/** The key is bound to a different operation. */
|
|
281
|
+
'key-reused'
|
|
282
|
+
/** Another call with this key is running in this process. */
|
|
283
|
+
| 'in-flight'
|
|
284
|
+
/** The original never reached its journal; pass `restartUnjournaled` to start it again once that is safe. */
|
|
285
|
+
| 'unjournaled'
|
|
286
|
+
/** The original is closed (provably unreserved or abandoned); use a new operation key. */
|
|
287
|
+
| 'closed'
|
|
288
|
+
/** A later call with this key took over before this one derived its request; this call spent nothing. */
|
|
289
|
+
| 'superseded';
|
|
290
|
+
/** A {@link paidPolicyOperation} refused without starting a second operation. */
|
|
291
|
+
export declare class PolicyOperationError extends TasraError {
|
|
292
|
+
/** Refusal category; never infer it from the message. */
|
|
293
|
+
readonly code: PolicyOperationErrorCode;
|
|
294
|
+
/** The original operation's request ID, when one is known. */
|
|
295
|
+
readonly requestId?: Hex;
|
|
296
|
+
constructor(code: PolicyOperationErrorCode, message: string, opts?: {
|
|
297
|
+
requestId?: Hex;
|
|
298
|
+
retryable?: boolean;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
declare const MAX_ATTEMPTS = 16;
|
|
302
|
+
/** The durable binding of one application operation key. */
|
|
303
|
+
export interface PolicyOperationBinding {
|
|
304
|
+
/** Record format. */
|
|
305
|
+
schema: 1;
|
|
306
|
+
/** Hash of the operation the key is bound to. */
|
|
307
|
+
fingerprint: Hex;
|
|
308
|
+
/** Hash of the policy statement the first call started with. */
|
|
309
|
+
policy: Hex;
|
|
310
|
+
/** Incremented by every (re)start; only the current generation may record a request. */
|
|
311
|
+
generation: number;
|
|
312
|
+
/** Unix seconds the key was first bound. */
|
|
313
|
+
createdAt: number;
|
|
314
|
+
/** Requests derived for this key, oldest first; the last one is the operation. */
|
|
315
|
+
attempts: {
|
|
316
|
+
generation: number;
|
|
317
|
+
requestId: Hex;
|
|
318
|
+
notAfter: number;
|
|
319
|
+
}[];
|
|
320
|
+
}
|
|
321
|
+
/** Store key of one operation key's binding. */
|
|
322
|
+
export declare function policyOperationKey(statement: Pick<SlotPolicyStatement, 'chainId' | 'keyRegistry' | 'slot' | 'audience'>, operationKey: string): string;
|
|
323
|
+
/** The operation identity a key binds: deployment, slot, action, exact payload digest, holder family and session mode. */
|
|
324
|
+
export declare function policyOperationFingerprint(input: {
|
|
325
|
+
chainId: number;
|
|
326
|
+
keyRegistry: Address;
|
|
327
|
+
slot: Hex;
|
|
328
|
+
holderKind: string;
|
|
329
|
+
sessionGrant: boolean;
|
|
330
|
+
operation: {
|
|
331
|
+
action: CommitteeAction;
|
|
332
|
+
message?: Uint8Array;
|
|
333
|
+
identity?: string;
|
|
334
|
+
payloadDigest?: Uint8Array;
|
|
335
|
+
decryption?: Parameters<typeof presentationOperationTypedData>[0]['decryption'];
|
|
336
|
+
};
|
|
337
|
+
}): Hex;
|
|
338
|
+
/** Whether a stored value is a well-formed operation key binding. */
|
|
339
|
+
export declare function validBinding(value: unknown): value is PolicyOperationBinding;
|
|
340
|
+
/** Mark one binding key running in this process for the duration of `work`; refuses a second. */
|
|
341
|
+
export declare function exclusivelyRunning<T>(store: ApplicationStore, key: string, work: () => Promise<T>): Promise<T>;
|
|
342
|
+
export { MAX_ATTEMPTS as POLICY_OPERATION_MAX_ATTEMPTS, SKEW_SECS as POLICY_SKEW_SECS };
|