This commit is contained in:
Josh Harvey 2016-10-22 00:28:43 +03:00
parent ff162775a1
commit 594228e871

View file

@ -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 db = require('./db')
const CA_PATH = path.resolve(__dirname, '..', 'ca-cert.pem')
function pullToken (token) { function pullToken (token) {
const sql = `delete from pairing_tokens const sql = `delete from pairing_tokens
where token=$1 where token=$1
@ -23,6 +29,10 @@ function authorizeCaDownload (caToken) {
return pullToken(caToken) return pullToken(caToken)
} }
function ca () {
return readFile(CA_PATH)
}
function isPaired (deviceId) { function isPaired (deviceId) {
const sql = 'select device_id from paired_devices where device_id=$1' const sql = 'select device_id from paired_devices where device_id=$1'
@ -30,4 +40,4 @@ function isPaired (deviceId) {
.then(() => true) .then(() => true)
} }
module.exports = {pair, authorizeCaDownload, isPaired} module.exports = {pair, authorizeCaDownload, ca, isPaired}