@ethersphere/bee-js 6.0.0-pre.0 → 6.0.0-pre.10
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/README.md +18 -17
- package/dist/cjs/bee-debug.js +572 -0
- package/dist/cjs/bee.js +876 -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 +126 -0
- package/dist/cjs/chunk/soc.js +159 -0
- package/dist/cjs/chunk/span.js +29 -0
- package/dist/cjs/feed/identifier.js +35 -0
- package/dist/cjs/feed/index.js +116 -0
- package/dist/cjs/feed/json.js +28 -0
- package/dist/cjs/feed/retrievable.js +58 -0
- package/dist/cjs/feed/topic.js +25 -0
- package/dist/cjs/feed/type.js +15 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/modules/bytes.js +61 -0
- package/dist/cjs/modules/bzz.js +125 -0
- package/dist/cjs/modules/chunk.js +48 -0
- package/dist/cjs/modules/debug/balance.js +60 -0
- package/dist/cjs/modules/debug/chequebook.js +142 -0
- package/dist/cjs/modules/debug/chunk.js +38 -0
- package/dist/cjs/modules/debug/connectivity.js +54 -0
- package/dist/cjs/modules/debug/settlements.js +32 -0
- package/dist/cjs/modules/debug/stake.js +57 -0
- package/dist/cjs/modules/debug/stamps.js +68 -0
- package/dist/cjs/modules/debug/states.js +64 -0
- package/dist/cjs/modules/debug/status.js +148 -0
- package/dist/cjs/modules/debug/tag.js +19 -0
- package/dist/cjs/modules/debug/transactions.js +64 -0
- package/dist/cjs/modules/feed.js +66 -0
- package/dist/cjs/modules/pinning.js +63 -0
- package/dist/cjs/modules/pss.js +43 -0
- package/dist/cjs/modules/soc.js +32 -0
- package/dist/cjs/modules/status.js +15 -0
- package/dist/cjs/modules/stewardship.js +28 -0
- package/dist/cjs/modules/tag.js +77 -0
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/types/debug.js +10 -0
- package/dist/cjs/types/index.js +51 -0
- package/dist/cjs/utils/bytes.js +121 -0
- package/dist/cjs/utils/collection.browser.js +23 -0
- package/dist/cjs/utils/collection.js +59 -0
- package/dist/cjs/utils/collection.node.js +71 -0
- package/dist/cjs/utils/data.browser.js +61 -0
- package/dist/cjs/utils/data.js +45 -0
- package/dist/cjs/utils/error.js +16 -0
- package/dist/cjs/utils/eth.js +199 -0
- package/dist/cjs/utils/expose.js +44 -0
- package/dist/cjs/utils/file.js +38 -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 +40 -0
- package/dist/cjs/utils/pss.js +18 -0
- package/dist/cjs/utils/reference.js +36 -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 +434 -0
- package/dist/cjs/utils/uint64.js +29 -0
- package/dist/cjs/utils/url.js +56 -0
- package/dist/index.browser.min.js +3 -0
- package/dist/index.browser.min.js.LICENSE.txt +50 -0
- package/dist/index.browser.min.js.map +1 -0
- package/dist/{src → mjs}/bee-debug.js +102 -183
- package/dist/{src → mjs}/bee.js +82 -232
- package/dist/{src → mjs}/chunk/bmt.js +4 -10
- package/dist/{src → mjs}/chunk/cac.js +0 -3
- package/dist/{src → mjs}/chunk/signer.js +1 -18
- package/dist/{src → mjs}/chunk/soc.js +17 -29
- package/dist/{src → mjs}/chunk/span.js +2 -5
- package/dist/{src → mjs}/feed/identifier.js +0 -6
- package/dist/{src → mjs}/feed/index.js +24 -27
- package/dist/{src → mjs}/feed/json.js +2 -5
- package/dist/{src → mjs}/feed/retrievable.js +7 -21
- package/dist/{src → mjs}/feed/topic.js +0 -2
- package/dist/{src → mjs}/index.js +2 -2
- package/dist/{src → mjs}/modules/bytes.js +16 -20
- package/dist/{src → mjs}/modules/bzz.js +33 -40
- package/dist/{src → mjs}/modules/chunk.js +11 -13
- package/dist/mjs/modules/debug/balance.js +53 -0
- package/dist/mjs/modules/debug/chequebook.js +135 -0
- package/dist/{src → mjs}/modules/debug/chunk.js +10 -12
- package/dist/mjs/modules/debug/connectivity.js +45 -0
- package/dist/mjs/modules/debug/settlements.js +27 -0
- package/dist/mjs/modules/debug/stake.js +51 -0
- package/dist/mjs/modules/debug/stamps.js +61 -0
- package/dist/mjs/modules/debug/states.js +58 -0
- package/dist/{src → mjs}/modules/debug/status.js +46 -37
- package/dist/mjs/modules/debug/tag.js +15 -0
- package/dist/mjs/modules/debug/transactions.js +59 -0
- package/dist/{src → mjs}/modules/feed.js +15 -21
- package/dist/mjs/modules/pinning.js +56 -0
- package/dist/{src → mjs}/modules/pss.js +7 -10
- package/dist/{src → mjs}/modules/soc.js +6 -7
- package/dist/mjs/modules/status.js +11 -0
- package/dist/mjs/modules/stewardship.js +23 -0
- package/dist/mjs/modules/tag.js +72 -0
- package/dist/mjs/package.json +8 -0
- package/dist/{src → mjs}/types/debug.js +0 -1
- package/dist/{src → mjs}/types/index.js +0 -4
- package/dist/{src → mjs}/utils/bytes.js +8 -17
- package/dist/{src/utils/collection-browser.js → mjs/utils/collection.browser.js} +0 -1
- package/dist/{src → mjs}/utils/collection.js +0 -12
- package/dist/{src/utils/collection-node.js → mjs/utils/collection.node.js} +0 -13
- package/dist/{src → mjs}/utils/data.browser.js +2 -11
- package/dist/{src → mjs}/utils/data.js +0 -7
- package/dist/mjs/utils/error.js +11 -0
- package/dist/{src → mjs}/utils/eth.js +6 -28
- package/dist/{src → mjs}/utils/expose.js +1 -1
- package/dist/{src → mjs}/utils/file.js +4 -9
- package/dist/{src → mjs}/utils/hash.js +0 -1
- package/dist/{src → mjs}/utils/headers.js +5 -13
- package/dist/{src → mjs}/utils/hex.js +6 -25
- package/dist/mjs/utils/http.js +34 -0
- package/dist/{src → mjs}/utils/pss.js +0 -2
- package/dist/{src → mjs}/utils/reference.js +2 -5
- package/dist/{src → mjs}/utils/stream.js +3 -26
- package/dist/{src → mjs}/utils/tar.js +3 -6
- package/dist/{src → mjs}/utils/type.js +23 -80
- package/dist/{src → mjs}/utils/uint64.js +0 -1
- package/dist/{src → mjs}/utils/url.js +2 -10
- package/dist/types/bee-debug.d.ts +71 -46
- package/dist/types/bee.d.ts +34 -58
- package/dist/types/chunk/bmt.d.ts +1 -1
- package/dist/types/chunk/cac.d.ts +1 -1
- package/dist/types/chunk/soc.d.ts +9 -9
- package/dist/types/chunk/span.d.ts +1 -1
- package/dist/types/feed/index.d.ts +10 -10
- package/dist/types/feed/json.d.ts +2 -2
- package/dist/types/feed/retrievable.d.ts +2 -2
- package/dist/types/feed/type.d.ts +1 -1
- package/dist/types/index.d.ts +13 -2
- package/dist/types/modules/bytes.d.ts +5 -5
- package/dist/types/modules/bzz.d.ts +8 -8
- package/dist/types/modules/chunk.d.ts +4 -4
- package/dist/types/modules/debug/balance.d.ts +9 -9
- package/dist/types/modules/debug/chequebook.d.ts +17 -17
- package/dist/types/modules/debug/chunk.d.ts +5 -5
- package/dist/types/modules/debug/connectivity.d.ts +7 -7
- package/dist/types/modules/debug/settlements.d.ts +5 -5
- package/dist/types/modules/debug/stake.d.ts +21 -0
- package/dist/types/modules/debug/stamps.d.ts +7 -7
- package/dist/types/modules/debug/states.d.ts +7 -7
- package/dist/types/modules/debug/status.d.ts +21 -15
- package/dist/types/modules/debug/tag.d.ts +3 -3
- package/dist/types/modules/debug/transactions.d.ts +5 -5
- package/dist/types/modules/feed.d.ts +3 -3
- package/dist/types/modules/pinning.d.ts +7 -7
- package/dist/types/modules/pss.d.ts +3 -3
- package/dist/types/modules/soc.d.ts +2 -2
- package/dist/types/modules/status.d.ts +3 -3
- package/dist/types/modules/stewardship.d.ts +3 -3
- package/dist/types/modules/tag.d.ts +6 -6
- package/dist/types/types/debug.d.ts +35 -2
- package/dist/types/types/index.d.ts +48 -89
- package/dist/types/utils/error.d.ts +0 -26
- package/dist/types/utils/eth.d.ts +6 -6
- package/dist/types/utils/expose.d.ts +4 -7
- package/dist/types/utils/hash.d.ts +1 -1
- package/dist/types/utils/headers.d.ts +1 -1
- package/dist/types/utils/hex.d.ts +4 -4
- package/dist/types/utils/http.d.ts +11 -21
- package/dist/types/utils/stream.d.ts +1 -1
- package/dist/types/utils/type.d.ts +3 -2
- package/dist/types/utils/uint64.d.ts +1 -1
- package/package.json +59 -52
- package/dist/index.browser.js +0 -33
- package/dist/index.browser.js.map +0 -7
- package/dist/src/modules/debug/balance.js +0 -57
- package/dist/src/modules/debug/chequebook.js +0 -150
- package/dist/src/modules/debug/connectivity.js +0 -45
- package/dist/src/modules/debug/settlements.js +0 -29
- package/dist/src/modules/debug/stamps.js +0 -64
- package/dist/src/modules/debug/states.js +0 -46
- package/dist/src/modules/debug/tag.js +0 -16
- package/dist/src/modules/debug/transactions.js +0 -69
- package/dist/src/modules/pinning.js +0 -60
- package/dist/src/modules/status.js +0 -12
- package/dist/src/modules/stewardship.js +0 -24
- package/dist/src/modules/tag.js +0 -77
- package/dist/src/utils/error.js +0 -47
- package/dist/src/utils/http.js +0 -162
- package/dist/src/utils/merge.js +0 -36
- package/dist/src/utils/sleep.js +0 -8
- package/dist/types/utils/merge.d.ts +0 -8
- package/dist/types/utils/sleep.d.ts +0 -6
- /package/dist/{src → mjs}/chunk/serialize.js +0 -0
- /package/dist/{src → mjs}/feed/type.js +0 -0
- /package/dist/{src → mjs}/utils/stamps.js +0 -0
- /package/dist/types/utils/{collection-browser.d.ts → collection.browser.d.ts} +0 -0
- /package/dist/types/utils/{collection-node.d.ts → collection.node.d.ts} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.areAllSequentialFeedsUpdateRetrievable = void 0;
|
|
4
|
+
const hex_1 = require("../utils/hex");
|
|
5
|
+
const uint64_1 = require("../utils/uint64");
|
|
6
|
+
const index_1 = require("./index");
|
|
7
|
+
function makeNumericIndex(index) {
|
|
8
|
+
if (index instanceof Uint8Array) {
|
|
9
|
+
return (0, uint64_1.readUint64BigEndian)(index);
|
|
10
|
+
}
|
|
11
|
+
if (typeof index === 'string') {
|
|
12
|
+
return parseInt(index);
|
|
13
|
+
}
|
|
14
|
+
if (typeof index === 'number') {
|
|
15
|
+
return index;
|
|
16
|
+
}
|
|
17
|
+
throw new TypeError('Unknown type of index!');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Function that checks if a chunk is retrievable by actually downloading it.
|
|
21
|
+
* The /stewardship/{reference} endpoint does not support verification of chunks, but only manifest's references.
|
|
22
|
+
*
|
|
23
|
+
* @param bee
|
|
24
|
+
* @param ref
|
|
25
|
+
* @param options
|
|
26
|
+
*/
|
|
27
|
+
async function isChunkRetrievable(bee, ref, requestOptions) {
|
|
28
|
+
try {
|
|
29
|
+
await bee.downloadChunk(ref, requestOptions);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
if (e?.response?.status === 404) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates array of references for all sequence updates chunk up to the given index.
|
|
41
|
+
*
|
|
42
|
+
* @param owner
|
|
43
|
+
* @param topic
|
|
44
|
+
* @param index
|
|
45
|
+
*/
|
|
46
|
+
function getAllSequenceUpdateReferences(owner, topic, index) {
|
|
47
|
+
const numIndex = makeNumericIndex(index);
|
|
48
|
+
const updateReferences = new Array(numIndex + 1);
|
|
49
|
+
for (let i = 0; i <= numIndex; i++) {
|
|
50
|
+
updateReferences[i] = (0, hex_1.bytesToHex)((0, index_1.getFeedUpdateChunkReference)(owner, topic, i));
|
|
51
|
+
}
|
|
52
|
+
return updateReferences;
|
|
53
|
+
}
|
|
54
|
+
async function areAllSequentialFeedsUpdateRetrievable(bee, owner, topic, index, requestOptions) {
|
|
55
|
+
const chunkRetrievablePromises = getAllSequenceUpdateReferences(owner, topic, index).map(async (ref) => isChunkRetrievable(bee, ref, requestOptions));
|
|
56
|
+
return (await Promise.all(chunkRetrievablePromises)).every(result => result);
|
|
57
|
+
}
|
|
58
|
+
exports.areAllSequentialFeedsUpdateRetrievable = areAllSequentialFeedsUpdateRetrievable;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTopicFromString = exports.makeTopic = void 0;
|
|
4
|
+
const hash_1 = require("../utils/hash");
|
|
5
|
+
const bytes_1 = require("../utils/bytes");
|
|
6
|
+
const hex_1 = require("../utils/hex");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
function makeTopic(topic) {
|
|
9
|
+
if (typeof topic === 'string') {
|
|
10
|
+
return (0, hex_1.makeHexString)(topic, types_1.TOPIC_HEX_LENGTH);
|
|
11
|
+
}
|
|
12
|
+
else if (topic instanceof Uint8Array) {
|
|
13
|
+
(0, bytes_1.assertBytes)(topic, types_1.TOPIC_BYTES_LENGTH);
|
|
14
|
+
return (0, hex_1.bytesToHex)(topic, types_1.TOPIC_HEX_LENGTH);
|
|
15
|
+
}
|
|
16
|
+
throw new TypeError('invalid topic');
|
|
17
|
+
}
|
|
18
|
+
exports.makeTopic = makeTopic;
|
|
19
|
+
function makeTopicFromString(s) {
|
|
20
|
+
if (typeof s !== 'string') {
|
|
21
|
+
throw new TypeError('topic has to be string!');
|
|
22
|
+
}
|
|
23
|
+
return (0, hex_1.bytesToHex)((0, hash_1.keccak256Hash)(s), types_1.TOPIC_HEX_LENGTH);
|
|
24
|
+
}
|
|
25
|
+
exports.makeTopicFromString = makeTopicFromString;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertFeedType = exports.isFeedType = exports.DEFAULT_FEED_TYPE = void 0;
|
|
4
|
+
const feedTypes = ['sequence', 'epoch'];
|
|
5
|
+
exports.DEFAULT_FEED_TYPE = 'sequence';
|
|
6
|
+
function isFeedType(type) {
|
|
7
|
+
return typeof type === 'string' && feedTypes.includes(type);
|
|
8
|
+
}
|
|
9
|
+
exports.isFeedType = isFeedType;
|
|
10
|
+
function assertFeedType(type) {
|
|
11
|
+
if (!isFeedType(type)) {
|
|
12
|
+
throw new TypeError('invalid feed type');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.assertFeedType = assertFeedType;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.BeeDebug = exports.Bee = exports.Utils = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = void 0;
|
|
30
|
+
const bee_1 = require("./bee");
|
|
31
|
+
Object.defineProperty(exports, "Bee", { enumerable: true, get: function () { return bee_1.Bee; } });
|
|
32
|
+
const bee_debug_1 = require("./bee-debug");
|
|
33
|
+
Object.defineProperty(exports, "BeeDebug", { enumerable: true, get: function () { return bee_debug_1.BeeDebug; } });
|
|
34
|
+
var status_1 = require("./modules/debug/status");
|
|
35
|
+
Object.defineProperty(exports, "SUPPORTED_BEE_VERSION", { enumerable: true, get: function () { return status_1.SUPPORTED_BEE_VERSION; } });
|
|
36
|
+
Object.defineProperty(exports, "SUPPORTED_BEE_VERSION_EXACT", { enumerable: true, get: function () { return status_1.SUPPORTED_BEE_VERSION_EXACT; } });
|
|
37
|
+
__exportStar(require("./types"), exports);
|
|
38
|
+
__exportStar(require("./utils/error"), exports);
|
|
39
|
+
exports.Utils = __importStar(require("./utils/expose"));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadReadable = exports.download = exports.upload = void 0;
|
|
4
|
+
const bytes_1 = require("../utils/bytes");
|
|
5
|
+
const headers_1 = require("../utils/headers");
|
|
6
|
+
const http_1 = require("../utils/http");
|
|
7
|
+
const type_1 = require("../utils/type");
|
|
8
|
+
const endpoint = 'bytes';
|
|
9
|
+
/**
|
|
10
|
+
* Upload data to a Bee node
|
|
11
|
+
*
|
|
12
|
+
* @param kyOptions Ky Options for making requests
|
|
13
|
+
* @param data Data to be uploaded
|
|
14
|
+
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
15
|
+
* @param options Additional options like tag, encryption, pinning
|
|
16
|
+
*/
|
|
17
|
+
async function upload(requestOptions, data, postageBatchId, options) {
|
|
18
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
19
|
+
url: endpoint,
|
|
20
|
+
method: 'post',
|
|
21
|
+
responseType: 'json',
|
|
22
|
+
data,
|
|
23
|
+
headers: {
|
|
24
|
+
'content-type': 'application/octet-stream',
|
|
25
|
+
...(0, headers_1.extractUploadHeaders)(postageBatchId, options),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
reference: response.data.reference,
|
|
30
|
+
tagUid: (0, type_1.makeTagUid)(response.headers['swarm-tag']),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.upload = upload;
|
|
34
|
+
/**
|
|
35
|
+
* Download data as a byte array
|
|
36
|
+
*
|
|
37
|
+
* @param ky
|
|
38
|
+
* @param hash Bee content reference
|
|
39
|
+
*/
|
|
40
|
+
async function download(requestOptions, hash) {
|
|
41
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
42
|
+
responseType: 'arraybuffer',
|
|
43
|
+
url: `${endpoint}/${hash}`,
|
|
44
|
+
});
|
|
45
|
+
return (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.data));
|
|
46
|
+
}
|
|
47
|
+
exports.download = download;
|
|
48
|
+
/**
|
|
49
|
+
* Download data as a readable stream
|
|
50
|
+
*
|
|
51
|
+
* @param ky
|
|
52
|
+
* @param hash Bee content reference
|
|
53
|
+
*/
|
|
54
|
+
async function downloadReadable(requestOptions, hash) {
|
|
55
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
56
|
+
responseType: 'stream',
|
|
57
|
+
url: `${endpoint}/${hash}`,
|
|
58
|
+
});
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
exports.downloadReadable = downloadReadable;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadCollection = exports.downloadFileReadable = exports.downloadFile = exports.uploadFile = void 0;
|
|
4
|
+
const bytes_1 = require("../utils/bytes");
|
|
5
|
+
const collection_1 = require("../utils/collection");
|
|
6
|
+
const headers_1 = require("../utils/headers");
|
|
7
|
+
const http_1 = require("../utils/http");
|
|
8
|
+
const stream_1 = require("../utils/stream");
|
|
9
|
+
const tar_1 = require("../utils/tar");
|
|
10
|
+
const type_1 = require("../utils/type");
|
|
11
|
+
const bzzEndpoint = 'bzz';
|
|
12
|
+
function extractFileUploadHeaders(postageBatchId, options) {
|
|
13
|
+
const headers = (0, headers_1.extractUploadHeaders)(postageBatchId, options);
|
|
14
|
+
if (options?.size)
|
|
15
|
+
headers['content-length'] = String(options.size);
|
|
16
|
+
if (options?.contentType)
|
|
17
|
+
headers['content-type'] = options.contentType;
|
|
18
|
+
return headers;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Upload single file
|
|
22
|
+
*
|
|
23
|
+
* @param ky
|
|
24
|
+
* @param data Files data
|
|
25
|
+
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
26
|
+
* @param name Name that will be attached to the uploaded file. Wraps the data into manifest with set index document.
|
|
27
|
+
* @param options
|
|
28
|
+
*/
|
|
29
|
+
async function uploadFile(requestOptions, data, postageBatchId, name, options) {
|
|
30
|
+
if ((0, stream_1.isReadable)(data) && !options?.contentType) {
|
|
31
|
+
if (!options)
|
|
32
|
+
options = {};
|
|
33
|
+
options.contentType = 'application/octet-stream';
|
|
34
|
+
}
|
|
35
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
36
|
+
method: 'post',
|
|
37
|
+
url: bzzEndpoint,
|
|
38
|
+
data,
|
|
39
|
+
headers: {
|
|
40
|
+
...extractFileUploadHeaders(postageBatchId, options),
|
|
41
|
+
},
|
|
42
|
+
params: { name },
|
|
43
|
+
responseType: 'json',
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
reference: response.data.reference,
|
|
47
|
+
tagUid: (0, type_1.makeTagUid)(response.headers['swarm-tag']),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.uploadFile = uploadFile;
|
|
51
|
+
/**
|
|
52
|
+
* Download single file as a buffer
|
|
53
|
+
*
|
|
54
|
+
* @param kyOptions Ky Options for making requests
|
|
55
|
+
* @param hash Bee file or collection hash
|
|
56
|
+
* @param path If hash is collection then this defines path to a single file in the collection
|
|
57
|
+
*/
|
|
58
|
+
async function downloadFile(requestOptions, hash, path = '') {
|
|
59
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
60
|
+
method: 'GET',
|
|
61
|
+
responseType: 'arraybuffer',
|
|
62
|
+
url: `${bzzEndpoint}/${hash}/${path}`,
|
|
63
|
+
});
|
|
64
|
+
const file = {
|
|
65
|
+
...(0, headers_1.readFileHeaders)(response.headers),
|
|
66
|
+
data: (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.data)),
|
|
67
|
+
};
|
|
68
|
+
return file;
|
|
69
|
+
}
|
|
70
|
+
exports.downloadFile = downloadFile;
|
|
71
|
+
/**
|
|
72
|
+
* Download single file as a readable stream
|
|
73
|
+
*
|
|
74
|
+
* @param kyOptions Ky Options for making requests
|
|
75
|
+
* @param hash Bee file or collection hash
|
|
76
|
+
* @param path If hash is collection then this defines path to a single file in the collection
|
|
77
|
+
*/
|
|
78
|
+
async function downloadFileReadable(requestOptions, hash, path = '') {
|
|
79
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
80
|
+
method: 'GET',
|
|
81
|
+
responseType: 'stream',
|
|
82
|
+
url: `${bzzEndpoint}/${hash}/${path}`,
|
|
83
|
+
});
|
|
84
|
+
const file = {
|
|
85
|
+
...(0, headers_1.readFileHeaders)(response.headers),
|
|
86
|
+
data: response.data,
|
|
87
|
+
};
|
|
88
|
+
return file;
|
|
89
|
+
}
|
|
90
|
+
exports.downloadFileReadable = downloadFileReadable;
|
|
91
|
+
function extractCollectionUploadHeaders(postageBatchId, options) {
|
|
92
|
+
const headers = (0, headers_1.extractUploadHeaders)(postageBatchId, options);
|
|
93
|
+
if (options?.indexDocument)
|
|
94
|
+
headers['swarm-index-document'] = options.indexDocument;
|
|
95
|
+
if (options?.errorDocument)
|
|
96
|
+
headers['swarm-error-document'] = options.errorDocument;
|
|
97
|
+
return headers;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Upload collection
|
|
101
|
+
* @param kyOptions Ky Options for making requests
|
|
102
|
+
* @param collection Collection of Uint8Array buffers to upload
|
|
103
|
+
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
104
|
+
* @param options
|
|
105
|
+
*/
|
|
106
|
+
async function uploadCollection(requestOptions, collection, postageBatchId, options) {
|
|
107
|
+
(0, collection_1.assertCollection)(collection);
|
|
108
|
+
const tarData = (0, tar_1.makeTar)(collection);
|
|
109
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
110
|
+
method: 'post',
|
|
111
|
+
url: bzzEndpoint,
|
|
112
|
+
data: tarData,
|
|
113
|
+
responseType: 'json',
|
|
114
|
+
headers: {
|
|
115
|
+
'content-type': 'application/x-tar',
|
|
116
|
+
'swarm-collection': 'true',
|
|
117
|
+
...extractCollectionUploadHeaders(postageBatchId, options),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
reference: response.data.reference,
|
|
122
|
+
tagUid: (0, type_1.makeTagUid)(response.headers['swarm-tag']),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
exports.uploadCollection = uploadCollection;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.download = exports.upload = void 0;
|
|
4
|
+
const bytes_1 = require("../utils/bytes");
|
|
5
|
+
const headers_1 = require("../utils/headers");
|
|
6
|
+
const http_1 = require("../utils/http");
|
|
7
|
+
const endpoint = 'chunks';
|
|
8
|
+
/**
|
|
9
|
+
* Upload chunk to a Bee node
|
|
10
|
+
*
|
|
11
|
+
* The chunk data consists of 8 byte span and up to 4096 bytes of payload data.
|
|
12
|
+
* The span stores the length of the payload in uint64 little endian encoding.
|
|
13
|
+
* Upload expects the chuck data to be set accordingly.
|
|
14
|
+
*
|
|
15
|
+
* @param ky Ky instance
|
|
16
|
+
* @param data Chunk data to be uploaded
|
|
17
|
+
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
18
|
+
* @param options Additional options like tag, encryption, pinning
|
|
19
|
+
*/
|
|
20
|
+
async function upload(requestOptions, data, postageBatchId, options) {
|
|
21
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
22
|
+
method: 'post',
|
|
23
|
+
url: `${endpoint}`,
|
|
24
|
+
data,
|
|
25
|
+
headers: {
|
|
26
|
+
'content-type': 'application/octet-stream',
|
|
27
|
+
...(0, headers_1.extractUploadHeaders)(postageBatchId, options),
|
|
28
|
+
},
|
|
29
|
+
responseType: 'json',
|
|
30
|
+
});
|
|
31
|
+
return response.data.reference;
|
|
32
|
+
}
|
|
33
|
+
exports.upload = upload;
|
|
34
|
+
/**
|
|
35
|
+
* Download chunk data as a byte array
|
|
36
|
+
*
|
|
37
|
+
* @param kyOptions Ky Options for making requests
|
|
38
|
+
* @param hash Bee content reference
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
async function download(requestOptions, hash) {
|
|
42
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
43
|
+
responseType: 'arraybuffer',
|
|
44
|
+
url: `${endpoint}/${hash}`,
|
|
45
|
+
});
|
|
46
|
+
return (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.data));
|
|
47
|
+
}
|
|
48
|
+
exports.download = download;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPastDueConsumptionPeerBalance = exports.getPastDueConsumptionBalances = exports.getPeerBalance = exports.getAllBalances = void 0;
|
|
4
|
+
const http_1 = require("../../utils/http");
|
|
5
|
+
const balancesEndpoint = 'balances';
|
|
6
|
+
const consumedEndpoint = 'consumed';
|
|
7
|
+
/**
|
|
8
|
+
* Get the balances with all known peers including prepaid services
|
|
9
|
+
*
|
|
10
|
+
* @param kyOptions Ky Options for making requests
|
|
11
|
+
*/
|
|
12
|
+
async function getAllBalances(requestOptions) {
|
|
13
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
14
|
+
url: balancesEndpoint,
|
|
15
|
+
responseType: 'json',
|
|
16
|
+
});
|
|
17
|
+
return response.data;
|
|
18
|
+
}
|
|
19
|
+
exports.getAllBalances = getAllBalances;
|
|
20
|
+
/**
|
|
21
|
+
* Get the balances with a specific peer including prepaid services
|
|
22
|
+
*
|
|
23
|
+
* @param kyOptions Ky Options for making requests
|
|
24
|
+
* @param address Swarm address of peer
|
|
25
|
+
*/
|
|
26
|
+
async function getPeerBalance(requestOptions, address) {
|
|
27
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
28
|
+
url: `${balancesEndpoint}/${address}`,
|
|
29
|
+
responseType: 'json',
|
|
30
|
+
});
|
|
31
|
+
return response.data;
|
|
32
|
+
}
|
|
33
|
+
exports.getPeerBalance = getPeerBalance;
|
|
34
|
+
/**
|
|
35
|
+
* Get the past due consumption balances with all known peers
|
|
36
|
+
*
|
|
37
|
+
* @param kyOptions Ky Options for making requests
|
|
38
|
+
*/
|
|
39
|
+
async function getPastDueConsumptionBalances(requestOptions) {
|
|
40
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
41
|
+
url: consumedEndpoint,
|
|
42
|
+
responseType: 'json',
|
|
43
|
+
});
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
46
|
+
exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
|
|
47
|
+
/**
|
|
48
|
+
* Get the past due consumption balance with a specific peer
|
|
49
|
+
*
|
|
50
|
+
* @param kyOptions Ky Options for making requests
|
|
51
|
+
* @param address Swarm address of peer
|
|
52
|
+
*/
|
|
53
|
+
async function getPastDueConsumptionPeerBalance(requestOptions, address) {
|
|
54
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
55
|
+
url: `${consumedEndpoint}/${address}`,
|
|
56
|
+
responseType: 'json',
|
|
57
|
+
});
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
exports.getPastDueConsumptionPeerBalance = getPastDueConsumptionPeerBalance;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withdrawTokens = exports.depositTokens = exports.getLastCheques = exports.getLastChequesForPeer = exports.cashoutLastCheque = exports.getLastCashoutAction = exports.getChequebookBalance = exports.getChequebookAddress = void 0;
|
|
4
|
+
const http_1 = require("../../utils/http");
|
|
5
|
+
const chequebookEndpoint = 'chequebook';
|
|
6
|
+
/**
|
|
7
|
+
* Get the address of the chequebook contract used
|
|
8
|
+
*
|
|
9
|
+
* @param kyOptions Ky Options for making requests
|
|
10
|
+
*/
|
|
11
|
+
async function getChequebookAddress(requestOptions) {
|
|
12
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
13
|
+
url: chequebookEndpoint + '/address',
|
|
14
|
+
responseType: 'json',
|
|
15
|
+
});
|
|
16
|
+
return response.data;
|
|
17
|
+
}
|
|
18
|
+
exports.getChequebookAddress = getChequebookAddress;
|
|
19
|
+
/**
|
|
20
|
+
* Get the balance of the chequebook
|
|
21
|
+
*
|
|
22
|
+
* @param kyOptions Ky Options for making requests
|
|
23
|
+
*/
|
|
24
|
+
async function getChequebookBalance(requestOptions) {
|
|
25
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
26
|
+
url: chequebookEndpoint + '/balance',
|
|
27
|
+
responseType: 'json',
|
|
28
|
+
});
|
|
29
|
+
return response.data;
|
|
30
|
+
}
|
|
31
|
+
exports.getChequebookBalance = getChequebookBalance;
|
|
32
|
+
/**
|
|
33
|
+
* Get last cashout action for the peer
|
|
34
|
+
*
|
|
35
|
+
* @param kyOptions Ky Options for making requests
|
|
36
|
+
* @param peer Swarm address of peer
|
|
37
|
+
*/
|
|
38
|
+
async function getLastCashoutAction(requestOptions, peer) {
|
|
39
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
40
|
+
url: chequebookEndpoint + `/cashout/${peer}`,
|
|
41
|
+
responseType: 'json',
|
|
42
|
+
});
|
|
43
|
+
return response.data;
|
|
44
|
+
}
|
|
45
|
+
exports.getLastCashoutAction = getLastCashoutAction;
|
|
46
|
+
/**
|
|
47
|
+
* Cashout the last cheque for the peer
|
|
48
|
+
*
|
|
49
|
+
* @param kyOptions Ky Options for making requests
|
|
50
|
+
* @param peer Swarm address of peer
|
|
51
|
+
* @param options
|
|
52
|
+
*/
|
|
53
|
+
async function cashoutLastCheque(requestOptions, peer, options) {
|
|
54
|
+
const headers = {};
|
|
55
|
+
if (options?.gasPrice) {
|
|
56
|
+
headers['gas-price'] = options.gasPrice.toString();
|
|
57
|
+
}
|
|
58
|
+
if (options?.gasLimit) {
|
|
59
|
+
headers['gas-limit'] = options.gasLimit.toString();
|
|
60
|
+
}
|
|
61
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
62
|
+
method: 'post',
|
|
63
|
+
url: chequebookEndpoint + `/cashout/${peer}`,
|
|
64
|
+
responseType: 'json',
|
|
65
|
+
headers,
|
|
66
|
+
});
|
|
67
|
+
return response.data.transactionHash;
|
|
68
|
+
}
|
|
69
|
+
exports.cashoutLastCheque = cashoutLastCheque;
|
|
70
|
+
/**
|
|
71
|
+
* Get last cheques for the peer
|
|
72
|
+
*
|
|
73
|
+
* @param kyOptions Ky Options for making requests
|
|
74
|
+
* @param peer Swarm address of peer
|
|
75
|
+
*/
|
|
76
|
+
async function getLastChequesForPeer(requestOptions, peer) {
|
|
77
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
78
|
+
url: chequebookEndpoint + `/cheque/${peer}`,
|
|
79
|
+
responseType: 'json',
|
|
80
|
+
});
|
|
81
|
+
return response.data;
|
|
82
|
+
}
|
|
83
|
+
exports.getLastChequesForPeer = getLastChequesForPeer;
|
|
84
|
+
/**
|
|
85
|
+
* Get last cheques for all peers
|
|
86
|
+
*
|
|
87
|
+
* @param kyOptions Ky Options for making requests
|
|
88
|
+
*/
|
|
89
|
+
async function getLastCheques(requestOptions) {
|
|
90
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
91
|
+
url: chequebookEndpoint + '/cheque',
|
|
92
|
+
responseType: 'json',
|
|
93
|
+
});
|
|
94
|
+
return response.data;
|
|
95
|
+
}
|
|
96
|
+
exports.getLastCheques = getLastCheques;
|
|
97
|
+
/**
|
|
98
|
+
* Deposit tokens from overlay address into chequebook
|
|
99
|
+
*
|
|
100
|
+
* @param kyOptions Ky Options for making requests
|
|
101
|
+
* @param amount Amount of tokens to deposit
|
|
102
|
+
* @param gasPrice Gas Price in WEI for the transaction call
|
|
103
|
+
* @return string Hash of the transaction
|
|
104
|
+
*/
|
|
105
|
+
async function depositTokens(requestOptions, amount, gasPrice) {
|
|
106
|
+
const headers = {};
|
|
107
|
+
if (gasPrice) {
|
|
108
|
+
headers['gas-price'] = gasPrice.toString();
|
|
109
|
+
}
|
|
110
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
111
|
+
method: 'post',
|
|
112
|
+
url: chequebookEndpoint + '/deposit',
|
|
113
|
+
responseType: 'json',
|
|
114
|
+
params: { amount: amount.toString(10) },
|
|
115
|
+
headers,
|
|
116
|
+
});
|
|
117
|
+
return response.data.transactionHash;
|
|
118
|
+
}
|
|
119
|
+
exports.depositTokens = depositTokens;
|
|
120
|
+
/**
|
|
121
|
+
* Withdraw tokens from the chequebook to the overlay address
|
|
122
|
+
*
|
|
123
|
+
* @param kyOptions Ky Options for making requests
|
|
124
|
+
* @param amount Amount of tokens to withdraw
|
|
125
|
+
* @param gasPrice Gas Price in WEI for the transaction call
|
|
126
|
+
* @return string Hash of the transaction
|
|
127
|
+
*/
|
|
128
|
+
async function withdrawTokens(requestOptions, amount, gasPrice) {
|
|
129
|
+
const headers = {};
|
|
130
|
+
if (gasPrice) {
|
|
131
|
+
headers['gas-price'] = gasPrice.toString();
|
|
132
|
+
}
|
|
133
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
134
|
+
method: 'post',
|
|
135
|
+
url: chequebookEndpoint + '/withdraw',
|
|
136
|
+
responseType: 'json',
|
|
137
|
+
params: { amount: amount.toString(10) },
|
|
138
|
+
headers,
|
|
139
|
+
});
|
|
140
|
+
return response.data.transactionHash;
|
|
141
|
+
}
|
|
142
|
+
exports.withdrawTokens = withdrawTokens;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteChunkFromLocalStorage = exports.checkIfChunkExistsLocally = void 0;
|
|
4
|
+
const http_1 = require("../../utils/http");
|
|
5
|
+
const endpoint = 'chunks';
|
|
6
|
+
/**
|
|
7
|
+
* Check if chunk at address exists locally
|
|
8
|
+
*
|
|
9
|
+
* @param kyOptions Ky Options for making requests
|
|
10
|
+
* @param address Swarm address of chunk
|
|
11
|
+
*
|
|
12
|
+
* @returns BeeGenericResponse if chunk is found or throws an exception
|
|
13
|
+
*/
|
|
14
|
+
async function checkIfChunkExistsLocally(requestOptions, address) {
|
|
15
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
16
|
+
url: `${endpoint}/${address}`,
|
|
17
|
+
responseType: 'json',
|
|
18
|
+
});
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
|
|
22
|
+
/**
|
|
23
|
+
* Delete a chunk from local storage
|
|
24
|
+
*
|
|
25
|
+
* @param kyOptions Ky Options for making requests
|
|
26
|
+
* @param address Swarm address of chunk
|
|
27
|
+
*
|
|
28
|
+
* @returns BeeGenericResponse if chunk was deleted or throws an exception
|
|
29
|
+
*/
|
|
30
|
+
async function deleteChunkFromLocalStorage(requestOptions, address) {
|
|
31
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
32
|
+
method: 'delete',
|
|
33
|
+
url: `${endpoint}/${address}`,
|
|
34
|
+
responseType: 'json',
|
|
35
|
+
});
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
exports.deleteChunkFromLocalStorage = deleteChunkFromLocalStorage;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
|
|
4
|
+
const http_1 = require("../../utils/http");
|
|
5
|
+
async function getNodeAddresses(requestOptions) {
|
|
6
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
7
|
+
url: 'addresses',
|
|
8
|
+
responseType: 'json',
|
|
9
|
+
});
|
|
10
|
+
return response.data;
|
|
11
|
+
}
|
|
12
|
+
exports.getNodeAddresses = getNodeAddresses;
|
|
13
|
+
async function getPeers(requestOptions) {
|
|
14
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
15
|
+
url: 'peers',
|
|
16
|
+
responseType: 'json',
|
|
17
|
+
});
|
|
18
|
+
return response.data.peers;
|
|
19
|
+
}
|
|
20
|
+
exports.getPeers = getPeers;
|
|
21
|
+
async function getBlocklist(requestOptions) {
|
|
22
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
23
|
+
url: 'blocklist',
|
|
24
|
+
responseType: 'json',
|
|
25
|
+
});
|
|
26
|
+
return response.data.peers;
|
|
27
|
+
}
|
|
28
|
+
exports.getBlocklist = getBlocklist;
|
|
29
|
+
async function removePeer(requestOptions, peer) {
|
|
30
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
31
|
+
url: `peers/${peer}`,
|
|
32
|
+
responseType: 'json',
|
|
33
|
+
method: 'DELETE',
|
|
34
|
+
});
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
exports.removePeer = removePeer;
|
|
38
|
+
async function getTopology(requestOptions) {
|
|
39
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
40
|
+
url: `topology`,
|
|
41
|
+
responseType: 'json',
|
|
42
|
+
});
|
|
43
|
+
return response.data;
|
|
44
|
+
}
|
|
45
|
+
exports.getTopology = getTopology;
|
|
46
|
+
async function pingPeer(requestOptions, peer) {
|
|
47
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
48
|
+
url: `pingpong/${peer}`,
|
|
49
|
+
responseType: 'json',
|
|
50
|
+
method: 'POST',
|
|
51
|
+
});
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
exports.pingPeer = pingPeer;
|