diff --git a/lib/extensions/admin/account.html b/lib/extensions/admin/account.html
index a8e9d8c..4792923 100644
--- a/lib/extensions/admin/account.html
+++ b/lib/extensions/admin/account.html
@@ -18,37 +18,61 @@
Account
-
-
Claims
-
If your DNS host supports ANAME records, please use those instead of CNAMEs.
-
If CNAMEs are not supported, set an A record to {{ site.deviceDomainA }}.
-
- -
- {{ claim.value }}
-
- CNAME *.{{ claim.value }}: {{ site.deviceDomain }}
-
- TXT _claim-challenge.{{ claim.value }}: {{ claim.challenge }}
-
-
-
-
+
+
+
Pending Claims
+
If your DNS host supports ANAME records, please use those instead of CNAMEs.
+
If CNAMEs are not supported, set an A record to {{ site.deviceDomainA }}.
+
+ -
+ {{ claim.value }}
+
+ CNAME *.{{ claim.value }}: {{ site.deviceDomain }}
+
+ TXT _claim-challenge.{{ claim.value }}: {{ claim.challenge }}
+
+
+
+
+
+
+
Devices
+
+ You can add up to 5 devices:
+
curl -sf https://get.telebit.io/ | bash
+
+
+
+ -
+ {{ device.id }} {{ device.socketId }}
+
+ - {{ name }}
+
+
+
+
+
Domains
-
- -
- *.{{ domain.name }} - {{domain.hostname}} ({{domain.os}} {{domain.arch}})
-
-
+
+
+
+ -
+ *.{{ domain.name }} - {{domain.hostname}} ({{domain.os}} {{domain.arch}})
+
+
+
+
+
Debug: Token
diff --git a/lib/extensions/admin/js/account.js b/lib/extensions/admin/js/account.js
index 61fcd57..85b1fe1 100644
--- a/lib/extensions/admin/js/account.js
+++ b/lib/extensions/admin/js/account.js
@@ -24,6 +24,7 @@
var vueData = {
claims: []
, domains: []
+ , devices: []
, newDomain: null
, newDomainWildcard: false
, newEmail: null
@@ -88,6 +89,7 @@
//window.alert("TODO: show authorized devices, domains, and connectivity information");
vueData.hasAccount = true;
vueData.domains = data.domains;
+ vueData.devices = data.devices;
vueData.claims = data.claims;
}
function loadAccount(session) {
diff --git a/lib/extensions/index.js b/lib/extensions/index.js
index f454e0c..ee247d0 100644
--- a/lib/extensions/index.js
+++ b/lib/extensions/index.js
@@ -19,6 +19,7 @@ var requestAsync = util.promisify(require('@coolaj86/urequest'));
var mkdirpAsync = util.promisify(require('mkdirp'));
var TRUSTED_ISSUERS = [ 'oauth3.org' ];
var DB = require('./db.js');
+var Devices = require('../device-tracker');
var Claims = {};
Claims.publicize = function publicizeClaim(claim) {
if (!claim) {
@@ -779,6 +780,7 @@ app.get('/api/telebit.cloud/account', function (req, res) {
var domainsMap = {};
var portsMap = {};
var claimsMap = {};
+ var devsMap = {};
var result = JSON.parse(JSON.stringify(acc));
result.domains.length = 0;
result.ports.length = 0;
@@ -806,6 +808,40 @@ app.get('/api/telebit.cloud/account', function (req, res) {
result.claims = Object.keys(claimsMap).map(function (k) {
return Claims.publicize(claimsMap[k]);
});
+
+ // TODO assign devices by public key, not domain name
+ result.domains.map(function (domain) {
+ console.log("[debug] Domain", domain);
+ var devs = Devices.list(req._state.deviceLists, domain.name);
+ console.log("[debug] Devs", devs.map(function (d) { return d.socketId; }));
+ if (!devs.length) { return null; }
+ devs.forEach(function (dev) {
+ // eventually we should implement so that a new connection
+ // with the same public key results in booting the prior session
+ // then we could use device.id instead of socketId
+ if (!devsMap[dev.socketId]) {
+ devsMap[dev.socketId] = {
+ id: dev.id
+ , socketId: dev.socketId
+ , active: true
+ , names: []
+ };
+ }
+ devsMap[dev.socketId].names.push(domain.name);
+ return devsMap[dev.socketId];
+ });
+ }).filter(Boolean);
+ result.devices = Object.keys(devsMap).map(function (sid) {
+ return devsMap[sid];
+ });
+
+ // Help the garbage collector out a little
+ domainsMap = null;
+ portsMap = null;
+ claimsMap = null;
+ devsMap = null;
+
+ // The data is useful! Send it away!
return result;
});
}