StateStorage
Defined in: src/client/state-storage.ts:40
Holds the state of a sign-in.
This is what decides whether this origin is signed in and as whom. It is a store of its own because it has to be readable without awaiting, which a credential store does not.
A record can be stale — a session revoked at the canister still reads as signed in until something calls and is refused — so it is the state as this browser knows it rather than an authority against the network.
Properties
Section titled “Properties”resumable?
Section titled “resumable?”
readonlyoptionalresumable?:boolean
Defined in: src/client/state-storage.ts:81
Whether a sign-in kept in this store may be resumed without a ceremony.
True only where the record reaches past this origin, because that is the case a silent re-issue exists for: a sibling reads the sign-in, holds no credential of its own, and needs the identity provider to remember the session it can extend. A store the origin keeps to itself has nothing to gain and would only be asking the provider to persist a sign-in on a device where nothing wanted one kept.
Absent means false, which is the answer for a store that never considered the question.
Methods
Section titled “Methods”discard()
Section titled “discard()”discard(
key):void
Defined in: src/client/state-storage.ts:66
Removes what this origin holds, leaving anything shared alone.
What finding out does, which is a different act. An origin whose chain turns out to be dead cannot tell whether the session was revoked or replaced by a sibling signing in — and in the second case the shared record was written by that sibling a moment ago, so retracting it would tell it that the session it just obtained is gone.
A store that publishes nothing beyond this origin answers it with remove, which is one line and the right answer.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
get(
key):SessionState|null
Defined in: src/client/state-storage.ts:42
The state, or null where nothing is signed in within this store’s reach.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”SessionState | null
remove()
Section titled “remove()”remove(
key):void
Defined in: src/client/state-storage.ts:52
Removes the state, and anything this store publishes beyond this origin.
What signing out does: the user ended the sign-in, so a sibling reading a shared record must stop seeing one.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
set(
key,state):void
Defined in: src/client/state-storage.ts:44
Parameters
Section titled “Parameters”string
Omit<SessionState, "held">
Returns
Section titled “Returns”void
subscribe()
Section titled “subscribe()”subscribe(
key,listener): () =>void
Defined in: src/client/state-storage.ts:92
Registers a listener fired when the state under key changes, including
when something other than this client changed it. Returns a function that
unregisters it.
Required rather than optional: two clients can share one store, even a store with no medium behind it, and a client that cannot be told the record changed under it goes on answering for a sign-in that is no longer there.
Parameters
Section titled “Parameters”string
listener
Section titled “listener”() => void
Returns
Section titled “Returns”() => void