# Class: AuthModule

### Constructors

#### new AuthModule()

> **new AuthModule**(`config`): `AuthModule`

Initializes the `AuthModule` instance.

**Parameters**

**config**

`Config`

An object containing the configuration for the authentication module. The `authApiUrl` field in the config is required to initialize the client.

**Returns**

`AuthModule`

**Defined in**

[module/auth.ts:25](https://github.com/haven1network/haven1-sdk/blob/0001e1c92905c3f34b86b89ff2290ffba9fe7417/packages/api-client/src/module/auth.ts#L25)

### Methods

#### getClient()

> **getClient**(): `undefined` | `Client`<`paths`, \`${string}/${string}\`>

Returns the OpenAPI client instance if it is initialized.

**Returns**

`undefined` | `Client`<`paths`, \`${string}/${string}\`>

The instance or `undefined` if not initialized.

**Defined in**

[module/auth.ts:40](https://github.com/haven1network/haven1-sdk/blob/0001e1c92905c3f34b86b89ff2290ffba9fe7417/packages/api-client/src/module/auth.ts#L40)

***

#### getNonce()

> **getNonce**(): `undefined` | `Promise`<`FetchResponse`<{}, `undefined` | `FetchOptions`<{}>, \`${string}/${string}\`>>

Retrieves a nonce from the authentication API.

The nonce can be used for generating and signing authentication messages.

**Returns**

`undefined` | `Promise`<`FetchResponse`<{}, `undefined` | `FetchOptions`<{}>, \`${string}/${string}\`>>

A `Promise` that resolves with the server's response, or `undefined` if the client is not initialized.

**Defined in**

[module/auth.ts:51](https://github.com/haven1network/haven1-sdk/blob/0001e1c92905c3f34b86b89ff2290ffba9fe7417/packages/api-client/src/module/auth.ts#L51)

***

#### signOut()

> **signOut**(): `undefined` | `Promise`<`FetchResponse`<{}, `undefined` | `FetchOptions`<{}>, \`${string}/${string}\`>>

Signs out the current session using the authentication API.

This function invalidates the authentication session on the backend.

**Returns**

`undefined` | `Promise`<`FetchResponse`<{}, `undefined` | `FetchOptions`<{}>, \`${string}/${string}\`>>

A `Promise` that resolves with the sign-out response, or `undefined` if the client is not initialized.

**Defined in**

[module/auth.ts:96](https://github.com/haven1network/haven1-sdk/blob/0001e1c92905c3f34b86b89ff2290ffba9fe7417/packages/api-client/src/module/auth.ts#L96)

***

#### validateToken()

> **validateToken**(`token`): `undefined` | `Promise`<`FetchResponse`<{}, { `params`: { `path`: { `token`: `string`; }; }; }, \`${string}/${string}\`>>

Validates an authentication token using the authentication API.

**Parameters**

**token**

`string` = `''`

The token to be validated. Defaults to an empty string if not provided.

**Returns**

`undefined` | `Promise`<`FetchResponse`<{}, { `params`: { `path`: { `token`: `string`; }; }; }, \`${string}/${string}\`>>

A `Promise` that resolves with the validation result, or `undefined` if the client is not initialized.

**Defined in**

[module/auth.ts:79](https://github.com/haven1network/haven1-sdk/blob/0001e1c92905c3f34b86b89ff2290ffba9fe7417/packages/api-client/src/module/auth.ts#L79)

***

#### verify()

> **verify**(`message`, `signature`): `undefined` | `Promise`<`FetchResponse`<{}, { `body`: { `message`: `string`; `signature`: `string`; }; }, \`${string}/${string}\`>>

Verifies a given signature against a message using the authentication API.

**Parameters**

**message**

`string`

The original message to be verified.

**signature**

`string`

The signature to verify against the message.

**Returns**

`undefined` | `Promise`<`FetchResponse`<{}, { `body`: { `message`: `string`; `signature`: `string`; }; }, \`${string}/${string}\`>>

A `Promise` that resolves with the verification result, or `undefined` if the client is not initialized.

**Defined in**

[module/auth.ts:63](https://github.com/haven1network/haven1-sdk/blob/0001e1c92905c3f34b86b89ff2290ffba9fe7417/packages/api-client/src/module/auth.ts#L63)
