Socket
Socket
Sign inDemoInstall

@did-connect/storage

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@did-connect/storage

Storage interface for did-auth


Version published
Weekly downloads
891
decreased by-41.5%
Maintainers
1
Weekly downloads
 
Created
Source

@did-connect/storage

styled with prettier

Interface for define a storage class that can be used by [@arcblock/did-auth].

Table of Contents

Motivation & Spec

Since tokens are used everywhere make achieve better QR code experience, we should allow users to customize how to generate/store/update token records.

Basic APIs that a token storage should support:

  • async init(), optional, should be called before creating any instance, open a database connection, creating a embed database on file system
  • async create(token, status = created), create a new token record, persist in data store
  • async exist?(token, did), check for token existense
  • async read(token), read a token from database,
  • async update(token, updates), update token record
  • async delete(token), remove a token record
  • async gc(), optional, run garbage collection on the token storage

Install

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

Usage

const StorageInterface = require('@did-connect/storage');
const keystone = require('keystone');

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

  create(token, status = 'created') {
    const LoginToken = this.model;
    const item = new LoginToken({ token, status });
    return item.save();
  }

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

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

  delete(token) {
    return this.model.remove({ token });
  }

  exist(token, did) {
    return this.model.findOne({ token, did });
  }
};

Contributors

NameWebsite
wangshijunhttps://ocap.arcblock.io

Keywords

FAQs

Package last updated on 18 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc