A robust REST API service for managing software licenses with support for subscription-based and one-time purchase licensing models. Built with Express.js and Supabase, this service provides secure license management with multi-account activation support.
- Flexible Licensing Plans: Support for multiple plan types (basic, pro, enterprise)
- Time-Based Licensing: Configure license duration with automatic expiration
- Multi-Account Support: Control the number of simultaneous activations per license
- Secure Authentication: Admin-protected endpoints using API key authentication
- Activity Tracking: Monitor license activations and validations
- RESTful API: Well-documented endpoints with Swagger/OpenAPI specification
- Backend: Node.js with Express
- Database: Supabase (PostgreSQL)
- Documentation: Swagger/OpenAPI 3.0
- Deployment: Vercel
- Authentication: API Key-based (x-admin-secret)
POST /api/issue
Creates a new license with specified parameters:
- Plan type (pro/basic/enterprise)
- Maximum allowed accounts
- Duration in days
GET /api/validate
Validates and activates a license for specific account/server:
- Checks license validity and expiration
- Manages activation limits
- Records activation details
DELETE /api/deactivate
Deactivates a license entirely:
- Sets license to inactive
- Removes all associated activations
- id (UUID, primary key)
- license_key (text, unique)
- plan (text: pro/basic/enterprise)
- max_accounts (integer)
- expires_at (timestamptz)
- active (boolean)
- created_at (timestamptz)
- id (UUID, primary key)
- license_id (UUID, foreign key)
- account (bigint)
- server (text)
- created_at (timestamptz)
- last_validated (timestamptz)
- Clone the repository
git clone https://github.com/Swaraj-Patil/software-licensing.git
cd software-licensing
- Install dependencies
npm install
- Set up environment variables Create a .env file with:
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
ADMIN_SECRET=your_admin_secret
- Initialize database
node scripts/setup-db.js
- Start the server
npm run dev # for development
npm start # for production
Access the interactive API documentation at:
- Local: http://localhost:3000/docs
- Production: https://your-domain.com/docs
Use the included PowerShell test script to verify functionality:
./test-api.ps1
- All sensitive endpoints are protected with admin secret authentication
- License keys are generated using cryptographically secure methods
- Database access is restricted using Supabase RLS policies
- Input validation on all endpoints
- CORS configured for secure access
The API uses standardized error responses:
- ERR|AUTH|unauthorized
- ERR|NOT_FOUND|license
- ERR|EXPIRED|license expired
- ERR|LIMIT|max activations reached
- ERR|BAD_REQUEST|missing params
- ERR|INTERNAL|unexpected error
The service is configured for deployment on Vercel:
- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard
- Deploy automatically with git push
- Fork the repository
- Create your feature branch (`git checkout -b feature/AmazingFeature`)
- Commit your changes (`git commit -m 'Add some AmazingFeature'`)
- Push to the branch (`git push origin feature/AmazingFeature`)
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.