aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyring-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r--app/scripts/keyring-controller.js44
1 files changed, 38 insertions, 6 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index d96b9c101..db7e5e61e 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -1,7 +1,7 @@
-const scrypt = require('scrypt-async')
-const bitcore = require('bitcore-lib')
-const configManager = require('./lib/config-manager')
const EventEmitter = require('events').EventEmitter
+const encryptor = require('./lib/encryptor')
+const messageManager = require('./lib/message-manager')
+
module.exports = class KeyringController extends EventEmitter {
@@ -12,12 +12,17 @@ module.exports = class KeyringController extends EventEmitter {
this.keyChains = []
}
+ keyFromPassword(password, callback) {
+ deriveKeyFromPassword(password, callback);
+ }
+
+ // Takes a pw and callback, returns a password-dervied key
getKeyForPassword(password, callback) {
let salt = this.configManager.getSalt()
if (!salt) {
salt = generateSalt(32)
- configManager.setSalt(salt)
+ this.configManager.setSalt(salt)
}
var logN = 14
@@ -39,7 +44,21 @@ module.exports = class KeyringController extends EventEmitter {
}
getState() {
- return {}
+ return {
+ isInitialized: !!this.key,
+ isUnlocked: !!this.key,
+ isConfirmed: true, // this.configManager.getConfirmed(),
+ isEthConfirmed: this.configManager.getShouldntShowWarning(),
+ unconfTxs: this.configManager.unconfirmedTxs(),
+ transactions: this.configManager.getTxList(),
+ unconfMsgs: messageManager.unconfirmedMsgs(),
+ messages: messageManager.getMsgList(),
+ selectedAddress: this.configManager.getSelectedAccount(),
+ shapeShiftTxList: this.configManager.getShapeShiftTxList(),
+ currentFiat: this.configManager.getCurrentFiat(),
+ conversionRate: this.configManager.getConversionRate(),
+ conversionDate: this.configManager.getConversionDate(),
+ }
}
setStore(ethStore) {
@@ -47,9 +66,22 @@ module.exports = class KeyringController extends EventEmitter {
}
createNewVault(password, entropy, cb) {
- cb()
+ encryptor.keyFromPassword(password)
+ .then((key) => {
+ this.key = key
+ return encryptor.encryptWithKey(key, {})
+ })
+ .then((encryptedString) => {
+ this.configManager.setVault(encryptedString)
+ cb(null, [])
+ })
+ .catch((err) => {
+ cb(err)
+ })
}
+
+
submitPassword(password, cb) {
cb()
}