diff --git a/js/libtextsecure.js b/js/libtextsecure.js
index 0f05c54f7..f7a0e36f3 100644
--- a/js/libtextsecure.js
+++ b/js/libtextsecure.js
@@ -38790,7 +38790,7 @@ window.textsecure.utils = function() {
var handleAttachment = function(attachment) {
function getAttachment() {
- return textsecure.api.getAttachment(attachment.id.toString());
+ return TextSecureServer.getAttachment(attachment.id.toString());
}
function decryptAttachment(encrypted) {
@@ -39024,9 +39024,7 @@ textsecure.processDecrypted = function(decrypted, source) {
* along with this program. If not, see .
*/
-window.textsecure = window.textsecure || {};
-
-window.textsecure.api = function () {
+TextSecureServer = function () {
'use strict';
var self = {};
@@ -39410,7 +39408,7 @@ window.textsecure.api = function () {
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
return new Promise(function(resolve) {
- new WebSocketResource(textsecure.api.getTempWebsocket(), function(request) {
+ new WebSocketResource(TextSecureServer.getTempWebsocket(), function(request) {
if (request.path == "/v1/address" && request.verb == "PUT") {
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
setProvisioningUrl([
@@ -39441,7 +39439,7 @@ window.textsecure.api = function () {
}).then(TextSecureServer.registerKeys).then(textsecure.registration.done);
},
refreshPreKeys: function() {
- return textsecure.api.getMyKeys().then(function(preKeyCount) {
+ return TextSecureServer.getMyKeys().then(function(preKeyCount) {
if (preKeyCount < 10) {
return generateKeys(100).then(TextSecureServer.registerKeys);
}
@@ -39462,7 +39460,7 @@ window.textsecure.api = function () {
var registrationId = axolotl.util.generateRegistrationId();
textsecure.storage.put("registrationId", registrationId);
- return textsecure.api.confirmCode(
+ return TextSecureServer.confirmCode(
number, verificationCode, password, signalingKey, registrationId, single_device
).then(function(response) {
textsecure.storage.user.setNumberAndDeviceId(number, response.deviceId || 1);
@@ -39560,7 +39558,7 @@ function generateKeys(count, progressCallback) {
constructor: MessageReceiver,
connect: function() {
// initialize the socket and start listening for messages
- this.socket = textsecure.api.getMessageWebsocket();
+ this.socket = TextSecureServer.getMessageWebsocket();
var eventTarget = this.target;
new WebSocketResource(this.socket, function(request) {
@@ -39639,9 +39637,9 @@ window.textsecure.messaging = function() {
var promises = [];
if (updateDevices !== undefined)
for (var i in updateDevices)
- promises[promises.length] = textsecure.api.getKeysForNumber(number, updateDevices[i]).then(handleResult);
+ promises[promises.length] = TextSecureServer.getKeysForNumber(number, updateDevices[i]).then(handleResult);
else
- return textsecure.api.getKeysForNumber(number).then(handleResult);
+ return TextSecureServer.getKeysForNumber(number).then(handleResult);
return Promise.all(promises);
}
@@ -39687,7 +39685,7 @@ window.textsecure.messaging = function() {
for (var i = 0; i < deviceObjectList.length; i++)
promises[i] = addEncryptionFor(i);
return Promise.all(promises).then(function() {
- return textsecure.api.sendMessages(number, jsonData);
+ return TextSecureServer.sendMessages(number, jsonData);
});
}
@@ -39838,7 +39836,7 @@ window.textsecure.messaging = function() {
var iv = textsecure.crypto.getRandomBytes(16);
return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) {
- return textsecure.api.putAttachment(encryptedBin).then(function(id) {
+ return TextSecureServer.putAttachment(encryptedBin).then(function(id) {
proto.id = id;
proto.contentType = attachment.contentType;
return proto;
diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js
index 7eb7d07f3..1ab06ad91 100644
--- a/libtextsecure/account_manager.js
+++ b/libtextsecure/account_manager.js
@@ -41,7 +41,7 @@
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
return new Promise(function(resolve) {
- new WebSocketResource(textsecure.api.getTempWebsocket(), function(request) {
+ new WebSocketResource(TextSecureServer.getTempWebsocket(), function(request) {
if (request.path == "/v1/address" && request.verb == "PUT") {
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
setProvisioningUrl([
@@ -72,7 +72,7 @@
}).then(TextSecureServer.registerKeys).then(textsecure.registration.done);
},
refreshPreKeys: function() {
- return textsecure.api.getMyKeys().then(function(preKeyCount) {
+ return TextSecureServer.getMyKeys().then(function(preKeyCount) {
if (preKeyCount < 10) {
return generateKeys(100).then(TextSecureServer.registerKeys);
}
@@ -92,7 +92,7 @@
var registrationId = axolotl.util.generateRegistrationId();
textsecure.storage.put("registrationId", registrationId);
- return textsecure.api.confirmCode(
+ return TextSecureServer.confirmCode(
number, verificationCode, password, signalingKey, registrationId, single_device
).then(function(response) {
textsecure.storage.user.setNumberAndDeviceId(number, response.deviceId || 1);
diff --git a/libtextsecure/api.js b/libtextsecure/api.js
index 958ba4201..eb1a8107e 100644
--- a/libtextsecure/api.js
+++ b/libtextsecure/api.js
@@ -14,9 +14,7 @@
* along with this program. If not, see .
*/
-window.textsecure = window.textsecure || {};
-
-window.textsecure.api = function () {
+TextSecureServer = function () {
'use strict';
var self = {};
diff --git a/libtextsecure/helpers.js b/libtextsecure/helpers.js
index ada38b17e..07ec076a7 100644
--- a/libtextsecure/helpers.js
+++ b/libtextsecure/helpers.js
@@ -128,7 +128,7 @@ window.textsecure.utils = function() {
var handleAttachment = function(attachment) {
function getAttachment() {
- return textsecure.api.getAttachment(attachment.id.toString());
+ return TextSecureServer.getAttachment(attachment.id.toString());
}
function decryptAttachment(encrypted) {
diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js
index 954ee7bcc..ece9e52ce 100644
--- a/libtextsecure/message_receiver.js
+++ b/libtextsecure/message_receiver.js
@@ -30,7 +30,7 @@
constructor: MessageReceiver,
connect: function() {
// initialize the socket and start listening for messages
- this.socket = textsecure.api.getMessageWebsocket();
+ this.socket = TextSecureServer.getMessageWebsocket();
var eventTarget = this.target;
new WebSocketResource(this.socket, function(request) {
diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js
index 5290cfdf1..f3668b4ff 100644
--- a/libtextsecure/sendmessage.js
+++ b/libtextsecure/sendmessage.js
@@ -40,9 +40,9 @@ window.textsecure.messaging = function() {
var promises = [];
if (updateDevices !== undefined)
for (var i in updateDevices)
- promises[promises.length] = textsecure.api.getKeysForNumber(number, updateDevices[i]).then(handleResult);
+ promises[promises.length] = TextSecureServer.getKeysForNumber(number, updateDevices[i]).then(handleResult);
else
- return textsecure.api.getKeysForNumber(number).then(handleResult);
+ return TextSecureServer.getKeysForNumber(number).then(handleResult);
return Promise.all(promises);
}
@@ -88,7 +88,7 @@ window.textsecure.messaging = function() {
for (var i = 0; i < deviceObjectList.length; i++)
promises[i] = addEncryptionFor(i);
return Promise.all(promises).then(function() {
- return textsecure.api.sendMessages(number, jsonData);
+ return TextSecureServer.sendMessages(number, jsonData);
});
}
@@ -239,7 +239,7 @@ window.textsecure.messaging = function() {
var iv = textsecure.crypto.getRandomBytes(16);
return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) {
- return textsecure.api.putAttachment(encryptedBin).then(function(id) {
+ return TextSecureServer.putAttachment(encryptedBin).then(function(id) {
proto.id = id;
proto.contentType = attachment.contentType;
return proto;
diff --git a/libtextsecure/test/fake_api.js b/libtextsecure/test/fake_api.js
index 12787d52c..6ce7f2b91 100644
--- a/libtextsecure/test/fake_api.js
+++ b/libtextsecure/test/fake_api.js
@@ -15,17 +15,17 @@
*/
var getKeysForNumberMap = {};
-textsecure.api.getKeysForNumber = function(number, deviceId) {
+TextSecureServer.getKeysForNumber = function(number, deviceId) {
var res = getKeysForNumberMap[number];
if (res !== undefined) {
delete getKeysForNumberMap[number];
return Promise.resolve(res);
} else
throw new Error("getKeysForNumber of unknown/used number");
-}
+};
var messagesSentMap = {};
-textsecure.api.sendMessages = function(destination, messageArray) {
+TextSecureServer.sendMessages = function(destination, messageArray) {
for (i in messageArray) {
var msg = messageArray[i];
if ((msg.type != 1 && msg.type != 3) ||
@@ -39,4 +39,4 @@ textsecure.api.sendMessages = function(destination, messageArray) {
messagesSentMap[destination + "." + messageArray[i].destinationDeviceId] = msg;
}
-}
+};