# Group storage

Encrypted private device state adapters.

[Read the shared private collections guide](/docs/groups/). Signatures below come from the published SDK declarations. Access SDK services through `db`; use their constructors only when integrating at a lower level.

## GroupStateAdapter


```ts
/** 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


```ts
declare class MemoryGroupStateAdapter implements GroupStateAdapter {}
```

### get


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

### set


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

### remove


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

### keys


```ts
keys(): Promise<string[]>;
```

### close


```ts
close(): void;
```

## IndexedDBGroupStateAdapter


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

### constructor


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

### get


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

### set


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

### remove


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

### keys


```ts
keys(): Promise<string[]>;
```

### close


```ts
close(): Promise<void>;
```


## Supporting declarations

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

### GroupStoreScope


```ts
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


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

### EncryptedGroupStore


```ts
/**
 * 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


```ts
readonly prefix: string;
```

### constructor


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

### setItem


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

### getItem


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

### removeItem


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

### keys


```ts
keys(): Promise<string[]>;
```

### clear


```ts
clear(): Promise<void>;
```
