[Pkg-javascript-commits] [node-keygrip] 30/68: more formatting

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Fri Jun 27 22:13:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-keygrip.

commit f8a83f11584a5f2a6665e92ac8790e52940e6d5f
Author: Jed Schmidt <tr at nslator.jp>
Date:   Mon Jul 9 23:41:30 2012 +0900

    more formatting
---
 README.md | 60 ++++++++++++++++++++++++++++++------------------------------
 test.js   | 38 +++++++++++++++++++-------------------
 2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/README.md b/README.md
index 97ce4c1..243e98a 100644
--- a/README.md
+++ b/README.md
@@ -8,40 +8,40 @@ Keygrip is a [node.js](http://nodejs.org/) module for signing and verifying data
 ## Install
 
     $ npm install keygrip
-    
+
 ## API
 
-### keys = new Keygrip([ keylist ])
+### keys = 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 `npm` installation, and will issue a warning to the console.
 
-Note that the `new` operator is also optional, so all of the following will work when `Keygrip = require( "keygrip" )`:
+Note that the `new` operator is also optional, so all of the following will work when `Keygrip = require("keygrip")`:
 
 ```javascript
 keys = new Keygrip
-keys = new Keygrip([ "SEKRIT2", "SEKRIT1" ])
+keys = new Keygrip(["SEKRIT2", "SEKRIT1"])
 keys = Keygrip()
-keys = Keygrip([ "SEKRIT2", "SEKRIT1" ])
-keys = require( "keygrip" )()
+keys = Keygrip(["SEKRIT2", "SEKRIT1"])
+keys = require("keygrip")()
 ```
-    
+
 The keylist is an array of all valid keys for signing, in descending order of freshness; new keys should be `unshift`ed into the array and old keys should be `pop`ped.
 
 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 )
+### 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 `+` with `-` and `/` with `_`).
 
-### keys.index( data, digest )
+### 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, `-1` is returned.
 
 The idea is that if the index returned is greater than `0`, the data should be re-signed to prevent premature credential invalidation, and enable better performance for subsequent challenges.
 
-### keys.verify( data, digest )
+### keys.verify(data, digest)
 
 This uses `index` to return `true` if the digest matches any existing keys, and `false` otherwise.
 
@@ -49,46 +49,46 @@ This uses `index` to return `true` if the digest matches any existing keys, and
 
 ```javascript
 // ./test.js
-var assert = require( "assert" )
-  , Keygrip = require( "keygrip" )
+var assert = require("assert")
+  , Keygrip = require("keygrip")
   , keylist, keys, hash, index
 
 // keygrip takes an array of keys, but if none exist,
 // it uses the defaults created during npm installation.
 // (but it'll will warn you)
-console.log( "Ignore this message:" )
-keys = new Keygrip( /* empty list */ )
+console.log("Ignore this message:")
+keys = new Keygrip(/* empty list */)
 
 // .sign returns the hash for the first key
 // all hashes are SHA1 HMACs in url-safe base64
-hash = keys.sign( "bieberschnitzel" )
-assert.ok( /^[\w\-]{27}$/.test( hash ) )
+hash = keys.sign("bieberschnitzel")
+assert.ok(/^[\w\-]{27}$/.test(hash))
 
 // but we're going to use our list.
 // (note that the 'new' operator is optional)
-keylist = [ "SEKRIT3", "SEKRIT2", "SEKRIT1" ]
-keys = Keygrip( keylist )
-hash = keys.sign( "bieberschnitzel" )
+keylist = ["SEKRIT3", "SEKRIT2", "SEKRIT1"]
+keys = Keygrip(keylist)
+hash = keys.sign("bieberschnitzel")
 
 // .index returns the index of the first matching key
-index = keys.index( "bieberschnitzel", hash )
-assert.equal( index, 0 )
+index = keys.index("bieberschnitzel", hash)
+assert.equal(index, 0)
 
 // .verify returns the a boolean indicating a matched key
-matched = keys.verify( "bieberschnitzel", hash )
-assert.ok( matched )
+matched = keys.verify("bieberschnitzel", hash)
+assert.ok(matched)
 
-index = keys.index( "bieberschnitzel", "o_O" )
-assert.equal( index, -1 )
+index = keys.index("bieberschnitzel", "o_O")
+assert.equal(index, -1)
 
 // rotate a new key in, and an old key out
-keylist.unshift( "SEKRIT4" )
+keylist.unshift("SEKRIT4")
 keylist.pop()
 
 // if index > 0, it's time to re-sign
-index = keys.index( "bieberschnitzel", hash )
-assert.equal( index, 1 )
-hash = keys.sign( "bieberschnitzel" ) 
+index = keys.index("bieberschnitzel", hash)
+assert.equal(index, 1)
+hash = keys.sign("bieberschnitzel")
 ```
 
 ## TODO
@@ -100,4 +100,4 @@ Copyright
 
 Copyright (c) 2012 Jed Schmidt. See LICENSE.txt for details.
 
-Send any questions or comments [here](http://twitter.com/jedschmidt).
\ No newline at end of file
+Send any questions or comments [here](http://twitter.com/jedschmidt).
diff --git a/test.js b/test.js
index fead072..01ae674 100644
--- a/test.js
+++ b/test.js
@@ -1,41 +1,41 @@
 // ./test.js
-var assert = require( "assert" )
-  , Keygrip = require( "./" )
+var assert = require("assert")
+  , Keygrip = require("./")
   , keylist, keys, hash, index
 
 // keygrip takes an array of keys, but if none exist,
 // it uses the defaults created during npm installation.
 // (but it'll will warn you)
-console.log( "Ignore this message:" )
-keys = new Keygrip( /* empty list */ )
+console.log("Ignore this message:")
+keys = new Keygrip(/* empty list */)
 
 // .sign returns the hash for the first key
 // all hashes are SHA1 HMACs in url-safe base64
-hash = keys.sign( "bieberschnitzel" )
-assert.ok( /^[\w\-]{27}$/.test( hash ) )
+hash = keys.sign("bieberschnitzel")
+assert.ok(/^[\w\-]{27}$/.test(hash))
 
 // but we're going to use our list.
 // (note that the 'new' operator is optional)
-keylist = [ "SEKRIT3", "SEKRIT2", "SEKRIT1" ]
-keys = Keygrip( keylist )
-hash = keys.sign( "bieberschnitzel" )
+keylist = ["SEKRIT3", "SEKRIT2", "SEKRIT1"]
+keys = Keygrip(keylist)
+hash = keys.sign("bieberschnitzel")
 
 // .index returns the index of the first matching key
-index = keys.index( "bieberschnitzel", hash )
-assert.equal( index, 0 )
+index = keys.index("bieberschnitzel", hash)
+assert.equal(index, 0)
 
 // .verify returns the a boolean indicating a matched key
-matched = keys.verify( "bieberschnitzel", hash )
-assert.ok( matched )
+matched = keys.verify("bieberschnitzel", hash)
+assert.ok(matched)
 
-index = keys.index( "bieberschnitzel", "o_O" )
-assert.equal( index, -1 )
+index = keys.index("bieberschnitzel", "o_O")
+assert.equal(index, -1)
 
 // rotate a new key in, and an old key out
-keylist.unshift( "SEKRIT4" )
+keylist.unshift("SEKRIT4")
 keylist.pop()
 
 // if index > 0, it's time to re-sign
-index = keys.index( "bieberschnitzel", hash )
-assert.equal( index, 1 )
-hash = keys.sign( "bieberschnitzel" )
\ No newline at end of file
+index = keys.index("bieberschnitzel", hash)
+assert.equal(index, 1)
+hash = keys.sign("bieberschnitzel")

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-keygrip.git



More information about the Pkg-javascript-commits mailing list