From 03d0effe18e6b6bc5b3aee25bffc1783f487243b Mon Sep 17 00:00:00 2001 From: Son NK Date: Thu, 3 Nov 2022 14:56:01 +0100 Subject: [PATCH] send log_in and log_out event --- src/manifest.json | 1 + src/popup/components/AppSettings.vue | 15 ++++++++++++++- src/popup/components/Main.vue | 21 ++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index fa48112..466d06d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -15,6 +15,7 @@ "activeTab", "storage", "contextMenus", + "nativeMessaging", "https://*.simplelogin.io/*", "http://*/*", "https://*/*" diff --git a/src/popup/components/AppSettings.vue b/src/popup/components/AppSettings.vue index 38ea19e..fdc0215 100644 --- a/src/popup/components/AppSettings.vue +++ b/src/popup/components/AppSettings.vue @@ -27,7 +27,9 @@ v-show="showSLButton" target="_blank" > -
Report an issue +
+ + Report an issue @@ -165,6 +167,17 @@ export default { await SLStorage.remove(SLStorage.SETTINGS.API_KEY); EventManager.broadcast(EventManager.EVENT.SETTINGS_CHANGED); Navigation.clearHistoryAndNavigateTo(Navigation.PATH.LOGIN); + + try { + console.log("send log out event to host app"); + let r = await browser.runtime.sendNativeMessage("application.id", { + message: { + logged_out: {}, + }, + }); + } catch (error) { + console.info("can't send data to native app", error); + } }, async setMailToUri() { diff --git a/src/popup/components/Main.vue b/src/popup/components/Main.vue index afdc2e7..f78ca27 100644 --- a/src/popup/components/Main.vue +++ b/src/popup/components/Main.vue @@ -93,7 +93,8 @@ class="btn btn-outline-primary btn-sm" @click="createRandomAlias" > - OR create a totally random alias + + OR create a totally random alias @@ -257,6 +258,24 @@ export default { this.apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL); this.apiKey = await SLStorage.get(SLStorage.SETTINGS.API_KEY); + if (this.apiKey) { + try { + console.log("send api key to host app"); + let r = await browser.runtime.sendNativeMessage("application.id", { + message: { + logged_in: { + data: { + api_key: this.apiKey, + api_url: this.apiUrl, + }, + }, + }, + }); + } catch (error) { + console.info("can't send data to native app", error); + } + } + this.contentElem = document.querySelector(".app > .content"); await this.getUserOptions();