Added generation of seed in registration.

pull/71/head
Mikunj 7 years ago
parent 89a19fd09b
commit 85298012e4

@ -1669,5 +1669,10 @@
"editDisplayName": {
"message": "Edit display name",
"description": "Button action that the user can click to edit their display name"
},
"copiedMnemonic": {
"message": "Copied mnemonic to clipboard",
"description": "A toast message telling the user that the mnemonic was copied"
}
}

@ -603,7 +603,7 @@
<div class='step-body'>
<div class='header'>Create your Loki Messenger Account</div>
<input class='form-control' type='text' placeholder='Display Name (optional)' autocomplete='off' spellcheck='false' maxlength='25'>
<input class='form-control' type='text' id='display-name' placeholder='Display Name (optional)' autocomplete='off' spellcheck='false' maxlength='25'>
<h4 class='section-toggle'>Register using Mnenomic</h4>
<div class='standalone-mnemonic section-content'>
@ -611,13 +611,18 @@
<input class='form-control' type='text' id='mnemonic' placeholder='Mnemonic' autocomplete='off' spellcheck='false' />
<select id='mnemonic-language'></select>
</div>
<a class='button' id='register-mnemonic'>Register using mnenomic</a>
<a class='button' id='register-mnemonic'>Register</a>
<div id='error' class='collapse'></div>
<div id=status></div>
</div>
<h4 class='section-toggle section-toggle-visible'>Register</h4>
<div class='standalone-register section-content'>
<a class='button' id='register' data-loading-text='Please wait...'>Register</a>
<div id='mnemonic-display' />
<div class='standalone-register-buttons'>
<a class='button' id='generate-mnemonic'>Generate Mnemonic</a>
<a class='button' id='copy-mnemonic'>Copy Mnemonic</a>
<a class='button' id='register' data-loading-text='Please wait...'>Register</a>
</div>
</div>
</div>
</div>

@ -1,4 +1,4 @@
/* global Whisper, $, getAccountManager, textsecure, storage, ConversationController */
/* global Whisper, $, getAccountManager, textsecure, i18n, storage, ConversationController */
/* eslint-disable more/no-then */
@ -27,6 +27,8 @@
this.$('.standalone-mnemonic').hide();
this.onGenerateMnemonic();
window.mnemonic.get_languages().forEach(language => {
this.$('#mnemonic-language').append(
$('<option>', {
@ -41,15 +43,17 @@
'click #request-voice': 'requestVoice',
'click #request-sms': 'requestSMSVerification',
'change #code': 'onChangeCode',
'click #register': 'register',
'click #register': 'registerWithoutMnemonic',
'click #register-mnemonic': 'registerWithMnemonic',
'change #mnemonic': 'onChangeMnemonic',
'click #generate-mnemonic': 'onGenerateMnemonic',
'click #copy-mnemonic': 'onCopyMnemonic',
'click .section-toggle': 'toggleSection',
},
register() {
register(mnemonic) {
this.accountManager
.registerSingleDevice(
this.$('#mnemonic').val(),
mnemonic,
this.$('#mnemonic-language').val(),
this.$('#display-name').val()
)
@ -58,17 +62,34 @@
})
.catch(this.log.bind(this));
},
registerWithoutMnemonic() {
const mnemonic = this.$('#mnemonic-display').text();
this.register(mnemonic);
},
registerWithMnemonic() {
const words = this.$('#mnemonic').val();
if (!words) {
const mnemonic = this.$('#mnemonic').val();
if (!mnemonic) {
this.log('Please provide a mnemonic word list');
} else {
this.register();
this.register(mnemonic);
}
},
onChangeMnemonic() {
this.$('#status').html('');
},
async onGenerateMnemonic() {
const mnemonic = await this.accountManager.generateMnemonic();
this.$('#mnemonic-display').text(mnemonic)
},
onCopyMnemonic() {
window.clipboard.writeText(this.$('#mnemonic-display').text());
const toast = new Whisper.MessageToastView({
message: i18n('copiedMnemonic'),
});
toast.$el.appendTo(this.$el);
toast.render();
},
log(s) {
window.log.info(s);
this.$('#status').text(s);

@ -2,7 +2,7 @@
window,
textsecure,
libsignal,
WebSocketResource,
mnemonic,
btoa,
getString,
Event,
@ -446,6 +446,11 @@
);
});
},
async generateMnemonic() {
const keys = await libsignal.KeyHelper.generateIdentityKeyPair();
const hex = StringView.arrayBufferToHex(keys.privKey);
return mnemonic.mn_encode(hex);
},
async registrationDone(number, profileName) {
window.log.info('registration done');

@ -722,8 +722,9 @@ textarea {
color: white;
background: $blue;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
user-select: none;
font-size: 12pt;
margin-top: 4px;
&.neutral {
color: black;
@ -823,7 +824,7 @@ textarea {
display: flex;
flex-direction: row;
align-items: center;
margin: 1em 12px;
margin: 1em 8px;
margin-top: 0;
input {
@ -832,6 +833,12 @@ textarea {
margin-right: 12px;
}
}
#mnemonic-display {
margin: 8px;
margin-top: 0;
font-size: 16px;
}
}
//yellow border fix

Loading…
Cancel
Save