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