@freqhole/midden 0.1.31 → 0.1.32

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.
package/midden.d.ts CHANGED
@@ -173,21 +173,30 @@ export class MiddenNode {
173
173
  compute_blake3(peer_addr: string, blob_id: string): Promise<string | undefined>;
174
174
  /**
175
175
  * create a new node with random identity
176
- * waits for relay connection before returning
176
+ * waits for relay connection before returning.
177
+ *
178
+ * `connect_timeout_ms` is an optional per-dial timeout for `open_bi`
179
+ * (defaults to 10s when omitted/undefined).
177
180
  */
178
- static create(): Promise<MiddenNode>;
181
+ static create(connect_timeout_ms?: number | null): Promise<MiddenNode>;
179
182
  /**
180
183
  * create a node from existing secret key bytes (for persistence)
181
- * key_bytes must be exactly 32 bytes
184
+ * key_bytes must be exactly 32 bytes.
185
+ *
186
+ * `connect_timeout_ms` is an optional per-dial timeout for `open_bi`
187
+ * (defaults to 10s when omitted/undefined).
182
188
  */
183
- static create_from_key(key_bytes: Uint8Array): Promise<MiddenNode>;
189
+ static create_from_key(key_bytes: Uint8Array, connect_timeout_ms?: number | null): Promise<MiddenNode>;
184
190
  /**
185
191
  * create a node from existing secret key with additional ALPN protocols.
186
192
  *
187
193
  * `extra_alpns` is a JS array of strings (e.g. ["iroh/automerge-repo/1"]).
188
194
  * the node always registers "freqhole/1" plus whatever extra ALPNs are given.
195
+ *
196
+ * `connect_timeout_ms` is an optional per-dial timeout for `open_bi`
197
+ * (defaults to 10s when omitted/undefined).
189
198
  */
190
- static create_with_alpns(key_bytes: Uint8Array, extra_alpns: Array<any>): Promise<MiddenNode>;
199
+ static create_with_alpns(key_bytes: Uint8Array, extra_alpns: Array<any>, connect_timeout_ms?: number | null): Promise<MiddenNode>;
191
200
  /**
192
201
  * download a blob using iroh-blobs verified streaming
193
202
  *
@@ -290,6 +299,16 @@ export class MiddenNode {
290
299
  * returns a JS object: `{ hash: string, bao: Uint8Array }`
291
300
  */
292
301
  import_blob_and_export_bao(data: Uint8Array): Promise<any>;
302
+ /**
303
+ * get our full endpoint address as JSON (node_id + relay url + any direct addrs).
304
+ *
305
+ * after `online()` has resolved this includes the home relay url, which is
306
+ * enough for a remote peer to dial us directly via the relay without doing
307
+ * a pkarr/DNS discovery lookup first. pass the returned string straight to
308
+ * `open_bi`/`connect` on the other side - `parse_peer_addr` accepts this
309
+ * same JSON shape. avoids the discovery propagation race on fresh boots.
310
+ */
311
+ node_addr(): string;
293
312
  /**
294
313
  * get our node_id (iroh public key)
295
314
  */
package/midden_bg.js CHANGED
@@ -385,23 +385,31 @@ export class MiddenNode {
385
385
  }
386
386
  /**
387
387
  * create a new node with random identity
388
- * waits for relay connection before returning
388
+ * waits for relay connection before returning.
389
+ *
390
+ * `connect_timeout_ms` is an optional per-dial timeout for `open_bi`
391
+ * (defaults to 10s when omitted/undefined).
392
+ * @param {number | null} [connect_timeout_ms]
389
393
  * @returns {Promise<MiddenNode>}
390
394
  */
391
- static create() {
392
- const ret = wasm.middennode_create();
395
+ static create(connect_timeout_ms) {
396
+ const ret = wasm.middennode_create(isLikeNone(connect_timeout_ms) ? 0x100000001 : (connect_timeout_ms) >>> 0);
393
397
  return ret;
394
398
  }
395
399
  /**
396
400
  * create a node from existing secret key bytes (for persistence)
397
- * key_bytes must be exactly 32 bytes
401
+ * key_bytes must be exactly 32 bytes.
402
+ *
403
+ * `connect_timeout_ms` is an optional per-dial timeout for `open_bi`
404
+ * (defaults to 10s when omitted/undefined).
398
405
  * @param {Uint8Array} key_bytes
406
+ * @param {number | null} [connect_timeout_ms]
399
407
  * @returns {Promise<MiddenNode>}
400
408
  */
401
- static create_from_key(key_bytes) {
409
+ static create_from_key(key_bytes, connect_timeout_ms) {
402
410
  const ptr0 = passArray8ToWasm0(key_bytes, wasm.__wbindgen_malloc);
403
411
  const len0 = WASM_VECTOR_LEN;
404
- const ret = wasm.middennode_create_from_key(ptr0, len0);
412
+ const ret = wasm.middennode_create_from_key(ptr0, len0, isLikeNone(connect_timeout_ms) ? 0x100000001 : (connect_timeout_ms) >>> 0);
405
413
  return ret;
406
414
  }
407
415
  /**
@@ -409,14 +417,18 @@ export class MiddenNode {
409
417
  *
410
418
  * `extra_alpns` is a JS array of strings (e.g. ["iroh/automerge-repo/1"]).
411
419
  * the node always registers "freqhole/1" plus whatever extra ALPNs are given.
420
+ *
421
+ * `connect_timeout_ms` is an optional per-dial timeout for `open_bi`
422
+ * (defaults to 10s when omitted/undefined).
412
423
  * @param {Uint8Array} key_bytes
413
424
  * @param {Array<any>} extra_alpns
425
+ * @param {number | null} [connect_timeout_ms]
414
426
  * @returns {Promise<MiddenNode>}
415
427
  */
416
- static create_with_alpns(key_bytes, extra_alpns) {
428
+ static create_with_alpns(key_bytes, extra_alpns, connect_timeout_ms) {
417
429
  const ptr0 = passArray8ToWasm0(key_bytes, wasm.__wbindgen_malloc);
418
430
  const len0 = WASM_VECTOR_LEN;
419
- const ret = wasm.middennode_create_with_alpns(ptr0, len0, extra_alpns);
431
+ const ret = wasm.middennode_create_with_alpns(ptr0, len0, extra_alpns, isLikeNone(connect_timeout_ms) ? 0x100000001 : (connect_timeout_ms) >>> 0);
420
432
  return ret;
421
433
  }
422
434
  /**
@@ -625,6 +637,34 @@ export class MiddenNode {
625
637
  const ret = wasm.middennode_import_blob_and_export_bao(this.__wbg_ptr, ptr0, len0);
626
638
  return ret;
627
639
  }
640
+ /**
641
+ * get our full endpoint address as JSON (node_id + relay url + any direct addrs).
642
+ *
643
+ * after `online()` has resolved this includes the home relay url, which is
644
+ * enough for a remote peer to dial us directly via the relay without doing
645
+ * a pkarr/DNS discovery lookup first. pass the returned string straight to
646
+ * `open_bi`/`connect` on the other side - `parse_peer_addr` accepts this
647
+ * same JSON shape. avoids the discovery propagation race on fresh boots.
648
+ * @returns {string}
649
+ */
650
+ node_addr() {
651
+ let deferred2_0;
652
+ let deferred2_1;
653
+ try {
654
+ const ret = wasm.middennode_node_addr(this.__wbg_ptr);
655
+ var ptr1 = ret[0];
656
+ var len1 = ret[1];
657
+ if (ret[3]) {
658
+ ptr1 = 0; len1 = 0;
659
+ throw takeFromExternrefTable0(ret[2]);
660
+ }
661
+ deferred2_0 = ptr1;
662
+ deferred2_1 = len1;
663
+ return getStringFromWasm0(ptr1, len1);
664
+ } finally {
665
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
666
+ }
667
+ }
628
668
  /**
629
669
  * get our node_id (iroh public key)
630
670
  * @returns {string}
@@ -1427,42 +1467,42 @@ export function __wbg_wasClean_69f68dc4ed2d2cc7(arg0) {
1427
1467
  return ret;
1428
1468
  }
1429
1469
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
1430
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3029, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 3030, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1470
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3042, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 3043, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1431
1471
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb183e556614092ca, wasm_bindgen__convert__closures_____invoke__hbe731298a115c9e4);
1432
1472
  return ret;
1433
1473
  }
1434
1474
  export function __wbindgen_cast_0000000000000002(arg0, arg1) {
1435
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3185, function: Function { arguments: [], shim_idx: 3186, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1475
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3198, function: Function { arguments: [], shim_idx: 3199, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1436
1476
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h85ae81daf1218992, wasm_bindgen__convert__closures_____invoke__hc6f3654ebee0b80e);
1437
1477
  return ret;
1438
1478
  }
1439
1479
  export function __wbindgen_cast_0000000000000003(arg0, arg1) {
1440
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3209, function: Function { arguments: [Externref], shim_idx: 3210, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1480
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3222, function: Function { arguments: [Externref], shim_idx: 3223, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1441
1481
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h9c0e6de874b60dbc, wasm_bindgen__convert__closures_____invoke__hd1f261354767d15e);
1442
1482
  return ret;
1443
1483
  }
1444
1484
  export function __wbindgen_cast_0000000000000004(arg0, arg1) {
1445
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3254, function: Function { arguments: [], shim_idx: 3255, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1485
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3267, function: Function { arguments: [], shim_idx: 3268, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1446
1486
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h23a1c12cd048d3cb, wasm_bindgen__convert__closures_____invoke__hfa08fd7116a7315b);
1447
1487
  return ret;
1448
1488
  }
1449
1489
  export function __wbindgen_cast_0000000000000005(arg0, arg1) {
1450
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3307, function: Function { arguments: [], shim_idx: 3308, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1490
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3320, function: Function { arguments: [], shim_idx: 3321, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1451
1491
  const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hea58ba9208361aba, wasm_bindgen__convert__closures_____invoke__he25ef9f974db7a85);
1452
1492
  return ret;
1453
1493
  }
1454
1494
  export function __wbindgen_cast_0000000000000006(arg0, arg1) {
1455
- // Cast intrinsic for `Closure(Closure { dtor_idx: 3728, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 3729, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1495
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 3741, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 3742, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1456
1496
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he82de21879ef6972, wasm_bindgen__convert__closures_____invoke__heb521225421210b0);
1457
1497
  return ret;
1458
1498
  }
1459
1499
  export function __wbindgen_cast_0000000000000007(arg0, arg1) {
1460
- // Cast intrinsic for `Closure(Closure { dtor_idx: 5061, function: Function { arguments: [], shim_idx: 5062, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1500
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 5074, function: Function { arguments: [], shim_idx: 5075, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1461
1501
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hc498dc21c6574762, wasm_bindgen__convert__closures_____invoke__he2934cb51e5b7bf4);
1462
1502
  return ret;
1463
1503
  }
1464
1504
  export function __wbindgen_cast_0000000000000008(arg0, arg1) {
1465
- // Cast intrinsic for `Closure(Closure { dtor_idx: 5070, function: Function { arguments: [Externref], shim_idx: 5071, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1505
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 5083, function: Function { arguments: [Externref], shim_idx: 5084, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1466
1506
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb75a498ac0db6fe5, wasm_bindgen__convert__closures_____invoke__h190e8892b208884b);
1467
1507
  return ret;
1468
1508
  }
package/midden_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@freqhole/midden",
3
3
  "type": "module",
4
4
  "description": "WASM bindings for freqhole P2P client (iroh-based)",
5
- "version": "0.1.31",
5
+ "version": "0.1.32",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/freqhole/tomb"