@ethersphere/bee-js 9.5.0 → 9.6.1

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/bee.js CHANGED
@@ -896,6 +896,17 @@ class Bee {
896
896
  }
897
897
  return true;
898
898
  }
899
+ /**
900
+ * Checks the `/gateway` endpoint to see if the remote API is a gateway.
901
+ *
902
+ * Do note that this is not a standard way to check for gateway nodes,
903
+ * but some of the gateway tooling expose this endpoint.
904
+ *
905
+ * @param options
906
+ */
907
+ async isGateway(options) {
908
+ return status.isGateway(this.getRequestOptionsForCall(options));
909
+ }
899
910
  // Legacy debug API
900
911
  async getNodeAddresses(options) {
901
912
  return connectivity.getNodeAddresses(this.getRequestOptionsForCall(options));
@@ -69,12 +69,12 @@ class Fork {
69
69
  }
70
70
  return cafe_utility_1.Binary.concatBytes(...data);
71
71
  }
72
- static unmarshal(reader) {
72
+ static unmarshal(reader, addressLength) {
73
73
  const type = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
74
74
  const prefixLength = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
75
75
  const prefix = reader.read(prefixLength);
76
76
  reader.read(30 - prefixLength);
77
- const selfAddress = reader.read(32);
77
+ const selfAddress = reader.read(addressLength);
78
78
  let metadata = undefined;
79
79
  if (isType(type, TYPE_WITH_METADATA)) {
80
80
  const metadataLength = cafe_utility_1.Binary.uint16ToNumber(reader.read(2), 'BE');
@@ -214,7 +214,7 @@ class MantarayNode {
214
214
  const forkBitmap = reader.read(32);
215
215
  for (let i = 0; i < 256; i++) {
216
216
  if (cafe_utility_1.Binary.getBit(forkBitmap, i, 'LE')) {
217
- const newFork = Fork.unmarshal(reader);
217
+ const newFork = Fork.unmarshal(reader, targetAddressLength);
218
218
  node.forks.set(i, newFork);
219
219
  newFork.node.parent = node;
220
220
  }
@@ -8,9 +8,9 @@ const cafe_utility_1 = require("cafe-utility");
8
8
  const major_js_1 = __importDefault(require("semver/functions/major.js"));
9
9
  const debug_1 = require("../../types/debug");
10
10
  const http_1 = require("../../utils/http");
11
- exports.SUPPORTED_BEE_VERSION_EXACT = '2.4.0-390a402e';
11
+ exports.SUPPORTED_BEE_VERSION_EXACT = '2.6.0-d0aa8b93';
12
12
  exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
13
- exports.SUPPORTED_API_VERSION = '7.2.0';
13
+ exports.SUPPORTED_API_VERSION = '7.3.0';
14
14
  const NODE_INFO_URL = 'node';
15
15
  const STATUS_URL = 'status';
16
16
  const HEALTH_URL = 'health';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkConnection = void 0;
3
+ exports.isGateway = exports.checkConnection = void 0;
4
+ const cafe_utility_1 = require("cafe-utility");
4
5
  const http_1 = require("../utils/http");
5
6
  /**
6
7
  * Ping the base bee URL. If connection was not successful throw error
@@ -13,3 +14,16 @@ async function checkConnection(requestOptions) {
13
14
  });
14
15
  }
15
16
  exports.checkConnection = checkConnection;
17
+ async function isGateway(requestOptions) {
18
+ try {
19
+ const response = await (0, http_1.http)(requestOptions, {
20
+ url: '/gateway',
21
+ });
22
+ const data = cafe_utility_1.Types.asObject(response.data);
23
+ return cafe_utility_1.Types.asBoolean(data.gateway);
24
+ }
25
+ catch (error) {
26
+ return false;
27
+ }
28
+ }
29
+ exports.isGateway = isGateway;