allow registering using a mnemonic word list (seed used as privKey for now)

pull/18/head
sachaaaaa 7 years ago
parent 2ea49473e5
commit a418a9d23b

@ -89,6 +89,7 @@ module.exports = grunt => {
libloki: {
src: [
'libloki/libloki-protocol.js',
'libloki/mnemonic.js',
],
dest: 'js/libloki.js',
},

@ -568,6 +568,15 @@
<div class='inner'>
<div class='step-body'>
<div class='header'>Create your Loki Messenger Account</div>
<input class='form-control' type='text' id='mnemonic' placeholder='Mnemonic' autocomplete='off' spellcheck='false'>
<div class='clearfix'>
<a class='button' id='register-mnemonic'>Register using mnenomic</a>
</div>
<div id='error' class='collapse'></div>
<div id=status></div>
</div>
<div class='nav'>
<a class='button' id='register' data-loading-text='Please wait...'>Register</a>

@ -31,15 +31,28 @@
'click #request-sms': 'requestSMSVerification',
'change #code': 'onChangeCode',
'click #register': 'register',
'click #register-mnemonic': 'registerWithMnemonic',
'change #mnemonic': 'onChangeMnemonic',
},
register() {
this.accountManager
.registerSingleDevice()
.registerSingleDevice(this.$('#mnemonic').val())
.then(() => {
this.$el.trigger('openInbox');
})
.catch(this.log.bind(this));
},
registerWithMnemonic() {
const words = this.$('#mnemonic').val();
if (!words) {
log('Please provide a mnemonic word list');
} else {
this.register();
}
},
onChangeMnemonic() {
this.$('#status').html('');
},
log(s) {
window.log.info(s);
this.$('#status').text(s);

File diff suppressed because it is too large Load Diff

@ -44,14 +44,25 @@
requestSMSVerification(number) {
return this.server.requestVerificationSMS(number);
},
registerSingleDevice() {
registerSingleDevice(mnemonic) {
const createAccount = this.createAccount.bind(this);
const clearSessionsAndPreKeys = this.clearSessionsAndPreKeys.bind(this);
const generateKeys = this.generateKeys.bind(this, 0);
const confirmKeys = this.confirmKeys.bind(this);
const registrationDone = this.registrationDone.bind(this);
return this.queueTask(() =>
libsignal.KeyHelper.generateIdentityKeyPair().then(identityKeyPair => {
let generateKeypair;
if (mnemonic) {
generateKeypair = () => {
const seedHex = window.mnemonic.decode(mnemonic);
// use seed as privkey?
const privKey = dcodeIO.ByteBuffer.wrap(seedHex, 'hex').toArrayBuffer();
return libsignal.Curve.async.createKeyPair(privKey);
};
} else {
generateKeypair = libsignal.KeyHelper.generateIdentityKeyPair;
}
return this.queueTask(() =>
generateKeypair().then(identityKeyPair => {
return createAccount(
identityKeyPair,
)

@ -206,6 +206,8 @@ window.LokiAPI = initializeLokiAPI({
url: config.serverUrl,
});
window.crc32 = require('buffer-crc32');
// Linux seems to periodically let the event loop stop, so this is a global workaround
setInterval(() => {
window.nodeSetImmediate(() => {});

Loading…
Cancel
Save