diff --git a/demo/nextjs-ssr-app/components/Main.tsx b/demo/nextjs-ssr-app/components/Main.tsx index d8e69aad4..5465858b6 100644 --- a/demo/nextjs-ssr-app/components/Main.tsx +++ b/demo/nextjs-ssr-app/components/Main.tsx @@ -3,7 +3,7 @@ import { useCheckout, useEnableMFA, - useIdentityToken, + useAuthTokenInfo, useManageMFA, useWalletConnectScanner, useWalletUI, @@ -31,7 +31,7 @@ const Main = () => { const { showCheckout, loading: isCheckoutLoading, error: checkoutError } = useCheckout(); const { showWalletConnectScanner, loading: isWalletConnectScannerLoading, error: walletConnectScannerError } = useWalletConnectScanner(); const { showWalletUI, loading: isWalletUILoading, error: walletUIError } = useWalletUI(); - const { token, loading: isUserTokenLoading, error: userTokenError, getIdentityToken } = useIdentityToken(); + const { token, loading: isUserTokenLoading, error: userTokenError, getAuthTokenInfo } = useAuthTokenInfo(); console.log("isConnected", isConnected, balance); @@ -59,7 +59,7 @@ const Main = () => { {isUserTokenLoading ? (

Authenticating...

) : ( - )} diff --git a/demo/react-app-no-modal/src/App.tsx b/demo/react-app-no-modal/src/App.tsx index 9a82e0d2c..b753cc40f 100644 --- a/demo/react-app-no-modal/src/App.tsx +++ b/demo/react-app-no-modal/src/App.tsx @@ -44,12 +44,12 @@ function App() { setProvider(web3authProvider); }; - const getIdentityToken = async () => { + const getAuthTokenInfo = async () => { if (!web3auth) { uiConsole("web3auth not initialized yet"); return; } - const idToken = await web3auth.getIdentityToken(); + const idToken = await web3auth.getAuthTokenInfo(); uiConsole(idToken); }; @@ -156,7 +156,7 @@ function App() {
-
diff --git a/demo/vue-app-new/package-lock.json b/demo/vue-app-new/package-lock.json index 908e9a491..31952c82d 100644 --- a/demo/vue-app-new/package-lock.json +++ b/demo/vue-app-new/package-lock.json @@ -23,6 +23,7 @@ "@web3auth/sign-in-with-web3": "^6.1.0", "@web3auth/ws-embed": "file:../../web3auth-ws-embed-5.6.5.tgz", "ethers": "^6.16.0", + "ox": "^0.11.3", "petite-vue-i18n": "^11.3.0", "react": "^19.2.4", "react-dom": "^19.2.4", @@ -51,7 +52,7 @@ "version": "10.15.0", "dependencies": { "@hcaptcha/react-hcaptcha": "^2.0.2", - "@toruslabs/base-controllers": "^9.4.1", + "@toruslabs/base-controllers": "^9.5.0", "@toruslabs/http-helpers": "^9.0.0", "@web3auth/auth": "^11.4.2", "@web3auth/no-modal": "^10.15.0", @@ -143,21 +144,22 @@ "@solana/client": "^1.7.0", "@solana/kit": "^6.5.0", "@solana/wallet-standard-features": "^1.3.0", - "@toruslabs/base-controllers": "^9.4.1", + "@toruslabs/base-controllers": "^9.5.0", "@toruslabs/constants": "^16.1.1", "@toruslabs/eccrypto": "^7.0.0", - "@toruslabs/ethereum-controllers": "^9.4.1", + "@toruslabs/ethereum-controllers": "^9.5.0", "@toruslabs/http-helpers": "^9.0.0", "@toruslabs/loglevel-sentry": "^9.0.0", "@toruslabs/metadata-helpers": "^8.2.0", "@toruslabs/secure-pub-sub": "4.3.0", + "@toruslabs/session-manager": "^5.6.0", "@wallet-standard/app": "^1.1.0", "@wallet-standard/base": "^1.1.0", "@wallet-standard/features": "^1.1.0", "@walletconnect/sign-client": "^2.23.8", "@walletconnect/types": "^2.23.8", "@walletconnect/utils": "^2.23.8", - "@web3auth/auth": "^11.4.2", + "@web3auth/auth": "^11.4.3", "@web3auth/ws-embed": "file:../../web3auth-ws-embed-5.6.5.tgz", "bignumber.js": "~9.3.1", "deepmerge": "^4.3.1", @@ -8777,8 +8779,6 @@ } ], "license": "MIT", - "optional": true, - "peer": true, "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", @@ -8802,17 +8802,13 @@ "version": "1.11.1", "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz", "integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==", - "license": "MIT", - "optional": true, - "peer": true + "license": "MIT" }, "node_modules/ox/node_modules/@noble/curves": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", "license": "MIT", - "optional": true, - "peer": true, "dependencies": { "@noble/hashes": "1.8.0" }, diff --git a/demo/vue-app-new/package.json b/demo/vue-app-new/package.json index 60e6f8fc6..b421357f7 100644 --- a/demo/vue-app-new/package.json +++ b/demo/vue-app-new/package.json @@ -25,6 +25,7 @@ "@web3auth/sign-in-with-web3": "^6.1.0", "@web3auth/ws-embed": "file:../../web3auth-ws-embed-5.6.5.tgz", "ethers": "^6.16.0", + "ox": "^0.11.3", "petite-vue-i18n": "^11.3.0", "react": "^19.2.4", "react-dom": "^19.2.4", diff --git a/demo/vue-app-new/src/MainView.vue b/demo/vue-app-new/src/MainView.vue index 252b96138..751f35788 100644 --- a/demo/vue-app-new/src/MainView.vue +++ b/demo/vue-app-new/src/MainView.vue @@ -20,7 +20,7 @@ import { WagmiProvider } from "@web3auth/modal/vue/wagmi"; import { coinbaseConnector } from "@web3auth/no-modal/connectors/coinbase-connector"; import { computed, onBeforeMount, ref, watch } from "vue"; -import { BUILD_ENV } from "@web3auth/auth"; +import { BUILD_ENV, CookieStorage, LocalStorageAdapter, MemoryStorage, SessionStorageAdapter, type StorageConfig } from "@web3auth/auth"; import AppDashboard from "./components/AppDashboard.vue"; import AppHeader from "./components/AppHeader.vue"; import AppSettings from "./components/AppSettings.vue"; @@ -34,6 +34,22 @@ const formData = formDataStore; const externalConnectors = ref([]); +function buildStorageConfig(): StorageConfig | undefined { + const type = formData.tokenStorage; + if (type === "default") return undefined; + + const adapter = + type === "session" + ? new SessionStorageAdapter() + : type === "cookies" + ? new CookieStorage({ maxAge: 7 * 86400 }) + : type === "memory" + ? new MemoryStorage() + : new LocalStorageAdapter(); + + return { sessionId: adapter, accessToken: adapter, refreshToken: adapter, idToken: adapter }; +} + const showAAProviderSettings = computed(() => formData.chainNamespaces.includes(CHAIN_NAMESPACES.EIP155)); // Options for reinitializing the web3Auth object @@ -122,11 +138,7 @@ const options = computed((): Web3AuthOptions => { uiConfig, accountAbstractionConfig, useAAWithExternalWallet: formData.useAAWithExternalWallet, - // TODO: Add more options - // enableLogging?: boolean; - // storageType?: "session" | "local"; - // sessionTime?: number; - // useSFAKey?: boolean; + storage: buildStorageConfig(), chains, defaultChainId: formData.defaultChainId, enableLogging: true, @@ -213,6 +225,7 @@ onBeforeMount(() => { formData.defaultChainId = json.defaultChainId; formData.initialAuthenticationMode = json.initialAuthenticationMode; formData.externalWalletOnly = json.externalWalletOnly || false; + formData.tokenStorage = json.tokenStorage || "default"; } } catch (error) {} } diff --git a/demo/vue-app-new/src/components/AppDashboard.vue b/demo/vue-app-new/src/components/AppDashboard.vue index 3f0275a69..53e268789 100644 --- a/demo/vue-app-new/src/components/AppDashboard.vue +++ b/demo/vue-app-new/src/components/AppDashboard.vue @@ -6,7 +6,7 @@ import { useFunding, useReceive, useEnableMFA, - useIdentityToken, + useAuthTokenInfo, useManageMFA, useWalletConnectScanner, useWalletUI, @@ -55,7 +55,7 @@ const { showWalletConnectScanner, loading: showWalletConnectScannerLoading } = u const { showCheckout, loading: showCheckoutLoading } = useCheckout(); const { showFunding, loading: showFundingLoading } = useFunding(); const { showReceive, loading: showReceiveLoading } = useReceive(); -const { getIdentityToken, loading: getIdentityTokenLoading } = useIdentityToken(); +const { getAuthTokenInfo, loading: getAuthTokenInfoLoading } = useAuthTokenInfo(); const { status, address } = useConnection(); const { mutateAsync: signTypedDataAsync } = useSignTypedData(); const { mutateAsync: signMessageAsync } = useSignMessage(); @@ -162,8 +162,8 @@ const onGetUserInfo = async () => { printToConsole("User Info", userInfo.value); }; -const ongetIdentityToken = async () => { - const idToken = await getIdentityToken(); +const onGetAuthTokenInfo = async () => { + const idToken = await getAuthTokenInfo(); printToConsole("id token", idToken); }; @@ -492,7 +492,7 @@ const onSwitchChain = async () => { - +
EIP-5792
@@ -522,7 +522,7 @@ const onSwitchChain = async () => { - + { :label-enabled="$t('app.externalWalletOnly')" class="mb-2" /> +