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

lblod-blockchain

v2.0.1

Published

Proof of concept rond Lokale Besluiten als Gelinkte Open Data – centrale vindplaats en mandatendatabank.

Downloads

5

Readme

LBLOD

Proof of concept rond Lokale Besluiten als Gelinkte Open Data – centrale vindplaats en mandatendatabank.

Repo structure

  • dist: this contains the transpiled version of the repo
  • src: this contains the actual code
    • utils
      • api
        • apiService: exposing all services
        • identityService: all interactions with identities
        • queryService: all interactions with queries
        • transaction: all transaction implementations
      • connection: class to instantiate a connection
      • ErrorMessages: export for all error messages
      • lblod: main package exposing all functionalities
      • wallets: all possible wallets
    • index: exporting of the package

Features

  • Creating a connection to the Rest API
  • Publishing a certain asset (Besluit) to the HLF network
  • Signing (voting) for a certain asset (Besluit) and register this action on the network
  • Validating/Compare an existing asset on the network with a given asset
  • Getting a certain asset by asset Id

Requirements

LBLOD Blockchain PoC API References

Getting started

First you need to get lblod into your project. This can be done using the following methods:

  • npm: npm install lblod-blockchain
  • bower: bower install lblod-blockchain
  • meteor: meteor add vo-blockchain:lblod-blockchain
  • vanilla: link the dist/index.js

LBLOD constructor

Parameters
  1. String - The token to the rest API (Obtained through the network admin)
  2. String - The baseURL to the Rest API (Obtained through the network admin)
  3. Boolean - Indicator whether development mode is enabled or not
Returns

LBLOD-Blockchain instance on which you can call any function specified below.

Example
import LBLOD from 'lblod-blockchain';

const lblod = new LBLOD('my-api-token', 'api-base-url', false);

publishBesluit

Parameters
  1. String - The id of the besluit (Uri typically)
  2. String - The besluit which should be hashed (Object must be able to be stringified)
Returns

Promise - Returns the transactionId of the publication on the blockchain

Example
import LBLOD from 'lblod-blockchain';

// besluit MUST be processable by a stringifier and should be a JSON file
const myBesluit = besluit.toJSON();

const lblod = new LBLOD('my-api-token', 'api-base-url', false);
const txId = await lblod.publishBesluit('my-besluit-id', myBesluit);

signBesluit

Parameters
  1. boolean - The choice which is made (true = authenticate, false = burn)
  2. String - The transactionId return from the function "publishBesluit" within this package
  3. String - The assign signer to perform the action on. Signers are obtained through the wallets export
Returns

Promise - Returns the transactionId of the sign action on the blockchain

Example
import LBLOD, { wallets } from 'lblod-blockchain';

// besluit MUST be processable by a stringifier and should be a JSON file
const myBesluit = besluit.toJSON();

// I choose to AUTHENTICATE the asset. True = Authenticate, False = Burn
const myChoice = true;

const lblod = new LBLOD('my-api-token', 'api-base-url', false);
const txId = await lblod.publishBesluit('my-besluit-id', myBesluit);

const result = await lblod.signBesluit(choice, txId, wallets.signer);

validateBesluit

Parameters
  1. txId - The transactionId return from the function "publishBesluit" within this package
  2. String - The besluit which should be hashed and compared to the original besluit (Object must be able to be stringified)
Returns

Promise - Returns a promise with True or False depending on the comparing results

Example
import LBLOD from 'lblod-blockchain';

// besluit MUST be processable by a stringifier and should be a JSON file
const myBesluit = besluit.toJSON();

// fakeBesluit MUST also be processable by a stringifier and should be a JSON file.
// This process should be the EXACT same operations as the process which
// the original published besluit went through to be able to replicate the same hash and result
const myFakeBesluit = fakeBesluit.toJSON();

const lblod = new LBLOD('my-api-token', 'api-base-url', false);
const txId = await lblod.publishBesluit('my-besluit-id', myBesluit);

const result = await lblod.validateBesluit(txId, myFakeBesluit);
console.log('Is myFakeBesluit tampered? ', result);

Full implementation example

This is an example of a service layer in your frontend application which implements all functionalities of this NPM package.

import LBLOD, { wallets }  from 'lblod-blockchain';

export default class hlfService {

  constructor(token){
    this.lblod = new LBLOD(token);
  }

  publishBesluit = (besluitId, besluit) => {
    return this.lblod.publishBesluit(besluitId, besluit, wallets.publisher);
  };

  sign = (choice, txId, signer) => {
    return this.lblod.signBesluit(choice, txId, signer);
  };

  validate = (txId, besluit) => {
    return this.lblod.validateBesluit(txId, besluit);
  };

  getAssetById = (txId) => {
    return this.lblod.getBesluitById(txId);
  };
}

Important note
- This is project is not intended to be used in any production environment as this is a Proof Of Concept and is not ready for production.
- As identity management is out of the scope of this project, all identities are handled in this package. This is NOT applicable for production and MUST be refactored
- Error handling is not included in the code examples, but don't forget to implement these with the proper try-catches or when using .then chaining, with .catch