diff options
| author | Adam Soltys <[email protected]> | 2026-03-02 23:37:57 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-02 23:37:57 -0800 |
| commit | 68684395a080a834d823b39e2e9641372bbafbfd (patch) | |
| tree | d9a02ed31ef3be0fe7c274b08597271e7dac8f15 /src/routes | |
| parent | 97fffca3e63e2edb4818305abdbcbb8953344aa3 (diff) | |
| download | coinos-ui-68684395a080a834d823b39e2e9641372bbafbfd.tar.gz coinos-ui-68684395a080a834d823b39e2e9641372bbafbfd.zip | |
dependency audit
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/[username]/(profile)/+page.ts | 4 | ||||
| -rw-r--r-- | src/routes/(app)/[username]/accepted/[text]/raw/+server.ts | 10 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.svelte | 1 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.svelte | 7 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/plain/+page.svelte | 5 | ||||
| -rw-r--r-- | src/routes/(app)/payments/[...page]/+page.svelte | 14 | ||||
| -rw-r--r-- | src/routes/(app)/qr/[text]/raw/+server.ts | 10 | ||||
| -rw-r--r-- | src/routes/+layout.ts | 10 |
8 files changed, 23 insertions, 38 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+page.ts b/src/routes/(app)/[username]/(profile)/+page.ts index e6a3ffeb..f60bee57 100644 --- a/src/routes/(app)/[username]/(profile)/+page.ts +++ b/src/routes/(app)/[username]/(profile)/+page.ts @@ -1,9 +1,9 @@ import { signer } from "$lib/store"; -import cookies from "js-cookie"; +import { getCookie } from "$lib/utils"; import { get } from "svelte/store"; export const ssr = false; export async function load() { - const sk = cookies.get("sk"); + const sk = getCookie("sk"); if (sk && !get(signer)) signer.set({ method: "nsec", params: { sk }, ready: true }); } diff --git a/src/routes/(app)/[username]/accepted/[text]/raw/+server.ts b/src/routes/(app)/[username]/accepted/[text]/raw/+server.ts index ad7fc6b1..77bb8a09 100644 --- a/src/routes/(app)/[username]/accepted/[text]/raw/+server.ts +++ b/src/routes/(app)/[username]/accepted/[text]/raw/+server.ts @@ -1,15 +1,13 @@ -import Qr from "qrcode-base64"; +import QRCode from "qrcode"; export async function GET({ params }) { const { text } = params; - const dataUri = Qr.drawImg(text, { size: 600 }); - const base64Data = dataUri.split(",")[1]; - const binaryData = Buffer.from(base64Data, "base64"); + const buffer = await QRCode.toBuffer(text, { width: 600, type: "png" }); - return new Response(binaryData, { + return new Response(buffer, { headers: { - "Content-Type": "image/gif", + "Content-Type": "image/png", "Cache-Control": "public, max-age=31536000, immutable", }, }); diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index 94d768aa..dea5a19b 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -7,7 +7,6 @@ import PhLightningFill from "virtual:icons/ph/lightning-fill"; import Amount from "$comp/Amount.svelte"; import Payments from "$comp/Payments.svelte"; - import { format } from "date-fns"; import { enhance } from "$app/forms"; import { page } from "$app/stores"; import Avatar from "$comp/Avatar.svelte"; diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 55daca8d..3e8c4788 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -5,7 +5,7 @@ import { browser } from "$app/environment"; import { onMount, tick } from "svelte"; import { t, loading } from "$lib/translations"; - import { copy, f, s, loc, toFiat, post, sats, fail, success, types } from "$lib/utils"; + import { copy, f, s, loc, toFiat, post, sats, fail, success, types, formatDate } from "$lib/utils"; import { fiat } from "$lib/store"; const toggleFiat = (e) => { @@ -14,9 +14,7 @@ $fiat = !$fiat; }; import Avatar from "$comp/Avatar.svelte"; - import { format } from "date-fns"; import { PUBLIC_EXPLORER, PUBLIC_LIQUID_EXPLORER } from "$env/static/public"; - import locales from "$lib/locales"; import { goto } from "$app/navigation"; let expanded: Set<string> = $state(new Set()); @@ -24,7 +22,6 @@ let { data } = $props(); let user = $derived(data.user); let p = $derived(data.payment); - let locale = $derived(user ? locales[user.language] : locales["en"]); let userLocale = $derived(loc(user)); let { @@ -192,7 +189,7 @@ </span> </button> <div class="text-secondary"> - {format(new Date(created), "MMM d, yyyy", { locale })}<span class="mx-3">{format(new Date(created), "h:mmaaa", { locale })}</span> + {formatDate(new Date(created), user?.language, { month: "short", day: "numeric", year: "numeric" })}<span class="mx-3">{formatDate(new Date(created), user?.language, { hour: "numeric", minute: "2-digit" })}</span> </div> </div> diff --git a/src/routes/(app)/payment/[id]/plain/+page.svelte b/src/routes/(app)/payment/[id]/plain/+page.svelte index 1efe2c32..d92ab58f 100644 --- a/src/routes/(app)/payment/[id]/plain/+page.svelte +++ b/src/routes/(app)/payment/[id]/plain/+page.svelte @@ -3,10 +3,9 @@ import { onMount } from "svelte"; import { browser } from "$app/environment"; import { t } from "$lib/translations"; - import { back, copy, f, s, toFiat, post, sats, success, types } from "$lib/utils"; + import { back, copy, f, s, toFiat, post, sats, success, types, formatDate } from "$lib/utils"; import { fiat } from "$lib/store"; import Avatar from "$comp/Avatar.svelte"; - import { format } from "date-fns"; import { PUBLIC_EXPLORER as expl } from "$env/static/public"; let { data } = $props(); @@ -66,7 +65,7 @@ <div> <span class="text-lg text-secondary">Date</span> - <div>{format(new Date(created), "MMMM d")}, {format(new Date(created), "h:mm aaa")}</div> + <div>{formatDate(new Date(created), "en", { month: "long", day: "numeric" })}, {formatDate(new Date(created), "en", { hour: "numeric", minute: "2-digit" })}</div> </div> {#if type === "bitcoin"} diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte index cbe5d07c..c34f04fe 100644 --- a/src/routes/(app)/payments/[...page]/+page.svelte +++ b/src/routes/(app)/payments/[...page]/+page.svelte @@ -3,12 +3,10 @@ import Avatar from "$comp/Avatar.svelte"; import Payments from "$comp/Payments.svelte"; import { onMount } from "svelte"; - import { format } from "date-fns"; import { newPayment, cachedPayments } from "$lib/store"; import { t } from "$lib/translations"; import { get, f, s, si, sat, loc, sats, types } from "$lib/utils"; import { page } from "$app/stores"; - import { differenceInDays, getUnixTime, sub } from "date-fns"; import { goto, invalidate } from "$app/navigation"; let { data } = $props(); @@ -26,28 +24,28 @@ let presets = $derived([ { title: $t("payments.day"), - start: sub(new Date(), { days: 1 }), + start: new Date(Date.now() - 86400000), end: null, }, { title: $t("payments.week"), - start: sub(new Date(), { days: 7 }), + start: new Date(Date.now() - 7 * 86400000), end: null, }, { title: $t("payments.month"), - start: sub(new Date(), { months: 1 }), + start: new Date(Date.now() - 30 * 86400000), end: null, }, { title: $t("payments.all"), - start: sub(new Date(), { years: 5 }), + start: new Date(Date.now() - 5 * 365 * 86400000), end: null, }, ]); let selection = $derived( - presets.findIndex((p) => Math.abs(differenceInDays(new Date(start * 1000), p.start)) < 1), + presets.findIndex((p) => Math.abs(new Date(start * 1000).getTime() - p.start.getTime()) < 86400000), ); $effect(() => { @@ -158,7 +156,7 @@ <div class="flex w-full gap-1"> {#each presets as { start, end, title }, i} <a - href={`/payments/${getUnixTime(start)}/1`} + href={`/payments/${Math.floor(start.getTime() / 1000)}/1`} class="btn !w-auto flex-1" class:!btn-active={selection === i} > diff --git a/src/routes/(app)/qr/[text]/raw/+server.ts b/src/routes/(app)/qr/[text]/raw/+server.ts index ad7fc6b1..77bb8a09 100644 --- a/src/routes/(app)/qr/[text]/raw/+server.ts +++ b/src/routes/(app)/qr/[text]/raw/+server.ts @@ -1,15 +1,13 @@ -import Qr from "qrcode-base64"; +import QRCode from "qrcode"; export async function GET({ params }) { const { text } = params; - const dataUri = Qr.drawImg(text, { size: 600 }); - const base64Data = dataUri.split(",")[1]; - const binaryData = Buffer.from(base64Data, "base64"); + const buffer = await QRCode.toBuffer(text, { width: 600, type: "png" }); - return new Response(binaryData, { + return new Response(buffer, { headers: { - "Content-Type": "image/gif", + "Content-Type": "image/png", "Cache-Control": "public, max-age=31536000, immutable", }, }); diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 719e35d6..0fcf5ec8 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,11 +1,7 @@ import { browser } from "$app/environment"; import { theme as themeStore } from "$lib/store"; import { addTranslations, setLocale, setRoute } from "$lib/translations/index"; -import cookies from "js-cookie"; - -const expires = new Date(); -expires.setSeconds(expires.getSeconds() + 21000000); -const opts = { path: "/", expires }; +import { getCookie, setCookie } from "$lib/utils"; /** @type {import('@sveltejs/kit').Load} */ export const load = async ({ data }) => { @@ -18,12 +14,12 @@ export const load = async ({ data }) => { await setLocale(locale); if (browser) { - let theme = cookies.get("theme"); + let theme = getCookie("theme"); if (!theme) { theme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; - cookies.set("theme", theme, opts); + setCookie("theme", theme, 21000000); if (theme === "dark") setTimeout(() => themeStore.set(theme), 100); } |
