mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
lint fixes
This commit is contained in:
parent
ec049edfdf
commit
4b5bab3c0e
50
src/bw.ts
50
src/bw.ts
@ -1,30 +1,28 @@
|
||||
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 { ConstantsService } from 'jslib/services/constants.service';
|
||||
import { PasswordGenerationService } from 'jslib/services/passwordGeneration.service';
|
||||
import { TotpService } from 'jslib/services/totp.service';
|
||||
import { NodeMessagingService } from './services/nodeMessaging.service';
|
||||
import { NodePlatformUtilsService } from './services/nodePlatformUtils.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 { 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';
|
||||
|
||||
@ -53,7 +51,6 @@ export class Main {
|
||||
auditService: AuditService;
|
||||
cryptoFunctionService: NodeCryptoFunctionService;
|
||||
authService: AuthService;
|
||||
|
||||
program: Program;
|
||||
|
||||
constructor() {
|
||||
@ -65,7 +62,8 @@ export class Main {
|
||||
this.appIdService = new AppIdService(this.storageService);
|
||||
this.tokenService = new TokenService(this.storageService);
|
||||
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.userService = new UserService(this.tokenService, this.storageService);
|
||||
this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService);
|
||||
@ -81,7 +79,7 @@ export class Main {
|
||||
() => { /* do nothing */ });
|
||||
this.syncService = new SyncService(this.userService, this.apiService, this.settingsService,
|
||||
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.totpService = new TotpService(this.storageService, this.cryptoFunctionService);
|
||||
this.authService = new AuthService(this.cryptoService, this.apiService, this.userService, this.tokenService,
|
||||
|
@ -23,7 +23,7 @@ export class EncodeCommand {
|
||||
});
|
||||
process.stdin.on('end', () => {
|
||||
const b64 = new Buffer(input, 'utf8').toString('base64');
|
||||
var res = new StringResponse(b64);
|
||||
const res = new StringResponse(b64);
|
||||
resolve(Response.success(res));
|
||||
});
|
||||
});
|
||||
|
@ -14,12 +14,12 @@ import { FolderResponse } from '../models/response/folderResponse';
|
||||
import { StringResponse } from '../models/response/stringResponse';
|
||||
import { TemplateResponse } from '../models/response/templateResponse';
|
||||
|
||||
import { CardRequest } from '../models/request/cardRequest';
|
||||
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 { 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';
|
||||
|
||||
export class GetCommand {
|
||||
@ -126,8 +126,8 @@ export class GetCommand {
|
||||
break;
|
||||
default:
|
||||
return Response.badRequest('Unknown template object.');
|
||||
|
||||
}
|
||||
|
||||
const res = new TemplateResponse(template);
|
||||
return Response.success(res);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { CardView } from 'jslib/models/view';
|
||||
|
||||
export class CardRequest {
|
||||
static template(): CardRequest {
|
||||
var req = new CardRequest();
|
||||
const req = new CardRequest();
|
||||
req.cardholderName = 'John Doe';
|
||||
req.brand = 'visa';
|
||||
req.number = '4242424242424242';
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { CipherType } from 'jslib/enums/cipherType';
|
||||
|
||||
import { CardRequest } from './cardRequest';
|
||||
import { FieldRequest } from './fieldRequest';
|
||||
import { IdentityRequest } from './identityRequest';
|
||||
import { LoginRequest } from './loginRequest';
|
||||
import { SecureNoteRequest } from './secureNoteRequest';
|
||||
import { CardRequest } from './cardRequest';
|
||||
import { IdentityRequest } from './identityRequest';
|
||||
import { FieldRequest } from './fieldRequest';
|
||||
|
||||
import { CipherView } from 'jslib/models/view/cipherView';
|
||||
|
||||
export class CipherRequest {
|
||||
static template(): CipherRequest {
|
||||
var req = new CipherRequest();
|
||||
const req = new CipherRequest();
|
||||
req.type = CipherType.Login;
|
||||
req.folderId = null;
|
||||
req.organizationId = null;
|
||||
|
@ -3,7 +3,7 @@ import { FieldView } from 'jslib/models/view';
|
||||
|
||||
export class FieldRequest {
|
||||
static template(): FieldRequest {
|
||||
var req = new FieldRequest();
|
||||
const req = new FieldRequest();
|
||||
req.name = 'Field name';
|
||||
req.value = 'Some value';
|
||||
req.type = FieldType.Text;
|
||||
|
@ -2,7 +2,7 @@ import { IdentityView } from 'jslib/models/view';
|
||||
|
||||
export class IdentityRequest {
|
||||
static template(): IdentityRequest {
|
||||
var req = new IdentityRequest();
|
||||
const req = new IdentityRequest();
|
||||
req.title = 'Mr';
|
||||
req.firstName = 'John';
|
||||
req.middleName = 'William';
|
||||
|
@ -4,7 +4,7 @@ import { LoginView } from 'jslib/models/view';
|
||||
|
||||
export class LoginRequest {
|
||||
static template(): LoginRequest {
|
||||
var req = new LoginRequest();
|
||||
const req = new LoginRequest();
|
||||
req.uris = [];
|
||||
req.username = 'jdoe';
|
||||
req.password = 'myp@ssword123';
|
||||
|
@ -3,7 +3,7 @@ import { LoginUriView } from 'jslib/models/view/loginUriView';
|
||||
|
||||
export class LoginUriRequest {
|
||||
static template(): LoginUriRequest {
|
||||
var req = new LoginUriRequest();
|
||||
const req = new LoginUriRequest();
|
||||
req.uri = 'https://google.com';
|
||||
req.match = null;
|
||||
return req;
|
||||
@ -12,7 +12,7 @@ export class LoginUriRequest {
|
||||
static toView(req: LoginUriRequest) {
|
||||
const view = new LoginUriView();
|
||||
view.uri = req.uri;
|
||||
view.match = req.match
|
||||
view.match = req.match;
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { SecureNoteView } from 'jslib/models/view/secureNoteView';
|
||||
|
||||
export class SecureNoteRequest {
|
||||
static template(): SecureNoteRequest {
|
||||
var req = new SecureNoteRequest();
|
||||
const req = new SecureNoteRequest();
|
||||
req.type = SecureNoteType.Generic;
|
||||
return req;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { BaseResponse } from './response/baseResponse';
|
||||
|
||||
export class Response {
|
||||
static error(message: string): Response {
|
||||
var res = new Response();
|
||||
const res = new Response();
|
||||
res.success = false;
|
||||
res.message = message;
|
||||
return res;
|
||||
@ -17,7 +17,7 @@ export class Response {
|
||||
}
|
||||
|
||||
static success(data?: BaseResponse): Response {
|
||||
var res = new Response();
|
||||
const res = new Response();
|
||||
res.success = true;
|
||||
res.data = data;
|
||||
return res;
|
||||
|
@ -2,25 +2,26 @@ import * as program from 'commander';
|
||||
|
||||
import { Main } from './bw';
|
||||
|
||||
import { CreateCommand } from './commands/create.command';
|
||||
import { DeleteCommand } from './commands/delete.command';
|
||||
import { EncodeCommand } from './commands/encode.command';
|
||||
import { GetCommand } from './commands/get.command';
|
||||
import { ListCommand } from './commands/list.command';
|
||||
import { LoginCommand } from './commands/login.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 { StringResponse } from './models/response/stringResponse';
|
||||
import { TemplateResponse } from './models/response/templateResponse';
|
||||
|
||||
import { Response } from './models/response';
|
||||
|
||||
export class Program {
|
||||
constructor(private main: Main) { }
|
||||
|
||||
run() {
|
||||
program
|
||||
.version('1.0.0', '-v, --version');
|
||||
.version(this.main.platformUtilsService.getApplicationVersion(), '-v, --version');
|
||||
|
||||
program
|
||||
.command('login <email> <password>')
|
||||
@ -37,8 +38,7 @@ export class Program {
|
||||
.command('logout')
|
||||
.description('Log out of the current Bitwarden user account.')
|
||||
.action((cmd) => {
|
||||
console.log('Logging out...');
|
||||
process.exit();
|
||||
// TODO
|
||||
});
|
||||
|
||||
program
|
||||
@ -84,9 +84,7 @@ export class Program {
|
||||
.command('edit <object> <id>')
|
||||
.description('Edit an object.')
|
||||
.action((object, id, cmd) => {
|
||||
console.log('Editing...');
|
||||
console.log(object);
|
||||
console.log(id);
|
||||
// TODO
|
||||
});
|
||||
|
||||
program
|
||||
@ -115,18 +113,18 @@ export class Program {
|
||||
if (response.success) {
|
||||
if (response.data != null) {
|
||||
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') {
|
||||
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') {
|
||||
console.log(JSON.stringify((response.data as TemplateResponse).template));
|
||||
process.stdout.write(JSON.stringify((response.data as TemplateResponse).template));
|
||||
} else {
|
||||
console.log(JSON.stringify(response.data));
|
||||
process.stdout.write(JSON.stringify(response.data));
|
||||
}
|
||||
}
|
||||
process.exit();
|
||||
} else {
|
||||
console.log(response.message);
|
||||
process.stdout.write(response.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
import { DeviceType } from 'jslib/enums/deviceType';
|
||||
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
@ -5,6 +6,9 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
|
||||
// tslint:disable-next-line
|
||||
const pjson = require('../../package.json');
|
||||
|
||||
export class NodePlatformUtilsService implements PlatformUtilsService {
|
||||
identityClientId: string;
|
||||
|
||||
@ -37,14 +41,37 @@ export class NodePlatformUtilsService implements PlatformUtilsService {
|
||||
return DeviceType[this.getDevice()].toLowerCase();
|
||||
}
|
||||
|
||||
isFirefox: () => false;
|
||||
isChrome: () => false;
|
||||
isEdge: () => false;
|
||||
isOpera: () => false;
|
||||
isVivaldi: () => false;
|
||||
isSafari: () => false;
|
||||
isMacAppStore: () => false;
|
||||
analyticsId: () => null;
|
||||
isFirefox() {
|
||||
return false;
|
||||
}
|
||||
|
||||
isChrome() {
|
||||
return false;
|
||||
}
|
||||
|
||||
isEdge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
isOpera() {
|
||||
return false;
|
||||
}
|
||||
|
||||
isVivaldi() {
|
||||
return false;
|
||||
}
|
||||
|
||||
isSafari() {
|
||||
return false;
|
||||
}
|
||||
|
||||
isMacAppStore() {
|
||||
return false;
|
||||
}
|
||||
|
||||
analyticsId() {
|
||||
return null as string;
|
||||
}
|
||||
|
||||
getDomain(uriString: string): string {
|
||||
return Utils.getHostname(uriString);
|
||||
@ -54,26 +81,31 @@ export class NodePlatformUtilsService implements PlatformUtilsService {
|
||||
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 {
|
||||
// TODO
|
||||
}
|
||||
|
||||
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):
|
||||
Promise<boolean> {
|
||||
console.log(title);
|
||||
console.log(text);
|
||||
process.stdout.write(title + '\n');
|
||||
process.stdout.write(text);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
isDev(): boolean {
|
||||
return false; // TODO?
|
||||
return process.env.ENV === 'development';
|
||||
}
|
||||
|
||||
copyToClipboard(text: string, options?: any): void {
|
||||
|
@ -28,7 +28,7 @@ export class NodeStorageService implements StorageService {
|
||||
if (obj != null && obj[key] != null) {
|
||||
return Promise.resolve(obj[key] as T);
|
||||
}
|
||||
} catch{ }
|
||||
} catch { }
|
||||
}
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ const plugins = [
|
||||
path.resolve(__dirname, 'build/*'),
|
||||
]),
|
||||
new CopyWebpackPlugin([
|
||||
'./package.json',
|
||||
{ from: './src/locales', to: 'locales' },
|
||||
]),
|
||||
new webpack.DefinePlugin({
|
||||
|
Loading…
Reference in New Issue
Block a user