Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/aaronateataco/ExophaseVerify. Discord verification for the exophaseAchievements equicord plugin. exophaseverify.vercel.app
Something went wrong. Try again.
Files
- TypeScript 100%
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 OAuthGET /api/verify/callback→ OAuth callback, does the match, writes KV, shows a static "you can close this tab" pageGET /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:
- Plugin generates a random
codelocally (e.g.crypto.randomUUID()). - Plugin opens
https://<domain>/api/verify/start?exophaseUsername=<local setting>&code=<code>viaVencordNative.native.openExternal. - 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, ... }→ storesettingsTokenviaDataStore, mark verified{ status: "failed", reason, noEligibleConnections, ... }→ showreasonto the user directly in plugin UI (no browser round-trip needed to see why it failed)
Setup #
-
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 -
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
- 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.
settingsTokenis a signed, 30-day HMAC token (seelib/token.ts), not a session — re-verifying issues a new one and invalidates the old (KV stores a hash, checked on everyPUT).- Rate limiting on
GET /api/users/:discordIdis a naive fixed-window IP counter in KV (30 req/min/IP) — fine at personal scale, revisit if abused. connected_platformson the Exophase summary response is just an array of display-name strings — the actual per-platform username lives inplatforms[].platform_username. Matching is done againstplatforms, notconnected_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.