143 lines
No EOL
4.3 KiB
Markdown
143 lines
No EOL
4.3 KiB
Markdown
# Web OSCAR Chat
|
||
|
||
A small browser chat client for [Open OSCAR Server](https://github.com/mk6i/open-oscar-server). It provides a simple web UI for basic AIM/ICQ-style messaging using a Node.js/Express backend.
|
||
|
||
> **Status:** early project. Review configuration and security before exposing it to the public.
|
||
|
||
## Features
|
||
|
||
- Sign in with an existing OSCAR screen name/password
|
||
- Simple math bot check on login
|
||
- Configurable server host/Web API port/TOC port on login (defaults prefilled)
|
||
- 1:1 instant messages
|
||
- Buddy list with online/away/offline status dots (presence updates when provided)
|
||
- Add buddy
|
||
- Group chat join/send/leave via TOC
|
||
- Chat invites (Join/Ignore) via TOC
|
||
- Real-time updates via SSE
|
||
- TOC connection status indicator
|
||
|
||
## Not supported
|
||
|
||
This is not a full OSCAR client. Not yet supported: offline messages, file transfer, buddy icons, away/profile/status messages, typing notifications, blocking/warning management, chat moderation/admin, account registration, encryption, and full user directory/search.
|
||
|
||
## Requirements
|
||
|
||
- Node.js **20.19+**
|
||
- npm
|
||
- A running [Open OSCAR Server](https://github.com/mk6i/open-oscar-server)
|
||
- Access to the server’s Web API and/or TOC listener
|
||
|
||
## Quick start
|
||
|
||
```bash
|
||
git clone https://git.claytonia.net/Clarth/oscar-web.git
|
||
cd oscar-web
|
||
npm install
|
||
cp .env.example .env
|
||
# edit .env
|
||
npm run dev
|
||
```
|
||
|
||
Open `http://localhost:3000` (or your configured `PORT`).
|
||
|
||
For a normal run:
|
||
|
||
```bash
|
||
npm start
|
||
```
|
||
|
||
## Configuration
|
||
|
||
Copy `.env.example` to `.env` and set values for your environment.
|
||
|
||
| Variable | Description | Default |
|
||
|---|---|---|
|
||
| `WEBAPI_HOST` | Open OSCAR Web API host | `127.0.0.1` |
|
||
| `WEBAPI_PORT` | Open OSCAR Web API port | `8081` |
|
||
| `TOC_HOST` | TOC host for IM/chat/invites | unset |
|
||
| `TOC_PORT` | TOC port | `9898` |
|
||
| `MANAGEMENT_HOST` | Management API host (optional user search) | `127.0.0.1` |
|
||
| `MANAGEMENT_PORT` | Management API port | `8080` |
|
||
| `PORT` | Port this app listens on | `3000` |
|
||
| `LISTEN_HOST` | Address this app binds to | `127.0.0.1` |
|
||
| `TRUST_PROXY` | Number of proxy hops in front of app | `1` |
|
||
| `COOKIE_SECURE` | Session cookie secure mode: `auto`, `true`, `false` | `auto` |
|
||
| `SESSION_MAX_AGE_HOURS` | Session lifetime in hours | `24` |
|
||
| `DB_PATH` | SQLite DB path for sessions | `./data/oscar-web.sqlite` |
|
||
| `SESSION_SECRET` | Long random secret for cookie signing | required |
|
||
| `NODE_ENV` | Runtime mode (`production` recommended behind HTTPS proxy) | `development` |
|
||
|
||
## Deployment (public / reverse proxy)
|
||
|
||
This app is intended to run behind HTTPS nginx.
|
||
|
||
### 1. App environment
|
||
|
||
Set these for public deployment:
|
||
|
||
```env
|
||
LISTEN_HOST=127.0.0.1
|
||
PORT=3000
|
||
TRUST_PROXY=1
|
||
COOKIE_SECURE=true
|
||
SESSION_SECRET=replace-with-a-long-random-secret
|
||
NODE_ENV=production
|
||
```
|
||
|
||
Protect `.env`:
|
||
|
||
```bash
|
||
chmod 600 .env
|
||
```
|
||
|
||
Run as a dedicated non-root user.
|
||
|
||
### 2. Nginx
|
||
|
||
- Redirect HTTP to HTTPS
|
||
- Use a valid TLS certificate
|
||
- Set HSTS
|
||
- Forward `X-Forwarded-*` headers
|
||
- Disable buffering for SSE (`/api/events`)
|
||
|
||
Example location for SSE:
|
||
|
||
```nginx
|
||
location /api/events {
|
||
proxy_pass http://127.0.0.1:3000;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
proxy_set_header Connection '';
|
||
proxy_buffering off;
|
||
proxy_cache off;
|
||
proxy_read_timeout 1h;
|
||
}
|
||
```
|
||
|
||
For all other routes, proxy normally to `http://127.0.0.1:3000`. See `deploy/nginx.conf.example` for a full example.
|
||
|
||
### 3. Firewall / process
|
||
|
||
- Do **not** expose port `3000` publicly; bind to `127.0.0.1`.
|
||
- Run with a process manager (e.g. systemd) and restart on failure. See `deploy/oscar-web.service.example`.
|
||
- Sessions are stored in SQLite; corrupted DB files are rotated aside and recreated automatically. Run as a single process.
|
||
|
||
## Security notes
|
||
|
||
- Sessions are stored in SQLite (`DB_PATH`). If the DB is malformed/corrupt, the app rotates it aside and starts fresh so it can continue running.
|
||
- SSE connections are limited to 3 per IP.
|
||
- The app includes Helmet/CSP, basic rate limits, input normalization/length limits, and fetch timeouts.
|
||
- Use HTTPS only, keep dependencies updated (`npm audit`), and monitor logs/auth failures.
|
||
|
||
## Development
|
||
|
||
- Backend: Node.js, Express, ES modules
|
||
- Frontend: plain HTML/CSS/JavaScript (no build step)
|
||
- Real-time events: SSE (`/api/events`)
|
||
|
||
## License
|
||
|
||
Add a license file before distributing publicly. |