@@ -0,0 +1,17 @@ | |||||
# editorconfig.org | |||||
root = true | |||||
[*] | |||||
charset = utf-8 | |||||
end_of_line = lf | |||||
indent_size = 2 | |||||
indent_style = space | |||||
insert_final_newline = true | |||||
trim_trailing_whitespace = true | |||||
[*.md] | |||||
trim_trailing_whitespace = false | |||||
[*.py] | |||||
indent_size = 4 |
@@ -0,0 +1,2 @@ | |||||
node_modules/ | |||||
npm-debug.log |
@@ -0,0 +1,18 @@ | |||||
dist: trusty | |||||
sudo: required | |||||
language: node_js | |||||
node_js: | |||||
- 6 | |||||
- 8 | |||||
addons: | |||||
firefox: "latest" | |||||
apt: | |||||
sources: | |||||
- google-chrome | |||||
packages: | |||||
- google-chrome-stable | |||||
before_script: | |||||
- export CHROME_BIN=/usr/bin/google-chrome | |||||
- "export DISPLAY=:99.0" | |||||
- "sh -e /etc/init.d/xvfb start" | |||||
- sleep 3 |
@@ -0,0 +1,43 @@ | |||||
# LessPass render password | |||||
LessPass node module used to render password based on options | |||||
## Requirements | |||||
- node LTS | |||||
## Install | |||||
npm install lesspass-master-password | |||||
## Usage | |||||
var LessPassMasterPassword = require("lesspass-master-password"); | |||||
console.log(LessPassMasterPassword.getFingerprint("e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e")) | |||||
// [ | |||||
{ | |||||
color: "#FFB5DA", | |||||
icon: "fa-flask" | |||||
}, | |||||
{ | |||||
color: "#009191", | |||||
icon: "fa-archiv,e" | |||||
}, | |||||
{ | |||||
color: "#B5DAFE", | |||||
icon: "fa-beer" | |||||
} | |||||
] | |||||
## Tests | |||||
npm test | |||||
## License | |||||
This project is licensed under the terms of the GNU GPLv3. | |||||
## Issues | |||||
report issues on [LessPass project](https://github.com/lesspass/lesspass/issues) |
@@ -0,0 +1,104 @@ | |||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.getLessPassFingerprint = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | |||||
function getColor(color) { | |||||
var colors = [ | |||||
"#000000", | |||||
"#074750", | |||||
"#009191", | |||||
"#FF6CB6", | |||||
"#FFB5DA", | |||||
"#490092", | |||||
"#006CDB", | |||||
"#B66DFF", | |||||
"#6DB5FE", | |||||
"#B5DAFE", | |||||
"#920000", | |||||
"#924900", | |||||
"#DB6D00", | |||||
"#24FE23" | |||||
]; | |||||
var index = parseInt(color, 16) % colors.length; | |||||
return colors[index]; | |||||
} | |||||
function getIcon(hash) { | |||||
var icons = [ | |||||
"fa-hashtag", | |||||
"fa-heart", | |||||
"fa-hotel", | |||||
"fa-university", | |||||
"fa-plug", | |||||
"fa-ambulance", | |||||
"fa-bus", | |||||
"fa-car", | |||||
"fa-plane", | |||||
"fa-rocket", | |||||
"fa-ship", | |||||
"fa-subway", | |||||
"fa-truck", | |||||
"fa-jpy", | |||||
"fa-eur", | |||||
"fa-btc", | |||||
"fa-usd", | |||||
"fa-gbp", | |||||
"fa-archive", | |||||
"fa-area-chart", | |||||
"fa-bed", | |||||
"fa-beer", | |||||
"fa-bell", | |||||
"fa-binoculars", | |||||
"fa-birthday-cake", | |||||
"fa-bomb", | |||||
"fa-briefcase", | |||||
"fa-bug", | |||||
"fa-camera", | |||||
"fa-cart-plus", | |||||
"fa-certificate", | |||||
"fa-coffee", | |||||
"fa-cloud", | |||||
"fa-coffee", | |||||
"fa-comment", | |||||
"fa-cube", | |||||
"fa-cutlery", | |||||
"fa-database", | |||||
"fa-diamond", | |||||
"fa-exclamation-circle", | |||||
"fa-eye", | |||||
"fa-flag", | |||||
"fa-flask", | |||||
"fa-futbol-o", | |||||
"fa-gamepad", | |||||
"fa-graduation-cap" | |||||
]; | |||||
var index = parseInt(hash, 16) % icons.length; | |||||
return icons[index]; | |||||
} | |||||
function getFingerprint(hmacSHA256) { | |||||
var fingerprint = []; | |||||
var hash1 = hmacSHA256.substring(0, 6); | |||||
fingerprint.push({ | |||||
color: getColor(hash1), | |||||
icon: getIcon(hash1) | |||||
}); | |||||
var hash2 = hmacSHA256.substring(6, 12); | |||||
fingerprint.push({ | |||||
color: getColor(hash2), | |||||
icon: getIcon(hash2) | |||||
}); | |||||
var hash3 = hmacSHA256.substring(12, 18); | |||||
fingerprint.push({ | |||||
color: getColor(hash3), | |||||
icon: getIcon(hash3) | |||||
}); | |||||
return fingerprint; | |||||
} | |||||
module.exports = { | |||||
getLessPassFingerprint: getFingerprint | |||||
}; | |||||
},{}]},{},[1])(1) | |||||
}); |
@@ -0,0 +1 @@ | |||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).getLessPassFingerprint=e()}}(function(){return function t(o,i,u){function c(a,e){if(!i[a]){if(!o[a]){var f="function"==typeof require&&require;if(!e&&f)return f(a,!0);if(s)return s(a,!0);var r=new Error("Cannot find module '"+a+"'");throw r.code="MODULE_NOT_FOUND",r}var n=i[a]={exports:{}};o[a][0].call(n.exports,function(e){return c(o[a][1][e]||e)},n,n.exports,t,o,i,u)}return i[a].exports}for(var s="function"==typeof require&&require,e=0;e<u.length;e++)c(u[e]);return c}({1:[function(e,a,f){function t(e){var a=["#000000","#074750","#009191","#FF6CB6","#FFB5DA","#490092","#006CDB","#B66DFF","#6DB5FE","#B5DAFE","#920000","#924900","#DB6D00","#24FE23"];return a[parseInt(e,16)%a.length]}function o(e){var a=["fa-hashtag","fa-heart","fa-hotel","fa-university","fa-plug","fa-ambulance","fa-bus","fa-car","fa-plane","fa-rocket","fa-ship","fa-subway","fa-truck","fa-jpy","fa-eur","fa-btc","fa-usd","fa-gbp","fa-archive","fa-area-chart","fa-bed","fa-beer","fa-bell","fa-binoculars","fa-birthday-cake","fa-bomb","fa-briefcase","fa-bug","fa-camera","fa-cart-plus","fa-certificate","fa-coffee","fa-cloud","fa-coffee","fa-comment","fa-cube","fa-cutlery","fa-database","fa-diamond","fa-exclamation-circle","fa-eye","fa-flag","fa-flask","fa-futbol-o","fa-gamepad","fa-graduation-cap"];return a[parseInt(e,16)%a.length]}a.exports={getLessPassFingerprint:function(e){var a=[],f=e.substring(0,6);a.push({color:t(f),icon:o(f)});var r=e.substring(6,12);a.push({color:t(r),icon:o(r)});var n=e.substring(12,18);return a.push({color:t(n),icon:o(n)}),a}}},{}]},{},[1])(1)}); |
@@ -0,0 +1,48 @@ | |||||
{ | |||||
"name": "lesspass-master-password", | |||||
"version": "0.1.0", | |||||
"description": "LessPass node module used to get fingerprint for 256 bytes string", | |||||
"keywords": [ | |||||
"crypto", | |||||
"lesspass", | |||||
"password" | |||||
], | |||||
"license": "GPL-3.0", | |||||
"author": "Guillaume Vincent <guillaume@oslab.fr>", | |||||
"files": [ | |||||
"dist", | |||||
"src" | |||||
], | |||||
"main": "src/index.js", | |||||
"module": "src/index.js", | |||||
"jsnext:main": "src/index.js", | |||||
"scripts": { | |||||
"precommit": "npm test && lint-staged", | |||||
"clean": "rm -rf dist && mkdir dist && npm prune", | |||||
"build": "npm run clean && browserify --standalone getLessPassFingerprint src/index.js > dist/lesspass-master-password.js && npm run minify", | |||||
"minify": "uglifyjs --output dist/lesspass-master-password.min.js --compress --mangle -- dist/lesspass-master-password.js", | |||||
"test": "npm run test:unit && npm run test:browser", | |||||
"test:unit": "mocha test", | |||||
"test:browser": "npm run build && karma start test/karma.conf.js" | |||||
}, | |||||
"dependencies": {}, | |||||
"devDependencies": { | |||||
"browserify": "^16.2.2", | |||||
"husky": "^0.14.3", | |||||
"karma": "^3.0.0", | |||||
"karma-browserify": "^5.3.0", | |||||
"karma-chrome-launcher": "^2.0.0", | |||||
"karma-firefox-launcher": "^1.1.0", | |||||
"karma-mocha": "^1.3.0", | |||||
"lint-staged": "^7.3.0", | |||||
"mocha": "^5.2.0", | |||||
"prettier": "^1.14.3", | |||||
"uglify-js": "^3.4.9" | |||||
}, | |||||
"lint-staged": { | |||||
"{src,test}/**/*.js": [ | |||||
"prettier --write", | |||||
"git add" | |||||
] | |||||
} | |||||
} |
@@ -0,0 +1,100 @@ | |||||
function getColor(color) { | |||||
var colors = [ | |||||
"#000000", | |||||
"#074750", | |||||
"#009191", | |||||
"#FF6CB6", | |||||
"#FFB5DA", | |||||
"#490092", | |||||
"#006CDB", | |||||
"#B66DFF", | |||||
"#6DB5FE", | |||||
"#B5DAFE", | |||||
"#920000", | |||||
"#924900", | |||||
"#DB6D00", | |||||
"#24FE23" | |||||
]; | |||||
var index = parseInt(color, 16) % colors.length; | |||||
return colors[index]; | |||||
} | |||||
function getIcon(hash) { | |||||
var icons = [ | |||||
"fa-hashtag", | |||||
"fa-heart", | |||||
"fa-hotel", | |||||
"fa-university", | |||||
"fa-plug", | |||||
"fa-ambulance", | |||||
"fa-bus", | |||||
"fa-car", | |||||
"fa-plane", | |||||
"fa-rocket", | |||||
"fa-ship", | |||||
"fa-subway", | |||||
"fa-truck", | |||||
"fa-jpy", | |||||
"fa-eur", | |||||
"fa-btc", | |||||
"fa-usd", | |||||
"fa-gbp", | |||||
"fa-archive", | |||||
"fa-area-chart", | |||||
"fa-bed", | |||||
"fa-beer", | |||||
"fa-bell", | |||||
"fa-binoculars", | |||||
"fa-birthday-cake", | |||||
"fa-bomb", | |||||
"fa-briefcase", | |||||
"fa-bug", | |||||
"fa-camera", | |||||
"fa-cart-plus", | |||||
"fa-certificate", | |||||
"fa-coffee", | |||||
"fa-cloud", | |||||
"fa-coffee", | |||||
"fa-comment", | |||||
"fa-cube", | |||||
"fa-cutlery", | |||||
"fa-database", | |||||
"fa-diamond", | |||||
"fa-exclamation-circle", | |||||
"fa-eye", | |||||
"fa-flag", | |||||
"fa-flask", | |||||
"fa-futbol-o", | |||||
"fa-gamepad", | |||||
"fa-graduation-cap" | |||||
]; | |||||
var index = parseInt(hash, 16) % icons.length; | |||||
return icons[index]; | |||||
} | |||||
function getFingerprint(hmacSHA256) { | |||||
var fingerprint = []; | |||||
var hash1 = hmacSHA256.substring(0, 6); | |||||
fingerprint.push({ | |||||
color: getColor(hash1), | |||||
icon: getIcon(hash1) | |||||
}); | |||||
var hash2 = hmacSHA256.substring(6, 12); | |||||
fingerprint.push({ | |||||
color: getColor(hash2), | |||||
icon: getIcon(hash2) | |||||
}); | |||||
var hash3 = hmacSHA256.substring(12, 18); | |||||
fingerprint.push({ | |||||
color: getColor(hash3), | |||||
icon: getIcon(hash3) | |||||
}); | |||||
return fingerprint; | |||||
} | |||||
module.exports = { | |||||
getLessPassFingerprint: getFingerprint | |||||
}; |
@@ -0,0 +1,33 @@ | |||||
var assert = require("assert"); | |||||
var masterPassword = require("../src/index"); | |||||
describe("api", function() { | |||||
it("should return array of 3 elements", function() { | |||||
assert.equal( | |||||
3, | |||||
masterPassword.getLessPassFingerprint( | |||||
"e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e" | |||||
).length | |||||
); | |||||
}); | |||||
it("should always return the same array based on the string passed as parameter", function() { | |||||
var expected_fingerprint = [ | |||||
{ | |||||
color: "#FFB5DA", | |||||
icon: "fa-flask" | |||||
}, | |||||
{ | |||||
color: "#009191", | |||||
icon: "fa-archive" | |||||
}, | |||||
{ | |||||
color: "#B5DAFE", | |||||
icon: "fa-beer" | |||||
} | |||||
]; | |||||
var fingerprint = masterPassword.getLessPassFingerprint( | |||||
"e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e" | |||||
); | |||||
assert.deepEqual(expected_fingerprint, fingerprint); | |||||
}); | |||||
}); |
@@ -0,0 +1,19 @@ | |||||
module.exports = function(config) { | |||||
config.set({ | |||||
basePath: "..", | |||||
frameworks: ["browserify", "mocha"], | |||||
files: ["dist/lesspass-master-password.min.js", "test/**/*.js"], | |||||
exclude: [], | |||||
preprocessors: { | |||||
"test/**/*.js": ["browserify"] | |||||
}, | |||||
reporters: ["progress"], | |||||
port: 9876, | |||||
colors: true, | |||||
logLevel: config.LOG_INFO, | |||||
autoWatch: false, | |||||
browsers: ["Firefox", "Chrome"], | |||||
singleRun: true, | |||||
concurrency: Infinity | |||||
}); | |||||
}; |
@@ -0,0 +1,3 @@ | |||||
* remove all report issues in all sub README.md | |||||
* remove "repository": "lesspass/..." in all package.json | |||||
* update all node modules `npx npm-check -u` |