gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 05/05: support for ext+taler:// while taler:// is no


From: gnunet
Subject: [taler-wallet-core] 05/05: support for ext+taler:// while taler:// is not yet allowed as scheme
Date: Thu, 22 Dec 2022 22:42:36 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit dc002f99a96752d3f0a10efe44a8a4d0503e8529
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Dec 22 18:42:18 2022 -0300

    support for ext+taler:// while taler:// is not yet allowed as scheme
---
 .../taler-wallet-webextension/manifest-v2.json     |  7 +++
 .../taler-wallet-webextension/manifest-v3.json     | 12 +++++
 .../src/cta/Withdraw/state.ts                      |  7 ++-
 .../src/platform/chrome.ts                         |  5 +-
 .../src/wallet/DeveloperPage.tsx                   | 60 +++++++++++++++++++++-
 .../taler-wallet-webextension/src/wxBackend.ts     |  5 +-
 6 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/packages/taler-wallet-webextension/manifest-v2.json 
b/packages/taler-wallet-webextension/manifest-v2.json
index 8c336da25..6adadad98 100644
--- a/packages/taler-wallet-webextension/manifest-v2.json
+++ b/packages/taler-wallet-webextension/manifest-v2.json
@@ -26,6 +26,13 @@
     "https://*/*";,
     "webRequest"
   ],
+  "protocol_handlers": [
+    {
+      "protocol": "ext+taler",
+      "name": "Taler Wallet WebExtension",
+      "uriTemplate": 
"/static/wallet.html#/cta/withdraw?d=1&talerWithdrawUri=%s"
+    }
+  ],
   "browser_action": {
     "default_icon": {
       "16": "static/img/taler-logo-16.png",
diff --git a/packages/taler-wallet-webextension/manifest-v3.json 
b/packages/taler-wallet-webextension/manifest-v3.json
index fe9b75375..4e18125b3 100644
--- a/packages/taler-wallet-webextension/manifest-v3.json
+++ b/packages/taler-wallet-webextension/manifest-v3.json
@@ -29,6 +29,18 @@
   "optional_permissions": [
     "webRequest"
   ],
+  "web_accessible_resources": [
+    {
+      "resources": [
+        "static/wallet.html"
+      ],
+      "matches": [
+        "https://*/*";,
+        "http://*/*";,
+        "file://*/*"
+      ]
+    }
+  ],
   "host_permissions": [
     "http://*/*";,
     "https://*/*";
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts 
b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
index 1ecf05eca..d1853442b 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -90,7 +90,7 @@ export function useComponentStateFromParams({
 }
 
 export function useComponentStateFromURI({
-  talerWithdrawUri,
+  talerWithdrawUri: maybeTalerUri,
   cancel,
   onSuccess,
 }: PropsFromURI): RecursiveState<State> {
@@ -99,7 +99,10 @@ export function useComponentStateFromURI({
    * Ask the wallet about the withdraw URI
    */
   const uriInfoHook = useAsyncAsHook(async () => {
-    if (!talerWithdrawUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL");
+    if (!maybeTalerUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL");
+    const talerWithdrawUri = maybeTalerUri.startsWith("ext+")
+      ? maybeTalerUri.substring(4)
+      : maybeTalerUri;
 
     const uriInfo = await api.wallet.call(
       WalletApiOperation.GetWithdrawalDetailsForUri,
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts 
b/packages/taler-wallet-webextension/src/platform/chrome.ts
index b7b0c6640..744283913 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -233,7 +233,10 @@ function notifyWhenAppIsReady(callback: () => void): void {
   }
 }
 
-function openWalletURIFromPopup(talerUri: string): void {
+function openWalletURIFromPopup(maybeTalerUri: string): void {
+  const talerUri = maybeTalerUri.startsWith("ext+")
+    ? maybeTalerUri.substring(4)
+    : maybeTalerUri;
   const uriType = classifyTalerUri(talerUri);
 
   let url: string | undefined = undefined;
diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx 
b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
index 0916f4f43..4805c03ca 100644
--- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
@@ -170,7 +170,7 @@ export function View({
       <p>
         <i18n.Translate>Debug tools</i18n.Translate>:
       </p>
-      <Grid container justifyContent="space-between" spacing={1}>
+      <Grid container justifyContent="space-between" spacing={1} size={4}>
         <Grid item>
           <Button
             variant="contained"
@@ -251,6 +251,64 @@ export function View({
             <i18n.Translate>export database</i18n.Translate>
           </Button>
         </Grid>
+        <Grid item>
+          <Button
+            variant="contained"
+            onClick={async () => {
+              navigator.registerProtocolHandler(
+                "taler",
+                
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
+              );
+            }}
+          >
+            <i18n.Translate>Register taler:// handler</i18n.Translate>
+          </Button>
+        </Grid>
+        <Grid item>
+          <Button
+            variant="contained"
+            onClick={async () => {
+              const n = navigator as any;
+              if ("unregisterProtocolHandler" in n) {
+                n.unregisterProtocolHandler(
+                  "taler",
+                  
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
+                );
+              }
+            }}
+          >
+            <i18n.Translate>Remove taler:// handler</i18n.Translate>
+          </Button>
+        </Grid>{" "}
+        <Grid item>
+          <Button
+            variant="contained"
+            onClick={async () => {
+              navigator.registerProtocolHandler(
+                "ext+taler",
+                
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
+              );
+            }}
+          >
+            <i18n.Translate>Register ext+taler:// handler</i18n.Translate>
+          </Button>
+        </Grid>
+        <Grid item>
+          <Button
+            variant="contained"
+            onClick={async () => {
+              const n = navigator as any;
+              if ("unregisterProtocolHandler" in n) {
+                n.unregisterProtocolHandler(
+                  "ext+taler",
+                  
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
+                );
+              }
+            }}
+          >
+            <i18n.Translate>Remove ext+taler:// handler</i18n.Translate>
+          </Button>
+        </Grid>{" "}
       </Grid>
       {downloadedDatabase && (
         <div>
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts 
b/packages/taler-wallet-webextension/src/wxBackend.ts
index dca239de6..0f0beb41f 100644
--- a/packages/taler-wallet-webextension/src/wxBackend.ts
+++ b/packages/taler-wallet-webextension/src/wxBackend.ts
@@ -298,7 +298,10 @@ async function reinitWallet(): Promise<void> {
   return walletInit.resolve();
 }
 
-function parseTalerUriAndRedirect(tabId: number, talerUri: string): void {
+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:

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]