@ethersphere/bee-js 6.9.0 → 7.0.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 (144) hide show
  1. package/README.md +107 -65
  2. package/dist/cjs/bee.js +533 -6
  3. package/dist/cjs/chunk/cac.js +3 -3
  4. package/dist/cjs/chunk/soc.js +5 -5
  5. package/dist/cjs/chunk/span.js +2 -6
  6. package/dist/cjs/feed/identifier.js +2 -2
  7. package/dist/cjs/feed/index.js +7 -8
  8. package/dist/cjs/feed/retrievable.js +2 -2
  9. package/dist/cjs/index.js +1 -3
  10. package/dist/cjs/modules/bytes.js +3 -3
  11. package/dist/cjs/modules/bzz.js +9 -20
  12. package/dist/cjs/modules/chunk.js +2 -2
  13. package/dist/cjs/modules/debug/balance.js +4 -4
  14. package/dist/cjs/modules/debug/chequebook.js +8 -8
  15. package/dist/cjs/modules/debug/chunk.js +2 -19
  16. package/dist/cjs/modules/debug/settlements.js +2 -2
  17. package/dist/cjs/modules/debug/stake.js +3 -3
  18. package/dist/cjs/modules/debug/states.js +4 -19
  19. package/dist/cjs/modules/debug/status.js +15 -32
  20. package/dist/cjs/modules/debug/tag.js +1 -1
  21. package/dist/cjs/modules/debug/transactions.js +4 -4
  22. package/dist/cjs/modules/feed.js +6 -7
  23. package/dist/cjs/modules/pinning.js +4 -4
  24. package/dist/cjs/modules/pss.js +1 -1
  25. package/dist/cjs/modules/soc.js +1 -1
  26. package/dist/cjs/modules/status.js +1 -1
  27. package/dist/cjs/modules/stewardship.js +1 -1
  28. package/dist/cjs/package.json +4 -0
  29. package/dist/cjs/types/index.js +5 -1
  30. package/dist/cjs/utils/collection.js +7 -22
  31. package/dist/cjs/utils/collection.node.js +2 -1
  32. package/dist/cjs/utils/data.browser.js +1 -49
  33. package/dist/cjs/utils/error.js +2 -6
  34. package/dist/cjs/utils/eth.js +1 -1
  35. package/dist/cjs/utils/expose.js +1 -8
  36. package/dist/cjs/utils/file.js +2 -2
  37. package/dist/cjs/utils/http.js +6 -25
  38. package/dist/cjs/utils/tar-uploader.browser.js +26 -0
  39. package/dist/cjs/utils/tar-uploader.js +27 -0
  40. package/dist/cjs/utils/tar-writer.browser.js +17 -0
  41. package/dist/cjs/utils/tar-writer.js +21 -0
  42. package/dist/cjs/utils/tar.browser.js +65 -0
  43. package/dist/cjs/utils/tar.js +47 -21
  44. package/dist/cjs/utils/type.js +7 -3
  45. package/dist/cjs/utils/url.js +1 -6
  46. package/dist/index.browser.min.js +1 -1
  47. package/dist/index.browser.min.js.LICENSE.txt +0 -42
  48. package/dist/index.browser.min.js.map +1 -1
  49. package/dist/mjs/bee.js +533 -9
  50. package/dist/mjs/chunk/cac.js +4 -4
  51. package/dist/mjs/chunk/soc.js +6 -6
  52. package/dist/mjs/chunk/span.js +2 -6
  53. package/dist/mjs/feed/identifier.js +2 -2
  54. package/dist/mjs/feed/index.js +7 -11
  55. package/dist/mjs/feed/retrievable.js +2 -2
  56. package/dist/mjs/index.js +1 -2
  57. package/dist/mjs/modules/bytes.js +3 -3
  58. package/dist/mjs/modules/bzz.js +8 -20
  59. package/dist/mjs/modules/chunk.js +2 -2
  60. package/dist/mjs/modules/debug/balance.js +4 -4
  61. package/dist/mjs/modules/debug/chequebook.js +8 -8
  62. package/dist/mjs/modules/debug/chunk.js +1 -17
  63. package/dist/mjs/modules/debug/settlements.js +2 -2
  64. package/dist/mjs/modules/debug/stake.js +3 -3
  65. package/dist/mjs/modules/debug/states.js +4 -19
  66. package/dist/mjs/modules/debug/status.js +15 -34
  67. package/dist/mjs/modules/debug/tag.js +1 -1
  68. package/dist/mjs/modules/debug/transactions.js +4 -4
  69. package/dist/mjs/modules/feed.js +6 -7
  70. package/dist/mjs/modules/pinning.js +4 -4
  71. package/dist/mjs/modules/pss.js +1 -1
  72. package/dist/mjs/modules/soc.js +1 -1
  73. package/dist/mjs/modules/status.js +1 -1
  74. package/dist/mjs/modules/stewardship.js +1 -1
  75. package/dist/mjs/package.json +6 -2
  76. package/dist/mjs/types/index.js +4 -0
  77. package/dist/mjs/utils/collection.js +7 -22
  78. package/dist/mjs/utils/collection.node.js +2 -1
  79. package/dist/mjs/utils/data.browser.js +0 -57
  80. package/dist/mjs/utils/error.js +2 -6
  81. package/dist/mjs/utils/eth.js +1 -1
  82. package/dist/mjs/utils/expose.js +0 -1
  83. package/dist/mjs/utils/http.js +5 -2
  84. package/dist/mjs/utils/tar-uploader.browser.js +22 -0
  85. package/dist/mjs/utils/tar-uploader.js +23 -0
  86. package/dist/mjs/utils/tar-writer.browser.js +12 -0
  87. package/dist/mjs/utils/tar-writer.js +16 -0
  88. package/dist/mjs/utils/tar.browser.js +61 -0
  89. package/dist/mjs/utils/tar.js +45 -16
  90. package/dist/mjs/utils/type.js +4 -1
  91. package/dist/mjs/utils/url.js +1 -6
  92. package/dist/types/bee.d.ts +305 -4
  93. package/dist/types/chunk/soc.d.ts +2 -2
  94. package/dist/types/feed/identifier.d.ts +1 -1
  95. package/dist/types/feed/index.d.ts +1 -1
  96. package/dist/types/index.d.ts +1 -3
  97. package/dist/types/modules/bytes.d.ts +3 -3
  98. package/dist/types/modules/bzz.d.ts +14 -6
  99. package/dist/types/modules/chunk.d.ts +2 -2
  100. package/dist/types/modules/debug/balance.d.ts +4 -4
  101. package/dist/types/modules/debug/chequebook.d.ts +8 -8
  102. package/dist/types/modules/debug/chunk.d.ts +1 -10
  103. package/dist/types/modules/debug/settlements.d.ts +2 -2
  104. package/dist/types/modules/debug/stake.d.ts +3 -3
  105. package/dist/types/modules/debug/states.d.ts +3 -3
  106. package/dist/types/modules/debug/status.d.ts +10 -20
  107. package/dist/types/modules/debug/tag.d.ts +1 -1
  108. package/dist/types/modules/debug/transactions.d.ts +4 -4
  109. package/dist/types/modules/feed.d.ts +6 -9
  110. package/dist/types/modules/pinning.d.ts +4 -4
  111. package/dist/types/modules/pss.d.ts +1 -1
  112. package/dist/types/modules/soc.d.ts +1 -1
  113. package/dist/types/modules/status.d.ts +1 -1
  114. package/dist/types/modules/stewardship.d.ts +1 -1
  115. package/dist/types/types/debug.d.ts +0 -3
  116. package/dist/types/types/index.d.ts +9 -17
  117. package/dist/types/utils/collection.browser.d.ts +1 -1
  118. package/dist/types/utils/collection.d.ts +3 -3
  119. package/dist/types/utils/collection.node.d.ts +1 -1
  120. package/dist/types/utils/data.browser.d.ts +0 -7
  121. package/dist/types/utils/data.d.ts +1 -2
  122. package/dist/types/utils/error.d.ts +2 -7
  123. package/dist/types/utils/eth.d.ts +1 -1
  124. package/dist/types/utils/expose.d.ts +0 -1
  125. package/dist/types/utils/tar-uploader.browser.d.ts +4 -0
  126. package/dist/types/utils/tar-uploader.d.ts +4 -0
  127. package/dist/types/utils/tar-writer.browser.d.ts +3 -0
  128. package/dist/types/utils/tar-writer.d.ts +3 -0
  129. package/dist/types/utils/tar.browser.d.ts +9 -0
  130. package/dist/types/utils/tar.d.ts +10 -2
  131. package/dist/types/utils/type.d.ts +4 -1
  132. package/package.json +4 -19
  133. package/dist/cjs/bee-debug.js +0 -590
  134. package/dist/cjs/chunk/serialize.js +0 -19
  135. package/dist/cjs/utils/stream.js +0 -146
  136. package/dist/cjs/utils/uint64.js +0 -29
  137. package/dist/mjs/bee-debug.js +0 -560
  138. package/dist/mjs/chunk/serialize.js +0 -15
  139. package/dist/mjs/utils/stream.js +0 -129
  140. package/dist/mjs/utils/uint64.js +0 -22
  141. package/dist/types/bee-debug.d.ts +0 -323
  142. package/dist/types/chunk/serialize.d.ts +0 -6
  143. package/dist/types/utils/stream.d.ts +0 -40
  144. package/dist/types/utils/uint64.d.ts +0 -4
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeFeedIdentifier = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
4
5
  const types_1 = require("../types");
5
6
  const hash_1 = require("../utils/hash");
6
7
  const hex_1 = require("../utils/hex");
7
- const uint64_1 = require("../utils/uint64");
8
8
  function isEpoch(epoch) {
9
9
  return typeof epoch === 'object' && epoch !== null && 'time' in epoch && 'level' in epoch;
10
10
  }
@@ -12,7 +12,7 @@ function hashFeedIdentifier(topic, index) {
12
12
  return (0, hash_1.keccak256Hash)((0, hex_1.hexToBytes)(topic), index);
13
13
  }
14
14
  function makeSequentialFeedIdentifier(topic, index) {
15
- const indexBytes = (0, uint64_1.writeUint64BigEndian)(index);
15
+ const indexBytes = cafe_utility_1.Binary.numberToUint64BE(index);
16
16
  return hashFeedIdentifier(topic, indexBytes);
17
17
  }
18
18
  function makeFeedIndexBytes(s) {
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.makeFeedWriter = exports.makeFeedReader = exports.downloadFeedUpdate = exports.getFeedUpdateChunkReference = exports.updateFeed = exports.findNextIndex = void 0;
27
- const serialize_1 = require("../chunk/serialize");
27
+ const cafe_utility_1 = require("cafe-utility");
28
28
  const soc_1 = require("../chunk/soc");
29
29
  const chunkAPI = __importStar(require("../modules/chunk"));
30
30
  const feed_1 = require("../modules/feed");
@@ -35,7 +35,6 @@ const hash_1 = require("../utils/hash");
35
35
  const hex_1 = require("../utils/hex");
36
36
  const reference_1 = require("../utils/reference");
37
37
  const type_1 = require("../utils/type");
38
- const uint64_1 = require("../utils/uint64");
39
38
  const identifier_1 = require("./identifier");
40
39
  const TIMESTAMP_PAYLOAD_OFFSET = 0;
41
40
  const TIMESTAMP_PAYLOAD_SIZE = 8;
@@ -53,13 +52,13 @@ async function findNextIndex(requestOptions, owner, topic, options) {
53
52
  }
54
53
  }
55
54
  exports.findNextIndex = findNextIndex;
56
- async function updateFeed(requestOptions, signer, topic, reference, postageBatchId, options, index = 'latest') {
55
+ async function updateFeed(requestOptions, signer, topic, reference, postageBatchId, options) {
57
56
  const ownerHex = (0, eth_1.makeHexEthAddress)(signer.address);
58
- const nextIndex = index === 'latest' ? await findNextIndex(requestOptions, ownerHex, topic, options) : index;
57
+ const nextIndex = options?.index || (await findNextIndex(requestOptions, ownerHex, topic, options));
59
58
  const identifier = (0, identifier_1.makeFeedIdentifier)(topic, nextIndex);
60
59
  const at = options?.at ?? Date.now() / 1000.0;
61
- const timestamp = (0, uint64_1.writeUint64BigEndian)(at);
62
- const payloadBytes = (0, serialize_1.serializeBytes)(timestamp, reference);
60
+ const timestamp = cafe_utility_1.Binary.numberToUint64BE(at);
61
+ const payloadBytes = cafe_utility_1.Binary.concatBytes(timestamp, reference);
63
62
  return (0, soc_1.uploadSingleOwnerChunkData)(requestOptions, signer, postageBatchId, identifier, payloadBytes, options);
64
63
  }
65
64
  exports.updateFeed = updateFeed;
@@ -75,7 +74,7 @@ async function downloadFeedUpdate(requestOptions, owner, topic, index) {
75
74
  const soc = (0, soc_1.makeSingleOwnerChunkFromData)(data, address);
76
75
  const payload = soc.payload();
77
76
  const timestampBytes = (0, bytes_1.bytesAtOffset)(payload, TIMESTAMP_PAYLOAD_OFFSET, TIMESTAMP_PAYLOAD_SIZE);
78
- const timestamp = (0, uint64_1.readUint64BigEndian)(timestampBytes);
77
+ const timestamp = cafe_utility_1.Binary.uint64BEToNumber(timestampBytes);
79
78
  const reference = (0, reference_1.makeBytesReference)(payload, REFERENCE_PAYLOAD_OFFSET);
80
79
  return {
81
80
  timestamp,
@@ -90,7 +89,7 @@ function makeFeedReader(requestOptions, type, topic, owner) {
90
89
  topic,
91
90
  async download(options) {
92
91
  if (!options?.index && options?.index !== 0) {
93
- return (0, feed_1.fetchLatestFeedUpdate)(requestOptions, owner, topic, { ...options, type });
92
+ return (0, feed_1.fetchLatestFeedUpdate)(requestOptions, owner, topic);
94
93
  }
95
94
  const update = await downloadFeedUpdate(requestOptions, (0, hex_1.hexToBytes)(owner), topic, options.index);
96
95
  return {
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.areAllSequentialFeedsUpdateRetrievable = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
4
5
  const hex_1 = require("../utils/hex");
5
- const uint64_1 = require("../utils/uint64");
6
6
  const index_1 = require("./index");
7
7
  function makeNumericIndex(index) {
8
8
  if (index instanceof Uint8Array) {
9
- return (0, uint64_1.readUint64BigEndian)(index);
9
+ return cafe_utility_1.Binary.uint64BEToNumber(index);
10
10
  }
11
11
  if (typeof index === 'string') {
12
12
  return parseInt(index);
package/dist/cjs/index.js CHANGED
@@ -26,11 +26,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.BeeDebug = exports.Bee = exports.Utils = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = void 0;
29
+ exports.Bee = exports.Utils = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = void 0;
30
30
  const bee_1 = require("./bee");
31
31
  Object.defineProperty(exports, "Bee", { enumerable: true, get: function () { return bee_1.Bee; } });
32
- const bee_debug_1 = require("./bee-debug");
33
- Object.defineProperty(exports, "BeeDebug", { enumerable: true, get: function () { return bee_debug_1.BeeDebug; } });
34
32
  var status_1 = require("./modules/debug/status");
35
33
  Object.defineProperty(exports, "SUPPORTED_BEE_VERSION", { enumerable: true, get: function () { return status_1.SUPPORTED_BEE_VERSION; } });
36
34
  Object.defineProperty(exports, "SUPPORTED_BEE_VERSION_EXACT", { enumerable: true, get: function () { return status_1.SUPPORTED_BEE_VERSION_EXACT; } });
@@ -9,7 +9,7 @@ const endpoint = 'bytes';
9
9
  /**
10
10
  * Upload data to a Bee node
11
11
  *
12
- * @param kyOptions Ky Options for making requests
12
+ * @param requestOptions Options for making requests
13
13
  * @param data Data to be uploaded
14
14
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
15
15
  * @param options Additional options like tag, encryption, pinning
@@ -34,7 +34,7 @@ exports.upload = upload;
34
34
  /**
35
35
  * Download data as a byte array
36
36
  *
37
- * @param ky
37
+ * @param requestOptions Options for making requests
38
38
  * @param hash Bee content reference
39
39
  */
40
40
  async function download(requestOptions, hash, options) {
@@ -49,7 +49,7 @@ exports.download = download;
49
49
  /**
50
50
  * Download data as a readable stream
51
51
  *
52
- * @param ky
52
+ * @param requestOptions Options for making requests
53
53
  * @param hash Bee content reference
54
54
  */
55
55
  async function downloadReadable(requestOptions, hash, options) {
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadCollection = exports.downloadFileReadable = exports.downloadFile = exports.uploadFile = void 0;
3
+ exports.uploadCollection = exports.extractCollectionUploadHeaders = exports.downloadFileReadable = exports.downloadFile = exports.uploadFile = void 0;
4
4
  const bytes_1 = require("../utils/bytes");
5
5
  const collection_1 = require("../utils/collection");
6
6
  const headers_1 = require("../utils/headers");
7
7
  const http_1 = require("../utils/http");
8
- const stream_1 = require("../utils/stream");
9
- const tar_1 = require("../utils/tar");
8
+ const tar_uploader_1 = require("../utils/tar-uploader");
10
9
  const type_1 = require("../utils/type");
11
10
  const bzzEndpoint = 'bzz';
12
11
  function extractFileUploadHeaders(postageBatchId, options) {
@@ -20,14 +19,14 @@ function extractFileUploadHeaders(postageBatchId, options) {
20
19
  /**
21
20
  * Upload single file
22
21
  *
23
- * @param ky
22
+ * @param requestOptions Options for making requests
24
23
  * @param data Files data
25
24
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
26
25
  * @param name Name that will be attached to the uploaded file. Wraps the data into manifest with set index document.
27
26
  * @param options
28
27
  */
29
28
  async function uploadFile(requestOptions, data, postageBatchId, name, options) {
30
- if ((0, stream_1.isReadable)(data) && !options?.contentType) {
29
+ if ((0, type_1.isReadable)(data) && !options?.contentType) {
31
30
  if (!options) {
32
31
  options = {};
33
32
  }
@@ -52,7 +51,7 @@ exports.uploadFile = uploadFile;
52
51
  /**
53
52
  * Download single file as a buffer
54
53
  *
55
- * @param kyOptions Ky Options for making requests
54
+ * @param requestOptions Options for making requests
56
55
  * @param hash Bee file or collection hash
57
56
  * @param path If hash is collection then this defines path to a single file in the collection
58
57
  */
@@ -73,7 +72,7 @@ exports.downloadFile = downloadFile;
73
72
  /**
74
73
  * Download single file as a readable stream
75
74
  *
76
- * @param kyOptions Ky Options for making requests
75
+ * @param requestOptions Options for making requests
77
76
  * @param hash Bee file or collection hash
78
77
  * @param path If hash is collection then this defines path to a single file in the collection
79
78
  */
@@ -101,27 +100,17 @@ function extractCollectionUploadHeaders(postageBatchId, options) {
101
100
  }
102
101
  return headers;
103
102
  }
103
+ exports.extractCollectionUploadHeaders = extractCollectionUploadHeaders;
104
104
  /**
105
105
  * Upload collection
106
- * @param kyOptions Ky Options for making requests
106
+ * @param requestOptions Options for making requests
107
107
  * @param collection Collection of Uint8Array buffers to upload
108
108
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
109
109
  * @param options
110
110
  */
111
111
  async function uploadCollection(requestOptions, collection, postageBatchId, options) {
112
112
  (0, collection_1.assertCollection)(collection);
113
- const tarData = (0, tar_1.makeTar)(collection);
114
- const response = await (0, http_1.http)(requestOptions, {
115
- method: 'post',
116
- url: bzzEndpoint,
117
- data: tarData,
118
- responseType: 'json',
119
- headers: {
120
- 'content-type': 'application/x-tar',
121
- 'swarm-collection': 'true',
122
- ...extractCollectionUploadHeaders(postageBatchId, options),
123
- },
124
- });
113
+ const response = await (0, tar_uploader_1.uploadTar)(requestOptions, collection, postageBatchId, options);
125
114
  return {
126
115
  reference: response.data.reference,
127
116
  tagUid: response.headers['swarm-tag'] ? (0, type_1.makeTagUid)(response.headers['swarm-tag']) : undefined,
@@ -12,7 +12,7 @@ const endpoint = 'chunks';
12
12
  * The span stores the length of the payload in uint64 little endian encoding.
13
13
  * Upload expects the chuck data to be set accordingly.
14
14
  *
15
- * @param ky Ky instance
15
+ * @param requestOptions Options for making requests
16
16
  * @param data Chunk data to be uploaded
17
17
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
18
18
  * @param options Additional options like tag, encryption, pinning
@@ -34,7 +34,7 @@ exports.upload = upload;
34
34
  /**
35
35
  * Download chunk data as a byte array
36
36
  *
37
- * @param kyOptions Ky Options for making requests
37
+ * @param requestOptions Options for making requests
38
38
  * @param hash Bee content reference
39
39
  *
40
40
  */
@@ -7,7 +7,7 @@ const consumedEndpoint = 'consumed';
7
7
  /**
8
8
  * Get the balances with all known peers including prepaid services
9
9
  *
10
- * @param kyOptions Ky Options for making requests
10
+ * @param requestOptions Options for making requests
11
11
  */
12
12
  async function getAllBalances(requestOptions) {
13
13
  const response = await (0, http_1.http)(requestOptions, {
@@ -20,7 +20,7 @@ exports.getAllBalances = getAllBalances;
20
20
  /**
21
21
  * Get the balances with a specific peer including prepaid services
22
22
  *
23
- * @param kyOptions Ky Options for making requests
23
+ * @param requestOptions Options for making requests
24
24
  * @param address Swarm address of peer
25
25
  */
26
26
  async function getPeerBalance(requestOptions, address) {
@@ -34,7 +34,7 @@ exports.getPeerBalance = getPeerBalance;
34
34
  /**
35
35
  * Get the past due consumption balances with all known peers
36
36
  *
37
- * @param kyOptions Ky Options for making requests
37
+ * @param requestOptions Options for making requests
38
38
  */
39
39
  async function getPastDueConsumptionBalances(requestOptions) {
40
40
  const response = await (0, http_1.http)(requestOptions, {
@@ -47,7 +47,7 @@ exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
47
47
  /**
48
48
  * Get the past due consumption balance with a specific peer
49
49
  *
50
- * @param kyOptions Ky Options for making requests
50
+ * @param requestOptions Options for making requests
51
51
  * @param address Swarm address of peer
52
52
  */
53
53
  async function getPastDueConsumptionPeerBalance(requestOptions, address) {
@@ -6,7 +6,7 @@ const chequebookEndpoint = 'chequebook';
6
6
  /**
7
7
  * Get the address of the chequebook contract used
8
8
  *
9
- * @param kyOptions Ky Options for making requests
9
+ * @param requestOptions Options for making requests
10
10
  */
11
11
  async function getChequebookAddress(requestOptions) {
12
12
  const response = await (0, http_1.http)(requestOptions, {
@@ -19,7 +19,7 @@ exports.getChequebookAddress = getChequebookAddress;
19
19
  /**
20
20
  * Get the balance of the chequebook
21
21
  *
22
- * @param kyOptions Ky Options for making requests
22
+ * @param requestOptions Options for making requests
23
23
  */
24
24
  async function getChequebookBalance(requestOptions) {
25
25
  const response = await (0, http_1.http)(requestOptions, {
@@ -32,7 +32,7 @@ exports.getChequebookBalance = getChequebookBalance;
32
32
  /**
33
33
  * Get last cashout action for the peer
34
34
  *
35
- * @param kyOptions Ky Options for making requests
35
+ * @param requestOptions Options for making requests
36
36
  * @param peer Swarm address of peer
37
37
  */
38
38
  async function getLastCashoutAction(requestOptions, peer) {
@@ -46,7 +46,7 @@ exports.getLastCashoutAction = getLastCashoutAction;
46
46
  /**
47
47
  * Cashout the last cheque for the peer
48
48
  *
49
- * @param kyOptions Ky Options for making requests
49
+ * @param requestOptions Options for making requests
50
50
  * @param peer Swarm address of peer
51
51
  * @param options
52
52
  */
@@ -70,7 +70,7 @@ exports.cashoutLastCheque = cashoutLastCheque;
70
70
  /**
71
71
  * Get last cheques for the peer
72
72
  *
73
- * @param kyOptions Ky Options for making requests
73
+ * @param requestOptions Options for making requests
74
74
  * @param peer Swarm address of peer
75
75
  */
76
76
  async function getLastChequesForPeer(requestOptions, peer) {
@@ -84,7 +84,7 @@ exports.getLastChequesForPeer = getLastChequesForPeer;
84
84
  /**
85
85
  * Get last cheques for all peers
86
86
  *
87
- * @param kyOptions Ky Options for making requests
87
+ * @param requestOptions Options for making requests
88
88
  */
89
89
  async function getLastCheques(requestOptions) {
90
90
  const response = await (0, http_1.http)(requestOptions, {
@@ -97,7 +97,7 @@ exports.getLastCheques = getLastCheques;
97
97
  /**
98
98
  * Deposit tokens from overlay address into chequebook
99
99
  *
100
- * @param kyOptions Ky Options for making requests
100
+ * @param requestOptions Options for making requests
101
101
  * @param amount Amount of tokens to deposit
102
102
  * @param gasPrice Gas Price in WEI for the transaction call
103
103
  * @return string Hash of the transaction
@@ -120,7 +120,7 @@ exports.depositTokens = depositTokens;
120
120
  /**
121
121
  * Withdraw tokens from the chequebook to the overlay address
122
122
  *
123
- * @param kyOptions Ky Options for making requests
123
+ * @param requestOptions Options for making requests
124
124
  * @param amount Amount of tokens to withdraw
125
125
  * @param gasPrice Gas Price in WEI for the transaction call
126
126
  * @return string Hash of the transaction
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteChunkFromLocalStorage = exports.checkIfChunkExistsLocally = void 0;
3
+ exports.checkIfChunkExistsLocally = void 0;
4
4
  const http_1 = require("../../utils/http");
5
5
  const endpoint = 'chunks';
6
6
  /**
7
7
  * Check if chunk at address exists locally
8
8
  *
9
- * @param kyOptions Ky Options for making requests
9
+ * @param requestOptions Options for making requests
10
10
  * @param address Swarm address of chunk
11
11
  *
12
12
  * @returns BeeGenericResponse if chunk is found or throws an exception
@@ -19,20 +19,3 @@ async function checkIfChunkExistsLocally(requestOptions, address) {
19
19
  return response.data;
20
20
  }
21
21
  exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
22
- /**
23
- * Delete a chunk from local storage
24
- *
25
- * @param kyOptions Ky Options for making requests
26
- * @param address Swarm address of chunk
27
- *
28
- * @returns BeeGenericResponse if chunk was deleted or throws an exception
29
- */
30
- async function deleteChunkFromLocalStorage(requestOptions, address) {
31
- const response = await (0, http_1.http)(requestOptions, {
32
- method: 'delete',
33
- url: `${endpoint}/${address}`,
34
- responseType: 'json',
35
- });
36
- return response.data;
37
- }
38
- exports.deleteChunkFromLocalStorage = deleteChunkFromLocalStorage;
@@ -6,7 +6,7 @@ const settlementsEndpoint = 'settlements';
6
6
  /**
7
7
  * Get amount of sent and received from settlements with a peer
8
8
  *
9
- * @param kyOptions Ky Options for making requests
9
+ * @param requestOptions Options for making requests
10
10
  * @param peer Swarm address of peer
11
11
  */
12
12
  async function getSettlements(requestOptions, peer) {
@@ -20,7 +20,7 @@ exports.getSettlements = getSettlements;
20
20
  /**
21
21
  * Get settlements with all known peers and total amount sent or received
22
22
  *
23
- * @param kyOptions Ky Options for making requests
23
+ * @param requestOptions Options for making requests
24
24
  */
25
25
  async function getAllSettlements(requestOptions) {
26
26
  const response = await (0, http_1.http)(requestOptions, {
@@ -7,7 +7,7 @@ const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
7
7
  /**
8
8
  * Gets the staked amount
9
9
  *
10
- * @param kyOptions Ky Options for making requests
10
+ * @param requestOptions Options for making requests
11
11
  */
12
12
  async function getStake(requestOptions) {
13
13
  const response = await (0, http_1.http)(requestOptions, {
@@ -21,7 +21,7 @@ exports.getStake = getStake;
21
21
  /**
22
22
  * Stake given amount of tokens.
23
23
  *
24
- * @param ky
24
+ * @param requestOptions Options for making requests
25
25
  * @param amount
26
26
  * @param options
27
27
  */
@@ -44,7 +44,7 @@ exports.stake = stake;
44
44
  /**
45
45
  * Get current status of node in redistribution game
46
46
  *
47
- * @param kyOptions Ky Options for making requests
47
+ * @param requestOptions Options for making requests
48
48
  */
49
49
  async function getRedistributionState(requestOptions) {
50
50
  const response = await (0, http_1.http)(requestOptions, {
@@ -8,7 +8,7 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
8
8
  /**
9
9
  * Get state of reserve
10
10
  *
11
- * @param kyOptions Ky Options for making requests
11
+ * @param requestOptions Options for making requests
12
12
  */
13
13
  async function getReserveState(requestOptions) {
14
14
  const response = await (0, http_1.http)(requestOptions, {
@@ -22,7 +22,7 @@ exports.getReserveState = getReserveState;
22
22
  /**
23
23
  * Get state of reserve
24
24
  *
25
- * @param kyOptions Ky Options for making requests
25
+ * @param requestOptions Options for making requests
26
26
  */
27
27
  async function getChainState(requestOptions) {
28
28
  const response = await (0, http_1.http)(requestOptions, {
@@ -36,7 +36,7 @@ exports.getChainState = getChainState;
36
36
  /**
37
37
  * Get wallet balances for xDai and BZZ of the node
38
38
  *
39
- * @param kyOptions Ky Options for making requests
39
+ * @param requestOptions Options for making requests
40
40
  */
41
41
  async function getWalletBalance(requestOptions) {
42
42
  const response = await (0, http_1.http)(requestOptions, {
@@ -44,21 +44,6 @@ async function getWalletBalance(requestOptions) {
44
44
  url: `${WALLET_ENDPOINT}`,
45
45
  responseType: 'json',
46
46
  });
47
- return mapWalletProperties(response.data);
47
+ return response.data;
48
48
  }
49
49
  exports.getWalletBalance = getWalletBalance;
50
- /**
51
- * TODO: Remove on next break
52
- * @param data
53
- */
54
- function mapWalletProperties(data) {
55
- return {
56
- // @ts-ignore: Needed for backward compatibility mapping
57
- bzz: data.bzzBalance,
58
- // @ts-ignore: Needed for backward compatibility mapping
59
- xDai: data.nativeTokenBalance,
60
- // @ts-ignore: Needed for backward compatibility mapping
61
- contractAddress: data.chequebookContractAddress,
62
- ...data,
63
- };
64
- }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.getDebugStatus = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
6
+ exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.getDebugStatus = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
7
7
  const major_js_1 = __importDefault(require("semver/functions/major.js"));
8
8
  const http_1 = require("../../utils/http");
9
9
  // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
@@ -11,7 +11,7 @@ const http_1 = require("../../utils/http");
11
11
  exports.SUPPORTED_BEE_VERSION_EXACT = '1.18.2-759f56f';
12
12
  exports.SUPPORTED_API_VERSION = '4.0.0';
13
13
  exports.SUPPORTED_DEBUG_API_VERSION = '4.0.0';
14
- exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
14
+ exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
15
15
  const NODE_INFO_URL = 'node';
16
16
  const STATUS_URL = 'status';
17
17
  const HEALTH_URL = 'health';
@@ -28,7 +28,7 @@ exports.getDebugStatus = getDebugStatus;
28
28
  /**
29
29
  * Get health of node
30
30
  *
31
- * @param kyOptions Ky Options for making requests
31
+ * @param requestOptions Options for making requests
32
32
  */
33
33
  async function getHealth(requestOptions) {
34
34
  const response = await (0, http_1.http)(requestOptions, {
@@ -42,7 +42,7 @@ exports.getHealth = getHealth;
42
42
  /**
43
43
  * Get readiness of node
44
44
  *
45
- * @param kyOptions Ky Options for making requests
45
+ * @param requestOptions Options for making requests
46
46
  */
47
47
  async function getReadiness(requestOptions) {
48
48
  try {
@@ -60,7 +60,7 @@ exports.getReadiness = getReadiness;
60
60
  /**
61
61
  * Get information about Bee node
62
62
  *
63
- * @param kyOptions Ky Options for making requests
63
+ * @param requestOptions Options for making requests
64
64
  */
65
65
  async function getNodeInfo(requestOptions) {
66
66
  const response = await (0, http_1.http)(requestOptions, {
@@ -74,8 +74,7 @@ exports.getNodeInfo = getNodeInfo;
74
74
  /**
75
75
  * Connects to a node and checks if it is a supported Bee version by the bee-js
76
76
  *
77
- * @param kyOptions Ky Options for making requests
78
- *
77
+ * @param requestOptions Options for making requests
79
78
  * @returns true if the Bee node version is supported
80
79
  * @deprecated Use `isSupportedExactVersion` instead
81
80
  */
@@ -92,7 +91,7 @@ exports.isSupportedVersion = isSupportedVersion;
92
91
  * `isSupportedApiVersion`, `isSupportedMainApiVersion` or `isSupportedDebugApiVersion`
93
92
  * based on your use-case.
94
93
  *
95
- * @param ky
94
+ * @param requestOptions Options for making requests
96
95
  */
97
96
  async function isSupportedExactVersion(requestOptions) {
98
97
  const { version } = await getHealth(requestOptions);
@@ -102,10 +101,10 @@ exports.isSupportedExactVersion = isSupportedExactVersion;
102
101
  /**
103
102
  * Connects to a node and checks if its main's API version matches with the one that bee-js supports.
104
103
  *
105
- * This is useful if you are not using `BeeDebug` class (for anything else then this check)
104
+ * This is useful if you are not using `Bee` class (for anything else then this check)
106
105
  * and want to make sure about compatibility.
107
106
  *
108
- * @param ky
107
+ * @param requestOptions Options for making requests
109
108
  */
110
109
  async function isSupportedMainApiVersion(requestOptions) {
111
110
  const { apiVersion } = await getHealth(requestOptions);
@@ -113,46 +112,30 @@ async function isSupportedMainApiVersion(requestOptions) {
113
112
  }
114
113
  exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
115
114
  /**
116
- * Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
117
- *
118
- * This is useful if you are not using `Bee` class in your application and want to make sure
119
- * about compatibility.
120
- *
121
- * @param ky
122
- */
123
- async function isSupportedDebugApiVersion(requestOptions) {
124
- const { debugApiVersion } = await getHealth(requestOptions);
125
- return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
126
- }
127
- exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
128
- /**
129
- * Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
115
+ * Connects to a node and checks if its Main API versions matches with the one that bee-js supports.
130
116
  *
131
117
  * This should be the main way how to check compatibility for your app and Bee node.
132
118
  *
133
- * @param ky
119
+ * @param requestOptions Options for making requests
134
120
  */
135
121
  async function isSupportedApiVersion(requestOptions) {
136
- const { apiVersion, debugApiVersion } = await getHealth(requestOptions);
137
- return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
138
- (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
122
+ const { apiVersion } = await getHealth(requestOptions);
123
+ return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
139
124
  }
140
125
  exports.isSupportedApiVersion = isSupportedApiVersion;
141
126
  /**
142
127
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
143
128
  * and versions that bee-js supports (properties prefixed with `supported*`).
144
129
  *
145
- * @param ky
130
+ * @param requestOptions Options for making requests
146
131
  */
147
132
  async function getVersions(requestOptions) {
148
- const { version, apiVersion, debugApiVersion } = await getHealth(requestOptions);
133
+ const { version, apiVersion } = await getHealth(requestOptions);
149
134
  return {
150
135
  supportedBeeVersion: exports.SUPPORTED_BEE_VERSION_EXACT,
151
136
  supportedBeeApiVersion: exports.SUPPORTED_API_VERSION,
152
- supportedBeeDebugApiVersion: exports.SUPPORTED_DEBUG_API_VERSION,
153
137
  beeVersion: version,
154
138
  beeApiVersion: apiVersion,
155
- beeDebugApiVersion: debugApiVersion,
156
139
  };
157
140
  }
158
141
  exports.getVersions = getVersions;
@@ -6,7 +6,7 @@ const endpoint = 'tags';
6
6
  /**
7
7
  * Retrieve tag with extended information from Bee node
8
8
  *
9
- * @param kyOptions Ky Options for making requests
9
+ * @param requestOptions Options for making requests
10
10
  * @param uid UID of tag to be retrieved
11
11
  */
12
12
  async function retrieveExtendedTag(requestOptions, uid) {
@@ -6,7 +6,7 @@ const transactionsEndpoint = 'transactions';
6
6
  /**
7
7
  * Get list of all pending transactions
8
8
  *
9
- * @param ky Debug Ky instance
9
+ * @param requestOptions Options for making requests
10
10
  */
11
11
  async function getAllTransactions(requestOptions) {
12
12
  const response = await (0, http_1.http)(requestOptions, {
@@ -19,7 +19,7 @@ exports.getAllTransactions = getAllTransactions;
19
19
  /**
20
20
  * Get information for specific pending transactions
21
21
  *
22
- * @param ky Debug Ky instance
22
+ * @param requestOptions Options for making requests
23
23
  * @param transactionHash Hash of the transaction
24
24
  */
25
25
  async function getTransaction(requestOptions, transactionHash) {
@@ -33,7 +33,7 @@ exports.getTransaction = getTransaction;
33
33
  /**
34
34
  * Rebroadcast existing transaction
35
35
  *
36
- * @param ky Debug Ky instance
36
+ * @param requestOptions Options for making requests
37
37
  * @param transactionHash Hash of the transaction
38
38
  */
39
39
  async function rebroadcastTransaction(requestOptions, transactionHash) {
@@ -48,7 +48,7 @@ exports.rebroadcastTransaction = rebroadcastTransaction;
48
48
  /**
49
49
  * Cancel existing transaction
50
50
  *
51
- * @param ky Debug Ky instance
51
+ * @param requestOptions Options for making requests
52
52
  * @param transactionHash Hash of the transaction
53
53
  * @param gasPrice Optional gas price
54
54
  */