@ethersphere/bee-js 10.3.0 → 11.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.
Files changed (81) hide show
  1. package/dist/cjs/bee.js +17 -10
  2. package/dist/cjs/chunk/bmt.js +1 -2
  3. package/dist/cjs/chunk/cac.js +3 -3
  4. package/dist/cjs/chunk/soc.js +24 -15
  5. package/dist/cjs/feed/identifier.js +1 -2
  6. package/dist/cjs/feed/index.js +25 -16
  7. package/dist/cjs/feed/retrievable.js +1 -2
  8. package/dist/cjs/index.js +17 -7
  9. package/dist/cjs/modules/bytes.js +4 -5
  10. package/dist/cjs/modules/bzz.js +4 -5
  11. package/dist/cjs/modules/chunk.js +2 -3
  12. package/dist/cjs/modules/debug/balance.js +4 -5
  13. package/dist/cjs/modules/debug/chequebook.js +8 -9
  14. package/dist/cjs/modules/debug/connectivity.js +7 -8
  15. package/dist/cjs/modules/debug/settlements.js +2 -3
  16. package/dist/cjs/modules/debug/stake.js +6 -7
  17. package/dist/cjs/modules/debug/stamps.js +23 -77
  18. package/dist/cjs/modules/debug/states.js +6 -6
  19. package/dist/cjs/modules/debug/status.js +9 -9
  20. package/dist/cjs/modules/debug/transactions.js +4 -5
  21. package/dist/cjs/modules/envelope.js +1 -2
  22. package/dist/cjs/modules/feed.js +3 -4
  23. package/dist/cjs/modules/grantee.js +3 -4
  24. package/dist/cjs/modules/gsoc.js +2 -3
  25. package/dist/cjs/modules/pinning.js +4 -5
  26. package/dist/cjs/modules/pss.js +2 -3
  27. package/dist/cjs/modules/rchash.js +1 -2
  28. package/dist/cjs/modules/soc.js +1 -2
  29. package/dist/cjs/modules/status.js +2 -3
  30. package/dist/cjs/modules/stewardship.js +2 -3
  31. package/dist/cjs/modules/tag.js +5 -6
  32. package/dist/cjs/types/debug.js +3 -3
  33. package/dist/cjs/types/index.js +2 -2
  34. package/dist/cjs/utils/bytes.js +2 -2
  35. package/dist/cjs/utils/chunk-size.js +1 -2
  36. package/dist/cjs/utils/chunk-stream.browser.js +3 -4
  37. package/dist/cjs/utils/chunk-stream.js +3 -4
  38. package/dist/cjs/utils/cid.js +3 -3
  39. package/dist/cjs/utils/collection.browser.js +2 -3
  40. package/dist/cjs/utils/collection.js +5 -6
  41. package/dist/cjs/utils/collection.node.js +2 -3
  42. package/dist/cjs/utils/data.browser.js +1 -2
  43. package/dist/cjs/utils/data.js +1 -2
  44. package/dist/cjs/utils/expose.js +4 -1
  45. package/dist/cjs/utils/file.js +2 -3
  46. package/dist/cjs/utils/headers.js +2 -3
  47. package/dist/cjs/utils/http.js +2 -2
  48. package/dist/cjs/utils/pss.js +1 -2
  49. package/dist/cjs/utils/redundancy.js +3 -4
  50. package/dist/cjs/utils/stamps.js +60 -11
  51. package/dist/cjs/utils/tar-uploader.browser.js +1 -2
  52. package/dist/cjs/utils/tar-uploader.js +1 -2
  53. package/dist/cjs/utils/tar-writer.browser.js +1 -2
  54. package/dist/cjs/utils/tar-writer.js +1 -2
  55. package/dist/cjs/utils/type.js +34 -25
  56. package/dist/cjs/utils/url.js +3 -4
  57. package/dist/cjs/utils/workaround.js +7 -5
  58. package/dist/index.browser.min.js +1 -1
  59. package/dist/index.browser.min.js.map +1 -1
  60. package/dist/mjs/bee.js +0 -3
  61. package/dist/mjs/modules/debug/stamps.js +37 -110
  62. package/dist/mjs/modules/debug/states.js +3 -0
  63. package/dist/mjs/modules/debug/status.js +1 -1
  64. package/dist/mjs/utils/expose.js +1 -1
  65. package/dist/mjs/utils/stamps.js +48 -0
  66. package/dist/mjs/utils/workaround.js +5 -2
  67. package/dist/types/bee.d.ts +0 -4
  68. package/dist/types/index.d.ts +3 -2
  69. package/dist/types/modules/bzz.d.ts +0 -1
  70. package/dist/types/modules/debug/status.d.ts +1 -1
  71. package/dist/types/modules/gsoc.d.ts +0 -1
  72. package/dist/types/modules/pss.d.ts +0 -1
  73. package/dist/types/types/debug.d.ts +1 -0
  74. package/dist/types/utils/constants.d.ts +3 -3
  75. package/dist/types/utils/error.d.ts +2 -2
  76. package/dist/types/utils/expose.d.ts +1 -1
  77. package/dist/types/utils/stamps.d.ts +15 -1
  78. package/dist/types/utils/tar.browser.d.ts +1 -1
  79. package/dist/types/utils/tar.d.ts +0 -1
  80. package/dist/types/utils/type.d.ts +0 -1
  81. package/package.json +9 -12
package/dist/mjs/bee.js CHANGED
@@ -953,9 +953,6 @@ export class Bee {
953
953
  *
954
954
  * @param rawPayload Data to be stored in the chunk. If the data is a string, it will be converted to UTF-8 bytes.
955
955
  * @param span Optional span for the chunk. If not provided, it will be set to the length of the payload.
956
- *
957
- * @example
958
- *
959
956
  */
960
957
  makeContentAddressedChunk(rawPayload, span) {
961
958
  return makeContentAddressedChunk(rawPayload, span);
@@ -1,11 +1,8 @@
1
1
  import { Types } from 'cafe-utility';
2
- import { Duration } from "../../utils/duration.js";
3
2
  import { http } from "../../utils/http.js";
4
- import { Size } from "../../utils/size.js";
5
- import { getStampEffectiveBytes, getStampTheoreticalBytes, getStampUsage } from "../../utils/stamps.js";
3
+ import { mapPostageBatch } from "../../utils/stamps.js";
6
4
  import { asNumberString } from "../../utils/type.js";
7
5
  import { BatchId, EthAddress } from "../../utils/typed-bytes.js";
8
- import { normalizeBatchTTL } from "../../utils/workaround.js";
9
6
  const STAMPS_ENDPOINT = 'stamps';
10
7
  const BATCHES_ENDPOINT = 'batches';
11
8
  export async function getGlobalPostageBatches(requestOptions) {
@@ -63,60 +60,7 @@ export async function getAllPostageBatches(requestOptions) {
63
60
  }).map(x => Types.asObject(x, {
64
61
  name: 'stamp'
65
62
  }));
66
- return stamps.map(x => {
67
- const utilization = Types.asNumber(x.utilization, {
68
- name: 'utilization'
69
- });
70
- const depth = Types.asNumber(x.depth, {
71
- name: 'depth'
72
- });
73
- const bucketDepth = Types.asNumber(x.bucketDepth, {
74
- name: 'bucketDepth'
75
- });
76
- const usage = getStampUsage(utilization, depth, bucketDepth);
77
- const batchTTL = normalizeBatchTTL(Types.asNumber(x.batchTTL, {
78
- name: 'batchTTL'
79
- }));
80
- const duration = Duration.fromSeconds(batchTTL);
81
- const effectiveBytes = getStampEffectiveBytes(depth);
82
- return {
83
- batchID: new BatchId(Types.asString(x.batchID, {
84
- name: 'batchID'
85
- })),
86
- utilization,
87
- usable: Types.asBoolean(x.usable, {
88
- name: 'usable'
89
- }),
90
- label: Types.asEmptiableString(x.label, {
91
- name: 'label'
92
- }),
93
- depth,
94
- amount: asNumberString(x.amount, {
95
- name: 'amount'
96
- }),
97
- bucketDepth,
98
- blockNumber: Types.asNumber(x.blockNumber, {
99
- name: 'blockNumber'
100
- }),
101
- immutableFlag: Types.asBoolean(x.immutableFlag, {
102
- name: 'immutableFlag'
103
- }),
104
- usage,
105
- usageText: `${Math.round(usage * 100)}%`,
106
- size: Size.fromBytes(effectiveBytes),
107
- remainingSize: Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage))),
108
- theoreticalSize: Size.fromBytes(getStampTheoreticalBytes(depth)),
109
- duration,
110
- calculateSize(encryption, redundancyLevel) {
111
- const effectiveBytes = getStampEffectiveBytes(this.depth, encryption, redundancyLevel);
112
- return Size.fromBytes(effectiveBytes);
113
- },
114
- calculateRemainingSize(encryption, redundancyLevel) {
115
- const effectiveBytes = getStampEffectiveBytes(this.depth, encryption, redundancyLevel);
116
- return Size.fromBytes(Math.ceil(effectiveBytes * (1 - this.usage)));
117
- }
118
- };
119
- });
63
+ return stamps.map(x => mapPostageBatch(validateRawPostageBatch(x)));
120
64
  }
121
65
  export async function getPostageBatch(requestOptions, postageBatchId, encryption, erasureCodeLevel) {
122
66
  const response = await http(requestOptions, {
@@ -127,58 +71,7 @@ export async function getPostageBatch(requestOptions, postageBatchId, encryption
127
71
  const body = Types.asObject(response.data, {
128
72
  name: 'response.data'
129
73
  });
130
- const utilization = Types.asNumber(body.utilization, {
131
- name: 'utilization'
132
- });
133
- const depth = Types.asNumber(body.depth, {
134
- name: 'depth'
135
- });
136
- const bucketDepth = Types.asNumber(body.bucketDepth, {
137
- name: 'bucketDepth'
138
- });
139
- const usage = getStampUsage(utilization, depth, bucketDepth);
140
- const batchTTL = normalizeBatchTTL(Types.asNumber(body.batchTTL, {
141
- name: 'batchTTL'
142
- }));
143
- const duration = Duration.fromSeconds(batchTTL);
144
- const effectiveBytes = getStampEffectiveBytes(depth, encryption, erasureCodeLevel);
145
- return {
146
- batchID: new BatchId(Types.asString(body.batchID, {
147
- name: 'batchID'
148
- })),
149
- utilization,
150
- usable: Types.asBoolean(body.usable, {
151
- name: 'usable'
152
- }),
153
- label: Types.asEmptiableString(body.label, {
154
- name: 'label'
155
- }),
156
- depth,
157
- amount: asNumberString(body.amount, {
158
- name: 'amount'
159
- }),
160
- bucketDepth,
161
- blockNumber: Types.asNumber(body.blockNumber, {
162
- name: 'blockNumber'
163
- }),
164
- immutableFlag: Types.asBoolean(body.immutableFlag, {
165
- name: 'immutableFlag'
166
- }),
167
- usage,
168
- usageText: `${Math.round(usage * 100)}%`,
169
- size: Size.fromBytes(effectiveBytes),
170
- remainingSize: Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage))),
171
- theoreticalSize: Size.fromBytes(getStampTheoreticalBytes(depth)),
172
- duration,
173
- calculateSize(encryption, redundancyLevel) {
174
- const effectiveBytes = getStampEffectiveBytes(depth, encryption, redundancyLevel);
175
- return Size.fromBytes(effectiveBytes);
176
- },
177
- calculateRemainingSize(encryption, redundancyLevel) {
178
- const effectiveBytes = getStampEffectiveBytes(depth, encryption, redundancyLevel);
179
- return Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage)));
180
- }
181
- };
74
+ return mapPostageBatch(validateRawPostageBatch(body), encryption, erasureCodeLevel);
182
75
  }
183
76
  export async function getPostageBatchBuckets(requestOptions, postageBatchId) {
184
77
  const response = await http(requestOptions, {
@@ -262,4 +155,38 @@ export async function diluteBatch(requestOptions, id, depth) {
262
155
  return new BatchId(Types.asString(body.batchID, {
263
156
  name: 'batchID'
264
157
  }));
158
+ }
159
+ function validateRawPostageBatch(raw) {
160
+ return {
161
+ amount: asNumberString(raw.amount, {
162
+ name: 'amount'
163
+ }),
164
+ batchID: Types.asString(raw.batchID, {
165
+ name: 'batchID'
166
+ }),
167
+ batchTTL: Types.asNumber(raw.batchTTL, {
168
+ name: 'batchTTL'
169
+ }),
170
+ bucketDepth: Types.asNumber(raw.bucketDepth, {
171
+ name: 'bucketDepth'
172
+ }),
173
+ blockNumber: Types.asNumber(raw.blockNumber, {
174
+ name: 'blockNumber'
175
+ }),
176
+ depth: Types.asNumber(raw.depth, {
177
+ name: 'depth'
178
+ }),
179
+ immutableFlag: Types.asBoolean(raw.immutableFlag, {
180
+ name: 'immutableFlag'
181
+ }),
182
+ label: Types.asEmptiableString(raw.label, {
183
+ name: 'label'
184
+ }),
185
+ usable: Types.asBoolean(raw.usable, {
186
+ name: 'usable'
187
+ }),
188
+ utilization: Types.asNumber(raw.utilization, {
189
+ name: 'utilization'
190
+ })
191
+ };
265
192
  }
@@ -30,6 +30,9 @@ export async function getReserveState(requestOptions) {
30
30
  }),
31
31
  storageRadius: Types.asNumber(body.storageRadius, {
32
32
  name: 'storageRadius'
33
+ }),
34
+ reserveCapacityDoubling: Types.asNumber(body.reserveCapacityDoubling, {
35
+ name: 'reserveCapacityDoubling'
33
36
  })
34
37
  };
35
38
  }
@@ -2,7 +2,7 @@ import { Types } from 'cafe-utility';
2
2
  import getMajorSemver from 'semver/functions/major.js';
3
3
  import { toBeeMode } from "../../types/debug.js";
4
4
  import { http } from "../../utils/http.js";
5
- export const SUPPORTED_BEE_VERSION_EXACT = '2.6.0-d0aa8b93';
5
+ export const SUPPORTED_BEE_VERSION_EXACT = '2.7.0-6ddf9b45';
6
6
  export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
7
7
  export const SUPPORTED_API_VERSION = '7.3.0';
8
8
  const NODE_INFO_URL = 'node';
@@ -2,4 +2,4 @@ export { getCollectionSize, makeCollectionFromFileList } from "./collection.js";
2
2
  export { getFolderSize } from "./collection.node.js";
3
3
  export { makeMaxTarget } from "./pss.js";
4
4
  export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from "./redundancy.js";
5
- export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage } from "./stamps.js";
5
+ export { convertEnvelopeToMarshaledStamp, getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage, mapPostageBatch, unmapPostageBatch } from "./stamps.js";
@@ -2,8 +2,11 @@ import { Binary } from 'cafe-utility';
2
2
  import { capacityBreakpoints } from "../types/index.js";
3
3
  import { Bytes, parseSizeToBytes } from "./bytes.js";
4
4
  import { Duration } from "./duration.js";
5
+ import { Size } from "./size.js";
5
6
  import { BZZ } from "./tokens.js";
6
7
  import { asNumberString } from "./type.js";
8
+ import { BatchId } from "./typed-bytes.js";
9
+ import { normalizeBatchTTL } from "./workaround.js";
7
10
  const MAX_UTILIZATION = 0.9;
8
11
  /**
9
12
  * Utility function that calculates usage of postage batch based on its utilization, depth and bucket depth.
@@ -137,4 +140,49 @@ export function marshalStamp(signature, batchId, timestamp, index) {
137
140
  throw Error('invalid index length');
138
141
  }
139
142
  return new Bytes(Binary.concatBytes(batchId, index, timestamp, signature));
143
+ }
144
+ export function mapPostageBatch(raw, encryption, erasureCodeLevel) {
145
+ const usage = getStampUsage(raw.utilization, raw.depth, raw.bucketDepth);
146
+ const batchTTL = normalizeBatchTTL(raw.batchTTL);
147
+ const duration = Duration.fromSeconds(batchTTL);
148
+ const effectiveBytes = getStampEffectiveBytes(raw.depth, encryption, erasureCodeLevel);
149
+ return {
150
+ batchID: new BatchId(raw.batchID),
151
+ utilization: raw.utilization,
152
+ usable: raw.usable,
153
+ label: raw.label,
154
+ depth: raw.depth,
155
+ amount: asNumberString(raw.amount),
156
+ bucketDepth: raw.bucketDepth,
157
+ blockNumber: raw.blockNumber,
158
+ immutableFlag: raw.immutableFlag,
159
+ usage,
160
+ usageText: `${Math.round(usage * 100)}%`,
161
+ size: Size.fromBytes(effectiveBytes),
162
+ remainingSize: Size.fromBytes(Math.ceil(effectiveBytes * (1 - usage))),
163
+ theoreticalSize: Size.fromBytes(getStampTheoreticalBytes(raw.depth)),
164
+ duration,
165
+ calculateSize(encryption, redundancyLevel) {
166
+ const effectiveBytes = getStampEffectiveBytes(raw.depth, encryption, redundancyLevel);
167
+ return Size.fromBytes(effectiveBytes);
168
+ },
169
+ calculateRemainingSize(encryption, redundancyLevel) {
170
+ const effectiveBytes = getStampEffectiveBytes(raw.depth, encryption, redundancyLevel);
171
+ return Size.fromBytes(Math.ceil(effectiveBytes * (1 - this.usage)));
172
+ }
173
+ };
174
+ }
175
+ export function unmapPostageBatch(batch) {
176
+ return {
177
+ batchID: batch.batchID.toHex(),
178
+ utilization: batch.utilization,
179
+ usable: batch.usable,
180
+ label: batch.label,
181
+ depth: batch.depth,
182
+ amount: batch.amount,
183
+ bucketDepth: batch.bucketDepth,
184
+ blockNumber: batch.blockNumber,
185
+ immutableFlag: batch.immutableFlag,
186
+ batchTTL: batch.duration.toSeconds()
187
+ };
140
188
  }
@@ -6,8 +6,11 @@ export function normalizeBatchTTL(batchTTL) {
6
6
  if (batchTTL < 1) {
7
7
  return 1;
8
8
  }
9
- if (batchTTL > 315569260) {
10
- return 315569260;
9
+ // Cap `batchTTL` (represents seconds) to 100 years.
10
+ // We can assume `storagePrice` is invalid (e.g. 1).
11
+ // This is needed to prevent Date objects breaking.
12
+ if (batchTTL > 3155695200) {
13
+ return 3155695200;
11
14
  }
12
15
  return batchTTL;
13
16
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable } from 'stream';
3
2
  import { Chunk } from './chunk/cac';
4
3
  import { SingleOwnerChunk } from './chunk/soc';
@@ -618,9 +617,6 @@ export declare class Bee {
618
617
  *
619
618
  * @param rawPayload Data to be stored in the chunk. If the data is a string, it will be converted to UTF-8 bytes.
620
619
  * @param span Optional span for the chunk. If not provided, it will be set to the length of the payload.
621
- *
622
- * @example
623
- *
624
620
  */
625
621
  makeContentAddressedChunk(rawPayload: Bytes | Uint8Array | string, span?: Span | bigint): Chunk;
626
622
  /**
@@ -2,8 +2,8 @@ import { Bee } from './bee';
2
2
  import { BeeDev } from './bee-dev';
3
3
  import { Stamper } from './stamper/stamper';
4
4
  export { MerkleTree } from 'cafe-utility';
5
- export { Chunk } from './chunk/cac';
6
- export { SingleOwnerChunk } from './chunk/soc';
5
+ export type { Chunk } from './chunk/cac';
6
+ export type { SingleOwnerChunk } from './chunk/soc';
7
7
  export { MantarayNode } from './manifest/manifest';
8
8
  export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from './modules/debug/status';
9
9
  export * from './types';
@@ -15,6 +15,7 @@ export * as Utils from './utils/expose';
15
15
  export { Size } from './utils/size';
16
16
  export * from './utils/tokens';
17
17
  export * from './utils/typed-bytes';
18
+ export type { UploadProgress } from './utils/upload-progress';
18
19
  export { Bee, BeeDev, Stamper };
19
20
  declare global {
20
21
  interface Window {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable } from 'stream';
3
2
  import { BeeRequestOptions, Collection, CollectionUploadOptions, DownloadOptions, FileData, FileUploadOptions, UploadResult } from '../types';
4
3
  import { Bytes } from '../utils/bytes';
@@ -1,7 +1,7 @@
1
1
  import { BeeRequestOptions } from '../../index';
2
2
  import type { DebugStatus, Health, NodeInfo, Readiness } from '../../types/debug';
3
3
  import { BeeVersions } from '../../types/debug';
4
- export declare const SUPPORTED_BEE_VERSION_EXACT = "2.6.0-d0aa8b93";
4
+ export declare const SUPPORTED_BEE_VERSION_EXACT = "2.7.0-6ddf9b45";
5
5
  export declare const SUPPORTED_BEE_VERSION: string;
6
6
  export declare const SUPPORTED_API_VERSION = "7.3.0";
7
7
  export declare function getDebugStatus(requestOptions: BeeRequestOptions): Promise<DebugStatus>;
@@ -1,4 +1,3 @@
1
- /// <reference types="ws" />
2
1
  import WebSocket from 'isomorphic-ws';
3
2
  import { BeeRequestOptions, UploadOptions } from '..';
4
3
  import { SingleOwnerChunk } from '../chunk/soc';
@@ -1,4 +1,3 @@
1
- /// <reference types="ws" />
2
1
  import WebSocket from 'isomorphic-ws';
3
2
  import type { BeeRequestOptions } from '../types';
4
3
  import { BatchId, PublicKey, Topic } from '../utils/typed-bytes';
@@ -212,6 +212,7 @@ export interface ReserveState {
212
212
  radius: number;
213
213
  storageRadius: number;
214
214
  commitment: number;
215
+ reserveCapacityDoubling: number;
215
216
  }
216
217
  export interface ChainState {
217
218
  chainTip: number;
@@ -2,6 +2,6 @@ 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;
5
+ export declare const NULL_ADDRESS: Uint8Array<ArrayBuffer>;
6
+ export declare const NULL_IDENTIFIER: Uint8Array<ArrayBuffer>;
7
+ export declare const NULL_OWNER: Uint8Array<ArrayBuffer>;
@@ -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?: unknown;
11
+ responseBody?: unknown | undefined;
12
12
  status?: number | undefined;
13
13
  statusText?: string | undefined;
14
- constructor(method: string, url: string, message: string, responseBody?: unknown, status?: number | undefined, statusText?: string | undefined);
14
+ constructor(method: string, url: string, message: string, responseBody?: unknown | undefined, status?: number | undefined, statusText?: string | undefined);
15
15
  }
@@ -2,4 +2,4 @@ export { getCollectionSize, makeCollectionFromFileList } from './collection';
2
2
  export { getFolderSize } from './collection.node';
3
3
  export { makeMaxTarget } from './pss';
4
4
  export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy';
5
- export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage, } from './stamps';
5
+ export { convertEnvelopeToMarshaledStamp, getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage, mapPostageBatch, unmapPostageBatch, } from './stamps';
@@ -1,4 +1,4 @@
1
- import { EnvelopeWithBatchId, NumberString, RedundancyLevel } from '../types';
1
+ import { EnvelopeWithBatchId, NumberString, PostageBatch, RedundancyLevel } from '../types';
2
2
  import { Bytes } from './bytes';
3
3
  import { Duration } from './duration';
4
4
  import { Size } from './size';
@@ -58,3 +58,17 @@ export declare function getAmountForDuration(duration: Duration, pricePerBlock:
58
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;
61
+ export interface RawPostageBatch {
62
+ batchID: string;
63
+ utilization: number;
64
+ usable: boolean;
65
+ label: string;
66
+ depth: number;
67
+ amount: string;
68
+ bucketDepth: number;
69
+ blockNumber: number;
70
+ immutableFlag: boolean;
71
+ batchTTL: number;
72
+ }
73
+ export declare function mapPostageBatch(raw: RawPostageBatch, encryption?: boolean, erasureCodeLevel?: RedundancyLevel): PostageBatch;
74
+ export declare function unmapPostageBatch(batch: PostageBatch): RawPostageBatch;
@@ -1,7 +1,7 @@
1
1
  export declare class TarStream {
2
2
  pieces: Uint8Array[];
3
3
  currentFileSize: number;
4
- get output(): Uint8Array;
4
+ get output(): Uint8Array<ArrayBufferLike>;
5
5
  beginFile(path: string, size: number): void;
6
6
  appendFile(data: Uint8Array): Promise<void>;
7
7
  endFile(): Promise<void>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PassThrough } from 'stream';
3
2
  export declare class TarStream {
4
3
  output: PassThrough;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import * as stream from 'stream';
3
2
  import { AllTagsOptions, BeeRequestOptions, CollectionUploadOptions, DownloadOptions, FileUploadOptions, GsocMessageHandler, NumberString, PostageBatchOptions, PssMessageHandler, RedundantUploadOptions, Tag, TransactionOptions, UploadOptions } from '../types';
4
3
  export declare function isReadable(value: unknown): value is stream.Readable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "10.3.0",
3
+ "version": "11.0.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -50,18 +50,18 @@
50
50
  "dist"
51
51
  ],
52
52
  "scripts": {
53
- "prepublishOnly": "cross-env NODE_ENV=production npm run build",
53
+ "prepublishOnly": "NODE_ENV=production npm run build",
54
54
  "build": "rimraf dist && npm run build:node && npm run build:types && npm run build:browser",
55
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/",
56
56
  "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
57
57
  "build:browser": "webpack --progress",
58
- "test": "jest --config=jest.config.ts --runInBand --verbose --forceExit",
58
+ "test": "TS_NODE_PROJECT=tsconfig.test.json jest --runInBand --verbose --forceExit",
59
59
  "check": "tsc --project tsconfig.test.json",
60
60
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\" && prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
61
61
  "depcheck": "depcheck ."
62
62
  },
63
63
  "dependencies": {
64
- "axios": "^0.30.0",
64
+ "axios": "^0.30.2",
65
65
  "cafe-utility": "^33.3.4",
66
66
  "debug": "^4.4.1",
67
67
  "isomorphic-ws": "^4.0.1",
@@ -77,10 +77,8 @@
77
77
  "@babel/preset-typescript": "^7.18.6",
78
78
  "@commitlint/cli": "^17.0.2",
79
79
  "@commitlint/config-conventional": "^17.4.2",
80
- "@jest/types": "^29.6.3",
81
- "@naholyr/cross-env": "^1.0.0",
82
80
  "@types/debug": "^4.1.12",
83
- "@types/jest": "^29.5.13",
81
+ "@types/jest": "^30.0.0",
84
82
  "@types/node": "^18.11.11",
85
83
  "@types/semver": "^7.3.9",
86
84
  "@types/ws": "^8.5.3",
@@ -88,20 +86,19 @@
88
86
  "@typescript-eslint/parser": "^5.46.0",
89
87
  "babel-loader": "^9.1.0",
90
88
  "babel-plugin-add-import-extension": "^1.6.0",
91
- "cross-env": "^7.0.3",
92
89
  "depcheck": "^1.4.7",
93
90
  "eslint": "^8.13.0",
94
91
  "eslint-config-prettier": "^8.5.0",
95
92
  "eslint-plugin-prettier": "^4.0.0",
96
93
  "eslint-plugin-unused-imports": "^2.0.0",
97
94
  "husky": "^8.0.1",
98
- "jest": "^29.7.0",
95
+ "jest": "^30.2.0",
99
96
  "prettier": "^2.6.2",
100
97
  "rimraf": "^3.0.2",
101
98
  "terser-webpack-plugin": "^5.3.1",
102
- "ts-jest": "^29.2.5",
103
- "ts-node": "^10.9.1",
104
- "typescript": "^4.9.5",
99
+ "ts-jest": "^29.4.6",
100
+ "ts-node": "^10.9.2",
101
+ "typescript": "^5.9.3",
105
102
  "webpack": "^5.75.0",
106
103
  "webpack-cli": "^5.0.1"
107
104
  }