{Utils, React, Actions} = require 'nylas-exports'
PGPKeyStore = require './pgp-key-store'
KeybaseUser = require './keybase-user'
PassphrasePopover = require './passphrase-popover'
kb = require './keybase'
_ = require 'underscore'
pgp = require 'kbpgp'
fs = require 'fs'
module.exports =
class KeyManager extends React.Component
@displayName: 'KeyManager'
@propTypes:
pubKeys: React.PropTypes.array.isRequired
privKeys: React.PropTypes.array.isRequired
constructor: (props) ->
super(props)
_exportPopoverDone: (passphrase, identity) =>
# check the passphrase before opening the save dialog
fs.readFile(identity.keyPath, (err, data) =>
pgp.KeyManager.import_from_armored_pgp {
armored: data
}, (err, km) =>
if err
console.warn err
else
km.unlock_pgp { passphrase: passphrase }, (err) =>
if err
PGPKeyStore._displayError(err)
else
PGPKeyStore.exportKey({identity: identity, passphrase: passphrase})
)
_exportPrivateKey: (identity, event) =>
popoverTarget = event.target.getBoundingClientRect()
Actions.openPopover(