@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,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -17,7 +8,7 @@ const http_1 = require("../../utils/http");
17
8
  const major_js_1 = __importDefault(require("semver/functions/major.js"));
18
9
  // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
19
10
  // so if you are changing anything about them change the `update_bee` action accordingly!
20
- exports.SUPPORTED_BEE_VERSION_EXACT = '1.10.0-904cbb08';
11
+ exports.SUPPORTED_BEE_VERSION_EXACT = '1.11.1-1992b846';
21
12
  exports.SUPPORTED_API_VERSION = '4.0.0';
22
13
  exports.SUPPORTED_DEBUG_API_VERSION = '4.0.0';
23
14
  exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
@@ -27,68 +18,60 @@ const READINESS_URL = 'readiness';
27
18
  /**
28
19
  * Get health of node
29
20
  *
30
- * @param ky Ky debug instance
21
+ * @param kyOptions Ky Options for making requests
31
22
  */
32
- function getHealth(ky) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const response = yield (0, http_1.http)(ky, {
35
- method: 'get',
36
- path: HEALTH_URL,
37
- responseType: 'json',
38
- });
39
- return response.data;
23
+ async function getHealth(kyOptions) {
24
+ const response = await (0, http_1.http)(kyOptions, {
25
+ method: 'get',
26
+ path: HEALTH_URL,
27
+ responseType: 'json',
40
28
  });
29
+ return response.parsedData;
41
30
  }
42
31
  exports.getHealth = getHealth;
43
32
  /**
44
33
  * Get readiness of node
45
34
  *
46
- * @param ky Ky debug instance
35
+ * @param kyOptions Ky Options for making requests
47
36
  */
48
- function getReadiness(ky) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- try {
51
- const response = yield (0, http_1.http)(ky, {
52
- method: 'get',
53
- path: READINESS_URL,
54
- });
55
- return response.status === 200;
56
- }
57
- catch (_a) {
58
- return false;
59
- }
60
- });
37
+ async function getReadiness(kyOptions) {
38
+ try {
39
+ const response = await (0, http_1.http)(kyOptions, {
40
+ method: 'get',
41
+ path: READINESS_URL,
42
+ });
43
+ return response.status === 200;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
61
48
  }
62
49
  exports.getReadiness = getReadiness;
63
50
  /**
64
51
  * Get information about Bee node
65
52
  *
66
- * @param ky Ky debug instance
53
+ * @param kyOptions Ky Options for making requests
67
54
  */
68
- function getNodeInfo(ky) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const response = yield (0, http_1.http)(ky, {
71
- method: 'get',
72
- path: NODE_INFO_URL,
73
- responseType: 'json',
74
- });
75
- return response.data;
55
+ async function getNodeInfo(kyOptions) {
56
+ const response = await (0, http_1.http)(kyOptions, {
57
+ method: 'get',
58
+ path: NODE_INFO_URL,
59
+ responseType: 'json',
76
60
  });
61
+ return response.parsedData;
77
62
  }
78
63
  exports.getNodeInfo = getNodeInfo;
79
64
  /**
80
65
  * Connects to a node and checks if it is a supported Bee version by the bee-js
81
66
  *
82
- * @param ky Ky debug instance
67
+ * @param kyOptions Ky Options for making requests
83
68
  *
84
69
  * @returns true if the Bee node version is supported
85
70
  * @deprecated Use `isSupportedExactVersion` instead
86
71
  */
87
72
  // TODO: Remove on break
88
- function isSupportedVersion(ky) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- return isSupportedExactVersion(ky);
91
- });
73
+ async function isSupportedVersion(kyOptions) {
74
+ return isSupportedExactVersion(kyOptions);
92
75
  }
93
76
  exports.isSupportedVersion = isSupportedVersion;
94
77
  /**
@@ -101,11 +84,9 @@ exports.isSupportedVersion = isSupportedVersion;
101
84
  *
102
85
  * @param ky
103
86
  */
104
- function isSupportedExactVersion(ky) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const { version } = yield getHealth(ky);
107
- return version === exports.SUPPORTED_BEE_VERSION_EXACT;
108
- });
87
+ async function isSupportedExactVersion(kyOptions) {
88
+ const { version } = await getHealth(kyOptions);
89
+ return version === exports.SUPPORTED_BEE_VERSION_EXACT;
109
90
  }
110
91
  exports.isSupportedExactVersion = isSupportedExactVersion;
111
92
  /**
@@ -116,11 +97,9 @@ exports.isSupportedExactVersion = isSupportedExactVersion;
116
97
  *
117
98
  * @param ky
118
99
  */
119
- function isSupportedMainApiVersion(ky) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- const { apiVersion } = yield getHealth(ky);
122
- return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
123
- });
100
+ async function isSupportedMainApiVersion(kyOptions) {
101
+ const { apiVersion } = await getHealth(kyOptions);
102
+ return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
124
103
  }
125
104
  exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
126
105
  /**
@@ -131,11 +110,9 @@ exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
131
110
  *
132
111
  * @param ky
133
112
  */
134
- function isSupportedDebugApiVersion(ky) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- const { debugApiVersion } = yield getHealth(ky);
137
- return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
138
- });
113
+ async function isSupportedDebugApiVersion(kyOptions) {
114
+ const { debugApiVersion } = await getHealth(kyOptions);
115
+ return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
139
116
  }
140
117
  exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
141
118
  /**
@@ -145,12 +122,10 @@ exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
145
122
  *
146
123
  * @param ky
147
124
  */
148
- function isSupportedApiVersion(ky) {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- const { apiVersion, debugApiVersion } = yield getHealth(ky);
151
- return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
152
- (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
153
- });
125
+ async function isSupportedApiVersion(kyOptions) {
126
+ const { apiVersion, debugApiVersion } = await getHealth(kyOptions);
127
+ return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
128
+ (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
154
129
  }
155
130
  exports.isSupportedApiVersion = isSupportedApiVersion;
156
131
  /**
@@ -159,17 +134,15 @@ exports.isSupportedApiVersion = isSupportedApiVersion;
159
134
  *
160
135
  * @param ky
161
136
  */
162
- function getVersions(ky) {
163
- return __awaiter(this, void 0, void 0, function* () {
164
- const { version, apiVersion, debugApiVersion } = yield getHealth(ky);
165
- return {
166
- supportedBeeVersion: exports.SUPPORTED_BEE_VERSION_EXACT,
167
- supportedBeeApiVersion: exports.SUPPORTED_API_VERSION,
168
- supportedBeeDebugApiVersion: exports.SUPPORTED_DEBUG_API_VERSION,
169
- beeVersion: version,
170
- beeApiVersion: apiVersion,
171
- beeDebugApiVersion: debugApiVersion,
172
- };
173
- });
137
+ async function getVersions(kyOptions) {
138
+ const { version, apiVersion, debugApiVersion } = await getHealth(kyOptions);
139
+ return {
140
+ supportedBeeVersion: exports.SUPPORTED_BEE_VERSION_EXACT,
141
+ supportedBeeApiVersion: exports.SUPPORTED_API_VERSION,
142
+ supportedBeeDebugApiVersion: exports.SUPPORTED_DEBUG_API_VERSION,
143
+ beeVersion: version,
144
+ beeApiVersion: apiVersion,
145
+ beeDebugApiVersion: debugApiVersion,
146
+ };
174
147
  }
175
148
  exports.getVersions = getVersions;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.retrieveExtendedTag = void 0;
13
4
  const http_1 = require("../../utils/http");
@@ -15,16 +6,14 @@ const endpoint = 'tags';
15
6
  /**
16
7
  * Retrieve tag with extended information from Bee node
17
8
  *
18
- * @param ky Ky debug instance
9
+ * @param kyOptions Ky Options for making requests
19
10
  * @param uid UID of tag to be retrieved
20
11
  */
21
- function retrieveExtendedTag(ky, uid) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const response = yield (0, http_1.http)(ky, {
24
- path: `${endpoint}/${uid}`,
25
- responseType: 'json',
26
- });
27
- return response.data;
12
+ async function retrieveExtendedTag(kyOptions, uid) {
13
+ const response = await (0, http_1.http)(kyOptions, {
14
+ path: `${endpoint}/${uid}`,
15
+ responseType: 'json',
28
16
  });
17
+ return response.parsedData;
29
18
  }
30
19
  exports.retrieveExtendedTag = retrieveExtendedTag;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.cancelTransaction = exports.rebroadcastTransaction = exports.getTransaction = exports.getAllTransactions = void 0;
13
4
  const http_1 = require("../../utils/http");
@@ -17,14 +8,12 @@ const transactionsEndpoint = 'transactions';
17
8
  *
18
9
  * @param ky Debug Ky instance
19
10
  */
20
- function getAllTransactions(ky) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const response = yield (0, http_1.http)(ky, {
23
- path: transactionsEndpoint,
24
- responseType: 'json',
25
- });
26
- return response.data.pendingTransactions;
11
+ async function getAllTransactions(kyOptions) {
12
+ const response = await (0, http_1.http)(kyOptions, {
13
+ path: transactionsEndpoint,
14
+ responseType: 'json',
27
15
  });
16
+ return response.parsedData.pendingTransactions;
28
17
  }
29
18
  exports.getAllTransactions = getAllTransactions;
30
19
  /**
@@ -33,14 +22,12 @@ exports.getAllTransactions = getAllTransactions;
33
22
  * @param ky Debug Ky instance
34
23
  * @param transactionHash Hash of the transaction
35
24
  */
36
- function getTransaction(ky, transactionHash) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const response = yield (0, http_1.http)(ky, {
39
- path: `${transactionsEndpoint}/${transactionHash}`,
40
- responseType: 'json',
41
- });
42
- return response.data;
25
+ async function getTransaction(kyOptions, transactionHash) {
26
+ const response = await (0, http_1.http)(kyOptions, {
27
+ path: `${transactionsEndpoint}/${transactionHash}`,
28
+ responseType: 'json',
43
29
  });
30
+ return response.parsedData;
44
31
  }
45
32
  exports.getTransaction = getTransaction;
46
33
  /**
@@ -49,15 +36,13 @@ exports.getTransaction = getTransaction;
49
36
  * @param ky Debug Ky instance
50
37
  * @param transactionHash Hash of the transaction
51
38
  */
52
- function rebroadcastTransaction(ky, transactionHash) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const response = yield (0, http_1.http)(ky, {
55
- method: 'post',
56
- path: `${transactionsEndpoint}/${transactionHash}`,
57
- responseType: 'json',
58
- });
59
- return response.data.transactionHash;
39
+ async function rebroadcastTransaction(kyOptions, transactionHash) {
40
+ const response = await (0, http_1.http)(kyOptions, {
41
+ method: 'post',
42
+ path: `${transactionsEndpoint}/${transactionHash}`,
43
+ responseType: 'json',
60
44
  });
45
+ return response.parsedData.transactionHash;
61
46
  }
62
47
  exports.rebroadcastTransaction = rebroadcastTransaction;
63
48
  /**
@@ -67,15 +52,13 @@ exports.rebroadcastTransaction = rebroadcastTransaction;
67
52
  * @param transactionHash Hash of the transaction
68
53
  * @param gasPrice Optional gas price
69
54
  */
70
- function cancelTransaction(ky, transactionHash, gasPrice) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- const response = yield (0, http_1.http)(ky, {
73
- method: 'delete',
74
- headers: { 'gas-price': gasPrice },
75
- path: `${transactionsEndpoint}/${transactionHash}`,
76
- responseType: 'json',
77
- });
78
- return response.data.transactionHash;
55
+ async function cancelTransaction(kyOptions, transactionHash, gasPrice) {
56
+ const response = await (0, http_1.http)(kyOptions, {
57
+ method: 'delete',
58
+ headers: { 'gas-price': gasPrice },
59
+ path: `${transactionsEndpoint}/${transactionHash}`,
60
+ responseType: 'json',
79
61
  });
62
+ return response.parsedData.transactionHash;
80
63
  }
81
64
  exports.cancelTransaction = cancelTransaction;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.fetchLatestFeedUpdate = exports.createFeedManifest = void 0;
13
4
  const http_1 = require("../utils/http");
@@ -23,17 +14,15 @@ const feedEndpoint = 'feeds';
23
14
  * @param postageBatchId Postage BatchId to be used to create the Feed Manifest
24
15
  * @param options Additional options, like type (default: 'sequence')
25
16
  */
26
- function createFeedManifest(ky, owner, topic, postageBatchId, options) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const response = yield (0, http_1.http)(ky, {
29
- method: 'post',
30
- responseType: 'json',
31
- path: `${feedEndpoint}/${owner}/${topic}`,
32
- searchParams: (0, http_1.filterHeaders)(options),
33
- headers: (0, headers_1.extractUploadHeaders)(postageBatchId),
34
- });
35
- return response.data.reference;
17
+ async function createFeedManifest(kyOptions, owner, topic, postageBatchId, options) {
18
+ const response = await (0, http_1.http)(kyOptions, {
19
+ method: 'post',
20
+ responseType: 'json',
21
+ path: `${feedEndpoint}/${owner}/${topic}`,
22
+ searchParams: (0, http_1.filterHeaders)(options),
23
+ headers: (0, headers_1.extractUploadHeaders)(postageBatchId),
36
24
  });
25
+ return response.parsedData.reference;
37
26
  }
38
27
  exports.createFeedManifest = createFeedManifest;
39
28
  function readFeedUpdateHeaders(headers) {
@@ -63,14 +52,15 @@ function readFeedUpdateHeaders(headers) {
63
52
  * @param topic Topic in hex
64
53
  * @param options Additional options, like index, at, type
65
54
  */
66
- function fetchLatestFeedUpdate(ky, owner, topic, options) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const response = yield (0, http_1.http)(ky, {
69
- responseType: 'json',
70
- path: `${feedEndpoint}/${owner}/${topic}`,
71
- searchParams: (0, http_1.filterHeaders)(options),
72
- });
73
- return Object.assign(Object.assign({}, response.data), readFeedUpdateHeaders(response.headers));
55
+ async function fetchLatestFeedUpdate(kyOptions, owner, topic, options) {
56
+ const response = await (0, http_1.http)(kyOptions, {
57
+ responseType: 'json',
58
+ path: `${feedEndpoint}/${owner}/${topic}`,
59
+ searchParams: (0, http_1.filterHeaders)(options),
74
60
  });
61
+ return {
62
+ ...response.parsedData,
63
+ ...readFeedUpdateHeaders(response.headers),
64
+ };
75
65
  }
76
66
  exports.fetchLatestFeedUpdate = fetchLatestFeedUpdate;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getAllPins = exports.getPin = exports.unpin = exports.pin = void 0;
13
4
  const http_1 = require("../utils/http");
@@ -15,32 +6,28 @@ const PINNING_ENDPOINT = 'pins';
15
6
  /**
16
7
  * Pin data with given reference
17
8
  *
18
- * @param ky Ky instance for given Bee class instance
9
+ * @param kyOptions Ky Options for making requests
19
10
  * @param reference Bee data reference
20
11
  */
21
- function pin(ky, reference) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- yield (0, http_1.http)(ky, {
24
- method: 'post',
25
- responseType: 'json',
26
- path: `${PINNING_ENDPOINT}/${reference}`,
27
- });
12
+ async function pin(kyOptions, reference) {
13
+ await (0, http_1.http)(kyOptions, {
14
+ method: 'post',
15
+ responseType: 'json',
16
+ path: `${PINNING_ENDPOINT}/${reference}`,
28
17
  });
29
18
  }
30
19
  exports.pin = pin;
31
20
  /**
32
21
  * Unpin data with given reference
33
22
  *
34
- * @param ky Ky instance for given Bee class instance
23
+ * @param kyOptions Ky Options for making requests
35
24
  * @param reference Bee data reference
36
25
  */
37
- function unpin(ky, reference) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- yield (0, http_1.http)(ky, {
40
- method: 'delete',
41
- responseType: 'json',
42
- path: `${PINNING_ENDPOINT}/${reference}`,
43
- });
26
+ async function unpin(kyOptions, reference) {
27
+ await (0, http_1.http)(kyOptions, {
28
+ method: 'delete',
29
+ responseType: 'json',
30
+ path: `${PINNING_ENDPOINT}/${reference}`,
44
31
  });
45
32
  }
46
33
  exports.unpin = unpin;
@@ -51,15 +38,13 @@ exports.unpin = unpin;
51
38
  * @param reference
52
39
  * @throws Error if given address is not pinned
53
40
  */
54
- function getPin(ky, reference) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const response = yield (0, http_1.http)(ky, {
57
- method: 'get',
58
- responseType: 'json',
59
- path: `${PINNING_ENDPOINT}/${reference}`,
60
- });
61
- return response.data;
41
+ async function getPin(kyOptions, reference) {
42
+ const response = await (0, http_1.http)(kyOptions, {
43
+ method: 'get',
44
+ responseType: 'json',
45
+ path: `${PINNING_ENDPOINT}/${reference}`,
62
46
  });
47
+ return response.parsedData;
63
48
  }
64
49
  exports.getPin = getPin;
65
50
  /**
@@ -67,14 +52,12 @@ exports.getPin = getPin;
67
52
  *
68
53
  * @param ky Ky instance
69
54
  */
70
- function getAllPins(ky) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- const response = yield (0, http_1.http)(ky, {
73
- method: 'get',
74
- responseType: 'json',
75
- path: `${PINNING_ENDPOINT}`,
76
- });
77
- return response.data.references;
55
+ async function getAllPins(kyOptions) {
56
+ const response = await (0, http_1.http)(kyOptions, {
57
+ method: 'get',
58
+ responseType: 'json',
59
+ path: `${PINNING_ENDPOINT}`,
78
60
  });
61
+ return response.parsedData.references;
79
62
  }
80
63
  exports.getAllPins = getAllPins;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -21,7 +12,7 @@ const endpoint = 'pss';
21
12
  /**
22
13
  * Send to recipient or target with Postal Service for Swarm
23
14
  *
24
- * @param ky Ky instance for given Bee class instance
15
+ * @param kyOptions Ky Options for making requests
25
16
  * @param topic Topic name
26
17
  * @param target Target message address prefix
27
18
  * @param data
@@ -29,16 +20,14 @@ const endpoint = 'pss';
29
20
  * @param recipient Recipient public key
30
21
  *
31
22
  */
32
- function send(ky, topic, target, data, postageBatchId, recipient) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- yield (0, http_1.http)(ky, {
35
- method: 'post',
36
- path: `${endpoint}/send/${topic}/${target}`,
37
- body: yield (0, data_1.prepareData)(data),
38
- responseType: 'json',
39
- searchParams: { recipient },
40
- headers: (0, headers_1.extractUploadHeaders)(postageBatchId),
41
- });
23
+ async function send(kyOptions, topic, target, data, postageBatchId, recipient) {
24
+ await (0, http_1.http)(kyOptions, {
25
+ method: 'post',
26
+ path: `${endpoint}/send/${topic}/${target}`,
27
+ body: await (0, data_1.prepareData)(data),
28
+ responseType: 'json',
29
+ searchParams: { recipient },
30
+ headers: (0, headers_1.extractUploadHeaders)(postageBatchId),
42
31
  });
43
32
  }
44
33
  exports.send = send;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.upload = void 0;
13
4
  const headers_1 = require("../utils/headers");
@@ -24,17 +15,18 @@ const socEndpoint = 'soc';
24
15
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
25
16
  * @param options Additional options like tag, encryption, pinning
26
17
  */
27
- function upload(ky, owner, identifier, signature, data, postageBatchId, options) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const response = yield (0, http_1.http)(ky, {
30
- method: 'post',
31
- path: `${socEndpoint}/${owner}/${identifier}`,
32
- body: data,
33
- headers: Object.assign({ 'content-type': 'application/octet-stream' }, (0, headers_1.extractUploadHeaders)(postageBatchId, options)),
34
- responseType: 'json',
35
- searchParams: { sig: signature },
36
- });
37
- return response.data.reference;
18
+ async function upload(kyOptions, owner, identifier, signature, data, postageBatchId, options) {
19
+ const response = await (0, http_1.http)(kyOptions, {
20
+ method: 'post',
21
+ path: `${socEndpoint}/${owner}/${identifier}`,
22
+ body: data,
23
+ headers: {
24
+ 'content-type': 'application/octet-stream',
25
+ ...(0, headers_1.extractUploadHeaders)(postageBatchId, options),
26
+ },
27
+ responseType: 'json',
28
+ searchParams: { sig: signature },
38
29
  });
30
+ return response.parsedData.reference;
39
31
  }
40
32
  exports.upload = upload;
@@ -1,26 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.checkConnection = void 0;
13
4
  const http_1 = require("../utils/http");
14
5
  /**
15
6
  * Ping the base bee URL. If connection was not successful throw error
16
7
  *
17
- * @param ky Ky instance for given Bee class instance
8
+ * @param kyOptions Ky instance for given Bee class instance
18
9
  */
19
- function checkConnection(ky) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- yield (0, http_1.http)(ky, {
22
- path: '',
23
- });
10
+ async function checkConnection(kyOptions) {
11
+ await (0, http_1.http)(kyOptions, {
12
+ path: '',
24
13
  });
25
14
  }
26
15
  exports.checkConnection = checkConnection;