Gathering detailed insights and metrics for @sphereon/did-uni-client
Gathering detailed insights and metrics for @sphereon/did-uni-client
Gathering detailed insights and metrics for @sphereon/did-uni-client
Gathering detailed insights and metrics for @sphereon/did-uni-client
DID client for universal resolver and registrar systems
npm install @sphereon/did-uni-client
Typescript
Module System
Node Version
NPM Version
54.3
Supply Chain
98.4
Quality
83.9
Maintenance
100
Vulnerability
98.9
License
Browser compatibility
Published on 03 Apr 2024
Updated dependencies
Published on 14 Jan 2024
Update DID did-resolver, make resolve method async
Published on 08 Mar 2023
Update DID did-resolver from 3.x to 4.0.1.
Published on 26 Oct 2022
Exported getUniResolver(s) methods and enabled strict mode
Published on 16 Oct 2021
Improved API
Published on 13 Oct 2021
TypeScript (99.21%)
JavaScript (0.79%)
Total Downloads
215,675
Last Day
43
Last Week
1,551
Last Month
20,147
Last Year
169,136
5 Stars
151 Commits
2 Forks
4 Watching
3 Branches
9 Contributors
Latest Version
0.6.3
Package Id
@sphereon/did-uni-client@0.6.3
Unpacked Size
51.44 kB
Size
14.45 kB
File Count
17
NPM Version
10.2.4
Node Version
20.11.1
Publised On
25 Apr 2024
Cumulative downloads
Total Downloads
Last day
-92.7%
43
Compared to previous day
Last week
-35.5%
1,551
Compared to previous week
Last month
-32%
20,147
Compared to previous month
Last year
360.8%
169,136
Compared to previous year
The did-uni-client is a library to call a universal registrar (e.g. https://uniregistrar.io) to create, update and deactivate decentralized identifiers (DIDs). And to call a universal resolver (e.g. https://dev.uniresolver.io) to resolve decentralized identifiers to DID Documents. It is written in Typescript and can be compiled to any target JavaScript version.
1import { UniRegistrar, DIDRegistrationRequestBuilder } from '@sphereon/did-uni-client'; 2 3const method = 'btcr'; 4const request = new DIDRegistrationRequestBuilder() 5 .withOptions({chain: 'TESTNET'}) 6 .build(); 7const registrar = new UniRegistrar(); 8 9registrar.create(method, request) 10 .then(result => 'success') 11 .catch(error => 'failed');
1import { UniRegistrar, DIDRegistrationRequestBuilder } from '@sphereon/did-uni-client'; 2 3const did = 'did:btcr:xz35-jznz-q6mr-7q6'; 4const request = new DIDRegistrationRequestBuilder() 5 .withOptions({chain: 'TESTNET'}) 6 .withSecret({token:"ey..."}) 7 .build(); 8const registrar = new UniRegistrar(); 9 10registrar.update(did, request) 11 .then(result => 'success') 12 .catch(error => 'failed');
1import { UniRegistrar, DIDRegistrationRequestBuilder } from '@sphereon/did-uni-client'; 2 3const did = 'did:btcr:xz35-jznz-q6mr-7q6'; 4const request = new DIDRegistrationRequestBuilder() 5.withOptions({chain: 'TESTNET'}) 6.withSecret({token: "ey..."}) 7.build(); 8const registrar = new UniRegistrar(); 9 10registrar.deactivate(did, request) 11.then(result => 'success') 12.catch(error => 'failed');
1import { UniResolver } from '@sphereon/did-uni-client'; 2 3const did = 'did:btcr:xz35-jznz-q6mr-7q6'; 4const resolver = new UniResolver(); 5 6resolver.resolve(did) 7 .then(result => 'success') 8 .catch(error => 'failed');
You can also use this project as a did-resolver driver. This project is developed based on the guidelines of Decentralized Identity
You can use it simply by calling getUniResolver('didMethodName')
followed by the respective 'didMethodName' as a function. This has to do with the fact that you typically use the driver as part of another resolver object, and that resolver registers all DID methods by key (see Example 3).
It is also possible to register multiple methods ad once for use as did-resolver, using the getUniResolvers method.
Examples:
1import { getUniResolver, UniResolver } from '@sphereon/did-uni-client'; 2 3const did = 'did:btcr:xz35-jznz-q6mr-7q6'; 4 5// Example 1: Use an option to provide an alternatieve resolution URL for bctr method 6const didResolutionResult1 = await getUniResolver('bctr', { resolveUrl: 'https://dev.uniresolver.io/1.0/identifiers'}) 7 .bctr(did); 8 9// Example 2: Use the standard resolution URL but for method factom 10const didResolutionResult2 = await getUniResolver('factom') 11 .factom(did); 12 13 14 15 16// 17// Example 3: Use it together with other drivers and register 2 method: 18// 19 20// 2 other drivers 21ethrResolver = ethr.getResolver(); 22webResolver = web.getResolver(); 23 24// 2 times the uni-driver but for different DID-methods 25uniResolvers = getUniResolvers(['btcr', 'eosio']); 26 27//If you are using multiple methods using the did-resolver pacakge you need to flatten them into one object 28const resolver = new Resolver({ 29 ...ethrResolver, 30 ...webResolver, 31 ...uniResolvers 32}) 33 34// Actual resolution 35const didResolutionResult3 = await resolver.resolve(did); 36
To use the library, URL's needs to be available for universal registrar endpoints and universal resolver endpoints. There are three options to configure the URL's. The library will use a configuration object. If you do not provide one a default configuration object will be used that first checks if there are environment variables, if these are not present it will use default values. It is also possible to overwrite the default URL's by using one of the URL setters in the UniRegistrar and UniResolver.
REGISTRAR_URL_CREATE - Defines the URL for a create endpoint (e.g. https://uniregistrar.io/1.0/create).
REGISTRAR_URL_UPDATE - Defines the URL for a update endpoint (e.g. https://uniregistrar.io/1.0/update).
REGISTRAR_URL_DEACTIVATE - Defines the URL for a deactivate endpoint (e.g. https://uniregistrar.io/1.0/deactivate).
RESOLVER_URL_RESOLVE - Defines the URL for a resolve endpoint (e.g. https://dev.uniresolver.io/1.0/identifiers).
1yarn build
The test command runs:
eslint
prettier
unit
coverage
You can also run only a single section of these tests, using for example yarn test:unit
.
1yarn test
There are several other utility scripts that help with development.
yarn fix
- runs eslint --fix
as well as prettier
to fix code style.yarn cov
- generates code coverage report.No vulnerabilities found.
No security vulnerabilities found.