diff --git a/packages/react-chat-example/src/index.tsx b/packages/react-chat-example/src/index.tsx index 1cdd097f..fcde8bf3 100644 --- a/packages/react-chat-example/src/index.tsx +++ b/packages/react-chat-example/src/index.tsx @@ -78,6 +78,7 @@ function DragDiv() { config={{ communityKey: process.env.COMMUNITY_KEY ?? "", environment: process.env.ENV ?? "", + dappUrl: "https://0.0.0.0:8080", }} fetchMetadata={fetchMetadata} /> diff --git a/packages/react-chat/src/components/Modals/WalletModal.tsx b/packages/react-chat/src/components/Modals/WalletModal.tsx index 936a3768..bc1e0812 100644 --- a/packages/react-chat/src/components/Modals/WalletModal.tsx +++ b/packages/react-chat/src/components/Modals/WalletModal.tsx @@ -3,6 +3,7 @@ import { genPrivateKeyWithEntropy } from "@waku/status-communities/dist/cjs/util import React, { useCallback } from "react"; import styled from "styled-components"; +import { useConfig } from "../../contexts/configProvider"; import { useSetIdentity, useSetWalletIdentity, @@ -29,9 +30,14 @@ export function WalletModal() { const { setModal: setWalleConnectModal } = useModal(WalletConnectModalName); const { setModal: setCoinbaseModal } = useModal(CoinbaseModalName); const { messenger } = useMessengerContext(); + const { dappUrl } = useConfig(); const handleMetamaskClick = useCallback(async () => { const ethereum = (window as any)?.ethereum as any | undefined; + if (document.location.origin !== dappUrl) { + alert("You are not signing in from correct url!"); + return; + } if (ethereum && messenger) { try { if (ethereum?.isMetaMask) { @@ -47,7 +53,7 @@ export function WalletModal() { }, message: { action: "Status Chat Key", - onlySignOn: "https://auth.status.im/", + onlySignOn: dappUrl, message: "I'm aware that i am signing message that creates a private chat key for status communicator. And I have double checked everything is fine.", }, diff --git a/packages/react-chat/src/contexts/configProvider.tsx b/packages/react-chat/src/contexts/configProvider.tsx index 22debb5c..8053e427 100644 --- a/packages/react-chat/src/contexts/configProvider.tsx +++ b/packages/react-chat/src/contexts/configProvider.tsx @@ -3,11 +3,13 @@ import React, { createContext, useContext } from "react"; export type ConfigType = { communityKey: string; environment: string; + dappUrl: string; }; const ConfigContext = createContext({ communityKey: "", environment: "production", + dappUrl: "", }); export function useConfig() {