Getting Started
Last updated
Was this helpful?
Last updated
Was this helpful?
This easy to use integration method allows a user to scan a QR code to sign into your application. If the user doesn’t have the Verida Wallet installed, they will be prompted to install it. Existing users will be prompted to authorize your application to access encrypted storage for that application.
This requires installing the @verida/account-web-vault
dependency:
Here’s how you initialize an application context:
Various configuration options can be set (as parameters in VaultAccount
) for the Verida Connect SDK.
These (all optional) config options include:
request?.logoUrl?
— The URL of a 170x170 PNG logo to display in the Wallet
request?.openUrl?
— An optional URL for the Wallet to open in the default browser on the user's mobile device after login is accepted. This will automatically authorize the user in local storage so future page loads of your application will be authenticated.
callback?
— A callback function when the auth response is received.
network?
- (banksia
, myrtle
) The Verida Wallet will ensure the user account exists on this network. Defaults to myrtle
.
deeplinkId?
— The HTML element ID of a link that should have the deeplink URI attached to the href
property
loginUri?
— The login URI or page where the user will be sent to login using the app; ie: vault.verida.io.
canvasId?
— A string representing the DOM id where the QR code canvas will be injected
When the user accepts the login request, an accessToken
and a refreshToken
are returned to the browser. If an accessToken
expires, the SDK will automatically attempt to fetch a new accessToken
using the refreshToken
. If the refreshToken
has expired, the SDK will re-open the QR code SSO modal and ask the user to re-login before continuing. Any existing network connections will be restored once the user logs in again.
Due to limitations with how mobile devices work, the redirection of the user, enabled by the request?.openUrl?
option, will open a new tab in the default browser.
Authorization uses an accessToken
and a refreshToken
. If an accessToken
expires, the SDK will automatically attempt to fetch a new accessToken
using the refreshToken
. If the refreshToken
has expired, the SDK will re-open the QR code SSO modal and ask the user to re-login before continuing. Any existing network connections will be restored once the user logs in again.
request?
— An object representing an authorization request that matches
request?.walletConnect?
— An optional configuration to automatically establish a wallet connection upon sign in. See
serverUri?
— An optional string representing the WSS URI of the authentication server. Leave this blank to use a server hosted by Verida or host your own (See )
It is recommended to use the hasSession
method and a conditional connect()
to optimize the user experience. An example of this pattern is shown in the .