# restoreSession

Rehydrate accounts from the browser keystore after a page refresh.

If the keystore holds entries, the persisted JWT (under `__jwt__`) is
restored first so adding accounts can skip the re-auth round trip (TOTP sign +
POST /auth). Each remaining key is an account whose keypairs come from the
keystore and whose metadata comes from storage; they are rebuilt into a
`CurvyAccount` and added. Per-account failures (missing metadata, corrupt data)
are swallowed — the user can re-authenticate to re-derive keypairs.

No-op in Node (`config.keystore` is `null`).

## Import

```ts
import { restoreSession } from "@0xcurvy/curvy-sdk/actions";
```

## Usage

```ts
await restoreSession();
```

## Signature

```ts
function restoreSession(parameters?: WithConfig): Promise<void>
```

## Returns

`Promise<void>`

The action resolves or returns the value shown in the signature.

## Parameters

### `config`

- **Type:** `CurvyConfig`
- **Required:** no

Curvy config to use. Defaults to the ambient config.

```ts
await restoreSession({
  config, // [!code focus]
});
```

## Errors

Errors from config resolution and the underlying SDK operation are propagated to the caller.

## Related

- [Authentication guide](/for-programmers/authentication)
- [`login`](/sdk/actions/auth/login) — Log in (add an existing account) from an account signature.
- [`loginWithPasskey`](/sdk/actions/auth/loginWithPasskey) — Log in via a passkey PRF output.
- [`loginWithPrivateKeys`](/sdk/actions/auth/loginWithPrivateKeys) — Log in from raw spending/viewing private keys.
- [`logout`](/sdk/actions/auth/logout) — Remove an account and re-point (or clear) the active account.

## Source

[packages/@0xcurvy/sdk/src/actions/auth/restoreSession.ts](https://github.com/0xCurvy/curvy-monorepo/blob/main/packages/@0xcurvy/sdk/src/actions/auth/restoreSession.ts)
