Fix Sign Message copy button in non-secure contexts - #770
Open
dmnyc wants to merge 1 commit into
Open
Conversation
The Copy button called navigator.clipboard.writeText directly, which is undefined when ThunderHub is served over plain HTTP or a LAN/Tor address (a non-secure context), so clicking Copy silently did nothing.
Add a fallback that copies via a temporary textarea and document.execCommand('copy') when the async Clipboard API is unavailable, and surface a success or error toast in both code paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the Sign Message tool, the Copy button does nothing when ThunderHub is accessed over a non-secure context — plain HTTP, or a LAN /
.onion/ Tailscale address. In those contextsnavigator.clipboardisundefined, so the existing handler:throws immediately, and because there is no
.catch, it fails silently with no feedback. Since most self-hosted ThunderHub instances are reached over exactly these non-HTTPS addresses, the button is effectively broken for a large share of users.Fix
Extract the copy handler and add a fallback: use the async Clipboard API when it is available in a secure context, otherwise fall back to a temporary
<textarea>+document.execCommand('copy'). Both paths surface a success toast, and the handler is wrapped in try/catch so a failure shows an error toast instead of silently doing nothing.Testing
lncli verifymessage(valid: true).