ETS-backed SIWX storage with TTL-based expiration.
Records are stored in an ETS table keyed by {address, resource} and cleaned
up periodically by the GenServer process.
Reads are serialized through the GenServer to ensure consistency with concurrent deletes (e.g., session revocation).
Summary
Functions
Returns a child specification for X402.Extensions.SIWX.ETSStorage.
Deletes an access record from the default storage server.
Deletes an access record from a specific storage server.
Fetches an access record for a wallet/resource pair from the default server.
Fetches an access record from a specific storage server.
Stores an access record in the default storage server.
Stores an access record in a specific storage server.
Starts an ETS-backed SIWX storage process.
Types
@type server() :: GenServer.server()
Storage server identifier accepted by GenServer.call/3.
@type state() :: %{ table: atom(), cleanup_interval_ms: pos_integer(), max_size: pos_integer() }
Functions
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child specification for X402.Extensions.SIWX.ETSStorage.
Deletes an access record from the default storage server.
Deletes an access record from a specific storage server.
@spec get(String.t(), String.t()) :: {:ok, X402.Extensions.SIWX.Storage.access_record()} | {:error, :not_found}
Fetches an access record for a wallet/resource pair from the default server.
Reads go directly to ETS for better concurrency. Expired records return
{:error, :not_found}.
@spec get(server(), String.t(), String.t()) :: {:ok, X402.Extensions.SIWX.Storage.access_record()} | {:error, :not_found}
Fetches an access record from a specific storage server.
Routes through the GenServer to ensure reads are serialised with
concurrent deletes (e.g., session revocation). A direct ETS read on a
:protected table sees the table state at read-time, which may be before
a queued-but-not-yet-processed delete is applied — meaning a revoked
session can appear valid until the next cleanup sweep.
@spec put(String.t(), String.t(), term(), non_neg_integer()) :: :ok | {:error, term()}
Stores an access record in the default storage server.
Stores an access record in a specific storage server.
@spec start_link(keyword()) :: GenServer.on_start() | {:error, NimbleOptions.ValidationError.t()}
Starts an ETS-backed SIWX storage process.
Options
:name(term/0) - Registered name of the ETS storage process. The default value isX402.Extensions.SIWX.ETSStorage.:table(atom/0) - Named ETS table used to store SIWX access records. The default value is:x402_siwx_storage.:cleanup_interval_ms(pos_integer/0) - Interval in milliseconds between cleanup sweeps. The default value is60000.:max_size(pos_integer/0) - Maximum number of {address, resource} entries to keep in the ETS table. When reached, newput/4calls return{:error, :storage_full}until the next cleanup sweep evicts expired records. Prevents unbounded memory growth under spam attacks. The default value is100000.