@hmcts/ccd-case-ui-toolkit 7.4.1 → 7.4.2-broken-access

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14787,7 +14787,7 @@ class CaseFileViewFieldComponent {
14787
14787
  }
14788
14788
  setMediaViewerFile(document) {
14789
14789
  const documentDetails = {
14790
- document_binary_url: document.document_binary_url,
14790
+ document_binary_url: this.withLegacyDocumentAccessContext(this.documentManagementService.getDocumentBinaryUrl(document)),
14791
14791
  document_filename: document.document_filename,
14792
14792
  content_type: document.content_type
14793
14793
  };
@@ -14802,6 +14802,19 @@ class CaseFileViewFieldComponent {
14802
14802
  const mediaViewerInfo = this.documentManagementService.getMediaViewerInfo(documentDetails);
14803
14803
  this.currentDocument = JSON.parse(mediaViewerInfo);
14804
14804
  }
14805
+ withLegacyDocumentAccessContext(documentBinaryUrl) {
14806
+ if (!documentBinaryUrl || !this.caseId) {
14807
+ return documentBinaryUrl;
14808
+ }
14809
+ const [path, query = ''] = documentBinaryUrl.split('?');
14810
+ if (!/^\/documents\/[^/]+\/binary\/?$/.test(path)) {
14811
+ return documentBinaryUrl;
14812
+ }
14813
+ // XUI validates legacy document access against the case before proxying the binary request.
14814
+ const searchParams = new URLSearchParams(query);
14815
+ searchParams.set('caseId', this.caseId);
14816
+ return `${path}?${searchParams.toString()}`;
14817
+ }
14805
14818
  moveDocument(data) {
14806
14819
  const cid = this.route.snapshot.paramMap.get(CaseFileViewFieldComponent.PARAM_CASE_ID);
14807
14820
  const loadingToken = this.loadingService.register();