Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 1be2d93496dc9d422ad9bf0f95bbcf39df138410 1 parent 43cf448
Andrey Kislyuk authored committed
1  .gitignore
View
@@ -12,3 +12,4 @@ logs
results
npm-debug.log
+/node_modules
3  .gitmodules
View
@@ -0,0 +1,3 @@
+[submodule "lib/jquery.complexify.js"]
+ path = lib/jquery.complexify.js
+ url = git://github.com/danpalmer/jquery.complexify.js.git
2  README.md
View
@@ -1,4 +1,4 @@
node-complexify
===============
-node.js wrapper for jquery.complexify.js
+node.js wrapper for [jquery.complexify.js](https://github.com/danpalmer/jquery.complexify.js/)
37 complexify
View
@@ -0,0 +1,37 @@
+#!/usr/bin/env node
+
+var fs = require('fs');
+var jsdom = require('jsdom').jsdom;
+
+function evalPasswordComplexity(password, callback) {
+ jsdom.env({'html': '<input id="password" value="' + password + '" />',
+ 'scripts': [__dirname + '/lib/jquery.js',
+ __dirname + '/lib/jquery.complexify.js/jquery.complexify.js'],
+ 'done': function(errors, window) {
+ var $ = window.$;
+ var options = {
+ // minimumChars: 8,
+ // strengthScaleFactor: 1,
+ };
+
+ $("#password").complexify(options, function(valid, complexity) {
+ callback(null, {"complexity": complexity, "valid": valid});
+ });
+
+ $('#password').trigger('keyup');
+ }});
+}
+
+if (process.argv[2] == undefined) {
+ console.error("Evaluate password complexity using jquery.complexify.js.");
+ console.error("Exit with an error if complexity is below the threshold.");
+ console.error("Usage: " + __filename + " password");
+ process.exit(1);
+}
+
+evalPasswordComplexity(process.argv[2], function(err, result) {
+ console.log(JSON.stringify(result));
+ if (!result.valid) {
+ process.exit(2);
+ }
+});
9,472 lib/jquery-1.8.3.js
View
9,472 additions, 0 deletions not shown
1  lib/jquery.complexify.js
@@ -0,0 +1 @@
+Subproject commit 0077ec10440486581c0b3833a35fbba7db151493
1  lib/jquery.js
View
8 package.json
View
@@ -0,0 +1,8 @@
+{
+ "name": "node-complexify",
+ "version": "0.0.1",
+ "description": "node.js wrapper for jquery.complexify.js",
+ "dependencies": {
+ "jsdom": "0.3.1"
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.