@remote.it/core
Version:
Core remote.it JavasScript/TypeScript library
68 lines • 3.02 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var debug_1 = __importDefault(require("debug"));
var Process_1 = require("./Process");
var Environment_1 = require("./Environment");
var Logger_1 = require("./Logger");
var d = debug_1.default('remoteit:ServiceProcess');
var ServiceProcess = /** @class */ (function (_super) {
__extends(ServiceProcess, _super);
function ServiceProcess(config) {
var _this = this;
if (!config.secret)
throw new Error('No secret returned from API!');
var targetProperties = [
"application_type " + config.type,
"proxy_dest_port " + config.port,
];
if (config.hostname)
targetProperties.push("proxy_dest_ip " + config.hostname);
if (config.overload)
targetProperties.push("application_type_overload " + config.overload);
targetProperties.push("UID " + config.uid);
targetProperties.push("secret " + config.secret);
var provisioningFile = Buffer.from(targetProperties.join('\n') + '\n').toString('base64');
var _ = config.secret, rest = __rest(config, ["secret"]);
Logger_1.Logger.info('service provision file', rest);
var binary = Environment_1.Environment.connectdPath;
_this = _super.call(this, binary + " -e " + provisioningFile) || this;
d('creating service process:', config);
_this.hostname = config.hostname;
_this.overload = config.overload;
_this.port = config.port;
_this.secret = config.secret;
_this.type = config.type;
_this.uid = config.uid;
return _this;
}
return ServiceProcess;
}(Process_1.Process));
exports.ServiceProcess = ServiceProcess;
//# sourceMappingURL=ServiceProcess.js.map