This commit is contained in:
Keerthana-A-V 2021-12-01 21:19:40 +05:30
parent 038bced804
commit 89caff5c13
59 changed files with 176 additions and 650 deletions

View File

@ -392,12 +392,12 @@
let columnName =`column${col}_count`;
console.log(element)
console.log(element.classList)
if (myFloID!=undefined) {
if (myFloID1!=undefined) {
if (element.classList.value == "fa fa-thumbs-o-up")
{
let articlekey =articlekeey
let mainObj = {
floID: myFloID,
floID: myFloID1,
articlekey: articlekey,
};
console.log("mainObj")
@ -423,16 +423,11 @@
</script>
<script id="onLoadStartUp">
var myFloID,col,articlekeey,myPrivKey;
var myFloID1,col,articlekeey,myPrivKey;
function onLoadStartUp(){
floDapps.launchStartUp().then(result => {
console.log(result)
console.log(`Welcome FLO_ID: ${myFloID}`)
//App functions....
}).catch(error => console.error(error))
floDapps.launchStartUp()
var b=JSON.parse(sessionStorage.getItem("z"))
myFloID=(sessionStorage.getItem("m"))
myFloID1=(sessionStorage.getItem("m"))
col=(sessionStorage.getItem("col"))
console.log(col)
articlekeey=(sessionStorage.getItem("articlename"))

View File

@ -10007,9 +10007,9 @@ Coming to Afropunk festival which will begin on 28th and 29th of November.  In
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10065,9 +10065,9 @@ Henceforth, Huawei is likely to follow the path which involves Washington granti
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10071,9 +10071,9 @@ Banning NGOs is not a solution whereas the government should keep our eye on NGO
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10024,9 +10024,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10163,9 +10163,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10481,9 +10481,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10034,9 +10034,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10093,9 +10093,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10143,9 +10143,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10065,9 +10065,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10067,9 +10067,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10163,9 +10163,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};
@ -10472,7 +10472,6 @@
reactor.registerEvent("startUpErrorLog");
reactor.addEventListener("startUpErrorLog", (log) => console.error(log));
</script>
<script id="webAppClient">
//Add this to the client script to request data from floWebappServer
const webAppClient = {

View File

@ -10049,9 +10049,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10115,9 +10115,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10132,9 +10132,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10030,9 +10030,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10034,9 +10034,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10037,9 +10037,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10131,9 +10131,9 @@ Local markets, where farmers sell their products directly in their local areas.
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10041,9 +10041,9 @@ Big data can be presented in zettabytes (a unit of data information, 10^21 bytes
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10069,9 +10069,9 @@ While the Government of India has taken significant measures for the industry, i
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10108,9 +10108,9 @@ The government of India and the technology companies that function right here sh
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10043,9 +10043,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10166,9 +10166,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10133,9 +10133,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10583,9 +10583,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10102,9 +10102,9 @@ With a past record of being an agency actively opposing innovation Reserve Bank
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10070,9 +10070,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10098,9 +10098,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10110,9 +10110,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10033,9 +10033,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10100,9 +10100,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10068,9 +10068,9 @@ Contemporary sustainability tried to bridge the gaps conventional couldn't by en
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10146,9 +10146,9 @@ This deal has knocked hard on the Future Group and it might result in the closur
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10009,9 +10009,9 @@ A real life tragic death has turned into a crucial opportunity for media and pol
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10303,9 +10303,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10189,9 +10189,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10538,9 +10538,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10165,9 +10165,9 @@ The future impact of quantum sensing can be revolutionary in many scientific and
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10189,9 +10189,9 @@ In conclusion, we should have multiple structured debates between senior leaders
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10038,9 +10038,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10021,9 +10021,9 @@ As table can turn anytime, there is an equal chance for both of them to win the
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10358,9 +10358,9 @@ It might be controlled through money printed by the RBI - It directly depends on
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10170,9 +10170,9 @@ Unfortunately, India isn't able to build such a reciprocal gesture. We are caref
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10085,9 +10085,9 @@ Nevertheless, Death of Ella kissi- Debrah at the age of 9, Sparkle the foglamp o
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10137,9 +10137,9 @@ This trade asymmetry is mainly compounded by the nature of goods flow. India exp
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10100,9 +10100,9 @@ Walmart Indias US parent, Walmart had reported a 5.6 % increase in its revenu
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10526,9 +10526,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10047,9 +10047,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10435,9 +10435,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10588,9 +10588,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -11247,9 +11247,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10286,475 +10286,7 @@
};
</script>
<script id="floDapps">
/* General functions for FLO Dapps*/
const floDapps = {
util: {
appObs: {},
initIndexedDB: function () {
return new Promise((resolve, reject) => {
var obj = {
//general
lastTx: {},
//supernode (cloud list)
supernodes: {
indexes: {
uri: null,
pubKey: null,
},
},
//login credentials
credentials: {},
//for Dapps
subAdmins: {},
appObjects: {},
vectorClock: {},
generalData: {},
generalVC: {},
};
//add other given objectStores
for (o in this.appObs) if (!(o in obj)) obj[o] = this.appObs[o];
compactIDB
.initDB(floGlobals.application, obj)
.then((result) => {
resolve("IndexedDB App Storage Initated Successfully");
})
.catch((error) => reject(error));
});
},
startUpFunctions: {
readSupernodeListFromAPI: function () {
return new Promise((resolve, reject) => {
compactIDB
.readData("lastTx", floGlobals.SNStorageID)
.then((lastTx) => {
floBlockchainAPI
.readData(floGlobals.SNStorageID, {
ignoreOld: lastTx,
sentOnly: true,
pattern: "SuperNodeStorage",
})
.then((result) => {
for (var i = result.data.length - 1; i >= 0; i--) {
var content = JSON.parse(
result.data[i]
).SuperNodeStorage;
for (sn in content.removeNodes)
compactIDB.removeData("supernodes", sn);
for (sn in content.addNodes)
compactIDB.writeData(
"supernodes",
content.addNodes[sn],
sn
);
}
compactIDB.writeData(
"lastTx",
result.totalTxs,
floGlobals.SNStorageID
);
compactIDB.readAllData("supernodes").then((result) => {
floGlobals.supernodes = result;
floSupernode.kBucket
.launch(
Object.keys(floGlobals.supernodes),
floGlobals.SNStorageID
)
.then((result) =>
resolve("Loaded Supernode list\n" + result)
);
});
});
})
.catch((error) => reject(error));
});
},
readSubAdminListFromAPI: function () {
return new Promise((resolve, reject) => {
compactIDB
.readData("lastTx", floGlobals.adminID)
.then((lastTx) => {
floBlockchainAPI
.readData(floGlobals.adminID, {
ignoreOld: lastTx,
sentOnly: true,
pattern: floGlobals.application,
})
.then((result) => {
for (var i = result.data.length - 1; i >= 0; i--) {
var content = JSON.parse(result.data[i])[
floGlobals.application
];
if (Array.isArray(content.removeSubAdmin))
for (
var j = 0;
j < content.removeSubAdmin.length;
j++
)
compactIDB.removeData(
"subAdmins",
content.removeSubAdmin[j]
);
if (Array.isArray(content.addSubAdmin))
for (var k = 0; k < content.addSubAdmin.length; k++)
compactIDB.writeData(
"subAdmins",
true,
content.addSubAdmin[k]
);
}
compactIDB.writeData(
"lastTx",
result.totalTxs,
floGlobals.adminID
);
compactIDB.readAllData("subAdmins").then((result) => {
floGlobals.subAdmins = Object.keys(result);
resolve("Read subAdmins from blockchain");
});
});
})
.catch((error) => reject(error));
});
},
loadDataFromIDB: function () {
return new Promise((resolve, reject) => {
var loadData = [
"appObjects",
"vectorClock",
"generalData",
"generalVC",
];
var promises = [];
for (var i = 0; i < loadData.length; i++)
promises[i] = compactIDB.readAllData(loadData[i]);
Promise.all(promises)
.then((results) => {
for (var i = 0; i < loadData.length; i++)
floGlobals[loadData[i]] = results[i];
resolve("Loaded Data from IDB");
})
.catch((error) => reject(error));
});
},
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
});
};
const inputFn = this.getCredentials.privKeyInput || defaultInput;
const readSharesFromIDB = function (indexArr) {
return new Promise((resolve, reject) => {
var promises = [];
for (var i = 0; i < indexArr.length; i++)
promises.push(
compactIDB.readData("credentials", indexArr[i])
);
Promise.all(promises)
.then((shares) => {
var secret = floCrypto.retrieveShamirSecret(shares);
if (secret) resolve(secret);
else reject("Shares are insufficient or incorrect");
})
.catch((error) => reject(error));
});
};
const writeSharesToIDB = function (
shares,
i = 0,
resultIndexes = []
) {
return new Promise((resolve, reject) => {
if (i >= shares.length) return resolve(resultIndexes);
var n = floCrypto.randInt(0, 100000);
compactIDB
.addData("credentials", shares[i], n)
.then((res) => {
resultIndexes.push(n);
writeSharesToIDB(shares, i + 1, resultIndexes).then(
(result) => resolve(result)
);
})
.catch((error) => {
writeSharesToIDB(shares, i, resultIndexes).then((result) =>
resolve(result)
);
});
});
};
const getPrivateKeyCredentials = function () {
return new Promise((resolve, reject) => {
var indexArr = localStorage.getItem(
`${floGlobals.application}#privKey`
);
if (indexArr) {
readSharesFromIDB(JSON.parse(indexArr))
.then((result) => resolve(result))
.catch((error) => reject(error));
} else {
var privKey;
inputFn("PRIVATE_KEY")
.then((result) => {
try {
if (!result) return reject("Empty Private Key");
var floID = floCrypto.getFloIDfromPubkeyHex(
floCrypto.getPubKeyHex(result)
);
privKey = result;
} catch (error) {
console.error(error);
return reject("Invalid Private Key");
}
})
.catch((error) => {
console.log(error, "Generating Random Keys");
privKey = floCrypto.generateNewID().privKey;
})
.finally((_) => {
var threshold = floCrypto.randInt(10, 20);
writeSharesToIDB(
floCrypto.createShamirsSecretShares(
privKey,
threshold,
threshold
)
)
.then((resultIndexes) => {
//store index keys in localStorage
localStorage.setItem(
`${floGlobals.application}#privKey`,
JSON.stringify(resultIndexes)
);
//also add a dummy privatekey to the IDB
var randomPrivKey = floCrypto.generateNewID().privKey;
var randomThreshold = floCrypto.randInt(10, 20);
writeSharesToIDB(
floCrypto.createShamirsSecretShares(
randomPrivKey,
randomThreshold,
randomThreshold
)
);
//resolve private Key
resolve(privKey);
})
.catch((error) => reject(error));
});
}
});
};
const checkIfPinRequired = function (key) {
return new Promise((resolve, reject) => {
if (key.length == 52) resolve(key);
else {
inputFn("PIN/Password")
.then((pwd) => {
try {
let privKey = Crypto.AES.decrypt(key, pwd);
resolve(privKey);
} catch (error) {
reject("Access Denied: Incorrect PIN/Password");
}
})
.catch((error) =>
reject("Access Denied: PIN/Password required")
);
}
});
};
return new Promise((resolve, reject) => {
getPrivateKeyCredentials()
.then((key) => {
checkIfPinRequired(key)
.then((privKey) => {
try {
myPrivKey = privKey;
myPubKey = floCrypto.getPubKeyHex(myPrivKey);
myFloID = floCrypto.getFloIDfromPubkeyHex(myPubKey);
resolve("Login Credentials loaded successful");
} catch (error) {
reject("Corrupted Private Key");
}
})
.catch((error) => reject(error));
})
.catch((error) => reject(error));
});
},
},
callStartUpFunction: function (fname) {
return new Promise((resolve, reject) => {
this.startUpFunctions[fname]()
.then((result) => {
this.callStartUpFunction.completed += 1;
reactor.dispatchEvent(
"startUpSuccessLog",
`${result}\nCompleted ${this.callStartUpFunction.completed}/${this.callStartUpFunction.total} Startup functions`
);
resolve(true);
})
.catch((error) => {
this.callStartUpFunction.failed += 1;
reactor.dispatchEvent(
"startUpErrorLog",
`${error}\nFailed ${this.callStartUpFunction.failed}/${this.callStartUpFunction.total} Startup functions`
);
reject(false);
});
});
},
getFilterString: function (type, options = {}) {
var filterStr = JSON.stringify({
application: options.application || floGlobals.application,
type: type,
comment: options.comment,
});
return filterStr;
},
},
launchStartUp: function () {
return new Promise((resolve, reject) => {
this.util.initIndexedDB().then((log) => {
console.log(log);
this.util.callStartUpFunction.total = Object.keys(
this.util.startUpFunctions
).length;
this.util.callStartUpFunction.completed = 0;
this.util.callStartUpFunction.failed = 0;
var promises = [];
for (fn in this.util.startUpFunctions)
promises.push(this.util.callStartUpFunction(fn));
Promise.all(promises)
.then((results) => resolve("App Startup finished successful"))
.catch((errors) => reject("App StartUp failed"));
});
});
},
addStartUpFunction: function (fname, fn) {
if (fname in this.util.startUpFunctions)
throw `Function ${fname} already defined`;
this.util.startUpFunctions[fname] = fn;
},
setCustomPrivKeyInput: function (customFn) {
this.util.startUpFunctions.getCredentials.privKeyInput = customFn;
},
setAppObjectStores: function (appObs) {
this.util.appObs = appObs;
},
manageSubAdmins(adminPrivKey, addList, rmList) {
return new Promise((resolve, reject) => {
if (!Array.isArray(addList)) addList = undefined;
if (!Array.isArray(rmList)) rmList = undefined;
var floData = {
[floGlobals.application]: {
addSubAdmin: addList,
removeSubAdmin: rmList,
},
};
var floID = floCrypto.getFloIDfromPubkeyHex(
floCrypto.getPubKeyHex(adminPrivKey)
);
if (floID != floGlobals.adminID)
reject("Access Denied for Admin privilege");
else
floBlockchainAPI
.writeData(floID, JSON.stringify(floData), adminPrivKey)
.then((result) => resolve(["Updated SubAdmin List", result]))
.catch((error) => reject(error));
});
},
clearCredentials: function () {
return new Promise((resolve, reject) => {
compactIDB
.clearData("credentials")
.then((result) => {
localStorage.removeItem(`${floGlobals.application}#privKey`);
myPrivKey = myPubKey = myFloID = undefined;
resolve("privKey credentials deleted!");
})
.catch((error) => reject(error));
});
},
securePrivKey: function (pwd) {
return new Promise((resolve, reject) => {
let indexArr = localStorage.getItem(
`${floGlobals.application}#privKey`
);
if (!indexArr) return reject("PrivKey not found");
indexArr = JSON.parse(indexArr);
let encryptedKey = Crypto.AES.encrypt(myPrivKey, pwd);
let threshold = indexArr.length;
let shares = floCrypto.createShamirsSecretShares(
encryptedKey,
threshold,
threshold
);
let promises = [];
for (var i = 0; i < threshold; i++)
promises.push(
compactIDB.writeData(
"credentials",
shares[i],
indexArr[i],
floGlobals.application
)
);
Promise.all(promises)
.then((results) => resolve("Private Key Secured"))
.catch((error) => reject(error));
});
},
objectDataMapper: function (object, path, data) {
var resObject = JSON.parse(JSON.stringify(object));
var pos = resObject;
path.forEach((p) => (pos = pos[p]));
if (Array.isArray(pos)) {
pos.push(data);
return resObject;
} else throw "Path is not an Array";
},
getNextGeneralData: function (type, vectorClock, options = {}) {
var filter = this.util.getFilterString(type, options);
var filteredResult = [];
for (var i = 0; i < floGlobals.generalData[filter].length; i++)
if (floGlobals.generalData[filter][i].vectorClock > vectorClock)
filteredResult.push(floGlobals.generalData[filter][i]);
return filteredResult;
},
};
reactor.registerEvent("startUpSuccessLog");
reactor.addEventListener("startUpSuccessLog", (log) => console.log(log));
reactor.registerEvent("startUpErrorLog");
reactor.addEventListener("startUpErrorLog", (log) => console.error(log));
</script>
<script id="webAppClient">
//Add this to the client script to request data from floWebappServer

View File

@ -10195,9 +10195,9 @@ Therefore, the digital revolution is considered a disruptive innovation in the f
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -9985,9 +9985,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10129,9 +10129,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -10579,9 +10579,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};

View File

@ -9984,9 +9984,9 @@
getCredentials: function () {
const defaultInput = function (type) {
return new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `);
if (inputVal === null) reject(null);
else resolve(inputVal);
// let inputVal = prompt(`Enter ${type}: `);
// if (inputVal === null) reject(null);
// else resolve(inputVal);
});
};