@agentbadge/circle-payments 0.1.14 → 0.1.16

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.
@@ -25,6 +25,8 @@ export interface RequirePaymentOptions extends PaymentRouterConfig {
25
25
  payment?: PaymentInfo;
26
26
  error?: string;
27
27
  }) => Promise<void> | void;
28
+ legacyHeader?: boolean;
29
+ extraRequirements?: Record<string, unknown>;
28
30
  }
29
31
  export interface PaymentInfo {
30
32
  payer?: string;
@@ -72,8 +72,20 @@ export function requirePayment(price, opts) {
72
72
  return c.json({ error: "Invalid price" }, 402);
73
73
  }
74
74
  }
75
- const accepts = router.acceptsFor(amount);
76
- const signatureHeader = c.req.header("payment-signature");
75
+ const accepts = opts.extraRequirements
76
+ ? router.acceptsFor(amount).map((a) => ({
77
+ ...a,
78
+ extra: { ...a.extra, ...opts.extraRequirements },
79
+ }))
80
+ : router.acceptsFor(amount);
81
+ let signatureHeader = c.req.header("payment-signature");
82
+ if (!signatureHeader && opts.legacyHeader) {
83
+ const v1 = c.req.header("x-payment");
84
+ if (v1) {
85
+ console.warn(`[x402] deprecated X-PAYMENT header used on ${c.req.path} — migrate to payment-signature`);
86
+ signatureHeader = v1;
87
+ }
88
+ }
77
89
  if (!signatureHeader) {
78
90
  return paymentRequired(c, accepts, opts);
79
91
  }
package/dist/router.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface RouterFlags {
11
11
  }
12
12
  export interface RouterConfig extends RouterFlags {
13
13
  sellerAddress: string;
14
+ railPayTo?: Partial<Record<"gateway" | "exact" | "arcSelfSettle", string>>;
14
15
  gatewayChains?: SupportedChain[];
15
16
  exactChains?: SupportedChain[];
16
17
  arcChain?: SupportedChain;
package/dist/router.js CHANGED
@@ -17,17 +17,17 @@ export function buildAccepts(amount, config) {
17
17
  for (const chain of chains) {
18
18
  if (chain === ARC_TESTNET && !arcOn)
19
19
  continue;
20
- accepts.push(buildGatewayRequirements(chain, amount, config.sellerAddress));
20
+ accepts.push(buildGatewayRequirements(chain, amount, config.railPayTo?.gateway ?? config.sellerAddress));
21
21
  }
22
22
  }
23
23
  if (exactOn) {
24
24
  const chains = config.exactChains ?? [BASE_SEPOLIA];
25
25
  for (const chain of chains) {
26
- accepts.push(buildExactRequirements(chain, amount, config.sellerAddress));
26
+ accepts.push(buildExactRequirements(chain, amount, config.railPayTo?.exact ?? config.sellerAddress));
27
27
  }
28
28
  }
29
29
  if (arcOn) {
30
- accepts.push(buildArcSelfSettleRequirements(config.arcChain ?? ARC_TESTNET, amount, config.sellerAddress));
30
+ accepts.push(buildArcSelfSettleRequirements(config.arcChain ?? ARC_TESTNET, amount, config.railPayTo?.arcSelfSettle ?? config.sellerAddress));
31
31
  }
32
32
  return accepts;
33
33
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentbadge/circle-payments",
3
- "version": "0.1.14",
4
- "description": "Circle Gateway nanopayments + x402 payment rails (Base Sepolia, Arc) for AgentBadge — trusted agent payments",
3
+ "version": "0.1.16",
4
+ "description": "Circle Gateway nanopayments + x402 payment rails (Base Sepolia, Arc) for AgentBadge \u2014 trusted agent payments",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",