@ethersphere/bee-js 12.3.1 → 12.3.2-upcoming.116
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/dist/cjs/index.js +3 -3
- package/dist/cjs/manifest/manifest.js +43 -15
- package/dist/cjs/modules/debug/status.js +5 -8
- package/dist/cjs/version.js +11 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/index.js +1 -1
- package/dist/mjs/manifest/manifest.js +43 -11
- package/dist/mjs/modules/debug/status.js +1 -3
- package/dist/mjs/version.js +8 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/manifest/manifest.d.ts +2 -0
- package/dist/types/modules/debug/status.d.ts +0 -3
- package/dist/types/version.d.ts +6 -0
- package/package.json +7 -5
package/dist/mjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Bee } from "./bee.js";
|
|
|
2
2
|
import { Stamper } from "./stamper/stamper.js";
|
|
3
3
|
export { MerkleTree } from 'cafe-utility';
|
|
4
4
|
export { MantarayNode } from "./manifest/manifest.js";
|
|
5
|
-
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./
|
|
5
|
+
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "./version.js";
|
|
6
6
|
export * from "./types/index.js";
|
|
7
7
|
export { Bytes } from "./utils/bytes.js";
|
|
8
8
|
export * from "./utils/constants.js";
|
|
@@ -55,7 +55,10 @@ export class Fork {
|
|
|
55
55
|
throw Error('Fork#marshal node.selfAddress is not set');
|
|
56
56
|
}
|
|
57
57
|
const data = [];
|
|
58
|
-
|
|
58
|
+
// Re-emit the type byte read from the chunk when the node is untouched, so an
|
|
59
|
+
// unmarshal → marshal round-trip is byte-identical. determineType() can only
|
|
60
|
+
// recompute it correctly once the node's children are loaded/built in memory.
|
|
61
|
+
data.push(new Uint8Array([this.node.type ?? this.node.determineType()]));
|
|
59
62
|
data.push(Binary.numberToUint8(this.prefix.length));
|
|
60
63
|
data.push(this.prefix);
|
|
61
64
|
if (this.prefix.length < 30) {
|
|
@@ -98,7 +101,8 @@ export class Fork {
|
|
|
98
101
|
return new Fork(prefix, new MantarayNode({
|
|
99
102
|
selfAddress,
|
|
100
103
|
metadata,
|
|
101
|
-
path: prefix
|
|
104
|
+
path: prefix,
|
|
105
|
+
type
|
|
102
106
|
}));
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -111,6 +115,7 @@ export class MantarayNode {
|
|
|
111
115
|
this.path = new Uint8Array(0);
|
|
112
116
|
this.forks = new Map();
|
|
113
117
|
this.parent = null;
|
|
118
|
+
this.type = null;
|
|
114
119
|
if (options?.targetAddress) {
|
|
115
120
|
this.targetAddress = options.targetAddress;
|
|
116
121
|
}
|
|
@@ -129,6 +134,7 @@ export class MantarayNode {
|
|
|
129
134
|
if (options?.parent) {
|
|
130
135
|
this.parent = options.parent;
|
|
131
136
|
}
|
|
137
|
+
this.type = options?.type ?? null;
|
|
132
138
|
}
|
|
133
139
|
get fullPath() {
|
|
134
140
|
return Binary.concatBytes(this.parent?.fullPath ?? new Uint8Array(0), this.path);
|
|
@@ -186,9 +192,22 @@ export class MantarayNode {
|
|
|
186
192
|
fork.node.selfAddress = (await fork.node.calculateSelfAddress()).toUint8Array();
|
|
187
193
|
}
|
|
188
194
|
}
|
|
195
|
+
const hasEntry = !Binary.equals(this.targetAddress, NULL_ADDRESS);
|
|
196
|
+
let refBytesSize = 0;
|
|
197
|
+
if (hasEntry) {
|
|
198
|
+
refBytesSize = this.targetAddress.length;
|
|
199
|
+
} else {
|
|
200
|
+
for (const fork of this.forks.values()) {
|
|
201
|
+
if (fork.node.selfAddress) {
|
|
202
|
+
refBytesSize = fork.node.selfAddress.length;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
189
207
|
const header = new Uint8Array(32);
|
|
190
208
|
header.set(VERSION_02_HASH, 0);
|
|
191
|
-
header.set(Binary.
|
|
209
|
+
header.set(Binary.numberToUint8(refBytesSize), 31);
|
|
210
|
+
const entry = hasEntry ? this.targetAddress : new Uint8Array(refBytesSize);
|
|
192
211
|
const forkBitmap = new Uint8Array(32);
|
|
193
212
|
for (const fork of this.forks.keys()) {
|
|
194
213
|
Binary.setBit(forkBitmap, fork, 1, 'LE');
|
|
@@ -199,7 +218,7 @@ export class MantarayNode {
|
|
|
199
218
|
forks.push(this.forks.get(i).marshal());
|
|
200
219
|
}
|
|
201
220
|
}
|
|
202
|
-
const data = Binary.xorCypher(Binary.concatBytes(header,
|
|
221
|
+
const data = Binary.xorCypher(Binary.concatBytes(header, entry, forkBitmap, ...forks), this.obfuscationKey);
|
|
203
222
|
return Binary.concatBytes(this.obfuscationKey, data);
|
|
204
223
|
}
|
|
205
224
|
/**
|
|
@@ -233,11 +252,13 @@ export class MantarayNode {
|
|
|
233
252
|
obfuscationKey
|
|
234
253
|
});
|
|
235
254
|
const forkBitmap = reader.read(32);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
255
|
+
if (targetAddressLength > 0) {
|
|
256
|
+
for (let i = 0; i < 256; i++) {
|
|
257
|
+
if (Binary.getBit(forkBitmap, i, 'LE')) {
|
|
258
|
+
const newFork = Fork.unmarshal(reader, selfAddress.length);
|
|
259
|
+
node.forks.set(i, newFork);
|
|
260
|
+
newFork.node.parent = node;
|
|
261
|
+
}
|
|
241
262
|
}
|
|
242
263
|
}
|
|
243
264
|
return node;
|
|
@@ -247,6 +268,7 @@ export class MantarayNode {
|
|
|
247
268
|
*/
|
|
248
269
|
addFork(path, reference, metadata) {
|
|
249
270
|
this.selfAddress = null;
|
|
271
|
+
this.type = null;
|
|
250
272
|
path = path instanceof Uint8Array ? path : ENCODER.encode(path);
|
|
251
273
|
debug('adding fork', {
|
|
252
274
|
path: DECODER.decode(path),
|
|
@@ -278,11 +300,13 @@ export class MantarayNode {
|
|
|
278
300
|
tip.forks.set(remainingPath[0], fork);
|
|
279
301
|
fork.node.parent = tip;
|
|
280
302
|
tip.selfAddress = null;
|
|
303
|
+
tip.type = null;
|
|
281
304
|
tip = newFork.node;
|
|
282
305
|
} else {
|
|
283
306
|
tip.forks.set(remainingPath[0], newFork);
|
|
284
307
|
newFork.node.parent = tip;
|
|
285
308
|
tip.selfAddress = null;
|
|
309
|
+
tip.type = null;
|
|
286
310
|
tip = newFork.node;
|
|
287
311
|
}
|
|
288
312
|
}
|
|
@@ -292,6 +316,7 @@ export class MantarayNode {
|
|
|
292
316
|
*/
|
|
293
317
|
removeFork(path) {
|
|
294
318
|
this.selfAddress = null;
|
|
319
|
+
this.type = null;
|
|
295
320
|
path = path instanceof Uint8Array ? path : ENCODER.encode(path);
|
|
296
321
|
if (path.length === 0) {
|
|
297
322
|
throw Error('MantarayNode#removeFork [path] parameter cannot be empty');
|
|
@@ -409,13 +434,20 @@ export class MantarayNode {
|
|
|
409
434
|
}
|
|
410
435
|
determineType() {
|
|
411
436
|
let type = 0;
|
|
412
|
-
|
|
437
|
+
// Mirror Bee (pkg/manifest/mantaray/node.go): Add() marks every explicitly
|
|
438
|
+
// added leaf as a value (makeValue), even one with a null entry such as a
|
|
439
|
+
// metadata-only "/" node. In final-state terms a leaf (no forks) is always an
|
|
440
|
+
// added entry, so it is a value; a node with forks is a value only when it also
|
|
441
|
+
// carries an entry. The path-separator flag is set only when a separator occurs
|
|
442
|
+
// past the first byte (IndexRune > 0), so a prefix that merely starts with '/'
|
|
443
|
+
// does not qualify.
|
|
444
|
+
if (!Binary.equals(this.targetAddress, NULL_ADDRESS) || this.forks.size === 0) {
|
|
413
445
|
type |= TYPE_VALUE;
|
|
414
446
|
}
|
|
415
447
|
if (this.forks.size > 0) {
|
|
416
448
|
type |= TYPE_EDGE;
|
|
417
449
|
}
|
|
418
|
-
if (Binary.indexOf(this.path, PATH_SEPARATOR)
|
|
450
|
+
if (Binary.indexOf(this.path, PATH_SEPARATOR) > 0) {
|
|
419
451
|
type |= TYPE_WITH_PATH_SEPARATOR;
|
|
420
452
|
}
|
|
421
453
|
if (this.metadata) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import getMajorSemver from 'semver/functions/major.js';
|
|
2
2
|
import { GetDebugStatusResponse, GetHealthResponse, GetNodeInfoResponse, GetReadinessResponse } from "../../types/schema/status.js";
|
|
3
3
|
import { http } from "../../utils/http.js";
|
|
4
|
-
|
|
5
|
-
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
|
|
6
|
-
export const SUPPORTED_API_VERSION = '8.1.0';
|
|
4
|
+
import { SUPPORTED_API_VERSION, SUPPORTED_BEE_VERSION_EXACT } from "../../version.js";
|
|
7
5
|
const NODE_INFO_URL = 'node';
|
|
8
6
|
const STATUS_URL = 'status';
|
|
9
7
|
const HEALTH_URL = 'health';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// AUTO-GENERATED from package.json "engines" by scripts/generate-version.cjs — do not edit by hand.
|
|
2
|
+
// Run `npm run generate:version` to regenerate.
|
|
3
|
+
/** Exact supported Bee version, including the commit hash suffix. */
|
|
4
|
+
export const SUPPORTED_BEE_VERSION_EXACT = '2.8.1-7cf53193';
|
|
5
|
+
/** Supported Bee version without the commit hash suffix. */
|
|
6
|
+
export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
|
|
7
|
+
/** Supported Bee API version. */
|
|
8
|
+
export const SUPPORTED_API_VERSION = '8.1.0';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { MerkleTree } from 'cafe-utility';
|
|
|
4
4
|
export type { Chunk } from './chunk/cac';
|
|
5
5
|
export type { SingleOwnerChunk } from './chunk/soc';
|
|
6
6
|
export { MantarayNode } from './manifest/manifest';
|
|
7
|
-
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from './
|
|
7
|
+
export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from './version';
|
|
8
8
|
export * from './types';
|
|
9
9
|
export { Bytes } from './utils/bytes';
|
|
10
10
|
export * from './utils/constants';
|
|
@@ -18,6 +18,7 @@ interface MantarayNodeOptions {
|
|
|
18
18
|
metadata?: Record<string, string> | null;
|
|
19
19
|
path?: Uint8Array | null;
|
|
20
20
|
parent?: MantarayNode | null;
|
|
21
|
+
type?: number | null;
|
|
21
22
|
}
|
|
22
23
|
export declare class MantarayNode {
|
|
23
24
|
obfuscationKey: Uint8Array;
|
|
@@ -27,6 +28,7 @@ export declare class MantarayNode {
|
|
|
27
28
|
path: Uint8Array;
|
|
28
29
|
forks: Map<number, Fork>;
|
|
29
30
|
parent: MantarayNode | null;
|
|
31
|
+
type: number | null;
|
|
30
32
|
constructor(options?: MantarayNodeOptions);
|
|
31
33
|
get fullPath(): Uint8Array;
|
|
32
34
|
get fullPathString(): string;
|
|
@@ -1,9 +1,6 @@
|
|
|
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.8.1-7cf53193";
|
|
5
|
-
export declare const SUPPORTED_BEE_VERSION: string;
|
|
6
|
-
export declare const SUPPORTED_API_VERSION = "8.1.0";
|
|
7
4
|
export declare function getDebugStatus(requestOptions: BeeRequestOptions): Promise<DebugStatus>;
|
|
8
5
|
/**
|
|
9
6
|
* Get health of node
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Exact supported Bee version, including the commit hash suffix. */
|
|
2
|
+
export declare const SUPPORTED_BEE_VERSION_EXACT = "2.8.1-7cf53193";
|
|
3
|
+
/** Supported Bee version without the commit hash suffix. */
|
|
4
|
+
export declare const SUPPORTED_BEE_VERSION: string;
|
|
5
|
+
/** Supported Bee API version. */
|
|
6
|
+
export declare const SUPPORTED_API_VERSION = "8.1.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethersphere/bee-js",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.2-upcoming.116",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -53,7 +53,9 @@
|
|
|
53
53
|
],
|
|
54
54
|
"scripts": {
|
|
55
55
|
"prepublishOnly": "NODE_ENV=production npm run build",
|
|
56
|
-
"
|
|
56
|
+
"prepare": "node scripts/generate-version.cjs",
|
|
57
|
+
"generate:version": "node scripts/generate-version.cjs",
|
|
58
|
+
"build": "npm run generate:version && rimraf dist && npm run build:node && npm run build:types && npm run build:browser",
|
|
57
59
|
"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/",
|
|
58
60
|
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types",
|
|
59
61
|
"build:browser": "webpack --progress",
|
|
@@ -66,7 +68,7 @@
|
|
|
66
68
|
"dependencies": {
|
|
67
69
|
"cafe-utility": "^34.0.0",
|
|
68
70
|
"debug": "^4.4.3",
|
|
69
|
-
"isomorphic-ws": "^
|
|
71
|
+
"isomorphic-ws": "^5.0.0",
|
|
70
72
|
"semver": "^7.3.5",
|
|
71
73
|
"ws": "^8.21.0",
|
|
72
74
|
"zod": "^4.4.3"
|
|
@@ -92,12 +94,12 @@
|
|
|
92
94
|
"depcheck": "^1.4.7",
|
|
93
95
|
"eslint": "^8.13.0",
|
|
94
96
|
"eslint-config-prettier": "^8.5.0",
|
|
95
|
-
"eslint-plugin-prettier": "^
|
|
97
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
96
98
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
97
99
|
"husky": "^8.0.1",
|
|
98
100
|
"jest": "^30.2.0",
|
|
99
101
|
"jest-environment-jsdom": "^30.4.1",
|
|
100
|
-
"prettier": "^
|
|
102
|
+
"prettier": "^3.9.4",
|
|
101
103
|
"rimraf": "^3.0.2",
|
|
102
104
|
"terser-webpack-plugin": "^5.3.1",
|
|
103
105
|
"ts-jest": "^29.4.11",
|