@piprail/sdk 2.14.0 → 2.14.2
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/CHANGELOG.md +65 -0
- package/dist/{algorand-6J3IABVF.js → algorand-CSEUTWNW.js} +1 -1
- package/dist/{algorand-QU6G2DQZ.cjs → algorand-I2O24RSM.cjs} +32 -32
- package/dist/{aptos-LFTQGBBK.cjs → aptos-GA5AEYYL.cjs} +31 -31
- package/dist/{aptos-DHOMTBLZ.js → aptos-J7QGCWNW.js} +1 -1
- package/dist/{chunk-GYM46G5L.cjs → chunk-3FR22M3O.cjs} +35 -20
- package/dist/{chunk-PAMKCWVW.js → chunk-3ZWM3DKM.js} +17 -2
- package/dist/index.cjs +246 -203
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +78 -35
- package/dist/{near-YNNK7RW7.cjs → near-NDQLGI4U.cjs} +27 -27
- package/dist/{near-5PXTVQ47.js → near-YA4Y4IGC.js} +1 -1
- package/dist/{solana-HITVI3HF.js → solana-MB6G3OA5.js} +1 -1
- package/dist/{solana-N3UCNCYE.cjs → solana-OU6IUMQM.cjs} +32 -32
- package/dist/{stellar-Y3SQN7S5.cjs → stellar-RSNVOIKL.cjs} +20 -20
- package/dist/{stellar-2QT6YYKN.js → stellar-WDWSYOED.js} +1 -1
- package/dist/{sui-FV5L6WF5.js → sui-GVSFNNJX.js} +1 -1
- package/dist/{sui-4AL4E6XU.cjs → sui-MVC46BFJ.cjs} +16 -16
- package/dist/{ton-5FWDQ4QR.js → ton-EJMGM3YI.js} +1 -1
- package/dist/{ton-5HDVOTMR.cjs → ton-MYOI3U3H.cjs} +16 -16
- package/dist/{tron-TX2B4N2A.cjs → tron-42X5N4GQ.cjs} +25 -25
- package/dist/{tron-AZDY7BMQ.js → tron-VAPVMGJK.js} +1 -1
- package/dist/{xrpl-5TYDLQFS.cjs → xrpl-MGUBUNSZ.cjs} +20 -20
- package/dist/{xrpl-UJL5J7CY.js → xrpl-Q2UWPCTJ.js} +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -4700,6 +4700,15 @@ declare class SettlementError extends PipRailError {
|
|
|
4700
4700
|
declare class InvalidEnvelopeError extends PipRailError {
|
|
4701
4701
|
readonly code = "INVALID_ENVELOPE";
|
|
4702
4702
|
}
|
|
4703
|
+
/**
|
|
4704
|
+
* A merchant-supplied gate config value is invalid — a non-decimal / scientific-notation /
|
|
4705
|
+
* non-string `amount` (e.g. `'1e3'`, which must NOT be silently read as 1000 tokens), a missing
|
|
4706
|
+
* `payTo`, or a malformed discovery input. A typed boundary error (ERRORS.md §5) so a merchant
|
|
4707
|
+
* gets a clear, catchable failure instead of a raw `viem`/`TypeError`.
|
|
4708
|
+
*/
|
|
4709
|
+
declare class InvalidConfigError extends PipRailError {
|
|
4710
|
+
readonly code = "INVALID_CONFIG";
|
|
4711
|
+
}
|
|
4703
4712
|
/**
|
|
4704
4713
|
* The envelope didn't include any accepts[] entry compatible with the
|
|
4705
4714
|
* client's chain id (or all entries used unsupported schemes).
|
|
@@ -6740,15 +6749,6 @@ declare function buildOpenApi(input: ManifestInput): OpenApiDocument;
|
|
|
6740
6749
|
* `/openapi.json` is the primary doc; this is a compatibility breadcrumb.
|
|
6741
6750
|
*/
|
|
6742
6751
|
declare function buildWellKnownX402(input: ManifestInput): WellKnownX402;
|
|
6743
|
-
/**
|
|
6744
|
-
* Build the official `/.well-known/x402.json` manifest (x402-foundation PR #2646 shape) — a
|
|
6745
|
-
* SECOND, richer discovery file beside the legacy {@link buildWellKnownX402}. Forward-compatible
|
|
6746
|
-
* by design: it emits only the fields the proposal defines, tolerates the spec adding more, and
|
|
6747
|
-
* pins nothing (the PR is explicitly pre-merge), so when #2646 stabilises only this one emitter
|
|
6748
|
-
* (and the docs recommendation) move — no default ever changed. `lastUpdated` defaults to now
|
|
6749
|
-
* (Unix seconds); pass it explicitly for a deterministic file. PURE — no network, no chain
|
|
6750
|
-
* library, fully deterministic given its args. The merchant hosts the result; PipRail serves nothing.
|
|
6751
|
-
*/
|
|
6752
6752
|
declare function buildWellKnownX402Manifest(input: ManifestInput & {
|
|
6753
6753
|
lastUpdated?: number;
|
|
6754
6754
|
}): WellKnownX402Manifest;
|
|
@@ -8396,4 +8396,4 @@ interface McpPaymentTool {
|
|
|
8396
8396
|
*/
|
|
8397
8397
|
declare function createMcpPaymentTool(options: McpPaymentToolOptions): McpPaymentTool;
|
|
8398
8398
|
|
|
8399
|
-
export { type A2AArtifact, type A2AExtensionDeclaration, type A2AMessage, type A2AMetadata, type A2APart, type A2APaymentHandler, type A2APaymentHandlerOptions, type A2APaymentStatus, type A2ATask, type A2ATaskRecord, type A2ATaskState, type A2ATaskStore, A2A_ERROR_KEY, A2A_EXTENSIONS_HEADER, A2A_PAYLOAD_KEY, A2A_RECEIPTS_KEY, A2A_REQUIRED_KEY, A2A_STATUS_KEY, A2A_X402_EXTENSION_URI_V01, A2A_X402_EXTENSION_URI_V02, type AcceptOption, AddressId, type AgentTool, type AlgorandToken, type AptosToken, AssetId, BRAND, BUILTIN_DENOMS, type BazaarExtension, type BuildExactParams, CHAINS, Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ChallengeTriage, type ChallengeVerdict, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type CountStatus, DENOM_PRECISION, DIRECTORY_INFO, type DeclineReasonCode, type DeliverAttempt, type DeliverReceiptOptions, type DeliverResult, type DenomRemaining, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoveryDescriptor, type DiscoverySigner, type DiscoverySort, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, ExactPaymentPayloadAny, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, type FacilitatorSupportedKind, type FailedPayment, GENERATOR, InsufficientFundsError, InvalidEnvelopeError, KNOWN_FACILITATORS, type KnownFacilitator, type ListingVisibility, MCP_PAYMENT_META_KEY, MCP_PAYMENT_RESPONSE_META_KEY, type ManifestInput, MaxRetriesExceededError, type McpContentBlock, type McpPaymentMeta, type McpPaymentTool, type McpPaymentToolOptions, type McpToolCallParams, type McpToolResult, MissingDriverError, MultiChainPayer, type MultiChainPayerOptions, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, PERMIT2_ADDRESS, PERMIT2_PROXY_CHAIN_IDS, PERMIT2_UPTO_WITNESS_TYPES, PERMIT2_WITNESS_TYPES, PIPRAIL_AGENT_GUIDE, POWERED_BY, PaidReceipt, type PayBlocker, type PayOption, type PayWarning, type PayingClient, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, type PaymentScheme, PaymentTimeoutError, Permit2UptoPaymentPayload, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, PipRailReceipt, type PolicyDecision, type PolicyDenyCode, REGISTER_ATTRIBUTION, type ReceiptInput, type ReceiptOption, type ReceiptVerification, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SelfDescribeEndpoint, type SelfDescribeRail, type SelfDescription, type SessionBudget, SettleOutcome, type SettleViaFacilitatorInput, SettlementError, SignedReceipt, type SolanaToken, SpendLedger, SpendRecord, type SpendRemaining, SpendStore, SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UPTO_PROXY_CHAIN_IDS, UnknownTokenError, UnsupportedNetworkError, UnsupportedSchemeError, type UptoRailOption, VERIFY_CODE_TO_A2A_ERROR, VerifyErrorCode, type VerifyPaymentResult, VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, WalletRequiredError, type WellKnownX402, type WellKnownX402Item, type WellKnownX402Manifest, WrongChainError, WrongFamilyError, X402AcceptEntry, X402AnyAccept, X402Challenge, type X402DnsRecord, X402ExactAcceptEntry, type X402InvalidBody, X402Receipt, X402UptoAcceptEntry, X402_EXACT_PERMIT2_PROXY, X402_UPTO_PERMIT2_PROXY, type XrplToken, agentGuide, appendAttribution, appendKeywords, buildBazaarExtension, buildEndpointInfo, buildExactAuthorization, buildMcpPaymentMeta, buildOpenApi, buildSelfDescription, buildWellKnownX402, buildWellKnownX402Manifest, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, classifyChallenge, createA2APaymentHandler, createMcpPaymentTool, createPaymentGate, decorateOutcome, deliverReceipt, denomOf, describeChallenge, discoveryHeaders, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, explainDecline, facilitatorCoverage, fetchAcross, firstKeylessFacilitator, formatSpendReport, fromA2APaymentPayload, fromA2APaymentRequired, fromMcpPayment, fromMcpPaymentRequired, fromMcpPaymentResponse, getDirectoryInfo, isMcpPaymentRequired, isPermit2ProxyChain, isUptoProxyChain, knownFacilitatorsFor, normalizeNetwork, parseExactRequirements, parseFacilitatorSupported, paymentTools, planAcross, rankResources, readExactDomain, register402Index, registerDriver, registerX402Scan, renderLandingPage, requirePayment, resolveChain, scoreResource, searchOpenIndexes, settleViaFacilitator, summarizePlan, toA2AErrorCode, toA2APaymentFailed, toA2APaymentReceipts, toA2APaymentRequired, toInsufficientFundsError, toInvalidBody, toMcpPaymentRequired, toMcpPaymentResponse, verify402IndexDomain };
|
|
8399
|
+
export { type A2AArtifact, type A2AExtensionDeclaration, type A2AMessage, type A2AMetadata, type A2APart, type A2APaymentHandler, type A2APaymentHandlerOptions, type A2APaymentStatus, type A2ATask, type A2ATaskRecord, type A2ATaskState, type A2ATaskStore, A2A_ERROR_KEY, A2A_EXTENSIONS_HEADER, A2A_PAYLOAD_KEY, A2A_RECEIPTS_KEY, A2A_REQUIRED_KEY, A2A_STATUS_KEY, A2A_X402_EXTENSION_URI_V01, A2A_X402_EXTENSION_URI_V02, type AcceptOption, AddressId, type AgentTool, type AlgorandToken, type AptosToken, AssetId, BRAND, BUILTIN_DENOMS, type BazaarExtension, type BuildExactParams, CHAINS, Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ChallengeTriage, type ChallengeVerdict, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type CountStatus, DENOM_PRECISION, DIRECTORY_INFO, type DeclineReasonCode, type DeliverAttempt, type DeliverReceiptOptions, type DeliverResult, type DenomRemaining, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoveryDescriptor, type DiscoverySigner, type DiscoverySort, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, ExactPaymentPayloadAny, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, type FacilitatorSupportedKind, type FailedPayment, GENERATOR, InsufficientFundsError, InvalidConfigError, InvalidEnvelopeError, KNOWN_FACILITATORS, type KnownFacilitator, type ListingVisibility, MCP_PAYMENT_META_KEY, MCP_PAYMENT_RESPONSE_META_KEY, type ManifestInput, MaxRetriesExceededError, type McpContentBlock, type McpPaymentMeta, type McpPaymentTool, type McpPaymentToolOptions, type McpToolCallParams, type McpToolResult, MissingDriverError, MultiChainPayer, type MultiChainPayerOptions, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, PERMIT2_ADDRESS, PERMIT2_PROXY_CHAIN_IDS, PERMIT2_UPTO_WITNESS_TYPES, PERMIT2_WITNESS_TYPES, PIPRAIL_AGENT_GUIDE, POWERED_BY, PaidReceipt, type PayBlocker, type PayOption, type PayWarning, type PayingClient, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, type PaymentScheme, PaymentTimeoutError, Permit2UptoPaymentPayload, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, PipRailReceipt, type PolicyDecision, type PolicyDenyCode, REGISTER_ATTRIBUTION, type ReceiptInput, type ReceiptOption, type ReceiptVerification, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SelfDescribeEndpoint, type SelfDescribeRail, type SelfDescription, type SessionBudget, SettleOutcome, type SettleViaFacilitatorInput, SettlementError, SignedReceipt, type SolanaToken, SpendLedger, SpendRecord, type SpendRemaining, SpendStore, SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UPTO_PROXY_CHAIN_IDS, UnknownTokenError, UnsupportedNetworkError, UnsupportedSchemeError, type UptoRailOption, VERIFY_CODE_TO_A2A_ERROR, VerifyErrorCode, type VerifyPaymentResult, VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, WalletRequiredError, type WellKnownX402, type WellKnownX402Item, type WellKnownX402Manifest, WrongChainError, WrongFamilyError, X402AcceptEntry, X402AnyAccept, X402Challenge, type X402DnsRecord, X402ExactAcceptEntry, type X402InvalidBody, X402Receipt, X402UptoAcceptEntry, X402_EXACT_PERMIT2_PROXY, X402_UPTO_PERMIT2_PROXY, type XrplToken, agentGuide, appendAttribution, appendKeywords, buildBazaarExtension, buildEndpointInfo, buildExactAuthorization, buildMcpPaymentMeta, buildOpenApi, buildSelfDescription, buildWellKnownX402, buildWellKnownX402Manifest, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, classifyChallenge, createA2APaymentHandler, createMcpPaymentTool, createPaymentGate, decorateOutcome, deliverReceipt, denomOf, describeChallenge, discoveryHeaders, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, explainDecline, facilitatorCoverage, fetchAcross, firstKeylessFacilitator, formatSpendReport, fromA2APaymentPayload, fromA2APaymentRequired, fromMcpPayment, fromMcpPaymentRequired, fromMcpPaymentResponse, getDirectoryInfo, isMcpPaymentRequired, isPermit2ProxyChain, isUptoProxyChain, knownFacilitatorsFor, normalizeNetwork, parseExactRequirements, parseFacilitatorSupported, paymentTools, planAcross, rankResources, readExactDomain, register402Index, registerDriver, registerX402Scan, renderLandingPage, requirePayment, resolveChain, scoreResource, searchOpenIndexes, settleViaFacilitator, summarizePlan, toA2AErrorCode, toA2APaymentFailed, toA2APaymentReceipts, toA2APaymentRequired, toInsufficientFundsError, toInvalidBody, toMcpPaymentRequired, toMcpPaymentResponse, verify402IndexDomain };
|
package/dist/index.d.ts
CHANGED
|
@@ -4700,6 +4700,15 @@ declare class SettlementError extends PipRailError {
|
|
|
4700
4700
|
declare class InvalidEnvelopeError extends PipRailError {
|
|
4701
4701
|
readonly code = "INVALID_ENVELOPE";
|
|
4702
4702
|
}
|
|
4703
|
+
/**
|
|
4704
|
+
* A merchant-supplied gate config value is invalid — a non-decimal / scientific-notation /
|
|
4705
|
+
* non-string `amount` (e.g. `'1e3'`, which must NOT be silently read as 1000 tokens), a missing
|
|
4706
|
+
* `payTo`, or a malformed discovery input. A typed boundary error (ERRORS.md §5) so a merchant
|
|
4707
|
+
* gets a clear, catchable failure instead of a raw `viem`/`TypeError`.
|
|
4708
|
+
*/
|
|
4709
|
+
declare class InvalidConfigError extends PipRailError {
|
|
4710
|
+
readonly code = "INVALID_CONFIG";
|
|
4711
|
+
}
|
|
4703
4712
|
/**
|
|
4704
4713
|
* The envelope didn't include any accepts[] entry compatible with the
|
|
4705
4714
|
* client's chain id (or all entries used unsupported schemes).
|
|
@@ -6740,15 +6749,6 @@ declare function buildOpenApi(input: ManifestInput): OpenApiDocument;
|
|
|
6740
6749
|
* `/openapi.json` is the primary doc; this is a compatibility breadcrumb.
|
|
6741
6750
|
*/
|
|
6742
6751
|
declare function buildWellKnownX402(input: ManifestInput): WellKnownX402;
|
|
6743
|
-
/**
|
|
6744
|
-
* Build the official `/.well-known/x402.json` manifest (x402-foundation PR #2646 shape) — a
|
|
6745
|
-
* SECOND, richer discovery file beside the legacy {@link buildWellKnownX402}. Forward-compatible
|
|
6746
|
-
* by design: it emits only the fields the proposal defines, tolerates the spec adding more, and
|
|
6747
|
-
* pins nothing (the PR is explicitly pre-merge), so when #2646 stabilises only this one emitter
|
|
6748
|
-
* (and the docs recommendation) move — no default ever changed. `lastUpdated` defaults to now
|
|
6749
|
-
* (Unix seconds); pass it explicitly for a deterministic file. PURE — no network, no chain
|
|
6750
|
-
* library, fully deterministic given its args. The merchant hosts the result; PipRail serves nothing.
|
|
6751
|
-
*/
|
|
6752
6752
|
declare function buildWellKnownX402Manifest(input: ManifestInput & {
|
|
6753
6753
|
lastUpdated?: number;
|
|
6754
6754
|
}): WellKnownX402Manifest;
|
|
@@ -8396,4 +8396,4 @@ interface McpPaymentTool {
|
|
|
8396
8396
|
*/
|
|
8397
8397
|
declare function createMcpPaymentTool(options: McpPaymentToolOptions): McpPaymentTool;
|
|
8398
8398
|
|
|
8399
|
-
export { type A2AArtifact, type A2AExtensionDeclaration, type A2AMessage, type A2AMetadata, type A2APart, type A2APaymentHandler, type A2APaymentHandlerOptions, type A2APaymentStatus, type A2ATask, type A2ATaskRecord, type A2ATaskState, type A2ATaskStore, A2A_ERROR_KEY, A2A_EXTENSIONS_HEADER, A2A_PAYLOAD_KEY, A2A_RECEIPTS_KEY, A2A_REQUIRED_KEY, A2A_STATUS_KEY, A2A_X402_EXTENSION_URI_V01, A2A_X402_EXTENSION_URI_V02, type AcceptOption, AddressId, type AgentTool, type AlgorandToken, type AptosToken, AssetId, BRAND, BUILTIN_DENOMS, type BazaarExtension, type BuildExactParams, CHAINS, Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ChallengeTriage, type ChallengeVerdict, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type CountStatus, DENOM_PRECISION, DIRECTORY_INFO, type DeclineReasonCode, type DeliverAttempt, type DeliverReceiptOptions, type DeliverResult, type DenomRemaining, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoveryDescriptor, type DiscoverySigner, type DiscoverySort, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, ExactPaymentPayloadAny, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, type FacilitatorSupportedKind, type FailedPayment, GENERATOR, InsufficientFundsError, InvalidEnvelopeError, KNOWN_FACILITATORS, type KnownFacilitator, type ListingVisibility, MCP_PAYMENT_META_KEY, MCP_PAYMENT_RESPONSE_META_KEY, type ManifestInput, MaxRetriesExceededError, type McpContentBlock, type McpPaymentMeta, type McpPaymentTool, type McpPaymentToolOptions, type McpToolCallParams, type McpToolResult, MissingDriverError, MultiChainPayer, type MultiChainPayerOptions, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, PERMIT2_ADDRESS, PERMIT2_PROXY_CHAIN_IDS, PERMIT2_UPTO_WITNESS_TYPES, PERMIT2_WITNESS_TYPES, PIPRAIL_AGENT_GUIDE, POWERED_BY, PaidReceipt, type PayBlocker, type PayOption, type PayWarning, type PayingClient, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, type PaymentScheme, PaymentTimeoutError, Permit2UptoPaymentPayload, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, PipRailReceipt, type PolicyDecision, type PolicyDenyCode, REGISTER_ATTRIBUTION, type ReceiptInput, type ReceiptOption, type ReceiptVerification, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SelfDescribeEndpoint, type SelfDescribeRail, type SelfDescription, type SessionBudget, SettleOutcome, type SettleViaFacilitatorInput, SettlementError, SignedReceipt, type SolanaToken, SpendLedger, SpendRecord, type SpendRemaining, SpendStore, SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UPTO_PROXY_CHAIN_IDS, UnknownTokenError, UnsupportedNetworkError, UnsupportedSchemeError, type UptoRailOption, VERIFY_CODE_TO_A2A_ERROR, VerifyErrorCode, type VerifyPaymentResult, VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, WalletRequiredError, type WellKnownX402, type WellKnownX402Item, type WellKnownX402Manifest, WrongChainError, WrongFamilyError, X402AcceptEntry, X402AnyAccept, X402Challenge, type X402DnsRecord, X402ExactAcceptEntry, type X402InvalidBody, X402Receipt, X402UptoAcceptEntry, X402_EXACT_PERMIT2_PROXY, X402_UPTO_PERMIT2_PROXY, type XrplToken, agentGuide, appendAttribution, appendKeywords, buildBazaarExtension, buildEndpointInfo, buildExactAuthorization, buildMcpPaymentMeta, buildOpenApi, buildSelfDescription, buildWellKnownX402, buildWellKnownX402Manifest, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, classifyChallenge, createA2APaymentHandler, createMcpPaymentTool, createPaymentGate, decorateOutcome, deliverReceipt, denomOf, describeChallenge, discoveryHeaders, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, explainDecline, facilitatorCoverage, fetchAcross, firstKeylessFacilitator, formatSpendReport, fromA2APaymentPayload, fromA2APaymentRequired, fromMcpPayment, fromMcpPaymentRequired, fromMcpPaymentResponse, getDirectoryInfo, isMcpPaymentRequired, isPermit2ProxyChain, isUptoProxyChain, knownFacilitatorsFor, normalizeNetwork, parseExactRequirements, parseFacilitatorSupported, paymentTools, planAcross, rankResources, readExactDomain, register402Index, registerDriver, registerX402Scan, renderLandingPage, requirePayment, resolveChain, scoreResource, searchOpenIndexes, settleViaFacilitator, summarizePlan, toA2AErrorCode, toA2APaymentFailed, toA2APaymentReceipts, toA2APaymentRequired, toInsufficientFundsError, toInvalidBody, toMcpPaymentRequired, toMcpPaymentResponse, verify402IndexDomain };
|
|
8399
|
+
export { type A2AArtifact, type A2AExtensionDeclaration, type A2AMessage, type A2AMetadata, type A2APart, type A2APaymentHandler, type A2APaymentHandlerOptions, type A2APaymentStatus, type A2ATask, type A2ATaskRecord, type A2ATaskState, type A2ATaskStore, A2A_ERROR_KEY, A2A_EXTENSIONS_HEADER, A2A_PAYLOAD_KEY, A2A_RECEIPTS_KEY, A2A_REQUIRED_KEY, A2A_STATUS_KEY, A2A_X402_EXTENSION_URI_V01, A2A_X402_EXTENSION_URI_V02, type AcceptOption, AddressId, type AgentTool, type AlgorandToken, type AptosToken, AssetId, BRAND, BUILTIN_DENOMS, type BazaarExtension, type BuildExactParams, CHAINS, Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ChallengeTriage, type ChallengeVerdict, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type CountStatus, DENOM_PRECISION, DIRECTORY_INFO, type DeclineReasonCode, type DeliverAttempt, type DeliverReceiptOptions, type DeliverResult, type DenomRemaining, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoveryDescriptor, type DiscoverySigner, type DiscoverySort, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, ExactPaymentPayloadAny, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, type FacilitatorSupportedKind, type FailedPayment, GENERATOR, InsufficientFundsError, InvalidConfigError, InvalidEnvelopeError, KNOWN_FACILITATORS, type KnownFacilitator, type ListingVisibility, MCP_PAYMENT_META_KEY, MCP_PAYMENT_RESPONSE_META_KEY, type ManifestInput, MaxRetriesExceededError, type McpContentBlock, type McpPaymentMeta, type McpPaymentTool, type McpPaymentToolOptions, type McpToolCallParams, type McpToolResult, MissingDriverError, MultiChainPayer, type MultiChainPayerOptions, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, PERMIT2_ADDRESS, PERMIT2_PROXY_CHAIN_IDS, PERMIT2_UPTO_WITNESS_TYPES, PERMIT2_WITNESS_TYPES, PIPRAIL_AGENT_GUIDE, POWERED_BY, PaidReceipt, type PayBlocker, type PayOption, type PayWarning, type PayingClient, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, type PaymentScheme, PaymentTimeoutError, Permit2UptoPaymentPayload, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, PipRailReceipt, type PolicyDecision, type PolicyDenyCode, REGISTER_ATTRIBUTION, type ReceiptInput, type ReceiptOption, type ReceiptVerification, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SelfDescribeEndpoint, type SelfDescribeRail, type SelfDescription, type SessionBudget, SettleOutcome, type SettleViaFacilitatorInput, SettlementError, SignedReceipt, type SolanaToken, SpendLedger, SpendRecord, type SpendRemaining, SpendStore, SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UPTO_PROXY_CHAIN_IDS, UnknownTokenError, UnsupportedNetworkError, UnsupportedSchemeError, type UptoRailOption, VERIFY_CODE_TO_A2A_ERROR, VerifyErrorCode, type VerifyPaymentResult, VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, WalletRequiredError, type WellKnownX402, type WellKnownX402Item, type WellKnownX402Manifest, WrongChainError, WrongFamilyError, X402AcceptEntry, X402AnyAccept, X402Challenge, type X402DnsRecord, X402ExactAcceptEntry, type X402InvalidBody, X402Receipt, X402UptoAcceptEntry, X402_EXACT_PERMIT2_PROXY, X402_UPTO_PERMIT2_PROXY, type XrplToken, agentGuide, appendAttribution, appendKeywords, buildBazaarExtension, buildEndpointInfo, buildExactAuthorization, buildMcpPaymentMeta, buildOpenApi, buildSelfDescription, buildWellKnownX402, buildWellKnownX402Manifest, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, classifyChallenge, createA2APaymentHandler, createMcpPaymentTool, createPaymentGate, decorateOutcome, deliverReceipt, denomOf, describeChallenge, discoveryHeaders, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, explainDecline, facilitatorCoverage, fetchAcross, firstKeylessFacilitator, formatSpendReport, fromA2APaymentPayload, fromA2APaymentRequired, fromMcpPayment, fromMcpPaymentRequired, fromMcpPaymentResponse, getDirectoryInfo, isMcpPaymentRequired, isPermit2ProxyChain, isUptoProxyChain, knownFacilitatorsFor, normalizeNetwork, parseExactRequirements, parseFacilitatorSupported, paymentTools, planAcross, rankResources, readExactDomain, register402Index, registerDriver, registerX402Scan, renderLandingPage, requirePayment, resolveChain, scoreResource, searchOpenIndexes, settleViaFacilitator, summarizePlan, toA2AErrorCode, toA2APaymentFailed, toA2APaymentReceipts, toA2APaymentRequired, toInsufficientFundsError, toInvalidBody, toMcpPaymentRequired, toMcpPaymentResponse, verify402IndexDomain };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
ConfirmationTimeoutError,
|
|
9
9
|
InsufficientFundsError,
|
|
10
|
+
InvalidConfigError,
|
|
10
11
|
InvalidEnvelopeError,
|
|
11
12
|
MAX_DECIMALS,
|
|
12
13
|
MaxRetriesExceededError,
|
|
@@ -31,7 +32,7 @@ import {
|
|
|
31
32
|
parseUnits,
|
|
32
33
|
rejectForeignToken,
|
|
33
34
|
toInsufficientFundsError
|
|
34
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-3ZWM3DKM.js";
|
|
35
36
|
|
|
36
37
|
// src/drivers/registry.ts
|
|
37
38
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -2381,7 +2382,7 @@ var loaders = {
|
|
|
2381
2382
|
solana: async () => {
|
|
2382
2383
|
let mod;
|
|
2383
2384
|
try {
|
|
2384
|
-
mod = await import("./solana-
|
|
2385
|
+
mod = await import("./solana-MB6G3OA5.js");
|
|
2385
2386
|
} catch (cause) {
|
|
2386
2387
|
throw new MissingDriverError(
|
|
2387
2388
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
@@ -2393,7 +2394,7 @@ var loaders = {
|
|
|
2393
2394
|
ton: async () => {
|
|
2394
2395
|
let mod;
|
|
2395
2396
|
try {
|
|
2396
|
-
mod = await import("./ton-
|
|
2397
|
+
mod = await import("./ton-EJMGM3YI.js");
|
|
2397
2398
|
} catch (cause) {
|
|
2398
2399
|
throw new MissingDriverError(
|
|
2399
2400
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
@@ -2405,7 +2406,7 @@ var loaders = {
|
|
|
2405
2406
|
stellar: async () => {
|
|
2406
2407
|
let mod;
|
|
2407
2408
|
try {
|
|
2408
|
-
mod = await import("./stellar-
|
|
2409
|
+
mod = await import("./stellar-WDWSYOED.js");
|
|
2409
2410
|
} catch (cause) {
|
|
2410
2411
|
throw new MissingDriverError(
|
|
2411
2412
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
@@ -2417,7 +2418,7 @@ var loaders = {
|
|
|
2417
2418
|
xrpl: async () => {
|
|
2418
2419
|
let mod;
|
|
2419
2420
|
try {
|
|
2420
|
-
mod = await import("./xrpl-
|
|
2421
|
+
mod = await import("./xrpl-Q2UWPCTJ.js");
|
|
2421
2422
|
} catch (cause) {
|
|
2422
2423
|
throw new MissingDriverError(
|
|
2423
2424
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
@@ -2429,7 +2430,7 @@ var loaders = {
|
|
|
2429
2430
|
tron: async () => {
|
|
2430
2431
|
let mod;
|
|
2431
2432
|
try {
|
|
2432
|
-
mod = await import("./tron-
|
|
2433
|
+
mod = await import("./tron-VAPVMGJK.js");
|
|
2433
2434
|
} catch (cause) {
|
|
2434
2435
|
throw new MissingDriverError(
|
|
2435
2436
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
@@ -2441,7 +2442,7 @@ var loaders = {
|
|
|
2441
2442
|
sui: async () => {
|
|
2442
2443
|
let mod;
|
|
2443
2444
|
try {
|
|
2444
|
-
mod = await import("./sui-
|
|
2445
|
+
mod = await import("./sui-GVSFNNJX.js");
|
|
2445
2446
|
} catch (cause) {
|
|
2446
2447
|
throw new MissingDriverError(
|
|
2447
2448
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
@@ -2453,7 +2454,7 @@ var loaders = {
|
|
|
2453
2454
|
near: async () => {
|
|
2454
2455
|
let mod;
|
|
2455
2456
|
try {
|
|
2456
|
-
mod = await import("./near-
|
|
2457
|
+
mod = await import("./near-YA4Y4IGC.js");
|
|
2457
2458
|
} catch (cause) {
|
|
2458
2459
|
throw new MissingDriverError(
|
|
2459
2460
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
@@ -2465,7 +2466,7 @@ var loaders = {
|
|
|
2465
2466
|
aptos: async () => {
|
|
2466
2467
|
let mod;
|
|
2467
2468
|
try {
|
|
2468
|
-
mod = await import("./aptos-
|
|
2469
|
+
mod = await import("./aptos-J7QGCWNW.js");
|
|
2469
2470
|
} catch (cause) {
|
|
2470
2471
|
throw new MissingDriverError(
|
|
2471
2472
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
@@ -2477,7 +2478,7 @@ var loaders = {
|
|
|
2477
2478
|
algorand: async () => {
|
|
2478
2479
|
let mod;
|
|
2479
2480
|
try {
|
|
2480
|
-
mod = await import("./algorand-
|
|
2481
|
+
mod = await import("./algorand-CSEUTWNW.js");
|
|
2481
2482
|
} catch (cause) {
|
|
2482
2483
|
throw new MissingDriverError(
|
|
2483
2484
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
@@ -2510,7 +2511,7 @@ async function resolveNetwork2(opts) {
|
|
|
2510
2511
|
}
|
|
2511
2512
|
|
|
2512
2513
|
// src/indexes.ts
|
|
2513
|
-
var DIRECTORY_INFO = {
|
|
2514
|
+
var DIRECTORY_INFO = Object.freeze({
|
|
2514
2515
|
"402index": {
|
|
2515
2516
|
source: "402index",
|
|
2516
2517
|
review: "probe-sync",
|
|
@@ -2538,7 +2539,7 @@ var DIRECTORY_INFO = {
|
|
|
2538
2539
|
readByDiscover: true,
|
|
2539
2540
|
caveat: "CDP Bazaar has no register endpoint \u2014 it catalogs a resource only when its own facilitator settles a payment. PipRail verifies locally with no facilitator, so a PipRail resource cannot be listed here (you can still READ Bazaar to find others). List on 402 Index or x402scan instead."
|
|
2540
2541
|
}
|
|
2541
|
-
};
|
|
2542
|
+
});
|
|
2542
2543
|
function getDirectoryInfo(source) {
|
|
2543
2544
|
return DIRECTORY_INFO[source];
|
|
2544
2545
|
}
|
|
@@ -5536,16 +5537,20 @@ function formatSpendReport(summary) {
|
|
|
5536
5537
|
return `${perAsset} \u2014 grand total: ${grand}`;
|
|
5537
5538
|
}
|
|
5538
5539
|
function describeChallenge(challenge) {
|
|
5539
|
-
const
|
|
5540
|
-
|
|
5541
|
-
|
|
5540
|
+
const generic = `${BRAND.name} x402 payment endpoint. Pay with @piprail/sdk (${BRAND.sdkInstall}). Docs: ${BRAND.home}.`;
|
|
5541
|
+
try {
|
|
5542
|
+
const accepts = Array.isArray(challenge?.accepts) ? challenge.accepts : [];
|
|
5543
|
+
const first = accepts[0];
|
|
5544
|
+
if (!first) return generic;
|
|
5545
|
+
const extra = first.extra ?? {};
|
|
5546
|
+
const amount = extra.amountFormatted ?? first.amount;
|
|
5547
|
+
const token = extra.symbol ?? first.asset;
|
|
5548
|
+
const hasExact = accepts.some((a) => a?.scheme === "exact");
|
|
5549
|
+
const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
|
|
5550
|
+
return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
|
|
5551
|
+
} catch {
|
|
5552
|
+
return generic;
|
|
5542
5553
|
}
|
|
5543
|
-
const extra = first.extra ?? {};
|
|
5544
|
-
const amount = extra.amountFormatted ?? first.amount;
|
|
5545
|
-
const token = extra.symbol ?? first.asset;
|
|
5546
|
-
const hasExact = challenge.accepts.some((a) => a.scheme === "exact");
|
|
5547
|
-
const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
|
|
5548
|
-
return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
|
|
5549
5554
|
}
|
|
5550
5555
|
|
|
5551
5556
|
// src/agentGuide.ts
|
|
@@ -6035,15 +6040,29 @@ function paymentTools(client) {
|
|
|
6035
6040
|
|
|
6036
6041
|
// src/classify.ts
|
|
6037
6042
|
function classifyChallenge(challenge, opts) {
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6043
|
+
try {
|
|
6044
|
+
const accepts = Array.isArray(challenge?.accepts) ? challenge.accepts : [];
|
|
6045
|
+
const network = opts?.network;
|
|
6046
|
+
const schemes = opts?.schemes ?? [];
|
|
6047
|
+
const offeredSchemes = [
|
|
6048
|
+
...new Set(accepts.map((a) => a?.scheme).filter((s) => s != null))
|
|
6049
|
+
];
|
|
6050
|
+
const offeredNetworks = [...new Set(accepts.map((a) => a?.network).filter((n) => n != null))];
|
|
6051
|
+
const onClientChain = accepts.some((a) => a?.network === network);
|
|
6052
|
+
const payableScheme = accepts.some(
|
|
6053
|
+
(a) => a?.network === network && schemes.includes(a?.scheme)
|
|
6054
|
+
);
|
|
6055
|
+
const verdict = accepts.length === 0 ? "NO_RAIL" : payableScheme ? "PAYABLE_RAIL" : onClientChain ? "UNPAYABLE_SCHEME" : "WRONG_CHAIN";
|
|
6056
|
+
return { onClientChain, payableScheme, offeredSchemes, offeredNetworks, verdict };
|
|
6057
|
+
} catch {
|
|
6058
|
+
return {
|
|
6059
|
+
onClientChain: false,
|
|
6060
|
+
payableScheme: false,
|
|
6061
|
+
offeredSchemes: [],
|
|
6062
|
+
offeredNetworks: [],
|
|
6063
|
+
verdict: "NO_RAIL"
|
|
6064
|
+
};
|
|
6065
|
+
}
|
|
6047
6066
|
}
|
|
6048
6067
|
|
|
6049
6068
|
// src/discovery.ts
|
|
@@ -6090,6 +6109,7 @@ function pathOf(url) {
|
|
|
6090
6109
|
}
|
|
6091
6110
|
}
|
|
6092
6111
|
function buildOpenApi(input) {
|
|
6112
|
+
assertResourceList(input?.resources, "buildOpenApi");
|
|
6093
6113
|
const paths = {};
|
|
6094
6114
|
for (const r of input.resources) {
|
|
6095
6115
|
const path = pathOf(r.url);
|
|
@@ -6119,16 +6139,31 @@ function buildOpenApi(input) {
|
|
|
6119
6139
|
};
|
|
6120
6140
|
}
|
|
6121
6141
|
function buildWellKnownX402(input) {
|
|
6142
|
+
assertResourceList(input?.resources, "buildWellKnownX402");
|
|
6122
6143
|
return {
|
|
6123
6144
|
version: 1,
|
|
6124
6145
|
resources: input.resources.map((r) => r.url),
|
|
6125
6146
|
...input.ownershipProofs && input.ownershipProofs.length > 0 ? { ownershipProofs: input.ownershipProofs } : {}
|
|
6126
6147
|
};
|
|
6127
6148
|
}
|
|
6149
|
+
function assertResourceList(resources, fn) {
|
|
6150
|
+
if (!Array.isArray(resources)) {
|
|
6151
|
+
throw new InvalidConfigError(`${fn}: \`resources\` must be an array of ResourceDescription.`);
|
|
6152
|
+
}
|
|
6153
|
+
resources.forEach((r, i) => {
|
|
6154
|
+
if (r === null || typeof r !== "object" || typeof r.url !== "string") {
|
|
6155
|
+
throw new InvalidConfigError(
|
|
6156
|
+
`${fn}: resources[${i}] must be a ResourceDescription with a string \`url\`.`
|
|
6157
|
+
);
|
|
6158
|
+
}
|
|
6159
|
+
});
|
|
6160
|
+
}
|
|
6128
6161
|
function buildWellKnownX402Manifest(input) {
|
|
6162
|
+
assertResourceList(input?.resources, "buildWellKnownX402Manifest");
|
|
6163
|
+
const lastUpdated = typeof input.lastUpdated === "number" && Number.isFinite(input.lastUpdated) ? input.lastUpdated : Math.floor(Date.now() / 1e3);
|
|
6129
6164
|
return {
|
|
6130
6165
|
x402Version: 2,
|
|
6131
|
-
lastUpdated
|
|
6166
|
+
lastUpdated,
|
|
6132
6167
|
items: input.resources.map((r) => ({
|
|
6133
6168
|
resource: {
|
|
6134
6169
|
url: r.url,
|
|
@@ -6674,18 +6709,25 @@ function toInvalidBody(result) {
|
|
|
6674
6709
|
return { x402Version: 2, status: "invalid", error: result.error, detail: result.detail };
|
|
6675
6710
|
}
|
|
6676
6711
|
function normaliseAccepts(options) {
|
|
6677
|
-
if (options.accept && options.accept.length > 0) {
|
|
6712
|
+
if (Array.isArray(options.accept) && options.accept.length > 0) {
|
|
6678
6713
|
if (options.chain !== void 0 || options.token !== void 0 || options.amount !== void 0) {
|
|
6679
|
-
throw new
|
|
6714
|
+
throw new InvalidConfigError(
|
|
6680
6715
|
"requirePayment: pass EITHER `accept: [...]` (multi-chain) OR `chain`/`token`/`amount` (single) \u2014 not both."
|
|
6681
6716
|
);
|
|
6682
6717
|
}
|
|
6718
|
+
options.accept.forEach((a, i) => {
|
|
6719
|
+
if (a === null || typeof a !== "object") {
|
|
6720
|
+
throw new InvalidConfigError(
|
|
6721
|
+
`requirePayment: accept[${i}] must be { chain, token, amount }, got ${a === null ? "null" : typeof a}.`
|
|
6722
|
+
);
|
|
6723
|
+
}
|
|
6724
|
+
});
|
|
6683
6725
|
return options.accept;
|
|
6684
6726
|
}
|
|
6685
6727
|
if (options.chain !== void 0 && options.token !== void 0 && options.amount !== void 0) {
|
|
6686
6728
|
return [{ chain: options.chain, token: options.token, amount: options.amount }];
|
|
6687
6729
|
}
|
|
6688
|
-
throw new
|
|
6730
|
+
throw new InvalidConfigError(
|
|
6689
6731
|
"requirePayment: provide either { chain, token, amount } or a non-empty `accept: [{ chain, token, amount }, \u2026]`."
|
|
6690
6732
|
);
|
|
6691
6733
|
}
|
|
@@ -6734,7 +6776,7 @@ function createPaymentGate(options) {
|
|
|
6734
6776
|
const net = await resolveNetwork2({ chain: a.chain, rpcUrl: a.rpcUrl ?? options.rpcUrl });
|
|
6735
6777
|
const payTo = a.payTo ?? options.payTo;
|
|
6736
6778
|
if (!payTo) {
|
|
6737
|
-
throw new
|
|
6779
|
+
throw new InvalidConfigError(
|
|
6738
6780
|
`requirePayment: no payTo for chain ${net.network}. Set it on the accept entry or pass a top-level payTo.`
|
|
6739
6781
|
);
|
|
6740
6782
|
}
|
|
@@ -7991,6 +8033,7 @@ export {
|
|
|
7991
8033
|
HEADER_SIGNATURE,
|
|
7992
8034
|
HEADER_SIGNATURE_V1,
|
|
7993
8035
|
InsufficientFundsError,
|
|
8036
|
+
InvalidConfigError,
|
|
7994
8037
|
InvalidEnvelopeError,
|
|
7995
8038
|
KNOWN_FACILITATORS,
|
|
7996
8039
|
MCP_PAYMENT_META_KEY,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
|
|
14
14
|
|
|
15
15
|
// src/drivers/near/index.ts
|
|
16
16
|
var _nearapijs = require('near-api-js');
|
|
@@ -61,18 +61,18 @@ async function payNear(params) {
|
|
|
61
61
|
return res.hash;
|
|
62
62
|
} catch (err) {
|
|
63
63
|
if (isNearRegistrationError(err)) {
|
|
64
|
-
throw new (0,
|
|
64
|
+
throw new (0, _chunk3FR22M3Ocjs.RecipientNotReadyError)(
|
|
65
65
|
`NEAR recipient ${accept.payTo} isn't registered on token ${accept.asset} (NEP-145 storage_deposit) \u2014 register it once (\u22480.00125 NEAR) before it can receive. (NEAR: not registered)`,
|
|
66
66
|
{ cause: err }
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
if (isNearAffordability(err)) {
|
|
70
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
71
71
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
72
72
|
{ cause: err }
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
throw _nullishCoalesce(
|
|
75
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
async function payNearNative(params) {
|
|
@@ -82,12 +82,12 @@ async function payNearNative(params) {
|
|
|
82
82
|
return res.hash;
|
|
83
83
|
} catch (err) {
|
|
84
84
|
if (isNearAffordability(err)) {
|
|
85
|
-
throw new (0,
|
|
85
|
+
throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
86
86
|
err instanceof Error ? err.message : "Insufficient NEAR balance for the payment.",
|
|
87
87
|
{ cause: err }
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
throw _nullishCoalesce(
|
|
90
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function isNearRegistrationError(err) {
|
|
@@ -109,28 +109,28 @@ var NONCE_BLOCK_MULTIPLIER = 1000000n;
|
|
|
109
109
|
async function payExactNear(input) {
|
|
110
110
|
const { signer, senderId, blockHeight, accessKeyNonce, accept } = input;
|
|
111
111
|
if (accept.asset === "native") {
|
|
112
|
-
throw new (0,
|
|
112
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
113
113
|
"NEAR exact is NEP-141-only (an ft_transfer); native NEAR is not exact-payable. Pay via onchain-proof."
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
if (!isValidNearAccountId(accept.asset)) {
|
|
117
|
-
throw new (0,
|
|
117
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(`NEAR exact: asset "${accept.asset}" must be a NEP-141 contract account id.`);
|
|
118
118
|
}
|
|
119
119
|
if (!isValidNearAccountId(accept.payTo)) {
|
|
120
|
-
throw new (0,
|
|
120
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(`NEAR exact: payTo "${accept.payTo}" is not a valid NEAR account id.`);
|
|
121
121
|
}
|
|
122
122
|
if (!isValidNearAccountId(senderId)) {
|
|
123
|
-
throw new (0,
|
|
123
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(`NEAR exact: sender "${senderId}" is not a valid NEAR account id.`);
|
|
124
124
|
}
|
|
125
125
|
const t = accept.maxTimeoutSeconds;
|
|
126
126
|
if (!Number.isInteger(t) || t <= 0) {
|
|
127
|
-
throw new (0,
|
|
127
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)("NEAR exact: maxTimeoutSeconds must be a positive integer.");
|
|
128
128
|
}
|
|
129
129
|
const timeoutBlocks = BigInt(Math.max(1, Math.ceil(t / ESTIMATED_BLOCK_SECONDS)));
|
|
130
130
|
const maxBlockHeight = blockHeight + timeoutBlocks;
|
|
131
131
|
const nonce = accessKeyNonce + 1n;
|
|
132
132
|
if (nonce >= blockHeight * NONCE_BLOCK_MULTIPLIER) {
|
|
133
|
-
throw new (0,
|
|
133
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
134
134
|
"NEAR exact: the access-key nonce is at the protocol ceiling for this block height; cannot build a delegate action."
|
|
135
135
|
);
|
|
136
136
|
}
|
|
@@ -259,7 +259,7 @@ async function verifyAndSettleExactNear(input) {
|
|
|
259
259
|
if (/not enough|insufficient|exceeded the prepaid gas|NotEnoughBalance|doesn't have enough|is not registered/i.test(m)) {
|
|
260
260
|
return fail("tx_reverted", `the ft_transfer would fail on chain: ${shorten(m)}.`);
|
|
261
261
|
}
|
|
262
|
-
throw new (0,
|
|
262
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
263
263
|
`NEAR exact settle: the relayer could not submit the delegate (${shorten(m)}). The buyer's signed delegate is still valid \u2014 fund/fix the relayer and the buyer can re-present it.`,
|
|
264
264
|
{ cause: err }
|
|
265
265
|
);
|
|
@@ -408,13 +408,13 @@ function txNotFound(hash) {
|
|
|
408
408
|
|
|
409
409
|
function assertNearWallet(wallet, network) {
|
|
410
410
|
if (typeof wallet !== "object" || wallet === null) {
|
|
411
|
-
throw new (0,
|
|
411
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
412
412
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
|
-
|
|
415
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "NEAR");
|
|
416
416
|
if (!("accountId" in wallet) || !("key" in wallet)) {
|
|
417
|
-
throw new (0,
|
|
417
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
418
418
|
`chain ${network} is NEAR; wallet must be { accountId, key } (key = ed25519:\u2026).`
|
|
419
419
|
);
|
|
420
420
|
}
|
|
@@ -422,13 +422,13 @@ function assertNearWallet(wallet, network) {
|
|
|
422
422
|
}
|
|
423
423
|
function resolveNearWallet(config) {
|
|
424
424
|
if (!config.accountId || !config.key) {
|
|
425
|
-
throw new (0,
|
|
425
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("NEAR wallet needs { accountId, key } (key = ed25519:\u2026).");
|
|
426
426
|
}
|
|
427
427
|
let signer;
|
|
428
428
|
try {
|
|
429
429
|
signer = _nearapijs.KeyPairSigner.fromSecretKey(config.key);
|
|
430
430
|
} catch (cause) {
|
|
431
|
-
throw new (0,
|
|
431
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)("NEAR wallet { key } is not a valid ed25519:\u2026 secret key.", {
|
|
432
432
|
cause
|
|
433
433
|
});
|
|
434
434
|
}
|
|
@@ -490,16 +490,16 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
490
490
|
const info = preset.tokens[token.toUpperCase()];
|
|
491
491
|
if (!info) {
|
|
492
492
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
493
|
-
throw new (0,
|
|
493
|
+
throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
|
|
494
494
|
`token "${token}" isn't built in for NEAR (known: ${known}). Pass { contractId, decimals } for a custom NEP-141.`
|
|
495
495
|
);
|
|
496
496
|
}
|
|
497
497
|
return { asset: info.contractId, decimals: info.decimals, symbol: info.symbol };
|
|
498
498
|
}
|
|
499
|
-
|
|
499
|
+
_chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "near", network);
|
|
500
500
|
const t = token;
|
|
501
501
|
if (!t.contractId || typeof t.decimals !== "number") {
|
|
502
|
-
throw new (0,
|
|
502
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
503
503
|
`chain ${network} is NEAR; a custom token must be { contractId, decimals }.`
|
|
504
504
|
);
|
|
505
505
|
}
|
|
@@ -518,12 +518,12 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
518
518
|
},
|
|
519
519
|
assertValidPayTo(payTo) {
|
|
520
520
|
if (payTo.startsWith("0x")) {
|
|
521
|
-
throw new (0,
|
|
521
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
522
522
|
`chain ${network} is NEAR, but payTo "${payTo}" looks like an EVM/Sui 0x address.`
|
|
523
523
|
);
|
|
524
524
|
}
|
|
525
525
|
if (!isValidNearAccountId(payTo)) {
|
|
526
|
-
throw new (0,
|
|
526
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
527
527
|
`chain ${network} is NEAR, but payTo "${payTo}" is not a valid NEAR account id.`
|
|
528
528
|
);
|
|
529
529
|
}
|
|
@@ -567,11 +567,11 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
567
567
|
if (tx && tx.success) return { height: "0" };
|
|
568
568
|
} catch (e11) {
|
|
569
569
|
}
|
|
570
|
-
throw new (0,
|
|
570
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(`NEAR tx ${hash} not confirmed in time.`);
|
|
571
571
|
},
|
|
572
572
|
async estimateCost(accept) {
|
|
573
573
|
if (accept.scheme === "exact") {
|
|
574
|
-
return
|
|
574
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
575
575
|
symbol: "NEAR",
|
|
576
576
|
decimals: NEAR_DECIMALS,
|
|
577
577
|
fee: 0n,
|
|
@@ -579,7 +579,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
579
579
|
detail: "gasless \u2014 the relayer prepays gas + the 1 yocto; the buyer pays 0 NEAR"
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
|
-
return
|
|
582
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
583
583
|
symbol: "NEAR",
|
|
584
584
|
decimals: NEAR_DECIMALS,
|
|
585
585
|
fee: 1500000000000000000000n,
|
|
@@ -701,7 +701,7 @@ function makeNearNetwork(preset, rpcUrl) {
|
|
|
701
701
|
try {
|
|
702
702
|
relayerWallet = resolveNearWallet(relayer._native);
|
|
703
703
|
} catch (err) {
|
|
704
|
-
throw new (0,
|
|
704
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
705
705
|
`NEAR exact settle: the relayer wallet is invalid (${err instanceof Error ? err.message : String(err)}).`,
|
|
706
706
|
{ cause: err }
|
|
707
707
|
);
|