Merged PR 612: assing hash signature to proxy requests
Related work items: #6718
This commit is contained in:
+16
-12
@@ -1,9 +1,9 @@
|
||||
// dev
|
||||
RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/
|
||||
RELAYURI = "dev-pedw-ns.servicebus.windows.net"
|
||||
RELAYPATH = "dev-pedw-hc"
|
||||
SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="
|
||||
SASKEYNAME = "devpedwnspolicy"
|
||||
//RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/
|
||||
//RELAYURI = "dev-pedw-ns.servicebus.windows.net"
|
||||
//RELAYPATH = "dev-pedw-hc"
|
||||
//SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="
|
||||
//SASKEYNAME = "devpedwnspolicy"
|
||||
|
||||
|
||||
PORT= "3000"
|
||||
@@ -23,16 +23,20 @@ I18N_DOMAIN = "cymru.local"
|
||||
|
||||
|
||||
//preprod
|
||||
//RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/
|
||||
//RELAYURI = "pp-pedw-ns.servicebus.windows.net"
|
||||
//RELAYPATH = "pp-pedw-hc"
|
||||
//SASKEY = "JzrOYfMTsGBD1cZHH2nkzqsbfDCqg0brO6jyiIDNVPo="
|
||||
//SASKEYNAME = "pppedwnspolicy"
|
||||
RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/
|
||||
RELAYURI = "pp-pedw-ns.servicebus.windows.net"
|
||||
RELAYPATH = "pp-pedw-hc"
|
||||
SASKEY = "JzrOYfMTsGBD1cZHH2nkzqsbfDCqg0brO6jyiIDNVPo="
|
||||
SASKEYNAME = "pppedwnspolicy"
|
||||
|
||||
|
||||
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
||||
SHOWLOGIN = "false"
|
||||
SHOWREPRESENTATIONS = "false"
|
||||
BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
|
||||
BASIC_AUTH_CREDENTIALS,, = pinswg:password|pinswg2:password2
|
||||
|
||||
NEXT_PUBLIC_ISHARESECRETPHRASE = "Secret phrase"
|
||||
NEXT_PUBLIC_ISHARESECRETPHRASE = "Secret phrase"
|
||||
|
||||
HASHKEY = "028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c"
|
||||
|
||||
NEXT_PUBLIC_HASHKEY = "028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c"
|
||||
|
||||
+144
-175
@@ -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,7 @@ if (process.browser) {
|
||||
} else {
|
||||
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
|
||||
}
|
||||
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
|
||||
|
||||
const API_PATH = "/api/data/v8.2/";
|
||||
|
||||
@@ -76,34 +78,6 @@ export const getSASToken = () => {
|
||||
return token;
|
||||
};
|
||||
|
||||
const accessToken =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSIsImtpZCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSJ9.eyJhdWQiOiJodHRwczovL2RldmNybTIwMTYubGxjZHQuZ292LndhbGVzLyIsImlzcyI6Imh0dHA6Ly9mcy50ZXN0Lmdvdi53YWxlcy9hZGZzL3NlcnZpY2VzL3RydXN0IiwiaWF0IjoxNjMyMTIxMjkxLCJuYmYiOjE2MzIxMjEyOTEsImV4cCI6MTYzMjE1MDA5MSwidXBuIjpbIlJvYmVydC5Cb25kQHRlc3QuZ292LndhbGVzIiwicm9iZXJ0LmJvbmRAdGVzdC5nb3Yud2FsZXMiXSwicHJpbWFyeXNpZCI6IlMtMS01LTIxLTE4MDA4NDIwNzYtMjQ1NTYwNjU5LTQyMTU3NzU0NjktMTY2MjgiLCJ1bmlxdWVfbmFtZSI6IlhNXFxCb25kUiIsImFwcHR5cGUiOiJQdWJsaWMiLCJhcHBpZCI6IjQyN2ZhNzljLWI1ZmMtNDJhZC04M2Q0LTQxMGIwMzk0OGFiNiIsImF1dGhtZXRob2QiOiJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvYXV0aGVudGljYXRpb25tZXRob2Qvd2luZG93cyIsImF1dGhfdGltZSI6IjIwMjEtMDktMjBUMDc6MDE6MzEuNDYzWiIsInZlciI6IjEuMCJ9.W0ID2nCBYVxh8T1eQqWKk2Wh45kRbRzCICfzrZNAs-4u54yl0UJUcVihyI8EBmQeALCEc5eY99DjK0gaqzCdJqxbxol8yk5LrFvhV5UkCiZ7SO2Wq1cLReWHVsgz39qBtrZ8vlqqZsv7DsEaRJQbtj8Djnx26Wb_kcNu-tuXwUBF0uR5GLFFvJfM3PzkRCY-ZPOTbvPTb73oN_NKe6BrsVjyaR9xSXsRJjgHPmJgWgnvq-2X0Dj7LCwXSEygDDOGlF1yqqN0Lv6qplhQoH-heZlC1K6qe_92nHPswXag6uN5nxTmk1Qw6zJt_aHMnXdwa18ghh4hGx5R0Jz53X113Q";
|
||||
|
||||
//const SASToken = getSASToken();
|
||||
|
||||
const crmHeaders = {
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Authorization": "Bearer " + accessToken,
|
||||
},
|
||||
};
|
||||
|
||||
const crmHeadersReturn = {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": "return=representation",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + accessToken,
|
||||
},
|
||||
};
|
||||
|
||||
const azureHeaders = (SASToken) => {
|
||||
return {
|
||||
headers: {
|
||||
@@ -131,6 +105,16 @@ const azureHeadersPaged = (SASToken) => {
|
||||
};
|
||||
};
|
||||
|
||||
const hashProxyPath = (queryPath) => {
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
);
|
||||
hashlink = hashlink.toString();
|
||||
|
||||
return "&hash=" + hashlink;
|
||||
};
|
||||
|
||||
export const getBasicSearch = (token, searchString) => {
|
||||
//console.log("\n\n", token, searchString);
|
||||
|
||||
@@ -160,22 +144,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");
|
||||
//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=" + '<cookie pagenumber="' + pageNumber + '" />'
|
||||
: "");
|
||||
|
||||
//console.log(queryUrl);
|
||||
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 +190,14 @@ 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=" + '<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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
return error.response;
|
||||
@@ -257,7 +240,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 +285,16 @@ 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=" + ('<cookie pagenumber="' + pageNumber + '" />')
|
||||
: "");
|
||||
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
return axios
|
||||
.get(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
let ErrResponse = {
|
||||
@@ -358,19 +338,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 +390,17 @@ 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 + '" />')
|
||||
: "");
|
||||
|
||||
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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -431,16 +410,14 @@ 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=" + ('<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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -450,12 +427,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -465,16 +442,15 @@ 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=" + ('<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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -484,11 +460,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
@@ -500,15 +476,14 @@ 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=" + ('<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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
@@ -535,13 +510,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -550,14 +525,12 @@ export const getBasicDNSSearchDetailsPaged = (caseReference) => {
|
||||
|
||||
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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => {
|
||||
//console.log(" linked date", res.data);
|
||||
return res.data;
|
||||
@@ -709,14 +682,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -834,13 +808,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
@@ -872,13 +845,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
@@ -886,13 +858,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
@@ -915,13 +886,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(queryUrl | +hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
@@ -1011,15 +981,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
@@ -1028,12 +997,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(queryUrl + hashProxyPath(queryUrl))
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
|
||||
@@ -105,12 +105,9 @@ const DocumentDetails = (props) => {
|
||||
>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
|
||||
<a
|
||||
href={
|
||||
"/api/proxy/documents/download/" +
|
||||
encryptDocReference(
|
||||
detailsObj.pinswg_isharedocumentreference
|
||||
)
|
||||
}
|
||||
href={encryptDocReference(
|
||||
detailsObj.pinswg_isharedocumentreference
|
||||
)}
|
||||
>
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
@@ -194,15 +191,18 @@ const DocumentDetails = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const encryptDocReference = (documentRef) => {
|
||||
var encrypted = encodeURIComponent(
|
||||
CryptoJS.AES.encrypt(
|
||||
documentRef,
|
||||
process.env.NEXT_PUBLIC_ISHARESECRETPHRASE
|
||||
)
|
||||
);
|
||||
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
|
||||
|
||||
return encrypted;
|
||||
const encryptDocReference = (documentRef) => {
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
"/api/proxy/documents/download/" + documentRef,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
);
|
||||
hashlink = hashlink.toString();
|
||||
|
||||
return (
|
||||
"/api/proxy/documents/download/" + documentRef + "&hash=" + hashlink
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -263,7 +263,19 @@ const Pinswg_dnsid = (props) => {
|
||||
detailsObj.pinswg_webaddress +
|
||||
'")].value_cy'
|
||||
)
|
||||
: detailsObj.pinswg_webaddress ||
|
||||
: (
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href={
|
||||
detailsObj.pinswg_webaddress
|
||||
}
|
||||
>
|
||||
{
|
||||
detailsObj.pinswg_webaddress
|
||||
}
|
||||
</a>
|
||||
) ||
|
||||
t(
|
||||
"case:summary-no-date-entered-label"
|
||||
)}
|
||||
|
||||
@@ -268,7 +268,7 @@ const DNSSearchResults = (props) => {
|
||||
//console.log("getting details", data);
|
||||
return getSearchDetailsPaged(data).then((data) => {
|
||||
setSearchDetails(data);
|
||||
setShowSpinnerState(false);
|
||||
//setShowSpinnerState(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import axios from "axios";
|
||||
import https from "https";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { response } from "express";
|
||||
import HmacSHA256 from "crypto-js/hmac-sha256";
|
||||
import { rest } from "lodash";
|
||||
|
||||
const PROXY_RELAY_URL =
|
||||
"https://" +
|
||||
@@ -48,16 +49,30 @@ const getSASToken = () => {
|
||||
return token;
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
//console.log(req.method);
|
||||
function checkProxyPath(queryPath) {
|
||||
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
|
||||
|
||||
const wordKey = WORDKEY;
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
decodeURI(queryPath),
|
||||
CryptoJS.enc.Hex.parse(wordKey)
|
||||
);
|
||||
|
||||
hashlink = hashlink.toString();
|
||||
|
||||
return hashlink;
|
||||
}
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var data = JSON.stringify(req.body);
|
||||
const SASToken = getSASToken();
|
||||
|
||||
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 +
|
||||
req.url.split("&hash=")[0].split("/api/proxy/")[1],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -85,7 +100,9 @@ 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 +
|
||||
req.url.split("&hash=")[0].split("/api/proxy/")[1],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -97,46 +114,49 @@ export default async function ApiProxy(req, res) {
|
||||
responseType: "arraybuffer",
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let apiPath = req.url.split("/api/proxy/")[1];
|
||||
let hasDocument = apiPath.indexOf("/download") > 0 ? true : false;
|
||||
// console.log(
|
||||
// "//////////////",
|
||||
// req.url.split("/api/proxy/")[1],
|
||||
// PROXY_RELAY_URL + req.query.route[0],
|
||||
// req.method,
|
||||
// hasDocument
|
||||
// );
|
||||
axios(
|
||||
req.method == "GET"
|
||||
? hasDocument
|
||||
? configDocument
|
||||
: configNoData
|
||||
: config
|
||||
)
|
||||
.then((response) => {
|
||||
res.statusCode = 200;
|
||||
if (hasDocument) {
|
||||
res.setHeader(
|
||||
"Content-disposition",
|
||||
"attachment; filename=" +
|
||||
response.headers["content-disposition"].split(
|
||||
"filename="
|
||||
)[1]
|
||||
);
|
||||
res.end(response.data);
|
||||
} else {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
// res.setHeader("Cache-Control", "max-age=1800000");
|
||||
res.end(JSON.stringify(response.data));
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("proxy response error", error);
|
||||
res.json(error);
|
||||
res.status(405).end();
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
let hashCheckPath = req.url.split("&hash=")[0];
|
||||
let hashCheckValue = req.url.split("&hash=")[1];
|
||||
let hashFromRequest = checkProxyPath(hashCheckPath);
|
||||
|
||||
if (hashCheckValue == hashFromRequest) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let hasDocument =
|
||||
hashCheckPath.indexOf("/download") > 0 ? true : false;
|
||||
|
||||
axios(
|
||||
req.method == "GET"
|
||||
? hasDocument
|
||||
? configDocument
|
||||
: configNoData
|
||||
: config
|
||||
)
|
||||
.then((response) => {
|
||||
res.statusCode = 200;
|
||||
if (hasDocument) {
|
||||
res.setHeader(
|
||||
"Content-disposition",
|
||||
"attachment; filename=" +
|
||||
response.headers["content-disposition"].split(
|
||||
"filename="
|
||||
)[1]
|
||||
);
|
||||
res.end(response.data);
|
||||
} else {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
// res.setHeader("Cache-Control", "max-age=1800000");
|
||||
res.end(JSON.stringify(response.data));
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("proxy response error", error);
|
||||
// res.json(error);
|
||||
res.status(405).end();
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
res.status(405).end();
|
||||
return resolve();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user