@haven_ai/signer 0.0.0-dev.202609250651.afc2091 → 0.0.0-dev.202609250737.3bd5a51

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/index.cjs CHANGED
@@ -61,7 +61,7 @@ function createEdgeSigner(delegateKey, options = {}) {
61
61
  `Refusing to sign the x402 settlement child: this signer cannot map the network '${expected.network}' to a chain id, so it cannot check which chain the child is scoped to. Update @haven_ai/signer.`
62
62
  );
63
63
  }
64
- edge.verifySettlementChild(typedData, {
64
+ edge.assertOwnSettlementChild(typedData, {
65
65
  merchantTo: expected.merchantTo,
66
66
  amount: expected.amount,
67
67
  asset: expected.asset,
@@ -71,7 +71,21 @@ function createEdgeSigner(delegateKey, options = {}) {
71
71
  // signed another" class this file exists to catch (#1455 review).
72
72
  chainId: settlementChainId,
73
73
  expiresAt: expected.expiresAt
74
+ }, delegateAddress);
75
+ } else if (edge.isPackedUserOperationTypedData(typedData)) {
76
+ edge.assertUserOpTypedDataBinding(typedData, expected.payloadHash);
77
+ edge.assertBoundDirectPaymentUserOp(typedData, delegateAddress);
78
+ edge.assertFundingLegPaysDelegate(typedData, {
79
+ delegateAddress,
80
+ asset: expected.asset,
81
+ amount: expected.amount
74
82
  });
83
+ } else {
84
+ throw new edge.HavenTypedDataRefusedError(
85
+ `This signer's x402 arm signs only a funding-leg PackedUserOperation or an erc7710 settlement Delegation; this typed data is '${String(
86
+ typedData.primaryType
87
+ )}'. Refusing, even though its digest is bound by the expected context.`
88
+ );
75
89
  }
76
90
  const account = accounts.privateKeyToAccount(delegateKey);
77
91
  const signature = await account.signTypedData(
@@ -896,7 +910,7 @@ var HavenTypedDataNotAllowedError = class extends edge.HavenTypedDataRefusedErro
896
910
  });
897
911
  }
898
912
  };
899
- function assertBoundDirectPaymentUserOp(typedData, delegateAddress) {
913
+ function assertBoundDirectPaymentUserOp2(typedData, delegateAddress) {
900
914
  try {
901
915
  edge.assertBoundDirectPaymentUserOp(typedData, delegateAddress);
902
916
  } catch (err) {
@@ -1096,7 +1110,17 @@ var toolDescriptions = {
1096
1110
  haven_sign_sweep_delegate: SIGN_SWEEP_DELEGATE_DESCRIPTION
1097
1111
  };
1098
1112
  async function signFundingLeg(signer, expected, typedData) {
1099
- return signer.signX402FundingTypedData(typedData, expected);
1113
+ try {
1114
+ return await signer.signX402FundingTypedData(typedData, expected);
1115
+ } catch (err) {
1116
+ if (err instanceof edge.HavenTypedDataRefusedError && !(err instanceof HavenTypedDataNotAllowedError)) {
1117
+ throw new HavenTypedDataNotAllowedError(err.message);
1118
+ }
1119
+ if (err instanceof edge.HavenUserOpBindingError) {
1120
+ throw new HavenUserOpBindingRefusedError(err.message);
1121
+ }
1122
+ throw err;
1123
+ }
1100
1124
  }
1101
1125
  function toExpectedX402(raw) {
1102
1126
  return {
@@ -1210,7 +1234,7 @@ function createToolHandlers(signer, options = {}) {
1210
1234
  }
1211
1235
  throw err;
1212
1236
  }
1213
- assertBoundDirectPaymentUserOp(typedData, signer.delegateAddress);
1237
+ assertBoundDirectPaymentUserOp2(typedData, signer.delegateAddress);
1214
1238
  const signature = await signer.signDelegationTypedData(typedData);
1215
1239
  await auditSigning("haven_sign", viem.hashTypedData(typedData));
1216
1240
  return { signature };
@@ -1577,7 +1601,7 @@ async function writeAckFile(path$1, hash) {
1577
1601
  );
1578
1602
  }
1579
1603
  var SIGNER_NAME = "@haven_ai/signer";
1580
- var SIGNER_VERSION = "0.0.0-dev.202609250651.afc2091";
1604
+ var SIGNER_VERSION = "0.0.0-dev.202609250737.3bd5a51";
1581
1605
  async function resolveEdgeSigner(options = {}) {
1582
1606
  const { signer } = await resolveSignerRuntime(options);
1583
1607
  return signer;