diff --git a/lib/pair.js b/lib/pair.js index 148bef0a..8ff9d079 100644 --- a/lib/pair.js +++ b/lib/pair.js @@ -1,5 +1,11 @@ +const path = require('path') +const fs = require('fs') +const pify = require('pify') +const readFile = pify(fs.readFile) const db = require('./db') +const CA_PATH = path.resolve(__dirname, '..', 'ca-cert.pem') + function pullToken (token) { const sql = `delete from pairing_tokens where token=$1 @@ -23,6 +29,10 @@ function authorizeCaDownload (caToken) { return pullToken(caToken) } +function ca () { + return readFile(CA_PATH) +} + function isPaired (deviceId) { const sql = 'select device_id from paired_devices where device_id=$1' @@ -30,4 +40,4 @@ function isPaired (deviceId) { .then(() => true) } -module.exports = {pair, authorizeCaDownload, isPaired} +module.exports = {pair, authorizeCaDownload, ca, isPaired}