@ethersphere/bee-js 9.7.1 → 9.8.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.
@@ -1,6 +1,8 @@
1
1
  import { Binary, MerkleTree, Optional, Uint8ArrayReader } from 'cafe-utility';
2
+ import _debug from 'debug';
2
3
  import { NULL_ADDRESS } from "../index.js";
3
4
  import { Reference } from "../utils/typed-bytes.js";
5
+ const debug = _debug('bee-js:manifest');
4
6
  const ENCODER = new TextEncoder();
5
7
  const DECODER = new TextDecoder();
6
8
  const TYPE_VALUE = 2;
@@ -60,6 +62,11 @@ export class Fork {
60
62
  data.push(new Uint8Array(30 - this.prefix.length));
61
63
  }
62
64
  data.push(this.node.selfAddress);
65
+ debug('marshalling fork', {
66
+ prefixLength: this.prefix.length,
67
+ prefix: DECODER.decode(this.prefix),
68
+ address: Binary.uint8ArrayToHex(this.node.selfAddress)
69
+ });
63
70
  if (this.node.metadata) {
64
71
  const metadataBytes = Binary.padEndToMultiple(new Uint8Array([0x00, 0x00, ...ENCODER.encode(JSON.stringify(this.node.metadata))]), 32, 0x0a);
65
72
  const metadataLengthBytes = Binary.numberToUint16(metadataBytes.length - 2, 'BE');
@@ -74,6 +81,12 @@ export class Fork {
74
81
  const prefix = reader.read(prefixLength);
75
82
  reader.read(30 - prefixLength);
76
83
  const selfAddress = reader.read(addressLength);
84
+ debug('unmarshalling fork', {
85
+ prefixLength,
86
+ prefix: DECODER.decode(prefix),
87
+ addressLength,
88
+ address: Binary.uint8ArrayToHex(selfAddress)
89
+ });
77
90
  let metadata = undefined;
78
91
  if (isType(type, TYPE_WITH_METADATA)) {
79
92
  const metadataLength = Binary.uint16ToNumber(reader.read(2), 'BE');
@@ -232,6 +245,10 @@ export class MantarayNode {
232
245
  addFork(path, reference, metadata) {
233
246
  this.selfAddress = null;
234
247
  path = path instanceof Uint8Array ? path : ENCODER.encode(path);
248
+ debug('adding fork', {
249
+ path: DECODER.decode(path),
250
+ reference: new Reference(reference).represent()
251
+ });
235
252
  // TODO: this should not be ignored
236
253
  // eslint-disable-next-line @typescript-eslint/no-this-alias
237
254
  let tip = this;
@@ -1,6 +1,8 @@
1
1
  import axios from 'axios';
2
2
  import { Dates, Objects, Strings, System } from 'cafe-utility';
3
+ import _debug from 'debug';
3
4
  import { BeeResponseError } from "../index.js";
5
+ const debug = _debug('bee-js:http');
4
6
  const {
5
7
  AxiosError
6
8
  } = axios;
@@ -37,6 +39,12 @@ export async function http(options, config) {
37
39
  let failedAttempts = 0;
38
40
  while (failedAttempts < MAX_FAILED_ATTEMPTS) {
39
41
  try {
42
+ debug(`${requestConfig.method || 'get'} ${Strings.joinUrl([requestConfig.baseURL, requestConfig.url])}`, {
43
+ headers: {
44
+ ...requestConfig.headers
45
+ },
46
+ params: requestConfig.params
47
+ });
40
48
  maybeRunOnRequestHook(options, requestConfig);
41
49
  const response = await axios(requestConfig);
42
50
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethersphere/bee-js",
3
- "version": "9.7.1",
3
+ "version": "9.8.0",
4
4
  "description": "Javascript client for Bee",
5
5
  "keywords": [
6
6
  "bee",
@@ -63,6 +63,7 @@
63
63
  "dependencies": {
64
64
  "axios": "^0.30.0",
65
65
  "cafe-utility": "^31.0.0",
66
+ "debug": "^4.4.1",
66
67
  "isomorphic-ws": "^4.0.1",
67
68
  "semver": "^7.3.5",
68
69
  "ws": "^8.7.0"
@@ -78,6 +79,7 @@
78
79
  "@commitlint/config-conventional": "^17.4.2",
79
80
  "@jest/types": "^29.6.3",
80
81
  "@naholyr/cross-env": "^1.0.0",
82
+ "@types/debug": "^4.1.12",
81
83
  "@types/jest": "^29.5.13",
82
84
  "@types/node": "^18.11.11",
83
85
  "@types/semver": "^7.3.9",