godprotocol 1.0.839 → 1.0.841

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,98 +1,133 @@
1
- import http from "http";
2
- import { is_port_available } from "./functions";
3
-
4
- let PORT = Number(process.env.PORT) || 1409;
5
-
6
- const cb = (res, data) => {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extension = exports["default"] = exports.PORT = void 0;
7
+ var _http = _interopRequireDefault(require("http"));
8
+ var _functions = require("./functions");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
12
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
13
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
+ var PORT = Number(process.env.PORT) || 1409;
20
+ exports.PORT = PORT;
21
+ var cb = function cb(res, data) {
7
22
  if (typeof data !== "string") data = JSON.stringify(data);
8
-
9
23
  res.end(data);
10
24
  };
11
-
12
- let extensions = new Object();
13
-
14
- const extension = (route, handler) => {
25
+ var extensions = new Object();
26
+ var extension = function extension(route, handler) {
15
27
  extensions[route] = handler;
16
28
  };
17
-
18
- const handle_routes = (req, res, app, manager) => {
19
- let data = "";
20
-
21
- let is_in_default_routes = [
22
- "run",
23
- "load",
24
- "parse",
25
- "create_account",
26
- ].includes(req.url.slice(1));
27
-
28
- if (is_in_default_routes || (!is_in_default_routes && !app)) {
29
- req.on("data", (chunk) => {
29
+ exports.extension = extension;
30
+ var handle_routes = function handle_routes(req, res, app, manager) {
31
+ var data = "";
32
+ var is_in_default_routes = ["run", "load", "parse", "create_account"].includes(req.url.slice(1));
33
+ if (is_in_default_routes || !is_in_default_routes && !app) {
34
+ req.on("data", function (chunk) {
30
35
  data += chunk;
31
36
  });
32
-
33
- req.on("end", () => {
37
+ req.on("end", function () {
34
38
  try {
35
39
  data = JSON.parse(data);
36
40
  } catch (e) {
37
41
  return cb(res, {
38
42
  error_message: "Invalid data",
39
43
  url: req.url,
40
- error: true,
44
+ error: true
41
45
  });
42
46
  }
43
-
44
47
  if (req.url === "/create_account") {
45
- let account = manager.add_account(null, { ...data, string: true });
46
-
48
+ var account = manager.add_account(null, _objectSpread(_objectSpread({}, data), {}, {
49
+ string: true
50
+ }));
47
51
  res.end(account);
48
52
  } else if (["run", "load", "parse"].includes(req.url.slice(1))) {
49
- manager.endpoint(req.url.slice(1), payload, (datagram) =>
50
- cb(res, datagram)
51
- );
53
+ manager.endpoint(req.url.slice(1), payload, function (datagram) {
54
+ return cb(res, datagram);
55
+ });
52
56
  } else {
53
- let extension = extensions[req.url.slice(1)];
54
-
55
- if (typeof extension !== "function") {
56
- res.writeHead(404, { "Content-Type": "application/json" });
57
- res.end(JSON.stringify({ error: true, error_message: "Not Found" }));
58
- } else extension(data, { req, res });
57
+ var _extension = extensions[req.url.slice(1)];
58
+ if (typeof _extension !== "function") {
59
+ res.writeHead(404, {
60
+ "Content-Type": "application/json"
61
+ });
62
+ res.end(JSON.stringify({
63
+ error: true,
64
+ error_message: "Not Found"
65
+ }));
66
+ } else _extension(data, {
67
+ req: req,
68
+ res: res
69
+ });
59
70
  }
60
71
  });
61
-
62
- req.on("error", (e) => {
72
+ req.on("error", function (e) {
63
73
  // res.writeHead(500, { "Content-Type": "application/json" });
64
- res.end(JSON.stringify({ status: "error", error_message: e.message }));
74
+ res.end(JSON.stringify({
75
+ status: "error",
76
+ error_message: e.message
77
+ }));
65
78
  });
66
79
  } else {
67
80
  app && app(req, res);
68
81
  }
69
82
  };
70
-
71
- const create_server = async (app, settings) => {
72
- settings = settings || {};
73
-
74
- let port = settings.port || PORT,
75
- port_search = settings.port_search;
76
-
77
- if (port_search) {
78
- let av = await is_port_available(port);
79
-
80
- while (!av) {
81
- port++;
82
- av = await is_port_available(port);
83
- }
84
- }
85
- PORT = port;
86
-
87
- let server = http.createServer((req, res) =>
88
- handle_routes(req, res, app, settings.manager)
89
- );
90
-
91
- server.listen(port, () => {
92
- console.log(`\n...GOD PROTOCOL RUNNING :${port}`);
93
- settings.manager.add_server({ ...settings.server_details, port: PORT });
94
- });
95
- };
96
-
97
- export default create_server;
98
- export { PORT, extension };
83
+ var create_server = /*#__PURE__*/function () {
84
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(app, settings) {
85
+ var port, port_search, av, server;
86
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
87
+ while (1) switch (_context.prev = _context.next) {
88
+ case 0:
89
+ settings = settings || {};
90
+ port = settings.port || PORT, port_search = settings.port_search;
91
+ if (!port_search) {
92
+ _context.next = 13;
93
+ break;
94
+ }
95
+ _context.next = 5;
96
+ return (0, _functions.is_port_available)(port);
97
+ case 5:
98
+ av = _context.sent;
99
+ case 6:
100
+ if (av) {
101
+ _context.next = 13;
102
+ break;
103
+ }
104
+ port++;
105
+ _context.next = 10;
106
+ return (0, _functions.is_port_available)(port);
107
+ case 10:
108
+ av = _context.sent;
109
+ _context.next = 6;
110
+ break;
111
+ case 13:
112
+ exports.PORT = PORT = port;
113
+ server = _http["default"].createServer(function (req, res) {
114
+ return handle_routes(req, res, app, settings.manager);
115
+ });
116
+ server.listen(port, function () {
117
+ console.log("\n...GOD PROTOCOL RUNNING :".concat(port));
118
+ settings.manager.add_server(_objectSpread(_objectSpread({}, settings.server_details), {}, {
119
+ port: PORT
120
+ }));
121
+ });
122
+ case 16:
123
+ case "end":
124
+ return _context.stop();
125
+ }
126
+ }, _callee);
127
+ }));
128
+ return function create_server(_x, _x2) {
129
+ return _ref.apply(this, arguments);
130
+ };
131
+ }();
132
+ var _default = create_server;
133
+ exports["default"] = _default;
@@ -1,45 +1,62 @@
1
- const array_to_nested_objects = (arr) => {
2
- if (arr.length === 0) return null;
1
+ "use strict";
3
2
 
4
- let [first, ...rest] = arr;
5
- return { [first]: array_to_nested_objects(rest) };
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.array_to_nested_objects = void 0;
7
+ exports.is_port_available = is_port_available;
8
+ exports.transpile_object = void 0;
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
16
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
17
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
18
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
19
+ var array_to_nested_objects = function array_to_nested_objects(arr) {
20
+ if (arr.length === 0) return null;
21
+ var _arr = _toArray(arr),
22
+ first = _arr[0],
23
+ rest = _arr.slice(1);
24
+ return _defineProperty({}, first, array_to_nested_objects(rest));
6
25
  };
7
-
8
- const transpile_object = (object) => {
9
- let code_string = "",
10
- type = typeof object;
26
+ exports.array_to_nested_objects = array_to_nested_objects;
27
+ var transpile_object = function transpile_object(object) {
28
+ var code_string = "",
29
+ type = _typeof(object);
11
30
  if (type === "object") {
12
31
  if (Array.isArray(object)) {
13
32
  code_string += "arr(";
14
- object.map((o) => {
15
- code_string += `${transpile_object(o)},`;
33
+ object.map(function (o) {
34
+ code_string += "".concat(transpile_object(o), ",");
16
35
  });
17
36
  code_string = code_string.slice(0, -1);
18
37
  code_string += ")";
19
38
  } else {
20
- if (!object) code_string = "Void";
21
- else {
39
+ if (!object) code_string = "Void";else {
22
40
  code_string = "twain(";
23
- for (let prop in object) {
24
- let val = object[prop];
25
- code_string += `${transpile_object(prop)}:${transpile_object(val)},`;
41
+ for (var prop in object) {
42
+ var val = object[prop];
43
+ code_string += "".concat(transpile_object(prop), ":").concat(transpile_object(val), ",");
26
44
  }
27
45
  code_string = code_string.slice(0, -1);
28
46
  code_string += ")";
29
47
  }
30
48
  }
31
49
  } else if (type === "string") {
32
- code_string = `"${object}"`;
50
+ code_string = "\"".concat(object, "\"");
33
51
  } else if (type === "number") {
34
- code_string = `${object}`;
52
+ code_string = "".concat(object);
35
53
  } else if (type === "boolean") {
36
- code_string = `${object}`;
54
+ code_string = "".concat(object);
37
55
  }
38
-
39
56
  return code_string;
40
57
  };
41
-
42
- const net = require("net");
58
+ exports.transpile_object = transpile_object;
59
+ var net = require("net");
43
60
 
44
61
  /**
45
62
  * Check if a port is available
@@ -47,24 +64,19 @@ const net = require("net");
47
64
  * @returns {Promise<boolean>} - Resolves to true if the port is available, false otherwise
48
65
  */
49
66
  function is_port_available(port) {
50
- return new Promise((resolve, reject) => {
51
- const server = net.createServer();
52
-
53
- server.once("error", (err) => {
67
+ return new Promise(function (resolve, reject) {
68
+ var server = net.createServer();
69
+ server.once("error", function (err) {
54
70
  if (err.code === "EADDRINUSE") {
55
71
  resolve(false); // Port is in use
56
72
  } else {
57
73
  reject(err); // Some other error
58
74
  }
59
75
  });
60
-
61
- server.once("listening", () => {
76
+ server.once("listening", function () {
62
77
  server.close();
63
78
  resolve(true); // Port is available
64
79
  });
65
-
66
80
  server.listen(port);
67
81
  });
68
- }
69
-
70
- export { array_to_nested_objects, transpile_object, is_port_available };
82
+ }
package/utils/hash.js CHANGED
@@ -1,13 +1,14 @@
1
- const crypto = require("crypto");
2
-
3
- const hash = (data) => {
4
- let hash = crypto.createHash("sha256");
5
-
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hash = void 0;
7
+ var crypto = require("crypto");
8
+ var hash = function hash(data) {
9
+ var hash = crypto.createHash("sha256");
6
10
  hash.update(data);
7
-
8
- let result = hash.digest("hex");
9
-
11
+ var result = hash.digest("hex");
10
12
  return result;
11
13
  };
12
-
13
- export { hash };
14
+ exports.hash = hash;
package/utils/privacy.js CHANGED
@@ -1,5 +1,11 @@
1
- const EC = require("elliptic").ec;
2
- const ec = new EC("secp256k1"); // You can use other curves like 'ed25519' based on your requirements
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var EC = require("elliptic").ec;
8
+ var ec = new EC("secp256k1"); // You can use other curves like 'ed25519' based on your requirements
3
9
 
4
10
  /**
5
11
  * Function to validate a signature using elliptic
@@ -8,15 +14,14 @@ const ec = new EC("secp256k1"); // You can use other curves like 'ed25519' based
8
14
  * @param {string} signature - The signature to be validated
9
15
  * @returns {boolean} - True if the signature is valid, false otherwise
10
16
  */
11
- const validate_signature = (public_key, message, signature) => {
12
- let key = ec.keyFromPublic(public_key, "hex");
13
- let hash = ec.hash().update(message).digest("hex");
14
- let sig = {
17
+ var validate_signature = function validate_signature(public_key, message, signature) {
18
+ var key = ec.keyFromPublic(public_key, "hex");
19
+ var hash = ec.hash().update(message).digest("hex");
20
+ var sig = {
15
21
  r: signature.slice(0, 64),
16
- s: signature.slice(64, 128),
22
+ s: signature.slice(64, 128)
17
23
  };
18
-
19
24
  return key.verify(hash, sig);
20
25
  };
21
-
22
- export default validate_signature;
26
+ var _default = validate_signature;
27
+ exports["default"] = _default;
package/utils/services.js CHANGED
@@ -1,6 +1,17 @@
1
- const http = require("http");
2
-
3
- const post_request = (payload, cb) => {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.post_request = void 0;
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ var http = require("http");
14
+ var post_request = function post_request(payload, cb) {
4
15
  // let options = {
5
16
  // hostname: 'example.com',
6
17
  // port: 80,
@@ -12,38 +23,28 @@ const post_request = (payload, cb) => {
12
23
  // },
13
24
  // };
14
25
 
15
- let req = http.request(
16
- {
17
- ...payload.options,
18
- method: "POST",
19
- headers: {
20
- "Content-Type": "application/json",
21
- "Content-Length": Buffer.byteLength(payload.data),
22
- },
23
- },
24
- (res) => {
25
- let data = "";
26
-
27
- res.on("data", (chunk) => {
28
- data += chunk;
29
- cb && cb(chunk);
30
- });
31
-
32
- res.on("end", () => {
33
- cb && cb(data);
34
- // console.log("Response:", data);
35
- });
26
+ var req = http.request(_objectSpread(_objectSpread({}, payload.options), {}, {
27
+ method: "POST",
28
+ headers: {
29
+ "Content-Type": "application/json",
30
+ "Content-Length": Buffer.byteLength(payload.data)
36
31
  }
37
- );
38
-
39
- req.on("error", (e) => {
32
+ }), function (res) {
33
+ var data = "";
34
+ res.on("data", function (chunk) {
35
+ data += chunk;
36
+ cb && cb(chunk);
37
+ });
38
+ res.on("end", function () {
39
+ cb && cb(data);
40
+ // console.log("Response:", data);
41
+ });
42
+ });
43
+ req.on("error", function (e) {
40
44
  cb(e.message);
41
- console.error(`Problem with request: ${e.message}`);
45
+ console.error("Problem with request: ".concat(e.message));
42
46
  });
43
-
44
47
  req.write(payload.data);
45
-
46
48
  req.end();
47
49
  };
48
-
49
- export { post_request };
50
+ exports.post_request = post_request;