From e700c97c7198c27f9bc760ef375a11010b43a04f Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 3 Jan 2024 16:49:44 +0000 Subject: [PATCH] chore: Update translations --- packages/app/src/Icons/Alby.tsx | 92 ++++++++--- packages/app/src/Icons/Cashu.tsx | 89 ++++++----- .../app/src/Pages/settings/WalletSettings.tsx | 57 ++++--- .../app/src/Pages/settings/wallet/Alby.tsx | 148 +++++++++--------- .../app/src/Pages/settings/wallet/index.tsx | 4 +- packages/app/src/translations/hu_HU.json | 2 +- 6 files changed, 229 insertions(+), 163 deletions(-) diff --git a/packages/app/src/Icons/Alby.tsx b/packages/app/src/Icons/Alby.tsx index df6723b5..b375b588 100644 --- a/packages/app/src/Icons/Alby.tsx +++ b/packages/app/src/Icons/Alby.tsx @@ -1,19 +1,75 @@ export default function AlbyIcon(props: { size?: number }) { - return - - - - - - - - - - - - - - - - ; -} \ No newline at end of file + return ( + + + + + + + + + + + + + + + + + + ); +} diff --git a/packages/app/src/Icons/Cashu.tsx b/packages/app/src/Icons/Cashu.tsx index d30a3a4e..2b7a167f 100644 --- a/packages/app/src/Icons/Cashu.tsx +++ b/packages/app/src/Icons/Cashu.tsx @@ -1,45 +1,48 @@ export default function CashuIcon(props: { size?: number }) { - return - - - - - - - + return ( + + + + + + + + -} \ No newline at end of file + ); +} diff --git a/packages/app/src/Pages/settings/WalletSettings.tsx b/packages/app/src/Pages/settings/WalletSettings.tsx index 8db145d6..2ebe5d2a 100644 --- a/packages/app/src/Pages/settings/WalletSettings.tsx +++ b/packages/app/src/Pages/settings/WalletSettings.tsx @@ -10,25 +10,29 @@ import AlbyIcon from "@/Icons/Alby"; import Icon from "@/Icons/Icon"; import { getAlbyOAuth } from "./wallet/Alby"; -const WalletRow = (props: { logo: ReactNode, name: ReactNode, url: string, desc?: ReactNode }) => { +const WalletRow = (props: { logo: ReactNode; name: ReactNode; url: string; desc?: ReactNode }) => { const navigate = useNavigate(); - return
{ - if (props.url.startsWith("http")) { - window.location.href = props.url; - } else { - navigate(props.url); - } - }}> -
- {props.logo} + return ( +
{ + if (props.url.startsWith("http")) { + window.location.href = props.url; + } else { + navigate(props.url); + } + }}> +
+ {props.logo} +
+
+
{props.name}
+
{props.desc}
+
+
-
-
{props.name}
-
{props.desc}
-
- -
-} + ); +}; const WalletSettings = () => { const alby = getAlbyOAuth(); @@ -42,30 +46,37 @@ const WalletSettings = () => { logo={} name="Nostr Wallet Connect" url="/settings/wallet/nwc" - desc={} /> + desc={} + /> } name="LND via LNC" url="/settings/wallet/lnc" - desc={} /> + desc={ + + } + /> } name="LNDHub" url="/settings/wallet/lndhub" - desc={} /> + desc={} + /> } name="Cashu" url="/settings/wallet/cashu" - desc={} /> + desc={} + /> } name="Alby" url={alby.authUrl} - desc={} /> + desc={} + />
); }; -export default WalletSettings; \ No newline at end of file +export default WalletSettings; diff --git a/packages/app/src/Pages/settings/wallet/Alby.tsx b/packages/app/src/Pages/settings/wallet/Alby.tsx index ff5b6559..235d4d86 100644 --- a/packages/app/src/Pages/settings/wallet/Alby.tsx +++ b/packages/app/src/Pages/settings/wallet/Alby.tsx @@ -6,93 +6,89 @@ import { useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; export default function AlbyOAuth() { - const location = useLocation(); - const alby = getAlbyOAuth(); - const [error, setError] = useState(""); + const location = useLocation(); + const alby = getAlbyOAuth(); + const [error, setError] = useState(""); - async function setupWallet(token: string) { - const auth = await alby.getToken(token); - console.debug(auth); + async function setupWallet(token: string) { + const auth = await alby.getToken(token); + console.debug(auth); + } + + useEffect(() => { + if (location.search) { + const params = new URLSearchParams(location.search); + const token = params.get("code"); + if (token) { + setupWallet(token).catch(e => { + setError((e as Error).message); + }); + } } + }, [location]); - useEffect(() => { - if (location.search) { - const params = new URLSearchParams(location.search); - const token = params.get("code"); - if (token) { - setupWallet(token).catch(e => { - setError((e as Error).message); - }); - } - } - }, [location]); - - if (!location.search) return; - return <> -

Alby Wallet Connection

- {!error && } - {error && {error}} + if (!location.search) return; + return ( + <> +

Alby Wallet Connection

+ {!error && } + {error && {error}} + ); } export function getAlbyOAuth() { - const clientId = "35EQp6crss"; - const clientSecret = "DTUPIqOjsjwxZXcJwF5C" - const redirectUrl = `${window.location.protocol}//${window.location.host}/settings/wallet/alby`; - const scopes = [ - "invoices:create", - "invoices:read", - "transactions:read", - "balance:read", - "payments:send" - ]; + const clientId = "35EQp6crss"; + const clientSecret = "DTUPIqOjsjwxZXcJwF5C"; + const redirectUrl = `${window.location.protocol}//${window.location.host}/settings/wallet/alby`; + const scopes = ["invoices:create", "invoices:read", "transactions:read", "balance:read", "payments:send"]; - const ec = new TextEncoder(); - const code_verifier = hex.encode(randomBytes(64)); - window.sessionStorage.setItem("alby-code", code_verifier); + const ec = new TextEncoder(); + const code_verifier = hex.encode(randomBytes(64)); + window.sessionStorage.setItem("alby-code", code_verifier); - const params = new URLSearchParams(); - params.set("client_id", clientId); - params.set("response_type", "code"); - params.set("code_challenge", base64urlnopad.encode(sha256(code_verifier))); - params.set("code_challenge_method", "S256"); - params.set("redirect_uri", redirectUrl); - params.set("scope", scopes.join(" ")) + const params = new URLSearchParams(); + params.set("client_id", clientId); + params.set("response_type", "code"); + params.set("code_challenge", base64urlnopad.encode(sha256(code_verifier))); + params.set("code_challenge_method", "S256"); + params.set("redirect_uri", redirectUrl); + params.set("scope", scopes.join(" ")); - const tokenUrl = "https://api.getalby.com/oauth/token"; - const authUrl = `https://getalby.com/oauth?${params}`; + const tokenUrl = "https://api.getalby.com/oauth/token"; + const authUrl = `https://getalby.com/oauth?${params}`; - return { - tokenUrl, - authUrl, - getToken: async (token: string) => { - const code = window.sessionStorage.getItem("alby-code"); - if (!code) throw new Error("Alby code is missing!"); - window.sessionStorage.removeItem("alby-code"); + return { + tokenUrl, + authUrl, + getToken: async (token: string) => { + const code = window.sessionStorage.getItem("alby-code"); + if (!code) throw new Error("Alby code is missing!"); + window.sessionStorage.removeItem("alby-code"); - const form = new URLSearchParams(); - form.set("client_id", clientId); - form.set("code_verifier", code); - form.set("grant_type", "authorization_code"); - form.set("redirect_uri", redirectUrl); - form.set("code", token); + const form = new URLSearchParams(); + form.set("client_id", clientId); + form.set("code_verifier", code); + form.set("grant_type", "authorization_code"); + form.set("redirect_uri", redirectUrl); + form.set("code", token); - const req = await fetch(tokenUrl, { - method: "POST", - headers: { - "accept": "application/json", - "content-type": "application/x-www-form-urlencoded", - "authorization": `Basic ${base64.encode(ec.encode(`${clientId}:${clientSecret}`))}` - }, - body: form - }); + const req = await fetch(tokenUrl, { + method: "POST", + headers: { + accept: "application/json", + "content-type": "application/x-www-form-urlencoded", + authorization: `Basic ${base64.encode(ec.encode(`${clientId}:${clientSecret}`))}`, + }, + body: form, + }); - const data = await req.json(); - if (req.ok) { - return data.access_token as string; - } else { - throw new Error(data.error_description as string); - } - } - }; -} \ No newline at end of file + const data = await req.json(); + if (req.ok) { + return data.access_token as string; + } else { + throw new Error(data.error_description as string); + } + }, + }; +} diff --git a/packages/app/src/Pages/settings/wallet/index.tsx b/packages/app/src/Pages/settings/wallet/index.tsx index 5716890d..bc5f8e6f 100644 --- a/packages/app/src/Pages/settings/wallet/index.tsx +++ b/packages/app/src/Pages/settings/wallet/index.tsx @@ -30,5 +30,5 @@ export const WalletSettingsRoutes = [ { path: "/settings/wallet/alby", element: , - } -] as Array; \ No newline at end of file + }, +] as Array; diff --git a/packages/app/src/translations/hu_HU.json b/packages/app/src/translations/hu_HU.json index fc3efebd..a8385272 100644 --- a/packages/app/src/translations/hu_HU.json +++ b/packages/app/src/translations/hu_HU.json @@ -484,7 +484,7 @@ "pI+77w": "A Snort csomópontból letölthető biztonsági másolatok", "pRess9": "ZapPool", "puLNUJ": "Kiemel", - "pukxg/": "Payments", + "pukxg/": "Fizetések", "pzTOmv": "Követők", "qD9EUF": "E-mail <> PÜ híd a Snort nostr címedhez", "qDwvZ4": "Ismeretlen hiba",