mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-23 16:38:45 +01:00
[PM-328] Move exporter to tools (#5070)
* Create and register new libs/exporter Create package.json Create tsconfig Create jest.config Extend shared and root tsconfig and jest.configs Register with eslint * Migrate exportService to libs/exporter Move exportService (abstraction and impl) into libs/exporter Refactored exportService to be split into vault-export and event-export Created barrel-files for both exports Moved export.service.spec.ts into vault-export Created an export-helper, which helps build the filename (extract method refactor from ExportService) * Move components in libs/angular into tools-subfolder Moved components Updated imports in jslib-services.module and jslib.module * Register libs/exporter with browser and fix imports Move export.component into tools-subfolder * Register libs/exporter with cli and fix imports Move export.command into tools-subfolder * Register libs/exporter with desktop and fix imports Move export.component into tools-subfolder * Move export models to libs/exporter * Update web imports * Update package-lock.json * Move export models back as it would create circular dependency Reponse models in common rely on export models which are in libs/exporter, which relies on common * Fix up web for event-export * Update CODEOWNERS * Add export-models to team-tools-dev * Simplify domain import * Moving EventExport into web
This commit is contained in:
parent
830af7b06d
commit
192bb5a7b3
@ -102,6 +102,10 @@
|
||||
{
|
||||
"target": "./libs/common/**/*",
|
||||
"from": "./libs/importer/**/*"
|
||||
},
|
||||
{
|
||||
"target": "./libs/common/**/*",
|
||||
"from": "./libs/exporter/**/*"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -160,6 +164,12 @@
|
||||
"rules": {
|
||||
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/importer/*", "src/**/*"] }]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["libs/exporter/src/**/*.ts"],
|
||||
"rules": {
|
||||
"no-restricted-imports": ["error", { "patterns": ["@bitwarden/exporter/*", "src/**/*"] }]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@ -25,7 +25,9 @@ apps/cli/src/app/tools @bitwarden/team-tools-dev
|
||||
apps/desktop/src/app/tools @bitwarden/team-tools-dev
|
||||
apps/web/src/app/tools @bitwarden/team-tools-dev
|
||||
libs/angular/src/tools @bitwarden/team-tools-dev
|
||||
libs/common/src/models/export @bitwarden/team-tools-dev
|
||||
libs/common/src/tools @bitwarden/team-tools-dev
|
||||
libs/exporter @bitwarden/team-tools-dev
|
||||
libs/importer @bitwarden/team-tools-dev
|
||||
|
||||
## Vault team files ##
|
||||
@ -49,4 +51,4 @@ libs/common/src/admin-console @bitwarden/team-admin-console-dev
|
||||
## Billing team files ##
|
||||
apps/web/src/app/billing @bitwarden/team-billing-dev
|
||||
libs/angular/src/billing @bitwarden/team-billing-dev
|
||||
libs/common/src/billing @bitwarden/team-billing-dev
|
||||
libs/common/src/billing @bitwarden/team-billing-dev
|
||||
|
@ -7,7 +7,6 @@ import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitw
|
||||
import { EncryptService } from "@bitwarden/common/abstractions/encrypt.service";
|
||||
import { EventCollectionService as EventCollectionServiceAbstraction } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/common/abstractions/event/event-upload.service";
|
||||
import { ExportService as ExportServiceAbstraction } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/abstractions/file-upload/file-upload.service";
|
||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService as LogServiceAbstraction } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -56,7 +55,6 @@ import { EncryptServiceImplementation } from "@bitwarden/common/services/cryptog
|
||||
import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/services/cryptography/multithread-encrypt.service.implementation";
|
||||
import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service";
|
||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { FileUploadService } from "@bitwarden/common/services/file-upload/file-upload.service";
|
||||
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
|
||||
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
|
||||
@ -89,6 +87,10 @@ import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-u
|
||||
import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder-api.service";
|
||||
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
|
||||
import { SyncService } from "@bitwarden/common/vault/services/sync/sync.service";
|
||||
import {
|
||||
VaultExportService,
|
||||
VaultExportServiceAbstraction,
|
||||
} from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { BrowserOrganizationService } from "../admin-console/services/browser-organization.service";
|
||||
import { BrowserPolicyService } from "../admin-console/services/browser-policy.service";
|
||||
@ -155,7 +157,7 @@ export default class MainBackground {
|
||||
containerService: ContainerService;
|
||||
auditService: AuditServiceAbstraction;
|
||||
authService: AuthServiceAbstraction;
|
||||
exportService: ExportServiceAbstraction;
|
||||
exportService: VaultExportServiceAbstraction;
|
||||
searchService: SearchServiceAbstraction;
|
||||
notificationsService: NotificationsServiceAbstraction;
|
||||
stateService: StateServiceAbstraction;
|
||||
@ -463,7 +465,7 @@ export default class MainBackground {
|
||||
this.settingsService
|
||||
);
|
||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||
this.exportService = new ExportService(
|
||||
this.exportService = new VaultExportService(
|
||||
this.folderService,
|
||||
this.cipherService,
|
||||
this.apiService,
|
||||
|
@ -23,6 +23,7 @@ import { PasswordGeneratorHistoryComponent } from "../tools/popup/generator/pass
|
||||
import { SendAddEditComponent } from "../tools/popup/send/send-add-edit.component";
|
||||
import { SendGroupingsComponent } from "../tools/popup/send/send-groupings.component";
|
||||
import { SendTypeComponent } from "../tools/popup/send/send-type.component";
|
||||
import { ExportComponent } from "../tools/popup/settings/export.component";
|
||||
import { AddEditComponent } from "../vault/popup/components/vault/add-edit.component";
|
||||
import { AttachmentsComponent } from "../vault/popup/components/vault/attachments.component";
|
||||
import { CollectionsComponent } from "../vault/popup/components/vault/collections.component";
|
||||
@ -36,7 +37,6 @@ import { ViewComponent } from "../vault/popup/components/vault/view.component";
|
||||
import { DebounceNavigationService } from "./services/debounceNavigationService";
|
||||
import { AutofillComponent } from "./settings/autofill.component";
|
||||
import { ExcludedDomainsComponent } from "./settings/excluded-domains.component";
|
||||
import { ExportComponent } from "./settings/export.component";
|
||||
import { FolderAddEditComponent } from "./settings/folder-add-edit.component";
|
||||
import { FoldersComponent } from "./settings/folders.component";
|
||||
import { HelpAndFeedbackComponent } from "./settings/help-and-feedback.component";
|
||||
|
@ -39,6 +39,7 @@ import { EffluxDatesComponent as SendEffluxDatesComponent } from "../tools/popup
|
||||
import { SendAddEditComponent } from "../tools/popup/send/send-add-edit.component";
|
||||
import { SendGroupingsComponent } from "../tools/popup/send/send-groupings.component";
|
||||
import { SendTypeComponent } from "../tools/popup/send/send-type.component";
|
||||
import { ExportComponent } from "../tools/popup/settings/export.component";
|
||||
import { ActionButtonsComponent } from "../vault/popup/components/action-buttons.component";
|
||||
import { CipherRowComponent } from "../vault/popup/components/cipher-row.component";
|
||||
import { PasswordRepromptComponent } from "../vault/popup/components/password-reprompt.component";
|
||||
@ -65,7 +66,6 @@ import { ServicesModule } from "./services/services.module";
|
||||
import { AboutComponent } from "./settings/about.component";
|
||||
import { AutofillComponent } from "./settings/autofill.component";
|
||||
import { ExcludedDomainsComponent } from "./settings/excluded-domains.component";
|
||||
import { ExportComponent } from "./settings/export.component";
|
||||
import { FolderAddEditComponent } from "./settings/folder-add-edit.component";
|
||||
import { FoldersComponent } from "./settings/folders.component";
|
||||
import { HelpAndFeedbackComponent } from "./settings/help-and-feedback.component";
|
||||
|
@ -17,7 +17,6 @@ import { EncryptService } from "@bitwarden/common/abstractions/encrypt.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { EventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileUploadService } from "@bitwarden/common/abstractions/file-upload/file-upload.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
|
||||
@ -79,6 +78,7 @@ import {
|
||||
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@bitwarden/common/vault/abstractions/password-reprompt.service";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder-api.service";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { BrowserOrganizationService } from "../../admin-console/services/browser-organization.service";
|
||||
import { BrowserPolicyService } from "../../admin-console/services/browser-policy.service";
|
||||
@ -342,7 +342,11 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
useFactory: getBgService<AutofillService>("autofillService"),
|
||||
deps: [],
|
||||
},
|
||||
{ provide: ExportService, useFactory: getBgService<ExportService>("exportService"), deps: [] },
|
||||
{
|
||||
provide: VaultExportServiceAbstraction,
|
||||
useFactory: getBgService<VaultExportServiceAbstraction>("exportService"),
|
||||
deps: [],
|
||||
},
|
||||
{
|
||||
provide: KeyConnectorService,
|
||||
useFactory: getBgService<KeyConnectorService>("keyConnectorService"),
|
||||
|
@ -2,16 +2,16 @@ import { Component } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/tools/export/components/export.component";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
@Component({
|
||||
selector: "app-export",
|
||||
@ -22,7 +22,7 @@ export class ExportComponent extends BaseExportComponent {
|
||||
cryptoService: CryptoService,
|
||||
i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
exportService: ExportService,
|
||||
exportService: VaultExportServiceAbstraction,
|
||||
eventCollectionService: EventCollectionService,
|
||||
policyService: PolicyService,
|
||||
private router: Router,
|
@ -11,7 +11,8 @@
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"]
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
||||
},
|
||||
"useDefineForClassFields": false
|
||||
},
|
||||
|
@ -30,7 +30,6 @@ import { ContainerService } from "@bitwarden/common/services/container.service";
|
||||
import { CryptoService } from "@bitwarden/common/services/crypto.service";
|
||||
import { EncryptServiceImplementation } from "@bitwarden/common/services/cryptography/encrypt.service.implementation";
|
||||
import { EnvironmentService } from "@bitwarden/common/services/environment.service";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { FileUploadService } from "@bitwarden/common/services/file-upload/file-upload.service";
|
||||
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
|
||||
import { NoopMessagingService } from "@bitwarden/common/services/noopMessaging.service";
|
||||
@ -55,6 +54,10 @@ import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder
|
||||
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
||||
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
|
||||
import { SyncService } from "@bitwarden/common/vault/services/sync/sync.service";
|
||||
import {
|
||||
VaultExportService,
|
||||
VaultExportServiceAbstraction,
|
||||
} from "@bitwarden/exporter/vault-export";
|
||||
import {
|
||||
ImportApiService,
|
||||
ImportApiServiceAbstraction,
|
||||
@ -105,7 +108,7 @@ export class Main {
|
||||
auditService: AuditService;
|
||||
importService: ImportServiceAbstraction;
|
||||
importApiService: ImportApiServiceAbstraction;
|
||||
exportService: ExportService;
|
||||
exportService: VaultExportServiceAbstraction;
|
||||
searchService: SearchService;
|
||||
cryptoFunctionService: NodeCryptoFunctionService;
|
||||
encryptService: EncryptServiceImplementation;
|
||||
@ -381,7 +384,7 @@ export class Main {
|
||||
this.collectionService,
|
||||
this.cryptoService
|
||||
);
|
||||
this.exportService = new ExportService(
|
||||
this.exportService = new VaultExportService(
|
||||
this.folderService,
|
||||
this.cipherService,
|
||||
this.apiService,
|
||||
|
@ -1,20 +1,23 @@
|
||||
import * as program from "commander";
|
||||
import * as inquirer from "inquirer";
|
||||
|
||||
import {
|
||||
ExportFormat,
|
||||
ExportService,
|
||||
EXPORT_FORMATS,
|
||||
} from "@bitwarden/common/abstractions/export.service";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
import {
|
||||
ExportFormat,
|
||||
EXPORT_FORMATS,
|
||||
VaultExportServiceAbstraction,
|
||||
} from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { Response } from "../models/response";
|
||||
import { CliUtils } from "../utils";
|
||||
|
||||
export class ExportCommand {
|
||||
constructor(private exportService: ExportService, private policyService: PolicyService) {}
|
||||
constructor(
|
||||
private exportService: VaultExportServiceAbstraction,
|
||||
private policyService: PolicyService
|
||||
) {}
|
||||
|
||||
async run(options: program.OptionValues): Promise<Response> {
|
||||
if (
|
@ -4,12 +4,12 @@ import { ConfirmCommand } from "./admin-console/commands/confirm.command";
|
||||
import { ShareCommand } from "./admin-console/commands/share.command";
|
||||
import { Main } from "./bw";
|
||||
import { EditCommand } from "./commands/edit.command";
|
||||
import { ExportCommand } from "./commands/export.command";
|
||||
import { GetCommand } from "./commands/get.command";
|
||||
import { ListCommand } from "./commands/list.command";
|
||||
import { RestoreCommand } from "./commands/restore.command";
|
||||
import { Response } from "./models/response";
|
||||
import { Program } from "./program";
|
||||
import { ExportCommand } from "./tools/export.command";
|
||||
import { ImportCommand } from "./tools/import.command";
|
||||
import { CliUtils } from "./utils";
|
||||
import { CreateCommand } from "./vault/create.command";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { FolderWithIdExport } from "@bitwarden/common/models/export/folder-with-id.export";
|
||||
import { FolderWithIdExport } from "@bitwarden/common/models/export";
|
||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||
|
||||
import { BaseResponse } from "../../models/response/base.response";
|
||||
|
@ -15,6 +15,7 @@
|
||||
"@bitwarden/common/spec/*": ["../../libs/common/spec/*"],
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/importer": ["../../libs/importer/src"],
|
||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"],
|
||||
"@bitwarden/node/*": ["../../libs/node/src/*"]
|
||||
}
|
||||
},
|
||||
|
@ -48,9 +48,9 @@ import { PremiumComponent } from "../vault/app/accounts/premium.component";
|
||||
import { FolderAddEditComponent } from "../vault/app/vault/folder-add-edit.component";
|
||||
|
||||
import { SettingsComponent } from "./accounts/settings.component";
|
||||
import { ExportComponent } from "./tools/export/export.component";
|
||||
import { GeneratorComponent } from "./tools/generator.component";
|
||||
import { PasswordGeneratorHistoryComponent } from "./tools/password-generator-history.component";
|
||||
import { ExportComponent } from "./vault/export.component";
|
||||
|
||||
const BroadcasterSubscriptionId = "AppComponent";
|
||||
const IdleTimeout = 60000 * 10; // 10 minutes
|
||||
|
@ -48,12 +48,12 @@ import { HeaderComponent } from "./layout/header.component";
|
||||
import { NavComponent } from "./layout/nav.component";
|
||||
import { SearchComponent } from "./layout/search/search.component";
|
||||
import { SharedModule } from "./shared/shared.module";
|
||||
import { ExportComponent } from "./tools/export/export.component";
|
||||
import { GeneratorComponent } from "./tools/generator.component";
|
||||
import { PasswordGeneratorHistoryComponent } from "./tools/password-generator-history.component";
|
||||
import { AddEditComponent as SendAddEditComponent } from "./tools/send/add-edit.component";
|
||||
import { EffluxDatesComponent as SendEffluxDatesComponent } from "./tools/send/efflux-dates.component";
|
||||
import { SendComponent } from "./tools/send/send.component";
|
||||
import { ExportComponent } from "./vault/export.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [SharedModule, AppRoutingModule, VaultFilterModule, LoginModule],
|
||||
|
@ -3,17 +3,17 @@ import * as os from "os";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/tools/export/components/export.component";
|
||||
import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
const BroadcasterSubscriptionId = "ExportComponent";
|
||||
|
||||
@ -26,7 +26,7 @@ export class ExportComponent extends BaseExportComponent implements OnInit {
|
||||
cryptoService: CryptoService,
|
||||
i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
exportService: ExportService,
|
||||
exportService: VaultExportServiceAbstraction,
|
||||
eventCollectionService: EventCollectionService,
|
||||
policyService: PolicyService,
|
||||
userVerificationService: UserVerificationService,
|
@ -11,7 +11,8 @@
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"]
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
||||
},
|
||||
"useDefineForClassFields": false
|
||||
},
|
||||
|
@ -4,7 +4,6 @@ import { concatMap, Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -18,6 +17,7 @@ import { EventResponse } from "@bitwarden/common/models/response/event.response"
|
||||
|
||||
import { BaseEventsComponent } from "../../../common/base.events.component";
|
||||
import { EventService } from "../../../core";
|
||||
import { EventExportService } from "../../../tools/event-export";
|
||||
|
||||
const EVENT_SYSTEM_USER_TO_TRANSLATION: Record<EventSystemUser, string> = {
|
||||
[EventSystemUser.SCIM]: null, // SCIM acronym not able to be translated so just display SCIM
|
||||
@ -41,7 +41,7 @@ export class EventsComponent extends BaseEventsComponent implements OnInit, OnDe
|
||||
private route: ActivatedRoute,
|
||||
eventService: EventService,
|
||||
i18nService: I18nService,
|
||||
exportService: ExportService,
|
||||
exportService: EventExportService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
private router: Router,
|
||||
logService: LogService,
|
||||
|
@ -5,7 +5,6 @@ import { ActivatedRoute } from "@angular/router";
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -13,6 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { ExportComponent } from "../../../../tools/import-export/export.component";
|
||||
|
||||
@ -26,7 +26,7 @@ export class OrganizationExportComponent extends ExportComponent {
|
||||
cryptoService: CryptoService,
|
||||
i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
exportService: ExportService,
|
||||
exportService: VaultExportServiceAbstraction,
|
||||
eventCollectionService: EventCollectionService,
|
||||
private route: ActivatedRoute,
|
||||
policyService: PolicyService,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Directive } from "@angular/core";
|
||||
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -10,6 +9,7 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||
|
||||
import { EventService } from "../core";
|
||||
import { EventExportService } from "../tools/event-export";
|
||||
|
||||
@Directive()
|
||||
export abstract class BaseEventsComponent {
|
||||
@ -29,7 +29,7 @@ export abstract class BaseEventsComponent {
|
||||
constructor(
|
||||
protected eventService: EventService,
|
||||
protected i18nService: I18nService,
|
||||
protected exportService: ExportService,
|
||||
protected exportService: EventExportService,
|
||||
protected platformUtilsService: PlatformUtilsService,
|
||||
protected logService: LogService,
|
||||
protected fileDownloadService: FileDownloadService
|
||||
|
20
apps/web/src/app/tools/event-export/event-export.service.ts
Normal file
20
apps/web/src/app/tools/event-export/event-export.service.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import * as papa from "papaparse";
|
||||
|
||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||
import { ExportHelper } from "@bitwarden/exporter/export-helper";
|
||||
|
||||
import { EventExport } from "./event.export";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class EventExportService {
|
||||
async getEventExport(events: EventView[]): Promise<string> {
|
||||
return papa.unparse(events.map((e) => new EventExport(e)));
|
||||
}
|
||||
|
||||
getFileName(prefix: string = null, extension = "csv"): string {
|
||||
return ExportHelper.getFileName(prefix, extension);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { EventType } from "../../enums";
|
||||
import { EventView } from "../view/event.view";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||
|
||||
export class EventExport {
|
||||
message: string;
|
1
apps/web/src/app/tools/event-export/index.ts
Normal file
1
apps/web/src/app/tools/event-export/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./event-export.service";
|
@ -1,11 +1,10 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/tools/export/components/export.component";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -13,6 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { EncryptedExportType } from "@bitwarden/common/enums";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { UserVerificationPromptComponent } from "../../components/user-verification-prompt.component";
|
||||
|
||||
@ -29,7 +29,7 @@ export class ExportComponent extends BaseExportComponent {
|
||||
cryptoService: CryptoService,
|
||||
i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
exportService: ExportService,
|
||||
exportService: VaultExportServiceAbstraction,
|
||||
eventCollectionService: EventCollectionService,
|
||||
policyService: PolicyService,
|
||||
logService: LogService,
|
||||
|
@ -9,7 +9,8 @@
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||
"@bitwarden/components": ["../../libs/components/src"],
|
||||
"@bitwarden/importer": ["../../libs/importer/src"]
|
||||
"@bitwarden/importer": ["../../libs/importer/src"],
|
||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
||||
}
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
|
@ -3,7 +3,6 @@ import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -12,6 +11,7 @@ import { ProviderService } from "@bitwarden/common/admin-console/abstractions/pr
|
||||
import { EventResponse } from "@bitwarden/common/models/response/event.response";
|
||||
import { BaseEventsComponent } from "@bitwarden/web-vault/app/common/base.events.component";
|
||||
import { EventService } from "@bitwarden/web-vault/app/core";
|
||||
import { EventExportService } from "@bitwarden/web-vault/app/tools/event-export";
|
||||
|
||||
@Component({
|
||||
selector: "provider-events",
|
||||
@ -31,7 +31,7 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
|
||||
eventService: EventService,
|
||||
i18nService: I18nService,
|
||||
private providerService: ProviderService,
|
||||
exportService: ExportService,
|
||||
exportService: EventExportService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
private router: Router,
|
||||
logService: LogService,
|
||||
|
@ -5,7 +5,8 @@
|
||||
"@bitwarden/web-vault/*": ["../../apps/web/src/*"],
|
||||
"@bitwarden/common/*": ["../../libs/common/src/*"],
|
||||
"@bitwarden/angular/*": ["../../libs/angular/src/*"],
|
||||
"@bitwarden/components": ["../../libs/components/src"]
|
||||
"@bitwarden/components": ["../../libs/components/src"],
|
||||
"@bitwarden/exporter/*": ["../../libs/exporter/src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.stories.ts"]
|
||||
|
@ -22,6 +22,7 @@ module.exports = {
|
||||
"<rootDir>/libs/common/jest.config.js",
|
||||
"<rootDir>/libs/components/jest.config.js",
|
||||
"<rootDir>/libs/importer/jest.config.js",
|
||||
"<rootDir>/libs/exporter/jest.config.js",
|
||||
"<rootDir>/libs/node/jest.config.js",
|
||||
],
|
||||
|
||||
|
@ -3,7 +3,6 @@ import { NgModule } from "@angular/core";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
|
||||
import { CalloutComponent } from "./components/callout.component";
|
||||
import { ExportScopeCalloutComponent } from "./components/export-scope-callout.component";
|
||||
import { BitwardenToastModule } from "./components/toastr.component";
|
||||
import { A11yInvalidDirective } from "./directives/a11y-invalid.directive";
|
||||
import { A11yTitleDirective } from "./directives/a11y-title.directive";
|
||||
@ -28,6 +27,7 @@ import { SearchPipe } from "./pipes/search.pipe";
|
||||
import { UserNamePipe } from "./pipes/user-name.pipe";
|
||||
import { UserTypePipe } from "./pipes/user-type.pipe";
|
||||
import { PasswordStrengthComponent } from "./shared/components/password-strength/password-strength.component";
|
||||
import { ExportScopeCalloutComponent } from "./tools/export/components/export-scope-callout.component";
|
||||
import { IconComponent } from "./vault/components/icon.component";
|
||||
|
||||
@NgModule({
|
||||
|
@ -14,7 +14,6 @@ import { EncryptService } from "@bitwarden/common/abstractions/encrypt.service";
|
||||
import { EnvironmentService as EnvironmentServiceAbstraction } from "@bitwarden/common/abstractions/environment.service";
|
||||
import { EventCollectionService as EventCollectionServiceAbstraction } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/common/abstractions/event/event-upload.service";
|
||||
import { ExportService as ExportServiceAbstraction } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/abstractions/file-upload/file-upload.service";
|
||||
import { FormValidationErrorsService as FormValidationErrorsServiceAbstraction } from "@bitwarden/common/abstractions/formValidationErrors.service";
|
||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
|
||||
@ -94,7 +93,6 @@ import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/servi
|
||||
import { EnvironmentService } from "@bitwarden/common/services/environment.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service";
|
||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { FileUploadService } from "@bitwarden/common/services/file-upload/file-upload.service";
|
||||
import { FormValidationErrorsService } from "@bitwarden/common/services/formValidationErrors.service";
|
||||
import { NotificationsService } from "@bitwarden/common/services/notifications.service";
|
||||
@ -138,6 +136,10 @@ import { FolderApiService } from "@bitwarden/common/vault/services/folder/folder
|
||||
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
||||
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
|
||||
import { SyncService } from "@bitwarden/common/vault/services/sync/sync.service";
|
||||
import {
|
||||
VaultExportService,
|
||||
VaultExportServiceAbstraction,
|
||||
} from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||
import { LockGuard } from "../auth/guards/lock.guard";
|
||||
@ -464,8 +466,8 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
|
||||
deps: [AbstractStorageService, SECURE_STORAGE, STATE_FACTORY],
|
||||
},
|
||||
{
|
||||
provide: ExportServiceAbstraction,
|
||||
useClass: ExportService,
|
||||
provide: VaultExportServiceAbstraction,
|
||||
useClass: VaultExportService,
|
||||
deps: [
|
||||
FolderServiceAbstraction,
|
||||
CipherServiceAbstraction,
|
||||
|
@ -4,7 +4,6 @@ import { merge, takeUntil, Subject, startWith } from "rxjs";
|
||||
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@ -13,6 +12,7 @@ import { UserVerificationService } from "@bitwarden/common/abstractions/userVeri
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { EncryptedExportType, EventType } from "@bitwarden/common/enums";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
@Directive()
|
||||
export class ExportComponent implements OnInit, OnDestroy {
|
||||
@ -41,7 +41,7 @@ export class ExportComponent implements OnInit, OnDestroy {
|
||||
protected cryptoService: CryptoService,
|
||||
protected i18nService: I18nService,
|
||||
protected platformUtilsService: PlatformUtilsService,
|
||||
protected exportService: ExportService,
|
||||
protected exportService: VaultExportServiceAbstraction,
|
||||
protected eventCollectionService: EventCollectionService,
|
||||
private policyService: PolicyService,
|
||||
protected win: Window,
|
11
libs/common/src/models/export/index.ts
Normal file
11
libs/common/src/models/export/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export { CardExport } from "./card.export";
|
||||
export { CipherWithIdExport } from "./cipher-with-ids.export";
|
||||
export { CipherExport } from "./cipher.export";
|
||||
export { CollectionWithIdExport } from "./collection-with-id.export";
|
||||
export { CollectionExport } from "./collection.export";
|
||||
export { FieldExport } from "./field.export";
|
||||
export { FolderWithIdExport } from "./folder-with-id.export";
|
||||
export { FolderExport } from "./folder.export";
|
||||
export { IdentityExport } from "./identity.export";
|
||||
export { LoginUriExport } from "./login-uri.export";
|
||||
export { SecureNoteExport } from "./secure-note.export";
|
14
libs/exporter/jest.config.js
Normal file
14
libs/exporter/jest.config.js
Normal file
@ -0,0 +1,14 @@
|
||||
const { pathsToModuleNameMapper } = require("ts-jest");
|
||||
|
||||
const { compilerOptions } = require("../shared/tsconfig.libs");
|
||||
|
||||
const sharedConfig = require("../shared/jest.config.base");
|
||||
|
||||
module.exports = {
|
||||
...sharedConfig,
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "jsdom",
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, {
|
||||
prefix: "<rootDir>/",
|
||||
}),
|
||||
};
|
23
libs/exporter/package.json
Normal file
23
libs/exporter/package.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@bitwarden/exporter",
|
||||
"version": "0.0.0",
|
||||
"description": "Home for all Bitwarden exporters.",
|
||||
"keywords": [
|
||||
"bitwarden"
|
||||
],
|
||||
"author": "Bitwarden Inc.",
|
||||
"homepage": "https://bitwarden.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bitwarden/clients"
|
||||
},
|
||||
"license": "GPL-3.0",
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/**/*",
|
||||
"build": "npm run clean && tsc",
|
||||
"build:watch": "npm run clean && tsc -watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bitwarden/common": "file:../common"
|
||||
}
|
||||
}
|
24
libs/exporter/src/export-helper.ts
Normal file
24
libs/exporter/src/export-helper.ts
Normal file
@ -0,0 +1,24 @@
|
||||
export class ExportHelper {
|
||||
static getFileName(prefix: string = null, extension = "csv"): string {
|
||||
const now = new Date();
|
||||
const dateString =
|
||||
now.getFullYear() +
|
||||
"" +
|
||||
this.padNumber(now.getMonth() + 1, 2) +
|
||||
"" +
|
||||
this.padNumber(now.getDate(), 2) +
|
||||
this.padNumber(now.getHours(), 2) +
|
||||
"" +
|
||||
this.padNumber(now.getMinutes(), 2) +
|
||||
this.padNumber(now.getSeconds(), 2);
|
||||
|
||||
return "bitwarden" + (prefix ? "_" + prefix : "") + "_export_" + dateString + "." + extension;
|
||||
}
|
||||
|
||||
private static padNumber(num: number, width: number, padCharacter = "0"): string {
|
||||
const numString = num.toString();
|
||||
return numString.length >= width
|
||||
? numString
|
||||
: new Array(width - numString.length + 1).join(padCharacter) + numString;
|
||||
}
|
||||
}
|
2
libs/exporter/src/vault-export/index.ts
Normal file
2
libs/exporter/src/vault-export/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./services/vault-export.service.abstraction";
|
||||
export * from "./services/vault-export.service";
|
@ -1,11 +1,9 @@
|
||||
import { EventView } from "../models/view/event.view";
|
||||
|
||||
export const EXPORT_FORMATS = ["csv", "json", "encrypted_json"] as const;
|
||||
export type ExportFormat = (typeof EXPORT_FORMATS)[number];
|
||||
export abstract class ExportService {
|
||||
|
||||
export abstract class VaultExportServiceAbstraction {
|
||||
getExport: (format?: ExportFormat, organizationId?: string) => Promise<string>;
|
||||
getPasswordProtectedExport: (password: string, organizationId?: string) => Promise<string>;
|
||||
getOrganizationExport: (organizationId: string, format?: ExportFormat) => Promise<string>;
|
||||
getEventExport: (events: EventView[]) => Promise<string>;
|
||||
getFileName: (prefix?: string, extension?: string) => string;
|
||||
}
|
@ -8,8 +8,7 @@ import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||
import { KdfType, DEFAULT_PBKDF2_ITERATIONS } from "@bitwarden/common/enums";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
import { EncString } from "@bitwarden/common/models/domain/enc-string";
|
||||
import { CipherWithIdExport as CipherExport } from "@bitwarden/common/models/export/cipher-with-ids.export";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { CipherWithIdExport } from "@bitwarden/common/models/export/cipher-with-ids.export";
|
||||
import { StateService } from "@bitwarden/common/services/state.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||
@ -21,7 +20,9 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||
|
||||
import { BuildTestObject, GetUniqueString } from "../utils";
|
||||
import { BuildTestObject, GetUniqueString } from "../../../../common/spec/utils";
|
||||
|
||||
import { VaultExportService } from "./vault-export.service";
|
||||
|
||||
const UserCipherViews = [
|
||||
generateCipherView(false),
|
||||
@ -101,9 +102,9 @@ function generateFolder() {
|
||||
|
||||
function expectEqualCiphers(ciphers: CipherView[] | Cipher[], jsonResult: string) {
|
||||
const actual = JSON.stringify(JSON.parse(jsonResult).items);
|
||||
const items: CipherExport[] = [];
|
||||
const items: CipherWithIdExport[] = [];
|
||||
ciphers.forEach((c: CipherView | Cipher) => {
|
||||
const item = new CipherExport();
|
||||
const item = new CipherWithIdExport();
|
||||
item.build(c);
|
||||
items.push(item);
|
||||
});
|
||||
@ -139,8 +140,8 @@ function expectEqualFolders(folders: Folder[], jsonResult: string) {
|
||||
expect(actual).toEqual(JSON.stringify(items));
|
||||
}
|
||||
|
||||
describe("ExportService", () => {
|
||||
let exportService: ExportService;
|
||||
describe("VaultExportService", () => {
|
||||
let exportService: VaultExportService;
|
||||
let apiService: SubstituteOf<ApiService>;
|
||||
let cryptoFunctionService: SubstituteOf<CryptoFunctionService>;
|
||||
let cipherService: SubstituteOf<CipherService>;
|
||||
@ -161,7 +162,7 @@ describe("ExportService", () => {
|
||||
stateService.getKdfType().resolves(KdfType.PBKDF2_SHA256);
|
||||
stateService.getKdfConfig().resolves(new KdfConfig(DEFAULT_PBKDF2_ITERATIONS));
|
||||
|
||||
exportService = new ExportService(
|
||||
exportService = new VaultExportService(
|
||||
folderService,
|
||||
cipherService,
|
||||
apiService,
|
@ -1,37 +1,36 @@
|
||||
import * as papa from "papaparse";
|
||||
|
||||
import { BitwardenPasswordProtectedFileFormat } from "@bitwarden/importer/src/importers/bitwarden/bitwarden-password-protected-types";
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { CryptoService } from "../abstractions/crypto.service";
|
||||
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { CryptoFunctionService } from "@bitwarden/common/abstractions/cryptoFunction.service";
|
||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||
import { CollectionData } from "@bitwarden/common/admin-console/models/data/collection.data";
|
||||
import { Collection } from "@bitwarden/common/admin-console/models/domain/collection";
|
||||
import { CollectionDetailsResponse } from "@bitwarden/common/admin-console/models/response/collection.response";
|
||||
import { CollectionView } from "@bitwarden/common/admin-console/models/view/collection.view";
|
||||
import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||
import { KdfType } from "@bitwarden/common/enums";
|
||||
import { Utils } from "@bitwarden/common/misc/utils";
|
||||
import {
|
||||
ExportFormat,
|
||||
ExportService as ExportServiceAbstraction,
|
||||
} from "../abstractions/export.service";
|
||||
import { StateService } from "../abstractions/state.service";
|
||||
import { CollectionData } from "../admin-console/models/data/collection.data";
|
||||
import { Collection } from "../admin-console/models/domain/collection";
|
||||
import { CollectionDetailsResponse } from "../admin-console/models/response/collection.response";
|
||||
import { CollectionView } from "../admin-console/models/view/collection.view";
|
||||
import { KdfConfig } from "../auth/models/domain/kdf-config";
|
||||
import { KdfType } from "../enums";
|
||||
import { Utils } from "../misc/utils";
|
||||
import { CipherWithIdExport as CipherExport } from "../models/export/cipher-with-ids.export";
|
||||
import { CollectionWithIdExport as CollectionExport } from "../models/export/collection-with-id.export";
|
||||
import { EventExport } from "../models/export/event.export";
|
||||
import { FolderWithIdExport as FolderExport } from "../models/export/folder-with-id.export";
|
||||
import { EventView } from "../models/view/event.view";
|
||||
import { CipherService } from "../vault/abstractions/cipher.service";
|
||||
import { FolderService } from "../vault/abstractions/folder/folder.service.abstraction";
|
||||
import { CipherType } from "../vault/enums/cipher-type";
|
||||
import { CipherData } from "../vault/models/data/cipher.data";
|
||||
import { Cipher } from "../vault/models/domain/cipher";
|
||||
import { Folder } from "../vault/models/domain/folder";
|
||||
import { CipherView } from "../vault/models/view/cipher.view";
|
||||
import { FolderView } from "../vault/models/view/folder.view";
|
||||
CipherWithIdExport,
|
||||
CollectionWithIdExport,
|
||||
FolderWithIdExport,
|
||||
} from "@bitwarden/common/models/export";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
|
||||
import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data";
|
||||
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
||||
import { Folder } from "@bitwarden/common/vault/models/domain/folder";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||
|
||||
export class ExportService implements ExportServiceAbstraction {
|
||||
import { ExportHelper } from "../../export-helper";
|
||||
import { BitwardenPasswordProtectedFileFormat } from "../bitwarden-password-protected-types";
|
||||
|
||||
import { ExportFormat, VaultExportServiceAbstraction } from "./vault-export.service.abstraction";
|
||||
|
||||
export class VaultExportService implements VaultExportServiceAbstraction {
|
||||
constructor(
|
||||
private folderService: FolderService,
|
||||
private cipherService: CipherService,
|
||||
@ -93,24 +92,8 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async getEventExport(events: EventView[]): Promise<string> {
|
||||
return papa.unparse(events.map((e) => new EventExport(e)));
|
||||
}
|
||||
|
||||
getFileName(prefix: string = null, extension = "csv"): string {
|
||||
const now = new Date();
|
||||
const dateString =
|
||||
now.getFullYear() +
|
||||
"" +
|
||||
this.padNumber(now.getMonth() + 1, 2) +
|
||||
"" +
|
||||
this.padNumber(now.getDate(), 2) +
|
||||
this.padNumber(now.getHours(), 2) +
|
||||
"" +
|
||||
this.padNumber(now.getMinutes(), 2) +
|
||||
this.padNumber(now.getSeconds(), 2);
|
||||
|
||||
return "bitwarden" + (prefix ? "_" + prefix : "") + "_export_" + dateString + "." + extension;
|
||||
return ExportHelper.getFileName(prefix, extension);
|
||||
}
|
||||
|
||||
private async getDecryptedExport(format: "json" | "csv"): Promise<string> {
|
||||
@ -170,7 +153,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
if (f.id == null) {
|
||||
return;
|
||||
}
|
||||
const folder = new FolderExport();
|
||||
const folder = new FolderWithIdExport();
|
||||
folder.build(f);
|
||||
jsonDoc.folders.push(folder);
|
||||
});
|
||||
@ -179,7 +162,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
if (c.organizationId != null) {
|
||||
return;
|
||||
}
|
||||
const cipher = new CipherExport();
|
||||
const cipher = new CipherWithIdExport();
|
||||
cipher.build(c);
|
||||
cipher.collectionIds = null;
|
||||
jsonDoc.items.push(cipher);
|
||||
@ -221,7 +204,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
if (f.id == null) {
|
||||
return;
|
||||
}
|
||||
const folder = new FolderExport();
|
||||
const folder = new FolderWithIdExport();
|
||||
folder.build(f);
|
||||
jsonDoc.folders.push(folder);
|
||||
});
|
||||
@ -230,7 +213,7 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
if (c.organizationId != null) {
|
||||
return;
|
||||
}
|
||||
const cipher = new CipherExport();
|
||||
const cipher = new CipherWithIdExport();
|
||||
cipher.build(c);
|
||||
cipher.collectionIds = null;
|
||||
jsonDoc.items.push(cipher);
|
||||
@ -313,13 +296,13 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
};
|
||||
|
||||
decCollections.forEach((c) => {
|
||||
const collection = new CollectionExport();
|
||||
const collection = new CollectionWithIdExport();
|
||||
collection.build(c);
|
||||
jsonDoc.collections.push(collection);
|
||||
});
|
||||
|
||||
decCiphers.forEach((c) => {
|
||||
const cipher = new CipherExport();
|
||||
const cipher = new CipherWithIdExport();
|
||||
cipher.build(c);
|
||||
jsonDoc.items.push(cipher);
|
||||
});
|
||||
@ -373,26 +356,19 @@ export class ExportService implements ExportServiceAbstraction {
|
||||
};
|
||||
|
||||
collections.forEach((c) => {
|
||||
const collection = new CollectionExport();
|
||||
const collection = new CollectionWithIdExport();
|
||||
collection.build(c);
|
||||
jsonDoc.collections.push(collection);
|
||||
});
|
||||
|
||||
ciphers.forEach((c) => {
|
||||
const cipher = new CipherExport();
|
||||
const cipher = new CipherWithIdExport();
|
||||
cipher.build(c);
|
||||
jsonDoc.items.push(cipher);
|
||||
});
|
||||
return JSON.stringify(jsonDoc, null, " ");
|
||||
}
|
||||
|
||||
private padNumber(num: number, width: number, padCharacter = "0"): string {
|
||||
const numString = num.toString();
|
||||
return numString.length >= width
|
||||
? numString
|
||||
: new Array(width - numString.length + 1).join(padCharacter) + numString;
|
||||
}
|
||||
|
||||
private buildCommonCipher(cipher: any, c: CipherView) {
|
||||
cipher.type = null;
|
||||
cipher.name = c.name;
|
5
libs/exporter/tsconfig.json
Normal file
5
libs/exporter/tsconfig.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../shared/tsconfig.libs",
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
3
libs/exporter/tsconfig.spec.json
Normal file
3
libs/exporter/tsconfig.spec.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "./tsconfig.json"
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
"build:watch": "npm run clean && tsc -watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bitwarden/common": "file:../common"
|
||||
"@bitwarden/common": "file:../common",
|
||||
"@bitwarden/exporter": "file:../exporter"
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { EncString } from "@bitwarden/common/models/domain/enc-string";
|
||||
import { CipherWithIdExport } from "@bitwarden/common/models/export/cipher-with-ids.export";
|
||||
import { CollectionWithIdExport } from "@bitwarden/common/models/export/collection-with-id.export";
|
||||
import { FolderWithIdExport } from "@bitwarden/common/models/export/folder-with-id.export";
|
||||
import {
|
||||
CipherWithIdExport,
|
||||
CollectionWithIdExport,
|
||||
FolderWithIdExport,
|
||||
} from "@bitwarden/common/models/export";
|
||||
|
||||
import { ImportResult } from "../../models/import-result";
|
||||
import { BaseImporter } from "../base-importer";
|
||||
|
@ -4,12 +4,12 @@ import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||
import { KdfType } from "@bitwarden/common/enums";
|
||||
import { EncString } from "@bitwarden/common/models/domain/enc-string";
|
||||
import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetric-crypto-key";
|
||||
import { BitwardenPasswordProtectedFileFormat } from "@bitwarden/exporter/vault-export/bitwarden-password-protected-types";
|
||||
|
||||
import { ImportResult } from "../../models/import-result";
|
||||
import { Importer } from "../importer";
|
||||
|
||||
import { BitwardenJsonImporter } from "./bitwarden-json-importer";
|
||||
import { BitwardenPasswordProtectedFileFormat } from "./bitwarden-password-protected-types";
|
||||
export class BitwardenPasswordProtectedImporter extends BitwardenJsonImporter implements Importer {
|
||||
private key: SymmetricCryptoKey;
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
"@bitwarden/common/*": ["../common/src/*"],
|
||||
"@bitwarden/angular/*": ["../angular/src/*"],
|
||||
"@bitwarden/node/*": ["../node/src/*"],
|
||||
"@bitwarden/importer": ["../importer/src"]
|
||||
"@bitwarden/importer": ["../importer/src"],
|
||||
"@bitwarden/exporter/*": ["../exporter/src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
package-lock.json
generated
17
package-lock.json
generated
@ -258,6 +258,13 @@
|
||||
"name": "@bitwarden/components",
|
||||
"version": "0.0.0"
|
||||
},
|
||||
"libs/exporter": {
|
||||
"version": "0.0.0",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@bitwarden/common": "file:../common"
|
||||
}
|
||||
},
|
||||
"libs/importer": {
|
||||
"name": "@bitwarden/importer",
|
||||
"version": "0.0.0",
|
||||
@ -3320,6 +3327,10 @@
|
||||
"resolved": "apps/desktop/desktop_native",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/exporter": {
|
||||
"resolved": "libs/exporter",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/importer": {
|
||||
"resolved": "libs/importer",
|
||||
"link": true
|
||||
@ -46979,6 +46990,12 @@
|
||||
"@napi-rs/cli": "^2.6.2"
|
||||
}
|
||||
},
|
||||
"@bitwarden/exporter": {
|
||||
"version": "file:libs/exporter",
|
||||
"requires": {
|
||||
"@bitwarden/common": "file:../common"
|
||||
}
|
||||
},
|
||||
"@bitwarden/importer": {
|
||||
"version": "file:libs/importer",
|
||||
"requires": {
|
||||
|
@ -18,7 +18,8 @@
|
||||
"@bitwarden/common/*": ["./libs/common/src/*"],
|
||||
"@bitwarden/angular/*": ["./libs/angular/src/*"],
|
||||
"@bitwarden/node/*": ["./libs/node/src/*"],
|
||||
"@bitwarden/components": ["./libs/components/src"]
|
||||
"@bitwarden/components": ["./libs/components/src"],
|
||||
"@bitwarden/exporter/*": ["./libs/exporter/src/*"]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
"@bitwarden/node/*": ["./libs/node/src/*"],
|
||||
"@bitwarden/components": ["./libs/components/src"],
|
||||
"@bitwarden/importer": ["./libs/importer/src"],
|
||||
"@bitwarden/exporter/*": ["./libs/exporter/src/*"],
|
||||
"@bitwarden/web-vault/*": ["./apps/web/src/*"]
|
||||
},
|
||||
"plugins": [
|
||||
|
Loading…
Reference in New Issue
Block a user