aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-02 23:37:57 -0800
committerAdam Soltys <[email protected]>2026-03-02 23:37:57 -0800
commit68684395a080a834d823b39e2e9641372bbafbfd (patch)
treed9a02ed31ef3be0fe7c274b08597271e7dac8f15 /src/lib
parent97fffca3e63e2edb4818305abdbcbb8953344aa3 (diff)
downloadcoinos-ui-68684395a080a834d823b39e2e9641372bbafbfd.tar.gz
coinos-ui-68684395a080a834d823b39e2e9641372bbafbfd.zip
dependency audit
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/locales.ts41
-rw-r--r--src/lib/random.ts28
-rw-r--r--src/lib/socket.ts5
-rw-r--r--src/lib/utils.ts34
4 files changed, 33 insertions, 75 deletions
diff --git a/src/lib/locales.ts b/src/lib/locales.ts
deleted file mode 100644
index 83e7a1bf..00000000
--- a/src/lib/locales.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { de } from "date-fns/locale/de";
-import { el } from "date-fns/locale/el";
-import { enUS as en } from "date-fns/locale/en-US";
-import { es } from "date-fns/locale/es";
-import { faIR as fa } from "date-fns/locale/fa-IR";
-import { fr } from "date-fns/locale/fr";
-import { ja } from "date-fns/locale/ja";
-import { pt } from "date-fns/locale/pt";
-import { ru } from "date-fns/locale/ru";
-import { zhCN as zh } from "date-fns/locale/zh-CN";
-import { arSA as ar } from "date-fns/locale/ar-SA";
-import { hi } from "date-fns/locale/hi";
-import { bn } from "date-fns/locale/bn";
-import { tr } from "date-fns/locale/tr";
-import { ko } from "date-fns/locale/ko";
-import { it } from "date-fns/locale/it";
-import { nl } from "date-fns/locale/nl";
-import { th } from "date-fns/locale/th";
-import { pl } from "date-fns/locale/pl";
-
-export default {
- de,
- el,
- en,
- es,
- fa,
- fr,
- ja,
- pt,
- ru,
- zh,
- ar,
- hi,
- bn,
- tr,
- ko,
- it,
- nl,
- th,
- pl,
-};
diff --git a/src/lib/random.ts b/src/lib/random.ts
index 4c8dbda3..73afa443 100644
--- a/src/lib/random.ts
+++ b/src/lib/random.ts
@@ -1,15 +1,17 @@
-import { NumberDictionary, animals, colors, uniqueNamesGenerator } from "unique-names-generator";
+const animals = [
+ "alligator", "bear", "cat", "dog", "eagle", "falcon", "gorilla", "hawk",
+ "iguana", "jaguar", "koala", "lion", "moose", "newt", "otter", "penguin",
+ "quail", "rabbit", "shark", "tiger", "urchin", "viper", "walrus", "fox",
+ "yak", "zebra", "badger", "crane", "dolphin", "elk",
+];
-export const randomName = () =>
- uniqueNamesGenerator({
- dictionaries: [animals, NumberDictionary.generate({ min: 10, max: 99 })],
- length: 2,
- separator: "",
- });
+const colors = [
+ "red", "blue", "green", "gold", "silver", "coral", "amber", "violet",
+ "teal", "crimson", "ivory", "jade", "navy", "olive", "scarlet",
+];
-export const randomPassword = () =>
- uniqueNamesGenerator({
- dictionaries: [colors, NumberDictionary.generate({ min: 100, max: 999 })],
- length: 2,
- separator: "",
- });
+const pick = (arr: string[]) => arr[Math.floor(Math.random() * arr.length)];
+const randInt = (min: number, max: number) => min + Math.floor(Math.random() * (max - min + 1));
+
+export const randomName = () => pick(animals) + randInt(10, 99);
+export const randomPassword = () => pick(colors) + randInt(100, 999);
diff --git a/src/lib/socket.ts b/src/lib/socket.ts
index 46784503..b2d070fe 100644
--- a/src/lib/socket.ts
+++ b/src/lib/socket.ts
@@ -3,8 +3,7 @@ import { navigating, page } from "$app/stores";
import { PUBLIC_SOCKET } from "$env/static/public";
import { vaultForwarding } from "$lib/ark";
import { event, importing, invoice, last, lastPayment, paymentSignal, request } from "$lib/store";
-import { s, sleep, success, wait } from "$lib/utils";
-import cookies from "js-cookie";
+import { getCookie, s, sleep, success, wait } from "$lib/utils";
import { get } from "svelte/store";
export let socket;
@@ -61,7 +60,7 @@ export const messages = (data) => ({
url: { pathname },
} = get(page);
- const username = cookies.get("username");
+ const username = getCookie("username");
if (amount > 0 && !vaultForwarding) {
if (
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 7a4030d5..6815a5b2 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -6,12 +6,7 @@ import { sha256 } from "@noble/hashes/sha2.js";
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
import { fail as svelteFail, redirect } from "@sveltejs/kit";
import { toast } from "@zerodevx/svelte-toast";
-import {
- differenceInDays,
- differenceInHours,
- differenceInMinutes,
- differenceInSeconds,
-} from "date-fns";
+
import { get as getStore } from "svelte/store";
export function scroll(section: any) {
@@ -484,20 +479,23 @@ export const versions = {
export const str = (s) => s.toString();
-export const ago = (t) => {
- const now = new Date();
- const date = new Date(t * 1000);
- const seconds = differenceInSeconds(now, date);
- if (seconds < 60) return `${seconds}s`;
-
- const minutes = differenceInMinutes(now, date);
- if (minutes < 60) return `${minutes}m`;
+const localeTagMap: Record<string, string> = {
+ en: "en-US",
+ fa: "fa-IR",
+ zh: "zh-CN",
+ ar: "ar-SA",
+};
+export const toLocaleTag = (lang = "en") => localeTagMap[lang] || lang;
- const hours = differenceInHours(now, date);
- if (hours < 24) return `${hours}h`;
+export const formatDate = (date: Date, lang = "en", opts: Intl.DateTimeFormatOptions = {}) =>
+ new Intl.DateTimeFormat(toLocaleTag(lang), opts).format(date);
- const days = differenceInDays(now, date);
- return `${days}d`;
+export const ago = (t) => {
+ const diff = Math.floor((Date.now() - t * 1000) / 1000);
+ if (diff < 60) return `${diff}s`;
+ if (diff < 3600) return `${Math.floor(diff / 60)}m`;
+ if (diff < 86400) return `${Math.floor(diff / 3600)}h`;
+ return `${Math.floor(diff / 86400)}d`;
};
export const register = async (