[READ-ONLY] Mirror of https://github.com/aaronateataco/ExophaseVerify. Discord verification for the exophaseAchievements equicord plugin. exophaseverify.vercel.app
Files
README.md

exophase-verify #

Backend for the Exophase Equicord plugin: verifies a configured Exophase username actually belongs to the Discord account (via matching Steam/Epic connection names), then serves that verification + cloud settings so achievements can render on other people's profiles too.

Endpoints #

  • GET /api/verify/start?exophaseUsername=<name>&code=<client-generated> → redirects to Discord OAuth
  • GET /api/verify/callback → OAuth callback, does the match, writes KV, shows a static "you can close this tab" page
  • GET /api/verify/poll?code=<same code> → { status: "pending" } until the callback finishes, then the full result (one-time read, deletes after returning)
  • GET /api/users/:discordId → public read: { verified, exophaseUsername, hiddenSections }
  • PUT /api/users/:discordId/settings → Authorization: Bearer <settingsToken>, body { hiddenSections: string[] }

Verify flow (plugin side) #

OAuth has to open in a real external browser tab — plugin rules forbid opening it in-client — which means there's no window.opener for the callback page to postMessage back through. Instead:

  1. Plugin generates a random code locally (e.g. crypto.randomUUID()).
  2. Plugin opens https://<domain>/api/verify/start?exophaseUsername=<local setting>&code=<code> via VencordNative.native.openExternal.
  3. Plugin polls GET /api/verify/poll?code=<code> every ~2s.
    • { status: "pending" } → keep polling (give up after ~5 min, matching the KV TTL)
    • { status: "success", settingsToken, matchedPlatforms, ... } → store settingsToken via DataStore, mark verified
    • { status: "failed", reason, noEligibleConnections, ... } → show reason to the user directly in plugin UI (no browser round-trip needed to see why it failed)

Setup #

  1. Create a Discord app at https://discord.com/developers/applications (OAuth2 tab only, no bot needed). Add redirect URI: https://<your-vercel-domain>/api/verify/callback

  2. Deploy:

npm i -g vercel
vercel link
vercel kv create exophase-verify-kv   # or add via Storage tab in dashboard
vercel env add DISCORD_CLIENT_ID
vercel env add DISCORD_CLIENT_SECRET
vercel env add DISCORD_REDIRECT_URI
vercel env add SETTINGS_TOKEN_SECRET   # openssl rand -hex 32
vercel --prod
  1. In the plugin, follow the poll-based flow above — see "Verify flow (plugin side)".

Testing #

Pure matching logic (no network, no deploy needed):

npm install
npx tsx test/match.test.ts

Live endpoint smoke tests, once deployed:

# Public read for a never-verified user — expect 404
curl -i https://exophaseverify.vercel.app/api/users/123456789

# Poll a code that was never issued — expect { "status": "pending" }
curl -i https://exophaseverify.vercel.app/api/verify/poll?code=doesnotexist

# Full verify flow — generate a code, open the browser, then poll
CODE=$(python3 -c "import uuid; print(uuid.uuid4())")
echo "Open this in a browser and approve:"
echo "https://exophaseverify.vercel.app/api/verify/start?exophaseUsername=<your-exophase-username>&code=$CODE"
# after approving in the browser:
curl -s "https://exophaseverify.vercel.app/api/verify/poll?code=$CODE" | python3 -m json.tool
  • Discord access tokens are never persisted — used once per verification, then discarded in the same request.
  • settingsToken is a signed, 30-day HMAC token (see lib/token.ts), not a session — re-verifying issues a new one and invalidates the old (KV stores a hash, checked on every PUT).
  • Rate limiting on GET /api/users/:discordId is a naive fixed-window IP counter in KV (30 req/min/IP) — fine at personal scale, revisit if abused.
  • connected_platforms on the Exophase summary response is just an array of display-name strings — the actual per-platform username lives in platforms[].platform_username. Matching is done against platforms, not connected_platforms.
  • Matching only ever checks Steam and Epic Games (the only two Discord connection types that reliably carry a public username comparable to Exophase's). PSN/Xbox/etc. aren't linkable through Discord's connections API at all, so there's nothing to match them against.