Skip to content

Commit b58312f

Browse files
committed
rename web3auth options
1 parent 6dcf602 commit b58312f

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const options = computed((): Web3AuthOptions => {
127127
// enableLogging?: boolean;
128128
// storageType?: "session" | "local";
129129
// sessionTime?: number;
130-
// useCoreKitKey?: boolean;
130+
// useSFAKey?: boolean;
131131
chains,
132132
defaultChainId: formData.defaultChainId,
133133
enableLogging: true,

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type AccountAbstractionMultiChainConfig } from "@toruslabs/ethereum-controllers";
2-
import { type BUILD_ENV_TYPE, type LoginParams, SafeEventEmitter, UX_MODE_TYPE, type WhiteLabelData } from "@web3auth/auth";
2+
import { type BUILD_ENV_TYPE, type LoginParams, MfaSettings, SafeEventEmitter, UX_MODE_TYPE, type WhiteLabelData } from "@web3auth/auth";
33
import { type WsEmbedParams } from "@web3auth/ws-embed";
44

55
import { type ChainNamespaceType, type CustomChainConfig } from "../chain/IChainInterface";
@@ -91,17 +91,17 @@ export interface IWeb3AuthCoreOptions {
9191
* Note: max value can be 30 days (86400 * 30) and min can be 1 sec (1)
9292
*/
9393
sessionTime?: number;
94+
9495
/**
95-
* Web3Auth Network to use for the session & the issued idToken
96-
* @defaultValue sapphire_mainnet
96+
* Web3Auth Network to use for the session.
9797
*/
98-
web3AuthNetwork?: WEB3AUTH_NETWORK_TYPE;
98+
web3AuthNetwork: WEB3AUTH_NETWORK_TYPE;
9999

100100
/**
101101
* Uses core-kit key with web3auth provider
102102
* @defaultValue false
103103
*/
104-
useCoreKitKey?: boolean;
104+
useSFAKey?: boolean;
105105

106106
/**
107107
* WhiteLabel options for web3auth
@@ -157,6 +157,11 @@ export interface IWeb3AuthCoreOptions {
157157
* @defaultValue BUILD_ENV.PRODUCTION
158158
*/
159159
authBuildEnv?: BUILD_ENV_TYPE;
160+
161+
/**
162+
* MFA settings for the auth connector
163+
*/
164+
mfaSettings?: MfaSettings;
160165
}
161166

162167
export type LoginParamMap = {

packages/no-modal/src/base/errors/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class WalletLoginError extends Web3AuthError {
137137
5115: "User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa",
138138
5116: "Chain config has not been added. Please add the chain config before calling switchChain",
139139
5117: "Unsupported operation",
140-
5118: "useCoreKitKey flag is enabled but coreKitKey is not available",
140+
5118: "useSFAKey flag is enabled but SFA key is not available",
141141
5119: "User not logged in.",
142142
};
143143

@@ -181,7 +181,7 @@ export class WalletLoginError extends Web3AuthError {
181181
return WalletLoginError.fromCode(5117, extraMessage, cause);
182182
}
183183

184-
public static coreKitKeyNotFound(extraMessage = "", cause?: unknown): IWeb3AuthError {
184+
public static sfaKeyNotFound(extraMessage = "", cause?: unknown): IWeb3AuthError {
185185
return WalletLoginError.fromCode(5118, extraMessage, cause);
186186
}
187187

packages/no-modal/src/connectors/auth-connector/authConnector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
111111
throw WalletInitializationError.invalidParams("authConnectionConfig is required before auth's initialization");
112112
const isRedirectResult = this.authOptions.uxMode === UX_MODE.REDIRECT;
113113

114-
this.authOptions = { ...this.authOptions, replaceUrlOnRedirect: isRedirectResult, useCoreKitKey: this.coreOptions.useCoreKitKey };
114+
this.authOptions = { ...this.authOptions, replaceUrlOnRedirect: isRedirectResult, useCoreKitKey: this.coreOptions.useSFAKey };
115115
this.authInstance = new Auth({
116116
...this.authOptions,
117117
clientId: this.coreOptions.clientId,
@@ -320,13 +320,13 @@ class AuthConnector extends BaseConnector<AuthLoginParams> {
320320
private _getFinalPrivKey() {
321321
if (!this.authInstance) return "";
322322
let finalPrivKey = this.authInstance.privKey;
323-
// coreKitKey is available only for custom verifiers by default
324-
if (this.coreOptions.useCoreKitKey) {
323+
// coreKitKey is available only for custom connections by default
324+
if (this.coreOptions.useSFAKey) {
325325
// this is to check if the user has already logged in but coreKitKey is not available.
326-
// when useCoreKitKey is set to true.
326+
// when useSFAKey is set to true.
327327
// This is to ensure that when there is no user session active, we don't throw an exception.
328328
if (this.authInstance.privKey && !this.authInstance.coreKitKey) {
329-
throw WalletLoginError.coreKitKeyNotFound();
329+
throw WalletLoginError.sfaKeyNotFound();
330330
}
331331
finalPrivKey = this.authInstance.coreKitKey;
332332
}
@@ -642,8 +642,8 @@ export const authConnector = (params?: AuthConnectorFuncParams): ConnectorFn =>
642642
walletServicesSettings: finalWsSettings,
643643
loginSettings: params?.loginSettings,
644644
coreOptions,
645-
// TODO: check, test this and may need to send modal config here later on.!!
646645
authConnectionConfig: projectConfig.embeddedWalletAuth,
646+
mfaSettings: coreOptions.mfaSettings,
647647
});
648648
};
649649
};

packages/no-modal/src/connectors/auth-connector/interface.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type AuthConnectionConfigItem, type AuthOptions, type LoginParams } from "@web3auth/auth";
1+
import { type AuthConnectionConfigItem, type AuthOptions, type LoginParams, MfaSettings } from "@web3auth/auth";
22
import { type WsEmbedParams } from "@web3auth/ws-embed";
33

44
import { type BaseConnectorSettings, type IBaseProvider } from "../../base";
@@ -10,10 +10,11 @@ export type PrivateKeyProvider = IBaseProvider<string>;
1010
export type WalletServicesSettings = Omit<WsEmbedParams, "chains" | "chainId"> & { modalZIndex?: number };
1111

1212
export interface AuthConnectorOptions extends BaseConnectorSettings {
13-
connectorSettings?: Omit<AuthOptions, "clientId" | "network" | "authConnectionConfig">;
13+
connectorSettings?: Omit<AuthOptions, "clientId" | "network" | "authConnectionConfig" | "mfaSettings">;
1414
loginSettings?: LoginSettings;
1515
walletServicesSettings?: WalletServicesSettings;
1616
authConnectionConfig?: (AuthConnectionConfigItem & { isDefault?: boolean })[];
17+
mfaSettings?: MfaSettings;
1718
}
1819

1920
export {

0 commit comments

Comments
 (0)