Permalink
Browse files

whitespace - 2 space indenting

  • Loading branch information...
1 parent 55bd7a0 commit 98795f13c00fe6379272c88578c6993c0e905a55 @lloyd lloyd committed Jul 20, 2011
Showing with 261 additions and 255 deletions.
  1. +51 −50 browserid/app.js
  2. +15 −14 browserid/lib/db.js
  3. +17 −16 browserid/lib/email.js
  4. +5 −5 browserid/lib/httputils.js
  5. +3 −2 browserid/lib/secrets.js
  6. +5 −4 browserid/lib/webfinger.js
  7. +163 −162 browserid/lib/wsapi.js
  8. +2 −2 browserid/run.js
View
@@ -1,20 +1,21 @@
-const fs = require('fs'),
- path = require('path');
+const
+fs = require('fs'),
+path = require('path');
// create the var directory if it doesn't exist
var VAR_DIR = path.join(__dirname, "var");
try { fs.mkdirSync(VAR_DIR, 0755); } catch(e) { };
const
- url = require('url'),
- crypto = require('crypto'),
- wsapi = require('./lib/wsapi.js'),
- httputils = require('./lib/httputils.js'),
- webfinger = require('./lib/webfinger.js'),
- sessions = require('cookie-sessions'),
- express = require('express'),
- secrets = require('./lib/secrets.js'),
- db = require('./lib/db.js')
+url = require('url'),
+crypto = require('crypto'),
+wsapi = require('./lib/wsapi.js'),
+httputils = require('./lib/httputils.js'),
+webfinger = require('./lib/webfinger.js'),
+sessions = require('cookie-sessions'),
+express = require('express'),
+secrets = require('./lib/secrets.js'),
+db = require('./lib/db.js')
// looks unused, see run.js
// const STATIC_DIR = path.join(path.dirname(__dirname), "static");
@@ -37,11 +38,11 @@ function router(app) {
// this should probably be an internal redirect
// as soon as relative paths are figured out.
app.get('/sign_in', function(req, res, next ){
- res.render('dialog.ejs', {
- title: 'A Better Way to Sign In',
- layout: false,
- production: exports.production
- });
+ res.render('dialog.ejs', {
+ title: 'A Better Way to Sign In',
+ layout: false,
+ production: exports.production
+ });
});
// simple redirects (internal for now)
@@ -52,9 +53,9 @@ function router(app) {
// but we must be careful that this is never a JSON structure that could be hijacked
// by a third party
app.get('/csrf', function(req, res) {
- res.write(req.session.csrf);
- res.end();
- });
+ res.write(req.session.csrf);
+ res.end();
+ });
app.get('/', function(req,res) {
res.render('index.ejs', {title: 'A Better Way to Sign In', fullpage: true});
@@ -92,19 +93,19 @@ function router(app) {
wsapi.setup(app);
app.get('/users/:identity.xml', function(req, resp, next) {
- webfinger.renderUserPage(req.params.identity, function (resultDocument) {
- if (resultDocument === undefined) {
- httputils.fourOhFour(resp, "I don't know anything about: " + req.params.identity + "\n");
- } else {
- httputils.xmlResponse(resp, resultDocument);
- }
- });
+ webfinger.renderUserPage(req.params.identity, function (resultDocument) {
+ if (resultDocument === undefined) {
+ httputils.fourOhFour(resp, "I don't know anything about: " + req.params.identity + "\n");
+ } else {
+ httputils.xmlResponse(resp, resultDocument);
+ }
});
+ });
app.get('/code_update', function(req, resp, next) {
- console.log("code updated. shutting down.");
- process.exit();
- });
+ console.log("code updated. shutting down.");
+ process.exit();
+ });
};
exports.varDir = VAR_DIR;
@@ -135,17 +136,17 @@ exports.setup = function(server) {
// we make sure that everyone has a session, otherwise we can't do CSRF properly
server.use(function(req, resp, next) {
- if (typeof req.session == 'undefined')
- req.session = {};
+ if (typeof req.session == 'undefined')
+ req.session = {};
- if (typeof req.session.csrf == 'undefined') {
- // FIXME: using express-csrf's approach for generating randomness
- // not awesome, but probably sufficient for now.
- req.session.csrf = crypto.createHash('md5').update('' + new Date().getTime()).digest('hex');
- }
-
- next();
- });
+ if (typeof req.session.csrf == 'undefined') {
+ // FIXME: using express-csrf's approach for generating randomness
+ // not awesome, but probably sufficient for now.
+ req.session.csrf = crypto.createHash('md5').update('' + new Date().getTime()).digest('hex');
+ }
+
+ next();
+ });
// a tweak to get the content type of host-meta correct
server.use(function(req, resp, next) {
@@ -157,22 +158,22 @@ exports.setup = function(server) {
// prevent framing
server.use(function(req, resp, next) {
- resp.setHeader('x-frame-options', 'DENY');
- next();
- });
+ resp.setHeader('x-frame-options', 'DENY');
+ next();
+ });
// check CSRF token
server.use(function(req, resp, next) {
- // only on POSTs
- if (req.method == "POST") {
- if (req.body.csrf != req.session.csrf) {
- // error, problem with CSRF
- throw new Error("CSRF violation - " + req.body.csrf + '/' + req.session.csrf);
- }
+ // only on POSTs
+ if (req.method == "POST") {
+ if (req.body.csrf != req.session.csrf) {
+ // error, problem with CSRF
+ throw new Error("CSRF violation - " + req.body.csrf + '/' + req.session.csrf);
}
+ }
- next();
- });
+ next();
+ });
// add the actual URL handlers other than static
router(server);
}
View
@@ -1,6 +1,7 @@
-const sqlite = require('sqlite'),
- path = require('path'),
- bcrypt = require('bcrypt');
+const
+sqlite = require('sqlite'),
+path = require('path'),
+bcrypt = require('bcrypt');
var VAR_DIR = path.join(path.dirname(__dirname), "var");
@@ -17,8 +18,8 @@ db.open(dbPath, function (error) {
}
db.executeScript(
"CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY, password TEXT );" +
- "CREATE TABLE IF NOT EXISTS emails ( id INTEGER PRIMARY KEY, user INTEGER, address TEXT UNIQUE );" +
- "CREATE TABLE IF NOT EXISTS keys ( id INTEGER PRIMARY KEY, email INTEGER, key TEXT, expires INTEGER )",
+ "CREATE TABLE IF NOT EXISTS emails ( id INTEGER PRIMARY KEY, user INTEGER, address TEXT UNIQUE );" +
+ "CREATE TABLE IF NOT EXISTS keys ( id INTEGER PRIMARY KEY, email INTEGER, key TEXT, expires INTEGER )",
function (error) {
if (error) {
throw error;
@@ -356,14 +357,14 @@ exports.removeEmail = function(authenticated_email, email, cb) {
};
exports.cancelAccount = function(authenticated_email, cb) {
- emailToUserID(authenticated_email, function(user_id) {
- executeTransaction([
- [ "delete from emails where user = ?", [ user_id ] ] ,
- [ "delete from keys where email in (select address from emails where user = ?)", [ user_id ] ],
- [ "delete from users where id = ?", [ user_id ] ],
- ], function (error) {
- if (error) cb(error);
- else cb();
- });
+ emailToUserID(authenticated_email, function(user_id) {
+ executeTransaction([
+ [ "delete from emails where user = ?", [ user_id ] ] ,
+ [ "delete from keys where email in (select address from emails where user = ?)", [ user_id ] ],
+ [ "delete from users where id = ?", [ user_id ] ],
+ ], function (error) {
+ if (error) cb(error);
+ else cb();
});
+ });
};
View
@@ -1,23 +1,24 @@
-const db = require('./db'),
- emailer = require('nodemailer'),
- fs = require('fs'),
- path = require('path'),
+const
+db = require('./db'),
+emailer = require('nodemailer'),
+fs = require('fs'),
+path = require('path'),
mustache = require('mustache');
const template = fs.readFileSync(path.join(__dirname, "prove_template.txt")).toString();
exports.sendVerificationEmail = function(email, site, secret) {
- var url = "https://browserid.org/prove?token=" + encodeURIComponent(secret);
+ var url = "https://browserid.org/prove?token=" + encodeURIComponent(secret);
- emailer.send_mail({
- sender: "noreply@browserid.org",
- to: email,
- subject : "Complete Login to " + site + " using BrowserID",
- body: mustache.to_html(template, { email: email, link: url, site: site })
- }, function(err, success){
- if(!success) {
- console.log("error sending email: ", err);
- console.log("verification URL: ", url);
- }
- });
+ emailer.send_mail({
+ sender: "noreply@browserid.org",
+ to: email,
+ subject : "Complete Login to " + site + " using BrowserID",
+ body: mustache.to_html(template, { email: email, link: url, site: site })
+ }, function(err, success){
+ if(!success) {
+ console.log("error sending email: ", err);
+ console.log("verification URL: ", url);
+ }
+ });
};
View
@@ -43,10 +43,10 @@ exports.xmlResponse = function(resp, doc)
};
exports.checkGetArgs = function(req, args) {
- [ "email", "pass", "pubkey" ].forEach(function(k) {
- if (!urlobj.hasOwnProperty(k) || typeof urlobj[k] !== 'string') {
- throw k;
- }
- });
+ [ "email", "pass", "pubkey" ].forEach(function(k) {
+ if (!urlobj.hasOwnProperty(k) || typeof urlobj[k] !== 'string') {
+ throw k;
+ }
+ });
};
View
@@ -1,5 +1,6 @@
-const path = require('path'),
- fs = require('fs');
+const
+path = require('path'),
+fs = require('fs');
function generateSecret() {
var str = "";
@@ -1,7 +1,8 @@
-const db = require('./db.js'),
- fs = require('fs'),
- mustache = require('mustache'),
- path = require('path');
+const
+db = require('./db.js'),
+fs = require('fs'),
+mustache = require('mustache'),
+path = require('path');
const TEMPLATE = fs.readFileSync(path.join(__dirname, "webfinger_template.xml")).toString();
Oops, something went wrong.

0 comments on commit 98795f1

Please sign in to comment.