Comparing version 3.3.0 to 3.3.1
// Generated by CoffeeScript 1.9.3 | ||
var KEYBOARD_AVERAGE_DEGREE, KEYBOARD_STARTING_POSITIONS, KEYPAD_AVERAGE_DEGREE, KEYPAD_STARTING_POSITIONS, adjacency_graphs, calc_average_degree, k, scoring, v; | ||
var adjacency_graphs, calc_average_degree, k, scoring, v; | ||
@@ -35,28 +35,2 @@ adjacency_graphs = require('./adjacency_graphs'); | ||
KEYBOARD_AVERAGE_DEGREE = calc_average_degree(adjacency_graphs.qwerty); | ||
KEYPAD_AVERAGE_DEGREE = calc_average_degree(adjacency_graphs.keypad); | ||
KEYBOARD_STARTING_POSITIONS = ((function() { | ||
var ref, results; | ||
ref = adjacency_graphs.qwerty; | ||
results = []; | ||
for (k in ref) { | ||
v = ref[k]; | ||
results.push(k); | ||
} | ||
return results; | ||
})()).length; | ||
KEYPAD_STARTING_POSITIONS = ((function() { | ||
var ref, results; | ||
ref = adjacency_graphs.keypad; | ||
results = []; | ||
for (k in ref) { | ||
v = ref[k]; | ||
results.push(k); | ||
} | ||
return results; | ||
})()).length; | ||
scoring = { | ||
@@ -83,3 +57,3 @@ nCk: function(n, k) { | ||
minimum_entropy_match_sequence: function(password, matches) { | ||
var backpointers, bruteforce_cardinality, candidate_entropy, crack_time, i, j, l, len, len1, m, make_bruteforce_match, match, match_sequence, match_sequence_copy, min_entropy, o, ref, ref1, ref2, up_to_k; | ||
var backpointers, bruteforce_cardinality, candidate_entropy, crack_time, i, j, k, l, len, len1, m, make_bruteforce_match, match, match_sequence, match_sequence_copy, min_entropy, o, ref, ref1, ref2, up_to_k; | ||
bruteforce_cardinality = this.calc_bruteforce_cardinality(password); | ||
@@ -223,2 +197,4 @@ up_to_k = []; | ||
}, | ||
MIN_YEAR_SPACE: 20, | ||
REFERENCE_YEAR: 2000, | ||
regex_entropy: function(match) { | ||
@@ -239,4 +215,5 @@ var char_class_bases, year_space; | ||
case 'recent_year': | ||
year_space = parseInt(match.rx_match) - 2000; | ||
return this.lg(Math.abs(year_space)); | ||
year_space = Math.abs(parseInt(match.regex_match[0]) - this.REFERENCE_YEAR); | ||
year_space = Math.max(year_space, this.MIN_YEAR_SPACE); | ||
return this.lg(year_space); | ||
} | ||
@@ -246,4 +223,5 @@ } | ||
date_entropy: function(match) { | ||
var entropy; | ||
entropy = this.lg(Math.abs(match.year - 2000) * 31 * 12); | ||
var entropy, year_space; | ||
year_space = Math.max(Math.abs(match.year - this.REFERENCE_YEAR), this.MIN_YEAR_SPACE); | ||
entropy = this.lg(year_space * 31 * 12); | ||
if (match.has_full_year) { | ||
@@ -257,10 +235,32 @@ entropy += 1; | ||
}, | ||
KEYBOARD_AVERAGE_DEGREE: calc_average_degree(adjacency_graphs.qwerty), | ||
KEYPAD_AVERAGE_DEGREE: calc_average_degree(adjacency_graphs.keypad), | ||
KEYBOARD_STARTING_POSITIONS: ((function() { | ||
var ref, results; | ||
ref = adjacency_graphs.qwerty; | ||
results = []; | ||
for (k in ref) { | ||
v = ref[k]; | ||
results.push(k); | ||
} | ||
return results; | ||
})()).length, | ||
KEYPAD_STARTING_POSITIONS: ((function() { | ||
var ref, results; | ||
ref = adjacency_graphs.keypad; | ||
results = []; | ||
for (k in ref) { | ||
v = ref[k]; | ||
results.push(k); | ||
} | ||
return results; | ||
})()).length, | ||
spatial_entropy: function(match) { | ||
var L, S, U, d, entropy, i, j, l, m, o, possibilities, possible_turns, ref, ref1, ref2, ref3, s, t; | ||
if ((ref = match.graph) === 'qwerty' || ref === 'dvorak') { | ||
s = KEYBOARD_STARTING_POSITIONS; | ||
d = KEYBOARD_AVERAGE_DEGREE; | ||
s = this.KEYBOARD_STARTING_POSITIONS; | ||
d = this.KEYBOARD_AVERAGE_DEGREE; | ||
} else { | ||
s = KEYPAD_STARTING_POSITIONS; | ||
d = KEYPAD_AVERAGE_DEGREE; | ||
s = this.KEYPAD_STARTING_POSITIONS; | ||
d = this.KEYPAD_AVERAGE_DEGREE; | ||
} | ||
@@ -280,7 +280,11 @@ possibilities = 0; | ||
U = match.token.length - match.shifted_count; | ||
possibilities = 0; | ||
for (i = o = 0, ref3 = Math.min(S, U); 0 <= ref3 ? o <= ref3 : o >= ref3; i = 0 <= ref3 ? ++o : --o) { | ||
possibilities += this.nCk(S + U, i); | ||
if (U === 0) { | ||
entropy += 1; | ||
} else { | ||
possibilities = 0; | ||
for (i = o = 1, ref3 = Math.min(S, U); 1 <= ref3 ? o <= ref3 : o >= ref3; i = 1 <= ref3 ? ++o : --o) { | ||
possibilities += this.nCk(S + U, i); | ||
} | ||
entropy += this.lg(possibilities); | ||
} | ||
entropy += this.lg(possibilities); | ||
} | ||
@@ -337,3 +341,3 @@ return entropy; | ||
possibilities = 0; | ||
for (i = m = 0, ref1 = Math.min(U, L); 0 <= ref1 ? m <= ref1 : m >= ref1; i = 0 <= ref1 ? ++m : --m) { | ||
for (i = m = 1, ref1 = Math.min(U, L); 1 <= ref1 ? m <= ref1 : m >= ref1; i = 1 <= ref1 ? ++m : --m) { | ||
possibilities += this.nCk(U + L, i); | ||
@@ -344,16 +348,16 @@ } | ||
extra_l33t_entropy: function(match) { | ||
var S, U, chr, i, l, possibilities, ref, ref1, subbed, unsubbed; | ||
var S, U, chr, chrs, extra_entropy, i, l, p, possibilities, ref, ref1, subbed, unsubbed; | ||
if (!match.l33t) { | ||
return 0; | ||
} | ||
possibilities = 0; | ||
extra_entropy = 0; | ||
ref = match.sub; | ||
for (subbed in ref) { | ||
unsubbed = ref[subbed]; | ||
chrs = match.token.toLowerCase().split(''); | ||
S = ((function() { | ||
var l, len, ref1, results; | ||
ref1 = match.token.split(''); | ||
var l, len, results; | ||
results = []; | ||
for (l = 0, len = ref1.length; l < len; l++) { | ||
chr = ref1[l]; | ||
for (l = 0, len = chrs.length; l < len; l++) { | ||
chr = chrs[l]; | ||
if (chr === subbed) { | ||
@@ -366,7 +370,6 @@ results.push(chr); | ||
U = ((function() { | ||
var l, len, ref1, results; | ||
ref1 = match.token.split(''); | ||
var l, len, results; | ||
results = []; | ||
for (l = 0, len = ref1.length; l < len; l++) { | ||
chr = ref1[l]; | ||
for (l = 0, len = chrs.length; l < len; l++) { | ||
chr = chrs[l]; | ||
if (chr === unsubbed) { | ||
@@ -378,11 +381,26 @@ results.push(chr); | ||
})()).length; | ||
for (i = l = 0, ref1 = Math.min(U, S); 0 <= ref1 ? l <= ref1 : l >= ref1; i = 0 <= ref1 ? ++l : --l) { | ||
possibilities += this.nCk(U + S, i); | ||
if (S === 0 || U === 0) { | ||
extra_entropy += 1; | ||
} else { | ||
p = Math.min(U, S); | ||
possibilities = 0; | ||
for (i = l = 1, ref1 = p; 1 <= ref1 ? l <= ref1 : l >= ref1; i = 1 <= ref1 ? ++l : --l) { | ||
possibilities += this.nCk(U + S, i); | ||
} | ||
extra_entropy += this.lg(possibilities); | ||
} | ||
} | ||
return this.lg(possibilities) || 1; | ||
return extra_entropy; | ||
}, | ||
calc_bruteforce_cardinality: function(password) { | ||
var c, chr, digits, l, len, lower, ord, ref, ref1, symbols, unicode, upper; | ||
ref = [false, false, false, false, false], lower = ref[0], upper = ref[1], digits = ref[2], symbols = ref[3], unicode = ref[4]; | ||
var c, chr, cp, digits, i, l, latin1_letters, latin1_symbols, len, len1, lower, m, max_cp, min_cp, ord, range, ref, ref1, ref2, symbols, unicode_codepoints, upper; | ||
ref = (function() { | ||
var l, results; | ||
results = []; | ||
for (i = l = 0; l < 6; i = ++l) { | ||
results.push(false); | ||
} | ||
return results; | ||
})(), lower = ref[0], upper = ref[1], digits = ref[2], symbols = ref[3], latin1_symbols = ref[4], latin1_letters = ref[5]; | ||
unicode_codepoints = []; | ||
ref1 = password.split(''); | ||
@@ -400,4 +418,8 @@ for (l = 0, len = ref1.length; l < len; l++) { | ||
symbols = true; | ||
} else { | ||
unicode = true; | ||
} else if ((0x80 <= ord && ord <= 0xBF)) { | ||
latin1_symbols = true; | ||
} else if ((0xC0 <= ord && ord <= 0xFF)) { | ||
latin1_letters = true; | ||
} else if (ord > 0xFF) { | ||
unicode_codepoints.push(ord); | ||
} | ||
@@ -418,9 +440,33 @@ } | ||
} | ||
if (unicode) { | ||
c += 100; | ||
if (latin1_symbols) { | ||
c += 64; | ||
} | ||
if (latin1_letters) { | ||
c += 64; | ||
} | ||
if (unicode_codepoints.length) { | ||
min_cp = max_cp = unicode_codepoints[0]; | ||
ref2 = unicode_codepoints.slice(1); | ||
for (m = 0, len1 = ref2.length; m < len1; m++) { | ||
cp = ref2[m]; | ||
if (cp < min_cp) { | ||
min_cp = cp; | ||
} | ||
if (cp > max_cp) { | ||
max_cp = cp; | ||
} | ||
} | ||
range = max_cp - min_cp + 1; | ||
if (range < 40) { | ||
range = 40; | ||
} | ||
if (range > 100) { | ||
range = 100; | ||
} | ||
c += range; | ||
} | ||
return c; | ||
}, | ||
display_time: function(seconds) { | ||
var century, day, hour, minute, month, year; | ||
var base, century, day, display_num, display_str, hour, minute, month, ref, year; | ||
minute = 60; | ||
@@ -432,17 +478,7 @@ hour = minute * 60; | ||
century = year * 100; | ||
if (seconds < minute) { | ||
return 'instant'; | ||
} else if (seconds < hour) { | ||
return (1 + Math.ceil(seconds / minute)) + " minutes"; | ||
} else if (seconds < day) { | ||
return (1 + Math.ceil(seconds / hour)) + " hours"; | ||
} else if (seconds < month) { | ||
return (1 + Math.ceil(seconds / day)) + " days"; | ||
} else if (seconds < year) { | ||
return (1 + Math.ceil(seconds / month)) + " months"; | ||
} else if (seconds < century) { | ||
return (1 + Math.ceil(seconds / year)) + " years"; | ||
} else { | ||
return 'centuries'; | ||
ref = seconds < minute ? [seconds, seconds + " second"] : seconds < hour ? (base = Math.round(seconds / minute), [base, base + " minute"]) : seconds < day ? (base = Math.round(seconds / hour), [base, base + " hour"]) : seconds < month ? (base = Math.round(seconds / day), [base, base + " day"]) : seconds < year ? (base = Math.round(seconds / month), [base, base + " month"]) : seconds < century ? (base = Math.round(seconds / year), [base, base + " year"]) : [null, 'centuries'], display_num = ref[0], display_str = ref[1]; | ||
if ((display_num != null) && display_num !== 1) { | ||
display_str += 's'; | ||
} | ||
return display_str; | ||
} | ||
@@ -449,0 +485,0 @@ }; |
{ | ||
"name": "zxcvbn", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "realistic password strength estimation", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3013743
6803