parent
a98857a1d1
commit
dfc292ac70
3 changed files with 146 additions and 119 deletions
|
@ -44,10 +44,12 @@
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var accountManager;
|
||||||
window.getAccountManager = function() {
|
window.getAccountManager = function() {
|
||||||
|
if (!accountManager) {
|
||||||
var USERNAME = storage.get('number_id');
|
var USERNAME = storage.get('number_id');
|
||||||
var PASSWORD = storage.get('password');
|
var PASSWORD = storage.get('password');
|
||||||
var accountManager = new textsecure.AccountManager(
|
accountManager = new textsecure.AccountManager(
|
||||||
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD
|
SERVER_URL, SERVER_PORTS, USERNAME, PASSWORD
|
||||||
);
|
);
|
||||||
accountManager.addEventListener('registration', function() {
|
accountManager.addEventListener('registration', function() {
|
||||||
|
@ -58,6 +60,7 @@
|
||||||
console.log("dispatching registration event");
|
console.log("dispatching registration event");
|
||||||
extension.trigger('registration_done');
|
extension.trigger('registration_done');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return accountManager;
|
return accountManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37902,6 +37902,7 @@ var TextSecureServer = (function() {
|
||||||
|
|
||||||
function AccountManager(url, ports, username, password) {
|
function AccountManager(url, ports, username, password) {
|
||||||
this.server = new TextSecureServer(url, ports, username, password);
|
this.server = new TextSecureServer(url, ports, username, password);
|
||||||
|
this.pending = Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager.prototype = new textsecure.EventTarget();
|
AccountManager.prototype = new textsecure.EventTarget();
|
||||||
|
@ -37918,12 +37919,16 @@ var TextSecureServer = (function() {
|
||||||
var createAccount = this.createAccount.bind(this);
|
var createAccount = this.createAccount.bind(this);
|
||||||
var generateKeys = this.generateKeys.bind(this, 100);
|
var generateKeys = this.generateKeys.bind(this, 100);
|
||||||
var registrationDone = this.registrationDone.bind(this);
|
var registrationDone = this.registrationDone.bind(this);
|
||||||
|
this.pending = this.pending.then(function() {
|
||||||
return libsignal.KeyHelper.generateIdentityKeyPair().then(function(identityKeyPair) {
|
return libsignal.KeyHelper.generateIdentityKeyPair().then(function(identityKeyPair) {
|
||||||
return createAccount(number, verificationCode, identityKeyPair).
|
return createAccount(number, verificationCode, identityKeyPair).
|
||||||
then(generateKeys).
|
then(generateKeys).
|
||||||
then(registerKeys).
|
then(registerKeys).
|
||||||
then(registrationDone);
|
then(registrationDone);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
return this.pending;
|
||||||
},
|
},
|
||||||
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
|
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
|
||||||
var createAccount = this.createAccount.bind(this);
|
var createAccount = this.createAccount.bind(this);
|
||||||
|
@ -37931,6 +37936,7 @@ var TextSecureServer = (function() {
|
||||||
var registrationDone = this.registrationDone.bind(this);
|
var registrationDone = this.registrationDone.bind(this);
|
||||||
var registerKeys = this.server.registerKeys.bind(this.server);
|
var registerKeys = this.server.registerKeys.bind(this.server);
|
||||||
var getSocket = this.server.getProvisioningSocket.bind(this.server);
|
var getSocket = this.server.getProvisioningSocket.bind(this.server);
|
||||||
|
this.pending = this.pending.then(function() {
|
||||||
var provisioningCipher = new libsignal.ProvisioningCipher();
|
var provisioningCipher = new libsignal.ProvisioningCipher();
|
||||||
return provisioningCipher.getPublicKey().then(function(pubKey) {
|
return provisioningCipher.getPublicKey().then(function(pubKey) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
@ -37976,16 +37982,22 @@ var TextSecureServer = (function() {
|
||||||
}).then(generateKeys).
|
}).then(generateKeys).
|
||||||
then(registerKeys).
|
then(registerKeys).
|
||||||
then(registrationDone);
|
then(registrationDone);
|
||||||
|
}.bind(this));
|
||||||
|
return this.pending;
|
||||||
},
|
},
|
||||||
refreshPreKeys: function() {
|
refreshPreKeys: function() {
|
||||||
var generateKeys = this.generateKeys.bind(this, 100);
|
var generateKeys = this.generateKeys.bind(this, 100);
|
||||||
var registerKeys = this.server.registerKeys.bind(this.server);
|
var registerKeys = this.server.registerKeys.bind(this.server);
|
||||||
|
|
||||||
|
this.pending = this.pending.then(function() {
|
||||||
return this.server.getMyKeys().then(function(preKeyCount) {
|
return this.server.getMyKeys().then(function(preKeyCount) {
|
||||||
console.log('prekey count ' + preKeyCount);
|
console.log('prekey count ' + preKeyCount);
|
||||||
if (preKeyCount < 10) {
|
if (preKeyCount < 10) {
|
||||||
return generateKeys().then(registerKeys);
|
return generateKeys().then(registerKeys);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
return this.pending;
|
||||||
},
|
},
|
||||||
createAccount: function(number, verificationCode, identityKeyPair, deviceName, userAgent) {
|
createAccount: function(number, verificationCode, identityKeyPair, deviceName, userAgent) {
|
||||||
var signalingKey = libsignal.crypto.getRandomBytes(32 + 20);
|
var signalingKey = libsignal.crypto.getRandomBytes(32 + 20);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
function AccountManager(url, ports, username, password) {
|
function AccountManager(url, ports, username, password) {
|
||||||
this.server = new TextSecureServer(url, ports, username, password);
|
this.server = new TextSecureServer(url, ports, username, password);
|
||||||
|
this.pending = Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager.prototype = new textsecure.EventTarget();
|
AccountManager.prototype = new textsecure.EventTarget();
|
||||||
|
@ -25,12 +26,16 @@
|
||||||
var createAccount = this.createAccount.bind(this);
|
var createAccount = this.createAccount.bind(this);
|
||||||
var generateKeys = this.generateKeys.bind(this, 100);
|
var generateKeys = this.generateKeys.bind(this, 100);
|
||||||
var registrationDone = this.registrationDone.bind(this);
|
var registrationDone = this.registrationDone.bind(this);
|
||||||
|
this.pending = this.pending.then(function() {
|
||||||
return libsignal.KeyHelper.generateIdentityKeyPair().then(function(identityKeyPair) {
|
return libsignal.KeyHelper.generateIdentityKeyPair().then(function(identityKeyPair) {
|
||||||
return createAccount(number, verificationCode, identityKeyPair).
|
return createAccount(number, verificationCode, identityKeyPair).
|
||||||
then(generateKeys).
|
then(generateKeys).
|
||||||
then(registerKeys).
|
then(registerKeys).
|
||||||
then(registrationDone);
|
then(registrationDone);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
return this.pending;
|
||||||
},
|
},
|
||||||
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
|
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
|
||||||
var createAccount = this.createAccount.bind(this);
|
var createAccount = this.createAccount.bind(this);
|
||||||
|
@ -38,6 +43,7 @@
|
||||||
var registrationDone = this.registrationDone.bind(this);
|
var registrationDone = this.registrationDone.bind(this);
|
||||||
var registerKeys = this.server.registerKeys.bind(this.server);
|
var registerKeys = this.server.registerKeys.bind(this.server);
|
||||||
var getSocket = this.server.getProvisioningSocket.bind(this.server);
|
var getSocket = this.server.getProvisioningSocket.bind(this.server);
|
||||||
|
this.pending = this.pending.then(function() {
|
||||||
var provisioningCipher = new libsignal.ProvisioningCipher();
|
var provisioningCipher = new libsignal.ProvisioningCipher();
|
||||||
return provisioningCipher.getPublicKey().then(function(pubKey) {
|
return provisioningCipher.getPublicKey().then(function(pubKey) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
@ -83,16 +89,22 @@
|
||||||
}).then(generateKeys).
|
}).then(generateKeys).
|
||||||
then(registerKeys).
|
then(registerKeys).
|
||||||
then(registrationDone);
|
then(registrationDone);
|
||||||
|
}.bind(this));
|
||||||
|
return this.pending;
|
||||||
},
|
},
|
||||||
refreshPreKeys: function() {
|
refreshPreKeys: function() {
|
||||||
var generateKeys = this.generateKeys.bind(this, 100);
|
var generateKeys = this.generateKeys.bind(this, 100);
|
||||||
var registerKeys = this.server.registerKeys.bind(this.server);
|
var registerKeys = this.server.registerKeys.bind(this.server);
|
||||||
|
|
||||||
|
this.pending = this.pending.then(function() {
|
||||||
return this.server.getMyKeys().then(function(preKeyCount) {
|
return this.server.getMyKeys().then(function(preKeyCount) {
|
||||||
console.log('prekey count ' + preKeyCount);
|
console.log('prekey count ' + preKeyCount);
|
||||||
if (preKeyCount < 10) {
|
if (preKeyCount < 10) {
|
||||||
return generateKeys().then(registerKeys);
|
return generateKeys().then(registerKeys);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
return this.pending;
|
||||||
},
|
},
|
||||||
createAccount: function(number, verificationCode, identityKeyPair, deviceName, userAgent) {
|
createAccount: function(number, verificationCode, identityKeyPair, deviceName, userAgent) {
|
||||||
var signalingKey = libsignal.crypto.getRandomBytes(32 + 20);
|
var signalingKey = libsignal.crypto.getRandomBytes(32 + 20);
|
||||||
|
|
Loading…
Reference in a new issue