moved hashapipath to reusable single helper

This commit is contained in:
2026-03-16 11:13:41 +00:00
parent 023a8e9e6d
commit 18dfc60754
74 changed files with 298 additions and 1149 deletions
@@ -22,6 +22,7 @@ import _ from "lodash";
import { azureHeadersPaged } from "../../../actions/core/headers";
import { consoleLogger } from "../../../actions/core/logger";
import { getToken } from "../../../actions/core/token";
import { hashAPIPath } from "../../../actions/core/hash";
const WORDKEY = process.env.HASHKEY;
@@ -29,18 +30,6 @@ const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
//return "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
const encryptDocReference = (documentRef) => {
var hashlink = CryptoJS.HmacSHA256(
"documents/download/" + documentRef,
@@ -76,7 +65,7 @@ export default async function ApiProxy(req, res) {
"pinswg_documentpublisheddate":
element.pinswg_documentpublisheddate != null
? element.pinswg_documentpublisheddate
: element.pinswg_latestpublisheddate,
: element.pinswg_latestpublisheddate
});
element.pinswg_hashlink = encryptDocReference(
element.pinswg_isharedocumentreference