Commit Graph
3 Commits
Author SHA1 Message Date
dhkatz f3cc3f9f17 feat(accounts): locked registration, for staging (#27)
Release / release (push) Successful in 4s
CI / test (push) Successful in 1m35s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 5s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 14s
Locks staging down before payments' staging (PayPal's sandbox) exists.

**The problem:** staging's registration is closed, but signing in with Discord still makes an approved basic account at once (`auth.ts`). So any Discord account can sign in to Music's staging.

**The change:** a third registration setting, `locked`:
- Every new account waits for a moderator's approval, Discord sign-ins too.
- Only approved accounts sign in to T5DE's other sites. The gate is the OAuth provider's `postLogin.shouldRedirect`: an unapproved account is sent to the website (which shows "Waiting for Approval") and no code is issued. It runs on every authorize request and on `/oauth2/continue`.
- Finishing setup under `locked` keeps the person's approval, so an approved basic account doesn't lose Music access by becoming a member.
- **Console:** the setting has a "Locked" option. **Website:** the waiting screen for unapproved Discord accounts, and the sign-up page's note.

`open` and `closed` behave as before. Under `closed`, a member waiting for approval still signs in to Music (tested), so prod doesn't change.

**After merging:** infra sets staging's `REGISTRATION` to `locked`. That's only a default: if staging's registration was ever changed in the console, set it to Locked there. Accounts already on staging keep their approval.

**Checks:** `bun test` (77 pass, two new tests), `check-types`, `lint`.

Locks staging down before payments' staging (PayPal's sandbox) exists.

**The problem:** staging's registration is closed, but signing in with Discord still makes an approved basic account at once (`auth.ts`). So any Discord account can sign in to Music's staging.

**The change:** a third registration setting, `locked`:
- Every new account waits for a moderator's approval, Discord sign-ins too.
- Only approved accounts sign in to T5DE's other sites. The gate is the OAuth provider's `postLogin.shouldRedirect`: an unapproved account is sent to the website (which shows "Waiting for Approval") and no code is issued. It runs on every authorize request and on `/oauth2/continue`.
- Finishing setup under `locked` keeps the person's approval, so an approved basic account doesn't lose Music access by becoming a member.
- **Console:** the setting has a "Locked" option. **Website:** the waiting screen for unapproved Discord accounts, and the sign-up page's note.

`open` and `closed` behave as before. Under `closed`, a member waiting for approval still signs in to Music (tested), so prod doesn't change.

**After merging:** infra sets staging's `REGISTRATION` to `locked`. That's only a default: if staging's registration was ever changed in the console, set it to Locked there. Accounts already on staging keep their approval.

**Checks:** `bun test` (77 pass, two new tests), `check-types`, `lint`.

Co-authored-by: dhkatz <[email protected]>
2026-11-20 20:31:32 +00:00
dhkatz 02e8269d4d docs(payments): a payments service of its own, Patreon first (#26)
Release / release (push) Successful in 4s
CI / test (push) Successful in 1m36s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 5s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 4s
Rewrites the payments plan for a separate payments service, with Patreon as the first way to pay.

**docs/payments.md**
- **`t5de-payments` is its own service:** its own repo, Postgres database and secrets, at `payments.t5de.dev`, to contain the compliance risk. The hub and Music never hold a payment provider's key. Music reads entitlements (`GET /v1/entitlements/{sub}`), is told about changes over a signed back-channel call, and keeps the last answer it got.
- **Patreon first:** Patreon is the seller, so it handles sales tax and VAT.
  - **Linking:** members link Patreon with OAuth (`identity`).
  - **Tiers:** which tier gives how much is set in config in git.
  - **Webhook:** the service checks its webhook exists and is set up right on every start, and fixes it if not. Requests are verified with `X-Patreon-Signature` (HMAC-MD5).
  - **State:** after a webhook it re-fetches the member from Patreon, and a nightly sync of every member catches anything missed.
  - **Grace:** access runs until `next_charge_date` plus 7 days.
  - **Tokens:** Patreon rotates the creator token's refresh token, so the current pair is kept in the database.
- **Entitlements are counts** (`music.rooms` × N), because a Patreon member has only one tier. Moderators' grants (no money) come first, in phase 1.
- **Processors:**
  - **Polar:** used only if their support says yes in writing. Its acceptable use policy names YouTube downloaders (#30) and circumventing other services' terms (#18).
  - **Not used:** Stripe or PayPal directly (we'd be the seller), and IMVU credits.

**docs/music.md**
- **The paid tier sells hosting only.** YouTube limits are now the same in both tiers.
- **Tiers:** Room ($1.99, 1 room) and Rooms ($4.99, 3 rooms). The owner picks which rooms are paid. When the count drops, the most recently picked rooms go back to free first.
- The risks section and phase 3b point to t5de-payments.

Rewrites the payments plan for a separate payments service, with Patreon as the first way to pay.

**docs/payments.md**
- **`t5de-payments` is its own service:** its own repo, Postgres database and secrets, at `payments.t5de.dev`, to contain the compliance risk. The hub and Music never hold a payment provider's key. Music reads entitlements (`GET /v1/entitlements/{sub}`), is told about changes over a signed back-channel call, and keeps the last answer it got.
- **Patreon first:** Patreon is the seller, so it handles sales tax and VAT.
  - **Linking:** members link Patreon with OAuth (`identity`).
  - **Tiers:** which tier gives how much is set in config in git.
  - **Webhook:** the service checks its webhook exists and is set up right on every start, and fixes it if not. Requests are verified with `X-Patreon-Signature` (HMAC-MD5).
  - **State:** after a webhook it re-fetches the member from Patreon, and a nightly sync of every member catches anything missed.
  - **Grace:** access runs until `next_charge_date` plus 7 days.
  - **Tokens:** Patreon rotates the creator token's refresh token, so the current pair is kept in the database.
- **Entitlements are counts** (`music.rooms` × N), because a Patreon member has only one tier. Moderators' grants (no money) come first, in phase 1.
- **Processors:**
  - **Polar:** used only if their support says yes in writing. Its acceptable use policy names YouTube downloaders (#30) and circumventing other services' terms (#18).
  - **Not used:** Stripe or PayPal directly (we'd be the seller), and IMVU credits.

**docs/music.md**
- **The paid tier sells hosting only.** YouTube limits are now the same in both tiers.
- **Tiers:** Room ($1.99, 1 room) and Rooms ($4.99, 3 rooms). The owner picks which rooms are paid. When the count drops, the most recently picked rooms go back to free first.
- The risks section and phase 3b point to t5de-payments.

Co-authored-by: dhkatz <[email protected]>
2026-11-20 19:38:01 +00:00
dhkatz a66a3a4b6a docs: Music and shared accounts plan (#21)
Release / release (push) Successful in 3s
CI / test (push) Successful in 1m30s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 8s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 20s
Plan for T5DE Music and the account and payment changes it needs. Docs only; no code changes.

- `docs/music.md`: an IMVU room music bot. The website is music.t5de.dev (at home); streams are radio.t5de.dev (Oracle Cloud's free tier, dhkatz/infra `music-oracle`). Covers one account system with Discord sign-in and basic accounts, the hub as an OIDC provider with Music as its first client, room ownership from linked IMVU accounts, chat commands and permissions, pluggable sources modelled on HorizonRadio's (stations, own streams, YouTube), relayed vs direct streams, and the paid tier (sell the hosting; $1.99 a month per room).
- `docs/payments.md`: billing in the hub's API, shared by Music and the hub. Separate merchants per product (adult content needs different processors), processor adapters, entitlements, credits, and selling as an individual.
- `README.md`: links to both.

Decisions are marked **Decided**; the rest are proposals, with the open ones at the end of each doc.

Plan for T5DE Music and the account and payment changes it needs. Docs only; no code changes.

- `docs/music.md`: an IMVU room music bot. The website is music.t5de.dev (at home); streams are radio.t5de.dev (Oracle Cloud's free tier, dhkatz/infra `music-oracle`). Covers one account system with Discord sign-in and basic accounts, the hub as an OIDC provider with Music as its first client, room ownership from linked IMVU accounts, chat commands and permissions, pluggable sources modelled on HorizonRadio's (stations, own streams, YouTube), relayed vs direct streams, and the paid tier (sell the hosting; $1.99 a month per room).
- `docs/payments.md`: billing in the hub's API, shared by Music and the hub. Separate merchants per product (adult content needs different processors), processor adapters, entitlements, credits, and selling as an individual.
- `README.md`: links to both.

Decisions are marked **Decided**; the rest are proposals, with the open ones at the end of each doc.

Co-authored-by: dhkatz <[email protected]>
2026-11-18 22:29:48 +00:00