22 Commits

Author SHA1 Message Date
c14d0ab735 feat: team roles with invitations and enforced API key scopes (G9)
Security fix plus team access. Before this change any valid API key,
including access keys the delivery system hands to BUYERS, authenticated
as the merchant on the whole management API, and GET /v1/api-keys listed
every organization's keys. Now only platform keys (issued at sign-up or
via POST /v1/api-keys/platform, marked with the platform product id) can
call the API, and each request needs its resource scope
(<resource>:read|write, write implies read; platform:admin or * for
full access), answered with 403 and details.requiredScope otherwise.
Keys cannot mint broader keys, customer keys cannot carry management
scopes, key listing is tenant-scoped and keys can be revoked by id.

Dashboard sessions get team roles (owner, admin, developer, support,
viewer) mapped to scopes. /v1/team manages members and email
invitations (packages/invitations, token hash only, 7-day expiry);
/v1/auth/invitations/accept joins the org and creates the account. The
last owner is protected and only owners grant owner. Dashboard: Team
page, invite accept page, and an API keys page that creates restricted
keys and shows the secret once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:09:06 +03:00
22c3208b60 feat: merchant accounting exports with Xero and QuickBooks imports (G5)
New tenant-scoped /v1/exports routes: payments, refunds, invoices and
payouts CSVs, a full USDC ledger, and bank statement files that Xero
(DD/MM/YYYY statement import) and QuickBooks Online (three-column bank
upload) import directly, with optional date ranges. packages/exports
gains a formula-injection guard (opt-in, admin unchanged) and the
accounting formatters. The dashboard Payments page links every export
through a session-authenticated download route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:35:58 +03:00
e0caf4bace feat: monthly platform fee statements with plan limits after grace (G1)
SettleKit's advertised per-payment fee was never collected because buyers
pay merchants' wallets directly. When PLATFORM_BILLING_ORG_ID is set, the
API now issues each merchant a monthly statement (confirmed payments x the
fee schedule) as an invoice from SettleKit's own org, paid through the
hosted checkout on the G2 payable-invoice path. Totals below the minimum
carry forward, test accounts are skipped, runs are idempotent and happen
automatically every six hours (or via POST /v1/billing/statements/run).
A statement unpaid past due + grace restricts new products to the free
plan limit from packages/pricing (402 with the pay link). Merchants see
accrued fees, statements and a Pay button on the Balances page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 03:50:08 +03:00
2b2c8b471d chore: merge Tameion operator into main alongside multi-chain SettleKit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 22:43:33 +03:00
e169731b42 chore: merge feat/solana-colosseum into feat/x402-multichain
Brings in packages/routing, packages/hyperliquid (hypercore network), checkout
AnyTokenPay/HyperCorePay, Node 22 pins, tenant-ownership guards and the zcash
tag lock. Only conflict: drizzle _journal.json (kept 0010_onchain_billing and
0011_coupons_organization in order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:39:32 +03:00
7ee993e478 feat(api): onchain subscription, escrow and per-network refund routes
/v1/onchain-billing: networks, subscription intents (what the buyer
signs or sends per network), grant submission with immediate first
charge and entitlement grant, cancel with revoke actions, Base escrow
authorize/capture/void/reclaim, and owner refunds recorded in
@settlekit/refunds and dispatched per network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:19:15 +03:00
2b9172e384 feat(api): HyperCore verifier, Tempo requireMemo sessions and routed-fill bindings
- HYPERCORE_* config; the registry registers a hypercore SettlementVerifier
  (payee ledger via @settlekit/hyperliquid) only when enabled
- checkout sessions accept requireMemo (Tempo only); confirmations then need
  transferWithMemo(keccak256(session id))
- a route provider's stored destination fill skips only the payer and memo
  bindings; hypercore joins the observable networks
- drop the unused @settlekit/routing dependency from the API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:48:20 +03:00
4cf8417728 feat(api): x402 v2 agent payments on Solana and every EVM chain
GET /v1/x402/research (x402 paymentMiddleware) and
POST /v1/x402/products/:productId/buy: one 402 challenge lists every
configured network; Solana/Base/Arbitrum settle through PayAI and
Ethereum/HyperEVM/Robinhood through the self-hosted facilitator, with
explicit per-network facilitator routing. Purchases use the upfront
flow: the facilitator settles BEFORE the handler, then the Payment is
recorded (tx hash unique, 409 on reuse), the entitlement granted and the
product's delivery actions run inline; the artifact is returned with the
PAYMENT-RESPONSE receipt. Product, price and required buyer fields are
validated before any challenge. Also exposes the facilitator's
/supported, /assets and bearer-guarded /verify and /settle, and
GET /v1/x402/networks. Runtime is built from env once at boot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:41:21 +03:00
2134532ba3 fix: drop Solana from the Tameion branch while keeping fail-closed confirmation
The cherry-picked fail-closed payment fixes imported @settlekit/solana, which
does not exist on this branch, breaking tsc -b and the api/worker suites.
Solana verification, env and session references are removed; arc/base/
ethereum keep the per-network verifier registry and the worker keeps
payTo-bound verification. A solana network is now rejected as unsupported
(400 on checkout/observe, unsupported in the worker). Also adds the missing
packages/circle project reference to the api, points the api/worker test
scripts at the root vitest config, and removes the operator's
vitest.apps.config.ts workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:55:28 +03:00
ab302a4b2f chore: document multi-chain env and wire project references
.env.example and render.yaml (api + worker) list SETTLEKIT_CHAIN_ENV,
ENABLED_EVM_CHAINS, per-chain RPC/NETWORK/MIN_CONFIRMATIONS, Solana and
Zcash settings; api/worker tsconfig reference @settlekit/chains and
@settlekit/zcash; the UI explorer map covers every PaymentNetwork.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:25:24 +03:00
2a4864dd49 feat: add operator API routes and public proof endpoints
/v1/operator (API key or dashboard session, scoped to the vault's org):
POST /events (caller org forced, duplicate event ids replay the recorded
decision, single-flight per event), GET /decisions[/:id], POST|GET /bills,
GET /escalations, owner-only POST /escalations/:id/approve|reject, GET and
owner-only PUT /policy which refuses drift from on-chain caps and allowlist.
/v1/public/operator: GET /proof (cached aggregates, demo org excluded) and
GET /verify/:id. Mounted with one route line in app.ts ahead of the v1
API-key group. Escalated bills close when the owner resolves them.

App-level operator tests run through vitest.apps.config.ts because the api
and worker tsconfigs reference packages/solana, absent on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:15:22 +03:00
0dad9a9170 fix: fail closed on payment confirmation without an on-chain verifier
Security: POST /v1/payments/:id/confirm only verified Arc payments; any
other network confirmed with an arbitrary txHash and granted
entitlements. The API now keeps a per-network verifier registry
(ctx.verifiers: arc via the existing Arc client, base via the generic
EVM client + BASE_RPC_URL + Base USDC, solana via @settlekit/solana)
and confirm/observe reject any network without one.

- a transaction hash settles at most one payment (409 on reuse, also
  on record); EVM hashes are normalized to lowercase
- checkout sessions accept network solana, require a base58 payTo and
  get a fresh Solana Pay paymentReference the tx must include
- observe validates hash/address formats per network (base58 vs 0x)
- compliance screening maps solana to Circle's SOL chain
- env: SOLANA_CLUSTER, SOLANA_RPC_URL, SOLANA_USDC_MINT, BASE_RPC_URL,
  BASE_MIN_CONFIRMATIONS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 14:55:35 +03:00
c0b39e38aa fix: fail closed on payment confirmation without an on-chain verifier
Security: POST /v1/payments/:id/confirm only verified Arc payments; any
other network confirmed with an arbitrary txHash and granted
entitlements. The API now keeps a per-network verifier registry
(ctx.verifiers: arc via the existing Arc client, base via the generic
EVM client + BASE_RPC_URL + Base USDC, solana via @settlekit/solana)
and confirm/observe reject any network without one.

- a transaction hash settles at most one payment (409 on reuse, also
  on record); EVM hashes are normalized to lowercase
- checkout sessions accept network solana, require a base58 payTo and
  get a fresh Solana Pay paymentReference the tx must include
- observe validates hash/address formats per network (base58 vs 0x)
- compliance screening maps solana to Circle's SOL chain
- env: SOLANA_CLUSTER, SOLANA_RPC_URL, SOLANA_USDC_MINT, BASE_RPC_URL,
  BASE_MIN_CONFIRMATIONS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 06:24:05 +03:00
pextacy
1d9c55d131 feat(oss-fund): fund maintainers your dependency tree leans on
Add @settlekit/oss-fund: read package.json / requirements.txt (+ optional
lockfile), map the (transitive) dependency graph to maintainer wallets, and
split a small monthly budget across them — settled over the existing
nanopayment spine (payee-registry, x402 Settler, RecursiveSplitDistributor).

The allocation is the core: an engine weighs four signals per package —
directness, reach (criticality), usage, and maintainer underfunding — and the
capability layer converts a proposed weighting into a conserved integer
allocation (legs sum to the budget exactly, only resolvable wallets paid,
unregistered maintainers earmarked to escrow). Two engines, mirroring the paying
agent: a deterministic heuristic (default/CI) and a Claude (claude-opus-4-8)
tool-use brain that proposes weights under the same enforced policy.

- packages/oss-fund: manifest/lockfile parsing, graph + reach, signals,
  resolver, conserved allocation, heuristic + Claude engines, settlement +
  on-chain distributor calldata, realistic seed, CLI, tests (12 passing).
- apps/api: public PUBLIC routes GET /v1/fund/demo and POST /v1/fund/plan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 13:11:38 +03:00
ff11f7754e feat(lepton): nanopayment modules + production settlement spine
Lepton Agents Hackathon (Canteen × Circle × Arc): agent-native nanopayments
on Arc, built on the existing SettleKit platform.

Hackathon modules (demo-ready, RFB-aligned):
- @settlekit/agent: autonomous paying agent (Claude tool-use loop) — RFB 1/3
- @settlekit/citation-toll: per-access content + recursive royalty splits — RFB 6
- @settlekit/streaming: per-second continuous-authorization settlement — RFB 4
- @settlekit/x402-client: x402 pay-and-retry + pluggable settler (local/Circle)
- @settlekit/agent-economy: closed-loop traction harness + CLI
- apps/api /v1/lepton: public live demo surface

Production settlement spine (Phase 1):
- @settlekit/settlement-core: configurable Gateway/Circle/local providers,
  idempotency, batch accumulator, on-chain reconciliation, nonce + receipt stores
- @settlekit/wallet-fleet: registry, spending caps + kill-switch, balances,
  Circle provisioning
- x402-client: provider-settler adapter + Arc-indexer on-chain verifier
- lepton DB schema (12 tables) + persistence Pg stores (settlements, nonces,
  sources, royalty legs, wallets, streams, payees)
- apps/worker jobs: lepton-settlement-reconcile, lepton-payout-sweep,
  lepton-stream-refund (no-op until the settlement spine is wired)

First real-world traction sidecar (Phase 2):
- @settlekit/payee-registry: identity→wallet payout rule (in-memory + Pg)
- services/sidecars/rsshub-citation-toll: ingest RSS items as priced citeable
  sources, x402-gated, settle per-citation royalties via settlement-core
- shared sweepPendingRoyalties used by the worker job and the sidecar
- services/sidecars/* wired as a TS workspace area (pnpm + vitest)

Docs: LEPTON.md, LEPTON_PRODUCTION_PLAN.md. All green: full typecheck + 870 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 14:37:38 +03:00
3a52b61096 adas 2026-06-17 03:02:36 +03:00
3853551433 asad 2026-06-17 02:09:36 +03:00
32b89f0515 firstof 2026-06-16 02:51:34 +03:00
bd3c2a85e5 feat: full-product round 3 — commerce engines wired + worker comms
- apps/api: /v1/refunds, /v1/dunning, /v1/disputes, /v1/payouts routes + context
  services + mounts (refunds/dunning/disputes/payouts engines).
- apps/dashboard: refunds/dunning/disputes/payouts pages + nav + api client + types.
- apps/worker: 9 scheduled jobs incl. receipt, renewal-reminder, dunning, and
  access-granted email jobs via @settlekit/notifications (idempotent, injectable transport).

Full build 0 TS errors; dashboard typecheck clean; 591 tests pass.
2026-06-15 17:25:34 +03:00
5cb0f48db7 feat: full-product round 2 — auth end-to-end + commerce engines
- apps/api: public /v1/auth routes (register/login/magic-link/session/logout) via
  @settlekit/auth, AuthService in context, signed sk_session cookie; existing
  api-key guard untouched (14 api tests intact).
- apps/dashboard + apps/portal: real login/signup UIs (password + magic-link),
  httpOnly session cookie via route handlers, server session helpers, sign-out.
- packages: fleshed refunds, dunning (retry schedules), disputes (state machine),
  payouts (settlement + available-balance) into real engines with stores+services.

Verified: full build 0 TS errors; 591 tests pass; live auth flow
(register->login->session->magic-link->bad-login 401) confirmed end-to-end.
2026-06-15 17:06:29 +03:00
3220b85c57 feat: product expansion — marketing site, customer portal, coupons + invoices
- apps/web: public marketing site (Next.js) — hero/§34, what-you-can-sell grid,
  how-it-works, dev tools, marketplace teaser, /pricing (§32 tiers), /use-cases (§29).
- apps/portal: customer portal (Next.js, §31) — per-customer overview, purchases/
  receipts, license keys, api keys, github/discord access (+re-check), subscriptions,
  downloads; anchored on the universal entitlements layer.
- packages/coupons: real discount engine (percent/amount/free-trial, window, expiry,
  max + per-customer redemptions, min-subtotal, product scoping), bigint USDC math,
  CouponStore + service.
- packages/invoices: real invoicing (line items, discount, @settlekit/tax, statuses,
  HTML/text render), fixed float bug, InvoiceStore + service.
- apps/api: /v1/coupons + /v1/invoices routes wired into context + app.
- apps/dashboard: Coupons + Invoices pages + nav + client methods.

All package + backend builds 0 TS errors; web/portal/dashboard typecheck clean;
590 tests pass (two redesigned coupon/invoice tests updated to the new API).
2026-06-15 12:25:58 +03:00
598cd03f05 feat: implement all 8 SettleKit apps + fix x402 nonce round-trip
apps:
- api: Hono REST server, all §26 endpoints, 14 tests
- worker: delivery runner + payment-confirm + access-sync + renewal + webhook-retry jobs wired to real package clients
- dashboard: Next.js merchant dashboard, full §16/§27 sections + §28 product builder
- checkout: Next.js hosted USDC checkout with real delivery materialization
- marketplace: Next.js public marketplace + agent metadata.json route
- admin: Next.js risk/ops console wired to @settlekit/risk + database
- docs: Next.js docs site (9 static routes)
- examples: 5 runnable end-to-end examples

fix(x402): support pinned config.nonce so a stateless verifier can confirm
the challenge nonce round-trips (default stays random; package tests intact).

Full workspace: 590 tests passing (122 files), tsc green for all packages +
api/worker/examples, all 5 Next apps typecheck clean, docs next build green.
2026-06-15 10:49:14 +03:00