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

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.
@@ -194,13 +194,23 @@ class Messaging {
194
194
  * @param address
195
195
  * @param identifier
196
196
  * @param handler
197
+ * @param options SOC fields to receive and whether to cache the wrapped chunk; requires Bee 2.8.3 or later
197
198
  */
198
- gsocSubscribe(address, identifier, handler) {
199
+ gsocSubscribe(address, identifier, handler, options) {
199
200
  const ethAddress = new core_sdk_1.EthAddress(address);
200
201
  const id = new core_sdk_1.Identifier(identifier);
201
202
  handler = schema_1.GsocMessageHandlerSchema.parse(handler);
203
+ const { fields, cacheWrappedChunk } = schema_1.GsocSubscribeOptionsSchema.parse(options ?? {});
204
+ const params = new URLSearchParams();
205
+ if (fields) {
206
+ params.set('swarm-soc-fields', fields.join(','));
207
+ }
208
+ if (cacheWrappedChunk !== undefined) {
209
+ params.set('swarm-cache-wrapped-chunk', String(cacheWrappedChunk));
210
+ }
202
211
  const socAddress = (0, soc_1.makeSOCAddress)(id, ethAddress);
203
- const ws = this.openWebSocket(`${GSOC_ENDPOINT}/subscribe/${socAddress.toHex()}`);
212
+ const query = params.toString() ? `?${params.toString()}` : '';
213
+ const ws = this.openWebSocket(`${GSOC_ENDPOINT}/subscribe/${socAddress.toHex()}${query}`);
204
214
  const cancel = this.makeCancel(ws);
205
215
  const subscription = { address: ethAddress, cancel };
206
216
  ws.onmessage = async (event) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AllTagsOptionsSchema = exports.TransactionOptionsSchema = exports.PostageBatchOptionsSchema = exports.GsocMessageHandlerSchema = exports.PssMessageHandlerSchema = exports.TagUidSchema = exports.TagInputSchema = exports.CollectionUploadOptionsSchema = exports.FileUploadOptionsSchema = exports.RedundantUploadOptionsSchema = exports.UploadOptionsSchema = exports.DownloadOptionsSchema = exports.BeeRequestOptionsSchema = exports.HexStringSchema = void 0;
3
+ exports.AllTagsOptionsSchema = exports.TransactionOptionsSchema = exports.PostageBatchOptionsSchema = exports.GsocSubscribeOptionsSchema = exports.GsocMessageHandlerSchema = exports.PssMessageHandlerSchema = exports.TagUidSchema = exports.TagInputSchema = exports.CollectionUploadOptionsSchema = exports.FileUploadOptionsSchema = exports.RedundantUploadOptionsSchema = exports.UploadOptionsSchema = exports.DownloadOptionsSchema = exports.BeeRequestOptionsSchema = exports.HexStringSchema = void 0;
4
4
  const core_sdk_1 = require("@ethersphere/core-sdk");
5
5
  const zod_1 = require("zod");
6
6
  const types_1 = require("../types");
@@ -71,6 +71,13 @@ exports.GsocMessageHandlerSchema = zod_1.z.object({
71
71
  onError: fnField,
72
72
  onClose: fnField,
73
73
  });
74
+ exports.GsocSubscribeOptionsSchema = zod_1.z.object({
75
+ fields: zod_1.z
76
+ .array(zod_1.z.enum(['address', 'recoveredPubKey', 'identifier', 'signature', 'wrappedAddress', 'span', 'payload']))
77
+ .nonempty()
78
+ .optional(),
79
+ cacheWrappedChunk: zod_1.z.boolean().optional(),
80
+ });
74
81
  exports.PostageBatchOptionsSchema = zod_1.z.object({
75
82
  gasPrice: integerStringField.optional(),
76
83
  immutableFlag: zod_1.z.boolean().optional(),