@ethersphere/bee-js 7.1.0 → 7.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mjs/bee.js CHANGED
@@ -71,7 +71,7 @@ export class Bee {
71
71
  * @param options Additional options like tag, encryption, pinning, content-type and request options
72
72
  *
73
73
  * @returns reference is a content hash of the data
74
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
74
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
75
75
  * @see [Bee API reference - `POST /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post)
76
76
  */
77
77
  async uploadData(postageBatchId, data, options, requestOptions) {
@@ -87,7 +87,7 @@ export class Bee {
87
87
  * @param options Options that affects the request behavior
88
88
  * @throws TypeError if some of the input parameters is not expected type
89
89
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
90
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
90
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
91
91
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
92
92
  */
93
93
  async downloadData(reference, options) {
@@ -102,7 +102,7 @@ export class Bee {
102
102
  * @param options Options that affects the request behavior
103
103
  * @throws TypeError if some of the input parameters is not expected type
104
104
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
105
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
105
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
106
106
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
107
107
  */
108
108
  async downloadReadableData(reference, options) {
@@ -118,7 +118,7 @@ export class Bee {
118
118
  * @param options Additional options like tag, encryption, pinning, content-type and request options
119
119
  *
120
120
  * @returns reference is a content hash of the data
121
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
121
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
122
122
  * @see [Bee API reference - `POST /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post)
123
123
  */
124
124
  async uploadChunk(postageBatchId, data, options, requestOptions) {
@@ -142,8 +142,8 @@ export class Bee {
142
142
  * @param options Options that affects the request behavior
143
143
  * @throws TypeError if some of the input parameters is not expected type
144
144
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
145
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
146
- * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{reference}/get)
145
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
146
+ * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{address}/get)
147
147
  */
148
148
  async downloadChunk(reference, options) {
149
149
  assertRequestOptions(options);
@@ -161,9 +161,9 @@ export class Bee {
161
161
  * @param name Optional name of the uploaded file
162
162
  * @param options Additional options like tag, encryption, pinning, content-type and request options
163
163
  *
164
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
165
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
166
- * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/File/paths/~1bzz/post)
164
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
165
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
166
+ * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
167
167
  * @returns reference is a content hash of the file
168
168
  */
169
169
  async uploadFile(postageBatchId, data, name, options, requestOptions) {
@@ -200,8 +200,8 @@ export class Bee {
200
200
  * @throws TypeError if some of the input parameters is not expected type
201
201
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
202
202
  * @see Data
203
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
204
- * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz~1{reference}~1{path}/get)
203
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
204
+ * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
205
205
  */
206
206
  async downloadFile(reference, path = '', options) {
207
207
  assertRequestOptions(options);
@@ -217,8 +217,8 @@ export class Bee {
217
217
  * @throws TypeError if some of the input parameters is not expected type
218
218
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
219
219
  *
220
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
221
- * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz~1{reference}~1{path}/get)
220
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
221
+ * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
222
222
  */
223
223
  async downloadReadableFile(reference, path = '', options) {
224
224
  assertRequestOptions(options);
@@ -237,9 +237,9 @@ export class Bee {
237
237
  * @param fileList list of files to be uploaded
238
238
  * @param options Additional options like tag, encryption, pinning and request options
239
239
  *
240
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
241
- * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/access-the-swarm/upload-a-directory/)
242
- * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz/post)
240
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
241
+ * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
242
+ * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
243
243
  */
244
244
  async uploadFiles(postageBatchId, fileList, options, requestOptions) {
245
245
  assertBatchId(postageBatchId);
@@ -275,9 +275,9 @@ export class Bee {
275
275
  * @param dir the path of the files to be uploaded
276
276
  * @param options Additional options like tag, encryption, pinning and request options
277
277
  *
278
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
279
- * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/access-the-swarm/upload-a-directory/)
280
- * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz/post)
278
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
279
+ * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
280
+ * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
281
281
  */
282
282
  async uploadFilesFromDirectory(postageBatchId, dir, options, requestOptions) {
283
283
  assertBatchId(postageBatchId);
@@ -289,7 +289,7 @@ export class Bee {
289
289
  * Create a new Tag which is meant for tracking progres of syncing data across network.
290
290
  *
291
291
  * @param options Options that affects the request behavior
292
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
292
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
293
293
  * @see [Bee API reference - `POST /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post)
294
294
  */
295
295
  async createTag(options) {
@@ -305,7 +305,7 @@ export class Bee {
305
305
  * @throws TypeError if limit or offset are not numbers or undefined
306
306
  * @throws BeeArgumentError if limit or offset have invalid options
307
307
  *
308
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
308
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
309
309
  * @see [Bee API reference - `GET /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/get)
310
310
  */
311
311
  async getAllTags(options) {
@@ -320,7 +320,7 @@ export class Bee {
320
320
  * @param options Options that affects the request behavior
321
321
  * @throws TypeError if tagUid is in not correct format
322
322
  *
323
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
323
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
324
324
  * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/get)
325
325
  *
326
326
  */
@@ -337,7 +337,7 @@ export class Bee {
337
337
  * @throws TypeError if tagUid is in not correct format
338
338
  * @throws BeeResponse error if something went wrong on the Bee node side while deleting the tag.
339
339
  *
340
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
340
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
341
341
  * @see [Bee API reference - `DELETE /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/delete)
342
342
  */
343
343
  async deleteTag(tagUid, options) {
@@ -357,7 +357,7 @@ export class Bee {
357
357
  * @throws TypeError if tagUid is in not correct format
358
358
  * @throws BeeResponse error if something went wrong on the Bee node side while deleting the tag.
359
359
  *
360
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
360
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
361
361
  * @see [Bee API reference - `PATCH /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/patch)
362
362
  */
363
363
  async updateTag(tagUid, reference, options) {
@@ -373,7 +373,7 @@ export class Bee {
373
373
  * @param options Options that affects the request behavior
374
374
  * @throws TypeError if reference is in not correct format
375
375
  *
376
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
376
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
377
377
  */
378
378
  async pin(reference, options) {
379
379
  assertRequestOptions(options);
@@ -387,7 +387,7 @@ export class Bee {
387
387
  * @param options Options that affects the request behavior
388
388
  * @throws TypeError if reference is in not correct format
389
389
  *
390
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
390
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
391
391
  */
392
392
  async unpin(reference, options) {
393
393
  assertRequestOptions(options);
@@ -398,7 +398,7 @@ export class Bee {
398
398
  * Get list of all locally pinned references
399
399
  *
400
400
  * @param options Options that affects the request behavior
401
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
401
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
402
402
  */
403
403
  async getAllPins(options) {
404
404
  assertRequestOptions(options);
@@ -412,7 +412,7 @@ export class Bee {
412
412
  * @throws TypeError if some of the input parameters is not expected type
413
413
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
414
414
  *
415
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
415
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
416
416
  */
417
417
  async getPin(reference, options) {
418
418
  assertRequestOptions(options);
@@ -503,7 +503,7 @@ export class Bee {
503
503
  * @param options Options that affects the request behavior
504
504
  * @throws TypeError if `data`, `batchId`, `target` or `recipient` are in invalid format
505
505
  *
506
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
506
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
507
507
  * @see [Bee API reference - `POST /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1send~1{topic}~1{targets}/post)
508
508
  */
509
509
  async pssSend(postageBatchId, topic, target, data, recipient, options) {
@@ -532,7 +532,7 @@ export class Bee {
532
532
  *
533
533
  * @returns Subscription to a given topic
534
534
  *
535
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
535
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
536
536
  * @see [Bee API reference - `GET /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1{topic}/get)
537
537
  */
538
538
  pssSubscribe(topic, handler) {
@@ -551,7 +551,6 @@ export class Bee {
551
551
  if (ws.terminate) ws.terminate();else ws.close(); // standard Websocket in browser does not have terminate function
552
552
  }
553
553
  };
554
-
555
554
  const subscription = {
556
555
  topic,
557
556
  cancel
@@ -592,7 +591,7 @@ export class Bee {
592
591
  *
593
592
  * @returns Message in byte array
594
593
  *
595
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
594
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
596
595
  * @see [Bee API reference - `GET /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1{topic}/get)
597
596
  */
598
597
  async pssReceive(topic, timeoutMsec = 0) {
@@ -637,7 +636,7 @@ export class Bee {
637
636
  * @param owner Owner's ethereum address in hex or bytes
638
637
  * @param options Options that affects the request behavior
639
638
  *
640
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
639
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
641
640
  * @see [Bee API reference - `POST /feeds`](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1{owner}~1{topic}/post)
642
641
  */
643
642
  async createFeedManifest(postageBatchId, type, topic, owner, options) {
@@ -659,7 +658,7 @@ export class Bee {
659
658
  * @param owner Owner's ethereum address in hex or bytes
660
659
  * @param options Options that affects the request behavior
661
660
  *
662
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
661
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
663
662
  */
664
663
  makeFeedReader(type, topic, owner, options) {
665
664
  assertRequestOptions(options);
@@ -676,7 +675,7 @@ export class Bee {
676
675
  * @param signer The signer's private key or a Signer instance that can sign data
677
676
  * @param options Options that affects the request behavior
678
677
  *
679
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
678
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
680
679
  */
681
680
  makeFeedWriter(type, topic, signer, options) {
682
681
  assertRequestOptions(options);
@@ -701,7 +700,7 @@ export class Bee {
701
700
  *
702
701
  * @throws BeeError if `options.signer` is not specified nor the default Signer on Bee's instance is specified.
703
702
  *
704
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
703
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
705
704
  */
706
705
  async setJsonFeed(postageBatchId, topic, data, options, requestOptions) {
707
706
  assertRequestOptions(options, 'JsonFeedOptions');
@@ -728,7 +727,7 @@ export class Bee {
728
727
  * @param options.address Ethereum address of owner of the feed that signed it. This option is exclusive with `signer` option.
729
728
  * @param options.type Type of Feed
730
729
  *
731
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
730
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
732
731
  */
733
732
  async getJsonFeed(topic, options) {
734
733
  assertRequestOptions(options, 'JsonFeedOptions');
@@ -770,7 +769,7 @@ export class Bee {
770
769
  *
771
770
  * @param ownerAddress The ethereum address of the owner
772
771
  * @param options Options that affects the request behavior
773
- * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/dapps-on-swarm/chunk-types#single-owner-chunks)
772
+ * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks)
774
773
  */
775
774
  makeSOCReader(ownerAddress, options) {
776
775
  assertRequestOptions(options);
@@ -785,7 +784,7 @@ export class Bee {
785
784
  *
786
785
  * @param signer The signer's private key or a Signer instance that can sign data
787
786
  * @param options Options that affects the request behavior
788
- * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/dapps-on-swarm/chunk-types#single-owner-chunks)
787
+ * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks)
789
788
  */
790
789
  makeSOCWriter(signer, options) {
791
790
  assertRequestOptions(options);
@@ -835,7 +834,7 @@ export class Bee {
835
834
  * @param tagUid UID or tag object to be retrieved
836
835
  * @throws TypeError if tagUid is in not correct format
837
836
  *
838
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
837
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
839
838
  * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/debug-api/#tag/Tag)
840
839
  *
841
840
  */
@@ -1131,7 +1130,7 @@ export class Bee {
1131
1130
  * Creates new postage batch from the funds that the node has available in its Ethereum account.
1132
1131
  *
1133
1132
  * For better understanding what each parameter means and what are the optimal values please see
1134
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
1133
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction#keep-your-data-alive).
1135
1134
  *
1136
1135
  * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1137
1136
  *
@@ -1141,7 +1140,7 @@ export class Bee {
1141
1140
  * @throws BeeArgumentError when negative amount or depth is specified
1142
1141
  * @throws TypeError if non-integer value is passed to amount or depth
1143
1142
  *
1144
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1143
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1145
1144
  * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
1146
1145
  */
1147
1146
  async createPostageBatch(amount, depth, options, requestOptions) {
@@ -1167,7 +1166,7 @@ export class Bee {
1167
1166
  * Topup a fresh amount of BZZ to given Postage Batch.
1168
1167
  *
1169
1168
  * For better understanding what each parameter means and what are the optimal values please see
1170
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
1169
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive).
1171
1170
  *
1172
1171
  * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1173
1172
  *
@@ -1175,7 +1174,7 @@ export class Bee {
1175
1174
  * @param amount Amount to be added to the batch
1176
1175
  * @param options Request options
1177
1176
  *
1178
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1177
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1179
1178
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{id}~1{amount}/patch)
1180
1179
  */
1181
1180
  async topUpBatch(postageBatchId, amount, options) {
@@ -1189,7 +1188,7 @@ export class Bee {
1189
1188
  * the Postage Batch to be used for more chunks.
1190
1189
  *
1191
1190
  * For better understanding what each parameter means and what are the optimal values please see
1192
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
1191
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive).
1193
1192
  *
1194
1193
  * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1195
1194
  *
@@ -1197,7 +1196,7 @@ export class Bee {
1197
1196
  * @param depth Amount to be added to the batch
1198
1197
  * @param options Request options
1199
1198
  *
1200
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1199
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1201
1200
  * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{id}~1{amount}/patch)
1202
1201
  */
1203
1202
  async diluteBatch(postageBatchId, depth, options) {
@@ -1211,7 +1210,7 @@ export class Bee {
1211
1210
  *
1212
1211
  * @param postageBatchId Batch ID
1213
1212
  *
1214
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1213
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1215
1214
  * @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
1216
1215
  */
1217
1216
  async getPostageBatch(postageBatchId, options) {
@@ -1224,7 +1223,7 @@ export class Bee {
1224
1223
  *
1225
1224
  * @param postageBatchId Batch ID
1226
1225
  *
1227
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1226
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1228
1227
  * @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}~1buckets/get)
1229
1228
  */
1230
1229
  async getPostageBatchBuckets(postageBatchId, options) {
@@ -1235,7 +1234,7 @@ export class Bee {
1235
1234
  /**
1236
1235
  * Return all postage batches that has the node available.
1237
1236
  *
1238
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1237
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1239
1238
  * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps/get)
1240
1239
  */
1241
1240
  async getAllPostageBatch(options) {
@@ -4,7 +4,7 @@ import { PSS_TARGET_HEX_LENGTH_MAX } from "../types/index.js";
4
4
  * target that Bee node will except.
5
5
  *
6
6
  * @param target is a non-prefixed hex string Bee address
7
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
7
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
8
8
  */
9
9
  export function makeMaxTarget(target) {
10
10
  if (typeof target !== 'string') {
@@ -2,7 +2,7 @@ import { fileArrayBuffer } from "./file.js";
2
2
  export async function writeTar(collection, tarStream) {
3
3
  for (const item of collection) {
4
4
  if (item.file) {
5
- await tarStream.beginFile(item.path, item.file.size);
5
+ tarStream.beginFile(item.path, item.file.size);
6
6
  await tarStream.appendFile(new Uint8Array(await fileArrayBuffer(item.file)));
7
7
  await tarStream.endFile();
8
8
  } else {
@@ -1,7 +1,7 @@
1
1
  import { createReadStream } from 'fs';
2
2
  export async function writeTar(collection, tarStream) {
3
3
  for (const item of collection) {
4
- await tarStream.beginFile(item.path, item.size);
4
+ tarStream.beginFile(item.path, item.size);
5
5
  if (item.fsPath) {
6
6
  const stream = createReadStream(item.fsPath);
7
7
  for await (const chunk of stream) {
@@ -11,7 +11,7 @@ export class TarStream {
11
11
  return newAcc;
12
12
  });
13
13
  }
14
- async beginFile(path, size) {
14
+ beginFile(path, size) {
15
15
  const header = createHeader(path, size);
16
16
  this.pieces.push(header);
17
17
  this.currentFileSize = 0;
@@ -21,38 +21,47 @@ export class TarStream {
21
21
  this.currentFileSize += data.length;
22
22
  }
23
23
  async endFile() {
24
- const padding = 512 - this.currentFileSize % 512;
25
- this.pieces.push(new Uint8Array(padding));
24
+ const padding = this.currentFileSize % 512 === 0 ? 0 : 512 - this.currentFileSize % 512;
25
+ if (padding > 0) {
26
+ this.pieces.push(new Uint8Array(padding));
27
+ }
26
28
  }
27
29
  async end() {
28
30
  this.pieces.push(createEndOfArchive());
29
31
  }
30
32
  }
31
33
  function createHeader(path, size) {
32
- const header = new Uint8Array(512); // Initialize header with zeros
33
34
  const encoder = new TextEncoder();
34
35
  function writeToBuffer(str, offset, length) {
35
36
  const bytes = encoder.encode(str);
36
37
  header.set(bytes.slice(0, length), offset);
37
38
  }
38
- writeToBuffer(path, 0, 100); // File name
39
- writeToBuffer('0000777', 100, 8); // File mode
40
- writeToBuffer('0001750', 108, 8); // UID
41
- writeToBuffer('0001750', 116, 8); // GID
42
- writeToBuffer(size.toString(8).padStart(11, '0') + ' ', 124, 12); // File size
43
- writeToBuffer(Math.floor(Date.now() / 1000).toString(8) + ' ', 136, 12); // Mod time
44
- writeToBuffer(' ', 148, 8); // Checksum placeholder
45
- writeToBuffer('0', 156, 1); // Typeflag
46
- writeToBuffer('ustar ', 257, 8); // Magic and version
47
- for (let i = 345; i < 512; i++) {
48
- header[i] = 0; // Fill remaining with zeros
49
- }
39
+ // Initialize header with zeros
40
+ const header = new Uint8Array();
41
+ header.fill(0, 0, 512);
42
+ // File name, truncated to 100 characters if necessary
43
+ writeToBuffer(path.slice(0, 100).padEnd(100, '\0'), 0, 100);
44
+ // File mode (octal) and null-terminated
45
+ writeToBuffer('0000777\0', 100, 8);
46
+ // UID and GID (octal) and null-terminated
47
+ writeToBuffer('0001750\0', 108, 8); // UID
48
+ writeToBuffer('0001750\0', 116, 8); // GID
49
+ // File size in octal (11 chars) and null-terminated
50
+ writeToBuffer(size.toString(8).padStart(11, '0') + '\0', 124, 12);
51
+ // Modification time in octal and null-terminated
52
+ const modTime = Math.floor(new Date().getTime() / 1000);
53
+ writeToBuffer(modTime.toString(8).padStart(11, '0') + '\0', 136, 12);
54
+ // Checksum placeholder (8 spaces)
55
+ writeToBuffer(' ', 148, 8);
56
+ // Typeflag (normal file)
57
+ writeToBuffer('0', 156, 1);
58
+ // USTAR magic and version
59
+ writeToBuffer('ustar\0\0', 257, 8);
50
60
  // Calculate checksum
51
61
  let checksum = 0;
52
62
  for (let i = 0; i < 512; i++) {
53
63
  checksum += header[i];
54
64
  }
55
- // Write checksum
56
65
  writeToBuffer(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
57
66
  return header;
58
67
  }
@@ -4,42 +4,65 @@ export class TarStream {
4
4
  this.output = new PassThrough();
5
5
  this.currentFileSize = 0;
6
6
  }
7
- async beginFile(path, size) {
7
+ beginFile(path, size) {
8
8
  const header = createHeader(path, size);
9
9
  this.output.write(header);
10
10
  this.currentFileSize = 0;
11
11
  }
12
12
  async appendFile(data) {
13
13
  return new Promise(resolve => {
14
- this.output.write(data, () => {
14
+ if (!this.output.write(data)) {
15
+ this.output.once('drain', () => {
16
+ resolve();
17
+ });
18
+ } else {
15
19
  resolve();
16
- });
20
+ }
17
21
  this.currentFileSize += data.length;
18
22
  });
19
23
  }
20
24
  async endFile() {
21
- const padding = 512 - this.currentFileSize % 512;
22
- this.output.write(Buffer.alloc(padding, 0));
25
+ const padding = this.currentFileSize % 512 === 0 ? 0 : 512 - this.currentFileSize % 512;
26
+ if (padding > 0) {
27
+ this.output.write(Buffer.alloc(padding, 0));
28
+ }
23
29
  }
24
30
  async end() {
25
- this.output.write(createEndOfArchive());
26
- this.output.end();
31
+ return new Promise(resolve => {
32
+ this.output.write(createEndOfArchive());
33
+ this.output.end(() => {
34
+ resolve();
35
+ });
36
+ });
27
37
  }
28
38
  }
29
39
  function createHeader(path, size) {
30
- const header = Buffer.alloc(512, 0); // Initialize header with zeros
31
- header.write(path, 0, 100); // File name
32
- header.write('0000777', 100, 8); // File mode
33
- header.write('0001750', 108, 8); // UID
34
- header.write('0001750', 116, 8); // GID
35
- header.write(size.toString(8).padStart(11, '0') + ' ', 124, 12); // File size
36
- header.write(Math.floor(new Date().getTime() / 1000).toString(8) + ' ', 136, 12); // Mod time
37
- header.write(' ', 148, 8); // Checksum placeholder
38
- header.write('0', 156, 1); // Typeflag
39
- header.write('ustar ', 257, 8); // Magic and version
40
- header.write('0'.repeat(8 * 12), 345, 8 * 12); // Fill remaining with zeros
41
- const checksum = header.reduce((sum, elem) => sum + elem, 0);
42
- header.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8); // Write checksum
40
+ // Initialize header with zeros
41
+ const header = Buffer.alloc(512, 0);
42
+ // File name, truncated to 100 characters if necessary
43
+ header.write(path.slice(0, 100).padEnd(100, '\0'), 0, 100);
44
+ // File mode (octal) and null-terminated
45
+ header.write('0000777\0', 100, 8);
46
+ // UID and GID (octal) and null-terminated
47
+ header.write('0001750\0', 108, 8); // UID
48
+ header.write('0001750\0', 116, 8); // GID
49
+ // File size in octal (11 chars) and null-terminated
50
+ header.write(size.toString(8).padStart(11, '0') + '\0', 124, 12);
51
+ // Modification time in octal and null-terminated
52
+ const modTime = Math.floor(new Date().getTime() / 1000);
53
+ header.write(modTime.toString(8).padStart(11, '0') + '\0', 136, 12);
54
+ // Checksum placeholder (8 spaces)
55
+ header.write(' ', 148, 8);
56
+ // Typeflag (normal file)
57
+ header.write('0', 156, 1);
58
+ // USTAR magic and version
59
+ header.write('ustar\0\0', 257, 8);
60
+ // Calculate checksum
61
+ let checksum = 0;
62
+ for (let i = 0; i < 512; i++) {
63
+ checksum += header[i];
64
+ }
65
+ header.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
43
66
  return header;
44
67
  }
45
68
  function createEndOfArchive() {