wao 0.15.7 → 0.16.0
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 +87 -93
- package/cjs/index.js +7 -0
- package/cjs/server.js +19 -20
- package/esm/adaptor.js +9 -8
- package/esm/index.js +2 -2
- package/esm/server.js +17 -13
- package/package.json +5 -1
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
|
-
|
|
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.
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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,
|
|
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
|
-
|
|
673
|
+
key = headerMatch[1];
|
|
672
674
|
value = headerMatch[2];
|
|
673
|
-
sigs[
|
|
674
|
-
currentKey =
|
|
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
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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 =
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
keyLookup:
|
|
708
|
-
|
|
709
|
-
|
|
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 =
|
|
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 =
|
|
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
|
|
735
|
+
case 39:
|
|
742
736
|
res = _context19.sent;
|
|
743
|
-
_context19.next =
|
|
737
|
+
_context19.next = 48;
|
|
744
738
|
break;
|
|
745
|
-
case
|
|
739
|
+
case 42:
|
|
746
740
|
if (!(sigs.type === "Message")) {
|
|
747
|
-
_context19.next =
|
|
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 =
|
|
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
|
|
761
|
+
case 47:
|
|
768
762
|
_res2 = _context19.sent;
|
|
769
|
-
case
|
|
770
|
-
_context19.next =
|
|
763
|
+
case 48:
|
|
764
|
+
_context19.next = 53;
|
|
771
765
|
break;
|
|
772
|
-
case
|
|
773
|
-
_context19.prev =
|
|
774
|
-
_context19.t1 = _context19["catch"](
|
|
766
|
+
case 50:
|
|
767
|
+
_context19.prev = 50;
|
|
768
|
+
_context19.t1 = _context19["catch"](32);
|
|
775
769
|
console.log(_context19.t1);
|
|
776
|
-
case
|
|
770
|
+
case 53:
|
|
777
771
|
return _context19.abrupt("return", {
|
|
778
772
|
send: "Success"
|
|
779
773
|
});
|
|
780
|
-
case
|
|
774
|
+
case 54:
|
|
781
775
|
case "end":
|
|
782
776
|
return _context19.stop();
|
|
783
777
|
}
|
|
784
|
-
}, _callee19, this, [[9, 23, 26, 29], [
|
|
778
|
+
}, _callee19, this, [[9, 23, 26, 29], [32, 50]]);
|
|
785
779
|
}));
|
|
786
|
-
function bd_post_tx(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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 (
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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/index.js
CHANGED
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "AR", {
|
|
|
15
15
|
return _ar["default"];
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "Adaptor", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _adaptor["default"];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "GQL", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
@@ -31,4 +37,5 @@ var _ar = _interopRequireDefault(require("./ar.js"));
|
|
|
31
37
|
var _ao = _interopRequireDefault(require("./ao.js"));
|
|
32
38
|
var _hb = _interopRequireDefault(require("./hb.js"));
|
|
33
39
|
var _gql = _interopRequireDefault(require("./gql.js"));
|
|
40
|
+
var _adaptor = _interopRequireDefault(require("./adaptor.js"));
|
|
34
41
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
package/cjs/server.js
CHANGED
|
@@ -137,18 +137,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}, {
|
|
140
|
-
key: "
|
|
141
|
-
value: function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return
|
|
187
|
-
case
|
|
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/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
|
-
|
|
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
package/esm/server.js
CHANGED
|
@@ -88,14 +88,16 @@ class Server {
|
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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](
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
await this.adaptor.get(
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wao",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"wao": "./cjs/cli.js",
|
|
6
6
|
"wao-esm": "./esm/cli.js"
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"require": "./cjs/test.js",
|
|
21
21
|
"import": "./esm/test.js"
|
|
22
22
|
},
|
|
23
|
+
"./server": {
|
|
24
|
+
"require": "./cjs/server.js",
|
|
25
|
+
"import": "./esm/server.js"
|
|
26
|
+
},
|
|
23
27
|
"./web": {
|
|
24
28
|
"require": "./cjs/web.js",
|
|
25
29
|
"import": "./esm/web.js"
|