@redcenterstudio/agent-tollbooth-edge 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +53 -2
- package/dist/index.d.ts +317 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1495 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -4
- package/src/index.ts +2005 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Red Center Studio (https://redcenterstudio.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @redcenterstudio/agent-tollbooth-edge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
HTTP 402 middleware for Cloudflare Workers, Hono and any Web `Request` handler. AI agents pay per call in USDC over x402 V2, straight to your own Base wallet. Red Center Studio takes 0% of payments and never holds your money.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @redcenterstudio/agent-tollbooth-edge
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start (Cloudflare Worker)
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { withTollbooth } from '@redcenterstudio/agent-tollbooth-edge';
|
|
15
|
+
|
|
16
|
+
export default withTollbooth(
|
|
17
|
+
{
|
|
18
|
+
priceUsd: 0.01,
|
|
19
|
+
mode: 'x402',
|
|
20
|
+
payTo: '0xYourBaseWallet',
|
|
21
|
+
network: 'eip155:84532', // Base Sepolia: free testing
|
|
22
|
+
},
|
|
23
|
+
async () => Response.json({ ok: true }),
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Hono:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { Hono } from 'hono';
|
|
31
|
+
import { honoTollbooth } from '@redcenterstudio/agent-tollbooth-edge';
|
|
32
|
+
|
|
33
|
+
const app = new Hono();
|
|
34
|
+
app.use('/api/*', honoTollbooth({ priceUsd: 0.01, mode: 'x402', payTo: '0xYourBaseWallet', network: 'eip155:84532' }));
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Unpaid requests get a `402 Payment Required` challenge. Paid requests pass through to your handler. `/health`, `/readyz` and `/webhook/*` stay free. Use `mode: 'sandbox'` for offline local tests.
|
|
38
|
+
|
|
39
|
+
## Going live on Base mainnet
|
|
40
|
+
|
|
41
|
+
Set `network: 'eip155:8453'`, then either:
|
|
42
|
+
|
|
43
|
+
- settle through your own x402 facilitator (`facilitatorUrl`), free, or
|
|
44
|
+
- settle through the hosted facilitator at tollbooth.redcenterstudio.com with a Pro Pass ($39 USD once, one project) or Agency Pass ($79 USD once). Register a developer account whose payout address is your `payTo`. No Coinbase developer account or facilitator server of your own needed.
|
|
45
|
+
|
|
46
|
+
Either way, payments go straight to your wallet.
|
|
47
|
+
|
|
48
|
+
## Links
|
|
49
|
+
|
|
50
|
+
- Setup guide and passes: https://tollbooth.redcenterstudio.com
|
|
51
|
+
- Claude Code plugin and source: https://github.com/Red-Center-Studio/agent-tollbooth-402
|
|
52
|
+
- Done-for-you setup: https://redcenterstudio.com/services/ai-tollbooth-setup/
|
|
53
|
+
|
|
54
|
+
MIT licensed.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @redcenterstudio/agent-tollbooth-edge
|
|
3
|
+
* Zero-dependency dual-rail HTTP 402 middleware for Cloudflare Workers, Fetch APIs, Next.js, and Hono.
|
|
4
|
+
*
|
|
5
|
+
* Rail A: Open x402 V2 standard (`PAYMENT-REQUIRED`, `PAYMENT-SIGNATURE`, `PAYMENT-RESPONSE`)
|
|
6
|
+
* Rail B: Red Center Fiat Agent Wallet (`rcs_receipt_...` verified <1ms via Web Crypto + NonceStore)
|
|
7
|
+
*/
|
|
8
|
+
export type PaymentScheme = 'exact' | 'upto';
|
|
9
|
+
export type TollboothRail = 'x402' | 'fiat_wallet';
|
|
10
|
+
export type FiatReceiptAlg = 'hs256' | 'ed25519';
|
|
11
|
+
export type TollboothMode = 'sandbox' | 'mock' | 'hybrid' | 'x402';
|
|
12
|
+
export type TollboothErrorCode = 'MISSING_PAYMENT' | 'INSUFFICIENT_FUNDS' | 'RECEIPT_EXPIRED' | 'NONCE_REPLAYED' | 'INVALID_SIGNATURE' | 'SPEND_CAP_EXCEEDED' | 'PRO_PASS_REQUIRED' | 'FACILITATOR_ERROR';
|
|
13
|
+
export declare const DEFAULT_FACILITATOR_URL = "https://tollbooth.redcenterstudio.com";
|
|
14
|
+
export declare const DEFAULT_PAYMENT_URL = "https://tollbooth.redcenterstudio.com";
|
|
15
|
+
export declare const DEFAULT_PAY_TO = "0x000000000000000000000000000000000000dEaD";
|
|
16
|
+
export declare const DEFAULT_NETWORK = "eip155:8453";
|
|
17
|
+
export declare const DEFAULT_USDC_BASE_ASSET = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
18
|
+
export declare const DEFAULT_EXEMPT_PATHS: readonly ["/health", "/readyz", "/webhook/*"];
|
|
19
|
+
export declare const DEFAULT_CLOCK_SKEW_SECONDS = 30;
|
|
20
|
+
export declare const DEFAULT_JWKS_URL = "https://tollbooth.redcenterstudio.com/.well-known/tollbooth-jwks.json";
|
|
21
|
+
/**
|
|
22
|
+
* EIP-712 domain of USDC per network. Payers sign with this name and version; a wrong name makes the USDC
|
|
23
|
+
* contract reject the transfer (Base mainnet USDC is "USD Coin", Base Sepolia USDC is "USDC").
|
|
24
|
+
*/
|
|
25
|
+
export declare const USDC_EIP712_DOMAINS: Record<string, {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare function usdcEip712Extra(network: string): {
|
|
30
|
+
name: string;
|
|
31
|
+
version: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Fetch the clearinghouse's Ed25519 receipt public key (the JWK `x`, base64url) for `fiatWallet.ed25519PublicKey`.
|
|
35
|
+
* Cache the result: the key changes only when the clearinghouse rotates it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fetchTollboothPublicKey(jwksUrl?: string, fetchImpl?: typeof fetch): Promise<string>;
|
|
38
|
+
export declare const DEFAULT_PRICE_USD = 0.01;
|
|
39
|
+
export declare const SANDBOX_HMAC_SECRET = "rcs_sandbox_local_dev_secret_32bytes_deterministic";
|
|
40
|
+
export declare const CORS_EXPOSE_HEADERS = "PAYMENT-REQUIRED, PAYMENT-RESPONSE, X-Agent-Receipt, WWW-Authenticate, X-Tollbooth-Rail";
|
|
41
|
+
export declare const CORS_ALLOW_HEADERS = "Content-Type, Authorization, PAYMENT-SIGNATURE, X-Agent-Receipt, Idempotency-Key";
|
|
42
|
+
export interface D1LikeRunResult {
|
|
43
|
+
meta?: {
|
|
44
|
+
changes?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface D1LikePreparedStatement {
|
|
48
|
+
bind(...values: unknown[]): D1LikePreparedStatement;
|
|
49
|
+
run(): Promise<D1LikeRunResult>;
|
|
50
|
+
}
|
|
51
|
+
export interface D1LikeDatabase {
|
|
52
|
+
prepare(query: string): D1LikePreparedStatement;
|
|
53
|
+
}
|
|
54
|
+
export interface NonceConsumeMeta {
|
|
55
|
+
walletOrPayer: string;
|
|
56
|
+
route: string;
|
|
57
|
+
expiresAt: number;
|
|
58
|
+
rail?: TollboothRail;
|
|
59
|
+
}
|
|
60
|
+
export interface NonceStore {
|
|
61
|
+
consume(nonce: string, meta: NonceConsumeMeta): Promise<boolean>;
|
|
62
|
+
release?(nonce: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
export interface SpendTracker {
|
|
65
|
+
checkAndRecord(agentId: string, amountMicros: number, capMicros: number): Promise<{
|
|
66
|
+
allowed: boolean;
|
|
67
|
+
spentMicros: number;
|
|
68
|
+
}>;
|
|
69
|
+
rollback?(agentId: string, amountMicros: number): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export interface RcsReceiptClaims {
|
|
72
|
+
v: 1;
|
|
73
|
+
jti: string;
|
|
74
|
+
sub: string;
|
|
75
|
+
aud: string;
|
|
76
|
+
mth?: string;
|
|
77
|
+
amt: number;
|
|
78
|
+
iat: number;
|
|
79
|
+
exp: number;
|
|
80
|
+
tier?: 'hybrid' | 'pro' | 'agency';
|
|
81
|
+
}
|
|
82
|
+
export type ReceiptSigningKey = {
|
|
83
|
+
alg: 'hs256';
|
|
84
|
+
secret: string;
|
|
85
|
+
} | {
|
|
86
|
+
alg: 'ed25519';
|
|
87
|
+
privateKey: CryptoKey;
|
|
88
|
+
};
|
|
89
|
+
export interface FiatWalletConfig {
|
|
90
|
+
hmacSecret?: string;
|
|
91
|
+
ed25519PublicKey?: CryptoKey | string;
|
|
92
|
+
clearinghouseUrl?: string;
|
|
93
|
+
clockSkewSeconds?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface FiatWalletVerifyOptions extends FiatWalletConfig {
|
|
96
|
+
expectedAudience: string;
|
|
97
|
+
expectedMethod: string;
|
|
98
|
+
requiredMicros: number;
|
|
99
|
+
nowSeconds?: number;
|
|
100
|
+
perAgentSpendCapMicros?: number;
|
|
101
|
+
spendTracker?: SpendTracker;
|
|
102
|
+
}
|
|
103
|
+
export interface FiatReceiptVerifyResult {
|
|
104
|
+
valid: boolean;
|
|
105
|
+
reason?: string;
|
|
106
|
+
claims?: RcsReceiptClaims;
|
|
107
|
+
alg?: FiatReceiptAlg;
|
|
108
|
+
verifiedInMs?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface X402AcceptOption {
|
|
111
|
+
scheme: PaymentScheme;
|
|
112
|
+
network: string;
|
|
113
|
+
amount: string;
|
|
114
|
+
asset: string;
|
|
115
|
+
payTo: string;
|
|
116
|
+
maxTimeoutSeconds: number;
|
|
117
|
+
extra?: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
export interface X402PaymentRequired {
|
|
120
|
+
x402Version: 2;
|
|
121
|
+
code: TollboothErrorCode;
|
|
122
|
+
error: string;
|
|
123
|
+
fix_hint: string;
|
|
124
|
+
priceUsd: string;
|
|
125
|
+
priceMicros: number;
|
|
126
|
+
acceptedRails: Array<'x402-v2' | 'rcs-fiat-wallet'>;
|
|
127
|
+
paymentUrl: string;
|
|
128
|
+
resource: {
|
|
129
|
+
url: string;
|
|
130
|
+
description: string;
|
|
131
|
+
mimeType: string;
|
|
132
|
+
};
|
|
133
|
+
accepts: X402AcceptOption[];
|
|
134
|
+
extensions: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
export interface X402Authorization {
|
|
137
|
+
from: string;
|
|
138
|
+
to: string;
|
|
139
|
+
value: string;
|
|
140
|
+
validAfter: string;
|
|
141
|
+
validBefore: string;
|
|
142
|
+
nonce: string;
|
|
143
|
+
}
|
|
144
|
+
export interface X402PaymentSignature {
|
|
145
|
+
x402Version: 2;
|
|
146
|
+
scheme?: PaymentScheme;
|
|
147
|
+
network?: string;
|
|
148
|
+
accepted?: {
|
|
149
|
+
scheme: PaymentScheme;
|
|
150
|
+
network: string;
|
|
151
|
+
};
|
|
152
|
+
payload: {
|
|
153
|
+
signature: string;
|
|
154
|
+
authorization: X402Authorization;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export interface X402PaymentResponse {
|
|
158
|
+
success: boolean;
|
|
159
|
+
transaction: string | null;
|
|
160
|
+
network: string;
|
|
161
|
+
payer: string | null;
|
|
162
|
+
settledAmount?: string;
|
|
163
|
+
rail?: TollboothRail;
|
|
164
|
+
errorReason: string | null;
|
|
165
|
+
}
|
|
166
|
+
export interface X402VerifyResponse {
|
|
167
|
+
isValid: boolean;
|
|
168
|
+
invalidReason: string | null;
|
|
169
|
+
}
|
|
170
|
+
export interface X402SettleResponse {
|
|
171
|
+
success: boolean;
|
|
172
|
+
txHash: string | null;
|
|
173
|
+
network?: string;
|
|
174
|
+
settledAmount?: string;
|
|
175
|
+
errorReason: string | null;
|
|
176
|
+
}
|
|
177
|
+
export interface TollboothRouteConfig {
|
|
178
|
+
pattern: string;
|
|
179
|
+
method?: string | string[];
|
|
180
|
+
scheme?: PaymentScheme;
|
|
181
|
+
priceMicros?: number;
|
|
182
|
+
priceUsd?: number | string;
|
|
183
|
+
minPriceMicros?: number;
|
|
184
|
+
proPass?: boolean;
|
|
185
|
+
description?: string;
|
|
186
|
+
mimeType?: string;
|
|
187
|
+
network?: string;
|
|
188
|
+
asset?: string;
|
|
189
|
+
payTo?: string;
|
|
190
|
+
maxTimeoutSeconds?: number;
|
|
191
|
+
meterUsage?: (request: Request, response: Response, minAtomic: bigint, authorizedAtomic: bigint) => Promise<bigint> | bigint;
|
|
192
|
+
}
|
|
193
|
+
export interface TollboothConfig {
|
|
194
|
+
payTo?: string;
|
|
195
|
+
mode?: TollboothMode;
|
|
196
|
+
priceUsd?: number | string;
|
|
197
|
+
priceMicros?: number;
|
|
198
|
+
facilitatorUrl?: string;
|
|
199
|
+
paymentUrl?: string;
|
|
200
|
+
network?: string;
|
|
201
|
+
asset?: string;
|
|
202
|
+
proPass?: boolean;
|
|
203
|
+
clockSkewSeconds?: number;
|
|
204
|
+
customPaymentPageHtml?: string | ((challenge: X402PaymentRequired, request: Request) => string);
|
|
205
|
+
perAgentSpendCapMicros?: number;
|
|
206
|
+
spendTracker?: SpendTracker;
|
|
207
|
+
exemptPaths?: string[];
|
|
208
|
+
nonceStore?: NonceStore;
|
|
209
|
+
fiatWallet?: FiatWalletConfig;
|
|
210
|
+
routes?: TollboothRouteConfig[];
|
|
211
|
+
fetchImpl?: typeof fetch;
|
|
212
|
+
nowSeconds?: () => number;
|
|
213
|
+
}
|
|
214
|
+
export interface WorkerHandler<Env = unknown> {
|
|
215
|
+
fetch(request: Request, env?: Env, ctx?: ExecutionContext): Promise<Response>;
|
|
216
|
+
}
|
|
217
|
+
export type WorkerFetchFn<Env = unknown> = (request: Request, env?: Env, ctx?: ExecutionContext) => Promise<Response> | Response;
|
|
218
|
+
export interface HonoLikeContext {
|
|
219
|
+
req: {
|
|
220
|
+
raw: Request;
|
|
221
|
+
};
|
|
222
|
+
res: Response | undefined;
|
|
223
|
+
}
|
|
224
|
+
export type HonoLikeNext = () => Promise<void>;
|
|
225
|
+
export type HonoLikeMiddleware = (c: HonoLikeContext, next: HonoLikeNext) => Promise<Response | void>;
|
|
226
|
+
/**
|
|
227
|
+
* Convert a USD dollar value (e.g. `0.005` or `"$0.005"`) into integer microdollars (`1 USD = 1_000_000`).
|
|
228
|
+
*/
|
|
229
|
+
export declare function usdToMicros(usd: number | string): number;
|
|
230
|
+
/**
|
|
231
|
+
* Format integer microdollars into a trimmed USD string (e.g. `5000` -> `"0.005"`).
|
|
232
|
+
*/
|
|
233
|
+
export declare function microsToUsdString(micros: number): string;
|
|
234
|
+
/**
|
|
235
|
+
* Convert USD microdollars to 6-decimal USDC atomic units (1 microdollar === 1 USDC atomic unit).
|
|
236
|
+
*/
|
|
237
|
+
export declare function usdMicrosToUsdcAtomic(micros: number): string;
|
|
238
|
+
/**
|
|
239
|
+
* Web-standard Base64 encode for UTF-8 JSON payloads without Node Buffer dependency.
|
|
240
|
+
*/
|
|
241
|
+
export declare function encodePaymentHeader(payload: unknown): string;
|
|
242
|
+
/**
|
|
243
|
+
* Web-standard Base64 decode for x402 V2 JSON header payloads.
|
|
244
|
+
*/
|
|
245
|
+
export declare function decodePaymentHeader<T>(encoded: string): T;
|
|
246
|
+
export declare function base64UrlEncode(bytes: Uint8Array): string;
|
|
247
|
+
export declare function base64UrlDecode(input: string): Uint8Array;
|
|
248
|
+
/**
|
|
249
|
+
* In-memory TTL-pruning NonceStore suitable for local smoke tests and single-isolate development.
|
|
250
|
+
*/
|
|
251
|
+
export declare class MemoryNonceStore implements NonceStore {
|
|
252
|
+
private readonly used;
|
|
253
|
+
consume(nonce: string, meta: NonceConsumeMeta): Promise<boolean>;
|
|
254
|
+
release(nonce: string): Promise<void>;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Durable edge NonceStore backed by Cloudflare D1 `used_nonces`.
|
|
258
|
+
*/
|
|
259
|
+
export declare class D1NonceStore implements NonceStore {
|
|
260
|
+
private readonly db;
|
|
261
|
+
constructor(db: D1LikeDatabase);
|
|
262
|
+
consume(nonce: string, meta: NonceConsumeMeta): Promise<boolean>;
|
|
263
|
+
release(nonce: string): Promise<void>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* In-memory per-agent spend cap tracker.
|
|
267
|
+
*/
|
|
268
|
+
export declare class MemorySpendTracker implements SpendTracker {
|
|
269
|
+
private readonly spendByAgent;
|
|
270
|
+
checkAndRecord(agentId: string, amountMicros: number, capMicros: number): Promise<{
|
|
271
|
+
allowed: boolean;
|
|
272
|
+
spentMicros: number;
|
|
273
|
+
}>;
|
|
274
|
+
rollback(agentId: string, amountMicros: number): Promise<void>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Sign a Red Center Fiat Agent Wallet receipt (`rcs_receipt_<alg>.<payload>.<sig>`).
|
|
278
|
+
*/
|
|
279
|
+
export declare function signFiatReceipt(claims: RcsReceiptClaims, keyMaterial: ReceiptSigningKey): Promise<string>;
|
|
280
|
+
/**
|
|
281
|
+
* Zero-config helper for local `mode: "sandbox"` / `"mock"` testing without API keys or Stripe.
|
|
282
|
+
*/
|
|
283
|
+
export declare function createSandboxReceipt(overrides?: Partial<RcsReceiptClaims> & {
|
|
284
|
+
priceUsd?: number | string;
|
|
285
|
+
secret?: string;
|
|
286
|
+
}): Promise<string>;
|
|
287
|
+
/**
|
|
288
|
+
* Zero-config helper generating a Base64-encoded x402 V2 `PAYMENT-SIGNATURE` header for local sandbox runs.
|
|
289
|
+
*/
|
|
290
|
+
export declare function createSandboxX402Header(overrides?: {
|
|
291
|
+
priceUsd?: number | string;
|
|
292
|
+
amount?: string;
|
|
293
|
+
payTo?: string;
|
|
294
|
+
from?: string;
|
|
295
|
+
nonce?: string;
|
|
296
|
+
scheme?: PaymentScheme;
|
|
297
|
+
network?: string;
|
|
298
|
+
}): string;
|
|
299
|
+
/**
|
|
300
|
+
* Verify a Rail B `rcs_receipt_...` bearer token in <1ms using Web Crypto `crypto.subtle.verify`.
|
|
301
|
+
*/
|
|
302
|
+
export declare function verifyFiatReceipt(token: string, options: FiatWalletVerifyOptions): Promise<FiatReceiptVerifyResult>;
|
|
303
|
+
/**
|
|
304
|
+
* Self-contained Red Center Studio HTML 402 Checkout Card rendered when
|
|
305
|
+
* a browser sends `Accept: text/html` to a gated endpoint.
|
|
306
|
+
*/
|
|
307
|
+
export declare function renderDefault402HtmlPage(challenge: X402PaymentRequired, request: Request): string;
|
|
308
|
+
/**
|
|
309
|
+
* Wrap a Cloudflare Worker `ExportedHandler` or bare Fetch handler `(request, env, ctx) => Response`
|
|
310
|
+
* with dual-rail HTTP 402 protection.
|
|
311
|
+
*/
|
|
312
|
+
export declare function withTollbooth<Env = unknown>(configOrFactory: TollboothConfig | ((env: Env) => TollboothConfig), handlerOrFn: WorkerHandler<Env> | WorkerFetchFn<Env>): WorkerHandler<Env>;
|
|
313
|
+
/**
|
|
314
|
+
* Hono-compatible middleware factory enforcing dual-rail HTTP 402 payment requirements.
|
|
315
|
+
*/
|
|
316
|
+
export declare function honoTollbooth(config: TollboothConfig): HonoLikeMiddleware;
|
|
317
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,aAAa,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnE,MAAM,MAAM,kBAAkB,GAC1B,iBAAiB,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,GACnB,oBAAoB,GACpB,mBAAmB,GACnB,mBAAmB,CAAC;AAExB,eAAO,MAAM,uBAAuB,0CAA0C,CAAC;AAC/E,eAAO,MAAM,mBAAmB,0CAA0C,CAAC;AAC3E,eAAO,MAAM,cAAc,+CAA+C,CAAC;AAC3E,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,uBAAuB,+CAA+C,CAAC;AACpF,eAAO,MAAM,oBAAoB,+CAAgD,CAAC;AAClF,eAAO,MAAM,0BAA0B,KAAK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