@ethersphere/bee-js 5.2.0 → 6.0.0-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.
Files changed (111) hide show
  1. package/dist/cjs/bee-debug.js +58 -72
  2. package/dist/cjs/bee.js +71 -86
  3. package/dist/cjs/chunk/soc.js +14 -14
  4. package/dist/cjs/feed/index.js +20 -21
  5. package/dist/cjs/feed/json.js +2 -2
  6. package/dist/cjs/feed/retrievable.js +7 -8
  7. package/dist/cjs/index.js +7 -7
  8. package/dist/cjs/modules/bytes.js +15 -15
  9. package/dist/cjs/modules/bzz.js +24 -25
  10. package/dist/cjs/modules/chunk.js +10 -10
  11. package/dist/cjs/modules/debug/balance.js +16 -16
  12. package/dist/cjs/modules/debug/chequebook.js +34 -34
  13. package/dist/cjs/modules/debug/chunk.js +8 -8
  14. package/dist/cjs/modules/debug/connectivity.js +24 -24
  15. package/dist/cjs/modules/debug/settlements.js +8 -8
  16. package/dist/cjs/modules/debug/stake.js +11 -11
  17. package/dist/cjs/modules/debug/stamps.js +25 -25
  18. package/dist/cjs/modules/debug/states.js +12 -12
  19. package/dist/cjs/modules/debug/status.js +24 -24
  20. package/dist/cjs/modules/debug/tag.js +4 -4
  21. package/dist/cjs/modules/debug/transactions.js +16 -16
  22. package/dist/cjs/modules/feed.js +14 -14
  23. package/dist/cjs/modules/pinning.js +14 -14
  24. package/dist/cjs/modules/pss.js +6 -6
  25. package/dist/cjs/modules/soc.js +6 -6
  26. package/dist/cjs/modules/status.js +3 -3
  27. package/dist/cjs/modules/stewardship.js +7 -7
  28. package/dist/cjs/modules/tag.js +20 -20
  29. package/dist/cjs/utils/error.js +1 -35
  30. package/dist/cjs/utils/headers.js +3 -3
  31. package/dist/cjs/utils/http.js +14 -141
  32. package/dist/cjs/utils/type.js +1 -4
  33. package/dist/index.browser.min.js +1 -1
  34. package/dist/index.browser.min.js.LICENSE.txt +0 -8
  35. package/dist/index.browser.min.js.map +1 -1
  36. package/dist/mjs/bee-debug.js +59 -73
  37. package/dist/mjs/bee.js +72 -87
  38. package/dist/mjs/chunk/soc.js +14 -14
  39. package/dist/mjs/feed/index.js +20 -21
  40. package/dist/mjs/feed/json.js +2 -2
  41. package/dist/mjs/feed/retrievable.js +7 -8
  42. package/dist/mjs/index.js +2 -2
  43. package/dist/mjs/modules/bytes.js +15 -15
  44. package/dist/mjs/modules/bzz.js +24 -25
  45. package/dist/mjs/modules/chunk.js +10 -10
  46. package/dist/mjs/modules/debug/balance.js +16 -16
  47. package/dist/mjs/modules/debug/chequebook.js +34 -34
  48. package/dist/mjs/modules/debug/chunk.js +8 -8
  49. package/dist/mjs/modules/debug/connectivity.js +24 -24
  50. package/dist/mjs/modules/debug/settlements.js +8 -8
  51. package/dist/mjs/modules/debug/stake.js +11 -11
  52. package/dist/mjs/modules/debug/stamps.js +25 -25
  53. package/dist/mjs/modules/debug/states.js +12 -12
  54. package/dist/mjs/modules/debug/status.js +24 -25
  55. package/dist/mjs/modules/debug/tag.js +4 -4
  56. package/dist/mjs/modules/debug/transactions.js +16 -16
  57. package/dist/mjs/modules/feed.js +14 -14
  58. package/dist/mjs/modules/pinning.js +14 -14
  59. package/dist/mjs/modules/pss.js +6 -6
  60. package/dist/mjs/modules/soc.js +6 -6
  61. package/dist/mjs/modules/status.js +3 -3
  62. package/dist/mjs/modules/stewardship.js +7 -7
  63. package/dist/mjs/modules/tag.js +20 -20
  64. package/dist/mjs/utils/error.js +0 -31
  65. package/dist/mjs/utils/headers.js +3 -3
  66. package/dist/mjs/utils/http.js +10 -138
  67. package/dist/mjs/utils/type.js +2 -5
  68. package/dist/types/bee-debug.d.ts +50 -50
  69. package/dist/types/bee.d.ts +34 -34
  70. package/dist/types/chunk/soc.d.ts +5 -6
  71. package/dist/types/feed/index.d.ts +7 -8
  72. package/dist/types/feed/json.d.ts +2 -2
  73. package/dist/types/feed/retrievable.d.ts +2 -2
  74. package/dist/types/index.d.ts +2 -4
  75. package/dist/types/modules/bytes.d.ts +4 -5
  76. package/dist/types/modules/bzz.d.ts +5 -6
  77. package/dist/types/modules/chunk.d.ts +3 -4
  78. package/dist/types/modules/debug/balance.d.ts +5 -6
  79. package/dist/types/modules/debug/chequebook.d.ts +9 -10
  80. package/dist/types/modules/debug/chunk.d.ts +3 -4
  81. package/dist/types/modules/debug/connectivity.d.ts +7 -8
  82. package/dist/types/modules/debug/settlements.d.ts +3 -4
  83. package/dist/types/modules/debug/stake.d.ts +4 -5
  84. package/dist/types/modules/debug/stamps.d.ts +7 -8
  85. package/dist/types/modules/debug/states.d.ts +4 -5
  86. package/dist/types/modules/debug/status.d.ts +10 -10
  87. package/dist/types/modules/debug/tag.d.ts +2 -3
  88. package/dist/types/modules/debug/transactions.d.ts +5 -6
  89. package/dist/types/modules/feed.d.ts +3 -4
  90. package/dist/types/modules/pinning.d.ts +5 -6
  91. package/dist/types/modules/pss.d.ts +2 -3
  92. package/dist/types/modules/soc.d.ts +2 -3
  93. package/dist/types/modules/status.d.ts +2 -2
  94. package/dist/types/modules/stewardship.d.ts +3 -4
  95. package/dist/types/modules/tag.d.ts +6 -7
  96. package/dist/types/types/debug.d.ts +2 -2
  97. package/dist/types/types/index.d.ts +12 -51
  98. package/dist/types/utils/error.d.ts +0 -26
  99. package/dist/types/utils/headers.d.ts +1 -1
  100. package/dist/types/utils/http.d.ts +12 -21
  101. package/dist/types/utils/type.d.ts +2 -2
  102. package/package.json +4 -4
  103. package/dist/223.index.browser.min.js +0 -3
  104. package/dist/223.index.browser.min.js.LICENSE.txt +0 -1
  105. package/dist/223.index.browser.min.js.map +0 -1
  106. package/dist/cjs/utils/merge.js +0 -34
  107. package/dist/cjs/utils/sleep.js +0 -12
  108. package/dist/mjs/utils/merge.js +0 -32
  109. package/dist/mjs/utils/sleep.js +0 -8
  110. package/dist/types/utils/merge.d.ts +0 -8
  111. package/dist/types/utils/sleep.d.ts +0 -6
package/dist/cjs/bee.js CHANGED
@@ -24,36 +24,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Bee = void 0;
27
- const bzz = __importStar(require("./modules/bzz"));
28
- const stewardship = __importStar(require("./modules/stewardship"));
29
- const tag = __importStar(require("./modules/tag"));
30
- const pinning = __importStar(require("./modules/pinning"));
31
- const bytes = __importStar(require("./modules/bytes"));
32
- const chunk = __importStar(require("./modules/chunk"));
33
- const pss = __importStar(require("./modules/pss"));
34
- const status = __importStar(require("./modules/status"));
35
- const error_1 = require("./utils/error");
36
- const data_1 = require("./utils/data");
37
- const file_1 = require("./utils/file");
38
- const feed_1 = require("./feed");
27
+ const swarm_cid_1 = require("@ethersphere/swarm-cid");
28
+ const cafe_utility_1 = require("cafe-utility");
39
29
  const signer_1 = require("./chunk/signer");
40
- const type_1 = require("./feed/type");
41
30
  const soc_1 = require("./chunk/soc");
31
+ const feed_1 = require("./feed");
32
+ const json_1 = require("./feed/json");
33
+ const retrievable_1 = require("./feed/retrievable");
42
34
  const topic_1 = require("./feed/topic");
35
+ const type_1 = require("./feed/type");
36
+ const bytes = __importStar(require("./modules/bytes"));
37
+ const bzz = __importStar(require("./modules/bzz"));
38
+ const chunk = __importStar(require("./modules/chunk"));
43
39
  const feed_2 = require("./modules/feed");
44
- const url_1 = require("./utils/url");
45
- const eth_1 = require("./utils/eth");
40
+ const pinning = __importStar(require("./modules/pinning"));
41
+ const pss = __importStar(require("./modules/pss"));
42
+ const status = __importStar(require("./modules/status"));
43
+ const stewardship = __importStar(require("./modules/stewardship"));
44
+ const tag = __importStar(require("./modules/tag"));
45
+ const types_1 = require("./types");
46
46
  const bytes_1 = require("./utils/bytes");
47
- const type_2 = require("./utils/type");
48
- const json_1 = require("./feed/json");
49
47
  const collection_1 = require("./utils/collection");
50
48
  const collection_node_1 = require("./utils/collection.node");
51
- const types_1 = require("./types");
52
- const http_1 = require("./utils/http");
49
+ const data_1 = require("./utils/data");
50
+ const error_1 = require("./utils/error");
51
+ const eth_1 = require("./utils/eth");
52
+ const file_1 = require("./utils/file");
53
53
  const stream_1 = require("./utils/stream");
54
- const retrievable_1 = require("./feed/retrievable");
55
- const swarm_cid_1 = require("@ethersphere/swarm-cid");
56
- const merge_1 = require("./utils/merge");
54
+ const type_2 = require("./utils/type");
55
+ const url_1 = require("./utils/url");
57
56
  /**
58
57
  * The main component that abstracts operations available on the main Bee API.
59
58
  *
@@ -74,26 +73,14 @@ class Bee {
74
73
  if (options?.signer) {
75
74
  this.signer = (0, signer_1.makeSigner)(options.signer);
76
75
  }
77
- const kyOptions = {
78
- prefixUrl: this.url,
76
+ const requestOptions = {
77
+ baseURL: this.url,
79
78
  timeout: options?.timeout ?? false,
80
- retry: options?.retry,
81
- fetch: options?.fetch,
82
- hooks: {
83
- beforeRequest: [],
84
- afterResponse: [],
85
- },
86
79
  };
87
- if (options?.defaultHeaders) {
88
- kyOptions.headers = options.defaultHeaders;
89
- }
90
- if (options?.onRequest) {
91
- kyOptions.hooks.beforeRequest.push((0, http_1.wrapRequestClosure)(options.onRequest));
92
- }
93
- if (options?.onResponse) {
94
- kyOptions.hooks.afterResponse.push((0, http_1.wrapResponseClosure)(options.onResponse));
80
+ if (options?.headers) {
81
+ requestOptions.headers = options.headers;
95
82
  }
96
- this.kyOptions = (0, merge_1.deepMerge)(http_1.DEFAULT_KY_CONFIG, kyOptions);
83
+ this.requestOptions = requestOptions;
97
84
  }
98
85
  /**
99
86
  * Upload data to a Bee node
@@ -106,12 +93,12 @@ class Bee {
106
93
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
107
94
  * @see [Bee API reference - `POST /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post)
108
95
  */
109
- async uploadData(postageBatchId, data, options) {
96
+ async uploadData(postageBatchId, data, options, requestOptions) {
110
97
  (0, type_2.assertBatchId)(postageBatchId);
111
98
  (0, type_2.assertData)(data);
112
99
  if (options)
113
100
  (0, type_2.assertUploadOptions)(options);
114
- return bytes.upload(this.getKyOptionsForCall(options), data, postageBatchId, options);
101
+ return bytes.upload(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
115
102
  }
116
103
  /**
117
104
  * Download data as a byte array
@@ -126,7 +113,7 @@ class Bee {
126
113
  async downloadData(reference, options) {
127
114
  (0, type_2.assertRequestOptions)(options);
128
115
  (0, type_2.assertReferenceOrEns)(reference);
129
- return bytes.download(this.getKyOptionsForCall(options), reference);
116
+ return bytes.download(this.getRequestOptionsForCall(options), reference);
130
117
  }
131
118
  /**
132
119
  * Download data as a Readable stream
@@ -141,7 +128,7 @@ class Bee {
141
128
  async downloadReadableData(reference, options) {
142
129
  (0, type_2.assertRequestOptions)(options);
143
130
  (0, type_2.assertReferenceOrEns)(reference);
144
- return bytes.downloadReadable(this.getKyOptionsForCall(options), reference);
131
+ return bytes.downloadReadable(this.getRequestOptionsForCall(options), reference);
145
132
  }
146
133
  /**
147
134
  * Upload chunk to a Bee node
@@ -154,7 +141,7 @@ class Bee {
154
141
  * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
155
142
  * @see [Bee API reference - `POST /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post)
156
143
  */
157
- async uploadChunk(postageBatchId, data, options) {
144
+ async uploadChunk(postageBatchId, data, options, requestOptions) {
158
145
  (0, type_2.assertBatchId)(postageBatchId);
159
146
  if (!(data instanceof Uint8Array)) {
160
147
  throw new TypeError('Data has to be Uint8Array instance!');
@@ -167,7 +154,7 @@ class Bee {
167
154
  }
168
155
  if (options)
169
156
  (0, type_2.assertUploadOptions)(options);
170
- return chunk.upload(this.getKyOptionsForCall(options), data, postageBatchId, options);
157
+ return chunk.upload(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options);
171
158
  }
172
159
  /**
173
160
  * Download chunk as a byte array
@@ -182,7 +169,7 @@ class Bee {
182
169
  async downloadChunk(reference, options) {
183
170
  (0, type_2.assertRequestOptions)(options);
184
171
  (0, type_2.assertReferenceOrEns)(reference);
185
- return chunk.download(this.getKyOptionsForCall(options), reference);
172
+ return chunk.download(this.getRequestOptionsForCall(options), reference);
186
173
  }
187
174
  /**
188
175
  * Upload single file to a Bee node.
@@ -200,7 +187,7 @@ class Bee {
200
187
  * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/File/paths/~1bzz/post)
201
188
  * @returns reference is a content hash of the file
202
189
  */
203
- async uploadFile(postageBatchId, data, name, options) {
190
+ async uploadFile(postageBatchId, data, name, options, requestOptions) {
204
191
  (0, type_2.assertBatchId)(postageBatchId);
205
192
  (0, type_2.assertFileData)(data);
206
193
  if (options)
@@ -213,16 +200,16 @@ class Bee {
213
200
  const fileName = name ?? data.name;
214
201
  const contentType = data.type;
215
202
  const fileOptions = { contentType, ...options };
216
- return (0, type_2.addCidConversionFunction)(await bzz.uploadFile(this.getKyOptionsForCall(options), fileData, postageBatchId, fileName, fileOptions), swarm_cid_1.ReferenceType.MANIFEST);
203
+ return (0, type_2.addCidConversionFunction)(await bzz.uploadFile(this.getRequestOptionsForCall(requestOptions), fileData, postageBatchId, fileName, fileOptions), swarm_cid_1.ReferenceType.MANIFEST);
217
204
  }
218
205
  else if ((0, stream_1.isReadable)(data) && options?.tag && !options.size) {
219
206
  // TODO: Needed until https://github.com/ethersphere/bee/issues/2317 is resolved
220
- const result = await bzz.uploadFile(this.getKyOptionsForCall(options), data, postageBatchId, name, options);
207
+ const result = await bzz.uploadFile(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, name, options);
221
208
  await this.updateTag(options.tag, result.reference);
222
209
  return (0, type_2.addCidConversionFunction)(result, swarm_cid_1.ReferenceType.MANIFEST);
223
210
  }
224
211
  else {
225
- return (0, type_2.addCidConversionFunction)(await bzz.uploadFile(this.getKyOptionsForCall(options), data, postageBatchId, name, options), swarm_cid_1.ReferenceType.MANIFEST);
212
+ return (0, type_2.addCidConversionFunction)(await bzz.uploadFile(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, name, options), swarm_cid_1.ReferenceType.MANIFEST);
226
213
  }
227
214
  }
228
215
  /**
@@ -240,7 +227,7 @@ class Bee {
240
227
  async downloadFile(reference, path = '', options) {
241
228
  (0, type_2.assertRequestOptions)(options);
242
229
  reference = (0, type_2.makeReferenceOrEns)(reference, swarm_cid_1.ReferenceType.MANIFEST);
243
- return bzz.downloadFile(this.getKyOptionsForCall(options), reference, path);
230
+ return bzz.downloadFile(this.getRequestOptionsForCall(options), reference, path);
244
231
  }
245
232
  /**
246
233
  * Download single file as a readable stream
@@ -257,7 +244,7 @@ class Bee {
257
244
  async downloadReadableFile(reference, path = '', options) {
258
245
  (0, type_2.assertRequestOptions)(options);
259
246
  reference = (0, type_2.makeReferenceOrEns)(reference, swarm_cid_1.ReferenceType.MANIFEST);
260
- return bzz.downloadFileReadable(this.getKyOptionsForCall(options), reference, path);
247
+ return bzz.downloadFileReadable(this.getRequestOptionsForCall(options), reference, path);
261
248
  }
262
249
  /**
263
250
  * Upload collection of files to a Bee node
@@ -275,12 +262,12 @@ class Bee {
275
262
  * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/access-the-swarm/upload-a-directory/)
276
263
  * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz/post)
277
264
  */
278
- async uploadFiles(postageBatchId, fileList, options) {
265
+ async uploadFiles(postageBatchId, fileList, options, requestOptions) {
279
266
  (0, type_2.assertBatchId)(postageBatchId);
280
267
  if (options)
281
268
  (0, type_2.assertCollectionUploadOptions)(options);
282
269
  const data = await (0, collection_1.makeCollectionFromFileList)(fileList);
283
- return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.getKyOptionsForCall(options), data, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
270
+ return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
284
271
  }
285
272
  /**
286
273
  * Upload Collection that you can assembly yourself.
@@ -297,7 +284,7 @@ class Bee {
297
284
  (0, collection_1.assertCollection)(collection);
298
285
  if (options)
299
286
  (0, type_2.assertCollectionUploadOptions)(options);
300
- return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.kyOptions, collection, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
287
+ return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.requestOptions, collection, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
301
288
  }
302
289
  /**
303
290
  * Upload collection of files.
@@ -315,12 +302,12 @@ class Bee {
315
302
  * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/access-the-swarm/upload-a-directory/)
316
303
  * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz/post)
317
304
  */
318
- async uploadFilesFromDirectory(postageBatchId, dir, options) {
305
+ async uploadFilesFromDirectory(postageBatchId, dir, options, requestOptions) {
319
306
  (0, type_2.assertBatchId)(postageBatchId);
320
307
  if (options)
321
308
  (0, type_2.assertCollectionUploadOptions)(options);
322
309
  const data = await (0, collection_node_1.makeCollectionFromFS)(dir);
323
- return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.getKyOptionsForCall(options), data, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
310
+ return (0, type_2.addCidConversionFunction)(await bzz.uploadCollection(this.getRequestOptionsForCall(requestOptions), data, postageBatchId, options), swarm_cid_1.ReferenceType.MANIFEST);
324
311
  }
325
312
  /**
326
313
  * Create a new Tag which is meant for tracking progres of syncing data across network.
@@ -331,7 +318,7 @@ class Bee {
331
318
  */
332
319
  async createTag(options) {
333
320
  (0, type_2.assertRequestOptions)(options);
334
- return tag.createTag(this.getKyOptionsForCall(options));
321
+ return tag.createTag(this.getRequestOptionsForCall(options));
335
322
  }
336
323
  /**
337
324
  * Fetches all tags.
@@ -348,7 +335,7 @@ class Bee {
348
335
  async getAllTags(options) {
349
336
  (0, type_2.assertRequestOptions)(options);
350
337
  (0, type_2.assertAllTagsOptions)(options);
351
- return tag.getAllTags(this.getKyOptionsForCall(options), options?.offset, options?.limit);
338
+ return tag.getAllTags(this.getRequestOptionsForCall(options), options?.offset, options?.limit);
352
339
  }
353
340
  /**
354
341
  * Retrieve tag information from Bee node
@@ -364,7 +351,7 @@ class Bee {
364
351
  async retrieveTag(tagUid, options) {
365
352
  (0, type_2.assertRequestOptions)(options);
366
353
  tagUid = (0, type_2.makeTagUid)(tagUid);
367
- return tag.retrieveTag(this.getKyOptionsForCall(options), tagUid);
354
+ return tag.retrieveTag(this.getRequestOptionsForCall(options), tagUid);
368
355
  }
369
356
  /**
370
357
  * Delete Tag
@@ -380,7 +367,7 @@ class Bee {
380
367
  async deleteTag(tagUid, options) {
381
368
  (0, type_2.assertRequestOptions)(options);
382
369
  tagUid = (0, type_2.makeTagUid)(tagUid);
383
- return tag.deleteTag(this.getKyOptionsForCall(options), tagUid);
370
+ return tag.deleteTag(this.getRequestOptionsForCall(options), tagUid);
384
371
  }
385
372
  /**
386
373
  * Update tag's total chunks count.
@@ -401,7 +388,7 @@ class Bee {
401
388
  (0, type_2.assertReference)(reference);
402
389
  (0, type_2.assertRequestOptions)(options);
403
390
  tagUid = (0, type_2.makeTagUid)(tagUid);
404
- return tag.updateTag(this.getKyOptionsForCall(options), tagUid, reference);
391
+ return tag.updateTag(this.getRequestOptionsForCall(options), tagUid, reference);
405
392
  }
406
393
  /**
407
394
  * Pin local data with given reference
@@ -415,7 +402,7 @@ class Bee {
415
402
  async pin(reference, options) {
416
403
  (0, type_2.assertRequestOptions)(options);
417
404
  (0, type_2.assertReference)(reference);
418
- return pinning.pin(this.getKyOptionsForCall(options), reference);
405
+ return pinning.pin(this.getRequestOptionsForCall(options), reference);
419
406
  }
420
407
  /**
421
408
  * Unpin local data with given reference
@@ -429,7 +416,7 @@ class Bee {
429
416
  async unpin(reference, options) {
430
417
  (0, type_2.assertRequestOptions)(options);
431
418
  (0, type_2.assertReference)(reference);
432
- return pinning.unpin(this.getKyOptionsForCall(options), reference);
419
+ return pinning.unpin(this.getRequestOptionsForCall(options), reference);
433
420
  }
434
421
  /**
435
422
  * Get list of all locally pinned references
@@ -439,7 +426,7 @@ class Bee {
439
426
  */
440
427
  async getAllPins(options) {
441
428
  (0, type_2.assertRequestOptions)(options);
442
- return pinning.getAllPins(this.getKyOptionsForCall(options));
429
+ return pinning.getAllPins(this.getRequestOptionsForCall(options));
443
430
  }
444
431
  /**
445
432
  * Get pinning status of chunk with given reference
@@ -454,7 +441,7 @@ class Bee {
454
441
  async getPin(reference, options) {
455
442
  (0, type_2.assertRequestOptions)(options);
456
443
  (0, type_2.assertReference)(reference);
457
- return pinning.getPin(this.getKyOptionsForCall(options), reference);
444
+ return pinning.getPin(this.getRequestOptionsForCall(options), reference);
458
445
  }
459
446
  /**
460
447
  * Instructs the Bee node to reupload a locally pinned data into the network.
@@ -470,7 +457,7 @@ class Bee {
470
457
  async reuploadPinnedData(reference, options) {
471
458
  (0, type_2.assertRequestOptions)(options);
472
459
  (0, type_2.assertReferenceOrEns)(reference);
473
- await stewardship.reupload(this.getKyOptionsForCall(options), reference);
460
+ await stewardship.reupload(this.getRequestOptionsForCall(options), reference);
474
461
  }
475
462
  /**
476
463
  * Checks if content specified by reference is retrievable from the network.
@@ -485,7 +472,7 @@ class Bee {
485
472
  async isReferenceRetrievable(reference, options) {
486
473
  (0, type_2.assertRequestOptions)(options);
487
474
  (0, type_2.assertReferenceOrEns)(reference);
488
- return stewardship.isRetrievable(this.getKyOptionsForCall(options), reference);
475
+ return stewardship.isRetrievable(this.getRequestOptionsForCall(options), reference);
489
476
  }
490
477
  /**
491
478
  * Functions that validates if feed is retrievable in the network.
@@ -511,9 +498,7 @@ class Bee {
511
498
  return true;
512
499
  }
513
500
  catch (e) {
514
- const err = e;
515
- // Only if the error is "not-found" then we return false otherwise we re-throw the error
516
- if (err?.status === 404) {
501
+ if (e?.response?.status === 404) {
517
502
  return false;
518
503
  }
519
504
  throw e;
@@ -522,7 +507,7 @@ class Bee {
522
507
  if (type !== 'sequence') {
523
508
  throw new error_1.BeeError('Only Sequence type of Feeds is supported at the moment');
524
509
  }
525
- return (0, retrievable_1.areAllSequentialFeedsUpdateRetrievable)(this, canonicalOwner, canonicalTopic, index, options);
510
+ return (0, retrievable_1.areAllSequentialFeedsUpdateRetrievable)(this, canonicalOwner, canonicalTopic, index, this.getRequestOptionsForCall(options));
526
511
  }
527
512
  /**
528
513
  * Send data to recipient or target with Postal Service for Swarm.
@@ -556,10 +541,10 @@ class Bee {
556
541
  }
557
542
  if (recipient) {
558
543
  (0, type_2.assertPublicKey)(recipient);
559
- return pss.send(this.getKyOptionsForCall(options), topic, target, data, postageBatchId, recipient);
544
+ return pss.send(this.getRequestOptionsForCall(options), topic, target, data, postageBatchId, recipient);
560
545
  }
561
546
  else {
562
- return pss.send(this.getKyOptionsForCall(options), topic, target, data, postageBatchId);
547
+ return pss.send(this.getRequestOptionsForCall(options), topic, target, data, postageBatchId);
563
548
  }
564
549
  }
565
550
  /**
@@ -689,7 +674,7 @@ class Bee {
689
674
  (0, type_2.assertBatchId)(postageBatchId);
690
675
  const canonicalTopic = (0, topic_1.makeTopic)(topic);
691
676
  const canonicalOwner = (0, eth_1.makeHexEthAddress)(owner);
692
- const reference = await (0, feed_2.createFeedManifest)(this.getKyOptionsForCall(options), canonicalOwner, canonicalTopic, postageBatchId, {
677
+ const reference = await (0, feed_2.createFeedManifest)(this.getRequestOptionsForCall(options), canonicalOwner, canonicalTopic, postageBatchId, {
693
678
  type,
694
679
  });
695
680
  return (0, type_2.addCidConversionFunction)({ reference }, swarm_cid_1.ReferenceType.FEED);
@@ -709,7 +694,7 @@ class Bee {
709
694
  (0, type_1.assertFeedType)(type);
710
695
  const canonicalTopic = (0, topic_1.makeTopic)(topic);
711
696
  const canonicalOwner = (0, eth_1.makeHexEthAddress)(owner);
712
- return (0, feed_1.makeFeedReader)(this.getKyOptionsForCall(options), type, canonicalTopic, canonicalOwner);
697
+ return (0, feed_1.makeFeedReader)(this.getRequestOptionsForCall(options), type, canonicalTopic, canonicalOwner);
713
698
  }
714
699
  /**
715
700
  * Make a new feed writer for updating feeds
@@ -726,7 +711,7 @@ class Bee {
726
711
  (0, type_1.assertFeedType)(type);
727
712
  const canonicalTopic = (0, topic_1.makeTopic)(topic);
728
713
  const canonicalSigner = this.resolveSigner(signer);
729
- return (0, feed_1.makeFeedWriter)(this.getKyOptionsForCall(options), type, canonicalTopic, canonicalSigner);
714
+ return (0, feed_1.makeFeedWriter)(this.getRequestOptionsForCall(options), type, canonicalTopic, canonicalSigner);
730
715
  }
731
716
  /**
732
717
  * High-level function that allows you to easily set JSON data to feed.
@@ -746,13 +731,13 @@ class Bee {
746
731
  *
747
732
  * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
748
733
  */
749
- async setJsonFeed(postageBatchId, topic, data, options) {
734
+ async setJsonFeed(postageBatchId, topic, data, options, requestOptions) {
750
735
  (0, type_2.assertRequestOptions)(options, 'JsonFeedOptions');
751
736
  (0, type_2.assertBatchId)(postageBatchId);
752
737
  const hashedTopic = this.makeFeedTopic(topic);
753
738
  const feedType = options?.type ?? type_1.DEFAULT_FEED_TYPE;
754
- const writer = this.makeFeedWriter(feedType, hashedTopic, options?.signer, options);
755
- return (0, json_1.setJsonData)(this, writer, postageBatchId, data, options);
739
+ const writer = this.makeFeedWriter(feedType, hashedTopic, options?.signer, requestOptions);
740
+ return (0, json_1.setJsonData)(this, writer, postageBatchId, data, options, requestOptions);
756
741
  }
757
742
  /**
758
743
  * High-level function that allows you to easily get data from feed.
@@ -823,7 +808,7 @@ class Bee {
823
808
  const canonicalOwner = (0, eth_1.makeEthAddress)(ownerAddress);
824
809
  return {
825
810
  owner: (0, eth_1.makeHexEthAddress)(canonicalOwner),
826
- download: soc_1.downloadSingleOwnerChunk.bind(null, this.getKyOptionsForCall(options), canonicalOwner),
811
+ download: soc_1.downloadSingleOwnerChunk.bind(null, this.getRequestOptionsForCall(options), canonicalOwner),
827
812
  };
828
813
  }
829
814
  /**
@@ -838,7 +823,7 @@ class Bee {
838
823
  const canonicalSigner = this.resolveSigner(signer);
839
824
  return {
840
825
  ...this.makeSOCReader(canonicalSigner.address, options),
841
- upload: soc_1.uploadSingleOwnerChunkData.bind(null, this.getKyOptionsForCall(options), canonicalSigner),
826
+ upload: soc_1.uploadSingleOwnerChunkData.bind(null, this.getRequestOptionsForCall(options), canonicalSigner),
842
827
  };
843
828
  }
844
829
  /**
@@ -849,7 +834,7 @@ class Bee {
849
834
  */
850
835
  async checkConnection(options) {
851
836
  (0, type_2.assertRequestOptions)(options, 'PostageBatchOptions');
852
- return status.checkConnection(this.getKyOptionsForCall(options));
837
+ return status.checkConnection(this.getRequestOptionsForCall(options));
853
838
  }
854
839
  /**
855
840
  * Ping the Bee node to see if there is a live Bee node on the given URL.
@@ -860,7 +845,7 @@ class Bee {
860
845
  async isConnected(options) {
861
846
  (0, type_2.assertRequestOptions)(options, 'PostageBatchOptions');
862
847
  try {
863
- await status.checkConnection(this.getKyOptionsForCall(options));
848
+ await status.checkConnection(this.getRequestOptionsForCall(options));
864
849
  }
865
850
  catch (e) {
866
851
  return false;
@@ -881,8 +866,8 @@ class Bee {
881
866
  }
882
867
  throw new error_1.BeeError('You have to pass Signer as property to either the method call or constructor! Non found.');
883
868
  }
884
- getKyOptionsForCall(options) {
885
- return (0, merge_1.deepMerge)(this.kyOptions, options);
869
+ getRequestOptionsForCall(options) {
870
+ return options ? cafe_utility_1.Objects.deepMerge2(this.requestOptions, options) : this.requestOptions;
886
871
  }
887
872
  }
888
873
  exports.Bee = Bee;
@@ -24,18 +24,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.downloadSingleOwnerChunk = exports.uploadSingleOwnerChunkData = exports.uploadSingleOwnerChunk = exports.makeSingleOwnerChunk = exports.makeSOCAddress = exports.makeSingleOwnerChunkFromData = void 0;
27
+ const chunkAPI = __importStar(require("../modules/chunk"));
28
+ const socAPI = __importStar(require("../modules/soc"));
27
29
  const bytes_1 = require("../utils/bytes");
28
- const bmt_1 = require("./bmt");
29
- const signer_1 = require("./signer");
30
- const hash_1 = require("../utils/hash");
31
- const span_1 = require("./span");
32
- const serialize_1 = require("./serialize");
33
30
  const error_1 = require("../utils/error");
34
- const cac_1 = require("./cac");
31
+ const hash_1 = require("../utils/hash");
35
32
  const hex_1 = require("../utils/hex");
36
- const socAPI = __importStar(require("../modules/soc"));
37
- const chunkAPI = __importStar(require("../modules/chunk"));
38
33
  const type_1 = require("../utils/type");
34
+ const bmt_1 = require("./bmt");
35
+ const cac_1 = require("./cac");
36
+ const serialize_1 = require("./serialize");
37
+ const signer_1 = require("./signer");
38
+ const span_1 = require("./span");
39
39
  const IDENTIFIER_SIZE = 32;
40
40
  const SIGNATURE_SIZE = 65;
41
41
  const SOC_IDENTIFIER_OFFSET = 0;
@@ -119,12 +119,12 @@ exports.makeSingleOwnerChunk = makeSingleOwnerChunk;
119
119
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
120
120
  * @param options Upload options
121
121
  */
122
- async function uploadSingleOwnerChunk(kyOptions, chunk, postageBatchId, options) {
122
+ async function uploadSingleOwnerChunk(requestOptions, chunk, postageBatchId, options) {
123
123
  const owner = (0, hex_1.bytesToHex)(chunk.owner());
124
124
  const identifier = (0, hex_1.bytesToHex)(chunk.identifier());
125
125
  const signature = (0, hex_1.bytesToHex)(chunk.signature());
126
126
  const data = (0, serialize_1.serializeBytes)(chunk.span(), chunk.payload());
127
- return socAPI.upload(kyOptions, owner, identifier, signature, data, postageBatchId, options);
127
+ return socAPI.upload(requestOptions, owner, identifier, signature, data, postageBatchId, options);
128
128
  }
129
129
  exports.uploadSingleOwnerChunk = uploadSingleOwnerChunk;
130
130
  /**
@@ -137,11 +137,11 @@ exports.uploadSingleOwnerChunk = uploadSingleOwnerChunk;
137
137
  * @param data The chunk data
138
138
  * @param options
139
139
  */
140
- async function uploadSingleOwnerChunkData(kyOptions, signer, postageBatchId, identifier, data, options) {
140
+ async function uploadSingleOwnerChunkData(requestOptions, signer, postageBatchId, identifier, data, options) {
141
141
  (0, type_1.assertAddress)(postageBatchId);
142
142
  const cac = (0, cac_1.makeContentAddressedChunk)(data);
143
143
  const soc = await makeSingleOwnerChunk(cac, identifier, signer);
144
- return uploadSingleOwnerChunk(kyOptions, soc, postageBatchId, options);
144
+ return uploadSingleOwnerChunk(requestOptions, soc, postageBatchId, options);
145
145
  }
146
146
  exports.uploadSingleOwnerChunkData = uploadSingleOwnerChunkData;
147
147
  /**
@@ -151,9 +151,9 @@ exports.uploadSingleOwnerChunkData = uploadSingleOwnerChunkData;
151
151
  * @param ownerAddress The singer interface for signing the chunk
152
152
  * @param identifier The identifier of the chunk
153
153
  */
154
- async function downloadSingleOwnerChunk(kyOptions, ownerAddress, identifier) {
154
+ async function downloadSingleOwnerChunk(requestOptions, ownerAddress, identifier) {
155
155
  const address = makeSOCAddress(identifier, ownerAddress);
156
- const data = await chunkAPI.download(kyOptions, (0, hex_1.bytesToHex)(address));
156
+ const data = await chunkAPI.download(requestOptions, (0, hex_1.bytesToHex)(address));
157
157
  return makeSingleOwnerChunkFromData(data, address);
158
158
  }
159
159
  exports.downloadSingleOwnerChunk = downloadSingleOwnerChunk;
@@ -24,44 +24,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.makeFeedWriter = exports.makeFeedReader = exports.downloadFeedUpdate = exports.getFeedUpdateChunkReference = exports.updateFeed = exports.findNextIndex = void 0;
27
- const hash_1 = require("../utils/hash");
28
27
  const serialize_1 = require("../chunk/serialize");
29
- const feed_1 = require("../modules/feed");
30
28
  const soc_1 = require("../chunk/soc");
29
+ const chunkAPI = __importStar(require("../modules/chunk"));
30
+ const feed_1 = require("../modules/feed");
31
31
  const types_1 = require("../types");
32
32
  const bytes_1 = require("../utils/bytes");
33
- const error_1 = require("../utils/error");
34
- const hex_1 = require("../utils/hex");
35
- const uint64_1 = require("../utils/uint64");
36
- const chunkAPI = __importStar(require("../modules/chunk"));
37
33
  const eth_1 = require("../utils/eth");
34
+ const hash_1 = require("../utils/hash");
35
+ const hex_1 = require("../utils/hex");
36
+ const reference_1 = require("../utils/reference");
38
37
  const type_1 = require("../utils/type");
38
+ const uint64_1 = require("../utils/uint64");
39
39
  const identifier_1 = require("./identifier");
40
- const reference_1 = require("../utils/reference");
41
40
  const TIMESTAMP_PAYLOAD_OFFSET = 0;
42
41
  const TIMESTAMP_PAYLOAD_SIZE = 8;
43
42
  const REFERENCE_PAYLOAD_OFFSET = TIMESTAMP_PAYLOAD_SIZE;
44
- async function findNextIndex(kyOptions, owner, topic, options) {
43
+ async function findNextIndex(requestOptions, owner, topic, options) {
45
44
  try {
46
- const feedUpdate = await (0, feed_1.fetchLatestFeedUpdate)(kyOptions, owner, topic, options);
45
+ const feedUpdate = await (0, feed_1.fetchLatestFeedUpdate)(requestOptions, owner, topic, options);
47
46
  return (0, hex_1.makeHexString)(feedUpdate.feedIndexNext, types_1.FEED_INDEX_HEX_LENGTH);
48
47
  }
49
48
  catch (e) {
50
- if (e instanceof error_1.BeeResponseError && e.status === 404) {
49
+ if (e?.response?.status === 404) {
51
50
  return (0, hex_1.bytesToHex)((0, bytes_1.makeBytes)(8));
52
51
  }
53
52
  throw e;
54
53
  }
55
54
  }
56
55
  exports.findNextIndex = findNextIndex;
57
- async function updateFeed(kyOptions, signer, topic, reference, postageBatchId, options, index = 'latest') {
56
+ async function updateFeed(requestOptions, signer, topic, reference, postageBatchId, options, index = 'latest') {
58
57
  const ownerHex = (0, eth_1.makeHexEthAddress)(signer.address);
59
- const nextIndex = index === 'latest' ? await findNextIndex(kyOptions, ownerHex, topic, options) : index;
58
+ const nextIndex = index === 'latest' ? await findNextIndex(requestOptions, ownerHex, topic, options) : index;
60
59
  const identifier = (0, identifier_1.makeFeedIdentifier)(topic, nextIndex);
61
60
  const at = options?.at ?? Date.now() / 1000.0;
62
61
  const timestamp = (0, uint64_1.writeUint64BigEndian)(at);
63
62
  const payloadBytes = (0, serialize_1.serializeBytes)(timestamp, reference);
64
- return (0, soc_1.uploadSingleOwnerChunkData)(kyOptions, signer, postageBatchId, identifier, payloadBytes, options);
63
+ return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
65
64
  }
66
65
  exports.updateFeed = updateFeed;
67
66
  function getFeedUpdateChunkReference(owner, topic, index) {
@@ -69,10 +68,10 @@ function getFeedUpdateChunkReference(owner, topic, index) {
69
68
  return (0, hash_1.keccak256Hash)(identifier, owner);
70
69
  }
71
70
  exports.getFeedUpdateChunkReference = getFeedUpdateChunkReference;
72
- async function downloadFeedUpdate(kyOptions, owner, topic, index) {
71
+ async function downloadFeedUpdate(requestOptions, owner, topic, index) {
73
72
  const address = getFeedUpdateChunkReference(owner, topic, index);
74
73
  const addressHex = (0, hex_1.bytesToHex)(address);
75
- const data = await chunkAPI.download(kyOptions, addressHex);
74
+ const data = await chunkAPI.download(requestOptions, addressHex);
76
75
  const soc = (0, soc_1.makeSingleOwnerChunkFromData)(data, address);
77
76
  const payload = soc.payload();
78
77
  const timestampBytes = (0, bytes_1.bytesAtOffset)(payload, TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
@@ -84,16 +83,16 @@ async function downloadFeedUpdate(kyOptions, owner, topic, index) {
84
83
  };
85
84
  }
86
85
  exports.downloadFeedUpdate = downloadFeedUpdate;
87
- function makeFeedReader(kyOptions, type, topic, owner) {
86
+ function makeFeedReader(requestOptions, type, topic, owner) {
88
87
  return {
89
88
  type,
90
89
  owner,
91
90
  topic,
92
91
  async download(options) {
93
92
  if (!options?.index) {
94
- return (0, feed_1.fetchLatestFeedUpdate)(kyOptions, owner, topic, { ...options, type });
93
+ return (0, feed_1.fetchLatestFeedUpdate)(requestOptions, owner, topic, { ...options, type });
95
94
  }
96
- const update = await downloadFeedUpdate(kyOptions, (0, hex_1.hexToBytes)(owner), topic, options.index);
95
+ const update = await downloadFeedUpdate(requestOptions, (0, hex_1.hexToBytes)(owner), topic, options.index);
97
96
  return {
98
97
  reference: (0, hex_1.bytesToHex)(update.reference),
99
98
  feedIndex: options.index,
@@ -103,14 +102,14 @@ function makeFeedReader(kyOptions, type, topic, owner) {
103
102
  };
104
103
  }
105
104
  exports.makeFeedReader = makeFeedReader;
106
- function makeFeedWriter(kyOptions, type, topic, signer) {
105
+ function makeFeedWriter(requestOptions, type, topic, signer) {
107
106
  const upload = async (postageBatchId, reference, options) => {
108
107
  (0, type_1.assertAddress)(postageBatchId);
109
108
  const canonicalReference = (0, reference_1.makeBytesReference)(reference);
110
- return updateFeed(kyOptions, signer, topic, canonicalReference, postageBatchId, { ...options, type });
109
+ return updateFeed(requestOptions, signer, topic, canonicalReference, postageBatchId, { ...options, type });
111
110
  };
112
111
  return {
113
- ...makeFeedReader(kyOptions, type, topic, (0, eth_1.makeHexEthAddress)(signer.address)),
112
+ ...makeFeedReader(requestOptions, type, topic, (0, eth_1.makeHexEthAddress)(signer.address)),
114
113
  upload,
115
114
  };
116
115
  }
@@ -20,9 +20,9 @@ async function getJsonData(bee, reader) {
20
20
  return retrievedData.json();
21
21
  }
22
22
  exports.getJsonData = getJsonData;
23
- async function setJsonData(bee, writer, postageBatchId, data, options) {
23
+ async function setJsonData(bee, writer, postageBatchId, data, options, requestOptions) {
24
24
  const serializedData = serializeJson(data);
25
- const { reference } = await bee.uploadData(postageBatchId, serializedData, options);
25
+ const { reference } = await bee.uploadData(postageBatchId, serializedData, options, requestOptions);
26
26
  return writer.upload(postageBatchId, reference);
27
27
  }
28
28
  exports.setJsonData = setJsonData;