summaryrefslogtreecommitdiffstats
path: root/lib/response.js
diff options
context:
space:
mode:
authorJannis R <mail@jannisr.de>2020-05-03 01:36:16 +0200
committerJannis R <mail@jannisr.de>2020-05-03 01:36:16 +0200
commitfbf45404d5810def49b47609cb2a70a09374bc58 (patch)
treeff8dc729031b1472fe7496b59e978817fd2b9709 /lib/response.js
parentc6a417420e4e82611fdf940d9b7403b8479f8dfc (diff)
TOFU client certificates, part 1
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js18
1 files changed, 12 insertions, 6 deletions
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()