From d8c685ba2e590bc00478387bba0e42b9237d61dd Mon Sep 17 00:00:00 2001 From: ryanml Date: Tue, 21 Jan 2020 17:22:55 -0800 Subject: [PATCH] Add mechanism to randomize seed phrase filename (#7863) The filename is seeded by a simple use of Math.random() pulling from an alphanumeric character bank, as opposed to a more cryptographically random solution. This provides a simple layer of difficulty for bad actors to seek out the recovery phrase file. --- app/_locales/am/messages.json | 3 --- app/_locales/ar/messages.json | 3 --- app/_locales/bg/messages.json | 3 --- app/_locales/bn/messages.json | 3 --- app/_locales/ca/messages.json | 3 --- app/_locales/da/messages.json | 3 --- app/_locales/de/messages.json | 3 --- app/_locales/el/messages.json | 3 --- app/_locales/en/messages.json | 3 --- app/_locales/es/messages.json | 3 --- app/_locales/es_419/messages.json | 3 --- app/_locales/et/messages.json | 3 --- app/_locales/fa/messages.json | 3 --- app/_locales/fi/messages.json | 3 --- app/_locales/fil/messages.json | 3 --- app/_locales/fr/messages.json | 3 --- app/_locales/he/messages.json | 3 --- app/_locales/hi/messages.json | 3 --- app/_locales/hr/messages.json | 3 --- app/_locales/ht/messages.json | 3 --- app/_locales/hu/messages.json | 3 --- app/_locales/id/messages.json | 3 --- app/_locales/it/messages.json | 3 --- app/_locales/kn/messages.json | 3 --- app/_locales/ko/messages.json | 3 --- app/_locales/lt/messages.json | 3 --- app/_locales/lv/messages.json | 3 --- app/_locales/ms/messages.json | 3 --- app/_locales/no/messages.json | 3 --- app/_locales/pl/messages.json | 3 --- app/_locales/pt_BR/messages.json | 3 --- app/_locales/ro/messages.json | 3 --- app/_locales/ru/messages.json | 3 --- app/_locales/sk/messages.json | 3 --- app/_locales/sl/messages.json | 3 --- app/_locales/sr/messages.json | 3 --- app/_locales/sv/messages.json | 3 --- app/_locales/sw/messages.json | 3 --- app/_locales/uk/messages.json | 3 --- app/_locales/zh_CN/messages.json | 3 --- .../export-text-container.component.js | 5 ++--- ui/app/helpers/utils/util.js | 15 +++++++++++++++ ui/app/helpers/utils/util.test.js | 15 +++++++++++++++ .../confirm-seed-phrase.component.js | 2 +- .../reveal-seed-phrase.component.js | 2 +- ui/app/pages/keychains/reveal-seed.js | 2 +- 46 files changed, 35 insertions(+), 126 deletions(-) diff --git a/app/_locales/am/messages.json b/app/_locales/am/messages.json index 5c1a0471845d..8de236b7cada 100644 --- a/app/_locales/am/messages.json +++ b/app/_locales/am/messages.json @@ -669,9 +669,6 @@ "metamaskDescription": { "message": "ከ Ethereum እና ያልተማከለ መረብ ጋር እርስዎን ማገናኘት።" }, - "metamaskSeedWords": { - "message": "MetaMask የዘር ቃላት" - }, "metamaskVersion": { "message": "የ MetaMask ስሪት" }, diff --git a/app/_locales/ar/messages.json b/app/_locales/ar/messages.json index 0ba0421270e5..fa6eb638a579 100644 --- a/app/_locales/ar/messages.json +++ b/app/_locales/ar/messages.json @@ -665,9 +665,6 @@ "metamaskDescription": { "message": "إيصالك بالإيثيريوم وبالشبكة اللامركزية." }, - "metamaskSeedWords": { - "message": "كلمات MetaMask البذرية" - }, "metamaskVersion": { "message": "إصدار MetaMask " }, diff --git a/app/_locales/bg/messages.json b/app/_locales/bg/messages.json index 87211117857a..9b58cce3da00 100644 --- a/app/_locales/bg/messages.json +++ b/app/_locales/bg/messages.json @@ -668,9 +668,6 @@ "metamaskDescription": { "message": "Свързва ви с Ethereum и децентрализираната мрежа." }, - "metamaskSeedWords": { - "message": "Думи зародиш на MetaMask" - }, "metamaskVersion": { "message": "Версия на MetaMask" }, diff --git a/app/_locales/bn/messages.json b/app/_locales/bn/messages.json index 869281bebb06..ebb3a7943712 100644 --- a/app/_locales/bn/messages.json +++ b/app/_locales/bn/messages.json @@ -672,9 +672,6 @@ "metamaskDescription": { "message": "আপনার Ethereum এবং ছড়িয়ে ছিটিয়ে থাকা ওয়েবের সাথে সংযোগ করছে। " }, - "metamaskSeedWords": { - "message": "MetaMask সীড শব্দসমূহ" - }, "metamaskVersion": { "message": "MetaMask সংস্করণ" }, diff --git a/app/_locales/ca/messages.json b/app/_locales/ca/messages.json index 201d321e0289..38a1b7eb1fcd 100644 --- a/app/_locales/ca/messages.json +++ b/app/_locales/ca/messages.json @@ -656,9 +656,6 @@ "metamaskDescription": { "message": "Conectant-te a Ethereum i la web descentralitzada." }, - "metamaskSeedWords": { - "message": "Frase de recuperació de MetaMask" - }, "metamaskVersion": { "message": "Versió MetaMask" }, diff --git a/app/_locales/da/messages.json b/app/_locales/da/messages.json index 88b457aeceb2..9adeedbf6f0c 100644 --- a/app/_locales/da/messages.json +++ b/app/_locales/da/messages.json @@ -656,9 +656,6 @@ "metamaskDescription": { "message": "Som forbinder dig til Ethereum og de decentraliserede internet." }, - "metamaskSeedWords": { - "message": "MetaMask Seedord" - }, "missingYourTokens": { "message": "Kan du ikke se dine tokens?" }, diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 1c2a4be351ec..b618df138fe7 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -648,9 +648,6 @@ "metamaskDescription": { "message": "MetaMask ist ein sicherer Identitätssafe für Ethereum." }, - "metamaskSeedWords": { - "message": "MetaMask-Seed-Wörter" - }, "metamaskVersion": { "message": "MetaMask-Version" }, diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index 84efaf273f6a..cb9299c0a878 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -669,9 +669,6 @@ "metamaskDescription": { "message": "Σύνδεση με το Ethereum και τον Αποκεντρωμένο Ιστό." }, - "metamaskSeedWords": { - "message": "Λέξεις Φύτρου MetaMask" - }, "metamaskVersion": { "message": "Έκδοση MetaMask " }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 665affeee244..f904ffa50971 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -812,9 +812,6 @@ "metamaskDescription": { "message": "Connecting you to Ethereum and the Decentralized Web." }, - "metamaskSeedWords": { - "message": "MetaMask Seed Words" - }, "metamaskVersion": { "message": "MetaMask Version" }, diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 32c6bb15f568..4fed0b1fb1ce 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -548,9 +548,6 @@ "metamaskDescription": { "message": "MetaMask es una identidad segura en Ethereum" }, - "metamaskSeedWords": { - "message": "Palabras semilla de MetaMask" - }, "metamaskVersion": { "message": "Versión de MetaMask" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index e2d386e0a5da..ac8d8569f241 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -657,9 +657,6 @@ "metamaskDescription": { "message": "Te estamos conectando a Ethereum y a la web descentralizada." }, - "metamaskSeedWords": { - "message": "Palabras de inicialización de MetaMask" - }, "metamaskVersion": { "message": "Versión de MetaMask" }, diff --git a/app/_locales/et/messages.json b/app/_locales/et/messages.json index 3946d4fad8db..191563c2fc61 100644 --- a/app/_locales/et/messages.json +++ b/app/_locales/et/messages.json @@ -662,9 +662,6 @@ "metamaskDescription": { "message": "Teid ühendatakse Ethereumi ja detsentraliseeritud võrguga." }, - "metamaskSeedWords": { - "message": "MetaMaski seemnesõnad" - }, "metamaskVersion": { "message": "MetaMaski versioon" }, diff --git a/app/_locales/fa/messages.json b/app/_locales/fa/messages.json index 94c041ff98fb..f95adee30840 100644 --- a/app/_locales/fa/messages.json +++ b/app/_locales/fa/messages.json @@ -672,9 +672,6 @@ "metamaskDescription": { "message": "در حال اتصال شما با ایترم و وب غیر متمرکز شده." }, - "metamaskSeedWords": { - "message": "کلمات بازیاب MetaMask" - }, "metamaskVersion": { "message": "نسخه MetaMask" }, diff --git a/app/_locales/fi/messages.json b/app/_locales/fi/messages.json index 61df7c813c42..31f1ff147e71 100644 --- a/app/_locales/fi/messages.json +++ b/app/_locales/fi/messages.json @@ -669,9 +669,6 @@ "metamaskDescription": { "message": "Sinua yhdistetään Ethereumiin ja hajautettuun verkkoon." }, - "metamaskSeedWords": { - "message": "MetaMaskin siemensanat" - }, "metamaskVersion": { "message": "MetaMask-versio" }, diff --git a/app/_locales/fil/messages.json b/app/_locales/fil/messages.json index ff44ba30a291..9311cdbdb360 100644 --- a/app/_locales/fil/messages.json +++ b/app/_locales/fil/messages.json @@ -607,9 +607,6 @@ "metamaskDescription": { "message": "Kinokonekta ka sa Ethereum at sa Decentralized Web." }, - "metamaskSeedWords": { - "message": "Seed Words ng MetaMask" - }, "metamaskVersion": { "message": "Bersyon ng MetaMask" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 5eb4dc066054..937d0e520ef3 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -651,9 +651,6 @@ "metamaskDescription": { "message": "MetaMask est un coffre sécurisé pour votre identité sur Ethereum." }, - "metamaskSeedWords": { - "message": "Mots Seed pour MetaMask" - }, "metamaskVersion": { "message": "Version de MetaMask" }, diff --git a/app/_locales/he/messages.json b/app/_locales/he/messages.json index c7e14dc771ee..bc906bafd042 100644 --- a/app/_locales/he/messages.json +++ b/app/_locales/he/messages.json @@ -669,9 +669,6 @@ "metamaskDescription": { "message": "מחבר אותך לאתריום ולרשת המבוזרת." }, - "metamaskSeedWords": { - "message": "מילות גרעין (Seed) של MetaMask " - }, "metamaskVersion": { "message": "גרסת MetaMask" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index 9a2f69614d1c..d3a955013501 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -669,9 +669,6 @@ "metamaskDescription": { "message": "आपको Ethereum और विकेंद्रीकृत वेब से कनेक्ट कर रहे हैं।" }, - "metamaskSeedWords": { - "message": "मेटामास्क बीज शब्द" - }, "metamaskVersion": { "message": "MetaMask का संस्करण" }, diff --git a/app/_locales/hr/messages.json b/app/_locales/hr/messages.json index e3ce9f2b7d4d..aa22658e4611 100644 --- a/app/_locales/hr/messages.json +++ b/app/_locales/hr/messages.json @@ -665,9 +665,6 @@ "metamaskDescription": { "message": "Povezujete se na Ethereum i decentralizirani internet." }, - "metamaskSeedWords": { - "message": "Početne riječi za MetaMask" - }, "metamaskVersion": { "message": "Inačica usluge MetaMask" }, diff --git a/app/_locales/ht/messages.json b/app/_locales/ht/messages.json index 6ca9b5c44168..8ae90a17d5be 100644 --- a/app/_locales/ht/messages.json +++ b/app/_locales/ht/messages.json @@ -401,9 +401,6 @@ "metamaskDescription": { "message": "MetaMask sekirize idantite pou Ethereum." }, - "metamaskSeedWords": { - "message": "MetaMask Seed Mo" - }, "metamaskVersion": { "message": "MetaMask Vèsyon" }, diff --git a/app/_locales/hu/messages.json b/app/_locales/hu/messages.json index 1794413e1b59..8d0c94228f7c 100644 --- a/app/_locales/hu/messages.json +++ b/app/_locales/hu/messages.json @@ -665,9 +665,6 @@ "metamaskDescription": { "message": "Csatlakozás az Ethereumhoz és a decentralizált hálózathoz." }, - "metamaskSeedWords": { - "message": "MetaMask seed szavak" - }, "metamaskVersion": { "message": "MetaMask verzió" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index 5ca31e394807..d7281ab629ea 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -650,9 +650,6 @@ "metamaskDescription": { "message": "Menghubungkan Anda ke Ethereum dan Web Terdesentralisasi." }, - "metamaskSeedWords": { - "message": "Kata Benih MetaMask" - }, "metamaskVersion": { "message": "Versi MetaMask" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 3b7a4870cb3b..e03c58d0555e 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -642,9 +642,6 @@ "metamaskDescription": { "message": "MetaMask è una cassaforte sicura per identità su Ethereum." }, - "metamaskSeedWords": { - "message": "Parole Seed di MetaMask" - }, "metamaskVersion": { "message": "versione di MetaMask" }, diff --git a/app/_locales/kn/messages.json b/app/_locales/kn/messages.json index 61d7fe74b23b..81c134c0e613 100644 --- a/app/_locales/kn/messages.json +++ b/app/_locales/kn/messages.json @@ -672,9 +672,6 @@ "metamaskDescription": { "message": "ನಿಮ್ಮನ್ನು ಎಥೆರಿಯಮ್ ಮತ್ತು ವಿಕೇಂದ್ರೀಕೃತ ವೆಬ್‌ಗೆ ಸಂಪರ್ಕಿಸಲಾಗುತ್ತಿದೆ." }, - "metamaskSeedWords": { - "message": "MetaMask ಸೀಡ್ ಪದಗಳು" - }, "metamaskVersion": { "message": "MetaMask ಆವೃತ್ತಿ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 346b7f4e3107..f2166ab36903 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -666,9 +666,6 @@ "metamaskDescription": { "message": "메타마스크는 이더리움을 위한 안전한 저장소입니다." }, - "metamaskSeedWords": { - "message": "메타마스크 시드 단어" - }, "metamaskVersion": { "message": "메타마스크 버전" }, diff --git a/app/_locales/lt/messages.json b/app/_locales/lt/messages.json index a89974bcc33b..d19b40b959d3 100644 --- a/app/_locales/lt/messages.json +++ b/app/_locales/lt/messages.json @@ -672,9 +672,6 @@ "metamaskDescription": { "message": "Prijungiame jus prie „Ethereum“ ir decentralizuotojo žiniatinklio." }, - "metamaskSeedWords": { - "message": "„MetaMask“ atkūrimo žodžiai" - }, "metamaskVersion": { "message": "„MetaMask“ versija" }, diff --git a/app/_locales/lv/messages.json b/app/_locales/lv/messages.json index 98a61ee46ad9..71d06529b84a 100644 --- a/app/_locales/lv/messages.json +++ b/app/_locales/lv/messages.json @@ -668,9 +668,6 @@ "metamaskDescription": { "message": "Veido savienojumu ar Ethereum un decentralizēto tīmekli." }, - "metamaskSeedWords": { - "message": "MetaMask atkopšanas vārdi" - }, "metamaskVersion": { "message": "MetaMask versija" }, diff --git a/app/_locales/ms/messages.json b/app/_locales/ms/messages.json index aaf4cca590c7..f16184011f9d 100644 --- a/app/_locales/ms/messages.json +++ b/app/_locales/ms/messages.json @@ -643,9 +643,6 @@ "metamaskDescription": { "message": "Menyambungkan anda kepada Ethereum dan Web Ternyahpusat." }, - "metamaskSeedWords": { - "message": "Perkataan Benih MetaMask" - }, "metamaskVersion": { "message": "Versi MetaMask" }, diff --git a/app/_locales/no/messages.json b/app/_locales/no/messages.json index 5102c3c9711d..84a4c2f18cdc 100644 --- a/app/_locales/no/messages.json +++ b/app/_locales/no/messages.json @@ -662,9 +662,6 @@ "metamaskDescription": { "message": "Kobler deg til Ethereum og det desentraliserte nettet." }, - "metamaskSeedWords": { - "message": "Mnemoniske gjenopprettingsfraser for MetaMask " - }, "metamaskVersion": { "message": "MetaMask-versjon " }, diff --git a/app/_locales/pl/messages.json b/app/_locales/pl/messages.json index 6e08f31aa345..9c037eddbabe 100644 --- a/app/_locales/pl/messages.json +++ b/app/_locales/pl/messages.json @@ -663,9 +663,6 @@ "metamaskDescription": { "message": "MetaMask to bezpieczny portfel dla Ethereum." }, - "metamaskSeedWords": { - "message": "Słowa Seed MetaMask" - }, "metamaskVersion": { "message": "Wersja MetaMask" }, diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index 52a711bd30c8..367d52564580 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -657,9 +657,6 @@ "metamaskDescription": { "message": "Conectando você ao Ethereum e à Web Descentralizada." }, - "metamaskSeedWords": { - "message": "Palavras-semente do MetaMask" - }, "metamaskVersion": { "message": "Versão do MetaMask" }, diff --git a/app/_locales/ro/messages.json b/app/_locales/ro/messages.json index aeb986ecb9d2..308ad5c74515 100644 --- a/app/_locales/ro/messages.json +++ b/app/_locales/ro/messages.json @@ -659,9 +659,6 @@ "metamaskDescription": { "message": "Vă conectăm la Ethereum și la Internetul descentralizat." }, - "metamaskSeedWords": { - "message": "Cuvinte Seed MetaMask" - }, "metamaskVersion": { "message": "Versiune MetaMask" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 9d819c29bac1..addc3178e025 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -896,9 +896,6 @@ "menu": { "message": "Меню" }, - "metamaskSeedWords": { - "message": "MetaMask ключевая фраза (сид)" - }, "metamaskVersion": { "message": "Версия MetaMask" }, diff --git a/app/_locales/sk/messages.json b/app/_locales/sk/messages.json index c1a5ef877c85..0460edb0bb08 100644 --- a/app/_locales/sk/messages.json +++ b/app/_locales/sk/messages.json @@ -638,9 +638,6 @@ "metamaskDescription": { "message": "MetaMask je bezpečný osobní trezor pro Ethereum." }, - "metamaskSeedWords": { - "message": "Seed slová MetaMask" - }, "metamaskVersion": { "message": "Verzia MetaMask" }, diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index 2dbeb1046440..ed1c3f71c9c9 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -657,9 +657,6 @@ "metamaskDescription": { "message": "MetaMask je varen identitetni sklad za Ethereum." }, - "metamaskSeedWords": { - "message": "Seed Words" - }, "metamaskVersion": { "message": "Različica" }, diff --git a/app/_locales/sr/messages.json b/app/_locales/sr/messages.json index 3b359584c02c..afc28ec93e53 100644 --- a/app/_locales/sr/messages.json +++ b/app/_locales/sr/messages.json @@ -663,9 +663,6 @@ "metamaskDescription": { "message": "Povezivanje na Ethereum i decentralizovani veb." }, - "metamaskSeedWords": { - "message": "MetaMask reči početne vrednosti" - }, "metamaskVersion": { "message": "MetaMask verzija" }, diff --git a/app/_locales/sv/messages.json b/app/_locales/sv/messages.json index 22cd0ffe66bd..098170886024 100644 --- a/app/_locales/sv/messages.json +++ b/app/_locales/sv/messages.json @@ -656,9 +656,6 @@ "metamaskDescription": { "message": "Ansluter dig mot Ethereum och den decentraliserade webben." }, - "metamaskSeedWords": { - "message": "MetaMask" - }, "metamaskVersion": { "message": "MetaMask-version" }, diff --git a/app/_locales/sw/messages.json b/app/_locales/sw/messages.json index 3326b7c7aee1..38cf9883f95b 100644 --- a/app/_locales/sw/messages.json +++ b/app/_locales/sw/messages.json @@ -650,9 +650,6 @@ "metamaskDescription": { "message": "Kukuunganisha kwenye Ethereum na Wavutiu Uliotawanywa." }, - "metamaskSeedWords": { - "message": "Maeno ya Kianzio ya MetaMask" - }, "metamaskVersion": { "message": "Toleo la MetaMask" }, diff --git a/app/_locales/uk/messages.json b/app/_locales/uk/messages.json index fa62d58f5c09..1e9218df98fe 100644 --- a/app/_locales/uk/messages.json +++ b/app/_locales/uk/messages.json @@ -672,9 +672,6 @@ "metamaskDescription": { "message": "Під'єднуємо вас до Ethereum та децентралізованої мережі." }, - "metamaskSeedWords": { - "message": "Початкові слова MetaMask" - }, "metamaskVersion": { "message": "Версія MetaMask" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index f970b5606e0d..b6cc66806de5 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -660,9 +660,6 @@ "metamaskDescription": { "message": "MetaMask is a secure identity vault for Ethereum." }, - "metamaskSeedWords": { - "message": "MetaMask 助记词" - }, "metamaskVersion": { "message": "MetaMask 版本" }, diff --git a/ui/app/components/ui/export-text-container/export-text-container.component.js b/ui/app/components/ui/export-text-container/export-text-container.component.js index ee809a553c54..61d15a99df0d 100644 --- a/ui/app/components/ui/export-text-container/export-text-container.component.js +++ b/ui/app/components/ui/export-text-container/export-text-container.component.js @@ -5,7 +5,7 @@ import { exportAsFile } from '../../../helpers/utils/util' class ExportTextContainer extends Component { render () { - const { text = '', filename = '' } = this.props + const { text = '' } = this.props const { t } = this.context return ( @@ -27,7 +27,7 @@ class ExportTextContainer extends Component {
exportAsFile(filename, text)} + onClick={() => exportAsFile('', text)} >
@@ -42,7 +42,6 @@ class ExportTextContainer extends Component { ExportTextContainer.propTypes = { text: PropTypes.string, - filename: PropTypes.string, } ExportTextContainer.contextTypes = { diff --git a/ui/app/helpers/utils/util.js b/ui/app/helpers/utils/util.js index c9ede21d889f..04e5072d5f6e 100644 --- a/ui/app/helpers/utils/util.js +++ b/ui/app/helpers/utils/util.js @@ -213,7 +213,22 @@ export function getContractAtAddress (tokenAddress) { return global.eth.contract(abi).at(tokenAddress) } +export function getRandomFileName () { + let fileName = '' + const charBank = [ + ...'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', + ] + const fileNameLength = Math.floor((Math.random() * 7) + 6) + + for (let i = 0; i < fileNameLength; i++) { + fileName += charBank[Math.floor(Math.random() * charBank.length)] + } + + return fileName +} + export function exportAsFile (filename, data, type = 'text/csv') { + filename = filename || getRandomFileName() // source: https://stackoverflow.com/a/33542499 by Ludovic Feltz const blob = new Blob([data], { type }) if (window.navigator.msSaveOrOpenBlob) { diff --git a/ui/app/helpers/utils/util.test.js b/ui/app/helpers/utils/util.test.js index 6e623ae3a5c6..51ec92ee3ac8 100644 --- a/ui/app/helpers/utils/util.test.js +++ b/ui/app/helpers/utils/util.test.js @@ -254,5 +254,20 @@ describe('util', function () { assert(result) }) }) + + describe('#getRandomFileName', function () { + it('should only return a string containing alphanumeric characters', function () { + const result = util.getRandomFileName() + assert(result.match(/^[a-zA-Z0-9]*$/g)) + }) + + // 50 samples + it('should return a string that is between 6 and 12 characters in length', function () { + for (let i = 0; i < 50; i++) { + const result = util.getRandomFileName() + assert(result.length >= 6 && result.length <= 12) + } + }) + }) }) }) diff --git a/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js b/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js index 8f51e89a3150..6642e1e7d0b8 100644 --- a/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js +++ b/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js @@ -67,7 +67,7 @@ export default class ConfirmSeedPhrase extends PureComponent { } handleExport = () => { - exportAsFile('MetaMask Secret Backup Phrase', this.props.seedPhrase, 'text/plain') + exportAsFile('', this.props.seedPhrase, 'text/plain') } handleSubmit = async () => { diff --git a/ui/app/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js b/ui/app/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js index 922685059ed2..afcd771c46e5 100644 --- a/ui/app/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js +++ b/ui/app/pages/first-time-flow/seed-phrase/reveal-seed-phrase/reveal-seed-phrase.component.js @@ -30,7 +30,7 @@ export default class RevealSeedPhrase extends PureComponent { } handleExport = () => { - exportAsFile('MetaMask Secret Backup Phrase', this.props.seedPhrase, 'text/plain') + exportAsFile('', this.props.seedPhrase, 'text/plain') } handleNext = () => { diff --git a/ui/app/pages/keychains/reveal-seed.js b/ui/app/pages/keychains/reveal-seed.js index b8afd1bcdec3..fa527a36396b 100644 --- a/ui/app/pages/keychains/reveal-seed.js +++ b/ui/app/pages/keychains/reveal-seed.js @@ -88,7 +88,7 @@ class RevealSeedPage extends Component { return (
- +
) }