1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

export uris

This commit is contained in:
Kyle Spearrin 2018-03-24 20:28:11 -04:00
parent 9ffb2a406d
commit 1802938b9e

View File

@ -6,6 +6,9 @@ import { BrowserApi } from '../../../browser/browserApi';
import { CipherType } from 'jslib/enums/cipherType'; import { CipherType } from 'jslib/enums/cipherType';
import { CipherView } from 'jslib/models/view/cipherView';
import { FolderView } from 'jslib/models/view/folderView';
import { CipherService } from 'jslib/abstractions/cipher.service'; import { CipherService } from 'jslib/abstractions/cipher.service';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { FolderService } from 'jslib/abstractions/folder.service'; import { FolderService } from 'jslib/abstractions/folder.service';
@ -59,27 +62,27 @@ export class ExportController {
} }
private async getCsv(): Promise<string> { private async getCsv(): Promise<string> {
let decFolders: any[] = []; let decFolders: FolderView[] = [];
let decCiphers: any[] = []; let decCiphers: CipherView[] = [];
const promises = []; const promises = [];
promises.push(this.folderService.getAllDecrypted().then((folders: any[]) => { promises.push(this.folderService.getAllDecrypted().then((folders) => {
decFolders = folders; decFolders = folders;
})); }));
promises.push(this.cipherService.getAllDecrypted().then((ciphers: any[]) => { promises.push(this.cipherService.getAllDecrypted().then((ciphers) => {
decCiphers = ciphers; decCiphers = ciphers;
})); }));
await Promise.all(promises); await Promise.all(promises);
const foldersMap = new Map<string, any>(); const foldersMap = new Map<string, FolderView>();
decFolders.forEach((f: any) => { decFolders.forEach((f) => {
foldersMap.set(f.id, f); foldersMap.set(f.id, f);
}); });
const exportCiphers: any[] = []; const exportCiphers: any[] = [];
decCiphers.forEach((c: any) => { decCiphers.forEach((c) => {
// only export logins and secure notes // only export logins and secure notes
if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) { if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
return; return;
@ -114,10 +117,16 @@ export class ExportController {
switch (c.type) { switch (c.type) {
case CipherType.Login: case CipherType.Login:
cipher.type = 'login'; cipher.type = 'login';
cipher.login_uri = c.login.uri;
cipher.login_username = c.login.username; cipher.login_username = c.login.username;
cipher.login_password = c.login.password; cipher.login_password = c.login.password;
cipher.login_totp = c.login.totp; cipher.login_totp = c.login.totp;
if (c.login.uris) {
cipher.login_uri = [];
c.login.uris.forEach((u) => {
cipher.login_uri.push(u.uri);
});
}
break; break;
case CipherType.SecureNote: case CipherType.SecureNote:
cipher.type = 'note'; cipher.type = 'note';