Bug fix: floDapps

- Fixed: setCustomPrivKeyInput not working
- Added semicolon at the end of all stdop files
This commit is contained in:
sairajzero 2022-04-02 02:06:44 +05:30
parent 5bb0ee8588
commit 4b7f6184a3
3 changed files with 15 additions and 16 deletions

View File

@ -256,4 +256,4 @@
} }
})(window.compactIDB = {}) })(window.compactIDB = {});

View File

@ -917,4 +917,4 @@
})(); })();
})('object' === typeof module ? module.exports : window.floCloudAPI = {}) })('object' === typeof module ? module.exports : window.floCloudAPI = {});

View File

@ -1,4 +1,4 @@
(function(EXPORTS) { //floDapps v2.2.0 (function(EXPORTS) { //floDapps v2.2.0a
/* General functions for FLO Dapps*/ /* General functions for FLO Dapps*/
//'use strict'; //'use strict';
const floDapps = EXPORTS; const floDapps = EXPORTS;
@ -146,16 +146,15 @@
}) })
}); });
function getCredentials() { var keyInput = type => new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `)
if (inputVal === null)
reject(null)
else
resolve(inputVal)
});
const inputFn = getCredentials.privKeyInput || function getCredentials() {
(type => new Promise((resolve, reject) => {
let inputVal = prompt(`Enter ${type}: `)
if (inputVal === null)
reject(null)
else
resolve(inputVal)
}));
const readSharesFromIDB = indexArr => new Promise((resolve, reject) => { const readSharesFromIDB = indexArr => new Promise((resolve, reject) => {
var promises = [] var promises = []
@ -195,7 +194,7 @@
.catch(error => reject(error)) .catch(error => reject(error))
} else { } else {
var privKey; var privKey;
inputFn("PRIVATE_KEY").then(result => { keyInput("PRIVATE_KEY").then(result => {
if (!result) if (!result)
return reject("Empty Private Key") return reject("Empty Private Key")
var floID = floCrypto.getFloID(result) var floID = floCrypto.getFloID(result)
@ -229,7 +228,7 @@
if (key.length == 52) if (key.length == 52)
resolve(key) resolve(key)
else { else {
inputFn("PIN/Password").then(pwd => { keyInput("PIN/Password").then(pwd => {
try { try {
let privKey = Crypto.AES.decrypt(key, pwd); let privKey = Crypto.AES.decrypt(key, pwd);
resolve(privKey) resolve(privKey)
@ -327,7 +326,7 @@
floDapps.setCustomStartupLogger = fn => fn instanceof Function ? startUpLog = fn : false; floDapps.setCustomStartupLogger = fn => fn instanceof Function ? startUpLog = fn : false;
floDapps.setCustomPrivKeyInput = fn => fn instanceof Function ? customFn = fn : false; floDapps.setCustomPrivKeyInput = fn => fn instanceof Function ? keyInput = fn : false;
floDapps.setAppObjectStores = appObs => initIndexedDB.appObs = appObs; floDapps.setAppObjectStores = appObs => initIndexedDB.appObs = appObs;
@ -600,4 +599,4 @@
.catch(error => reject(error)) .catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}); });
})('object' === typeof module ? module.exports : window.floDapps = {}) })('object' === typeof module ? module.exports : window.floDapps = {});