@profullstack/throttle 0.2.3 → 0.3.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/throttle.js +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/throttle",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "An app-wide rate limit whose answer to going over is a price, not a 429. 100 requests a minute free, then x402 Payment Required with an offer, settled by CoinPay. Meters every route, so a scraper wearing a browser user agent is charged like any other crawler.",
6
6
  "keywords": [
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "sideEffects": false,
56
56
  "dependencies": {
57
- "@profullstack/x402-gateway": "^0.6.0 || ^0.7.0"
57
+ "@profullstack/x402-gateway": "^0.6.0 || ^0.7.0 || ^0.8.0"
58
58
  },
59
59
  "scripts": {
60
60
  "test": "node --test"
package/src/throttle.js CHANGED
@@ -176,6 +176,13 @@ export function createThrottle(options = {}) {
176
176
  if (gateway) {
177
177
  const token = gateway.passFrom(request);
178
178
  if (token && (await gateway.verifyPass(token))) return null;
179
+ /*
180
+ * A search crawler whose address matches its name (gateway 0.8+) reads
181
+ * unmetered. Googlebot walks a large site from a handful of addresses,
182
+ * outruns any per-address allowance, and a 402 to it is how a site
183
+ * drops out of the index.
184
+ */
185
+ if (typeof gateway.isWelcome === 'function' && gateway.isWelcome(request)) return null;
179
186
  }
180
187
 
181
188
  const key = identify(request);