diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-13 12:21:39 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-13 12:57:40 -0300 |
commit | 7b2de89444f27faa554bb40855da996a113ef5b9 (patch) | |
tree | df56fd4246a93790ef778640a7b07c692bc569ca /packages/taler-wallet-webextension/src/wxBackend.ts | |
parent | ebd004195673c58718c7c9d8b8270df28b35b539 (diff) | |
download | wallet-core-7b2de89444f27faa554bb40855da996a113ef5b9.tar.xz |
use /taler-uri as redirection point to all taler uris
Diffstat (limited to 'packages/taler-wallet-webextension/src/wxBackend.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wxBackend.ts | 74 |
1 files changed, 12 insertions, 62 deletions
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index 3655c5dbc..c50412053 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -34,6 +34,8 @@ import { WalletDiagnostics, makeErrorDetail, getErrorDetailFromException, + parseTalerUri, + TalerUriAction, } from "@gnu-taler/taler-util"; import { DbAccess, @@ -332,69 +334,17 @@ function parseTalerUriAndRedirect(tabId: number, maybeTalerUri: string): void { const talerUri = maybeTalerUri.startsWith("ext+") ? maybeTalerUri.substring(4) : maybeTalerUri; - const uriType = classifyTalerUri(talerUri); - switch (uriType) { - case TalerUriType.TalerWithdraw: - return platform.redirectTabToWalletPage( - tabId, - `/cta/withdraw?talerWithdrawUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerPay: - return platform.redirectTabToWalletPage( - tabId, - `/cta/pay?talerPayUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerTip: - return platform.redirectTabToWalletPage( - tabId, - `/cta/tip?talerTipUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerRefund: - return platform.redirectTabToWalletPage( - tabId, - `/cta/refund?talerRefundUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerPayPull: - return platform.redirectTabToWalletPage( - tabId, - `/cta/invoice/pay?talerPayPullUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerPayPush: - return platform.redirectTabToWalletPage( - tabId, - `/cta/transfer/pickup?talerPayPushUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerRecovery: - return platform.redirectTabToWalletPage( - tabId, - `/cta/transfer/recovery?talerBackupUri=${encodeURIComponent(talerUri)}`, - ); - case TalerUriType.TalerPayTemplate: - return platform.redirectTabToWalletPage( - tabId, - `/cta/pay/template?talerPayTemplateUri=${encodeURIComponent(talerUri)}`, - ); - return; - case TalerUriType.Unknown: - logger.warn( - `Response with HTTP 402 the Taler header but could not classify ${talerUri}`, - ); - return; - case TalerUriType.TalerDevExperiment: - // FIXME: Implement! - logger.warn("not implemented"); - return; - case TalerUriType.TalerTemplate: - logger.warn("not implemented"); - return; - default: { - const error: never = uriType; - logger.warn( - `Response with HTTP 402 the Taler header "${error}", but header value is not a taler:// URI.`, - ); - return; - } + const uri = parseTalerUri(talerUri); + if (!uri) { + logger.warn( + `Response with HTTP 402 the Taler header but could not classify ${talerUri}`, + ); + return; } + return platform.redirectTabToWalletPage( + tabId, + `/taler-uri/${encodeURIComponent(talerUri)}`, + ); } /** |