Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize 12 words input #815

Closed
henriquecbuss opened this issue Aug 17, 2022 · 4 comments · Fixed by #816
Closed

Sanitize 12 words input #815

henriquecbuss opened this issue Aug 17, 2022 · 4 comments · Fixed by #816
Assignees
Labels
🧰 enhancement Changes and improvements to what we already have

Comments

@henriquecbuss
Copy link
Member

What we have
The input we use to login to the app isn't very smart. It just sends data the way it is.

Proposal
We should make our input smarter and sanitize the data before trying to sign in.

Why
To make it easier for users. Sometimes they may paste something with extra spaces, or their input might be not formatted perfectly.

How
Probably something like this is enough:

inputValue
  |> String.words
  |> List.join " "

Additional context
https://cambiatus.slack.com/archives/CA83HJAAD/p1660764647207089

@henriquecbuss henriquecbuss moved this to ✨ New Issues in Software Aug 17, 2022
@henriquecbuss henriquecbuss added the 🧰 enhancement Changes and improvements to what we already have label Aug 17, 2022
@henriquecbuss henriquecbuss added this to the 🧹 Housekeeping milestone Aug 17, 2022
@henriquecbuss henriquecbuss self-assigned this Aug 18, 2022
@henriquecbuss henriquecbuss moved this from ✨ New Issues to 👷🚧 In progress in Software Aug 18, 2022
@henriquecbuss henriquecbuss moved this from 👷🚧 In progress to 📮 Inbox in Software Aug 18, 2022
@henriquecbuss
Copy link
Member Author

Seems like we already do some validation:

passphraseValidator : Form.Validate.Validator String -> Form.Validate.Validator Passphrase
passphraseValidator =
    let
        has12Words passphrase =
            if List.length (String.words passphrase) >= 12 then
                String.words passphrase
                    |> List.take 12
                    |> String.join " "
                    |> Ok

            else
                Err (\translators_ -> translators_.t "auth.login.wordsMode.input.notPassphraseError")

        wordsHave3Letters passphrase =
            if
                String.words passphrase
                    |> List.all (\word -> String.length word > 2)
            then
                Ok passphrase

            else
                Err (\translators_ -> translators_.t "auth.login.wordsMode.input.atLeastThreeLettersError")
    in
    Form.Validate.custom has12Words
        >> Form.Validate.custom wordsHave3Letters
        >> Form.Validate.map Passphrase

@lucca65 any ideas of what else we could do? I couldn't seem to replicate the issue

@lucca65
Copy link
Member

lucca65 commented Aug 18, 2022

clean up extra whitespaces?

downcase everything, because some phones force capitalization of the first letter

There is also something we could do, we actually have access to the word list. To generate the private key we have a finite number of specific words and we can validate them

@henriquecbuss
Copy link
Member Author

clean up extra whitespaces?

That's already done by String.words

downcase everything, because some phones force capitalization of the first letter

👍

There is also something we could do, we actually have access to the word list. To generate the private key we have a finite number of specific words and we can validate them

Where can I get that list? 👀

@lucca65
Copy link
Member

lucca65 commented Aug 18, 2022

the standard we use is called bip39, you can follow our node modules, or here: https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt

@henriquecbuss henriquecbuss moved this from 📮 Inbox to 📑🧐 Review in progress in Software Aug 18, 2022
Repository owner moved this from 📑🧐 Review in progress to ✅ Done in Software Aug 24, 2022
@lucca65 lucca65 moved this from ✅ Done to 🗄️ Archive in Software Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧰 enhancement Changes and improvements to what we already have
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants