ConfigStore
The config storage layer defines how verification configurations are persisted and retrieved on the backend. These configurations represent the same disclosure/verification rules that the frontend and smart contracts enforce. Keeping them consistent is critical.
This @selfxyz/core library exposes an interface (IConfigStorage) and two default implementations (DefaultConfigStore, InMemoryConfigStore).
IConfigStorage
IConfigStorageexport interface IConfigStorage {
getConfig(id: string): Promise<VerificationConfig>
setConfig(id: string, config: VerificationConfig): Promise<boolean>
getActionId(userIdentifier: string, data: string): Promise<string>
}Methods
getConfig(id)Returns the
VerificationConfigassociated with a given id.This id is typically the
configIdreferenced by your contract/backend/frontend.
setConfig(id, config)Stores a new verification config under the given id.
Returns
trueif an existing config was replaced,falseif it was newly set.
getActionId(userIdentifier, data)Computes or retrieves an action id based on user context data from the frontend.
This action id links user activity with a registered config and is later used by
getConfig(id)
DefaultConfigStore
A simple implementation that always returns the same config regardless of id.
Example
InMemoryConfigStore
A more flexible implementation that can hold multiple configs in memory.
Example
Use cases:
Backends that need to manage multiple verification configurations at once.
Scenarios where action ids must be computed dynamically per user.
Good for prototyping before connecting to a persistent store (DB, KV, etc.).
Custom Implementations
Here's an example of a KVConfigStore that is used in the playground.
Integration with Frontend
The userDefinedData parameter in the frontend's SelfAppBuilder is passed to your getActionId method:
Summary
IConfigStoragedefines a contract for working with verification configs.The library ships with
DefaultConfigStore(static) andInMemoryConfigStore(multi‑config, dynamic).Backend verifiers (like
SelfBackendVerifier) depend onIConfigStorageto fetch configs and action ids.You can plug in your own storage backend by implementing the same interface.
Last updated