Skip to content

Conversation

Ansonhkg
Copy link
Collaborator

@Ansonhkg Ansonhkg commented Sep 15, 2025

WHAT

Migrated away from using Elysia (Optimised for Bun) to Express.

Commands to start the services

// lit-auth-server (previously Relayer)
nx run lit-auth-server:serve:production

// lit-login-server
nx run lit-login-server:serve:production

Usage

// lit-auth-server
const litAuthServer = createLitAuthServer({
  port: Number(3001),
  host: process.env['HOST'],
  network: process.env['NETWORK'],
  litTxsenderRpcUrl: process.env['LIT_TXSENDER_RPC_URL'] as string,
  litTxsenderPrivateKey: process.env['LIT_TXSENDER_PRIVATE_KEY'],
  enableApiKeyGate: process.env['ENABLE_API_KEY_GATE'] === 'true',
  stytchProjectId: process.env['STYTCH_PROJECT_ID'],
  stytchSecretKey: process.env['STYTCH_SECRET'],
  maxRequestsPerWindow: Number(process.env['MAX_REQUESTS_PER_WINDOW']),
  windowMs: Number(process.env['WINDOW_MS']),
  redisUrl: process.env['REDIS_URL'] as string,
});

await litAuthServer.start();

// lit-login-server
const litLoginServer = createLitLoginServer({
  port: Number(process.env['LOGIN_SERVER_PORT']),
  host: process.env['LOGIN_SERVER_HOST'],
  stateExpirySeconds: 30,
  socialProviders: {
    google: {
      clientId: process.env['LOGIN_SERVER_GOOGLE_CLIENT_ID'] as string,
      clientSecret: process.env['LOGIN_SERVER_GOOGLE_CLIENT_SECRET'] as string,
    },
    discord: {
      clientId: process.env['LOGIN_SERVER_DISCORD_CLIENT_ID'] as string,
      clientSecret: process.env['LOGIN_SERVER_DISCORD_CLIENT_SECRET'] as string,
    },
  },
});

await litLoginServer.start();

Docker build

// lit-auth-server 
nx run lit-auth-server:docker-build

// lit-login-server
nx run lit-login-server:docker-build

Note: The publish pipeline is not setup yet, but these commands basically what we need to publish it to GHCR. This also allow us to provide one-click deploy on Railway or any other platforms.

// Tag your local image
docker tag lit-auth-server:latest ghcr.io/lit-protocol/lit-auth-server:latest

// Push it
docker push ghcr.io/lit-protocol/lit-auth-server:latest

```ts
await client.authService.mintWithAuth({
  authData,
  authServiceBaseUrl,
  scopes,
  apiKey: 'YOUR_API_KEY',
});
```

```ts
await WebAuthnAuthenticator.registerAndMintPKP({
  authServiceBaseUrl,
  scopes,
  apiKey: 'YOUR_API_KEY',
});
```

Upcoming PR to use .overrides authBaseUrl and API key instead.
- fixed env should be service specific
- added html packages back to lit-login-server
- renamed lit-*-service to lit-*-server
- return express instance for devs to customise
- pinned @ts-oss/env-cors version

This commit has also been tested locally using the E2E test dApp
…bstract-provider' or its corresponding type declarations.
…Cannot find module '@ethersproject/contracts' or its corresponding type declarations.` error from `packages/access-control-conditions/src/lib/humanizer.ts:1:26`
…y` and update main entry point to index.ts
…rsion 21.2.1, removing deprecated settings and adjusting package versions for compatibility
…ority of them came from `createContractManager` which supplies incompatible client shapes (or mixing public/wallet inference) made Client generics collide. Explicit PublicClient annotation triggered heavy generic expansion and account mismatches. Letting TS infer the type from createPublicClient resolves this.

- removed capacity credits as we have remove this concept for Naga
- Using `LitResourceAbilityRequestSchema` inferred type instead of legacy `CapacityDelegationRequest` (Types to be removed)
- Login server Node's CJS resolving dir name
- types on JobStatus
- declare the `auth-services` package as types node
- replaced @ts-expect-error in error.ts to @ts-ignore
- fixed the type from Ajv
- Introduced StrictAuthData instead of inline type
- bindAccount helper in the createChainManagerFactory to fix signature mismatch
- updated targets from ES2020 to ES2022
…xecutable via node eg. `NODE_OPTIONS=--no-deprecation node ./dist/apps/lit-login-server/main.cjs`
…rver with updated Dockerfiles and README instructions; include .dockerignore for build optimization
Ansonhkg added a commit that referenced this pull request Sep 15, 2025
…ata. This changes are added in #891 and #892 but they are pull in so this PR can build
@Ansonhkg Ansonhkg mentioned this pull request Sep 18, 2025
…/LIT-Protocol/js-sdk into feature/jss-105-refactor-auth-services-from-elysia-to-express
…rver to use multi-platform support and streamline dependency installation
…as CommonJS again so bundlers stop loading the build artifacts in ESM mode and hitting exports runtime errors

- Point the few packages whose main/types fields were still referencing the old ./dist paths at the real build outputs instead, so consumers resolve the CJS entry on first try instead of falling through to the broken ESM path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant