@ethersphere/bee-js 2.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +2 -2
  3. package/dist/index.browser.min.js +1 -1
  4. package/dist/index.browser.min.js.map +1 -1
  5. package/dist/index.min.js +1 -1
  6. package/dist/index.min.js.map +1 -1
  7. package/dist/src/bee-debug.d.ts +38 -6
  8. package/dist/src/bee.d.ts +34 -46
  9. package/dist/src/modules/chunk.d.ts +2 -10
  10. package/dist/src/modules/debug/stamps.d.ts +2 -0
  11. package/dist/src/modules/debug/status.d.ts +10 -4
  12. package/dist/src/modules/stewardship.d.ts +1 -0
  13. package/dist/src/types/debug.d.ts +11 -0
  14. package/dist/src/types/index.d.ts +6 -7
  15. package/dist/src/utils/bytes.d.ts +1 -1
  16. package/dist/src/utils/expose.d.ts +1 -0
  17. package/dist/src/utils/stamps.d.ts +12 -0
  18. package/package.json +10 -8
  19. package/.babelrc.js +0 -33
  20. package/.depcheckrc.json +0 -27
  21. package/.editorconfig +0 -6
  22. package/.eslintignore +0 -1
  23. package/.eslintrc.js +0 -109
  24. package/.gitattributes +0 -1
  25. package/.github/config.yaml +0 -23
  26. package/.github/workflows/check.yaml +0 -57
  27. package/.github/workflows/publish_npmjs.yaml +0 -20
  28. package/.github/workflows/release_github.yaml +0 -20
  29. package/.github/workflows/tests.yaml +0 -128
  30. package/.huskyrc +0 -5
  31. package/.prettierrc +0 -13
  32. package/.vscode/launch.json +0 -49
  33. package/.vscode/settings.json +0 -39
  34. package/CODEOWNERS +0 -1
  35. package/CODE_OF_CONDUCT.md +0 -76
  36. package/commitlint.config.js +0 -3
  37. package/dist/src/modules/stamps.d.ts +0 -4
  38. package/jest-puppeteer.config.js +0 -5
  39. package/jest.config.ts +0 -85
  40. package/src/bee-debug.ts +0 -559
  41. package/src/bee.ts +0 -1070
  42. package/src/chunk/bmt.ts +0 -55
  43. package/src/chunk/cac.ts +0 -79
  44. package/src/chunk/serialize.ts +0 -16
  45. package/src/chunk/signer.ts +0 -141
  46. package/src/chunk/soc.ts +0 -190
  47. package/src/chunk/span.ts +0 -33
  48. package/src/feed/index.ts +0 -217
  49. package/src/feed/json.ts +0 -33
  50. package/src/feed/topic.ts +0 -23
  51. package/src/feed/type.ts +0 -12
  52. package/src/index.ts +0 -24
  53. package/src/modules/bytes.ts +0 -70
  54. package/src/modules/bzz.ts +0 -179
  55. package/src/modules/chunk.ts +0 -69
  56. package/src/modules/debug/balance.ts +0 -63
  57. package/src/modules/debug/chequebook.ts +0 -175
  58. package/src/modules/debug/chunk.ts +0 -39
  59. package/src/modules/debug/connectivity.ts +0 -61
  60. package/src/modules/debug/settlements.ts +0 -33
  61. package/src/modules/debug/stamps.ts +0 -76
  62. package/src/modules/debug/states.ts +0 -35
  63. package/src/modules/debug/status.ts +0 -35
  64. package/src/modules/debug/tag.ts +0 -19
  65. package/src/modules/debug/transactions.ts +0 -79
  66. package/src/modules/feed.ts +0 -105
  67. package/src/modules/pinning.ts +0 -74
  68. package/src/modules/pss.ts +0 -49
  69. package/src/modules/soc.ts +0 -40
  70. package/src/modules/stamps.ts +0 -59
  71. package/src/modules/status.ts +0 -13
  72. package/src/modules/stewardship.ts +0 -18
  73. package/src/modules/tag.ts +0 -83
  74. package/src/types/debug.ts +0 -204
  75. package/src/types/index.ts +0 -566
  76. package/src/types/ky-universal/common.d.ts +0 -17
  77. package/src/types/ky-universal/hooks.d.ts +0 -103
  78. package/src/types/ky-universal/index.d.ts +0 -125
  79. package/src/types/ky-universal/options.d.ts +0 -235
  80. package/src/types/ky-universal/response.d.ts +0 -38
  81. package/src/types/ky-universal/retry.d.ts +0 -39
  82. package/src/types/tar-js.d.ts +0 -1
  83. package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
  84. package/src/utils/bytes.ts +0 -144
  85. package/src/utils/collection.ts +0 -151
  86. package/src/utils/data.browser.ts +0 -68
  87. package/src/utils/data.ts +0 -48
  88. package/src/utils/error.ts +0 -23
  89. package/src/utils/eth.ts +0 -229
  90. package/src/utils/expose.ts +0 -48
  91. package/src/utils/file.ts +0 -40
  92. package/src/utils/hash.ts +0 -16
  93. package/src/utils/headers.ts +0 -63
  94. package/src/utils/hex.ts +0 -186
  95. package/src/utils/http.ts +0 -141
  96. package/src/utils/merge.ts +0 -34
  97. package/src/utils/pss.ts +0 -16
  98. package/src/utils/stream.ts +0 -146
  99. package/src/utils/tar.ts +0 -30
  100. package/src/utils/type.ts +0 -394
  101. package/src/utils/uint64.ts +0 -31
  102. package/src/utils/url.ts +0 -52
  103. package/test/bee.sh +0 -187
  104. package/test/data/1.txt +0 -1
  105. package/test/data/2.txt +0 -0
  106. package/test/data/empty +0 -0
  107. package/test/data/sub/3.txt +0 -1
  108. package/test/data/sub//303/251 +0 -0
  109. package/test/data/sub//360/237/230/216 +0 -0
  110. package/test/integration/bee-class.browser.spec.ts +0 -272
  111. package/test/integration/bee-class.spec.ts +0 -631
  112. package/test/integration/bee-debug-class.spec.ts +0 -85
  113. package/test/integration/chunk/bmt.spec.ts +0 -33
  114. package/test/integration/chunk/cac.spec.ts +0 -27
  115. package/test/integration/chunk/soc.spec.ts +0 -38
  116. package/test/integration/feed/index.spec.ts +0 -84
  117. package/test/integration/modules/bytes.spec.ts +0 -23
  118. package/test/integration/modules/bzz.spec.ts +0 -265
  119. package/test/integration/modules/chunk.spec.ts +0 -29
  120. package/test/integration/modules/debug/balance.spec.ts +0 -70
  121. package/test/integration/modules/debug/chequebook.spec.ts +0 -64
  122. package/test/integration/modules/debug/connectivity.spec.ts +0 -69
  123. package/test/integration/modules/debug/settlements.spec.ts +0 -34
  124. package/test/integration/modules/debug/states.spec.ts +0 -34
  125. package/test/integration/modules/debug/status.spec.ts +0 -65
  126. package/test/integration/modules/debug/tag.spec.ts +0 -27
  127. package/test/integration/modules/debug/transactions.spec.ts +0 -10
  128. package/test/integration/modules/feed.spec.ts +0 -61
  129. package/test/integration/modules/pinning.spec.ts +0 -155
  130. package/test/integration/modules/pss.spec.ts +0 -97
  131. package/test/integration/modules/status.spec.ts +0 -10
  132. package/test/integration/modules/stewardship.spec.ts +0 -32
  133. package/test/integration/modules/tag.spec.ts +0 -51
  134. package/test/test-type-sequencer.js +0 -36
  135. package/test/testpage/testpage.html +0 -20
  136. package/test/tests-setup.ts +0 -94
  137. package/test/unit/assertions.ts +0 -460
  138. package/test/unit/bee-class.spec.ts +0 -976
  139. package/test/unit/bee-debug-class.spec.ts +0 -435
  140. package/test/unit/chunk/bmt.spec.ts +0 -16
  141. package/test/unit/chunk/cac.spec.ts +0 -29
  142. package/test/unit/chunk/serialize.spec.ts +0 -24
  143. package/test/unit/chunk/signer.spec.ts +0 -140
  144. package/test/unit/chunk/soc.spec.ts +0 -25
  145. package/test/unit/chunk/span.spec.ts +0 -38
  146. package/test/unit/feed/json.spec.ts +0 -73
  147. package/test/unit/nock.ts +0 -151
  148. package/test/unit/utils/bytes.spec.ts +0 -32
  149. package/test/unit/utils/collection.spec.ts +0 -22
  150. package/test/unit/utils/eth.spec.ts +0 -224
  151. package/test/unit/utils/hex.spec.ts +0 -115
  152. package/test/unit/utils/stream.spec.ts +0 -30
  153. package/test/unit/utils/type.spec.ts +0 -32
  154. package/test/unit/utils/uint64.spec.ts +0 -102
  155. package/test/utils.ts +0 -328
  156. package/tsconfig.json +0 -18
  157. package/tsconfig.test.json +0 -11
  158. package/typedoc.json +0 -7
  159. package/webpack.config.ts +0 -141
@@ -1,10 +1,5 @@
1
- import type { Address, Peer, BalanceResponse, PeerBalance, ChequebookAddressResponse, ChequebookBalanceResponse, LastChequesResponse, LastChequesForPeerResponse, LastCashoutActionResponse, Settlements, AllSettlements, RemovePeerResponse, Topology, PingResponse, Health, NodeAddresses, ReserveState, ChainState, NumberString, ExtendedTag, PostageBatchBuckets, DebugPostageBatch, TransactionInfo, TransactionHash } from './types';
1
+ import type { Address, Peer, BalanceResponse, PeerBalance, ChequebookAddressResponse, ChequebookBalanceResponse, LastChequesResponse, LastChequesForPeerResponse, LastCashoutActionResponse, Settlements, AllSettlements, RemovePeerResponse, Topology, PingResponse, Health, NodeAddresses, ReserveState, ChainState, NumberString, ExtendedTag, PostageBatchBuckets, DebugPostageBatch, TransactionInfo, TransactionHash, NodesInfo } from './types';
2
2
  import { BatchId, BeeOptions, CashoutOptions, PostageBatchOptions, RequestOptions, Tag } from './types';
3
- /**
4
- * The BeeDebug class provides a way of interacting with the Bee debug APIs based on the provided url
5
- *
6
- * @param url URL of a running Bee node
7
- */
8
3
  export declare class BeeDebug {
9
4
  /**
10
5
  * URL on which is the Debug API of Bee node exposed
@@ -122,6 +117,10 @@ export declare class BeeDebug {
122
117
  * Get health of node
123
118
  */
124
119
  getHealth(options?: RequestOptions): Promise<Health>;
120
+ /**
121
+ * Get mode information of node
122
+ */
123
+ getNodeInfo(options?: RequestOptions): Promise<NodesInfo>;
125
124
  /**
126
125
  * Connnects to a node and checks if it is a supported Bee version by the bee-js
127
126
  *
@@ -154,6 +153,39 @@ export declare class BeeDebug {
154
153
  * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/debug-api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
155
154
  */
156
155
  createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
156
+ /**
157
+ * Topup a fresh amount of BZZ to given Postage Batch.
158
+ *
159
+ * For better understanding what each parameter means and what are the optimal values please see
160
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
161
+ *
162
+ * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
163
+ *
164
+ * @param postageBatchId Batch ID
165
+ * @param amount Amount to be added to the batch
166
+ * @param options Request options
167
+ *
168
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
169
+ * @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)
170
+ */
171
+ topUpBatch(postageBatchId: BatchId | string, amount: NumberString, options?: RequestOptions): Promise<void>;
172
+ /**
173
+ * Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows
174
+ * the Postage Batch to be used for more chunks.
175
+ *
176
+ * For better understanding what each parameter means and what are the optimal values please see
177
+ * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
178
+ *
179
+ * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
180
+ *
181
+ * @param postageBatchId Batch ID
182
+ * @param depth Amount to be added to the batch
183
+ * @param options Request options
184
+ *
185
+ * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
186
+ * @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)
187
+ */
188
+ diluteBatch(postageBatchId: BatchId | string, depth: number, options?: RequestOptions): Promise<void>;
157
189
  /**
158
190
  * Return details for specific postage batch.
159
191
  *
package/dist/src/bee.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FeedType } from './feed/type';
2
2
  import { EthAddress } from './utils/eth';
3
- import { AllTagsOptions, Collection, NumberString, PostageBatchOptions, Readable, RequestOptions, UploadResult } from './types';
4
- import type { Tag, FileData, Reference, UploadOptions, PublicKey, AddressPrefix, PssMessageHandler, PssSubscription, CollectionUploadOptions, FileUploadOptions, Data, Signer, FeedReader, FeedWriter, SOCWriter, SOCReader, Topic, BeeOptions, JsonFeedOptions, AnyJson, Pin, PostageBatch, BatchId } from './types';
3
+ import { AllTagsOptions, Collection, Readable, RequestOptions, UploadResult } from './types';
4
+ import type { Tag, FileData, Reference, UploadOptions, PublicKey, AddressPrefix, PssMessageHandler, PssSubscription, CollectionUploadOptions, FileUploadOptions, Data, Signer, FeedReader, FeedWriter, SOCWriter, SOCReader, Topic, BeeOptions, JsonFeedOptions, AnyJson, Pin, BatchId } from './types';
5
5
  /**
6
6
  * The main component that abstracts operations available on the main Bee API.
7
7
  *
@@ -57,6 +57,27 @@ export declare class Bee {
57
57
  * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get)
58
58
  */
59
59
  downloadReadableData(reference: Reference | string, options?: RequestOptions): Promise<ReadableStream<Uint8Array>>;
60
+ /**
61
+ * Upload chunk to a Bee node
62
+ *
63
+ * @param postageBatchId Postage BatchId to be used to upload the chunk with
64
+ * @param data Raw chunk to be uploaded
65
+ * @param options Additional options like tag, encryption, pinning, content-type and request options
66
+ *
67
+ * @returns reference is a content hash of the data
68
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
69
+ * @see [Bee API reference - `POST /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post)
70
+ */
71
+ uploadChunk(postageBatchId: string | BatchId, data: Uint8Array, options?: UploadOptions): Promise<Reference>;
72
+ /**
73
+ * Download chunk as a byte array
74
+ *
75
+ * @param reference Bee chunk reference
76
+ * @param options Options that affects the request behavior
77
+ * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/access-the-swarm/upload-and-download)
78
+ * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{reference}/get)
79
+ */
80
+ downloadChunk(reference: Reference | string, options?: RequestOptions): Promise<Data>;
60
81
  /**
61
82
  * Upload single file to a Bee node.
62
83
  *
@@ -265,8 +286,19 @@ export declare class Bee {
265
286
  * @param options Options that affects the request behavior
266
287
  * @throws BeeArgumentError if the reference is not locally pinned
267
288
  * @throws TypeError if reference is in not correct format
289
+ *
290
+ * @see [Bee API reference - `PUT /stewardship`](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1{reference}/put)
268
291
  */
269
292
  reuploadPinnedData(reference: Reference | string, options?: RequestOptions): Promise<void>;
293
+ /**
294
+ * Checks if content specified by reference is retrievable from the network.
295
+ *
296
+ * @param reference The checked content
297
+ * @param options Options that affects the request behavior
298
+ *
299
+ * @see [Bee API reference - `GET /stewardship`](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1{reference}/get)
300
+ */
301
+ isReferenceRetrievable(reference: Reference | string, options?: RequestOptions): Promise<boolean>;
270
302
  /**
271
303
  * Send data to recipient or target with Postal Service for Swarm.
272
304
  *
@@ -437,50 +469,6 @@ export declare class Bee {
437
469
  * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/dapps-on-swarm/chunk-types#single-owner-chunks)
438
470
  */
439
471
  makeSOCWriter(signer?: Signer | Uint8Array | string, options?: RequestOptions): SOCWriter;
440
- /**
441
- * Creates new postage batch from the funds that the node has available in its Ethereum account.
442
- *
443
- * For better understanding what each parameter means and what are the optimal values please see
444
- * [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive).
445
- *
446
- * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY**
447
- * **Warning! Not allowed when node is in Gateway mode!**
448
- *
449
- * @param amount Amount that represents the value per chunk, has to be greater or equal zero.
450
- * @param depth Logarithm of the number of chunks that can be stamped with the batch.
451
- * @param options Options for creation of postage batch and request options
452
- * @throws BeeArgumentError when negative amount or depth is specified
453
- * @throws TypeError if non-integer value is passed to amount or depth
454
- *
455
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
456
- * @see [Bee API reference - `POST /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post)
457
- * @deprecated Use DebugBee for postage batch management
458
- */
459
- createPostageBatch(amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
460
- /**
461
- * Return details for specific postage batch.
462
- *
463
- * **Warning! Not allowed when node is in Gateway mode!**
464
- *
465
- * @param postageBatchId Batch ID
466
- * @param options Options that affects the request behavior
467
- *
468
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
469
- * @see [Bee API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{id}/get)
470
- * @deprecated Use DebugBee for postage batch management
471
- */
472
- getPostageBatch(postageBatchId: BatchId | string, options?: RequestOptions): Promise<PostageBatch>;
473
- /**
474
- * Return all postage batches that has the node available.
475
- *
476
- * **Warning! Not allowed when node is in Gateway mode!**
477
- *
478
- * @param options Options that affects the request behavior
479
- * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/access-the-swarm/keep-your-data-alive)
480
- * @see [Bee API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get)
481
- * @deprecated Use DebugBee for postage batch management
482
- */
483
- getAllPostageBatch(options?: RequestOptions): Promise<PostageBatch[]>;
484
472
  /**
485
473
  * Ping the Bee node to see if there is a live Bee node on the given URL.
486
474
  *
@@ -1,5 +1,4 @@
1
- import type { BatchId, Ky, UploadOptions } from '../types';
2
- import { Reference } from '../types';
1
+ import type { BatchId, Data, Ky, Reference, UploadOptions } from '../types';
3
2
  /**
4
3
  * Upload chunk to a Bee node
5
4
  *
@@ -20,11 +19,4 @@ export declare function upload(ky: Ky, data: Uint8Array, postageBatchId: BatchId
20
19
  * @param hash Bee content reference
21
20
  *
22
21
  */
23
- export declare function download(ky: Ky, hash: string): Promise<Uint8Array>;
24
- /**
25
- * Download chunk data as a readable stream
26
- *
27
- * @param ky Ky instance for given Bee class instance
28
- * @param hash Bee content reference
29
- */
30
- export declare function downloadReadable(ky: Ky, hash: string): Promise<ReadableStream<Uint8Array>>;
22
+ export declare function download(ky: Ky, hash: string): Promise<Data>;
@@ -3,3 +3,5 @@ export declare function getAllPostageBatches(ky: Ky): Promise<DebugPostageBatch[
3
3
  export declare function getPostageBatch(ky: Ky, postageBatchId: BatchId): Promise<DebugPostageBatch>;
4
4
  export declare function getPostageBatchBuckets(ky: Ky, postageBatchId: BatchId): Promise<PostageBatchBuckets>;
5
5
  export declare function createPostageBatch(ky: Ky, amount: NumberString, depth: number, options?: PostageBatchOptions): Promise<BatchId>;
6
+ export declare function topUpBatch(ky: Ky, id: string, amount: NumberString): Promise<BatchId>;
7
+ export declare function diluteBatch(ky: Ky, id: string, depth: number): Promise<BatchId>;
@@ -1,4 +1,4 @@
1
- import type { Health } from '../../types/debug';
1
+ import type { Health, NodesInfo } from '../../types/debug';
2
2
  import { Ky } from '../../types';
3
3
  export declare const SUPPORTED_BEE_VERSION_EXACT: string;
4
4
  export declare const SUPPORTED_BEE_VERSION: string;
@@ -7,12 +7,18 @@ export declare const SUPPORTED_BEE_VERSION: string;
7
7
  *
8
8
  * @param ky Ky debug instance
9
9
  */
10
- export declare function getHealth(ky: Ky): Promise<Health> | never;
10
+ export declare function getHealth(ky: Ky): Promise<Health>;
11
11
  /**
12
- * Connnects to a node and checks if it is a supported Bee version by the bee-js
12
+ * Get information about Bee node
13
+ *
14
+ * @param ky Ky debug instance
15
+ */
16
+ export declare function getNodeInfo(ky: Ky): Promise<NodesInfo>;
17
+ /**
18
+ * Connects to a node and checks if it is a supported Bee version by the bee-js
13
19
  *
14
20
  * @param ky Ky debug instance
15
21
  *
16
22
  * @returns true if the Bee node version is supported
17
23
  */
18
- export declare function isSupportedVersion(ky: Ky): Promise<boolean> | never;
24
+ export declare function isSupportedVersion(ky: Ky): Promise<boolean>;
@@ -7,3 +7,4 @@ import type { Ky, Reference } from '../types';
7
7
  * @throws BeeResponseError if not locally pinned or invalid data
8
8
  */
9
9
  export declare function reupload(ky: Ky, reference: Reference): Promise<void>;
10
+ export declare function isRetrievable(ky: Ky, reference: Reference): Promise<boolean>;
@@ -118,6 +118,17 @@ export interface BalanceResponse {
118
118
  export interface Health {
119
119
  status: 'ok';
120
120
  version: string;
121
+ apiVersion: string;
122
+ debugApiVersion: string;
123
+ }
124
+ export declare enum BeeModes {
125
+ FULL = "full",
126
+ LIGHT = "light",
127
+ DEV = "dev"
128
+ }
129
+ export interface NodesInfo {
130
+ gatewayMode: boolean;
131
+ beeMode: BeeModes;
121
132
  }
122
133
  export interface RemovePeerResponse {
123
134
  message: string;
@@ -16,8 +16,12 @@ export declare type Ky = typeof ky;
16
16
  export interface Dictionary<T> {
17
17
  [Key: string]: T;
18
18
  }
19
+ export declare const SPAN_SIZE = 8;
20
+ export declare const SECTION_SIZE = 32;
21
+ export declare const BRANCHES = 128;
22
+ export declare const CHUNK_SIZE: number;
19
23
  export declare const ADDRESS_HEX_LENGTH = 64;
20
- export declare const PSS_TARGET_HEX_LENGTH_MAX = 4;
24
+ export declare const PSS_TARGET_HEX_LENGTH_MAX = 6;
21
25
  export declare const PUBKEY_HEX_LENGTH = 66;
22
26
  export declare const BATCH_ID_HEX_LENGTH = 64;
23
27
  export declare const REFERENCE_HEX_LENGTH = 64;
@@ -105,13 +109,8 @@ export interface UploadResult {
105
109
  reference: Reference;
106
110
  /**
107
111
  * Automatically created tag's UID.
108
- *
109
- * There is bug in Bee, that does not return correct CORS header (Access-Control-Expose-Headers) for the `Swarm-Tag` to be exposed
110
- * in browser when uploading collection. The `tagUid` is marked as optional even though in 99% of results
111
- * it is present. The Optional mark will be removed with next Bee release.
112
- * TODO: Remove Optional with next Bee release: https://github.com/ethersphere/bee-js/issues/406
113
112
  */
114
- tagUid?: number;
113
+ tagUid: number;
115
114
  }
116
115
  export interface UploadOptions extends RequestOptions {
117
116
  /**
@@ -22,7 +22,7 @@ export interface FlexBytes<Min extends number, Max extends number> extends Uint8
22
22
  readonly __max__: Max;
23
23
  }
24
24
  /**
25
- * Type guard for Bytes<T> type
25
+ * Type guard for `Bytes<T>` type
26
26
  *
27
27
  * @param b The byte array
28
28
  * @param length The length of the byte array
@@ -5,3 +5,4 @@ export { EthAddress, makeEthAddress, makeHexEthAddress, isHexEthAddress, ethToSw
5
5
  export { readableWebToNode, readableNodeToWeb, isReadableStream, isNodeReadable, normalizeToReadableStream, isReadable, } from './stream';
6
6
  export { keccak256Hash } from './hash';
7
7
  export { makeMaxTarget } from './pss';
8
+ export { getStampUsage } from './stamps';
@@ -0,0 +1,12 @@
1
+ import { DebugPostageBatch } from '../types';
2
+ /**
3
+ * Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
4
+ *
5
+ * Be aware for small depths (17, 18) this does not provide that much information as the provided set of distinct values
6
+ * is small.
7
+ *
8
+ * @param utilization
9
+ * @param depth
10
+ * @param bucketDepth
11
+ */
12
+ export declare function getStampUsage({ utilization, depth, bucketDepth }: DebugPostageBatch): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "2.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -27,9 +27,12 @@
27
27
  "./dist/index.min.js": "./dist/index.browser.min.js",
28
28
  "data": "data.browser"
29
29
  },
30
+ "files": [
31
+ "dist"
32
+ ],
30
33
  "types": "dist/src/index.d.ts",
31
34
  "scripts": {
32
- "prepare": "rimraf dist && npm run compile:types && npm run compile:browser --env mode=production && npm run compile:node --env mode=production",
35
+ "prepublishOnly": "rimraf dist && npm run compile:types && npm run compile:browser --env mode=production && npm run compile:node --env mode=production",
33
36
  "compile:node": "webpack --progress --env target=node",
34
37
  "compile:types": "tsc --emitDeclarationOnly --declaration",
35
38
  "compile:browser": "webpack --progress --env target=web",
@@ -48,13 +51,17 @@
48
51
  "depcheck": "depcheck ."
49
52
  },
50
53
  "dependencies": {
54
+ "@types/readable-stream": "^2.3.11",
55
+ "bufferutil": "^4.0.3",
51
56
  "cross-blob": "^2.0.1",
52
57
  "elliptic": "^6.5.4",
53
58
  "isomorphic-ws": "^4.0.1",
54
59
  "js-sha3": "^0.8.0",
55
60
  "ky": "^0.25.1",
56
61
  "ky-universal": "^0.8.2",
62
+ "readable-stream": "^3.6.0",
57
63
  "tar-js": "^0.3.0",
64
+ "utf-8-validate": "^5.0.5",
58
65
  "web-streams-polyfill": "^3.1.0",
59
66
  "ws": "^7.5.0"
60
67
  },
@@ -78,15 +85,12 @@
78
85
  "@types/jest-environment-puppeteer": "^4.4.1",
79
86
  "@types/node": "^15.12.4",
80
87
  "@types/puppeteer": "^5.4.3",
81
- "@types/readable-stream": "^2.3.11",
82
- "@types/tar-stream": "^2.2.0",
83
88
  "@types/terser-webpack-plugin": "^5.0.3",
84
89
  "@types/ws": "^7.4.5",
85
90
  "@typescript-eslint/eslint-plugin": "^4.28.0",
86
91
  "@typescript-eslint/parser": "^4.28.0",
87
92
  "babel-jest": "^27.0.5",
88
93
  "babel-loader": "^8.2.2",
89
- "bufferutil": "^4.0.3",
90
94
  "debug": "^4.3.1",
91
95
  "depcheck": "^1.4.0",
92
96
  "eslint": "^7.29.0",
@@ -101,14 +105,12 @@
101
105
  "nock": "^13.1.0",
102
106
  "prettier": "^2.3.1",
103
107
  "puppeteer": "^9.1.1",
104
- "readable-stream": "^3.6.0",
105
108
  "rimraf": "^3.0.2",
106
109
  "terser-webpack-plugin": "^5.1.3",
107
110
  "ts-node": "^10.0.0",
108
111
  "typedoc": "^0.21.0",
109
112
  "typedoc-plugin-markdown": "^3.10.0",
110
113
  "typescript": "^4.3.4",
111
- "utf-8-validate": "^5.0.5",
112
114
  "webpack": "^5.40.0",
113
115
  "webpack-bundle-analyzer": "^4.4.1",
114
116
  "webpack-cli": "^4.7.2"
@@ -116,6 +118,6 @@
116
118
  "engines": {
117
119
  "node": ">=12.0.0",
118
120
  "npm": ">=6.0.0",
119
- "bee": "1.1.0-80cdea19"
121
+ "bee": "1.4.1-238867f1"
120
122
  }
121
123
  }
package/.babelrc.js DELETED
@@ -1,33 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = function (api) {
4
- const targets = '>1% or node >=10 and not ie 11 and not dead'
5
- api.cache(true)
6
- api.cacheDirectory = true
7
-
8
- return {
9
- presets: [
10
- '@babel/preset-typescript',
11
- [
12
- '@babel/preset-env',
13
- {
14
- corejs: 3,
15
- useBuiltIns: 'entry',
16
- modules: 'commonjs',
17
- bugfixes: true,
18
- targets
19
- }
20
- ]
21
- ],
22
- plugins: [
23
- '@babel/plugin-proposal-class-properties',
24
- [
25
- '@babel/plugin-transform-runtime',
26
- {
27
- helpers: false,
28
- regenerator: true
29
- }
30
- ]
31
- ]
32
- }
33
- }
package/.depcheckrc.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "ignores": [
3
- "@babel/core",
4
- "@babel/plugin-proposal-class-properties",
5
- "@babel/plugin-transform-runtime",
6
- "@babel/preset-env",
7
- "@babel/preset-typescript",
8
- "@commitlint/cli",
9
- "@commitlint/config-conventional",
10
- "@types/content-disposition",
11
- "@types/debug",
12
- "@types/expect-puppeteer",
13
- "@types/jest",
14
- "@types/jest-environment-puppeteer",
15
- "@types/puppeteer",
16
- "@types/tar-stream",
17
- "babel-jest",
18
- "babel-loader",
19
- "debug",
20
- "husky",
21
- "jest-puppeteer",
22
- "puppeteer",
23
- "ts-node",
24
- "typedoc-plugin-markdown",
25
- "webpack-cli"
26
- ]
27
- }
package/.editorconfig DELETED
@@ -1,6 +0,0 @@
1
- [*]
2
- indent_style = space
3
- indent_size = 2
4
- trim_trailing_whitespace = true
5
- insert_final_newline = true
6
- end_of_line = lf
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- dist/**
package/.eslintrc.js DELETED
@@ -1,109 +0,0 @@
1
- module.exports = {
2
- extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'],
3
- parserOptions: {
4
- sourceType: 'module',
5
- ecmaVersion: 2018,
6
- project: './tsconfig.test.json',
7
- },
8
- env: {
9
- jest: true,
10
- },
11
- globals: {
12
- browser: true,
13
- page: true,
14
- },
15
- plugins: ['jest', 'unused-imports'],
16
- rules: {
17
- 'array-bracket-newline': ['error', 'consistent'],
18
- strict: ['error', 'safe'],
19
- 'block-scoped-var': 'error',
20
- complexity: 'warn',
21
- 'default-case': 'error',
22
- 'dot-notation': 'warn',
23
- eqeqeq: 'error',
24
- 'guard-for-in': 'warn',
25
- 'linebreak-style': ['warn', 'unix'],
26
- 'no-alert': 'error',
27
- 'no-case-declarations': 'error',
28
- 'no-console': 'error',
29
- 'no-constant-condition': 'error',
30
- 'no-continue': 'warn',
31
- 'no-div-regex': 'error',
32
- 'no-empty': 'warn',
33
- 'no-empty-pattern': 'error',
34
- 'no-implicit-coercion': 'error',
35
- 'prefer-arrow-callback': 'warn',
36
- 'no-labels': 'error',
37
- 'no-loop-func': 'error',
38
- 'no-nested-ternary': 'warn',
39
- 'no-script-url': 'error',
40
- 'no-warning-comments': 'warn',
41
- 'quote-props': ['error', 'as-needed'],
42
- 'require-yield': 'error',
43
- 'max-nested-callbacks': ['error', 4],
44
- 'max-depth': ['error', 4],
45
- 'space-before-function-paren': [
46
- 'error',
47
- {
48
- anonymous: 'never',
49
- named: 'never',
50
- asyncArrow: 'always',
51
- },
52
- ],
53
- 'padding-line-between-statements': [
54
- 'error',
55
- { blankLine: 'always', prev: '*', next: 'if' },
56
- { blankLine: 'always', prev: '*', next: 'function' },
57
- { blankLine: 'always', prev: '*', next: 'return' },
58
- ],
59
- 'no-useless-constructor': 'off',
60
- 'no-dupe-class-members': 'off',
61
- 'no-unused-expressions': 'off',
62
- curly: ['error', 'multi-line'],
63
- 'object-curly-spacing': ['error', 'always'],
64
- 'comma-dangle': ['error', 'always-multiline'],
65
- '@typescript-eslint/no-useless-constructor': 'error',
66
- '@typescript-eslint/no-unused-expressions': 'error',
67
- '@typescript-eslint/member-delimiter-style': [
68
- 'error',
69
- {
70
- multiline: {
71
- delimiter: 'none',
72
- requireLast: true,
73
- },
74
- singleline: {
75
- delimiter: 'semi',
76
- requireLast: false,
77
- },
78
- },
79
- ],
80
- '@typescript-eslint/ban-ts-comment': [
81
- 'error',
82
- {
83
- 'ts-expect-error': 'allow-with-description',
84
- 'ts-ignore': 'allow-with-description',
85
- 'ts-nocheck': 'allow-with-description',
86
- 'ts-check': 'allow-with-description',
87
- minimumDescriptionLength: 6,
88
- },
89
- ],
90
- 'require-await': 'off',
91
- '@typescript-eslint/promise-function-async': 'error',
92
- '@typescript-eslint/require-await': 'off',
93
- '@typescript-eslint/no-non-null-assertion': 'off',
94
- '@typescript-eslint/no-unused-vars': 'off',
95
- 'unused-imports/no-unused-imports': 'error',
96
- 'unused-imports/no-unused-vars': [
97
- 'warn',
98
- { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
99
- ],
100
- },
101
- overrides: [
102
- {
103
- files: ['*.spec.ts'],
104
- rules: {
105
- 'max-nested-callbacks': ['error', 10], // allow describe/it nesting
106
- },
107
- },
108
- ],
109
- }
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- * text=auto
@@ -1,23 +0,0 @@
1
- labels:
2
- issue: type:issue
3
- pull-request: type:pull-request
4
- release:
5
- trigger:
6
- labels:
7
- - 'autorelease: pending'
8
- checklist: |
9
- ## 🚀 Release checklist
10
-
11
- ### Before release
12
-
13
- - [ ] Ensure the release works with the intended `bee` version
14
- - [ ] Verify all the example code works with the release code
15
- - [ ] Verify all user documentation is up to date
16
- - [ ] Have two approval for this PR
17
- - [ ] Write small summary for the release and verify changelog
18
- - [ ] Verify that changes to release PR comment is synchronized to `CHANGELOG` with manual commit
19
-
20
- ### After release
21
-
22
- - [ ] Update API docs
23
- - [ ] Update example's `bee-js` version
@@ -1,57 +0,0 @@
1
- name: Check
2
-
3
- on:
4
- push:
5
- branches:
6
- - 'master'
7
- pull_request:
8
- branches:
9
- - '**'
10
-
11
- jobs:
12
- check:
13
- runs-on: ubuntu-latest
14
-
15
- strategy:
16
- matrix:
17
- node-version: [14.x]
18
-
19
- steps:
20
- - uses: actions/checkout@v2
21
- with:
22
- fetch-depth: 0
23
- - name: Use Node.js ${{ matrix.node-version }}
24
- uses: actions/setup-node@v1
25
- with:
26
- node-version: ${{ matrix.node-version }}
27
-
28
- ## Try getting the node modules from cache, if failed npm ci
29
- - uses: actions/cache@v2
30
- id: cache-npm
31
- with:
32
- path: node_modules
33
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
34
- restore-keys: |
35
- ${{ runner.OS }}-node-${{ env.cache-name }}-
36
- ${{ runner.OS }}-node-
37
- ${{ runner.OS }}-
38
- - name: Install npm deps
39
- if: steps.cache-npm.outputs.cache-hit != 'true'
40
- run: npm ci
41
-
42
- - name: Commit linting
43
- uses: wagoid/commitlint-github-action@v2
44
-
45
- - name: Code linting
46
- run: npm run lint:check
47
- env:
48
- CI: true
49
-
50
- - name: Dependency check
51
- run: npm run depcheck
52
-
53
- - name: Check typings
54
- run: npm run check:types
55
-
56
- - name: Build docs
57
- run: npm run docs