@ethersphere/bee-js 8.3.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +192 -50
  2. package/dist/cjs/bee-dev.js +78 -0
  3. package/dist/cjs/bee.js +341 -417
  4. package/dist/cjs/chunk/bmt.js +15 -32
  5. package/dist/cjs/chunk/cac.js +26 -36
  6. package/dist/cjs/chunk/soc.js +56 -51
  7. package/dist/cjs/feed/identifier.js +3 -28
  8. package/dist/cjs/feed/index.js +95 -44
  9. package/dist/cjs/feed/retrievable.js +11 -22
  10. package/dist/cjs/index.js +17 -1
  11. package/dist/cjs/manifest/manifest.js +369 -0
  12. package/dist/cjs/modules/bytes.js +24 -12
  13. package/dist/cjs/modules/bzz.js +24 -34
  14. package/dist/cjs/modules/chunk.js +13 -7
  15. package/dist/cjs/modules/debug/balance.js +29 -4
  16. package/dist/cjs/modules/debug/chequebook.js +60 -16
  17. package/dist/cjs/modules/debug/connectivity.js +82 -4
  18. package/dist/cjs/modules/debug/settlements.js +22 -2
  19. package/dist/cjs/modules/debug/stake.js +29 -11
  20. package/dist/cjs/modules/debug/stamps.js +88 -7
  21. package/dist/cjs/modules/debug/states.js +25 -3
  22. package/dist/cjs/modules/debug/status.js +45 -47
  23. package/dist/cjs/modules/debug/transactions.js +27 -5
  24. package/dist/cjs/modules/envelope.js +8 -6
  25. package/dist/cjs/modules/feed.js +25 -10
  26. package/dist/cjs/modules/grantee.js +18 -12
  27. package/dist/cjs/modules/gsoc.js +24 -0
  28. package/dist/cjs/modules/pinning.js +13 -2
  29. package/dist/cjs/modules/pss.js +9 -3
  30. package/dist/cjs/modules/soc.js +9 -4
  31. package/dist/cjs/modules/stewardship.js +7 -3
  32. package/dist/cjs/modules/tag.js +35 -3
  33. package/dist/cjs/package.json +1 -0
  34. package/dist/cjs/stamper/stamper.js +43 -0
  35. package/dist/cjs/types/debug.js +16 -1
  36. package/dist/cjs/types/index.js +2 -24
  37. package/dist/cjs/utils/bytes.js +67 -115
  38. package/dist/cjs/utils/chunk-size.js +17 -0
  39. package/dist/cjs/utils/chunk-stream.browser.js +85 -0
  40. package/dist/cjs/utils/chunk-stream.js +84 -0
  41. package/dist/cjs/utils/cid.js +5 -6
  42. package/dist/cjs/utils/collection.browser.js +2 -2
  43. package/dist/cjs/utils/collection.js +3 -2
  44. package/dist/cjs/utils/collection.node.js +0 -2
  45. package/dist/cjs/utils/constants.js +7 -3
  46. package/dist/cjs/utils/data.browser.js +6 -3
  47. package/dist/cjs/utils/data.js +8 -4
  48. package/dist/cjs/utils/duration.js +51 -0
  49. package/dist/cjs/utils/expose.js +11 -40
  50. package/dist/cjs/utils/headers.js +79 -52
  51. package/dist/cjs/utils/http.js +34 -10
  52. package/dist/cjs/utils/mime.js +78 -0
  53. package/dist/cjs/utils/pss.js +3 -4
  54. package/dist/cjs/utils/redundancy.js +18 -14
  55. package/dist/cjs/utils/resource-locator.js +17 -0
  56. package/dist/cjs/utils/size.js +35 -0
  57. package/dist/cjs/utils/stamps.js +67 -51
  58. package/dist/cjs/utils/tar-uploader.browser.js +2 -2
  59. package/dist/cjs/utils/tar-uploader.js +2 -2
  60. package/dist/cjs/utils/tar-writer.js +4 -0
  61. package/dist/cjs/utils/tar.browser.js +1 -1
  62. package/dist/cjs/utils/tokens.js +144 -0
  63. package/dist/cjs/utils/type.js +141 -350
  64. package/dist/cjs/utils/typed-bytes.js +179 -0
  65. package/dist/cjs/utils/upload-progress.js +2 -0
  66. package/dist/cjs/utils/url.js +0 -4
  67. package/dist/cjs/utils/workaround.js +27 -0
  68. package/dist/index.browser.min.js +1 -2
  69. package/dist/index.browser.min.js.map +1 -1
  70. package/dist/mjs/bee-dev.js +98 -0
  71. package/dist/mjs/bee.js +367 -411
  72. package/dist/mjs/chunk/bmt.js +13 -29
  73. package/dist/mjs/chunk/cac.js +26 -34
  74. package/dist/mjs/chunk/soc.js +57 -53
  75. package/dist/mjs/feed/identifier.js +3 -26
  76. package/dist/mjs/feed/index.js +98 -51
  77. package/dist/mjs/feed/retrievable.js +12 -23
  78. package/dist/mjs/index.js +10 -1
  79. package/dist/mjs/manifest/manifest.js +371 -0
  80. package/dist/mjs/modules/bytes.js +27 -15
  81. package/dist/mjs/modules/bzz.js +25 -32
  82. package/dist/mjs/modules/chunk.js +16 -8
  83. package/dist/mjs/modules/debug/balance.js +61 -4
  84. package/dist/mjs/modules/debug/chequebook.js +116 -16
  85. package/dist/mjs/modules/debug/connectivity.js +144 -3
  86. package/dist/mjs/modules/debug/settlements.js +46 -2
  87. package/dist/mjs/modules/debug/stake.js +69 -11
  88. package/dist/mjs/modules/debug/stamps.js +184 -7
  89. package/dist/mjs/modules/debug/states.js +55 -3
  90. package/dist/mjs/modules/debug/status.js +97 -45
  91. package/dist/mjs/modules/debug/transactions.js +61 -5
  92. package/dist/mjs/modules/envelope.js +11 -9
  93. package/dist/mjs/modules/feed.js +26 -10
  94. package/dist/mjs/modules/grantee.js +35 -13
  95. package/dist/mjs/modules/gsoc.js +16 -0
  96. package/dist/mjs/modules/pinning.js +23 -2
  97. package/dist/mjs/modules/pss.js +10 -4
  98. package/dist/mjs/modules/soc.js +10 -5
  99. package/dist/mjs/modules/stewardship.js +14 -4
  100. package/dist/mjs/modules/tag.js +93 -3
  101. package/dist/mjs/package.json +2 -1
  102. package/dist/mjs/stamper/stamper.js +39 -0
  103. package/dist/mjs/types/debug.js +15 -1
  104. package/dist/mjs/types/index.js +2 -24
  105. package/dist/mjs/utils/bytes.js +63 -104
  106. package/dist/mjs/utils/chunk-size.js +13 -0
  107. package/dist/mjs/utils/chunk-stream.browser.js +85 -0
  108. package/dist/mjs/utils/chunk-stream.js +87 -0
  109. package/dist/mjs/utils/cid.js +5 -6
  110. package/dist/mjs/utils/collection.browser.js +2 -2
  111. package/dist/mjs/utils/collection.js +2 -2
  112. package/dist/mjs/utils/collection.node.js +0 -2
  113. package/dist/mjs/utils/constants.js +6 -2
  114. package/dist/mjs/utils/data.browser.js +9 -3
  115. package/dist/mjs/utils/data.js +12 -4
  116. package/dist/mjs/utils/duration.js +47 -0
  117. package/dist/mjs/utils/expose.js +2 -7
  118. package/dist/mjs/utils/headers.js +73 -48
  119. package/dist/mjs/utils/http.js +33 -11
  120. package/dist/mjs/utils/mime.js +75 -0
  121. package/dist/mjs/utils/pss.js +3 -4
  122. package/dist/mjs/utils/redundancy.js +18 -8
  123. package/dist/mjs/utils/resource-locator.js +13 -0
  124. package/dist/mjs/utils/size.js +31 -0
  125. package/dist/mjs/utils/stamps.js +47 -44
  126. package/dist/mjs/utils/tar-uploader.browser.js +2 -2
  127. package/dist/mjs/utils/tar-uploader.js +2 -2
  128. package/dist/mjs/utils/tar-writer.js +3 -0
  129. package/dist/mjs/utils/tar.browser.js +1 -1
  130. package/dist/mjs/utils/tokens.js +139 -0
  131. package/dist/mjs/utils/type.js +215 -310
  132. package/dist/mjs/utils/typed-bytes.js +160 -0
  133. package/dist/mjs/utils/upload-progress.js +1 -0
  134. package/dist/mjs/utils/url.js +0 -4
  135. package/dist/mjs/utils/workaround.js +22 -0
  136. package/dist/types/bee-dev.d.ts +5 -0
  137. package/dist/types/bee.d.ts +88 -165
  138. package/dist/types/chunk/bmt.d.ts +2 -2
  139. package/dist/types/chunk/cac.d.ts +7 -24
  140. package/dist/types/chunk/soc.d.ts +15 -15
  141. package/dist/types/feed/identifier.d.ts +2 -4
  142. package/dist/types/feed/index.d.ts +14 -18
  143. package/dist/types/feed/retrievable.d.ts +3 -4
  144. package/dist/types/index.d.ts +28 -1
  145. package/dist/types/manifest/manifest.d.ts +106 -0
  146. package/dist/types/modules/bytes.d.ts +8 -5
  147. package/dist/types/modules/bzz.d.ts +8 -10
  148. package/dist/types/modules/chunk.d.ts +4 -3
  149. package/dist/types/modules/debug/balance.d.ts +3 -2
  150. package/dist/types/modules/debug/chequebook.d.ts +7 -6
  151. package/dist/types/modules/debug/connectivity.d.ts +5 -3
  152. package/dist/types/modules/debug/settlements.d.ts +2 -1
  153. package/dist/types/modules/debug/stake.d.ts +4 -2
  154. package/dist/types/modules/debug/stamps.d.ts +5 -4
  155. package/dist/types/modules/debug/status.d.ts +6 -25
  156. package/dist/types/modules/debug/transactions.d.ts +5 -4
  157. package/dist/types/modules/envelope.d.ts +3 -2
  158. package/dist/types/modules/feed.d.ts +20 -16
  159. package/dist/types/modules/grantee.d.ts +7 -6
  160. package/dist/types/modules/gsoc.d.ts +7 -0
  161. package/dist/types/modules/pinning.d.ts +2 -4
  162. package/dist/types/modules/pss.d.ts +4 -3
  163. package/dist/types/modules/soc.d.ts +3 -2
  164. package/dist/types/modules/stewardship.d.ts +4 -4
  165. package/dist/types/modules/tag.d.ts +2 -1
  166. package/dist/types/stamper/stamper.d.ts +15 -0
  167. package/dist/types/types/debug.d.ts +63 -115
  168. package/dist/types/types/index.d.ts +103 -204
  169. package/dist/types/utils/bytes.d.ts +16 -90
  170. package/dist/types/utils/chunk-size.d.ts +1 -0
  171. package/dist/types/utils/chunk-stream.browser.d.ts +6 -0
  172. package/dist/types/utils/chunk-stream.d.ts +6 -0
  173. package/dist/types/utils/cid.d.ts +3 -2
  174. package/dist/types/utils/collection.browser.d.ts +2 -2
  175. package/dist/types/utils/collection.d.ts +2 -1
  176. package/dist/types/utils/collection.node.d.ts +0 -1
  177. package/dist/types/utils/constants.d.ts +4 -1
  178. package/dist/types/utils/duration.d.ts +17 -0
  179. package/dist/types/utils/error.d.ts +2 -2
  180. package/dist/types/utils/expose.d.ts +2 -7
  181. package/dist/types/utils/headers.d.ts +3 -4
  182. package/dist/types/utils/mime.d.ts +1 -0
  183. package/dist/types/utils/pss.d.ts +2 -2
  184. package/dist/types/utils/resource-locator.d.ts +6 -0
  185. package/dist/types/utils/size.d.ts +16 -0
  186. package/dist/types/utils/stamps.d.ts +27 -33
  187. package/dist/types/utils/tar-uploader.browser.d.ts +3 -4
  188. package/dist/types/utils/tar-uploader.d.ts +3 -4
  189. package/dist/types/utils/tokens.d.ts +77 -0
  190. package/dist/types/utils/type.d.ts +20 -52
  191. package/dist/types/utils/typed-bytes.d.ts +68 -0
  192. package/dist/types/utils/upload-progress.d.ts +4 -0
  193. package/dist/types/utils/workaround.d.ts +2 -0
  194. package/package.json +11 -17
  195. package/dist/cjs/chunk/signer.js +0 -126
  196. package/dist/cjs/chunk/span.js +0 -25
  197. package/dist/cjs/feed/json.js +0 -28
  198. package/dist/cjs/feed/topic.js +0 -25
  199. package/dist/cjs/feed/type.js +0 -15
  200. package/dist/cjs/modules/debug/chunk.js +0 -21
  201. package/dist/cjs/modules/debug/tag.js +0 -19
  202. package/dist/cjs/utils/eth.js +0 -216
  203. package/dist/cjs/utils/hash.js +0 -21
  204. package/dist/cjs/utils/hex.js +0 -150
  205. package/dist/cjs/utils/reference.js +0 -36
  206. package/dist/index.browser.min.js.LICENSE.txt +0 -8
  207. package/dist/mjs/chunk/signer.js +0 -114
  208. package/dist/mjs/chunk/span.js +0 -21
  209. package/dist/mjs/feed/json.js +0 -26
  210. package/dist/mjs/feed/topic.js +0 -19
  211. package/dist/mjs/feed/type.js +0 -10
  212. package/dist/mjs/modules/debug/chunk.js +0 -17
  213. package/dist/mjs/modules/debug/tag.js +0 -15
  214. package/dist/mjs/utils/eth.js +0 -192
  215. package/dist/mjs/utils/hash.js +0 -16
  216. package/dist/mjs/utils/hex.js +0 -135
  217. package/dist/mjs/utils/reference.js +0 -29
  218. package/dist/types/chunk/signer.d.ts +0 -31
  219. package/dist/types/chunk/span.d.ts +0 -10
  220. package/dist/types/feed/json.d.ts +0 -4
  221. package/dist/types/feed/topic.d.ts +0 -3
  222. package/dist/types/feed/type.d.ts +0 -6
  223. package/dist/types/modules/debug/chunk.d.ts +0 -10
  224. package/dist/types/modules/debug/tag.d.ts +0 -8
  225. package/dist/types/utils/eth.d.ts +0 -67
  226. package/dist/types/utils/hash.d.ts +0 -9
  227. package/dist/types/utils/hex.d.ts +0 -86
  228. package/dist/types/utils/reference.d.ts +0 -2
package/README.md CHANGED
@@ -7,13 +7,13 @@
7
7
  ![](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-orange.svg?style=flat-square)
8
8
  ![](https://img.shields.io/badge/runs%20in-browser%20%7C%20node%20%7C%20webworker%20%7C%20electron-orange)
9
9
 
10
- > JavaScript SDK for connecting to a Bee node in the Swarm decentralised storage.
10
+ > JavaScript SDK for the Swarm decentralised storage.
11
11
 
12
12
  > Supports Node.js 18+, Vite and Webpack.
13
13
 
14
14
  > Write your code in CJS, MJS or TypeScript.
15
15
 
16
- > Intended to be used with Bee version 2.2.0.
16
+ > Intended to be used with Bee version 2.5.0.
17
17
 
18
18
  ## Quick start
19
19
 
@@ -37,12 +37,6 @@ Supported types are `node`, `node-esm`, `node-ts` and `vite-tsx`. Replace `my-da
37
37
  npm install @ethersphere/bee-js
38
38
  ```
39
39
 
40
- or
41
-
42
- ```sh
43
- yarn add @ethersphere/bee-js
44
- ```
45
-
46
40
  ## Import
47
41
 
48
42
  ### CJS
@@ -65,6 +59,185 @@ Loading this module through a script tag will make the `BeeJs` object available
65
59
  <script src="https://unpkg.com/@ethersphere/bee-js/dist/index.browser.min.js"></script>
66
60
  ```
67
61
 
62
+ ## Overview
63
+
64
+ ### Type interfaces
65
+
66
+ `NumberString` is a branded type for marking strings that represent numbers. It interops with `string` and `bigint`
67
+ types. Where `NumberString` is present, `number` is disallowed in order to avoid pitfalls with unsafe large values.
68
+
69
+ ### Byte primitives
70
+
71
+ All the classes below extend `Bytes`, therefor the following methods are available on all of them: `toUint8Array`,
72
+ `toHex`, `toBase64`, `toBase32`, `toUtf8`, `toJSON`, `static keccak256`, `static fromUtf8`.
73
+
74
+ The `toString` method uses `toHex`.
75
+
76
+ `Bytes` and its subclasses may be constructed with `new` from `Uint8Array` or hex `string`.
77
+
78
+ #### Elliptic
79
+
80
+ | Name | Description | Methods |
81
+ | ---------- | ------------------------- | ------------------------------------------------------ |
82
+ | PrivateKey | 32 bytes private key | `publicKey`, `sign` |
83
+ | PublicKey | 64 bytes public key | `address`, `toCompressedUint8Array`, `toCompressedHex` |
84
+ | EthAddress | 20 bytes Ethereum address | `toChecksum` |
85
+ | Signature | 65 bytes signature | `recoverPublicKey` |
86
+
87
+ #### Swarm
88
+
89
+ | Name | Description | Methods |
90
+ | ------------- | ----------------------------------- | ------------------------------- |
91
+ | Reference | 32/64 bytes reference (chunk, feed) | `toCid` |
92
+ | Identifier | 32 bytes identifier (SOC, Feed) | - |
93
+ | TransactionId | 32 bytes transaction ID | - |
94
+ | FeedIndex | 8 bytes feed index (BE) | `static fromBigInt`, `toBigInt` |
95
+ | Topic | 32 bytes topic | `static fromString` |
96
+ | PeerAddress | 32 bytes peer address | - |
97
+ | BatchId | 32 bytes batch ID | - |
98
+ | Span | 8 bytes span (LE) | `static fromBigInt`, `toBigInt` |
99
+
100
+ ### Tokens
101
+
102
+ | Name | Description | Methods |
103
+ | ---- | --------------------------- | ------------------------------------------------------------------------------------------------ |
104
+ | DAI | ERC20 DAI token (18 digits) | `static fromDecimalString`, `static fromWei`, `toWeiString`, `toWeiBigInt`, `toDecimalString` |
105
+ | BZZ | ERC20 BZZ token (16 digits) | `static fromDecimalString`, `static fromPLUR`, `toPLURString`, `toPLURBigInt`, `toDecimalString` |
106
+
107
+ ### Swarm chunks
108
+
109
+ | Name | Description | Creation |
110
+ | ---------------- | ----------------------------------------------------------------------------------------------- | --------------------------- |
111
+ | Chunk | Span, max. 4096 bytes payload; address dervied from content | `makeContentAddressedChunk` |
112
+ | SingleOwnerChunk | Identifier, signature, span, max. 4096 bytes payload; address derived from identifier and owner | `makeSingleOwnerChunk` |
113
+
114
+ ### Swarm primitives
115
+
116
+ | Name | Description | Methods |
117
+ | ------------ | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
118
+ | MantarayNode | Compact trie with reference values and JSON metadata | `addFork`, `removeFork`, `calculateSelfAddress`, `find`, `findClosest`, `collect`, `marshal`, `unmarshal`, `saveRecursively`, `loadRecursively` |
119
+ | MerkleTree | Streaming BMT of chunks | `append`, `finalize`, `static root` |
120
+
121
+ ### Swarm objects
122
+
123
+ | Name | Description | Creation |
124
+ | ---------- | ----------------------- | -------------------- |
125
+ | SOCWriter | SingleOwnerChunk writer | `bee.makeSOCWriter` |
126
+ | SOCReader | SingleOwnerChunk reader | `bee.makeSOCReader` |
127
+ | FeedWriter | Feed writer | `bee.makeFeedWriter` |
128
+ | FeedReader | Feed reader | `bee.makeFeedReader` |
129
+
130
+ ### Bee API
131
+
132
+ - ❌❌✅ - Full node only
133
+ - ❌✅✅ - Light node and full node
134
+ - ✅✅✅ - Ultra-light node, light node and full node
135
+
136
+ | JS Call | Bee Endpoint | Bee Mode |
137
+ | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
138
+ | `uploadFile` | `POST /bzz` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) | ❌✅✅ |
139
+ | `uploadFilesFromDirectory` _Node.js_ | `POST /bzz` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) | ❌✅✅ |
140
+ | `uploadFiles` | `POST /bzz` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) | ❌✅✅ |
141
+ | `uploadCollection` | `POST /bzz` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) | ❌✅✅ |
142
+ | `uploadData` | `POST /bytes` [🔗](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post) | ❌✅✅ |
143
+ | `uploadChunk` | `POST /chunks` [🔗](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post) | ❌✅✅ |
144
+ | `streamDirectory` _Node.js_ | `POST /chunks` [🔗](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post) | ❌✅✅ |
145
+ | `streamFiles` _Browser_ | `POST /chunks` [🔗](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post) | ❌✅✅ |
146
+ | `SOCWriter.upload` | `POST /soc/:owner/:identifier` [🔗](https://docs.ethswarm.org/api/#tag/Single-owner-chunk/paths/~1soc~1%7Bowner%7D~1%7Bid%7D/post) | ❌✅✅ |
147
+ | `FeedReader.download` | `GET /feeds/:owner/:topic` [🔗](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1%7Bowner%7D~1%7Btopic%7D/get) | ✅✅✅ |
148
+ | `FeedWriter.updateFeed` | `POST /soc/:owner/:identifier` [🔗](https://docs.ethswarm.org/api/#tag/Single-owner-chunk/paths/~1soc~1%7Bowner%7D~1%7Bid%7D/post) | ❌✅✅ |
149
+ | `downloadFile` | `GET /bzz/:reference` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D/get) | ✅✅✅ |
150
+ | `downloadFile` | `GET /bzz/:reference/:path` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get) | ✅✅✅ |
151
+ | `downloadReadableFile` | `GET /bzz/:reference` [🔗](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D/get) | ✅✅✅ |
152
+ | `downloadData` | `GET /bytes/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1%7Breference%7D/get) | ✅✅✅ |
153
+ | `downloadReadableData` | `GET /bytes/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1%7Breference%7D/get) | ✅✅✅ |
154
+ | `downloadChunk` | `GET /chunks/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1%7Baddress%7D/get) | ✅✅✅ |
155
+ | `createFeedManifest` | `POST /feeds/:owner/:topic` [🔗](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1%7Bowner%7D~1%7Btopic%7D/post) | ❌✅✅ |
156
+ | `isConnected` | `GET /` | ✅✅✅ |
157
+ | `getHealth` | `GET /health` [🔗](https://docs.ethswarm.org/api/#tag/Status/paths/~1health/get) | ✅✅✅ |
158
+ | `getReadiness` | `GET /readiness` [🔗](https://docs.ethswarm.org/api/#tag/Status/paths/~1readiness/get) | ✅✅✅ |
159
+ | `getNodeInfo` | `GET /node` [🔗](https://docs.ethswarm.org/api/#tag/Status/paths/~1node/get) | ✅✅✅ |
160
+ | `getChainState` | `GET /chainstate` [🔗](https://docs.ethswarm.org/api/#tag/Status/paths/~1chainstate/get) | ❌✅✅ |
161
+ | `getRedistributionState` | `GET /redistributionstate` [🔗](https://docs.ethswarm.org/api/#tag/RedistributionState/paths/~1redistributionstate/get) | ❌❌✅ |
162
+ | `getReserveState` | `GET /reservestate` [🔗](https://docs.ethswarm.org/api/#tag/Status/paths/~1reservestate/get) | ❌❌✅ |
163
+ | `getStatus` | `GET /status` [🔗](https://docs.ethswarm.org/api/#tag/Node-Status/paths/~1status/get) | ✅✅✅ |
164
+ | `getWallet` | `GET /wallet` [🔗](https://docs.ethswarm.org/api/#tag/Wallet/paths/~1wallet/get) | ❌✅✅ |
165
+ | `getTopology` | `GET /topology` [🔗](https://docs.ethswarm.org/api/#tag/Connectivity/paths/~1topology/get) | ✅✅✅ |
166
+ | `getAddresses` | `GET /addresses` [🔗](https://docs.ethswarm.org/api/#tag/Connectivity/paths/~1addresses/get) | ✅✅✅ |
167
+ | `getPeers` | `GET /peers` [🔗](https://docs.ethswarm.org/api/#tag/Connectivity/paths/~1peers/get) | ✅✅✅ |
168
+ | `getAllBalances` | `GET /balances` [🔗](https://docs.ethswarm.org/api/#tag/Balance/paths/~1balances/get) | ❌✅✅ |
169
+ | `getPeerBalance` | `GET /balances/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Balance/paths/~1balances~1%7Baddress%7D/get) | ❌✅✅ |
170
+ | `getPastDueConsumptionBalances` | `GET /consumed` [🔗](https://docs.ethswarm.org/api/#tag/Balance/paths/~1consumed/get) | ❌✅✅ |
171
+ | `getPastDueConsumptionPeerBalance` | `GET /consumed/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Balance/paths/~1consumed~1%7Baddress%7D/get) | ❌✅✅ |
172
+ | `getAllSettlements` | `GET /settlements` [🔗](https://docs.ethswarm.org/api/#tag/Settlements/paths/~1settlements/get) | ❌✅✅ |
173
+ | `getSettlements` | `GET /settlements/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Settlements/paths/~1settlements~1%7Baddress%7D/get) | ❌✅✅ |
174
+ | `getChequebookAddress` | `GET /chequebook/address` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1address/get) | ❌✅✅ |
175
+ | `getChequebookBalance` | `GET /chequebook/balance` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1balance/get) | ❌✅✅ |
176
+ | `getLastCheques` | `GET /chequebook/cheque` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cheque/get) | ❌✅✅ |
177
+ | `getLastChequesForPeer` | `GET /chequebook/cheque/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cheque~1%7Bpeer-id%7D/get) | ❌✅✅ |
178
+ | `getLastCashoutAction` | `GET /chequebook/cashout/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cashout~1%7Bpeer-id%7D/get) | ❌✅✅ |
179
+ | `cashoutLastCheque` | `POST /chequebook/cashout/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cashout~1%7Bpeer-id%7D/post) | ❌✅✅ |
180
+ | `depositTokens` | `POST /chequebook/deposit` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1deposit/post) | ❌✅✅ |
181
+ | `withdrawTokens` | `POST /chequebook/withdraw` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1withdraw/post) | ❌✅✅ |
182
+ | `getAllPendingTransactions` | `GET /transactions` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions/get) | ❌✅✅ |
183
+ | `getPendingTransaction` | `GET /transactions/:id` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions~1%7BtxHash%7D/get) | ❌✅✅ |
184
+ | `rebroadcastTransaction` | `POST /transactions/:id` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions~1%7BtxHash%7D/post) | ❌✅✅ |
185
+ | `cancelTransaction` | `DELETE /transactions/:id` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions~1%7BtxHash%7D/delete) | ❌✅✅ |
186
+ | `createTag` | `POST /tags` [🔗](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post) | ❌✅✅ |
187
+ | `retrieveTag` | `GET /tags/:id` [🔗](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1%7Buid%7D/get) | ❌✅✅ |
188
+ | `getAllTags` | `GET /tags` [🔗](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/get) | ❌✅✅ |
189
+ | `deleteTag` | `DELETE /tags/:id` [🔗](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1%7Buid%7D/delete) | ❌✅✅ |
190
+ | `updateTag` | `PATCH /tags/:id` [🔗](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1%7Buid%7D/patch) | ❌✅✅ |
191
+ | `pin` | `POST /pins/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Pinning/paths/~1pins~1%7Breference%7D/post) | ✅✅✅ |
192
+ | `getAllPins` | `GET /pins` [🔗](https://docs.ethswarm.org/api/#tag/Pinning/paths/~1pins/get) | ✅✅✅ |
193
+ | `getPin` | `GET /pins/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Pinning/paths/~1pins~1%7Breference%7D/get) | ✅✅✅ |
194
+ | `isReferenceRetrievable` | `GET /stewardship/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1%7Breference%7D/get) | ✅✅✅ |
195
+ | `reuploadPinnedData` | `PUT /stewardship/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1%7Breference%7D/put) | ❌✅✅ |
196
+ | `unpin` | `DELETE /pins/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Pinning/paths/~1pins~1%7Breference%7D/delete) | ✅✅✅ |
197
+ | `getGrantees` | `GET /grantee/:reference` [🔗](https://docs.ethswarm.org/api/#tag/ACT/paths/~1grantee~1%7Breference%7D/get) | ❌✅✅ |
198
+ | `createGrantees` | `POST /grantee` [🔗](https://docs.ethswarm.org/api/#tag/ACT/paths/~1grantee/post) | ❌✅✅ |
199
+ | `patchGrantees` | `PATCH /grantee/:reference` [🔗](https://docs.ethswarm.org/api/#tag/ACT/paths/~1grantee~1%7Breference%7D/patch) | ❌✅✅ |
200
+ | `pssSend` | `POST /pss/send/:topic/:target` [🔗](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1send~1%7Btopic%7D~1%7Btargets%7D/post) | ❌✅✅ |
201
+ | `pssSubscribe` _Websocket_ | `GET /pss/subscribe/:topic` [🔗](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1%7Btopic%7D/get) | ❌❌✅ |
202
+ | `pssReceive` | `GET /pss/subscribe/:topic` [🔗](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1%7Btopic%7D/get) | ❌❌✅ |
203
+ | `getAllPostageBatch` | `GET /stamps` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get) | ❌✅✅ |
204
+ | `getGlobalPostageBatches` | `GET /batches` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1batches/get) | ❌✅✅ |
205
+ | `getPostageBatch` | `GET /stamps/:batchId` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D/get) | ❌✅✅ |
206
+ | `getPostageBatchBuckets` | `GET /stamps/:batchId/buckets` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D~1buckets/get) | ❌✅✅ |
207
+ | `createPostageBatch` | `POST /stamps/:amount/:depth` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bamount%7D~1%7Bdepth%7D/post) | ❌✅✅ |
208
+ | `topUpBatch` | `PATCH /stamps/topup/:batchId/:amount` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1topup~1%7Bbatch_id%7D~1%7Bamount%7D/patch) | ❌✅✅ |
209
+ | `diluteBatch` | `PATCH /stamps/dilute/:batchId/:depth` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1dilute~1%7Bbatch_id%7D~1%7Bdepth%7D/patch) | ❌✅✅ |
210
+ | `createEnvelope` | `POST /envelope/:reference` [🔗](https://docs.ethswarm.org/api/#tag/Envelope/paths/~1envelope~1%7Baddress%7D/post) | ❌✅✅ |
211
+ | `getStake` | `GET /stake` [🔗](https://docs.ethswarm.org/api/#tag/Staking/paths/~1stake/get) | ❌❌✅ |
212
+ | `depositStake` | `POST /stake` [🔗](https://docs.ethswarm.org/api/#tag/Staking/paths/~1stake~1%7Bamount%7D/post) | ❌❌✅ |
213
+
214
+ ### Utils
215
+
216
+ #### General
217
+
218
+ - `getCollectionSize`
219
+ - `getFolderSize`
220
+
221
+ #### PSS
222
+
223
+ - `makeMaxTarget`
224
+
225
+ #### Erasure Coding
226
+
227
+ - `approximateOverheadForRedundancyLevel`
228
+ - `getRedundancyStat`
229
+ - `getRedundancyStats`
230
+
231
+ #### Stamps
232
+
233
+ - `getAmountForTtl`
234
+ - `getDepthForCapacity`
235
+ - `getStampCost`
236
+ - `getStampEffectiveBytes`
237
+ - `getStampMaximumCapacityBytes`
238
+ - `getStampTtlSeconds`
239
+ - `getStampUsage`
240
+
68
241
  ## Usage
69
242
 
70
243
  ### Upload via Swarm Gateway
@@ -77,7 +250,7 @@ main()
77
250
  async function main() {
78
251
  const bee = new Bee(SWARM_GATEWAY_URL)
79
252
  const { reference } = await bee.uploadData(NULL_STAMP, 'Hello, World!')
80
- console.log(reference)
253
+ console.log(reference.toHex())
81
254
  }
82
255
  ```
83
256
 
@@ -99,7 +272,7 @@ async function getOrCreatePostageBatch() {
99
272
  if (usable) {
100
273
  batchId = usable.batchID
101
274
  } else {
102
- batchId = await bee.createPostageBatch('500000000', 20)
275
+ batchId = await bee.buyStorage(Size.fromGigabytes(1), Duration.fromDays(7))
103
276
  }
104
277
  }
105
278
  ```
@@ -116,7 +289,7 @@ const bee = new Bee('http://localhost:1633')
116
289
  const uploadResult = await bee.uploadData(batchId, 'Bee is awesome!')
117
290
  const data = await bee.downloadData(uploadResult.reference)
118
291
 
119
- console.log(data.text()) // prints 'Bee is awesome!'
292
+ console.log(data.toUtf8()) // prints 'Bee is awesome!'
120
293
  ```
121
294
 
122
295
  ### Upload data from a file input (React)
@@ -170,13 +343,6 @@ const bee = new Bee('http://localhost:1633', {
170
343
  })
171
344
  ```
172
345
 
173
- [**Check out our examples repo for some more ideas on how to use `bee-js`**](https://github.com/ethersphere/examples-js)
174
-
175
- ## Documentation
176
-
177
- You can find the full documentation [here](https://bee-js.ethswarm.org/docs). The API reference documentation can be
178
- found [here](https://bee-js.ethswarm.org/docs/api).
179
-
180
346
  ## Contribute
181
347
 
182
348
  Stay up to date by joining the [official Discord](https://discord.gg/GU22h2utj6) and by keeping an eye on the
@@ -191,48 +357,24 @@ There are some ways you can make this module better:
191
357
 
192
358
  ### Setup
193
359
 
194
- Install project dependencies with
360
+ Install project dependencies:
195
361
 
196
362
  ```sh
197
- npm i
363
+ npm install
198
364
  ```
199
365
 
200
- ### Test
201
-
202
- The tests run in both context: node and dom with Jest.
203
-
204
- To run the integration tests, you need to spin up local Bee cluster using our
205
- [`fdp-play`](https://github.com/fairDataSociety/fdp-play/) project. In order to do that you have to have locally Docker
206
- running on your machine, but afterwards you can just simply run `npm run bee`, which spins up the cluster and display
207
- Queen's logs. If you want to exit hit `CTRL+C`.
208
-
209
- If you want to skip creation of postage stamps every run of integration tests you can create stamps for both nodes and
210
- set them under env. variables `BEE_POSTAGE` and `BEE_PEER_POSTAGE`.
211
-
212
- By default, for integration tests two bee nodes are expected to run on localhost on addresses `http://localhost:1633`
213
- and `http://localhost:11633`. These are the default values for the `fdp-play` script. If you want to use custom setup,
214
- you can change the behavior of tests to different addresses using environment variables `BEE_API_URL` and
215
- `BEE_PEER_API_URL`.
216
-
217
- There are also browser tests by Puppeteer, which also provide integrity testing.
366
+ Build the project:
218
367
 
219
368
  ```sh
220
- npm run test:browser
369
+ npm run build
221
370
  ```
222
371
 
223
- The test HTML file which Puppeteer uses is the [test/testpage/testpage.html](test/testpage/testpage.html). To open and
224
- manually test BeeJS with developer console, it is necessary to build the library first with `npm run compile:browser`
225
- (running the browser tests `npm run test:browser` also builds the library).
372
+ After making changes, link the package to your project by running `npm link` in the Bee-JS project root, and
373
+ `npm link @ethersphere/bee-js` in your project root.
226
374
 
227
- ### Compile code
228
-
229
- In order to compile NodeJS code run
230
-
231
- `npm run compile:node`
232
-
233
- or for Browsers
375
+ ### Test
234
376
 
235
- `npm run compile:browser`
377
+ Tests are currently run against a mainnet Bee nodes. This is temporary and this section will be revised in the future.
236
378
 
237
379
  ## License
238
380
 
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BeeDev = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
5
+ const _1 = require(".");
6
+ const connectivity_1 = require("./modules/debug/connectivity");
7
+ const http_1 = require("./utils/http");
8
+ class BeeDev extends _1.Bee {
9
+ async getNodeAddresses(options) {
10
+ const requestOptions = super.getRequestOptionsForCall(options);
11
+ const response = await (0, http_1.http)(requestOptions, {
12
+ url: 'addresses',
13
+ responseType: 'json',
14
+ });
15
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
16
+ return {
17
+ overlay: new _1.PeerAddress(cafe_utility_1.Types.asString(body.overlay, { name: 'overlay' })),
18
+ underlay: [],
19
+ ethereum: new _1.EthAddress(cafe_utility_1.Types.asString(body.ethereum, { name: 'ethereum' })),
20
+ publicKey: new _1.PublicKey(cafe_utility_1.Types.asString(body.publicKey, { name: 'publicKey' })),
21
+ pssPublicKey: new _1.PublicKey(cafe_utility_1.Types.asString(body.pssPublicKey, { name: 'pssPublicKey' })),
22
+ };
23
+ }
24
+ async getTopology(options) {
25
+ const requestOptions = super.getRequestOptionsForCall(options);
26
+ const response = await (0, http_1.http)(requestOptions, {
27
+ url: `topology`,
28
+ responseType: 'json',
29
+ });
30
+ const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
31
+ const bins = cafe_utility_1.Types.asObject(body.bins, { name: 'bins' });
32
+ return {
33
+ baseAddr: '0bab5ca208a980950604f900f2791613fc980676c2dee7dd92a4fdda5a54bf26',
34
+ population: cafe_utility_1.Types.asNumber(body.population, { name: 'population' }),
35
+ connected: cafe_utility_1.Types.asNumber(body.connected, { name: 'connected' }),
36
+ timestamp: cafe_utility_1.Types.asString(body.timestamp, { name: 'timestamp' }),
37
+ nnLowWatermark: cafe_utility_1.Types.asNumber(body.nnLowWatermark, { name: 'nnLowWatermark' }),
38
+ depth: cafe_utility_1.Types.asNumber(body.depth, { name: 'depth' }),
39
+ reachability: 'Public',
40
+ networkAvailability: 'Available',
41
+ bins: {
42
+ bin_0: (0, connectivity_1.asBin)(bins.bin_0, 'bin_0'),
43
+ bin_1: (0, connectivity_1.asBin)(bins.bin_1, 'bin_1'),
44
+ bin_2: (0, connectivity_1.asBin)(bins.bin_2, 'bin_2'),
45
+ bin_3: (0, connectivity_1.asBin)(bins.bin_3, 'bin_3'),
46
+ bin_4: (0, connectivity_1.asBin)(bins.bin_4, 'bin_4'),
47
+ bin_5: (0, connectivity_1.asBin)(bins.bin_5, 'bin_5'),
48
+ bin_6: (0, connectivity_1.asBin)(bins.bin_6, 'bin_6'),
49
+ bin_7: (0, connectivity_1.asBin)(bins.bin_7, 'bin_7'),
50
+ bin_8: (0, connectivity_1.asBin)(bins.bin_8, 'bin_8'),
51
+ bin_9: (0, connectivity_1.asBin)(bins.bin_9, 'bin_9'),
52
+ bin_10: (0, connectivity_1.asBin)(bins.bin_10, 'bin_10'),
53
+ bin_11: (0, connectivity_1.asBin)(bins.bin_11, 'bin_11'),
54
+ bin_12: (0, connectivity_1.asBin)(bins.bin_12, 'bin_12'),
55
+ bin_13: (0, connectivity_1.asBin)(bins.bin_13, 'bin_13'),
56
+ bin_14: (0, connectivity_1.asBin)(bins.bin_14, 'bin_14'),
57
+ bin_15: (0, connectivity_1.asBin)(bins.bin_15, 'bin_15'),
58
+ bin_16: (0, connectivity_1.asBin)(bins.bin_16, 'bin_16'),
59
+ bin_17: (0, connectivity_1.asBin)(bins.bin_17, 'bin_17'),
60
+ bin_18: (0, connectivity_1.asBin)(bins.bin_18, 'bin_18'),
61
+ bin_19: (0, connectivity_1.asBin)(bins.bin_19, 'bin_19'),
62
+ bin_20: (0, connectivity_1.asBin)(bins.bin_20, 'bin_20'),
63
+ bin_21: (0, connectivity_1.asBin)(bins.bin_21, 'bin_21'),
64
+ bin_22: (0, connectivity_1.asBin)(bins.bin_22, 'bin_22'),
65
+ bin_23: (0, connectivity_1.asBin)(bins.bin_23, 'bin_23'),
66
+ bin_24: (0, connectivity_1.asBin)(bins.bin_24, 'bin_24'),
67
+ bin_25: (0, connectivity_1.asBin)(bins.bin_25, 'bin_25'),
68
+ bin_26: (0, connectivity_1.asBin)(bins.bin_26, 'bin_26'),
69
+ bin_27: (0, connectivity_1.asBin)(bins.bin_27, 'bin_27'),
70
+ bin_28: (0, connectivity_1.asBin)(bins.bin_28, 'bin_28'),
71
+ bin_29: (0, connectivity_1.asBin)(bins.bin_29, 'bin_29'),
72
+ bin_30: (0, connectivity_1.asBin)(bins.bin_30, 'bin_30'),
73
+ bin_31: (0, connectivity_1.asBin)(bins.bin_31, 'bin_31'),
74
+ },
75
+ };
76
+ }
77
+ }
78
+ exports.BeeDev = BeeDev;