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