diff --git a/apps/web/src/app/auth/settings/emergency-access/attachments/emergency-access-attachments.component.ts b/apps/web/src/app/auth/settings/emergency-access/attachments/emergency-access-attachments.component.ts
deleted file mode 100644
index 73191e1539e..00000000000
--- a/apps/web/src/app/auth/settings/emergency-access/attachments/emergency-access-attachments.component.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Component } from "@angular/core";
-
-import { AttachmentsComponent as BaseAttachmentsComponent } from "@bitwarden/angular/vault/components/attachments.component";
-import { ApiService } from "@bitwarden/common/abstractions/api.service";
-import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
-import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
-import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
-import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
-import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
-import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
-import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
-import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
-import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
-import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
-import { DialogService, ToastService } from "@bitwarden/components";
-import { KeyService } from "@bitwarden/key-management";
-
-@Component({
- selector: "emergency-access-attachments",
- templateUrl: "../../../../vault/individual-vault/attachments.component.html",
-})
-export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponent {
- viewOnly = true;
- canAccessAttachments = true;
-
- constructor(
- cipherService: CipherService,
- i18nService: I18nService,
- keyService: KeyService,
- encryptService: EncryptService,
- stateService: StateService,
- platformUtilsService: PlatformUtilsService,
- apiService: ApiService,
- logService: LogService,
- fileDownloadService: FileDownloadService,
- dialogService: DialogService,
- billingAccountProfileStateService: BillingAccountProfileStateService,
- accountService: AccountService,
- toastService: ToastService,
- ) {
- super(
- cipherService,
- i18nService,
- keyService,
- encryptService,
- platformUtilsService,
- apiService,
- window,
- logService,
- stateService,
- fileDownloadService,
- dialogService,
- billingAccountProfileStateService,
- accountService,
- toastService,
- );
- }
-
- protected async init() {
- // Do nothing since cipher is already decoded
- }
-
- protected showFixOldAttachments(attachment: AttachmentView) {
- return false;
- }
-}
diff --git a/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.html b/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.html
index a936e3a427d..87e2643c178 100644
--- a/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.html
+++ b/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.html
@@ -38,28 +38,6 @@
{{ currentCipher.subTitle }}
-
-
-
-
-
-
-
- |
diff --git a/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.ts b/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.ts
index 1e3d0cf705f..bf7ca29da9b 100644
--- a/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.ts
+++ b/apps/web/src/app/auth/settings/emergency-access/view/emergency-access-view.component.ts
@@ -1,15 +1,13 @@
-// FIXME: Update this file to be type safe and remove this and next line
-// @ts-strict-ignore
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
+import { firstValueFrom } from "rxjs";
-import { ModalService } from "@bitwarden/angular/services/modal.service";
+import { EmergencyAccessId } from "@bitwarden/common/types/guid";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, DefaultCipherFormConfigService } from "@bitwarden/vault";
import { EmergencyAccessService } from "../../../emergency-access";
-import { EmergencyAccessAttachmentsComponent } from "../attachments/emergency-access-attachments.component";
import { EmergencyViewDialogComponent } from "./emergency-view-dialog.component";
@@ -20,56 +18,34 @@ import { EmergencyViewDialogComponent } from "./emergency-view-dialog.component"
})
export class EmergencyAccessViewComponent implements OnInit {
@ViewChild("attachments", { read: ViewContainerRef, static: true })
- attachmentsModalRef: ViewContainerRef;
-
- id: string;
+ id: EmergencyAccessId | null = null;
ciphers: CipherView[] = [];
loaded = false;
constructor(
- private modalService: ModalService,
private router: Router,
private route: ActivatedRoute,
private emergencyAccessService: EmergencyAccessService,
private dialogService: DialogService,
) {}
- ngOnInit() {
- // eslint-disable-next-line rxjs-angular/prefer-takeuntil
- this.route.params.subscribe((qParams) => {
- if (qParams.id == null) {
- return this.router.navigate(["settings/emergency-access"]);
- }
+ async ngOnInit() {
+ const qParams = await firstValueFrom(this.route.params);
+ if (qParams.id == null) {
+ await this.router.navigate(["settings/emergency-access"]);
+ return;
+ }
- this.id = qParams.id;
-
- // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
- this.load();
- });
+ this.id = qParams.id;
+ this.ciphers = await this.emergencyAccessService.getViewOnlyCiphers(qParams.id);
+ this.loaded = true;
}
async selectCipher(cipher: CipherView) {
EmergencyViewDialogComponent.open(this.dialogService, {
cipher,
+ emergencyAccessId: this.id!,
});
return;
}
-
- async load() {
- this.ciphers = await this.emergencyAccessService.getViewOnlyCiphers(this.id);
- this.loaded = true;
- }
-
- // FIXME PM-17747: This will also need to be replaced with the new AttachmentViewDialog
- async viewAttachments(cipher: CipherView) {
- await this.modalService.openViewRef(
- EmergencyAccessAttachmentsComponent,
- this.attachmentsModalRef,
- (comp) => {
- comp.cipher = cipher;
- comp.emergencyAccessId = this.id;
- },
- );
- }
}
diff --git a/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.html b/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.html
index be38e1d9505..b3d8e48260a 100644
--- a/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.html
+++ b/apps/web/src/app/auth/settings/emergency-access/view/emergency-view-dialog.component.html
@@ -3,7 +3,7 @@
{{ title }}
diff --git a/libs/vault/src/cipher-view/attachments/attachments-v2-view.component.ts b/libs/vault/src/cipher-view/attachments/attachments-v2-view.component.ts
index 0c2ca35cbbc..8e4a1ac952c 100644
--- a/libs/vault/src/cipher-view/attachments/attachments-v2-view.component.ts
+++ b/libs/vault/src/cipher-view/attachments/attachments-v2-view.component.ts
@@ -9,7 +9,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions";
import { StateProvider } from "@bitwarden/common/platform/state";
-import { OrganizationId } from "@bitwarden/common/types/guid";
+import { EmergencyAccessId, OrganizationId } from "@bitwarden/common/types/guid";
import { OrgKey } from "@bitwarden/common/types/key";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import {
@@ -41,6 +41,9 @@ import { DownloadAttachmentComponent } from "../../components/download-attachmen
export class AttachmentsV2ViewComponent {
@Input() cipher: CipherView;
+ // Required for fetching attachment data when viewed from cipher via emergency access
+ @Input() emergencyAccessId?: EmergencyAccessId;
+
canAccessPremium: boolean;
orgKey: OrgKey;
diff --git a/libs/vault/src/cipher-view/cipher-view.component.html b/libs/vault/src/cipher-view/cipher-view.component.html
index b2e747aa2fe..c441c921c39 100644
--- a/libs/vault/src/cipher-view/cipher-view.component.html
+++ b/libs/vault/src/cipher-view/cipher-view.component.html
@@ -76,7 +76,8 @@
-
+
+
diff --git a/libs/vault/src/cipher-view/cipher-view.component.ts b/libs/vault/src/cipher-view/cipher-view.component.ts
index 657c0d11527..48b70271e43 100644
--- a/libs/vault/src/cipher-view/cipher-view.component.ts
+++ b/libs/vault/src/cipher-view/cipher-view.component.ts
@@ -15,7 +15,7 @@ import { isCardExpired } from "@bitwarden/common/autofill/utils";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
-import { CipherId, CollectionId, UserId } from "@bitwarden/common/types/guid";
+import { CipherId, CollectionId, EmergencyAccessId, UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
@@ -61,6 +61,9 @@ import { ViewIdentitySectionsComponent } from "./view-identity-sections/view-ide
export class CipherViewComponent implements OnChanges, OnDestroy {
@Input({ required: true }) cipher: CipherView | null = null;
+ // Required for fetching attachment data when viewed from cipher via emergency access
+ @Input() emergencyAccessId?: EmergencyAccessId;
+
activeUserId$ = getUserId(this.accountService.activeAccount$);
/**
diff --git a/libs/vault/src/components/download-attachment/download-attachment.component.ts b/libs/vault/src/components/download-attachment/download-attachment.component.ts
index 1445ca557cf..812051775f8 100644
--- a/libs/vault/src/components/download-attachment/download-attachment.component.ts
+++ b/libs/vault/src/components/download-attachment/download-attachment.component.ts
@@ -13,7 +13,7 @@ import { FileDownloadService } from "@bitwarden/common/platform/abstractions/fil
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { EncArrayBuffer } from "@bitwarden/common/platform/models/domain/enc-array-buffer";
import { StateProvider } from "@bitwarden/common/platform/state";
-import { OrganizationId } from "@bitwarden/common/types/guid";
+import { EmergencyAccessId, OrganizationId } from "@bitwarden/common/types/guid";
import { OrgKey } from "@bitwarden/common/types/key";
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
@@ -36,6 +36,9 @@ export class DownloadAttachmentComponent {
// When in view mode, we will want to check for the master password reprompt
@Input() checkPwReprompt?: boolean = false;
+ // Required for fetching attachment data when viewed from cipher via emergency access
+ @Input() emergencyAccessId?: EmergencyAccessId;
+
/** The organization key if the cipher is associated with one */
private orgKey: OrgKey | null = null;
@@ -68,6 +71,7 @@ export class DownloadAttachmentComponent {
const attachmentDownloadResponse = await this.apiService.getAttachmentData(
this.cipher.id,
this.attachment.id,
+ this.emergencyAccessId,
);
url = attachmentDownloadResponse.url;
} catch (e) {