@parallel-protocol/x402 0.8.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,65 +1,65 @@
1
1
  'use strict';
2
2
 
3
- var chunkTH77IB3T_cjs = require('./chunk-TH77IB3T.cjs');
3
+ var chunkMYCUOJ3H_cjs = require('./chunk-MYCUOJ3H.cjs');
4
4
  var chunkKZZY5LS6_cjs = require('./chunk-KZZY5LS6.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "FacilitatorClient", {
9
9
  enumerable: true,
10
- get: function () { return chunkTH77IB3T_cjs.FacilitatorClient; }
10
+ get: function () { return chunkMYCUOJ3H_cjs.FacilitatorClient; }
11
11
  });
12
12
  Object.defineProperty(exports, "PARALLEL_TOKENS", {
13
13
  enumerable: true,
14
- get: function () { return chunkTH77IB3T_cjs.PARALLEL_TOKENS; }
14
+ get: function () { return chunkMYCUOJ3H_cjs.PARALLEL_TOKENS; }
15
15
  });
16
16
  Object.defineProperty(exports, "SETTLE_AMOUNT_HEADER", {
17
17
  enumerable: true,
18
- get: function () { return chunkTH77IB3T_cjs.SETTLE_AMOUNT_HEADER; }
18
+ get: function () { return chunkMYCUOJ3H_cjs.SETTLE_AMOUNT_HEADER; }
19
19
  });
20
20
  Object.defineProperty(exports, "createPaymentGate", {
21
21
  enumerable: true,
22
- get: function () { return chunkTH77IB3T_cjs.createPaymentGate; }
22
+ get: function () { return chunkMYCUOJ3H_cjs.createPaymentGate; }
23
23
  });
24
24
  Object.defineProperty(exports, "createPaymentMiddleware", {
25
25
  enumerable: true,
26
- get: function () { return chunkTH77IB3T_cjs.createPaymentMiddleware; }
26
+ get: function () { return chunkMYCUOJ3H_cjs.createPaymentMiddleware; }
27
27
  });
28
28
  Object.defineProperty(exports, "encodeBase64", {
29
29
  enumerable: true,
30
- get: function () { return chunkTH77IB3T_cjs.encodeBase64; }
30
+ get: function () { return chunkMYCUOJ3H_cjs.encodeBase64; }
31
31
  });
32
32
  Object.defineProperty(exports, "getDefaultAcceptedTokens", {
33
33
  enumerable: true,
34
- get: function () { return chunkTH77IB3T_cjs.getDefaultAcceptedTokens; }
34
+ get: function () { return chunkMYCUOJ3H_cjs.getDefaultAcceptedTokens; }
35
35
  });
36
36
  Object.defineProperty(exports, "parsePrice", {
37
37
  enumerable: true,
38
- get: function () { return chunkTH77IB3T_cjs.parsePrice; }
38
+ get: function () { return chunkMYCUOJ3H_cjs.parsePrice; }
39
39
  });
40
40
  Object.defineProperty(exports, "resolveCharge", {
41
41
  enumerable: true,
42
- get: function () { return chunkTH77IB3T_cjs.resolveCharge; }
42
+ get: function () { return chunkMYCUOJ3H_cjs.resolveCharge; }
43
43
  });
44
44
  Object.defineProperty(exports, "resolveSettleAmount", {
45
45
  enumerable: true,
46
- get: function () { return chunkTH77IB3T_cjs.resolveSettleAmount; }
46
+ get: function () { return chunkMYCUOJ3H_cjs.resolveSettleAmount; }
47
47
  });
48
48
  Object.defineProperty(exports, "settleVerified", {
49
49
  enumerable: true,
50
- get: function () { return chunkTH77IB3T_cjs.settleVerified; }
50
+ get: function () { return chunkMYCUOJ3H_cjs.settleVerified; }
51
51
  });
52
52
  Object.defineProperty(exports, "settlementFailureResponse", {
53
53
  enumerable: true,
54
- get: function () { return chunkTH77IB3T_cjs.settlementFailureResponse; }
54
+ get: function () { return chunkMYCUOJ3H_cjs.settlementFailureResponse; }
55
55
  });
56
56
  Object.defineProperty(exports, "toEip155Network", {
57
57
  enumerable: true,
58
- get: function () { return chunkTH77IB3T_cjs.toEip155Network; }
58
+ get: function () { return chunkMYCUOJ3H_cjs.toEip155Network; }
59
59
  });
60
60
  Object.defineProperty(exports, "validateAddress", {
61
61
  enumerable: true,
62
- get: function () { return chunkTH77IB3T_cjs.validateAddress; }
62
+ get: function () { return chunkMYCUOJ3H_cjs.validateAddress; }
63
63
  });
64
64
  Object.defineProperty(exports, "X402ConfigError", {
65
65
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FacilitatorConfig, b as FacilitatorPaymentRequirements, V as VerifyResult, c as FacilitatorSettleOptions, d as FacilitatorResponse, e as PaymentConfirmation, P as PaymentMiddlewareConfig, H as HTTPAdapter, f as PaymentGateResult, M as MiddlewareResult, g as PassResult, h as VerifiedPayment, S as SettleOptions } from './types-BkGQ2lPA.cjs';
2
- export { i as MeterContext, j as MeterFunction, k as PaymentFailure, l as PaymentRequired, m as PaymentRequirements, n as PriceContext, o as PriceFunction, p as ResourceInfo, q as RouteConfig, R as RunHandlerOptions, a as RunHandlerResult } from './types-BkGQ2lPA.cjs';
1
+ import { F as FacilitatorConfig, b as FacilitatorPaymentRequirements, V as VerifyResult, c as FacilitatorSettleOptions, d as FacilitatorResponse, e as PaymentConfirmation, P as PaymentMiddlewareConfig, H as HTTPAdapter, f as PaymentGateResult, M as MiddlewareResult, g as PassResult, h as VerifiedPayment, S as SettleOptions } from './types-BWL9h1eY.cjs';
2
+ export { i as MeterContext, j as MeterFunction, k as PaymentFailure, l as PaymentRequired, m as PaymentRequirements, n as PriceContext, o as PriceFunction, p as ResourceInfo, q as RouteConfig, R as RunHandlerOptions, a as RunHandlerResult } from './types-BWL9h1eY.cjs';
3
3
  import { Address } from 'viem';
4
4
 
5
5
  declare class FacilitatorClient {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FacilitatorConfig, b as FacilitatorPaymentRequirements, V as VerifyResult, c as FacilitatorSettleOptions, d as FacilitatorResponse, e as PaymentConfirmation, P as PaymentMiddlewareConfig, H as HTTPAdapter, f as PaymentGateResult, M as MiddlewareResult, g as PassResult, h as VerifiedPayment, S as SettleOptions } from './types-BkGQ2lPA.js';
2
- export { i as MeterContext, j as MeterFunction, k as PaymentFailure, l as PaymentRequired, m as PaymentRequirements, n as PriceContext, o as PriceFunction, p as ResourceInfo, q as RouteConfig, R as RunHandlerOptions, a as RunHandlerResult } from './types-BkGQ2lPA.js';
1
+ import { F as FacilitatorConfig, b as FacilitatorPaymentRequirements, V as VerifyResult, c as FacilitatorSettleOptions, d as FacilitatorResponse, e as PaymentConfirmation, P as PaymentMiddlewareConfig, H as HTTPAdapter, f as PaymentGateResult, M as MiddlewareResult, g as PassResult, h as VerifiedPayment, S as SettleOptions } from './types-BWL9h1eY.js';
2
+ export { i as MeterContext, j as MeterFunction, k as PaymentFailure, l as PaymentRequired, m as PaymentRequirements, n as PriceContext, o as PriceFunction, p as ResourceInfo, q as RouteConfig, R as RunHandlerOptions, a as RunHandlerResult } from './types-BWL9h1eY.js';
3
3
  import { Address } from 'viem';
4
4
 
5
5
  declare class FacilitatorClient {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { FacilitatorClient, PARALLEL_TOKENS, SETTLE_AMOUNT_HEADER, createPaymentGate, createPaymentMiddleware, encodeBase64, getDefaultAcceptedTokens, parsePrice, resolveCharge, resolveSettleAmount, settleVerified, settlementFailureResponse, toEip155Network, validateAddress } from './chunk-G7HSURPM.js';
1
+ export { FacilitatorClient, PARALLEL_TOKENS, SETTLE_AMOUNT_HEADER, createPaymentGate, createPaymentMiddleware, encodeBase64, getDefaultAcceptedTokens, parsePrice, resolveCharge, resolveSettleAmount, settleVerified, settlementFailureResponse, toEip155Network, validateAddress } from './chunk-VSNDEQGS.js';
2
2
  export { X402ConfigError, X402PriceRejectedError, X402RuntimeError, X402_ERROR_CODES, isPriceRejection } from './chunk-QAECRSWF.js';
package/dist/llm.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as PriceFunction, j as MeterFunction } from './types-BkGQ2lPA.cjs';
1
+ import { o as PriceFunction, j as MeterFunction } from './types-BWL9h1eY.cjs';
2
2
  import 'viem';
3
3
 
4
4
  /**
package/dist/llm.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as PriceFunction, j as MeterFunction } from './types-BkGQ2lPA.js';
1
+ import { o as PriceFunction, j as MeterFunction } from './types-BWL9h1eY.js';
2
2
  import 'viem';
3
3
 
4
4
  /**
package/dist/next.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkTH77IB3T_cjs = require('./chunk-TH77IB3T.cjs');
3
+ var chunkMYCUOJ3H_cjs = require('./chunk-MYCUOJ3H.cjs');
4
4
  require('./chunk-KZZY5LS6.cjs');
5
5
  var server = require('next/server');
6
6
 
@@ -25,7 +25,7 @@ var NextAdapter = class {
25
25
  // Read from a clone: a request body is a stream that can be consumed once,
26
26
  // and the handler still needs the original.
27
27
  async getBody() {
28
- if (!chunkTH77IB3T_cjs.isJsonContentType(this.req.headers.get("content-type") ?? void 0))
28
+ if (!chunkMYCUOJ3H_cjs.isJsonContentType(this.req.headers.get("content-type") ?? void 0))
29
29
  return void 0;
30
30
  try {
31
31
  return await this.req.clone().json();
@@ -43,7 +43,7 @@ function fromResult(result) {
43
43
  });
44
44
  }
45
45
  function withPayment(config, handler) {
46
- const gate = chunkTH77IB3T_cjs.createPaymentGate(config);
46
+ const gate = chunkMYCUOJ3H_cjs.createPaymentGate(config);
47
47
  return async (req) => {
48
48
  const gateResult = await gate(new NextAdapter(req));
49
49
  if (gateResult.type === "pass") {
@@ -52,11 +52,11 @@ function withPayment(config, handler) {
52
52
  if (gateResult.type === "error") return fromResult(gateResult.result);
53
53
  let response;
54
54
  try {
55
- const outcome = await chunkTH77IB3T_cjs.raceTimeout(
55
+ const outcome = await chunkMYCUOJ3H_cjs.raceTimeout(
56
56
  handler(req),
57
57
  gateResult.handlerTimeoutMs
58
58
  );
59
- if (outcome === chunkTH77IB3T_cjs.HANDLER_TIMEOUT) {
59
+ if (outcome === chunkMYCUOJ3H_cjs.HANDLER_TIMEOUT) {
60
60
  return new server.NextResponse(null, { status: 504 });
61
61
  }
62
62
  response = outcome;
@@ -65,10 +65,10 @@ function withPayment(config, handler) {
65
65
  }
66
66
  let raw;
67
67
  if (gateResult.scheme === "upto") {
68
- raw = response.headers.get(chunkTH77IB3T_cjs.SETTLE_AMOUNT_HEADER) ?? void 0;
68
+ raw = response.headers.get(chunkMYCUOJ3H_cjs.SETTLE_AMOUNT_HEADER) ?? void 0;
69
69
  if (raw !== void 0) {
70
70
  const headers = new Headers(response.headers);
71
- headers.delete(chunkTH77IB3T_cjs.SETTLE_AMOUNT_HEADER);
71
+ headers.delete(chunkMYCUOJ3H_cjs.SETTLE_AMOUNT_HEADER);
72
72
  response = new server.NextResponse(response.body, {
73
73
  status: response.status,
74
74
  headers
@@ -79,24 +79,24 @@ function withPayment(config, handler) {
79
79
  let settleOptions;
80
80
  if (gateResult.scheme === "upto") {
81
81
  const handled = response;
82
- const resolved = await chunkTH77IB3T_cjs.resolveCharge(gateResult, raw, {
82
+ const resolved = await chunkMYCUOJ3H_cjs.resolveCharge(gateResult, raw, {
83
83
  status: handled.status,
84
84
  header: (name) => handled.headers.get(name) ?? void 0,
85
85
  // Read from a clone: the body streams once, to the client.
86
- body: () => chunkTH77IB3T_cjs.jsonFromResponse(handled)
86
+ body: () => chunkMYCUOJ3H_cjs.jsonFromResponse(handled)
87
87
  });
88
88
  if (resolved.kind === "invalid") {
89
89
  handled.body?.cancel().catch(() => {
90
90
  });
91
- return fromResult(chunkTH77IB3T_cjs.invalidSettleAmountResponse(resolved.reason));
91
+ return fromResult(chunkMYCUOJ3H_cjs.invalidSettleAmountResponse(resolved.reason));
92
92
  }
93
93
  if (resolved.kind === "skip") return response;
94
94
  settleOptions = { amount: resolved.amount };
95
95
  }
96
- const outcome = await chunkTH77IB3T_cjs.settleVerified(gateResult, settleOptions);
96
+ const outcome = await chunkMYCUOJ3H_cjs.settleVerified(gateResult, settleOptions);
97
97
  if (outcome.settled) {
98
98
  const headers = new Headers(response.headers);
99
- headers.set("payment-response", chunkTH77IB3T_cjs.encodeBase64(outcome.confirmation));
99
+ headers.set("payment-response", chunkMYCUOJ3H_cjs.encodeBase64(outcome.confirmation));
100
100
  headers.set("access-control-expose-headers", "payment-response");
101
101
  return new server.NextResponse(response.body, {
102
102
  status: response.status,
@@ -105,7 +105,7 @@ function withPayment(config, handler) {
105
105
  }
106
106
  response.body?.cancel().catch(() => {
107
107
  });
108
- return fromResult(chunkTH77IB3T_cjs.settlementFailureResponse(outcome));
108
+ return fromResult(chunkMYCUOJ3H_cjs.settlementFailureResponse(outcome));
109
109
  }
110
110
  return response;
111
111
  };
package/dist/next.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { H as HTTPAdapter, P as PaymentMiddlewareConfig } from './types-BkGQ2lPA.cjs';
2
+ import { H as HTTPAdapter, P as PaymentMiddlewareConfig } from './types-BWL9h1eY.cjs';
3
3
  import 'viem';
4
4
 
5
5
  declare class NextAdapter implements HTTPAdapter {
package/dist/next.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { H as HTTPAdapter, P as PaymentMiddlewareConfig } from './types-BkGQ2lPA.js';
2
+ import { H as HTTPAdapter, P as PaymentMiddlewareConfig } from './types-BWL9h1eY.js';
3
3
  import 'viem';
4
4
 
5
5
  declare class NextAdapter implements HTTPAdapter {
package/dist/next.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isJsonContentType, createPaymentGate, raceTimeout, HANDLER_TIMEOUT, SETTLE_AMOUNT_HEADER, resolveCharge, jsonFromResponse, invalidSettleAmountResponse, settleVerified, encodeBase64, settlementFailureResponse } from './chunk-G7HSURPM.js';
1
+ import { isJsonContentType, createPaymentGate, raceTimeout, HANDLER_TIMEOUT, SETTLE_AMOUNT_HEADER, resolveCharge, jsonFromResponse, invalidSettleAmountResponse, settleVerified, encodeBase64, settlementFailureResponse } from './chunk-VSNDEQGS.js';
2
2
  import './chunk-QAECRSWF.js';
3
3
  import { NextResponse } from 'next/server';
4
4
 
@@ -163,11 +163,22 @@ interface PaymentConfirmation {
163
163
  networkId: string;
164
164
  /** Amount actually charged (smallest unit) — metered routes only. */
165
165
  amountSettled?: string;
166
+ /**
167
+ * A standard x402 Permit2 payment: the USDp the merchant received for
168
+ * `amountSettled` (smallest unit), when the facilitator read it from the
169
+ * settlement.
170
+ */
171
+ amountDelivered?: string;
166
172
  /**
167
173
  * Present when the facilitator answered from the outcome an earlier settle
168
174
  * of the same payment recorded: this call broadcast nothing.
169
175
  */
170
176
  alreadySettled?: true;
177
+ transaction?: Address;
178
+ network?: string;
179
+ /** The amount charged, in the smallest unit of the paid token. */
180
+ amount?: string;
181
+ payer?: Address;
171
182
  }
172
183
  interface PaymentFailure {
173
184
  success: false;
@@ -163,11 +163,22 @@ interface PaymentConfirmation {
163
163
  networkId: string;
164
164
  /** Amount actually charged (smallest unit) — metered routes only. */
165
165
  amountSettled?: string;
166
+ /**
167
+ * A standard x402 Permit2 payment: the USDp the merchant received for
168
+ * `amountSettled` (smallest unit), when the facilitator read it from the
169
+ * settlement.
170
+ */
171
+ amountDelivered?: string;
166
172
  /**
167
173
  * Present when the facilitator answered from the outcome an earlier settle
168
174
  * of the same payment recorded: this call broadcast nothing.
169
175
  */
170
176
  alreadySettled?: true;
177
+ transaction?: Address;
178
+ network?: string;
179
+ /** The amount charged, in the smallest unit of the paid token. */
180
+ amount?: string;
181
+ payer?: Address;
171
182
  }
172
183
  interface PaymentFailure {
173
184
  success: false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallel-protocol/x402",
3
- "version": "0.8.3",
3
+ "version": "0.10.0",
4
4
  "description": "Parallel Protocol x402 payment middleware — Express, Next.js, Fastify, Hono",
5
5
  "author": "Parallel Protocol <contact@parallel.best>",
6
6
  "repository": {
@@ -101,7 +101,7 @@
101
101
  "viem": "^2.0.0",
102
102
  "express": "^4.0.0 || ^5.0.0",
103
103
  "next": "^14.0.0 || ^15.0.0",
104
- "fastify": "^4.0.0 || ^5.0.0",
104
+ "fastify": "^5.12.7",
105
105
  "hono": "^4.0.0"
106
106
  },
107
107
  "peerDependenciesMeta": {
@@ -124,7 +124,7 @@
124
124
  "devDependencies": {
125
125
  "@types/express": "^5.0.1",
126
126
  "@types/node": "^22.0.0",
127
- "fastify": "^5.0.0",
127
+ "fastify": "^5.12.7",
128
128
  "hono": "^4.0.0",
129
129
  "next": "^15.0.0",
130
130
  "tsup": "^8.0.0",
@@ -133,7 +133,8 @@
133
133
  "vitest": "^4.0.14"
134
134
  },
135
135
  "dependencies": {
136
- "@parallel-protocol/chains": "^0.5.1",
136
+ "@parallel-protocol/chains": "^0.6.0",
137
+ "@parallel-protocol/payment-core": "^0.3.0",
137
138
  "fastify-plugin": "^6.0.0",
138
139
  "zod": "^4.4.3"
139
140
  },