@ethersphere/bee-js 5.2.0 → 6.0.0-pre.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.
- package/dist/cjs/bee-debug.js +58 -72
- package/dist/cjs/bee.js +71 -86
- package/dist/cjs/chunk/soc.js +14 -14
- package/dist/cjs/feed/index.js +20 -21
- package/dist/cjs/feed/json.js +2 -2
- package/dist/cjs/feed/retrievable.js +7 -8
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/modules/bytes.js +15 -15
- package/dist/cjs/modules/bzz.js +24 -25
- package/dist/cjs/modules/chunk.js +10 -10
- package/dist/cjs/modules/debug/balance.js +16 -16
- package/dist/cjs/modules/debug/chequebook.js +34 -34
- package/dist/cjs/modules/debug/chunk.js +8 -8
- package/dist/cjs/modules/debug/connectivity.js +24 -24
- package/dist/cjs/modules/debug/settlements.js +8 -8
- package/dist/cjs/modules/debug/stake.js +11 -11
- package/dist/cjs/modules/debug/stamps.js +25 -25
- package/dist/cjs/modules/debug/states.js +12 -12
- package/dist/cjs/modules/debug/status.js +24 -24
- package/dist/cjs/modules/debug/tag.js +4 -4
- package/dist/cjs/modules/debug/transactions.js +16 -16
- package/dist/cjs/modules/feed.js +14 -14
- package/dist/cjs/modules/pinning.js +14 -14
- package/dist/cjs/modules/pss.js +6 -6
- package/dist/cjs/modules/soc.js +6 -6
- package/dist/cjs/modules/status.js +3 -3
- package/dist/cjs/modules/stewardship.js +7 -7
- package/dist/cjs/modules/tag.js +20 -20
- package/dist/cjs/utils/error.js +1 -35
- package/dist/cjs/utils/headers.js +3 -3
- package/dist/cjs/utils/http.js +14 -141
- package/dist/cjs/utils/type.js +1 -4
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +0 -8
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +59 -73
- package/dist/mjs/bee.js +72 -87
- package/dist/mjs/chunk/soc.js +14 -14
- package/dist/mjs/feed/index.js +20 -21
- package/dist/mjs/feed/json.js +2 -2
- package/dist/mjs/feed/retrievable.js +7 -8
- package/dist/mjs/index.js +2 -2
- package/dist/mjs/modules/bytes.js +15 -15
- package/dist/mjs/modules/bzz.js +24 -25
- package/dist/mjs/modules/chunk.js +10 -10
- package/dist/mjs/modules/debug/balance.js +16 -16
- package/dist/mjs/modules/debug/chequebook.js +34 -34
- package/dist/mjs/modules/debug/chunk.js +8 -8
- package/dist/mjs/modules/debug/connectivity.js +24 -24
- package/dist/mjs/modules/debug/settlements.js +8 -8
- package/dist/mjs/modules/debug/stake.js +11 -11
- package/dist/mjs/modules/debug/stamps.js +25 -25
- package/dist/mjs/modules/debug/states.js +12 -12
- package/dist/mjs/modules/debug/status.js +24 -25
- package/dist/mjs/modules/debug/tag.js +4 -4
- package/dist/mjs/modules/debug/transactions.js +16 -16
- package/dist/mjs/modules/feed.js +14 -14
- package/dist/mjs/modules/pinning.js +14 -14
- package/dist/mjs/modules/pss.js +6 -6
- package/dist/mjs/modules/soc.js +6 -6
- package/dist/mjs/modules/status.js +3 -3
- package/dist/mjs/modules/stewardship.js +7 -7
- package/dist/mjs/modules/tag.js +20 -20
- package/dist/mjs/utils/error.js +0 -31
- package/dist/mjs/utils/headers.js +3 -3
- package/dist/mjs/utils/http.js +10 -138
- package/dist/mjs/utils/type.js +2 -5
- package/dist/types/bee-debug.d.ts +50 -50
- package/dist/types/bee.d.ts +34 -34
- package/dist/types/chunk/soc.d.ts +5 -6
- package/dist/types/feed/index.d.ts +7 -8
- package/dist/types/feed/json.d.ts +2 -2
- package/dist/types/feed/retrievable.d.ts +2 -2
- package/dist/types/index.d.ts +2 -4
- package/dist/types/modules/bytes.d.ts +4 -5
- package/dist/types/modules/bzz.d.ts +5 -6
- package/dist/types/modules/chunk.d.ts +3 -4
- package/dist/types/modules/debug/balance.d.ts +5 -6
- package/dist/types/modules/debug/chequebook.d.ts +9 -10
- package/dist/types/modules/debug/chunk.d.ts +3 -4
- package/dist/types/modules/debug/connectivity.d.ts +7 -8
- package/dist/types/modules/debug/settlements.d.ts +3 -4
- package/dist/types/modules/debug/stake.d.ts +4 -5
- package/dist/types/modules/debug/stamps.d.ts +7 -8
- package/dist/types/modules/debug/states.d.ts +4 -5
- package/dist/types/modules/debug/status.d.ts +10 -10
- package/dist/types/modules/debug/tag.d.ts +2 -3
- package/dist/types/modules/debug/transactions.d.ts +5 -6
- package/dist/types/modules/feed.d.ts +3 -4
- package/dist/types/modules/pinning.d.ts +5 -6
- package/dist/types/modules/pss.d.ts +2 -3
- package/dist/types/modules/soc.d.ts +2 -3
- package/dist/types/modules/status.d.ts +2 -2
- package/dist/types/modules/stewardship.d.ts +3 -4
- package/dist/types/modules/tag.d.ts +6 -7
- package/dist/types/types/debug.d.ts +2 -2
- package/dist/types/types/index.d.ts +12 -51
- package/dist/types/utils/error.d.ts +0 -26
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/http.d.ts +12 -21
- package/dist/types/utils/type.d.ts +2 -2
- package/package.json +4 -4
- package/dist/223.index.browser.min.js +0 -3
- package/dist/223.index.browser.min.js.LICENSE.txt +0 -1
- package/dist/223.index.browser.min.js.map +0 -1
- package/dist/cjs/utils/merge.js +0 -34
- package/dist/cjs/utils/sleep.js +0 -12
- package/dist/mjs/utils/merge.js +0 -32
- package/dist/mjs/utils/sleep.js +0 -8
- package/dist/types/utils/merge.d.ts +0 -8
- package/dist/types/utils/sleep.d.ts +0 -6
|
@@ -9,12 +9,12 @@ const settlementsEndpoint = 'settlements';
|
|
|
9
9
|
* @param kyOptions Ky Options for making requests
|
|
10
10
|
* @param peer Swarm address of peer
|
|
11
11
|
*/
|
|
12
|
-
async function getSettlements(
|
|
13
|
-
const response = await (0, http_1.http)(
|
|
14
|
-
|
|
12
|
+
async function getSettlements(requestOptions, peer) {
|
|
13
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
14
|
+
url: `${settlementsEndpoint}/${peer}`,
|
|
15
15
|
responseType: 'json',
|
|
16
16
|
});
|
|
17
|
-
return response.
|
|
17
|
+
return response.data;
|
|
18
18
|
}
|
|
19
19
|
exports.getSettlements = getSettlements;
|
|
20
20
|
/**
|
|
@@ -22,11 +22,11 @@ exports.getSettlements = getSettlements;
|
|
|
22
22
|
*
|
|
23
23
|
* @param kyOptions Ky Options for making requests
|
|
24
24
|
*/
|
|
25
|
-
async function getAllSettlements(
|
|
26
|
-
const response = await (0, http_1.http)(
|
|
27
|
-
|
|
25
|
+
async function getAllSettlements(requestOptions) {
|
|
26
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
27
|
+
url: settlementsEndpoint,
|
|
28
28
|
responseType: 'json',
|
|
29
29
|
});
|
|
30
|
-
return response.
|
|
30
|
+
return response.data;
|
|
31
31
|
}
|
|
32
32
|
exports.getAllSettlements = getAllSettlements;
|
|
@@ -9,13 +9,13 @@ const REDISTRIBUTION_ENDPOINT = 'redistributionstate';
|
|
|
9
9
|
*
|
|
10
10
|
* @param kyOptions Ky Options for making requests
|
|
11
11
|
*/
|
|
12
|
-
async function getStake(
|
|
13
|
-
const response = await (0, http_1.http)(
|
|
12
|
+
async function getStake(requestOptions) {
|
|
13
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
14
14
|
method: 'get',
|
|
15
15
|
responseType: 'json',
|
|
16
|
-
|
|
16
|
+
url: `${STAKE_ENDPOINT}`,
|
|
17
17
|
});
|
|
18
|
-
return response.
|
|
18
|
+
return response.data.stakedAmount.toString();
|
|
19
19
|
}
|
|
20
20
|
exports.getStake = getStake;
|
|
21
21
|
/**
|
|
@@ -25,7 +25,7 @@ exports.getStake = getStake;
|
|
|
25
25
|
* @param amount
|
|
26
26
|
* @param options
|
|
27
27
|
*/
|
|
28
|
-
async function stake(
|
|
28
|
+
async function stake(requestOptions, amount, options) {
|
|
29
29
|
const headers = {};
|
|
30
30
|
if (options?.gasPrice) {
|
|
31
31
|
headers['gas-price'] = options.gasPrice.toString();
|
|
@@ -33,10 +33,10 @@ async function stake(kyOptions, amount, options) {
|
|
|
33
33
|
if (options?.gasLimit) {
|
|
34
34
|
headers['gas-limit'] = options.gasLimit.toString();
|
|
35
35
|
}
|
|
36
|
-
await (0, http_1.http)(
|
|
36
|
+
await (0, http_1.http)(requestOptions, {
|
|
37
37
|
method: 'post',
|
|
38
38
|
responseType: 'json',
|
|
39
|
-
|
|
39
|
+
url: `${STAKE_ENDPOINT}/${amount}`,
|
|
40
40
|
headers,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -46,12 +46,12 @@ exports.stake = stake;
|
|
|
46
46
|
*
|
|
47
47
|
* @param kyOptions Ky Options for making requests
|
|
48
48
|
*/
|
|
49
|
-
async function getRedistributionState(
|
|
50
|
-
const response = await (0, http_1.http)(
|
|
49
|
+
async function getRedistributionState(requestOptions) {
|
|
50
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
51
51
|
method: 'get',
|
|
52
52
|
responseType: 'json',
|
|
53
|
-
|
|
53
|
+
url: REDISTRIBUTION_ENDPOINT,
|
|
54
54
|
});
|
|
55
|
-
return response.
|
|
55
|
+
return response.data;
|
|
56
56
|
}
|
|
57
57
|
exports.getRedistributionState = getRedistributionState;
|
|
@@ -3,34 +3,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.diluteBatch = exports.topUpBatch = exports.createPostageBatch = exports.getPostageBatchBuckets = exports.getPostageBatch = exports.getAllPostageBatches = void 0;
|
|
4
4
|
const http_1 = require("../../utils/http");
|
|
5
5
|
const STAMPS_ENDPOINT = 'stamps';
|
|
6
|
-
async function getAllPostageBatches(
|
|
7
|
-
const response = await (0, http_1.http)(
|
|
6
|
+
async function getAllPostageBatches(requestOptions) {
|
|
7
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
8
8
|
method: 'get',
|
|
9
|
-
|
|
9
|
+
url: `${STAMPS_ENDPOINT}`,
|
|
10
10
|
responseType: 'json',
|
|
11
11
|
});
|
|
12
|
-
return response.
|
|
12
|
+
return response.data.stamps;
|
|
13
13
|
}
|
|
14
14
|
exports.getAllPostageBatches = getAllPostageBatches;
|
|
15
|
-
async function getPostageBatch(
|
|
16
|
-
const response = await (0, http_1.http)(
|
|
15
|
+
async function getPostageBatch(requestOptions, postageBatchId) {
|
|
16
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
17
17
|
method: 'get',
|
|
18
|
-
|
|
18
|
+
url: `${STAMPS_ENDPOINT}/${postageBatchId}`,
|
|
19
19
|
responseType: 'json',
|
|
20
20
|
});
|
|
21
|
-
return response.
|
|
21
|
+
return response.data;
|
|
22
22
|
}
|
|
23
23
|
exports.getPostageBatch = getPostageBatch;
|
|
24
|
-
async function getPostageBatchBuckets(
|
|
25
|
-
const response = await (0, http_1.http)(
|
|
24
|
+
async function getPostageBatchBuckets(requestOptions, postageBatchId) {
|
|
25
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
26
26
|
method: 'get',
|
|
27
|
-
|
|
27
|
+
url: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
|
|
28
28
|
responseType: 'json',
|
|
29
29
|
});
|
|
30
|
-
return response.
|
|
30
|
+
return response.data;
|
|
31
31
|
}
|
|
32
32
|
exports.getPostageBatchBuckets = getPostageBatchBuckets;
|
|
33
|
-
async function createPostageBatch(
|
|
33
|
+
async function createPostageBatch(requestOptions, amount, depth, options) {
|
|
34
34
|
const headers = {};
|
|
35
35
|
if (options?.gasPrice) {
|
|
36
36
|
headers['gas-price'] = options.gasPrice.toString();
|
|
@@ -38,31 +38,31 @@ async function createPostageBatch(kyOptions, amount, depth, options) {
|
|
|
38
38
|
if (options?.immutableFlag !== undefined) {
|
|
39
39
|
headers.immutable = String(options.immutableFlag);
|
|
40
40
|
}
|
|
41
|
-
const response = await (0, http_1.http)(
|
|
41
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
42
42
|
method: 'post',
|
|
43
|
-
|
|
43
|
+
url: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
|
|
44
44
|
responseType: 'json',
|
|
45
|
-
|
|
45
|
+
params: { label: options?.label },
|
|
46
46
|
headers,
|
|
47
47
|
});
|
|
48
|
-
return response.
|
|
48
|
+
return response.data.batchID;
|
|
49
49
|
}
|
|
50
50
|
exports.createPostageBatch = createPostageBatch;
|
|
51
|
-
async function topUpBatch(
|
|
52
|
-
const response = await (0, http_1.http)(
|
|
51
|
+
async function topUpBatch(requestOptions, id, amount) {
|
|
52
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
53
53
|
method: 'patch',
|
|
54
|
-
|
|
54
|
+
url: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
|
|
55
55
|
responseType: 'json',
|
|
56
56
|
});
|
|
57
|
-
return response.
|
|
57
|
+
return response.data.batchID;
|
|
58
58
|
}
|
|
59
59
|
exports.topUpBatch = topUpBatch;
|
|
60
|
-
async function diluteBatch(
|
|
61
|
-
const response = await (0, http_1.http)(
|
|
60
|
+
async function diluteBatch(requestOptions, id, depth) {
|
|
61
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
62
62
|
method: 'patch',
|
|
63
|
-
|
|
63
|
+
url: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
|
|
64
64
|
responseType: 'json',
|
|
65
65
|
});
|
|
66
|
-
return response.
|
|
66
|
+
return response.data.batchID;
|
|
67
67
|
}
|
|
68
68
|
exports.diluteBatch = diluteBatch;
|
|
@@ -10,13 +10,13 @@ const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
|
10
10
|
*
|
|
11
11
|
* @param kyOptions Ky Options for making requests
|
|
12
12
|
*/
|
|
13
|
-
async function getReserveState(
|
|
14
|
-
const response = await (0, http_1.http)(
|
|
13
|
+
async function getReserveState(requestOptions) {
|
|
14
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
15
15
|
method: 'get',
|
|
16
|
-
|
|
16
|
+
url: `${RESERVE_STATE_ENDPOINT}`,
|
|
17
17
|
responseType: 'json',
|
|
18
18
|
});
|
|
19
|
-
return response.
|
|
19
|
+
return response.data;
|
|
20
20
|
}
|
|
21
21
|
exports.getReserveState = getReserveState;
|
|
22
22
|
/**
|
|
@@ -24,13 +24,13 @@ exports.getReserveState = getReserveState;
|
|
|
24
24
|
*
|
|
25
25
|
* @param kyOptions Ky Options for making requests
|
|
26
26
|
*/
|
|
27
|
-
async function getChainState(
|
|
28
|
-
const response = await (0, http_1.http)(
|
|
27
|
+
async function getChainState(requestOptions) {
|
|
28
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
29
29
|
method: 'get',
|
|
30
|
-
|
|
30
|
+
url: `${CHAIN_STATE_ENDPOINT}`,
|
|
31
31
|
responseType: 'json',
|
|
32
32
|
});
|
|
33
|
-
return response.
|
|
33
|
+
return response.data;
|
|
34
34
|
}
|
|
35
35
|
exports.getChainState = getChainState;
|
|
36
36
|
/**
|
|
@@ -38,13 +38,13 @@ exports.getChainState = getChainState;
|
|
|
38
38
|
*
|
|
39
39
|
* @param kyOptions Ky Options for making requests
|
|
40
40
|
*/
|
|
41
|
-
async function getWalletBalance(
|
|
42
|
-
const response = await (0, http_1.http)(
|
|
41
|
+
async function getWalletBalance(requestOptions) {
|
|
42
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
43
43
|
method: 'get',
|
|
44
|
-
|
|
44
|
+
url: `${WALLET_ENDPOINT}`,
|
|
45
45
|
responseType: 'json',
|
|
46
46
|
});
|
|
47
|
-
return mapWalletProperties(response.
|
|
47
|
+
return mapWalletProperties(response.data);
|
|
48
48
|
}
|
|
49
49
|
exports.getWalletBalance = getWalletBalance;
|
|
50
50
|
/**
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getReadiness = exports.getHealth = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
7
|
-
const http_1 = require("../../utils/http");
|
|
8
7
|
const major_js_1 = __importDefault(require("semver/functions/major.js"));
|
|
8
|
+
const http_1 = require("../../utils/http");
|
|
9
9
|
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
10
10
|
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
11
11
|
exports.SUPPORTED_BEE_VERSION_EXACT = '1.12.0-88c1d236';
|
|
@@ -20,13 +20,13 @@ const READINESS_URL = 'readiness';
|
|
|
20
20
|
*
|
|
21
21
|
* @param kyOptions Ky Options for making requests
|
|
22
22
|
*/
|
|
23
|
-
async function getHealth(
|
|
24
|
-
const response = await (0, http_1.http)(
|
|
23
|
+
async function getHealth(requestOptions) {
|
|
24
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
25
25
|
method: 'get',
|
|
26
|
-
|
|
26
|
+
url: HEALTH_URL,
|
|
27
27
|
responseType: 'json',
|
|
28
28
|
});
|
|
29
|
-
return response.
|
|
29
|
+
return response.data;
|
|
30
30
|
}
|
|
31
31
|
exports.getHealth = getHealth;
|
|
32
32
|
/**
|
|
@@ -34,11 +34,11 @@ exports.getHealth = getHealth;
|
|
|
34
34
|
*
|
|
35
35
|
* @param kyOptions Ky Options for making requests
|
|
36
36
|
*/
|
|
37
|
-
async function getReadiness(
|
|
37
|
+
async function getReadiness(requestOptions) {
|
|
38
38
|
try {
|
|
39
|
-
const response = await (0, http_1.http)(
|
|
39
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
40
40
|
method: 'get',
|
|
41
|
-
|
|
41
|
+
url: READINESS_URL,
|
|
42
42
|
});
|
|
43
43
|
return response.status === 200;
|
|
44
44
|
}
|
|
@@ -52,13 +52,13 @@ exports.getReadiness = getReadiness;
|
|
|
52
52
|
*
|
|
53
53
|
* @param kyOptions Ky Options for making requests
|
|
54
54
|
*/
|
|
55
|
-
async function getNodeInfo(
|
|
56
|
-
const response = await (0, http_1.http)(
|
|
55
|
+
async function getNodeInfo(requestOptions) {
|
|
56
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
57
57
|
method: 'get',
|
|
58
|
-
|
|
58
|
+
url: NODE_INFO_URL,
|
|
59
59
|
responseType: 'json',
|
|
60
60
|
});
|
|
61
|
-
return response.
|
|
61
|
+
return response.data;
|
|
62
62
|
}
|
|
63
63
|
exports.getNodeInfo = getNodeInfo;
|
|
64
64
|
/**
|
|
@@ -70,8 +70,8 @@ exports.getNodeInfo = getNodeInfo;
|
|
|
70
70
|
* @deprecated Use `isSupportedExactVersion` instead
|
|
71
71
|
*/
|
|
72
72
|
// TODO: Remove on break
|
|
73
|
-
async function isSupportedVersion(
|
|
74
|
-
return isSupportedExactVersion(
|
|
73
|
+
async function isSupportedVersion(requestOptions) {
|
|
74
|
+
return isSupportedExactVersion(requestOptions);
|
|
75
75
|
}
|
|
76
76
|
exports.isSupportedVersion = isSupportedVersion;
|
|
77
77
|
/**
|
|
@@ -84,8 +84,8 @@ exports.isSupportedVersion = isSupportedVersion;
|
|
|
84
84
|
*
|
|
85
85
|
* @param ky
|
|
86
86
|
*/
|
|
87
|
-
async function isSupportedExactVersion(
|
|
88
|
-
const { version } = await getHealth(
|
|
87
|
+
async function isSupportedExactVersion(requestOptions) {
|
|
88
|
+
const { version } = await getHealth(requestOptions);
|
|
89
89
|
return version === exports.SUPPORTED_BEE_VERSION_EXACT;
|
|
90
90
|
}
|
|
91
91
|
exports.isSupportedExactVersion = isSupportedExactVersion;
|
|
@@ -97,8 +97,8 @@ exports.isSupportedExactVersion = isSupportedExactVersion;
|
|
|
97
97
|
*
|
|
98
98
|
* @param ky
|
|
99
99
|
*/
|
|
100
|
-
async function isSupportedMainApiVersion(
|
|
101
|
-
const { apiVersion } = await getHealth(
|
|
100
|
+
async function isSupportedMainApiVersion(requestOptions) {
|
|
101
|
+
const { apiVersion } = await getHealth(requestOptions);
|
|
102
102
|
return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
|
|
103
103
|
}
|
|
104
104
|
exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
|
|
@@ -110,8 +110,8 @@ exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
|
|
|
110
110
|
*
|
|
111
111
|
* @param ky
|
|
112
112
|
*/
|
|
113
|
-
async function isSupportedDebugApiVersion(
|
|
114
|
-
const { debugApiVersion } = await getHealth(
|
|
113
|
+
async function isSupportedDebugApiVersion(requestOptions) {
|
|
114
|
+
const { debugApiVersion } = await getHealth(requestOptions);
|
|
115
115
|
return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
|
|
116
116
|
}
|
|
117
117
|
exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
|
|
@@ -122,8 +122,8 @@ exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
|
|
|
122
122
|
*
|
|
123
123
|
* @param ky
|
|
124
124
|
*/
|
|
125
|
-
async function isSupportedApiVersion(
|
|
126
|
-
const { apiVersion, debugApiVersion } = await getHealth(
|
|
125
|
+
async function isSupportedApiVersion(requestOptions) {
|
|
126
|
+
const { apiVersion, debugApiVersion } = await getHealth(requestOptions);
|
|
127
127
|
return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
|
|
128
128
|
(0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
|
|
129
129
|
}
|
|
@@ -134,8 +134,8 @@ exports.isSupportedApiVersion = isSupportedApiVersion;
|
|
|
134
134
|
*
|
|
135
135
|
* @param ky
|
|
136
136
|
*/
|
|
137
|
-
async function getVersions(
|
|
138
|
-
const { version, apiVersion, debugApiVersion } = await getHealth(
|
|
137
|
+
async function getVersions(requestOptions) {
|
|
138
|
+
const { version, apiVersion, debugApiVersion } = await getHealth(requestOptions);
|
|
139
139
|
return {
|
|
140
140
|
supportedBeeVersion: exports.SUPPORTED_BEE_VERSION_EXACT,
|
|
141
141
|
supportedBeeApiVersion: exports.SUPPORTED_API_VERSION,
|
|
@@ -9,11 +9,11 @@ const endpoint = 'tags';
|
|
|
9
9
|
* @param kyOptions Ky Options for making requests
|
|
10
10
|
* @param uid UID of tag to be retrieved
|
|
11
11
|
*/
|
|
12
|
-
async function retrieveExtendedTag(
|
|
13
|
-
const response = await (0, http_1.http)(
|
|
14
|
-
|
|
12
|
+
async function retrieveExtendedTag(requestOptions, uid) {
|
|
13
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
14
|
+
url: `${endpoint}/${uid}`,
|
|
15
15
|
responseType: 'json',
|
|
16
16
|
});
|
|
17
|
-
return response.
|
|
17
|
+
return response.data;
|
|
18
18
|
}
|
|
19
19
|
exports.retrieveExtendedTag = retrieveExtendedTag;
|
|
@@ -8,12 +8,12 @@ const transactionsEndpoint = 'transactions';
|
|
|
8
8
|
*
|
|
9
9
|
* @param ky Debug Ky instance
|
|
10
10
|
*/
|
|
11
|
-
async function getAllTransactions(
|
|
12
|
-
const response = await (0, http_1.http)(
|
|
13
|
-
|
|
11
|
+
async function getAllTransactions(requestOptions) {
|
|
12
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
13
|
+
url: transactionsEndpoint,
|
|
14
14
|
responseType: 'json',
|
|
15
15
|
});
|
|
16
|
-
return response.
|
|
16
|
+
return response.data.pendingTransactions;
|
|
17
17
|
}
|
|
18
18
|
exports.getAllTransactions = getAllTransactions;
|
|
19
19
|
/**
|
|
@@ -22,12 +22,12 @@ exports.getAllTransactions = getAllTransactions;
|
|
|
22
22
|
* @param ky Debug Ky instance
|
|
23
23
|
* @param transactionHash Hash of the transaction
|
|
24
24
|
*/
|
|
25
|
-
async function getTransaction(
|
|
26
|
-
const response = await (0, http_1.http)(
|
|
27
|
-
|
|
25
|
+
async function getTransaction(requestOptions, transactionHash) {
|
|
26
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
27
|
+
url: `${transactionsEndpoint}/${transactionHash}`,
|
|
28
28
|
responseType: 'json',
|
|
29
29
|
});
|
|
30
|
-
return response.
|
|
30
|
+
return response.data;
|
|
31
31
|
}
|
|
32
32
|
exports.getTransaction = getTransaction;
|
|
33
33
|
/**
|
|
@@ -36,13 +36,13 @@ exports.getTransaction = getTransaction;
|
|
|
36
36
|
* @param ky Debug Ky instance
|
|
37
37
|
* @param transactionHash Hash of the transaction
|
|
38
38
|
*/
|
|
39
|
-
async function rebroadcastTransaction(
|
|
40
|
-
const response = await (0, http_1.http)(
|
|
39
|
+
async function rebroadcastTransaction(requestOptions, transactionHash) {
|
|
40
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
41
41
|
method: 'post',
|
|
42
|
-
|
|
42
|
+
url: `${transactionsEndpoint}/${transactionHash}`,
|
|
43
43
|
responseType: 'json',
|
|
44
44
|
});
|
|
45
|
-
return response.
|
|
45
|
+
return response.data.transactionHash;
|
|
46
46
|
}
|
|
47
47
|
exports.rebroadcastTransaction = rebroadcastTransaction;
|
|
48
48
|
/**
|
|
@@ -52,13 +52,13 @@ exports.rebroadcastTransaction = rebroadcastTransaction;
|
|
|
52
52
|
* @param transactionHash Hash of the transaction
|
|
53
53
|
* @param gasPrice Optional gas price
|
|
54
54
|
*/
|
|
55
|
-
async function cancelTransaction(
|
|
56
|
-
const response = await (0, http_1.http)(
|
|
55
|
+
async function cancelTransaction(requestOptions, transactionHash, gasPrice) {
|
|
56
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
57
57
|
method: 'delete',
|
|
58
58
|
headers: { 'gas-price': gasPrice },
|
|
59
|
-
|
|
59
|
+
url: `${transactionsEndpoint}/${transactionHash}`,
|
|
60
60
|
responseType: 'json',
|
|
61
61
|
});
|
|
62
|
-
return response.
|
|
62
|
+
return response.data.transactionHash;
|
|
63
63
|
}
|
|
64
64
|
exports.cancelTransaction = cancelTransaction;
|
package/dist/cjs/modules/feed.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchLatestFeedUpdate = exports.createFeedManifest = void 0;
|
|
4
|
-
const http_1 = require("../utils/http");
|
|
5
|
-
const headers_1 = require("../utils/headers");
|
|
6
4
|
const error_1 = require("../utils/error");
|
|
5
|
+
const headers_1 = require("../utils/headers");
|
|
6
|
+
const http_1 = require("../utils/http");
|
|
7
7
|
const feedEndpoint = 'feeds';
|
|
8
8
|
/**
|
|
9
9
|
* Create an initial feed root manifest
|
|
@@ -14,20 +14,20 @@ const feedEndpoint = 'feeds';
|
|
|
14
14
|
* @param postageBatchId Postage BatchId to be used to create the Feed Manifest
|
|
15
15
|
* @param options Additional options, like type (default: 'sequence')
|
|
16
16
|
*/
|
|
17
|
-
async function createFeedManifest(
|
|
18
|
-
const response = await (0, http_1.http)(
|
|
17
|
+
async function createFeedManifest(requestOptions, owner, topic, postageBatchId, options) {
|
|
18
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
19
19
|
method: 'post',
|
|
20
20
|
responseType: 'json',
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
url: `${feedEndpoint}/${owner}/${topic}`,
|
|
22
|
+
params: options,
|
|
23
23
|
headers: (0, headers_1.extractUploadHeaders)(postageBatchId),
|
|
24
24
|
});
|
|
25
|
-
return response.
|
|
25
|
+
return response.data.reference;
|
|
26
26
|
}
|
|
27
27
|
exports.createFeedManifest = createFeedManifest;
|
|
28
28
|
function readFeedUpdateHeaders(headers) {
|
|
29
|
-
const feedIndex = headers
|
|
30
|
-
const feedIndexNext = headers
|
|
29
|
+
const feedIndex = headers['swarm-feed-index'];
|
|
30
|
+
const feedIndexNext = headers['swarm-feed-index-next'];
|
|
31
31
|
if (!feedIndex) {
|
|
32
32
|
throw new error_1.BeeError('Response did not contain expected swarm-feed-index!');
|
|
33
33
|
}
|
|
@@ -52,14 +52,14 @@ function readFeedUpdateHeaders(headers) {
|
|
|
52
52
|
* @param topic Topic in hex
|
|
53
53
|
* @param options Additional options, like index, at, type
|
|
54
54
|
*/
|
|
55
|
-
async function fetchLatestFeedUpdate(
|
|
56
|
-
const response = await (0, http_1.http)(
|
|
55
|
+
async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
|
|
56
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
57
57
|
responseType: 'json',
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
url: `${feedEndpoint}/${owner}/${topic}`,
|
|
59
|
+
params: options,
|
|
60
60
|
});
|
|
61
61
|
return {
|
|
62
|
-
...response.
|
|
62
|
+
...response.data,
|
|
63
63
|
...readFeedUpdateHeaders(response.headers),
|
|
64
64
|
};
|
|
65
65
|
}
|
|
@@ -9,11 +9,11 @@ const PINNING_ENDPOINT = 'pins';
|
|
|
9
9
|
* @param kyOptions Ky Options for making requests
|
|
10
10
|
* @param reference Bee data reference
|
|
11
11
|
*/
|
|
12
|
-
async function pin(
|
|
13
|
-
await (0, http_1.http)(
|
|
12
|
+
async function pin(requestOptions, reference) {
|
|
13
|
+
await (0, http_1.http)(requestOptions, {
|
|
14
14
|
method: 'post',
|
|
15
15
|
responseType: 'json',
|
|
16
|
-
|
|
16
|
+
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
exports.pin = pin;
|
|
@@ -23,11 +23,11 @@ exports.pin = pin;
|
|
|
23
23
|
* @param kyOptions Ky Options for making requests
|
|
24
24
|
* @param reference Bee data reference
|
|
25
25
|
*/
|
|
26
|
-
async function unpin(
|
|
27
|
-
await (0, http_1.http)(
|
|
26
|
+
async function unpin(requestOptions, reference) {
|
|
27
|
+
await (0, http_1.http)(requestOptions, {
|
|
28
28
|
method: 'delete',
|
|
29
29
|
responseType: 'json',
|
|
30
|
-
|
|
30
|
+
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
exports.unpin = unpin;
|
|
@@ -38,13 +38,13 @@ exports.unpin = unpin;
|
|
|
38
38
|
* @param reference
|
|
39
39
|
* @throws Error if given address is not pinned
|
|
40
40
|
*/
|
|
41
|
-
async function getPin(
|
|
42
|
-
const response = await (0, http_1.http)(
|
|
41
|
+
async function getPin(requestOptions, reference) {
|
|
42
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
43
43
|
method: 'get',
|
|
44
44
|
responseType: 'json',
|
|
45
|
-
|
|
45
|
+
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
46
46
|
});
|
|
47
|
-
return response.
|
|
47
|
+
return response.data;
|
|
48
48
|
}
|
|
49
49
|
exports.getPin = getPin;
|
|
50
50
|
/**
|
|
@@ -52,12 +52,12 @@ exports.getPin = getPin;
|
|
|
52
52
|
*
|
|
53
53
|
* @param ky Ky instance
|
|
54
54
|
*/
|
|
55
|
-
async function getAllPins(
|
|
56
|
-
const response = await (0, http_1.http)(
|
|
55
|
+
async function getAllPins(requestOptions) {
|
|
56
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
57
57
|
method: 'get',
|
|
58
58
|
responseType: 'json',
|
|
59
|
-
|
|
59
|
+
url: `${PINNING_ENDPOINT}`,
|
|
60
60
|
});
|
|
61
|
-
return response.
|
|
61
|
+
return response.data.references;
|
|
62
62
|
}
|
|
63
63
|
exports.getAllPins = getAllPins;
|
package/dist/cjs/modules/pss.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.subscribe = exports.send = void 0;
|
|
7
7
|
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
8
8
|
const data_1 = require("../utils/data");
|
|
9
|
-
const http_1 = require("../utils/http");
|
|
10
9
|
const headers_1 = require("../utils/headers");
|
|
10
|
+
const http_1 = require("../utils/http");
|
|
11
11
|
const endpoint = 'pss';
|
|
12
12
|
/**
|
|
13
13
|
* Send to recipient or target with Postal Service for Swarm
|
|
@@ -20,13 +20,13 @@ const endpoint = 'pss';
|
|
|
20
20
|
* @param recipient Recipient public key
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
async function send(
|
|
24
|
-
await (0, http_1.http)(
|
|
23
|
+
async function send(requestOptions, topic, target, data, postageBatchId, recipient) {
|
|
24
|
+
await (0, http_1.http)(requestOptions, {
|
|
25
25
|
method: 'post',
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
url: `${endpoint}/send/${topic}/${target}`,
|
|
27
|
+
data: await (0, data_1.prepareData)(data),
|
|
28
28
|
responseType: 'json',
|
|
29
|
-
|
|
29
|
+
params: { recipient },
|
|
30
30
|
headers: (0, headers_1.extractUploadHeaders)(postageBatchId),
|
|
31
31
|
});
|
|
32
32
|
}
|
package/dist/cjs/modules/soc.js
CHANGED
|
@@ -15,18 +15,18 @@ const socEndpoint = 'soc';
|
|
|
15
15
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
16
16
|
* @param options Additional options like tag, encryption, pinning
|
|
17
17
|
*/
|
|
18
|
-
async function upload(
|
|
19
|
-
const response = await (0, http_1.http)(
|
|
18
|
+
async function upload(requestOptions, owner, identifier, signature, data, postageBatchId, options) {
|
|
19
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
20
20
|
method: 'post',
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
url: `${socEndpoint}/${owner}/${identifier}`,
|
|
22
|
+
data,
|
|
23
23
|
headers: {
|
|
24
24
|
'content-type': 'application/octet-stream',
|
|
25
25
|
...(0, headers_1.extractUploadHeaders)(postageBatchId, options),
|
|
26
26
|
},
|
|
27
27
|
responseType: 'json',
|
|
28
|
-
|
|
28
|
+
params: { sig: signature },
|
|
29
29
|
});
|
|
30
|
-
return response.
|
|
30
|
+
return response.data.reference;
|
|
31
31
|
}
|
|
32
32
|
exports.upload = upload;
|
|
@@ -7,9 +7,9 @@ const http_1 = require("../utils/http");
|
|
|
7
7
|
*
|
|
8
8
|
* @param kyOptions Ky instance for given Bee class instance
|
|
9
9
|
*/
|
|
10
|
-
async function checkConnection(
|
|
11
|
-
await (0, http_1.http)(
|
|
12
|
-
|
|
10
|
+
async function checkConnection(requestOptions) {
|
|
11
|
+
await (0, http_1.http)(requestOptions, {
|
|
12
|
+
url: '',
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.checkConnection = checkConnection;
|