-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
34 lines (26 loc) · 912 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { Router } = require('express');
const uuidv4 = require('uuid').v4;
const ecc = require('eosjs-ecc');
const sha256 = x => ecc.sha256(x);
const routes = Router();
const wallets = require('./wallets');
// const proofKey = config('PROOF_KEY');
const returnResult = (data, req, res) => {
// let {proof} = req.headers;
// if(proof && proof.length === 64){
// proof = ecc.sign(proof, proofKey);
// res.append('proof', proof);
// }
res.json(data);
};
routes.get('/app/connect/:device', async (req, res) => {
const {device} = req.params;
console.log('connected', sha256(req.ipData+device), req.ipData, device);
const uuid = wallets[sha256(req.ipData+device)];
if(!uuid) return returnResult(false, req, res);
returnResult(uuid, req, res);
});
const createSocket = require('./sockets');
const socket = createSocket();
routes.all('*', (req, res) => res.sendStatus(403));
module.exports = routes;