1 | matching = require './matching'
|
2 | scoring = require './scoring'
|
3 | time_estimates = require './time_estimates'
|
4 | feedback = require './feedback'
|
5 |
|
6 | time = -> (new Date()).getTime()
|
7 |
|
8 | zxcvbn = (password, user_inputs = []) ->
|
9 | start = time()
|
10 |
|
11 | sanitized_inputs = []
|
12 | for arg in user_inputs
|
13 | if typeof arg in ["string", "number", "boolean"]
|
14 | sanitized_inputs.push arg.toString().toLowerCase()
|
15 | matching.set_user_input_dictionary sanitized_inputs
|
16 | matches = matching.omnimatch password
|
17 | result = scoring.most_guessable_match_sequence password, matches
|
18 | result.calc_time = time() - start
|
19 | attack_times = time_estimates.estimate_attack_times result.guesses
|
20 | for prop, val of attack_times
|
21 | result[prop] = val
|
22 | result.feedback = feedback.get_feedback result.score, result.sequence
|
23 | result
|
24 |
|
25 | module.exports = zxcvbn
|