Skip to content
IC Reactor

AuthLike

Defined in: core/src/client.ts:79

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 and Client.signOut, and dispose(), when present, is called from 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.

getPrincipal(): { toText: string; } | undefined

Defined in: core/src/client.ts:81

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

{ toText: string; } | undefined


getStatus(): object

Defined in: core/src/client.ts:86

Who is signed in. Only "signed-in" makes the client call as AuthLike.getPrincipal; every other state calls anonymously.

object

readonly state: "signed-in" | "signed-in-elsewhere" | "expired" | "signed-out"


getIdentity(): Promise<Identity>

Defined in: core/src/client.ts:91

The identity to sign calls with while signed in.

Promise<Identity>


subscribe(listener): () => void

Defined in: core/src/client.ts:93

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

() => void

() => void


signIn(options?): Promise<unknown>

Defined in: core/src/client.ts:94

unknown

Promise<unknown>


signOut(options?): Promise<unknown>

Defined in: core/src/client.ts:95

unknown

Promise<unknown>


optional dispose(): void

Defined in: core/src/client.ts:97

Releases what the auth holds. Called once, from Client.dispose.

void