Represents the session state with expiration and last check timestamps.
Classes
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. |
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. |
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. |
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. |
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. |
The parsed serialized state, or undefined if not found or invalid.
SerializedState
|
undefined
# dispatchAfterStateChangeEvent()
Dispatches an event after the state has changed.
# serialize() → {SerializedState}
Serializes the current state into a storable format.
The serialized state object.
SerializedState