Module: Auth
The Auth module handles authentication with the Arattai platform. It includes QR code login, session persistence, and token-based auth (placeholder for future use).
Source: src/Auth/
Exports
| Class | Source | Description |
|---|---|---|
QRLogin |
Auth/qr-login.js |
Handles QR code authentication flow |
SessionManager |
Auth/session-manager.js |
Saves/loads session cookies to cookies.json |
TokenLogin |
Auth/token-login.js |
Token-based auth (placeholder for future implementation) |
QRLogin
Initiates the QR code login flow. Fetches a QR code from the Arattai accounts server, displays it in the terminal, and polls for the user to scan it.
new QRLogin(session)
- session
AxiosInstance— Axios instance with cookie jar.
initiateLogin()
async
initiateLogin(): Promise<object | null>
Starts the QR login flow. Returns the login response on success, or
null on failure.
SessionManager
Manages session persistence. Saves cookies to cookies.json after successful login
and tests cookie validity on startup to skip QR scanning if possible.
new SessionManager(session)
- session
AxiosInstance— Axios instance with cookie jar.
testCookies()
async
testCookies(): Promise<boolean>
Test if saved cookies are still valid. Returns
true if the session can be reused.
saveSession()
async
saveSession(): Promise<void>
Save current session cookies to
cookies.json.
Authentication Flow
1. ArattixBot.loginWithQr() called
2. SessionManager.testCookies() — check saved session
├─ Valid → return Bot (skip QR)
└─ Invalid → continue
3. QRLogin.initiateLogin() — fetch & display QR code
4. User scans QR with Arattai mobile app
5. SessionManager.saveSession() — persist cookies
6. Return authenticated Bot instance
Note
You typically don't use these classes directly. Use ArattixBot.loginWithQr()
which handles the full flow automatically.