@ethersphere/bee-js 13.1.0 → 13.1.1-upcoming.g29c89d7
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 -0
- 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 -0
- package/dist/mjs/utils/error.js +3 -0
- package/dist/mjs/utils/http.js +17 -8
- package/package.json +2 -2
|
@@ -43,6 +43,7 @@ async function loadRecursively(node, bee, options, requestOptions) {
|
|
|
43
43
|
const loaded = CoreMantarayNode.unmarshalFromData(data, fork.node.selfAddress);
|
|
44
44
|
fork.node.targetAddress = loaded.targetAddress;
|
|
45
45
|
fork.node.forks = loaded.forks;
|
|
46
|
+
fork.node.obfuscationKey = loaded.obfuscationKey;
|
|
46
47
|
fork.node.path = fork.prefix;
|
|
47
48
|
fork.node.parent = node;
|
|
48
49
|
await loadRecursively(fork.node, bee, options, requestOptions);
|
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') {
|
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.g29c89d7",
|
|
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.1",
|
|
79
79
|
"ws": "^8.21.0",
|
|
80
80
|
"zod": "^4.4.3"
|
|
81
81
|
},
|