From 004908e735f9bba763ee8f8283cd7ba7fedb71e5 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 5 Aug 2018 07:20:06 +0000 Subject: [PATCH] add some more info to domain list --- lib/extensions/data-files-to-json.js | 10 +++++++--- lib/extensions/index.js | 24 +++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/extensions/data-files-to-json.js b/lib/extensions/data-files-to-json.js index 2b24d69..ad81740 100644 --- a/lib/extensions/data-files-to-json.js +++ b/lib/extensions/data-files-to-json.js @@ -11,11 +11,13 @@ files.forEach(function (fname) { var data; var email; var iat; + var mdata; if (!/\.data$/.test(fname)) { return; } data = JSON.parse(fs.readFileSync(fpath)); email = fname.replace('\.' + data.domains.join('') + '\.data', ''); + mdata = JSON.parse(fs.readFileSync(path.join(basedir, email))); if (data.iat) { iat = new Date(data.iat).toISOString(); } @@ -23,16 +25,18 @@ files.forEach(function (fname) { emails[email] = { domains: [] , ports: [] - , nodes: [ { issuedAt: iat, scheme: 'mailto', type: 'email', name: email } ] + , nodes: [ { createdAt: iat, scheme: 'mailto', type: 'email', name: email } ] , jtis: [] }; } emails[email].jtis.push(data.id); data.domains.forEach(function (d) { - emails[email].domains.push({ issuedAt: iat, name: d }); + emails[email].domains.push({ createdAt: iat, name: d, wildcard: true, hostname: mdata.hostname + , os: mdata.os_type, arch: mdata.os_arch }); }); data.ports.forEach(function (p) { - emails[email].ports.push({ issuedAt: iat, number: p }); + emails[email].ports.push({ createdAt: iat, number: p, hostname: mdata.hostname + , os: mdata.os_type, arch: mdata.os_arch }); }); }); console.log('[\n' + Object.keys(emails).map(function (k) { return JSON.stringify(emails[k]); }).join(',\n') + '\n]'); diff --git a/lib/extensions/index.js b/lib/extensions/index.js index 5f05f62..1ef9c88 100644 --- a/lib/extensions/index.js +++ b/lib/extensions/index.js @@ -143,15 +143,17 @@ DB.domains.available = function (name) { return !DB._byDomain[name]; }); }; -DB.domains._add = function (acc, name) { +DB.domains._add = function (acc, opts) { // TODO verifications to change ownership of a domain return PromiseA.resolve().then(function () { var err; //var acc = DB._byId[aid]; var domain = { - name: name + name: opts.domain || opts.name + , hostname: opts.hostname + , os: opts.os , createdAt: new Date().toISOString() - , wildcard: true + , wildcard: opts.wildcard }; var pdomain; var parts = name.split('.').map(function (el, i) { @@ -189,11 +191,13 @@ DB.ports.available = function (number) { return !DB._byPort[number]; }); }; -DB.ports._add = function (acc, number) { +DB.ports._add = function (acc, opts) { return PromiseA.resolve().then(function () { //var acc = DB._byId[aid]; var port = { - number: number + number: opts.port || opts.number + , hostname: opts.hostname + , os: opts.os , createdAt: new Date().toISOString() }; if (DB._byPort[number]) { @@ -652,6 +656,10 @@ module.exports.pairRequest = function (opts) { , sub: authReq.subject , pin: pin , hostname: authReq.hostname + , os_type: authReq.os_type + , os_platform: authReq.os_platform + , os_release: authReq.os_release + , os_arch: authReq.os_arch }; auth = { id: authReq.id @@ -747,8 +755,10 @@ module.exports.pairPin = function (opts) { acc = { email: true, domains: [], ports: [], nodes: [ emailNode ] }; } return PromiseA.all([ - DB.domains._add(acc, opts.domain) - , DB.ports._add(acc, opts.port) + DB.domains._add(acc, { domain: opts.domain, wildcard: true, hostname: auth.authnData.hostname, + os: auth.authnData.os_type, arch: auth.authnData.os_arch }) + , DB.ports._add(acc, { port: opts.port, hostname: auth.authnData.hostname, + os: auth.authnData.os_type, arch: auth.authnData.os_arch }) ]).then(function () { var authzData = { id: auth.id