@@ -20,7 +20,15 @@ import { WagmiProvider } from "@web3auth/modal/vue/wagmi";
2020import { coinbaseConnector } from " @web3auth/no-modal/connectors/coinbase-connector" ;
2121import { computed , onBeforeMount , ref , watch } from " vue" ;
2222
23- import { BUILD_ENV , CookieStorage , LocalStorageAdapter , MemoryStorage , SessionStorageAdapter , type BUILD_ENV_TYPE , type StorageConfig } from " @web3auth/auth" ;
23+ import {
24+ BUILD_ENV ,
25+ CookieStorage ,
26+ LocalStorageAdapter ,
27+ MemoryStorage ,
28+ SessionStorageAdapter ,
29+ type BUILD_ENV_TYPE ,
30+ type StorageConfig ,
31+ } from " @web3auth/auth" ;
2432import AppDashboard from " ./components/AppDashboard.vue" ;
2533import AppHeader from " ./components/AppHeader.vue" ;
2634import AppSettings from " ./components/AppSettings.vue" ;
@@ -34,14 +42,10 @@ const formData = formDataStore;
3442
3543const externalConnectors = ref <ConnectorFn []>([]);
3644const buildEnvValues = new Set <BUILD_ENV_TYPE >(Object .values (BUILD_ENV ));
37-
38- function resolveAuthBuildEnv(): BUILD_ENV_TYPE {
39- const envValue = import .meta .env .VITE_APP_AUTH_BUILD_ENV ;
40- if (envValue && buildEnvValues .has (envValue as BUILD_ENV_TYPE )) {
41- return envValue as BUILD_ENV_TYPE ;
42- }
43-
44- return import .meta .env .DEV ? BUILD_ENV .TESTING : BUILD_ENV .PRODUCTION ;
45+ const envValue = import .meta .env .VITE_APP_AUTH_BUILD_ENV ;
46+ let authBuildEnv: BUILD_ENV_TYPE = import .meta .env .DEV ? BUILD_ENV .TESTING : BUILD_ENV .PRODUCTION ;
47+ if (envValue && buildEnvValues .has (envValue as BUILD_ENV_TYPE )) {
48+ authBuildEnv = envValue as BUILD_ENV_TYPE ;
4549}
4650
4751function buildStorageConfig(): StorageConfig | undefined {
@@ -152,7 +156,7 @@ const options = computed((): Web3AuthOptions => {
152156 chains ,
153157 defaultChainId: formData .defaultChainId ,
154158 enableLogging: true ,
155- authBuildEnv: resolveAuthBuildEnv () ,
159+ authBuildEnv ,
156160 connectors: [... externalConnectors .value , authConnectorInstance ],
157161 plugins ,
158162 multiInjectedProviderDiscovery: formData .multiInjectedProviderDiscovery ,
@@ -165,13 +169,33 @@ const options = computed((): Web3AuthOptions => {
165169 };
166170});
167171
172+ // Note: authConnectionId may varies based on the project config and web3auth client id.
173+ // The following function return the authConnectionId relevant to the AuthBuildEnv and `clientIds` Map from `config.ts`
174+ const getAuthConnectionIds = (authConnectionStr : string ): { authConnectionId: string ; groupedAuthConnectionId? : string } => {
175+ if (authBuildEnv === BUILD_ENV .PRODUCTION ) {
176+ //
177+ return {
178+ authConnectionId: " web3auth" ,
179+ groupedAuthConnectionId: ` web3auth-auth0-${authConnectionStr }-passwordless-sapphire ` ,
180+ };
181+ }
182+ return {
183+ authConnectionId: ` w3a-custom-${authConnectionStr }-${formData .network .replace (" _" , " -" )} ` ,
184+ };
185+ };
186+
168187const loginMethodsConfig = computed (() => {
188+ const { authConnectionId : customEmailAuthConnectionId, groupedAuthConnectionId : customEmailGroupedAuthConnectionId } =
189+ getAuthConnectionIds (" email" );
190+ const { authConnectionId : customSmsAuthConnectionId, groupedAuthConnectionId : customSmsGroupedAuthConnectionId } = getAuthConnectionIds (" sms" );
169191 const customConfig = {
170192 email_passwordless: {
171- authConnectionId: ` w3a-custom-email-${formData .network .replace (" _" , " -" )} ` ,
193+ authConnectionId: customEmailAuthConnectionId ,
194+ groupedAuthConnectionId: customEmailGroupedAuthConnectionId ,
172195 },
173196 sms_passwordless: {
174- authConnectionId: ` w3a-custom-sms-${formData .network .replace (" _" , " -" )} ` ,
197+ authConnectionId: customSmsAuthConnectionId ,
198+ groupedAuthConnectionId: customSmsGroupedAuthConnectionId ,
175199 },
176200 };
177201 if (formData .loginProviders .length === 0 ) return customConfig ;
@@ -183,10 +207,12 @@ const loginMethodsConfig = computed(() => {
183207 }, {} as LoginMethodConfig );
184208
185209 if (config .email_passwordless ) {
186- config .email_passwordless .authConnectionId = ` w3a-custom-email-${formData .network .replace (" _" , " -" )} ` ;
210+ config .email_passwordless .authConnectionId = customEmailAuthConnectionId ;
211+ config .email_passwordless .groupedAuthConnectionId = customEmailGroupedAuthConnectionId ;
187212 }
188213 if (config .sms_passwordless ) {
189- config .sms_passwordless .authConnectionId = ` w3a-custom-sms-${formData .network .replace (" _" , " -" )} ` ;
214+ config .sms_passwordless .authConnectionId = customSmsAuthConnectionId ;
215+ config .sms_passwordless .groupedAuthConnectionId = customSmsGroupedAuthConnectionId ;
190216 }
191217
192218 const loginMethods: LoginMethodConfig = JSON .parse (JSON .stringify (config ));
0 commit comments