Skip to content

Commit 0779fe7

Browse files
committed
refactor(auth-services): migrate away from using Bun
1 parent 81012f7 commit 0779fe7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1108
-2352
lines changed

apps/lit-auth-service/.bun-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/lit-auth-service/env.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

apps/lit-auth-service/index.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import { createLitAuthServer } from '@lit-protocol/auth-services';
2-
import { env } from './env';
2+
import { startAuthServiceWorker } from '@lit-protocol/auth-services';
33

44
const litAuthServer = createLitAuthServer({
5-
// some host look for PORT env var automatically
6-
port: parseInt(process.env.PORT!) || env.AUTH_SERVER_PORT,
7-
host: env.AUTH_SERVER_HOST,
8-
network: env.NETWORK,
9-
litTxsenderRpcUrl: env.LIT_TXSENDER_RPC_URL,
10-
litTxsenderPrivateKey: env.LIT_TXSENDER_PRIVATE_KEY,
11-
enableApiKeyGate: env.ENABLE_API_KEY_GATE,
12-
stytchProjectId: env.STYTCH_PROJECT_ID,
13-
stytchSecretKey: env.STYTCH_SECRET,
5+
port: Number(3001),
6+
host: '0.0.0.0',
7+
network: process.env['NETWORK'],
8+
litTxsenderRpcUrl: process.env['LIT_TXSENDER_RPC_URL'] as string,
9+
litTxsenderPrivateKey: process.env['LIT_TXSENDER_PRIVATE_KEY'],
10+
enableApiKeyGate: true,
11+
stytchProjectId: process.env['STYTCH_PROJECT_ID'],
12+
stytchSecretKey: process.env['STYTCH_SECRET'],
13+
maxRequestsPerWindow: Number(process.env['MAX_REQUESTS_PER_WINDOW']),
14+
windowMs: Number(process.env['WINDOW_MS']),
15+
redisUrl: process.env['REDIS_URL'] as string,
1416
});
1517

16-
litAuthServer.start().catch((err) => {
17-
console.error('Failed to start Lit Auth Server:', err);
18-
process.exit(1);
18+
// Start the auth server
19+
await litAuthServer.start();
20+
21+
// Requires REDIS_URL
22+
await startAuthServiceWorker({
23+
litTxsenderRpcUrl: process.env['LIT_TXSENDER_RPC_URL'] as string,
24+
redisUrl: process.env['REDIS_URL'] as string,
1925
});

apps/lit-auth-service/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "lit-auth-service",
3+
"type": "module",
34
"module": "index.ts",
45
"devDependencies": {
56
"@types/bun": "^1.2.15",
@@ -12,13 +13,10 @@
1213
},
1314
"private": true,
1415
"scripts": {
15-
"validate-deps": "npm ls --depth=0 || true",
16-
"start": "bun run validate-deps && bun run ./index.ts",
16+
"start": "dotenvx run --env-file=.env tsx index.ts",
1717
"reset": "rimraf package-lock.json bun.lock node_modules"
1818
},
19-
"type": "module",
2019
"dependencies": {
21-
"@lit-protocol/auth-services": "1.0.0-alpha.13",
22-
"@t3-oss/env-core": "^0.13.6"
20+
"@lit-protocol/auth-services": "workspace:*"
2321
}
2422
}
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{
2+
"extends": "../../tsconfig.base.json",
23
"compilerOptions": {
3-
"target": "ESNext",
44
"module": "ESNext",
55
"moduleResolution": "bundler",
6-
"allowSyntheticDefaultImports": true,
7-
"esModuleInterop": true,
8-
"allowJs": true,
96
"strict": true,
107
"skipLibCheck": true,
11-
"forceConsistentCasingInFileNames": true,
128
"resolveJsonModule": true,
139
"isolatedModules": true,
1410
"useDefineForClassFields": true,
15-
"types": ["bun-types"]
11+
"types": ["node"],
12+
"allowJs": true,
13+
"esModuleInterop": true,
14+
"allowSyntheticDefaultImports": true
1615
},
1716
"include": ["**/*.ts", "**/*.tsx"],
1817
"exclude": ["node_modules"]
19-
}
18+
}

apps/lit-login-service/.bun-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/lit-login-service/env.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

apps/lit-login-service/index.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
import { env } from "./env";
2-
import {
3-
createLitAuthServer,
4-
startAuthServiceWorker,
5-
} from "@lit-protocol/auth-services";
1+
import { createLitLoginServer } from '@lit-protocol/auth-services';
62

7-
const litAuthServer = createLitAuthServer({
8-
port: env.AUTH_SERVER_PORT,
9-
host: env.AUTH_SERVER_HOST,
10-
network: env.NETWORK,
11-
litTxsenderRpcUrl: env.LIT_TXSENDER_RPC_URL,
12-
litTxsenderPrivateKey: env.LIT_TXSENDER_PRIVATE_KEY,
13-
enableApiKeyGate: env.ENABLE_API_KEY_GATE,
14-
stytchProjectId: env.STYTCH_PROJECT_ID,
15-
stytchSecretKey: env.STYTCH_SECRET,
3+
const litLoginServer = createLitLoginServer({
4+
port: Number(process.env['LOGIN_SERVER_PORT']),
5+
host: process.env['LOGIN_SERVER_HOST'],
6+
stateExpirySeconds: 30,
7+
socialProviders: {
8+
google: {
9+
clientId: process.env['LOGIN_SERVER_GOOGLE_CLIENT_ID'] as string,
10+
clientSecret: process.env['LOGIN_SERVER_GOOGLE_CLIENT_SECRET'] as string,
11+
},
12+
discord: {
13+
clientId: process.env['LOGIN_SERVER_DISCORD_CLIENT_ID'] as string,
14+
clientSecret: process.env['LOGIN_SERVER_DISCORD_CLIENT_SECRET'] as string,
15+
},
16+
},
1617
});
1718

18-
litAuthServer.start().catch((err: Error) => {
19-
console.error("Failed to start Lit Auth Server:", err);
20-
process.exit(1);
21-
});
22-
23-
startAuthServiceWorker();
19+
await litLoginServer.start();
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
{
2-
"name": "lit-auth-services",
2+
"name": "lit-login-service",
3+
"type": "module",
34
"module": "index.ts",
5+
"private": true,
6+
"scripts": {
7+
"start": "dotenvx run --env-file=.env tsx index.ts",
8+
"reset": "rimraf package-lock.json bun.lock node_modules"
9+
},
10+
"dependencies": {
11+
"@lit-protocol/auth-services": "workspace:*"
12+
},
413
"devDependencies": {
514
"@types/bun": "^1.2.15",
615
"dotenv": "^16.5.0",
@@ -9,15 +18,5 @@
918
},
1019
"peerDependencies": {
1120
"typescript": "^5"
12-
},
13-
"private": true,
14-
"scripts": {
15-
"validate-deps": "npm ls --depth=0 || true",
16-
"start": "bun run validate-deps && bun run ./index.ts",
17-
"reset": "rimraf package-lock.json bun.lock node_modules"
18-
},
19-
"type": "module",
20-
"dependencies": {
21-
"@lit-protocol/auth-services": "1.0.0-alpha.13"
2221
}
2322
}
Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
{
2+
"extends": "../../tsconfig.base.json",
23
"compilerOptions": {
3-
// Environment setup & latest features
4-
"lib": ["ESNext"],
5-
"target": "ESNext",
64
"module": "ESNext",
7-
"moduleDetection": "force",
8-
"jsx": "react-jsx",
9-
"allowJs": true,
10-
11-
// Bundler mode
125
"moduleResolution": "bundler",
13-
"allowImportingTsExtensions": true,
14-
"verbatimModuleSyntax": true,
15-
"noEmit": true,
16-
17-
// Best practices
186
"strict": true,
197
"skipLibCheck": true,
20-
"noFallthroughCasesInSwitch": true,
21-
"noUncheckedIndexedAccess": true,
22-
23-
// Some stricter flags (disabled by default)
24-
"noUnusedLocals": false,
25-
"noUnusedParameters": false,
26-
"noPropertyAccessFromIndexSignature": false
27-
}
8+
"resolveJsonModule": true,
9+
"isolatedModules": true,
10+
"useDefineForClassFields": true,
11+
"types": ["node"],
12+
"allowJs": true,
13+
"esModuleInterop": true,
14+
"allowSyntheticDefaultImports": true
15+
},
16+
"include": ["**/*.ts", "**/*.tsx"],
17+
"exclude": ["node_modules"]
2818
}

0 commit comments

Comments
 (0)