From 08f80a23bdf3db16cbbdba5972ee88ec695c1b64 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Fri, 30 Sep 2011 16:19:09 +0100 Subject: [PATCH] Starting the namespace process. Issue #275 --- .../controllers/authenticate_controller.js | 10 +- .../checkregistration_controller.js | 6 +- .../dialog/controllers/dialog_controller.js | 18 ++-- .../controllers/pickemail_controller.js | 4 +- browserid/static/dialog/dialog.js | 1 + .../dialog/resources/browserid-errors.js | 2 +- .../dialog/resources/browserid-extensions.js | 41 +++++--- .../dialog/resources/browserid-identities.js | 12 +-- .../dialog/resources/browserid-network.js | 4 +- .../static/dialog/resources/browserid-wait.js | 2 +- .../static/dialog/resources/browserid.js | 41 ++++++++ browserid/static/dialog/resources/storage.js | 2 +- .../browserid-identities_functional_test.js | 94 +++++++++---------- .../qunit/browserid-identities_unit_test.js | 10 +- .../test/qunit/browserid-network_test.js | 4 +- .../test/qunit/browserid-storage_unit_test.js | 6 +- browserid/static/dialog/test/qunit/qunit.js | 3 +- browserid/static/js/browserid.js | 9 +- .../static/js/pages/add_email_address.js | 4 +- browserid/static/js/pages/manage_account.js | 10 +- browserid/static/js/pages/signin.js | 4 +- browserid/static/js/pages/signup.js | 4 +- .../static/js/pages/verify_email_address.js | 4 +- 23 files changed, 175 insertions(+), 120 deletions(-) create mode 100644 browserid/static/dialog/resources/browserid.js diff --git a/browserid/static/dialog/controllers/authenticate_controller.js b/browserid/static/dialog/controllers/authenticate_controller.js index 80c34e364..aceadf2b6 100644 --- a/browserid/static/dialog/controllers/authenticate_controller.js +++ b/browserid/static/dialog/controllers/authenticate_controller.js @@ -1,5 +1,5 @@ /*jshint browser:true, jQuery: true, forin: true, laxbreak:true */ -/*global BrowserIDIdentities: true, BrowserIDWait:true, BrowserIDErrors: true, PageController: true */ +/*global BrowserID, PageController: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -38,7 +38,7 @@ "use strict"; var ANIMATION_TIME = 250, - identities = BrowserIDIdentities; + identities = BrowserID.Identities; function checkEmail() { var email = $("#email").val(), @@ -80,7 +80,7 @@ else { // XXX can't register this email address. } - }, self.getErrorDialog(BrowserIDErrors.createAccount)); + }, self.getErrorDialog(BrowserID.Errors.createAccount)); } function authenticate() { @@ -96,7 +96,7 @@ identities.authenticateAndSync(email, pass, function onAuthenticate(authenticated) { if (authenticated) { - self.doWait(BrowserIDWait.authentication); + self.doWait(BrowserID.Wait.authentication); } else { // XXX error screen @@ -111,7 +111,7 @@ // XXX error screen. } }, - self.getErrorDialog(BrowserIDErrors.authentication) + self.getErrorDialog(BrowserID.Errors.authentication) ); } diff --git a/browserid/static/dialog/controllers/checkregistration_controller.js b/browserid/static/dialog/controllers/checkregistration_controller.js index e675e8e7e..eeb01baff 100644 --- a/browserid/static/dialog/controllers/checkregistration_controller.js +++ b/browserid/static/dialog/controllers/checkregistration_controller.js @@ -1,5 +1,5 @@ /*jshint browser:true, jQuery: true, forin: true, laxbreak:true */ -/*global BrowserIDIdentities: true, BrowserIDErrors: true, PageController: true */ +/*global BrowserID: true, PageController: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -37,7 +37,7 @@ (function() { "use strict"; - var identities = BrowserIDIdentities; + var identities = BrowserID.Identities; PageController.extend("Checkregistration", {}, { init: function(el, options) { @@ -60,7 +60,7 @@ identities.syncEmailKeypairs(function() { me.close(me.verificationMessage); }); - }, me.getErrorDialog(BrowserIDErrors.registration)); + }, me.getErrorDialog(BrowserID.Errors.registration)); } }); diff --git a/browserid/static/dialog/controllers/dialog_controller.js b/browserid/static/dialog/controllers/dialog_controller.js index b29e2d2a1..0ba484d28 100644 --- a/browserid/static/dialog/controllers/dialog_controller.js +++ b/browserid/static/dialog/controllers/dialog_controller.js @@ -1,5 +1,5 @@ /*jshint browser:true, jQuery: true, forin: true, laxbreak:true */ -/*global setupChannel:true, BrowserIDIdentities: true, BrowserIDWait:true, BrowserIDErrors: true, PageController: true, OpenAjax: true */ +/*global setupChannel:true, BrowserID: true, PageController: true, OpenAjax: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -59,7 +59,7 @@ PageController.extend("Dialog", {}, { this.onsuccess = onsuccess; this.onerror = onerror; - BrowserIDIdentities.setOrigin(origin_url); + BrowserID.Identities.setOrigin(origin_url); this.doStart(); @@ -186,7 +186,7 @@ PageController.extend("Dialog", {}, { doEmailSelected: function(email) { var self=this; // yay! now we need to produce an assertion. - BrowserIDIdentities.getAssertion(email, function(assertion) { + BrowserID.Identities.getAssertion(email, function(assertion) { // Clear onerror before the call to onsuccess - the code to onsuccess // calls window.close, which would trigger the onerror callback if we // tried this afterwards. @@ -196,20 +196,20 @@ PageController.extend("Dialog", {}, { }, doNotMe: function() { - BrowserIDIdentities.logoutUser(this.doAuthenticate.bind(this)); + BrowserID.Identities.logoutUser(this.doAuthenticate.bind(this)); }, syncEmailKeypairs: function() { var self = this; - BrowserIDIdentities.syncEmailKeypairs(self.doSignIn.bind(self), - self.getErrorDialog(BrowserIDErrors.signIn)); + BrowserID.Identities.syncEmailKeypairs(self.doSignIn.bind(self), + self.getErrorDialog(BrowserID.Errors.signIn)); }, doCheckAuth: function() { var self=this; - self.doWait(BrowserIDWait.checkAuth); - BrowserIDIdentities.checkAuthenticationAndSync(function onSuccess() {}, + self.doWait(BrowserID.Wait.checkAuth); + BrowserID.Identities.checkAuthenticationAndSync(function onSuccess() {}, function onComplete(authenticated) { if (authenticated) { self.doSignIn(); @@ -217,7 +217,7 @@ PageController.extend("Dialog", {}, { self.doAuthenticate(); } }, - self.getErrorDialog(BrowserIDErrors.checkAuthentication)); + self.getErrorDialog(BrowserID.Errors.checkAuthentication)); } }); diff --git a/browserid/static/dialog/controllers/pickemail_controller.js b/browserid/static/dialog/controllers/pickemail_controller.js index 85e758137..db926e9fc 100644 --- a/browserid/static/dialog/controllers/pickemail_controller.js +++ b/browserid/static/dialog/controllers/pickemail_controller.js @@ -1,5 +1,5 @@ /*jshint brgwser:true, jQuery: true, forin: true, laxbreak:true */ -/*global _: true, BrowserIDIdentities: true, PageController: true */ +/*global _: true, BrowserID: true, PageController: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -38,7 +38,7 @@ "use strict"; var ANIMATION_TIME = 250, - identities = BrowserIDIdentities; + identities = BrowserID.Identities; function animateSwap(fadeOutSelector, fadeInSelector, callback) { // XXX instead of using jQuery here, think about using CSS animations. diff --git a/browserid/static/dialog/dialog.js b/browserid/static/dialog/dialog.js index 8f29abb4d..88e4066dc 100644 --- a/browserid/static/dialog/dialog.js +++ b/browserid/static/dialog/dialog.js @@ -51,6 +51,7 @@ steal.plugins( 'base64', 'underscore-min', 'channel', + 'browserid', 'storage', 'browserid-extensions', 'browserid-network', diff --git a/browserid/static/dialog/resources/browserid-errors.js b/browserid/static/dialog/resources/browserid-errors.js index fe8703706..dd7ee7313 100644 --- a/browserid/static/dialog/resources/browserid-errors.js +++ b/browserid/static/dialog/resources/browserid-errors.js @@ -32,7 +32,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -var BrowserIDErrors = (function(){ +BrowserID.Errors = (function(){ "use strict"; var Errors = { diff --git a/browserid/static/dialog/resources/browserid-extensions.js b/browserid/static/dialog/resources/browserid-extensions.js index 1d45a366c..01e670ab9 100644 --- a/browserid/static/dialog/resources/browserid-extensions.js +++ b/browserid/static/dialog/resources/browserid-extensions.js @@ -33,26 +33,37 @@ * * ***** END LICENSE BLOCK ***** */ -if (!Function.prototype.bind) { +(function() { + "use strict"; - Function.prototype.bind = function (oThis) { + if (!Function.prototype.bind) { - if (typeof this !== "function") // closest thing possible to the ECMAScript 5 internal IsCallable function - throw new TypeError("Function.prototype.bind - what is trying to be fBound is not callable"); + Function.prototype.bind = function (oThis) { - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, - fNOP = function () {}, - fBound = function () { - return fToBind.apply(this instanceof fNOP ? this : oThis || window, aArgs.concat(Array.prototype.slice.call(arguments))); - }; + if (typeof this !== "function") // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be fBound is not callable"); + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP ? this : oThis || window, aArgs.concat(Array.prototype.slice.call(arguments))); + }; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); - return fBound; + return fBound; + + }; - }; + } -} + if(!window.console) { + window.console = {}; + } + if(!console.log) { + console.log = function() {}; + } +}()); diff --git a/browserid/static/dialog/resources/browserid-identities.js b/browserid/static/dialog/resources/browserid-identities.js index 8f34fecde..8592ad065 100644 --- a/browserid/static/dialog/resources/browserid-identities.js +++ b/browserid/static/dialog/resources/browserid-identities.js @@ -1,5 +1,5 @@ /*jshint browsers:true, forin: true, laxbreak: true */ -/*global _: true, BrowserIDStorage: true, BrowserIDNetwork: true */ +/*global _: true, BrowserID: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,12 +35,12 @@ * * ***** END LICENSE BLOCK ***** */ -var BrowserIDIdentities = (function() { +BrowserID.Identities = (function() { "use strict"; var jwk, jwt, vep, jwcert, origin, - network = BrowserIDNetwork, - storage = BrowserIDStorage; + network = BrowserID.Network, + storage = BrowserID.Storage; function prepareDeps() { if (!jwk) { @@ -139,8 +139,8 @@ var BrowserIDIdentities = (function() { /** * Set the interface to use for networking. Used for unit testing. * @method setNetwork - * @param {BrowserIDNetwork} networkInterface - BrowserIDNetwork interface - * to use. + * @param {BrowserID.Network} networkInterface - BrowserID.Network + * compatible interface to use. */ setNetwork: function(networkInterface) { network = networkInterface; diff --git a/browserid/static/dialog/resources/browserid-network.js b/browserid/static/dialog/resources/browserid-network.js index 0f923b6fb..afd926599 100644 --- a/browserid/static/dialog/resources/browserid-network.js +++ b/browserid/static/dialog/resources/browserid-network.js @@ -1,5 +1,5 @@ /*jshint browsers:true, forin: true, laxbreak: true */ -/*global BrowserIDStorage: true, _: true */ +/*global BrowserID: true, _: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,7 +34,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -var BrowserIDNetwork = (function() { +BrowserID.Network = (function() { "use strict"; var csrf_token, diff --git a/browserid/static/dialog/resources/browserid-wait.js b/browserid/static/dialog/resources/browserid-wait.js index 6e4e6fe08..190074c30 100644 --- a/browserid/static/dialog/resources/browserid-wait.js +++ b/browserid/static/dialog/resources/browserid-wait.js @@ -32,7 +32,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -var BrowserIDWait = (function(){ +BrowserID.Wait = (function(){ "use strict"; var Wait = { diff --git a/browserid/static/dialog/resources/browserid.js b/browserid/static/dialog/resources/browserid.js new file mode 100644 index 000000000..c91ee8a4d --- /dev/null +++ b/browserid/static/dialog/resources/browserid.js @@ -0,0 +1,41 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla BrowserID. + * + * The Initial Developer of the Original Code is Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +(function() { + "use strict"; + + window.BrowserID = window.BrowserID || {}; + +}()); diff --git a/browserid/static/dialog/resources/storage.js b/browserid/static/dialog/resources/storage.js index 1fcfbc0af..1a1ce7cc8 100644 --- a/browserid/static/dialog/resources/storage.js +++ b/browserid/static/dialog/resources/storage.js @@ -33,7 +33,7 @@ * * ***** END LICENSE BLOCK ***** */ -var BrowserIDStorage = (function() { +BrowserID.Storage = (function() { var jwk; diff --git a/browserid/static/dialog/test/qunit/browserid-identities_functional_test.js b/browserid/static/dialog/test/qunit/browserid-identities_functional_test.js index 4148b6b8a..ee268426c 100644 --- a/browserid/static/dialog/test/qunit/browserid-identities_functional_test.js +++ b/browserid/static/dialog/test/qunit/browserid-identities_functional_test.js @@ -1,5 +1,5 @@ /*jshint browsers:true, forin: true, laxbreak: true */ -/*global steal: true, test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserIDStorage.clearEmails: true, BrowserIDNetwork: true , BrowserIDIdentities: true */ +/*global steal: true, test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserID: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,13 +49,13 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden } test("getStoredIdentities", function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); equal("object", typeof identities, "we have some identities"); }); test("clearStoredIdentities", function() { - BrowserIDIdentities.clearStoredIdentities(); - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserID.Identities.clearStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); var count = 0; for(var key in identities) { if(identities.hasOwnProperty(key)) { @@ -67,7 +67,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("stageIdentity", function() { - BrowserIDIdentities.stageIdentity("testuser@testuser.com", "testuser", function(keypair) { + BrowserID.Identities.stageIdentity("testuser@testuser.com", "testuser", function(keypair) { equal("object", typeof keypair, "We have a key pair"); start(); }, failure("stageIdentity failure")); @@ -76,7 +76,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("confirmIdentity", function() { - /* BrowserIDIdentities.confirmIdentity("testuser@testuser.com", function() { + /* BrowserID.Identities.confirmIdentity("testuser@testuser.com", function() { start(); }); @@ -85,10 +85,10 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("authenticateAndSync", function() { - BrowserIDStorage.clearEmails(); - BrowserIDIdentities.authenticateAndSync("testuser@testuser.com", "testuser", function() { + BrowserID.Storage.clearEmails(); + BrowserID.Identities.authenticateAndSync("testuser@testuser.com", "testuser", function() { }, function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); ok("testuser@testuser.com" in identities, "authenticateAndSync syncs email addresses"); start(); }, failure("Authentication failure")); @@ -98,10 +98,10 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("checkAuthenticationAndSync", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDStorage.clearEmails(); - BrowserIDIdentities.checkAuthenticationAndSync(function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Storage.clearEmails(); + BrowserID.Identities.checkAuthenticationAndSync(function() { + var identities = BrowserID.Identities.getStoredIdentities(); ok("testuser@testuser.com" in identities, "checkAuthenticationAndSync syncs email addresses"); start(); }); @@ -111,12 +111,12 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("addIdentity", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.removeIdentity("testemail@testemail.com", function() { - BrowserIDIdentities.addIdentity("testemail@testemail.com", function(keypair) { + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.removeIdentity("testemail@testemail.com", function() { + BrowserID.Identities.addIdentity("testemail@testemail.com", function(keypair) { equal("object", typeof keypair, "we have a keypair"); - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); equal(false, "testemail@testemail.com" in identities, "Our new email is not added until confirmation."); start(); @@ -129,10 +129,10 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden /* test("syncIdentity on confirmed email address", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.removeIdentity("testemail@testemail.com", "issuer", function() { + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.removeIdentity("testemail@testemail.com", "issuer", function() { // XXX verify the identity here - BrowserIDIdentities.syncIdentity("testemail@testemail.com", "issuer", function(keypair) { + BrowserID.Identities.syncIdentity("testemail@testemail.com", "issuer", function(keypair) { ok(false, "Syncing a non-verified identity should fail"); start(); @@ -145,17 +145,17 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden */ test("persistIdentity", function() { - BrowserIDIdentities.persistIdentity("testemail2@testemail.com", { pub: "pub", priv: "priv" }); - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserID.Identities.persistIdentity("testemail2@testemail.com", { pub: "pub", priv: "priv" }); + var identities = BrowserID.Identities.getStoredIdentities(); ok("testemail2@testemail.com" in identities, "Our new email is added"); }); /* test("removeIdentity that we add", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.syncIdentity("testemail@testemail.com", "issuer", function(keypair) { - BrowserIDIdentities.removeIdentity("testemail@testemail.com", function() { - var identities = BrowserIDIdentities.getStoredIdentities(); + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.syncIdentity("testemail@testemail.com", "issuer", function(keypair) { + BrowserID.Identities.removeIdentity("testemail@testemail.com", function() { + var identities = BrowserID.Identities.getStoredIdentities(); equal(false, "testemail@testemail.com" in identities, "Our new email is removed"); start(); }, failure("removeIdentity failure")); @@ -166,9 +166,9 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); */ test("syncIdentities with no identities", function() { - BrowserIDStorage.clearEmails(); - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.syncIdentities(function onSuccess() { + BrowserID.Storage.clearEmails(); + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.syncIdentities(function onSuccess() { ok(true, "we have synced identities"); start(); }, failure("identity sync failure")); @@ -178,8 +178,8 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("syncIdentities with identities preloaded", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.syncIdentities(function onSuccess() { + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.syncIdentities(function onSuccess() { ok(true, "we have synced identities"); start(); }, failure("identity sync failure")); @@ -189,8 +189,8 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("getIdentityAssertion", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.getIdentityAssertion("testuser@testuser.com", function(assertion) { + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.getIdentityAssertion("testuser@testuser.com", function(assertion) { equal("string", typeof assertion, "we have an assertion!"); start(); }); @@ -201,17 +201,17 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden /* test("syncIdentity on non-confirmed email address", function() { - BrowserIDStorage.clearEmails(); - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { - BrowserIDIdentities.removeIdentity("testemail@testemail.com", function() { - BrowserIDIdentities.syncIdentity("testemail@testemail.com", "issuer", function(keypair) { + BrowserID.Storage.clearEmails(); + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Identities.removeIdentity("testemail@testemail.com", function() { + BrowserID.Identities.syncIdentity("testemail@testemail.com", "issuer", function(keypair) { ok(false, "Syncing a non-verified identity should fail"); start(); }, function() { ok(true, "trying to sync an identity that is not yet verified should fail"); - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); equal("testemail@testemail.com" in identities, false, "Our new email is added"); start(); @@ -223,26 +223,26 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden }); test("syncIdentity without first validating email", function() { - BrowserIDNetwork.authenticate("testuser@testuser.com", "testuser", function() { + BrowserID.Network.authenticate("testuser@testuser.com", "testuser", function() { // First, force removal that way we know it is not part of our list. - BrowserIDIdentities.removeIdentity("unvalidated@unvalidated.com", function() { + BrowserID.Identities.removeIdentity("unvalidated@unvalidated.com", function() { - BrowserIDStorage.clearEmails(); - BrowserIDIdentities.syncIdentities(function onSuccess() { + BrowserID.Storage.clearEmails(); + BrowserID.Identities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); // Make sure the server has forgotten about this email address. equal("unvalidated@unvalidated.com" in identities, false, "The removed email should not be on the list."); // This next call will call /wsapi/set_key on a // key that has not been validated. - BrowserIDIdentities.syncIdentity("unvalidated@unvalidated.com", "issuer", function(keypair) { + BrowserID.Identities.syncIdentity("unvalidated@unvalidated.com", "issuer", function(keypair) { // Clear all the local emails, then refetch the list from the server // just to be sure we are seeing what the server sees. - BrowserIDStorage.clearEmails(); - BrowserIDIdentities.syncIdentities(function onSuccess() { + BrowserID.Storage.clearEmails(); + BrowserID.Identities.syncIdentities(function onSuccess() { - var identities = BrowserIDIdentities.getStoredIdentities(); + var identities = BrowserID.Identities.getStoredIdentities(); // woah. Things just went wrong. equal("unvalidated@unvalidated.com" in identities, false, "The unvalidated email should not be added just through calling sync_key"); start(); diff --git a/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js b/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js index b0e52eca1..2ecc46c18 100644 --- a/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js +++ b/browserid/static/dialog/test/qunit/browserid-identities_unit_test.js @@ -1,5 +1,5 @@ /*jshint browsers:true, forin: true, laxbreak: true */ -/*global steal: true, test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserIDStorage:true, BrowserIDNetwork: true , BrowserIDIdentities: true */ +/*global steal: true, test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserID: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -42,9 +42,9 @@ var jwk = require("./jwk"); var jwcert = require("./jwcert"); steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-identities", function() { - var lib = BrowserIDIdentities, - network = BrowserIDNetwork, - storage = BrowserIDStorage; + var lib = BrowserID.Identities, + network = BrowserID.Network, + storage = BrowserID.Storage; // I generated these locally, they are used nowhere else. var pubkey = {"algorithm":"RS","n":"56063028070432982322087418176876748072035482898334811368408525596198252519267108132604198004792849077868951906170812540713982954653810539949384712773390200791949565903439521424909576832418890819204354729217207360105906039023299561374098942789996780102073071760852841068989860403431737480182725853899733706069","e":"65537"}; @@ -164,7 +164,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-iden emailCheckCount = 0; }, teardown: function() { - lib.setNetwork(BrowserIDNetwork); + lib.setNetwork(BrowserID.Network); } }); diff --git a/browserid/static/dialog/test/qunit/browserid-network_test.js b/browserid/static/dialog/test/qunit/browserid-network_test.js index 9f4dc4c63..371ffd265 100644 --- a/browserid/static/dialog/test/qunit/browserid-network_test.js +++ b/browserid/static/dialog/test/qunit/browserid-network_test.js @@ -1,5 +1,5 @@ /*jshint browsers:true, forin: true, laxbreak: true */ -/*global test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserIDNetwork: true */ +/*global test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserID: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -41,7 +41,7 @@ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/browserid-network", function() { "use strict"; - var network = BrowserIDNetwork; + var network = BrowserID.Network; var xhr = { results: { "get /wsapi/csrf valid": "csrf_token", diff --git a/browserid/static/dialog/test/qunit/browserid-storage_unit_test.js b/browserid/static/dialog/test/qunit/browserid-storage_unit_test.js index acd9d087c..323bbf902 100644 --- a/browserid/static/dialog/test/qunit/browserid-storage_unit_test.js +++ b/browserid/static/dialog/test/qunit/browserid-storage_unit_test.js @@ -1,5 +1,5 @@ /*jshint browsers:true, forin: true, laxbreak: true */ -/*global steal: true, test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserIDStorage:true */ +/*global steal: true, test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserID:true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,9 +35,9 @@ * * ***** END LICENSE BLOCK ***** */ steal.plugins("jquery", "funcunit/qunit").then("/dialog/resources/storage", function() { - var storage = BrowserIDStorage; + var storage = BrowserID.Storage; - module("BrowserIDStorage", { + module("BrowserID.Storage", { startup: function() { storage.clearEmails(); }, diff --git a/browserid/static/dialog/test/qunit/qunit.js b/browserid/static/dialog/test/qunit/qunit.js index 887b03c17..1a898cc40 100644 --- a/browserid/static/dialog/test/qunit/qunit.js +++ b/browserid/static/dialog/test/qunit/qunit.js @@ -1,4 +1,5 @@ -steal("/dialog/resources/storage.js", +steal("/dialog/resources/browserid.js", + "/dialog/resources/storage.js", "/dialog/resources/underscore-min.js") .plugins("funcunit/qunit") .then("browserid-storage_unit_test") diff --git a/browserid/static/js/browserid.js b/browserid/static/js/browserid.js index f6759e8d5..a9226e558 100644 --- a/browserid/static/js/browserid.js +++ b/browserid/static/js/browserid.js @@ -1,4 +1,4 @@ -/*globals BrowserIDNetwork: true, BrowserIDIdentities: true, _: true */ +/*globals BrowserID: true, _: true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -56,7 +56,8 @@ $(function() { var token = getParameterByName("token"), path = document.location.pathname, - bid = BrowserID; + bid = BrowserID, + identities = bid.Identities; if (!path || path === "/") { bid.index(); @@ -81,12 +82,12 @@ $(function() { $(".signOut").click(function(event) { event.preventDefault(); - BrowserIDIdentities.logoutUser(function() { + identities.logoutUser(function() { document.location = "/"; }); }); - BrowserIDIdentities.checkAuthentication(function(authenticated) { + identities.checkAuthentication(function(authenticated) { if (authenticated) { $("#content").fadeIn("slow"); if ($('#emailList').length) { diff --git a/browserid/static/js/pages/add_email_address.js b/browserid/static/js/pages/add_email_address.js index 7df3615cf..9755ef018 100644 --- a/browserid/static/js/pages/add_email_address.js +++ b/browserid/static/js/pages/add_email_address.js @@ -1,4 +1,4 @@ -/*globals BrowserID: true, BrowserIDNetwork: true, $:true */ +/*globals BrowserID: true, $:true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -51,7 +51,7 @@ } BrowserID.addEmailAddress = function(token) { - BrowserIDNetwork.completeEmailRegistration(token, function onSuccess(valid) { + BrowserID.Network.completeEmailRegistration(token, function onSuccess(valid) { if (valid) { emailRegistrationSuccess(); } else { diff --git a/browserid/static/js/pages/manage_account.js b/browserid/static/js/pages/manage_account.js index 500cbc43d..491f4adf6 100644 --- a/browserid/static/js/pages/manage_account.js +++ b/browserid/static/js/pages/manage_account.js @@ -1,4 +1,4 @@ -/*globals BrowserID:true, BrowserIDNetwork: true, BrowserIDIdentities: true, _: true, confirm: true, syncAndDisplayEmails: true, displayEmails: true, onRemoveEmail: true*/ +/*globals BrowserID:true, _: true, confirm: true, syncAndDisplayEmails: true, displayEmails: true, onRemoveEmail: true*/ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -122,8 +122,8 @@ function syncAndDisplayEmails() { var emails = {}; - BrowserIDIdentities.syncEmailKeypairs(function() { - emails = BrowserIDIdentities.getStoredEmailKeypairs(); + BrowserID.Identities.syncEmailKeypairs(function() { + emails = BrowserID.Identities.getStoredEmailKeypairs(); if (_.isEmpty(emails)) { $("#content").hide(); } else { @@ -163,14 +163,14 @@ event.preventDefault(); if (confirm("Remove " + email + " from your BrowserID?")) { - BrowserIDIdentities.removeEmail(email, syncAndDisplayEmails); + BrowserID.Identities.removeEmail(email, syncAndDisplayEmails); } } BrowserID.manageAccount = function() { $('#cancellink').click(function() { if (confirm('Are you sure you want to cancel your account?')) { - BrowserIDNetwork.cancelUser(function() { + BrowserID.Network.cancelUser(function() { document.location="/"; }); } diff --git a/browserid/static/js/pages/signin.js b/browserid/static/js/pages/signin.js index 989c0da4e..1afb9d305 100644 --- a/browserid/static/js/pages/signin.js +++ b/browserid/static/js/pages/signin.js @@ -1,4 +1,4 @@ -/*globals BrowserID:true, BrowserIDNetwork: true, $:true*/ +/*globals BrowserID:true, $:true*/ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -46,7 +46,7 @@ var email = $("#email").val(), password = $("#password").val(); - BrowserIDNetwork.authenticate(email, password, function onSuccess(authenticated) { + BrowserID.Network.authenticate(email, password, function onSuccess(authenticated) { if (authenticated) { document.location = "/"; } diff --git a/browserid/static/js/pages/signup.js b/browserid/static/js/pages/signup.js index d4f8f9d34..7cf7a3cf1 100644 --- a/browserid/static/js/pages/signup.js +++ b/browserid/static/js/pages/signup.js @@ -1,4 +1,4 @@ -/*globals BrowserID:true, BrowserIDIdentities: true, $:true*/ +/*globals BrowserID:true, $:true*/ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -56,7 +56,7 @@ $(function () { - var identities = BrowserIDIdentities; + var identities = BrowserID.Identities; $("form input[autofocus]").focus(); diff --git a/browserid/static/js/pages/verify_email_address.js b/browserid/static/js/pages/verify_email_address.js index 5315582c6..bef1c2455 100644 --- a/browserid/static/js/pages/verify_email_address.js +++ b/browserid/static/js/pages/verify_email_address.js @@ -1,4 +1,4 @@ -/*globals BrowserID:true, BrowserIDNetwork: true, $:true */ +/*globals BrowserID:true, $:true */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -46,7 +46,7 @@ pass2 = $("#vpassword").val(); if (pass && pass === pass2) { - BrowserIDNetwork.completeUserRegistration(token, pass, function onSuccess(registered) { + BrowserID.Network.completeUserRegistration(token, pass, function onSuccess(registered) { if (registered) { $("#congrats").fadeIn(250); } -- GitLab