From 2442d891b85d94019982a2df0791f2dc1f2db215 Mon Sep 17 00:00:00 2001 From: not-nullptr Date: Mon, 11 Mar 2024 00:17:41 +0000 Subject: [PATCH] fix secrets mess --- .gitignore | 2 +- src/lib/server/secrets/secrets.example.json | 4 ++++ src/lib/server/util/index.ts | 2 +- src/lib/util/api/index.ts | 2 +- src/routes/jwt/internal/+server.ts | 2 +- src/routes/lobby/+server.ts | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 src/lib/server/secrets/secrets.example.json diff --git a/.gitignore b/.gitignore index 77dbb3b..7603e89 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ vite.config.js.timestamp-* vite.config.ts.timestamp-* ssl *.sqlite -src/lib/server/secrets \ No newline at end of file +src/lib/server/secrets/secrets.json \ No newline at end of file diff --git a/src/lib/server/secrets/secrets.example.json b/src/lib/server/secrets/secrets.example.json new file mode 100644 index 0000000..ad49ac1 --- /dev/null +++ b/src/lib/server/secrets/secrets.example.json @@ -0,0 +1,4 @@ +{ + "PUBLIC_KEY": "-----BEGIN PUBLIC...", + "PRIVATE_KEY": "-----BEGIN PRIVATE..." +} diff --git a/src/lib/server/util/index.ts b/src/lib/server/util/index.ts index 3bca8e0..6916588 100644 --- a/src/lib/server/util/index.ts +++ b/src/lib/server/util/index.ts @@ -1,6 +1,6 @@ import type { IJwtData } from "$types/auth"; import type { Role } from "$types/db"; -import { PUBLIC_KEY } from "../secrets"; +import { PUBLIC_KEY } from "../secrets/secrets.json"; import jwt from "jsonwebtoken"; export function json(body: T): Response { diff --git a/src/lib/util/api/index.ts b/src/lib/util/api/index.ts index aa94f02..9f32e73 100644 --- a/src/lib/util/api/index.ts +++ b/src/lib/util/api/index.ts @@ -1,6 +1,6 @@ import { userRepo } from "$lib/server/repo"; import type { SuyuUser } from "$lib/server/schema"; -import { PUBLIC_KEY } from "$lib/server/secrets"; +import { PUBLIC_KEY } from "$lib/server/secrets/secrets.json"; import type { IJwtData } from "$types/auth"; import cookie from "cookie"; import jwt from "jsonwebtoken"; diff --git a/src/routes/jwt/internal/+server.ts b/src/routes/jwt/internal/+server.ts index 3410146..7294ef7 100644 --- a/src/routes/jwt/internal/+server.ts +++ b/src/routes/jwt/internal/+server.ts @@ -1,4 +1,4 @@ -import { PRIVATE_KEY } from "$lib/server/secrets/index.js"; +import { PRIVATE_KEY } from "$lib/server/secrets/secrets.json"; import { useAuth } from "$lib/util/api/index.js"; import jwt from "jsonwebtoken"; diff --git a/src/routes/lobby/+server.ts b/src/routes/lobby/+server.ts index c2d430a..ae7a03c 100644 --- a/src/routes/lobby/+server.ts +++ b/src/routes/lobby/+server.ts @@ -1,7 +1,7 @@ import { Room, RoomManager } from "$lib/server/class/Room"; import { userRepo } from "$lib/server/repo/index.js"; import { SuyuUser } from "$lib/server/schema"; -import { PUBLIC_KEY } from "$lib/server/secrets/index.js"; +import { PUBLIC_KEY } from "$lib/server/secrets/secrets.json"; import { json } from "$lib/server/util"; import type { IJwtData } from "$types/auth.js"; import type { IRoom, LobbyResponse } from "$types/rooms";