From 879104622ab3112525077ea850db1f7791c86f3d Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 18 Jan 2026 06:39:43 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20auth/gameToken=20=EB=AA=A8=EB=93=88?= =?UTF-8?q?=EB=A1=9C=EC=9D=98=20=EA=B2=BD=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20tsdown=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/game-api/src/auth/accessTokenStore.ts | 2 +- app/game-api/src/auth/tokenVerifier.ts | 4 ++-- app/game-api/src/context.ts | 2 +- app/game-api/src/router/auth/index.ts | 4 ++-- app/game-api/src/server.ts | 3 ++- app/game-api/test/router.test.ts | 2 +- app/gateway-api/src/router.ts | 2 +- packages/common/package.json | 14 ++++++++++++-- packages/common/src/index.ts | 1 - packages/common/tsdown.config.ts | 18 ++++++++++++++++++ tools/integration-tests/tsconfig.json | 2 +- 11 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 packages/common/tsdown.config.ts 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