@freqhole/midden 0.1.30 → 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/README.md +4 -0
- package/midden.d.ts +24 -5
- package/midden_bg.js +93 -44
- package/midden_bg.wasm +0 -0
- package/package.json +5 -4
package/README.md
CHANGED
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
|
|
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}
|
|
@@ -1167,7 +1207,7 @@ export function __wbg_new_typed_aaaeaf29cf802876(arg0, arg1) {
|
|
|
1167
1207
|
const a = state0.a;
|
|
1168
1208
|
state0.a = 0;
|
|
1169
1209
|
try {
|
|
1170
|
-
return
|
|
1210
|
+
return wasm_bindgen__convert__closures_____invoke__h357561f53ac5f508(a, state0.b, arg0, arg1);
|
|
1171
1211
|
} finally {
|
|
1172
1212
|
state0.a = a;
|
|
1173
1213
|
}
|
|
@@ -1427,61 +1467,66 @@ 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:
|
|
1431
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
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`.
|
|
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:
|
|
1436
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1475
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3198, function: Function { arguments: [], shim_idx: 3199, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
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:
|
|
1441
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
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`.
|
|
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:
|
|
1446
|
-
const ret =
|
|
1485
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3267, function: Function { arguments: [], shim_idx: 3268, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
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:
|
|
1451
|
-
const ret =
|
|
1490
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3320, function: Function { arguments: [], shim_idx: 3321, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
|
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:
|
|
1456
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
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`.
|
|
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:
|
|
1461
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1500
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 5074, function: Function { arguments: [], shim_idx: 5075, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
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
|
-
export function __wbindgen_cast_0000000000000008(arg0) {
|
|
1504
|
+
export function __wbindgen_cast_0000000000000008(arg0, arg1) {
|
|
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`.
|
|
1506
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb75a498ac0db6fe5, wasm_bindgen__convert__closures_____invoke__h190e8892b208884b);
|
|
1507
|
+
return ret;
|
|
1508
|
+
}
|
|
1509
|
+
export function __wbindgen_cast_0000000000000009(arg0) {
|
|
1465
1510
|
// Cast intrinsic for `F64 -> Externref`.
|
|
1466
1511
|
const ret = arg0;
|
|
1467
1512
|
return ret;
|
|
1468
1513
|
}
|
|
1469
|
-
export function
|
|
1514
|
+
export function __wbindgen_cast_000000000000000a(arg0) {
|
|
1470
1515
|
// Cast intrinsic for `I64 -> Externref`.
|
|
1471
1516
|
const ret = arg0;
|
|
1472
1517
|
return ret;
|
|
1473
1518
|
}
|
|
1474
|
-
export function
|
|
1519
|
+
export function __wbindgen_cast_000000000000000b(arg0, arg1) {
|
|
1475
1520
|
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1476
1521
|
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1477
1522
|
return ret;
|
|
1478
1523
|
}
|
|
1479
|
-
export function
|
|
1524
|
+
export function __wbindgen_cast_000000000000000c(arg0, arg1) {
|
|
1480
1525
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1481
1526
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
1482
1527
|
return ret;
|
|
1483
1528
|
}
|
|
1484
|
-
export function
|
|
1529
|
+
export function __wbindgen_cast_000000000000000d(arg0) {
|
|
1485
1530
|
// Cast intrinsic for `U64 -> Externref`.
|
|
1486
1531
|
const ret = BigInt.asUintN(64, arg0);
|
|
1487
1532
|
return ret;
|
|
@@ -1495,39 +1540,43 @@ export function __wbindgen_init_externref_table() {
|
|
|
1495
1540
|
table.set(offset + 2, true);
|
|
1496
1541
|
table.set(offset + 3, false);
|
|
1497
1542
|
}
|
|
1498
|
-
function
|
|
1499
|
-
wasm.
|
|
1543
|
+
function wasm_bindgen__convert__closures_____invoke__hc6f3654ebee0b80e(arg0, arg1) {
|
|
1544
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hc6f3654ebee0b80e(arg0, arg1);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
function wasm_bindgen__convert__closures_____invoke__hfa08fd7116a7315b(arg0, arg1) {
|
|
1548
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hfa08fd7116a7315b(arg0, arg1);
|
|
1500
1549
|
}
|
|
1501
1550
|
|
|
1502
|
-
function
|
|
1503
|
-
wasm.
|
|
1551
|
+
function wasm_bindgen__convert__closures_____invoke__he25ef9f974db7a85(arg0, arg1) {
|
|
1552
|
+
wasm.wasm_bindgen__convert__closures_____invoke__he25ef9f974db7a85(arg0, arg1);
|
|
1504
1553
|
}
|
|
1505
1554
|
|
|
1506
|
-
function
|
|
1507
|
-
wasm.
|
|
1555
|
+
function wasm_bindgen__convert__closures_____invoke__he2934cb51e5b7bf4(arg0, arg1) {
|
|
1556
|
+
wasm.wasm_bindgen__convert__closures_____invoke__he2934cb51e5b7bf4(arg0, arg1);
|
|
1508
1557
|
}
|
|
1509
1558
|
|
|
1510
|
-
function
|
|
1511
|
-
wasm.
|
|
1559
|
+
function wasm_bindgen__convert__closures_____invoke__hbe731298a115c9e4(arg0, arg1, arg2) {
|
|
1560
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hbe731298a115c9e4(arg0, arg1, arg2);
|
|
1512
1561
|
}
|
|
1513
1562
|
|
|
1514
|
-
function
|
|
1515
|
-
wasm.
|
|
1563
|
+
function wasm_bindgen__convert__closures_____invoke__hd1f261354767d15e(arg0, arg1, arg2) {
|
|
1564
|
+
wasm.wasm_bindgen__convert__closures_____invoke__hd1f261354767d15e(arg0, arg1, arg2);
|
|
1516
1565
|
}
|
|
1517
1566
|
|
|
1518
|
-
function
|
|
1519
|
-
wasm.
|
|
1567
|
+
function wasm_bindgen__convert__closures_____invoke__heb521225421210b0(arg0, arg1, arg2) {
|
|
1568
|
+
wasm.wasm_bindgen__convert__closures_____invoke__heb521225421210b0(arg0, arg1, arg2);
|
|
1520
1569
|
}
|
|
1521
1570
|
|
|
1522
|
-
function
|
|
1523
|
-
const ret = wasm.
|
|
1571
|
+
function wasm_bindgen__convert__closures_____invoke__h190e8892b208884b(arg0, arg1, arg2) {
|
|
1572
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h190e8892b208884b(arg0, arg1, arg2);
|
|
1524
1573
|
if (ret[1]) {
|
|
1525
1574
|
throw takeFromExternrefTable0(ret[0]);
|
|
1526
1575
|
}
|
|
1527
1576
|
}
|
|
1528
1577
|
|
|
1529
|
-
function
|
|
1530
|
-
wasm.
|
|
1578
|
+
function wasm_bindgen__convert__closures_____invoke__h357561f53ac5f508(arg0, arg1, arg2, arg3) {
|
|
1579
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h357561f53ac5f508(arg0, arg1, arg2, arg3);
|
|
1531
1580
|
}
|
|
1532
1581
|
|
|
1533
1582
|
|
package/midden_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
"name": "@freqhole/midden",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WASM bindings for freqhole P2P client (iroh-based)",
|
|
5
|
-
"version": "0.1.
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"version": "0.1.32",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/freqhole/tomb"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"midden_bg.wasm",
|
|
@@ -18,4 +19,4 @@
|
|
|
18
19
|
"./midden.js",
|
|
19
20
|
"./snippets/*"
|
|
20
21
|
]
|
|
21
|
-
}
|
|
22
|
+
}
|