diff --git a/i18n/locales/de/common.json b/i18n/locales/de/common.json index 24354f1f6..28b0ead4b 100644 --- a/i18n/locales/de/common.json +++ b/i18n/locales/de/common.json @@ -194,6 +194,7 @@ "What's New...": "Neues...", "When you have the signature, you only need the publicKey of the signer in order to verify that the message came from the right private/publicKey pair. Be aware, everybody knowing the signature and the publicKey can verify the message. If ever there is a dispute, everybody can take the publicKey and signature to a judge and prove that the message is coming from the specific private/publicKey pair.": "Wenn du eine Signatur hast, brauchst du nur noch den öffentlichen Schlüssel des Unterzeichners, um zu überprüfen, ob die Nachricht von dem korrekten privaten/öffentlichen Schlüssel-Paar kommt. Bedenke dass jeder, der den öffentlichen Schlüssel besitzt, die Nachricht verifizieren kann. Wenn es eine Streitigkeit geben sollte, kann jeder den öffentlichen Schlüssel und die Signatur zu einem Richter bringen und dort beweisen, dass die Nachricht von diesem speziellen privaten/öffentlichen Schlüssel-Paar kommt.", "Window": "Fenster", + "Word \"{{invalidWord}}\" contains upper case letters. All words must be lower case": "Das Wort \"{{invalidWord}}\" enhält Großbuchstaben. Alle Wörter müssen ausschließlich Kleinbuchstaben enthalten.", "Word \"{{invalidWord}}\" is not on the passphrase Word List.": "Das Wort \"{{invalidWord}}\" ist in der Passphrasen-Wortliste nicht vorhanden.", "Word \"{{invalidWord}}\" is not on the passphrase Word List. Most similar word on the list is \"{{similarWord}}\"": "Das Wort \"{{invalidWord}}\" ist nicht in der Passphrasen-Wortliste. Das ähnlichste Wort in der Liste ist \"{{similarWord}}\"", "Yes! It's safe": "Ja! Es ist sicher", diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index b2efb97cf..79d05f510 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -192,6 +192,7 @@ "What's New...": "What's New...", "When you have the signature, you only need the publicKey of the signer in order to verify that the message came from the right private/publicKey pair. Be aware, everybody knowing the signature and the publicKey can verify the message. If ever there is a dispute, everybody can take the publicKey and signature to a judge and prove that the message is coming from the specific private/publicKey pair.": "When you have the signature, you only need the publicKey of the signer in order to verify that the message came from the right private/publicKey pair. Be aware, everybody knowing the signature and the publicKey can verify the message. If ever there is a dispute, everybody can take the publicKey and signature to a judge and prove that the message is coming from the specific private/publicKey pair.", "Window": "Window", + "Word \"{{invalidWord}}\" contains upper case letters. All words must be lower case": "Word \"{{invalidWord}}\" contains upper case letters. All words must be lower case", "Word \"{{invalidWord}}\" is not on the passphrase Word List.": "Word \"{{invalidWord}}\" is not on the passphrase Word List.", "Word \"{{invalidWord}}\" is not on the passphrase Word List. Most similar word on the list is \"{{similarWord}}\"": "Word \"{{invalidWord}}\" is not on the passphrase Word List. Most similar word on the list is \"{{similarWord}}\"", "Yes! It's safe": "Yes! It's safe", diff --git a/src/components/passphraseInput/index.js b/src/components/passphraseInput/index.js index b81095b3f..4e5864406 100644 --- a/src/components/passphraseInput/index.js +++ b/src/components/passphraseInput/index.js @@ -38,11 +38,13 @@ class PassphraseInput extends React.Component { return this.props.t('Passphrase should have 12 words, entered passphrase has {{length}}', { length: mnemonic.length }); } - const invalidWord = mnemonic.find(word => !inDictionary(word.toLowerCase())); + const invalidWord = mnemonic.find(word => !inDictionary(word)); if (invalidWord) { if (invalidWord.length >= 2 && invalidWord.length <= 8) { const validWord = findSimilarWord(invalidWord); - if (validWord) { + if (invalidWord.toLowerCase() !== invalidWord) { + return this.props.t('Word "{{invalidWord}}" contains upper case letters. All words must be lower case', { invalidWord }); + } else if (validWord) { return this.props.t('Word "{{invalidWord}}" is not on the passphrase Word List. Most similar word on the list is "{{similarWord}}"', { invalidWord, similarWord: findSimilarWord(invalidWord) }); } } diff --git a/src/components/passphraseInput/index.test.js b/src/components/passphraseInput/index.test.js index 80d71d283..9702cfd38 100644 --- a/src/components/passphraseInput/index.test.js +++ b/src/components/passphraseInput/index.test.js @@ -59,6 +59,13 @@ describe('PassphraseInput', () => { expect(wrapper.props().onChange).to.have.been.calledWith(passphrase, SIMILAR_WORD_ERROR); }); + const UPPER_CASE_ERROR = 'Word "WAGON" contains upper case letters. All words must be lower case'; + it(`should call props.onChange with error='${UPPER_CASE_ERROR}' if an passphrase with a typo is entered`, () => { + const passphrase = 'WAGON stock borrow episode laundry kitten salute link globe zero feed marble'; + wrapper.find('input').simulate('change', { target: { value: passphrase } }); + expect(wrapper.props().onChange).to.have.been.calledWith(passphrase, UPPER_CASE_ERROR); + }); + const NOT_VALID_ERROR = 'Passphrase is not valid'; it(`should call props.onChange with error="${NOT_VALID_ERROR}" if an otherwise invalid passphrase is entered`, () => { const passphrase = 'stock wagon borrow episode laundry kitten salute link globe zero feed marble'; diff --git a/src/utils/passphrase.js b/src/utils/passphrase.js index 7cdc00c34..dd299bca2 100644 --- a/src/utils/passphrase.js +++ b/src/utils/passphrase.js @@ -88,7 +88,7 @@ export const generatePassphrase = ({ seed }) => (new mnemonic(new Buffer(seed.jo * @returns {bool} isValidPassphrase */ export const isValidPassphrase = (passphrase) => { - const normalizedValue = passphrase.replace(/ +/g, ' ').trim().toLowerCase(); + const normalizedValue = passphrase.replace(/ +/g, ' ').trim(); let isValid; try { isValid = normalizedValue.split(' ').length >= 12 && mnemonic.isValid(normalizedValue);