@upcoming/bee-js 10.1.2 → 11.1.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/README.md +2 -2
- package/dist/cjs/bee.js +89 -12
- package/dist/cjs/chunk/bmt.js +1 -2
- package/dist/cjs/chunk/cac.js +27 -32
- package/dist/cjs/chunk/soc.js +39 -31
- package/dist/cjs/feed/identifier.js +1 -2
- package/dist/cjs/feed/index.js +29 -19
- package/dist/cjs/feed/retrievable.js +1 -2
- package/dist/cjs/index.js +17 -7
- package/dist/cjs/manifest/manifest.js +19 -2
- package/dist/cjs/modules/bytes.js +4 -5
- package/dist/cjs/modules/bzz.js +4 -5
- package/dist/cjs/modules/chunk.js +2 -3
- package/dist/cjs/modules/debug/balance.js +4 -5
- package/dist/cjs/modules/debug/chequebook.js +8 -9
- package/dist/cjs/modules/debug/connectivity.js +7 -8
- package/dist/cjs/modules/debug/settlements.js +2 -3
- package/dist/cjs/modules/debug/stake.js +6 -7
- package/dist/cjs/modules/debug/stamps.js +23 -77
- package/dist/cjs/modules/debug/states.js +6 -6
- package/dist/cjs/modules/debug/status.js +9 -9
- package/dist/cjs/modules/debug/transactions.js +4 -5
- package/dist/cjs/modules/envelope.js +1 -2
- package/dist/cjs/modules/feed.js +3 -4
- package/dist/cjs/modules/grantee.js +3 -4
- package/dist/cjs/modules/gsoc.js +2 -3
- package/dist/cjs/modules/pinning.js +4 -5
- package/dist/cjs/modules/pss.js +2 -3
- package/dist/cjs/modules/rchash.js +1 -2
- package/dist/cjs/modules/soc.js +1 -2
- package/dist/cjs/modules/status.js +2 -3
- package/dist/cjs/modules/stewardship.js +2 -3
- package/dist/cjs/modules/tag.js +5 -6
- package/dist/cjs/types/debug.js +3 -3
- package/dist/cjs/types/index.js +2 -2
- package/dist/cjs/utils/bytes.js +2 -2
- package/dist/cjs/utils/chunk-size.js +1 -2
- package/dist/cjs/utils/chunk-stream.browser.js +30 -6
- package/dist/cjs/utils/chunk-stream.js +3 -4
- package/dist/cjs/utils/cid.js +3 -3
- package/dist/cjs/utils/collection.browser.js +2 -3
- package/dist/cjs/utils/collection.js +5 -6
- package/dist/cjs/utils/collection.node.js +2 -3
- package/dist/cjs/utils/data.browser.js +1 -2
- package/dist/cjs/utils/data.js +1 -2
- package/dist/cjs/utils/expose.js +4 -1
- package/dist/cjs/utils/file.js +2 -3
- package/dist/cjs/utils/headers.js +2 -3
- package/dist/cjs/utils/http.js +25 -5
- package/dist/cjs/utils/pss.js +1 -2
- package/dist/cjs/utils/redundancy.js +3 -4
- package/dist/cjs/utils/stamps.js +60 -11
- package/dist/cjs/utils/tar-uploader.browser.js +1 -2
- package/dist/cjs/utils/tar-uploader.js +1 -2
- package/dist/cjs/utils/tar-writer.browser.js +1 -2
- package/dist/cjs/utils/tar-writer.js +1 -2
- package/dist/cjs/utils/type.js +35 -25
- package/dist/cjs/utils/url.js +3 -4
- package/dist/cjs/utils/workaround.js +7 -5
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +73 -8
- package/dist/mjs/chunk/cac.js +21 -30
- package/dist/mjs/chunk/soc.js +16 -17
- package/dist/mjs/feed/index.js +7 -6
- package/dist/mjs/manifest/manifest.js +19 -2
- package/dist/mjs/modules/debug/stamps.js +37 -110
- package/dist/mjs/modules/debug/states.js +3 -0
- package/dist/mjs/modules/debug/status.js +1 -1
- package/dist/mjs/utils/chunk-stream.browser.js +29 -5
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/http.js +25 -3
- package/dist/mjs/utils/stamps.js +48 -0
- package/dist/mjs/utils/type.js +2 -1
- package/dist/mjs/utils/workaround.js +5 -2
- package/dist/types/bee.d.ts +55 -4
- package/dist/types/chunk/cac.d.ts +27 -13
- package/dist/types/chunk/soc.d.ts +43 -11
- package/dist/types/index.d.ts +3 -0
- package/dist/types/modules/bzz.d.ts +0 -1
- package/dist/types/modules/debug/status.d.ts +1 -1
- package/dist/types/modules/gsoc.d.ts +0 -1
- package/dist/types/modules/pss.d.ts +0 -1
- package/dist/types/types/debug.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +3 -3
- package/dist/types/utils/error.d.ts +2 -2
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +15 -1
- package/dist/types/utils/tar.browser.d.ts +1 -1
- package/dist/types/utils/tar.d.ts +0 -1
- package/dist/types/utils/type.d.ts +0 -1
- package/package.json +10 -13
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getAllTransactions = getAllTransactions;
|
|
4
|
+
exports.getTransaction = getTransaction;
|
|
5
|
+
exports.rebroadcastTransaction = rebroadcastTransaction;
|
|
6
|
+
exports.cancelTransaction = cancelTransaction;
|
|
4
7
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
8
|
const http_1 = require("../../utils/http");
|
|
6
9
|
const type_1 = require("../../utils/type");
|
|
@@ -20,7 +23,6 @@ async function getAllTransactions(requestOptions) {
|
|
|
20
23
|
const pendingTransactions = cafe_utility_1.Types.asArray(body.pendingTransactions, { name: 'pendingTransactions' });
|
|
21
24
|
return pendingTransactions.map(toTransaction);
|
|
22
25
|
}
|
|
23
|
-
exports.getAllTransactions = getAllTransactions;
|
|
24
26
|
/**
|
|
25
27
|
* Get information for specific pending transactions
|
|
26
28
|
*
|
|
@@ -35,7 +37,6 @@ async function getTransaction(requestOptions, transactionHash) {
|
|
|
35
37
|
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
|
|
36
38
|
return toTransaction(body);
|
|
37
39
|
}
|
|
38
|
-
exports.getTransaction = getTransaction;
|
|
39
40
|
function toTransaction(value) {
|
|
40
41
|
const object = cafe_utility_1.Types.asObject(value, { name: 'transaction' });
|
|
41
42
|
return {
|
|
@@ -65,7 +66,6 @@ async function rebroadcastTransaction(requestOptions, transactionHash) {
|
|
|
65
66
|
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
|
|
66
67
|
return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
|
|
67
68
|
}
|
|
68
|
-
exports.rebroadcastTransaction = rebroadcastTransaction;
|
|
69
69
|
/**
|
|
70
70
|
* Cancel existing transaction
|
|
71
71
|
*
|
|
@@ -87,4 +87,3 @@ async function cancelTransaction(requestOptions, transactionHash, gasPrice) {
|
|
|
87
87
|
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
|
|
88
88
|
return new typed_bytes_1.TransactionId(cafe_utility_1.Types.asString(body.transactionHash, { name: 'transactionHash' }));
|
|
89
89
|
}
|
|
90
|
-
exports.cancelTransaction = cancelTransaction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.postEnvelope =
|
|
3
|
+
exports.postEnvelope = postEnvelope;
|
|
4
4
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
5
|
const http_1 = require("../utils/http");
|
|
6
6
|
const ENVELOPE_ENDPOINT = 'envelope';
|
|
@@ -22,4 +22,3 @@ async function postEnvelope(requestOptions, postageBatchId, reference) {
|
|
|
22
22
|
batchId: postageBatchId,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
exports.postEnvelope = postEnvelope;
|
package/dist/cjs/modules/feed.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createFeedManifest = createFeedManifest;
|
|
4
|
+
exports.fetchLatestFeedUpdate = fetchLatestFeedUpdate;
|
|
5
|
+
exports.probeFeed = probeFeed;
|
|
4
6
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
7
|
const bytes_1 = require("../utils/bytes");
|
|
6
8
|
const error_1 = require("../utils/error");
|
|
@@ -27,7 +29,6 @@ async function createFeedManifest(requestOptions, owner, topic, stamp, options)
|
|
|
27
29
|
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
|
|
28
30
|
return new typed_bytes_1.Reference(cafe_utility_1.Types.asHexString(body.reference));
|
|
29
31
|
}
|
|
30
|
-
exports.createFeedManifest = createFeedManifest;
|
|
31
32
|
function readFeedUpdateHeaders(headers) {
|
|
32
33
|
const feedIndex = headers['swarm-feed-index'];
|
|
33
34
|
const feedIndexNext = headers['swarm-feed-index-next'];
|
|
@@ -66,7 +67,6 @@ async function fetchLatestFeedUpdate(requestOptions, owner, topic, options) {
|
|
|
66
67
|
...readFeedUpdateHeaders(response.headers),
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
|
-
exports.fetchLatestFeedUpdate = fetchLatestFeedUpdate;
|
|
70
70
|
async function probeFeed(requestOptions, owner, topic) {
|
|
71
71
|
const response = await (0, http_1.http)(requestOptions, {
|
|
72
72
|
responseType: 'arraybuffer',
|
|
@@ -77,4 +77,3 @@ async function probeFeed(requestOptions, owner, topic) {
|
|
|
77
77
|
});
|
|
78
78
|
return readFeedUpdateHeaders(response.headers);
|
|
79
79
|
}
|
|
80
|
-
exports.probeFeed = probeFeed;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getGrantees = getGrantees;
|
|
4
|
+
exports.createGrantees = createGrantees;
|
|
5
|
+
exports.patchGrantees = patchGrantees;
|
|
4
6
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
7
|
const headers_1 = require("../utils/headers");
|
|
6
8
|
const http_1 = require("../utils/http");
|
|
@@ -19,7 +21,6 @@ async function getGrantees(reference, requestOptions) {
|
|
|
19
21
|
grantees: body,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
|
-
exports.getGrantees = getGrantees;
|
|
23
24
|
async function createGrantees(requestOptions, postageBatchId, grantees) {
|
|
24
25
|
const response = await (0, http_1.http)(requestOptions, {
|
|
25
26
|
method: 'post',
|
|
@@ -36,7 +37,6 @@ async function createGrantees(requestOptions, postageBatchId, grantees) {
|
|
|
36
37
|
historyref: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.historyref, { name: 'historyref' })),
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
exports.createGrantees = createGrantees;
|
|
40
40
|
async function patchGrantees(postageBatchId, reference, historyRef, grantees, requestOptions) {
|
|
41
41
|
const response = await (0, http_1.http)(requestOptions, {
|
|
42
42
|
method: 'patch',
|
|
@@ -59,4 +59,3 @@ async function patchGrantees(postageBatchId, reference, historyRef, grantees, re
|
|
|
59
59
|
historyref: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.historyref, { name: 'historyref' })),
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
exports.patchGrantees = patchGrantees;
|
package/dist/cjs/modules/gsoc.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.send = send;
|
|
7
|
+
exports.subscribe = subscribe;
|
|
7
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
8
9
|
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
9
10
|
const soc_1 = require("../chunk/soc");
|
|
@@ -11,7 +12,6 @@ const endpoint = 'gsoc';
|
|
|
11
12
|
async function send(requestOptions, soc, stamp, options) {
|
|
12
13
|
return (0, soc_1.uploadSingleOwnerChunk)(requestOptions, soc, stamp, options);
|
|
13
14
|
}
|
|
14
|
-
exports.send = send;
|
|
15
15
|
function subscribe(url, reference, headers) {
|
|
16
16
|
const wsUrl = url.replace(/^http/i, 'ws');
|
|
17
17
|
if (cafe_utility_1.System.whereAmI() === 'browser') {
|
|
@@ -21,4 +21,3 @@ function subscribe(url, reference, headers) {
|
|
|
21
21
|
headers,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
exports.subscribe = subscribe;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.pin = pin;
|
|
4
|
+
exports.unpin = unpin;
|
|
5
|
+
exports.getPin = getPin;
|
|
6
|
+
exports.getAllPins = getAllPins;
|
|
4
7
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
8
|
const http_1 = require("../utils/http");
|
|
6
9
|
const typed_bytes_1 = require("../utils/typed-bytes");
|
|
@@ -18,7 +21,6 @@ async function pin(requestOptions, reference) {
|
|
|
18
21
|
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
|
-
exports.pin = pin;
|
|
22
24
|
/**
|
|
23
25
|
* Unpin data with given reference
|
|
24
26
|
*
|
|
@@ -32,7 +34,6 @@ async function unpin(requestOptions, reference) {
|
|
|
32
34
|
url: `${PINNING_ENDPOINT}/${reference}`,
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
|
-
exports.unpin = unpin;
|
|
36
37
|
/**
|
|
37
38
|
* Get pin status for specific address.
|
|
38
39
|
*
|
|
@@ -51,7 +52,6 @@ async function getPin(requestOptions, reference) {
|
|
|
51
52
|
reference: new typed_bytes_1.Reference(cafe_utility_1.Types.asString(body.reference, { name: 'reference' })),
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
exports.getPin = getPin;
|
|
55
55
|
/**
|
|
56
56
|
* Get list of all pins
|
|
57
57
|
*
|
|
@@ -71,4 +71,3 @@ async function getAllPins(requestOptions) {
|
|
|
71
71
|
const references = cafe_utility_1.Types.asArray(body.references, { name: 'references' }).map(x => cafe_utility_1.Types.asString(x, { name: 'reference' }));
|
|
72
72
|
return references.map(x => new typed_bytes_1.Reference(x));
|
|
73
73
|
}
|
|
74
|
-
exports.getAllPins = getAllPins;
|
package/dist/cjs/modules/pss.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.send = send;
|
|
7
|
+
exports.subscribe = subscribe;
|
|
7
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
8
9
|
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
9
10
|
const headers_1 = require("../utils/headers");
|
|
@@ -30,7 +31,6 @@ async function send(requestOptions, topic, target, data, postageBatchId, recipie
|
|
|
30
31
|
headers: (0, headers_1.prepareRequestHeaders)(postageBatchId),
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
exports.send = send;
|
|
34
34
|
/**
|
|
35
35
|
* Subscribe for messages on the given topic
|
|
36
36
|
*
|
|
@@ -46,4 +46,3 @@ function subscribe(url, topic, headers) {
|
|
|
46
46
|
headers,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
exports.subscribe = subscribe;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rchash =
|
|
3
|
+
exports.rchash = rchash;
|
|
4
4
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
5
|
const http_1 = require("../utils/http");
|
|
6
6
|
const RCHASH_ENDPOINT = 'rchash';
|
|
@@ -12,4 +12,3 @@ async function rchash(requestOptions, depth, anchor1, anchor2) {
|
|
|
12
12
|
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
|
|
13
13
|
return cafe_utility_1.Types.asNumber(body.durationSeconds, { name: 'durationSeconds' });
|
|
14
14
|
}
|
|
15
|
-
exports.rchash = rchash;
|
package/dist/cjs/modules/soc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upload =
|
|
3
|
+
exports.upload = upload;
|
|
4
4
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
5
|
const headers_1 = require("../utils/headers");
|
|
6
6
|
const http_1 = require("../utils/http");
|
|
@@ -39,4 +39,3 @@ async function upload(requestOptions, owner, identifier, signature, data, stamp,
|
|
|
39
39
|
: cafe_utility_1.Optional.empty(),
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
exports.upload = upload;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.checkConnection = checkConnection;
|
|
4
|
+
exports.isGateway = isGateway;
|
|
4
5
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
6
|
const http_1 = require("../utils/http");
|
|
6
7
|
/**
|
|
@@ -13,7 +14,6 @@ async function checkConnection(requestOptions) {
|
|
|
13
14
|
url: '',
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
|
-
exports.checkConnection = checkConnection;
|
|
17
17
|
async function isGateway(requestOptions) {
|
|
18
18
|
try {
|
|
19
19
|
const response = await (0, http_1.http)(requestOptions, {
|
|
@@ -26,4 +26,3 @@ async function isGateway(requestOptions) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.isGateway = isGateway;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.reupload = reupload;
|
|
4
|
+
exports.isRetrievable = isRetrievable;
|
|
4
5
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
6
|
const http_1 = require("../utils/http");
|
|
6
7
|
const typed_bytes_1 = require("../utils/typed-bytes");
|
|
@@ -18,7 +19,6 @@ async function reupload(requestOptions, stamp, reference) {
|
|
|
18
19
|
headers: { 'swarm-postage-batch-id': stamp.toHex() },
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
exports.reupload = reupload;
|
|
22
22
|
async function isRetrievable(requestOptions, reference) {
|
|
23
23
|
reference = new typed_bytes_1.Reference(reference);
|
|
24
24
|
const response = await (0, http_1.http)(requestOptions, {
|
|
@@ -29,4 +29,3 @@ async function isRetrievable(requestOptions, reference) {
|
|
|
29
29
|
const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
|
|
30
30
|
return cafe_utility_1.Types.asBoolean(body.isRetrievable, { name: 'isRetrievable' });
|
|
31
31
|
}
|
|
32
|
-
exports.isRetrievable = isRetrievable;
|
package/dist/cjs/modules/tag.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createTag = createTag;
|
|
4
|
+
exports.retrieveTag = retrieveTag;
|
|
5
|
+
exports.getAllTags = getAllTags;
|
|
6
|
+
exports.deleteTag = deleteTag;
|
|
7
|
+
exports.updateTag = updateTag;
|
|
4
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
9
|
const http_1 = require("../utils/http");
|
|
6
10
|
const endpoint = 'tags';
|
|
@@ -27,7 +31,6 @@ async function createTag(requestOptions) {
|
|
|
27
31
|
uid: cafe_utility_1.Types.asNumber(body.uid, { name: 'uid' }),
|
|
28
32
|
};
|
|
29
33
|
}
|
|
30
|
-
exports.createTag = createTag;
|
|
31
34
|
/**
|
|
32
35
|
* Retrieve tag information from Bee node
|
|
33
36
|
*
|
|
@@ -51,7 +54,6 @@ async function retrieveTag(requestOptions, uid) {
|
|
|
51
54
|
uid: cafe_utility_1.Types.asNumber(body.uid, { name: 'uid' }),
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
|
-
exports.retrieveTag = retrieveTag;
|
|
55
57
|
/**
|
|
56
58
|
* Get limited listing of all tags.
|
|
57
59
|
*
|
|
@@ -78,7 +80,6 @@ async function getAllTags(requestOptions, offset, limit) {
|
|
|
78
80
|
uid: cafe_utility_1.Types.asNumber(x.uid, { name: 'uid' }),
|
|
79
81
|
}));
|
|
80
82
|
}
|
|
81
|
-
exports.getAllTags = getAllTags;
|
|
82
83
|
/**
|
|
83
84
|
* Removes tag from the Bee node.
|
|
84
85
|
* @param url
|
|
@@ -90,7 +91,6 @@ async function deleteTag(requestOptions, uid) {
|
|
|
90
91
|
url: `${endpoint}/${uid}`,
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
exports.deleteTag = deleteTag;
|
|
94
94
|
/**
|
|
95
95
|
* Updates tag
|
|
96
96
|
* @param url
|
|
@@ -106,4 +106,3 @@ async function updateTag(requestOptions, uid, reference) {
|
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
exports.updateTag = updateTag;
|
package/dist/cjs/types/debug.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BeeModes = void 0;
|
|
4
|
+
exports.toBeeMode = toBeeMode;
|
|
4
5
|
var BeeModes;
|
|
5
6
|
(function (BeeModes) {
|
|
6
7
|
BeeModes["FULL"] = "full";
|
|
7
8
|
BeeModes["LIGHT"] = "light";
|
|
8
9
|
BeeModes["ULTRA_LIGHT"] = "ultra-light";
|
|
9
10
|
BeeModes["DEV"] = "dev";
|
|
10
|
-
})(BeeModes
|
|
11
|
+
})(BeeModes || (exports.BeeModes = BeeModes = {}));
|
|
11
12
|
function toBeeMode(value) {
|
|
12
13
|
switch (value) {
|
|
13
14
|
case 'full':
|
|
@@ -22,4 +23,3 @@ function toBeeMode(value) {
|
|
|
22
23
|
throw new Error(`Unknown Bee mode: ${value}`);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
exports.toBeeMode = toBeeMode;
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var RedundancyLevel;
|
|
|
47
47
|
RedundancyLevel[RedundancyLevel["STRONG"] = 2] = "STRONG";
|
|
48
48
|
RedundancyLevel[RedundancyLevel["INSANE"] = 3] = "INSANE";
|
|
49
49
|
RedundancyLevel[RedundancyLevel["PARANOID"] = 4] = "PARANOID";
|
|
50
|
-
})(RedundancyLevel
|
|
50
|
+
})(RedundancyLevel || (exports.RedundancyLevel = RedundancyLevel = {}));
|
|
51
51
|
/**
|
|
52
52
|
* Specify the retrieve strategy on redundant data.
|
|
53
53
|
* The possible values are NONE, DATA, PROX and RACE.
|
|
@@ -64,7 +64,7 @@ var RedundancyStrategy;
|
|
|
64
64
|
RedundancyStrategy[RedundancyStrategy["DATA"] = 1] = "DATA";
|
|
65
65
|
RedundancyStrategy[RedundancyStrategy["PROX"] = 2] = "PROX";
|
|
66
66
|
RedundancyStrategy[RedundancyStrategy["RACE"] = 3] = "RACE";
|
|
67
|
-
})(RedundancyStrategy
|
|
67
|
+
})(RedundancyStrategy || (exports.RedundancyStrategy = RedundancyStrategy = {}));
|
|
68
68
|
exports.capacityBreakpoints = {
|
|
69
69
|
ENCRYPTION_OFF: {
|
|
70
70
|
[RedundancyLevel.OFF]: [
|
package/dist/cjs/utils/bytes.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Bytes = void 0;
|
|
7
|
+
exports.parseSizeToBytes = parseSizeToBytes;
|
|
7
8
|
const cafe_utility_1 = require("cafe-utility");
|
|
8
9
|
const debug_1 = __importDefault(require("debug"));
|
|
9
10
|
const debug = (0, debug_1.default)('bee-js:bytes');
|
|
@@ -111,4 +112,3 @@ function parseSizeToBytes(sizeStr) {
|
|
|
111
112
|
const unit = match[2];
|
|
112
113
|
return Math.ceil(value * units[unit]);
|
|
113
114
|
}
|
|
114
|
-
exports.parseSizeToBytes = parseSizeToBytes;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.totalChunks =
|
|
3
|
+
exports.totalChunks = totalChunks;
|
|
4
4
|
function totalChunks(fileSize) {
|
|
5
5
|
const chunkSize = 4096;
|
|
6
6
|
const hashesPerChunk = 128;
|
|
@@ -14,4 +14,3 @@ function totalChunks(fileSize) {
|
|
|
14
14
|
const baseLevelChunks = Math.ceil(fileSize / chunkSize);
|
|
15
15
|
return chunksAtLevel(baseLevelChunks);
|
|
16
16
|
}
|
|
17
|
-
exports.totalChunks = totalChunks;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.hashDirectory = hashDirectory;
|
|
4
|
+
exports.streamDirectory = streamDirectory;
|
|
5
|
+
exports.streamFiles = streamFiles;
|
|
4
6
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
7
|
const __1 = require("..");
|
|
6
8
|
const manifest_1 = require("../manifest/manifest");
|
|
@@ -11,12 +13,14 @@ const typed_bytes_1 = require("./typed-bytes");
|
|
|
11
13
|
async function hashDirectory(_dir) {
|
|
12
14
|
throw new Error('Hashing directories is not supported in browsers!');
|
|
13
15
|
}
|
|
14
|
-
exports.hashDirectory = hashDirectory;
|
|
15
16
|
async function streamDirectory(_bee, _dir, _postageBatchId, _onUploadProgress, _options, _requestOptions) {
|
|
16
17
|
throw new Error('Streaming directories is not supported in browsers!');
|
|
17
18
|
}
|
|
18
|
-
exports.streamDirectory = streamDirectory;
|
|
19
19
|
async function streamFiles(bee, files, postageBatchId, onUploadProgress, options, requestOptions) {
|
|
20
|
+
const signal = requestOptions?.signal;
|
|
21
|
+
if (signal?.aborted) {
|
|
22
|
+
throw new Error('Request aborted');
|
|
23
|
+
}
|
|
20
24
|
const queue = new cafe_utility_1.AsyncQueue(64, 64);
|
|
21
25
|
let total = 0;
|
|
22
26
|
let processed = 0;
|
|
@@ -26,12 +30,26 @@ async function streamFiles(bee, files, postageBatchId, onUploadProgress, options
|
|
|
26
30
|
postageBatchId = new typed_bytes_1.BatchId(postageBatchId);
|
|
27
31
|
async function onChunk(chunk) {
|
|
28
32
|
await queue.enqueue(async () => {
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
if (signal?.aborted) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
await bee.uploadChunk(postageBatchId, chunk.build(), options, requestOptions);
|
|
38
|
+
onUploadProgress?.({ total, processed: ++processed });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (signal?.aborted) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
31
46
|
});
|
|
32
47
|
}
|
|
33
48
|
const mantaray = new manifest_1.MantarayNode();
|
|
34
49
|
for (const file of files) {
|
|
50
|
+
if (signal?.aborted) {
|
|
51
|
+
throw new Error('Request aborted');
|
|
52
|
+
}
|
|
35
53
|
const rootChunk = await new Promise((resolve, reject) => {
|
|
36
54
|
const tree = new cafe_utility_1.MerkleTree(onChunk);
|
|
37
55
|
let offset = 0;
|
|
@@ -40,6 +58,10 @@ async function streamFiles(bee, files, postageBatchId, onUploadProgress, options
|
|
|
40
58
|
reject(reader.error);
|
|
41
59
|
};
|
|
42
60
|
const readNextChunk = async () => {
|
|
61
|
+
if (signal?.aborted) {
|
|
62
|
+
reject(new Error('Request aborted'));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
43
65
|
if (offset >= file.size) {
|
|
44
66
|
const rootChunk = await tree.finalize();
|
|
45
67
|
resolve(rootChunk);
|
|
@@ -74,9 +96,11 @@ async function streamFiles(bee, files, postageBatchId, onUploadProgress, options
|
|
|
74
96
|
});
|
|
75
97
|
}
|
|
76
98
|
}
|
|
99
|
+
if (signal?.aborted) {
|
|
100
|
+
throw new Error('Request aborted');
|
|
101
|
+
}
|
|
77
102
|
return mantaray.saveRecursively(bee, postageBatchId, options, requestOptions);
|
|
78
103
|
}
|
|
79
|
-
exports.streamFiles = streamFiles;
|
|
80
104
|
function maybeEnrichMime(mime) {
|
|
81
105
|
if (['text/html', 'text/css'].includes(mime)) {
|
|
82
106
|
return `${mime}; charset=utf-8`;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.hashDirectory = hashDirectory;
|
|
4
|
+
exports.streamDirectory = streamDirectory;
|
|
5
|
+
exports.streamFiles = streamFiles;
|
|
4
6
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
7
|
const fs_1 = require("fs");
|
|
6
8
|
const __1 = require("..");
|
|
@@ -30,7 +32,6 @@ async function hashDirectory(dir) {
|
|
|
30
32
|
}
|
|
31
33
|
return mantaray.calculateSelfAddress();
|
|
32
34
|
}
|
|
33
|
-
exports.hashDirectory = hashDirectory;
|
|
34
35
|
async function streamDirectory(bee, dir, postageBatchId, onUploadProgress, options, requestOptions) {
|
|
35
36
|
const queue = new cafe_utility_1.AsyncQueue(64, 64);
|
|
36
37
|
let total = 0;
|
|
@@ -83,7 +84,6 @@ async function streamDirectory(bee, dir, postageBatchId, onUploadProgress, optio
|
|
|
83
84
|
}
|
|
84
85
|
return mantaray.saveRecursively(bee, postageBatchId, options, requestOptions);
|
|
85
86
|
}
|
|
86
|
-
exports.streamDirectory = streamDirectory;
|
|
87
87
|
function maybeEnrichMime(mime) {
|
|
88
88
|
if (['text/html', 'text/css'].includes(mime)) {
|
|
89
89
|
return `${mime}; charset=utf-8`;
|
|
@@ -93,4 +93,3 @@ function maybeEnrichMime(mime) {
|
|
|
93
93
|
async function streamFiles(_bee, _files, _postageBatchId, _onUploadProgress, _options, _requestOptions) {
|
|
94
94
|
throw new Error('Streaming files is not supported in Node.js');
|
|
95
95
|
}
|
|
96
|
-
exports.streamFiles = streamFiles;
|
package/dist/cjs/utils/cid.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SWARM_FEED_CODEC = exports.SWARM_MANIFEST_CODEC = void 0;
|
|
4
|
+
exports.convertReferenceToCid = convertReferenceToCid;
|
|
5
|
+
exports.convertCidToReference = convertCidToReference;
|
|
4
6
|
const cafe_utility_1 = require("cafe-utility");
|
|
5
7
|
const typed_bytes_1 = require("./typed-bytes");
|
|
6
8
|
exports.SWARM_MANIFEST_CODEC = 0xfa;
|
|
@@ -21,7 +23,6 @@ function convertReferenceToCid(reference, type) {
|
|
|
21
23
|
const hash = reference.toBase32().replace(/\=+$/, '');
|
|
22
24
|
return `${base32}${header}${hash}`.toLowerCase();
|
|
23
25
|
}
|
|
24
|
-
exports.convertReferenceToCid = convertReferenceToCid;
|
|
25
26
|
function convertCidToReference(cid) {
|
|
26
27
|
const bytes = cafe_utility_1.Binary.base32ToUint8Array(cid.toUpperCase().slice(1));
|
|
27
28
|
const codec = bytes[1];
|
|
@@ -34,4 +35,3 @@ function convertCidToReference(cid) {
|
|
|
34
35
|
reference,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
|
-
exports.convertCidToReference = convertCidToReference;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.makeCollectionFromFS = makeCollectionFromFS;
|
|
4
|
+
exports.getFolderSize = getFolderSize;
|
|
4
5
|
/**
|
|
5
6
|
* Creates array in the format of Collection with data loaded from directory on filesystem.
|
|
6
7
|
* The function loads all the data into memory!
|
|
@@ -10,7 +11,6 @@ exports.getFolderSize = exports.makeCollectionFromFS = void 0;
|
|
|
10
11
|
async function makeCollectionFromFS(_dir) {
|
|
11
12
|
throw new Error('Creating Collection from File System is not supported in browsers!');
|
|
12
13
|
}
|
|
13
|
-
exports.makeCollectionFromFS = makeCollectionFromFS;
|
|
14
14
|
/**
|
|
15
15
|
* Calculate folder size recursively
|
|
16
16
|
*
|
|
@@ -20,4 +20,3 @@ exports.makeCollectionFromFS = makeCollectionFromFS;
|
|
|
20
20
|
async function getFolderSize(_dir) {
|
|
21
21
|
throw new Error('Creating Collection from File System is not supported in browsers!');
|
|
22
22
|
}
|
|
23
|
-
exports.getFolderSize = getFolderSize;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isCollection = isCollection;
|
|
4
|
+
exports.assertCollection = assertCollection;
|
|
5
|
+
exports.makeFilePath = makeFilePath;
|
|
6
|
+
exports.makeCollectionFromFileList = makeCollectionFromFileList;
|
|
7
|
+
exports.getCollectionSize = getCollectionSize;
|
|
4
8
|
const error_1 = require("./error");
|
|
5
9
|
function isCollection(data) {
|
|
6
10
|
if (!Array.isArray(data)) {
|
|
@@ -8,13 +12,11 @@ function isCollection(data) {
|
|
|
8
12
|
}
|
|
9
13
|
return data.every(entry => typeof entry === 'object' && entry.path && entry.size !== undefined);
|
|
10
14
|
}
|
|
11
|
-
exports.isCollection = isCollection;
|
|
12
15
|
function assertCollection(data) {
|
|
13
16
|
if (!isCollection(data)) {
|
|
14
17
|
throw new error_1.BeeArgumentError('invalid collection', data);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
|
-
exports.assertCollection = assertCollection;
|
|
18
20
|
function makeFilePath(file) {
|
|
19
21
|
if (file.webkitRelativePath && file.webkitRelativePath !== '') {
|
|
20
22
|
return file.webkitRelativePath.replace(/.*?\//i, '');
|
|
@@ -24,7 +26,6 @@ function makeFilePath(file) {
|
|
|
24
26
|
}
|
|
25
27
|
throw new TypeError('file is not valid File object');
|
|
26
28
|
}
|
|
27
|
-
exports.makeFilePath = makeFilePath;
|
|
28
29
|
function makeCollectionFromFileList(fileList) {
|
|
29
30
|
return Array.from(fileList).map(file => ({
|
|
30
31
|
path: makeFilePath(file),
|
|
@@ -32,7 +33,6 @@ function makeCollectionFromFileList(fileList) {
|
|
|
32
33
|
file,
|
|
33
34
|
}));
|
|
34
35
|
}
|
|
35
|
-
exports.makeCollectionFromFileList = makeCollectionFromFileList;
|
|
36
36
|
/**
|
|
37
37
|
* Calculate cumulative size of files
|
|
38
38
|
*
|
|
@@ -42,4 +42,3 @@ exports.makeCollectionFromFileList = makeCollectionFromFileList;
|
|
|
42
42
|
function getCollectionSize(fileList) {
|
|
43
43
|
return Array.from(fileList).reduce((sum, file) => sum + file.size, 0);
|
|
44
44
|
}
|
|
45
|
-
exports.getCollectionSize = getCollectionSize;
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.makeCollectionFromFS = makeCollectionFromFS;
|
|
7
|
+
exports.getFolderSize = getFolderSize;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
/**
|
|
@@ -20,7 +21,6 @@ async function makeCollectionFromFS(dir) {
|
|
|
20
21
|
}
|
|
21
22
|
return buildCollectionRelative(dir, '');
|
|
22
23
|
}
|
|
23
|
-
exports.makeCollectionFromFS = makeCollectionFromFS;
|
|
24
24
|
async function buildCollectionRelative(dir, relativePath) {
|
|
25
25
|
const dirname = path_1.default.join(dir, relativePath);
|
|
26
26
|
const entries = await fs_1.default.promises.opendir(dirname);
|
|
@@ -67,4 +67,3 @@ async function getFolderSize(dir) {
|
|
|
67
67
|
}
|
|
68
68
|
return size;
|
|
69
69
|
}
|
|
70
|
-
exports.getFolderSize = getFolderSize;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareWebsocketData =
|
|
3
|
+
exports.prepareWebsocketData = prepareWebsocketData;
|
|
4
4
|
async function prepareWebsocketData(data) {
|
|
5
5
|
if (typeof data === 'string') {
|
|
6
6
|
return new TextEncoder().encode(data);
|
|
@@ -13,4 +13,3 @@ async function prepareWebsocketData(data) {
|
|
|
13
13
|
}
|
|
14
14
|
throw new TypeError('unknown websocket data type');
|
|
15
15
|
}
|
|
16
|
-
exports.prepareWebsocketData = prepareWebsocketData;
|
package/dist/cjs/utils/data.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareWebsocketData =
|
|
3
|
+
exports.prepareWebsocketData = prepareWebsocketData;
|
|
4
4
|
function isBufferArray(buffer) {
|
|
5
5
|
return Array.isArray(buffer) && buffer.length > 0 && buffer.every(data => data instanceof Buffer);
|
|
6
6
|
}
|
|
@@ -19,4 +19,3 @@ async function prepareWebsocketData(data) {
|
|
|
19
19
|
}
|
|
20
20
|
throw new TypeError('unknown websocket data type');
|
|
21
21
|
}
|
|
22
|
-
exports.prepareWebsocketData = prepareWebsocketData;
|