@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,50 +1,15 @@
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 endpoint = 'tags';
35
3
  /**
36
4
  * Retrieve tag with extended information from Bee node
37
5
  *
38
- * @param ky Ky debug instance
6
+ * @param kyOptions Ky Options for making requests
39
7
  * @param uid UID of tag to be retrieved
40
8
  */
41
-
42
- export function retrieveExtendedTag(ky, uid) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const response = yield http(ky, {
45
- path: `${endpoint}/${uid}`,
46
- responseType: 'json'
47
- });
48
- return response.data;
9
+ export async function retrieveExtendedTag(kyOptions, uid) {
10
+ const response = await http(kyOptions, {
11
+ path: `${endpoint}/${uid}`,
12
+ responseType: 'json'
49
13
  });
14
+ return response.parsedData;
50
15
  }
@@ -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 transactionsEndpoint = 'transactions';
35
3
  /**
@@ -37,15 +5,12 @@ const transactionsEndpoint = 'transactions';
37
5
  *
38
6
  * @param ky Debug Ky instance
39
7
  */
40
-
41
- export function getAllTransactions(ky) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const response = yield http(ky, {
44
- path: transactionsEndpoint,
45
- responseType: 'json'
46
- });
47
- return response.data.pendingTransactions;
8
+ export async function getAllTransactions(kyOptions) {
9
+ const response = await http(kyOptions, {
10
+ path: transactionsEndpoint,
11
+ responseType: 'json'
48
12
  });
13
+ return response.parsedData.pendingTransactions;
49
14
  }
50
15
  /**
51
16
  * Get information for specific pending transactions
@@ -53,15 +18,12 @@ export function getAllTransactions(ky) {
53
18
  * @param ky Debug Ky instance
54
19
  * @param transactionHash Hash of the transaction
55
20
  */
56
-
57
- export function getTransaction(ky, transactionHash) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const response = yield http(ky, {
60
- path: `${transactionsEndpoint}/${transactionHash}`,
61
- responseType: 'json'
62
- });
63
- return response.data;
21
+ export async function getTransaction(kyOptions, transactionHash) {
22
+ const response = await http(kyOptions, {
23
+ path: `${transactionsEndpoint}/${transactionHash}`,
24
+ responseType: 'json'
64
25
  });
26
+ return response.parsedData;
65
27
  }
66
28
  /**
67
29
  * Rebroadcast existing transaction
@@ -69,16 +31,13 @@ export function getTransaction(ky, transactionHash) {
69
31
  * @param ky Debug Ky instance
70
32
  * @param transactionHash Hash of the transaction
71
33
  */
72
-
73
- export function rebroadcastTransaction(ky, transactionHash) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const response = yield http(ky, {
76
- method: 'post',
77
- path: `${transactionsEndpoint}/${transactionHash}`,
78
- responseType: 'json'
79
- });
80
- return response.data.transactionHash;
34
+ export async function rebroadcastTransaction(kyOptions, transactionHash) {
35
+ const response = await http(kyOptions, {
36
+ method: 'post',
37
+ path: `${transactionsEndpoint}/${transactionHash}`,
38
+ responseType: 'json'
81
39
  });
40
+ return response.parsedData.transactionHash;
82
41
  }
83
42
  /**
84
43
  * Cancel existing transaction
@@ -87,17 +46,14 @@ export function rebroadcastTransaction(ky, transactionHash) {
87
46
  * @param transactionHash Hash of the transaction
88
47
  * @param gasPrice Optional gas price
89
48
  */
90
-
91
- export function cancelTransaction(ky, transactionHash, gasPrice) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const response = yield http(ky, {
94
- method: 'delete',
95
- headers: {
96
- 'gas-price': gasPrice
97
- },
98
- path: `${transactionsEndpoint}/${transactionHash}`,
99
- responseType: 'json'
100
- });
101
- return response.data.transactionHash;
49
+ export async function cancelTransaction(kyOptions, transactionHash, gasPrice) {
50
+ const response = await http(kyOptions, {
51
+ method: 'delete',
52
+ headers: {
53
+ 'gas-price': gasPrice
54
+ },
55
+ path: `${transactionsEndpoint}/${transactionHash}`,
56
+ responseType: 'json'
102
57
  });
58
+ return response.parsedData.transactionHash;
103
59
  }
@@ -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 { filterHeaders, http } from "../utils/http.js";
34
2
  import { extractUploadHeaders } from "../utils/headers.js";
35
3
  import { BeeError } from "../utils/error.js";
@@ -43,32 +11,25 @@ const feedEndpoint = 'feeds';
43
11
  * @param postageBatchId Postage BatchId to be used to create the Feed Manifest
44
12
  * @param options Additional options, like type (default: 'sequence')
45
13
  */
46
-
47
- export function createFeedManifest(ky, owner, topic, postageBatchId, options) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const response = yield http(ky, {
50
- method: 'post',
51
- responseType: 'json',
52
- path: `${feedEndpoint}/${owner}/${topic}`,
53
- searchParams: filterHeaders(options),
54
- headers: extractUploadHeaders(postageBatchId)
55
- });
56
- return response.data.reference;
14
+ export async function createFeedManifest(kyOptions, owner, topic, postageBatchId, options) {
15
+ const response = await http(kyOptions, {
16
+ method: 'post',
17
+ responseType: 'json',
18
+ path: `${feedEndpoint}/${owner}/${topic}`,
19
+ searchParams: filterHeaders(options),
20
+ headers: extractUploadHeaders(postageBatchId)
57
21
  });
22
+ return response.parsedData.reference;
58
23
  }
59
-
60
24
  function readFeedUpdateHeaders(headers) {
61
25
  const feedIndex = headers.get('swarm-feed-index');
62
26
  const feedIndexNext = headers.get('swarm-feed-index-next');
63
-
64
27
  if (!feedIndex) {
65
28
  throw new BeeError('Response did not contain expected swarm-feed-index!');
66
29
  }
67
-
68
30
  if (!feedIndexNext) {
69
31
  throw new BeeError('Response did not contain expected swarm-feed-index-next!');
70
32
  }
71
-
72
33
  return {
73
34
  feedIndex,
74
35
  feedIndexNext
@@ -87,15 +48,14 @@ function readFeedUpdateHeaders(headers) {
87
48
  * @param topic Topic in hex
88
49
  * @param options Additional options, like index, at, type
89
50
  */
90
-
91
-
92
- export function fetchLatestFeedUpdate(ky, owner, topic, options) {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- const response = yield http(ky, {
95
- responseType: 'json',
96
- path: `${feedEndpoint}/${owner}/${topic}`,
97
- searchParams: filterHeaders(options)
98
- });
99
- return Object.assign(Object.assign({}, response.data), readFeedUpdateHeaders(response.headers));
51
+ export async function fetchLatestFeedUpdate(kyOptions, owner, topic, options) {
52
+ const response = await http(kyOptions, {
53
+ responseType: 'json',
54
+ path: `${feedEndpoint}/${owner}/${topic}`,
55
+ searchParams: filterHeaders(options)
100
56
  });
57
+ return {
58
+ ...response.parsedData,
59
+ ...readFeedUpdateHeaders(response.headers)
60
+ };
101
61
  }
@@ -1,67 +1,29 @@
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 PINNING_ENDPOINT = 'pins';
35
3
  /**
36
4
  * Pin data with given reference
37
5
  *
38
- * @param ky Ky instance for given Bee class instance
6
+ * @param kyOptions Ky Options for making requests
39
7
  * @param reference Bee data reference
40
8
  */
41
-
42
- export function pin(ky, reference) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- yield http(ky, {
45
- method: 'post',
46
- responseType: 'json',
47
- path: `${PINNING_ENDPOINT}/${reference}`
48
- });
9
+ export async function pin(kyOptions, reference) {
10
+ await http(kyOptions, {
11
+ method: 'post',
12
+ responseType: 'json',
13
+ path: `${PINNING_ENDPOINT}/${reference}`
49
14
  });
50
15
  }
51
16
  /**
52
17
  * Unpin data with given reference
53
18
  *
54
- * @param ky Ky instance for given Bee class instance
19
+ * @param kyOptions Ky Options for making requests
55
20
  * @param reference Bee data reference
56
21
  */
57
-
58
- export function unpin(ky, reference) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- yield http(ky, {
61
- method: 'delete',
62
- responseType: 'json',
63
- path: `${PINNING_ENDPOINT}/${reference}`
64
- });
22
+ export async function unpin(kyOptions, reference) {
23
+ await http(kyOptions, {
24
+ method: 'delete',
25
+ responseType: 'json',
26
+ path: `${PINNING_ENDPOINT}/${reference}`
65
27
  });
66
28
  }
67
29
  /**
@@ -71,30 +33,24 @@ export function unpin(ky, reference) {
71
33
  * @param reference
72
34
  * @throws Error if given address is not pinned
73
35
  */
74
-
75
- export function getPin(ky, reference) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const response = yield http(ky, {
78
- method: 'get',
79
- responseType: 'json',
80
- path: `${PINNING_ENDPOINT}/${reference}`
81
- });
82
- return response.data;
36
+ export async function getPin(kyOptions, reference) {
37
+ const response = await http(kyOptions, {
38
+ method: 'get',
39
+ responseType: 'json',
40
+ path: `${PINNING_ENDPOINT}/${reference}`
83
41
  });
42
+ return response.parsedData;
84
43
  }
85
44
  /**
86
45
  * Get list of all pins
87
46
  *
88
47
  * @param ky Ky instance
89
48
  */
90
-
91
- export function getAllPins(ky) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const response = yield http(ky, {
94
- method: 'get',
95
- responseType: 'json',
96
- path: `${PINNING_ENDPOINT}`
97
- });
98
- return response.data.references;
49
+ export async function getAllPins(kyOptions) {
50
+ const response = await http(kyOptions, {
51
+ method: 'get',
52
+ responseType: 'json',
53
+ path: `${PINNING_ENDPOINT}`
99
54
  });
55
+ return response.parsedData.references;
100
56
  }
@@ -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 WebSocket from 'isomorphic-ws';
34
2
  import { prepareData } from "../utils/data.js";
35
3
  import { http } from "../utils/http.js";
@@ -38,7 +6,7 @@ const endpoint = 'pss';
38
6
  /**
39
7
  * Send to recipient or target with Postal Service for Swarm
40
8
  *
41
- * @param ky Ky instance for given Bee class instance
9
+ * @param kyOptions Ky Options for making requests
42
10
  * @param topic Topic name
43
11
  * @param target Target message address prefix
44
12
  * @param data
@@ -46,19 +14,16 @@ const endpoint = 'pss';
46
14
  * @param recipient Recipient public key
47
15
  *
48
16
  */
49
-
50
- export function send(ky, topic, target, data, postageBatchId, recipient) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- yield http(ky, {
53
- method: 'post',
54
- path: `${endpoint}/send/${topic}/${target}`,
55
- body: yield prepareData(data),
56
- responseType: 'json',
57
- searchParams: {
58
- recipient
59
- },
60
- headers: extractUploadHeaders(postageBatchId)
61
- });
17
+ export async function send(kyOptions, topic, target, data, postageBatchId, recipient) {
18
+ await http(kyOptions, {
19
+ method: 'post',
20
+ path: `${endpoint}/send/${topic}/${target}`,
21
+ body: await prepareData(data),
22
+ responseType: 'json',
23
+ searchParams: {
24
+ recipient
25
+ },
26
+ headers: extractUploadHeaders(postageBatchId)
62
27
  });
63
28
  }
64
29
  /**
@@ -67,7 +32,6 @@ export function send(ky, topic, target, data, postageBatchId, recipient) {
67
32
  * @param url Bee node URL
68
33
  * @param topic Topic name
69
34
  */
70
-
71
35
  export function subscribe(url, topic) {
72
36
  const wsUrl = url.replace(/^http/i, 'ws');
73
37
  return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic}`);
@@ -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 { extractUploadHeaders } from "../utils/headers.js";
34
2
  import { http } from "../utils/http.js";
35
3
  const socEndpoint = 'soc';
@@ -44,21 +12,19 @@ const socEndpoint = 'soc';
44
12
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
45
13
  * @param options Additional options like tag, encryption, pinning
46
14
  */
47
-
48
- export function upload(ky, owner, identifier, signature, data, postageBatchId, options) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const response = yield http(ky, {
51
- method: 'post',
52
- path: `${socEndpoint}/${owner}/${identifier}`,
53
- body: data,
54
- headers: Object.assign({
55
- 'content-type': 'application/octet-stream'
56
- }, extractUploadHeaders(postageBatchId, options)),
57
- responseType: 'json',
58
- searchParams: {
59
- sig: signature
60
- }
61
- });
62
- return response.data.reference;
15
+ export async function upload(kyOptions, owner, identifier, signature, data, postageBatchId, options) {
16
+ const response = await http(kyOptions, {
17
+ method: 'post',
18
+ path: `${socEndpoint}/${owner}/${identifier}`,
19
+ body: data,
20
+ headers: {
21
+ 'content-type': 'application/octet-stream',
22
+ ...extractUploadHeaders(postageBatchId, options)
23
+ },
24
+ responseType: 'json',
25
+ searchParams: {
26
+ sig: signature
27
+ }
63
28
  });
29
+ return response.parsedData.reference;
64
30
  }
@@ -1,46 +1,11 @@
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
  /**
35
3
  * Ping the base bee URL. If connection was not successful throw error
36
4
  *
37
- * @param ky Ky instance for given Bee class instance
5
+ * @param kyOptions Ky instance for given Bee class instance
38
6
  */
39
-
40
- export function checkConnection(ky) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- yield http(ky, {
43
- path: ''
44
- });
7
+ export async function checkConnection(kyOptions) {
8
+ await http(kyOptions, {
9
+ path: ''
45
10
  });
46
11
  }
@@ -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 stewardshipEndpoint = 'stewardship';
35
3
  /**
@@ -39,22 +7,17 @@ const stewardshipEndpoint = 'stewardship';
39
7
  * @param options
40
8
  * @throws BeeResponseError if not locally pinned or invalid data
41
9
  */
42
-
43
- export function reupload(ky, reference) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- yield http(ky, {
46
- method: 'put',
47
- path: `${stewardshipEndpoint}/${reference}`
48
- });
10
+ export async function reupload(kyOptions, reference) {
11
+ await http(kyOptions, {
12
+ method: 'put',
13
+ path: `${stewardshipEndpoint}/${reference}`
49
14
  });
50
15
  }
51
- export function isRetrievable(ky, reference) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const response = yield http(ky, {
54
- method: 'get',
55
- responseType: 'json',
56
- path: `${stewardshipEndpoint}/${reference}`
57
- });
58
- return response.data.isRetrievable;
16
+ export async function isRetrievable(kyOptions, reference) {
17
+ const response = await http(kyOptions, {
18
+ method: 'get',
19
+ responseType: 'json',
20
+ path: `${stewardshipEndpoint}/${reference}`
59
21
  });
22
+ return response.parsedData.isRetrievable;
60
23
  }