# AuthLike

Defined in: [core/src/client.ts:79](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L79)

A sign-in the client can own: what `@icp-sdk/auth` 10's `AuthClient` and the
`auth` of `createTestClient()` from `@ic-reactor/core/testing` both are, with
no adapter.

The client reads `getStatus()` and `getPrincipal()` synchronously to decide
who calls, asks `getIdentity()` for the identity to sign with only when it
builds or checks an agent for a signed-in principal, and re-reads both after
every `subscribe()` notification. `signIn()` and `signOut()` are forwarded
from [Client.signIn](https://ic-reactor.b3pay.net/v4/libs/interfaces/client/#signin) and [Client.signOut](https://ic-reactor.b3pay.net/v4/libs/interfaces/client/#signout), and `dispose()`, when
present, is called from [Client.dispose](https://ic-reactor.b3pay.net/v4/libs/interfaces/client/#dispose): the client owns the auth its
factory built.

Another sign-in source (a wallet, a hand-rolled session) fits by
implementing these six methods, and `dispose()` if it holds anything. Its
`getIdentity()` should return the same object until the identity really
changes: the client builds a new agent for every new identity object it is
handed, and reads a new object for the same principal as a renewal.

## Methods

### getPrincipal()

> **getPrincipal**(): \{ `toText`: `string`; \} \| `undefined`

Defined in: [core/src/client.ts:81](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L81)

Who calls are accepted as, or `undefined` when nobody can act.

#### Returns

\{ `toText`: `string`; \} \| `undefined`

***

### getStatus()

> **getStatus**(): `object`

Defined in: [core/src/client.ts:86](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L86)

Who is signed in. Only `"signed-in"` makes the client call as
[AuthLike.getPrincipal](#getprincipal); every other state calls anonymously.

#### Returns

`object`

##### state

> `readonly` **state**: `"signed-in"` \| `"signed-in-elsewhere"` \| `"expired"` \| `"signed-out"`

***

### getIdentity()

> **getIdentity**(): `Promise`\<`Identity`\>

Defined in: [core/src/client.ts:91](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L91)

The identity to sign calls with while signed in.

#### Returns

`Promise`\<`Identity`\>

***

### subscribe()

> **subscribe**(`listener`): () => `void`

Defined in: [core/src/client.ts:93](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L93)

Calls `listener` after each change of who is signed in. Returns a function that stops listening.

#### Parameters

##### listener

() => `void`

#### Returns

() => `void`

***

### signIn()

> **signIn**(`options?`): `Promise`\<`unknown`\>

Defined in: [core/src/client.ts:94](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L94)

#### Parameters

##### options?

`unknown`

#### Returns

`Promise`\<`unknown`\>

***

### signOut()

> **signOut**(`options?`): `Promise`\<`unknown`\>

Defined in: [core/src/client.ts:95](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L95)

#### Parameters

##### options?

`unknown`

#### Returns

`Promise`\<`unknown`\>

***

### dispose()?

> `optional` **dispose**(): `void`

Defined in: [core/src/client.ts:97](https://github.com/B3Pay/ic-reactor/blob/6b3b9f58b7868082175216ca6e3688d278d17c1f/packages/core/src/client.ts#L97)

Releases what the auth holds. Called once, from [Client.dispose](https://ic-reactor.b3pay.net/v4/libs/interfaces/client/#dispose).

#### Returns

`void`