Recommend this page to a friend! |
Classes of Igor Escobar | Terminal Crossword | twitter-streaming/node_modules/ntwitter/node_modules/keygrip/README.md | Download |
|
|
DownloadKeygripKeygrip is a node.js module for signing and verifying data (such as cookies or URLs) through a rotating credential system, in which new server keys can be added and old ones removed regularly, without invalidating client credentials. Install
APIkeys = new Keygrip([ keylist ])This creates a new Keygrip based on the provided keylist, an array of secret keys used for SHA1 HMAC digests. If no list is given, or the list is empty, Keygrip uses the default key created during Note that the
The keylist is an array of all valid keys for signing, in descending order of freshness; new keys should be The tradeoff here is that adding more keys to the keylist allows for more granular freshness for key validation, at the cost of a more expensive worst-case scenario for old or invalid hashes. Keygrip keeps a reference to this array to automatically reflect any changes. This reference is stored using a closure to prevent external access. keys.sign( data )This creates a SHA1 HMAC based on the _first_ key in the keylist, and outputs it as a 27-byte url-safe base64 digest (base64 without padding, replacing keys.index( data, digest )This loops through all of the keys currently in the keylist until the digest of the current key matches the given digest, at which point the current index is returned. If no key is matched, The idea is that if the index returned is greater than keys.verify( data, digest )This uses Example
TODO
CopyrightCopyright (c) 2012 Jed Schmidt. See LICENSE.txt for details. Send any questions or comments here. |