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