message-verifier
v0.2.1
Published
Makes it easy to generate and verify messages which are signed to prevent tampering
Downloads
2
Readme
message-verifier
Makes it easy to generate and verify messages which are signed to prevent tampering.
This is useful for cases like remember-me tokens and auto-unsubscribe links where the session store isn't suitable or available.
Usage
import MessageVerifier from 'message-verifier';
let secret = `Hey, I'm a secret!`;
let verifier = new MessageVerifier(secret, options);
// Generate token:
let token = verifier.generate([user.id, twoWeeksFromNow])
// In the authentication filter:
let [id, time] = verifier.verify(token);
if (time < Date.now()) {
let user = User.find(id);
}