@automerge/subduction 0.8.1 → 0.10.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 (37) hide show
  1. package/package.json +3 -2
  2. package/dist/cjs/node.cjs +0 -5
  3. package/dist/cjs/slim.cjs +0 -1
  4. package/dist/cjs/wasm-base64.cjs +0 -1
  5. package/dist/cjs/web-bindings.cjs +0 -4400
  6. package/dist/cjs/web.cjs +0 -4351
  7. package/dist/esm/bundler.js +0 -7
  8. package/dist/esm/node.js +0 -7
  9. package/dist/esm/slim.js +0 -2
  10. package/dist/esm/wasm-base64.js +0 -1
  11. package/dist/esm/web.js +0 -5
  12. package/dist/esm/workerd.js +0 -5
  13. package/dist/iife/index.js +0 -4310
  14. package/dist/index.d.ts +0 -1571
  15. package/dist/subduction.wasm +0 -0
  16. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-68c0499598a3382c/inline0.js +0 -2
  17. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-68c0499598a3382c/inline1.js +0 -2
  18. package/dist/wasm_bindgen/bundler/snippets/sedimentree_wasm-68c0499598a3382c/inline2.js +0 -2
  19. package/dist/wasm_bindgen/bundler/subduction_wasm.d.ts +0 -1571
  20. package/dist/wasm_bindgen/bundler/subduction_wasm.js +0 -9
  21. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.js +0 -4447
  22. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm +0 -0
  23. package/dist/wasm_bindgen/bundler/subduction_wasm_bg.wasm.d.ts +0 -234
  24. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-68c0499598a3382c/inline0.js +0 -2
  25. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-68c0499598a3382c/inline1.js +0 -2
  26. package/dist/wasm_bindgen/nodejs/snippets/sedimentree_wasm-68c0499598a3382c/inline2.js +0 -2
  27. package/dist/wasm_bindgen/nodejs/subduction_wasm.cjs +0 -4489
  28. package/dist/wasm_bindgen/nodejs/subduction_wasm.d.ts +0 -1571
  29. package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm +0 -0
  30. package/dist/wasm_bindgen/nodejs/subduction_wasm_bg.wasm.d.ts +0 -234
  31. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-68c0499598a3382c/inline0.js +0 -2
  32. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-68c0499598a3382c/inline1.js +0 -2
  33. package/dist/wasm_bindgen/web/snippets/sedimentree_wasm-68c0499598a3382c/inline2.js +0 -2
  34. package/dist/wasm_bindgen/web/subduction_wasm.d.ts +0 -1830
  35. package/dist/wasm_bindgen/web/subduction_wasm.js +0 -4548
  36. package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm +0 -0
  37. package/dist/wasm_bindgen/web/subduction_wasm_bg.wasm.d.ts +0 -234
@@ -1,1830 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- export interface SedimentreeStorage {
5
- saveSedimentreeId(sedimentreeId: SedimentreeId): Promise<void>;
6
- deleteSedimentreeId(sedimentreeId: SedimentreeId): Promise<void>;
7
- loadAllSedimentreeIds(): Promise<SedimentreeId[]>;
8
-
9
- // Compound storage for commits (signed data + blob stored together)
10
- saveCommit(sedimentreeId: SedimentreeId, digest: Digest, signedCommit: SignedLooseCommit, blob: Uint8Array): Promise<void>;
11
- loadCommit(sedimentreeId: SedimentreeId, digest: Digest): Promise<CommitWithBlob | null>;
12
- listCommitDigests(sedimentreeId: SedimentreeId): Promise<Digest[]>;
13
- loadAllCommits(sedimentreeId: SedimentreeId): Promise<CommitWithBlob[]>;
14
- deleteCommit(sedimentreeId: SedimentreeId, digest: Digest): Promise<void>;
15
- deleteAllCommits(sedimentreeId: SedimentreeId): Promise<void>;
16
-
17
- // Compound storage for fragments (signed data + blob stored together)
18
- saveFragment(sedimentreeId: SedimentreeId, digest: Digest, signedFragment: SignedFragment, blob: Uint8Array): Promise<void>;
19
- loadFragment(sedimentreeId: SedimentreeId, digest: Digest): Promise<FragmentWithBlob | null>;
20
- listFragmentDigests(sedimentreeId: SedimentreeId): Promise<Digest[]>;
21
- loadAllFragments(sedimentreeId: SedimentreeId): Promise<FragmentWithBlob[]>;
22
- deleteFragment(sedimentreeId: SedimentreeId, digest: Digest): Promise<void>;
23
- deleteAllFragments(sedimentreeId: SedimentreeId): Promise<void>;
24
- }
25
-
26
-
27
-
28
- export interface Transport {
29
- sendBytes(bytes: Uint8Array): Promise<void>;
30
- recvBytes(): Promise<Uint8Array>;
31
- disconnect(): Promise<void>;
32
- }
33
-
34
-
35
-
36
- /**
37
- * An authenticated HTTP long-poll transport.
38
- *
39
- * This wrapper proves that the transport has completed the Subduction handshake
40
- * and the peer identity has been cryptographically verified.
41
- *
42
- * Obtain via [`SubductionLongPoll::tryConnect`] or [`SubductionLongPoll::tryDiscover`].
43
- */
44
- export class AuthenticatedLongPoll {
45
- private constructor();
46
- free(): void;
47
- [Symbol.dispose](): void;
48
- /**
49
- * Convert to a transport-erased [`AuthenticatedTransport`](super::WasmAuthenticatedTransport).
50
- */
51
- toTransport(): AuthenticatedTransport;
52
- /**
53
- * The verified peer identity.
54
- */
55
- readonly peerId: PeerId;
56
- /**
57
- * The session ID assigned by the server.
58
- */
59
- readonly sessionId: string;
60
- }
61
-
62
- /**
63
- * A transport-erased authenticated transport.
64
- *
65
- * Wraps an [`Authenticated<MessageTransport<JsTransport>>`] and is the common type
66
- * accepted by [`addConnection`](crate::subduction::WasmSubduction::add_connection).
67
- *
68
- * # Construction
69
- *
70
- * There are three ways to obtain an `AuthenticatedTransport`:
71
- *
72
- * 1. **Custom transport** — implement the `Transport` interface
73
- * (`sendBytes`/`recvBytes`/`disconnect`) and call [`setup`](Self::setup):
74
- *
75
- * ```js
76
- * const auth = await AuthenticatedTransport.setup(myTransport, signer, peerId);
77
- * ```
78
- *
79
- * 2. **From WebSocket** — authenticate via [`SubductionWebSocket`] then convert:
80
- *
81
- * ```js
82
- * const wsAuth = await SubductionWebSocket.tryConnect(url, signer, peerId, timeout);
83
- * const auth = wsAuth.toTransport();
84
- * ```
85
- *
86
- * 3. **From HTTP long-poll** — same pattern via [`SubductionLongPoll`]:
87
- *
88
- * ```js
89
- * const lpAuth = await SubductionLongPoll.tryConnect(url, signer, peerId, timeout);
90
- * const auth = lpAuth.toTransport();
91
- * ```
92
- */
93
- export class AuthenticatedTransport {
94
- private constructor();
95
- free(): void;
96
- [Symbol.dispose](): void;
97
- /**
98
- * Accept an incoming handshake over a custom transport (responder side).
99
- *
100
- * This is the counterpart to [`setup`](Self::setup). The initiator calls
101
- * `setup`, and the responder calls `accept` over the same underlying channel.
102
- *
103
- * # Arguments
104
- *
105
- * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
106
- * * `signer` - The responder's signer for authentication
107
- * * `max_drift_seconds` - Maximum acceptable clock drift in seconds (default: 600)
108
- *
109
- * # Errors
110
- *
111
- * Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
112
- */
113
- static accept(transport: Transport, signer: any, max_drift_seconds?: number | null): Promise<AuthenticatedTransport>;
114
- /**
115
- * Run the Subduction handshake over a custom transport, producing an
116
- * authenticated transport.
117
- *
118
- * The `transport` object must implement the `Transport` interface
119
- * (`sendBytes`/`recvBytes`/`disconnect`).
120
- * The same object is used for both the handshake phase and post-handshake
121
- * communication.
122
- *
123
- * # Arguments
124
- *
125
- * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
126
- * * `signer` - The client's signer for authentication
127
- * * `expected_peer_id` - The expected server peer ID (verified during handshake)
128
- *
129
- * # Errors
130
- *
131
- * Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
132
- */
133
- static setup(transport: Transport, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedTransport>;
134
- /**
135
- * Run the Subduction handshake over a custom transport using discovery
136
- * mode, producing an authenticated transport.
137
- *
138
- * Unlike [`setup`](Self::setup) which requires a known peer ID,
139
- * this method discovers the peer's identity during the handshake
140
- * using a shared service name.
141
- *
142
- * # Arguments
143
- *
144
- * * `transport` - A `Transport` implementing `sendBytes`/`recvBytes`/`disconnect`
145
- * * `signer` - The client's signer for authentication
146
- * * `service_name` - Shared service name for discovery.
147
- * Defaults to [`DEFAULT_LOCAL_SERVICE_NAME`] (`"subduction:local"`) if omitted.
148
- *
149
- * # Errors
150
- *
151
- * Returns a [`HandshakeError`](WasmHandshakeError) if the handshake fails.
152
- */
153
- static setupDiscover(transport: Transport, signer: any, service_name?: string | null): Promise<AuthenticatedTransport>;
154
- /**
155
- * The verified peer identity.
156
- */
157
- readonly peerId: PeerId;
158
- }
159
-
160
- /**
161
- * An authenticated WebSocket transport.
162
- *
163
- * This wrapper proves that the connection has completed the Subduction handshake
164
- * and the peer identity has been cryptographically verified.
165
- *
166
- * Obtain via [`SubductionWebSocket::setup`], [`SubductionWebSocket::tryConnect`],
167
- * or [`SubductionWebSocket::tryDiscover`].
168
- */
169
- export class AuthenticatedWebSocket {
170
- private constructor();
171
- free(): void;
172
- [Symbol.dispose](): void;
173
- /**
174
- * Convert to a transport-erased [`AuthenticatedTransport`](super::WasmAuthenticatedTransport).
175
- */
176
- toTransport(): AuthenticatedTransport;
177
- /**
178
- * The verified peer identity.
179
- */
180
- readonly peerId: PeerId;
181
- }
182
-
183
- /**
184
- * Wasm wrapper for [`BatchSyncRequest`].
185
- */
186
- export class BatchSyncRequest {
187
- private constructor();
188
- free(): void;
189
- [Symbol.dispose](): void;
190
- /**
191
- * The sedimentree ID this request corresponds to.
192
- */
193
- id(): SedimentreeId;
194
- /**
195
- * The request ID for this request.
196
- */
197
- request_id(): RequestId;
198
- /**
199
- * Whether this request subscribes to future updates.
200
- */
201
- subscribe(): boolean;
202
- }
203
-
204
- /**
205
- * Wasm wrapper for [`BatchSyncResponse`].
206
- */
207
- export class BatchSyncResponse {
208
- private constructor();
209
- free(): void;
210
- [Symbol.dispose](): void;
211
- /**
212
- * Upcasts; to the JS-import type for [`WasmBatchSyncResponse`].
213
- */
214
- __wasm_refgen_toWasmBatchSyncResponse(): BatchSyncResponse;
215
- /**
216
- * The sedimentree ID this response corresponds to.
217
- */
218
- id(): SedimentreeId;
219
- /**
220
- * The request ID this response corresponds to.
221
- */
222
- request_id(): RequestId;
223
- }
224
-
225
- /**
226
- * A Wasm wrapper around the [`BlobMeta`] type.
227
- */
228
- export class BlobMeta {
229
- free(): void;
230
- [Symbol.dispose](): void;
231
- /**
232
- * Get the digest of the blob.
233
- */
234
- digest(): Digest;
235
- /**
236
- * Create a `BlobMeta` from a digest and size.
237
- *
238
- * This is useful for deserialization when the original blob is not available.
239
- * Since this is manual, the caller must ensure the digest and size are correct.
240
- */
241
- static fromDigestSize(digest: Digest, size_bytes: bigint): BlobMeta;
242
- /**
243
- * Create a new `BlobMeta` from the given blob contents.
244
- */
245
- constructor(blob: Uint8Array);
246
- /**
247
- * Get the size of the blob in bytes.
248
- */
249
- readonly sizeBytes: bigint;
250
- }
251
-
252
- /**
253
- * Wasm wrapper for call errors.
254
- */
255
- export class CallError {
256
- private constructor();
257
- free(): void;
258
- [Symbol.dispose](): void;
259
- }
260
-
261
- /**
262
- * A commit stored with its associated blob.
263
- */
264
- export class CommitWithBlob {
265
- free(): void;
266
- [Symbol.dispose](): void;
267
- /**
268
- * Upcasts; to the JS-import type for [`WasmCommitWithBlob`].
269
- */
270
- __wasm_refgen_toWasmCommitWithBlob(): CommitWithBlob;
271
- /**
272
- * Create a new commit with blob.
273
- */
274
- constructor(signed: SignedLooseCommit, blob: Uint8Array);
275
- /**
276
- * Get the blob.
277
- */
278
- readonly blob: Uint8Array;
279
- /**
280
- * Get the signed commit.
281
- */
282
- readonly signed: SignedLooseCommit;
283
- }
284
-
285
- /**
286
- * A JavaScript wrapper around `Depth`.
287
- */
288
- export class Depth {
289
- free(): void;
290
- [Symbol.dispose](): void;
291
- /**
292
- * Internal method for a hack crossing the JS boundary.
293
- */
294
- __subduction_castToDepth(): Depth;
295
- /**
296
- * Upcasts; to the JS-import type for [`WasmDepth`].
297
- */
298
- __wasm_refgen_toWasmDepth(): Depth;
299
- /**
300
- * Creates a new `WasmDepth` from a JavaScript value.
301
- *
302
- * # Errors
303
- *
304
- * Returns a `NotU32Error` if the JS value is not safely coercible to `u32`.
305
- */
306
- constructor(js_value: any);
307
- /**
308
- * The depth value as an integer.
309
- */
310
- readonly value: number;
311
- }
312
-
313
- /**
314
- * A wrapper around digest bytes for use in JavaScript via wasm-bindgen.
315
- *
316
- * Since JavaScript doesn't have Rust's type system, this stores raw bytes
317
- * and converts to/from typed `Digest<T>` at the Rust boundary.
318
- */
319
- export class Digest {
320
- free(): void;
321
- [Symbol.dispose](): void;
322
- /**
323
- * Upcasts; to the JS-import type for [`WasmDigest`].
324
- */
325
- __wasm_refgen_toWasmDigest(): Digest;
326
- /**
327
- * Creates a new digest from its Base58 string representation.
328
- *
329
- * # Errors
330
- *
331
- * Returns a `WasmInvalidDigest` error if the string cannot be decoded or is not a valid digest.
332
- */
333
- static fromBase58(s: string): Digest;
334
- /**
335
- * Creates a new digest from its byte representation.
336
- *
337
- * # Errors
338
- *
339
- * Returns a `WasmValue` error if the byte slice is not a valid digest.
340
- */
341
- static fromBytes(bytes: Uint8Array): Digest;
342
- /**
343
- * Creates a new digest from its hexadecimal string representation.
344
- *
345
- * # Errors
346
- *
347
- * Returns a [`WasmInvalidDigest`] if the string is not a valid digest.
348
- */
349
- static fromHexString(s: string): Digest;
350
- /**
351
- * Creates a new digest from its byte representation.
352
- *
353
- * # Errors
354
- *
355
- * Returns a `WasmValue` error if the byte slice is not a valid digest.
356
- */
357
- constructor(bytes: Uint8Array);
358
- /**
359
- * Returns the byte representation of the digest.
360
- */
361
- toBytes(): Uint8Array;
362
- /**
363
- * Returns the hexadecimal string representation of the digest.
364
- */
365
- toHexString(): string;
366
- }
367
-
368
- /**
369
- * A data fragment used in the Sedimentree system.
370
- */
371
- export class Fragment {
372
- free(): void;
373
- [Symbol.dispose](): void;
374
- /**
375
- * Upcasts; to the JS-import type for [`WasmFragment`].
376
- */
377
- __wasm_refgen_toWasmFragment(): Fragment;
378
- /**
379
- * Create a new fragment from the given sedimentree ID, head, boundary, checkpoints, and blob metadata.
380
- */
381
- constructor(sedimentree_id: SedimentreeId, head: Digest, boundary: Digest[], checkpoints: Digest[], blob_meta: BlobMeta);
382
- /**
383
- * Get the blob metadata of the fragment.
384
- */
385
- readonly blobMeta: BlobMeta;
386
- /**
387
- * Get the boundary digests of the fragment.
388
- */
389
- readonly boundary: Digest[];
390
- /**
391
- * Get the head digest of the fragment.
392
- */
393
- readonly head: Digest;
394
- }
395
-
396
- /**
397
- * A request for a specific fragment in the Sedimentree system.
398
- */
399
- export class FragmentRequested {
400
- free(): void;
401
- [Symbol.dispose](): void;
402
- /**
403
- * Create a new fragment request from the given digest.
404
- */
405
- constructor(digest: Digest, depth: Depth);
406
- /**
407
- * Get the depth of the requested fragment.
408
- */
409
- readonly depth: Depth;
410
- /**
411
- * Get the digest of the requested fragment.
412
- */
413
- readonly head: Digest;
414
- }
415
-
416
- /**
417
- * A fragment stored with its associated blob.
418
- */
419
- export class FragmentWithBlob {
420
- free(): void;
421
- [Symbol.dispose](): void;
422
- /**
423
- * Upcasts; to the JS-import type for [`WasmFragmentWithBlob`].
424
- */
425
- __wasm_refgen_toWasmFragmentWithBlob(): FragmentWithBlob;
426
- /**
427
- * Create a new fragment with blob.
428
- */
429
- constructor(signed: SignedFragment, blob: Uint8Array);
430
- /**
431
- * Get the blob.
432
- */
433
- readonly blob: Uint8Array;
434
- /**
435
- * Get the signed fragment.
436
- */
437
- readonly signed: SignedFragment;
438
- }
439
-
440
- export class FragmentsArray {
441
- private constructor();
442
- free(): void;
443
- [Symbol.dispose](): void;
444
- /**
445
- * Upcasts; to the JS-import type for [`WasmFragmentsArray`].
446
- */
447
- __wasm_refgen_toWasmFragmentsArray(): FragmentsArray;
448
- }
449
-
450
- /**
451
- * An overridable hash metric.
452
- */
453
- export class HashMetric {
454
- free(): void;
455
- [Symbol.dispose](): void;
456
- /**
457
- * Create a new `WasmHashMetric` with an optional JavaScript function.
458
- *
459
- * Defaults to counting leading zero bytes if no function is provided.
460
- */
461
- constructor(func?: Function | null);
462
- }
463
-
464
- /**
465
- * A Wasm wrapper around the [`LooseCommit`] type.
466
- */
467
- export class LooseCommit {
468
- free(): void;
469
- [Symbol.dispose](): void;
470
- /**
471
- * Upcasts; to the JS-import type for [`WasmLooseCommit`].
472
- */
473
- __wasm_refgen_toWasmLooseCommit(): LooseCommit;
474
- /**
475
- * Create a new `LooseCommit` from the given sedimentree ID, parents, and blob metadata.
476
- */
477
- constructor(sedimentree_id: SedimentreeId, parents: Digest[], blob_meta: BlobMeta);
478
- /**
479
- * Get the blob metadata of the commit.
480
- */
481
- readonly blobMeta: BlobMeta;
482
- /**
483
- * Get the digest of the commit.
484
- */
485
- readonly digest: Digest;
486
- /**
487
- * Get the parent digests of the commit.
488
- */
489
- readonly parents: Digest[];
490
- }
491
-
492
- /**
493
- * An in-memory Ed25519 signer exposed to JavaScript.
494
- *
495
- * Implements the `Signer` interface (`sign` / `verifyingKey`) so it can be
496
- * passed anywhere a [`JsSigner`](crate::signer::JsSigner) is expected.
497
- *
498
- * # Example
499
- *
500
- * ```javascript
501
- * import { MemorySigner } from "@automerge/subduction";
502
- *
503
- * const signer = MemorySigner.generate();
504
- * console.log("Peer ID:", signer.peerId().toString());
505
- * ```
506
- */
507
- export class MemorySigner {
508
- free(): void;
509
- [Symbol.dispose](): void;
510
- /**
511
- * Create a signer from raw 32-byte Ed25519 secret key bytes.
512
- *
513
- * # Errors
514
- *
515
- * Returns an error if `bytes` is not exactly 32 bytes.
516
- */
517
- static fromBytes(bytes: Uint8Array): MemorySigner;
518
- /**
519
- * Create a new signer with a randomly generated Ed25519 key.
520
- *
521
- * # Panics
522
- *
523
- * Panics if the system random number generator fails.
524
- */
525
- static generate(): MemorySigner;
526
- /**
527
- * Create a new signer with a randomly generated Ed25519 key.
528
- *
529
- * This is the JS constructor (`new MemorySigner()`), equivalent to
530
- * [`generate`](Self::generate).
531
- *
532
- * # Panics
533
- *
534
- * Panics if the system random number generator fails.
535
- */
536
- constructor();
537
- /**
538
- * Get the peer ID derived from this signer's verifying key.
539
- */
540
- peerId(): PeerId;
541
- /**
542
- * Sign a message and return the 64-byte Ed25519 signature as a `Uint8Array`.
543
- *
544
- * This fulfils the `Signer.sign(message)` interface contract.
545
- * Returns a `Promise<Uint8Array>` for consistency with the async signer interface.
546
- */
547
- sign(message: Uint8Array): Promise<Uint8Array>;
548
- /**
549
- * Get the 32-byte Ed25519 verifying (public) key as a `Uint8Array`.
550
- *
551
- * This fulfils the `Signer.verifyingKey()` interface contract.
552
- */
553
- verifyingKey(): Uint8Array;
554
- }
555
-
556
- /**
557
- * An in-memory storage implementation for use in tests and development.
558
- *
559
- * This wraps the core `MemoryStorage` and exposes it via the `SedimentreeStorage` interface.
560
- */
561
- export class MemoryStorage {
562
- free(): void;
563
- [Symbol.dispose](): void;
564
- /**
565
- * Delete all commits for a sedimentree.
566
- */
567
- deleteAllCommits(sedimentree_id: SedimentreeId): Promise<any>;
568
- /**
569
- * Delete all fragments for a sedimentree.
570
- */
571
- deleteAllFragments(sedimentree_id: SedimentreeId): Promise<any>;
572
- /**
573
- * Delete a commit by digest.
574
- */
575
- deleteCommit(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
576
- /**
577
- * Delete a fragment by digest.
578
- */
579
- deleteFragment(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
580
- /**
581
- * Delete a sedimentree ID.
582
- */
583
- deleteSedimentreeId(sedimentree_id: SedimentreeId): Promise<any>;
584
- /**
585
- * List all commit digests for a sedimentree.
586
- */
587
- listCommitDigests(sedimentree_id: SedimentreeId): Promise<any>;
588
- /**
589
- * List all fragment digests for a sedimentree.
590
- */
591
- listFragmentDigests(sedimentree_id: SedimentreeId): Promise<any>;
592
- /**
593
- * Load all commits for a sedimentree, returning `CommitWithBlob[]`.
594
- */
595
- loadAllCommits(sedimentree_id: SedimentreeId): Promise<any>;
596
- /**
597
- * Load all fragments for a sedimentree, returning `FragmentWithBlob[]`.
598
- */
599
- loadAllFragments(sedimentree_id: SedimentreeId): Promise<any>;
600
- /**
601
- * Load all sedimentree IDs.
602
- */
603
- loadAllSedimentreeIds(): Promise<any>;
604
- /**
605
- * Load a commit by digest, returning `CommitWithBlob` or null.
606
- */
607
- loadCommit(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
608
- /**
609
- * Load a fragment by digest, returning `FragmentWithBlob` or null.
610
- */
611
- loadFragment(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
612
- /**
613
- * Create a new in-memory storage instance.
614
- */
615
- constructor();
616
- /**
617
- * Save a commit with its blob.
618
- */
619
- saveCommit(sedimentree_id: SedimentreeId, _digest: Digest, signed_commit: SignedLooseCommit, blob: Uint8Array): Promise<any>;
620
- /**
621
- * Save a fragment with its blob.
622
- */
623
- saveFragment(sedimentree_id: SedimentreeId, _digest: Digest, signed_fragment: SignedFragment, blob: Uint8Array): Promise<any>;
624
- /**
625
- * Save a sedimentree ID.
626
- */
627
- saveSedimentreeId(sedimentree_id: SedimentreeId): Promise<any>;
628
- }
629
-
630
- /**
631
- * A `Transport` backed by a `MessagePort` (or any object with
632
- * `postMessage` / `onmessage` / `close`).
633
- *
634
- * Implements the byte-oriented `Transport` interface (`sendBytes`,
635
- * `recvBytes`, `disconnect`) using the port as the underlying channel.
636
- * After the handshake, the [`Authenticated`] wrapper provides the sync API.
637
- */
638
- export class MessagePortTransport {
639
- free(): void;
640
- [Symbol.dispose](): void;
641
- /**
642
- * Disconnect (close the port).
643
- */
644
- disconnect(): Promise<any>;
645
- /**
646
- * Create a new connection wrapping the given `MessagePort`.
647
- */
648
- constructor(port: any);
649
- /**
650
- * Receive raw bytes (for the handshake phase).
651
- */
652
- recvBytes(): Promise<any>;
653
- /**
654
- * Send raw bytes (for the handshake phase).
655
- */
656
- sendBytes(bytes: Uint8Array): Promise<any>;
657
- }
658
-
659
- /**
660
- * A 64-bit nonce represented as big-endian bytes.
661
- */
662
- export class Nonce {
663
- free(): void;
664
- [Symbol.dispose](): void;
665
- /**
666
- * Create a new [`WasmNonce`] from exactly 8 big-endian bytes.
667
- *
668
- * # Errors
669
- *
670
- * Returns [`WasmNonceError`] if the input is not exactly 8 bytes.
671
- */
672
- constructor(bytes: Uint8Array);
673
- /**
674
- * Generate a random nonce.
675
- *
676
- * # Panics
677
- *
678
- * Panics if the system random number generator fails.
679
- */
680
- static random(): Nonce;
681
- /**
682
- * Get the nonce as big-endian bytes.
683
- */
684
- readonly bytes: Uint8Array;
685
- }
686
-
687
- /**
688
- * Result of a peer batch sync request.
689
- */
690
- export class PeerBatchSyncResult {
691
- private constructor();
692
- free(): void;
693
- [Symbol.dispose](): void;
694
- /**
695
- * Statistics about the sync operation.
696
- */
697
- readonly stats: SyncStats;
698
- /**
699
- * Whether the batch sync was successful with at least one connection.
700
- */
701
- readonly success: boolean;
702
- /**
703
- * Errors that occurred during the batch sync.
704
- */
705
- readonly transportErrors: Error[];
706
- }
707
-
708
- /**
709
- * A JavaScript-compatible wrapper around the Rust `PeerId` type.
710
- */
711
- export class PeerId {
712
- free(): void;
713
- [Symbol.dispose](): void;
714
- /**
715
- * Creates a new `WasmPeerId` from a `PeerId`.
716
- *
717
- * # Errors
718
- *
719
- * Returns a `WasmInvalidPeerId` if the provided byte slice is not exactly 32 bytes long.
720
- */
721
- constructor(bytes: Uint8Array);
722
- /**
723
- * Returns the byte representation of the `PeerId`.
724
- */
725
- toBytes(): Uint8Array;
726
- /**
727
- * Returns the string representation of the `PeerId`.
728
- */
729
- toString(): string;
730
- }
731
-
732
- /**
733
- * Map of peer IDs to their batch sync results.
734
- */
735
- export class PeerResultMap {
736
- private constructor();
737
- free(): void;
738
- [Symbol.dispose](): void;
739
- /**
740
- * Get all entries in the peer result map.
741
- */
742
- entries(): PeerBatchSyncResult[];
743
- /**
744
- * Get the result for a specific peer ID.
745
- */
746
- getResult(peer_id: PeerId): PeerBatchSyncResult | undefined;
747
- }
748
-
749
- /**
750
- * Wasm wrapper for [`RequestId`].
751
- */
752
- export class RequestId {
753
- free(): void;
754
- [Symbol.dispose](): void;
755
- /**
756
- * Upcasts; to the JS-import type for [`WasmRequestId`].
757
- */
758
- __wasm_refgen_toWasmRequestId(): RequestId;
759
- /**
760
- * Create a new [`RequestId`] from a requestor peer ID and nonce.
761
- */
762
- constructor(requestor: PeerId, nonce: Nonce);
763
- /**
764
- * The request nonce.
765
- */
766
- readonly nonce: Nonce;
767
- /**
768
- * The peer ID of the requestor.
769
- */
770
- readonly requestor: PeerId;
771
- }
772
-
773
- /**
774
- * The main Sedimentree data structure.
775
- */
776
- export class Sedimentree {
777
- free(): void;
778
- [Symbol.dispose](): void;
779
- /**
780
- * Create an empty Sedimentree.
781
- */
782
- static empty(): Sedimentree;
783
- /**
784
- * Create a new Sedimentree from fragments and loose commits.
785
- */
786
- constructor(fragments: Fragment[], commits: LooseCommit[]);
787
- }
788
-
789
- /**
790
- * A Wasm wrapper around the [`SedimentreeId`] type.
791
- */
792
- export class SedimentreeId {
793
- private constructor();
794
- free(): void;
795
- [Symbol.dispose](): void;
796
- /**
797
- * Upcasts; to the JS-import type for [`WasmSedimentreeId`].
798
- */
799
- __wasm_refgen_toWasmSedimentreeId(): SedimentreeId;
800
- /**
801
- * Create an ID from a byte array.
802
- *
803
- * # Errors
804
- *
805
- * Returns `Not32Bytes` if the provided byte array is not exactly 32 bytes long.
806
- */
807
- static fromBytes(bytes: Uint8Array): SedimentreeId;
808
- /**
809
- * Returns the raw bytes of this ID.
810
- */
811
- toBytes(): Uint8Array;
812
- /**
813
- * Returns the string representation of the ID.
814
- */
815
- toString(): string;
816
- }
817
-
818
- export class SedimentreeIdsArray {
819
- private constructor();
820
- free(): void;
821
- [Symbol.dispose](): void;
822
- /**
823
- * Upcasts; to the JS-import type for [`WasmSedimentreeIdsArray`].
824
- */
825
- __wasm_refgen_toWasmSedimentreeIdsArray(): SedimentreeIdsArray;
826
- }
827
-
828
- /**
829
- * A Wasm wrapper around `Signed<Fragment>`.
830
- */
831
- export class SignedFragment {
832
- private constructor();
833
- free(): void;
834
- [Symbol.dispose](): void;
835
- /**
836
- * Upcasts; to the JS-import type for [`WasmSignedFragment`].
837
- */
838
- __wasm_refgen_toWasmSignedFragment(): SignedFragment;
839
- /**
840
- * Encode this signed fragment to raw bytes.
841
- */
842
- encode(): Uint8Array;
843
- /**
844
- * Decode a `SignedFragment` from raw bytes.
845
- *
846
- * # Errors
847
- *
848
- * Returns an error if the bytes are not a valid signed fragment.
849
- */
850
- static tryDecode(bytes: Uint8Array): SignedFragment;
851
- /**
852
- * Get the unsigned payload without re-verifying the signature.
853
- *
854
- * # Errors
855
- *
856
- * Returns an error if the payload cannot be decoded.
857
- */
858
- readonly payload: Fragment;
859
- }
860
-
861
- /**
862
- * A Wasm wrapper around `Signed<LooseCommit>`.
863
- */
864
- export class SignedLooseCommit {
865
- private constructor();
866
- free(): void;
867
- [Symbol.dispose](): void;
868
- /**
869
- * Upcasts; to the JS-import type for [`WasmSignedLooseCommit`].
870
- */
871
- __wasm_refgen_toWasmSignedLooseCommit(): SignedLooseCommit;
872
- /**
873
- * Encode this signed loose commit to raw bytes.
874
- */
875
- encode(): Uint8Array;
876
- /**
877
- * Decode a `SignedLooseCommit` from raw bytes.
878
- *
879
- * # Errors
880
- *
881
- * Returns an error if the bytes are not a valid signed loose commit.
882
- */
883
- static tryDecode(bytes: Uint8Array): SignedLooseCommit;
884
- /**
885
- * Get the unsigned payload without re-verifying the signature.
886
- *
887
- * # Errors
888
- *
889
- * Returns an error if the payload cannot be decoded.
890
- */
891
- readonly payload: LooseCommit;
892
- }
893
-
894
- /**
895
- * Wasm bindings for [`Subduction`](subduction_core::Subduction)
896
- */
897
- export class Subduction {
898
- free(): void;
899
- [Symbol.dispose](): void;
900
- /**
901
- * Accept a connection from a peer over any [`Transport`](JsTransport).
902
- *
903
- * Performs the responder side of the handshake, then adds the authenticated
904
- * connection. This is the counterpart to [`connectTransport`](Self::connect_transport).
905
- *
906
- * # Arguments
907
- *
908
- * * `transport` - Any JS object with `sendBytes`/`recvBytes`/`disconnect`
909
- * * `service_name` - Shared service name for discovery
910
- *
911
- * # Errors
912
- *
913
- * Returns an error if the handshake or connection fails.
914
- */
915
- acceptTransport(transport: Transport, service_name: string): Promise<PeerId>;
916
- /**
917
- * Add a commit with its associated blob to the storage.
918
- *
919
- * The commit metadata (including `BlobMeta`) is computed internally from
920
- * the provided blob, ensuring consistency by construction.
921
- *
922
- * # Errors
923
- *
924
- * Returns a [`WasmWriteError`] if storage, networking, or policy fail.
925
- */
926
- addCommit(id: SedimentreeId, parents: Digest[], blob: Uint8Array): Promise<FragmentRequested | undefined>;
927
- /**
928
- * Onboard an authenticated transport: add it and sync all sedimentrees.
929
- *
930
- * Accepts an [`AuthenticatedTransport`](WasmAuthenticatedTransport),
931
- * obtained via [`AuthenticatedTransport.setup`](WasmAuthenticatedTransport::setup),
932
- * [`AuthenticatedWebSocket.toTransport`], or [`AuthenticatedLongPoll.toTransport`].
933
- *
934
- * Returns `true` if this is a new peer, `false` if already connected.
935
- *
936
- * Add an authenticated transport to tracking.
937
- *
938
- * This does not perform any synchronization. To sync after adding,
939
- * call [`fullSyncWithPeer`](Self::full_sync_with_peer).
940
- *
941
- * Returns `true` if this is a new peer, `false` if already connected.
942
- *
943
- * # Errors
944
- *
945
- * Returns an error if the connection is rejected by the policy.
946
- */
947
- addConnection(transport: AuthenticatedTransport): Promise<boolean>;
948
- /**
949
- * Add a fragment with its associated blob to the storage.
950
- *
951
- * The fragment metadata (including `BlobMeta`) is computed internally from
952
- * the provided blob, ensuring consistency by construction.
953
- *
954
- * # Errors
955
- *
956
- * Returns a [`WasmWriteError`] if storage, networking, or policy fail.
957
- */
958
- addFragment(id: SedimentreeId, head: Digest, boundary: Digest[], checkpoints: Digest[], blob: Uint8Array): Promise<void>;
959
- /**
960
- * Add a Sedimentree.
961
- *
962
- * # Errors
963
- *
964
- * Returns [`WasmWriteError`] if there is a problem with storage, networking, or policy.
965
- */
966
- addSedimentree(id: SedimentreeId, sedimentree: Sedimentree, blobs: Uint8Array[]): Promise<void>;
967
- /**
968
- * Connect to a peer via WebSocket and add the connection.
969
- *
970
- * This performs the cryptographic handshake, verifies the server's identity,
971
- * and adds the authenticated connection for syncing.
972
- *
973
- * Returns the verified peer ID on success.
974
- *
975
- * # Arguments
976
- *
977
- * * `address` - The WebSocket URL to connect to
978
- * * `expected_peer_id` - The expected server peer ID (verified during handshake)
979
- *
980
- * # Errors
981
- *
982
- * Returns an error if connection, handshake, or adding the connection fails.
983
- */
984
- connect(address: URL, expected_peer_id: PeerId): Promise<PeerId>;
985
- /**
986
- * Connect to a peer via WebSocket using discovery mode and add the connection.
987
- *
988
- * Returns the discovered and verified peer ID on success.
989
- *
990
- * # Arguments
991
- *
992
- * * `address` - The WebSocket URL to connect to
993
- * * `timeout_milliseconds` - Request timeout in milliseconds (defaults to 30000)
994
- * * `service_name` - The service name for discovery (defaults to URL host)
995
- *
996
- * # Errors
997
- *
998
- * Returns an error if connection, handshake, or adding the connection fails.
999
- */
1000
- connectDiscover(address: URL, service_name?: string | null): Promise<PeerId>;
1001
- /**
1002
- * Connect to a peer via HTTP long-poll using discovery mode.
1003
- *
1004
- * Returns the discovered and verified peer ID on success.
1005
- *
1006
- * # Arguments
1007
- *
1008
- * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
1009
- * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
1010
- * * `service_name` - The service name for discovery (defaults to `base_url`)
1011
- *
1012
- * # Errors
1013
- *
1014
- * Returns an error if connection, handshake, or adding the connection fails.
1015
- */
1016
- connectDiscoverLongPoll(base_url: string, service_name?: string | null): Promise<PeerId>;
1017
- /**
1018
- * Connect to a peer via HTTP long-poll and add the connection.
1019
- *
1020
- * Returns the verified peer ID on success.
1021
- *
1022
- * # Arguments
1023
- *
1024
- * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
1025
- * * `expected_peer_id` - The expected server peer ID (verified during handshake)
1026
- * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
1027
- *
1028
- * # Errors
1029
- *
1030
- * Returns an error if connection, handshake, or adding the connection fails.
1031
- */
1032
- connectLongPoll(base_url: string, expected_peer_id: PeerId): Promise<PeerId>;
1033
- /**
1034
- * Connect to a peer over any [`Transport`](JsTransport) using discovery mode.
1035
- *
1036
- * Performs a discovery handshake, then adds the authenticated connection.
1037
- * The peer's identity is discovered during the handshake.
1038
- *
1039
- * # Arguments
1040
- *
1041
- * * `transport` - Any JS object with `sendBytes`/`recvBytes`/`disconnect`
1042
- * * `service_name` - Shared service name for discovery
1043
- *
1044
- * # Errors
1045
- *
1046
- * Returns an error if the handshake or connection fails.
1047
- */
1048
- connectTransport(transport: Transport, service_name: string): Promise<PeerId>;
1049
- /**
1050
- * Disconnect from all peers.
1051
- *
1052
- * # Errors
1053
- *
1054
- * Returns a [`WasmDisconnectionError`] if disconnection was not graceful.
1055
- */
1056
- disconnectAll(): Promise<void>;
1057
- /**
1058
- * Disconnect from a peer by its ID.
1059
- *
1060
- * # Errors
1061
- *
1062
- * Returns a `WasmDisconnectionError` if disconnection fails.
1063
- */
1064
- disconnectFromPeer(peer_id: PeerId): Promise<boolean>;
1065
- /**
1066
- * Fetch blobs by their digests, with an optional timeout in milliseconds.
1067
- *
1068
- * # Errors
1069
- *
1070
- * Returns a [`WasmIoError`] if storage or networking fail.
1071
- */
1072
- fetchBlobs(id: SedimentreeId, timeout_milliseconds?: bigint | null): Promise<Uint8Array[] | undefined>;
1073
- /**
1074
- * Sync all known Sedimentree IDs with all connected peers.
1075
- */
1076
- fullSyncWithAllPeers(timeout_milliseconds?: bigint | null): Promise<PeerBatchSyncResult>;
1077
- /**
1078
- * Sync all known Sedimentree IDs with a single peer.
1079
- *
1080
- * # Arguments
1081
- *
1082
- * * `peer_id` - The peer to sync with
1083
- * * `subscribe` - Whether to subscribe to future updates (default: `true`)
1084
- * * `timeout_milliseconds` - Per-call timeout in milliseconds
1085
- */
1086
- fullSyncWithPeer(peer_id: PeerId, subscribe?: boolean | null, timeout_milliseconds?: bigint | null): Promise<PeerBatchSyncResult>;
1087
- /**
1088
- * Get a local blob by its digest.
1089
- *
1090
- * # Errors
1091
- *
1092
- * Returns a [`JsStorageError`] if JS storage fails.
1093
- */
1094
- getBlob(id: SedimentreeId, digest: Digest): Promise<Uint8Array | undefined>;
1095
- /**
1096
- * Get all local blobs for a given Sedimentree ID.
1097
- *
1098
- * # Errors
1099
- *
1100
- * Returns a [`JsStorageError`] if JS storage fails.
1101
- */
1102
- getBlobs(id: SedimentreeId): Promise<Uint8Array[]>;
1103
- /**
1104
- * Get all commits for a given Sedimentree ID
1105
- */
1106
- getCommits(id: SedimentreeId): Promise<LooseCommit[] | undefined>;
1107
- /**
1108
- * Get the peer IDs of all connected peers.
1109
- */
1110
- getConnectedPeerIds(): Promise<PeerId[]>;
1111
- /**
1112
- * Get all fragments for a given Sedimentree ID
1113
- */
1114
- getFragments(id: SedimentreeId): Promise<Fragment[] | undefined>;
1115
- /**
1116
- * Hydrate a [`Subduction`] instance from external storage.
1117
- *
1118
- * Loads all sedimentree data from storage and reconstructs the in-memory
1119
- * state before initializing the sync engine.
1120
- *
1121
- * # Arguments
1122
- *
1123
- * * `signer` - The cryptographic signer for this node's identity
1124
- * * `storage` - Storage backend for persisting data
1125
- * * `service_name` - Optional service identifier for discovery mode (e.g., `sync.example.com`).
1126
- * When set, clients can connect without knowing the server's peer ID.
1127
- * * `hash_metric_override` - Optional custom depth metric function
1128
- * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
1129
- *
1130
- * # Panics
1131
- *
1132
- * Panics if `hash_metric_override` is `Some` but the underlying JS value
1133
- * cannot be cast to a `Function`.
1134
- *
1135
- * # Errors
1136
- *
1137
- * Returns [`WasmHydrationError`] if hydration fails.
1138
- */
1139
- static hydrate(signer: any, storage: SedimentreeStorage, service_name?: string | null, hash_metric_override?: (digest: Digest) => Depth | null, max_pending_blob_requests?: number | null): Promise<Subduction>;
1140
- /**
1141
- * Link two local [`Subduction`](WasmSubduction) instances over a
1142
- * [`MessageChannel`](web_sys::MessageChannel).
1143
- *
1144
- * Creates a `MessageChannel`, performs a discovery handshake between
1145
- * the two instances, and adds the connections to both. This is the
1146
- * simplest way to sync two local instances.
1147
- *
1148
- * # Errors
1149
- *
1150
- * Returns an error if the handshake or connection fails.
1151
- */
1152
- static link(a: Subduction, b: Subduction): Promise<void>;
1153
- /**
1154
- * Create a new [`Subduction`] instance.
1155
- *
1156
- * # Arguments
1157
- *
1158
- * * `signer` - The cryptographic signer for this node's identity
1159
- * * `storage` - Storage backend for persisting data
1160
- * * `service_name` - Optional service identifier for discovery mode (e.g., `sync.example.com`).
1161
- * When set, clients can connect without knowing the server's peer ID.
1162
- * * `hash_metric_override` - Optional custom depth metric function
1163
- * * `max_pending_blob_requests` - Optional maximum number of pending blob requests (default: 10,000)
1164
- *
1165
- * # Panics
1166
- *
1167
- * Panics if `hash_metric_override` is `Some` but the underlying JS value
1168
- * cannot be cast to a `Function`.
1169
- */
1170
- constructor(signer: any, storage: SedimentreeStorage, service_name?: string | null, hash_metric_override?: (digest: Digest) => Depth | null, max_pending_blob_requests?: number | null);
1171
- /**
1172
- * Remove a Sedimentree and all associated data.
1173
- *
1174
- * # Errors
1175
- *
1176
- * Returns a [`WasmIoError`] if storage or networking fail.
1177
- */
1178
- removeSedimentree(id: SedimentreeId): Promise<void>;
1179
- /**
1180
- * Request blobs by their digests from connected peers for a specific sedimentree.
1181
- */
1182
- requestBlobs(id: SedimentreeId, digests: Digest[]): Promise<void>;
1183
- /**
1184
- * Get all known Sedimentree IDs
1185
- */
1186
- sedimentreeIds(): Promise<SedimentreeId[]>;
1187
- /**
1188
- * Request batch sync for a given Sedimentree ID from all connected peers.
1189
- *
1190
- * # Arguments
1191
- *
1192
- * * `id` - The sedimentree ID to sync
1193
- * * `subscribe` - Whether to subscribe for incremental updates
1194
- * * `timeout_milliseconds` - Optional timeout in milliseconds
1195
- *
1196
- * # Errors
1197
- *
1198
- * Returns a [`WasmIoError`] if storage or networking fail.
1199
- */
1200
- syncWithAllPeers(id: SedimentreeId, subscribe: boolean, timeout_milliseconds?: bigint | null): Promise<PeerResultMap>;
1201
- /**
1202
- * Request batch sync for a given Sedimentree ID from a specific peer.
1203
- *
1204
- * # Arguments
1205
- *
1206
- * * `to_ask` - The peer ID to sync with
1207
- * * `id` - The sedimentree ID to sync
1208
- * * `subscribe` - Whether to subscribe for incremental updates
1209
- * * `timeout_milliseconds` - Optional timeout in milliseconds
1210
- *
1211
- * # Errors
1212
- *
1213
- * Returns a [`WasmIoError`] if storage or networking fail.
1214
- */
1215
- syncWithPeer(to_ask: PeerId, id: SedimentreeId, subscribe: boolean, timeout_milliseconds?: bigint | null): Promise<PeerBatchSyncResult>;
1216
- /**
1217
- * Get the backing storage.
1218
- */
1219
- readonly storage: any;
1220
- }
1221
-
1222
- /**
1223
- * JS-facing wrapper around [`HttpLongPollTransport`] that exposes the
1224
- * byte-oriented [`Transport`](super::JsTransport) interface
1225
- * (`sendBytes`/`recvBytes`/`disconnect`) so it can be used as a
1226
- * duck-typed `JsTransport` from JavaScript.
1227
- */
1228
- export class SubductionHttpLongPoll {
1229
- private constructor();
1230
- free(): void;
1231
- [Symbol.dispose](): void;
1232
- /**
1233
- * Disconnect from the peer gracefully.
1234
- *
1235
- * # Errors
1236
- *
1237
- * Returns an error if the disconnect fails.
1238
- */
1239
- disconnect(): Promise<void>;
1240
- /**
1241
- * Receive the next message frame as raw bytes.
1242
- *
1243
- * # Errors
1244
- *
1245
- * Returns an error if the inbound channel is closed.
1246
- */
1247
- recvBytes(): Promise<Uint8Array>;
1248
- /**
1249
- * Send raw bytes over the transport.
1250
- *
1251
- * # Errors
1252
- *
1253
- * Returns an error if the outbound channel is closed.
1254
- */
1255
- sendBytes(bytes: Uint8Array): Promise<void>;
1256
- }
1257
-
1258
- /**
1259
- * HTTP long-poll transport factory for browser/worker environments.
1260
- *
1261
- * Analogous to [`SubductionWebSocket`] but uses HTTP long-poll instead of WebSocket.
1262
- */
1263
- export class SubductionLongPoll {
1264
- private constructor();
1265
- free(): void;
1266
- [Symbol.dispose](): void;
1267
- /**
1268
- * Connect to a server with a known peer ID.
1269
- *
1270
- * # Arguments
1271
- *
1272
- * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
1273
- * * `signer` - The client's signer for authentication
1274
- * * `expected_peer_id` - The expected server peer ID (verified during handshake)
1275
- * * `timeout_milliseconds` - Request timeout in milliseconds (default: 30000)
1276
- *
1277
- * # Errors
1278
- *
1279
- * Returns [`LongPollTransportError`] if connection or handshake fails.
1280
- */
1281
- static tryConnect(base_url: string, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedLongPoll>;
1282
- /**
1283
- * Connect to a server using discovery mode.
1284
- *
1285
- * # Arguments
1286
- *
1287
- * * `base_url` - The server's HTTP base URL (e.g., `http://localhost:8080`)
1288
- * * `signer` - The client's signer for authentication
1289
- * * `service_name` - The service name for discovery. If omitted, the base URL is used.
1290
- *
1291
- * # Errors
1292
- *
1293
- * Returns [`LongPollTransportError`] if connection or handshake fails.
1294
- */
1295
- static tryDiscover(base_url: string, signer: any, service_name?: string | null): Promise<AuthenticatedLongPoll>;
1296
- }
1297
-
1298
- /**
1299
- * A WebSocket transport exposing the byte-oriented `Transport` interface.
1300
- *
1301
- * Raw bytes from the WebSocket's `onmessage` handler are buffered in an
1302
- * `async_channel` and returned via `recvBytes`. No message decoding or
1303
- * request-response routing happens here — that's handled by
1304
- * [`MessageTransport`](subduction_core::transport::message::MessageTransport).
1305
- */
1306
- export class SubductionWebSocket {
1307
- private constructor();
1308
- free(): void;
1309
- [Symbol.dispose](): void;
1310
- /**
1311
- * Disconnect from the peer gracefully.
1312
- */
1313
- disconnect(): Promise<void>;
1314
- /**
1315
- * Receive the next message frame as raw bytes.
1316
- *
1317
- * # Errors
1318
- *
1319
- * Returns [`ReadFromClosedChannel`] if the channel has been closed.
1320
- */
1321
- recvBytes(): Promise<Uint8Array>;
1322
- /**
1323
- * Send raw bytes over the WebSocket.
1324
- *
1325
- * # Errors
1326
- *
1327
- * Returns [`WasmSendError`] if the bytes could not be sent.
1328
- */
1329
- sendBytes(bytes: Uint8Array): Promise<void>;
1330
- /**
1331
- * Authenticate an existing WebSocket via handshake.
1332
- *
1333
- * This performs the Subduction handshake protocol over the provided WebSocket
1334
- * to establish mutual identity. The WebSocket can be in CONNECTING or OPEN state.
1335
- *
1336
- * # Arguments
1337
- *
1338
- * * `ws` - An existing WebSocket (CONNECTING or OPEN)
1339
- * * `signer` - The client's signer for authentication
1340
- * * `expected_peer_id` - The expected server peer ID (verified during handshake)
1341
- * * `timeout_milliseconds` - Request timeout in milliseconds
1342
- *
1343
- * # Errors
1344
- *
1345
- * Returns an error if the handshake fails (signature invalid, wrong peer, etc.)
1346
- */
1347
- static setup(ws: WebSocket, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedWebSocket>;
1348
- /**
1349
- * Connect to a WebSocket server with mutual authentication via handshake.
1350
- *
1351
- * # Arguments
1352
- *
1353
- * * `address` - The WebSocket URL to connect to
1354
- * * `signer` - The client's signer for authentication
1355
- * * `expected_peer_id` - The expected server peer ID (verified during handshake)
1356
- * # Errors
1357
- *
1358
- * Returns an error if:
1359
- * - The WebSocket connection could not be established
1360
- * - The handshake fails (signature invalid, wrong server, clock drift, etc.)
1361
- */
1362
- static tryConnect(address: URL, signer: any, expected_peer_id: PeerId): Promise<AuthenticatedWebSocket>;
1363
- /**
1364
- * Connect to a WebSocket server using discovery mode.
1365
- *
1366
- * This method performs a cryptographic handshake using a service name
1367
- * instead of a known peer ID. The server's peer ID is discovered during
1368
- * the handshake and returned.
1369
- *
1370
- * # Arguments
1371
- *
1372
- * * `address` - The WebSocket URL to connect to
1373
- * * `signer` - The client's signer for authentication
1374
- * * `timeout_milliseconds` - Request timeout in milliseconds. Defaults to 30000 (30s).
1375
- * * `service_name` - The service name for discovery (e.g., `localhost:8080`).
1376
- * If omitted, the host is extracted from the URL.
1377
- *
1378
- * # Errors
1379
- *
1380
- * Returns an error if:
1381
- * - The WebSocket connection could not be established
1382
- * - The handshake fails (signature invalid, clock drift, etc.)
1383
- */
1384
- static tryDiscover(address: URL, signer: any, service_name?: string | null): Promise<AuthenticatedWebSocket>;
1385
- }
1386
-
1387
- /**
1388
- * Wasm wrapper for [`SyncMessage`].
1389
- */
1390
- export class SyncMessage {
1391
- private constructor();
1392
- free(): void;
1393
- [Symbol.dispose](): void;
1394
- /**
1395
- * Upcasts; to the JS-import type for [`WasmMessage`].
1396
- */
1397
- __wasm_refgen_toWasmMessage(): SyncMessage;
1398
- /**
1399
- * Create a [`SyncMessage::BatchSyncRequest`] message.
1400
- */
1401
- static batchSyncRequest(request: BatchSyncRequest): SyncMessage;
1402
- /**
1403
- * Create a [`SyncMessage::BatchSyncResponse`] message.
1404
- */
1405
- static batchSyncResponse(response: BatchSyncResponse): SyncMessage;
1406
- /**
1407
- * Create a [`SyncMessage::BlobsRequest`] message.
1408
- */
1409
- static blobsRequest(id: SedimentreeId, digests: Digest[]): SyncMessage;
1410
- /**
1411
- * Create a [`SyncMessage::BlobsResponse`] message.
1412
- */
1413
- static blobsResponse(id: SedimentreeId, blobs: Uint8Array[]): SyncMessage;
1414
- /**
1415
- * Deserialize a message from bytes.
1416
- *
1417
- * # Errors
1418
- *
1419
- * Returns a [`JsMessageDeserializationError`] if deserialization fails.
1420
- */
1421
- static fromBytes(bytes: Uint8Array): SyncMessage;
1422
- /**
1423
- * Serialize the message to bytes.
1424
- */
1425
- toBytes(): Uint8Array;
1426
- /**
1427
- * The [`Blob`] for commit or fragment messages, if applicable.
1428
- */
1429
- readonly blob: Uint8Array | undefined;
1430
- /**
1431
- * The [`Blob`]s for a [`SyncMessage::BlobsResponse`], if applicable.
1432
- */
1433
- readonly blobs: Uint8Array[] | undefined;
1434
- /**
1435
- * The [`LooseCommit`] for a [`SyncMessage::LooseCommit`], if applicable.
1436
- *
1437
- * Decodes the signed payload to extract the underlying commit.
1438
- */
1439
- readonly commit: LooseCommit | undefined;
1440
- /**
1441
- * The requested [`Digest`]s for a [`SyncMessage::BlobsRequest`], if applicable.
1442
- */
1443
- readonly digests: Digest[] | undefined;
1444
- /**
1445
- * The [`Fragment`] for a [`SyncMessage::Fragment`], if applicable.
1446
- *
1447
- * Decodes the signed payload to extract the underlying fragment.
1448
- */
1449
- readonly fragment: Fragment | undefined;
1450
- /**
1451
- * The [`BatchSyncRequest`] for a [`SyncMessage::BatchSyncRequest`], if applicable.
1452
- */
1453
- readonly request: BatchSyncRequest | undefined;
1454
- /**
1455
- * The [`BatchSyncResponse`] for a [`SyncMessage::BatchSyncResponse`], if applicable.
1456
- */
1457
- readonly response: BatchSyncResponse | undefined;
1458
- /**
1459
- * The [`SedimentreeId`] associated with this message, if any.
1460
- */
1461
- readonly sedimentreeId: SedimentreeId | undefined;
1462
- /**
1463
- * The message variant name.
1464
- */
1465
- readonly type: string;
1466
- }
1467
-
1468
- /**
1469
- * Statistics from a sync operation.
1470
- *
1471
- * The "sent" counts reflect items that were _successfully_ sent over the wire,
1472
- * not just items that were requested.
1473
- */
1474
- export class SyncStats {
1475
- private constructor();
1476
- free(): void;
1477
- [Symbol.dispose](): void;
1478
- /**
1479
- * Number of commits received from the peer.
1480
- */
1481
- readonly commitsReceived: number;
1482
- /**
1483
- * Number of commits successfully sent to the peer.
1484
- */
1485
- readonly commitsSent: number;
1486
- /**
1487
- * Number of fragments received from the peer.
1488
- */
1489
- readonly fragmentsReceived: number;
1490
- /**
1491
- * Number of fragments successfully sent to the peer.
1492
- */
1493
- readonly fragmentsSent: number;
1494
- /**
1495
- * Returns true if no data was exchanged.
1496
- */
1497
- readonly isEmpty: boolean;
1498
- /**
1499
- * Total items received (commits + fragments).
1500
- */
1501
- readonly totalReceived: number;
1502
- /**
1503
- * Total items sent (commits + fragments).
1504
- */
1505
- readonly totalSent: number;
1506
- }
1507
-
1508
- /**
1509
- * An Ed25519 signer using the browser's `WebCrypto` API.
1510
- *
1511
- * This signer generates and stores Ed25519 keys using `crypto.subtle`,
1512
- * providing secure key generation and signing operations. The key is
1513
- * persisted to `IndexedDB` so it survives page reloads.
1514
- *
1515
- * # Example
1516
- *
1517
- * ```javascript
1518
- * import { WebCryptoSigner } from "@anthropic/subduction";
1519
- *
1520
- * const signer = await WebCryptoSigner.setup();
1521
- * console.log("Peer ID:", signer.peerId().toString());
1522
- * ```
1523
- */
1524
- export class WebCryptoSigner {
1525
- private constructor();
1526
- free(): void;
1527
- [Symbol.dispose](): void;
1528
- /**
1529
- * Get the peer ID derived from this signer's verifying key.
1530
- *
1531
- * # Panics
1532
- *
1533
- * Panics if the stored public key bytes are invalid (should never happen).
1534
- */
1535
- peerId(): PeerId;
1536
- /**
1537
- * Set up the signer, loading an existing key from `IndexedDB` or generating a new one.
1538
- *
1539
- * # Errors
1540
- *
1541
- * Returns an error if `WebCrypto` or `IndexedDB` operations fail.
1542
- */
1543
- static setup(): Promise<WebCryptoSigner>;
1544
- /**
1545
- * Sign a message and return the 64-byte Ed25519 signature.
1546
- *
1547
- * # Errors
1548
- *
1549
- * Returns an error if `WebCrypto` signing fails.
1550
- */
1551
- sign(message: Uint8Array): Promise<Uint8Array>;
1552
- /**
1553
- * Get the 32-byte Ed25519 verifying (public) key.
1554
- */
1555
- verifyingKey(): Uint8Array;
1556
- }
1557
-
1558
- /**
1559
- * Convenience factory — equivalent to `new MessagePortTransport(port)`.
1560
- */
1561
- export function makeMessagePortTransport(port: any): MessagePortTransport;
1562
-
1563
- /**
1564
- * Entry point called when the Wasm module is instantiated.
1565
- *
1566
- * Only compiled when the `standalone` feature is active. Downstream cdylib
1567
- * crates that define their own `#[wasm_bindgen(start)]` should depend on
1568
- * `subduction_wasm` with `default-features = false` and call
1569
- * [`set_panic_hook`] from their own start function.
1570
- */
1571
- export function start(): void;
1572
-
1573
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1574
-
1575
- export interface InitOutput {
1576
- readonly memory: WebAssembly.Memory;
1577
- readonly start: () => void;
1578
- readonly __wbg_fragmentrequested_free: (a: number, b: number) => void;
1579
- readonly fragmentrequested_new: (a: number, b: number) => number;
1580
- readonly fragmentrequested_head: (a: number) => number;
1581
- readonly fragmentrequested_depth: (a: number) => number;
1582
- readonly __wbg_memorysigner_free: (a: number, b: number) => void;
1583
- readonly memorysigner_generate: () => number;
1584
- readonly memorysigner_fromBytes: (a: number, b: number) => [number, number, number];
1585
- readonly memorysigner_sign: (a: number, b: number, c: number) => any;
1586
- readonly memorysigner_verifyingKey: (a: number) => any;
1587
- readonly memorysigner_peerId: (a: number) => number;
1588
- readonly __wbg_peerid_free: (a: number, b: number) => void;
1589
- readonly peerid_new: (a: number, b: number) => [number, number, number];
1590
- readonly peerid_toBytes: (a: number) => [number, number];
1591
- readonly peerid_toString: (a: number) => [number, number];
1592
- readonly webcryptosigner_setup: () => any;
1593
- readonly webcryptosigner_sign: (a: number, b: number, c: number) => any;
1594
- readonly webcryptosigner_verifyingKey: (a: number) => any;
1595
- readonly webcryptosigner_peerId: (a: number) => number;
1596
- readonly __wbg_subduction_free: (a: number, b: number) => void;
1597
- readonly subduction_new: (a: any, b: any, c: number, d: number, e: number, f: number) => number;
1598
- readonly subduction_hydrate: (a: any, b: any, c: number, d: number, e: number, f: number) => any;
1599
- readonly subduction_addSedimentree: (a: number, b: number, c: number, d: number, e: number) => any;
1600
- readonly subduction_removeSedimentree: (a: number, b: number) => any;
1601
- readonly subduction_connect: (a: number, b: any, c: number) => any;
1602
- readonly subduction_connectDiscover: (a: number, b: any, c: number, d: number) => any;
1603
- readonly subduction_connectLongPoll: (a: number, b: number, c: number, d: number) => any;
1604
- readonly subduction_connectDiscoverLongPoll: (a: number, b: number, c: number, d: number, e: number) => any;
1605
- readonly subduction_disconnectAll: (a: number) => any;
1606
- readonly subduction_disconnectFromPeer: (a: number, b: number) => any;
1607
- readonly subduction_addConnection: (a: number, b: number) => any;
1608
- readonly subduction_connectTransport: (a: number, b: any, c: number, d: number) => any;
1609
- readonly subduction_acceptTransport: (a: number, b: any, c: number, d: number) => any;
1610
- readonly subduction_link: (a: number, b: number) => any;
1611
- readonly subduction_getBlob: (a: number, b: number, c: number) => any;
1612
- readonly subduction_getBlobs: (a: number, b: number) => any;
1613
- readonly subduction_fetchBlobs: (a: number, b: number, c: number, d: bigint) => any;
1614
- readonly subduction_addCommit: (a: number, b: number, c: number, d: number, e: any) => any;
1615
- readonly subduction_addFragment: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => any;
1616
- readonly subduction_requestBlobs: (a: number, b: number, c: number, d: number) => any;
1617
- readonly subduction_syncWithPeer: (a: number, b: number, c: number, d: number, e: number, f: bigint) => any;
1618
- readonly subduction_syncWithAllPeers: (a: number, b: number, c: number, d: number, e: bigint) => any;
1619
- readonly subduction_fullSyncWithPeer: (a: number, b: number, c: number, d: number, e: bigint) => any;
1620
- readonly subduction_fullSyncWithAllPeers: (a: number, b: number, c: bigint) => any;
1621
- readonly subduction_sedimentreeIds: (a: number) => any;
1622
- readonly subduction_getCommits: (a: number, b: number) => any;
1623
- readonly subduction_getFragments: (a: number, b: number) => any;
1624
- readonly subduction_getConnectedPeerIds: (a: number) => any;
1625
- readonly subduction_storage: (a: number) => any;
1626
- readonly __wbg_peerbatchsyncresult_free: (a: number, b: number) => void;
1627
- readonly peerbatchsyncresult_success: (a: number) => number;
1628
- readonly peerbatchsyncresult_stats: (a: number) => number;
1629
- readonly peerbatchsyncresult_transportErrors: (a: number) => [number, number];
1630
- readonly __wbg_peerresultmap_free: (a: number, b: number) => void;
1631
- readonly peerresultmap_getResult: (a: number, b: number) => number;
1632
- readonly peerresultmap_entries: (a: number) => [number, number];
1633
- readonly __wbg_hashmetric_free: (a: number, b: number) => void;
1634
- readonly hashmetric_new: (a: number) => number;
1635
- readonly __wbg_callerror_free: (a: number, b: number) => void;
1636
- readonly __wbg_syncstats_free: (a: number, b: number) => void;
1637
- readonly syncstats_commitsReceived: (a: number) => number;
1638
- readonly syncstats_fragmentsReceived: (a: number) => number;
1639
- readonly syncstats_commitsSent: (a: number) => number;
1640
- readonly syncstats_fragmentsSent: (a: number) => number;
1641
- readonly syncstats_totalReceived: (a: number) => number;
1642
- readonly syncstats_totalSent: (a: number) => number;
1643
- readonly syncstats_isEmpty: (a: number) => number;
1644
- readonly __wbg_subductionhttplongpoll_free: (a: number, b: number) => void;
1645
- readonly subductionhttplongpoll_sendBytes: (a: number, b: number, c: number) => any;
1646
- readonly subductionhttplongpoll_recvBytes: (a: number) => any;
1647
- readonly subductionhttplongpoll_disconnect: (a: number) => any;
1648
- readonly __wbg_authenticatedlongpoll_free: (a: number, b: number) => void;
1649
- readonly authenticatedlongpoll_peerId: (a: number) => number;
1650
- readonly authenticatedlongpoll_sessionId: (a: number) => [number, number];
1651
- readonly authenticatedlongpoll_toTransport: (a: number) => number;
1652
- readonly __wbg_subductionlongpoll_free: (a: number, b: number) => void;
1653
- readonly subductionlongpoll_tryConnect: (a: number, b: number, c: any, d: number) => any;
1654
- readonly subductionlongpoll_tryDiscover: (a: number, b: number, c: any, d: number, e: number) => any;
1655
- readonly __wbg_syncmessage_free: (a: number, b: number) => void;
1656
- readonly syncmessage_toBytes: (a: number) => [number, number];
1657
- readonly syncmessage_fromBytes: (a: number, b: number) => [number, number, number];
1658
- readonly syncmessage_blobsRequest: (a: number, b: number, c: number) => number;
1659
- readonly syncmessage_blobsResponse: (a: number, b: number, c: number) => number;
1660
- readonly syncmessage_batchSyncRequest: (a: number) => number;
1661
- readonly syncmessage_batchSyncResponse: (a: number) => number;
1662
- readonly syncmessage_type: (a: number) => [number, number];
1663
- readonly syncmessage_sedimentreeId: (a: number) => number;
1664
- readonly syncmessage_commit: (a: number) => number;
1665
- readonly syncmessage_fragment: (a: number) => number;
1666
- readonly syncmessage_blob: (a: number) => any;
1667
- readonly syncmessage_digests: (a: number) => [number, number];
1668
- readonly syncmessage_blobs: (a: number) => [number, number];
1669
- readonly syncmessage_request: (a: number) => number;
1670
- readonly syncmessage_response: (a: number) => number;
1671
- readonly syncmessage___wasm_refgen_toWasmMessage: (a: number) => number;
1672
- readonly __wbg_messageporttransport_free: (a: number, b: number) => void;
1673
- readonly messageporttransport_sendBytes: (a: number, b: number, c: number) => any;
1674
- readonly messageporttransport_recvBytes: (a: number) => any;
1675
- readonly messageporttransport_disconnect: (a: number) => any;
1676
- readonly makeMessagePortTransport: (a: any) => number;
1677
- readonly __wbg_nonce_free: (a: number, b: number) => void;
1678
- readonly nonce_new: (a: number, b: number) => [number, number, number];
1679
- readonly nonce_random: () => number;
1680
- readonly nonce_bytes: (a: number) => [number, number];
1681
- readonly __wbg_subductionwebsocket_free: (a: number, b: number) => void;
1682
- readonly subductionwebsocket_setup: (a: any, b: any, c: number) => any;
1683
- readonly subductionwebsocket_tryConnect: (a: any, b: any, c: number) => any;
1684
- readonly subductionwebsocket_tryDiscover: (a: any, b: any, c: number, d: number) => any;
1685
- readonly subductionwebsocket_sendBytes: (a: number, b: number, c: number) => any;
1686
- readonly subductionwebsocket_recvBytes: (a: number) => any;
1687
- readonly subductionwebsocket_disconnect: (a: number) => any;
1688
- readonly __wbg_authenticatedwebsocket_free: (a: number, b: number) => void;
1689
- readonly authenticatedwebsocket_peerId: (a: number) => number;
1690
- readonly authenticatedwebsocket_toTransport: (a: number) => number;
1691
- readonly __wbg_requestid_free: (a: number, b: number) => void;
1692
- readonly requestid_new: (a: number, b: number) => number;
1693
- readonly requestid_requestor: (a: number) => number;
1694
- readonly requestid_nonce: (a: number) => number;
1695
- readonly requestid___wasm_refgen_toWasmRequestId: (a: number) => number;
1696
- readonly __wbg_batchsyncrequest_free: (a: number, b: number) => void;
1697
- readonly batchsyncrequest_id: (a: number) => number;
1698
- readonly batchsyncrequest_request_id: (a: number) => number;
1699
- readonly batchsyncrequest_subscribe: (a: number) => number;
1700
- readonly __wbg_batchsyncresponse_free: (a: number, b: number) => void;
1701
- readonly batchsyncresponse_id: (a: number) => number;
1702
- readonly batchsyncresponse_request_id: (a: number) => number;
1703
- readonly batchsyncresponse___wasm_refgen_toWasmBatchSyncResponse: (a: number) => number;
1704
- readonly __wbg_authenticatedtransport_free: (a: number, b: number) => void;
1705
- readonly authenticatedtransport_setup: (a: any, b: any, c: number) => any;
1706
- readonly authenticatedtransport_setupDiscover: (a: any, b: any, c: number, d: number) => any;
1707
- readonly authenticatedtransport_accept: (a: any, b: any, c: number) => any;
1708
- readonly authenticatedtransport_peerId: (a: number) => number;
1709
- readonly memorysigner_new: () => number;
1710
- readonly messageporttransport_new: (a: any) => number;
1711
- readonly __wbg_webcryptosigner_free: (a: number, b: number) => void;
1712
- readonly __wbg_depth_free: (a: number, b: number) => void;
1713
- readonly depth_new: (a: any) => [number, number, number];
1714
- readonly depth_value: (a: number) => number;
1715
- readonly depth___subduction_castToDepth: (a: number) => number;
1716
- readonly __wbg_digest_free: (a: number, b: number) => void;
1717
- readonly digest_new: (a: number, b: number) => [number, number, number];
1718
- readonly digest_fromBytes: (a: number, b: number) => [number, number, number];
1719
- readonly digest_fromBase58: (a: number, b: number) => [number, number, number];
1720
- readonly digest_toBytes: (a: number) => [number, number];
1721
- readonly digest_fromHexString: (a: number, b: number) => [number, number, number];
1722
- readonly digest_toHexString: (a: number) => [number, number];
1723
- readonly digest___wasm_refgen_toWasmDigest: (a: number) => number;
1724
- readonly __wbg_fragment_free: (a: number, b: number) => void;
1725
- readonly fragment_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
1726
- readonly fragment_head: (a: number) => number;
1727
- readonly fragment_boundary: (a: number) => [number, number];
1728
- readonly fragment_blobMeta: (a: number) => number;
1729
- readonly fragment___wasm_refgen_toWasmFragment: (a: number) => number;
1730
- readonly __wbg_fragmentsarray_free: (a: number, b: number) => void;
1731
- readonly fragmentsarray___wasm_refgen_toWasmFragmentsArray: (a: number) => number;
1732
- readonly fragmentwithblob_signed: (a: number) => number;
1733
- readonly fragmentwithblob___wasm_refgen_toWasmFragmentWithBlob: (a: number) => number;
1734
- readonly __wbg_loosecommit_free: (a: number, b: number) => void;
1735
- readonly loosecommit_new: (a: number, b: number, c: number, d: number) => number;
1736
- readonly loosecommit_digest: (a: number) => number;
1737
- readonly loosecommit_parents: (a: number) => [number, number];
1738
- readonly loosecommit_blobMeta: (a: number) => number;
1739
- readonly loosecommit___wasm_refgen_toWasmLooseCommit: (a: number) => number;
1740
- readonly __wbg_blobmeta_free: (a: number, b: number) => void;
1741
- readonly blobmeta_new: (a: number, b: number) => number;
1742
- readonly blobmeta_fromDigestSize: (a: number, b: bigint) => number;
1743
- readonly blobmeta_digest: (a: number) => number;
1744
- readonly blobmeta_sizeBytes: (a: number) => bigint;
1745
- readonly __wbg_commitwithblob_free: (a: number, b: number) => void;
1746
- readonly commitwithblob_new: (a: number, b: any) => number;
1747
- readonly commitwithblob_signed: (a: number) => number;
1748
- readonly commitwithblob_blob: (a: number) => any;
1749
- readonly commitwithblob___wasm_refgen_toWasmCommitWithBlob: (a: number) => number;
1750
- readonly __wbg_sedimentree_free: (a: number, b: number) => void;
1751
- readonly sedimentree_new: (a: number, b: number, c: number, d: number) => number;
1752
- readonly sedimentree_empty: () => number;
1753
- readonly sedimentreeid_fromBytes: (a: number, b: number) => [number, number, number];
1754
- readonly sedimentreeid_toString: (a: number) => [number, number];
1755
- readonly __wbg_sedimentreeidsarray_free: (a: number, b: number) => void;
1756
- readonly sedimentreeidsarray___wasm_refgen_toWasmSedimentreeIdsArray: (a: number) => number;
1757
- readonly signedloosecommit_tryDecode: (a: any) => [number, number, number];
1758
- readonly signedloosecommit_encode: (a: number) => any;
1759
- readonly signedloosecommit_payload: (a: number) => [number, number, number];
1760
- readonly signedloosecommit___wasm_refgen_toWasmSignedLooseCommit: (a: number) => number;
1761
- readonly __wbg_signedfragment_free: (a: number, b: number) => void;
1762
- readonly signedfragment_tryDecode: (a: any) => [number, number, number];
1763
- readonly signedfragment_encode: (a: number) => any;
1764
- readonly signedfragment_payload: (a: number) => [number, number, number];
1765
- readonly signedfragment___wasm_refgen_toWasmSignedFragment: (a: number) => number;
1766
- readonly __wbg_memorystorage_free: (a: number, b: number) => void;
1767
- readonly memorystorage_new: () => number;
1768
- readonly memorystorage_saveSedimentreeId: (a: number, b: number) => any;
1769
- readonly memorystorage_deleteSedimentreeId: (a: number, b: number) => any;
1770
- readonly memorystorage_loadAllSedimentreeIds: (a: number) => any;
1771
- readonly memorystorage_saveCommit: (a: number, b: number, c: number, d: number, e: any) => any;
1772
- readonly memorystorage_loadCommit: (a: number, b: number, c: number) => any;
1773
- readonly memorystorage_listCommitDigests: (a: number, b: number) => any;
1774
- readonly memorystorage_loadAllCommits: (a: number, b: number) => any;
1775
- readonly memorystorage_deleteCommit: (a: number, b: number, c: number) => any;
1776
- readonly memorystorage_deleteAllCommits: (a: number, b: number) => any;
1777
- readonly memorystorage_saveFragment: (a: number, b: number, c: number, d: number, e: any) => any;
1778
- readonly memorystorage_loadFragment: (a: number, b: number, c: number) => any;
1779
- readonly memorystorage_listFragmentDigests: (a: number, b: number) => any;
1780
- readonly memorystorage_loadAllFragments: (a: number, b: number) => any;
1781
- readonly memorystorage_deleteFragment: (a: number, b: number, c: number) => any;
1782
- readonly memorystorage_deleteAllFragments: (a: number, b: number) => any;
1783
- readonly depth___wasm_refgen_toWasmDepth: (a: number) => number;
1784
- readonly fragmentwithblob_new: (a: number, b: any) => number;
1785
- readonly __wbg_sedimentreeid_free: (a: number, b: number) => void;
1786
- readonly __wbg_fragmentwithblob_free: (a: number, b: number) => void;
1787
- readonly __wbg_signedloosecommit_free: (a: number, b: number) => void;
1788
- readonly sedimentreeid___wasm_refgen_toWasmSedimentreeId: (a: number) => number;
1789
- readonly sedimentreeid_toBytes: (a: number) => [number, number];
1790
- readonly fragmentwithblob_blob: (a: number) => any;
1791
- readonly __wasm_bindgen_func_elem_255: (a: number, b: number) => void;
1792
- readonly __wasm_bindgen_func_elem_1476: (a: number, b: number, c: any) => [number, number];
1793
- readonly __wasm_bindgen_func_elem_1476_183: (a: number, b: number, c: any, d: any) => void;
1794
- readonly __wasm_bindgen_func_elem_1476_184: (a: number, b: number, c: any, d: any) => void;
1795
- readonly __wasm_bindgen_func_elem_552: (a: number, b: number, c: any) => void;
1796
- readonly __wasm_bindgen_func_elem_552_1: (a: number, b: number, c: any) => void;
1797
- readonly __wasm_bindgen_func_elem_552_2: (a: number, b: number, c: any) => void;
1798
- readonly __wasm_bindgen_func_elem_552_3: (a: number, b: number, c: any) => void;
1799
- readonly __wbindgen_export: (a: number, b: number) => number;
1800
- readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
1801
- readonly __wbindgen_export3: (a: number) => void;
1802
- readonly __wbindgen_export4: () => number;
1803
- readonly __wbindgen_externrefs: WebAssembly.Table;
1804
- readonly __wbindgen_export5: (a: number, b: number, c: number) => void;
1805
- readonly __wbindgen_export6: (a: number, b: number) => void;
1806
- readonly __wbindgen_export7: (a: number) => void;
1807
- readonly __wbindgen_start: () => void;
1808
- }
1809
-
1810
- export type SyncInitInput = BufferSource | WebAssembly.Module;
1811
-
1812
- /**
1813
- * Instantiates the given `module`, which can either be bytes or
1814
- * a precompiled `WebAssembly.Module`.
1815
- *
1816
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1817
- *
1818
- * @returns {InitOutput}
1819
- */
1820
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
1821
-
1822
- /**
1823
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1824
- * for everything else, calls `WebAssembly.instantiate` directly.
1825
- *
1826
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1827
- *
1828
- * @returns {Promise<InitOutput>}
1829
- */
1830
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;