@solarpunkltd/swarm-id 0.0.0-stage → 0.8.1

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