diff --git a/lib/paranoid.js b/lib/paranoid.js index cd2ef41..def8cd1 100644 --- a/lib/paranoid.js +++ b/lib/paranoid.js @@ -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'); @@ -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 @@ -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) { @@ -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) };