@ethersphere/bee-js 3.3.0 → 3.3.1

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 (85) hide show
  1. package/dist/cjs/chunk/bmt.js +7 -2
  2. package/dist/cjs/chunk/signer.js +9 -4
  3. package/dist/cjs/modules/debug/status.js +5 -5
  4. package/dist/cjs/package.json +1 -0
  5. package/dist/cjs/types/ky-options.js +8 -0
  6. package/dist/cjs/types/ky-universal/common.js +8 -0
  7. package/dist/cjs/types/ky-universal/hooks.js +8 -0
  8. package/dist/cjs/types/ky-universal/retry.js +8 -0
  9. package/dist/cjs/utils/eth.js +8 -3
  10. package/dist/cjs/utils/hash.js +7 -2
  11. package/dist/cjs/utils/stream.js +14 -5
  12. package/dist/index.browser.min.js +3 -0
  13. package/dist/index.browser.min.js.LICENSE.txt +52 -0
  14. package/dist/index.browser.min.js.map +1 -0
  15. package/dist/mjs/bee-debug.js +608 -508
  16. package/dist/mjs/bee.js +935 -836
  17. package/dist/mjs/chunk/bmt.js +34 -24
  18. package/dist/mjs/chunk/cac.js +24 -22
  19. package/dist/mjs/chunk/serialize.js +9 -9
  20. package/dist/mjs/chunk/signer.js +92 -73
  21. package/dist/mjs/chunk/soc.js +78 -66
  22. package/dist/mjs/chunk/span.js +19 -16
  23. package/dist/mjs/feed/index.js +110 -101
  24. package/dist/mjs/feed/json.js +21 -17
  25. package/dist/mjs/feed/topic.js +18 -17
  26. package/dist/mjs/feed/type.js +5 -5
  27. package/dist/mjs/index.js +7 -7
  28. package/dist/mjs/modules/bytes.js +33 -30
  29. package/dist/mjs/modules/bzz.js +80 -77
  30. package/dist/mjs/modules/chunk.js +22 -20
  31. package/dist/mjs/modules/debug/balance.js +26 -22
  32. package/dist/mjs/modules/debug/chequebook.js +84 -65
  33. package/dist/mjs/modules/debug/chunk.js +15 -13
  34. package/dist/mjs/modules/debug/connectivity.js +34 -34
  35. package/dist/mjs/modules/debug/settlements.js +14 -12
  36. package/dist/mjs/modules/debug/stamps.js +52 -47
  37. package/dist/mjs/modules/debug/states.js +16 -14
  38. package/dist/mjs/modules/debug/status.js +55 -35
  39. package/dist/mjs/modules/debug/tag.js +8 -7
  40. package/dist/mjs/modules/debug/transactions.js +31 -25
  41. package/dist/mjs/modules/feed.js +39 -33
  42. package/dist/mjs/modules/pinning.js +34 -28
  43. package/dist/mjs/modules/pss.js +18 -14
  44. package/dist/mjs/modules/soc.js +18 -15
  45. package/dist/mjs/modules/status.js +6 -5
  46. package/dist/mjs/modules/stewardship.js +13 -12
  47. package/dist/mjs/modules/tag.js +38 -30
  48. package/dist/mjs/package.json +1 -0
  49. package/dist/mjs/types/debug.js +5 -4
  50. package/dist/mjs/types/index.js +6 -2
  51. package/dist/mjs/types/ky-options.js +7 -0
  52. package/dist/mjs/types/ky-universal/common.js +7 -0
  53. package/dist/mjs/types/ky-universal/hooks.js +7 -0
  54. package/dist/mjs/types/ky-universal/retry.js +7 -0
  55. package/dist/mjs/utils/bytes.js +32 -26
  56. package/dist/mjs/utils/collection.browser.js +4 -3
  57. package/dist/mjs/utils/collection.js +47 -35
  58. package/dist/mjs/utils/collection.node.js +53 -42
  59. package/dist/mjs/utils/data.browser.js +64 -48
  60. package/dist/mjs/utils/data.js +29 -25
  61. package/dist/mjs/utils/error.js +47 -39
  62. package/dist/mjs/utils/eth.js +119 -104
  63. package/dist/mjs/utils/expose.js +9 -9
  64. package/dist/mjs/utils/file.js +22 -19
  65. package/dist/mjs/utils/hash.js +10 -5
  66. package/dist/mjs/utils/headers.js +43 -39
  67. package/dist/mjs/utils/hex.js +78 -63
  68. package/dist/mjs/utils/http.js +119 -100
  69. package/dist/mjs/utils/merge.js +26 -20
  70. package/dist/mjs/utils/pss.js +8 -6
  71. package/dist/mjs/utils/stamps.js +7 -3
  72. package/dist/mjs/utils/stream.js +107 -82
  73. package/dist/mjs/utils/tar.js +17 -14
  74. package/dist/mjs/utils/type.js +249 -209
  75. package/dist/mjs/utils/uint64.js +16 -16
  76. package/dist/mjs/utils/url.js +32 -25
  77. package/dist/types/types/index.d.ts +1 -1
  78. package/dist/types/types/ky-options.d.ts +221 -0
  79. package/dist/types/types/ky-universal/common.d.ts +13 -0
  80. package/dist/types/types/ky-universal/hooks.d.ts +92 -0
  81. package/dist/types/types/ky-universal/retry.d.ts +38 -0
  82. package/dist/types/utils/stream.d.ts +11 -8
  83. package/package.json +9 -6
  84. package/dist/index.js +0 -28326
  85. package/dist/index.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const RESERVE_STATE_ENDPOINT = 'reservestate';
3
3
  const CHAIN_STATE_ENDPOINT = 'chainstate';
4
4
  /**
@@ -6,24 +6,26 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
6
6
  *
7
7
  * @param ky Ky debug instance
8
8
  */
9
+
9
10
  export async function getReserveState(ky) {
10
- const response = await http(ky, {
11
- method: 'get',
12
- path: `${RESERVE_STATE_ENDPOINT}`,
13
- responseType: 'json',
14
- });
15
- return response.data;
11
+ const response = await http(ky, {
12
+ method: 'get',
13
+ path: `${RESERVE_STATE_ENDPOINT}`,
14
+ responseType: 'json'
15
+ });
16
+ return response.data;
16
17
  }
17
18
  /**
18
19
  * Get state of reserve
19
20
  *
20
21
  * @param ky Ky debug instance
21
22
  */
23
+
22
24
  export async function getChainState(ky) {
23
- const response = await http(ky, {
24
- method: 'get',
25
- path: `${CHAIN_STATE_ENDPOINT}`,
26
- responseType: 'json',
27
- });
28
- return response.data;
29
- }
25
+ const response = await http(ky, {
26
+ method: 'get',
27
+ path: `${CHAIN_STATE_ENDPOINT}`,
28
+ responseType: 'json'
29
+ });
30
+ return response.data;
31
+ }
@@ -1,7 +1,7 @@
1
- import { http } from '../../utils/http';
2
- import getMajorSemver from 'semver/functions/major';
3
- // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
1
+ import { http } from "../../utils/http.js";
2
+ import getMajorSemver from 'semver/functions/major.js'; // Following lines bellow are automatically updated with GitHub Action when Bee version is updated
4
3
  // so if you are changing anything about them change the `update_bee` action accordingly!
4
+
5
5
  export const SUPPORTED_BEE_VERSION_EXACT = '1.4.3-1213e063';
6
6
  export const SUPPORTED_API_VERSION = '2.0.0';
7
7
  export const SUPPORTED_DEBUG_API_VERSION = '1.2.1';
@@ -13,26 +13,28 @@ const HEALTH_URL = 'health';
13
13
  *
14
14
  * @param ky Ky debug instance
15
15
  */
16
+
16
17
  export async function getHealth(ky) {
17
- const response = await http(ky, {
18
- method: 'get',
19
- path: HEALTH_URL,
20
- responseType: 'json',
21
- });
22
- return response.data;
18
+ const response = await http(ky, {
19
+ method: 'get',
20
+ path: HEALTH_URL,
21
+ responseType: 'json'
22
+ });
23
+ return response.data;
23
24
  }
24
25
  /**
25
26
  * Get information about Bee node
26
27
  *
27
28
  * @param ky Ky debug instance
28
29
  */
30
+
29
31
  export async function getNodeInfo(ky) {
30
- const response = await http(ky, {
31
- method: 'get',
32
- path: NODE_INFO_URL,
33
- responseType: 'json',
34
- });
35
- return response.data;
32
+ const response = await http(ky, {
33
+ method: 'get',
34
+ path: NODE_INFO_URL,
35
+ responseType: 'json'
36
+ });
37
+ return response.data;
36
38
  }
37
39
  /**
38
40
  * Connects to a node and checks if it is a supported Bee version by the bee-js
@@ -42,8 +44,9 @@ export async function getNodeInfo(ky) {
42
44
  * @returns true if the Bee node version is supported
43
45
  * @deprecated Use `isSupportedExactVersion` instead
44
46
  */
47
+
45
48
  export async function isSupportedVersion(ky) {
46
- return isSupportedExactVersion(ky);
49
+ return isSupportedExactVersion(ky);
47
50
  }
48
51
  /**
49
52
  * Connects to a node and checks if its version matches with the one that bee-js supports.
@@ -55,9 +58,12 @@ export async function isSupportedVersion(ky) {
55
58
  *
56
59
  * @param ky
57
60
  */
61
+
58
62
  export async function isSupportedExactVersion(ky) {
59
- const { version } = await getHealth(ky);
60
- return version === SUPPORTED_BEE_VERSION_EXACT;
63
+ const {
64
+ version
65
+ } = await getHealth(ky);
66
+ return version === SUPPORTED_BEE_VERSION_EXACT;
61
67
  }
62
68
  /**
63
69
  * Connects to a node and checks if its main's API version matches with the one that bee-js supports.
@@ -67,9 +73,12 @@ export async function isSupportedExactVersion(ky) {
67
73
  *
68
74
  * @param ky
69
75
  */
76
+
70
77
  export async function isSupportedMainApiVersion(ky) {
71
- const { apiVersion } = await getHealth(ky);
72
- return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
78
+ const {
79
+ apiVersion
80
+ } = await getHealth(ky);
81
+ return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION);
73
82
  }
74
83
  /**
75
84
  * Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
@@ -79,9 +88,12 @@ export async function isSupportedMainApiVersion(ky) {
79
88
  *
80
89
  * @param ky
81
90
  */
91
+
82
92
  export async function isSupportedDebugApiVersion(ky) {
83
- const { debugApiVersion } = await getHealth(ky);
84
- return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
93
+ const {
94
+ debugApiVersion
95
+ } = await getHealth(ky);
96
+ return getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
85
97
  }
86
98
  /**
87
99
  * Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
@@ -90,10 +102,13 @@ export async function isSupportedDebugApiVersion(ky) {
90
102
  *
91
103
  * @param ky
92
104
  */
105
+
93
106
  export async function isSupportedApiVersion(ky) {
94
- const { apiVersion, debugApiVersion } = await getHealth(ky);
95
- return (getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) &&
96
- getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION));
107
+ const {
108
+ apiVersion,
109
+ debugApiVersion
110
+ } = await getHealth(ky);
111
+ return getMajorSemver(apiVersion) === getMajorSemver(SUPPORTED_API_VERSION) && getMajorSemver(debugApiVersion) === getMajorSemver(SUPPORTED_DEBUG_API_VERSION);
97
112
  }
98
113
  /**
99
114
  * Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
@@ -101,14 +116,19 @@ export async function isSupportedApiVersion(ky) {
101
116
  *
102
117
  * @param ky
103
118
  */
119
+
104
120
  export async function getVersions(ky) {
105
- const { version, apiVersion, debugApiVersion } = await getHealth(ky);
106
- return {
107
- supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
108
- supportedBeeApiVersion: SUPPORTED_API_VERSION,
109
- supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
110
- beeVersion: version,
111
- beeApiVersion: apiVersion,
112
- beeDebugApiVersion: debugApiVersion,
113
- };
114
- }
121
+ const {
122
+ version,
123
+ apiVersion,
124
+ debugApiVersion
125
+ } = await getHealth(ky);
126
+ return {
127
+ supportedBeeVersion: SUPPORTED_BEE_VERSION_EXACT,
128
+ supportedBeeApiVersion: SUPPORTED_API_VERSION,
129
+ supportedBeeDebugApiVersion: SUPPORTED_DEBUG_API_VERSION,
130
+ beeVersion: version,
131
+ beeApiVersion: apiVersion,
132
+ beeDebugApiVersion: debugApiVersion
133
+ };
134
+ }
@@ -1,4 +1,4 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const endpoint = 'tags';
3
3
  /**
4
4
  * Retrieve tag with extended information from Bee node
@@ -6,10 +6,11 @@ const endpoint = 'tags';
6
6
  * @param ky Ky debug instance
7
7
  * @param uid UID of tag to be retrieved
8
8
  */
9
+
9
10
  export async function retrieveExtendedTag(ky, uid) {
10
- const response = await http(ky, {
11
- path: `${endpoint}/${uid}`,
12
- responseType: 'json',
13
- });
14
- return response.data;
15
- }
11
+ const response = await http(ky, {
12
+ path: `${endpoint}/${uid}`,
13
+ responseType: 'json'
14
+ });
15
+ return response.data;
16
+ }
@@ -1,16 +1,17 @@
1
- import { http } from '../../utils/http';
1
+ import { http } from "../../utils/http.js";
2
2
  const transactionsEndpoint = 'transactions';
3
3
  /**
4
4
  * Get list of all pending transactions
5
5
  *
6
6
  * @param ky Debug Ky instance
7
7
  */
8
+
8
9
  export async function getAllTransactions(ky) {
9
- const response = await http(ky, {
10
- path: transactionsEndpoint,
11
- responseType: 'json',
12
- });
13
- return response.data.pendingTransactions;
10
+ const response = await http(ky, {
11
+ path: transactionsEndpoint,
12
+ responseType: 'json'
13
+ });
14
+ return response.data.pendingTransactions;
14
15
  }
15
16
  /**
16
17
  * Get information for specific pending transactions
@@ -18,12 +19,13 @@ export async function getAllTransactions(ky) {
18
19
  * @param ky Debug Ky instance
19
20
  * @param transactionHash Hash of the transaction
20
21
  */
22
+
21
23
  export async function getTransaction(ky, transactionHash) {
22
- const response = await http(ky, {
23
- path: `${transactionsEndpoint}/${transactionHash}`,
24
- responseType: 'json',
25
- });
26
- return response.data;
24
+ const response = await http(ky, {
25
+ path: `${transactionsEndpoint}/${transactionHash}`,
26
+ responseType: 'json'
27
+ });
28
+ return response.data;
27
29
  }
28
30
  /**
29
31
  * Rebroadcast existing transaction
@@ -31,13 +33,14 @@ export async function getTransaction(ky, transactionHash) {
31
33
  * @param ky Debug Ky instance
32
34
  * @param transactionHash Hash of the transaction
33
35
  */
36
+
34
37
  export async function rebroadcastTransaction(ky, transactionHash) {
35
- const response = await http(ky, {
36
- method: 'post',
37
- path: `${transactionsEndpoint}/${transactionHash}`,
38
- responseType: 'json',
39
- });
40
- return response.data.transactionHash;
38
+ const response = await http(ky, {
39
+ method: 'post',
40
+ path: `${transactionsEndpoint}/${transactionHash}`,
41
+ responseType: 'json'
42
+ });
43
+ return response.data.transactionHash;
41
44
  }
42
45
  /**
43
46
  * Cancel existing transaction
@@ -46,12 +49,15 @@ export async function rebroadcastTransaction(ky, transactionHash) {
46
49
  * @param transactionHash Hash of the transaction
47
50
  * @param gasPrice Optional gas price
48
51
  */
52
+
49
53
  export async function cancelTransaction(ky, transactionHash, gasPrice) {
50
- const response = await http(ky, {
51
- method: 'delete',
52
- headers: { 'gas-price': gasPrice },
53
- path: `${transactionsEndpoint}/${transactionHash}`,
54
- responseType: 'json',
55
- });
56
- return response.data.transactionHash;
57
- }
54
+ const response = await http(ky, {
55
+ method: 'delete',
56
+ headers: {
57
+ 'gas-price': gasPrice
58
+ },
59
+ path: `${transactionsEndpoint}/${transactionHash}`,
60
+ responseType: 'json'
61
+ });
62
+ return response.data.transactionHash;
63
+ }
@@ -1,6 +1,6 @@
1
- import { filterHeaders, http } from '../utils/http';
2
- import { extractUploadHeaders } from '../utils/headers';
3
- import { BeeError } from '../utils/error';
1
+ import { filterHeaders, http } from "../utils/http.js";
2
+ import { extractUploadHeaders } from "../utils/headers.js";
3
+ import { BeeError } from "../utils/error.js";
4
4
  const feedEndpoint = 'feeds';
5
5
  /**
6
6
  * Create an initial feed root manifest
@@ -11,29 +11,34 @@ const feedEndpoint = 'feeds';
11
11
  * @param postageBatchId Postage BatchId to be used to create the Feed Manifest
12
12
  * @param options Additional options, like type (default: 'sequence')
13
13
  */
14
+
14
15
  export async function createFeedManifest(ky, owner, topic, postageBatchId, options) {
15
- const response = await http(ky, {
16
- method: 'post',
17
- responseType: 'json',
18
- path: `${feedEndpoint}/${owner}/${topic}`,
19
- searchParams: filterHeaders(options),
20
- headers: extractUploadHeaders(postageBatchId),
21
- });
22
- return response.data.reference;
16
+ const response = await http(ky, {
17
+ method: 'post',
18
+ responseType: 'json',
19
+ path: `${feedEndpoint}/${owner}/${topic}`,
20
+ searchParams: filterHeaders(options),
21
+ headers: extractUploadHeaders(postageBatchId)
22
+ });
23
+ return response.data.reference;
23
24
  }
25
+
24
26
  function readFeedUpdateHeaders(headers) {
25
- const feedIndex = headers.get('swarm-feed-index');
26
- const feedIndexNext = headers.get('swarm-feed-index-next');
27
- if (!feedIndex) {
28
- throw new BeeError('Response did not contain expected swarm-feed-index!');
29
- }
30
- if (!feedIndexNext) {
31
- throw new BeeError('Response did not contain expected swarm-feed-index-next!');
32
- }
33
- return {
34
- feedIndex,
35
- feedIndexNext,
36
- };
27
+ const feedIndex = headers.get('swarm-feed-index');
28
+ const feedIndexNext = headers.get('swarm-feed-index-next');
29
+
30
+ if (!feedIndex) {
31
+ throw new BeeError('Response did not contain expected swarm-feed-index!');
32
+ }
33
+
34
+ if (!feedIndexNext) {
35
+ throw new BeeError('Response did not contain expected swarm-feed-index-next!');
36
+ }
37
+
38
+ return {
39
+ feedIndex,
40
+ feedIndexNext
41
+ };
37
42
  }
38
43
  /**
39
44
  * Find and retrieve feed update
@@ -48,14 +53,15 @@ function readFeedUpdateHeaders(headers) {
48
53
  * @param topic Topic in hex
49
54
  * @param options Additional options, like index, at, type
50
55
  */
56
+
57
+
51
58
  export async function fetchFeedUpdate(ky, owner, topic, options) {
52
- const response = await http(ky, {
53
- responseType: 'json',
54
- path: `${feedEndpoint}/${owner}/${topic}`,
55
- searchParams: filterHeaders(options),
56
- });
57
- return {
58
- ...response.data,
59
- ...readFeedUpdateHeaders(response.headers),
60
- };
61
- }
59
+ const response = await http(ky, {
60
+ responseType: 'json',
61
+ path: `${feedEndpoint}/${owner}/${topic}`,
62
+ searchParams: filterHeaders(options)
63
+ });
64
+ return { ...response.data,
65
+ ...readFeedUpdateHeaders(response.headers)
66
+ };
67
+ }
@@ -1,4 +1,4 @@
1
- import { http } from '../utils/http';
1
+ import { http } from "../utils/http.js";
2
2
  const PINNING_ENDPOINT = 'pins';
3
3
  /**
4
4
  * Pin data with given reference
@@ -6,12 +6,13 @@ const PINNING_ENDPOINT = 'pins';
6
6
  * @param ky Ky instance for given Bee class instance
7
7
  * @param reference Bee data reference
8
8
  */
9
+
9
10
  export async function pin(ky, reference) {
10
- await http(ky, {
11
- method: 'post',
12
- responseType: 'json',
13
- path: `${PINNING_ENDPOINT}/${reference}`,
14
- });
11
+ await http(ky, {
12
+ method: 'post',
13
+ responseType: 'json',
14
+ path: `${PINNING_ENDPOINT}/${reference}`
15
+ });
15
16
  }
16
17
  /**
17
18
  * Unpin data with given reference
@@ -19,12 +20,13 @@ export async function pin(ky, reference) {
19
20
  * @param ky Ky instance for given Bee class instance
20
21
  * @param reference Bee data reference
21
22
  */
23
+
22
24
  export async function unpin(ky, reference) {
23
- await http(ky, {
24
- method: 'delete',
25
- responseType: 'json',
26
- path: `${PINNING_ENDPOINT}/${reference}`,
27
- });
25
+ await http(ky, {
26
+ method: 'delete',
27
+ responseType: 'json',
28
+ path: `${PINNING_ENDPOINT}/${reference}`
29
+ });
28
30
  }
29
31
  /**
30
32
  * Get pin status for specific address.
@@ -33,28 +35,32 @@ export async function unpin(ky, reference) {
33
35
  * @param reference
34
36
  * @throws Error if given address is not pinned
35
37
  */
38
+
36
39
  export async function getPin(ky, reference) {
37
- const response = await http(ky, {
38
- method: 'get',
39
- responseType: 'json',
40
- path: `${PINNING_ENDPOINT}/${reference}`,
41
- });
42
- return response.data;
40
+ const response = await http(ky, {
41
+ method: 'get',
42
+ responseType: 'json',
43
+ path: `${PINNING_ENDPOINT}/${reference}`
44
+ });
45
+ return response.data;
43
46
  }
44
47
  /**
45
48
  * Get list of all pins
46
49
  *
47
50
  * @param ky Ky instance
48
51
  */
52
+
49
53
  export async function getAllPins(ky) {
50
- const response = await http(ky, {
51
- method: 'get',
52
- responseType: 'json',
53
- path: `${PINNING_ENDPOINT}`,
54
- });
55
- const result = response.data.references;
56
- if (result === null) {
57
- return [];
58
- }
59
- return result;
60
- }
54
+ const response = await http(ky, {
55
+ method: 'get',
56
+ responseType: 'json',
57
+ path: `${PINNING_ENDPOINT}`
58
+ });
59
+ const result = response.data.references;
60
+
61
+ if (result === null) {
62
+ return [];
63
+ }
64
+
65
+ return result;
66
+ }
@@ -1,7 +1,7 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { prepareData } from '../utils/data';
3
- import { http } from '../utils/http';
4
- import { extractUploadHeaders } from '../utils/headers';
2
+ import { prepareData } from "../utils/data.js";
3
+ import { http } from "../utils/http.js";
4
+ import { extractUploadHeaders } from "../utils/headers.js";
5
5
  const endpoint = 'pss';
6
6
  /**
7
7
  * Send to recipient or target with Postal Service for Swarm
@@ -14,15 +14,18 @@ const endpoint = 'pss';
14
14
  * @param recipient Recipient public key
15
15
  *
16
16
  */
17
+
17
18
  export async function send(ky, topic, target, data, postageBatchId, recipient) {
18
- await http(ky, {
19
- method: 'post',
20
- path: `${endpoint}/send/${topic}/${target}`,
21
- body: await prepareData(data),
22
- responseType: 'json',
23
- searchParams: { recipient },
24
- headers: extractUploadHeaders(postageBatchId),
25
- });
19
+ await http(ky, {
20
+ method: 'post',
21
+ path: `${endpoint}/send/${topic}/${target}`,
22
+ body: await prepareData(data),
23
+ responseType: 'json',
24
+ searchParams: {
25
+ recipient
26
+ },
27
+ headers: extractUploadHeaders(postageBatchId)
28
+ });
26
29
  }
27
30
  /**
28
31
  * Subscribe for messages on the given topic
@@ -30,7 +33,8 @@ export async function send(ky, topic, target, data, postageBatchId, recipient) {
30
33
  * @param url Bee node URL
31
34
  * @param topic Topic name
32
35
  */
36
+
33
37
  export function subscribe(url, topic) {
34
- const wsUrl = url.replace(/^http/i, 'ws');
35
- return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic}`);
36
- }
38
+ const wsUrl = url.replace(/^http/i, 'ws');
39
+ return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic}`);
40
+ }
@@ -1,5 +1,5 @@
1
- import { extractUploadHeaders } from '../utils/headers';
2
- import { http } from '../utils/http';
1
+ import { extractUploadHeaders } from "../utils/headers.js";
2
+ import { http } from "../utils/http.js";
3
3
  const socEndpoint = 'soc';
4
4
  /**
5
5
  * Upload single owner chunk (SOC) to a Bee node
@@ -12,17 +12,20 @@ const socEndpoint = 'soc';
12
12
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
13
13
  * @param options Additional options like tag, encryption, pinning
14
14
  */
15
+
15
16
  export async function upload(ky, owner, identifier, signature, data, postageBatchId, options) {
16
- const response = await http(ky, {
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: { sig: signature },
26
- });
27
- return response.data.reference;
28
- }
17
+ const response = await http(ky, {
18
+ method: 'post',
19
+ path: `${socEndpoint}/${owner}/${identifier}`,
20
+ body: data,
21
+ headers: {
22
+ 'content-type': 'application/octet-stream',
23
+ ...extractUploadHeaders(postageBatchId, options)
24
+ },
25
+ responseType: 'json',
26
+ searchParams: {
27
+ sig: signature
28
+ }
29
+ });
30
+ return response.data.reference;
31
+ }
@@ -1,11 +1,12 @@
1
- import { http } from '../utils/http';
1
+ import { http } from "../utils/http.js";
2
2
  /**
3
3
  * Ping the base bee URL. If connection was not successful throw error
4
4
  *
5
5
  * @param ky Ky instance for given Bee class instance
6
6
  */
7
+
7
8
  export async function checkConnection(ky) {
8
- await http(ky, {
9
- path: '',
10
- });
11
- }
9
+ await http(ky, {
10
+ path: ''
11
+ });
12
+ }
@@ -1,4 +1,4 @@
1
- import { http } from '../utils/http';
1
+ import { http } from "../utils/http.js";
2
2
  const stewardshipEndpoint = 'stewardship';
3
3
  /**
4
4
  * Reupload locally pinned data
@@ -7,17 +7,18 @@ const stewardshipEndpoint = 'stewardship';
7
7
  * @param options
8
8
  * @throws BeeResponseError if not locally pinned or invalid data
9
9
  */
10
+
10
11
  export async function reupload(ky, reference) {
11
- await http(ky, {
12
- method: 'put',
13
- path: `${stewardshipEndpoint}/${reference}`,
14
- });
12
+ await http(ky, {
13
+ method: 'put',
14
+ path: `${stewardshipEndpoint}/${reference}`
15
+ });
15
16
  }
16
17
  export async function isRetrievable(ky, reference) {
17
- const response = await http(ky, {
18
- method: 'get',
19
- responseType: 'json',
20
- path: `${stewardshipEndpoint}/${reference}`,
21
- });
22
- return response.data.isRetrievable;
23
- }
18
+ const response = await http(ky, {
19
+ method: 'get',
20
+ responseType: 'json',
21
+ path: `${stewardshipEndpoint}/${reference}`
22
+ });
23
+ return response.data.isRetrievable;
24
+ }