Ind.ie is now Small Technology Foundation.
Commit 09e3e913 authored by wim-vantomme's avatar wim-vantomme

Added a route for the encrypted private key.

parent 37e102ad
......@@ -45,6 +45,8 @@ __0.1.0__
- Imported the private key as unextractable.
- Saved unextractable private key to IndexedDB.
- Transfer publicKey and encryptedPrivateKey to the server
- Made encryptedPublicKey accessible from a route on the server
- Made encryptedPrivateKey accessible from a route on the server
## License
......
......@@ -15,9 +15,9 @@ app.post('/register', (req, res) => {
const publicKey = JSON.stringify({publickKey: req.body.publicKey})
const privateKey = JSON.stringify({privateKey: req.body.privateKey})
const writeSalt = fileUtils.writeFile('./server/files/salt.txt', salt)
const writePublicKey = fileUtils.writeFile('./server/files/publickey.pem', publicKey)
const writePrivateKey = fileUtils.writeFile('./server/files/privatekey.pem', privateKey)
const writeSalt = fileUtils.writeFile('./server/files/salt.json', salt)
const writePublicKey = fileUtils.writeFile('./server/files/publickey.json', publicKey)
const writePrivateKey = fileUtils.writeFile('./server/files/privatekey.json', privateKey)
Promise.all([writeSalt, writePublicKey, writePrivateKey]).then(() => {
res.status(200).end()
......@@ -27,7 +27,17 @@ app.post('/register', (req, res) => {
})
app.get('/publickey', (req, res) => {
fileUtils.readFile('./server/files/publickey.pem').then((data) => {
fileUtils.readFile('./server/files/publickey.json').then((data) => {
data = JSON.parse(data)
res.status(200).send(data)
}).catch((err) => {
res.status(500).send('Ooops, something went wrong')
console.log(err)
})
})
app.get('/privatekey', (req, res) => {
fileUtils.readFile('./server/files/privatekey.json').then((data) => {
data = JSON.parse(data)
res.status(200).send(data)
}).catch((err) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment