
EBSI NP DID Resolver
This library supports the proposed did:ebsinp
method from EBSI:
did-ebsinp-format := did:ebsinp:MULTIBASE(base58-btc, MULTICODEC(jwk_jcs-pub, raw-public-key-bytes))
Inspired by The did:key Method v0.7.
The multicodec must be jwk_jcs-pub
(code: 0xeb51
, not standardised yet). It corresponds to a JWK with required members only through JCS.
It requires the did-resolver
library, which is the primary interface for resolving DIDs.
Table of Contents
- Installation
- Resolving a DID document
- Library Test
- Licensing
Installation
npm install @cef-ebsi/ebsinp-did-resolver
or if you use yarn
:
yarn add @cef-ebsi/ebsinp-did-resolver
Resolving a DID Document
The library provides a resolver that is meant to be used through the did-resolver
aggregator.
import { Resolver } from "did-resolver";
import { getResolver } from "@cef-ebsi/ebsinp-did-resolver";
const ebsinpResolver = getResolver();
const didResolver = new Resolver(ebsinpResolver);
didResolver
.resolve(
"did:ebsinp:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbsEYvdrjxMjQ4tpnje9BDBTzuNDP3knn6qLZErzd4bJ5go2CChoPjd5GAH3zpFJP5fuwSk66U5Pq6EhF4nKnHzDnznEP8fX99nZGgwbAh1o7Gj1X52Tdhf7U4KTk66xsA5r"
)
.then((doc) => console.log(doc));
const doc = await didResolver.resolve(
"did:ebsinp:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbsEYvdrjxMjQ4tpnje9BDBTzuNDP3knn6qLZErzd4bJ5go2CChoPjd5GAH3zpFJP5fuwSk66U5Pq6EhF4nKnHzDnznEP8fX99nZGgwbAh1o7Gj1X52Tdhf7U4KTk66xsA5r"
);
console.log(doc);
Creating a DID from a JWK
The library exposes a method allowing you to create a DID from a JWK:
import { util } from "@cef-ebsi/ebsinp-did-resolver";
const jwk = {
kty: "EC",
crv: "P-256",
x: "ngy44T1vxAT6Di4nr-UaM9K3Tlnz9pkoksDokKFkmNc",
y: "QCRfOKlSM31GTkb4JHx3nXB4G_jSPMsbdjzlkT_UpPc",
};
const did = util.createDid(jwk);
Validating a DID
The library also exposes a method to assert if a DID is valid:
import { util } from "@cef-ebsi/ebsinp-did-resolver";
const did =
"did:ebsinp:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbsEYvdrjxMjQ4tpnje9BDBTzuNDP3knn6qLZErzd4bJ5go2CChoPjd5GAH3zpFJP5fuwSk66U5Pq6EhF4nKnHzDnznEP8fX99nZGgwbAh1o7Gj1X52Tdhf7U4KTk66xsA5r";
util.validateDid(did);
Library Test
Create an .env
file using .env.example
and update the env variables.
$ yarn test:unit
$ yarn test:e2e
$ 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.