Skip to content

Commit

Permalink
fix: optional mfa (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Dec 15, 2023
1 parent 0f7fde6 commit 5e121df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions config/web3-auth.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { OPENLOGIN_NETWORK_TYPE, WALLET_ADAPTERS } from "@web3auth/base"
import {
MFA_LEVELS,
OpenLoginOptions,
UX_MODE,
} from "@toruslabs/openlogin-utils"
import { LoginSettings } from "@web3auth/openlogin-adapter"

export const WEB3AUTH_CLIENT_ID =
process.env["NEXT_PUBLIC_WEB3AUTH_CLIENT_ID"] ?? "invalid"
export const WEB3AUTH_NETWORK = process.env[
"NEXT_PUBLIC_WEB3AUTH_NETWORK"
] as OPENLOGIN_NETWORK_TYPE

export const WEB3AUTH_ADAPTER_SETTINGS = {
uxMode: UX_MODE.POPUP,
} as OpenLoginOptions

export const WEB3AUTH_LOGIN_SETTINGS = {
mfaLevel: MFA_LEVELS.OPTIONAL,
} as LoginSettings

export const WEB3AUTH_MODAL_CONFIG = {
[WALLET_ADAPTERS.OPENLOGIN]: {
label: "openlogin",
Expand Down
7 changes: 4 additions & 3 deletions lib/web3-auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Web3Auth } from "@web3auth/modal"
import { OpenloginAdapter } from "@web3auth/openlogin-adapter"
import {
WEB3AUTH_ADAPTER_SETTINGS,
WEB3AUTH_CLIENT_ID,
WEB3AUTH_LOGIN_SETTINGS,
WEB3AUTH_MODAL_CONFIG,
WEB3AUTH_NETWORK,
} from "../config/web3-auth"
Expand All @@ -23,9 +25,8 @@ export async function web3AuthInitProvider(
uiConfig: uiConfig,
})
const openloginAdapter = new OpenloginAdapter({
adapterSettings: {
uxMode: "popup",
},
adapterSettings: WEB3AUTH_ADAPTER_SETTINGS,
loginSettings: WEB3AUTH_LOGIN_SETTINGS,
})
web3auth.configureAdapter(openloginAdapter)

Expand Down

0 comments on commit 5e121df

Please sign in to comment.