@profullstack/x402-gateway 0.5.0 → 0.6.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/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/index.js +14 -0
package/index.d.ts
CHANGED
|
@@ -180,6 +180,10 @@ export interface Gateway {
|
|
|
180
180
|
passFrom: (request: Request) => string | null;
|
|
181
181
|
/** Whether that token is a live pass this gateway minted. */
|
|
182
182
|
verifyPass: (token: string | null) => Promise<boolean>;
|
|
183
|
+
/** The x402 offer this gateway would make, without answering a request. */
|
|
184
|
+
offer: (days?: number) => Offer;
|
|
185
|
+
/** The full 402 body around that offer: the offer plus the pass terms. */
|
|
186
|
+
receipt: (days?: number, extra?: Record<string, unknown>) => Offer & Record<string, unknown>;
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
export function createGateway(options: GatewayOptions): Gateway;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profullstack/x402-gateway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Sell crawl access to AI training crawlers by the day over x402, settled by CoinPay. One middleware: 402 with an offer, a sales page with CLI instructions, signed passes, and a robots.txt that keeps search crawlers welcome.",
|
|
6
6
|
"keywords": [
|
package/src/index.js
CHANGED
|
@@ -388,6 +388,20 @@ export function createGateway(options = {}) {
|
|
|
388
388
|
*/
|
|
389
389
|
passFrom,
|
|
390
390
|
verifyPass: async (token) => Boolean(token && (await readPass(token, { secret }))),
|
|
391
|
+
/**
|
|
392
|
+
* The x402 offer this gateway would make, and the full receipt body around
|
|
393
|
+
* it, without answering a request.
|
|
394
|
+
*
|
|
395
|
+
* A site with its own refusal -- a tiered limiter whose 429 body says which
|
|
396
|
+
* rung the caller is on and what the next one costs -- wants to keep that
|
|
397
|
+
* body and add a machine-readable offer to it, so an x402 client can pay
|
|
398
|
+
* on the spot instead of being told in prose to go and fetch /crawl. The
|
|
399
|
+
* alternative is every such site rebuilding payTo, price, currency and
|
|
400
|
+
* network from its own copy of the config, which is how two of them end up
|
|
401
|
+
* quoting different numbers.
|
|
402
|
+
*/
|
|
403
|
+
offer,
|
|
404
|
+
receipt,
|
|
391
405
|
/** robots.txt with this gateway's lists and sales path. */
|
|
392
406
|
robotsTxt: (extra = {}) =>
|
|
393
407
|
robotsTxt({ siteUrl: o.siteUrl, path: o.path, training: o.training, retrieval: o.retrieval, ...extra }),
|