From 9c94efd3dd1d1c9acbff83f6c42795ccda66891e Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 8 Dec 2022 11:15:28 +0000 Subject: [PATCH] handle open dev tool showing a warning --- packages/app/src/App.jsx | 20 ++++++++++++++++--- .../app/src/utils/handleOpenDevTools/index.js | 17 ++++++++++++++++ packages/app/src/utils/index.js | 3 ++- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 packages/app/src/utils/handleOpenDevTools/index.js diff --git a/packages/app/src/App.jsx b/packages/app/src/App.jsx index f5af5326..8349212d 100755 --- a/packages/app/src/App.jsx +++ b/packages/app/src/App.jsx @@ -271,6 +271,18 @@ class App extends React.Component { {(t) => t("You have been disconnected from the server, trying to reconnect.")} }) + }, + "devtool-opened": () => { + // show warning + antd.notification.open({ + message: + {(t) => t("Devtool opened")} + , + description: + {(t) => t("You have opened the devtool for the first time, please be aware that this is a security risk and you should close it as soon as possible.")} + , + icon: , + }) } } @@ -452,12 +464,14 @@ class App extends React.Component { }, () => { App.publicMethods.openCreator() }) - + app.eventBus.emit("app.initialization.start") - + await this.initialization() - + app.eventBus.emit("app.initialization.finish") + + Utils.handleOpenDevTools() } initialization = async () => { diff --git a/packages/app/src/utils/handleOpenDevTools/index.js b/packages/app/src/utils/handleOpenDevTools/index.js new file mode 100644 index 00000000..f717e3c8 --- /dev/null +++ b/packages/app/src/utils/handleOpenDevTools/index.js @@ -0,0 +1,17 @@ +export default () => { + var devtools = function () { } + + devtools.toString = function () { + console.log( + "%cStop!\n", + "color: red; font-size: 40px; font-weight: bold;", + ) + + console.log( + `%cYou have opened the devtools. This is a browser feature intended for developers. If someone told you to copy and paste something here to enable a feature or "hack" someone's account, it is a scam and will give them access to your account and data.`, + "color: black; font-size: 20px; font-weight: bold;" + ) + } + + console.log('%c', devtools) +} \ No newline at end of file diff --git a/packages/app/src/utils/index.js b/packages/app/src/utils/index.js index 1d545630..7d692c95 100755 --- a/packages/app/src/utils/index.js +++ b/packages/app/src/utils/index.js @@ -4,4 +4,5 @@ export { default as cursorPosition } from "./cursorPosition" export { default as getBase64 } from "./getBase64" export { default as Haptics } from "./haptics" export { default as processString } from "./processString" -export { default as deleteInternalStorage } from "./deleteInternalStorage" \ No newline at end of file +export { default as deleteInternalStorage } from "./deleteInternalStorage" +export { default as handleOpenDevTools } from "./handleOpenDevTools" \ No newline at end of file