A typescript client library for registering and resolving DIDs using the SOL method
npm install @identity.com/sol-did-client-legacyA typescript client library for registering and resolving DIDs using the SOL method
``shell`
yarn global add @identity.com/sol-did-client # or npm install -g @identity.com/sol-did-client
sol did:sol:ygGfLvAyuRymPNv2fJDK1ZMpdy59m8cV5dak6A8uHKa
`js
import {
register,
resolve,
addKey,
removeKey,
addController,
removeController,
addService,
removeSerice
} from '@identity.com/sol-did-client';
// generate an X25519 key, eg using 'tweetnacl'
import nacl from 'tweetnacl';
const keyPair = nacl.sign.keyPair();
// register a DID
const did = await register({
payer: keyPair.secretKey,
});
// resolve a DID
const document = await resolve(did);
// update a DID
const request = {
payer: keyPair.secretKey,
did,
document: {
service: [{
description: 'Messaging Service',
id: ${did}#service1,https://dummmy.dummy/${did}
serviceEndpoint: ,
type: 'Messaging',
}],
},
};
await update(request);
// deactivate a DID
await deactivate({
payer: keyPair.secretKey,
did,
});
// Add a key to the DID
addKey({
payer: keyPair.secretKey,
did,
fragment: 'ledger',
key
});
// Remove a key from the DID
removeKey({
payer: keyPair.secretKey,
did,
fragment: 'ledger',
});
// Add a controller to the DID
addController({
payer: keyPair.secretKey,
did,
controller,
});
// Remove a controller from the DID
removeController({
payer: keyPair.secretKey,
did,
controller,
});
// Add a service to the DID
addService({
payer: keyPair.secretKey,
did,
service: {
id: ${did}#${fragment},https://service.com/${did}
type: 'Service',
serviceEndpoint: ,
description: 'Service'
},
});
// Remove a service from the DID
removeService({
payer: keyPair.secretKey,
did,
fragment,
});
`
Note: Before contributing to this project, please check out the code of conduct and contributing guidelines.
`shell`
nvm i
yarn
`shell`
yarn test
Install Solana locally by following the steps described here.
In one shell, run:
`shell`
yarn build-program
yarn start-validator
In another shell:
`shell``
yarn test-e2e