@ethersphere/bee-js 3.4.0-pre.0 → 4.1.1-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -22
- package/README.md +3 -22
- package/dist/cjs/bee-debug.js +31 -8
- package/dist/cjs/bee.js +79 -24
- package/dist/cjs/feed/identifier.js +35 -0
- package/dist/cjs/feed/index.js +34 -90
- package/dist/cjs/feed/retrievable.js +72 -0
- package/dist/cjs/modules/debug/states.js +18 -1
- package/dist/cjs/modules/debug/status.js +3 -3
- package/dist/cjs/modules/feed.js +3 -3
- package/dist/cjs/types/index.js +2 -1
- package/dist/cjs/utils/bytes.js +15 -1
- package/dist/cjs/utils/http.js +6 -0
- package/dist/cjs/utils/reference.js +36 -0
- package/dist/cjs/utils/sleep.js +23 -0
- package/dist/cjs/utils/type.js +100 -1
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-debug.js +40 -10
- package/dist/mjs/bee.js +87 -27
- package/dist/mjs/chunk/cac.js +1 -1
- package/dist/mjs/feed/identifier.js +35 -0
- package/dist/mjs/feed/index.js +39 -94
- package/dist/mjs/feed/retrievable.js +105 -0
- package/dist/mjs/modules/debug/states.js +17 -0
- package/dist/mjs/modules/debug/status.js +3 -3
- package/dist/mjs/modules/feed.js +1 -1
- package/dist/mjs/types/index.js +1 -0
- package/dist/mjs/utils/bytes.js +15 -0
- package/dist/mjs/utils/http.js +7 -0
- package/dist/mjs/utils/reference.js +32 -0
- package/dist/mjs/utils/sleep.js +43 -0
- package/dist/mjs/utils/type.js +109 -2
- package/dist/types/bee-debug.d.ts +8 -1
- package/dist/types/bee.d.ts +55 -24
- package/dist/types/chunk/cac.d.ts +4 -5
- package/dist/types/chunk/soc.d.ts +4 -4
- package/dist/types/feed/identifier.d.ts +4 -0
- package/dist/types/feed/index.d.ts +9 -16
- package/dist/types/feed/retrievable.d.ts +5 -0
- package/dist/types/modules/bytes.d.ts +3 -3
- package/dist/types/modules/bzz.d.ts +3 -3
- package/dist/types/modules/chunk.d.ts +2 -2
- package/dist/types/modules/debug/states.d.ts +7 -1
- package/dist/types/modules/debug/status.d.ts +3 -3
- package/dist/types/modules/feed.d.ts +12 -1
- package/dist/types/modules/stewardship.d.ts +3 -3
- package/dist/types/types/debug.d.ts +38 -3
- package/dist/types/types/index.d.ts +33 -2
- package/dist/types/utils/bytes.d.ts +7 -0
- package/dist/types/utils/reference.d.ts +2 -0
- package/dist/types/utils/sleep.d.ts +6 -0
- package/dist/types/utils/type.d.ts +17 -1
- package/package.json +24 -24
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { BrandedType } from '../types';
|
|
1
|
+
import { BrandedType, PlainBytesReference } from '../types';
|
|
2
2
|
import { Bytes, FlexBytes } from '../utils/bytes';
|
|
3
3
|
export declare const MIN_PAYLOAD_SIZE = 1;
|
|
4
4
|
export declare const MAX_PAYLOAD_SIZE = 4096;
|
|
5
|
-
export declare type ChunkAddress = Bytes<32>;
|
|
6
5
|
/**
|
|
7
6
|
* General chunk interface for Swarm
|
|
8
7
|
*
|
|
@@ -16,7 +15,7 @@ export interface Chunk {
|
|
|
16
15
|
readonly data: Uint8Array;
|
|
17
16
|
span(): Bytes<8>;
|
|
18
17
|
payload(): FlexBytes<1, 4096>;
|
|
19
|
-
address():
|
|
18
|
+
address(): PlainBytesReference;
|
|
20
19
|
}
|
|
21
20
|
declare type ValidChunkData = BrandedType<Uint8Array, 'ValidChunkData'>;
|
|
22
21
|
/**
|
|
@@ -31,7 +30,7 @@ export declare function makeContentAddressedChunk(payloadBytes: Uint8Array): Chu
|
|
|
31
30
|
* @param data The chunk data
|
|
32
31
|
* @param chunkAddress The address of the chunk
|
|
33
32
|
*/
|
|
34
|
-
export declare function isValidChunkData(data: unknown, chunkAddress:
|
|
33
|
+
export declare function isValidChunkData(data: unknown, chunkAddress: PlainBytesReference): data is ValidChunkData;
|
|
35
34
|
/**
|
|
36
35
|
* Asserts if data are representing given address of its chunk.
|
|
37
36
|
*
|
|
@@ -40,5 +39,5 @@ export declare function isValidChunkData(data: unknown, chunkAddress: ChunkAddre
|
|
|
40
39
|
*
|
|
41
40
|
* @returns a valid content addressed chunk or throws error
|
|
42
41
|
*/
|
|
43
|
-
export declare function assertValidChunkData(data: unknown, chunkAddress:
|
|
42
|
+
export declare function assertValidChunkData(data: unknown, chunkAddress: PlainBytesReference): asserts data is ValidChunkData;
|
|
44
43
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bytes } from '../utils/bytes';
|
|
2
|
-
import { Chunk
|
|
3
|
-
import { UploadOptions, Signature, Signer, BatchId, Reference, Ky } from '../types';
|
|
2
|
+
import { Chunk } from './cac';
|
|
3
|
+
import { UploadOptions, Signature, Signer, BatchId, Reference, Ky, PlainBytesReference } from '../types';
|
|
4
4
|
import { EthAddress } from '../utils/eth';
|
|
5
5
|
export declare type Identifier = Bytes<32>;
|
|
6
6
|
/**
|
|
@@ -24,8 +24,8 @@ export interface SingleOwnerChunk extends Chunk {
|
|
|
24
24
|
*
|
|
25
25
|
* @returns a single owner chunk or throws error
|
|
26
26
|
*/
|
|
27
|
-
export declare function makeSingleOwnerChunkFromData(data: Uint8Array, address:
|
|
28
|
-
export declare function makeSOCAddress(identifier: Identifier, address: EthAddress):
|
|
27
|
+
export declare function makeSingleOwnerChunkFromData(data: Uint8Array, address: PlainBytesReference): SingleOwnerChunk;
|
|
28
|
+
export declare function makeSOCAddress(identifier: Identifier, address: EthAddress): PlainBytesReference;
|
|
29
29
|
/**
|
|
30
30
|
* Creates a single owner chunk object
|
|
31
31
|
*
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
import { Identifier } from '../chunk/soc';
|
|
2
1
|
import { FeedUpdateOptions } from '../modules/feed';
|
|
3
|
-
import {
|
|
2
|
+
import { BatchId, BytesReference, FEED_INDEX_HEX_LENGTH, FeedReader, FeedWriter, Ky, PlainBytesReference, Reference, Signer, Topic, UploadOptions } from '../types';
|
|
4
3
|
import { Bytes } from '../utils/bytes';
|
|
5
4
|
import { HexString } from '../utils/hex';
|
|
6
5
|
import { EthAddress, HexEthAddress } from '../utils/eth';
|
|
7
6
|
import type { FeedType } from './type';
|
|
8
|
-
declare const INDEX_HEX_LENGTH = 16;
|
|
9
7
|
export interface Epoch {
|
|
10
8
|
time: number;
|
|
11
9
|
level: number;
|
|
12
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Bytes of Feed's Index.
|
|
13
|
+
* For Sequential Feeds this is numeric value in big-endian.
|
|
14
|
+
*/
|
|
13
15
|
export declare type IndexBytes = Bytes<8>;
|
|
14
16
|
export declare type Index = number | Epoch | IndexBytes | string;
|
|
15
17
|
export interface FeedUploadOptions extends UploadOptions, FeedUpdateOptions {
|
|
16
18
|
}
|
|
17
|
-
declare type PlainChunkReference = Bytes<32>;
|
|
18
|
-
declare type EncryptedChunkReference = Bytes<64>;
|
|
19
|
-
export declare type ChunkReference = PlainChunkReference | EncryptedChunkReference;
|
|
20
19
|
export interface FeedUpdate {
|
|
21
20
|
timestamp: number;
|
|
22
|
-
reference:
|
|
21
|
+
reference: BytesReference;
|
|
23
22
|
}
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function makeFeedIdentifier(topic: Topic, index: Index): Identifier;
|
|
28
|
-
export declare function uploadFeedUpdate(ky: Ky, signer: Signer, topic: Topic, index: Index, reference: ChunkReference, postageBatchId: BatchId, options?: FeedUploadOptions): Promise<Reference>;
|
|
29
|
-
export declare function findNextIndex(ky: Ky, owner: HexEthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<HexString<typeof INDEX_HEX_LENGTH>>;
|
|
30
|
-
export declare function updateFeed(ky: Ky, signer: Signer, topic: Topic, reference: ChunkReference, postageBatchId: BatchId, options?: FeedUploadOptions): Promise<Reference>;
|
|
31
|
-
export declare function verifyChunkReference(data: Uint8Array): ChunkReference;
|
|
23
|
+
export declare function findNextIndex(ky: Ky, owner: HexEthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<HexString<typeof FEED_INDEX_HEX_LENGTH>>;
|
|
24
|
+
export declare function updateFeed(ky: Ky, signer: Signer, topic: Topic, reference: BytesReference, postageBatchId: BatchId, options?: FeedUploadOptions, index?: Index): Promise<Reference>;
|
|
25
|
+
export declare function getFeedUpdateChunkReference(owner: EthAddress, topic: Topic, index: Index): PlainBytesReference;
|
|
32
26
|
export declare function downloadFeedUpdate(ky: Ky, owner: EthAddress, topic: Topic, index: Index): Promise<FeedUpdate>;
|
|
33
27
|
export declare function makeFeedReader(ky: Ky, type: FeedType, topic: Topic, owner: HexEthAddress): FeedReader;
|
|
34
28
|
export declare function makeFeedWriter(ky: Ky, type: FeedType, topic: Topic, signer: Signer): FeedWriter;
|
|
35
|
-
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Bee } from '../bee';
|
|
2
|
+
import { EthAddress } from '../utils/eth';
|
|
3
|
+
import { RequestOptions, Topic } from '../types';
|
|
4
|
+
import { Index } from './index';
|
|
5
|
+
export declare function areAllSequentialFeedsUpdateRetrievable(bee: Bee, owner: EthAddress, topic: Topic, index: Index, options?: RequestOptions): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BatchId, Data, Ky,
|
|
1
|
+
import type { BatchId, Data, Ky, ReferenceOrEns, UploadOptions } from '../types';
|
|
2
2
|
import { UploadResult } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Upload data to a Bee node
|
|
@@ -15,11 +15,11 @@ export declare function upload(ky: Ky, data: string | Uint8Array, postageBatchId
|
|
|
15
15
|
* @param ky
|
|
16
16
|
* @param hash Bee content reference
|
|
17
17
|
*/
|
|
18
|
-
export declare function download(ky: Ky, hash:
|
|
18
|
+
export declare function download(ky: Ky, hash: ReferenceOrEns): Promise<Data>;
|
|
19
19
|
/**
|
|
20
20
|
* Download data as a readable stream
|
|
21
21
|
*
|
|
22
22
|
* @param ky
|
|
23
23
|
* @param hash Bee content reference
|
|
24
24
|
*/
|
|
25
|
-
export declare function downloadReadable(ky: Ky, hash:
|
|
25
|
+
export declare function downloadReadable(ky: Ky, hash: ReferenceOrEns): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchId, Collection, CollectionUploadOptions, Data, FileData, FileUploadOptions, Ky, Readable, UploadResult } from '../types';
|
|
1
|
+
import { BatchId, Collection, CollectionUploadOptions, Data, FileData, FileUploadOptions, Ky, Readable, ReferenceOrEns, UploadResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Upload single file
|
|
4
4
|
*
|
|
@@ -16,7 +16,7 @@ export declare function uploadFile(ky: Ky, data: string | Uint8Array | Readable
|
|
|
16
16
|
* @param hash Bee file or collection hash
|
|
17
17
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
18
18
|
*/
|
|
19
|
-
export declare function downloadFile(ky: Ky, hash:
|
|
19
|
+
export declare function downloadFile(ky: Ky, hash: ReferenceOrEns, path?: string): Promise<FileData<Data>>;
|
|
20
20
|
/**
|
|
21
21
|
* Download single file as a readable stream
|
|
22
22
|
*
|
|
@@ -24,7 +24,7 @@ export declare function downloadFile(ky: Ky, hash: string, path?: string): Promi
|
|
|
24
24
|
* @param hash Bee file or collection hash
|
|
25
25
|
* @param path If hash is collection then this defines path to a single file in the collection
|
|
26
26
|
*/
|
|
27
|
-
export declare function downloadFileReadable(ky: Ky, hash:
|
|
27
|
+
export declare function downloadFileReadable(ky: Ky, hash: ReferenceOrEns, path?: string): Promise<FileData<ReadableStream<Uint8Array>>>;
|
|
28
28
|
/**
|
|
29
29
|
* Upload collection
|
|
30
30
|
* @param ky Ky instance for given Bee class instance
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BatchId, Data, Ky, Reference, UploadOptions } from '../types';
|
|
1
|
+
import type { BatchId, Data, Ky, Reference, ReferenceOrEns, UploadOptions } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Upload chunk to a Bee node
|
|
4
4
|
*
|
|
@@ -19,4 +19,4 @@ export declare function upload(ky: Ky, data: Uint8Array, postageBatchId: BatchId
|
|
|
19
19
|
* @param hash Bee content reference
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
export declare function download(ky: Ky, hash:
|
|
22
|
+
export declare function download(ky: Ky, hash: ReferenceOrEns): Promise<Data>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainState, Ky, ReserveState } from '../../types';
|
|
1
|
+
import { ChainState, Ky, ReserveState, WalletBalance } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Get state of reserve
|
|
4
4
|
*
|
|
@@ -11,3 +11,9 @@ export declare function getReserveState(ky: Ky): Promise<ReserveState>;
|
|
|
11
11
|
* @param ky Ky debug instance
|
|
12
12
|
*/
|
|
13
13
|
export declare function getChainState(ky: Ky): Promise<ChainState>;
|
|
14
|
+
/**
|
|
15
|
+
* Get wallet balances for xDai and BZZ of the node
|
|
16
|
+
*
|
|
17
|
+
* @param ky Ky debug instance
|
|
18
|
+
*/
|
|
19
|
+
export declare function getWalletBalance(ky: Ky): Promise<WalletBalance>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Health, NodeInfo } from '../../types/debug';
|
|
2
2
|
import { Ky } from '../../types';
|
|
3
3
|
import { BeeVersions } from '../../types/debug';
|
|
4
|
-
export declare const SUPPORTED_BEE_VERSION_EXACT = "1.
|
|
5
|
-
export declare const SUPPORTED_API_VERSION = "3.0.
|
|
6
|
-
export declare const SUPPORTED_DEBUG_API_VERSION = "2.0.
|
|
4
|
+
export declare const SUPPORTED_BEE_VERSION_EXACT = "1.6.0-6ceadd35";
|
|
5
|
+
export declare const SUPPORTED_API_VERSION = "3.0.1";
|
|
6
|
+
export declare const SUPPORTED_DEBUG_API_VERSION = "2.0.1";
|
|
7
7
|
export declare const SUPPORTED_BEE_VERSION: string;
|
|
8
8
|
/**
|
|
9
9
|
* Get health of node
|
|
@@ -13,9 +13,20 @@ export interface FeedUpdateOptions {
|
|
|
13
13
|
* Can be 'epoch' or 'sequence' (default: 'sequence')
|
|
14
14
|
*/
|
|
15
15
|
type?: FeedType;
|
|
16
|
+
/**
|
|
17
|
+
* Fetch specific previous Feed's update (default fetches latest update)
|
|
18
|
+
*/
|
|
19
|
+
index?: string;
|
|
16
20
|
}
|
|
17
21
|
interface FeedUpdateHeaders {
|
|
22
|
+
/**
|
|
23
|
+
* The current feed's index
|
|
24
|
+
*/
|
|
18
25
|
feedIndex: string;
|
|
26
|
+
/**
|
|
27
|
+
* The feed's index for next update.
|
|
28
|
+
* Only set for the latest update. If update is fetched using previous index, then this is an empty string.
|
|
29
|
+
*/
|
|
19
30
|
feedIndexNext: string;
|
|
20
31
|
}
|
|
21
32
|
export interface FetchFeedUpdateResponse extends ReferenceResponse, FeedUpdateHeaders {
|
|
@@ -43,5 +54,5 @@ export declare function createFeedManifest(ky: Ky, owner: HexEthAddress, topic:
|
|
|
43
54
|
* @param topic Topic in hex
|
|
44
55
|
* @param options Additional options, like index, at, type
|
|
45
56
|
*/
|
|
46
|
-
export declare function
|
|
57
|
+
export declare function fetchLatestFeedUpdate(ky: Ky, owner: HexEthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<FetchFeedUpdateResponse>;
|
|
47
58
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Ky,
|
|
1
|
+
import type { Ky, ReferenceOrEns } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Reupload locally pinned data
|
|
4
4
|
* @param ky Ky instance
|
|
@@ -6,5 +6,5 @@ import type { Ky, Reference } from '../types';
|
|
|
6
6
|
* @param options
|
|
7
7
|
* @throws BeeResponseError if not locally pinned or invalid data
|
|
8
8
|
*/
|
|
9
|
-
export declare function reupload(ky: Ky, reference:
|
|
10
|
-
export declare function isRetrievable(ky: Ky, reference:
|
|
9
|
+
export declare function reupload(ky: Ky, reference: ReferenceOrEns): Promise<void>;
|
|
10
|
+
export declare function isRetrievable(ky: Ky, reference: ReferenceOrEns): Promise<boolean>;
|
|
@@ -139,8 +139,27 @@ export declare enum BeeModes {
|
|
|
139
139
|
* Information about Bee node and its configuration
|
|
140
140
|
*/
|
|
141
141
|
export interface NodeInfo {
|
|
142
|
+
/**
|
|
143
|
+
* Indicates whether the node is in a Gateway mode.
|
|
144
|
+
* Gateway mode is a restricted mode where some features are not available.
|
|
145
|
+
*/
|
|
142
146
|
gatewayMode: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Indicates in what mode Bee is running.
|
|
149
|
+
*/
|
|
143
150
|
beeMode: BeeModes;
|
|
151
|
+
/**
|
|
152
|
+
* Indicates whether the Bee node has its own deployed chequebook.
|
|
153
|
+
*
|
|
154
|
+
* @see [Bee docs - Chequebook](https://docs.ethswarm.org/docs/introduction/terminology#cheques--chequebook)
|
|
155
|
+
*/
|
|
156
|
+
chequebookEnabled: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Indicates whether SWAP is enabled for the Bee node.
|
|
159
|
+
*
|
|
160
|
+
* @see [Bee docs - SWAP](https://docs.ethswarm.org/docs/introduction/terminology#swap)
|
|
161
|
+
*/
|
|
162
|
+
swapEnabled: boolean;
|
|
144
163
|
}
|
|
145
164
|
/**
|
|
146
165
|
* Information about Bee node and its configuration
|
|
@@ -188,13 +207,29 @@ export interface PingResponse {
|
|
|
188
207
|
}
|
|
189
208
|
export interface ReserveState {
|
|
190
209
|
radius: number;
|
|
210
|
+
commitment: number;
|
|
191
211
|
storageRadius: number;
|
|
192
|
-
available: number;
|
|
193
|
-
outer: NumberString;
|
|
194
|
-
inner: NumberString;
|
|
195
212
|
}
|
|
196
213
|
export interface ChainState {
|
|
197
214
|
block: number;
|
|
198
215
|
totalAmount: NumberString;
|
|
199
216
|
currentPrice: NumberString;
|
|
200
217
|
}
|
|
218
|
+
export interface WalletBalance {
|
|
219
|
+
/**
|
|
220
|
+
* Balance of BZZ tokens
|
|
221
|
+
*/
|
|
222
|
+
bzz: NumberString;
|
|
223
|
+
/**
|
|
224
|
+
* Balance of xDai
|
|
225
|
+
*/
|
|
226
|
+
xDai: NumberString;
|
|
227
|
+
/**
|
|
228
|
+
* Chain network ID to which the Bee node is connected
|
|
229
|
+
*/
|
|
230
|
+
chainID: number;
|
|
231
|
+
/**
|
|
232
|
+
* Chequebook contract address
|
|
233
|
+
*/
|
|
234
|
+
contractAddress: string;
|
|
235
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Identifier, SingleOwnerChunk } from '../chunk/soc';
|
|
3
|
-
import type {
|
|
3
|
+
import type { FeedUploadOptions } from '../feed';
|
|
4
4
|
import type { FeedType } from '../feed/type';
|
|
5
5
|
import type { FeedUpdateOptions, FetchFeedUpdateResponse } from '../modules/feed';
|
|
6
6
|
import type { Bytes } from '../utils/bytes';
|
|
@@ -39,6 +39,7 @@ export declare const STAMPS_DEPTH_MIN = 17;
|
|
|
39
39
|
export declare const STAMPS_DEPTH_MAX = 255;
|
|
40
40
|
export declare const TAGS_LIMIT_MIN = 1;
|
|
41
41
|
export declare const TAGS_LIMIT_MAX = 1000;
|
|
42
|
+
export declare const FEED_INDEX_HEX_LENGTH = 16;
|
|
42
43
|
/**
|
|
43
44
|
* Generic reference that can be either non-encrypted reference which is a hex string of length 64 or encrypted
|
|
44
45
|
* reference which is a hex string of length 128.
|
|
@@ -48,6 +49,17 @@ export declare const TAGS_LIMIT_MAX = 1000;
|
|
|
48
49
|
* @see [Bee docs - Store with Encryption](https://docs.ethswarm.org/docs/access-the-swarm/store-with-encryption)
|
|
49
50
|
*/
|
|
50
51
|
export declare type Reference = HexString<typeof REFERENCE_HEX_LENGTH> | HexString<typeof ENCRYPTED_REFERENCE_HEX_LENGTH>;
|
|
52
|
+
/**
|
|
53
|
+
* Type that represents either Swarm's reference in hex string or ESN domain (something.eth).
|
|
54
|
+
*/
|
|
55
|
+
export declare type ReferenceOrEns = Reference | string;
|
|
56
|
+
/**
|
|
57
|
+
* Type that represents either Swarm's reference in hex string, ESN domain (something.eth) or CID using one of the Swarm's codecs.
|
|
58
|
+
*/
|
|
59
|
+
export declare type ReferenceCidOrEns = ReferenceOrEns | string;
|
|
60
|
+
export declare type PlainBytesReference = Bytes<typeof REFERENCE_BYTES_LENGTH>;
|
|
61
|
+
export declare type EncryptedBytesReference = Bytes<typeof ENCRYPTED_REFERENCE_BYTES_LENGTH>;
|
|
62
|
+
export declare type BytesReference = PlainBytesReference | EncryptedBytesReference;
|
|
51
63
|
export declare type PublicKey = HexString<typeof PUBKEY_HEX_LENGTH>;
|
|
52
64
|
export declare type Address = HexString<typeof ADDRESS_HEX_LENGTH>;
|
|
53
65
|
/**
|
|
@@ -111,6 +123,9 @@ export interface BeeOptions extends RequestOptions {
|
|
|
111
123
|
*/
|
|
112
124
|
onResponse?: HookCallback<BeeResponse>;
|
|
113
125
|
}
|
|
126
|
+
export interface UploadResultWithCid extends UploadResult {
|
|
127
|
+
cid: string;
|
|
128
|
+
}
|
|
114
129
|
/**
|
|
115
130
|
* Result of upload calls.
|
|
116
131
|
*/
|
|
@@ -356,7 +371,7 @@ export interface FeedWriter extends FeedReader {
|
|
|
356
371
|
*
|
|
357
372
|
* @returns Reference that points at Single Owner Chunk that contains the new update and pointer to the updated chunk reference.
|
|
358
373
|
*/
|
|
359
|
-
upload(postageBatchId: string | BatchId, reference:
|
|
374
|
+
upload(postageBatchId: string | BatchId, reference: BytesReference | Reference, options?: FeedUploadOptions): Promise<Reference>;
|
|
360
375
|
}
|
|
361
376
|
/**
|
|
362
377
|
* Interface for downloading single owner chunks
|
|
@@ -441,6 +456,22 @@ export interface PostageBatchOptions extends RequestOptions {
|
|
|
441
456
|
*/
|
|
442
457
|
gasPrice?: NumberString;
|
|
443
458
|
immutableFlag?: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* The returned Promise will await until the purchased Postage Batch is usable.
|
|
461
|
+
* In other word, it has to have enough block confirmations that Bee pronounce it usable.
|
|
462
|
+
* If turned on, this significantly prolong the creation of postage batch!
|
|
463
|
+
* If you plan to use the stamp right away for some action with Bee (like uploading using this stamp) it is
|
|
464
|
+
* highly recommended to use this option, otherwise you might get errors "stamp not usable" from Bee.
|
|
465
|
+
*
|
|
466
|
+
* In next breaking release this option will be turned on by default.
|
|
467
|
+
* @default false
|
|
468
|
+
*/
|
|
469
|
+
waitForUsable?: boolean;
|
|
470
|
+
/**
|
|
471
|
+
* When waiting for the postage stamp to become usable, this specify the timeout for the waiting.
|
|
472
|
+
* Default: 120s
|
|
473
|
+
*/
|
|
474
|
+
waitForUsableTimeout?: number;
|
|
444
475
|
}
|
|
445
476
|
/**
|
|
446
477
|
* With this type a number should be represented in a string
|
|
@@ -28,6 +28,13 @@ export interface FlexBytes<Min extends number, Max extends number> extends Uint8
|
|
|
28
28
|
* @param length The length of the byte array
|
|
29
29
|
*/
|
|
30
30
|
export declare function isBytes<Length extends number>(b: unknown, length: Length): b is Bytes<Length>;
|
|
31
|
+
/**
|
|
32
|
+
* Function that verifies if passed data are Bytes and if the array has "length" number of bytes under given offset.
|
|
33
|
+
* @param data
|
|
34
|
+
* @param offset
|
|
35
|
+
* @param length
|
|
36
|
+
*/
|
|
37
|
+
export declare function hasBytesAtOffset(data: unknown, offset: number, length: number): boolean;
|
|
31
38
|
/**
|
|
32
39
|
* Verifies if a byte array has a certain length
|
|
33
40
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Address, AddressPrefix, AllTagsOptions, BatchId, CollectionUploadOptions, FileUploadOptions, NumberString, PssMessageHandler, PublicKey, Readable, Reference, Tag, UploadOptions, TransactionHash, RequestOptions, PostageBatchOptions, CashoutOptions } from '../types';
|
|
1
|
+
import { Address, AddressPrefix, AllTagsOptions, BatchId, CollectionUploadOptions, FileUploadOptions, NumberString, PssMessageHandler, PublicKey, Readable, Reference, Tag, UploadOptions, TransactionHash, RequestOptions, PostageBatchOptions, CashoutOptions, ReferenceOrEns, UploadResult, UploadResultWithCid } from '../types';
|
|
2
|
+
import { ReferenceType } from '@ethersphere/swarm-cid';
|
|
2
3
|
export declare function isUint8Array(obj: unknown): obj is Uint8Array;
|
|
3
4
|
export declare function isInteger(value: unknown): value is number | NumberString;
|
|
4
5
|
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
@@ -22,7 +23,22 @@ export declare function assertStrictlyObject(value: unknown, name?: string): ass
|
|
|
22
23
|
export declare function assertBoolean(value: unknown, name?: string): asserts value is boolean;
|
|
23
24
|
export declare function assertInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
|
24
25
|
export declare function assertNonNegativeInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
|
26
|
+
export declare function assertPositiveInteger(value: unknown, name?: string): asserts value is number | NumberString;
|
|
25
27
|
export declare function assertReference(value: unknown): asserts value is Reference;
|
|
28
|
+
export declare function assertReferenceOrEns(value: unknown): asserts value is ReferenceOrEns;
|
|
29
|
+
/**
|
|
30
|
+
* Function that mainly converts Swarm CID into hex encoded Swarm Reference
|
|
31
|
+
*
|
|
32
|
+
* @param value
|
|
33
|
+
* @param expectedCidType
|
|
34
|
+
*/
|
|
35
|
+
export declare function makeReferenceOrEns(value: unknown, expectedCidType: ReferenceType): ReferenceOrEns;
|
|
36
|
+
/**
|
|
37
|
+
* Function that adds getter which converts the reference into CID base32 encoded string.
|
|
38
|
+
* @param result
|
|
39
|
+
* @param cidType Type as described in the @ethersphere/swarm-cids-js -> ReferenceType
|
|
40
|
+
*/
|
|
41
|
+
export declare function addCidConversionFunction(result: UploadResult, cidType: ReferenceType): UploadResultWithCid;
|
|
26
42
|
export declare function assertAddress(value: unknown): asserts value is Address;
|
|
27
43
|
export declare function assertBatchId(value: unknown): asserts value is BatchId;
|
|
28
44
|
export declare function assertRequestOptions(value: unknown, name?: string): asserts value is RequestOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.1-pre.0",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
|
|
51
51
|
"build:browser": "webpack --progress",
|
|
52
52
|
"mock-ci": "npm run lint:check && npm run check:types && npm run test",
|
|
53
|
-
"docs": "rimraf docs && typedoc",
|
|
54
53
|
"test": "npm run build:browser && jest --verbose --selectProjects=node:unit node:integration dom:integration --config=jest.config.ts",
|
|
55
54
|
"test:integration:browser": "npm run build:browser && jest --verbose --selectProjects=dom:integration --config=jest.config.ts",
|
|
56
55
|
"test:integration:node": "jest --verbose --selectProjects=node:integration --config=jest.config.ts",
|
|
@@ -61,9 +60,11 @@
|
|
|
61
60
|
"check:types": "tsc --project tsconfig.test.json",
|
|
62
61
|
"lint": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\" && prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
63
62
|
"lint:check": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
64
|
-
"depcheck": "depcheck ."
|
|
63
|
+
"depcheck": "depcheck .",
|
|
64
|
+
"bee": "bee-factory start"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
+
"@ethersphere/swarm-cid": "^0.1.0",
|
|
67
68
|
"@types/readable-stream": "^2.3.13",
|
|
68
69
|
"bufferutil": "^4.0.6",
|
|
69
70
|
"elliptic": "^6.5.4",
|
|
@@ -76,17 +77,18 @@
|
|
|
76
77
|
"tar-js": "^0.3.0",
|
|
77
78
|
"utf-8-validate": "^5.0.9",
|
|
78
79
|
"web-streams-polyfill": "^4.0.0-beta.1",
|
|
79
|
-
"ws": "^8.
|
|
80
|
+
"ws": "^8.6.0"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
|
-
"@babel/cli": "^7.17.
|
|
83
|
-
"@babel/core": "^7.
|
|
83
|
+
"@babel/cli": "^7.17.10",
|
|
84
|
+
"@babel/core": "^7.17.9",
|
|
84
85
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
85
86
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
86
|
-
"@babel/preset-env": "^7.
|
|
87
|
+
"@babel/preset-env": "^7.17.10",
|
|
87
88
|
"@babel/preset-typescript": "^7.14.5",
|
|
88
|
-
"@commitlint/cli": "^16.2.
|
|
89
|
+
"@commitlint/cli": "^16.2.3",
|
|
89
90
|
"@commitlint/config-conventional": "^16.2.1",
|
|
91
|
+
"@ethersphere/bee-factory": "^0.4.1",
|
|
90
92
|
"@fluffy-spoon/substitute": "^1.208.0",
|
|
91
93
|
"@jest/test-sequencer": "^27.5.0",
|
|
92
94
|
"@jest/types": "^27.5.1",
|
|
@@ -100,43 +102,41 @@
|
|
|
100
102
|
"@types/node": "^15.12.4",
|
|
101
103
|
"@types/puppeteer": "^5.4.5",
|
|
102
104
|
"@types/semver": "^7.3.9",
|
|
103
|
-
"@types/ws": "^
|
|
105
|
+
"@types/ws": "^8.5.3",
|
|
104
106
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
105
|
-
"@typescript-eslint/parser": "^5.
|
|
106
|
-
"babel-jest": "^
|
|
107
|
-
"babel-loader": "^8.2.
|
|
107
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
108
|
+
"babel-jest": "^28.1.0",
|
|
109
|
+
"babel-loader": "^8.2.5",
|
|
108
110
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
109
111
|
"cross-blob": "^2.0.1",
|
|
110
112
|
"cross-env": "^7.0.3",
|
|
111
113
|
"debug": "^4.3.4",
|
|
112
114
|
"depcheck": "^1.4.3",
|
|
113
|
-
"eslint": "^8.
|
|
115
|
+
"eslint": "^8.13.0",
|
|
114
116
|
"eslint-config-prettier": "^8.5.0",
|
|
115
117
|
"eslint-plugin-jest": "^25.7.0",
|
|
116
118
|
"eslint-plugin-prettier": "^4.0.0",
|
|
117
119
|
"eslint-plugin-unused-imports": "^2.0.0",
|
|
118
|
-
"glob": "^
|
|
119
|
-
"husky": "^
|
|
120
|
+
"glob": "^8.0.1",
|
|
121
|
+
"husky": "^8.0.1",
|
|
120
122
|
"jest": "^27.5.1",
|
|
121
123
|
"jest-puppeteer": "^6.1.0",
|
|
122
124
|
"nock": "^13.2.4",
|
|
123
125
|
"prettier": "^2.6.2",
|
|
124
|
-
"puppeteer": "^
|
|
126
|
+
"puppeteer": "^14.1.0",
|
|
125
127
|
"rimraf": "^3.0.2",
|
|
126
|
-
"terser-webpack-plugin": "^5.3.
|
|
128
|
+
"terser-webpack-plugin": "^5.3.1",
|
|
127
129
|
"ts-node": "^10.7.0",
|
|
128
|
-
"typedoc": "^0.22.11",
|
|
129
|
-
"typedoc-plugin-markdown": "^3.11.12",
|
|
130
130
|
"typescript": "^4.5.4",
|
|
131
|
-
"webpack": "^5.
|
|
132
|
-
"webpack-bundle-analyzer": "^4.
|
|
131
|
+
"webpack": "^5.72.0",
|
|
132
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
133
133
|
"webpack-cli": "^4.9.2"
|
|
134
134
|
},
|
|
135
135
|
"engines": {
|
|
136
136
|
"node": ">=12.0.0",
|
|
137
137
|
"npm": ">=6.0.0",
|
|
138
|
-
"beeApiVersion": "3.0.
|
|
139
|
-
"beeDebugApiVersion": "2.0.
|
|
140
|
-
"bee": "1.
|
|
138
|
+
"beeApiVersion": "3.0.1",
|
|
139
|
+
"beeDebugApiVersion": "2.0.1",
|
|
140
|
+
"bee": "1.6.0-6ceadd35"
|
|
141
141
|
}
|
|
142
142
|
}
|