0.17.42 • Published 9 months ago

@evo/vchasno-signer v0.17.42

Weekly downloads
290
License
ISC
Repository
gitlab
Last release
9 months ago

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

0.17.42

9 months ago

0.17.39

12 months ago

0.17.41

11 months ago

0.17.40

11 months ago

0.17.38

1 year ago

0.17.37

1 year ago

0.17.36

1 year ago

0.17.35

1 year ago

0.17.34

1 year ago

0.17.33

1 year ago

0.17.32

1 year ago

0.17.31

1 year ago

0.17.30

2 years ago

0.17.29

2 years ago

0.17.28

2 years ago

0.17.19

2 years ago

0.17.21

2 years ago

0.17.20

2 years ago

0.17.23

2 years ago

0.17.22

2 years ago

0.17.25

2 years ago

0.17.24

2 years ago

0.17.27

2 years ago

0.17.26

2 years ago

0.17.14

2 years ago

0.17.16

2 years ago

0.17.15

2 years ago

0.17.18

2 years ago

0.17.17

2 years ago

0.17.13

2 years ago

0.17.7

3 years ago

0.17.8

3 years ago

0.17.9

3 years ago

0.17.10

3 years ago

0.17.12

2 years ago

0.17.11

2 years ago

0.17.4

3 years ago

0.17.5

3 years ago

0.17.6

3 years ago

0.17.2

3 years ago

0.17.3

3 years ago

0.17.1

3 years ago

0.17.0

3 years ago

0.15.8

3 years ago

0.16.0

3 years ago

0.15.7

4 years ago

0.15.4

4 years ago

0.15.5

4 years ago

0.15.6

4 years ago

0.15.3

4 years ago

0.15.1

4 years ago

0.15.2

4 years ago

0.15.0

4 years ago

0.14.1

4 years ago

0.14.0

4 years ago

0.13.3

4 years ago

0.13.0

4 years ago

0.13.1

4 years ago

0.13.2

4 years ago

0.12.0

4 years ago

0.11.3

4 years ago

0.11.2

5 years ago

0.11.1

5 years ago

0.11.0

5 years ago

0.10.4

5 years ago

0.10.3

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.8

5 years ago

0.9.7

5 years ago

0.9.6

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.6

6 years ago

0.7.4

6 years ago

0.7.2

6 years ago

0.7.0

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.6.0-0

6 years ago

0.5.11

6 years ago

0.5.10

6 years ago

0.5.8

7 years ago

0.5.6

7 years ago

0.5.5

7 years ago

0.5.4

7 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.0

7 years ago

0.4.13

7 years ago

0.4.14

7 years ago

0.4.12

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.4.0-beta.1

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.20

8 years ago

0.1.19

8 years ago

0.1.18

8 years ago

0.1.17

8 years ago

0.1.16

8 years ago

0.1.15

8 years ago

0.1.14

8 years ago

0.1.13

8 years ago

0.1.12

8 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago