From bd06a46b5e00c2d69024e771ea67420db847dcc5 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 7 Dec 2018 06:11:51 +0000 Subject: [PATCH] Pronounceable password format Fixes #12 --- passmate.css | 10 +++++++--- passmate.js | 40 +++++++++++++++++++++++++++++++++++++-- test/canonical_values.txt | 5 +++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/passmate.css b/passmate.css index 7b97078..63223cb 100644 --- a/passmate.css +++ b/passmate.css @@ -404,15 +404,19 @@ overview,product { font-size: 1.1em; } - passwordAlphaNum,passwordWords { + passwordShort,passwordPronounceable,passwordReadable { display: none; } - product.passwords-short passwordAlphaNum { + product.passwords-short passwordShort { display: inline; } - product.passwords-readable passwordWords { + product.passwords-pronounceable passwordPronounceable { + display: inline; + } + + product.passwords-readable passwordReadable { display: inline; } diff --git a/passmate.js b/passmate.js index 0e14a78..2629a31 100644 --- a/passmate.js +++ b/passmate.js @@ -1,7 +1,10 @@ class PassMate { constructor(container) { this.SAFE_UALPHA = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; + this.SAFE_UALPHA_CON = 'BCDFGHJKLMNPQRSTVWXYZ'; this.SAFE_LALPHA = 'abcdefghijkmnpqrstuvwxyz'; + this.SAFE_LALPHA_CON = 'bcdfghjkmnpqrstvwxyz'; + this.SAFE_LALPHA_VOW = 'aeu'; this.SAFE_NUM = '23456789'; this.SAFE_ALPHANUM = this.SAFE_UALPHA + this.SAFE_LALPHA + this.SAFE_NUM; this.SAFE_SYMBOL = '!?'; @@ -20,6 +23,7 @@ class PassMate { this.pages = []; this.shortPasswords = new Map(); + this.pronounceablePasswords = new Map(); this.readablePasswords = new Map(); this.addProduct(container); @@ -55,11 +59,14 @@ class PassMate { let formats = this.addElement('ul', formatStep); let format = new Select((key) => { this.product.classList.remove('passwords-short'); + this.product.classList.remove('passwords-pronounceable'); this.product.classList.remove('passwords-readable'); this.product.classList.add('passwords-' + key); }); let shortItem = this.addElement('li', formats); format.add('short', this.addElement('button', shortItem, 'Short: 5EQaDfNS')); + let pronounceableItem = this.addElement('li', formats); + format.add('pronounceable', this.addElement('button', pronounceableItem, 'Pronounceable: KebeDuveBagica39')); let readableItem = this.addElement('li', formats); format.add('readable', this.addElement('button', readableItem, 'Readable: LeasedBarneyPlays565 (too long for some websites)')); @@ -210,10 +217,13 @@ class PassMate { password.style.gridArea = 'password'; this.shortPasswords.set( letter + '-' + (i % pagesPerLetter).toString() + '-' + j.toString(), - this.addElement('passwordAlphaNum', password)); + this.addElement('passwordShort', password)); + this.pronounceablePasswords.set( + letter + '-' + (i % pagesPerLetter).toString() + '-' + j.toString(), + this.addElement('passwordPronounceable', password)); this.readablePasswords.set( letter + '-' + (i % pagesPerLetter).toString() + '-' + j.toString(), - this.addElement('passwordWords', password)); + this.addElement('passwordReadable', password)); this.addElement('passwordSymbols', password, this.SAFE_SYMBOL); this.addElement('websiteLabel', pwblock, 'Website:').style.gridArea = 'websiteLabel'; @@ -306,6 +316,32 @@ class PassMate { container.innerText = arr.join(''); }); } + + for (let [info, container] of this.pronounceablePasswords) { + let choices = [ + this.SAFE_UALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_LALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_UALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_LALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_UALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_LALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_LALPHA_CON, + this.SAFE_LALPHA_VOW, + this.SAFE_NUM, + this.SAFE_NUM, + this.SAFE_NUM, + ]; + this.deriveValidArray(key, info, choices, this.validatePassword.bind(this)) + .then((arr) => { + container.innerText = arr.join(''); + }); + } } /** diff --git a/test/canonical_values.txt b/test/canonical_values.txt index 6532e25..8aeb065 100644 --- a/test/canonical_values.txt +++ b/test/canonical_values.txt @@ -4,6 +4,11 @@ A6Fe2bnneuTMUNEAVKQpjNQq74BQVG5JB A-0-1: qhqv9Myy A-1-0: MzyhW9Np Z-1-4: 5EQaDfNS + Pronounceable + A-0-0: DetaNemaJekada532 + A-0-1: JuquSafaCedece842 + A-1-0: PuvuZahaTuzaxu628 + Z-1-4: YataFeraQerura389 Readable A-0-0: ReactorsHybridElected875 A-0-1: OlderOwnerGeneric253