wao 0.32.2 → 0.33.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/hb.js CHANGED
@@ -7,11 +7,10 @@ exports["default"] = void 0;
7
7
  var _aoconnect = require("@permaweb/aoconnect");
8
8
  var _ramda = require("ramda");
9
9
  var _utils = require("./utils.js");
10
- var _signer = require("./signer.js");
11
- var _send3 = require("./send.js");
10
+ var _hbsig = require("hbsig");
12
11
  var _hyperAos = _interopRequireDefault(require("./lua/hyper-aos.js"));
13
12
  var _aos_wamr = _interopRequireDefault(require("./lua/aos_wamr.js"));
14
- var _httpsig = require("./httpsig.js");
13
+ var _httpsigUtils = require("./httpsig-utils.js");
15
14
  var _excluded = ["path"],
16
15
  _excluded2 = ["action", "tags"],
17
16
  _excluded3 = ["action", "tags"],
@@ -38,11 +37,6 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
38
37
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
39
38
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
40
39
  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); }
41
- var seed = function seed(num) {
42
- var array = new Array(num);
43
- for (var i = 0; i < num; i++) array[i] = Math.floor(Math.random() * 256);
44
- return Buffer.from(array).toString("base64");
45
- };
46
40
  var HB = /*#__PURE__*/function () {
47
41
  function HB() {
48
42
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
@@ -66,7 +60,7 @@ var HB = /*#__PURE__*/function () {
66
60
  case 0:
67
61
  path = encoded.path, msg = _objectWithoutProperties(encoded, _excluded);
68
62
  _context.next = 3;
69
- return (0, _signer.sign)({
63
+ return (0, _hbsig.sign)({
70
64
  jwk: this.jwk,
71
65
  msg: msg,
72
66
  path: path,
@@ -91,18 +85,10 @@ var HB = /*#__PURE__*/function () {
91
85
  this.jwk = jwk;
92
86
  this.signer = (0, _aoconnect.createSigner)(jwk, this.url);
93
87
  this.addr = (0, _utils.toAddr)(jwk.n);
94
- this.sign = (0, _signer.signer)({
88
+ this.sign = (0, _hbsig.signer)({
95
89
  signer: this.signer,
96
90
  url: this.url
97
91
  });
98
- var _connect = (0, _aoconnect.connect)({
99
- MODE: "mainnet",
100
- URL: this.url,
101
- device: "",
102
- signer: this.signer
103
- }),
104
- request = _connect.request;
105
- this._request = request;
106
92
  }
107
93
  }, {
108
94
  key: "setInfo",
@@ -168,7 +154,7 @@ var HB = /*#__PURE__*/function () {
168
154
  while (1) switch (_context4.prev = _context4.next) {
169
155
  case 0:
170
156
  _context4.next = 2;
171
- return (0, _send3.send)(msg);
157
+ return (0, _hbsig.send)(msg);
172
158
  case 2:
173
159
  return _context4.abrupt("return", _context4.sent);
174
160
  case 3:
@@ -888,7 +874,7 @@ var HB = /*#__PURE__*/function () {
888
874
  _context25.t0 = this;
889
875
  _context25.next = 4;
890
876
  return this.commit((0, _ramda.mergeLeft)(tags, {
891
- "random-seed": seed(16),
877
+ "random-seed": (0, _utils.seed)(16),
892
878
  type: "Process",
893
879
  "execution-device": "test-device@1.0",
894
880
  device: "process@1.0",
@@ -1098,43 +1084,24 @@ var HB = /*#__PURE__*/function () {
1098
1084
  }, {
1099
1085
  key: "commit",
1100
1086
  value: function () {
1101
- var _commit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(obj, opts) {
1102
- var msg, hmacId, rsaId, committer, meta, meta2, sigs;
1087
+ var _commit2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(obj, opts) {
1103
1088
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
1104
1089
  while (1) switch (_context30.prev = _context30.next) {
1105
1090
  case 0:
1106
1091
  _context30.next = 2;
1107
- return this.sign(obj, opts);
1092
+ return (0, _hbsig.commit)(obj, _objectSpread(_objectSpread({}, opts), {}, {
1093
+ signer: this.sign
1094
+ }));
1108
1095
  case 2:
1109
- msg = _context30.sent;
1110
- hmacId = (0, _utils.hmacid)(msg.headers);
1111
- rsaId = (0, _utils.rsaid)(msg.headers);
1112
- committer = this.addr;
1113
- meta = {
1114
- alg: "rsa-pss-sha512",
1115
- "commitment-device": "httpsig@1.0"
1116
- };
1117
- meta2 = {
1118
- alg: "hmac-sha256",
1119
- "commitment-device": "httpsig@1.0"
1120
- };
1121
- sigs = {
1122
- signature: msg.headers.signature,
1123
- "signature-input": msg.headers["signature-input"]
1124
- };
1125
- return _context30.abrupt("return", _objectSpread({
1126
- commitments: _defineProperty(_defineProperty({}, rsaId, _objectSpread(_objectSpread({}, meta), {}, {
1127
- committer: committer
1128
- }, sigs)), hmacId, _objectSpread(_objectSpread({}, meta2), sigs))
1129
- }, obj));
1130
- case 10:
1096
+ return _context30.abrupt("return", _context30.sent);
1097
+ case 3:
1131
1098
  case "end":
1132
1099
  return _context30.stop();
1133
1100
  }
1134
1101
  }, _callee30, this);
1135
1102
  }));
1136
1103
  function commit(_x18, _x19) {
1137
- return _commit.apply(this, arguments);
1104
+ return _commit2.apply(this, arguments);
1138
1105
  }
1139
1106
  return commit;
1140
1107
  }()
@@ -1362,7 +1329,7 @@ var HB = /*#__PURE__*/function () {
1362
1329
  body: _context34.t1,
1363
1330
  status: _context34.t2
1364
1331
  };
1365
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, (0, _httpsig.from)(http)), http));
1332
+ return _context34.abrupt("return", _objectSpread(_objectSpread({}, (0, _httpsigUtils.from)(http)), http));
1366
1333
  case 19:
1367
1334
  case "end":
1368
1335
  return _context34.stop();