Fix glob processing in npm. Ban single param parens (#257)

This commit is contained in:
Matt Gibson 2021-02-04 09:49:23 -06:00 committed by GitHub
parent a16d8f7de7
commit 58f40b0085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
98 changed files with 275 additions and 271 deletions

View File

@ -16,8 +16,8 @@
"clean": "rimraf dist/**/*", "clean": "rimraf dist/**/*",
"build": "npm run clean && tsc", "build": "npm run clean && tsc",
"build:watch": "npm run clean && tsc -watch", "build:watch": "npm run clean && tsc -watch",
"lint": "tslint src/**/*.ts spec/**/*.ts", "lint": "tslint 'src/**/*.ts' 'spec/**/*.ts'",
"lint:fix": "tslint src/**/*.ts spec/**/*.ts --fix", "lint:fix": "tslint 'src/**/*.ts' 'spec/**/*.ts' --fix",
"test": "karma start ./spec/support/karma.conf.js --single-run", "test": "karma start ./spec/support/karma.conf.js --single-run",
"test:watch": "karma start ./spec/support/karma.conf.js", "test:watch": "karma start ./spec/support/karma.conf.js",
"test:node": "npm run build && jasmine", "test:node": "npm run build && jasmine",

View File

@ -160,7 +160,7 @@ Notes:",nomonth,,0`,
]; ];
describe('Lastpass CSV Importer', () => { describe('Lastpass CSV Importer', () => {
CipherData.forEach((data) => { CipherData.forEach(data => {
it(data.title, async () => { it(data.title, async () => {
const importer = new Importer(); const importer = new Importer();
const result = await importer.parse(data.csv); const result = await importer.parse(data.csv);

View File

@ -84,12 +84,12 @@ describe('sequentialize decorator', () => {
const allRes: number[] = []; const allRes: number[] = [];
await Promise.all([ await Promise.all([
foo.bar(1).then((res) => allRes.push(res)), foo.bar(1).then(res => allRes.push(res)),
foo.bar(1).then((res) => allRes.push(res)), foo.bar(1).then(res => allRes.push(res)),
foo.bar(2).then((res) => allRes.push(res)), foo.bar(2).then(res => allRes.push(res)),
foo.bar(2).then((res) => allRes.push(res)), foo.bar(2).then(res => allRes.push(res)),
foo.bar(3).then((res) => allRes.push(res)), foo.bar(3).then(res => allRes.push(res)),
foo.bar(3).then((res) => allRes.push(res)), foo.bar(3).then(res => allRes.push(res)),
]); ]);
expect(foo.calls).toBe(3); expect(foo.calls).toBe(3);
expect(allRes.length).toBe(6); expect(allRes.length).toBe(6);
@ -102,12 +102,12 @@ describe('sequentialize decorator', () => {
const allRes: number[] = []; const allRes: number[] = [];
await Promise.all([ await Promise.all([
foo.baz(1).then((res) => allRes.push(res)), foo.baz(1).then(res => allRes.push(res)),
foo.baz(1).then((res) => allRes.push(res)), foo.baz(1).then(res => allRes.push(res)),
foo.baz(2).then((res) => allRes.push(res)), foo.baz(2).then(res => allRes.push(res)),
foo.baz(2).then((res) => allRes.push(res)), foo.baz(2).then(res => allRes.push(res)),
foo.baz(3).then((res) => allRes.push(res)), foo.baz(3).then(res => allRes.push(res)),
foo.baz(3).then((res) => allRes.push(res)), foo.baz(3).then(res => allRes.push(res)),
]); ]);
expect(foo.calls).toBe(3); expect(foo.calls).toBe(3);
expect(allRes.length).toBe(6); expect(allRes.length).toBe(6);
@ -119,20 +119,20 @@ describe('sequentialize decorator', () => {
class Foo { class Foo {
calls = 0; calls = 0;
@sequentialize((args) => 'bar' + args[0]) @sequentialize(args => 'bar' + args[0])
bar(a: number): Promise<number> { bar(a: number): Promise<number> {
this.calls++; this.calls++;
return new Promise((res) => { return new Promise(res => {
setTimeout(() => { setTimeout(() => {
res(a * 2); res(a * 2);
}, Math.random() * 100); }, Math.random() * 100);
}); });
} }
@sequentialize((args) => 'baz' + args[0]) @sequentialize(args => 'baz' + args[0])
baz(a: number): Promise<number> { baz(a: number): Promise<number> {
this.calls++; this.calls++;
return new Promise((res) => { return new Promise(res => {
setTimeout(() => { setTimeout(() => {
res(a * 3); res(a * 3);
}, Math.random() * 100); }, Math.random() * 100);

View File

@ -72,7 +72,7 @@ class Foo {
bar(a: number) { bar(a: number) {
this.calls++; this.calls++;
this.inflight++; this.inflight++;
return new Promise((res) => { return new Promise(res => {
setTimeout(() => { setTimeout(() => {
expect(this.inflight).toBe(1); expect(this.inflight).toBe(1);
this.inflight--; this.inflight--;
@ -85,7 +85,7 @@ class Foo {
baz(a: number) { baz(a: number) {
this.calls++; this.calls++;
this.inflight++; this.inflight++;
return new Promise((res) => { return new Promise(res => {
setTimeout(() => { setTimeout(() => {
expect(this.inflight).toBeLessThanOrEqual(5); expect(this.inflight).toBeLessThanOrEqual(5);
this.inflight--; this.inflight--;
@ -94,12 +94,12 @@ class Foo {
}); });
} }
@sequentialize((args) => 'qux' + args[0]) @sequentialize(args => 'qux' + args[0])
@throttle(1, () => 'qux') @throttle(1, () => 'qux')
qux(a: number) { qux(a: number) {
this.calls++; this.calls++;
this.inflight++; this.inflight++;
return new Promise((res) => { return new Promise(res => {
setTimeout(() => { setTimeout(() => {
expect(this.inflight).toBe(1); expect(this.inflight).toBe(1);
this.inflight--; this.inflight--;

View File

@ -40,7 +40,7 @@ describe('ConsoleLogService', () => {
}); });
it('filters messages below the set threshold', () => { it('filters messages below the set threshold', () => {
logService = new ConsoleLogService(true, (level) => true); logService = new ConsoleLogService(true, level => true);
logService.debug('debug'); logService.debug('debug');
logService.info('info'); logService.info('info');
logService.warning('warning'); logService.warning('warning');
@ -86,7 +86,7 @@ describe('ConsoleLogService', () => {
}); });
it('filters time output', async () => { it('filters time output', async () => {
logService = new ConsoleLogService(true, (level) => true); logService = new ConsoleLogService(true, level => true);
logService.time(); logService.time();
logService.timeEnd(); logService.timeEnd();

View File

@ -1,5 +1,5 @@
function newGuid() { function newGuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
// tslint:disable:no-bitwise // tslint:disable:no-bitwise
const r = Math.random() * 16 | 0; const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8); const v = c === 'x' ? r : (r & 0x3 | 0x8);

View File

@ -468,8 +468,8 @@ function testRsaGenerateKeyPair(length: 1024 | 2048 | 4096) {
function getWebCryptoFunctionService() { function getWebCryptoFunctionService() {
const platformUtilsMock = TypeMoq.Mock.ofType<PlatformUtilsService>(PlatformUtilsServiceMock); const platformUtilsMock = TypeMoq.Mock.ofType<PlatformUtilsService>(PlatformUtilsServiceMock);
platformUtilsMock.setup((x) => x.isEdge()).returns(() => navigator.userAgent.indexOf(' Edg/') !== -1); platformUtilsMock.setup(x => x.isEdge()).returns(() => navigator.userAgent.indexOf(' Edg/') !== -1);
platformUtilsMock.setup((x) => x.isIE()).returns(() => navigator.userAgent.indexOf(' Edg/') === -1 && platformUtilsMock.setup(x => x.isIE()).returns(() => navigator.userAgent.indexOf(' Edg/') === -1 &&
navigator.userAgent.indexOf(' Trident/') !== -1); navigator.userAgent.indexOf(' Trident/') !== -1);
return new WebCryptoFunctionService(window, platformUtilsMock.object); return new WebCryptoFunctionService(window, platformUtilsMock.object);
} }

View File

@ -159,7 +159,7 @@ export class AddEditComponent implements OnInit {
const myEmail = await this.userService.getEmail(); const myEmail = await this.userService.getEmail();
this.ownershipOptions.push({ name: myEmail, value: null }); this.ownershipOptions.push({ name: myEmail, value: null });
const orgs = await this.userService.getAllOrganizations(); const orgs = await this.userService.getAllOrganizations();
orgs.sort(Utils.getSortFunction(this.i18nService, 'name')).forEach((o) => { orgs.sort(Utils.getSortFunction(this.i18nService, 'name')).forEach(o => {
if (o.enabled && o.status === OrganizationUserStatusType.Confirmed) { if (o.enabled && o.status === OrganizationUserStatusType.Confirmed) {
this.ownershipOptions.push({ name: o.name, value: o.id }); this.ownershipOptions.push({ name: o.name, value: o.id });
if (policies != null && o.usePolicies && !o.canManagePolicies && this.allowPersonal) { if (policies != null && o.usePolicies && !o.canManagePolicies && this.allowPersonal) {
@ -231,7 +231,7 @@ export class AddEditComponent implements OnInit {
if (this.cipher != null && (!this.editMode || addEditCipherInfo != null || this.cloneMode)) { if (this.cipher != null && (!this.editMode || addEditCipherInfo != null || this.cloneMode)) {
await this.organizationChanged(); await this.organizationChanged();
if (this.collectionIds != null && this.collectionIds.length > 0 && this.collections.length > 0) { if (this.collectionIds != null && this.collectionIds.length > 0 && this.collections.length > 0) {
this.collections.forEach((c) => { this.collections.forEach(c => {
if (this.collectionIds.indexOf(c.id) > -1) { if (this.collectionIds.indexOf(c.id) > -1) {
(c as any).checked = true; (c as any).checked = true;
} }
@ -273,7 +273,7 @@ export class AddEditComponent implements OnInit {
// Allows saving of selected collections during "Add" and "Clone" flows // Allows saving of selected collections during "Add" and "Clone" flows
if ((!this.editMode || this.cloneMode) && this.cipher.organizationId != null) { if ((!this.editMode || this.cloneMode) && this.cipher.organizationId != null) {
this.cipher.collectionIds = this.collections == null ? [] : this.cipher.collectionIds = this.collections == null ? [] :
this.collections.filter((c) => (c as any).checked).map((c) => c.id); this.collections.filter(c => (c as any).checked).map(c => c.id);
} }
// Clear current Cipher Id to trigger "Add" cipher flow // Clear current Cipher Id to trigger "Add" cipher flow
@ -459,10 +459,10 @@ export class AddEditComponent implements OnInit {
async organizationChanged() { async organizationChanged() {
if (this.writeableCollections != null) { if (this.writeableCollections != null) {
this.writeableCollections.forEach((c) => (c as any).checked = false); this.writeableCollections.forEach(c => (c as any).checked = false);
} }
if (this.cipher.organizationId != null) { if (this.cipher.organizationId != null) {
this.collections = this.writeableCollections.filter((c) => c.organizationId === this.cipher.organizationId); this.collections = this.writeableCollections.filter(c => c.organizationId === this.cipher.organizationId);
const org = await this.userService.getOrganization(this.cipher.organizationId); const org = await this.userService.getOrganization(this.cipher.organizationId);
if (org != null) { if (org != null) {
this.cipher.organizationUseTotp = org.useTotp; this.cipher.organizationUseTotp = org.useTotp;
@ -496,7 +496,7 @@ export class AddEditComponent implements OnInit {
protected async loadCollections() { protected async loadCollections() {
const allCollections = await this.collectionService.getAllDecrypted(); const allCollections = await this.collectionService.getAllDecrypted();
return allCollections.filter((c) => !c.readOnly); return allCollections.filter(c => !c.readOnly);
} }
protected loadCipher() { protected loadCipher() {

View File

@ -192,7 +192,7 @@ export class AttachmentsComponent implements OnInit {
// 3. Delete old // 3. Delete old
this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id); this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id);
await this.deletePromises[attachment.id]; await this.deletePromises[attachment.id];
const foundAttachment = this.cipher.attachments.filter((a2) => a2.id === attachment.id); const foundAttachment = this.cipher.attachments.filter(a2 => a2.id === attachment.id);
if (foundAttachment.length > 0) { if (foundAttachment.length > 0) {
const i = this.cipher.attachments.indexOf(foundAttachment[0]); const i = this.cipher.attachments.indexOf(foundAttachment[0]);
if (i > -1) { if (i > -1) {

View File

@ -82,7 +82,7 @@ export class CiphersComponent {
if (this.searchTimeout != null) { if (this.searchTimeout != null) {
clearTimeout(this.searchTimeout); clearTimeout(this.searchTimeout);
} }
const deletedFilter: (cipher: CipherView) => boolean = (c) => c.isDeleted === this.deleted; const deletedFilter: (cipher: CipherView) => boolean = c => c.isDeleted === this.deleted;
if (timeout == null) { if (timeout == null) {
this.ciphers = await this.searchService.searchCiphers(this.searchText, [this.filter, deletedFilter], null); this.ciphers = await this.searchService.searchCiphers(this.searchText, [this.filter, deletedFilter], null);
await this.resetPaging(); await this.resetPaging();

View File

@ -42,9 +42,9 @@ export class CollectionsComponent implements OnInit {
this.cipher = await this.cipherDomain.decrypt(); this.cipher = await this.cipherDomain.decrypt();
this.collections = await this.loadCollections(); this.collections = await this.loadCollections();
this.collections.forEach((c) => (c as any).checked = false); this.collections.forEach(c => (c as any).checked = false);
if (this.collectionIds != null) { if (this.collectionIds != null) {
this.collections.forEach((c) => { this.collections.forEach(c => {
(c as any).checked = this.collectionIds != null && this.collectionIds.indexOf(c.id) > -1; (c as any).checked = this.collectionIds != null && this.collectionIds.indexOf(c.id) > -1;
}); });
} }
@ -52,8 +52,8 @@ export class CollectionsComponent implements OnInit {
async submit() { async submit() {
const selectedCollectionIds = this.collections const selectedCollectionIds = this.collections
.filter((c) => !!(c as any).checked) .filter(c => !!(c as any).checked)
.map((c) => c.id); .map(c => c.id);
if (!this.allowSelectNone && selectedCollectionIds.length === 0) { if (!this.allowSelectNone && selectedCollectionIds.length === 0) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('selectOneCollection')); this.i18nService.t('selectOneCollection'));
@ -79,7 +79,7 @@ export class CollectionsComponent implements OnInit {
protected async loadCollections() { protected async loadCollections() {
const allCollections = await this.collectionService.getAllDecrypted(); const allCollections = await this.collectionService.getAllDecrypted();
return allCollections.filter((c) => !c.readOnly && c.organizationId === this.cipher.organizationId); return allCollections.filter(c => !c.readOnly && c.organizationId === this.cipher.organizationId);
} }
protected saveCollections() { protected saveCollections() {

View File

@ -79,7 +79,7 @@ export class GroupingsComponent {
} }
const collections = await this.collectionService.getAllDecrypted(); const collections = await this.collectionService.getAllDecrypted();
if (organizationId != null) { if (organizationId != null) {
this.collections = collections.filter((c) => c.organizationId === organizationId); this.collections = collections.filter(c => c.organizationId === organizationId);
} else { } else {
this.collections = collections; this.collections = collections;
} }

View File

@ -56,7 +56,7 @@ export class ModalComponent implements OnDestroy {
const modals = Array.from(document.querySelectorAll('.modal, .modal *[data-dismiss="modal"]')); const modals = Array.from(document.querySelectorAll('.modal, .modal *[data-dismiss="modal"]'));
for (const closeElement of modals) { for (const closeElement of modals) {
closeElement.addEventListener('click', (event) => { closeElement.addEventListener('click', event => {
this.close(); this.close();
}); });
} }

View File

@ -100,13 +100,13 @@ export class SendComponent implements OnInit {
clearTimeout(this.searchTimeout); clearTimeout(this.searchTimeout);
} }
if (timeout == null) { if (timeout == null) {
this.filteredSends = this.sends.filter((s) => this.filter == null || this.filter(s)); this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s));
this.applyTextSearch(); this.applyTextSearch();
return; return;
} }
this.searchPending = true; this.searchPending = true;
this.searchTimeout = setTimeout(async () => { this.searchTimeout = setTimeout(async () => {
this.filteredSends = this.sends.filter((s) => this.filter == null || this.filter(s)); this.filteredSends = this.sends.filter(s => this.filter == null || this.filter(s));
this.applyTextSearch(); this.applyTextSearch();
this.searchPending = false; this.searchPending = false;
}, timeout); }, timeout);
@ -189,7 +189,7 @@ export class SendComponent implements OnInit {
selectType(type: SendType) { selectType(type: SendType) {
this.clearSelections(); this.clearSelections();
this.selectedType = type; this.selectedType = type;
this.applyFilter((s) => s.type === type); this.applyFilter(s => s.type === type);
} }
clearSelections() { clearSelections() {

View File

@ -44,7 +44,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
await this.syncService.fullSync(true); await this.syncService.fullSync(true);
this.syncLoading = false; this.syncLoading = false;
const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
if (qParams.identifier != null) { if (qParams.identifier != null) {
this.identifier = qParams.identifier; this.identifier = qParams.identifier;
} }

View File

@ -43,10 +43,10 @@ export class ShareComponent implements OnInit {
async load() { async load() {
const allCollections = await this.collectionService.getAllDecrypted(); const allCollections = await this.collectionService.getAllDecrypted();
this.writeableCollections = allCollections.map((c) => c).filter((c) => !c.readOnly); this.writeableCollections = allCollections.map(c => c).filter(c => !c.readOnly);
const orgs = await this.userService.getAllOrganizations(); const orgs = await this.userService.getAllOrganizations();
this.organizations = orgs.sort(Utils.getSortFunction(this.i18nService, 'name')) this.organizations = orgs.sort(Utils.getSortFunction(this.i18nService, 'name'))
.filter((o) => o.enabled && o.status === OrganizationUserStatusType.Confirmed); .filter(o => o.enabled && o.status === OrganizationUserStatusType.Confirmed);
const cipherDomain = await this.cipherService.get(this.cipherId); const cipherDomain = await this.cipherService.get(this.cipherId);
this.cipher = await cipherDomain.decrypt(); this.cipher = await cipherDomain.decrypt();
@ -57,18 +57,18 @@ export class ShareComponent implements OnInit {
} }
filterCollections() { filterCollections() {
this.writeableCollections.forEach((c) => (c as any).checked = false); this.writeableCollections.forEach(c => (c as any).checked = false);
if (this.organizationId == null || this.writeableCollections.length === 0) { if (this.organizationId == null || this.writeableCollections.length === 0) {
this.collections = []; this.collections = [];
} else { } else {
this.collections = this.writeableCollections.filter((c) => c.organizationId === this.organizationId); this.collections = this.writeableCollections.filter(c => c.organizationId === this.organizationId);
} }
} }
async submit(): Promise<boolean> { async submit(): Promise<boolean> {
const selectedCollectionIds = this.collections const selectedCollectionIds = this.collections
.filter((c) => !!(c as any).checked) .filter(c => !!(c as any).checked)
.map((c) => c.id); .map(c => c.id);
if (selectedCollectionIds.length === 0) { if (selectedCollectionIds.length === 0) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('selectOneCollection')); this.i18nService.t('selectOneCollection'));

View File

@ -45,7 +45,7 @@ export class SsoComponent {
protected passwordGenerationService: PasswordGenerationService) { } protected passwordGenerationService: PasswordGenerationService) { }
async ngOnInit() { async ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
if (qParams.code != null && qParams.state != null) { if (qParams.code != null && qParams.state != null) {
const codeVerifier = await this.storageService.get<string>(ConstantsService.ssoCodeVerifierKey); const codeVerifier = await this.storageService.get<string>(ConstantsService.ssoCodeVerifierKey);
const state = await this.storageService.get<string>(ConstantsService.ssoStateKey); const state = await this.storageService.get<string>(ConstantsService.ssoStateKey);

View File

@ -63,7 +63,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
return; return;
} }
const queryParamsSub = this.route.queryParams.subscribe(async (qParams) => { const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
if (qParams.identifier != null) { if (qParams.identifier != null) {
this.identifier = qParams.identifier; this.identifier = qParams.identifier;
} }

View File

@ -18,7 +18,7 @@ export class BoxRowDirective implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.formEls = Array.from(this.el.querySelectorAll('input:not([type="hidden"]), select, textarea')); this.formEls = Array.from(this.el.querySelectorAll('input:not([type="hidden"]), select, textarea'));
this.formEls.forEach((formEl) => { this.formEls.forEach(formEl => {
formEl.addEventListener('focus', (event: Event) => { formEl.addEventListener('focus', (event: Event) => {
this.el.classList.add('active'); this.el.classList.add('active');
}, false); }, false);

View File

@ -15,13 +15,13 @@ export class SearchCiphersPipe implements PipeTransform {
} }
if (searchText == null || searchText.length < 2) { if (searchText == null || searchText.length < 2) {
return ciphers.filter((c) => { return ciphers.filter(c => {
return deleted !== c.isDeleted; return deleted !== c.isDeleted;
}); });
} }
searchText = searchText.trim().toLowerCase(); searchText = searchText.trim().toLowerCase();
return ciphers.filter((c) => { return ciphers.filter(c => {
if (deleted !== c.isDeleted) { if (deleted !== c.isDeleted) {
return false; return false;
} }

View File

@ -17,7 +17,7 @@ export class SearchPipe implements PipeTransform {
} }
searchText = searchText.trim().toLowerCase(); searchText = searchText.trim().toLowerCase();
return items.filter((i) => { return items.filter(i => {
if (prop1 != null && i[prop1] != null && i[prop1].toString().toLowerCase().indexOf(searchText) > -1) { if (prop1 != null && i[prop1] != null && i[prop1].toString().toLowerCase().indexOf(searchText) > -1) {
return true; return true;
} }

View File

@ -175,7 +175,7 @@ export class LoginCommand {
if (twoFactorMethod != null) { if (twoFactorMethod != null) {
try { try {
selectedProvider = twoFactorProviders.filter((p) => p.type === twoFactorMethod)[0]; selectedProvider = twoFactorProviders.filter(p => p.type === twoFactorMethod)[0];
} catch (e) { } catch (e) {
return Response.error('Invalid two-step login method.'); return Response.error('Invalid two-step login method.');
} }
@ -185,7 +185,7 @@ export class LoginCommand {
if (twoFactorProviders.length === 1) { if (twoFactorProviders.length === 1) {
selectedProvider = twoFactorProviders[0]; selectedProvider = twoFactorProviders[0];
} else if (this.canInteract) { } else if (this.canInteract) {
const twoFactorOptions = twoFactorProviders.map((p) => p.name); const twoFactorOptions = twoFactorProviders.map(p => p.name);
twoFactorOptions.push(new inquirer.Separator()); twoFactorOptions.push(new inquirer.Separator());
twoFactorOptions.push('Cancel'); twoFactorOptions.push('Cancel');
const answer: inquirer.Answers = const answer: inquirer.Answers =

View File

@ -24,7 +24,7 @@ export class Response {
static multipleResults(ids: string[]): Response { static multipleResults(ids: string[]): Response {
let msg = 'More than one result was found. Try getting a specific object by `id` instead. ' + let msg = 'More than one result was found. Try getting a specific object by `id` instead. ' +
'The following objects were found:'; 'The following objects were found:';
ids.forEach((id) => { ids.forEach(id => {
msg += '\n' + id; msg += '\n' + id;
}); });
return Response.error(msg, ids); return Response.error(msg, ids);

View File

@ -118,9 +118,9 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
remote.dialog.showSaveDialog(remote.getCurrentWindow(), { remote.dialog.showSaveDialog(remote.getCurrentWindow(), {
defaultPath: fileName, defaultPath: fileName,
showsTagField: false, showsTagField: false,
}).then((ret) => { }).then(ret => {
if (ret.filePath != null) { if (ret.filePath != null) {
fs.writeFile(ret.filePath, Buffer.from(blobData), (err) => { fs.writeFile(ret.filePath, Buffer.from(blobData), err => {
// error check? // error check?
}); });
} }
@ -213,7 +213,7 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
} }
authenticateBiometric(): Promise<boolean> { authenticateBiometric(): Promise<boolean> {
return new Promise((resolve) => { return new Promise(resolve => {
const val = ipcRenderer.sendSync('biometric', { const val = ipcRenderer.sendSync('biometric', {
action: 'authenticate', action: 'authenticate',
}); });

View File

@ -89,7 +89,7 @@ export class UpdaterMain {
this.reset(); this.reset();
}); });
autoUpdater.on('update-downloaded', async (info) => { autoUpdater.on('update-downloaded', async info => {
if (this.onUpdateDownloaded != null) { if (this.onUpdateDownloaded != null) {
this.onUpdateDownloaded(); this.onUpdateDownloaded();
} }
@ -114,7 +114,7 @@ export class UpdaterMain {
} }
}); });
autoUpdater.on('error', (error) => { autoUpdater.on('error', error => {
if (this.doingUpdateCheckWithFeedback) { if (this.doingUpdateCheckWithFeedback) {
dialog.showErrorBox(this.i18nService.t('updateError'), dialog.showErrorBox(this.i18nService.t('updateError'),
error == null ? this.i18nService.t('unknown') : (error.stack || error).toString()); error == null ? this.i18nService.t('unknown') : (error.stack || error).toString());

View File

@ -12,7 +12,7 @@ export class AscendoCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length < 2) { if (value.length < 2) {
return; return;
} }

View File

@ -12,7 +12,7 @@ export class AvastCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name); cipher.name = this.getValueOrDefault(value.name);
cipher.login.uris = this.makeUriArray(value.web); cipher.login.uris = this.makeUriArray(value.web);

View File

@ -12,7 +12,7 @@ export class AviraCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name, cipher.name = this.getValueOrDefault(value.name,
this.getValueOrDefault(this.nameFromUrl(value.website), '--')); this.getValueOrDefault(this.nameFromUrl(value.website), '--'));

View File

@ -91,7 +91,7 @@ export abstract class BaseImporter {
data = this.splitNewLine(data).join('\n').trim(); data = this.splitNewLine(data).join('\n').trim();
const result = papa.parse(data, parseOptions); const result = papa.parse(data, parseOptions);
if (result.errors != null && result.errors.length > 0) { if (result.errors != null && result.errors.length > 0) {
result.errors.forEach((e) => { result.errors.forEach(e => {
if (e.row != null) { if (e.row != null) {
// tslint:disable-next-line // tslint:disable-next-line
this.logService.warning('Error parsing row ' + e.row + ': ' + e.message); this.logService.warning('Error parsing row ' + e.row + ': ' + e.message);
@ -129,7 +129,7 @@ export abstract class BaseImporter {
if (uri.length > 0) { if (uri.length > 0) {
const returnArr: LoginUriView[] = []; const returnArr: LoginUriView[] = [];
uri.forEach((u) => { uri.forEach(u => {
const loginUri = new LoginUriView(); const loginUri = new LoginUriView();
loginUri.uri = this.fixUri(u); loginUri.uri = this.fixUri(u);
if (this.isNullOrWhitespace(loginUri.uri)) { if (this.isNullOrWhitespace(loginUri.uri)) {
@ -265,8 +265,8 @@ export abstract class BaseImporter {
} }
protected moveFoldersToCollections(result: ImportResult) { protected moveFoldersToCollections(result: ImportResult) {
result.folderRelationships.forEach((r) => result.collectionRelationships.push(r)); result.folderRelationships.forEach(r => result.collectionRelationships.push(r));
result.collections = result.folders.map((f) => { result.collections = result.folders.map(f => {
const collection = new CollectionView(); const collection = new CollectionView();
collection.name = f.name; collection.name = f.name;
return collection; return collection;
@ -281,7 +281,7 @@ export abstract class BaseImporter {
} }
protected querySelectorAllDirectChild(parentEl: Element, query: string) { protected querySelectorAllDirectChild(parentEl: Element, query: string) {
return Array.from(parentEl.querySelectorAll(query)).filter((el) => el.parentNode === parentEl); return Array.from(parentEl.querySelectorAll(query)).filter(el => el.parentNode === parentEl);
} }
protected initLoginCipher() { protected initLoginCipher() {

View File

@ -23,10 +23,10 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (this.organization && !this.isNullOrWhitespace(value.collections)) { if (this.organization && !this.isNullOrWhitespace(value.collections)) {
const collections = (value.collections as string).split(','); const collections = (value.collections as string).split(',');
collections.forEach((col) => { collections.forEach(col => {
let addCollection = true; let addCollection = true;
let collectionIndex = result.collections.length; let collectionIndex = result.collections.length;

View File

@ -71,7 +71,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) { if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) {
this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]); this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]);
} else if (this.organization && c.collectionIds != null) { } else if (this.organization && c.collectionIds != null) {
c.collectionIds.forEach((cId) => { c.collectionIds.forEach(cId => {
if (groupingsMap.has(cId)) { if (groupingsMap.has(cId)) {
this.result.collectionRelationships.push([this.result.ciphers.length, groupingsMap.get(cId)]); this.result.collectionRelationships.push([this.result.ciphers.length, groupingsMap.get(cId)]);
} }
@ -123,7 +123,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) { if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) {
this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]); this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]);
} else if (this.organization && c.collectionIds != null) { } else if (this.organization && c.collectionIds != null) {
c.collectionIds.forEach((cId) => { c.collectionIds.forEach(cId => {
if (groupingsMap.has(cId)) { if (groupingsMap.has(cId)) {
this.result.collectionRelationships.push([this.result.ciphers.length, groupingsMap.get(cId)]); this.result.collectionRelationships.push([this.result.ciphers.length, groupingsMap.get(cId)]);
} }

View File

@ -12,7 +12,7 @@ export class BlackBerryCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.grouping === 'list') { if (value.grouping === 'list') {
return; return;
} }

View File

@ -12,7 +12,7 @@ export class BlurCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.label === 'null') { if (value.label === 'null') {
value.label = null; value.label = null;
} }

View File

@ -16,7 +16,7 @@ export class ButtercupCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
this.processFolder(result, this.getValueOrDefault(value['!group_name'])); this.processFolder(result, this.getValueOrDefault(value['!group_name']));
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();

View File

@ -12,7 +12,7 @@ export class ChromeCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name, '--'); cipher.name = this.getValueOrDefault(value.name, '--');
cipher.login.username = this.getValueOrDefault(value.username); cipher.login.username = this.getValueOrDefault(value.username);

View File

@ -12,7 +12,7 @@ export class CodebookCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
this.processFolder(result, this.getValueOrDefault(value.Category)); this.processFolder(result, this.getValueOrDefault(value.Category));
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();

View File

@ -16,7 +16,7 @@ export class EncryptrCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.Label, '--'); cipher.name = this.getValueOrDefault(value.Label, '--');
cipher.notes = this.getValueOrDefault(value.Notes); cipher.notes = this.getValueOrDefault(value.Notes);

View File

@ -19,7 +19,7 @@ export class EnpassCsvImporter extends BaseImporter implements Importer {
} }
let firstRow = true; let firstRow = true;
results.forEach((value) => { results.forEach(value => {
if (value.length < 2 || (firstRow && (value[0] === 'Title' || value[0] === 'title'))) { if (value.length < 2 || (firstRow && (value[0] === 'Title' || value[0] === 'title'))) {
firstRow = false; firstRow = false;
return; return;
@ -106,7 +106,7 @@ export class EnpassCsvImporter extends BaseImporter implements Importer {
if (fields == null || name == null) { if (fields == null || name == null) {
return false; return false;
} }
return fields.filter((f) => !this.isNullOrWhitespace(f) && return fields.filter(f => !this.isNullOrWhitespace(f) &&
f.toLowerCase() === name.toLowerCase()).length > 0; f.toLowerCase() === name.toLowerCase()).length > 0;
} }
} }

View File

@ -12,7 +12,7 @@ export class FirefoxCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
const url = this.getValueOrDefault(value.url, this.getValueOrDefault(value.hostname)); const url = this.getValueOrDefault(value.url, this.getValueOrDefault(value.hostname));
cipher.name = this.getValueOrDefault(this.nameFromUrl(url), '--'); cipher.name = this.getValueOrDefault(this.nameFromUrl(url), '--');

View File

@ -43,7 +43,7 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
const applications = this.parseDataCategory(applicationsData); const applications = this.parseDataCategory(applicationsData);
const websites = this.parseDataCategory(websitesData); const websites = this.parseDataCategory(websitesData);
notes.forEach((n) => { notes.forEach(n => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(n.get('Name')); cipher.name = this.getValueOrDefault(n.get('Name'));
cipher.notes = this.getValueOrDefault(n.get('Text')); cipher.notes = this.getValueOrDefault(n.get('Text'));
@ -51,7 +51,7 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
result.ciphers.push(cipher); result.ciphers.push(cipher);
}); });
websites.concat(applications).forEach((w) => { websites.concat(applications).forEach(w => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
const nameKey = w.has('Website name') ? 'Website name' : 'Application'; const nameKey = w.has('Website name') ? 'Website name' : 'Application';
cipher.name = this.getValueOrDefault(w.get(nameKey), ''); cipher.name = this.getValueOrDefault(w.get(nameKey), '');
@ -80,14 +80,14 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
return []; return [];
} }
const items: Map<string, string>[] = []; const items: Map<string, string>[] = [];
data.split(Delimiter).forEach((p) => { data.split(Delimiter).forEach(p => {
if (p.indexOf('\n') === -1) { if (p.indexOf('\n') === -1) {
return; return;
} }
const item = new Map<string, string>(); const item = new Map<string, string>();
let itemComment: string; let itemComment: string;
let itemCommentKey: string; let itemCommentKey: string;
p.split('\n').forEach((l) => { p.split('\n').forEach(l => {
if (itemComment != null) { if (itemComment != null) {
itemComment += ('\n' + l); itemComment += ('\n' + l);
return; return;

View File

@ -49,11 +49,11 @@ export class KeePass2XmlImporter extends BaseImporter implements Importer {
this.result.folders.push(folder); this.result.folders.push(folder);
} }
this.querySelectorAllDirectChild(node, 'Entry').forEach((entry) => { this.querySelectorAllDirectChild(node, 'Entry').forEach(entry => {
const cipherIndex = this.result.ciphers.length; const cipherIndex = this.result.ciphers.length;
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
this.querySelectorAllDirectChild(entry, 'String').forEach((entryString) => { this.querySelectorAllDirectChild(entry, 'String').forEach(entryString => {
const valueEl = this.querySelectorDirectChild(entryString, 'Value'); const valueEl = this.querySelectorDirectChild(entryString, 'Value');
const value = valueEl != null ? valueEl.textContent : null; const value = valueEl != null ? valueEl.textContent : null;
if (this.isNullOrWhitespace(value)) { if (this.isNullOrWhitespace(value)) {
@ -93,7 +93,7 @@ export class KeePass2XmlImporter extends BaseImporter implements Importer {
} }
}); });
this.querySelectorAllDirectChild(node, 'Group').forEach((group) => { this.querySelectorAllDirectChild(node, 'Group').forEach(group => {
this.traverse(group, false, groupName); this.traverse(group, false, groupName);
}); });
} }

View File

@ -12,7 +12,7 @@ export class KeePassXCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (this.isNullOrWhitespace(value.Title)) { if (this.isNullOrWhitespace(value.Title)) {
return; return;
} }

View File

@ -14,7 +14,7 @@ export class KeeperCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length < 6) { if (value.length < 6) {
return; return;
} }

View File

@ -233,7 +233,7 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
const dataObj: any = {}; const dataObj: any = {};
let processingNotes = false; let processingNotes = false;
extraParts.forEach((extraPart) => { extraParts.forEach(extraPart => {
let key: string = null; let key: string = null;
let val: string = null; let val: string = null;
if (!processingNotes) { if (!processingNotes) {

View File

@ -12,7 +12,7 @@ export class LogMeOnceCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length < 4) { if (value.length < 4) {
return; return;
} }

View File

@ -12,7 +12,7 @@ export class MeldiumCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.DisplayName, '--'); cipher.name = this.getValueOrDefault(value.DisplayName, '--');
cipher.notes = this.getValueOrDefault(value.Notes); cipher.notes = this.getValueOrDefault(value.Notes);

View File

@ -17,7 +17,7 @@ export class MSecureCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length < 3) { if (value.length < 3) {
return; return;
} }

View File

@ -19,7 +19,7 @@ export class MykiCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.nickname, '--'); cipher.name = this.getValueOrDefault(value.nickname, '--');
cipher.notes = this.getValueOrDefault(value.additionalInfo); cipher.notes = this.getValueOrDefault(value.additionalInfo);

View File

@ -17,7 +17,7 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
result = new ImportResult(); result = new ImportResult();
parse(data: string): Promise<ImportResult> { parse(data: string): Promise<ImportResult> {
data.split(this.newLineRegex).forEach((line) => { data.split(this.newLineRegex).forEach(line => {
if (this.isNullOrWhitespace(line) || line[0] !== '{') { if (this.isNullOrWhitespace(line) || line[0] !== '{') {
return; return;
} }
@ -237,7 +237,7 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
const fieldName = this.isNullOrWhitespace(field[nameKey]) ? 'no_name' : field[nameKey]; const fieldName = this.isNullOrWhitespace(field[nameKey]) ? 'no_name' : field[nameKey];
if (fieldName === 'password' && cipher.passwordHistory != null && if (fieldName === 'password' && cipher.passwordHistory != null &&
cipher.passwordHistory.some((h) => h.password === fieldValue)) { cipher.passwordHistory.some(h => h.password === fieldValue)) {
return; return;
} }

View File

@ -27,7 +27,7 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (this.isNullOrWhitespace(this.getProp(value, 'title'))) { if (this.isNullOrWhitespace(this.getProp(value, 'title'))) {
return; return;
} }

View File

@ -16,7 +16,7 @@ export class PadlockCsvImporter extends BaseImporter implements Importer {
} }
let headers: string[] = null; let headers: string[] = null;
results.forEach((value) => { results.forEach(value => {
if (headers == null) { if (headers == null) {
headers = value.map((v: string) => v); headers = value.map((v: string) => v);
return; return;
@ -29,7 +29,7 @@ export class PadlockCsvImporter extends BaseImporter implements Importer {
if (!this.isNullOrWhitespace(value[1])) { if (!this.isNullOrWhitespace(value[1])) {
if (this.organization) { if (this.organization) {
const tags = (value[1] as string).split(','); const tags = (value[1] as string).split(',');
tags.forEach((tag) => { tags.forEach(tag => {
tag = tag.trim(); tag = tag.trim();
let addCollection = true; let addCollection = true;
let collectionIndex = result.collections.length; let collectionIndex = result.collections.length;

View File

@ -12,7 +12,7 @@ export class PassKeepCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
this.processFolder(result, this.getValue('category', value)); this.processFolder(result, this.getValue('category', value));
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.notes = this.getValue('description', value); cipher.notes = this.getValue('description', value);

View File

@ -14,7 +14,7 @@ export class PasspackCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const tagsJson = !this.isNullOrWhitespace(value.Tags) ? JSON.parse(value.Tags) : null; const tagsJson = !this.isNullOrWhitespace(value.Tags) ? JSON.parse(value.Tags) : null;
const tags: string[] = tagsJson != null && tagsJson.tags != null && tagsJson.tags.length > 0 ? const tags: string[] = tagsJson != null && tagsJson.tags != null && tagsJson.tags.length > 0 ?
tagsJson.tags.map((tagJson: string) => { tagsJson.tags.map((tagJson: string) => {
@ -26,7 +26,7 @@ export class PasspackCsvImporter extends BaseImporter implements Importer {
}).filter((t: string) => !this.isNullOrWhitespace(t)) : null; }).filter((t: string) => !this.isNullOrWhitespace(t)) : null;
if (this.organization && tags != null && tags.length > 0) { if (this.organization && tags != null && tags.length > 0) {
tags.forEach((tag) => { tags.forEach(tag => {
let addCollection = true; let addCollection = true;
let collectionIndex = result.collections.length; let collectionIndex = result.collections.length;

View File

@ -13,7 +13,7 @@ export class PasswordAgentCsvImporter extends BaseImporter implements Importer {
} }
let newVersion = true; let newVersion = true;
results.forEach((value) => { results.forEach(value => {
if (value.length !== 5 && value.length < 9) { if (value.length !== 5 && value.length < 9) {
return; return;
} }

View File

@ -13,7 +13,7 @@ export class PasswordDragonXmlImporter extends BaseImporter implements Importer
} }
const records = doc.querySelectorAll('PasswordManager > record'); const records = doc.querySelectorAll('PasswordManager > record');
Array.from(records).forEach((record) => { Array.from(records).forEach(record => {
const category = this.querySelectorDirectChild(record, 'Category'); const category = this.querySelectorDirectChild(record, 'Category');
const categoryText = category != null && !this.isNullOrWhitespace(category.textContent) && const categoryText = category != null && !this.isNullOrWhitespace(category.textContent) &&
category.textContent !== 'Unfiled' ? category.textContent : null; category.textContent !== 'Unfiled' ? category.textContent : null;
@ -36,7 +36,7 @@ export class PasswordDragonXmlImporter extends BaseImporter implements Importer
attributes.push('Attribute-' + i); attributes.push('Attribute-' + i);
} }
this.querySelectorAllDirectChild(record, attributes.join(',')).forEach((attr) => { this.querySelectorAllDirectChild(record, attributes.join(',')).forEach(attr => {
if (this.isNullOrWhitespace(attr.textContent) || attr.textContent === 'null') { if (this.isNullOrWhitespace(attr.textContent) || attr.textContent === 'null') {
return; return;
} }

View File

@ -21,7 +21,7 @@ export class PasswordSafeXmlImporter extends BaseImporter implements Importer {
const notesDelimiter = passwordSafe.getAttribute('delimiter'); const notesDelimiter = passwordSafe.getAttribute('delimiter');
const entries = doc.querySelectorAll('passwordsafe > entry'); const entries = doc.querySelectorAll('passwordsafe > entry');
Array.from(entries).forEach((entry) => { Array.from(entries).forEach(entry => {
const group = this.querySelectorDirectChild(entry, 'group'); const group = this.querySelectorDirectChild(entry, 'group');
const groupText = group != null && !this.isNullOrWhitespace(group.textContent) ? const groupText = group != null && !this.isNullOrWhitespace(group.textContent) ?
group.textContent.split('.').join('/') : null; group.textContent.split('.').join('/') : null;

View File

@ -12,7 +12,7 @@ export class PasswordWalletTxtImporter extends BaseImporter implements Importer
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length < 1) { if (value.length < 1) {
return; return;
} }

View File

@ -16,7 +16,7 @@ export class RememBearCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.trash === 'true') { if (value.trash === 'true') {
return; return;
} }

View File

@ -13,7 +13,7 @@ export class RoboFormCsvImporter extends BaseImporter implements Importer {
} }
let i = 1; let i = 1;
results.forEach((value) => { results.forEach(value => {
const folder = !this.isNullOrWhitespace(value.Folder) && value.Folder.startsWith('/') ? const folder = !this.isNullOrWhitespace(value.Folder) && value.Folder.startsWith('/') ?
value.Folder.replace('/', '') : value.Folder; value.Folder.replace('/', '') : value.Folder;
const folderName = !this.isNullOrWhitespace(folder) ? folder : null; const folderName = !this.isNullOrWhitespace(folder) ? folder : null;

View File

@ -27,7 +27,7 @@ export class SafeInCloudXmlImporter extends BaseImporter implements Importer {
const foldersMap = new Map<string, number>(); const foldersMap = new Map<string, number>();
Array.from(doc.querySelectorAll('database > label')).forEach((labelEl) => { Array.from(doc.querySelectorAll('database > label')).forEach(labelEl => {
const name = labelEl.getAttribute('name'); const name = labelEl.getAttribute('name');
const id = labelEl.getAttribute('id'); const id = labelEl.getAttribute('id');
if (!this.isNullOrWhitespace(name) && !this.isNullOrWhitespace(id)) { if (!this.isNullOrWhitespace(name) && !this.isNullOrWhitespace(id)) {
@ -38,7 +38,7 @@ export class SafeInCloudXmlImporter extends BaseImporter implements Importer {
} }
}); });
Array.from(doc.querySelectorAll('database > card')).forEach((cardEl) => { Array.from(doc.querySelectorAll('database > card')).forEach(cardEl => {
if (cardEl.getAttribute('template') === 'true') { if (cardEl.getAttribute('template') === 'true') {
return; return;
} }
@ -60,7 +60,7 @@ export class SafeInCloudXmlImporter extends BaseImporter implements Importer {
cipher.secureNote = new SecureNoteView(); cipher.secureNote = new SecureNoteView();
cipher.secureNote.type = SecureNoteType.Generic; cipher.secureNote.type = SecureNoteType.Generic;
} else { } else {
Array.from(this.querySelectorAllDirectChild(cardEl, 'field')).forEach((fieldEl) => { Array.from(this.querySelectorAllDirectChild(cardEl, 'field')).forEach(fieldEl => {
const text = fieldEl.textContent; const text = fieldEl.textContent;
if (this.isNullOrWhitespace(text)) { if (this.isNullOrWhitespace(text)) {
return; return;
@ -83,7 +83,7 @@ export class SafeInCloudXmlImporter extends BaseImporter implements Importer {
}); });
} }
Array.from(this.querySelectorAllDirectChild(cardEl, 'notes')).forEach((notesEl) => { Array.from(this.querySelectorAllDirectChild(cardEl, 'notes')).forEach(notesEl => {
cipher.notes += (notesEl.textContent + '\n'); cipher.notes += (notesEl.textContent + '\n');
}); });

View File

@ -12,7 +12,7 @@ export class SaferPassCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(this.nameFromUrl(value.url), '--'); cipher.name = this.getValueOrDefault(this.nameFromUrl(value.url), '--');
cipher.notes = this.getValueOrDefault(value.notes); cipher.notes = this.getValueOrDefault(value.notes);

View File

@ -12,7 +12,7 @@ export class SecureSafeCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.Title); cipher.name = this.getValueOrDefault(value.Title);
cipher.notes = this.getValueOrDefault(value.Comment); cipher.notes = this.getValueOrDefault(value.Comment);

View File

@ -13,7 +13,7 @@ export class SplashIdCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length < 3) { if (value.length < 3) {
return; return;
} }

View File

@ -13,7 +13,7 @@ export class StickyPasswordXmlImporter extends BaseImporter implements Importer
} }
const loginNodes = doc.querySelectorAll('root > Database > Logins > Login'); const loginNodes = doc.querySelectorAll('root > Database > Logins > Login');
Array.from(loginNodes).forEach((loginNode) => { Array.from(loginNodes).forEach(loginNode => {
const accountId = loginNode.getAttribute('ID'); const accountId = loginNode.getAttribute('ID');
if (this.isNullOrWhitespace(accountId)) { if (this.isNullOrWhitespace(accountId)) {
return; return;

View File

@ -22,7 +22,7 @@ export class TrueKeyCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.favorite = this.getValueOrDefault(value.favorite, '').toLowerCase() === 'true'; cipher.favorite = this.getValueOrDefault(value.favorite, '').toLowerCase() === 'true';
cipher.name = this.getValueOrDefault(value.name, '--'); cipher.name = this.getValueOrDefault(value.name, '--');

View File

@ -12,7 +12,7 @@ export class UpmCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (value.length !== 5) { if (value.length !== 5) {
return; return;
} }

View File

@ -12,7 +12,7 @@ export class YotiCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
const cipher = this.initLoginCipher(); const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.Name, '--'); cipher.name = this.getValueOrDefault(value.Name, '--');
cipher.login.username = this.getValueOrDefault(value['User name']); cipher.login.username = this.getValueOrDefault(value['User name']);

View File

@ -13,7 +13,7 @@ export class ZohoVaultCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result); return Promise.resolve(result);
} }
results.forEach((value) => { results.forEach(value => {
if (this.isNullOrWhitespace(value['Password Name']) && this.isNullOrWhitespace(value['Secret Name'])) { if (this.isNullOrWhitespace(value['Password Name']) && this.isNullOrWhitespace(value['Secret Name'])) {
return; return;
} }
@ -45,7 +45,7 @@ export class ZohoVaultCsvImporter extends BaseImporter implements Importer {
return; return;
} }
const dataLines = this.splitNewLine(data); const dataLines = this.splitNewLine(data);
dataLines.forEach((line) => { dataLines.forEach(line => {
const delimPosition = line.indexOf(':'); const delimPosition = line.indexOf(':');
if (delimPosition < 0) { if (delimPosition < 0) {
return; return;

View File

@ -109,7 +109,7 @@ export class Analytics {
} }
const pathParts = pagePath.split('/'); const pathParts = pagePath.split('/');
const newPathParts: string[] = []; const newPathParts: string[] = [];
pathParts.forEach((p) => { pathParts.forEach(p => {
if (p.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)) { if (p.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)) {
newPathParts.push('__guid__'); newPathParts.push('__guid__');
} else { } else {

View File

@ -19,11 +19,11 @@ export class NodeUtils {
const readStream = fs.createReadStream(fileName, {encoding: 'utf8'}); const readStream = fs.createReadStream(fileName, {encoding: 'utf8'});
const readInterface = readline.createInterface(readStream); const readInterface = readline.createInterface(readStream);
readInterface readInterface
.on('line', (line) => { .on('line', line => {
readStream.close(); readStream.close();
resolve(line); resolve(line);
}) })
.on('error', (err) => reject(err)); .on('error', err => reject(err));
}); });
} }

View File

@ -27,7 +27,7 @@ export class ServiceUtils {
return; return;
} }
if (nodeTree.filter((n) => n.node.name === partName).length === 0) { if (nodeTree.filter(n => n.node.name === partName).length === 0) {
if (end) { if (end) {
nodeTree.push(new TreeNode(obj, partName, parent)); nodeTree.push(new TreeNode(obj, partName, parent));
return; return;

View File

@ -159,7 +159,7 @@ export class Utils {
// ref: http://stackoverflow.com/a/2117523/1090359 // ref: http://stackoverflow.com/a/2117523/1090359
static newGuid(): string { static newGuid(): string {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
// tslint:disable-next-line // tslint:disable-next-line
const r = Math.random() * 16 | 0; const r = Math.random() * 16 | 0;
// tslint:disable-next-line // tslint:disable-next-line
@ -242,7 +242,7 @@ export class Utils {
} }
const map = new Map<string, string>(); const map = new Map<string, string>();
const pairs = (url.search[0] === '?' ? url.search.substr(1) : url.search).split('&'); const pairs = (url.search[0] === '?' ? url.search.substr(1) : url.search).split('&');
pairs.forEach((pair) => { pairs.forEach(pair => {
const parts = pair.split('='); const parts = pair.split('=');
if (parts.length < 1) { if (parts.length < 1) {
return; return;
@ -289,7 +289,7 @@ export class Utils {
private static isMobile(win: Window) { private static isMobile(win: Window) {
let mobile = false; let mobile = false;
((a) => { (a => {
// tslint:disable-next-line // tslint:disable-next-line
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) {
mobile = true; mobile = true;

View File

@ -72,13 +72,13 @@ export class CipherData {
} }
if (response.fields != null) { if (response.fields != null) {
this.fields = response.fields.map((f) => new FieldData(f)); this.fields = response.fields.map(f => new FieldData(f));
} }
if (response.attachments != null) { if (response.attachments != null) {
this.attachments = response.attachments.map((a) => new AttachmentData(a)); this.attachments = response.attachments.map(a => new AttachmentData(a));
} }
if (response.passwordHistory != null) { if (response.passwordHistory != null) {
this.passwordHistory = response.passwordHistory.map((ph) => new PasswordHistoryData(ph)); this.passwordHistory = response.passwordHistory.map(ph => new PasswordHistoryData(ph));
} }
} }
} }

View File

@ -20,7 +20,7 @@ export class LoginData {
this.totp = data.totp; this.totp = data.totp;
if (data.uris) { if (data.uris) {
this.uris = data.uris.map((u) => new LoginUriData(u)); this.uris = data.uris.map(u => new LoginUriData(u));
} }
} }
} }

View File

@ -85,19 +85,19 @@ export class Cipher extends Domain {
} }
if (obj.attachments != null) { if (obj.attachments != null) {
this.attachments = obj.attachments.map((a) => new Attachment(a, alreadyEncrypted)); this.attachments = obj.attachments.map(a => new Attachment(a, alreadyEncrypted));
} else { } else {
this.attachments = null; this.attachments = null;
} }
if (obj.fields != null) { if (obj.fields != null) {
this.fields = obj.fields.map((f) => new Field(f, alreadyEncrypted)); this.fields = obj.fields.map(f => new Field(f, alreadyEncrypted));
} else { } else {
this.fields = null; this.fields = null;
} }
if (obj.passwordHistory != null) { if (obj.passwordHistory != null) {
this.passwordHistory = obj.passwordHistory.map((ph) => new Password(ph, alreadyEncrypted)); this.passwordHistory = obj.passwordHistory.map(ph => new Password(ph, alreadyEncrypted));
} else { } else {
this.passwordHistory = null; this.passwordHistory = null;
} }
@ -135,7 +135,7 @@ export class Cipher extends Domain {
await this.attachments.reduce((promise, attachment) => { await this.attachments.reduce((promise, attachment) => {
return promise.then(() => { return promise.then(() => {
return attachment.decrypt(orgId, encKey); return attachment.decrypt(orgId, encKey);
}).then((decAttachment) => { }).then(decAttachment => {
attachments.push(decAttachment); attachments.push(decAttachment);
}); });
}, Promise.resolve()); }, Promise.resolve());
@ -147,7 +147,7 @@ export class Cipher extends Domain {
await this.fields.reduce((promise, field) => { await this.fields.reduce((promise, field) => {
return promise.then(() => { return promise.then(() => {
return field.decrypt(orgId, encKey); return field.decrypt(orgId, encKey);
}).then((decField) => { }).then(decField => {
fields.push(decField); fields.push(decField);
}); });
}, Promise.resolve()); }, Promise.resolve());
@ -159,7 +159,7 @@ export class Cipher extends Domain {
await this.passwordHistory.reduce((promise, ph) => { await this.passwordHistory.reduce((promise, ph) => {
return promise.then(() => { return promise.then(() => {
return ph.decrypt(orgId, encKey); return ph.decrypt(orgId, encKey);
}).then((decPh) => { }).then(decPh => {
passwordHistory.push(decPh); passwordHistory.push(decPh);
}); });
}, Promise.resolve()); }, Promise.resolve());
@ -207,13 +207,13 @@ export class Cipher extends Domain {
} }
if (this.fields != null) { if (this.fields != null) {
c.fields = this.fields.map((f) => f.toFieldData()); c.fields = this.fields.map(f => f.toFieldData());
} }
if (this.attachments != null) { if (this.attachments != null) {
c.attachments = this.attachments.map((a) => a.toAttachmentData()); c.attachments = this.attachments.map(a => a.toAttachmentData());
} }
if (this.passwordHistory != null) { if (this.passwordHistory != null) {
c.passwordHistory = this.passwordHistory.map((ph) => ph.toPasswordHistoryData()); c.passwordHistory = this.passwordHistory.map(ph => ph.toPasswordHistoryData());
} }
return c; return c;
} }

View File

@ -30,7 +30,7 @@ export class Login extends Domain {
if (obj.uris) { if (obj.uris) {
this.uris = []; this.uris = [];
obj.uris.forEach((u) => { obj.uris.forEach(u => {
this.uris.push(new LoginUri(u, alreadyEncrypted)); this.uris.push(new LoginUri(u, alreadyEncrypted));
}); });
} }
@ -65,7 +65,7 @@ export class Login extends Domain {
if (this.uris != null && this.uris.length > 0) { if (this.uris != null && this.uris.length > 0) {
l.uris = []; l.uris = [];
this.uris.forEach((u) => { this.uris.forEach(u => {
l.uris.push(u.toLoginUriData()); l.uris.push(u.toLoginUriData());
}); });
} }

View File

@ -39,7 +39,7 @@ export class Cipher {
view.favorite = req.favorite; view.favorite = req.favorite;
if (req.fields != null) { if (req.fields != null) {
view.fields = req.fields.map((f) => Field.toView(f)); view.fields = req.fields.map(f => Field.toView(f));
} }
switch (req.type) { switch (req.type) {
@ -71,7 +71,7 @@ export class Cipher {
domain.favorite = req.favorite; domain.favorite = req.favorite;
if (req.fields != null) { if (req.fields != null) {
domain.fields = req.fields.map((f) => Field.toDomain(f)); domain.fields = req.fields.map(f => Field.toDomain(f));
} }
switch (req.type) { switch (req.type) {
@ -122,9 +122,9 @@ export class Cipher {
if (o.fields != null) { if (o.fields != null) {
if (o instanceof CipherView) { if (o instanceof CipherView) {
this.fields = o.fields.map((f) => new Field(f)); this.fields = o.fields.map(f => new Field(f));
} else { } else {
this.fields = o.fields.map((f) => new Field(f)); this.fields = o.fields.map(f => new Field(f));
} }
} }

View File

@ -17,7 +17,7 @@ export class Login {
static toView(req: Login, view = new LoginView()) { static toView(req: Login, view = new LoginView()) {
if (req.uris != null) { if (req.uris != null) {
view.uris = req.uris.map((u) => LoginUri.toView(u)); view.uris = req.uris.map(u => LoginUri.toView(u));
} }
view.username = req.username; view.username = req.username;
view.password = req.password; view.password = req.password;
@ -27,7 +27,7 @@ export class Login {
static toDomain(req: Login, domain = new LoginDomain()) { static toDomain(req: Login, domain = new LoginDomain()) {
if (req.uris != null) { if (req.uris != null) {
domain.uris = req.uris.map((u) => LoginUri.toDomain(u)); domain.uris = req.uris.map(u => LoginUri.toDomain(u));
} }
domain.username = req.username != null ? new CipherString(req.username) : null; domain.username = req.username != null ? new CipherString(req.username) : null;
domain.password = req.password != null ? new CipherString(req.password) : null; domain.password = req.password != null ? new CipherString(req.password) : null;
@ -47,9 +47,9 @@ export class Login {
if (o.uris != null) { if (o.uris != null) {
if (o instanceof LoginView) { if (o instanceof LoginView) {
this.uris = o.uris.map((u) => new LoginUri(u)); this.uris = o.uris.map(u => new LoginUri(u));
} else { } else {
this.uris = o.uris.map((u) => new LoginUri(u)); this.uris = o.uris.map(u => new LoginUri(u));
} }
} }

View File

@ -9,7 +9,7 @@ export class CipherBulkShareRequest {
constructor(ciphers: Cipher[], collectionIds: string[]) { constructor(ciphers: Cipher[], collectionIds: string[]) {
if (ciphers != null) { if (ciphers != null) {
this.ciphers = []; this.ciphers = [];
ciphers.forEach((c) => { ciphers.forEach(c => {
this.ciphers.push(new CipherWithIdRequest(c)); this.ciphers.push(new CipherWithIdRequest(c));
}); });
} }

View File

@ -50,7 +50,7 @@ export class CipherRequest {
this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null; this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null;
if (cipher.login.uris != null) { if (cipher.login.uris != null) {
this.login.uris = cipher.login.uris.map((u) => { this.login.uris = cipher.login.uris.map(u => {
const uri = new LoginUriApi(); const uri = new LoginUriApi();
uri.uri = u.uri != null ? u.uri.encryptedString : null; uri.uri = u.uri != null ? u.uri.encryptedString : null;
uri.match = u.match != null ? u.match : null; uri.match = u.match != null ? u.match : null;
@ -110,7 +110,7 @@ export class CipherRequest {
} }
if (cipher.fields != null) { if (cipher.fields != null) {
this.fields = cipher.fields.map((f) => { this.fields = cipher.fields.map(f => {
const field = new FieldApi(); const field = new FieldApi();
field.type = f.type; field.type = f.type;
field.name = f.name ? f.name.encryptedString : null; field.name = f.name ? f.name.encryptedString : null;
@ -121,7 +121,7 @@ export class CipherRequest {
if (cipher.passwordHistory != null) { if (cipher.passwordHistory != null) {
this.passwordHistory = []; this.passwordHistory = [];
cipher.passwordHistory.forEach((ph) => { cipher.passwordHistory.forEach(ph => {
this.passwordHistory.push({ this.passwordHistory.push({
lastUsedDate: ph.lastUsedDate, lastUsedDate: ph.lastUsedDate,
password: ph.password ? ph.password.encryptedString : null, password: ph.password ? ph.password.encryptedString : null,
@ -132,7 +132,7 @@ export class CipherRequest {
if (cipher.attachments != null) { if (cipher.attachments != null) {
this.attachments = {}; this.attachments = {};
this.attachments2 = {}; this.attachments2 = {};
cipher.attachments.forEach((attachment) => { cipher.attachments.forEach(attachment => {
const fileName = attachment.fileName ? attachment.fileName.encryptedString : null; const fileName = attachment.fileName ? attachment.fileName.encryptedString : null;
this.attachments[attachment.id] = fileName; this.attachments[attachment.id] = fileName;
const attachmentRequest = new AttachmentRequest(); const attachmentRequest = new AttachmentRequest();

View File

@ -32,7 +32,7 @@ export class LoginView implements View {
} }
get canLaunch(): boolean { get canLaunch(): boolean {
return this.hasUris && this.uris.some((u) => u.canLaunch); return this.hasUris && this.uris.some(u => u.canLaunch);
} }
get hasTotp(): boolean { get hasTotp(): boolean {
@ -41,7 +41,7 @@ export class LoginView implements View {
get launchUri(): string { get launchUri(): string {
if (this.hasUris) { if (this.hasUris) {
const uri = this.uris.find((u) => u.canLaunch); const uri = this.uris.find(u => u.canLaunch);
if (uri != null) { if (uri != null) {
return uri.launchUri; return uri.launchUri;
} }

View File

@ -1312,7 +1312,7 @@ export class ApiService implements ApiServiceAbstraction {
} }
private qsStringify(params: any): string { private qsStringify(params: any): string {
return Object.keys(params).map((key) => { return Object.keys(params).map(key => {
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]); return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
}).join('&'); }).join('&');
} }

View File

@ -22,7 +22,7 @@ export class AuditService implements AuditServiceAbstraction {
const response = await this.apiService.nativeFetch(new Request(PwnedPasswordsApi + hashStart)); const response = await this.apiService.nativeFetch(new Request(PwnedPasswordsApi + hashStart));
const leakedHashes = await response.text(); const leakedHashes = await response.text();
const match = leakedHashes.split(/\r?\n/).find((v) => { const match = leakedHashes.split(/\r?\n/).find(v => {
return v.split(':')[0] === hashEnding; return v.split(':')[0] === hashEnding;
}); });

View File

@ -11,7 +11,7 @@ export class BroadcasterService implements BroadcasterServiceAbstraction {
return; return;
} }
this.subscribers.forEach((value) => { this.subscribers.forEach(value => {
value(message); value(message);
}); });
} }

View File

@ -113,12 +113,12 @@ export class CipherService implements CipherServiceAbstraction {
} }
} }
if (existingCipher.hasFields) { if (existingCipher.hasFields) {
const existingHiddenFields = existingCipher.fields.filter((f) => f.type === FieldType.Hidden && const existingHiddenFields = existingCipher.fields.filter(f => f.type === FieldType.Hidden &&
f.name != null && f.name !== '' && f.value != null && f.value !== ''); f.name != null && f.name !== '' && f.value != null && f.value !== '');
const hiddenFields = model.fields == null ? [] : const hiddenFields = model.fields == null ? [] :
model.fields.filter((f) => f.type === FieldType.Hidden && f.name != null && f.name !== ''); model.fields.filter(f => f.type === FieldType.Hidden && f.name != null && f.name !== '');
existingHiddenFields.forEach((ef) => { existingHiddenFields.forEach(ef => {
const matchedField = hiddenFields.find((f) => f.name === ef.name); const matchedField = hiddenFields.find(f => f.name === ef.name);
if (matchedField == null || matchedField.value !== ef.value) { if (matchedField == null || matchedField.value !== ef.value) {
const ph = new PasswordHistoryView(); const ph = new PasswordHistoryView();
ph.password = ef.name + ': ' + ef.value; ph.password = ef.name + ': ' + ef.value;
@ -157,13 +157,13 @@ export class CipherService implements CipherServiceAbstraction {
notes: null, notes: null,
}, key), }, key),
this.encryptCipherData(cipher, model, key), this.encryptCipherData(cipher, model, key),
this.encryptFields(model.fields, key).then((fields) => { this.encryptFields(model.fields, key).then(fields => {
cipher.fields = fields; cipher.fields = fields;
}), }),
this.encryptPasswordHistories(model.passwordHistory, key).then((ph) => { this.encryptPasswordHistories(model.passwordHistory, key).then(ph => {
cipher.passwordHistory = ph; cipher.passwordHistory = ph;
}), }),
this.encryptAttachments(model.attachments, key).then((attachments) => { this.encryptAttachments(model.attachments, key).then(attachments => {
cipher.attachments = attachments; cipher.attachments = attachments;
}), }),
]); ]);
@ -178,7 +178,7 @@ export class CipherService implements CipherServiceAbstraction {
const promises: Promise<any>[] = []; const promises: Promise<any>[] = [];
const encAttachments: Attachment[] = []; const encAttachments: Attachment[] = [];
attachmentsModel.forEach(async (model) => { attachmentsModel.forEach(async model => {
const attachment = new Attachment(); const attachment = new Attachment();
attachment.id = model.id; attachment.id = model.id;
attachment.size = model.size; attachment.size = model.size;
@ -302,8 +302,8 @@ export class CipherService implements CipherServiceAbstraction {
const promises: any[] = []; const promises: any[] = [];
const ciphers = await this.getAll(); const ciphers = await this.getAll();
ciphers.forEach((cipher) => { ciphers.forEach(cipher => {
promises.push(cipher.decrypt().then((c) => decCiphers.push(c))); promises.push(cipher.decrypt().then(c => decCiphers.push(c)));
}); });
await Promise.all(promises); await Promise.all(promises);
@ -315,7 +315,7 @@ export class CipherService implements CipherServiceAbstraction {
async getAllDecryptedForGrouping(groupingId: string, folder: boolean = true): Promise<CipherView[]> { async getAllDecryptedForGrouping(groupingId: string, folder: boolean = true): Promise<CipherView[]> {
const ciphers = await this.getAllDecrypted(); const ciphers = await this.getAllDecrypted();
return ciphers.filter((cipher) => { return ciphers.filter(cipher => {
if (cipher.isDeleted) { if (cipher.isDeleted) {
return false; return false;
} }
@ -339,7 +339,7 @@ export class CipherService implements CipherServiceAbstraction {
const eqDomainsPromise = domain == null ? Promise.resolve([]) : const eqDomainsPromise = domain == null ? Promise.resolve([]) :
this.settingsService.getEquivalentDomains().then((eqDomains: any[][]) => { this.settingsService.getEquivalentDomains().then((eqDomains: any[][]) => {
let matches: any[] = []; let matches: any[] = [];
eqDomains.forEach((eqDomain) => { eqDomains.forEach(eqDomain => {
if (eqDomain.length && eqDomain.indexOf(domain) >= 0) { if (eqDomain.length && eqDomain.indexOf(domain) >= 0) {
matches = matches.concat(eqDomain); matches = matches.concat(eqDomain);
} }
@ -363,7 +363,7 @@ export class CipherService implements CipherServiceAbstraction {
} }
} }
return ciphers.filter((cipher) => { return ciphers.filter(cipher => {
if (cipher.deletedDate != null) { if (cipher.deletedDate != null) {
return false; return false;
} }
@ -432,10 +432,10 @@ export class CipherService implements CipherServiceAbstraction {
if (ciphers != null && ciphers.data != null && ciphers.data.length) { if (ciphers != null && ciphers.data != null && ciphers.data.length) {
const decCiphers: CipherView[] = []; const decCiphers: CipherView[] = [];
const promises: any[] = []; const promises: any[] = [];
ciphers.data.forEach((r) => { ciphers.data.forEach(r => {
const data = new CipherData(r); const data = new CipherData(r);
const cipher = new Cipher(data); const cipher = new Cipher(data);
promises.push(cipher.decrypt().then((c) => decCiphers.push(c))); promises.push(cipher.decrypt().then(c => decCiphers.push(c)));
}); });
await Promise.all(promises); await Promise.all(promises);
decCiphers.sort(this.getLocaleSortingFunction()); decCiphers.sort(this.getLocaleSortingFunction());
@ -556,7 +556,7 @@ export class CipherService implements CipherServiceAbstraction {
async shareWithServer(cipher: CipherView, organizationId: string, collectionIds: string[]): Promise<any> { async shareWithServer(cipher: CipherView, organizationId: string, collectionIds: string[]): Promise<any> {
const attachmentPromises: Promise<any>[] = []; const attachmentPromises: Promise<any>[] = [];
if (cipher.attachments != null) { if (cipher.attachments != null) {
cipher.attachments.forEach((attachment) => { cipher.attachments.forEach(attachment => {
if (attachment.key == null) { if (attachment.key == null) {
attachmentPromises.push(this.shareAttachmentWithServer(attachment, cipher.id, organizationId)); attachmentPromises.push(this.shareAttachmentWithServer(attachment, cipher.id, organizationId));
} }
@ -580,7 +580,7 @@ export class CipherService implements CipherServiceAbstraction {
for (const cipher of ciphers) { for (const cipher of ciphers) {
cipher.organizationId = organizationId; cipher.organizationId = organizationId;
cipher.collectionIds = collectionIds; cipher.collectionIds = collectionIds;
promises.push(this.encrypt(cipher).then((c) => { promises.push(this.encrypt(cipher).then(c => {
encCiphers.push(c); encCiphers.push(c);
})); }));
} }
@ -588,7 +588,7 @@ export class CipherService implements CipherServiceAbstraction {
const request = new CipherBulkShareRequest(encCiphers, collectionIds); const request = new CipherBulkShareRequest(encCiphers, collectionIds);
await this.apiService.putShareCiphers(request); await this.apiService.putShareCiphers(request);
const userId = await this.userService.getUserId(); const userId = await this.userService.getUserId();
await this.upsert(encCiphers.map((c) => c.toCipherData(userId))); await this.upsert(encCiphers.map(c => c.toCipherData(userId)));
} }
saveAttachmentWithServer(cipher: Cipher, unencryptedFile: any, admin = false): Promise<Cipher> { saveAttachmentWithServer(cipher: Cipher, unencryptedFile: any, admin = false): Promise<Cipher> {
@ -604,7 +604,7 @@ export class CipherService implements CipherServiceAbstraction {
reject(e); reject(e);
} }
}; };
reader.onerror = (evt) => { reader.onerror = evt => {
reject('Error reading file.'); reject('Error reading file.');
}; };
}); });
@ -674,7 +674,7 @@ export class CipherService implements CipherServiceAbstraction {
const c = cipher as CipherData; const c = cipher as CipherData;
ciphers[c.id] = c; ciphers[c.id] = c;
} else { } else {
(cipher as CipherData[]).forEach((c) => { (cipher as CipherData[]).forEach(c => {
ciphers[c.id] = c; ciphers[c.id] = c;
}); });
} }
@ -704,7 +704,7 @@ export class CipherService implements CipherServiceAbstraction {
ciphers = {}; ciphers = {};
} }
ids.forEach((id) => { ids.forEach(id => {
if (ciphers.hasOwnProperty(id)) { if (ciphers.hasOwnProperty(id)) {
ciphers[id].folderId = folderId; ciphers[id].folderId = folderId;
} }
@ -728,7 +728,7 @@ export class CipherService implements CipherServiceAbstraction {
} }
delete ciphers[id]; delete ciphers[id];
} else { } else {
(id as string[]).forEach((i) => { (id as string[]).forEach(i => {
delete ciphers[i]; delete ciphers[i];
}); });
} }

View File

@ -52,8 +52,8 @@ export class CollectionService implements CollectionServiceAbstraction {
} }
const decCollections: CollectionView[] = []; const decCollections: CollectionView[] = [];
const promises: Promise<any>[] = []; const promises: Promise<any>[] = [];
collections.forEach((collection) => { collections.forEach(collection => {
promises.push(collection.decrypt().then((c) => decCollections.push(c))); promises.push(collection.decrypt().then(c => decCollections.push(c)));
}); });
await Promise.all(promises); await Promise.all(promises);
return decCollections.sort(Utils.getSortFunction(this.i18nService, 'name')); return decCollections.sort(Utils.getSortFunction(this.i18nService, 'name'));
@ -103,7 +103,7 @@ export class CollectionService implements CollectionServiceAbstraction {
collections = await this.getAllDecrypted(); collections = await this.getAllDecrypted();
} }
const nodes: TreeNode<CollectionView>[] = []; const nodes: TreeNode<CollectionView>[] = [];
collections.forEach((c) => { collections.forEach(c => {
const collectionCopy = new CollectionView(); const collectionCopy = new CollectionView();
collectionCopy.id = c.id; collectionCopy.id = c.id;
collectionCopy.organizationId = c.organizationId; collectionCopy.organizationId = c.organizationId;
@ -130,7 +130,7 @@ export class CollectionService implements CollectionServiceAbstraction {
const c = collection as CollectionData; const c = collection as CollectionData;
collections[c.id] = c; collections[c.id] = c;
} else { } else {
(collection as CollectionData[]).forEach((c) => { (collection as CollectionData[]).forEach(c => {
collections[c.id] = c; collections[c.id] = c;
}); });
} }
@ -162,7 +162,7 @@ export class CollectionService implements CollectionServiceAbstraction {
const i = id as string; const i = id as string;
delete collections[id]; delete collections[id];
} else { } else {
(id as string[]).forEach((i) => { (id as string[]).forEach(i => {
delete collections[i]; delete collections[i];
}); });
} }

View File

@ -80,7 +80,7 @@ export class CryptoService implements CryptoServiceAbstraction {
setOrgKeys(orgs: ProfileOrganizationResponse[]): Promise<{}> { setOrgKeys(orgs: ProfileOrganizationResponse[]): Promise<{}> {
const orgKeys: any = {}; const orgKeys: any = {};
orgs.forEach((org) => { orgs.forEach(org => {
orgKeys[org.id] = org.key; orgKeys[org.id] = org.key;
}); });

View File

@ -39,7 +39,7 @@ export class EventService implements EventServiceAbstraction {
if (organizations == null) { if (organizations == null) {
return; return;
} }
const orgIds = new Set<string>(organizations.filter((o) => o.useEvents).map((o) => o.id)); const orgIds = new Set<string>(organizations.filter(o => o.useEvents).map(o => o.id));
if (orgIds.size === 0) { if (orgIds.size === 0) {
return; return;
} }
@ -73,7 +73,7 @@ export class EventService implements EventServiceAbstraction {
if (eventCollection == null || eventCollection.length === 0) { if (eventCollection == null || eventCollection.length === 0) {
return; return;
} }
const request = eventCollection.map((e) => { const request = eventCollection.map(e => {
const req = new EventRequest(); const req = new EventRequest();
req.type = e.type; req.type = e.type;
req.cipherId = e.cipherId; req.cipherId = e.cipherId;

View File

@ -59,11 +59,11 @@ export class ExportService implements ExportServiceAbstraction {
let decCiphers: CipherView[] = []; let decCiphers: CipherView[] = [];
const promises = []; const promises = [];
promises.push(this.folderService.getAllDecrypted().then((folders) => { promises.push(this.folderService.getAllDecrypted().then(folders => {
decFolders = folders; decFolders = folders;
})); }));
promises.push(this.cipherService.getAllDecrypted().then((ciphers) => { promises.push(this.cipherService.getAllDecrypted().then(ciphers => {
decCiphers = ciphers.filter(f => f.deletedDate == null); decCiphers = ciphers.filter(f => f.deletedDate == null);
})); }));
@ -71,14 +71,14 @@ export class ExportService implements ExportServiceAbstraction {
if (format === 'csv') { if (format === 'csv') {
const foldersMap = new Map<string, FolderView>(); const foldersMap = new Map<string, FolderView>();
decFolders.forEach((f) => { decFolders.forEach(f => {
if (f.id != null) { if (f.id != null) {
foldersMap.set(f.id, f); foldersMap.set(f.id, f);
} }
}); });
const exportCiphers: any[] = []; const exportCiphers: any[] = [];
decCiphers.forEach((c) => { decCiphers.forEach(c => {
// only export logins and secure notes // only export logins and secure notes
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) { if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
return; return;
@ -103,7 +103,7 @@ export class ExportService implements ExportServiceAbstraction {
items: [], items: [],
}; };
decFolders.forEach((f) => { decFolders.forEach(f => {
if (f.id == null) { if (f.id == null) {
return; return;
} }
@ -112,7 +112,7 @@ export class ExportService implements ExportServiceAbstraction {
jsonDoc.folders.push(folder); jsonDoc.folders.push(folder);
}); });
decCiphers.forEach((c) => { decCiphers.forEach(c => {
if (c.organizationId != null) { if (c.organizationId != null) {
return; return;
} }
@ -131,12 +131,12 @@ export class ExportService implements ExportServiceAbstraction {
let ciphers: Cipher[] = []; let ciphers: Cipher[] = [];
const promises = []; const promises = [];
promises.push(this.folderService.getAll().then((f) => { promises.push(this.folderService.getAll().then(f => {
folders = f; folders = f;
})); }));
promises.push(this.cipherService.getAll().then((c) => { promises.push(this.cipherService.getAll().then(c => {
ciphers = c.filter((f) => f.deletedDate == null); ciphers = c.filter(f => f.deletedDate == null);
})); }));
await Promise.all(promises); await Promise.all(promises);
@ -147,7 +147,7 @@ export class ExportService implements ExportServiceAbstraction {
items: [], items: [],
}; };
folders.forEach((f) => { folders.forEach(f => {
if (f.id == null) { if (f.id == null) {
return; return;
} }
@ -156,7 +156,7 @@ export class ExportService implements ExportServiceAbstraction {
jsonDoc.folders.push(folder); jsonDoc.folders.push(folder);
}); });
ciphers.forEach((c) => { ciphers.forEach(c => {
if (c.organizationId != null) { if (c.organizationId != null) {
return; return;
} }
@ -174,12 +174,12 @@ export class ExportService implements ExportServiceAbstraction {
const decCiphers: CipherView[] = []; const decCiphers: CipherView[] = [];
const promises = []; const promises = [];
promises.push(this.apiService.getCollections(organizationId).then((collections) => { promises.push(this.apiService.getCollections(organizationId).then(collections => {
const collectionPromises: any = []; const collectionPromises: any = [];
if (collections != null && collections.data != null && collections.data.length > 0) { if (collections != null && collections.data != null && collections.data.length > 0) {
collections.data.forEach((c) => { collections.data.forEach(c => {
const collection = new Collection(new CollectionData(c as CollectionDetailsResponse)); const collection = new Collection(new CollectionData(c as CollectionDetailsResponse));
collectionPromises.push(collection.decrypt().then((decCol) => { collectionPromises.push(collection.decrypt().then(decCol => {
decCollections.push(decCol); decCollections.push(decCol);
})); }));
}); });
@ -187,12 +187,12 @@ export class ExportService implements ExportServiceAbstraction {
return Promise.all(collectionPromises); return Promise.all(collectionPromises);
})); }));
promises.push(this.apiService.getCiphersOrganization(organizationId).then((ciphers) => { promises.push(this.apiService.getCiphersOrganization(organizationId).then(ciphers => {
const cipherPromises: any = []; const cipherPromises: any = [];
if (ciphers != null && ciphers.data != null && ciphers.data.length > 0) { if (ciphers != null && ciphers.data != null && ciphers.data.length > 0) {
ciphers.data.filter((c) => c.deletedDate === null).forEach((c) => { ciphers.data.filter(c => c.deletedDate === null).forEach(c => {
const cipher = new Cipher(new CipherData(c)); const cipher = new Cipher(new CipherData(c));
cipherPromises.push(cipher.decrypt().then((decCipher) => { cipherPromises.push(cipher.decrypt().then(decCipher => {
decCiphers.push(decCipher); decCiphers.push(decCipher);
})); }));
}); });
@ -204,12 +204,12 @@ export class ExportService implements ExportServiceAbstraction {
if (format === 'csv') { if (format === 'csv') {
const collectionsMap = new Map<string, CollectionView>(); const collectionsMap = new Map<string, CollectionView>();
decCollections.forEach((c) => { decCollections.forEach(c => {
collectionsMap.set(c.id, c); collectionsMap.set(c.id, c);
}); });
const exportCiphers: any[] = []; const exportCiphers: any[] = [];
decCiphers.forEach((c) => { decCiphers.forEach(c => {
// only export logins and secure notes // only export logins and secure notes
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) { if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
return; return;
@ -218,8 +218,8 @@ export class ExportService implements ExportServiceAbstraction {
const cipher: any = {}; const cipher: any = {};
cipher.collections = []; cipher.collections = [];
if (c.collectionIds != null) { if (c.collectionIds != null) {
cipher.collections = c.collectionIds.filter((id) => collectionsMap.has(id)) cipher.collections = c.collectionIds.filter(id => collectionsMap.has(id))
.map((id) => collectionsMap.get(id).name); .map(id => collectionsMap.get(id).name);
} }
this.buildCommonCipher(cipher, c); this.buildCommonCipher(cipher, c);
exportCiphers.push(cipher); exportCiphers.push(cipher);
@ -233,13 +233,13 @@ export class ExportService implements ExportServiceAbstraction {
items: [], items: [],
}; };
decCollections.forEach((c) => { decCollections.forEach(c => {
const collection = new CollectionExport(); const collection = new CollectionExport();
collection.build(c); collection.build(c);
jsonDoc.collections.push(collection); jsonDoc.collections.push(collection);
}); });
decCiphers.forEach((c) => { decCiphers.forEach(c => {
const cipher = new CipherExport(); const cipher = new CipherExport();
cipher.build(c); cipher.build(c);
jsonDoc.items.push(cipher); jsonDoc.items.push(cipher);
@ -253,10 +253,10 @@ export class ExportService implements ExportServiceAbstraction {
const ciphers: Cipher[] = []; const ciphers: Cipher[] = [];
const promises = []; const promises = [];
promises.push(this.apiService.getCollections(organizationId).then((c) => { promises.push(this.apiService.getCollections(organizationId).then(c => {
const collectionPromises: any = []; const collectionPromises: any = [];
if (c != null && c.data != null && c.data.length > 0) { if (c != null && c.data != null && c.data.length > 0) {
c.data.forEach((r) => { c.data.forEach(r => {
const collection = new Collection(new CollectionData(r as CollectionDetailsResponse)); const collection = new Collection(new CollectionData(r as CollectionDetailsResponse));
collections.push(collection); collections.push(collection);
}); });
@ -264,10 +264,10 @@ export class ExportService implements ExportServiceAbstraction {
return Promise.all(collectionPromises); return Promise.all(collectionPromises);
})); }));
promises.push(this.apiService.getCiphersOrganization(organizationId).then((c) => { promises.push(this.apiService.getCiphersOrganization(organizationId).then(c => {
const cipherPromises: any = []; const cipherPromises: any = [];
if (c != null && c.data != null && c.data.length > 0) { if (c != null && c.data != null && c.data.length > 0) {
c.data.filter((item) => item.deletedDate === null).forEach((item) => { c.data.filter(item => item.deletedDate === null).forEach(item => {
const cipher = new Cipher(new CipherData(item)); const cipher = new Cipher(new CipherData(item));
ciphers.push(cipher); ciphers.push(cipher);
}); });
@ -283,13 +283,13 @@ export class ExportService implements ExportServiceAbstraction {
items: [], items: [],
}; };
collections.forEach((c) => { collections.forEach(c => {
const collection = new CollectionExport(); const collection = new CollectionExport();
collection.build(c); collection.build(c);
jsonDoc.collections.push(collection); jsonDoc.collections.push(collection);
}); });
ciphers.forEach((c) => { ciphers.forEach(c => {
const cipher = new CipherExport(); const cipher = new CipherExport();
cipher.build(c); cipher.build(c);
jsonDoc.items.push(cipher); jsonDoc.items.push(cipher);
@ -335,7 +335,7 @@ export class ExportService implements ExportServiceAbstraction {
if (c.login.uris) { if (c.login.uris) {
cipher.login_uri = []; cipher.login_uri = [];
c.login.uris.forEach((u) => { c.login.uris.forEach(u => {
cipher.login_uri.push(u.uri); cipher.login_uri.push(u.uri);
}); });
} }

View File

@ -83,8 +83,8 @@ export class FolderService implements FolderServiceAbstraction {
const decFolders: FolderView[] = []; const decFolders: FolderView[] = [];
const promises: Promise<any>[] = []; const promises: Promise<any>[] = [];
const folders = await this.getAll(); const folders = await this.getAll();
folders.forEach((folder) => { folders.forEach(folder => {
promises.push(folder.decrypt().then((f) => decFolders.push(f))); promises.push(folder.decrypt().then(f => decFolders.push(f)));
}); });
await Promise.all(promises); await Promise.all(promises);
@ -101,7 +101,7 @@ export class FolderService implements FolderServiceAbstraction {
async getAllNested(): Promise<TreeNode<FolderView>[]> { async getAllNested(): Promise<TreeNode<FolderView>[]> {
const folders = await this.getAllDecrypted(); const folders = await this.getAllDecrypted();
const nodes: TreeNode<FolderView>[] = []; const nodes: TreeNode<FolderView>[] = [];
folders.forEach((f) => { folders.forEach(f => {
const folderCopy = new FolderView(); const folderCopy = new FolderView();
folderCopy.id = f.id; folderCopy.id = f.id;
folderCopy.revisionDate = f.revisionDate; folderCopy.revisionDate = f.revisionDate;
@ -144,7 +144,7 @@ export class FolderService implements FolderServiceAbstraction {
const f = folder as FolderData; const f = folder as FolderData;
folders[f.id] = f; folders[f.id] = f;
} else { } else {
(folder as FolderData[]).forEach((f) => { (folder as FolderData[]).forEach(f => {
folders[f.id] = f; folders[f.id] = f;
}); });
} }
@ -178,7 +178,7 @@ export class FolderService implements FolderServiceAbstraction {
} }
delete folders[id]; delete folders[id];
} else { } else {
(id as string[]).forEach((i) => { (id as string[]).forEach(i => {
delete folders[i]; delete folders[i];
}); });
} }

View File

@ -306,7 +306,7 @@ export class ImportService implements ImportServiceAbstraction {
} }
} }
if (importResult.folderRelationships != null) { if (importResult.folderRelationships != null) {
importResult.folderRelationships.forEach((r) => importResult.folderRelationships.forEach(r =>
request.folderRelationships.push(new KvpRequest(r[0], r[1]))); request.folderRelationships.push(new KvpRequest(r[0], r[1])));
} }
return await this.apiService.postImportCiphers(request); return await this.apiService.postImportCiphers(request);
@ -325,7 +325,7 @@ export class ImportService implements ImportServiceAbstraction {
} }
} }
if (importResult.collectionRelationships != null) { if (importResult.collectionRelationships != null) {
importResult.collectionRelationships.forEach((r) => importResult.collectionRelationships.forEach(r =>
request.collectionRelationships.push(new KvpRequest(r[0], r[1]))); request.collectionRelationships.push(new KvpRequest(r[0], r[1])));
} }
return await this.apiService.postImportOrganizationCiphers(organizationId, request); return await this.apiService.postImportOrganizationCiphers(organizationId, request);

View File

@ -269,7 +269,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
return enforcedOptions; return enforcedOptions;
} }
policies.forEach((currentPolicy) => { policies.forEach(currentPolicy => {
if (!currentPolicy.enabled || currentPolicy.data == null) { if (!currentPolicy.enabled || currentPolicy.data == null) {
return; return;
} }
@ -471,7 +471,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
return Promise.resolve([]); return Promise.resolve([]);
} }
const promises = history.map(async (item) => { const promises = history.map(async item => {
const encrypted = await this.cryptoService.encrypt(item.password); const encrypted = await this.cryptoService.encrypt(item.password);
return new GeneratedPasswordHistory(encrypted.encryptedString, item.date); return new GeneratedPasswordHistory(encrypted.encryptedString, item.date);
}); });
@ -484,7 +484,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
return Promise.resolve([]); return Promise.resolve([]);
} }
const promises = history.map(async (item) => { const promises = history.map(async item => {
const decrypted = await this.cryptoService.decryptToUtf8(new CipherString(item.password)); const decrypted = await this.cryptoService.decryptToUtf8(new CipherString(item.password));
return new GeneratedPasswordHistory(decrypted, item.date); return new GeneratedPasswordHistory(decrypted, item.date);
}); });

View File

@ -37,7 +37,7 @@ export class PolicyService implements PolicyServiceAbstraction {
this.policyCache = response; this.policyCache = response;
} }
if (type != null) { if (type != null) {
return this.policyCache.filter((p) => p.type === type); return this.policyCache.filter(p => p.type === type);
} else { } else {
return this.policyCache; return this.policyCache;
} }
@ -60,14 +60,14 @@ export class PolicyService implements PolicyServiceAbstraction {
if (policies == null) { if (policies == null) {
policies = await this.getAll(PolicyType.MasterPassword); policies = await this.getAll(PolicyType.MasterPassword);
} else { } else {
policies = policies.filter((p) => p.type === PolicyType.MasterPassword); policies = policies.filter(p => p.type === PolicyType.MasterPassword);
} }
if (policies == null || policies.length === 0) { if (policies == null || policies.length === 0) {
return enforcedOptions; return enforcedOptions;
} }
policies.forEach((currentPolicy) => { policies.forEach(currentPolicy => {
if (!currentPolicy.enabled || currentPolicy.data == null) { if (!currentPolicy.enabled || currentPolicy.data == null) {
return; return;
} }

View File

@ -61,7 +61,7 @@ export class SearchService implements SearchServiceAbstraction {
{ extractor: (c: CipherView) => this.attachmentExtractor(c, true) }); { extractor: (c: CipherView) => this.attachmentExtractor(c, true) });
builder.field('organizationid', { extractor: (c: CipherView) => c.organizationId }); builder.field('organizationid', { extractor: (c: CipherView) => c.organizationId });
const ciphers = await this.cipherService.getAllDecrypted(); const ciphers = await this.cipherService.getAllDecrypted();
ciphers.forEach((c) => builder.add(c)); ciphers.forEach(c => builder.add(c));
this.index = builder.build(); this.index = builder.build();
this.indexing = false; this.indexing = false;
@ -85,7 +85,7 @@ export class SearchService implements SearchServiceAbstraction {
} }
if (filter != null && Array.isArray(filter) && filter.length > 0) { if (filter != null && Array.isArray(filter) && filter.length > 0) {
ciphers = ciphers.filter((c) => filter.every((f) => f == null || f(c))); ciphers = ciphers.filter(c => filter.every(f => f == null || f(c)));
} else if (filter != null) { } else if (filter != null) {
ciphers = ciphers.filter(filter as (cipher: CipherView) => boolean); ciphers = ciphers.filter(filter as (cipher: CipherView) => boolean);
} }
@ -95,9 +95,9 @@ export class SearchService implements SearchServiceAbstraction {
} }
if (this.indexing) { if (this.indexing) {
await new Promise((r) => setTimeout(r, 250)); await new Promise(r => setTimeout(r, 250));
if (this.indexing) { if (this.indexing) {
await new Promise((r) => setTimeout(r, 500)); await new Promise(r => setTimeout(r, 500));
} }
} }
@ -108,7 +108,7 @@ export class SearchService implements SearchServiceAbstraction {
} }
const ciphersMap = new Map<string, CipherView>(); const ciphersMap = new Map<string, CipherView>();
ciphers.forEach((c) => ciphersMap.set(c.id, c)); ciphers.forEach(c => ciphersMap.set(c.id, c));
let searchResults: lunr.Index.Result[] = null; let searchResults: lunr.Index.Result[] = null;
const isQueryString = query != null && query.length > 1 && query.indexOf('>') === 0; const isQueryString = query != null && query.length > 1 && query.indexOf('>') === 0;
@ -119,8 +119,8 @@ export class SearchService implements SearchServiceAbstraction {
} else { } else {
// tslint:disable-next-line // tslint:disable-next-line
const soWild = lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING; const soWild = lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING;
searchResults = index.query((q) => { searchResults = index.query(q => {
lunr.tokenizer(query).forEach((token) => { lunr.tokenizer(query).forEach(token => {
const t = token.toString(); const t = token.toString();
q.term(t, { fields: ['name'], wildcard: soWild }); q.term(t, { fields: ['name'], wildcard: soWild });
q.term(t, { fields: ['subtitle'], wildcard: soWild }); q.term(t, { fields: ['subtitle'], wildcard: soWild });
@ -131,7 +131,7 @@ export class SearchService implements SearchServiceAbstraction {
} }
if (searchResults != null) { if (searchResults != null) {
searchResults.forEach((r) => { searchResults.forEach(r => {
if (ciphersMap.has(r.ref)) { if (ciphersMap.has(r.ref)) {
results.push(ciphersMap.get(r.ref)); results.push(ciphersMap.get(r.ref));
} }
@ -142,7 +142,7 @@ export class SearchService implements SearchServiceAbstraction {
searchCiphersBasic(ciphers: CipherView[], query: string, deleted: boolean = false) { searchCiphersBasic(ciphers: CipherView[], query: string, deleted: boolean = false) {
query = query.trim().toLowerCase(); query = query.trim().toLowerCase();
return ciphers.filter((c) => { return ciphers.filter(c => {
if (deleted !== c.isDeleted) { if (deleted !== c.isDeleted) {
return false; return false;
} }
@ -193,7 +193,7 @@ export class SearchService implements SearchServiceAbstraction {
return null; return null;
} }
let fields: string[] = []; let fields: string[] = [];
c.fields.forEach((f) => { c.fields.forEach(f => {
if (f.name != null) { if (f.name != null) {
fields.push(f.name); fields.push(f.name);
} }
@ -201,7 +201,7 @@ export class SearchService implements SearchServiceAbstraction {
fields.push(f.value); fields.push(f.value);
} }
}); });
fields = fields.filter((f) => f.trim() !== ''); fields = fields.filter(f => f.trim() !== '');
if (fields.length === 0) { if (fields.length === 0) {
return null; return null;
} }
@ -213,7 +213,7 @@ export class SearchService implements SearchServiceAbstraction {
return null; return null;
} }
let attachments: string[] = []; let attachments: string[] = [];
c.attachments.forEach((a) => { c.attachments.forEach(a => {
if (a != null && a.fileName != null) { if (a != null && a.fileName != null) {
if (joined && a.fileName.indexOf('.') > -1) { if (joined && a.fileName.indexOf('.') > -1) {
attachments.push(a.fileName.substr(0, a.fileName.lastIndexOf('.'))); attachments.push(a.fileName.substr(0, a.fileName.lastIndexOf('.')));
@ -222,7 +222,7 @@ export class SearchService implements SearchServiceAbstraction {
} }
} }
}); });
attachments = attachments.filter((f) => f.trim() !== ''); attachments = attachments.filter(f => f.trim() !== '');
if (attachments.length === 0) { if (attachments.length === 0) {
return null; return null;
} }
@ -234,7 +234,7 @@ export class SearchService implements SearchServiceAbstraction {
return null; return null;
} }
const uris: string[] = []; const uris: string[] = [];
c.login.uris.forEach((u) => { c.login.uris.forEach(u => {
if (u.uri == null || u.uri === '') { if (u.uri == null || u.uri === '') {
return; return;
} }

View File

@ -115,8 +115,8 @@ export class SendService implements SendServiceAbstraction {
const decSends: SendView[] = []; const decSends: SendView[] = [];
const promises: Promise<any>[] = []; const promises: Promise<any>[] = [];
const sends = await this.getAll(); const sends = await this.getAll();
sends.forEach((send) => { sends.forEach(send => {
promises.push(send.decrypt().then((f) => decSends.push(f))); promises.push(send.decrypt().then(f => decSends.push(f)));
}); });
await Promise.all(promises); await Promise.all(promises);
@ -173,7 +173,7 @@ export class SendService implements SendServiceAbstraction {
const s = send as SendData; const s = send as SendData;
sends[s.id] = s; sends[s.id] = s;
} else { } else {
(send as SendData[]).forEach((s) => { (send as SendData[]).forEach(s => {
sends[s.id] = s; sends[s.id] = s;
}); });
} }
@ -207,7 +207,7 @@ export class SendService implements SendServiceAbstraction {
} }
delete sends[id]; delete sends[id];
} else { } else {
(id as string[]).forEach((i) => { (id as string[]).forEach(i => {
delete sends[i]; delete sends[i];
}); });
} }
@ -232,7 +232,7 @@ export class SendService implements SendServiceAbstraction {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();
reader.readAsArrayBuffer(file); reader.readAsArrayBuffer(file);
reader.onload = async (evt) => { reader.onload = async evt => {
try { try {
const [name, data] = await this.encryptFileData(file.name, evt.target.result as ArrayBuffer, key); const [name, data] = await this.encryptFileData(file.name, evt.target.result as ArrayBuffer, key);
send.file.fileName = name; send.file.fileName = name;
@ -241,7 +241,7 @@ export class SendService implements SendServiceAbstraction {
reject(e); reject(e);
} }
}; };
reader.onerror = (evt) => { reader.onerror = evt => {
reject('Error reading file.'); reject('Error reading file.');
}; };
}); });

View File

@ -290,7 +290,7 @@ export class SyncService implements SyncServiceAbstraction {
await this.userService.setSecurityStamp(response.securityStamp); await this.userService.setSecurityStamp(response.securityStamp);
const organizations: { [id: string]: OrganizationData; } = {}; const organizations: { [id: string]: OrganizationData; } = {};
response.organizations.forEach((o) => { response.organizations.forEach(o => {
organizations[o.id] = new OrganizationData(o); organizations[o.id] = new OrganizationData(o);
}); });
return await this.userService.replaceOrganizations(organizations); return await this.userService.replaceOrganizations(organizations);
@ -298,7 +298,7 @@ export class SyncService implements SyncServiceAbstraction {
private async syncFolders(userId: string, response: FolderResponse[]) { private async syncFolders(userId: string, response: FolderResponse[]) {
const folders: { [id: string]: FolderData; } = {}; const folders: { [id: string]: FolderData; } = {};
response.forEach((f) => { response.forEach(f => {
folders[f.id] = new FolderData(f, userId); folders[f.id] = new FolderData(f, userId);
}); });
return await this.folderService.replace(folders); return await this.folderService.replace(folders);
@ -306,7 +306,7 @@ export class SyncService implements SyncServiceAbstraction {
private async syncCollections(response: CollectionDetailsResponse[]) { private async syncCollections(response: CollectionDetailsResponse[]) {
const collections: { [id: string]: CollectionData; } = {}; const collections: { [id: string]: CollectionData; } = {};
response.forEach((c) => { response.forEach(c => {
collections[c.id] = new CollectionData(c); collections[c.id] = new CollectionData(c);
}); });
return await this.collectionService.replace(collections); return await this.collectionService.replace(collections);
@ -314,7 +314,7 @@ export class SyncService implements SyncServiceAbstraction {
private async syncCiphers(userId: string, response: CipherResponse[]) { private async syncCiphers(userId: string, response: CipherResponse[]) {
const ciphers: { [id: string]: CipherData; } = {}; const ciphers: { [id: string]: CipherData; } = {};
response.forEach((c) => { response.forEach(c => {
ciphers[c.id] = new CipherData(c, userId); ciphers[c.id] = new CipherData(c, userId);
}); });
return await this.cipherService.replace(ciphers); return await this.cipherService.replace(ciphers);
@ -322,7 +322,7 @@ export class SyncService implements SyncServiceAbstraction {
private async syncSends(userId: string, response: SendResponse[]) { private async syncSends(userId: string, response: SendResponse[]) {
const sends: { [id: string]: SendData; } = {}; const sends: { [id: string]: SendData; } = {};
response.forEach((s) => { response.forEach(s => {
sends[s.id] = new SendData(s, userId); sends[s.id] = new SendData(s, userId);
}); });
return await this.sendService.replace(sends); return await this.sendService.replace(sends);
@ -335,7 +335,7 @@ export class SyncService implements SyncServiceAbstraction {
} }
if (response != null && response.globalEquivalentDomains != null) { if (response != null && response.globalEquivalentDomains != null) {
response.globalEquivalentDomains.forEach((global) => { response.globalEquivalentDomains.forEach(global => {
if (global.domains.length > 0) { if (global.domains.length > 0) {
eqDomains.push(global.domains); eqDomains.push(global.domains);
} }
@ -348,7 +348,7 @@ export class SyncService implements SyncServiceAbstraction {
private async syncPolicies(response: PolicyResponse[]) { private async syncPolicies(response: PolicyResponse[]) {
const policies: { [id: string]: PolicyData; } = {}; const policies: { [id: string]: PolicyData; } = {};
if (response != null) { if (response != null) {
response.forEach((p) => { response.forEach(p => {
policies[p.id] = new PolicyData(p); policies[p.id] = new PolicyData(p);
}); });
} }

View File

@ -59,7 +59,7 @@ export class SystemService implements SystemServiceAbstraction {
if (Utils.isNullOrWhitespace(clipboardValue)) { if (Utils.isNullOrWhitespace(clipboardValue)) {
return; return;
} }
this.storageService.get<number>(ConstantsService.clearClipboardKey).then((clearSeconds) => { this.storageService.get<number>(ConstantsService.clearClipboardKey).then(clearSeconds => {
if (clearSeconds == null) { if (clearSeconds == null) {
return; return;
} }

View File

@ -52,6 +52,10 @@
"check-type" "check-type"
], ],
"max-classes-per-file": false, "max-classes-per-file": false,
"arrow-parens": [
true,
"ban-single-arg-parens"
],
"semicolon": [ "semicolon": [
true, true,
"always" "always"