@agirails/sdk 3.2.0 → 3.4.1
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/LICENSE +1 -1
- package/README.md +12 -14
- package/dist/ACTPClient.d.ts +8 -11
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +79 -20
- package/dist/ACTPClient.js.map +1 -1
- package/dist/__tests__/helpers/mockX402Server.d.ts +67 -0
- package/dist/__tests__/helpers/mockX402Server.d.ts.map +1 -0
- package/dist/__tests__/helpers/mockX402Server.js +121 -0
- package/dist/__tests__/helpers/mockX402Server.js.map +1 -0
- package/dist/adapters/BaseAdapter.d.ts +7 -1
- package/dist/adapters/BaseAdapter.d.ts.map +1 -1
- package/dist/adapters/BaseAdapter.js +11 -6
- package/dist/adapters/BaseAdapter.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +12 -2
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/StandardAdapter.d.ts.map +1 -1
- package/dist/adapters/StandardAdapter.js +12 -2
- package/dist/adapters/StandardAdapter.js.map +1 -1
- package/dist/adapters/X402Adapter.d.ts +161 -199
- package/dist/adapters/X402Adapter.d.ts.map +1 -1
- package/dist/adapters/X402Adapter.js +603 -414
- package/dist/adapters/X402Adapter.js.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/api/agirailsApp.d.ts +21 -1
- package/dist/api/agirailsApp.d.ts.map +1 -1
- package/dist/api/agirailsApp.js.map +1 -1
- package/dist/builders/CounterAcceptBuilder.d.ts +96 -0
- package/dist/builders/CounterAcceptBuilder.d.ts.map +1 -0
- package/dist/builders/CounterAcceptBuilder.js +226 -0
- package/dist/builders/CounterAcceptBuilder.js.map +1 -0
- package/dist/builders/CounterOfferBuilder.d.ts +143 -0
- package/dist/builders/CounterOfferBuilder.d.ts.map +1 -0
- package/dist/builders/CounterOfferBuilder.js +329 -0
- package/dist/builders/CounterOfferBuilder.js.map +1 -0
- package/dist/builders/DeliveryProofBuilder.d.ts.map +1 -1
- package/dist/builders/DeliveryProofBuilder.js +3 -2
- package/dist/builders/DeliveryProofBuilder.js.map +1 -1
- package/dist/builders/QuoteBuilder.d.ts.map +1 -1
- package/dist/builders/QuoteBuilder.js +8 -3
- package/dist/builders/QuoteBuilder.js.map +1 -1
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +7 -1
- package/dist/builders/index.js.map +1 -1
- package/dist/cli/agirails.js +34 -6
- package/dist/cli/agirails.js.map +1 -1
- package/dist/cli/commands/autopublish.js +9 -1
- package/dist/cli/commands/autopublish.js.map +1 -1
- package/dist/cli/commands/config.js +1 -12
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/deploy-env.js +1 -1
- package/dist/cli/commands/deploy-env.js.map +1 -1
- package/dist/cli/commands/diff.js +38 -4
- package/dist/cli/commands/diff.js.map +1 -1
- package/dist/cli/commands/health.js +24 -6
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +100 -7
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/pay.d.ts.map +1 -1
- package/dist/cli/commands/pay.js +23 -0
- package/dist/cli/commands/pay.js.map +1 -1
- package/dist/cli/commands/publish.d.ts +34 -0
- package/dist/cli/commands/publish.d.ts.map +1 -1
- package/dist/cli/commands/publish.js +266 -83
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/pull.js +3 -1
- package/dist/cli/commands/pull.js.map +1 -1
- package/dist/cli/commands/receipt.d.ts +17 -3
- package/dist/cli/commands/receipt.d.ts.map +1 -1
- package/dist/cli/commands/receipt.js +95 -33
- package/dist/cli/commands/receipt.js.map +1 -1
- package/dist/cli/commands/repair.d.ts +23 -0
- package/dist/cli/commands/repair.d.ts.map +1 -0
- package/dist/cli/commands/repair.js +210 -0
- package/dist/cli/commands/repair.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +38 -0
- package/dist/cli/commands/serve.d.ts.map +1 -0
- package/dist/cli/commands/serve.js +308 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +222 -60
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/tx.js +13 -0
- package/dist/cli/commands/tx.js.map +1 -1
- package/dist/cli/index.js +9 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/receiptUpload.d.ts +52 -0
- package/dist/cli/receiptUpload.d.ts.map +1 -0
- package/dist/cli/receiptUpload.js +134 -0
- package/dist/cli/receiptUpload.js.map +1 -0
- package/dist/cli/utils/banner.d.ts +31 -0
- package/dist/cli/utils/banner.d.ts.map +1 -0
- package/dist/cli/utils/banner.js +92 -0
- package/dist/cli/utils/banner.js.map +1 -0
- package/dist/cli/utils/config.d.ts +0 -2
- package/dist/cli/utils/config.d.ts.map +1 -1
- package/dist/cli/utils/config.js +40 -25
- package/dist/cli/utils/config.js.map +1 -1
- package/dist/cli/utils/output.d.ts +2 -0
- package/dist/cli/utils/output.d.ts.map +1 -1
- package/dist/cli/utils/output.js +7 -1
- package/dist/cli/utils/output.js.map +1 -1
- package/dist/cli/utils/share.d.ts +51 -0
- package/dist/cli/utils/share.d.ts.map +1 -0
- package/dist/cli/utils/share.js +133 -0
- package/dist/cli/utils/share.js.map +1 -0
- package/dist/config/agirailsmd.d.ts.map +1 -1
- package/dist/config/agirailsmd.js +2 -1
- package/dist/config/agirailsmd.js.map +1 -1
- package/dist/config/agirailsmdV4.d.ts +46 -1
- package/dist/config/agirailsmdV4.d.ts.map +1 -1
- package/dist/config/agirailsmdV4.js +65 -8
- package/dist/config/agirailsmdV4.js.map +1 -1
- package/dist/config/defaults.d.ts +12 -2
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +19 -3
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/networks.d.ts +7 -0
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +20 -11
- package/dist/config/networks.js.map +1 -1
- package/dist/config/pendingPublish.d.ts.map +1 -1
- package/dist/config/pendingPublish.js +10 -3
- package/dist/config/pendingPublish.js.map +1 -1
- package/dist/config/publishPipeline.d.ts +23 -1
- package/dist/config/publishPipeline.d.ts.map +1 -1
- package/dist/config/publishPipeline.js +70 -15
- package/dist/config/publishPipeline.js.map +1 -1
- package/dist/config/syncOperations.d.ts.map +1 -1
- package/dist/config/syncOperations.js +4 -2
- package/dist/config/syncOperations.js.map +1 -1
- package/dist/erc8004/ERC8004Bridge.d.ts.map +1 -1
- package/dist/erc8004/ERC8004Bridge.js +0 -1
- package/dist/erc8004/ERC8004Bridge.js.map +1 -1
- package/dist/errors/ACTPError.d.ts +24 -0
- package/dist/errors/ACTPError.d.ts.map +1 -0
- package/dist/errors/ACTPError.js +35 -0
- package/dist/errors/ACTPError.js.map +1 -0
- package/dist/errors/X402Errors.d.ts +106 -0
- package/dist/errors/X402Errors.d.ts.map +1 -0
- package/dist/errors/X402Errors.js +160 -0
- package/dist/errors/X402Errors.js.map +1 -0
- package/dist/errors/index.d.ts +3 -9
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +38 -33
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -3
- package/dist/index.js.map +1 -1
- package/dist/level0/Provider.d.ts +5 -0
- package/dist/level0/Provider.d.ts.map +1 -1
- package/dist/level0/ServiceDirectory.d.ts.map +1 -1
- package/dist/level0/ServiceDirectory.js +3 -2
- package/dist/level0/ServiceDirectory.js.map +1 -1
- package/dist/level0/provide.d.ts.map +1 -1
- package/dist/level0/provide.js +11 -8
- package/dist/level0/provide.js.map +1 -1
- package/dist/level0/request.d.ts.map +1 -1
- package/dist/level0/request.js +14 -6
- package/dist/level0/request.js.map +1 -1
- package/dist/level1/Agent.d.ts +28 -1
- package/dist/level1/Agent.d.ts.map +1 -1
- package/dist/level1/Agent.js +89 -12
- package/dist/level1/Agent.js.map +1 -1
- package/dist/level1/pricing/PriceCalculator.d.ts.map +1 -1
- package/dist/level1/pricing/PriceCalculator.js +4 -12
- package/dist/level1/pricing/PriceCalculator.js.map +1 -1
- package/dist/negotiation/BuyerOrchestrator.d.ts +103 -1
- package/dist/negotiation/BuyerOrchestrator.d.ts.map +1 -1
- package/dist/negotiation/BuyerOrchestrator.js +499 -4
- package/dist/negotiation/BuyerOrchestrator.js.map +1 -1
- package/dist/negotiation/DecisionEngine.d.ts +69 -1
- package/dist/negotiation/DecisionEngine.d.ts.map +1 -1
- package/dist/negotiation/DecisionEngine.js +140 -1
- package/dist/negotiation/DecisionEngine.js.map +1 -1
- package/dist/negotiation/PolicyEngine.d.ts +32 -0
- package/dist/negotiation/PolicyEngine.d.ts.map +1 -1
- package/dist/negotiation/PolicyEngine.js.map +1 -1
- package/dist/negotiation/ProviderOrchestrator.d.ts +108 -0
- package/dist/negotiation/ProviderOrchestrator.d.ts.map +1 -0
- package/dist/negotiation/ProviderOrchestrator.js +136 -0
- package/dist/negotiation/ProviderOrchestrator.js.map +1 -0
- package/dist/negotiation/ProviderPolicy.d.ts +143 -0
- package/dist/negotiation/ProviderPolicy.d.ts.map +1 -0
- package/dist/negotiation/ProviderPolicy.js +207 -0
- package/dist/negotiation/ProviderPolicy.js.map +1 -0
- package/dist/negotiation/index.d.ts +8 -1
- package/dist/negotiation/index.d.ts.map +1 -1
- package/dist/negotiation/index.js +8 -1
- package/dist/negotiation/index.js.map +1 -1
- package/dist/negotiation/verifyQuoteOnChain.d.ts +58 -0
- package/dist/negotiation/verifyQuoteOnChain.d.ts.map +1 -0
- package/dist/negotiation/verifyQuoteOnChain.js +83 -0
- package/dist/negotiation/verifyQuoteOnChain.js.map +1 -0
- package/dist/protocol/ACTPKernel.d.ts +4 -1
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +2 -1
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/protocol/EventMonitor.d.ts +27 -1
- package/dist/protocol/EventMonitor.d.ts.map +1 -1
- package/dist/protocol/EventMonitor.js +11 -9
- package/dist/protocol/EventMonitor.js.map +1 -1
- package/dist/protocol/ProofGenerator.d.ts.map +1 -1
- package/dist/protocol/ProofGenerator.js +3 -2
- package/dist/protocol/ProofGenerator.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts +15 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +42 -6
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/runtime/IACTPRuntime.d.ts +35 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.d.ts +14 -2
- package/dist/runtime/MockRuntime.d.ts.map +1 -1
- package/dist/runtime/MockRuntime.js +55 -22
- package/dist/runtime/MockRuntime.js.map +1 -1
- package/dist/runtime/types/MockState.d.ts +14 -0
- package/dist/runtime/types/MockState.d.ts.map +1 -1
- package/dist/runtime/types/MockState.js.map +1 -1
- package/dist/server/buildX402Server.d.ts +131 -0
- package/dist/server/buildX402Server.d.ts.map +1 -0
- package/dist/server/buildX402Server.js +151 -0
- package/dist/server/buildX402Server.js.map +1 -0
- package/dist/server/index.d.ts +33 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +36 -0
- package/dist/server/index.js.map +1 -0
- package/dist/transport/QuoteChannel.d.ts +201 -0
- package/dist/transport/QuoteChannel.d.ts.map +1 -0
- package/dist/transport/QuoteChannel.js +358 -0
- package/dist/transport/QuoteChannel.js.map +1 -0
- package/dist/types/adapter.d.ts +64 -34
- package/dist/types/adapter.d.ts.map +1 -1
- package/dist/types/adapter.js +6 -1
- package/dist/types/adapter.js.map +1 -1
- package/dist/types/eip712.d.ts +20 -0
- package/dist/types/eip712.d.ts.map +1 -1
- package/dist/types/x402.d.ts +8 -8
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js +4 -6
- package/dist/utils/security.js.map +1 -1
- package/dist/wallet/AutoWalletProvider.d.ts +45 -1
- package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
- package/dist/wallet/AutoWalletProvider.js +154 -1
- package/dist/wallet/AutoWalletProvider.js.map +1 -1
- package/dist/wallet/EOAWalletProvider.d.ts +13 -1
- package/dist/wallet/EOAWalletProvider.d.ts.map +1 -1
- package/dist/wallet/EOAWalletProvider.js +24 -0
- package/dist/wallet/EOAWalletProvider.js.map +1 -1
- package/dist/wallet/IWalletProvider.d.ts +34 -0
- package/dist/wallet/IWalletProvider.d.ts.map +1 -1
- package/dist/wallet/SmartWalletRouter.d.ts.map +1 -1
- package/dist/wallet/SmartWalletRouter.js +3 -1
- package/dist/wallet/SmartWalletRouter.js.map +1 -1
- package/dist/wallet/aa/BundlerClient.js +8 -4
- package/dist/wallet/aa/BundlerClient.js.map +1 -1
- package/dist/wallet/aa/DualNonceManager.d.ts +4 -1
- package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
- package/dist/wallet/aa/DualNonceManager.js +3 -0
- package/dist/wallet/aa/DualNonceManager.js.map +1 -1
- package/dist/wallet/keystore.d.ts.map +1 -1
- package/dist/wallet/keystore.js +6 -4
- package/dist/wallet/keystore.js.map +1 -1
- package/package.json +31 -3
- package/dist/adapters/BeginnerAdapter.d.ts +0 -152
- package/dist/adapters/BeginnerAdapter.d.ts.map +0 -1
- package/dist/adapters/BeginnerAdapter.js +0 -168
- package/dist/adapters/BeginnerAdapter.js.map +0 -1
- package/dist/adapters/IntermediateAdapter.d.ts +0 -211
- package/dist/adapters/IntermediateAdapter.d.ts.map +0 -1
- package/dist/adapters/IntermediateAdapter.js +0 -260
- package/dist/adapters/IntermediateAdapter.js.map +0 -1
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* QuoteChannel — HTTPS transport for AIP-2.1 quote + counter-offer messages.
|
|
4
|
+
*
|
|
5
|
+
* Split into three responsibilities so the SDK is framework-agnostic:
|
|
6
|
+
*
|
|
7
|
+
* 1. `QuoteChannelClient` — sends a signed message to a peer's endpoint.
|
|
8
|
+
* Used by buyers (posting counter-offers to the provider) and by
|
|
9
|
+
* providers (posting quotes to the buyer). Plain fetch + timeout.
|
|
10
|
+
*
|
|
11
|
+
* 2. `QuoteChannelHandler` — framework-agnostic receive-side handler.
|
|
12
|
+
* Callers wire it into whatever HTTP framework they use (Express,
|
|
13
|
+
* Next.js route handler, Fastify, etc). Enforces the security model
|
|
14
|
+
* from AIP-2.1-DRAFT §8:
|
|
15
|
+
* - URL path binding: `/quote-channel/{chainId}/{txId}` must
|
|
16
|
+
* match message.chainId / message.txId (closes T2 + T5).
|
|
17
|
+
* - EIP-712 signature verification (closes "anyone can POST").
|
|
18
|
+
* - TTL + grace window (closes T3).
|
|
19
|
+
* - Nonce LRU dedup (closes T1, idempotent replay).
|
|
20
|
+
* Rate limiting is intentionally out of scope — framework-level
|
|
21
|
+
* concern (Next.js middleware, Express rate-limit, nginx, etc).
|
|
22
|
+
*
|
|
23
|
+
* 3. `DedupStore` — swappable backing for the nonce LRU. In-memory
|
|
24
|
+
* default for single-process use; callers can plug Redis etc. for
|
|
25
|
+
* multi-worker production.
|
|
26
|
+
*
|
|
27
|
+
* @module transport/QuoteChannel
|
|
28
|
+
* @see Protocol/aips/AIP-2.1-DRAFT.md §8 (threat model + mitigations)
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.assertSafePeerUrl = exports.QuoteChannelHandler = exports.QuoteChannelClient = exports.InMemoryDedupStore = exports.DEDUP_TTL_SECONDS = exports.TTL_GRACE_SECONDS = exports.buildChannelPath = void 0;
|
|
32
|
+
const QuoteBuilder_1 = require("../builders/QuoteBuilder");
|
|
33
|
+
const CounterOfferBuilder_1 = require("../builders/CounterOfferBuilder");
|
|
34
|
+
const NonceManager_1 = require("../utils/NonceManager");
|
|
35
|
+
const ethers_1 = require("ethers");
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Constants (exported for tests + callers that want to align)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
/** Path pattern builders use / handlers expect. */
|
|
40
|
+
function buildChannelPath(chainId, txId) {
|
|
41
|
+
return `/quote-channel/${chainId}/${txId}`;
|
|
42
|
+
}
|
|
43
|
+
exports.buildChannelPath = buildChannelPath;
|
|
44
|
+
exports.TTL_GRACE_SECONDS = 30;
|
|
45
|
+
exports.DEDUP_TTL_SECONDS = 90000; // 25h (covers max quote TTL + grace)
|
|
46
|
+
/**
|
|
47
|
+
* Single-process in-memory LRU. Callers replace this in production
|
|
48
|
+
* with a distributed store (Redis SET NX EX, DynamoDB conditional put,
|
|
49
|
+
* Postgres INSERT ... ON CONFLICT DO NOTHING, etc).
|
|
50
|
+
*
|
|
51
|
+
* Atomicity here is free because JavaScript event-loop execution is
|
|
52
|
+
* single-threaded — a `recordOnce` call cannot be interrupted mid-way.
|
|
53
|
+
* Multi-worker deployments MUST use a real distributed store or will
|
|
54
|
+
* see duplicate 'recorded' returns across workers.
|
|
55
|
+
*/
|
|
56
|
+
class InMemoryDedupStore {
|
|
57
|
+
constructor(maxSize = 10000) {
|
|
58
|
+
this.entries = new Map(); // key → expires_at_ms
|
|
59
|
+
this.maxSize = maxSize;
|
|
60
|
+
}
|
|
61
|
+
async recordOnce(key, ttlMs) {
|
|
62
|
+
this.dropExpired();
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
const exp = this.entries.get(key);
|
|
65
|
+
if (exp !== undefined && exp > now) {
|
|
66
|
+
return 'duplicate';
|
|
67
|
+
}
|
|
68
|
+
// Atomic in single-threaded JS — the check above and this set happen
|
|
69
|
+
// without any await in between, so no other task can interleave.
|
|
70
|
+
this.entries.set(key, now + ttlMs);
|
|
71
|
+
// Trim AFTER the set so `size <= maxSize` is an invariant. Trimming
|
|
72
|
+
// before the set would still leave the map at maxSize+1 after set.
|
|
73
|
+
this.trimToSize();
|
|
74
|
+
return 'recorded';
|
|
75
|
+
}
|
|
76
|
+
/** Drop entries whose TTL has elapsed. O(n) — fine for our sizes. */
|
|
77
|
+
dropExpired() {
|
|
78
|
+
const now = Date.now();
|
|
79
|
+
for (const [k, exp] of this.entries) {
|
|
80
|
+
if (exp <= now)
|
|
81
|
+
this.entries.delete(k);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Bound the map at `maxSize` by evicting oldest-inserted keys. */
|
|
85
|
+
trimToSize() {
|
|
86
|
+
while (this.entries.size > this.maxSize) {
|
|
87
|
+
const firstKey = this.entries.keys().next().value;
|
|
88
|
+
if (firstKey === undefined)
|
|
89
|
+
break;
|
|
90
|
+
this.entries.delete(firstKey);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.InMemoryDedupStore = InMemoryDedupStore;
|
|
95
|
+
class QuoteChannelClient {
|
|
96
|
+
constructor(cfg = {}) {
|
|
97
|
+
this.timeoutMs = cfg.timeoutMs ?? 10000;
|
|
98
|
+
this.fetchImpl = cfg.fetchImpl ?? fetch;
|
|
99
|
+
this.allowInsecureTargets = cfg.allowInsecureTargets ?? false;
|
|
100
|
+
}
|
|
101
|
+
/** POST a provider quote to the buyer's endpoint. */
|
|
102
|
+
async sendQuote(peerEndpoint, quote) {
|
|
103
|
+
await this.post(peerEndpoint, quote.chainId, quote.txId, {
|
|
104
|
+
type: 'agirails.quote.v1',
|
|
105
|
+
message: quote,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/** POST a buyer counter-offer to the provider's endpoint. */
|
|
109
|
+
async sendCounter(peerEndpoint, counter) {
|
|
110
|
+
await this.post(peerEndpoint, counter.chainId, counter.txId, {
|
|
111
|
+
type: 'agirails.counteroffer.v1',
|
|
112
|
+
message: counter,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async post(peerEndpoint, chainId, txId, payload) {
|
|
116
|
+
const url = `${stripTrailingSlash(peerEndpoint)}${buildChannelPath(chainId, txId)}`;
|
|
117
|
+
// SSRF guard. Peer endpoints come from on-chain AgentRegistry / the
|
|
118
|
+
// agirails.app DB — both technically writable by an adversary. A
|
|
119
|
+
// malicious endpoint pointing at http://169.254.169.254/ (AWS metadata),
|
|
120
|
+
// http://localhost:8080 (internal service), or http://10.x.x.x (RFC1918
|
|
121
|
+
// internal) would have the client leak signed payloads inside the
|
|
122
|
+
// deployer's infrastructure. Fail fast in `new URL()` + string checks.
|
|
123
|
+
assertSafePeerUrl(url, this.allowInsecureTargets);
|
|
124
|
+
const controller = new AbortController();
|
|
125
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
126
|
+
try {
|
|
127
|
+
const res = await this.fetchImpl(url, {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
headers: { 'Content-Type': 'application/json' },
|
|
130
|
+
body: JSON.stringify(payload),
|
|
131
|
+
signal: controller.signal,
|
|
132
|
+
});
|
|
133
|
+
if (!res.ok) {
|
|
134
|
+
const text = await res.text().catch(() => '');
|
|
135
|
+
throw new Error(`Quote channel POST failed: ${res.status} ${res.statusText}${text ? ` — ${text}` : ''}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.QuoteChannelClient = QuoteChannelClient;
|
|
144
|
+
class QuoteChannelHandler {
|
|
145
|
+
constructor(cfg) {
|
|
146
|
+
this.kernelAddressByChainId = cfg.kernelAddressByChainId;
|
|
147
|
+
this.dedupStore = cfg.dedupStore ?? new InMemoryDedupStore();
|
|
148
|
+
this.ttlGraceSeconds = cfg.ttlGraceSeconds ?? exports.TTL_GRACE_SECONDS;
|
|
149
|
+
const throwawayWallet = ethers_1.Wallet.createRandom();
|
|
150
|
+
const throwawayNonces = new NonceManager_1.InMemoryNonceManager();
|
|
151
|
+
this.quoteVerifier = new QuoteBuilder_1.QuoteBuilder(throwawayWallet, throwawayNonces);
|
|
152
|
+
this.counterVerifier = new CounterOfferBuilder_1.CounterOfferBuilder(throwawayWallet, throwawayNonces);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Validate + dedup an incoming POST.
|
|
156
|
+
* Caller is responsible for: parsing URL path into `pathChainId` /
|
|
157
|
+
* `pathTxId`, parsing request body into `ChannelPayload`, and rate
|
|
158
|
+
* limiting the endpoint at the framework level.
|
|
159
|
+
*/
|
|
160
|
+
async handle(payload, ctx) {
|
|
161
|
+
// 1. Shape check on the payload wrapper.
|
|
162
|
+
if (!isChannelPayload(payload)) {
|
|
163
|
+
return {
|
|
164
|
+
status: 400,
|
|
165
|
+
body: { accepted: false, reason: 'Invalid payload shape' },
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
// 2. Path binding — the URL path chainId/txId MUST match the inner message.
|
|
169
|
+
if (payload.message.chainId !== ctx.pathChainId) {
|
|
170
|
+
return {
|
|
171
|
+
status: 400,
|
|
172
|
+
body: { accepted: false, reason: 'chainId mismatch between URL and message' },
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (payload.message.txId.toLowerCase() !== ctx.pathTxId.toLowerCase()) {
|
|
176
|
+
return {
|
|
177
|
+
status: 400,
|
|
178
|
+
body: { accepted: false, reason: 'txId mismatch between URL and message' },
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// 3. Kernel address must be configured for this chain.
|
|
182
|
+
const kernelAddress = this.kernelAddressByChainId[payload.message.chainId];
|
|
183
|
+
if (!kernelAddress) {
|
|
184
|
+
return {
|
|
185
|
+
status: 400,
|
|
186
|
+
body: { accepted: false, reason: `Unsupported chainId: ${payload.message.chainId}` },
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// 4. TTL + grace. Check expiry BEFORE signature to fast-reject stale traffic
|
|
190
|
+
// cheaply; signature verification is the expensive step.
|
|
191
|
+
const now = Math.floor(Date.now() / 1000);
|
|
192
|
+
if (payload.message.expiresAt + this.ttlGraceSeconds < now) {
|
|
193
|
+
return {
|
|
194
|
+
status: 410,
|
|
195
|
+
body: { accepted: false, reason: 'Message expired' },
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// 5. Signature verification + business rules (delegated to the builder).
|
|
199
|
+
try {
|
|
200
|
+
if (payload.type === 'agirails.quote.v1') {
|
|
201
|
+
await this.quoteVerifier.verify(payload.message, kernelAddress);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
await this.counterVerifier.verify(payload.message, kernelAddress);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
209
|
+
// Signature failures vs schema/band failures are both client errors;
|
|
210
|
+
// distinguish with 401 (auth) vs 422 (validation) for better diagnostics.
|
|
211
|
+
const isAuth = /signature|Invalid signature|recovered/i.test(reason);
|
|
212
|
+
return {
|
|
213
|
+
status: isAuth ? 401 : 422,
|
|
214
|
+
body: { accepted: false, reason },
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
// 6. Dedup via nonce LRU. Key is (type, signerDID, nonce) — uniquely
|
|
218
|
+
// identifies a signed message within its issuing agent's nonce space.
|
|
219
|
+
// Single atomic recordOnce() call (not check-then-record) so concurrent
|
|
220
|
+
// workers competing on the same key see exactly one 'recorded'; the
|
|
221
|
+
// rest see 'duplicate' and return the idempotent cached response.
|
|
222
|
+
const signerDID = payload.type === 'agirails.quote.v1'
|
|
223
|
+
? payload.message.provider
|
|
224
|
+
: payload.message.consumer;
|
|
225
|
+
const dedupKey = `${payload.type}:${signerDID}:${payload.message.nonce}`;
|
|
226
|
+
const outcome = await this.dedupStore.recordOnce(dedupKey, exports.DEDUP_TTL_SECONDS * 1000);
|
|
227
|
+
if (outcome === 'duplicate') {
|
|
228
|
+
return { status: 200, body: { accepted: true, duplicate: true } };
|
|
229
|
+
}
|
|
230
|
+
return { status: 201, body: { accepted: true, duplicate: false } };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.QuoteChannelHandler = QuoteChannelHandler;
|
|
234
|
+
// ============================================================================
|
|
235
|
+
// Helpers
|
|
236
|
+
// ============================================================================
|
|
237
|
+
function stripTrailingSlash(url) {
|
|
238
|
+
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Reject peer URLs that could SSRF into local / internal infrastructure.
|
|
242
|
+
*
|
|
243
|
+
* Rules (default, `allowInsecureTargets=false`):
|
|
244
|
+
* - scheme MUST be https
|
|
245
|
+
* - hostname MUST NOT be `localhost`
|
|
246
|
+
* - hostname MUST NOT be a literal loopback IP (127.x.x.x, ::1)
|
|
247
|
+
* - hostname MUST NOT be a literal link-local IP (169.254.x.x, fe80::/10)
|
|
248
|
+
* — this also covers AWS metadata at 169.254.169.254
|
|
249
|
+
* - hostname MUST NOT be a literal RFC1918 private IP (10.x, 172.16-31.x,
|
|
250
|
+
* 192.168.x) or IPv6 ULA (fc00::/7)
|
|
251
|
+
*
|
|
252
|
+
* Dev mode (`allowInsecureTargets=true`): no restrictions, callers
|
|
253
|
+
* opting in are responsible for their own network security.
|
|
254
|
+
*
|
|
255
|
+
* @throws Error if the URL fails the checks. Error message is deliberately
|
|
256
|
+
* specific so test fixtures and diagnostics can assert on it.
|
|
257
|
+
* @internal Exported for unit tests.
|
|
258
|
+
*/
|
|
259
|
+
function assertSafePeerUrl(url, allowInsecureTargets) {
|
|
260
|
+
let parsed;
|
|
261
|
+
try {
|
|
262
|
+
parsed = new URL(url);
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
throw new Error(`Invalid peer URL: ${url}`);
|
|
266
|
+
}
|
|
267
|
+
if (allowInsecureTargets)
|
|
268
|
+
return;
|
|
269
|
+
if (parsed.protocol !== 'https:') {
|
|
270
|
+
throw new Error(`Peer URL must use https:// (got ${parsed.protocol}//). ` +
|
|
271
|
+
`Set allowInsecureTargets=true on the QuoteChannelClient for dev/test only.`);
|
|
272
|
+
}
|
|
273
|
+
// Node's URL() keeps brackets around IPv6 hosts. Strip them so the
|
|
274
|
+
// downstream string checks work uniformly for IPv4 and IPv6 literals.
|
|
275
|
+
const rawHost = parsed.hostname.toLowerCase();
|
|
276
|
+
const stripped = rawHost.startsWith('[') && rawHost.endsWith(']')
|
|
277
|
+
? rawHost.slice(1, -1)
|
|
278
|
+
: rawHost;
|
|
279
|
+
// IPv4-mapped IPv6 — the OS resolves this to the corresponding IPv4
|
|
280
|
+
// address, so the same loopback / RFC1918 / link-local rules MUST apply.
|
|
281
|
+
// Two normalized shapes can come out of Node's URL():
|
|
282
|
+
// 1. dotted-quad: `::ffff:127.0.0.1` (rare, some Node versions)
|
|
283
|
+
// 2. hex pair: `::ffff:7f00:1` (Node default — folds the v4 octets)
|
|
284
|
+
// Without this re-extraction, an attacker crafts `[::ffff:127.0.0.1]`
|
|
285
|
+
// or `[::ffff:169.254.169.254]` and bypasses the IPv4 checks below
|
|
286
|
+
// (which only match dotted-quad).
|
|
287
|
+
let host = stripped;
|
|
288
|
+
const mappedDotted = stripped.match(/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
289
|
+
const mappedHex = stripped.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);
|
|
290
|
+
if (mappedDotted) {
|
|
291
|
+
host = mappedDotted[1];
|
|
292
|
+
}
|
|
293
|
+
else if (mappedHex) {
|
|
294
|
+
const hi = parseInt(mappedHex[1], 16);
|
|
295
|
+
const lo = parseInt(mappedHex[2], 16);
|
|
296
|
+
host = `${(hi >> 8) & 0xff}.${hi & 0xff}.${(lo >> 8) & 0xff}.${lo & 0xff}`;
|
|
297
|
+
}
|
|
298
|
+
if (host === 'localhost' || host.endsWith('.localhost')) {
|
|
299
|
+
throw new Error(`Peer URL points at localhost (${host}) — refusing (SSRF guard)`);
|
|
300
|
+
}
|
|
301
|
+
// IPv4 literals
|
|
302
|
+
const ipv4 = host.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
303
|
+
if (ipv4) {
|
|
304
|
+
const [, a, b] = ipv4.map(Number);
|
|
305
|
+
if (a === 127) {
|
|
306
|
+
throw new Error(`Peer URL points at loopback IP (${host}) — refusing (SSRF guard)`);
|
|
307
|
+
}
|
|
308
|
+
if (a === 169 && b === 254) {
|
|
309
|
+
throw new Error(`Peer URL points at link-local / cloud-metadata IP (${host}) — refusing (SSRF guard)`);
|
|
310
|
+
}
|
|
311
|
+
if (a === 10) {
|
|
312
|
+
throw new Error(`Peer URL points at RFC1918 10.x.x.x (${host}) — refusing (SSRF guard)`);
|
|
313
|
+
}
|
|
314
|
+
if (a === 192 && b === 168) {
|
|
315
|
+
throw new Error(`Peer URL points at RFC1918 192.168.x.x (${host}) — refusing (SSRF guard)`);
|
|
316
|
+
}
|
|
317
|
+
if (a === 172 && b >= 16 && b <= 31) {
|
|
318
|
+
throw new Error(`Peer URL points at RFC1918 172.16-31.x (${host}) — refusing (SSRF guard)`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// IPv6 literals — URL() wraps with brackets; the hostname getter strips them.
|
|
322
|
+
if (host === '::1') {
|
|
323
|
+
throw new Error(`Peer URL points at IPv6 loopback (${host}) — refusing (SSRF guard)`);
|
|
324
|
+
}
|
|
325
|
+
if (host.startsWith('fe80:') || host.startsWith('fe80::')) {
|
|
326
|
+
throw new Error(`Peer URL points at IPv6 link-local (${host}) — refusing (SSRF guard)`);
|
|
327
|
+
}
|
|
328
|
+
// IPv6 ULA fc00::/7 → high byte starts with 0xfc or 0xfd.
|
|
329
|
+
if (host.startsWith('fc') || host.startsWith('fd')) {
|
|
330
|
+
// Narrow to the fc00::/7 pattern: fc?? or fd?? as the first group.
|
|
331
|
+
if (/^(fc|fd)[0-9a-f]{0,2}:/.test(host)) {
|
|
332
|
+
throw new Error(`Peer URL points at IPv6 ULA (${host}) — refusing (SSRF guard)`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
exports.assertSafePeerUrl = assertSafePeerUrl;
|
|
337
|
+
function isChannelPayload(x) {
|
|
338
|
+
if (!x || typeof x !== 'object')
|
|
339
|
+
return false;
|
|
340
|
+
const p = x;
|
|
341
|
+
if (p.type !== 'agirails.quote.v1' && p.type !== 'agirails.counteroffer.v1')
|
|
342
|
+
return false;
|
|
343
|
+
if (!p.message || typeof p.message !== 'object')
|
|
344
|
+
return false;
|
|
345
|
+
const msg = p.message;
|
|
346
|
+
if (typeof msg.chainId !== 'number')
|
|
347
|
+
return false;
|
|
348
|
+
if (typeof msg.txId !== 'string')
|
|
349
|
+
return false;
|
|
350
|
+
if (typeof msg.nonce !== 'number')
|
|
351
|
+
return false;
|
|
352
|
+
if (typeof msg.expiresAt !== 'number')
|
|
353
|
+
return false;
|
|
354
|
+
if (typeof msg.signature !== 'string')
|
|
355
|
+
return false;
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=QuoteChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuoteChannel.js","sourceRoot":"","sources":["../../src/transport/QuoteChannel.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAEH,2DAAsE;AACtE,yEAA2F;AAC3F,wDAA6D;AAC7D,mCAAgC;AAEhC,+EAA+E;AAC/E,8DAA8D;AAC9D,+EAA+E;AAE/E,mDAAmD;AACnD,SAAgB,gBAAgB,CAAC,OAAe,EAAE,IAAY;IAC5D,OAAO,kBAAkB,OAAO,IAAI,IAAI,EAAE,CAAC;AAC7C,CAAC;AAFD,4CAEC;AAEY,QAAA,iBAAiB,GAAG,EAAE,CAAC;AACvB,QAA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AAK,CAAC;IACpD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/types/adapter.d.ts
CHANGED
|
@@ -55,8 +55,8 @@ export declare const AdapterMetadataSchema: z.ZodObject<{
|
|
|
55
55
|
settlementMode: z.ZodEnum<["explicit", "timed", "atomic"]>;
|
|
56
56
|
priority: z.ZodNumber;
|
|
57
57
|
}, "strip", z.ZodTypeAny, {
|
|
58
|
-
id: string;
|
|
59
58
|
name: string;
|
|
59
|
+
id: string;
|
|
60
60
|
usesEscrow: boolean;
|
|
61
61
|
supportsDisputes: boolean;
|
|
62
62
|
requiresIdentity: boolean;
|
|
@@ -64,8 +64,8 @@ export declare const AdapterMetadataSchema: z.ZodObject<{
|
|
|
64
64
|
priority: number;
|
|
65
65
|
supportedIdentityTypes?: string[] | undefined;
|
|
66
66
|
}, {
|
|
67
|
-
id: string;
|
|
68
67
|
name: string;
|
|
68
|
+
id: string;
|
|
69
69
|
usesEscrow: boolean;
|
|
70
70
|
supportsDisputes: boolean;
|
|
71
71
|
requiresIdentity: boolean;
|
|
@@ -102,11 +102,11 @@ export declare const PaymentIdentitySchema: z.ZodObject<{
|
|
|
102
102
|
type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
|
|
103
103
|
value: z.ZodString;
|
|
104
104
|
}, "strip", z.ZodTypeAny, {
|
|
105
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
106
105
|
value: string;
|
|
106
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
107
107
|
}, {
|
|
108
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
109
108
|
value: string;
|
|
109
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
110
110
|
}>;
|
|
111
111
|
/**
|
|
112
112
|
* Zod schema for PaymentMetadata runtime validation.
|
|
@@ -119,11 +119,11 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
|
|
|
119
119
|
type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
|
|
120
120
|
value: z.ZodString;
|
|
121
121
|
}, "strip", z.ZodTypeAny, {
|
|
122
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
123
122
|
value: string;
|
|
123
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
124
124
|
}, {
|
|
125
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
126
125
|
value: string;
|
|
126
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
127
127
|
}>>;
|
|
128
128
|
paymentMethod: z.ZodOptional<z.ZodEnum<["x402", "actp", "auto"]>>;
|
|
129
129
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -131,8 +131,8 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
|
|
|
131
131
|
requiresEscrow?: boolean | undefined;
|
|
132
132
|
requiresDispute?: boolean | undefined;
|
|
133
133
|
identity?: {
|
|
134
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
135
134
|
value: string;
|
|
135
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
136
136
|
} | undefined;
|
|
137
137
|
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
138
138
|
}, {
|
|
@@ -140,8 +140,8 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
|
|
|
140
140
|
requiresEscrow?: boolean | undefined;
|
|
141
141
|
requiresDispute?: boolean | undefined;
|
|
142
142
|
identity?: {
|
|
143
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
144
143
|
value: string;
|
|
144
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
145
145
|
} | undefined;
|
|
146
146
|
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
147
147
|
}>;
|
|
@@ -151,8 +151,15 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
|
|
|
151
151
|
export interface UnifiedPayParams {
|
|
152
152
|
/** Recipient - address, HTTP endpoint, or ERC-8004 agent ID */
|
|
153
153
|
to: string;
|
|
154
|
-
/**
|
|
155
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Amount in human-readable format.
|
|
156
|
+
*
|
|
157
|
+
* - REQUIRED for ACTP adapters (basic, standard) — client sets the price
|
|
158
|
+
* - OPTIONAL for x402 URL targets — amount comes from the server's
|
|
159
|
+
* payment-required response; this field is ignored. The x402 adapter
|
|
160
|
+
* enforces its own per-tx safety cap via `X402AdapterConfig.maxAmountPerTx`.
|
|
161
|
+
*/
|
|
162
|
+
amount?: string | number;
|
|
156
163
|
/** Deadline (relative like '+24h' or unix timestamp) */
|
|
157
164
|
deadline?: string | number;
|
|
158
165
|
/** Dispute window in seconds (min 3600, max 30 days) */
|
|
@@ -167,13 +174,22 @@ export interface UnifiedPayParams {
|
|
|
167
174
|
* Used for reputation reporting after settlement.
|
|
168
175
|
*/
|
|
169
176
|
erc8004AgentId?: string;
|
|
177
|
+
/**
|
|
178
|
+
* HTTP method for x402 paid requests. Ignored by ACTP adapters.
|
|
179
|
+
* Default: 'GET'.
|
|
180
|
+
*/
|
|
181
|
+
httpMethod?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
182
|
+
/** HTTP body for x402 paid requests (POST/PUT/PATCH). Ignored by ACTP adapters. */
|
|
183
|
+
httpBody?: string | Uint8Array;
|
|
184
|
+
/** Extra HTTP headers for x402 paid requests. Ignored by ACTP adapters. */
|
|
185
|
+
httpHeaders?: Record<string, string>;
|
|
170
186
|
}
|
|
171
187
|
/**
|
|
172
188
|
* Zod schema for UnifiedPayParams with strict validation.
|
|
173
189
|
*/
|
|
174
190
|
export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
175
191
|
to: z.ZodString;
|
|
176
|
-
amount: z.ZodUnion<[z.ZodString, z.ZodNumber]
|
|
192
|
+
amount: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
177
193
|
deadline: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
178
194
|
disputeWindow: z.ZodOptional<z.ZodNumber>;
|
|
179
195
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -185,11 +201,11 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
|
185
201
|
type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
|
|
186
202
|
value: z.ZodString;
|
|
187
203
|
}, "strip", z.ZodTypeAny, {
|
|
188
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
189
204
|
value: string;
|
|
205
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
190
206
|
}, {
|
|
191
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
192
207
|
value: string;
|
|
208
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
193
209
|
}>>;
|
|
194
210
|
paymentMethod: z.ZodOptional<z.ZodEnum<["x402", "actp", "auto"]>>;
|
|
195
211
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -197,8 +213,8 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
|
197
213
|
requiresEscrow?: boolean | undefined;
|
|
198
214
|
requiresDispute?: boolean | undefined;
|
|
199
215
|
identity?: {
|
|
200
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
201
216
|
value: string;
|
|
217
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
202
218
|
} | undefined;
|
|
203
219
|
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
204
220
|
}, {
|
|
@@ -206,15 +222,18 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
|
206
222
|
requiresEscrow?: boolean | undefined;
|
|
207
223
|
requiresDispute?: boolean | undefined;
|
|
208
224
|
identity?: {
|
|
209
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
210
225
|
value: string;
|
|
226
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
211
227
|
} | undefined;
|
|
212
228
|
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
213
229
|
}>>;
|
|
214
230
|
erc8004AgentId: z.ZodOptional<z.ZodString>;
|
|
231
|
+
httpMethod: z.ZodOptional<z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>>;
|
|
232
|
+
httpBody: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>>;
|
|
233
|
+
httpHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
215
234
|
}, "strip", z.ZodTypeAny, {
|
|
216
|
-
amount: string | number;
|
|
217
235
|
to: string;
|
|
236
|
+
amount?: string | number | undefined;
|
|
218
237
|
deadline?: string | number | undefined;
|
|
219
238
|
disputeWindow?: number | undefined;
|
|
220
239
|
description?: string | undefined;
|
|
@@ -223,15 +242,18 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
|
223
242
|
requiresEscrow?: boolean | undefined;
|
|
224
243
|
requiresDispute?: boolean | undefined;
|
|
225
244
|
identity?: {
|
|
226
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
227
245
|
value: string;
|
|
246
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
228
247
|
} | undefined;
|
|
229
248
|
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
230
249
|
} | undefined;
|
|
231
250
|
erc8004AgentId?: string | undefined;
|
|
251
|
+
httpMethod?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
252
|
+
httpBody?: string | Uint8Array | undefined;
|
|
253
|
+
httpHeaders?: Record<string, string> | undefined;
|
|
232
254
|
}, {
|
|
233
|
-
amount: string | number;
|
|
234
255
|
to: string;
|
|
256
|
+
amount?: string | number | undefined;
|
|
235
257
|
deadline?: string | number | undefined;
|
|
236
258
|
disputeWindow?: number | undefined;
|
|
237
259
|
description?: string | undefined;
|
|
@@ -240,12 +262,15 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
|
|
|
240
262
|
requiresEscrow?: boolean | undefined;
|
|
241
263
|
requiresDispute?: boolean | undefined;
|
|
242
264
|
identity?: {
|
|
243
|
-
type: "address" | "erc8004" | "did" | "ens";
|
|
244
265
|
value: string;
|
|
266
|
+
type: "did" | "address" | "erc8004" | "ens";
|
|
245
267
|
} | undefined;
|
|
246
268
|
paymentMethod?: "x402" | "actp" | "auto" | undefined;
|
|
247
269
|
} | undefined;
|
|
248
270
|
erc8004AgentId?: string | undefined;
|
|
271
|
+
httpMethod?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | undefined;
|
|
272
|
+
httpBody?: string | Uint8Array | undefined;
|
|
273
|
+
httpHeaders?: Record<string, string> | undefined;
|
|
249
274
|
}>;
|
|
250
275
|
/**
|
|
251
276
|
* Transaction state after payment initiation.
|
|
@@ -257,11 +282,13 @@ export type InitialTransactionState = 'COMMITTED' | 'IN_PROGRESS';
|
|
|
257
282
|
/**
|
|
258
283
|
* Unified payment result returned by all adapters.
|
|
259
284
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
285
|
+
* For escrow adapters (basic/standard), success=true means payment initiated
|
|
286
|
+
* and caller must later call releaseEscrow() after delivery verification.
|
|
287
|
+
* For atomic adapters (x402), success=true means settlement is final and
|
|
288
|
+
* releaseRequired=false.
|
|
262
289
|
*/
|
|
263
290
|
export interface UnifiedPayResult {
|
|
264
|
-
/** ACTP transaction
|
|
291
|
+
/** Transaction identifier (ACTP txId or x402 settlement transaction hash) */
|
|
265
292
|
txId: string;
|
|
266
293
|
/** Escrow ID (for release) - null for non-escrow adapters */
|
|
267
294
|
escrowId: string | null;
|
|
@@ -296,8 +323,11 @@ export interface UnifiedPayResult {
|
|
|
296
323
|
*/
|
|
297
324
|
erc8004AgentId?: string;
|
|
298
325
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
326
|
+
* @deprecated Legacy from the pre-v2 x402 flow routed through the
|
|
327
|
+
* on-chain X402Relay fee-splitting contract. The current X402Adapter
|
|
328
|
+
* (SDK 3.3.0+) pays seller directly with zero AGIRAILS fee, so this
|
|
329
|
+
* field is never populated on the x402 path. Retained for API
|
|
330
|
+
* back-compat; removal scheduled for the next breaking SDK major.
|
|
301
331
|
*/
|
|
302
332
|
feeBreakdown?: X402FeeBreakdown;
|
|
303
333
|
}
|
|
@@ -339,18 +369,18 @@ export declare const UnifiedPayResultSchema: z.ZodObject<{
|
|
|
339
369
|
}>>;
|
|
340
370
|
}, "strip", z.ZodTypeAny, {
|
|
341
371
|
txId: string;
|
|
342
|
-
|
|
343
|
-
provider: string;
|
|
372
|
+
escrowId: string | null;
|
|
344
373
|
amount: string;
|
|
374
|
+
success: boolean;
|
|
345
375
|
deadline: string;
|
|
346
|
-
|
|
376
|
+
provider: string;
|
|
347
377
|
adapter: string;
|
|
348
378
|
state: "COMMITTED" | "IN_PROGRESS";
|
|
349
|
-
success: boolean;
|
|
350
379
|
releaseRequired: boolean;
|
|
351
|
-
|
|
380
|
+
requester: string;
|
|
352
381
|
error?: string | undefined;
|
|
353
382
|
erc8004AgentId?: string | undefined;
|
|
383
|
+
response?: any;
|
|
354
384
|
feeBreakdown?: {
|
|
355
385
|
grossAmount: string;
|
|
356
386
|
providerNet: string;
|
|
@@ -360,18 +390,18 @@ export declare const UnifiedPayResultSchema: z.ZodObject<{
|
|
|
360
390
|
} | undefined;
|
|
361
391
|
}, {
|
|
362
392
|
txId: string;
|
|
363
|
-
|
|
364
|
-
provider: string;
|
|
393
|
+
escrowId: string | null;
|
|
365
394
|
amount: string;
|
|
395
|
+
success: boolean;
|
|
366
396
|
deadline: string;
|
|
367
|
-
|
|
397
|
+
provider: string;
|
|
368
398
|
adapter: string;
|
|
369
399
|
state: "COMMITTED" | "IN_PROGRESS";
|
|
370
|
-
success: boolean;
|
|
371
400
|
releaseRequired: boolean;
|
|
372
|
-
|
|
401
|
+
requester: string;
|
|
373
402
|
error?: string | undefined;
|
|
374
403
|
erc8004AgentId?: string | undefined;
|
|
404
|
+
response?: any;
|
|
375
405
|
feeBreakdown?: {
|
|
376
406
|
grossAmount: string;
|
|
377
407
|
providerNet: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/types/adapter.ts"],"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