@haven_ai/sdk 0.5.0-alpha.1 → 0.6.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/README.md +2 -1
- package/dist/{base64-BUMXmruY.d.cts → base64-cD9kR4JL.d.cts} +243 -16
- package/dist/{base64-BUMXmruY.d.ts → base64-cD9kR4JL.d.ts} +243 -16
- package/dist/{chunk-KQ7JXKTV.js → chunk-3WSEX3GW.js} +315 -6
- package/dist/chunk-3WSEX3GW.js.map +1 -0
- package/dist/{chunk-GLNG2GF7.js → chunk-63GPTEEY.js} +42 -6
- package/dist/chunk-63GPTEEY.js.map +1 -0
- package/dist/{chunk-QSSVOPWA.cjs → chunk-CK4NLLMO.cjs} +333 -17
- package/dist/chunk-CK4NLLMO.cjs.map +1 -0
- package/dist/{chunk-JKUIE45B.cjs → chunk-S42QSWJY.cjs} +42 -6
- package/dist/chunk-S42QSWJY.cjs.map +1 -0
- package/dist/edge.cjs +85 -57
- package/dist/edge.d.cts +24 -4
- package/dist/edge.d.ts +24 -4
- package/dist/edge.js +3 -3
- package/dist/index.cjs +485 -294
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -3
- package/dist/index.d.ts +47 -3
- package/dist/index.js +192 -21
- package/dist/index.js.map +1 -1
- package/dist/test-support.cjs +18 -18
- package/dist/test-support.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-GLNG2GF7.js.map +0 -1
- package/dist/chunk-JKUIE45B.cjs.map +0 -1
- package/dist/chunk-KQ7JXKTV.js.map +0 -1
- package/dist/chunk-QSSVOPWA.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HavenSigningError, deriveDelegateAccountAddress, DELEGATION_MANAGER, assertRedeemsOwnBudgetDelegation, verifySettlementChild, REDEEM_DELEGATIONS_ABI } from './chunk-
|
|
2
|
-
import { decodeFunctionData, encodeFunctionData, encodePacked, recoverTypedDataAddress } from 'viem';
|
|
1
|
+
import { HavenSigningError, deriveDelegateAccountAddress, DELEGATION_MANAGER, assertRedeemsOwnBudgetDelegation, verifySettlementChild, REDEEM_DELEGATIONS_ABI, ROOT_AUTHORITY, CAVEAT_ENFORCERS, DELEGATION_TUPLE_COMPONENTS } from './chunk-63GPTEEY.js';
|
|
2
|
+
import { decodeFunctionData, encodeFunctionData, encodePacked, recoverTypedDataAddress, encodeAbiParameters, keccak256 } from 'viem';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
|
|
5
5
|
var TYPED_DATA_NOT_ALLOWED = "TYPED_DATA_NOT_ALLOWED";
|
|
@@ -777,7 +777,7 @@ function stableStringify2(value) {
|
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
// src/client-identity.ts
|
|
780
|
-
var SDK_VERSION = "0.
|
|
780
|
+
var SDK_VERSION = "0.6.0-alpha.0";
|
|
781
781
|
var HAVEN_CLIENT_HEADER = "X-Haven-Client";
|
|
782
782
|
function havenClientIdentity(pkg, version) {
|
|
783
783
|
return `${pkg}/${version}`;
|
|
@@ -896,7 +896,316 @@ function unsupportedNodeVersionMessage(options) {
|
|
|
896
896
|
function major(version) {
|
|
897
897
|
return String(parseNodeVersion(version)[0]);
|
|
898
898
|
}
|
|
899
|
+
var MAX_TASK_BUDGET_TTL_SECONDS = 86400;
|
|
900
|
+
var EXPECTED_DELEGATION_TYPES = {
|
|
901
|
+
Caveat: [
|
|
902
|
+
{ name: "enforcer", type: "address" },
|
|
903
|
+
{ name: "terms", type: "bytes" }
|
|
904
|
+
],
|
|
905
|
+
Delegation: [
|
|
906
|
+
{ name: "delegate", type: "address" },
|
|
907
|
+
{ name: "delegator", type: "address" },
|
|
908
|
+
{ name: "authority", type: "bytes32" },
|
|
909
|
+
{ name: "caveats", type: "Caveat[]" },
|
|
910
|
+
{ name: "salt", type: "uint256" }
|
|
911
|
+
]
|
|
912
|
+
};
|
|
913
|
+
var DELEGATION_DOMAIN_NAME = "DelegationManager";
|
|
914
|
+
var DELEGATION_DOMAIN_VERSION = "1";
|
|
915
|
+
function same(a, b) {
|
|
916
|
+
return !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
917
|
+
}
|
|
918
|
+
function hex(value) {
|
|
919
|
+
return value.startsWith("0x") ? value.slice(2).toLowerCase() : value.toLowerCase();
|
|
920
|
+
}
|
|
921
|
+
function slice(terms, start, end) {
|
|
922
|
+
const body = hex(terms);
|
|
923
|
+
return end === void 0 ? body.slice(start * 2) : body.slice(start * 2, end * 2);
|
|
924
|
+
}
|
|
925
|
+
function findCaveat(caveats, enforcer) {
|
|
926
|
+
return caveats.find((c) => same(c.enforcer, enforcer));
|
|
927
|
+
}
|
|
928
|
+
function isTaskChildTypedData(value) {
|
|
929
|
+
const td = value;
|
|
930
|
+
if (!td || td.primaryType !== "Delegation" || typeof td.domain?.verifyingContract !== "string" || !Array.isArray(td.message?.caveats)) {
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
const delegate = td.message?.delegate;
|
|
934
|
+
const delegator = td.message?.delegator;
|
|
935
|
+
return typeof delegate === "string" && typeof delegator === "string" && same(delegate, delegator);
|
|
936
|
+
}
|
|
937
|
+
function refuseTaskChild(what, detail) {
|
|
938
|
+
throw new HavenTypedDataRefusedError(
|
|
939
|
+
`Refusing to sign the task-budget child: ${what}. ${detail} This signature opens a self-delegated slice of the agent budget, so it is verified locally against the expectation Haven declared, rather than trusted.`
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
function assertOwnTaskChild(typedData, expected, delegateAddress, now = Date.now()) {
|
|
943
|
+
const td = typedData;
|
|
944
|
+
if (td?.primaryType !== "Delegation") {
|
|
945
|
+
refuseTaskChild("it is not a Delegation payload", `primaryType was '${String(td?.primaryType)}'.`);
|
|
946
|
+
}
|
|
947
|
+
if (!same(td.domain?.verifyingContract, DELEGATION_MANAGER)) {
|
|
948
|
+
refuseTaskChild(
|
|
949
|
+
"the EIP-712 domain names an unknown DelegationManager",
|
|
950
|
+
`Expected ${DELEGATION_MANAGER}, got ${td.domain?.verifyingContract}.`
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
if (td.domain?.name !== DELEGATION_DOMAIN_NAME || td.domain?.version !== DELEGATION_DOMAIN_VERSION) {
|
|
954
|
+
refuseTaskChild(
|
|
955
|
+
"the EIP-712 domain name/version does not match the pinned DelegationManager domain",
|
|
956
|
+
`Expected name '${DELEGATION_DOMAIN_NAME}' version '${DELEGATION_DOMAIN_VERSION}'; got name '${String(td.domain?.name)}' version '${String(td.domain?.version)}'.`
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
if (JSON.stringify(td.types?.Caveat) !== JSON.stringify(EXPECTED_DELEGATION_TYPES.Caveat) || JSON.stringify(td.types?.Delegation) !== JSON.stringify(EXPECTED_DELEGATION_TYPES.Delegation)) {
|
|
960
|
+
refuseTaskChild(
|
|
961
|
+
"its EIP-712 type definitions do not match the pinned Delegation/Caveat shape",
|
|
962
|
+
"A renamed, reordered, or additional field on Delegation or Caveat could change what the caveats below mean without changing this check's field-by-field comparisons."
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
const domainChain = Number(td.domain?.chainId);
|
|
966
|
+
if (!Number.isFinite(domainChain) || !DIRECT_PAYMENT_CHAIN_IDS.has(domainChain)) {
|
|
967
|
+
refuseTaskChild(
|
|
968
|
+
"it is scoped to a chain the delegation rail has no pinned contracts for",
|
|
969
|
+
`Chains with pinned contracts: ${[...DIRECT_PAYMENT_CHAIN_IDS].join(", ")}; the child says ${String(td.domain?.chainId)}.`
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
if (domainChain !== expected.chainId) {
|
|
973
|
+
refuseTaskChild(
|
|
974
|
+
"it is scoped to the wrong chain",
|
|
975
|
+
`Expected chain ${expected.chainId}; the child says ${td.domain?.chainId}.`
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
const ownAccount = deriveDelegateAccountAddress(delegateAddress);
|
|
979
|
+
const delegator = td.message?.delegator;
|
|
980
|
+
if (typeof delegator !== "string" || !same(delegator, ownAccount)) {
|
|
981
|
+
refuseTaskChild(
|
|
982
|
+
"it is not delegated by this agent's own account",
|
|
983
|
+
`Expected delegator ${ownAccount}; the child names ${String(delegator)}.`
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
const delegate = td.message?.delegate;
|
|
987
|
+
if (typeof delegate !== "string" || !same(delegate, ownAccount)) {
|
|
988
|
+
refuseTaskChild(
|
|
989
|
+
"it is not self-delegated to this agent's own account",
|
|
990
|
+
`Expected delegate ${ownAccount}; the child names ${String(delegate)}.`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
const authority = td.message?.authority;
|
|
994
|
+
if (typeof authority !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(authority)) {
|
|
995
|
+
refuseTaskChild("its authority is not a 32-byte delegation hash", `Got ${String(authority)}.`);
|
|
996
|
+
}
|
|
997
|
+
if (authority.toLowerCase() === ROOT_AUTHORITY) {
|
|
998
|
+
refuseTaskChild(
|
|
999
|
+
"it is a ROOT delegation, not a re-delegation of the agent budget",
|
|
1000
|
+
"A task budget always chains under the agent budget delegation."
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
if (!same(authority, expected.parentDelegationHash)) {
|
|
1004
|
+
refuseTaskChild(
|
|
1005
|
+
"it chains under a different parent delegation",
|
|
1006
|
+
`Expected authority ${expected.parentDelegationHash}; the child says ${authority}.`
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
const caveats = td.message?.caveats ?? [];
|
|
1010
|
+
const transfer = findCaveat(caveats, CAVEAT_ENFORCERS.erc20TransferAmount);
|
|
1011
|
+
if (!transfer) {
|
|
1012
|
+
refuseTaskChild(
|
|
1013
|
+
"it has no ERC-20 transfer-amount caveat",
|
|
1014
|
+
"Without it the child is not bounded to an amount."
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
const token = `0x${slice(transfer.terms, 0, 20)}`;
|
|
1018
|
+
if (!same(token, expected.tokenAddress)) {
|
|
1019
|
+
refuseTaskChild("it spends a different token", `Expected ${expected.tokenAddress}, child pins ${token}.`);
|
|
1020
|
+
}
|
|
1021
|
+
const amount = BigInt(`0x${slice(transfer.terms, 20, 52)}`);
|
|
1022
|
+
if (amount !== BigInt(expected.maxAmountAtomic)) {
|
|
1023
|
+
refuseTaskChild(
|
|
1024
|
+
"the amount does not match",
|
|
1025
|
+
`Expected ${expected.maxAmountAtomic}; the child allows ${amount.toString()}.`
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
const timestamp = findCaveat(caveats, CAVEAT_ENFORCERS.timestamp);
|
|
1029
|
+
if (!timestamp) {
|
|
1030
|
+
refuseTaskChild("it never expires", "A task-budget child without a timestamp caveat is open-ended.");
|
|
1031
|
+
}
|
|
1032
|
+
const beforeThreshold = Number(BigInt(`0x${slice(timestamp.terms, 16, 32)}`));
|
|
1033
|
+
const nowSec = Math.floor(now / 1e3);
|
|
1034
|
+
if (beforeThreshold <= nowSec) {
|
|
1035
|
+
refuseTaskChild("it has already expired", `Expiry ${beforeThreshold} is not in the future.`);
|
|
1036
|
+
}
|
|
1037
|
+
if (beforeThreshold > nowSec + MAX_TASK_BUDGET_TTL_SECONDS) {
|
|
1038
|
+
refuseTaskChild(
|
|
1039
|
+
"its window is longer than a task budget may live",
|
|
1040
|
+
`Expiry is ${beforeThreshold - nowSec}s out; the ceiling is ${MAX_TASK_BUDGET_TTL_SECONDS}s.`
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
if (beforeThreshold !== expected.expiresAt) {
|
|
1044
|
+
refuseTaskChild(
|
|
1045
|
+
"its expiry does not match what Haven declared",
|
|
1046
|
+
`Expected ${expected.expiresAt}; the child says ${beforeThreshold}.`
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
const calldata = findCaveat(caveats, CAVEAT_ENFORCERS.allowedCalldata);
|
|
1050
|
+
if (expected.recipientAddress) {
|
|
1051
|
+
if (!calldata) {
|
|
1052
|
+
refuseTaskChild(
|
|
1053
|
+
"it has no recipient pin",
|
|
1054
|
+
"The task budget was opened with a pinned recipient, so the child must carry one."
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
const startIndex = BigInt(`0x${slice(calldata.terms, 0, 32)}`);
|
|
1058
|
+
if (startIndex !== 4n) {
|
|
1059
|
+
refuseTaskChild(
|
|
1060
|
+
"the recipient pin points at the wrong calldata offset",
|
|
1061
|
+
`Expected offset 4, got ${startIndex.toString()}.`
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
const paddedRecipient = slice(calldata.terms, 32, 64);
|
|
1065
|
+
if (paddedRecipient.slice(0, 24) !== "0".repeat(24)) {
|
|
1066
|
+
refuseTaskChild("the pinned recipient is not a plain address", "Its 32-byte word is not a padded address.");
|
|
1067
|
+
}
|
|
1068
|
+
const recipient = `0x${paddedRecipient.slice(24)}`;
|
|
1069
|
+
if (!same(recipient, expected.recipientAddress)) {
|
|
1070
|
+
refuseTaskChild(
|
|
1071
|
+
"it pins a different recipient than Haven declared",
|
|
1072
|
+
`Expected ${expected.recipientAddress}; the child pins ${recipient}.`
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
} else if (calldata) {
|
|
1076
|
+
refuseTaskChild(
|
|
1077
|
+
"it pins a recipient the task budget was not opened with",
|
|
1078
|
+
"This task budget is open (no recipient pin); the child must not add one."
|
|
1079
|
+
);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
var DISABLE_DELEGATION_ABI = [
|
|
1083
|
+
{
|
|
1084
|
+
type: "function",
|
|
1085
|
+
name: "disableDelegation",
|
|
1086
|
+
inputs: [{ name: "delegation", type: "tuple", components: DELEGATION_TUPLE_COMPONENTS }],
|
|
1087
|
+
outputs: [],
|
|
1088
|
+
stateMutability: "nonpayable"
|
|
1089
|
+
}
|
|
1090
|
+
];
|
|
1091
|
+
function assertOwnTaskBudgetCloseUserOp(typedData, expected, delegateAddress) {
|
|
1092
|
+
const domain = typedData.domain ?? {};
|
|
1093
|
+
const message = typedData.message ?? {};
|
|
1094
|
+
if (typeof domain.chainId !== "number" && typeof domain.chainId !== "bigint") {
|
|
1095
|
+
throw new HavenTypedDataRefusedError(
|
|
1096
|
+
`This close UserOperation's domain.chainId is ${typeof domain.chainId} (${String(domain.chainId)}), not a number \u2014 refusing rather than risk signing a different EIP-712 domain than this check evaluated.`
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
const chainId = Number(domain.chainId);
|
|
1100
|
+
if (!DIRECT_PAYMENT_CHAIN_IDS.has(chainId)) {
|
|
1101
|
+
throw new HavenTypedDataRefusedError(
|
|
1102
|
+
`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.`
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
const ownAccount = deriveDelegateAccountAddress(delegateAddress);
|
|
1106
|
+
const sender = typeof message.sender === "string" ? message.sender : "";
|
|
1107
|
+
if (sender.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
1108
|
+
throw new HavenTypedDataRefusedError(
|
|
1109
|
+
`This close UserOperation's account (${sender || "unknown"}) is not this signer's own delegate account (${ownAccount}). Sign only your own agent's Haven-prepared payloads.`
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
const callData = message.callData;
|
|
1113
|
+
let decoded;
|
|
1114
|
+
try {
|
|
1115
|
+
const { args } = decodeFunctionData({ abi: EXECUTE_ABI, data: callData });
|
|
1116
|
+
decoded = args[0];
|
|
1117
|
+
} catch {
|
|
1118
|
+
throw new HavenTypedDataRefusedError(
|
|
1119
|
+
"This close UserOperation's callData is not a single execute((address,uint256,bytes)) call. This signer only signs a task-budget close of that exact shape."
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
const reEncodedExecute = encodeFunctionData({ abi: EXECUTE_ABI, functionName: "execute", args: [decoded] });
|
|
1123
|
+
if (reEncodedExecute.toLowerCase() !== callData.toLowerCase()) {
|
|
1124
|
+
throw new HavenTypedDataRefusedError(
|
|
1125
|
+
"This close UserOperation's execute() call does not re-encode to the exact callData bytes (trailing or non-canonical bytes). Refusing."
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
if (decoded.target.toLowerCase() !== DELEGATION_MANAGER.toLowerCase()) {
|
|
1129
|
+
throw new HavenTypedDataRefusedError(
|
|
1130
|
+
`This close UserOperation's execute() calls ${decoded.target}, not the DelegationManager (${DELEGATION_MANAGER}). Refusing what looks like a self-call or a call to an unrelated contract.`
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
if (decoded.value !== 0n) {
|
|
1134
|
+
throw new HavenTypedDataRefusedError(
|
|
1135
|
+
`This close UserOperation's execute() sends ${decoded.value} wei of native value alongside the DelegationManager call \u2014 a task-budget close never does. Refusing.`
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
let delegation;
|
|
1139
|
+
try {
|
|
1140
|
+
const { args } = decodeFunctionData({ abi: DISABLE_DELEGATION_ABI, data: decoded.callData });
|
|
1141
|
+
delegation = args[0];
|
|
1142
|
+
} catch {
|
|
1143
|
+
throw new HavenTypedDataRefusedError(
|
|
1144
|
+
"This close UserOperation's execute() does not call disableDelegation(Delegation) \u2014 this signer only signs a task-budget close of that exact shape."
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
const reEncodedDisable = encodeFunctionData({
|
|
1148
|
+
abi: DISABLE_DELEGATION_ABI,
|
|
1149
|
+
functionName: "disableDelegation",
|
|
1150
|
+
args: [delegation]
|
|
1151
|
+
});
|
|
1152
|
+
if (reEncodedDisable.toLowerCase() !== decoded.callData.toLowerCase()) {
|
|
1153
|
+
throw new HavenTypedDataRefusedError(
|
|
1154
|
+
"This close UserOperation's disableDelegation call does not re-encode to the exact bytes signed (trailing or non-canonical bytes). Refusing."
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
if (delegation.delegator.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
1158
|
+
throw new HavenTypedDataRefusedError(
|
|
1159
|
+
`This close UserOperation disables a delegation granted by ${delegation.delegator}, not this signer's own account (${ownAccount}). Refusing.`
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1162
|
+
if (delegation.delegate.toLowerCase() !== ownAccount.toLowerCase()) {
|
|
1163
|
+
throw new HavenTypedDataRefusedError(
|
|
1164
|
+
`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.`
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
if (delegation.authority.toLowerCase() === ROOT_AUTHORITY) {
|
|
1168
|
+
throw new HavenTypedDataRefusedError(
|
|
1169
|
+
"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."
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
const actualHash = hashDelegation(delegation);
|
|
1173
|
+
if (actualHash.toLowerCase() !== expected.delegationHash.toLowerCase()) {
|
|
1174
|
+
throw new HavenTypedDataRefusedError(
|
|
1175
|
+
`This close UserOperation disables delegation ${actualHash}, not the task budget's own child (${expected.delegationHash}). Refusing.`
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
var DELEGATION_TYPEHASH = "0x88c1d2ecf185adf710588203a5f263f0ff61be0d33da39792cde19ba9aa4331e";
|
|
1180
|
+
var CAVEAT_TYPEHASH = "0x80ad7e1b04ee6d994a125f4714ca0720908bd80ed16063ec8aee4b88e9253e2d";
|
|
1181
|
+
function hashCaveat(caveat) {
|
|
1182
|
+
const termsHash = keccak256(caveat.terms);
|
|
1183
|
+
const encoded = encodeAbiParameters(
|
|
1184
|
+
[{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }],
|
|
1185
|
+
[CAVEAT_TYPEHASH, caveat.enforcer, termsHash]
|
|
1186
|
+
);
|
|
1187
|
+
return keccak256(encoded);
|
|
1188
|
+
}
|
|
1189
|
+
function hashCaveatsArray(caveats) {
|
|
1190
|
+
const concatenated = `0x${caveats.map((c) => hashCaveat(c).slice(2)).join("")}`;
|
|
1191
|
+
return keccak256(concatenated);
|
|
1192
|
+
}
|
|
1193
|
+
function hashDelegation(delegation) {
|
|
1194
|
+
const caveatsHash = hashCaveatsArray(delegation.caveats);
|
|
1195
|
+
const encoded = encodeAbiParameters(
|
|
1196
|
+
[
|
|
1197
|
+
{ type: "bytes32" },
|
|
1198
|
+
{ type: "address" },
|
|
1199
|
+
{ type: "address" },
|
|
1200
|
+
{ type: "bytes32" },
|
|
1201
|
+
{ type: "bytes32" },
|
|
1202
|
+
{ type: "uint256" }
|
|
1203
|
+
],
|
|
1204
|
+
[DELEGATION_TYPEHASH, delegation.delegate, delegation.delegator, delegation.authority, caveatsHash, delegation.salt]
|
|
1205
|
+
);
|
|
1206
|
+
return keccak256(encoded);
|
|
1207
|
+
}
|
|
899
1208
|
|
|
900
|
-
export { DEFAULT_NEXT_TOOL_BY_ACTION, DIRECT_PAYMENT_CHAIN_IDS, ERC7710_ASSET_TRANSFER_METHOD, EXECUTE_ABI, HAVEN_CLIENT_HEADER, HAVEN_MINIMUM_NODE_VERSION, HavenTypedDataRefusedError, NEXT_TOOL_SERVER_NAMES, NEXT_TOOL_SERVER_ROLES, SDK_CLIENT_IDENTITY, SDK_VERSION, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, TRANSFER_WITH_AUTHORIZATION_TYPES, TYPED_DATA_NOT_ALLOWED, X402PaymentHeaderValidationError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, assertBoundDirectPaymentUserOp, assertFundingLegPaysDelegate, assertOwnSettlementChild, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, buildX402IdempotencyKey, compareNodeVersions, createNextStepBuilder, decodeBase64Json, decodeBase64Utf8, defaultNextToolFor, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, havenClientIdentity, isErc7710Option, isSupportedNodeVersion, isSweepableChain, normalizePaymentRequired, parseNextTool, parsePaymentRequired, parsePaymentRequiredResponse, readClientUpdate, renderNextTool, resolveTokenFromAddress, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402PaymentHeaderNamesFor, x402PaymentHeaderNamesSent, x402V2PaymentEnvelope };
|
|
901
|
-
//# sourceMappingURL=chunk-
|
|
902
|
-
//# sourceMappingURL=chunk-
|
|
1209
|
+
export { CAVEAT_TYPEHASH, DEFAULT_NEXT_TOOL_BY_ACTION, DELEGATION_TYPEHASH, DIRECT_PAYMENT_CHAIN_IDS, ERC7710_ASSET_TRANSFER_METHOD, EXECUTE_ABI, HAVEN_CLIENT_HEADER, HAVEN_MINIMUM_NODE_VERSION, HavenTypedDataRefusedError, MAX_TASK_BUDGET_TTL_SECONDS, NEXT_TOOL_SERVER_NAMES, NEXT_TOOL_SERVER_ROLES, SDK_CLIENT_IDENTITY, SDK_VERSION, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, TRANSFER_WITH_AUTHORIZATION_TYPES, TYPED_DATA_NOT_ALLOWED, X402PaymentHeaderValidationError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, assertBoundDirectPaymentUserOp, assertFundingLegPaysDelegate, assertOwnSettlementChild, assertOwnTaskBudgetCloseUserOp, assertOwnTaskChild, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, buildX402IdempotencyKey, compareNodeVersions, createNextStepBuilder, decodeBase64Json, decodeBase64Utf8, defaultNextToolFor, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, hashDelegation, havenClientIdentity, isErc7710Option, isSupportedNodeVersion, isSweepableChain, isTaskChildTypedData, normalizePaymentRequired, parseNextTool, parsePaymentRequired, parsePaymentRequiredResponse, readClientUpdate, renderNextTool, resolveTokenFromAddress, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402PaymentHeaderNamesFor, x402PaymentHeaderNamesSent, x402V2PaymentEnvelope };
|
|
1210
|
+
//# sourceMappingURL=chunk-3WSEX3GW.js.map
|
|
1211
|
+
//# sourceMappingURL=chunk-3WSEX3GW.js.map
|