@ethersphere/bee-js 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +14 -6
  2. package/dist/223.index.browser.min.js +3 -0
  3. package/dist/223.index.browser.min.js.LICENSE.txt +1 -0
  4. package/dist/223.index.browser.min.js.map +1 -0
  5. package/dist/cjs/bee-debug.js +208 -312
  6. package/dist/cjs/bee.js +258 -353
  7. package/dist/cjs/chunk/signer.js +11 -22
  8. package/dist/cjs/chunk/soc.js +33 -50
  9. package/dist/cjs/chunk/span.js +1 -1
  10. package/dist/cjs/feed/index.js +50 -65
  11. package/dist/cjs/feed/json.js +8 -21
  12. package/dist/cjs/feed/retrievable.js +14 -27
  13. package/dist/cjs/modules/bytes.js +25 -37
  14. package/dist/cjs/modules/bzz.js +63 -68
  15. package/dist/cjs/modules/chunk.js +17 -27
  16. package/dist/cjs/modules/debug/balance.js +24 -41
  17. package/dist/cjs/modules/debug/chequebook.js +71 -96
  18. package/dist/cjs/modules/debug/chunk.js +13 -26
  19. package/dist/cjs/modules/debug/connectivity.js +32 -53
  20. package/dist/cjs/modules/debug/settlements.js +12 -25
  21. package/dist/cjs/modules/debug/stake.js +20 -33
  22. package/dist/cjs/modules/debug/stamps.js +45 -66
  23. package/dist/cjs/modules/debug/states.js +27 -40
  24. package/dist/cjs/modules/debug/status.js +53 -80
  25. package/dist/cjs/modules/debug/tag.js +6 -17
  26. package/dist/cjs/modules/debug/transactions.js +23 -40
  27. package/dist/cjs/modules/feed.js +17 -27
  28. package/dist/cjs/modules/pinning.js +24 -41
  29. package/dist/cjs/modules/pss.js +9 -20
  30. package/dist/cjs/modules/soc.js +12 -20
  31. package/dist/cjs/modules/status.js +4 -15
  32. package/dist/cjs/modules/stewardship.js +10 -23
  33. package/dist/cjs/modules/tag.js +28 -47
  34. package/dist/cjs/utils/collection.browser.js +4 -17
  35. package/dist/cjs/utils/collection.js +11 -22
  36. package/dist/cjs/utils/collection.node.js +42 -86
  37. package/dist/cjs/utils/data.browser.js +46 -59
  38. package/dist/cjs/utils/data.js +22 -35
  39. package/dist/cjs/utils/eth.js +31 -43
  40. package/dist/cjs/utils/file.js +9 -20
  41. package/dist/cjs/utils/headers.js +4 -4
  42. package/dist/cjs/utils/http.js +78 -93
  43. package/dist/cjs/utils/merge.js +1 -1
  44. package/dist/cjs/utils/sleep.js +2 -13
  45. package/dist/cjs/utils/type.js +14 -12
  46. package/dist/index.browser.min.js +1 -1
  47. package/dist/index.browser.min.js.LICENSE.txt +1 -3
  48. package/dist/index.browser.min.js.map +1 -1
  49. package/dist/mjs/bee-debug.js +209 -450
  50. package/dist/mjs/bee.js +256 -491
  51. package/dist/mjs/chunk/bmt.js +4 -10
  52. package/dist/mjs/chunk/cac.js +0 -3
  53. package/dist/mjs/chunk/signer.js +12 -63
  54. package/dist/mjs/chunk/soc.js +33 -85
  55. package/dist/mjs/chunk/span.js +3 -6
  56. package/dist/mjs/feed/identifier.js +0 -6
  57. package/dist/mjs/feed/index.js +53 -97
  58. package/dist/mjs/feed/json.js +10 -49
  59. package/dist/mjs/feed/retrievable.js +13 -64
  60. package/dist/mjs/feed/topic.js +0 -2
  61. package/dist/mjs/index.js +1 -2
  62. package/dist/mjs/modules/bytes.js +25 -65
  63. package/dist/mjs/modules/bzz.js +64 -108
  64. package/dist/mjs/modules/chunk.js +17 -54
  65. package/dist/mjs/modules/debug/balance.js +24 -68
  66. package/dist/mjs/modules/debug/chequebook.js +75 -138
  67. package/dist/mjs/modules/debug/chunk.js +13 -51
  68. package/dist/mjs/modules/debug/connectivity.js +32 -76
  69. package/dist/mjs/modules/debug/settlements.js +12 -50
  70. package/dist/mjs/modules/debug/stake.js +20 -61
  71. package/dist/mjs/modules/debug/stamps.js +47 -94
  72. package/dist/mjs/modules/debug/states.js +25 -66
  73. package/dist/mjs/modules/debug/status.js +66 -125
  74. package/dist/mjs/modules/debug/tag.js +6 -41
  75. package/dist/mjs/modules/debug/transactions.js +25 -69
  76. package/dist/mjs/modules/feed.js +17 -57
  77. package/dist/mjs/modules/pinning.js +24 -68
  78. package/dist/mjs/modules/pss.js +11 -47
  79. package/dist/mjs/modules/soc.js +14 -48
  80. package/dist/mjs/modules/status.js +4 -39
  81. package/dist/mjs/modules/stewardship.js +10 -47
  82. package/dist/mjs/modules/tag.js +31 -78
  83. package/dist/mjs/types/debug.js +0 -1
  84. package/dist/mjs/types/index.js +0 -4
  85. package/dist/mjs/utils/bytes.js +6 -14
  86. package/dist/mjs/utils/collection.browser.js +4 -42
  87. package/dist/mjs/utils/collection.js +11 -57
  88. package/dist/mjs/utils/collection.node.js +42 -150
  89. package/dist/mjs/utils/data.browser.js +49 -94
  90. package/dist/mjs/utils/data.js +19 -62
  91. package/dist/mjs/utils/error.js +0 -5
  92. package/dist/mjs/utils/eth.js +37 -95
  93. package/dist/mjs/utils/file.js +11 -50
  94. package/dist/mjs/utils/hash.js +0 -1
  95. package/dist/mjs/utils/headers.js +6 -14
  96. package/dist/mjs/utils/hex.js +6 -25
  97. package/dist/mjs/utils/http.js +80 -138
  98. package/dist/mjs/utils/merge.js +3 -7
  99. package/dist/mjs/utils/pss.js +0 -2
  100. package/dist/mjs/utils/reference.js +2 -5
  101. package/dist/mjs/utils/sleep.js +2 -37
  102. package/dist/mjs/utils/stream.js +0 -23
  103. package/dist/mjs/utils/tar.js +2 -5
  104. package/dist/mjs/utils/type.js +18 -82
  105. package/dist/mjs/utils/uint64.js +0 -1
  106. package/dist/mjs/utils/url.js +2 -10
  107. package/dist/types/bee-debug.d.ts +2 -2
  108. package/dist/types/bee.d.ts +2 -26
  109. package/dist/types/chunk/cac.d.ts +1 -1
  110. package/dist/types/chunk/soc.d.ts +8 -7
  111. package/dist/types/feed/index.d.ts +9 -8
  112. package/dist/types/feed/type.d.ts +1 -1
  113. package/dist/types/modules/bytes.d.ts +6 -5
  114. package/dist/types/modules/bzz.d.ts +9 -8
  115. package/dist/types/modules/chunk.d.ts +5 -4
  116. package/dist/types/modules/debug/balance.d.ts +10 -9
  117. package/dist/types/modules/debug/chequebook.d.ts +18 -17
  118. package/dist/types/modules/debug/chunk.d.ts +6 -5
  119. package/dist/types/modules/debug/connectivity.d.ts +8 -7
  120. package/dist/types/modules/debug/settlements.d.ts +6 -5
  121. package/dist/types/modules/debug/stake.d.ts +5 -4
  122. package/dist/types/modules/debug/stamps.d.ts +8 -7
  123. package/dist/types/modules/debug/states.d.ts +8 -7
  124. package/dist/types/modules/debug/status.d.ts +15 -15
  125. package/dist/types/modules/debug/tag.d.ts +4 -3
  126. package/dist/types/modules/debug/transactions.d.ts +6 -5
  127. package/dist/types/modules/feed.d.ts +4 -3
  128. package/dist/types/modules/pinning.d.ts +8 -7
  129. package/dist/types/modules/pss.d.ts +4 -3
  130. package/dist/types/modules/soc.d.ts +3 -2
  131. package/dist/types/modules/status.d.ts +3 -3
  132. package/dist/types/modules/stewardship.d.ts +4 -3
  133. package/dist/types/modules/tag.d.ts +7 -6
  134. package/dist/types/types/debug.d.ts +1 -1
  135. package/dist/types/types/index.d.ts +30 -34
  136. package/dist/types/utils/eth.d.ts +3 -3
  137. package/dist/types/utils/hex.d.ts +2 -2
  138. package/dist/types/utils/http.d.ts +6 -6
  139. package/package.json +34 -39
  140. package/dist/cjs/types/ky-options.js +0 -8
  141. package/dist/cjs/types/ky-universal/common.js +0 -8
  142. package/dist/cjs/types/ky-universal/hooks.js +0 -8
  143. package/dist/cjs/types/ky-universal/retry.js +0 -8
  144. package/dist/mjs/types/ky-options.js +0 -7
  145. package/dist/mjs/types/ky-universal/common.js +0 -7
  146. package/dist/mjs/types/ky-universal/hooks.js +0 -7
  147. package/dist/mjs/types/ky-universal/retry.js +0 -7
  148. package/dist/types/types/ky-options.d.ts +0 -221
  149. package/dist/types/types/ky-universal/common.d.ts +0 -13
  150. package/dist/types/types/ky-universal/hooks.d.ts +0 -92
  151. package/dist/types/types/ky-universal/retry.d.ts +0 -38
@@ -1,52 +1,17 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const STAKE_ENDPOINT = 'stake';
35
3
  /**
36
4
  * Gets the staked amount
37
5
  *
38
- * @param ky Ky instance for given Bee class instance
6
+ * @param kyOptions Ky Options for making requests
39
7
  */
40
-
41
- export function getStake(ky) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const response = yield http(ky, {
44
- method: 'get',
45
- responseType: 'json',
46
- path: `${STAKE_ENDPOINT}`
47
- });
48
- return response.data.stakedAmount.toString();
8
+ export async function getStake(kyOptions) {
9
+ const response = await http(kyOptions, {
10
+ method: 'get',
11
+ responseType: 'json',
12
+ path: `${STAKE_ENDPOINT}`
49
13
  });
14
+ return response.parsedData.stakedAmount.toString();
50
15
  }
51
16
  /**
52
17
  * Stake given amount of tokens.
@@ -55,24 +20,18 @@ export function getStake(ky) {
55
20
  * @param amount
56
21
  * @param options
57
22
  */
58
-
59
- export function stake(ky, amount, options) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const headers = {};
62
-
63
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
64
- headers['gas-price'] = options.gasPrice.toString();
65
- }
66
-
67
- if (options === null || options === void 0 ? void 0 : options.gasLimit) {
68
- headers['gas-limit'] = options.gasLimit.toString();
69
- }
70
-
71
- yield http(ky, {
72
- method: 'post',
73
- responseType: 'json',
74
- path: `${STAKE_ENDPOINT}/${amount}`,
75
- headers
76
- });
23
+ export async function stake(kyOptions, amount, options) {
24
+ const headers = {};
25
+ if (options?.gasPrice) {
26
+ headers['gas-price'] = options.gasPrice.toString();
27
+ }
28
+ if (options?.gasLimit) {
29
+ headers['gas-limit'] = options.gasLimit.toString();
30
+ }
31
+ await http(kyOptions, {
32
+ method: 'post',
33
+ responseType: 'json',
34
+ path: `${STAKE_ENDPOINT}/${amount}`,
35
+ headers
77
36
  });
78
37
  }
@@ -1,108 +1,61 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const STAMPS_ENDPOINT = 'stamps';
35
- export function getAllPostageBatches(ky) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const response = yield http(ky, {
38
- method: 'get',
39
- path: `${STAMPS_ENDPOINT}`,
40
- responseType: 'json'
41
- });
42
- return response.data.stamps;
3
+ export async function getAllPostageBatches(kyOptions) {
4
+ const response = await http(kyOptions, {
5
+ method: 'get',
6
+ path: `${STAMPS_ENDPOINT}`,
7
+ responseType: 'json'
43
8
  });
9
+ return response.parsedData.stamps;
44
10
  }
45
- export function getPostageBatch(ky, postageBatchId) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const response = yield http(ky, {
48
- method: 'get',
49
- path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
50
- responseType: 'json'
51
- });
52
- return response.data;
11
+ export async function getPostageBatch(kyOptions, postageBatchId) {
12
+ const response = await http(kyOptions, {
13
+ method: 'get',
14
+ path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
15
+ responseType: 'json'
53
16
  });
17
+ return response.parsedData;
54
18
  }
55
- export function getPostageBatchBuckets(ky, postageBatchId) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const response = yield http(ky, {
58
- method: 'get',
59
- path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
60
- responseType: 'json'
61
- });
62
- return response.data;
19
+ export async function getPostageBatchBuckets(kyOptions, postageBatchId) {
20
+ const response = await http(kyOptions, {
21
+ method: 'get',
22
+ path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
23
+ responseType: 'json'
63
24
  });
25
+ return response.parsedData;
64
26
  }
65
- export function createPostageBatch(ky, amount, depth, options) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const headers = {};
68
-
69
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
70
- headers['gas-price'] = options.gasPrice.toString();
71
- }
72
-
73
- if ((options === null || options === void 0 ? void 0 : options.immutableFlag) !== undefined) {
74
- headers.immutable = String(options.immutableFlag);
75
- }
76
-
77
- const response = yield http(ky, {
78
- method: 'post',
79
- path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
80
- responseType: 'json',
81
- searchParams: {
82
- label: options === null || options === void 0 ? void 0 : options.label
83
- },
84
- headers
85
- });
86
- return response.data.batchID;
27
+ export async function createPostageBatch(kyOptions, amount, depth, options) {
28
+ const headers = {};
29
+ if (options?.gasPrice) {
30
+ headers['gas-price'] = options.gasPrice.toString();
31
+ }
32
+ if (options?.immutableFlag !== undefined) {
33
+ headers.immutable = String(options.immutableFlag);
34
+ }
35
+ const response = await http(kyOptions, {
36
+ method: 'post',
37
+ path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
38
+ responseType: 'json',
39
+ searchParams: {
40
+ label: options?.label
41
+ },
42
+ headers
87
43
  });
44
+ return response.parsedData.batchID;
88
45
  }
89
- export function topUpBatch(ky, id, amount) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const response = yield http(ky, {
92
- method: 'patch',
93
- path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
94
- responseType: 'json'
95
- });
96
- return response.data.batchID;
46
+ export async function topUpBatch(kyOptions, id, amount) {
47
+ const response = await http(kyOptions, {
48
+ method: 'patch',
49
+ path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
50
+ responseType: 'json'
97
51
  });
52
+ return response.parsedData.batchID;
98
53
  }
99
- export function diluteBatch(ky, id, depth) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const response = yield http(ky, {
102
- method: 'patch',
103
- path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
104
- responseType: 'json'
105
- });
106
- return response.data.batchID;
54
+ export async function diluteBatch(kyOptions, id, depth) {
55
+ const response = await http(kyOptions, {
56
+ method: 'patch',
57
+ path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
58
+ responseType: 'json'
107
59
  });
60
+ return response.parsedData.batchID;
108
61
  }
@@ -1,35 +1,3 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
2
  const RESERVE_STATE_ENDPOINT = 'reservestate';
35
3
  const WALLET_ENDPOINT = 'wallet';
@@ -37,63 +5,54 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
37
5
  /**
38
6
  * Get state of reserve
39
7
  *
40
- * @param ky Ky debug instance
8
+ * @param kyOptions Ky Options for making requests
41
9
  */
42
-
43
- export function getReserveState(ky) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const response = yield http(ky, {
46
- method: 'get',
47
- path: `${RESERVE_STATE_ENDPOINT}`,
48
- responseType: 'json'
49
- });
50
- return response.data;
10
+ export async function getReserveState(kyOptions) {
11
+ const response = await http(kyOptions, {
12
+ method: 'get',
13
+ path: `${RESERVE_STATE_ENDPOINT}`,
14
+ responseType: 'json'
51
15
  });
16
+ return response.parsedData;
52
17
  }
53
18
  /**
54
19
  * Get state of reserve
55
20
  *
56
- * @param ky Ky debug instance
21
+ * @param kyOptions Ky Options for making requests
57
22
  */
58
-
59
- export function getChainState(ky) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const response = yield http(ky, {
62
- method: 'get',
63
- path: `${CHAIN_STATE_ENDPOINT}`,
64
- responseType: 'json'
65
- });
66
- return response.data;
23
+ export async function getChainState(kyOptions) {
24
+ const response = await http(kyOptions, {
25
+ method: 'get',
26
+ path: `${CHAIN_STATE_ENDPOINT}`,
27
+ responseType: 'json'
67
28
  });
29
+ return response.parsedData;
68
30
  }
69
31
  /**
70
32
  * Get wallet balances for xDai and BZZ of the node
71
33
  *
72
- * @param ky Ky debug instance
34
+ * @param kyOptions Ky Options for making requests
73
35
  */
74
-
75
- export function getWalletBalance(ky) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const response = yield http(ky, {
78
- method: 'get',
79
- path: `${WALLET_ENDPOINT}`,
80
- responseType: 'json'
81
- });
82
- return mapWalletProperties(response.data);
36
+ export async function getWalletBalance(kyOptions) {
37
+ const response = await http(kyOptions, {
38
+ method: 'get',
39
+ path: `${WALLET_ENDPOINT}`,
40
+ responseType: 'json'
83
41
  });
42
+ return mapWalletProperties(response.parsedData);
84
43
  }
85
44
  /**
86
45
  * TODO: Remove on next break
87
46
  * @param data
88
47
  */
89
-
90
48
  function mapWalletProperties(data) {
91
- return Object.assign({
49
+ return {
92
50
  // @ts-ignore: Needed for backward compatibility mapping
93
51
  bzz: data.bzzBalance,
94
52
  // @ts-ignore: Needed for backward compatibility mapping
95
53
  xDai: data.nativeTokenBalance,
96
54
  // @ts-ignore: Needed for backward compatibility mapping
97
- contractAddress: data.chequebookContractAddress
98
- }, data);
55
+ contractAddress: data.chequebookContractAddress,
56
+ ...data
57
+ };
99
58
  }
@@ -1,40 +1,8 @@
1
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) {
3
- return value instanceof P ? value : new P(function (resolve) {
4
- resolve(value);
5
- });
6
- }
7
-
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) {
10
- try {
11
- step(generator.next(value));
12
- } catch (e) {
13
- reject(e);
14
- }
15
- }
16
-
17
- function rejected(value) {
18
- try {
19
- step(generator["throw"](value));
20
- } catch (e) {
21
- reject(e);
22
- }
23
- }
24
-
25
- function step(result) {
26
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
27
- }
28
-
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- };
32
-
33
1
  import { http } from "../../utils/http.js";
34
- import getMajorSemver from 'semver/functions/major.js'; // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
2
+ import getMajorSemver from 'semver/functions/major.js';
3
+ // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
35
4
  // so if you are changing anything about them change the `update_bee` action accordingly!
36
-
37
- export const SUPPORTED_BEE_VERSION_EXACT = '1.10.0-904cbb08';
5
+ export const SUPPORTED_BEE_VERSION_EXACT = '1.11.1-1992b846';
38
6
  export const SUPPORTED_API_VERSION = '4.0.0';
39
7
  export const SUPPORTED_DEBUG_API_VERSION = '4.0.0';
40
8
  export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.substring(0, SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
@@ -44,68 +12,56 @@ const READINESS_URL = 'readiness';
44
12
  /**
45
13
  * Get health of node
46
14
  *
47
- * @param ky Ky debug instance
15
+ * @param kyOptions Ky Options for making requests
48
16
  */
49
-
50
- export function getHealth(ky) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const response = yield http(ky, {
53
- method: 'get',
54
- path: HEALTH_URL,
55
- responseType: 'json'
56
- });
57
- return response.data;
17
+ export async function getHealth(kyOptions) {
18
+ const response = await http(kyOptions, {
19
+ method: 'get',
20
+ path: HEALTH_URL,
21
+ responseType: 'json'
58
22
  });
23
+ return response.parsedData;
59
24
  }
60
25
  /**
61
26
  * Get readiness of node
62
27
  *
63
- * @param ky Ky debug instance
28
+ * @param kyOptions Ky Options for making requests
64
29
  */
65
-
66
- export function getReadiness(ky) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- try {
69
- const response = yield http(ky, {
70
- method: 'get',
71
- path: READINESS_URL
72
- });
73
- return response.status === 200;
74
- } catch (_a) {
75
- return false;
76
- }
77
- });
30
+ export async function getReadiness(kyOptions) {
31
+ try {
32
+ const response = await http(kyOptions, {
33
+ method: 'get',
34
+ path: READINESS_URL
35
+ });
36
+ return response.status === 200;
37
+ } catch {
38
+ return false;
39
+ }
78
40
  }
79
41
  /**
80
42
  * Get information about Bee node
81
43
  *
82
- * @param ky Ky debug instance
44
+ * @param kyOptions Ky Options for making requests
83
45
  */
84
-
85
- export function getNodeInfo(ky) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const response = yield http(ky, {
88
- method: 'get',
89
- path: NODE_INFO_URL,
90
- responseType: 'json'
91
- });
92
- return response.data;
46
+ export async function getNodeInfo(kyOptions) {
47
+ const response = await http(kyOptions, {
48
+ method: 'get',
49
+ path: NODE_INFO_URL,
50
+ responseType: 'json'
93
51
  });
52
+ return response.parsedData;
94
53
  }
95
54
  /**
96
55
  * Connects to a node and checks if it is a supported Bee version by the bee-js
97
56
  *
98
- * @param ky Ky debug instance
57
+ * @param kyOptions Ky Options for making requests
99
58
  *
100
59
  * @returns true if the Bee node version is supported
101
60
  * @deprecated Use `isSupportedExactVersion` instead
102
61
  */
103
62
  // TODO: Remove on break
104
-
105
- export function isSupportedVersion(ky) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- return isSupportedExactVersion(ky);
108
- });
63
+ export async function isSupportedVersion(kyOptions) {
64
+ return isSupportedExactVersion(kyOptions);
109
65
  }
110
66
  /**
111
67
  * Connects to a node and checks if its version matches with the one that bee-js supports.
@@ -117,14 +73,11 @@ export function isSupportedVersion(ky) {
117
73
  *
118
74
  * @param ky
119
75
  */
120
-
121
- export function isSupportedExactVersion(ky) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- const {
124
- version
125
- } = yield getHealth(ky);
126
- return version === SUPPORTED_BEE_VERSION_EXACT;
127
- });
76
+ export async function isSupportedExactVersion(kyOptions) {
77
+ const {
78
+ version
79
+ } = await getHealth(kyOptions);
80
+ return version === SUPPORTED_BEE_VERSION_EXACT;
128
81
  }
129
82
  /**
130
83
  * Connects to a node and checks if its main's API version matches with the one that bee-js supports.
@@ -134,14 +87,11 @@ export function isSupportedExactVersion(ky) {
134
87
  *
135
88
  * @param ky
136
89
  */
137
-
138
- export function isSupportedMainApiVersion(ky) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- const {
141
- apiVersion
142
- } = yield getHealth(ky);
143
- return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
144
- });
90
+ export async function isSupportedMainApiVersion(kyOptions) {
91
+ const {
92
+ apiVersion
93
+ } = await getHealth(kyOptions);
94
+ return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
145
95
  }
146
96
  /**
147
97
  * Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
@@ -151,14 +101,11 @@ export function isSupportedMainApiVersion(ky) {
151
101
  *
152
102
  * @param ky
153
103
  */
154
-
155
- export function isSupportedDebugApiVersion(ky) {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- const {
158
- debugApiVersion
159
- } = yield getHealth(ky);
160
- return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
161
- });
104
+ export async function isSupportedDebugApiVersion(kyOptions) {
105
+ const {
106
+ debugApiVersion
107
+ } = await getHealth(kyOptions);
108
+ return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
162
109
  }
163
110
  /**
164
111
  * Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
@@ -167,15 +114,12 @@ export function isSupportedDebugApiVersion(ky) {
167
114
  *
168
115
  * @param ky
169
116
  */
170
-
171
- export function isSupportedApiVersion(ky) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- const {
174
- apiVersion,
175
- debugApiVersion
176
- } = yield getHealth(ky);
177
- return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
178
- });
117
+ export async function isSupportedApiVersion(kyOptions) {
118
+ const {
119
+ apiVersion,
120
+ debugApiVersion
121
+ } = await getHealth(kyOptions);
122
+ return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
179
123
  }
180
124
  /**
181
125
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
@@ -183,21 +127,18 @@ export function isSupportedApiVersion(ky) {
183
127
  *
184
128
  * @param ky
185
129
  */
186
-
187
- export function getVersions(ky) {
188
- return __awaiter(this, void 0, void 0, function* () {
189
- const {
190
- version,
191
- apiVersion,
192
- debugApiVersion
193
- } = yield getHealth(ky);
194
- return {
195
- supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
196
- supportedBeeApiVersion: SUPPORTED_API_VERSION,
197
- supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
198
- beeVersion: version,
199
- beeApiVersion: apiVersion,
200
- beeDebugApiVersion: debugApiVersion
201
- };
202
- });
130
+ export async function getVersions(kyOptions) {
131
+ const {
132
+ version,
133
+ apiVersion,
134
+ debugApiVersion
135
+ } = await getHealth(kyOptions);
136
+ return {
137
+ supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
138
+ supportedBeeApiVersion: SUPPORTED_API_VERSION,
139
+ supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
140
+ beeVersion: version,
141
+ beeApiVersion: apiVersion,
142
+ beeDebugApiVersion: debugApiVersion
143
+ };
203
144
  }