@ethersphere/bee-js 13.1.0 → 13.1.1-upcoming.g157b172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/cjs/manifest/manifest.js +1 -3
- package/dist/cjs/modules/chequebook.js +2 -2
- package/dist/cjs/utils/error.js +3 -0
- package/dist/cjs/utils/http.js +18 -6
- package/dist/codemod/transforms/v13.js +25 -16
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/manifest/manifest.js +1 -3
- package/dist/mjs/modules/chequebook.js +2 -2
- package/dist/mjs/utils/error.js +3 -0
- package/dist/mjs/utils/http.js +17 -8
- package/dist/types/api/chunk.d.ts +2 -2
- package/dist/types/api/soc.d.ts +2 -2
- package/dist/types/chunk/soc.d.ts +4 -4
- package/dist/types/modules/chunk.d.ts +2 -2
- package/dist/types/modules/messaging.d.ts +2 -2
- package/dist/types/types/index.d.ts +7 -1
- package/package.json +2 -2
|
@@ -40,9 +40,7 @@ async function loadRecursively(node, bee, options, requestOptions) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
const data = (await bee.data.download(fork.node.selfAddress, downloadOptions, requestOptions)).toUint8Array();
|
|
43
|
-
|
|
44
|
-
fork.node.targetAddress = loaded.targetAddress;
|
|
45
|
-
fork.node.forks = loaded.forks;
|
|
43
|
+
fork.node.hydrate(data);
|
|
46
44
|
fork.node.path = fork.prefix;
|
|
47
45
|
fork.node.parent = node;
|
|
48
46
|
await loadRecursively(fork.node, bee, options, requestOptions);
|
|
@@ -38,7 +38,7 @@ export class Chequebook {
|
|
|
38
38
|
min: 1n,
|
|
39
39
|
name: 'amount'
|
|
40
40
|
});
|
|
41
|
-
const gasPriceString = gasPrice ? asNumberString(
|
|
41
|
+
const gasPriceString = gasPrice ? asNumberString(gasPrice, {
|
|
42
42
|
min: 0n,
|
|
43
43
|
name: 'gasPrice'
|
|
44
44
|
}) : undefined;
|
|
@@ -56,7 +56,7 @@ export class Chequebook {
|
|
|
56
56
|
min: 1n,
|
|
57
57
|
name: 'amount'
|
|
58
58
|
});
|
|
59
|
-
const gasPriceString = gasPrice ? asNumberString(
|
|
59
|
+
const gasPriceString = gasPrice ? asNumberString(gasPrice, {
|
|
60
60
|
min: 0n,
|
|
61
61
|
name: 'gasPrice'
|
|
62
62
|
}) : undefined;
|
package/dist/mjs/utils/error.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export class BeeError extends Error {
|
|
2
2
|
constructor(message) {
|
|
3
3
|
super(message);
|
|
4
|
+
this.name = 'BeeError';
|
|
4
5
|
}
|
|
5
6
|
}
|
|
6
7
|
export class BeeArgumentError extends BeeError {
|
|
7
8
|
constructor(message, value) {
|
|
8
9
|
super(message);
|
|
9
10
|
this.value = value;
|
|
11
|
+
this.name = 'BeeArgumentError';
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
export class BeeResponseError extends BeeError {
|
|
@@ -17,6 +19,7 @@ export class BeeResponseError extends BeeError {
|
|
|
17
19
|
this.responseBody = responseBody;
|
|
18
20
|
this.status = status;
|
|
19
21
|
this.statusText = statusText;
|
|
22
|
+
this.name = 'BeeResponseError';
|
|
20
23
|
this.response = {
|
|
21
24
|
status,
|
|
22
25
|
data: responseBody,
|
package/dist/mjs/utils/http.js
CHANGED
|
@@ -51,7 +51,7 @@ export async function http(options, config) {
|
|
|
51
51
|
params: requestConfig.params
|
|
52
52
|
});
|
|
53
53
|
const res = await fetch(url, requestConfig);
|
|
54
|
-
if (!res.ok) await throwHttpError(method, url, res
|
|
54
|
+
if (!res.ok) await throwHttpError(method, url, res);
|
|
55
55
|
return toBeeResponse(res, requestConfig.responseType);
|
|
56
56
|
} catch (e) {
|
|
57
57
|
if (e instanceof BeeResponseError) throw e;
|
|
@@ -86,13 +86,22 @@ function attachBody(config) {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
async function throwHttpError(method, url, res
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
async function throwHttpError(method, url, res) {
|
|
90
|
+
const data = await readErrorBody(res);
|
|
91
|
+
const bodyMsg = typeof data === 'string' ? data : JSON.stringify(data);
|
|
92
|
+
const message = bodyMsg ? `${res.statusText}: ${bodyMsg}` : res.statusText;
|
|
93
|
+
throw new BeeResponseError(method, url, message, data, res.status, res.statusText);
|
|
94
|
+
}
|
|
95
|
+
async function readErrorBody(res) {
|
|
96
|
+
const raw = await res.text().catch(() => '');
|
|
97
|
+
if (!raw) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
return JSON.parse(raw);
|
|
102
|
+
} catch {
|
|
103
|
+
return raw;
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
106
|
function toBeeError(err, method, url) {
|
|
98
107
|
if (err.name === 'AbortError') {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BatchId, Reference } from '@ethersphere/core-sdk';
|
|
2
|
-
import type { BeeRequestOptions, DownloadOptions, EnvelopeWithBatchId,
|
|
2
|
+
import type { BeeRequestOptions, ChunkUploadOptions, DownloadOptions, EnvelopeWithBatchId, UploadResult } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Raw HTTP calls for the `/chunks` endpoint.
|
|
5
5
|
*/
|
|
6
|
-
export declare function upload(requestOptions: BeeRequestOptions, data: Uint8Array, stamp: EnvelopeWithBatchId | BatchId | Uint8Array | string, options?:
|
|
6
|
+
export declare function upload(requestOptions: BeeRequestOptions, data: Uint8Array, stamp: EnvelopeWithBatchId | BatchId | Uint8Array | string, options?: ChunkUploadOptions): Promise<UploadResult>;
|
|
7
7
|
export declare function download(requestOptions: BeeRequestOptions, reference: Reference | string | Uint8Array, options?: DownloadOptions): Promise<Uint8Array>;
|
package/dist/types/api/soc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BatchId, EthAddress, Identifier, Signature } from '@ethersphere/core-sdk';
|
|
2
|
-
import type { BeeRequestOptions,
|
|
2
|
+
import type { BeeRequestOptions, ChunkUploadOptions, UploadResult } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Raw HTTP calls for the `/soc` endpoint.
|
|
5
5
|
*/
|
|
6
|
-
export declare function upload(requestOptions: BeeRequestOptions, owner: EthAddress, identifier: Identifier, signature: Signature, data: Uint8Array, stamp: BatchId | Uint8Array | string, options?:
|
|
6
|
+
export declare function upload(requestOptions: BeeRequestOptions, owner: EthAddress, identifier: Identifier, signature: Signature, data: Uint8Array, stamp: BatchId | Uint8Array | string, options?: ChunkUploadOptions): Promise<UploadResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BatchId, Bytes, Chunk, EthAddress, Identifier, PrivateKey, Reference, SingleOwnerChunk, Span, makeSOCAddress } from '@ethersphere/core-sdk';
|
|
2
|
-
import { BeeRequestOptions,
|
|
2
|
+
import { BeeRequestOptions, ChunkUploadOptions, UploadResult } from '../types';
|
|
3
3
|
export { makeSOCAddress };
|
|
4
4
|
export type { SingleOwnerChunk };
|
|
5
5
|
/**
|
|
@@ -30,7 +30,7 @@ export declare function makeSingleOwnerChunk(address: Reference, span: Span, pay
|
|
|
30
30
|
* @param stamp Postage BatchId that will be assigned to uploaded data
|
|
31
31
|
* @param options Upload options
|
|
32
32
|
*/
|
|
33
|
-
export declare function uploadSingleOwnerChunk(requestOptions: BeeRequestOptions, chunk: SingleOwnerChunk, stamp: BatchId | Uint8Array | string, options?:
|
|
33
|
+
export declare function uploadSingleOwnerChunk(requestOptions: BeeRequestOptions, chunk: SingleOwnerChunk, stamp: BatchId | Uint8Array | string, options?: ChunkUploadOptions): Promise<UploadResult>;
|
|
34
34
|
/**
|
|
35
35
|
* Helper function to create and upload SOC.
|
|
36
36
|
*
|
|
@@ -41,8 +41,8 @@ export declare function uploadSingleOwnerChunk(requestOptions: BeeRequestOptions
|
|
|
41
41
|
* @param data The chunk data
|
|
42
42
|
* @param options
|
|
43
43
|
*/
|
|
44
|
-
export declare function uploadSingleOwnerChunkData(requestOptions: BeeRequestOptions, signer: PrivateKey | Uint8Array | string, stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: Uint8Array, options?:
|
|
45
|
-
export declare function uploadSingleOwnerChunkWithWrappedChunk(requestOptions: BeeRequestOptions, signer: PrivateKey | Uint8Array | string, stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, wrappedChunk: Chunk, options?:
|
|
44
|
+
export declare function uploadSingleOwnerChunkData(requestOptions: BeeRequestOptions, signer: PrivateKey | Uint8Array | string, stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: Uint8Array, options?: ChunkUploadOptions): Promise<UploadResult>;
|
|
45
|
+
export declare function uploadSingleOwnerChunkWithWrappedChunk(requestOptions: BeeRequestOptions, signer: PrivateKey | Uint8Array | string, stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, wrappedChunk: Chunk, options?: ChunkUploadOptions): Promise<UploadResult>;
|
|
46
46
|
/**
|
|
47
47
|
* Helper function to download SOC.
|
|
48
48
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BatchId, Chunk as ContentAddressedChunk, Reference } from '@ethersphere/core-sdk';
|
|
2
2
|
import { SingleOwnerChunk } from '../chunk/soc';
|
|
3
|
-
import type { BeeRequestOptions, DownloadOptions, EnvelopeWithBatchId
|
|
3
|
+
import type { BeeRequestOptions, ChunkUploadOptions, DownloadOptions, EnvelopeWithBatchId } from '../types';
|
|
4
4
|
import { UploadResult } from '../types';
|
|
5
5
|
import type { BeeContext } from './context';
|
|
6
6
|
/**
|
|
@@ -21,7 +21,7 @@ export declare class Chunk {
|
|
|
21
21
|
* @param options Additional options like tag, encryption, pinning, content-type and request options
|
|
22
22
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
23
23
|
*/
|
|
24
|
-
upload(stamp: EnvelopeWithBatchId | BatchId | Uint8Array | string, data: Uint8Array | ContentAddressedChunk | SingleOwnerChunk, options?:
|
|
24
|
+
upload(stamp: EnvelopeWithBatchId | BatchId | Uint8Array | string, data: Uint8Array | ContentAddressedChunk | SingleOwnerChunk, options?: ChunkUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>;
|
|
25
25
|
/**
|
|
26
26
|
* Downloads a chunk as a `Uint8Array`.
|
|
27
27
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BatchId, Bytes, EthAddress, Identifier, PeerAddress, PrivateKey, PublicKey, Topic } from '@ethersphere/core-sdk';
|
|
2
|
-
import type { BeeRequestOptions, GsocMessageHandler, GsocSubscription, PssMessageHandler, PssSubscription
|
|
2
|
+
import type { BeeRequestOptions, ChunkUploadOptions, GsocMessageHandler, GsocSubscription, PssMessageHandler, PssSubscription } from '../types';
|
|
3
3
|
import type { BeeContext } from './context';
|
|
4
4
|
/**
|
|
5
5
|
* Messaging protocols — PSS (Postal Service for Swarm) and GSOC. Method names keep
|
|
@@ -61,7 +61,7 @@ export declare class Messaging {
|
|
|
61
61
|
* @param options
|
|
62
62
|
* @param requestOptions Options for making requests, such as timeouts, custom HTTP agents, headers, etc.
|
|
63
63
|
*/
|
|
64
|
-
gsocSend(postageBatchId: BatchId | Uint8Array | string, signer: PrivateKey | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: string | Uint8Array, options?:
|
|
64
|
+
gsocSend(postageBatchId: BatchId | Uint8Array | string, signer: PrivateKey | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: string | Uint8Array, options?: ChunkUploadOptions, requestOptions?: BeeRequestOptions): Promise<import("../types").UploadResult>;
|
|
65
65
|
/**
|
|
66
66
|
* Subscribes to GSOC messages for the specified owner (of the signer) and identifier.
|
|
67
67
|
*
|
|
@@ -137,6 +137,12 @@ export interface UploadOptions {
|
|
|
137
137
|
*/
|
|
138
138
|
deferred?: boolean;
|
|
139
139
|
}
|
|
140
|
+
export interface ChunkUploadOptions extends Omit<UploadOptions, 'act' | 'actHistoryAddress'> {
|
|
141
|
+
/** @deprecated Bee ignores ACT on `/chunks` and `/soc`; this option will be removed. */
|
|
142
|
+
act?: boolean;
|
|
143
|
+
/** @deprecated Bee ignores ACT on `/chunks` and `/soc`; this option will be removed. */
|
|
144
|
+
actHistoryAddress?: Reference | Uint8Array | string;
|
|
145
|
+
}
|
|
140
146
|
/**
|
|
141
147
|
* Add redundancy to the data being uploaded so that downloaders can download it with better UX.
|
|
142
148
|
* 0 value is default and does not add any redundancy to the file.
|
|
@@ -396,7 +402,7 @@ export interface SOCWriter extends SOCReader {
|
|
|
396
402
|
* @param data The chunk payload data
|
|
397
403
|
* @param options Upload options
|
|
398
404
|
*/
|
|
399
|
-
upload: (stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: Uint8Array, options?:
|
|
405
|
+
upload: (stamp: BatchId | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: Uint8Array, options?: ChunkUploadOptions) => Promise<UploadResult>;
|
|
400
406
|
}
|
|
401
407
|
export interface GlobalPostageBatch {
|
|
402
408
|
batchID: BatchId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.1-upcoming.g157b172",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"debug": "^4.4.3",
|
|
76
76
|
"isomorphic-ws": "^5.0.0",
|
|
77
77
|
"semver": "^7.3.5",
|
|
78
|
-
"@ethersphere/core-sdk": "^0.
|
|
78
|
+
"@ethersphere/core-sdk": "^0.2.2",
|
|
79
79
|
"ws": "^8.21.0",
|
|
80
80
|
"zod": "^4.4.3"
|
|
81
81
|
},
|