diff --git a/src/app/components/ContentMessage/index.tsx b/src/app/components/ContentMessage/index.tsx index 0de09f5b92..c6fb17e4ca 100644 --- a/src/app/components/ContentMessage/index.tsx +++ b/src/app/components/ContentMessage/index.tsx @@ -1,5 +1,5 @@ type Props = { - heading: string; + heading: string | React.ReactNode; content: string; }; diff --git a/src/app/router/Prompt/Prompt.tsx b/src/app/router/Prompt/Prompt.tsx index 6e6f1688be..090d637b58 100644 --- a/src/app/router/Prompt/Prompt.tsx +++ b/src/app/router/Prompt/Prompt.tsx @@ -28,7 +28,8 @@ import LiquidEnable from "~/app/screens/Enable/LiquidEnable"; import NostrEnable from "~/app/screens/Enable/NostrEnable"; import WebbtcEnable from "~/app/screens/Enable/WebbtcEnable"; import WeblnEnable from "~/app/screens/Enable/WeblnEnable"; -import NostrConfirmEncryptOrDecrypt from "~/app/screens/Nostr/ConfirmEncryptOrDecrypt"; +import NostrConfirmDecrypt from "~/app/screens/Nostr/ConfirmDecrypt"; +import NostrConfirmEncrypt from "~/app/screens/Nostr/ConfirmEncrypt"; import type { NavigationState, OriginData } from "~/types"; // Parse out the parameters from the querystring. @@ -124,8 +125,12 @@ function Prompt() { element={} /> } + path="public/nostr/confirmEncrypt" + element={} + /> + } /> ) { + event.preventDefault(); + msg.error(USER_REJECTED_ERROR); + } + + async function block(event: React.MouseEvent) { + event.preventDefault(); + await msg.request("addBlocklist", { + domain: origin.domain, + host: origin.host, + }); + alert(`Added ${origin.host} to the blocklist, please reload the website`); + msg.error(USER_REJECTED_ERROR); + } + + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + + return ( +
+ +
+ + +
+

{t("allow", { host: origin.host })}

+

+ + {tPermissions("nostr.nip04decrypt")} +

+
+ +
+
+ { + setRememberPermission(event.target.checked); + }} + /> + +
+ + + {t("block_and_ignore", { host: origin.host })} + +
+
+
+
+ ); +} + +export default NostrConfirmDecrypt; diff --git a/src/app/screens/Nostr/ConfirmEncryptOrDecrypt.tsx b/src/app/screens/Nostr/ConfirmEncrypt.tsx similarity index 89% rename from src/app/screens/Nostr/ConfirmEncryptOrDecrypt.tsx rename to src/app/screens/Nostr/ConfirmEncrypt.tsx index c5eaf44329..7708df074b 100644 --- a/src/app/screens/Nostr/ConfirmEncryptOrDecrypt.tsx +++ b/src/app/screens/Nostr/ConfirmEncrypt.tsx @@ -12,16 +12,16 @@ import { USER_REJECTED_ERROR } from "~/common/constants"; import msg from "~/common/lib/msg"; import { OriginData } from "~/types"; -function NostrConfirmEncryptOrDecrypt() { +function NostrConfirmEncrypt() { const { t } = useTranslation("translation", { keyPrefix: "nostr", }); const { t: tCommon } = useTranslation("common"); const navState = useNavigationState(); const origin = navState.origin as OriginData; - const action = navState.args?.encryptOrDecrypt?.action; - const peer = navState.args?.encryptOrDecrypt?.peer; - const message = navState.args?.encryptOrDecrypt?.message; + + const recipientNpub = navState.args?.encrypt.recipientNpub; + const message = navState.args?.encrypt.message; const [loading, setLoading] = useState(false); const [showDetails, setShowDetails] = useState(false); @@ -75,12 +75,9 @@ function NostrConfirmEncryptOrDecrypt() { /> {message && ( )} @@ -91,7 +88,7 @@ function NostrConfirmEncryptOrDecrypt() { {showDetails && (
- {t("peer")}: {peer} + {t("recipient")}: {recipientNpub}
)} @@ -132,4 +129,4 @@ function NostrConfirmEncryptOrDecrypt() { ); } -export default NostrConfirmEncryptOrDecrypt; +export default NostrConfirmEncrypt; diff --git a/src/app/screens/Nostr/ConfirmSignMessage.tsx b/src/app/screens/Nostr/ConfirmSignMessage.tsx index 8c72c34a96..8607bcfca5 100644 --- a/src/app/screens/Nostr/ConfirmSignMessage.tsx +++ b/src/app/screens/Nostr/ConfirmSignMessage.tsx @@ -5,7 +5,7 @@ import PublisherCard from "@components/PublisherCard"; import SuccessMessage from "@components/SuccessMessage"; import Checkbox from "@components/form/Checkbox"; import { useState } from "react"; -import { useTranslation } from "react-i18next"; +import { Trans, useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import Hyperlink from "~/app/components/Hyperlink"; import ScreenHeader from "~/app/components/ScreenHeader"; @@ -84,12 +84,22 @@ function ConfirmSignMessage() { url={origin.host} /> ]} + /> + } content={event.content || ""} />
diff --git a/src/extension/background-script/actions/nostr/decryptOrPrompt.ts b/src/extension/background-script/actions/nostr/decryptOrPrompt.ts index 6e9c211eb9..b6e0e54136 100644 --- a/src/extension/background-script/actions/nostr/decryptOrPrompt.ts +++ b/src/extension/background-script/actions/nostr/decryptOrPrompt.ts @@ -32,14 +32,7 @@ const decryptOrPrompt = async (message: MessageDecryptGet, sender: Sender) => { rememberPermission: boolean; }>({ ...message, - action: "public/nostr/confirmEncryptOrDecrypt", - args: { - encryptOrDecrypt: { - action: "decrypt", - peer: message.args.peer, - message: message.args.ciphertext, - }, - }, + action: "public/nostr/confirmDecrypt", }); // add permission to db only if user decided to always allow this request diff --git a/src/extension/background-script/actions/nostr/encryptOrPrompt.ts b/src/extension/background-script/actions/nostr/encryptOrPrompt.ts index 512a359a42..2eb7800697 100644 --- a/src/extension/background-script/actions/nostr/encryptOrPrompt.ts +++ b/src/extension/background-script/actions/nostr/encryptOrPrompt.ts @@ -1,4 +1,5 @@ import { USER_REJECTED_ERROR } from "~/common/constants"; +import nostr from "~/common/lib/nostr"; import utils from "~/common/lib/utils"; import { getHostFromSender } from "~/common/utils/helpers"; import { @@ -30,11 +31,10 @@ const encryptOrPrompt = async (message: MessageEncryptGet, sender: Sender) => { rememberPermission: boolean; }>({ ...message, - action: "public/nostr/confirmEncryptOrDecrypt", + action: "public/nostr/confirmEncrypt", args: { - encryptOrDecrypt: { - action: "encrypt", - peer: message.args.peer, + encrypt: { + recipientNpub: nostr.hexToNip19(message.args.peer, "npub"), message: message.args.plaintext, }, }, diff --git a/src/i18n/locales/de/translation.json b/src/i18n/locales/de/translation.json index 2d4a7456da..44f72a70f4 100644 --- a/src/i18n/locales/de/translation.json +++ b/src/i18n/locales/de/translation.json @@ -654,7 +654,7 @@ "unknown": "kind {{kind}}" }, "peer": "Peer", - "allow_sign_event": "Erlaube {{Gastgeber}}, ein {{kind}} Ereignis zu unterzeichnen", + "allow_sign_event": "Erlaube {{Gastgeber}}, ein <0>{{kind}} Ereignis zu unterzeichnen", "allow_encrypt": "Erlaube {{host}}, die Nachricht zu verschlüsseln:", "allow_decrypt": "Erlaube {{host}}, die Nachricht zu entschlüsseln:" }, diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index f4632e99c0..54b91d50f2 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -941,14 +941,13 @@ "allow": "Allow this website to:", "content": "This website asks you to sign:", "allow_sign": "Allow {{host}} to sign:", - "allow_sign_event": "Allow {{host}} to sign a {{kind}} event", + "allow_sign_event": "Allow {{host}} to sign a <0>{{kind}} event", "allow_encrypt": "Allow {{host}} to encrypt the message:", - "allow_decrypt": "Allow {{host}} to decrypt the message:", "view_details": "View details", "hide_details": "Hide details", "block_and_ignore": "Block and ignore {{host}}", "block_added": "Added {{host}} to the blocklist, please reload the website.", - "peer": "Peer", + "recipient": "Recipient", "kinds": { "unknown": "kind {{kind}}", "0": "metadata", @@ -1199,7 +1198,6 @@ "nostr": { "getpublickey": "Read your public key", "signmessage": "Sign message with your key", - "nip04encrypt": "Encrypt data", "nip04decrypt": "Decrypt data" }, "bitcoin": { diff --git a/src/i18n/locales/pt_BR/translation.json b/src/i18n/locales/pt_BR/translation.json index 71f898a0ad..7fea24e302 100644 --- a/src/i18n/locales/pt_BR/translation.json +++ b/src/i18n/locales/pt_BR/translation.json @@ -693,7 +693,7 @@ "9735": "zap", "unknown": "tipo {{kind}}" }, - "allow_sign_event": "Permitir {{host}} assinar um evento {{kind}}", + "allow_sign_event": "Permitir {{host}} assinar um evento <0>{{kind}}", "allow_encrypt": "Permitir {{host}} criptografar a mensagem:", "allow_decrypt": "Permitir {{host}} descriptografar a mensagem:" }, diff --git a/src/types.ts b/src/types.ts index 66626e6002..594e7e246a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -170,9 +170,8 @@ export type NavigationState = { sigHash?: string; // nostr - encryptOrDecrypt?: { - action: "encrypt" | "decrypt"; - peer: string; + encrypt: { + recipientNpub: string; message: string; };