commit 7d4966c19386b4f4e50440cb4d51ac22d5f93a1d Author: Guillaume Vincent Date: Thu Oct 20 14:31:34 2016 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d4619bb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - '6' + - '5' + - '4' diff --git a/ISSUE_TEMPLATE b/ISSUE_TEMPLATE new file mode 100644 index 0000000..f6acdd8 --- /dev/null +++ b/ISSUE_TEMPLATE @@ -0,0 +1,11 @@ + + +**Thank you for taking your time to fill out an issue.** + +To make it easier to manage, can you put this issue in LessPass super project ? + +https://github.com/lesspass/lesspass/issues + +:heart: + +Thanks \ No newline at end of file diff --git a/cli.js b/cli.js new file mode 100755 index 0000000..dc4ed18 --- /dev/null +++ b/cli.js @@ -0,0 +1,52 @@ +#!/usr/bin/env node +'use strict'; +var meow = require('meow'); +var lesspass = require('lesspass'); + +var cli = meow(` + Usage + $ lesspass + + Options + --lowercase, -l true or false (default true) + --uppercase, -u true or false (default true) + --symbols, -s true or false (default true) + --numbers, -n true or false (default true) + --length, -L int (default 12) + --counter, -c int (default 1) + + Examples + $ lesspass lesspass.com contact@lesspass.com 'my Master Password' --length=14 -s=false + onAV7eqIM1arOZ +`, { + alias: { + l: 'lowercase', + u: 'uppercase', + s: 'symbols', + n: 'numbers', + L: 'length', + c: 'counter', + } +}); + + +var lowercase = (cli.flags.lowercase || 'true').toLowerCase() === 'true'; +var uppercase = (cli.flags.uppercase || 'true').toLowerCase() === 'true'; +var symbols = (cli.flags.symbols || 'true').toLowerCase() === 'true'; +var numbers = (cli.flags.numbers || 'true').toLowerCase() === 'true'; +var site = cli.input[0]; +var login = cli.input[1]; +var masterPassword = cli.input[2]; +var options = { + counter: cli.flags.counter || 1, + length: cli.flags.length || 12, + lowercase: lowercase, + uppercase: uppercase, + numbers: numbers, + symbols: symbols +}; + +lesspass.encryptLogin(login, masterPassword).then(function (encryptedLogin) { + var generatedPassword = lesspass.renderPassword(encryptedLogin, site, options); + console.log(generatedPassword); +}); diff --git a/license b/license new file mode 100644 index 0000000..6a8501b --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Guillaume Vincent (guillaumevincent.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/package.json b/package.json new file mode 100644 index 0000000..b48a84a --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "lesspass-cli", + "version": "0.0.0", + "description": "build LessPass passwords directly in command line", + "license": "MIT", + "repository": "lesspass/cli", + "author": "Guillaume Vincent ", + "bin": { + "lesspass": "cli.js" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "ava" + }, + "files": [ + "cli.js" + ], + "keywords": [ + "cli-app", + "cli", + "password", + "lesspass" + ], + "dependencies": { + "lesspass": "^4.0.4", + "meow": "^3.3.0" + }, + "devDependencies": { + "ava": "^0.16.0", + "execa": "^0.5.0" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..79b709c --- /dev/null +++ b/readme.md @@ -0,0 +1,49 @@ + + +> build LessPass passwords directly in command line with nodejs + + +## Install + +``` +$ npm install --global lesspass-cli +``` + + +## Usage + +``` +$ lesspass --help + + build LessPass passwords directly in command line + + Usage + $ lesspass + + Options + --lowercase, -l true or false (default true) + --uppercase, -u true or false (default true) + --symbols, -s true or false (default true) + --numbers, -n true or false (default true) + --length, -L int (default 12) + --counter, -c int (default 1) + + Examples + $ lesspass lesspass.com contact@lesspass.com 'my Master Password' --length=14 -s=false + onAV7eqIM1arOZ +``` + + +## FAQ + +How can I generate a password if I have a quote (`'`) in my master password ? + +Escape the quote like this : + + lesspass lesspass.com contact@lesspass.com 'my parents'\'' house is great' + +Replace `'` by `'\''` + +## License + +MIT © [Guillaume Vincent](http://guillaumevincent.com) diff --git a/test.js b/test.js new file mode 100644 index 0000000..f448ab7 --- /dev/null +++ b/test.js @@ -0,0 +1,81 @@ +import test from 'ava'; +import execa from 'execa'; + +test('default options', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password']); + t.is(stdout, 'azYS7,olOL2]'); +}); + +test('length', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--length=14']); + t.is(stdout, 'azYS7,olOL2]iz'); +}); + +test('length shortcut', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '-L=14']); + t.is(stdout, 'azYS7,olOL2]iz'); +}); + +test('counter', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--counter=2']); + t.is(stdout, 'obYT2=olOV9='); +}); + +test('counter shortcut', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '-c=2']); + t.is(stdout, 'obYT2=olOV9='); +}); + +test('no lowercase', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--lowercase=false']); + t.is(stdout, 'AZ3[EQ7@OL2]'); +}); + +test('no lowercase shortcut', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '-l=false']); + t.is(stdout, 'AZ3[EQ7@OL2]'); +}); + +test('boolean option case insensitive', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--lowercase=FalSe']); + t.is(stdout, 'AZ3[EQ7@OL2]'); +}); + +test('boolean option case insensitive', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--lowercase=TrUe']); + t.is(stdout, 'azYS7,olOL2]'); +}); + +test('no uppercase', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--uppercase=false']); + t.is(stdout, 'az3[eq7@ol2]'); +}); + +test('no uppercase shortcut', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '-u=false']); + t.is(stdout, 'az3[eq7@ol2]'); +}); + +test('no numbers', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--numbers=false']); + t.is(stdout, 'azYS&uwAW@at'); +}); + +test('no numbers shortcut', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '-n=false']); + t.is(stdout, 'azYS&uwAW@at'); +}); +test('no symbols', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '--symbols=false']); + t.is(stdout, 'azYS7uwAW8at'); +}); + +test('no symbols shortcut', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'password', '-s=false']); + t.is(stdout, 'azYS7uwAW8at'); +}); + +test('test space in password', async t => { + const {stdout} = await execa('./cli.js', ['lesspass.com', 'contact@lesspass.com', 'my Master Password']); + t.is(stdout, 'onAV7&uvEC2='); +}); \ No newline at end of file