mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
lint fixes
This commit is contained in:
@@ -2,9 +2,12 @@ import { CipherString } from '../domain/cipherString';
|
||||
|
||||
export default abstract class Domain {
|
||||
protected buildDomainModel(model: any, obj: any, map: any, alreadyEncrypted: boolean, notEncList: any = []) {
|
||||
for (var prop in map) {
|
||||
if (map.hasOwnProperty(prop)) {
|
||||
var objProp = obj[(map[prop] || prop)];
|
||||
for (const prop in map) {
|
||||
if (!map.hasOwnProperty(prop)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const objProp = obj[(map[prop] || prop)];
|
||||
if (alreadyEncrypted === true || notEncList.indexOf(prop) > -1) {
|
||||
model[prop] = objProp ? objProp : null;
|
||||
} else {
|
||||
@@ -12,27 +15,27 @@ export default abstract class Domain {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async decryptObj(model: any, self: any, map: any, orgId: string) {
|
||||
var promises = [];
|
||||
for (let prop in map) {
|
||||
const promises = [];
|
||||
for (const prop in map) {
|
||||
if (!map.hasOwnProperty(prop)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line
|
||||
(function (theProp) {
|
||||
let promise = Promise.resolve().then(function () {
|
||||
var mapProp = map[theProp] || theProp;
|
||||
const p = Promise.resolve().then(() => {
|
||||
const mapProp = map[theProp] || theProp;
|
||||
if (self[mapProp]) {
|
||||
return self[mapProp].decrypt(orgId);
|
||||
}
|
||||
return null;
|
||||
}).then(function (val) {
|
||||
}).then((val: any) => {
|
||||
model[theProp] = val;
|
||||
return;
|
||||
});
|
||||
promises.push(promise);
|
||||
promises.push(p);
|
||||
})(prop);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CipherString } from './cipherString';
|
||||
import { FolderData } from '../data/folderData'
|
||||
import { FolderData } from '../data/folderData';
|
||||
|
||||
import Domain from './domain'
|
||||
import { CipherString } from './cipherString';
|
||||
import Domain from './domain';
|
||||
|
||||
class Folder extends Domain {
|
||||
id: string;
|
||||
@@ -15,18 +15,17 @@ class Folder extends Domain {
|
||||
|
||||
this.buildDomainModel(this, obj, {
|
||||
id: null,
|
||||
name: null
|
||||
name: null,
|
||||
}, alreadyEncrypted, ['id']);
|
||||
}
|
||||
|
||||
async decrypt(): Promise<any> {
|
||||
var self = this;
|
||||
var model = {
|
||||
id: self.id
|
||||
const model = {
|
||||
id: this.id,
|
||||
};
|
||||
|
||||
return await this.decryptObj(model, this, {
|
||||
name: null
|
||||
name: null,
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import ServicesModule from './services/services.module';
|
||||
import LockModule from './lock/lock.module';
|
||||
|
||||
// Model imports
|
||||
import { Folder } from './models/domain/folder';
|
||||
import { Folder } from '../../models/domain/folder';
|
||||
|
||||
import { AttachmentData } from '../../models/data/attachmentData';
|
||||
import { CardData } from '../../models/data/cardData';
|
||||
|
||||
@@ -82,10 +82,10 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.identityBaseUrl + '/connect/token', {
|
||||
body: this.qsStringify(request.toIdentityToken()),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -114,9 +114,9 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/two-factor/send-email-login', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -132,10 +132,10 @@ export default class ApiService {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.baseUrl + '/accounts/revision-date', {
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
Accept: 'application/json',
|
||||
Authorization: authHeader,
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
if (response.status === 200) {
|
||||
@@ -150,9 +150,9 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/accounts/password-hint', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -166,9 +166,9 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/accounts/register', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -185,11 +185,11 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/folders', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Authorization': authHeader,
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -207,11 +207,11 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/folders/' + id, {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Authorization': authHeader,
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'PUT',
|
||||
}));
|
||||
|
||||
@@ -228,9 +228,9 @@ export default class ApiService {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.baseUrl + '/folders/' + id, {
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
Authorization: authHeader,
|
||||
},
|
||||
}),
|
||||
method: 'DELETE',
|
||||
}));
|
||||
|
||||
@@ -247,11 +247,11 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/ciphers', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Authorization': authHeader,
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -269,11 +269,11 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/ciphers/' + id, {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Authorization': authHeader,
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
}),
|
||||
method: 'PUT',
|
||||
}));
|
||||
|
||||
@@ -290,9 +290,9 @@ export default class ApiService {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.baseUrl + '/ciphers/' + id, {
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
Authorization: authHeader,
|
||||
},
|
||||
}),
|
||||
method: 'DELETE',
|
||||
}));
|
||||
|
||||
@@ -309,10 +309,10 @@ export default class ApiService {
|
||||
const response = await fetch(new Request(this.baseUrl + '/ciphers/' + id + '/attachment', {
|
||||
body: data,
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
Accept: 'application/json',
|
||||
Authorization: authHeader,
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
@@ -329,9 +329,9 @@ export default class ApiService {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.baseUrl + '/ciphers/' + id + '/attachment/' + attachmentId, {
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
Authorization: authHeader,
|
||||
},
|
||||
}),
|
||||
method: 'DELETE',
|
||||
}));
|
||||
|
||||
@@ -347,10 +347,10 @@ export default class ApiService {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.baseUrl + '/sync', {
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
Accept: 'application/json',
|
||||
Authorization: authHeader,
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
if (response.status === 200) {
|
||||
@@ -407,10 +407,10 @@ export default class ApiService {
|
||||
refresh_token: refreshToken,
|
||||
}),
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { CipherString } from '../models/domain/cipherString';
|
||||
import { Folder } from '../models/domain/folder';
|
||||
|
||||
import { FolderData } from '../models/data/folderData';
|
||||
import { FolderResponse } from '../models/response/folderResponse';
|
||||
|
||||
import { FolderRequest } from '../models/request/folderRequest';
|
||||
import { FolderResponse } from '../models/response/folderResponse';
|
||||
|
||||
import ApiService from './api.service';
|
||||
import ConstantsService from './constants.service';
|
||||
@@ -11,14 +13,14 @@ import UserService from './user.service';
|
||||
import UtilsService from './utils.service';
|
||||
|
||||
const Keys = {
|
||||
foldersPrefix: 'folders_'
|
||||
foldersPrefix: 'folders_',
|
||||
};
|
||||
|
||||
export default class FolderService {
|
||||
decryptedFolderCache: any[];
|
||||
|
||||
constructor(private cryptoService: CryptoService, private userService: UserService, private i18nService: any, private apiService: ApiService) {
|
||||
|
||||
constructor(private cryptoService: CryptoService, private userService: UserService,
|
||||
private i18nService: any, private apiService: ApiService) {
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
@@ -58,7 +60,7 @@ export default class FolderService {
|
||||
|
||||
const decFolders: any[] = [{
|
||||
id: null,
|
||||
name: this.i18nService.noneFolder
|
||||
name: this.i18nService.noneFolder,
|
||||
}];
|
||||
|
||||
const key = await this.cryptoService.getKey();
|
||||
@@ -128,7 +130,7 @@ export default class FolderService {
|
||||
|
||||
async delete(id: string | string[]): Promise<any> {
|
||||
const userId = await this.userService.getUserId();
|
||||
let folders = await UtilsService.getObjFromStorage<Map<string, FolderData>>(Keys.foldersPrefix + userId);
|
||||
const folders = await UtilsService.getObjFromStorage<Map<string, FolderData>>(Keys.foldersPrefix + userId);
|
||||
if (folders == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user