@haven_ai/sdk 0.1.18-alpha.0 → 0.1.20-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/index.cjs +52 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -1
- package/dist/index.d.ts +100 -1
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1692,6 +1692,75 @@ declare const HAVEN_SKILL_MD = "---\nname: haven-pay\ndescription: Pay for thing
|
|
|
1692
1692
|
/** Directory name for the installed skill folder. */
|
|
1693
1693
|
declare const SKILL_FOLDER_NAME = "haven-pay";
|
|
1694
1694
|
|
|
1695
|
+
/**
|
|
1696
|
+
* The Node.js floor Haven's published packages support (#1161).
|
|
1697
|
+
*
|
|
1698
|
+
* ## Why this lives in the SDK
|
|
1699
|
+
*
|
|
1700
|
+
* Three packages need to enforce the same floor — `connect` (at setup),
|
|
1701
|
+
* `signer` and `mcp` (at startup) — and `@haven_ai/sdk` is the only dependency
|
|
1702
|
+
* all three already share. A copy per package is how the floor drifted in the
|
|
1703
|
+
* first place: `engines` said `>=24` everywhere while connect's runtime manifest
|
|
1704
|
+
* enforced `20.0.0`, so a connect run on Node v23 passed the guard, installed
|
|
1705
|
+
* the signer, and signed a real payment. Two numbers for one fact is one number
|
|
1706
|
+
* too many.
|
|
1707
|
+
*
|
|
1708
|
+
* Each consumer still owns its own refusal — the error type, the exit code, the
|
|
1709
|
+
* wording of "what to do next" — because a library must never terminate its
|
|
1710
|
+
* host process. This module only answers *is this version supported* and *what
|
|
1711
|
+
* should we tell the user*.
|
|
1712
|
+
*
|
|
1713
|
+
* ## Why a floor is enforced at all
|
|
1714
|
+
*
|
|
1715
|
+
* `engines` is advisory: npm emits `EBADENGINE` and installs anyway unless the
|
|
1716
|
+
* user happens to have `engine-strict` set. For a normal library that is a
|
|
1717
|
+
* reasonable default. For the **signer** it is not — it holds the delegate key
|
|
1718
|
+
* and produces every payment signature, so a subtle runtime incompatibility
|
|
1719
|
+
* shows up as a wrong or missing signature on a money path. "It seemed to work"
|
|
1720
|
+
* is precisely the evidence that cannot be relied on there.
|
|
1721
|
+
*/
|
|
1722
|
+
/**
|
|
1723
|
+
* The minimum supported Node.js version, as `major.minor.patch`.
|
|
1724
|
+
*
|
|
1725
|
+
* MUST equal the `engines.node` floor declared by every published Haven
|
|
1726
|
+
* package. A guard test in each package asserts exactly that against its own
|
|
1727
|
+
* `package.json`, so the two cannot drift again silently.
|
|
1728
|
+
*/
|
|
1729
|
+
declare const HAVEN_MINIMUM_NODE_VERSION = "24.0.0";
|
|
1730
|
+
/**
|
|
1731
|
+
* Compare two Node versions. Negative when `left` is older.
|
|
1732
|
+
*
|
|
1733
|
+
* An unparseable version parses to `0.0.0` and therefore compares as older than
|
|
1734
|
+
* any real floor — fail-closed. A version string Haven cannot read is not
|
|
1735
|
+
* evidence of a supported runtime, and treating it as one would reopen exactly
|
|
1736
|
+
* the hole this module closes.
|
|
1737
|
+
*/
|
|
1738
|
+
declare function compareNodeVersions(left: string, right: string): number;
|
|
1739
|
+
declare function isSupportedNodeVersion(nodeVersion?: string, minimumNodeVersion?: string): boolean;
|
|
1740
|
+
interface UnsupportedNodeVersionMessageOptions {
|
|
1741
|
+
/**
|
|
1742
|
+
* What is being refused, in the user's terms — "Haven setup", "The Haven
|
|
1743
|
+
* signer". Leads the message so the reader knows what just stopped.
|
|
1744
|
+
*/
|
|
1745
|
+
subject: string;
|
|
1746
|
+
nodeVersion?: string;
|
|
1747
|
+
minimumNodeVersion?: string;
|
|
1748
|
+
/** Appended verbatim as the closing line. Used for the re-run instruction. */
|
|
1749
|
+
retryHint?: string;
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* The refusal text.
|
|
1753
|
+
*
|
|
1754
|
+
* Names the detected version, the required version, and **how to fix it** — the
|
|
1755
|
+
* previous message stopped after the two version numbers, which tells a user
|
|
1756
|
+
* they are stuck without telling them how to get unstuck. The version-manager
|
|
1757
|
+
* lines are the fix for nearly everyone; the closing caveat is there because the
|
|
1758
|
+
* runtime that *spawns* the signer is frequently not the shell that was
|
|
1759
|
+
* upgraded, and a desktop app can keep launching the old Node long after
|
|
1760
|
+
* `node -v` in a terminal says otherwise.
|
|
1761
|
+
*/
|
|
1762
|
+
declare function unsupportedNodeVersionMessage(options: UnsupportedNodeVersionMessageOptions): string;
|
|
1763
|
+
|
|
1695
1764
|
/**
|
|
1696
1765
|
* x402 protocol support for the Haven SDK.
|
|
1697
1766
|
*
|
|
@@ -1704,6 +1773,36 @@ declare const SKILL_FOLDER_NAME = "haven-pay";
|
|
|
1704
1773
|
* (see client.ts) since they need API access and signing.
|
|
1705
1774
|
*/
|
|
1706
1775
|
|
|
1776
|
+
/**
|
|
1777
|
+
* Upper bound on the MERCHANT-requested part of the EIP-3009 authorization
|
|
1778
|
+
* window (#715, epic #713). The x402 library sets
|
|
1779
|
+
* `validBefore = now + maxTimeoutSeconds` straight from the MERCHANT's 402
|
|
1780
|
+
* challenge — without a cap, a malicious or sloppy merchant can request a
|
|
1781
|
+
* year-long window and a leaked signed authorization stays spendable that
|
|
1782
|
+
* whole time. 600 s is generous for any facilitator settle (typical is
|
|
1783
|
+
* 30–60 s); we CLAMP rather than reject so payments keep flowing while
|
|
1784
|
+
* exposure stays bounded. `validBefore` is a deadline, not a demand —
|
|
1785
|
+
* settling earlier is always valid.
|
|
1786
|
+
*/
|
|
1787
|
+
declare const X402_MAX_AUTHORIZATION_WINDOW_SECONDS = 600;
|
|
1788
|
+
/**
|
|
1789
|
+
* Forward margin ADDED on top of the (clamped) merchant timeout when the
|
|
1790
|
+
* authorization is actually signed (#1256). The x402 verify rule requires
|
|
1791
|
+
* `validBefore ≥ now + maxTimeoutSeconds` AT THE FACILITATOR — but the
|
|
1792
|
+
* upstream library computes `validBefore = now + maxTimeoutSeconds` at
|
|
1793
|
+
* SIGNING time, leaving zero forward margin. Haven's flow guarantees elapsed
|
|
1794
|
+
* time between the two (the funding UserOp confirms before the merchant
|
|
1795
|
+
* retry, ~1 min plus latency), so every purchase against a merchant whose
|
|
1796
|
+
* `maxTimeoutSeconds` exceeded that latency failed structurally — measured
|
|
1797
|
+
* live on Base mainnet: Anchor requires 300 s, and 226 s remained at verify.
|
|
1798
|
+
*
|
|
1799
|
+
* 300 s covers funding + retry latency with room to spare. The #715 exposure
|
|
1800
|
+
* ceiling becomes clamped-timeout + margin ≤ 900 s total forward — a
|
|
1801
|
+
* deliberate widening from 600 s, recorded on #1256: an authorization that
|
|
1802
|
+
* cannot pass verify protects no one, and 900 s is still bounded by the same
|
|
1803
|
+
* clamp discipline.
|
|
1804
|
+
*/
|
|
1805
|
+
declare const X402_SETTLEMENT_FORWARD_MARGIN_SECONDS = 300;
|
|
1707
1806
|
/**
|
|
1708
1807
|
* Parse an HTTP 402 response into x402 PaymentRequired data.
|
|
1709
1808
|
*
|
|
@@ -1816,4 +1915,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
1816
1915
|
*/
|
|
1817
1916
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
1818
1917
|
|
|
1819
|
-
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type ClaudeTool, HAVEN_SKILL_MD, type HavenAgent, type HavenAgentAllowanceSummary, type HavenAgentReadiness, type HavenAgentSummary, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type MppAuthorizationOptions, type MppQuote, type MppResumeState, type OpenAITool, type PaymentFee, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentReceipt, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PendingApproval, RECEIPT_VERSION, type ReceiptVerification, type ResumeAuthorizedMppInput, type ResumeAuthorizedX402Input, type ResumeMppPaymentInput, type ResumeX402PaymentInput, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, type SweepAuthorization, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type X402AuthorizationOptions, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpTransport, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, isSweepableChain, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, verifyPaymentReceipt, verifySignature, x402AuthorizationAmount };
|
|
1918
|
+
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type ClaudeTool, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_MD, type HavenAgent, type HavenAgentAllowanceSummary, type HavenAgentReadiness, type HavenAgentSummary, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type MppAuthorizationOptions, type MppQuote, type MppResumeState, type OpenAITool, type PaymentFee, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentReceipt, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PendingApproval, RECEIPT_VERSION, type ReceiptVerification, type ResumeAuthorizedMppInput, type ResumeAuthorizedX402Input, type ResumeMppPaymentInput, type ResumeX402PaymentInput, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, type SweepAuthorization, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type UnsupportedNodeVersionMessageOptions, type X402AuthorizationOptions, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpTransport, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, isSupportedNodeVersion, isSweepableChain, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, verifyPaymentReceipt, verifySignature, x402AuthorizationAmount };
|
package/dist/index.d.ts
CHANGED
|
@@ -1692,6 +1692,75 @@ declare const HAVEN_SKILL_MD = "---\nname: haven-pay\ndescription: Pay for thing
|
|
|
1692
1692
|
/** Directory name for the installed skill folder. */
|
|
1693
1693
|
declare const SKILL_FOLDER_NAME = "haven-pay";
|
|
1694
1694
|
|
|
1695
|
+
/**
|
|
1696
|
+
* The Node.js floor Haven's published packages support (#1161).
|
|
1697
|
+
*
|
|
1698
|
+
* ## Why this lives in the SDK
|
|
1699
|
+
*
|
|
1700
|
+
* Three packages need to enforce the same floor — `connect` (at setup),
|
|
1701
|
+
* `signer` and `mcp` (at startup) — and `@haven_ai/sdk` is the only dependency
|
|
1702
|
+
* all three already share. A copy per package is how the floor drifted in the
|
|
1703
|
+
* first place: `engines` said `>=24` everywhere while connect's runtime manifest
|
|
1704
|
+
* enforced `20.0.0`, so a connect run on Node v23 passed the guard, installed
|
|
1705
|
+
* the signer, and signed a real payment. Two numbers for one fact is one number
|
|
1706
|
+
* too many.
|
|
1707
|
+
*
|
|
1708
|
+
* Each consumer still owns its own refusal — the error type, the exit code, the
|
|
1709
|
+
* wording of "what to do next" — because a library must never terminate its
|
|
1710
|
+
* host process. This module only answers *is this version supported* and *what
|
|
1711
|
+
* should we tell the user*.
|
|
1712
|
+
*
|
|
1713
|
+
* ## Why a floor is enforced at all
|
|
1714
|
+
*
|
|
1715
|
+
* `engines` is advisory: npm emits `EBADENGINE` and installs anyway unless the
|
|
1716
|
+
* user happens to have `engine-strict` set. For a normal library that is a
|
|
1717
|
+
* reasonable default. For the **signer** it is not — it holds the delegate key
|
|
1718
|
+
* and produces every payment signature, so a subtle runtime incompatibility
|
|
1719
|
+
* shows up as a wrong or missing signature on a money path. "It seemed to work"
|
|
1720
|
+
* is precisely the evidence that cannot be relied on there.
|
|
1721
|
+
*/
|
|
1722
|
+
/**
|
|
1723
|
+
* The minimum supported Node.js version, as `major.minor.patch`.
|
|
1724
|
+
*
|
|
1725
|
+
* MUST equal the `engines.node` floor declared by every published Haven
|
|
1726
|
+
* package. A guard test in each package asserts exactly that against its own
|
|
1727
|
+
* `package.json`, so the two cannot drift again silently.
|
|
1728
|
+
*/
|
|
1729
|
+
declare const HAVEN_MINIMUM_NODE_VERSION = "24.0.0";
|
|
1730
|
+
/**
|
|
1731
|
+
* Compare two Node versions. Negative when `left` is older.
|
|
1732
|
+
*
|
|
1733
|
+
* An unparseable version parses to `0.0.0` and therefore compares as older than
|
|
1734
|
+
* any real floor — fail-closed. A version string Haven cannot read is not
|
|
1735
|
+
* evidence of a supported runtime, and treating it as one would reopen exactly
|
|
1736
|
+
* the hole this module closes.
|
|
1737
|
+
*/
|
|
1738
|
+
declare function compareNodeVersions(left: string, right: string): number;
|
|
1739
|
+
declare function isSupportedNodeVersion(nodeVersion?: string, minimumNodeVersion?: string): boolean;
|
|
1740
|
+
interface UnsupportedNodeVersionMessageOptions {
|
|
1741
|
+
/**
|
|
1742
|
+
* What is being refused, in the user's terms — "Haven setup", "The Haven
|
|
1743
|
+
* signer". Leads the message so the reader knows what just stopped.
|
|
1744
|
+
*/
|
|
1745
|
+
subject: string;
|
|
1746
|
+
nodeVersion?: string;
|
|
1747
|
+
minimumNodeVersion?: string;
|
|
1748
|
+
/** Appended verbatim as the closing line. Used for the re-run instruction. */
|
|
1749
|
+
retryHint?: string;
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* The refusal text.
|
|
1753
|
+
*
|
|
1754
|
+
* Names the detected version, the required version, and **how to fix it** — the
|
|
1755
|
+
* previous message stopped after the two version numbers, which tells a user
|
|
1756
|
+
* they are stuck without telling them how to get unstuck. The version-manager
|
|
1757
|
+
* lines are the fix for nearly everyone; the closing caveat is there because the
|
|
1758
|
+
* runtime that *spawns* the signer is frequently not the shell that was
|
|
1759
|
+
* upgraded, and a desktop app can keep launching the old Node long after
|
|
1760
|
+
* `node -v` in a terminal says otherwise.
|
|
1761
|
+
*/
|
|
1762
|
+
declare function unsupportedNodeVersionMessage(options: UnsupportedNodeVersionMessageOptions): string;
|
|
1763
|
+
|
|
1695
1764
|
/**
|
|
1696
1765
|
* x402 protocol support for the Haven SDK.
|
|
1697
1766
|
*
|
|
@@ -1704,6 +1773,36 @@ declare const SKILL_FOLDER_NAME = "haven-pay";
|
|
|
1704
1773
|
* (see client.ts) since they need API access and signing.
|
|
1705
1774
|
*/
|
|
1706
1775
|
|
|
1776
|
+
/**
|
|
1777
|
+
* Upper bound on the MERCHANT-requested part of the EIP-3009 authorization
|
|
1778
|
+
* window (#715, epic #713). The x402 library sets
|
|
1779
|
+
* `validBefore = now + maxTimeoutSeconds` straight from the MERCHANT's 402
|
|
1780
|
+
* challenge — without a cap, a malicious or sloppy merchant can request a
|
|
1781
|
+
* year-long window and a leaked signed authorization stays spendable that
|
|
1782
|
+
* whole time. 600 s is generous for any facilitator settle (typical is
|
|
1783
|
+
* 30–60 s); we CLAMP rather than reject so payments keep flowing while
|
|
1784
|
+
* exposure stays bounded. `validBefore` is a deadline, not a demand —
|
|
1785
|
+
* settling earlier is always valid.
|
|
1786
|
+
*/
|
|
1787
|
+
declare const X402_MAX_AUTHORIZATION_WINDOW_SECONDS = 600;
|
|
1788
|
+
/**
|
|
1789
|
+
* Forward margin ADDED on top of the (clamped) merchant timeout when the
|
|
1790
|
+
* authorization is actually signed (#1256). The x402 verify rule requires
|
|
1791
|
+
* `validBefore ≥ now + maxTimeoutSeconds` AT THE FACILITATOR — but the
|
|
1792
|
+
* upstream library computes `validBefore = now + maxTimeoutSeconds` at
|
|
1793
|
+
* SIGNING time, leaving zero forward margin. Haven's flow guarantees elapsed
|
|
1794
|
+
* time between the two (the funding UserOp confirms before the merchant
|
|
1795
|
+
* retry, ~1 min plus latency), so every purchase against a merchant whose
|
|
1796
|
+
* `maxTimeoutSeconds` exceeded that latency failed structurally — measured
|
|
1797
|
+
* live on Base mainnet: Anchor requires 300 s, and 226 s remained at verify.
|
|
1798
|
+
*
|
|
1799
|
+
* 300 s covers funding + retry latency with room to spare. The #715 exposure
|
|
1800
|
+
* ceiling becomes clamped-timeout + margin ≤ 900 s total forward — a
|
|
1801
|
+
* deliberate widening from 600 s, recorded on #1256: an authorization that
|
|
1802
|
+
* cannot pass verify protects no one, and 900 s is still bounded by the same
|
|
1803
|
+
* clamp discipline.
|
|
1804
|
+
*/
|
|
1805
|
+
declare const X402_SETTLEMENT_FORWARD_MARGIN_SECONDS = 300;
|
|
1707
1806
|
/**
|
|
1708
1807
|
* Parse an HTTP 402 response into x402 PaymentRequired data.
|
|
1709
1808
|
*
|
|
@@ -1816,4 +1915,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
1816
1915
|
*/
|
|
1817
1916
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
1818
1917
|
|
|
1819
|
-
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type ClaudeTool, HAVEN_SKILL_MD, type HavenAgent, type HavenAgentAllowanceSummary, type HavenAgentReadiness, type HavenAgentSummary, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type MppAuthorizationOptions, type MppQuote, type MppResumeState, type OpenAITool, type PaymentFee, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentReceipt, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PendingApproval, RECEIPT_VERSION, type ReceiptVerification, type ResumeAuthorizedMppInput, type ResumeAuthorizedX402Input, type ResumeMppPaymentInput, type ResumeX402PaymentInput, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, type SweepAuthorization, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type X402AuthorizationOptions, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpTransport, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, isSweepableChain, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, verifyPaymentReceipt, verifySignature, x402AuthorizationAmount };
|
|
1918
|
+
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type ClaudeTool, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_MD, type HavenAgent, type HavenAgentAllowanceSummary, type HavenAgentReadiness, type HavenAgentSummary, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type MppAuthorizationOptions, type MppQuote, type MppResumeState, type OpenAITool, type PaymentFee, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentReceipt, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PendingApproval, RECEIPT_VERSION, type ReceiptVerification, type ResumeAuthorizedMppInput, type ResumeAuthorizedX402Input, type ResumeMppPaymentInput, type ResumeX402PaymentInput, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, type SweepAuthorization, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type UnsupportedNodeVersionMessageOptions, type X402AuthorizationOptions, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpTransport, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, isSupportedNodeVersion, isSweepableChain, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, verifyPaymentReceipt, verifySignature, x402AuthorizationAmount };
|
package/dist/index.js
CHANGED
|
@@ -347,6 +347,7 @@ function optionAuthorizationAmount(option) {
|
|
|
347
347
|
return option.maxAmountRequired ?? option.amount;
|
|
348
348
|
}
|
|
349
349
|
var X402_MAX_AUTHORIZATION_WINDOW_SECONDS = 600;
|
|
350
|
+
var X402_SETTLEMENT_FORWARD_MARGIN_SECONDS = 300;
|
|
350
351
|
function clampAuthorizationWindow(seconds) {
|
|
351
352
|
const requested = typeof seconds === "number" && Number.isFinite(seconds) ? seconds : 30;
|
|
352
353
|
return Math.min(Math.max(Math.floor(requested), 1), X402_MAX_AUTHORIZATION_WINDOW_SECONDS);
|
|
@@ -544,7 +545,12 @@ function toStandardPaymentRequirements(paymentRequired, option) {
|
|
|
544
545
|
// Second enforcement point (#715): the parse path clamps too, but this is
|
|
545
546
|
// the last stop before the x402 library turns the timeout into
|
|
546
547
|
// `validBefore` — options constructed without parsing are bounded here.
|
|
547
|
-
|
|
548
|
+
// The forward margin (#1256) is added ONLY here, at signing: the parse
|
|
549
|
+
// path keeps recording the merchant's advertised timeout unchanged, and
|
|
550
|
+
// the library's `validBefore = now + this value` then carries enough
|
|
551
|
+
// slack to satisfy the facilitator's `validBefore ≥ now + maxTimeout`
|
|
552
|
+
// verify rule after our funding leg confirms.
|
|
553
|
+
maxTimeoutSeconds: clampAuthorizationWindow(option.maxTimeoutSeconds) + X402_SETTLEMENT_FORWARD_MARGIN_SECONDS,
|
|
548
554
|
extra: option.extra
|
|
549
555
|
};
|
|
550
556
|
}
|
|
@@ -3606,6 +3612,45 @@ for that credential.
|
|
|
3606
3612
|
`;
|
|
3607
3613
|
var SKILL_FOLDER_NAME = "haven-pay";
|
|
3608
3614
|
|
|
3615
|
+
// src/node-version.ts
|
|
3616
|
+
var HAVEN_MINIMUM_NODE_VERSION = "24.0.0";
|
|
3617
|
+
function parseNodeVersion(value) {
|
|
3618
|
+
const match = value.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
|
|
3619
|
+
if (!match) return [0, 0, 0];
|
|
3620
|
+
return [Number(match[1] ?? 0), Number(match[2] ?? 0), Number(match[3] ?? 0)];
|
|
3621
|
+
}
|
|
3622
|
+
function compareNodeVersions(left, right) {
|
|
3623
|
+
const leftParts = parseNodeVersion(left);
|
|
3624
|
+
const rightParts = parseNodeVersion(right);
|
|
3625
|
+
for (let i = 0; i < 3; i += 1) {
|
|
3626
|
+
if (leftParts[i] !== rightParts[i]) return leftParts[i] > rightParts[i] ? 1 : -1;
|
|
3627
|
+
}
|
|
3628
|
+
return 0;
|
|
3629
|
+
}
|
|
3630
|
+
function isSupportedNodeVersion(nodeVersion = process.versions.node, minimumNodeVersion = HAVEN_MINIMUM_NODE_VERSION) {
|
|
3631
|
+
return compareNodeVersions(nodeVersion, minimumNodeVersion) >= 0;
|
|
3632
|
+
}
|
|
3633
|
+
function unsupportedNodeVersionMessage(options) {
|
|
3634
|
+
const nodeVersion = options.nodeVersion ?? process.versions.node;
|
|
3635
|
+
const minimum = options.minimumNodeVersion ?? HAVEN_MINIMUM_NODE_VERSION;
|
|
3636
|
+
const lines = [
|
|
3637
|
+
`${options.subject} requires Node.js >=${minimum}, but this is Node.js ${nodeVersion}.`,
|
|
3638
|
+
"",
|
|
3639
|
+
"Upgrade Node, then try again:",
|
|
3640
|
+
` nvm install ${major(minimum)} && nvm use ${major(minimum)} (nvm)`,
|
|
3641
|
+
` fnm install ${major(minimum)} && fnm use ${major(minimum)} (fnm)`,
|
|
3642
|
+
` volta install node@${major(minimum)} (volta)`,
|
|
3643
|
+
` or download Node ${major(minimum)} from https://nodejs.org`,
|
|
3644
|
+
"",
|
|
3645
|
+
"If you use a version manager, check that the agent runtime launching Haven picks up the same version \u2014 upgrading your shell does not always change what a desktop app spawns."
|
|
3646
|
+
];
|
|
3647
|
+
if (options.retryHint) lines.push("", options.retryHint);
|
|
3648
|
+
return lines.join("\n");
|
|
3649
|
+
}
|
|
3650
|
+
function major(version) {
|
|
3651
|
+
return String(parseNodeVersion(version)[0]);
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3609
3654
|
// src/sweep.ts
|
|
3610
3655
|
var SWEEP_BASE_CHAIN_ID = 8453;
|
|
3611
3656
|
var SWEEP_BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
@@ -3711,6 +3756,6 @@ function stableStringify2(value) {
|
|
|
3711
3756
|
return `{${Object.keys(object).sort().map((key) => `${JSON.stringify(key)}:${stableStringify2(object[key])}`).join(",")}}`;
|
|
3712
3757
|
}
|
|
3713
3758
|
|
|
3714
|
-
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, HAVEN_SKILL_MD, HavenApiError, HavenClient, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, RECEIPT_VERSION, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, TRANSFER_WITH_AUTHORIZATION_TYPES, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, isSweepableChain, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, verifyPaymentReceipt, verifySignature, x402AuthorizationAmount };
|
|
3759
|
+
export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_MD, HavenApiError, HavenClient, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, RECEIPT_VERSION, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, TRANSFER_WITH_AUTHORIZATION_TYPES, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, isSupportedNodeVersion, isSweepableChain, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, verifyPaymentReceipt, verifySignature, x402AuthorizationAmount };
|
|
3715
3760
|
//# sourceMappingURL=index.js.map
|
|
3716
3761
|
//# sourceMappingURL=index.js.map
|