Skip to content

Linux + iPhone Continuity / iMessage / SMS

integrate ext into daemon

Zack Bartel47b092f458df
diff --git a/extension/manifest-browser.json b/extension/manifest-browser.json
index 1692b44..5c8921b 100644
--- a/extension/manifest-browser.json
+++ b/extension/manifest-browser.json
@@ -12,9 +12,17 @@
"host_permissions": [
"<all_urls>"
],
+ "browser_specific_settings": {
+ "gecko": {
+ "strict_min_version": "109.0"
+ }
+ },
"background": {
"service_worker": "src/background/background.js",
- "type": "module"
+ "scripts": [
+ "src/background/background.js"
+ ]
},
"content_scripts": [
{
diff --git a/extension/src/background/background.js b/extension/src/background/background.js
index da21517..4d5a886 100644
--- a/extension/src/background/background.js
+++ b/extension/src/background/background.js
@@ -14,7 +14,7 @@ if (typeof chrome !== 'undefined' && chrome.runtime) {
console.log("Found OTP in email, sending to Tether daemon:", request.otp);
// Send the extracted OTP to the C++ daemon
sendToNativeHost({
- type: "new_otp",
+ command: "new_otp",
otp: request.otp,
source: request.source
});
@@ -25,7 +25,7 @@ if (typeof chrome !== 'undefined' && chrome.runtime) {
console.log("Content script requesting OTP for:", request.url);
// Query the C++ daemon for an OTP
sendToNativeHost({
- type: "request_otp",
+ command: "request_otp",
url: request.url
});
sendResponse({ status: "requested" });
diff --git a/extension/src/shared/native.js b/extension/src/shared/native.js
index 20cd1be..f0f60c5 100644
--- a/extension/src/shared/native.js
+++ b/extension/src/shared/native.js
@@ -36,7 +36,7 @@ export function sendToNativeHost(message) {
function handleNativeMessage(message) {
// Dispatch native messages to other parts of the extension
- if (message.type === "otp_available") {
+ if (message.command === "otp_available") {
// Notify content scripts or popup
if (typeof chrome !== 'undefined' && chrome.tabs) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
diff --git a/src/core/src/net.cpp b/src/core/src/net.cpp
index ea1f8e9..26f2f8d 100644
--- a/src/core/src/net.cpp
+++ b/src/core/src/net.cpp
@@ -53,6 +53,7 @@ namespace tether {
static std::vector<ReceivedFileInfo> recent_received_files;
static constexpr size_t kMaxRecentReceivedFiles = 16;
static std::map<int, ConnectedClientSnapshot> connected_remote_clients;
+ static std::string g_current_otp;
void register_client_fd(int fd) { active_sessions[fd] = {fd, nullptr}; }
@@ -411,6 +412,22 @@ namespace tether {
}
continue;
}
+ } else if (j.contains("command") && j["command"] == "new_otp" && j.contains("otp")) {
+ g_current_otp = j["otp"];
+ std::string payload = "{\"status\":\"ok\"}\n";
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
+ continue;
+ } else if (j.contains("command") && j["command"] == "request_otp") {
+ nlohmann::json resp;
+ resp["command"] = "otp_available";
+ resp["otp"] = g_current_otp;
+ std::string payload = resp.dump() + "\n";
+ if (write(client_fd, payload.c_str(), payload.size()) < 0) {
+ debug::log(ERR, "net write error\n");
+ }
+ continue;
} else if (j.contains("command") && j["command"] == "file_start") {
if (broadcast_tcp_message(msg) == 0) {
nlohmann::json resp;