diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..332f3a5d3f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Set default charset +[*.{js,ts,scss,html}] +charset = utf-8 +indent_style = space +indent_size = 4 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..a67268c429 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "protocol": "inspector", + "cwd": "${workspaceRoot}", + "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", + "args": [ + "${workspaceFolder}/src/main.ts", + "login", + "kyle@sdfdf.com", + "mypassword" + ] + } + ] +} diff --git a/src/commands/login.command.ts b/src/commands/login.command.ts new file mode 100644 index 0000000000..ba894767f8 --- /dev/null +++ b/src/commands/login.command.ts @@ -0,0 +1,15 @@ +import * as program from 'commander'; + +import { AuthResult } from 'jslib/models/domain/authResult'; + +import { AuthService } from 'jslib/abstractions/auth.service'; + +export class LoginCommand { + constructor(private authService: AuthService) { + + } + + run(email: string, password: string, cmd: program.Command) { + + } +} diff --git a/src/main.ts b/src/main.ts index 88453aa360..fed6b82df4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,17 +1,20 @@ import * as program from 'commander'; +import { AuthService } from 'jslib/services/auth.service'; + +import { LoginCommand } from './commands/login.command'; + program .version('1.0.0', '-v, --version'); program .command('login ') .description('Log into a Bitwarden user account.') - .option('-t, --two_factor ', '2FA code.') - .action((email, password, cmd) => { - console.log('Logging in...'); - console.log(email); - console.log(password); - console.log(cmd.two_factor); + .option('-m, --method ', '2FA method.') + .option('-c, --code ', '2FA code.') + .action((email: string, password: string, cmd: program.Command) => { + const command = new LoginCommand(null); + command.run(email, password, cmd); }); program diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..87f1d6bdd5 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "noImplicitAny": true, + "allowJs": true, + "sourceMap": true, + "baseUrl": ".", + "paths": { + "jslib/*": [ + "jslib/src/*" + ] + } + }, + "exclude": [ + "node_modules", + "jslib/node_modules", + "dist", + "jslib/dist", + "jslib/spec", + "jslib/src/electron", + "jslib/src/angular/components/modal.component.ts", + "jslib/src/angular/dummy.module.ts", + "build" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000000..b6d5571669 --- /dev/null +++ b/tslint.json @@ -0,0 +1,53 @@ +{ + "extends": "tslint:recommended", + "rules": { + "align": [ true, "statements", "members" ], + "ban-types": { + "options": [ + [ "Object", "Avoid using the `Object` type. Did you mean `object`?" ], + [ "Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?" ], + [ "Number", "Avoid using the `Number` type. Did you mean `number`?" ], + [ "String", "Avoid using the `String` type. Did you mean `string`?" ], + [ "Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?" ] + ] + }, + "member-access": [ true, "no-public" ], + "member-ordering": [ + true, + { + "order": [ + "public-static-field", + "public-static-method", + "protected-static-field", + "protected-static-method", + "private-static-field", + "private-static-method", + "public-instance-field", + "protected-instance-field", + "private-instance-field", + "public-constructor", + "protected-constructor", + "private-constructor", + "public-instance-method", + "protected-instance-method", + "private-instance-method" + ] + } + ], + "no-empty": [ true, "allow-empty-catch" ], + "object-literal-sort-keys": false, + "object-literal-shorthand": [ true, "never" ], + "prefer-for-of": false, + "quotemark": [ true, "single" ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-module", + "check-operator", + "check-preblock", + "check-separator", + "check-type" + ] + } +}