Configure environment variables for @warpy-auth-sdk/core.
@warpy-auth-sdk/core requires several environment variables to function properly. Here's a complete reference for all supported variables.
Required: JWT signing secret for session tokens and CSRF protection.
AUTH_SECRET=your-secret-key-min-32-chars-long-replace-this-in-productionYou can generate a secure secret using Node.js:
// Generate a secure secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Required for Google OAuth authentication:
# Google OAuth credentials
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/callback/googlehttp://localhost:3000/api/auth/callback/googlehttps://yourdomain.com/api/auth/callback/googleRequired for email magic link authentication:
# SMTP configuration for email magic links
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SMTP_FROM=noreply@yourdomain.comSMTP_PASSFor production, consider using dedicated email services:
smtp.sendgrid.net:587smtp.mailgun.org:587email-smtp.us-east-1.amazonaws.com:587smtp.postmarkapp.com:587For session persistence with database adapters:
# PostgreSQL with Prisma
DATABASE_URL="postgresql://username:password@localhost:5432/auth_db"
# MySQL with Prisma
DATABASE_URL="mysql://username:password@localhost:3306/auth_db"
# SQLite (development)
DATABASE_URL="file:./dev.db"For AI agent authentication features:
# Enable MCP features
MCP_ENABLED=true
# Agent token expiration (default: 15m)
MCP_TOKEN_EXPIRES_IN=15m
# Allowed agent scopes (comma-separated)
MCP_ALLOWED_SCOPES=debug,read,writeFor production deployment, ensure you have:
# Production environment
NODE_ENV=production
AUTH_SECRET=your-production-secret-here
GOOGLE_CLIENT_ID=your-production-client-id
GOOGLE_CLIENT_SECRET=your-production-client-secret
GOOGLE_REDIRECT_URI=https://yourdomain.com/api/auth/callback/google
# Production SMTP
SMTP_HOST=your-production-smtp-host
SMTP_PORT=587
SMTP_USER=your-production-email
SMTP_PASS=your-production-password
SMTP_FROM=noreply@yourdomain.com
# Production database
DATABASE_URL=your-production-database-urlYou can validate your environment variables at startup:
// lib/env.ts
export function validateEnv() {
const required = [
'AUTH_SECRET',
'GOOGLE_CLIENT_ID',
'GOOGLE_CLIENT_SECRET',
'GOOGLE_REDIRECT_URI'
];
const missing = required.filter(key => !process.env[key]);
if (missing.length > 0) {
throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
}
if (process.env.AUTH_SECRET!.length < 32) {
throw new Error('AUTH_SECRET must be at least 32 characters long');
}
}
// Call this in your app startup
validateEnv();Use different configurations for development and production:
# Development environment
AUTH_SECRET=dev-secret-key-32-chars-minimum-length
GOOGLE_CLIENT_ID=your-dev-client-id
GOOGLE_CLIENT_SECRET=your-dev-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/callback/google
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-dev-email@gmail.com
SMTP_PASS=your-dev-app-passwordIn production, set environment variables through your hosting platform:
Once you have your environment variables configured, you can proceed to implement your first authentication flow.