From 9b04d8bf3581d162cbd631892ca115df811c46f8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Jan 2023 08:38:48 -0300 Subject: fix #7152 --- .../taler-wallet-webextension/src/platform/api.ts | 8 ++- .../src/platform/chrome.ts | 60 +++++++++++----------- .../src/platform/firefox.ts | 7 ++- 3 files changed, 38 insertions(+), 37 deletions(-) (limited to 'packages/taler-wallet-webextension/src/platform') diff --git a/packages/taler-wallet-webextension/src/platform/api.ts b/packages/taler-wallet-webextension/src/platform/api.ts index cd09f6438..40993477b 100644 --- a/packages/taler-wallet-webextension/src/platform/api.ts +++ b/packages/taler-wallet-webextension/src/platform/api.ts @@ -146,9 +146,9 @@ export interface BackgroundPlatformAPI { */ getPermissionsApi(): CrossBrowserPermissionsApi; /** - * Used by the wallet backend to send notification about new information - * @param message - */ + * Used by the wallet backend to send notification about new information + * @param message + */ sendMessageToAllChannels(message: MessageFromBackend): void; /** @@ -196,7 +196,6 @@ export interface ForegroundPlatformAPI { */ openWalletURIFromPopup(talerUri: string): void; - /** * Popup API * @@ -248,5 +247,4 @@ export interface ForegroundPlatformAPI { listenToWalletBackground( listener: (message: MessageFromBackend) => void, ): () => void; - } diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts index e5efdec4e..fc51a65fb 100644 --- a/packages/taler-wallet-webextension/src/platform/chrome.ts +++ b/packages/taler-wallet-webextension/src/platform/chrome.ts @@ -14,17 +14,17 @@ GNU Taler; see the file COPYING. If not, see */ -import { - classifyTalerUri, Logger, - TalerUriType -} from "@gnu-taler/taler-util"; +import { classifyTalerUri, Logger, TalerUriType } from "@gnu-taler/taler-util"; import { WalletOperations } from "@gnu-taler/taler-wallet-core"; import { BackgroundOperations } from "../wxApi.js"; import { - BackgroundPlatformAPI, CrossBrowserPermissionsApi, ForegroundPlatformAPI, MessageFromBackend, + BackgroundPlatformAPI, + CrossBrowserPermissionsApi, + ForegroundPlatformAPI, + MessageFromBackend, MessageFromFrontend, MessageResponse, - Permissions + Permissions, } from "./api.js"; const api: BackgroundPlatformAPI & ForegroundPlatformAPI = { @@ -306,13 +306,12 @@ function openWalletPageFromPopup(page: string): void { }); } - let nextMessageIndex = 0; /** * To be used by the foreground - * @param message - * @returns + * @param message + * @returns */ async function sendMessageToBackground< Op extends WalletOperations | BackgroundOperations, @@ -321,13 +320,13 @@ async function sendMessageToBackground< return new Promise((resolve, reject) => { logger.trace("send operation to the wallet background", message); - let timedout = false + let timedout = false; setTimeout(() => { - timedout = true - reject("timedout") + timedout = true; + reject("timedout"); }, 2000); chrome.runtime.sendMessage(messageWithId, (backgroundResponse) => { - if (timedout) return false + if (timedout) return false; if (chrome.runtime.lastError) { reject(chrome.runtime.lastError.message); } else { @@ -358,7 +357,6 @@ function listenToWalletBackground(listener: (m: any) => void): () => void { const allPorts: chrome.runtime.Port[] = []; - function sendMessageToAllChannels(message: MessageFromBackend): void { for (const notif of allPorts) { // const message: MessageFromBackend = { type: msg.type }; @@ -578,26 +576,26 @@ function setAlertedIcon(): void { interface OffscreenCanvasRenderingContext2D extends CanvasState, - CanvasTransform, - CanvasCompositing, - CanvasImageSmoothing, - CanvasFillStrokeStyles, - CanvasShadowStyles, - CanvasFilters, - CanvasRect, - CanvasDrawPath, - CanvasUserInterface, - CanvasText, - CanvasDrawImage, - CanvasImageData, - CanvasPathDrawingStyles, - CanvasTextDrawingStyles, - CanvasPath { + CanvasTransform, + CanvasCompositing, + CanvasImageSmoothing, + CanvasFillStrokeStyles, + CanvasShadowStyles, + CanvasFilters, + CanvasRect, + CanvasDrawPath, + CanvasUserInterface, + CanvasText, + CanvasDrawImage, + CanvasImageData, + CanvasPathDrawingStyles, + CanvasTextDrawingStyles, + CanvasPath { readonly canvas: OffscreenCanvas; } declare const OffscreenCanvasRenderingContext2D: { prototype: OffscreenCanvasRenderingContext2D; - new(): OffscreenCanvasRenderingContext2D; + new (): OffscreenCanvasRenderingContext2D; }; interface OffscreenCanvas extends EventTarget { @@ -610,7 +608,7 @@ interface OffscreenCanvas extends EventTarget { } declare const OffscreenCanvas: { prototype: OffscreenCanvas; - new(width: number, height: number): OffscreenCanvas; + new (width: number, height: number): OffscreenCanvas; }; function createCanvas(size: number): OffscreenCanvas { diff --git a/packages/taler-wallet-webextension/src/platform/firefox.ts b/packages/taler-wallet-webextension/src/platform/firefox.ts index a36859a0b..7f6980be7 100644 --- a/packages/taler-wallet-webextension/src/platform/firefox.ts +++ b/packages/taler-wallet-webextension/src/platform/firefox.ts @@ -14,7 +14,12 @@ GNU Taler; see the file COPYING. If not, see */ -import { BackgroundPlatformAPI, CrossBrowserPermissionsApi, ForegroundPlatformAPI, Permissions } from "./api.js"; +import { + BackgroundPlatformAPI, + CrossBrowserPermissionsApi, + ForegroundPlatformAPI, + Permissions, +} from "./api.js"; import chromePlatform, { containsHostPermissions as chromeHostContains, removeHostPermissions as chromeHostRemove, -- cgit v1.2.3