wao 0.32.1 → 0.32.2
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/cjs/hb.js +474 -690
- package/cjs/send.js +6 -2
- package/cjs/workspace/package.json +1 -1
- package/esm/hb.js +68 -218
- package/esm/send.js +8 -4
- package/esm/signer.js +0 -1
- package/esm/workspace/package.json +1 -1
- package/package.json +1 -1
- package/cjs/hb2.js +0 -1505
- package/cjs/hb3.js +0 -1468
- package/esm/hb2.js +0 -439
- package/esm/hb3.js +0 -418
package/cjs/hb3.js
DELETED
|
@@ -1,1468 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _aoconnect = require("@permaweb/aoconnect");
|
|
8
|
-
var _ramda = require("ramda");
|
|
9
|
-
var _utils = require("./utils.js");
|
|
10
|
-
var _signer = require("./signer.js");
|
|
11
|
-
var _send3 = require("./send.js");
|
|
12
|
-
var _hyperAos = _interopRequireDefault(require("./lua/hyper-aos.js"));
|
|
13
|
-
var _aos_wamr = _interopRequireDefault(require("./lua/aos_wamr.js"));
|
|
14
|
-
var _httpsig = require("./httpsig.js");
|
|
15
|
-
var _excluded = ["path"],
|
|
16
|
-
_excluded2 = ["path"];
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
|
-
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); }
|
|
19
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
20
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
22
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
23
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
24
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
25
|
-
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; }
|
|
26
|
-
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; }
|
|
27
|
-
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; }
|
|
28
|
-
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; }
|
|
29
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
30
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
31
|
-
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); }
|
|
32
|
-
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); }); }; }
|
|
33
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
34
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
35
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
36
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
37
|
-
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); }
|
|
38
|
-
var seed = function seed(num) {
|
|
39
|
-
var array = new Array(num);
|
|
40
|
-
for (var i = 0; i < num; i++) array[i] = Math.floor(Math.random() * 256);
|
|
41
|
-
return Buffer.from(array).toString("base64");
|
|
42
|
-
};
|
|
43
|
-
var HB = /*#__PURE__*/function () {
|
|
44
|
-
function HB() {
|
|
45
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
46
|
-
_ref$url = _ref.url,
|
|
47
|
-
url = _ref$url === void 0 ? "http://localhost:10001" : _ref$url,
|
|
48
|
-
_ref$cu = _ref.cu,
|
|
49
|
-
cu = _ref$cu === void 0 ? "http://localhost:6363" : _ref$cu,
|
|
50
|
-
jwk = _ref.jwk;
|
|
51
|
-
_classCallCheck(this, HB);
|
|
52
|
-
this.cu = cu;
|
|
53
|
-
this.url = url;
|
|
54
|
-
if (jwk) this._init(jwk);
|
|
55
|
-
}
|
|
56
|
-
return _createClass(HB, [{
|
|
57
|
-
key: "signEncoded",
|
|
58
|
-
value: function () {
|
|
59
|
-
var _signEncoded = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(encoded) {
|
|
60
|
-
var path, msg;
|
|
61
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
-
while (1) switch (_context.prev = _context.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
path = encoded.path, msg = _objectWithoutProperties(encoded, _excluded);
|
|
65
|
-
_context.next = 3;
|
|
66
|
-
return (0, _signer.sign)({
|
|
67
|
-
jwk: this.jwk,
|
|
68
|
-
msg: msg,
|
|
69
|
-
path: path,
|
|
70
|
-
url: this.url
|
|
71
|
-
});
|
|
72
|
-
case 3:
|
|
73
|
-
return _context.abrupt("return", _context.sent);
|
|
74
|
-
case 4:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
78
|
-
}, _callee, this);
|
|
79
|
-
}));
|
|
80
|
-
function signEncoded(_x) {
|
|
81
|
-
return _signEncoded.apply(this, arguments);
|
|
82
|
-
}
|
|
83
|
-
return signEncoded;
|
|
84
|
-
}()
|
|
85
|
-
}, {
|
|
86
|
-
key: "_init",
|
|
87
|
-
value: function _init(jwk) {
|
|
88
|
-
this.jwk = jwk;
|
|
89
|
-
this.signer = (0, _aoconnect.createSigner)(jwk, this.url);
|
|
90
|
-
this.addr = (0, _utils.toAddr)(jwk.n);
|
|
91
|
-
this.sign = (0, _signer.signer)({
|
|
92
|
-
signer: this.signer,
|
|
93
|
-
url: this.url
|
|
94
|
-
});
|
|
95
|
-
var _connect = (0, _aoconnect.connect)({
|
|
96
|
-
MODE: "mainnet",
|
|
97
|
-
URL: this.url,
|
|
98
|
-
device: "",
|
|
99
|
-
signer: this.signer
|
|
100
|
-
}),
|
|
101
|
-
request = _connect.request;
|
|
102
|
-
this._request = request;
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "setInfo",
|
|
106
|
-
value: function () {
|
|
107
|
-
var _setInfo = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
108
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
109
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
110
|
-
case 0:
|
|
111
|
-
if (this._info) {
|
|
112
|
-
_context2.next = 9;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
_context2.prev = 1;
|
|
116
|
-
_context2.next = 4;
|
|
117
|
-
return this.g("/~meta@1.0/info");
|
|
118
|
-
case 4:
|
|
119
|
-
this._info = _context2.sent;
|
|
120
|
-
_context2.next = 9;
|
|
121
|
-
break;
|
|
122
|
-
case 7:
|
|
123
|
-
_context2.prev = 7;
|
|
124
|
-
_context2.t0 = _context2["catch"](1);
|
|
125
|
-
case 9:
|
|
126
|
-
case "end":
|
|
127
|
-
return _context2.stop();
|
|
128
|
-
}
|
|
129
|
-
}, _callee2, this, [[1, 7]]);
|
|
130
|
-
}));
|
|
131
|
-
function setInfo() {
|
|
132
|
-
return _setInfo.apply(this, arguments);
|
|
133
|
-
}
|
|
134
|
-
return setInfo;
|
|
135
|
-
}()
|
|
136
|
-
}, {
|
|
137
|
-
key: "init",
|
|
138
|
-
value: function () {
|
|
139
|
-
var _init2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(jwk) {
|
|
140
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
141
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
142
|
-
case 0:
|
|
143
|
-
this._init(jwk);
|
|
144
|
-
_context3.next = 3;
|
|
145
|
-
return this.setInfo();
|
|
146
|
-
case 3:
|
|
147
|
-
return _context3.abrupt("return", this);
|
|
148
|
-
case 4:
|
|
149
|
-
case "end":
|
|
150
|
-
return _context3.stop();
|
|
151
|
-
}
|
|
152
|
-
}, _callee3, this);
|
|
153
|
-
}));
|
|
154
|
-
function init(_x2) {
|
|
155
|
-
return _init2.apply(this, arguments);
|
|
156
|
-
}
|
|
157
|
-
return init;
|
|
158
|
-
}()
|
|
159
|
-
}, {
|
|
160
|
-
key: "send",
|
|
161
|
-
value: function () {
|
|
162
|
-
var _send2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(msg) {
|
|
163
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
164
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
165
|
-
case 0:
|
|
166
|
-
_context4.next = 2;
|
|
167
|
-
return (0, _send3.send)(msg);
|
|
168
|
-
case 2:
|
|
169
|
-
return _context4.abrupt("return", _context4.sent);
|
|
170
|
-
case 3:
|
|
171
|
-
case "end":
|
|
172
|
-
return _context4.stop();
|
|
173
|
-
}
|
|
174
|
-
}, _callee4);
|
|
175
|
-
}));
|
|
176
|
-
function send(_x3) {
|
|
177
|
-
return _send2.apply(this, arguments);
|
|
178
|
-
}
|
|
179
|
-
return send;
|
|
180
|
-
}()
|
|
181
|
-
}, {
|
|
182
|
-
key: "getImage",
|
|
183
|
-
value: function () {
|
|
184
|
-
var _getImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
185
|
-
var _this$image;
|
|
186
|
-
var wasm, id;
|
|
187
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
188
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
189
|
-
case 0:
|
|
190
|
-
wasm = Buffer.from(_aos_wamr["default"], "base64");
|
|
191
|
-
_context5.next = 3;
|
|
192
|
-
return this.cacheBinary(wasm, "application/wasm");
|
|
193
|
-
case 3:
|
|
194
|
-
id = _context5.sent;
|
|
195
|
-
(_this$image = this.image) !== null && _this$image !== void 0 ? _this$image : this.image = id;
|
|
196
|
-
return _context5.abrupt("return", id);
|
|
197
|
-
case 6:
|
|
198
|
-
case "end":
|
|
199
|
-
return _context5.stop();
|
|
200
|
-
}
|
|
201
|
-
}, _callee5, this);
|
|
202
|
-
}));
|
|
203
|
-
function getImage() {
|
|
204
|
-
return _getImage.apply(this, arguments);
|
|
205
|
-
}
|
|
206
|
-
return getImage;
|
|
207
|
-
}()
|
|
208
|
-
}, {
|
|
209
|
-
key: "getLua",
|
|
210
|
-
value: function () {
|
|
211
|
-
var _getLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
212
|
-
var _this$lua;
|
|
213
|
-
var lua, id;
|
|
214
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
215
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
216
|
-
case 0:
|
|
217
|
-
lua = Buffer.from(_hyperAos["default"], "base64");
|
|
218
|
-
_context6.next = 3;
|
|
219
|
-
return this.cacheScript(lua, "application/lua");
|
|
220
|
-
case 3:
|
|
221
|
-
id = _context6.sent;
|
|
222
|
-
(_this$lua = this.lua) !== null && _this$lua !== void 0 ? _this$lua : this.lua = id;
|
|
223
|
-
return _context6.abrupt("return", id);
|
|
224
|
-
case 6:
|
|
225
|
-
case "end":
|
|
226
|
-
return _context6.stop();
|
|
227
|
-
}
|
|
228
|
-
}, _callee6, this);
|
|
229
|
-
}));
|
|
230
|
-
function getLua() {
|
|
231
|
-
return _getLua.apply(this, arguments);
|
|
232
|
-
}
|
|
233
|
-
return getLua;
|
|
234
|
-
}()
|
|
235
|
-
}, {
|
|
236
|
-
key: "scheduleAOS",
|
|
237
|
-
value: function () {
|
|
238
|
-
var _scheduleAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref2) {
|
|
239
|
-
var _pid;
|
|
240
|
-
var pid, _ref2$action, action, _ref2$tags, tags, data, _tags, res, slot;
|
|
241
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
242
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
243
|
-
case 0:
|
|
244
|
-
pid = _ref2.pid, _ref2$action = _ref2.action, action = _ref2$action === void 0 ? "Eval" : _ref2$action, _ref2$tags = _ref2.tags, tags = _ref2$tags === void 0 ? {} : _ref2$tags, data = _ref2.data;
|
|
245
|
-
(_pid = pid) !== null && _pid !== void 0 ? _pid : pid = this.pid;
|
|
246
|
-
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
247
|
-
device: "process@1.0",
|
|
248
|
-
method: "POST",
|
|
249
|
-
path: "/".concat(pid, "~process@1.0/schedule"),
|
|
250
|
-
scheduler: this.scheduler,
|
|
251
|
-
type: "Message",
|
|
252
|
-
Action: action,
|
|
253
|
-
target: pid
|
|
254
|
-
});
|
|
255
|
-
if (data) _tags.data = data;
|
|
256
|
-
_context7.next = 6;
|
|
257
|
-
return this.post(_tags);
|
|
258
|
-
case 6:
|
|
259
|
-
res = _context7.sent;
|
|
260
|
-
slot = res.headers.slot;
|
|
261
|
-
return _context7.abrupt("return", {
|
|
262
|
-
slot: slot,
|
|
263
|
-
res: res,
|
|
264
|
-
pid: pid
|
|
265
|
-
});
|
|
266
|
-
case 9:
|
|
267
|
-
case "end":
|
|
268
|
-
return _context7.stop();
|
|
269
|
-
}
|
|
270
|
-
}, _callee7, this);
|
|
271
|
-
}));
|
|
272
|
-
function scheduleAOS(_x4) {
|
|
273
|
-
return _scheduleAOS.apply(this, arguments);
|
|
274
|
-
}
|
|
275
|
-
return scheduleAOS;
|
|
276
|
-
}()
|
|
277
|
-
}, {
|
|
278
|
-
key: "messageAOS",
|
|
279
|
-
value: function () {
|
|
280
|
-
var _messageAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(args) {
|
|
281
|
-
var _yield$this$scheduleA, slot, pid;
|
|
282
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
283
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
284
|
-
case 0:
|
|
285
|
-
_context8.next = 2;
|
|
286
|
-
return this.scheduleAOS(args);
|
|
287
|
-
case 2:
|
|
288
|
-
_yield$this$scheduleA = _context8.sent;
|
|
289
|
-
slot = _yield$this$scheduleA.slot;
|
|
290
|
-
pid = _yield$this$scheduleA.pid;
|
|
291
|
-
_context8.t0 = slot;
|
|
292
|
-
_context8.next = 8;
|
|
293
|
-
return this.computeAOS({
|
|
294
|
-
pid: pid,
|
|
295
|
-
slot: slot
|
|
296
|
-
});
|
|
297
|
-
case 8:
|
|
298
|
-
_context8.t1 = _context8.sent;
|
|
299
|
-
return _context8.abrupt("return", {
|
|
300
|
-
slot: _context8.t0,
|
|
301
|
-
outbox: _context8.t1
|
|
302
|
-
});
|
|
303
|
-
case 10:
|
|
304
|
-
case "end":
|
|
305
|
-
return _context8.stop();
|
|
306
|
-
}
|
|
307
|
-
}, _callee8, this);
|
|
308
|
-
}));
|
|
309
|
-
function messageAOS(_x5) {
|
|
310
|
-
return _messageAOS.apply(this, arguments);
|
|
311
|
-
}
|
|
312
|
-
return messageAOS;
|
|
313
|
-
}()
|
|
314
|
-
}, {
|
|
315
|
-
key: "messageLegacy",
|
|
316
|
-
value: function () {
|
|
317
|
-
var _messageLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(args) {
|
|
318
|
-
var _yield$this$scheduleL, slot, pid;
|
|
319
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
320
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
321
|
-
case 0:
|
|
322
|
-
_context9.next = 2;
|
|
323
|
-
return this.scheduleLegacy(args);
|
|
324
|
-
case 2:
|
|
325
|
-
_yield$this$scheduleL = _context9.sent;
|
|
326
|
-
slot = _yield$this$scheduleL.slot;
|
|
327
|
-
pid = _yield$this$scheduleL.pid;
|
|
328
|
-
_context9.t0 = slot;
|
|
329
|
-
_context9.next = 8;
|
|
330
|
-
return this.computeLegacy({
|
|
331
|
-
pid: pid,
|
|
332
|
-
slot: slot
|
|
333
|
-
});
|
|
334
|
-
case 8:
|
|
335
|
-
_context9.t1 = _context9.sent;
|
|
336
|
-
return _context9.abrupt("return", {
|
|
337
|
-
slot: _context9.t0,
|
|
338
|
-
res: _context9.t1
|
|
339
|
-
});
|
|
340
|
-
case 10:
|
|
341
|
-
case "end":
|
|
342
|
-
return _context9.stop();
|
|
343
|
-
}
|
|
344
|
-
}, _callee9, this);
|
|
345
|
-
}));
|
|
346
|
-
function messageLegacy(_x6) {
|
|
347
|
-
return _messageLegacy.apply(this, arguments);
|
|
348
|
-
}
|
|
349
|
-
return messageLegacy;
|
|
350
|
-
}()
|
|
351
|
-
}, {
|
|
352
|
-
key: "computeAOS",
|
|
353
|
-
value: function () {
|
|
354
|
-
var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref3) {
|
|
355
|
-
var pid, slot;
|
|
356
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
357
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
358
|
-
case 0:
|
|
359
|
-
pid = _ref3.pid, slot = _ref3.slot;
|
|
360
|
-
_context10.next = 3;
|
|
361
|
-
return this.getJSON({
|
|
362
|
-
path: "/".concat(pid, "/compute/results/outbox"),
|
|
363
|
-
slot: slot
|
|
364
|
-
});
|
|
365
|
-
case 3:
|
|
366
|
-
return _context10.abrupt("return", _context10.sent);
|
|
367
|
-
case 4:
|
|
368
|
-
case "end":
|
|
369
|
-
return _context10.stop();
|
|
370
|
-
}
|
|
371
|
-
}, _callee10, this);
|
|
372
|
-
}));
|
|
373
|
-
function computeAOS(_x7) {
|
|
374
|
-
return _computeAOS.apply(this, arguments);
|
|
375
|
-
}
|
|
376
|
-
return computeAOS;
|
|
377
|
-
}()
|
|
378
|
-
}, {
|
|
379
|
-
key: "computeLua",
|
|
380
|
-
value: function () {
|
|
381
|
-
var _computeLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref4) {
|
|
382
|
-
var pid, slot;
|
|
383
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
384
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
385
|
-
case 0:
|
|
386
|
-
pid = _ref4.pid, slot = _ref4.slot;
|
|
387
|
-
_context11.next = 3;
|
|
388
|
-
return this.getJSON({
|
|
389
|
-
path: "/".concat(pid, "/compute/results"),
|
|
390
|
-
slot: slot
|
|
391
|
-
});
|
|
392
|
-
case 3:
|
|
393
|
-
return _context11.abrupt("return", _context11.sent);
|
|
394
|
-
case 4:
|
|
395
|
-
case "end":
|
|
396
|
-
return _context11.stop();
|
|
397
|
-
}
|
|
398
|
-
}, _callee11, this);
|
|
399
|
-
}));
|
|
400
|
-
function computeLua(_x8) {
|
|
401
|
-
return _computeLua.apply(this, arguments);
|
|
402
|
-
}
|
|
403
|
-
return computeLua;
|
|
404
|
-
}()
|
|
405
|
-
}, {
|
|
406
|
-
key: "compute",
|
|
407
|
-
value: function () {
|
|
408
|
-
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref5) {
|
|
409
|
-
var pid, slot, _ref5$path, path;
|
|
410
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
411
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
412
|
-
case 0:
|
|
413
|
-
pid = _ref5.pid, slot = _ref5.slot, _ref5$path = _ref5.path, path = _ref5$path === void 0 ? "" : _ref5$path;
|
|
414
|
-
if (path && !/^\//.test(path)) path = "/" + path;
|
|
415
|
-
_context12.next = 4;
|
|
416
|
-
return this.getJSON({
|
|
417
|
-
path: "/".concat(pid, "/compute").concat(path),
|
|
418
|
-
slot: slot
|
|
419
|
-
});
|
|
420
|
-
case 4:
|
|
421
|
-
return _context12.abrupt("return", _context12.sent);
|
|
422
|
-
case 5:
|
|
423
|
-
case "end":
|
|
424
|
-
return _context12.stop();
|
|
425
|
-
}
|
|
426
|
-
}, _callee12, this);
|
|
427
|
-
}));
|
|
428
|
-
function compute(_x9) {
|
|
429
|
-
return _compute.apply(this, arguments);
|
|
430
|
-
}
|
|
431
|
-
return compute;
|
|
432
|
-
}()
|
|
433
|
-
}, {
|
|
434
|
-
key: "computeLegacy",
|
|
435
|
-
value: function () {
|
|
436
|
-
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref6) {
|
|
437
|
-
var pid, slot, json;
|
|
438
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
439
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
440
|
-
case 0:
|
|
441
|
-
pid = _ref6.pid, slot = _ref6.slot;
|
|
442
|
-
_context13.next = 3;
|
|
443
|
-
return this.compute({
|
|
444
|
-
pid: pid,
|
|
445
|
-
slot: slot
|
|
446
|
-
});
|
|
447
|
-
case 3:
|
|
448
|
-
json = _context13.sent;
|
|
449
|
-
return _context13.abrupt("return", JSON.parse(json.results.json.body));
|
|
450
|
-
case 5:
|
|
451
|
-
case "end":
|
|
452
|
-
return _context13.stop();
|
|
453
|
-
}
|
|
454
|
-
}, _callee13, this);
|
|
455
|
-
}));
|
|
456
|
-
function computeLegacy(_x10) {
|
|
457
|
-
return _computeLegacy.apply(this, arguments);
|
|
458
|
-
}
|
|
459
|
-
return computeLegacy;
|
|
460
|
-
}()
|
|
461
|
-
}, {
|
|
462
|
-
key: "spawn",
|
|
463
|
-
value: function () {
|
|
464
|
-
var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
465
|
-
var _this$scheduler;
|
|
466
|
-
var tags,
|
|
467
|
-
addr,
|
|
468
|
-
_tags,
|
|
469
|
-
res,
|
|
470
|
-
_args15 = arguments;
|
|
471
|
-
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
472
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
473
|
-
case 0:
|
|
474
|
-
tags = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
475
|
-
_context14.next = 3;
|
|
476
|
-
return this.g("/~meta@1.0/info/address");
|
|
477
|
-
case 3:
|
|
478
|
-
addr = _context14.sent;
|
|
479
|
-
(_this$scheduler = this.scheduler) !== null && _this$scheduler !== void 0 ? _this$scheduler : this.scheduler = addr;
|
|
480
|
-
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
481
|
-
device: "process@1.0",
|
|
482
|
-
path: "/schedule",
|
|
483
|
-
scheduler: this.scheduler,
|
|
484
|
-
"random-seed": seed(16),
|
|
485
|
-
type: "Process",
|
|
486
|
-
"execution-device": "test-device@1.0"
|
|
487
|
-
});
|
|
488
|
-
_context14.next = 8;
|
|
489
|
-
return this.post(_tags);
|
|
490
|
-
case 8:
|
|
491
|
-
res = _context14.sent;
|
|
492
|
-
return _context14.abrupt("return", {
|
|
493
|
-
res: res,
|
|
494
|
-
pid: res.headers.process
|
|
495
|
-
});
|
|
496
|
-
case 10:
|
|
497
|
-
case "end":
|
|
498
|
-
return _context14.stop();
|
|
499
|
-
}
|
|
500
|
-
}, _callee14, this);
|
|
501
|
-
}));
|
|
502
|
-
function spawn() {
|
|
503
|
-
return _spawn.apply(this, arguments);
|
|
504
|
-
}
|
|
505
|
-
return spawn;
|
|
506
|
-
}()
|
|
507
|
-
}, {
|
|
508
|
-
key: "cacheScript",
|
|
509
|
-
value: function () {
|
|
510
|
-
var _cacheScript = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(data) {
|
|
511
|
-
var type,
|
|
512
|
-
_yield$this$spawn,
|
|
513
|
-
pid,
|
|
514
|
-
_yield$this$schedule,
|
|
515
|
-
slot,
|
|
516
|
-
msgs,
|
|
517
|
-
_args16 = arguments;
|
|
518
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
519
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
520
|
-
case 0:
|
|
521
|
-
type = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : "application/lua";
|
|
522
|
-
if (this.cache) {
|
|
523
|
-
_context15.next = 7;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
_context15.next = 4;
|
|
527
|
-
return this.spawn({});
|
|
528
|
-
case 4:
|
|
529
|
-
_yield$this$spawn = _context15.sent;
|
|
530
|
-
pid = _yield$this$spawn.pid;
|
|
531
|
-
this.cache = pid;
|
|
532
|
-
case 7:
|
|
533
|
-
_context15.next = 9;
|
|
534
|
-
return this.schedule({
|
|
535
|
-
data: data,
|
|
536
|
-
pid: this.cache,
|
|
537
|
-
"content-type": type
|
|
538
|
-
});
|
|
539
|
-
case 9:
|
|
540
|
-
_yield$this$schedule = _context15.sent;
|
|
541
|
-
slot = _yield$this$schedule.slot;
|
|
542
|
-
_context15.next = 13;
|
|
543
|
-
return this.messages({
|
|
544
|
-
pid: this.cache,
|
|
545
|
-
from: slot,
|
|
546
|
-
limit: 1
|
|
547
|
-
});
|
|
548
|
-
case 13:
|
|
549
|
-
msgs = _context15.sent;
|
|
550
|
-
return _context15.abrupt("return", msgs.edges[0].node.message.Id);
|
|
551
|
-
case 15:
|
|
552
|
-
case "end":
|
|
553
|
-
return _context15.stop();
|
|
554
|
-
}
|
|
555
|
-
}, _callee15, this);
|
|
556
|
-
}));
|
|
557
|
-
function cacheScript(_x11) {
|
|
558
|
-
return _cacheScript.apply(this, arguments);
|
|
559
|
-
}
|
|
560
|
-
return cacheScript;
|
|
561
|
-
}()
|
|
562
|
-
}, {
|
|
563
|
-
key: "cacheBinary",
|
|
564
|
-
value: function () {
|
|
565
|
-
var _cacheBinary = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(data, type) {
|
|
566
|
-
var res;
|
|
567
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
568
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
569
|
-
case 0:
|
|
570
|
-
_context16.next = 2;
|
|
571
|
-
return this.post({
|
|
572
|
-
path: "/~wao@1.0/cache_module",
|
|
573
|
-
data: data,
|
|
574
|
-
type: type
|
|
575
|
-
});
|
|
576
|
-
case 2:
|
|
577
|
-
res = _context16.sent;
|
|
578
|
-
return _context16.abrupt("return", res.headers.id);
|
|
579
|
-
case 4:
|
|
580
|
-
case "end":
|
|
581
|
-
return _context16.stop();
|
|
582
|
-
}
|
|
583
|
-
}, _callee16, this);
|
|
584
|
-
}));
|
|
585
|
-
function cacheBinary(_x12, _x13) {
|
|
586
|
-
return _cacheBinary.apply(this, arguments);
|
|
587
|
-
}
|
|
588
|
-
return cacheBinary;
|
|
589
|
-
}()
|
|
590
|
-
}, {
|
|
591
|
-
key: "message",
|
|
592
|
-
value: function () {
|
|
593
|
-
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(args) {
|
|
594
|
-
var pid, _yield$this$schedule2, slot, res;
|
|
595
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
596
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
597
|
-
case 0:
|
|
598
|
-
pid = args.pid;
|
|
599
|
-
_context17.next = 3;
|
|
600
|
-
return this.schedule(args);
|
|
601
|
-
case 3:
|
|
602
|
-
_yield$this$schedule2 = _context17.sent;
|
|
603
|
-
slot = _yield$this$schedule2.slot;
|
|
604
|
-
_context17.next = 7;
|
|
605
|
-
return this.compute({
|
|
606
|
-
pid: pid,
|
|
607
|
-
slot: slot
|
|
608
|
-
});
|
|
609
|
-
case 7:
|
|
610
|
-
res = _context17.sent;
|
|
611
|
-
return _context17.abrupt("return", {
|
|
612
|
-
slot: slot,
|
|
613
|
-
pid: pid,
|
|
614
|
-
res: res
|
|
615
|
-
});
|
|
616
|
-
case 9:
|
|
617
|
-
case "end":
|
|
618
|
-
return _context17.stop();
|
|
619
|
-
}
|
|
620
|
-
}, _callee17, this);
|
|
621
|
-
}));
|
|
622
|
-
function message(_x14) {
|
|
623
|
-
return _message.apply(this, arguments);
|
|
624
|
-
}
|
|
625
|
-
return message;
|
|
626
|
-
}()
|
|
627
|
-
}, {
|
|
628
|
-
key: "scheduleLegacy",
|
|
629
|
-
value: function () {
|
|
630
|
-
var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
631
|
-
var _ref7,
|
|
632
|
-
pid,
|
|
633
|
-
_ref7$action,
|
|
634
|
-
action,
|
|
635
|
-
_ref7$tags,
|
|
636
|
-
tags,
|
|
637
|
-
data,
|
|
638
|
-
scheduler,
|
|
639
|
-
_args19 = arguments;
|
|
640
|
-
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
641
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
642
|
-
case 0:
|
|
643
|
-
_ref7 = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {}, pid = _ref7.pid, _ref7$action = _ref7.action, action = _ref7$action === void 0 ? "Eval" : _ref7$action, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data, scheduler = _ref7.scheduler;
|
|
644
|
-
if (action) tags.Action = action;
|
|
645
|
-
_context18.next = 4;
|
|
646
|
-
return this.schedule({
|
|
647
|
-
pid: pid,
|
|
648
|
-
tags: tags,
|
|
649
|
-
data: data,
|
|
650
|
-
scheduler: scheduler
|
|
651
|
-
});
|
|
652
|
-
case 4:
|
|
653
|
-
return _context18.abrupt("return", _context18.sent);
|
|
654
|
-
case 5:
|
|
655
|
-
case "end":
|
|
656
|
-
return _context18.stop();
|
|
657
|
-
}
|
|
658
|
-
}, _callee18, this);
|
|
659
|
-
}));
|
|
660
|
-
function scheduleLegacy() {
|
|
661
|
-
return _scheduleLegacy.apply(this, arguments);
|
|
662
|
-
}
|
|
663
|
-
return scheduleLegacy;
|
|
664
|
-
}()
|
|
665
|
-
}, {
|
|
666
|
-
key: "scheduleLua",
|
|
667
|
-
value: function () {
|
|
668
|
-
var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
669
|
-
var _args20 = arguments;
|
|
670
|
-
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
671
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
672
|
-
case 0:
|
|
673
|
-
_context19.next = 2;
|
|
674
|
-
return this.scheduleLegacy.apply(this, _args20);
|
|
675
|
-
case 2:
|
|
676
|
-
return _context19.abrupt("return", _context19.sent);
|
|
677
|
-
case 3:
|
|
678
|
-
case "end":
|
|
679
|
-
return _context19.stop();
|
|
680
|
-
}
|
|
681
|
-
}, _callee19, this);
|
|
682
|
-
}));
|
|
683
|
-
function scheduleLua() {
|
|
684
|
-
return _scheduleLua.apply(this, arguments);
|
|
685
|
-
}
|
|
686
|
-
return scheduleLua;
|
|
687
|
-
}()
|
|
688
|
-
}, {
|
|
689
|
-
key: "schedule",
|
|
690
|
-
value: function () {
|
|
691
|
-
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
692
|
-
var _pid2;
|
|
693
|
-
var _ref8,
|
|
694
|
-
pid,
|
|
695
|
-
_ref8$tags,
|
|
696
|
-
tags,
|
|
697
|
-
data,
|
|
698
|
-
_tags,
|
|
699
|
-
res,
|
|
700
|
-
_args21 = arguments;
|
|
701
|
-
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
702
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
703
|
-
case 0:
|
|
704
|
-
_ref8 = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {}, pid = _ref8.pid, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, data = _ref8.data;
|
|
705
|
-
(_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
|
|
706
|
-
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
707
|
-
method: "POST",
|
|
708
|
-
path: "/".concat(pid, "/schedule"),
|
|
709
|
-
type: "Message",
|
|
710
|
-
target: pid
|
|
711
|
-
});
|
|
712
|
-
if (data) _tags.data = data;
|
|
713
|
-
_context20.next = 6;
|
|
714
|
-
return this.post(_tags);
|
|
715
|
-
case 6:
|
|
716
|
-
res = _context20.sent;
|
|
717
|
-
return _context20.abrupt("return", {
|
|
718
|
-
slot: res.headers.slot,
|
|
719
|
-
res: res,
|
|
720
|
-
pid: pid
|
|
721
|
-
});
|
|
722
|
-
case 8:
|
|
723
|
-
case "end":
|
|
724
|
-
return _context20.stop();
|
|
725
|
-
}
|
|
726
|
-
}, _callee20, this);
|
|
727
|
-
}));
|
|
728
|
-
function schedule() {
|
|
729
|
-
return _schedule.apply(this, arguments);
|
|
730
|
-
}
|
|
731
|
-
return schedule;
|
|
732
|
-
}()
|
|
733
|
-
}, {
|
|
734
|
-
key: "spawnAOS",
|
|
735
|
-
value: function () {
|
|
736
|
-
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(image) {
|
|
737
|
-
var _this$scheduler2, _image, _this$image2, _this$pid;
|
|
738
|
-
var addr, res, pid;
|
|
739
|
-
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
740
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
741
|
-
case 0:
|
|
742
|
-
_context21.next = 2;
|
|
743
|
-
return this.g("/~meta@1.0/info/address");
|
|
744
|
-
case 2:
|
|
745
|
-
addr = _context21.sent;
|
|
746
|
-
(_this$scheduler2 = this.scheduler) !== null && _this$scheduler2 !== void 0 ? _this$scheduler2 : this.scheduler = addr;
|
|
747
|
-
if (!((_image = image) !== null && _image !== void 0)) {
|
|
748
|
-
_context21.next = 8;
|
|
749
|
-
break;
|
|
750
|
-
}
|
|
751
|
-
_image;
|
|
752
|
-
_context21.next = 16;
|
|
753
|
-
break;
|
|
754
|
-
case 8:
|
|
755
|
-
if (!((_this$image2 = this.image) !== null && _this$image2 !== void 0)) {
|
|
756
|
-
_context21.next = 12;
|
|
757
|
-
break;
|
|
758
|
-
}
|
|
759
|
-
_context21.t0 = _this$image2;
|
|
760
|
-
_context21.next = 15;
|
|
761
|
-
break;
|
|
762
|
-
case 12:
|
|
763
|
-
_context21.next = 14;
|
|
764
|
-
return this.getImage();
|
|
765
|
-
case 14:
|
|
766
|
-
_context21.t0 = _context21.sent;
|
|
767
|
-
case 15:
|
|
768
|
-
image = _context21.t0;
|
|
769
|
-
case 16:
|
|
770
|
-
_context21.next = 18;
|
|
771
|
-
return this.post({
|
|
772
|
-
device: "process@1.0",
|
|
773
|
-
path: "/schedule",
|
|
774
|
-
scheduler: this.scheduler,
|
|
775
|
-
"data-protocol": "ao",
|
|
776
|
-
variant: "ao.N.1",
|
|
777
|
-
"scheduler-location": this.scheduler,
|
|
778
|
-
authority: this.scheduler,
|
|
779
|
-
"random-seed": seed(16),
|
|
780
|
-
type: "Process",
|
|
781
|
-
image: image,
|
|
782
|
-
"execution-device": "stack@1.0",
|
|
783
|
-
"push-device": "push@1.0",
|
|
784
|
-
"device-stack": ["wasi@1.0", "json-iface@1.0", "wasm-64@1.0", "patch@1.0", "multipass@1.0"],
|
|
785
|
-
"output-prefix": "wasm",
|
|
786
|
-
"patch-from": "/results/outbox",
|
|
787
|
-
"patch-mode": "patches",
|
|
788
|
-
"stack-keys": ["init", "compute", "snapshot", "normalize"],
|
|
789
|
-
passes: 2
|
|
790
|
-
});
|
|
791
|
-
case 18:
|
|
792
|
-
res = _context21.sent;
|
|
793
|
-
pid = res.headers.process;
|
|
794
|
-
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
795
|
-
return _context21.abrupt("return", {
|
|
796
|
-
pid: pid,
|
|
797
|
-
res: res
|
|
798
|
-
});
|
|
799
|
-
case 22:
|
|
800
|
-
case "end":
|
|
801
|
-
return _context21.stop();
|
|
802
|
-
}
|
|
803
|
-
}, _callee21, this);
|
|
804
|
-
}));
|
|
805
|
-
function spawnAOS(_x15) {
|
|
806
|
-
return _spawnAOS.apply(this, arguments);
|
|
807
|
-
}
|
|
808
|
-
return spawnAOS;
|
|
809
|
-
}()
|
|
810
|
-
}, {
|
|
811
|
-
key: "spawnLua",
|
|
812
|
-
value: function () {
|
|
813
|
-
var _spawnLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(lua) {
|
|
814
|
-
var _this$scheduler3, _lua, _this$lua2, _this$pid2;
|
|
815
|
-
var addr, res, pid;
|
|
816
|
-
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
817
|
-
while (1) switch (_context22.prev = _context22.next) {
|
|
818
|
-
case 0:
|
|
819
|
-
_context22.next = 2;
|
|
820
|
-
return this.g("/~meta@1.0/info/address");
|
|
821
|
-
case 2:
|
|
822
|
-
addr = _context22.sent;
|
|
823
|
-
(_this$scheduler3 = this.scheduler) !== null && _this$scheduler3 !== void 0 ? _this$scheduler3 : this.scheduler = addr;
|
|
824
|
-
if (!((_lua = lua) !== null && _lua !== void 0)) {
|
|
825
|
-
_context22.next = 8;
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
_lua;
|
|
829
|
-
_context22.next = 16;
|
|
830
|
-
break;
|
|
831
|
-
case 8:
|
|
832
|
-
if (!((_this$lua2 = this.lua) !== null && _this$lua2 !== void 0)) {
|
|
833
|
-
_context22.next = 12;
|
|
834
|
-
break;
|
|
835
|
-
}
|
|
836
|
-
_context22.t0 = _this$lua2;
|
|
837
|
-
_context22.next = 15;
|
|
838
|
-
break;
|
|
839
|
-
case 12:
|
|
840
|
-
_context22.next = 14;
|
|
841
|
-
return this.getLua();
|
|
842
|
-
case 14:
|
|
843
|
-
_context22.t0 = _context22.sent;
|
|
844
|
-
case 15:
|
|
845
|
-
lua = _context22.t0;
|
|
846
|
-
case 16:
|
|
847
|
-
_context22.next = 18;
|
|
848
|
-
return this.post({
|
|
849
|
-
device: "process@1.0",
|
|
850
|
-
path: "/schedule",
|
|
851
|
-
scheduler: this.scheduler,
|
|
852
|
-
"data-protocol": "ao",
|
|
853
|
-
variant: "ao.N.1",
|
|
854
|
-
"scheduler-location": this.scheduler,
|
|
855
|
-
authority: this.scheduler,
|
|
856
|
-
"random-seed": seed(16),
|
|
857
|
-
type: "Process",
|
|
858
|
-
module: lua,
|
|
859
|
-
"execution-device": "lua@5.3a",
|
|
860
|
-
"push-device": "push@1.0",
|
|
861
|
-
"patch-from": "/results/outbox"
|
|
862
|
-
});
|
|
863
|
-
case 18:
|
|
864
|
-
res = _context22.sent;
|
|
865
|
-
pid = res.headers.process;
|
|
866
|
-
(_this$pid2 = this.pid) !== null && _this$pid2 !== void 0 ? _this$pid2 : this.pid = pid;
|
|
867
|
-
return _context22.abrupt("return", {
|
|
868
|
-
pid: pid,
|
|
869
|
-
res: res
|
|
870
|
-
});
|
|
871
|
-
case 22:
|
|
872
|
-
case "end":
|
|
873
|
-
return _context22.stop();
|
|
874
|
-
}
|
|
875
|
-
}, _callee22, this);
|
|
876
|
-
}));
|
|
877
|
-
function spawnLua(_x16) {
|
|
878
|
-
return _spawnLua.apply(this, arguments);
|
|
879
|
-
}
|
|
880
|
-
return spawnLua;
|
|
881
|
-
}()
|
|
882
|
-
}, {
|
|
883
|
-
key: "now",
|
|
884
|
-
value: function () {
|
|
885
|
-
var _now = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref9) {
|
|
886
|
-
var pid, _ref9$path, path;
|
|
887
|
-
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
888
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
889
|
-
case 0:
|
|
890
|
-
pid = _ref9.pid, _ref9$path = _ref9.path, path = _ref9$path === void 0 ? "" : _ref9$path;
|
|
891
|
-
if (path && !/^\//.test(path)) path = "/" + path;
|
|
892
|
-
_context23.next = 4;
|
|
893
|
-
return this.getJSON({
|
|
894
|
-
path: "/".concat(pid, "/now").concat(path)
|
|
895
|
-
});
|
|
896
|
-
case 4:
|
|
897
|
-
return _context23.abrupt("return", _context23.sent);
|
|
898
|
-
case 5:
|
|
899
|
-
case "end":
|
|
900
|
-
return _context23.stop();
|
|
901
|
-
}
|
|
902
|
-
}, _callee23, this);
|
|
903
|
-
}));
|
|
904
|
-
function now(_x17) {
|
|
905
|
-
return _now.apply(this, arguments);
|
|
906
|
-
}
|
|
907
|
-
return now;
|
|
908
|
-
}()
|
|
909
|
-
}, {
|
|
910
|
-
key: "slot",
|
|
911
|
-
value: function () {
|
|
912
|
-
var _slot = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref10) {
|
|
913
|
-
var pid, _ref10$path, path;
|
|
914
|
-
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
915
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
916
|
-
case 0:
|
|
917
|
-
pid = _ref10.pid, _ref10$path = _ref10.path, path = _ref10$path === void 0 ? "" : _ref10$path;
|
|
918
|
-
if (path && !/^\//.test(path)) path = "/" + path;
|
|
919
|
-
_context24.next = 4;
|
|
920
|
-
return this.getJSON({
|
|
921
|
-
path: "/".concat(pid, "/slot").concat(path)
|
|
922
|
-
});
|
|
923
|
-
case 4:
|
|
924
|
-
return _context24.abrupt("return", _context24.sent);
|
|
925
|
-
case 5:
|
|
926
|
-
case "end":
|
|
927
|
-
return _context24.stop();
|
|
928
|
-
}
|
|
929
|
-
}, _callee24, this);
|
|
930
|
-
}));
|
|
931
|
-
function slot(_x18) {
|
|
932
|
-
return _slot.apply(this, arguments);
|
|
933
|
-
}
|
|
934
|
-
return slot;
|
|
935
|
-
}()
|
|
936
|
-
}, {
|
|
937
|
-
key: "messages",
|
|
938
|
-
value: function () {
|
|
939
|
-
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
940
|
-
var _this = this;
|
|
941
|
-
var _ref11,
|
|
942
|
-
pid,
|
|
943
|
-
from,
|
|
944
|
-
to,
|
|
945
|
-
params,
|
|
946
|
-
res,
|
|
947
|
-
_args27 = arguments;
|
|
948
|
-
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
949
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
950
|
-
case 0:
|
|
951
|
-
_ref11 = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {}, pid = _ref11.pid, from = _ref11.from, to = _ref11.to;
|
|
952
|
-
params = "target=".concat(pid);
|
|
953
|
-
if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
|
|
954
|
-
if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
|
|
955
|
-
params += "&accept=application/aos-2";
|
|
956
|
-
_context26.next = 7;
|
|
957
|
-
return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
|
|
958
|
-
return r.json();
|
|
959
|
-
});
|
|
960
|
-
case 7:
|
|
961
|
-
res = _context26.sent;
|
|
962
|
-
if (res.page_info.has_next_page) {
|
|
963
|
-
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
964
|
-
var from2;
|
|
965
|
-
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
966
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
967
|
-
case 0:
|
|
968
|
-
from2 = (0, _ramda.last)(res.edges).cursor + 1;
|
|
969
|
-
_context25.next = 3;
|
|
970
|
-
return _this.messages({
|
|
971
|
-
pid: pid,
|
|
972
|
-
from: from2,
|
|
973
|
-
to: to
|
|
974
|
-
});
|
|
975
|
-
case 3:
|
|
976
|
-
return _context25.abrupt("return", _context25.sent);
|
|
977
|
-
case 4:
|
|
978
|
-
case "end":
|
|
979
|
-
return _context25.stop();
|
|
980
|
-
}
|
|
981
|
-
}, _callee25);
|
|
982
|
-
}));
|
|
983
|
-
}
|
|
984
|
-
return _context26.abrupt("return", res);
|
|
985
|
-
case 10:
|
|
986
|
-
case "end":
|
|
987
|
-
return _context26.stop();
|
|
988
|
-
}
|
|
989
|
-
}, _callee26, this);
|
|
990
|
-
}));
|
|
991
|
-
function messages() {
|
|
992
|
-
return _messages.apply(this, arguments);
|
|
993
|
-
}
|
|
994
|
-
return messages;
|
|
995
|
-
}()
|
|
996
|
-
}, {
|
|
997
|
-
key: "spawnLegacy",
|
|
998
|
-
value: function () {
|
|
999
|
-
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1000
|
-
var _ref13,
|
|
1001
|
-
module,
|
|
1002
|
-
_ref13$tags,
|
|
1003
|
-
tags,
|
|
1004
|
-
data,
|
|
1005
|
-
t,
|
|
1006
|
-
_args28 = arguments;
|
|
1007
|
-
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1008
|
-
while (1) switch (_context27.prev = _context27.next) {
|
|
1009
|
-
case 0:
|
|
1010
|
-
_ref13 = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {}, module = _ref13.module, _ref13$tags = _ref13.tags, tags = _ref13$tags === void 0 ? {} : _ref13$tags, data = _ref13.data;
|
|
1011
|
-
_context27.next = 3;
|
|
1012
|
-
return this.setInfo();
|
|
1013
|
-
case 3:
|
|
1014
|
-
t = {
|
|
1015
|
-
type: "Process",
|
|
1016
|
-
"data-protocol": "ao",
|
|
1017
|
-
variant: "ao.TN.1",
|
|
1018
|
-
scheduler: this._info.address,
|
|
1019
|
-
authority: this._info.address,
|
|
1020
|
-
"scheduler-location": this._info.address,
|
|
1021
|
-
"random-seed": seed(16),
|
|
1022
|
-
module: module !== null && module !== void 0 ? module : "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
|
|
1023
|
-
device: "process@1.0",
|
|
1024
|
-
"scheduler-device": "scheduler@1.0",
|
|
1025
|
-
"execution-device": "stack@1.0",
|
|
1026
|
-
"push-device": "push@1.0",
|
|
1027
|
-
"device-stack": ["genesis-wasm@1.0", "patch@1.0"],
|
|
1028
|
-
"patch-from": "/results/outbox",
|
|
1029
|
-
"stack-keys": ["init", "compute", "snapshot", "normalize"]
|
|
1030
|
-
};
|
|
1031
|
-
if (data) t.data = data;
|
|
1032
|
-
tags = (0, _ramda.mergeLeft)(tags, t);
|
|
1033
|
-
_context27.next = 8;
|
|
1034
|
-
return this.spawn(tags);
|
|
1035
|
-
case 8:
|
|
1036
|
-
return _context27.abrupt("return", _context27.sent);
|
|
1037
|
-
case 9:
|
|
1038
|
-
case "end":
|
|
1039
|
-
return _context27.stop();
|
|
1040
|
-
}
|
|
1041
|
-
}, _callee27, this);
|
|
1042
|
-
}));
|
|
1043
|
-
function spawnLegacy() {
|
|
1044
|
-
return _spawnLegacy.apply(this, arguments);
|
|
1045
|
-
}
|
|
1046
|
-
return spawnLegacy;
|
|
1047
|
-
}()
|
|
1048
|
-
}, {
|
|
1049
|
-
key: "results",
|
|
1050
|
-
value: function () {
|
|
1051
|
-
var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1052
|
-
var _ref14,
|
|
1053
|
-
process,
|
|
1054
|
-
limit,
|
|
1055
|
-
_ref14$sort,
|
|
1056
|
-
sort,
|
|
1057
|
-
from,
|
|
1058
|
-
to,
|
|
1059
|
-
params,
|
|
1060
|
-
addParam,
|
|
1061
|
-
res,
|
|
1062
|
-
_args29 = arguments;
|
|
1063
|
-
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1064
|
-
while (1) switch (_context28.prev = _context28.next) {
|
|
1065
|
-
case 0:
|
|
1066
|
-
_ref14 = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {}, process = _ref14.process, limit = _ref14.limit, _ref14$sort = _ref14.sort, sort = _ref14$sort === void 0 ? "DESC" : _ref14$sort, from = _ref14.from, to = _ref14.to;
|
|
1067
|
-
params = "";
|
|
1068
|
-
addParam = function addParam(key, val) {
|
|
1069
|
-
params += params === "" ? "?" : "&";
|
|
1070
|
-
params += "".concat(key, "=").concat(val);
|
|
1071
|
-
};
|
|
1072
|
-
if (limit) addParam("limit", limit);
|
|
1073
|
-
if (sort) addParam("sort", sort);
|
|
1074
|
-
if (from) addParam("from", from);
|
|
1075
|
-
if (to) addParam("to", to);
|
|
1076
|
-
_context28.next = 9;
|
|
1077
|
-
return this.post({
|
|
1078
|
-
path: "/~relay@1.0/call",
|
|
1079
|
-
method: "GET",
|
|
1080
|
-
"relay-path": "".concat(this.cu, "/results/").concat(process).concat(params),
|
|
1081
|
-
"content-type": "application/json"
|
|
1082
|
-
});
|
|
1083
|
-
case 9:
|
|
1084
|
-
res = _context28.sent;
|
|
1085
|
-
return _context28.abrupt("return", JSON.parse(res.body));
|
|
1086
|
-
case 11:
|
|
1087
|
-
case "end":
|
|
1088
|
-
return _context28.stop();
|
|
1089
|
-
}
|
|
1090
|
-
}, _callee28, this);
|
|
1091
|
-
}));
|
|
1092
|
-
function results() {
|
|
1093
|
-
return _results.apply(this, arguments);
|
|
1094
|
-
}
|
|
1095
|
-
return results;
|
|
1096
|
-
}()
|
|
1097
|
-
}, {
|
|
1098
|
-
key: "dryrun",
|
|
1099
|
-
value: function () {
|
|
1100
|
-
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1101
|
-
var _ref15,
|
|
1102
|
-
_ref15$tags,
|
|
1103
|
-
tags,
|
|
1104
|
-
pid,
|
|
1105
|
-
action,
|
|
1106
|
-
data,
|
|
1107
|
-
json,
|
|
1108
|
-
res,
|
|
1109
|
-
_args30 = arguments;
|
|
1110
|
-
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1111
|
-
while (1) switch (_context29.prev = _context29.next) {
|
|
1112
|
-
case 0:
|
|
1113
|
-
_ref15 = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {}, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, pid = _ref15.pid, action = _ref15.action, data = _ref15.data;
|
|
1114
|
-
if (typeof action === "string") tags.Action = action;
|
|
1115
|
-
json = {
|
|
1116
|
-
Tags: (0, _utils.buildTags)(_objectSpread({}, tags)),
|
|
1117
|
-
Owner: this.addr
|
|
1118
|
-
};
|
|
1119
|
-
if (data) json.Data = data;
|
|
1120
|
-
_context29.next = 6;
|
|
1121
|
-
return this.post({
|
|
1122
|
-
path: "/~relay@1.0/call",
|
|
1123
|
-
method: "POST",
|
|
1124
|
-
"relay-path": "".concat(this.cu, "/dry-run?process-id=").concat(pid),
|
|
1125
|
-
"content-type": "application/json",
|
|
1126
|
-
"relay-body": JSON.stringify(json)
|
|
1127
|
-
});
|
|
1128
|
-
case 6:
|
|
1129
|
-
res = _context29.sent;
|
|
1130
|
-
return _context29.abrupt("return", JSON.parse(res.body));
|
|
1131
|
-
case 8:
|
|
1132
|
-
case "end":
|
|
1133
|
-
return _context29.stop();
|
|
1134
|
-
}
|
|
1135
|
-
}, _callee29, this);
|
|
1136
|
-
}));
|
|
1137
|
-
function dryrun() {
|
|
1138
|
-
return _dryrun.apply(this, arguments);
|
|
1139
|
-
}
|
|
1140
|
-
return dryrun;
|
|
1141
|
-
}()
|
|
1142
|
-
}, {
|
|
1143
|
-
key: "commit",
|
|
1144
|
-
value: function () {
|
|
1145
|
-
var _commit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(obj, opts) {
|
|
1146
|
-
var msg, hmacId, rsaId, committer, meta, meta2, sigs;
|
|
1147
|
-
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
1148
|
-
while (1) switch (_context30.prev = _context30.next) {
|
|
1149
|
-
case 0:
|
|
1150
|
-
_context30.next = 2;
|
|
1151
|
-
return this.sign(obj, opts);
|
|
1152
|
-
case 2:
|
|
1153
|
-
msg = _context30.sent;
|
|
1154
|
-
hmacId = (0, _utils.hmacid)(msg.headers);
|
|
1155
|
-
rsaId = (0, _utils.rsaid)(msg.headers);
|
|
1156
|
-
committer = this.addr;
|
|
1157
|
-
meta = {
|
|
1158
|
-
alg: "rsa-pss-sha512",
|
|
1159
|
-
"commitment-device": "httpsig@1.0"
|
|
1160
|
-
};
|
|
1161
|
-
meta2 = {
|
|
1162
|
-
alg: "hmac-sha256",
|
|
1163
|
-
"commitment-device": "httpsig@1.0"
|
|
1164
|
-
};
|
|
1165
|
-
sigs = {
|
|
1166
|
-
signature: msg.headers.signature,
|
|
1167
|
-
"signature-input": msg.headers["signature-input"]
|
|
1168
|
-
};
|
|
1169
|
-
return _context30.abrupt("return", _objectSpread({
|
|
1170
|
-
commitments: _defineProperty(_defineProperty({}, rsaId, _objectSpread(_objectSpread({}, meta), {}, {
|
|
1171
|
-
committer: committer
|
|
1172
|
-
}, sigs)), hmacId, _objectSpread(_objectSpread({}, meta2), sigs))
|
|
1173
|
-
}, obj));
|
|
1174
|
-
case 10:
|
|
1175
|
-
case "end":
|
|
1176
|
-
return _context30.stop();
|
|
1177
|
-
}
|
|
1178
|
-
}, _callee30, this);
|
|
1179
|
-
}));
|
|
1180
|
-
function commit(_x19, _x20) {
|
|
1181
|
-
return _commit.apply(this, arguments);
|
|
1182
|
-
}
|
|
1183
|
-
return commit;
|
|
1184
|
-
}()
|
|
1185
|
-
}, {
|
|
1186
|
-
key: "p",
|
|
1187
|
-
value: function () {
|
|
1188
|
-
var _p = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(path) {
|
|
1189
|
-
var _, _args$_, _args$, _args$$path, _yield$this$post$out, _yield$this$post;
|
|
1190
|
-
var _len,
|
|
1191
|
-
args,
|
|
1192
|
-
_key,
|
|
1193
|
-
_args,
|
|
1194
|
-
_args32 = arguments;
|
|
1195
|
-
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
1196
|
-
while (1) switch (_context31.prev = _context31.next) {
|
|
1197
|
-
case 0:
|
|
1198
|
-
for (_len = _args32.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1199
|
-
args[_key - 1] = _args32[_key];
|
|
1200
|
-
}
|
|
1201
|
-
_args = (0, _ramda.clone)(args);
|
|
1202
|
-
(_args$_ = _args[_ = 0]) !== null && _args$_ !== void 0 ? _args$_ : _args[_] = {};
|
|
1203
|
-
(_args$$path = (_args$ = _args[0]).path) !== null && _args$$path !== void 0 ? _args$$path : _args$.path = path;
|
|
1204
|
-
_context31.next = 6;
|
|
1205
|
-
return this.post.apply(this, _toConsumableArray(_args));
|
|
1206
|
-
case 6:
|
|
1207
|
-
_context31.t2 = _yield$this$post = _context31.sent;
|
|
1208
|
-
_context31.t1 = _context31.t2 === null;
|
|
1209
|
-
if (_context31.t1) {
|
|
1210
|
-
_context31.next = 10;
|
|
1211
|
-
break;
|
|
1212
|
-
}
|
|
1213
|
-
_context31.t1 = _yield$this$post === void 0;
|
|
1214
|
-
case 10:
|
|
1215
|
-
if (!_context31.t1) {
|
|
1216
|
-
_context31.next = 14;
|
|
1217
|
-
break;
|
|
1218
|
-
}
|
|
1219
|
-
_context31.t3 = void 0;
|
|
1220
|
-
_context31.next = 15;
|
|
1221
|
-
break;
|
|
1222
|
-
case 14:
|
|
1223
|
-
_context31.t3 = _yield$this$post.out;
|
|
1224
|
-
case 15:
|
|
1225
|
-
_context31.t4 = _yield$this$post$out = _context31.t3;
|
|
1226
|
-
_context31.t0 = _context31.t4 !== null;
|
|
1227
|
-
if (!_context31.t0) {
|
|
1228
|
-
_context31.next = 19;
|
|
1229
|
-
break;
|
|
1230
|
-
}
|
|
1231
|
-
_context31.t0 = _yield$this$post$out !== void 0;
|
|
1232
|
-
case 19:
|
|
1233
|
-
if (!_context31.t0) {
|
|
1234
|
-
_context31.next = 23;
|
|
1235
|
-
break;
|
|
1236
|
-
}
|
|
1237
|
-
_context31.t5 = _yield$this$post$out;
|
|
1238
|
-
_context31.next = 24;
|
|
1239
|
-
break;
|
|
1240
|
-
case 23:
|
|
1241
|
-
_context31.t5 = null;
|
|
1242
|
-
case 24:
|
|
1243
|
-
return _context31.abrupt("return", _context31.t5);
|
|
1244
|
-
case 25:
|
|
1245
|
-
case "end":
|
|
1246
|
-
return _context31.stop();
|
|
1247
|
-
}
|
|
1248
|
-
}, _callee31, this);
|
|
1249
|
-
}));
|
|
1250
|
-
function p(_x21) {
|
|
1251
|
-
return _p.apply(this, arguments);
|
|
1252
|
-
}
|
|
1253
|
-
return p;
|
|
1254
|
-
}()
|
|
1255
|
-
}, {
|
|
1256
|
-
key: "post",
|
|
1257
|
-
value: function () {
|
|
1258
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(obj, json) {
|
|
1259
|
-
var _json;
|
|
1260
|
-
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
1261
|
-
while (1) switch (_context32.prev = _context32.next) {
|
|
1262
|
-
case 0:
|
|
1263
|
-
_json = json ? "/~json@1.0/serialize" : "";
|
|
1264
|
-
obj.path += _json;
|
|
1265
|
-
_context32.t0 = this;
|
|
1266
|
-
_context32.next = 5;
|
|
1267
|
-
return this.sign(obj);
|
|
1268
|
-
case 5:
|
|
1269
|
-
_context32.t1 = _context32.sent;
|
|
1270
|
-
_context32.next = 8;
|
|
1271
|
-
return _context32.t0.send.call(_context32.t0, _context32.t1);
|
|
1272
|
-
case 8:
|
|
1273
|
-
return _context32.abrupt("return", _context32.sent);
|
|
1274
|
-
case 9:
|
|
1275
|
-
case "end":
|
|
1276
|
-
return _context32.stop();
|
|
1277
|
-
}
|
|
1278
|
-
}, _callee32, this);
|
|
1279
|
-
}));
|
|
1280
|
-
function post(_x22, _x23) {
|
|
1281
|
-
return _post.apply(this, arguments);
|
|
1282
|
-
}
|
|
1283
|
-
return post;
|
|
1284
|
-
}()
|
|
1285
|
-
}, {
|
|
1286
|
-
key: "g",
|
|
1287
|
-
value: function () {
|
|
1288
|
-
var _g = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(path) {
|
|
1289
|
-
var _2, _args$_2, _args$2, _args$2$path, _yield$this$get$out, _yield$this$get;
|
|
1290
|
-
var _len2,
|
|
1291
|
-
args,
|
|
1292
|
-
_key2,
|
|
1293
|
-
_args,
|
|
1294
|
-
_args34 = arguments;
|
|
1295
|
-
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
1296
|
-
while (1) switch (_context33.prev = _context33.next) {
|
|
1297
|
-
case 0:
|
|
1298
|
-
for (_len2 = _args34.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1299
|
-
args[_key2 - 1] = _args34[_key2];
|
|
1300
|
-
}
|
|
1301
|
-
_args = (0, _ramda.clone)(args);
|
|
1302
|
-
(_args$_2 = _args[_2 = 0]) !== null && _args$_2 !== void 0 ? _args$_2 : _args[_2] = {};
|
|
1303
|
-
(_args$2$path = (_args$2 = _args[0]).path) !== null && _args$2$path !== void 0 ? _args$2$path : _args$2.path = path;
|
|
1304
|
-
_context33.next = 6;
|
|
1305
|
-
return this.get.apply(this, _toConsumableArray(_args));
|
|
1306
|
-
case 6:
|
|
1307
|
-
_context33.t2 = _yield$this$get = _context33.sent;
|
|
1308
|
-
_context33.t1 = _context33.t2 === null;
|
|
1309
|
-
if (_context33.t1) {
|
|
1310
|
-
_context33.next = 10;
|
|
1311
|
-
break;
|
|
1312
|
-
}
|
|
1313
|
-
_context33.t1 = _yield$this$get === void 0;
|
|
1314
|
-
case 10:
|
|
1315
|
-
if (!_context33.t1) {
|
|
1316
|
-
_context33.next = 14;
|
|
1317
|
-
break;
|
|
1318
|
-
}
|
|
1319
|
-
_context33.t3 = void 0;
|
|
1320
|
-
_context33.next = 15;
|
|
1321
|
-
break;
|
|
1322
|
-
case 14:
|
|
1323
|
-
_context33.t3 = _yield$this$get.out;
|
|
1324
|
-
case 15:
|
|
1325
|
-
_context33.t4 = _yield$this$get$out = _context33.t3;
|
|
1326
|
-
_context33.t0 = _context33.t4 !== null;
|
|
1327
|
-
if (!_context33.t0) {
|
|
1328
|
-
_context33.next = 19;
|
|
1329
|
-
break;
|
|
1330
|
-
}
|
|
1331
|
-
_context33.t0 = _yield$this$get$out !== void 0;
|
|
1332
|
-
case 19:
|
|
1333
|
-
if (!_context33.t0) {
|
|
1334
|
-
_context33.next = 23;
|
|
1335
|
-
break;
|
|
1336
|
-
}
|
|
1337
|
-
_context33.t5 = _yield$this$get$out;
|
|
1338
|
-
_context33.next = 24;
|
|
1339
|
-
break;
|
|
1340
|
-
case 23:
|
|
1341
|
-
_context33.t5 = null;
|
|
1342
|
-
case 24:
|
|
1343
|
-
return _context33.abrupt("return", _context33.t5);
|
|
1344
|
-
case 25:
|
|
1345
|
-
case "end":
|
|
1346
|
-
return _context33.stop();
|
|
1347
|
-
}
|
|
1348
|
-
}, _callee33, this);
|
|
1349
|
-
}));
|
|
1350
|
-
function g(_x24) {
|
|
1351
|
-
return _g.apply(this, arguments);
|
|
1352
|
-
}
|
|
1353
|
-
return g;
|
|
1354
|
-
}()
|
|
1355
|
-
}, {
|
|
1356
|
-
key: "get",
|
|
1357
|
-
value: function () {
|
|
1358
|
-
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(_ref16) {
|
|
1359
|
-
var _path;
|
|
1360
|
-
var path,
|
|
1361
|
-
params,
|
|
1362
|
-
json,
|
|
1363
|
-
_json,
|
|
1364
|
-
_params,
|
|
1365
|
-
i,
|
|
1366
|
-
k,
|
|
1367
|
-
response,
|
|
1368
|
-
headers,
|
|
1369
|
-
http,
|
|
1370
|
-
_args35 = arguments;
|
|
1371
|
-
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
1372
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
1373
|
-
case 0:
|
|
1374
|
-
path = _ref16.path, params = _objectWithoutProperties(_ref16, _excluded2);
|
|
1375
|
-
json = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : false;
|
|
1376
|
-
_json = json ? "/~json@1.0/serialize" : "";
|
|
1377
|
-
(_path = path) !== null && _path !== void 0 ? _path : path = "/~message@1.0";
|
|
1378
|
-
if (!/^\//.test(path)) path = "/" + path;
|
|
1379
|
-
_params = "";
|
|
1380
|
-
if (!(0, _ramda.isEmpty)(params)) {
|
|
1381
|
-
i = 0;
|
|
1382
|
-
for (k in params) {
|
|
1383
|
-
_params += "".concat(i === 0 ? "?" : "&").concat(k, "=").concat(params[k]);
|
|
1384
|
-
i++;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
_context34.next = 9;
|
|
1388
|
-
return fetch("".concat(this.url).concat(path).concat(_json).concat(_params));
|
|
1389
|
-
case 9:
|
|
1390
|
-
response = _context34.sent;
|
|
1391
|
-
headers = {};
|
|
1392
|
-
response.headers.forEach(function (v, k) {
|
|
1393
|
-
return headers[k] = v;
|
|
1394
|
-
});
|
|
1395
|
-
_context34.t0 = headers;
|
|
1396
|
-
_context34.next = 15;
|
|
1397
|
-
return response.text();
|
|
1398
|
-
case 15:
|
|
1399
|
-
_context34.t1 = _context34.sent;
|
|
1400
|
-
_context34.t2 = response.status;
|
|
1401
|
-
http = {
|
|
1402
|
-
headers: _context34.t0,
|
|
1403
|
-
body: _context34.t1,
|
|
1404
|
-
status: _context34.t2
|
|
1405
|
-
};
|
|
1406
|
-
return _context34.abrupt("return", _objectSpread(_objectSpread({}, (0, _httpsig.from)(http)), http));
|
|
1407
|
-
case 19:
|
|
1408
|
-
case "end":
|
|
1409
|
-
return _context34.stop();
|
|
1410
|
-
}
|
|
1411
|
-
}, _callee34, this);
|
|
1412
|
-
}));
|
|
1413
|
-
function get(_x25) {
|
|
1414
|
-
return _get.apply(this, arguments);
|
|
1415
|
-
}
|
|
1416
|
-
return get;
|
|
1417
|
-
}()
|
|
1418
|
-
}, {
|
|
1419
|
-
key: "postJSON",
|
|
1420
|
-
value: function () {
|
|
1421
|
-
var _postJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(args) {
|
|
1422
|
-
var res;
|
|
1423
|
-
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
1424
|
-
while (1) switch (_context35.prev = _context35.next) {
|
|
1425
|
-
case 0:
|
|
1426
|
-
_context35.next = 2;
|
|
1427
|
-
return this.post(args, true);
|
|
1428
|
-
case 2:
|
|
1429
|
-
res = _context35.sent;
|
|
1430
|
-
return _context35.abrupt("return", JSON.parse(res.body));
|
|
1431
|
-
case 4:
|
|
1432
|
-
case "end":
|
|
1433
|
-
return _context35.stop();
|
|
1434
|
-
}
|
|
1435
|
-
}, _callee35, this);
|
|
1436
|
-
}));
|
|
1437
|
-
function postJSON(_x26) {
|
|
1438
|
-
return _postJSON.apply(this, arguments);
|
|
1439
|
-
}
|
|
1440
|
-
return postJSON;
|
|
1441
|
-
}()
|
|
1442
|
-
}, {
|
|
1443
|
-
key: "getJSON",
|
|
1444
|
-
value: function () {
|
|
1445
|
-
var _getJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(args) {
|
|
1446
|
-
var res;
|
|
1447
|
-
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
1448
|
-
while (1) switch (_context36.prev = _context36.next) {
|
|
1449
|
-
case 0:
|
|
1450
|
-
_context36.next = 2;
|
|
1451
|
-
return this.get(args, true);
|
|
1452
|
-
case 2:
|
|
1453
|
-
res = _context36.sent;
|
|
1454
|
-
return _context36.abrupt("return", JSON.parse(res.body));
|
|
1455
|
-
case 4:
|
|
1456
|
-
case "end":
|
|
1457
|
-
return _context36.stop();
|
|
1458
|
-
}
|
|
1459
|
-
}, _callee36, this);
|
|
1460
|
-
}));
|
|
1461
|
-
function getJSON(_x27) {
|
|
1462
|
-
return _getJSON.apply(this, arguments);
|
|
1463
|
-
}
|
|
1464
|
-
return getJSON;
|
|
1465
|
-
}()
|
|
1466
|
-
}]);
|
|
1467
|
-
}();
|
|
1468
|
-
var _default = exports["default"] = HB;
|