Interface

State

State

Represents the session state with expiration and last check timestamps.

View Source lib/events/SessionState.ts, line 41

Classes

State
State

Methods

# async static create(hanko, flowName, configopt) → {Promise.<AnyState>}

Creates a new state instance, using cached or fetched data.
Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
flowName FlowName The name of the flow.
config StateCreateConfig <optional>
{} Configuration options.
dispatchAfterStateChangeEvent boolean <optional>
true Whether to dispatch an event after state change.
excludeAutoSteps AutoStepExclusion <optional>
null States to exclude from auto-step processing, or "all".
cacheKey string <optional>
"hanko-flow-state" Key for localStorage caching.
loadFromCache boolean <optional>
true Whether to attempt loading from cache.

View Source lib/flow-api/State.ts, line 458

A promise resolving to the created state.
Promise.<AnyState>

# async static deserialize(hanko, serializedState, configopt) → {Promise.<AnyState>}

Deserializes a state from a serialized state object.
Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
serializedState SerializedState The serialized state data.
config StateCreateConfig <optional>
{} Configuration options.
dispatchAfterStateChangeEvent boolean <optional>
true Whether to dispatch an event after state change.
excludeAutoSteps AutoStepExclusion <optional>
null States to exclude from auto-step processing, or "all".
cacheKey string <optional>
"hanko-flow-state" Key for localStorage caching.
loadFromCache boolean <optional>
true Whether to attempt loading from cache.

View Source lib/flow-api/State.ts, line 473

A promise resolving to the deserialized state.
Promise.<AnyState>

# async static fetchState(hanko, href, bodyopt) → {Promise.<FlowResponse.<any>>}

Fetches state data from the server.
Parameters:
Name Type Attributes Description
hanko Hanko The Hanko instance for API interactions.
href string The endpoint to fetch from.
body any <optional>
Optional request body.

View Source lib/flow-api/State.ts, line 483

A promise resolving to the flow response.
Promise.<FlowResponse.<any>>

# async static initializeFlowState(hanko, flowName, response, optionsopt) → {Promise.<AnyState>}

Initializes a flow state, processing auto-steps if applicable.
Parameters:
Name Type Attributes Default Description
hanko Hanko The Hanko instance for API interactions.
flowName FlowName The name of the flow.
response FlowResponse.<any> The initial flow response.
options StateInitConfig <optional>
{} Configuration options.
dispatchAfterStateChangeEvent boolean <optional>
true Whether to dispatch an event after state change.
excludeAutoSteps AutoStepExclusion <optional>
null States to exclude from auto-step processing, or "all".
previousAction ActionInfo <optional>
null Information about the previous action.
isCached boolean <optional>
false Whether the state is loaded from cache.
cacheKey string <optional>
"hanko-flow-state" Key for localStorage caching.

View Source lib/flow-api/State.ts, line 435

A promise resolving to the initialized state.
Promise.<AnyState>

# static readFromLocalStorage(cacheKey) → {SerializedState|undefined}

Retrieves and parses state data from localStorage.
Parameters:
Name Type Description
cacheKey string The key used to store the state in localStorage.

View Source lib/flow-api/State.ts, line 443

The parsed serialized state, or undefined if not found or invalid.
SerializedState | undefined

# dispatchAfterStateChangeEvent()

Dispatches an event after the state has changed.

View Source lib/flow-api/State.ts, line 397

# removeFromLocalStorage() → {void}

Removes the current state from localStorage.

View Source lib/flow-api/State.ts, line 418

void

# saveToLocalStorage() → {void}

Saves the current state to localStorage.

View Source lib/flow-api/State.ts, line 411

void

# serialize() → {SerializedState}

Serializes the current state into a storable format.

View Source lib/flow-api/State.ts, line 404

The serialized state object.
SerializedState

Methods