You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1009 B
JavaScript
41 lines
1009 B
JavaScript
7 years ago
|
/* globals Buffer */
|
||
7 years ago
|
var Https = require('https');
|
||
6 years ago
|
var Config = require("../config/config.js");
|
||
|
var Package = require("../package.json");
|
||
7 years ago
|
|
||
|
var body = JSON.stringify({
|
||
|
domain: Config.myDomain,
|
||
|
adminEmail: Config.adminEmail,
|
||
|
version: Package.version,
|
||
|
});
|
||
|
|
||
|
var options = {
|
||
|
host: 'accounts.cryptpad.fr',
|
||
|
path: '/api/getauthorized',
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json',
|
||
|
'Content-Length': Buffer.byteLength(body)
|
||
|
}
|
||
|
};
|
||
|
|
||
7 years ago
|
Https.request(options, function (response) {
|
||
7 years ago
|
if (!('' + response.statusCode).match(/^2\d\d$/)) {
|
||
|
throw new Error('SERVER ERROR ' + response.statusCode);
|
||
|
}
|
||
|
var str = '';
|
||
|
response.on('data', function (chunk) {
|
||
|
str += chunk;
|
||
|
});
|
||
|
response.on('end', function () {
|
||
|
try {
|
||
|
var json = JSON.parse(str);
|
||
|
console.log(json);
|
||
|
} catch (e) {
|
||
|
throw new Error(e);
|
||
|
}
|
||
|
});
|
||
|
}).on('error', function (e) {
|
||
|
console.error(e);
|
||
|
}).end(body);
|