Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

edu-signer-js

1.0.2 • 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

install

npm i edu-signer-js

Downloadsweekly downloads

2

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability