diff --git a/index.html b/index.html
index 3068998..07fcc2a 100644
--- a/index.html
+++ b/index.html
@@ -2998,7 +2998,7 @@
Waiting for confirmation...
-
Minimize
+
Minimize
Transaction in progress...
@@ -3512,27 +3512,36 @@
};
// Loder-Modal Methods
- function showLoader() {
+ function showLoader(hideText = '') {
const loaderModal = document.getElementById('loader-modal');
loaderModal.style.display = 'flex';
loaderModal.style.width = '100%'; // Full screen width
loaderModal.style.height = '100%'; // Full screen height
loaderModal.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; // Enable background fading
document.getElementById('loader-content').style.display = 'block';
+ if(hideText != '') {
+ document.getElementById('loader-text').style.display = 'none';
+ }
document.getElementById('loader-minimized').style.display = 'none';
}
function hideLoader() {
document.getElementById('loader-modal').style.display = 'none';
+ document.getElementById('loader-text').style.display = 'block';
}
function minimizeLoader() {
const loaderModal = document.getElementById('loader-modal');
+ if(document.getElementById('loader-text').style.display == 'none') {
+ hideLoader();
+ return;
+ }
loaderModal.style.backgroundColor = 'transparent'; // Remove background fading
loaderModal.style.width = '0'; // Minimize modal size
loaderModal.style.height = '0'; // Minimize modal size
document.getElementById('loader-content').style.display = 'none';
document.getElementById('loader-minimized').style.display = 'block';
+ document.getElementById('loader-text').style.display = 'block';
}
function maximizeLoader() {
@@ -3542,6 +3551,7 @@
loaderModal.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; // Re-enable background fading
document.getElementById('loader-content').style.display = 'block';
document.getElementById('loader-minimized').style.display = 'none';
+ document.getElementById('loader-text').style.display = 'block';
}
function togglePendingTransactionsDropdown() {
@@ -4971,6 +4981,12 @@
${translateThis("Transaction Pending")}
} else {
localStorage.setItem(myaccounts + DDEaddy + myCurrentChainId + ":api", "a");
localStorage.setItem(myaccounts + DDEaddy + myCurrentChainId + ":apiKeys", "none");
+ sightengineApiUser = '';
+ sightengineApiSecret = '';
+ pinataApiKey = '';
+ pinataSecretApiKey = '';
+ pinataGateway = '';
+ pinataToken = '';
}
}
}
@@ -5962,24 +5978,6 @@
${translateThis("Transaction Pending")}
request.publicKey = userpubkey;
const timestamp = new Date().getTime();
const padding = Crypto.SHA256(timestamp).substring(0, 16); //Pad to avoid chosen cipher attack
- var gatewayPub = gatewayList[currentGateway]['pub'];
- if(window.globalPublicKey) {
- gatewayPub = window.globalPublicKey;
- }
- var finalMessage = cryptico.encrypt(JSON.stringify(orderData) + "#*#*#" + timestamp + padding, gatewayPub, userprivkey).cipher;
- request.message = finalMessage;
- if(ipfs != '') {
- request.ipfs = true;
- }
- if(window.globalPublicKey) {
- return localVerify(request);
- }
- const requestData = {
- action: "verify",
- item: "",
- value: request, // Keep this as an object
- key: ""
- };
var maxtries = 3;
var checkedThis = {};
if(maxtries>gatewayList.length) {
@@ -5992,6 +5990,24 @@
${translateThis("Transaction Pending")}
continue;
}
checkedThis[x.toString()] = 1;
+ var gatewayPub = gatewayList[currentGateway]['pub'];
+ if(window.globalPublicKey) {
+ gatewayPub = window.globalPublicKey;
+ }
+ var finalMessage = cryptico.encrypt(JSON.stringify(orderData) + "#*#*#" + timestamp + padding, gatewayPub, userprivkey).cipher;
+ request.message = finalMessage;
+ if(ipfs != '') {
+ request.ipfs = true;
+ }
+ if(window.globalPublicKey) {
+ return localVerify(request);
+ }
+ const requestData = {
+ action: "verify",
+ item: "",
+ value: request, // Keep this as an object
+ key: ""
+ };
const response = await axios.post(gatewayList[currentGateway]['url'], requestData, {
headers: { 'ngrok-skip-browser-warning':true, 'Content-Type': 'application/json'}
});
@@ -6399,7 +6415,7 @@
${translateThis("Transaction Pending")}
orderData = {
message: 'error',
contact: '',
- image: [''],
+ image: [],
title: '',
location: ''
};
@@ -7131,6 +7147,7 @@
${translateThis("Transaction Pending")}
};
var isGood = await validateOrderData(orderData, hash);
+ console.log(isGood)
if(isGood.toString().toLowerCase().includes("order passed ai test") || isGood.toString().toLowerCase().includes("order failed ai test") || isGood.toString().toLowerCase() == 'true' || isGood.toString().toLowerCase() == 'false') {
if(isGood.toString().toLowerCase().includes("order passed ai test")) {
isGood = true;
@@ -7314,13 +7331,13 @@
${translateThis("Transaction Pending")}
try {
var messageData = JSON.parse(jsondata.message);
if('recipient' in messageData && 'cipher' in messageData.recipient) {
- jsondata.image = [''];
+ jsondata.image = [];
jsondata.message = DOMPurify.sanitize(text);
jsondata.contact = '';
jsondata.title = '';
jsondata.location = '';
} else {
- var myimg = Array.isArray(messageData.image) ? messageData.image : [''];
+ var myimg = Array.isArray(messageData.image) ? messageData.image : [];
storeFile(Crypto.SHA256(JSON.stringify(myimg)), myimg);
jsondata.image = Crypto.SHA256(JSON.stringify(myimg));
jsondata.message = messageData.message;
@@ -7330,14 +7347,14 @@
${translateThis("Transaction Pending")}
}
} catch (e) {
console.log("Error loading data");
- jsondata.image = [''];
+ jsondata.image = [];
jsondata.message = DOMPurify.sanitize(text);
jsondata.contact = '';
jsondata.title = '';
jsondata.location = '';
}
} else {
- jsondata.image = [''];
+ jsondata.image = [];
jsondata.message = '';
jsondata.title = '';
jsondata.location = '';
@@ -7415,10 +7432,13 @@
${translateThis("Transaction Pending")}
if (myimg && myimg.length > 0) {
const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'];
for (let i = 0; i < myimg.length; i++) {
- const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
- if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
- dataUrl = myimg[i];
- break;
+ try {
+ const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
+ if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
+ dataUrl = myimg[i];
+ break;
+ }
+ } catch {
}
}
}
@@ -7531,10 +7551,13 @@
${translateThis("Transaction Pending")}
if (myimg && myimg.length > 0) {
const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'];
for (let i = 0; i < myimg.length; i++) {
- const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
- if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
- dataUrl2 = myimg[i];
- break;
+ try {
+ const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
+ if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
+ dataUrl2 = myimg[i];
+ break;
+ }
+ } catch {
}
}
}
@@ -7720,12 +7743,15 @@
${translateThis("Transaction Pending")}
if (myimg && myimg.length > 0) {
const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'];
- for (let i = 0; i < myimg.length; i++) {
- const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
- if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
- dataUrl3 = myimg[i];
- break;
+ try {
+ for (let i = 0; i < myimg.length; i++) {
+ const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
+ if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
+ dataUrl3 = myimg[i];
+ break;
+ }
}
+ } catch {
}
}
li3.innerHTML = `
@@ -8035,13 +8061,15 @@
${translateThis("Transaction Pending")}
const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'];
for (let j = 0; j < myimg.length; j++) {
+ try {
const mimeType = myimg[j].match(/^data:(.*?);/)[1].toLowerCase();
-
if (imageMimeTypes.includes(mimeType)) {
tempimg = '
';
foundImage = true;
break;
}
+ } catch {
+ }
}
if (!foundImage) {
@@ -8201,11 +8229,14 @@
${translateThis("Transaction Pending")}
const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'];
for (let i = 0; i < myimg.length; i++) {
- const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
- if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
- tempimg = `
`;
- foundImage = true;
- break;
+ try {
+ const mimeTypeMatch = myimg[i].match(/^data:(.*?);/);
+ if (mimeTypeMatch && imageMimeTypes.includes(mimeTypeMatch[1].toLowerCase())) {
+ tempimg = `
`;
+ foundImage = true;
+ break;
+ }
+ } catch {
}
}
@@ -8593,7 +8624,7 @@
${notification.message[0] || "Default Title"}
throw new Error("Failed");
}
var messageData = JSON.parse(thisText);
- var myimg = Array.isArray(messageData.image) ? messageData.image : [''];
+ var myimg = Array.isArray(messageData.image) ? messageData.image : [];
storeFile(Crypto.SHA256(JSON.stringify(myimg)), myimg);
storeFile(Crypto.SHA256(listing.message), thisText);
listing.image = Crypto.SHA256(JSON.stringify(myimg));
@@ -10449,6 +10480,7 @@
${notification.message[0] || "Default Title"}
});
if (response.isConfirmed) {
await registerData();
+ return;
} else {
return;
}
@@ -11061,7 +11093,9 @@
` + translateThis('Create Contract') + `
};
if(contractDetails || title || location) {
if(sightengineApiUser != '') {
+ showLoader(1);
var isGood = await validateOrderData(orderData);
+ hideLoader();
if(!isGood) {
await Swal.fire(translateThis("Your title or description has been flagged as inappropriate. Please try again with a different title or description.")+" "+translateThis("Orders should not contain links, sex, violence, fraud, drugs, weapons, insults, etc."));
return false;
@@ -11178,7 +11212,9 @@
` + translateThis('Create Contract') + `
return false;
}
} else {
+ showLoader(1);
var isGood = await validateOrderData(orderData, '', true);
+ hideLoader();
var validated = false;
if(isGood.toString().toLowerCase().includes("order passed ai test") || isGood.toString().toLowerCase().includes("order failed ai test")) {
if(isGood.toString().toLowerCase().includes("order passed ai test")) {
@@ -11638,6 +11674,7 @@
` + translateThis('Create Contract') + `
});
if (response.isConfirmed) {
await registerData();
+ return;
} else {
return;
}
diff --git a/node/index.html b/node/index.html
index abbdda4..8ffef4d 100644
--- a/node/index.html
+++ b/node/index.html
@@ -402,6 +402,18 @@
title: DOMPurify.sanitize(message?.title),
location: DOMPurify.sanitize(message?.location)
};
+ orderData['image'] = orderData.image.map((img, index) => {
+ try {
+ const mime = img.match(/^data:(.*);base64,/)[1]; // Match base64 data URL
+ if (['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml'].includes(mime)) {
+ dataURLtoFile(img, `image${index}.${mime.split('/')[1]}`);
+ return img;
+ }
+ } catch {
+ return null; // Return null for invalid or non-base64 images
+ }
+ return null; // Return null for any image that doesn't match the valid mime types
+ }).filter(img => img !== null);
} catch (e) {
return {'false':'Invalid JSON'};
}
@@ -430,7 +442,7 @@
} else {
if('ipfs' in request) {
userData.IPFSRequests += 1;
- var ipfshash = await pinToPinataIPFS(message);
+ var ipfshash = await pinToPinataIPFS(JSON.stringify(message));
console.log(ipfshash)
if(ipfshash == "error") {
return {'false': "error posting to ipfs"};