wao 0.14.4 → 0.14.6

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/ao.js CHANGED
@@ -1545,6 +1545,124 @@ var AO = /*#__PURE__*/function () {
1545
1545
  }
1546
1546
  return deploy;
1547
1547
  }()
1548
+ }, {
1549
+ key: "var",
1550
+ value: function () {
1551
+ var _var2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref26) {
1552
+ var pid, data, _ref26$json, json, _ref26$pretty, pretty, _yield$this$dry2, _var3, _yield$this$dry3, _var4;
1553
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1554
+ while (1) switch (_context22.prev = _context22.next) {
1555
+ case 0:
1556
+ pid = _ref26.pid, data = _ref26.data, _ref26$json = _ref26.json, json = _ref26$json === void 0 ? true : _ref26$json, _ref26$pretty = _ref26.pretty, pretty = _ref26$pretty === void 0 ? false : _ref26$pretty;
1557
+ if (!json) {
1558
+ _context22.next = 31;
1559
+ break;
1560
+ }
1561
+ _context22.next = 4;
1562
+ return this.dry({
1563
+ act: "Eval",
1564
+ data: "require(\"json\").encode(".concat(data, ")"),
1565
+ pid: pid
1566
+ });
1567
+ case 4:
1568
+ _context22.t3 = _yield$this$dry2 = _context22.sent;
1569
+ _context22.t2 = _context22.t3 === null;
1570
+ if (_context22.t2) {
1571
+ _context22.next = 8;
1572
+ break;
1573
+ }
1574
+ _context22.t2 = _yield$this$dry2 === void 0;
1575
+ case 8:
1576
+ _context22.t1 = _context22.t2;
1577
+ if (_context22.t1) {
1578
+ _context22.next = 11;
1579
+ break;
1580
+ }
1581
+ _context22.t1 = (_yield$this$dry2 = _yield$this$dry2.res) === null || _yield$this$dry2 === void 0;
1582
+ case 11:
1583
+ _context22.t0 = _context22.t1;
1584
+ if (_context22.t0) {
1585
+ _context22.next = 14;
1586
+ break;
1587
+ }
1588
+ _context22.t0 = (_yield$this$dry2 = _yield$this$dry2.Output) === null || _yield$this$dry2 === void 0;
1589
+ case 14:
1590
+ if (!_context22.t0) {
1591
+ _context22.next = 18;
1592
+ break;
1593
+ }
1594
+ _context22.t4 = void 0;
1595
+ _context22.next = 19;
1596
+ break;
1597
+ case 18:
1598
+ _context22.t4 = _yield$this$dry2.data;
1599
+ case 19:
1600
+ _var3 = _context22.t4;
1601
+ if (!_var3) {
1602
+ _context22.next = 28;
1603
+ break;
1604
+ }
1605
+ _context22.prev = 21;
1606
+ return _context22.abrupt("return", JSON.parse(strip(_var3)));
1607
+ case 25:
1608
+ _context22.prev = 25;
1609
+ _context22.t5 = _context22["catch"](21);
1610
+ return _context22.abrupt("return", strip(_var3));
1611
+ case 28:
1612
+ return _context22.abrupt("return", _var3);
1613
+ case 31:
1614
+ _context22.next = 33;
1615
+ return this.dry({
1616
+ act: "Eval",
1617
+ data: data,
1618
+ pid: pid
1619
+ });
1620
+ case 33:
1621
+ _context22.t9 = _yield$this$dry3 = _context22.sent;
1622
+ _context22.t8 = _context22.t9 === null;
1623
+ if (_context22.t8) {
1624
+ _context22.next = 37;
1625
+ break;
1626
+ }
1627
+ _context22.t8 = _yield$this$dry3 === void 0;
1628
+ case 37:
1629
+ _context22.t7 = _context22.t8;
1630
+ if (_context22.t7) {
1631
+ _context22.next = 40;
1632
+ break;
1633
+ }
1634
+ _context22.t7 = (_yield$this$dry3 = _yield$this$dry3.res) === null || _yield$this$dry3 === void 0;
1635
+ case 40:
1636
+ _context22.t6 = _context22.t7;
1637
+ if (_context22.t6) {
1638
+ _context22.next = 43;
1639
+ break;
1640
+ }
1641
+ _context22.t6 = (_yield$this$dry3 = _yield$this$dry3.Output) === null || _yield$this$dry3 === void 0;
1642
+ case 43:
1643
+ if (!_context22.t6) {
1644
+ _context22.next = 47;
1645
+ break;
1646
+ }
1647
+ _context22.t10 = void 0;
1648
+ _context22.next = 48;
1649
+ break;
1650
+ case 47:
1651
+ _context22.t10 = _yield$this$dry3.data;
1652
+ case 48:
1653
+ _var4 = _context22.t10;
1654
+ return _context22.abrupt("return", pretty ? _var4 : strip(_var4));
1655
+ case 50:
1656
+ case "end":
1657
+ return _context22.stop();
1658
+ }
1659
+ }, _callee22, this, [[21, 25]]);
1660
+ }));
1661
+ function _var(_x25) {
1662
+ return _var2.apply(this, arguments);
1663
+ }
1664
+ return _var;
1665
+ }()
1548
1666
  }, {
1549
1667
  key: "p",
1550
1668
  value: function p(pid) {
@@ -1552,6 +1670,9 @@ var AO = /*#__PURE__*/function () {
1552
1670
  }
1553
1671
  }]);
1554
1672
  }();
1673
+ function strip(str) {
1674
+ return str.replace(/\x1B\[[0-9;]*[JKmsu]/g, "");
1675
+ }
1555
1676
  var getParams = function getParams(tags, opts) {
1556
1677
  var _tags = tags;
1557
1678
  var _opts = opts;
@@ -1578,24 +1699,24 @@ var Process = /*#__PURE__*/function () {
1578
1699
  return _createClass(Process, [{
1579
1700
  key: "load",
1580
1701
  value: function () {
1581
- var _load2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1702
+ var _load2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1582
1703
  var opt,
1583
- _args22 = arguments;
1584
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1585
- while (1) switch (_context22.prev = _context22.next) {
1704
+ _args23 = arguments;
1705
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1706
+ while (1) switch (_context23.prev = _context23.next) {
1586
1707
  case 0:
1587
- opt = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
1588
- _context22.next = 3;
1708
+ opt = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
1709
+ _context23.next = 3;
1589
1710
  return this.ao.load(_objectSpread({
1590
1711
  pid: this.pid
1591
1712
  }, opt));
1592
1713
  case 3:
1593
- return _context22.abrupt("return", _context22.sent);
1714
+ return _context23.abrupt("return", _context23.sent);
1594
1715
  case 4:
1595
1716
  case "end":
1596
- return _context22.stop();
1717
+ return _context23.stop();
1597
1718
  }
1598
- }, _callee22, this);
1719
+ }, _callee23, this);
1599
1720
  }));
1600
1721
  function load() {
1601
1722
  return _load2.apply(this, arguments);
@@ -1605,27 +1726,27 @@ var Process = /*#__PURE__*/function () {
1605
1726
  }, {
1606
1727
  key: "msg",
1607
1728
  value: function () {
1608
- var _msg2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(act, tags, opts) {
1729
+ var _msg2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(act, tags, opts) {
1609
1730
  var _getParams, _tags, _opts;
1610
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1611
- while (1) switch (_context23.prev = _context23.next) {
1731
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1732
+ while (1) switch (_context24.prev = _context24.next) {
1612
1733
  case 0:
1613
1734
  _getParams = getParams(tags, opts), _tags = _getParams._tags, _opts = _getParams._opts;
1614
- _context23.next = 3;
1735
+ _context24.next = 3;
1615
1736
  return this.ao.msg(_objectSpread({
1616
1737
  pid: this.pid,
1617
1738
  act: act,
1618
1739
  tags: _tags
1619
1740
  }, _opts));
1620
1741
  case 3:
1621
- return _context23.abrupt("return", _context23.sent);
1742
+ return _context24.abrupt("return", _context24.sent);
1622
1743
  case 4:
1623
1744
  case "end":
1624
- return _context23.stop();
1745
+ return _context24.stop();
1625
1746
  }
1626
- }, _callee23, this);
1747
+ }, _callee24, this);
1627
1748
  }));
1628
- function msg(_x25, _x26, _x27) {
1749
+ function msg(_x26, _x27, _x28) {
1629
1750
  return _msg2.apply(this, arguments);
1630
1751
  }
1631
1752
  return msg;
@@ -1633,27 +1754,27 @@ var Process = /*#__PURE__*/function () {
1633
1754
  }, {
1634
1755
  key: "dry",
1635
1756
  value: function () {
1636
- var _dry2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(act, tags, opts) {
1757
+ var _dry2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(act, tags, opts) {
1637
1758
  var _getParams2, _tags, _opts;
1638
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1639
- while (1) switch (_context24.prev = _context24.next) {
1759
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1760
+ while (1) switch (_context25.prev = _context25.next) {
1640
1761
  case 0:
1641
1762
  _getParams2 = getParams(tags, opts), _tags = _getParams2._tags, _opts = _getParams2._opts;
1642
- _context24.next = 3;
1763
+ _context25.next = 3;
1643
1764
  return this.ao.dry(_objectSpread({
1644
1765
  pid: this.pid,
1645
1766
  act: act,
1646
1767
  tags: _tags
1647
1768
  }, _opts));
1648
1769
  case 3:
1649
- return _context24.abrupt("return", _context24.sent);
1770
+ return _context25.abrupt("return", _context25.sent);
1650
1771
  case 4:
1651
1772
  case "end":
1652
- return _context24.stop();
1773
+ return _context25.stop();
1653
1774
  }
1654
- }, _callee24, this);
1775
+ }, _callee25, this);
1655
1776
  }));
1656
- function dry(_x28, _x29, _x30) {
1777
+ function dry(_x29, _x30, _x31) {
1657
1778
  return _dry2.apply(this, arguments);
1658
1779
  }
1659
1780
  return dry;
@@ -1661,28 +1782,28 @@ var Process = /*#__PURE__*/function () {
1661
1782
  }, {
1662
1783
  key: "m",
1663
1784
  value: function () {
1664
- var _m = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1785
+ var _m = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1665
1786
  var res,
1666
- _args25 = arguments;
1667
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1668
- while (1) switch (_context25.prev = _context25.next) {
1787
+ _args26 = arguments;
1788
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1789
+ while (1) switch (_context26.prev = _context26.next) {
1669
1790
  case 0:
1670
- _context25.next = 2;
1671
- return this.msg.apply(this, _args25);
1791
+ _context26.next = 2;
1792
+ return this.msg.apply(this, _args26);
1672
1793
  case 2:
1673
- res = _context25.sent;
1794
+ res = _context26.sent;
1674
1795
  if (!res.err) {
1675
- _context25.next = 5;
1796
+ _context26.next = 5;
1676
1797
  break;
1677
1798
  }
1678
1799
  throw Error(res.err);
1679
1800
  case 5:
1680
- return _context25.abrupt("return", res.out);
1801
+ return _context26.abrupt("return", res.out);
1681
1802
  case 6:
1682
1803
  case "end":
1683
- return _context25.stop();
1804
+ return _context26.stop();
1684
1805
  }
1685
- }, _callee25, this);
1806
+ }, _callee26, this);
1686
1807
  }));
1687
1808
  function m() {
1688
1809
  return _m.apply(this, arguments);
@@ -1692,34 +1813,66 @@ var Process = /*#__PURE__*/function () {
1692
1813
  }, {
1693
1814
  key: "d",
1694
1815
  value: function () {
1695
- var _d = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1816
+ var _d = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1696
1817
  var res,
1697
- _args26 = arguments;
1698
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1699
- while (1) switch (_context26.prev = _context26.next) {
1818
+ _args27 = arguments;
1819
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1820
+ while (1) switch (_context27.prev = _context27.next) {
1700
1821
  case 0:
1701
- _context26.next = 2;
1702
- return this.dry.apply(this, _args26);
1822
+ _context27.next = 2;
1823
+ return this.dry.apply(this, _args27);
1703
1824
  case 2:
1704
- res = _context26.sent;
1825
+ res = _context27.sent;
1705
1826
  if (!res.err) {
1706
- _context26.next = 5;
1827
+ _context27.next = 5;
1707
1828
  break;
1708
1829
  }
1709
1830
  throw Error(res.err);
1710
1831
  case 5:
1711
- return _context26.abrupt("return", res.out);
1832
+ return _context27.abrupt("return", res.out);
1712
1833
  case 6:
1713
1834
  case "end":
1714
- return _context26.stop();
1835
+ return _context27.stop();
1715
1836
  }
1716
- }, _callee26, this);
1837
+ }, _callee27, this);
1717
1838
  }));
1718
1839
  function d() {
1719
1840
  return _d.apply(this, arguments);
1720
1841
  }
1721
1842
  return d;
1722
1843
  }()
1844
+ }, {
1845
+ key: "v",
1846
+ value: function () {
1847
+ var _v2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(data) {
1848
+ var json,
1849
+ pretty,
1850
+ _args28 = arguments;
1851
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1852
+ while (1) switch (_context28.prev = _context28.next) {
1853
+ case 0:
1854
+ json = _args28.length > 1 && _args28[1] !== undefined ? _args28[1] : true;
1855
+ pretty = _args28.length > 2 && _args28[2] !== undefined ? _args28[2] : false;
1856
+ _context28.next = 4;
1857
+ return this.ao["var"]({
1858
+ pid: this.pid,
1859
+ data: data,
1860
+ json: json,
1861
+ pretty: pretty
1862
+ });
1863
+ case 4:
1864
+ return _context28.abrupt("return", _context28.sent);
1865
+ case 5:
1866
+ case "end":
1867
+ return _context28.stop();
1868
+ }
1869
+ }, _callee28, this);
1870
+ }));
1871
+ function v(_x32) {
1872
+ return _v2.apply(this, arguments);
1873
+ }
1874
+ return v;
1875
+ }()
1723
1876
  }]);
1724
1877
  }();
1725
1878
  var _default = exports["default"] = AO;
package/cjs/server.js CHANGED
@@ -176,33 +176,28 @@ var Server = /*#__PURE__*/function () {
176
176
  return _regeneratorRuntime().wrap(function _callee$(_context) {
177
177
  while (1) switch (_context.prev = _context.next) {
178
178
  case 0:
179
- if (Buffer.isBuffer(req.body)) {
180
- _context.next = 3;
181
- break;
182
- }
183
- console.log("BD: Invalid body | expected raw Buffer");
184
- return _context.abrupt("return", res.status(400).send("Invalid body: expected raw Buffer"));
185
- case 3:
179
+ return _context.abrupt("return", res.status(200).send("Success"));
180
+ case 4:
186
181
  lines = req.body.toString("utf8").split(/\r?\n/);
187
182
  sigs = {};
188
183
  currentKey = null;
189
184
  _iterator = _createForOfIteratorHelper(lines);
190
- _context.prev = 7;
185
+ _context.prev = 8;
191
186
  _iterator.s();
192
- case 9:
187
+ case 10:
193
188
  if ((_step = _iterator.n()).done) {
194
- _context.next = 19;
189
+ _context.next = 20;
195
190
  break;
196
191
  }
197
192
  line = _step.value;
198
193
  trimmed = line.trim();
199
194
  if (!/^--[a-zA-Z0-9_\-=]+/.test(trimmed)) {
200
- _context.next = 15;
195
+ _context.next = 16;
201
196
  break;
202
197
  }
203
198
  currentKey = null;
204
- return _context.abrupt("continue", 17);
205
- case 15:
199
+ return _context.abrupt("continue", 18);
200
+ case 16:
206
201
  headerMatch = trimmed.match(/^([a-zA-Z0-9_-]+):\s*(.*)$/);
207
202
  if (headerMatch && !headerMatch[2].includes(": ")) {
208
203
  _key = headerMatch[1];
@@ -210,21 +205,21 @@ var Server = /*#__PURE__*/function () {
210
205
  sigs[_key] = value;
211
206
  currentKey = _key;
212
207
  } else if (currentKey) sigs[currentKey] += "\n" + line;
213
- case 17:
214
- _context.next = 9;
208
+ case 18:
209
+ _context.next = 10;
215
210
  break;
216
- case 19:
217
- _context.next = 24;
211
+ case 20:
212
+ _context.next = 25;
218
213
  break;
219
- case 21:
220
- _context.prev = 21;
221
- _context.t0 = _context["catch"](7);
214
+ case 22:
215
+ _context.prev = 22;
216
+ _context.t0 = _context["catch"](8);
222
217
  _iterator.e(_context.t0);
223
- case 24:
224
- _context.prev = 24;
218
+ case 25:
219
+ _context.prev = 25;
225
220
  _iterator.f();
226
- return _context.finish(24);
227
- case 27:
221
+ return _context.finish(25);
222
+ case 28:
228
223
  sigs.target = req.headers.process;
229
224
  sigs.slot = req.headers.slot;
230
225
  input = parseSignatureInput(req.headers["signature-input"]);
@@ -238,8 +233,8 @@ var Server = /*#__PURE__*/function () {
238
233
  format: "jwk"
239
234
  }), "rsa-pss-sha512");
240
235
  id = null;
241
- _context.prev = 33;
242
- _context.next = 36;
236
+ _context.prev = 34;
237
+ _context.next = 37;
243
238
  return verifyMessage({
244
239
  keyLookup: function keyLookup(params) {
245
240
  return {
@@ -251,11 +246,11 @@ var Server = /*#__PURE__*/function () {
251
246
  headers: req.headers,
252
247
  url: "http://ao.com".concat(req.headers.path)
253
248
  });
254
- case 36:
249
+ case 37:
255
250
  isValid = _context.sent;
256
251
  item = toANS104Request(sigs).item;
257
252
  if (!(sigs.slot === "0" || sigs.type === "Process")) {
258
- _context.next = 46;
253
+ _context.next = 47;
259
254
  break;
260
255
  }
261
256
  _iterator2 = _createForOfIteratorHelper(item.tags);
@@ -269,19 +264,19 @@ var Server = /*#__PURE__*/function () {
269
264
  } finally {
270
265
  _iterator2.f();
271
266
  }
272
- _context.next = 43;
267
+ _context.next = 44;
273
268
  return _this.spawn({
274
269
  http_msg: item,
275
270
  module: sigs.module,
276
271
  scheduler: sigs.scheduler
277
272
  });
278
- case 43:
273
+ case 44:
279
274
  _res2 = _context.sent;
280
- _context.next = 52;
275
+ _context.next = 53;
281
276
  break;
282
- case 46:
277
+ case 47:
283
278
  if (!(sigs.type === "Message")) {
284
- _context.next = 52;
279
+ _context.next = 53;
285
280
  break;
286
281
  }
287
282
  _iterator3 = _createForOfIteratorHelper(item.tags);
@@ -295,28 +290,28 @@ var Server = /*#__PURE__*/function () {
295
290
  } finally {
296
291
  _iterator3.f();
297
292
  }
298
- _context.next = 51;
293
+ _context.next = 52;
299
294
  return _this.message({
300
295
  slot: sigs.slot,
301
296
  http_msg: item,
302
297
  process: sigs.target
303
298
  });
304
- case 51:
305
- _res3 = _context.sent;
306
299
  case 52:
307
- _context.next = 57;
300
+ _res3 = _context.sent;
301
+ case 53:
302
+ _context.next = 58;
308
303
  break;
309
- case 54:
310
- _context.prev = 54;
311
- _context.t1 = _context["catch"](33);
304
+ case 55:
305
+ _context.prev = 55;
306
+ _context.t1 = _context["catch"](34);
312
307
  console.log(_context.t1, req.originalUrl);
313
- case 57:
314
- return _context.abrupt("return", res.status(200).send("Success"));
315
308
  case 58:
309
+ return _context.abrupt("return", res.status(200).send("Success"));
310
+ case 59:
316
311
  case "end":
317
312
  return _context.stop();
318
313
  }
319
- }, _callee, null, [[7, 21, 24, 27], [33, 54]]);
314
+ }, _callee, null, [[8, 22, 25, 28], [34, 55]]);
320
315
  }));
321
316
  return function (_x, _x2) {
322
317
  return _ref2.apply(this, arguments);
@@ -375,7 +370,7 @@ var Server = /*#__PURE__*/function () {
375
370
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
376
371
  while (1) switch (_context3.prev = _context3.next) {
377
372
  case 0:
378
- res.send(_this2.mem.getAnchor());
373
+ return _context3.abrupt("return", res.send(_this2.mem.getAnchor()));
379
374
  case 1:
380
375
  case "end":
381
376
  return _context3.stop();
@@ -391,7 +386,7 @@ var Server = /*#__PURE__*/function () {
391
386
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
392
387
  while (1) switch (_context4.prev = _context4.next) {
393
388
  case 0:
394
- res.json(req.params);
389
+ return _context4.abrupt("return", res.json(req.params));
395
390
  case 1:
396
391
  case "end":
397
392
  return _context4.stop();
@@ -433,7 +428,7 @@ var Server = /*#__PURE__*/function () {
433
428
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
434
429
  while (1) switch (_context6.prev = _context6.next) {
435
430
  case 0:
436
- res.send("0");
431
+ return _context6.abrupt("return", res.send("0"));
437
432
  case 1:
438
433
  case "end":
439
434
  return _context6.stop();
@@ -813,7 +808,7 @@ var Server = /*#__PURE__*/function () {
813
808
  });
814
809
  var result = /*#__PURE__*/function () {
815
810
  var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(req, res) {
816
- var message, process, _yield$_this5$recover, success, _this5$mem$env$proces, res2;
811
+ var message, process, _yield$_this5$recover, success, slot, _this5$mem$env$proces, _this5$mem$env$proces2, res2;
817
812
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
818
813
  while (1) switch (_context13.prev = _context13.next) {
819
814
  case 0:
@@ -839,29 +834,37 @@ var Server = /*#__PURE__*/function () {
839
834
  });
840
835
  return _context13.abrupt("return");
841
836
  case 12:
837
+ slot = message;
842
838
  if (!/^--[0-9a-zA-Z_-]{43,44}$/.test(message)) {
843
- message = (_this5$mem$env$proces = _this5.mem.env[process]) === null || _this5$mem$env$proces === void 0 || (_this5$mem$env$proces = _this5$mem$env$proces.results) === null || _this5$mem$env$proces === void 0 ? void 0 : _this5$mem$env$proces[message];
839
+ message = (_this5$mem$env$proces = _this5.mem.env[process]) === null || _this5$mem$env$proces === void 0 || (_this5$mem$env$proces = _this5$mem$env$proces.results) === null || _this5$mem$env$proces === void 0 ? void 0 : _this5$mem$env$proces[slot];
840
+ }
841
+ if (!(0, _ramda.isNil)(message)) {
842
+ _context13.next = 22;
843
+ break;
844
844
  }
845
+ _context13.next = 17;
846
+ return _this5.recover(process);
847
+ case 17:
848
+ message = (_this5$mem$env$proces2 = _this5.mem.env[process]) === null || _this5$mem$env$proces2 === void 0 || (_this5$mem$env$proces2 = _this5$mem$env$proces2.results) === null || _this5$mem$env$proces2 === void 0 ? void 0 : _this5$mem$env$proces2[slot];
845
849
  if (!(0, _ramda.isNil)(message)) {
846
- _context13.next = 18;
850
+ _context13.next = 22;
847
851
  break;
848
852
  }
849
- console.log("message not found", message, req.params);
850
853
  res.status(404);
851
854
  res.json({
852
855
  error: "Not Found"
853
856
  });
854
857
  return _context13.abrupt("return");
855
- case 18:
856
- _context13.next = 20;
858
+ case 22:
859
+ _context13.next = 24;
857
860
  return _this5.result({
858
861
  message: message,
859
862
  process: process
860
863
  });
861
- case 20:
864
+ case 24:
862
865
  res2 = _context13.sent;
863
866
  res.json(res2);
864
- case 22:
867
+ case 26:
865
868
  case "end":
866
869
  return _context13.stop();
867
870
  }
package/esm/ao.js CHANGED
@@ -59,7 +59,7 @@ const getHash = res =>
59
59
  Messages: res.Messages ?? [],
60
60
  Spawns: res.Spawns ?? [],
61
61
  Assignments: res.Assignments ?? [],
62
- }),
62
+ })
63
63
  )
64
64
 
65
65
  function createDataItemSigner2(wallet) {
@@ -597,7 +597,7 @@ class AO {
597
597
  if (typeof text === "number") text = Number(text).toString()
598
598
  _data = _data.replace(
599
599
  new RegExp(`\<${k}\>`, "g"),
600
- text.replace(/'/g, "\\'"),
600
+ text.replace(/'/g, "\\'")
601
601
  )
602
602
  }
603
603
  out = _data
@@ -707,11 +707,43 @@ class AO {
707
707
  if (result.pid) result.p = this.p(result.pid)
708
708
  return result
709
709
  }
710
+ async var({ pid, data, json = true, pretty = false }) {
711
+ if (json) {
712
+ const _var = (
713
+ await this.dry({
714
+ act: "Eval",
715
+ data: `require("json").encode(${data})`,
716
+ pid,
717
+ })
718
+ )?.res?.Output?.data
719
+ if (_var) {
720
+ try {
721
+ return JSON.parse(strip(_var))
722
+ } catch (e) {
723
+ return strip(_var)
724
+ }
725
+ }
726
+ return _var
727
+ } else {
728
+ const _var = (
729
+ await this.dry({
730
+ act: "Eval",
731
+ data,
732
+ pid,
733
+ })
734
+ )?.res?.Output?.data
735
+ return pretty ? _var : strip(_var)
736
+ }
737
+ }
710
738
  p(pid) {
711
739
  return new Process(pid, this)
712
740
  }
713
741
  }
714
742
 
743
+ function strip(str) {
744
+ return str.replace(/\x1B\[[0-9;]*[JKmsu]/g, "")
745
+ }
746
+
715
747
  const getParams = (tags, opts) => {
716
748
  let _tags = tags
717
749
  let _opts = opts
@@ -760,6 +792,9 @@ class Process {
760
792
  if (res.err) throw Error(res.err)
761
793
  return res.out
762
794
  }
795
+ async v(data, json = true, pretty = false) {
796
+ return await this.ao.var({ pid: this.pid, data, json, pretty })
797
+ }
763
798
  }
764
799
 
765
800
  export default AO
package/esm/server.js CHANGED
@@ -4,7 +4,7 @@ import express from "express"
4
4
  import cors from "cors"
5
5
  import base64url from "base64url"
6
6
  import { DataItem } from "arbundles"
7
- import { tags, toGraphObj, optAO } from "./utils.js"
7
+ import { tags, toGraphObj, optAO, wait } from "./utils.js"
8
8
  import { connect } from "./aoconnect.js"
9
9
  import { GQL, cu, su, mu } from "./test.js"
10
10
  import bodyParser from "body-parser"
@@ -130,6 +130,8 @@ class Server {
130
130
  app.use(cors())
131
131
  app.use("/tx", bodyParser.raw({ type: "*/*", limit: "100mb" }))
132
132
  app.post("/tx", async (req, res) => {
133
+ // todo: items from HB has wrong sigs and ids
134
+ return res.status(200).send("Success")
133
135
  if (!Buffer.isBuffer(req.body)) {
134
136
  console.log("BD: Invalid body | expected raw Buffer")
135
137
  return res.status(400).send("Invalid body: expected raw Buffer")
@@ -218,12 +220,8 @@ class Server {
218
220
  res.status(400)
219
221
  res.send(null)
220
222
  })
221
- app.get("/tx_anchor", async (req, res) => {
222
- res.send(this.mem.getAnchor())
223
- })
224
- app.get("/mine", async (req, res) => {
225
- res.json(req.params)
226
- })
223
+ app.get("/tx_anchor", async (req, res) => res.send(this.mem.getAnchor()))
224
+ app.get("/mine", async (req, res) => res.json(req.params))
227
225
  app.get("/:id", async (req, res) => {
228
226
  const _data = await this._ar.data(req.params.id)
229
227
  if (!_data) {
@@ -233,9 +231,7 @@ class Server {
233
231
  res.send(Buffer.from(_data, "base64"))
234
232
  }
235
233
  })
236
- app.get("/price/:id", async (req, res) => {
237
- res.send("0")
238
- })
234
+ app.get("/price/:id", async (req, res) => res.send("0"))
239
235
  app.post("/graphql", async (req, res) => {
240
236
  try {
241
237
  const { query, variables } = req.body
@@ -414,14 +410,18 @@ class Server {
414
410
  return
415
411
  }
416
412
  }
413
+ const slot = message
417
414
  if (!/^--[0-9a-zA-Z_-]{43,44}$/.test(message)) {
418
- message = this.mem.env[process]?.results?.[message]
415
+ message = this.mem.env[process]?.results?.[slot]
419
416
  }
420
417
  if (isNil(message)) {
421
- console.log("message not found", message, req.params)
422
- res.status(404)
423
- res.json({ error: `Not Found` })
424
- return
418
+ await this.recover(process)
419
+ message = this.mem.env[process]?.results?.[slot]
420
+ if (isNil(message)) {
421
+ res.status(404)
422
+ res.json({ error: `Not Found` })
423
+ return
424
+ }
425
425
  }
426
426
  const res2 = await this.result({
427
427
  message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"
@@ -26,12 +26,12 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "aoconnect-wao": "https://gitpkg.vercel.app/weavedb/ao/connect?abd2992689dc5983d5cd48b38fb997b0532f192a&scripts.postinstall=npm%20install%20--ignore-scripts%20%26%26%20npm%20run%20build",
30
29
  "@babel/plugin-transform-modules-commonjs": "^7.24.8",
31
30
  "@bokuweb/zstd-wasm": "^0.0.22",
32
31
  "@dha-team/arbundles": "^1.0.1",
33
32
  "@permaweb/ao-loader": "^0.0.44",
34
33
  "@permaweb/aoconnect": "^0.0.62",
34
+ "aoconnect-wao": "https://gitpkg.vercel.app/weavedb/ao/connect?abd2992689dc5983d5cd48b38fb997b0532f192a&scripts.postinstall=npm%20install%20--ignore-scripts%20%26%26%20npm%20run%20build",
35
35
  "arbundles": "^0.11.1",
36
36
  "arjson": "^0.0.2",
37
37
  "arweave": "^1.15.1",