1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

lint fixes

This commit is contained in:
Kyle Spearrin 2018-05-14 23:40:11 -04:00
parent ec049edfdf
commit 4b5bab3c0e
15 changed files with 101 additions and 74 deletions

View File

@ -1,30 +1,28 @@
import { AuthService } from 'jslib/services/auth.service'; import { AuthService } from 'jslib/services/auth.service';
import { LoginCommand } from './commands/login.command';
import { CryptoService } from 'jslib/services/crypto.service';
import { NodeCryptoFunctionService } from 'jslib/services/nodeCryptoFunction.service';
import { NodeStorageService } from './services/nodeStorage.service';
import { ApiService } from 'jslib/services/api.service';
import { NodePlatformUtilsService } from './services/nodePlatformUtils.service';
import { AppIdService } from 'jslib/services/appId.service';
import { TokenService } from 'jslib/services/token.service';
import { EnvironmentService } from 'jslib/services/environment.service';
import { UserService } from 'jslib/services/user.service';
import { ContainerService } from 'jslib/services/container.service';
import { NodeMessagingService } from './services/nodeMessaging.service';
import { SyncCommand } from './commands/sync.command';
import { SyncService } from 'jslib/services/sync.service';
import { SettingsService } from 'jslib/services/settings.service';
import { CipherService } from 'jslib/services/cipher.service';
import { FolderService } from 'jslib/services/folder.service';
import { CollectionService } from 'jslib/services/collection.service';
import { LockService } from 'jslib/services/lock.service';
import { I18nService } from './services/i18n.service'; import { I18nService } from './services/i18n.service';
import { ConstantsService } from 'jslib/services/constants.service'; import { NodeMessagingService } from './services/nodeMessaging.service';
import { PasswordGenerationService } from 'jslib/services/passwordGeneration.service'; import { NodePlatformUtilsService } from './services/nodePlatformUtils.service';
import { TotpService } from 'jslib/services/totp.service'; import { NodeStorageService } from './services/nodeStorage.service';
import { ApiService } from 'jslib/services/api.service';
import { AppIdService } from 'jslib/services/appId.service';
import { AuditService } from 'jslib/services/audit.service'; import { AuditService } from 'jslib/services/audit.service';
import { CipherService } from 'jslib/services/cipher.service';
import { CollectionService } from 'jslib/services/collection.service';
import { ConstantsService } from 'jslib/services/constants.service';
import { ContainerService } from 'jslib/services/container.service';
import { CryptoService } from 'jslib/services/crypto.service';
import { EnvironmentService } from 'jslib/services/environment.service';
import { FolderService } from 'jslib/services/folder.service';
import { LockService } from 'jslib/services/lock.service';
import { NodeCryptoFunctionService } from 'jslib/services/nodeCryptoFunction.service';
import { PasswordGenerationService } from 'jslib/services/passwordGeneration.service';
import { SettingsService } from 'jslib/services/settings.service';
import { SyncService } from 'jslib/services/sync.service';
import { TokenService } from 'jslib/services/token.service';
import { TotpService } from 'jslib/services/totp.service';
import { UserService } from 'jslib/services/user.service';
import { Program } from './program'; import { Program } from './program';
@ -53,7 +51,6 @@ export class Main {
auditService: AuditService; auditService: AuditService;
cryptoFunctionService: NodeCryptoFunctionService; cryptoFunctionService: NodeCryptoFunctionService;
authService: AuthService; authService: AuthService;
program: Program; program: Program;
constructor() { constructor() {
@ -65,7 +62,8 @@ export class Main {
this.appIdService = new AppIdService(this.storageService); this.appIdService = new AppIdService(this.storageService);
this.tokenService = new TokenService(this.storageService); this.tokenService = new TokenService(this.storageService);
this.messagingService = new NodeMessagingService(); this.messagingService = new NodeMessagingService();
this.apiService = new ApiService(this.tokenService, this.platformUtilsService, (expired: boolean) => { }); this.apiService = new ApiService(this.tokenService, this.platformUtilsService,
(expired: boolean) => { /* do nothing */ });
this.environmentService = new EnvironmentService(this.apiService, this.storageService); this.environmentService = new EnvironmentService(this.apiService, this.storageService);
this.userService = new UserService(this.tokenService, this.storageService); this.userService = new UserService(this.tokenService, this.storageService);
this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService); this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService);
@ -81,7 +79,7 @@ export class Main {
() => { /* do nothing */ }); () => { /* do nothing */ });
this.syncService = new SyncService(this.userService, this.apiService, this.settingsService, this.syncService = new SyncService(this.userService, this.apiService, this.settingsService,
this.folderService, this.cipherService, this.cryptoService, this.collectionService, this.folderService, this.cipherService, this.cryptoService, this.collectionService,
this.storageService, this.messagingService, (expired: boolean) => { }); this.storageService, this.messagingService, (expired: boolean) => { /* do nothing */ });
this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService); this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService);
this.totpService = new TotpService(this.storageService, this.cryptoFunctionService); this.totpService = new TotpService(this.storageService, this.cryptoFunctionService);
this.authService = new AuthService(this.cryptoService, this.apiService, this.userService, this.tokenService, this.authService = new AuthService(this.cryptoService, this.apiService, this.userService, this.tokenService,

View File

@ -23,7 +23,7 @@ export class EncodeCommand {
}); });
process.stdin.on('end', () => { process.stdin.on('end', () => {
const b64 = new Buffer(input, 'utf8').toString('base64'); const b64 = new Buffer(input, 'utf8').toString('base64');
var res = new StringResponse(b64); const res = new StringResponse(b64);
resolve(Response.success(res)); resolve(Response.success(res));
}); });
}); });

View File

@ -14,12 +14,12 @@ import { FolderResponse } from '../models/response/folderResponse';
import { StringResponse } from '../models/response/stringResponse'; import { StringResponse } from '../models/response/stringResponse';
import { TemplateResponse } from '../models/response/templateResponse'; import { TemplateResponse } from '../models/response/templateResponse';
import { CardRequest } from '../models/request/cardRequest';
import { CipherRequest } from '../models/request/cipherRequest'; import { CipherRequest } from '../models/request/cipherRequest';
import { FieldRequest } from '../models/request/fieldRequest';
import { IdentityRequest } from '../models/request/identityRequest';
import { LoginRequest } from '../models/request/loginRequest'; import { LoginRequest } from '../models/request/loginRequest';
import { LoginUriRequest } from '../models/request/loginUriRequest'; import { LoginUriRequest } from '../models/request/loginUriRequest';
import { FieldRequest } from '../models/request/fieldRequest';
import { CardRequest } from '../models/request/cardRequest';
import { IdentityRequest } from '../models/request/identityRequest';
import { SecureNoteRequest } from '../models/request/secureNoteRequest'; import { SecureNoteRequest } from '../models/request/secureNoteRequest';
export class GetCommand { export class GetCommand {
@ -126,8 +126,8 @@ export class GetCommand {
break; break;
default: default:
return Response.badRequest('Unknown template object.'); return Response.badRequest('Unknown template object.');
} }
const res = new TemplateResponse(template); const res = new TemplateResponse(template);
return Response.success(res); return Response.success(res);
} }

View File

@ -2,7 +2,7 @@ import { CardView } from 'jslib/models/view';
export class CardRequest { export class CardRequest {
static template(): CardRequest { static template(): CardRequest {
var req = new CardRequest(); const req = new CardRequest();
req.cardholderName = 'John Doe'; req.cardholderName = 'John Doe';
req.brand = 'visa'; req.brand = 'visa';
req.number = '4242424242424242'; req.number = '4242424242424242';

View File

@ -1,16 +1,16 @@
import { CipherType } from 'jslib/enums/cipherType'; import { CipherType } from 'jslib/enums/cipherType';
import { CardRequest } from './cardRequest';
import { FieldRequest } from './fieldRequest';
import { IdentityRequest } from './identityRequest';
import { LoginRequest } from './loginRequest'; import { LoginRequest } from './loginRequest';
import { SecureNoteRequest } from './secureNoteRequest'; import { SecureNoteRequest } from './secureNoteRequest';
import { CardRequest } from './cardRequest';
import { IdentityRequest } from './identityRequest';
import { FieldRequest } from './fieldRequest';
import { CipherView } from 'jslib/models/view/cipherView'; import { CipherView } from 'jslib/models/view/cipherView';
export class CipherRequest { export class CipherRequest {
static template(): CipherRequest { static template(): CipherRequest {
var req = new CipherRequest(); const req = new CipherRequest();
req.type = CipherType.Login; req.type = CipherType.Login;
req.folderId = null; req.folderId = null;
req.organizationId = null; req.organizationId = null;

View File

@ -3,7 +3,7 @@ import { FieldView } from 'jslib/models/view';
export class FieldRequest { export class FieldRequest {
static template(): FieldRequest { static template(): FieldRequest {
var req = new FieldRequest(); const req = new FieldRequest();
req.name = 'Field name'; req.name = 'Field name';
req.value = 'Some value'; req.value = 'Some value';
req.type = FieldType.Text; req.type = FieldType.Text;

View File

@ -2,7 +2,7 @@ import { IdentityView } from 'jslib/models/view';
export class IdentityRequest { export class IdentityRequest {
static template(): IdentityRequest { static template(): IdentityRequest {
var req = new IdentityRequest(); const req = new IdentityRequest();
req.title = 'Mr'; req.title = 'Mr';
req.firstName = 'John'; req.firstName = 'John';
req.middleName = 'William'; req.middleName = 'William';

View File

@ -4,7 +4,7 @@ import { LoginView } from 'jslib/models/view';
export class LoginRequest { export class LoginRequest {
static template(): LoginRequest { static template(): LoginRequest {
var req = new LoginRequest(); const req = new LoginRequest();
req.uris = []; req.uris = [];
req.username = 'jdoe'; req.username = 'jdoe';
req.password = 'myp@ssword123'; req.password = 'myp@ssword123';

View File

@ -3,7 +3,7 @@ import { LoginUriView } from 'jslib/models/view/loginUriView';
export class LoginUriRequest { export class LoginUriRequest {
static template(): LoginUriRequest { static template(): LoginUriRequest {
var req = new LoginUriRequest(); const req = new LoginUriRequest();
req.uri = 'https://google.com'; req.uri = 'https://google.com';
req.match = null; req.match = null;
return req; return req;
@ -12,7 +12,7 @@ export class LoginUriRequest {
static toView(req: LoginUriRequest) { static toView(req: LoginUriRequest) {
const view = new LoginUriView(); const view = new LoginUriView();
view.uri = req.uri; view.uri = req.uri;
view.match = req.match view.match = req.match;
return view; return view;
} }

View File

@ -3,7 +3,7 @@ import { SecureNoteView } from 'jslib/models/view/secureNoteView';
export class SecureNoteRequest { export class SecureNoteRequest {
static template(): SecureNoteRequest { static template(): SecureNoteRequest {
var req = new SecureNoteRequest(); const req = new SecureNoteRequest();
req.type = SecureNoteType.Generic; req.type = SecureNoteType.Generic;
return req; return req;
} }

View File

@ -2,7 +2,7 @@ import { BaseResponse } from './response/baseResponse';
export class Response { export class Response {
static error(message: string): Response { static error(message: string): Response {
var res = new Response(); const res = new Response();
res.success = false; res.success = false;
res.message = message; res.message = message;
return res; return res;
@ -17,7 +17,7 @@ export class Response {
} }
static success(data?: BaseResponse): Response { static success(data?: BaseResponse): Response {
var res = new Response(); const res = new Response();
res.success = true; res.success = true;
res.data = data; res.data = data;
return res; return res;

View File

@ -2,25 +2,26 @@ import * as program from 'commander';
import { Main } from './bw'; import { Main } from './bw';
import { CreateCommand } from './commands/create.command';
import { DeleteCommand } from './commands/delete.command'; import { DeleteCommand } from './commands/delete.command';
import { EncodeCommand } from './commands/encode.command';
import { GetCommand } from './commands/get.command'; import { GetCommand } from './commands/get.command';
import { ListCommand } from './commands/list.command'; import { ListCommand } from './commands/list.command';
import { LoginCommand } from './commands/login.command'; import { LoginCommand } from './commands/login.command';
import { SyncCommand } from './commands/sync.command'; import { SyncCommand } from './commands/sync.command';
import { Response } from './models/response';
import { CreateCommand } from './commands/create.command';
import { EncodeCommand } from './commands/encode.command';
import { ListResponse } from './models/response/listResponse'; import { ListResponse } from './models/response/listResponse';
import { StringResponse } from './models/response/stringResponse'; import { StringResponse } from './models/response/stringResponse';
import { TemplateResponse } from './models/response/templateResponse'; import { TemplateResponse } from './models/response/templateResponse';
import { Response } from './models/response';
export class Program { export class Program {
constructor(private main: Main) { } constructor(private main: Main) { }
run() { run() {
program program
.version('1.0.0', '-v, --version'); .version(this.main.platformUtilsService.getApplicationVersion(), '-v, --version');
program program
.command('login <email> <password>') .command('login <email> <password>')
@ -37,8 +38,7 @@ export class Program {
.command('logout') .command('logout')
.description('Log out of the current Bitwarden user account.') .description('Log out of the current Bitwarden user account.')
.action((cmd) => { .action((cmd) => {
console.log('Logging out...'); // TODO
process.exit();
}); });
program program
@ -84,9 +84,7 @@ export class Program {
.command('edit <object> <id>') .command('edit <object> <id>')
.description('Edit an object.') .description('Edit an object.')
.action((object, id, cmd) => { .action((object, id, cmd) => {
console.log('Editing...'); // TODO
console.log(object);
console.log(id);
}); });
program program
@ -115,18 +113,18 @@ export class Program {
if (response.success) { if (response.success) {
if (response.data != null) { if (response.data != null) {
if (response.data.object === 'string') { if (response.data.object === 'string') {
console.log((response.data as StringResponse).data); process.stdout.write((response.data as StringResponse).data);
} else if (response.data.object === 'list') { } else if (response.data.object === 'list') {
console.log(JSON.stringify((response.data as ListResponse).data)); process.stdout.write(JSON.stringify((response.data as ListResponse).data));
} else if (response.data.object === 'template') { } else if (response.data.object === 'template') {
console.log(JSON.stringify((response.data as TemplateResponse).template)); process.stdout.write(JSON.stringify((response.data as TemplateResponse).template));
} else { } else {
console.log(JSON.stringify(response.data)); process.stdout.write(JSON.stringify(response.data));
} }
} }
process.exit(); process.exit();
} else { } else {
console.log(response.message); process.stdout.write(response.message);
process.exit(1); process.exit(1);
} }
} }

View File

@ -1,3 +1,4 @@
import { DeviceType } from 'jslib/enums/deviceType'; import { DeviceType } from 'jslib/enums/deviceType';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
@ -5,6 +6,9 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { Utils } from 'jslib/misc/utils'; import { Utils } from 'jslib/misc/utils';
// tslint:disable-next-line
const pjson = require('../../package.json');
export class NodePlatformUtilsService implements PlatformUtilsService { export class NodePlatformUtilsService implements PlatformUtilsService {
identityClientId: string; identityClientId: string;
@ -37,14 +41,37 @@ export class NodePlatformUtilsService implements PlatformUtilsService {
return DeviceType[this.getDevice()].toLowerCase(); return DeviceType[this.getDevice()].toLowerCase();
} }
isFirefox: () => false; isFirefox() {
isChrome: () => false; return false;
isEdge: () => false; }
isOpera: () => false;
isVivaldi: () => false; isChrome() {
isSafari: () => false; return false;
isMacAppStore: () => false; }
analyticsId: () => null;
isEdge() {
return false;
}
isOpera() {
return false;
}
isVivaldi() {
return false;
}
isSafari() {
return false;
}
isMacAppStore() {
return false;
}
analyticsId() {
return null as string;
}
getDomain(uriString: string): string { getDomain(uriString: string): string {
return Utils.getHostname(uriString); return Utils.getHostname(uriString);
@ -54,26 +81,31 @@ export class NodePlatformUtilsService implements PlatformUtilsService {
return false; return false;
} }
launchUri(uri: string, options?: any): void { } launchUri(uri: string, options?: any): void {
// TODO
}
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void { saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
// TODO
} }
getApplicationVersion(): string { getApplicationVersion(): string {
return '1.0.0'; // TODO return pjson.version;
} }
supportsU2f: (win: Window) => false; supportsU2f(win: Window) {
return false;
}
showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string): showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string):
Promise<boolean> { Promise<boolean> {
console.log(title); process.stdout.write(title + '\n');
console.log(text); process.stdout.write(text);
return Promise.resolve(true); return Promise.resolve(true);
} }
isDev(): boolean { isDev(): boolean {
return false; // TODO? return process.env.ENV === 'development';
} }
copyToClipboard(text: string, options?: any): void { copyToClipboard(text: string, options?: any): void {

View File

@ -28,7 +28,7 @@ export class NodeStorageService implements StorageService {
if (obj != null && obj[key] != null) { if (obj != null && obj[key] != null) {
return Promise.resolve(obj[key] as T); return Promise.resolve(obj[key] as T);
} }
} catch{ } } catch { }
} }
return Promise.resolve(null); return Promise.resolve(null);
} }

View File

@ -33,7 +33,6 @@ const plugins = [
path.resolve(__dirname, 'build/*'), path.resolve(__dirname, 'build/*'),
]), ]),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
'./package.json',
{ from: './src/locales', to: 'locales' }, { from: './src/locales', to: 'locales' },
]), ]),
new webpack.DefinePlugin({ new webpack.DefinePlugin({