@agentspend/sdk 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -4
- package/package.json +1 -1
- package/src/index.ts +5 -4
package/dist/index.js
CHANGED
|
@@ -141,8 +141,9 @@ function createAgentSpend(options) {
|
|
|
141
141
|
return c.json({ error: "Could not determine payment amount from request" }, 400);
|
|
142
142
|
}
|
|
143
143
|
const currency = opts.currency ?? "usd";
|
|
144
|
-
// Step 3: Check for
|
|
145
|
-
|
|
144
|
+
// Step 3: Check for payment header → crypto payment
|
|
145
|
+
// x402 v2 uses "Payment-Signature", v1 uses "X-Payment"
|
|
146
|
+
const paymentHeader = c.req.header("payment-signature") ?? c.req.header("x-payment");
|
|
146
147
|
if (paymentHeader) {
|
|
147
148
|
return handleCryptoPayment(c, next, paymentHeader, effectiveAmount, currency, body, opts);
|
|
148
149
|
}
|
|
@@ -234,7 +235,7 @@ function createAgentSpend(options) {
|
|
|
234
235
|
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
|
|
235
236
|
payTo,
|
|
236
237
|
maxTimeoutSeconds: 300,
|
|
237
|
-
extra: {}
|
|
238
|
+
extra: { name: "USD Coin", version: "2" }
|
|
238
239
|
};
|
|
239
240
|
// Verify payment via facilitator
|
|
240
241
|
const verifyResult = await facilitator.verify(paymentPayload, paymentRequirements);
|
|
@@ -278,7 +279,7 @@ function createAgentSpend(options) {
|
|
|
278
279
|
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
|
|
279
280
|
payTo,
|
|
280
281
|
maxTimeoutSeconds: 300,
|
|
281
|
-
extra: {}
|
|
282
|
+
extra: { name: "USD Coin", version: "2" }
|
|
282
283
|
};
|
|
283
284
|
// Build x402 v2 PaymentRequired response
|
|
284
285
|
const paymentRequired = {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -293,8 +293,9 @@ export function createAgentSpend(options: AgentSpendOptions): AgentSpend {
|
|
|
293
293
|
|
|
294
294
|
const currency = opts.currency ?? "usd";
|
|
295
295
|
|
|
296
|
-
// Step 3: Check for
|
|
297
|
-
|
|
296
|
+
// Step 3: Check for payment header → crypto payment
|
|
297
|
+
// x402 v2 uses "Payment-Signature", v1 uses "X-Payment"
|
|
298
|
+
const paymentHeader = c.req.header("payment-signature") ?? c.req.header("x-payment");
|
|
298
299
|
if (paymentHeader) {
|
|
299
300
|
return handleCryptoPayment(c, next, paymentHeader, effectiveAmount, currency, body, opts);
|
|
300
301
|
}
|
|
@@ -417,7 +418,7 @@ export function createAgentSpend(options: AgentSpendOptions): AgentSpend {
|
|
|
417
418
|
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
|
|
418
419
|
payTo,
|
|
419
420
|
maxTimeoutSeconds: 300,
|
|
420
|
-
extra: {}
|
|
421
|
+
extra: { name: "USD Coin", version: "2" }
|
|
421
422
|
};
|
|
422
423
|
|
|
423
424
|
// Verify payment via facilitator
|
|
@@ -489,7 +490,7 @@ export function createAgentSpend(options: AgentSpendOptions): AgentSpend {
|
|
|
489
490
|
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
|
|
490
491
|
payTo,
|
|
491
492
|
maxTimeoutSeconds: 300,
|
|
492
|
-
extra: {}
|
|
493
|
+
extra: { name: "USD Coin", version: "2" }
|
|
493
494
|
};
|
|
494
495
|
|
|
495
496
|
// Build x402 v2 PaymentRequired response
|