WIP
This commit is contained in:
parent
ff162775a1
commit
594228e871
1 changed files with 11 additions and 1 deletions
12
lib/pair.js
12
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 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}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue