aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte2
-rw-r--r--src/routes/(app)/[username]/receive/+page.svelte7
-rw-r--r--src/routes/(app)/account/[id]/+page.svelte6
-rw-r--r--src/routes/(app)/account/ark/+page.svelte12
-rw-r--r--src/routes/(app)/account/pass/+page.svelte16
-rw-r--r--src/routes/(app)/dm/+page.svelte58
-rw-r--r--src/routes/(app)/firehose/+page.svelte4
-rw-r--r--src/routes/(app)/fund/[id]/+page.svelte4
-rw-r--r--src/routes/(app)/fund/[id]/access/+page.svelte2
-rw-r--r--src/routes/(app)/invoice/[id]/+page.svelte5
-rw-r--r--src/routes/(app)/invoice/[id]/tip/+page.svelte28
-rw-r--r--src/routes/(app)/messages/+page.svelte18
-rw-r--r--src/routes/(app)/messages/[recipient]/+page.svelte28
-rw-r--r--src/routes/(app)/payment/[id]/+page.svelte2
-rw-r--r--src/routes/(app)/pos/+page.svelte30
-rw-r--r--src/routes/(app)/send/[...text]/+page.svelte4
-rw-r--r--src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte2
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte28
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.svelte12
-rw-r--r--src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.server.ts2
-rw-r--r--src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte16
-rw-r--r--src/routes/(app)/send/zap/[id]/[...amount]/+page.svelte30
-rw-r--r--src/routes/(app)/settings/+layout.svelte40
-rw-r--r--src/routes/(app)/settings/account/+page.svelte15
-rw-r--r--src/routes/(app)/settings/nostr/+page.svelte18
-rw-r--r--src/routes/(app)/settings/profile/+page.svelte19
-rw-r--r--src/routes/(app)/settings/security/+page.svelte34
-rw-r--r--src/routes/(static)/bounties/+page.svelte2
-rw-r--r--src/routes/(static)/login/+page.svelte32
-rw-r--r--src/routes/(static)/register/+page.svelte66
-rw-r--r--src/routes/(static)/support/+page.svelte5
31 files changed, 275 insertions, 272 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index 5734c71f..8331c98e 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -29,7 +29,7 @@
try {
await post(`/reset`, { username: n, password });
success("Password reset");
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte
index 009422a5..6921d443 100644
--- a/src/routes/(app)/[username]/receive/+page.svelte
+++ b/src/routes/(app)/[username]/receive/+page.svelte
@@ -26,7 +26,7 @@
import { goto, invalidate } from "$app/navigation";
import { page } from "$app/stores";
- let { data } = $props();
+ let { data }: any = $props();
let showOptions;
@@ -40,7 +40,7 @@
let qr;
let aid = $derived(subject.id);
- let invoice = $derived({
+ let invoice: any = $derived({
aid,
type: types.lightning,
items: [],
@@ -65,7 +65,7 @@
else url += "?options=true";
goto(url, { invalidateAll: true, noScroll: true });
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
@@ -158,7 +158,6 @@
{invoice}
{copy}
{link}
- {type}
{showQr}
{txt}
t={$t}
diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte
index ad977e7a..4a23a211 100644
--- a/src/routes/(app)/account/[id]/+page.svelte
+++ b/src/routes/(app)/account/[id]/+page.svelte
@@ -40,7 +40,7 @@
mnemonic = entropyToMnemonic(entropy, wordlist);
password = cached;
return true;
- } catch (e) {
+ } catch (e: any) {
forgetWalletPassword();
return false;
}
@@ -57,7 +57,7 @@
const { decrypt } = await import("nostr-tools/nip49");
let entropy = await decrypt(seed, password);
mnemonic = entropyToMnemonic(entropy, wordlist);
- } catch (e) {
+ } catch (e: any) {
fail("Invalid password, try again");
passwordPrompt = true;
}
@@ -67,7 +67,7 @@
try {
await post("/api/account/delete", { id });
goto(`/${user.username}`);
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
diff --git a/src/routes/(app)/account/ark/+page.svelte b/src/routes/(app)/account/ark/+page.svelte
index 32dbfe13..0c4d8783 100644
--- a/src/routes/(app)/account/ark/+page.svelte
+++ b/src/routes/(app)/account/ark/+page.svelte
@@ -66,12 +66,12 @@
let seed = await mnemonicToSeed(mnemonic, pw);
let master = HDKey.fromMasterSeed(seed, versions);
let arkChild = master.derive("m/86'/0'/0'/0/0");
- let arkHex = bytesToHex(arkChild.privateKey);
+ let arkHex = bytesToHex(arkChild.privateKey!);
const identity = SingleKey.fromHex(arkHex);
const wallet = await Wallet.create({ identity, arkServerUrl });
arkAddress = await wallet.getAddress();
confirmed = true;
- } catch (e) {
+ } catch (e: any) {
console.log("master seed derivation failed", e);
fail("Invalid password");
}
@@ -117,7 +117,7 @@
forgetWalletPassword();
}
goto(`/${user.username}`);
- } catch (e) {
+ } catch (e: any) {
console.log(e);
fail(e.message);
}
@@ -150,7 +150,7 @@
forgetWalletPassword();
}
goto(`/${user.username}`);
- } catch (e) {
+ } catch (e: any) {
console.log(e);
fail(e.message);
}
@@ -220,7 +220,7 @@
id="rememberFor"
class="w-full"
value={rememberForMs}
- onchange={(e) => (rememberForMs = Number(e.target.value))}
+ onchange={(e) => (rememberForMs = Number((e.target as HTMLSelectElement).value))}
>
{#each rememberForOptions as option}
<option value={option.ms}>{option.label}</option>
@@ -371,7 +371,7 @@
id="rememberFor"
class="w-full"
value={rememberForMs}
- onchange={(e) => (rememberForMs = Number(e.target.value))}
+ onchange={(e) => (rememberForMs = Number((e.target as HTMLSelectElement).value))}
>
{#each rememberForOptions as option}
<option value={option.ms}>{option.label}</option>
diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte
index a64d95ee..4e9573d4 100644
--- a/src/routes/(app)/account/pass/+page.svelte
+++ b/src/routes/(app)/account/pass/+page.svelte
@@ -21,13 +21,13 @@
forgetWalletPassword,
} from "$lib/passwordCache";
- let { data } = $props();
+ let { data }: any = $props();
let { user } = data;
- let submitting = $state();
+ let submitting = $state(false);
- let confirm = $state(),
- password = $state(),
+ let confirm: string = $state(""),
+ password: string = $state(""),
revealPassword = $state(),
revealConfirm = $state();
let rememberForMs = $state(defaultRememberForMs);
@@ -47,7 +47,7 @@
try {
const { encrypt } = await import("nostr-tools/nip49");
let seed = await encrypt(
- mnemonicToEntropy($mnemonic, wordlist),
+ mnemonicToEntropy($mnemonic as string, wordlist),
password,
);
@@ -55,7 +55,7 @@
await post("/post/user", { seed });
let master = HDKey.fromMasterSeed(
- await mnemonicToSeed($mnemonic, password),
+ await mnemonicToSeed($mnemonic as string, password),
versions,
);
@@ -78,7 +78,7 @@
}
$mnemonic = "";
goto(`/${user.username}`);
- } catch (e) {
+ } catch (e: any) {
console.log(e);
fail(e.message);
}
@@ -188,7 +188,7 @@
id="rememberFor"
class="w-full"
value={rememberForMs}
- onchange={(e) => (rememberForMs = Number(e.target.value))}
+ onchange={(e) => (rememberForMs = Number((e.target as HTMLSelectElement).value))}
>
{#each rememberForOptions as option}
<option value={option.ms}>{option.label}</option>
diff --git a/src/routes/(app)/dm/+page.svelte b/src/routes/(app)/dm/+page.svelte
index 7b864f89..95cb208e 100644
--- a/src/routes/(app)/dm/+page.svelte
+++ b/src/routes/(app)/dm/+page.svelte
@@ -23,7 +23,7 @@
}
/// chat selection
- const usernameFromPubkey = async (pubkey: string): string => {
+ const usernameFromPubkey = async (pubkey: string): Promise<string | null> => {
const response = await fetch(`/api/users/${pubkey}`);
if (response.ok) {
const userInfo = await response.json();
@@ -35,7 +35,7 @@
const userInfo = async (pubkey: string) => {
if (pubkey.slice(0, 4) === "npub") {
- return userInfo(decode(pubkey).data);
+ return userInfo(decode(pubkey).data as string);
}
const nostrUserInfo = await getNostrUserInfo(pubkey) || {};
@@ -48,11 +48,11 @@
nip05Valid: valid, pubkey };
}
- const name = (userInfo: object): string => {
+ const name = (userInfo: any): string => {
return userInfo.coinosUsername || userInfo.nostrName || $t("dm.anonymous");
}
- const id = (userInfo: object): string => {
+ const id = (userInfo: any): string => {
if (userInfo.nip05 && userInfo.nip05.slice(0, 2) == "_@") {
return userInfo.nip05.slice(2);
}
@@ -60,11 +60,11 @@
return userInfo.nip05 || (npubEncode(userInfo.pubkey).slice(0, 16) + "...");
}
- const idValid = (userInfo: object): string => {
+ const idValid = (userInfo: any): boolean => {
return !userInfo.nip05 || userInfo.nip05Valid;
}
- const rumourInvolves = (rumour: object, pubkey: string) => {
+ const rumourInvolves = (rumour: any, pubkey: string) => {
if (rumour.pubkey === pubkey) {
return true;
} else {
@@ -77,7 +77,7 @@
}
}
- const mostRecentCommunication = (rumours: object[], pubkey: string) => {
+ const mostRecentCommunication = (rumours: any[], pubkey: string) => {
let mostRecentTime = null;
for (const rumour of rumours.filter((r) => rumourInvolves(r, pubkey))) {
if (!mostRecentTime || rumour.created_at > mostRecentTime) {
@@ -87,9 +87,9 @@
return mostRecentTime;
}
- const updateSendersRecipients = async (rumours: object[]) => {
- const senders = new Set<object>();
- const recipients = new Set<object>();
+ const updateSendersRecipients = async (rumours: any[]) => {
+ const senders = new Set<any>();
+ const recipients = new Set<any>();
for (const rumour of rumours) {
if (rumour.pubkey !== user.pubkey) {
senders.add(await userInfo(rumour.pubkey));
@@ -102,7 +102,7 @@
messageSenders = Array.from(senders);
messageRecipients = Array.from(recipients);
- const chatMap = new Map<string, object>();
+ const chatMap = new Map<string, any>();
for (const sender of senders) {
chatMap.set(sender.pubkey, sender);
}
@@ -110,31 +110,31 @@
chatMap.set(recipient.pubkey, recipient);
}
chats = Array.from(chatMap.values());
- chats.sort((a, b) => mostRecentCommunication(rumours, b.pubkey) - mostRecentCommunication(rumours, a.pubkey));
+ chats.sort((a, b) => (mostRecentCommunication(rumours, b.pubkey) ?? 0) - (mostRecentCommunication(rumours, a.pubkey) ?? 0));
};
- let messageSenders = $state([]);
- let messageRecipients = $state([]);
- let chats = $state([]);
+ let messageSenders: any[] = $state([]);
+ let messageRecipients: any[] = $state([]);
+ let chats: any[] = $state([]);
getMessageRumours(user).then(updateSendersRecipients);
- let selectedChat = $state(null);
+ let selectedChat: any = $state(null);
let creatingNewChat = $state(false);
let searchQuery = $state("");
/// individual chat
let text = $state("");
- let allRumours = $state([]);
- let messageRumours = $state([]);
- let dates = $state([]);
+ let allRumours: any[] = $state([]);
+ let messageRumours: any = $state([]);
+ let dates: any[] = $state([]);
let relayWarningShown = $state(false);
let expiryEnabled = $state(false);
let expiryDays = $state(7);
let canSend = $state(false);
let canSendExpiring = $state(false);
- let nostrUserInfo = $state({});
+ let nostrUserInfo: any = $state({});
- const includesPubkey = (chats: object[], pubkey: string) => {
+ const includesPubkey = (chats: any[], pubkey: string) => {
for (const c of chats) {
if (c.pubkey === pubkey) {
return true;
@@ -143,7 +143,7 @@
return false;
}
- const selectChat = (c: object) => {
+ const selectChat = (c: any) => {
selectedChat = c;
if (!includesPubkey(chats, c.pubkey)) {
chats.unshift(c);
@@ -184,23 +184,23 @@
onMount(() => {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('username')) {
- selectChatUsername(urlParams.get('username'));
+ selectChatUsername(urlParams.get('username')!);
} else if (urlParams.get('nip05')) {
- selectChatNip05(urlParams.get('nip05'));
+ selectChatNip05(urlParams.get('nip05')!);
} else if (urlParams.get('pubkey')) {
- selectChatPubkey(urlParams.get('pubkey'));
+ selectChatPubkey(urlParams.get('pubkey')!);
}
});
- const appendMultimap = (map: Map, key: string, value: object) => {
+ const appendMultimap = (map: Map<any, any>, key: any, value: any) => {
if (map.has(key)) {
- map.get(key).push(value);
+ map.get(key)!.push(value);
} else {
map.set(key, [value]);
}
}
- const dateMap = (events: object[]): Map<number, object> => {
+ const dateMap = (events: any[]): Map<any, any> => {
let eventsMap = new Map();
for (const event of events) {
const created = Math.floor(event.created_at / 86400);
@@ -249,7 +249,7 @@
}
const sendMessage = async (message: string) => {
- const expiry = expiryEnabled ? expiryDays : null;
+ const expiry = expiryEnabled ? expiryDays : undefined;
await libnip17.send(message, user, selectedChat, expiry);
updateEvents();
}
diff --git a/src/routes/(app)/firehose/+page.svelte b/src/routes/(app)/firehose/+page.svelte
index 6b2338c2..2fdaa4d0 100644
--- a/src/routes/(app)/firehose/+page.svelte
+++ b/src/routes/(app)/firehose/+page.svelte
@@ -4,7 +4,7 @@
import { onMount } from "svelte";
import { ignore } from "$lib/store";
- let events = $state([]);
+ let events: any[] = $state([]);
let paused = $state();
let pause = (e) => {
e.preventDefault();
@@ -21,7 +21,7 @@
const { Relay } = await import("nostr-tools/relay");
const relay = await Relay.connect("wss://relay.primal.net");
const subscription = relay.subscribe([{ kinds: [1], limit: 20 }], {
- async onevent(event) {
+ async onevent(event: any) {
if (paused) return;
const { parts, names } = await post("/post/parseEvent", { event });
event.author = await get(`/api/users/${event.pubkey}`);
diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte
index 5f8d848f..c3fa7ce1 100644
--- a/src/routes/(app)/fund/[id]/+page.svelte
+++ b/src/routes/(app)/fund/[id]/+page.svelte
@@ -12,7 +12,7 @@
import { bech32 } from "@scure/base";
const encoder = new TextEncoder();
- let { data } = $props();
+ let { data }: any = $props();
let { amount, payments, managers, rate, user } = data;
let { id } = $page.params;
@@ -21,7 +21,7 @@
let currency = user ? user.currency : "CAD";
let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2)));
- $effect(() => ($loginRedirect = $page.url.pathname));
+ $effect(() => { $loginRedirect = $page.url.pathname; });
let show = $state();
let toggle = () => (show = !show);
diff --git a/src/routes/(app)/fund/[id]/access/+page.svelte b/src/routes/(app)/fund/[id]/access/+page.svelte
index 9a7a85cb..24ded54e 100644
--- a/src/routes/(app)/fund/[id]/access/+page.svelte
+++ b/src/routes/(app)/fund/[id]/access/+page.svelte
@@ -15,7 +15,7 @@
m = await post(`/post/fund/${id}/managers/delete`, {
id: user.id,
});
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte
index beffa264..bf62a062 100644
--- a/src/routes/(app)/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/+page.svelte
@@ -28,7 +28,7 @@
import { t } from "$lib/translations";
import { goto, invalidate } from "$app/navigation";
- let { data } = $props();
+ let { data }: any = $props();
let showOptions;
@@ -91,7 +91,7 @@
else url += "?options=true";
goto(url, { invalidateAll: true, noScroll: true });
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
@@ -185,7 +185,6 @@
{invoice}
{copy}
{link}
- {type}
{txt}
t={$t}
bind:showQr={$showQr}
diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte
index c9f38837..4d3af188 100644
--- a/src/routes/(app)/invoice/[id]/tip/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte
@@ -10,10 +10,10 @@
const tipAmounts = ["No", "10%", "15%", "20%"];
let showCustomAmount = $state();
- let customInput = $state();
- let customTipAmount = $state();
+ let customInput: HTMLInputElement = $state() as any;
+ let customTipAmount: number = $state(0);
- let apply = async (e) => {
+ let apply = async (e: Event) => {
e.preventDefault();
if (customTipAmount > 0) {
@@ -25,24 +25,24 @@
let active = (amount) =>
!customTipAmount && Math.round(tipPercent) === parseInt(amount.slice(0, 2));
- const handleCustomTipAmount = (e) => {
- customTipAmount = e.target.value;
+ const handleCustomTipAmount = (e: Event) => {
+ customTipAmount = Number((e.target as HTMLInputElement).value);
tipPercent = (customTipAmount / amountFiat) * 100;
tip = Math.round((amount / 100) * tipPercent);
};
let timeout;
- const handleSlide = (e) => {
- customTipAmount = "";
+ const handleSlide = (e: Event) => {
+ customTipAmount = 0;
if (customInput) {
customInput.value = "";
}
- tipPercent = e.target.value;
+ tipPercent = Number((e.target as HTMLInputElement).value);
tip = Math.round((amount / 100) * tipPercent);
};
let submitting = $state();
- const handleTipButtonClick = async (v) => {
+ const handleTipButtonClick = async (v: string) => {
submitting = true;
if (v === "No") {
tipPercent = 0;
@@ -56,9 +56,9 @@
submit.click();
};
- let submit = $state();
+ let submit: HTMLButtonElement = $state() as any;
- let { data } = $props();
+ let { data }: any = $props();
let { invoice, id, user } = $state(data);
let {
aid,
@@ -87,7 +87,7 @@
});
let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2)));
- let tipAmount = $derived(((tip * rate) / sats).toFixed(2));
+ let tipAmount = $derived(parseFloat(((tip * rate) / sats).toFixed(2)));
let invoiceAmountFiatFormatted = $derived(f(amountFiat, currency));
</script>
@@ -147,14 +147,14 @@
use:focus
type="button"
class="btn"
- class:active={active(amount, tipPercent)}
+ class:active={active(amount)}
onclick={() => handleTipButtonClick(amount)}>{amount}</button
>
{:else}
<button
type="button"
class="btn"
- class:active={active(amount, tipPercent)}
+ class:active={active(amount)}
onclick={() => handleTipButtonClick(amount)}>{amount}</button
>
{/if}
diff --git a/src/routes/(app)/messages/+page.svelte b/src/routes/(app)/messages/+page.svelte
index 606af893..2de56e0b 100644
--- a/src/routes/(app)/messages/+page.svelte
+++ b/src/routes/(app)/messages/+page.svelte
@@ -9,24 +9,24 @@
let { data } = $props();
- let { messages, notes, invoices, sent, received, subject, user } =
+ let { messages, notes, invoices, sent, received, subject, user }: any =
$state(data);
- let refresh = (d) =>
+ let refresh = (d: any) =>
({ messages, notes, invoices, sent, received, subject, user } = d);
let keys = new Set();
- let latest = $state([]);
- let ready;
+ let latest: any[] = $state([]);
+ let ready: any;
- e.subscribe(async (event) => {
+ e.subscribe(async (event: any) => {
if (!(browser && event && ready)) return;
if (
event.recipient?.id === user.id &&
- !~latest.findIndex((m) => m.id === event.id)
+ !~latest.findIndex((m: any) => m.id === event.id)
) {
event.content = await decrypt({ event, user });
- let i = latest.findIndex((m) => m.pubkey === event.pubkey);
+ let i = latest.findIndex((m: any) => m.pubkey === event.pubkey);
let popped;
if (~i) popped = latest.splice(i, 1);
else popped = latest.pop();
@@ -36,7 +36,7 @@
}
});
- let initialize = async (p) => {
+ let initialize = async (p: any) => {
let i = 0;
ready = false;
if (!(browser && user)) return;
@@ -80,7 +80,7 @@
<a href={`/messages/${u.username}`}>
<div class="flex hover:bg-gray-100 p-4 rounded-2xl">
<div class="my-auto">
- <Avatar user={u} size={"20"} disabled={true} />
+ <Avatar user={u} size={20} disabled={true} />
</div>
<div class="my-auto truncate">
<div class="my-auto ml-1 text-lg font-bold">{u.username}</div>
diff --git a/src/routes/(app)/messages/[recipient]/+page.svelte b/src/routes/(app)/messages/[recipient]/+page.svelte
index c8d522f0..f399ab25 100644
--- a/src/routes/(app)/messages/[recipient]/+page.svelte
+++ b/src/routes/(app)/messages/[recipient]/+page.svelte
@@ -15,12 +15,12 @@
let { data } = $props();
function fadeScale(
- node,
- { delay = 0, duration = 200, easing = (x) => x, baseScale = 0 },
+ node: any,
+ { delay = 0, duration = 200, easing = (x: number) => x, baseScale = 0 },
) {
const o = +getComputedStyle(node).opacity;
const m = getComputedStyle(node).transform.match(/scale\(([0-9.]+)\)/);
- const s = m ? m[1] : 1;
+ const s: any = m ? m[1] : 1;
const is = 1 - baseScale;
return {
@@ -35,10 +35,10 @@
};
}
- let { messages, recipient, user } = $state(data);
- let input, pane = $state();
+ let { messages, recipient, user }: any = $state(data);
+ let input: any, pane: any = $state();
- let initialize = async (p) => {
+ let initialize = async (p: any) => {
await Promise.all(
messages.map(
async (event) => (event.message = await decrypt({ event, user })),
@@ -49,8 +49,8 @@
tick().then(() => pane && (pane.scrollTop = pane.scrollHeight));
};
- e.subscribe(async (event) => {
- let found = ~messages.findIndex((m) => m.id === event?.id);
+ e.subscribe(async (event: any) => {
+ let found = ~messages.findIndex((m: any) => m.id === event?.id);
if (event?.recipient.id === user.id && !found) {
event.message = await decrypt({ event, user });
messages.push(event);
@@ -59,11 +59,11 @@
}
});
- let sent, submitting, message = $state();
+ let sent: any, submitting: any, message: any = $state();
let submit = async () => {
submitting = true;
- let event = {
+ let event: any = {
pubkey: user.pubkey,
created_at: Math.floor(Date.now() / 1000),
kind: 4,
@@ -93,8 +93,8 @@
await send(event);
sent = true;
- } catch (e) {
- console.log(e);
+ } catch (err: any) {
+ console.log(err);
fail("Failed to send message");
}
@@ -102,7 +102,7 @@
submitting = false;
};
- let keydown = (e) => {
+ let keydown = (e: any) => {
if (e.key === "Enter") {
e.preventDefault();
submit();
@@ -149,7 +149,7 @@
{message}
</div>
<div class="mt-auto">
- <Avatar user={author} size={"12"} />
+ <Avatar user={author} size={12} />
</div>
</div>
<div class="text-sm text-gray-400 mb-6" class:text-right={ours}>
diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte
index e368f2ad..436a7ab6 100644
--- a/src/routes/(app)/payment/[id]/+page.svelte
+++ b/src/routes/(app)/payment/[id]/+page.svelte
@@ -66,7 +66,7 @@
let bump = async () => {
try {
await post(`/payment/${id}/bump`, { id });
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
diff --git a/src/routes/(app)/pos/+page.svelte b/src/routes/(app)/pos/+page.svelte
index 967ddd09..6806fec3 100644
--- a/src/routes/(app)/pos/+page.svelte
+++ b/src/routes/(app)/pos/+page.svelte
@@ -3,7 +3,7 @@
import { hex } from "@scure/base";
// Convert Uint8Array → JS "binary string" in safe chunks
- function bs(uint8Array) {
+ function bs(uint8Array: Uint8Array) {
let binaryString = "";
const chunkSize = 0x8000;
for (let i = 0; i < uint8Array.length; i += chunkSize) {
@@ -13,7 +13,7 @@
return binaryString;
}
- let { data, form } = $props();
+ let { data, form }: any = $props();
let { token } = $state(data);
// --- Defaults ---
@@ -23,12 +23,12 @@
const WORK_BAUD = 921600; // fast flashing
// --- Shared state ---
- let esploader = $state();
- let chip, transport;
+ let esploader: any = $state();
+ let chip: any, transport: any;
let connected = $state(false);
let portInfo = $state("");
- let ESPLoader;
- let Transport;
+ let ESPLoader: any;
+ let Transport: any;
// --- Existing config path (generated server-side to hex in form.bytes) ---
let bytes = $derived(form ? hex.decode(form.bytes) : undefined);
@@ -37,8 +37,8 @@
let configDone = $state(false);
// --- New firmware flashing path ---
- let fwFile = $state(null);
- let fwBytes = $state(); // Uint8Array
+ let fwFile: any = $state(null);
+ let fwBytes: Uint8Array | undefined = $state(); // Uint8Array
let fwAddress = $state(FW_ADDRESS_DEFAULT);
let fwEraseAll = $state(false);
let fwProgress = $state(0);
@@ -53,7 +53,7 @@
if (!ESPLoader || !Transport) {
({ ESPLoader, Transport } = await import("esptool-js"));
}
- const device = await navigator.serial.requestPort({});
+ const device = await (navigator as any).serial.requestPort({});
transport = new Transport(device, true);
esploader = new ESPLoader({
transport,
@@ -90,10 +90,10 @@
configDone = true;
};
- function onPickFw(e) {
+ function onPickFw(e: Event) {
fwError = "";
fwDone = false;
- const f = e.target.files?.[0];
+ const f = (e.target as HTMLInputElement).files?.[0];
fwFile = f || null;
if (!fwFile) {
fwBytes = undefined;
@@ -101,7 +101,7 @@
}
const reader = new FileReader();
reader.onload = () => {
- const buf = new Uint8Array(reader.result);
+ const buf = new Uint8Array(reader.result as ArrayBuffer);
fwBytes = buf;
};
reader.onerror = () => {
@@ -138,7 +138,7 @@
});
fwDone = true;
- } catch (e) {
+ } catch (e: any) {
console.error(e);
fwError = e?.message || "Flash failed.";
}
@@ -178,7 +178,7 @@
id="littlefs-address"
class="input"
bind:value={littlefsAddress}
- onchange={(e) => (littlefsAddress = Number(e.target.value))}
+ onchange={(e) => (littlefsAddress = Number((e.target as HTMLInputElement).value))}
/>
<div class="mt-3">
<button class="btn" onclick={flashConfig}>Flash config</button>
@@ -214,7 +214,7 @@
id="firmware-address"
class="input"
bind:value={fwAddress}
- onchange={(e) => (fwAddress = Number(e.target.value))}
+ onchange={(e) => (fwAddress = Number((e.target as HTMLInputElement).value))}
/>
<label class="flex items-center gap-2 mt-2">
diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte
index 25a77a1e..34acb4b0 100644
--- a/src/routes/(app)/send/[...text]/+page.svelte
+++ b/src/routes/(app)/send/[...text]/+page.svelte
@@ -21,10 +21,10 @@
all = await get("/contacts");
};
- let el = $state(),
+ let el: any = $state(),
text = $state(),
pasted = $state(),
- w = $state();
+ w: number | undefined = $state();
let keypress = (e) =>
e.key === "Enter" ? e.preventDefault() || el.click() : (pasted = false);
diff --git a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte
index ea1e9f71..f5bc3bc6 100644
--- a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte
+++ b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte
@@ -32,7 +32,7 @@
});
goto(`/sent/${p.id}`, { invalidateAll: true });
- } catch (e) {
+ } catch (e: any) {
submitting = false;
error = e.message || "Failed to send";
}
diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
index faa6c919..ecdb3b08 100644
--- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
+++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte
@@ -22,11 +22,11 @@
import Amount from "$comp/Amount.svelte";
- let { data, form } = $props();
+ let { data, form }: any = $props();
let { encode, decode } = hexUtil;
let passwordPrompt = $state();
- let password = $state();
+ let password: any = $state();
let cancel = $state(() => (passwordPrompt = false));
let signed = $state();
let loading = $state(false);
@@ -39,7 +39,7 @@
password = cached;
await signTx();
return true;
- } catch (e) {
+ } catch (e: any) {
forgetWalletPassword();
return false;
}
@@ -69,7 +69,7 @@
user: data.user,
});
goto(`/sent/${p.id}`, { invalidateAll: true });
- } catch (e) {
+ } catch (e: any) {
loading = false;
error = e.message || "Failed to send";
}
@@ -102,15 +102,15 @@
import("@scure/bip39"),
import("@scure/bip39/wordlists/english.js"),
]);
- let entropy = await decrypt(account.seed || data.user.seed, password);
+ let entropy = await decrypt(account.seed || data.user.seed, password as string);
let mnemonic = entropyToMnemonic(entropy, wordlist);
- let seed = await mnemonicToSeed(mnemonic, password);
- let master = HDKey.fromMasterSeed(seed, network);
+ let seed = await mnemonicToSeed(mnemonic, password as string);
+ let master = HDKey.fromMasterSeed(seed, network as any);
let child = master.derive(`m/84'/0'/${account.accountIndex ?? 0}'`);
let raw = decode(hex);
let isPSBT = raw[0] === 0x70 && raw[1] === 0x73 && raw[2] === 0x62 && raw[3] === 0x74;
- let tx = isPSBT ? Transaction.fromPSBT(raw) : Transaction.fromRaw(raw);
+ let tx: any = isPSBT ? Transaction.fromPSBT(raw) : Transaction.fromRaw(raw);
for (let [i, input] of tx.inputs.entries()) {
let { witnessUtxo, path } = inputs[i];
@@ -120,14 +120,14 @@
tx.updateInput(i, { witnessUtxo });
}
let key = child.derive(path);
- tx.signIdx(key.privateKey, i);
+ tx.signIdx(key.privateKey!, i);
}
tx.finalize();
hex = tx.hex;
signed = true;
await tick();
- submit.click();
+ (submit as any).click();
};
let toggle = () => (submitting = !submitting);
@@ -145,7 +145,7 @@
inputs,
} = $derived(data);
- let { feeRate } = $state(data);
+ let { feeRate }: any = $state(data);
$effect(() => {
if (fees) {
@@ -162,8 +162,8 @@
let { balance, currency } = data.user;
let submitting = $state(),
- submit = $state(),
- showSettings;
+ submit: any = $state(),
+ showSettings = $state();
let feeNames = {
fastestFee: $t("payments.fastest"),
@@ -247,7 +247,7 @@
</div>
{#if passwordPrompt}
- <WalletPass bind:password bind:cancel submit={signTx} />
+ <WalletPass bind:password {cancel} submit={signTx} />
{/if}
<style>
diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte
index 2a2d72e2..f3f2f618 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/send/invoice/[id]/+page.svelte
@@ -23,7 +23,7 @@
focus,
loc,
} from "$lib/utils";
- let { data, form } = $props();
+ let { data, form }: any = $props();
let { trusted, balance, invoice, user } = $state(data);
let { address, hash, payreq, user: recipient, tip } = $state(data.invoice);
@@ -33,8 +33,8 @@
let rate = $derived(invoice.rate * (data.rate / data.invoiceRate));
- let a = $state(),
- af = $state(),
+ let a: any = $state(),
+ af: any = $state(),
fiat = $state(untrack(() => !amount));
let amountFiat = $state((untrack(() => amount) * untrack(() => rate)) / sats);
@@ -63,7 +63,7 @@
});
};
- let toggleTrust = async (e) => {
+ let toggleTrust = async (e: Event) => {
e.preventDefault();
e.stopPropagation();
@@ -100,7 +100,7 @@
// }
// });
- let setMax = (e) => {
+ let setMax = (e: Event) => {
e.preventDefault();
fiat = false;
amount = balance;
@@ -126,7 +126,7 @@
</h1>
<div class="flex p-1 gap-2 justify-center">
- <Avatar user={recipient} size={"20"} />
+ <Avatar user={recipient} size={20} />
<p class="text-4xl break-words my-auto">
{recipient.username}
</p>
diff --git a/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.server.ts b/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.server.ts
index fef0a359..7a5514e8 100644
--- a/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.server.ts
+++ b/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.server.ts
@@ -4,7 +4,7 @@ import { fail, redirect } from "@sveltejs/kit";
export async function load({ cookies, params, parent }) {
const { user } = await parent();
- let data = { ...params };
+ let data: any = { ...params };
const rates = await getRates();
if (!params.payreq.startsWith("lno")) {
data = { ...data, ...(await post("/parse", params, auth(cookies))) };
diff --git a/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte
index 66ac240d..526038fa 100644
--- a/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte
+++ b/src/routes/(app)/send/lightning/[payreq]/[...memo]/+page.svelte
@@ -11,15 +11,15 @@
import { fiat, rate, pin } from "$lib/store";
import { sendArkViaForward } from "$lib/ark";
- let { data, form } = $props();
+ let { data, form }: any = $props();
let { alias, memo, payreq, ourfee, user } = $derived({ ...data, ...form });
let a = $state();
let { currency, locked } = $derived(user);
let locale = $derived(loc(user));
- $effect(() => ($rate ||= data.rate));
- $effect(() => form && (loading = false));
+ $effect(() => { $rate ||= data.rate; });
+ $effect(() => { if (form) loading = false; });
let showMax = $state();
let error = $state("");
@@ -27,12 +27,13 @@
let loading = $state();
let next = $state();
+ let show = $state(false);
let toggle = () => (show = !show);
let amount = $derived(form?.amount || data.amount);
let maxfee = $state(
Math.max(5, Math.round(untrack(() => amount) * 0.02 || 0)),
);
- $effect(() => (maxfee = Math.max(5, Math.round(amount * 0.02) || 0)));
+ $effect(() => { maxfee = Math.max(5, Math.round(amount * 0.02) || 0); });
let handler = ({ cancel }) => {
loading = true;
@@ -51,7 +52,7 @@
user,
});
goto(`/sent/${p.id}`, { invalidateAll: true });
- } catch (e) {
+ } catch (e: any) {
loading = false;
error = e.message || "Failed to send";
}
@@ -71,7 +72,7 @@
});
goto(`/send/bitcoin/${inv.hash}/${amount}`);
- } catch (e) {
+ } catch (e: any) {
loading = false;
error = e.message || "Failed to send";
}
@@ -115,7 +116,7 @@
<div class="my-auto">
{#if $fiat}
<h2 class="text-xl">
- {f(toFiat(ourfee, $rate), currency)}
+ {f(toFiat(ourfee as number, $rate as number), currency)}
</h2>
{:else}
<h3 class="text-secondary">⚡️{s(ourfee)}</h3>
@@ -191,6 +192,7 @@
{locale}
bind:rate={$rate}
submit={next}
+ element={undefined}
/>
<button type="submit" class="btn" bind:this={next}
>{$t("payments.next")}</button
diff --git a/src/routes/(app)/send/zap/[id]/[...amount]/+page.svelte b/src/routes/(app)/send/zap/[id]/[...amount]/+page.svelte
index 0af4e6ac..78b4d64f 100644
--- a/src/routes/(app)/send/zap/[id]/[...amount]/+page.svelte
+++ b/src/routes/(app)/send/zap/[id]/[...amount]/+page.svelte
@@ -12,7 +12,7 @@
import { sign, send } from "$lib/nostr";
import { rate, pin } from "$lib/store";
- let { data, form } = $props();
+ let { data, form }: any = $props();
let { id, request, user } = $derived({ ...data, ...form });
let a = $state(data.amount);
@@ -20,19 +20,21 @@
let locale = $derived(loc(user));
let event = $state();
- $effect(() => ($rate ||= data.rate));
- $effect(async () => {
+ $effect(() => { $rate ||= data.rate; });
+ $effect(() => {
if (form || request) {
- try {
- loading = false;
- event = await sign(request);
- let { pr: payreq } = await post("/post/zap", { event });
- await post("/post/payments", { amount, payreq, pin: $pin });
- goto(`/e/${id}`);
- } catch (e) {
- console.log(e);
- fail(e.message);
- }
+ (async () => {
+ try {
+ loading = false;
+ event = await sign(request);
+ let { pr: payreq } = await post("/post/zap", { event });
+ await post("/post/payments", { amount, payreq, pin: $pin });
+ goto(`/e/${id}`);
+ } catch (e: any) {
+ console.log(e);
+ fail(e.message);
+ }
+ })();
}
});
@@ -42,6 +44,7 @@
let submit = () => (loading = true);
let next = $state();
+ let show = $state(false);
let toggle = () => (show = !show);
let amount = $derived(form?.amount || data.amount);
let maxfee = $state(Math.max(5, Math.round(untrack(() => amount) * 0.005)));
@@ -63,6 +66,7 @@
{locale}
bind:rate={$rate}
submit={next}
+ element={undefined}
/>
<button type="submit" class="btn" bind:this={next}
>{$t("payments.next")}</button
diff --git a/src/routes/(app)/settings/+layout.svelte b/src/routes/(app)/settings/+layout.svelte
index 02e2fe62..a8792333 100644
--- a/src/routes/(app)/settings/+layout.svelte
+++ b/src/routes/(app)/settings/+layout.svelte
@@ -17,9 +17,9 @@
import { SimplePool } from 'nostr-tools/pool';
import { finalizeEvent } from 'nostr-tools/pure';
- let { children, data, form } = $props();
+ let { children, data, form }: any = $props();
- let formElement = $state();
+ let formElement: HTMLFormElement | undefined = $state();
let { token, cookies, subscriptions } = $derived(data);
let { tab } = $derived(data);
@@ -48,7 +48,7 @@
import { PUBLIC_DM_RELAYS } from '$env/static/public';
const DM_RELAYS_LIST = PUBLIC_DM_RELAYS.split(',');
const updateRelaysIfAvailable = async () => {
- const relayEntry = document.getElementById('dmRelays');
+ const relayEntry = document.getElementById('dmRelays') as HTMLTextAreaElement | null;
if (!relayEntry || relayEntry.value.length === 0) return;
const newRelays = relayEntry.value.split(/[ \r\n\t]+/)
@@ -65,8 +65,8 @@
content: ""
};
let signed;
- if (await window.nostr.getPublicKey() === user.pubkey) {
- signed = await window.nostr.signEvent(event);
+ if (await window.nostr!.getPublicKey() === user.pubkey) {
+ signed = await window.nostr!.signEvent(event);
} else {
const sk = await getPrivateKey(user);
signed = finalizeEvent(event, sk);
@@ -78,23 +78,23 @@
try {
new URL(url);
return true;
- } catch (err) {
+ } catch (err: any) {
return false;
}
}
- async function handleSubmit(e) {
+ async function handleSubmit(e: any) {
updateRelaysIfAvailable();
e.preventDefault();
try {
submitting = true;
- let body = new FormData(formElement);
+ let body = new FormData(formElement!);
form = {
user: await fd({
formData() {
return body;
},
- }),
+ } as any),
};
await tick();
@@ -122,14 +122,14 @@
if ($avatar) {
try {
let { hash } = JSON.parse(
- await upload($avatar.file, $avatar.type, $avatar.progress, token),
+ 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`;
body.set("picture", url);
await fetch(url, { cache: "reload", mode: "no-cors" });
- } catch (e) {
+ } catch (e: any) {
console.log("problem upsubmitting avatar", e);
}
}
@@ -137,13 +137,13 @@
if ($banner) {
try {
let { hash } = JSON.parse(
- await upload($banner.file, $banner.type, $banner.progress, token),
+ await upload(($banner as any).file, ($banner as any).type, ($banner as any).progress) as string,
);
let url = `${$page.url.origin}/api/public/${hash}.webp`;
body.set("banner", url);
await fetch(url, { cache: "reload", mode: "no-cors" });
- } catch (e) {
+ } catch (e: any) {
console.log("problem uploading banner", e);
}
}
@@ -171,7 +171,7 @@
try {
event = await sign(event, user);
send(event);
- } catch (e) {
+ } catch (e: any) {
warning("Nostr profile not updated");
}
}
@@ -179,8 +179,8 @@
let email = body.get("email");
if (email && email !== prev.email) {
try {
- cookies.get = function (n) {
- return this.find((c) => c.name === n).value;
+ (cookies as any).get = function (n: string) {
+ return (this as any).find((c: any) => c.name === n)?.value;
};
user.verified = false;
@@ -188,13 +188,13 @@
await post("/email", { email });
warning($t("user.settings.verifying"), false);
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
console.log(e);
}
}
- const response = await fetch(formElement.action, {
+ const response = await fetch(formElement!.action, {
method: "POST",
body,
});
@@ -203,11 +203,11 @@
if (result.type === "success") {
await invalidateAll();
- if (body.get("password")) $password = body.get("password");
+ if (body.get("password")) $password = body.get("password") as string;
}
applyAction(result);
- } catch (e) {
+ } catch (e: any) {
console.log(e);
fail("Something went wrong");
}
diff --git a/src/routes/(app)/settings/account/+page.svelte b/src/routes/(app)/settings/account/+page.svelte
index 1aa46ff6..a3cc24fd 100644
--- a/src/routes/(app)/settings/account/+page.svelte
+++ b/src/routes/(app)/settings/account/+page.svelte
@@ -19,7 +19,8 @@
let rate = $derived(() => rates[currency]);
let fiats = Object.keys(rates).sort((a, b) => a.localeCompare(b));
- let keypress = (e) => e.key === "Enter" && (e.preventDefault() || el.click());
+ let el: any;
+ let keypress = (e: any) => e.key === "Enter" && (e.preventDefault() || el.click());
let editingReserve = $state(),
editingThreshold = $state(),
@@ -44,19 +45,19 @@
if (!user.threshold) user.threshold = 1000000;
if (!user.reserve) user.reserve = 100000;
- let reserveEl = $state(),
- thresholdEl = $state();
+ let reserveEl: any = $state(),
+ thresholdEl: any = $state();
let push = $state(),
- pm,
- subscription;
+ pm: any,
+ subscription: any;
onMount(async () => {
if (!browser) return;
pm =
navigator?.serviceWorker &&
- (await navigator.serviceWorker.getRegistration()).pushManager;
+ (await navigator.serviceWorker.getRegistration())?.pushManager;
permission = await pm.permissionState({
userVisibleOnly: true,
@@ -308,7 +309,7 @@
</h1>
<Numpad
bind:amount={user.reserve}
- bind:currency
+ {currency}
bind:rate
bind:submit={doneReserve}
bind:element={reserveEl}
diff --git a/src/routes/(app)/settings/nostr/+page.svelte b/src/routes/(app)/settings/nostr/+page.svelte
index f1d06c66..ae074d30 100644
--- a/src/routes/(app)/settings/nostr/+page.svelte
+++ b/src/routes/(app)/settings/nostr/+page.svelte
@@ -12,13 +12,14 @@
let { data } = $props();
let { apps, challenge, user } = $derived(data);
let npub = $state(untrack(() => user.npub));
- let extensionAvailable = $derived(browser && window.nostr);
+ let extensionAvailable = $derived(browser && (window as any).nostr);
let { locale } = $derived(user);
import { SimplePool } from 'nostr-tools/pool';
let newNsec = $state(),
- nsec = $state(),
+ nsec: any = $state(),
+ nwc: string = $state(""),
pin = $state(""),
revealNsec = $state(),
revealNwc = $state();
@@ -36,17 +37,17 @@
let getPubkey = async () => {
$signer = { method: "extension", ready: true };
extension = true;
- npub = await window.nostr.getPublicKey();
+ npub = await window.nostr!.getPublicKey();
await tick();
- $save.click();
+ ($save as any).click();
};
import { PUBLIC_DM_RELAYS } from '$env/static/public';
const DM_RELAYS_LIST = PUBLIC_DM_RELAYS.split(',');
const pool = new SimplePool();
getPreferredRelays(user.pubkey).then(relays => {
- const relayEntry = document.getElementById('dmRelays');
- relayEntry.value = relays.join("\n");
+ const relayEntry = document.getElementById('dmRelays') as HTMLTextAreaElement | null;
+ if (relayEntry) relayEntry.value = relays.join("\n");
});
</script>
@@ -77,8 +78,8 @@
class="text-yellow-300"
></iconify-icon>
{#if $fiat && $rate}
- {f((app.spent * $rate) / sats, user.currency, locale)} /
- {f((app.max_amount * $rate) / sats, user.currency, locale)}
+ {f((app.spent * ($rate as number)) / sats, user.currency, locale)} /
+ {f((app.max_amount * ($rate as number)) / sats, user.currency, locale)}
{:else}
{s(app.spent, locale)} /
{s(app.max_amount, locale)}
@@ -116,7 +117,6 @@
href={`/qr/${encodeURIComponent(app.nwc)}`}
class:btn-disabled={!app.secret}
title={$t("user.receive.showQR")}
- disabled={!app.secret}
>
<iconify-icon icon="ph:qr-code-bold" width="32"></iconify-icon>
</a>
diff --git a/src/routes/(app)/settings/profile/+page.svelte b/src/routes/(app)/settings/profile/+page.svelte
index d4a54a9f..e7a60677 100644
--- a/src/routes/(app)/settings/profile/+page.svelte
+++ b/src/routes/(app)/settings/profile/+page.svelte
@@ -15,11 +15,11 @@
let username = $state();
let avatarFile,
- avatarInput = $state(),
+ avatarInput: any = $state(),
bannerFile,
password = $state(),
revealPassword = $state(),
- bannerInput = $state();
+ bannerInput: any = $state();
let selectAvatar = () => avatarInput.click();
let selectBanner = () => bannerInput.click();
@@ -31,7 +31,7 @@
let tooLarge = $state({});
- let handleFile = async ({ target }, type) => {
+ let handleFile = async ({ target }: any, type: string) => {
tooLarge[type] = false;
let file = target.files[0];
if (!file) return;
@@ -45,11 +45,11 @@
}
var reader = new FileReader();
- reader.onload = async (e) => {
+ reader.onload = async (e: any) => {
if (type === "picture") {
- $avatar.src = e.target.result;
+ ($avatar as any).src = e.target.result;
} else if (type === "banner") {
- $bannerStore.src = e.target.result;
+ ($bannerStore as any).src = e.target.result;
}
};
@@ -109,9 +109,9 @@
tabindex="0"
>
<img
- src={$avatar?.src || picture}
+ src={($avatar as any)?.src || picture}
class="absolute w-full h-full object-cover object-center visible overflow-hidden"
- alt={username}
+ alt={username as any}
/>
</div>
{:else}
@@ -158,7 +158,7 @@
aria-label="Select banner"
>
<img
- src={$bannerStore ? $bannerStore.src : banner}
+ src={$bannerStore ? ($bannerStore as any).src : banner}
class="w-full object-cover object-center visible overflow-hidden h-48 mb-4 hover:opacity-80"
alt="Banner"
/>
@@ -196,7 +196,6 @@
>{$t("user.settings.about")}</label
>
<textarea
- type="text"
name="about"
bind:value={about}
placeholder={$t("user.settings.aboutPlaceholder")}
diff --git a/src/routes/(app)/settings/security/+page.svelte b/src/routes/(app)/settings/security/+page.svelte
index 8c9f0105..7ce68d11 100644
--- a/src/routes/(app)/settings/security/+page.svelte
+++ b/src/routes/(app)/settings/security/+page.svelte
@@ -6,6 +6,7 @@
import Qr from "$comp/Qr.svelte";
import { copy, post, success, fail } from "$lib/utils";
import { save, pin as current } from "$lib/store";
+ import { getNsec } from "$lib/nostr";
import { invalidate } from "$app/navigation";
import { page } from "$app/stores";
@@ -19,11 +20,11 @@
importing = $state(),
newNsec = $state(),
nsec = $state(),
- otp = $state(),
- pin = $state(""),
+ otp: any = $state(),
+ pin: any = $state(""),
revealSeed,
revealNsec = $state(),
- token = $state(""),
+ token: any = $state(""),
setting2fa = $state(),
settingPin = $state(),
verify = $state("");
@@ -51,13 +52,13 @@
}
};
- let checkPin = async () => {
+ let checkPin = async (_?: any) => {
try {
- if (pin.length > 5 && pin === verify) {
+ if (pin && pin.length > 5 && pin === verify) {
$current = pin;
pin = "";
verify = "";
- $save.click();
+ ($save as any).click();
settingPin = false;
verifying = false;
} else {
@@ -85,7 +86,7 @@
try {
disablingPin = true;
await tick();
- $save.click();
+ ($save as any).click();
} catch (e) {
console.log(e);
fail("Failed to disable pin");
@@ -109,7 +110,7 @@
let startDisabling2fa = () => (disabling2fa = true);
let startConfirming2fa = () => (confirming2fa = true);
- let cancel = () => {
+ let cancel: any = () => {
pin = null;
token = null;
verifying = false;
@@ -119,9 +120,9 @@
disabling2fa = false;
};
- let enable2fa = async (twoFa) => {
+ let enable2fa = async (twoFa?: any) => {
try {
- if (setting2fa && token.length === 6) {
+ if (setting2fa && token && token.length === 6) {
await post("/enable2fa", { token });
success("2FA enabled");
user.twofa = 1;
@@ -133,9 +134,9 @@
}
};
- let disable2fa = async () => {
+ let disable2fa = async (_?: any) => {
try {
- if (disabling2fa && token.length === 6) {
+ if (disabling2fa && token && token.length === 6) {
await post("/disable2fa", { token });
success("2FA disabled");
delete user.twofa;
@@ -148,9 +149,9 @@
};
let verifying = $derived(pin?.length > 5);
- $effect(() => verify && checkPin(pin));
- $effect(() => setting2fa && enable2fa(token));
- $effect(() => disabling2fa && disable2fa(token));
+ $effect(() => { if (verify) checkPin(pin as any); });
+ $effect(() => { if (setting2fa) enable2fa(token as any); });
+ $effect(() => { if (disabling2fa) disable2fa(token as any); });
</script>
<input type="hidden" name="newpin" value={disablingPin ? "delete" : pin} />
@@ -195,7 +196,7 @@
{#if setting2fa}
<a href={otp.uri}>
- <Qr text={otp.uri} />
+ <Qr text={otp.uri} icon="" />
</a>
<div class="text-center my-4">
@@ -226,7 +227,6 @@
bind:value={token}
title="Enter 2FA Code"
{cancel}
- persist={false}
notify={false}
/>
{/if}
diff --git a/src/routes/(static)/bounties/+page.svelte b/src/routes/(static)/bounties/+page.svelte
index 6e8fb12b..3cc269dc 100644
--- a/src/routes/(static)/bounties/+page.svelte
+++ b/src/routes/(static)/bounties/+page.svelte
@@ -3,7 +3,7 @@
import { s } from "$lib/utils";
import Amount from "$comp/Amount.svelte";
- let { data } = $props();
+ let { data }: any = $props();
let { users } = data;
let bounties = [
diff --git a/src/routes/(static)/login/+page.svelte b/src/routes/(static)/login/+page.svelte
index 30592625..2f67b48e 100644
--- a/src/routes/(static)/login/+page.svelte
+++ b/src/routes/(static)/login/+page.svelte
@@ -18,7 +18,7 @@
import { sha256 } from "@noble/hashes/sha2.js";
import { bytesToHex } from "@noble/hashes/utils.js";
- let { data, form } = $props();
+ let { data, form }: any = $props();
onMount(() => {
if (browser) {
@@ -50,16 +50,16 @@
}
});
- let cancel = () => (need2fa = false);
+ let cancel: any = () => { need2fa = false; };
- let username = $state(),
- email,
- btn = $state();
+ let username: string | undefined = $state(),
+ email: any,
+ btn: HTMLButtonElement = $state() as any;
- $effect(() => 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 = "";
+ if (need2fa && form?.token === token) token = "";
});
let revealPassword = $state(false);
@@ -76,17 +76,17 @@
});
});
- const enhanceLogin = async ({ formData, cancel }) => {
+ const enhanceLogin = async ({ formData, cancel }: any) => {
try {
const recaptcha = await getRecaptchaToken();
- formData.set("recaptcha", recaptcha);
- } catch (err) {
+ formData.set("recaptcha", recaptcha as string);
+ } catch (err: any) {
fail(err.message || "captcha failed");
cancel();
return;
}
- return async ({ result }) => {
+ return async ({ result }: any) => {
if (result.type === "success") {
await invalidateAll();
}
@@ -124,11 +124,11 @@
try {
const recaptcha = await getRecaptchaToken();
- formData.append("loginRedirect", redirect);
- formData.append("token", token);
+ formData.append("loginRedirect", (redirect ?? "") as string);
+ formData.append("token", token ?? "");
formData.append("event", JSON.stringify(signedEvent));
formData.append("challenge", challenge);
- formData.append("recaptcha", recaptcha);
+ formData.append("recaptcha", recaptcha as string);
let response = await fetch("/login?/nostr", {
method: "POST",
@@ -138,7 +138,7 @@
const result = deserialize(await response.text());
applyAction(result);
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
@@ -147,7 +147,7 @@
if (!browser) return;
const nodeBadge = document.querySelector(".grecaptcha-badge");
if (nodeBadge) {
- document.body.removeChild(nodeBadge.parentNode);
+ document.body.removeChild(nodeBadge.parentNode!);
}
const scriptSelector =
diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte
index 38e8cbb0..29aac7df 100644
--- a/src/routes/(static)/register/+page.svelte
+++ b/src/routes/(static)/register/+page.svelte
@@ -26,7 +26,7 @@
} from "unique-names-generator";
import { sign } from "$lib/nostr";
- let { form, data } = $props();
+ let { form, data }: any = $props();
let { challenge } = $derived(data);
let recaptchaSiteKey = PUBLIC_RECAPTCHA_SITE_KEY;
let isTor = browser && location.hostname.endsWith(".onion");
@@ -51,7 +51,7 @@
}
});
- let username = $state();
+ let username: string | undefined = $state();
let { index } = $state(data);
let revealPassword = $state(false);
@@ -65,7 +65,7 @@
}
};
- let refresh = async (e) => {
+ let refresh = async (e: any) => {
e.preventDefault();
cleared = false;
@@ -92,17 +92,17 @@
}
});
- let token = $state(),
- formElement;
- let code = [];
- let redirect;
+ let token: string = $state(""),
+ formElement: any;
+ let code: any[] = [];
+ let redirect: any;
- let cancel = () => (need2fa = false);
+ let cancel: any = () => { need2fa = false; };
- let email,
- btn = $state();
+ let email: any,
+ btn: HTMLButtonElement = $state() as any;
- let loading = $state();
+ let loading = $state(false);
const getRecaptchaToken = () =>
new Promise((resolve, reject) => {
if (isTor) return resolve("");
@@ -115,14 +115,14 @@
});
});
- async function handleSubmit(e) {
+ async function handleSubmit(e: SubmitEvent) {
e.preventDefault();
loading = true;
- let data = new FormData(this);
- let user = Object.fromEntries(data);
- user.username = user.username.replace(/\s*/g, "");
+ let data = new FormData(e.target as HTMLFormElement);
+ let user: Record<string, any> = Object.fromEntries(data);
+ user.username = (user.username as string).replace(/\s*/g, "");
for (let k in user) {
data.set(k, user[k]);
@@ -130,8 +130,8 @@
try {
const recaptcha = await getRecaptchaToken();
- data.set("recaptcha", recaptcha);
- } catch (err) {
+ data.set("recaptcha", recaptcha as string);
+ } catch (err: any) {
fail(err.message || "captcha failed");
loading = false;
return;
@@ -141,7 +141,7 @@
if ($avatar) {
try {
let { hash } = JSON.parse(
- await upload($avatar.file, $avatar.type, $avatar.progress, token),
+ 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`;
@@ -170,37 +170,37 @@
loading = false;
}
- let avatarInput = $state();
+ let avatarInput: HTMLInputElement = $state() as any;
let decr = () => (index = index <= 0 ? 63 : index - 1);
let incr = () => (index = index >= 63 ? 0 : index + 1);
let selectAvatar = () => avatarInput.click();
let progress;
- let handleFile = async ({ target }) => {
+ let handleFile = async ({ target }: { target: HTMLInputElement }) => {
let type = "picture";
- let file = target.files[0];
+ let file = target.files![0];
if (!file) return;
- if (file.size > 10000000) form.error = "File too large";
+ if (file.size > 10000000) form!.error = "File too large";
$avatar = { file, type, progress };
var reader = new FileReader();
- reader.onload = async (e) => {
+ reader.onload = async (e: any) => {
src = e.target.result;
};
reader.readAsDataURL(file);
};
- let need2fa = $derived(form?.message === "2fa");
- let src = $derived(`/api/public/${punks[index]}.webp`);
+ let need2fa: any = $derived(form?.message === "2fa");
+ let src: string = $derived(`/api/public/${punks[index]}.webp`);
$effect(() => {
- if (need2fa && form.token === token) token = "";
+ if (need2fa && form?.token === token) token = "";
});
$effect(() => {
- token && token?.length === 6 && tick().then(() => btn.click());
+ token && token.length === 6 && tick().then(() => btn.click());
});
let nostrLogin = async () => {
@@ -221,11 +221,11 @@
try {
const recaptcha = await getRecaptchaToken();
- formData.append("loginRedirect", redirect);
- formData.append("token", token);
+ formData.append("loginRedirect", redirect ?? "");
+ formData.append("token", token ?? "");
formData.append("event", JSON.stringify(signedEvent));
formData.append("challenge", challenge);
- formData.append("recaptcha", recaptcha);
+ formData.append("recaptcha", recaptcha as string);
let response = await fetch("/login?/nostr", {
method: "POST",
@@ -239,7 +239,7 @@
}
applyAction(result);
- } catch (e) {
+ } catch (e: any) {
fail(e.message);
}
};
@@ -248,7 +248,7 @@
if (!browser) return;
const nodeBadge = document.querySelector(".grecaptcha-badge");
if (nodeBadge) {
- document.body.removeChild(nodeBadge.parentNode);
+ document.body.removeChild(nodeBadge.parentNode!);
}
const scriptSelector =
@@ -274,7 +274,7 @@
type="file"
class="hidden!"
bind:this={avatarInput}
- onchange={(e) => handleFile(e, "picture")}
+ onchange={(e: any) => handleFile(e)}
/>
<div class="relative">
diff --git a/src/routes/(static)/support/+page.svelte b/src/routes/(static)/support/+page.svelte
index 7a2b05a5..c82a6cf9 100644
--- a/src/routes/(static)/support/+page.svelte
+++ b/src/routes/(static)/support/+page.svelte
@@ -27,7 +27,7 @@
}
});
- let submit = (e) => {
+ let submit = (e: any) => {
e.preventDefault();
if (isTor) {
post("/post/email", {
@@ -58,7 +58,7 @@
if (!browser) return;
const nodeBadge = document.querySelector(".grecaptcha-badge");
if (nodeBadge) {
- document.body.removeChild(nodeBadge.parentNode);
+ document.body.removeChild(nodeBadge.parentNode!);
}
const scriptSelector =
@@ -119,7 +119,6 @@
>
<textarea
rows={5}
- type="text"
name="message"
bind:value={message}
required