Evan Feenstra
5 years ago
30 changed files with 33371 additions and 41 deletions
@ -0,0 +1,46 @@ |
|||
|
|||
import * as moment from 'moment' |
|||
import * as zbase32 from './zbase32' |
|||
import {signBuffer, getInfo} from './lightning' |
|||
import * as path from 'path' |
|||
import * as mqtt from 'mqtt' |
|||
|
|||
const env = process.env.NODE_ENV || 'development' |
|||
const config = require(path.join(__dirname,'../../config/app.json'))[env] |
|||
|
|||
export async function connect() { |
|||
const pwd = await genSignedTimestamp() |
|||
const info = await getInfo() |
|||
|
|||
const client = mqtt.connect(`tcp://${config.tribes_host}`,{ |
|||
username:info.identity_pubkey, |
|||
password:pwd, |
|||
}) |
|||
|
|||
client.on('connect', function () { |
|||
console.log("MQTT CLIENT CONNECTED!") |
|||
// subscribe to all public groups here
|
|||
// that you are NOT admin of (dont sub to your own!)
|
|||
}) |
|||
client.on('close', function () { |
|||
console.log("MQTT CLOSED") |
|||
}) |
|||
} |
|||
|
|||
export async function genSignedTimestamp(){ |
|||
const now = moment().unix() |
|||
const tsBytes = Buffer.from(now.toString(16), 'hex') |
|||
const sig = await signBuffer(tsBytes) |
|||
const sigBytes = zbase32.decode(sig) |
|||
const totalLength = tsBytes.length + sigBytes.length |
|||
const buf = Buffer.concat([tsBytes, sigBytes], totalLength) |
|||
return urlBase64(buf) |
|||
} |
|||
|
|||
export function getHost() { |
|||
return config.tribes_host || '' |
|||
} |
|||
|
|||
function urlBase64(buf){ |
|||
return buf.toString('base64').replace(/\//g, '_').replace(/\+/g, '-') |
|||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@ |
|||
{"version":3,"file":"rsa.js","sourceRoot":"","sources":["../../../api/crypto/rsa.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,SAAgB,OAAO,CAAC,GAAG,EAAE,GAAG;IAC9B,IAAG;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC1B,MAAM,GAAG,GAAG,M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AAG,GAAG,IAAI;YACV,8BAA8B,CAAA;IAClC,CAAC;IACD,IAAI,EAAC,UAAS,GAAG;QACf,OAAO,mCAAmC;YACxC,GAAG,GAAG,IAAI;YACV,+BAA+B,CAAA;IACnC,CAAC;CACF,CAAA"} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@ |
|||
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../api/utils/setup.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAA2C;AAC3C,sCAA2C;AAC3C,iDAAoC;AACpC,iCAAgC;AAChC,sCAAqC;AACrC,gDAAwC;AACxC,8CAA0D;AAE1D,MAAM,YAAY,GAAG,CAAC,CAAA;AAEtB,MAAM,aAAa,GAAG,GAAS,EAAE;IAC/B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;IACxC,MAAM,UAAU,EAAE,CAAA;IAClB,IAAI;QACF,MAAM,kBAAS,CAAC,IAAI,EAAE,CAAA;QACtB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;KACpC;IAAC,OAAM,CAAC,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAC,CAAC,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,EAAE,CAAA;IACf,iBAAiB,EAAE,CAAA;IACnB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AACnC,CAAC,CAAA,CAAA;AAgEQ,sCAAa;AA9DtB,SAAe,UAAU;;QACvB,IAAI;YACF,MAAM,kBAAS,CAAC,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAA;SAC/D;QAAC,OAAM,CAAC,EAAE;YACT,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAC,CAAC,CAAC,CAAA;SACtC;IACH,CAAC;CAAA;AAED,SAAe,OAAO;;QACpB,IAAI;YACF,MAAM,kBAAS,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAA;SACrE;QAAC,OAAM,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,GAAG,CAAC,qBAAqB,GAAG,aAAa,UAAU,EAAE,CAAC,CAAA;IAChE,CAAC;CAAA;AAED,SAAe,OAAO;;QACpB,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAA;QAC9B,IAAI,SAAS,CAAA;QACb,IAAG,CAAC,EAAE,EAAE;YACN,IAAI;gBACF,SAAS,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAA;aAChC;YAAC,OAAM,CAAC,EAAC;gBACR,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;aACf;SACF;aAAM;YACL,SAAS,GAAG,EAAE,CAAA;SACf;QACD,IAAG,CAAC,SAAS,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;YACvC,OAAM;SACP;QACD,IAAI,KAAK,GAAG,SAAS,CAAA;QACrB,qDAAqD;QAErD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK,kBAAQ,IAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC3E,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAC,EAAC,IAAI,EAAC,UAAU,EAAC,EAAE,UAAU,GAAG,EAAE,GAAG;YACvD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;IACJ,CAAC;CAAA"} |
@ -0,0 +1,57 @@ |
|||
"use strict"; |
|||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
|||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|||
return new (P || (P = Promise))(function (resolve, reject) { |
|||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|||
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|||
}); |
|||
}; |
|||
Object.defineProperty(exports, "__esModule", { value: true }); |
|||
const moment = require("moment"); |
|||
const zbase32 = require("./zbase32"); |
|||
const lightning_1 = require("./lightning"); |
|||
const path = require("path"); |
|||
const mqtt = require("mqtt"); |
|||
const env = process.env.NODE_ENV || 'development'; |
|||
const config = require(path.join(__dirname, '../../config/app.json'))[env]; |
|||
function connect() { |
|||
return __awaiter(this, void 0, void 0, function* () { |
|||
const pwd = yield genSignedTimestamp(); |
|||
const info = yield lightning_1.getInfo(); |
|||
const client = mqtt.connect(`tcp://${config.tribes_host}`, { |
|||
username: info.identity_pubkey, |
|||
password: pwd, |
|||
}); |
|||
client.on('connect', function () { |
|||
console.log("MQTT CLIENT CONNECTED!"); |
|||
// subscribe to all public groups here
|
|||
// that you are NOT admin of (dont sub to your own!)
|
|||
}); |
|||
client.on('close', function () { |
|||
console.log("MQTT CLOSED"); |
|||
}); |
|||
}); |
|||
} |
|||
exports.connect = connect; |
|||
function genSignedTimestamp() { |
|||
return __awaiter(this, void 0, void 0, function* () { |
|||
const now = moment().unix(); |
|||
const tsBytes = Buffer.from(now.toString(16), 'hex'); |
|||
const sig = yield lightning_1.signBuffer(tsBytes); |
|||
const sigBytes = zbase32.decode(sig); |
|||
const totalLength = tsBytes.length + sigBytes.length; |
|||
const buf = Buffer.concat([tsBytes, sigBytes], totalLength); |
|||
return urlBase64(buf); |
|||
}); |
|||
} |
|||
exports.genSignedTimestamp = genSignedTimestamp; |
|||
function getHost() { |
|||
return config.tribes_host || ''; |
|||
} |
|||
exports.getHost = getHost; |
|||
function urlBase64(buf) { |
|||
return buf.toString('base64').replace(/\//g, '_').replace(/\+/g, '-'); |
|||
} |
|||
//# sourceMappingURL=tribes.js.map
|
@ -0,0 +1 @@ |
|||
{"version":3,"file":"tribes.js","sourceR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WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;QACpD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAA;QAC3D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;CAAA;AARD,gDAQC;AAED,SAAgB,OAAO;IACnB,OAAO,MAAM,CAAC,WAAW,IAAI,EAAE,CAAA;AACnC,CAAC;AAFD,0BAEC;AAED,SAAS,SAAS,CAAC,GAAG;IAClB,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACzE,CAAC"} |
@ -0,0 +1,11 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>React app</title> |
|||
</head> |
|||
<body> |
|||
<div id="app"></div> |
|||
<script src="/static/js/app.js"></script> |
|||
<link href="/static/semantic.min.css" rel="stylesheet" /> |
|||
</body> |
|||
</html> |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 257 KiB |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue