@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/README.md CHANGED
@@ -15,6 +15,22 @@
15
15
 
16
16
  > Intended to be used with Bee version 2.1.0.
17
17
 
18
+ ## Quick start
19
+
20
+ Start a Swarm project using TypeScript:
21
+
22
+ ```sh
23
+ npm init swarm-app@latest my-dapp node-ts
24
+ ```
25
+
26
+ or using Vite and TypeScript:
27
+
28
+ ```sh
29
+ npm init swarm-app@latest my-dapp vite-tsx
30
+ ```
31
+
32
+ Supported types are `node`, `node-esm`, `node-ts` and `vite-tsx`. Replace `my-dapp` with your project name.
33
+
18
34
  ## Install
19
35
 
20
36
  ```sh
package/dist/cjs/bee.js CHANGED
@@ -97,7 +97,7 @@ class Bee {
97
97
  * @param options Additional options like tag, encryption, pinning, content-type and request options
98
98
  *
99
99
  * @returns reference is a content hash of the data
100
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
100
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
101
101
  * @see [Bee API reference - `POST /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post)
102
102
  */
103
103
  async uploadData(postageBatchId, data, options, requestOptions) {
@@ -114,7 +114,7 @@ class Bee {
114
114
  * @param options Options that affects the request behavior
115
115
  * @throws TypeError if some of the input parameters is not expected type
116
116
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
117
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
117
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
118
118
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
119
119
  */
120
120
  async downloadData(reference, options) {
@@ -129,7 +129,7 @@ class Bee {
129
129
  * @param options Options that affects the request behavior
130
130
  * @throws TypeError if some of the input parameters is not expected type
131
131
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
132
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
132
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
133
133
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
134
134
  */
135
135
  async downloadReadableData(reference, options) {
@@ -145,7 +145,7 @@ class Bee {
145
145
  * @param options Additional options like tag, encryption, pinning, content-type and request options
146
146
  *
147
147
  * @returns reference is a content hash of the data
148
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
148
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
149
149
  * @see [Bee API reference - `POST /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post)
150
150
  */
151
151
  async uploadChunk(postageBatchId, data, options, requestOptions) {
@@ -170,8 +170,8 @@ class Bee {
170
170
  * @param options Options that affects the request behavior
171
171
  * @throws TypeError if some of the input parameters is not expected type
172
172
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
173
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
174
- * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{reference}/get)
173
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
174
+ * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{address}/get)
175
175
  */
176
176
  async downloadChunk(reference, options) {
177
177
  (0, type_2.assertRequestOptions)(options);
@@ -189,9 +189,9 @@ class Bee {
189
189
  * @param name Optional name of the uploaded file
190
190
  * @param options Additional options like tag, encryption, pinning, content-type and request options
191
191
  *
192
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
193
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
194
- * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/File/paths/~1bzz/post)
192
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
193
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
194
+ * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
195
195
  * @returns reference is a content hash of the file
196
196
  */
197
197
  async uploadFile(postageBatchId, data, name, options, requestOptions) {
@@ -228,8 +228,8 @@ class Bee {
228
228
  * @throws TypeError if some of the input parameters is not expected type
229
229
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
230
230
  * @see Data
231
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
232
- * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz~1{reference}~1{path}/get)
231
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
232
+ * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
233
233
  */
234
234
  async downloadFile(reference, path = '', options) {
235
235
  (0, type_2.assertRequestOptions)(options);
@@ -245,8 +245,8 @@ class Bee {
245
245
  * @throws TypeError if some of the input parameters is not expected type
246
246
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
247
247
  *
248
- * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
249
- * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz~1{reference}~1{path}/get)
248
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download)
249
+ * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get)
250
250
  */
251
251
  async downloadReadableFile(reference, path = '', options) {
252
252
  (0, type_2.assertRequestOptions)(options);
@@ -265,9 +265,9 @@ class Bee {
265
265
  * @param fileList list of files to be uploaded
266
266
  * @param options Additional options like tag, encryption, pinning and request options
267
267
  *
268
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
269
- * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/access-the-swarm/upload-a-directory/)
270
- * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz/post)
268
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
269
+ * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
270
+ * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
271
271
  */
272
272
  async uploadFiles(postageBatchId, fileList, options, requestOptions) {
273
273
  (0, type_2.assertBatchId)(postageBatchId);
@@ -305,9 +305,9 @@ class Bee {
305
305
  * @param dir the path of the files to be uploaded
306
306
  * @param options Additional options like tag, encryption, pinning and request options
307
307
  *
308
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
309
- * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/access-the-swarm/upload-a-directory/)
310
- * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/Collection/paths/~1bzz/post)
308
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
309
+ * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory)
310
+ * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post)
311
311
  */
312
312
  async uploadFilesFromDirectory(postageBatchId, dir, options, requestOptions) {
313
313
  (0, type_2.assertBatchId)(postageBatchId);
@@ -320,7 +320,7 @@ class Bee {
320
320
  * Create a new Tag which is meant for tracking progres of syncing data across network.
321
321
  *
322
322
  * @param options Options that affects the request behavior
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 - `POST /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post)
325
325
  */
326
326
  async createTag(options) {
@@ -336,7 +336,7 @@ class Bee {
336
336
  * @throws TypeError if limit or offset are not numbers or undefined
337
337
  * @throws BeeArgumentError if limit or offset have invalid options
338
338
  *
339
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
339
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
340
340
  * @see [Bee API reference - `GET /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/get)
341
341
  */
342
342
  async getAllTags(options) {
@@ -351,7 +351,7 @@ class Bee {
351
351
  * @param options Options that affects the request behavior
352
352
  * @throws TypeError if tagUid is in not correct format
353
353
  *
354
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
354
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
355
355
  * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/get)
356
356
  *
357
357
  */
@@ -368,7 +368,7 @@ class Bee {
368
368
  * @throws TypeError if tagUid is in not correct format
369
369
  * @throws BeeResponse error if something went wrong on the Bee node side while deleting the tag.
370
370
  *
371
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
371
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
372
372
  * @see [Bee API reference - `DELETE /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/delete)
373
373
  */
374
374
  async deleteTag(tagUid, options) {
@@ -388,7 +388,7 @@ class Bee {
388
388
  * @throws TypeError if tagUid is in not correct format
389
389
  * @throws BeeResponse error if something went wrong on the Bee node side while deleting the tag.
390
390
  *
391
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
391
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
392
392
  * @see [Bee API reference - `PATCH /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/patch)
393
393
  */
394
394
  async updateTag(tagUid, reference, options) {
@@ -404,7 +404,7 @@ class Bee {
404
404
  * @param options Options that affects the request behavior
405
405
  * @throws TypeError if reference is in not correct format
406
406
  *
407
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
407
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
408
408
  */
409
409
  async pin(reference, options) {
410
410
  (0, type_2.assertRequestOptions)(options);
@@ -418,7 +418,7 @@ class Bee {
418
418
  * @param options Options that affects the request behavior
419
419
  * @throws TypeError if reference is in not correct format
420
420
  *
421
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
421
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
422
422
  */
423
423
  async unpin(reference, options) {
424
424
  (0, type_2.assertRequestOptions)(options);
@@ -429,7 +429,7 @@ class Bee {
429
429
  * Get list of all locally pinned references
430
430
  *
431
431
  * @param options Options that affects the request behavior
432
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
432
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
433
433
  */
434
434
  async getAllPins(options) {
435
435
  (0, type_2.assertRequestOptions)(options);
@@ -443,7 +443,7 @@ class Bee {
443
443
  * @throws TypeError if some of the input parameters is not expected type
444
444
  * @throws BeeArgumentError if there is passed ENS domain with invalid unicode characters
445
445
  *
446
- * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
446
+ * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning)
447
447
  */
448
448
  async getPin(reference, options) {
449
449
  (0, type_2.assertRequestOptions)(options);
@@ -535,7 +535,7 @@ class Bee {
535
535
  * @param options Options that affects the request behavior
536
536
  * @throws TypeError if `data`, `batchId`, `target` or `recipient` are in invalid format
537
537
  *
538
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
538
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
539
539
  * @see [Bee API reference - `POST /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1send~1{topic}~1{targets}/post)
540
540
  */
541
541
  async pssSend(postageBatchId, topic, target, data, recipient, options) {
@@ -565,7 +565,7 @@ class Bee {
565
565
  *
566
566
  * @returns Subscription to a given topic
567
567
  *
568
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
568
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
569
569
  * @see [Bee API reference - `GET /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1{topic}/get)
570
570
  */
571
571
  pssSubscribe(topic, handler) {
@@ -627,7 +627,7 @@ class Bee {
627
627
  *
628
628
  * @returns Message in byte array
629
629
  *
630
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
630
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
631
631
  * @see [Bee API reference - `GET /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1{topic}/get)
632
632
  */
633
633
  async pssReceive(topic, timeoutMsec = 0) {
@@ -672,7 +672,7 @@ class Bee {
672
672
  * @param owner Owner's ethereum address in hex or bytes
673
673
  * @param options Options that affects the request behavior
674
674
  *
675
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
675
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
676
676
  * @see [Bee API reference - `POST /feeds`](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1{owner}~1{topic}/post)
677
677
  */
678
678
  async createFeedManifest(postageBatchId, type, topic, owner, options) {
@@ -692,7 +692,7 @@ class Bee {
692
692
  * @param owner Owner's ethereum address in hex or bytes
693
693
  * @param options Options that affects the request behavior
694
694
  *
695
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
695
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
696
696
  */
697
697
  makeFeedReader(type, topic, owner, options) {
698
698
  (0, type_2.assertRequestOptions)(options);
@@ -709,7 +709,7 @@ class Bee {
709
709
  * @param signer The signer's private key or a Signer instance that can sign data
710
710
  * @param options Options that affects the request behavior
711
711
  *
712
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
712
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
713
713
  */
714
714
  makeFeedWriter(type, topic, signer, options) {
715
715
  (0, type_2.assertRequestOptions)(options);
@@ -734,7 +734,7 @@ class Bee {
734
734
  *
735
735
  * @throws BeeError if `options.signer` is not specified nor the default Signer on Bee's instance is specified.
736
736
  *
737
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
737
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
738
738
  */
739
739
  async setJsonFeed(postageBatchId, topic, data, options, requestOptions) {
740
740
  (0, type_2.assertRequestOptions)(options, 'JsonFeedOptions');
@@ -761,7 +761,7 @@ class Bee {
761
761
  * @param options.address Ethereum address of owner of the feed that signed it. This option is exclusive with `signer` option.
762
762
  * @param options.type Type of Feed
763
763
  *
764
- * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/dapps-on-swarm/feeds)
764
+ * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds)
765
765
  */
766
766
  async getJsonFeed(topic, options) {
767
767
  (0, type_2.assertRequestOptions)(options, 'JsonFeedOptions');
@@ -806,7 +806,7 @@ class Bee {
806
806
  *
807
807
  * @param ownerAddress The ethereum address of the owner
808
808
  * @param options Options that affects the request behavior
809
- * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/dapps-on-swarm/chunk-types#single-owner-chunks)
809
+ * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks)
810
810
  */
811
811
  makeSOCReader(ownerAddress, options) {
812
812
  (0, type_2.assertRequestOptions)(options);
@@ -821,7 +821,7 @@ class Bee {
821
821
  *
822
822
  * @param signer The signer's private key or a Signer instance that can sign data
823
823
  * @param options Options that affects the request behavior
824
- * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/dapps-on-swarm/chunk-types#single-owner-chunks)
824
+ * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks)
825
825
  */
826
826
  makeSOCWriter(signer, options) {
827
827
  (0, type_2.assertRequestOptions)(options);
@@ -872,7 +872,7 @@ class Bee {
872
872
  * @param tagUid UID or tag object to be retrieved
873
873
  * @throws TypeError if tagUid is in not correct format
874
874
  *
875
- * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
875
+ * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
876
876
  * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/debug-api/#tag/Tag)
877
877
  *
878
878
  */
@@ -1170,7 +1170,7 @@ class Bee {
1170
1170
  * Creates new postage batch from the funds that the node has available in its Ethereum account.
1171
1171
  *
1172
1172
  * For better understanding what each parameter means and what are the optimal values please see
1173
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
1173
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction#keep-your-data-alive).
1174
1174
  *
1175
1175
  * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1176
1176
  *
@@ -1180,7 +1180,7 @@ class Bee {
1180
1180
  * @throws BeeArgumentError when negative amount or depth is specified
1181
1181
  * @throws TypeError if non-integer value is passed to amount or depth
1182
1182
  *
1183
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1183
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1184
1184
  * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
1185
1185
  */
1186
1186
  async createPostageBatch(amount, depth, options, requestOptions) {
@@ -1206,7 +1206,7 @@ class Bee {
1206
1206
  * Topup a fresh amount of BZZ to given Postage Batch.
1207
1207
  *
1208
1208
  * For better understanding what each parameter means and what are the optimal values please see
1209
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
1209
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive).
1210
1210
  *
1211
1211
  * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1212
1212
  *
@@ -1214,7 +1214,7 @@ class Bee {
1214
1214
  * @param amount Amount to be added to the batch
1215
1215
  * @param options Request options
1216
1216
  *
1217
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1217
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1218
1218
  * @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)
1219
1219
  */
1220
1220
  async topUpBatch(postageBatchId, amount, options) {
@@ -1228,7 +1228,7 @@ class Bee {
1228
1228
  * the Postage Batch to be used for more chunks.
1229
1229
  *
1230
1230
  * For better understanding what each parameter means and what are the optimal values please see
1231
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
1231
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive).
1232
1232
  *
1233
1233
  * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
1234
1234
  *
@@ -1236,7 +1236,7 @@ class Bee {
1236
1236
  * @param depth Amount to be added to the batch
1237
1237
  * @param options Request options
1238
1238
  *
1239
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1239
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1240
1240
  * @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)
1241
1241
  */
1242
1242
  async diluteBatch(postageBatchId, depth, options) {
@@ -1250,7 +1250,7 @@ class Bee {
1250
1250
  *
1251
1251
  * @param postageBatchId Batch ID
1252
1252
  *
1253
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1253
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1254
1254
  * @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
1255
1255
  */
1256
1256
  async getPostageBatch(postageBatchId, options) {
@@ -1263,7 +1263,7 @@ class Bee {
1263
1263
  *
1264
1264
  * @param postageBatchId Batch ID
1265
1265
  *
1266
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1266
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1267
1267
  * @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{id}~1buckets/get)
1268
1268
  */
1269
1269
  async getPostageBatchBuckets(postageBatchId, options) {
@@ -1274,7 +1274,7 @@ class Bee {
1274
1274
  /**
1275
1275
  * Return all postage batches that has the node available.
1276
1276
  *
1277
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
1277
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive)
1278
1278
  * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps/get)
1279
1279
  */
1280
1280
  async getAllPostageBatch(options) {
@@ -7,7 +7,7 @@ const types_1 = require("../types");
7
7
  * target that Bee node will except.
8
8
  *
9
9
  * @param target is a non-prefixed hex string Bee address
10
- * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/dapps-on-swarm/pss)
10
+ * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
11
11
  */
12
12
  function makeMaxTarget(target) {
13
13
  if (typeof target !== 'string') {
@@ -5,7 +5,7 @@ const file_1 = require("./file");
5
5
  async function writeTar(collection, tarStream) {
6
6
  for (const item of collection) {
7
7
  if (item.file) {
8
- await tarStream.beginFile(item.path, item.file.size);
8
+ tarStream.beginFile(item.path, item.file.size);
9
9
  await tarStream.appendFile(new Uint8Array(await (0, file_1.fileArrayBuffer)(item.file)));
10
10
  await tarStream.endFile();
11
11
  }
@@ -4,7 +4,7 @@ exports.writeTar = void 0;
4
4
  const fs_1 = require("fs");
5
5
  async function writeTar(collection, tarStream) {
6
6
  for (const item of collection) {
7
- await tarStream.beginFile(item.path, item.size);
7
+ tarStream.beginFile(item.path, item.size);
8
8
  if (item.fsPath) {
9
9
  const stream = (0, fs_1.createReadStream)(item.fsPath);
10
10
  for await (const chunk of stream) {
@@ -14,7 +14,7 @@ class TarStream {
14
14
  return newAcc;
15
15
  });
16
16
  }
17
- async beginFile(path, size) {
17
+ beginFile(path, size) {
18
18
  const header = createHeader(path, size);
19
19
  this.pieces.push(header);
20
20
  this.currentFileSize = 0;
@@ -24,8 +24,10 @@ class TarStream {
24
24
  this.currentFileSize += data.length;
25
25
  }
26
26
  async endFile() {
27
- const padding = 512 - (this.currentFileSize % 512);
28
- this.pieces.push(new Uint8Array(padding));
27
+ const padding = this.currentFileSize % 512 === 0 ? 0 : 512 - (this.currentFileSize % 512);
28
+ if (padding > 0) {
29
+ this.pieces.push(new Uint8Array(padding));
30
+ }
29
31
  }
30
32
  async end() {
31
33
  this.pieces.push(createEndOfArchive());
@@ -33,30 +35,37 @@ class TarStream {
33
35
  }
34
36
  exports.TarStream = TarStream;
35
37
  function createHeader(path, size) {
36
- const header = new Uint8Array(512); // Initialize header with zeros
37
38
  const encoder = new TextEncoder();
38
39
  function writeToBuffer(str, offset, length) {
39
40
  const bytes = encoder.encode(str);
40
41
  header.set(bytes.slice(0, length), offset);
41
42
  }
42
- writeToBuffer(path, 0, 100); // File name
43
- writeToBuffer('0000777', 100, 8); // File mode
44
- writeToBuffer('0001750', 108, 8); // UID
45
- writeToBuffer('0001750', 116, 8); // GID
46
- writeToBuffer(size.toString(8).padStart(11, '0') + ' ', 124, 12); // File size
47
- writeToBuffer(Math.floor(Date.now() / 1000).toString(8) + ' ', 136, 12); // Mod time
48
- writeToBuffer(' ', 148, 8); // Checksum placeholder
49
- writeToBuffer('0', 156, 1); // Typeflag
50
- writeToBuffer('ustar ', 257, 8); // Magic and version
51
- for (let i = 345; i < 512; i++) {
52
- header[i] = 0; // Fill remaining with zeros
53
- }
43
+ // Initialize header with zeros
44
+ const header = new Uint8Array();
45
+ header.fill(0, 0, 512);
46
+ // File name, truncated to 100 characters if necessary
47
+ writeToBuffer(path.slice(0, 100).padEnd(100, '\0'), 0, 100);
48
+ // File mode (octal) and null-terminated
49
+ writeToBuffer('0000777\0', 100, 8);
50
+ // UID and GID (octal) and null-terminated
51
+ writeToBuffer('0001750\0', 108, 8); // UID
52
+ writeToBuffer('0001750\0', 116, 8); // GID
53
+ // File size in octal (11 chars) and null-terminated
54
+ writeToBuffer(size.toString(8).padStart(11, '0') + '\0', 124, 12);
55
+ // Modification time in octal and null-terminated
56
+ const modTime = Math.floor(new Date().getTime() / 1000);
57
+ writeToBuffer(modTime.toString(8).padStart(11, '0') + '\0', 136, 12);
58
+ // Checksum placeholder (8 spaces)
59
+ writeToBuffer(' ', 148, 8);
60
+ // Typeflag (normal file)
61
+ writeToBuffer('0', 156, 1);
62
+ // USTAR magic and version
63
+ writeToBuffer('ustar\0\0', 257, 8);
54
64
  // Calculate checksum
55
65
  let checksum = 0;
56
66
  for (let i = 0; i < 512; i++) {
57
67
  checksum += header[i];
58
68
  }
59
- // Write checksum
60
69
  writeToBuffer(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
61
70
  return header;
62
71
  }
@@ -7,43 +7,67 @@ class TarStream {
7
7
  this.output = new stream_1.PassThrough();
8
8
  this.currentFileSize = 0;
9
9
  }
10
- async beginFile(path, size) {
10
+ beginFile(path, size) {
11
11
  const header = createHeader(path, size);
12
12
  this.output.write(header);
13
13
  this.currentFileSize = 0;
14
14
  }
15
15
  async appendFile(data) {
16
16
  return new Promise(resolve => {
17
- this.output.write(data, () => {
17
+ if (!this.output.write(data)) {
18
+ this.output.once('drain', () => {
19
+ resolve();
20
+ });
21
+ }
22
+ else {
18
23
  resolve();
19
- });
24
+ }
20
25
  this.currentFileSize += data.length;
21
26
  });
22
27
  }
23
28
  async endFile() {
24
- const padding = 512 - (this.currentFileSize % 512);
25
- this.output.write(Buffer.alloc(padding, 0));
29
+ const padding = this.currentFileSize % 512 === 0 ? 0 : 512 - (this.currentFileSize % 512);
30
+ if (padding > 0) {
31
+ this.output.write(Buffer.alloc(padding, 0));
32
+ }
26
33
  }
27
34
  async end() {
28
- this.output.write(createEndOfArchive());
29
- this.output.end();
35
+ return new Promise(resolve => {
36
+ this.output.write(createEndOfArchive());
37
+ this.output.end(() => {
38
+ resolve();
39
+ });
40
+ });
30
41
  }
31
42
  }
32
43
  exports.TarStream = TarStream;
33
44
  function createHeader(path, size) {
34
- const header = Buffer.alloc(512, 0); // Initialize header with zeros
35
- header.write(path, 0, 100); // File name
36
- header.write('0000777', 100, 8); // File mode
37
- header.write('0001750', 108, 8); // UID
38
- header.write('0001750', 116, 8); // GID
39
- header.write(size.toString(8).padStart(11, '0') + ' ', 124, 12); // File size
40
- header.write(Math.floor(new Date().getTime() / 1000).toString(8) + ' ', 136, 12); // Mod time
41
- header.write(' ', 148, 8); // Checksum placeholder
42
- header.write('0', 156, 1); // Typeflag
43
- header.write('ustar ', 257, 8); // Magic and version
44
- header.write('0'.repeat(8 * 12), 345, 8 * 12); // Fill remaining with zeros
45
- const checksum = header.reduce((sum, elem) => sum + elem, 0);
46
- header.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8); // Write checksum
45
+ // Initialize header with zeros
46
+ const header = Buffer.alloc(512, 0);
47
+ // File name, truncated to 100 characters if necessary
48
+ header.write(path.slice(0, 100).padEnd(100, '\0'), 0, 100);
49
+ // File mode (octal) and null-terminated
50
+ header.write('0000777\0', 100, 8);
51
+ // UID and GID (octal) and null-terminated
52
+ header.write('0001750\0', 108, 8); // UID
53
+ header.write('0001750\0', 116, 8); // GID
54
+ // File size in octal (11 chars) and null-terminated
55
+ header.write(size.toString(8).padStart(11, '0') + '\0', 124, 12);
56
+ // Modification time in octal and null-terminated
57
+ const modTime = Math.floor(new Date().getTime() / 1000);
58
+ header.write(modTime.toString(8).padStart(11, '0') + '\0', 136, 12);
59
+ // Checksum placeholder (8 spaces)
60
+ header.write(' ', 148, 8);
61
+ // Typeflag (normal file)
62
+ header.write('0', 156, 1);
63
+ // USTAR magic and version
64
+ header.write('ustar\0\0', 257, 8);
65
+ // Calculate checksum
66
+ let checksum = 0;
67
+ for (let i = 0; i < 512; i++) {
68
+ checksum += header[i];
69
+ }
70
+ header.write(checksum.toString(8).padStart(6, '0') + '\0 ', 148, 8);
47
71
  return header;
48
72
  }
49
73
  function createEndOfArchive() {