@ethersphere/bee-js 3.2.0 → 3.3.2-pre.0
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 +615 -0
- package/dist/cjs/bee.js +922 -0
- package/dist/cjs/chunk/bmt.js +55 -0
- package/dist/cjs/chunk/cac.js +56 -0
- package/dist/cjs/chunk/serialize.js +19 -0
- package/dist/cjs/chunk/signer.js +137 -0
- package/dist/cjs/chunk/soc.js +172 -0
- package/dist/cjs/chunk/span.js +29 -0
- package/dist/cjs/feed/index.js +184 -0
- package/dist/cjs/feed/json.js +41 -0
- package/dist/cjs/feed/topic.js +25 -0
- package/dist/cjs/feed/type.js +15 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/modules/bytes.js +74 -0
- package/dist/cjs/modules/bzz.js +131 -0
- package/dist/cjs/modules/chunk.js +58 -0
- package/dist/cjs/modules/debug/balance.js +77 -0
- package/dist/cjs/modules/debug/chequebook.js +167 -0
- package/dist/cjs/modules/debug/chunk.js +51 -0
- package/dist/cjs/modules/debug/connectivity.js +75 -0
- package/dist/cjs/modules/debug/settlements.js +45 -0
- package/dist/cjs/modules/debug/stamps.js +89 -0
- package/dist/cjs/modules/debug/states.js +47 -0
- package/dist/cjs/modules/debug/status.js +153 -0
- package/dist/cjs/modules/debug/tag.js +30 -0
- package/dist/cjs/modules/debug/transactions.js +81 -0
- package/dist/cjs/modules/feed.js +76 -0
- package/dist/cjs/modules/pinning.js +84 -0
- package/dist/cjs/modules/pss.js +55 -0
- package/dist/cjs/modules/soc.js +40 -0
- package/dist/cjs/modules/status.js +26 -0
- package/dist/cjs/modules/stewardship.js +41 -0
- package/dist/cjs/modules/tag.js +96 -0
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/types/debug.js +9 -0
- package/dist/cjs/types/index.js +46 -0
- package/dist/cjs/types/ky-options.js +8 -0
- package/dist/cjs/types/ky-universal/common.js +8 -0
- package/dist/cjs/types/ky-universal/hooks.js +8 -0
- package/dist/cjs/types/ky-universal/retry.js +8 -0
- package/dist/cjs/utils/bytes.js +107 -0
- package/dist/cjs/utils/collection.browser.js +36 -0
- package/dist/cjs/utils/collection.js +70 -0
- package/dist/cjs/utils/collection.node.js +115 -0
- package/dist/cjs/utils/data.browser.js +78 -0
- package/dist/cjs/utils/data.js +60 -0
- package/dist/cjs/utils/error.js +50 -0
- package/dist/cjs/utils/eth.js +211 -0
- package/dist/cjs/utils/expose.js +44 -0
- package/dist/cjs/utils/file.js +49 -0
- package/dist/cjs/utils/hash.js +21 -0
- package/dist/cjs/utils/headers.js +59 -0
- package/dist/cjs/utils/hex.js +150 -0
- package/dist/cjs/utils/http.js +166 -0
- package/dist/cjs/utils/merge.js +34 -0
- package/dist/cjs/utils/pss.js +18 -0
- package/dist/cjs/utils/stamps.js +17 -0
- package/dist/cjs/utils/stream.js +146 -0
- package/dist/cjs/utils/tar.js +25 -0
- package/dist/cjs/utils/type.js +327 -0
- package/dist/cjs/utils/uint64.js +29 -0
- package/dist/cjs/utils/url.js +56 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.LICENSE.txt +12 -11
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +609 -0
- package/dist/mjs/bee.js +944 -0
- package/dist/mjs/chunk/bmt.js +56 -0
- package/dist/mjs/chunk/cac.js +52 -0
- package/dist/mjs/chunk/serialize.js +15 -0
- package/dist/mjs/chunk/signer.js +131 -0
- package/dist/mjs/chunk/soc.js +139 -0
- package/dist/mjs/chunk/span.js +28 -0
- package/dist/mjs/feed/index.js +145 -0
- package/dist/mjs/feed/json.js +27 -0
- package/dist/mjs/feed/topic.js +21 -0
- package/dist/mjs/feed/type.js +10 -0
- package/dist/mjs/index.js +7 -0
- package/dist/mjs/modules/bytes.js +59 -0
- package/dist/mjs/modules/bzz.js +122 -0
- package/dist/mjs/modules/chunk.js +45 -0
- package/dist/mjs/modules/debug/balance.js +57 -0
- package/dist/mjs/modules/debug/chequebook.js +150 -0
- package/dist/mjs/modules/debug/chunk.js +35 -0
- package/dist/mjs/modules/debug/connectivity.js +45 -0
- package/dist/mjs/modules/debug/settlements.js +29 -0
- package/dist/mjs/modules/debug/stamps.js +64 -0
- package/dist/mjs/modules/debug/states.js +31 -0
- package/dist/mjs/modules/debug/status.js +134 -0
- package/dist/mjs/modules/debug/tag.js +16 -0
- package/dist/mjs/modules/debug/transactions.js +63 -0
- package/dist/mjs/modules/feed.js +67 -0
- package/dist/mjs/modules/pinning.js +66 -0
- package/dist/mjs/modules/pss.js +40 -0
- package/dist/mjs/modules/soc.js +31 -0
- package/dist/mjs/modules/status.js +12 -0
- package/dist/mjs/modules/stewardship.js +24 -0
- package/dist/mjs/modules/tag.js +77 -0
- package/dist/mjs/package.json +8 -0
- package/dist/mjs/types/debug.js +7 -0
- package/dist/mjs/types/index.js +37 -0
- package/dist/mjs/types/ky-options.js +7 -0
- package/dist/mjs/types/ky-universal/common.js +7 -0
- package/dist/mjs/types/ky-universal/hooks.js +7 -0
- package/dist/mjs/types/ky-universal/retry.js +7 -0
- package/dist/mjs/utils/bytes.js +101 -0
- package/dist/mjs/utils/collection.browser.js +19 -0
- package/dist/mjs/utils/collection.js +64 -0
- package/dist/mjs/utils/collection.node.js +74 -0
- package/dist/mjs/utils/data.browser.js +73 -0
- package/dist/mjs/utils/data.js +43 -0
- package/dist/mjs/utils/error.js +56 -0
- package/dist/mjs/utils/eth.js +199 -0
- package/dist/mjs/utils/expose.js +9 -0
- package/dist/mjs/utils/file.js +36 -0
- package/dist/mjs/utils/hash.js +17 -0
- package/dist/mjs/utils/headers.js +58 -0
- package/dist/mjs/utils/hex.js +154 -0
- package/dist/mjs/utils/http.js +155 -0
- package/dist/mjs/utils/merge.js +36 -0
- package/dist/mjs/utils/pss.js +16 -0
- package/dist/mjs/utils/stamps.js +17 -0
- package/dist/mjs/utils/stream.js +156 -0
- package/dist/mjs/utils/tar.js +21 -0
- package/dist/mjs/utils/type.js +336 -0
- package/dist/mjs/utils/uint64.js +23 -0
- package/dist/mjs/utils/url.js +57 -0
- package/dist/{src → types}/bee-debug.d.ts +47 -1
- package/dist/{src → types}/bee.d.ts +0 -0
- package/dist/{src → types}/chunk/bmt.d.ts +0 -0
- package/dist/{src → types}/chunk/cac.d.ts +0 -0
- package/dist/{src → types}/chunk/serialize.d.ts +0 -0
- package/dist/{src → types}/chunk/signer.d.ts +0 -0
- package/dist/{src → types}/chunk/soc.d.ts +0 -0
- package/dist/{src → types}/chunk/span.d.ts +0 -0
- package/dist/{src → types}/feed/index.d.ts +0 -0
- package/dist/{src → types}/feed/json.d.ts +0 -0
- package/dist/{src → types}/feed/topic.d.ts +0 -0
- package/dist/{src → types}/feed/type.d.ts +0 -0
- package/dist/{src → types}/index.d.ts +0 -0
- package/dist/{src → types}/modules/bytes.d.ts +0 -0
- package/dist/{src → types}/modules/bzz.d.ts +0 -0
- package/dist/{src → types}/modules/chunk.d.ts +0 -0
- package/dist/{src → types}/modules/debug/balance.d.ts +0 -0
- package/dist/{src → types}/modules/debug/chequebook.d.ts +0 -0
- package/dist/{src → types}/modules/debug/chunk.d.ts +0 -0
- package/dist/{src → types}/modules/debug/connectivity.d.ts +0 -0
- package/dist/{src → types}/modules/debug/settlements.d.ts +0 -0
- package/dist/{src → types}/modules/debug/stamps.d.ts +0 -0
- package/dist/{src → types}/modules/debug/states.d.ts +0 -0
- package/dist/types/modules/debug/status.d.ts +72 -0
- package/dist/{src → types}/modules/debug/tag.d.ts +0 -0
- package/dist/{src → types}/modules/debug/transactions.d.ts +0 -0
- package/dist/{src → types}/modules/feed.d.ts +0 -0
- package/dist/{src → types}/modules/pinning.d.ts +0 -0
- package/dist/{src → types}/modules/pss.d.ts +0 -0
- package/dist/{src → types}/modules/soc.d.ts +0 -0
- package/dist/{src → types}/modules/status.d.ts +0 -0
- package/dist/{src → types}/modules/stewardship.d.ts +0 -0
- package/dist/{src → types}/modules/tag.d.ts +0 -0
- package/dist/{src → types}/types/debug.d.ts +8 -0
- package/dist/{src → types}/types/index.d.ts +3 -2
- package/dist/types/types/ky-options.d.ts +221 -0
- package/dist/types/types/ky-universal/common.d.ts +13 -0
- package/dist/types/types/ky-universal/hooks.d.ts +92 -0
- package/dist/types/types/ky-universal/retry.d.ts +38 -0
- package/dist/{src → types}/utils/bytes.d.ts +0 -0
- package/dist/types/utils/collection.browser.d.ts +15 -0
- package/dist/{src → types}/utils/collection.d.ts +0 -14
- package/dist/types/utils/collection.node.d.ts +15 -0
- package/dist/{src → types}/utils/data.browser.d.ts +0 -0
- package/dist/{src → types}/utils/data.d.ts +0 -0
- package/dist/{src → types}/utils/error.d.ts +0 -0
- package/dist/{src → types}/utils/eth.d.ts +0 -0
- package/dist/{src → types}/utils/expose.d.ts +2 -1
- package/dist/{src → types}/utils/file.d.ts +0 -0
- package/dist/{src → types}/utils/hash.d.ts +0 -0
- package/dist/{src → types}/utils/headers.d.ts +0 -0
- package/dist/{src → types}/utils/hex.d.ts +0 -0
- package/dist/{src → types}/utils/http.d.ts +0 -0
- package/dist/{src → types}/utils/merge.d.ts +0 -0
- package/dist/{src → types}/utils/pss.d.ts +0 -0
- package/dist/{src → types}/utils/stamps.d.ts +0 -0
- package/dist/{src → types}/utils/stream.d.ts +11 -8
- package/dist/{src → types}/utils/tar.d.ts +0 -0
- package/dist/{src → types}/utils/type.d.ts +0 -0
- package/dist/{src → types}/utils/uint64.d.ts +0 -0
- package/dist/{src → types}/utils/url.d.ts +0 -0
- package/package.json +55 -36
- package/dist/index.min.js +0 -3
- package/dist/index.min.js.LICENSE.txt +0 -50
- package/dist/index.min.js.map +0 -1
- package/dist/src/modules/debug/status.d.ts +0 -24
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
function getNodeAddresses(ky) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const response = yield (0, http_1.http)(ky, {
|
|
17
|
+
path: 'addresses',
|
|
18
|
+
responseType: 'json',
|
|
19
|
+
});
|
|
20
|
+
return response.data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.getNodeAddresses = getNodeAddresses;
|
|
24
|
+
function getPeers(ky) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const response = yield (0, http_1.http)(ky, {
|
|
27
|
+
path: 'peers',
|
|
28
|
+
responseType: 'json',
|
|
29
|
+
});
|
|
30
|
+
return response.data.peers || [];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.getPeers = getPeers;
|
|
34
|
+
function getBlocklist(ky) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const response = yield (0, http_1.http)(ky, {
|
|
37
|
+
path: 'blocklist',
|
|
38
|
+
responseType: 'json',
|
|
39
|
+
});
|
|
40
|
+
return response.data.peers || [];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.getBlocklist = getBlocklist;
|
|
44
|
+
function removePeer(ky, peer) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const response = yield (0, http_1.http)(ky, {
|
|
47
|
+
path: `peers/${peer}`,
|
|
48
|
+
responseType: 'json',
|
|
49
|
+
method: 'DELETE',
|
|
50
|
+
});
|
|
51
|
+
return response.data;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.removePeer = removePeer;
|
|
55
|
+
function getTopology(ky) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const response = yield (0, http_1.http)(ky, {
|
|
58
|
+
path: `topology`,
|
|
59
|
+
responseType: 'json',
|
|
60
|
+
});
|
|
61
|
+
return response.data;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.getTopology = getTopology;
|
|
65
|
+
function pingPeer(ky, peer) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const response = yield (0, http_1.http)(ky, {
|
|
68
|
+
path: `pingpong/${peer}`,
|
|
69
|
+
responseType: 'json',
|
|
70
|
+
method: 'POST',
|
|
71
|
+
});
|
|
72
|
+
return response.data;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.pingPeer = pingPeer;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAllSettlements = exports.getSettlements = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
const settlementsEndpoint = 'settlements';
|
|
15
|
+
/**
|
|
16
|
+
* Get amount of sent and received from settlements with a peer
|
|
17
|
+
*
|
|
18
|
+
* @param ky Ky debug instance
|
|
19
|
+
* @param peer Swarm address of peer
|
|
20
|
+
*/
|
|
21
|
+
function getSettlements(ky, peer) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const response = yield (0, http_1.http)(ky, {
|
|
24
|
+
path: `${settlementsEndpoint}/${peer}`,
|
|
25
|
+
responseType: 'json',
|
|
26
|
+
});
|
|
27
|
+
return response.data;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.getSettlements = getSettlements;
|
|
31
|
+
/**
|
|
32
|
+
* Get settlements with all known peers and total amount sent or received
|
|
33
|
+
*
|
|
34
|
+
* @param ky Ky debug instance
|
|
35
|
+
*/
|
|
36
|
+
function getAllSettlements(ky) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const response = yield (0, http_1.http)(ky, {
|
|
39
|
+
path: settlementsEndpoint,
|
|
40
|
+
responseType: 'json',
|
|
41
|
+
});
|
|
42
|
+
return response.data;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.getAllSettlements = getAllSettlements;
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.diluteBatch = exports.topUpBatch = exports.createPostageBatch = exports.getPostageBatchBuckets = exports.getPostageBatch = exports.getAllPostageBatches = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
const STAMPS_ENDPOINT = 'stamps';
|
|
15
|
+
function getAllPostageBatches(ky) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const response = yield (0, http_1.http)(ky, {
|
|
18
|
+
method: 'get',
|
|
19
|
+
path: `${STAMPS_ENDPOINT}`,
|
|
20
|
+
responseType: 'json',
|
|
21
|
+
});
|
|
22
|
+
return response.data.stamps || [];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.getAllPostageBatches = getAllPostageBatches;
|
|
26
|
+
function getPostageBatch(ky, postageBatchId) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const response = yield (0, http_1.http)(ky, {
|
|
29
|
+
method: 'get',
|
|
30
|
+
path: `${STAMPS_ENDPOINT}/${postageBatchId}`,
|
|
31
|
+
responseType: 'json',
|
|
32
|
+
});
|
|
33
|
+
return response.data;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.getPostageBatch = getPostageBatch;
|
|
37
|
+
function getPostageBatchBuckets(ky, postageBatchId) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const response = yield (0, http_1.http)(ky, {
|
|
40
|
+
method: 'get',
|
|
41
|
+
path: `${STAMPS_ENDPOINT}/${postageBatchId}/buckets`,
|
|
42
|
+
responseType: 'json',
|
|
43
|
+
});
|
|
44
|
+
return response.data;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.getPostageBatchBuckets = getPostageBatchBuckets;
|
|
48
|
+
function createPostageBatch(ky, amount, depth, options) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const headers = {};
|
|
51
|
+
if (options === null || options === void 0 ? void 0 : options.gasPrice) {
|
|
52
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
53
|
+
}
|
|
54
|
+
if ((options === null || options === void 0 ? void 0 : options.immutableFlag) !== undefined) {
|
|
55
|
+
headers.immutable = String(options.immutableFlag);
|
|
56
|
+
}
|
|
57
|
+
const response = yield (0, http_1.http)(ky, {
|
|
58
|
+
method: 'post',
|
|
59
|
+
path: `${STAMPS_ENDPOINT}/${amount}/${depth}`,
|
|
60
|
+
responseType: 'json',
|
|
61
|
+
searchParams: { label: options === null || options === void 0 ? void 0 : options.label },
|
|
62
|
+
headers,
|
|
63
|
+
});
|
|
64
|
+
return response.data.batchID;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.createPostageBatch = createPostageBatch;
|
|
68
|
+
function topUpBatch(ky, id, amount) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const response = yield (0, http_1.http)(ky, {
|
|
71
|
+
method: 'patch',
|
|
72
|
+
path: `${STAMPS_ENDPOINT}/topup/${id}/${amount}`,
|
|
73
|
+
responseType: 'json',
|
|
74
|
+
});
|
|
75
|
+
return response.data.batchID;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.topUpBatch = topUpBatch;
|
|
79
|
+
function diluteBatch(ky, id, depth) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const response = yield (0, http_1.http)(ky, {
|
|
82
|
+
method: 'patch',
|
|
83
|
+
path: `${STAMPS_ENDPOINT}/dilute/${id}/${depth}`,
|
|
84
|
+
responseType: 'json',
|
|
85
|
+
});
|
|
86
|
+
return response.data.batchID;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.diluteBatch = diluteBatch;
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getChainState = exports.getReserveState = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
const RESERVE_STATE_ENDPOINT = 'reservestate';
|
|
15
|
+
const CHAIN_STATE_ENDPOINT = 'chainstate';
|
|
16
|
+
/**
|
|
17
|
+
* Get state of reserve
|
|
18
|
+
*
|
|
19
|
+
* @param ky Ky debug instance
|
|
20
|
+
*/
|
|
21
|
+
function getReserveState(ky) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const response = yield (0, http_1.http)(ky, {
|
|
24
|
+
method: 'get',
|
|
25
|
+
path: `${RESERVE_STATE_ENDPOINT}`,
|
|
26
|
+
responseType: 'json',
|
|
27
|
+
});
|
|
28
|
+
return response.data;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.getReserveState = getReserveState;
|
|
32
|
+
/**
|
|
33
|
+
* Get state of reserve
|
|
34
|
+
*
|
|
35
|
+
* @param ky Ky debug instance
|
|
36
|
+
*/
|
|
37
|
+
function getChainState(ky) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const response = yield (0, http_1.http)(ky, {
|
|
40
|
+
method: 'get',
|
|
41
|
+
path: `${CHAIN_STATE_ENDPOINT}`,
|
|
42
|
+
responseType: 'json',
|
|
43
|
+
});
|
|
44
|
+
return response.data;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.getChainState = getChainState;
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getVersions = exports.isSupportedApiVersion = exports.isSupportedDebugApiVersion = exports.isSupportedMainApiVersion = exports.isSupportedExactVersion = exports.isSupportedVersion = exports.getNodeInfo = exports.getHealth = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_DEBUG_API_VERSION = exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
|
|
16
|
+
const http_1 = require("../../utils/http");
|
|
17
|
+
const major_js_1 = __importDefault(require("semver/functions/major.js"));
|
|
18
|
+
// Following lines bellow are automatically updated with GitHub Action when Bee version is updated
|
|
19
|
+
// so if you are changing anything about them change the `update_bee` action accordingly!
|
|
20
|
+
exports.SUPPORTED_BEE_VERSION_EXACT = '1.4.3-1213e063';
|
|
21
|
+
exports.SUPPORTED_API_VERSION = '2.0.0';
|
|
22
|
+
exports.SUPPORTED_DEBUG_API_VERSION = '1.2.1';
|
|
23
|
+
exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.substring(0, exports.SUPPORTED_BEE_VERSION_EXACT.indexOf('-'));
|
|
24
|
+
const NODE_INFO_URL = 'node';
|
|
25
|
+
const HEALTH_URL = 'health';
|
|
26
|
+
/**
|
|
27
|
+
* Get health of node
|
|
28
|
+
*
|
|
29
|
+
* @param ky Ky debug instance
|
|
30
|
+
*/
|
|
31
|
+
function getHealth(ky) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const response = yield (0, http_1.http)(ky, {
|
|
34
|
+
method: 'get',
|
|
35
|
+
path: HEALTH_URL,
|
|
36
|
+
responseType: 'json',
|
|
37
|
+
});
|
|
38
|
+
return response.data;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.getHealth = getHealth;
|
|
42
|
+
/**
|
|
43
|
+
* Get information about Bee node
|
|
44
|
+
*
|
|
45
|
+
* @param ky Ky debug instance
|
|
46
|
+
*/
|
|
47
|
+
function getNodeInfo(ky) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const response = yield (0, http_1.http)(ky, {
|
|
50
|
+
method: 'get',
|
|
51
|
+
path: NODE_INFO_URL,
|
|
52
|
+
responseType: 'json',
|
|
53
|
+
});
|
|
54
|
+
return response.data;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.getNodeInfo = getNodeInfo;
|
|
58
|
+
/**
|
|
59
|
+
* Connects to a node and checks if it is a supported Bee version by the bee-js
|
|
60
|
+
*
|
|
61
|
+
* @param ky Ky debug instance
|
|
62
|
+
*
|
|
63
|
+
* @returns true if the Bee node version is supported
|
|
64
|
+
* @deprecated Use `isSupportedExactVersion` instead
|
|
65
|
+
*/
|
|
66
|
+
function isSupportedVersion(ky) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
return isSupportedExactVersion(ky);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.isSupportedVersion = isSupportedVersion;
|
|
72
|
+
/**
|
|
73
|
+
* Connects to a node and checks if its version matches with the one that bee-js supports.
|
|
74
|
+
*
|
|
75
|
+
* Be aware that this is the most strict version check and most probably
|
|
76
|
+
* you will want to use more relaxed API-versions based checks like
|
|
77
|
+
* `isSupportedApiVersion`, `isSupportedMainApiVersion` or `isSupportedDebugApiVersion`
|
|
78
|
+
* based on your use-case.
|
|
79
|
+
*
|
|
80
|
+
* @param ky
|
|
81
|
+
*/
|
|
82
|
+
function isSupportedExactVersion(ky) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const { version } = yield getHealth(ky);
|
|
85
|
+
return version === exports.SUPPORTED_BEE_VERSION_EXACT;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.isSupportedExactVersion = isSupportedExactVersion;
|
|
89
|
+
/**
|
|
90
|
+
* Connects to a node and checks if its main's API version matches with the one that bee-js supports.
|
|
91
|
+
*
|
|
92
|
+
* This is useful if you are not using `BeeDebug` class (for anything else then this check)
|
|
93
|
+
* and want to make sure about compatibility.
|
|
94
|
+
*
|
|
95
|
+
* @param ky
|
|
96
|
+
*/
|
|
97
|
+
function isSupportedMainApiVersion(ky) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const { apiVersion } = yield getHealth(ky);
|
|
100
|
+
return (0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.isSupportedMainApiVersion = isSupportedMainApiVersion;
|
|
104
|
+
/**
|
|
105
|
+
* Connects to a node and checks if its Debug API version matches with the one that bee-js supports.
|
|
106
|
+
*
|
|
107
|
+
* This is useful if you are not using `Bee` class in your application and want to make sure
|
|
108
|
+
* about compatibility.
|
|
109
|
+
*
|
|
110
|
+
* @param ky
|
|
111
|
+
*/
|
|
112
|
+
function isSupportedDebugApiVersion(ky) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const { debugApiVersion } = yield getHealth(ky);
|
|
115
|
+
return (0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.isSupportedDebugApiVersion = isSupportedDebugApiVersion;
|
|
119
|
+
/**
|
|
120
|
+
* Connects to a node and checks if its Main and Debug API versions matches with the one that bee-js supports.
|
|
121
|
+
*
|
|
122
|
+
* This should be the main way how to check compatibility for your app and Bee node.
|
|
123
|
+
*
|
|
124
|
+
* @param ky
|
|
125
|
+
*/
|
|
126
|
+
function isSupportedApiVersion(ky) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const { apiVersion, debugApiVersion } = yield getHealth(ky);
|
|
129
|
+
return ((0, major_js_1.default)(apiVersion) === (0, major_js_1.default)(exports.SUPPORTED_API_VERSION) &&
|
|
130
|
+
(0, major_js_1.default)(debugApiVersion) === (0, major_js_1.default)(exports.SUPPORTED_DEBUG_API_VERSION));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
exports.isSupportedApiVersion = isSupportedApiVersion;
|
|
134
|
+
/**
|
|
135
|
+
* Returns object with all versions specified by the connected Bee node (properties prefixed with `bee*`)
|
|
136
|
+
* and versions that bee-js supports (properties prefixed with `supported*`).
|
|
137
|
+
*
|
|
138
|
+
* @param ky
|
|
139
|
+
*/
|
|
140
|
+
function getVersions(ky) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
const { version, apiVersion, debugApiVersion } = yield getHealth(ky);
|
|
143
|
+
return {
|
|
144
|
+
supportedBeeVersion: exports.SUPPORTED_BEE_VERSION_EXACT,
|
|
145
|
+
supportedBeeApiVersion: exports.SUPPORTED_API_VERSION,
|
|
146
|
+
supportedBeeDebugApiVersion: exports.SUPPORTED_DEBUG_API_VERSION,
|
|
147
|
+
beeVersion: version,
|
|
148
|
+
beeApiVersion: apiVersion,
|
|
149
|
+
beeDebugApiVersion: debugApiVersion,
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
exports.getVersions = getVersions;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.retrieveExtendedTag = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
const endpoint = 'tags';
|
|
15
|
+
/**
|
|
16
|
+
* Retrieve tag with extended information from Bee node
|
|
17
|
+
*
|
|
18
|
+
* @param ky Ky debug instance
|
|
19
|
+
* @param uid UID of tag to be retrieved
|
|
20
|
+
*/
|
|
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;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.retrieveExtendedTag = retrieveExtendedTag;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.cancelTransaction = exports.rebroadcastTransaction = exports.getTransaction = exports.getAllTransactions = void 0;
|
|
13
|
+
const http_1 = require("../../utils/http");
|
|
14
|
+
const transactionsEndpoint = 'transactions';
|
|
15
|
+
/**
|
|
16
|
+
* Get list of all pending transactions
|
|
17
|
+
*
|
|
18
|
+
* @param ky Debug Ky instance
|
|
19
|
+
*/
|
|
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;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.getAllTransactions = getAllTransactions;
|
|
30
|
+
/**
|
|
31
|
+
* Get information for specific pending transactions
|
|
32
|
+
*
|
|
33
|
+
* @param ky Debug Ky instance
|
|
34
|
+
* @param transactionHash Hash of the transaction
|
|
35
|
+
*/
|
|
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;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.getTransaction = getTransaction;
|
|
46
|
+
/**
|
|
47
|
+
* Rebroadcast existing transaction
|
|
48
|
+
*
|
|
49
|
+
* @param ky Debug Ky instance
|
|
50
|
+
* @param transactionHash Hash of the transaction
|
|
51
|
+
*/
|
|
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;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.rebroadcastTransaction = rebroadcastTransaction;
|
|
63
|
+
/**
|
|
64
|
+
* Cancel existing transaction
|
|
65
|
+
*
|
|
66
|
+
* @param ky Debug Ky instance
|
|
67
|
+
* @param transactionHash Hash of the transaction
|
|
68
|
+
* @param gasPrice Optional gas price
|
|
69
|
+
*/
|
|
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;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.cancelTransaction = cancelTransaction;
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fetchFeedUpdate = exports.createFeedManifest = void 0;
|
|
13
|
+
const http_1 = require("../utils/http");
|
|
14
|
+
const headers_1 = require("../utils/headers");
|
|
15
|
+
const error_1 = require("../utils/error");
|
|
16
|
+
const feedEndpoint = 'feeds';
|
|
17
|
+
/**
|
|
18
|
+
* Create an initial feed root manifest
|
|
19
|
+
*
|
|
20
|
+
* @param ky Ky instance
|
|
21
|
+
* @param owner Owner's ethereum address in hex
|
|
22
|
+
* @param topic Topic in hex
|
|
23
|
+
* @param postageBatchId Postage BatchId to be used to create the Feed Manifest
|
|
24
|
+
* @param options Additional options, like type (default: 'sequence')
|
|
25
|
+
*/
|
|
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;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.createFeedManifest = createFeedManifest;
|
|
39
|
+
function readFeedUpdateHeaders(headers) {
|
|
40
|
+
const feedIndex = headers.get('swarm-feed-index');
|
|
41
|
+
const feedIndexNext = headers.get('swarm-feed-index-next');
|
|
42
|
+
if (!feedIndex) {
|
|
43
|
+
throw new error_1.BeeError('Response did not contain expected swarm-feed-index!');
|
|
44
|
+
}
|
|
45
|
+
if (!feedIndexNext) {
|
|
46
|
+
throw new error_1.BeeError('Response did not contain expected swarm-feed-index-next!');
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
feedIndex,
|
|
50
|
+
feedIndexNext,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Find and retrieve feed update
|
|
55
|
+
*
|
|
56
|
+
* The feed consists of updates. This endpoint looks up an
|
|
57
|
+
* update that matches the provided parameters and returns
|
|
58
|
+
* the reference it contains along with its index and the
|
|
59
|
+
* index of the subsequent update.
|
|
60
|
+
*
|
|
61
|
+
* @param ky Ky instance
|
|
62
|
+
* @param owner Owner's ethereum address in hex
|
|
63
|
+
* @param topic Topic in hex
|
|
64
|
+
* @param options Additional options, like index, at, type
|
|
65
|
+
*/
|
|
66
|
+
function fetchFeedUpdate(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));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.fetchFeedUpdate = fetchFeedUpdate;
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAllPins = exports.getPin = exports.unpin = exports.pin = void 0;
|
|
13
|
+
const http_1 = require("../utils/http");
|
|
14
|
+
const PINNING_ENDPOINT = 'pins';
|
|
15
|
+
/**
|
|
16
|
+
* Pin data with given reference
|
|
17
|
+
*
|
|
18
|
+
* @param ky Ky instance for given Bee class instance
|
|
19
|
+
* @param reference Bee data reference
|
|
20
|
+
*/
|
|
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
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.pin = pin;
|
|
31
|
+
/**
|
|
32
|
+
* Unpin data with given reference
|
|
33
|
+
*
|
|
34
|
+
* @param ky Ky instance for given Bee class instance
|
|
35
|
+
* @param reference Bee data reference
|
|
36
|
+
*/
|
|
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
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.unpin = unpin;
|
|
47
|
+
/**
|
|
48
|
+
* Get pin status for specific address.
|
|
49
|
+
*
|
|
50
|
+
* @param ky Ky instance
|
|
51
|
+
* @param reference
|
|
52
|
+
* @throws Error if given address is not pinned
|
|
53
|
+
*/
|
|
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;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.getPin = getPin;
|
|
65
|
+
/**
|
|
66
|
+
* Get list of all pins
|
|
67
|
+
*
|
|
68
|
+
* @param ky Ky instance
|
|
69
|
+
*/
|
|
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
|
+
const result = response.data.references;
|
|
78
|
+
if (result === null) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
exports.getAllPins = getAllPins;
|