nostrbasedocs
Start building
API reference
.md

Read the shared private collections guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.

GroupStateAdapter

/** Durable storage receives ciphertext strings only; one adapter can serve many scoped stores. */
interface GroupStateAdapter {
  get(key: string): Promise<string | null>;
  set(key: string, value: string): Promise<void>;
  remove(key: string): Promise<void>;
  keys(): Promise<string[]>;
  close(): void | Promise<void>;
}

MemoryGroupStateAdapter

declare class MemoryGroupStateAdapter implements GroupStateAdapter {}

get

get(key: string): Promise<string | null>;

set

set(key: string, value: string): Promise<void>;

remove

remove(key: string): Promise<void>;

keys

keys(): Promise<string[]>;

close

close(): void;

IndexedDBGroupStateAdapter

/** A write resolves only after IndexedDB commits. Close and open failures reject operations. */
declare class IndexedDBGroupStateAdapter implements GroupStateAdapter {}

constructor

constructor(name?: string, factory?: IDBFactory | undefined);

get

get(key: string): Promise<string | null>;

set

set(key: string, value: string): Promise<void>;

remove

remove(key: string): Promise<void>;

keys

keys(): Promise<string[]>;

close

close(): Promise<void>;

Supporting declarations

These types appear in public signatures but are not package exports.

GroupStoreScope

interface GroupStoreScope {
  namespace: string;
  /** The Nostr account's lowercase public key. */
  account: string;
  /** A stable, random 32-byte device identifier encoded as lowercase hex. */
  device: string;
  bucket: string;
}

GroupStoreIdentityGuard

type GroupStoreIdentityGuard = () => void | Promise<void>;

EncryptedGroupStore

/**
 * A Marmot GenericKeyValueStore-compatible wrapper. Every value is encrypted to the scoped account.
 * The parent owns adapter close. Identity guards must include account, auth revision, and client lifetime.
 */
declare class EncryptedGroupStore<T> {}

Properties

readonly prefix: string;

constructor

constructor(
  adapter: GroupStateAdapter,
  scope: GroupStoreScope,
  signer: Signer,
  guard: GroupStoreIdentityGuard,
);

setItem

setItem(key: string, value: T): Promise<T>;

getItem

getItem(key: string): Promise<T | null>;

removeItem

removeItem(key: string): Promise<void>;

keys

keys(): Promise<string[]>;

clear

clear(): Promise<void>;

Search guides, API methods, and protocols.