wao 0.31.2 → 0.32.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 +708 -435
- package/cjs/hb2.js +1505 -0
- package/cjs/hb3.js +1468 -0
- package/cjs/http-message-signatures/httpbis.js +497 -0
- package/cjs/http-message-signatures/index.js +26 -0
- package/cjs/http-message-signatures/structured-header.js +129 -0
- package/cjs/hyperbeam.js +1 -3
- package/cjs/send.js +5 -5
- package/cjs/signer-utils.js +6 -6
- package/cjs/signer.js +12 -15
- package/cjs/workspace/README.md +2 -1
- package/cjs/workspace/package.json +1 -1
- package/cjs/workspace/test/legacynet.test.js +23 -0
- package/cjs/workspace/test/web.test.js +1 -11
- package/esm/hb.js +213 -94
- package/esm/hb2.js +439 -0
- package/esm/hb3.js +418 -0
- package/esm/http-message-signatures/httpbis.js +438 -0
- package/esm/http-message-signatures/index.js +4 -0
- package/esm/http-message-signatures/structured-header.js +105 -0
- package/esm/hyperbeam.js +2 -2
- package/esm/send.js +1 -1
- package/esm/signer-utils.js +1 -1
- package/esm/signer.js +11 -15
- package/esm/workspace/README.md +2 -1
- package/esm/workspace/package.json +1 -1
- package/esm/workspace/test/legacynet.test.js +23 -0
- package/esm/workspace/test/web.test.js +1 -11
- package/package.json +2 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.List = exports.Item = exports.Dictionary = void 0;
|
|
7
|
+
exports.parseHeader = parseHeader;
|
|
8
|
+
exports.quoteString = quoteString;
|
|
9
|
+
var _structuredHeaders = require("structured-headers");
|
|
10
|
+
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); }
|
|
11
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
19
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
+
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); }
|
|
22
|
+
var Dictionary = exports.Dictionary = /*#__PURE__*/function () {
|
|
23
|
+
function Dictionary(input) {
|
|
24
|
+
_classCallCheck(this, Dictionary);
|
|
25
|
+
this.raw = input;
|
|
26
|
+
this.parsed = (0, _structuredHeaders.parseDictionary)(input);
|
|
27
|
+
}
|
|
28
|
+
return _createClass(Dictionary, [{
|
|
29
|
+
key: "toString",
|
|
30
|
+
value: function toString() {
|
|
31
|
+
return this.serialize();
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "serialize",
|
|
35
|
+
value: function serialize() {
|
|
36
|
+
return (0, _structuredHeaders.serializeDictionary)(this.parsed);
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "has",
|
|
40
|
+
value: function has(key) {
|
|
41
|
+
return this.parsed.has(key);
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "get",
|
|
45
|
+
value: function get(key) {
|
|
46
|
+
var value = this.parsed.get(key);
|
|
47
|
+
if (!value) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
if ((0, _structuredHeaders.isInnerList)(value)) {
|
|
51
|
+
return (0, _structuredHeaders.serializeInnerList)(value);
|
|
52
|
+
}
|
|
53
|
+
return (0, _structuredHeaders.serializeItem)(value);
|
|
54
|
+
}
|
|
55
|
+
}]);
|
|
56
|
+
}();
|
|
57
|
+
var List = exports.List = /*#__PURE__*/function () {
|
|
58
|
+
function List(input) {
|
|
59
|
+
_classCallCheck(this, List);
|
|
60
|
+
this.raw = input;
|
|
61
|
+
this.parsed = (0, _structuredHeaders.parseList)(input);
|
|
62
|
+
}
|
|
63
|
+
return _createClass(List, [{
|
|
64
|
+
key: "toString",
|
|
65
|
+
value: function toString() {
|
|
66
|
+
return this.serialize();
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "serialize",
|
|
70
|
+
value: function serialize() {
|
|
71
|
+
return (0, _structuredHeaders.serializeList)(this.parsed);
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
}();
|
|
75
|
+
var Item = exports.Item = /*#__PURE__*/function () {
|
|
76
|
+
function Item(input) {
|
|
77
|
+
_classCallCheck(this, Item);
|
|
78
|
+
this.raw = input;
|
|
79
|
+
this.parsed = (0, _structuredHeaders.parseItem)(input);
|
|
80
|
+
}
|
|
81
|
+
return _createClass(Item, [{
|
|
82
|
+
key: "toString",
|
|
83
|
+
value: function toString() {
|
|
84
|
+
return this.serialize();
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "serialize",
|
|
88
|
+
value: function serialize() {
|
|
89
|
+
return (0, _structuredHeaders.serializeItem)(this.parsed);
|
|
90
|
+
}
|
|
91
|
+
}]);
|
|
92
|
+
}();
|
|
93
|
+
function parseHeader(header) {
|
|
94
|
+
var classes = [List, Dictionary, Item];
|
|
95
|
+
for (var i = 0; i < classes.length; i++) {
|
|
96
|
+
try {
|
|
97
|
+
return new classes[i](header);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
// noop
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
throw new Error("Unable to parse header as structured field");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* This allows consumers of the library to supply field specifications that aren't
|
|
107
|
+
* strictly "structured fields". Really a string must start with a `"` but that won't
|
|
108
|
+
* tend to happen in our configs.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} input
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
function quoteString(input) {
|
|
114
|
+
// if it's not quoted, attempt to quote
|
|
115
|
+
if (!input.startsWith('"')) {
|
|
116
|
+
// try to split the structured field
|
|
117
|
+
var _input$split = input.split(";"),
|
|
118
|
+
_input$split2 = _toArray(_input$split),
|
|
119
|
+
name = _input$split2[0],
|
|
120
|
+
rest = _input$split2.slice(1);
|
|
121
|
+
// no params, just quote the whole thing
|
|
122
|
+
if (!rest.length) {
|
|
123
|
+
return "\"".concat(name, "\"");
|
|
124
|
+
}
|
|
125
|
+
// quote the first part and put the rest back as it was
|
|
126
|
+
return "\"".concat(name, "\";").concat(rest.join(";"));
|
|
127
|
+
}
|
|
128
|
+
return input;
|
|
129
|
+
}
|
package/cjs/hyperbeam.js
CHANGED
|
@@ -36,8 +36,6 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
36
36
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
37
37
|
_ref$port = _ref.port,
|
|
38
38
|
port = _ref$port === void 0 ? 10001 : _ref$port,
|
|
39
|
-
_ref$cu = _ref.cu,
|
|
40
|
-
cu = _ref$cu === void 0 ? 6363 : _ref$cu,
|
|
41
39
|
_ref$as = _ref.as,
|
|
42
40
|
as = _ref$as === void 0 ? [] : _ref$as,
|
|
43
41
|
bundler = _ref.bundler,
|
|
@@ -95,7 +93,7 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
|
|
|
95
93
|
_iterator.f();
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
this.cu = cu
|
|
96
|
+
//this.cu = cu
|
|
99
97
|
this.store_prefix = store_prefix ? "cache-mainnet-" + Math.floor(Math.random() * 10000000) : "cache-mainnet";
|
|
100
98
|
this.p4_lua = p4_lua;
|
|
101
99
|
this.simple_pay = simple_pay;
|
package/cjs/send.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.send = send;
|
|
8
8
|
exports.toHttpSigner = void 0;
|
|
9
9
|
var _base64url = _interopRequireDefault(require("base64url"));
|
|
10
|
-
var
|
|
10
|
+
var _index = require("./http-message-signatures/index.js");
|
|
11
11
|
var _structuredHeaders = require("structured-headers");
|
|
12
12
|
var _httpsig = require("./httpsig.js");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -29,10 +29,10 @@ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(
|
|
|
29
29
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
30
30
|
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); }
|
|
31
31
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
32
|
-
var augmentHeaders =
|
|
33
|
-
createSignatureBase =
|
|
34
|
-
createSigningParameters =
|
|
35
|
-
formatSignatureBase =
|
|
32
|
+
var augmentHeaders = _index.httpbis.augmentHeaders,
|
|
33
|
+
createSignatureBase = _index.httpbis.createSignatureBase,
|
|
34
|
+
createSigningParameters = _index.httpbis.createSigningParameters,
|
|
35
|
+
formatSignatureBase = _index.httpbis.formatSignatureBase;
|
|
36
36
|
function send(_x) {
|
|
37
37
|
return _send.apply(this, arguments);
|
|
38
38
|
}
|
package/cjs/signer-utils.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.toHttpSigner = void 0;
|
|
|
11
11
|
exports.verify = verify;
|
|
12
12
|
var _base64url = _interopRequireDefault(require("base64url"));
|
|
13
13
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
14
|
-
var
|
|
14
|
+
var _index = require("./http-message-signatures/index.js");
|
|
15
15
|
var _structuredHeaders = require("structured-headers");
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
17
|
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; }
|
|
@@ -34,11 +34,11 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
34
34
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
35
35
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
36
36
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
37
|
-
var augmentHeaders =
|
|
38
|
-
createSignatureBase =
|
|
39
|
-
createSigningParameters =
|
|
40
|
-
formatSignatureBase =
|
|
41
|
-
var verifyMessage =
|
|
37
|
+
var augmentHeaders = _index.httpbis.augmentHeaders,
|
|
38
|
+
createSignatureBase = _index.httpbis.createSignatureBase,
|
|
39
|
+
createSigningParameters = _index.httpbis.createSigningParameters,
|
|
40
|
+
formatSignatureBase = _index.httpbis.formatSignatureBase;
|
|
41
|
+
var verifyMessage = _index.httpbis.verifyMessage;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Decode signature-input header to extract all components
|
package/cjs/signer.js
CHANGED
|
@@ -45,7 +45,7 @@ function _sign2() {
|
|
|
45
45
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
46
46
|
while (1) switch (_context2.prev = _context2.next) {
|
|
47
47
|
case 0:
|
|
48
|
-
url = _ref2.url, path = _ref2.path, encoded = _ref2.msg, jwk = _ref2.jwk, _ref2$signPath = _ref2.signPath, signPath = _ref2$signPath === void 0 ?
|
|
48
|
+
url = _ref2.url, path = _ref2.path, encoded = _ref2.msg, jwk = _ref2.jwk, _ref2$signPath = _ref2.signPath, signPath = _ref2$signPath === void 0 ? true : _ref2$signPath;
|
|
49
49
|
signer = (0, _aoconnect.createSigner)(jwk, url);
|
|
50
50
|
_encoded$body = encoded.body, body = _encoded$body === void 0 ? null : _encoded$body, headers = _objectWithoutProperties(encoded, _excluded2);
|
|
51
51
|
_enc = {
|
|
@@ -75,16 +75,17 @@ function _sign(_x2) {
|
|
|
75
75
|
}
|
|
76
76
|
function _sign3() {
|
|
77
77
|
_sign3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
|
|
78
|
-
var encoded, signer, path, url, _ref3$method, method, _ref3$_path, _path, headersObj, body, _url, bodySize, lowercaseHeaders, _i, _Object$entries, _Object$entries$_i, key, value, bodyKeys, signingFields, signedRequest, finalHeaders, _i2, _Object$entries2, _Object$entries2$_i, _key, _value, result;
|
|
78
|
+
var encoded, signer, path, url, _ref3$method, method, _ref3$_path, _path, headersObj, body, url_path, _url, bodySize, lowercaseHeaders, _i, _Object$entries, _Object$entries$_i, key, value, bodyKeys, isPath, signingFields, signedRequest, finalHeaders, _i2, _Object$entries2, _Object$entries2$_i, _key, _value, result;
|
|
79
79
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
80
80
|
while (1) switch (_context3.prev = _context3.next) {
|
|
81
81
|
case 0:
|
|
82
|
-
encoded = _ref3.encoded, signer = _ref3.signer, path = _ref3.path, url = _ref3.url, _ref3$method = _ref3.method, method = _ref3$method === void 0 ? "POST" : _ref3$method, _ref3$_path = _ref3._path, _path = _ref3$_path === void 0 ?
|
|
82
|
+
encoded = _ref3.encoded, signer = _ref3.signer, path = _ref3.path, url = _ref3.url, _ref3$method = _ref3.method, method = _ref3$method === void 0 ? "POST" : _ref3$method, _ref3$_path = _ref3._path, _path = _ref3$_path === void 0 ? true : _ref3$_path;
|
|
83
83
|
headersObj = encoded ? encoded.headers : {};
|
|
84
84
|
body = encoded ? encoded.body : undefined;
|
|
85
|
+
url_path = typeof _path === "string" ? _path : path;
|
|
85
86
|
_url = joinUrl({
|
|
86
87
|
url: url,
|
|
87
|
-
path:
|
|
88
|
+
path: url_path
|
|
88
89
|
});
|
|
89
90
|
headersObj["path"] = path;
|
|
90
91
|
if (body && !headersObj["content-length"]) {
|
|
@@ -99,17 +100,13 @@ function _sign3() {
|
|
|
99
100
|
bodyKeys = headersObj["body-keys"] ? headersObj["body-keys"].replace(/"/g, "").split(",").map(function (k) {
|
|
100
101
|
return k.trim();
|
|
101
102
|
}) : [];
|
|
103
|
+
isPath = false;
|
|
102
104
|
signingFields = Object.keys(lowercaseHeaders).filter(function (key) {
|
|
105
|
+
if (key === "path") isPath = true;
|
|
103
106
|
return key !== "body-keys" && key !== "path" && !bodyKeys.includes(key);
|
|
104
107
|
});
|
|
105
|
-
if (_path) signingFields.push("path");
|
|
106
|
-
|
|
107
|
-
if (signingFields.length === 0 && !body) {
|
|
108
|
-
//lowercaseHeaders["content-length"] = "0"
|
|
109
|
-
//signingFields.push("content-length")
|
|
110
|
-
}
|
|
111
|
-
*/
|
|
112
|
-
_context3.next = 13;
|
|
108
|
+
if (_path !== false && isPath) signingFields.push("@path");
|
|
109
|
+
_context3.next = 15;
|
|
113
110
|
return (0, _send.toHttpSigner)(signer)({
|
|
114
111
|
request: {
|
|
115
112
|
url: _url,
|
|
@@ -118,7 +115,7 @@ function _sign3() {
|
|
|
118
115
|
},
|
|
119
116
|
fields: signingFields
|
|
120
117
|
});
|
|
121
|
-
case
|
|
118
|
+
case 15:
|
|
122
119
|
signedRequest = _context3.sent;
|
|
123
120
|
finalHeaders = {};
|
|
124
121
|
for (_i2 = 0, _Object$entries2 = Object.entries(headersObj); _i2 < _Object$entries2.length; _i2++) {
|
|
@@ -137,7 +134,7 @@ function _sign3() {
|
|
|
137
134
|
};
|
|
138
135
|
if (body) result.body = body;
|
|
139
136
|
return _context3.abrupt("return", result);
|
|
140
|
-
case
|
|
137
|
+
case 24:
|
|
141
138
|
case "end":
|
|
142
139
|
return _context3.stop();
|
|
143
140
|
}
|
|
@@ -167,7 +164,7 @@ function signer(config) {
|
|
|
167
164
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
168
165
|
while (1) switch (_context.prev = _context.next) {
|
|
169
166
|
case 0:
|
|
170
|
-
_ref5 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref5$encoded = _ref5.encoded, _encoded = _ref5$encoded === void 0 ? false : _ref5$encoded, _ref5$path = _ref5.path, _path = _ref5$path === void 0 ?
|
|
167
|
+
_ref5 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref5$encoded = _ref5.encoded, _encoded = _ref5$encoded === void 0 ? false : _ref5$encoded, _ref5$path = _ref5.path, _path = _ref5$path === void 0 ? true : _ref5$path;
|
|
171
168
|
_fields$path = fields.path, path = _fields$path === void 0 ? "/relay/process" : _fields$path, _fields$method = fields.method, method = _fields$method === void 0 ? "POST" : _fields$method, aoFields = _objectWithoutProperties(fields, _excluded);
|
|
172
169
|
if (!_encoded) {
|
|
173
170
|
_context.next = 6;
|
package/cjs/workspace/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
#### 1. Create an APP
|
|
2
3
|
|
|
3
4
|
```bash
|
|
@@ -17,7 +18,7 @@ Go to [the web app](https://preview.wao.eco) and open `Networks`, then click `Pr
|
|
|
17
18
|
#### 4. Run Test
|
|
18
19
|
|
|
19
20
|
```bash
|
|
20
|
-
yarn test test/test.js
|
|
21
|
+
yarn test test/hyperbeam.test.js
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
#### 5. Deploy a Process to AO Testnet
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assert from "assert"
|
|
2
|
+
import { describe, it } from "node:test"
|
|
3
|
+
import { readFileSync } from "fs"
|
|
4
|
+
import { resolve } from "path"
|
|
5
|
+
|
|
6
|
+
import { AO, acc } from "wao/test" // in-memory test
|
|
7
|
+
|
|
8
|
+
const src_data = readFileSync(
|
|
9
|
+
resolve(import.meta.dirname, "../src/counter.lua"),
|
|
10
|
+
"utf8"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
describe("WAO Legacynet", function () {
|
|
14
|
+
// lightning-fast testing in memory
|
|
15
|
+
it("should spawn a process and send messages in memory", async () => {
|
|
16
|
+
const ao = await new AO().init(acc[0])
|
|
17
|
+
const { p, pid } = await ao.deploy({ src_data, scheduler: acc[0].addr })
|
|
18
|
+
|
|
19
|
+
assert.equal(await p.d("Hello", false), "Hello, World!")
|
|
20
|
+
assert.equal(await p.m("Inc", false), "Incremented!")
|
|
21
|
+
assert.equal(await p.d("Get", false), "1")
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -11,17 +11,7 @@ const src_data = readFileSync(
|
|
|
11
11
|
"utf8"
|
|
12
12
|
)
|
|
13
13
|
|
|
14
|
-
describe("WAO", function () {
|
|
15
|
-
// lightning-fast testing in memory
|
|
16
|
-
it("should spawn a process and send messages in memory", async () => {
|
|
17
|
-
const ao = await new AO().init(acc[0])
|
|
18
|
-
const { p, pid } = await ao.deploy({ src_data, scheduler: acc[0].addr })
|
|
19
|
-
|
|
20
|
-
assert.equal(await p.d("Hello", false), "Hello, World!")
|
|
21
|
-
assert.equal(await p.m("Inc", false), "Incremented!")
|
|
22
|
-
assert.equal(await p.d("Get", false), "1")
|
|
23
|
-
})
|
|
24
|
-
|
|
14
|
+
describe("WAO the Web", function () {
|
|
25
15
|
// WAO Proxy must be running on your computer => "npx wao proxy"
|
|
26
16
|
it("should spawn a process and send messages to the browser", async () => {
|
|
27
17
|
// connect with 4000 - 4004 ports
|