Skip to main content
Use the TypeScript SDK session APIs after authentication to restore wallet state, issue ID tokens, and manage credential access.

Session Restore

Browser sessions restore automatically when browser storage is available. Use a custom StorageManager only for non-browser runtimes or custom persistence.
import { OMSClient } from '@0xsequence/typescript-sdk'

const oms = new OMSClient({
  publishableKey: 'YOUR_PUBLISHABLE_KEY',
})

if (oms.wallet.session.walletAddress) {
  console.log('Restored wallet:', oms.wallet.session.walletAddress)
}
Returns oms.wallet.session returns OMSClientSessionState with walletAddress, expiresAt, loginType, and sessionEmail.

Session Expiry Events

Register an onSessionExpired listener when the app should react as soon as the active wallet session expires.
const unsubscribe = oms.wallet.onSessionExpired((event) => {
  console.log('Session expired at:', event.expiredAt)
  console.log('Expired wallet:', event.session.walletAddress)
})
Keep the listener active while the component, route, or service needs updates. Call unsubscribe() during cleanup. Parameters
ParameterTypeDescription
listenerOMSClientSessionExpiredListenerCallback that receives { session, expiredAt } when the wallet session expires.
Returns Returns () => void, an unsubscribe function that removes the listener.

List Wallets

List wallets available to the authenticated credential.
const wallets = await oms.wallet.listWallets()

for (const wallet of wallets) {
  console.log(wallet.id, wallet.type, wallet.address)
}
Parameters Takes no parameters. Returns Returns Promise<OmsWallet[]>.

Get ID Token

Request an ID token for the active wallet session. Send this token to your backend when using backend wallet verification.
const idToken = await oms.wallet.getIdToken({
  ttlSeconds: 300,
})
Parameters
ParameterTypeDescription
ttlSecondsnumber or undefinedOptional token lifetime in seconds.
customClaimsRecord<string, unknown> or undefinedOptional app-provided claims. Backends should treat them as client-provided context unless they control the values.
Returns Returns Promise<string>.

List Access

List wallet access grants for account-management UI.
const grants = await oms.wallet.listAccess()

for (const grant of grants) {
  console.log(grant.credentialId, grant.expiresAt, grant.isCaller)
}
Parameters
ParameterTypeDescription
pageSizenumber or undefinedOptional page size for paginated access results.
Returns Returns Promise<AccessGrant[]>.

List Access Pages

Use listAccessPages when your UI should render credential access one page at a time.
for await (const page of oms.wallet.listAccessPages({ pageSize: 25 })) {
  for (const grant of page.grants) {
    console.log(grant.credentialId, grant.isCaller)
  }
}
Parameters
ParameterTypeDescription
pageSizenumber or undefinedOptional page size for each access-list request.
Returns Returns AsyncIterable<AccessGrantPage>.

Revoke Access

Revoke another credential’s access to the active wallet.
await oms.wallet.revokeAccess({
  targetCredentialId: 'credential-id',
})
Parameters
ParameterTypeDescription
targetCredentialIdstringCredential ID returned by listAccess.
Returns Returns Promise<void>.

Sign Out

await oms.wallet.signOut()
Signing out clears the saved wallet session and authentication state. The user must authenticate again before wallet operations. Parameters Takes no parameters. Returns Returns Promise<void>.