From 368e5ef0f3cbfdb5a67fb1ff024a076c744255f6 Mon Sep 17 00:00:00 2001 From: not-nullptr Date: Thu, 28 Mar 2024 13:34:06 +0000 Subject: [PATCH] fix page transitions --- src/lib/server/util/index.ts | 4 +- src/lib/util/api/index.ts | 4 +- src/routes/+page.svelte | 14 +++--- src/routes/account/+layout.svelte | 5 ++- src/routes/jwt/external/[audience]/+server.ts | 24 ++++++++++ src/routes/jwt/external/key.pem/+server.ts | 44 +++---------------- src/routes/jwt/internal/+server.ts | 2 +- src/routes/lobby/+server.ts | 8 ---- 8 files changed, 42 insertions(+), 63 deletions(-) create mode 100644 src/routes/jwt/external/[audience]/+server.ts diff --git a/src/lib/server/util/index.ts b/src/lib/server/util/index.ts index fb4030d..104afea 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/secrets.json"; +import { PUB_KEY } from "$env/static/private"; import jwt from "jsonwebtoken"; export function json(body: T, status?: number): Response { @@ -14,7 +14,7 @@ export function json(body: T, status?: number): Response { export async function getJwtData(token: string): Promise { return new Promise((resolve, reject) => { - jwt.verify(token, PUBLIC_KEY, { algorithms: ["RS256"] }, (err, data) => { + jwt.verify(token, PUB_KEY, { algorithms: ["RS256"] }, (err, data) => { if (err) reject(err); else resolve(data as IJwtData); }); diff --git a/src/lib/util/api/index.ts b/src/lib/util/api/index.ts index b5c24e4..dbedfb6 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/secrets.json"; +import { PUB_KEY } from "$env/static/private"; import type { IJwtData } from "$types/auth"; import cookie from "cookie"; import jwt from "jsonwebtoken"; @@ -18,7 +18,7 @@ export async function useAuth( } if (apiKey.startsWith("Bearer ")) { const token = apiKey.replace("Bearer ", ""); - const decoded: IJwtData = jwt.verify(token, Buffer.from(PUBLIC_KEY), { + const decoded: IJwtData = jwt.verify(token, Buffer.from(PUB_KEY), { algorithms: ["RS256"], }) as IJwtData; let user = await userRepo.findOne({ diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7447cf2..4661e00 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -8,7 +8,7 @@ export let data: PageData; $: memberCount = parseFloat(data.memberCount?.toPrecision(2)); - $: contributors = parseFloat(data.roleMembers["1214817156420862012"]?.toPrecision(2)); + $: contributors = parseFloat(data.roleMembers?.["1214817156420862012"]?.toPrecision(2)); $: starCount = parseFloat(data.starCount?.toPrecision(2)); let metadata = { url: "https://suyu.dev", @@ -70,12 +70,8 @@ and open-source, forever.
- Our Git instance is where all the magic of suyu happens. We're always looking for new contributors - to help us out, so feel free to check out our code. + Our Git instance is where all the magic of suyu happens. We're always looking for new + contributors to help us out, so feel free to check out our code.