@devmonetizer/auth
v0.1.0
Published
Authentication and authorization for Monetizer platform
Maintainers
Readme
@monetizer/auth
Authentication and authorization package for Monetizer platform.
Features
- JWT-based authentication
- User registration and login
- API key management
- Tier-based access control
- SQLite database for user storage
Installation
pnpm add @monetizer/authUsage
import { createAuthHandler, requireAuth } from '@monetizer/auth';
// Initialize auth system
const auth = createAuthHandler({
jwtSecret: process.env.JWT_SECRET,
dbPath: './users.db'
});
// Endpoints
// POST /auth/register - Register new user
// POST /auth/login - Login and get JWT token
// GET /auth/api-keys - List user's API keys
// POST /auth/api-keys - Generate new API key
// Middleware
app.use('/api', requireAuth);Database Schema
CREATE TABLE users (
id TEXT PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
passwordHash TEXT NOT NULL,
tier TEXT NOT NULL DEFAULT 'free',
createdAt INTEGER NOT NULL
);
CREATE TABLE api_keys (
id TEXT PRIMARY KEY,
userId TEXT NOT NULL,
key TEXT UNIQUE NOT NULL,
name TEXT,
lastUsedAt INTEGER,
createdAt INTEGER NOT NULL,
FOREIGN KEY (userId) REFERENCES users(id)
);Tiers
free- Limited accesspro- Standard paid tierenterprise- Full access
API
See source files for detailed API documentation.
