bitwarden-estensione-browser/apps/web/src/app/tools/export.component.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
3.7 KiB
TypeScript
Raw Normal View History

import { Component, EventEmitter, Output, ViewChild, ViewContainerRef } from "@angular/core";
import { FormBuilder, FormControl } from "@angular/forms";
2018-06-20 22:28:56 +02:00
2022-06-14 17:10:53 +02:00
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
2022-06-14 17:10:53 +02:00
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
import { EventService } from "@bitwarden/common/abstractions/event.service";
import { ExportService } from "@bitwarden/common/abstractions/export.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 { PolicyService } from "@bitwarden/common/abstractions/policy.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
2022-06-14 17:10:53 +02:00
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
2018-06-20 22:28:56 +02:00
import { ApiKeyComponent } from "../settings/api-key.component";
2018-06-10 05:33:12 +02:00
@Component({
selector: "app-export",
templateUrl: "export.component.html",
})
2018-06-20 22:28:56 +02:00
export class ExportComponent extends BaseExportComponent {
organizationId: string;
formatControl: string;
encryptionType: string;
showPassword: boolean;
showConfirmPassword: boolean;
secretValue: string;
secret: FormControl;
@ViewChild("viewUserApiKeyModalRef", { read: ViewContainerRef, static: true })
viewUserApiKeyModalRef: ViewContainerRef;
constructor(
cryptoService: CryptoService,
i18nService: I18nService,
2019-07-12 23:11:50 +02:00
platformUtilsService: PlatformUtilsService,
exportService: ExportService,
eventService: EventService,
policyService: PolicyService,
logService: LogService,
userVerificationService: UserVerificationService,
formBuilder: FormBuilder,
modalService: ModalService,
apiService: ApiService,
stateService: StateService
) {
super(
cryptoService,
i18nService,
platformUtilsService,
exportService,
eventService,
policyService,
window,
logService,
userVerificationService,
formBuilder,
modalService,
apiService,
stateService
);
2018-06-20 22:28:56 +02:00
}
async promptUserForSecret() {
const entityId = await this.stateService.getUserId();
try {
// //TODO get help from Thomas on this/ other options I have to get a Secret :
// await this.modalService.openViewRef(ApiKeyComponent, this.viewUserApiKeyModalRef, (comp) => {
// comp.keyType = "user";
// comp.entityId = entityId;
// comp.postKey = this.apiService.postUserApiKey.bind(this.apiService);
// comp.scope = "api";
// comp.grantType = "client_credentials";
// comp.apiKeyTitle = "apiKey";
// comp.apiKeyWarning = "userApiKeyWarning";
// comp.apiKeyDescription = "userApiKeyDesc";
// });
// this.platformUtilsService.showToast("error", "This line doesn't get called because of an error ", this.i18nService.t("exportFail"));
//If verification is successful:
this.submitWithSecretAlreadyVerified();
} catch {
this.platformUtilsService.showToast("error", "FAIL", this.i18nService.t("exportFail"));
}
}
togglePassword() {
this.showPassword = !this.showPassword;
document.getElementById("newPassword").focus();
}
toggleConfirmPassword() {
this.showConfirmPassword = !this.showConfirmPassword;
document.getElementById("newConfirmPassword").focus();
}
2018-06-20 22:28:56 +02:00
protected saved() {
super.saved();
this.platformUtilsService.showToast("success", null, this.i18nService.t("exportSuccess"));
2018-06-20 22:28:56 +02:00
}
}