~ev/tildeprotocol

b82b3ae311158469cae7271120d2cda2b250e465 — Ev Bogue 4 years ago 566e0e8
we should really move the keypair out of the program dir so that it is not served on the server
1 files changed, 6 insertions(+), 3 deletions(-)

M util.js
M util.js => util.js +6 -3
@@ 3,6 3,7 @@ if ((typeof process !== 'undefined') && (process.release.name === 'node')) {
  var nacl = require('tweetnacl')
      nacl.util = require('tweetnacl-util')
  var ed2curve = require('ed2curve')
  var homedir = require('os').homedir()
}




@@ 70,7 71,7 @@ function generatekey () {
async function keys () {
  try {
    if (fs) {
      var keypair = fs.readFileSync(__dirname + '/keypair', 'UTF-8')
      var keypair = fs.readFileSync(homedir + '/.tilde/keypair', 'UTF-8')
    } else {
      var keypair = await localforage.getItem('id')
      if (keypair === null) {


@@ 81,10 82,12 @@ async function keys () {
  } catch (err) {
    var keypair = generatekey()
    if (fs) {
      fs.writeFileSync(__dirname + '/keypair', keypair, 'UTF-8')
      if (!fs.existsSync(homedir + '/.tilde')){
        fs.mkdirSync(homedir + '/.tilde')
      }
      fs.writeFileSync(homedir + '/.tilde/keypair', keypair, 'UTF-8')
    }
  }
  console.log(keypair)
  return keypair
}