> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Manage Sessions

> Restore sessions, manage access, and sign out with the TypeScript OMS Wallet SDK.

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.

```typescript theme={null}
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.

```typescript theme={null}
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**

| Parameter  | Type                              | Description                                                                      |
| ---------- | --------------------------------- | -------------------------------------------------------------------------------- |
| `listener` | `OMSClientSessionExpiredListener` | Callback 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.

```typescript theme={null}
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](/wallets/sdk/guides/backend-wallet-verification).

```typescript theme={null}
const idToken = await oms.wallet.getIdToken({
  ttlSeconds: 300,
})
```

**Parameters**

| Parameter      | Type                                   | Description                                                                                                         |
| -------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `ttlSeconds`   | `number` or undefined                  | Optional token lifetime in seconds.                                                                                 |
| `customClaims` | `Record<string, unknown>` or undefined | Optional 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.

```typescript theme={null}
const grants = await oms.wallet.listAccess()

for (const grant of grants) {
  console.log(grant.credentialId, grant.expiresAt, grant.isCaller)
}
```

**Parameters**

| Parameter  | Type                  | Description                                      |
| ---------- | --------------------- | ------------------------------------------------ |
| `pageSize` | `number` or undefined | Optional 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.

```typescript theme={null}
for await (const page of oms.wallet.listAccessPages({ pageSize: 25 })) {
  for (const grant of page.grants) {
    console.log(grant.credentialId, grant.isCaller)
  }
}
```

**Parameters**

| Parameter  | Type                  | Description                                      |
| ---------- | --------------------- | ------------------------------------------------ |
| `pageSize` | `number` or undefined | Optional page size for each access-list request. |

**Returns**

Returns `AsyncIterable<AccessGrantPage>`.

## Revoke Access

Revoke another credential's access to the active wallet.

```typescript theme={null}
await oms.wallet.revokeAccess({
  targetCredentialId: 'credential-id',
})
```

**Parameters**

| Parameter            | Type     | Description                             |
| -------------------- | -------- | --------------------------------------- |
| `targetCredentialId` | `string` | Credential ID returned by `listAccess`. |

**Returns**

Returns `Promise<void>`.

## Sign Out

```typescript theme={null}
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>`.
