godprotocol 1.0.795 → 1.0.797

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.
package/Index.js CHANGED
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true,
5
+ });
6
+ Object.defineProperty(exports, "create_server", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _create_server["default"];
10
+ },
5
11
  });
6
12
  exports.initiator = exports["default"] = void 0;
7
13
  var _Manager = _interopRequireDefault(require("./Objects/Manager"));
8
14
  var _create_server = _interopRequireDefault(require("./utils/create_server"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
+ function _interopRequireDefault(e) {
16
+ return e && e.__esModule ? e : { default: e };
17
+ }
10
18
  var manager = new _Manager["default"]();
11
19
  var initiator = manager.add_account(process.env.INITIATOR || "initiator");
12
20
  exports.initiator = initiator;
13
- (0, _create_server["default"])(initiator);
14
21
  var _default = manager;
15
- exports["default"] = _default;
22
+ exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "1.0.795",
3
+ "version": "1.0.797",
4
4
  "description": "A data mediator.",
5
5
  "main": "Index.js",
6
6
  "types": "index.d.ts",
@@ -1,22 +1,533 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
- value: true
4
+ value: true,
6
5
  });
7
6
  exports.extension = exports["default"] = exports.PORT = void 0;
8
7
  var _http = _interopRequireDefault(require("http"));
9
8
  var _functions = require("./functions");
10
- var _PORT;
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- 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; }
13
- 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; }
14
- 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; }
15
- 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; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- 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); }
18
- 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); }
19
- 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); }); }; }
9
+ var _Index = require("../Index");
10
+ function _interopRequireDefault(e) {
11
+ return e && e.__esModule ? e : { default: e };
12
+ }
13
+ function _typeof(o) {
14
+ "@babel/helpers - typeof";
15
+ return (
16
+ (_typeof =
17
+ "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
18
+ ? function (o) {
19
+ return typeof o;
20
+ }
21
+ : function (o) {
22
+ return o &&
23
+ "function" == typeof Symbol &&
24
+ o.constructor === Symbol &&
25
+ o !== Symbol.prototype
26
+ ? "symbol"
27
+ : typeof o;
28
+ }),
29
+ _typeof(o)
30
+ );
31
+ }
32
+ function _regeneratorRuntime() {
33
+ "use strict";
34
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime =
35
+ function _regeneratorRuntime() {
36
+ return e;
37
+ };
38
+ var t,
39
+ e = {},
40
+ r = Object.prototype,
41
+ n = r.hasOwnProperty,
42
+ o =
43
+ Object.defineProperty ||
44
+ function (t, e, r) {
45
+ t[e] = r.value;
46
+ },
47
+ i = "function" == typeof Symbol ? Symbol : {},
48
+ a = i.iterator || "@@iterator",
49
+ c = i.asyncIterator || "@@asyncIterator",
50
+ u = i.toStringTag || "@@toStringTag";
51
+ function define(t, e, r) {
52
+ return (
53
+ Object.defineProperty(t, e, {
54
+ value: r,
55
+ enumerable: !0,
56
+ configurable: !0,
57
+ writable: !0,
58
+ }),
59
+ t[e]
60
+ );
61
+ }
62
+ try {
63
+ define({}, "");
64
+ } catch (t) {
65
+ define = function define(t, e, r) {
66
+ return (t[e] = r);
67
+ };
68
+ }
69
+ function wrap(t, e, r, n) {
70
+ var i = e && e.prototype instanceof Generator ? e : Generator,
71
+ a = Object.create(i.prototype),
72
+ c = new Context(n || []);
73
+ return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a;
74
+ }
75
+ function tryCatch(t, e, r) {
76
+ try {
77
+ return { type: "normal", arg: t.call(e, r) };
78
+ } catch (t) {
79
+ return { type: "throw", arg: t };
80
+ }
81
+ }
82
+ e.wrap = wrap;
83
+ var h = "suspendedStart",
84
+ l = "suspendedYield",
85
+ f = "executing",
86
+ s = "completed",
87
+ y = {};
88
+ function Generator() {}
89
+ function GeneratorFunction() {}
90
+ function GeneratorFunctionPrototype() {}
91
+ var p = {};
92
+ define(p, a, function () {
93
+ return this;
94
+ });
95
+ var d = Object.getPrototypeOf,
96
+ v = d && d(d(values([])));
97
+ v && v !== r && n.call(v, a) && (p = v);
98
+ var g =
99
+ (GeneratorFunctionPrototype.prototype =
100
+ Generator.prototype =
101
+ Object.create(p));
102
+ function defineIteratorMethods(t) {
103
+ ["next", "throw", "return"].forEach(function (e) {
104
+ define(t, e, function (t) {
105
+ return this._invoke(e, t);
106
+ });
107
+ });
108
+ }
109
+ function AsyncIterator(t, e) {
110
+ function invoke(r, o, i, a) {
111
+ var c = tryCatch(t[r], t, o);
112
+ if ("throw" !== c.type) {
113
+ var u = c.arg,
114
+ h = u.value;
115
+ return h && "object" == _typeof(h) && n.call(h, "__await")
116
+ ? e.resolve(h.__await).then(
117
+ function (t) {
118
+ invoke("next", t, i, a);
119
+ },
120
+ function (t) {
121
+ invoke("throw", t, i, a);
122
+ }
123
+ )
124
+ : e.resolve(h).then(
125
+ function (t) {
126
+ (u.value = t), i(u);
127
+ },
128
+ function (t) {
129
+ return invoke("throw", t, i, a);
130
+ }
131
+ );
132
+ }
133
+ a(c.arg);
134
+ }
135
+ var r;
136
+ o(this, "_invoke", {
137
+ value: function value(t, n) {
138
+ function callInvokeWithMethodAndArg() {
139
+ return new e(function (e, r) {
140
+ invoke(t, n, e, r);
141
+ });
142
+ }
143
+ return (r = r
144
+ ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg)
145
+ : callInvokeWithMethodAndArg());
146
+ },
147
+ });
148
+ }
149
+ function makeInvokeMethod(e, r, n) {
150
+ var o = h;
151
+ return function (i, a) {
152
+ if (o === f) throw Error("Generator is already running");
153
+ if (o === s) {
154
+ if ("throw" === i) throw a;
155
+ return { value: t, done: !0 };
156
+ }
157
+ for (n.method = i, n.arg = a; ; ) {
158
+ var c = n.delegate;
159
+ if (c) {
160
+ var u = maybeInvokeDelegate(c, n);
161
+ if (u) {
162
+ if (u === y) continue;
163
+ return u;
164
+ }
165
+ }
166
+ if ("next" === n.method) n.sent = n._sent = n.arg;
167
+ else if ("throw" === n.method) {
168
+ if (o === h) throw ((o = s), n.arg);
169
+ n.dispatchException(n.arg);
170
+ } else "return" === n.method && n.abrupt("return", n.arg);
171
+ o = f;
172
+ var p = tryCatch(e, r, n);
173
+ if ("normal" === p.type) {
174
+ if (((o = n.done ? s : l), p.arg === y)) continue;
175
+ return { value: p.arg, done: n.done };
176
+ }
177
+ "throw" === p.type && ((o = s), (n.method = "throw"), (n.arg = p.arg));
178
+ }
179
+ };
180
+ }
181
+ function maybeInvokeDelegate(e, r) {
182
+ var n = r.method,
183
+ o = e.iterator[n];
184
+ if (o === t)
185
+ return (
186
+ (r.delegate = null),
187
+ ("throw" === n &&
188
+ e.iterator["return"] &&
189
+ ((r.method = "return"),
190
+ (r.arg = t),
191
+ maybeInvokeDelegate(e, r),
192
+ "throw" === r.method)) ||
193
+ ("return" !== n &&
194
+ ((r.method = "throw"),
195
+ (r.arg = new TypeError(
196
+ "The iterator does not provide a '" + n + "' method"
197
+ )))),
198
+ y
199
+ );
200
+ var i = tryCatch(o, e.iterator, r.arg);
201
+ if ("throw" === i.type)
202
+ return (r.method = "throw"), (r.arg = i.arg), (r.delegate = null), y;
203
+ var a = i.arg;
204
+ return a
205
+ ? a.done
206
+ ? ((r[e.resultName] = a.value),
207
+ (r.next = e.nextLoc),
208
+ "return" !== r.method && ((r.method = "next"), (r.arg = t)),
209
+ (r.delegate = null),
210
+ y)
211
+ : a
212
+ : ((r.method = "throw"),
213
+ (r.arg = new TypeError("iterator result is not an object")),
214
+ (r.delegate = null),
215
+ y);
216
+ }
217
+ function pushTryEntry(t) {
218
+ var e = { tryLoc: t[0] };
219
+ 1 in t && (e.catchLoc = t[1]),
220
+ 2 in t && ((e.finallyLoc = t[2]), (e.afterLoc = t[3])),
221
+ this.tryEntries.push(e);
222
+ }
223
+ function resetTryEntry(t) {
224
+ var e = t.completion || {};
225
+ (e.type = "normal"), delete e.arg, (t.completion = e);
226
+ }
227
+ function Context(t) {
228
+ (this.tryEntries = [{ tryLoc: "root" }]),
229
+ t.forEach(pushTryEntry, this),
230
+ this.reset(!0);
231
+ }
232
+ function values(e) {
233
+ if (e || "" === e) {
234
+ var r = e[a];
235
+ if (r) return r.call(e);
236
+ if ("function" == typeof e.next) return e;
237
+ if (!isNaN(e.length)) {
238
+ var o = -1,
239
+ i = function next() {
240
+ for (; ++o < e.length; )
241
+ if (n.call(e, o))
242
+ return (next.value = e[o]), (next.done = !1), next;
243
+ return (next.value = t), (next.done = !0), next;
244
+ };
245
+ return (i.next = i);
246
+ }
247
+ }
248
+ throw new TypeError(_typeof(e) + " is not iterable");
249
+ }
250
+ return (
251
+ (GeneratorFunction.prototype = GeneratorFunctionPrototype),
252
+ o(g, "constructor", {
253
+ value: GeneratorFunctionPrototype,
254
+ configurable: !0,
255
+ }),
256
+ o(GeneratorFunctionPrototype, "constructor", {
257
+ value: GeneratorFunction,
258
+ configurable: !0,
259
+ }),
260
+ (GeneratorFunction.displayName = define(
261
+ GeneratorFunctionPrototype,
262
+ u,
263
+ "GeneratorFunction"
264
+ )),
265
+ (e.isGeneratorFunction = function (t) {
266
+ var e = "function" == typeof t && t.constructor;
267
+ return (
268
+ !!e &&
269
+ (e === GeneratorFunction ||
270
+ "GeneratorFunction" === (e.displayName || e.name))
271
+ );
272
+ }),
273
+ (e.mark = function (t) {
274
+ return (
275
+ Object.setPrototypeOf
276
+ ? Object.setPrototypeOf(t, GeneratorFunctionPrototype)
277
+ : ((t.__proto__ = GeneratorFunctionPrototype),
278
+ define(t, u, "GeneratorFunction")),
279
+ (t.prototype = Object.create(g)),
280
+ t
281
+ );
282
+ }),
283
+ (e.awrap = function (t) {
284
+ return { __await: t };
285
+ }),
286
+ defineIteratorMethods(AsyncIterator.prototype),
287
+ define(AsyncIterator.prototype, c, function () {
288
+ return this;
289
+ }),
290
+ (e.AsyncIterator = AsyncIterator),
291
+ (e.async = function (t, r, n, o, i) {
292
+ void 0 === i && (i = Promise);
293
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
294
+ return e.isGeneratorFunction(r)
295
+ ? a
296
+ : a.next().then(function (t) {
297
+ return t.done ? t.value : a.next();
298
+ });
299
+ }),
300
+ defineIteratorMethods(g),
301
+ define(g, u, "Generator"),
302
+ define(g, a, function () {
303
+ return this;
304
+ }),
305
+ define(g, "toString", function () {
306
+ return "[object Generator]";
307
+ }),
308
+ (e.keys = function (t) {
309
+ var e = Object(t),
310
+ r = [];
311
+ for (var n in e) r.push(n);
312
+ return (
313
+ r.reverse(),
314
+ function next() {
315
+ for (; r.length; ) {
316
+ var t = r.pop();
317
+ if (t in e) return (next.value = t), (next.done = !1), next;
318
+ }
319
+ return (next.done = !0), next;
320
+ }
321
+ );
322
+ }),
323
+ (e.values = values),
324
+ (Context.prototype = {
325
+ constructor: Context,
326
+ reset: function reset(e) {
327
+ if (
328
+ ((this.prev = 0),
329
+ (this.next = 0),
330
+ (this.sent = this._sent = t),
331
+ (this.done = !1),
332
+ (this.delegate = null),
333
+ (this.method = "next"),
334
+ (this.arg = t),
335
+ this.tryEntries.forEach(resetTryEntry),
336
+ !e)
337
+ )
338
+ for (var r in this)
339
+ "t" === r.charAt(0) &&
340
+ n.call(this, r) &&
341
+ !isNaN(+r.slice(1)) &&
342
+ (this[r] = t);
343
+ },
344
+ stop: function stop() {
345
+ this.done = !0;
346
+ var t = this.tryEntries[0].completion;
347
+ if ("throw" === t.type) throw t.arg;
348
+ return this.rval;
349
+ },
350
+ dispatchException: function dispatchException(e) {
351
+ if (this.done) throw e;
352
+ var r = this;
353
+ function handle(n, o) {
354
+ return (
355
+ (a.type = "throw"),
356
+ (a.arg = e),
357
+ (r.next = n),
358
+ o && ((r.method = "next"), (r.arg = t)),
359
+ !!o
360
+ );
361
+ }
362
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
363
+ var i = this.tryEntries[o],
364
+ a = i.completion;
365
+ if ("root" === i.tryLoc) return handle("end");
366
+ if (i.tryLoc <= this.prev) {
367
+ var c = n.call(i, "catchLoc"),
368
+ u = n.call(i, "finallyLoc");
369
+ if (c && u) {
370
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
371
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
372
+ } else if (c) {
373
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
374
+ } else {
375
+ if (!u) throw Error("try statement without catch or finally");
376
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
377
+ }
378
+ }
379
+ }
380
+ },
381
+ abrupt: function abrupt(t, e) {
382
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
383
+ var o = this.tryEntries[r];
384
+ if (
385
+ o.tryLoc <= this.prev &&
386
+ n.call(o, "finallyLoc") &&
387
+ this.prev < o.finallyLoc
388
+ ) {
389
+ var i = o;
390
+ break;
391
+ }
392
+ }
393
+ i &&
394
+ ("break" === t || "continue" === t) &&
395
+ i.tryLoc <= e &&
396
+ e <= i.finallyLoc &&
397
+ (i = null);
398
+ var a = i ? i.completion : {};
399
+ return (
400
+ (a.type = t),
401
+ (a.arg = e),
402
+ i
403
+ ? ((this.method = "next"), (this.next = i.finallyLoc), y)
404
+ : this.complete(a)
405
+ );
406
+ },
407
+ complete: function complete(t, e) {
408
+ if ("throw" === t.type) throw t.arg;
409
+ return (
410
+ "break" === t.type || "continue" === t.type
411
+ ? (this.next = t.arg)
412
+ : "return" === t.type
413
+ ? ((this.rval = this.arg = t.arg),
414
+ (this.method = "return"),
415
+ (this.next = "end"))
416
+ : "normal" === t.type && e && (this.next = e),
417
+ y
418
+ );
419
+ },
420
+ finish: function finish(t) {
421
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
422
+ var r = this.tryEntries[e];
423
+ if (r.finallyLoc === t)
424
+ return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
425
+ }
426
+ },
427
+ catch: function _catch(t) {
428
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
429
+ var r = this.tryEntries[e];
430
+ if (r.tryLoc === t) {
431
+ var n = r.completion;
432
+ if ("throw" === n.type) {
433
+ var o = n.arg;
434
+ resetTryEntry(r);
435
+ }
436
+ return o;
437
+ }
438
+ }
439
+ throw Error("illegal catch attempt");
440
+ },
441
+ delegateYield: function delegateYield(e, r, n) {
442
+ return (
443
+ (this.delegate = { iterator: values(e), resultName: r, nextLoc: n }),
444
+ "next" === this.method && (this.arg = t),
445
+ y
446
+ );
447
+ },
448
+ }),
449
+ e
450
+ );
451
+ }
452
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
453
+ try {
454
+ var i = n[a](c),
455
+ u = i.value;
456
+ } catch (n) {
457
+ return void e(n);
458
+ }
459
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
460
+ }
461
+ function _asyncToGenerator(n) {
462
+ return function () {
463
+ var t = this,
464
+ e = arguments;
465
+ return new Promise(function (r, o) {
466
+ var a = n.apply(t, e);
467
+ function _next(n) {
468
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
469
+ }
470
+ function _throw(n) {
471
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
472
+ }
473
+ _next(void 0);
474
+ });
475
+ };
476
+ }
477
+ function ownKeys(e, r) {
478
+ var t = Object.keys(e);
479
+ if (Object.getOwnPropertySymbols) {
480
+ var o = Object.getOwnPropertySymbols(e);
481
+ r &&
482
+ (o = o.filter(function (r) {
483
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
484
+ })),
485
+ t.push.apply(t, o);
486
+ }
487
+ return t;
488
+ }
489
+ function _objectSpread(e) {
490
+ for (var r = 1; r < arguments.length; r++) {
491
+ var t = null != arguments[r] ? arguments[r] : {};
492
+ r % 2
493
+ ? ownKeys(Object(t), !0).forEach(function (r) {
494
+ _defineProperty(e, r, t[r]);
495
+ })
496
+ : Object.getOwnPropertyDescriptors
497
+ ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
498
+ : ownKeys(Object(t)).forEach(function (r) {
499
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
500
+ });
501
+ }
502
+ return e;
503
+ }
504
+ function _defineProperty(e, r, t) {
505
+ return (
506
+ (r = _toPropertyKey(r)) in e
507
+ ? Object.defineProperty(e, r, {
508
+ value: t,
509
+ enumerable: !0,
510
+ configurable: !0,
511
+ writable: !0,
512
+ })
513
+ : (e[r] = t),
514
+ e
515
+ );
516
+ }
517
+ function _toPropertyKey(t) {
518
+ var i = _toPrimitive(t, "string");
519
+ return "symbol" == _typeof(i) ? i : i + "";
520
+ }
521
+ function _toPrimitive(t, r) {
522
+ if ("object" != _typeof(t) || !t) return t;
523
+ var e = t[Symbol.toPrimitive];
524
+ if (void 0 !== e) {
525
+ var i = e.call(t, r || "default");
526
+ if ("object" != _typeof(i)) return i;
527
+ throw new TypeError("@@toPrimitive must return a primitive value.");
528
+ }
529
+ return ("string" === r ? String : Number)(t);
530
+ }
20
531
  var PORT = Number(process.env.PORT) || 1408;
21
532
  exports.PORT = PORT;
22
533
  var cb = function cb(res, data) {
@@ -33,87 +544,117 @@ var extension = function extension(route, handler) {
33
544
  handlers.push(handler);
34
545
  };
35
546
  exports.extension = extension;
36
- var create_server = /*#__PURE__*/function () {
37
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(initiator) {
38
- var av, server;
39
- return _regeneratorRuntime().wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- _context.next = 2;
43
- return (0, _functions.is_port_available)(PORT);
44
- case 2:
45
- av = _context.sent;
46
- case 3:
47
- if (av) {
48
- _context.next = 10;
49
- break;
547
+ var handle_routes = function handle_routes(req, res, app) {
548
+ var data = "";
549
+ var is_in_default_routes = [
550
+ "run",
551
+ "load",
552
+ "parse",
553
+ "create_account",
554
+ ].includes(req.url.slice(1));
555
+ if (is_in_default_routes || (!is_in_default_routes && !app)) {
556
+ req.on("data", function (chunk) {
557
+ data += chunk;
558
+ });
559
+ req.on("end", function () {
560
+ try {
561
+ data = JSON.parse(data);
562
+ } catch (e) {
563
+ return cb(res.end, {
564
+ error_message: "Invalid data",
565
+ error: true,
566
+ });
567
+ }
568
+ if (req.url === "/create_account") {
569
+ var account = _Index.initiator.create_account(data);
570
+ res.end(account.stringify(true));
571
+ } else if (["run", "load", "parse"].includes(req.url.slice(1))) {
572
+ var payload = _objectSpread(
573
+ _objectSpread({}, data),
574
+ {},
575
+ {
576
+ callback: function callback(datagram) {
577
+ return cb(res.end, datagram);
578
+ },
50
579
  }
51
- _PORT = PORT++, exports.PORT = PORT, _PORT;
52
- _context.next = 7;
53
- return (0, _functions.is_port_available)(PORT);
54
- case 7:
55
- av = _context.sent;
56
- _context.next = 3;
57
- break;
58
- case 10:
59
- server = _http["default"].createServer(function (req, res) {
60
- var data = "";
61
- req.on("data", function (chunk) {
62
- data += chunk;
63
- });
64
- req.on("end", function () {
65
- try {
66
- data = JSON.parse(data);
67
- } catch (e) {
68
- return res.end(JSON.stringify({
69
- error_message: "Invalid data",
70
- error: true
71
- }));
72
- }
73
- if (req.url === "/create_account") {
74
- var account = initiator.create_account(data);
75
- res.end(account.stringify(true));
76
- } else if (["run", "load", "parse"].includes(req.url.slice(1))) {
77
- var payload = _objectSpread(_objectSpread({}, data), {}, {
78
- callback: function callback(datagram) {
79
- return cb(res.end, datagram);
80
- }
81
- });
82
- initiator.endpoint(req.url.slice(1), payload);
83
- } else {
84
- var _extension = extensions[req.url.slice(1)];
85
- if (_extension) {
86
- _extension.map(function (ex) {
87
- typeof ex === "function" && ex(data, {
88
- req: req,
89
- res: res
90
- });
91
- });
92
- }
93
- }
94
- });
95
- req.on("error", function (e) {
96
- res.writeHead(500, {
97
- "Content-Type": "application/json"
580
+ );
581
+ _Index.initiator.endpoint(req.url.slice(1), payload);
582
+ } else {
583
+ var _extension = extensions[req.url.slice(1)];
584
+ _extension &&
585
+ _extension.map(function (ex) {
586
+ typeof ex === "function" &&
587
+ ex(data, {
588
+ req: req,
589
+ res: res,
98
590
  });
99
- res.end(JSON.stringify({
100
- status: "error",
101
- message: e.message
102
- }));
103
- });
104
591
  });
105
- server.listen(PORT, function () {
106
- console.log("\n...GOD PROTOCOL RUNNING :".concat(PORT));
107
- });
108
- case 12:
109
- case "end":
110
- return _context.stop();
111
592
  }
112
- }, _callee);
113
- }));
114
- return function create_server(_x) {
593
+ });
594
+ req.on("error", function (e) {
595
+ res.writeHead(500, {
596
+ "Content-Type": "application/json",
597
+ });
598
+ res.end(
599
+ JSON.stringify({
600
+ status: "error",
601
+ message: e.message,
602
+ })
603
+ );
604
+ });
605
+ } else {
606
+ app && app(req, res);
607
+ }
608
+ };
609
+ var create_server = /*#__PURE__*/ (function () {
610
+ var _ref = _asyncToGenerator(
611
+ /*#__PURE__*/ _regeneratorRuntime().mark(function _callee(app, settings) {
612
+ var port, port_search, av, server;
613
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
614
+ while (1)
615
+ switch ((_context.prev = _context.next)) {
616
+ case 0:
617
+ settings = settings || {};
618
+ (port = settings.port || PORT),
619
+ (port_search = settings.port_search);
620
+ if (!port_search) {
621
+ _context.next = 13;
622
+ break;
623
+ }
624
+ _context.next = 5;
625
+ return (0, _functions.is_port_available)(port);
626
+ case 5:
627
+ av = _context.sent;
628
+ case 6:
629
+ if (av) {
630
+ _context.next = 13;
631
+ break;
632
+ }
633
+ port++;
634
+ _context.next = 10;
635
+ return (0, _functions.is_port_available)(port);
636
+ case 10:
637
+ av = _context.sent;
638
+ _context.next = 6;
639
+ break;
640
+ case 13:
641
+ exports.PORT = PORT = port;
642
+ server = _http["default"].createServer(function (req, res) {
643
+ return handle_routes(req, res, app);
644
+ });
645
+ server.listen(port, function () {
646
+ console.log("\n...GOD PROTOCOL RUNNING :".concat(port));
647
+ });
648
+ case 16:
649
+ case "end":
650
+ return _context.stop();
651
+ }
652
+ }, _callee);
653
+ })
654
+ );
655
+ return function create_server(_x, _x2) {
115
656
  return _ref.apply(this, arguments);
116
657
  };
117
- }();
658
+ })();
118
659
  var _default = create_server;
119
- exports["default"] = _default;
660
+ exports["default"] = _default;