Update to real server provisioning API

pull/749/head
Matt Corallo 10 years ago
parent c112c59ce6
commit 29b2ffc769

@ -5674,6 +5674,7 @@ CryptoJS.lib.Cipher || (function (undefined) {
PushMessageContent : pushMessages.PushMessageContent, PushMessageContent : pushMessages.PushMessageContent,
WhisperMessage : protocolMessages.WhisperMessage, WhisperMessage : protocolMessages.WhisperMessage,
PreKeyWhisperMessage : protocolMessages.PreKeyWhisperMessage, PreKeyWhisperMessage : protocolMessages.PreKeyWhisperMessage,
ProvisioningUuid : deviceMessages.ProvisioningUuid,
DeviceInit : deviceMessages.DeviceInit, DeviceInit : deviceMessages.DeviceInit,
IdentityKey : deviceMessages.IdentityKey, IdentityKey : deviceMessages.IdentityKey,
DeviceControl : deviceMessages.DeviceControl, DeviceControl : deviceMessages.DeviceControl,
@ -6739,7 +6740,7 @@ window.textsecure.api = function () {
URL_CALLS.devices = "/v1/devices"; URL_CALLS.devices = "/v1/devices";
URL_CALLS.keys = "/v2/keys"; URL_CALLS.keys = "/v2/keys";
URL_CALLS.push = "/v1/websocket"; URL_CALLS.push = "/v1/websocket";
URL_CALLS.temp_push = "/v1/temp_websocket"; URL_CALLS.temp_push = "/v1/provisioning";
URL_CALLS.messages = "/v1/messages"; URL_CALLS.messages = "/v1/messages";
URL_CALLS.attachment = "/v1/attachments"; URL_CALLS.attachment = "/v1/attachments";
@ -7023,13 +7024,7 @@ window.textsecure.api = function () {
} }
self.getTempWebsocket = function() { self.getTempWebsocket = function() {
//XXX return getWebsocket(URL_CALLS['temp_push'], false, 1000);
var socketWrapper = { onmessage: function() {}, ondisconnect: function() {}, onconnect: function() {} };
setTimeout(function() {
socketWrapper.onmessage({uuid: "404-42-magic"});
}, 1000);
return socketWrapper;
//return getWebsocket(URL_CALLS['temp_push'], false, 5000);
} }
return self; return self;

@ -137,16 +137,18 @@
$('#setup-qr').html(''); $('#setup-qr').html('');
textsecure.protocol.prepareTempWebsocket().then(function(cryptoInfo) { textsecure.protocol.prepareTempWebsocket().then(function(cryptoInfo) {
var qrCode = new QRCode(document.getElementById('setup-qr')); var qrCode = new QRCode(document.getElementById('setup-qr'));
var socket = textsecure.api.getTempWebsocket();
socket.onmessage = function(message) { var socket = textsecure.api.getTempWebsocket();
if (message.uuid) { new WebSocketResource(socket, function(request) {
if (request.path == "/v1/address" && request.verb == "PUT") {
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
qrCode.makeCode('textsecure-device-init:/' + qrCode.makeCode('textsecure-device-init:/' +
'?channel_uuid=' + message.uuid + '?channel_uuid=' + proto.uuid +
'&channel_server=' + textsecure.api.relay + '&channel_server=' + textsecure.api.relay +
'&publicKey=' + btoa(getString(cryptoInfo.publicKey))); '&publicKey=' + btoa(getString(cryptoInfo.publicKey)));
$('img').removeAttr('style'); $('img').removeAttr('style');
$('#multi-device .status').text("Use your phone to scan the QR code.") $('#multi-device .status').text("Use your phone to scan the QR code.")
request.respond(200, 'OK');
} else { } else {
$('#init-setup').hide(); $('#init-setup').hide();
$('#verify1done').text(''); $('#verify1done').text('');
@ -157,7 +159,7 @@
$('#verify').show().addClass('in'); $('#verify').show().addClass('in');
textsecure.registerSecondDevice(cryptoInfo, message.message, function(step) { textsecure.registerSecondDevice(message.body, cryptoInfo, function(step) {
switch(step) { switch(step) {
case 1: case 1:
$('#verify1done').text('done'); $('#verify1done').text('done');
@ -179,11 +181,7 @@
} }
}); });
} }
}; });
socket.ondisconnect = function() {
$('#multi-device .status').text("The push server disconnected, please wait while we reconnect...");
};
}); });
}); });
} }

@ -37,7 +37,7 @@ window.textsecure.api = function () {
URL_CALLS.devices = "/v1/devices"; URL_CALLS.devices = "/v1/devices";
URL_CALLS.keys = "/v2/keys"; URL_CALLS.keys = "/v2/keys";
URL_CALLS.push = "/v1/websocket"; URL_CALLS.push = "/v1/websocket";
URL_CALLS.temp_push = "/v1/temp_websocket"; URL_CALLS.temp_push = "/v1/provisioning";
URL_CALLS.messages = "/v1/messages"; URL_CALLS.messages = "/v1/messages";
URL_CALLS.attachment = "/v1/attachments"; URL_CALLS.attachment = "/v1/attachments";
@ -321,13 +321,7 @@ window.textsecure.api = function () {
} }
self.getTempWebsocket = function() { self.getTempWebsocket = function() {
//XXX return getWebsocket(URL_CALLS['temp_push'], false, 1000);
var socketWrapper = { onmessage: function() {}, ondisconnect: function() {}, onconnect: function() {} };
setTimeout(function() {
socketWrapper.onmessage({uuid: "404-42-magic"});
}, 1000);
return socketWrapper;
//return getWebsocket(URL_CALLS['temp_push'], false, 5000);
} }
return self; return self;

@ -15,6 +15,7 @@
PushMessageContent : pushMessages.PushMessageContent, PushMessageContent : pushMessages.PushMessageContent,
WhisperMessage : protocolMessages.WhisperMessage, WhisperMessage : protocolMessages.WhisperMessage,
PreKeyWhisperMessage : protocolMessages.PreKeyWhisperMessage, PreKeyWhisperMessage : protocolMessages.PreKeyWhisperMessage,
ProvisioningUuid : deviceMessages.ProvisioningUuid,
DeviceInit : deviceMessages.DeviceInit, DeviceInit : deviceMessages.DeviceInit,
IdentityKey : deviceMessages.IdentityKey, IdentityKey : deviceMessages.IdentityKey,
DeviceControl : deviceMessages.DeviceControl, DeviceControl : deviceMessages.DeviceControl,

@ -1,5 +1,9 @@
package textsecure; package textsecure;
message ProvisioningUuid {
optional string uuid = 1;
}
message DeviceInit { message DeviceInit {
required bytes masterEphemeralPubKey = 1; required bytes masterEphemeralPubKey = 1;
required bytes identityKeyMessage = 2; // contains an IdentityKey required bytes identityKeyMessage = 2; // contains an IdentityKey

Loading…
Cancel
Save