Fix client hash signing via authenticated endpoint

This commit is contained in:
2026-03-13 13:49:28 +00:00
parent 846cba1645
commit 82f891ada8
4 changed files with 234 additions and 6 deletions
+29 -3
View File
@@ -3,6 +3,26 @@ import { BASE_URL } from "../core/env";
import { consoleLogger } from "../core/logger";
import { hashAPIPath } from "../core/hash";
const buildHashedQueryUrl = async (queryUrl) => {
try {
const signRes = await axios.get(
"/api/endpoint/gethash_api?path=" + encodeURIComponent(queryUrl)
);
if (!signRes?.data?.hash) {
throw new Error("Hash signature unavailable");
}
return queryUrl + signRes.data.hash;
} catch (error) {
if (typeof window === "undefined" && process.env.HASHKEY) {
return queryUrl + hashAPIPath(queryUrl);
}
throw error;
}
};
export const getAwaitingSubmissionFromBlob = (containerName) => {
return axios
.get(
@@ -132,9 +152,11 @@ export const uploadFiles = async (
var queryUrl = "/api/file/upload";
const hashedUrl = await buildHashedQueryUrl(queryUrl);
const config = {
method: "post",
url: queryUrl + hashAPIPath(queryUrl),
url: hashedUrl,
data: formData,
headers: { "content-type": "multipart/form-data" }
};
@@ -160,9 +182,11 @@ export const uploadSingleFile = async (filesObj, containerID, casefolderID) => {
var queryUrl = "/api/file/uploadsinglefile";
const hashedUrl = await buildHashedQueryUrl(queryUrl);
const config = {
method: "post",
url: queryUrl + hashAPIPath(queryUrl),
url: hashedUrl,
data: formData,
headers: { "content-type": "multipart/form-data" }
};
@@ -189,9 +213,11 @@ export const uploadRepFiles = async (
var queryUrl = "/api/file/upload";
const hashedUrl = await buildHashedQueryUrl(queryUrl);
const config = {
method: "post",
url: queryUrl + hashAPIPath(queryUrl),
url: hashedUrl,
data: formData,
headers: { "content-type": "multipart/form-data" }
};