mirror of
https://git.suyu.dev/suyu/website.git
synced 2025-12-22 05:36:13 +01:00
fix page transitions
This commit is contained in:
parent
9da5ac1b00
commit
368e5ef0f3
8 changed files with 42 additions and 63 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import type { IJwtData } from "$types/auth";
|
import type { IJwtData } from "$types/auth";
|
||||||
import type { Role } from "$types/db";
|
import type { Role } from "$types/db";
|
||||||
import { PUBLIC_KEY } from "../secrets/secrets.json";
|
import { PUB_KEY } from "$env/static/private";
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
export function json<T>(body: T, status?: number): Response {
|
export function json<T>(body: T, status?: number): Response {
|
||||||
|
|
@ -14,7 +14,7 @@ export function json<T>(body: T, status?: number): Response {
|
||||||
|
|
||||||
export async function getJwtData(token: string): Promise<IJwtData> {
|
export async function getJwtData(token: string): Promise<IJwtData> {
|
||||||
return new Promise((resolve, reject) => {
|
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);
|
if (err) reject(err);
|
||||||
else resolve(data as IJwtData);
|
else resolve(data as IJwtData);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { userRepo } from "$lib/server/repo";
|
import { userRepo } from "$lib/server/repo";
|
||||||
import type { SuyuUser } from "$lib/server/schema";
|
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 type { IJwtData } from "$types/auth";
|
||||||
import cookie from "cookie";
|
import cookie from "cookie";
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
|
|
@ -18,7 +18,7 @@ export async function useAuth(
|
||||||
}
|
}
|
||||||
if (apiKey.startsWith("Bearer ")) {
|
if (apiKey.startsWith("Bearer ")) {
|
||||||
const token = apiKey.replace("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"],
|
algorithms: ["RS256"],
|
||||||
}) as IJwtData;
|
}) as IJwtData;
|
||||||
let user = await userRepo.findOne({
|
let user = await userRepo.findOne({
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
$: memberCount = parseFloat(data.memberCount?.toPrecision(2));
|
$: 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));
|
$: starCount = parseFloat(data.starCount?.toPrecision(2));
|
||||||
let metadata = {
|
let metadata = {
|
||||||
url: "https://suyu.dev",
|
url: "https://suyu.dev",
|
||||||
|
|
@ -70,11 +70,7 @@
|
||||||
and open-source, forever.
|
and open-source, forever.
|
||||||
</p>
|
</p>
|
||||||
<div class="flex flex-col gap-4 md:flex-row">
|
<div class="flex flex-col gap-4 md:flex-row">
|
||||||
<a
|
<a href="/download" rel="noreferrer noopener" class="cta-button">
|
||||||
href="/download"
|
|
||||||
rel="noreferrer noopener"
|
|
||||||
class="cta-button"
|
|
||||||
>
|
|
||||||
Download <svg
|
Download <svg
|
||||||
width="16"
|
width="16"
|
||||||
height="16"
|
height="16"
|
||||||
|
|
@ -186,8 +182,8 @@
|
||||||
>
|
>
|
||||||
<h2 class="text-[24px] leading-[1.41] md:text-[60px] md:leading-[1.1]">Git</h2>
|
<h2 class="text-[24px] leading-[1.41] md:text-[60px] md:leading-[1.1]">Git</h2>
|
||||||
<p class="mt-2 text-lg leading-relaxed">
|
<p class="mt-2 text-lg leading-relaxed">
|
||||||
Our Git instance is where all the magic of suyu happens. We're always looking for new contributors
|
Our Git instance is where all the magic of suyu happens. We're always looking for new
|
||||||
to help us out, so feel free to check out our code.
|
contributors to help us out, so feel free to check out our code.
|
||||||
</p>
|
</p>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
// },
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
function navClick(e: MouseEvent | HTMLAnchorElement) {
|
function navClick(e: MouseEvent | HTMLAnchorElement, ignoreAnimation = false) {
|
||||||
const navBars = document.querySelectorAll<HTMLDivElement>(".navbar");
|
const navBars = document.querySelectorAll<HTMLDivElement>(".navbar");
|
||||||
if (navBars.length !== 1)
|
if (navBars.length !== 1)
|
||||||
navBars.forEach((bar) => {
|
navBars.forEach((bar) => {
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
const bounds = target.getBoundingClientRect();
|
const bounds = target.getBoundingClientRect();
|
||||||
const navBounds = navBar.getBoundingClientRect();
|
const navBounds = navBar.getBoundingClientRect();
|
||||||
const pillBounds = indicator.getBoundingClientRect();
|
const pillBounds = indicator.getBoundingClientRect();
|
||||||
|
if (ignoreAnimation) return;
|
||||||
indicator.style.transform = `translateX(${bounds.left - navBounds.left}px)`;
|
indicator.style.transform = `translateX(${bounds.left - navBounds.left}px)`;
|
||||||
indicator.style.width = `${bounds.width}px`;
|
indicator.style.width = `${bounds.width}px`;
|
||||||
if (
|
if (
|
||||||
|
|
@ -190,7 +191,7 @@
|
||||||
<a
|
<a
|
||||||
href={item.href}
|
href={item.href}
|
||||||
data-index={i}
|
data-index={i}
|
||||||
on:click={navClick}
|
on:click={(e) => navClick(e, true)}
|
||||||
class={`navitem flex flex-grow basis-[0] items-center justify-center whitespace-nowrap rounded-full px-4 py-2 text-sm font-bold ${
|
class={`navitem flex flex-grow basis-[0] items-center justify-center whitespace-nowrap rounded-full px-4 py-2 text-sm font-bold ${
|
||||||
selected === i ? " text-[#a9a9a9] opacity-100" : "opacity-50"
|
selected === i ? " text-[#a9a9a9] opacity-100" : "opacity-50"
|
||||||
}`}
|
}`}
|
||||||
|
|
|
||||||
24
src/routes/jwt/external/[audience]/+server.ts
vendored
Normal file
24
src/routes/jwt/external/[audience]/+server.ts
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { PRIVATE_KEY } from "$env/static/private";
|
||||||
|
import { userRepo } from "$lib/server/repo/index.js";
|
||||||
|
import { getJwtData } from "$lib/server/util/index.js";
|
||||||
|
import { useAuth } from "$lib/util/api/index.js";
|
||||||
|
import type { IJwtData } from "$types/auth.js";
|
||||||
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
export async function POST({ request }) {
|
||||||
|
const jwtData = await getJwtData(request.headers.get("authorization")?.split(" ")[1] || "");
|
||||||
|
const user = await userRepo.findOne({
|
||||||
|
where: {
|
||||||
|
apiKey: jwtData.apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const token = jwt.sign({ ...user }, Buffer.from(PRIVATE_KEY), {
|
||||||
|
algorithm: "RS256",
|
||||||
|
});
|
||||||
|
return new Response(token, {
|
||||||
|
status: 200,
|
||||||
|
headers: {
|
||||||
|
"content-type": "text/html",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
40
src/routes/jwt/external/key.pem/+server.ts
vendored
40
src/routes/jwt/external/key.pem/+server.ts
vendored
|
|
@ -1,45 +1,11 @@
|
||||||
import { json } from "$lib/server/util/index.js";
|
import { PUB_KEY } from "$env/static/private";
|
||||||
|
|
||||||
export function GET({ request }) {
|
export function GET({ request }) {
|
||||||
return new Response(
|
return new Response(PUB_KEY, {
|
||||||
`-----BEGIN CERTIFICATE-----
|
|
||||||
AAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
||||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
|
|
||||||
-----END CERTIFICATE-----`,
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "text/plain",
|
"content-type": "text/plain",
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function POST({ request }) {
|
export function POST({ request }) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { PRIVATE_KEY } from "$lib/server/secrets/secrets.json";
|
import { PRIVATE_KEY } from "$env/static/private";
|
||||||
import { useAuth } from "$lib/util/api/index.js";
|
import { useAuth } from "$lib/util/api/index.js";
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Room, RoomManager } from "$lib/server/class/Room";
|
import { Room, RoomManager } from "$lib/server/class/Room";
|
||||||
import { userRepo } from "$lib/server/repo/index.js";
|
import { userRepo } from "$lib/server/repo/index.js";
|
||||||
import { SuyuUser } from "$lib/server/schema";
|
import { SuyuUser } from "$lib/server/schema";
|
||||||
import { PUBLIC_KEY } from "$lib/server/secrets/secrets.json";
|
|
||||||
import { json } from "$lib/server/util";
|
import { json } from "$lib/server/util";
|
||||||
import { useAuth } from "$lib/util/api/index.js";
|
import { useAuth } from "$lib/util/api/index.js";
|
||||||
import type { IJwtData } from "$types/auth.js";
|
import type { IJwtData } from "$types/auth.js";
|
||||||
|
|
@ -65,12 +64,5 @@ export async function POST({ request, getClientAddress }) {
|
||||||
host: user,
|
host: user,
|
||||||
hasPassword: body.hasPassword || false,
|
hasPassword: body.hasPassword || false,
|
||||||
});
|
});
|
||||||
console.log("Room added:", JSON.stringify(room, null, 2));
|
|
||||||
// push every room to the top which starts with `[SUYU OFFICIAL]` and was created with username "suyu"
|
|
||||||
const suyuRoom = RoomManager.rooms.find((r) => r.roomInfo.name.startsWith("[SUYU OFFICIAL]"));
|
|
||||||
if (suyuRoom && suyuRoom.host.username === "suyu") {
|
|
||||||
RoomManager.rooms.splice(RoomManager.rooms.indexOf(suyuRoom), 1);
|
|
||||||
RoomManager.rooms.unshift(suyuRoom);
|
|
||||||
}
|
|
||||||
return json(room.toJSON());
|
return json(room.toJSON());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue