safariapp apis updates

This commit is contained in:
Kyle Spearrin 2019-08-15 14:06:59 -04:00
parent e5e04b8fa9
commit 039f09e33f
2 changed files with 7 additions and 3 deletions

View File

@ -156,7 +156,7 @@ export class BrowserApi {
return chrome.runtime.getManifest().version; return chrome.runtime.getManifest().version;
} else if (BrowserApi.isSafariApi) { } else if (BrowserApi.isSafariApi) {
// TODO // TODO
return 'TODO'; return null;
} else { } else {
return null; return null;
} }

View File

@ -3,8 +3,11 @@ import { BrowserApi } from './browserApi';
export class SafariApp { export class SafariApp {
static init() { static init() {
if (BrowserApi.isSafariApi) { if (BrowserApi.isSafariApi) {
(window as any).bitwardenSafariAppMessageReceiver = (message: any) => (window as any).bitwardenSafariAppMessageReceiver = (message: any) => {
// tslint:disable-next-line
console.log(message);
SafariApp.receiveMessageFromApp(message == null ? null : JSON.parse(message)); SafariApp.receiveMessageFromApp(message == null ? null : JSON.parse(message));
};
} }
} }
@ -19,6 +22,7 @@ export class SafariApp {
id: messageId, id: messageId,
command: command, command: command,
data: data, data: data,
responseData: null,
})); }));
SafariApp.requests.set(messageId, { resolve: resolve, date: now }); SafariApp.requests.set(messageId, { resolve: resolve, date: now });
}); });
@ -31,6 +35,6 @@ export class SafariApp {
return; return;
} }
const p = SafariApp.requests.get(message.id); const p = SafariApp.requests.get(message.id);
p.resolve(message.data); p.resolve(message.responseData);
} }
} }