gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (e9c6b105d -> 63755ad98)


From: gnunet
Subject: [taler-wallet-core] branch master updated (e9c6b105d -> 63755ad98)
Date: Fri, 19 Jan 2024 14:30:22 +0100

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

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

    from e9c6b105d update config from merchant
     new e8d82efd3 fix: missing changes in merchant
     new 63755ad98 fixes #8136

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/paths/admin/create/Create.stories.tsx      |   5 +
 .../src/paths/admin/create/stories.tsx             |   5 +
 .../src/paths/instance/details/stories.tsx         |   5 +
 .../src/paths/instance/templates/update/index.tsx  |   2 +-
 .../src/paths/settings/index.tsx                   |   2 +-
 .../src/taler-wallet-interaction-support.ts        | 310 +++++++++++----------
 6 files changed, 173 insertions(+), 156 deletions(-)

diff --git 
a/packages/merchant-backoffice-ui/src/paths/admin/create/Create.stories.tsx 
b/packages/merchant-backoffice-ui/src/paths/admin/create/Create.stories.tsx
index 91b6b4b56..93ada2374 100644
--- a/packages/merchant-backoffice-ui/src/paths/admin/create/Create.stories.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/admin/create/Create.stories.tsx
@@ -41,6 +41,11 @@ function createExample<Props>(
       value={{
         currency: "ARS",
         version: "1",
+        currencies: {
+          currency: "TESTKUDOS"
+        },
+        exchanges: [],
+        name: "taler-merchant"
       }}
     >
       <Component {...args} />
diff --git a/packages/merchant-backoffice-ui/src/paths/admin/create/stories.tsx 
b/packages/merchant-backoffice-ui/src/paths/admin/create/stories.tsx
index 0012f9b9b..0161e9dc1 100644
--- a/packages/merchant-backoffice-ui/src/paths/admin/create/stories.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/admin/create/stories.tsx
@@ -41,6 +41,11 @@ function createExample<Props>(
       value={{
         currency: "TESTKUDOS",
         version: "1",
+        currencies: {
+          currency: "TESTKUDOS"
+        },
+        exchanges: [],
+        name: "taler-merchant"
       }}
     >
       <Internal {...(props as any)} />
diff --git 
a/packages/merchant-backoffice-ui/src/paths/instance/details/stories.tsx 
b/packages/merchant-backoffice-ui/src/paths/instance/details/stories.tsx
index 367fabce2..d7f61a8a5 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/details/stories.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/details/stories.tsx
@@ -41,6 +41,11 @@ function createExample<Props>(
       value={{
         currency: "TESTKUDOS",
         version: "1",
+        currencies: {
+          currency: "TESTKUDOS"
+        },
+        exchanges: [],
+        name: "taler-merchant"
       }}
     >
       <Internal {...(props as any)} />
diff --git 
a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx 
b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx
index 3adca45db..fb9b1d8aa 100644
--- 
a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx
+++ 
b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx
@@ -80,7 +80,7 @@ export default function UpdateTemplate({
     <Fragment>
       <NotificationCard notification={notif} />
       <UpdatePage
-        template={{ ...result.data, id: tid }}
+        template={{ ...result.data }}
         onBack={onBack}
         onUpdate={(data) => {
           return updateTemplate(tid, data)
diff --git a/packages/merchant-backoffice-ui/src/paths/settings/index.tsx 
b/packages/merchant-backoffice-ui/src/paths/settings/index.tsx
index 87bd2fa39..8e69537ec 100644
--- a/packages/merchant-backoffice-ui/src/paths/settings/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/settings/index.tsx
@@ -16,7 +16,7 @@ function getBrowserLang(): string | undefined {
 export function Settings({ onClose }: { onClose?: () => void }): VNode {
   const { i18n } = useTranslationContext()
   const borwserLang = getBrowserLang()
-  const { update } = useLang()
+  const { update } = useLang(undefined, {})
 
   const [value, updateValue] = useSettings()
   const errors: FormErrors<Settings> = {
diff --git 
a/packages/taler-wallet-webextension/src/taler-wallet-interaction-support.ts 
b/packages/taler-wallet-webextension/src/taler-wallet-interaction-support.ts
index 085b7a2ec..993c12703 100644
--- a/packages/taler-wallet-webextension/src/taler-wallet-interaction-support.ts
+++ b/packages/taler-wallet-webextension/src/taler-wallet-interaction-support.ts
@@ -20,173 +20,175 @@
  * This script will be loaded and run in every page while the
  * user us navigating. It must be short, simple and safe.
  */
+(() => {
+  const logger = {
+    debug: (...msg: any[]) => { },
+    info: (...msg: any[]) =>
+      console.log(`${new Date().toISOString()} TALER`, ...msg),
+    error: (...msg: any[]) =>
+      console.error(`${new Date().toISOString()} TALER`, ...msg),
+  };
 
-const logger = {
-  debug: (...msg: any[]) => { },
-  info: (...msg: any[]) =>
-    console.log(`${new Date().toISOString()} TALER`, ...msg),
-  error: (...msg: any[]) =>
-    console.error(`${new Date().toISOString()} TALER`, ...msg),
-};
-
-const documentDocTypeIsHTML =
-  window.document.doctype && window.document.doctype.name === "html";
-const suffixIsNotXMLorPDF =
-  !window.location.pathname.endsWith(".xml") &&
-  !window.location.pathname.endsWith(".pdf");
-const rootElementIsHTML =
-  document.documentElement.nodeName &&
-  document.documentElement.nodeName.toLowerCase() === "html";
-const pageAcceptsTalerSupport = document.head.querySelector(
-  "meta[name=taler-support]",
-);
-
-// this is also checked by the loader
-// but a double check will prevent running and breaking user navigation
-// if loaded from other location
-const shouldNotRun =
-  !documentDocTypeIsHTML ||
-  !suffixIsNotXMLorPDF ||
-  // !pageAcceptsTalerSupport || FIXME: removing this before release for 
testing
-  !rootElementIsHTML;
-
-interface Info {
-  extensionId: string;
-  protocol: string;
-  hostname: string;
-}
-interface API {
-  convertURIToWebExtensionPath: (uri: string) => string | undefined;
-  anchorOnClick: (ev: MouseEvent) => void;
-  registerProtocolHandler: () => void;
-}
-interface TalerSupport {
-  info: Readonly<Info>;
-  __internal: API;
-}
-
-function buildApi(config: Readonly<Info>): API {
-  /**
-   * Takes an anchor href that starts with taler:// and
-   * returns the path to the web-extension page
-   */
-  function convertURIToWebExtensionPath(uri: string): string | undefined {
-    if (!validateTalerUri(uri)) {
-      logger.error(`taler:// URI is invalid: ${uri}`);
-      return undefined;
-    }
-    const host = `${config.protocol}//${config.hostname}`;
-    const path = `static/wallet.html#/taler-uri/${encodeURIComponent(uri)}`;
-    return `${host}/${path}`;
+  const documentDocTypeIsHTML =
+    window.document.doctype && window.document.doctype.name === "html";
+  const suffixIsNotXMLorPDF =
+    !window.location.pathname.endsWith(".xml") &&
+    !window.location.pathname.endsWith(".pdf");
+  const rootElementIsHTML =
+    document.documentElement.nodeName &&
+    document.documentElement.nodeName.toLowerCase() === "html";
+  const pageAcceptsTalerSupport = document.head.querySelector(
+    "meta[name=taler-support]",
+  );
+
+  // this is also checked by the loader
+  // but a double check will prevent running and breaking user navigation
+  // if loaded from other location
+  const shouldNotRun =
+    !documentDocTypeIsHTML ||
+    !suffixIsNotXMLorPDF ||
+    // !pageAcceptsTalerSupport || FIXME: removing this before release for 
testing
+    !rootElementIsHTML;
+
+  interface Info {
+    extensionId: string;
+    protocol: string;
+    hostname: string;
+  }
+  interface API {
+    convertURIToWebExtensionPath: (uri: string) => string | undefined;
+    anchorOnClick: (ev: MouseEvent) => void;
+    registerProtocolHandler: () => void;
+  }
+  interface TalerSupport {
+    info: Readonly<Info>;
+    __internal: API;
   }
 
-  function anchorOnClick(ev: MouseEvent) {
-    if (!(ev.currentTarget instanceof Element)) {
-      logger.debug(`onclick: registered in a link that is not an HTML 
element`);
-      return;
+  function buildApi(config: Readonly<Info>): API {
+    /**
+     * Takes an anchor href that starts with taler:// and
+     * returns the path to the web-extension page
+     */
+    function convertURIToWebExtensionPath(uri: string): string | undefined {
+      if (!validateTalerUri(uri)) {
+        logger.error(`taler:// URI is invalid: ${uri}`);
+        return undefined;
+      }
+      const host = `${config.protocol}//${config.hostname}`;
+      const path = `static/wallet.html#/taler-uri/${encodeURIComponent(uri)}`;
+      return `${host}/${path}`;
     }
-    const hrefAttr = ev.currentTarget.attributes.getNamedItem("href");
-    if (!hrefAttr) {
-      logger.debug(`onclick: link didn't have href with taler:// uri`);
-      return;
+
+    function anchorOnClick(ev: MouseEvent) {
+      if (!(ev.currentTarget instanceof Element)) {
+        logger.debug(`onclick: registered in a link that is not an HTML 
element`);
+        return;
+      }
+      const hrefAttr = ev.currentTarget.attributes.getNamedItem("href");
+      if (!hrefAttr) {
+        logger.debug(`onclick: link didn't have href with taler:// uri`);
+        return;
+      }
+      const targetAttr = ev.currentTarget.attributes.getNamedItem("target");
+      const windowTarget =
+        targetAttr && targetAttr.value ? targetAttr.value : "_self";
+      const page = convertURIToWebExtensionPath(hrefAttr.value);
+      if (!page) {
+        logger.debug(`onclick: could not convert "${hrefAttr.value}" into 
path`);
+        return;
+      }
+      // we can use window.open, but maybe some browser will block it?
+      window.open(page, windowTarget);
+      ev.preventDefault();
+      ev.stopPropagation();
+      ev.stopImmediatePropagation();
+      return false;
     }
-    const targetAttr = ev.currentTarget.attributes.getNamedItem("target");
-    const windowTarget =
-      targetAttr && targetAttr.value ? targetAttr.value : "_self";
-    const page = convertURIToWebExtensionPath(hrefAttr.value);
-    if (!page) {
-      logger.debug(`onclick: could not convert "${hrefAttr.value}" into path`);
-      return;
+
+    function overrideAllAnchor(root: HTMLElement) {
+      const allAnchors = root.querySelectorAll("a[href^=taler]");
+      logger.debug(`registering taler protocol in ${allAnchors.length} links`);
+      allAnchors.forEach((link) => {
+        if (link instanceof HTMLElement) {
+          link.addEventListener("click", anchorOnClick);
+        }
+      });
     }
-    // we can use window.open, but maybe some browser will block it?
-    window.open(page, windowTarget);
-    ev.preventDefault();
-    ev.stopPropagation();
-    ev.stopImmediatePropagation();
-    return false;
-  }
 
-  function overrideAllAnchor(root: HTMLElement) {
-    const allAnchors = root.querySelectorAll("a[href^=taler]");
-    logger.debug(`registering taler protocol in ${allAnchors.length} links`);
-    allAnchors.forEach((link) => {
-      if (link instanceof HTMLElement) {
-        link.addEventListener("click", anchorOnClick);
-      }
-    });
-  }
+    function checkForNewAnchors(
+      mutations: MutationRecord[],
+      observer: MutationObserver,
+    ) {
+      mutations.forEach((mut) => {
+        if (mut.type === "childList") {
+          mut.addedNodes.forEach((added) => {
+            if (added instanceof HTMLElement) {
+              logger.debug(`new element`, added);
+              overrideAllAnchor(added);
+            }
+          });
+        }
+      });
+    }
 
-  function checkForNewAnchors(
-    mutations: MutationRecord[],
-    observer: MutationObserver,
-  ) {
-    mutations.forEach((mut) => {
-      if (mut.type === "childList") {
-        mut.addedNodes.forEach((added) => {
-          if (added instanceof HTMLElement) {
-            logger.debug(`new element`, added);
-            overrideAllAnchor(added);
-          }
-        });
-      }
-    });
-  }
+    /**
+     * Check of every anchor and observes for new one.
+     * Register the anchor handler when found
+     */
+    function registerProtocolHandler() {
+      if (document.body) overrideAllAnchor(document.body)
+      new MutationObserver(checkForNewAnchors).observe(document, {
+        childList: true,
+        subtree: true,
+        attributes: false,
+      });
+    }
 
-  /**
-   * Check of every anchor and observes for new one.
-   * Register the anchor handler when found
-   */
-  function registerProtocolHandler() {
-    if (document.body) overrideAllAnchor(document.body)
-    new MutationObserver(checkForNewAnchors).observe(document, {
-      childList: true,
-      subtree: true,
-      attributes: false,
-    });
+    return {
+      convertURIToWebExtensionPath,
+      anchorOnClick,
+      registerProtocolHandler,
+    };
   }
 
-  return {
-    convertURIToWebExtensionPath,
-    anchorOnClick,
-    registerProtocolHandler,
-  };
-}
-
-function start() {
-  if (shouldNotRun) return;
-  // FIXME: we can remove this if the script caller send information we need
-  if (!(document.currentScript instanceof HTMLScriptElement)) return;
-
-  const url = new URL(document.currentScript.src);
-  const { protocol, searchParams, hostname } = url;
-  const extensionId = searchParams.get("id") ?? "";
-  const debugEnabled = searchParams.get("debug") === "true";
-  if (debugEnabled) {
-    logger.debug = logger.info;
-  }
+  function start() {
+    if (shouldNotRun) return;
+    // FIXME: we can remove this if the script caller send information we need
+    if (!(document.currentScript instanceof HTMLScriptElement)) return;
+
+    const url = new URL(document.currentScript.src);
+    const { protocol, searchParams, hostname } = url;
+    const extensionId = searchParams.get("id") ?? "";
+    const debugEnabled = searchParams.get("debug") === "true";
+    if (debugEnabled) {
+      logger.debug = logger.info;
+    }
 
-  const info: Info = Object.freeze({
-    extensionId,
-    protocol,
-    hostname,
-  });
-  const taler: TalerSupport = {
-    info,
-    __internal: buildApi(info),
-  };
+    const info: Info = Object.freeze({
+      extensionId,
+      protocol,
+      hostname,
+    });
+    const taler: TalerSupport = {
+      info,
+      __internal: buildApi(info),
+    };
 
-  //@ts-ignore
-  window.taler = taler;
+    //@ts-ignore
+    window.taler = taler;
 
-  //default behavior: register on install
-  taler.__internal.registerProtocolHandler();
-}
+    //default behavior: register on install
+    taler.__internal.registerProtocolHandler();
+  }
 
-// utils functions
-function validateTalerUri(uri: string): boolean {
-  return (
-    !!uri && (uri.startsWith("taler://") || uri.startsWith("taler+http://";))
-  );
-}
+  // utils functions
+  function validateTalerUri(uri: string): boolean {
+    return (
+      !!uri && (uri.startsWith("taler://") || uri.startsWith("taler+http://";))
+    );
+  }
+
+  return start
+})()
 
-start();

-- 
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]