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

ridl-js

v1.0.4

Published

RIDL is a multi-chain reputation and identity layer which promotes on-chain reputing of entities. This library is a simple wrapper around the RIDL API which is used to allow EOSIO contracts to not require users to have EOSIO accounts (public key pinning

Downloads

10

Readme

RIDL JS

RIDL is a multi-chain reputation and identity layer which promotes on-chain reputing of entities. This library is a simple wrapper around the RIDL API which is used to allow EOSIO contracts to not require users to have EOSIO accounts (public key pinning).

Instantiation

Nodejs

  • npm: npm i -S ridl-js
  • yarn: yarn add ridl-js
const RidlJS = require('ridl-js');

// https://github.com/EOSIO/eosjs-ecc/
const signer = hash => ecc.signHash(hash, someKey);

const ridl = RidlJS(signer);

Browser

// Just copy `index.js` to your project and rename it.
<script src="./ridl.js"></script>

... same as above

Methods

Valid Name

Checks if a username is valid.

if(ridl.validName(username)){ ... }

Get Chains

Gets a list of the currently used chains for RIDL

const chains = await ridl.chains();
// ['chain_id1', 'chain_id2',]

Get Hosts

Gets a list of the currently used hosts for a chain

const hosts = await ridl.hosts(chain);
// ['https://node.com']

Add host

This method is turned off on the API for now.

Suggest a node/host to be added for a chain. Specific requirements for this method will be posted here when it is live.

const options = {
    logic_contract:'ridlridlridl',
    token_contract:'ridlridltkns',
    sender_account:'ridlridlsend',
    creator_account:'ridlridluser',
};

const added = await ridl.addHost(chain_id, host, options);

Find Identity

Finds an identity by username.

You should be doing this to find the identity's id and chain before calling repute() or changekey().

const identity = await ridl.findIdentity(username);

Find Reputation

Finds a reputation by entity.

const entity = 'contract::eosio.token';
const identity = await ridl.findReputation(entity);

Register Identity

Finds a reputation by entity.

const result = await ridl.identify(username, publicKey);
if(result && result.success) ...
else console.error(result);

Change Identity Key

Finds a reputation by entity.

const result = await ridl.changekey(identity.id, new_public_key, identity.chain);
if(result && result.success) ...
else console.error(result);

Apply Reputation

Finds a reputation by entity.

const entity = 'contract::ridlridlridl';
const fragments = [{type:'testing', value:1}];
const tokens = '1.0000 RIDL';
const details = 'I think this contract is awesome!';

const result = await ridl.repute(identity.id, entity, fragments, tokens, identity.chain, details);
if(result && result.success) ...
else console.error(result);

Special notes about changekey and repute.

Both of these methods can also take a block_num and sig parameter (always the last two params). These are used to sign a proofing hash which the smart contracts use to make sure no parameters were tampered with. This library does it by default when a block_num is null, but you can do it yourself like so:

// For `changekey(..., block_num, sig)`
const sig = ecc.signHash(sha256(`${identity.id}:${entity}:${block_num}:${key}`), privateKey);

// For `repute(..., block_num, sig)`
const sig = ecc.signHash(sha256(`${identity.id}:${entity}:${block_num}:${fragments.map(x => `${x.type}${x.value}`).join('')}:${tokens}`), privateKey);

The block_num must be within range of the current head_block_num on chain within a 10 block radius.