eslint config & cleanups
This commit is contained in:
28
.eslintrc.js
Normal file
28
.eslintrc.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2015
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"indent": [
|
||||||
|
"error",
|
||||||
|
"tab"
|
||||||
|
],
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
8
package.json
Normal file
8
package.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "passmate",
|
||||||
|
"description": "Generate secure, unique password books to print at home",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^5.9.0",
|
||||||
|
"eslint-config-google": "^0.11.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
30
passmate.js
30
passmate.js
@@ -88,7 +88,6 @@ class PassMate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPages(container, numPages) {
|
addPages(container, numPages) {
|
||||||
console.assert(numPages % 4 == 0);
|
|
||||||
let numSheets = numPages / 4;
|
let numSheets = numPages / 4;
|
||||||
for (let sheetNum = 0; sheetNum < numSheets; ++sheetNum) {
|
for (let sheetNum = 0; sheetNum < numSheets; ++sheetNum) {
|
||||||
let sideNum = sheetNum * 2;
|
let sideNum = sheetNum * 2;
|
||||||
@@ -218,11 +217,9 @@ class PassMate {
|
|||||||
{name: 'HKDF'},
|
{name: 'HKDF'},
|
||||||
false,
|
false,
|
||||||
['deriveBits'])
|
['deriveBits'])
|
||||||
.then((key) => {
|
.then((key) => {
|
||||||
this.addDerivedPasswords(key);
|
this.addDerivedPasswords(key);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.assert(false, 'Invalid recovery key version:', this.recovery.charAt(0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,19 +239,18 @@ class PassMate {
|
|||||||
},
|
},
|
||||||
key,
|
key,
|
||||||
this.PASSWORD_LENGTH * this.OVERSAMPLE * 8 /* bits per byte */)
|
this.PASSWORD_LENGTH * this.OVERSAMPLE * 8 /* bits per byte */)
|
||||||
.then((bits) => {
|
.then((bits) => {
|
||||||
let password = this.generatePassword(this.PASSWORD_LENGTH, new Uint8Array(bits));
|
let password = this.generatePassword(this.PASSWORD_LENGTH, new Uint8Array(bits));
|
||||||
if (this.validatePassword(password)) {
|
if (this.validatePassword(password)) {
|
||||||
container.innerText = password;
|
container.innerText = password;
|
||||||
} else {
|
} else {
|
||||||
// Keep trying until we get a valid password.
|
// Keep trying until we get a valid password.
|
||||||
this.addDerivedPassword(key, info + 'x', container);
|
this.addDerivedPassword(key, info + 'x', container);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
intToSafeChar(i) {
|
intToSafeChar(i) {
|
||||||
console.assert(this.SAFE_ALPHANUM.length < 0x3f);
|
|
||||||
i %= 0x3f;
|
i %= 0x3f;
|
||||||
if (i < this.SAFE_ALPHANUM.length) {
|
if (i < this.SAFE_ALPHANUM.length) {
|
||||||
return [this.SAFE_ALPHANUM[i]];
|
return [this.SAFE_ALPHANUM[i]];
|
||||||
@@ -285,7 +281,7 @@ function onReady() {
|
|||||||
new PassMate(document.getElementsByTagName('body')[0]);
|
new PassMate(document.getElementsByTagName('body')[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.readyState === "loading") {
|
if (document.readyState == 'loading') {
|
||||||
document.addEventListener('DOMContentLoaded', onReady);
|
document.addEventListener('DOMContentLoaded', onReady);
|
||||||
} else {
|
} else {
|
||||||
onReady();
|
onReady();
|
||||||
|
|||||||
Reference in New Issue
Block a user