Linux + iPhone Continuity / iMessage / SMS
fix up installation
Zack Bartel07f3dfae3a58
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 03d48fc..3e2312a 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -50,8 +50,13 @@ endif()# Browser Extension Host manifest generationinclude(GNUInstallDirs)configure_file(- "${CMAKE_CURRENT_SOURCE_DIR}/extension/host/com.tether.extension.json.in"- "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.json"+ "${CMAKE_CURRENT_SOURCE_DIR}/extension/host/com.tether.extension.chrome.json.in"+ "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.chrome.json"+ @ONLY+)+configure_file(+ "${CMAKE_CURRENT_SOURCE_DIR}/extension/host/com.tether.extension.mozilla.json.in"+ "${CMAKE_CURRENT_BINARY_DIR}/com.tether.extension.mozilla.json"@ONLY)diff --git a/extension/host/com.tether.extension.json.in b/extension/host/com.tether.extension.chrome.json.insimilarity index 68%rename from extension/host/com.tether.extension.json.inrename to extension/host/com.tether.extension.chrome.json.inindex c53975f..e2f6c4e 100644--- a/extension/host/com.tether.extension.json.in+++ b/extension/host/com.tether.extension.chrome.json.in@@ -4,7 +4,6 @@"path": "@CMAKE_INSTALL_FULL_BINDIR@/tether-native-host","type": "stdio","allowed_origins": [- "chrome-extension://<EXTENSION-ID-HERE>/",- "moz-extension://<EXTENSION-ID-HERE>/"+ "chrome-extension://<EXTENSION-ID-HERE>/"]}diff --git a/extension/host/com.tether.extension.mozilla.json.in b/extension/host/com.tether.extension.mozilla.json.innew file mode 100644index 0000000..93c94a6--- /dev/null+++ b/extension/host/com.tether.extension.mozilla.json.in@@ -0,0 +1,10 @@+{+ "name": "com.tether.extension",+ "description": "Tether Native Messaging Host",+ "path": "@CMAKE_INSTALL_FULL_BINDIR@/tether-native-host",+ "type": "stdio",+ "allowed_extensions": [+ "[email protected]",+ ]+}diff --git a/extension/host/tether-native-host b/extension/host/tether-native-hostindex 47f3b56..9aeb544 100755--- a/extension/host/tether-native-host+++ b/extension/host/tether-native-host@@ -2,4 +2,11 @@# Wrapper script to run tether in native messaging proxy mode# The browser will execute this script via the com.tether.extension.json manifest.-exec tether --native-host+if [ -x "/usr/local/bin/tether" ]; then+ exec /usr/local/bin/tether --native-host 2>> /tmp/tether-native.log+elif [ -x "/usr/bin/tether" ]; then+ exec /usr/bin/tether --native-host 2>> /tmp/tether-native.log+else+ # Fallback to whatever is in the sandbox's $PATH+ exec tether --native-host 2>> /tmp/tether-native.log+fidiff --git a/extension/manifest-browser.json b/extension/manifest-browser.jsonindex 5c8921b..324540d 100644--- a/extension/manifest-browser.json+++ b/extension/manifest-browser.json@@ -1,47 +1,51 @@{- "manifest_version": 3,- "name": "Tether Browser Extension",- "version": "1.0.0",- "description": "Autofills OTPs on webpages using Tether daemon",- "permissions": [- "nativeMessaging",- "activeTab",- "scripting",- "storage"- ],- "host_permissions": [- "<all_urls>"- ],- "browser_specific_settings": {- "gecko": {- "id": "[email protected]",- "strict_min_version": "109.0"+ "manifest_version": 3,+ "name": "Tether Browser Extension",+ "version": "1.0.0",+ "description": "Autofills OTPs on webpages using Tether daemon",+ "permissions": [+ "nativeMessaging",+ "activeTab",+ "scripting",+ "storage"+ ],+ "host_permissions": [+ "<all_urls>"+ ],+ "browser_specific_settings": {+ "gecko": {+ "id": "[email protected]",+ "strict_min_version": "109.0"+ }+ },+ "background": {+ "service_worker": "src/background/background.js",+ "scripts": [+ "src/background/background.js"+ ]+ },+ "content_scripts": [+ {+ "matches": [+ "<all_urls>"+ ],+ "js": [+ "src/content/autofill.js"+ ],+ "run_at": "document_idle"+ }+ ],+ "action": {+ "default_popup": "popup/index.html",+ "default_icon": {+ "16": "icons/icon16.png",+ "48": "icons/icon48.png",+ "128": "icons/icon128.png"+ }+ },+ "icons": {+ "16": "icons/icon16.png",+ "48": "icons/icon48.png",+ "128": "icons/icon128.png"}- },- "background": {- "service_worker": "src/background/background.js",- "scripts": [- "src/background/background.js"- ]- },- "content_scripts": [- {- "matches": ["<all_urls>"],- "js": ["src/content/autofill.js"],- "run_at": "document_idle"- }- ],- "action": {- "default_popup": "popup/index.html",- "default_icon": {- "16": "icons/icon16.png",- "48": "icons/icon48.png",- "128": "icons/icon128.png"- }- },- "icons": {- "16": "icons/icon16.png",- "48": "icons/icon48.png",- "128": "icons/icon128.png"- }}diff --git a/extension/manifest-mail.json b/extension/manifest-mail.jsonindex 03c8784..7d8b7e9 100644--- a/extension/manifest-mail.json+++ b/extension/manifest-mail.json@@ -1,33 +1,36 @@{- "manifest_version": 2,- "name": "Tether Mail Extension",- "version": "1.0.0",- "description": "Extracts OTPs from emails for Tether daemon",- "browser_specific_settings": {- "gecko": {- "id": "[email protected]",- "strict_min_version": "115.0"+ "manifest_version": 2,+ "name": "Tether Mail Extension",+ "version": "1.0.0",+ "description": "Extracts OTPs from emails for Tether daemon",+ "browser_specific_settings": {+ "gecko": {+ "id": "[email protected]",+ "strict_min_version": "115.0"+ }+ },+ "permissions": [+ "nativeMessaging",+ "messagesRead",+ "storage"+ ],+ "background": {+ "scripts": [+ "src/background/background.js",+ "src/mail/extractor.js"+ ]+ },+ "browser_action": {+ "default_popup": "popup/index.html",+ "default_icon": {+ "16": "icons/icon16.png",+ "48": "icons/icon48.png",+ "128": "icons/icon128.png"+ }+ },+ "icons": {+ "16": "icons/icon16.png",+ "48": "icons/icon48.png",+ "128": "icons/icon128.png"}- },- "permissions": [- "nativeMessaging",- "messagesRead",- "storage"- ],- "background": {- "scripts": ["src/background/background.js", "src/mail/extractor.js"]- },- "browser_action": {- "default_popup": "popup/index.html",- "default_icon": {- "16": "icons/icon16.png",- "48": "icons/icon48.png",- "128": "icons/icon128.png"- }- },- "icons": {- "16": "icons/icon16.png",- "48": "icons/icon48.png",- "128": "icons/icon128.png"- }}diff --git a/extension/src/mail/extractor.js b/extension/src/mail/extractor.jsindex 5e3efc8..814aee7 100644--- a/extension/src/mail/extractor.js+++ b/extension/src/mail/extractor.js@@ -4,7 +4,9 @@// This example assumes Manifest V2/V3 background script using the WebExtension Mail APIs// (messenger.messages, messenger.mailTabs)-import { sendToNativeHost } from '../shared/native.js';+import { connectToNativeHost, sendToNativeHost } from '../shared/native.js';++connectToNativeHost();if (typeof messenger !== 'undefined') {console.log("Tether Mail Extractor loaded in Thunderbird/Betterbird");diff --git a/extension/src/shared/native.js b/extension/src/shared/native.jsindex f0f60c5..e6d14bf 100644--- a/extension/src/shared/native.js+++ b/extension/src/shared/native.js@@ -17,10 +17,17 @@ export function connectToNativeHost() {handleNativeMessage(message);});- port.onDisconnect.addListener(() => {- console.log("Disconnected from Tether daemon");+ port.onDisconnect.addListener((p) => {+ let errorMsg = "unknown reason";+ if (p.error) {+ errorMsg = p.error.message;+ } else if (typeof browser !== 'undefined' && browser.runtime.lastError) {+ errorMsg = browser.runtime.lastError.message;+ } else if (typeof chrome !== 'undefined' && chrome.runtime.lastError) {+ errorMsg = chrome.runtime.lastError.message;+ }+ console.log("Disconnected from Tether daemon. Reason:", errorMsg);port = null;- // Implement reconnection logic if needed});return port;diff --git a/src/cli/main.cpp b/src/cli/main.cppindex b5c47bb..1bb4e4b 100644--- a/src/cli/main.cpp+++ b/src/cli/main.cpp@@ -7,6 +7,7 @@#include <vector>void run_native_messaging_host(tether::Client& client) {+ debug::log(INFO, "Starting Native Messaging Host loop...\n");while (true) {uint32_t length = 0;if (!std::cin.read(reinterpret_cast<char*>(&length), sizeof(length))) {