@ethersphere/bee-js 13.2.0-upcoming.g9a08883 → 13.2.0-upcoming.gc0ec0bb

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 CHANGED
@@ -59,6 +59,18 @@ Loading this module through a script tag will make the `BeeJs` object available
59
59
  <script src="https://unpkg.com/@ethersphere/bee-js/dist/index.browser.min.js"></script>
60
60
  ```
61
61
 
62
+ ### Browser apps and CORS
63
+
64
+ From Bee 2.8.3, a node rejects `POST`, `PUT`, `PATCH` and `DELETE` requests from a browser page on another origin with
65
+ `403 Forbidden`, unless that origin is listed in the node's `cors-allowed-origins` option. Uploads, stamp purchases and
66
+ other write calls from a web app therefore need the app's origin in that list:
67
+
68
+ ```sh
69
+ bee start --cors-allowed-origins="https://my-app.example"
70
+ ```
71
+
72
+ Node.js scripts are not affected, because they send no `Origin` header.
73
+
62
74
  ## Overview
63
75
 
64
76
  ### Type interfaces
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRedistributionState = getRedistributionState;
4
+ exports.setRedistributionEnabled = setRedistributionEnabled;
4
5
  const stake_1 = require("../types/schema/stake");
5
6
  const http_1 = require("../utils/http");
6
7
  const redistributionStateEndpoint = 'redistributionstate';
@@ -15,3 +16,12 @@ async function getRedistributionState(requestOptions) {
15
16
  });
16
17
  return stake_1.GetRedistributionStateResponse.parse(response.data);
17
18
  }
19
+ async function setRedistributionEnabled(requestOptions, enabled) {
20
+ const response = await (0, http_1.http)(requestOptions, {
21
+ method: 'patch',
22
+ responseType: 'json',
23
+ url: redistributionStateEndpoint,
24
+ data: { enabled },
25
+ });
26
+ return stake_1.RedistributionToggleResponse.parse(response.data).enabled;
27
+ }
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Stake = void 0;
37
+ const zod_1 = require("zod");
37
38
  const schema_1 = require("../utils/schema");
38
39
  const tokens_1 = require("../utils/tokens");
39
40
  const type_1 = require("../utils/type");
@@ -112,5 +113,9 @@ class Stake {
112
113
  async getRedistributionState(requestOptions) {
113
114
  return redistributionApi.getRedistributionState(this.context.getRequestOptionsForCall(requestOptions));
114
115
  }
116
+ /** Enables or disables participation in new redistribution rounds; resets to enabled when the node restarts. */
117
+ async setRedistributionEnabled(enabled, requestOptions) {
118
+ return redistributionApi.setRedistributionEnabled(this.context.getRequestOptionsForCall(requestOptions), zod_1.z.boolean().parse(enabled));
119
+ }
115
120
  }
116
121
  exports.Stake = Stake;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetRedistributionStateResponse = exports.TxHashResponse = exports.GetWithdrawableStakeResponse = exports.GetStakeResponse = void 0;
3
+ exports.RedistributionToggleResponse = exports.GetRedistributionStateResponse = exports.TxHashResponse = exports.GetWithdrawableStakeResponse = exports.GetStakeResponse = void 0;
4
4
  const core_sdk_1 = require("@ethersphere/core-sdk");
5
5
  const zod_1 = require("zod");
6
6
  const tokens_1 = require("../../utils/tokens");
@@ -34,4 +34,10 @@ exports.GetRedistributionStateResponse = zod_1.z.object({
34
34
  reward: zod_1.z.string().transform(s => tokens_1.BZZ.fromPLUR((0, type_1.asNumberString)(s, { name: 'reward' }))),
35
35
  fees: zod_1.z.string().transform(s => tokens_1.DAI.fromWei((0, type_1.asNumberString)(s, { name: 'fees' }))),
36
36
  isHealthy: zod_1.z.boolean(),
37
+ enabled: zod_1.z.boolean(),
38
+ hasCommittedThisRound: zod_1.z.boolean(),
39
+ hasRevealedThisRound: zod_1.z.boolean(),
40
+ });
41
+ exports.RedistributionToggleResponse = zod_1.z.object({
42
+ enabled: zod_1.z.boolean(),
37
43
  });
@@ -4,8 +4,8 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.SUPPORTED_API_VERSION = exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT = void 0;
6
6
  /** Exact supported Bee version, including the commit hash suffix. */
7
- exports.SUPPORTED_BEE_VERSION_EXACT = '2.8.1-7cf53193';
7
+ exports.SUPPORTED_BEE_VERSION_EXACT = '2.8.3';
8
8
  /** Supported Bee version without the commit hash suffix. */
9
9
  exports.SUPPORTED_BEE_VERSION = exports.SUPPORTED_BEE_VERSION_EXACT.split('-')[0];
10
10
  /** Supported Bee API version. */
11
- exports.SUPPORTED_API_VERSION = '8.1.0';
11
+ exports.SUPPORTED_API_VERSION = '8.2.0';