Close the provisioning socket

This commit is contained in:
lilia 2015-05-04 22:26:32 -07:00
parent 43d6efcd9e
commit 37c496f4f0
3 changed files with 8 additions and 2 deletions

View file

@ -38356,6 +38356,7 @@ TextSecureWebSocket = function (url) {
function resetKeepAliveTimer() {
clearTimeout(keepAliveTimer);
if (calledClose) { return; }
keepAliveTimer = setTimeout(function() {
if (socket.readyState === WebSocket.OPEN) {
socket.send(
@ -39298,7 +39299,8 @@ TextSecureServer = function () {
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
return new Promise(function(resolve) {
new WebSocketResource(TextSecureServer.getTempWebsocket(), function(request) {
var socket = TextSecureServer.getTempWebsocket();
new WebSocketResource(socket, function(request) {
if (request.path == "/v1/address" && request.verb == "PUT") {
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
setProvisioningUrl([
@ -39309,6 +39311,7 @@ TextSecureServer = function () {
} else if (request.path == "/v1/message" && request.verb == "PUT") {
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
request.respond(200, 'OK');
socket.close();
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
return confirmNumber(provisionMessage.number).then(function() {
return createAccount(

View file

@ -41,7 +41,8 @@
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
return new Promise(function(resolve) {
new WebSocketResource(TextSecureServer.getTempWebsocket(), function(request) {
var socket = TextSecureServer.getTempWebsocket();
new WebSocketResource(socket, function(request) {
if (request.path == "/v1/address" && request.verb == "PUT") {
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
setProvisioningUrl([
@ -52,6 +53,7 @@
} else if (request.path == "/v1/message" && request.verb == "PUT") {
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
request.respond(200, 'OK');
socket.close();
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
return confirmNumber(provisionMessage.number).then(function() {
return createAccount(

View file

@ -40,6 +40,7 @@ TextSecureWebSocket = function (url) {
function resetKeepAliveTimer() {
clearTimeout(keepAliveTimer);
if (calledClose) { return; }
keepAliveTimer = setTimeout(function() {
if (socket.readyState === WebSocket.OPEN) {
socket.send(