Add entirely untested secondary device init

This commit is contained in:
Matt Corallo 2014-07-26 01:31:41 -04:00
parent 379115d902
commit a6b0d1f84b
9 changed files with 425 additions and 198 deletions

View file

@ -18,7 +18,7 @@
}
html {
margin: 12px 0 0 100px; }
margin: 12px 100px 0 100px; }
h1 {
font-size: 30pt;
@ -30,6 +30,16 @@ h2 {
font-size: 12pt;
font-weight: normal; }
.left-column {
float: left;
width: 45%;
text-align: center; }
.right-column {
float: right;
width: 50%;
text-align: center; }
.hidden {
display: none; }
@ -37,12 +47,9 @@ h2 {
width: 50px;
height: 50px; }
#init-go-single-client {
display:block; }
#phonenumberspan {
display: block;
margin: .5em auto 1em auto; }
#countrycode {
text-align: right; }
text-align: right; }

File diff suppressed because one or more lines are too long

View file

@ -26,6 +26,7 @@ window.textsecure.api = function() {
************************************************/
// Staging server
var URL_BASE = "https://textsecure-service-ca.whispersystems.org:4433";
self.relay = "textsecure-service-staging.whispersystems.org";
// This is the real server
//var URL_BASE = "https://textsecure-service.whispersystems.org";
@ -35,6 +36,7 @@ window.textsecure.api = function() {
URL_CALLS['devices'] = "/v1/devices";
URL_CALLS['keys'] = "/v2/keys";
URL_CALLS['push'] = "/v1/websocket";
URL_CALLS['temp_push'] = "/v1/temp_websocket";
URL_CALLS['messages'] = "/v1/messages";
URL_CALLS['attachment'] = "/v1/attachments";
@ -279,15 +281,93 @@ window.textsecure.api = function() {
});
};
self.getWebsocket = function() {
var user = textsecure.storage.getUnencrypted("number_id");
var password = textsecure.storage.getEncrypted("password");
var URL = URL_BASE.replace(/^http/g, 'ws') + URL_CALLS['push'] + '/?';
var params = $.param({
login: '+' + getString(user).substring(1),
password: getString(password)
});
return new WebSocket(URL+params);
var getWebsocket = function(url, auth, reconnectTimeout) {
var URL = URL_BASE.replace(/^http/g, 'ws') + url + '/?';
if (auth) {
var user = textsecure.storage.getUnencrypted("number_id");
var password = textsecure.storage.getEncrypted("password");
var params = $.param({
login: '+' + getString(user).substring(1),
password: getString(password)
});
} else
var params = $.param({});
var reconnectSemaphore = 0;
var pingInterval;
var socketWrapper = { onmessage: function() {}, ondisconnect: function() {}, onconnect: function() {} };
var connect = function() {
reconnectSemaphore++;
if (reconnectSemaphore <= 0)
return;
var socket = new WebSocket(URL+params);
socket.onerror = function(socketEvent) {
console.log('Server is down :(');
clearInterval(pingInterval);
reconnectSemaphore--;
setTimeout(function() { connect(); }, reconnectTimeout);
socketWrapper.ondisconnect();
};
socket.onclose = function(socketEvent) {
console.log('Server closed :(');
clearInterval(pingInterval);
reconnectSemaphore--;
setTimeout(function() { connect(); }, reconnectTimeout);
socketWrapper.ondisconnect();
};
socket.onopen = function(socketEvent) {
console.log('Connected to server!');
pingInterval = setInterval(function() {
console.log("Sending server ping message.");
if (socket.readyState == socket.CLOSED || socket.readyState == socket.CLOSING) {
socket.close();
socket.onclose();
} else
socket.send(JSON.stringify({type: 2}));
}, reconnectTimeout / 2);
socketWrapper.onconnect();
};
//TODO: wrap onmessage so that we reconnect on missing pong
socket.onmessage = function(response) {
try {
var message = JSON.parse(response.data);
} catch (e) {
console.log('Error parsing server JSON message: ' + response);
return;
}
if (message.type == 3)
console.log("Got pong message");
else if ((message.type === undefined && message.id !== undefined) || message.type === 4)
socketWrapper.onmessage(message);
else
console.log("Got invalid message from server: " + message);
};
};
connect();
return socketWrapper;
}
self.getMessageWebsocket = function() {
return getWebsocket(URL_CALLS['push'], true, 60000);
}
self.getTempWebsocket = function() {
//XXX
var socketWrapper = { onmessage: function() {}, ondisconnect: function() {}, onconnect: function() {} };
setTimeout(function() {
socketWrapper.onmessage({type: 4, message: "404-42-magic"});
}, 1000);
return socketWrapper;
//return getWebsocket(URL_CALLS['temp_push'], false, 5000);
}
return self;

View file

@ -110,9 +110,13 @@ window.textsecure.crypto = function() {
***************************/
var crypto_storage = {};
crypto_storage.putKeyPair = function(keyName, keyPair) {
textsecure.storage.putEncrypted("25519Key" + keyName, keyPair);
}
crypto_storage.getNewStoredKeyPair = function(keyName, isIdentity) {
return createNewKeyPair(isIdentity).then(function(keyPair) {
textsecure.storage.putEncrypted("25519Key" + keyName, keyPair);
crypto_storage.putKeyPair(keyName, keyPair);
return keyPair;
});
}
@ -736,10 +740,10 @@ window.textsecure.crypto = function() {
var iv = decodedMessage.slice(1, 1 + 16);
var ciphertext = decodedMessage.slice(1 + 16, decodedMessage.byteLength - 10);
var ivAndCiphertext = decodedMessage.slice(1, decodedMessage.byteLength - 10);
var ivAndCiphertext = decodedMessage.slice(0, decodedMessage.byteLength - 10);
var mac = decodedMessage.slice(decodedMessage.byteLength - 10, decodedMessage.byteLength);
return verifyMACWithVersionByte(ivAndCiphertext, mac_key, mac).then(function() {
return verifyMAC(ivAndCiphertext, mac_key, mac).then(function() {
return window.crypto.subtle.decrypt({name: "AES-CBC", iv: iv}, aes_key, ciphertext);
});
};
@ -935,6 +939,47 @@ window.textsecure.crypto = function() {
self.Ed25519Verify = Ed25519Verify;
self.prepareTempWebsocket = function() {
var socketInfo = {};
var keyPair;
socketInfo.decryptAndHandleDeviceInit = function(deviceInit) {
var masterEphemeral = toArrayBuffer(deviceInit.masterEphemeralPubKey);
var message = toArrayBuffer(deviceInit.identityKeyMessage);
return ECDHE(masterEphemeral, keyPair.privKey).then(function(ecRes) {
return HKDF(ecRes, masterEphemeral, "WhisperDeviceInit").then(function(keys) {
if (new Uint8Array(message)[0] != (3 << 4) | 3)
throw new Error("Bad version number on IdentityKeyMessage");
var iv = message.slice(1, 16 + 1);
var mac = message.slice(message.length - 32, message.length);
var ivAndCiphertext = message.slice(0, message.length - 32);
var ciphertext = message.slice(16 + 1, message.length - 32);
return verifyMAC(ivAndCiphertext, ecRes[1], mac).then(function() {
window.crypto.subtle.decrypt({name: "AES-CBC", iv: iv}, ecRes[0], ciphertext).then(function(plaintext) {
var identityKeyMsg = textsecure.protos.decodeIdentityKeyProtobuf(getString(plaintext));
privToPub(toArrayBuffer(identityKeyMsg.identityKey)).then(function(identityKeyPair) {
crypto_storage.putKeyPair("identityKey", identityKeyPair);
identityKeyMsg.identityKey = null;
return identityKeyMsg;
});
});
});
});
});
}
return createNewKeyPair(false).then(function(newKeyPair) {
keyPair = newKeyPair;
socketInfo.pubKey = keyPair.pubKey;
return socketInfo;
});
}
self.testing_only = testing_only;
return self;
}();

View file

@ -195,9 +195,19 @@ window.textsecure.protos = function() {
return self.PreKeyWhisperMessageProtobuf.decode(btoa(string));
}
self.KeyExchangeMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/WhisperTextProtocol.proto").build("textsecure.KeyExchangeMessage");
self.decodeKeyExchangeMessageProtobuf = function(string) {
return self.KeyExchangeMessageProtobuf.decode(btoa(string));
self.DeviceInitProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/DeviceMessages.proto").build("textsecure.DeviceInit");
self.decodeDeviceInitProtobuf = function(string) {
return self.DeviceInitProtobuf.decode(btoa(string));
}
self.IdentityKeyProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/DeviceMessages.proto").build("textsecure.IdentityKey");
self.decodeIdentityKeyProtobuf = function(string) {
return self.IdentityKeyProtobuf.decode(btoa(string));
}
self.DeviceControlProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/DeviceMessages.proto").build("textsecure.DeviceControl");
self.decodeDeviceControlProtobuf = function(string) {
return self.DeviceControlProtobuf.decode(btoa(string));
}
return self;
@ -635,154 +645,109 @@ window.textsecure.replay = function() {
}();
// message_callback({message: decryptedMessage, pushMessage: server-providedPushMessage})
window.textsecure.subscribeToPush = function() {
var subscribeToPushMessageSemaphore = 0;
return function(message_callback) {
subscribeToPushMessageSemaphore++;
if (subscribeToPushMessageSemaphore <= 0)
return;
window.textsecure.subscribeToPush = function(message_callback) {
var socket = textsecure.api.getMessageWebsocket();
var socket = textsecure.api.getWebsocket();
socket.onmessage = function(message) {
textsecure.crypto.decryptWebsocketMessage(message.message).then(function(plaintext) {
var proto = textsecure.protos.decodeIncomingPushMessageProtobuf(getString(plaintext));
// After this point, a) decoding errors are not the server's fault, and
// b) we should handle them gracefully and tell the user they received an invalid message
console.log("Successfully decoded message with id: " + message.id);
socket.send(JSON.stringify({type: 1, id: message.id}));
return textsecure.crypto.handleIncomingPushMessageProto(proto).then(function(decrypted) {
// Now that its decrypted, validate the message and clean it up for consumer processing
// Note that messages may (generally) only perform one action and we ignore remaining fields
// after the first action.
var pingInterval;
if (decrypted.flags == null)
decrypted.flags = 0;
//TODO: GUI
socket.onerror = function(socketEvent) {
console.log('Server is down :(');
clearInterval(pingInterval);
subscribeToPushMessageSemaphore--;
setTimeout(function() { textsecure.subscribeToPush(message_callback); }, 60000);
};
socket.onclose = function(socketEvent) {
console.log('Server closed :(');
clearInterval(pingInterval);
subscribeToPushMessageSemaphore--;
setTimeout(function() { textsecure.subscribeToPush(message_callback); }, 60000);
};
socket.onopen = function(socketEvent) {
console.log('Connected to server!');
pingInterval = setInterval(function() {
console.log("Sending server ping message.");
if (socket.readyState == socket.CLOSED || socket.readyState == socket.CLOSING) {
socket.close();
socket.onclose();
} else
socket.send(JSON.stringify({type: 2}));
}, 30000);
};
if ((decrypted.flags & textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION)
== textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION)
return;
if (decrypted.flags != 0)
throw new Error("Unknown flags in message");
socket.onmessage = function(response) {
try {
var message = JSON.parse(response.data);
} catch (e) {
console.log('Error parsing server JSON message: ' + response.responseBody.split("|")[1]);
return;
}
if (message.type == 3) {
console.log("Got pong message");
} else if (message.type === undefined && message.id !== undefined) {
textsecure.crypto.decryptWebsocketMessage(message.message).then(function(plaintext) {
var proto = textsecure.protos.decodeIncomingPushMessageProtobuf(getString(plaintext));
// After this point, a) decoding errors are not the server's fault, and
// b) we should handle them gracefully and tell the user they received an invalid message
console.log("Successfully decoded message with id: " + message.id);
socket.send(JSON.stringify({type: 1, id: message.id}));
return textsecure.crypto.handleIncomingPushMessageProto(proto).then(function(decrypted) {
// Now that its decrypted, validate the message and clean it up for consumer processing
// Note that messages may (generally) only perform one action and we ignore remaining fields
// after the first action.
if (decrypted.flags == null)
decrypted.flags = 0;
if ((decrypted.flags & textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION)
== textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION)
return;
if (decrypted.flags != 0)
throw new Error("Unknown flags in message");
var handleAttachment = function(attachment) {
return textsecure.api.getAttachment(attachment.id).then(function(encryptedBin) {
return textsecure.crypto.decryptAttachment(encryptedBin, toArrayBuffer(attachment.key)).then(function(decryptedBin) {
attachment.decrypted = decryptedBin;
});
});
};
var promises = [];
if (decrypted.group !== null) {
var existingGroup = textsecure.storage.groups.getNumbers(decrypted.group.id);
if (existingGroup === undefined) {
if (decrypted.group.type != textsecure.protos.PushMessageContentProtobuf.GroupContext.UPDATE)
throw new Error("Got message for unknown group");
textsecure.storage.groups.createNewGroup(decrypted.group.members, decrypted.group.id);
} else {
var fromIndex = existingGroup.indexOf(proto.source);
if (fromIndex < 0) //TODO: This could be indication of a race...
throw new Error("Sender was not a member of the group they were sending from");
switch(decrypted.group.type) {
case textsecure.protos.PushMessageContentProtobuf.GroupContext.UPDATE:
if (decrypted.group.avatar !== null)
promises.push(handleAttachment(decrypted.group.avatar));
if (existingGroup.filter(function(number) { decrypted.group.members.indexOf(number) < 0 }).length != 0)
throw new Error("Attempted to remove numbers from group with an UPDATE");
decrypted.group.added = decrypted.group.members.filter(function(number) { return existingGroup.indexOf(number) < 0; });
var newGroup = textsecure.storage.groups.addNumbers(decrypted.group.id, decrypted.group.added);
if (newGroup.length != decrypted.group.members.length ||
newGroup.filter(function(number) { return decrypted.group.members.indexOf(number) < 0; }).length != 0)
throw new Error("Error calculating group member difference");
//TODO: Also follow this path if avatar + name haven't changed (ie we should start storing those)
if (decrypted.group.avatar === null && decrypted.group.added.length == 0 && decrypted.group.name === null)
return;
//TODO: Strictly verify all numbers (ie dont let verifyNumber do any user-magic tweaking)
decrypted.body = null;
decrypted.attachments = [];
break;
case textsecure.protos.PushMessageContentProtobuf.GroupContext.QUIT:
textsecure.storage.groups.removeNumber(decrypted.group.id, proto.source);
decrypted.body = null;
decrypted.attachments = [];
case textsecure.protos.PushMessageContentProtobuf.GroupContext.DELIVER:
decrypted.group.name = null;
decrypted.group.members = [];
decrypted.group.avatar = null;
break;
default:
throw new Error("Unknown group message type");
}
}
}
for (var i in decrypted.attachments)
promises.push(handleAttachment(decrypted.attachments[i]));
return Promise.all(promises).then(function() {
message_callback({pushMessage: proto, message: decrypted});
var handleAttachment = function(attachment) {
return textsecure.api.getAttachment(attachment.id).then(function(encryptedBin) {
return textsecure.crypto.decryptAttachment(encryptedBin, toArrayBuffer(attachment.key)).then(function(decryptedBin) {
attachment.decrypted = decryptedBin;
});
})
}).catch(function(e) {
// TODO: Show "Invalid message" messages?
console.log("Error handling incoming message: ");
console.log(e);
});
}
};
}
}();
});
};
window.textsecure.register = function() {
return function(number, verificationCode, singleDevice, stepDone) {
var promises = [];
if (decrypted.group !== null) {
var existingGroup = textsecure.storage.groups.getNumbers(decrypted.group.id);
if (existingGroup === undefined) {
if (decrypted.group.type != textsecure.protos.PushMessageContentProtobuf.GroupContext.UPDATE)
throw new Error("Got message for unknown group");
textsecure.storage.groups.createNewGroup(decrypted.group.members, decrypted.group.id);
} else {
var fromIndex = existingGroup.indexOf(proto.source);
if (fromIndex < 0) //TODO: This could be indication of a race...
throw new Error("Sender was not a member of the group they were sending from");
switch(decrypted.group.type) {
case textsecure.protos.PushMessageContentProtobuf.GroupContext.UPDATE:
if (decrypted.group.avatar !== null)
promises.push(handleAttachment(decrypted.group.avatar));
if (existingGroup.filter(function(number) { decrypted.group.members.indexOf(number) < 0 }).length != 0)
throw new Error("Attempted to remove numbers from group with an UPDATE");
decrypted.group.added = decrypted.group.members.filter(function(number) { return existingGroup.indexOf(number) < 0; });
var newGroup = textsecure.storage.groups.addNumbers(decrypted.group.id, decrypted.group.added);
if (newGroup.length != decrypted.group.members.length ||
newGroup.filter(function(number) { return decrypted.group.members.indexOf(number) < 0; }).length != 0)
throw new Error("Error calculating group member difference");
//TODO: Also follow this path if avatar + name haven't changed (ie we should start storing those)
if (decrypted.group.avatar === null && decrypted.group.added.length == 0 && decrypted.group.name === null)
return;
//TODO: Strictly verify all numbers (ie dont let verifyNumber do any user-magic tweaking)
decrypted.body = null;
decrypted.attachments = [];
break;
case textsecure.protos.PushMessageContentProtobuf.GroupContext.QUIT:
textsecure.storage.groups.removeNumber(decrypted.group.id, proto.source);
decrypted.body = null;
decrypted.attachments = [];
case textsecure.protos.PushMessageContentProtobuf.GroupContext.DELIVER:
decrypted.group.name = null;
decrypted.group.members = [];
decrypted.group.avatar = null;
break;
default:
throw new Error("Unknown group message type");
}
}
}
for (var i in decrypted.attachments)
promises.push(handleAttachment(decrypted.attachments[i]));
return Promise.all(promises).then(function() {
message_callback({pushMessage: proto, message: decrypted});
});
})
}).catch(function(e) {
// TODO: Show "Invalid message" messages?
console.log("Error handling incoming message: ");
console.log(e);
});
};
};
window.textsecure.registerSingleDevice = function() {
return function(number, verificationCode, stepDone) {
var signalingKey = textsecure.crypto.getRandomBytes(32 + 20);
textsecure.storage.putEncrypted('signaling_key', signalingKey);
@ -794,25 +759,55 @@ window.textsecure.register = function() {
registrationId = registrationId & 0x3fff;
textsecure.storage.putUnencrypted("registrationId", registrationId);
return textsecure.api.confirmCode(number, verificationCode, password, signalingKey, registrationId, singleDevice).then(function(response) {
if (singleDevice)
response = 1;
var numberId = number + "." + response;
return textsecure.api.confirmCode(number, verificationCode, password, signalingKey, registrationId, true).then(function() {
var numberId = number + ".1";
textsecure.storage.putUnencrypted("number_id", numberId);
textsecure.storage.putUnencrypted("regionCode", textsecure.utils.getRegionCodeForNumber(number));
stepDone(1);
if (!singleDevice) {
//TODO: Do things???
stepDone(2);
}
return textsecure.crypto.generateKeys().then(function(keys) {
stepDone(3);
stepDone(2);
return textsecure.api.registerKeys(keys).then(function() {
stepDone(4);
stepDone(3);
});
});
});
}
}();
window.textsecure.registerSecondDevice = function(encodedDeviceInit, cryptoInfo, stepDone) {
var deviceInit = textsecure.protos.decodeDeviceInit(encodedDeviceInit);
return cryptoInfo.decryptAndHandleDeviceInit(deviceInit).then(function(identityKey) {
if (identityKey.server != textsecure.api.relay)
throw new Error("Unknown relay used by master");
var number = identityKey.phoneNumber;
stepDone(1);
var signalingKey = textsecure.crypto.getRandomBytes(32 + 20);
textsecure.storage.putEncrypted('signaling_key', signalingKey);
var password = btoa(getString(textsecure.crypto.getRandomBytes(16)));
password = password.substring(0, password.length - 2);
textsecure.storage.putEncrypted("password", password);
var registrationId = new Uint16Array(textsecure.crypto.getRandomBytes(2))[0];
registrationId = registrationId & 0x3fff;
textsecure.storage.putUnencrypted("registrationId", registrationId);
return textsecure.api.confirmCode(number, identityKey.provisioningCode, password, signalingKey, registrationId, false).then(function(result) {
var numberId = number + "." + result;
textsecure.storage.putUnencrypted("number_id", numberId);
textsecure.storage.putUnencrypted("regionCode", textsecure.utils.getRegionCodeForNumber(number));
stepDone(2);
return textsecure.crypto.generateKeys().then(function(keys) {
stepDone(3);
return textsecure.api.registerKeys(keys).then(function() {
stepDone(4);
//TODO: Send DeviceControl.NEW_DEVICE_REGISTERED to all other devices
});
});
});
});
};

View file

@ -73,26 +73,23 @@ $('#init-go').click(function() {
return;
}
$('#init-setup').hide();
$('#verify1done').text('');
$('#verify2').hide();
$('#verify1').hide();
$('#verify2done').text('');
$('#verify3done').text('');
$('#verify4done').text('');
$('#verify5').hide();
$('#verify').show();
textsecure.register(parsedNumber, $('#code').val(), single_device, function(step) {
textsecure.registerSingleDevice(parsedNumber, $('#code').val(), function(step) {
switch(step) {
case 1:
$('#verify1done').text('done');
break;
case 2:
$('#verify2done').text('done');
break;
case 3:
case 2:
$('#verify3done').text('done');
break;
case 4:
case 3:
$('#complete-number').text(parsedNumber);
$('#verify').hide();
$('#setup-complete').show();
@ -136,6 +133,61 @@ textsecure.registerOnLoadFunction(function() {
$('#regionCode').val(textsecure.utils.getRegionCodeForCountryCode($('#countrycode').val()));
updateNumberColors();
textsecure.crypto.prepareTempWebsocket().then(function(cryptoInfo) {
var qrCode = new QRCode(document.getElementById('setup-qr'));
var socket = textsecure.api.getTempWebsocket();
socket.onmessage = function(message) {
//TODO: Get a server format for this
if (message.type === 4) {
qrCode.makeCode('textsecure-device-init:/' +
'?channel_uuid=' + message.message +
'&channel_server=' + textsecure.api.relay +
'&publicKey=' + btoa(getString(cryptoInfo.publicKey)));
$('img').removeAttr('style');
$('#left-connecting').hide();
$('#left-setup').show();
$('#left-reconnecting').hide();
} else {
$('#init-setup').hide();
$('#verify1done').text('');
$('#verify2done').text('');
$('#verify3done').text('');
$('#verify4done').text('');
$('#verify5done').text('');
$('#verify').show();
textsecure.registerSecondDevice(cryptoInfo, message.message, function(step) {
switch(step) {
case 1:
$('#verify1done').text('done');
break;
case 2:
$('#verify2done').text('done');
break;
case 3:
$('#verify3done').text('done');
break;
case 4:
//TODO: User needs to verify number before we continue
$('#complete-number').text(parsedNumber);
$('#verify4done').text('done');
case 5:
$('#verify').hide();
$('#setup-complete').show();
registrationDone();
}
});
}
};
socket.ondisconnect = function() {
$('#left-connecting').hide();
$('#left-setup').hide();
$('#left-reconnecting').show();
};
});
} else {
$('#complete-number').text(textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0]);//TODO: no
$('#setup-complete').show();

View file

@ -27,23 +27,38 @@
<h1><img id="textsecure-icon" src='icon.png'/> TextSecure</h1>
<div id="init-setup" class="hidden">
<h2>Welcome to TextSecure. To get started please get a 6-digit setup code from your phone and enter it below.</h2>
<span>Please select your country:</span>
<select id="regionCode">
<option value="ZZ" selected>Please choose your country.</option>
</select>
<span id="phonenumberspan">Enter your phone number (including country code): + <input type="text" size="3" id="countrycode"> <input type="text" size="14" id="number"></span>
<button id="init-go-single-client" class="btn">Send single-client code</button>
<div id="init-setup-verification" class="hidden">
<p>Code: <input type="text" pattern="[0-9]{3}-?[0-9]{3}" title="Enter the 6-didgit verificaion code displayed on your phone." size="8" id="code" /></p>
<button id="init-go" class="btn">Sync</button>
<h2>Welcome to TextSecure. If you want to register as a secondary device, follow the instructions on the left, if you want to register as the only device, follow the instructions on the right</h2>
<div id="left-connecting" class="left-column">
Please wait while we connect to the push server...
</div>
<div id="left-setup" class="left-column hidden">
Please scan the QR code below on the master device: <br>
<div id="setup-qr"></div>
</div>
<div id="left-reconnecting" class="left-column hidden">
The push server disconnected, please wait while we reconnect...
</div>
<div class="right-column">
<span>Please select your country or enter your country code below:</span>
<select id="regionCode">
<option value="ZZ" selected>Please choose your country.</option>
</select>
<span id="phonenumberspan">+ <input type="text" size="3" id="countrycode"> <input type="text" size="14" id="number"></span>
<button id="init-go-single-client" class="btn">Send single-client code</button>
<div id="init-setup-verification" class="hidden">
<p>Code: <input type="text" pattern="[0-9]{3}-?[0-9]{3}" title="Enter the 6-didgit verificaion code displayed on your phone." size="8" id="code" /></p>
<button id="init-go" class="btn">Sync</button>
</div>
</div>
</div>
<div id="verify" class="hidden">
<div id="verify1">Verifying number and setup code...<span id="verify1done"></span></div>
<div id="verify2">Syncing with existing devices...<span id="verify2done"></span></div>
<div id="verify1">Receiving identity key...<span id="verify1done"></span></div>
<div id="verify2">Verifying number and setup code...<span id="verify2done"></span></div>
<div id="verify3">Generating keys...<span id="verify3done"></span></div>
<div id="verify4">Registering...<span id="verify4done"></span></div>
<div id="verify5">Syncing with existing devices...<span id="verify5done"></span></div>
</div>
<div id="setup-complete" class="hidden">
<h2>You are now registered on TextSecure with number <span id="complete-number"></span></h2>
@ -59,6 +74,7 @@
<script type="text/javascript" src="js-deps/backbone.js"></script>
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
<script type="text/javascript" src="js-deps/qrcode.min.js"></script>
<script type="text/javascript" src="js/helpers.js"></script>
<script type="text/javascript" src="js/webcrypto.js"></script>

View file

@ -0,0 +1,30 @@
package textsecure;
message DeviceInit {
required bytes masterEphemeralPubKey = 1;
required bytes identityKeyMessage = 2; // contains an IdentityKey
}
message IdentityKey {
required bytes identityKey = 1;
required string phoneNumber = 2;
required string server = 3;
required bool masterSupportsSms = 4;
required uint32 provisioningCode = 5;
}
message DeviceControl {
enum Type {
UNKNOWN = 0;
NEW_DEVICE_REGISTERED = 1; // Requries only newDeviceId
SENT_MESSAGE = 2; // Requires only message
}
message MessageSent {
required string otherNumber = 1; // The destination account (ie phone #), not device
required uint64 timestamp = 2;
required bytes message = 3; // PushMessageContent
}
required Type type = 1;
optional uint32 newDeviceId = 2;
optional MessageSent message = 3;
}

View file

@ -48,13 +48,15 @@
<script type="text/javascript" src="js-deps/backbone.localStorage.js"></script>
<script type="text/javascript" src="js-deps/libphonenumber_api-compiled.js"></script>
<script type="text/javascript" src="js/helpers.js"></script>
<script type="text/javascript" src="js-deps/blanket.min.js"></script>
<script type="text/javascript" src="js/helpers.js" data-cover></script>
<script type="text/javascript" src="js/webcrypto.js"></script>
<script type="text/javascript" src="js/crypto.js"></script>
<script type="text/javascript" src="js/crypto.js" data-cover></script>
<script type="text/javascript" src="js/models/messages.js"></script>
<script type="text/javascript" src="js/models/threads.js"></script>
<script type="text/javascript" src="js/api.js"></script>
<script type="text/javascript" src="js/sendmessage.js"></script>
<script type="text/javascript" src="js/sendmessage.js" data-cover></script>
<script type="text/javascript" src="js/chromium.js"></script>
<script type="text/javascript" src="js/fake_api.js"></script>