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

# IAuthManager

Interface for auth manager implementations.
Defines the public contract that both real and mock implementations must satisfy.

## Methods

### getUser()

```ts theme={null}
getUser(): 
  | null
  | User;
```

Gets the current user, or null if there is no user signed in.

#### Returns

\| `null`
\| [`User`](/sdks/cdp-sdks-v2/frontend/@coinbase/cdp-core/Type-Aliases/User)

***

### isSignedIn()

```ts theme={null}
isSignedIn(): Promise<boolean>;
```

Returns whether the user is signed in.

#### Returns

`Promise`\<`boolean`>

***

### signOut()

```ts theme={null}
signOut(): Promise<void>;
```

Signs out the user, clearing all authentication state.

#### Returns

`Promise`\<`void`>

***

### addAuthStateChangeCallback()

```ts theme={null}
addAuthStateChangeCallback(callback: OnAuthStateChangeFn): void;
```

Adds a callback to be called when the auth state changes.

#### Parameters

| Parameter  | Type                                                                                                    |
| ---------- | ------------------------------------------------------------------------------------------------------- |
| `callback` | [`OnAuthStateChangeFn`](/sdks/cdp-sdks-v2/frontend/@coinbase/cdp-core/Type-Aliases/OnAuthStateChangeFn) |

#### Returns

`void`

***

### getToken()

```ts theme={null}
getToken(options?: {
  forceRefresh?: boolean;
}): Promise<null | string>;
```

Gets the access token, refreshing if needed, or null if the user is not signed in.

#### Parameters

| Parameter               | Type                             | Description                              |
| ----------------------- | -------------------------------- | ---------------------------------------- |
| `options?`              | \{ `forceRefresh?`: `boolean`; } | The options for getting the token.       |
| `options.forceRefresh?` | `boolean`                        | Whether to force a refresh of the token. |

#### Returns

`Promise`\<`null` | `string`>

***

### getTokenExpiration()

```ts theme={null}
getTokenExpiration(): Promise<null | number>;
```

Gets the expiration time of the access token, or null if the user is not signed in.

#### Returns

`Promise`\<`null` | `number`>

***

### getWalletSecretId()

```ts theme={null}
getWalletSecretId(): Promise<string>;
```

Gets the currently registered wallet secret ID, refreshing if needed.

#### Returns

`Promise`\<`string`>

The wallet secret ID.

***

### getXWalletAuth()

```ts theme={null}
getXWalletAuth(options: {
  requestMethod: string;
  requestHost: string;
  requestPath: string;
  requestData?: Record<string, unknown>;
}): Promise<string>;
```

Gets the X-Wallet-Auth header value. Throws an error if the user is not signed in.

#### Parameters

| Parameter               | Type                                                                                                                              |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `options`               | \{ `requestMethod`: `string`; `requestHost`: `string`; `requestPath`: `string`; `requestData?`: `Record`\<`string`, `unknown`>; } |
| `options.requestMethod` | `string`                                                                                                                          |
| `options.requestHost`   | `string`                                                                                                                          |
| `options.requestPath`   | `string`                                                                                                                          |
| `options.requestData?`  | `Record`\<`string`, `unknown`>                                                                                                    |

#### Returns

`Promise`\<`string`>

***

### getAuthState()

```ts theme={null}
getAuthState(): 
  | null
  | AuthState;
```

Gets the authentication state.

#### Returns

\| `null`
\| [`AuthState`](/sdks/cdp-sdks-v2/frontend/@coinbase/cdp-core/Interfaces/AuthState)

***

### setAuthState()

```ts theme={null}
setAuthState(authState: AuthState): Promise<void>;
```

Sets the authentication state.

#### Parameters

| Parameter   | Type                                                                              |
| ----------- | --------------------------------------------------------------------------------- |
| `authState` | [`AuthState`](/sdks/cdp-sdks-v2/frontend/@coinbase/cdp-core/Interfaces/AuthState) |

#### Returns

`Promise`\<`void`>

***

### clearAuthState()

```ts theme={null}
clearAuthState(): Promise<void>;
```

Clears the authentication state.

#### Returns

`Promise`\<`void`>

***

### ensureInitialized()

```ts theme={null}
ensureInitialized(): Promise<void>;
```

Awaitable method whose promise only resolves when the auth manager is ready to be used.

#### Returns

`Promise`\<`void`>
