OrbisDB utilizes DIDs (link) for its account management. We managed to abstract all the complexities away and bundle it into a single method call.
Before using the methods, make sure to initialize (link) your OrbisDB SDK.
Authentication is handled by OrbisAuthenticators which generate the DID session in did:pkh
(OrbisEVMAuth
, OrbisSolanaAuth
, OrbisTezosAuth
) and did:key
(OrbisKeyDidAuth
) formats.
import { OrbisDB } from "@useorbis/db-sdk"
import { OrbisEVMAuth } from "@useorbis/db-sdk/auth"
// Browser provider (ie. Metamask)
const provider = window.ethereum
// Orbis Authenticator
const auth = new OrbisEVMAuth(provider)
// Authenticate the user and persist the session in localStorage
const authResult: OrbisConnectResult = await orbis.connectUser({ auth })
// Log the result
console.log({ authResult })
import { OrbisDB } from "@useorbis/db-sdk"
import { OrbisSolanaAuth } from "@useorbis/db-sdk/auth"
// Browser provider (ie. Phantom)
const provider = window.solana
// Orbis Authenticator
const auth = new OrbisSolanaAuth(provider)
// Authenticate the user and persist the session in localStorage
const authResult: OrbisConnectResult = await orbis.connectUser({ auth })
// Log the result
console.log({ authResult })
import { OrbisDB } from "@useorbis/db-sdk"
import { OrbisKeyDidAuth } from "@useorbis/db-sdk/auth"
// Generate the seed or provide an existing one
const seed = await OrbisKeyDidAuth.generateSeed()
// Initiate the authenticator using the generated (or persisted) seed
const auth = await OrbisKeyDidAuth.fromSeed(seed)
// Authenticate the user and persist the session in localStorage
const authResult: OrbisConnectResult = await orbis.connectUser({ auth })
// Log the result
console.log({ authResult })
OrbisDB Sessions are stored in localStorage
and valid for up to 3 months. To bypass this behavior, you can pass an optional saveSession
argument to connectUser
.
Sessions are serializable and stored as a base64
encoded string.
// ...
const authResult = await orbis.connectUser({ auth, saveSession: false })
// ...
In case no active session is found, the method will check the
localStorage
for any persisted sessions
// Check if any user is connected
const connected: boolean = await orbis.isUserConnected()
// Check if a user with the specified wallet address is connected
const connected = await orbis.isUserConnected("0x00...")
In case no active session is found, the method will check the
localStorage
for any persisted sessions