aboutsummaryrefslogtreecommitdiffstats
path: root/extension/src/prompt.js
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/prompt.js')
-rw-r--r--extension/src/prompt.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/extension/src/prompt.js b/extension/src/prompt.js
new file mode 100644
index 0000000..6637f70
--- /dev/null
+++ b/extension/src/prompt.js
@@ -0,0 +1,20 @@
+// The one question a site ever gets asked: may it use the key (or the
+// wallet)? "Always allow" is remembered; the site is not asked again.
+const q = new URLSearchParams(location.search);
+const origin = q.get('origin') || '';
+const kind = q.get('kind') === 'pay' ? 'pay' : 'sign';
+const $ = (id) => document.getElementById(id);
+$('origin').textContent = origin.replace(/^https:\/\//, '');
+$('what').textContent = kind === 'pay' ? 'Let this site use your wallet?' : 'Let this site use your nostr key?';
+$('detail').textContent = kind === 'pay'
+ ? 'It will be able to see your balance, create invoices and send payments without asking, within the limit you set on the wallet connection.'
+ : 'It will be able to see your public key, sign as you and read your private messages, without asking again.';
+const answer = async (choice) => {
+ for (const b of document.querySelectorAll('button')) b.disabled = true;
+ await chrome.runtime.sendMessage({ type: 'answer', id: q.get('id'), origin, kind, choice });
+ window.close();
+};
+$('allow').onclick = () => answer('always');
+$('deny').onclick = () => answer('deny');
+$('never').onclick = () => answer('never');
+$('allow').focus();