wao 0.15.7 → 0.16.1

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/adaptor.js CHANGED
@@ -10,8 +10,6 @@ var _utils = require("./utils.js");
10
10
  var _aoconnect = require("./aoconnect.js");
11
11
  var _test = require("./test.js");
12
12
  var _ramda = require("ramda");
13
- var _httpMessageSignatures = require("http-message-signatures");
14
- var _nodeCrypto = require("node:crypto");
15
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
14
  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); }
17
15
  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; }
@@ -29,7 +27,9 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
29
27
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
30
28
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
31
29
  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); }
32
- var verifyMessage = _httpMessageSignatures.httpbis.verifyMessage;
30
+ //import { httpbis, createVerifier } from "http-message-signatures"
31
+ //import { createPublicKey } from "node:crypto"
32
+ //const { verifyMessage } = httpbis
33
33
  var Adaptor = /*#__PURE__*/function () {
34
34
  function Adaptor(_ref) {
35
35
  var hb_url = _ref.hb_url,
@@ -75,21 +75,23 @@ var Adaptor = /*#__PURE__*/function () {
75
75
  return _createClass(Adaptor, [{
76
76
  key: "get",
77
77
  value: function () {
78
- var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
78
+ var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
79
79
  return _regeneratorRuntime().wrap(function _callee$(_context) {
80
80
  while (1) switch (_context.prev = _context.next) {
81
81
  case 0:
82
- _context.next = 2;
82
+ _context.t0 = res;
83
+ _context.next = 3;
83
84
  return this[req.device](req);
84
- case 2:
85
- return _context.abrupt("return", _context.sent);
86
85
  case 3:
86
+ _context.t1 = _context.sent;
87
+ (0, _context.t0)(_context.t1);
88
+ case 5:
87
89
  case "end":
88
90
  return _context.stop();
89
91
  }
90
92
  }, _callee, this);
91
93
  }));
92
- function get(_x) {
94
+ function get(_x, _x2) {
93
95
  return _get.apply(this, arguments);
94
96
  }
95
97
  return get;
@@ -111,7 +113,7 @@ var Adaptor = /*#__PURE__*/function () {
111
113
  }
112
114
  }, _callee2, this);
113
115
  }));
114
- function bd(_x2) {
116
+ function bd(_x3) {
115
117
  return _bd.apply(this, arguments);
116
118
  }
117
119
  return bd;
@@ -133,7 +135,7 @@ var Adaptor = /*#__PURE__*/function () {
133
135
  }
134
136
  }, _callee3, this);
135
137
  }));
136
- function ar(_x3) {
138
+ function ar(_x4) {
137
139
  return _ar2.apply(this, arguments);
138
140
  }
139
141
  return ar;
@@ -155,7 +157,7 @@ var Adaptor = /*#__PURE__*/function () {
155
157
  }
156
158
  }, _callee4, this);
157
159
  }));
158
- function su(_x4) {
160
+ function su(_x5) {
159
161
  return _su.apply(this, arguments);
160
162
  }
161
163
  return su;
@@ -177,7 +179,7 @@ var Adaptor = /*#__PURE__*/function () {
177
179
  }
178
180
  }, _callee5, this);
179
181
  }));
180
- function mu(_x5) {
182
+ function mu(_x6) {
181
183
  return _mu.apply(this, arguments);
182
184
  }
183
185
  return mu;
@@ -199,7 +201,7 @@ var Adaptor = /*#__PURE__*/function () {
199
201
  }
200
202
  }, _callee6, this);
201
203
  }));
202
- function cu(_x6) {
204
+ function cu(_x7) {
203
205
  return _cu.apply(this, arguments);
204
206
  }
205
207
  return cu;
@@ -220,7 +222,7 @@ var Adaptor = /*#__PURE__*/function () {
220
222
  }
221
223
  }, _callee7);
222
224
  }));
223
- function bd_get(_x7) {
225
+ function bd_get(_x8) {
224
226
  return _bd_get.apply(this, arguments);
225
227
  }
226
228
  return bd_get;
@@ -251,7 +253,7 @@ var Adaptor = /*#__PURE__*/function () {
251
253
  }
252
254
  }, _callee8, this);
253
255
  }));
254
- function bd_post(_x8) {
256
+ function bd_post(_x9) {
255
257
  return _bd_post.apply(this, arguments);
256
258
  }
257
259
  return bd_post;
@@ -317,7 +319,7 @@ var Adaptor = /*#__PURE__*/function () {
317
319
  }
318
320
  }, _callee9, this);
319
321
  }));
320
- function ar_get(_x9) {
322
+ function ar_get(_x10) {
321
323
  return _ar_get.apply(this, arguments);
322
324
  }
323
325
  return ar_get;
@@ -353,7 +355,7 @@ var Adaptor = /*#__PURE__*/function () {
353
355
  }
354
356
  }, _callee10, this);
355
357
  }));
356
- function ar_post(_x10) {
358
+ function ar_post(_x11) {
357
359
  return _ar_post.apply(this, arguments);
358
360
  }
359
361
  return ar_post;
@@ -394,7 +396,7 @@ var Adaptor = /*#__PURE__*/function () {
394
396
  }
395
397
  }, _callee11, this);
396
398
  }));
397
- function su_get(_x11) {
399
+ function su_get(_x12) {
398
400
  return _su_get.apply(this, arguments);
399
401
  }
400
402
  return su_get;
@@ -420,7 +422,7 @@ var Adaptor = /*#__PURE__*/function () {
420
422
  }
421
423
  }, _callee12, this);
422
424
  }));
423
- function su_post(_x12) {
425
+ function su_post(_x13) {
424
426
  return _su_post.apply(this, arguments);
425
427
  }
426
428
  return su_post;
@@ -456,7 +458,7 @@ var Adaptor = /*#__PURE__*/function () {
456
458
  }
457
459
  }, _callee13, this);
458
460
  }));
459
- function mu_get(_x13) {
461
+ function mu_get(_x14) {
460
462
  return _mu_get.apply(this, arguments);
461
463
  }
462
464
  return mu_get;
@@ -487,7 +489,7 @@ var Adaptor = /*#__PURE__*/function () {
487
489
  }
488
490
  }, _callee14, this);
489
491
  }));
490
- function mu_delete(_x14) {
492
+ function mu_delete(_x15) {
491
493
  return _mu_delete.apply(this, arguments);
492
494
  }
493
495
  return mu_delete;
@@ -523,7 +525,7 @@ var Adaptor = /*#__PURE__*/function () {
523
525
  }
524
526
  }, _callee15, this);
525
527
  }));
526
- function mu_post(_x15) {
528
+ function mu_post(_x16) {
527
529
  return _mu_post.apply(this, arguments);
528
530
  }
529
531
  return mu_post;
@@ -569,7 +571,7 @@ var Adaptor = /*#__PURE__*/function () {
569
571
  }
570
572
  }, _callee16, this);
571
573
  }));
572
- function cu_get(_x16) {
574
+ function cu_get(_x17) {
573
575
  return _cu_get.apply(this, arguments);
574
576
  }
575
577
  return cu_get;
@@ -605,7 +607,7 @@ var Adaptor = /*#__PURE__*/function () {
605
607
  }
606
608
  }, _callee17, this);
607
609
  }));
608
- function cu_post(_x17) {
610
+ function cu_post(_x18) {
609
611
  return _cu_post.apply(this, arguments);
610
612
  }
611
613
  return cu_post;
@@ -628,7 +630,7 @@ var Adaptor = /*#__PURE__*/function () {
628
630
  }
629
631
  }, _callee18);
630
632
  }));
631
- function bad(_x18) {
633
+ function bad(_x19) {
632
634
  return _bad.apply(this, arguments);
633
635
  }
634
636
  return bad;
@@ -637,7 +639,7 @@ var Adaptor = /*#__PURE__*/function () {
637
639
  key: "bd_post_tx",
638
640
  value: function () {
639
641
  var _bd_post_tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref3) {
640
- var query, params, body, headers, method, lines, sigs, currentKey, _iterator, _step, line, trimmed, headerMatch, _key, value, input, key, verifier, id, isValid, item, _iterator2, _step2, v, res, _iterator3, _step3, _v, _res2;
642
+ var query, params, body, headers, method, lines, sigs, currentKey, _iterator, _step, line, trimmed, headerMatch, key, value, id, item, _iterator2, _step2, v, res, _iterator3, _step3, _v, _res2;
641
643
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
642
644
  while (1) switch (_context19.prev = _context19.next) {
643
645
  case 0:
@@ -668,10 +670,10 @@ var Adaptor = /*#__PURE__*/function () {
668
670
  case 17:
669
671
  headerMatch = trimmed.match(/^([a-zA-Z0-9_-]+):\s*(.*)$/);
670
672
  if (headerMatch && !headerMatch[2].includes(": ")) {
671
- _key = headerMatch[1];
673
+ key = headerMatch[1];
672
674
  value = headerMatch[2];
673
- sigs[_key] = value;
674
- currentKey = _key;
675
+ sigs[key] = value;
676
+ currentKey = key;
675
677
  } else if (currentKey) sigs[currentKey] += "\n" + line;
676
678
  case 19:
677
679
  _context19.next = 11;
@@ -690,35 +692,27 @@ var Adaptor = /*#__PURE__*/function () {
690
692
  case 29:
691
693
  sigs.target = headers.process;
692
694
  sigs.slot = headers.slot;
693
- input = (0, _utils.parseSignatureInput)(headers["signature-input"]);
694
- key = {
695
- kty: "RSA",
696
- n: input.keyid,
697
- e: "AQAB"
698
- };
699
- verifier = (0, _httpMessageSignatures.createVerifier)((0, _nodeCrypto.createPublicKey)({
700
- key: key,
701
- format: "jwk"
702
- }), "rsa-pss-sha512");
695
+ /*
696
+ const input = parseSignatureInput(headers["signature-input"])
697
+ const key = { kty: "RSA", n: input.keyid, e: "AQAB" }
698
+ const verifier = createVerifier(
699
+ createPublicKey({ key, format: "jwk" }),
700
+ "rsa-pss-sha512"
701
+ )*/
703
702
  id = null;
704
- _context19.prev = 35;
705
- _context19.next = 38;
706
- return verifyMessage({
707
- keyLookup: function keyLookup(params) {
708
- return {
709
- verify: verifier
710
- };
703
+ _context19.prev = 32;
704
+ /*
705
+ const isValid = await verifyMessage(
706
+ { keyLookup: params => ({ verify: verifier }) },
707
+ {
708
+ method: method,
709
+ headers: headers,
710
+ url: `http://ao.com${headers.path}`,
711
711
  }
712
- }, {
713
- method: method,
714
- headers: headers,
715
- url: "http://ao.com".concat(headers.path)
716
- });
717
- case 38:
718
- isValid = _context19.sent;
712
+ )*/
719
713
  item = (0, _utils.toANS104Request)(sigs).item;
720
714
  if (!(sigs.slot === "0" || sigs.type === "Process")) {
721
- _context19.next = 48;
715
+ _context19.next = 42;
722
716
  break;
723
717
  }
724
718
  _iterator2 = _createForOfIteratorHelper(item.tags);
@@ -732,19 +726,19 @@ var Adaptor = /*#__PURE__*/function () {
732
726
  } finally {
733
727
  _iterator2.f();
734
728
  }
735
- _context19.next = 45;
729
+ _context19.next = 39;
736
730
  return this.spawn({
737
731
  http_msg: item,
738
732
  module: sigs.module,
739
733
  scheduler: sigs.scheduler
740
734
  });
741
- case 45:
735
+ case 39:
742
736
  res = _context19.sent;
743
- _context19.next = 54;
737
+ _context19.next = 48;
744
738
  break;
745
- case 48:
739
+ case 42:
746
740
  if (!(sigs.type === "Message")) {
747
- _context19.next = 54;
741
+ _context19.next = 48;
748
742
  break;
749
743
  }
750
744
  _iterator3 = _createForOfIteratorHelper(item.tags);
@@ -758,32 +752,32 @@ var Adaptor = /*#__PURE__*/function () {
758
752
  } finally {
759
753
  _iterator3.f();
760
754
  }
761
- _context19.next = 53;
755
+ _context19.next = 47;
762
756
  return this.message({
763
757
  slot: sigs.slot,
764
758
  http_msg: item,
765
759
  process: sigs.target
766
760
  });
767
- case 53:
761
+ case 47:
768
762
  _res2 = _context19.sent;
769
- case 54:
770
- _context19.next = 59;
763
+ case 48:
764
+ _context19.next = 53;
771
765
  break;
772
- case 56:
773
- _context19.prev = 56;
774
- _context19.t1 = _context19["catch"](35);
766
+ case 50:
767
+ _context19.prev = 50;
768
+ _context19.t1 = _context19["catch"](32);
775
769
  console.log(_context19.t1);
776
- case 59:
770
+ case 53:
777
771
  return _context19.abrupt("return", {
778
772
  send: "Success"
779
773
  });
780
- case 60:
774
+ case 54:
781
775
  case "end":
782
776
  return _context19.stop();
783
777
  }
784
- }, _callee19, this, [[9, 23, 26, 29], [35, 56]]);
778
+ }, _callee19, this, [[9, 23, 26, 29], [32, 50]]);
785
779
  }));
786
- function bd_post_tx(_x19) {
780
+ function bd_post_tx(_x20) {
787
781
  return _bd_post_tx.apply(this, arguments);
788
782
  }
789
783
  return bd_post_tx;
@@ -809,7 +803,7 @@ var Adaptor = /*#__PURE__*/function () {
809
803
  }
810
804
  }, _callee20);
811
805
  }));
812
- function cu_get_root(_x20) {
806
+ function cu_get_root(_x21) {
813
807
  return _cu_get_root.apply(this, arguments);
814
808
  }
815
809
  return cu_get_root;
@@ -844,7 +838,7 @@ var Adaptor = /*#__PURE__*/function () {
844
838
  }
845
839
  }, _callee21, this);
846
840
  }));
847
- function cu_get_state(_x21) {
841
+ function cu_get_state(_x22) {
848
842
  return _cu_get_state.apply(this, arguments);
849
843
  }
850
844
  return cu_get_state;
@@ -889,7 +883,7 @@ var Adaptor = /*#__PURE__*/function () {
889
883
  }
890
884
  }, _callee22, this);
891
885
  }));
892
- function cu_post_dryrun(_x22) {
886
+ function cu_post_dryrun(_x23) {
893
887
  return _cu_post_dryrun.apply(this, arguments);
894
888
  }
895
889
  return cu_post_dryrun;
@@ -974,7 +968,7 @@ var Adaptor = /*#__PURE__*/function () {
974
968
  }
975
969
  }, _callee23, this, [[10, 29, 32, 35]]);
976
970
  }));
977
- function cu_post_results(_x23) {
971
+ function cu_post_results(_x24) {
978
972
  return _cu_post_results.apply(this, arguments);
979
973
  }
980
974
  return cu_post_results;
@@ -1050,7 +1044,7 @@ var Adaptor = /*#__PURE__*/function () {
1050
1044
  }
1051
1045
  }, _callee24, this);
1052
1046
  }));
1053
- function cu_get_result(_x24) {
1047
+ function cu_get_result(_x25) {
1054
1048
  return _cu_get_result.apply(this, arguments);
1055
1049
  }
1056
1050
  return cu_get_result;
@@ -1078,7 +1072,7 @@ var Adaptor = /*#__PURE__*/function () {
1078
1072
  }
1079
1073
  }, _callee25, this);
1080
1074
  }));
1081
- function su_get_root(_x25) {
1075
+ function su_get_root(_x26) {
1082
1076
  return _su_get_root.apply(this, arguments);
1083
1077
  }
1084
1078
  return su_get_root;
@@ -1104,7 +1098,7 @@ var Adaptor = /*#__PURE__*/function () {
1104
1098
  }
1105
1099
  }, _callee26, this);
1106
1100
  }));
1107
- function su_get_timestamp(_x26) {
1101
+ function su_get_timestamp(_x27) {
1108
1102
  return _su_get_timestamp.apply(this, arguments);
1109
1103
  }
1110
1104
  return su_get_timestamp;
@@ -1167,7 +1161,7 @@ var Adaptor = /*#__PURE__*/function () {
1167
1161
  }
1168
1162
  }, _callee27);
1169
1163
  }));
1170
- return function (_x28) {
1164
+ return function (_x29) {
1171
1165
  return _ref12.apply(this, arguments);
1172
1166
  };
1173
1167
  }())((0, _ramda.reverse)((_this$mem$env$pid$res2 = (_this$mem$env$pid3 = this.mem.env[pid]) === null || _this$mem$env$pid3 === void 0 ? void 0 : _this$mem$env$pid3.results) !== null && _this$mem$env$pid$res2 !== void 0 ? _this$mem$env$pid$res2 : [])); // need mod
@@ -1185,7 +1179,7 @@ var Adaptor = /*#__PURE__*/function () {
1185
1179
  }
1186
1180
  }, _callee28, this);
1187
1181
  }));
1188
- function su_get_pid(_x27) {
1182
+ function su_get_pid(_x28) {
1189
1183
  return _su_get_pid.apply(this, arguments);
1190
1184
  }
1191
1185
  return su_get_pid;
@@ -1208,7 +1202,7 @@ var Adaptor = /*#__PURE__*/function () {
1208
1202
  }
1209
1203
  }, _callee29);
1210
1204
  }));
1211
- function mu_get_root(_x29) {
1205
+ function mu_get_root(_x30) {
1212
1206
  return _mu_get_root.apply(this, arguments);
1213
1207
  }
1214
1208
  return mu_get_root;
@@ -1282,7 +1276,7 @@ var Adaptor = /*#__PURE__*/function () {
1282
1276
  }
1283
1277
  }, _callee30, this);
1284
1278
  }));
1285
- function mu_post_root(_x30) {
1279
+ function mu_post_root(_x31) {
1286
1280
  return _mu_post_root.apply(this, arguments);
1287
1281
  }
1288
1282
  return mu_post_root;
@@ -1313,7 +1307,7 @@ var Adaptor = /*#__PURE__*/function () {
1313
1307
  }
1314
1308
  }, _callee31, this);
1315
1309
  }));
1316
- function mu_post_monitor(_x31) {
1310
+ function mu_post_monitor(_x32) {
1317
1311
  return _mu_post_monitor.apply(this, arguments);
1318
1312
  }
1319
1313
  return mu_post_monitor;
@@ -1344,7 +1338,7 @@ var Adaptor = /*#__PURE__*/function () {
1344
1338
  }
1345
1339
  }, _callee32, this);
1346
1340
  }));
1347
- function mu_delete_monitor(_x32) {
1341
+ function mu_delete_monitor(_x33) {
1348
1342
  return _mu_delete_monitor.apply(this, arguments);
1349
1343
  }
1350
1344
  return mu_delete_monitor;
@@ -1373,7 +1367,7 @@ var Adaptor = /*#__PURE__*/function () {
1373
1367
  }
1374
1368
  }, _callee33, this);
1375
1369
  }));
1376
- function ar_get_root(_x33) {
1370
+ function ar_get_root(_x34) {
1377
1371
  return _ar_get_root.apply(this, arguments);
1378
1372
  }
1379
1373
  return ar_get_root;
@@ -1396,7 +1390,7 @@ var Adaptor = /*#__PURE__*/function () {
1396
1390
  }
1397
1391
  }, _callee34);
1398
1392
  }));
1399
- function ar_get_wallet_balance(_x34) {
1393
+ function ar_get_wallet_balance(_x35) {
1400
1394
  return _ar_get_wallet_balance.apply(this, arguments);
1401
1395
  }
1402
1396
  return ar_get_wallet_balance;
@@ -1421,7 +1415,7 @@ var Adaptor = /*#__PURE__*/function () {
1421
1415
  }
1422
1416
  }, _callee35);
1423
1417
  }));
1424
- function ar_get_mint(_x35) {
1418
+ function ar_get_mint(_x36) {
1425
1419
  return _ar_get_mint.apply(this, arguments);
1426
1420
  }
1427
1421
  return ar_get_mint;
@@ -1445,7 +1439,7 @@ var Adaptor = /*#__PURE__*/function () {
1445
1439
  }
1446
1440
  }, _callee36);
1447
1441
  }));
1448
- function ar_get_tx_offset(_x36) {
1442
+ function ar_get_tx_offset(_x37) {
1449
1443
  return _ar_get_tx_offset.apply(this, arguments);
1450
1444
  }
1451
1445
  return ar_get_tx_offset;
@@ -1468,7 +1462,7 @@ var Adaptor = /*#__PURE__*/function () {
1468
1462
  }
1469
1463
  }, _callee37, this);
1470
1464
  }));
1471
- function ar_get_tx_anchor(_x37) {
1465
+ function ar_get_tx_anchor(_x38) {
1472
1466
  return _ar_get_tx_anchor.apply(this, arguments);
1473
1467
  }
1474
1468
  return ar_get_tx_anchor;
@@ -1491,7 +1485,7 @@ var Adaptor = /*#__PURE__*/function () {
1491
1485
  }
1492
1486
  }, _callee38);
1493
1487
  }));
1494
- function ar_get_mine(_x38) {
1488
+ function ar_get_mine(_x39) {
1495
1489
  return _ar_get_mine.apply(this, arguments);
1496
1490
  }
1497
1491
  return ar_get_mine;
@@ -1527,7 +1521,7 @@ var Adaptor = /*#__PURE__*/function () {
1527
1521
  }
1528
1522
  }, _callee39, this);
1529
1523
  }));
1530
- function ar_get_id(_x39) {
1524
+ function ar_get_id(_x40) {
1531
1525
  return _ar_get_id.apply(this, arguments);
1532
1526
  }
1533
1527
  return ar_get_id;
@@ -1550,7 +1544,7 @@ var Adaptor = /*#__PURE__*/function () {
1550
1544
  }
1551
1545
  }, _callee40);
1552
1546
  }));
1553
- function ar_get_price(_x40) {
1547
+ function ar_get_price(_x41) {
1554
1548
  return _ar_get_price.apply(this, arguments);
1555
1549
  }
1556
1550
  return ar_get_price;
@@ -1623,7 +1617,7 @@ var Adaptor = /*#__PURE__*/function () {
1623
1617
  }
1624
1618
  }, _callee41, this, [[1, 19]]);
1625
1619
  }));
1626
- function ar_post_graphql(_x41) {
1620
+ function ar_post_graphql(_x42) {
1627
1621
  return _ar_post_graphql.apply(this, arguments);
1628
1622
  }
1629
1623
  return ar_post_graphql;
@@ -1691,7 +1685,7 @@ var Adaptor = /*#__PURE__*/function () {
1691
1685
  }
1692
1686
  }, _callee42, this);
1693
1687
  }));
1694
- function ar_post_id(_x42) {
1688
+ function ar_post_id(_x43) {
1695
1689
  return _ar_post_id.apply(this, arguments);
1696
1690
  }
1697
1691
  return ar_post_id;
package/cjs/server.js CHANGED
@@ -137,18 +137,20 @@ var Server = /*#__PURE__*/function () {
137
137
  });
138
138
  }
139
139
  }, {
140
- key: "send",
141
- value: function send(res, data) {
142
- if (data.status) res.status(data.status);
143
- if (data.error) {
144
- res.json({
145
- error: data.error
146
- });
147
- } else if (data.json) {
148
- res.json(data.json);
149
- } else {
150
- res.send(data.send);
151
- }
140
+ key: "res",
141
+ value: function res(_res) {
142
+ return function (data) {
143
+ if (data.status) _res.status(data.status);
144
+ if (data.error) {
145
+ _res.json({
146
+ error: data.error
147
+ });
148
+ } else if (data.json) {
149
+ _res.json(data.json);
150
+ } else {
151
+ _res.send(data.send);
152
+ }
153
+ };
152
154
  }
153
155
  }, {
154
156
  key: "req",
@@ -180,14 +182,11 @@ var Server = /*#__PURE__*/function () {
180
182
  return _regeneratorRuntime().wrap(function _callee$(_context) {
181
183
  while (1) switch (_context.prev = _context.next) {
182
184
  case 0:
183
- _context.t0 = _this;
184
- _context.t1 = res;
185
- _context.next = 4;
186
- return _this.adaptor.get(_this.req(req, name.toLowerCase(), path));
187
- case 4:
188
- _context.t2 = _context.sent;
189
- return _context.abrupt("return", _context.t0.send.call(_context.t0, _context.t1, _context.t2));
190
- case 6:
185
+ _context.next = 2;
186
+ return _this.adaptor.get(_this.req(req, name.toLowerCase(), path), _this.res(res));
187
+ case 2:
188
+ return _context.abrupt("return", _context.sent);
189
+ case 3:
191
190
  case "end":
192
191
  return _context.stop();
193
192
  }
package/cjs/test.js CHANGED
@@ -16,6 +16,12 @@ Object.defineProperty(exports, "AR", {
16
16
  return _tar["default"];
17
17
  }
18
18
  });
19
+ Object.defineProperty(exports, "Adaptor", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _adaptor["default"];
23
+ }
24
+ });
19
25
  Object.defineProperty(exports, "ArMem", {
20
26
  enumerable: true,
21
27
  get: function get() {
@@ -107,6 +113,7 @@ var _armem = _interopRequireDefault(require("./armem.js"));
107
113
  var _utils = require("./utils.js");
108
114
  var _helpers = require("./helpers.js");
109
115
  var _server = _interopRequireDefault(require("./server.js"));
116
+ var _adaptor = _interopRequireDefault(require("./adaptor.js"));
110
117
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
111
118
  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; }
112
119
  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); }
package/esm/adaptor.js CHANGED
@@ -9,9 +9,9 @@ import {
9
9
  import { connect } from "./aoconnect.js"
10
10
  import { GQL, cu, su, mu } from "./test.js"
11
11
  import { keys, map, isNil, reverse, omit } from "ramda"
12
- import { httpbis, createVerifier } from "http-message-signatures"
13
- import { createPublicKey } from "node:crypto"
14
- const { verifyMessage } = httpbis
12
+ //import { httpbis, createVerifier } from "http-message-signatures"
13
+ //import { createPublicKey } from "node:crypto"
14
+ //const { verifyMessage } = httpbis
15
15
 
16
16
  class Adaptor {
17
17
  constructor({ hb_url, aoconnect, log = false, db }) {
@@ -42,8 +42,8 @@ class Adaptor {
42
42
  this.mem = mem
43
43
  this.gql = new GQL({ mem })
44
44
  }
45
- async get(req) {
46
- return await this[req.device](req)
45
+ async get(req, res) {
46
+ res(await this[req.device](req))
47
47
  }
48
48
  async bd(req) {
49
49
  return await this[`bd_${req.method.toLowerCase()}`](req)
@@ -216,15 +216,16 @@ class Adaptor {
216
216
  }
217
217
  sigs.target = headers.process
218
218
  sigs.slot = headers.slot
219
-
219
+ /*
220
220
  const input = parseSignatureInput(headers["signature-input"])
221
221
  const key = { kty: "RSA", n: input.keyid, e: "AQAB" }
222
222
  const verifier = createVerifier(
223
223
  createPublicKey({ key, format: "jwk" }),
224
224
  "rsa-pss-sha512"
225
- )
225
+ )*/
226
226
  let id = null
227
227
  try {
228
+ /*
228
229
  const isValid = await verifyMessage(
229
230
  { keyLookup: params => ({ verify: verifier }) },
230
231
  {
@@ -232,7 +233,7 @@ class Adaptor {
232
233
  headers: headers,
233
234
  url: `http://ao.com${headers.path}`,
234
235
  }
235
- )
236
+ )*/
236
237
  const item = toANS104Request(sigs).item
237
238
 
238
239
  if (sigs.slot === "0" || sigs.type === "Process") {
package/esm/index.js CHANGED
@@ -2,5 +2,4 @@ import AR from "./ar.js"
2
2
  import AO from "./ao.js"
3
3
  import HB from "./hb.js"
4
4
  import GQL from "./gql.js"
5
-
6
5
  export { AO, AR, HB, GQL }
package/esm/server.js CHANGED
@@ -88,14 +88,16 @@ class Server {
88
88
  })
89
89
  }
90
90
 
91
- send(res, data) {
92
- if (data.status) res.status(data.status)
93
- if (data.error) {
94
- res.json({ error: data.error })
95
- } else if (data.json) {
96
- res.json(data.json)
97
- } else {
98
- res.send(data.send)
91
+ res(res) {
92
+ return data => {
93
+ if (data.status) res.status(data.status)
94
+ if (data.error) {
95
+ res.json({ error: data.error })
96
+ } else if (data.json) {
97
+ res.json(data.json)
98
+ } else {
99
+ res.send(data.send)
100
+ }
99
101
  }
100
102
  }
101
103
  req(req, device, path) {
@@ -115,11 +117,13 @@ class Server {
115
117
  const port = this.ports[name.toLowerCase()]
116
118
  for (const method in paths) {
117
119
  for (const path of paths[method]) {
118
- app[method](path, async (req, res) =>
119
- this.send(
120
- res,
121
- await this.adaptor.get(this.req(req, name.toLowerCase(), path))
122
- )
120
+ app[method](
121
+ path,
122
+ async (req, res) =>
123
+ await this.adaptor.get(
124
+ this.req(req, name.toLowerCase(), path),
125
+ this.res(res)
126
+ )
123
127
  )
124
128
  }
125
129
  }
package/esm/test.js CHANGED
@@ -9,6 +9,7 @@ import ArMem from "./armem.js"
9
9
  import { dirname } from "./utils.js"
10
10
  import { Testnet, Src, setup, ok, fail } from "./helpers.js"
11
11
  import Server from "./server.js"
12
+ import Adaptor from "./adaptor.js"
12
13
 
13
14
  const blueprint = async pkg => {
14
15
  return readFileSync(resolve(await dirname(), `lua/${pkg}.lua`), "utf8")
@@ -16,6 +17,7 @@ const blueprint = async pkg => {
16
17
  const scheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
17
18
 
18
19
  export {
20
+ Adaptor,
19
21
  Testnet,
20
22
  Server,
21
23
  GQL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.15.7",
3
+ "version": "0.16.1",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"