@ethersphere/bee-js 3.3.0 → 3.3.2-pre.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/dist/cjs/chunk/bmt.js +7 -2
- package/dist/cjs/chunk/signer.js +9 -4
- package/dist/cjs/modules/debug/status.js +8 -8
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types/debug.js +1 -0
- package/dist/cjs/types/ky-options.js +8 -0
- package/dist/cjs/types/ky-universal/common.js +8 -0
- package/dist/cjs/types/ky-universal/hooks.js +8 -0
- package/dist/cjs/types/ky-universal/retry.js +8 -0
- package/dist/cjs/utils/eth.js +8 -3
- package/dist/cjs/utils/hash.js +7 -2
- package/dist/cjs/utils/stream.js +14 -5
- package/dist/index.browser.min.js +3 -0
- package/dist/index.browser.min.js.LICENSE.txt +60 -0
- package/dist/index.browser.min.js.map +1 -0
- package/dist/mjs/bee-debug.js +608 -508
- package/dist/mjs/bee.js +935 -836
- package/dist/mjs/chunk/bmt.js +34 -24
- package/dist/mjs/chunk/cac.js +24 -22
- package/dist/mjs/chunk/serialize.js +9 -9
- package/dist/mjs/chunk/signer.js +92 -73
- package/dist/mjs/chunk/soc.js +78 -66
- package/dist/mjs/chunk/span.js +19 -16
- package/dist/mjs/feed/index.js +110 -101
- package/dist/mjs/feed/json.js +21 -17
- package/dist/mjs/feed/topic.js +18 -17
- package/dist/mjs/feed/type.js +5 -5
- package/dist/mjs/index.js +7 -7
- package/dist/mjs/modules/bytes.js +33 -30
- package/dist/mjs/modules/bzz.js +80 -77
- package/dist/mjs/modules/chunk.js +22 -20
- package/dist/mjs/modules/debug/balance.js +26 -22
- package/dist/mjs/modules/debug/chequebook.js +84 -65
- package/dist/mjs/modules/debug/chunk.js +15 -13
- package/dist/mjs/modules/debug/connectivity.js +34 -34
- package/dist/mjs/modules/debug/settlements.js +14 -12
- package/dist/mjs/modules/debug/stamps.js +52 -47
- package/dist/mjs/modules/debug/states.js +16 -14
- package/dist/mjs/modules/debug/status.js +58 -38
- package/dist/mjs/modules/debug/tag.js +8 -7
- package/dist/mjs/modules/debug/transactions.js +31 -25
- package/dist/mjs/modules/feed.js +39 -33
- package/dist/mjs/modules/pinning.js +34 -28
- package/dist/mjs/modules/pss.js +18 -14
- package/dist/mjs/modules/soc.js +18 -15
- package/dist/mjs/modules/status.js +6 -5
- package/dist/mjs/modules/stewardship.js +13 -12
- package/dist/mjs/modules/tag.js +38 -30
- package/dist/mjs/package.json +1 -0
- package/dist/mjs/types/debug.js +6 -4
- package/dist/mjs/types/index.js +6 -2
- package/dist/mjs/types/ky-options.js +7 -0
- package/dist/mjs/types/ky-universal/common.js +7 -0
- package/dist/mjs/types/ky-universal/hooks.js +7 -0
- package/dist/mjs/types/ky-universal/retry.js +7 -0
- package/dist/mjs/utils/bytes.js +32 -26
- package/dist/mjs/utils/collection.browser.js +4 -3
- package/dist/mjs/utils/collection.js +47 -35
- package/dist/mjs/utils/collection.node.js +53 -42
- package/dist/mjs/utils/data.browser.js +64 -48
- package/dist/mjs/utils/data.js +29 -25
- package/dist/mjs/utils/error.js +47 -39
- package/dist/mjs/utils/eth.js +119 -104
- package/dist/mjs/utils/expose.js +9 -9
- package/dist/mjs/utils/file.js +22 -19
- package/dist/mjs/utils/hash.js +10 -5
- package/dist/mjs/utils/headers.js +43 -39
- package/dist/mjs/utils/hex.js +78 -63
- package/dist/mjs/utils/http.js +119 -100
- package/dist/mjs/utils/merge.js +26 -20
- package/dist/mjs/utils/pss.js +8 -6
- package/dist/mjs/utils/stamps.js +7 -3
- package/dist/mjs/utils/stream.js +107 -82
- package/dist/mjs/utils/tar.js +17 -14
- package/dist/mjs/utils/type.js +249 -209
- package/dist/mjs/utils/uint64.js +16 -16
- package/dist/mjs/utils/url.js +32 -25
- package/dist/types/bee-debug.d.ts +3 -3
- package/dist/types/modules/debug/stamps.d.ts +3 -3
- package/dist/types/modules/debug/status.d.ts +3 -3
- package/dist/types/types/debug.d.ts +1 -0
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/ky-options.d.ts +221 -0
- package/dist/types/types/ky-universal/common.d.ts +13 -0
- package/dist/types/types/ky-universal/hooks.d.ts +92 -0
- package/dist/types/types/ky-universal/retry.d.ts +38 -0
- package/dist/types/utils/stamps.d.ts +2 -2
- package/dist/types/utils/stream.d.ts +11 -8
- package/package.json +22 -19
- package/dist/index.js +0 -28326
- package/dist/index.js.map +0 -1
package/dist/cjs/chunk/bmt.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.bmtHash = void 0;
|
|
4
|
-
|
|
7
|
+
// For ESM compatibility
|
|
8
|
+
const js_sha3_1 = __importDefault(require("js-sha3"));
|
|
9
|
+
const { keccak256 } = js_sha3_1.default;
|
|
5
10
|
const error_1 = require("../utils/error");
|
|
6
11
|
const hash_1 = require("../utils/hash");
|
|
7
12
|
const MAX_CHUNK_PAYLOAD_SIZE = 4096;
|
|
@@ -41,7 +46,7 @@ function bmtRootHash(payload) {
|
|
|
41
46
|
const output = new Uint8Array(input.length / 2);
|
|
42
47
|
// in each round we hash the segment pairs together
|
|
43
48
|
for (let offset = 0; offset < input.length; offset += SEGMENT_PAIR_SIZE) {
|
|
44
|
-
const hashNumbers =
|
|
49
|
+
const hashNumbers = keccak256.array(input.slice(offset, offset + SEGMENT_PAIR_SIZE));
|
|
45
50
|
output.set(hashNumbers, offset / 2);
|
|
46
51
|
}
|
|
47
52
|
input = output;
|
package/dist/cjs/chunk/signer.js
CHANGED
|
@@ -8,9 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.sign = exports.makeSigner = exports.assertSigner = exports.makePrivateKeySigner = exports.recoverAddress = exports.defaultSign = void 0;
|
|
13
|
-
|
|
16
|
+
// For ESM compatibility
|
|
17
|
+
const elliptic_1 = __importDefault(require("elliptic"));
|
|
18
|
+
const { ec } = elliptic_1.default;
|
|
14
19
|
const error_1 = require("../utils/error");
|
|
15
20
|
const bytes_1 = require("../utils/bytes");
|
|
16
21
|
const hash_1 = require("../utils/hash");
|
|
@@ -31,7 +36,7 @@ function hashWithEthereumPrefix(data) {
|
|
|
31
36
|
* @param privateKey The private key used for signing the data
|
|
32
37
|
*/
|
|
33
38
|
function defaultSign(data, privateKey) {
|
|
34
|
-
const curve = new
|
|
39
|
+
const curve = new ec('secp256k1');
|
|
35
40
|
const keyPair = curve.keyFromPrivate(privateKey);
|
|
36
41
|
const hashedDigest = hashWithEthereumPrefix(data);
|
|
37
42
|
const sigRaw = curve.sign(hashedDigest, keyPair, { canonical: true, pers: undefined });
|
|
@@ -62,7 +67,7 @@ function publicKeyToAddress(pubKey) {
|
|
|
62
67
|
* @returns the recovered address
|
|
63
68
|
*/
|
|
64
69
|
function recoverAddress(signature, digest) {
|
|
65
|
-
const curve = new
|
|
70
|
+
const curve = new ec('secp256k1');
|
|
66
71
|
const sig = {
|
|
67
72
|
r: signature.slice(0, 32),
|
|
68
73
|
s: signature.slice(32, 64),
|
|
@@ -79,7 +84,7 @@ exports.recoverAddress = recoverAddress;
|
|
|
79
84
|
* @param privateKey The private key
|
|
80
85
|
*/
|
|
81
86
|
function makePrivateKeySigner(privateKey) {
|
|
82
|
-
const curve = new
|
|
87
|
+
const curve = new ec('secp256k1');
|
|
83
88
|
const keyPair = curve.keyFromPrivate(privateKey);
|
|
84
89
|
const address = publicKeyToAddress(keyPair.getPublic());
|
|
85
90
|
return {
|
|
@@ -14,12 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getHealth = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
16
16
|
const http_1 = require("../../utils/http");
|
|
17
|
-
const
|
|
17
|
+
const major_js_1 = __importDefault(require("semver/functions/major.js"));
|
|
18
18
|
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
19
19
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
20
|
-
exports.SUPPORTED_BEE_VERSION_EXACT = '1.
|
|
21
|
-
exports.SUPPORTED_API_VERSION = '
|
|
22
|
-
exports.SUPPORTED_DEBUG_API_VERSION = '
|
|
20
|
+
exports.SUPPORTED_BEE_VERSION_EXACT = '1.5.0-dda5606e';
|
|
21
|
+
exports.SUPPORTED_API_VERSION = '3.0.0';
|
|
22
|
+
exports.SUPPORTED_DEBUG_API_VERSION = '2.0.0';
|
|
23
23
|
exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
24
24
|
const NODE_INFO_URL = 'node';
|
|
25
25
|
const HEALTH_URL = 'health';
|
|
@@ -97,7 +97,7 @@ exports.isSupportedExactVersion = isSupportedExactVersion;
|
|
|
97
97
|
function isSupportedMainApiVersion(ky) {
|
|
98
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
99
|
const { apiVersion } = yield getHealth(ky);
|
|
100
|
-
return (0,
|
|
100
|
+
return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
|
|
@@ -112,7 +112,7 @@ exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
|
|
|
112
112
|
function isSupportedDebugApiVersion(ky) {
|
|
113
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
114
|
const { debugApiVersion } = yield getHealth(ky);
|
|
115
|
-
return (0,
|
|
115
|
+
return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
|
|
@@ -126,8 +126,8 @@ exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
|
|
|
126
126
|
function isSupportedApiVersion(ky) {
|
|
127
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
128
|
const { apiVersion, debugApiVersion } = yield getHealth(ky);
|
|
129
|
-
return ((0,
|
|
130
|
-
(0,
|
|
129
|
+
return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
|
|
130
|
+
(0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
exports.isSupportedApiVersion = isSupportedApiVersion;
|
package/dist/cjs/package.json
CHANGED
package/dist/cjs/types/debug.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
4
|
+
*
|
|
5
|
+
* @author https://github.com/sindresorhus
|
|
6
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
4
|
+
*
|
|
5
|
+
* @author https://github.com/sindresorhus
|
|
6
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
4
|
+
*
|
|
5
|
+
* @author https://github.com/sindresorhus
|
|
6
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Types extracted from Ky as a backport for older Ky non-ESM version
|
|
4
|
+
*
|
|
5
|
+
* @author https://github.com/sindresorhus
|
|
6
|
+
* @licence MIT https://github.com/sindresorhus/ky/blob/main/license
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/cjs/utils/eth.js
CHANGED
|
@@ -8,9 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.makeEthereumWalletSigner = exports.ethToSwarmAddress = exports.fromLittleEndian = exports.toLittleEndian = exports.isHexEthAddress = exports.makeHexEthAddress = exports.makeEthAddress = void 0;
|
|
13
|
-
|
|
16
|
+
// For ESM compatibility
|
|
17
|
+
const js_sha3_1 = __importDefault(require("js-sha3"));
|
|
18
|
+
const { keccak256, sha3_256 } = js_sha3_1.default;
|
|
14
19
|
const hex_1 = require("./hex");
|
|
15
20
|
const bytes_1 = require("./bytes");
|
|
16
21
|
const ETH_ADDR_BYTES_LENGTH = 20;
|
|
@@ -60,7 +65,7 @@ function isValidChecksummedEthAddress(address) {
|
|
|
60
65
|
// Check for valid case insensitive hex type string, 40 chars
|
|
61
66
|
const addr = (0, hex_1.makeHexString)(address, ETH_ADDR_HEX_LENGTH);
|
|
62
67
|
// Check the checksum
|
|
63
|
-
const addressHash =
|
|
68
|
+
const addressHash = keccak256(addr.toLowerCase());
|
|
64
69
|
for (let i = 0; i < 40; i += 1) {
|
|
65
70
|
// the nth letter should be uppercase if the nth digit of casemap is 1
|
|
66
71
|
if ((parseInt(addressHash[i], 16) > 7 && addr[i].toUpperCase() !== addr[i]) ||
|
|
@@ -159,7 +164,7 @@ function ethToSwarmAddress(ethAddress, networkId = 1) {
|
|
|
159
164
|
assertSwarmNetworkId(networkId);
|
|
160
165
|
const hex = `${(0, hex_1.makeHexString)(ethAddress)}${toLittleEndian(networkId, 16)}`;
|
|
161
166
|
(0, hex_1.assertHexString)(hex);
|
|
162
|
-
const overlayAddress =
|
|
167
|
+
const overlayAddress = sha3_256((0, hex_1.hexToBytes)(hex));
|
|
163
168
|
return overlayAddress;
|
|
164
169
|
}
|
|
165
170
|
exports.ethToSwarmAddress = ethToSwarmAddress;
|
package/dist/cjs/utils/hash.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.keccak256Hash = void 0;
|
|
4
|
-
|
|
7
|
+
// For ESM compatibility
|
|
8
|
+
const js_sha3_1 = __importDefault(require("js-sha3"));
|
|
9
|
+
const { keccak256 } = js_sha3_1.default;
|
|
5
10
|
/**
|
|
6
11
|
* Helper function for calculating the keccak256 hash with
|
|
7
12
|
* correct types.
|
|
@@ -9,7 +14,7 @@ const js_sha3_1 = require("js-sha3");
|
|
|
9
14
|
* @param messages Any number of messages (strings, byte arrays etc.)
|
|
10
15
|
*/
|
|
11
16
|
function keccak256Hash(...messages) {
|
|
12
|
-
const hasher =
|
|
17
|
+
const hasher = keccak256.create();
|
|
13
18
|
messages.forEach(bytes => hasher.update(bytes));
|
|
14
19
|
return Uint8Array.from(hasher.digest());
|
|
15
20
|
}
|
package/dist/cjs/utils/stream.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeToReadableStream = exports.readableWebToNode = exports.readableNodeToWeb = exports.isNodeReadable = exports.isReadableStream = exports.isReadable = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
4
5
|
const type_1 = require("./type");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
6
|
+
const web_streams_polyfill_1 = require("web-streams-polyfill");
|
|
7
|
+
const NodeReadable = stream_1.Readable || class {
|
|
8
|
+
};
|
|
7
9
|
/**
|
|
8
10
|
* Validates if passed object is either browser's ReadableStream
|
|
9
11
|
* or Node's Readable.
|
|
@@ -51,7 +53,7 @@ exports.isNodeReadable = isNodeReadable;
|
|
|
51
53
|
* @param nodeStream
|
|
52
54
|
*/
|
|
53
55
|
function readableNodeToWeb(nodeStream) {
|
|
54
|
-
return new
|
|
56
|
+
return new web_streams_polyfill_1.ReadableStream({
|
|
55
57
|
start(controller) {
|
|
56
58
|
nodeStream.pause();
|
|
57
59
|
nodeStream.on('data', chunk => {
|
|
@@ -82,7 +84,7 @@ exports.readableNodeToWeb = readableNodeToWeb;
|
|
|
82
84
|
* @author https://github.com/gwicke
|
|
83
85
|
* @licence Apache License 2.0 https://github.com/gwicke/node-web-streams/blob/master/LICENSE
|
|
84
86
|
*/
|
|
85
|
-
class NodeReadableWrapper extends
|
|
87
|
+
class NodeReadableWrapper extends NodeReadable {
|
|
86
88
|
constructor(webStream, options) {
|
|
87
89
|
super(options);
|
|
88
90
|
this._webStream = webStream;
|
|
@@ -115,13 +117,20 @@ class NodeReadableWrapper extends readable_stream_1.Readable {
|
|
|
115
117
|
* Function that converts WHATWG ReadableStream into Node's Readable
|
|
116
118
|
*
|
|
117
119
|
* Taken over from https://github.com/gwicke/node-web-streams/blob/master/lib/conversions.js
|
|
118
|
-
* Because it uses forked web-streams-polyfill that
|
|
120
|
+
* Because it uses forked web-streams-polyfill that is outdated.
|
|
121
|
+
*
|
|
122
|
+
* **Warning!**
|
|
123
|
+
* If you want to use this function in browser you have to polyfill `stream` package with your bundler.
|
|
119
124
|
*
|
|
120
125
|
* @author https://github.com/gwicke
|
|
121
126
|
* @licence Apache License 2.0 https://github.com/gwicke/node-web-streams/blob/master/LICENSE
|
|
122
127
|
* @param webStream
|
|
128
|
+
* @param options
|
|
123
129
|
*/
|
|
124
130
|
function readableWebToNode(webStream, options) {
|
|
131
|
+
if (!stream_1.Readable) {
|
|
132
|
+
throw new Error("The Node's Readable is not available! If you are running this in browser you have to polyfill 'stream' package!");
|
|
133
|
+
}
|
|
125
134
|
return new NodeReadableWrapper(webStream, options);
|
|
126
135
|
}
|
|
127
136
|
exports.readableWebToNode = readableWebToNode;
|