@haven_ai/sdk 0.8.0-alpha.0 → 0.9.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base64-BZDPJ8M1.d.ts +1344 -0
- package/dist/base64-Cyxhsvqd.d.cts +1344 -0
- package/dist/{chunk-UXULZ3ZY.js → chunk-424S4QMG.js} +10 -5
- package/dist/chunk-424S4QMG.js.map +1 -0
- package/dist/{chunk-HX34HOW4.cjs → chunk-4Z6ATE44.cjs} +2 -2
- package/dist/chunk-4Z6ATE44.cjs.map +1 -0
- package/dist/chunk-7UTWSJC5.cjs +106 -0
- package/dist/chunk-7UTWSJC5.cjs.map +1 -0
- package/dist/{chunk-H4APV67M.js → chunk-J7N4LUZZ.js} +2 -2
- package/dist/chunk-J7N4LUZZ.js.map +1 -0
- package/dist/chunk-VRKWNJ7H.js +103 -0
- package/dist/chunk-VRKWNJ7H.js.map +1 -0
- package/dist/{chunk-WJFDXCYP.cjs → chunk-ZDKNPNI3.cjs} +41 -35
- package/dist/chunk-ZDKNPNI3.cjs.map +1 -0
- package/dist/edge.cjs +97 -89
- package/dist/edge.d.cts +4 -2
- package/dist/edge.d.ts +4 -2
- package/dist/edge.js +4 -4
- package/dist/index.cjs +1033 -490
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -147
- package/dist/index.d.ts +103 -147
- package/dist/index.js +705 -189
- package/dist/index.js.map +1 -1
- package/dist/receipt-D4Roey3D.d.cts +130 -0
- package/dist/receipt-WkXHZGbu.d.ts +130 -0
- package/dist/test-support.cjs +71 -18
- package/dist/test-support.cjs.map +1 -1
- package/dist/test-support.d.cts +21 -1
- package/dist/test-support.d.ts +21 -1
- package/dist/test-support.js +53 -3
- package/dist/test-support.js.map +1 -1
- package/dist/{base64-znjJJQqu.d.cts → types-CrszUJ7Z.d.cts} +208 -1306
- package/dist/{base64-znjJJQqu.d.ts → types-CrszUJ7Z.d.ts} +208 -1306
- package/package.json +1 -1
- package/dist/chunk-H4APV67M.js.map +0 -1
- package/dist/chunk-HX34HOW4.cjs.map +0 -1
- package/dist/chunk-UXULZ3ZY.js.map +0 -1
- package/dist/chunk-WJFDXCYP.cjs.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { DELEGATION_MANAGER } from './chunk-J7N4LUZZ.js';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { keccak256, toBytes, concatHex, encodeAbiParameters } from 'viem';
|
|
4
|
+
|
|
5
|
+
var RECEIPT_VERSION = "haven-receipt-1";
|
|
6
|
+
var DELEGATION_MANAGER_CHAIN_IDS = /* @__PURE__ */ new Set([8453, 84532]);
|
|
7
|
+
var EIP712_DOMAIN_TYPEHASH = keccak256(
|
|
8
|
+
toBytes("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
|
|
9
|
+
);
|
|
10
|
+
function delegationDomainSeparator(chainId) {
|
|
11
|
+
return keccak256(
|
|
12
|
+
encodeAbiParameters(
|
|
13
|
+
[{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "address" }],
|
|
14
|
+
[
|
|
15
|
+
EIP712_DOMAIN_TYPEHASH,
|
|
16
|
+
keccak256(toBytes("DelegationManager")),
|
|
17
|
+
keccak256(toBytes("1")),
|
|
18
|
+
BigInt(chainId),
|
|
19
|
+
DELEGATION_MANAGER
|
|
20
|
+
]
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function delegationDigest(structHash, chainId) {
|
|
25
|
+
return keccak256(concatHex(["0x1901", delegationDomainSeparator(chainId), structHash]));
|
|
26
|
+
}
|
|
27
|
+
function defaultRecover(hash, signature) {
|
|
28
|
+
return ethers.recoverAddress(hash, signature);
|
|
29
|
+
}
|
|
30
|
+
var NOT_A_SIGNED_RECEIPT = { verified: false, reason: "not_a_signed_receipt" };
|
|
31
|
+
function match(delegate, hash, signature, recover) {
|
|
32
|
+
let recovered;
|
|
33
|
+
try {
|
|
34
|
+
recovered = recover(hash, signature);
|
|
35
|
+
} catch {
|
|
36
|
+
return { ok: false, reason: "bad_signature" };
|
|
37
|
+
}
|
|
38
|
+
if (recovered.toLowerCase() !== delegate.toLowerCase()) {
|
|
39
|
+
return { ok: false, reason: "signer_mismatch", recoveredSigner: recovered };
|
|
40
|
+
}
|
|
41
|
+
return { ok: true, recoveredSigner: recovered };
|
|
42
|
+
}
|
|
43
|
+
function finish(result, verifiedOver) {
|
|
44
|
+
if (result.ok) {
|
|
45
|
+
return { verified: true, recoveredSigner: result.recoveredSigner, verifiedOver };
|
|
46
|
+
}
|
|
47
|
+
return result.recoveredSigner !== void 0 ? { verified: false, reason: result.reason, recoveredSigner: result.recoveredSigner } : { verified: false, reason: result.reason };
|
|
48
|
+
}
|
|
49
|
+
function verifyPaymentReceipt(receipt, recover = defaultRecover) {
|
|
50
|
+
if (typeof receipt !== "object" || receipt === null) return NOT_A_SIGNED_RECEIPT;
|
|
51
|
+
let source = receipt;
|
|
52
|
+
if (typeof source.authorization !== "object" || source.authorization === null) {
|
|
53
|
+
if (typeof source.receipt !== "object" || source.receipt === null) {
|
|
54
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
55
|
+
}
|
|
56
|
+
source = source.receipt;
|
|
57
|
+
}
|
|
58
|
+
if (typeof source.authorization !== "object" || source.authorization === null) {
|
|
59
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
60
|
+
}
|
|
61
|
+
const auth = source.authorization;
|
|
62
|
+
const { delegate, signHash, signature, signatureScheme } = auth;
|
|
63
|
+
if (typeof delegate !== "string" || delegate === "" || typeof signHash !== "string" || signHash === "") {
|
|
64
|
+
return NOT_A_SIGNED_RECEIPT;
|
|
65
|
+
}
|
|
66
|
+
if (typeof signature !== "string" || signature === "") {
|
|
67
|
+
return { verified: false, reason: "missing_signature" };
|
|
68
|
+
}
|
|
69
|
+
const chainId = typeof source.onChain?.chainId === "number" ? source.onChain.chainId : void 0;
|
|
70
|
+
const digestVerifiable = chainId !== void 0 && DELEGATION_MANAGER_CHAIN_IDS.has(chainId);
|
|
71
|
+
if (signatureScheme === "eip712_userop") {
|
|
72
|
+
return { verified: false, reason: "not_verifiable_offline" };
|
|
73
|
+
}
|
|
74
|
+
if (signatureScheme === "eip712_delegation") {
|
|
75
|
+
if (!digestVerifiable) {
|
|
76
|
+
return { verified: false, reason: "not_verifiable_offline" };
|
|
77
|
+
}
|
|
78
|
+
let digest;
|
|
79
|
+
try {
|
|
80
|
+
digest = delegationDigest(signHash, chainId);
|
|
81
|
+
} catch {
|
|
82
|
+
return { verified: false, reason: "bad_signature" };
|
|
83
|
+
}
|
|
84
|
+
return finish(match(delegate, digest, signature, recover), "delegation_digest");
|
|
85
|
+
}
|
|
86
|
+
const raw = match(delegate, signHash, signature, recover);
|
|
87
|
+
if (raw.ok) return finish(raw, "sign_hash");
|
|
88
|
+
if (digestVerifiable) {
|
|
89
|
+
let digest;
|
|
90
|
+
try {
|
|
91
|
+
digest = delegationDigest(signHash, chainId);
|
|
92
|
+
} catch {
|
|
93
|
+
return finish(raw, "sign_hash");
|
|
94
|
+
}
|
|
95
|
+
const delegated = match(delegate, digest, signature, recover);
|
|
96
|
+
if (delegated.ok) return finish(delegated, "delegation_digest");
|
|
97
|
+
}
|
|
98
|
+
return finish(raw, "sign_hash");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { RECEIPT_VERSION, verifyPaymentReceipt };
|
|
102
|
+
//# sourceMappingURL=chunk-VRKWNJ7H.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-VRKWNJ7H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/receipt.ts"],"names":[],"mappings":";;;;AA6CO,IAAM,eAAA,GAAkB;AA6E/B,IAAM,+CAAoD,IAAI,GAAA,CAAI,CAAC,IAAA,EAAM,KAAK,CAAC,CAAA;AAE/E,IAAM,sBAAA,GAAyB,SAAA;AAAA,EAC7B,QAAQ,oFAAoF;A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EAAA,IAAI,GAAA,CAAI,EAAA,EAAI,OAAO,MAAA,CAAO,KAAK,WAAW,CAAA;AAC1C,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,IAAI,MAAA;AACJ,IAAA,IAAI;AACF,MAAA,MAAA,GAAS,gBAAA,CAAiB,UAAU,OAAiB,CAAA;AAAA,IACvD,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,MAAA,CAAO,KAAK,WAAW,CAAA;AAAA,IAChC;AACA,IAAA,MAAM,SAAA,GAAY,KAAA,CAAM,QAAA,EAAU,MAAA,EAAQ,WAAW,OAAO,CAAA;AAC5D,IAAA,IAAI,SAAA,CAAU,EAAA,EAAI,OAAO,MAAA,CAAO,WAAW,mBAAmB,CAAA;AAAA,EAChE;AACA,EAAA,OAAO,MAAA,CAAO,KAAK,WAAW,CAAA;AAChC","file":"chunk-VRKWNJ7H.js","sourcesContent":["import { ethers } from 'ethers'\nimport { concatHex, encodeAbiParameters, keccak256, toBytes, type Hex } from 'viem'\nimport { DELEGATION_MANAGER } from './settlement-child.js'\nimport type { RawPaymentParties } from './types.js'\n\n/**\n * Verifiable payment receipts.\n *\n * A self-contained bundle for a settled Haven payment whose agent\n * authorisation can be checked offline. What `verifyPaymentReceipt` proves is\n * deliberately narrow: the `payment` block (amount, recipient) is\n * Haven-asserted and is NOT bound by the signature, and `verified: true` never\n * proves the payment settled on-chain — settlement stays an explorer check on\n * `onChain.txHash` / `settlementTxHash`.\n *\n * What `verified: true` means, per scheme:\n *\n * - erc7710 (`authorization.signatureScheme: 'eip712_delegation'`): the bundle\n * carries the settlement child's EIP-712 struct hash as `signHash`. The\n * verifier rebuilds the digest the delegate actually signed —\n * `keccak256(0x1901 ‖ domainSeparator(DelegationManager, chainId) ‖ signHash)`\n * — from the DelegationManager address the SDK pins and the bundle's\n * `onChain.chainId`, never from a value the receipt itself vouches for.\n * `verified: true` means the delegate key signed that settlement delegation\n * (`verifiedOver: 'delegation_digest'`).\n * - direct payments and the eip3009 funding leg\n * (`signatureScheme: 'eip712_userop'`) sign an ERC-4337 user operation the\n * bundle does not carry: they return `not_verifiable_offline` rather than a\n * false accusation.\n * - retired-rail bundles (no scheme) carry a raw-signed `signHash`; the\n * verifier recovers over it directly, then over the delegation digest when\n * the chain allows rebuilding it.\n *\n * Anything that is not a signed bundle — including a `haven_list_receipts`\n * history row, which carries no signature at all — returns\n * `not_a_signed_receipt`. Verification never throws.\n *\n * #3723: the response `GET /payments/{id}/receipt` returns —\n * `{ receipt, verification }` — is accepted AS-IS: when the top level carries\n * no `authorization`, the `.receipt` object inside is verified instead (one\n * level, no recursion). The wrapper's `verification` is never read — it is\n * Haven's own self-check, and trusting it would defeat an offline verifier.\n *\n * This lives in the SDK so agents and users can verify receipts client-side.\n */\nexport const RECEIPT_VERSION = 'haven-receipt-1'\n\nexport interface PaymentReceipt {\n version: typeof RECEIPT_VERSION\n paymentId: string\n payment: {\n token: string\n tokenAddress: string\n amount: string\n amountSek: string | null\n recipient: string\n /** The payer's smart-account address. */\n account: string\n /**\n * #2960: one party vocabulary for \"who paid\", additive alongside `account`\n * above (which is `parties.treasury_account` only). Optional: a server\n * from before #2960 emits neither. Ignored by `verifyPaymentReceipt`,\n * which reads only `authorization`.\n */\n parties?: RawPaymentParties\n chainId: number\n settledAt: string | null\n resourceUrl: string | null\n /**\n * #3770: the paying agent's own evidence-only verdict on what the\n * merchant DELIVERED (`ok` / `unusable` / `partial`, plus a bounded\n * note). Additive and OPTIONAL: a server from before #3770 emits\n * neither, and `null` means the agent has not reported. Ignored by\n * `verifyPaymentReceipt`, which reads only `authorization` — the same\n * rule `parties` follows. Evidence only: it never changes what the\n * payment itself is, and `settled`/amounts are untouched by a report.\n */\n deliveryQuality?: {\n quality: 'ok' | 'unusable' | 'partial'\n note: string | null\n reportedAt: string | null\n } | null\n }\n /** The agent's cryptographic authorisation — what makes the receipt verifiable. */\n authorization: {\n delegate: string\n signHash: string\n signature: string | null\n /**\n * #3418: which digest the delegate signed — selects what offline\n * verification rebuilds. `'eip712_delegation'`: the settlement\n * delegation's EIP-712 digest (erc7710). `'eip712_userop'`: an ERC-4337\n * user-operation digest the bundle does not carry (direct payments, the\n * eip3009 funding leg) — not verifiable offline. Absent on retired-rail\n * bundles and on backends older than #3418, whose `signHash` was signed\n * raw. The value is only a selector: a lying one cannot make a forged\n * signature verify, because recovery must still return `delegate`.\n */\n signatureScheme?: 'eip712_delegation' | 'eip712_userop'\n }\n onChain: {\n txHash: string | null\n chainId: number\n }\n}\n\nexport type ReceiptVerification =\n | { verified: true; recoveredSigner: string; verifiedOver: 'sign_hash' | 'delegation_digest' }\n | {\n verified: false\n reason:\n /** #3418: the input is not a haven-receipt-1 bundle (a haven_list_receipts row, null, undefined, a non-object). */\n | 'not_a_signed_receipt'\n /** #3418: eip712_userop bundle; or a delegation bundle on a chain the SDK pins no DelegationManager for. */\n | 'not_verifiable_offline'\n | 'missing_signature'\n | 'bad_signature'\n | 'signer_mismatch'\n recoveredSigner?: string\n }\n\n/** Chains whose DelegationManager the SDK pins (same address on both — rails/delegation-contracts.ts). */\nconst DELEGATION_MANAGER_CHAIN_IDS: ReadonlySet<number> = new Set([8453, 84532])\n\nconst EIP712_DOMAIN_TYPEHASH = keccak256(\n toBytes('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),\n)\n\n/**\n * The EIP-712 domain separator of the DelegationManager on `chainId`, rebuilt\n * from the manager's own constants (name/version, fixed in the contract) and\n * the address the SDK pins — never from a value the receipt vouches for.\n */\nfunction delegationDomainSeparator(chainId: number): Hex {\n return keccak256(\n encodeAbiParameters(\n [{ type: 'bytes32' }, { type: 'bytes32' }, { type: 'bytes32' }, { type: 'uint256' }, { type: 'address' }],\n [\n EIP712_DOMAIN_TYPEHASH,\n keccak256(toBytes('DelegationManager')),\n keccak256(toBytes('1')),\n BigInt(chainId),\n DELEGATION_MANAGER as Hex,\n ],\n ),\n )\n}\n\n/** The EIP-712 digest over a delegation struct hash (what the delegate signs). */\nfunction delegationDigest(structHash: string, chainId: number): Hex {\n return keccak256(concatHex(['0x1901', delegationDomainSeparator(chainId), structHash as Hex]))\n}\n\n/** Default ECDSA recovery (raw ecrecover over the hash, no message prefix). */\nfunction defaultRecover(hash: string, signature: string): string {\n return ethers.recoverAddress(hash, signature)\n}\n\nconst NOT_A_SIGNED_RECEIPT = { verified: false, reason: 'not_a_signed_receipt' } as const\n\ntype RecoverFn = (hash: string, signature: string) => string\n\ntype MatchResult =\n | { ok: true; recoveredSigner: string }\n | { ok: false; reason: 'bad_signature' | 'signer_mismatch'; recoveredSigner?: string }\n\n/** Recover over one candidate hash and compare the signer with the named delegate. */\nfunction match(delegate: string, hash: string, signature: string, recover: RecoverFn): MatchResult {\n let recovered: string\n try {\n recovered = recover(hash, signature)\n } catch {\n return { ok: false, reason: 'bad_signature' }\n }\n if (recovered.toLowerCase() !== delegate.toLowerCase()) {\n return { ok: false, reason: 'signer_mismatch', recoveredSigner: recovered }\n }\n return { ok: true, recoveredSigner: recovered }\n}\n\nfunction finish(result: MatchResult, verifiedOver: 'sign_hash' | 'delegation_digest'): ReceiptVerification {\n if (result.ok) {\n return { verified: true, recoveredSigner: result.recoveredSigner, verifiedOver }\n }\n return result.recoveredSigner !== undefined\n ? { verified: false, reason: result.reason, recoveredSigner: result.recoveredSigner }\n : { verified: false, reason: result.reason }\n}\n\n/**\n * Verify a receipt's agent authorisation offline: recover the signer and\n * confirm it is the agent delegate, over whichever digest the bundle's scheme\n * names (see the module doc for what that proves — and what it does not).\n * Never throws: anything that is not a signed receipt — a\n * `haven_list_receipts` history row, null, undefined, a non-object — returns\n * `not_a_signed_receipt`. The `{ receipt, verification }` wrapper the receipt\n * endpoint returns is accepted as-is: `.receipt` is verified, and the\n * wrapper's `verification` — Haven's own self-check — is never read. Pure —\n * `recover` is injectable but defaults to\n * standard ECDSA recovery, so this runs anywhere (no Haven backend).\n */\nexport function verifyPaymentReceipt(\n receipt: unknown,\n recover: RecoverFn = defaultRecover,\n): ReceiptVerification {\n // #3418 rule 1: a list row (or any non-bundle) has no authorization object\n // holding string delegate/signHash — answer, never throw.\n if (typeof receipt !== 'object' || receipt === null) return NOT_A_SIGNED_RECEIPT\n let source = receipt as {\n authorization?: unknown\n receipt?: unknown\n onChain?: { chainId?: unknown }\n }\n // #3723: accept the endpoint's response as-is. When the top level carries no\n // `authorization` and `.receipt` is a non-null object, verify the bundle\n // inside the `{ receipt, verification }` wrapper (GET\n // /payments/{id}/receipt, and HavenClient.getReceipt's re-wrap). ONE level\n // only — no recursion — and the wrapper's `verification` is NEVER read: it\n // is Haven's own self-check, and trusting it would defeat an offline\n // verifier. A list row wrapped or bare still answers not_a_signed_receipt.\n if (typeof source.authorization !== 'object' || source.authorization === null) {\n if (typeof source.receipt !== 'object' || source.receipt === null) {\n return NOT_A_SIGNED_RECEIPT\n }\n source = source.receipt as typeof source\n }\n if (typeof source.authorization !== 'object' || source.authorization === null) {\n return NOT_A_SIGNED_RECEIPT\n }\n const auth = source.authorization as {\n delegate?: unknown\n signHash?: unknown\n signature?: unknown\n signatureScheme?: unknown\n }\n const { delegate, signHash, signature, signatureScheme } = auth\n if (typeof delegate !== 'string' || delegate === '' || typeof signHash !== 'string' || signHash === '') {\n return NOT_A_SIGNED_RECEIPT\n }\n if (typeof signature !== 'string' || signature === '') {\n return { verified: false, reason: 'missing_signature' }\n }\n\n const chainId =\n typeof source.onChain?.chainId === 'number' ? source.onChain.chainId : undefined\n const digestVerifiable = chainId !== undefined && DELEGATION_MANAGER_CHAIN_IDS.has(chainId)\n\n // #3418 rule 4: a userop digest needs the full UserOperation, which the\n // bundle does not carry. Return not_verifiable_offline — never\n // signer_mismatch, which would accuse a genuine payment.\n if (signatureScheme === 'eip712_userop') {\n return { verified: false, reason: 'not_verifiable_offline' }\n }\n\n // #3418 rule 3: rebuild the delegation digest from the pinned manager and\n // the bundle's chain id, then recover over it.\n if (signatureScheme === 'eip712_delegation') {\n if (!digestVerifiable) {\n return { verified: false, reason: 'not_verifiable_offline' }\n }\n let digest: string\n try {\n digest = delegationDigest(signHash, chainId as number)\n } catch {\n return { verified: false, reason: 'bad_signature' }\n }\n return finish(match(delegate, digest, signature, recover), 'delegation_digest')\n }\n\n // #3418 rule 5: absent or unknown scheme — retired-rail history (signed raw\n // over signHash) or a backend older than this change. Raw recovery first,\n // then the delegation digest when the chain allows rebuilding it. This is\n // the one remaining ambiguous case, limited to old bundles.\n const raw = match(delegate, signHash, signature, recover)\n if (raw.ok) return finish(raw, 'sign_hash')\n if (digestVerifiable) {\n let digest: string\n try {\n digest = delegationDigest(signHash, chainId as number)\n } catch {\n return finish(raw, 'sign_hash')\n }\n const delegated = match(delegate, digest, signature, recover)\n if (delegated.ok) return finish(delegated, 'delegation_digest')\n }\n return finish(raw, 'sign_hash')\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4Z6ATE44_cjs = require('./chunk-4Z6ATE44.cjs');
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var secp256k1 = require('@noble/curves/secp256k1');
|
|
7
7
|
var accounts = require('viem/accounts');
|
|
8
8
|
|
|
9
9
|
var TYPED_DATA_NOT_ALLOWED = "TYPED_DATA_NOT_ALLOWED";
|
|
10
|
-
var HavenTypedDataRefusedError = class extends
|
|
10
|
+
var HavenTypedDataRefusedError = class extends chunk4Z6ATE44_cjs.HavenSigningError {
|
|
11
11
|
constructor(message) {
|
|
12
12
|
super(message);
|
|
13
13
|
this.code = TYPED_DATA_NOT_ALLOWED;
|
|
@@ -48,7 +48,7 @@ function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
|
|
|
48
48
|
`This signer only signs direct payments on chains the delegation rail has pinned contracts for (${[...DIRECT_PAYMENT_CHAIN_IDS].join(", ")}); this typed data names chain ${String(domain.chainId)}. Refusing.`
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
const ownAccount =
|
|
51
|
+
const ownAccount = chunk4Z6ATE44_cjs.deriveDelegateAccountAddress(delegateAddress);
|
|
52
52
|
const sender = typeof message.sender === "string" ? message.sender : "";
|
|
53
53
|
if (sender.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
54
54
|
throw new HavenTypedDataRefusedError(
|
|
@@ -78,9 +78,9 @@ function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
|
|
|
78
78
|
"This UserOperation's execute() call does not re-encode to the exact callData bytes (trailing or non-canonical bytes). Refusing."
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
|
-
if (decoded.target.toLowerCase() !==
|
|
81
|
+
if (decoded.target.toLowerCase() !== chunk4Z6ATE44_cjs.DELEGATION_MANAGER.toLowerCase()) {
|
|
82
82
|
throw new HavenTypedDataRefusedError(
|
|
83
|
-
`This UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${
|
|
83
|
+
`This UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${chunk4Z6ATE44_cjs.DELEGATION_MANAGER}). A direct payment only ever redeems the agent's own budget delegation \u2014 refusing what looks like a self-call (e.g. transferOwnership, updateSigners, upgradeToAndCall) or a call to an unrelated contract.`
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
if (decoded.value !== 0n) {
|
|
@@ -89,20 +89,20 @@ function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
|
-
|
|
92
|
+
chunk4Z6ATE44_cjs.assertRedeemsOwnBudgetDelegation(decoded.callData, ownAccount);
|
|
93
93
|
} catch (err) {
|
|
94
94
|
throw new HavenTypedDataRefusedError(err instanceof Error ? err.message : String(err));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
function assertOwnSettlementChild(typedData, expectation, delegateAddress) {
|
|
98
98
|
try {
|
|
99
|
-
|
|
99
|
+
chunk4Z6ATE44_cjs.verifySettlementChild(typedData, {
|
|
100
100
|
...expectation,
|
|
101
|
-
delegatorAccount:
|
|
101
|
+
delegatorAccount: chunk4Z6ATE44_cjs.deriveDelegateAccountAddress(delegateAddress)
|
|
102
102
|
});
|
|
103
103
|
} catch (err) {
|
|
104
104
|
if (err instanceof HavenTypedDataRefusedError) throw err;
|
|
105
|
-
if (err instanceof
|
|
105
|
+
if (err instanceof chunk4Z6ATE44_cjs.HavenSigningError) throw new HavenTypedDataRefusedError(err.message);
|
|
106
106
|
throw new HavenTypedDataRefusedError(
|
|
107
107
|
`Refusing to sign the x402 settlement child: it is malformed (${err instanceof Error ? err.message : String(err)}).`
|
|
108
108
|
);
|
|
@@ -131,7 +131,7 @@ function assertFundingLegPaysDelegate(typedData, expected) {
|
|
|
131
131
|
try {
|
|
132
132
|
const { args: executeArgs } = viem.decodeFunctionData({ abi: EXECUTE_ABI, data: message.callData });
|
|
133
133
|
const inner = executeArgs[0].callData;
|
|
134
|
-
const { args } = viem.decodeFunctionData({ abi:
|
|
134
|
+
const { args } = viem.decodeFunctionData({ abi: chunk4Z6ATE44_cjs.REDEEM_DELEGATIONS_ABI, data: inner });
|
|
135
135
|
const executions = args[2];
|
|
136
136
|
executionCallData = executions[0];
|
|
137
137
|
} catch {
|
|
@@ -250,7 +250,7 @@ var TRANSFER_WITH_AUTHORIZATION_TYPES = {
|
|
|
250
250
|
function sweepUsdcAddress(chainId) {
|
|
251
251
|
const address = USDC_ADDRESS_BY_CHAIN[chainId];
|
|
252
252
|
if (!address) {
|
|
253
|
-
throw new
|
|
253
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError(
|
|
254
254
|
`Sweep is not supported on chain ${chainId}. Supported: ${SWEEPABLE_CHAIN_IDS.join(", ")}.`
|
|
255
255
|
);
|
|
256
256
|
}
|
|
@@ -259,7 +259,7 @@ function sweepUsdcAddress(chainId) {
|
|
|
259
259
|
function sweepUsdcDomain(chainId) {
|
|
260
260
|
const domain = USDC_EIP712_DOMAIN_BY_CHAIN[chainId];
|
|
261
261
|
if (!domain) {
|
|
262
|
-
throw new
|
|
262
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError(
|
|
263
263
|
`Sweep is not supported on chain ${chainId}. Supported: ${SWEEPABLE_CHAIN_IDS.join(", ")}.`
|
|
264
264
|
);
|
|
265
265
|
}
|
|
@@ -272,12 +272,12 @@ function buildSweepTypedData(auth) {
|
|
|
272
272
|
const domain = sweepUsdcDomain(auth.chainId);
|
|
273
273
|
const expectedToken = sweepUsdcAddress(auth.chainId);
|
|
274
274
|
if (!sameAddress(auth.token, expectedToken)) {
|
|
275
|
-
throw new
|
|
275
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError(
|
|
276
276
|
`Sweep token ${auth.token} is not the canonical USDC contract for chain ${auth.chainId}.`
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
279
|
if (!/^0x[0-9a-fA-F]{64}$/.test(auth.nonce)) {
|
|
280
|
-
throw new
|
|
280
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError("Sweep nonce must be a 0x-prefixed 32-byte hex string.");
|
|
281
281
|
}
|
|
282
282
|
return {
|
|
283
283
|
domain,
|
|
@@ -448,6 +448,11 @@ function x402PaymentHeaderNamesFor(paymentHeader) {
|
|
|
448
448
|
if (!accepted || typeof accepted !== "object" || Array.isArray(accepted)) return both;
|
|
449
449
|
return isErc7710Option(accepted) ? [X402_PAYMENT_HEADER_NAME] : both;
|
|
450
450
|
}
|
|
451
|
+
function x402RetryHeadersFor(paymentHeader) {
|
|
452
|
+
return Object.fromEntries(
|
|
453
|
+
x402PaymentHeaderNamesFor(paymentHeader).map((name) => [name, paymentHeader])
|
|
454
|
+
);
|
|
455
|
+
}
|
|
451
456
|
function x402PaymentHeaderNamesSent(paymentHeader) {
|
|
452
457
|
return x402PaymentHeaderNamesFor(paymentHeader).join(", ");
|
|
453
458
|
}
|
|
@@ -777,7 +782,7 @@ function stableStringify2(value) {
|
|
|
777
782
|
}
|
|
778
783
|
|
|
779
784
|
// src/client-identity.ts
|
|
780
|
-
var SDK_VERSION = "0.
|
|
785
|
+
var SDK_VERSION = "0.9.0-alpha.0";
|
|
781
786
|
var HAVEN_CLIENT_HEADER = "X-Haven-Client";
|
|
782
787
|
function havenClientIdentity(pkg, version) {
|
|
783
788
|
return `${pkg}/${version}`;
|
|
@@ -810,7 +815,7 @@ function addressFromKey(privateKey) {
|
|
|
810
815
|
try {
|
|
811
816
|
return accounts.privateKeyToAddress(`0x${hexBytes(privateKey, 32, "private key")}`);
|
|
812
817
|
} catch (err) {
|
|
813
|
-
throw new
|
|
818
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError(
|
|
814
819
|
`Invalid private key: ${err instanceof Error ? err.message : String(err)}`
|
|
815
820
|
);
|
|
816
821
|
}
|
|
@@ -824,7 +829,7 @@ function signHash(privateKey, hash) {
|
|
|
824
829
|
yParity: recovery
|
|
825
830
|
});
|
|
826
831
|
} catch (err) {
|
|
827
|
-
throw new
|
|
832
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError(
|
|
828
833
|
`Failed to sign hash: ${err instanceof Error ? err.message : String(err)}`
|
|
829
834
|
);
|
|
830
835
|
}
|
|
@@ -860,7 +865,7 @@ var TAX_DECLARATION_TYPES = {
|
|
|
860
865
|
var X_TAX_DECLARATION_HEADER = "X-Tax-Declaration";
|
|
861
866
|
function validateContent(content) {
|
|
862
867
|
if (typeof content !== "object" || content === null || Array.isArray(content)) {
|
|
863
|
-
throw new
|
|
868
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError("Tax declaration content must be an object.");
|
|
864
869
|
}
|
|
865
870
|
const record = content;
|
|
866
871
|
for (const field of ["principalId", "principalAttributionHash"]) {
|
|
@@ -913,7 +918,7 @@ function taxPrincipalId(network, delegateAddress) {
|
|
|
913
918
|
if (network.startsWith("eip155:")) {
|
|
914
919
|
return `did:pkh:${network}:${delegateAddress}`;
|
|
915
920
|
}
|
|
916
|
-
const chainId =
|
|
921
|
+
const chainId = chunk4Z6ATE44_cjs.chainIdForNetwork(network);
|
|
917
922
|
if (chainId === void 0) {
|
|
918
923
|
throw new TaxDeclarationRefusedError(
|
|
919
924
|
`The accepted payment option's network '${network}' is not a CAIP-2 eip155 chain this SDK can name; refusing to build a tax principal without the settlement network.`
|
|
@@ -958,12 +963,12 @@ function addressFromKeyForTax(delegateKey) {
|
|
|
958
963
|
try {
|
|
959
964
|
return addressFromKey(delegateKey);
|
|
960
965
|
} catch (err) {
|
|
961
|
-
throw new
|
|
966
|
+
throw new chunk4Z6ATE44_cjs.HavenSigningError(
|
|
962
967
|
`Invalid delegate key for tax declaration signing: ${err instanceof Error ? err.message : String(err)}`
|
|
963
968
|
);
|
|
964
969
|
}
|
|
965
970
|
}
|
|
966
|
-
var TaxDeclarationRefusedError = class extends
|
|
971
|
+
var TaxDeclarationRefusedError = class extends chunk4Z6ATE44_cjs.HavenSigningError {
|
|
967
972
|
code = "TAX_DECLARATION_REFUSED";
|
|
968
973
|
constructor(message) {
|
|
969
974
|
super(message);
|
|
@@ -1115,10 +1120,10 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1115
1120
|
if (td?.primaryType !== "Delegation") {
|
|
1116
1121
|
refuseTaskChild("it is not a Delegation payload", `primaryType was '${String(td?.primaryType)}'.`);
|
|
1117
1122
|
}
|
|
1118
|
-
if (!same(td.domain?.verifyingContract,
|
|
1123
|
+
if (!same(td.domain?.verifyingContract, chunk4Z6ATE44_cjs.DELEGATION_MANAGER)) {
|
|
1119
1124
|
refuseTaskChild(
|
|
1120
1125
|
"the EIP-712 domain names an unknown DelegationManager",
|
|
1121
|
-
`Expected ${
|
|
1126
|
+
`Expected ${chunk4Z6ATE44_cjs.DELEGATION_MANAGER}, got ${td.domain?.verifyingContract}.`
|
|
1122
1127
|
);
|
|
1123
1128
|
}
|
|
1124
1129
|
if (td.domain?.name !== DELEGATION_DOMAIN_NAME || td.domain?.version !== DELEGATION_DOMAIN_VERSION) {
|
|
@@ -1146,7 +1151,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1146
1151
|
`Expected chain ${expected.chainId}; the child says ${td.domain?.chainId}.`
|
|
1147
1152
|
);
|
|
1148
1153
|
}
|
|
1149
|
-
const ownAccount =
|
|
1154
|
+
const ownAccount = chunk4Z6ATE44_cjs.deriveDelegateAccountAddress(delegateAddress);
|
|
1150
1155
|
const delegator = td.message?.delegator;
|
|
1151
1156
|
if (typeof delegator !== "string" || !same(delegator, ownAccount)) {
|
|
1152
1157
|
refuseTaskChild(
|
|
@@ -1165,7 +1170,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1165
1170
|
if (typeof authority !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(authority)) {
|
|
1166
1171
|
refuseTaskChild("its authority is not a 32-byte delegation hash", `Got ${String(authority)}.`);
|
|
1167
1172
|
}
|
|
1168
|
-
if (authority.toLowerCase() ===
|
|
1173
|
+
if (authority.toLowerCase() === chunk4Z6ATE44_cjs.ROOT_AUTHORITY) {
|
|
1169
1174
|
refuseTaskChild(
|
|
1170
1175
|
"it is a ROOT delegation, not a re-delegation of the agent budget",
|
|
1171
1176
|
"A task budget always chains under the agent budget delegation."
|
|
@@ -1178,7 +1183,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1178
1183
|
);
|
|
1179
1184
|
}
|
|
1180
1185
|
const caveats = td.message?.caveats ?? [];
|
|
1181
|
-
const transfer = findCaveat(caveats,
|
|
1186
|
+
const transfer = findCaveat(caveats, chunk4Z6ATE44_cjs.CAVEAT_ENFORCERS.erc20TransferAmount);
|
|
1182
1187
|
if (!transfer) {
|
|
1183
1188
|
refuseTaskChild(
|
|
1184
1189
|
"it has no ERC-20 transfer-amount caveat",
|
|
@@ -1196,7 +1201,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1196
1201
|
`Expected ${expected.maxAmountAtomic}; the child allows ${amount.toString()}.`
|
|
1197
1202
|
);
|
|
1198
1203
|
}
|
|
1199
|
-
const timestamp = findCaveat(caveats,
|
|
1204
|
+
const timestamp = findCaveat(caveats, chunk4Z6ATE44_cjs.CAVEAT_ENFORCERS.timestamp);
|
|
1200
1205
|
if (!timestamp) {
|
|
1201
1206
|
refuseTaskChild("it never expires", "A task-budget child without a timestamp caveat is open-ended.");
|
|
1202
1207
|
}
|
|
@@ -1217,7 +1222,7 @@ function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now
|
|
|
1217
1222
|
`Expected ${expected.expiresAt}; the child says ${beforeThreshold}.`
|
|
1218
1223
|
);
|
|
1219
1224
|
}
|
|
1220
|
-
const calldata = findCaveat(caveats,
|
|
1225
|
+
const calldata = findCaveat(caveats, chunk4Z6ATE44_cjs.CAVEAT_ENFORCERS.allowedCalldata);
|
|
1221
1226
|
if (expected.recipientAddress) {
|
|
1222
1227
|
if (!calldata) {
|
|
1223
1228
|
refuseTaskChild(
|
|
@@ -1254,7 +1259,7 @@ var DISABLE_DELEGATION_ABI = [
|
|
|
1254
1259
|
{
|
|
1255
1260
|
type: "function",
|
|
1256
1261
|
name: "disableDelegation",
|
|
1257
|
-
inputs: [{ name: "delegation", type: "tuple", components:
|
|
1262
|
+
inputs: [{ name: "delegation", type: "tuple", components: chunk4Z6ATE44_cjs.DELEGATION_TUPLE_COMPONENTS }],
|
|
1258
1263
|
outputs: [],
|
|
1259
1264
|
stateMutability: "nonpayable"
|
|
1260
1265
|
}
|
|
@@ -1273,7 +1278,7 @@ function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
|
1273
1278
|
`This signer only signs a task-budget close on chains the delegation rail has pinned contracts for (${[...DIRECT_PAYMENT_CHAIN_IDS].join(", ")}); this typed data names chain ${String(domain.chainId)}. Refusing.`
|
|
1274
1279
|
);
|
|
1275
1280
|
}
|
|
1276
|
-
const ownAccount =
|
|
1281
|
+
const ownAccount = chunk4Z6ATE44_cjs.deriveDelegateAccountAddress(delegateAddress);
|
|
1277
1282
|
const sender = typeof message.sender === "string" ? message.sender : "";
|
|
1278
1283
|
if (sender.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
1279
1284
|
throw new HavenTypedDataRefusedError(
|
|
@@ -1296,9 +1301,9 @@ function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
|
1296
1301
|
"This close UserOperation's execute() call does not re-encode to the exact callData bytes (trailing or non-canonical bytes). Refusing."
|
|
1297
1302
|
);
|
|
1298
1303
|
}
|
|
1299
|
-
if (decoded.target.toLowerCase() !==
|
|
1304
|
+
if (decoded.target.toLowerCase() !== chunk4Z6ATE44_cjs.DELEGATION_MANAGER.toLowerCase()) {
|
|
1300
1305
|
throw new HavenTypedDataRefusedError(
|
|
1301
|
-
`This close UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${
|
|
1306
|
+
`This close UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${chunk4Z6ATE44_cjs.DELEGATION_MANAGER}). Refusing what looks like a self-call or a call to an unrelated contract.`
|
|
1302
1307
|
);
|
|
1303
1308
|
}
|
|
1304
1309
|
if (decoded.value !== 0n) {
|
|
@@ -1335,7 +1340,7 @@ function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
|
1335
1340
|
`This close UserOperation disables a delegation granted to ${delegation.delegate}, not this signer's own account (${ownAccount}) \u2014 a task-budget child is always self-delegated. Refusing.`
|
|
1336
1341
|
);
|
|
1337
1342
|
}
|
|
1338
|
-
if (delegation.authority.toLowerCase() ===
|
|
1343
|
+
if (delegation.authority.toLowerCase() === chunk4Z6ATE44_cjs.ROOT_AUTHORITY) {
|
|
1339
1344
|
throw new HavenTypedDataRefusedError(
|
|
1340
1345
|
"This close UserOperation disables a ROOT delegation, not a re-delegation of the agent budget. A task-budget child always chains under the agent budget delegation. Refusing."
|
|
1341
1346
|
);
|
|
@@ -1464,6 +1469,7 @@ exports.x402AuthorizationAmount = x402AuthorizationAmount;
|
|
|
1464
1469
|
exports.x402FacilitatorAddresses = x402FacilitatorAddresses;
|
|
1465
1470
|
exports.x402PaymentHeaderNamesFor = x402PaymentHeaderNamesFor;
|
|
1466
1471
|
exports.x402PaymentHeaderNamesSent = x402PaymentHeaderNamesSent;
|
|
1472
|
+
exports.x402RetryHeadersFor = x402RetryHeadersFor;
|
|
1467
1473
|
exports.x402V2PaymentEnvelope = x402V2PaymentEnvelope;
|
|
1468
|
-
//# sourceMappingURL=chunk-
|
|
1469
|
-
//# sourceMappingURL=chunk-
|
|
1474
|
+
//# sourceMappingURL=chunk-ZDKNPNI3.cjs.map
|
|
1475
|
+
//# sourceMappingURL=chunk-ZDKNPNI3.cjs.map
|