Skip to content
Last updated
Edit

Once a user has successfully authenticated, the application should display the user’s domain (and not their wallet address) in the application’s UI to confirm the authorization was successful.

Showing an authenticated user's domain

Showing an authenticated user's domain

Authorizations are stored inside localStorage, so any identically configured UAuth instance has access to the same users. Any integration using @uauth/js or a dependent middleware package can access the authorized user information by instantiating a new UAuth object with the same client options and calling the user() method.

import UAuth from '@uauth/js'

const uauth = new UAuth({
  // ... options
})

uauth.user()
  .then((user) => {
    // user exists
    console.log("User information:", user)
  })
  .catch(() => {
    // user does not exist
  })

The user() method will return a UserInfo object containing the information requested by your client scopes. The following key-value pairs would be returned by a login session with the minimum "openid wallet" scopes defined:

{
  "sub" : "domain.tld", // The domain used to login
  "wallet_address" : "0x . . . ", // The Ethereum wallet that owns the domain
  "wallet_type_hint" : "web3",
  "eip4361_message" : "identity.unstoppable domains wants you sign in with your Ethereum account: . . . ",
  "eip4361_signature" : "0x . . . ",
}