npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eosio-did

v0.1.2

Published

Create, resolve, update and deactivate Decentralized Identifier (DID) documents based on EOSIO blockchains

Downloads

5

Readme

Contributions

The EOSIO Identity Working Group is an open working group where we, the EOSIO community, discuss identity on EOSIO chains and progress work such as this DID specification and it's implementation. We have a weekly meeting and a Slack channel.

Join the EOSIO Identity Working Group

Comments regarding this document are welcome. Please file issues and PRs directly on Github. Contributors are recognized through adding commits to the code base.

See README.tsdx.md for instructions on how to run, build, test and test this library.

Contributors:

EOSIO DID

This library is intended to use EOSIO accounts as fully self managed Decentralized Identifiers and wrap them in a DID Document

It supports the proposed Decentralized Identifiers spec from the W3C Credentials Community Group.

The DID specification can be found at eosio-did-spec.

DID Create

const eosioDid = new EosioDID({
    chain: 'eos:testnet:jungle',
    signatureProvider: new JsSignatureProvider(['PVT_K1_27yS4sdX86VDahQRABMLCcDABH5Vzy8vgLLS7wBeKESyrXetMf'])
});
const myPermission = {
    threshold: 1,
    keys: [{
        key: 'PUB_K1_5irHomACLB3oRbkqdgYTdh1GHGt8yvzQ7no5dxvEw5eYAiUiut',
        weight: 1,
    }],
    accounts: [],
    waits: [],
};

// "didtester333" account creates a new account called "newaccount11" with the owner and active permission set to "mypermission"
// on the Jungle testnet
const didCreateResult = await eosioDid.create('didtester333', 'newaccount11', myPermission, myPermission);

DID Resolve

const eosioDid = new EosioDID();

// resolves the "didtester333" account on the Jungle testnet account to a DID Document
const didResolveResult = await eosioDid.resolve('did:eosio:eos:testnet:jungle:didtester333');

DID Update

const eosioDID = new EosioDID({
    account: 'didtester333',
    signatureProvider: new JsSignatureProvider(['PVT_K1_27yS4sdX86VDahQRABMLCcDABH5Vzy8vgLLS7wBeKESyrXetMf']),
    chain: 'eos:testnet:jungle'
});

const myNewPermission = {
    threshold: 1,
    keys: [{
        key: 'PUB_K1_5irHomACLB3oRbkqdgYTdh1GHGt8yvzQ7no5dxvEw5eYAiUiut',
        weight: 1,
    }],
    accounts: [],
    waits: [],
};

// "didtester333" changes it's "active" permission to the "myNewPermission" on the Jungle testnet
const didUpdateResult = await eosioDID.update('didtester333', 'active', 'owner', myNewPermission);

DID Deactivate

Note: DID Deactive always throws an error as it is not supported by default on an EOSIO chain. See the EOSIO DID Spec for more information.

const eosioDID = new EosioDID({
    account: 'didtester333',
    signatureProvider: new JsSignatureProvider(['PVT_K1_27yS4sdX86VDahQRABMLCcDABH5Vzy8vgLLS7wBeKESyrXetMf']),
    chain: 'eos:testnet:jungle'
});

// Will throw an error
await eosioDID.deactivate('did:eosio:eos:testnet:jungle:didtester333');

Conficuration

All function calls (create, resolve, update, deactivate) can be called with an optional options argument with the following optional properties:

{
  chain?: string;
  fetch?: any;
  account?: string;
  signatureProvider?: SignatureProvider;
  accountPermission?: string;
  registry?: ChainRegistry;
  transactionOptions?: {
    blocksBehind?: number;
    expireSeconds?: number;
  };
}

chain - the chain id or the registered chain name (see the DID method schema part of the EOSIO DID spec). This must be provided to know which chain to contact and a corresponding item in the eosio-did-chain-registry.json or registry property must exist e.g. eos:testnet:jungle telos 4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11 fetch - fetch object used to communicate with the eosio API. If using nodejs then you need to import the node-fetch npm package and use this. See the eosjs documentation for more details. signatureProvider - the SignatureProvider object that will be used to sign txs accountPermission - the permission name that will be used to send txs registry - additional ChainRegisries that are used to find the API endpoints of the eosio API. This should be used when communicating with EOSIO blockchain nodes that have not been registed in the eosio-did-chain-registry.json transactionOptions - overrides the tx options when the tx is sent. See the eosjs documentation for more details.

Create configuration

The create function can be called with the following additional optional properties:

{
  buyrambytes?: number;
  stakeNetQuantity?: string;
  stakeCpuQuantity?: string;
  transfer?: boolean;
}

buyrambytes - amount of RAM to allocate to the new account in bytes (default = 8192) stakeNetQuantity - amout of NET to stake to the new account (default = "1.0000 EOS") stakeCpuQuantity - amount of CPU to stake to the new account (default = "1.0000 EOS") transfer - transfer the ownership of the staked tokens to the new account (default = false)

Error handling

All function calls (create, resolve, update, deactivate) return an object containing an errors encountered. They do not throw errors.

For example

const didResolveResult = await eosioDid.resolve('did:eosio:invalid_did_string');
// This will NOT throw an error

console.log(didResolveResult);
/*
{
    didResolutionMetadata: { 'invalidDid' },
    didDocument: null,
    didDocumentMetadata: {},
}
*/