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 +11 -4
- package/package.json +1 -1
- package/utils/create_server.js +630 -89
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,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
|
|
11
|
-
function _interopRequireDefault(e) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
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
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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"
|
|
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
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
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;
|