@aastar/sdk 0.20.7 → 0.20.9
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/dist/BaseClient-CkBhQ1ou.d.cts +88 -0
- package/dist/UserClient-2J6XMTNV.cjs +15 -0
- package/dist/UserClient-2J6XMTNV.cjs.map +1 -0
- package/dist/account.cjs +31 -0
- package/dist/account.cjs.map +1 -0
- package/dist/account.d.cts +48 -0
- package/dist/admin.cjs +15 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +62 -0
- package/dist/airaccount.cjs +452 -0
- package/dist/airaccount.cjs.map +1 -0
- package/dist/airaccount.d.cts +4 -0
- package/dist/airaccount.js +3 -1
- package/dist/channel-CkRRbzT8.d.cts +77 -0
- package/dist/channel.cjs +27 -0
- package/dist/channel.cjs.map +1 -0
- package/dist/channel.d.cts +64 -0
- package/dist/chunk-2RCJBWPO.cjs +1168 -0
- package/dist/chunk-2RCJBWPO.cjs.map +1 -0
- package/dist/chunk-FTJD2DWE.cjs +42472 -0
- package/dist/chunk-FTJD2DWE.cjs.map +1 -0
- package/dist/chunk-GRDC6ZRA.cjs +118 -0
- package/dist/chunk-GRDC6ZRA.cjs.map +1 -0
- package/dist/chunk-GX7NROST.cjs +421 -0
- package/dist/chunk-GX7NROST.cjs.map +1 -0
- package/dist/chunk-HSVQIFIK.cjs +128 -0
- package/dist/chunk-HSVQIFIK.cjs.map +1 -0
- package/dist/{chunk-UIFMIVDK.js → chunk-IC3G6YM2.js} +24 -26
- package/dist/chunk-IC3G6YM2.js.map +1 -0
- package/dist/chunk-JTWY2XEG.cjs +115 -0
- package/dist/chunk-JTWY2XEG.cjs.map +1 -0
- package/dist/chunk-MRREGCWN.cjs +585 -0
- package/dist/chunk-MRREGCWN.cjs.map +1 -0
- package/dist/chunk-NT26BDGN.cjs +228 -0
- package/dist/chunk-NT26BDGN.cjs.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-QLF7N6H7.cjs +448 -0
- package/dist/chunk-QLF7N6H7.cjs.map +1 -0
- package/dist/chunk-RNHSA3LO.cjs +108 -0
- package/dist/chunk-RNHSA3LO.cjs.map +1 -0
- package/dist/chunk-S5IKOOUR.cjs +393 -0
- package/dist/chunk-S5IKOOUR.cjs.map +1 -0
- package/dist/chunk-TFLZETWB.cjs +4693 -0
- package/dist/chunk-TFLZETWB.cjs.map +1 -0
- package/dist/chunk-WQREDGUF.cjs +435 -0
- package/dist/chunk-WQREDGUF.cjs.map +1 -0
- package/dist/chunk-XQROKLZI.cjs +4521 -0
- package/dist/chunk-XQROKLZI.cjs.map +1 -0
- package/dist/contract-addresses-TANQ5DLX.cjs +49 -0
- package/dist/contract-addresses-TANQ5DLX.cjs.map +1 -0
- package/dist/core.cjs +894 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +6930 -0
- package/dist/dapp.cjs +289 -0
- package/dist/dapp.cjs.map +1 -0
- package/dist/dapp.d.cts +127 -0
- package/dist/doc-types-471vSmPO.d.cts +16 -0
- package/dist/enduser.cjs +24 -0
- package/dist/enduser.cjs.map +1 -0
- package/dist/enduser.d.cts +261 -0
- package/dist/identity.cjs +23 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +81 -0
- package/dist/index-B6SfEQxo.d.cts +47 -0
- package/dist/index.cjs +2814 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +656 -0
- package/dist/kms.cjs +452 -0
- package/dist/kms.cjs.map +1 -0
- package/dist/kms.d.cts +3054 -0
- package/dist/kms.d.ts +13 -13
- package/dist/kms.js +3 -1
- package/dist/lib-FE4GR7TO.cjs +1865 -0
- package/dist/lib-FE4GR7TO.cjs.map +1 -0
- package/dist/operator.cjs +27 -0
- package/dist/operator.cjs.map +1 -0
- package/dist/operator.d.cts +164 -0
- package/dist/paymaster.cjs +63 -0
- package/dist/paymaster.cjs.map +1 -0
- package/dist/paymaster.d.cts +312 -0
- package/dist/src-ENPA7D2S.cjs +63 -0
- package/dist/src-ENPA7D2S.cjs.map +1 -0
- package/dist/src-TQKEO2I4.cjs +894 -0
- package/dist/src-TQKEO2I4.cjs.map +1 -0
- package/dist/tier-router-DeeVg69O.d.cts +370 -0
- package/dist/tokens.cjs +15 -0
- package/dist/tokens.cjs.map +1 -0
- package/dist/tokens.d.cts +64 -0
- package/dist/x402.cjs +103 -0
- package/dist/x402.cjs.map +1 -0
- package/dist/x402.d.cts +373 -0
- package/package.json +32 -32
- package/dist/chunk-UIFMIVDK.js.map +0 -1
package/dist/kms.d.cts
ADDED
|
@@ -0,0 +1,3054 @@
|
|
|
1
|
+
import { y as UserOperation, P as PackedUserOperation, j as BLSSignatureData, w as TierLevel$1, T as TierConfig, p as GuardStatus, v as PreCheckResult } from './tier-router-DeeVg69O.cjs';
|
|
2
|
+
export { A as ALG_BLS, a as ALG_CUMULATIVE_T2, b as ALG_CUMULATIVE_T3, c as ALG_ECDSA, d as ALG_P256, e as AirAccountClient, f as AirAccountConfig, g as AlgId, B as BLSConfig, h as BLSManager, i as BLSNode, k as BeginAuthenticationResponse, l as BeginRegistrationResponse, m as BeginTransactionVerificationResponse, C as CryptoUtil, n as CumulativeT2SignatureData, o as CumulativeT3SignatureData, D as DEFAULT_PASSKEY_ROUTES, E as ERC4337Utils, G as GasEstimate, q as PasskeyAuthenticationParams, r as PasskeyInfo, s as PasskeyManager, t as PasskeyRegistrationParams, u as PasskeyRoutes, x as TransactionVerificationParams, U as UserOpBuilder, Y as YAAAClient, z as YAAAConfig, F as algIdForTier, H as resolveTier } from './tier-router-DeeVg69O.cjs';
|
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
|
4
|
+
import { PublicClient, Address, Abi, WalletClient, Hex } from 'viem';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Account record stored by the SDK.
|
|
8
|
+
*/
|
|
9
|
+
interface AccountRecord {
|
|
10
|
+
userId: string;
|
|
11
|
+
address: string;
|
|
12
|
+
signerAddress: string;
|
|
13
|
+
salt: number | bigint;
|
|
14
|
+
deployed: boolean;
|
|
15
|
+
deploymentTxHash: string | null;
|
|
16
|
+
validatorAddress: string;
|
|
17
|
+
entryPointVersion: string;
|
|
18
|
+
factoryAddress: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
/**
|
|
21
|
+
* Daily transfer limit in wei, stored as a decimal string (bigint serialization).
|
|
22
|
+
* "0" or undefined means no guard / no limit.
|
|
23
|
+
* Written into the factory config at account creation time.
|
|
24
|
+
*/
|
|
25
|
+
dailyLimit?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Guardian addresses and their acceptance signatures.
|
|
28
|
+
* Present only for accounts created via createAccountWithGuardians().
|
|
29
|
+
* Required by transfer-manager to reconstruct initCode using createAccountWithDefaults.
|
|
30
|
+
*/
|
|
31
|
+
guardian1?: string;
|
|
32
|
+
guardian1Sig?: string;
|
|
33
|
+
guardian2?: string;
|
|
34
|
+
guardian2Sig?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Transfer record stored by the SDK.
|
|
38
|
+
*/
|
|
39
|
+
interface TransferRecord {
|
|
40
|
+
id: string;
|
|
41
|
+
userId: string;
|
|
42
|
+
from: string;
|
|
43
|
+
to: string;
|
|
44
|
+
amount: string;
|
|
45
|
+
data?: string;
|
|
46
|
+
userOpHash: string;
|
|
47
|
+
bundlerUserOpHash?: string;
|
|
48
|
+
transactionHash?: string;
|
|
49
|
+
status: "pending" | "submitted" | "completed" | "failed";
|
|
50
|
+
error?: string;
|
|
51
|
+
nodeIndices: number[];
|
|
52
|
+
tokenAddress?: string;
|
|
53
|
+
tokenSymbol?: string;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
submittedAt?: string;
|
|
56
|
+
completedAt?: string;
|
|
57
|
+
failedAt?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Paymaster configuration record.
|
|
61
|
+
*/
|
|
62
|
+
interface PaymasterRecord {
|
|
63
|
+
id?: string;
|
|
64
|
+
name: string;
|
|
65
|
+
address: string;
|
|
66
|
+
apiKey?: string;
|
|
67
|
+
type: "pimlico" | "stackup" | "alchemy" | "custom";
|
|
68
|
+
endpoint?: string;
|
|
69
|
+
createdAt?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* BLS configuration record.
|
|
73
|
+
*/
|
|
74
|
+
interface BlsConfigRecord {
|
|
75
|
+
signerNodes?: {
|
|
76
|
+
nodes: Array<{
|
|
77
|
+
nodeId: string;
|
|
78
|
+
nodeName: string;
|
|
79
|
+
apiEndpoint: string;
|
|
80
|
+
status: string;
|
|
81
|
+
lastSeen?: string;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
discovery?: {
|
|
85
|
+
seedNodes?: Array<{
|
|
86
|
+
endpoint: string;
|
|
87
|
+
}>;
|
|
88
|
+
discoveryTimeout?: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Pluggable storage adapter — replaces NestJS DatabaseService.
|
|
93
|
+
* SDK only manages accounts, transfers, paymasters, and BLS config.
|
|
94
|
+
* User authentication is NOT handled by the SDK.
|
|
95
|
+
*/
|
|
96
|
+
interface IStorageAdapter {
|
|
97
|
+
getAccounts(): Promise<AccountRecord[]>;
|
|
98
|
+
saveAccount(account: AccountRecord): Promise<void>;
|
|
99
|
+
findAccountByUserId(userId: string): Promise<AccountRecord | null>;
|
|
100
|
+
updateAccount(userId: string, updates: Partial<AccountRecord>): Promise<void>;
|
|
101
|
+
saveTransfer(transfer: TransferRecord): Promise<void>;
|
|
102
|
+
findTransfersByUserId(userId: string): Promise<TransferRecord[]>;
|
|
103
|
+
findTransferById(id: string): Promise<TransferRecord | null>;
|
|
104
|
+
updateTransfer(id: string, updates: Partial<TransferRecord>): Promise<void>;
|
|
105
|
+
getPaymasters(userId: string): Promise<PaymasterRecord[]>;
|
|
106
|
+
savePaymaster(userId: string, paymaster: PaymasterRecord): Promise<void>;
|
|
107
|
+
removePaymaster(userId: string, name: string): Promise<boolean>;
|
|
108
|
+
getBlsConfig(): Promise<BlsConfigRecord | null>;
|
|
109
|
+
updateSignerNodesCache(nodes: unknown[]): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Optional logger interface for server SDK.
|
|
114
|
+
* Implement this to integrate with your application's logging framework.
|
|
115
|
+
*/
|
|
116
|
+
interface ILogger {
|
|
117
|
+
debug(message: string, ...args: unknown[]): void;
|
|
118
|
+
log(message: string, ...args: unknown[]): void;
|
|
119
|
+
warn(message: string, ...args: unknown[]): void;
|
|
120
|
+
error(message: string, ...args: unknown[]): void;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Default console logger used when no custom logger is provided.
|
|
124
|
+
*/
|
|
125
|
+
declare class ConsoleLogger implements ILogger {
|
|
126
|
+
private readonly prefix;
|
|
127
|
+
constructor(prefix?: string);
|
|
128
|
+
debug(message: string, ...args: unknown[]): void;
|
|
129
|
+
log(message: string, ...args: unknown[]): void;
|
|
130
|
+
warn(message: string, ...args: unknown[]): void;
|
|
131
|
+
error(message: string, ...args: unknown[]): void;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Silent logger that suppresses all output.
|
|
135
|
+
*/
|
|
136
|
+
declare class SilentLogger implements ILogger {
|
|
137
|
+
debug(): void;
|
|
138
|
+
log(): void;
|
|
139
|
+
warn(): void;
|
|
140
|
+
error(): void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Canonical production KMS endpoint (IMX93 TEE behind Cloudflare Tunnel).
|
|
145
|
+
* v0.20.0 (Beta2) — see AirAccount/kms/CHANGELOG.md.
|
|
146
|
+
*/
|
|
147
|
+
declare const DEFAULT_KMS_ENDPOINT = "https://kms.aastar.io";
|
|
148
|
+
interface KmsHttpClientOptions {
|
|
149
|
+
kmsEndpoint?: string;
|
|
150
|
+
kmsEnabled?: boolean;
|
|
151
|
+
kmsApiKey?: string;
|
|
152
|
+
logger?: ILogger;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Shared low-level HTTP transport for all KMS service classes.
|
|
156
|
+
*
|
|
157
|
+
* Centralises axios setup (baseURL, x-api-key), the `enabled` gate, and the three
|
|
158
|
+
* request flavours the KMS uses:
|
|
159
|
+
* - plain JSON → `post` / `get`
|
|
160
|
+
* - AWS-KMS framed → `amzPost` (adds x-amz-target + x-amz-json-1.1 content type)
|
|
161
|
+
* - agent/session JWT → `postWithBearer` (Authorization: Bearer <jwt>)
|
|
162
|
+
*
|
|
163
|
+
* KmsManager and the composed services (agent / session / payment / monitor) all share
|
|
164
|
+
* one instance so they reuse the same connection config and auth headers.
|
|
165
|
+
*/
|
|
166
|
+
declare class KmsHttpClient {
|
|
167
|
+
readonly endpoint: string;
|
|
168
|
+
readonly enabled: boolean;
|
|
169
|
+
readonly logger: ILogger;
|
|
170
|
+
private readonly apiKey?;
|
|
171
|
+
private readonly http;
|
|
172
|
+
constructor(options: KmsHttpClientOptions);
|
|
173
|
+
/** Throw if KMS is not enabled — every operation must call this first. */
|
|
174
|
+
ensureEnabled(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Plain JSON POST. The axios `config` arg is only forwarded when defined, so a
|
|
177
|
+
* config-less call results in `http.post(path, body)` (2 args) — preserving the
|
|
178
|
+
* exact call shape the existing unit tests assert against.
|
|
179
|
+
*/
|
|
180
|
+
post<T>(path: string, body?: unknown, config?: AxiosRequestConfig): Promise<T>;
|
|
181
|
+
/** Plain JSON GET. */
|
|
182
|
+
get<T>(path: string, config?: AxiosRequestConfig): Promise<T>;
|
|
183
|
+
/** POST with AWS-KMS framing (x-amz-target header) — required for wallet/signing ops. */
|
|
184
|
+
amzPost<T>(path: string, target: string, body: unknown): Promise<T>;
|
|
185
|
+
/** POST authenticated with a TEE-issued agent/session JWT (Authorization: Bearer). */
|
|
186
|
+
postWithBearer<T>(path: string, body: unknown, jwt: string): Promise<T>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* RP id the TA verifies against. The TA hardcodes
|
|
191
|
+
* `EXPECTED_RP_ID_HASH = SHA-256("aastar.io")` (AirAccount PR#44 / Issue #39);
|
|
192
|
+
* any other rpId makes the TA reject the assertion with "rpId hash mismatch".
|
|
193
|
+
*/
|
|
194
|
+
declare const DEFAULT_RP_ID = "aastar.io";
|
|
195
|
+
/** Origin embedded in clientDataJSON — must be the RP origin the TA expects. */
|
|
196
|
+
declare const DEFAULT_ORIGIN = "https://aastar.io";
|
|
197
|
+
/**
|
|
198
|
+
* Placeholder credential id (base64url of "test-credential") matching the
|
|
199
|
+
* reference ceremony fixtures. Production callers SHOULD pass the credential id
|
|
200
|
+
* returned by CompleteRegistration for the registered passkey.
|
|
201
|
+
*/
|
|
202
|
+
declare const DEFAULT_CREDENTIAL_ID = "dGVzdC1jcmVkZW50aWFs";
|
|
203
|
+
declare function base64UrlEncode(bytes: Uint8Array): string;
|
|
204
|
+
declare function base64UrlDecode(value: string): Uint8Array;
|
|
205
|
+
/**
|
|
206
|
+
* WebAuthn AuthenticationResponseJSON (the subset the KMS verifies). This is the
|
|
207
|
+
* value placed in `WebAuthnAssertion.Credential`.
|
|
208
|
+
*/
|
|
209
|
+
interface WebAuthnAuthenticationCredential {
|
|
210
|
+
id: string;
|
|
211
|
+
rawId: string;
|
|
212
|
+
type: "public-key";
|
|
213
|
+
response: {
|
|
214
|
+
clientDataJSON: string;
|
|
215
|
+
authenticatorData: string;
|
|
216
|
+
signature: string;
|
|
217
|
+
userHandle?: string;
|
|
218
|
+
};
|
|
219
|
+
clientExtensionResults?: Record<string, unknown>;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Pluggable passkey signer. The ceremony helper builds clientDataJSON +
|
|
223
|
+
* authenticatorData and computes the WebAuthn message
|
|
224
|
+
* (authenticatorData || SHA-256(clientDataJSON)); this signer turns that message
|
|
225
|
+
* into an ES256 (ECDSA P-256 over SHA-256) DER signature.
|
|
226
|
+
*
|
|
227
|
+
* Browser callers back this with the platform authenticator; server/test callers
|
|
228
|
+
* use {@link P256PasskeySigner}.
|
|
229
|
+
*/
|
|
230
|
+
interface PasskeyCeremonySigner {
|
|
231
|
+
/** base64url credential id registered with the KMS for this passkey. */
|
|
232
|
+
readonly credentialId: string;
|
|
233
|
+
/**
|
|
234
|
+
* Sign the WebAuthn message (authenticatorData || SHA-256(clientDataJSON)).
|
|
235
|
+
* MUST return a DER-encoded ES256 signature (ECDSA P-256 with SHA-256 applied
|
|
236
|
+
* to the message), matching the WebAuthn wire format.
|
|
237
|
+
*/
|
|
238
|
+
sign(message: Uint8Array): Uint8Array | Promise<Uint8Array>;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Server/test {@link PasskeyCeremonySigner} backed by a raw P-256 private key
|
|
242
|
+
* (the passkey bound to the KMS key). Mirrors `p256_helper.py`'s
|
|
243
|
+
* `make_ceremony_assertion`: ES256 DER signature over the WebAuthn message.
|
|
244
|
+
*/
|
|
245
|
+
declare class P256PasskeySigner implements PasskeyCeremonySigner {
|
|
246
|
+
readonly credentialId: string;
|
|
247
|
+
private readonly privateKey;
|
|
248
|
+
/**
|
|
249
|
+
* @param privateKey raw 32-byte P-256 scalar (Uint8Array or hex, 0x optional).
|
|
250
|
+
* @param credentialId base64url credential id (defaults to the reference fixture).
|
|
251
|
+
*/
|
|
252
|
+
constructor(privateKey: Uint8Array | string, credentialId?: string);
|
|
253
|
+
/**
|
|
254
|
+
* Uncompressed (0x04…, 65-byte) P-256 public key hex. Register this with the
|
|
255
|
+
* KMS via CreateKey `PasskeyPublicKey` (or ChangePasskey) so the TA can verify
|
|
256
|
+
* assertions produced by this signer.
|
|
257
|
+
*/
|
|
258
|
+
get publicKeyHex(): string;
|
|
259
|
+
sign(message: Uint8Array): Uint8Array;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Build the clientDataJSON bytes embedding the TA-issued one-time challenge.
|
|
263
|
+
*
|
|
264
|
+
* Compact JSON (no whitespace) with field order `type, challenge, origin`,
|
|
265
|
+
* mirroring the reference ceremony. The KMS parses this and asserts the
|
|
266
|
+
* `challenge` field equals the stored nonce before verifying the signature over
|
|
267
|
+
* (authenticatorData || SHA-256(clientDataJSON)).
|
|
268
|
+
*/
|
|
269
|
+
declare function buildClientDataJSON(challenge: string, origin?: string): Uint8Array;
|
|
270
|
+
/**
|
|
271
|
+
* Build authenticatorData = rpIdHash(32) || flags(1) || signCount(4, big-endian).
|
|
272
|
+
* flags = 0x05 (UP | UV). `signCount` must strictly increase across ceremonies
|
|
273
|
+
* for the same wallet (anti-clone check); callers performing multiple sequential
|
|
274
|
+
* signs should pass an incrementing value.
|
|
275
|
+
*/
|
|
276
|
+
declare function buildAuthenticatorData(rpId?: string, signCount?: number): Uint8Array;
|
|
277
|
+
interface BuildCredentialOptions {
|
|
278
|
+
/** The base64url challenge returned by the begin endpoint. */
|
|
279
|
+
challenge: string;
|
|
280
|
+
signer: PasskeyCeremonySigner;
|
|
281
|
+
rpId?: string;
|
|
282
|
+
origin?: string;
|
|
283
|
+
signCount?: number;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Build a complete WebAuthn AuthenticationResponseJSON for a dynamic TA
|
|
287
|
+
* challenge: construct clientDataJSON (embedding the challenge) + authenticatorData,
|
|
288
|
+
* then sign (authenticatorData || SHA-256(clientDataJSON)).
|
|
289
|
+
*/
|
|
290
|
+
declare function buildAuthenticationCredential(opts: BuildCredentialOptions): Promise<WebAuthnAuthenticationCredential>;
|
|
291
|
+
/** Minimal shape returned by BeginAuthentication / begin-grant-session-auth. */
|
|
292
|
+
interface BeginCeremonyResponse {
|
|
293
|
+
ChallengeId: string;
|
|
294
|
+
Options: {
|
|
295
|
+
challenge: string;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
interface RunCeremonyOptions {
|
|
299
|
+
signer: PasskeyCeremonySigner;
|
|
300
|
+
rpId?: string;
|
|
301
|
+
origin?: string;
|
|
302
|
+
signCount?: number;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Run a full WebAuthn challenge-binding ceremony (AirAccount #49):
|
|
306
|
+
* 1. fetch a one-time TA challenge from the `begin` endpoint,
|
|
307
|
+
* 2. embed it in clientDataJSON,
|
|
308
|
+
* 3. build + sign the assertion,
|
|
309
|
+
* 4. return `{ ChallengeId, Credential }` for the KMS `WebAuthn` /
|
|
310
|
+
* `webAuthnAssertion` field.
|
|
311
|
+
*
|
|
312
|
+
* `begin` is injected so the same helper serves both the generic
|
|
313
|
+
* (purpose="authentication") and grant-session (purpose="grant-session")
|
|
314
|
+
* challenge endpoints.
|
|
315
|
+
*/
|
|
316
|
+
declare function runWebAuthnCeremony(begin: () => Promise<BeginCeremonyResponse>, options: RunCeremonyOptions): Promise<WebAuthnAssertion>;
|
|
317
|
+
/** Fetch a generic authentication challenge (purpose="authentication"). */
|
|
318
|
+
declare function beginAuthenticationChallenge(http: KmsHttpClient, keyId: string): Promise<BeginCeremonyResponse>;
|
|
319
|
+
/** Fetch a grant-session challenge (purpose="grant-session"). */
|
|
320
|
+
declare function beginGrantSessionChallenge(http: KmsHttpClient, keyId: string): Promise<BeginCeremonyResponse>;
|
|
321
|
+
/**
|
|
322
|
+
* Convenience: run a generic authentication ceremony over an {@link KmsHttpClient}.
|
|
323
|
+
* Covers DeriveAddress / Sign / SignHash / SignTypedData / agent-key /
|
|
324
|
+
* p256-session signing paths.
|
|
325
|
+
*/
|
|
326
|
+
declare function runAuthenticationCeremony(http: KmsHttpClient, keyId: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<WebAuthnAssertion>;
|
|
327
|
+
/**
|
|
328
|
+
* Convenience: run a grant-session ceremony over an {@link KmsHttpClient}.
|
|
329
|
+
* Required by sign-grant-session / sign-p256-grant-session, which reject the
|
|
330
|
+
* generic 'authentication' challenge for cross-op replay safety.
|
|
331
|
+
*/
|
|
332
|
+
declare function runGrantSessionCeremony(http: KmsHttpClient, keyId: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<WebAuthnAssertion>;
|
|
333
|
+
|
|
334
|
+
interface LegacyPasskeyAssertion {
|
|
335
|
+
AuthenticatorData: string;
|
|
336
|
+
ClientDataHash: string;
|
|
337
|
+
Signature: string;
|
|
338
|
+
}
|
|
339
|
+
interface WebAuthnAssertion {
|
|
340
|
+
ChallengeId: string;
|
|
341
|
+
Credential: unknown;
|
|
342
|
+
}
|
|
343
|
+
interface KmsCreateKeyRequest {
|
|
344
|
+
Description: string;
|
|
345
|
+
KeyUsage?: string;
|
|
346
|
+
KeySpec?: string;
|
|
347
|
+
Origin?: string;
|
|
348
|
+
PasskeyPublicKey: string;
|
|
349
|
+
}
|
|
350
|
+
interface KmsCreateKeyResponse {
|
|
351
|
+
KeyMetadata: {
|
|
352
|
+
KeyId: string;
|
|
353
|
+
Arn: string;
|
|
354
|
+
CreationDate: string;
|
|
355
|
+
Enabled: boolean;
|
|
356
|
+
Description: string;
|
|
357
|
+
KeyUsage: string;
|
|
358
|
+
KeySpec: string;
|
|
359
|
+
Origin: string;
|
|
360
|
+
Address?: string;
|
|
361
|
+
};
|
|
362
|
+
Mnemonic: string;
|
|
363
|
+
Address?: string;
|
|
364
|
+
Status?: string;
|
|
365
|
+
}
|
|
366
|
+
interface KmsSignHashResponse {
|
|
367
|
+
Signature: string;
|
|
368
|
+
}
|
|
369
|
+
interface KmsBeginRegistrationRequest {
|
|
370
|
+
Description?: string;
|
|
371
|
+
UserName?: string;
|
|
372
|
+
UserDisplayName?: string;
|
|
373
|
+
}
|
|
374
|
+
interface KmsBeginRegistrationResponse {
|
|
375
|
+
ChallengeId: string;
|
|
376
|
+
Options: PublicKeyCredentialCreationOptions;
|
|
377
|
+
}
|
|
378
|
+
interface KmsCompleteRegistrationRequest {
|
|
379
|
+
ChallengeId: string;
|
|
380
|
+
Credential: unknown;
|
|
381
|
+
Description?: string;
|
|
382
|
+
}
|
|
383
|
+
interface KmsCompleteRegistrationResponse {
|
|
384
|
+
KeyId: string;
|
|
385
|
+
CredentialId: string;
|
|
386
|
+
Status: string;
|
|
387
|
+
}
|
|
388
|
+
interface KmsBeginAuthenticationRequest {
|
|
389
|
+
Address?: string;
|
|
390
|
+
KeyId?: string;
|
|
391
|
+
}
|
|
392
|
+
interface KmsBeginAuthenticationResponse {
|
|
393
|
+
ChallengeId: string;
|
|
394
|
+
Options: PublicKeyCredentialRequestOptions;
|
|
395
|
+
}
|
|
396
|
+
interface KmsEip712Domain {
|
|
397
|
+
name?: string;
|
|
398
|
+
version?: string;
|
|
399
|
+
chainId?: number;
|
|
400
|
+
verifyingContract?: string;
|
|
401
|
+
}
|
|
402
|
+
/** One entry in a `types` definition: a struct name and its ordered fields. */
|
|
403
|
+
interface KmsEip712TypeDef {
|
|
404
|
+
name: string;
|
|
405
|
+
fields: Array<{
|
|
406
|
+
name: string;
|
|
407
|
+
type: string;
|
|
408
|
+
}>;
|
|
409
|
+
}
|
|
410
|
+
/** One field value for the primary type's message. */
|
|
411
|
+
interface KmsEip712FieldValue {
|
|
412
|
+
name: string;
|
|
413
|
+
value: unknown;
|
|
414
|
+
}
|
|
415
|
+
interface KmsSignTypedDataRequest {
|
|
416
|
+
keyId: string;
|
|
417
|
+
hdPath?: string;
|
|
418
|
+
domain: KmsEip712Domain;
|
|
419
|
+
primaryType: string;
|
|
420
|
+
types: KmsEip712TypeDef[];
|
|
421
|
+
message: KmsEip712FieldValue[];
|
|
422
|
+
/** Required unless a Bearer agent JWT is supplied. Legacy passkeyAssertion is rejected. */
|
|
423
|
+
webAuthnAssertion?: WebAuthnAssertion;
|
|
424
|
+
}
|
|
425
|
+
interface KmsSignTypedDataResponse {
|
|
426
|
+
keyId: string;
|
|
427
|
+
signature: string;
|
|
428
|
+
}
|
|
429
|
+
interface KmsBeginGrantSessionAuthRequest {
|
|
430
|
+
keyId: string;
|
|
431
|
+
}
|
|
432
|
+
interface KmsBeginGrantSessionAuthResponse {
|
|
433
|
+
ChallengeId: string;
|
|
434
|
+
Options: PublicKeyCredentialRequestOptions;
|
|
435
|
+
}
|
|
436
|
+
interface KmsSignGrantSessionRequest {
|
|
437
|
+
keyId: string;
|
|
438
|
+
hdPath?: string;
|
|
439
|
+
chainId: number;
|
|
440
|
+
verifyingContract: string;
|
|
441
|
+
account: string;
|
|
442
|
+
sessionKey: string;
|
|
443
|
+
expiry: number;
|
|
444
|
+
contractScope: string;
|
|
445
|
+
selectorScope: string;
|
|
446
|
+
velocityLimit: number;
|
|
447
|
+
velocityWindow: number;
|
|
448
|
+
callTargets: string[];
|
|
449
|
+
selectorAllowlist: string[];
|
|
450
|
+
nonce: number;
|
|
451
|
+
webAuthnAssertion: WebAuthnAssertion;
|
|
452
|
+
}
|
|
453
|
+
interface KmsSignGrantSessionResponse {
|
|
454
|
+
keyId: string;
|
|
455
|
+
signature: string;
|
|
456
|
+
}
|
|
457
|
+
interface KmsSignP256GrantSessionRequest {
|
|
458
|
+
keyId: string;
|
|
459
|
+
hdPath?: string;
|
|
460
|
+
chainId: number;
|
|
461
|
+
verifyingContract: string;
|
|
462
|
+
account: string;
|
|
463
|
+
keyX: string;
|
|
464
|
+
keyY: string;
|
|
465
|
+
expiry: number;
|
|
466
|
+
contractScope: string;
|
|
467
|
+
selectorScope: string;
|
|
468
|
+
velocityLimit: number;
|
|
469
|
+
velocityWindow: number;
|
|
470
|
+
callTargets: string[];
|
|
471
|
+
selectorAllowlist: string[];
|
|
472
|
+
nonce: number;
|
|
473
|
+
webAuthnAssertion: WebAuthnAssertion;
|
|
474
|
+
}
|
|
475
|
+
interface KmsKeyStatusResponse {
|
|
476
|
+
KeyId: string;
|
|
477
|
+
Status: "creating" | "deriving" | "ready" | "error";
|
|
478
|
+
Address?: string;
|
|
479
|
+
PublicKey?: string;
|
|
480
|
+
DerivationPath?: string;
|
|
481
|
+
Error?: string;
|
|
482
|
+
}
|
|
483
|
+
interface KmsDescribeKeyResponse {
|
|
484
|
+
KeyMetadata: {
|
|
485
|
+
KeyId: string;
|
|
486
|
+
Address?: string;
|
|
487
|
+
PublicKey?: string;
|
|
488
|
+
DerivationPath?: string;
|
|
489
|
+
PasskeyPublicKey?: string;
|
|
490
|
+
Arn?: string;
|
|
491
|
+
CreationDate?: string;
|
|
492
|
+
Enabled?: boolean;
|
|
493
|
+
Description?: string;
|
|
494
|
+
KeyUsage?: string;
|
|
495
|
+
KeySpec?: string;
|
|
496
|
+
Origin?: string;
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
interface KmsEthereumTransaction {
|
|
500
|
+
chainId: number;
|
|
501
|
+
nonce: number;
|
|
502
|
+
to: string;
|
|
503
|
+
value: string;
|
|
504
|
+
gasPrice: string;
|
|
505
|
+
gas: number;
|
|
506
|
+
data: string;
|
|
507
|
+
}
|
|
508
|
+
interface KmsSignRequest {
|
|
509
|
+
KeyId?: string;
|
|
510
|
+
Address?: string;
|
|
511
|
+
DerivationPath?: string;
|
|
512
|
+
/** Provide exactly one of Message or Transaction. */
|
|
513
|
+
Message?: string;
|
|
514
|
+
Transaction?: KmsEthereumTransaction;
|
|
515
|
+
SigningAlgorithm?: string;
|
|
516
|
+
WebAuthn?: WebAuthnAssertion;
|
|
517
|
+
Passkey?: LegacyPasskeyAssertion;
|
|
518
|
+
}
|
|
519
|
+
interface KmsSignResponse {
|
|
520
|
+
Signature: string;
|
|
521
|
+
TransactionHash?: string;
|
|
522
|
+
}
|
|
523
|
+
interface KmsGetPublicKeyResponse {
|
|
524
|
+
KeyId: string;
|
|
525
|
+
PublicKey: string;
|
|
526
|
+
Address?: string;
|
|
527
|
+
KeyUsage?: string;
|
|
528
|
+
KeySpec?: string;
|
|
529
|
+
}
|
|
530
|
+
interface KmsDeriveAddressResponse {
|
|
531
|
+
Address: string;
|
|
532
|
+
PublicKey?: string;
|
|
533
|
+
}
|
|
534
|
+
interface KmsListKeysResponse {
|
|
535
|
+
Keys: Array<{
|
|
536
|
+
KeyId: string;
|
|
537
|
+
KeyArn?: string;
|
|
538
|
+
}>;
|
|
539
|
+
Truncated?: boolean;
|
|
540
|
+
NextMarker?: string;
|
|
541
|
+
}
|
|
542
|
+
interface KmsDeleteKeyResponse {
|
|
543
|
+
KeyId: string;
|
|
544
|
+
DeletionDate?: string;
|
|
545
|
+
}
|
|
546
|
+
interface KmsChangePasskeyResponse {
|
|
547
|
+
KeyId: string;
|
|
548
|
+
Changed: boolean;
|
|
549
|
+
}
|
|
550
|
+
interface KmsUnfreezeKeyResponse {
|
|
551
|
+
KeyId: string;
|
|
552
|
+
LifecycleStatus: string;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* KMS service for remote key management with WebAuthn/Passkey integration.
|
|
556
|
+
*
|
|
557
|
+
* Targets the AAStar TEE KMS (v0.20.0, kms.aastar.io). WebAuthn registration /
|
|
558
|
+
* authentication ceremonies are handled by the KMS directly; signing operations
|
|
559
|
+
* require a Passkey assertion (Legacy hex) or a one-time WebAuthn ceremony.
|
|
560
|
+
*
|
|
561
|
+
* Wraps a shared {@link KmsHttpClient}; the composed services (agent / session /
|
|
562
|
+
* payment / monitor) reuse the same client via {@link KmsManager.httpClient}.
|
|
563
|
+
*/
|
|
564
|
+
declare class KmsManager {
|
|
565
|
+
private readonly client;
|
|
566
|
+
readonly logger: ILogger;
|
|
567
|
+
constructor(options: {
|
|
568
|
+
kmsEndpoint?: string;
|
|
569
|
+
kmsEnabled?: boolean;
|
|
570
|
+
kmsApiKey?: string;
|
|
571
|
+
logger?: ILogger;
|
|
572
|
+
});
|
|
573
|
+
isKmsEnabled(): boolean;
|
|
574
|
+
/** Shared HTTP transport — pass to KmsAgentService / KmsSessionService / etc. */
|
|
575
|
+
get httpClient(): KmsHttpClient;
|
|
576
|
+
private ensureEnabled;
|
|
577
|
+
/** POST with x-amz-target header (required for wallet/signing operations). */
|
|
578
|
+
private amzPost;
|
|
579
|
+
createKey(description: string, passkeyPublicKey: string): Promise<KmsCreateKeyResponse>;
|
|
580
|
+
getKeyStatus(keyId: string): Promise<KmsKeyStatusResponse>;
|
|
581
|
+
describeKey(keyId: string): Promise<KmsDescribeKeyResponse>;
|
|
582
|
+
/** Get a key's public key (uncompressed). Not WebAuthn-gated. */
|
|
583
|
+
getPublicKey(target: {
|
|
584
|
+
KeyId?: string;
|
|
585
|
+
Address?: string;
|
|
586
|
+
}): Promise<KmsGetPublicKeyResponse>;
|
|
587
|
+
/**
|
|
588
|
+
* Derive an Ethereum address at a BIP-44 path (WebAuthn-gated).
|
|
589
|
+
* Provide a WebAuthn ceremony assertion (preferred) or a Legacy passkey assertion.
|
|
590
|
+
*/
|
|
591
|
+
deriveAddress(params: {
|
|
592
|
+
KeyId: string;
|
|
593
|
+
DerivationPath: string;
|
|
594
|
+
WebAuthn?: WebAuthnAssertion;
|
|
595
|
+
Passkey?: LegacyPasskeyAssertion;
|
|
596
|
+
}): Promise<KmsDeriveAddressResponse>;
|
|
597
|
+
/** List keys (paginated). Not WebAuthn-gated. */
|
|
598
|
+
listKeys(params?: {
|
|
599
|
+
Limit?: number;
|
|
600
|
+
Marker?: string;
|
|
601
|
+
}): Promise<KmsListKeysResponse>;
|
|
602
|
+
/**
|
|
603
|
+
* Schedule key deletion (AWS-KMS action ScheduleKeyDeletion; WebAuthn-gated).
|
|
604
|
+
* RPMB-bound on the TEE — requires a passkey/WebAuthn assertion on the normal path.
|
|
605
|
+
*/
|
|
606
|
+
deleteKey(params: {
|
|
607
|
+
KeyId: string;
|
|
608
|
+
PendingWindowInDays?: number;
|
|
609
|
+
WebAuthn?: WebAuthnAssertion;
|
|
610
|
+
Passkey?: LegacyPasskeyAssertion;
|
|
611
|
+
}): Promise<KmsDeleteKeyResponse>;
|
|
612
|
+
/**
|
|
613
|
+
* Unfreeze a dormant (frozen) key (issue #42; WebAuthn-gated).
|
|
614
|
+
* A key auto-frozen by the dormant-key sweep rejects signing until unfrozen.
|
|
615
|
+
* The TEE verifies the owner via the same strict WebAuthn ceremony as
|
|
616
|
+
* {@link deleteKey}; ownership is checked even when the key is already active,
|
|
617
|
+
* so this cannot be used as an unauthenticated key-state probe. Unlike DeleteKey
|
|
618
|
+
* this endpoint takes no `x-amz-target` header — it authenticates via the default
|
|
619
|
+
* API key plus the WebAuthn assertion in the body.
|
|
620
|
+
*/
|
|
621
|
+
unfreezeKey(params: {
|
|
622
|
+
KeyId: string;
|
|
623
|
+
WebAuthn?: WebAuthnAssertion;
|
|
624
|
+
}): Promise<KmsUnfreezeKeyResponse>;
|
|
625
|
+
/**
|
|
626
|
+
* Rotate the WebAuthn passkey bound to a key (WebAuthn-gated, RPMB-bound).
|
|
627
|
+
* `PasskeyPublicKey` is the NEW P-256 public key (0x04… 65-byte uncompressed).
|
|
628
|
+
*/
|
|
629
|
+
changePasskey(params: {
|
|
630
|
+
KeyId: string;
|
|
631
|
+
PasskeyPublicKey: string;
|
|
632
|
+
WebAuthn?: WebAuthnAssertion;
|
|
633
|
+
Passkey?: LegacyPasskeyAssertion;
|
|
634
|
+
}): Promise<KmsChangePasskeyResponse>;
|
|
635
|
+
/**
|
|
636
|
+
* Sign a message or an EIP-155 transaction (WebAuthn-gated).
|
|
637
|
+
* Provide exactly one of `Message` (hex) or `Transaction`. For a raw 32-byte
|
|
638
|
+
* digest use {@link signHash} / {@link signHashWithWebAuthn} instead.
|
|
639
|
+
*/
|
|
640
|
+
sign(params: KmsSignRequest): Promise<KmsSignResponse>;
|
|
641
|
+
/**
|
|
642
|
+
* Poll KeyStatus until the key is ready (address derived) or timeout.
|
|
643
|
+
* STM32 key derivation takes 60-75 seconds on first creation.
|
|
644
|
+
*/
|
|
645
|
+
pollUntilReady(keyId: string, timeoutMs?: number, intervalMs?: number): Promise<KmsKeyStatusResponse>;
|
|
646
|
+
/**
|
|
647
|
+
* Sign a hash using Legacy Passkey assertion (reusable for BLS dual-signing).
|
|
648
|
+
*/
|
|
649
|
+
signHash(hash: string, assertion: LegacyPasskeyAssertion, target: {
|
|
650
|
+
Address?: string;
|
|
651
|
+
KeyId?: string;
|
|
652
|
+
}): Promise<KmsSignHashResponse>;
|
|
653
|
+
/**
|
|
654
|
+
* Sign a hash using a WebAuthn ceremony assertion (one-time use).
|
|
655
|
+
*/
|
|
656
|
+
signHashWithWebAuthn(hash: string, challengeId: string, credential: unknown, target: {
|
|
657
|
+
Address?: string;
|
|
658
|
+
KeyId?: string;
|
|
659
|
+
}): Promise<KmsSignHashResponse>;
|
|
660
|
+
/**
|
|
661
|
+
* Sign arbitrary EIP-712 typed data via `POST /kms/SignTypedData` (v0.20.0).
|
|
662
|
+
*
|
|
663
|
+
* The KMS hashes the typed data host-side, so the FULL EIP-712 structure
|
|
664
|
+
* (domain / primaryType / types / message) is sent — not a pre-hashed
|
|
665
|
+
* domainSeparator/structHash. The `webAuthnAssertion` challenge comes from a
|
|
666
|
+
* generic {@link beginAuthentication} ceremony (purpose="authentication").
|
|
667
|
+
*
|
|
668
|
+
* Alternatively, agents authenticate with a Bearer JWT — see KmsAgentService.
|
|
669
|
+
*/
|
|
670
|
+
signTypedDataWithWebAuthn(params: KmsSignTypedDataRequest): Promise<KmsSignTypedDataResponse>;
|
|
671
|
+
/**
|
|
672
|
+
* Begin a grant-session WebAuthn challenge.
|
|
673
|
+
* The returned challengeId can ONLY be used with sign-grant-session, not sign-typed-data.
|
|
674
|
+
*/
|
|
675
|
+
beginGrantSessionAuth(params: KmsBeginGrantSessionAuthRequest): Promise<KmsBeginGrantSessionAuthResponse>;
|
|
676
|
+
/**
|
|
677
|
+
* Sign a GRANT_SESSION_V2 hash off-chain inside the TEE (secp256k1 session key).
|
|
678
|
+
* Returns a 65-byte signature (R||S||V, V=27/28) for use in grantSessionWithSig().
|
|
679
|
+
*/
|
|
680
|
+
signGrantSession(params: KmsSignGrantSessionRequest): Promise<KmsSignGrantSessionResponse>;
|
|
681
|
+
/**
|
|
682
|
+
* Sign a GRANT_P256_SESSION_V2 hash off-chain inside the TEE (P256 session key).
|
|
683
|
+
* Returns a 65-byte signature for use in grantP256SessionWithSig().
|
|
684
|
+
*/
|
|
685
|
+
signP256GrantSession(params: KmsSignP256GrantSessionRequest): Promise<KmsSignGrantSessionResponse>;
|
|
686
|
+
/**
|
|
687
|
+
* Run a generic authentication ceremony (purpose="authentication") bound to a
|
|
688
|
+
* fresh TA challenge. The returned assertion is valid for DeriveAddress / Sign
|
|
689
|
+
* / SignHash / SignTypedData / agent-key / p256-session signing.
|
|
690
|
+
*/
|
|
691
|
+
runAuthenticationCeremony(keyId: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<WebAuthnAssertion>;
|
|
692
|
+
/**
|
|
693
|
+
* Run a grant-session ceremony (purpose="grant-session") bound to a fresh TA
|
|
694
|
+
* challenge — required by {@link signGrantSession} / {@link signP256GrantSession}
|
|
695
|
+
* (the generic 'authentication' challenge is rejected there for replay safety).
|
|
696
|
+
*/
|
|
697
|
+
runGrantSessionCeremony(keyId: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<WebAuthnAssertion>;
|
|
698
|
+
/** Derive an address, running the challenge-binding ceremony internally. */
|
|
699
|
+
deriveAddressWithCeremony(params: {
|
|
700
|
+
KeyId: string;
|
|
701
|
+
DerivationPath: string;
|
|
702
|
+
}, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsDeriveAddressResponse>;
|
|
703
|
+
/**
|
|
704
|
+
* Sign a message or EIP-155 transaction, running the challenge-binding ceremony
|
|
705
|
+
* internally. `params.KeyId` is required (it identifies the wallet to challenge).
|
|
706
|
+
*/
|
|
707
|
+
signWithCeremony(params: Omit<KmsSignRequest, "WebAuthn" | "Passkey"> & {
|
|
708
|
+
KeyId: string;
|
|
709
|
+
}, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsSignResponse>;
|
|
710
|
+
/** Sign a 32-byte digest, running the challenge-binding ceremony internally. */
|
|
711
|
+
signHashWithCeremony(hash: string, target: {
|
|
712
|
+
KeyId: string;
|
|
713
|
+
}, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsSignHashResponse>;
|
|
714
|
+
/** Sign EIP-712 typed data, running the challenge-binding ceremony internally. */
|
|
715
|
+
signTypedDataWithCeremony(params: Omit<KmsSignTypedDataRequest, "webAuthnAssertion">, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsSignTypedDataResponse>;
|
|
716
|
+
/**
|
|
717
|
+
* Sign a GRANT_SESSION_V2 hash, running the grant-session ceremony internally
|
|
718
|
+
* (uses the purpose-bound `begin-grant-session-auth` challenge).
|
|
719
|
+
*/
|
|
720
|
+
signGrantSessionWithCeremony(params: Omit<KmsSignGrantSessionRequest, "webAuthnAssertion">, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsSignGrantSessionResponse>;
|
|
721
|
+
/**
|
|
722
|
+
* Sign a GRANT_P256_SESSION_V2 hash, running the grant-session ceremony
|
|
723
|
+
* internally (uses the purpose-bound `begin-grant-session-auth` challenge).
|
|
724
|
+
*/
|
|
725
|
+
signP256GrantSessionWithCeremony(params: Omit<KmsSignP256GrantSessionRequest, "webAuthnAssertion">, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsSignGrantSessionResponse>;
|
|
726
|
+
beginRegistration(params: KmsBeginRegistrationRequest): Promise<KmsBeginRegistrationResponse>;
|
|
727
|
+
completeRegistration(params: KmsCompleteRegistrationRequest): Promise<KmsCompleteRegistrationResponse>;
|
|
728
|
+
beginAuthentication(params: KmsBeginAuthenticationRequest): Promise<KmsBeginAuthenticationResponse>;
|
|
729
|
+
/**
|
|
730
|
+
* Begin a generic WebAuthn authentication ceremony for a key, returning a
|
|
731
|
+
* challenge usable for SignHash / SignTypedData (purpose="authentication").
|
|
732
|
+
*
|
|
733
|
+
* NOTE: there is no dedicated `begin-webauthn-auth` endpoint — this delegates
|
|
734
|
+
* to `POST /BeginAuthentication`. (Grant-session signing needs a purpose-bound
|
|
735
|
+
* challenge from {@link beginGrantSessionAuth} instead.)
|
|
736
|
+
*/
|
|
737
|
+
beginWebAuthnAuth(keyId: string): Promise<KmsBeginAuthenticationResponse>;
|
|
738
|
+
createKmsSigner(keyId: string, address: string, assertionProvider: () => Promise<LegacyPasskeyAssertion>): KmsSigner;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* KMS-backed signer with Passkey assertion.
|
|
742
|
+
*
|
|
743
|
+
* Each signing operation calls the `assertionProvider` to obtain a Legacy
|
|
744
|
+
* Passkey assertion, which is then passed to KMS SignHash. The Legacy format
|
|
745
|
+
* is reusable (no challenge consumption), enabling BLS dual-signing.
|
|
746
|
+
*
|
|
747
|
+
* Narrowed during the ethers -> viem migration: only the EIP-191 personal-sign
|
|
748
|
+
* and address-read behaviour is actually consumed by the SDK, so the former
|
|
749
|
+
* ethers.AbstractSigner surface (signTransaction / signTypedData / connect /
|
|
750
|
+
* provider) has been dropped.
|
|
751
|
+
*/
|
|
752
|
+
declare class KmsSigner {
|
|
753
|
+
private readonly keyId;
|
|
754
|
+
private readonly _address;
|
|
755
|
+
private readonly kmsManager;
|
|
756
|
+
private readonly assertionProvider;
|
|
757
|
+
constructor(keyId: string, _address: string, kmsManager: KmsManager, assertionProvider: () => Promise<LegacyPasskeyAssertion>);
|
|
758
|
+
getAddress(): Promise<string>;
|
|
759
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Context for passing Passkey assertion data through the signing chain.
|
|
764
|
+
* Used by KMS-backed signers to authenticate signing operations.
|
|
765
|
+
*/
|
|
766
|
+
interface PasskeyAssertionContext {
|
|
767
|
+
assertion: LegacyPasskeyAssertion;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Pluggable signer adapter — replaces NestJS AuthService wallet management.
|
|
771
|
+
* Implement this to provide signing capabilities from your key management system.
|
|
772
|
+
*
|
|
773
|
+
* Narrow by design: the only operations the SDK performs are EOA address
|
|
774
|
+
* lookup and EIP-191 personal-sign over a digest. There is no transaction
|
|
775
|
+
* signing / provider connection — that lives in the bundler/UserOp path.
|
|
776
|
+
*/
|
|
777
|
+
interface ISignerAdapter {
|
|
778
|
+
/** Get the EOA address for a given user. */
|
|
779
|
+
getAddress(userId: string): Promise<`0x${string}`>;
|
|
780
|
+
/**
|
|
781
|
+
* Sign a message for a given user, applying EIP-191 personal-sign semantics
|
|
782
|
+
* (equivalent to ethers `signer.signMessage(bytes)` / viem
|
|
783
|
+
* `account.signMessage({ raw: bytes })`). A `Uint8Array` (or raw `0x` hex) is
|
|
784
|
+
* signed as raw bytes — callers pass a 32-byte digest, NOT UTF-8 text.
|
|
785
|
+
*
|
|
786
|
+
* @param ctx optional Passkey assertion context for KMS-backed signers.
|
|
787
|
+
*/
|
|
788
|
+
signMessage(userId: string, message: `0x${string}` | Uint8Array, ctx?: PasskeyAssertionContext): Promise<`0x${string}`>;
|
|
789
|
+
/**
|
|
790
|
+
* Ensure a signer exists for the user (create on demand if needed).
|
|
791
|
+
* Returns the signer's address.
|
|
792
|
+
*/
|
|
793
|
+
ensureSigner(userId: string): Promise<{
|
|
794
|
+
address: `0x${string}`;
|
|
795
|
+
}>;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Per-version EntryPoint configuration.
|
|
800
|
+
*/
|
|
801
|
+
interface EntryPointVersionConfig {
|
|
802
|
+
entryPointAddress: string;
|
|
803
|
+
factoryAddress: string;
|
|
804
|
+
validatorAddress: string;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Server SDK configuration — replaces NestJS ConfigService.
|
|
808
|
+
*/
|
|
809
|
+
interface ServerConfig {
|
|
810
|
+
/** Main network RPC URL. */
|
|
811
|
+
rpcUrl: string;
|
|
812
|
+
/** Bundler RPC URL (e.g. Pimlico, StackUp). */
|
|
813
|
+
bundlerRpcUrl: string;
|
|
814
|
+
/** Chain ID of the target network. */
|
|
815
|
+
chainId: number;
|
|
816
|
+
/** EntryPoint configurations — at least one version must be provided. */
|
|
817
|
+
entryPoints: {
|
|
818
|
+
v06?: EntryPointVersionConfig;
|
|
819
|
+
v07?: EntryPointVersionConfig;
|
|
820
|
+
v08?: EntryPointVersionConfig;
|
|
821
|
+
};
|
|
822
|
+
/** Default EntryPoint version to use when not specified. */
|
|
823
|
+
defaultVersion?: "0.6" | "0.7" | "0.8";
|
|
824
|
+
/** BLS signer seed nodes for gossip discovery. */
|
|
825
|
+
blsSeedNodes?: string[];
|
|
826
|
+
/** Timeout for BLS node discovery in ms. */
|
|
827
|
+
blsDiscoveryTimeout?: number;
|
|
828
|
+
/** KMS endpoint URL (optional, for KMS-based signing). */
|
|
829
|
+
kmsEndpoint?: string;
|
|
830
|
+
/** Whether KMS signing is enabled. */
|
|
831
|
+
kmsEnabled?: boolean;
|
|
832
|
+
/** KMS API key for authenticated requests. */
|
|
833
|
+
kmsApiKey?: string;
|
|
834
|
+
/** Storage adapter (required). */
|
|
835
|
+
storage: IStorageAdapter;
|
|
836
|
+
/** Signer adapter (required). */
|
|
837
|
+
signer: ISignerAdapter;
|
|
838
|
+
/** Logger (optional, defaults to ConsoleLogger). */
|
|
839
|
+
logger?: ILogger;
|
|
840
|
+
}
|
|
841
|
+
/** AirAccount contract version selection.
|
|
842
|
+
* - "M7" — r4 audit-final (default). Use for all new account creation.
|
|
843
|
+
* - "M7r6" — r6 deployment (2026-03-29, superseded). Use ONLY to recover existing r6-deployed accounts.
|
|
844
|
+
* - "M5" — legacy 6-field InitConfig deployment.
|
|
845
|
+
*/
|
|
846
|
+
type AirAccountVersion = "M5" | "M7" | "M7r6";
|
|
847
|
+
/**
|
|
848
|
+
* Build a pre-configured EntryPointVersionConfig for Sepolia using a known AirAccount deployment.
|
|
849
|
+
* Eliminates the need to look up contract addresses manually.
|
|
850
|
+
*
|
|
851
|
+
* @example
|
|
852
|
+
* // Use M7 r4 audit-final (default)
|
|
853
|
+
* const config = { entryPoints: { v07: sepoliaV07Config() }, ... };
|
|
854
|
+
*
|
|
855
|
+
* // Recover an existing r6-deployed account (do NOT use for new accounts)
|
|
856
|
+
* const config = { entryPoints: { v07: sepoliaV07Config("M7r6") }, ... };
|
|
857
|
+
*
|
|
858
|
+
* // Use M5 legacy
|
|
859
|
+
* const config = { entryPoints: { v07: sepoliaV07Config("M5") }, ... };
|
|
860
|
+
*/
|
|
861
|
+
declare function sepoliaV07Config(version?: AirAccountVersion): EntryPointVersionConfig;
|
|
862
|
+
/**
|
|
863
|
+
* Validate a ServerConfig and throw descriptive errors for missing fields.
|
|
864
|
+
*/
|
|
865
|
+
declare function validateConfig(config: ServerConfig): void;
|
|
866
|
+
|
|
867
|
+
declare enum EntryPointVersion {
|
|
868
|
+
V0_6 = "0.6",
|
|
869
|
+
V0_7 = "0.7",
|
|
870
|
+
V0_8 = "0.8"
|
|
871
|
+
}
|
|
872
|
+
interface EntryPointConfig {
|
|
873
|
+
version: EntryPointVersion;
|
|
874
|
+
address: string;
|
|
875
|
+
factoryAddress: string;
|
|
876
|
+
validatorAddress: string;
|
|
877
|
+
}
|
|
878
|
+
/** Default EntryPoint addresses (same on Sepolia, Mainnet, and OP Mainnet). */
|
|
879
|
+
declare const ENTRYPOINT_ADDRESSES: {
|
|
880
|
+
"0.6": {
|
|
881
|
+
sepolia: string;
|
|
882
|
+
mainnet: string;
|
|
883
|
+
optimism: string;
|
|
884
|
+
};
|
|
885
|
+
"0.7": {
|
|
886
|
+
sepolia: string;
|
|
887
|
+
mainnet: string;
|
|
888
|
+
optimism: string;
|
|
889
|
+
};
|
|
890
|
+
"0.8": {
|
|
891
|
+
sepolia: string;
|
|
892
|
+
mainnet: string;
|
|
893
|
+
optimism: string;
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
declare const ENTRYPOINT_ABI_V6: string[];
|
|
897
|
+
declare const ENTRYPOINT_ABI_V7_V8: string[];
|
|
898
|
+
declare const FACTORY_ABI_V6: string[];
|
|
899
|
+
declare const FACTORY_ABI_V7_V8: string[];
|
|
900
|
+
declare const ACCOUNT_ABI: string[];
|
|
901
|
+
declare const VALIDATOR_ABI: string[];
|
|
902
|
+
declare const AIRACCOUNT_ADDRESSES: {
|
|
903
|
+
sepolia: {
|
|
904
|
+
factoryM4: string;
|
|
905
|
+
factoryM5: string;
|
|
906
|
+
/** @deprecated defaultCommunityGuardian was address(0); superseded by r6 and r4. Do not use for new accounts. */
|
|
907
|
+
factoryM7r5Prev: string;
|
|
908
|
+
/** @deprecated Use {@link factory} (r4 audit-final) for new accounts. */
|
|
909
|
+
factoryM7r6: string;
|
|
910
|
+
/** @deprecated Use {@link accountImpl} (r4 audit-final). */
|
|
911
|
+
accountImplM7r6: string;
|
|
912
|
+
/** @deprecated Use {@link compositeValidator} (r4 audit-final). */
|
|
913
|
+
compositeValidatorM7r6: string;
|
|
914
|
+
/** @deprecated Use {@link tierGuardHook} (r4 audit-final). */
|
|
915
|
+
tierGuardHookM7r6: string;
|
|
916
|
+
/** @deprecated Use {@link agentSessionKeyValidator} (r4 audit-final). */
|
|
917
|
+
agentSessionKeyValidatorM7r6: string;
|
|
918
|
+
/** @deprecated Use factory (beta.4) for new accounts. */
|
|
919
|
+
factoryM7r4: string;
|
|
920
|
+
/** @deprecated */
|
|
921
|
+
accountImplM7r4: string;
|
|
922
|
+
/** @deprecated Use validatorRouter. */
|
|
923
|
+
validatorRouterM7r4: string;
|
|
924
|
+
/** @deprecated */
|
|
925
|
+
compositeValidatorM7r4: string;
|
|
926
|
+
/** @deprecated */
|
|
927
|
+
tierGuardHookM7r4: string;
|
|
928
|
+
/** @deprecated */
|
|
929
|
+
agentSessionKeyValidatorM7r4: string;
|
|
930
|
+
factory: "0x52c5190E7308Ea9B149157FF016cC99B6C6bf984";
|
|
931
|
+
factoryM7: "0x52c5190E7308Ea9B149157FF016cC99B6C6bf984";
|
|
932
|
+
accountImpl: "0x7fe62d512f0b8238DE6Ff17175DcE40eA312bBF2";
|
|
933
|
+
validatorRouter: "0xC20A986Bcd5bF5Cc2fE5fFde6b155B8419E0389e";
|
|
934
|
+
blsAlgorithm: "0x68c381Ad3A2e3380F22840008027E9Ec2783F43A";
|
|
935
|
+
blsAggregator: "0x77f7bf95B8602b7851f392F412257539242947e0";
|
|
936
|
+
superPaymaster: "0x030025f40d509b1a99547bAEb3795bD27F7182b7";
|
|
937
|
+
sessionKeyValidator: "0x70de2e36004d6Ddc24DEB80e1Ef76c03EdC0c2AE";
|
|
938
|
+
forceExitModule: "0xd882a16Ea37Be463D1885EF4a397Dbbf157dC211";
|
|
939
|
+
airAccountDelegate: "0xA8D7f70c9D36bC4a4eb14F0dCEE19053FCB3309f";
|
|
940
|
+
airAccountExtension: "0xD61C0F3DE6D98070E9986743d35A56d56855A249";
|
|
941
|
+
agentRegistry: "0x3895b3E6fEf4e121E6289dC7881A0eEd5283C652";
|
|
942
|
+
calldataParserRegistry: "0xb8Af1C039dF88F6bD9fE36Ca683492a3c09e7D17";
|
|
943
|
+
uniswapV3Parser: string;
|
|
944
|
+
};
|
|
945
|
+
};
|
|
946
|
+
declare const AIRACCOUNT_ABI: string[];
|
|
947
|
+
declare const AIRACCOUNT_FACTORY_ABI: string[];
|
|
948
|
+
declare const GLOBAL_GUARD_ABI: string[];
|
|
949
|
+
declare const ERC20_ABI: string[];
|
|
950
|
+
declare const AGENT_SESSION_KEY_VALIDATOR_ABI: string[];
|
|
951
|
+
declare const TIER_GUARD_HOOK_ABI: string[];
|
|
952
|
+
declare const AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI: string[];
|
|
953
|
+
declare const FORCE_EXIT_MODULE_ABI: string[];
|
|
954
|
+
declare const MODULE_TYPE: {
|
|
955
|
+
readonly VALIDATOR: 1;
|
|
956
|
+
readonly EXECUTOR: 2;
|
|
957
|
+
readonly FALLBACK: 3;
|
|
958
|
+
readonly HOOK: 4;
|
|
959
|
+
};
|
|
960
|
+
declare const ALG_ID: {
|
|
961
|
+
readonly BLS: 1;
|
|
962
|
+
readonly ECDSA: 2;
|
|
963
|
+
readonly P256: 3;
|
|
964
|
+
readonly CUMULATIVE_T2: 4;
|
|
965
|
+
readonly CUMULATIVE_T3: 5;
|
|
966
|
+
readonly COMBINED_T1: 6;
|
|
967
|
+
readonly WEIGHTED: 7;
|
|
968
|
+
readonly SESSION_KEY: 8;
|
|
969
|
+
readonly AGENT_SESSION_KEY: 9;
|
|
970
|
+
};
|
|
971
|
+
declare const SESSION_KEY_VALIDATOR_ABI: string[];
|
|
972
|
+
declare const CALLDATA_PARSER_REGISTRY_ABI: string[];
|
|
973
|
+
declare const AIR_ACCOUNT_DELEGATE_ABI: string[];
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* A viem contract instance bound to a read-only PublicClient.
|
|
977
|
+
*
|
|
978
|
+
* The EntryPoint/AirAccount ABIs are loaded from human-readable signatures via
|
|
979
|
+
* `parseAbi`, which yields the loosely-typed `Abi` shape. As a result `read`/`write`
|
|
980
|
+
* method access is not statically typed per-function; callers index by name and the
|
|
981
|
+
* returned value is `unknown` (cast at the call site). This mirrors the dynamic
|
|
982
|
+
* surface that `ethers.Contract` previously exposed.
|
|
983
|
+
*/
|
|
984
|
+
type ViemContractMethods = Record<string, (...args: unknown[]) => Promise<unknown>>;
|
|
985
|
+
interface ViemContract {
|
|
986
|
+
address: Address;
|
|
987
|
+
abi: Abi;
|
|
988
|
+
/** Read (view/pure) calls: `contract.read.fnName([...args])`. */
|
|
989
|
+
read: ViemContractMethods;
|
|
990
|
+
/** State-changing calls (requires a wallet client — not provided by this read-only hub). */
|
|
991
|
+
write: ViemContractMethods;
|
|
992
|
+
estimateGas: ViemContractMethods;
|
|
993
|
+
simulate: ViemContractMethods;
|
|
994
|
+
getEvents: ViemContractMethods;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Unified Ethereum provider — replaces NestJS EthereumService.
|
|
998
|
+
* Manages RPC + Bundler clients (viem) and contract interactions.
|
|
999
|
+
*/
|
|
1000
|
+
declare class EthereumProvider {
|
|
1001
|
+
/** Main-network read client. Pass to viem getContract / readContract calls. */
|
|
1002
|
+
private readonly provider;
|
|
1003
|
+
/** Bundler client — used only for raw eth_ / pimlico_ userOp JSON-RPC. */
|
|
1004
|
+
private readonly bundlerProvider;
|
|
1005
|
+
private readonly config;
|
|
1006
|
+
private readonly logger;
|
|
1007
|
+
constructor(config: ServerConfig);
|
|
1008
|
+
/** Returns the viem PublicClient for the main network RPC. */
|
|
1009
|
+
getProvider(): PublicClient;
|
|
1010
|
+
/** Returns the viem PublicClient bound to the bundler RPC (raw .request only). */
|
|
1011
|
+
getBundlerProvider(): PublicClient;
|
|
1012
|
+
/**
|
|
1013
|
+
* Raw bundler JSON-RPC call. The bundler exposes non-standard methods
|
|
1014
|
+
* (eth_sendUserOperation, pimlico_getUserOperationGasPrice, ...) that are not in
|
|
1015
|
+
* viem's typed RPC schema, so we go through the transport's request fn untyped.
|
|
1016
|
+
*/
|
|
1017
|
+
private bundlerRequest;
|
|
1018
|
+
private getVersionConfig;
|
|
1019
|
+
getEntryPointAddress(version: EntryPointVersion): string;
|
|
1020
|
+
getFactoryAddress(version: EntryPointVersion): string;
|
|
1021
|
+
getValidatorAddress(version: EntryPointVersion): string;
|
|
1022
|
+
getDefaultVersion(): EntryPointVersion;
|
|
1023
|
+
/** Build a read-only viem contract bound to the main-network PublicClient. */
|
|
1024
|
+
private contractAt;
|
|
1025
|
+
getFactoryContract(version?: EntryPointVersion): ViemContract;
|
|
1026
|
+
getEntryPointContract(version?: EntryPointVersion): ViemContract;
|
|
1027
|
+
getValidatorContract(version?: EntryPointVersion): ViemContract;
|
|
1028
|
+
getAccountContract(address: string): ViemContract;
|
|
1029
|
+
getAgentSessionKeyValidatorContract(address?: string): ViemContract;
|
|
1030
|
+
getTierGuardHookContract(address?: string): ViemContract;
|
|
1031
|
+
getCompositeValidatorContract(address?: string): ViemContract;
|
|
1032
|
+
getForceExitModuleContract(address: string): ViemContract;
|
|
1033
|
+
getBalance(address: string): Promise<string>;
|
|
1034
|
+
getNonce(accountAddress: string, key?: number, version?: EntryPointVersion): Promise<bigint>;
|
|
1035
|
+
getUserOpHash(userOp: UserOperation | PackedUserOperation, version?: EntryPointVersion): Promise<string>;
|
|
1036
|
+
estimateUserOperationGas(userOp: unknown, version?: EntryPointVersion): Promise<{
|
|
1037
|
+
callGasLimit: string;
|
|
1038
|
+
verificationGasLimit: string;
|
|
1039
|
+
preVerificationGas: string;
|
|
1040
|
+
}>;
|
|
1041
|
+
sendUserOperation(userOp: unknown, version?: EntryPointVersion): Promise<string>;
|
|
1042
|
+
getUserOperationReceipt(userOpHash: string): Promise<unknown>;
|
|
1043
|
+
waitForUserOp(userOpHash: string, maxAttempts?: number): Promise<string>;
|
|
1044
|
+
getUserOperationGasPrice(): Promise<{
|
|
1045
|
+
maxFeePerGas: string;
|
|
1046
|
+
maxPriorityFeePerGas: string;
|
|
1047
|
+
}>;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Account manager — extracted from NestJS AccountService.
|
|
1052
|
+
* Creates and retrieves smart accounts without framework dependencies.
|
|
1053
|
+
*/
|
|
1054
|
+
declare class AccountManager {
|
|
1055
|
+
private readonly ethereum;
|
|
1056
|
+
private readonly storage;
|
|
1057
|
+
private readonly signer;
|
|
1058
|
+
private readonly logger;
|
|
1059
|
+
constructor(ethereum: EthereumProvider, storage: IStorageAdapter, signer: ISignerAdapter, logger?: ILogger);
|
|
1060
|
+
createAccount(userId: string, options?: {
|
|
1061
|
+
entryPointVersion?: EntryPointVersion;
|
|
1062
|
+
salt?: number | bigint;
|
|
1063
|
+
/** Daily transfer limit in wei. When > 0 the account is created with on-chain guard enforcement. */
|
|
1064
|
+
dailyLimit?: bigint;
|
|
1065
|
+
}): Promise<AccountRecord>;
|
|
1066
|
+
getAccount(userId: string): Promise<(AccountRecord & {
|
|
1067
|
+
balance: string;
|
|
1068
|
+
nonce: string;
|
|
1069
|
+
}) | null>;
|
|
1070
|
+
getAccountAddress(userId: string): Promise<string>;
|
|
1071
|
+
getAccountBalance(userId: string): Promise<{
|
|
1072
|
+
address: string;
|
|
1073
|
+
balance: string;
|
|
1074
|
+
balanceInWei: string;
|
|
1075
|
+
}>;
|
|
1076
|
+
getAccountNonce(userId: string): Promise<{
|
|
1077
|
+
address: string;
|
|
1078
|
+
nonce: string;
|
|
1079
|
+
}>;
|
|
1080
|
+
getAccountByUserId(userId: string): Promise<AccountRecord | null>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Build the acceptance hash that guardian devices must sign before account creation.
|
|
1083
|
+
*
|
|
1084
|
+
* Encoding: keccak256(solidityPacked(
|
|
1085
|
+
* ["string","uint256","address","address","uint256","uint256"],
|
|
1086
|
+
* ["ACCEPT_GUARDIAN", chainId, factoryAddress, owner, salt, dailyLimit]
|
|
1087
|
+
* ))
|
|
1088
|
+
*
|
|
1089
|
+
* dailyLimit is bound in the hash (PR #47 / C-3) to prevent a front-runner from
|
|
1090
|
+
* replaying guardian sigs with a weaker limit on the same counterfactual address.
|
|
1091
|
+
*
|
|
1092
|
+
* Returns the RAW keccak256 hash (no EIP-191 prefix).
|
|
1093
|
+
* Guardians MUST sign via personal_sign / ethers.signMessage(ethers.getBytes(hash)).
|
|
1094
|
+
* Do NOT use eth_sign — the EIP-191 "\x19Ethereum Signed Message:\n32" prefix
|
|
1095
|
+
* is applied inside the contract (toEthSignedMessageHash) before ecrecover, not here.
|
|
1096
|
+
*
|
|
1097
|
+
* @returns raw hex keccak256 hash — encode this into the QR code shown to guardian devices
|
|
1098
|
+
*/
|
|
1099
|
+
buildGuardianAcceptanceHash(owner: string, salt: number | bigint, factoryAddress: string, chainId: number, dailyLimit: bigint): string;
|
|
1100
|
+
/**
|
|
1101
|
+
* Encode calldata for modifyTierLimitsWithGuardians() — guardian-gated tier-limit change (PR #43).
|
|
1102
|
+
*
|
|
1103
|
+
* Both tier1 and tier2 can be raised or lowered, subject to guardian approval.
|
|
1104
|
+
* Caller is responsible for building and submitting the resulting UserOp.
|
|
1105
|
+
*
|
|
1106
|
+
* @param tier1 New Tier-1 ceiling in wei (ECDSA-only spending; 0 = no limit)
|
|
1107
|
+
* @param tier2 New Tier-2 ceiling in wei (dual-factor; 0 = no limit)
|
|
1108
|
+
* @param deadline Unix timestamp — guardian sigs rejected after this
|
|
1109
|
+
* @param guardianSigs 65-byte EIP-191 hex signatures from required guardians
|
|
1110
|
+
*/
|
|
1111
|
+
encodeModifyTierLimits(tier1: bigint, tier2: bigint, deadline: bigint, guardianSigs: string[]): string;
|
|
1112
|
+
/**
|
|
1113
|
+
* Create an AirAccount with 3 on-chain guardians:
|
|
1114
|
+
* - guardian1 and guardian2: user's own devices (passkeys on phone 1 and phone 2)
|
|
1115
|
+
* - guardian3: team Safe multisig (defaultCommunityGuardian, set in factory at deploy time)
|
|
1116
|
+
*
|
|
1117
|
+
* Both guardian1 and guardian2 must sign the acceptance hash produced by
|
|
1118
|
+
* buildGuardianAcceptanceHash() before this method is called.
|
|
1119
|
+
*
|
|
1120
|
+
* Recovery: any 2-of-3 guardians can initiate social recovery after a 48h timelock.
|
|
1121
|
+
*/
|
|
1122
|
+
createAccountWithGuardians(userId: string, params: {
|
|
1123
|
+
guardian1: string;
|
|
1124
|
+
guardian1Sig: string;
|
|
1125
|
+
guardian2: string;
|
|
1126
|
+
guardian2Sig: string;
|
|
1127
|
+
dailyLimit: bigint;
|
|
1128
|
+
salt?: number | bigint;
|
|
1129
|
+
entryPointVersion?: EntryPointVersion;
|
|
1130
|
+
}): Promise<AccountRecord>;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Minimal guardian signer surface (was `ethers.Signer`): an external signer that
|
|
1135
|
+
* performs an EIP-191 personal-sign over raw bytes and returns a 0x-prefixed
|
|
1136
|
+
* 65-byte hex signature. Structural — any ethers/viem signer with this method fits.
|
|
1137
|
+
*/
|
|
1138
|
+
interface GuardianSigner {
|
|
1139
|
+
signMessage(message: Uint8Array): Promise<string>;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* Raised when a DVT node (aNode YetAnotherAA-Validator ≥ v1.3.0, running with
|
|
1144
|
+
* `CONFIRM_ENABLED=true`) withholds its co-signature on a high-value op pending
|
|
1145
|
+
* out-of-band approval. The node returns `{ status: "pending_confirmation",
|
|
1146
|
+
* userOpHash }` instead of a signature; the withheld co-sign is released by
|
|
1147
|
+
* `POST /signature/confirm { userOpHash, token }` once the user approves over an
|
|
1148
|
+
* independent channel (single-use token, TTL, fail-closed). The SDK surfaces this
|
|
1149
|
+
* as a typed error rather than silently dropping the node so callers can drive the
|
|
1150
|
+
* confirm flow. Default-off nodes never emit this (behaviour == v1.2.0).
|
|
1151
|
+
*/
|
|
1152
|
+
declare class DvtPendingConfirmationError extends Error {
|
|
1153
|
+
readonly userOpHash: string;
|
|
1154
|
+
readonly nodeEndpoint: string;
|
|
1155
|
+
constructor(userOpHash: string, nodeEndpoint: string);
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Type guard for a DVT v1.3.0 `/signature/sign` response that withheld its
|
|
1159
|
+
* co-signature pending out-of-band confirmation (`{ status: "pending_confirmation",
|
|
1160
|
+
* userOpHash }`). Used at every sign call site so a high-value-op withhold is
|
|
1161
|
+
* surfaced, not mistaken for a signature-less failure. Default-off nodes never
|
|
1162
|
+
* return this shape.
|
|
1163
|
+
*/
|
|
1164
|
+
declare function isPendingConfirmation(data: unknown): data is {
|
|
1165
|
+
status: "pending_confirmation";
|
|
1166
|
+
userOpHash?: string;
|
|
1167
|
+
};
|
|
1168
|
+
/**
|
|
1169
|
+
* BLS signature service — extracted from NestJS BlsService.
|
|
1170
|
+
* Uses lazy initialization instead of onModuleInit.
|
|
1171
|
+
*/
|
|
1172
|
+
declare class BLSSignatureService {
|
|
1173
|
+
private readonly config;
|
|
1174
|
+
private readonly ethereum;
|
|
1175
|
+
private readonly storage;
|
|
1176
|
+
private readonly signer;
|
|
1177
|
+
private blsManager;
|
|
1178
|
+
private readonly logger;
|
|
1179
|
+
constructor(config: ServerConfig, ethereum: EthereumProvider, storage: IStorageAdapter, signer: ISignerAdapter, logger?: ILogger);
|
|
1180
|
+
/** Lazy-initialize BLSManager on first use. */
|
|
1181
|
+
private ensureInitialized;
|
|
1182
|
+
getActiveSignerNodes(): Promise<unknown[]>;
|
|
1183
|
+
generateBLSSignature(userId: string, userOpHash: string, ctx?: PasskeyAssertionContext): Promise<BLSSignatureData>;
|
|
1184
|
+
packSignature(blsData: BLSSignatureData): Promise<string>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Generate a tiered signature based on the required tier level.
|
|
1187
|
+
*
|
|
1188
|
+
* - Tier 1: raw 65-byte ECDSA (no algId prefix, backwards-compat)
|
|
1189
|
+
* - Tier 2: algId 0x04 — P256 + BLS aggregate + messagePoint ECDSA
|
|
1190
|
+
* - Tier 3: algId 0x05 — P256 + BLS + messagePoint ECDSA + Guardian ECDSA
|
|
1191
|
+
*
|
|
1192
|
+
* @param tier - Required tier level (1, 2, or 3)
|
|
1193
|
+
* @param userId - User ID for account lookup
|
|
1194
|
+
* @param userOpHash - The UserOp hash to sign
|
|
1195
|
+
* @param p256Signature - P256 passkey signature (64 bytes, required for tier 2/3)
|
|
1196
|
+
* @param guardianSigner - Guardian signer (required for tier 3)
|
|
1197
|
+
* @param ctx - Optional passkey assertion context for KMS signing
|
|
1198
|
+
*/
|
|
1199
|
+
generateTieredSignature(params: {
|
|
1200
|
+
tier: TierLevel$1;
|
|
1201
|
+
userId: string;
|
|
1202
|
+
userOpHash: string;
|
|
1203
|
+
p256Signature?: string;
|
|
1204
|
+
guardianSigner?: GuardianSigner;
|
|
1205
|
+
ctx?: PasskeyAssertionContext;
|
|
1206
|
+
}): Promise<string>;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Pre-checks transactions against GlobalGuard before submitting on-chain.
|
|
1211
|
+
* Avoids wasted gas from predictable reverts.
|
|
1212
|
+
*/
|
|
1213
|
+
declare class GuardChecker {
|
|
1214
|
+
private readonly ethereum;
|
|
1215
|
+
private readonly logger;
|
|
1216
|
+
constructor(ethereum: EthereumProvider, logger?: ILogger);
|
|
1217
|
+
/**
|
|
1218
|
+
* Fetch tier limits from an AirAccount contract.
|
|
1219
|
+
*/
|
|
1220
|
+
fetchTierConfig(accountAddress: string): Promise<TierConfig>;
|
|
1221
|
+
/**
|
|
1222
|
+
* Fetch guard status from the account's GlobalGuard.
|
|
1223
|
+
*/
|
|
1224
|
+
fetchGuardStatus(accountAddress: string): Promise<GuardStatus>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Pre-check a transaction: determine tier, check guard limits and algorithm approval.
|
|
1227
|
+
* Returns errors array (empty = OK to proceed).
|
|
1228
|
+
*/
|
|
1229
|
+
preCheck(accountAddress: string, value: bigint): Promise<PreCheckResult>;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* Thrown when a paymaster's on-chain price cache is stale.
|
|
1234
|
+
* Caller should invoke `paymasterManager.updatePrice(paymasterAddress)` before retrying.
|
|
1235
|
+
*/
|
|
1236
|
+
declare class PaymasterPriceStalenessError extends Error {
|
|
1237
|
+
readonly paymasterAddress: string;
|
|
1238
|
+
readonly ageSeconds: number;
|
|
1239
|
+
readonly thresholdSeconds: number;
|
|
1240
|
+
constructor(paymasterAddress: string, ageSeconds: number, thresholdSeconds: number);
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Paymaster manager — extracted from NestJS PaymasterService.
|
|
1244
|
+
* Storage via IStorageAdapter instead of filesystem JSON files.
|
|
1245
|
+
*/
|
|
1246
|
+
declare class PaymasterManager {
|
|
1247
|
+
private readonly ethereum;
|
|
1248
|
+
private readonly storage;
|
|
1249
|
+
private readonly logger;
|
|
1250
|
+
constructor(ethereum: EthereumProvider, storage: IStorageAdapter, logger?: ILogger);
|
|
1251
|
+
getAvailablePaymasters(userId: string): Promise<{
|
|
1252
|
+
name: string;
|
|
1253
|
+
address: string;
|
|
1254
|
+
configured: boolean;
|
|
1255
|
+
}[]>;
|
|
1256
|
+
addCustomPaymaster(userId: string, name: string, address: string, type?: "pimlico" | "stackup" | "alchemy" | "custom", apiKey?: string, endpoint?: string): Promise<void>;
|
|
1257
|
+
removeCustomPaymaster(userId: string, name: string): Promise<boolean>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Check whether a paymaster's on-chain price cache is still fresh.
|
|
1260
|
+
* Returns `{ fresh, ageSeconds, thresholdSeconds }`.
|
|
1261
|
+
* Throws if the contract does not implement `cachedPriceTimestamp()` / `priceStalenessThreshold()`.
|
|
1262
|
+
*/
|
|
1263
|
+
checkPriceFreshness(paymasterAddress: string): Promise<{
|
|
1264
|
+
fresh: boolean;
|
|
1265
|
+
ageSeconds: number;
|
|
1266
|
+
thresholdSeconds: number;
|
|
1267
|
+
}>;
|
|
1268
|
+
/**
|
|
1269
|
+
* Call `updatePrice()` on a paymaster contract (permissionless).
|
|
1270
|
+
* Useful when `checkPriceFreshness()` reports stale price.
|
|
1271
|
+
*
|
|
1272
|
+
* @param walletClient - A viem WalletClient (with an account) that will send
|
|
1273
|
+
* the transaction (must have gas). Replaces the former ethers Signer param.
|
|
1274
|
+
*/
|
|
1275
|
+
updatePrice(paymasterAddress: string, walletClient: WalletClient): Promise<string>;
|
|
1276
|
+
getPaymasterData(userId: string, paymasterName: string, userOp: unknown, entryPoint: string, customAddress?: string, options?: {
|
|
1277
|
+
tokenAddress?: string;
|
|
1278
|
+
}): Promise<string>;
|
|
1279
|
+
private getPimlicoPaymasterData;
|
|
1280
|
+
private getStackUpPaymasterData;
|
|
1281
|
+
private getAlchemyPaymasterData;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
interface TokenInfo {
|
|
1285
|
+
address: string;
|
|
1286
|
+
symbol: string;
|
|
1287
|
+
name: string;
|
|
1288
|
+
decimals: number;
|
|
1289
|
+
}
|
|
1290
|
+
interface TokenBalance {
|
|
1291
|
+
token: TokenInfo;
|
|
1292
|
+
balance: string;
|
|
1293
|
+
formattedBalance: string;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Token service — extracted from NestJS TokenService.
|
|
1297
|
+
* Only on-chain queries and calldata generation (no preset token list).
|
|
1298
|
+
*/
|
|
1299
|
+
declare class TokenService {
|
|
1300
|
+
private readonly ethereum;
|
|
1301
|
+
constructor(ethereum: EthereumProvider);
|
|
1302
|
+
getTokenInfo(tokenAddress: string): Promise<TokenInfo>;
|
|
1303
|
+
getTokenBalance(tokenAddress: string, walletAddress: string): Promise<string>;
|
|
1304
|
+
getFormattedTokenBalance(tokenAddress: string, walletAddress: string): Promise<TokenBalance>;
|
|
1305
|
+
generateTransferCalldata(to: string, amount: string, decimals: number): string;
|
|
1306
|
+
validateToken(tokenAddress: string): Promise<{
|
|
1307
|
+
isValid: boolean;
|
|
1308
|
+
token?: TokenInfo;
|
|
1309
|
+
error?: string;
|
|
1310
|
+
}>;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
interface ExecuteTransferParams {
|
|
1314
|
+
to: string;
|
|
1315
|
+
amount: string;
|
|
1316
|
+
data?: string;
|
|
1317
|
+
tokenAddress?: string;
|
|
1318
|
+
usePaymaster?: boolean;
|
|
1319
|
+
paymasterAddress?: string;
|
|
1320
|
+
paymasterData?: string;
|
|
1321
|
+
/** ERC-20 token address for deposit-pull paymasters (e.g. PMv4) that require
|
|
1322
|
+
* the gas token address appended to paymasterData. Used when the paymaster
|
|
1323
|
+
* contract does not expose a public token() getter for auto-detection. */
|
|
1324
|
+
paymasterTokenAddress?: string;
|
|
1325
|
+
passkeyAssertion?: LegacyPasskeyAssertion;
|
|
1326
|
+
/** P256 passkey signature (64 bytes hex). Required for AirAccount Tier 2/3. */
|
|
1327
|
+
p256Signature?: string;
|
|
1328
|
+
/** Guardian signer instance. Required for AirAccount Tier 3. */
|
|
1329
|
+
guardianSigner?: GuardianSigner;
|
|
1330
|
+
/** Enable AirAccount tiered signature routing. Default: false (legacy BLS-only). */
|
|
1331
|
+
useAirAccountTiering?: boolean;
|
|
1332
|
+
/**
|
|
1333
|
+
* Wrap the execute()/executeBatch() callData with the `executeUserOp` selector
|
|
1334
|
+
* (v0.17.2-beta.4 bundler-compat). REQUIRED for guard-enabled accounts submitted
|
|
1335
|
+
* through a standard ERC-4337 bundler; the account re-derives the signature algId
|
|
1336
|
+
* in-frame. Default: false. No-guard accounts and owner-direct calls leave it off.
|
|
1337
|
+
*/
|
|
1338
|
+
wrapExecuteUserOp?: boolean;
|
|
1339
|
+
}
|
|
1340
|
+
interface EstimateGasParams {
|
|
1341
|
+
to: string;
|
|
1342
|
+
amount: string;
|
|
1343
|
+
data?: string;
|
|
1344
|
+
tokenAddress?: string;
|
|
1345
|
+
/** Match the executeUserOp wrapping used at submission so gas estimation is accurate (v0.17.2-beta.4). */
|
|
1346
|
+
wrapExecuteUserOp?: boolean;
|
|
1347
|
+
}
|
|
1348
|
+
interface TransferResult {
|
|
1349
|
+
success: boolean;
|
|
1350
|
+
transferId: string;
|
|
1351
|
+
userOpHash: string;
|
|
1352
|
+
status: string;
|
|
1353
|
+
message: string;
|
|
1354
|
+
from: string;
|
|
1355
|
+
to: string;
|
|
1356
|
+
amount: string;
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Transfer manager — extracted from NestJS TransferService.
|
|
1360
|
+
* No passkey verification: callers are responsible for their own auth.
|
|
1361
|
+
*/
|
|
1362
|
+
declare class TransferManager {
|
|
1363
|
+
private readonly ethereum;
|
|
1364
|
+
private readonly accountManager;
|
|
1365
|
+
private readonly blsService;
|
|
1366
|
+
private readonly paymasterManager;
|
|
1367
|
+
private readonly tokenService;
|
|
1368
|
+
private readonly storage;
|
|
1369
|
+
private readonly signer;
|
|
1370
|
+
private readonly logger;
|
|
1371
|
+
private readonly guardChecker;
|
|
1372
|
+
constructor(ethereum: EthereumProvider, accountManager: AccountManager, blsService: BLSSignatureService, paymasterManager: PaymasterManager, tokenService: TokenService, storage: IStorageAdapter, signer: ISignerAdapter, logger?: ILogger, guardChecker?: GuardChecker);
|
|
1373
|
+
executeTransfer(userId: string, params: ExecuteTransferParams): Promise<TransferResult>;
|
|
1374
|
+
private processTransferAsync;
|
|
1375
|
+
estimateGas(userId: string, params: EstimateGasParams): Promise<{
|
|
1376
|
+
callGasLimit: string;
|
|
1377
|
+
verificationGasLimit: string;
|
|
1378
|
+
preVerificationGas: string;
|
|
1379
|
+
validatorGasEstimate: string;
|
|
1380
|
+
totalGasEstimate: string;
|
|
1381
|
+
maxFeePerGas: string;
|
|
1382
|
+
maxPriorityFeePerGas: string;
|
|
1383
|
+
}>;
|
|
1384
|
+
getTransferStatus(userId: string, transferId: string): Promise<Record<string, unknown>>;
|
|
1385
|
+
getTransferHistory(userId: string, page?: number, limit?: number): Promise<{
|
|
1386
|
+
transfers: TransferRecord[];
|
|
1387
|
+
total: number;
|
|
1388
|
+
page: number;
|
|
1389
|
+
limit: number;
|
|
1390
|
+
totalPages: number;
|
|
1391
|
+
}>;
|
|
1392
|
+
private buildUserOperation;
|
|
1393
|
+
private formatUserOpForBundler;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Thin wrapper around ISignerAdapter for consistent wallet access.
|
|
1398
|
+
*/
|
|
1399
|
+
declare class WalletManager {
|
|
1400
|
+
private readonly signer;
|
|
1401
|
+
constructor(signer: ISignerAdapter);
|
|
1402
|
+
getAddress(userId: string): Promise<`0x${string}`>;
|
|
1403
|
+
signMessage(userId: string, message: `0x${string}` | Uint8Array, ctx?: PasskeyAssertionContext): Promise<`0x${string}`>;
|
|
1404
|
+
ensureSigner(userId: string): Promise<{
|
|
1405
|
+
address: `0x${string}`;
|
|
1406
|
+
}>;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Main facade for the YAAA Server SDK.
|
|
1411
|
+
* Wires all services together from a single config object.
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```ts
|
|
1415
|
+
* import { AirAccountServerClient, MemoryStorage, LocalWalletSigner } from '@aastar/airaccount/server';
|
|
1416
|
+
*
|
|
1417
|
+
* const client = new AirAccountServerClient({
|
|
1418
|
+
* rpcUrl: 'https://sepolia.infura.io/v3/...',
|
|
1419
|
+
* bundlerRpcUrl: 'https://api.pimlico.io/v2/11155111/rpc?apikey=...',
|
|
1420
|
+
* chainId: 11155111,
|
|
1421
|
+
* entryPoints: {
|
|
1422
|
+
* v06: {
|
|
1423
|
+
* entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
|
|
1424
|
+
* factoryAddress: '0x...',
|
|
1425
|
+
* validatorAddress: '0x...',
|
|
1426
|
+
* },
|
|
1427
|
+
* },
|
|
1428
|
+
* storage: new MemoryStorage(),
|
|
1429
|
+
* signer: new LocalWalletSigner('0xPRIVATE_KEY'),
|
|
1430
|
+
* });
|
|
1431
|
+
*
|
|
1432
|
+
* const account = await client.accounts.createAccount('user-123');
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
declare class AirAccountServerClient {
|
|
1436
|
+
readonly ethereum: EthereumProvider;
|
|
1437
|
+
readonly accounts: AccountManager;
|
|
1438
|
+
readonly transfers: TransferManager;
|
|
1439
|
+
readonly bls: BLSSignatureService;
|
|
1440
|
+
readonly paymaster: PaymasterManager;
|
|
1441
|
+
readonly tokens: TokenService;
|
|
1442
|
+
readonly wallets: WalletManager;
|
|
1443
|
+
constructor(config: ServerConfig);
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* @deprecated Renamed to {@link AirAccountServerClient}. This alias is kept for
|
|
1447
|
+
* backward compatibility and will be removed in a future major version.
|
|
1448
|
+
*/
|
|
1449
|
+
declare const YAAAServerClient: typeof AirAccountServerClient;
|
|
1450
|
+
|
|
1451
|
+
type ModuleTypeId = 1 | 2 | 3 | 4;
|
|
1452
|
+
interface InstallModuleParams {
|
|
1453
|
+
/** The deployed AirAccount address */
|
|
1454
|
+
account: string;
|
|
1455
|
+
/** ERC-7579 module type: 1=Validator, 2=Executor, 3=Fallback, 4=Hook */
|
|
1456
|
+
moduleTypeId: ModuleTypeId;
|
|
1457
|
+
/** Module contract address to install */
|
|
1458
|
+
module: string;
|
|
1459
|
+
/**
|
|
1460
|
+
* Guardian signatures + module init data, packed as:
|
|
1461
|
+
* bytes[0..65*sigsRequired] = guardian ECDSA sigs
|
|
1462
|
+
* bytes[65*sigsRequired..] = module onInstall() init data
|
|
1463
|
+
*
|
|
1464
|
+
* Sig hash (per guardian, r5 format):
|
|
1465
|
+
* keccak256("INSTALL_MODULE" ‖ chainId ‖ account ‖ moduleTypeId ‖ module ‖ keccak256(moduleInitData)).toEthSignedMessageHash()
|
|
1466
|
+
*
|
|
1467
|
+
* sigsRequired: 0 if threshold<=40, 1 if <=70, 2 if =100
|
|
1468
|
+
*/
|
|
1469
|
+
guardianSigs?: string[];
|
|
1470
|
+
/** Raw bytes passed to module.onInstall() after guardian sigs */
|
|
1471
|
+
moduleInitData?: string;
|
|
1472
|
+
}
|
|
1473
|
+
interface UninstallModuleParams {
|
|
1474
|
+
account: string;
|
|
1475
|
+
moduleTypeId: ModuleTypeId;
|
|
1476
|
+
module: string;
|
|
1477
|
+
/** Always requires 2 guardian sigs for uninstall */
|
|
1478
|
+
guardianSig1: string;
|
|
1479
|
+
guardianSig2: string;
|
|
1480
|
+
/** Passed to module.onUninstall() */
|
|
1481
|
+
moduleDeInitData?: string;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Build the EIP-191 install hash that guardians must sign.
|
|
1485
|
+
*
|
|
1486
|
+
* r5 format: includes keccak256(moduleInitData) to prevent config-swap attacks.
|
|
1487
|
+
*
|
|
1488
|
+
* @example
|
|
1489
|
+
* const hash = buildInstallModuleHash(chainId, account, 1, moduleAddress, moduleInitData);
|
|
1490
|
+
* const sig = await guardian.signMessage(hexToBytes(hash));
|
|
1491
|
+
*/
|
|
1492
|
+
declare function buildInstallModuleHash(chainId: number, account: string, moduleTypeId: ModuleTypeId, module: string, moduleInitData?: string): string;
|
|
1493
|
+
/**
|
|
1494
|
+
* Build the EIP-191 uninstall hash that guardians must sign.
|
|
1495
|
+
*/
|
|
1496
|
+
declare function buildUninstallModuleHash(chainId: number, account: string, moduleTypeId: ModuleTypeId, module: string): string;
|
|
1497
|
+
/**
|
|
1498
|
+
* ModuleManager — ERC-7579 module install/uninstall helpers.
|
|
1499
|
+
*
|
|
1500
|
+
* Handles the guardian-sig packing required by AAStarAirAccountV7:
|
|
1501
|
+
* installModule(moduleTypeId, module, guardianSigs ‖ moduleInitData)
|
|
1502
|
+
* uninstallModule(moduleTypeId, module, guardianSig1 ‖ guardianSig2 ‖ deInitData)
|
|
1503
|
+
*/
|
|
1504
|
+
declare class ModuleManager {
|
|
1505
|
+
private readonly provider;
|
|
1506
|
+
private readonly chainId;
|
|
1507
|
+
constructor(provider: PublicClient, chainId: number);
|
|
1508
|
+
/**
|
|
1509
|
+
* Encode calldata for installModule().
|
|
1510
|
+
* Caller is responsible for submitting via UserOp (EntryPoint) or direct tx.
|
|
1511
|
+
*/
|
|
1512
|
+
encodeInstall(params: InstallModuleParams): string;
|
|
1513
|
+
/**
|
|
1514
|
+
* Encode calldata for uninstallModule().
|
|
1515
|
+
* Always requires 2 guardian signatures.
|
|
1516
|
+
*/
|
|
1517
|
+
encodeUninstall(params: UninstallModuleParams): string;
|
|
1518
|
+
/** Check if a module is currently installed on the account. */
|
|
1519
|
+
isInstalled(account: string, moduleTypeId: ModuleTypeId, module: string): Promise<boolean>;
|
|
1520
|
+
/** Return the install hash for a guardian to sign (r5 format, includes moduleInitData hash). */
|
|
1521
|
+
installHash(account: string, moduleTypeId: ModuleTypeId, module: string, moduleInitData?: string): string;
|
|
1522
|
+
/** Return the uninstall hash for guardians to sign. */
|
|
1523
|
+
uninstallHash(account: string, moduleTypeId: ModuleTypeId, module: string): string;
|
|
1524
|
+
/**
|
|
1525
|
+
* Convenience: build install calldata for the standard M7 module set.
|
|
1526
|
+
* Uses pre-deployed Sepolia addresses (r4 audit-final). No guardian sigs required when
|
|
1527
|
+
* account threshold <= 40 (default for newly created accounts).
|
|
1528
|
+
*
|
|
1529
|
+
* Note: beta.3 unifies these into SessionKeyValidator. This helper retains the r4
|
|
1530
|
+
* addresses for accounts already deployed on r4; new accounts use SessionKeyValidator.
|
|
1531
|
+
*/
|
|
1532
|
+
encodeInstallDefaultModules(account: string): {
|
|
1533
|
+
compositeValidator: string;
|
|
1534
|
+
tierGuardHook: string;
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
interface GrantSessionParams {
|
|
1539
|
+
/** Account that owns the session */
|
|
1540
|
+
account: string;
|
|
1541
|
+
/** The session key address (ephemeral EOA) */
|
|
1542
|
+
sessionKey: string;
|
|
1543
|
+
/** Expiry unix timestamp (max 7 days from now) */
|
|
1544
|
+
expiry: number;
|
|
1545
|
+
/** address(0) = any destination allowed */
|
|
1546
|
+
contractScope?: string;
|
|
1547
|
+
/** bytes4(0) = any selector allowed */
|
|
1548
|
+
selectorScope?: string;
|
|
1549
|
+
/** Max calls per velocityWindow (0 = unlimited). Session struct field. */
|
|
1550
|
+
velocityLimit?: number;
|
|
1551
|
+
/** Velocity window in seconds (0 = no window). Session struct field. */
|
|
1552
|
+
velocityWindow?: number;
|
|
1553
|
+
/** Allowed destination addresses ([] = any). Session struct field. */
|
|
1554
|
+
callTargets?: string[];
|
|
1555
|
+
/** Allowed selectors ([] = any). Session struct field. */
|
|
1556
|
+
selectorAllowlist?: string[];
|
|
1557
|
+
/** Owner signature over buildGrantHash() — omit if calling directly from account */
|
|
1558
|
+
ownerSig?: string;
|
|
1559
|
+
}
|
|
1560
|
+
interface SessionInfo {
|
|
1561
|
+
expiry: number;
|
|
1562
|
+
contractScope: string;
|
|
1563
|
+
selectorScope: string;
|
|
1564
|
+
revoked: boolean;
|
|
1565
|
+
velocityLimit: number;
|
|
1566
|
+
velocityWindow: number;
|
|
1567
|
+
callTargets: string[];
|
|
1568
|
+
selectorAllowlist: string[];
|
|
1569
|
+
active: boolean;
|
|
1570
|
+
}
|
|
1571
|
+
interface GrantP256SessionParams {
|
|
1572
|
+
/** Account that owns the session */
|
|
1573
|
+
account: string;
|
|
1574
|
+
/** P256 public key X coordinate (0x-prefixed 32-byte hex) */
|
|
1575
|
+
keyX: string;
|
|
1576
|
+
/** P256 public key Y coordinate (0x-prefixed 32-byte hex) */
|
|
1577
|
+
keyY: string;
|
|
1578
|
+
/** Expiry unix timestamp (max 7 days from now) */
|
|
1579
|
+
expiry: number;
|
|
1580
|
+
/** address(0) = any destination allowed */
|
|
1581
|
+
contractScope?: string;
|
|
1582
|
+
/** bytes4(0) = any selector allowed */
|
|
1583
|
+
selectorScope?: string;
|
|
1584
|
+
/** Max calls per velocityWindow (0 = unlimited). Session struct field. */
|
|
1585
|
+
velocityLimit?: number;
|
|
1586
|
+
/** Velocity window in seconds (0 = no window). Session struct field. */
|
|
1587
|
+
velocityWindow?: number;
|
|
1588
|
+
/** Allowed destination addresses ([] = any). Session struct field. */
|
|
1589
|
+
callTargets?: string[];
|
|
1590
|
+
/** Allowed selectors ([] = any). Session struct field. */
|
|
1591
|
+
selectorAllowlist?: string[];
|
|
1592
|
+
/** Owner signature over buildP256GrantHash() — omit if calling directly from the owner EOA */
|
|
1593
|
+
ownerSig?: string;
|
|
1594
|
+
}
|
|
1595
|
+
interface AgentSessionConfig {
|
|
1596
|
+
expiry: number;
|
|
1597
|
+
velocityLimit: number;
|
|
1598
|
+
velocityWindow: number;
|
|
1599
|
+
callTargets: string[];
|
|
1600
|
+
selectorAllowlist: string[];
|
|
1601
|
+
}
|
|
1602
|
+
interface AgentSessionInfo extends AgentSessionConfig {
|
|
1603
|
+
revoked: boolean;
|
|
1604
|
+
callCount: bigint;
|
|
1605
|
+
windowStart: bigint;
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* SessionKeyService — manage M6 (basic) and M7 (agent) session keys.
|
|
1609
|
+
*
|
|
1610
|
+
* M6 SessionKeyValidator (algId=0x08):
|
|
1611
|
+
* Simple time-limited ECDSA/P256 key with optional contract+selector scope.
|
|
1612
|
+
* Used for standard delegated actions (hot wallet, automated tasks).
|
|
1613
|
+
*
|
|
1614
|
+
* M7 AgentSessionKeyValidator (algId=0x09):
|
|
1615
|
+
* Rich session key for AI agents: velocity limits, spend caps, call allowlists,
|
|
1616
|
+
* hierarchical delegation (parent → sub-agent with scope narrowing).
|
|
1617
|
+
*/
|
|
1618
|
+
declare class SessionKeyService {
|
|
1619
|
+
private readonly skValidator;
|
|
1620
|
+
private readonly askValidator;
|
|
1621
|
+
constructor(provider: PublicClient, sessionKeyValidatorAddress: string, agentSessionKeyValidatorAddress: string);
|
|
1622
|
+
/**
|
|
1623
|
+
* Build the hash that the account owner must sign to grant a session key.
|
|
1624
|
+
* Use grantSession() with this sig, or grantSessionDirect() from the account itself.
|
|
1625
|
+
*/
|
|
1626
|
+
buildGrantHash(params: Omit<GrantSessionParams, "ownerSig">): Promise<string>;
|
|
1627
|
+
/** Query an ECDSA session key state (decodes the 8-field Session tuple). */
|
|
1628
|
+
getSession(account: string, sessionKey: string): Promise<SessionInfo>;
|
|
1629
|
+
/** Check if an ECDSA session is currently active. */
|
|
1630
|
+
isSessionActive(account: string, sessionKey: string): Promise<boolean>;
|
|
1631
|
+
/**
|
|
1632
|
+
* Encode calldata for session grant.
|
|
1633
|
+
*
|
|
1634
|
+
* - **With ownerSig** → `grantSession()` — for gasless/UserOp flows.
|
|
1635
|
+
* Owner signs the GRANT_SESSION_V2 typed hash via KMS `sign-grant-session`,
|
|
1636
|
+
* then the relayer calls `grantSession(account, key, cfg, ownerSig)` on-chain.
|
|
1637
|
+
* This is the ONLY path for ERC-4337 sponsored / gasless grant flows.
|
|
1638
|
+
*
|
|
1639
|
+
* - **Without ownerSig** → `grantSessionDirect()` — **owner EOA direct-send only**.
|
|
1640
|
+
* Since v0.17.2 round 3, `grantSessionDirect` requires `msg.sender == ownerOf(account)`.
|
|
1641
|
+
* It does NOT accept `msg.sender == account` (removed in round 3 — confused-deputy fix).
|
|
1642
|
+
* Do NOT encode this for a UserOp callData; the EntryPoint is not the owner EOA.
|
|
1643
|
+
*/
|
|
1644
|
+
encodeGrantSession(params: GrantSessionParams): string;
|
|
1645
|
+
/** Encode calldata for revokeSession(). */
|
|
1646
|
+
encodeRevokeSession(account: string, sessionKey: string): string;
|
|
1647
|
+
/**
|
|
1648
|
+
* Build the hash that the account owner must sign to grant a P256/passkey session key.
|
|
1649
|
+
* Use grantP256Session() with this sig, or grantP256SessionDirect() from the owner EOA itself.
|
|
1650
|
+
* The owner/KMS signs this hash to authorize a gasless grantP256Session().
|
|
1651
|
+
*/
|
|
1652
|
+
buildP256GrantHash(params: Omit<GrantP256SessionParams, "ownerSig">): Promise<string>;
|
|
1653
|
+
/**
|
|
1654
|
+
* Query a P256 session key state (decodes the 8-field Session tuple).
|
|
1655
|
+
* @param keyHash The keccak256 hash of (keyX, keyY) used as the on-chain session id.
|
|
1656
|
+
*/
|
|
1657
|
+
getP256Session(account: string, keyHash: string): Promise<SessionInfo>;
|
|
1658
|
+
/** Check if a P256 session is currently active. */
|
|
1659
|
+
isP256SessionActive(account: string, keyX: string, keyY: string): Promise<boolean>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Encode calldata for a P256/passkey session grant.
|
|
1662
|
+
*
|
|
1663
|
+
* - **With ownerSig** → `grantP256Session()` — for gasless/UserOp flows.
|
|
1664
|
+
* Owner signs the buildP256GrantHash() digest via KMS `sign-p256-grant-session`,
|
|
1665
|
+
* then the relayer calls `grantP256Session(account, keyX, keyY, cfg, ownerSig)` on-chain.
|
|
1666
|
+
* This is the ONLY path for ERC-4337 sponsored / gasless P256 grant flows.
|
|
1667
|
+
*
|
|
1668
|
+
* - **Without ownerSig** → `grantP256SessionDirect()` — **owner EOA direct-send only**.
|
|
1669
|
+
* Since v0.17.2 round 3, `grantP256SessionDirect` requires `msg.sender == ownerOf(account)`.
|
|
1670
|
+
* It does NOT accept `msg.sender == account` (removed in round 3 — confused-deputy fix).
|
|
1671
|
+
* Do NOT encode this for a UserOp callData; the EntryPoint is not the owner EOA.
|
|
1672
|
+
*/
|
|
1673
|
+
encodeGrantP256Session(params: GrantP256SessionParams): string;
|
|
1674
|
+
/** Encode calldata for revokeP256Session(). */
|
|
1675
|
+
encodeRevokeP256Session(account: string, keyX: string, keyY: string): string;
|
|
1676
|
+
/**
|
|
1677
|
+
* Encode calldata for grantAgentSession().
|
|
1678
|
+
* Must be called from the account (via UserOp or direct execute).
|
|
1679
|
+
* The contract uses msg.sender as the account — no account param needed.
|
|
1680
|
+
*/
|
|
1681
|
+
encodeGrantAgentSession(sessionKey: string, cfg: AgentSessionConfig): string;
|
|
1682
|
+
/**
|
|
1683
|
+
* Encode calldata for delegateSession() — sub-agent delegation.
|
|
1684
|
+
* The sub-agent config must be a strict subset of the parent session's scope.
|
|
1685
|
+
* Called by the parent session key (not the account owner).
|
|
1686
|
+
* @param account The smart account under which the parent session was granted.
|
|
1687
|
+
*/
|
|
1688
|
+
encodeDelegateSession(account: string, subKey: string, subCfg: AgentSessionConfig): string;
|
|
1689
|
+
/** Encode calldata for revokeAgentSession(). */
|
|
1690
|
+
encodeRevokeAgentSession(sessionKey: string): string;
|
|
1691
|
+
/** Query agent session config + runtime state. */
|
|
1692
|
+
getAgentSession(account: string, sessionKey: string): Promise<AgentSessionInfo>;
|
|
1693
|
+
/** Check if an agent session is active (not expired, not revoked). */
|
|
1694
|
+
isAgentSessionActive(account: string, sessionKey: string): Promise<boolean>;
|
|
1695
|
+
/** Return the parent account of a delegated session key. */
|
|
1696
|
+
getSessionKeyOwner(sessionKey: string): Promise<string>;
|
|
1697
|
+
/** Return the parent key that delegated to subKey, or ZeroAddress if not delegated. */
|
|
1698
|
+
getDelegatedBy(account: string, subKey: string): Promise<string>;
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Pack a secp256k1 session key signature into the 106-byte UserOp.signature format.
|
|
1702
|
+
*
|
|
1703
|
+
* Layout: [0x08][account(20)][sessionKey(20)][r(32)][s(32)][v(1)]
|
|
1704
|
+
*
|
|
1705
|
+
* @param account - The AirAccount address (20 bytes, with or without 0x)
|
|
1706
|
+
* @param sessionKey - The ephemeral EOA session key address (20 bytes)
|
|
1707
|
+
* @param signature - 65-byte hex signature from KMS sign-grant-session (R||S||V)
|
|
1708
|
+
* @returns 106-byte hex string (0x-prefixed) suitable as UserOp.signature
|
|
1709
|
+
*/
|
|
1710
|
+
declare function packSecp256k1SessionSignature(account: string, sessionKey: string, signature: string): string;
|
|
1711
|
+
/**
|
|
1712
|
+
* Pack a P256 session key signature into the 149-byte UserOp.signature format.
|
|
1713
|
+
*
|
|
1714
|
+
* Layout: [0x08][account(20)][keyX(32)][keyY(32)][r(32)][s(32)]
|
|
1715
|
+
*
|
|
1716
|
+
* @param account - The AirAccount address (20 bytes)
|
|
1717
|
+
* @param keyX - P256 public key X coordinate (32 bytes hex, without 0x)
|
|
1718
|
+
* @param keyY - P256 public key Y coordinate (32 bytes hex, without 0x)
|
|
1719
|
+
* @param signature - 64-byte hex signature from KMS sign-p256-grant-session (R||S, no V)
|
|
1720
|
+
* @returns 149-byte hex string (0x-prefixed) suitable as UserOp.signature
|
|
1721
|
+
*/
|
|
1722
|
+
declare function packP256SessionSignature(account: string, keyX: string, keyY: string, signature: string): string;
|
|
1723
|
+
|
|
1724
|
+
type TierLevel = 1 | 2 | 3;
|
|
1725
|
+
interface GuardState {
|
|
1726
|
+
/** ETH daily limit in wei */
|
|
1727
|
+
dailyLimit: bigint;
|
|
1728
|
+
/** ETH already spent today in wei */
|
|
1729
|
+
todaySpent: bigint;
|
|
1730
|
+
/** ETH remaining for today in wei */
|
|
1731
|
+
remaining: bigint;
|
|
1732
|
+
/** Current tier based on spent amount */
|
|
1733
|
+
currentTier: TierLevel;
|
|
1734
|
+
/** Tier 1 max spend threshold in wei (single sig) */
|
|
1735
|
+
tier1Limit: bigint;
|
|
1736
|
+
/** Tier 2 max spend threshold in wei (dual sig) */
|
|
1737
|
+
tier2Limit: bigint;
|
|
1738
|
+
/** Minimum daily limit floor (cannot decrease below this) */
|
|
1739
|
+
minDailyLimit: bigint;
|
|
1740
|
+
/** Guard contract address */
|
|
1741
|
+
guardAddress: string;
|
|
1742
|
+
}
|
|
1743
|
+
interface TokenGuardState {
|
|
1744
|
+
token: string;
|
|
1745
|
+
todaySpent: bigint;
|
|
1746
|
+
dailyLimit: bigint;
|
|
1747
|
+
remaining: bigint;
|
|
1748
|
+
currentTier: TierLevel;
|
|
1749
|
+
tier1Limit: bigint;
|
|
1750
|
+
tier2Limit: bigint;
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* GuardStateReader — F6: read AAStarGlobalGuard spending state.
|
|
1754
|
+
*
|
|
1755
|
+
* Enables UI components to show:
|
|
1756
|
+
* - Daily spend progress bar
|
|
1757
|
+
* - Current required tier (T1/T2/T3) for next transaction
|
|
1758
|
+
* - Per-token limits and remaining allowances
|
|
1759
|
+
*/
|
|
1760
|
+
declare class GuardStateReader {
|
|
1761
|
+
private readonly provider;
|
|
1762
|
+
constructor(provider: PublicClient);
|
|
1763
|
+
private accountContract;
|
|
1764
|
+
private guardContract;
|
|
1765
|
+
/**
|
|
1766
|
+
* Read the full ETH guard state for an account.
|
|
1767
|
+
* Returns null if the account has no guard (dailyLimit=0).
|
|
1768
|
+
*/
|
|
1769
|
+
getGuardState(accountAddress: string): Promise<GuardState | null>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Read per-token guard state.
|
|
1772
|
+
* Returns null if the token is not configured on the guard.
|
|
1773
|
+
*/
|
|
1774
|
+
getTokenGuardState(accountAddress: string, token: string): Promise<TokenGuardState | null>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Determine the minimum tier required to send a given ETH amount.
|
|
1777
|
+
* Useful for showing "this transfer needs 2 signatures" before submission.
|
|
1778
|
+
*/
|
|
1779
|
+
requiredTierForAmount(accountAddress: string, amountWei: bigint): Promise<TierLevel>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Check if a given algorithm ID is approved on the guard.
|
|
1782
|
+
*/
|
|
1783
|
+
isAlgorithmApproved(accountAddress: string, algId: number): Promise<boolean>;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
interface OapdConfig {
|
|
1787
|
+
/** Account owner address */
|
|
1788
|
+
owner: string;
|
|
1789
|
+
/** DApp identifier — use the DApp's domain or contract address */
|
|
1790
|
+
dappId: string;
|
|
1791
|
+
/** Factory address (defaults to M7 Sepolia) */
|
|
1792
|
+
factoryAddress?: string;
|
|
1793
|
+
/**
|
|
1794
|
+
* InitConfig for the OAPD account.
|
|
1795
|
+
* Typically lower daily limits than the main account.
|
|
1796
|
+
*/
|
|
1797
|
+
initConfig: {
|
|
1798
|
+
guardians: [string, string, string];
|
|
1799
|
+
dailyLimit: bigint;
|
|
1800
|
+
approvedAlgIds: number[];
|
|
1801
|
+
minDailyLimit: bigint;
|
|
1802
|
+
initialTokens: string[];
|
|
1803
|
+
initialTokenConfigs: Array<{
|
|
1804
|
+
tier1Limit: bigint;
|
|
1805
|
+
tier2Limit: bigint;
|
|
1806
|
+
dailyLimit: bigint;
|
|
1807
|
+
}>;
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Compute the numeric salt for an OAPD address.
|
|
1812
|
+
* salt = uint256(keccak256(abi.encodePacked(owner, dappId)))
|
|
1813
|
+
*/
|
|
1814
|
+
declare function computeOapdSalt(owner: string, dappId: string): bigint;
|
|
1815
|
+
/**
|
|
1816
|
+
* Predict the counterfactual OAPD address without deploying.
|
|
1817
|
+
* Uses the factory's getAddress() view function.
|
|
1818
|
+
*/
|
|
1819
|
+
declare function getOapdAddress(provider: PublicClient, config: OapdConfig): Promise<string>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Get the OAPD address and its ERC-7828 chain-qualified identifier.
|
|
1822
|
+
*/
|
|
1823
|
+
declare function getOapdAddressWithChainId(provider: PublicClient, config: OapdConfig): Promise<{
|
|
1824
|
+
address: string;
|
|
1825
|
+
chainQualified: string;
|
|
1826
|
+
}>;
|
|
1827
|
+
/**
|
|
1828
|
+
* Check if an OAPD account has been deployed yet.
|
|
1829
|
+
*/
|
|
1830
|
+
declare function isOapdDeployed(provider: PublicClient, config: OapdConfig): Promise<boolean>;
|
|
1831
|
+
|
|
1832
|
+
/** 4-byte selector of `executeUserOp((PackedUserOperation),bytes32)`. */
|
|
1833
|
+
declare const EXECUTE_USER_OP_SELECTOR: `0x${string}`;
|
|
1834
|
+
/** 4-byte selector of `execute(address,uint256,bytes)`. */
|
|
1835
|
+
declare const EXECUTE_SELECTOR: `0x${string}`;
|
|
1836
|
+
/** 4-byte selector of `executeBatch(address[],uint256[],bytes[])`. */
|
|
1837
|
+
declare const EXECUTE_BATCH_SELECTOR: `0x${string}`;
|
|
1838
|
+
/**
|
|
1839
|
+
* Wrap inner `execute()` / `executeBatch()` callData with the `executeUserOp` selector so a
|
|
1840
|
+
* guard-enabled (v0.17.2-beta.4) account routes the bundler UserOp through `executeUserOp`.
|
|
1841
|
+
*
|
|
1842
|
+
* Only `execute` / `executeBatch` may be wrapped — the account reverts
|
|
1843
|
+
* `UnsupportedInnerSelector` for anything else (including a nested `executeUserOp`).
|
|
1844
|
+
*
|
|
1845
|
+
* Owner-direct (non-bundler) `execute()` does NOT need this; no-guard accounts can submit
|
|
1846
|
+
* bare callData. Use this only when building a bundler UserOp for a guard-enabled account.
|
|
1847
|
+
*
|
|
1848
|
+
* @param innerCallData ABI-encoded `execute`/`executeBatch` calldata (0x-prefixed)
|
|
1849
|
+
* @returns `executeUserOp.selector ++ innerCallData`
|
|
1850
|
+
* @throws if `innerCallData` is not an `execute`/`executeBatch` call
|
|
1851
|
+
*/
|
|
1852
|
+
declare function wrapExecuteUserOp(innerCallData: string): string;
|
|
1853
|
+
/** True if callData is already wrapped with the executeUserOp selector. */
|
|
1854
|
+
declare function isExecuteUserOpWrapped(callData: string): boolean;
|
|
1855
|
+
|
|
1856
|
+
declare const L2_TYPE: {
|
|
1857
|
+
readonly OPTIMISM: 1;
|
|
1858
|
+
readonly ARBITRUM: 2;
|
|
1859
|
+
};
|
|
1860
|
+
type L2Type = (typeof L2_TYPE)[keyof typeof L2_TYPE];
|
|
1861
|
+
interface PendingExit {
|
|
1862
|
+
target: string;
|
|
1863
|
+
value: bigint;
|
|
1864
|
+
data: string;
|
|
1865
|
+
proposedAt: bigint;
|
|
1866
|
+
approvalBitmap: bigint;
|
|
1867
|
+
guardians: [string, string, string];
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* A viem client capable of backing the ForceExit contract. A `PublicClient`
|
|
1871
|
+
* alone enables the on-chain reads; a `WalletClient` (or the `{ public, wallet }`
|
|
1872
|
+
* pair) is required for the state-changing `proposeForceExit`/`approveForceExit`/
|
|
1873
|
+
* etc. transactions. This replaces the old `ethers.Provider | ethers.Signer`
|
|
1874
|
+
* argument (provider = reads, signer = reads + writes).
|
|
1875
|
+
*/
|
|
1876
|
+
type ForceExitClient = PublicClient | WalletClient | {
|
|
1877
|
+
public: PublicClient;
|
|
1878
|
+
wallet: WalletClient;
|
|
1879
|
+
};
|
|
1880
|
+
/**
|
|
1881
|
+
* ForceExitService — typed wrappers for ForceExitModule ERC-7579 emergency L2→L1 exit.
|
|
1882
|
+
*
|
|
1883
|
+
* Flow:
|
|
1884
|
+
* 1. Owner installs module via account.installModule(2, forceExitModuleAddr, encodeOnInstall(L2_TYPE.OPTIMISM))
|
|
1885
|
+
* 2. Any party calls proposeForceExit(target, value, data) to submit a bridge-out proposal
|
|
1886
|
+
* 3. 2-of-3 guardians each call approveForceExit(account, guardianSig) within their window
|
|
1887
|
+
* 4. Anyone calls executeForceExit(account) once threshold is met — triggers L2→L1 bridge call
|
|
1888
|
+
*
|
|
1889
|
+
* The module is an ERC-7579 Executor (moduleTypeId=2) — call installModule on the account, not here.
|
|
1890
|
+
*/
|
|
1891
|
+
declare class ForceExitService {
|
|
1892
|
+
private readonly moduleAddress;
|
|
1893
|
+
private readonly contract;
|
|
1894
|
+
constructor(moduleAddress: string, client: ForceExitClient);
|
|
1895
|
+
isInitialized(smartAccount: string): Promise<boolean>;
|
|
1896
|
+
getPendingExit(account: string): Promise<PendingExit>;
|
|
1897
|
+
getAccountL2Type(account: string): Promise<number>;
|
|
1898
|
+
getApprovalThreshold(): Promise<number>;
|
|
1899
|
+
getModuleVersion(): Promise<string>;
|
|
1900
|
+
/**
|
|
1901
|
+
* Encode onInstall calldata for installModule() call on the smart account.
|
|
1902
|
+
* Must be submitted by the account owner, with moduleTypeId=2 (EXECUTOR).
|
|
1903
|
+
*
|
|
1904
|
+
* @param l2Type - L2_TYPE.OPTIMISM (1) or L2_TYPE.ARBITRUM (2)
|
|
1905
|
+
* @example
|
|
1906
|
+
* const calldata = forceExit.encodeOnInstall(L2_TYPE.OPTIMISM);
|
|
1907
|
+
* // account.installModule(2, forceExitModuleAddress, calldata)
|
|
1908
|
+
*/
|
|
1909
|
+
encodeOnInstall(l2Type: L2Type): string;
|
|
1910
|
+
encodeOnUninstall(): string;
|
|
1911
|
+
/**
|
|
1912
|
+
* Encode calldata for proposeForceExit — the exit payload to bridge out of L2.
|
|
1913
|
+
* `target` is the L2→L1 bridge contract; `data` is the bridge call payload.
|
|
1914
|
+
*/
|
|
1915
|
+
encodeProposeForceExit(target: string, value: bigint, data: string): string;
|
|
1916
|
+
/**
|
|
1917
|
+
* Encode calldata for approveForceExit — guardian signs off on the pending proposal.
|
|
1918
|
+
* `guardianSig` must be an EIP-191 personal_sign over the proposal hash.
|
|
1919
|
+
*/
|
|
1920
|
+
encodeApproveForceExit(account: string, guardianSig: string): string;
|
|
1921
|
+
encodeExecuteForceExit(account: string): string;
|
|
1922
|
+
encodeCancelForceExit(account: string): string;
|
|
1923
|
+
proposeForceExit(target: string, value: bigint, data: string): Promise<Hex>;
|
|
1924
|
+
approveForceExit(account: string, guardianSig: string): Promise<Hex>;
|
|
1925
|
+
executeForceExit(account: string): Promise<Hex>;
|
|
1926
|
+
cancelForceExit(account: string): Promise<Hex>;
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
/**
|
|
1930
|
+
* RECOVERY_THRESHOLD — number of distinct guardian approvals required to recover
|
|
1931
|
+
* (or to cancel a recovery). The contract hard-codes `RECOVERY_THRESHOLD = 2`
|
|
1932
|
+
* against a maximum of 3 guardians, i.e. a 2-of-3 social-recovery scheme.
|
|
1933
|
+
*
|
|
1934
|
+
* Source of truth: `AAStarAirAccountBase.RECOVERY_THRESHOLD` (internal constant).
|
|
1935
|
+
*/
|
|
1936
|
+
declare const RECOVERY_THRESHOLD = 2;
|
|
1937
|
+
/**
|
|
1938
|
+
* MAX_GUARDIANS — the account stores at most 3 guardians (packed slots 12-14).
|
|
1939
|
+
* Source: `AAStarAirAccountBase.addGuardian` (`_guardianCount >= 3` reverts).
|
|
1940
|
+
*/
|
|
1941
|
+
declare const MAX_GUARDIANS = 3;
|
|
1942
|
+
/**
|
|
1943
|
+
* RECOVERY_TIMELOCK_SECONDS — delay between `proposeRecovery` and the earliest
|
|
1944
|
+
* `executeRecovery`. The contract hard-codes `RECOVERY_TIMELOCK = 2 days`
|
|
1945
|
+
* (172800 seconds).
|
|
1946
|
+
*
|
|
1947
|
+
* NOTE: the prose in `docs/abi/capabilities.md` says "72h"; the deployed
|
|
1948
|
+
* contract uses 2 days (48h). The on-chain constant is authoritative.
|
|
1949
|
+
*
|
|
1950
|
+
* Source of truth: `AAStarAirAccountBase.RECOVERY_TIMELOCK` (internal constant).
|
|
1951
|
+
*/
|
|
1952
|
+
declare const RECOVERY_TIMELOCK_SECONDS: bigint;
|
|
1953
|
+
/**
|
|
1954
|
+
* Decoded view of the account's `activeRecovery()` struct (RecoveryProposal).
|
|
1955
|
+
*
|
|
1956
|
+
* On-chain layout (`AAStarAgentStorageLayout.RecoveryProposal`):
|
|
1957
|
+
* - newOwner : proposed new owner (address(0) ⇒ no active recovery)
|
|
1958
|
+
* - proposedAt : block.timestamp when the recovery was proposed
|
|
1959
|
+
* - approvalBitmap : bit i set ⇒ guardian[i] approved (2-of-3 to execute)
|
|
1960
|
+
* - cancellationBitmap : bit i set ⇒ guardian[i] voted to cancel (2-of-3 to cancel)
|
|
1961
|
+
*
|
|
1962
|
+
* The remaining fields are SDK-side conveniences derived from those values.
|
|
1963
|
+
*/
|
|
1964
|
+
interface ActiveRecovery {
|
|
1965
|
+
/** Proposed new owner. `0x0000…0000` means there is no active recovery. */
|
|
1966
|
+
newOwner: string;
|
|
1967
|
+
/** `block.timestamp` at which the recovery was proposed (seconds). */
|
|
1968
|
+
proposedAt: bigint;
|
|
1969
|
+
/** Bitmap of guardian approvals (bit i ⇒ guardian[i] approved). */
|
|
1970
|
+
approvalBitmap: bigint;
|
|
1971
|
+
/** Bitmap of guardian cancel votes (bit i ⇒ guardian[i] voted to cancel). */
|
|
1972
|
+
cancellationBitmap: bigint;
|
|
1973
|
+
/** Number of distinct guardian approvals (popcount of `approvalBitmap`). */
|
|
1974
|
+
approvalCount: number;
|
|
1975
|
+
/** Number of distinct guardian cancel votes (popcount of `cancellationBitmap`). */
|
|
1976
|
+
cancellationCount: number;
|
|
1977
|
+
/** Earliest timestamp at which `executeRecovery` may succeed (`proposedAt + timelock`). */
|
|
1978
|
+
executeAfter: bigint;
|
|
1979
|
+
/** True when a recovery is currently active (`newOwner != address(0)`). */
|
|
1980
|
+
isActive: boolean;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* RecoveryService — typed wrappers for AirAccount's on-chain social / guardian
|
|
1984
|
+
* recovery (capability F28). Unlike `ForceExitService` (an ERC-7579 module),
|
|
1985
|
+
* these functions live directly on the account contract, so every encoded
|
|
1986
|
+
* calldata below is meant to be submitted **to the account address itself**
|
|
1987
|
+
* (via a direct tx or a UserOp).
|
|
1988
|
+
*
|
|
1989
|
+
* ## Threshold & timelock
|
|
1990
|
+
* 2-of-3 guardians ({@link RECOVERY_THRESHOLD} of {@link MAX_GUARDIANS}), with a
|
|
1991
|
+
* {@link RECOVERY_TIMELOCK_SECONDS} (2-day) delay before execution.
|
|
1992
|
+
*
|
|
1993
|
+
* ## Lifecycle & who-can-call
|
|
1994
|
+
* 1. `addGuardian(guardian)` — **owner only**. Registers a guardian (max 3).
|
|
1995
|
+
* 2. `proposeRecovery(newOwner)` — **any guardian**. Starts the timelock and
|
|
1996
|
+
* records the proposer's approval bit (counts as the first of 2 approvals).
|
|
1997
|
+
* 3. `approveRecovery()` — **another guardian**. Sets its approval bit; once
|
|
1998
|
+
* 2-of-3 approvals are reached the threshold is satisfied.
|
|
1999
|
+
* 4. `executeRecovery()` — **anyone**, but only after the timelock has elapsed
|
|
2000
|
+
* AND the approval threshold is met. Rotates `owner` to `newOwner`.
|
|
2001
|
+
* 5. `cancelRecovery()` — **guardians only** (2-of-3 votes). The owner cannot
|
|
2002
|
+
* cancel: a thief who stole the owner key must not be able to block a
|
|
2003
|
+
* legitimate recovery. Each guardian votes independently.
|
|
2004
|
+
* 6. `removeGuardian(index, guardianSigs)` — **owner**, but additionally
|
|
2005
|
+
* requires >= {@link RECOVERY_THRESHOLD} guardian signatures over the
|
|
2006
|
+
* removal hash (and cannot drop below 2 guardians).
|
|
2007
|
+
*
|
|
2008
|
+
* Guardian signatures are domain-separated per operation (the contract hashes a
|
|
2009
|
+
* per-op label such as "REMOVE_GUARDIAN") to prevent cross-operation replay.
|
|
2010
|
+
*
|
|
2011
|
+
* ## Re-proposing
|
|
2012
|
+
* A new proposal reverts with `RecoveryAlreadyActive` while one is pending. The
|
|
2013
|
+
* docs reference a `clearStaleRecovery()` helper, but that function is NOT
|
|
2014
|
+
* present in the deployed V7 ABI/contract — a stale proposal must instead be
|
|
2015
|
+
* cleared via guardian `cancelRecovery()` votes before re-proposing.
|
|
2016
|
+
*/
|
|
2017
|
+
declare class RecoveryService {
|
|
2018
|
+
private readonly client;
|
|
2019
|
+
/**
|
|
2020
|
+
* @param client viem read client (was `ethers.Provider | ethers.Signer`). Only
|
|
2021
|
+
* on-chain reads are performed here; calldata encoders are pure and never
|
|
2022
|
+
* touch the client.
|
|
2023
|
+
*/
|
|
2024
|
+
constructor(client: PublicClient);
|
|
2025
|
+
/**
|
|
2026
|
+
* Encode `addGuardian(guardian)` calldata. **Owner only.**
|
|
2027
|
+
* Registers a recovery guardian; reverts once 3 guardians are set, or if the
|
|
2028
|
+
* guardian is `address(0)`, the owner, or already registered.
|
|
2029
|
+
*/
|
|
2030
|
+
encodeAddGuardian(guardian: string): string;
|
|
2031
|
+
/**
|
|
2032
|
+
* Encode `removeGuardian(index, guardianSigs)` calldata. **Owner only**, and
|
|
2033
|
+
* requires >= {@link RECOVERY_THRESHOLD} guardian signatures over the removal
|
|
2034
|
+
* hash. Cannot remove while a recovery is active, nor drop below 2 guardians.
|
|
2035
|
+
*
|
|
2036
|
+
* @param index Guardian slot to remove (0-indexed).
|
|
2037
|
+
* @param guardianSigs EIP-191 guardian signatures over the removal hash.
|
|
2038
|
+
*/
|
|
2039
|
+
encodeRemoveGuardian(index: number, guardianSigs: string[]): string;
|
|
2040
|
+
/**
|
|
2041
|
+
* Encode `proposeRecovery(newOwner)` calldata. **Any guardian** may call.
|
|
2042
|
+
* Starts the {@link RECOVERY_TIMELOCK_SECONDS} timelock and records the
|
|
2043
|
+
* proposer's approval (1 of {@link RECOVERY_THRESHOLD}).
|
|
2044
|
+
*/
|
|
2045
|
+
encodeProposeRecovery(newOwner: string): string;
|
|
2046
|
+
/**
|
|
2047
|
+
* Encode `approveRecovery()` calldata. **Another guardian** approves the
|
|
2048
|
+
* active proposal, setting its bit in `approvalBitmap`.
|
|
2049
|
+
*/
|
|
2050
|
+
encodeApproveRecovery(): string;
|
|
2051
|
+
/**
|
|
2052
|
+
* Encode `cancelRecovery()` calldata. **Guardians only** — each call is one
|
|
2053
|
+
* vote; recovery is dropped once {@link RECOVERY_THRESHOLD} cancel votes are
|
|
2054
|
+
* reached. The owner cannot cancel.
|
|
2055
|
+
*/
|
|
2056
|
+
encodeCancelRecovery(): string;
|
|
2057
|
+
/**
|
|
2058
|
+
* Encode `executeRecovery()` calldata. **Anyone** may call, but it only
|
|
2059
|
+
* succeeds once the timelock has elapsed and the approval threshold is met.
|
|
2060
|
+
* Rotates the account owner to the proposed `newOwner`.
|
|
2061
|
+
*/
|
|
2062
|
+
encodeExecuteRecovery(): string;
|
|
2063
|
+
/**
|
|
2064
|
+
* Read and decode the account's `activeRecovery()` struct.
|
|
2065
|
+
* Returns derived `approvalCount`, `cancellationCount`, `executeAfter`, and
|
|
2066
|
+
* `isActive` alongside the raw fields.
|
|
2067
|
+
*
|
|
2068
|
+
* @param account The AirAccount address to query.
|
|
2069
|
+
*/
|
|
2070
|
+
getActiveRecovery(account: string): Promise<ActiveRecovery>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Read the number of registered guardians via `guardianCount()`.
|
|
2073
|
+
*
|
|
2074
|
+
* @param account The AirAccount address to query.
|
|
2075
|
+
*/
|
|
2076
|
+
getGuardianCount(account: string): Promise<number>;
|
|
2077
|
+
/**
|
|
2078
|
+
* Read the full guardian address list.
|
|
2079
|
+
*
|
|
2080
|
+
* The V7 account exposes positional `guardians(uint256 i)` (3 packed slots) plus
|
|
2081
|
+
* `guardianCount()` — there is no single `getGuardians()` getter on the account
|
|
2082
|
+
* (that exists only on `AirAccountDelegate`, the EIP-7702 path). This reads slots
|
|
2083
|
+
* `0..guardianCount-1` and returns the non-zero guardian addresses.
|
|
2084
|
+
*
|
|
2085
|
+
* @param account The AirAccount address to query.
|
|
2086
|
+
*/
|
|
2087
|
+
getGuardians(account: string): Promise<string[]>;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
declare const AIR_ACCOUNT_DELEGATE_ADDRESS = "0x8603AAF6C3f07fdae810B323c95a198D796EC52E";
|
|
2091
|
+
interface DelegateInitParams {
|
|
2092
|
+
/** Guardian 1 address */
|
|
2093
|
+
guardian1: string;
|
|
2094
|
+
/** EIP-712 acceptance signature from guardian 1 */
|
|
2095
|
+
guardian1Sig: string;
|
|
2096
|
+
/** Guardian 2 address */
|
|
2097
|
+
guardian2: string;
|
|
2098
|
+
/** EIP-712 acceptance signature from guardian 2 */
|
|
2099
|
+
guardian2Sig: string;
|
|
2100
|
+
/** Daily ETH spend limit in wei */
|
|
2101
|
+
dailyLimit: bigint;
|
|
2102
|
+
}
|
|
2103
|
+
interface EIP7702Authorization {
|
|
2104
|
+
/** Chain ID (e.g. 11155111 for Sepolia) */
|
|
2105
|
+
chainId: number;
|
|
2106
|
+
/** The delegation target — AirAccountDelegate singleton address */
|
|
2107
|
+
address: string;
|
|
2108
|
+
/** EOA nonce at time of signing */
|
|
2109
|
+
nonce: bigint;
|
|
2110
|
+
/** Signature over the EIP-7702 authorization hash (65 bytes, R||S||V) */
|
|
2111
|
+
signature: string;
|
|
2112
|
+
}
|
|
2113
|
+
/**
|
|
2114
|
+
* EIP7702DelegateService — Path A: SDK payload construction for AirAccountDelegate.
|
|
2115
|
+
*
|
|
2116
|
+
* Path A applies when the integrator controls the private key (KMS, server-side signer,
|
|
2117
|
+
* embedded wallet). The EOA signs a SET_CODE authorization offline; the integrator's relay
|
|
2118
|
+
* submits a Type-4 transaction to activate the delegation.
|
|
2119
|
+
*
|
|
2120
|
+
* This service does NOT submit transactions — it produces signed payloads for relay.
|
|
2121
|
+
*
|
|
2122
|
+
* Deployed address: AirAccountDelegate singleton at AIR_ACCOUNT_DELEGATE_ADDRESS (Sepolia).
|
|
2123
|
+
* The user's EOA address does NOT change — only its bytecode pointer changes to 0xef0100||addr.
|
|
2124
|
+
*
|
|
2125
|
+
* Usage:
|
|
2126
|
+
* 1. Build SET_CODE authorization payload (call signer.signAuthorization externally — viem)
|
|
2127
|
+
* 2. Build initialize() calldata for the first UserOp / direct tx
|
|
2128
|
+
* 3. Submit both via integrator's relay
|
|
2129
|
+
*/
|
|
2130
|
+
declare class EIP7702DelegateService {
|
|
2131
|
+
private readonly delegateAddress;
|
|
2132
|
+
/** Parsed ABI (loose viem `Abi` shape) used for encoding calldata and on-chain reads. */
|
|
2133
|
+
private readonly abi;
|
|
2134
|
+
/** Optional viem read client (was `ethers.Provider | ethers.Signer`). Required only for on-chain reads. */
|
|
2135
|
+
private readonly client?;
|
|
2136
|
+
constructor(delegateAddress?: string, client?: PublicClient);
|
|
2137
|
+
/**
|
|
2138
|
+
* Encode initialize() calldata for the first post-delegation UserOp.
|
|
2139
|
+
* Must be the callData of a UserOp sent immediately after the SET_CODE delegation activates.
|
|
2140
|
+
* Guardian acceptance sigs follow the same EIP-712 scheme as AirAccountV7 createAccount.
|
|
2141
|
+
*/
|
|
2142
|
+
encodeInitialize(params: DelegateInitParams): string;
|
|
2143
|
+
encodeExecute(dest: string, value: bigint, data: string): string;
|
|
2144
|
+
encodeExecuteBatch(dests: string[], values: bigint[], datas: string[]): string;
|
|
2145
|
+
/**
|
|
2146
|
+
* Compute the EIP-7702 SET_CODE authorization hash that the EOA must sign.
|
|
2147
|
+
*
|
|
2148
|
+
* Hash = keccak256(0x05 || RLP([chainId, address, nonce]))
|
|
2149
|
+
*
|
|
2150
|
+
* This is the hash the private key signs to delegate code execution to
|
|
2151
|
+
* AirAccountDelegate. Use this hash with your KMS sign-hash endpoint or
|
|
2152
|
+
* local viem account.
|
|
2153
|
+
*
|
|
2154
|
+
* @param chainId - Target chain ID (11155111 for Sepolia)
|
|
2155
|
+
* @param nonce - EOA's current transaction nonce
|
|
2156
|
+
* @returns 32-byte hash (0x-prefixed) ready for signing
|
|
2157
|
+
*/
|
|
2158
|
+
buildAuthorizationHash(chainId: number, nonce: bigint): string;
|
|
2159
|
+
/**
|
|
2160
|
+
* Build the full EIP-7702 authorization object for relay submission.
|
|
2161
|
+
* The caller must sign `buildAuthorizationHash()` externally and pass the result here.
|
|
2162
|
+
*
|
|
2163
|
+
* @param chainId - Target chain ID
|
|
2164
|
+
* @param nonce - EOA's current nonce
|
|
2165
|
+
* @param signature - 65-byte ECDSA signature (R||S||V) over the authorization hash
|
|
2166
|
+
*/
|
|
2167
|
+
buildAuthorization(chainId: number, nonce: bigint, signature: string): EIP7702Authorization;
|
|
2168
|
+
/**
|
|
2169
|
+
* Verify that a signature is a valid EIP-7702 authorization for the given EOA address.
|
|
2170
|
+
* Recovers the signer from the authorization hash and checks it matches `eoa`.
|
|
2171
|
+
*
|
|
2172
|
+
* NOTE: now async — viem's `recoverAddress` is asynchronous (ethers' was sync).
|
|
2173
|
+
*/
|
|
2174
|
+
verifyAuthorization(eoa: string, chainId: number, nonce: bigint, signature: string): Promise<boolean>;
|
|
2175
|
+
isInitialized(eoa: string): Promise<boolean>;
|
|
2176
|
+
getOwner(eoa: string): Promise<string>;
|
|
2177
|
+
getGuardians(eoa: string): Promise<[string, string, string]>;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/** Timelock that must elapse after a proposal before executeWeightChange() succeeds (WEIGHT_CHANGE_TIMELOCK = 2 days). */
|
|
2181
|
+
declare const WEIGHT_CHANGE_TIMELOCK_SECONDS: number;
|
|
2182
|
+
/** Guardian approvals required to execute a pending weight change (WEIGHT_CHANGE_THRESHOLD = 2-of-3). */
|
|
2183
|
+
declare const WEIGHT_CHANGE_THRESHOLD = 2;
|
|
2184
|
+
/** A proposal expires this long after it is proposed; approvals/execution after expiry revert (WEIGHT_CHANGE_EXPIRY = 30 days). */
|
|
2185
|
+
declare const WEIGHT_CHANGE_EXPIRY_SECONDS: number;
|
|
2186
|
+
/**
|
|
2187
|
+
* WeightConfig — the weighted multi-signature policy for an AAStarAirAccount (algId 0x07).
|
|
2188
|
+
*
|
|
2189
|
+
* Each signer type / guardian contributes its weight; a transaction is authorized when the
|
|
2190
|
+
* summed weight of present signatures meets the relevant tier threshold. tier1 is the base
|
|
2191
|
+
* (required, non-zero) threshold; tier2/tier3 gate higher-value operations and, when set,
|
|
2192
|
+
* must be monotonically non-decreasing (tier1 <= tier2 <= tier3).
|
|
2193
|
+
*
|
|
2194
|
+
* Field order MUST match the on-chain struct exactly (see AAStarAirAccountV7.json):
|
|
2195
|
+
* passkeyWeight, ecdsaWeight, blsWeight, guardian0Weight, guardian1Weight, guardian2Weight,
|
|
2196
|
+
* _padding, tier1Threshold, tier2Threshold, tier3Threshold.
|
|
2197
|
+
*/
|
|
2198
|
+
interface WeightConfig {
|
|
2199
|
+
/** Weight granted by a valid passkey (P256/WebAuthn) signature. */
|
|
2200
|
+
passkeyWeight: number;
|
|
2201
|
+
/** Weight granted by a valid ECDSA (secp256k1 owner) signature. */
|
|
2202
|
+
ecdsaWeight: number;
|
|
2203
|
+
/** Weight granted by a valid BLS signature. */
|
|
2204
|
+
blsWeight: number;
|
|
2205
|
+
/** Weight granted by guardian slot 0. */
|
|
2206
|
+
guardian0Weight: number;
|
|
2207
|
+
/** Weight granted by guardian slot 1. */
|
|
2208
|
+
guardian1Weight: number;
|
|
2209
|
+
/** Weight granted by guardian slot 2. */
|
|
2210
|
+
guardian2Weight: number;
|
|
2211
|
+
/** Reserved padding byte (storage packing); keep 0. */
|
|
2212
|
+
_padding: number;
|
|
2213
|
+
/** Base threshold; must be non-zero and strictly greater than every individual weight. */
|
|
2214
|
+
tier1Threshold: number;
|
|
2215
|
+
/** Tier-2 threshold (0 = disabled); when set must be >= tier1Threshold. */
|
|
2216
|
+
tier2Threshold: number;
|
|
2217
|
+
/** Tier-3 threshold (0 = disabled); when set requires tier2 set and must be >= tier2Threshold. */
|
|
2218
|
+
tier3Threshold: number;
|
|
2219
|
+
}
|
|
2220
|
+
/** A pending weight-change proposal awaiting guardian approval + timelock. */
|
|
2221
|
+
interface PendingWeightChange {
|
|
2222
|
+
/** The proposed new WeightConfig. */
|
|
2223
|
+
proposed: WeightConfig;
|
|
2224
|
+
/** Unix timestamp when the proposal was created; 0 means no active proposal. */
|
|
2225
|
+
proposedAt: bigint;
|
|
2226
|
+
/** Bitmap of guardian indices that have approved (bit i set => guardian i approved). */
|
|
2227
|
+
approvalBitmap: bigint;
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* WeightedSignatureService — typed wrappers for AAStarAirAccount weighted-signature
|
|
2231
|
+
* governance (algId 0x07).
|
|
2232
|
+
*
|
|
2233
|
+
* Governance model:
|
|
2234
|
+
* - setWeightConfig(config): OWNER only. Used for the first-time config and for
|
|
2235
|
+
* *strengthening* changes (no individual weight or tier threshold decreased).
|
|
2236
|
+
* Reverts WeakeningRequiresProposal-equivalent path is enforced by the contract:
|
|
2237
|
+
* a weakening passed here reverts; route weakenings through proposeWeightChange.
|
|
2238
|
+
* Also reverts if a proposal is already pending (WeightChangePending).
|
|
2239
|
+
* - proposeWeightChange(config): OWNER only. Required when the new config *weakens*
|
|
2240
|
+
* security (lowers any weight or threshold). Opens a guardian-approved proposal.
|
|
2241
|
+
* - approveWeightChange(): GUARDIAN only (any of the 3 guardian slots). Each guardian
|
|
2242
|
+
* may approve once; approvals are tracked in approvalBitmap.
|
|
2243
|
+
* - executeWeightChange(): ANYONE, but only succeeds once BOTH conditions hold:
|
|
2244
|
+
* (1) approvals >= WEIGHT_CHANGE_THRESHOLD (2-of-3 guardians), and
|
|
2245
|
+
* (2) WEIGHT_CHANGE_TIMELOCK (2 days) has elapsed since proposedAt.
|
|
2246
|
+
* A proposal also expires after WEIGHT_CHANGE_EXPIRY (30 days).
|
|
2247
|
+
* - cancelWeightChange(): OWNER or any GUARDIAN may cancel a pending proposal.
|
|
2248
|
+
*
|
|
2249
|
+
* Unlike ForceExitService (an ERC-7579 module), these calls target the ACCOUNT itself.
|
|
2250
|
+
* Construct with the account address; encode* methods return calldata for a UserOp or
|
|
2251
|
+
* direct tx, and reads use the contract directly.
|
|
2252
|
+
*/
|
|
2253
|
+
declare class WeightedSignatureService {
|
|
2254
|
+
private readonly accountAddress;
|
|
2255
|
+
private readonly client;
|
|
2256
|
+
private readonly address;
|
|
2257
|
+
constructor(accountAddress: string, client: PublicClient);
|
|
2258
|
+
/** Read the account's current active WeightConfig. */
|
|
2259
|
+
getWeightConfig(): Promise<WeightConfig>;
|
|
2260
|
+
/**
|
|
2261
|
+
* Read the pending weight-change proposal. When `proposedAt === 0n` there is no
|
|
2262
|
+
* active proposal (the returned `proposed` config will be all zeros).
|
|
2263
|
+
*/
|
|
2264
|
+
getPendingWeightChange(): Promise<PendingWeightChange>;
|
|
2265
|
+
/**
|
|
2266
|
+
* Encode setWeightConfig calldata. OWNER only; for first-time setup or strengthening.
|
|
2267
|
+
* Weakening an existing config must go through encodeProposeWeightChange instead.
|
|
2268
|
+
*/
|
|
2269
|
+
encodeSetWeightConfig(config: WeightConfig): Hex;
|
|
2270
|
+
/**
|
|
2271
|
+
* Encode proposeWeightChange calldata. OWNER only; opens a guardian-governed proposal
|
|
2272
|
+
* (required for any weakening). Subject to 2-of-3 approval + 2-day timelock before execute.
|
|
2273
|
+
*/
|
|
2274
|
+
encodeProposeWeightChange(config: WeightConfig): Hex;
|
|
2275
|
+
/** Encode approveWeightChange calldata. GUARDIAN only; each guardian may approve once. */
|
|
2276
|
+
encodeApproveWeightChange(): Hex;
|
|
2277
|
+
/** Encode cancelWeightChange calldata. OWNER or any GUARDIAN may cancel a pending proposal. */
|
|
2278
|
+
encodeCancelWeightChange(): Hex;
|
|
2279
|
+
/**
|
|
2280
|
+
* Encode executeWeightChange calldata. Callable by anyone, but only succeeds once the
|
|
2281
|
+
* threshold (2-of-3) and timelock (2 days) are both satisfied and the proposal has not expired.
|
|
2282
|
+
*/
|
|
2283
|
+
encodeExecuteWeightChange(): Hex;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
interface CreateAgentAccountParams {
|
|
2287
|
+
/** The agent's own signing key (EOA controlled by the agent runtime / KMS). */
|
|
2288
|
+
agentKey: string;
|
|
2289
|
+
/** ERC-8004-style agent identifier (bytes32) binding this account to an off-chain identity. */
|
|
2290
|
+
agentId: string;
|
|
2291
|
+
/** The human guardian (guardian2) co-owning the agent account for recovery. */
|
|
2292
|
+
guardian2: string;
|
|
2293
|
+
/** Guardian2's acceptance signature over the creation hash (EIP-191). */
|
|
2294
|
+
guardian2Sig: string;
|
|
2295
|
+
/** The agent key's acceptance signature over the creation hash (EIP-191). */
|
|
2296
|
+
agentKeySig: string;
|
|
2297
|
+
/** Unix timestamp (uint48) after which the signatures are rejected. */
|
|
2298
|
+
deadline: bigint | number;
|
|
2299
|
+
/** Daily transfer limit in wei (on-chain guard enforcement; V7 requires > 0). */
|
|
2300
|
+
dailyLimit: bigint;
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* AgentRegistryService — typed wrappers for the AAStar AgentRegistry contract plus the
|
|
2304
|
+
* AAStarAirAccountFactoryV7 agent-account creation helpers.
|
|
2305
|
+
*
|
|
2306
|
+
* **Two contracts, two responsibilities:**
|
|
2307
|
+
*
|
|
2308
|
+
* 1. AgentRegistry (constructor `registryAddress`) — the canonical map of agent wallet →
|
|
2309
|
+
* human owner used by SuperPaymaster to authorise gasless sponsorship. The factory calls
|
|
2310
|
+
* `markValid`/registers the agent at deployment; humans manage the binding afterwards via
|
|
2311
|
+
* `registerAgent` / `revokeAgent` / `deregisterAgent`.
|
|
2312
|
+
*
|
|
2313
|
+
* 2. AAStarAirAccountFactoryV7 — deploys an agent-owned AirAccount. `encodeCreateAgentAccount`
|
|
2314
|
+
* targets the factory (NOT the registry); `getAgentAccountAddress` predicts the CREATE2
|
|
2315
|
+
* address before deployment.
|
|
2316
|
+
*
|
|
2317
|
+
* All `encode*` methods return ABI-encoded calldata ready for a UserOp (gasless) or a direct
|
|
2318
|
+
* owner transaction. Read methods require a viem `PublicClient`.
|
|
2319
|
+
*/
|
|
2320
|
+
declare class AgentRegistryService {
|
|
2321
|
+
private readonly registryAddress;
|
|
2322
|
+
private readonly client;
|
|
2323
|
+
/**
|
|
2324
|
+
* @param client viem PublicClient for on-chain reads (e.g. `ethereum.getProvider()`).
|
|
2325
|
+
* @param registryAddress deployed AgentRegistry contract address.
|
|
2326
|
+
*/
|
|
2327
|
+
constructor(client: PublicClient, registryAddress: string);
|
|
2328
|
+
/** Encode `account.execute(registry, 0, registerAgent(agentWallet, agentWalletSig))`. */
|
|
2329
|
+
encodeRegisterAgentViaAccount(agentWallet: string, agentWalletSig: string): string;
|
|
2330
|
+
/** Encode `account.execute(registry, 0, revokeAgent(agentWallet))`. */
|
|
2331
|
+
encodeRevokeAgentViaAccount(agentWallet: string): string;
|
|
2332
|
+
/**
|
|
2333
|
+
* Encode calldata for `registerAgent(agentWallet, agentWalletSig)`.
|
|
2334
|
+
*
|
|
2335
|
+
* Binds `agentWallet` to the caller (the human owner). `agentWalletSig` must be the agent
|
|
2336
|
+
* wallet's EIP-191 signature proving control of the key. Reverts with
|
|
2337
|
+
* `SelfRegistrationForbidden` if the caller registers itself, or `AgentAlreadyRegistered`
|
|
2338
|
+
* if the wallet is already bound.
|
|
2339
|
+
*/
|
|
2340
|
+
encodeRegisterAgent(agentWallet: string, agentWalletSig: string): string;
|
|
2341
|
+
/**
|
|
2342
|
+
* Encode calldata for `revokeAgent(agentWallet)`.
|
|
2343
|
+
*
|
|
2344
|
+
* Owner-initiated revocation of a previously registered agent wallet. Caller must be the
|
|
2345
|
+
* agent's human owner (else `NotAgentOwner`).
|
|
2346
|
+
*/
|
|
2347
|
+
encodeRevokeAgent(agentWallet: string): string;
|
|
2348
|
+
/**
|
|
2349
|
+
* Encode calldata for `deregisterAgent(agentWallet)`.
|
|
2350
|
+
*
|
|
2351
|
+
* Removes the agent wallet from the registry (full deregistration, distinct from the
|
|
2352
|
+
* lighter-weight `revokeAgent`). Caller must be the agent's human owner.
|
|
2353
|
+
*/
|
|
2354
|
+
encodeDeregisterAgent(agentWallet: string): string;
|
|
2355
|
+
/** Whether `agentWallet` is currently registered in the registry. */
|
|
2356
|
+
isRegisteredAgent(agentWallet: string): Promise<boolean>;
|
|
2357
|
+
/** Whether `account` has been marked valid (e.g. an AirAccount minted by the bound factory). */
|
|
2358
|
+
isValidAccount(account: string): Promise<boolean>;
|
|
2359
|
+
/** The human owner bound to `agentWallet` (ZeroAddress if unregistered). */
|
|
2360
|
+
getHumanOwner(agentWallet: string): Promise<string>;
|
|
2361
|
+
/** Number of agents registered under `owner`. */
|
|
2362
|
+
getAgentCount(owner: string): Promise<bigint>;
|
|
2363
|
+
/** The agent wallet at `index` in `owner`'s agent list. */
|
|
2364
|
+
getAgentByIndex(owner: string, index: bigint | number): Promise<string>;
|
|
2365
|
+
/** Full list of agent wallets registered under `humanOwner`. */
|
|
2366
|
+
getAgents(humanOwner: string): Promise<string[]>;
|
|
2367
|
+
/**
|
|
2368
|
+
* Paginated slice of `owner`'s agent wallets: `count` entries starting at `start`.
|
|
2369
|
+
* The contract clamps `count` to the remaining length, so the returned array may be shorter.
|
|
2370
|
+
*/
|
|
2371
|
+
getAgentsPage(owner: string, start: bigint | number, count: bigint | number): Promise<string[]>;
|
|
2372
|
+
/** Raw `agentWalletOwner` mapping read (agentWallet → owner). */
|
|
2373
|
+
agentWalletOwner(agentWallet: string): Promise<string>;
|
|
2374
|
+
/** Raw `ownerAgents` array read (owner, index → agentWallet). */
|
|
2375
|
+
ownerAgents(owner: string, index: bigint | number): Promise<string>;
|
|
2376
|
+
/**
|
|
2377
|
+
* Encode calldata for the factory's `createAgentAccount(...)`.
|
|
2378
|
+
*
|
|
2379
|
+
* Targets the AAStarAirAccountFactoryV7, NOT the AgentRegistry. The factory deploys the agent
|
|
2380
|
+
* AirAccount and registers it in the bound AgentRegistry in one transaction. Submit this
|
|
2381
|
+
* calldata to the factory address (direct tx or via a relayer).
|
|
2382
|
+
*/
|
|
2383
|
+
encodeCreateAgentAccount(params: CreateAgentAccountParams): string;
|
|
2384
|
+
/**
|
|
2385
|
+
* Encode calldata for the factory's `setAgentRegistry(_agentRegistry)` (factory-admin only).
|
|
2386
|
+
*/
|
|
2387
|
+
encodeSetAgentRegistry(agentRegistry: string): string;
|
|
2388
|
+
/**
|
|
2389
|
+
* Predict the CREATE2 address of an agent account via the factory's `getAgentAddress(...)`.
|
|
2390
|
+
*
|
|
2391
|
+
* @param factoryAddress AAStarAirAccountFactoryV7 address.
|
|
2392
|
+
* @param humanOwner the human guardian/owner co-owning the agent account.
|
|
2393
|
+
* @param agentKey the agent's signing key.
|
|
2394
|
+
* @param agentId the bytes32 agent identifier.
|
|
2395
|
+
*/
|
|
2396
|
+
getAgentAccountAddress(factoryAddress: string, humanOwner: string, agentKey: string, agentId: string): Promise<string>;
|
|
2397
|
+
/** Read the AgentRegistry address currently bound to the factory. */
|
|
2398
|
+
getFactoryAgentRegistry(factoryAddress: string): Promise<string>;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
declare const ERC8004_ADDRESSES: {
|
|
2402
|
+
readonly mainnet: {
|
|
2403
|
+
readonly identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
|
|
2404
|
+
readonly reputationRegistry: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63";
|
|
2405
|
+
readonly validationRegistry: "0x8004Cc8439f36fd5F9F049D9fF86523Df6dAAB58";
|
|
2406
|
+
};
|
|
2407
|
+
readonly testnet: {
|
|
2408
|
+
readonly identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e";
|
|
2409
|
+
readonly reputationRegistry: "0x8004B663056A597Dffe9eCcC1965A193B7388713";
|
|
2410
|
+
readonly validationRegistry: "0x8004Cb1BF31DAf7788923b405b754f57acEB4272";
|
|
2411
|
+
};
|
|
2412
|
+
};
|
|
2413
|
+
declare function erc8004AddressesForChain(chainId: number): (typeof ERC8004_ADDRESSES)["mainnet"] | (typeof ERC8004_ADDRESSES)["testnet"];
|
|
2414
|
+
interface SetAgentWalletParams {
|
|
2415
|
+
agentId: bigint;
|
|
2416
|
+
agentWallet: string;
|
|
2417
|
+
/** AAStar AgentRegistry contract address (SuperPaymaster-facing, NOT the official ERC-8004 registry) */
|
|
2418
|
+
agentRegistry: string;
|
|
2419
|
+
/** Signature from the agent wallet proving ownership */
|
|
2420
|
+
agentWalletSig: string;
|
|
2421
|
+
}
|
|
2422
|
+
interface MintAgentIdentityParams {
|
|
2423
|
+
/** Must be the official ERC-8004 identity registry for this chain */
|
|
2424
|
+
identityRegistry: string;
|
|
2425
|
+
/** Agent metadata URI (ERC-721 tokenURI) */
|
|
2426
|
+
agentURI: string;
|
|
2427
|
+
}
|
|
2428
|
+
interface BindERC8004AgentWalletParams {
|
|
2429
|
+
/** Must be the official ERC-8004 identity registry for this chain */
|
|
2430
|
+
identityRegistry: string;
|
|
2431
|
+
agentId: bigint;
|
|
2432
|
+
agentWallet: string;
|
|
2433
|
+
/** Unix timestamp — signature becomes invalid after this deadline */
|
|
2434
|
+
deadline: bigint;
|
|
2435
|
+
/** Signature authorising the wallet binding, signed by the identity registry's expected signer */
|
|
2436
|
+
signature: string;
|
|
2437
|
+
}
|
|
2438
|
+
interface SubmitAgentReputationParams {
|
|
2439
|
+
/** Must be the official ERC-8004 reputation registry for this chain */
|
|
2440
|
+
reputationRegistry: string;
|
|
2441
|
+
agentId: bigint;
|
|
2442
|
+
value: bigint;
|
|
2443
|
+
valueDecimals: number;
|
|
2444
|
+
tag1: string;
|
|
2445
|
+
tag2: string;
|
|
2446
|
+
endpoint: string;
|
|
2447
|
+
feedbackURI: string;
|
|
2448
|
+
feedbackHash: string;
|
|
2449
|
+
}
|
|
2450
|
+
interface QueryAgentReputationParams {
|
|
2451
|
+
/** Must be the official ERC-8004 reputation registry for this chain */
|
|
2452
|
+
reputationRegistry: string;
|
|
2453
|
+
agentId: bigint;
|
|
2454
|
+
clientAddresses: string[];
|
|
2455
|
+
tag1: string;
|
|
2456
|
+
tag2: string;
|
|
2457
|
+
}
|
|
2458
|
+
interface AgentReputationSummary {
|
|
2459
|
+
count: bigint;
|
|
2460
|
+
summaryValue: bigint;
|
|
2461
|
+
summaryDecimals: number;
|
|
2462
|
+
}
|
|
2463
|
+
/**
|
|
2464
|
+
* ERC8004Service — TypeScript wrappers for AirAccount's ERC-8004 "Trustless Agents" functions.
|
|
2465
|
+
*
|
|
2466
|
+
* **Two distinct registration paths:**
|
|
2467
|
+
*
|
|
2468
|
+
* 1. `encodeSetAgentWallet` — AAStar/SuperPaymaster path.
|
|
2469
|
+
* Registers the agent wallet in the AAStar AgentRegistry contract. Use this when you want
|
|
2470
|
+
* SuperPaymaster to recognise the agent for gasless sponsorship. The `agentRegistry` argument
|
|
2471
|
+
* is the deployed AgentRegistry address, NOT the official ERC-8004 IdentityRegistry.
|
|
2472
|
+
*
|
|
2473
|
+
* 2. `encodeMintAgentIdentity` + `encodeBindERC8004AgentWallet` — official ERC-8004 path.
|
|
2474
|
+
* Mints an ERC-721 identity NFT in the official ERC-8004 IdentityRegistry and binds an
|
|
2475
|
+
* execution wallet to it. The registry address MUST be from `erc8004AddressesForChain()`.
|
|
2476
|
+
* These calls revert on-chain if the wrong registry address is supplied.
|
|
2477
|
+
*
|
|
2478
|
+
* All `encode*` methods return ABI-encoded calldata ready to be submitted via UserOp (gasless)
|
|
2479
|
+
* or a direct owner transaction. The calldata targets the AirAccount address — the account's
|
|
2480
|
+
* fallback delegates to AirAccountExtension for these selectors.
|
|
2481
|
+
*/
|
|
2482
|
+
declare class ERC8004Service {
|
|
2483
|
+
private readonly abi;
|
|
2484
|
+
private readonly provider?;
|
|
2485
|
+
constructor(provider?: PublicClient);
|
|
2486
|
+
/**
|
|
2487
|
+
* Build a read-only viem contract bound to the account address. The ABI is loaded from
|
|
2488
|
+
* human-readable signatures via `parseAbi` (loose `Abi`), so `read` methods are indexed by
|
|
2489
|
+
* name and return `unknown` — cast at the call site. Mirrors the dynamic surface that
|
|
2490
|
+
* `ethers.Contract` previously exposed. Caller must ensure `this.provider` is set.
|
|
2491
|
+
*/
|
|
2492
|
+
private contractAt;
|
|
2493
|
+
/**
|
|
2494
|
+
* Encode calldata for `setAgentWallet`.
|
|
2495
|
+
*
|
|
2496
|
+
* Registers `agentWallet` in the AAStar AgentRegistry (SuperPaymaster-facing). This is the
|
|
2497
|
+
* correct path when the goal is SuperPaymaster gasless sponsorship for the agent.
|
|
2498
|
+
*
|
|
2499
|
+
* **Not** a call to the official ERC-8004 IdentityRegistry. Use `encodeMintAgentIdentity`
|
|
2500
|
+
* + `encodeBindERC8004AgentWallet` for the ERC-8004 standard path.
|
|
2501
|
+
*
|
|
2502
|
+
* Callable: owner EOA direct tx OR via UserOp (gasless).
|
|
2503
|
+
*/
|
|
2504
|
+
encodeSetAgentWallet(params: SetAgentWalletParams): string;
|
|
2505
|
+
/**
|
|
2506
|
+
* Encode calldata for `mintAgentIdentity`.
|
|
2507
|
+
*
|
|
2508
|
+
* Mints an ERC-721 agent identity NFT in the official ERC-8004 IdentityRegistry and returns
|
|
2509
|
+
* the new `agentId` (decoded from the tx receipt). The `identityRegistry` must be
|
|
2510
|
+
* `erc8004AddressesForChain(chainId).identityRegistry` — the contract reverts otherwise.
|
|
2511
|
+
*
|
|
2512
|
+
* Callable: owner EOA direct tx OR via UserOp (gasless).
|
|
2513
|
+
*/
|
|
2514
|
+
encodeMintAgentIdentity(params: MintAgentIdentityParams): string;
|
|
2515
|
+
/**
|
|
2516
|
+
* Encode calldata for `bindERC8004AgentWallet`.
|
|
2517
|
+
*
|
|
2518
|
+
* Binds an execution wallet to an existing ERC-8004 agent identity NFT. Requires a
|
|
2519
|
+
* deadline-bounded signature from the expected signer (see the IdentityRegistry contract).
|
|
2520
|
+
* The `identityRegistry` must be the official chain-specific address.
|
|
2521
|
+
*
|
|
2522
|
+
* Callable: owner EOA direct tx OR via UserOp (gasless).
|
|
2523
|
+
*/
|
|
2524
|
+
encodeBindERC8004AgentWallet(params: BindERC8004AgentWalletParams): string;
|
|
2525
|
+
/**
|
|
2526
|
+
* Encode calldata for `submitAgentReputation`.
|
|
2527
|
+
*
|
|
2528
|
+
* Submits a reputation feedback entry to the official ERC-8004 ReputationRegistry.
|
|
2529
|
+
* `reputationRegistry` must be `erc8004AddressesForChain(chainId).reputationRegistry`.
|
|
2530
|
+
*
|
|
2531
|
+
* Callable: owner EOA direct tx OR via UserOp (gasless).
|
|
2532
|
+
*/
|
|
2533
|
+
encodeSubmitAgentReputation(params: SubmitAgentReputationParams): string;
|
|
2534
|
+
/**
|
|
2535
|
+
* Query aggregated reputation for an agent from the official ERC-8004 ReputationRegistry.
|
|
2536
|
+
* Returns `null` when no provider was supplied at construction.
|
|
2537
|
+
*/
|
|
2538
|
+
queryAgentReputation(accountAddress: string, params: QueryAgentReputationParams): Promise<AgentReputationSummary>;
|
|
2539
|
+
/**
|
|
2540
|
+
* Encode calldata for `queryAgentReputation` (for static-call or eth_call without a signer).
|
|
2541
|
+
*/
|
|
2542
|
+
encodeQueryAgentReputation(params: QueryAgentReputationParams): string;
|
|
2543
|
+
/**
|
|
2544
|
+
* Read the agentExtension implementation address from a deployed AirAccount.
|
|
2545
|
+
*/
|
|
2546
|
+
getAgentExtensionAddress(accountAddress: string): Promise<string>;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
/**
|
|
2550
|
+
* Request to mint a new agent key under an existing human key.
|
|
2551
|
+
*
|
|
2552
|
+
* WebAuthn-gated: the human approves the mint with a one-time WebAuthn ceremony
|
|
2553
|
+
* (preferred) or a Legacy passkey assertion. The challenge is obtained via
|
|
2554
|
+
* {@link KmsManager.beginAuthentication} (generic, purpose="authentication") —
|
|
2555
|
+
* the caller supplies the resulting assertion here.
|
|
2556
|
+
*/
|
|
2557
|
+
interface KmsCreateAgentKeyRequest {
|
|
2558
|
+
humanKeyId: string;
|
|
2559
|
+
label?: string;
|
|
2560
|
+
webAuthnAssertion?: WebAuthnAssertion;
|
|
2561
|
+
passkeyAssertion?: LegacyPasskeyAssertion;
|
|
2562
|
+
}
|
|
2563
|
+
interface KmsCreateAgentKeyResponse {
|
|
2564
|
+
keyId: string;
|
|
2565
|
+
agentAddress: string;
|
|
2566
|
+
derivationPath: string;
|
|
2567
|
+
agentCredential: string;
|
|
2568
|
+
expiresAt: number;
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Request to sign a userOpHash with an agent key, authenticated by the agent's
|
|
2572
|
+
* TEE-JWT credential (Bearer). Used for gasless ERC-4337 sponsorship.
|
|
2573
|
+
*/
|
|
2574
|
+
interface KmsSignAgentRequest {
|
|
2575
|
+
keyId: string;
|
|
2576
|
+
payload: string;
|
|
2577
|
+
algorithm?: string;
|
|
2578
|
+
accountAddress: string;
|
|
2579
|
+
}
|
|
2580
|
+
interface KmsSignAgentResponse {
|
|
2581
|
+
keyId: string;
|
|
2582
|
+
agentAddress: string;
|
|
2583
|
+
/** Hex 106-byte signature: [0x08][account(20)][key(20)][r(32)][s(32)][v(1)]. */
|
|
2584
|
+
signature: string;
|
|
2585
|
+
}
|
|
2586
|
+
/**
|
|
2587
|
+
* Request to refresh (re-mint) an agent's TEE-JWT credential before it expires.
|
|
2588
|
+
*
|
|
2589
|
+
* Authenticated with the existing (still-valid) credential via Bearer JWT, plus
|
|
2590
|
+
* a WebAuthn / Legacy passkey assertion from the human key owner.
|
|
2591
|
+
*/
|
|
2592
|
+
interface KmsRefreshAgentCredentialRequest {
|
|
2593
|
+
keyId: string;
|
|
2594
|
+
webAuthnAssertion?: WebAuthnAssertion;
|
|
2595
|
+
passkeyAssertion?: LegacyPasskeyAssertion;
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* The server response shape is not strictly documented; this models the fields
|
|
2599
|
+
* the SDK relies on. `keyId` is echoed back optionally.
|
|
2600
|
+
*/
|
|
2601
|
+
interface KmsRefreshAgentCredentialResponse {
|
|
2602
|
+
keyId?: string;
|
|
2603
|
+
agentCredential: string;
|
|
2604
|
+
expiresAt: number;
|
|
2605
|
+
}
|
|
2606
|
+
/**
|
|
2607
|
+
* Request to revoke an agent's credential (WebAuthn-gated).
|
|
2608
|
+
*
|
|
2609
|
+
* The challenge is obtained via {@link KmsManager.beginAuthentication} (generic,
|
|
2610
|
+
* purpose="authentication"); the caller supplies the resulting assertion here.
|
|
2611
|
+
*/
|
|
2612
|
+
interface KmsRevokeAgentCredentialRequest {
|
|
2613
|
+
keyId: string;
|
|
2614
|
+
webAuthnAssertion?: WebAuthnAssertion;
|
|
2615
|
+
passkeyAssertion?: LegacyPasskeyAssertion;
|
|
2616
|
+
}
|
|
2617
|
+
interface KmsRevokeAgentCredentialResponse {
|
|
2618
|
+
success: boolean;
|
|
2619
|
+
revokedAt: number;
|
|
2620
|
+
}
|
|
2621
|
+
/**
|
|
2622
|
+
* Agent-key lifecycle service for the AAStar TEE KMS (v0.20.0).
|
|
2623
|
+
*
|
|
2624
|
+
* An "agent key" is a TEE-JWT credential minted under a human key, used for
|
|
2625
|
+
* gasless ERC-4337 sponsorship without re-prompting the human for each signature.
|
|
2626
|
+
* Lifecycle:
|
|
2627
|
+
* 1. {@link createAgentKey} — human mints the agent key (WebAuthn-gated)
|
|
2628
|
+
* 2. {@link signAgent} — agent signs userOpHashes (Bearer JWT auth)
|
|
2629
|
+
* 3. {@link refreshAgentCredential}— re-mint before expiry (Bearer JWT + WebAuthn)
|
|
2630
|
+
* 4. {@link revokeAgentCredential} — human revokes the agent key (WebAuthn-gated)
|
|
2631
|
+
*
|
|
2632
|
+
* Wraps a shared {@link KmsHttpClient} — obtain it via {@link KmsManager.httpClient}
|
|
2633
|
+
* so this service reuses the same connection config and auth headers.
|
|
2634
|
+
*/
|
|
2635
|
+
declare class KmsAgentService {
|
|
2636
|
+
private readonly http;
|
|
2637
|
+
constructor(http: KmsHttpClient);
|
|
2638
|
+
/**
|
|
2639
|
+
* Mint a new agent key under an existing human key (WebAuthn-gated).
|
|
2640
|
+
*
|
|
2641
|
+
* The WebAuthn challenge is obtained from a generic
|
|
2642
|
+
* {@link KmsManager.beginAuthentication} ceremony (purpose="authentication");
|
|
2643
|
+
* the caller supplies the resulting assertion in the request.
|
|
2644
|
+
*/
|
|
2645
|
+
createAgentKey(params: KmsCreateAgentKeyRequest): Promise<KmsCreateAgentKeyResponse>;
|
|
2646
|
+
/**
|
|
2647
|
+
* Sign a userOpHash with an agent key, authenticated by the agent's TEE-JWT
|
|
2648
|
+
* credential (`jwt`, the `agentCredential` from {@link createAgentKey}).
|
|
2649
|
+
* Returns the 106-byte packed signature for ERC-4337 sponsorship.
|
|
2650
|
+
*/
|
|
2651
|
+
signAgent(params: KmsSignAgentRequest, jwt: string): Promise<KmsSignAgentResponse>;
|
|
2652
|
+
/**
|
|
2653
|
+
* Refresh (re-mint) an agent credential before it expires. Authenticated with
|
|
2654
|
+
* the existing credential (`jwt`, Bearer) plus a human WebAuthn / passkey
|
|
2655
|
+
* assertion in the request.
|
|
2656
|
+
*/
|
|
2657
|
+
refreshAgentCredential(params: KmsRefreshAgentCredentialRequest, jwt: string): Promise<KmsRefreshAgentCredentialResponse>;
|
|
2658
|
+
/**
|
|
2659
|
+
* Revoke an agent's credential (WebAuthn-gated).
|
|
2660
|
+
*
|
|
2661
|
+
* The WebAuthn challenge is obtained from a generic
|
|
2662
|
+
* {@link KmsManager.beginAuthentication} ceremony (purpose="authentication");
|
|
2663
|
+
* the caller supplies the resulting assertion in the request.
|
|
2664
|
+
*/
|
|
2665
|
+
revokeAgentCredential(params: KmsRevokeAgentCredentialRequest): Promise<KmsRevokeAgentCredentialResponse>;
|
|
2666
|
+
/** Mint an agent key, running the challenge-binding ceremony internally. */
|
|
2667
|
+
createAgentKeyWithCeremony(params: Omit<KmsCreateAgentKeyRequest, "webAuthnAssertion" | "passkeyAssertion">, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsCreateAgentKeyResponse>;
|
|
2668
|
+
/**
|
|
2669
|
+
* Refresh an agent credential, running the challenge-binding ceremony
|
|
2670
|
+
* internally. `humanKeyId` is the owning human key challenged by the ceremony
|
|
2671
|
+
* (distinct from the agent `keyId` in `params`); `jwt` is the existing credential.
|
|
2672
|
+
*/
|
|
2673
|
+
refreshAgentCredentialWithCeremony(params: Omit<KmsRefreshAgentCredentialRequest, "webAuthnAssertion" | "passkeyAssertion">, humanKeyId: string, jwt: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsRefreshAgentCredentialResponse>;
|
|
2674
|
+
/**
|
|
2675
|
+
* Revoke an agent credential, running the challenge-binding ceremony internally.
|
|
2676
|
+
* `humanKeyId` is the owning human key challenged by the ceremony (distinct from
|
|
2677
|
+
* the agent `keyId` in `params`).
|
|
2678
|
+
*/
|
|
2679
|
+
revokeAgentCredentialWithCeremony(params: Omit<KmsRevokeAgentCredentialRequest, "webAuthnAssertion" | "passkeyAssertion">, humanKeyId: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<KmsRevokeAgentCredentialResponse>;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
interface CreateP256SessionKeyRequest {
|
|
2683
|
+
/** Human (root) key under which the session key is minted. */
|
|
2684
|
+
humanKeyId: string;
|
|
2685
|
+
/** Optional human-readable label for the session key. */
|
|
2686
|
+
label?: string;
|
|
2687
|
+
/**
|
|
2688
|
+
* One-time WebAuthn assertion gating creation. The challenge comes from a
|
|
2689
|
+
* generic {@link KmsManager.beginAuthentication} ceremony — the caller runs
|
|
2690
|
+
* the ceremony and supplies the resulting assertion here.
|
|
2691
|
+
*/
|
|
2692
|
+
webAuthnAssertion?: WebAuthnAssertion;
|
|
2693
|
+
}
|
|
2694
|
+
interface CreateP256SessionKeyResponse {
|
|
2695
|
+
keyId: string;
|
|
2696
|
+
pubKeyX: string;
|
|
2697
|
+
pubKeyY: string;
|
|
2698
|
+
algorithm: string;
|
|
2699
|
+
agentCredential: string;
|
|
2700
|
+
expiresAt: number;
|
|
2701
|
+
}
|
|
2702
|
+
interface SignP256UserOpRequest {
|
|
2703
|
+
keyId: string;
|
|
2704
|
+
payload: string;
|
|
2705
|
+
accountAddress: string;
|
|
2706
|
+
}
|
|
2707
|
+
interface SignP256UserOpResponse {
|
|
2708
|
+
keyId: string;
|
|
2709
|
+
pubKeyX: string;
|
|
2710
|
+
pubKeyY: string;
|
|
2711
|
+
/**
|
|
2712
|
+
* 149-byte P256 session-key wire format (hex):
|
|
2713
|
+
* [0x08][account(20)][keyX(32)][keyY(32)][r(32)][s(32)].
|
|
2714
|
+
*/
|
|
2715
|
+
signature: string;
|
|
2716
|
+
}
|
|
2717
|
+
interface RevokeP256SessionKeyRequest {
|
|
2718
|
+
keyId: string;
|
|
2719
|
+
/**
|
|
2720
|
+
* One-time WebAuthn assertion gating revocation. The challenge comes from a
|
|
2721
|
+
* generic {@link KmsManager.beginAuthentication} ceremony — the caller runs
|
|
2722
|
+
* the ceremony and supplies the resulting assertion here.
|
|
2723
|
+
*/
|
|
2724
|
+
webAuthnAssertion?: WebAuthnAssertion;
|
|
2725
|
+
}
|
|
2726
|
+
interface RevokeP256SessionKeyResponse {
|
|
2727
|
+
success: boolean;
|
|
2728
|
+
revokedAt: number;
|
|
2729
|
+
}
|
|
2730
|
+
/**
|
|
2731
|
+
* Manages the lifecycle of a P-256 session key minted under a human key for
|
|
2732
|
+
* ERC-4337 UserOp signing (AAStar TEE KMS v0.20.0).
|
|
2733
|
+
*
|
|
2734
|
+
* A session key is created under a root (human) key, used to sign UserOps via a
|
|
2735
|
+
* TEE-issued bearer JWT (the `agentCredential`), and eventually revoked. The
|
|
2736
|
+
* per-UserOp signature is the 149-byte P256 session-key wire format.
|
|
2737
|
+
*
|
|
2738
|
+
* Relationship to {@link KmsManager.signP256GrantSession}: that method signs the
|
|
2739
|
+
* GRANT_P256_SESSION_V2 authorization needed to *install* this key on-chain
|
|
2740
|
+
* (granting the session key its on-chain scope/policies). This service instead
|
|
2741
|
+
* manages the session key's own lifecycle (create / sign / revoke) once granted.
|
|
2742
|
+
*
|
|
2743
|
+
* Create and revoke are WebAuthn-gated: the challenge originates from a generic
|
|
2744
|
+
* {@link KmsManager.beginAuthentication} ceremony and the caller supplies the
|
|
2745
|
+
* resulting assertion. Per-UserOp signing authenticates with the bearer JWT.
|
|
2746
|
+
*
|
|
2747
|
+
* Wraps a shared {@link KmsHttpClient} — pass `KmsManager.httpClient`.
|
|
2748
|
+
*/
|
|
2749
|
+
declare class KmsSessionService {
|
|
2750
|
+
private readonly http;
|
|
2751
|
+
constructor(http: KmsHttpClient);
|
|
2752
|
+
/**
|
|
2753
|
+
* Create a P-256 session key under a human key (WebAuthn-gated).
|
|
2754
|
+
*
|
|
2755
|
+
* `POST /kms/create-p256-session-key`. The `webAuthnAssertion` challenge comes
|
|
2756
|
+
* from a generic {@link KmsManager.beginAuthentication} ceremony supplied by
|
|
2757
|
+
* the caller. Returns the session key's public key plus an `agentCredential`
|
|
2758
|
+
* JWT used to authenticate subsequent {@link signP256UserOp} calls.
|
|
2759
|
+
*/
|
|
2760
|
+
createP256SessionKey(params: CreateP256SessionKeyRequest): Promise<CreateP256SessionKeyResponse>;
|
|
2761
|
+
/**
|
|
2762
|
+
* Sign an ERC-4337 UserOp hash with a P-256 session key (Bearer JWT auth).
|
|
2763
|
+
*
|
|
2764
|
+
* `POST /kms/sign-p256-user-op`, authenticated with the `agentCredential` JWT
|
|
2765
|
+
* returned by {@link createP256SessionKey}. Returns the 149-byte P256
|
|
2766
|
+
* session-key wire-format signature.
|
|
2767
|
+
*/
|
|
2768
|
+
signP256UserOp(params: SignP256UserOpRequest, jwt: string): Promise<SignP256UserOpResponse>;
|
|
2769
|
+
/**
|
|
2770
|
+
* Revoke a P-256 session key (WebAuthn-gated, idempotent).
|
|
2771
|
+
*
|
|
2772
|
+
* `POST /kms/revoke-p256-session-key`. The `webAuthnAssertion` challenge comes
|
|
2773
|
+
* from a generic {@link KmsManager.beginAuthentication} ceremony supplied by
|
|
2774
|
+
* the caller. Idempotent: revoking an already-revoked key still resolves.
|
|
2775
|
+
*/
|
|
2776
|
+
revokeP256SessionKey(params: RevokeP256SessionKeyRequest): Promise<RevokeP256SessionKeyResponse>;
|
|
2777
|
+
/** Create a P-256 session key, running the challenge-binding ceremony internally. */
|
|
2778
|
+
createP256SessionKeyWithCeremony(params: Omit<CreateP256SessionKeyRequest, "webAuthnAssertion">, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<CreateP256SessionKeyResponse>;
|
|
2779
|
+
/**
|
|
2780
|
+
* Revoke a P-256 session key, running the challenge-binding ceremony internally.
|
|
2781
|
+
* `humanKeyId` is the owning human key challenged by the ceremony (distinct from
|
|
2782
|
+
* the session `keyId` in `params`).
|
|
2783
|
+
*/
|
|
2784
|
+
revokeP256SessionKeyWithCeremony(params: Omit<RevokeP256SessionKeyRequest, "webAuthnAssertion">, humanKeyId: string, signer: PasskeyCeremonySigner, options?: Omit<RunCeremonyOptions, "signer">): Promise<RevokeP256SessionKeyResponse>;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
type KmsPaymentAuth = {
|
|
2788
|
+
jwt: string;
|
|
2789
|
+
} | {
|
|
2790
|
+
webAuthnAssertion: WebAuthnAssertion;
|
|
2791
|
+
};
|
|
2792
|
+
/** Shared signature response for all payment signing endpoints. */
|
|
2793
|
+
interface KmsPaymentSignatureResponse {
|
|
2794
|
+
keyId: string;
|
|
2795
|
+
signature: string;
|
|
2796
|
+
}
|
|
2797
|
+
interface KmsSignMicropaymentVoucherRequest {
|
|
2798
|
+
keyId: string;
|
|
2799
|
+
hdPath?: string;
|
|
2800
|
+
chainId: number;
|
|
2801
|
+
verifyingContract: string;
|
|
2802
|
+
channelId: string;
|
|
2803
|
+
cumulativeAmount: string;
|
|
2804
|
+
}
|
|
2805
|
+
interface KmsSignGTokenAuthorizationRequest {
|
|
2806
|
+
keyId: string;
|
|
2807
|
+
hdPath?: string;
|
|
2808
|
+
chainId: number;
|
|
2809
|
+
gTokenAddress: string;
|
|
2810
|
+
from: string;
|
|
2811
|
+
to: string;
|
|
2812
|
+
value: string;
|
|
2813
|
+
validAfter: string;
|
|
2814
|
+
validBefore: string;
|
|
2815
|
+
nonce: string;
|
|
2816
|
+
}
|
|
2817
|
+
interface KmsSignX402PaymentRequest {
|
|
2818
|
+
keyId: string;
|
|
2819
|
+
hdPath?: string;
|
|
2820
|
+
chainId: number;
|
|
2821
|
+
verifyingContract: string;
|
|
2822
|
+
paymentId: string;
|
|
2823
|
+
amount: string;
|
|
2824
|
+
recipient: string;
|
|
2825
|
+
deadline: string;
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Convenience signers for SuperPaymaster payment flows (v0.20.0 P2).
|
|
2829
|
+
*
|
|
2830
|
+
* Each method maps to a fixed EIP-712 domain + type that the KMS builds host-side
|
|
2831
|
+
* and signs inside the TEE; the SDK only forwards the structured parameters. Every
|
|
2832
|
+
* endpoint accepts EITHER a one-time `webAuthnAssertion` in the body OR an agent
|
|
2833
|
+
* Bearer JWT — see {@link KmsPaymentAuth}.
|
|
2834
|
+
*
|
|
2835
|
+
* Wraps a shared {@link KmsHttpClient}; reuse the same instance across the agent /
|
|
2836
|
+
* session / payment / monitor services.
|
|
2837
|
+
*/
|
|
2838
|
+
declare class KmsPaymentSigner {
|
|
2839
|
+
private readonly http;
|
|
2840
|
+
constructor(http: KmsHttpClient);
|
|
2841
|
+
/**
|
|
2842
|
+
* Dispatch a payment-signing request with the chosen auth mode.
|
|
2843
|
+
* JWT auth uses `postWithBearer`; WebAuthn auth merges the assertion into the body.
|
|
2844
|
+
*/
|
|
2845
|
+
private signWithAuth;
|
|
2846
|
+
/**
|
|
2847
|
+
* Sign a MicroPaymentChannel voucher (cumulative-amount EIP-712 message)
|
|
2848
|
+
* via `POST /kms/SignMicropaymentVoucher`.
|
|
2849
|
+
*/
|
|
2850
|
+
signMicropaymentVoucher(params: KmsSignMicropaymentVoucherRequest, auth: KmsPaymentAuth): Promise<KmsPaymentSignatureResponse>;
|
|
2851
|
+
/**
|
|
2852
|
+
* Sign an EIP-3009 TransferWithAuthorization for a GToken transfer
|
|
2853
|
+
* via `POST /kms/SignGTokenAuthorization`. `from` MUST equal the derived address.
|
|
2854
|
+
*/
|
|
2855
|
+
signGTokenAuthorization(params: KmsSignGTokenAuthorizationRequest, auth: KmsPaymentAuth): Promise<KmsPaymentSignatureResponse>;
|
|
2856
|
+
/**
|
|
2857
|
+
* Sign an x402 payment authorization via `POST /kms/SignX402Payment`.
|
|
2858
|
+
*/
|
|
2859
|
+
signX402Payment(params: KmsSignX402PaymentRequest, auth: KmsPaymentAuth): Promise<KmsPaymentSignatureResponse>;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
/**
|
|
2863
|
+
* Liveness probe response. Returned by `GET /health` without auth — works even
|
|
2864
|
+
* when the SDK's KMS feature flag is off.
|
|
2865
|
+
*/
|
|
2866
|
+
interface KmsHealthResponse {
|
|
2867
|
+
status: string;
|
|
2868
|
+
service?: string;
|
|
2869
|
+
ta_mode?: string;
|
|
2870
|
+
version?: string;
|
|
2871
|
+
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Version / capability descriptor. Returned by `GET /version` without auth.
|
|
2874
|
+
* Extra fields are passed through.
|
|
2875
|
+
*/
|
|
2876
|
+
interface KmsVersionResponse {
|
|
2877
|
+
version?: string;
|
|
2878
|
+
ta_mode?: string;
|
|
2879
|
+
endpoints?: string[];
|
|
2880
|
+
[k: string]: unknown;
|
|
2881
|
+
}
|
|
2882
|
+
/**
|
|
2883
|
+
* KMS request-queue health, including circuit-breaker state. Useful for
|
|
2884
|
+
* back-pressure decisions before submitting signing operations.
|
|
2885
|
+
*/
|
|
2886
|
+
interface KmsQueueStatusResponse {
|
|
2887
|
+
queue_depth: number;
|
|
2888
|
+
estimated_wait_seconds: number;
|
|
2889
|
+
circuit_breaker_open: boolean;
|
|
2890
|
+
consecutive_failures: number;
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* RPMB anti-rollback monotonic counter (diagnostic, v0.20.0). The exact shape
|
|
2894
|
+
* is undocumented; the known `counter` field is surfaced and all other fields
|
|
2895
|
+
* are passed through.
|
|
2896
|
+
*/
|
|
2897
|
+
interface KmsRollbackCounterResponse {
|
|
2898
|
+
counter?: number;
|
|
2899
|
+
[k: string]: unknown;
|
|
2900
|
+
}
|
|
2901
|
+
/**
|
|
2902
|
+
* Machine-readable runtime statistics (v0.20.0). Pass-through; the response is
|
|
2903
|
+
* not strongly typed. Known top-level fields:
|
|
2904
|
+
* - `wallets` — wallet / key counts
|
|
2905
|
+
* - `tx` — transaction / signing counts
|
|
2906
|
+
* - `queue` — queue depth and timing metrics
|
|
2907
|
+
* - `warnings` — active operational warnings
|
|
2908
|
+
*/
|
|
2909
|
+
interface KmsStatsResponse {
|
|
2910
|
+
[k: string]: unknown;
|
|
2911
|
+
}
|
|
2912
|
+
/** `GET /attestation` evidence bound to a caller nonce (#37). */
|
|
2913
|
+
interface KmsAttestationResponse {
|
|
2914
|
+
schema?: string;
|
|
2915
|
+
nonce?: string;
|
|
2916
|
+
ta_uuid?: string;
|
|
2917
|
+
ta_measurement?: string;
|
|
2918
|
+
signature?: string;
|
|
2919
|
+
attest_pubkey_exp?: string;
|
|
2920
|
+
attest_pubkey_mod?: string;
|
|
2921
|
+
sig_alg?: number;
|
|
2922
|
+
ree_time_secs?: number;
|
|
2923
|
+
trust_root?: string;
|
|
2924
|
+
[k: string]: unknown;
|
|
2925
|
+
}
|
|
2926
|
+
/** `GET /.well-known/attestation-measurements.json` — Ed25519-signed manifest (#12). */
|
|
2927
|
+
interface KmsAttestationManifestResponse {
|
|
2928
|
+
body?: Record<string, unknown>;
|
|
2929
|
+
publisher_key?: string;
|
|
2930
|
+
signature?: string;
|
|
2931
|
+
[k: string]: unknown;
|
|
2932
|
+
}
|
|
2933
|
+
/** `GET /.well-known/attestation-measurements-proof.json` — Sigsum proof sidecar (#87). */
|
|
2934
|
+
interface KmsAttestationProofResponse {
|
|
2935
|
+
proof?: Record<string, unknown>;
|
|
2936
|
+
[k: string]: unknown;
|
|
2937
|
+
}
|
|
2938
|
+
/**
|
|
2939
|
+
* Response of the destructive operator-only purge action (v0.20.0).
|
|
2940
|
+
* Pass-through; the response shape is not strongly typed.
|
|
2941
|
+
*/
|
|
2942
|
+
interface KmsPurgeKeyResponse {
|
|
2943
|
+
[k: string]: unknown;
|
|
2944
|
+
}
|
|
2945
|
+
/**
|
|
2946
|
+
* Infrastructure monitoring + operator admin surface for the AAStar TEE KMS
|
|
2947
|
+
* (v0.20.0, kms.aastar.io).
|
|
2948
|
+
*
|
|
2949
|
+
* Wraps a shared {@link KmsHttpClient}. Liveness probes (`health`, `version`)
|
|
2950
|
+
* intentionally bypass the `enabled` gate so they work even when the SDK's KMS
|
|
2951
|
+
* feature flag is off; every other method calls `ensureEnabled()` first.
|
|
2952
|
+
*/
|
|
2953
|
+
declare class KmsMonitorService {
|
|
2954
|
+
private readonly http;
|
|
2955
|
+
constructor(http: KmsHttpClient);
|
|
2956
|
+
/**
|
|
2957
|
+
* Liveness probe (`GET /health`, no auth). Does NOT require the KMS feature
|
|
2958
|
+
* flag to be enabled.
|
|
2959
|
+
*/
|
|
2960
|
+
health(): Promise<KmsHealthResponse>;
|
|
2961
|
+
/**
|
|
2962
|
+
* Version / capability descriptor (`GET /version`, no auth). Does NOT require
|
|
2963
|
+
* the KMS feature flag to be enabled.
|
|
2964
|
+
*/
|
|
2965
|
+
version(): Promise<KmsVersionResponse>;
|
|
2966
|
+
/**
|
|
2967
|
+
* Request-queue health and circuit-breaker state (`GET /QueueStatus`).
|
|
2968
|
+
*/
|
|
2969
|
+
queueStatus(): Promise<KmsQueueStatusResponse>;
|
|
2970
|
+
/**
|
|
2971
|
+
* RPMB anti-rollback monotonic counter (`GET /RollbackCounter`, diagnostic,
|
|
2972
|
+
* v0.20.0).
|
|
2973
|
+
*/
|
|
2974
|
+
rollbackCounter(): Promise<KmsRollbackCounterResponse>;
|
|
2975
|
+
/**
|
|
2976
|
+
* Machine-readable runtime statistics (`GET /stats`, v0.20.0) — wallets, tx,
|
|
2977
|
+
* queue, warnings.
|
|
2978
|
+
*/
|
|
2979
|
+
stats(): Promise<KmsStatsResponse>;
|
|
2980
|
+
/**
|
|
2981
|
+
* TEE remote-attestation evidence bound to a caller nonce (`GET /attestation`,
|
|
2982
|
+
* #37). Public (no auth) — pass a fresh random `nonce` (hex, ≤64 bytes) to bind
|
|
2983
|
+
* the evidence + defeat replay, then verify the returned signed measurement.
|
|
2984
|
+
*/
|
|
2985
|
+
getAttestation(nonce: string): Promise<KmsAttestationResponse>;
|
|
2986
|
+
/**
|
|
2987
|
+
* Ed25519-signed measurement manifest, version → ta_measurement
|
|
2988
|
+
* (`GET /.well-known/attestation-measurements.json`, #12). Public.
|
|
2989
|
+
*/
|
|
2990
|
+
getAttestationMeasurements(): Promise<KmsAttestationManifestResponse>;
|
|
2991
|
+
/**
|
|
2992
|
+
* Sigsum transparency proof sidecar for the measurement manifest
|
|
2993
|
+
* (`GET /.well-known/attestation-measurements-proof.json`, #87). Public.
|
|
2994
|
+
*/
|
|
2995
|
+
getAttestationMeasurementsProof(): Promise<KmsAttestationProofResponse>;
|
|
2996
|
+
/**
|
|
2997
|
+
* WARNING — DESTRUCTIVE, IRREVERSIBLE. Force-purges a key from both the TEE
|
|
2998
|
+
* and the SQLite store with NO passkey/WebAuthn check (`POST /admin/purge-key`,
|
|
2999
|
+
* v0.20.0). Operator-only: authorised solely by the `KMS_ADMIN_TOKEN` operator
|
|
3000
|
+
* secret sent as `Authorization: Bearer <adminToken>`. There is no recovery
|
|
3001
|
+
* once a key is purged.
|
|
3002
|
+
*
|
|
3003
|
+
* @internal Operator/break-glass tooling only — not part of the general SDK surface.
|
|
3004
|
+
* The endpoint is gated server-side and intentionally omitted from the public KMS
|
|
3005
|
+
* docs; do not expose it in application-facing flows.
|
|
3006
|
+
*/
|
|
3007
|
+
adminPurgeKey(params: {
|
|
3008
|
+
key_id: string;
|
|
3009
|
+
reason: string;
|
|
3010
|
+
}, adminToken: string): Promise<KmsPurgeKeyResponse>;
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
/**
|
|
3014
|
+
* In-memory storage adapter — useful for testing and demos.
|
|
3015
|
+
* All data is lost when the process exits.
|
|
3016
|
+
*/
|
|
3017
|
+
declare class MemoryStorage implements IStorageAdapter {
|
|
3018
|
+
private accounts;
|
|
3019
|
+
private transfers;
|
|
3020
|
+
private paymasters;
|
|
3021
|
+
private blsConfig;
|
|
3022
|
+
getAccounts(): Promise<AccountRecord[]>;
|
|
3023
|
+
saveAccount(account: AccountRecord): Promise<void>;
|
|
3024
|
+
findAccountByUserId(userId: string): Promise<AccountRecord | null>;
|
|
3025
|
+
updateAccount(userId: string, updates: Partial<AccountRecord>): Promise<void>;
|
|
3026
|
+
saveTransfer(transfer: TransferRecord): Promise<void>;
|
|
3027
|
+
findTransfersByUserId(userId: string): Promise<TransferRecord[]>;
|
|
3028
|
+
findTransferById(id: string): Promise<TransferRecord | null>;
|
|
3029
|
+
updateTransfer(id: string, updates: Partial<TransferRecord>): Promise<void>;
|
|
3030
|
+
getPaymasters(userId: string): Promise<PaymasterRecord[]>;
|
|
3031
|
+
savePaymaster(userId: string, paymaster: PaymasterRecord): Promise<void>;
|
|
3032
|
+
removePaymaster(userId: string, name: string): Promise<boolean>;
|
|
3033
|
+
getBlsConfig(): Promise<BlsConfigRecord | null>;
|
|
3034
|
+
updateSignerNodesCache(nodes: unknown[]): Promise<void>;
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
/**
|
|
3038
|
+
* Local wallet signer — backs all users with a single private key.
|
|
3039
|
+
* Suitable for testing, demos, and single-tenant server setups.
|
|
3040
|
+
*
|
|
3041
|
+
* For multi-tenant production use, implement ISignerAdapter with
|
|
3042
|
+
* per-user key management (e.g., KMS, HSM, or encrypted database).
|
|
3043
|
+
*/
|
|
3044
|
+
declare class LocalWalletSigner implements ISignerAdapter {
|
|
3045
|
+
private readonly account;
|
|
3046
|
+
constructor(privateKey: string);
|
|
3047
|
+
getAddress(_userId: string): Promise<`0x${string}`>;
|
|
3048
|
+
signMessage(_userId: string, message: `0x${string}` | Uint8Array, _ctx?: PasskeyAssertionContext): Promise<`0x${string}`>;
|
|
3049
|
+
ensureSigner(_userId: string): Promise<{
|
|
3050
|
+
address: `0x${string}`;
|
|
3051
|
+
}>;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
export { ACCOUNT_ABI, AGENT_SESSION_KEY_VALIDATOR_ABI, AIRACCOUNT_ABI, AIRACCOUNT_ADDRESSES, AIRACCOUNT_FACTORY_ABI, AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI, AIR_ACCOUNT_DELEGATE_ABI, AIR_ACCOUNT_DELEGATE_ADDRESS, ALG_ID, AccountManager, type AccountRecord, type ActiveRecovery, AgentRegistryService, type AgentReputationSummary, type AgentSessionConfig, type AgentSessionInfo, AirAccountServerClient, type AirAccountVersion, BLSSignatureData, BLSSignatureService, type BeginCeremonyResponse, type BindERC8004AgentWalletParams, type BlsConfigRecord, type BuildCredentialOptions, CALLDATA_PARSER_REGISTRY_ABI, ConsoleLogger, type CreateAgentAccountParams, type CreateP256SessionKeyRequest, type CreateP256SessionKeyResponse, DEFAULT_CREDENTIAL_ID, DEFAULT_KMS_ENDPOINT, DEFAULT_ORIGIN, DEFAULT_RP_ID, type DelegateInitParams, DvtPendingConfirmationError, type EIP7702Authorization, EIP7702DelegateService, ENTRYPOINT_ABI_V6, ENTRYPOINT_ABI_V7_V8, ENTRYPOINT_ADDRESSES, ERC20_ABI, ERC8004Service, ERC8004_ADDRESSES, EXECUTE_BATCH_SELECTOR, EXECUTE_SELECTOR, EXECUTE_USER_OP_SELECTOR, type EntryPointConfig, EntryPointVersion, type EntryPointVersionConfig, type EstimateGasParams, EthereumProvider, type ExecuteTransferParams, FACTORY_ABI_V6, FACTORY_ABI_V7_V8, FORCE_EXIT_MODULE_ABI, ForceExitService, GLOBAL_GUARD_ABI, type GrantP256SessionParams, type GrantSessionParams, GuardChecker, type GuardState, GuardStateReader, GuardStatus, type ILogger, type ISignerAdapter, type IStorageAdapter, type InstallModuleParams, KmsAgentService, type KmsAttestationManifestResponse, type KmsAttestationProofResponse, type KmsAttestationResponse, type KmsBeginAuthenticationRequest, type KmsBeginAuthenticationResponse, type KmsBeginGrantSessionAuthRequest, type KmsBeginGrantSessionAuthResponse, type KmsBeginRegistrationRequest, type KmsBeginRegistrationResponse, type KmsChangePasskeyResponse, type KmsCompleteRegistrationRequest, type KmsCompleteRegistrationResponse, type KmsCreateAgentKeyRequest, type KmsCreateAgentKeyResponse, type KmsCreateKeyRequest, type KmsCreateKeyResponse, type KmsDeleteKeyResponse, type KmsDeriveAddressResponse, type KmsDescribeKeyResponse, type KmsEip712Domain, type KmsEip712FieldValue, type KmsEip712TypeDef, type KmsEthereumTransaction, type KmsGetPublicKeyResponse, type KmsHealthResponse, KmsHttpClient, type KmsHttpClientOptions, type KmsKeyStatusResponse, type KmsListKeysResponse, KmsManager, KmsMonitorService, type KmsPaymentAuth, type KmsPaymentSignatureResponse, KmsPaymentSigner, type KmsPurgeKeyResponse, type KmsQueueStatusResponse, type KmsRefreshAgentCredentialRequest, type KmsRefreshAgentCredentialResponse, type KmsRevokeAgentCredentialRequest, type KmsRevokeAgentCredentialResponse, type KmsRollbackCounterResponse, KmsSessionService, type KmsSignAgentRequest, type KmsSignAgentResponse, type KmsSignGTokenAuthorizationRequest, type KmsSignGrantSessionRequest, type KmsSignGrantSessionResponse, type KmsSignHashResponse, type KmsSignMicropaymentVoucherRequest, type KmsSignP256GrantSessionRequest, type KmsSignRequest, type KmsSignResponse, type KmsSignTypedDataRequest, type KmsSignTypedDataResponse, type KmsSignX402PaymentRequest, KmsSigner, type KmsStatsResponse, type KmsVersionResponse, type L2Type, L2_TYPE, type LegacyPasskeyAssertion, LocalWalletSigner, MAX_GUARDIANS, MODULE_TYPE, MemoryStorage, type MintAgentIdentityParams, ModuleManager, type ModuleTypeId, type OapdConfig, P256PasskeySigner, PackedUserOperation, type PasskeyAssertionContext, type PasskeyCeremonySigner, PaymasterManager, PaymasterPriceStalenessError, type PaymasterRecord, type PendingExit, type PendingWeightChange, PreCheckResult, type QueryAgentReputationParams, RECOVERY_THRESHOLD, RECOVERY_TIMELOCK_SECONDS, RecoveryService, type RevokeP256SessionKeyRequest, type RevokeP256SessionKeyResponse, type RunCeremonyOptions, SESSION_KEY_VALIDATOR_ABI, type ServerConfig, type SessionInfo, SessionKeyService, type SetAgentWalletParams, type SignP256UserOpRequest, type SignP256UserOpResponse, SilentLogger, type SubmitAgentReputationParams, TIER_GUARD_HOOK_ABI, TierConfig, TierLevel$1 as TierLevel, type TokenBalance, type TokenGuardState, type TokenInfo, TokenService, TransferManager, type TransferRecord, type TransferResult, type UninstallModuleParams, UserOperation, VALIDATOR_ABI, WEIGHT_CHANGE_EXPIRY_SECONDS, WEIGHT_CHANGE_THRESHOLD, WEIGHT_CHANGE_TIMELOCK_SECONDS, WalletManager, type WebAuthnAssertion, type WebAuthnAuthenticationCredential, type WeightConfig, WeightedSignatureService, YAAAServerClient, base64UrlDecode, base64UrlEncode, beginAuthenticationChallenge, beginGrantSessionChallenge, buildAuthenticationCredential, buildAuthenticatorData, buildClientDataJSON, buildInstallModuleHash, buildUninstallModuleHash, computeOapdSalt, erc8004AddressesForChain, getOapdAddress, getOapdAddressWithChainId, isExecuteUserOpWrapped, isOapdDeployed, isPendingConfirmation, packP256SessionSignature, packSecp256k1SessionSignature, runAuthenticationCeremony, runGrantSessionCeremony, runWebAuthnCeremony, sepoliaV07Config, validateConfig, wrapExecuteUserOp };
|