[Pkg-javascript-commits] [node-keygrip] 01/68: first commit, code coming.
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Fri Jun 27 22:13:23 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 ea228fc58fdb1e1b41e70343cc6b1d736dd4bf2e
Author: Jed Schmidt <tr at nslator.jp>
Date: Fri Feb 25 15:14:06 2011 +0900
first commit, code coming.
---
LICENSE.txt | 20 ++++++++++++++++++++
README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
package.json | 6 ++++++
3 files changed, 79 insertions(+)
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..a612d47
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Jed Schmidt, http://jedschmidt.com/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..957824b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,53 @@
+cookie-node.js
+============
+
+`cookie-node` is a cookie module for [node.js](http://nodejs.org/), based
+loosely on Tornado's approach to [signed cookies](http://www.tornadoweb.org/documentation#cookies-and-secure-cookies).
+
+To start, require the library in your app:
+
+ var cookie = require( "./cookie-node" );
+
+This extends the `ServerRequest` and `ServerResponse` objects, allowing you to
+get cookies on requests and set them on responses for server calls:
+
+ function( req, res ) {
+ var name = req.getCookie( "name" ),
+ length = name.length;
+
+ res.setCookie( "name_length", length );
+
+ res.writeHead(200, {"Content-Type": "text/html"});
+ res.write( "Your name has " + length + " characters." );
+ res.close();
+ }
+
+You can also set a cookie secret to enable signed cookies, and prevent forged
+cookies:
+
+ cookie.secret = "myRandomSecretThatNoOneWillGuess";
+
+so that the above becomes:
+
+ function( req, res ) {
+ var name = req.getSecureCookie( "name" ),
+ length = name.length;
+
+ res.setSecureCookie( "name_length", length );
+
+ res.writeHead(200, {"Content-Type": "text/html"});
+ res.write( "Your name has " + length + " characters." );
+ res.close();
+ }
+
+(You don't need to set the secret, but your cookies will end up being
+invalidated when the server restarts, and you will be yelled at.)
+
+When you set a secure cookie, the value is stored alongside its expiration
+date, as well as an HMAC SHA-1 digest of the two values with your secret. If a
+cookie's signature does not match that calculated on the server, the
+`getSecureCookie` method throws.
+
+If you'd like to clear a cookie, just use `res.clearCookie( name )`.
+
+That's about it. Send any questions or comments [here](http://twitter.com/jedschmidt).
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..5f6887b
--- /dev/null
+++ b/package.json
@@ -0,0 +1,6 @@
+{ "name" : "keygrip"
+, "version" : "0.1.0"
+, "description" : "Key signing and verification for rotated credentials"
+, "main" : "./index"
+, "engines": [ "node" ]
+}
\ No newline at end of file
--
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