# @did-connect/storage

> Storage interface for did-auth

Latest version **2.2.8** (published 2025-05-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @did-connect/storage
pnpm add @did-connect/storage
yarn add @did-connect/storage
bun add @did-connect/storage
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.2.8 |
| Published | 2025-05-12 |
| First published | 2022-07-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | wangshijun <shijun@arcblock.io> (https://ocap.arcblock.io) |
| Maintainers | wangshijun |
| Keywords | did, web3 |

## Links

- npm: https://www.npmjs.com/package/@did-connect/storage
- Repository: https://github.com/ArcBlock/did-connect/tree/master/packagesstorage
- Issues: https://github.com/ArcBlock/did-connect/issues
- npm.io page: https://npm.io/package/@did-connect/storage

## Dependencies (1)

- [@did-connect/types](https://npm.io/package/@did-connect/types.md) 2.2.8

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.2.8 (latest) — 2025-05-12
- 2.2.7 — 2025-01-25
- 2.2.6 — 2025-01-25
- 2.2.5 — 2025-01-24
- 2.2.4 — 2024-04-12
- 2.2.3 — 2024-04-09
- 2.2.2 — 2024-04-08
- 2.2.1 — 2023-11-07
- 2.2.0 — 2023-07-10
- 2.1.59 — 2023-05-23
- 2.1.58 — 2023-05-19
- 2.1.57 — 2023-05-16
- 2.1.54 — 2023-05-04
- 2.1.53 — 2023-04-27
- 2.1.52 — 2023-04-23
- … 66 more at https://npm.io/package/@did-connect/storage/versions

## README

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

## Introduction

Defines the interface for DID Connect Session Storage, basic APIs that a session storage includes:

- `async create(session, attrs)`, create a new session record, persist in storage
- `async read(session)`, read a session from storage,
- `async update(session, updates)`, update session record
- `async delete(session)`, remove a session record

## Install

```sh
npm install @did-connect/storage
// or
yarn add @did-connect/storage
```

## Usage

```js
const { BaseStorage } = require('@did-connect/storage');
const keystone = require('keystone');

module.exports = class KeystoneStorage extends BaseStorage {
  constructor() {
    this.model = keystone.list('sessions').model;
  }

  create(sessionId, attrs) {
    const LoginToken = this.model;
    const item = new LoginToken({ sessionId, ...attrs });
    return item.save();
  }

  read(sessionId) {
    return this.model.findOne({ sessionId });
  }

  update(sessionId, updates) {
    return this.model.findOneAndUpdate({ sessionId }, updates);
  }

  delete(sessionId) {
    return this.model.remove({ sessionId });
  }
};
```

---
_Source: https://npm.io/package/@did-connect/storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
