aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(static)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-11 17:51:24 -0800
committerAdam Soltys <[email protected]>2026-02-11 17:51:24 -0800
commit13466248004327e9a026cb89f94926f9b060d1c1 (patch)
tree47b4972c33809ccdf866b043c92cd3e0ecf5dcd0 /src/routes/(static)
parent3aa9ce1b5985397d7f568887ec6f881df13c1034 (diff)
downloadcoinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.tar.gz
coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.zip
linting
Diffstat (limited to 'src/routes/(static)')
-rw-r--r--src/routes/(static)/+layout.server.ts24
-rw-r--r--src/routes/(static)/bounties/+page.server.ts78
-rw-r--r--src/routes/(static)/docs/+page.server.ts8
-rw-r--r--src/routes/(static)/docs/+page.svelte10
-rw-r--r--src/routes/(static)/forgot/+page.server.ts18
-rw-r--r--src/routes/(static)/forgot/+page.svelte3
-rw-r--r--src/routes/(static)/login/+page.server.ts115
-rw-r--r--src/routes/(static)/login/+page.svelte14
-rw-r--r--src/routes/(static)/login/[token]/+page.server.ts14
-rw-r--r--src/routes/(static)/register/+page.server.ts30
-rw-r--r--src/routes/(static)/register/+page.svelte16
-rw-r--r--src/routes/(static)/support/+page.svelte12
12 files changed, 181 insertions, 161 deletions
diff --git a/src/routes/(static)/+layout.server.ts b/src/routes/(static)/+layout.server.ts
index 5de752fa..bd8ce5a8 100644
--- a/src/routes/(static)/+layout.server.ts
+++ b/src/routes/(static)/+layout.server.ts
@@ -2,18 +2,18 @@ import { auth, get, isInvalidTokenError } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export async function load({ cookies }) {
- const token = cookies.get("token");
+ const token = cookies.get("token");
- let user;
- if (token) {
- try {
- user = await get("/me", auth(cookies));
- } catch (e) {
- if (isInvalidTokenError(e)) {
- redirect(307, "/logout");
- }
- }
- }
+ let user;
+ if (token) {
+ try {
+ user = await get("/me", auth(cookies));
+ } catch (e) {
+ if (isInvalidTokenError(e)) {
+ redirect(307, "/logout");
+ }
+ }
+ }
- return { user };
+ return { user };
}
diff --git a/src/routes/(static)/bounties/+page.server.ts b/src/routes/(static)/bounties/+page.server.ts
index 8378e2f2..00a94d76 100644
--- a/src/routes/(static)/bounties/+page.server.ts
+++ b/src/routes/(static)/bounties/+page.server.ts
@@ -1,44 +1,44 @@
import { get } from "$lib/utils";
export const load = async () => {
- const users = [
- {
- username: "fustler",
- merchant: "rrdrive",
- type: "Bakery",
- amount: 1000000,
- },
- {
- username: "laluna",
- merchant: "butchersguild",
- type: "Butcher Shop",
- amount: 1000000,
- },
- {
- username: "ica547",
- merchant: "vanlove",
- type: "Sushi Restaurant",
- amount: 1000000,
- },
- {
- username: "reverendhodl",
- merchant: "laughingbean",
- type: "Cafe",
- amount: 1000000,
- },
- {
- username: "kimsrepair",
- merchant: "kimsrepair",
- type: "Kims Repair",
- amount: 100000,
- },
- ];
+ const users = [
+ {
+ username: "fustler",
+ merchant: "rrdrive",
+ type: "Bakery",
+ amount: 1000000,
+ },
+ {
+ username: "laluna",
+ merchant: "butchersguild",
+ type: "Butcher Shop",
+ amount: 1000000,
+ },
+ {
+ username: "ica547",
+ merchant: "vanlove",
+ type: "Sushi Restaurant",
+ amount: 1000000,
+ },
+ {
+ username: "reverendhodl",
+ merchant: "laughingbean",
+ type: "Cafe",
+ amount: 1000000,
+ },
+ {
+ username: "kimsrepair",
+ merchant: "kimsrepair",
+ type: "Kims Repair",
+ amount: 100000,
+ },
+ ];
- for (const user of users) {
- const { username, merchant } = user;
- console.log(username, merchant);
- user.user = await get(`/users/${username}`);
- user.merchant = await get(`/users/${merchant}`);
- }
+ for (const user of users) {
+ const { username, merchant } = user;
+ console.log(username, merchant);
+ user.user = await get(`/users/${username}`);
+ user.merchant = await get(`/users/${merchant}`);
+ }
- return { users };
+ return { users };
};
diff --git a/src/routes/(static)/docs/+page.server.ts b/src/routes/(static)/docs/+page.server.ts
index 93ba544c..ec5ace69 100644
--- a/src/routes/(static)/docs/+page.server.ts
+++ b/src/routes/(static)/docs/+page.server.ts
@@ -1,7 +1,7 @@
import { auth, get } from "$lib/utils";
export const load = async ({ cookies }) => {
- const token = cookies.get("token");
- let ro;
- if (token) ro = await get("/ro", auth(cookies));
- return { ro, token };
+ const token = cookies.get("token");
+ let ro;
+ if (token) ro = await get("/ro", auth(cookies));
+ return { ro, token };
};
diff --git a/src/routes/(static)/docs/+page.svelte b/src/routes/(static)/docs/+page.svelte
index 76e487c5..51b1f54e 100644
--- a/src/routes/(static)/docs/+page.svelte
+++ b/src/routes/(static)/docs/+page.svelte
@@ -2,7 +2,8 @@
import { copyNoNewlines as copy } from "$lib/utils";
import { PUBLIC_DOMAIN, PUBLIC_COINOS_URL } from "$env/static/public";
- import Code from "$comp/Code.svelte"; let { data } = $props();
+ import Code from "$comp/Code.svelte";
+ let { data } = $props();
let { user, ro, token } = data;
@@ -63,7 +64,8 @@
or get one from the /login endpoint.
{/if}
- Save it in a variable called <b>$token</b> to run the examples. It gives full access to your account so keep it safe.
+ Save it in a variable called <b>$token</b> to run the examples. It gives full
+ access to your account so keep it safe.
</p>
<div
@@ -75,8 +77,8 @@
{#if ro}
<p class="text-secondary">
- This read-only token has permission to create invoices and fetch
- payments but can't be used to make withdrawals
+ This read-only token has permission to create invoices and fetch payments
+ but can't be used to make withdrawals
</p>
<div
class="bg-primary text-primary-content rounded-lg p-4 flex gap-4 items-center"
diff --git a/src/routes/(static)/forgot/+page.server.ts b/src/routes/(static)/forgot/+page.server.ts
index 55169a5e..e7476c2d 100644
--- a/src/routes/(static)/forgot/+page.server.ts
+++ b/src/routes/(static)/forgot/+page.server.ts
@@ -2,13 +2,13 @@ import { fail } from "@sveltejs/kit";
import { fd, post } from "$lib/utils";
export const actions = {
- default: async ({ request }) => {
- try {
- const { email } = await fd(request);
- await post("/forgot", { email });
- return { success: true };
- } catch (e: any) {
- return fail(400, { error: e.message });
- }
- },
+ default: async ({ request }) => {
+ try {
+ const { email } = await fd(request);
+ await post("/forgot", { email });
+ return { success: true };
+ } catch (e: any) {
+ return fail(400, { error: e.message });
+ }
+ },
};
diff --git a/src/routes/(static)/forgot/+page.svelte b/src/routes/(static)/forgot/+page.svelte
index 186655a5..711c5568 100644
--- a/src/routes/(static)/forgot/+page.svelte
+++ b/src/routes/(static)/forgot/+page.svelte
@@ -1,7 +1,8 @@
<script lang="ts">
import { focus } from "$lib/utils";
import { enhance } from "$app/forms";
- import { t } from "$lib/translations"; import Spinner from "$comp/Spinner.svelte";
+ import { t } from "$lib/translations";
+ import Spinner from "$comp/Spinner.svelte";
import { fly } from "svelte/transition";
let loading;
diff --git a/src/routes/(static)/login/+page.server.ts b/src/routes/(static)/login/+page.server.ts
index ce343790..e4fb3815 100644
--- a/src/routes/(static)/login/+page.server.ts
+++ b/src/routes/(static)/login/+page.server.ts
@@ -1,77 +1,82 @@
import { PUBLIC_COINOS_URL } from "$env/static/public";
-import { fd, get, login, post } from "$lib/utils";
+import { fd, get, login } from "$lib/utils";
import { fail, redirect } from "@sveltejs/kit";
export const load = async ({ parent }) => {
- const { user } = await parent();
- if (user?.pubkey) redirect(307, `/${user.username}`);
- const { challenge } = await get("/challenge");
- return { challenge };
+ const { user } = await parent();
+ if (user?.pubkey) redirect(307, `/${user.username}`);
+ const { challenge } = await get("/challenge");
+ return { challenge };
};
export const actions = {
- login: async ({ cookies, request }) => {
- const form = await fd(request);
- let { username, password, token, loginRedirect, recaptcha } = form;
+ login: async ({ cookies, request }) => {
+ const form = await fd(request);
+ let { username, password, token, loginRedirect, recaptcha } = form;
username = username.split("@")[0];
- const user = {
- username,
- password,
- token,
- recaptcha,
- };
+ const user = {
+ username,
+ password,
+ token,
+ recaptcha,
+ };
- if (loginRedirect === "undefined") loginRedirect = undefined;
+ if (loginRedirect === "undefined") loginRedirect = undefined;
- try {
- await login(user, cookies, request.headers.get("cf-connecting-ip"), request.headers.get("host"));
- } catch (e) {
- const { message } = e as Error;
- return fail(400, { error: "Login failed", message, ...form });
- }
+ try {
+ await login(
+ user,
+ cookies,
+ request.headers.get("cf-connecting-ip"),
+ request.headers.get("host"),
+ );
+ } catch (e) {
+ const { message } = e as Error;
+ return fail(400, { error: "Login failed", message, ...form });
+ }
- redirect(307, loginRedirect || `/${user.username}`);
- },
+ redirect(307, loginRedirect || `/${user.username}`);
+ },
- nostr: async ({ cookies, fetch, request }) => {
- const form = await fd(request);
- let { challenge, event, loginRedirect, recaptcha } = form;
- if (loginRedirect === "null") loginRedirect = undefined;
- event = JSON.parse(event);
+ nostr: async ({ cookies, fetch, request }) => {
+ const form = await fd(request);
+ let { challenge, event, loginRedirect, recaptcha } = form;
+ if (loginRedirect === "null") loginRedirect = undefined;
+ event = JSON.parse(event);
- const maxAge = 380 * 24 * 60 * 60;
+ const maxAge = 380 * 24 * 60 * 60;
- const res = await fetch(`${PUBLIC_COINOS_URL}/nostrAuth`, {
- method: "POST",
- body: JSON.stringify({ challenge, event, recaptcha }),
- headers: {
- "content-type": "application/json",
- accept: "application/json",
- "cf-connecting-ip": request.headers.get("cf-connecting-ip"),
- "x-forwarded-host": request.headers.get("host"),
- },
- });
+ const res = await fetch(`${PUBLIC_COINOS_URL}/nostrAuth`, {
+ method: "POST",
+ body: JSON.stringify({ challenge, event, recaptcha }),
+ headers: {
+ "content-type": "application/json",
+ accept: "application/json",
+ "cf-connecting-ip": request.headers.get("cf-connecting-ip"),
+ "x-forwarded-host": request.headers.get("host"),
+ },
+ });
- const text = await res.text();
+ const text = await res.text();
- if (res.status === 401) {
- if (text.startsWith("2fa")) throw new Error("2fa");
- throw new Error(text);
- }
+ if (res.status === 401) {
+ if (text.startsWith("2fa")) throw new Error("2fa");
+ throw new Error(text);
+ }
- const { user, token } = JSON.parse(text);
- if (!token) throw new Error("Login failed");
- const { username, language } = user;
+ const { user, token } = JSON.parse(text);
+ if (!token) throw new Error("Login failed");
+ const { username, language } = user;
- const expires = new Date();
- expires.setSeconds(expires.getSeconds() + maxAge);
+ const expires = new Date();
+ expires.setSeconds(expires.getSeconds() + maxAge);
- const opts = { path: "/", expires };
- if (language) cookies.set("lang", language, opts);
- cookies.set("username", username, opts);
- cookies.set("token", token, opts);
+ const opts = { path: "/", expires };
+ if (language) cookies.set("lang", language, opts);
+ cookies.set("username", username, opts);
+ cookies.set("token", token, opts);
- redirect(307, loginRedirect || `/${username}`);
- },
+ redirect(307, loginRedirect || `/${username}`);
+ },
};
diff --git a/src/routes/(static)/login/+page.svelte b/src/routes/(static)/login/+page.svelte
index 2f67b48e..08694cd8 100644
--- a/src/routes/(static)/login/+page.svelte
+++ b/src/routes/(static)/login/+page.svelte
@@ -45,18 +45,23 @@
onMount(() => {
if (!isTor && recaptchaSiteKey) {
let s = document.createElement("script");
- s.src = "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
+ s.src =
+ "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
document.head.appendChild(s);
}
});
- let cancel: any = () => { need2fa = false; };
+ let cancel: any = () => {
+ need2fa = false;
+ };
let username: string | undefined = $state(),
email: any,
btn: HTMLButtonElement = $state() as any;
- $effect(() => { if (form) ({ username, password: $password } = form); });
+ $effect(() => {
+ if (form) ({ username, password: $password } = form);
+ });
let need2fa = $derived(form?.message === "2fa");
$effect(() => {
if (need2fa && form?.token === token) token = "";
@@ -67,7 +72,8 @@
const getRecaptchaToken = () =>
new Promise((resolve, reject) => {
if (isTor || !recaptchaSiteKey) return resolve("");
- if (!browser || !grecaptcha) return reject(new Error("captcha unavailable"));
+ if (!browser || !grecaptcha)
+ return reject(new Error("captcha unavailable"));
grecaptcha.ready(() => {
grecaptcha
.execute(recaptchaSiteKey, { action: "login" })
diff --git a/src/routes/(static)/login/[token]/+page.server.ts b/src/routes/(static)/login/[token]/+page.server.ts
index 8fe49578..f2750036 100644
--- a/src/routes/(static)/login/[token]/+page.server.ts
+++ b/src/routes/(static)/login/[token]/+page.server.ts
@@ -1,13 +1,13 @@
import { redirect } from "@sveltejs/kit";
export const load = async ({ cookies, params }) => {
- const { token } = params;
- const maxAge = 380 * 24 * 60 * 60;
+ const { token } = params;
+ const maxAge = 380 * 24 * 60 * 60;
- const expires = new Date();
- expires.setSeconds(expires.getSeconds() + maxAge);
+ const expires = new Date();
+ expires.setSeconds(expires.getSeconds() + maxAge);
- const opts = { path: "/", expires };
- cookies.set("token", token, opts);
- redirect(307, "/login");
+ const opts = { path: "/", expires };
+ cookies.set("token", token, opts);
+ redirect(307, "/login");
};
diff --git a/src/routes/(static)/register/+page.server.ts b/src/routes/(static)/register/+page.server.ts
index 2bcf6f2d..7fde82aa 100644
--- a/src/routes/(static)/register/+page.server.ts
+++ b/src/routes/(static)/register/+page.server.ts
@@ -2,25 +2,25 @@ import { fd, get, register } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export const load = async ({ parent }) => {
- const { user } = await parent();
- if (user) redirect(307, `/${user.username}`);
+ const { user } = await parent();
+ if (user) redirect(307, `/${user.username}`);
- const index = Math.floor(Math.random() * 64) + 1;
- const { challenge } = await get("/challenge");
+ const index = Math.floor(Math.random() * 64) + 1;
+ const { challenge } = await get("/challenge");
- return { index, challenge };
+ return { index, challenge };
};
export const actions = {
- default: async ({ cookies, request }) => {
- const ip = request.headers.get("cf-connecting-ip");
- const host = request.headers.get("host");
- const form = await fd(request);
- const { picture, username, password, challenge, recaptcha } = form;
- let { loginRedirect } = form;
- if (loginRedirect === "undefined") loginRedirect = undefined;
+ default: async ({ cookies, request }) => {
+ const ip = request.headers.get("cf-connecting-ip");
+ const host = request.headers.get("host");
+ const form = await fd(request);
+ const { picture, username, password, challenge, recaptcha } = form;
+ let { loginRedirect } = form;
+ if (loginRedirect === "undefined") loginRedirect = undefined;
- const user = { picture, username, password, challenge, recaptcha };
- return register(user, ip, cookies, loginRedirect, host);
- },
+ const user = { picture, username, password, challenge, recaptcha };
+ return register(user, ip, cookies, loginRedirect, host);
+ },
};
diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte
index 29aac7df..0200b15b 100644
--- a/src/routes/(static)/register/+page.svelte
+++ b/src/routes/(static)/register/+page.svelte
@@ -34,7 +34,8 @@
onMount(() => {
if (!isTor && recaptchaSiteKey) {
let s = document.createElement("script");
- s.src = "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
+ s.src =
+ "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
document.head.appendChild(s);
}
});
@@ -97,7 +98,9 @@
let code: any[] = [];
let redirect: any;
- let cancel: any = () => { need2fa = false; };
+ let cancel: any = () => {
+ need2fa = false;
+ };
let email: any,
btn: HTMLButtonElement = $state() as any;
@@ -106,7 +109,8 @@
const getRecaptchaToken = () =>
new Promise((resolve, reject) => {
if (isTor) return resolve("");
- if (!browser || !grecaptcha) return reject(new Error("captcha unavailable"));
+ if (!browser || !grecaptcha)
+ return reject(new Error("captcha unavailable"));
grecaptcha.ready(() => {
grecaptcha
.execute(recaptchaSiteKey, { action: "register" })
@@ -141,7 +145,11 @@
if ($avatar) {
try {
let { hash } = JSON.parse(
- await upload(($avatar as any).file, ($avatar as any).type, ($avatar as any).progress) as string,
+ (await upload(
+ ($avatar as any).file,
+ ($avatar as any).type,
+ ($avatar as any).progress,
+ )) as string,
);
let url = `${$page.url.origin}/api/public/${hash}.webp`;
diff --git a/src/routes/(static)/support/+page.svelte b/src/routes/(static)/support/+page.svelte
index c82a6cf9..dd5439d5 100644
--- a/src/routes/(static)/support/+page.svelte
+++ b/src/routes/(static)/support/+page.svelte
@@ -3,7 +3,8 @@
import { browser } from "$app/environment";
import { onDestroy, onMount } from "svelte";
import { fail, success, post } from "$lib/utils";
- import { scale } from "svelte/transition"; import { t } from "$lib/translations";
+ import { scale } from "svelte/transition";
+ import { t } from "$lib/translations";
let { data } = $props();
let user = $derived(data.user);
@@ -22,7 +23,8 @@
onMount(() => {
if (!isTor && recaptchaSiteKey) {
let s = document.createElement("script");
- s.src = "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
+ s.src =
+ "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
document.head.appendChild(s);
}
});
@@ -117,11 +119,7 @@
<label for="message" class="font-semibold"
>{$t("user.support.message")}</label
>
- <textarea
- rows={5}
- name="message"
- bind:value={message}
- required
+ <textarea rows={5} name="message" bind:value={message} required
></textarea>
</div>