const initSNS = async () => {
try {
const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: '0x5', // Please use 0x1 for Mainnet
rpcTarget: 'https://rpc.ankr.com/eth_goerli',
displayName: 'Goerli Testnet',
blockExplorer: 'https://goerli.etherscan.io/',
ticker: 'ETH',
tickerName: 'Ethereum',
}
const id =
'BMwTnf6I4qw7qwOWP1J1BsgHKEZDGG0peo-DpCMBmurc1RUSY16Ag8LdC4on55hLiStTQxm0FJ2wOuIZU2m9gr0'
const web3auth = new Web3AuthNoModal({
clientId: id,
chainConfig: chainConfig,
web3AuthNetwork: 'testnet',
useCoreKitKey: false,
})
const privateKeyProvider = new EthereumPrivateKeyProvider({
config: { chainConfig },
})
const openloginAdapter = new OpenloginAdapter({
loginSettings: {
mfaLevel: 'none', // Pass on the mfa level of your choice: default, optional, mandatory, none
},
adapterSettings: {
clientId: id,
mfaSettings: {
deviceShareFactor: {
enable: false,
priority: 1,
mandatory: false,
},
backUpShareFactor: {
enable: false,
priority: 2,
mandatory: false,
},
socialBackupFactor: {
enable: false,
priority: 3,
mandatory: false,
},
passwordFactor: {
enable: false,
priority: 4,
mandatory: false,
},
},
loginConfig: {
// Google login
google: {
verifier: 'ppp-social-login-2', // Pass the Verifier name here. eg. w3a-agg-example
verifierSubIdentifier: 'ppp-google-login', // Pass the Sub-Verifier here. eg w3a-google
typeOfLogin: 'google', // Pass the type of login provider.
clientId:
'792163717588-h9t0is3ng39opqmt1meflma087ov18k3.apps.googleusercontent.com', // Pass the Google `Client ID` here.
},
// facebook Login via Auth0
facebook: {
verifier: 'ppp-social-login-2',
verifierSubIdentifier: 'ppp-facebook-login',
typeOfLogin: 'jwt',
clientId: 'H67UacptdCvHI27IEHuJBTVOgxjfAPvn',
},
// line Login via Auth0
line: {
verifier: 'ppp-social-login-2',
verifierSubIdentifier: 'ppp-line-login',
typeOfLogin: 'jwt',
clientId: 'Y0EkN53ZYHQmE3BTlv3ylvKAg5dt38CP',
},
apple: {
verifier: 'ppp-social-login-2',
verifierSubIdentifier: 'ppp-apple-login',
typeOfLogin: 'jwt',
clientId: 'QRQW2fY3167OZTzreWBqHTBQU7gGXUD0',
},
// emailpasswordless Login via Auth0
emailpasswordless: {
verifier: 'ppp-social-login-2', // Pass the Verifier name here. eg. w3a-agg-example
verifierSubIdentifier: 'ppp-passwordless-login', // Pass the Sub-Verifier here. eg w3a-a0-email-passwordless
typeOfLogin: 'jwt', // Pass the type of login provider. For Auth0, it's jwt and not Auth0.
clientId: 'kV31v4CokK8xEHgNcHki1nAVDCh3Friu', // Pass the `Client ID` of your Auth0 Application.
},
},
},
privateKeyProvider,
})
web3auth.configureAdapter(openloginAdapter)
;(window as any).Web3Auth = web3auth
await web3auth.init()
;(window as any).Web3AuthProvider = web3auth.provider
} catch (error) {
console.error(error)
}
}
const loginWithLine = async () => {
try {
const { Web3Auth } = window as any
const web3authProvider = await Web3Auth.connectTo('openlogin', {
loginProvider: 'line',
extraLoginOptions: {
domain: 'https://dev-px4cfed8eh5nu1bn.jp.auth0.com', // Pass the Auth0 Domain here, eg. https://web3auth.au.auth0.com
// This corresponds to the field inside jwt which must be used to uniquely identify the user.
verifierIdField: 'email', // This is mapped b/w google and github logins.
isVerifierIdCaseSensitive: false,
connection: 'line',
},
})
;(window as any).Web3AuthProvider = web3authProvider
} catch (error) {
console.error(error)
}
}