
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@sphereon/did-uni-client
Advanced tools
A Typescript library to create, update, deactivate and resolve DID documents using a Universal Registrar and Universal Resolver
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://uniresolver.dev.sphereon.com) to resolve decentralized identifiers to DID Documents. It is written in Typescript and can be compiled to any target JavaScript version.
import { UniRegistrar, DIDRegistrationRequestBuilder } from '@sphereon/did-uni-client';
const method = 'btcr';
const request = new DIDRegistrationRequestBuilder()
.withOptions({chain: 'TESTNET'})
.build();
const registrar = new UniRegistrar();
registrar.create(method, request)
.then(result => 'success')
.catch(error => 'failed');
import { UniRegistrar, DIDRegistrationRequestBuilder } from '@sphereon/did-uni-client';
const did = 'did:btcr:xz35-jznz-q6mr-7q6';
const request = new DIDRegistrationRequestBuilder()
.withOptions({chain: 'TESTNET'})
.withSecret({token:"ey..."})
.build();
const registrar = new UniRegistrar();
registrar.update(did, request)
.then(result => 'success')
.catch(error => 'failed');
import { UniRegistrar, DIDRegistrationRequestBuilder } from '@sphereon/did-uni-client';
const did = 'did:btcr:xz35-jznz-q6mr-7q6';
const request = new DIDRegistrationRequestBuilder()
.withOptions({chain: 'TESTNET'})
.withSecret({token: "ey..."})
.build();
const registrar = new UniRegistrar();
registrar.deactivate(did, request)
.then(result => 'success')
.catch(error => 'failed');
import { UniResolver } from '@sphereon/did-uni-client';
const did = 'did:btcr:xz35-jznz-q6mr-7q6';
const resolver = new UniResolver();
resolver.resolve(did)
.then(result => 'success')
.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:
import { getUniResolver, UniResolver } from '@sphereon/did-uni-client';
const did = 'did:btcr:xz35-jznz-q6mr-7q6';
// Example 1: Use an option to provide an alternatieve resolution URL for bctr method
const didResolutionResult1 = await getUniResolver('bctr', { resolveUrl: 'https://uniresolver.dev.sphereon.com/1.0/identifiers'})
.bctr(did);
// Example 2: Use the standard resolution URL but for method factom
const didResolutionResult2 = await getUniResolver('factom')
.factom(did);
//
// Example 3: Use it together with other drivers and register 2 method:
//
// 2 other drivers
ethrResolver = ethr.getResolver();
webResolver = web.getResolver();
// 2 times the uni-driver but for different DID-methods
uniResolvers = getUniResolvers(['btcr', 'eosio']);
//If you are using multiple methods using the did-resolver pacakge you need to flatten them into one object
const resolver = new Resolver({
...ethrResolver,
...webResolver,
...uniResolvers
})
// Actual resolution
const didResolutionResult3 = await resolver.resolve(did);
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://uniresolver.dev.sphereon.com/1.0/identifiers).
yarn build
The test command runs:
eslintprettierunitcoverageYou can also run only a single section of these tests, using for example yarn test:unit.
yarn 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.FAQs
A Typescript library to create, update, deactivate and resolve DID documents using a Universal Registrar and Universal Resolver
The npm package @sphereon/did-uni-client receives a total of 2,726 weekly downloads. As such, @sphereon/did-uni-client popularity was classified as popular.
We found that @sphereon/did-uni-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.