From 9ab2b6d060376ac4caed88e691d4475421d67a42 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 16 Aug 2019 08:48:43 -0400 Subject: [PATCH] receive message from cs scripts --- src/browser/safariApp.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/browser/safariApp.ts b/src/browser/safariApp.ts index 627a4b918b..6b4f07a7ca 100644 --- a/src/browser/safariApp.ts +++ b/src/browser/safariApp.ts @@ -39,10 +39,17 @@ export class SafariApp { } private static receiveMessageFromApp(message: any) { - if (message == null || message.id == null || !(window as any).bitwardenSafariAppRequests.has(message.id)) { + if (message == null) { return; } - const p = (window as any).bitwardenSafariAppRequests.get(message.id); - p.resolve(message.responseData); + if (message.id == null && message.command === 'cs_message') { + try { + const msg = JSON.parse(message.data); + SafariApp.sendMessageToListeners(msg, 'cs_message', null); + } catch { } + } else if (message.id != null && (window as any).bitwardenSafariAppRequests.has(message.id)) { + const p = (window as any).bitwardenSafariAppRequests.get(message.id); + p.resolve(message.responseData); + } } }