diff options
author | Sebastian <sebasjm@gmail.com> | 2022-03-23 10:50:12 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-03-23 10:58:57 -0300 |
commit | 32f6409ac312f31821f791c3a376168289f0e4f4 (patch) | |
tree | c77c660bb85cf359faf74b5cddbe95eb0a915c5e /packages/taler-wallet-webextension/src/utils/index.ts | |
parent | c539d1803c1376cba0831be64866b6d2c1652403 (diff) | |
download | wallet-core-32f6409ac312f31821f791c3a376168289f0e4f4.tar.xz |
all the browser related code move into one place, making it easy for specific platform code or mocking for testing
Diffstat (limited to 'packages/taler-wallet-webextension/src/utils/index.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/utils/index.ts | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/packages/taler-wallet-webextension/src/utils/index.ts b/packages/taler-wallet-webextension/src/utils/index.ts index cef0595d3..e5447f9cb 100644 --- a/packages/taler-wallet-webextension/src/utils/index.ts +++ b/packages/taler-wallet-webextension/src/utils/index.ts @@ -187,52 +187,3 @@ export function amountToString(text: AmountJson): string { return `${amount} ${aj.currency}`; } -export function actionForTalerUri( - uriType: TalerUriType, - talerUri: string, -): string | undefined { - switch (uriType) { - case TalerUriType.TalerWithdraw: - return makeExtensionUrlWithParams("static/wallet.html#/cta/withdraw", { - talerWithdrawUri: talerUri, - }); - case TalerUriType.TalerPay: - return makeExtensionUrlWithParams("static/wallet.html#/cta/pay", { - talerPayUri: talerUri, - }); - case TalerUriType.TalerTip: - return makeExtensionUrlWithParams("static/wallet.html#/cta/tip", { - talerTipUri: talerUri, - }); - case TalerUriType.TalerRefund: - return makeExtensionUrlWithParams("static/wallet.html#/cta/refund", { - talerRefundUri: talerUri, - }); - case TalerUriType.TalerNotifyReserve: - // FIXME: implement - break; - default: - console.warn( - "Response with HTTP 402 has Taler header, but header value is not a taler:// URI.", - ); - break; - } - return undefined; -} - -function makeExtensionUrlWithParams( - url: string, - params?: { [name: string]: string | undefined }, -): string { - // eslint-disable-next-line no-undef - const innerUrl = new URL(chrome.runtime.getURL("/" + url)); - if (params) { - const hParams = Object.keys(params) - .map((k) => `${k}=${params[k]}`) - .join("&"); - innerUrl.hash = innerUrl.hash + "?" + hParams; - } - return innerUrl.href; -} - - |