@ethersphere/bee-js 5.1.1 → 5.1.2

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.
Files changed (151) hide show
  1. package/README.md +14 -6
  2. package/dist/223.index.browser.min.js +3 -0
  3. package/dist/223.index.browser.min.js.LICENSE.txt +1 -0
  4. package/dist/223.index.browser.min.js.map +1 -0
  5. package/dist/cjs/bee-debug.js +208 -312
  6. package/dist/cjs/bee.js +258 -353
  7. package/dist/cjs/chunk/signer.js +11 -22
  8. package/dist/cjs/chunk/soc.js +33 -50
  9. package/dist/cjs/chunk/span.js +1 -1
  10. package/dist/cjs/feed/index.js +50 -65
  11. package/dist/cjs/feed/json.js +8 -21
  12. package/dist/cjs/feed/retrievable.js +14 -27
  13. package/dist/cjs/modules/bytes.js +25 -37
  14. package/dist/cjs/modules/bzz.js +63 -68
  15. package/dist/cjs/modules/chunk.js +17 -27
  16. package/dist/cjs/modules/debug/balance.js +24 -41
  17. package/dist/cjs/modules/debug/chequebook.js +71 -96
  18. package/dist/cjs/modules/debug/chunk.js +13 -26
  19. package/dist/cjs/modules/debug/connectivity.js +32 -53
  20. package/dist/cjs/modules/debug/settlements.js +12 -25
  21. package/dist/cjs/modules/debug/stake.js +20 -33
  22. package/dist/cjs/modules/debug/stamps.js +45 -66
  23. package/dist/cjs/modules/debug/states.js +27 -40
  24. package/dist/cjs/modules/debug/status.js +53 -80
  25. package/dist/cjs/modules/debug/tag.js +6 -17
  26. package/dist/cjs/modules/debug/transactions.js +23 -40
  27. package/dist/cjs/modules/feed.js +17 -27
  28. package/dist/cjs/modules/pinning.js +24 -41
  29. package/dist/cjs/modules/pss.js +9 -20
  30. package/dist/cjs/modules/soc.js +12 -20
  31. package/dist/cjs/modules/status.js +4 -15
  32. package/dist/cjs/modules/stewardship.js +10 -23
  33. package/dist/cjs/modules/tag.js +28 -47
  34. package/dist/cjs/utils/collection.browser.js +4 -17
  35. package/dist/cjs/utils/collection.js +11 -22
  36. package/dist/cjs/utils/collection.node.js +42 -86
  37. package/dist/cjs/utils/data.browser.js +46 -59
  38. package/dist/cjs/utils/data.js +22 -35
  39. package/dist/cjs/utils/eth.js +31 -43
  40. package/dist/cjs/utils/file.js +9 -20
  41. package/dist/cjs/utils/headers.js +4 -4
  42. package/dist/cjs/utils/http.js +78 -93
  43. package/dist/cjs/utils/merge.js +1 -1
  44. package/dist/cjs/utils/sleep.js +2 -13
  45. package/dist/cjs/utils/type.js +14 -12
  46. package/dist/index.browser.min.js +1 -1
  47. package/dist/index.browser.min.js.LICENSE.txt +1 -3
  48. package/dist/index.browser.min.js.map +1 -1
  49. package/dist/mjs/bee-debug.js +209 -450
  50. package/dist/mjs/bee.js +256 -491
  51. package/dist/mjs/chunk/bmt.js +4 -10
  52. package/dist/mjs/chunk/cac.js +0 -3
  53. package/dist/mjs/chunk/signer.js +12 -63
  54. package/dist/mjs/chunk/soc.js +33 -85
  55. package/dist/mjs/chunk/span.js +3 -6
  56. package/dist/mjs/feed/identifier.js +0 -6
  57. package/dist/mjs/feed/index.js +53 -97
  58. package/dist/mjs/feed/json.js +10 -49
  59. package/dist/mjs/feed/retrievable.js +13 -64
  60. package/dist/mjs/feed/topic.js +0 -2
  61. package/dist/mjs/index.js +1 -2
  62. package/dist/mjs/modules/bytes.js +25 -65
  63. package/dist/mjs/modules/bzz.js +64 -108
  64. package/dist/mjs/modules/chunk.js +17 -54
  65. package/dist/mjs/modules/debug/balance.js +24 -68
  66. package/dist/mjs/modules/debug/chequebook.js +75 -138
  67. package/dist/mjs/modules/debug/chunk.js +13 -51
  68. package/dist/mjs/modules/debug/connectivity.js +32 -76
  69. package/dist/mjs/modules/debug/settlements.js +12 -50
  70. package/dist/mjs/modules/debug/stake.js +20 -61
  71. package/dist/mjs/modules/debug/stamps.js +47 -94
  72. package/dist/mjs/modules/debug/states.js +25 -66
  73. package/dist/mjs/modules/debug/status.js +66 -125
  74. package/dist/mjs/modules/debug/tag.js +6 -41
  75. package/dist/mjs/modules/debug/transactions.js +25 -69
  76. package/dist/mjs/modules/feed.js +17 -57
  77. package/dist/mjs/modules/pinning.js +24 -68
  78. package/dist/mjs/modules/pss.js +11 -47
  79. package/dist/mjs/modules/soc.js +14 -48
  80. package/dist/mjs/modules/status.js +4 -39
  81. package/dist/mjs/modules/stewardship.js +10 -47
  82. package/dist/mjs/modules/tag.js +31 -78
  83. package/dist/mjs/types/debug.js +0 -1
  84. package/dist/mjs/types/index.js +0 -4
  85. package/dist/mjs/utils/bytes.js +6 -14
  86. package/dist/mjs/utils/collection.browser.js +4 -42
  87. package/dist/mjs/utils/collection.js +11 -57
  88. package/dist/mjs/utils/collection.node.js +42 -150
  89. package/dist/mjs/utils/data.browser.js +49 -94
  90. package/dist/mjs/utils/data.js +19 -62
  91. package/dist/mjs/utils/error.js +0 -5
  92. package/dist/mjs/utils/eth.js +37 -95
  93. package/dist/mjs/utils/file.js +11 -50
  94. package/dist/mjs/utils/hash.js +0 -1
  95. package/dist/mjs/utils/headers.js +6 -14
  96. package/dist/mjs/utils/hex.js +6 -25
  97. package/dist/mjs/utils/http.js +80 -138
  98. package/dist/mjs/utils/merge.js +3 -7
  99. package/dist/mjs/utils/pss.js +0 -2
  100. package/dist/mjs/utils/reference.js +2 -5
  101. package/dist/mjs/utils/sleep.js +2 -37
  102. package/dist/mjs/utils/stream.js +0 -23
  103. package/dist/mjs/utils/tar.js +2 -5
  104. package/dist/mjs/utils/type.js +18 -82
  105. package/dist/mjs/utils/uint64.js +0 -1
  106. package/dist/mjs/utils/url.js +2 -10
  107. package/dist/types/bee-debug.d.ts +2 -2
  108. package/dist/types/bee.d.ts +2 -26
  109. package/dist/types/chunk/cac.d.ts +1 -1
  110. package/dist/types/chunk/soc.d.ts +8 -7
  111. package/dist/types/feed/index.d.ts +9 -8
  112. package/dist/types/feed/type.d.ts +1 -1
  113. package/dist/types/modules/bytes.d.ts +6 -5
  114. package/dist/types/modules/bzz.d.ts +9 -8
  115. package/dist/types/modules/chunk.d.ts +5 -4
  116. package/dist/types/modules/debug/balance.d.ts +10 -9
  117. package/dist/types/modules/debug/chequebook.d.ts +18 -17
  118. package/dist/types/modules/debug/chunk.d.ts +6 -5
  119. package/dist/types/modules/debug/connectivity.d.ts +8 -7
  120. package/dist/types/modules/debug/settlements.d.ts +6 -5
  121. package/dist/types/modules/debug/stake.d.ts +5 -4
  122. package/dist/types/modules/debug/stamps.d.ts +8 -7
  123. package/dist/types/modules/debug/states.d.ts +8 -7
  124. package/dist/types/modules/debug/status.d.ts +15 -15
  125. package/dist/types/modules/debug/tag.d.ts +4 -3
  126. package/dist/types/modules/debug/transactions.d.ts +6 -5
  127. package/dist/types/modules/feed.d.ts +4 -3
  128. package/dist/types/modules/pinning.d.ts +8 -7
  129. package/dist/types/modules/pss.d.ts +4 -3
  130. package/dist/types/modules/soc.d.ts +3 -2
  131. package/dist/types/modules/status.d.ts +3 -3
  132. package/dist/types/modules/stewardship.d.ts +4 -3
  133. package/dist/types/modules/tag.d.ts +7 -6
  134. package/dist/types/types/debug.d.ts +1 -1
  135. package/dist/types/types/index.d.ts +30 -34
  136. package/dist/types/utils/eth.d.ts +3 -3
  137. package/dist/types/utils/hex.d.ts +2 -2
  138. package/dist/types/utils/http.d.ts +6 -6
  139. package/package.json +34 -39
  140. package/dist/cjs/types/ky-options.js +0 -8
  141. package/dist/cjs/types/ky-universal/common.js +0 -8
  142. package/dist/cjs/types/ky-universal/hooks.js +0 -8
  143. package/dist/cjs/types/ky-universal/retry.js +0 -8
  144. package/dist/mjs/types/ky-options.js +0 -7
  145. package/dist/mjs/types/ky-universal/common.js +0 -7
  146. package/dist/mjs/types/ky-universal/hooks.js +0 -7
  147. package/dist/mjs/types/ky-universal/retry.js +0 -7
  148. package/dist/types/types/ky-options.d.ts +0 -221
  149. package/dist/types/types/ky-universal/common.d.ts +0 -13
  150. package/dist/types/types/ky-universal/hooks.d.ts +0 -92
  151. package/dist/types/types/ky-universal/retry.d.ts +0 -38
@@ -23,7 +23,6 @@ export function isObject(value) {
23
23
  * @param value
24
24
  */
25
25
  // eslint-disable-next-line @typescript-eslint/ban-types
26
-
27
26
  export function isStrictlyObject(value) {
28
27
  return isObject(value) && !Array.isArray(value);
29
28
  }
@@ -32,11 +31,10 @@ export function isStrictlyObject(value) {
32
31
  *
33
32
  * @param e
34
33
  */
35
-
36
34
  export function isError(e) {
37
35
  return e instanceof Error;
38
- } // eslint-disable-next-line @typescript-eslint/ban-types
39
-
36
+ }
37
+ // eslint-disable-next-line @typescript-eslint/ban-types
40
38
  export function assertStrictlyObject(value, name = 'value') {
41
39
  if (!isStrictlyObject(value)) {
42
40
  throw new TypeError(`${name} has to be an object that is not null nor array!`);
@@ -67,7 +65,6 @@ export function assertReferenceOrEns(value) {
67
65
  if (typeof value !== 'string') {
68
66
  throw new TypeError('ReferenceOrEns has to be a string!');
69
67
  }
70
-
71
68
  if (isHexString(value)) {
72
69
  assertReference(value);
73
70
  return;
@@ -104,12 +101,10 @@ export function assertReferenceOrEns(value) {
104
101
  * This covers everything but top level domain which is 2 to 63 characters long so we can just use the <regexp2> again
105
102
  * ^(<regexp1>|<regexp2>\.)+<regexp1>$
106
103
  */
107
-
108
-
109
- const DOMAIN_REGEX = /^(?:(?:[^-.\/?:\s][^.\/?:\s]{0,61}[^-.\/?:\s]|[^-.\/?:\s]{1,2})\.)+[^-.\/?:\s][^.\/?:\s]{0,61}[^-.\/?:\s]$/; // We are doing best-effort validation of domain here. The proper way would be to do validation using IDNA UTS64 standard
104
+ const DOMAIN_REGEX = /^(?:(?:[^-.\/?:\s][^.\/?:\s]{0,61}[^-.\/?:\s]|[^-.\/?:\s]{1,2})\.)+[^-.\/?:\s][^.\/?:\s]{0,61}[^-.\/?:\s]$/;
105
+ // We are doing best-effort validation of domain here. The proper way would be to do validation using IDNA UTS64 standard
110
106
  // but that would give us high penalty to our dependencies as the library (idna-uts46-hx) that does this validation and translation
111
107
  // adds 160kB minified size which is significant. We expects that full validation will be done on Bee side.
112
-
113
108
  if (!DOMAIN_REGEX.test(value)) {
114
109
  throw new TypeError('ReferenceOrEns is not valid Reference, but also not valid ENS domain.');
115
110
  }
@@ -120,26 +115,19 @@ export function assertReferenceOrEns(value) {
120
115
  * @param value
121
116
  * @param expectedCidType
122
117
  */
123
-
124
118
  export function makeReferenceOrEns(value, expectedCidType) {
125
- var _a;
126
-
127
119
  if (typeof value !== 'string') {
128
120
  throw new TypeError('ReferenceCidOrEns has to be a string!');
129
121
  }
130
-
131
122
  try {
132
123
  const result = decodeCid(value);
133
-
134
124
  if (result.type !== expectedCidType) {
135
- throw new BeeError(`CID was expected to be of type ${expectedCidType}, but got instead ${(_a = result.type) !== null && _a !== void 0 ? _a : 'non-Swarm CID'}`);
125
+ throw new BeeError(`CID was expected to be of type ${expectedCidType}, but got instead ${result.type ?? 'non-Swarm CID'}`);
136
126
  }
137
-
138
127
  return result.reference;
139
128
  } catch (e) {
140
129
  if (e instanceof BeeError) throw e;
141
130
  }
142
-
143
131
  assertReferenceOrEns(value);
144
132
  return value;
145
133
  }
@@ -148,14 +136,13 @@ export function makeReferenceOrEns(value, expectedCidType) {
148
136
  * @param result
149
137
  * @param cidType Type as described in the @ethersphere/swarm-cids-js -> ReferenceType
150
138
  */
151
-
152
139
  export function addCidConversionFunction(result, cidType) {
153
- return Object.assign(Object.assign({}, result), {
140
+ return {
141
+ ...result,
154
142
  cid() {
155
143
  return encodeReference(result.reference, cidType).toString();
156
144
  }
157
-
158
- });
145
+ };
159
146
  }
160
147
  export function assertAddress(value) {
161
148
  assertHexString(value, ADDRESS_HEX_LENGTH, 'Address');
@@ -167,21 +154,16 @@ export function assertRequestOptions(value, name = 'RequestOptions') {
167
154
  if (value === undefined) {
168
155
  return;
169
156
  }
170
-
171
157
  if (!isStrictlyObject(value)) {
172
158
  throw new TypeError(`${name} has to be an object!`);
173
159
  }
174
-
175
160
  const options = value;
176
-
177
161
  if (options.retry) {
178
162
  assertNonNegativeInteger(options.retry, `${name}.retry`);
179
163
  }
180
-
181
164
  if (options.timeout) {
182
165
  assertNonNegativeInteger(options.timeout, `${name}.timeout`);
183
166
  }
184
-
185
167
  if (options.fetch && typeof options.fetch !== 'function') {
186
168
  throw new TypeError(`${name}.fetch has to be a function or undefined!`);
187
169
  }
@@ -190,38 +172,30 @@ export function assertUploadOptions(value, name = 'UploadOptions') {
190
172
  if (!isStrictlyObject(value)) {
191
173
  throw new TypeError(`${name} has to be an object!`);
192
174
  }
193
-
194
175
  assertRequestOptions(value, name);
195
176
  const options = value;
196
-
197
177
  if (options.pin && typeof options.pin !== 'boolean') {
198
178
  throw new TypeError(`options.pin property in ${name} has to be boolean or undefined!`);
199
179
  }
200
-
201
180
  if (options.encrypt && typeof options.encrypt !== 'boolean') {
202
181
  throw new TypeError(`options.encrypt property in ${name} has to be boolean or undefined!`);
203
182
  }
204
-
205
183
  if (options.tag) {
206
184
  if (typeof options.tag !== 'number') {
207
185
  throw new TypeError(`options.tag property in ${name} has to be number or undefined!`);
208
186
  }
209
-
210
187
  assertNonNegativeInteger(options.tag, 'options.tag');
211
188
  }
212
189
  }
213
190
  export function assertFileUploadOptions(value) {
214
191
  assertUploadOptions(value, 'FileUploadOptions');
215
192
  const options = value;
216
-
217
193
  if (options.size) {
218
194
  if (typeof options.size !== 'number') {
219
195
  throw new TypeError('tag property in FileUploadOptions has to be number or undefined!');
220
196
  }
221
-
222
197
  assertNonNegativeInteger(options.size, 'options.size');
223
198
  }
224
-
225
199
  if (options.contentType && typeof options.contentType !== 'string') {
226
200
  throw new TypeError('contentType property in FileUploadOptions has to be string or undefined!');
227
201
  }
@@ -229,11 +203,9 @@ export function assertFileUploadOptions(value) {
229
203
  export function assertCollectionUploadOptions(value) {
230
204
  assertUploadOptions(value, 'CollectionUploadOptions');
231
205
  const options = value;
232
-
233
206
  if (options.indexDocument && typeof options.indexDocument !== 'string') {
234
207
  throw new TypeError('indexDocument property in CollectionUploadOptions has to be string or undefined!');
235
208
  }
236
-
237
209
  if (options.errorDocument && typeof options.errorDocument !== 'string') {
238
210
  throw new TypeError('errorDocument property in CollectionUploadOptions has to be string or undefined!');
239
211
  }
@@ -242,46 +214,37 @@ export function isTag(value) {
242
214
  if (!isStrictlyObject(value)) {
243
215
  return false;
244
216
  }
245
-
246
217
  const tag = value;
247
218
  const numberProperties = ['total', 'processed', 'synced', 'uid'];
248
219
  const correctNumberProperties = numberProperties.every(numberProperty => typeof tag[numberProperty] === 'number');
249
-
250
220
  if (!correctNumberProperties || !tag.startedAt || typeof tag.startedAt !== 'string') {
251
221
  return false;
252
222
  }
253
-
254
223
  return true;
255
224
  }
256
225
  export function assertTag(value) {
257
226
  if (!isStrictlyObject(value)) {
258
227
  throw new TypeError('Tag is not an object!');
259
228
  }
260
-
261
229
  const tag = value;
262
230
  const numberProperties = ['total', 'processed', 'synced', 'uid'];
263
-
264
231
  for (const numberProperty of numberProperties) {
265
232
  if (!tag[numberProperty]) {
266
233
  throw new TypeError(`Tag's property '${numberProperty}' has to be specified!`);
267
234
  }
268
-
269
235
  if (typeof tag[numberProperty] !== 'number') {
270
236
  throw new TypeError(`Tag's property '${numberProperty}' has to be number!`);
271
237
  }
272
238
  }
273
-
274
239
  if (!tag.startedAt) {
275
240
  throw new TypeError("Tag's property 'startedAt' has to be specified!");
276
241
  }
277
-
278
242
  if (typeof tag.startedAt !== 'string') {
279
243
  throw new TypeError("Tag's property 'startedAt' has to be string!");
280
244
  }
281
245
  }
282
246
  export function assertAddressPrefix(value) {
283
247
  assertHexString(value, undefined, 'AddressPrefix');
284
-
285
248
  if (value.length > PSS_TARGET_HEX_LENGTH_MAX) {
286
249
  throw new BeeArgumentError(`AddressPrefix must have length of ${PSS_TARGET_HEX_LENGTH_MAX} at most! Got string with ${value.length}`, value);
287
250
  }
@@ -290,13 +253,10 @@ export function assertPssMessageHandler(value) {
290
253
  if (!isStrictlyObject(value)) {
291
254
  throw new TypeError('PssMessageHandler has to be object!');
292
255
  }
293
-
294
256
  const handler = value;
295
-
296
257
  if (typeof handler.onMessage !== 'function') {
297
258
  throw new TypeError('onMessage property of PssMessageHandler has to be function!');
298
259
  }
299
-
300
260
  if (typeof handler.onError !== 'function') {
301
261
  throw new TypeError('onError property of PssMessageHandler has to be function!');
302
262
  }
@@ -308,24 +268,19 @@ export function assertPostageBatchOptions(value) {
308
268
  if (value === undefined) {
309
269
  return;
310
270
  }
311
-
312
271
  assertStrictlyObject(value);
313
272
  const options = value;
314
273
  assertRequestOptions(options, 'PostageBatchOptions');
315
-
316
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
274
+ if (options?.gasPrice) {
317
275
  assertNonNegativeInteger(options.gasPrice);
318
276
  }
319
-
320
- if ((options === null || options === void 0 ? void 0 : options.immutableFlag) !== undefined) {
277
+ if (options?.immutableFlag !== undefined) {
321
278
  assertBoolean(options.immutableFlag);
322
279
  }
323
-
324
- if ((options === null || options === void 0 ? void 0 : options.waitForUsable) !== undefined) {
280
+ if (options?.waitForUsable !== undefined) {
325
281
  assertBoolean(options.waitForUsable);
326
282
  }
327
-
328
- if ((options === null || options === void 0 ? void 0 : options.waitForUsableTimeout) !== undefined) {
283
+ if (options?.waitForUsableTimeout !== undefined) {
329
284
  assertNonNegativeInteger(options.waitForUsableTimeout, 'options.waitForUsableTimeout');
330
285
  }
331
286
  }
@@ -333,15 +288,12 @@ export function assertTransactionOptions(value, name = 'TransactionOptions') {
333
288
  if (value === undefined) {
334
289
  return;
335
290
  }
336
-
337
291
  assertStrictlyObject(value, name);
338
292
  const options = value;
339
-
340
- if (options === null || options === void 0 ? void 0 : options.gasLimit) {
293
+ if (options?.gasLimit) {
341
294
  assertNonNegativeInteger(options.gasLimit, name);
342
295
  }
343
-
344
- if (options === null || options === void 0 ? void 0 : options.gasPrice) {
296
+ if (options?.gasPrice) {
345
297
  assertNonNegativeInteger(options.gasPrice, name);
346
298
  }
347
299
  }
@@ -349,7 +301,6 @@ export function assertCashoutOptions(value) {
349
301
  if (value === undefined) {
350
302
  return;
351
303
  }
352
-
353
304
  assertStrictlyObject(value);
354
305
  const options = value;
355
306
  assertRequestOptions(options, 'CashoutOptions');
@@ -360,7 +311,6 @@ export function assertCashoutOptions(value) {
360
311
  * @param value
361
312
  * @throws TypeError if not valid
362
313
  */
363
-
364
314
  export function assertData(value) {
365
315
  if (typeof value !== 'string' && !(value instanceof Uint8Array)) {
366
316
  throw new TypeError('Data must be either string or Uint8Array!');
@@ -371,7 +321,6 @@ export function assertData(value) {
371
321
  * @param value
372
322
  * @throws TypeError if not valid
373
323
  */
374
-
375
324
  export function assertFileData(value) {
376
325
  if (typeof value !== 'string' && !(value instanceof Uint8Array) && !isFile(value) && !isReadable(value)) {
377
326
  throw new TypeError('Data must be either string, Readable, Uint8Array or File!');
@@ -381,30 +330,24 @@ export function assertFileData(value) {
381
330
  * Checks whether optional options for AllTags query are valid
382
331
  * @param options
383
332
  */
384
-
385
333
  export function assertAllTagsOptions(entry) {
386
334
  if (entry !== undefined && !isStrictlyObject(entry)) {
387
335
  throw new TypeError('options has to be an object or undefined!');
388
336
  }
389
-
390
337
  assertRequestOptions(entry, 'AllTagsOptions');
391
338
  const options = entry;
392
-
393
- if ((options === null || options === void 0 ? void 0 : options.limit) !== undefined) {
339
+ if (options?.limit !== undefined) {
394
340
  if (typeof options.limit !== 'number') {
395
341
  throw new TypeError('AllTagsOptions.limit has to be a number or undefined!');
396
342
  }
397
-
398
343
  if (options.limit < TAGS_LIMIT_MIN) {
399
344
  throw new BeeArgumentError(`AllTagsOptions.limit has to be at least ${TAGS_LIMIT_MIN}`, options.limit);
400
345
  }
401
-
402
346
  if (options.limit > TAGS_LIMIT_MAX) {
403
347
  throw new BeeArgumentError(`AllTagsOptions.limit has to be at most ${TAGS_LIMIT_MAX}`, options.limit);
404
348
  }
405
349
  }
406
-
407
- if ((options === null || options === void 0 ? void 0 : options.offset) !== undefined) {
350
+ if (options?.offset !== undefined) {
408
351
  assertNonNegativeInteger(options.offset, 'AllTagsOptions.offset');
409
352
  }
410
353
  }
@@ -412,12 +355,10 @@ export function assertAllTagsOptions(entry) {
412
355
  * Utility functions that return Tag UID
413
356
  * @param tagUid
414
357
  */
415
-
416
358
  export function makeTagUid(tagUid) {
417
359
  if (tagUid === undefined || tagUid === null) {
418
360
  throw new TypeError('TagUid was expected but got undefined or null instead!');
419
361
  }
420
-
421
362
  if (isTag(tagUid)) {
422
363
  return tagUid.uid;
423
364
  } else if (typeof tagUid === 'number') {
@@ -425,27 +366,22 @@ export function makeTagUid(tagUid) {
425
366
  return tagUid;
426
367
  } else if (typeof tagUid === 'string') {
427
368
  const int = parseInt(tagUid);
428
-
429
369
  if (isNaN(int)) {
430
370
  throw new TypeError('Passed tagUid string is not valid integer!');
431
371
  }
432
-
433
372
  if (int < 0) {
434
373
  throw new TypeError(`TagUid was expected to be positive non-negative integer! Got ${int}`);
435
374
  }
436
-
437
375
  return int;
438
376
  }
439
-
440
377
  throw new TypeError('tagUid has to be either Tag or a number (UID)!');
441
378
  }
442
379
  export function assertTransactionHash(transactionHash) {
443
380
  if (typeof transactionHash !== 'string') {
444
381
  throw new TypeError('TransactionHash has to be a string!');
445
382
  }
446
-
447
- assertPrefixedHexString(transactionHash, 'TransactionHash'); // Hash is 64 long + '0x' prefix = 66
448
-
383
+ assertPrefixedHexString(transactionHash, 'TransactionHash');
384
+ // Hash is 64 long + '0x' prefix = 66
449
385
  if (transactionHash.length !== 66) {
450
386
  throw new TypeError('TransactionHash has to be prefixed hex string with total length 66 (prefix including)');
451
387
  }
@@ -1,7 +1,6 @@
1
1
  import { makeBytes } from "./bytes.js"; // TODO handle bigger values than 32 bit
2
2
  // For now it's good enough because we only use these functions
3
3
  // sequential feed indexes.
4
-
5
4
  export function writeUint64LittleEndian(value, bytes = makeBytes(8)) {
6
5
  const dataView = new DataView(bytes.buffer);
7
6
  const valueLower32 = value & 0xffffffff;
@@ -1,6 +1,5 @@
1
1
  import { BeeArgumentError } from "./error.js";
2
2
  import { isObject } from "./type.js";
3
-
4
3
  function isNodeJsError(e) {
5
4
  return isObject(e) && typeof e.code === 'string';
6
5
  }
@@ -10,16 +9,13 @@ function isNodeJsError(e) {
10
9
  *
11
10
  * @param url
12
11
  */
13
-
14
-
15
12
  export function isValidBeeUrl(url) {
16
13
  try {
17
14
  if (typeof url !== 'string') {
18
15
  return false;
19
16
  }
20
-
21
- const urlObject = new URL(url); // There can be wide range of protocols passed.
22
-
17
+ const urlObject = new URL(url);
18
+ // There can be wide range of protocols passed.
23
19
  return urlObject.protocol === 'http:' || urlObject.protocol === 'https:';
24
20
  } catch (e) {
25
21
  // URL constructor throws TypeError if not valid URL
@@ -27,7 +23,6 @@ export function isValidBeeUrl(url) {
27
23
  if (e instanceof TypeError || isNodeJsError(e) && e.code === 'ERR_INVALID_URL') {
28
24
  return false;
29
25
  }
30
-
31
26
  throw e;
32
27
  }
33
28
  }
@@ -37,7 +32,6 @@ export function isValidBeeUrl(url) {
37
32
  * @param url
38
33
  * @throws BeeArgumentError if non valid URL
39
34
  */
40
-
41
35
  export function assertBeeUrl(url) {
42
36
  if (!isValidBeeUrl(url)) {
43
37
  throw new BeeArgumentError('URL is not valid!', url);
@@ -47,11 +41,9 @@ export function assertBeeUrl(url) {
47
41
  * Removes trailing slash out of the given string.
48
42
  * @param url
49
43
  */
50
-
51
44
  export function stripLastSlash(url) {
52
45
  if (url.endsWith('/')) {
53
46
  return url.slice(0, -1);
54
47
  }
55
-
56
48
  return url;
57
49
  }
@@ -9,7 +9,7 @@ export declare class BeeDebug {
9
9
  * Ky instance that defines connection to Bee node
10
10
  * @private
11
11
  */
12
- private readonly ky;
12
+ private readonly kyOptions;
13
13
  constructor(url: string, options?: BeeOptions);
14
14
  getNodeAddresses(options?: RequestOptions): Promise<NodeAddresses>;
15
15
  getBlocklist(options?: RequestOptions): Promise<Peer[]>;
@@ -305,5 +305,5 @@ export declare class BeeDebug {
305
305
  */
306
306
  depositStake(amount: NumberString, options?: RequestOptions & TransactionOptions): Promise<void>;
307
307
  private waitForUsablePostageStamp;
308
- private getKy;
308
+ private getKyOptionsForCall;
309
309
  }
@@ -22,7 +22,7 @@ export declare class Bee {
22
22
  * Ky instance that defines connection to Bee node
23
23
  * @private
24
24
  */
25
- private readonly ky;
25
+ private readonly kyOptions;
26
26
  /**
27
27
  * @param url URL on which is the main API of Bee node exposed
28
28
  * @param options
@@ -176,8 +176,6 @@ export declare class Bee {
176
176
  /**
177
177
  * Create a new Tag which is meant for tracking progres of syncing data across network.
178
178
  *
179
- * **Warning! Not allowed when node is in Gateway mode!**
180
- *
181
179
  * @param options Options that affects the request behavior
182
180
  * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/access-the-swarm/syncing)
183
181
  * @see [Bee API reference - `POST /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post)
@@ -188,8 +186,6 @@ export declare class Bee {
188
186
  *
189
187
  * The listing is limited by options.limit. So you have to iterate using options.offset to get all tags.
190
188
  *
191
- * **Warning! Not allowed when node is in Gateway mode!**
192
- *
193
189
  * @param options Options that affects the request behavior
194
190
  * @throws TypeError if limit or offset are not numbers or undefined
195
191
  * @throws BeeArgumentError if limit or offset have invalid options
@@ -201,8 +197,6 @@ export declare class Bee {
201
197
  /**
202
198
  * Retrieve tag information from Bee node
203
199
  *
204
- * **Warning! Not allowed when node is in Gateway mode!**
205
- *
206
200
  * @param tagUid UID or tag object to be retrieved
207
201
  * @param options Options that affects the request behavior
208
202
  * @throws TypeError if tagUid is in not correct format
@@ -215,8 +209,6 @@ export declare class Bee {
215
209
  /**
216
210
  * Delete Tag
217
211
  *
218
- * **Warning! Not allowed when node is in Gateway mode!**
219
- *
220
212
  * @param tagUid UID or tag object to be retrieved
221
213
  * @param options Options that affects the request behavior
222
214
  * @throws TypeError if tagUid is in not correct format
@@ -232,8 +224,6 @@ export declare class Bee {
232
224
  * This is important if you are uploading individual chunks with a tag. Then upon finishing the final root chunk,
233
225
  * you can use this method to update the total chunks count for the tag.
234
226
  *
235
- * **Warning! Not allowed when node is in Gateway mode!**
236
- *
237
227
  * @param tagUid UID or tag object to be retrieved
238
228
  * @param reference The root reference that contains all the chunks to be counted
239
229
  * @param options Options that affects the request behavior
@@ -247,8 +237,6 @@ export declare class Bee {
247
237
  /**
248
238
  * Pin local data with given reference
249
239
  *
250
- * **Warning! Not allowed when node is in Gateway mode!**
251
- *
252
240
  * @param reference Data reference
253
241
  * @param options Options that affects the request behavior
254
242
  * @throws TypeError if reference is in not correct format
@@ -259,8 +247,6 @@ export declare class Bee {
259
247
  /**
260
248
  * Unpin local data with given reference
261
249
  *
262
- * **Warning! Not allowed when node is in Gateway mode!**
263
- *
264
250
  * @param reference Data reference
265
251
  * @param options Options that affects the request behavior
266
252
  * @throws TypeError if reference is in not correct format
@@ -271,8 +257,6 @@ export declare class Bee {
271
257
  /**
272
258
  * Get list of all locally pinned references
273
259
  *
274
- * **Warning! Not allowed when node is in Gateway mode!**
275
- *
276
260
  * @param options Options that affects the request behavior
277
261
  * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/access-the-swarm/pinning)
278
262
  */
@@ -280,8 +264,6 @@ export declare class Bee {
280
264
  /**
281
265
  * Get pinning status of chunk with given reference
282
266
  *
283
- * **Warning! Not allowed when node is in Gateway mode!**
284
- *
285
267
  * @param reference Bee data reference in hex string (either 64 or 128 chars long) or ENS domain.
286
268
  * @param options Options that affects the request behavior
287
269
  * @throws TypeError if some of the input parameters is not expected type
@@ -337,8 +319,6 @@ export declare class Bee {
337
319
  * most likely for setting up an encrypted communication
338
320
  * channel by sending an one-off message.
339
321
  *
340
- * **Warning! Not allowed when node is in Gateway mode!**
341
- *
342
322
  * **Warning! If the recipient Bee node is a light node, then he will never receive the message!**
343
323
  * This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.
344
324
  *
@@ -357,8 +337,6 @@ export declare class Bee {
357
337
  /**
358
338
  * Subscribe to messages for given topic with Postal Service for Swarm
359
339
  *
360
- * **Warning! Not allowed when node is in Gateway mode!**
361
- *
362
340
  * **Warning! If connected Bee node is a light node, then he will never receive any message!**
363
341
  * This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.
364
342
  *
@@ -384,8 +362,6 @@ export declare class Bee {
384
362
  * timeout can be provided for the message to arrive or else
385
363
  * an error will be thrown.
386
364
  *
387
- * **Warning! Not allowed when node is in Gateway mode!**
388
- *
389
365
  * **Warning! If connected Bee node is a light node, then he will never receive any message!**
390
366
  * This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.
391
367
  *
@@ -519,5 +495,5 @@ export declare class Bee {
519
495
  * @throws BeeError if either no Signer was passed or no default Signer was specified for the instance
520
496
  */
521
497
  private resolveSigner;
522
- private getKy;
498
+ private getKyOptionsForCall;
523
499
  }
@@ -17,7 +17,7 @@ export interface Chunk {
17
17
  payload(): FlexBytes<1, 4096>;
18
18
  address(): PlainBytesReference;
19
19
  }
20
- declare type ValidChunkData = BrandedType<Uint8Array, 'ValidChunkData'>;
20
+ type ValidChunkData = BrandedType<Uint8Array, 'ValidChunkData'>;
21
21
  /**
22
22
  * Creates a content addressed chunk and verifies the payload size.
23
23
  *
@@ -1,8 +1,9 @@
1
1
  import { Bytes } from '../utils/bytes';
2
2
  import { Chunk } from './cac';
3
- import { UploadOptions, Signature, Signer, BatchId, Reference, Ky, PlainBytesReference } from '../types';
3
+ import { UploadOptions, Signature, Signer, BatchId, Reference, PlainBytesReference } from '../types';
4
4
  import { EthAddress } from '../utils/eth';
5
- export declare type Identifier = Bytes<32>;
5
+ import type { Options as KyOptions } from 'ky';
6
+ export type Identifier = Bytes<32>;
6
7
  /**
7
8
  * With single owner chunks, a user can assign arbitrary data to an
8
9
  * address and attest chunk integrity with their digital signature.
@@ -39,23 +40,23 @@ export declare function makeSingleOwnerChunk(chunk: Chunk, identifier: Identifie
39
40
  *
40
41
  * It uses the Chunk API and calculates the address before uploading.
41
42
  *
42
- * @param ky Ky instance
43
+ * @param kyOptions Ky Options for making requests
43
44
  * @param chunk A chunk object
44
45
  * @param postageBatchId Postage BatchId that will be assigned to uploaded data
45
46
  * @param options Upload options
46
47
  */
47
- export declare function uploadSingleOwnerChunk(ky: Ky, chunk: SingleOwnerChunk, postageBatchId: BatchId, options?: UploadOptions): Promise<Reference>;
48
+ export declare function uploadSingleOwnerChunk(kyOptions: KyOptions, chunk: SingleOwnerChunk, postageBatchId: BatchId, options?: UploadOptions): Promise<Reference>;
48
49
  /**
49
50
  * Helper function to create and upload SOC.
50
51
  *
51
- * @param ky Ky instance
52
+ * @param kyOptions Ky Options for making requests
52
53
  * @param signer The singer interface for signing the chunk
53
54
  * @param postageBatchId
54
55
  * @param identifier The identifier of the chunk
55
56
  * @param data The chunk data
56
57
  * @param options
57
58
  */
58
- export declare function uploadSingleOwnerChunkData(ky: Ky, signer: Signer, postageBatchId: BatchId | string, identifier: Identifier, data: Uint8Array, options?: UploadOptions): Promise<Reference>;
59
+ export declare function uploadSingleOwnerChunkData(kyOptions: KyOptions, signer: Signer, postageBatchId: BatchId | string, identifier: Identifier, data: Uint8Array, options?: UploadOptions): Promise<Reference>;
59
60
  /**
60
61
  * Helper function to download SOC.
61
62
  *
@@ -63,4 +64,4 @@ export declare function uploadSingleOwnerChunkData(ky: Ky, signer: Signer, posta
63
64
  * @param ownerAddress The singer interface for signing the chunk
64
65
  * @param identifier The identifier of the chunk
65
66
  */
66
- export declare function downloadSingleOwnerChunk(ky: Ky, ownerAddress: EthAddress, identifier: Identifier): Promise<SingleOwnerChunk>;
67
+ export declare function downloadSingleOwnerChunk(kyOptions: KyOptions, ownerAddress: EthAddress, identifier: Identifier): Promise<SingleOwnerChunk>;
@@ -1,8 +1,9 @@
1
1
  import { FeedUpdateOptions } from '../modules/feed';
2
- import { BatchId, BytesReference, FEED_INDEX_HEX_LENGTH, FeedReader, FeedWriter, Ky, PlainBytesReference, Reference, Signer, Topic, UploadOptions } from '../types';
2
+ import { BatchId, BytesReference, FEED_INDEX_HEX_LENGTH, FeedReader, FeedWriter, PlainBytesReference, Reference, Signer, Topic, UploadOptions } from '../types';
3
3
  import { Bytes } from '../utils/bytes';
4
4
  import { HexString } from '../utils/hex';
5
5
  import { EthAddress, HexEthAddress } from '../utils/eth';
6
+ import type { Options as KyOptions } from 'ky';
6
7
  import type { FeedType } from './type';
7
8
  export interface Epoch {
8
9
  time: number;
@@ -12,17 +13,17 @@ export interface Epoch {
12
13
  * Bytes of Feed's Index.
13
14
  * For Sequential Feeds this is numeric value in big-endian.
14
15
  */
15
- export declare type IndexBytes = Bytes<8>;
16
- export declare type Index = number | Epoch | IndexBytes | string;
16
+ export type IndexBytes = Bytes<8>;
17
+ export type Index = number | Epoch | IndexBytes | string;
17
18
  export interface FeedUploadOptions extends UploadOptions, FeedUpdateOptions {
18
19
  }
19
20
  export interface FeedUpdate {
20
21
  timestamp: number;
21
22
  reference: BytesReference;
22
23
  }
23
- export declare function findNextIndex(ky: Ky, owner: HexEthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<HexString<typeof FEED_INDEX_HEX_LENGTH>>;
24
- export declare function updateFeed(ky: Ky, signer: Signer, topic: Topic, reference: BytesReference, postageBatchId: BatchId, options?: FeedUploadOptions, index?: Index): Promise<Reference>;
24
+ export declare function findNextIndex(kyOptions: KyOptions, owner: HexEthAddress, topic: Topic, options?: FeedUpdateOptions): Promise<HexString<typeof FEED_INDEX_HEX_LENGTH>>;
25
+ export declare function updateFeed(kyOptions: KyOptions, signer: Signer, topic: Topic, reference: BytesReference, postageBatchId: BatchId, options?: FeedUploadOptions, index?: Index): Promise<Reference>;
25
26
  export declare function getFeedUpdateChunkReference(owner: EthAddress, topic: Topic, index: Index): PlainBytesReference;
26
- export declare function downloadFeedUpdate(ky: Ky, owner: EthAddress, topic: Topic, index: Index): Promise<FeedUpdate>;
27
- export declare function makeFeedReader(ky: Ky, type: FeedType, topic: Topic, owner: HexEthAddress): FeedReader;
28
- export declare function makeFeedWriter(ky: Ky, type: FeedType, topic: Topic, signer: Signer): FeedWriter;
27
+ export declare function downloadFeedUpdate(kyOptions: KyOptions, owner: EthAddress, topic: Topic, index: Index): Promise<FeedUpdate>;
28
+ export declare function makeFeedReader(kyOptions: KyOptions, type: FeedType, topic: Topic, owner: HexEthAddress): FeedReader;
29
+ export declare function makeFeedWriter(kyOptions: KyOptions, type: FeedType, topic: Topic, signer: Signer): FeedWriter;
@@ -1,5 +1,5 @@
1
1
  declare const feedTypes: readonly ["sequence", "epoch"];
2
- export declare type FeedType = typeof feedTypes[number];
2
+ export type FeedType = typeof feedTypes[number];
3
3
  export declare const DEFAULT_FEED_TYPE: FeedType;
4
4
  export declare function isFeedType(type: unknown): type is FeedType;
5
5
  export declare function assertFeedType(type: unknown): asserts type is FeedType;