8 Commits
Author SHA1 Message Date
CatoandClaude d5e5dd915f feat: publish as @bitbaum/limitkit (same code, same version) (#42)
Owner, 2026-11-06: the fleet's packages belong under the @bitbaum npm
organization; this one was published earlier, unscoped, and never moved
(fleet docs/package-scope-migration-plan.md). Name, imports in tests, examples
and docs change; no API changes. The old name stays installable and is
deprecated once no adopter uses it.


Claude-Session: https://claude.ai/code/session_019MDtmvpWNTLxXNfwUHS7MD

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 13:49:06 +01:00
Cato 60271e9a5a docs(readme): install from npm, the way the registry says (#33)
Problem: the README told a reader to install a Git tag or a raw commit (2 files changed, 15 insertions(+), 1 deletion(-)). The package is on npm and fleet's SHARED.md and registers/packages.json name npm as the install route; a Git pin hides the version and defeats semver updates. Change: the install line is the npm one. Nothing else in the README changed.
2026-10-28 02:40:53 +01:00
CatoandClaude Opus 5 e775a6b012 docs: link back to bitbaum, and to who uses this package (#22)
Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 01:04:34 -07:00
f6349c2d57 docs: sync docs with actual stack (#14)
The README install line pointed at the retired handle
(`github:catomean/limitkit`) and the old `v0.1.0` tag; the repo lives under
the `bitbaum` org and is at v0.2.0 (limitkit is not on the npm registry —
unpublished 2026-03 — so the github: form stays). Command switched to pnpm,
the fleet's one package manager.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 07:51:51 -07:00
bc221819eb chore: pnpm — the fleet has one package manager (#13)
Convert from npm to pnpm (fleet standard, STACK.md):
- packageManager pin pnpm@11.25.0 (corepack SSOT)
- pnpm-lock.yaml via `pnpm import` from package-lock.json (resolutions
  preserved), then package-lock.json deleted
- CI + publish workflows: pnpm/action-setup@v6, cache: pnpm,
  `pnpm install --frozen-lockfile`, `pnpm run verify`
- package.json scripts and contributor docs use pnpm; consumer install
  lines stay npm — consumers choose their own package manager
- npm publish invocation unchanged (works from a pnpm-managed tree)

Clean-room proven: rm -rf node_modules && pnpm install --frozen-lockfile
&& tests green.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-03 08:01:40 -07:00
75adef1e99 fix(http)!: key on the hop the proxy wrote, not the one the client sent (#2)
clientIp returned the FIRST x-forwarded-for hop, with a comment asserting that
was "what the proxy saw" and a test pinning it. Both were wrong in the same
direction.

A reverse proxy APPENDS to X-Forwarded-For. Caddy and nginx both do. So for a
request through one proxy the header reads `<whatever the client sent>, <what
the proxy actually saw>`, and the only entry a client cannot forge is the LAST.

The effect, in every adopter at once: send a random X-Forwarded-For with each
request and every request lands in a fresh bucket, so no bucket ever fills.
Not "weakened" — bypassed completely. A limiter that cannot be tripped is not a
limiter, and it is worse than none, because the route reads as protected.

Found in orangecat's payments audit (bitbaum/orangecat#563, finding 2), where
the same mistake is copied across three payment routes that each mint a real
Lightning invoice per request.

Now counts from the right. `trustedProxies` (default 1) says how many proxies
of your own sit in front; a CDN in front of Caddy is 2 and moves the answer one
further left. `trustedProxies: 0` means the server is exposed directly, so every
forwarded header is client-written and none is evidence — the result is
"unknown" rather than a number that looks like proof.

Verified against the fleet's actual topology rather than assumed: DNS resolves
straight to the box, no CDN, one Caddy 2.11.4 with no trusted_proxies
configured, so exactly one hop is appended.

BREAKING: the returned identity changes behind a proxy — which is the point.
v0.2.0. Adopters pinning #v0.1.0 keep the bypass until they move.


Claude-Session: https://claude.ai/code/session_018waGt1ieA9TjpscqrbrnGb

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 19:51:09 +02:00
Mao Nakamoto b15a5384ae chore(ci): GitHub owner maonakamoto -> catomean 2026-08-27 19:18:38 +02:00
Mao NakamotoandClaude Opus 5 9010598cab feat: limitkit — rate limiting as a decision, extracted from twelve copies
Twelve near-identical rate limiters existed across nine repos of this fleet.
orangecat alone carried four, and its ADR-0002 to unify them sat "Proposed" for
seven months while the count doubled — the measured proof that writing a plan
down is not the same as extracting the code.

What actually varied between the twelve was ONE thing: where the counts live
(eleven in process memory, one in Upstash). Everything else — window
arithmetic, refusal shape, headers, client-IP extraction — was the same idea
written twelve slightly different ways, with independently re-invented bugs.
So the algorithm is fixed and the store is the seam:

  slidingWindow / fixedWindow  pure over store + clock. Both shapes shipped in
                               the fleet, and they refuse differently; the
                               choice is now named at the call site instead of
                               implied by whichever file got copied.
  Store / MemoryStore          two methods. The default is BOUNDED (LRU past
                               maxKeys): one replaced implementation kept a
                               bare Map keyed by stranger IPs with no eviction
                               — a slow memory leak fed by the public
                               internet, now impossible by construction.
  toHeaders / clientIp         the HTTP edges everyone also rewrote. Standard
                               X-RateLimit-* trio, Retry-After on refusals
                               only — exactly what orangecat's ADR specified.

Two decisions worth naming:

  A REFUSAL COUNTS NOTHING. Several replaced implementations let refused
  requests extend the window, so a scripted attacker hammering a key locked
  the legitimate user behind the same NAT out indefinitely. Here a hammered
  key recovers the moment the attacker stops; there is a test for exactly
  this shape.

  retryAfterSeconds IS DERIVED, never fabricated — computed from when the
  oldest counted hit ages out. "Try again shortly" on a window that opens in
  an hour is the same lie ai-ration's 429 classifier exists to prevent, one
  layer down.

Deliberately not included, per SHARED.md's extraction rules: no HTTP client,
no middleware, no framework types, no distributed store (the seam is two
methods; your Redis is your ops posture), and NO LIMIT VALUES — how many
attempts a login route allows is app semantics, asserted locally.

Every function takes `now` as an argument, so all of it is testable without
sleeping — which is why this package has 14 tests and the twelve files it
replaces, collectively, had almost none. Tests import the package BY NAME, so
the exports map is exercised on every run, not at the first consumer's
install.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 15:55:38 +02:00