2018-05-10 08:08:20 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-09-17 07:16:27 +00:00
|
|
|
function addCommunityMember(pkg, action, email, domains, communityMember) {
|
2018-05-10 08:08:20 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
var https = require('https');
|
|
|
|
var req = https.request({
|
|
|
|
hostname: 'api.ppl.family'
|
|
|
|
, port: 443
|
|
|
|
, path: '/api/ppl.family/public/list'
|
|
|
|
, method: 'POST'
|
|
|
|
, headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}
|
|
|
|
}, function (err, resp) {
|
|
|
|
if (err) { return; }
|
|
|
|
resp.on('data', function () {});
|
|
|
|
});
|
2018-09-17 07:16:27 +00:00
|
|
|
var data = {
|
2018-05-10 08:08:20 +00:00
|
|
|
address: email
|
2018-09-17 07:16:27 +00:00
|
|
|
// greenlock-security is transactional and security only
|
|
|
|
, list: communityMember ? (pkg + '@ppl.family') : 'greenlock-security@ppl.family'
|
|
|
|
, action: action // reg | renew
|
|
|
|
, package: pkg
|
|
|
|
// hashed for privacy, but so we can still get some telemetry and inform users
|
|
|
|
// if abnormal things are happening (like several registrations for the same domain each day)
|
|
|
|
, domain: (domains||[]).map(function (d) {
|
2018-05-10 08:08:20 +00:00
|
|
|
return require('crypto').createHash('sha1').update(d).digest('base64')
|
|
|
|
.replace(/\//g, '_').replace(/\+/g, '-').replace(/=/g, '');
|
|
|
|
}).join(',')
|
2018-09-17 07:16:27 +00:00
|
|
|
};
|
|
|
|
req.write(JSON.stringify(data, 2, null));
|
2018-05-10 08:08:20 +00:00
|
|
|
req.end();
|
|
|
|
}, 50);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.add = addCommunityMember;
|
2018-09-17 07:16:27 +00:00
|
|
|
|
|
|
|
if (require.main === module) {
|
|
|
|
//addCommunityMember('greenlock-express.js', 'reg', 'coolaj86+test42@gmail.com', ['coolaj86.com'], true);
|
|
|
|
//addCommunityMember('greenlock.js', 'reg', 'coolaj86+test37@gmail.com', ['oneal.im'], false);
|
|
|
|
//addCommunityMember('greenlock.js', 'reg', 'coolaj86+test11@gmail.com', ['ppl.family'], true);
|
|
|
|
}
|