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
+26 -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 getMyCases = (loggedInUserId) => {
return axios
.get(
@@ -234,8 +254,11 @@ export const sendCaseCompleteMessage = async (
"&tempcaseref=" +
caseReference +
"&inv=" +
inv +
hashAPIPath(hashQueryPath);
inv;
var signedQueryUrl = await buildHashedQueryUrl(hashQueryPath);
queryUrl = queryUrl + signedQueryUrl.replace(hashQueryPath, "");
var config = {
method: "get",
@@ -288,7 +311,7 @@ export const sendRepCompleteMessage = async (
"&repid=" +
fileName;
var queryUrl = hashQueryPath + hashAPIPath(hashQueryPath);
var queryUrl = await buildHashedQueryUrl(hashQueryPath);
var config = {
method: "get",