πŸ’° Need Test Tokens? Visit the Chronicle Yellowstone Faucet to get test tokens for your EOA account.

Overview

Create your own authentication infrastructure using the Lit Protocol Auth Services package. This provides two core services:
  1. Auth Server for PKP minting with various auth methods, and a Worker for background minting operations.
  2. Login Server for OAuth flows

Dev Network

On the naga-dev network, you don’t need to setup these services yourself, they are already set up for you.

Login Server

https://login.litgateway.com

Auth Server

https://naga-auth-service.onrender.com

Test & Production Networks

The following guide is incomplete. More details coming soon for test and production networks on how to setup these services yourself.

Install the SDK

Run the following command to install the SDK: (Only available using Bun to install at the moment.)
bun add @lit-protocol/auth-services@beta

Lit Auth Service

1

Create the Lit Auth Service

Create the Lit Auth Service instance.
// 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();
2

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
3

Setup environment variables

Setup the 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

Lit Login Server

1

Create the Lit Login Server

Create the Lit Login Server instance.
// 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();
2

Setup environment variables

# 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