@ethersphere/bee-js 9.8.0 → 10.0.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.
@@ -23,7 +23,7 @@ export interface Peer {
23
23
  fullNode?: boolean;
24
24
  }
25
25
  export interface ChequebookAddressResponse {
26
- chequebookAddress: string;
26
+ chequebookAddress: EthAddress;
27
27
  }
28
28
  export interface ChequebookBalanceResponse {
29
29
  totalBalance: BZZ;
@@ -13,16 +13,24 @@ export declare const BRANCHES = 128;
13
13
  export declare const CHUNK_SIZE: number;
14
14
  export declare const PSS_TARGET_HEX_LENGTH_MAX = 4;
15
15
  /**
16
- * Minimal depth that can be used for creation of postage batch
16
+ * Minimum postage batch depth.
17
17
  */
18
18
  export declare const STAMPS_DEPTH_MIN = 17;
19
19
  /**
20
- * Maximal depth that can be used for creation of postage batch
20
+ * Maximum postage batch depth.
21
21
  */
22
22
  export declare const STAMPS_DEPTH_MAX = 255;
23
+ /**
24
+ * Minimum tags API page size.
25
+ */
23
26
  export declare const TAGS_LIMIT_MIN = 1;
27
+ /**
28
+ * Maximum tags API page size.
29
+ */
24
30
  export declare const TAGS_LIMIT_MAX = 1000;
25
- export declare const FEED_INDEX_HEX_LENGTH = 16;
31
+ /**
32
+ * Behavior of the HTTP client, such as `timeout`, additional `headers`, custom `httpAgent`, etc.
33
+ */
26
34
  export type BeeRequestOptions = {
27
35
  baseURL?: string;
28
36
  timeout?: number;
@@ -32,13 +40,29 @@ export type BeeRequestOptions = {
32
40
  httpsAgent?: unknown;
33
41
  endlesslyRetry?: boolean;
34
42
  };
43
+ /**
44
+ * Options for the Bee client which affect all method calls *(unless overridden in the method call itself)*.
45
+ *
46
+ * Extends `BeeRequestOptions`, which allows configuring the HTTP client behavior,
47
+ * such as `timeout`, additional `headers`, custom `httpAgent`, etc.
48
+ */
35
49
  export interface BeeOptions extends BeeRequestOptions {
36
50
  /**
37
- * Signer object or private key of the Signer in form of either hex string or Uint8Array that will be default signer for the instance.
51
+ * Default signer (a private key) used for signing.
52
+ *
53
+ * Mainly used in single-owner chunk (SOC) related operations, and consequently in feeds.
54
+ *
55
+ * If not provided, methods such as `makeFeedWriter` and `makeSOCWriter`
56
+ * must be provided with a private key in their respective function calls.
38
57
  */
39
58
  signer?: PrivateKey | Uint8Array | string;
40
59
  /**
41
- * Default gnosis when unspecified.
60
+ * Network on which the Bee node is running.
61
+ *
62
+ * This is currently used to determine block time for postage batch time-to-live (TTL) calculations.
63
+ * The block time for `gnosis` is `5` seconds, and for `sepolia` it is `15` seconds.
64
+ *
65
+ * Default value is `gnosis`.
42
66
  */
43
67
  network?: 'gnosis' | 'sepolia';
44
68
  }
@@ -146,14 +170,20 @@ export declare enum RedundancyStrategy {
146
170
  export interface DownloadOptions {
147
171
  /**
148
172
  * Specify the retrieve strategy on redundant data.
173
+ *
174
+ * Only applicable for erasure coded data.
149
175
  */
150
176
  redundancyStrategy?: RedundancyStrategy;
151
177
  /**
152
178
  * Specify if the retrieve strategies (chunk prefetching on redundant data) are used in a fallback cascade. The default is true.
179
+ *
180
+ * Only applicable for erasure coded data.
153
181
  */
154
182
  fallback?: boolean;
155
183
  /**
156
184
  * Specify the timeout for chunk retrieval. The default is 30 seconds.
185
+ *
186
+ * This is not the timeout for the whole download operation, but rather for each chunk retrieval.
157
187
  */
158
188
  timeoutMs?: number;
159
189
  actPublisher?: PublicKey | Uint8Array | string;
@@ -200,7 +230,11 @@ export interface UploadHeaders {
200
230
  'swarm-postage-batch-id'?: string;
201
231
  }
202
232
  /**
203
- * Object that contains infromation about progress of upload of data to network.
233
+ * Object that contains information about upload progress of data to network.
234
+ *
235
+ * The total amount of chunks is represented by `split` property.
236
+ *
237
+ * The actual progress of the upload can be tracked by the `seen + synced` properties.
204
238
  *
205
239
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing)
206
240
  */
@@ -273,6 +307,7 @@ export interface PssSubscription {
273
307
  export interface PssMessageHandler {
274
308
  onMessage: (message: Bytes, subscription: PssSubscription) => void;
275
309
  onError: (error: BeeError, subscription: PssSubscription) => void;
310
+ onClose: (subscription: PssSubscription) => void;
276
311
  }
277
312
  export interface GsocSubscription {
278
313
  readonly address: EthAddress;
@@ -281,6 +316,7 @@ export interface GsocSubscription {
281
316
  export interface GsocMessageHandler {
282
317
  onMessage: (message: Bytes, subscription: GsocSubscription) => void;
283
318
  onError: (error: BeeError, subscription: GsocSubscription) => void;
319
+ onClose: (subscription: GsocSubscription) => void;
284
320
  }
285
321
  export interface ReferenceResponse {
286
322
  reference: Reference;
@@ -484,3 +520,69 @@ export interface EnvelopeWithBatchId extends Envelope {
484
520
  export type NumberString = string & {
485
521
  __numberString: never;
486
522
  };
523
+ export declare const capacityBreakpoints: {
524
+ ENCRYPTION_OFF: {
525
+ 0: {
526
+ theoreticalVolume: string;
527
+ effectiveVolume: string;
528
+ batchDepth: number;
529
+ utilizationRate: string;
530
+ }[];
531
+ 1: {
532
+ theoreticalVolume: string;
533
+ effectiveVolume: string;
534
+ batchDepth: number;
535
+ utilizationRate: string;
536
+ }[];
537
+ 2: {
538
+ theoreticalVolume: string;
539
+ effectiveVolume: string;
540
+ batchDepth: number;
541
+ utilizationRate: string;
542
+ }[];
543
+ 3: {
544
+ theoreticalVolume: string;
545
+ effectiveVolume: string;
546
+ batchDepth: number;
547
+ utilizationRate: string;
548
+ }[];
549
+ 4: {
550
+ theoreticalVolume: string;
551
+ effectiveVolume: string;
552
+ batchDepth: number;
553
+ utilizationRate: string;
554
+ }[];
555
+ };
556
+ ENCRYPTION_ON: {
557
+ 0: {
558
+ theoreticalVolume: string;
559
+ effectiveVolume: string;
560
+ batchDepth: number;
561
+ utilizationRate: string;
562
+ }[];
563
+ 1: {
564
+ theoreticalVolume: string;
565
+ effectiveVolume: string;
566
+ batchDepth: number;
567
+ utilizationRate: string;
568
+ }[];
569
+ 2: {
570
+ theoreticalVolume: string;
571
+ effectiveVolume: string;
572
+ batchDepth: number;
573
+ utilizationRate: string;
574
+ }[];
575
+ 3: {
576
+ theoreticalVolume: string;
577
+ effectiveVolume: string;
578
+ batchDepth: number;
579
+ utilizationRate: string;
580
+ }[];
581
+ 4: {
582
+ theoreticalVolume: string;
583
+ effectiveVolume: string;
584
+ batchDepth: number;
585
+ utilizationRate: string;
586
+ }[];
587
+ };
588
+ };
@@ -16,3 +16,4 @@ export declare class Bytes {
16
16
  equals(other: Bytes | Uint8Array | string): boolean;
17
17
  represent(): string;
18
18
  }
19
+ export declare function parseSizeToBytes(sizeStr: string): number;
@@ -1,5 +1,6 @@
1
1
  export declare class Duration {
2
2
  private seconds;
3
+ static ZERO: Duration;
3
4
  private constructor();
4
5
  static fromMilliseconds(milliseconds: number): Duration;
5
6
  static fromSeconds(seconds: number): Duration;
@@ -15,4 +16,5 @@ export declare class Duration {
15
16
  toYears(): number;
16
17
  toEndDate(startDate?: Date): Date;
17
18
  represent(): string;
19
+ isZero(): boolean;
18
20
  }
@@ -1,4 +1,4 @@
1
- import { EnvelopeWithBatchId, NumberString } from '../types';
1
+ import { EnvelopeWithBatchId, NumberString, RedundancyLevel } from '../types';
2
2
  import { Bytes } from './bytes';
3
3
  import { Duration } from './duration';
4
4
  import { Size } from './size';
@@ -27,8 +27,8 @@ export declare function getStampTheoreticalBytes(depth: number): number;
27
27
  *
28
28
  * @returns {number} The effective size of the postage batch in bytes.
29
29
  */
30
- export declare function getStampEffectiveBytes(depth: number): number;
31
- export declare function getStampEffectiveBytesBreakpoints(): Map<number, number>;
30
+ export declare function getStampEffectiveBytes(depth: number, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): number;
31
+ export declare function getStampEffectiveBytesBreakpoints(encryption: boolean, erasureCodeLevel?: RedundancyLevel): Map<number, number>;
32
32
  /**
33
33
  * Utility function that calculates the cost of a postage batch based on its depth and amount.
34
34
  */
@@ -55,6 +55,6 @@ export declare function getAmountForDuration(duration: Duration, pricePerBlock:
55
55
  * @param size The effective size of the postage batch
56
56
  * @returns
57
57
  */
58
- export declare function getDepthForSize(size: Size): number;
58
+ export declare function getDepthForSize(size: Size, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): number;
59
59
  export declare function convertEnvelopeToMarshaledStamp(envelope: EnvelopeWithBatchId): Bytes;
60
60
  export declare function marshalStamp(signature: Uint8Array, batchId: Uint8Array, timestamp: Uint8Array, index: Uint8Array): Bytes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "9.8.0",
3
+ "version": "10.0.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",