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

@suku/doc-auth-lib

v2.1.0

Published

This is the SUKU Blockchain Document Authenticator Library. It can be used to write blockchain proofs (signed hashes) of files to the blockchain. It expects a deployed version of the [SUKU Ethereum Node API](https://github.com/SukuLab/suku-ethereum-node-a

Downloads

21

Readme

SUKU Blockchain Document Authenticator Library

This is the SUKU Blockchain Document Authenticator Library. It can be used to write blockchain proofs (signed hashes) of files to the blockchain. It expects a deployed version of the SUKU Ethereum Node API.

Usage as a library

Note: Before you start, please make sure that you need a deployed version of SUKU Ethereum Node API.

The document authenticator ships as an npm package. It requires the document authenticator smart contract to be deployed to the blockchain.

This package uses SUKU Ethereum Node API Client Lib to connect to an instance of SUKU Ethereum Node API.

NPM Install

@suku/doc-auth-lib is available as an NPM Package.

Use the following command to install the library.

npm i --save @suku/doc-auth-lib

Prep: Contract Deployment

The Doc Authenticator requires a contract that needs to be deployed to the blockchain. If the contract has already been deployed to your network, please skip this section.

If you still need to deploy the contract, you can deploy it manually or use our deploymenty script.

Manual Deployment

To deploy the contract manually, copy the smart contract code from ./blockchain/contracts/Docauth.sol. Use Remix and MetaMask to deploy the contract to your network. Connect remix to the network of your choice. We recommend Ganache for test purposes.

Automatic Deployment

The document authenticator comes with a helper script that allows for flexible deployment.

  1. Import the deployment script from the library
  2. Use the deployDocAuth(nodeUrl, privateKey) function to deploy the smart contract to your blockchain.
  3. As nodeURL use the URL of a running instance of SUKU Ethereum Node API.
  4. As privateKey specify a private key that is able to send transactions on the Ethereum node that your API instance is connected to. Make sure that this private key has sufficient gas to send transactions.
import deployDocAuth from '@suku/doc-auth-lib/dist/deploydocauthenticator';

const nodeUrl = "HTTP://xyz"; // SUKU Ethereum Node API instance
const privateKey = "abc"; 

deployDocAuth(nodeUrl,privateKey)
.then( async receipt => {
    logger.info("Contract deployed. Contract address: " + receipt.contractAddress);
});

Importing the library

The import depends on you ECMAScript version.

For ECMAScript <= ES5 (CommonJS require())

const docAuthLibrary = require('@suku/doc-auth-lib');

For ECMAScript >= ES6 (import)

import DocAuthenicator from '@suku/doc-auth-lib';

Adding a Proof

CommonJS Example:

const docAuthLibrary = require('@suku/doc-auth-lib');

let docauth = new docAuthLibrary.default(
        nodeUrl, // SUKU Ethereum Node API instance
        receipt.contractAddress, // contractAddress
        privateKey // private key that is used for signing
    );

let proofReceipt = await docauth.addProof(fileBuffer, uid);
let docHash = proofReceipt.docHash;
let txReceipt = proofReceipt.txReceipt;

Reading a Proof

CommonJS Example:

const docAuthLibrary = require('@suku/doc-auth-lib');

let docauth = new docAuthLibrary.default(
        nodeUrl, // SUKU Ethereum Node API instance
        receipt.contractAddress, // contractAddress
        privateKey // private key that is used for signing
    );

let docProof = docauth.readProof(buffer);