@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/index.d.cts
CHANGED
|
@@ -772,7 +772,7 @@ declare function renderSignerConsentBlock(input: SignerConsentInput, hash: strin
|
|
|
772
772
|
declare function ensureSignerConsent(input: SignerConsentInput, options?: SignerConsentOptions): Promise<SignerConsentDecision>;
|
|
773
773
|
|
|
774
774
|
declare const SIGNER_NAME = "@haven_ai/signer";
|
|
775
|
-
declare const SIGNER_VERSION = "0.0.0-dev.
|
|
775
|
+
declare const SIGNER_VERSION = "0.0.0-dev.202609250737.3bd5a51";
|
|
776
776
|
interface SignerOptions {
|
|
777
777
|
/** Path to a Haven credential JSON file (delegate_key is read from it). */
|
|
778
778
|
credentialsPath?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -772,7 +772,7 @@ declare function renderSignerConsentBlock(input: SignerConsentInput, hash: strin
|
|
|
772
772
|
declare function ensureSignerConsent(input: SignerConsentInput, options?: SignerConsentOptions): Promise<SignerConsentDecision>;
|
|
773
773
|
|
|
774
774
|
declare const SIGNER_NAME = "@haven_ai/signer";
|
|
775
|
-
declare const SIGNER_VERSION = "0.0.0-dev.
|
|
775
|
+
declare const SIGNER_VERSION = "0.0.0-dev.202609250737.3bd5a51";
|
|
776
776
|
interface SignerOptions {
|
|
777
777
|
/** Path to a Haven credential JSON file (delegate_key is read from it). */
|
|
778
778
|
credentialsPath?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID, createHash } from 'crypto';
|
|
2
2
|
import { recoverTypedDataAddress, hashTypedData, hashMessage } from 'viem';
|
|
3
3
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
-
import { createNextStepBuilder, addressFromKey, HavenSigningError, buildSweepTypedData, selectStandardPaymentOption, HavenApiError, toStandardPaymentRequirements, decodeBase64Json, encodeBase64Json, x402V2PaymentEnvelope, isSettlementChildTypedData, chainIdForNetwork,
|
|
4
|
+
import { createNextStepBuilder, addressFromKey, HavenSigningError, buildSweepTypedData, selectStandardPaymentOption, HavenApiError, toStandardPaymentRequirements, decodeBase64Json, encodeBase64Json, x402V2PaymentEnvelope, isSettlementChildTypedData, chainIdForNetwork, assertOwnSettlementChild, isPackedUserOperationTypedData, assertUserOpTypedDataBinding, assertBoundDirectPaymentUserOp, assertFundingLegPaysDelegate, HavenTypedDataRefusedError, buildSweepAuthorizationMessage, verifySignature, x402AuthorizationAmount, SignerRefusalCode, connectorRerunCommand, SIGNER_UPDATE_FALLBACK, HavenUnsupportedSignerVersionError, buildX402ExpectedMessage, DIRECT_SIGN_CONTEXT_VERSION, AgentPaymentNextAction, HavenError, AgentPaymentFailureCode, isSupportedNodeVersion, unsupportedNodeVersionMessage, HavenUserOpBindingError } from '@haven_ai/sdk/edge';
|
|
5
5
|
export { deriveDelegateAccountAddress } from '@haven_ai/sdk/edge';
|
|
6
6
|
import { stat, lstat, chmod, readFile, mkdir, rename, appendFile, writeFile } from 'fs/promises';
|
|
7
7
|
import { resolve, dirname, join } from 'path';
|
|
@@ -60,7 +60,7 @@ function createEdgeSigner(delegateKey, options = {}) {
|
|
|
60
60
|
`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.`
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
assertOwnSettlementChild(typedData, {
|
|
64
64
|
merchantTo: expected.merchantTo,
|
|
65
65
|
amount: expected.amount,
|
|
66
66
|
asset: expected.asset,
|
|
@@ -70,7 +70,21 @@ function createEdgeSigner(delegateKey, options = {}) {
|
|
|
70
70
|
// signed another" class this file exists to catch (#1455 review).
|
|
71
71
|
chainId: settlementChainId,
|
|
72
72
|
expiresAt: expected.expiresAt
|
|
73
|
+
}, delegateAddress);
|
|
74
|
+
} else if (isPackedUserOperationTypedData(typedData)) {
|
|
75
|
+
assertUserOpTypedDataBinding(typedData, expected.payloadHash);
|
|
76
|
+
assertBoundDirectPaymentUserOp(typedData, delegateAddress);
|
|
77
|
+
assertFundingLegPaysDelegate(typedData, {
|
|
78
|
+
delegateAddress,
|
|
79
|
+
asset: expected.asset,
|
|
80
|
+
amount: expected.amount
|
|
73
81
|
});
|
|
82
|
+
} else {
|
|
83
|
+
throw new HavenTypedDataRefusedError(
|
|
84
|
+
`This signer's x402 arm signs only a funding-leg PackedUserOperation or an erc7710 settlement Delegation; this typed data is '${String(
|
|
85
|
+
typedData.primaryType
|
|
86
|
+
)}'. Refusing, even though its digest is bound by the expected context.`
|
|
87
|
+
);
|
|
74
88
|
}
|
|
75
89
|
const account = privateKeyToAccount(delegateKey);
|
|
76
90
|
const signature = await account.signTypedData(
|
|
@@ -895,9 +909,9 @@ var HavenTypedDataNotAllowedError = class extends HavenTypedDataRefusedError {
|
|
|
895
909
|
});
|
|
896
910
|
}
|
|
897
911
|
};
|
|
898
|
-
function
|
|
912
|
+
function assertBoundDirectPaymentUserOp2(typedData, delegateAddress) {
|
|
899
913
|
try {
|
|
900
|
-
assertBoundDirectPaymentUserOp
|
|
914
|
+
assertBoundDirectPaymentUserOp(typedData, delegateAddress);
|
|
901
915
|
} catch (err) {
|
|
902
916
|
if (err instanceof HavenTypedDataRefusedError && !(err instanceof HavenTypedDataNotAllowedError)) {
|
|
903
917
|
throw new HavenTypedDataNotAllowedError(err.message);
|
|
@@ -1095,7 +1109,17 @@ var toolDescriptions = {
|
|
|
1095
1109
|
haven_sign_sweep_delegate: SIGN_SWEEP_DELEGATE_DESCRIPTION
|
|
1096
1110
|
};
|
|
1097
1111
|
async function signFundingLeg(signer, expected, typedData) {
|
|
1098
|
-
|
|
1112
|
+
try {
|
|
1113
|
+
return await signer.signX402FundingTypedData(typedData, expected);
|
|
1114
|
+
} catch (err) {
|
|
1115
|
+
if (err instanceof HavenTypedDataRefusedError && !(err instanceof HavenTypedDataNotAllowedError)) {
|
|
1116
|
+
throw new HavenTypedDataNotAllowedError(err.message);
|
|
1117
|
+
}
|
|
1118
|
+
if (err instanceof HavenUserOpBindingError) {
|
|
1119
|
+
throw new HavenUserOpBindingRefusedError(err.message);
|
|
1120
|
+
}
|
|
1121
|
+
throw err;
|
|
1122
|
+
}
|
|
1099
1123
|
}
|
|
1100
1124
|
function toExpectedX402(raw) {
|
|
1101
1125
|
return {
|
|
@@ -1209,7 +1233,7 @@ function createToolHandlers(signer, options = {}) {
|
|
|
1209
1233
|
}
|
|
1210
1234
|
throw err;
|
|
1211
1235
|
}
|
|
1212
|
-
|
|
1236
|
+
assertBoundDirectPaymentUserOp2(typedData, signer.delegateAddress);
|
|
1213
1237
|
const signature = await signer.signDelegationTypedData(typedData);
|
|
1214
1238
|
await auditSigning("haven_sign", hashTypedData(typedData));
|
|
1215
1239
|
return { signature };
|
|
@@ -1576,7 +1600,7 @@ async function writeAckFile(path, hash) {
|
|
|
1576
1600
|
);
|
|
1577
1601
|
}
|
|
1578
1602
|
var SIGNER_NAME = "@haven_ai/signer";
|
|
1579
|
-
var SIGNER_VERSION = "0.0.0-dev.
|
|
1603
|
+
var SIGNER_VERSION = "0.0.0-dev.202609250737.3bd5a51";
|
|
1580
1604
|
async function resolveEdgeSigner(options = {}) {
|
|
1581
1605
|
const { signer } = await resolveSignerRuntime(options);
|
|
1582
1606
|
return signer;
|