edu-signer-js
v1.0.4
Published
[![Build Status](https://travis-ci.org/ronaldoaraujo/edu-signer-js.svg?branch=master)](https://travis-ci.org/ronaldoaraujo/edu-signer-js) [![Coverage Status](https://coveralls.io/repos/github/ronaldoaraujo/edu-signer-js/badge.svg?branch=master)](https://c
Downloads
22
Readme
edu-signer-js
A javascript library for digital signature
Browser Support
This library relies on Fetch API. And this API is supported in the following browsers.
| | | | | --- | --- | --- | --- | --- | 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