17 Commits

Author SHA1 Message Date
Keysat 238689ddcc Persist payment-webhook dedup; declare BTCPay required; scope CORS
Replace the in-memory dedup Sets in the BTCPay and Zaprite webhook
handlers (and the BTCPay rescan path) with a persistent JSON-backed
store (server/webhook-dedup.js). The in-memory sets were cleared on
restart, so a duplicate webhook delivery straddling a relay restart
could double-credit (BTCPay) or double-extend a subscription (Zaprite).
The store atomically writes /data/processed-webhooks.json, namespaces
keys per rail (storeId|invoiceId vs zaprite:orderId), and prunes
entries older than 180 days (safely beyond any retry window).

Also:
- BTCPay is a required running dependency (operator decision). Config
  was already optional:false/kind:'running'; corrected the contradictory
  "optional" comment in the manifest to match.
- Scope cors() to /relay/* only — off /admin/* and the same-origin
  dashboard, which don't need permissive CORS.
- Add money-path unit tests (commitCredit/refundCredit/applyTierPromotion)
  and webhook-dedup tests (incl. the survives-a-restart guarantee).
- Fix two AGENTS.md auth-doc drifts; refresh Current state.

Version 0.2.125 -> 0.2.126.
2026-06-15 18:15:00 -05:00
Keysat 798a698132 Add Users dashboard tab with per-user balances and credit grants
New cookie-gated "Users" tab on the operator dashboard: a sortable view
of every credit-ledger row (typed cloud/license/install) with computed
remaining/total balances, key filter, and a per-row "grant free credits"
action.

Endpoints (routes/admin.js):
- GET /admin/credits — snapshotAll() enriched with a type derived from
  the credit-key prefix and a computed balance (computeRemaining against
  live tier quotas), since the ledger stores consumed counters only.
- POST /admin/credits/grant {credit_key, amount} — adds free top-up via
  addPurchasedCredits. Grants land in the never-expires purchased bucket
  (spent after the tier allowance). Guards: positive integer, <=1,000,000,
  and the row must already exist (a typo can't spawn a ghost row).

Admin-only; no /relay/* client contract change. Tests added in
server/test/admin-credits.test.js (mount the real router over HTTP).
Version bumped 0.2.124 -> 0.2.125.
2026-06-15 16:25:14 -05:00
Keysat 1243f4414c Package v0.2.12→v0.2.124: manifest, actions, version graph 2026-06-13 13:36:30 -05:00
Keysat 0aa648706e Add self-serve billing: tiers, credits, BTCPay and Zaprite 2026-06-13 13:36:05 -05:00
local b7f75904bb v0.2.11 /relay/capabilities + /relay/transcribe-url (yt-dlp in container) 2026-05-12 01:33:34 -05:00
local 0a0fa009ec v0.2.10 hardware backend URL normalization + path fallback 2026-05-12 01:00:48 -05:00
local 8ffc3ffb73 v0.2.9 Gemini model selects + fallback chain 2026-05-12 00:45:41 -05:00
local 05ebeb5d51 v0.2.8 operator dashboard with per-call audit log + cost tracking 2026-05-12 00:26:59 -05:00
local 9af70302b1 v0.2.7 configurable Gemini models + per-pipeline backend preference 2026-05-12 00:15:07 -05:00
local cd377683fb v0.2.6 calendar-anniversary billing 2026-05-11 23:02:57 -05:00
local 45c8462fa2 v0.2.5 grouped actions 2026-05-11 22:12:02 -05:00
local e612e8b8e8 v0.2.4 max-monthly union + /relay/policy 2026-05-11 22:02:38 -05:00
local 6797aae404 v0.2.3 Core tier 10/5/5 split + dynamic health version 2026-05-11 21:53:50 -05:00
local 07fe14010c v0.2.2 balance peek endpoint 2026-05-11 21:34:31 -05:00
local c9f051cd07 v0.2.1 model names config-driven 2026-05-11 20:27:19 -05:00
local cccbee27e4 v0.2 hardware backend 2026-05-11 20:14:50 -05:00
local b9d86fa303 initial relay scaffold 2026-05-11 20:03:27 -05:00