Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marius-wieschollek/passwords-webextension.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius David Wieschollek <passwords.public@mdns.eu>2021-01-16 14:06:56 +0300
committerMarius David Wieschollek <passwords.public@mdns.eu>2021-01-16 14:06:56 +0300
commit7ca320f77ec3e59db37ae8bd73bf1706cbf5c906 (patch)
treedbbed7cbc49da083a9482439044ce6123f64fb22
parent0e8631ceced9f62445737e09bb80a7df6436298d (diff)
Add support for chrome passlink
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
-rw-r--r--src/js/App/Background.js2
-rw-r--r--src/js/Manager/PassLinkManager.js39
-rw-r--r--src/js/Services/SystemService.js7
-rw-r--r--src/js/Services/ThemeService.js4
-rw-r--r--src/platform/chrome/manifest.json4
-rw-r--r--src/platform/fenix/manifest.json4
-rw-r--r--src/platform/firefox/manifest.json4
-rw-r--r--src/platform/generic/_locales/de/messages.json4
-rw-r--r--src/platform/generic/_locales/en/messages.json4
-rw-r--r--src/vue/Components/Firstrun/Steps/ServerSetup.vue13
10 files changed, 54 insertions, 31 deletions
diff --git a/src/js/App/Background.js b/src/js/App/Background.js
index b3ab44e..cea5277 100644
--- a/src/js/App/Background.js
+++ b/src/js/App/Background.js
@@ -18,6 +18,7 @@ import ThemeRepository from '@js/Repositories/ThemeRepository';
import SettingsService from '@js/Services/SettingsService';
import MasterSettingsProvider from '@js/Settings/MasterSettingsProvider';
import LocalisationService from "@js/Services/LocalisationService";
+import PassLinkManager from "@js/Manager/PassLinkManager";
class Background {
async init() {
@@ -28,6 +29,7 @@ class Background {
await MessageService.init();
SettingsService.init(MasterSettingsProvider);
await UpgradeManager.run();
+ PassLinkManager.init();
ControllerManager.init();
ConverterManager.init();
SearchManager.init();
diff --git a/src/js/Manager/PassLinkManager.js b/src/js/Manager/PassLinkManager.js
new file mode 100644
index 0000000..23912fe
--- /dev/null
+++ b/src/js/Manager/PassLinkManager.js
@@ -0,0 +1,39 @@
+import SystemService from "@js/Services/SystemService";
+
+export default new class PassLinkManager {
+
+ /**
+ *
+ */
+ constructor() {
+ this._beforeRequestListener =
+ (d) => { return this._redirectRequest(d); };
+ }
+
+ /**
+ *
+ */
+ init() {
+ SystemService.getBrowserApi().webRequest.onBeforeRequest.addListener(
+ this._beforeRequestListener,
+ {urls: ['https://passlink.mdns.eu/open/*']},
+ ['blocking']
+ );
+ }
+
+ /**
+ *
+ * @param requestDetails
+ * @return {{cancel: boolean}|{redirectUrl: *}}
+ * @private
+ */
+ _redirectRequest(requestDetails) {
+ let passlinkUrl = SystemService.getBrowserApi().runtime.getURL('html/passlink.html'),
+ eventUrl = requestDetails.url.replace('https://passlink.mdns.eu/open/', 'ext+passlink:');
+
+ passlinkUrl += '?link=' + encodeURIComponent(eventUrl);
+ SystemService.getBrowserApi().tabs.update(requestDetails.tabId, {url: passlinkUrl});
+
+ return {cancel: true};
+ }
+}; \ No newline at end of file
diff --git a/src/js/Services/SystemService.js b/src/js/Services/SystemService.js
index 16471b6..f9eead9 100644
--- a/src/js/Services/SystemService.js
+++ b/src/js/Services/SystemService.js
@@ -156,13 +156,6 @@ class SystemService {
}
/**
- * @returns {Boolean}
- */
- hasProtocolHandlers() {
- return process.env.APP_PLATFORM === 'firefox';
- }
-
- /**
* @returns {Promise<String>}
*/
async getUserAgent() {
diff --git a/src/js/Services/ThemeService.js b/src/js/Services/ThemeService.js
index 4c40737..1f386eb 100644
--- a/src/js/Services/ThemeService.js
+++ b/src/js/Services/ThemeService.js
@@ -65,10 +65,10 @@ class ThemeService {
if(!icon) icon = 'passwords';
if(SystemService.isCompatible(SystemService.PLATFORM_FIREFOX)) {
- return await SystemService.getBrowserApi().runtime.getURL(`img/${icon}.svg`);
+ return SystemService.getBrowserApi().runtime.getURL(`img/${icon}.svg`);
}
- return await SystemService.getBrowserApi().runtime.getURL(`img/${icon}.png`);
+ return SystemService.getBrowserApi().runtime.getURL(`img/${icon}.png`);
}
/**
diff --git a/src/platform/chrome/manifest.json b/src/platform/chrome/manifest.json
index 3b195a1..0614e48 100644
--- a/src/platform/chrome/manifest.json
+++ b/src/platform/chrome/manifest.json
@@ -50,6 +50,8 @@
"tabs",
"storage",
"contextMenus",
- "notifications"
+ "notifications",
+ "webRequest",
+ "webRequestBlocking"
]
} \ No newline at end of file
diff --git a/src/platform/fenix/manifest.json b/src/platform/fenix/manifest.json
index 8fd8e31..9539414 100644
--- a/src/platform/fenix/manifest.json
+++ b/src/platform/fenix/manifest.json
@@ -79,6 +79,8 @@
"tabs",
"storage",
"notifications",
- "clipboardWrite"
+ "clipboardWrite",
+ "webRequest",
+ "webRequestBlocking"
]
} \ No newline at end of file
diff --git a/src/platform/firefox/manifest.json b/src/platform/firefox/manifest.json
index f476698..b3a9ac9 100644
--- a/src/platform/firefox/manifest.json
+++ b/src/platform/firefox/manifest.json
@@ -87,6 +87,8 @@
"menus",
"storage",
"notifications",
- "clipboardWrite"
+ "clipboardWrite",
+ "webRequest",
+ "webRequestBlocking"
]
} \ No newline at end of file
diff --git a/src/platform/generic/_locales/de/messages.json b/src/platform/generic/_locales/de/messages.json
index 9d7800a..0bd1d8d 100644
--- a/src/platform/generic/_locales/de/messages.json
+++ b/src/platform/generic/_locales/de/messages.json
@@ -1024,10 +1024,6 @@
"message" : "Falls das hier ein Gerät ist, klicke auf die Schaltfläche unten und scanne den Code",
"description": "Text in the first run wizard for Firefox users. They can scan the QR-Code in the Passlink Connect dialog in the Nextcloud App with the extension and coonnect the extension that way"
},
- "FirstRunConnectScanChrome" : {
- "message" : "Klicke auf die Schaltfläche unten und scanne den PassLink Code",
- "description": "Text shown to chrome in the first run wizard users that they can scan the QR-Code in the PassLink Connect dialog in the Nextcloud app to start the connection process"
- },
"FirstRunConnectManual" : {
"message" : "In den Addon-Einstellungen ist es auch möglich, ein Konto manuell anzulegen",
"description": "Text in the first run wizard to tell users they can also set up the connection manually in the extension settings."
diff --git a/src/platform/generic/_locales/en/messages.json b/src/platform/generic/_locales/en/messages.json
index 99f262f..8cb7efa 100644
--- a/src/platform/generic/_locales/en/messages.json
+++ b/src/platform/generic/_locales/en/messages.json
@@ -1038,10 +1038,6 @@
"message" : "If this is a different device, scan the PassLink Connect Code with the button below",
"description": "Text in the first run wizard for Firefox users. They can scan the QR-Code in the Passlink Connect dialog in the Nextcloud App with the extension and coonnect the extension that way"
},
- "FirstRunConnectScanChrome" : {
- "message" : "Click the button below and scan the PassLink Connect code",
- "description": "Text shown to chrome in the first run wizard users that they can scan the QR-Code in the PassLink Connect dialog in the Nextcloud app to start the connection process"
- },
"FirstRunConnectManual" : {
"message" : "You can also create the account manually in the extension settings",
"description": "Text in the first run wizard to tell users they can also set up the connection manually in the extension settings."
diff --git a/src/vue/Components/Firstrun/Steps/ServerSetup.vue b/src/vue/Components/Firstrun/Steps/ServerSetup.vue
index 740703f..9f832b8 100644
--- a/src/vue/Components/Firstrun/Steps/ServerSetup.vue
+++ b/src/vue/Components/Firstrun/Steps/ServerSetup.vue
@@ -3,9 +3,8 @@
<translate tag="h2" say="FirstRunConnectTitle"/>
<translate say="FirstRunConnectText"/>
<ul class="sever-setup-options">
- <translate tag="li" say="FirstRunConnectLink" v-if="hasLinkHandler"/>
- <translate tag="li" say="FirstRunConnectScan" v-if="hasLinkHandler"/>
- <translate tag="li" class="link" say="FirstRunConnectScanChrome" v-if="!hasLinkHandler" @click="scanQr"/>
+ <translate tag="li" say="FirstRunConnectLink" />
+ <translate tag="li" say="FirstRunConnectScan" />
<translate tag="li" class="link" say="FirstRunConnectManual" @click="openSettings"/>
</ul>
<button-field value="FirstRunConnectScanButton" @click="scanQr"/>
@@ -22,14 +21,6 @@
export default {
components: {ButtonField, Translate},
- data() {
- return {
- hasLinkHandler: SystemService.hasProtocolHandlers()
- };
- },
-
- computed: {},
-
methods: {
scanQr() {
MessageService.send({type: 'passlink.open', payload: {action: 'scan-qr'}})