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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
729 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) {
2021-02-10 16:40:15 +01:00
return Promise.resolve(null);
2019-08-12 18:31:32 +02:00
}
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",
2021-12-21 15:43:35 +01:00
{
id: messageId,
command: command,
data: data,
responseData: null,
2021-12-21 15:43:35 +01:00
},
(response: any) => {
resolve(response);
2021-12-21 15:43:35 +01:00
}
);
});
}
2019-08-12 18:31:32 +02:00
}