Skip to content

Commit 437d039

Browse files
inglettronaldimconnorngl
authored andcommitted
chore: cf
1 parent dae560f commit 437d039

28 files changed

Lines changed: 750 additions & 636 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Temporary Items
5353
.svelte-kit/
5454
package
5555

56+
### Cloudflare / Wrangler ###
57+
# Local wrangler/miniflare runtime state (sqlite cache, etc.)
58+
.wrangler/
59+
5660
### VisualStudioCode ###
5761
.vscode/*
5862
!.vscode/settings.json

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
> This is a fork of [SkyCryptWebsite/SkyCrypt-Frontend](https://github.com/SkyCryptWebsite/SkyCrypt-Frontend) with minimal changes to support embedding the profile viewer in Lunar Client. To keep this fork up to date with upstream:
2+
>
3+
> ```
4+
> git rebase upstream/dev
5+
> # Resolve any conflicts that occur
6+
> git push origin dev --force-with-lease
7+
> ```
8+
19
<p align="center">
210
<picture>
311
<source media="(prefers-color-scheme: light)" srcset="static/img/logo_black.avif">

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@oslojs/crypto": "^1.0.1",
5454
"@oslojs/encoding": "^1.1.0",
5555
"@playwright/test": "^1.60.0",
56+
"@sveltejs/adapter-cloudflare": "^7.2.8",
5657
"@sveltejs/adapter-node": "^5.5.4",
5758
"@sveltejs/kit": "^2.63.0",
5859
"@sveltejs/load-config": "^0.1.1",
@@ -120,6 +121,7 @@
120121
"@sentry/sveltekit": "^10.56.0",
121122
"culori": "^4.0.2",
122123
"simple-git-hooks": "^2.13.1",
124+
"svelte-interactions": "^0.2.0",
123125
"takumi-js": "^1.7.0"
124126
},
125127
"engines": {
@@ -133,4 +135,4 @@
133135
"simple-git-hooks": {
134136
"commit-msg": "pnpm exec commitlint --edit $1"
135137
}
136-
}
138+
}

pnpm-lock.yaml

Lines changed: 599 additions & 116 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ allowBuilds:
66
esbuild: true
77
sharp: true
88
simple-git-hooks: true
9+
svelte-preprocess: true
10+
workerd: true
911
overrides:
1012
kysely: 0.28.17

src/app.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,8 @@
420420
@utility minecraft-tooltip {
421421
@apply relative rounded-sm border-2 border-solid border-transparent bg-mctooltip-bg px-1 pt-1 pb-0.75 indent-[initial] font-minecraft text-[0.9375rem] leading-4.5 font-normal text-pretty [border-image:linear-gradient(to_bottom,oklch(48.503%_0.297_278.42/0.31),oklch(29.365%_0.17619_281.21/0.31))_1] text-shadow-[0.09375rem_0.09375rem_oklch(36.768%,0.00004,271.152)];
422422
}
423+
424+
body {
425+
-webkit-user-select: none;
426+
user-select: none;
427+
}

src/context/preferences.svelte.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ interface PreferencesData {
1717
export class PreferencesContext {
1818
#data = new PersistedState<PreferencesData>("skycryptPreferences", {
1919
sectionOrder: sections,
20-
performanceMode: false,
20+
performanceMode: true,
2121
keybind: "/",
22-
showGlint: true,
22+
showGlint: false,
2323
rainbowEnchantments: false,
2424
mctooltip: false
2525
});

src/hooks.server.ts

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
import { building } from "$app/environment";
2-
import { env as envPublic } from "$env/dynamic/public";
3-
import { auth } from "$lib/server/auth";
4-
import { UserRole } from "$lib/shared/roles";
5-
import { runMigrations } from "$src/lib/server/db/migrate";
61
import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
7-
import { redirect, type Handle, type ServerInit } from "@sveltejs/kit";
2+
import { type Handle } from "@sveltejs/kit";
83
import { sequence } from "@sveltejs/kit/hooks";
9-
import { svelteKitHandler } from "better-auth/svelte-kit";
104

11-
const protectedRouteGroupName = "(protected)";
12-
const protectedAdminRouteGroupName = "(admin)";
13-
const signInPath = "/login";
14-
15-
export const init: ServerInit = async () => {
16-
if (building) {
17-
console.info("Skipping migrations during build.");
18-
return;
19-
}
20-
await runMigrations();
21-
};
5+
// This fork is a public stats/card embed (skycrypt-embed.lunarclient.com) deployed
6+
// on Cloudflare Workers. It has no user accounts, so the upstream better-auth +
7+
// Postgres pipeline is intentionally omitted: DB-backed session lookups need a
8+
// database the embed doesn't have, and migrate-on-startup can't run on Workers
9+
// (no filesystem / process.cwd). See src/lib/server/db/index.ts (lazy db).
2210

2311
const headersHandler = (async ({ event, resolve }) => {
2412
const response = await resolve(event);
@@ -29,18 +17,8 @@ const headersHandler = (async ({ event, resolve }) => {
2917
response.headers.set("Permissions-Policy", "accelerometer=(), autoplay=(), camera=(), encrypted-media=(), fullscreen=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), sync-xhr=(), usb=(), xr-spatial-tracking=(), geolocation=()");
3018
response.headers.set("X-Content-Type-Options", "nosniff");
3119
response.headers.set("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload");
32-
33-
// Clickjacking protection. The newsroom draft preview must be embeddable in the Payload
34-
// CMS admin's live-preview iframe, so allow only the CMS origin to frame that one route;
35-
// everything else stays frame-locked.
36-
const isNewsroomPreview = url.pathname.startsWith("/newsroom/") && url.searchParams.get("preview") === "1";
37-
if (isNewsroomPreview) {
38-
const cms = envPublic.PUBLIC_CMS_URL?.trim();
39-
response.headers.append("Content-Security-Policy", `frame-ancestors 'self'${cms ? ` ${cms}` : ""}`);
40-
} else {
41-
response.headers.set("X-Frame-Options", "DENY");
42-
response.headers.append("Content-Security-Policy", "frame-ancestors 'none'");
43-
}
20+
// No frame-locking: this fork is embedded as an iframe (skycrypt-embed.lunarclient.com),
21+
// so X-Frame-Options / frame-ancestors restrictions are intentionally omitted.
4422

4523
// Cross-Origin policies
4624
// COEP intentionally unsafe-none: tightening would require all cross-origin
@@ -66,40 +44,4 @@ const headersHandler = (async ({ event, resolve }) => {
6644
// If you have a custom error handler, pass it to `handleErrorWithSentry`
6745
export const handleError = handleErrorWithSentry();
6846

69-
const betterAuthHandler: Handle = async ({ event, resolve }) => {
70-
const session = await auth.api.getSession({ headers: event.request.headers });
71-
72-
if (session) {
73-
event.locals.session = session.session;
74-
event.locals.user = session.user;
75-
}
76-
77-
return svelteKitHandler({ event, resolve, auth, building });
78-
};
79-
80-
const protectedHandler = (async ({ event, resolve }) => {
81-
const { locals, route } = event;
82-
if (!locals.user) {
83-
if (route.id?.includes(protectedRouteGroupName)) {
84-
console.info("Redirecting to sign-in page as user is not authenticated.");
85-
redirect(307, signInPath);
86-
}
87-
}
88-
if (locals.user) {
89-
const roles = (locals.user.role ? locals.user.role.split(",") : []) as UserRole[];
90-
const isAdmin = roles.includes(UserRole.Admin);
91-
if (route.id?.includes(protectedAdminRouteGroupName) && !isAdmin) {
92-
console.info("Redirecting to dashboard as user lacks admin role.");
93-
redirect(307, "/dashboard");
94-
}
95-
}
96-
if (locals.user && locals.session) {
97-
if (route.id?.startsWith(signInPath)) {
98-
redirect(307, "/dashboard");
99-
}
100-
}
101-
return resolve(event);
102-
}) satisfies Handle;
103-
104-
// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.
105-
export const handle = sequence(sentryHandle(), betterAuthHandler, protectedHandler, headersHandler) satisfies Handle;
47+
export const handle = sequence(sentryHandle(), headersHandler) satisfies Handle;

src/instrumentation.server.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/lib/components/header/Info.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
2+
import { version } from "$app/environment";
23
import { getHoverContext } from "$ctx";
34
import { env } from "$env/dynamic/public";
4-
import { PUBLIC_COMMIT_HASH } from "$env/static/public";
55
import { flyAndScale } from "$lib/shared/utils";
66
import ExternalLink from "@lucide/svelte/icons/external-link";
77
import Info from "@lucide/svelte/icons/info";
@@ -12,12 +12,12 @@
1212
1313
const { PUBLIC_DISCORD_INVITE, PUBLIC_PATREON } = env;
1414
const packageVersion = __NPM_PACKAGE_VERSION__;
15-
const commitHash = PUBLIC_COMMIT_HASH;
15+
const commitHash = version;
1616
</script>
1717

1818
{#snippet info()}
1919
<p class="my-4">SkyCrypt is a free, open-source stats viewer for Hypixel SkyBlock.</p>
20-
{#if __NPM_PACKAGE_VERSION__ || PUBLIC_COMMIT_HASH}
20+
{#if __NPM_PACKAGE_VERSION__ || version}
2121
<p>
2222
Currently running version
2323
<span class="font-semibold">

0 commit comments

Comments
 (0)