Skip to content

Commit fba8738

Browse files
committed
prompt user on non-whitelisted hosts
Maintaining a whitelist in the binary does not scale and might put off third party devs. For a host that is not in the whitelist, we instead prompt the user if they want to accept the connection. Since we already run a server, we simply launch the browser on confirmation page served by our server. It is a bit weird UX, but it was the easiest solution I could find that works everywhere. Alternatives considered: - native dialogs using rfd - unfortunately does not work on macOS as the main process is windowless - native dialogs using SDL: looks extremely ugly, hard to figure out deployment - use Rust's Tauri or Qt or similar for native UIs: hard to deploy
1 parent 7d7141c commit fba8738

File tree

4 files changed

+409
-30
lines changed

4 files changed

+409
-30
lines changed

Cargo.lock

Lines changed: 201 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bitbox-bridge/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77
license = "Apache-2.0"
88

99
[dependencies]
10+
webbrowser = "1.0"
1011
env_logger = "0.11"
1112
futures = { workspace = true }
1213
futures-util = { workspace = true }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>BitBoxBridge</title>
6+
</head>
7+
<body>
8+
<h1>BitBoxBridge</h1>
9+
<p>{{ message }}</p>
10+
<button onclick="sendResponse(false)">Reject</button>
11+
<button onclick="sendResponse(true)">Accept</button>
12+
<script>
13+
function sendResponse(userChoice) {
14+
fetch(`/confirm/response/{{ counter }}/${userChoice}`, { method: 'POST' })
15+
.then(() => window.close())
16+
.catch(err => console.error('Error sending response:', err));
17+
}
18+
</script>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)