@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/README.md +13 -6
- package/dist/cli.cjs +27 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +28 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +29 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { randomUUID, createHash } from 'crypto';
|
|
3
3
|
import { readFile, mkdir, writeFile, stat, lstat, rename, appendFile, chmod } from 'fs/promises';
|
|
4
4
|
import { resolve, dirname, join } from 'path';
|
|
5
|
-
import { createNextStepBuilder, isSupportedNodeVersion, unsupportedNodeVersionMessage, addressFromKey, HavenSigningError, buildSweepTypedData, selectStandardPaymentOption, HavenApiError, toStandardPaymentRequirements, decodeBase64Json, encodeBase64Json, x402V2PaymentEnvelope, isSettlementChildTypedData, chainIdForNetwork,
|
|
5
|
+
import { createNextStepBuilder, isSupportedNodeVersion, unsupportedNodeVersionMessage, addressFromKey, HavenSigningError, buildSweepTypedData, selectStandardPaymentOption, HavenApiError, toStandardPaymentRequirements, decodeBase64Json, encodeBase64Json, x402V2PaymentEnvelope, isSettlementChildTypedData, chainIdForNetwork, assertOwnSettlementChild, isPackedUserOperationTypedData, assertUserOpTypedDataBinding, assertBoundDirectPaymentUserOp as assertBoundDirectPaymentUserOp$1, assertFundingLegPaysDelegate, HavenTypedDataRefusedError, connectorRerunCommand, buildSweepAuthorizationMessage, verifySignature, x402AuthorizationAmount, SignerRefusalCode, SIGNER_UPDATE_FALLBACK, HavenUnsupportedSignerVersionError, buildX402ExpectedMessage, DIRECT_SIGN_CONTEXT_VERSION, HavenError, AgentPaymentFailureCode, AgentPaymentNextAction, HavenUserOpBindingError } from '@haven_ai/sdk/edge';
|
|
6
6
|
import { recoverTypedDataAddress, hashTypedData, hashMessage } from 'viem';
|
|
7
7
|
import { z as z$1 } from 'zod/v3';
|
|
8
8
|
import { z } from 'zod';
|
|
@@ -632,7 +632,17 @@ var toolDescriptions = {
|
|
|
632
632
|
haven_sign_sweep_delegate: SIGN_SWEEP_DELEGATE_DESCRIPTION
|
|
633
633
|
};
|
|
634
634
|
async function signFundingLeg(signer, expected, typedData) {
|
|
635
|
-
|
|
635
|
+
try {
|
|
636
|
+
return await signer.signX402FundingTypedData(typedData, expected);
|
|
637
|
+
} catch (err) {
|
|
638
|
+
if (err instanceof HavenTypedDataRefusedError && !(err instanceof HavenTypedDataNotAllowedError)) {
|
|
639
|
+
throw new HavenTypedDataNotAllowedError(err.message);
|
|
640
|
+
}
|
|
641
|
+
if (err instanceof HavenUserOpBindingError) {
|
|
642
|
+
throw new HavenUserOpBindingRefusedError(err.message);
|
|
643
|
+
}
|
|
644
|
+
throw err;
|
|
645
|
+
}
|
|
636
646
|
}
|
|
637
647
|
function toExpectedX402(raw) {
|
|
638
648
|
return {
|
|
@@ -1220,7 +1230,7 @@ function createEdgeSigner(delegateKey, options = {}) {
|
|
|
1220
1230
|
`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.`
|
|
1221
1231
|
);
|
|
1222
1232
|
}
|
|
1223
|
-
|
|
1233
|
+
assertOwnSettlementChild(typedData, {
|
|
1224
1234
|
merchantTo: expected.merchantTo,
|
|
1225
1235
|
amount: expected.amount,
|
|
1226
1236
|
asset: expected.asset,
|
|
@@ -1230,7 +1240,21 @@ function createEdgeSigner(delegateKey, options = {}) {
|
|
|
1230
1240
|
// signed another" class this file exists to catch (#1455 review).
|
|
1231
1241
|
chainId: settlementChainId,
|
|
1232
1242
|
expiresAt: expected.expiresAt
|
|
1243
|
+
}, delegateAddress);
|
|
1244
|
+
} else if (isPackedUserOperationTypedData(typedData)) {
|
|
1245
|
+
assertUserOpTypedDataBinding(typedData, expected.payloadHash);
|
|
1246
|
+
assertBoundDirectPaymentUserOp$1(typedData, delegateAddress);
|
|
1247
|
+
assertFundingLegPaysDelegate(typedData, {
|
|
1248
|
+
delegateAddress,
|
|
1249
|
+
asset: expected.asset,
|
|
1250
|
+
amount: expected.amount
|
|
1233
1251
|
});
|
|
1252
|
+
} else {
|
|
1253
|
+
throw new HavenTypedDataRefusedError(
|
|
1254
|
+
`This signer's x402 arm signs only a funding-leg PackedUserOperation or an erc7710 settlement Delegation; this typed data is '${String(
|
|
1255
|
+
typedData.primaryType
|
|
1256
|
+
)}'. Refusing, even though its digest is bound by the expected context.`
|
|
1257
|
+
);
|
|
1234
1258
|
}
|
|
1235
1259
|
const account = privateKeyToAccount(delegateKey);
|
|
1236
1260
|
const signature = await account.signTypedData(
|
|
@@ -1637,7 +1661,7 @@ async function warnIfCredentialFilePermissive(path, log = (message) => process.s
|
|
|
1637
1661
|
|
|
1638
1662
|
// src/server.ts
|
|
1639
1663
|
var SIGNER_NAME = "@haven_ai/signer";
|
|
1640
|
-
var SIGNER_VERSION = "0.0.0-dev.
|
|
1664
|
+
var SIGNER_VERSION = "0.0.0-dev.202609250737.3bd5a51";
|
|
1641
1665
|
async function resolveSignerRuntime(options = {}) {
|
|
1642
1666
|
assertSupportedNodeVersion(options.nodeVersion);
|
|
1643
1667
|
if (options.delegateKey) {
|