@ethersphere/bee-js 8.3.1 → 9.0.2
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 +192 -50
- package/dist/cjs/bee-dev.js +78 -0
- package/dist/cjs/bee.js +341 -417
- package/dist/cjs/chunk/bmt.js +15 -32
- package/dist/cjs/chunk/cac.js +26 -36
- package/dist/cjs/chunk/soc.js +56 -51
- package/dist/cjs/feed/identifier.js +3 -28
- package/dist/cjs/feed/index.js +95 -44
- package/dist/cjs/feed/retrievable.js +11 -22
- package/dist/cjs/index.js +17 -1
- package/dist/cjs/manifest/manifest.js +369 -0
- package/dist/cjs/modules/bytes.js +24 -12
- package/dist/cjs/modules/bzz.js +24 -34
- package/dist/cjs/modules/chunk.js +13 -7
- package/dist/cjs/modules/debug/balance.js +29 -4
- package/dist/cjs/modules/debug/chequebook.js +60 -16
- package/dist/cjs/modules/debug/connectivity.js +82 -4
- package/dist/cjs/modules/debug/settlements.js +22 -2
- package/dist/cjs/modules/debug/stake.js +29 -11
- package/dist/cjs/modules/debug/stamps.js +88 -7
- package/dist/cjs/modules/debug/states.js +25 -3
- package/dist/cjs/modules/debug/status.js +45 -47
- package/dist/cjs/modules/debug/transactions.js +27 -5
- package/dist/cjs/modules/envelope.js +8 -6
- package/dist/cjs/modules/feed.js +25 -10
- package/dist/cjs/modules/grantee.js +18 -12
- package/dist/cjs/modules/gsoc.js +24 -0
- package/dist/cjs/modules/pinning.js +13 -2
- package/dist/cjs/modules/pss.js +9 -3
- package/dist/cjs/modules/soc.js +9 -4
- package/dist/cjs/modules/stewardship.js +7 -3
- package/dist/cjs/modules/tag.js +35 -3
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/stamper/stamper.js +43 -0
- package/dist/cjs/types/debug.js +16 -1
- package/dist/cjs/types/index.js +2 -24
- package/dist/cjs/utils/bytes.js +67 -115
- package/dist/cjs/utils/chunk-size.js +17 -0
- package/dist/cjs/utils/chunk-stream.browser.js +85 -0
- package/dist/cjs/utils/chunk-stream.js +84 -0
- package/dist/cjs/utils/cid.js +5 -6
- package/dist/cjs/utils/collection.browser.js +2 -2
- package/dist/cjs/utils/collection.js +3 -2
- package/dist/cjs/utils/collection.node.js +0 -2
- package/dist/cjs/utils/constants.js +7 -3
- package/dist/cjs/utils/data.browser.js +6 -3
- package/dist/cjs/utils/data.js +8 -4
- package/dist/cjs/utils/duration.js +51 -0
- package/dist/cjs/utils/expose.js +11 -40
- package/dist/cjs/utils/headers.js +79 -52
- package/dist/cjs/utils/http.js +34 -10
- package/dist/cjs/utils/mime.js +78 -0
- package/dist/cjs/utils/pss.js +3 -4
- package/dist/cjs/utils/redundancy.js +18 -14
- package/dist/cjs/utils/resource-locator.js +17 -0
- package/dist/cjs/utils/size.js +35 -0
- package/dist/cjs/utils/stamps.js +67 -51
- package/dist/cjs/utils/tar-uploader.browser.js +2 -2
- package/dist/cjs/utils/tar-uploader.js +2 -2
- package/dist/cjs/utils/tokens.js +144 -0
- package/dist/cjs/utils/type.js +142 -350
- package/dist/cjs/utils/typed-bytes.js +179 -0
- package/dist/cjs/utils/upload-progress.js +2 -0
- package/dist/cjs/utils/url.js +0 -4
- package/dist/cjs/utils/workaround.js +27 -0
- package/dist/index.browser.min.js +1 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-dev.js +98 -0
- package/dist/mjs/bee.js +367 -411
- package/dist/mjs/chunk/bmt.js +13 -29
- package/dist/mjs/chunk/cac.js +26 -34
- package/dist/mjs/chunk/soc.js +57 -53
- package/dist/mjs/feed/identifier.js +3 -26
- package/dist/mjs/feed/index.js +98 -51
- package/dist/mjs/feed/retrievable.js +12 -23
- package/dist/mjs/index.js +10 -1
- package/dist/mjs/manifest/manifest.js +371 -0
- package/dist/mjs/modules/bytes.js +27 -15
- package/dist/mjs/modules/bzz.js +25 -32
- package/dist/mjs/modules/chunk.js +16 -8
- package/dist/mjs/modules/debug/balance.js +61 -4
- package/dist/mjs/modules/debug/chequebook.js +116 -16
- package/dist/mjs/modules/debug/connectivity.js +144 -3
- package/dist/mjs/modules/debug/settlements.js +46 -2
- package/dist/mjs/modules/debug/stake.js +69 -11
- package/dist/mjs/modules/debug/stamps.js +184 -7
- package/dist/mjs/modules/debug/states.js +55 -3
- package/dist/mjs/modules/debug/status.js +97 -45
- package/dist/mjs/modules/debug/transactions.js +61 -5
- package/dist/mjs/modules/envelope.js +11 -9
- package/dist/mjs/modules/feed.js +26 -10
- package/dist/mjs/modules/grantee.js +35 -13
- package/dist/mjs/modules/gsoc.js +16 -0
- package/dist/mjs/modules/pinning.js +23 -2
- package/dist/mjs/modules/pss.js +10 -4
- package/dist/mjs/modules/soc.js +10 -5
- package/dist/mjs/modules/stewardship.js +14 -4
- package/dist/mjs/modules/tag.js +93 -3
- package/dist/mjs/package.json +2 -1
- package/dist/mjs/stamper/stamper.js +39 -0
- package/dist/mjs/types/debug.js +15 -1
- package/dist/mjs/types/index.js +2 -24
- package/dist/mjs/utils/bytes.js +63 -104
- package/dist/mjs/utils/chunk-size.js +13 -0
- package/dist/mjs/utils/chunk-stream.browser.js +85 -0
- package/dist/mjs/utils/chunk-stream.js +87 -0
- package/dist/mjs/utils/cid.js +5 -6
- package/dist/mjs/utils/collection.browser.js +2 -2
- package/dist/mjs/utils/collection.js +2 -2
- package/dist/mjs/utils/collection.node.js +0 -2
- package/dist/mjs/utils/constants.js +6 -2
- package/dist/mjs/utils/data.browser.js +9 -3
- package/dist/mjs/utils/data.js +12 -4
- package/dist/mjs/utils/duration.js +47 -0
- package/dist/mjs/utils/expose.js +2 -7
- package/dist/mjs/utils/headers.js +73 -48
- package/dist/mjs/utils/http.js +33 -11
- package/dist/mjs/utils/mime.js +75 -0
- package/dist/mjs/utils/pss.js +3 -4
- package/dist/mjs/utils/redundancy.js +18 -8
- package/dist/mjs/utils/resource-locator.js +13 -0
- package/dist/mjs/utils/size.js +31 -0
- package/dist/mjs/utils/stamps.js +47 -44
- package/dist/mjs/utils/tar-uploader.browser.js +2 -2
- package/dist/mjs/utils/tar-uploader.js +2 -2
- package/dist/mjs/utils/tokens.js +139 -0
- package/dist/mjs/utils/type.js +216 -310
- package/dist/mjs/utils/typed-bytes.js +160 -0
- package/dist/mjs/utils/upload-progress.js +1 -0
- package/dist/mjs/utils/url.js +0 -4
- package/dist/mjs/utils/workaround.js +22 -0
- package/dist/types/bee-dev.d.ts +5 -0
- package/dist/types/bee.d.ts +88 -165
- package/dist/types/chunk/bmt.d.ts +2 -2
- package/dist/types/chunk/cac.d.ts +7 -24
- package/dist/types/chunk/soc.d.ts +15 -15
- package/dist/types/feed/identifier.d.ts +2 -4
- package/dist/types/feed/index.d.ts +14 -18
- package/dist/types/feed/retrievable.d.ts +3 -4
- package/dist/types/index.d.ts +28 -1
- package/dist/types/manifest/manifest.d.ts +106 -0
- package/dist/types/modules/bytes.d.ts +8 -5
- package/dist/types/modules/bzz.d.ts +8 -10
- package/dist/types/modules/chunk.d.ts +4 -3
- package/dist/types/modules/debug/balance.d.ts +3 -2
- package/dist/types/modules/debug/chequebook.d.ts +7 -6
- package/dist/types/modules/debug/connectivity.d.ts +5 -3
- package/dist/types/modules/debug/settlements.d.ts +2 -1
- package/dist/types/modules/debug/stake.d.ts +4 -2
- package/dist/types/modules/debug/stamps.d.ts +5 -4
- package/dist/types/modules/debug/status.d.ts +6 -25
- package/dist/types/modules/debug/transactions.d.ts +5 -4
- package/dist/types/modules/envelope.d.ts +3 -2
- package/dist/types/modules/feed.d.ts +20 -16
- package/dist/types/modules/grantee.d.ts +7 -6
- package/dist/types/modules/gsoc.d.ts +7 -0
- package/dist/types/modules/pinning.d.ts +2 -4
- package/dist/types/modules/pss.d.ts +4 -3
- package/dist/types/modules/soc.d.ts +3 -2
- package/dist/types/modules/stewardship.d.ts +4 -4
- package/dist/types/modules/tag.d.ts +2 -1
- package/dist/types/stamper/stamper.d.ts +15 -0
- package/dist/types/types/debug.d.ts +63 -115
- package/dist/types/types/index.d.ts +103 -204
- package/dist/types/utils/bytes.d.ts +16 -90
- package/dist/types/utils/chunk-size.d.ts +1 -0
- package/dist/types/utils/chunk-stream.browser.d.ts +6 -0
- package/dist/types/utils/chunk-stream.d.ts +6 -0
- package/dist/types/utils/cid.d.ts +3 -2
- package/dist/types/utils/collection.browser.d.ts +2 -2
- package/dist/types/utils/collection.d.ts +2 -1
- package/dist/types/utils/collection.node.d.ts +0 -1
- package/dist/types/utils/constants.d.ts +4 -1
- package/dist/types/utils/duration.d.ts +17 -0
- package/dist/types/utils/error.d.ts +2 -2
- package/dist/types/utils/expose.d.ts +2 -7
- package/dist/types/utils/headers.d.ts +3 -4
- package/dist/types/utils/mime.d.ts +1 -0
- package/dist/types/utils/pss.d.ts +2 -2
- package/dist/types/utils/resource-locator.d.ts +6 -0
- package/dist/types/utils/size.d.ts +16 -0
- package/dist/types/utils/stamps.d.ts +27 -33
- package/dist/types/utils/tar-uploader.browser.d.ts +3 -4
- package/dist/types/utils/tar-uploader.d.ts +3 -4
- package/dist/types/utils/tokens.d.ts +77 -0
- package/dist/types/utils/type.d.ts +20 -52
- package/dist/types/utils/typed-bytes.d.ts +68 -0
- package/dist/types/utils/upload-progress.d.ts +4 -0
- package/dist/types/utils/workaround.d.ts +2 -0
- package/package.json +11 -17
- package/dist/cjs/chunk/signer.js +0 -126
- package/dist/cjs/chunk/span.js +0 -25
- package/dist/cjs/feed/json.js +0 -28
- package/dist/cjs/feed/topic.js +0 -25
- package/dist/cjs/feed/type.js +0 -15
- package/dist/cjs/modules/debug/chunk.js +0 -21
- package/dist/cjs/modules/debug/tag.js +0 -19
- package/dist/cjs/utils/eth.js +0 -216
- package/dist/cjs/utils/hash.js +0 -21
- package/dist/cjs/utils/hex.js +0 -150
- package/dist/cjs/utils/reference.js +0 -36
- package/dist/index.browser.min.js.LICENSE.txt +0 -8
- package/dist/mjs/chunk/signer.js +0 -114
- package/dist/mjs/chunk/span.js +0 -21
- package/dist/mjs/feed/json.js +0 -26
- package/dist/mjs/feed/topic.js +0 -19
- package/dist/mjs/feed/type.js +0 -10
- package/dist/mjs/modules/debug/chunk.js +0 -17
- package/dist/mjs/modules/debug/tag.js +0 -15
- package/dist/mjs/utils/eth.js +0 -192
- package/dist/mjs/utils/hash.js +0 -16
- package/dist/mjs/utils/hex.js +0 -135
- package/dist/mjs/utils/reference.js +0 -29
- package/dist/types/chunk/signer.d.ts +0 -31
- package/dist/types/chunk/span.d.ts +0 -10
- package/dist/types/feed/json.d.ts +0 -4
- package/dist/types/feed/topic.d.ts +0 -3
- package/dist/types/feed/type.d.ts +0 -6
- package/dist/types/modules/debug/chunk.d.ts +0 -10
- package/dist/types/modules/debug/tag.d.ts +0 -8
- package/dist/types/utils/eth.d.ts +0 -67
- package/dist/types/utils/hash.d.ts +0 -9
- package/dist/types/utils/hex.d.ts +0 -86
- package/dist/types/utils/reference.d.ts +0 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { BatchId, Topic } from '
|
|
1
|
+
import { BatchId, Topic } from './typed-bytes';
|
|
2
2
|
export declare const SWARM_GATEWAY_URL = "https://api.gateway.ethswarm.org";
|
|
3
3
|
export declare const NULL_STAMP: BatchId;
|
|
4
4
|
export declare const NULL_TOPIC: Topic;
|
|
5
|
+
export declare const NULL_ADDRESS: Uint8Array;
|
|
6
|
+
export declare const NULL_IDENTIFIER: Uint8Array;
|
|
7
|
+
export declare const NULL_OWNER: Uint8Array;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class Duration {
|
|
2
|
+
private seconds;
|
|
3
|
+
private constructor();
|
|
4
|
+
static fromMilliseconds(milliseconds: number): Duration;
|
|
5
|
+
static fromSeconds(seconds: number): Duration;
|
|
6
|
+
static fromHours(hours: number): Duration;
|
|
7
|
+
static fromDays(days: number): Duration;
|
|
8
|
+
static fromWeeks(weeks: number): Duration;
|
|
9
|
+
static fromYears(years: number): Duration;
|
|
10
|
+
static fromEndDate(endDate: Date, startDate?: Date): Duration;
|
|
11
|
+
toSeconds(): number;
|
|
12
|
+
toHours(): number;
|
|
13
|
+
toDays(): number;
|
|
14
|
+
toWeeks(): number;
|
|
15
|
+
toYears(): number;
|
|
16
|
+
toEndDate(startDate?: Date): Date;
|
|
17
|
+
}
|
|
@@ -8,8 +8,8 @@ export declare class BeeArgumentError extends BeeError {
|
|
|
8
8
|
export declare class BeeResponseError extends BeeError {
|
|
9
9
|
method: string;
|
|
10
10
|
url: string;
|
|
11
|
-
responseBody?:
|
|
11
|
+
responseBody?: unknown;
|
|
12
12
|
status?: number | undefined;
|
|
13
13
|
statusText?: string | undefined;
|
|
14
|
-
constructor(method: string, url: string, message: string, responseBody?:
|
|
14
|
+
constructor(method: string, url: string, message: string, responseBody?: unknown, status?: number | undefined, statusText?: string | undefined);
|
|
15
15
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
export { getCollectionSize } from './collection';
|
|
1
|
+
export { getCollectionSize, makeCollectionFromFileList } from './collection';
|
|
2
2
|
export { getFolderSize } from './collection.node';
|
|
3
|
-
export { Bytes, FlexBytes, assertBytes, assertFlexBytes, bytesAtOffset, bytesEqual, flexBytesAtOffset, isBytes, isFlexBytes, } from './bytes';
|
|
4
|
-
export { HexString, PrefixedHexString, assertHexString, assertPrefixedHexString, bytesToHex, hexToBytes, intToHex, isHexString, makeHexString, } from './hex';
|
|
5
|
-
export { EthAddress, capitalizeAddressERC55, ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian, } from './eth';
|
|
6
|
-
export { keccak256Hash } from './hash';
|
|
7
3
|
export { makeMaxTarget } from './pss';
|
|
8
|
-
export { getAmountForTtl, getDepthForCapacity, getStampCostInBzz, getStampCostInPlur, getStampEffectiveBytes, getStampMaximumCapacityBytes, getStampTtlSeconds, getStampUsage, } from './stamps';
|
|
9
4
|
export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy';
|
|
10
|
-
export {
|
|
5
|
+
export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage, } from './stamps';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvelopeWithBatchId, FileHeaders } from '../types';
|
|
2
|
+
import { BatchId } from './typed-bytes';
|
|
2
3
|
export declare function readFileHeaders(headers: Record<string, string>): FileHeaders;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function extractRedundantUploadHeaders(postageBatchId: BatchId, options?: UploadOptions & UploadRedundancyOptions): Record<string, string>;
|
|
5
|
-
export declare function extractDownloadHeaders(options?: DownloadRedundancyOptions): Record<string, string>;
|
|
4
|
+
export declare function prepareRequestHeaders(stamp: BatchId | Uint8Array | string | EnvelopeWithBatchId | null, nullableOptions?: unknown): Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mimes: Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PeerAddress } from './typed-bytes';
|
|
2
2
|
/**
|
|
3
3
|
* Utility function that for given strings/reference takes the most specific
|
|
4
4
|
* target that Bee node will except.
|
|
@@ -6,4 +6,4 @@ import { AddressPrefix } from '../types';
|
|
|
6
6
|
* @param target is a non-prefixed hex string Bee address
|
|
7
7
|
* @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss)
|
|
8
8
|
*/
|
|
9
|
-
export declare function makeMaxTarget(target: string):
|
|
9
|
+
export declare function makeMaxTarget(target: PeerAddress | Uint8Array | string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a size in bytes.
|
|
3
|
+
*
|
|
4
|
+
* Uses 1000 instead of 1024 for converting between units.
|
|
5
|
+
* This is to stay consistent with the Swarm papers
|
|
6
|
+
* on theoretical and effective storage capacity.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Size {
|
|
9
|
+
private bytes;
|
|
10
|
+
private constructor();
|
|
11
|
+
static fromBytes(bytes: number): Size;
|
|
12
|
+
static fromGigabytes(gigabytes: number): Size;
|
|
13
|
+
toBytes(): number;
|
|
14
|
+
toGigabytes(): number;
|
|
15
|
+
toFormattedString(): string;
|
|
16
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvelopeWithBatchId, NumberString } from '../types';
|
|
2
|
+
import { Bytes } from './bytes';
|
|
3
|
+
import { Duration } from './duration';
|
|
4
|
+
import { Size } from './size';
|
|
5
|
+
import { BZZ } from './tokens';
|
|
2
6
|
/**
|
|
3
7
|
* Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
|
|
4
8
|
*
|
|
@@ -8,59 +12,49 @@ import { BatchId, Envelope, NumberString } from '../types';
|
|
|
8
12
|
*/
|
|
9
13
|
export declare function getStampUsage(utilization: number, depth: number, bucketDepth: number): number;
|
|
10
14
|
/**
|
|
11
|
-
* Utility function that calculates the theoritical maximum
|
|
15
|
+
* Utility function that calculates the theoritical maximum size of a postage batch based on its depth.
|
|
12
16
|
*
|
|
13
|
-
* For smaller depths (up to
|
|
17
|
+
* For smaller depths (up to 22), this may provide less accurate results.
|
|
14
18
|
*
|
|
15
|
-
* @returns {number} The maximum
|
|
19
|
+
* @returns {number} The maximum theoretical size of the postage batch in bytes.
|
|
16
20
|
*/
|
|
17
|
-
export declare function
|
|
21
|
+
export declare function getStampTheoreticalBytes(depth: number): number;
|
|
18
22
|
/**
|
|
19
|
-
* Utility function that calculates the effective
|
|
23
|
+
* Utility function that calculates the effective size of a postage batch based on its depth.
|
|
20
24
|
*
|
|
21
|
-
* Below 22 depth the effective
|
|
25
|
+
* Below 22 depth the effective size is 0
|
|
22
26
|
* Above 34 it's always > 99%
|
|
23
27
|
*
|
|
24
|
-
* @returns {number} The effective
|
|
28
|
+
* @returns {number} The effective size of the postage batch in bytes.
|
|
25
29
|
*/
|
|
26
30
|
export declare function getStampEffectiveBytes(depth: number): number;
|
|
31
|
+
export declare function getStampEffectiveBytesBreakpoints(): Map<number, number>;
|
|
27
32
|
/**
|
|
28
33
|
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
29
|
-
*
|
|
30
|
-
* @returns {number} The cost of the postage batch in PLUR (10000000000000000 [1e16] PLUR = 1 BZZ)
|
|
31
|
-
*/
|
|
32
|
-
export declare function getStampCostInPlur(depth: number, amount: number): number;
|
|
33
|
-
/**
|
|
34
|
-
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
35
|
-
*
|
|
36
|
-
* @returns {number} The cost of the postage batch in BZZ (1 BZZ = 10000000000000000 [1e16] PLUR)
|
|
37
34
|
*/
|
|
38
|
-
export declare function
|
|
35
|
+
export declare function getStampCost(depth: number, amount: NumberString | string | bigint): BZZ;
|
|
39
36
|
/**
|
|
40
37
|
* Utility function that calculates the TTL of a postage batch based on its amount, price per block and block time.
|
|
41
38
|
*
|
|
42
39
|
* For more accurate results, get the price per block and block time from the Bee node or the blockchain.
|
|
43
40
|
*
|
|
44
|
-
* @returns {number} The TTL of the postage batch
|
|
41
|
+
* @returns {number} The TTL of the postage batch.
|
|
45
42
|
*/
|
|
46
|
-
export declare function
|
|
43
|
+
export declare function getStampDuration(amount: NumberString | string | bigint, pricePerBlock: number, blockTime?: number): Duration;
|
|
47
44
|
/**
|
|
48
|
-
*
|
|
45
|
+
* Get the postage batch `amount` required for a given `duration`.
|
|
49
46
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
* @returns {NumberString} The estimated amount of tokens needed for the specified TTL.
|
|
47
|
+
* @param duration A duration object representing the duration of the storage.
|
|
48
|
+
* @param pricePerBlock The price per block in PLUR.
|
|
49
|
+
* @param blockTime The block time in seconds.
|
|
54
50
|
*/
|
|
55
|
-
export declare function
|
|
51
|
+
export declare function getAmountForDuration(duration: Duration, pricePerBlock: number, blockTime?: number): bigint;
|
|
56
52
|
/**
|
|
57
|
-
* Utility function that calculates the depth required for a postage batch to achieve the specified
|
|
58
|
-
*
|
|
59
|
-
* The depth is determined based on the given gigabytes, and the result is adjusted to a minimum depth of 18.
|
|
53
|
+
* Utility function that calculates the depth required for a postage batch to achieve the specified effective size
|
|
60
54
|
*
|
|
61
|
-
* @param
|
|
62
|
-
* @returns
|
|
55
|
+
* @param size The effective size of the postage batch
|
|
56
|
+
* @returns
|
|
63
57
|
*/
|
|
64
|
-
export declare function
|
|
65
|
-
export declare function convertEnvelopeToMarshaledStamp(
|
|
66
|
-
export declare function marshalStamp(signature: Uint8Array,
|
|
58
|
+
export declare function getDepthForSize(size: Size): number;
|
|
59
|
+
export declare function convertEnvelopeToMarshaledStamp(envelope: EnvelopeWithBatchId): Bytes;
|
|
60
|
+
export declare function marshalStamp(signature: Uint8Array, batchId: Uint8Array, timestamp: Uint8Array, index: Uint8Array): Bytes;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}, any>>;
|
|
1
|
+
import { BeeRequestOptions, Collection, CollectionUploadOptions } from '..';
|
|
2
|
+
import { BatchId } from './typed-bytes';
|
|
3
|
+
export declare function uploadTar(requestOptions: BeeRequestOptions, collection: Collection, postageBatchId: BatchId, options?: CollectionUploadOptions): Promise<import("axios").AxiosResponse<unknown, any>>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}, any>>;
|
|
1
|
+
import { BeeRequestOptions, Collection, CollectionUploadOptions } from '..';
|
|
2
|
+
import { BatchId } from './typed-bytes';
|
|
3
|
+
export declare function uploadTar(requestOptions: BeeRequestOptions, collection: Collection, postageBatchId: BatchId, options?: CollectionUploadOptions): Promise<import("axios").AxiosResponse<unknown, any>>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { NumberString } from '..';
|
|
2
|
+
export declare class BZZ {
|
|
3
|
+
static readonly DIGITS = 16;
|
|
4
|
+
private state;
|
|
5
|
+
private constructor();
|
|
6
|
+
static fromDecimalString(string: string): BZZ;
|
|
7
|
+
static fromPLUR(plur: NumberString | string | bigint): BZZ;
|
|
8
|
+
toPLURString(): string;
|
|
9
|
+
toPLURBigInt(): bigint;
|
|
10
|
+
toDecimalString(): string;
|
|
11
|
+
toSignificantDigits(digits: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* Does not mutate the current BZZ instance.
|
|
14
|
+
*
|
|
15
|
+
* @param other BZZ instance, or amount in PLUR
|
|
16
|
+
* @returns New BZZ instance
|
|
17
|
+
*/
|
|
18
|
+
plus(other: BZZ | NumberString | string | bigint): BZZ;
|
|
19
|
+
/**
|
|
20
|
+
* Does not mutate the current BZZ instance.
|
|
21
|
+
*
|
|
22
|
+
* @param other BZZ instance, or amount in PLUR
|
|
23
|
+
* @returns New BZZ instance
|
|
24
|
+
*/
|
|
25
|
+
minus(other: BZZ | NumberString | string | bigint): BZZ;
|
|
26
|
+
/**
|
|
27
|
+
* Does not mutate the current BZZ instance.
|
|
28
|
+
*
|
|
29
|
+
* @param other Divisor
|
|
30
|
+
* @returns New BZZ instance
|
|
31
|
+
*/
|
|
32
|
+
divide(other: bigint): BZZ;
|
|
33
|
+
gt(other: BZZ): boolean;
|
|
34
|
+
gte(other: BZZ): boolean;
|
|
35
|
+
lt(other: BZZ): boolean;
|
|
36
|
+
lte(other: BZZ): boolean;
|
|
37
|
+
eq(other: BZZ): boolean;
|
|
38
|
+
exchangeToDAI(daiPerBzz: DAI): DAI;
|
|
39
|
+
}
|
|
40
|
+
export declare class DAI {
|
|
41
|
+
static readonly DIGITS = 18;
|
|
42
|
+
private state;
|
|
43
|
+
private constructor();
|
|
44
|
+
static fromDecimalString(string: string): DAI;
|
|
45
|
+
static fromWei(wei: NumberString | string | bigint): DAI;
|
|
46
|
+
toWeiString(): string;
|
|
47
|
+
toWeiBigInt(): bigint;
|
|
48
|
+
toDecimalString(): string;
|
|
49
|
+
toSignificantDigits(digits: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Does not mutate the current DAI instance.
|
|
52
|
+
*
|
|
53
|
+
* @param other DAI instance, or amount in PLUR
|
|
54
|
+
* @returns New DAI instance
|
|
55
|
+
*/
|
|
56
|
+
plus(other: DAI | NumberString | string | bigint): DAI;
|
|
57
|
+
/**
|
|
58
|
+
* Does not mutate the current DAI instance.
|
|
59
|
+
*
|
|
60
|
+
* @param other DAI instance, or amount in PLUR
|
|
61
|
+
* @returns New DAI instance
|
|
62
|
+
*/
|
|
63
|
+
minus(other: DAI | NumberString | string | bigint): DAI;
|
|
64
|
+
/**
|
|
65
|
+
* Does not mutate the current DAI instance.
|
|
66
|
+
*
|
|
67
|
+
* @param other Divisor
|
|
68
|
+
* @returns New DAI instance
|
|
69
|
+
*/
|
|
70
|
+
divide(other: bigint): DAI;
|
|
71
|
+
gt(other: DAI): boolean;
|
|
72
|
+
gte(other: DAI): boolean;
|
|
73
|
+
lt(other: DAI): boolean;
|
|
74
|
+
lte(other: DAI): boolean;
|
|
75
|
+
eq(other: DAI): boolean;
|
|
76
|
+
exchangeToBZZ(daiPerBzz: DAI): BZZ;
|
|
77
|
+
}
|
|
@@ -1,54 +1,23 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
export declare function isReadable(
|
|
5
|
-
export declare function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function assertInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
|
17
|
-
export declare function assertNonNegativeInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
|
18
|
-
export declare function assertPositiveInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
|
19
|
-
export declare function assertReference(value: unknown): asserts value is Reference;
|
|
20
|
-
export declare function assertReferenceOrEns(value: unknown): asserts value is ReferenceOrEns;
|
|
21
|
-
/**
|
|
22
|
-
* Function that mainly converts Swarm CID into hex encoded Swarm Reference
|
|
23
|
-
*
|
|
24
|
-
* @param value
|
|
25
|
-
* @param expectedCidType
|
|
26
|
-
*/
|
|
27
|
-
export declare function makeReferenceOrEns(value: unknown, expectedCidType: 'feed' | 'manifest'): ReferenceOrEns;
|
|
28
|
-
/**
|
|
29
|
-
* Function that adds getter which converts the reference into CID base32 encoded string.
|
|
30
|
-
* @param result
|
|
31
|
-
* @param cidType feed or manifest
|
|
32
|
-
*/
|
|
33
|
-
export declare function addCidConversionFunction<T extends {
|
|
34
|
-
reference: string;
|
|
35
|
-
}>(result: T, cidType: 'feed' | 'manifest'): T & {
|
|
36
|
-
cid: () => string;
|
|
37
|
-
};
|
|
38
|
-
export declare function assertAddress(value: unknown): asserts value is Address;
|
|
39
|
-
export declare function assertBatchId(value: unknown): asserts value is BatchId;
|
|
40
|
-
export declare function assertRequestOptions(value: unknown, name?: string): asserts value is BeeRequestOptions;
|
|
41
|
-
export declare function assertUploadOptions(value: unknown, name?: string): asserts value is UploadOptions;
|
|
42
|
-
export declare function assertFileUploadOptions(value: unknown): asserts value is FileUploadOptions;
|
|
43
|
-
export declare function assertCollectionUploadOptions(value: unknown): asserts value is CollectionUploadOptions;
|
|
2
|
+
import * as stream from 'stream';
|
|
3
|
+
import { AllTagsOptions, BeeRequestOptions, CollectionUploadOptions, DownloadOptions, FileUploadOptions, GsocMessageHandler, NumberString, PostageBatchOptions, PssMessageHandler, RedundantUploadOptions, Tag, TransactionOptions, UploadOptions } from '../types';
|
|
4
|
+
export declare function isReadable(value: unknown): value is stream.Readable;
|
|
5
|
+
export declare function asNumberString(value: unknown, options?: {
|
|
6
|
+
name?: string;
|
|
7
|
+
min?: bigint;
|
|
8
|
+
max?: bigint;
|
|
9
|
+
}): NumberString;
|
|
10
|
+
export declare function prepareBeeRequestOptions(value: unknown): BeeRequestOptions;
|
|
11
|
+
export declare function prepareDownloadOptions(value: unknown): DownloadOptions;
|
|
12
|
+
export declare function prepareUploadOptions(value: unknown, name?: string): UploadOptions;
|
|
13
|
+
export declare function prepareRedundantUploadOptions(value: unknown, name?: string): RedundantUploadOptions;
|
|
14
|
+
export declare function prepareFileUploadOptions(value: unknown): FileUploadOptions;
|
|
15
|
+
export declare function prepareCollectionUploadOptions(value: unknown): CollectionUploadOptions;
|
|
44
16
|
export declare function isTag(value: unknown): value is Tag;
|
|
45
|
-
export declare function
|
|
46
|
-
export declare function
|
|
47
|
-
export declare function
|
|
48
|
-
export declare function
|
|
49
|
-
export declare function assertPostageBatchOptions(value: unknown): asserts value is PostageBatchOptions;
|
|
50
|
-
export declare function assertTransactionOptions(value: unknown, name?: string): asserts value is TransactionOptions;
|
|
51
|
-
export declare function assertCashoutOptions(value: unknown): asserts value is CashoutOptions;
|
|
17
|
+
export declare function preparePssMessageHandler(value: unknown): PssMessageHandler;
|
|
18
|
+
export declare function prepareGsocMessageHandler(value: unknown): GsocMessageHandler;
|
|
19
|
+
export declare function preparePostageBatchOptions(value: unknown): PostageBatchOptions;
|
|
20
|
+
export declare function prepareTransactionOptions(value: unknown, name?: string): TransactionOptions;
|
|
52
21
|
/**
|
|
53
22
|
* Check whether the given parameter is valid data to upload
|
|
54
23
|
* @param value
|
|
@@ -60,15 +29,14 @@ export declare function assertData(value: unknown): asserts value is string | Ui
|
|
|
60
29
|
* @param value
|
|
61
30
|
* @throws TypeError if not valid
|
|
62
31
|
*/
|
|
63
|
-
export declare function assertFileData(value: unknown): asserts value is string | Uint8Array | Readable | File;
|
|
32
|
+
export declare function assertFileData(value: unknown): asserts value is string | Uint8Array | stream.Readable | File;
|
|
64
33
|
/**
|
|
65
34
|
* Checks whether optional options for AllTags query are valid
|
|
66
35
|
* @param options
|
|
67
36
|
*/
|
|
68
|
-
export declare function
|
|
37
|
+
export declare function prepareAllTagsOptions(value: unknown): AllTagsOptions;
|
|
69
38
|
/**
|
|
70
39
|
* Utility functions that return Tag UID
|
|
71
40
|
* @param tagUid
|
|
72
41
|
*/
|
|
73
42
|
export declare function makeTagUid(tagUid: number | Tag | string | null | undefined): number;
|
|
74
|
-
export declare function assertTransactionHash(transactionHash: unknown): asserts transactionHash is TransactionHash;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Bytes } from './bytes';
|
|
2
|
+
export declare class PrivateKey extends Bytes {
|
|
3
|
+
static readonly LENGTH = 32;
|
|
4
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
5
|
+
publicKey(): PublicKey;
|
|
6
|
+
sign(data: Uint8Array | string): Signature;
|
|
7
|
+
}
|
|
8
|
+
export declare class PublicKey extends Bytes {
|
|
9
|
+
static readonly LENGTH = 64;
|
|
10
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
11
|
+
address(): EthAddress;
|
|
12
|
+
toCompressedUint8Array(): Uint8Array;
|
|
13
|
+
toCompressedHex(): string;
|
|
14
|
+
}
|
|
15
|
+
export declare class EthAddress extends Bytes {
|
|
16
|
+
static readonly LENGTH = 20;
|
|
17
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
18
|
+
toChecksum(): string;
|
|
19
|
+
}
|
|
20
|
+
export declare class Identifier extends Bytes {
|
|
21
|
+
static readonly LENGTH = 32;
|
|
22
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
23
|
+
static fromString(value: string): Identifier;
|
|
24
|
+
}
|
|
25
|
+
export declare class Reference extends Bytes {
|
|
26
|
+
static readonly LENGTH = 32;
|
|
27
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
28
|
+
toCid(type: 'feed' | 'manifest'): string;
|
|
29
|
+
static isValid(value: string): boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare class TransactionId extends Bytes {
|
|
32
|
+
static readonly LENGTH = 32;
|
|
33
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
34
|
+
}
|
|
35
|
+
export declare class Span extends Bytes {
|
|
36
|
+
static readonly LENGTH = 8;
|
|
37
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
38
|
+
static fromBigInt(number: bigint): FeedIndex;
|
|
39
|
+
toBigInt(): bigint;
|
|
40
|
+
static fromSlice(bytes: Uint8Array, start: number): Span;
|
|
41
|
+
}
|
|
42
|
+
export declare class PeerAddress extends Bytes {
|
|
43
|
+
static readonly LENGTH = 32;
|
|
44
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
45
|
+
}
|
|
46
|
+
export declare class BatchId extends Bytes {
|
|
47
|
+
static readonly LENGTH = 32;
|
|
48
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
49
|
+
}
|
|
50
|
+
export declare class Signature extends Bytes {
|
|
51
|
+
static readonly LENGTH = 65;
|
|
52
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
53
|
+
static fromSlice(bytes: Uint8Array, start: number): Signature;
|
|
54
|
+
recoverPublicKey(digest: Uint8Array | string): PublicKey;
|
|
55
|
+
isValid(digest: Uint8Array | string, expectedAddress: EthAddress | Uint8Array | string): boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare class Topic extends Bytes {
|
|
58
|
+
static readonly LENGTH = 32;
|
|
59
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
60
|
+
static fromString(value: string): Topic;
|
|
61
|
+
}
|
|
62
|
+
export declare class FeedIndex extends Bytes {
|
|
63
|
+
static readonly LENGTH = 8;
|
|
64
|
+
static readonly MINUS_ONE: FeedIndex;
|
|
65
|
+
constructor(bytes: Uint8Array | string | Bytes);
|
|
66
|
+
static fromBigInt(number: bigint): FeedIndex;
|
|
67
|
+
toBigInt(): bigint;
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -31,16 +31,20 @@
|
|
|
31
31
|
"types": "./dist/types/index.d.ts"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"bee": "2.4.0-390a402e",
|
|
36
|
+
"beeApiVersion": "7.2.0"
|
|
37
|
+
},
|
|
34
38
|
"types": "dist/types/index.d.ts",
|
|
35
39
|
"browser": {
|
|
36
40
|
"stream": false,
|
|
37
41
|
"fs": false,
|
|
38
|
-
"./src/utils/data.ts": "./src/utils/data.browser.ts",
|
|
39
42
|
"./dist/cjs/utils/data.js": "./dist/cjs/utils/data.browser.js",
|
|
40
43
|
"./dist/mjs/utils/data.js": "./dist/mjs/utils/data.browser.js",
|
|
44
|
+
"./dist/cjs/utils/chunk-stream.js": "./dist/cjs/utils/chunk-stream.browser.js",
|
|
45
|
+
"./dist/mjs/utils/chunk-stream.js": "./dist/mjs/utils/chunk-stream.browser.js",
|
|
41
46
|
"./dist/cjs/utils/collection.node.js": "./dist/cjs/utils/collection.browser.js",
|
|
42
|
-
"./dist/mjs/utils/collection.node.js": "./dist/mjs/utils/collection.browser.js"
|
|
43
|
-
"./src/utils/collection.node.ts": "./src/utils/collection.browser.ts"
|
|
47
|
+
"./dist/mjs/utils/collection.node.js": "./dist/mjs/utils/collection.browser.js"
|
|
44
48
|
},
|
|
45
49
|
"files": [
|
|
46
50
|
"dist"
|
|
@@ -51,21 +55,16 @@
|
|
|
51
55
|
"build:node": "tsc -p tsconfig.json && tsc -p tsconfig-mjs.json && ./build-fixup && babel --plugins \"babel-plugin-add-import-extension\" --out-dir dist/mjs/ dist/mjs/",
|
|
52
56
|
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
|
|
53
57
|
"build:browser": "webpack --progress",
|
|
54
|
-
"mock-ci": "npm run lint:check && npm run check:types && npm run test",
|
|
55
58
|
"test": "jest --config=jest.config.ts --runInBand --verbose",
|
|
56
|
-
"test:coverage": "jest --config=jest.config.ts --coverage",
|
|
57
59
|
"check:types": "tsc --project tsconfig.test.json",
|
|
58
60
|
"lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
59
61
|
"lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
60
|
-
"depcheck": "depcheck ."
|
|
61
|
-
"bee": "npx @fairdatasociety/fdp-play@3.2.0 start --detach --fresh"
|
|
62
|
+
"depcheck": "depcheck ."
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
65
|
"axios": "^0.28.1",
|
|
65
|
-
"cafe-utility": "^
|
|
66
|
-
"elliptic": "^6.5.4",
|
|
66
|
+
"cafe-utility": "^27.14.2",
|
|
67
67
|
"isomorphic-ws": "^4.0.1",
|
|
68
|
-
"js-sha3": "^0.8.0",
|
|
69
68
|
"semver": "^7.3.5",
|
|
70
69
|
"ws": "^8.7.0"
|
|
71
70
|
},
|
|
@@ -80,7 +79,6 @@
|
|
|
80
79
|
"@commitlint/config-conventional": "^17.4.2",
|
|
81
80
|
"@jest/types": "^29.6.3",
|
|
82
81
|
"@naholyr/cross-env": "^1.0.0",
|
|
83
|
-
"@types/elliptic": "^6.4.14",
|
|
84
82
|
"@types/jest": "^29.5.13",
|
|
85
83
|
"@types/node": "^18.11.11",
|
|
86
84
|
"@types/semver": "^7.3.9",
|
|
@@ -97,7 +95,7 @@
|
|
|
97
95
|
"eslint-plugin-unused-imports": "^2.0.0",
|
|
98
96
|
"husky": "^8.0.1",
|
|
99
97
|
"jest": "^29.7.0",
|
|
100
|
-
"
|
|
98
|
+
"jest-puppeteer": "^11.0.0",
|
|
101
99
|
"prettier": "^2.6.2",
|
|
102
100
|
"rimraf": "^3.0.2",
|
|
103
101
|
"terser-webpack-plugin": "^5.3.1",
|
|
@@ -106,9 +104,5 @@
|
|
|
106
104
|
"typescript": "^4.9.5",
|
|
107
105
|
"webpack": "^5.75.0",
|
|
108
106
|
"webpack-cli": "^5.0.1"
|
|
109
|
-
},
|
|
110
|
-
"engines": {
|
|
111
|
-
"bee": "2.2.0-06a0aca7",
|
|
112
|
-
"beeApiVersion": "7.1.0"
|
|
113
107
|
}
|
|
114
108
|
}
|