@ethersphere/bee-js 12.3.2-upcoming.116 → 13.0.0-upcoming.gc013bdf

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 (268) hide show
  1. package/dist/cjs/api/balance.js +24 -0
  2. package/dist/cjs/api/batches.js +26 -0
  3. package/dist/cjs/{modules → api}/bytes.js +4 -29
  4. package/dist/cjs/{modules → api}/bzz.js +6 -34
  5. package/dist/cjs/{modules/debug → api}/chequebook.js +48 -87
  6. package/dist/cjs/api/chunk.js +43 -0
  7. package/dist/cjs/api/connectivity.js +86 -0
  8. package/dist/cjs/api/consumed.js +24 -0
  9. package/dist/cjs/{modules → api}/envelope.js +3 -2
  10. package/dist/cjs/api/feed.js +55 -0
  11. package/dist/cjs/api/grantee.js +62 -0
  12. package/dist/cjs/{modules/pinning.js → api/pin.js} +13 -34
  13. package/dist/cjs/api/pss.js +19 -0
  14. package/dist/cjs/api/redistributionstate.js +17 -0
  15. package/dist/cjs/{modules/debug/settlements.js → api/settlement.js} +3 -11
  16. package/dist/cjs/api/soc.js +34 -0
  17. package/dist/cjs/{modules/debug → api}/stake.js +15 -43
  18. package/dist/cjs/{modules/debug/stamps.js → api/stamp.js} +41 -57
  19. package/dist/cjs/api/status.js +67 -0
  20. package/dist/cjs/{modules → api}/stewardship.js +1 -6
  21. package/dist/cjs/api/tag.js +51 -0
  22. package/dist/cjs/{modules/debug/transactions.js → api/transaction.js} +10 -31
  23. package/dist/cjs/{modules/debug/states.js → api/wallet.js} +4 -36
  24. package/dist/cjs/bee.js +115 -1978
  25. package/dist/cjs/chunk/soc.js +23 -65
  26. package/dist/cjs/feed/identifier.js +3 -4
  27. package/dist/cjs/feed/index.js +20 -22
  28. package/dist/cjs/feed/retrievable.js +3 -3
  29. package/dist/cjs/index.js +18 -8
  30. package/dist/cjs/manifest/manifest.js +99 -335
  31. package/dist/cjs/modules/balance.js +86 -0
  32. package/dist/cjs/modules/cheque.js +92 -0
  33. package/dist/cjs/modules/chequebook.js +90 -0
  34. package/dist/cjs/modules/chunk.js +87 -53
  35. package/dist/cjs/modules/collection.js +145 -0
  36. package/dist/cjs/modules/connectivity.js +141 -0
  37. package/dist/cjs/modules/context.js +2 -0
  38. package/dist/cjs/modules/data.js +119 -0
  39. package/dist/cjs/modules/feed.js +94 -70
  40. package/dist/cjs/modules/file.js +113 -0
  41. package/dist/cjs/modules/grantee.js +86 -55
  42. package/dist/cjs/modules/messaging.js +248 -0
  43. package/dist/cjs/modules/pin.js +100 -0
  44. package/dist/cjs/modules/settlement.js +67 -0
  45. package/dist/cjs/modules/soc.js +39 -36
  46. package/dist/cjs/modules/stake.js +110 -0
  47. package/dist/cjs/modules/stamp.js +199 -0
  48. package/dist/cjs/modules/status.js +128 -20
  49. package/dist/cjs/modules/storage.js +191 -0
  50. package/dist/cjs/modules/tag.js +97 -71
  51. package/dist/cjs/modules/transaction.js +92 -0
  52. package/dist/cjs/modules/wallet.js +82 -0
  53. package/dist/cjs/types/schema/chequebook.js +5 -5
  54. package/dist/cjs/types/schema/connectivity.js +5 -5
  55. package/dist/cjs/types/schema/envelope.js +5 -5
  56. package/dist/cjs/types/schema/grantee.js +4 -4
  57. package/dist/cjs/types/schema/stake.js +2 -2
  58. package/dist/cjs/types/schema/stamps.js +4 -4
  59. package/dist/cjs/types/schema/states.js +2 -2
  60. package/dist/cjs/types/schema/transactions.js +3 -3
  61. package/dist/cjs/types/schema/upload.js +2 -2
  62. package/dist/cjs/utils/chunk-stream.browser.js +24 -16
  63. package/dist/cjs/utils/chunk-stream.js +17 -9
  64. package/dist/cjs/utils/constants.js +3 -3
  65. package/dist/cjs/utils/expose.js +4 -4
  66. package/dist/cjs/utils/headers.js +4 -4
  67. package/dist/cjs/utils/pss.js +2 -2
  68. package/dist/cjs/utils/resource-locator.js +2 -2
  69. package/dist/cjs/utils/schema.js +4 -4
  70. package/dist/cjs/utils/stamps.js +15 -130
  71. package/dist/index.browser.min.js +2 -1
  72. package/dist/index.browser.min.js.LICENSE.txt +3 -0
  73. package/dist/index.browser.min.js.map +1 -1
  74. package/dist/mjs/api/balance.js +20 -0
  75. package/dist/mjs/api/batches.js +22 -0
  76. package/dist/mjs/{modules → api}/bytes.js +2 -27
  77. package/dist/mjs/{modules → api}/bzz.js +2 -30
  78. package/dist/mjs/{modules/debug → api}/chequebook.js +50 -89
  79. package/dist/mjs/api/chunk.js +37 -0
  80. package/dist/mjs/api/connectivity.js +76 -0
  81. package/dist/mjs/api/consumed.js +20 -0
  82. package/dist/mjs/{modules → api}/envelope.js +3 -2
  83. package/dist/mjs/api/feed.js +52 -0
  84. package/dist/mjs/api/grantee.js +59 -0
  85. package/dist/mjs/{modules/pinning.js → api/pin.js} +14 -35
  86. package/dist/mjs/api/pss.js +18 -0
  87. package/dist/mjs/api/redistributionstate.js +14 -0
  88. package/dist/mjs/{modules/debug/settlements.js → api/settlement.js} +3 -11
  89. package/dist/mjs/api/soc.js +31 -0
  90. package/dist/mjs/{modules/debug → api}/stake.js +14 -41
  91. package/dist/mjs/{modules/debug/stamps.js → api/stamp.js} +37 -51
  92. package/dist/mjs/api/status.js +59 -0
  93. package/dist/mjs/{modules → api}/stewardship.js +1 -6
  94. package/dist/mjs/api/tag.js +49 -0
  95. package/dist/mjs/api/transaction.js +41 -0
  96. package/dist/mjs/api/wallet.js +38 -0
  97. package/dist/mjs/bee.js +115 -1965
  98. package/dist/mjs/chunk/soc.js +13 -51
  99. package/dist/mjs/feed/identifier.js +2 -3
  100. package/dist/mjs/feed/index.js +9 -11
  101. package/dist/mjs/feed/retrievable.js +2 -2
  102. package/dist/mjs/index.js +2 -5
  103. package/dist/mjs/manifest/manifest.js +97 -341
  104. package/dist/mjs/modules/balance.js +49 -0
  105. package/dist/mjs/modules/cheque.js +55 -0
  106. package/dist/mjs/modules/chequebook.js +65 -0
  107. package/dist/mjs/modules/chunk.js +52 -49
  108. package/dist/mjs/modules/collection.js +108 -0
  109. package/dist/mjs/modules/connectivity.js +102 -0
  110. package/dist/mjs/modules/context.js +1 -0
  111. package/dist/mjs/modules/data.js +82 -0
  112. package/dist/mjs/modules/feed.js +89 -67
  113. package/dist/mjs/modules/file.js +78 -0
  114. package/dist/mjs/modules/grantee.js +52 -55
  115. package/dist/mjs/modules/messaging.js +213 -0
  116. package/dist/mjs/modules/pin.js +63 -0
  117. package/dist/mjs/modules/settlement.js +30 -0
  118. package/dist/mjs/modules/soc.js +36 -34
  119. package/dist/mjs/modules/stake.js +76 -0
  120. package/dist/mjs/modules/stamp.js +170 -0
  121. package/dist/mjs/modules/status.js +98 -18
  122. package/dist/mjs/modules/storage.js +185 -0
  123. package/dist/mjs/modules/tag.js +61 -68
  124. package/dist/mjs/modules/transaction.js +58 -0
  125. package/dist/mjs/modules/wallet.js +45 -0
  126. package/dist/mjs/types/schema/chequebook.js +1 -1
  127. package/dist/mjs/types/schema/connectivity.js +1 -1
  128. package/dist/mjs/types/schema/envelope.js +5 -5
  129. package/dist/mjs/types/schema/grantee.js +1 -1
  130. package/dist/mjs/types/schema/stake.js +1 -1
  131. package/dist/mjs/types/schema/stamps.js +1 -1
  132. package/dist/mjs/types/schema/states.js +1 -1
  133. package/dist/mjs/types/schema/transactions.js +1 -1
  134. package/dist/mjs/types/schema/upload.js +1 -1
  135. package/dist/mjs/utils/chunk-stream.browser.js +28 -18
  136. package/dist/mjs/utils/chunk-stream.js +21 -11
  137. package/dist/mjs/utils/constants.js +1 -1
  138. package/dist/mjs/utils/expose.js +1 -1
  139. package/dist/mjs/utils/headers.js +1 -1
  140. package/dist/mjs/utils/pss.js +1 -1
  141. package/dist/mjs/utils/resource-locator.js +1 -1
  142. package/dist/mjs/utils/schema.js +1 -1
  143. package/dist/mjs/utils/stamps.js +5 -99
  144. package/dist/types/api/balance.d.ts +7 -0
  145. package/dist/types/api/batches.d.ts +7 -0
  146. package/dist/types/api/bytes.d.ts +11 -0
  147. package/dist/types/api/bzz.d.ts +12 -0
  148. package/dist/types/api/chequebook.d.ts +21 -0
  149. package/dist/types/api/chunk.d.ts +7 -0
  150. package/dist/types/api/connectivity.d.ts +22 -0
  151. package/dist/types/api/consumed.d.ts +7 -0
  152. package/dist/types/{modules → api}/envelope.d.ts +1 -1
  153. package/dist/types/api/feed.d.ts +40 -0
  154. package/dist/types/api/grantee.d.ts +11 -0
  155. package/dist/types/api/pin.d.ts +10 -0
  156. package/dist/types/api/pss.d.ts +6 -0
  157. package/dist/types/api/redistributionstate.d.ts +5 -0
  158. package/dist/types/api/settlement.d.ts +7 -0
  159. package/dist/types/api/soc.d.ts +6 -0
  160. package/dist/types/api/stake.d.ts +11 -0
  161. package/dist/types/api/stamp.d.ts +12 -0
  162. package/dist/types/api/status.d.ts +11 -0
  163. package/dist/types/api/stewardship.d.ts +7 -0
  164. package/dist/types/api/tag.d.ts +12 -0
  165. package/dist/types/api/transaction.d.ts +9 -0
  166. package/dist/types/api/wallet.d.ts +9 -0
  167. package/dist/types/bee.d.ts +71 -1199
  168. package/dist/types/chunk/soc.d.ts +3 -48
  169. package/dist/types/feed/identifier.d.ts +1 -1
  170. package/dist/types/feed/index.d.ts +2 -4
  171. package/dist/types/feed/retrievable.d.ts +1 -1
  172. package/dist/types/index.d.ts +17 -20
  173. package/dist/types/manifest/manifest.d.ts +25 -34
  174. package/dist/types/modules/balance.d.ts +38 -0
  175. package/dist/types/modules/cheque.d.ts +40 -0
  176. package/dist/types/modules/chequebook.d.ts +41 -0
  177. package/dist/types/modules/chunk.d.ts +30 -20
  178. package/dist/types/modules/collection.d.ts +77 -0
  179. package/dist/types/modules/connectivity.d.ts +74 -0
  180. package/dist/types/modules/context.d.ts +24 -0
  181. package/dist/types/modules/data.d.ts +55 -0
  182. package/dist/types/modules/feed.d.ts +47 -49
  183. package/dist/types/modules/file.d.ts +43 -0
  184. package/dist/types/modules/grantee.d.ts +40 -8
  185. package/dist/types/modules/messaging.d.ts +79 -0
  186. package/dist/types/modules/pin.d.ts +47 -0
  187. package/dist/types/modules/settlement.d.ts +25 -0
  188. package/dist/types/modules/soc.d.ts +23 -11
  189. package/dist/types/modules/stake.d.ts +55 -0
  190. package/dist/types/modules/stamp.d.ts +96 -0
  191. package/dist/types/modules/status.d.ts +66 -5
  192. package/dist/types/modules/storage.d.ts +107 -0
  193. package/dist/types/modules/tag.d.ts +44 -33
  194. package/dist/types/modules/transaction.d.ts +42 -0
  195. package/dist/types/modules/wallet.d.ts +35 -0
  196. package/dist/types/types/debug.d.ts +1 -1
  197. package/dist/types/types/index.d.ts +3 -12
  198. package/dist/types/types/schema/chequebook.d.ts +1 -1
  199. package/dist/types/types/schema/connectivity.d.ts +1 -1
  200. package/dist/types/types/schema/grantee.d.ts +1 -1
  201. package/dist/types/types/schema/stake.d.ts +1 -1
  202. package/dist/types/types/schema/stamps.d.ts +1 -1
  203. package/dist/types/types/schema/states.d.ts +1 -1
  204. package/dist/types/types/schema/transactions.d.ts +1 -1
  205. package/dist/types/types/schema/upload.d.ts +1 -1
  206. package/dist/types/utils/chunk-stream.browser.d.ts +1 -1
  207. package/dist/types/utils/chunk-stream.d.ts +2 -2
  208. package/dist/types/utils/constants.d.ts +1 -1
  209. package/dist/types/utils/expose.d.ts +1 -1
  210. package/dist/types/utils/headers.d.ts +1 -1
  211. package/dist/types/utils/pss.d.ts +1 -1
  212. package/dist/types/utils/resource-locator.d.ts +1 -1
  213. package/dist/types/utils/schema.d.ts +1 -1
  214. package/dist/types/utils/stamps.d.ts +2 -27
  215. package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
  216. package/dist/types/utils/tar-uploader.d.ts +1 -1
  217. package/package.json +4 -2
  218. package/dist/cjs/chunk/bmt.js +0 -37
  219. package/dist/cjs/chunk/cac.js +0 -43
  220. package/dist/cjs/modules/debug/balance.js +0 -60
  221. package/dist/cjs/modules/debug/connectivity.js +0 -54
  222. package/dist/cjs/modules/debug/status.js +0 -104
  223. package/dist/cjs/modules/gsoc.js +0 -23
  224. package/dist/cjs/modules/pss.js +0 -48
  225. package/dist/cjs/stamper/stamper.js +0 -44
  226. package/dist/cjs/utils/bytes.js +0 -116
  227. package/dist/cjs/utils/cid.js +0 -37
  228. package/dist/cjs/utils/redundancy.js +0 -133
  229. package/dist/cjs/utils/typed-bytes.js +0 -186
  230. package/dist/mjs/chunk/bmt.js +0 -34
  231. package/dist/mjs/chunk/cac.js +0 -34
  232. package/dist/mjs/modules/debug/balance.js +0 -54
  233. package/dist/mjs/modules/debug/connectivity.js +0 -46
  234. package/dist/mjs/modules/debug/states.js +0 -68
  235. package/dist/mjs/modules/debug/status.js +0 -99
  236. package/dist/mjs/modules/debug/transactions.js +0 -62
  237. package/dist/mjs/modules/gsoc.js +0 -16
  238. package/dist/mjs/modules/pss.js +0 -43
  239. package/dist/mjs/stamper/stamper.js +0 -40
  240. package/dist/mjs/utils/bytes.js +0 -102
  241. package/dist/mjs/utils/cid.js +0 -32
  242. package/dist/mjs/utils/redundancy.js +0 -98
  243. package/dist/mjs/utils/typed-bytes.js +0 -167
  244. package/dist/types/chunk/bmt.d.ts +0 -16
  245. package/dist/types/chunk/cac.d.ts +0 -40
  246. package/dist/types/modules/bytes.d.ts +0 -35
  247. package/dist/types/modules/bzz.d.ts +0 -40
  248. package/dist/types/modules/debug/balance.d.ts +0 -28
  249. package/dist/types/modules/debug/chequebook.d.ts +0 -60
  250. package/dist/types/modules/debug/connectivity.d.ts +0 -9
  251. package/dist/types/modules/debug/settlements.d.ts +0 -15
  252. package/dist/types/modules/debug/stake.d.ts +0 -30
  253. package/dist/types/modules/debug/stamps.d.ts +0 -11
  254. package/dist/types/modules/debug/states.d.ts +0 -23
  255. package/dist/types/modules/debug/status.d.ts +0 -46
  256. package/dist/types/modules/debug/transactions.d.ts +0 -30
  257. package/dist/types/modules/gsoc.d.ts +0 -6
  258. package/dist/types/modules/pinning.d.ts +0 -30
  259. package/dist/types/modules/pss.d.ts +0 -22
  260. package/dist/types/modules/stewardship.d.ts +0 -10
  261. package/dist/types/stamper/stamper.d.ts +0 -15
  262. package/dist/types/utils/bytes.d.ts +0 -19
  263. package/dist/types/utils/cid.d.ts +0 -10
  264. package/dist/types/utils/redundancy.d.ts +0 -21
  265. package/dist/types/utils/typed-bytes.d.ts +0 -69
  266. /package/dist/cjs/{modules → api}/rchash.js +0 -0
  267. /package/dist/mjs/{modules → api}/rchash.js +0 -0
  268. /package/dist/types/{modules → api}/rchash.d.ts +0 -0
@@ -33,33 +33,18 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.makeSOCAddress = void 0;
36
37
  exports.unmarshalSingleOwnerChunk = unmarshalSingleOwnerChunk;
37
- exports.makeSOCAddress = makeSOCAddress;
38
38
  exports.makeSingleOwnerChunk = makeSingleOwnerChunk;
39
39
  exports.uploadSingleOwnerChunk = uploadSingleOwnerChunk;
40
40
  exports.uploadSingleOwnerChunkData = uploadSingleOwnerChunkData;
41
41
  exports.uploadSingleOwnerChunkWithWrappedChunk = uploadSingleOwnerChunkWithWrappedChunk;
42
42
  exports.downloadSingleOwnerChunk = downloadSingleOwnerChunk;
43
- const cafe_utility_1 = require("cafe-utility");
44
- const chunkAPI = __importStar(require("../modules/chunk"));
45
- const socAPI = __importStar(require("../modules/soc"));
46
- const bytes_1 = require("../utils/bytes");
43
+ const swarm_core_1 = require("swarm-core");
44
+ Object.defineProperty(exports, "makeSOCAddress", { enumerable: true, get: function () { return swarm_core_1.makeSOCAddress; } });
45
+ const chunkAPI = __importStar(require("../api/chunk"));
46
+ const socAPI = __importStar(require("../api/soc"));
47
47
  const error_1 = require("../utils/error");
48
- const typed_bytes_1 = require("../utils/typed-bytes");
49
- const bmt_1 = require("./bmt");
50
- const cac_1 = require("./cac");
51
- const SOC_SIGNATURE_OFFSET = typed_bytes_1.Identifier.LENGTH;
52
- const SOC_SPAN_OFFSET = typed_bytes_1.Identifier.LENGTH + typed_bytes_1.Signature.LENGTH;
53
- const SOC_PAYLOAD_OFFSET = typed_bytes_1.Identifier.LENGTH + typed_bytes_1.Signature.LENGTH + typed_bytes_1.Span.LENGTH;
54
- function recoverChunkOwner(data) {
55
- const cacData = data.slice(SOC_SPAN_OFFSET);
56
- const chunkAddress = (0, bmt_1.calculateChunkAddress)(cacData);
57
- const signature = typed_bytes_1.Signature.fromSlice(data, SOC_SIGNATURE_OFFSET);
58
- const identifier = bytes_1.Bytes.fromSlice(data, 0, typed_bytes_1.Identifier.LENGTH);
59
- const digest = cafe_utility_1.Binary.concatBytes(identifier.toUint8Array(), chunkAddress.toUint8Array());
60
- const ownerAddress = signature.recoverPublicKey(digest).address();
61
- return ownerAddress;
62
- }
63
48
  /**
64
49
  * Unmarshals arbitrary data into a Single Owner Chunk.
65
50
  * Throws an error if the data is not a valid SOC.
@@ -70,29 +55,12 @@ function recoverChunkOwner(data) {
70
55
  * @returns a single owner chunk or throws error
71
56
  */
72
57
  function unmarshalSingleOwnerChunk(data, address) {
73
- data = data instanceof bytes_1.Bytes ? data.toUint8Array() : data;
74
- address = new typed_bytes_1.Reference(address);
75
- const ownerAddress = recoverChunkOwner(data);
76
- const identifier = bytes_1.Bytes.fromSlice(data, 0, typed_bytes_1.Identifier.LENGTH);
77
- const socAddress = new typed_bytes_1.Reference(cafe_utility_1.Binary.keccak256(cafe_utility_1.Binary.concatBytes(identifier.toUint8Array(), ownerAddress.toUint8Array())));
78
- if (!cafe_utility_1.Binary.equals(address.toUint8Array(), socAddress.toUint8Array())) {
79
- throw new error_1.BeeError('SOC data does not match given address!');
58
+ try {
59
+ return (0, swarm_core_1.unmarshalSingleOwnerChunk)(data, address);
60
+ }
61
+ catch (e) {
62
+ throw new error_1.BeeError(e.message);
80
63
  }
81
- const signature = typed_bytes_1.Signature.fromSlice(data, SOC_SIGNATURE_OFFSET);
82
- const span = typed_bytes_1.Span.fromSlice(data, SOC_SPAN_OFFSET);
83
- const payload = bytes_1.Bytes.fromSlice(data, SOC_PAYLOAD_OFFSET);
84
- return {
85
- data,
86
- identifier,
87
- signature,
88
- span,
89
- payload,
90
- address: socAddress,
91
- owner: ownerAddress,
92
- };
93
- }
94
- function makeSOCAddress(identifier, address) {
95
- return new typed_bytes_1.Reference(cafe_utility_1.Binary.keccak256(cafe_utility_1.Binary.concatBytes(identifier.toUint8Array(), address.toUint8Array())));
96
64
  }
97
65
  /**
98
66
  * Creates a single owner chunk object
@@ -102,20 +70,10 @@ function makeSOCAddress(identifier, address) {
102
70
  * @param signer The signer interface for signing the chunk
103
71
  */
104
72
  function makeSingleOwnerChunk(address, span, payload, identifier, signer) {
105
- identifier = new typed_bytes_1.Identifier(identifier);
106
- signer = new typed_bytes_1.PrivateKey(signer);
107
- const socAddress = makeSOCAddress(identifier, signer.publicKey().address());
108
- const signature = signer.sign(cafe_utility_1.Binary.concatBytes(identifier.toUint8Array(), address.toUint8Array()));
109
- const data = cafe_utility_1.Binary.concatBytes(identifier.toUint8Array(), signature.toUint8Array(), span.toUint8Array(), payload.toUint8Array());
110
- return {
111
- data,
112
- identifier,
113
- signature,
114
- span,
115
- payload,
116
- address: socAddress,
117
- owner: signer.publicKey().address(),
118
- };
73
+ identifier = new swarm_core_1.Identifier(identifier);
74
+ signer = new swarm_core_1.PrivateKey(signer);
75
+ const wrappedChunk = { data: (0, swarm_core_1.concatBytes)(span.toUint8Array(), payload.toUint8Array()), span, payload, address };
76
+ return (0, swarm_core_1.makeSingleOwnerChunk)(wrappedChunk, identifier, signer.toBigInt());
119
77
  }
120
78
  /**
121
79
  * Helper function to upload a chunk.
@@ -128,7 +86,7 @@ function makeSingleOwnerChunk(address, span, payload, identifier, signer) {
128
86
  * @param options Upload options
129
87
  */
130
88
  async function uploadSingleOwnerChunk(requestOptions, chunk, stamp, options) {
131
- const data = cafe_utility_1.Binary.concatBytes(chunk.span.toUint8Array(), chunk.payload.toUint8Array());
89
+ const data = (0, swarm_core_1.concatBytes)(chunk.span.toUint8Array(), chunk.payload.toUint8Array());
132
90
  return socAPI.upload(requestOptions, chunk.owner, chunk.identifier, chunk.signature, data, stamp, options);
133
91
  }
134
92
  /**
@@ -142,15 +100,15 @@ async function uploadSingleOwnerChunk(requestOptions, chunk, stamp, options) {
142
100
  * @param options
143
101
  */
144
102
  async function uploadSingleOwnerChunkData(requestOptions, signer, stamp, identifier, data, options) {
145
- signer = new typed_bytes_1.PrivateKey(signer);
146
- identifier = new typed_bytes_1.Identifier(identifier);
147
- const cac = (0, cac_1.makeContentAddressedChunk)(data);
103
+ signer = new swarm_core_1.PrivateKey(signer);
104
+ identifier = new swarm_core_1.Identifier(identifier);
105
+ const cac = (0, swarm_core_1.makeContentAddressedChunk)(data);
148
106
  const soc = cac.toSingleOwnerChunk(identifier, signer);
149
107
  return uploadSingleOwnerChunk(requestOptions, soc, stamp, options);
150
108
  }
151
109
  async function uploadSingleOwnerChunkWithWrappedChunk(requestOptions, signer, stamp, identifier, wrappedChunk, options) {
152
- signer = new typed_bytes_1.PrivateKey(signer);
153
- identifier = new typed_bytes_1.Identifier(identifier);
110
+ signer = new swarm_core_1.PrivateKey(signer);
111
+ identifier = new swarm_core_1.Identifier(identifier);
154
112
  const soc = wrappedChunk.toSingleOwnerChunk(identifier, signer);
155
113
  return uploadSingleOwnerChunk(requestOptions, soc, stamp, options);
156
114
  }
@@ -162,9 +120,9 @@ async function uploadSingleOwnerChunkWithWrappedChunk(requestOptions, signer, st
162
120
  * @param identifier The identifier of the chunk
163
121
  */
164
122
  async function downloadSingleOwnerChunk(requestOptions, ownerAddress, identifier) {
165
- identifier = new typed_bytes_1.Identifier(identifier);
166
- ownerAddress = new typed_bytes_1.EthAddress(ownerAddress);
167
- const address = makeSOCAddress(identifier, ownerAddress);
123
+ identifier = new swarm_core_1.Identifier(identifier);
124
+ ownerAddress = new swarm_core_1.EthAddress(ownerAddress);
125
+ const address = (0, swarm_core_1.makeSOCAddress)(identifier, ownerAddress);
168
126
  const cac = await chunkAPI.download(requestOptions, address.toHex());
169
127
  return unmarshalSingleOwnerChunk(cac, address);
170
128
  }
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeFeedIdentifier = makeFeedIdentifier;
4
- const cafe_utility_1 = require("cafe-utility");
5
- const typed_bytes_1 = require("../utils/typed-bytes");
4
+ const swarm_core_1 = require("swarm-core");
6
5
  function makeFeedIdentifier(topic, index) {
7
- index = typeof index === 'number' ? typed_bytes_1.FeedIndex.fromBigInt(BigInt(index)) : index;
8
- return new typed_bytes_1.Identifier(cafe_utility_1.Binary.keccak256(cafe_utility_1.Binary.concatBytes(topic.toUint8Array(), index.toUint8Array())));
6
+ index = typeof index === 'number' ? swarm_core_1.FeedIndex.fromBigInt(BigInt(index)) : index;
7
+ return new swarm_core_1.Identifier((0, swarm_core_1.keccak256)((0, swarm_core_1.concatBytes)(topic.toUint8Array(), index.toUint8Array())));
9
8
  }
@@ -43,15 +43,13 @@ exports.makeFeedReader = makeFeedReader;
43
43
  exports.makeFeedWriter = makeFeedWriter;
44
44
  const cafe_utility_1 = require("cafe-utility");
45
45
  const zod_1 = require("zod");
46
- const cac_1 = require("../chunk/cac");
46
+ const swarm_core_1 = require("swarm-core");
47
47
  const soc_1 = require("../chunk/soc");
48
- const bytes = __importStar(require("../modules/bytes"));
49
- const chunkAPI = __importStar(require("../modules/chunk"));
50
- const feed_1 = require("../modules/feed");
51
- const bytes_1 = require("../utils/bytes");
48
+ const bytes = __importStar(require("../api/bytes"));
49
+ const chunkAPI = __importStar(require("../api/chunk"));
50
+ const feed_1 = require("../api/feed");
52
51
  const error_1 = require("../utils/error");
53
52
  const resource_locator_1 = require("../utils/resource-locator");
54
- const typed_bytes_1 = require("../utils/typed-bytes");
55
53
  const identifier_1 = require("./identifier");
56
54
  const TIMESTAMP_PAYLOAD_OFFSET = 0;
57
55
  const TIMESTAMP_PAYLOAD_SIZE = 8;
@@ -66,18 +64,18 @@ async function findNextIndex(requestOptions, owner, topic) {
66
64
  }
67
65
  catch (e) {
68
66
  if (e instanceof error_1.BeeResponseError) {
69
- return typed_bytes_1.FeedIndex.fromBigInt(0n);
67
+ return swarm_core_1.FeedIndex.fromBigInt(0n);
70
68
  }
71
69
  throw e;
72
70
  }
73
71
  }
74
72
  async function updateFeedWithReference(requestOptions, signer, topic, reference, postageBatchId, options) {
75
- reference = new typed_bytes_1.Reference(reference);
73
+ reference = new swarm_core_1.Reference(reference);
76
74
  const nextIndex = options?.index ?? (await findNextIndex(requestOptions, signer.publicKey().address(), topic));
77
75
  const identifier = (0, identifier_1.makeFeedIdentifier)(topic, nextIndex);
78
76
  const at = options?.at ?? Date.now() / 1000.0;
79
- const timestamp = cafe_utility_1.Binary.numberToUint64(BigInt(Math.floor(at)), 'BE');
80
- const payloadBytes = cafe_utility_1.Binary.concatBytes(timestamp, reference.toUint8Array());
77
+ const timestamp = (0, swarm_core_1.numberToUint64)(BigInt(Math.floor(at)), 'BE');
78
+ const payloadBytes = (0, swarm_core_1.concatBytes)(timestamp, reference.toUint8Array());
81
79
  return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
82
80
  }
83
81
  async function updateFeedWithPayload(requestOptions, signer, topic, data, postageBatchId, options) {
@@ -85,37 +83,37 @@ async function updateFeedWithPayload(requestOptions, signer, topic, data, postag
85
83
  const identifier = (0, identifier_1.makeFeedIdentifier)(topic, nextIndex);
86
84
  if (data.length > 4096) {
87
85
  const uploadResult = await bytes.upload(requestOptions, data, postageBatchId, options);
88
- const rootChunk = (0, cac_1.unmarshalContentAddressedChunk)(await chunkAPI.download(requestOptions, uploadResult.reference));
86
+ const rootChunk = (0, swarm_core_1.unmarshalContentAddressedChunk)(await chunkAPI.download(requestOptions, uploadResult.reference));
89
87
  return (0, soc_1.uploadSingleOwnerChunkWithWrappedChunk)(requestOptions, signer, postageBatchId, identifier, rootChunk, options);
90
88
  }
91
89
  const dataString = zod_1.z.string().safeParse(data);
92
- return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, dataString.success ? bytes_1.Bytes.fromUtf8(dataString.data).toUint8Array() : data, options);
90
+ return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, dataString.success ? swarm_core_1.Bytes.fromUtf8(dataString.data).toUint8Array() : data, options);
93
91
  }
94
92
  function getFeedUpdateChunkReference(owner, topic, index) {
95
93
  const identifier = (0, identifier_1.makeFeedIdentifier)(topic, index);
96
- return new typed_bytes_1.Reference(cafe_utility_1.Binary.keccak256(cafe_utility_1.Binary.concatBytes(identifier.toUint8Array(), owner.toUint8Array())));
94
+ return new swarm_core_1.Reference((0, swarm_core_1.keccak256)((0, swarm_core_1.concatBytes)(identifier.toUint8Array(), owner.toUint8Array())));
97
95
  }
98
96
  async function downloadFeedUpdate(requestOptions, owner, topic, index, hasTimestamp = false) {
99
- index = typeof index === 'number' ? typed_bytes_1.FeedIndex.fromBigInt(BigInt(index)) : index;
97
+ index = typeof index === 'number' ? swarm_core_1.FeedIndex.fromBigInt(BigInt(index)) : index;
100
98
  const address = getFeedUpdateChunkReference(owner, topic, index);
101
99
  const data = await chunkAPI.download(requestOptions, address.toHex());
102
100
  const soc = (0, soc_1.unmarshalSingleOwnerChunk)(data, address);
103
101
  let timestamp = cafe_utility_1.Optional.empty();
104
102
  if (hasTimestamp) {
105
- const timestampBytes = bytes_1.Bytes.fromSlice(soc.payload.toUint8Array(), TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
106
- timestamp = cafe_utility_1.Optional.of(Number(cafe_utility_1.Binary.uint64ToNumber(timestampBytes.toUint8Array(), 'BE')));
103
+ const timestampBytes = swarm_core_1.Bytes.fromSlice(soc.payload.toUint8Array(), TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
104
+ timestamp = cafe_utility_1.Optional.of(Number((0, swarm_core_1.uint64ToNumber)(timestampBytes.toUint8Array(), 'BE')));
107
105
  }
108
106
  return {
109
107
  timestamp,
110
- payload: new bytes_1.Bytes(soc.payload.offset(hasTimestamp ? REFERENCE_PAYLOAD_OFFSET : 0)),
108
+ payload: new swarm_core_1.Bytes(soc.payload.offset(hasTimestamp ? REFERENCE_PAYLOAD_OFFSET : 0)),
111
109
  };
112
110
  }
113
111
  async function downloadFeedUpdateAsCAC(requestOptions, owner, topic, index) {
114
- index = typeof index === 'number' ? typed_bytes_1.FeedIndex.fromBigInt(BigInt(index)) : index;
112
+ index = typeof index === 'number' ? swarm_core_1.FeedIndex.fromBigInt(BigInt(index)) : index;
115
113
  const address = getFeedUpdateChunkReference(owner, topic, index);
116
114
  const data = await chunkAPI.download(requestOptions, address);
117
115
  const soc = (0, soc_1.unmarshalSingleOwnerChunk)(data, address);
118
- return (0, cac_1.makeContentAddressedChunk)(soc.payload, soc.span);
116
+ return (0, swarm_core_1.makeContentAddressedChunk)(soc.payload, soc.span);
119
117
  }
120
118
  function makeFeedReader(requestOptions, topic, owner) {
121
119
  // TODO: remove after enough time has passed in deprecated version
@@ -124,7 +122,7 @@ function makeFeedReader(requestOptions, topic, owner) {
124
122
  return (0, feed_1.fetchLatestFeedUpdate)(requestOptions, owner, topic);
125
123
  }
126
124
  const update = await downloadFeedUpdate(requestOptions, owner, topic, options.index, options.hasTimestamp ?? true);
127
- const feedIndex = typeof options.index === 'number' ? typed_bytes_1.FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
125
+ const feedIndex = typeof options.index === 'number' ? swarm_core_1.FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
128
126
  return {
129
127
  payload: update.payload,
130
128
  feedIndex,
@@ -139,7 +137,7 @@ function makeFeedReader(requestOptions, topic, owner) {
139
137
  const payload = cac.span.toBigInt() <= 4096n
140
138
  ? cac.payload
141
139
  : await bytes.download(requestOptions, new resource_locator_1.ResourceLocator(cac.address));
142
- const feedIndex = typeof options.index === 'number' ? typed_bytes_1.FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
140
+ const feedIndex = typeof options.index === 'number' ? swarm_core_1.FeedIndex.fromBigInt(BigInt(options.index)) : options.index;
143
141
  return {
144
142
  payload,
145
143
  feedIndex,
@@ -153,7 +151,7 @@ function makeFeedReader(requestOptions, topic, owner) {
153
151
  }
154
152
  const payload = await download({ ...options, index: index });
155
153
  return {
156
- reference: new typed_bytes_1.Reference(payload.payload.toUint8Array()),
154
+ reference: new swarm_core_1.Reference(payload.payload.toUint8Array()),
157
155
  feedIndex: payload.feedIndex,
158
156
  feedIndexNext: payload.feedIndexNext ?? payload.feedIndex.next(),
159
157
  };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.areAllSequentialFeedsUpdateRetrievable = areAllSequentialFeedsUpdateRetrievable;
4
+ const swarm_core_1 = require("swarm-core");
4
5
  const cafe_utility_1 = require("cafe-utility");
5
- const typed_bytes_1 = require("../utils/typed-bytes");
6
6
  const index_1 = require("./index");
7
7
  /**
8
8
  * Function that checks if a chunk is retrievable by actually downloading it.
@@ -14,7 +14,7 @@ const index_1 = require("./index");
14
14
  */
15
15
  async function isChunkRetrievable(bee, reference, options, requestOptions) {
16
16
  try {
17
- await bee.downloadChunk(reference, options, requestOptions);
17
+ await bee.chunk.download(reference, options, requestOptions);
18
18
  return true;
19
19
  }
20
20
  catch (e) {
@@ -36,7 +36,7 @@ function getAllSequenceUpdateReferences(owner, topic, index) {
36
36
  const count = index.toBigInt();
37
37
  const updateReferences = [];
38
38
  for (let i = 0n; i <= count; i++) {
39
- updateReferences.push((0, index_1.getFeedUpdateChunkReference)(owner, topic, typed_bytes_1.FeedIndex.fromBigInt(i)));
39
+ updateReferences.push((0, index_1.getFeedUpdateChunkReference)(owner, topic, swarm_core_1.FeedIndex.fromBigInt(i)));
40
40
  }
41
41
  return updateReferences;
42
42
  }
package/dist/cjs/index.js CHANGED
@@ -36,21 +36,32 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Stamper = exports.Bee = exports.Size = exports.Utils = exports.Duration = exports.Bytes = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = exports.MantarayNode = exports.MerkleTree = void 0;
39
+ exports.Bee = exports.Size = exports.Utils = exports.Duration = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = exports.MantarayNode = exports.TransactionId = exports.Topic = exports.Stamper = exports.Span = exports.Signature = exports.Reference = exports.PublicKey = exports.PrivateKey = exports.PeerAddress = exports.Identifier = exports.FeedIndex = exports.EthAddress = exports.ChunkSplitter = exports.ChunkBuilder = exports.Bytes = exports.BatchId = void 0;
40
40
  const bee_1 = require("./bee");
41
41
  Object.defineProperty(exports, "Bee", { enumerable: true, get: function () { return bee_1.Bee; } });
42
- const stamper_1 = require("./stamper/stamper");
43
- Object.defineProperty(exports, "Stamper", { enumerable: true, get: function () { return stamper_1.Stamper; } });
44
- var cafe_utility_1 = require("cafe-utility");
45
- Object.defineProperty(exports, "MerkleTree", { enumerable: true, get: function () { return cafe_utility_1.MerkleTree; } });
42
+ var swarm_core_1 = require("swarm-core");
43
+ Object.defineProperty(exports, "BatchId", { enumerable: true, get: function () { return swarm_core_1.BatchId; } });
44
+ Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return swarm_core_1.Bytes; } });
45
+ Object.defineProperty(exports, "ChunkBuilder", { enumerable: true, get: function () { return swarm_core_1.ChunkBuilder; } });
46
+ Object.defineProperty(exports, "ChunkSplitter", { enumerable: true, get: function () { return swarm_core_1.ChunkSplitter; } });
47
+ Object.defineProperty(exports, "EthAddress", { enumerable: true, get: function () { return swarm_core_1.EthAddress; } });
48
+ Object.defineProperty(exports, "FeedIndex", { enumerable: true, get: function () { return swarm_core_1.FeedIndex; } });
49
+ Object.defineProperty(exports, "Identifier", { enumerable: true, get: function () { return swarm_core_1.Identifier; } });
50
+ Object.defineProperty(exports, "PeerAddress", { enumerable: true, get: function () { return swarm_core_1.PeerAddress; } });
51
+ Object.defineProperty(exports, "PrivateKey", { enumerable: true, get: function () { return swarm_core_1.PrivateKey; } });
52
+ Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return swarm_core_1.PublicKey; } });
53
+ Object.defineProperty(exports, "Reference", { enumerable: true, get: function () { return swarm_core_1.Reference; } });
54
+ Object.defineProperty(exports, "Signature", { enumerable: true, get: function () { return swarm_core_1.Signature; } });
55
+ Object.defineProperty(exports, "Span", { enumerable: true, get: function () { return swarm_core_1.Span; } });
56
+ Object.defineProperty(exports, "Stamper", { enumerable: true, get: function () { return swarm_core_1.Stamper; } });
57
+ Object.defineProperty(exports, "Topic", { enumerable: true, get: function () { return swarm_core_1.Topic; } });
58
+ Object.defineProperty(exports, "TransactionId", { enumerable: true, get: function () { return swarm_core_1.TransactionId; } });
46
59
  var manifest_1 = require("./manifest/manifest");
47
60
  Object.defineProperty(exports, "MantarayNode", { enumerable: true, get: function () { return manifest_1.MantarayNode; } });
48
61
  var version_1 = require("./version");
49
62
  Object.defineProperty(exports, "SUPPORTED_BEE_VERSION", { enumerable: true, get: function () { return version_1.SUPPORTED_BEE_VERSION; } });
50
63
  Object.defineProperty(exports, "SUPPORTED_BEE_VERSION_EXACT", { enumerable: true, get: function () { return version_1.SUPPORTED_BEE_VERSION_EXACT; } });
51
64
  __exportStar(require("./types"), exports);
52
- var bytes_1 = require("./utils/bytes");
53
- Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return bytes_1.Bytes; } });
54
65
  __exportStar(require("./utils/constants"), exports);
55
66
  var duration_1 = require("./utils/duration");
56
67
  Object.defineProperty(exports, "Duration", { enumerable: true, get: function () { return duration_1.Duration; } });
@@ -59,4 +70,3 @@ exports.Utils = __importStar(require("./utils/expose"));
59
70
  var size_1 = require("./utils/size");
60
71
  Object.defineProperty(exports, "Size", { enumerable: true, get: function () { return size_1.Size; } });
61
72
  __exportStar(require("./utils/tokens"), exports);
62
- __exportStar(require("./utils/typed-bytes"), exports);