@haven_ai/sdk 0.0.0-dev.202609241802.ea320de → 0.0.0-dev.202609242134.f497e3b
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/README.md +16 -7
- package/dist/{base64-CPxbmyU9.d.cts → base64-9_tWgxq-.d.cts} +241 -6
- package/dist/{base64-CPxbmyU9.d.ts → base64-9_tWgxq-.d.ts} +241 -6
- package/dist/{chunk-M57KOLAN.cjs → chunk-C4BG4HER.cjs} +289 -723
- package/dist/chunk-C4BG4HER.cjs.map +1 -0
- package/dist/chunk-KPQAAF4I.cjs +879 -0
- package/dist/chunk-KPQAAF4I.cjs.map +1 -0
- package/dist/{chunk-FR5R26V3.js → chunk-KQ757ZWS.js} +277 -670
- package/dist/chunk-KQ757ZWS.js.map +1 -0
- package/dist/chunk-ML4FBTBL.js +817 -0
- package/dist/chunk-ML4FBTBL.js.map +1 -0
- package/dist/edge.cjs +132 -55
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +99 -3
- package/dist/edge.d.ts +99 -3
- package/dist/edge.js +3 -2
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +409 -356
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/test-support.cjs +192 -0
- package/dist/test-support.cjs.map +1 -0
- package/dist/test-support.d.cts +162 -0
- package/dist/test-support.d.ts +162 -0
- package/dist/test-support.js +178 -0
- package/dist/test-support.js.map +1 -0
- package/package.json +11 -1
- package/dist/chunk-FR5R26V3.js.map +0 -1
- package/dist/chunk-M57KOLAN.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -21,11 +21,16 @@ and managing the account from the shell with `@haven_ai/cli`.
|
|
|
21
21
|
npm install @haven_ai/sdk@alpha
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
The package has
|
|
24
|
+
The package has three entries. `@haven_ai/sdk` is the full client. `@haven_ai/sdk/edge`
|
|
25
25
|
(#3173) is the ethers-free subset the local signer imports — error classes, the
|
|
26
|
-
typed-next-step builder, the x402 message builders, viem-based key helpers
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
typed-next-step builder, the x402 message builders, viem-based key helpers, and
|
|
27
|
+
(#3283) the signing-surface guard: `assertBoundDirectPaymentUserOp`, the
|
|
28
|
+
redemption guard, `deriveDelegateAccountAddress` and `verifySettlementChild` —
|
|
29
|
+
and loads in about a third of the time; use it when you need those helpers
|
|
30
|
+
without the HTTP client. A class imported from either entry is the same class.
|
|
31
|
+
`@haven_ai/sdk/test-support` (#3283) holds test fixture builders shared by
|
|
32
|
+
Haven's own packages; it is not a signing API, nothing at runtime imports it,
|
|
33
|
+
and it carries no semver guarantee.
|
|
29
34
|
|
|
30
35
|
## Quick Start
|
|
31
36
|
|
|
@@ -116,9 +121,13 @@ const intent = await haven.createIntent({
|
|
|
116
121
|
// the account validates the EIP-712 typed data in intent.signData.typed_data,
|
|
117
122
|
// never the bare hash — a signature over signData.hash is rejected on-chain
|
|
118
123
|
// (AA24). Sign that typed data with your delegate key (viem signTypedData),
|
|
119
|
-
// after checking it with assertUserOpTypedDataBinding(typed_data, hash)
|
|
120
|
-
//
|
|
121
|
-
//
|
|
124
|
+
// after checking it with assertUserOpTypedDataBinding(typed_data, hash) AND
|
|
125
|
+
// assertBoundDirectPaymentUserOp(typed_data, yourDelegateAddress) — the
|
|
126
|
+
// first proves the typed data matches the hash, the second that it is your
|
|
127
|
+
// own account redeeming your budget delegation, not a self-call (#3283).
|
|
128
|
+
// There is no public HavenClient method for this step yet; pay() does both
|
|
129
|
+
// for you. HavenClient.sign(hash) and signUserOpTypedDataForDelegation are
|
|
130
|
+
// verbatim primitives: they check nothing.
|
|
122
131
|
const signature = await signTypedDataWithYourDelegateKey(intent.signData.typed_data)
|
|
123
132
|
|
|
124
133
|
// Step 3: Submit the signature
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PaymentRequirements } from 'x402/types';
|
|
2
|
-
import { Hex } from 'viem';
|
|
2
|
+
import { Hex, Address } from 'viem';
|
|
3
3
|
|
|
4
4
|
interface HavenClientConfig {
|
|
5
5
|
/** Haven API key (sk_agent_xxx) */
|
|
@@ -323,6 +323,11 @@ interface X402ExpectedContext {
|
|
|
323
323
|
* which is NOT what the account validates — binding it alone would leave the
|
|
324
324
|
* edge signer unable to verify the payload it is being asked to sign. Binding
|
|
325
325
|
* this digest makes Haven's declaration cover the real payload.
|
|
326
|
+
*
|
|
327
|
+
* Absent ⇒ the retired version-1 bare-hash context. Since #3272 the backend
|
|
328
|
+
* never emits one (`signX402ExpectedContext` requires this field) and
|
|
329
|
+
* `@haven_ai/signer` refuses it with its version-mismatch refusal; the field
|
|
330
|
+
* stays optional here only because the type also describes older payloads.
|
|
326
331
|
*/
|
|
327
332
|
typedDataHash?: string;
|
|
328
333
|
/**
|
|
@@ -338,8 +343,9 @@ interface X402ExpectedContext {
|
|
|
338
343
|
}
|
|
339
344
|
interface X402ExpectedAuth {
|
|
340
345
|
/**
|
|
341
|
-
*
|
|
342
|
-
* #
|
|
346
|
+
* 2 = carries `typedDataHash` (delegation rail, #1138). 3 = additionally binds
|
|
347
|
+
* the payer identity (#1690). 1 (hash-only, retired Safe rail) is never
|
|
348
|
+
* emitted since #3272 and the signer refuses it.
|
|
343
349
|
*
|
|
344
350
|
* Deliberately `number`, not a literal union (#1143). This is an **inbound**
|
|
345
351
|
* value: a signer parses a context Haven produced, and a signer older than the
|
|
@@ -2329,8 +2335,10 @@ declare function resolveTokenFromAddress(address: string, network?: string): {
|
|
|
2329
2335
|
* typed data the hash does NOT cover (domain name/version/verifyingContract,
|
|
2330
2336
|
* the field list, the EntryPoint). It is a CORRUPTION check: the caller supplies
|
|
2331
2337
|
* both values, so it proves they describe the same operation, never that Haven
|
|
2332
|
-
* prepared it. Provenance is the byte-free sign context (`payment_id`); what
|
|
2333
|
-
*
|
|
2338
|
+
* prepared it. Provenance is the byte-free sign context (`payment_id`); what a
|
|
2339
|
+
* delegate key will sign at all is `assertBoundDirectPaymentUserOp`
|
|
2340
|
+
* (`direct-payment-guard.ts`, #3272 / #3283), which every caller of this check
|
|
2341
|
+
* — `HavenClient.signForData` and the signer's `haven_sign` — runs next.
|
|
2334
2342
|
*
|
|
2335
2343
|
* Pure viem, no ethers: `@haven_ai/sdk/edge` re-exports it for the edge signer,
|
|
2336
2344
|
* and `edge-imports.test.ts` pins that graph.
|
|
@@ -2372,6 +2380,233 @@ declare function packedUserOperationHash(typedData: unknown): Hex;
|
|
|
2372
2380
|
*/
|
|
2373
2381
|
declare function assertUserOpTypedDataBinding(typedData: unknown, payloadHash: string): Hex;
|
|
2374
2382
|
|
|
2383
|
+
/**
|
|
2384
|
+
* The counterfactual HybridDeleGator account address for an owner EOA (#3272).
|
|
2385
|
+
*
|
|
2386
|
+
* `haven_sign`'s unbound branch (`@haven_ai/signer`'s `tools.ts`) and, since
|
|
2387
|
+
* #3283, `HavenClient.signForData` (`direct-payment-guard.ts`) sign a
|
|
2388
|
+
* `PackedUserOperation`
|
|
2389
|
+
* only when its `sender` (== `domain.verifyingContract`) is THIS SIGNER'S OWN
|
|
2390
|
+
* delegate account — never any other HybridDeleGator, and never a third
|
|
2391
|
+
* party's. Haven provisions that account counterfactually at signup (#970):
|
|
2392
|
+
* it may have zero on-chain transactions, so the signer must be able to
|
|
2393
|
+
* compute its address OFFLINE, from nothing but the delegate key's own
|
|
2394
|
+
* address.
|
|
2395
|
+
*
|
|
2396
|
+
* This is exactly what `@metamask/smart-accounts-kit`'s
|
|
2397
|
+
* `getCounterfactualAccountData` computes for
|
|
2398
|
+
* `implementation: 'Hybrid'`, `deployParams: [owner, [], [], []]` (no passkey
|
|
2399
|
+
* co-owners — the only shape Haven's signup flow provisions), `deploySalt:
|
|
2400
|
+
* '0x'`: CREATE2 of an `ERC1967Proxy(HybridDeleGatorImpl, initialize(owner,
|
|
2401
|
+
* [], [], []))` behind the `SimpleFactory`.
|
|
2402
|
+
*
|
|
2403
|
+
* VENDORED, NOT IMPORTED. `@metamask/smart-accounts-kit` is a devDependency
|
|
2404
|
+
* only (see `package.json`) — this package installs on users' machines and
|
|
2405
|
+
* must not carry it at runtime. The constants below (the factory and
|
|
2406
|
+
* implementation addresses, the `ERC1967Proxy` bytecode) are copied from the
|
|
2407
|
+
* kit's pinned environment / `@metamask/delegation-abis`' bytecode export,
|
|
2408
|
+
* exactly like `settlement-child.ts` vendors the DelegationManager and caveat
|
|
2409
|
+
* enforcer addresses for the same reason. Cross-checked against the kit by
|
|
2410
|
+
* `packages/signer/src/delegate-account.pins.test.ts`, including against the real, on-chain
|
|
2411
|
+
* `direct-payment-userop.json` fixture.
|
|
2412
|
+
*/
|
|
2413
|
+
|
|
2414
|
+
/**
|
|
2415
|
+
* SimpleFactory — deterministically deployed, so Base and Base Sepolia share
|
|
2416
|
+
* the address (matches `packages/backend/src/rails/delegation-contracts.ts`'s
|
|
2417
|
+
* `simpleFactory` pin for both chains).
|
|
2418
|
+
*/
|
|
2419
|
+
declare const SIMPLE_FACTORY_ADDRESS: Address;
|
|
2420
|
+
/**
|
|
2421
|
+
* HybridDeleGator implementation — matches `delegation-contracts.ts`'s
|
|
2422
|
+
* `hybridDeleGatorImpl` pin for both chains.
|
|
2423
|
+
*/
|
|
2424
|
+
declare const HYBRID_DELEGATOR_IMPLEMENTATION: Address;
|
|
2425
|
+
/**
|
|
2426
|
+
* Derive the counterfactual HybridDeleGator account address for `owner`, with
|
|
2427
|
+
* no passkey co-owners — the only shape Haven's signup flow provisions
|
|
2428
|
+
* (#970). Pure and offline: no RPC call, no dependency on the account having
|
|
2429
|
+
* been deployed. Verified byte-for-byte against
|
|
2430
|
+
* `@metamask/smart-accounts-kit`'s `getCounterfactualAccountData` by
|
|
2431
|
+
* `packages/signer/src/delegate-account.pins.test.ts`, including against a real Base Sepolia payload served by the dev backend
|
|
2432
|
+
* (`direct-payment-userop.json`).
|
|
2433
|
+
*/
|
|
2434
|
+
declare function deriveDelegateAccountAddress(owner: Address): Address;
|
|
2435
|
+
|
|
2436
|
+
/**
|
|
2437
|
+
* Independent verification of an erc7710 x402 settlement child (#1455).
|
|
2438
|
+
*
|
|
2439
|
+
* Moved from `@haven_ai/signer` into the SDK by #3283 (epic #3284) so the
|
|
2440
|
+
* signer and `HavenClient.signForData` run ONE verifier. The signer checks the
|
|
2441
|
+
* child against the Haven-signed expected context; the SDK checks it against
|
|
2442
|
+
* the merchant's own 402, which Haven does not produce.
|
|
2443
|
+
*
|
|
2444
|
+
* WHY THIS EXISTS. `assertExpectedBinding` proves Haven *declared* a payload:
|
|
2445
|
+
* the expected context is signed by `HAVEN_X402_BINDING_SIGNER` and commits to
|
|
2446
|
+
* the digest of the exact bytes being signed. That is a real property, and it
|
|
2447
|
+
* is not this one. It says nothing about what the payload MEANS.
|
|
2448
|
+
*
|
|
2449
|
+
* A backend that declared `merchantTo = the real merchant` while pinning a
|
|
2450
|
+
* different payee in the child's `AllowedCalldata` caveat would produce a
|
|
2451
|
+
* perfectly consistent pair: the declaration binds the digest, the digest is
|
|
2452
|
+
* the child's, and the child pays someone else. The signature is the authority
|
|
2453
|
+
* here — the merchant's facilitator redeems it and pulls from the treasury — so
|
|
2454
|
+
* the signer has to re-derive the meaning locally or it is a pass-through with
|
|
2455
|
+
* extra steps.
|
|
2456
|
+
*
|
|
2457
|
+
* ADDRESSES ARE PINNED HERE ON PURPOSE. Reading the enforcer map from Haven
|
|
2458
|
+
* would make the check circular: an attacker who can pick which contract counts
|
|
2459
|
+
* as "the payee enforcer" can satisfy any comparison. Taking
|
|
2460
|
+
* `@metamask/smart-accounts-kit` as a runtime dependency was the other option
|
|
2461
|
+
* and was rejected — this package installs on users' machines. The constants
|
|
2462
|
+
* below are snapshot-pinned and cross-checked against the kit by a test
|
|
2463
|
+
* (`packages/signer/src/settlement-child.pins.test.ts`), the same pattern
|
|
2464
|
+
* `packages/core/src/chains.ts` uses against its registry.
|
|
2465
|
+
*
|
|
2466
|
+
* EXTRA CAVEATS ARE ALLOWED, and that is deliberate — verified, not assumed
|
|
2467
|
+
* (#1455 review challenged it directly).
|
|
2468
|
+
*
|
|
2469
|
+
* `DelegationManager.redeemDelegations` loops every caveat of every delegation
|
|
2470
|
+
* and calls `beforeHook` on each, with no break and no try/catch: a single
|
|
2471
|
+
* revert aborts the whole redemption, and nothing lets one caveat cause another
|
|
2472
|
+
* to be skipped. Top-level caveats are therefore strictly AND-ed, so one this
|
|
2473
|
+
* file does not recognise can only add a constraint, never remove one.
|
|
2474
|
+
*
|
|
2475
|
+
* The specific challenge was `LogicalOrWrapperEnforcer`, whose terms encode
|
|
2476
|
+
* several caveat GROUPS and whose own security notice warns that "the redeemer
|
|
2477
|
+
* can select the least restrictive group, bypassing stricter requirements in
|
|
2478
|
+
* other groups". That warning is about groups INSIDE the wrapper — it binds
|
|
2479
|
+
* whoever authors wrapper terms. The wrapper is itself one caveat among the
|
|
2480
|
+
* delegation's, so it is AND-ed with the four required below and cannot unlock
|
|
2481
|
+
* them.
|
|
2482
|
+
*
|
|
2483
|
+
* The shape that WOULD be dangerous is the inverse: a required caveat hidden
|
|
2484
|
+
* inside a wrapper group instead of sitting at top level, where the redeemer
|
|
2485
|
+
* could select a group that omits it. This file scans top-level caveats and
|
|
2486
|
+
* refuses on absence, so that child is refused for lacking the caveat — which
|
|
2487
|
+
* is the correct outcome and is pinned by a test.
|
|
2488
|
+
*/
|
|
2489
|
+
/** DelegationManager, the EIP-712 `verifyingContract` for a delegation. */
|
|
2490
|
+
declare const DELEGATION_MANAGER = "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3";
|
|
2491
|
+
/**
|
|
2492
|
+
* Caveat enforcers, by role. Deterministically deployed, so Base and Base
|
|
2493
|
+
* Sepolia share addresses — verified for both chains by the pin test.
|
|
2494
|
+
*/
|
|
2495
|
+
declare const CAVEAT_ENFORCERS: {
|
|
2496
|
+
readonly erc20TransferAmount: "0xf100b0819427117EcF76Ed94B358B1A5b5C6D2Fc";
|
|
2497
|
+
readonly allowedCalldata: "0xc2b0d624c1c4319760C96503BA27C347F3260f55";
|
|
2498
|
+
readonly timestamp: "0x1046bb45C8d673d4ea75321280DB34899413c069";
|
|
2499
|
+
readonly redeemer: "0xE144b0b2618071B4E56f746313528a669c7E65c5";
|
|
2500
|
+
};
|
|
2501
|
+
/** The backend's own ceiling (`MAX_SETTLEMENT_WINDOW_SECONDS`), enforced again here. */
|
|
2502
|
+
declare const MAX_SETTLEMENT_WINDOW_SECONDS = 600;
|
|
2503
|
+
interface SettlementChildTypedData {
|
|
2504
|
+
domain: {
|
|
2505
|
+
name?: string;
|
|
2506
|
+
version?: string;
|
|
2507
|
+
chainId?: number | string;
|
|
2508
|
+
verifyingContract?: string;
|
|
2509
|
+
};
|
|
2510
|
+
types: Record<string, unknown>;
|
|
2511
|
+
primaryType: string;
|
|
2512
|
+
message: Record<string, unknown>;
|
|
2513
|
+
}
|
|
2514
|
+
/** True when this typed data is a delegation — the shape that must never be signed unbound. */
|
|
2515
|
+
declare function isSettlementChildTypedData(value: unknown): value is SettlementChildTypedData;
|
|
2516
|
+
/**
|
|
2517
|
+
* Map an x402 network string to a chain id. Local on purpose (#1455 review):
|
|
2518
|
+
* the chain must come from Haven's SIGNED `network` field, never from the
|
|
2519
|
+
* payload under verification — see `verifySettlementChild`.
|
|
2520
|
+
*/
|
|
2521
|
+
declare function chainIdForNetwork(network: string | undefined): number | undefined;
|
|
2522
|
+
interface SettlementChildExpectation {
|
|
2523
|
+
merchantTo: string;
|
|
2524
|
+
amount: string;
|
|
2525
|
+
asset: string;
|
|
2526
|
+
/**
|
|
2527
|
+
* Derived from the expected context's SIGNED `network`, never from
|
|
2528
|
+
* `typedData.domain.chainId`. Comparing the payload's own claim against
|
|
2529
|
+
* itself is a check that cannot fail — which is exactly what shipped in the
|
|
2530
|
+
* first draft of this file's call site, and what the review caught.
|
|
2531
|
+
*/
|
|
2532
|
+
chainId: number;
|
|
2533
|
+
/** ISO timestamp; the child must not outlive it. */
|
|
2534
|
+
expiresAt?: string;
|
|
2535
|
+
/**
|
|
2536
|
+
* #3283 / #3281 criterion 8: the signer's OWN derived delegate account.
|
|
2537
|
+
* When set, the child's `delegator` must be exactly this account — the
|
|
2538
|
+
* child is a re-delegation of this agent's budget, never a grant from some
|
|
2539
|
+
* other account the key happens to control.
|
|
2540
|
+
*/
|
|
2541
|
+
delegatorAccount?: string;
|
|
2542
|
+
/**
|
|
2543
|
+
* #3283: the facilitator addresses the merchant's 402 advertised
|
|
2544
|
+
* (`extra.facilitatorAddresses`). When non-empty, the child must carry a
|
|
2545
|
+
* `RedeemerEnforcer` caveat pinning exactly this set — otherwise the child
|
|
2546
|
+
* is a bearer instrument any party could redeem within its bounds.
|
|
2547
|
+
*/
|
|
2548
|
+
redeemers?: readonly string[];
|
|
2549
|
+
}
|
|
2550
|
+
/** `@metamask/delegation-core`'s `ROOT_AUTHORITY` — a delegation chained to nothing. */
|
|
2551
|
+
declare const ROOT_AUTHORITY: string;
|
|
2552
|
+
/**
|
|
2553
|
+
* Verify a settlement child implements what the expected context declares.
|
|
2554
|
+
* Throws `HavenSigningError` on any disagreement; returns nothing on success.
|
|
2555
|
+
*
|
|
2556
|
+
* `now` is injectable so the expiry checks are testable without faking clocks.
|
|
2557
|
+
*/
|
|
2558
|
+
declare function verifySettlementChild(typedData: SettlementChildTypedData, expected: SettlementChildExpectation, now?: number): void;
|
|
2559
|
+
|
|
2560
|
+
/** Wire code for a typed-data payload outside the signable allowlist. */
|
|
2561
|
+
declare const TYPED_DATA_NOT_ALLOWED: "TYPED_DATA_NOT_ALLOWED";
|
|
2562
|
+
/**
|
|
2563
|
+
* A typed-data payload was refused before signing because it is not a shape
|
|
2564
|
+
* a delegate key may sign. Nothing was signed. `@haven_ai/signer` subclasses
|
|
2565
|
+
* this to attach its MCP next step; the `code` is the same on both.
|
|
2566
|
+
*/
|
|
2567
|
+
declare class HavenTypedDataRefusedError extends HavenSigningError {
|
|
2568
|
+
readonly code: typeof TYPED_DATA_NOT_ALLOWED;
|
|
2569
|
+
constructor(message: string);
|
|
2570
|
+
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Chains the delegation rail has PINNED delegation contracts for
|
|
2573
|
+
* (`packages/backend/src/rails/delegation-contracts.ts`) — the only chains a
|
|
2574
|
+
* direct-payment UserOp may be scoped to. Gnosis (100) has no pinned
|
|
2575
|
+
* DelegationManager/enforcer set, so it is deliberately excluded even though
|
|
2576
|
+
* the delegate account itself could exist there.
|
|
2577
|
+
*/
|
|
2578
|
+
declare const DIRECT_PAYMENT_CHAIN_IDS: ReadonlySet<number>;
|
|
2579
|
+
/** The DeleGator's single-execution `execute((address,uint256,bytes))` — selector `0x5c1c6dcd`. */
|
|
2580
|
+
declare const EXECUTE_ABI: readonly [{
|
|
2581
|
+
readonly type: "function";
|
|
2582
|
+
readonly name: "execute";
|
|
2583
|
+
readonly inputs: readonly [{
|
|
2584
|
+
readonly name: "_execution";
|
|
2585
|
+
readonly type: "tuple";
|
|
2586
|
+
readonly components: readonly [{
|
|
2587
|
+
readonly name: "target";
|
|
2588
|
+
readonly type: "address";
|
|
2589
|
+
}, {
|
|
2590
|
+
readonly name: "value";
|
|
2591
|
+
readonly type: "uint256";
|
|
2592
|
+
}, {
|
|
2593
|
+
readonly name: "callData";
|
|
2594
|
+
readonly type: "bytes";
|
|
2595
|
+
}];
|
|
2596
|
+
}];
|
|
2597
|
+
readonly outputs: readonly [];
|
|
2598
|
+
readonly stateMutability: "payable";
|
|
2599
|
+
}];
|
|
2600
|
+
/**
|
|
2601
|
+
* The content + provenance allowlist (#3272 criteria 1–2). Call ONLY after
|
|
2602
|
+
* `assertUserOpTypedDataBinding` has already proven `typedData` is a
|
|
2603
|
+
* well-formed `PackedUserOperation` matching its own hash — this function
|
|
2604
|
+
* trusts `typedData.domain`/`message` are shaped correctly and checks only
|
|
2605
|
+
* what they SAY. Throws `HavenTypedDataRefusedError` (never returns) on any
|
|
2606
|
+
* disagreement.
|
|
2607
|
+
*/
|
|
2608
|
+
declare function assertBoundDirectPaymentUserOp(typedData: Record<string, unknown>, delegateAddress: string): void;
|
|
2609
|
+
|
|
2375
2610
|
/**
|
|
2376
2611
|
* Runtime-agnostic base64 helpers — the single source of truth for the wire
|
|
2377
2612
|
* encoding shared by the SDK and the edge signer (#325).
|
|
@@ -2410,4 +2645,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
2410
2645
|
*/
|
|
2411
2646
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
2412
2647
|
|
|
2413
|
-
export { type AgentPaymentSummary as $, type AgentPaymentWarning as A, type X402McpTransport as B, type X402MerchantCallContext as C, HavenError as D, AGENT_PAYMENT_FAILURE_CODE_VALUES as E, AGENT_PAYMENT_NEXT_ACTION_VALUES as F, AGENT_PAYMENT_PHASE_VALUES as G, type HavenClientConfig as H, AGENT_PAYMENT_RAIL_VALUES as I, type AgentNextStep as J, type AgentPaymentEnumSchema as K, AgentPaymentFailureCode as L, AgentPaymentFailureCodeDescriptions as M, AgentPaymentFailureCodeSchema as N, AgentPaymentNextAction as O, type PaymentRequest as P, AgentPaymentNextActionDescriptions as Q, type RawPaymentParties as R, type SweepResult as S, AgentPaymentNextActionSchema as T, AgentPaymentPhase as U, AgentPaymentPhaseDescriptions as V, AgentPaymentPhaseSchema as W, type X402PaymentRequired as X, AgentPaymentRail as Y, AgentPaymentRailDescriptions as Z, AgentPaymentRailSchema as _, type PaymentResult as a, type
|
|
2648
|
+
export { type AgentPaymentSummary as $, type AgentPaymentWarning as A, type X402McpTransport as B, type X402MerchantCallContext as C, HavenError as D, AGENT_PAYMENT_FAILURE_CODE_VALUES as E, AGENT_PAYMENT_NEXT_ACTION_VALUES as F, AGENT_PAYMENT_PHASE_VALUES as G, type HavenClientConfig as H, AGENT_PAYMENT_RAIL_VALUES as I, type AgentNextStep as J, type AgentPaymentEnumSchema as K, AgentPaymentFailureCode as L, AgentPaymentFailureCodeDescriptions as M, AgentPaymentFailureCodeSchema as N, AgentPaymentNextAction as O, type PaymentRequest as P, AgentPaymentNextActionDescriptions as Q, type RawPaymentParties as R, type SweepResult as S, AgentPaymentNextActionSchema as T, AgentPaymentPhase as U, AgentPaymentPhaseDescriptions as V, AgentPaymentPhaseSchema as W, type X402PaymentRequired as X, AgentPaymentRail as Y, AgentPaymentRailDescriptions as Z, AgentPaymentRailSchema as _, type PaymentResult as a, type X402PaymentHeaderContext as a$, AgentPaymentWarningCode as a0, type AgentPurchaseSummary as a1, CONNECTOR_PACKAGE_NAME as a2, type CatalogSubmissionAccepted as a3, DEFAULT_CONFIRMATION_TIMEOUT_MS as a4, DEFAULT_NEXT_TOOL_BY_ACTION as a5, DIRECT_SIGN_CONTEXT_VERSION as a6, ENTRY_POINT_V07 as a7, ERC7710_ASSET_TRANSFER_METHOD as a8, HAVEN_CONNECTOR_CHANNEL as a9, type NextToolServerRole as aA, PACKED_USER_OPERATION_FIELDS as aB, type PaymentFee as aC, type PaymentNextAction as aD, type PaymentPhase as aE, type PaymentStatus as aF, ROOT_AUTHORITY as aG, SIGNER_UPDATE_FALLBACK as aH, SWEEP_BASE_CHAIN_ID as aI, SWEEP_BASE_SEPOLIA_CHAIN_ID as aJ, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aK, SWEEP_BASE_USDC_ADDRESS as aL, type SettlementChildExpectation as aM, SignerRefusalCode as aN, type SweepConfirmation as aO, type SweepEip712Domain as aP, type SweepEntry as aQ, type SweepExpectedAuth as aR, type SweepPreparation as aS, type SweepSubmitResult as aT, type SweepTypedData as aU, TRANSFER_WITH_AUTHORIZATION_TYPES as aV, TYPED_DATA_NOT_ALLOWED as aW, type UnsupportedNodeVersionMessageOptions as aX, X402AlreadySettledError as aY, type X402ExpectedAuth as aZ, type X402ExpectedContext as a_, HAVEN_MINIMUM_NODE_VERSION as aa, HYBRID_DELEGATOR_DOMAIN_NAME as ab, HYBRID_DELEGATOR_DOMAIN_VERSION as ac, type HavenAgentAllowanceSummary as ad, type HavenAgentReadiness as ae, type HavenAllowance as af, HavenApiError as ag, type HavenCatalogMerchant as ah, type HavenListScope as ai, HavenPaymentStateError as aj, HavenSigningError as ak, HavenTimeoutError as al, HavenTypedDataRefusedError as am, HavenUnsupportedSignerVersionError as an, HavenUserOpBindingError as ao, HavenZeroSettlementHashError as ap, type MachinePaymentRail as aq, MerchantTimeoutError as ar, NEXT_TOOL_SERVER_NAMES as as, NEXT_TOOL_SERVER_ROLES as at, type NextStep as au, type NextStepArguments as av, type NextStepHandoff as aw, type NextStepInput as ax, type NextStepTarget as ay, type NextStepTargets as az, type PaymentIntent as b, type SettlementChildTypedData as b$, X402PaymentHeaderValidationError as b0, type X402PaymentOption as b1, type X402RequestSnapshot as b2, type X402SchemeSelection as b3, X402UnexpectedStatusError as b4, X402_LEGACY_PAYMENT_HEADER_NAME as b5, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as b6, X402_PAYMENT_HEADER_NAME as b7, X402_PAYMENT_HEADER_NAMES_SENT as b8, X402_PAYMENT_REQUIRED_HEADER_NAME as b9, parsePaymentRequired as bA, parsePaymentRequiredResponse as bB, renderNextTool as bC, resolveConnectorChannel as bD, resolveTokenFromAddress as bE, selectErc7710PaymentOption as bF, selectPaymentOption as bG, selectStandardPaymentOption as bH, selectX402SettlementScheme as bI, signerUpdateFallback as bJ, sweepUsdcAddress as bK, sweepUsdcDomain as bL, toStandardPaymentRequirements as bM, unsupportedNodeVersionMessage as bN, validateStandardX402PaymentHeader as bO, verifySettlementChild as bP, x402AssetTransferMethod as bQ, x402AuthorizationAmount as bR, x402FacilitatorAddresses as bS, x402V2PaymentEnvelope as bT, CAVEAT_ENFORCERS as bU, DELEGATION_MANAGER as bV, DIRECT_PAYMENT_CHAIN_IDS as bW, EXECUTE_ABI as bX, HYBRID_DELEGATOR_IMPLEMENTATION as bY, MAX_SETTLEMENT_WINDOW_SECONDS as bZ, SIMPLE_FACTORY_ADDRESS as b_, X402_PAYMENT_RESPONSE_HEADER_NAME as ba, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bb, assertBoundDirectPaymentUserOp as bc, assertUserOpTypedDataBinding as bd, buildSweepAuthorizationMessage as be, buildSweepTypedData as bf, buildX402ExpectedMessage as bg, compareNodeVersions as bh, connectorRerunCommand as bi, connectorSpec as bj, createNextStepBuilder as bk, decodeBase64Json as bl, decodeBase64Utf8 as bm, defaultNextToolFor as bn, deriveDelegateAccountAddress as bo, encodeBase64Json as bp, encodeBase64Utf8 as bq, encodePaymentProof as br, isConnectorChannel as bs, isErc7710Option as bt, isPackedUserOperationTypedData as bu, isSupportedNodeVersion as bv, isSweepableChain as bw, normalizePaymentRequired as bx, packedUserOperationHash as by, parseNextTool as bz, type X402AuthorizationOptions as c, chainIdForNetwork as c0, isSettlementChildTypedData as c1, type X402Intent as d, type PaymentStatusResult as e, type HavenAgent as f, type HavenAgentSummary as g, type SweepPrepareResponse as h, type SweepAuthorization as i, type SweepSubmitResponse as j, type HavenAllowanceSummary as k, type HavenBalanceCoverage as l, type PostPurchaseAllowanceSummary as m, type HavenCatalogEntry as n, type HavenCatalogSubmission as o, type HavenPaymentReceipt as p, type HavenPaymentReceiptsPage as q, type PaymentResumeState as r, type X402Receipt as s, type X402Quote as t, type X402Erc7710Settlement as u, type X402McpCallContext as v, type SignData as w, type ResumeAuthorizedX402Input as x, type ResumeX402PaymentInput as y, type X402ResumeState as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PaymentRequirements } from 'x402/types';
|
|
2
|
-
import { Hex } from 'viem';
|
|
2
|
+
import { Hex, Address } from 'viem';
|
|
3
3
|
|
|
4
4
|
interface HavenClientConfig {
|
|
5
5
|
/** Haven API key (sk_agent_xxx) */
|
|
@@ -323,6 +323,11 @@ interface X402ExpectedContext {
|
|
|
323
323
|
* which is NOT what the account validates — binding it alone would leave the
|
|
324
324
|
* edge signer unable to verify the payload it is being asked to sign. Binding
|
|
325
325
|
* this digest makes Haven's declaration cover the real payload.
|
|
326
|
+
*
|
|
327
|
+
* Absent ⇒ the retired version-1 bare-hash context. Since #3272 the backend
|
|
328
|
+
* never emits one (`signX402ExpectedContext` requires this field) and
|
|
329
|
+
* `@haven_ai/signer` refuses it with its version-mismatch refusal; the field
|
|
330
|
+
* stays optional here only because the type also describes older payloads.
|
|
326
331
|
*/
|
|
327
332
|
typedDataHash?: string;
|
|
328
333
|
/**
|
|
@@ -338,8 +343,9 @@ interface X402ExpectedContext {
|
|
|
338
343
|
}
|
|
339
344
|
interface X402ExpectedAuth {
|
|
340
345
|
/**
|
|
341
|
-
*
|
|
342
|
-
* #
|
|
346
|
+
* 2 = carries `typedDataHash` (delegation rail, #1138). 3 = additionally binds
|
|
347
|
+
* the payer identity (#1690). 1 (hash-only, retired Safe rail) is never
|
|
348
|
+
* emitted since #3272 and the signer refuses it.
|
|
343
349
|
*
|
|
344
350
|
* Deliberately `number`, not a literal union (#1143). This is an **inbound**
|
|
345
351
|
* value: a signer parses a context Haven produced, and a signer older than the
|
|
@@ -2329,8 +2335,10 @@ declare function resolveTokenFromAddress(address: string, network?: string): {
|
|
|
2329
2335
|
* typed data the hash does NOT cover (domain name/version/verifyingContract,
|
|
2330
2336
|
* the field list, the EntryPoint). It is a CORRUPTION check: the caller supplies
|
|
2331
2337
|
* both values, so it proves they describe the same operation, never that Haven
|
|
2332
|
-
* prepared it. Provenance is the byte-free sign context (`payment_id`); what
|
|
2333
|
-
*
|
|
2338
|
+
* prepared it. Provenance is the byte-free sign context (`payment_id`); what a
|
|
2339
|
+
* delegate key will sign at all is `assertBoundDirectPaymentUserOp`
|
|
2340
|
+
* (`direct-payment-guard.ts`, #3272 / #3283), which every caller of this check
|
|
2341
|
+
* — `HavenClient.signForData` and the signer's `haven_sign` — runs next.
|
|
2334
2342
|
*
|
|
2335
2343
|
* Pure viem, no ethers: `@haven_ai/sdk/edge` re-exports it for the edge signer,
|
|
2336
2344
|
* and `edge-imports.test.ts` pins that graph.
|
|
@@ -2372,6 +2380,233 @@ declare function packedUserOperationHash(typedData: unknown): Hex;
|
|
|
2372
2380
|
*/
|
|
2373
2381
|
declare function assertUserOpTypedDataBinding(typedData: unknown, payloadHash: string): Hex;
|
|
2374
2382
|
|
|
2383
|
+
/**
|
|
2384
|
+
* The counterfactual HybridDeleGator account address for an owner EOA (#3272).
|
|
2385
|
+
*
|
|
2386
|
+
* `haven_sign`'s unbound branch (`@haven_ai/signer`'s `tools.ts`) and, since
|
|
2387
|
+
* #3283, `HavenClient.signForData` (`direct-payment-guard.ts`) sign a
|
|
2388
|
+
* `PackedUserOperation`
|
|
2389
|
+
* only when its `sender` (== `domain.verifyingContract`) is THIS SIGNER'S OWN
|
|
2390
|
+
* delegate account — never any other HybridDeleGator, and never a third
|
|
2391
|
+
* party's. Haven provisions that account counterfactually at signup (#970):
|
|
2392
|
+
* it may have zero on-chain transactions, so the signer must be able to
|
|
2393
|
+
* compute its address OFFLINE, from nothing but the delegate key's own
|
|
2394
|
+
* address.
|
|
2395
|
+
*
|
|
2396
|
+
* This is exactly what `@metamask/smart-accounts-kit`'s
|
|
2397
|
+
* `getCounterfactualAccountData` computes for
|
|
2398
|
+
* `implementation: 'Hybrid'`, `deployParams: [owner, [], [], []]` (no passkey
|
|
2399
|
+
* co-owners — the only shape Haven's signup flow provisions), `deploySalt:
|
|
2400
|
+
* '0x'`: CREATE2 of an `ERC1967Proxy(HybridDeleGatorImpl, initialize(owner,
|
|
2401
|
+
* [], [], []))` behind the `SimpleFactory`.
|
|
2402
|
+
*
|
|
2403
|
+
* VENDORED, NOT IMPORTED. `@metamask/smart-accounts-kit` is a devDependency
|
|
2404
|
+
* only (see `package.json`) — this package installs on users' machines and
|
|
2405
|
+
* must not carry it at runtime. The constants below (the factory and
|
|
2406
|
+
* implementation addresses, the `ERC1967Proxy` bytecode) are copied from the
|
|
2407
|
+
* kit's pinned environment / `@metamask/delegation-abis`' bytecode export,
|
|
2408
|
+
* exactly like `settlement-child.ts` vendors the DelegationManager and caveat
|
|
2409
|
+
* enforcer addresses for the same reason. Cross-checked against the kit by
|
|
2410
|
+
* `packages/signer/src/delegate-account.pins.test.ts`, including against the real, on-chain
|
|
2411
|
+
* `direct-payment-userop.json` fixture.
|
|
2412
|
+
*/
|
|
2413
|
+
|
|
2414
|
+
/**
|
|
2415
|
+
* SimpleFactory — deterministically deployed, so Base and Base Sepolia share
|
|
2416
|
+
* the address (matches `packages/backend/src/rails/delegation-contracts.ts`'s
|
|
2417
|
+
* `simpleFactory` pin for both chains).
|
|
2418
|
+
*/
|
|
2419
|
+
declare const SIMPLE_FACTORY_ADDRESS: Address;
|
|
2420
|
+
/**
|
|
2421
|
+
* HybridDeleGator implementation — matches `delegation-contracts.ts`'s
|
|
2422
|
+
* `hybridDeleGatorImpl` pin for both chains.
|
|
2423
|
+
*/
|
|
2424
|
+
declare const HYBRID_DELEGATOR_IMPLEMENTATION: Address;
|
|
2425
|
+
/**
|
|
2426
|
+
* Derive the counterfactual HybridDeleGator account address for `owner`, with
|
|
2427
|
+
* no passkey co-owners — the only shape Haven's signup flow provisions
|
|
2428
|
+
* (#970). Pure and offline: no RPC call, no dependency on the account having
|
|
2429
|
+
* been deployed. Verified byte-for-byte against
|
|
2430
|
+
* `@metamask/smart-accounts-kit`'s `getCounterfactualAccountData` by
|
|
2431
|
+
* `packages/signer/src/delegate-account.pins.test.ts`, including against a real Base Sepolia payload served by the dev backend
|
|
2432
|
+
* (`direct-payment-userop.json`).
|
|
2433
|
+
*/
|
|
2434
|
+
declare function deriveDelegateAccountAddress(owner: Address): Address;
|
|
2435
|
+
|
|
2436
|
+
/**
|
|
2437
|
+
* Independent verification of an erc7710 x402 settlement child (#1455).
|
|
2438
|
+
*
|
|
2439
|
+
* Moved from `@haven_ai/signer` into the SDK by #3283 (epic #3284) so the
|
|
2440
|
+
* signer and `HavenClient.signForData` run ONE verifier. The signer checks the
|
|
2441
|
+
* child against the Haven-signed expected context; the SDK checks it against
|
|
2442
|
+
* the merchant's own 402, which Haven does not produce.
|
|
2443
|
+
*
|
|
2444
|
+
* WHY THIS EXISTS. `assertExpectedBinding` proves Haven *declared* a payload:
|
|
2445
|
+
* the expected context is signed by `HAVEN_X402_BINDING_SIGNER` and commits to
|
|
2446
|
+
* the digest of the exact bytes being signed. That is a real property, and it
|
|
2447
|
+
* is not this one. It says nothing about what the payload MEANS.
|
|
2448
|
+
*
|
|
2449
|
+
* A backend that declared `merchantTo = the real merchant` while pinning a
|
|
2450
|
+
* different payee in the child's `AllowedCalldata` caveat would produce a
|
|
2451
|
+
* perfectly consistent pair: the declaration binds the digest, the digest is
|
|
2452
|
+
* the child's, and the child pays someone else. The signature is the authority
|
|
2453
|
+
* here — the merchant's facilitator redeems it and pulls from the treasury — so
|
|
2454
|
+
* the signer has to re-derive the meaning locally or it is a pass-through with
|
|
2455
|
+
* extra steps.
|
|
2456
|
+
*
|
|
2457
|
+
* ADDRESSES ARE PINNED HERE ON PURPOSE. Reading the enforcer map from Haven
|
|
2458
|
+
* would make the check circular: an attacker who can pick which contract counts
|
|
2459
|
+
* as "the payee enforcer" can satisfy any comparison. Taking
|
|
2460
|
+
* `@metamask/smart-accounts-kit` as a runtime dependency was the other option
|
|
2461
|
+
* and was rejected — this package installs on users' machines. The constants
|
|
2462
|
+
* below are snapshot-pinned and cross-checked against the kit by a test
|
|
2463
|
+
* (`packages/signer/src/settlement-child.pins.test.ts`), the same pattern
|
|
2464
|
+
* `packages/core/src/chains.ts` uses against its registry.
|
|
2465
|
+
*
|
|
2466
|
+
* EXTRA CAVEATS ARE ALLOWED, and that is deliberate — verified, not assumed
|
|
2467
|
+
* (#1455 review challenged it directly).
|
|
2468
|
+
*
|
|
2469
|
+
* `DelegationManager.redeemDelegations` loops every caveat of every delegation
|
|
2470
|
+
* and calls `beforeHook` on each, with no break and no try/catch: a single
|
|
2471
|
+
* revert aborts the whole redemption, and nothing lets one caveat cause another
|
|
2472
|
+
* to be skipped. Top-level caveats are therefore strictly AND-ed, so one this
|
|
2473
|
+
* file does not recognise can only add a constraint, never remove one.
|
|
2474
|
+
*
|
|
2475
|
+
* The specific challenge was `LogicalOrWrapperEnforcer`, whose terms encode
|
|
2476
|
+
* several caveat GROUPS and whose own security notice warns that "the redeemer
|
|
2477
|
+
* can select the least restrictive group, bypassing stricter requirements in
|
|
2478
|
+
* other groups". That warning is about groups INSIDE the wrapper — it binds
|
|
2479
|
+
* whoever authors wrapper terms. The wrapper is itself one caveat among the
|
|
2480
|
+
* delegation's, so it is AND-ed with the four required below and cannot unlock
|
|
2481
|
+
* them.
|
|
2482
|
+
*
|
|
2483
|
+
* The shape that WOULD be dangerous is the inverse: a required caveat hidden
|
|
2484
|
+
* inside a wrapper group instead of sitting at top level, where the redeemer
|
|
2485
|
+
* could select a group that omits it. This file scans top-level caveats and
|
|
2486
|
+
* refuses on absence, so that child is refused for lacking the caveat — which
|
|
2487
|
+
* is the correct outcome and is pinned by a test.
|
|
2488
|
+
*/
|
|
2489
|
+
/** DelegationManager, the EIP-712 `verifyingContract` for a delegation. */
|
|
2490
|
+
declare const DELEGATION_MANAGER = "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3";
|
|
2491
|
+
/**
|
|
2492
|
+
* Caveat enforcers, by role. Deterministically deployed, so Base and Base
|
|
2493
|
+
* Sepolia share addresses — verified for both chains by the pin test.
|
|
2494
|
+
*/
|
|
2495
|
+
declare const CAVEAT_ENFORCERS: {
|
|
2496
|
+
readonly erc20TransferAmount: "0xf100b0819427117EcF76Ed94B358B1A5b5C6D2Fc";
|
|
2497
|
+
readonly allowedCalldata: "0xc2b0d624c1c4319760C96503BA27C347F3260f55";
|
|
2498
|
+
readonly timestamp: "0x1046bb45C8d673d4ea75321280DB34899413c069";
|
|
2499
|
+
readonly redeemer: "0xE144b0b2618071B4E56f746313528a669c7E65c5";
|
|
2500
|
+
};
|
|
2501
|
+
/** The backend's own ceiling (`MAX_SETTLEMENT_WINDOW_SECONDS`), enforced again here. */
|
|
2502
|
+
declare const MAX_SETTLEMENT_WINDOW_SECONDS = 600;
|
|
2503
|
+
interface SettlementChildTypedData {
|
|
2504
|
+
domain: {
|
|
2505
|
+
name?: string;
|
|
2506
|
+
version?: string;
|
|
2507
|
+
chainId?: number | string;
|
|
2508
|
+
verifyingContract?: string;
|
|
2509
|
+
};
|
|
2510
|
+
types: Record<string, unknown>;
|
|
2511
|
+
primaryType: string;
|
|
2512
|
+
message: Record<string, unknown>;
|
|
2513
|
+
}
|
|
2514
|
+
/** True when this typed data is a delegation — the shape that must never be signed unbound. */
|
|
2515
|
+
declare function isSettlementChildTypedData(value: unknown): value is SettlementChildTypedData;
|
|
2516
|
+
/**
|
|
2517
|
+
* Map an x402 network string to a chain id. Local on purpose (#1455 review):
|
|
2518
|
+
* the chain must come from Haven's SIGNED `network` field, never from the
|
|
2519
|
+
* payload under verification — see `verifySettlementChild`.
|
|
2520
|
+
*/
|
|
2521
|
+
declare function chainIdForNetwork(network: string | undefined): number | undefined;
|
|
2522
|
+
interface SettlementChildExpectation {
|
|
2523
|
+
merchantTo: string;
|
|
2524
|
+
amount: string;
|
|
2525
|
+
asset: string;
|
|
2526
|
+
/**
|
|
2527
|
+
* Derived from the expected context's SIGNED `network`, never from
|
|
2528
|
+
* `typedData.domain.chainId`. Comparing the payload's own claim against
|
|
2529
|
+
* itself is a check that cannot fail — which is exactly what shipped in the
|
|
2530
|
+
* first draft of this file's call site, and what the review caught.
|
|
2531
|
+
*/
|
|
2532
|
+
chainId: number;
|
|
2533
|
+
/** ISO timestamp; the child must not outlive it. */
|
|
2534
|
+
expiresAt?: string;
|
|
2535
|
+
/**
|
|
2536
|
+
* #3283 / #3281 criterion 8: the signer's OWN derived delegate account.
|
|
2537
|
+
* When set, the child's `delegator` must be exactly this account — the
|
|
2538
|
+
* child is a re-delegation of this agent's budget, never a grant from some
|
|
2539
|
+
* other account the key happens to control.
|
|
2540
|
+
*/
|
|
2541
|
+
delegatorAccount?: string;
|
|
2542
|
+
/**
|
|
2543
|
+
* #3283: the facilitator addresses the merchant's 402 advertised
|
|
2544
|
+
* (`extra.facilitatorAddresses`). When non-empty, the child must carry a
|
|
2545
|
+
* `RedeemerEnforcer` caveat pinning exactly this set — otherwise the child
|
|
2546
|
+
* is a bearer instrument any party could redeem within its bounds.
|
|
2547
|
+
*/
|
|
2548
|
+
redeemers?: readonly string[];
|
|
2549
|
+
}
|
|
2550
|
+
/** `@metamask/delegation-core`'s `ROOT_AUTHORITY` — a delegation chained to nothing. */
|
|
2551
|
+
declare const ROOT_AUTHORITY: string;
|
|
2552
|
+
/**
|
|
2553
|
+
* Verify a settlement child implements what the expected context declares.
|
|
2554
|
+
* Throws `HavenSigningError` on any disagreement; returns nothing on success.
|
|
2555
|
+
*
|
|
2556
|
+
* `now` is injectable so the expiry checks are testable without faking clocks.
|
|
2557
|
+
*/
|
|
2558
|
+
declare function verifySettlementChild(typedData: SettlementChildTypedData, expected: SettlementChildExpectation, now?: number): void;
|
|
2559
|
+
|
|
2560
|
+
/** Wire code for a typed-data payload outside the signable allowlist. */
|
|
2561
|
+
declare const TYPED_DATA_NOT_ALLOWED: "TYPED_DATA_NOT_ALLOWED";
|
|
2562
|
+
/**
|
|
2563
|
+
* A typed-data payload was refused before signing because it is not a shape
|
|
2564
|
+
* a delegate key may sign. Nothing was signed. `@haven_ai/signer` subclasses
|
|
2565
|
+
* this to attach its MCP next step; the `code` is the same on both.
|
|
2566
|
+
*/
|
|
2567
|
+
declare class HavenTypedDataRefusedError extends HavenSigningError {
|
|
2568
|
+
readonly code: typeof TYPED_DATA_NOT_ALLOWED;
|
|
2569
|
+
constructor(message: string);
|
|
2570
|
+
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Chains the delegation rail has PINNED delegation contracts for
|
|
2573
|
+
* (`packages/backend/src/rails/delegation-contracts.ts`) — the only chains a
|
|
2574
|
+
* direct-payment UserOp may be scoped to. Gnosis (100) has no pinned
|
|
2575
|
+
* DelegationManager/enforcer set, so it is deliberately excluded even though
|
|
2576
|
+
* the delegate account itself could exist there.
|
|
2577
|
+
*/
|
|
2578
|
+
declare const DIRECT_PAYMENT_CHAIN_IDS: ReadonlySet<number>;
|
|
2579
|
+
/** The DeleGator's single-execution `execute((address,uint256,bytes))` — selector `0x5c1c6dcd`. */
|
|
2580
|
+
declare const EXECUTE_ABI: readonly [{
|
|
2581
|
+
readonly type: "function";
|
|
2582
|
+
readonly name: "execute";
|
|
2583
|
+
readonly inputs: readonly [{
|
|
2584
|
+
readonly name: "_execution";
|
|
2585
|
+
readonly type: "tuple";
|
|
2586
|
+
readonly components: readonly [{
|
|
2587
|
+
readonly name: "target";
|
|
2588
|
+
readonly type: "address";
|
|
2589
|
+
}, {
|
|
2590
|
+
readonly name: "value";
|
|
2591
|
+
readonly type: "uint256";
|
|
2592
|
+
}, {
|
|
2593
|
+
readonly name: "callData";
|
|
2594
|
+
readonly type: "bytes";
|
|
2595
|
+
}];
|
|
2596
|
+
}];
|
|
2597
|
+
readonly outputs: readonly [];
|
|
2598
|
+
readonly stateMutability: "payable";
|
|
2599
|
+
}];
|
|
2600
|
+
/**
|
|
2601
|
+
* The content + provenance allowlist (#3272 criteria 1–2). Call ONLY after
|
|
2602
|
+
* `assertUserOpTypedDataBinding` has already proven `typedData` is a
|
|
2603
|
+
* well-formed `PackedUserOperation` matching its own hash — this function
|
|
2604
|
+
* trusts `typedData.domain`/`message` are shaped correctly and checks only
|
|
2605
|
+
* what they SAY. Throws `HavenTypedDataRefusedError` (never returns) on any
|
|
2606
|
+
* disagreement.
|
|
2607
|
+
*/
|
|
2608
|
+
declare function assertBoundDirectPaymentUserOp(typedData: Record<string, unknown>, delegateAddress: string): void;
|
|
2609
|
+
|
|
2375
2610
|
/**
|
|
2376
2611
|
* Runtime-agnostic base64 helpers — the single source of truth for the wire
|
|
2377
2612
|
* encoding shared by the SDK and the edge signer (#325).
|
|
@@ -2410,4 +2645,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
2410
2645
|
*/
|
|
2411
2646
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
2412
2647
|
|
|
2413
|
-
export { type AgentPaymentSummary as $, type AgentPaymentWarning as A, type X402McpTransport as B, type X402MerchantCallContext as C, HavenError as D, AGENT_PAYMENT_FAILURE_CODE_VALUES as E, AGENT_PAYMENT_NEXT_ACTION_VALUES as F, AGENT_PAYMENT_PHASE_VALUES as G, type HavenClientConfig as H, AGENT_PAYMENT_RAIL_VALUES as I, type AgentNextStep as J, type AgentPaymentEnumSchema as K, AgentPaymentFailureCode as L, AgentPaymentFailureCodeDescriptions as M, AgentPaymentFailureCodeSchema as N, AgentPaymentNextAction as O, type PaymentRequest as P, AgentPaymentNextActionDescriptions as Q, type RawPaymentParties as R, type SweepResult as S, AgentPaymentNextActionSchema as T, AgentPaymentPhase as U, AgentPaymentPhaseDescriptions as V, AgentPaymentPhaseSchema as W, type X402PaymentRequired as X, AgentPaymentRail as Y, AgentPaymentRailDescriptions as Z, AgentPaymentRailSchema as _, type PaymentResult as a, type
|
|
2648
|
+
export { type AgentPaymentSummary as $, type AgentPaymentWarning as A, type X402McpTransport as B, type X402MerchantCallContext as C, HavenError as D, AGENT_PAYMENT_FAILURE_CODE_VALUES as E, AGENT_PAYMENT_NEXT_ACTION_VALUES as F, AGENT_PAYMENT_PHASE_VALUES as G, type HavenClientConfig as H, AGENT_PAYMENT_RAIL_VALUES as I, type AgentNextStep as J, type AgentPaymentEnumSchema as K, AgentPaymentFailureCode as L, AgentPaymentFailureCodeDescriptions as M, AgentPaymentFailureCodeSchema as N, AgentPaymentNextAction as O, type PaymentRequest as P, AgentPaymentNextActionDescriptions as Q, type RawPaymentParties as R, type SweepResult as S, AgentPaymentNextActionSchema as T, AgentPaymentPhase as U, AgentPaymentPhaseDescriptions as V, AgentPaymentPhaseSchema as W, type X402PaymentRequired as X, AgentPaymentRail as Y, AgentPaymentRailDescriptions as Z, AgentPaymentRailSchema as _, type PaymentResult as a, type X402PaymentHeaderContext as a$, AgentPaymentWarningCode as a0, type AgentPurchaseSummary as a1, CONNECTOR_PACKAGE_NAME as a2, type CatalogSubmissionAccepted as a3, DEFAULT_CONFIRMATION_TIMEOUT_MS as a4, DEFAULT_NEXT_TOOL_BY_ACTION as a5, DIRECT_SIGN_CONTEXT_VERSION as a6, ENTRY_POINT_V07 as a7, ERC7710_ASSET_TRANSFER_METHOD as a8, HAVEN_CONNECTOR_CHANNEL as a9, type NextToolServerRole as aA, PACKED_USER_OPERATION_FIELDS as aB, type PaymentFee as aC, type PaymentNextAction as aD, type PaymentPhase as aE, type PaymentStatus as aF, ROOT_AUTHORITY as aG, SIGNER_UPDATE_FALLBACK as aH, SWEEP_BASE_CHAIN_ID as aI, SWEEP_BASE_SEPOLIA_CHAIN_ID as aJ, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aK, SWEEP_BASE_USDC_ADDRESS as aL, type SettlementChildExpectation as aM, SignerRefusalCode as aN, type SweepConfirmation as aO, type SweepEip712Domain as aP, type SweepEntry as aQ, type SweepExpectedAuth as aR, type SweepPreparation as aS, type SweepSubmitResult as aT, type SweepTypedData as aU, TRANSFER_WITH_AUTHORIZATION_TYPES as aV, TYPED_DATA_NOT_ALLOWED as aW, type UnsupportedNodeVersionMessageOptions as aX, X402AlreadySettledError as aY, type X402ExpectedAuth as aZ, type X402ExpectedContext as a_, HAVEN_MINIMUM_NODE_VERSION as aa, HYBRID_DELEGATOR_DOMAIN_NAME as ab, HYBRID_DELEGATOR_DOMAIN_VERSION as ac, type HavenAgentAllowanceSummary as ad, type HavenAgentReadiness as ae, type HavenAllowance as af, HavenApiError as ag, type HavenCatalogMerchant as ah, type HavenListScope as ai, HavenPaymentStateError as aj, HavenSigningError as ak, HavenTimeoutError as al, HavenTypedDataRefusedError as am, HavenUnsupportedSignerVersionError as an, HavenUserOpBindingError as ao, HavenZeroSettlementHashError as ap, type MachinePaymentRail as aq, MerchantTimeoutError as ar, NEXT_TOOL_SERVER_NAMES as as, NEXT_TOOL_SERVER_ROLES as at, type NextStep as au, type NextStepArguments as av, type NextStepHandoff as aw, type NextStepInput as ax, type NextStepTarget as ay, type NextStepTargets as az, type PaymentIntent as b, type SettlementChildTypedData as b$, X402PaymentHeaderValidationError as b0, type X402PaymentOption as b1, type X402RequestSnapshot as b2, type X402SchemeSelection as b3, X402UnexpectedStatusError as b4, X402_LEGACY_PAYMENT_HEADER_NAME as b5, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as b6, X402_PAYMENT_HEADER_NAME as b7, X402_PAYMENT_HEADER_NAMES_SENT as b8, X402_PAYMENT_REQUIRED_HEADER_NAME as b9, parsePaymentRequired as bA, parsePaymentRequiredResponse as bB, renderNextTool as bC, resolveConnectorChannel as bD, resolveTokenFromAddress as bE, selectErc7710PaymentOption as bF, selectPaymentOption as bG, selectStandardPaymentOption as bH, selectX402SettlementScheme as bI, signerUpdateFallback as bJ, sweepUsdcAddress as bK, sweepUsdcDomain as bL, toStandardPaymentRequirements as bM, unsupportedNodeVersionMessage as bN, validateStandardX402PaymentHeader as bO, verifySettlementChild as bP, x402AssetTransferMethod as bQ, x402AuthorizationAmount as bR, x402FacilitatorAddresses as bS, x402V2PaymentEnvelope as bT, CAVEAT_ENFORCERS as bU, DELEGATION_MANAGER as bV, DIRECT_PAYMENT_CHAIN_IDS as bW, EXECUTE_ABI as bX, HYBRID_DELEGATOR_IMPLEMENTATION as bY, MAX_SETTLEMENT_WINDOW_SECONDS as bZ, SIMPLE_FACTORY_ADDRESS as b_, X402_PAYMENT_RESPONSE_HEADER_NAME as ba, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bb, assertBoundDirectPaymentUserOp as bc, assertUserOpTypedDataBinding as bd, buildSweepAuthorizationMessage as be, buildSweepTypedData as bf, buildX402ExpectedMessage as bg, compareNodeVersions as bh, connectorRerunCommand as bi, connectorSpec as bj, createNextStepBuilder as bk, decodeBase64Json as bl, decodeBase64Utf8 as bm, defaultNextToolFor as bn, deriveDelegateAccountAddress as bo, encodeBase64Json as bp, encodeBase64Utf8 as bq, encodePaymentProof as br, isConnectorChannel as bs, isErc7710Option as bt, isPackedUserOperationTypedData as bu, isSupportedNodeVersion as bv, isSweepableChain as bw, normalizePaymentRequired as bx, packedUserOperationHash as by, parseNextTool as bz, type X402AuthorizationOptions as c, chainIdForNetwork as c0, isSettlementChildTypedData as c1, type X402Intent as d, type PaymentStatusResult as e, type HavenAgent as f, type HavenAgentSummary as g, type SweepPrepareResponse as h, type SweepAuthorization as i, type SweepSubmitResponse as j, type HavenAllowanceSummary as k, type HavenBalanceCoverage as l, type PostPurchaseAllowanceSummary as m, type HavenCatalogEntry as n, type HavenCatalogSubmission as o, type HavenPaymentReceipt as p, type HavenPaymentReceiptsPage as q, type PaymentResumeState as r, type X402Receipt as s, type X402Quote as t, type X402Erc7710Settlement as u, type X402McpCallContext as v, type SignData as w, type ResumeAuthorizedX402Input as x, type ResumeX402PaymentInput as y, type X402ResumeState as z };
|