@aura-payments/sdk 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1292 @@
1
+ import { PaginatedResponse } from '@aura-payments/shared';
2
+ export { PaginatedResponse, PaginationParams } from '@aura-payments/shared';
3
+
4
+ /**
5
+ * Escrow types for Aura Payments SDK
6
+ * Public API types for external developers
7
+ */
8
+ /**
9
+ * Escrow states (matches API schema)
10
+ */
11
+ type EscrowState = "initiated" | "deployed" | "funded" | "locked" | "released" | "refunded" | "disputed";
12
+ type UnlockType = "oracle" | "timeout" | "hybrid" | "manual";
13
+ type DisputeStatus = "open" | "investigating" | "resolved" | "closed";
14
+ /**
15
+ * Supported blockchain chains
16
+ */
17
+ type Chain = "ARC" | "ARB" | "BASE" | "ETH" | "MATIC";
18
+ /**
19
+ * Owner types for escrow splits
20
+ */
21
+ type OwnerType = "buyer" | "seller" | "platform" | "vendor" | "creator" | "affiliate" | "logistics" | "tax";
22
+ /**
23
+ * Split roles (excludes buyer)
24
+ */
25
+ type SplitRole = "seller" | "platform" | "vendor" | "creator" | "affiliate" | "logistics" | "tax";
26
+ /**
27
+ * Split configuration for creating escrow (input)
28
+ */
29
+ interface EscrowSplitInput {
30
+ ownerType: OwnerType;
31
+ ownerId: string;
32
+ role: SplitRole;
33
+ percentage: number;
34
+ }
35
+ /**
36
+ * Split in API response
37
+ */
38
+ interface EscrowSplitResponse {
39
+ splitId: string;
40
+ role: string;
41
+ basisPoints: number;
42
+ recipientWallet: {
43
+ walletId: string;
44
+ address: string;
45
+ };
46
+ }
47
+ /**
48
+ * Main escrow object (from GET /v1/escrow/:id)
49
+ */
50
+ interface Escrow {
51
+ escrowId: string;
52
+ orderId: string;
53
+ state: EscrowState;
54
+ buyerWalletId: string;
55
+ escrowWallet: {
56
+ walletId: string;
57
+ address: string;
58
+ circleWalletId: string;
59
+ };
60
+ buyerWallet: {
61
+ walletId: string;
62
+ address: string;
63
+ };
64
+ amount: string;
65
+ splits: EscrowSplitResponse[];
66
+ blockchain?: {
67
+ contractAddress: string | null;
68
+ chain: string;
69
+ factoryAddress: string | null;
70
+ deployed: boolean;
71
+ mode: string;
72
+ };
73
+ createdAt: string;
74
+ }
75
+ /**
76
+ * Parameters for creating an escrow
77
+ *
78
+ * Minimums:
79
+ * - `amount` must be large enough that, after platform fees (~1% + ~$0.009
80
+ * gas), each split receives at least $1 USDC. As a safe floor, use $10+
81
+ * for production flows; very small escrows ($1–$3) will be rejected with
82
+ * `VALIDATION_ERROR` when net-after-fees per split falls below $1.
83
+ */
84
+ interface CreateEscrowParams {
85
+ orderId: string;
86
+ buyerOwnerId: string;
87
+ amount: string;
88
+ chain?: Chain;
89
+ splits: EscrowSplitInput[];
90
+ }
91
+ /**
92
+ * Response from creating an escrow
93
+ *
94
+ * When created with async mode (default), includes:
95
+ * - async: true - indicates blockchain deployment is in progress
96
+ * - webhookPending: true - webhook will be sent when deployment completes
97
+ * - state: 'pending' - will transition to 'deployed' after contract deployment
98
+ */
99
+ interface CreateEscrowResponse {
100
+ escrowId: string;
101
+ orderId: string;
102
+ state: EscrowState;
103
+ buyerWalletId: string;
104
+ escrowWallet: {
105
+ walletId: string;
106
+ address: string;
107
+ circleWalletId: string;
108
+ };
109
+ buyerWallet: {
110
+ walletId: string;
111
+ address: string;
112
+ };
113
+ amount: string;
114
+ splits: EscrowSplitResponse[];
115
+ blockchain?: {
116
+ contractAddress: string | null;
117
+ chain: string;
118
+ factoryAddress: string | null;
119
+ deployed: boolean;
120
+ mode: string;
121
+ };
122
+ unlock?: {
123
+ type: 'manual' | 'timeout' | 'oracle' | 'hybrid';
124
+ unlockAt: string | null;
125
+ delaySeconds: number | null;
126
+ };
127
+ createdAt: string;
128
+ /** Present when using async mode (default) - indicates deployment in progress */
129
+ async?: boolean;
130
+ /** Present when using async mode - webhook will be sent on completion */
131
+ webhookPending?: boolean;
132
+ }
133
+ /**
134
+ * Parameters for funding an escrow
135
+ */
136
+ interface FundEscrowParams {
137
+ escrowId: string;
138
+ buyerWalletId: string;
139
+ amount: string;
140
+ correlationId?: string;
141
+ }
142
+ /**
143
+ * Parameters for releasing an escrow
144
+ */
145
+ interface ReleaseEscrowParams {
146
+ escrowId: string;
147
+ actorId: string;
148
+ reason?: string;
149
+ correlationId?: string;
150
+ }
151
+ /**
152
+ * Parameters for refunding an escrow
153
+ */
154
+ interface RefundEscrowParams {
155
+ escrowId: string;
156
+ reason: string;
157
+ actorId: string;
158
+ }
159
+ /**
160
+ * How far the `receiveAndSplit` loop progressed.
161
+ * - `created` — escrow created, on-chain deployment not yet confirmed
162
+ * - `deployed` — deployed, but funds not moved (payer balance short → see fundingRequired)
163
+ * - `funded` — escrow funded; not released (autoRelease:false)
164
+ * - `released` — funds split to recipients (terminal happy path)
165
+ */
166
+ type ReceiveAndSplitStage = 'created' | 'deployed' | 'funded' | 'released';
167
+ /**
168
+ * Parameters for the one-call receive→split primitive (board D4).
169
+ * Composes the existing create → fund → release escrow path.
170
+ */
171
+ interface ReceiveAndSplitParams {
172
+ /** Caller-provided order id, unique per account. */
173
+ orderId: string;
174
+ /** Entity that funds the escrow. May be the agent itself or a counterparty. */
175
+ payerOwnerId: string;
176
+ /** Whole-number USDC amount as a string (e.g. "50"). */
177
+ amount: string;
178
+ /** Payment splits; percentages must sum to 100. */
179
+ splits: EscrowSplitInput[];
180
+ /** Target chain. Defaults to 'ARC' (→ ARC-TESTNET). */
181
+ chain?: Chain;
182
+ /** Actor recorded on release. Defaults to `payerOwnerId`. */
183
+ actorId?: string;
184
+ /** Auto-release immediately after funding. Default true. */
185
+ autoRelease?: boolean;
186
+ /** Max time to wait for on-chain deployment before returning stage:'created'. Default 60000. */
187
+ waitForDeploymentMs?: number;
188
+ /** Max time to wait for funds to settle (funded/locked) before releasing. Default 60000. */
189
+ waitForFundingMs?: number;
190
+ /** Poll interval while waiting for deployment/funding (floored at 250ms). Default 2000. */
191
+ pollIntervalMs?: number;
192
+ /** Idempotency key for the create call (fund/release derive suffixed keys). */
193
+ idempotencyKey?: string;
194
+ }
195
+ /**
196
+ * Present when `receiveAndSplit` stops at `deployed` because the payer wallet
197
+ * lacks the funds to fund the escrow. Resume by funding this wallet (e.g.
198
+ * `wallets.requestTestnetFunds`) then re-running fund + release.
199
+ */
200
+ interface ReceiveAndSplitFundingRequired {
201
+ payerWalletId: string;
202
+ payerAddress: string;
203
+ /** Amount the escrow needs. */
204
+ amount: string;
205
+ /** Payer wallet's current USDC balance. */
206
+ available: string;
207
+ }
208
+ /**
209
+ * Result of `receiveAndSplit`. The `stage` field makes partial runs explicit
210
+ * and resumable instead of throwing opaquely.
211
+ */
212
+ interface ReceiveAndSplitResult {
213
+ stage: ReceiveAndSplitStage;
214
+ escrow: Escrow;
215
+ splits: EscrowSplitResponse[];
216
+ /** Set iff stage === 'deployed' due to insufficient payer balance. */
217
+ fundingRequired?: ReceiveAndSplitFundingRequired;
218
+ /** Set iff stage === 'created' because deployment didn't confirm in time. */
219
+ deploymentPending?: boolean;
220
+ /** Set iff stage === 'funded' because funds didn't settle within waitForFundingMs (do not release yet). */
221
+ fundingPending?: boolean;
222
+ }
223
+ /**
224
+ * Dispute object
225
+ */
226
+ interface Dispute {
227
+ id: string;
228
+ escrowId: string;
229
+ status: DisputeStatus;
230
+ reason: string;
231
+ evidence?: string[];
232
+ actorId: string;
233
+ resolution?: string;
234
+ resolvedBy?: string;
235
+ openedAt: string;
236
+ closedAt?: string;
237
+ }
238
+ /**
239
+ * Parameters for creating a dispute
240
+ */
241
+ interface CreateDisputeParams {
242
+ escrowId: string;
243
+ reason: string;
244
+ actorId: string;
245
+ evidence?: string[];
246
+ }
247
+ /**
248
+ * Sort options for escrow list
249
+ */
250
+ type EscrowSortBy = 'created_desc' | 'created_asc' | 'amount_desc' | 'amount_asc';
251
+ /**
252
+ * List escrows query parameters (matches API route)
253
+ */
254
+ interface ListEscrowsParams {
255
+ /** Search by escrow ID, order ID, or buyer wallet ID */
256
+ search?: string;
257
+ /** Filter by escrow state (or 'all' for all states) */
258
+ state?: EscrowState | 'all';
259
+ /** Sort order (default: created_desc) */
260
+ sortBy?: EscrowSortBy;
261
+ /** Number of results (default: 50) */
262
+ limit?: number;
263
+ /** Pagination offset (default: 0) */
264
+ offset?: number;
265
+ }
266
+ /**
267
+ * Escrow list item (from GET /v1/escrow response)
268
+ */
269
+ interface EscrowListItem {
270
+ id: string;
271
+ orderId: string;
272
+ state: string;
273
+ amountUsdc: string;
274
+ createdAt: string;
275
+ buyerWalletId: string;
276
+ splitCount: number;
277
+ }
278
+ /**
279
+ * Paginated escrow list response
280
+ */
281
+ interface ListEscrowsResponse {
282
+ escrows: EscrowListItem[];
283
+ total: number;
284
+ limit: number;
285
+ offset: number;
286
+ }
287
+
288
+ /**
289
+ * Agent types for Aura Payments SDK.
290
+ *
291
+ * Public API types covering the agent lifecycle: create, list, get, update,
292
+ * freeze/unfreeze, balance, and policy evaluation. Wire shapes match the
293
+ * platform's `/v1/agents` route handlers exactly — types are kept in sync
294
+ * with `lib/agents/agent-service.ts` and the Zod schemas in those routes.
295
+ */
296
+
297
+ type AgentType = 'treasury' | 'payment' | 'trading' | 'custom';
298
+ type AgentStatus = 'active' | 'paused' | 'archived';
299
+ type AgentRiskTier = 'low' | 'medium' | 'high' | 'critical';
300
+ type SpendingLimitType = 'per_transaction' | 'daily' | 'weekly' | 'monthly' | 'lifetime';
301
+ type MerchantRuleType = 'allowlist' | 'blocklist';
302
+ type MerchantDestinationType = 'address' | 'domain' | 'category' | 'entity_id';
303
+ interface SpendingLimitInput {
304
+ limitType: SpendingLimitType;
305
+ /** Whole-number USDC amount as string (e.g. `"100"`). */
306
+ maxAmount: string;
307
+ /** Defaults to `"USDC"` server-side. */
308
+ currency?: string;
309
+ }
310
+ interface MerchantRuleInput {
311
+ ruleType: MerchantRuleType;
312
+ destinationType: MerchantDestinationType;
313
+ /** For `address`, must be `0x` + 40 hex chars (validated server-side). */
314
+ destinationValue: string;
315
+ }
316
+ interface InitialPolicyInput {
317
+ name?: string;
318
+ description?: string;
319
+ spendingLimits?: SpendingLimitInput[];
320
+ merchantRules?: MerchantRuleInput[];
321
+ /** Amount above which a mandate (human approval) is required. */
322
+ requiresApprovalAbove?: string;
323
+ /** Amount below which the agent auto-approves without a mandate. */
324
+ autoApproveBelow?: string;
325
+ }
326
+ interface Agent {
327
+ id: string;
328
+ accountId: string;
329
+ name: string;
330
+ description?: string | null;
331
+ type: AgentType;
332
+ status: AgentStatus;
333
+ riskTier?: AgentRiskTier | null;
334
+ chain: Chain;
335
+ walletId?: string | null;
336
+ walletAddress?: string | null;
337
+ metadata?: Record<string, unknown> | null;
338
+ createdAt: string;
339
+ updatedAt: string;
340
+ }
341
+ interface CreateAgentParams {
342
+ name: string;
343
+ description?: string;
344
+ type: AgentType;
345
+ chain?: Chain;
346
+ metadata?: Record<string, unknown>;
347
+ initialPolicy?: InitialPolicyInput;
348
+ }
349
+ interface CreateAgentResponse {
350
+ agent: Agent;
351
+ policyId: string;
352
+ walletId: string;
353
+ walletAddress: string;
354
+ }
355
+ interface UpdateAgentParams {
356
+ name?: string;
357
+ description?: string | null;
358
+ status?: AgentStatus;
359
+ metadata?: Record<string, unknown> | null;
360
+ }
361
+ interface ListAgentsParams {
362
+ status?: AgentStatus;
363
+ type?: AgentType;
364
+ limit?: number;
365
+ offset?: number;
366
+ orderBy?: 'createdAt' | 'name';
367
+ orderDirection?: 'asc' | 'desc';
368
+ }
369
+ interface ListAgentsResponse {
370
+ agents: Agent[];
371
+ total: number;
372
+ limit: number;
373
+ offset: number;
374
+ hasMore: boolean;
375
+ }
376
+ interface FreezeAgentParams {
377
+ agentId: string;
378
+ /** Surfaced in the activity event metadata for the audit trail. */
379
+ reason?: string;
380
+ }
381
+ interface UnfreezeAgentParams {
382
+ agentId: string;
383
+ }
384
+ /**
385
+ * Returned by both freeze and unfreeze. `isActive` is a derived view of
386
+ * `status === 'active'` (no extra column on the agents table).
387
+ */
388
+ interface AgentStatusResponse {
389
+ id: string;
390
+ name: string;
391
+ status: AgentStatus;
392
+ isActive: boolean;
393
+ updatedAt: string;
394
+ }
395
+ interface AgentBalance {
396
+ agentId: string;
397
+ walletId: string;
398
+ walletAddress: string;
399
+ chain: Chain;
400
+ /** USDC balance as a decimal string. */
401
+ amount: string;
402
+ currency: 'USDC';
403
+ /** ISO-8601 timestamp of when the balance was fetched on-chain. */
404
+ fetchedAt: string;
405
+ }
406
+ type PolicyDecision = 'auto_approve' | 'auto_deny' | 'requires_human_approval';
407
+ interface EvaluatePolicyParams {
408
+ agentId: string;
409
+ /** USDC amount as decimal string. */
410
+ amount: string;
411
+ /** Counterparty wallet address (`0x...`) or merchant identifier. */
412
+ destination: string;
413
+ destinationType?: MerchantDestinationType;
414
+ /** Optional reasoning the agent will log alongside the decision. */
415
+ reasoning?: string;
416
+ metadata?: Record<string, unknown>;
417
+ }
418
+ interface EvaluatePolicyResponse {
419
+ decision: PolicyDecision;
420
+ /** Human-readable reason for the decision. */
421
+ reason: string;
422
+ /** When `requires_human_approval`, the mandate that was created (if any). */
423
+ mandateId?: string;
424
+ /** The matched rule(s) that drove the decision. */
425
+ matchedRules?: Array<{
426
+ kind: string;
427
+ ruleId?: string;
428
+ detail?: string;
429
+ }>;
430
+ }
431
+
432
+ /**
433
+ * Agents resource for the Aura Payments SDK.
434
+ *
435
+ * Wraps `/v1/agents/*` routes: create, list, get, update, freeze, unfreeze,
436
+ * balance, evaluate. All methods are account-scoped via the API key — the
437
+ * platform extracts `accountId` server-side; the SDK never sends it.
438
+ */
439
+
440
+ declare class Agents {
441
+ private client;
442
+ constructor(client: AuraClient);
443
+ /**
444
+ * Create a new AI agent with a dedicated wallet and (optional) initial
445
+ * policy. The platform provisions a Circle wallet on the requested chain
446
+ * during this call; expect a few seconds of latency for the on-chain part.
447
+ */
448
+ create(params: CreateAgentParams, idempotencyKey?: string): Promise<CreateAgentResponse>;
449
+ /**
450
+ * List agents for the authenticated account, paginated.
451
+ */
452
+ list(params?: ListAgentsParams): Promise<ListAgentsResponse>;
453
+ /**
454
+ * Get a single agent by id.
455
+ */
456
+ get(agentId: string): Promise<Agent>;
457
+ /**
458
+ * Patch an agent's metadata fields. Cannot be used to flip status — use
459
+ * `freeze`/`unfreeze` for that so the mandate-cascade and activity events
460
+ * fire correctly.
461
+ */
462
+ update(agentId: string, params: UpdateAgentParams, idempotencyKey?: string): Promise<Agent>;
463
+ /**
464
+ * Freeze (kill switch) — sets status to `paused` and cascade-rejects every
465
+ * pending mandate the agent has in flight. Idempotent.
466
+ */
467
+ freeze(params: FreezeAgentParams, idempotencyKey?: string): Promise<AgentStatusResponse>;
468
+ /**
469
+ * Unfreeze — sets status back to `active`. Previously cascade-rejected
470
+ * mandates are NOT restored; the agent re-creates them on its next loop.
471
+ */
472
+ unfreeze(params: UnfreezeAgentParams, idempotencyKey?: string): Promise<AgentStatusResponse>;
473
+ /**
474
+ * Get the agent's wallet balance (USDC, on-chain at request time).
475
+ */
476
+ getBalance(agentId: string): Promise<AgentBalance>;
477
+ /**
478
+ * Run a hypothetical transaction through the policy engine without
479
+ * executing it. Returns the engine's decision (`auto_approve`, `auto_deny`,
480
+ * or `requires_human_approval`) along with the matched rules. When the
481
+ * decision is `requires_human_approval`, the engine creates a mandate row
482
+ * and returns its id so the caller can watch for the operator's decision.
483
+ */
484
+ evaluate(params: EvaluatePolicyParams, idempotencyKey?: string): Promise<EvaluatePolicyResponse>;
485
+ }
486
+
487
+ /**
488
+ * Escrows resource for Aura Payments SDK
489
+ */
490
+
491
+ declare class Escrows {
492
+ private client;
493
+ constructor(client: AuraClient);
494
+ /**
495
+ * Create a new escrow
496
+ */
497
+ create(params: CreateEscrowParams, idempotencyKey?: string): Promise<CreateEscrowResponse>;
498
+ /**
499
+ * Get escrow by ID
500
+ */
501
+ get(escrowId: string): Promise<Escrow>;
502
+ /**
503
+ * List escrows with optional filters
504
+ */
505
+ list(params?: ListEscrowsParams): Promise<ListEscrowsResponse>;
506
+ /**
507
+ * Fund an escrow
508
+ */
509
+ fund(params: FundEscrowParams, idempotencyKey?: string): Promise<Escrow>;
510
+ /**
511
+ * Release an escrow
512
+ */
513
+ release(params: ReleaseEscrowParams, idempotencyKey?: string): Promise<Escrow>;
514
+ /**
515
+ * Refund an escrow
516
+ */
517
+ refund(params: RefundEscrowParams, idempotencyKey?: string): Promise<Escrow>;
518
+ /**
519
+ * Receive USDC and split it across recipients in a single call (board D4).
520
+ *
521
+ * Composes the existing, crash-safe escrow path:
522
+ * create → poll-until-deployed → pre-flight balance → fund → poll-until-funded → release.
523
+ *
524
+ * Funds move from an Aura wallet owned by `payerOwnerId` (the agent itself or a
525
+ * counterparty). The result's `stage` makes a partial run explicit:
526
+ * - `created` — deployment didn't confirm within `waitForDeploymentMs`
527
+ * - `deployed` — payer wallet lacks funds (see `fundingRequired`); no money moved
528
+ * - `funded` — funded but not released (`autoRelease:false`, or funding didn't
529
+ * settle within `waitForFundingMs` → `fundingPending: true`)
530
+ * - `released` — split to recipients (happy path)
531
+ *
532
+ * Resume note: a partial run is resumed by acting on the returned
533
+ * `escrow.escrowId` (call `fund`/`release` directly) — NOT by re-calling
534
+ * `receiveAndSplit`, which re-`create`s and would hit a duplicate-orderId error.
535
+ * Pass a stable `idempotencyKey` for retry-safe fund/release.
536
+ *
537
+ * Funding is asynchronous and the platform's fund/release endpoints return
538
+ * operation metadata (not a full escrow), so this method re-`get`s the escrow
539
+ * for authoritative state + splits rather than trusting those response bodies.
540
+ *
541
+ * @throws AuraValidationError if split percentages don't sum to 100 (pre-flight).
542
+ */
543
+ receiveAndSplit(params: ReceiveAndSplitParams): Promise<ReceiveAndSplitResult>;
544
+ /**
545
+ * Poll `get(escrowId)` until `predicate` holds or `budgetMs` elapses. Returns
546
+ * the last-observed escrow; the caller re-checks the predicate to branch.
547
+ * `seed` is the escrow already in hand, checked before any poll so a
548
+ * synchronously-settled escrow returns without a network round-trip.
549
+ */
550
+ private pollEscrowUntil;
551
+ /**
552
+ * Create a dispute for an escrow
553
+ */
554
+ createDispute(params: CreateDisputeParams, idempotencyKey?: string): Promise<Dispute>;
555
+ /**
556
+ * Get dispute details
557
+ */
558
+ getDispute(escrowId: string, disputeId: string): Promise<Dispute>;
559
+ }
560
+
561
+ /**
562
+ * Mandate types for Aura Payments SDK.
563
+ *
564
+ * A mandate is a single human-approval request raised when the agent's
565
+ * policy engine returns `requires_human_approval`. Operators decide
566
+ * (approve/reject) on mobile (biometric/passcode) or via the CLI (manual).
567
+ *
568
+ * Wire shape mirrors `agent_mandates` table + `lib/agents/mandate-service.ts`.
569
+ * Decision signature is HMAC over `${id}:${decision}:${decidedAt}`; the
570
+ * platform verifies before applying state changes.
571
+ */
572
+ type MandateStatus = 'pending' | 'approved' | 'rejected' | 'cancelled';
573
+ type MandateDecisionMethod = 'biometric' | 'passcode' | 'manual' | 'ttl_expired';
574
+ /**
575
+ * Discriminated union for the kinds of intents a mandate can carry.
576
+ * Each kind has its own `intent.payload` shape that the operator UI
577
+ * renders differently.
578
+ */
579
+ type MandateIntentKind = 'x402.payment' | 'escrow.fund' | 'escrow.release' | 'agent.policy.proposed' | 'agent.transfer';
580
+ interface MandateIntent {
581
+ kind: MandateIntentKind;
582
+ /** Human-readable summary the operator sees. */
583
+ summary: string;
584
+ /** Optional decimal-string amount in USDC (most kinds carry this). */
585
+ amount?: string;
586
+ currency?: 'USDC';
587
+ counterparty?: string;
588
+ /** Kind-specific payload. Type narrows on `kind`. */
589
+ payload: Record<string, unknown>;
590
+ }
591
+ interface Mandate {
592
+ id: string;
593
+ accountId: string;
594
+ agentId: string;
595
+ /** Denormalized agent name so inbox rows render without a join. */
596
+ agentName: string;
597
+ status: MandateStatus;
598
+ intent: MandateIntent;
599
+ /** ISO-8601. After this, the TTL sweeper auto-rejects. */
600
+ expiresAt: string;
601
+ createdAt: string;
602
+ decidedAt?: string;
603
+ /** User id of the operator who decided, or `kill-switch:<agentId>` for cascade. */
604
+ decidedBy?: string;
605
+ decisionMethod?: MandateDecisionMethod;
606
+ decisionSignature?: string;
607
+ }
608
+ interface ListMandatesParams {
609
+ status?: MandateStatus;
610
+ agentId?: string;
611
+ /** Page size, 1-200, defaults to 50. */
612
+ limit?: number;
613
+ /** Last mandate id from the previous page. */
614
+ cursor?: string;
615
+ }
616
+ interface ListMandatesResponse {
617
+ mandates: Mandate[];
618
+ /** Pass back as `cursor` to fetch the next page. `null` at end. */
619
+ nextCursor: string | null;
620
+ }
621
+ interface ApproveMandateParams {
622
+ mandateId: string;
623
+ /**
624
+ * `biometric`/`passcode` come from the mobile flow, `manual` from CLI/web.
625
+ * `ttl_expired` is reserved for the server-side sweeper.
626
+ */
627
+ decisionMethod: Exclude<MandateDecisionMethod, 'ttl_expired'>;
628
+ /**
629
+ * HMAC-SHA256 over `${mandateId}:approve:${decidedAt}`. Computed by the
630
+ * caller; the platform re-derives and verifies before applying.
631
+ */
632
+ decisionSignature: string;
633
+ /** ISO-8601. The signature commits to this; defaults to "now" server-side. */
634
+ decidedAt?: string;
635
+ }
636
+ interface RejectMandateParams {
637
+ mandateId: string;
638
+ decisionMethod: Exclude<MandateDecisionMethod, 'ttl_expired'>;
639
+ decisionSignature: string;
640
+ decidedAt?: string;
641
+ /** Optional human-readable reason logged to the activity feed. */
642
+ reason?: string;
643
+ }
644
+
645
+ /**
646
+ * Mandates resource for the Aura Payments SDK.
647
+ *
648
+ * Wraps `/v1/agent/mandates/*` routes (operator-facing inbox). Approve/reject
649
+ * require an HMAC decision signature — see `MandateSignature` helper below
650
+ * for computing it client-side.
651
+ */
652
+
653
+ declare class Mandates {
654
+ private client;
655
+ constructor(client: AuraClient);
656
+ /**
657
+ * List mandates for the authenticated account. Defaults to `status=pending`
658
+ * so this acts as the operator's inbox out of the box.
659
+ */
660
+ list(params?: ListMandatesParams): Promise<ListMandatesResponse>;
661
+ /**
662
+ * Convenience wrapper for the most common case: pending mandates in
663
+ * urgency order (most-expiring first).
664
+ */
665
+ listPending(extras?: Omit<ListMandatesParams, 'status'>): Promise<ListMandatesResponse>;
666
+ /**
667
+ * Get a single mandate by id.
668
+ */
669
+ get(mandateId: string): Promise<Mandate>;
670
+ /**
671
+ * Approve a pending mandate. Caller is responsible for computing
672
+ * `decisionSignature` — use `MandateSignature.compute()` below.
673
+ *
674
+ * Idempotent: re-approving an already-`approved` mandate returns 200 with
675
+ * the existing decision. Approving a `rejected`/`cancelled` mandate
676
+ * returns 409.
677
+ */
678
+ approve(params: ApproveMandateParams, idempotencyKey?: string): Promise<Mandate>;
679
+ /**
680
+ * Reject a pending mandate. Same signature scheme as `approve`.
681
+ */
682
+ reject(params: RejectMandateParams, idempotencyKey?: string): Promise<Mandate>;
683
+ }
684
+ /**
685
+ * Computes / verifies the HMAC-SHA256 signature the platform requires when
686
+ * deciding a mandate. The signature commits to the mandate id, the decision
687
+ * verb, and the timestamp so a stolen "approve" payload can't be replayed
688
+ * against a different mandate.
689
+ *
690
+ * Usage:
691
+ * ```ts
692
+ * const decidedAt = new Date().toISOString()
693
+ * const sig = MandateSignature.compute({
694
+ * mandateId,
695
+ * decision: 'approve',
696
+ * decidedAt,
697
+ * secret: process.env.MANDATE_HMAC_SECRET!,
698
+ * })
699
+ * await client.mandates.approve({
700
+ * mandateId,
701
+ * decisionMethod: 'manual',
702
+ * decisionSignature: sig,
703
+ * decidedAt,
704
+ * })
705
+ * ```
706
+ *
707
+ * The platform's verify lives at `lib/agents/mandate-signature.ts` and uses
708
+ * the same `${id}:${decision}:${decidedAt}` payload format. Keep them
709
+ * synchronized.
710
+ */
711
+ declare const MandateSignature: {
712
+ compute(input: {
713
+ mandateId: string;
714
+ decision: 'approve' | 'reject';
715
+ decidedAt: string;
716
+ secret: string;
717
+ }): string;
718
+ verify(input: {
719
+ mandateId: string;
720
+ decision: 'approve' | 'reject';
721
+ decidedAt: string;
722
+ secret: string;
723
+ signature: string;
724
+ }): boolean;
725
+ };
726
+
727
+ /**
728
+ * Policy types for Aura Payments SDK.
729
+ *
730
+ * Policies are the persistent rules that drive the agent's policy engine.
731
+ * Each agent has 1+ policies; each policy has spending limits + merchant
732
+ * rules + approval thresholds. Approving an `agent.policy.proposed` mandate
733
+ * creates a new policy via the same shape.
734
+ */
735
+
736
+ interface SpendingLimit {
737
+ id: string;
738
+ agentId: string;
739
+ policyId: string;
740
+ limitType: SpendingLimitInput['limitType'];
741
+ maxAmount: string;
742
+ currency: string;
743
+ createdAt: string;
744
+ }
745
+ interface MerchantRule {
746
+ id: string;
747
+ agentId: string;
748
+ policyId: string;
749
+ ruleType: MerchantRuleInput['ruleType'];
750
+ destinationType: MerchantRuleInput['destinationType'];
751
+ destinationValue: string;
752
+ createdAt: string;
753
+ }
754
+ interface AgentPolicy {
755
+ id: string;
756
+ accountId: string;
757
+ agentId: string;
758
+ name?: string | null;
759
+ description?: string | null;
760
+ /** Amount above which a mandate is required. Decimal string in USDC. */
761
+ requiresApprovalAbove?: string | null;
762
+ /** Amount below which the agent auto-approves silently. */
763
+ autoApproveBelow?: string | null;
764
+ spendingLimits: SpendingLimit[];
765
+ merchantRules: MerchantRule[];
766
+ createdAt: string;
767
+ updatedAt: string;
768
+ }
769
+ interface CreatePolicyParams {
770
+ agentId: string;
771
+ name?: string;
772
+ description?: string;
773
+ spendingLimits?: SpendingLimitInput[];
774
+ merchantRules?: MerchantRuleInput[];
775
+ requiresApprovalAbove?: string;
776
+ autoApproveBelow?: string;
777
+ }
778
+ interface ListPoliciesResponse {
779
+ policies: AgentPolicy[];
780
+ total: number;
781
+ }
782
+
783
+ /**
784
+ * Policies resource for the Aura Payments SDK.
785
+ *
786
+ * Wraps `/v1/agents/{agentId}/policies/*` routes for managing the persistent
787
+ * rules that drive the policy engine. Note: approving an `agent.policy.proposed`
788
+ * mandate also creates a new policy server-side — this resource is for direct
789
+ * policy CRUD outside the mandate flow.
790
+ */
791
+
792
+ declare class Policies {
793
+ private client;
794
+ constructor(client: AuraClient);
795
+ /**
796
+ * List all policies attached to an agent.
797
+ */
798
+ list(agentId: string): Promise<ListPoliciesResponse>;
799
+ /**
800
+ * Get a single policy by id (scoped to the parent agent).
801
+ */
802
+ get(agentId: string, policyId: string): Promise<AgentPolicy>;
803
+ /**
804
+ * Create a new policy for an agent. The agent's policy engine will start
805
+ * matching against this policy on the next evaluation.
806
+ */
807
+ create(params: CreatePolicyParams, idempotencyKey?: string): Promise<AgentPolicy>;
808
+ }
809
+
810
+ /**
811
+ * Wallet types for Aura Payments SDK
812
+ * Public API types for external developers
813
+ */
814
+
815
+ /**
816
+ * Wallet owner types - matches escrow split roles
817
+ */
818
+ type WalletOwnerType = 'BUSINESS' | 'buyer' | 'seller' | 'platform' | 'vendor' | 'creator' | 'affiliate' | 'logistics' | 'tax' | 'escrow';
819
+ /**
820
+ * Wallet object (from API response)
821
+ */
822
+ interface Wallet {
823
+ id: string;
824
+ accountId: string;
825
+ circleWalletId: string;
826
+ address: string;
827
+ chain: string;
828
+ custodyType: string;
829
+ ownerType: string;
830
+ ownerId: string;
831
+ userId: string | null;
832
+ circleUserId: string | null;
833
+ createdAt: string;
834
+ }
835
+ /**
836
+ * Resolved wallet returned by POST /v1/wallets (create-or-get).
837
+ * Note: the platform API returns `walletId` (not `id`) here for historical reasons.
838
+ */
839
+ interface ResolvedWallet {
840
+ walletId: string;
841
+ circleWalletId: string;
842
+ address: string;
843
+ ownerType: string;
844
+ ownerId: string;
845
+ chain: string;
846
+ createdAt: string;
847
+ accountId: string;
848
+ isNew: boolean;
849
+ }
850
+ /**
851
+ * Individual token balance
852
+ */
853
+ interface TokenBalance {
854
+ token: string;
855
+ symbol: string;
856
+ amount: string;
857
+ decimals: number;
858
+ }
859
+ /**
860
+ * Wallet balance response (GET /v1/wallets/:walletId/balance)
861
+ */
862
+ interface WalletBalance {
863
+ walletId: string;
864
+ address: string;
865
+ chain: Chain;
866
+ balance: {
867
+ usdc: string;
868
+ tokenBalances: TokenBalance[];
869
+ };
870
+ tokens?: TokenBalance[];
871
+ }
872
+ /**
873
+ * Parameters for creating a wallet (matches createWalletRequestSchema)
874
+ */
875
+ interface CreateWalletParams {
876
+ /** Your unique entity identifier */
877
+ entityId: string;
878
+ /** Blockchain chain (default: 'ARC') */
879
+ chain?: Chain;
880
+ /** Wallet owner type (default: 'BUSINESS') */
881
+ type?: WalletOwnerType;
882
+ }
883
+ /**
884
+ * Parameters for wallet transfer
885
+ */
886
+ interface TransferParams {
887
+ fromWalletId: string;
888
+ toAddress: string;
889
+ amount: string;
890
+ token?: string;
891
+ idempotencyKey?: string;
892
+ }
893
+ /**
894
+ * Transfer response
895
+ */
896
+ interface Transfer {
897
+ id: string;
898
+ txHash: string;
899
+ status: 'pending' | 'confirmed' | 'failed';
900
+ amount: string;
901
+ token: string;
902
+ fromAddress: string;
903
+ toAddress: string;
904
+ chain: Chain;
905
+ createdAt: string;
906
+ confirmedAt?: string;
907
+ }
908
+ /**
909
+ * Parameters for requesting testnet funds from the faucet.
910
+ *
911
+ * Testnet only. Backed by `POST /v1/wallets/:id/faucet` (provided by AURA-010);
912
+ * see {@link AuraFaucetUnavailableError} for the not-yet-deployed case.
913
+ */
914
+ interface RequestTestnetFundsParams {
915
+ /** Token to drip. Default: 'USDC'. */
916
+ token?: string;
917
+ /** Override the wallet's chain (testnet codes only). */
918
+ chain?: Chain;
919
+ }
920
+ /**
921
+ * Faucet response. Drips are asynchronous on-chain — the wallet balance may
922
+ * take a few seconds to reflect the funds.
923
+ */
924
+ interface RequestTestnetFundsResponse {
925
+ requested: boolean;
926
+ walletId: string;
927
+ address: string;
928
+ chain: string;
929
+ token: string;
930
+ /** Optional human-readable note (e.g. "drip queued; allow ~30s"). */
931
+ note?: string;
932
+ }
933
+ /**
934
+ * List wallets query parameters
935
+ */
936
+ interface ListWalletsParams {
937
+ entityId?: string;
938
+ chain?: Chain;
939
+ type?: WalletOwnerType;
940
+ page?: number;
941
+ limit?: number;
942
+ }
943
+ /**
944
+ * Paginated wallet list response
945
+ */
946
+ type ListWalletsResponse = PaginatedResponse<Wallet>;
947
+
948
+ /**
949
+ * Wallets resource for Aura Payments SDK
950
+ */
951
+
952
+ declare class Wallets {
953
+ private client;
954
+ constructor(client: AuraClient);
955
+ /**
956
+ * Create a new wallet
957
+ */
958
+ create(params: CreateWalletParams, idempotencyKey?: string): Promise<ResolvedWallet>;
959
+ /**
960
+ * Get wallet by ID
961
+ */
962
+ get(walletId: string): Promise<Wallet>;
963
+ /**
964
+ * List wallets with optional filters
965
+ */
966
+ list(params?: ListWalletsParams): Promise<ListWalletsResponse>;
967
+ /**
968
+ * Get wallet balance
969
+ */
970
+ getBalance(walletId: string): Promise<WalletBalance>;
971
+ /**
972
+ * Transfer funds from wallet
973
+ */
974
+ transfer(params: TransferParams): Promise<Transfer>;
975
+ /**
976
+ * Request testnet funds (USDC) for a wallet from the platform faucet.
977
+ *
978
+ * Testnet only. Backed by `POST /v1/wallets/:id/faucet`, provided by the
979
+ * platform (AURA-010). Until that endpoint ships, this capability-probes and
980
+ * raises {@link AuraFaucetUnavailableError} (rather than a generic 404/501)
981
+ * so callers can degrade gracefully to manual funding.
982
+ */
983
+ requestTestnetFunds(walletId: string, params?: RequestTestnetFundsParams): Promise<RequestTestnetFundsResponse>;
984
+ /**
985
+ * Get transfer by ID
986
+ */
987
+ getTransfer(walletId: string, transferId: string): Promise<Transfer>;
988
+ /**
989
+ * Generate a unique idempotency key
990
+ */
991
+ private generateIdempotencyKey;
992
+ }
993
+
994
+ /**
995
+ * Webhook types for Aura Payments SDK
996
+ * Public API types for external developers
997
+ */
998
+ /**
999
+ * Webhook event types (matches Platform `lib/webhooks/types.ts`)
1000
+ *
1001
+ * Note: `'*'` is a special subscription value meaning "all events".
1002
+ */
1003
+ type WebhookEventType = '*' | 'escrow.created' | 'escrow.funded' | 'escrow.locked' | 'escrow.released' | 'escrow.refunded' | 'escrow.disputed' | 'transfer.completed' | 'transfer.failed' | 'withdrawal.created' | 'withdrawal.processing' | 'withdrawal.completed' | 'withdrawal.failed' | 'account.kyc_approved' | 'account.kyc_rejected' | 'account.tier_upgraded' | 'security.api_key_created' | 'security.api_key_revoked';
1004
+ /**
1005
+ * Webhook event payload
1006
+ */
1007
+ interface WebhookEvent<T = Record<string, unknown>> {
1008
+ id: string;
1009
+ type: WebhookEventType;
1010
+ data: T;
1011
+ accountId: string;
1012
+ timestamp: string;
1013
+ livemode: boolean;
1014
+ }
1015
+ /**
1016
+ * Webhook configuration
1017
+ */
1018
+ interface WebhookConfig {
1019
+ url: string;
1020
+ events: WebhookEventType[];
1021
+ status: 'active';
1022
+ createdAt: string;
1023
+ }
1024
+ interface WebhookConfigWithSecret extends WebhookConfig {
1025
+ /** Only returned once on initial configuration */
1026
+ secret: string;
1027
+ }
1028
+ /**
1029
+ * Parameters for configuring webhook
1030
+ */
1031
+ interface ConfigureWebhookParams {
1032
+ url: string;
1033
+ /** Optional list of event types. If omitted, the platform subscribes to all events. */
1034
+ events?: WebhookEventType[];
1035
+ /** Optional description (currently ignored by the platform API). */
1036
+ description?: string;
1037
+ }
1038
+ /**
1039
+ * Webhook validation result
1040
+ */
1041
+ interface WebhookValidationResult {
1042
+ valid: boolean;
1043
+ event?: WebhookEvent;
1044
+ error?: string;
1045
+ }
1046
+ /**
1047
+ * Webhook signature validation options
1048
+ */
1049
+ interface ValidateWebhookSignatureOptions {
1050
+ payload: string | object;
1051
+ signature: string;
1052
+ secret: string;
1053
+ /**
1054
+ * Max allowed signature age in milliseconds (default: 300_000ms).
1055
+ * The platform signs payloads as: `${timestampMs}.${rawBody}` with signature header `t=...,v1=...`.
1056
+ */
1057
+ toleranceMs?: number;
1058
+ }
1059
+
1060
+ /**
1061
+ * Webhooks resource and utilities for Aura Payments SDK
1062
+ */
1063
+
1064
+ declare class Webhooks {
1065
+ private client;
1066
+ constructor(client: AuraClient);
1067
+ /**
1068
+ * Configure webhook endpoint and events
1069
+ */
1070
+ configure(params: ConfigureWebhookParams): Promise<WebhookConfigWithSecret>;
1071
+ /**
1072
+ * Get current webhook configuration
1073
+ */
1074
+ getConfig(): Promise<WebhookConfig>;
1075
+ /**
1076
+ * Delete webhook configuration
1077
+ */
1078
+ delete(): Promise<{
1079
+ deleted: true;
1080
+ message: string;
1081
+ }>;
1082
+ /**
1083
+ * Validate webhook signature
1084
+ * Use this in your webhook handler to verify authenticity
1085
+ */
1086
+ static validateSignature(options: ValidateWebhookSignatureOptions): WebhookValidationResult;
1087
+ /**
1088
+ * Parse signature header: "t=timestamp,v1=signature"
1089
+ */
1090
+ private static parseSignatureHeader;
1091
+ /**
1092
+ * Compute HMAC-SHA256 signature
1093
+ */
1094
+ private static computeHmacSignature;
1095
+ /**
1096
+ * Constant-time string comparison
1097
+ */
1098
+ private static secureCompare;
1099
+ }
1100
+
1101
+ /**
1102
+ * Aura Payments SDK Client
1103
+ * Main entry point for interacting with the Aura Payments Platform API
1104
+ */
1105
+
1106
+ interface AuraClientConfig {
1107
+ /**
1108
+ * API key for authentication
1109
+ */
1110
+ apiKey: string;
1111
+ /**
1112
+ * Base URL of the Aura Platform API.
1113
+ *
1114
+ * Accepts either a bare hostname (`https://getaura.sh`) or a hostname
1115
+ * including the `/api` path (`https://getaura.sh/api`). The SDK appends
1116
+ * `/api` automatically if it's missing, so resource paths like `/v1/escrow`
1117
+ * always resolve to `https://your-host/api/v1/escrow`.
1118
+ *
1119
+ * @default 'https://getaura.sh/api'
1120
+ */
1121
+ baseUrl?: string;
1122
+ /**
1123
+ * Request timeout in milliseconds
1124
+ * @default 30000
1125
+ */
1126
+ timeout?: number;
1127
+ /**
1128
+ * Maximum number of retry attempts for failed requests
1129
+ * @default 3
1130
+ */
1131
+ maxRetries?: number;
1132
+ /**
1133
+ * Enable automatic idempotency key generation
1134
+ * @default true
1135
+ */
1136
+ autoIdempotency?: boolean;
1137
+ }
1138
+ interface RequestOptions {
1139
+ idempotencyKey?: string;
1140
+ skipRetry?: boolean;
1141
+ }
1142
+ declare class AuraClient {
1143
+ private readonly apiKey;
1144
+ private readonly baseUrl;
1145
+ private readonly timeout;
1146
+ private readonly maxRetries;
1147
+ private readonly autoIdempotency;
1148
+ readonly escrows: Escrows;
1149
+ readonly wallets: Wallets;
1150
+ readonly webhooks: Webhooks;
1151
+ readonly agents: Agents;
1152
+ readonly policies: Policies;
1153
+ readonly mandates: Mandates;
1154
+ constructor(config: AuraClientConfig);
1155
+ /**
1156
+ * Normalize the base URL so resource paths like `/v1/escrow` reach the
1157
+ * platform's `/api/v1/escrow` route regardless of how the caller framed
1158
+ * `baseUrl`. Trailing slashes are trimmed; missing `/api` is appended.
1159
+ *
1160
+ * @internal exported pattern for tests; do not call directly.
1161
+ */
1162
+ private static normalizeBaseUrl;
1163
+ /**
1164
+ * Get the API key
1165
+ */
1166
+ getApiKey(): string;
1167
+ /**
1168
+ * Get the base URL
1169
+ */
1170
+ getBaseUrl(): string;
1171
+ /**
1172
+ * Get the timeout value
1173
+ */
1174
+ getTimeout(): number;
1175
+ /**
1176
+ * Get the max retries value
1177
+ */
1178
+ getMaxRetries(): number;
1179
+ /**
1180
+ * Make an authenticated request to the API with automatic retry logic
1181
+ */
1182
+ protected request<T>(method: string, path: string, body?: unknown, options?: RequestOptions): Promise<T>;
1183
+ /**
1184
+ * Execute a single HTTP request (internal)
1185
+ */
1186
+ private executeRequest;
1187
+ /**
1188
+ * Normalize API responses across different wrapper formats.
1189
+ *
1190
+ * The platform API currently uses two common success wrappers:
1191
+ * - { success: true, data: T, ... }
1192
+ * - { data: T, meta: {...} } (and sometimes { data: T[], meta, pagination })
1193
+ *
1194
+ * SDK methods generally return the inner `data` payload, except for paginated
1195
+ * endpoints where pagination metadata is meaningful and preserved.
1196
+ */
1197
+ private normalizeResponse;
1198
+ /**
1199
+ * Handle HTTP error responses and throw appropriate errors
1200
+ */
1201
+ private handleErrorResponse;
1202
+ /**
1203
+ * Get the auto-idempotency setting
1204
+ */
1205
+ getAutoIdempotency(): boolean;
1206
+ }
1207
+
1208
+ /**
1209
+ * Custom error classes for Aura Payments SDK
1210
+ */
1211
+ declare class AuraError extends Error {
1212
+ readonly code?: string | undefined;
1213
+ readonly statusCode?: number | undefined;
1214
+ readonly details?: unknown;
1215
+ constructor(message: string, code?: string | undefined, statusCode?: number | undefined, details?: unknown);
1216
+ }
1217
+ declare class AuraAPIError extends AuraError {
1218
+ constructor(message: string, statusCode: number, code?: string, details?: unknown);
1219
+ }
1220
+ declare class AuraNetworkError extends AuraError {
1221
+ readonly cause?: Error | undefined;
1222
+ constructor(message: string, cause?: Error | undefined);
1223
+ }
1224
+ declare class AuraTimeoutError extends AuraError {
1225
+ constructor(message?: string);
1226
+ }
1227
+ declare class AuraValidationError extends AuraError {
1228
+ constructor(message: string, details?: unknown);
1229
+ }
1230
+ declare class AuraAuthenticationError extends AuraError {
1231
+ constructor(message?: string);
1232
+ }
1233
+ declare class AuraNotFoundError extends AuraError {
1234
+ constructor(resource: string);
1235
+ }
1236
+ declare class AuraRateLimitError extends AuraError {
1237
+ readonly retryAfter?: number | undefined;
1238
+ constructor(message?: string, retryAfter?: number | undefined);
1239
+ }
1240
+ /**
1241
+ * Thrown when the testnet faucet endpoint is not available on the target
1242
+ * deployment. The faucet (`POST /v1/wallets/:id/faucet`) is provided by the
1243
+ * platform (AURA-010); until it ships, `wallets.requestTestnetFunds()`
1244
+ * capability-probes and raises this typed error instead of a generic 404/501,
1245
+ * so callers can degrade gracefully (e.g. prompt for manual funding).
1246
+ */
1247
+ declare class AuraFaucetUnavailableError extends AuraError {
1248
+ constructor(message?: string);
1249
+ }
1250
+ /**
1251
+ * Type guards for error handling
1252
+ */
1253
+ declare function isAuraError(error: unknown): error is AuraError;
1254
+ declare function isAuraFaucetUnavailableError(error: unknown): error is AuraFaucetUnavailableError;
1255
+ declare function isAuraAPIError(error: unknown): error is AuraAPIError;
1256
+ declare function isAuraNetworkError(error: unknown): error is AuraNetworkError;
1257
+ declare function isAuraTimeoutError(error: unknown): error is AuraTimeoutError;
1258
+ declare function isRetryableError(error: unknown): boolean;
1259
+
1260
+ /**
1261
+ * Utility functions for Aura Payments SDK
1262
+ */
1263
+ /**
1264
+ * Generate a unique idempotency key
1265
+ * Format: timestamp-random
1266
+ */
1267
+ declare function generateIdempotencyKey(): string;
1268
+ /**
1269
+ * Calculate exponential backoff delay
1270
+ * @param attempt - The retry attempt number (0-based)
1271
+ * @param baseDelay - Base delay in milliseconds (default: 1000ms)
1272
+ * @param maxDelay - Maximum delay in milliseconds (default: 30000ms)
1273
+ * @returns Delay in milliseconds
1274
+ */
1275
+ declare function calculateBackoff(attempt: number, baseDelay?: number, maxDelay?: number): number;
1276
+ /**
1277
+ * Retry a function with exponential backoff
1278
+ * @param fn - The async function to retry
1279
+ * @param maxRetries - Maximum number of retry attempts
1280
+ * @param shouldRetry - Optional function to determine if error is retryable
1281
+ * @returns Promise with the function result
1282
+ */
1283
+ declare function retryWithBackoff<T>(fn: () => Promise<T>, maxRetries?: number, shouldRetry?: (error: unknown) => boolean): Promise<T>;
1284
+ /**
1285
+ * Execute with timeout
1286
+ * @param promise - The promise to execute
1287
+ * @param timeoutMs - Timeout in milliseconds
1288
+ * @param timeoutMessage - Optional timeout error message
1289
+ */
1290
+ declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutMessage?: string): Promise<T>;
1291
+
1292
+ export { type Agent, type AgentBalance, type AgentPolicy, type AgentRiskTier, type AgentStatus, type AgentStatusResponse, type AgentType, Agents, type ApproveMandateParams, AuraAPIError, AuraAuthenticationError, AuraClient, type AuraClientConfig, AuraError, AuraFaucetUnavailableError, AuraNetworkError, AuraNotFoundError, AuraRateLimitError, AuraTimeoutError, AuraValidationError, type Chain, type ConfigureWebhookParams, type CreateAgentParams, type CreateAgentResponse, type CreateDisputeParams, type CreateEscrowParams, type CreateEscrowResponse, type CreatePolicyParams, type CreateWalletParams, type Dispute, type DisputeStatus, type Escrow, type EscrowListItem, type EscrowSortBy, type EscrowSplitInput, type EscrowSplitResponse, type EscrowState, Escrows, type EvaluatePolicyParams, type EvaluatePolicyResponse, type FreezeAgentParams, type FundEscrowParams, type InitialPolicyInput, type ListAgentsParams, type ListAgentsResponse, type ListEscrowsParams, type ListEscrowsResponse, type ListMandatesParams, type ListMandatesResponse, type ListPoliciesResponse, type ListWalletsParams, type ListWalletsResponse, type Mandate, type MandateDecisionMethod, type MandateIntent, type MandateIntentKind, MandateSignature, type MandateStatus, Mandates, type MerchantDestinationType, type MerchantRule, type MerchantRuleInput, type MerchantRuleType, type OwnerType, Policies, type PolicyDecision, type ReceiveAndSplitFundingRequired, type ReceiveAndSplitParams, type ReceiveAndSplitResult, type ReceiveAndSplitStage, type RefundEscrowParams, type RejectMandateParams, type ReleaseEscrowParams, type RequestTestnetFundsParams, type RequestTestnetFundsResponse, type SpendingLimit, type SpendingLimitInput, type SpendingLimitType, type SplitRole, type TokenBalance, type Transfer, type TransferParams, type UnfreezeAgentParams, type UnlockType, type UpdateAgentParams, type ValidateWebhookSignatureOptions, type Wallet, type WalletBalance, type WalletOwnerType, Wallets, type WebhookConfig, type WebhookEvent, type WebhookEventType, type WebhookValidationResult, Webhooks, calculateBackoff, generateIdempotencyKey, isAuraAPIError, isAuraError, isAuraFaucetUnavailableError, isAuraNetworkError, isAuraTimeoutError, isRetryableError, retryWithBackoff, withTimeout };