diff --git a/app/game-api/src/auth/accessTokenStore.ts b/app/game-api/src/auth/accessTokenStore.ts index b69322f..ac975cd 100644 --- a/app/game-api/src/auth/accessTokenStore.ts +++ b/app/game-api/src/auth/accessTokenStore.ts @@ -1,6 +1,6 @@ import { randomUUID } from 'node:crypto'; -import type { GameSessionTokenPayload } from '@sammo-ts/common'; +import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken'; import { isValid, parseISO } from 'date-fns'; interface RedisClientLike { diff --git a/app/game-api/src/auth/tokenVerifier.ts b/app/game-api/src/auth/tokenVerifier.ts index cc3f8ce..71426cb 100644 --- a/app/game-api/src/auth/tokenVerifier.ts +++ b/app/game-api/src/auth/tokenVerifier.ts @@ -1,5 +1,5 @@ -import type { GameSessionTokenPayload } from '@sammo-ts/common'; -import { decryptGameSessionToken } from '@sammo-ts/common'; +import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken'; +import { decryptGameSessionToken } from '@sammo-ts/common/auth/gameToken'; import { isAfter, isValid, parseISO } from 'date-fns'; import type { FlushStore } from './flushStore.js'; diff --git a/app/game-api/src/context.ts b/app/game-api/src/context.ts index c3c2864..3ba9ced 100644 --- a/app/game-api/src/context.ts +++ b/app/game-api/src/context.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import type { GameSessionTokenPayload } from '@sammo-ts/common'; +import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken'; import type { DatabaseClient as InfraDatabaseClient, RedisConnector, GamePrisma } from '@sammo-ts/infra'; import type { TurnDaemonTransport } from './daemon/transport.js'; diff --git a/app/game-api/src/router/auth/index.ts b/app/game-api/src/router/auth/index.ts index 252222c..aa7b4ea 100644 --- a/app/game-api/src/router/auth/index.ts +++ b/app/game-api/src/router/auth/index.ts @@ -1,9 +1,9 @@ import { TRPCError } from '@trpc/server'; -import { decryptGameSessionToken } from '@sammo-ts/common'; +import { decryptGameSessionToken } from '@sammo-ts/common/auth/gameToken'; import { isAfter, isValid, parseISO } from 'date-fns'; import { z } from 'zod'; -import type { GameSessionTokenPayload } from '@sammo-ts/common'; +import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken'; import { procedure, router } from '../../trpc.js'; const parseDate = (value: string): Date | null => { diff --git a/app/game-api/src/server.ts b/app/game-api/src/server.ts index af620d8..897266d 100644 --- a/app/game-api/src/server.ts +++ b/app/game-api/src/server.ts @@ -1,7 +1,8 @@ import fastify, { type FastifyRequest } from 'fastify'; import cors from '@fastify/cors'; import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify'; -import { buildGameEventChannel, type GameSessionTokenPayload } from '@sammo-ts/common'; +import { buildGameEventChannel } from '@sammo-ts/common'; +import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken'; import { createGamePostgresConnector, createRedisConnector, diff --git a/app/game-api/test/router.test.ts b/app/game-api/test/router.test.ts index 458dc47..001a05b 100644 --- a/app/game-api/test/router.test.ts +++ b/app/game-api/test/router.test.ts @@ -15,7 +15,7 @@ import { InMemoryTurnDaemonTransport } from '../src/daemon/inMemoryTransport.js' import { InMemoryFlushStore } from '../src/auth/flushStore.js'; import { RedisAccessTokenStore } from '../src/auth/accessTokenStore.js'; import { appRouter } from '../src/router.js'; -import type { GameSessionTokenPayload } from '@sammo-ts/common'; +import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken'; const profile: GameProfile = { id: 'che', diff --git a/app/gateway-api/src/router.ts b/app/gateway-api/src/router.ts index 61a3acc..29e9fce 100644 --- a/app/gateway-api/src/router.ts +++ b/app/gateway-api/src/router.ts @@ -4,7 +4,7 @@ import { TRPCError } from '@trpc/server'; import { addHours, addSeconds, isAfter, isValid, parseISO } from 'date-fns'; import { z } from 'zod'; -import { decryptGameSessionToken, encryptGameSessionToken } from '@sammo-ts/common'; +import { decryptGameSessionToken, encryptGameSessionToken } from '@sammo-ts/common/auth/gameToken'; import { procedure, router } from './trpc.js'; import { toPublicUser } from './auth/userRepository.js'; diff --git a/packages/common/package.json b/packages/common/package.json index 9e211b8..6b80d52 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -5,9 +5,19 @@ "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./auth/gameToken": { + "types": "./dist/auth/gameToken.d.ts", + "default": "./dist/auth/gameToken.js" + } + }, "scripts": { - "build": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/common", - "dev": "tsdown -c ../../tsdown.config.ts -F @sammo-ts/common --watch", + "build": "tsdown -c ./tsdown.config.ts", + "dev": "tsdown -c ./tsdown.config.ts --watch", "lint": "eslint .", "lint:fix": "eslint . --fix", "test": "vitest run --config vitest.config.ts", diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index e816d0d..738fe0f 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,5 +1,4 @@ export * from './rng.js'; -export * from './auth/gameToken.js'; export * from './time/Clock.js'; export * from './util/BytesLike.js'; export * from './util/convertBytesLikeToArrayBuffer.js'; diff --git a/packages/common/tsdown.config.ts b/packages/common/tsdown.config.ts new file mode 100644 index 0000000..4cadf17 --- /dev/null +++ b/packages/common/tsdown.config.ts @@ -0,0 +1,18 @@ +import { defineConfig } from 'tsdown'; + +export default defineConfig({ + entry: { + index: 'src/index.ts', + 'auth/gameToken': 'src/auth/gameToken.ts', + }, + format: 'es', + outDir: 'dist', + dts: { + build: true, + }, + sourcemap: true, + target: 'node22', + platform: 'node', + fixedExtension: false, + hash: false, +}); diff --git a/tools/integration-tests/tsconfig.json b/tools/integration-tests/tsconfig.json index 8d01748..13251ee 100644 --- a/tools/integration-tests/tsconfig.json +++ b/tools/integration-tests/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../tsconfig.paths.json", "compilerOptions": { "types": ["node"], "noEmit": true