@web3-onboard/uauth
Wallet module for connecting Unstoppable Domains to web3-onboard
Install
NPM
npm i @web3-onboard/core @web3-onboard/uauth
Yarn
yarn add @web3-onboard/core @web3-onboard/uauth
Options
Follow the Login Client Congifuration Docs on the Unstoppable Domains website to get setup with your clientID and redirectUri.
Note: The Redirection URI value(s) in the client configuration MUST exactly match the redirect_uri parameter value used in UauthInitOptions
. More specifics can be found in the Rules for Redirect URIs Docs.
type UauthInitOptions = {
clientID: string
redirectUri: string
scope?: string
shouldLoginWithRedirect?: boolean
bridge?: string
qrcodeModalOptions?: {
mobileLinks: string[]
}
connectFirstChainId?: boolean
}
Usage
import Onboard from '@web3-onboard/core'
import uauthModule from '@web3-onboard/uauth'
const uauth = uauthModule({
clientID: 'YOUR_CLIENT_ID',
redirectUri: 'YOUR_REDIRECT_URI',
scope?: 'YOUR_SCOPES',
shouldLoginWithRedirect?: false
bridge?: 'YOUR_CUSTOM_BRIDGE_SERVER',
qrcodeModalOptions?: {
mobileLinks: ['rainbow', 'metamask', 'argent', 'trust', 'imtoken', 'pillar']
},
connectFirstChainId?: true
})
const onboard = Onboard({
wallets: [
uauth
]
})
const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
Accessing the UAuth configuration
When Unstoppable Domains is connected the UAuth user instance is exposed.
This can be used to get information related to the user scopes requested through the UauthInitOptions
.
const wallets$ = onboard.state.select('wallets').pipe(share())
wallets$.subscribe(wallet => {
const unstoppableUser = wallet.find(
provider => provider.label === 'Unstoppable'
)
if (unstoppableUser) console.log(unstoppableUser.instance.user)
})