@ethersphere/bee-js 3.3.2 → 3.4.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.
Files changed (48) hide show
  1. package/dist/cjs/utils/data.browser.js +6 -10
  2. package/dist/cjs/utils/data.js +4 -6
  3. package/dist/index.browser.min.js +1 -1
  4. package/dist/index.browser.min.js.map +1 -1
  5. package/dist/mjs/bee-debug.js +294 -189
  6. package/dist/mjs/bee.js +316 -237
  7. package/dist/mjs/chunk/signer.js +46 -12
  8. package/dist/mjs/chunk/soc.js +71 -31
  9. package/dist/mjs/chunk/span.js +1 -1
  10. package/dist/mjs/feed/index.js +86 -42
  11. package/dist/mjs/feed/json.js +46 -10
  12. package/dist/mjs/index.js +2 -1
  13. package/dist/mjs/modules/bytes.js +61 -24
  14. package/dist/mjs/modules/bzz.js +96 -58
  15. package/dist/mjs/modules/chunk.js +51 -16
  16. package/dist/mjs/modules/debug/balance.js +60 -20
  17. package/dist/mjs/modules/debug/chequebook.js +115 -67
  18. package/dist/mjs/modules/debug/chunk.js +47 -11
  19. package/dist/mjs/modules/debug/connectivity.js +76 -32
  20. package/dist/mjs/modules/debug/settlements.js +46 -10
  21. package/dist/mjs/modules/debug/stamps.js +91 -47
  22. package/dist/mjs/modules/debug/states.js +48 -12
  23. package/dist/mjs/modules/debug/status.js +97 -49
  24. package/dist/mjs/modules/debug/tag.js +39 -5
  25. package/dist/mjs/modules/debug/transactions.js +65 -25
  26. package/dist/mjs/modules/feed.js +50 -16
  27. package/dist/mjs/modules/pinning.js +67 -27
  28. package/dist/mjs/modules/pss.js +44 -10
  29. package/dist/mjs/modules/soc.js +47 -14
  30. package/dist/mjs/modules/status.js +37 -3
  31. package/dist/mjs/modules/stewardship.js +46 -10
  32. package/dist/mjs/modules/tag.js +73 -31
  33. package/dist/mjs/utils/collection.browser.js +41 -4
  34. package/dist/mjs/utils/collection.js +45 -11
  35. package/dist/mjs/utils/collection.node.js +137 -42
  36. package/dist/mjs/utils/data.browser.js +88 -53
  37. package/dist/mjs/utils/data.js +57 -22
  38. package/dist/mjs/utils/error.js +0 -9
  39. package/dist/mjs/utils/eth.js +68 -32
  40. package/dist/mjs/utils/file.js +42 -8
  41. package/dist/mjs/utils/headers.js +4 -4
  42. package/dist/mjs/utils/http.js +110 -64
  43. package/dist/mjs/utils/merge.js +2 -2
  44. package/dist/mjs/utils/stream.js +0 -4
  45. package/dist/mjs/utils/type.js +6 -6
  46. package/dist/types/utils/data.browser.d.ts +0 -1
  47. package/dist/types/utils/data.d.ts +2 -2
  48. package/package.json +14 -13
package/dist/mjs/bee.js CHANGED
@@ -1,3 +1,35 @@
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
+
1
33
  import * as bzz from "./modules/bzz.js";
2
34
  import * as stewardship from "./modules/stewardship.js";
3
35
  import * as tag from "./modules/tag.js";
@@ -33,57 +65,43 @@ import { isReadable } from "./utils/stream.js";
33
65
  */
34
66
 
35
67
  export class Bee {
36
- /**
37
- * URL on which is the main API of Bee node exposed
38
- */
39
- url;
40
- /**
41
- * Default Signer object used for signing operations, mainly Feeds.
42
- */
43
-
44
- signer;
45
- /**
46
- * Ky instance that defines connection to Bee node
47
- * @private
48
- */
49
-
50
- ky;
51
68
  /**
52
69
  * @param url URL on which is the main API of Bee node exposed
53
70
  * @param options
54
71
  */
55
-
56
72
  constructor(url, options) {
73
+ var _a;
74
+
57
75
  assertBeeUrl(url); // Remove last slash if present, as our endpoint strings starts with `/...`
58
76
  // which could lead to double slash in URL to which Bee responds with
59
77
  // unnecessary redirects.
60
78
 
61
79
  this.url = stripLastSlash(url);
62
80
 
63
- if (options?.signer) {
81
+ if (options === null || options === void 0 ? void 0 : options.signer) {
64
82
  this.signer = makeSigner(options.signer);
65
83
  }
66
84
 
67
85
  const kyOptions = {
68
86
  prefixUrl: this.url,
69
- timeout: options?.timeout ?? false,
70
- retry: options?.retry,
71
- fetch: options?.fetch,
87
+ timeout: (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : false,
88
+ retry: options === null || options === void 0 ? void 0 : options.retry,
89
+ fetch: options === null || options === void 0 ? void 0 : options.fetch,
72
90
  hooks: {
73
91
  beforeRequest: [],
74
92
  afterResponse: []
75
93
  }
76
94
  };
77
95
 
78
- if (options?.defaultHeaders) {
96
+ if (options === null || options === void 0 ? void 0 : options.defaultHeaders) {
79
97
  kyOptions.headers = options.defaultHeaders;
80
98
  }
81
99
 
82
- if (options?.onRequest) {
100
+ if (options === null || options === void 0 ? void 0 : options.onRequest) {
83
101
  kyOptions.hooks.beforeRequest.push(wrapRequestClosure(options.onRequest));
84
102
  }
85
103
 
86
- if (options?.onResponse) {
104
+ if (options === null || options === void 0 ? void 0 : options.onResponse) {
87
105
  kyOptions.hooks.afterResponse.push(wrapResponseClosure(options.onResponse));
88
106
  }
89
107
 
@@ -102,11 +120,13 @@ export class Bee {
102
120
  */
103
121
 
104
122
 
105
- async uploadData(postageBatchId, data, options) {
106
- assertBatchId(postageBatchId);
107
- assertData(data);
108
- if (options) assertUploadOptions(options);
109
- return bytes.upload(this.getKy(options), data, postageBatchId, options);
123
+ uploadData(postageBatchId, data, options) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ assertBatchId(postageBatchId);
126
+ assertData(data);
127
+ if (options) assertUploadOptions(options);
128
+ return bytes.upload(this.getKy(options), data, postageBatchId, options);
129
+ });
110
130
  }
111
131
  /**
112
132
  * Download data as a byte array
@@ -118,10 +138,12 @@ export class Bee {
118
138
  */
119
139
 
120
140
 
121
- async downloadData(reference, options) {
122
- assertRequestOptions(options);
123
- assertReference(reference);
124
- return bytes.download(this.getKy(options), reference);
141
+ downloadData(reference, options) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ assertRequestOptions(options);
144
+ assertReference(reference);
145
+ return bytes.download(this.getKy(options), reference);
146
+ });
125
147
  }
126
148
  /**
127
149
  * Download data as a Readable stream
@@ -133,10 +155,12 @@ export class Bee {
133
155
  */
134
156
 
135
157
 
136
- async downloadReadableData(reference, options) {
137
- assertRequestOptions(options);
138
- assertReference(reference);
139
- return bytes.downloadReadable(this.getKy(options), reference);
158
+ downloadReadableData(reference, options) {
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ assertRequestOptions(options);
161
+ assertReference(reference);
162
+ return bytes.downloadReadable(this.getKy(options), reference);
163
+ });
140
164
  }
141
165
  /**
142
166
  * Upload chunk to a Bee node
@@ -151,23 +175,25 @@ export class Bee {
151
175
  */
152
176
 
153
177
 
154
- async uploadChunk(postageBatchId, data, options) {
155
- assertBatchId(postageBatchId);
178
+ uploadChunk(postageBatchId, data, options) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ assertBatchId(postageBatchId);
156
181
 
157
- if (!(data instanceof Uint8Array)) {
158
- throw new TypeError('Data has to be Uint8Array instance!');
159
- }
182
+ if (!(data instanceof Uint8Array)) {
183
+ throw new TypeError('Data has to be Uint8Array instance!');
184
+ }
160
185
 
161
- if (data.length < SPAN_SIZE) {
162
- throw new BeeArgumentError(`Chunk has to have size of at least ${SPAN_SIZE}.`, data);
163
- }
186
+ if (data.length < SPAN_SIZE) {
187
+ throw new BeeArgumentError(`Chunk has to have size of at least ${SPAN_SIZE}.`, data);
188
+ }
164
189
 
165
- if (data.length > CHUNK_SIZE + SPAN_SIZE) {
166
- throw new BeeArgumentError(`Chunk has to have size of at most ${CHUNK_SIZE}.`, data);
167
- }
190
+ if (data.length > CHUNK_SIZE + SPAN_SIZE) {
191
+ throw new BeeArgumentError(`Chunk has to have size of at most ${CHUNK_SIZE}.`, data);
192
+ }
168
193
 
169
- if (options) assertUploadOptions(options);
170
- return chunk.upload(this.getKy(options), data, postageBatchId, options);
194
+ if (options) assertUploadOptions(options);
195
+ return chunk.upload(this.getKy(options), data, postageBatchId, options);
196
+ });
171
197
  }
172
198
  /**
173
199
  * Download chunk as a byte array
@@ -179,10 +205,12 @@ export class Bee {
179
205
  */
180
206
 
181
207
 
182
- async downloadChunk(reference, options) {
183
- assertRequestOptions(options);
184
- assertReference(reference);
185
- return chunk.download(this.getKy(options), reference);
208
+ downloadChunk(reference, options) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ assertRequestOptions(options);
211
+ assertReference(reference);
212
+ return chunk.download(this.getKy(options), reference);
213
+ });
186
214
  }
187
215
  /**
188
216
  * Upload single file to a Bee node.
@@ -202,32 +230,33 @@ export class Bee {
202
230
  */
203
231
 
204
232
 
205
- async uploadFile(postageBatchId, data, name, options) {
206
- assertBatchId(postageBatchId);
207
- assertFileData(data);
208
- if (options) assertFileUploadOptions(options);
233
+ uploadFile(postageBatchId, data, name, options) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ assertBatchId(postageBatchId);
236
+ assertFileData(data);
237
+ if (options) assertFileUploadOptions(options);
209
238
 
210
- if (name && typeof name !== 'string') {
211
- throw new TypeError('name has to be string or undefined!');
212
- }
239
+ if (name && typeof name !== 'string') {
240
+ throw new TypeError('name has to be string or undefined!');
241
+ }
213
242
 
214
- if (isFile(data)) {
215
- const fileData = await fileArrayBuffer(data);
216
- const fileName = name ?? data.name;
217
- const contentType = data.type;
218
- const fileOptions = {
219
- contentType,
220
- ...options
221
- };
222
- return bzz.uploadFile(this.getKy(options), fileData, postageBatchId, fileName, fileOptions);
223
- } else if (isReadable(data) && options?.tag && !options.size) {
224
- // TODO: Needed until https://github.com/ethersphere/bee/issues/2317 is resolved
225
- const result = await bzz.uploadFile(this.getKy(options), data, postageBatchId, name, options);
226
- await this.updateTag(options.tag, result.reference);
227
- return result;
228
- } else {
229
- return bzz.uploadFile(this.getKy(options), data, postageBatchId, name, options);
230
- }
243
+ if (isFile(data)) {
244
+ const fileData = yield fileArrayBuffer(data);
245
+ const fileName = name !== null && name !== void 0 ? name : data.name;
246
+ const contentType = data.type;
247
+ const fileOptions = Object.assign({
248
+ contentType
249
+ }, options);
250
+ return bzz.uploadFile(this.getKy(options), fileData, postageBatchId, fileName, fileOptions);
251
+ } else if (isReadable(data) && (options === null || options === void 0 ? void 0 : options.tag) && !options.size) {
252
+ // TODO: Needed until https://github.com/ethersphere/bee/issues/2317 is resolved
253
+ const result = yield bzz.uploadFile(this.getKy(options), data, postageBatchId, name, options);
254
+ yield this.updateTag(options.tag, result.reference);
255
+ return result;
256
+ } else {
257
+ return bzz.uploadFile(this.getKy(options), data, postageBatchId, name, options);
258
+ }
259
+ });
231
260
  }
232
261
  /**
233
262
  * Download single file.
@@ -242,10 +271,12 @@ export class Bee {
242
271
  */
243
272
 
244
273
 
245
- async downloadFile(reference, path = '', options) {
246
- assertRequestOptions(options);
247
- assertReference(reference);
248
- return bzz.downloadFile(this.getKy(options), reference, path);
274
+ downloadFile(reference, path = '', options) {
275
+ return __awaiter(this, void 0, void 0, function* () {
276
+ assertRequestOptions(options);
277
+ assertReference(reference);
278
+ return bzz.downloadFile(this.getKy(options), reference, path);
279
+ });
249
280
  }
250
281
  /**
251
282
  * Download single file as a readable stream
@@ -259,10 +290,12 @@ export class Bee {
259
290
  */
260
291
 
261
292
 
262
- async downloadReadableFile(reference, path = '', options) {
263
- assertRequestOptions(options);
264
- assertReference(reference);
265
- return bzz.downloadFileReadable(this.getKy(options), reference, path);
293
+ downloadReadableFile(reference, path = '', options) {
294
+ return __awaiter(this, void 0, void 0, function* () {
295
+ assertRequestOptions(options);
296
+ assertReference(reference);
297
+ return bzz.downloadFileReadable(this.getKy(options), reference, path);
298
+ });
266
299
  }
267
300
  /**
268
301
  * Upload collection of files to a Bee node
@@ -282,11 +315,13 @@ export class Bee {
282
315
  */
283
316
 
284
317
 
285
- async uploadFiles(postageBatchId, fileList, options) {
286
- assertBatchId(postageBatchId);
287
- if (options) assertCollectionUploadOptions(options);
288
- const data = await makeCollectionFromFileList(fileList);
289
- return bzz.uploadCollection(this.getKy(options), data, postageBatchId, options);
318
+ uploadFiles(postageBatchId, fileList, options) {
319
+ return __awaiter(this, void 0, void 0, function* () {
320
+ assertBatchId(postageBatchId);
321
+ if (options) assertCollectionUploadOptions(options);
322
+ const data = yield makeCollectionFromFileList(fileList);
323
+ return bzz.uploadCollection(this.getKy(options), data, postageBatchId, options);
324
+ });
290
325
  }
291
326
  /**
292
327
  * Upload Collection that you can assembly yourself.
@@ -300,11 +335,13 @@ export class Bee {
300
335
  */
301
336
 
302
337
 
303
- async uploadCollection(postageBatchId, collection, options) {
304
- assertBatchId(postageBatchId);
305
- assertCollection(collection);
306
- if (options) assertCollectionUploadOptions(options);
307
- return bzz.uploadCollection(this.ky, collection, postageBatchId, options);
338
+ uploadCollection(postageBatchId, collection, options) {
339
+ return __awaiter(this, void 0, void 0, function* () {
340
+ assertBatchId(postageBatchId);
341
+ assertCollection(collection);
342
+ if (options) assertCollectionUploadOptions(options);
343
+ return bzz.uploadCollection(this.ky, collection, postageBatchId, options);
344
+ });
308
345
  }
309
346
  /**
310
347
  * Upload collection of files.
@@ -324,11 +361,13 @@ export class Bee {
324
361
  */
325
362
 
326
363
 
327
- async uploadFilesFromDirectory(postageBatchId, dir, options) {
328
- assertBatchId(postageBatchId);
329
- if (options) assertCollectionUploadOptions(options);
330
- const data = await makeCollectionFromFS(dir);
331
- return bzz.uploadCollection(this.getKy(options), data, postageBatchId, options);
364
+ uploadFilesFromDirectory(postageBatchId, dir, options) {
365
+ return __awaiter(this, void 0, void 0, function* () {
366
+ assertBatchId(postageBatchId);
367
+ if (options) assertCollectionUploadOptions(options);
368
+ const data = yield makeCollectionFromFS(dir);
369
+ return bzz.uploadCollection(this.getKy(options), data, postageBatchId, options);
370
+ });
332
371
  }
333
372
  /**
334
373
  * Create a new Tag which is meant for tracking progres of syncing data across network.
@@ -341,9 +380,11 @@ export class Bee {
341
380
  */
342
381
 
343
382
 
344
- async createTag(options) {
345
- assertRequestOptions(options);
346
- return tag.createTag(this.getKy(options));
383
+ createTag(options) {
384
+ return __awaiter(this, void 0, void 0, function* () {
385
+ assertRequestOptions(options);
386
+ return tag.createTag(this.getKy(options));
387
+ });
347
388
  }
348
389
  /**
349
390
  * Fetches all tags.
@@ -361,10 +402,12 @@ export class Bee {
361
402
  */
362
403
 
363
404
 
364
- async getAllTags(options) {
365
- assertRequestOptions(options);
366
- assertAllTagsOptions(options);
367
- return tag.getAllTags(this.getKy(options), options?.offset, options?.limit);
405
+ getAllTags(options) {
406
+ return __awaiter(this, void 0, void 0, function* () {
407
+ assertRequestOptions(options);
408
+ assertAllTagsOptions(options);
409
+ return tag.getAllTags(this.getKy(options), options === null || options === void 0 ? void 0 : options.offset, options === null || options === void 0 ? void 0 : options.limit);
410
+ });
368
411
  }
369
412
  /**
370
413
  * Retrieve tag information from Bee node
@@ -381,10 +424,12 @@ export class Bee {
381
424
  */
382
425
 
383
426
 
384
- async retrieveTag(tagUid, options) {
385
- assertRequestOptions(options);
386
- tagUid = makeTagUid(tagUid);
387
- return tag.retrieveTag(this.getKy(options), tagUid);
427
+ retrieveTag(tagUid, options) {
428
+ return __awaiter(this, void 0, void 0, function* () {
429
+ assertRequestOptions(options);
430
+ tagUid = makeTagUid(tagUid);
431
+ return tag.retrieveTag(this.getKy(options), tagUid);
432
+ });
388
433
  }
389
434
  /**
390
435
  * Delete Tag
@@ -401,10 +446,12 @@ export class Bee {
401
446
  */
402
447
 
403
448
 
404
- async deleteTag(tagUid, options) {
405
- assertRequestOptions(options);
406
- tagUid = makeTagUid(tagUid);
407
- return tag.deleteTag(this.getKy(options), tagUid);
449
+ deleteTag(tagUid, options) {
450
+ return __awaiter(this, void 0, void 0, function* () {
451
+ assertRequestOptions(options);
452
+ tagUid = makeTagUid(tagUid);
453
+ return tag.deleteTag(this.getKy(options), tagUid);
454
+ });
408
455
  }
409
456
  /**
410
457
  * Update tag's total chunks count.
@@ -425,11 +472,13 @@ export class Bee {
425
472
  */
426
473
 
427
474
 
428
- async updateTag(tagUid, reference, options) {
429
- assertReference(reference);
430
- assertRequestOptions(options);
431
- tagUid = makeTagUid(tagUid);
432
- return tag.updateTag(this.getKy(options), tagUid, reference);
475
+ updateTag(tagUid, reference, options) {
476
+ return __awaiter(this, void 0, void 0, function* () {
477
+ assertReference(reference);
478
+ assertRequestOptions(options);
479
+ tagUid = makeTagUid(tagUid);
480
+ return tag.updateTag(this.getKy(options), tagUid, reference);
481
+ });
433
482
  }
434
483
  /**
435
484
  * Pin local data with given reference
@@ -444,10 +493,12 @@ export class Bee {
444
493
  */
445
494
 
446
495
 
447
- async pin(reference, options) {
448
- assertRequestOptions(options);
449
- assertReference(reference);
450
- return pinning.pin(this.getKy(options), reference);
496
+ pin(reference, options) {
497
+ return __awaiter(this, void 0, void 0, function* () {
498
+ assertRequestOptions(options);
499
+ assertReference(reference);
500
+ return pinning.pin(this.getKy(options), reference);
501
+ });
451
502
  }
452
503
  /**
453
504
  * Unpin local data with given reference
@@ -462,10 +513,12 @@ export class Bee {
462
513
  */
463
514
 
464
515
 
465
- async unpin(reference, options) {
466
- assertRequestOptions(options);
467
- assertReference(reference);
468
- return pinning.unpin(this.getKy(options), reference);
516
+ unpin(reference, options) {
517
+ return __awaiter(this, void 0, void 0, function* () {
518
+ assertRequestOptions(options);
519
+ assertReference(reference);
520
+ return pinning.unpin(this.getKy(options), reference);
521
+ });
469
522
  }
470
523
  /**
471
524
  * Get list of all locally pinned references
@@ -477,9 +530,11 @@ export class Bee {
477
530
  */
478
531
 
479
532
 
480
- async getAllPins(options) {
481
- assertRequestOptions(options);
482
- return pinning.getAllPins(this.getKy(options));
533
+ getAllPins(options) {
534
+ return __awaiter(this, void 0, void 0, function* () {
535
+ assertRequestOptions(options);
536
+ return pinning.getAllPins(this.getKy(options));
537
+ });
483
538
  }
484
539
  /**
485
540
  * Get pinning status of chunk with given reference
@@ -494,10 +549,12 @@ export class Bee {
494
549
  */
495
550
 
496
551
 
497
- async getPin(reference, options) {
498
- assertRequestOptions(options);
499
- assertReference(reference);
500
- return pinning.getPin(this.getKy(options), reference);
552
+ getPin(reference, options) {
553
+ return __awaiter(this, void 0, void 0, function* () {
554
+ assertRequestOptions(options);
555
+ assertReference(reference);
556
+ return pinning.getPin(this.getKy(options), reference);
557
+ });
501
558
  }
502
559
  /**
503
560
  * Instructs the Bee node to reupload a locally pinned data into the network.
@@ -511,10 +568,12 @@ export class Bee {
511
568
  */
512
569
 
513
570
 
514
- async reuploadPinnedData(reference, options) {
515
- assertRequestOptions(options);
516
- assertReference(reference);
517
- await stewardship.reupload(this.getKy(options), reference);
571
+ reuploadPinnedData(reference, options) {
572
+ return __awaiter(this, void 0, void 0, function* () {
573
+ assertRequestOptions(options);
574
+ assertReference(reference);
575
+ yield stewardship.reupload(this.getKy(options), reference);
576
+ });
518
577
  }
519
578
  /**
520
579
  * Checks if content specified by reference is retrievable from the network.
@@ -526,10 +585,12 @@ export class Bee {
526
585
  */
527
586
 
528
587
 
529
- async isReferenceRetrievable(reference, options) {
530
- assertRequestOptions(options);
531
- assertReference(reference);
532
- return stewardship.isRetrievable(this.getKy(options), reference);
588
+ isReferenceRetrievable(reference, options) {
589
+ return __awaiter(this, void 0, void 0, function* () {
590
+ assertRequestOptions(options);
591
+ assertReference(reference);
592
+ return stewardship.isRetrievable(this.getKy(options), reference);
593
+ });
533
594
  }
534
595
  /**
535
596
  * Send data to recipient or target with Postal Service for Swarm.
@@ -557,22 +618,24 @@ export class Bee {
557
618
  */
558
619
 
559
620
 
560
- async pssSend(postageBatchId, topic, target, data, recipient, options) {
561
- assertRequestOptions(options);
562
- assertData(data);
563
- assertBatchId(postageBatchId);
564
- assertAddressPrefix(target);
621
+ pssSend(postageBatchId, topic, target, data, recipient, options) {
622
+ return __awaiter(this, void 0, void 0, function* () {
623
+ assertRequestOptions(options);
624
+ assertData(data);
625
+ assertBatchId(postageBatchId);
626
+ assertAddressPrefix(target);
565
627
 
566
- if (typeof topic !== 'string') {
567
- throw new TypeError('topic has to be an string!');
568
- }
628
+ if (typeof topic !== 'string') {
629
+ throw new TypeError('topic has to be an string!');
630
+ }
569
631
 
570
- if (recipient) {
571
- assertPublicKey(recipient);
572
- return pss.send(this.getKy(options), topic, target, data, postageBatchId, recipient);
573
- } else {
574
- return pss.send(this.getKy(options), topic, target, data, postageBatchId);
575
- }
632
+ if (recipient) {
633
+ assertPublicKey(recipient);
634
+ return pss.send(this.getKy(options), topic, target, data, postageBatchId, recipient);
635
+ } else {
636
+ return pss.send(this.getKy(options), topic, target, data, postageBatchId);
637
+ }
638
+ });
576
639
  }
577
640
  /**
578
641
  * Subscribe to messages for given topic with Postal Service for Swarm
@@ -617,13 +680,13 @@ export class Bee {
617
680
  cancel
618
681
  };
619
682
 
620
- ws.onmessage = async ev => {
621
- const data = await prepareWebsocketData(ev.data); // ignore empty messages
683
+ ws.onmessage = ev => __awaiter(this, void 0, void 0, function* () {
684
+ const data = yield prepareWebsocketData(ev.data); // ignore empty messages
622
685
 
623
686
  if (data.length > 0) {
624
687
  handler.onMessage(wrapBytesWithHelpers(data), subscription);
625
688
  }
626
- };
689
+ });
627
690
 
628
691
  ws.onerror = ev => {
629
692
  // ignore errors after subscription was cancelled
@@ -662,38 +725,40 @@ export class Bee {
662
725
  */
663
726
 
664
727
 
665
- async pssReceive(topic, timeoutMsec = 0) {
666
- if (typeof topic !== 'string') {
667
- throw new TypeError('topic has to be an string!');
668
- }
728
+ pssReceive(topic, timeoutMsec = 0) {
729
+ return __awaiter(this, void 0, void 0, function* () {
730
+ if (typeof topic !== 'string') {
731
+ throw new TypeError('topic has to be an string!');
732
+ }
669
733
 
670
- if (typeof timeoutMsec !== 'number') {
671
- throw new TypeError('timeoutMsc parameter has to be a number!');
672
- }
734
+ if (typeof timeoutMsec !== 'number') {
735
+ throw new TypeError('timeoutMsc parameter has to be a number!');
736
+ }
673
737
 
674
- return new Promise((resolve, reject) => {
675
- let timeout;
676
- const subscription = this.pssSubscribe(topic, {
677
- onError: error => {
678
- clearTimeout(timeout);
679
- subscription.cancel();
680
- reject(error.message);
681
- },
682
- onMessage: message => {
683
- clearTimeout(timeout);
684
- subscription.cancel();
685
- resolve(message);
738
+ return new Promise((resolve, reject) => {
739
+ let timeout;
740
+ const subscription = this.pssSubscribe(topic, {
741
+ onError: error => {
742
+ clearTimeout(timeout);
743
+ subscription.cancel();
744
+ reject(error.message);
745
+ },
746
+ onMessage: message => {
747
+ clearTimeout(timeout);
748
+ subscription.cancel();
749
+ resolve(message);
750
+ }
751
+ });
752
+
753
+ if (timeoutMsec > 0) {
754
+ // we need to cast the type because Typescript is getting confused with Node.js'
755
+ // alternative type definitions
756
+ timeout = setTimeout(() => {
757
+ subscription.cancel();
758
+ reject(new BeeError('pssReceive timeout'));
759
+ }, timeoutMsec);
686
760
  }
687
761
  });
688
-
689
- if (timeoutMsec > 0) {
690
- // we need to cast the type because Typescript is getting confused with Node.js'
691
- // alternative type definitions
692
- timeout = setTimeout(() => {
693
- subscription.cancel();
694
- reject(new BeeError('pssReceive timeout'));
695
- }, timeoutMsec);
696
- }
697
762
  });
698
763
  }
699
764
  /**
@@ -712,14 +777,16 @@ export class Bee {
712
777
  */
713
778
 
714
779
 
715
- async createFeedManifest(postageBatchId, type, topic, owner, options) {
716
- assertRequestOptions(options);
717
- assertFeedType(type);
718
- assertBatchId(postageBatchId);
719
- const canonicalTopic = makeTopic(topic);
720
- const canonicalOwner = makeHexEthAddress(owner);
721
- return createFeedManifest(this.getKy(options), canonicalOwner, canonicalTopic, postageBatchId, {
722
- type
780
+ createFeedManifest(postageBatchId, type, topic, owner, options) {
781
+ return __awaiter(this, void 0, void 0, function* () {
782
+ assertRequestOptions(options);
783
+ assertFeedType(type);
784
+ assertBatchId(postageBatchId);
785
+ const canonicalTopic = makeTopic(topic);
786
+ const canonicalOwner = makeHexEthAddress(owner);
787
+ return createFeedManifest(this.getKy(options), canonicalOwner, canonicalTopic, postageBatchId, {
788
+ type
789
+ });
723
790
  });
724
791
  }
725
792
  /**
@@ -780,13 +847,17 @@ export class Bee {
780
847
  */
781
848
 
782
849
 
783
- async setJsonFeed(postageBatchId, topic, data, options) {
784
- assertRequestOptions(options, 'JsonFeedOptions');
785
- assertBatchId(postageBatchId);
786
- const hashedTopic = this.makeFeedTopic(topic);
787
- const feedType = options?.type ?? DEFAULT_FEED_TYPE;
788
- const writer = this.makeFeedWriter(feedType, hashedTopic, options?.signer, options);
789
- return setJsonData(this, writer, postageBatchId, data, options);
850
+ setJsonFeed(postageBatchId, topic, data, options) {
851
+ var _a;
852
+
853
+ return __awaiter(this, void 0, void 0, function* () {
854
+ assertRequestOptions(options, 'JsonFeedOptions');
855
+ assertBatchId(postageBatchId);
856
+ const hashedTopic = this.makeFeedTopic(topic);
857
+ const feedType = (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : DEFAULT_FEED_TYPE;
858
+ const writer = this.makeFeedWriter(feedType, hashedTopic, options === null || options === void 0 ? void 0 : options.signer, options);
859
+ return setJsonData(this, writer, postageBatchId, data, options);
860
+ });
790
861
  }
791
862
  /**
792
863
  * High-level function that allows you to easily get data from feed.
@@ -809,33 +880,37 @@ export class Bee {
809
880
  */
810
881
 
811
882
 
812
- async getJsonFeed(topic, options) {
813
- assertRequestOptions(options, 'JsonFeedOptions');
814
- const hashedTopic = this.makeFeedTopic(topic);
815
- const feedType = options?.type ?? DEFAULT_FEED_TYPE;
883
+ getJsonFeed(topic, options) {
884
+ var _a;
816
885
 
817
- if (options?.signer && options?.address) {
818
- throw new BeeError('Both options "signer" and "address" can not be specified at one time!');
819
- }
886
+ return __awaiter(this, void 0, void 0, function* () {
887
+ assertRequestOptions(options, 'JsonFeedOptions');
888
+ const hashedTopic = this.makeFeedTopic(topic);
889
+ const feedType = (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : DEFAULT_FEED_TYPE;
820
890
 
821
- let address;
891
+ if ((options === null || options === void 0 ? void 0 : options.signer) && (options === null || options === void 0 ? void 0 : options.address)) {
892
+ throw new BeeError('Both options "signer" and "address" can not be specified at one time!');
893
+ }
822
894
 
823
- if (options?.address) {
824
- address = makeEthAddress(options?.address);
825
- } else {
826
- try {
827
- address = this.resolveSigner(options?.signer).address;
828
- } catch (e) {
829
- if (e instanceof BeeError) {
830
- throw new BeeError('Either address, signer or default signer has to be specified!');
831
- } else {
832
- throw e;
895
+ let address;
896
+
897
+ if (options === null || options === void 0 ? void 0 : options.address) {
898
+ address = makeEthAddress(options === null || options === void 0 ? void 0 : options.address);
899
+ } else {
900
+ try {
901
+ address = this.resolveSigner(options === null || options === void 0 ? void 0 : options.signer).address;
902
+ } catch (e) {
903
+ if (e instanceof BeeError) {
904
+ throw new BeeError('Either address, signer or default signer has to be specified!');
905
+ } else {
906
+ throw e;
907
+ }
833
908
  }
834
909
  }
835
- }
836
910
 
837
- const reader = this.makeFeedReader(feedType, hashedTopic, address, options);
838
- return getJsonData(this, reader);
911
+ const reader = this.makeFeedReader(feedType, hashedTopic, address, options);
912
+ return getJsonData(this, reader);
913
+ });
839
914
  }
840
915
  /**
841
916
  * Make a new feed topic from a string
@@ -879,9 +954,9 @@ export class Bee {
879
954
  makeSOCWriter(signer, options) {
880
955
  assertRequestOptions(options);
881
956
  const canonicalSigner = this.resolveSigner(signer);
882
- return { ...this.makeSOCReader(canonicalSigner.address, options),
957
+ return Object.assign(Object.assign({}, this.makeSOCReader(canonicalSigner.address, options)), {
883
958
  upload: uploadSingleOwnerChunkData.bind(null, this.getKy(options), canonicalSigner)
884
- };
959
+ });
885
960
  }
886
961
  /**
887
962
  * Ping the Bee node to see if there is a live Bee node on the given URL.
@@ -891,9 +966,11 @@ export class Bee {
891
966
  */
892
967
 
893
968
 
894
- async checkConnection(options) {
895
- assertRequestOptions(options, 'PostageBatchOptions');
896
- return status.checkConnection(this.getKy(options));
969
+ checkConnection(options) {
970
+ return __awaiter(this, void 0, void 0, function* () {
971
+ assertRequestOptions(options, 'PostageBatchOptions');
972
+ return status.checkConnection(this.getKy(options));
973
+ });
897
974
  }
898
975
  /**
899
976
  * Ping the Bee node to see if there is a live Bee node on the given URL.
@@ -903,16 +980,18 @@ export class Bee {
903
980
  */
904
981
 
905
982
 
906
- async isConnected(options) {
907
- assertRequestOptions(options, 'PostageBatchOptions');
983
+ isConnected(options) {
984
+ return __awaiter(this, void 0, void 0, function* () {
985
+ assertRequestOptions(options, 'PostageBatchOptions');
908
986
 
909
- try {
910
- await status.checkConnection(this.getKy(options));
911
- } catch (e) {
912
- return false;
913
- }
987
+ try {
988
+ yield status.checkConnection(this.getKy(options));
989
+ } catch (e) {
990
+ return false;
991
+ }
914
992
 
915
- return true;
993
+ return true;
994
+ });
916
995
  }
917
996
  /**
918
997
  * @param signer