👩💻UserAuthorization Module
The UserAuthorization module, accessible via ssx.userAuthorization
, allows developers to ask the end user for signing-related operations.
This includes:
Authentication (using Sign-in with Ethereum),
User authorizations (delegating to a session key, using ReCap messages) and,
Accessing capabilities granted by the user.
It's enabled by default, and many methods from this module are already accessible directly from the SSX instance (see Root Methods). However, some methods must be called from the module.
Background
Some of the functions for the UserAuthorization Module are written in Rust and made available to the SSX SDK through WebAssembly. This allows for a more secure and performant implementation of these functions using SpruceID Rust libraries.
The UserAuthorization Module is built using two classes: UserAuthorizationInit
and UserAuthorizationConnected
. This approach prevents downstream consumers of this module from having to consider and manage WebAssembly in their application.
Getting Started
Once you have a SSX object, you can use the UserAuthorization Module to authenticate and authorize users. The UserAuthorization Module is available on the SSX object as ssx.userAuthorization
after sign-in.
Methods
address
Gets the address that is connected and signed in.
Here is an example of how to use it:
chainId
Get the chainId that the address is connected and signed in on.
Here is an example of how to use it:
connect
Prompts the user to connect their wallet to the application. Once the user has connected their wallet, you can use the UserAuthorization Module to authenticate and authorize the user.
Calling this is optional, as calling signIn
will automatically connect to the wallet if it is not already connected.
Here is an example of how to use it:
extend
Extends SSX with functions that are called after connecting and signing in.
Here is an example of how to use it:
getProvider
Gets the provider that is connected and signed in.
Here is an example of how to use it:
getSigner
Returns the signer of the connected address.
Here is an example of how to use it:
resolveEns
Resolve ENS data supported by SSX.
Here is an example of how to use it:
resolveLens
Resolves Lens profiles owned by the given Ethereum Address. Each request is limited to 10. To get other pages, you must pass the pageCursor parameter.
This feature is available for Polygon Mainnet and Mumbai Testnet. Visit the Lens docs for more information.
Here is an example of how to use it:
signIn
Request the user to sign in and start the session. Returns an object containing information about the session.
Here is an example of how to use it:
signMessage
Signs a message using the private key of the connected address and returns the signature.
Here is an example of how to use it:
signOut
Invalidates the user's session.
Here is an example of how to use it:
Last updated