hashing proxy

This commit is contained in:
2021-11-16 14:18:59 +00:00
parent a7d6cf9386
commit c6d4743f73
3 changed files with 216 additions and 172 deletions
+155 -144
View File
@@ -1,6 +1,7 @@
import axios from "axios";
import https from "https";
import CryptoJS from "crypto-js";
import HmacSHA256 from "crypto-js/hmac-sha256";
//import {XMLHttpRequest} from 'xmlhttprequest';
@@ -14,6 +15,8 @@ if (process.browser) {
} else {
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
}
const WORDKEY =
"028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c";
const API_PATH = "/api/data/v8.2/";
@@ -131,6 +134,21 @@ const azureHeadersPaged = (SASToken) => {
};
};
const hashProxyPath = (queryPath) => {
//console.log(CryptoJS.enc.Hex.parse(wordKey));
//console.log("hasshing this: ", queryPath);
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString();
hashlink = encodeURI(hashlink);
console.log(hashlink);
return "&hash=" + hashlink;
};
export const getBasicSearch = (token, searchString) => {
//console.log("\n\n", token, searchString);
@@ -160,22 +178,22 @@ export const getBasicSearch = (token, searchString) => {
export const getBasicSearchPaged = (searchString, pageNumber) => {
//console.log("\n\n", token, searchString);
var token = getSASToken();
console.log(typeof pageNumber != "undefined");
var queryUrl =
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(queryUrl + hashProxyPath(queryUrl))
.then((res) => {
// console.log(" ");
// console.log("/////////////////////");
@@ -206,15 +224,15 @@ export const getBasicDNSSearch = (token, searchString) => {
export const getBasicDNSSearchPaged = (pageNumber) => {
var token = getSASToken();
var queryUrl =
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(hashProxyPath(queryUrl), azureHeadersPaged(token))
.then((res) => res.data)
.catch((error) => {
return error.response;
@@ -257,7 +275,6 @@ export const getAdvancedSearch = (token, searchString) => {
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -303,18 +320,17 @@ export const getAdvancedSearchPaged = (searchString, pageNumber) => {
searchString.apt
: "";
return axios
.get(
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
var queryUrl =
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
azureHeadersPaged(token)
)
return axios
.get(hashProxyPath(queryUrl), azureHeadersPaged(token))
.then((res) => res.data)
.catch((error) => {
let ErrResponse = {
@@ -358,19 +374,18 @@ export const getBasicSearchDetailsPaged = (
incidentID
) => {
//console.log("check appealtype:", appealType, caseReference);
var token = getSASToken();
var queryUrl =
"/api/proxy/" +
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
return axios
.get(
"/api/proxy/" +
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true",
azureHeaders(token)
)
.get(queryUrl + hashProxyPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this error", error);
@@ -411,17 +426,18 @@ export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
console.log(incidentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
hashProxyPath(queryUrl);
return axios
.get(
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(hashProxyPath(queryUrl), azureHeadersPaged(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -431,16 +447,15 @@ export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(hashProxyPath(queryUrl), azureHeadersPaged(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -450,12 +465,12 @@ export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
export const getSearchDocumentDetails1 = (incidentID) => {
//console.log(incidentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference";
return axios
.get(
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference"
)
.get(hashProxyPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -465,16 +480,16 @@ export const getSearchDocumentDetails1 = (incidentID) => {
export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
//console.log(incidentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "")
)
.get(hashProxyPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -484,11 +499,11 @@ export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
export const getSearchDocumentHistory1 = (documentID) => {
//console.log(documentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID;
return axios
.get(
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID
)
.get(hashProxyPath(queryUrl))
.then((res) => {
return res.data;
})
@@ -500,15 +515,15 @@ export const getSearchDocumentHistory1 = (documentID) => {
export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => {
//console.log(documentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "")
)
.get(hashProxyPath(queryUrl))
.then((res) => {
return res.data;
})
@@ -535,13 +550,13 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
export const getBasicDNSSearchDetailsPaged = (caseReference) => {
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true",
azureHeadersPaged(token)
)
.get(hashProxyPath(queryUrl), azureHeadersPaged(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -552,12 +567,12 @@ export const getLinkedCases = (parentIncidentid) => {
//console.log(parentIncidentid);
var token = getSASToken();
var queryUrl =
"/api/proxy/incidents?$count=true&$filter=_parentcaseid_value eq " +
parentIncidentid +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid";
return axios
.get(
"/api/proxy/incidents?$count=true&$filter=_parentcaseid_value eq " +
parentIncidentid +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid,"
)
.get(hashProxyPath(queryUrl))
.then((res) => {
//console.log(" linked date", res.data);
return res.data;
@@ -709,14 +724,15 @@ export const getAppealID = (
};
export const getLogin = (emailAddress, pwd) => {
var queryUrl =
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"' and pinswg_custom_password eq '" +
pwd +
"'&$count=true&$select=emailaddress1,%20contactid,pinswg_custom_password, yomifullname, firstname, lastname";
return axios
.get(
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"' and pinswg_custom_password eq '" +
pwd +
"'&$count=true&$select=emailaddress1,%20contactid,pinswg_custom_password, yomifullname, firstname, lastname"
)
.get(hashProxyPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -834,13 +850,12 @@ export const getMyRepresentations = (token, loggedInUserId) => {
};
export const getMyRepresentationsProxy = (token, loggedInUserId) => {
var queryUrl =
"/api/proxy/pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(hashProxyPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -872,13 +887,12 @@ export const deleteMyRepresentations = (myRepresentationsID) => {
};
export const getRepresentations = (incidentID) => {
var queryUrl =
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc",
azureHeaders(getSASToken())
)
.get(hashProxyPath(queryUrl), azureHeaders(getSASToken()))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -886,13 +900,12 @@ export const getRepresentations = (incidentID) => {
};
export const getRepresentationsProxy = (token, incidentID) => {
var queryUrl =
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
"&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(hashProxyPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -915,13 +928,12 @@ export const getWatchedCases = (token, loggedInUserId) => {
};
export const getWatchedCasesProxy = (token, loggedInUserId) => {
var queryUrl =
"/api/proxy/pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(hashProxyPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -1011,15 +1023,14 @@ export const getPortalModuleDetailsProxy = (
appealType,
caseReference
) => {
var queryUrl =
"/api/proxy/" +
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
"/api/proxy/" +
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true",
azureHeaders(token)
)
.get(hashProxyPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -1028,12 +1039,12 @@ export const getPortalModuleDetailsProxy = (
export const getEmailAccountCheck = (emailAddress) => {
let token = getSASToken();
var queryUrl =
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1, contactid";
return axios
.get(
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1, contactid"
)
.get(hashProxyPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);