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/**/*",
"build": "npm run clean && tsc",
"build:watch": "npm run clean && tsc -watch",
"lint": "tslint src/**/*.ts spec/**/*.ts",
"lint:fix": "tslint src/**/*.ts spec/**/*.ts --fix",
"lint": "tslint 'src/**/*.ts' 'spec/**/*.ts'",
"lint:fix": "tslint 'src/**/*.ts' 'spec/**/*.ts' --fix",
"test": "karma start ./spec/support/karma.conf.js --single-run",
"test:watch": "karma start ./spec/support/karma.conf.js",
"test:node": "npm run build && jasmine",

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
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
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);

View File

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

View File

@ -159,7 +159,7 @@ export class AddEditComponent implements OnInit {
const myEmail = await this.userService.getEmail();
this.ownershipOptions.push({ name: myEmail, value: null });
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) {
this.ownershipOptions.push({ name: o.name, value: o.id });
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)) {
await this.organizationChanged();
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) {
(c as any).checked = true;
}
@ -273,7 +273,7 @@ export class AddEditComponent implements OnInit {
// Allows saving of selected collections during "Add" and "Clone" flows
if ((!this.editMode || this.cloneMode) && this.cipher.organizationId != 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
@ -459,10 +459,10 @@ export class AddEditComponent implements OnInit {
async organizationChanged() {
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) {
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);
if (org != null) {
this.cipher.organizationUseTotp = org.useTotp;
@ -496,7 +496,7 @@ export class AddEditComponent implements OnInit {
protected async loadCollections() {
const allCollections = await this.collectionService.getAllDecrypted();
return allCollections.filter((c) => !c.readOnly);
return allCollections.filter(c => !c.readOnly);
}
protected loadCipher() {

View File

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

View File

@ -82,7 +82,7 @@ export class CiphersComponent {
if (this.searchTimeout != null) {
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) {
this.ciphers = await this.searchService.searchCiphers(this.searchText, [this.filter, deletedFilter], null);
await this.resetPaging();

View File

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

View File

@ -79,7 +79,7 @@ export class GroupingsComponent {
}
const collections = await this.collectionService.getAllDecrypted();
if (organizationId != null) {
this.collections = collections.filter((c) => c.organizationId === organizationId);
this.collections = collections.filter(c => c.organizationId === organizationId);
} else {
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"]'));
for (const closeElement of modals) {
closeElement.addEventListener('click', (event) => {
closeElement.addEventListener('click', event => {
this.close();
});
}

View File

@ -100,13 +100,13 @@ export class SendComponent implements OnInit {
clearTimeout(this.searchTimeout);
}
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();
return;
}
this.searchPending = true;
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.searchPending = false;
}, timeout);
@ -189,7 +189,7 @@ export class SendComponent implements OnInit {
selectType(type: SendType) {
this.clearSelections();
this.selectedType = type;
this.applyFilter((s) => s.type === type);
this.applyFilter(s => s.type === type);
}
clearSelections() {

View File

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

View File

@ -43,10 +43,10 @@ export class ShareComponent implements OnInit {
async load() {
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();
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);
this.cipher = await cipherDomain.decrypt();
@ -57,18 +57,18 @@ export class ShareComponent implements OnInit {
}
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) {
this.collections = [];
} 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> {
const selectedCollectionIds = this.collections
.filter((c) => !!(c as any).checked)
.map((c) => c.id);
.filter(c => !!(c as any).checked)
.map(c => c.id);
if (selectedCollectionIds.length === 0) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('selectOneCollection'));

View File

@ -45,7 +45,7 @@ export class SsoComponent {
protected passwordGenerationService: PasswordGenerationService) { }
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) {
const codeVerifier = await this.storageService.get<string>(ConstantsService.ssoCodeVerifierKey);
const state = await this.storageService.get<string>(ConstantsService.ssoStateKey);

View File

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

View File

@ -18,7 +18,7 @@ export class BoxRowDirective implements OnInit {
ngOnInit(): void {
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) => {
this.el.classList.add('active');
}, false);

View File

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

View File

@ -17,7 +17,7 @@ export class SearchPipe implements PipeTransform {
}
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) {
return true;
}

View File

@ -175,7 +175,7 @@ export class LoginCommand {
if (twoFactorMethod != null) {
try {
selectedProvider = twoFactorProviders.filter((p) => p.type === twoFactorMethod)[0];
selectedProvider = twoFactorProviders.filter(p => p.type === twoFactorMethod)[0];
} catch (e) {
return Response.error('Invalid two-step login method.');
}
@ -185,7 +185,7 @@ export class LoginCommand {
if (twoFactorProviders.length === 1) {
selectedProvider = twoFactorProviders[0];
} 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('Cancel');
const answer: inquirer.Answers =

View File

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

View File

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

View File

@ -89,7 +89,7 @@ export class UpdaterMain {
this.reset();
});
autoUpdater.on('update-downloaded', async (info) => {
autoUpdater.on('update-downloaded', async info => {
if (this.onUpdateDownloaded != null) {
this.onUpdateDownloaded();
}
@ -114,7 +114,7 @@ export class UpdaterMain {
}
});
autoUpdater.on('error', (error) => {
autoUpdater.on('error', error => {
if (this.doingUpdateCheckWithFeedback) {
dialog.showErrorBox(this.i18nService.t('updateError'),
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);
}
results.forEach((value) => {
results.forEach(value => {
if (value.length < 2) {
return;
}

View File

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

View File

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

View File

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

View File

@ -23,10 +23,10 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach((value) => {
results.forEach(value => {
if (this.organization && !this.isNullOrWhitespace(value.collections)) {
const collections = (value.collections as string).split(',');
collections.forEach((col) => {
collections.forEach(col => {
let addCollection = true;
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)) {
this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]);
} else if (this.organization && c.collectionIds != null) {
c.collectionIds.forEach((cId) => {
c.collectionIds.forEach(cId => {
if (groupingsMap.has(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)) {
this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]);
} else if (this.organization && c.collectionIds != null) {
c.collectionIds.forEach((cId) => {
c.collectionIds.forEach(cId => {
if (groupingsMap.has(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);
}
results.forEach((value) => {
results.forEach(value => {
if (value.grouping === 'list') {
return;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -49,11 +49,11 @@ export class KeePass2XmlImporter extends BaseImporter implements Importer {
this.result.folders.push(folder);
}
this.querySelectorAllDirectChild(node, 'Entry').forEach((entry) => {
this.querySelectorAllDirectChild(node, 'Entry').forEach(entry => {
const cipherIndex = this.result.ciphers.length;
const cipher = this.initLoginCipher();
this.querySelectorAllDirectChild(entry, 'String').forEach((entryString) => {
this.querySelectorAllDirectChild(entry, 'String').forEach(entryString => {
const valueEl = this.querySelectorDirectChild(entryString, 'Value');
const value = valueEl != null ? valueEl.textContent : null;
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);
});
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ export class PasswordDragonXmlImporter extends BaseImporter implements Importer
}
const records = doc.querySelectorAll('PasswordManager > record');
Array.from(records).forEach((record) => {
Array.from(records).forEach(record => {
const category = this.querySelectorDirectChild(record, 'Category');
const categoryText = category != null && !this.isNullOrWhitespace(category.textContent) &&
category.textContent !== 'Unfiled' ? category.textContent : null;
@ -36,7 +36,7 @@ export class PasswordDragonXmlImporter extends BaseImporter implements Importer
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') {
return;
}

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ export class RoboFormCsvImporter extends BaseImporter implements Importer {
}
let i = 1;
results.forEach((value) => {
results.forEach(value => {
const folder = !this.isNullOrWhitespace(value.Folder) && value.Folder.startsWith('/') ?
value.Folder.replace('/', '') : value.Folder;
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>();
Array.from(doc.querySelectorAll('database > label')).forEach((labelEl) => {
Array.from(doc.querySelectorAll('database > label')).forEach(labelEl => {
const name = labelEl.getAttribute('name');
const id = labelEl.getAttribute('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') {
return;
}
@ -60,7 +60,7 @@ export class SafeInCloudXmlImporter extends BaseImporter implements Importer {
cipher.secureNote = new SecureNoteView();
cipher.secureNote.type = SecureNoteType.Generic;
} else {
Array.from(this.querySelectorAllDirectChild(cardEl, 'field')).forEach((fieldEl) => {
Array.from(this.querySelectorAllDirectChild(cardEl, 'field')).forEach(fieldEl => {
const text = fieldEl.textContent;
if (this.isNullOrWhitespace(text)) {
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');
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -109,7 +109,7 @@ export class Analytics {
}
const pathParts = pagePath.split('/');
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)) {
newPathParts.push('__guid__');
} else {

View File

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

View File

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

View File

@ -159,7 +159,7 @@ export class Utils {
// ref: http://stackoverflow.com/a/2117523/1090359
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
const r = Math.random() * 16 | 0;
// tslint:disable-next-line
@ -242,7 +242,7 @@ export class Utils {
}
const map = new Map<string, string>();
const pairs = (url.search[0] === '?' ? url.search.substr(1) : url.search).split('&');
pairs.forEach((pair) => {
pairs.forEach(pair => {
const parts = pair.split('=');
if (parts.length < 1) {
return;
@ -289,7 +289,7 @@ export class Utils {
private static isMobile(win: Window) {
let mobile = false;
((a) => {
(a => {
// 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))) {
mobile = true;

View File

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

View File

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

View File

@ -39,7 +39,7 @@ export class Cipher {
view.favorite = req.favorite;
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) {
@ -71,7 +71,7 @@ export class Cipher {
domain.favorite = req.favorite;
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) {
@ -122,9 +122,9 @@ export class Cipher {
if (o.fields != null) {
if (o instanceof CipherView) {
this.fields = o.fields.map((f) => new Field(f));
this.fields = o.fields.map(f => new Field(f));
} 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()) {
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.password = req.password;
@ -27,7 +27,7 @@ export class Login {
static toDomain(req: Login, domain = new LoginDomain()) {
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.password = req.password != null ? new CipherString(req.password) : null;
@ -47,9 +47,9 @@ export class Login {
if (o.uris != null) {
if (o instanceof LoginView) {
this.uris = o.uris.map((u) => new LoginUri(u));
this.uris = o.uris.map(u => new LoginUri(u));
} 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[]) {
if (ciphers != null) {
this.ciphers = [];
ciphers.forEach((c) => {
ciphers.forEach(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;
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();
uri.uri = u.uri != null ? u.uri.encryptedString : null;
uri.match = u.match != null ? u.match : null;
@ -110,7 +110,7 @@ export class CipherRequest {
}
if (cipher.fields != null) {
this.fields = cipher.fields.map((f) => {
this.fields = cipher.fields.map(f => {
const field = new FieldApi();
field.type = f.type;
field.name = f.name ? f.name.encryptedString : null;
@ -121,7 +121,7 @@ export class CipherRequest {
if (cipher.passwordHistory != null) {
this.passwordHistory = [];
cipher.passwordHistory.forEach((ph) => {
cipher.passwordHistory.forEach(ph => {
this.passwordHistory.push({
lastUsedDate: ph.lastUsedDate,
password: ph.password ? ph.password.encryptedString : null,
@ -132,7 +132,7 @@ export class CipherRequest {
if (cipher.attachments != null) {
this.attachments = {};
this.attachments2 = {};
cipher.attachments.forEach((attachment) => {
cipher.attachments.forEach(attachment => {
const fileName = attachment.fileName ? attachment.fileName.encryptedString : null;
this.attachments[attachment.id] = fileName;
const attachmentRequest = new AttachmentRequest();

View File

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

View File

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

View File

@ -22,7 +22,7 @@ export class AuditService implements AuditServiceAbstraction {
const response = await this.apiService.nativeFetch(new Request(PwnedPasswordsApi + hashStart));
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;
});

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ export class EventService implements EventServiceAbstraction {
if (organizations == null) {
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) {
return;
}
@ -73,7 +73,7 @@ export class EventService implements EventServiceAbstraction {
if (eventCollection == null || eventCollection.length === 0) {
return;
}
const request = eventCollection.map((e) => {
const request = eventCollection.map(e => {
const req = new EventRequest();
req.type = e.type;
req.cipherId = e.cipherId;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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