tokener
v1.1.1
Published
generate and verify signed tokens with expiration dates
Downloads
4
Readme
Tokener
Generate and verify ephemeral tokens.
The inspiration behind this API comes from here.
Instantiation
var tokener = require("tokener");
// Signing key is required, everything else is optional
var signer = tokener("SIGNING KEY HERE", {
algorithm: "sha1", // from crypto module
msValid: 86400000, // 1 day is default (milliseconds!)
throwOnError: false // can change verify method to throw
});
Signing
var token = signer.create("some data to sign");
Verification
var data = signer.verify(token); // this will throw when throwOnError is true
if ( data instanceof Error ) {
// uh-oh, token could NOT be verified, or was expired
}
else {
// we're good!
}