Minor bug fixes
This commit is contained in:
parent
99ce43c089
commit
b0e15d1a7f
@ -7867,7 +7867,7 @@ Bitcoin.Util = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script id="floCloudAPI" version="2.0.2a">
|
<script id="floCloudAPI" version="2.0.2b">
|
||||||
/* FLO Cloud operations to send/request application data*/
|
/* FLO Cloud operations to send/request application data*/
|
||||||
const floCloudAPI = {
|
const floCloudAPI = {
|
||||||
|
|
||||||
@ -8068,7 +8068,7 @@ Bitcoin.Util = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
liveRequest: function (floID, datareq, callback) {
|
liveRequest: function (floID, datareq, callback) {
|
||||||
request = {
|
let request = {
|
||||||
...datareq.request
|
...datareq.request
|
||||||
};
|
};
|
||||||
const checkFilter = (v, d, r) =>
|
const checkFilter = (v, d, r) =>
|
||||||
@ -8090,15 +8090,18 @@ Bitcoin.Util = {
|
|||||||
else if (evt.data.startsWith(floID, 1))
|
else if (evt.data.startsWith(floID, 1))
|
||||||
var i = 36
|
var i = 36
|
||||||
else return;
|
else return;
|
||||||
|
let d = e = null;
|
||||||
try {
|
try {
|
||||||
let data = JSON.parse(evt.data.substring(i))
|
let data = JSON.parse(evt.data.substring(i))
|
||||||
let filter = {}
|
let filter = {}
|
||||||
for (let v in data)
|
for (let v in data)
|
||||||
if (checkFilter(v, data[v], request))
|
if (checkFilter(v, data[v], request))
|
||||||
filter[v] = data[v]
|
filter[v] = data[v]
|
||||||
callback(filter, null)
|
d = filter
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
callback(null, evt.data.substring(i))
|
e = evt.data.substring(i)
|
||||||
|
} finally {
|
||||||
|
callback(d, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.liveRequest[randID] = node;
|
this.liveRequest[randID] = node;
|
||||||
@ -8629,7 +8632,7 @@ Bitcoin.Util = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script id="floDapps" version="2.0.1">
|
<script id="floDapps" version="2.0.1a">
|
||||||
/* General functions for FLO Dapps*/
|
/* General functions for FLO Dapps*/
|
||||||
const floDapps = {
|
const floDapps = {
|
||||||
|
|
||||||
@ -9029,14 +9032,14 @@ Bitcoin.Util = {
|
|||||||
return reject("Invalid floID!")
|
return reject("Invalid floID!")
|
||||||
compactIDB.writeData("contacts", name, floID, `floDapps#${myFloID}`).then(result => {
|
compactIDB.writeData("contacts", name, floID, `floDapps#${myFloID}`).then(result => {
|
||||||
floGlobals.contacts[floID] = name;
|
floGlobals.contacts[floID] = name;
|
||||||
resolve(result)
|
resolve("Contact stored")
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
storePubKey(floID, pubKey) {
|
storePubKey(floID, pubKey) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (floID in floGlobals.pubKey)
|
if (floID in floGlobals.pubKeys)
|
||||||
return resolve("pubKey already stored")
|
return resolve("pubKey already stored")
|
||||||
if (!floCrypto.validateAddr(floID))
|
if (!floCrypto.validateAddr(floID))
|
||||||
return reject("Invalid floID!")
|
return reject("Invalid floID!")
|
||||||
@ -9044,7 +9047,7 @@ Bitcoin.Util = {
|
|||||||
return reject("Incorrect pubKey")
|
return reject("Incorrect pubKey")
|
||||||
compactIDB.writeData("pubKeys", pubKey, floID, `floDapps#${myFloID}`).then(result => {
|
compactIDB.writeData("pubKeys", pubKey, floID, `floDapps#${myFloID}`).then(result => {
|
||||||
floGlobals.pubKeys[floID] = pubKey;
|
floGlobals.pubKeys[floID] = pubKey;
|
||||||
resolve(result)
|
resolve("pubKey stored")
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -9074,8 +9077,10 @@ Bitcoin.Util = {
|
|||||||
}
|
}
|
||||||
options.callback = (d, e) => {
|
options.callback = (d, e) => {
|
||||||
for (let v in d) {
|
for (let v in d) {
|
||||||
if ("secret" in d[v].message)
|
try {
|
||||||
d[v].message = floCrypto.decryptData(d[v].message, myPrivKey)
|
if (d[v].message instanceof Object && "secret" in d[v].message)
|
||||||
|
d[v].message = floCrypto.decryptData(d[v].message, myPrivKey)
|
||||||
|
} catch (error) {}
|
||||||
compactIDB.writeData("messages", d[v], v, `floDapps#${myFloID}`)
|
compactIDB.writeData("messages", d[v], v, `floDapps#${myFloID}`)
|
||||||
floGlobals.messages[v] = d[v]
|
floGlobals.messages[v] = d[v]
|
||||||
}
|
}
|
||||||
@ -9115,7 +9120,7 @@ Bitcoin.Util = {
|
|||||||
|
|
||||||
clearCredentials: function () {
|
clearCredentials: function () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
compactIDB.clearData('credentials').then(result => {
|
compactIDB.clearData('credentials', floGlobals.application).then(result => {
|
||||||
localStorage.removeItem(`${floGlobals.application}#privKey`)
|
localStorage.removeItem(`${floGlobals.application}#privKey`)
|
||||||
myPrivKey = myPubKey = myFloID = undefined;
|
myPrivKey = myPubKey = myFloID = undefined;
|
||||||
resolve("privKey credentials deleted!")
|
resolve("privKey credentials deleted!")
|
||||||
@ -9123,11 +9128,11 @@ Bitcoin.Util = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteUserData: function(credentials = false) {
|
deleteUserData: function (credentials = false) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let p = []
|
let p = []
|
||||||
p.push(compactIDB.deleteDB(`floDapps#${myFloID}`))
|
p.push(compactIDB.deleteDB(`floDapps#${myFloID}`))
|
||||||
if(credentials)
|
if (credentials)
|
||||||
p.push(this.clearCredentials())
|
p.push(this.clearCredentials())
|
||||||
Promise.all(p)
|
Promise.all(p)
|
||||||
.then(result => resolve('User database(local) deleted'))
|
.then(result => resolve('User database(local) deleted'))
|
||||||
@ -9135,9 +9140,9 @@ Bitcoin.Util = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteAppData: function() {
|
deleteAppData: function () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
compactIDB.deleteDB().then(result => {
|
compactIDB.deleteDB(floGlobals.application).then(result => {
|
||||||
localStorage.removeItem(`${floGlobals.application}#privKey`)
|
localStorage.removeItem(`${floGlobals.application}#privKey`)
|
||||||
myPrivKey = myPubKey = myFloID = undefined;
|
myPrivKey = myPubKey = myFloID = undefined;
|
||||||
resolve("App database(local) deleted")
|
resolve("App database(local) deleted")
|
||||||
@ -9155,8 +9160,10 @@ Bitcoin.Util = {
|
|||||||
let threshold = indexArr.length;
|
let threshold = indexArr.length;
|
||||||
let shares = floCrypto.createShamirsSecretShares(encryptedKey, threshold, threshold)
|
let shares = floCrypto.createShamirsSecretShares(encryptedKey, threshold, threshold)
|
||||||
let promises = [];
|
let promises = [];
|
||||||
|
let overwriteFn = (share, index) =>
|
||||||
|
compactIDB.writeData("credentials", share, index, floGlobals.application);
|
||||||
for (var i = 0; i < threshold; i++)
|
for (var i = 0; i < threshold; i++)
|
||||||
promises.push(compactIDB.writeData("credentials", shares[i], indexArr[i]));
|
promises.push(overwriteFn(shares[i], indexArr[i]));
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(results => resolve("Private Key Secured"))
|
.then(results => resolve("Private Key Secured"))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
@ -9186,7 +9193,7 @@ Bitcoin.Util = {
|
|||||||
for (let f in filteredResult) {
|
for (let f in filteredResult) {
|
||||||
let data = filteredResult[f]
|
let data = filteredResult[f]
|
||||||
try {
|
try {
|
||||||
if ("secret" in data.message && "senderPublicKeyString" in data.message) {
|
if (data.message instanceof Object && "secret" in data.message) {
|
||||||
for (let key of decryptionKey) {
|
for (let key of decryptionKey) {
|
||||||
try {
|
try {
|
||||||
let tmp = floCrypto.decryptData(data.message, key)
|
let tmp = floCrypto.decryptData(data.message, key)
|
||||||
@ -9234,13 +9241,13 @@ Bitcoin.Util = {
|
|||||||
let sync = JSON.parse(Crypto.AES.decrypt(response[vc].message, myPrivKey))
|
let sync = JSON.parse(Crypto.AES.decrypt(response[vc].message, myPrivKey))
|
||||||
let promises = []
|
let promises = []
|
||||||
let store = (key, val, obs) =>
|
let store = (key, val, obs) =>
|
||||||
promises.push(compactIDB.writeData(obs, val, key, `floDapps#${floID}`))
|
promises.push(compactIDB.writeData(obs, val, key, `floDapps#${floID}`))[
|
||||||
["contacts", "pubKeys", "messages"].forEach(c => {
|
"contacts", "pubKeys", "messages"].forEach(c => {
|
||||||
for (let i in sync[c]) {
|
for (let i in sync[c]) {
|
||||||
store(i, sync[c][i], c)
|
store(i, sync[c][i], c)
|
||||||
floGlobals[c][i] = sync[c][i]
|
floGlobals[c][i] = sync[c][i]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(results => resolve("Sync data successful"))
|
.then(results => resolve("Sync data successful"))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user