@@ -1,6 +1,6 @@ | |||
import crypto from 'crypto'; | |||
module.exports = { | |||
export default { | |||
encryptLogin: _encryptLogin, | |||
renderPassword: _renderPassword, | |||
_deriveEncryptedLogin, |
@@ -2,63 +2,41 @@ | |||
"name": "lesspass", | |||
"version": "4.0.0", | |||
"author": "Guillaume Vincent <guillaume@oslab.fr>", | |||
"description": "lesspass javascript module to generate idempotent passwords", | |||
"main": "lib/lesspass.js", | |||
"description": "LessPass javascript module to generate idempotent passwords", | |||
"main": "index", | |||
"repository": "lesspass/core", | |||
"homepage": "https://github.com/lesspass/core#readme", | |||
"bugs": "https://github.com/lesspass/core/issues", | |||
"scripts": { | |||
"test-node": "cd tests && babel-node --presets es2015 node.js && cd ..", | |||
"test": "ava --require babel-core/register", | |||
"browserify": "browserify src/lesspass.js --standalone lesspass | uglifyjs > dist/lesspass.min.js", | |||
"babelify": "babel src/lesspass.js -o lib/lesspass.js", | |||
"build": "rm -rf dist lib && mkdir dist lib && npm run browserify && npm run babelify", | |||
"prepublish": "npm test && npm run build" | |||
"prepublish": "npm test" | |||
}, | |||
"files": [ | |||
"*.md", | |||
"lib" | |||
], | |||
"keywords": [ | |||
"password", | |||
"crypto", | |||
"lesspass" | |||
], | |||
"repository": { | |||
"type": "git", | |||
"url": "git+ssh://git@github.com:lesspass/core.git" | |||
}, | |||
"engines": { | |||
"node": ">=4.2.6" | |||
}, | |||
"license": "MIT", | |||
"bugs": { | |||
"url": "https://github.com/lesspass/core/issues" | |||
}, | |||
"homepage": "https://github.com/lesspass/core#readme", | |||
"devDependencies": { | |||
"ava": "^0.15.2", | |||
"babel-cli": "^6.10.1", | |||
"babel-core": "^6.10.4", | |||
"babel-preset-es2015": "^6.9.0", | |||
"babelify": "^7.3.0", | |||
"browserify": "^13.0.1", | |||
"karma": "^1.1.0", | |||
"karma-ava": "0.0.1", | |||
"karma-chrome-launcher": "^1.0.1", | |||
"karma-firefox-launcher": "^1.0.0", | |||
"uglify-js": "^2.6.4" | |||
"ava": "^0.16.0", | |||
"babel-cli": "^6.16.0", | |||
"babel-core": "^6.17.0", | |||
"babel-preset-es2015": "^6.16.0" | |||
}, | |||
"babel": { | |||
"presets": [ | |||
"es2015" | |||
] | |||
}, | |||
"browserify": { | |||
"transform": [ | |||
"babelify" | |||
] | |||
}, | |||
"ava": { | |||
"files": [ | |||
"tests/*.js", | |||
"!tests/karma.conf.js", | |||
"!tests/node.js" | |||
], | |||
"source": [ | |||
"src/*.js" | |||
] | |||
} | |||
} |
@@ -4,26 +4,22 @@ | |||
core library for LessPass password manager in javascript used to generate unique password. | |||
It works with the browser and NodeJs | |||
## Requirements | |||
- node 4.x.x | |||
- node v4.6.x | |||
## Install | |||
npm install lesspass | |||
## Usage | |||
### Node | |||
var lesspass = require('lesspass'); | |||
var login = 'contact@lesspass.com'; | |||
var masterPassword = 'password'; | |||
var site = 'lesspass.com'; | |||
var options = { | |||
import LessPass from 'lesspass'; | |||
const site = 'lesspass.com'; | |||
const login = 'contact@lesspass.com'; | |||
const masterPassword = 'password'; | |||
const options = { | |||
counter: 1, | |||
length: 12, | |||
lowercase: true, | |||
@@ -31,42 +27,11 @@ It works with the browser and NodeJs | |||
numbers: true, | |||
symbols: true | |||
}; | |||
lesspass.encryptLogin(login, masterPassword).then(function (encryptedLogin) { | |||
var generatedPassword = lesspass.renderPassword(encryptedLogin, site, options); | |||
console.log(generatedPassword); //azYS7,olOL2] | |||
}); | |||
### Browser | |||
<!doctype html> | |||
<html lang="en"> | |||
<head> | |||
<meta charset="UTF-8"> | |||
</head> | |||
<body> | |||
<script src="../dist/lesspass.min.js"></script> | |||
<script> | |||
var site = 'lesspass.com'; | |||
var login = 'contact@lesspass.com'; | |||
var masterPassword = 'password'; | |||
var options = { | |||
counter: 1, | |||
length: 12, | |||
lowercase: true, | |||
uppercase: true, | |||
numbers: true, | |||
symbols: true | |||
}; | |||
lesspass.encryptLogin(login, masterPassword).then(function (encryptedLogin) { | |||
var generatedPassword = lesspass.renderPassword(encryptedLogin, site, options); | |||
console.log(generatedPassword); //azYS7,olOL2] | |||
LessPass.encryptLogin(login, masterPassword) | |||
.then(encryptedLogin => { | |||
var generatedPassword = LessPass.renderPassword(encryptedLogin, site, options); | |||
console.log(generatedPassword); //azYS7,olOL2] | |||
}); | |||
</script> | |||
</body> | |||
</html> | |||
see [tests/api.tests.js](tests/api.tests.js) for more examples | |||
@@ -1,5 +1,5 @@ | |||
import test from 'ava'; | |||
import lesspass from '../src/lesspass'; | |||
import lesspass from '../index'; | |||
test('encrypt login with pbkdf2 8192 iterations and sha256', t => { | |||
return lesspass.encryptLogin('test@example.org', 'password').then(encryptedLogin => { | |||
@@ -1,5 +1,5 @@ | |||
import test from 'ava'; | |||
import lesspass from '../src/lesspass'; | |||
import lesspass from '../index'; | |||
test('should derive encrypted login with default length', t => { | |||
const encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88'; | |||
@@ -1,5 +1,5 @@ | |||
import test from 'ava'; | |||
import lesspass from '../src/lesspass'; | |||
import lesspass from '../index'; | |||
test('should get default template', t => { | |||
t.is('vcVCns', lesspass._getPasswordTemplate({ | |||
@@ -1,31 +0,0 @@ | |||
<!doctype html> | |||
<html lang="en"> | |||
<head> | |||
<meta charset="UTF-8"> | |||
</head> | |||
<body> | |||
<script src="../dist/lesspass.min.js"></script> | |||
<script> | |||
var site = 'lesspass.com'; | |||
var login = 'contact@lesspass.com'; | |||
var masterPassword = 'password'; | |||
var options = { | |||
counter: 1, | |||
length: 12, | |||
lowercase: true, | |||
uppercase: true, | |||
numbers: true, | |||
symbols: true | |||
}; | |||
lesspass.encryptLogin(login, masterPassword).then(function (encryptedLogin) { | |||
var generatedPassword = lesspass.renderPassword(encryptedLogin, site, options); | |||
if (generatedPassword === 'azYS7,olOL2]') { | |||
document.body.innerHTML = "generatePassword ok"; | |||
} else { | |||
document.body.innerHTML = "generatePassword not ok " + generatedPassword + ' not equals azYS7,olOL2]'; | |||
} | |||
}); | |||
</script> | |||
</body> | |||
</html> |
@@ -1,10 +1,10 @@ | |||
var lesspass = require('../lib/lesspass'); | |||
var assert = require('assert'); | |||
import lesspass from '../index'; | |||
import assert from 'assert'; | |||
var site = 'lesspass.com'; | |||
var login = 'contact@lesspass.com'; | |||
var masterPassword = 'password'; | |||
var options = { | |||
const site = 'lesspass.com'; | |||
const login = 'contact@lesspass.com'; | |||
const masterPassword = 'password'; | |||
const options = { | |||
counter: 1, | |||
length: 12, | |||
lowercase: true, | |||
@@ -12,9 +12,12 @@ var options = { | |||
numbers: true, | |||
symbols: true | |||
}; | |||
lesspass.encryptLogin(login, masterPassword).then(function (encryptedLogin) { | |||
var generatedPassword = lesspass.renderPassword(encryptedLogin, site, options); | |||
assert.equal(generatedPassword, 'azYS7,olOL2]'); | |||
}).catch(function (err) { | |||
console.log(err); | |||
}); | |||
lesspass.encryptLogin(login, masterPassword) | |||
.then(encryptedLogin => { | |||
var generatedPassword = lesspass.renderPassword(encryptedLogin, site, options); | |||
assert.equal(generatedPassword, 'azYS7,olOL2]'); | |||
console.log('test node ES6 ok'); | |||
}) | |||
.catch(err => { | |||
console.log(err); | |||
}); |
@@ -1,5 +1,5 @@ | |||
import test from 'ava'; | |||
import lesspass from '../src/lesspass'; | |||
import lesspass from '../index'; | |||
test('should print different password if templates different', t => { | |||
const encryptedLogin = '78ae5892055ab59fdd54489ae30928d322841a27590b65cf875fcfdd083f7c32'; | |||