@ethersphere/bee-js 3.3.2 → 3.3.4
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/LICENSE +24 -22
- package/dist/cjs/modules/debug/status.js +1 -1
- package/dist/cjs/utils/data.browser.js +6 -10
- package/dist/cjs/utils/data.js +4 -6
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +294 -189
- package/dist/mjs/bee.js +316 -237
- package/dist/mjs/chunk/signer.js +46 -12
- package/dist/mjs/chunk/soc.js +71 -31
- package/dist/mjs/chunk/span.js +1 -1
- package/dist/mjs/feed/index.js +86 -42
- package/dist/mjs/feed/json.js +46 -10
- package/dist/mjs/index.js +2 -1
- package/dist/mjs/modules/bytes.js +61 -24
- package/dist/mjs/modules/bzz.js +96 -58
- package/dist/mjs/modules/chunk.js +51 -16
- package/dist/mjs/modules/debug/balance.js +60 -20
- package/dist/mjs/modules/debug/chequebook.js +115 -67
- package/dist/mjs/modules/debug/chunk.js +47 -11
- package/dist/mjs/modules/debug/connectivity.js +76 -32
- package/dist/mjs/modules/debug/settlements.js +46 -10
- package/dist/mjs/modules/debug/stamps.js +91 -47
- package/dist/mjs/modules/debug/states.js +48 -12
- package/dist/mjs/modules/debug/status.js +98 -50
- package/dist/mjs/modules/debug/tag.js +39 -5
- package/dist/mjs/modules/debug/transactions.js +65 -25
- package/dist/mjs/modules/feed.js +50 -16
- package/dist/mjs/modules/pinning.js +67 -27
- package/dist/mjs/modules/pss.js +44 -10
- package/dist/mjs/modules/soc.js +47 -14
- package/dist/mjs/modules/status.js +37 -3
- package/dist/mjs/modules/stewardship.js +46 -10
- package/dist/mjs/modules/tag.js +73 -31
- package/dist/mjs/utils/collection.browser.js +41 -4
- package/dist/mjs/utils/collection.js +45 -11
- package/dist/mjs/utils/collection.node.js +137 -42
- package/dist/mjs/utils/data.browser.js +88 -53
- package/dist/mjs/utils/data.js +57 -22
- package/dist/mjs/utils/error.js +0 -9
- package/dist/mjs/utils/eth.js +68 -32
- package/dist/mjs/utils/file.js +42 -8
- package/dist/mjs/utils/headers.js +4 -4
- package/dist/mjs/utils/http.js +110 -64
- package/dist/mjs/utils/merge.js +2 -2
- package/dist/mjs/utils/stream.js +0 -4
- package/dist/mjs/utils/type.js +6 -6
- package/dist/types/modules/debug/status.d.ts +1 -1
- package/dist/types/types/debug.d.ts +19 -0
- package/dist/types/utils/data.browser.d.ts +0 -1
- package/dist/types/utils/data.d.ts +2 -2
- package/package.json +14 -13
package/dist/mjs/utils/http.js
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) {
|
|
3
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
+
resolve(value);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) {
|
|
10
|
+
try {
|
|
11
|
+
step(generator.next(value));
|
|
12
|
+
} catch (e) {
|
|
13
|
+
reject(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function rejected(value) {
|
|
18
|
+
try {
|
|
19
|
+
step(generator["throw"](value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function step(result) {
|
|
26
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
34
|
+
var t = {};
|
|
35
|
+
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
37
|
+
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
39
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
|
|
1
44
|
import { BeeError, BeeNotAJsonError, BeeRequestError, BeeResponseError } from "./error.js";
|
|
2
45
|
import kyFactory from 'ky-universal';
|
|
3
46
|
import { normalizeToReadableStream } from "./stream.js";
|
|
@@ -34,19 +77,19 @@ function wrapRequest(request) {
|
|
|
34
77
|
}
|
|
35
78
|
|
|
36
79
|
export function wrapRequestClosure(cb) {
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
};
|
|
80
|
+
return request => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
yield cb(wrapRequest(request));
|
|
82
|
+
});
|
|
40
83
|
}
|
|
41
84
|
export function wrapResponseClosure(cb) {
|
|
42
|
-
return
|
|
43
|
-
|
|
85
|
+
return (request, options, response) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
yield cb({
|
|
44
87
|
headers: headersToObject(response.headers),
|
|
45
88
|
status: response.status,
|
|
46
89
|
statusText: response.statusText,
|
|
47
90
|
request: wrapRequest(request)
|
|
48
91
|
});
|
|
49
|
-
};
|
|
92
|
+
});
|
|
50
93
|
}
|
|
51
94
|
/**
|
|
52
95
|
* Filters out entries that has undefined value from headers object.
|
|
@@ -82,73 +125,76 @@ export function filterHeaders(obj) {
|
|
|
82
125
|
* @param config
|
|
83
126
|
*/
|
|
84
127
|
|
|
85
|
-
export
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
128
|
+
export function http(ky, config) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
try {
|
|
131
|
+
const {
|
|
132
|
+
path,
|
|
133
|
+
responseType
|
|
134
|
+
} = config,
|
|
135
|
+
kyConfig = __rest(config, ["path", "responseType"]);
|
|
136
|
+
|
|
137
|
+
const response = yield ky(path, Object.assign(Object.assign({}, kyConfig), {
|
|
138
|
+
searchParams: filterHeaders(kyConfig.searchParams)
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
switch (responseType) {
|
|
142
|
+
case 'stream':
|
|
143
|
+
if (!response.body) {
|
|
144
|
+
throw new BeeError('Response was expected to get data but did not get any!');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
response.data = normalizeToReadableStream(response.body);
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
case 'arraybuffer':
|
|
151
|
+
response.data = yield response.arrayBuffer();
|
|
152
|
+
break;
|
|
153
|
+
|
|
154
|
+
case 'json':
|
|
155
|
+
try {
|
|
156
|
+
response.data = yield response.json();
|
|
157
|
+
} catch (e) {
|
|
158
|
+
throw new BeeNotAJsonError();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
default:
|
|
164
|
+
break;
|
|
165
|
+
// If responseType is not set, then no data are expected
|
|
166
|
+
}
|
|
95
167
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
168
|
+
return response;
|
|
169
|
+
} catch (e) {
|
|
170
|
+
// Passthrough thrown errors
|
|
171
|
+
if (e instanceof BeeNotAJsonError) {
|
|
172
|
+
throw e;
|
|
173
|
+
}
|
|
101
174
|
|
|
102
|
-
|
|
103
|
-
|
|
175
|
+
if (isHttpError(e)) {
|
|
176
|
+
let message; // We store the response body here as it can be read only once in Response's lifecycle so to make it exposed
|
|
177
|
+
// to the user in the BeeResponseError, for further analysis.
|
|
104
178
|
|
|
105
|
-
|
|
106
|
-
response.data = await response.arrayBuffer();
|
|
107
|
-
break;
|
|
179
|
+
const body = yield e.response.text();
|
|
108
180
|
|
|
109
|
-
case 'json':
|
|
110
181
|
try {
|
|
111
|
-
response
|
|
112
|
-
|
|
113
|
-
|
|
182
|
+
// The response can be Bee's JSON with structure `{code, message}` lets try to parse it
|
|
183
|
+
message = JSON.parse(body).message;
|
|
184
|
+
} catch (e) {}
|
|
185
|
+
|
|
186
|
+
if (message) {
|
|
187
|
+
throw new BeeResponseError(e.response.status, e.response, body, config, `${e.response.statusText}: ${message}`);
|
|
188
|
+
} else {
|
|
189
|
+
throw new BeeResponseError(e.response.status, e.response, body, config, e.response.statusText);
|
|
114
190
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
default:
|
|
119
|
-
break;
|
|
120
|
-
// If responseType is not set, then no data are expected
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return response;
|
|
124
|
-
} catch (e) {
|
|
125
|
-
// Passthrough thrown errors
|
|
126
|
-
if (e instanceof BeeNotAJsonError) {
|
|
127
|
-
throw e;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (isHttpError(e)) {
|
|
131
|
-
let message; // We store the response body here as it can be read only once in Response's lifecycle so to make it exposed
|
|
132
|
-
// to the user in the BeeResponseError, for further analysis.
|
|
133
|
-
|
|
134
|
-
const body = await e.response.text();
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
// The response can be Bee's JSON with structure `{code, message}` lets try to parse it
|
|
138
|
-
message = JSON.parse(body).message;
|
|
139
|
-
} catch (e) {}
|
|
140
|
-
|
|
141
|
-
if (message) {
|
|
142
|
-
throw new BeeResponseError(e.response.status, e.response, body, config, `${e.response.statusText}: ${message}`);
|
|
191
|
+
} else if (isHttpRequestError(e)) {
|
|
192
|
+
throw new BeeRequestError(e.message, config);
|
|
143
193
|
} else {
|
|
144
|
-
throw new
|
|
194
|
+
throw new BeeError(e.message);
|
|
145
195
|
}
|
|
146
|
-
} else if (isHttpRequestError(e)) {
|
|
147
|
-
throw new BeeRequestError(e.message, config);
|
|
148
|
-
} else {
|
|
149
|
-
throw new BeeError(e.message);
|
|
150
196
|
}
|
|
151
|
-
}
|
|
197
|
+
});
|
|
152
198
|
}
|
|
153
199
|
export function makeDefaultKy(kyConfig) {
|
|
154
200
|
return kyFactory.create(deepMerge(DEFAULT_KY_CONFIG, kyConfig));
|
package/dist/mjs/utils/merge.js
CHANGED
package/dist/mjs/utils/stream.js
CHANGED
package/dist/mjs/utils/type.js
CHANGED
|
@@ -214,11 +214,11 @@ export function assertPostageBatchOptions(value) {
|
|
|
214
214
|
const options = value;
|
|
215
215
|
assertRequestOptions(options, 'PostageBatchOptions');
|
|
216
216
|
|
|
217
|
-
if (options
|
|
217
|
+
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
218
218
|
assertNonNegativeInteger(options.gasPrice);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
if (options
|
|
221
|
+
if ((options === null || options === void 0 ? void 0 : options.immutableFlag) !== undefined) {
|
|
222
222
|
assertBoolean(options.immutableFlag);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
@@ -231,11 +231,11 @@ export function assertCashoutOptions(value) {
|
|
|
231
231
|
const options = value;
|
|
232
232
|
assertRequestOptions(options, 'PostageBatchOptions');
|
|
233
233
|
|
|
234
|
-
if (options
|
|
234
|
+
if (options === null || options === void 0 ? void 0 : options.gasLimit) {
|
|
235
235
|
assertNonNegativeInteger(options.gasLimit);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
if (options
|
|
238
|
+
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
239
239
|
assertNonNegativeInteger(options.gasPrice);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -274,7 +274,7 @@ export function assertAllTagsOptions(entry) {
|
|
|
274
274
|
assertRequestOptions(entry, 'AllTagsOptions');
|
|
275
275
|
const options = entry;
|
|
276
276
|
|
|
277
|
-
if (options
|
|
277
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) !== undefined) {
|
|
278
278
|
if (typeof options.limit !== 'number') {
|
|
279
279
|
throw new TypeError('AllTagsOptions.limit has to be a number or undefined!');
|
|
280
280
|
}
|
|
@@ -288,7 +288,7 @@ export function assertAllTagsOptions(entry) {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
if (options
|
|
291
|
+
if ((options === null || options === void 0 ? void 0 : options.offset) !== undefined) {
|
|
292
292
|
assertNonNegativeInteger(options.offset, 'AllTagsOptions.offset');
|
|
293
293
|
}
|
|
294
294
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Health, NodeInfo } from '../../types/debug';
|
|
2
2
|
import { Ky } from '../../types';
|
|
3
3
|
import { BeeVersions } from '../../types/debug';
|
|
4
|
-
export declare const SUPPORTED_BEE_VERSION_EXACT = "1.5.
|
|
4
|
+
export declare const SUPPORTED_BEE_VERSION_EXACT = "1.5.1-d0a77598";
|
|
5
5
|
export declare const SUPPORTED_API_VERSION = "3.0.0";
|
|
6
6
|
export declare const SUPPORTED_DEBUG_API_VERSION = "2.0.0";
|
|
7
7
|
export declare const SUPPORTED_BEE_VERSION: string;
|
|
@@ -139,8 +139,27 @@ export declare enum BeeModes {
|
|
|
139
139
|
* Information about Bee node and its configuration
|
|
140
140
|
*/
|
|
141
141
|
export interface NodeInfo {
|
|
142
|
+
/**
|
|
143
|
+
* Indicates whether the node is in a Gateway mode.
|
|
144
|
+
* Gateway mode is a restricted mode where some features are not available.
|
|
145
|
+
*/
|
|
142
146
|
gatewayMode: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Indicates in what mode Bee is running.
|
|
149
|
+
*/
|
|
143
150
|
beeMode: BeeModes;
|
|
151
|
+
/**
|
|
152
|
+
* Indicates whether the Bee node has its own deployed chequebook.
|
|
153
|
+
*
|
|
154
|
+
* @see [Bee docs - Chequebook](https://docs.ethswarm.org/docs/introduction/terminology#cheques--chequebook)
|
|
155
|
+
*/
|
|
156
|
+
chequebookEnabled: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Indicates whether SWAP is enabled for the Bee node.
|
|
159
|
+
*
|
|
160
|
+
* @see [Bee docs - SWAP](https://docs.ethswarm.org/docs/introduction/terminology#swap)
|
|
161
|
+
*/
|
|
162
|
+
swapEnabled: boolean;
|
|
144
163
|
}
|
|
145
164
|
/**
|
|
146
165
|
* Information about Bee node and its configuration
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Data } from 'ws';
|
|
2
|
-
import
|
|
2
|
+
import BlobPolyfill from 'fetch-blob';
|
|
3
3
|
import { Readable } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Prepare data for valid input for node-fetch.
|
|
@@ -10,4 +10,4 @@ import { Readable } from '../types';
|
|
|
10
10
|
* @param data any string, ArrayBuffer, Uint8Array or Readable
|
|
11
11
|
*/
|
|
12
12
|
export declare function prepareData(data: string | ArrayBuffer | Uint8Array | Readable): Promise<Blob | ReadableStream<Uint8Array> | never>;
|
|
13
|
-
export declare function prepareWebsocketData(data: Data |
|
|
13
|
+
export declare function prepareWebsocketData(data: Data | BlobPolyfill): Promise<Uint8Array> | never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -66,15 +66,15 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@types/readable-stream": "^2.3.13",
|
|
68
68
|
"bufferutil": "^4.0.6",
|
|
69
|
-
"cross-blob": "^2.0.1",
|
|
70
69
|
"elliptic": "^6.5.4",
|
|
70
|
+
"fetch-blob": "2.1.2",
|
|
71
71
|
"isomorphic-ws": "^4.0.1",
|
|
72
72
|
"js-sha3": "^0.8.0",
|
|
73
73
|
"ky": "^0.25.1",
|
|
74
74
|
"ky-universal": "^0.8.2",
|
|
75
75
|
"semver": "^7.3.5",
|
|
76
76
|
"tar-js": "^0.3.0",
|
|
77
|
-
"utf-8-validate": "^5.0.
|
|
77
|
+
"utf-8-validate": "^5.0.9",
|
|
78
78
|
"web-streams-polyfill": "^4.0.0-beta.1",
|
|
79
79
|
"ws": "^8.5.0"
|
|
80
80
|
},
|
|
@@ -94,11 +94,11 @@
|
|
|
94
94
|
"@types/debug": "^4.1.7",
|
|
95
95
|
"@types/elliptic": "^6.4.14",
|
|
96
96
|
"@types/expect-puppeteer": "^4.4.7",
|
|
97
|
-
"@types/glob": "^7.
|
|
97
|
+
"@types/glob": "^7.2.0",
|
|
98
98
|
"@types/jest": "^26.0.23",
|
|
99
99
|
"@types/jest-environment-puppeteer": "^4.4.1",
|
|
100
100
|
"@types/node": "^15.12.4",
|
|
101
|
-
"@types/puppeteer": "^5.4.
|
|
101
|
+
"@types/puppeteer": "^5.4.5",
|
|
102
102
|
"@types/semver": "^7.3.9",
|
|
103
103
|
"@types/ws": "^7.4.5",
|
|
104
104
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
@@ -106,24 +106,25 @@
|
|
|
106
106
|
"babel-jest": "^27.0.5",
|
|
107
107
|
"babel-loader": "^8.2.3",
|
|
108
108
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
109
|
+
"cross-blob": "^2.0.1",
|
|
109
110
|
"cross-env": "^7.0.3",
|
|
110
|
-
"debug": "^4.3.
|
|
111
|
+
"debug": "^4.3.4",
|
|
111
112
|
"depcheck": "^1.4.3",
|
|
112
113
|
"eslint": "^8.8.0",
|
|
113
|
-
"eslint-config-prettier": "^8.
|
|
114
|
+
"eslint-config-prettier": "^8.5.0",
|
|
114
115
|
"eslint-plugin-jest": "^25.7.0",
|
|
115
116
|
"eslint-plugin-prettier": "^4.0.0",
|
|
116
117
|
"eslint-plugin-unused-imports": "^2.0.0",
|
|
117
118
|
"glob": "^7.1.7",
|
|
118
119
|
"husky": "^7.0.4",
|
|
119
|
-
"jest": "^27.
|
|
120
|
-
"jest-puppeteer": "^
|
|
121
|
-
"nock": "^13.2.
|
|
122
|
-
"prettier": "^2.
|
|
120
|
+
"jest": "^27.5.1",
|
|
121
|
+
"jest-puppeteer": "^6.1.0",
|
|
122
|
+
"nock": "^13.2.4",
|
|
123
|
+
"prettier": "^2.6.2",
|
|
123
124
|
"puppeteer": "^13.2.0",
|
|
124
125
|
"rimraf": "^3.0.2",
|
|
125
126
|
"terser-webpack-plugin": "^5.3.0",
|
|
126
|
-
"ts-node": "^10.
|
|
127
|
+
"ts-node": "^10.7.0",
|
|
127
128
|
"typedoc": "^0.22.11",
|
|
128
129
|
"typedoc-plugin-markdown": "^3.11.12",
|
|
129
130
|
"typescript": "^4.5.4",
|
|
@@ -136,6 +137,6 @@
|
|
|
136
137
|
"npm": ">=6.0.0",
|
|
137
138
|
"beeApiVersion": "3.0.0",
|
|
138
139
|
"beeDebugApiVersion": "2.0.0",
|
|
139
|
-
"bee": "1.5.
|
|
140
|
+
"bee": "1.5.1-d0a77598"
|
|
140
141
|
}
|
|
141
142
|
}
|