summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/platform/chrome.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/platform/chrome.ts')
-rw-r--r--packages/taler-wallet-webextension/src/platform/chrome.ts69
1 files changed, 36 insertions, 33 deletions
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts
index 4b0bdbfb7..03259314e 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -15,11 +15,11 @@
*/
import {
- classifyTalerUri,
Logger,
TalerErrorCode,
- TalerUriType,
+ TalerUriAction,
TalerError,
+ parseTalerUri,
} from "@gnu-taler/taler-util";
import { WalletOperations } from "@gnu-taler/taler-wallet-core";
import { BackgroundOperations } from "../wxApi.js";
@@ -239,80 +239,83 @@ function openWalletURIFromPopup(maybeTalerUri: string): void {
const talerUri = maybeTalerUri.startsWith("ext+")
? maybeTalerUri.substring(4)
: maybeTalerUri;
- const uriType = classifyTalerUri(talerUri);
+ const uri = parseTalerUri(talerUri);
+ if (!uri) {
+ logger.warn(
+ `Response with HTTP 402 the Taler header but could not classify ${talerUri}`,
+ );
+ return;
+ }
+ //FIXME: this should redirect to just one place
+ // the target pathname should handle what happens if the endpoint is not there
+ // like "trying to open from popup but this uri is not handled"
encodeURIComponent;
let url: string | undefined = undefined;
- switch (uriType) {
- case TalerUriType.TalerWithdraw:
+ switch (uri.type) {
+ case TalerUriAction.Withdraw:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/withdraw?talerWithdrawUri=${encodeURIComponent(
+ `static/wallet.html#/cta/withdraw?talerUri=${encodeURIComponent(
talerUri,
)}`,
);
break;
- case TalerUriType.TalerRecovery:
+ case TalerUriAction.Restore:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/recovery?talerRecoveryUri=${encodeURIComponent(
+ `static/wallet.html#/cta/recovery?talerUri=${encodeURIComponent(
talerUri,
)}`,
);
break;
- case TalerUriType.TalerPay:
+ case TalerUriAction.Pay:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/pay?talerPayUri=${encodeURIComponent(
- talerUri,
- )}`,
+ `static/wallet.html#/cta/pay?talerUri=${encodeURIComponent(talerUri)}`,
);
break;
- case TalerUriType.TalerTip:
+ case TalerUriAction.Tip:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/tip?talerTipUri=${encodeURIComponent(
- talerUri,
- )}`,
+ `static/wallet.html#/cta/tip?talerUri=${encodeURIComponent(talerUri)}`,
);
break;
- case TalerUriType.TalerRefund:
+ case TalerUriAction.Refund:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/refund?talerRefundUri=${encodeURIComponent(
+ `static/wallet.html#/cta/refund?talerUri=${encodeURIComponent(
talerUri,
)}`,
);
break;
- case TalerUriType.TalerPayPull:
+ case TalerUriAction.PayPull:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/invoice/pay?talerPayPullUri=${encodeURIComponent(
+ `static/wallet.html#/cta/invoice/pay?talerUri=${encodeURIComponent(
talerUri,
)}`,
);
break;
- case TalerUriType.TalerPayPush:
+ case TalerUriAction.PayPush:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/transfer/pickup?talerPayPushUri=${encodeURIComponent(
+ `static/wallet.html#/cta/transfer/pickup?talerUri=${encodeURIComponent(
talerUri,
)}`,
);
break;
- case TalerUriType.TalerPayTemplate:
+ case TalerUriAction.PayTemplate:
url = chrome.runtime.getURL(
- `static/wallet.html#/cta/pay/template?talerPayTemplateUri=${encodeURIComponent(
+ `static/wallet.html#/cta/pay/template?talerUri=${encodeURIComponent(
talerUri,
)}`,
);
break;
- case TalerUriType.Unknown:
- logger.warn(
- `Response with HTTP 402 the Taler header but could not classify ${talerUri}`,
- );
- return;
- case TalerUriType.TalerDevExperiment:
+ case TalerUriAction.DevExperiment:
logger.warn(`taler://dev-experiment URIs are not allowed in headers`);
return;
- case TalerUriType.TalerTemplate:
- logger.warn(`taler://dev-template URIs are not allowed in headers`);
+ case TalerUriAction.Exchange:
+ logger.warn(`taler://exchange not yet supported`);
+ return;
+ case TalerUriAction.Auditor:
+ logger.warn(`taler://auditor not yet supported`);
return;
default: {
- const error: never = uriType;
+ const error: never = uri;
logger.warn(
`Response with HTTP 402 the Taler header "${error}", but header value is not a taler:// URI.`,
);