taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 551aa1a5e7e7e3a390a472fa433387da8bf3fc72
parent b639a130c9b033510b0c8a69e611912ab844bc49
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 29 Aug 2024 11:42:34 -0300

ignore case for taler://

Diffstat:
Mpackages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx | 2+-
Mpackages/taler-wallet-webextension/src/wallet/Application.tsx | 169+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Mpackages/taler-wallet-webextension/src/wallet/QrReader.tsx | 6+++---
3 files changed, 96 insertions(+), 81 deletions(-)

diff --git a/packages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx b/packages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx @@ -27,7 +27,7 @@ export interface Props { export function AddNewActionView({ onCancel }: Props): VNode { const [url, setUrl] = useState(""); - const uri = parseTalerUri(url); + const uri = parseTalerUri(url.toLowerCase()); const { i18n } = useTranslationContext(); async function redirectToWallet(): Promise<void> { diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx @@ -131,7 +131,9 @@ export function Application(): VNode { onDetected={(talerActionUrl: TalerUri) => { redirectTo( Pages.defaultCta({ - uri: encodeCrockForURI(stringifyTalerUri(talerActionUrl)), + uri: encodeCrockForURI( + stringifyTalerUri(talerActionUrl), + ), }), ); }} @@ -188,14 +190,18 @@ export function Application(): VNode { goToWalletDeposit={(scope: ScopeInfo) => redirectTo( Pages.sendCash({ - scope: encodeCrockForURI(stringifyScopeInfoShort(scope)), + scope: encodeCrockForURI( + stringifyScopeInfoShort(scope), + ), }), ) } goToWalletManualWithdraw={(scope?: ScopeInfo) => redirectTo( Pages.receiveCash({ - scope: !scope ? undefined : encodeCrockForURI(stringifyScopeInfoShort(scope)), + scope: !scope + ? undefined + : encodeCrockForURI(stringifyScopeInfoShort(scope)), }), ) } @@ -221,14 +227,18 @@ export function Application(): VNode { goToWalletDeposit={(scope: ScopeInfo) => redirectTo( Pages.sendCash({ - scope: encodeCrockForURI(stringifyScopeInfoShort(scope)), + scope: encodeCrockForURI( + stringifyScopeInfoShort(scope), + ), }), ) } goToWalletManualWithdraw={(scope?: ScopeInfo) => redirectTo( Pages.receiveCash({ - scope: !scope ? undefined : encodeCrockForURI(stringifyScopeInfoShort(scope)), + scope: !scope + ? undefined + : encodeCrockForURI(stringifyScopeInfoShort(scope)), }), ) } @@ -238,11 +248,7 @@ export function Application(): VNode { /> <Route path={Pages.sendCash.pattern} - component={({ - scope, - }: { - scope?: string; - }) => { + component={({ scope }: { scope?: string }) => { if (!scope) return <Redirect to={Pages.balanceHistory({})} />; const s = parseScopeInfoShort(decodeCrockFromURI(scope)); if (!s) return <Redirect to={Pages.balanceHistory({})} />; @@ -281,26 +287,32 @@ export function Application(): VNode { /> <Route path={Pages.bankManange.pattern} - component={({ - scope, - }: { - scope?: string; - }) => { - const s = !scope ? undefined : parseScopeInfoShort(decodeCrockFromURI(scope)); - if (!s) return <div>missing scope</div> + component={({ scope }: { scope?: string }) => { + const s = !scope + ? undefined + : parseScopeInfoShort(decodeCrockFromURI(scope)); + if (!s) return <div>missing scope</div>; return ( <WalletTemplate path="balance" goToURL={redirectToURL}> <ManageAccountPage scope={s} - onAccountAdded={(account) => redirectTo(Pages.ctaDeposit({ - scope: encodeCrockForURI(stringifyScopeInfoShort(s)), - account: encodeCrockForURI(stringifyPaytoUri(account)), - }))} + onAccountAdded={(account) => + redirectTo( + Pages.ctaDeposit({ + scope: encodeCrockForURI(stringifyScopeInfoShort(s)), + account: encodeCrockForURI( + stringifyPaytoUri(account), + ), + }), + ) + } onCancel={() => { - redirectTo(Pages.balanceHistory({ - scope: encodeCrockForURI(stringifyScopeInfoShort(s)), - })) + redirectTo( + Pages.balanceHistory({ + scope: encodeCrockForURI(stringifyScopeInfoShort(s)), + }), + ); }} /> </WalletTemplate> @@ -329,11 +341,7 @@ export function Application(): VNode { /> <Route path={Pages.receiveCash.pattern} - component={({ - scope, - }: { - scope?: string; - }) => { + component={({ scope }: { scope?: string }) => { const s = !scope ? undefined : parseScopeInfoShort(decodeCrockFromURI(scope)); @@ -343,14 +351,14 @@ export function Application(): VNode { <DestinationSelectionPage type="get" scope={s} - goToWalletManualWithdraw={(s,) => + goToWalletManualWithdraw={(s) => redirectTo( Pages.ctaWithdrawManual({ scope: encodeCrockForURI(stringifyScopeInfoShort(s)), }), ) } - goToWalletWalletInvoice={(s,) => + goToWalletWalletInvoice={(s) => redirectTo( Pages.ctaInvoiceCreate({ scope: encodeCrockForURI(stringifyScopeInfoShort(s)), @@ -372,7 +380,9 @@ export function Application(): VNode { goToWalletHistory={(scope: ScopeInfo) => redirectTo( Pages.balanceHistory({ - scope: encodeCrockForURI(stringifyScopeInfoShort(scope)), + scope: encodeCrockForURI( + stringifyScopeInfoShort(scope), + ), }), ) } @@ -383,34 +393,36 @@ export function Application(): VNode { <Route path={Pages.balanceDeposit.pattern} - component={({ - scope, - }: { - scope: string; - }) => { - const s = parseScopeInfoShort(decodeCrockFromURI(scope)) + component={({ scope }: { scope: string }) => { + const s = parseScopeInfoShort(decodeCrockFromURI(scope)); if (!s) { - return <div>missing scope</div> + return <div>missing scope</div>; } - return <WalletTemplate path="balance" goToURL={redirectToURL}> - <DepositPage - scope={s} - onCancel={(scope: ScopeInfo) => { - redirectTo( - Pages.balanceHistory({ - scope: encodeCrockForURI(stringifyScopeInfoShort(scope)), - }), - ); - }} - onSuccess={(scope: ScopeInfo) => { - redirectTo( - Pages.balanceHistory({ - scope: encodeCrockForURI(stringifyScopeInfoShort(scope)), - }), - ); - }} - /> - </WalletTemplate> + return ( + <WalletTemplate path="balance" goToURL={redirectToURL}> + <DepositPage + scope={s} + onCancel={(scope: ScopeInfo) => { + redirectTo( + Pages.balanceHistory({ + scope: encodeCrockForURI( + stringifyScopeInfoShort(scope), + ), + }), + ); + }} + onSuccess={(scope: ScopeInfo) => { + redirectTo( + Pages.balanceHistory({ + scope: encodeCrockForURI( + stringifyScopeInfoShort(scope), + ), + }), + ); + }} + /> + </WalletTemplate> + ); }} /> @@ -624,30 +636,31 @@ export function Application(): VNode { scope, account, }: { - scope: string, + scope: string; account: string; }) => { - const s = parseScopeInfoShort(decodeCrockFromURI(scope)) + const s = parseScopeInfoShort(decodeCrockFromURI(scope)); if (!s) { - return <div>missing scope</div> + return <div>missing scope</div>; } - const p = parsePaytoUri(decodeCrockFromURI(account)) + const p = parsePaytoUri(decodeCrockFromURI(account)); if (!p) { - return <div>missing account</div> + return <div>missing account</div>; } - return <CallToActionTemplate title={i18n.str`Digital cash deposit`} > - <DepositPageCTA - scope={s} - account={p} - cancel={() => redirectTo(Pages.balance)} - onSuccess={(tid: string) => - redirectTo(Pages.balanceTransaction({ tid })) - } - /> - </CallToActionTemplate> - } - } + return ( + <CallToActionTemplate title={i18n.str`Digital cash deposit`}> + <DepositPageCTA + scope={s} + account={p} + cancel={() => redirectTo(Pages.balance)} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } + /> + </CallToActionTemplate> + ); + }} /> <Route path={Pages.ctaInvoiceCreate.pattern} @@ -736,7 +749,9 @@ export function Application(): VNode { <Route path={Pages.ctaAddExchange} component={({ talerUri }: { talerUri: string }) => { - const tUri = parseTalerUri(decodeCrockFromURI(talerUri)); + const tUri = parseTalerUri( + decodeCrockFromURI(talerUri).toLowerCase(), + ); const baseUrl = tUri?.type === TalerUriAction.AddExchange ? tUri.exchangeBaseUrl @@ -776,7 +791,7 @@ export function Application(): VNode { <WalletActivity /> </EnabledBySettings> </IoCProviderForRuntime> - </TranslationProvider > + </TranslationProvider> ); } diff --git a/packages/taler-wallet-webextension/src/wallet/QrReader.tsx b/packages/taler-wallet-webextension/src/wallet/QrReader.tsx @@ -216,7 +216,7 @@ export function QrReaderPage({ onDetected }: Props): VNode { function onChangeDetect(str: string) { if (str) { - const uri = parseTalerUri(str); + const uri = parseTalerUri(str.toLowerCase()); if (!uri) { setError( i18n.str`URI is not valid. Taler URI should start with "taler://"`, @@ -233,7 +233,7 @@ export function QrReaderPage({ onDetected }: Props): VNode { function onChange(str: string) { if (str) { - if (!parseTalerUri(str)) { + if (!parseTalerUri(str.toLowerCase())) { setError( i18n.str`URI is not valid. Taler URI should start with "taler://"`, ); @@ -293,7 +293,7 @@ export function QrReaderPage({ onDetected }: Props): VNode { setError(i18n.str`something unexpected happen: ${error}`); } } - const uri = parseTalerUri(value); + const uri = parseTalerUri(value.toLowerCase()); return ( <Container>