Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@suku/doc-auth-lib

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@suku/doc-auth-lib

## Usage as a library The document authenticator ships as an npm package. It can be used as a library but requires the document authenticator smart contract to be deployed to the blockchain that the doc-auth-lib is interacting with.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

SUKU Doc Authenticator Lib

Usage as a library

The document authenticator ships as an npm package. It can be used as a library but requires the document authenticator smart contract to be deployed to the blockchain that the doc-auth-lib is interacting with.

NPM Install

To install the document authenticator in your NodeJS project, one can use the official SUKU NPM Repo (access required) or a git based install.

If you have access to the official NPM repo, you the following command to install the library.

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

If you don't have access to the official NPM repo, you can still install the document authenticator from github. You will need to create a personal access token for the git command line. Please see this guide. Use the following command:

npm i --save https://{your-github-token}@github.com/SukuLab/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.
import deployDocAuth from '@suku/doc-auth-lib/dist/deploydocauthenticator';

const nodeUrl = "HTTP://xyz";
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, // nodeUrl
        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, // nodeUrl
        receipt.contractAddress, // contractAddress
        privateKey // private key that is used for signing
    );

let docProof = docauth.readProof(buffer);

FAQs

Package last updated on 05 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc