From f8d7e30ed15db9880b5231413b891f6d982e3520 Mon Sep 17 00:00:00 2001 From: gacogo Date: Sat, 16 Mar 2024 16:53:27 +0300 Subject: [PATCH 1/4] 'fix(ses errors): Address SES errors Webpack and read-only property issues in dev environment as well as production environment *On dev environment * Resolves Webpack reference errors: * `ReferenceError: __webpack_require__` * `exports is not defined` and other related errors * Upon building: * Fixes read-only property error: `Cannot assign to read only property 'concat' of object '[object Object]'` * Addresses related errors as outlined in the README. --- components/common/Footer.tsx | 3 ++- components/common/Header.tsx | 3 ++- components/wallet/Wallet.tsx | 3 ++- pages/index.tsx | 5 +++-- tsconfig.json | 2 +- utils/installSesLockdown.ts | 32 ++++++++++++++++++++++---------- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/components/common/Footer.tsx b/components/common/Footer.tsx index ca89213..aa5ef6a 100644 --- a/components/common/Footer.tsx +++ b/components/common/Footer.tsx @@ -7,7 +7,8 @@ import { Text, useColorModeValue, } from "@interchain-ui/react"; -import { dependencies, products, Project } from "@/config"; +import { Project, dependencies, products } from "../../config"; +// import { dependencies, products, Project } from "@/config"; function Product({ name, desc, link }: Project) { return ( diff --git a/components/common/Header.tsx b/components/common/Header.tsx index 86ffefe..ba8dda0 100644 --- a/components/common/Header.tsx +++ b/components/common/Header.tsx @@ -7,7 +7,8 @@ import { useColorModeValue, useTheme, } from "@interchain-ui/react"; -import { dependencies } from "@/config"; +import { dependencies } from "../../config"; +// import { dependencies } from "@/config"; const stacks = ["CosmosKit", "Next.js"]; diff --git a/components/wallet/Wallet.tsx b/components/wallet/Wallet.tsx index e89efb9..9665bd7 100644 --- a/components/wallet/Wallet.tsx +++ b/components/wallet/Wallet.tsx @@ -11,7 +11,7 @@ import { chains } from 'chain-registry'; import { User } from './User'; import { Chain } from './Chain'; import { Warning } from './Warning'; -import { CHAIN_NAME, CHAIN_NAME_STORAGE_KEY } from '@/config'; +// import { CHAIN_NAME, CHAIN_NAME_STORAGE_KEY } from '@/config'; import { ButtonConnect, ButtonConnected, @@ -21,6 +21,7 @@ import { ButtonNotExist, ButtonRejected, } from './Connect'; +import { CHAIN_NAME, CHAIN_NAME_STORAGE_KEY } from '../../config'; export type WalletProps = { chainName?: string; diff --git a/pages/index.tsx b/pages/index.tsx index fa6fe9d..1c2a867 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,7 @@ import { useState } from "react"; -import { Layout, Wallet } from "@/components"; -import { CHAIN_NAME } from "@/config"; +import { CHAIN_NAME } from "../config"; +import { Layout, Wallet } from "../components"; + export default function Home() { const [chainName, setChainName] = useState(CHAIN_NAME); diff --git a/tsconfig.json b/tsconfig.json index 22140a2..b5c1f0c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,7 @@ "jsx": "preserve", "incremental": true, "paths": { - "@/*": ["*"] + "@/*": ["/*"] } }, "include": [ diff --git a/utils/installSesLockdown.ts b/utils/installSesLockdown.ts index 28c323e..b588a89 100644 --- a/utils/installSesLockdown.ts +++ b/utils/installSesLockdown.ts @@ -1,12 +1,24 @@ -import 'ses'; +let lockdownstatus = false; -const consoleTaming = - process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test' - ? 'unsafe' - : 'safe'; +// execute upon import +(async () => { + if (lockdownstatus) return; + await import("ses"); // adds lockdown, harden, and Compartment + console.log("Installing lockdown..."); + lockdown({ + errorTaming: "safe", + overrideTaming: "moderate", + consoleTaming: "unsafe", + stackFiltering: "verbose", + localeTaming: "unsafe", + }); + lockdownstatus = true; + console.log("SES lockdown installed..."); + Error.stackTraceLimit = Infinity; -lockdown({ - errorTaming: 'unsafe', - overrideTaming: 'severe', - consoleTaming, -}); + lockdownstatus = true; +})(); + +export default function initiateLockdown() { + return Promise.resolve(); +} From d04a82a80d5c9fc2ae357a041e9bc3eb618d59de Mon Sep 17 00:00:00 2001 From: gacogo Date: Sat, 16 Mar 2024 17:12:56 +0300 Subject: [PATCH 2/4] fix(typo): remove redundant lockdown = true on installLockdown.ts --- tsconfig.json | 5 +---- utils/installSesLockdown.ts | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index b5c1f0c..e68bd5a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,10 +17,7 @@ "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", - "incremental": true, - "paths": { - "@/*": ["/*"] - } + "incremental": true }, "include": [ "next-env.d.ts", diff --git a/utils/installSesLockdown.ts b/utils/installSesLockdown.ts index b588a89..b425e67 100644 --- a/utils/installSesLockdown.ts +++ b/utils/installSesLockdown.ts @@ -12,7 +12,6 @@ let lockdownstatus = false; stackFiltering: "verbose", localeTaming: "unsafe", }); - lockdownstatus = true; console.log("SES lockdown installed..."); Error.stackTraceLimit = Infinity; From f72223e517996b89eeb77a01420ace05dc7c1a51 Mon Sep 17 00:00:00 2001 From: gacogo Date: Sat, 16 Mar 2024 17:21:43 +0300 Subject: [PATCH 3/4] refactor(installLockdown.ts): Works without lockdown status - removed global state and checks for the same --- utils/installSesLockdown.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/utils/installSesLockdown.ts b/utils/installSesLockdown.ts index b425e67..2154cc7 100644 --- a/utils/installSesLockdown.ts +++ b/utils/installSesLockdown.ts @@ -2,7 +2,6 @@ let lockdownstatus = false; // execute upon import (async () => { - if (lockdownstatus) return; await import("ses"); // adds lockdown, harden, and Compartment console.log("Installing lockdown..."); lockdown({ @@ -14,8 +13,6 @@ let lockdownstatus = false; }); console.log("SES lockdown installed..."); Error.stackTraceLimit = Infinity; - - lockdownstatus = true; })(); export default function initiateLockdown() { From 156ceb3d9148a9ad8ca490afca40561c9e9a37b2 Mon Sep 17 00:00:00 2001 From: gacogo Date: Sat, 16 Mar 2024 18:09:38 +0300 Subject: [PATCH 4/4] fix(installSesLockdown.ts): update lockdown args, remove lockdown status variable --- utils/installSesLockdown.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/utils/installSesLockdown.ts b/utils/installSesLockdown.ts index 2154cc7..6e38729 100644 --- a/utils/installSesLockdown.ts +++ b/utils/installSesLockdown.ts @@ -1,18 +1,19 @@ -let lockdownstatus = false; - // execute upon import (async () => { await import("ses"); // adds lockdown, harden, and Compartment - console.log("Installing lockdown..."); + const consoleTaming = + process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test" + ? "unsafe" + : "safe"; + lockdown({ - errorTaming: "safe", - overrideTaming: "moderate", - consoleTaming: "unsafe", - stackFiltering: "verbose", - localeTaming: "unsafe", + errorTaming: "unsafe", + overrideTaming: "severe", + consoleTaming, }); - console.log("SES lockdown installed..."); + Error.stackTraceLimit = Infinity; + })(); export default function initiateLockdown() {