1.0.0-alpha.7 • Published 2 years ago

@ebsifnmt/ebsi-did-resolver v1.0.0-alpha.7

Weekly downloads
-
License
(EUPL-1.2 OR Apac...
Repository
-
Last release
2 years ago

EBSI Logo

EBSI DID Resolver

This library supports the proposed did:ebsi method spec from EBSI.

It requires the did-resolver library, which is the primary interface for resolving DIDs.

Table of Contents

  1. Installation
  2. Resolving a DID document
  3. Library Test
  4. Licensing

Installation

npm install @ebsifnmt/ebsi-did-resolver

or if you use yarn:

yarn add @ebsifnmt/ebsi-did-resolver

Resolving a DID document

The library presents a resolve() function that returns a Promise returning the DID document. It is not meant to be used directly but through the did-resolver aggregator.

You can use the getResolver(config) method to produce an entry that can be used with the Resolver constructor:

import { Resolver } from "did-resolver";
import { getResolver } from "@ebsifnmt/ebsi-did-resolver";

// You must set the address of the DID Registry to be used
const resolverConfig = {
  registry: "https://api.preprod.ebsi.eu/did-registry/v2/identifiers",
};

// getResolver will return an object with a key/value pair of { "ebsi": resolver } where resolver is a function used by the generic did resolver.
const ebsiDidResolver = getResolver(resolverConfig);
const didResolver = new Resolver(ebsiDidResolver);

didResolver
  .resolve("did:ebsi:zub5ZZUfHLLptCduwEy8xRj")
  .then((doc) => console.log);

// You can also use ES7 async/await syntax
const doc = await didResolver.resolve("did:ebsi:zub5ZZUfHLLptCduwEy8xRj");

Library Test

Create an .env file using .env.example and update the env variables.

# unit tests
$ yarn test:unit

# e2e tests
$ yarn test:e2e

# all the tests
$ yarn test

Licensing

Copyright (c) 2019 European Commission Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work except in compliance with the Licence. You may obtain a copy of the Licence at:

Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence.

Library based on did-resolver library licensed under Apache 2.0 Copyright 2020 decentralized identity.