edu-signer-js

1.0.4 • Public • Published

edu-signer-js

Build Status Coverage Status

A javascript library for digital signature

Browser Support

This library relies on Fetch API. And this API is supported in the following browsers.

Chrome Firefox Opera Safari IE
39+ 42+ 29+ 10.1+ Nope ✘

Dependencies

This library depends on fetch to make requests to the EduSigner. For environments that don't support fetch, you'll need to provide a polyfill to browser or polyfill to Node.

Installation

Get EduSignerWS.

$ npm install edu-signer-js --save

How to use

ES6

// to import a specific method
import EduSigner from 'edu-signer-js';

const signer = new EduSigner({
  licenseKey: 'YOUR_KEY_HERE'
});

// using  method
pki = signer.PKI;
pki.getVersion().then(data => {
  console.log('Version: ' + data.version);
});

CommonJS

const EduSigner = require('edu-signer-js');

const signer = new EduSigner({
  licenseKey: 'YOUR_KEY_HERE'
});

UMD in Browser

<!-- to import non-minified version -->
<script src="edu-signer-js.umd.js"></script>

<!-- to import minified version -->
<script src="edu-signer-js.umd.min.js"></script>

After that the library will be available to the Global as EduSigner. Follow an example:

const signer = new EduSigner({
  licenseKey: 'YOUR_KEY_HERE'
});

pki = signer.PKI;
pki.getVersion().then(data => {
  console.log('Version: ' + data.version);
});

Methods

Follow the methods that the library provides.

pki.getVersion()

Example

  pki.getVersion().then(data => {
    console.log('Version: ' + data.version);
  }).catch(err => {
    window.location.href = 'https://certificaedu.com.br/install'; //Will take to the installation page.
  });

pki.getCertificates()

Example

  pki.getCertificates().then(certs => {
    for (var i = 0; i < certs.length; i++) {
        var cert = certs[i];
        console.log(cert.fingerprint);
        console.log(cert.subject);
        console.log(cert.issuer);
    }
  });

pki.getCertificate()

Example

  pki.getCertificate(thumbprint).then(cert => {
    console.log(cert.thumbprint);
    console.log(cert.subject);
    console.log(cert.issuer);
    console.log(cert.contentBase64);
  });

pki.signedData()

Example

  pki.signedData(thumbprint, data).then(dataSigned => {
    console.log(dataSigned);
  });

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Readme

Keywords

Package Sidebar

Install

npm i edu-signer-js

Weekly Downloads

5

Version

1.0.4

License

MIT

Unpacked Size

379 kB

Total Files

9

Last publish

Collaborators

  • ronaldoaraujo