hashing function
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import axios from "axios";
|
||||
import https from "https";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { response } from "express";
|
||||
import HmacSHA256 from "crypto-js/hmac-sha256";
|
||||
|
||||
const PROXY_RELAY_URL =
|
||||
"https://" +
|
||||
@@ -48,16 +48,33 @@ const getSASToken = () => {
|
||||
return token;
|
||||
};
|
||||
|
||||
function hashProxyPath(queryPath) {
|
||||
const wordKey = process.env.HASHKEY;
|
||||
//console.log(CryptoJS.enc.Hex.parse(wordKey));
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(wordKey)
|
||||
);
|
||||
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Base64);
|
||||
|
||||
console.log("&hash=" + hashlink);
|
||||
|
||||
return queryPath; //+ "&hash=" + hashlink;
|
||||
}
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
//console.log(req.method);
|
||||
|
||||
var data = JSON.stringify(req.body);
|
||||
const SASToken = getSASToken();
|
||||
|
||||
//console.log("the request", req.query.route, req.url);
|
||||
|
||||
var configNoData = {
|
||||
method: req.method,
|
||||
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1],
|
||||
url: PROXY_RELAY_URL + hashProxyPath(req.url.split("/api/proxy/")[1]),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -71,7 +88,7 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var config = {
|
||||
method: req.method,
|
||||
url: PROXY_RELAY_URL + req.query.route[0],
|
||||
url: PROXY_RELAY_URL + hashProxyPath(req.query.route[0]),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -85,7 +102,7 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var configDocument = {
|
||||
method: req.method,
|
||||
url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1],
|
||||
url: PROXY_RELAY_URL + hashProxyPath(req.url.split("/api/proxy/")[1]),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
|
||||
Reference in New Issue
Block a user