Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/paranoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
vulnerable browser plugins) and with the ability to increase
the algorithm complexity over time.

Version 1.0.0-beta
Version 1.0.0-beta2
*/

var URIjs = require('URIjs');
Expand All @@ -32,6 +32,7 @@ var DEFAULT_ITERATIONS = 2000;
* is being generated
* - iterations: (optional, default 2000) number of pbkdf2 iterations
*
* - normalize: (optional, default true) attempt to normalize uri
* - doNotNormalizePrefix: (optional, default undefined) if set, any uri that
* starts with the doNotNormalizePrefix will not be normalized
* - applyPasswordRules: (optional, default true) ensures at least one
Expand All @@ -48,6 +49,10 @@ function paranoid (opts) {
var paranoidLock = opts.paranoidLock || opts.lock;
var uri = opts.uri || opts.target;
var iterations = opts.iterations || DEFAULT_ITERATIONS;
var normalize = true;
if ('normalize' in opts) {
normalize = opts.normalize;
}

// verify required fields are present
if (!masterPassword || !paranoidLock || !uri) {
Expand All @@ -62,7 +67,7 @@ function paranoid (opts) {
removeWordBreaks: opts.removeWordBreaks || true,

// normalize unless prefix is given and matches the uri
normalize: !(opts.doNotNormalizePrefix &&
normalize: !!normalize && !(opts.doNotNormalizePrefix &&
uri.substr(0, opts.doNotNormalizePrefix.length) ===
opts.doNotNoramlizePrefix)
};
Expand Down