2018-06-20 09:07:35 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var email = 'jon@example.com';
|
2018-06-21 06:10:49 +00:00
|
|
|
var pin = Math.round(Math.random() * 999999).toString().padStart(6, '0'); // '321654'
|
|
|
|
|
|
|
|
console.log('Pair Code:', pin);
|
2018-06-20 09:07:35 +00:00
|
|
|
|
2019-05-11 07:50:18 +00:00
|
|
|
var urequest = require('@root/request');
|
2018-06-20 09:07:35 +00:00
|
|
|
var req = {
|
|
|
|
url: 'https://api.telebit.ppl.family/api/telebit.cloud/pair_request'
|
|
|
|
, method: 'POST'
|
|
|
|
, headers: { 'cOntEnt-tYpE': 'application/json;charset=utf-8' }
|
|
|
|
, json: {
|
2018-06-21 21:01:31 +00:00
|
|
|
subject: email
|
|
|
|
, subject_scheme: 'mailto'
|
|
|
|
, scope: ''
|
|
|
|
, otp: pin
|
|
|
|
, hostname: "User's Macbook Pro"
|
|
|
|
, os_type: 'Linux'
|
|
|
|
, os_platform: 'linux'
|
2018-06-20 09:07:35 +00:00
|
|
|
, os_release: '4.4.0-116-generic'
|
2018-06-21 21:01:31 +00:00
|
|
|
, os_arch: 'x64'
|
|
|
|
}
|
2018-06-20 09:07:35 +00:00
|
|
|
};
|
|
|
|
urequest(req, function (err, resp, body) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log('Location:', resp.headers.location);
|
|
|
|
console.log('Body:');
|
|
|
|
console.log(body);
|
2018-06-21 21:01:31 +00:00
|
|
|
/*
|
|
|
|
{ jwt: '...'
|
|
|
|
}
|
|
|
|
*/
|
2018-06-20 09:07:35 +00:00
|
|
|
});
|