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

@evo/vchasno-signer

v0.17.42

Published

Sign module for Vchasno project

Downloads

1,020

Readme

Vchasno Signer

Library to work with private keys, sign data and verify signatures.

Instalation

npm install -E @evo/vchasno-signer

Usage

import vchasnoSigner from '@evo/vchasno-signer';

// Minimal config for signer, more details you can find in config object section
const configObject = { proxyServiceUrl: '/internal-api/proxy' };

// Initialize signer
await vchasnoSigner.init(configObject);

// Read private key
const key = await vchasnoSigner.readKey(keyFile, password, caServerIdx, certificateFiles);

// Sign data
const eSign = vchasnoSigner.signData(data, key);

// Verify signature
const signInfo = vchasnoSigner.verifySign(data, eSign);

Config object

{
    // Allow to use only power certificates, default is true
    checkIsPowerCertificate: true,
    // Download internal sign library from specific url. If not specified, library
    // will be downloaded from Vchasno servers
    downloadSignLibraryUrl: null,
    // Max data size to work with in bytes, library will take 10x size in memory.
    // *Implicit* default value is 5Mb for desktop and 2Mb for mobile
    maxFileSize: undefined,
    // By default path to library is `/js/lib/iit`, but you can specify your own path
    pathToLibrary: '/path/to/library',
    // To work library need proxy service in your backend.
    // Library send a POST request to proxy service url with address in GET parameter
    // and data string in body. Backend needs to make a request to this address with
    // data string and return received data to the library
    proxyServiceUrl: '/internal-api/proxy',
    // By default library will use Web Workers if supported, but you can force it
    // by setting useMainThread = true
    useMainThread: false,
}

Read private key

Read PK file to get key object with PK content, associated certificates, information about PK and actual certificate.

Parameters:

  • keyFile: PK file in Blob format
  • password: PK password
  • caServerIdx: PK vendor, you can get list of supported CA servers with getCAServers function
  • certificateFiles: optional parameter, some CA use certificates from file, so we need to pass PK file and associated certificates file/files. You can use getCAServerSettings function to find out which certificates type are used.
// List of supported CA servers
const caServers = vchasnoSigner.getCAServers();

// CA server settings
const caServerSettings = vchasnoSigner.getCAServerSettings(caServers[idx]);
caServerSettings.loadCertsFromFile;  // true - need to pass associated certificates, false - certificates will be found in CA servers

// Read PK
const key = await vchasnoSigner.readKey(keyFile, password, caServerIdx, certificateFiles);
key.keyData //content of PK
key.password //PK password
key.certificates //PK associated certificates
key.keyInfo //information about PK owner
key.certificateInfo //information about actual associated certificate

Sign data

Sign data with PK, verify signature and return signature object.

Parameters:

  • data: data to sign in Blob, ArrayBuffer, or Uint8Array format
  • key: key object from readKey function
const eSign = vchasnoSigner.signData(data, key);

Also data can be signed internaly in p7s container

const [eSign, p7s] = vchasnoSigner.signDataInternal(data, key);

Verify signature

Verify association between data and signature, return information about signature.

Parameters:

  • data: data to sign in Blob, ArrayBuffer or Uint8Array format
  • eSign: signature string from signData function
const signInfo = vchasnoSigner.verifySign(data, eSign);

For internal signatures need to pass only p7s container.

Parameters:

  • p7s: p7s container from signDataInternal function
const signInfo = vchasnoSigner.verifySignInternal(p7s);

For library developers

Autodeploy

To deploy new version:

npm version <patch|minor|major>
git push origin --atomic HEAD v0.0.1

Update certificates

  1. Update CAs.json, CACertificates
    • Docker with just
      # buid container if needed
      just docker-build-image
      # update certificates
      just docker-update-ca-servers
    • Node
      wget --output-document ./scripts/rawCAs.json https://iit.com.ua/download/productfiles/CAs.json
      wget --output-document ./src/files/CACertificates.p7b https://iit.com.ua/download/productfiles/CACertificates.p7b
      
      node scripts/generateCAServers.js
  2. Add new tag