firefox jetpack code to take advantage of warner's new jetpack crypto module

This commit is contained in:
Chris Karlof 2013-01-24 21:11:16 -08:00
Родитель cce56fde36
Коммит 991b248f9a
14 изменённых файлов: 26 добавлений и 9 удалений

3
.gitmodules поставляемый
Просмотреть файл

@ -4,3 +4,6 @@
[submodule "infobar"] [submodule "infobar"]
path = infobar path = infobar
url = git://github.com/lloyd/simulated_infobars url = git://github.com/lloyd/simulated_infobars
[submodule "packages/gombot-crypto-jetpack"]
path = packages/gombot-crypto-jetpack
url = git@github.com:warner/gombot-crypto-jetpack.git

3
TODO
Просмотреть файл

@ -1,4 +1,7 @@
- handle errors in gombot-crypto-jetpacka
- san jose ticketing site maybe not working
- reorg directories; given the Jetpack doesn't allow more than one level of .., the consider top level firefox and chrome directories - reorg directories; given the Jetpack doesn't allow more than one level of .., the consider top level firefox and chrome directories
- think about "local only" mode on Mac OS X that writes passwords to Keychain
- figure out API URL for different releases - figure out API URL for different releases
- revisit tobmog packaging - revisit tobmog packaging
- make sure linking creds are deleted if no logged in user or user dismisses but wait until after notification appears and user reacts - make sure linking creds are deleted if no logged in user or user dismisses but wait until after notification appears and user reacts

Просмотреть файл

@ -1,4 +1,4 @@
var CommandHandler = function(Gombot, Messaging) { var CommandHandler = function(Gombot, Messaging, _) {
function addLogin(message, sender) { function addLogin(message, sender) {
var currentUser = Gombot.getCurrentUser(), var currentUser = Gombot.getCurrentUser(),

Просмотреть файл

@ -54,7 +54,7 @@ var _Gombot = function(importedModules, Gombot) {
Gombot.LoginCredentialCollection = getModule("LoginCredentialCollection")(Backbone, _, Gombot.LoginCredential); // LoginCredential need to be initialized Gombot.LoginCredentialCollection = getModule("LoginCredentialCollection")(Backbone, _, Gombot.LoginCredential); // LoginCredential need to be initialized
Gombot.CapturedCredentialStorage = getModule("CapturedCredentialStorage")(Gombot, getModule("Uri")); Gombot.CapturedCredentialStorage = getModule("CapturedCredentialStorage")(Gombot, getModule("Uri"));
Gombot.Linker = getModule("Linker")(Gombot); Gombot.Linker = getModule("Linker")(Gombot);
Gombot.CommandHandler = getModule("CommandHandler")(Gombot, Gombot.Messaging); Gombot.CommandHandler = getModule("CommandHandler")(Gombot, Gombot.Messaging, _);
var currentUser = null; var currentUser = null;
Gombot.getCurrentUser = function() { Gombot.getCurrentUser = function() {
@ -91,11 +91,13 @@ var _Gombot = function(importedModules, Gombot) {
if (typeof startFirstRunFlow === 'function') { if (typeof startFirstRunFlow === 'function') {
startFirstRunFlow(false /* showSignInPage */); // shows signup page on first run startFirstRunFlow(false /* showSignInPage */); // shows signup page on first run
Gombot.LocalStorage.setItem("firstRun", true); Gombot.LocalStorage.setItem("firstRun", true);
} // TODO: fix this }
} }
var loggedInUser = Gombot.users.find(function(user) { return user.isAuthenticated() }); var loggedInUser = Gombot.users.find(function(user) { return user.isAuthenticated() });
if (loggedInUser) Gombot.setCurrentUser(loggedInUser); if (loggedInUser) Gombot.setCurrentUser(loggedInUser);
if (Gombot.users.size() === 0) { if (Gombot.users.size() === 0) {
// TODO: remove this is a hack for Firefox testing and we create a dummy user
// until we have a signup and signin page
console.log("No logged in user. Number of users:"+Gombot.users.size()); console.log("No logged in user. Number of users:"+Gombot.users.size());
var user = new Gombot.User({ var user = new Gombot.User({
'email': 'ckarlof+'+Math.floor(10000*Math.random(10000))+'@mozilla.com', 'email': 'ckarlof+'+Math.floor(10000*Math.random(10000))+'@mozilla.com',
@ -107,14 +109,16 @@ var _Gombot = function(importedModules, Gombot) {
Gombot.setCurrentUser(user); Gombot.setCurrentUser(user);
}, },
error: function(args) { error: function(args) {
console.log("ERROR", JSON.stringify(args)); console.log("ERROR"+JSON.stringify(args));
if (args.response && args.response.errorMessage.match(/That email has already been used/)) { if (args.response && args.response.errorMessage && args.response.errorMessage.match(/That email has already been used/)) {
} }
}, },
password: "foobar", password: "foobar",
newsletter: false newsletter: false
}); });
} else {
console.log("we found a user :"+JSON.stringify(loggedInUser));
} }
}}); }});
} }

Просмотреть файл

@ -11,7 +11,7 @@ var GombotSync = function(Gombot, Backbone, _) {
try { try {
response = JSON.parse(err.error.responseText); response = JSON.parse(err.error.responseText);
} catch(e) {}; } catch(e) {};
result.response = response || ""; result.response = response || {};
} }
console.log("GombotSync error", result); console.log("GombotSync error", result);
if (handler) handler(result); if (handler) handler(result);

Просмотреть файл

@ -99,6 +99,7 @@ var User = function(Backbone, _, Gombot, LocalStorage) {
var success = function(resp) { var success = function(resp) {
var s = options.success; var s = options.success;
options.success = function(model, resp, options) { options.success = function(model, resp, options) {
console.log("User.sync finished method="+method+" resp="+JSON.stringify(resp)+" model="+JSON.stringify(model));
// resp.data is returned by GombotSync calls with plaintext user data // resp.data is returned by GombotSync calls with plaintext user data
if (s) s(model, resp.data || {}, options); if (s) s(model, resp.data || {}, options);
} }
@ -108,6 +109,7 @@ var User = function(Backbone, _, Gombot, LocalStorage) {
if (method === "read") { if (method === "read") {
self.save(resp.data, _.extend(options, { localOnly: true, ciphertext: resp.ciphertext })); self.save(resp.data, _.extend(options, { localOnly: true, ciphertext: resp.ciphertext }));
} else { } else {
console.log("localSync method="+method);
Backbone.localSync(method, model, _.extend(options, { ciphertext: resp.ciphertext })); Backbone.localSync(method, model, _.extend(options, { ciphertext: resp.ciphertext }));
} }
} else if (options.success) { } else if (options.success) {

Просмотреть файл

@ -14,11 +14,10 @@ var Xhrequest = function(url, req) {
}; };
reqObj.onComplete = function(response) { reqObj.onComplete = function(response) {
//console.log(JSON.stringify(response.json))
if (response.status === 200) { if (response.status === 200) {
success(response.text); success(response.text);
} else { } else {
error({ error: { responseText: response.text }, status: response.status }, {}, response.status); error({ responseText: response.text }, {}, response.status);
} }
}; };

1
data/gombot-content.js Symbolic link
Просмотреть файл

@ -0,0 +1 @@
../packages/gombot-crypto-jetpack/data/gombot-content.js

1
data/gombot-worker1.html Symbolic link
Просмотреть файл

@ -0,0 +1 @@
../packages/gombot-crypto-jetpack/data/gombot-worker1.html

1
data/gombot-worker1.js Symbolic link
Просмотреть файл

@ -0,0 +1 @@
../packages/gombot-crypto-jetpack/data/gombot-worker1.js

1
data/gombot-worker2.js Symbolic link
Просмотреть файл

@ -0,0 +1 @@
../packages/gombot-crypto-jetpack/data/gombot-worker2.js

1
data/sjcl-with-cbc.js Symbolic link
Просмотреть файл

@ -0,0 +1 @@
../packages/gombot-crypto-jetpack/data/sjcl-with-cbc.js

@ -0,0 +1 @@
Subproject commit 4fe6d2ae6e8c30237498e067f6ac91faaee65d2f

2
server

@ -1 +1 @@
Subproject commit f7c922a2171aa26680a7d0a37e184a896a757db0 Subproject commit cf341995c9060995b3f9a9c05df4ed3cd5561500