@parallel-protocol/x402 0.8.0 → 0.8.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/dist/index.d.ts CHANGED
@@ -3,10 +3,15 @@ export { i as MeterContext, j as MeterFunction, k as PaymentFailure, l as Paymen
3
3
  import { Address } from 'viem';
4
4
 
5
5
  declare class FacilitatorClient {
6
- private readonly config;
6
+ private readonly url;
7
+ private readonly apiKey;
7
8
  constructor(config: FacilitatorConfig);
8
9
  verify(paymentHeader: string, paymentRequirements: FacilitatorPaymentRequirements): Promise<VerifyResult>;
9
10
  settle(paymentHeader: string, paymentRequirements: FacilitatorPaymentRequirements, options?: FacilitatorSettleOptions): Promise<FacilitatorResponse>;
11
+ /**
12
+ * @deprecated The Parallel facilitator no longer serves `/x402/pay`, so this
13
+ * call fails with `FACILITATOR_UNAVAILABLE`. Use `verify`, then `settle`.
14
+ */
10
15
  pay(paymentHeader: string): Promise<FacilitatorResponse>;
11
16
  private buildHeaders;
12
17
  }
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-SA5ULSG2.js';
1
+ export { FacilitatorClient, PARALLEL_TOKENS, SETTLE_AMOUNT_HEADER, createPaymentGate, createPaymentMiddleware, encodeBase64, getDefaultAcceptedTokens, parsePrice, resolveCharge, resolveSettleAmount, settleVerified, settlementFailureResponse, toEip155Network, validateAddress } from './chunk-KTBFF5HI.js';
2
2
  export { X402ConfigError, X402PriceRejectedError, X402RuntimeError, X402_ERROR_CODES, isPriceRejection } from './chunk-QAECRSWF.js';
package/dist/next.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkNA7245L5_cjs = require('./chunk-NA7245L5.cjs');
3
+ var chunkMXGS3HMS_cjs = require('./chunk-MXGS3HMS.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 (!chunkNA7245L5_cjs.isJsonContentType(this.req.headers.get("content-type") ?? void 0))
28
+ if (!chunkMXGS3HMS_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 = chunkNA7245L5_cjs.createPaymentGate(config);
46
+ const gate = chunkMXGS3HMS_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 chunkNA7245L5_cjs.raceTimeout(
55
+ const outcome = await chunkMXGS3HMS_cjs.raceTimeout(
56
56
  handler(req),
57
57
  gateResult.handlerTimeoutMs
58
58
  );
59
- if (outcome === chunkNA7245L5_cjs.HANDLER_TIMEOUT) {
59
+ if (outcome === chunkMXGS3HMS_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(chunkNA7245L5_cjs.SETTLE_AMOUNT_HEADER) ?? void 0;
68
+ raw = response.headers.get(chunkMXGS3HMS_cjs.SETTLE_AMOUNT_HEADER) ?? void 0;
69
69
  if (raw !== void 0) {
70
70
  const headers = new Headers(response.headers);
71
- headers.delete(chunkNA7245L5_cjs.SETTLE_AMOUNT_HEADER);
71
+ headers.delete(chunkMXGS3HMS_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 chunkNA7245L5_cjs.resolveCharge(gateResult, raw, {
82
+ const resolved = await chunkMXGS3HMS_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: () => chunkNA7245L5_cjs.jsonFromResponse(handled)
86
+ body: () => chunkMXGS3HMS_cjs.jsonFromResponse(handled)
87
87
  });
88
88
  if (resolved.kind === "invalid") {
89
89
  handled.body?.cancel().catch(() => {
90
90
  });
91
- return fromResult(chunkNA7245L5_cjs.invalidSettleAmountResponse(resolved.reason));
91
+ return fromResult(chunkMXGS3HMS_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 chunkNA7245L5_cjs.settleVerified(gateResult, settleOptions);
96
+ const outcome = await chunkMXGS3HMS_cjs.settleVerified(gateResult, settleOptions);
97
97
  if (outcome.settled) {
98
98
  const headers = new Headers(response.headers);
99
- headers.set("payment-response", chunkNA7245L5_cjs.encodeBase64(outcome.confirmation));
99
+ headers.set("payment-response", chunkMXGS3HMS_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(chunkNA7245L5_cjs.settlementFailureResponse(outcome));
108
+ return fromResult(chunkMXGS3HMS_cjs.settlementFailureResponse(outcome));
109
109
  }
110
110
  return response;
111
111
  };
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-SA5ULSG2.js';
1
+ import { isJsonContentType, createPaymentGate, raceTimeout, HANDLER_TIMEOUT, SETTLE_AMOUNT_HEADER, resolveCharge, jsonFromResponse, invalidSettleAmountResponse, settleVerified, encodeBase64, settlementFailureResponse } from './chunk-KTBFF5HI.js';
2
2
  import './chunk-QAECRSWF.js';
3
3
  import { NextResponse } from 'next/server';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallel-protocol/x402",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Parallel Protocol x402 payment middleware — Express, Next.js, Fastify, Hono",
5
5
  "author": "Parallel Protocol <contact@parallel.best>",
6
6
  "repository": {