@kodeme-io/next-core-license
v0.8.4
Published
License validation system for next-core packages
Maintainers
Readme
@next-core/license
License validation system for next-core packages.
Features
- ✅ JWT-based license keys (cryptographically secure)
- ✅ Offline validation (no server required)
- ✅ Development mode bypass (works on localhost)
- ✅ 30-day grace period for expired licenses
- ✅ Multiple license tiers (basic, pro, enterprise)
- ✅ Feature flags support
- ✅ CLI tool for generating and validating licenses
Installation
npm install @next-core/licenseUsage
For End Users (Adding License to Project)
Add your license key to .env.local:
NEXT_CORE_LICENSE_KEY=nc_prod_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...That's it! The license will be automatically validated when you use @next-core packages.
For Administrators (Generating Licenses)
Generate a License
# Generate a production license for 1 year
npx @next-core/license generate \
--org "ABC Food" \
--project "Jakarta SFA" \
--tier pro \
--days 365 \
--env prodValidate a License
npx @next-core/license validate nc_prod_eyJhbGciOiJIUzI1...View License Information
npx @next-core/license info nc_prod_eyJhbGciOiJIUzI1...CLI Commands
generate - Generate a new license
Required options:
-o, --org <name>- Organization name-p, --project <name>- Project name
Optional options:
-c, --contact <email>- Contact email (default: [email protected])-t, --tier <tier>- License tier: basic, pro, enterprise (default: pro)-d, --days <days>- Days until expiration (default: 365)-e, --env <env>- Environment: dev, prod, test (default: prod)-f, --features <features>- Comma-separated features--max-projects <number>- Maximum number of projects--domains <domains>- Comma-separated allowed domains-s, --secret <secret>- JWT secret
Example:
npx @next-core/license generate \
--org "ABC Food" \
--project "Bandung LFA" \
--tier enterprise \
--days 365 \
--env prod \
--features "ui,auth,odoo-api,pwa,gps,s3,maps" \
--contact "[email protected]"validate - Validate a license
npx @next-core/license validate nc_prod_eyJhbGciOiJIUz...With grace period:
npx @next-core/license validate --grace nc_prod_eyJhbGciOiJIUz...info - Display license information
npx @next-core/license info nc_prod_eyJhbGciOiJIUz...example - Show usage examples
npx @next-core/license exampleProgrammatic Usage
Validating a License
import { LicenseValidator } from '@next-core/license'
const validator = new LicenseValidator('your-secret-key')
const result = validator.validate(licenseKey)
if (result.valid) {
console.log('License is valid!')
console.log('Organization:', result.data?.org)
console.log('Tier:', result.data?.tier)
} else {
console.error('License is invalid:', result.reason)
}With Grace Period
const result = validator.validateWithGrace(licenseKey)
if (result.valid && result.warning) {
console.warn('License validation warning:', result.warning)
}Generating a License
import { generateLicense } from '@next-core/license'
const license = generateLicense(
{
org: 'ABC Food',
project: 'Jakarta SFA',
tier: 'pro',
expiresIn: 365 * 24 * 60 * 60, // 1 year in seconds
environment: 'prod',
},
'your-secret-key'
)
console.log('License:', license)License Tiers
Basic
- Core UI components
- Authentication
- Odoo API client
Default features: ui, auth, odoo-api
Pro (Recommended)
- Everything in Basic
- PWA components
- GPS utilities
- S3 storage
- Partner & Product modules
Default features: ui, auth, odoo-api, partner, product, pwa, gps, s3
Enterprise
- Everything in Pro
- N8N integration
- Maps support
- QR code scanning
- Custom features
Default features: ui, auth, odoo-api, partner, product, n8n, pwa, gps, s3, maps, qr, custom
License Key Format
nc_{environment}_{jwt_token}Prefixes:
nc_dev_- Development licensenc_prod_- Production licensenc_test_- Testing license
Example:
nc_prod_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJuZXh0LWNvcmUiLCJzdWIiOiJKYWthcnRhIFNGQSIsImlhdCI6MTcyODIxMDAwMCwiZXhwIjoxNzU5NzQ2MDAwLCJ0aWVyIjoicHJvIiwiZmVhdHVyZXMiOlsidWkiLCJhdXRoIiwib2Rvby1hcGkiLCJwYXJ0bmVyIiwicHJvZHVjdCIsInB3YSIsImdwcyIsInMzIl0sIm9yZyI6IkFCQyBGb29kIiwiY29udGFjdCI6InN1cHBvcnRAYWJjZm9vZC5jb20iLCJlbnZpcm9ubWVudCI6InByb2QifQ.xYzABCDEFGH123456Development Mode
In development mode (localhost), license validation is automatically bypassed:
// No license needed for development!
npm run dev // Works without NEXT_CORE_LICENSE_KEYDevelopment mode is detected when:
NODE_ENV=developmentorNODE_ENV=test- AND not running on deployment platforms (Vercel, Netlify, Railway)
Grace Period
If a license expires, a 30-day grace period is automatically activated:
- First expiration check starts grace period
- App continues to work for 30 days
- After grace period, license must be renewed
Track grace period:
- Server:
NEXT_CORE_GRACE_PERIOD_STARTenvironment variable - Client:
next_core_grace_period_startlocalStorage key
Environment Variables
For End Users
# Required in production
NEXT_CORE_LICENSE_KEY=nc_prod_eyJhbGciOiJIUz...For Administrators
# Required for generating licenses
NEXT_CORE_LICENSE_SECRET=your-secret-key-here
# Optional: track grace period (auto-set)
NEXT_CORE_GRACE_PERIOD_START=2025-10-06T00:00:00.000ZSecurity Best Practices
Protect Your Secret
- Never commit
NEXT_CORE_LICENSE_SECRETto git - Use environment variables
- Different secrets for dev/prod
- Never commit
Secure License Distribution
- Send licenses via secure channels (email, Slack DM)
- Document who has which licenses
- Implement rotation policy
Monitor Usage
- Keep track of active licenses
- Set up expiration reminders
- Review licenses quarterly
Troubleshooting
"License key not found"
Problem: NEXT_CORE_LICENSE_KEY not set in environment
Solution:
- Create
.env.localfile - Add
NEXT_CORE_LICENSE_KEY=nc_prod_... - Restart development server
"License expired"
Problem: License has passed expiration date
Solution:
- Check grace period status
- Contact administrator for renewal
- Generate new license with extended date
"Invalid license signature"
Problem: License key is corrupted or secret mismatch
Solution:
- Verify license key is complete (not truncated)
- Check if using correct secret
- Request new license if corrupted
"License environment mismatch"
Problem: Using dev license in production or vice versa
Solution:
- Check
NODE_ENVsetting - Use correct license type for environment
- Generate new license for target environment
Support
For license issues:
- Internal teams: Contact DevOps team
- External clients: [email protected]
License
MIT © ABC Food Development Team
