Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let wordCount = 0
const trimmedWords = suppliedSeedPhrase
.trim()
.split(" ")
.filter(word => word.length > 0)
.map(word => word.trim())
.map(word => word.toLowerCase())
if (trimmedWords.length > 0) {
wordCount = trimmedWords.length
}
if (wordCount !== 23) {
const msg = "Please enter 23 words. (You entered " + wordCount + ")"
return validationReply(msg)
}
const dictionary = bip39.wordlists[bip39.getDefaultWordlist()]
const nonDictionaryWords =
trimmedWords
.map(word => dictionary.includes(word) ? "" : word)
.filter(word => word.length > 0)
.map(word => "'" + word + "'")
.join(", ")
if (nonDictionaryWords.length > 0) {
const msg = "Words not in the dictionary: " + nonDictionaryWords
return validationReply(msg)
}
return validationReply("", trimmedWords.join(" "))
}