Skip to content

@armada/sdk / index / IndexedDBStorageAdapter

Class: IndexedDBStorageAdapter ​

Defined in: src/storage/indexeddb.ts:54

IndexedDB-backed KV. Values are stored as Uint8Array (structured-clone native). dbName scopes the database — pass a per-app name. open() takes an origin-scoped EXCLUSIVE Web Lock on dbName (held until close()): IndexedDB itself allows many connections to one DB, but the SDK's scan-state read-modify-write is not safe across instances, so a second live instance on the same DB fails loud with StorageConflictError instead of silently corrupting shared scan state. Where the browser has no Web Locks API (an insecure context, or a very old browser) open() fails closed with StorageUnavailableError, unless the adapter was built with dangerouslySkipLock.

Implements ​

Constructors ​

Constructor ​

new IndexedDBStorageAdapter(dbName, options?): IndexedDBStorageAdapter

Defined in: src/storage/indexeddb.ts:63

Parameters ​

dbName ​

string

options? ​

IndexedDBStorageAdapterOptions = {}

Returns ​

IndexedDBStorageAdapter

Methods ​

open() ​

open(namespace): Promise<{ reset: boolean; }>

Defined in: src/storage/indexeddb.ts:128

Bind the store to namespace. Returns { reset: true } when a namespace mismatch (a redeploy under a preserved identity) triggered a chain-state reset, so the instance can surface it as telemetry. Opening an already-open adapter under a DIFFERENT namespace throws StorageConflictError (it would wipe the chain state of whoever is using it); the same namespace again is a no-op.

Parameters ​

namespace ​

StorageNamespace

Returns ​

Promise<{ reset: boolean; }>

Implementation of ​

StorageAdapter.open


get() ​

get(key): Promise<Uint8Array<ArrayBufferLike> | undefined>

Defined in: src/storage/indexeddb.ts:145

Parameters ​

key ​

string

Returns ​

Promise<Uint8Array<ArrayBufferLike> | undefined>

Implementation of ​

StorageAdapter.get


put() ​

put(key, value): Promise<void>

Defined in: src/storage/indexeddb.ts:150

Parameters ​

key ​

string

value ​

Uint8Array

Returns ​

Promise<void>

Implementation of ​

StorageAdapter.put


del() ​

del(key): Promise<void>

Defined in: src/storage/indexeddb.ts:156

Parameters ​

key ​

string

Returns ​

Promise<void>

Implementation of ​

StorageAdapter.del


update() ​

update(key, fn, options?): Promise<Uint8Array<ArrayBufferLike> | undefined>

Defined in: src/storage/indexeddb.ts:165

Atomic read-modify-write: fn gets the current value (or undefined) and returns the new one (undefined deletes the record). Atomic with respect to every other write to this adapter. fn MUST be synchronous: an IndexedDB transaction commits as soon as it awaits anything else. Resolves to the value stored.

Parameters ​

key ​

string

fn ​

(current) => Uint8Array<ArrayBufferLike> | undefined

options? ​

StorageWriteOptions

Returns ​

Promise<Uint8Array<ArrayBufferLike> | undefined>

Implementation of ​

StorageAdapter.update


batch() ​

batch(ops, options?): Promise<void>

Defined in: src/storage/indexeddb.ts:194

Apply ops in order as one atomic write: all of them land, or none do.

Parameters ​

ops ​

readonly StorageOp[]

options? ​

StorageWriteOptions

Returns ​

Promise<void>

Implementation of ​

StorageAdapter.batch


list() ​

list(prefix): AsyncIterable<{ key: string; value: Uint8Array; }>

Defined in: src/storage/indexeddb.ts:205

Iterate entries whose key starts with prefix, in key order.

Parameters ​

prefix ​

string

Returns ​

AsyncIterable<{ key: string; value: Uint8Array; }>

Implementation of ​

StorageAdapter.list


resetChainState() ​

resetChainState(): Promise<void>

Defined in: src/storage/indexeddb.ts:217

Targeted reset of chain-derived namespaces, preserving identity records.

Returns ​

Promise<void>

Implementation of ​

StorageAdapter.resetChainState


close() ​

close(): Promise<void>

Defined in: src/storage/indexeddb.ts:226

Returns ​

Promise<void>

Implementation of ​

StorageAdapter.close