diff --git a/src/browser/safariApp.ts b/src/browser/safariApp.ts index 9e498f7d97..627a4b918b 100644 --- a/src/browser/safariApp.ts +++ b/src/browser/safariApp.ts @@ -3,6 +3,10 @@ import { BrowserApi } from './browserApi'; export class SafariApp { static init() { if (BrowserApi.isSafariApi) { + (window as any).bitwardenSafariAppRequests = + new Map void, date: Date }>(); + (window as any).bitwardenSafariAppMessageListeners = + new Map void, date: Date }>(); (window as any).bitwardenSafariAppMessageReceiver = (message: any) => { SafariApp.receiveMessageFromApp(message); }; @@ -22,26 +26,23 @@ export class SafariApp { data: data, responseData: null, })); - SafariApp.requests.set(messageId, { resolve: resolve, date: now }); + (window as any).bitwardenSafariAppRequests.set(messageId, { resolve: resolve, date: now }); }); } static addMessageListener(name: string, callback: (message: any, sender: any, response: any) => void) { - SafariApp.messageListeners.set(name, callback); + (window as any).bitwardenSafariAppMessageListeners.set(name, callback); } static sendMessageToListeners(message: any, sender: any, response: any) { - SafariApp.messageListeners.forEach((f) => f(message, sender, response)); + (window as any).bitwardenSafariAppMessageListeners.forEach((f: any) => f(message, sender, response)); } - private static requests = new Map void, date: Date }>(); - private static messageListeners = new Map void>(); - private static receiveMessageFromApp(message: any) { - if (message == null || message.id == null || !SafariApp.requests.has(message.id)) { + if (message == null || message.id == null || !(window as any).bitwardenSafariAppRequests.has(message.id)) { return; } - const p = SafariApp.requests.get(message.id); + const p = (window as any).bitwardenSafariAppRequests.get(message.id); p.resolve(message.responseData); } }