@solarpunkltd/swarm-id 0.0.0-stage → 0.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.
Files changed (111) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +86 -2
  3. package/dist/bus/account-bus.d.ts +104 -0
  4. package/dist/bus/account-delta.d.ts +52 -0
  5. package/dist/bus/bus-context.d.ts +7 -0
  6. package/dist/bus/envelope.d.ts +9 -0
  7. package/dist/bus/messages.d.ts +241 -0
  8. package/dist/bus/presence.d.ts +62 -0
  9. package/dist/bus/signaling-transport.d.ts +79 -0
  10. package/dist/chunk/bmt.d.ts +16 -0
  11. package/dist/chunk/cac.d.ts +17 -0
  12. package/dist/chunk/constants.d.ts +10 -0
  13. package/dist/chunk/encrypted-cac.d.ts +47 -0
  14. package/dist/chunk/encryption.d.ts +85 -0
  15. package/dist/chunk/index.d.ts +5 -0
  16. package/dist/chunks/chat-binding-DlH_ZkTn.js +23 -0
  17. package/dist/chunks/chat-binding-DlH_ZkTn.js.map +1 -0
  18. package/dist/errors.d.ts +35 -0
  19. package/dist/index.d.ts +27 -0
  20. package/dist/internal.d.ts +49 -0
  21. package/dist/internal.esm.js +2 -0
  22. package/dist/internal.esm.js.map +1 -0
  23. package/dist/proxy/act/act.d.ts +58 -0
  24. package/dist/proxy/act/crypto.d.ts +46 -0
  25. package/dist/proxy/act/grantee-list.d.ts +81 -0
  26. package/dist/proxy/act/history.d.ts +182 -0
  27. package/dist/proxy/act/index.d.ts +114 -0
  28. package/dist/proxy/app-stamp-limits.d.ts +62 -0
  29. package/dist/proxy/chunk-upload-stream.d.ts +37 -0
  30. package/dist/proxy/chunking.d.ts +15 -0
  31. package/dist/proxy/collection.d.ts +38 -0
  32. package/dist/proxy/download-data.d.ts +27 -0
  33. package/dist/proxy/errors.d.ts +8 -0
  34. package/dist/proxy/feed-manifest.d.ts +60 -0
  35. package/dist/proxy/feeds/epochs/async-finder.d.ts +70 -0
  36. package/dist/proxy/feeds/epochs/epoch.d.ts +79 -0
  37. package/dist/proxy/feeds/epochs/finder.d.ts +60 -0
  38. package/dist/proxy/feeds/epochs/index.d.ts +30 -0
  39. package/dist/proxy/feeds/epochs/types.d.ts +110 -0
  40. package/dist/proxy/feeds/epochs/updater.d.ts +76 -0
  41. package/dist/proxy/feeds/epochs/utils.d.ts +21 -0
  42. package/dist/proxy/feeds/index.d.ts +4 -0
  43. package/dist/proxy/feeds/sequence/async-finder.d.ts +14 -0
  44. package/dist/proxy/feeds/sequence/finder.d.ts +11 -0
  45. package/dist/proxy/feeds/sequence/index.d.ts +22 -0
  46. package/dist/proxy/feeds/sequence/types.d.ts +82 -0
  47. package/dist/proxy/feeds/sequence/updater.d.ts +20 -0
  48. package/dist/proxy/index.d.ts +5 -0
  49. package/dist/proxy/manifest-builder.d.ts +164 -0
  50. package/dist/proxy/mantaray.d.ts +76 -0
  51. package/dist/proxy/soc-restamp-slots.d.ts +48 -0
  52. package/dist/proxy/stamp-chunk.d.ts +45 -0
  53. package/dist/proxy/stamp-worker-handler.d.ts +32 -0
  54. package/dist/proxy/stamp-worker-pool.d.ts +52 -0
  55. package/dist/proxy/stamp-worker.d.ts +1 -0
  56. package/dist/proxy/types.d.ts +38 -0
  57. package/dist/proxy/upload.d.ts +207 -0
  58. package/dist/schemas.d.ts +665 -0
  59. package/dist/stamp-worker.iife.js +1 -0
  60. package/dist/storage/debounced-uploader.d.ts +61 -0
  61. package/dist/storage/utilization-store.d.ts +113 -0
  62. package/dist/swarm-id-client.d.ts +1114 -0
  63. package/dist/swarm-id-proxy.d.ts +1031 -0
  64. package/dist/swarm-id.esm.js +2 -0
  65. package/dist/swarm-id.esm.js.map +1 -0
  66. package/dist/sync/batch-write-coordinator.d.ts +347 -0
  67. package/dist/sync/device-roster.d.ts +59 -0
  68. package/dist/sync/device-state.d.ts +199 -0
  69. package/dist/sync/fold-account-from-swarm.d.ts +53 -0
  70. package/dist/sync/index.d.ts +11 -0
  71. package/dist/sync/merge-snapshot.d.ts +57 -0
  72. package/dist/sync/partition-intent.d.ts +218 -0
  73. package/dist/sync/partition-lease.d.ts +531 -0
  74. package/dist/sync/partition-lock.d.ts +218 -0
  75. package/dist/sync/partition-state.d.ts +287 -0
  76. package/dist/sync/session-check.d.ts +29 -0
  77. package/dist/sync/store-interfaces.d.ts +48 -0
  78. package/dist/sync/sync-account.d.ts +45 -0
  79. package/dist/sync/timing-constants.d.ts +32 -0
  80. package/dist/sync/types.d.ts +18 -0
  81. package/dist/types.d.ts +3007 -0
  82. package/dist/utils/account-state-snapshot.d.ts +43 -0
  83. package/dist/utils/active-devices.d.ts +45 -0
  84. package/dist/utils/avatar.d.ts +30 -0
  85. package/dist/utils/batch-utilization.d.ts +840 -0
  86. package/dist/utils/batch-write-lock.d.ts +12 -0
  87. package/dist/utils/bee-error.d.ts +11 -0
  88. package/dist/utils/chat-binding.d.ts +113 -0
  89. package/dist/utils/coalesced-task.d.ts +28 -0
  90. package/dist/utils/collection.d.ts +6 -0
  91. package/dist/utils/connection-info.d.ts +11 -0
  92. package/dist/utils/constants.d.ts +28 -0
  93. package/dist/utils/device-id.d.ts +109 -0
  94. package/dist/utils/hex.d.ts +31 -0
  95. package/dist/utils/json-rpc.d.ts +34 -0
  96. package/dist/utils/key-derivation.d.ts +124 -0
  97. package/dist/utils/lock-soc.d.ts +35 -0
  98. package/dist/utils/postage-contract.d.ts +143 -0
  99. package/dist/utils/postage-stamp-association.d.ts +39 -0
  100. package/dist/utils/promise.d.ts +37 -0
  101. package/dist/utils/sealed-values.d.ts +23 -0
  102. package/dist/utils/seed-encryption.d.ts +17 -0
  103. package/dist/utils/site-allow-list.d.ts +54 -0
  104. package/dist/utils/stamp-lifespan.d.ts +37 -0
  105. package/dist/utils/storage-managers.d.ts +62 -0
  106. package/dist/utils/storage-probe.d.ts +40 -0
  107. package/dist/utils/tag.d.ts +11 -0
  108. package/dist/utils/ttl.d.ts +120 -0
  109. package/dist/utils/url.d.ts +47 -0
  110. package/dist/utils/versioned-storage.d.ts +183 -0
  111. package/package.json +91 -3
@@ -0,0 +1,1114 @@
1
+ import type { ClientOptions, ConnectOptions, AuthStatus, Avatar, ConnectionInfo, UploadResult, FileData, UploadOptions, UploadFilesOptions, CollectionFileInput, CollectionEntry, ActUploadOptions, DownloadOptions, RequestOptions, Reference, SOCReader, SOCWriter, FeedReaderOptions, FeedWriterOptions, FeedReader, FeedWriter, SequentialFeedReaderOptions, SequentialFeedWriterOptions, SequentialFeedReader, SequentialFeedWriter, StampChunkInput, StampedChunk, PostageBatch } from "./types";
2
+ import { EthAddress, PrivateKey } from "@ethersphere/bee-js";
3
+ /**
4
+ * Main client library for integrating Swarm ID authentication and storage capabilities
5
+ * into web applications.
6
+ *
7
+ * SwarmIdClient enables parent windows to interact with a Swarm ID iframe proxy,
8
+ * providing secure authentication, identity management, and data upload/download
9
+ * functionality to the Swarm decentralized storage network.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const client = new SwarmIdClient({
14
+ * iframeOrigin: 'https://swarm-id.example.com',
15
+ * metadata: {
16
+ * name: 'My App',
17
+ * description: 'A decentralized application'
18
+ * },
19
+ * onConnectionChange: (info) => {
20
+ * console.log('Connection changed:', info.identity?.name, info.canUpload)
21
+ * }
22
+ * })
23
+ *
24
+ * await client.initialize()
25
+ *
26
+ * // Check canUpload — an authenticated user can still lack upload capability
27
+ * // when they have no postage stamp and no subsidised gateway is configured.
28
+ * if (client.connectionInfo.identity && client.connectionInfo.canUpload) {
29
+ * const result = await client.uploadData(new Uint8Array([1, 2, 3]))
30
+ * console.log('Uploaded with reference:', result.reference)
31
+ * }
32
+ * ```
33
+ */
34
+ export declare class SwarmIdClient {
35
+ private iframe;
36
+ private iframeOrigin;
37
+ private iframePath;
38
+ private timeout;
39
+ private initializationTimeout;
40
+ private onConnectionChange?;
41
+ private lastConnectionInfo;
42
+ private firstConnectionInfoPromise;
43
+ private firstConnectionInfoResolve?;
44
+ private firstConnectionInfoReject?;
45
+ private iframeLoadReject?;
46
+ private popupMode;
47
+ private metadata;
48
+ private buttonConfig?;
49
+ private containerId?;
50
+ private subsidisedGatewayUrl?;
51
+ private ready;
52
+ /**
53
+ * Whether the proxy iframe can read the trusted domain's first-party store,
54
+ * as reported on `proxyReady`. Decides which transport `connect()` uses
55
+ * (#613); undefined against a proxy that predates the field, which reads as
56
+ * "not proven shared".
57
+ */
58
+ private storageShared;
59
+ private readyPromise;
60
+ private readyResolve?;
61
+ private readyReject?;
62
+ private pendingRequests;
63
+ /**
64
+ * Progress callbacks of in-flight uploads, by request id. Dispatched from
65
+ * the one window listener, so progress passes the same source and origin
66
+ * checks as every other message from the iframe.
67
+ */
68
+ private progressListeners;
69
+ private requestIdCounter;
70
+ private messageListener;
71
+ private proxyInitializedPromise;
72
+ private proxyInitializedResolve?;
73
+ private proxyInitializedReject?;
74
+ /**
75
+ * Creates a new SwarmIdClient instance.
76
+ *
77
+ * @param options - Configuration options for the client
78
+ * @param options.iframeOrigin - The origin URL where the Swarm ID proxy iframe is hosted
79
+ * @param options.iframePath - The path to the proxy iframe (defaults to "/proxy")
80
+ * @param options.timeout - Request timeout in milliseconds (defaults to 30000). Bounds each call's whole round trip through the iframe; a call's own `requestOptions.timeout` replaces it for that call
81
+ * @param options.onConnectionChange - Callback invoked when the dApp-visible ConnectionInfo changes (identity, stamp, account type, auth)
82
+ * @param options.popupMode - How to display the authentication popup: "popup" or "window" (defaults to "window")
83
+ * @param options.metadata - Application metadata shown to users during authentication
84
+ * @param options.metadata.name - Application name (1-100 characters)
85
+ * @param options.metadata.description - Optional application description (max 500 characters)
86
+ * @param options.metadata.icon - Optional application icon as a data URL (SVG or PNG, max 4KB)
87
+ * @param options.buttonConfig - Button configuration for the authentication UI (optional)
88
+ * @param options.buttonConfig.connectText - Text for the connect button (optional)
89
+ * @param options.buttonConfig.disconnectText - Text for the disconnect button (optional)
90
+ * @param options.buttonConfig.loadingText - Text shown during loading (optional)
91
+ * @param options.buttonConfig.backgroundColor - Background color for buttons (optional)
92
+ * @param options.buttonConfig.color - Text color for buttons (optional)
93
+ * @param options.buttonConfig.borderRadius - Border radius for buttons and iframe (optional)
94
+ * @param options.buttonConfig.fontFamily - CSS font-family for the button, so it can match the embedding page; a font stack falls back as usual (optional)
95
+ * @param options.buttonConfig.fontSize - CSS font-size for the button; the default floating iframe is a fixed 300x50 px and hides its overflow, so a size that does not fit is clipped — pass `containerId` to own the box (optional)
96
+ * @param options.buttonConfig.fontWeight - CSS font-weight for the button, as a keyword or a number (optional)
97
+ * @param options.containerId - ID of container element to place iframe in (optional)
98
+ * @throws {Error} If constructed where there is no `window` (a server render)
99
+ * @throws {SwarmIdError} `invalid-request` if the provided app metadata is invalid
100
+ */
101
+ constructor(options: ClientOptions);
102
+ /**
103
+ * Initializes the client by creating and embedding the proxy iframe.
104
+ *
105
+ * This method must be called before using any other client methods.
106
+ * It creates a hidden iframe, waits for the proxy to initialize,
107
+ * identifies the parent application to the proxy, and waits for
108
+ * the proxy to signal readiness.
109
+ *
110
+ * @returns A promise that resolves when the client is fully initialized
111
+ * @throws {SwarmIdError} `invalid-state` if the client is already initialized, or `destroy()` runs before it resolves
112
+ * @throws {SwarmIdError} `invalid-request` if `containerId` names no element
113
+ * @throws {SwarmIdError} `init-failed` if the iframe fails to load, origin validation fails on the proxy side, or the proxy does not respond within `initializationTimeout` (30 seconds by default)
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const client = new SwarmIdClient({ ... })
118
+ * try {
119
+ * await client.initialize()
120
+ * console.log('Client ready')
121
+ * } catch (error) {
122
+ * console.error('Failed to initialize:', error)
123
+ * }
124
+ * ```
125
+ */
126
+ initialize(): Promise<void>;
127
+ /**
128
+ * Setup message listener for iframe responses
129
+ */
130
+ private setupMessageListener;
131
+ /**
132
+ * Handle messages from iframe
133
+ */
134
+ private handleIframeMessage;
135
+ /**
136
+ * Send message to iframe
137
+ */
138
+ private sendMessage;
139
+ /**
140
+ * Send request and wait for response
141
+ */
142
+ private sendRequest;
143
+ /**
144
+ * The round-trip bound for one call, from its own `requestOptions.timeout`.
145
+ *
146
+ * Only a value `setTimeout` can honour is taken. Zero and negatives mean
147
+ * "no timeout" to Bee, which is where this option went before it also bound
148
+ * the round trip — taken literally here they would reject on the next tick,
149
+ * the opposite of what the caller asked, so they fall back to the client
150
+ * default and still reach Bee unchanged. A value past the 32-bit timer
151
+ * ceiling means "as long as it takes", and `setTimeout` would wrap it into
152
+ * firing almost at once, so it clamps to the ceiling instead. `Infinity` and
153
+ * `NaN` never get this far: `z.number()` rejects them on the way out.
154
+ */
155
+ private roundTripTimeout;
156
+ /**
157
+ * Generate unique request ID
158
+ */
159
+ private generateRequestId;
160
+ private normalizeSocIdentifier;
161
+ private normalizeSocKey;
162
+ private normalizeFeedTopic;
163
+ private normalizeReference;
164
+ private normalizeFeedTimestamp;
165
+ private normalizeFeedIndex;
166
+ private normalizePayload;
167
+ private socChunkFromResponse;
168
+ /**
169
+ * Ensure client is initialized
170
+ */
171
+ private ensureReady;
172
+ /**
173
+ * Returns the authentication iframe element.
174
+ *
175
+ * The iframe displays authentication UI based on the current auth status:
176
+ * - If not authenticated: shows a "Connect" button
177
+ * - If authenticated: shows identity info and a "Disconnect" button
178
+ *
179
+ * The iframe is positioned fixed in the bottom-right corner of the viewport.
180
+ *
181
+ * @returns The iframe element displaying the authentication UI
182
+ * @throws {SwarmIdError} `invalid-state` if the client is not initialized, or the iframe is not available
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const iframe = client.getAuthIframe()
187
+ * // The iframe is already displayed; this returns a reference to it
188
+ * ```
189
+ */
190
+ getAuthIframe(): HTMLIFrameElement;
191
+ /**
192
+ * Checks the current authentication status with the Swarm ID proxy.
193
+ *
194
+ * @returns A promise resolving to the authentication status object
195
+ * @returns return.authenticated - Whether the user is currently authenticated
196
+ * @returns return.origin - The origin that authenticated (if authenticated)
197
+ * @throws {Error} If the client is not initialized
198
+ * @throws {Error} If the request times out
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const status = await client.checkAuthStatus()
203
+ * if (status.authenticated) {
204
+ * console.log('Authenticated from:', status.origin)
205
+ * }
206
+ * ```
207
+ */
208
+ checkAuthStatus(): Promise<AuthStatus>;
209
+ /**
210
+ * Gets the current postage batch for the authenticated identity.
211
+ *
212
+ * Returns information about the postage stamp associated with the
213
+ * connected identity, including batch ID, utilization, depth, and TTL.
214
+ *
215
+ * @returns A promise resolving to the PostageBatch or undefined if none is configured
216
+ * @throws {Error} If the client is not initialized
217
+ * @throws {Error} If the request times out
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const batch = await client.getPostageBatch()
222
+ * if (batch) {
223
+ * console.log('Batch ID:', batch.batchID)
224
+ * console.log('Utilization:', batch.utilization)
225
+ * console.log('Depth:', batch.depth)
226
+ * console.log('TTL:', batch.batchTTL)
227
+ * } else {
228
+ * console.log('No postage batch configured')
229
+ * }
230
+ * ```
231
+ */
232
+ getPostageBatch(): Promise<PostageBatch | undefined>;
233
+ /**
234
+ * Disconnects the current session and clears authentication data.
235
+ *
236
+ * After disconnection, the user will need to re-authenticate to perform
237
+ * uploads or access identity-related features. The
238
+ * {@link ClientOptions.onConnectionChange} callback will fire with an
239
+ * un-authenticated snapshot.
240
+ *
241
+ * @returns A promise that resolves when disconnection is complete
242
+ * @throws {SwarmIdError} `invalid-state` if the client is not initialized
243
+ * @throws {SwarmIdError} `internal` if the proxy reports the disconnect failed
244
+ * @throws {SwarmIdError} `timeout` if the request times out
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * await client.disconnect()
249
+ * console.log('User logged out')
250
+ * ```
251
+ */
252
+ disconnect(): Promise<void>;
253
+ /**
254
+ * Opens the Swarm ID authentication page in a new window.
255
+ *
256
+ * This method creates the same authentication URL as used by the iframe
257
+ * proxy and opens it in a new browser window. The user can authenticate
258
+ * with their Swarm ID, and the resulting authentication will be available
259
+ * to the client when they return.
260
+ *
261
+ * **Which window opens it** is decided by the iframe's STORAGE, not by the
262
+ * user agent (#613):
263
+ * - Shared storage: opened here, from the parent, so the click's activation is
264
+ * still unspent. The popup writes the connection to the first-party store
265
+ * the iframe reads, and a `storage` event carries it across.
266
+ * - Partitioned, or not proven shared: the proxy opens it, so the popup's
267
+ * `window.opener` points back at the iframe and the session can be handed
268
+ * over directly — the only channel into a partitioned frame. The session
269
+ * is then kept in that partition's own store until it is disconnected or
270
+ * its 7 days are up (#635), so a reload does not re-run this; a handover
271
+ * that arrives without the account view is refused outright rather than
272
+ * producing a session that cannot upload and cannot hear a revoke. A popup
273
+ * blocked on this path falls back to opening from the parent.
274
+ *
275
+ * Safari private mode sessions are ephemeral (lost when the private window
276
+ * closes). The whole partitioned path — handover, stamper, upload — is
277
+ * confirmed on real Safari; see
278
+ * https://github.com/snaha/swarm-id/issues/584
279
+ *
280
+ * @param options - Configuration options for the connect flow
281
+ * @throws {SwarmIdError} `invalid-state` if the client is not initialized
282
+ * @throws {SwarmIdError} `popup-blocked` if the browser blocks the popup
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * const client = new SwarmIdClient({ ... })
287
+ * await client.initialize()
288
+ *
289
+ * // Open authentication page
290
+ * await client.connect()
291
+ * ```
292
+ */
293
+ connect(options?: ConnectOptions): Promise<void>;
294
+ /**
295
+ * Open the auth popup from the dApp page.
296
+ *
297
+ * Carries no challenge: a popup opened here has the dApp page as its
298
+ * `window.opener`, so there is nothing for a handover to attach to, and the
299
+ * popup falls back to the storage write it does anyway.
300
+ *
301
+ * @returns whether the popup opened — a blocked one returns null, which the
302
+ * caller must not report as a connect in progress.
303
+ */
304
+ private openAuthWindow;
305
+ /**
306
+ * Current dApp-visible {@link ConnectionInfo} snapshot — identity, app key,
307
+ * upload capability, and upload mode. Populated by the proxy as soon as it
308
+ * is ready and refreshed whenever any of those derived fields change.
309
+ * Subscribe to {@link ClientOptions.onConnectionChange} to react to updates.
310
+ *
311
+ * @throws {SwarmIdError} `invalid-state` if {@link initialize} has not resolved yet
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * await client.initialize()
316
+ * const info = client.connectionInfo
317
+ * if (info.canUpload) {
318
+ * console.log('Ready to upload as:', info.identity?.name)
319
+ * }
320
+ * ```
321
+ */
322
+ get connectionInfo(): ConnectionInfo;
323
+ /**
324
+ * Avatar of the connected identity at a specific size.
325
+ *
326
+ * Most callers want `connectionInfo.identity.avatar` instead — it is already
327
+ * resolved on every snapshot and needs no call. Reach for this only to
328
+ * render at a size the default does not suit. Async so that honouring a size
329
+ * may involve fetching, which anything but the generated avatar would.
330
+ *
331
+ * @param options.size - Width and height in pixels
332
+ * @returns The avatar, or `undefined` when no identity is connected
333
+ */
334
+ getAvatar(options?: {
335
+ size?: number;
336
+ }): Promise<Avatar | undefined>;
337
+ /**
338
+ * Checks whether the Bee node is reachable.
339
+ *
340
+ * This method never throws an exception. If the client is not initialized,
341
+ * the request times out, or any other error occurs, it returns `false`.
342
+ *
343
+ * @returns A promise resolving to `true` if the Bee node is reachable, `false` otherwise
344
+ *
345
+ * @example
346
+ * ```typescript
347
+ * const connected = await client.isBeeConnected()
348
+ * if (connected) {
349
+ * console.log('Bee node is online')
350
+ * } else {
351
+ * console.log('Bee node is offline')
352
+ * }
353
+ * ```
354
+ */
355
+ isBeeConnected(): Promise<boolean>;
356
+ /**
357
+ * Gets information about the Bee node configuration.
358
+ *
359
+ * Needs a real Bee node: the public gateway has no `/node` endpoint, so this
360
+ * rejects there. Do not gate uploads on it — it exists to detect a dev-mode
361
+ * node, where deferred uploads are required.
362
+ *
363
+ * This method retrieves the current Bee node's operating mode and feature flags.
364
+ * Use this to determine if deferred uploads are required (dev mode) or if direct
365
+ * uploads are available (production modes).
366
+ *
367
+ * @returns A promise resolving to the node info object
368
+ * @returns return.beeMode - The Bee node operating mode ("dev", "light", "full", "ultra-light")
369
+ * @returns return.chequebookEnabled - Whether the chequebook is enabled
370
+ * @returns return.swapEnabled - Whether SWAP is enabled
371
+ * @throws {Error} If the client is not initialized
372
+ * @throws {Error} If the Bee node is not reachable
373
+ * @throws {Error} If the request times out
374
+ *
375
+ * @example
376
+ * ```typescript
377
+ * const nodeInfo = await client.getNodeInfo()
378
+ * if (nodeInfo.beeMode === 'dev') {
379
+ * // Dev mode requires deferred uploads
380
+ * await client.uploadData(data, { deferred: true })
381
+ * } else {
382
+ * // Production modes can use direct uploads
383
+ * await client.uploadData(data, { deferred: false })
384
+ * }
385
+ * ```
386
+ */
387
+ getNodeInfo(): Promise<{
388
+ beeMode: string;
389
+ chequebookEnabled: boolean;
390
+ swapEnabled: boolean;
391
+ }>;
392
+ /**
393
+ * Uploads raw binary data to the Swarm network.
394
+ *
395
+ * Read the returned reference back with {@link downloadData}, or from a
396
+ * gateway at `/bytes/<reference>`. It carries no manifest, so
397
+ * {@link downloadFile} and `/bzz/` cannot resolve it.
398
+ *
399
+ * The data is uploaded using the authenticated user's postage stamp.
400
+ * Progress can be tracked via the optional callback.
401
+ *
402
+ * @param data - The binary data to upload as a Uint8Array
403
+ * @param options - Optional upload configuration
404
+ * @param options.pin - Whether to pin the data locally (defaults to false; ignored on a subsidised gateway)
405
+ * @param options.encrypt - Whether to encrypt the data (defaults to false)
406
+ * @param options.tag - Tag ID for tracking upload progress
407
+ * @param options.deferred - Whether to use deferred upload (defaults to false)
408
+ * @param options.onProgress - Optional callback for tracking upload progress
409
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
410
+ * @returns A promise resolving to the upload result
411
+ * @returns return.reference - The Swarm reference (hash) of the uploaded data
412
+ * @returns return.tagUid - The tag UID if a tag was created
413
+ * @throws {Error} If the client is not initialized
414
+ * @throws {Error} If the user is not authenticated or cannot upload
415
+ * @throws {Error} If the request times out
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * const data = new TextEncoder().encode('Hello, Swarm!')
420
+ * const result = await client.uploadData(data, {
421
+ * encrypt: true,
422
+ * onProgress: (progress) => {
423
+ * console.log(`Progress: ${progress.processed}/${progress.total}`)
424
+ * },
425
+ * })
426
+ * console.log('Reference:', result.reference)
427
+ * ```
428
+ */
429
+ uploadData(data: Uint8Array, options?: UploadOptions, requestOptions?: RequestOptions): Promise<UploadResult>;
430
+ /**
431
+ * Downloads raw binary data from the Swarm network: the counterpart of
432
+ * {@link uploadData}. Pass an encrypted (128-hex) reference here rather
433
+ * than putting it in a gateway URL — it contains the decryption key.
434
+ *
435
+ * @param reference - The Swarm reference (hash) of the data to download.
436
+ * Can be 64 hex chars (32 bytes) or 128 hex chars (64 bytes for encrypted)
437
+ * @param options - Optional download configuration
438
+ * @param options.redundancyStrategy - Strategy for handling redundancy (0-3)
439
+ * @param options.fallback - Whether to use fallback retrieval
440
+ * @param options.timeoutMs - Download timeout in milliseconds
441
+ * @param options.actPublisher - ACT publisher for encrypted content
442
+ * @param options.actHistoryAddress - ACT history address for encrypted content
443
+ * @param options.actTimestamp - ACT timestamp for encrypted content
444
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
445
+ * @returns A promise resolving to the downloaded data as a Uint8Array
446
+ * @throws {Error} If the client is not initialized
447
+ * @throws {Error} If the reference is not found
448
+ * @throws {Error} If the request times out
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * const data = await client.downloadData('a1b2c3...') // 64 char hex reference
453
+ * const text = new TextDecoder().decode(data)
454
+ * console.log('Downloaded:', text)
455
+ * ```
456
+ */
457
+ downloadData(reference: Reference, options?: DownloadOptions, requestOptions?: RequestOptions): Promise<Uint8Array>;
458
+ /**
459
+ * Derive a stable, app-scoped secret for this identity + app origin.
460
+ *
461
+ * Computes `HMAC(appSecret, label)` inside the iframe, where `appSecret` is the
462
+ * app-specific secret that never leaves the trusted context. The result is
463
+ * deterministic — the same identity, app origin, and label always yield the
464
+ * same bytes across sessions and devices — yet unguessable to anyone without
465
+ * the identity. Use it to seed feed topics or other app material without
466
+ * exposing the recoverable app public key (#520).
467
+ *
468
+ * @param label - Application-chosen domain separator (e.g. `"state-feed"`)
469
+ * @returns A promise resolving to the 32-byte derived secret
470
+ * @throws {Error} If the client is not initialized or not authenticated
471
+ *
472
+ * @example
473
+ * ```typescript
474
+ * const seed = await client.deriveAppSecret('state-feed')
475
+ * const topic = keccak256(seed) // an unguessable, stable feed topic
476
+ * ```
477
+ */
478
+ deriveAppSecret(label: string): Promise<Uint8Array>;
479
+ /**
480
+ * The site's chat key: the private key this site's chat signs messages
481
+ * with, whose address `connectionInfo.chatBinding` names as the account's
482
+ * chat address on this site (docs/Chat-Binding.md).
483
+ *
484
+ * It is derived inside the iframe from the app secret, which never leaves
485
+ * it, and is the same for this account and this site on every device. The
486
+ * library keeps it in memory only and never writes it to storage. Hold it no
487
+ * longer than the chat needs it, and never publish it.
488
+ *
489
+ * @returns A promise resolving to the 32-byte secp256k1 private key
490
+ * @throws {SwarmIdError} If the client is not initialized, or with code
491
+ * `not-authenticated` when no account is connected
492
+ *
493
+ * @example
494
+ * ```typescript
495
+ * const chatKey = await client.getChatKey()
496
+ * const signer = new PrivateKey(chatKey) // its address is the binding's chat address
497
+ * ```
498
+ */
499
+ getChatKey(): Promise<Uint8Array>;
500
+ /**
501
+ * Stamp a chunk with the account's own postage stamp and get the stamp back,
502
+ * to send the chunk through whatever Swarm access the app chose: a gateway,
503
+ * its own Bee node or a browser node.
504
+ *
505
+ * The frame computes the chunk's address itself, so the whole chunk goes in,
506
+ * never an address. A content chunk is stamped as it is. A single-owner chunk
507
+ * is signed by the frame in this same call, with the app's own secret
508
+ * (`signer: "app"`) or a private key the app supplies, such as a chat's
509
+ * shared GSOC inbox key. A pre-signed chunk is refused, and so is one owned
510
+ * by any of the account's own keys.
511
+ *
512
+ * The stamp is returned only once the bucket counter it spent is saved and,
513
+ * for an account shared between devices, published, as an upload is
514
+ * acknowledged. Two calls never return the same bucket slot.
515
+ *
516
+ * @param chunk - The chunk: `data` is the 8-byte little-endian span followed
517
+ * by the payload, 8 to 4104 bytes
518
+ * @returns The chunk address, the stamp as the `swarm-postage-stamp` header
519
+ * value, and for a single-owner chunk its owner and signature
520
+ * @throws {SwarmIdError} `upload-unavailable` with reason `subsidised` when
521
+ * the account is in subsidised mode, where the gateway stamps and there is
522
+ * no stamp of the account's to return, and `invalid-request` for a chunk of the
523
+ * wrong shape or an owner that is one of the account's keys
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * const { address, stamp } = await client.stampChunk({ kind: 'content', data })
528
+ * await fetch(`${gateway}/chunks`, {
529
+ * method: 'POST',
530
+ * headers: { 'swarm-postage-stamp': stamp },
531
+ * body: data,
532
+ * })
533
+ * ```
534
+ */
535
+ stampChunk(chunk: StampChunkInput): Promise<StampedChunk>;
536
+ /**
537
+ * Uploads a file to the Swarm network, wrapped in a manifest that carries
538
+ * its name and content type. Read the reference back with
539
+ * {@link downloadFile}. A gateway's `/bzz/<reference>/` is only for a plain
540
+ * reference, uploaded with `encrypt: false`.
541
+ *
542
+ * Accepts either a File object (from file input) or raw Uint8Array data.
543
+ * When using a File object, the filename is automatically extracted unless
544
+ * explicitly overridden.
545
+ *
546
+ * Content is encrypted unless `options.encrypt` is `false`, and the
547
+ * manifest too — a 64-byte reference that carries the key — unless
548
+ * `options.encrypt` or `options.encryptManifest` is `false`. The same rule
549
+ * as {@link uploadFiles}.
550
+ *
551
+ * @param file - The file to upload (File object or Uint8Array)
552
+ * @param name - Optional filename (extracted from File object if not provided)
553
+ * @param options - Optional upload configuration
554
+ * @param options.pin - Whether to pin the file locally (defaults to false; ignored on a subsidised gateway)
555
+ * @param options.encrypt - Whether to encrypt the file content (defaults to true); `false` also leaves the manifest plain
556
+ * @param options.encryptManifest - Whether to encrypt the manifest too (defaults to true); `false` gives a 32-byte reference over encrypted content
557
+ * @param options.tag - Tag ID for tracking upload progress
558
+ * @param options.deferred - Whether to use deferred upload (defaults to false)
559
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
560
+ * @returns A promise resolving to the upload result
561
+ * @returns return.reference - The Swarm reference (hash) of the uploaded file
562
+ * @returns return.tagUid - The tag UID if a tag was created
563
+ * @throws {Error} If the client is not initialized
564
+ * @throws {Error} If the user is not authenticated or cannot upload
565
+ * @throws {Error} If the request times out
566
+ *
567
+ * @example
568
+ * ```typescript
569
+ * // From file input
570
+ * const fileInput = document.querySelector('input[type="file"]')
571
+ * const file = fileInput.files[0]
572
+ * const result = await client.uploadFile(file)
573
+ *
574
+ * // From Uint8Array with custom name
575
+ * const data = new Uint8Array([...])
576
+ * const result = await client.uploadFile(data, 'document.pdf')
577
+ * ```
578
+ */
579
+ uploadFile(file: File | Uint8Array, name?: string, options?: UploadOptions, requestOptions?: RequestOptions): Promise<UploadResult>;
580
+ /**
581
+ * Downloads a file from the Swarm network: the counterpart of
582
+ * {@link uploadFile}. It resolves a manifest, so a reference produced by
583
+ * {@link uploadData} fails here inside the manifest parser; use
584
+ * {@link downloadData} for those.
585
+ *
586
+ * Returns both the file data and its original filename (if available).
587
+ * For manifest references, an optional path can be specified to retrieve
588
+ * a specific file from the manifest.
589
+ *
590
+ * @param reference - The Swarm reference (hash) of the file to download
591
+ * @param path - Optional path within a manifest to retrieve a specific file
592
+ * @param options - Optional download configuration
593
+ * @param options.redundancyStrategy - Strategy for handling redundancy (0-3)
594
+ * @param options.fallback - Whether to use fallback retrieval
595
+ * @param options.timeoutMs - Download timeout in milliseconds
596
+ * @param options.actPublisher - ACT publisher for encrypted content
597
+ * @param options.actHistoryAddress - ACT history address for encrypted content
598
+ * @param options.actTimestamp - ACT timestamp for encrypted content
599
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
600
+ * @returns A promise resolving to the file data object
601
+ * @returns return.name - The filename
602
+ * @returns return.data - The file contents as a Uint8Array
603
+ * @throws {Error} If the client is not initialized
604
+ * @throws {Error} If the reference is not found
605
+ * @throws {Error} If the request times out
606
+ *
607
+ * @example
608
+ * ```typescript
609
+ * const file = await client.downloadFile('a1b2c3...')
610
+ * console.log('Filename:', file.name)
611
+ *
612
+ * // Create download link
613
+ * const blob = new Blob([file.data])
614
+ * const url = URL.createObjectURL(blob)
615
+ * ```
616
+ */
617
+ downloadFile(reference: Reference, path?: string, options?: DownloadOptions, requestOptions?: RequestOptions): Promise<FileData>;
618
+ /**
619
+ * Uploads a folder as one manifest (#750): a fork per file with its path and
620
+ * content type, which a gateway serves at `/bzz/<reference>/<path>` when the
621
+ * folder is plain (`encrypt: false`). Takes what bee-js takes — the
622
+ * `FileList` of a `webkitdirectory` input or a dropped directory, a `File[]`,
623
+ * or `{ path, file }` pairs for a folder the app assembled itself. A `File`'s
624
+ * path is its `webkitRelativePath` minus the picked folder's own name, or its
625
+ * name.
626
+ *
627
+ * Content is encrypted unless `options.encrypt` is `false`, and the
628
+ * manifest too — a 64-byte root reference — unless `options.encrypt` or
629
+ * `options.encryptManifest` is `false`. Name `options.indexDocument` for
630
+ * the bare `/bzz/<reference>/` to serve a file. Read a folder back with
631
+ * {@link listFiles} and {@link downloadData} per entry, or one file with
632
+ * {@link downloadFile} and its path.
633
+ *
634
+ * Every file is read into memory before the upload starts; for folders
635
+ * larger than that, upload the files with {@link uploadData} and build the
636
+ * manifest with `@ethersphere/core-sdk`.
637
+ *
638
+ * @param files - The folder's files
639
+ * @param options - Optional upload configuration; `onProgress` counts files, `useWorkers` / `workerCount` stamp in a pool as with {@link uploadData}
640
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
641
+ * @returns A promise resolving to the upload result
642
+ * @returns return.reference - The Swarm reference of the manifest
643
+ * @returns return.tagUid - The tag UID if a tag was created
644
+ * @throws {Error} If the client is not initialized
645
+ * @throws {Error} If the user is not authenticated or cannot upload
646
+ * @throws {Error} If two files share a path
647
+ * @throws {Error} If the request times out
648
+ *
649
+ * @example
650
+ * ```typescript
651
+ * // <input type="file" webkitdirectory>
652
+ * const { reference } = await client.uploadFiles(input.files, {
653
+ * indexDocument: 'index.html',
654
+ * })
655
+ * // or assembled by the app
656
+ * await client.uploadFiles([{ path: 'a/b.txt', file: new Blob(['hi']) }])
657
+ * ```
658
+ */
659
+ uploadFiles(files: FileList | Iterable<File | CollectionFileInput>, options?: UploadFilesOptions, requestOptions?: RequestOptions): Promise<UploadResult>;
660
+ /**
661
+ * Lists the files of a manifest uploaded with {@link uploadFiles} (or any
662
+ * manifest): each entry's path, content type, and the reference of its
663
+ * content, which {@link downloadData} reads.
664
+ *
665
+ * @param reference - The Swarm reference of the manifest
666
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry)
667
+ * @returns A promise resolving to the entries, the index-document fork excluded
668
+ * @throws {Error} If the client is not initialized
669
+ * @throws {Error} If the reference is not a manifest or is not found
670
+ * @throws {Error} If the request times out
671
+ *
672
+ * @example
673
+ * ```typescript
674
+ * for (const { path, reference } of await client.listFiles(root)) {
675
+ * const data = await client.downloadData(reference)
676
+ * }
677
+ * ```
678
+ */
679
+ listFiles(reference: Reference, requestOptions?: RequestOptions): Promise<CollectionEntry[]>;
680
+ /**
681
+ * Forward the proxy's `uploadProgress` messages for one request to a
682
+ * callback, through the window listener's checks. Returns the function that
683
+ * stops forwarding; a no-op without a callback.
684
+ */
685
+ private listenForProgress;
686
+ /**
687
+ * Uploads a single chunk to the Swarm network.
688
+ *
689
+ * Chunks are the fundamental unit of storage in Swarm (4KB each).
690
+ * This method is useful for low-level operations or when implementing
691
+ * custom chunking strategies.
692
+ *
693
+ * `data` is the chunk's payload, not a finished chunk: the proxy builds the
694
+ * content-addressed chunk around it (span header, BMT address) and returns
695
+ * that address. A chunk that already carries its span header is wrapped a
696
+ * second time and stored under an address nothing else computes (#774). To
697
+ * store a folder as a manifest, use {@link uploadFiles}; to save a Mantaray
698
+ * tree of your own, use `saveMantarayTreeRecursively` with {@link uploadData}.
699
+ *
700
+ * @param data - The chunk payload, 1 to 4096 bytes
701
+ * @param options - Optional upload configuration
702
+ * @param options.pin - Whether to pin the chunk locally (defaults to false; ignored on a subsidised gateway)
703
+ * @param options.encrypt - Whether to encrypt the chunk (defaults to false)
704
+ * @param options.tag - Tag ID for tracking upload progress
705
+ * @param options.deferred - Whether to use deferred upload (defaults to false)
706
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
707
+ * @returns A promise resolving to the upload result
708
+ * @returns return.reference - The Swarm reference (hash) of the uploaded chunk
709
+ * @throws {Error} If the client is not initialized
710
+ * @throws {Error} If the user is not authenticated or cannot upload
711
+ * @throws {Error} If the request times out
712
+ *
713
+ * @example
714
+ * ```typescript
715
+ * const chunk = new Uint8Array(4096) // 4KB chunk
716
+ * chunk.fill(0x42) // Fill with data
717
+ * const result = await client.uploadChunk(chunk)
718
+ * console.log('Chunk reference:', result.reference)
719
+ * ```
720
+ */
721
+ uploadChunk(data: Uint8Array, options?: UploadOptions, requestOptions?: RequestOptions): Promise<UploadResult>;
722
+ /**
723
+ * Downloads a single chunk from the Swarm network.
724
+ *
725
+ * Retrieves a chunk by its reference hash. This method is useful for
726
+ * low-level operations or when implementing custom retrieval strategies.
727
+ *
728
+ * @param reference - The Swarm reference (hash) of the chunk to download
729
+ * @param options - Optional download configuration
730
+ * @param options.redundancyStrategy - Strategy for handling redundancy (0-3)
731
+ * @param options.fallback - Whether to use fallback retrieval
732
+ * @param options.timeoutMs - Download timeout in milliseconds
733
+ * @param options.actPublisher - ACT publisher for encrypted content
734
+ * @param options.actHistoryAddress - ACT history address for encrypted content
735
+ * @param options.actTimestamp - ACT timestamp for encrypted content
736
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
737
+ * @returns A promise resolving to the chunk data as a Uint8Array
738
+ * @throws {Error} If the client is not initialized
739
+ * @throws {Error} If the reference is not found
740
+ * @throws {Error} If the request times out
741
+ *
742
+ * @example
743
+ * ```typescript
744
+ * const chunk = await client.downloadChunk('a1b2c3...')
745
+ * console.log('Chunk size:', chunk.length)
746
+ * ```
747
+ */
748
+ downloadChunk(reference: Reference, options?: DownloadOptions, requestOptions?: RequestOptions): Promise<Uint8Array>;
749
+ /**
750
+ * Returns an object for reading single owner chunks (SOC).
751
+ *
752
+ * @param ownerAddress - Ethereum address of the SOC owner
753
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
754
+ * @returns SOCReader with `download` (encrypted) and `rawDownload` (unencrypted)
755
+ * @throws {Error} If the client is not initialized
756
+ * @throws {Error} If the request times out
757
+ *
758
+ * @example
759
+ * ```typescript
760
+ * const reader = client.makeSOCReader(owner)
761
+ * const soc = await reader.download(identifier, encryptionKey)
762
+ * console.log('Payload:', new TextDecoder().decode(soc.payload))
763
+ * ```
764
+ */
765
+ makeSOCReader(ownerAddress: EthAddress | Uint8Array | string, requestOptions?: RequestOptions): SOCReader;
766
+ /**
767
+ * Returns an object for reading and writing single owner chunks (SOC).
768
+ *
769
+ * Uploads are encrypted by default. Use `rawUpload` for unencrypted SOCs.
770
+ *
771
+ * @param signer - Optional SOC signer private key. If omitted, the proxy uses the app signer.
772
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
773
+ * @returns SOCWriter with `upload`, `rawUpload`, `download`, and `rawDownload`
774
+ * @throws {Error} If the client is not initialized
775
+ * @throws {Error} If the request times out
776
+ *
777
+ * @example
778
+ * ```typescript
779
+ * const writer = client.makeSOCWriter()
780
+ * const upload = await writer.upload(identifier, payload)
781
+ * const soc = await writer.download(identifier, upload.encryptionKey)
782
+ * ```
783
+ */
784
+ makeSOCWriter(signer?: PrivateKey | Uint8Array | string, requestOptions?: RequestOptions): SOCWriter;
785
+ /**
786
+ * Returns an object for reading epoch-based feeds.
787
+ *
788
+ * @param options - Feed reader options
789
+ * @param options.topic - Feed topic (32 bytes)
790
+ * @param options.owner - Optional feed owner address
791
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
792
+ * @returns FeedReader with `getOwner`, `downloadReference`, and `downloadPayload`
793
+ * @throws {Error} If the client is not initialized
794
+ * @throws {Error} If the request times out
795
+ */
796
+ makeEpochFeedReader(options: FeedReaderOptions, requestOptions?: RequestOptions): FeedReader;
797
+ /**
798
+ * Returns an object for reading and writing epoch-based feeds.
799
+ *
800
+ * @param options - Feed writer options
801
+ * @param options.topic - Feed topic (32 bytes)
802
+ * @param options.signer - Optional feed signer private key. If omitted, the proxy uses the app signer.
803
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
804
+ * @returns FeedWriter with `getOwner`, `downloadReference`, `downloadPayload`, `uploadPayload`, and `uploadReference`
805
+ * @throws {Error} If the client is not initialized
806
+ * @throws {Error} If the request times out
807
+ */
808
+ makeEpochFeedWriter(options: FeedWriterOptions, requestOptions?: RequestOptions): FeedWriter;
809
+ /**
810
+ * Returns a sequential feed reader (chunk API only).
811
+ *
812
+ * @param options - Sequential feed reader options
813
+ * @param options.topic - Feed topic (32 bytes)
814
+ * @param options.owner - Optional feed owner address
815
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
816
+ * @returns SequentialFeedReader with payload/reference download helpers
817
+ */
818
+ makeSequentialFeedReader(options: SequentialFeedReaderOptions, requestOptions?: RequestOptions): SequentialFeedReader;
819
+ /**
820
+ * Returns a sequential feed writer (chunk API only).
821
+ *
822
+ * @param options - Sequential feed writer options
823
+ * @param options.topic - Feed topic (32 bytes)
824
+ * @param options.signer - Optional signer private key. If omitted, proxy uses app signer.
825
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
826
+ * @returns SequentialFeedWriter with payload/reference upload helpers
827
+ */
828
+ makeSequentialFeedWriter(options: SequentialFeedWriterOptions, requestOptions?: RequestOptions): SequentialFeedWriter;
829
+ /**
830
+ * Creates a feed manifest for accessing feed content via URL.
831
+ *
832
+ * A feed manifest enables accessing the latest feed content via a URL path
833
+ * (e.g., `/bzz/{manifest-reference}/`). The manifest stores metadata about
834
+ * the feed including owner, topic, and type.
835
+ *
836
+ * @param topic - Feed topic (32-byte hex string)
837
+ * @param options - Optional configuration
838
+ * @param options.owner - Feed owner address; if omitted, uses app signer
839
+ * @param options.uploadOptions - Upload configuration (pin, deferred, etc.)
840
+ * @param requestOptions - Request configuration (timeout, headers). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
841
+ * @returns Promise resolving to the manifest reference
842
+ * @throws {Error} If the client is not initialized
843
+ * @throws {Error} If no owner is provided and no app signer is available
844
+ * @throws {Error} If the request times out
845
+ *
846
+ * @example
847
+ * ```typescript
848
+ * // Create manifest for a feed (uses app signer as owner)
849
+ * const manifestRef = await client.createFeedManifest(topic)
850
+ * console.log('Feed accessible at /bzz/' + manifestRef)
851
+ *
852
+ * // Create manifest with explicit owner
853
+ * const manifestRef = await client.createFeedManifest(topic, {
854
+ * owner: '0x1234...',
855
+ * })
856
+ * ```
857
+ */
858
+ createFeedManifest(topic: string, options?: {
859
+ owner?: string;
860
+ /** Feed type: "Sequence" for sequential feeds, "Epoch" for epoch feeds. Default: "Sequence" */
861
+ feedType?: "Sequence" | "Epoch";
862
+ uploadOptions?: UploadOptions;
863
+ }, requestOptions?: RequestOptions): Promise<string>;
864
+ /**
865
+ * Mines a private key whose SOC address is proximate to a target overlay.
866
+ *
867
+ * This is a synchronous, pure computation that does not require authentication.
868
+ * The mined signer can be used with {@link gsocSend} to send GSOC messages
869
+ * that route to the target overlay node.
870
+ *
871
+ * @param targetOverlay - The target overlay address to mine proximity for
872
+ * @param identifier - The GSOC identifier
873
+ * @param proximity - Optional proximity depth (defaults to 12 in bee-js)
874
+ * @returns A promise resolving to the mined signer as a hex string (private key)
875
+ * @throws {Error} If the client is not initialized
876
+ * @throws {Error} If no valid signer can be mined
877
+ * @throws {Error} If the request times out
878
+ *
879
+ * @example
880
+ * ```typescript
881
+ * const signer = await client.gsocMine(targetOverlay, identifier)
882
+ * // Use signer with gsocSend
883
+ * await client.gsocSend(signer, identifier, data)
884
+ * ```
885
+ */
886
+ gsocMine(targetOverlay: string, identifier: string, proximity?: number): Promise<string>;
887
+ /**
888
+ * Sends a GSOC (Global Single Owner Chunk) message using a mined signer.
889
+ *
890
+ * The signer should be obtained from {@link gsocMine}. The message is sent
891
+ * using the proxy's stored postage batch ID.
892
+ *
893
+ * @param signer - The mined signer as a hex string (from gsocMine)
894
+ * @param identifier - The GSOC identifier
895
+ * @param data - The message data to send
896
+ * @param options - Optional upload configuration
897
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
898
+ * @returns A promise resolving to the upload result with reference and optional tagUid
899
+ * @throws {Error} If the client is not initialized
900
+ * @throws {Error} If the user is not authenticated
901
+ * @throws {Error} If no postage batch ID is available
902
+ * @throws {Error} If the request times out
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * const signer = await client.gsocMine(targetOverlay, identifier)
907
+ * const result = await client.gsocSend(signer, identifier, new TextEncoder().encode('Hello!'))
908
+ * console.log('GSOC reference:', result.reference)
909
+ * ```
910
+ */
911
+ gsocSend(signer: string, identifier: string, data: Uint8Array, options?: UploadOptions, requestOptions?: RequestOptions): Promise<UploadResult>;
912
+ /**
913
+ * Uploads data with ACT (Access Control Tries) protection.
914
+ *
915
+ * This method encrypts the data and creates an ACT that controls who can decrypt it.
916
+ * Only the specified grantees (and the publisher) can decrypt and access the data.
917
+ *
918
+ * @param data - The binary data to upload as a Uint8Array
919
+ * @param grantees - Array of grantee public keys as compressed hex strings (33 bytes = 66 hex chars).
920
+ * A grantee is either another user's `appKey.publicKey` (that user in this app origin only) or
921
+ * their `identity.sharingPublicKey` (that user in every app they connect, #519)
922
+ * @param options - Optional upload configuration
923
+ * @param options.publisher - `"app"` (default) publishes with this origin's app key; `"identity"`
924
+ * publishes with the account-wide sharing key, so any of the user's apps can manage the grantees later
925
+ * @param options.pin - Whether to pin the data locally (defaults to false; ignored on a subsidised gateway)
926
+ * @param options.tag - Tag ID for tracking upload progress
927
+ * @param options.deferred - Whether to use deferred upload (defaults to false)
928
+ * @param options.onProgress - Optional callback for tracking upload progress
929
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
930
+ * @returns A promise resolving to the ACT upload result
931
+ * @returns return.encryptedReference - The encrypted reference that must be stored with the ACT
932
+ * @returns return.actReference - The Swarm reference (hash) of the ACT manifest
933
+ * @returns return.historyReference - The Swarm reference of the history manifest (use for future operations)
934
+ * @returns return.granteeListReference - The Swarm reference of the encrypted grantee list
935
+ * @returns return.publisherPubKey - The publisher's compressed public key (share with grantees)
936
+ * @returns return.tagUid - The tag UID if a tag was created
937
+ * @throws {Error} If the client is not initialized
938
+ * @throws {Error} If the user is not authenticated or cannot upload
939
+ * @throws {Error} If the request times out
940
+ *
941
+ * @example
942
+ * ```typescript
943
+ * const data = new TextEncoder().encode('Secret message')
944
+ * const grantees = ['03a1b2c3...'] // Compressed public keys of allowed readers
945
+ * const result = await client.actUploadData(data, grantees, {
946
+ * onProgress: (progress) => {
947
+ * console.log(`Progress: ${progress.processed}/${progress.total}`)
948
+ * },
949
+ * })
950
+ * console.log('History Reference:', result.historyReference)
951
+ * console.log('Encrypted Reference:', result.encryptedReference)
952
+ * console.log('Publisher Public Key:', result.publisherPubKey)
953
+ * ```
954
+ */
955
+ actUploadData(data: Uint8Array, grantees: string[], options?: ActUploadOptions, requestOptions?: RequestOptions): Promise<{
956
+ encryptedReference: string;
957
+ historyReference: string;
958
+ granteeListReference: string;
959
+ publisherPubKey: string;
960
+ actReference: string;
961
+ tagUid?: number;
962
+ }>;
963
+ /**
964
+ * Downloads ACT-protected data from the Swarm network.
965
+ *
966
+ * This method decrypts the ACT to recover the content reference,
967
+ * then downloads and returns the decrypted data. Only authorized
968
+ * grantees (including the publisher) can successfully decrypt.
969
+ *
970
+ * @param encryptedReference - The encrypted reference from actUploadData
971
+ * @param historyReference - The history reference from actUploadData
972
+ * @param publisherPubKey - The publisher's compressed public key from actUploadData
973
+ * @param timestamp - Optional timestamp to look up a specific ACT version
974
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
975
+ * @returns A promise resolving to the decrypted data as a Uint8Array
976
+ * @throws {Error} If the client is not initialized
977
+ * @throws {Error} If the user is not authorized to decrypt the ACT
978
+ * @throws {Error} If the references are not found
979
+ * @throws {Error} If the request times out
980
+ *
981
+ * @example
982
+ * ```typescript
983
+ * // Using the references from actUploadData
984
+ * const data = await client.actDownloadData(
985
+ * encryptedReference,
986
+ * historyReference,
987
+ * publisherPubKey
988
+ * )
989
+ * const text = new TextDecoder().decode(data)
990
+ * console.log('Decrypted:', text)
991
+ * ```
992
+ */
993
+ actDownloadData(encryptedReference: string, historyReference: string, publisherPubKey: string, timestamp?: number, requestOptions?: RequestOptions): Promise<Uint8Array>;
994
+ /**
995
+ * Adds new grantees to an existing ACT.
996
+ *
997
+ * This method adds new public keys to the ACT's access list.
998
+ * Only the publisher (original uploader) can add grantees.
999
+ * Returns new references since Swarm content is immutable.
1000
+ *
1001
+ * @param historyReference - The current history reference
1002
+ * @param grantees - Array of new grantee public keys as compressed hex strings
1003
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
1004
+ * @returns A promise resolving to the new references
1005
+ * @returns return.historyReference - The new history reference after adding grantees
1006
+ * @returns return.granteeListReference - The new grantee list reference
1007
+ * @returns return.actReference - The new ACT reference
1008
+ * @throws {Error} If the client is not initialized
1009
+ * @throws {Error} If the user is not the publisher
1010
+ * @throws {Error} If the request times out
1011
+ *
1012
+ * @example
1013
+ * ```typescript
1014
+ * const newGrantees = ['03d4e5f6...'] // New public keys to grant access
1015
+ * const result = await client.actAddGrantees(historyReference, newGrantees)
1016
+ * console.log('New History Reference:', result.historyReference)
1017
+ * // The encrypted reference remains the same
1018
+ * ```
1019
+ */
1020
+ actAddGrantees(historyReference: string, grantees: string[], requestOptions?: RequestOptions): Promise<{
1021
+ historyReference: string;
1022
+ granteeListReference: string;
1023
+ actReference: string;
1024
+ }>;
1025
+ /**
1026
+ * Revokes grantees from an existing ACT.
1027
+ *
1028
+ * This method removes public keys from the ACT's access list, producing a new
1029
+ * ACT/history without the revoked entries.
1030
+ *
1031
+ * IMPORTANT: Revocation cannot un-share already-published content. A former
1032
+ * grantee kept the access key while granted and the reference lives in
1033
+ * immutable history, so they can still decrypt content published before
1034
+ * revocation. Revocation only stops access to content published afterwards.
1035
+ * The returned `encryptedReference` is unchanged — it is NOT re-encrypted, as
1036
+ * that would leak the keystream to former grantees (#496).
1037
+ *
1038
+ * @param historyReference - The current history reference
1039
+ * @param encryptedReference - The current encrypted reference
1040
+ * @param revokeGrantees - Array of grantee public keys to revoke as compressed hex strings
1041
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
1042
+ * @returns A promise resolving to the new references after revocation
1043
+ * @returns return.encryptedReference - The content reference, unchanged
1044
+ * @returns return.historyReference - The new history reference after revocation
1045
+ * @returns return.granteeListReference - The new grantee list reference
1046
+ * @returns return.actReference - The new ACT reference after revocation
1047
+ * @throws {Error} If the client is not initialized
1048
+ * @throws {Error} If the user is not the publisher
1049
+ * @throws {Error} If the request times out
1050
+ *
1051
+ * @example
1052
+ * ```typescript
1053
+ * const revokeKeys = ['03a1b2c3...'] // Public keys to revoke
1054
+ * const result = await client.actRevokeGrantees(historyReference, encryptedReference, revokeKeys)
1055
+ * console.log('New History Reference:', result.historyReference)
1056
+ * // encryptedReference is unchanged; historyReference/actReference are new
1057
+ * ```
1058
+ */
1059
+ actRevokeGrantees(historyReference: string, encryptedReference: string, revokeGrantees: string[], requestOptions?: RequestOptions): Promise<{
1060
+ encryptedReference: string;
1061
+ historyReference: string;
1062
+ granteeListReference: string;
1063
+ actReference: string;
1064
+ }>;
1065
+ /**
1066
+ * Retrieves the list of grantees from an ACT.
1067
+ *
1068
+ * Only the publisher (original uploader) can view the grantee list,
1069
+ * as it is encrypted with the publisher's key.
1070
+ *
1071
+ * @param historyReference - The history reference
1072
+ * @param requestOptions - Optional request configuration (timeout, headers, endlesslyRetry). `timeout` replaces the client default for this call's whole round trip, not only the Bee request
1073
+ * @returns A promise resolving to an array of grantee public keys as compressed hex strings
1074
+ * @throws {Error} If the client is not initialized
1075
+ * @throws {Error} If the user is not the publisher
1076
+ * @throws {Error} If the request times out
1077
+ *
1078
+ * @example
1079
+ * ```typescript
1080
+ * const grantees = await client.actGetGrantees(historyReference)
1081
+ * console.log('Current grantees:', grantees.length)
1082
+ * grantees.forEach(pubKey => console.log(' -', pubKey))
1083
+ * ```
1084
+ */
1085
+ actGetGrantees(historyReference: string, requestOptions?: RequestOptions): Promise<string[]>;
1086
+ /**
1087
+ * Destroys the client and releases all resources.
1088
+ *
1089
+ * This method should be called when the client is no longer needed.
1090
+ * It performs the following cleanup:
1091
+ * - Rejects every pending request, and a pending `initialize()`, with a
1092
+ * `SwarmIdError` of code `invalid-state`
1093
+ * - Removes the message event listener
1094
+ * - Removes the iframe from the DOM
1095
+ * - Resets the client to an uninitialized state
1096
+ *
1097
+ * After calling destroy(), the client instance cannot be reused.
1098
+ * Create a new instance if you need to reconnect.
1099
+ *
1100
+ * @example
1101
+ * ```typescript
1102
+ * // Clean up when component unmounts
1103
+ * useEffect(() => {
1104
+ * const client = new SwarmIdClient({ ... })
1105
+ * client.initialize()
1106
+ *
1107
+ * return () => {
1108
+ * client.destroy()
1109
+ * }
1110
+ * }, [])
1111
+ * ```
1112
+ */
1113
+ destroy(): void;
1114
+ }