bitwarden-estensione-browser/src/browser/safariApp.ts

22 lines
771 B
TypeScript
Raw Normal View History

2019-08-12 18:31:32 +02:00
import { BrowserApi } from './browserApi';
export class SafariApp {
static sendMessageToApp(command: string, data: any = null, resolveNow = false): Promise<any> {
2019-08-12 18:31:32 +02:00
if (!BrowserApi.isSafariApi) {
return Promise.resolve(null);
}
return new Promise((resolve) => {
2019-08-12 21:50:47 +02:00
const now = new Date();
const messageId = now.getTime().toString() + '_' + Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
(browser as any).runtime.sendNativeMessage('com.bitwarden.desktop', {
id: messageId,
command: command,
data: data,
responseData: null,
}, (response: any) => {
resolve(response);
2020-12-07 20:00:49 +01:00
});
2019-08-12 18:31:32 +02:00
});
}
}