aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/platform
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/platform')
-rw-r--r--packages/taler-wallet-webextension/src/platform/api.ts17
-rw-r--r--packages/taler-wallet-webextension/src/platform/chrome.ts6
-rw-r--r--packages/taler-wallet-webextension/src/platform/dev.ts1
3 files changed, 20 insertions, 4 deletions
diff --git a/packages/taler-wallet-webextension/src/platform/api.ts b/packages/taler-wallet-webextension/src/platform/api.ts
index 37f52192f..23fd80ed7 100644
--- a/packages/taler-wallet-webextension/src/platform/api.ts
+++ b/packages/taler-wallet-webextension/src/platform/api.ts
@@ -163,13 +163,22 @@ export interface PlatformAPI {
findTalerUriInActiveTab(): Promise<string | undefined>;
/**
- * Used from the frontend to send commands to the wallet
+ * Popup API
*
- * @param operation
- * @param payload
+ * Read the current tab html and try to find any Taler URI or QR code present.
*
- * @return response from the backend
+ * @return Taler URI if found
*/
+ findTalerUriInClipboard(): Promise<string | undefined>;
+
+ /**
+ * Used from the frontend to send commands to the wallet
+ *
+ * @param operation
+ * @param payload
+ *
+ * @return response from the backend
+ */
sendMessageToWalletBackground(
operation: string,
payload: any,
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts
index 4ce995bd7..7311354c9 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -30,6 +30,7 @@ import {
const api: PlatformAPI = {
isFirefox,
findTalerUriInActiveTab,
+ findTalerUriInClipboard,
getPermissionsApi,
getWalletWebExVersion,
listenToWalletBackground,
@@ -689,6 +690,11 @@ async function findTalerUriInTab(tabId: number): Promise<string | undefined> {
}
}
+async function findTalerUriInClipboard(): Promise<string | undefined> {
+ const textInClipboard = await window.navigator.clipboard.readText();
+ return textInClipboard.startsWith("taler://") || textInClipboard.startsWith("taler+http://") ? textInClipboard : undefined
+}
+
async function findTalerUriInActiveTab(): Promise<string | undefined> {
const tab = await getCurrentTab();
if (!tab || tab.id === undefined) return;
diff --git a/packages/taler-wallet-webextension/src/platform/dev.ts b/packages/taler-wallet-webextension/src/platform/dev.ts
index e5db0c8ec..bb7e181c4 100644
--- a/packages/taler-wallet-webextension/src/platform/dev.ts
+++ b/packages/taler-wallet-webextension/src/platform/dev.ts
@@ -23,6 +23,7 @@ const api: PlatformAPI = {
isFirefox: () => false,
keepAlive: (cb: VoidFunction) => cb(),
findTalerUriInActiveTab: async () => undefined,
+ findTalerUriInClipboard: async () => undefined,
containsTalerHeaderListener: () => {
return true;
},