@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.areAllSequentialFeedsUpdateRetrievable = void 0;
|
|
4
|
-
const index_1 = require("./index");
|
|
5
|
-
const uint64_1 = require("../utils/uint64");
|
|
6
4
|
const hex_1 = require("../utils/hex");
|
|
5
|
+
const uint64_1 = require("../utils/uint64");
|
|
6
|
+
const index_1 = require("./index");
|
|
7
7
|
function makeNumericIndex(index) {
|
|
8
8
|
if (index instanceof Uint8Array) {
|
|
9
9
|
return (0, uint64_1.readUint64BigEndian)(index);
|
|
@@ -24,14 +24,13 @@ function makeNumericIndex(index) {
|
|
|
24
24
|
* @param ref
|
|
25
25
|
* @param options
|
|
26
26
|
*/
|
|
27
|
-
async function isChunkRetrievable(bee, ref,
|
|
27
|
+
async function isChunkRetrievable(bee, ref, requestOptions) {
|
|
28
28
|
try {
|
|
29
|
-
await bee.downloadChunk(ref,
|
|
29
|
+
await bee.downloadChunk(ref, requestOptions);
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
catch (e) {
|
|
33
|
-
|
|
34
|
-
if (err.status === 404) {
|
|
33
|
+
if (e?.response?.status === 404) {
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
37
36
|
throw e;
|
|
@@ -52,8 +51,8 @@ function getAllSequenceUpdateReferences(owner, topic, index) {
|
|
|
52
51
|
}
|
|
53
52
|
return updateReferences;
|
|
54
53
|
}
|
|
55
|
-
async function areAllSequentialFeedsUpdateRetrievable(bee, owner, topic, index,
|
|
56
|
-
const chunkRetrievablePromises = getAllSequenceUpdateReferences(owner, topic, index).map(async (ref) => isChunkRetrievable(bee, ref,
|
|
54
|
+
async function areAllSequentialFeedsUpdateRetrievable(bee, owner, topic, index, requestOptions) {
|
|
55
|
+
const chunkRetrievablePromises = getAllSequenceUpdateReferences(owner, topic, index).map(async (ref) => isChunkRetrievable(bee, ref, requestOptions));
|
|
57
56
|
return (await Promise.all(chunkRetrievablePromises)).every(result => result);
|
|
58
57
|
}
|
|
59
58
|
exports.areAllSequentialFeedsUpdateRetrievable = areAllSequentialFeedsUpdateRetrievable;
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,9 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
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
|
+
};
|
|
18
21
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
22
|
if (mod && mod.__esModule) return mod;
|
|
20
23
|
var result = {};
|
|
@@ -22,18 +25,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
25
|
__setModuleDefault(result, mod);
|
|
23
26
|
return result;
|
|
24
27
|
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.BeeDebug = exports.Bee = exports.
|
|
29
|
+
exports.BeeDebug = exports.Bee = exports.Utils = exports.SUPPORTED_BEE_VERSION_EXACT = exports.SUPPORTED_BEE_VERSION = void 0;
|
|
30
30
|
const bee_1 = require("./bee");
|
|
31
31
|
Object.defineProperty(exports, "Bee", { enumerable: true, get: function () { return bee_1.Bee; } });
|
|
32
32
|
const bee_debug_1 = require("./bee-debug");
|
|
33
33
|
Object.defineProperty(exports, "BeeDebug", { enumerable: true, get: function () { return bee_debug_1.BeeDebug; } });
|
|
34
|
-
exports.Utils = __importStar(require("./utils/expose"));
|
|
35
|
-
__exportStar(require("./types"), exports);
|
|
36
|
-
__exportStar(require("./utils/error"), exports);
|
|
37
34
|
var status_1 = require("./modules/debug/status");
|
|
38
35
|
Object.defineProperty(exports, "SUPPORTED_BEE_VERSION", { enumerable: true, get: function () { return status_1.SUPPORTED_BEE_VERSION; } });
|
|
39
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"));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.downloadReadable = exports.download = exports.upload = void 0;
|
|
4
|
+
const bytes_1 = require("../utils/bytes");
|
|
4
5
|
const data_1 = require("../utils/data");
|
|
5
6
|
const headers_1 = require("../utils/headers");
|
|
6
7
|
const http_1 = require("../utils/http");
|
|
7
|
-
const bytes_1 = require("../utils/bytes");
|
|
8
8
|
const type_1 = require("../utils/type");
|
|
9
9
|
const endpoint = 'bytes';
|
|
10
10
|
/**
|
|
@@ -15,20 +15,20 @@ const endpoint = 'bytes';
|
|
|
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)(
|
|
20
|
-
|
|
18
|
+
async function upload(requestOptions, data, postageBatchId, options) {
|
|
19
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
20
|
+
url: endpoint,
|
|
21
21
|
method: 'post',
|
|
22
22
|
responseType: 'json',
|
|
23
|
-
|
|
23
|
+
data: await (0, data_1.prepareData)(data),
|
|
24
24
|
headers: {
|
|
25
25
|
'content-type': 'application/octet-stream',
|
|
26
26
|
...(0, headers_1.extractUploadHeaders)(postageBatchId, options),
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
return {
|
|
30
|
-
reference: response.
|
|
31
|
-
tagUid: (0, type_1.makeTagUid)(response.headers
|
|
30
|
+
reference: response.data.reference,
|
|
31
|
+
tagUid: (0, type_1.makeTagUid)(response.headers['swarm-tag']),
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
exports.upload = upload;
|
|
@@ -38,12 +38,12 @@ exports.upload = upload;
|
|
|
38
38
|
* @param ky
|
|
39
39
|
* @param hash Bee content reference
|
|
40
40
|
*/
|
|
41
|
-
async function download(
|
|
42
|
-
const response = await (0, http_1.http)(
|
|
41
|
+
async function download(requestOptions, hash) {
|
|
42
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
43
43
|
responseType: 'arraybuffer',
|
|
44
|
-
|
|
44
|
+
url: `${endpoint}/${hash}`,
|
|
45
45
|
});
|
|
46
|
-
return (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.
|
|
46
|
+
return (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.data));
|
|
47
47
|
}
|
|
48
48
|
exports.download = download;
|
|
49
49
|
/**
|
|
@@ -52,11 +52,11 @@ exports.download = download;
|
|
|
52
52
|
* @param ky
|
|
53
53
|
* @param hash Bee content reference
|
|
54
54
|
*/
|
|
55
|
-
async function downloadReadable(
|
|
56
|
-
const response = await (0, http_1.http)(
|
|
55
|
+
async function downloadReadable(requestOptions, hash) {
|
|
56
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
57
57
|
responseType: 'stream',
|
|
58
|
-
|
|
58
|
+
url: `${endpoint}/${hash}`,
|
|
59
59
|
});
|
|
60
|
-
return response.
|
|
60
|
+
return response.data;
|
|
61
61
|
}
|
|
62
62
|
exports.downloadReadable = downloadReadable;
|
package/dist/cjs/modules/bzz.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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");
|
|
4
6
|
const headers_1 = require("../utils/headers");
|
|
5
7
|
const http_1 = require("../utils/http");
|
|
6
|
-
const data_1 = require("../utils/data");
|
|
7
|
-
const tar_1 = require("../utils/tar");
|
|
8
|
-
const collection_1 = require("../utils/collection");
|
|
9
|
-
const bytes_1 = require("../utils/bytes");
|
|
10
8
|
const stream_1 = require("../utils/stream");
|
|
9
|
+
const tar_1 = require("../utils/tar");
|
|
11
10
|
const type_1 = require("../utils/type");
|
|
12
11
|
const bzzEndpoint = 'bzz';
|
|
13
12
|
function extractFileUploadHeaders(postageBatchId, options) {
|
|
@@ -27,25 +26,25 @@ function extractFileUploadHeaders(postageBatchId, options) {
|
|
|
27
26
|
* @param name Name that will be attached to the uploaded file. Wraps the data into manifest with set index document.
|
|
28
27
|
* @param options
|
|
29
28
|
*/
|
|
30
|
-
async function uploadFile(
|
|
29
|
+
async function uploadFile(requestOptions, data, postageBatchId, name, options) {
|
|
31
30
|
if ((0, stream_1.isReadable)(data) && !options?.contentType) {
|
|
32
31
|
if (!options)
|
|
33
32
|
options = {};
|
|
34
33
|
options.contentType = 'application/octet-stream';
|
|
35
34
|
}
|
|
36
|
-
const response = await (0, http_1.http)(
|
|
35
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
37
36
|
method: 'post',
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
url: bzzEndpoint,
|
|
38
|
+
data,
|
|
40
39
|
headers: {
|
|
41
40
|
...extractFileUploadHeaders(postageBatchId, options),
|
|
42
41
|
},
|
|
43
|
-
|
|
42
|
+
params: { name },
|
|
44
43
|
responseType: 'json',
|
|
45
44
|
});
|
|
46
45
|
return {
|
|
47
|
-
reference: response.
|
|
48
|
-
tagUid: (0, type_1.makeTagUid)(response.headers
|
|
46
|
+
reference: response.data.reference,
|
|
47
|
+
tagUid: (0, type_1.makeTagUid)(response.headers['swarm-tag']),
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
exports.uploadFile = uploadFile;
|
|
@@ -56,15 +55,15 @@ exports.uploadFile = uploadFile;
|
|
|
56
55
|
* @param hash Bee file or collection hash
|
|
57
56
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
58
57
|
*/
|
|
59
|
-
async function downloadFile(
|
|
60
|
-
const response = await (0, http_1.http)(
|
|
58
|
+
async function downloadFile(requestOptions, hash, path = '') {
|
|
59
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
61
60
|
method: 'GET',
|
|
62
61
|
responseType: 'arraybuffer',
|
|
63
|
-
|
|
62
|
+
url: `${bzzEndpoint}/${hash}/${path}`,
|
|
64
63
|
});
|
|
65
64
|
const file = {
|
|
66
65
|
...(0, headers_1.readFileHeaders)(response.headers),
|
|
67
|
-
data: (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.
|
|
66
|
+
data: (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.data)),
|
|
68
67
|
};
|
|
69
68
|
return file;
|
|
70
69
|
}
|
|
@@ -76,15 +75,15 @@ exports.downloadFile = downloadFile;
|
|
|
76
75
|
* @param hash Bee file or collection hash
|
|
77
76
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
78
77
|
*/
|
|
79
|
-
async function downloadFileReadable(
|
|
80
|
-
const response = await (0, http_1.http)(
|
|
78
|
+
async function downloadFileReadable(requestOptions, hash, path = '') {
|
|
79
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
81
80
|
method: 'GET',
|
|
82
81
|
responseType: 'stream',
|
|
83
|
-
|
|
82
|
+
url: `${bzzEndpoint}/${hash}/${path}`,
|
|
84
83
|
});
|
|
85
84
|
const file = {
|
|
86
85
|
...(0, headers_1.readFileHeaders)(response.headers),
|
|
87
|
-
data: response.
|
|
86
|
+
data: response.data,
|
|
88
87
|
};
|
|
89
88
|
return file;
|
|
90
89
|
}
|
|
@@ -104,13 +103,13 @@ function extractCollectionUploadHeaders(postageBatchId, options) {
|
|
|
104
103
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
105
104
|
* @param options
|
|
106
105
|
*/
|
|
107
|
-
async function uploadCollection(
|
|
106
|
+
async function uploadCollection(requestOptions, collection, postageBatchId, options) {
|
|
108
107
|
(0, collection_1.assertCollection)(collection);
|
|
109
108
|
const tarData = (0, tar_1.makeTar)(collection);
|
|
110
|
-
const response = await (0, http_1.http)(
|
|
109
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
111
110
|
method: 'post',
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
url: bzzEndpoint,
|
|
112
|
+
data: tarData,
|
|
114
113
|
responseType: 'json',
|
|
115
114
|
headers: {
|
|
116
115
|
'content-type': 'application/x-tar',
|
|
@@ -119,8 +118,8 @@ async function uploadCollection(kyOptions, collection, postageBatchId, options)
|
|
|
119
118
|
},
|
|
120
119
|
});
|
|
121
120
|
return {
|
|
122
|
-
reference: response.
|
|
123
|
-
tagUid: (0, type_1.makeTagUid)(response.headers
|
|
121
|
+
reference: response.data.reference,
|
|
122
|
+
tagUid: (0, type_1.makeTagUid)(response.headers['swarm-tag']),
|
|
124
123
|
};
|
|
125
124
|
}
|
|
126
125
|
exports.uploadCollection = uploadCollection;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.download = exports.upload = void 0;
|
|
4
|
+
const bytes_1 = require("../utils/bytes");
|
|
4
5
|
const headers_1 = require("../utils/headers");
|
|
5
6
|
const http_1 = require("../utils/http");
|
|
6
|
-
const bytes_1 = require("../utils/bytes");
|
|
7
7
|
const endpoint = 'chunks';
|
|
8
8
|
/**
|
|
9
9
|
* Upload chunk to a Bee node
|
|
@@ -17,18 +17,18 @@ const endpoint = 'chunks';
|
|
|
17
17
|
* @param postageBatchId Postage BatchId that will be assigned to uploaded data
|
|
18
18
|
* @param options Additional options like tag, encryption, pinning
|
|
19
19
|
*/
|
|
20
|
-
async function upload(
|
|
21
|
-
const response = await (0, http_1.http)(
|
|
20
|
+
async function upload(requestOptions, data, postageBatchId, options) {
|
|
21
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
22
22
|
method: 'post',
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
url: `${endpoint}`,
|
|
24
|
+
data,
|
|
25
25
|
headers: {
|
|
26
26
|
'content-type': 'application/octet-stream',
|
|
27
27
|
...(0, headers_1.extractUploadHeaders)(postageBatchId, options),
|
|
28
28
|
},
|
|
29
29
|
responseType: 'json',
|
|
30
30
|
});
|
|
31
|
-
return response.
|
|
31
|
+
return response.data.reference;
|
|
32
32
|
}
|
|
33
33
|
exports.upload = upload;
|
|
34
34
|
/**
|
|
@@ -38,11 +38,11 @@ exports.upload = upload;
|
|
|
38
38
|
* @param hash Bee content reference
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
41
|
-
async function download(
|
|
42
|
-
const response = await (0, http_1.http)(
|
|
41
|
+
async function download(requestOptions, hash) {
|
|
42
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
43
43
|
responseType: 'arraybuffer',
|
|
44
|
-
|
|
44
|
+
url: `${endpoint}/${hash}`,
|
|
45
45
|
});
|
|
46
|
-
return (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.
|
|
46
|
+
return (0, bytes_1.wrapBytesWithHelpers)(new Uint8Array(response.data));
|
|
47
47
|
}
|
|
48
48
|
exports.download = download;
|
|
@@ -9,12 +9,12 @@ const consumedEndpoint = 'consumed';
|
|
|
9
9
|
*
|
|
10
10
|
* @param kyOptions Ky Options for making requests
|
|
11
11
|
*/
|
|
12
|
-
async function getAllBalances(
|
|
13
|
-
const response = await (0, http_1.http)(
|
|
14
|
-
|
|
12
|
+
async function getAllBalances(requestOptions) {
|
|
13
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
14
|
+
url: balancesEndpoint,
|
|
15
15
|
responseType: 'json',
|
|
16
16
|
});
|
|
17
|
-
return response.
|
|
17
|
+
return response.data;
|
|
18
18
|
}
|
|
19
19
|
exports.getAllBalances = getAllBalances;
|
|
20
20
|
/**
|
|
@@ -23,12 +23,12 @@ exports.getAllBalances = getAllBalances;
|
|
|
23
23
|
* @param kyOptions Ky Options for making requests
|
|
24
24
|
* @param address Swarm address of peer
|
|
25
25
|
*/
|
|
26
|
-
async function getPeerBalance(
|
|
27
|
-
const response = await (0, http_1.http)(
|
|
28
|
-
|
|
26
|
+
async function getPeerBalance(requestOptions, address) {
|
|
27
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
28
|
+
url: `${balancesEndpoint}/${address}`,
|
|
29
29
|
responseType: 'json',
|
|
30
30
|
});
|
|
31
|
-
return response.
|
|
31
|
+
return response.data;
|
|
32
32
|
}
|
|
33
33
|
exports.getPeerBalance = getPeerBalance;
|
|
34
34
|
/**
|
|
@@ -36,12 +36,12 @@ exports.getPeerBalance = getPeerBalance;
|
|
|
36
36
|
*
|
|
37
37
|
* @param kyOptions Ky Options for making requests
|
|
38
38
|
*/
|
|
39
|
-
async function getPastDueConsumptionBalances(
|
|
40
|
-
const response = await (0, http_1.http)(
|
|
41
|
-
|
|
39
|
+
async function getPastDueConsumptionBalances(requestOptions) {
|
|
40
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
41
|
+
url: consumedEndpoint,
|
|
42
42
|
responseType: 'json',
|
|
43
43
|
});
|
|
44
|
-
return response.
|
|
44
|
+
return response.data;
|
|
45
45
|
}
|
|
46
46
|
exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
|
|
47
47
|
/**
|
|
@@ -50,11 +50,11 @@ exports.getPastDueConsumptionBalances = getPastDueConsumptionBalances;
|
|
|
50
50
|
* @param kyOptions Ky Options for making requests
|
|
51
51
|
* @param address Swarm address of peer
|
|
52
52
|
*/
|
|
53
|
-
async function getPastDueConsumptionPeerBalance(
|
|
54
|
-
const response = await (0, http_1.http)(
|
|
55
|
-
|
|
53
|
+
async function getPastDueConsumptionPeerBalance(requestOptions, address) {
|
|
54
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
55
|
+
url: `${consumedEndpoint}/${address}`,
|
|
56
56
|
responseType: 'json',
|
|
57
57
|
});
|
|
58
|
-
return response.
|
|
58
|
+
return response.data;
|
|
59
59
|
}
|
|
60
60
|
exports.getPastDueConsumptionPeerBalance = getPastDueConsumptionPeerBalance;
|
|
@@ -8,12 +8,12 @@ const chequebookEndpoint = 'chequebook';
|
|
|
8
8
|
*
|
|
9
9
|
* @param kyOptions Ky Options for making requests
|
|
10
10
|
*/
|
|
11
|
-
async function getChequebookAddress(
|
|
12
|
-
const response = await (0, http_1.http)(
|
|
13
|
-
|
|
11
|
+
async function getChequebookAddress(requestOptions) {
|
|
12
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
13
|
+
url: chequebookEndpoint + '/address',
|
|
14
14
|
responseType: 'json',
|
|
15
15
|
});
|
|
16
|
-
return response.
|
|
16
|
+
return response.data;
|
|
17
17
|
}
|
|
18
18
|
exports.getChequebookAddress = getChequebookAddress;
|
|
19
19
|
/**
|
|
@@ -21,12 +21,12 @@ exports.getChequebookAddress = getChequebookAddress;
|
|
|
21
21
|
*
|
|
22
22
|
* @param kyOptions Ky Options for making requests
|
|
23
23
|
*/
|
|
24
|
-
async function getChequebookBalance(
|
|
25
|
-
const response = await (0, http_1.http)(
|
|
26
|
-
|
|
24
|
+
async function getChequebookBalance(requestOptions) {
|
|
25
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
26
|
+
url: chequebookEndpoint + '/balance',
|
|
27
27
|
responseType: 'json',
|
|
28
28
|
});
|
|
29
|
-
return response.
|
|
29
|
+
return response.data;
|
|
30
30
|
}
|
|
31
31
|
exports.getChequebookBalance = getChequebookBalance;
|
|
32
32
|
/**
|
|
@@ -35,12 +35,12 @@ exports.getChequebookBalance = getChequebookBalance;
|
|
|
35
35
|
* @param kyOptions Ky Options for making requests
|
|
36
36
|
* @param peer Swarm address of peer
|
|
37
37
|
*/
|
|
38
|
-
async function getLastCashoutAction(
|
|
39
|
-
const response = await (0, http_1.http)(
|
|
40
|
-
|
|
38
|
+
async function getLastCashoutAction(requestOptions, peer) {
|
|
39
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
40
|
+
url: chequebookEndpoint + `/cashout/${peer}`,
|
|
41
41
|
responseType: 'json',
|
|
42
42
|
});
|
|
43
|
-
return response.
|
|
43
|
+
return response.data;
|
|
44
44
|
}
|
|
45
45
|
exports.getLastCashoutAction = getLastCashoutAction;
|
|
46
46
|
/**
|
|
@@ -50,7 +50,7 @@ exports.getLastCashoutAction = getLastCashoutAction;
|
|
|
50
50
|
* @param peer Swarm address of peer
|
|
51
51
|
* @param options
|
|
52
52
|
*/
|
|
53
|
-
async function cashoutLastCheque(
|
|
53
|
+
async function cashoutLastCheque(requestOptions, peer, options) {
|
|
54
54
|
const headers = {};
|
|
55
55
|
if (options?.gasPrice) {
|
|
56
56
|
headers['gas-price'] = options.gasPrice.toString();
|
|
@@ -58,13 +58,13 @@ async function cashoutLastCheque(kyOptions, peer, options) {
|
|
|
58
58
|
if (options?.gasLimit) {
|
|
59
59
|
headers['gas-limit'] = options.gasLimit.toString();
|
|
60
60
|
}
|
|
61
|
-
const response = await (0, http_1.http)(
|
|
61
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
62
62
|
method: 'post',
|
|
63
|
-
|
|
63
|
+
url: chequebookEndpoint + `/cashout/${peer}`,
|
|
64
64
|
responseType: 'json',
|
|
65
65
|
headers,
|
|
66
66
|
});
|
|
67
|
-
return response.
|
|
67
|
+
return response.data.transactionHash;
|
|
68
68
|
}
|
|
69
69
|
exports.cashoutLastCheque = cashoutLastCheque;
|
|
70
70
|
/**
|
|
@@ -73,12 +73,12 @@ exports.cashoutLastCheque = cashoutLastCheque;
|
|
|
73
73
|
* @param kyOptions Ky Options for making requests
|
|
74
74
|
* @param peer Swarm address of peer
|
|
75
75
|
*/
|
|
76
|
-
async function getLastChequesForPeer(
|
|
77
|
-
const response = await (0, http_1.http)(
|
|
78
|
-
|
|
76
|
+
async function getLastChequesForPeer(requestOptions, peer) {
|
|
77
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
78
|
+
url: chequebookEndpoint + `/cheque/${peer}`,
|
|
79
79
|
responseType: 'json',
|
|
80
80
|
});
|
|
81
|
-
return response.
|
|
81
|
+
return response.data;
|
|
82
82
|
}
|
|
83
83
|
exports.getLastChequesForPeer = getLastChequesForPeer;
|
|
84
84
|
/**
|
|
@@ -86,12 +86,12 @@ exports.getLastChequesForPeer = getLastChequesForPeer;
|
|
|
86
86
|
*
|
|
87
87
|
* @param kyOptions Ky Options for making requests
|
|
88
88
|
*/
|
|
89
|
-
async function getLastCheques(
|
|
90
|
-
const response = await (0, http_1.http)(
|
|
91
|
-
|
|
89
|
+
async function getLastCheques(requestOptions) {
|
|
90
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
91
|
+
url: chequebookEndpoint + '/cheque',
|
|
92
92
|
responseType: 'json',
|
|
93
93
|
});
|
|
94
|
-
return response.
|
|
94
|
+
return response.data;
|
|
95
95
|
}
|
|
96
96
|
exports.getLastCheques = getLastCheques;
|
|
97
97
|
/**
|
|
@@ -102,19 +102,19 @@ exports.getLastCheques = getLastCheques;
|
|
|
102
102
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
103
103
|
* @return string Hash of the transaction
|
|
104
104
|
*/
|
|
105
|
-
async function depositTokens(
|
|
105
|
+
async function depositTokens(requestOptions, amount, gasPrice) {
|
|
106
106
|
const headers = {};
|
|
107
107
|
if (gasPrice) {
|
|
108
108
|
headers['gas-price'] = gasPrice.toString();
|
|
109
109
|
}
|
|
110
|
-
const response = await (0, http_1.http)(
|
|
110
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
111
111
|
method: 'post',
|
|
112
|
-
|
|
112
|
+
url: chequebookEndpoint + '/deposit',
|
|
113
113
|
responseType: 'json',
|
|
114
|
-
|
|
114
|
+
params: { amount: amount.toString(10) },
|
|
115
115
|
headers,
|
|
116
116
|
});
|
|
117
|
-
return response.
|
|
117
|
+
return response.data.transactionHash;
|
|
118
118
|
}
|
|
119
119
|
exports.depositTokens = depositTokens;
|
|
120
120
|
/**
|
|
@@ -125,18 +125,18 @@ exports.depositTokens = depositTokens;
|
|
|
125
125
|
* @param gasPrice Gas Price in WEI for the transaction call
|
|
126
126
|
* @return string Hash of the transaction
|
|
127
127
|
*/
|
|
128
|
-
async function withdrawTokens(
|
|
128
|
+
async function withdrawTokens(requestOptions, amount, gasPrice) {
|
|
129
129
|
const headers = {};
|
|
130
130
|
if (gasPrice) {
|
|
131
131
|
headers['gas-price'] = gasPrice.toString();
|
|
132
132
|
}
|
|
133
|
-
const response = await (0, http_1.http)(
|
|
133
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
134
134
|
method: 'post',
|
|
135
|
-
|
|
135
|
+
url: chequebookEndpoint + '/withdraw',
|
|
136
136
|
responseType: 'json',
|
|
137
|
-
|
|
137
|
+
params: { amount: amount.toString(10) },
|
|
138
138
|
headers,
|
|
139
139
|
});
|
|
140
|
-
return response.
|
|
140
|
+
return response.data.transactionHash;
|
|
141
141
|
}
|
|
142
142
|
exports.withdrawTokens = withdrawTokens;
|
|
@@ -11,12 +11,12 @@ const endpoint = 'chunks';
|
|
|
11
11
|
*
|
|
12
12
|
* @returns BeeGenericResponse if chunk is found or throws an exception
|
|
13
13
|
*/
|
|
14
|
-
async function checkIfChunkExistsLocally(
|
|
15
|
-
const response = await (0, http_1.http)(
|
|
16
|
-
|
|
14
|
+
async function checkIfChunkExistsLocally(requestOptions, address) {
|
|
15
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
16
|
+
url: `${endpoint}/${address}`,
|
|
17
17
|
responseType: 'json',
|
|
18
18
|
});
|
|
19
|
-
return response.
|
|
19
|
+
return response.data;
|
|
20
20
|
}
|
|
21
21
|
exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
|
|
22
22
|
/**
|
|
@@ -27,12 +27,12 @@ exports.checkIfChunkExistsLocally = checkIfChunkExistsLocally;
|
|
|
27
27
|
*
|
|
28
28
|
* @returns BeeGenericResponse if chunk was deleted or throws an exception
|
|
29
29
|
*/
|
|
30
|
-
async function deleteChunkFromLocalStorage(
|
|
31
|
-
const response = await (0, http_1.http)(
|
|
30
|
+
async function deleteChunkFromLocalStorage(requestOptions, address) {
|
|
31
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
32
32
|
method: 'delete',
|
|
33
|
-
|
|
33
|
+
url: `${endpoint}/${address}`,
|
|
34
34
|
responseType: 'json',
|
|
35
35
|
});
|
|
36
|
-
return response.
|
|
36
|
+
return response.data;
|
|
37
37
|
}
|
|
38
38
|
exports.deleteChunkFromLocalStorage = deleteChunkFromLocalStorage;
|
|
@@ -2,53 +2,53 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pingPeer = exports.getTopology = exports.removePeer = exports.getBlocklist = exports.getPeers = exports.getNodeAddresses = void 0;
|
|
4
4
|
const http_1 = require("../../utils/http");
|
|
5
|
-
async function getNodeAddresses(
|
|
6
|
-
const response = await (0, http_1.http)(
|
|
7
|
-
|
|
5
|
+
async function getNodeAddresses(requestOptions) {
|
|
6
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
7
|
+
url: 'addresses',
|
|
8
8
|
responseType: 'json',
|
|
9
9
|
});
|
|
10
|
-
return response.
|
|
10
|
+
return response.data;
|
|
11
11
|
}
|
|
12
12
|
exports.getNodeAddresses = getNodeAddresses;
|
|
13
|
-
async function getPeers(
|
|
14
|
-
const response = await (0, http_1.http)(
|
|
15
|
-
|
|
13
|
+
async function getPeers(requestOptions) {
|
|
14
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
15
|
+
url: 'peers',
|
|
16
16
|
responseType: 'json',
|
|
17
17
|
});
|
|
18
|
-
return response.
|
|
18
|
+
return response.data.peers;
|
|
19
19
|
}
|
|
20
20
|
exports.getPeers = getPeers;
|
|
21
|
-
async function getBlocklist(
|
|
22
|
-
const response = await (0, http_1.http)(
|
|
23
|
-
|
|
21
|
+
async function getBlocklist(requestOptions) {
|
|
22
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
23
|
+
url: 'blocklist',
|
|
24
24
|
responseType: 'json',
|
|
25
25
|
});
|
|
26
|
-
return response.
|
|
26
|
+
return response.data.peers;
|
|
27
27
|
}
|
|
28
28
|
exports.getBlocklist = getBlocklist;
|
|
29
|
-
async function removePeer(
|
|
30
|
-
const response = await (0, http_1.http)(
|
|
31
|
-
|
|
29
|
+
async function removePeer(requestOptions, peer) {
|
|
30
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
31
|
+
url: `peers/${peer}`,
|
|
32
32
|
responseType: 'json',
|
|
33
33
|
method: 'DELETE',
|
|
34
34
|
});
|
|
35
|
-
return response.
|
|
35
|
+
return response.data;
|
|
36
36
|
}
|
|
37
37
|
exports.removePeer = removePeer;
|
|
38
|
-
async function getTopology(
|
|
39
|
-
const response = await (0, http_1.http)(
|
|
40
|
-
|
|
38
|
+
async function getTopology(requestOptions) {
|
|
39
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
40
|
+
url: `topology`,
|
|
41
41
|
responseType: 'json',
|
|
42
42
|
});
|
|
43
|
-
return response.
|
|
43
|
+
return response.data;
|
|
44
44
|
}
|
|
45
45
|
exports.getTopology = getTopology;
|
|
46
|
-
async function pingPeer(
|
|
47
|
-
const response = await (0, http_1.http)(
|
|
48
|
-
|
|
46
|
+
async function pingPeer(requestOptions, peer) {
|
|
47
|
+
const response = await (0, http_1.http)(requestOptions, {
|
|
48
|
+
url: `pingpong/${peer}`,
|
|
49
49
|
responseType: 'json',
|
|
50
50
|
method: 'POST',
|
|
51
51
|
});
|
|
52
|
-
return response.
|
|
52
|
+
return response.data;
|
|
53
53
|
}
|
|
54
54
|
exports.pingPeer = pingPeer;
|