Fix owner registration, find, get

parent f45c1956
......@@ -23,7 +23,9 @@ function setOwnerKeys (app, ownerKeys = null) {
encryptedPrivateSigningKey: mainKeyObject.encryptedPrivateSigningKey
}
ownerPublicSigningKey = mainKeyObject.publicSigningKey
ownerPublicSigningKey = {
publicSigningKey: mainKeyObject.publicSigningKey
}
}
if (ownerKeys === null && fs.existsSync(ownerKeysFilePath)) {
......
......@@ -17,14 +17,24 @@ class Service {
}
async get (id, params) {
console.log(`ID: ${id}`)
switch (id) {
case 'encrypted-private-signing-key':
return this.app.get('ownerEncryptedPrivateSigningKey')
case 'public-signing-key':
return this.app.get('ownerPublicSigningKey')
default:
throw new errors.MethodNotAllowed()
const getKey = keyName => {
const key = this.app.get(keyName)
if (key === null) throw new errors.NotFound('Key not set.')
return key
}
try {
switch (id) {
case 'encrypted-private-signing-key':
return getKey('ownerEncryptedPrivateSigningKey')
case 'public-signing-key':
return getKey('ownerPublicSigningKey')
default:
throw new errors.NotFound('Key type does not exist.')
}
} catch (error) {
/* re- */ throw error
}
}
......
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