@peaje/next 0.2.0 → 0.2.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/README.md CHANGED
@@ -31,7 +31,7 @@ export default withPeaje(nextConfig, { slug: 'cafe-andino' })
31
31
 
32
32
  `withPeaje` prepends the Peaje rules to `rewrites().beforeFiles` and keeps what you had: an array becomes `afterFiles`, an object keeps its `beforeFiles`, `afterFiles` and `fallback`. It accepts sync or async `rewrites()` and a config written as a function `(phase, { defaultConfig }) => config`. Wrapping twice does not duplicate rules.
33
33
 
34
- Options: `slug` (required, the one from your Peaje dashboard) and `gateway` (defaults to `https://peaje-gateway.up.railway.app`, overridable with the `PEAJE_GATEWAY_URL` environment variable).
34
+ Options: `slug` (required, the one from your Peaje dashboard) and `gateway` (defaults to `https://api.usepeaje.com`, overridable with the `PEAJE_GATEWAY_URL` environment variable).
35
35
 
36
36
  ## 1b. Runtime proxy (priced API routes on your domain)
37
37
 
@@ -101,17 +101,35 @@ function iguales(a, b) {
101
101
  }
102
102
  function coincidePatron(patron, pathname) {
103
103
  const p = patron.split("/").filter(Boolean);
104
- const parts = pathname.split("/").filter(Boolean);
104
+ const parts = segmentosCanonicos(pathname);
105
105
  for (let i = 0; i < p.length; i++) {
106
106
  const seg = p[i];
107
107
  if (seg === "*") return true;
108
108
  const v = parts[i];
109
109
  if (v === void 0) return false;
110
110
  if (seg.startsWith(":")) continue;
111
- if (seg !== v) return false;
111
+ if (seg.toLowerCase() !== v.toLowerCase()) return false;
112
112
  }
113
113
  return p.length === parts.length;
114
114
  }
115
+ function segmentosCanonicos(pathname) {
116
+ const out = [];
117
+ for (const crudo of pathname.split(/[\\/]+/)) {
118
+ if (!crudo) continue;
119
+ let seg = crudo;
120
+ try {
121
+ seg = decodeURIComponent(crudo);
122
+ } catch {
123
+ }
124
+ for (const s of seg.split(/[\\/]+/)) {
125
+ if (!s || s === ".") continue;
126
+ if (s === "..") out.pop();
127
+ else out.push(s);
128
+ }
129
+ }
130
+ return out;
131
+ }
132
+ var pathCanonico = (pathname) => `/${segmentosCanonicos(pathname).join("/")}`;
115
133
  function patronReenviable(patron) {
116
134
  const segs = patron.split("/").filter(Boolean);
117
135
  if (segs.length === 0) return false;
@@ -171,9 +189,10 @@ function crearProxyRuntime(opciones) {
171
189
  if (secreto && prueba && iguales(prueba, secreto)) return null;
172
190
  const { rutas, prefijos, patrones } = await listas();
173
191
  const path = input.pathname;
192
+ const canon = pathCanonico(path).toLowerCase();
174
193
  const esFetchDePeaje = input.headers.get(PEAJE_FETCH_HEADER) !== null;
175
- const fija = rutas.includes(path) && !(path === "/llms.txt" && esFetchDePeaje);
176
- const prefijo = prefijos.some((p) => path.startsWith(p));
194
+ const fija = (rutas.includes(path) || rutas.some((r) => r.toLowerCase() === canon)) && !(canon === "/llms.txt" && esFetchDePeaje);
195
+ const prefijo = prefijos.some((p) => path.startsWith(p) || canon.startsWith(p.toLowerCase()));
177
196
  const method = input.method.toUpperCase();
178
197
  const patron = secreto !== null && patrones.some((p) => p.method.toUpperCase() === method && patronReenviable(p.path) && coincidePatron(p.path, path));
179
198
  if (!fija && !prefijo && !patron) return null;
@@ -201,32 +220,6 @@ var TOKENS = {
201
220
  };
202
221
  var DEFAULT_CURRENCY = TOKENS.pathUsd;
203
222
  var NETWORKS = {
204
- tempo: {
205
- id: "tempo",
206
- label: "Tempo",
207
- token: TOKENS.pathUsd,
208
- tokenSymbol: "pathUSD",
209
- decimals: 6,
210
- mainnet: TEMPO.mainnet,
211
- testnet: TEMPO.testnet
212
- },
213
- arc: {
214
- id: "arc",
215
- label: "Arc",
216
- // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
217
- token: "0x3600000000000000000000000000000000000000",
218
- tokenSymbol: "USDC",
219
- decimals: 6,
220
- // Leído on-chain del contrato: name() = "USDC", version() = "2".
221
- eip3009: { name: "USDC", version: "2" },
222
- // Arc no publica direcciones de mainnet todavía (sept 2026).
223
- mainnet: null,
224
- testnet: {
225
- chainId: 5042002,
226
- rpcUrl: "https://rpc.testnet.arc.io",
227
- explorerUrl: "https://testnet.arcscan.app"
228
- }
229
- },
230
223
  arbitrum: {
231
224
  id: "arbitrum",
232
225
  label: "Arbitrum",
@@ -275,6 +268,32 @@ var NETWORKS = {
275
268
  rpcUrl: "https://rpc.testnet.chain.robinhood.com",
276
269
  explorerUrl: "https://explorer.testnet.chain.robinhood.com"
277
270
  }
271
+ },
272
+ tempo: {
273
+ id: "tempo",
274
+ label: "Tempo",
275
+ token: TOKENS.pathUsd,
276
+ tokenSymbol: "pathUSD",
277
+ decimals: 6,
278
+ mainnet: TEMPO.mainnet,
279
+ testnet: TEMPO.testnet
280
+ },
281
+ arc: {
282
+ id: "arc",
283
+ label: "Arc",
284
+ // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
285
+ token: "0x3600000000000000000000000000000000000000",
286
+ tokenSymbol: "USDC",
287
+ decimals: 6,
288
+ // Leído on-chain del contrato: name() = "USDC", version() = "2".
289
+ eip3009: { name: "USDC", version: "2" },
290
+ // Arc no publica direcciones de mainnet todavía (sept 2026).
291
+ mainnet: null,
292
+ testnet: {
293
+ chainId: 5042002,
294
+ rpcUrl: "https://rpc.testnet.arc.io",
295
+ explorerUrl: "https://testnet.arcscan.app"
296
+ }
278
297
  }
279
298
  };
280
299
  var NETWORK_IDS = Object.keys(NETWORKS);
@@ -310,7 +329,7 @@ var GATEWAY_RAILS = {
310
329
  var GATEWAY_RAIL_IDS = Object.keys(GATEWAY_RAILS);
311
330
 
312
331
  // src/index.ts
313
- var GATEWAY_POR_DEFECTO = "https://peaje-gateway.up.railway.app";
332
+ var GATEWAY_POR_DEFECTO = "https://api.usepeaje.com";
314
333
  function baseDe({ slug, gateway }) {
315
334
  const raiz = (gateway ?? process.env.PEAJE_GATEWAY_URL ?? GATEWAY_POR_DEFECTO).replace(/\/+$/, "");
316
335
  return `${raiz}/${slug}`;
package/dist/head.cjs CHANGED
@@ -109,32 +109,6 @@ var TOKENS = {
109
109
  };
110
110
  var DEFAULT_CURRENCY = TOKENS.pathUsd;
111
111
  var NETWORKS = {
112
- tempo: {
113
- id: "tempo",
114
- label: "Tempo",
115
- token: TOKENS.pathUsd,
116
- tokenSymbol: "pathUSD",
117
- decimals: 6,
118
- mainnet: TEMPO.mainnet,
119
- testnet: TEMPO.testnet
120
- },
121
- arc: {
122
- id: "arc",
123
- label: "Arc",
124
- // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
125
- token: "0x3600000000000000000000000000000000000000",
126
- tokenSymbol: "USDC",
127
- decimals: 6,
128
- // Leído on-chain del contrato: name() = "USDC", version() = "2".
129
- eip3009: { name: "USDC", version: "2" },
130
- // Arc no publica direcciones de mainnet todavía (sept 2026).
131
- mainnet: null,
132
- testnet: {
133
- chainId: 5042002,
134
- rpcUrl: "https://rpc.testnet.arc.io",
135
- explorerUrl: "https://testnet.arcscan.app"
136
- }
137
- },
138
112
  arbitrum: {
139
113
  id: "arbitrum",
140
114
  label: "Arbitrum",
@@ -183,6 +157,32 @@ var NETWORKS = {
183
157
  rpcUrl: "https://rpc.testnet.chain.robinhood.com",
184
158
  explorerUrl: "https://explorer.testnet.chain.robinhood.com"
185
159
  }
160
+ },
161
+ tempo: {
162
+ id: "tempo",
163
+ label: "Tempo",
164
+ token: TOKENS.pathUsd,
165
+ tokenSymbol: "pathUSD",
166
+ decimals: 6,
167
+ mainnet: TEMPO.mainnet,
168
+ testnet: TEMPO.testnet
169
+ },
170
+ arc: {
171
+ id: "arc",
172
+ label: "Arc",
173
+ // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
174
+ token: "0x3600000000000000000000000000000000000000",
175
+ tokenSymbol: "USDC",
176
+ decimals: 6,
177
+ // Leído on-chain del contrato: name() = "USDC", version() = "2".
178
+ eip3009: { name: "USDC", version: "2" },
179
+ // Arc no publica direcciones de mainnet todavía (sept 2026).
180
+ mainnet: null,
181
+ testnet: {
182
+ chainId: 5042002,
183
+ rpcUrl: "https://rpc.testnet.arc.io",
184
+ explorerUrl: "https://testnet.arcscan.app"
185
+ }
186
186
  }
187
187
  };
188
188
  var NETWORK_IDS = Object.keys(NETWORKS);
@@ -218,7 +218,7 @@ var GATEWAY_RAILS = {
218
218
  var GATEWAY_RAIL_IDS = Object.keys(GATEWAY_RAILS);
219
219
 
220
220
  // src/index.ts
221
- var GATEWAY_POR_DEFECTO = "https://peaje-gateway.up.railway.app";
221
+ var GATEWAY_POR_DEFECTO = "https://api.usepeaje.com";
222
222
  function baseDe({ slug, gateway }) {
223
223
  const raiz = (gateway ?? process.env.PEAJE_GATEWAY_URL ?? GATEWAY_POR_DEFECTO).replace(/\/+$/, "");
224
224
  return `${raiz}/${slug}`;
package/dist/head.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  baseDe,
4
4
  jsonLdWebApi,
5
5
  jsonParaScript
6
- } from "./chunk-XUCHMX2L.js";
6
+ } from "./chunk-WRT76472.js";
7
7
 
8
8
  // src/head.tsx
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
package/dist/index.cjs CHANGED
@@ -86,32 +86,6 @@ var TOKENS = {
86
86
  };
87
87
  var DEFAULT_CURRENCY = TOKENS.pathUsd;
88
88
  var NETWORKS = {
89
- tempo: {
90
- id: "tempo",
91
- label: "Tempo",
92
- token: TOKENS.pathUsd,
93
- tokenSymbol: "pathUSD",
94
- decimals: 6,
95
- mainnet: TEMPO.mainnet,
96
- testnet: TEMPO.testnet
97
- },
98
- arc: {
99
- id: "arc",
100
- label: "Arc",
101
- // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
102
- token: "0x3600000000000000000000000000000000000000",
103
- tokenSymbol: "USDC",
104
- decimals: 6,
105
- // Leído on-chain del contrato: name() = "USDC", version() = "2".
106
- eip3009: { name: "USDC", version: "2" },
107
- // Arc no publica direcciones de mainnet todavía (sept 2026).
108
- mainnet: null,
109
- testnet: {
110
- chainId: 5042002,
111
- rpcUrl: "https://rpc.testnet.arc.io",
112
- explorerUrl: "https://testnet.arcscan.app"
113
- }
114
- },
115
89
  arbitrum: {
116
90
  id: "arbitrum",
117
91
  label: "Arbitrum",
@@ -160,6 +134,32 @@ var NETWORKS = {
160
134
  rpcUrl: "https://rpc.testnet.chain.robinhood.com",
161
135
  explorerUrl: "https://explorer.testnet.chain.robinhood.com"
162
136
  }
137
+ },
138
+ tempo: {
139
+ id: "tempo",
140
+ label: "Tempo",
141
+ token: TOKENS.pathUsd,
142
+ tokenSymbol: "pathUSD",
143
+ decimals: 6,
144
+ mainnet: TEMPO.mainnet,
145
+ testnet: TEMPO.testnet
146
+ },
147
+ arc: {
148
+ id: "arc",
149
+ label: "Arc",
150
+ // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
151
+ token: "0x3600000000000000000000000000000000000000",
152
+ tokenSymbol: "USDC",
153
+ decimals: 6,
154
+ // Leído on-chain del contrato: name() = "USDC", version() = "2".
155
+ eip3009: { name: "USDC", version: "2" },
156
+ // Arc no publica direcciones de mainnet todavía (sept 2026).
157
+ mainnet: null,
158
+ testnet: {
159
+ chainId: 5042002,
160
+ rpcUrl: "https://rpc.testnet.arc.io",
161
+ explorerUrl: "https://testnet.arcscan.app"
162
+ }
163
163
  }
164
164
  };
165
165
  var NETWORK_IDS = Object.keys(NETWORKS);
@@ -195,7 +195,7 @@ var GATEWAY_RAILS = {
195
195
  var GATEWAY_RAIL_IDS = Object.keys(GATEWAY_RAILS);
196
196
 
197
197
  // src/index.ts
198
- var GATEWAY_POR_DEFECTO = "https://peaje-gateway.up.railway.app";
198
+ var GATEWAY_POR_DEFECTO = "https://api.usepeaje.com";
199
199
  function baseDe({ slug, gateway }) {
200
200
  const raiz = (gateway ?? process.env.PEAJE_GATEWAY_URL ?? GATEWAY_POR_DEFECTO).replace(/\/+$/, "");
201
201
  return `${raiz}/${slug}`;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- declare const GATEWAY_POR_DEFECTO = "https://peaje-gateway.up.railway.app";
1
+ declare const GATEWAY_POR_DEFECTO = "https://api.usepeaje.com";
2
2
  type OpcionesPeaje = {
3
3
  /** El slug del negocio en Peaje (el mismo del dashboard). */
4
4
  slug: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const GATEWAY_POR_DEFECTO = "https://peaje-gateway.up.railway.app";
1
+ declare const GATEWAY_POR_DEFECTO = "https://api.usepeaje.com";
2
2
  type OpcionesPeaje = {
3
3
  /** El slug del negocio en Peaje (el mismo del dashboard). */
4
4
  slug: string;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  fusionarRewrites,
5
5
  src_default,
6
6
  withPeaje
7
- } from "./chunk-XUCHMX2L.js";
7
+ } from "./chunk-WRT76472.js";
8
8
  export {
9
9
  GATEWAY_POR_DEFECTO,
10
10
  baseDe,
package/dist/proxy.cjs CHANGED
@@ -64,17 +64,35 @@ function iguales(a, b) {
64
64
  }
65
65
  function coincidePatron(patron, pathname) {
66
66
  const p = patron.split("/").filter(Boolean);
67
- const parts = pathname.split("/").filter(Boolean);
67
+ const parts = segmentosCanonicos(pathname);
68
68
  for (let i = 0; i < p.length; i++) {
69
69
  const seg = p[i];
70
70
  if (seg === "*") return true;
71
71
  const v = parts[i];
72
72
  if (v === void 0) return false;
73
73
  if (seg.startsWith(":")) continue;
74
- if (seg !== v) return false;
74
+ if (seg.toLowerCase() !== v.toLowerCase()) return false;
75
75
  }
76
76
  return p.length === parts.length;
77
77
  }
78
+ function segmentosCanonicos(pathname) {
79
+ const out = [];
80
+ for (const crudo of pathname.split(/[\\/]+/)) {
81
+ if (!crudo) continue;
82
+ let seg = crudo;
83
+ try {
84
+ seg = decodeURIComponent(crudo);
85
+ } catch {
86
+ }
87
+ for (const s of seg.split(/[\\/]+/)) {
88
+ if (!s || s === ".") continue;
89
+ if (s === "..") out.pop();
90
+ else out.push(s);
91
+ }
92
+ }
93
+ return out;
94
+ }
95
+ var pathCanonico = (pathname) => `/${segmentosCanonicos(pathname).join("/")}`;
78
96
  function patronReenviable(patron) {
79
97
  const segs = patron.split("/").filter(Boolean);
80
98
  if (segs.length === 0) return false;
@@ -134,9 +152,10 @@ function crearProxyRuntime(opciones) {
134
152
  if (secreto && prueba && iguales(prueba, secreto)) return null;
135
153
  const { rutas, prefijos, patrones } = await listas();
136
154
  const path = input.pathname;
155
+ const canon = pathCanonico(path).toLowerCase();
137
156
  const esFetchDePeaje = input.headers.get(PEAJE_FETCH_HEADER) !== null;
138
- const fija = rutas.includes(path) && !(path === "/llms.txt" && esFetchDePeaje);
139
- const prefijo = prefijos.some((p) => path.startsWith(p));
157
+ const fija = (rutas.includes(path) || rutas.some((r) => r.toLowerCase() === canon)) && !(canon === "/llms.txt" && esFetchDePeaje);
158
+ const prefijo = prefijos.some((p) => path.startsWith(p) || canon.startsWith(p.toLowerCase()));
140
159
  const method = input.method.toUpperCase();
141
160
  const patron = secreto !== null && patrones.some((p) => p.method.toUpperCase() === method && patronReenviable(p.path) && coincidePatron(p.path, path));
142
161
  if (!fija && !prefijo && !patron) return null;
@@ -164,32 +183,6 @@ var TOKENS = {
164
183
  };
165
184
  var DEFAULT_CURRENCY = TOKENS.pathUsd;
166
185
  var NETWORKS = {
167
- tempo: {
168
- id: "tempo",
169
- label: "Tempo",
170
- token: TOKENS.pathUsd,
171
- tokenSymbol: "pathUSD",
172
- decimals: 6,
173
- mainnet: TEMPO.mainnet,
174
- testnet: TEMPO.testnet
175
- },
176
- arc: {
177
- id: "arc",
178
- label: "Arc",
179
- // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
180
- token: "0x3600000000000000000000000000000000000000",
181
- tokenSymbol: "USDC",
182
- decimals: 6,
183
- // Leído on-chain del contrato: name() = "USDC", version() = "2".
184
- eip3009: { name: "USDC", version: "2" },
185
- // Arc no publica direcciones de mainnet todavía (sept 2026).
186
- mainnet: null,
187
- testnet: {
188
- chainId: 5042002,
189
- rpcUrl: "https://rpc.testnet.arc.io",
190
- explorerUrl: "https://testnet.arcscan.app"
191
- }
192
- },
193
186
  arbitrum: {
194
187
  id: "arbitrum",
195
188
  label: "Arbitrum",
@@ -238,6 +231,32 @@ var NETWORKS = {
238
231
  rpcUrl: "https://rpc.testnet.chain.robinhood.com",
239
232
  explorerUrl: "https://explorer.testnet.chain.robinhood.com"
240
233
  }
234
+ },
235
+ tempo: {
236
+ id: "tempo",
237
+ label: "Tempo",
238
+ token: TOKENS.pathUsd,
239
+ tokenSymbol: "pathUSD",
240
+ decimals: 6,
241
+ mainnet: TEMPO.mainnet,
242
+ testnet: TEMPO.testnet
243
+ },
244
+ arc: {
245
+ id: "arc",
246
+ label: "Arc",
247
+ // Interfaz ERC-20 del USDC nativo de Arc; el gas de la red se paga en ese mismo USDC.
248
+ token: "0x3600000000000000000000000000000000000000",
249
+ tokenSymbol: "USDC",
250
+ decimals: 6,
251
+ // Leído on-chain del contrato: name() = "USDC", version() = "2".
252
+ eip3009: { name: "USDC", version: "2" },
253
+ // Arc no publica direcciones de mainnet todavía (sept 2026).
254
+ mainnet: null,
255
+ testnet: {
256
+ chainId: 5042002,
257
+ rpcUrl: "https://rpc.testnet.arc.io",
258
+ explorerUrl: "https://testnet.arcscan.app"
259
+ }
241
260
  }
242
261
  };
243
262
  var NETWORK_IDS = Object.keys(NETWORKS);
@@ -276,7 +295,7 @@ var GATEWAY_RAIL_IDS = Object.keys(GATEWAY_RAILS);
276
295
  var import_server = require("next/server");
277
296
 
278
297
  // src/index.ts
279
- var GATEWAY_POR_DEFECTO = "https://peaje-gateway.up.railway.app";
298
+ var GATEWAY_POR_DEFECTO = "https://api.usepeaje.com";
280
299
  function baseDe({ slug, gateway }) {
281
300
  const raiz = (gateway ?? process.env.PEAJE_GATEWAY_URL ?? GATEWAY_POR_DEFECTO).replace(/\/+$/, "");
282
301
  return `${raiz}/${slug}`;
package/dist/proxy.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  RUTAS_PROXY,
4
4
  baseDe,
5
5
  crearProxyRuntime
6
- } from "./chunk-XUCHMX2L.js";
6
+ } from "./chunk-WRT76472.js";
7
7
 
8
8
  // src/proxy.ts
9
9
  import { NextResponse } from "next/server";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peaje/next",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Peaje for Next.js: runtime proxy, rewrites and the head block that make your site answer 402 (MPP, x402), MCP and OpenAPI on your own domain.",
5
5
  "license": "MIT",
6
6
  "type": "module",