diff --git a/dist/lesspass.js b/dist/lesspass.js index 26c5e91..6913458 100644 --- a/dist/lesspass.js +++ b/dist/lesspass.js @@ -29,7 +29,16 @@ module.exports = { }; var defaultPasswordProfile = { - version: 1 + version: 2, + lowercase: true, + digits: true, + uppercase: true, + symbols: true, + keylen: 32, + digest: 'sha256', + length: 16, + index: 1, + iterations: 100000 }; function generatePassword(site, login, masterPassword, passwordProfile) { @@ -51,7 +60,7 @@ function generatePassword(site, login, masterPassword, passwordProfile) { }); } if (_passwordProfile.version === 2) { - return v2.generatePassword(site, login, masterPassword, passwordProfile); + return v2.generatePassword(site, login, masterPassword, _passwordProfile); } } },{"./src/pbkdf2":48,"./src/v1":49,"./src/v2":50,"object-assign":18}],2:[function(require,module,exports){ @@ -8468,7 +8477,6 @@ function createFingerprint(str) { },{"./pbkdf2":48,"buffer":6,"create-hmac":12,"pinkie-promise":21}],50:[function(require,module,exports){ var pbkdf2 = require('./pbkdf2'); var bigInt = require("big-integer"); -var objectAssign = require('object-assign'); module.exports = { generatePassword: generatePassword, @@ -8482,24 +8490,11 @@ module.exports = { }; function generatePassword(site, login, masterPassword, passwordProfile) { - var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile); - return calcEntropy(site, login, masterPassword, _passwordProfile).then(function (entropy) { - return renderPassword(entropy, _passwordProfile); + return calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) { + return renderPassword(entropy, passwordProfile); }); } -var defaultPasswordProfile = { - lowercase: true, - uppercase: true, - digits: true, - symbols: true, - length: 16, - index: 1, - iterations: 100000, - keylen: 32, - digest: 'sha256' -}; - function calcEntropy(site, login, masterPassword, passwordProfile) { var salt = site + login + passwordProfile.index.toString(16); return pbkdf2(masterPassword, salt, passwordProfile.iterations, passwordProfile.keylen, passwordProfile.digest); @@ -8558,13 +8553,12 @@ function getConfiguredRules(passwordProfile) { } function renderPassword(entropy, passwordProfile) { - var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile); - var rules = getConfiguredRules(_passwordProfile); + var rules = getConfiguredRules(passwordProfile); var setOfCharacters = getSetOfCharacters(rules); - var password = consumeEntropy('', bigInt(entropy, 16), setOfCharacters, _passwordProfile.length - rules.length); + var password = consumeEntropy('', bigInt(entropy, 16), setOfCharacters, passwordProfile.length - rules.length); var charactersToAdd = getOneCharPerRule(password.entropy, rules); return insertStringPseudoRandomly(password.value, charactersToAdd.entropy, charactersToAdd.value); } -},{"./pbkdf2":48,"big-integer":3,"object-assign":18}]},{},[1])(1) +},{"./pbkdf2":48,"big-integer":3}]},{},[1])(1) }); \ No newline at end of file diff --git a/index.js b/index.js index a85cd91..d8064f1 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,16 @@ module.exports = { }; var defaultPasswordProfile = { - version: 1 + version: 2, + lowercase: true, + digits: true, + uppercase: true, + symbols: true, + keylen: 32, + digest: 'sha256', + length: 16, + index: 1, + iterations: 100000 }; function generatePassword(site, login, masterPassword, passwordProfile) { @@ -50,6 +59,6 @@ function generatePassword(site, login, masterPassword, passwordProfile) { }); } if (_passwordProfile.version === 2) { - return v2.generatePassword(site, login, masterPassword, passwordProfile); + return v2.generatePassword(site, login, masterPassword, _passwordProfile); } } \ No newline at end of file diff --git a/package.json b/package.json index 5721f52..2b3017b 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "unibabel": "^2.1.3" }, "devDependencies": { - "bluebird": "^3.4.6", "browserify": "^13.1.1", "chai": "^3.5.0", "karma": "^1.3.0", diff --git a/src/v2.js b/src/v2.js index f0e4102..7881568 100644 --- a/src/v2.js +++ b/src/v2.js @@ -1,6 +1,5 @@ var pbkdf2 = require('./pbkdf2'); var bigInt = require("big-integer"); -var objectAssign = require('object-assign'); module.exports = { generatePassword: generatePassword, @@ -14,24 +13,11 @@ module.exports = { }; function generatePassword(site, login, masterPassword, passwordProfile) { - var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile); - return calcEntropy(site, login, masterPassword, _passwordProfile).then(function (entropy) { - return renderPassword(entropy, _passwordProfile); + return calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) { + return renderPassword(entropy, passwordProfile); }); } -var defaultPasswordProfile = { - lowercase: true, - uppercase: true, - digits: true, - symbols: true, - length: 16, - index: 1, - iterations: 100000, - keylen: 32, - digest: 'sha256' -}; - function calcEntropy(site, login, masterPassword, passwordProfile) { var salt = site + login + passwordProfile.index.toString(16); return pbkdf2(masterPassword, salt, passwordProfile.iterations, passwordProfile.keylen, passwordProfile.digest); @@ -90,10 +76,9 @@ function getConfiguredRules(passwordProfile) { } function renderPassword(entropy, passwordProfile) { - var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile); - var rules = getConfiguredRules(_passwordProfile); + var rules = getConfiguredRules(passwordProfile); var setOfCharacters = getSetOfCharacters(rules); - var password = consumeEntropy('', bigInt(entropy, 16), setOfCharacters, _passwordProfile.length - rules.length); + var password = consumeEntropy('', bigInt(entropy, 16), setOfCharacters, passwordProfile.length - rules.length); var charactersToAdd = getOneCharPerRule(password.entropy, rules); return insertStringPseudoRandomly(password.value, charactersToAdd.entropy, charactersToAdd.value); } diff --git a/tests/karma.config.js b/tests/karma.config.js index e47a5a5..6ba61c5 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -3,7 +3,6 @@ module.exports = function (config) { basePath: '..', frameworks: ['mocha', 'chai'], files: [ - 'node_modules/bluebird/js/browser/bluebird.core.min.js', 'node_modules/big-integer/BigInteger.min.js', 'dist/lesspass.js', 'tests/**/*.js' diff --git a/tests/v2/debug.py b/tests/v2/debug.py deleted file mode 100644 index e494f8b..0000000 --- a/tests/v2/debug.py +++ /dev/null @@ -1,16 +0,0 @@ -import math - - -def renderPassword(mdp, quotient, alphabet): - if len(mdp) > 14: - return mdp - quotient, remainder = divmod(quotient, len(alphabet)) - mdp += alphabet[remainder] - return renderPassword(mdp, quotient, alphabet) - - -alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' -print(renderPassword('', int('dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e', 16), alphabet)) - -max_length = math.floor(math.log(int('dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e', 16))/math.log(26 + 26 + 10 + 32)) - 4 -print('max number of char for password with 32 bytes entropy: %d' % max_length)