From fbf45404d5810def49b47609cb2a70a09374bc58 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sun, 3 May 2020 01:36:16 +0200 Subject: TOFU client certificates, part 1 --- lib/response.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/response.js') diff --git a/lib/response.js b/lib/response.js index ad27c75..442cea0 100644 --- a/lib/response.js +++ b/lib/response.js @@ -47,19 +47,25 @@ const createResponse = () => { res.statusCode = CODES.SUCCESS res.meta = '' res.mimeType = null - - // API res.sendHeader = sendHeader + + // convenience API res.prompt = (promptMsg) => { if (typeof promptMsg !== 'string') { throw new Error('invalid promptMsg') } - sendHeader(10, promptMsg) - res.push(null) + sendHeader(CODES.INPUT, promptMsg) } res.gone = () => { - sendHeader(51) - res.push(null) + sendHeader(CODES.GONE) + } + res.requestTransientClientCert = (reason) => { + if (typeof reason !== 'string') throw new Error('invalid reason') + sendHeader(CODES.TRANSIENT_CERT_REQUESTED, reason) + } + res.requestAuthorizedClientCert = (reason) => { + if (typeof reason !== 'string') throw new Error('invalid reason') + sendHeader(CODES.AUTHORISED_CERT_REQUIRED, reason) } // todo: redirect(), serverUnavailable(), slowDown(), badRequest() -- cgit v1.3