Files
Job-Info/Mode1Svelte/README.md
T
aewing 5a4a3c51e9 Add Mode1Svelte - independent copy of Mode1 for future SvelteKit integration
- Created Mode1Svelte as complete standalone project
- Identical to Mode1 currently (Hono backend + Vite frontend)
- Separate auth-module copy (no dependencies on Mode1)
- Updated orchestrator to default to Mode1Svelte
- Both Mode1 and Mode1Svelte are independent and interchangeable via ModeSwitch
- Ready for gradual Svelte/SvelteKit migration while maintaining API compatibility
2026-01-22 05:53:15 +00:00

159 lines
4.1 KiB
Markdown

# Mode1Svelte - Auth Module Test Suite
Self-contained test environment for the auth-module. This version is identical to Mode1 currently, serving as a foundation for future Svelte integration.
## Structure
```
Mode1Svelte/
├── auth-module/ # Local copy of auth-module (not linked to root)
├── backend/ # Backend server with auth endpoints
│ └── server.ts # Hono app with Graph token and PB validation APIs
├── frontend/ # Frontend test interface
│ └── index.html # Interactive test dashboard
├── logs/ # Application logs
├── package.json # Dependencies (auth module + Hono + PocketBase)
└── bun.lock # Locked dependencies
```
## Features
**Frontend Auth (PocketBaseAuth)**
- OAuth2 login initialization
- Auth state retrieval
- Token refresh
- Logout
**Backend Auth (GraphTokenManager)**
- Microsoft Graph token acquisition
- Token caching (with 60s expiration buffer)
- Cache validity checking
- Cache refresh
**PocketBase Validation (PocketBaseValidator)**
- User token validation
- User record retrieval
- Token comparison (Graph vs PocketBase)
## Running Mode1Svelte
### Via Orchestrator (recommended)
```bash
# Switch to Mode1Svelte
curl -X POST http://localhost:3006/switch/Mode1Svelte
# Check status
curl http://localhost:3006/status
```
### Direct
```bash
cd Mode1Svelte
bun install
PORT=3005 bun run backend/server.ts
```
Then visit: `http://localhost:3005`
## Future: Svelte Integration
This project is set up as an independent Mode to eventually convert to SvelteKit while maintaining the same API endpoints and auth-module integration.
## Structure
```
Mode1/
├── auth-module/ # Local copy of auth-module (not linked to root)
├── backend/ # Backend server with auth endpoints
│ └── server.ts # Hono app with Graph token and PB validation APIs
├── frontend/ # Frontend test interface
│ └── index.html # Interactive test dashboard
├── logs/ # Application logs
├── package.json # Dependencies (auth module + Hono + PocketBase)
└── bun.lock # Locked dependencies
```
## Features Tested
**Frontend Auth (PocketBaseAuth)**
- OAuth2 login initialization
- Auth state retrieval
- Token refresh
- Logout
**Backend Auth (GraphTokenManager)**
- Microsoft Graph token acquisition
- Token caching (with 60s expiration buffer)
- Cache validity checking
- Cache refresh
**PocketBase Validation (PocketBaseValidator)**
- User token validation
- User record retrieval
## Running Mode1
### Via Orchestrator (recommended)
```bash
# Switch to Mode1
curl -X POST http://localhost:3006/switch/Mode1
# Check status
curl http://localhost:3006/status
```
### Direct
```bash
# Install dependencies (already done)
bun install
# Start server
bun run backend/server.ts
# Access dashboard
open http://localhost:3005
```
## API Endpoints
### Configuration
- `GET /api/auth/config` - Get frontend configuration
### Graph Token Management
- `GET /api/auth/graph/token` - Get current Graph token (with expiration)
- `POST /api/auth/refresh-graph` - Force refresh Graph token
### PocketBase Validation
- `POST /api/auth/validate-pb-token` - Validate a PocketBase token
### Health
- `GET /health` - Health check
## Environment Variables
Uses `/home/admin/secrets/.env` via auth-module:
- `CLIENT_ID` - Microsoft application ID
- `TENANT_ID` - Azure tenant ID
- `CLIENT_SECRET` - Microsoft client secret
- `PB_URL` - PocketBase frontend URL
- `PB_DB` - PocketBase backend URL
## Dependencies
All dependencies are installed locally in `node_modules/`:
- `hono` - Web framework
- `pocketbase` - PocketBase client
- `@azure/msal-node` - Microsoft authentication
- `dotenv` - Environment variable loading
## Notes
- This Mode1 is **completely self-contained** with its own auth-module copy
- No dependencies on root auth-module
- Safe to modify and test independently
- All secrets come from `/home/admin/secrets/.env`