godprotocol 1.0.796 → 1.0.798
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/.babelrc +3 -0
- package/Index.js +8 -21
- package/Loader_sequence/main.js +259 -358
- package/Objects/Account.js +178 -337
- package/Objects/Block.js +53 -58
- package/Objects/Blockweb.js +27 -34
- package/Objects/Chain.js +115 -118
- package/Objects/Explorer.js +30 -37
- package/Objects/Filesystem.js +95 -80
- package/Objects/Frame.js +43 -48
- package/Objects/Manager.js +68 -77
- package/Objects/Opcodes.js +32 -97
- package/Objects/Oracle.js +23 -39
- package/Objects/Virtual_machine.js +125 -261
- package/build/Account.js +162 -0
- package/build/Block.js +65 -0
- package/build/Blockweb.js +36 -0
- package/build/Chain.js +119 -0
- package/build/Explorer.js +47 -0
- package/build/Filesystem.js +127 -0
- package/build/Frame.js +52 -0
- package/build/Index.js +15 -0
- package/build/Manager.js +99 -0
- package/build/Opcodes.js +39 -0
- package/build/Oracle.js +42 -0
- package/build/Virtual_machine.js +128 -0
- package/build/add.js +41 -0
- package/build/create_server.js +119 -0
- package/build/framer.js +57 -0
- package/build/functions.js +82 -0
- package/build/hash.js +14 -0
- package/build/jmp.js +19 -0
- package/build/main.js +283 -0
- package/build/opcodes.js +42 -0
- package/build/privacy.js +27 -0
- package/build/services.js +50 -0
- package/build/std.js +11 -0
- package/framer.js +39 -31
- package/opcodes/add.js +14 -40
- package/opcodes/jmp.js +10 -14
- package/opcodes/std.js +5 -9
- package/opcodes.js +25 -29
- package/package.json +3 -3
- package/readme.md +71 -95
- package/types/Account.d.ts +73 -0
- package/types/Block.d.ts +22 -0
- package/types/Blockweb.d.ts +14 -0
- package/types/Chain.d.ts +35 -0
- package/types/Explorer.d.ts +9 -0
- package/types/Filesystem.d.ts +23 -0
- package/types/Frame.d.ts +14 -0
- package/types/Manager.d.ts +21 -0
- package/types/Opcodes.d.ts +11 -0
- package/types/Oracle.d.ts +17 -0
- package/types/Virtual_machine.d.ts +20 -0
- package/types/index.d.ts +4 -0
- package/utils/create_server.js +65 -622
- package/utils/functions.js +31 -43
- package/utils/hash.js +10 -11
- package/utils/privacy.js +10 -15
- package/utils/services.js +32 -33
package/utils/create_server.js
CHANGED
|
@@ -1,656 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
import http from "http";
|
|
2
|
+
import { is_port_available } from "./functions";
|
|
3
|
+
import { initiator } from "../Index";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.extension = exports["default"] = exports.PORT = void 0;
|
|
7
|
-
var _http = _interopRequireDefault(require("http"));
|
|
8
|
-
var _functions = require("./functions");
|
|
9
|
-
var _Index = require("../Index");
|
|
10
|
-
var _PORT;
|
|
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
|
-
}
|
|
532
|
-
var PORT = Number(process.env.PORT) || 1408;
|
|
533
|
-
exports.PORT = PORT;
|
|
534
|
-
var cb = function cb(res, data) {
|
|
5
|
+
let PORT = Number(process.env.PORT) || 1408;
|
|
6
|
+
|
|
7
|
+
const cb = (res, data) => {
|
|
535
8
|
if (typeof data !== "string") data = JSON.stringify(data);
|
|
9
|
+
|
|
536
10
|
res(data);
|
|
537
11
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
12
|
+
|
|
13
|
+
let extensions = new Object();
|
|
14
|
+
|
|
15
|
+
const extension = (route, handler) => {
|
|
16
|
+
let handlers = extensions[route];
|
|
541
17
|
if (!handlers) {
|
|
542
18
|
handlers = new Array();
|
|
543
19
|
extensions[route] = handlers;
|
|
544
20
|
}
|
|
21
|
+
|
|
545
22
|
handlers.push(handler);
|
|
546
23
|
};
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
24
|
+
|
|
25
|
+
const handle_routes = (req, res, app) => {
|
|
26
|
+
let data = "";
|
|
27
|
+
|
|
28
|
+
let is_in_default_routes = [
|
|
551
29
|
"run",
|
|
552
30
|
"load",
|
|
553
31
|
"parse",
|
|
554
32
|
"create_account",
|
|
555
33
|
].includes(req.url.slice(1));
|
|
34
|
+
|
|
556
35
|
if (is_in_default_routes || (!is_in_default_routes && !app)) {
|
|
557
|
-
req.on("data",
|
|
36
|
+
req.on("data", (chunk) => {
|
|
558
37
|
data += chunk;
|
|
559
38
|
});
|
|
560
|
-
|
|
39
|
+
|
|
40
|
+
req.on("end", () => {
|
|
561
41
|
try {
|
|
562
42
|
data = JSON.parse(data);
|
|
563
43
|
} catch (e) {
|
|
564
|
-
return cb(
|
|
565
|
-
res.end,
|
|
566
|
-
JSON.stringify({
|
|
567
|
-
error_message: "Invalid data",
|
|
568
|
-
error: true,
|
|
569
|
-
})
|
|
570
|
-
);
|
|
44
|
+
return cb(res.end, { error_message: "Invalid data", error: true });
|
|
571
45
|
}
|
|
46
|
+
|
|
572
47
|
if (req.url === "/create_account") {
|
|
573
|
-
|
|
48
|
+
let account = initiator.create_account(data);
|
|
574
49
|
res.end(account.stringify(true));
|
|
575
50
|
} else if (["run", "load", "parse"].includes(req.url.slice(1))) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return cb(res.end, datagram);
|
|
582
|
-
},
|
|
583
|
-
}
|
|
584
|
-
);
|
|
585
|
-
_Index.initiator.endpoint(req.url.slice(1), payload);
|
|
51
|
+
let payload = {
|
|
52
|
+
...data,
|
|
53
|
+
callback: (datagram) => cb(res.end, datagram),
|
|
54
|
+
};
|
|
55
|
+
initiator.endpoint(req.url.slice(1), payload);
|
|
586
56
|
} else {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
req: req,
|
|
593
|
-
res: res,
|
|
594
|
-
});
|
|
57
|
+
let extension = extensions[req.url.slice(1)];
|
|
58
|
+
|
|
59
|
+
extension &&
|
|
60
|
+
extension.map((ex) => {
|
|
61
|
+
typeof ex === "function" && ex(data, { req, res });
|
|
595
62
|
});
|
|
596
63
|
}
|
|
597
64
|
});
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
});
|
|
602
|
-
res.end(
|
|
603
|
-
JSON.stringify({
|
|
604
|
-
status: "error",
|
|
605
|
-
message: e.message,
|
|
606
|
-
})
|
|
607
|
-
);
|
|
65
|
+
|
|
66
|
+
req.on("error", (e) => {
|
|
67
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
68
|
+
res.end(JSON.stringify({ status: "error", message: e.message }));
|
|
608
69
|
});
|
|
609
70
|
} else {
|
|
610
71
|
app && app(req, res);
|
|
611
72
|
}
|
|
612
73
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
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
|
-
);
|
|
651
|
-
return function create_server(_x) {
|
|
652
|
-
return _ref.apply(this, arguments);
|
|
653
|
-
};
|
|
654
|
-
})();
|
|
655
|
-
var _default = create_server;
|
|
656
|
-
exports["default"] = _default;
|
|
74
|
+
|
|
75
|
+
const create_server = async (app, settings) => {
|
|
76
|
+
settings = settings || {};
|
|
77
|
+
|
|
78
|
+
let port = settings.port || PORT,
|
|
79
|
+
port_search = settings.port_search;
|
|
80
|
+
|
|
81
|
+
if (port_search) {
|
|
82
|
+
let av = await is_port_available(port);
|
|
83
|
+
|
|
84
|
+
while (!av) {
|
|
85
|
+
port++;
|
|
86
|
+
av = await is_port_available(port);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
PORT = port;
|
|
90
|
+
|
|
91
|
+
let server = http.createServer((req, res) => handle_routes(req, res, app));
|
|
92
|
+
|
|
93
|
+
server.listen(port, () => {
|
|
94
|
+
console.log(`\n...GOD PROTOCOL RUNNING :${port}`);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default create_server;
|
|
99
|
+
export { PORT, extension };
|