Natively Pluggable Module

    @identity.com/sol-did-client
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.2 • Public • Published

    SOL DID Client

    A typescript client library for registering and resolving DIDs using the SOL method

    Getting Started

    Command line tool

    yarn global add @identity.com/sol-did-client # or npm install -g @identity.com/sol-did-client
    sol did:sol:ygGfLvAyuRymPNv2fJDK1ZMpdy59m8cV5dak6A8uHKa

    Client library

    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`,
          serviceEndpoint: `https://dummmy.dummy/${did}`,
          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}`,
        type: 'Service',
        serviceEndpoint: `https://service.com/${did}`,
        description: 'Service'
      },
    });
    
    // Remove a service from the DID
    removeService({
      payer: keyPair.secretKey,
      did,
      fragment,
    });

    Contributing

    Note: Before contributing to this project, please check out the code of conduct and contributing guidelines.

    Sol-DID uses nvm and yarn

    nvm i
    yarn

    Running the tests

    Unit tests

    yarn test

    E2E tests

    Install Solana locally by following the steps described here.

    In one shell, run:

    yarn build-program
    yarn start-validator

    In another shell:

    yarn test-e2e

    Keywords

    none

    Install

    npm i @identity.com/sol-did-client

    DownloadsWeekly Downloads

    249

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    841 kB

    Total Files

    57

    Last publish

    Collaborators

    • diosakhilleus
    • chriteixeira
    • rado0x54
    • araptarchis
    • mitchcivic
    • identity.com-ci
    • dankelleher
    • flippiescholtz
    • kevinhcolgan
    • pbshoemaker
    • tyronemichael
    • lucmir
    • william-identity