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
23
floDapps.js
23
floDapps.js
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //floDapps v2.3.1a
|
(function(EXPORTS) { //floDapps v2.3.2
|
||||||
/* General functions for FLO Dapps*/
|
/* General functions for FLO Dapps*/
|
||||||
'use strict';
|
'use strict';
|
||||||
const floDapps = EXPORTS;
|
const floDapps = EXPORTS;
|
||||||
@ -40,6 +40,18 @@
|
|||||||
else
|
else
|
||||||
return Crypto.AES.decrypt(user_private, aes_key);
|
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() {
|
get db_name() {
|
||||||
return "floDapps#" + user.id;
|
return "floDapps#" + user.id;
|
||||||
},
|
},
|
||||||
@ -240,7 +252,7 @@
|
|||||||
resolve(inputVal)
|
resolve(inputVal)
|
||||||
});
|
});
|
||||||
|
|
||||||
function getCredentials(lock_key) {
|
function getCredentials() {
|
||||||
|
|
||||||
const readSharesFromIDB = indexArr => new Promise((resolve, reject) => {
|
const readSharesFromIDB = indexArr => new Promise((resolve, reject) => {
|
||||||
var promises = []
|
var promises = []
|
||||||
@ -336,9 +348,6 @@
|
|||||||
let n = floCrypto.randInt(12, 20);
|
let n = floCrypto.randInt(12, 20);
|
||||||
aes_key = floCrypto.randString(n);
|
aes_key = floCrypto.randString(n);
|
||||||
user_priv_raw = Crypto.AES.encrypt(privKey, aes_key);
|
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')
|
resolve('Login Credentials loaded successful')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -384,7 +393,7 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
floDapps.launchStartUp = function(options = {}) {
|
floDapps.launchStartUp = function() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
initIndexedDB().then(log => {
|
initIndexedDB().then(log => {
|
||||||
console.log(log)
|
console.log(log)
|
||||||
@ -399,7 +408,7 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
let p2 = new Promise((res, rej) => {
|
let p2 = new Promise((res, rej) => {
|
||||||
callAndLog(getCredentials(options.lock_key)).then(r => {
|
callAndLog(getCredentials()).then(r => {
|
||||||
callAndLog(initUserDB()).then(r => {
|
callAndLog(initUserDB()).then(r => {
|
||||||
callAndLog(loadUserDB())
|
callAndLog(loadUserDB())
|
||||||
.then(r => res(true))
|
.then(r => res(true))
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
//floDapps.addStartUpFunction('Sample', Promised Function)
|
//floDapps.addStartUpFunction('Sample', Promised Function)
|
||||||
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
||||||
//floDapps.setCustomPrivKeyInput( () => { FUNCTION BODY *must resolve private key* } )
|
//floDapps.setCustomPrivKeyInput( () => { FUNCTION BODY *must resolve private key* } )
|
||||||
floDapps.launchStartUp( /*{lock_key: true}*/ ).then(result => {
|
floDapps.launchStartUp().then(result => {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
alert(`Welcome FLO_ID: ${myFloID}`)
|
alert(`Welcome FLO_ID: ${myFloID}`)
|
||||||
//App functions....
|
//App functions....
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user