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

opensig-js

v0.1.4

Published

OpenSig javascript library for publishing digital signatures to EVM-based blockchains.

Downloads

11

Readme

opensig-js

Javascript e-signature library for digitally signing and verifying files on EVM-based blockchains using the OpenSig standard. See https://opensig.net/about.

Also supports public and private notarisation to the blockchain.

Installation

Browser

<script src="https://cdn.jsdelivr.net/gh/opensig/opensig-js/dist/opensig-js.js"></script>

Node.js

npm install opensig-js

Usage

Browser

// Construct a blockchain provider (see opensig.providers)

const provider = new window.opensig.providers.MetamaskProvider({
  chainId: 1,
  name: "Ethereum",
  contract: "0x73eF7A3643aCbC3D616Bd5f7Ee5153Aa5f14DB30", 
  blockTime: 12000,
  creationBlock: 16764681
});


// Construct an OpenSig Document object from a File 
// (or construct one from a hash - see Document Class below)

const myDoc = new window.opensig.File(provider, new File('./myfile.txt'));


// Verify signatures on the blockchain

const signatures = await myDoc.verify();

signatures.forEach(sig => console.log(sig.time, sig.signatory, sig.data));


// Sign using Metamask

const signData = {
  type: 'string',
  encrypted: true,
  content: 'some data'
};

const result = await myDoc.sign(signData);

console.log(result.txHash, result.signatory, result.signature);

const receipt = await result.confirmationInformer;

console.log('signature published successfully', receipt));

Node.js

import * as opensig from 'opensig-js';

import MetaMaskSDK from '@metamask/sdk';


const MMSDK = new MetaMaskSDK(options);

const ethereumProvider = MMSDK.getProvider();


// Construct a blockchain provider (see opensig.providers)

const provider = new opensig.providers.MetamaskProvider({
  chainId: 1,
  name: "Ethereum",
  contract: "0x73eF7A3643aCbC3D616Bd5f7Ee5153Aa5f14DB30", 
  blockTime: 12000,
  creationBlock: 16764681,
  ethereum: ethereumProvider,
});

...

Document Class

The Document class is an alternative to the File class. It takes a pre-determined document hash instead of a file.

const myDocHash = ...

const myDoc = new opensig.Document(provider, myDocHash);

const signatures = await myDoc.verify();
...

Blockchain Providers

Blockchain providers publish sign transactions to the blockchain and query the blockchain for signatures using whatever transport protocol is appropriate.

Implement your own or use one of the bundled providers. See src/providers.js for the BlockchainProvider interface.

OpenSig is bundled with 3 types of provider accessed via opensig.providers. At this time all three use Metamask to sign signature transactions but use different services to query the blockchain for signatures:

MetamaskProvider - Uses the local Metamask wallet to query the blockchain for signatures and to sign transactions.

HTTPProvider - Uses a web3 http provider to query the blockchain for signatures. Uses the local Metamask wallet to sign and publish transactions.

AnkrProvider - Uses the Ankr network to query the blockchain for signatures. Uses the local Metamask wallet to sign and publish transactions.

Parameters

A BlockchainProvider takes the following parameters:

  • chainId - blockchain's chain id
  • name - label
  • contract - address of that blockchain's Registry Contract (see https://opensig.net/about#contracts)
  • blockTime - the network block time in ms
  • creationBlock - the registry contract's creation block number (minimises search window when querying for signatures)

MetamaskProvider extends BlockchainProvider and takes in addition:

  • ethereum - optional Metamask ethereum provider. Defaults to window.ethereum

HTTPProvider extends MetamaskProvider and takes in addition:

  • url - url of the http service, e.g. Infura

AnkrProvider extends MetamaskProvider and takes in addition:

  • endpoint - url of the Ankr network endpoint, e.g. https://rpc.ankr.com/multichain