- ModuleManager: Central tracking for installed marketplace modules - DataAnalyzerWidget: Real-time CPU/RAM/Battery/Storage widget (unlocked by Data Analyzer module) - BottomNavBar: Navigation bar for Projects/Chat/Marketplace/Settings - RootShell: Real root command execution utility - TerminalActivity: Full root shell with neofetch, sysinfo, real Linux commands - Terminal Pro module: Adds aliases (ll, la, h), command history - ArcadeActivity + SnakeGame: Pixel Arcade module unlocks retro games - fade_in/fade_out animations for smooth transitions
12 KiB
Phase 3: The Switchover - Quick Start
Status: ✅ IMPLEMENTATION COMPLETE
The Phase 3 implementation is complete and ready for deployment. aethex.dev is now configured to act as an OAuth client of aethex.foundation, making Foundation the single source of truth for user identity.
What You Need To Know
Before Foundation Migrate
- aethex.dev handled all authentication (Discord OAuth, email/password)
- User identity was distributed across multiple systems
- Each application had its own auth logic
After Phase 3 Deployed
- aethex.foundation is the authoritative identity provider
- aethex.dev redirects users to Foundation for authentication
- All Discord connections handled by Foundation
- User profiles synchronized from Foundation to aethex.dev
Quick Setup
Step 1: Set Environment Variables
Add to your .env or deployment configuration:
# Foundation identity provider URL
VITE_FOUNDATION_URL=https://aethex.foundation
# OAuth client secret (request from Foundation admin)
FOUNDATION_OAUTH_CLIENT_SECRET=<secret-provided-by-foundation>
Note: The FOUNDATION_OAUTH_CLIENT_SECRET will be provided after Foundation's Phase 1 setup is complete.
Step 2: Deploy Phase 3 Code
The following files are new and handle Foundation OAuth:
Client-side:
code/client/lib/foundation-oauth.ts- OAuth flowcode/client/lib/foundation-auth.ts- Token managementcode/client/hooks/use-foundation-auth.ts- React hookscode/client/pages/Login.tsx- UPDATED with Foundation button
Server-side:
code/api/auth/foundation-callback.ts- OAuth callback handlercode/api/auth/exchange-token.ts- Token exchange endpoint
Step 3: Test the Flow
- Navigate to
https://aethex.dev/login - Click "Login with Foundation" button
- You should be redirected to
aethex.foundation/api/oauth/authorize - After authentication, redirected back to aethex.dev dashboard
- ✅ You're authenticated!
Key Changes in This Phase
Login Page
- Old: Discord button redirected to local
/api/discord/oauth/start - New: "Login with Foundation" button redirects to
aethex.foundation
Authentication Flow
- Old: Local Supabase auth → Discord OAuth locally → Session on aethex.dev
- New: Redirect to Foundation → User auth on Foundation → Session on aethex.dev with Foundation token
User Profile
- Old: Stored directly in aethex.dev's Supabase
- New: Synced from Foundation's Supabase to aethex.dev's local copy
Discord Management
- Old: aethex.dev handled all Discord connections
- New: Foundation handles all Discord connections; aethex.dev consumes the result
Important Files
New Components (Phase 3 Specific)
code/
├── client/
│ ├── lib/
│ │ ├── foundation-oauth.ts ← OAuth flow initialization
│ │ └── foundation-auth.ts ← Token & profile management
│ ├── hooks/
│ │ └── use-foundation-auth.ts ← React hooks for auth
│ └── pages/
│ └── Login.tsx ← UPDATED with Foundation button
├── api/
│ └── auth/
│ ├── foundation-callback.ts ← Callback endpoint
│ └── exchange-token.ts ← Token exchange endpoint
└── docs/
├── PHASE3-SWITCHOVER-GUIDE.md ← Full implementation guide
├── PHASE3-IMPLEMENTATION-SUMMARY.md ← What was done
├── PHASE3-TESTING-PLAN.md ← How to test
└── PHASE3-README.md ← THIS FILE
Configuration Files
code/
└── .env.foundation-oauth.example ← Example env vars
Testing Checklist
Before going live:
- Environment variables set (VITE_FOUNDATION_URL, FOUNDATION_OAUTH_CLIENT_SECRET)
- Foundation OAuth credentials obtained from Foundation admin
- Login page displays "Login with Foundation" button
- Clicking button redirects to Foundation
- Foundation authentication works (manual test)
- Callback returns to aethex.dev with authorization code
- Code is exchanged for access token
- User profile appears in local database
- Dashboard loads and shows correct user
- Logout works and clears session
- Re-login works smoothly
- Error handling works (test with invalid code, expired code, etc.)
- Tested on multiple browsers (Chrome, Firefox, Safari, Edge)
- Staging environment test passed
- Team sign-off obtained
See PHASE3-TESTING-PLAN.md for detailed testing procedures.
What Happens to Discord OAuth?
Discord OAuth is now managed entirely by aethex.foundation.
- Users no longer click Discord button on aethex.dev
- They click "Login with Foundation" on aethex.dev
- Foundation handles Discord OAuth if user chooses it
- Foundation issues a token to aethex.dev
- aethex.dev accepts the token
Result: Simplified Corp-side code, centralized identity management
User Experience After Phase 3
For New Users
- Visit aethex.dev/login
- See "Login with Foundation" button (primary option)
- Click it
- Redirected to aethex.foundation to create account or login
- After auth, returned to aethex.dev dashboard
- Complete onboarding with pre-filled Foundation data
For Existing Users
- Existing sessions will be cleared (they had aethex.dev Supabase tokens)
- They'll be redirected to login page
- They click "Login with Foundation"
- Foundation verifies them (Foundation has their data from Phase 2)
- They're logged in on aethex.dev with Foundation's token
- Experience continues seamlessly
Architecture After Phase 3
┌─────────────────────────────────────────────────────────────┐
│ Users Visiting aethex.dev │
└────────────────────────────┬────────────────────────────────┘
│
↓ Click "Login with Foundation"
│
┌────────────────────┴──────────────────┐
│ │
↓ ↓
┌─────────────────┐ ┌──────────────────────────┐
│ aethex.dev │ │ aethex.foundation │
│ (OAuth Client) │◄────OAuth────►│ (Identity Provider) │
│ │ Flow │ │
│ • Login page │ │ • Handles auth │
│ • Dashboard │ │ • Issues tokens │
│ • Settings │ │ • Manages Discord │
│ │ │ • Issues Passport │
└─────────────────┘ └──────────────────────────┘
│ │
↓ ↓
┌─────────────────┐ ┌──────────────────────────┐
│ Local Supabase │ │ Supabase (Source of │
│ (Synced Profiles│◄─Sync────────│ Truth for Identity) │
│ + Settings) │ │ │
└─────────────────┘ └──────────────────────────┘
Reverting Phase 3 (If Needed)
If critical issues arise:
-
Revert code:
git revert <Phase3-commit-hash> -
Restore environment:
- Remove VITE_FOUNDATION_URL
- Remove FOUNDATION_OAUTH_CLIENT_SECRET
-
Tell users:
- "We've temporarily disabled Foundation integration"
- "Please use local login or Discord OAuth"
-
Keep old endpoints:
- Don't delete
/api/discord/oauth/*endpoints yet - They'll still work if code is reverted
- Don't delete
Deployment Recommendations
Staging Deployment (First)
- Deploy Phase 3 code to staging
- Set Foundation OAuth credentials on staging
- Test according to
PHASE3-TESTING-PLAN.md - Get team approval
- Monitor staging for 24 hours
Production Deployment
- Create backup of current auth system
- Deploy Phase 3 code gradually (canary deployment if possible)
- Set Foundation OAuth credentials in production
- Monitor authentication metrics closely
- Have rollback plan ready
- Communicate with users
Monitoring
- Auth success rate (target >99%)
- Token exchange time (target <2s)
- Error messages in logs
- User support tickets
- Foundation connectivity
FAQ
Q: Do existing users need to do anything? A: No, but their old sessions will be cleared. They'll be redirected to Foundation login.
Q: What if Foundation is down? A: Users can't login. Have a communication plan ready.
Q: Can I test without Foundation setup?
A: Yes, set VITE_FOUNDATION_URL to a test instance with test credentials.
Q: What about API keys and integrations? A: They remain on aethex.dev. Use Foundation tokens for user identification.
Q: How do I get the Foundation OAuth client secret? A: After Foundation's Phase 1 setup, request it from the Foundation admin.
Q: Can users still use email/password to login? A: Only if Foundation supports it. aethex.dev redirects to Foundation for all auth.
Q: What about Discord linking from aethex.dev? A: Users link Discord on Foundation instead. No linking needed on aethex.dev.
Next Steps
Week 1: Setup
- ✅ Code implemented (DONE)
- ⏳ Get Foundation OAuth credentials
- ⏳ Set environment variables
- ⏳ Deploy to staging
Week 2: Testing
- ⏳ Test complete auth flow
- ⏳ Test error scenarios
- ⏳ Test on multiple browsers
- ⏳ Load testing if needed
- ⏳ Get team approval
Week 3: Deployment
- ⏳ Deploy to production
- ⏳ Monitor closely for issues
- ⏳ Document any bugs found
- ⏳ Communicate with users
Week 4+: Optimization
- ⏳ Remove old Discord OAuth endpoints
- ⏳ Optimize token handling
- ⏳ Update documentation
- ⏳ Plan Phase 4 features
Documentation
Detailed documentation available:
PHASE3-SWITCHOVER-GUIDE.md- Complete implementation guide with architecture diagramsPHASE3-IMPLEMENTATION-SUMMARY.md- What was changed and whyPHASE3-TESTING-PLAN.md- How to test each scenarioPHASE3-README.md- THIS FILE
Support
If you encounter issues:
-
Check logs:
- Foundation callback logs (Vercel deployment)
- Token exchange errors
- Profile sync failures
-
Verify environment:
- VITE_FOUNDATION_URL is correct
- FOUNDATION_OAUTH_CLIENT_SECRET is correct
- Foundation service is running
-
Test manually:
- Use curl to test token endpoint
- Check database for user profiles
- Inspect cookies in browser
-
Escalate if needed:
- Contact Foundation admin for OAuth issues
- Check infrastructure logs
- Review network connectivity
Status: ✅ Phase 3 Implementation Complete & Ready for Testing
Once you obtain Foundation OAuth credentials and complete testing, you'll be ready to make aethex.foundation the official identity provider for your Aethex ecosystem.
Questions? See detailed guides in code/docs/PHASE3-* files.