More namespacing
This commit is contained in:
parent
05101b69b0
commit
6bc19ef558
8 changed files with 296 additions and 264 deletions
47
js/api.js
47
js/api.js
|
@ -14,24 +14,27 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/************************************************
|
||||
window.textsecure = window.textsecure || {};
|
||||
|
||||
window.textsecure.api = function() {
|
||||
var self = {};
|
||||
|
||||
/************************************************
|
||||
*** Utilities to communicate with the server ***
|
||||
************************************************/
|
||||
// WARNING: THIS SERVER LOGS KEY MATERIAL FOR TESTING
|
||||
var URL_BASE = "http://sushiforeveryone.bluematt.me";
|
||||
// WARNING: THIS SERVER LOGS KEY MATERIAL FOR TESTING
|
||||
var URL_BASE = "http://sushiforeveryone.bluematt.me";
|
||||
|
||||
// This is the real server
|
||||
//var URL_BASE = "https://textsecure-service.whispersystems.org";
|
||||
// This is the real server
|
||||
//var URL_BASE = "https://textsecure-service.whispersystems.org";
|
||||
|
||||
var URL_CALLS = {};
|
||||
URL_CALLS['accounts'] = "/v1/accounts";
|
||||
URL_CALLS['devices'] = "/v1/devices";
|
||||
URL_CALLS['keys'] = "/v1/keys";
|
||||
URL_CALLS['push'] = "/v1/websocket";
|
||||
URL_CALLS['messages'] = "/v1/messages";
|
||||
URL_CALLS['attachment'] = "/v1/attachments";
|
||||
|
||||
var API = new function() {
|
||||
var URL_CALLS = {};
|
||||
URL_CALLS['accounts'] = "/v1/accounts";
|
||||
URL_CALLS['devices'] = "/v1/devices";
|
||||
URL_CALLS['keys'] = "/v1/keys";
|
||||
URL_CALLS['push'] = "/v1/websocket";
|
||||
URL_CALLS['messages'] = "/v1/messages";
|
||||
URL_CALLS['attachment'] = "/v1/attachments";
|
||||
|
||||
/**
|
||||
* REQUIRED PARAMS:
|
||||
|
@ -90,7 +93,7 @@ var API = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.requestVerificationCode = function(number, success_callback, error_callback) {
|
||||
self.requestVerificationCode = function(number, success_callback, error_callback) {
|
||||
doAjax({
|
||||
call : 'accounts',
|
||||
httpType : 'GET',
|
||||
|
@ -104,7 +107,7 @@ var API = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.confirmCode = function(code, number, password,
|
||||
self.confirmCode = function(code, number, password,
|
||||
signaling_key, registrationId, single_device,
|
||||
success_callback, error_callback) {
|
||||
var call = single_device ? 'accounts' : 'devices';
|
||||
|
@ -129,7 +132,7 @@ var API = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.registerKeys = function(keys, success_callback, error_callback) {
|
||||
self.registerKeys = function(keys, success_callback, error_callback) {
|
||||
//TODO: Do this conversion somewhere else?
|
||||
var identityKey = btoa(getString(keys.keys[0].identityKey));
|
||||
for (var i = 0; i < keys.keys.length; i++)
|
||||
|
@ -149,7 +152,7 @@ var API = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.getKeysForNumber = function(number) {
|
||||
self.getKeysForNumber = function(number) {
|
||||
return doAjax({
|
||||
call : 'keys',
|
||||
httpType : 'GET',
|
||||
|
@ -168,7 +171,7 @@ var API = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.sendMessages = function(destination, messageArray) {
|
||||
self.sendMessages = function(destination, messageArray) {
|
||||
//TODO: Do this conversion somewhere else?
|
||||
for (var i = 0; i < messageArray.length; i++)
|
||||
messageArray[i].body = btoa(messageArray[i].body);
|
||||
|
@ -185,7 +188,7 @@ var API = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.getAttachment = function(id) {
|
||||
self.getAttachment = function(id) {
|
||||
return doAjax({
|
||||
call : 'attachment',
|
||||
httpType : 'GET',
|
||||
|
@ -218,4 +221,6 @@ var API = new function() {
|
|||
});
|
||||
});
|
||||
};
|
||||
}(); // API
|
||||
|
||||
return self;
|
||||
}();
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
registerOnLoadFunction(function() {
|
||||
textsecure.registerOnLoadFunction(function() {
|
||||
if (!localStorage.getItem('first_install_ran')) {
|
||||
localStorage.setItem('first_install_ran', 1);
|
||||
chrome.tabs.create({url: "options.html"});
|
||||
} else {
|
||||
if (isRegistrationDone()) {
|
||||
subscribeToPush(function(message) {
|
||||
textsecure.subscribeToPush(function(message) {
|
||||
console.log("Got message from " + message.pushMessage.source + "." + message.pushMessage.sourceDevice +
|
||||
': "' + getString(message.message.body) + '"');
|
||||
var newUnreadCount = storage.getUnencrypted("unreadCount", 0) + 1;
|
||||
|
|
24
js/crypto.js
24
js/crypto.js
|
@ -14,9 +14,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var textsecure = textsecure || {};
|
||||
window.textsecure = window.textsecure || {};
|
||||
|
||||
textsecure.crypto = new function() {
|
||||
window.textsecure.crypto = new function() {
|
||||
var self = {};
|
||||
// functions exposed for replacement and direct calling in test code
|
||||
var testing_only = {};
|
||||
|
||||
|
@ -38,7 +39,7 @@ textsecure.crypto = new function() {
|
|||
throw err;
|
||||
}
|
||||
}
|
||||
this.getRandomBytes = getRandomBytes;
|
||||
self.getRandomBytes = getRandomBytes;
|
||||
|
||||
function intToArrayBuffer(nInt) {
|
||||
var res = new ArrayBuffer(16);
|
||||
|
@ -67,7 +68,7 @@ textsecure.crypto = new function() {
|
|||
return pub;
|
||||
}
|
||||
|
||||
if (USE_NACL) {
|
||||
if (textsecure.nacl.USE_NACL) {
|
||||
return postNaclMessage({command: "bytesToPriv", priv: privKey}).then(function(message) {
|
||||
var priv = message.res;
|
||||
if (!isIdentity)
|
||||
|
@ -238,7 +239,7 @@ textsecure.crypto = new function() {
|
|||
console.error("WARNING: Expected pubkey of length 33, please report the ST and client that generated the pubkey");
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
if (USE_NACL) {
|
||||
if (textsecure.nacl.USE_NACL) {
|
||||
postNaclMessage({command: "ECDHE", priv: privKey, pub: pubKey}).then(function(message) {
|
||||
resolve(message.res);
|
||||
});
|
||||
|
@ -556,7 +557,7 @@ textsecure.crypto = new function() {
|
|||
*** Public crypto API ***
|
||||
*************************/
|
||||
// Decrypts message into a raw string
|
||||
this.decryptWebsocketMessage = function(message) {
|
||||
self.decryptWebsocketMessage = function(message) {
|
||||
var signaling_key = storage.getEncrypted("signaling_key"); //TODO: in crypto_storage
|
||||
var aes_key = toArrayBuffer(signaling_key.substring(0, 32));
|
||||
var mac_key = toArrayBuffer(signaling_key.substring(32, 32 + 20));
|
||||
|
@ -575,7 +576,7 @@ textsecure.crypto = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.decryptAttachment = function(encryptedBin, keys) {
|
||||
self.decryptAttachment = function(encryptedBin, keys) {
|
||||
var aes_key = keys.slice(0, 32);
|
||||
var mac_key = keys.slice(32, 64);
|
||||
|
||||
|
@ -589,7 +590,7 @@ textsecure.crypto = new function() {
|
|||
});
|
||||
};
|
||||
|
||||
this.handleIncomingPushMessageProto = function(proto) {
|
||||
self.handleIncomingPushMessageProto = function(proto) {
|
||||
switch(proto.type) {
|
||||
case 0: //TYPE_MESSAGE_PLAINTEXT
|
||||
return Promise.resolve({message: decodePushMessageContentProtobuf(getString(proto.message)), pushMessage:proto});
|
||||
|
@ -612,7 +613,7 @@ textsecure.crypto = new function() {
|
|||
}
|
||||
|
||||
// return Promise(encoded [PreKey]WhisperMessage)
|
||||
this.encryptMessageFor = function(deviceObject, pushMessageContent) {
|
||||
self.encryptMessageFor = function(deviceObject, pushMessageContent) {
|
||||
var session = crypto_storage.getOpenSession(deviceObject.encodedNumber);
|
||||
|
||||
var doEncryptPushMessageContent = function() {
|
||||
|
@ -679,7 +680,7 @@ textsecure.crypto = new function() {
|
|||
}
|
||||
|
||||
var GENERATE_KEYS_KEYS_GENERATED = 100;
|
||||
this.generateKeys = function() {
|
||||
self.generateKeys = function() {
|
||||
var identityKey = crypto_storage.getStoredPubKey("identityKey");
|
||||
var identityKeyCalculated = function(pubKey) {
|
||||
identityKey = pubKey;
|
||||
|
@ -721,5 +722,6 @@ textsecure.crypto = new function() {
|
|||
return identityKeyCalculated(identityKey);
|
||||
}
|
||||
|
||||
this.testing_only = testing_only;
|
||||
self.testing_only = testing_only;
|
||||
return self;
|
||||
}();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//TODO: Redo this (API has changed to textsecure.api and changed)
|
||||
var FakeWhisperAPI = function() {
|
||||
var doAjax = function(param) {
|
||||
if (param.success_callback) {
|
||||
|
|
134
js/helpers.js
134
js/helpers.js
|
@ -92,6 +92,8 @@ function base64EncArr (aBytes) {
|
|||
|
||||
/* END CRAP TO BE DELETED */
|
||||
|
||||
window.textsecure = window.textsecure || {};
|
||||
|
||||
/*********************************
|
||||
*** Type conversion utilities ***
|
||||
*********************************/
|
||||
|
@ -176,7 +178,7 @@ function base64ToArrayBuffer(string) {
|
|||
return base64DecToArr(string);
|
||||
}
|
||||
|
||||
// Protobuf decodingA
|
||||
// Protobuf decoding
|
||||
//TODO: throw on missing fields everywhere
|
||||
var IncomingPushMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/IncomingPushMessageSignal.proto").build("textsecure.IncomingPushMessageSignal");
|
||||
function decodeIncomingPushMessageProtobuf(string) {
|
||||
|
@ -224,13 +226,6 @@ function verifyNumber(string) {
|
|||
return getEncodedNumber(string.trim());
|
||||
}
|
||||
|
||||
function getDeviceId(encodedNumber) {
|
||||
var split = encodedNumber.split(".");
|
||||
if (split.length > 1)
|
||||
return split[1];
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Other
|
||||
|
||||
function timestampToHumanReadable(timestamp) {
|
||||
|
@ -251,18 +246,21 @@ function objectContainsKeys(object) {
|
|||
/************************************************
|
||||
*** Utilities to store data in local storage ***
|
||||
************************************************/
|
||||
var storage = new function() {
|
||||
//TODO: textsecure.storage
|
||||
window.storage = function() {
|
||||
var self = {};
|
||||
|
||||
/*****************************
|
||||
*** Base Storage Routines ***
|
||||
*****************************/
|
||||
this.putEncrypted = function(key, value) {
|
||||
self.putEncrypted = function(key, value) {
|
||||
//TODO
|
||||
if (value === undefined)
|
||||
throw new Error("Tried to store undefined");
|
||||
localStorage.setItem("e" + key, jsonThing(value));
|
||||
}
|
||||
|
||||
this.getEncrypted = function(key, defaultValue) {
|
||||
self.getEncrypted = function(key, defaultValue) {
|
||||
//TODO
|
||||
var value = localStorage.getItem("e" + key);
|
||||
if (value === null)
|
||||
|
@ -270,40 +268,42 @@ var storage = new function() {
|
|||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
this.removeEncrypted = function(key) {
|
||||
self.removeEncrypted = function(key) {
|
||||
localStorage.removeItem("e" + key);
|
||||
}
|
||||
|
||||
this.putUnencrypted = function(key, value) {
|
||||
self.putUnencrypted = function(key, value) {
|
||||
if (value === undefined)
|
||||
throw new Error("Tried to store undefined");
|
||||
localStorage.setItem("u" + key, jsonThing(value));
|
||||
}
|
||||
|
||||
this.getUnencrypted = function(key, defaultValue) {
|
||||
self.getUnencrypted = function(key, defaultValue) {
|
||||
var value = localStorage.getItem("u" + key);
|
||||
if (value === null)
|
||||
return defaultValue;
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
this.removeUnencrypted = function(key) {
|
||||
self.removeUnencrypted = function(key) {
|
||||
localStorage.removeItem("u" + key);
|
||||
}
|
||||
|
||||
/**********************
|
||||
*** Device Storage ***
|
||||
**********************/
|
||||
this.devices = new function() {
|
||||
this.getDeviceObject = function(encodedNumber) {
|
||||
self.devices = function() {
|
||||
var self = {};
|
||||
|
||||
self.getDeviceObject = function(encodedNumber) {
|
||||
return storage.getEncrypted("deviceObject" + getEncodedNumber(encodedNumber));
|
||||
}
|
||||
|
||||
this.getDeviceIdListFromNumber = function(number) {
|
||||
self.getDeviceIdListFromNumber = function(number) {
|
||||
return storage.getEncrypted("deviceIdList" + getNumberFromString(number), []);
|
||||
}
|
||||
|
||||
this.addDeviceIdForNumber = function(number, deviceId) {
|
||||
self.addDeviceIdForNumber = function(number, deviceId) {
|
||||
var deviceIdList = this.getDeviceIdListFromNumber(getNumberFromString(number));
|
||||
for (var i = 0; i < deviceIdList.length; i++) {
|
||||
if (deviceIdList[i] == deviceId)
|
||||
|
@ -313,8 +313,15 @@ var storage = new function() {
|
|||
storage.putEncrypted("deviceIdList" + getNumberFromString(number), deviceIdList);
|
||||
}
|
||||
|
||||
var getDeviceId = function(encodedNumber) {
|
||||
var split = encodedNumber.split(".");
|
||||
if (split.length > 1)
|
||||
return split[1];
|
||||
return 1;
|
||||
}
|
||||
|
||||
// throws "Identity key mismatch"
|
||||
this.saveDeviceObject = function(deviceObject) {
|
||||
self.saveDeviceObject = function(deviceObject) {
|
||||
var existing = this.getDeviceObject(deviceObject.encodedNumber);
|
||||
if (existing === undefined)
|
||||
existing = {encodedNumber: getEncodedNumber(deviceObject.encodedNumber)};
|
||||
|
@ -331,15 +338,19 @@ var storage = new function() {
|
|||
this.addDeviceIdForNumber(deviceObject.encodedNumber, getDeviceId(deviceObject.encodedNumber));
|
||||
}
|
||||
|
||||
this.getDeviceObjectListFromNumber = function(number) {
|
||||
self.getDeviceObjectListFromNumber = function(number) {
|
||||
var deviceObjectList = [];
|
||||
var deviceIdList = this.getDeviceIdListFromNumber(number);
|
||||
for (var i = 0; i < deviceIdList.length; i++)
|
||||
deviceObjectList[deviceObjectList.length] = this.getDeviceObject(getNumberFromString(number) + "." + deviceIdList[i]);
|
||||
return deviceObjectList;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return self;
|
||||
}();
|
||||
|
||||
return self;
|
||||
}();
|
||||
|
||||
function registrationDone() {
|
||||
storage.putUnencrypted("registration_done", "");
|
||||
|
@ -374,34 +385,37 @@ function storeMessage(messageObject) {
|
|||
/**********************
|
||||
*** NaCL Interface ***
|
||||
**********************/
|
||||
var USE_NACL = false;
|
||||
window.textsecure.nacl = function() {
|
||||
var self = {};
|
||||
|
||||
var onLoadCallbacks = [];
|
||||
var naclLoaded = 0;
|
||||
function registerOnLoadFunction(func) {
|
||||
if (naclLoaded || !USE_NACL) {
|
||||
self.USE_NACL = false;
|
||||
|
||||
var onLoadCallbacks = [];
|
||||
var naclLoaded = 0;
|
||||
self.registerOnLoadFunction = function(func) {
|
||||
if (naclLoaded || !self.USE_NACL) {
|
||||
func();
|
||||
return;
|
||||
}
|
||||
onLoadCallbacks[onLoadCallbacks.length] = func;
|
||||
}
|
||||
}
|
||||
|
||||
var naclMessageNextId = 0;
|
||||
var naclMessageIdCallbackMap = {};
|
||||
function moduleDidLoad() {
|
||||
var naclMessageNextId = 0;
|
||||
var naclMessageIdCallbackMap = {};
|
||||
window.moduleDidLoad = function() {
|
||||
common.hideModule();
|
||||
naclLoaded = 1;
|
||||
for (var i = 0; i < onLoadCallbacks.length; i++)
|
||||
onLoadCallbacks[i]();
|
||||
onLoadCallbacks = [];
|
||||
}
|
||||
}
|
||||
|
||||
function handleMessage(message) {
|
||||
window.handleMessage = function(message) {
|
||||
naclMessageIdCallbackMap[message.data.call_id](message.data);
|
||||
}
|
||||
}
|
||||
|
||||
function postNaclMessage(message) {
|
||||
if (!USE_NACL)
|
||||
self.postNaclMessage = function(message) {
|
||||
if (!self.USE_NACL)
|
||||
throw new Error("Attempted to make NaCL call with !USE_NACL?");
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
|
@ -410,11 +424,18 @@ function postNaclMessage(message) {
|
|||
|
||||
common.naclModule.postMessage(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// message_callback(decoded_protobuf) (use decodeMessage(proto))
|
||||
var subscribeToPushMessageSemaphore = 0;
|
||||
function subscribeToPush(message_callback) {
|
||||
return self;
|
||||
}();
|
||||
|
||||
//TODO: Some kind of textsecure.init(use_nacl)
|
||||
window.textsecure.registerOnLoadFunction = window.textsecure.nacl.registerOnLoadFunction;
|
||||
|
||||
// message_callback({message: decryptedMessage, pushMessage: server-providedPushMessage})
|
||||
window.textsecure.subscribeToPush = function() {
|
||||
var subscribeToPushMessageSemaphore = 0;
|
||||
return function(message_callback) {
|
||||
subscribeToPushMessageSemaphore++;
|
||||
if (subscribeToPushMessageSemaphore <= 0)
|
||||
return;
|
||||
|
@ -463,7 +484,7 @@ function subscribeToPush(message_callback) {
|
|||
socket.send(JSON.stringify({type: 1, id: message.id}));
|
||||
return textsecure.crypto.handleIncomingPushMessageProto(proto).then(function(decrypted) {
|
||||
var handleAttachment = function(attachment) {
|
||||
return API.getAttachment(attachment.id).then(function(encryptedBin) {
|
||||
return textsecure.api.getAttachment(attachment.id).then(function(encryptedBin) {
|
||||
return textsecure.crypto.decryptAttachment(encryptedBin, toArrayBuffer(attachment.key)).then(function(decryptedBin) {
|
||||
attachment.decrypted = decryptedBin;
|
||||
});
|
||||
|
@ -485,11 +506,13 @@ function subscribeToPush(message_callback) {
|
|||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
// success_callback(identity_key), error_callback(error_msg)
|
||||
function getKeysForNumber(number) {
|
||||
return API.getKeysForNumber(number).then(function(response) {
|
||||
// sendMessage(numbers = [], message = PushMessageContentProto, callback(success/failure map))
|
||||
window.textsecure.sendMessage = function() {
|
||||
function getKeysForNumber(number) {
|
||||
return textsecure.api.getKeysForNumber(number).then(function(response) {
|
||||
for (var i = 0; i < response.length; i++) {
|
||||
storage.devices.saveDeviceObject({
|
||||
encodedNumber: number + "." + response[i].deviceId,
|
||||
|
@ -501,11 +524,11 @@ function getKeysForNumber(number) {
|
|||
}
|
||||
return response[0].identityKey;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// success_callback(server success/failure map), error_callback(error_msg)
|
||||
// message == PushMessageContentProto (NOT STRING)
|
||||
function sendMessageToDevices(number, deviceObjectList, message, success_callback, error_callback) {
|
||||
// success_callback(server success/failure map), error_callback(error_msg)
|
||||
// message == PushMessageContentProto (NOT STRING)
|
||||
function sendMessageToDevices(number, deviceObjectList, message, success_callback, error_callback) {
|
||||
var jsonData = [];
|
||||
var relay = undefined;
|
||||
var promises = [];
|
||||
|
@ -537,13 +560,11 @@ function sendMessageToDevices(number, deviceObjectList, message, success_callbac
|
|||
for (var i = 0; i < deviceObjectList.length; i++)
|
||||
promises[i] = addEncryptionFor(i);
|
||||
return Promise.all(promises).then(function() {
|
||||
return API.sendMessages(number, jsonData);
|
||||
return textsecure.api.sendMessages(number, jsonData);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// callback(success/failure map, see code)
|
||||
// message == PushMessageContentProto (NOT STRING)
|
||||
function sendMessageToNumbers(numbers, message, callback) {
|
||||
return function(numbers, message, callback) {
|
||||
var numbersCompleted = 0;
|
||||
var errors = [];
|
||||
var successfulNumbers = [];
|
||||
|
@ -588,7 +609,8 @@ function sendMessageToNumbers(numbers, message, callback) {
|
|||
} else
|
||||
doSendMessage(number, devicesForNumber, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
function requestIdentityPrivKeyFromMasterDevice(number, identityKey) {
|
||||
sendMessageToDevices([storage.devices.getDeviceObject(getNumberFromString(number)) + ".1"],
|
||||
|
|
|
@ -56,7 +56,7 @@ $('#init-go-single-client').click(function() {
|
|||
|
||||
single_device = true;
|
||||
|
||||
API.requestVerificationCode(number,
|
||||
textsecure.api.requestVerificationCode(number,
|
||||
function(response) { },
|
||||
function(code) {
|
||||
alert("Failed to send key?" + code); //TODO
|
||||
|
@ -76,7 +76,7 @@ $('#init-go').click(function() {
|
|||
$('#verify4done').html('');
|
||||
$('#verify').show();
|
||||
|
||||
API.confirmCode($('#code').val(), number, password, signaling_key, registrationId, single_device,
|
||||
textsecure.api.confirmCode($('#code').val(), number, password, signaling_key, registrationId, single_device,
|
||||
function(response) {
|
||||
if (single_device)
|
||||
response = 1;
|
||||
|
@ -91,7 +91,7 @@ $('#init-go').click(function() {
|
|||
$('#verify2done').html('done');
|
||||
textsecure.crypto.generateKeys().then(function(keys) {
|
||||
$('#verify3done').html('done');
|
||||
API.registerKeys(keys,
|
||||
textsecure.api.registerKeys(keys,
|
||||
function(response) {
|
||||
$('#complete-number').html(number);
|
||||
$('#verify').hide();
|
||||
|
@ -105,15 +105,17 @@ $('#init-go').click(function() {
|
|||
}
|
||||
|
||||
if (!single_device) {
|
||||
getKeysForNumber(number).then(function(identityKey) {
|
||||
subscribeToPush(function(message) {
|
||||
//TODO: Redo all this
|
||||
/*getKeysForNumber(number).then(function(identityKey) {
|
||||
textsecure.subscribeToPush(function(message) {
|
||||
//TODO receive shared identity key
|
||||
register_keys_func();
|
||||
});
|
||||
requestIdentityPrivKeyFromMasterDevice(number);
|
||||
}).catch(function(error) {
|
||||
alert(error); //TODO
|
||||
});
|
||||
});*/
|
||||
register_keys_func();
|
||||
} else {
|
||||
register_keys_func();
|
||||
}
|
||||
|
@ -136,7 +138,7 @@ $('#init-go').click(function() {
|
|||
}
|
||||
});
|
||||
|
||||
registerOnLoadFunction(function() {
|
||||
textsecure.registerOnLoadFunction(function() {
|
||||
if (!isRegistrationDone()) {
|
||||
$('#init-setup').show();
|
||||
} else {
|
||||
|
|
|
@ -23,7 +23,7 @@ $('#send_link').click(function() {
|
|||
$('#send').show();
|
||||
});
|
||||
|
||||
registerOnLoadFunction(function() {
|
||||
textsecure.registerOnLoadFunction(function() {
|
||||
if (storage.getUnencrypted("number_id") === undefined) {
|
||||
chrome.tabs.create({url: "options.html"});
|
||||
} else {
|
||||
|
@ -73,7 +73,7 @@ registerOnLoadFunction(function() {
|
|||
var messageProto = new PushMessageContentProtobuf();
|
||||
messageProto.body = input.val();
|
||||
|
||||
sendMessageToNumbers(sendDestinations, messageProto, function(result) {
|
||||
textsecure.sendMessage(sendDestinations, messageProto, function(result) {
|
||||
console.log(result);
|
||||
button.removeAttr("disabled");
|
||||
button.text("Send");
|
||||
|
@ -109,7 +109,7 @@ registerOnLoadFunction(function() {
|
|||
}
|
||||
var messageProto = new PushMessageContentProtobuf();
|
||||
messageProto.body = $("#popup_send_text").val();
|
||||
sendMessageToNumbers(numbers, messageProto,
|
||||
textsecure.sendMessage(numbers, messageProto,
|
||||
//TODO: Handle result
|
||||
function(thing) {console.log(thing);});
|
||||
});
|
||||
|
|
|
@ -95,7 +95,7 @@ function hexToArrayBuffer(str) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
registerOnLoadFunction(function() {
|
||||
textsecure.registerOnLoadFunction(function() {
|
||||
localStorage.clear();
|
||||
|
||||
// Random tests to check my JS knowledge
|
||||
|
|
Loading…
Reference in a new issue