Migrate HKP api
This commit is contained in:
parent
49b24a5cb4
commit
4081463dfa
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const parse = require('co-body');
|
|
||||||
const util = require('../service/util');
|
const util = require('../service/util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,13 +36,13 @@ class HKP {
|
|||||||
* Public key upload via http POST
|
* Public key upload via http POST
|
||||||
* @param {Object} ctx The koa request/response context
|
* @param {Object} ctx The koa request/response context
|
||||||
*/
|
*/
|
||||||
*add(ctx) {
|
async add(ctx) {
|
||||||
const {keytext: publicKeyArmored} = yield parse.form(ctx, {limit: '1mb'});
|
const publicKeyArmored = ctx.request.body.keytext;
|
||||||
if (!publicKeyArmored) {
|
if (!publicKeyArmored) {
|
||||||
ctx.throw(400, 'Invalid request!');
|
ctx.throw(400, 'Invalid request!');
|
||||||
}
|
}
|
||||||
const origin = util.origin(ctx);
|
const origin = util.origin(ctx);
|
||||||
yield this._publicKey.put({publicKeyArmored, origin});
|
await this._publicKey.put({publicKeyArmored, origin});
|
||||||
ctx.body = 'Upload successful. Check your inbox to verify your email address.';
|
ctx.body = 'Upload successful. Check your inbox to verify your email address.';
|
||||||
ctx.status = 201;
|
ctx.status = 201;
|
||||||
}
|
}
|
||||||
@ -52,9 +51,9 @@ class HKP {
|
|||||||
* Public key lookup via http GET
|
* Public key lookup via http GET
|
||||||
* @param {Object} ctx The koa request/response context
|
* @param {Object} ctx The koa request/response context
|
||||||
*/
|
*/
|
||||||
*lookup(ctx) {
|
async lookup(ctx) {
|
||||||
const params = this.parseQueryString(ctx);
|
const params = this.parseQueryString(ctx);
|
||||||
const key = yield this._publicKey.get(params);
|
const key = await this._publicKey.get(params);
|
||||||
this.setGetHeaders(ctx, params);
|
this.setGetHeaders(ctx, params);
|
||||||
this.setGetBody(ctx, params, key);
|
this.setGetBody(ctx, params, key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user