floDapps v2.3.2: lock privkey by default
- Removed the options for launchStartUp - private-key is on lock mode by default - Added utility functions that uses private-key without entering password in .user .sign(message): signs message .decrypt(data): decrypts ciphertext in asymmetric .encipher(message): encrypts message in symmetric .decipher(data): decrypts ciphertext in symmetric
This commit is contained in:
parent
0a74e393ed
commit
fa3d790c6c
25
floDapps.js
25
floDapps.js
@ -1,4 +1,4 @@
|
||||
(function(EXPORTS) { //floDapps v2.3.1a
|
||||
(function(EXPORTS) { //floDapps v2.3.2
|
||||
/* General functions for FLO Dapps*/
|
||||
'use strict';
|
||||
const floDapps = EXPORTS;
|
||||
@ -40,6 +40,18 @@
|
||||
else
|
||||
return Crypto.AES.decrypt(user_private, aes_key);
|
||||
},
|
||||
sign(message) {
|
||||
return floCrypto.signData(message, raw_user.private);
|
||||
},
|
||||
decrypt(data) {
|
||||
return floCrypto.decryptData(data, raw_user.private);
|
||||
},
|
||||
encipher(message) {
|
||||
return Crypto.AES.encrypt(message, raw_user.private);
|
||||
},
|
||||
decipher(data) {
|
||||
return Crypto.AES.decrypt(data, raw_user.private);
|
||||
},
|
||||
get db_name() {
|
||||
return "floDapps#" + user.id;
|
||||
},
|
||||
@ -240,7 +252,7 @@
|
||||
resolve(inputVal)
|
||||
});
|
||||
|
||||
function getCredentials(lock_key) {
|
||||
function getCredentials() {
|
||||
|
||||
const readSharesFromIDB = indexArr => new Promise((resolve, reject) => {
|
||||
var promises = []
|
||||
@ -336,10 +348,7 @@
|
||||
let n = floCrypto.randInt(12, 20);
|
||||
aes_key = floCrypto.randString(n);
|
||||
user_priv_raw = Crypto.AES.encrypt(privKey, aes_key);
|
||||
if (!lock_key)
|
||||
user_private = user_priv_raw;
|
||||
else
|
||||
user_private = user_priv_wrap;
|
||||
user_private = user_priv_wrap;
|
||||
resolve('Login Credentials loaded successful')
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
@ -384,7 +393,7 @@
|
||||
})
|
||||
});
|
||||
|
||||
floDapps.launchStartUp = function(options = {}) {
|
||||
floDapps.launchStartUp = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
initIndexedDB().then(log => {
|
||||
console.log(log)
|
||||
@ -399,7 +408,7 @@
|
||||
})
|
||||
});
|
||||
let p2 = new Promise((res, rej) => {
|
||||
callAndLog(getCredentials(options.lock_key)).then(r => {
|
||||
callAndLog(getCredentials()).then(r => {
|
||||
callAndLog(initUserDB()).then(r => {
|
||||
callAndLog(loadUserDB())
|
||||
.then(r => res(true))
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
//floDapps.addStartUpFunction('Sample', Promised Function)
|
||||
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
||||
//floDapps.setCustomPrivKeyInput( () => { FUNCTION BODY *must resolve private key* } )
|
||||
floDapps.launchStartUp( /*{lock_key: true}*/ ).then(result => {
|
||||
floDapps.launchStartUp().then(result => {
|
||||
console.log(result)
|
||||
alert(`Welcome FLO_ID: ${myFloID}`)
|
||||
//App functions....
|
||||
|
||||
Loading…
Reference in New Issue
Block a user