@ethersphere/bee-js 4.1.1 → 6.0.0-pre.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/README.md +11 -3
- package/dist/index.browser.js +33 -0
- package/dist/index.browser.js.map +7 -0
- package/dist/src/bee-debug.js +624 -0
- package/dist/{mjs → src}/bee.js +243 -338
- package/dist/{mjs → src}/chunk/bmt.js +0 -0
- package/dist/{mjs → src}/chunk/cac.js +0 -0
- package/dist/{mjs → src}/chunk/serialize.js +0 -0
- package/dist/{mjs → src}/chunk/signer.js +13 -47
- package/dist/{mjs → src}/chunk/soc.js +31 -71
- package/dist/{mjs → src}/chunk/span.js +1 -1
- package/dist/{mjs → src}/feed/identifier.js +0 -0
- package/dist/src/feed/index.js +92 -0
- package/dist/src/feed/json.js +27 -0
- package/dist/src/feed/retrievable.js +67 -0
- package/dist/{mjs → src}/feed/topic.js +0 -0
- package/dist/{mjs → src}/feed/type.js +0 -0
- package/dist/{mjs → src}/index.js +1 -2
- package/dist/src/modules/bytes.js +59 -0
- package/dist/src/modules/bzz.js +122 -0
- package/dist/src/modules/chunk.js +45 -0
- package/dist/src/modules/debug/balance.js +57 -0
- package/dist/src/modules/debug/chequebook.js +150 -0
- package/dist/src/modules/debug/chunk.js +35 -0
- package/dist/src/modules/debug/connectivity.js +45 -0
- package/dist/src/modules/debug/settlements.js +29 -0
- package/dist/src/modules/debug/stamps.js +64 -0
- package/dist/src/modules/debug/states.js +46 -0
- package/dist/src/modules/debug/status.js +134 -0
- package/dist/src/modules/debug/tag.js +16 -0
- package/dist/src/modules/debug/transactions.js +69 -0
- package/dist/src/modules/feed.js +67 -0
- package/dist/src/modules/pinning.js +60 -0
- package/dist/src/modules/pss.js +40 -0
- package/dist/src/modules/soc.js +31 -0
- package/dist/src/modules/status.js +12 -0
- package/dist/src/modules/stewardship.js +24 -0
- package/dist/src/modules/tag.js +77 -0
- package/dist/{mjs → src}/types/debug.js +0 -0
- package/dist/{mjs → src}/types/index.js +0 -0
- package/dist/{mjs → src}/utils/bytes.js +3 -2
- package/dist/src/utils/collection-browser.js +19 -0
- package/dist/src/utils/collection-node.js +74 -0
- package/dist/src/utils/collection.js +64 -0
- package/dist/src/utils/data.browser.js +72 -0
- package/dist/src/utils/data.js +42 -0
- package/dist/{mjs → src}/utils/error.js +0 -0
- package/dist/{mjs → src}/utils/eth.js +32 -68
- package/dist/{mjs → src}/utils/expose.js +1 -1
- package/dist/src/utils/file.js +36 -0
- package/dist/{mjs → src}/utils/hash.js +0 -0
- package/dist/{mjs → src}/utils/headers.js +4 -4
- package/dist/{mjs → src}/utils/hex.js +0 -0
- package/dist/src/utils/http.js +162 -0
- package/dist/{mjs → src}/utils/merge.js +2 -2
- package/dist/{mjs → src}/utils/pss.js +0 -0
- package/dist/{mjs → src}/utils/reference.js +0 -0
- package/dist/src/utils/sleep.js +8 -0
- package/dist/{mjs → src}/utils/stamps.js +0 -0
- package/dist/{mjs → src}/utils/stream.js +3 -3
- package/dist/{mjs → src}/utils/tar.js +0 -0
- package/dist/{mjs → src}/utils/type.js +13 -14
- package/dist/{mjs → src}/utils/uint64.js +0 -0
- package/dist/{mjs → src}/utils/url.js +0 -0
- package/dist/types/bee.d.ts +2 -3
- package/dist/types/chunk/bmt.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +1 -1
- package/dist/types/chunk/span.d.ts +1 -1
- package/dist/types/feed/index.d.ts +1 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/modules/bzz.d.ts +1 -1
- package/dist/types/modules/debug/status.d.ts +3 -3
- package/dist/types/modules/pinning.d.ts +1 -1
- package/dist/types/types/debug.d.ts +2 -7
- package/dist/types/types/index.d.ts +33 -16
- package/dist/types/utils/{collection.browser.d.ts → collection-browser.d.ts} +0 -0
- package/dist/types/utils/{collection.node.d.ts → collection-node.d.ts} +0 -0
- package/dist/types/utils/error.d.ts +1 -1
- package/dist/types/utils/eth.d.ts +3 -3
- package/dist/types/utils/expose.d.ts +7 -4
- package/dist/types/utils/hash.d.ts +1 -1
- package/dist/types/utils/hex.d.ts +2 -2
- package/dist/types/utils/http.d.ts +3 -3
- package/dist/types/utils/stream.d.ts +1 -1
- package/dist/types/utils/type.d.ts +6 -2
- package/dist/types/utils/uint64.d.ts +1 -1
- package/package.json +50 -65
- package/dist/cjs/bee-debug.js +0 -638
- package/dist/cjs/bee.js +0 -977
- package/dist/cjs/chunk/bmt.js +0 -55
- package/dist/cjs/chunk/cac.js +0 -56
- package/dist/cjs/chunk/serialize.js +0 -19
- package/dist/cjs/chunk/signer.js +0 -137
- package/dist/cjs/chunk/soc.js +0 -172
- package/dist/cjs/chunk/span.js +0 -29
- package/dist/cjs/feed/identifier.js +0 -35
- package/dist/cjs/feed/index.js +0 -128
- package/dist/cjs/feed/json.js +0 -41
- package/dist/cjs/feed/retrievable.js +0 -72
- package/dist/cjs/feed/topic.js +0 -25
- package/dist/cjs/feed/type.js +0 -15
- package/dist/cjs/index.js +0 -35
- package/dist/cjs/modules/bytes.js +0 -74
- package/dist/cjs/modules/bzz.js +0 -131
- package/dist/cjs/modules/chunk.js +0 -58
- package/dist/cjs/modules/debug/balance.js +0 -77
- package/dist/cjs/modules/debug/chequebook.js +0 -167
- package/dist/cjs/modules/debug/chunk.js +0 -51
- package/dist/cjs/modules/debug/connectivity.js +0 -75
- package/dist/cjs/modules/debug/settlements.js +0 -45
- package/dist/cjs/modules/debug/stamps.js +0 -89
- package/dist/cjs/modules/debug/states.js +0 -64
- package/dist/cjs/modules/debug/status.js +0 -153
- package/dist/cjs/modules/debug/tag.js +0 -30
- package/dist/cjs/modules/debug/transactions.js +0 -81
- package/dist/cjs/modules/feed.js +0 -76
- package/dist/cjs/modules/pinning.js +0 -84
- package/dist/cjs/modules/pss.js +0 -55
- package/dist/cjs/modules/soc.js +0 -40
- package/dist/cjs/modules/status.js +0 -26
- package/dist/cjs/modules/stewardship.js +0 -41
- package/dist/cjs/modules/tag.js +0 -96
- package/dist/cjs/package.json +0 -8
- package/dist/cjs/types/debug.js +0 -10
- package/dist/cjs/types/index.js +0 -47
- package/dist/cjs/types/ky-options.js +0 -8
- package/dist/cjs/types/ky-universal/common.js +0 -8
- package/dist/cjs/types/ky-universal/hooks.js +0 -8
- package/dist/cjs/types/ky-universal/retry.js +0 -8
- package/dist/cjs/utils/bytes.js +0 -121
- package/dist/cjs/utils/collection.browser.js +0 -36
- package/dist/cjs/utils/collection.js +0 -70
- package/dist/cjs/utils/collection.node.js +0 -115
- package/dist/cjs/utils/data.browser.js +0 -74
- package/dist/cjs/utils/data.js +0 -58
- package/dist/cjs/utils/error.js +0 -50
- package/dist/cjs/utils/eth.js +0 -211
- package/dist/cjs/utils/expose.js +0 -44
- package/dist/cjs/utils/file.js +0 -49
- package/dist/cjs/utils/hash.js +0 -21
- package/dist/cjs/utils/headers.js +0 -59
- package/dist/cjs/utils/hex.js +0 -150
- package/dist/cjs/utils/http.js +0 -172
- package/dist/cjs/utils/merge.js +0 -34
- package/dist/cjs/utils/pss.js +0 -18
- package/dist/cjs/utils/reference.js +0 -36
- package/dist/cjs/utils/sleep.js +0 -23
- package/dist/cjs/utils/stamps.js +0 -17
- package/dist/cjs/utils/stream.js +0 -146
- package/dist/cjs/utils/tar.js +0 -25
- package/dist/cjs/utils/type.js +0 -426
- package/dist/cjs/utils/uint64.js +0 -29
- package/dist/cjs/utils/url.js +0 -56
- package/dist/index.browser.min.js +0 -3
- package/dist/index.browser.min.js.LICENSE.txt +0 -60
- package/dist/index.browser.min.js.map +0 -1
- package/dist/mjs/bee-debug.js +0 -744
- package/dist/mjs/feed/index.js +0 -134
- package/dist/mjs/feed/json.js +0 -63
- package/dist/mjs/feed/retrievable.js +0 -105
- package/dist/mjs/modules/bytes.js +0 -96
- package/dist/mjs/modules/bzz.js +0 -160
- package/dist/mjs/modules/chunk.js +0 -80
- package/dist/mjs/modules/debug/balance.js +0 -97
- package/dist/mjs/modules/debug/chequebook.js +0 -198
- package/dist/mjs/modules/debug/chunk.js +0 -71
- package/dist/mjs/modules/debug/connectivity.js +0 -89
- package/dist/mjs/modules/debug/settlements.js +0 -65
- package/dist/mjs/modules/debug/stamps.js +0 -108
- package/dist/mjs/modules/debug/states.js +0 -84
- package/dist/mjs/modules/debug/status.js +0 -182
- package/dist/mjs/modules/debug/tag.js +0 -50
- package/dist/mjs/modules/debug/transactions.js +0 -103
- package/dist/mjs/modules/feed.js +0 -101
- package/dist/mjs/modules/pinning.js +0 -106
- package/dist/mjs/modules/pss.js +0 -74
- package/dist/mjs/modules/soc.js +0 -64
- package/dist/mjs/modules/status.js +0 -46
- package/dist/mjs/modules/stewardship.js +0 -60
- package/dist/mjs/modules/tag.js +0 -119
- package/dist/mjs/package.json +0 -8
- package/dist/mjs/types/ky-options.js +0 -7
- package/dist/mjs/types/ky-universal/common.js +0 -7
- package/dist/mjs/types/ky-universal/hooks.js +0 -7
- package/dist/mjs/types/ky-universal/retry.js +0 -7
- package/dist/mjs/utils/collection.browser.js +0 -56
- package/dist/mjs/utils/collection.js +0 -98
- package/dist/mjs/utils/collection.node.js +0 -169
- package/dist/mjs/utils/data.browser.js +0 -108
- package/dist/mjs/utils/data.js +0 -78
- package/dist/mjs/utils/file.js +0 -70
- package/dist/mjs/utils/http.js +0 -208
- package/dist/mjs/utils/sleep.js +0 -43
- package/dist/types/types/ky-options.d.ts +0 -221
- package/dist/types/types/ky-universal/common.d.ts +0 -13
- package/dist/types/types/ky-universal/hooks.d.ts +0 -92
- package/dist/types/types/ky-universal/retry.d.ts +0 -38
package/dist/{mjs → src}/bee.js
RENAMED
|
@@ -1,35 +1,3 @@
|
|
|
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
1
|
import * as bzz from "./modules/bzz.js";
|
|
34
2
|
import * as stewardship from "./modules/stewardship.js";
|
|
35
3
|
import * as tag from "./modules/tag.js";
|
|
@@ -53,7 +21,7 @@ import { wrapBytesWithHelpers } from "./utils/bytes.js";
|
|
|
53
21
|
import { addCidConversionFunction, assertAddressPrefix, assertAllTagsOptions, assertBatchId, assertCollectionUploadOptions, assertData, assertFileData, assertFileUploadOptions, assertPssMessageHandler, assertPublicKey, assertReference, assertReferenceOrEns, assertRequestOptions, assertUploadOptions, makeReferenceOrEns, makeTagUid } from "./utils/type.js";
|
|
54
22
|
import { getJsonData, setJsonData } from "./feed/json.js";
|
|
55
23
|
import { assertCollection, makeCollectionFromFileList } from "./utils/collection.js";
|
|
56
|
-
import { makeCollectionFromFS } from "./utils/collection
|
|
24
|
+
import { makeCollectionFromFS } from "./utils/collection-node.js";
|
|
57
25
|
import { CHUNK_SIZE, SPAN_SIZE } from "./types/index.js";
|
|
58
26
|
import { makeDefaultKy, wrapRequestClosure, wrapResponseClosure } from "./utils/http.js";
|
|
59
27
|
import { isReadable } from "./utils/stream.js";
|
|
@@ -72,38 +40,36 @@ export class Bee {
|
|
|
72
40
|
* @param options
|
|
73
41
|
*/
|
|
74
42
|
constructor(url, options) {
|
|
75
|
-
var _a;
|
|
76
|
-
|
|
77
43
|
assertBeeUrl(url); // Remove last slash if present, as our endpoint strings starts with `/...`
|
|
78
44
|
// which could lead to double slash in URL to which Bee responds with
|
|
79
45
|
// unnecessary redirects.
|
|
80
46
|
|
|
81
47
|
this.url = stripLastSlash(url);
|
|
82
48
|
|
|
83
|
-
if (options
|
|
49
|
+
if (options?.signer) {
|
|
84
50
|
this.signer = makeSigner(options.signer);
|
|
85
51
|
}
|
|
86
52
|
|
|
87
53
|
const kyOptions = {
|
|
88
54
|
prefixUrl: this.url,
|
|
89
|
-
timeout:
|
|
90
|
-
retry: options
|
|
91
|
-
fetch: options
|
|
55
|
+
timeout: options?.timeout ?? false,
|
|
56
|
+
retry: options?.retry,
|
|
57
|
+
fetch: options?.fetch,
|
|
92
58
|
hooks: {
|
|
93
59
|
beforeRequest: [],
|
|
94
60
|
afterResponse: []
|
|
95
61
|
}
|
|
96
62
|
};
|
|
97
63
|
|
|
98
|
-
if (options
|
|
64
|
+
if (options?.defaultHeaders) {
|
|
99
65
|
kyOptions.headers = options.defaultHeaders;
|
|
100
66
|
}
|
|
101
67
|
|
|
102
|
-
if (options
|
|
68
|
+
if (options?.onRequest) {
|
|
103
69
|
kyOptions.hooks.beforeRequest.push(wrapRequestClosure(options.onRequest));
|
|
104
70
|
}
|
|
105
71
|
|
|
106
|
-
if (options
|
|
72
|
+
if (options?.onResponse) {
|
|
107
73
|
kyOptions.hooks.afterResponse.push(wrapResponseClosure(options.onResponse));
|
|
108
74
|
}
|
|
109
75
|
|
|
@@ -122,13 +88,11 @@ export class Bee {
|
|
|
122
88
|
*/
|
|
123
89
|
|
|
124
90
|
|
|
125
|
-
uploadData(postageBatchId, data, options) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return bytes.upload(this.getKy(options), data, postageBatchId, options);
|
|
131
|
-
});
|
|
91
|
+
async uploadData(postageBatchId, data, options) {
|
|
92
|
+
assertBatchId(postageBatchId);
|
|
93
|
+
assertData(data);
|
|
94
|
+
if (options) assertUploadOptions(options);
|
|
95
|
+
return bytes.upload(this.getKy(options), data, postageBatchId, options);
|
|
132
96
|
}
|
|
133
97
|
/**
|
|
134
98
|
* Download data as a byte array
|
|
@@ -142,12 +106,10 @@ export class Bee {
|
|
|
142
106
|
*/
|
|
143
107
|
|
|
144
108
|
|
|
145
|
-
downloadData(reference, options) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return bytes.download(this.getKy(options), reference);
|
|
150
|
-
});
|
|
109
|
+
async downloadData(reference, options) {
|
|
110
|
+
assertRequestOptions(options);
|
|
111
|
+
assertReferenceOrEns(reference);
|
|
112
|
+
return bytes.download(this.getKy(options), reference);
|
|
151
113
|
}
|
|
152
114
|
/**
|
|
153
115
|
* Download data as a Readable stream
|
|
@@ -161,12 +123,10 @@ export class Bee {
|
|
|
161
123
|
*/
|
|
162
124
|
|
|
163
125
|
|
|
164
|
-
downloadReadableData(reference, options) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return bytes.downloadReadable(this.getKy(options), reference);
|
|
169
|
-
});
|
|
126
|
+
async downloadReadableData(reference, options) {
|
|
127
|
+
assertRequestOptions(options);
|
|
128
|
+
assertReferenceOrEns(reference);
|
|
129
|
+
return bytes.downloadReadable(this.getKy(options), reference);
|
|
170
130
|
}
|
|
171
131
|
/**
|
|
172
132
|
* Upload chunk to a Bee node
|
|
@@ -181,25 +141,23 @@ export class Bee {
|
|
|
181
141
|
*/
|
|
182
142
|
|
|
183
143
|
|
|
184
|
-
uploadChunk(postageBatchId, data, options) {
|
|
185
|
-
|
|
186
|
-
assertBatchId(postageBatchId);
|
|
144
|
+
async uploadChunk(postageBatchId, data, options) {
|
|
145
|
+
assertBatchId(postageBatchId);
|
|
187
146
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
147
|
+
if (!(data instanceof Uint8Array)) {
|
|
148
|
+
throw new TypeError('Data has to be Uint8Array instance!');
|
|
149
|
+
}
|
|
191
150
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
151
|
+
if (data.length < SPAN_SIZE) {
|
|
152
|
+
throw new BeeArgumentError(`Chunk has to have size of at least ${SPAN_SIZE}.`, data);
|
|
153
|
+
}
|
|
195
154
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
155
|
+
if (data.length > CHUNK_SIZE + SPAN_SIZE) {
|
|
156
|
+
throw new BeeArgumentError(`Chunk has to have size of at most ${CHUNK_SIZE}.`, data);
|
|
157
|
+
}
|
|
199
158
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
159
|
+
if (options) assertUploadOptions(options);
|
|
160
|
+
return chunk.upload(this.getKy(options), data, postageBatchId, options);
|
|
203
161
|
}
|
|
204
162
|
/**
|
|
205
163
|
* Download chunk as a byte array
|
|
@@ -213,12 +171,10 @@ export class Bee {
|
|
|
213
171
|
*/
|
|
214
172
|
|
|
215
173
|
|
|
216
|
-
downloadChunk(reference, options) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return chunk.download(this.getKy(options), reference);
|
|
221
|
-
});
|
|
174
|
+
async downloadChunk(reference, options) {
|
|
175
|
+
assertRequestOptions(options);
|
|
176
|
+
assertReferenceOrEns(reference);
|
|
177
|
+
return chunk.download(this.getKy(options), reference);
|
|
222
178
|
}
|
|
223
179
|
/**
|
|
224
180
|
* Upload single file to a Bee node.
|
|
@@ -238,33 +194,32 @@ export class Bee {
|
|
|
238
194
|
*/
|
|
239
195
|
|
|
240
196
|
|
|
241
|
-
uploadFile(postageBatchId, data, name, options) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (options) assertFileUploadOptions(options);
|
|
197
|
+
async uploadFile(postageBatchId, data, name, options) {
|
|
198
|
+
assertBatchId(postageBatchId);
|
|
199
|
+
assertFileData(data);
|
|
200
|
+
if (options) assertFileUploadOptions(options);
|
|
246
201
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
202
|
+
if (name && typeof name !== 'string') {
|
|
203
|
+
throw new TypeError('name has to be string or undefined!');
|
|
204
|
+
}
|
|
250
205
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
206
|
+
if (isFile(data)) {
|
|
207
|
+
const fileData = await fileArrayBuffer(data);
|
|
208
|
+
const fileName = name ?? data.name;
|
|
209
|
+
const contentType = data.type;
|
|
210
|
+
const fileOptions = {
|
|
211
|
+
contentType,
|
|
212
|
+
...options
|
|
213
|
+
};
|
|
214
|
+
return addCidConversionFunction(await bzz.uploadFile(this.getKy(options), fileData, postageBatchId, fileName, fileOptions), ReferenceType.MANIFEST);
|
|
215
|
+
} else if (isReadable(data) && options?.tag && !options.size) {
|
|
216
|
+
// TODO: Needed until https://github.com/ethersphere/bee/issues/2317 is resolved
|
|
217
|
+
const result = await bzz.uploadFile(this.getKy(options), data, postageBatchId, name, options);
|
|
218
|
+
await this.updateTag(options.tag, result.reference);
|
|
219
|
+
return addCidConversionFunction(result, ReferenceType.MANIFEST);
|
|
220
|
+
} else {
|
|
221
|
+
return addCidConversionFunction(await bzz.uploadFile(this.getKy(options), data, postageBatchId, name, options), ReferenceType.MANIFEST);
|
|
222
|
+
}
|
|
268
223
|
}
|
|
269
224
|
/**
|
|
270
225
|
* Download single file.
|
|
@@ -280,12 +235,10 @@ export class Bee {
|
|
|
280
235
|
*/
|
|
281
236
|
|
|
282
237
|
|
|
283
|
-
downloadFile(reference, path = '', options) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return bzz.downloadFile(this.getKy(options), reference, path);
|
|
288
|
-
});
|
|
238
|
+
async downloadFile(reference, path = '', options) {
|
|
239
|
+
assertRequestOptions(options);
|
|
240
|
+
reference = makeReferenceOrEns(reference, ReferenceType.MANIFEST);
|
|
241
|
+
return bzz.downloadFile(this.getKy(options), reference, path);
|
|
289
242
|
}
|
|
290
243
|
/**
|
|
291
244
|
* Download single file as a readable stream
|
|
@@ -301,12 +254,10 @@ export class Bee {
|
|
|
301
254
|
*/
|
|
302
255
|
|
|
303
256
|
|
|
304
|
-
downloadReadableFile(reference, path = '', options) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return bzz.downloadFileReadable(this.getKy(options), reference, path);
|
|
309
|
-
});
|
|
257
|
+
async downloadReadableFile(reference, path = '', options) {
|
|
258
|
+
assertRequestOptions(options);
|
|
259
|
+
reference = makeReferenceOrEns(reference, ReferenceType.MANIFEST);
|
|
260
|
+
return bzz.downloadFileReadable(this.getKy(options), reference, path);
|
|
310
261
|
}
|
|
311
262
|
/**
|
|
312
263
|
* Upload collection of files to a Bee node
|
|
@@ -326,13 +277,11 @@ export class Bee {
|
|
|
326
277
|
*/
|
|
327
278
|
|
|
328
279
|
|
|
329
|
-
uploadFiles(postageBatchId, fileList, options) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return addCidConversionFunction(yield bzz.uploadCollection(this.getKy(options), data, postageBatchId, options), ReferenceType.MANIFEST);
|
|
335
|
-
});
|
|
280
|
+
async uploadFiles(postageBatchId, fileList, options) {
|
|
281
|
+
assertBatchId(postageBatchId);
|
|
282
|
+
if (options) assertCollectionUploadOptions(options);
|
|
283
|
+
const data = await makeCollectionFromFileList(fileList);
|
|
284
|
+
return addCidConversionFunction(await bzz.uploadCollection(this.getKy(options), data, postageBatchId, options), ReferenceType.MANIFEST);
|
|
336
285
|
}
|
|
337
286
|
/**
|
|
338
287
|
* Upload Collection that you can assembly yourself.
|
|
@@ -346,13 +295,11 @@ export class Bee {
|
|
|
346
295
|
*/
|
|
347
296
|
|
|
348
297
|
|
|
349
|
-
uploadCollection(postageBatchId, collection, options) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
return addCidConversionFunction(yield bzz.uploadCollection(this.ky, collection, postageBatchId, options), ReferenceType.MANIFEST);
|
|
355
|
-
});
|
|
298
|
+
async uploadCollection(postageBatchId, collection, options) {
|
|
299
|
+
assertBatchId(postageBatchId);
|
|
300
|
+
assertCollection(collection);
|
|
301
|
+
if (options) assertCollectionUploadOptions(options);
|
|
302
|
+
return addCidConversionFunction(await bzz.uploadCollection(this.ky, collection, postageBatchId, options), ReferenceType.MANIFEST);
|
|
356
303
|
}
|
|
357
304
|
/**
|
|
358
305
|
* Upload collection of files.
|
|
@@ -372,13 +319,11 @@ export class Bee {
|
|
|
372
319
|
*/
|
|
373
320
|
|
|
374
321
|
|
|
375
|
-
uploadFilesFromDirectory(postageBatchId, dir, options) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return addCidConversionFunction(yield bzz.uploadCollection(this.getKy(options), data, postageBatchId, options), ReferenceType.MANIFEST);
|
|
381
|
-
});
|
|
322
|
+
async uploadFilesFromDirectory(postageBatchId, dir, options) {
|
|
323
|
+
assertBatchId(postageBatchId);
|
|
324
|
+
if (options) assertCollectionUploadOptions(options);
|
|
325
|
+
const data = await makeCollectionFromFS(dir);
|
|
326
|
+
return addCidConversionFunction(await bzz.uploadCollection(this.getKy(options), data, postageBatchId, options), ReferenceType.MANIFEST);
|
|
382
327
|
}
|
|
383
328
|
/**
|
|
384
329
|
* Create a new Tag which is meant for tracking progres of syncing data across network.
|
|
@@ -391,11 +336,9 @@ export class Bee {
|
|
|
391
336
|
*/
|
|
392
337
|
|
|
393
338
|
|
|
394
|
-
createTag(options) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return tag.createTag(this.getKy(options));
|
|
398
|
-
});
|
|
339
|
+
async createTag(options) {
|
|
340
|
+
assertRequestOptions(options);
|
|
341
|
+
return tag.createTag(this.getKy(options));
|
|
399
342
|
}
|
|
400
343
|
/**
|
|
401
344
|
* Fetches all tags.
|
|
@@ -413,12 +356,10 @@ export class Bee {
|
|
|
413
356
|
*/
|
|
414
357
|
|
|
415
358
|
|
|
416
|
-
getAllTags(options) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return tag.getAllTags(this.getKy(options), options === null || options === void 0 ? void 0 : options.offset, options === null || options === void 0 ? void 0 : options.limit);
|
|
421
|
-
});
|
|
359
|
+
async getAllTags(options) {
|
|
360
|
+
assertRequestOptions(options);
|
|
361
|
+
assertAllTagsOptions(options);
|
|
362
|
+
return tag.getAllTags(this.getKy(options), options?.offset, options?.limit);
|
|
422
363
|
}
|
|
423
364
|
/**
|
|
424
365
|
* Retrieve tag information from Bee node
|
|
@@ -435,12 +376,10 @@ export class Bee {
|
|
|
435
376
|
*/
|
|
436
377
|
|
|
437
378
|
|
|
438
|
-
retrieveTag(tagUid, options) {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
return tag.retrieveTag(this.getKy(options), tagUid);
|
|
443
|
-
});
|
|
379
|
+
async retrieveTag(tagUid, options) {
|
|
380
|
+
assertRequestOptions(options);
|
|
381
|
+
tagUid = makeTagUid(tagUid);
|
|
382
|
+
return tag.retrieveTag(this.getKy(options), tagUid);
|
|
444
383
|
}
|
|
445
384
|
/**
|
|
446
385
|
* Delete Tag
|
|
@@ -457,12 +396,10 @@ export class Bee {
|
|
|
457
396
|
*/
|
|
458
397
|
|
|
459
398
|
|
|
460
|
-
deleteTag(tagUid, options) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return tag.deleteTag(this.getKy(options), tagUid);
|
|
465
|
-
});
|
|
399
|
+
async deleteTag(tagUid, options) {
|
|
400
|
+
assertRequestOptions(options);
|
|
401
|
+
tagUid = makeTagUid(tagUid);
|
|
402
|
+
return tag.deleteTag(this.getKy(options), tagUid);
|
|
466
403
|
}
|
|
467
404
|
/**
|
|
468
405
|
* Update tag's total chunks count.
|
|
@@ -483,13 +420,11 @@ export class Bee {
|
|
|
483
420
|
*/
|
|
484
421
|
|
|
485
422
|
|
|
486
|
-
updateTag(tagUid, reference, options) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
return tag.updateTag(this.getKy(options), tagUid, reference);
|
|
492
|
-
});
|
|
423
|
+
async updateTag(tagUid, reference, options) {
|
|
424
|
+
assertReference(reference);
|
|
425
|
+
assertRequestOptions(options);
|
|
426
|
+
tagUid = makeTagUid(tagUid);
|
|
427
|
+
return tag.updateTag(this.getKy(options), tagUid, reference);
|
|
493
428
|
}
|
|
494
429
|
/**
|
|
495
430
|
* Pin local data with given reference
|
|
@@ -504,12 +439,10 @@ export class Bee {
|
|
|
504
439
|
*/
|
|
505
440
|
|
|
506
441
|
|
|
507
|
-
pin(reference, options) {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
return pinning.pin(this.getKy(options), reference);
|
|
512
|
-
});
|
|
442
|
+
async pin(reference, options) {
|
|
443
|
+
assertRequestOptions(options);
|
|
444
|
+
assertReference(reference);
|
|
445
|
+
return pinning.pin(this.getKy(options), reference);
|
|
513
446
|
}
|
|
514
447
|
/**
|
|
515
448
|
* Unpin local data with given reference
|
|
@@ -524,12 +457,10 @@ export class Bee {
|
|
|
524
457
|
*/
|
|
525
458
|
|
|
526
459
|
|
|
527
|
-
unpin(reference, options) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return pinning.unpin(this.getKy(options), reference);
|
|
532
|
-
});
|
|
460
|
+
async unpin(reference, options) {
|
|
461
|
+
assertRequestOptions(options);
|
|
462
|
+
assertReference(reference);
|
|
463
|
+
return pinning.unpin(this.getKy(options), reference);
|
|
533
464
|
}
|
|
534
465
|
/**
|
|
535
466
|
* Get list of all locally pinned references
|
|
@@ -541,11 +472,9 @@ export class Bee {
|
|
|
541
472
|
*/
|
|
542
473
|
|
|
543
474
|
|
|
544
|
-
getAllPins(options) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
return pinning.getAllPins(this.getKy(options));
|
|
548
|
-
});
|
|
475
|
+
async getAllPins(options) {
|
|
476
|
+
assertRequestOptions(options);
|
|
477
|
+
return pinning.getAllPins(this.getKy(options));
|
|
549
478
|
}
|
|
550
479
|
/**
|
|
551
480
|
* Get pinning status of chunk with given reference
|
|
@@ -561,12 +490,10 @@ export class Bee {
|
|
|
561
490
|
*/
|
|
562
491
|
|
|
563
492
|
|
|
564
|
-
getPin(reference, options) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return pinning.getPin(this.getKy(options), reference);
|
|
569
|
-
});
|
|
493
|
+
async getPin(reference, options) {
|
|
494
|
+
assertRequestOptions(options);
|
|
495
|
+
assertReference(reference);
|
|
496
|
+
return pinning.getPin(this.getKy(options), reference);
|
|
570
497
|
}
|
|
571
498
|
/**
|
|
572
499
|
* Instructs the Bee node to reupload a locally pinned data into the network.
|
|
@@ -581,12 +508,10 @@ export class Bee {
|
|
|
581
508
|
*/
|
|
582
509
|
|
|
583
510
|
|
|
584
|
-
reuploadPinnedData(reference, options) {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
yield stewardship.reupload(this.getKy(options), reference);
|
|
589
|
-
});
|
|
511
|
+
async reuploadPinnedData(reference, options) {
|
|
512
|
+
assertRequestOptions(options);
|
|
513
|
+
assertReferenceOrEns(reference);
|
|
514
|
+
await stewardship.reupload(this.getKy(options), reference);
|
|
590
515
|
}
|
|
591
516
|
/**
|
|
592
517
|
* Checks if content specified by reference is retrievable from the network.
|
|
@@ -600,12 +525,10 @@ export class Bee {
|
|
|
600
525
|
*/
|
|
601
526
|
|
|
602
527
|
|
|
603
|
-
isReferenceRetrievable(reference, options) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
return stewardship.isRetrievable(this.getKy(options), reference);
|
|
608
|
-
});
|
|
528
|
+
async isReferenceRetrievable(reference, options) {
|
|
529
|
+
assertRequestOptions(options);
|
|
530
|
+
assertReferenceOrEns(reference);
|
|
531
|
+
return stewardship.isRetrievable(this.getKy(options), reference);
|
|
609
532
|
}
|
|
610
533
|
/**
|
|
611
534
|
* Functions that validates if feed is retrievable in the network.
|
|
@@ -624,32 +547,30 @@ export class Bee {
|
|
|
624
547
|
*/
|
|
625
548
|
|
|
626
549
|
|
|
627
|
-
isFeedRetrievable(type, owner, topic, index, options) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
const canonicalTopic = makeTopic(topic);
|
|
631
|
-
|
|
632
|
-
if (!index) {
|
|
633
|
-
try {
|
|
634
|
-
yield this.makeFeedReader(type, canonicalTopic, canonicalOwner).download();
|
|
635
|
-
return true;
|
|
636
|
-
} catch (e) {
|
|
637
|
-
const err = e; // Only if the error is "not-found" then we return false otherwise we re-throw the error
|
|
550
|
+
async isFeedRetrievable(type, owner, topic, index, options) {
|
|
551
|
+
const canonicalOwner = makeEthAddress(owner);
|
|
552
|
+
const canonicalTopic = makeTopic(topic);
|
|
638
553
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
554
|
+
if (!index) {
|
|
555
|
+
try {
|
|
556
|
+
await this.makeFeedReader(type, canonicalTopic, canonicalOwner).download();
|
|
557
|
+
return true;
|
|
558
|
+
} catch (e) {
|
|
559
|
+
const err = e; // Only if the error is "not-found" then we return false otherwise we re-throw the error
|
|
642
560
|
|
|
643
|
-
|
|
561
|
+
if (err?.status === 404) {
|
|
562
|
+
return false;
|
|
644
563
|
}
|
|
645
|
-
}
|
|
646
564
|
|
|
647
|
-
|
|
648
|
-
throw new BeeError('Only Sequence type of Feeds is supported at the moment');
|
|
565
|
+
throw e;
|
|
649
566
|
}
|
|
567
|
+
}
|
|
650
568
|
|
|
651
|
-
|
|
652
|
-
|
|
569
|
+
if (type !== 'sequence') {
|
|
570
|
+
throw new BeeError('Only Sequence type of Feeds is supported at the moment');
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return areAllSequentialFeedsUpdateRetrievable(this, canonicalOwner, canonicalTopic, index, options);
|
|
653
574
|
}
|
|
654
575
|
/**
|
|
655
576
|
* Send data to recipient or target with Postal Service for Swarm.
|
|
@@ -677,24 +598,22 @@ export class Bee {
|
|
|
677
598
|
*/
|
|
678
599
|
|
|
679
600
|
|
|
680
|
-
pssSend(postageBatchId, topic, target, data, recipient, options) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
assertAddressPrefix(target);
|
|
601
|
+
async pssSend(postageBatchId, topic, target, data, recipient, options) {
|
|
602
|
+
assertRequestOptions(options);
|
|
603
|
+
assertData(data);
|
|
604
|
+
assertBatchId(postageBatchId);
|
|
605
|
+
assertAddressPrefix(target);
|
|
686
606
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
607
|
+
if (typeof topic !== 'string') {
|
|
608
|
+
throw new TypeError('topic has to be an string!');
|
|
609
|
+
}
|
|
690
610
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
});
|
|
611
|
+
if (recipient) {
|
|
612
|
+
assertPublicKey(recipient);
|
|
613
|
+
return pss.send(this.getKy(options), topic, target, data, postageBatchId, recipient);
|
|
614
|
+
} else {
|
|
615
|
+
return pss.send(this.getKy(options), topic, target, data, postageBatchId);
|
|
616
|
+
}
|
|
698
617
|
}
|
|
699
618
|
/**
|
|
700
619
|
* Subscribe to messages for given topic with Postal Service for Swarm
|
|
@@ -739,13 +658,13 @@ export class Bee {
|
|
|
739
658
|
cancel
|
|
740
659
|
};
|
|
741
660
|
|
|
742
|
-
ws.onmessage = ev =>
|
|
743
|
-
const data =
|
|
661
|
+
ws.onmessage = async ev => {
|
|
662
|
+
const data = await prepareWebsocketData(ev.data); // ignore empty messages
|
|
744
663
|
|
|
745
664
|
if (data.length > 0) {
|
|
746
665
|
handler.onMessage(wrapBytesWithHelpers(data), subscription);
|
|
747
666
|
}
|
|
748
|
-
}
|
|
667
|
+
};
|
|
749
668
|
|
|
750
669
|
ws.onerror = ev => {
|
|
751
670
|
// ignore errors after subscription was cancelled
|
|
@@ -784,40 +703,38 @@ export class Bee {
|
|
|
784
703
|
*/
|
|
785
704
|
|
|
786
705
|
|
|
787
|
-
pssReceive(topic, timeoutMsec = 0) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
706
|
+
async pssReceive(topic, timeoutMsec = 0) {
|
|
707
|
+
if (typeof topic !== 'string') {
|
|
708
|
+
throw new TypeError('topic has to be an string!');
|
|
709
|
+
}
|
|
792
710
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
711
|
+
if (typeof timeoutMsec !== 'number') {
|
|
712
|
+
throw new TypeError('timeoutMsc parameter has to be a number!');
|
|
713
|
+
}
|
|
796
714
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
if (timeoutMsec > 0) {
|
|
813
|
-
// we need to cast the type because Typescript is getting confused with Node.js'
|
|
814
|
-
// alternative type definitions
|
|
815
|
-
timeout = setTimeout(() => {
|
|
816
|
-
subscription.cancel();
|
|
817
|
-
reject(new BeeError('pssReceive timeout'));
|
|
818
|
-
}, timeoutMsec);
|
|
715
|
+
return new Promise((resolve, reject) => {
|
|
716
|
+
let timeout;
|
|
717
|
+
const subscription = this.pssSubscribe(topic, {
|
|
718
|
+
onError: error => {
|
|
719
|
+
clearTimeout(timeout);
|
|
720
|
+
subscription.cancel();
|
|
721
|
+
reject(error.message);
|
|
722
|
+
},
|
|
723
|
+
onMessage: message => {
|
|
724
|
+
clearTimeout(timeout);
|
|
725
|
+
subscription.cancel();
|
|
726
|
+
resolve(message);
|
|
819
727
|
}
|
|
820
728
|
});
|
|
729
|
+
|
|
730
|
+
if (timeoutMsec > 0) {
|
|
731
|
+
// we need to cast the type because Typescript is getting confused with Node.js'
|
|
732
|
+
// alternative type definitions
|
|
733
|
+
timeout = setTimeout(() => {
|
|
734
|
+
subscription.cancel();
|
|
735
|
+
reject(new BeeError('pssReceive timeout'));
|
|
736
|
+
}, timeoutMsec);
|
|
737
|
+
}
|
|
821
738
|
});
|
|
822
739
|
}
|
|
823
740
|
/**
|
|
@@ -833,21 +750,21 @@ export class Bee {
|
|
|
833
750
|
*
|
|
834
751
|
* @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
|
|
835
752
|
* @see [Bee API reference - `POST /feeds`](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1{owner}~1{topic}/post)
|
|
836
|
-
* TODO: Once breaking add support for Feed CID
|
|
837
753
|
*/
|
|
838
754
|
|
|
839
755
|
|
|
840
|
-
createFeedManifest(postageBatchId, type, topic, owner, options) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
type
|
|
849
|
-
});
|
|
756
|
+
async createFeedManifest(postageBatchId, type, topic, owner, options) {
|
|
757
|
+
assertRequestOptions(options);
|
|
758
|
+
assertFeedType(type);
|
|
759
|
+
assertBatchId(postageBatchId);
|
|
760
|
+
const canonicalTopic = makeTopic(topic);
|
|
761
|
+
const canonicalOwner = makeHexEthAddress(owner);
|
|
762
|
+
const reference = await createFeedManifest(this.getKy(options), canonicalOwner, canonicalTopic, postageBatchId, {
|
|
763
|
+
type
|
|
850
764
|
});
|
|
765
|
+
return addCidConversionFunction({
|
|
766
|
+
reference
|
|
767
|
+
}, ReferenceType.FEED);
|
|
851
768
|
}
|
|
852
769
|
/**
|
|
853
770
|
* Make a new feed reader for downloading feed updates.
|
|
@@ -907,17 +824,13 @@ export class Bee {
|
|
|
907
824
|
*/
|
|
908
825
|
|
|
909
826
|
|
|
910
|
-
setJsonFeed(postageBatchId, topic, data, options) {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
const feedType = (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : DEFAULT_FEED_TYPE;
|
|
918
|
-
const writer = this.makeFeedWriter(feedType, hashedTopic, options === null || options === void 0 ? void 0 : options.signer, options);
|
|
919
|
-
return setJsonData(this, writer, postageBatchId, data, options);
|
|
920
|
-
});
|
|
827
|
+
async setJsonFeed(postageBatchId, topic, data, options) {
|
|
828
|
+
assertRequestOptions(options, 'JsonFeedOptions');
|
|
829
|
+
assertBatchId(postageBatchId);
|
|
830
|
+
const hashedTopic = this.makeFeedTopic(topic);
|
|
831
|
+
const feedType = options?.type ?? DEFAULT_FEED_TYPE;
|
|
832
|
+
const writer = this.makeFeedWriter(feedType, hashedTopic, options?.signer, options);
|
|
833
|
+
return setJsonData(this, writer, postageBatchId, data, options);
|
|
921
834
|
}
|
|
922
835
|
/**
|
|
923
836
|
* High-level function that allows you to easily get data from feed.
|
|
@@ -940,37 +853,33 @@ export class Bee {
|
|
|
940
853
|
*/
|
|
941
854
|
|
|
942
855
|
|
|
943
|
-
getJsonFeed(topic, options) {
|
|
944
|
-
|
|
856
|
+
async getJsonFeed(topic, options) {
|
|
857
|
+
assertRequestOptions(options, 'JsonFeedOptions');
|
|
858
|
+
const hashedTopic = this.makeFeedTopic(topic);
|
|
859
|
+
const feedType = options?.type ?? DEFAULT_FEED_TYPE;
|
|
945
860
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
const feedType = (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : DEFAULT_FEED_TYPE;
|
|
861
|
+
if (options?.signer && options?.address) {
|
|
862
|
+
throw new BeeError('Both options "signer" and "address" can not be specified at one time!');
|
|
863
|
+
}
|
|
950
864
|
|
|
951
|
-
|
|
952
|
-
throw new BeeError('Both options "signer" and "address" can not be specified at one time!');
|
|
953
|
-
}
|
|
865
|
+
let address;
|
|
954
866
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
} else {
|
|
966
|
-
throw e;
|
|
967
|
-
}
|
|
867
|
+
if (options?.address) {
|
|
868
|
+
address = makeEthAddress(options?.address);
|
|
869
|
+
} else {
|
|
870
|
+
try {
|
|
871
|
+
address = this.resolveSigner(options?.signer).address;
|
|
872
|
+
} catch (e) {
|
|
873
|
+
if (e instanceof BeeError) {
|
|
874
|
+
throw new BeeError('Either address, signer or default signer has to be specified!');
|
|
875
|
+
} else {
|
|
876
|
+
throw e;
|
|
968
877
|
}
|
|
969
878
|
}
|
|
879
|
+
}
|
|
970
880
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
});
|
|
881
|
+
const reader = this.makeFeedReader(feedType, hashedTopic, address, options);
|
|
882
|
+
return getJsonData(this, reader);
|
|
974
883
|
}
|
|
975
884
|
/**
|
|
976
885
|
* Make a new feed topic from a string
|
|
@@ -1014,9 +923,9 @@ export class Bee {
|
|
|
1014
923
|
makeSOCWriter(signer, options) {
|
|
1015
924
|
assertRequestOptions(options);
|
|
1016
925
|
const canonicalSigner = this.resolveSigner(signer);
|
|
1017
|
-
return
|
|
926
|
+
return { ...this.makeSOCReader(canonicalSigner.address, options),
|
|
1018
927
|
upload: uploadSingleOwnerChunkData.bind(null, this.getKy(options), canonicalSigner)
|
|
1019
|
-
}
|
|
928
|
+
};
|
|
1020
929
|
}
|
|
1021
930
|
/**
|
|
1022
931
|
* Ping the Bee node to see if there is a live Bee node on the given URL.
|
|
@@ -1026,11 +935,9 @@ export class Bee {
|
|
|
1026
935
|
*/
|
|
1027
936
|
|
|
1028
937
|
|
|
1029
|
-
checkConnection(options) {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
return status.checkConnection(this.getKy(options));
|
|
1033
|
-
});
|
|
938
|
+
async checkConnection(options) {
|
|
939
|
+
assertRequestOptions(options, 'PostageBatchOptions');
|
|
940
|
+
return status.checkConnection(this.getKy(options));
|
|
1034
941
|
}
|
|
1035
942
|
/**
|
|
1036
943
|
* Ping the Bee node to see if there is a live Bee node on the given URL.
|
|
@@ -1040,18 +947,16 @@ export class Bee {
|
|
|
1040
947
|
*/
|
|
1041
948
|
|
|
1042
949
|
|
|
1043
|
-
isConnected(options) {
|
|
1044
|
-
|
|
1045
|
-
assertRequestOptions(options, 'PostageBatchOptions');
|
|
950
|
+
async isConnected(options) {
|
|
951
|
+
assertRequestOptions(options, 'PostageBatchOptions');
|
|
1046
952
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
953
|
+
try {
|
|
954
|
+
await status.checkConnection(this.getKy(options));
|
|
955
|
+
} catch (e) {
|
|
956
|
+
return false;
|
|
957
|
+
}
|
|
1052
958
|
|
|
1053
|
-
|
|
1054
|
-
});
|
|
959
|
+
return true;
|
|
1055
960
|
}
|
|
1056
961
|
/**
|
|
1057
962
|
* @param signer
|