Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including edu-signer-js with all npm packages installed. Try it out:

var eduSignerJs = require("edu-signer-js")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

edu-signer-js v1.0.2

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free