@profullstack/throttle 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/throttle.js +7 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/throttle",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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.5.0"
57
+ "@profullstack/x402-gateway": "^0.6.0"
58
58
  },
59
59
  "scripts": {
60
60
  "test": "node --test"
package/src/throttle.js CHANGED
@@ -143,7 +143,13 @@ export function createThrottle(options = {}) {
143
143
  // Telling someone must never cost the caller its answer.
144
144
  }
145
145
  }
146
- if (!gateway) return tooMany(rule, usage);
146
+ /*
147
+ * A gateway with no CoinPay key and no payTo cannot take money, and its
148
+ * 402 carries an empty `accepts` list -- a price tag on a locked door. A
149
+ * refusal nobody can buy their way out of is a 429, and saying so is
150
+ * honest about which one this is.
151
+ */
152
+ if (!gateway?.enabled) return tooMany(rule, usage);
147
153
  return gateway.sell(request, {
148
154
  usage,
149
155
  quota: { requests: rule.limit, windowSeconds: rule.windowSeconds },