Skip to content

Fix Sign Message copy button in non-secure contexts - #770

Open
dmnyc wants to merge 1 commit into
apotdevin:masterfrom
dmnyc:fix/sign-message-copy-clipboard
Open

Fix Sign Message copy button in non-secure contexts#770
dmnyc wants to merge 1 commit into
apotdevin:masterfrom
dmnyc:fix/sign-message-copy-clipboard

Conversation

@dmnyc

@dmnyc dmnyc commented Jul 10, 2026

Copy link
Copy Markdown

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 contexts navigator.clipboard is undefined, so the existing handler:

navigator.clipboard.writeText(signed).then(() => toast.success('Signature Copied'))

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

  • Built and ran locally against a live LND node.
  • Signed a message and clicked Copy over a non-HTTPS address (previously a no-op) — the success toast now appears and the clipboard is populated.
  • Verified the copied signature is complete and valid via lncli verifymessage (valid: true).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant