Update consumers of WebsocketResources
This commit is contained in:
parent
1af8bd16b7
commit
1a06cb5cbe
3 changed files with 64 additions and 60 deletions
|
@ -39387,36 +39387,37 @@ TextSecureServer = function () {
|
||||||
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
|
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
var socket = TextSecureServer.getTempWebsocket();
|
var socket = TextSecureServer.getTempWebsocket();
|
||||||
var wsr = new WebSocketResource(socket, function(request) {
|
var wsr = new WebSocketResource(socket, {
|
||||||
if (request.path == "/v1/address" && request.verb == "PUT") {
|
keepalive: { path: '/v1/keepalive' },
|
||||||
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
|
handleRequest: function(request) {
|
||||||
setProvisioningUrl([
|
if (request.path == "/v1/address" && request.verb == "PUT") {
|
||||||
'tsdevice:/?uuid=', proto.uuid, '&pub_key=',
|
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
|
||||||
encodeURIComponent(btoa(getString(cryptoInfo.pubKey)))
|
setProvisioningUrl([
|
||||||
].join(''));
|
'tsdevice:/?uuid=', proto.uuid, '&pub_key=',
|
||||||
request.respond(200, 'OK');
|
encodeURIComponent(btoa(getString(cryptoInfo.pubKey)))
|
||||||
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
].join(''));
|
||||||
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
request.respond(200, 'OK');
|
||||||
request.respond(200, 'OK');
|
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
||||||
wsr.close();
|
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
||||||
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
request.respond(200, 'OK');
|
||||||
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
wsr.close();
|
||||||
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
||||||
throw new Error('Invalid device name');
|
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
||||||
}
|
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
||||||
return createAccount(
|
throw new Error('Invalid device name');
|
||||||
provisionMessage.number,
|
}
|
||||||
provisionMessage.provisioningCode,
|
return createAccount(
|
||||||
provisionMessage.identityKeyPair,
|
provisionMessage.number,
|
||||||
deviceName
|
provisionMessage.provisioningCode,
|
||||||
);
|
provisionMessage.identityKeyPair,
|
||||||
});
|
deviceName
|
||||||
}));
|
);
|
||||||
} else {
|
});
|
||||||
console.log('Unknown websocket message', request.path);
|
}));
|
||||||
|
} else {
|
||||||
|
console.log('Unknown websocket message', request.path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
keepalive: { path: '/v1/keepalive' }
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
@ -39564,7 +39565,8 @@ function generateKeys(count, progressCallback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.wsr = new WebSocketResource(this.socket, this.handleRequest.bind(this), {
|
this.wsr = new WebSocketResource(this.socket, {
|
||||||
|
handleRequest: this.handleRequest.bind(this),
|
||||||
keepalive: { path: '/v1/keepalive', disconnect: true }
|
keepalive: { path: '/v1/keepalive', disconnect: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -44,36 +44,37 @@
|
||||||
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
|
return textsecure.protocol_wrapper.createIdentityKeyRecvSocket().then(function(cryptoInfo) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
var socket = TextSecureServer.getTempWebsocket();
|
var socket = TextSecureServer.getTempWebsocket();
|
||||||
var wsr = new WebSocketResource(socket, function(request) {
|
var wsr = new WebSocketResource(socket, {
|
||||||
if (request.path == "/v1/address" && request.verb == "PUT") {
|
keepalive: { path: '/v1/keepalive' },
|
||||||
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
|
handleRequest: function(request) {
|
||||||
setProvisioningUrl([
|
if (request.path == "/v1/address" && request.verb == "PUT") {
|
||||||
'tsdevice:/?uuid=', proto.uuid, '&pub_key=',
|
var proto = textsecure.protobuf.ProvisioningUuid.decode(request.body);
|
||||||
encodeURIComponent(btoa(getString(cryptoInfo.pubKey)))
|
setProvisioningUrl([
|
||||||
].join(''));
|
'tsdevice:/?uuid=', proto.uuid, '&pub_key=',
|
||||||
request.respond(200, 'OK');
|
encodeURIComponent(btoa(getString(cryptoInfo.pubKey)))
|
||||||
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
].join(''));
|
||||||
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
request.respond(200, 'OK');
|
||||||
request.respond(200, 'OK');
|
} else if (request.path == "/v1/message" && request.verb == "PUT") {
|
||||||
wsr.close();
|
var envelope = textsecure.protobuf.ProvisionEnvelope.decode(request.body, 'binary');
|
||||||
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
request.respond(200, 'OK');
|
||||||
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
wsr.close();
|
||||||
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
resolve(cryptoInfo.decryptAndHandleDeviceInit(envelope).then(function(provisionMessage) {
|
||||||
throw new Error('Invalid device name');
|
return confirmNumber(provisionMessage.number).then(function(deviceName) {
|
||||||
}
|
if (typeof deviceName !== 'string' || deviceName.length == 0) {
|
||||||
return createAccount(
|
throw new Error('Invalid device name');
|
||||||
provisionMessage.number,
|
}
|
||||||
provisionMessage.provisioningCode,
|
return createAccount(
|
||||||
provisionMessage.identityKeyPair,
|
provisionMessage.number,
|
||||||
deviceName
|
provisionMessage.provisioningCode,
|
||||||
);
|
provisionMessage.identityKeyPair,
|
||||||
});
|
deviceName
|
||||||
}));
|
);
|
||||||
} else {
|
});
|
||||||
console.log('Unknown websocket message', request.path);
|
}));
|
||||||
|
} else {
|
||||||
|
console.log('Unknown websocket message', request.path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
keepalive: { path: '/v1/keepalive' }
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
|
|
@ -44,7 +44,8 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.wsr = new WebSocketResource(this.socket, this.handleRequest.bind(this), {
|
this.wsr = new WebSocketResource(this.socket, {
|
||||||
|
handleRequest: this.handleRequest.bind(this),
|
||||||
keepalive: { path: '/v1/keepalive', disconnect: true }
|
keepalive: { path: '/v1/keepalive', disconnect: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue