1.1.4 • Published 4 months ago

@mdip/gatekeeper v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

MDIP Gatekeeper

Gatekeeper is a node library for the MDIP. It manages a local database of DIDs on the MDIP network. Gatekeeper functions are used to Create, Read, Update, and Delete DIDs (CRUD).

Installation

npm install @mdip/gatekeeper

Usage

Library

The library must be configured by calling the start function with one of the supported databases:

  • JSON - @mdip/gatekeeper/db/json
  • JSON with memory cache - @mdip/gatekeeper/db/json-cache
  • sqlite - @mdip/gatekeeper/db/sqlite
  • mongodb - @mdip/gatekeeper/db/mongodb
  • redis - @mdip/gatekeeper/db/redis
// Import using subpaths
import Gatekeeper from '@mdip/gatekeeper';
import DbRedis from '@mdip/gatekeeper/db/redis';

// Non-subpath imports
import Gatekeeper, { DbRedis } from '@mdip/gatekeeper';

const db_redis = new DbRedis('mdip-test');
await db_redis.start();

const gatekeeper = new Gatekeeper({ db: db_redis });
const did = 'did:test:z3v8AuaTV5VKcT9MJoSHkSTRLpXDoqcgqiKkwGBNSV4nVzb6kLk';
const docs = await gatekeeper.resolveDID(did);
console.log(JSON.stringify(docs, null, 4));

Client

The GatekeeperClient is used to communicate with a Gatekeeper REST API service.

// Import using subpaths
import GatekeeperClient from '@mdip/gatekeeper/client';

// Non-subpath imports
import { GatekeeperClient } from '@mdip/gatekeeper';

// Try connecting to the gatekeeper service every second,
// and start reporting (chatty) if not connected after 5 attempts
const gatekeeper = new GatekeeperClient();
await gatekeeper.connect({
    url: 'http://gatekeeper-host:4224',
    waitUntilReady: true,
    intervalSeconds: 1,
    chatty: false,
    becomeChattyAfter: 5
});

const did = 'did:test:z3v8AuaTV5VKcT9MJoSHkSTRLpXDoqcgqiKkwGBNSV4nVzb6kLk';
const docs = await gatekeeper.resolveDID(did);
console.log(JSON.stringify(docs, null, 4));
1.1.1

5 months ago

1.1.0

6 months ago

1.0.0

8 months ago

1.1.4

4 months ago

1.1.3

5 months ago

1.1.2

5 months ago

0.5.0

10 months ago

0.4.1

11 months ago

0.4.0

11 months ago

0.6.0

9 months ago

0.3.0

1 year ago

0.1.0

1 year ago