Configure auth services for the Lit JS SDK
https://login.litgateway.com
https://naga-auth-service.onrender.com
bun add @lit-protocol/auth-services@beta
Create the Lit Auth Service
// Auth Server Setup import { createLitAuthServer } from "@lit-protocol/auth-services"; const litAuthServer = createLitAuthServer({ port: process.env.PORT || 6380, network: process.env.NETWORK || "naga-dev", litTxsenderRpcUrl: process.env.LIT_TXSENDER_RPC_URL, litTxsenderPrivateKey: process.env.LIT_TXSENDER_PRIVATE_KEY, enableApiKeyGate: process.env.ENABLE_API_KEY_GATE === "true", }); // Start the auth server await litAuthServer.start();
Start the background worker
// Worker Setup import { startAuthServiceWorker } from "@lit-protocol/auth-services"; // Start the background worker for processing PKP minting operations await startAuthServiceWorker(); // The worker handles: // - Background PKP minting operations (non-blocking) // - Job queue processing with BullMQ // - Redis connection management // - Error handling and retry logic for minting jobs
Setup environment variables
# Network configuration (supports naga-dev, naga-test, naga) NETWORK=naga-dev LOG_LEVEL=debug # Lit transaction sender settings LIT_TXSENDER_RPC_URL=https://yellowstone-rpc.litprotocol.com LIT_TXSENDER_PRIVATE_KEY=your_private_key # Redis settings for job queue and caching REDIS_URL=redis://user:pass@redis-host.com:12345 PORT=6380 # Rate limiting configuration ENABLE_API_KEY_GATE=true MAX_REQUESTS_PER_WINDOW=10 WINDOW_MS=10000 # Stytch configuration (for OTP services) STYTCH_PUBLIC_TOKEN=your_stytch_public_token STYTCH_SECRET=your_stytch_secret
Create the Lit Login Server
// Login Server Setup import { createLitLoginServer } from "@lit-protocol/auth-services"; const litLoginServer = createLitLoginServer({ port: 3300, host: "0.0.0.0", stateExpirySeconds: 30, // OAuth provider configuration socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, }, discord: { clientId: process.env.DISCORD_CLIENT_ID!, clientSecret: process.env.DISCORD_CLIENT_SECRET!, }, }, }); // Start the login server await litLoginServer.start();
# OAuth provider credentials GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret DISCORD_CLIENT_ID=your_discord_client_id DISCORD_CLIENT_SECRET=your_discord_client_secret
Was this page helpful?