1.0.4 • Published 2 years ago

edu-signer-js v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

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.

ChromeFirefoxOperaSafariIE
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

1.0.4

2 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.0

6 years ago