Skip to content

Commit cffa673

Browse files
feat: make uiconfig logo require on web3auth sdk
1 parent ac28652 commit cffa673

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

demo/vue-app-new/src/MainView.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const options = computed((): Web3AuthOptions => {
7373
const { confirmationStrategy } = formData.walletPlugin;
7474
walletServicesConfig = {
7575
...walletServicesConfig,
76-
whiteLabel: { showWidgetButton: true, logoLight: "", logoDark: "" },
76+
whiteLabel: { showWidgetButton: true },
7777
confirmationStrategy,
7878
};
7979
}
@@ -112,14 +112,25 @@ const options = computed((): Web3AuthOptions => {
112112
113113
const { widget, targetId } = formData;
114114
const uiConfig: Web3AuthOptions["uiConfig"] = enabledWhiteLabel
115-
? { ...whiteLabel, widgetType: widget, targetId }
116-
: { widgetType: widget, targetId };
115+
? {
116+
...whiteLabel,
117+
widgetType: widget,
118+
targetId,
119+
logoLight: whiteLabel.logoLight || "",
120+
logoDark: whiteLabel.logoDark || "",
121+
}
122+
: {
123+
widgetType: widget,
124+
targetId,
125+
logoLight: "",
126+
logoDark: "",
127+
};
117128
const authConnectorInstance = authConnector({ connectorSettings: {} });
118129
119130
return {
120131
clientId: clientIds[formData.network],
121132
web3AuthNetwork: formData.network,
122-
uiConfig: uiConfig as UIConfig,
133+
uiConfig: uiConfig,
123134
accountAbstractionConfig,
124135
useAAWithExternalWallet: formData.useAAWithExternalWallet,
125136
// TODO: Add more options

packages/modal/src/modalManager.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ export interface Web3AuthOptions extends IWeb3AuthCoreOptions {
4343
/**
4444
* Config for configuring modal ui display properties
4545
*/
46-
uiConfig?: Omit<UIConfig, "connectorListener">;
46+
uiConfig: Omit<UIConfig, "connectorListener" | "logoLight" | "logoDark"> & {
47+
/**
48+
* App logo to use in light mode
49+
*/
50+
logoLight: string;
51+
/**
52+
* App logo to use in dark mode
53+
*/
54+
logoDark: string;
55+
};
4756

4857
/**
4958
* Config for configuring modal ui display properties
@@ -62,7 +71,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
6271
super(options, initialState);
6372
this.options = { ...options };
6473

65-
if (!this.options.uiConfig) this.options.uiConfig = {};
74+
if (!this.options.uiConfig) this.options.uiConfig = { logoLight: "", logoDark: "" };
6675
if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
6776

6877
log.info("modalConfig", this.modalConfig);
@@ -209,9 +218,14 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
209218
this.options.uiConfig = deepmerge(cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
210219
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
211220
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
212-
this.options.uiConfig = deepmerge(projectConfig.loginModal || {}, this.options.uiConfig, {
221+
const uiConfig = deepmerge.all<UIConfig>([projectConfig.loginModal || {}, this.options.uiConfig], {
213222
arrayMerge: (_, sourceArray) => sourceArray,
214223
});
224+
this.options.uiConfig = {
225+
...uiConfig,
226+
logoLight: uiConfig.logoLight || "",
227+
logoDark: uiConfig.logoDark || "",
228+
};
215229

216230
// merge login methods order from project config and user config, with user config taking precedence
217231
const defaultAuthConnections = projectConfig.embeddedWalletAuth.filter((x) => x.isDefault).map((x) => x.authConnection);

packages/no-modal/src/base/core/IWeb3Auth.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type AuthLoginParams = LoginParams & {
3838

3939
export type WalletServicesConfig = Omit<
4040
WsEmbedParams,
41-
"buildEnv" | "enableLogging" | "chainId" | "chains" | "confirmationStrategy" | "accountAbstractionConfig" | "whiteLabel"
41+
"buildEnv" | "enableLogging" | "chainId" | "chains" | "confirmationStrategy" | "accountAbstractionConfig"
4242
> & {
4343
/**
4444
* Determines how to show confirmation screens
@@ -53,11 +53,6 @@ export type WalletServicesConfig = Omit<
5353
*/
5454
confirmationStrategy?: Exclude<WsEmbedParams["confirmationStrategy"], "popup">;
5555
modalZIndex?: number;
56-
57-
/**
58-
* WhiteLabel options for web3auth
59-
*/
60-
whiteLabel?: NonNullable<WsEmbedParams["whiteLabel"]> & Required<Pick<NonNullable<WsEmbedParams["whiteLabel"]>, "logoLight" | "logoDark">>;
6156
};
6257

6358
export interface UIConfig extends WhiteLabelData {

0 commit comments

Comments
 (0)