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.
Methods
Section titled “Methods”getPrincipal()
Section titled “getPrincipal()”getPrincipal(): {
toText:string; } |undefined
Defined in: core/src/client.ts:81
Who calls are accepted as, or undefined when nobody can act.
Returns
Section titled “Returns”{ toText: string; } | undefined
getStatus()
Section titled “getStatus()”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.
Returns
Section titled “Returns”object
readonlystate:"signed-in"|"signed-in-elsewhere"|"expired"|"signed-out"
getIdentity()
Section titled “getIdentity()”getIdentity():
Promise<Identity>
Defined in: core/src/client.ts:91
The identity to sign calls with while signed in.
Returns
Section titled “Returns”Promise<Identity>
subscribe()
Section titled “subscribe()”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.
Parameters
Section titled “Parameters”listener
Section titled “listener”() => void
Returns
Section titled “Returns”() => void
signIn()
Section titled “signIn()”signIn(
options?):Promise<unknown>
Defined in: core/src/client.ts:94
Parameters
Section titled “Parameters”options?
Section titled “options?”unknown
Returns
Section titled “Returns”Promise<unknown>
signOut()
Section titled “signOut()”signOut(
options?):Promise<unknown>
Defined in: core/src/client.ts:95
Parameters
Section titled “Parameters”options?
Section titled “options?”unknown
Returns
Section titled “Returns”Promise<unknown>
dispose()?
Section titled “dispose()?”
optionaldispose():void
Defined in: core/src/client.ts:97
Releases what the auth holds. Called once, from Client.dispose.
Returns
Section titled “Returns”void