@siafoundation/sia-storage 0.1.5 → 0.2.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.
@@ -116,18 +116,16 @@ export class Builder {
116
116
  }
117
117
  /**
118
118
  * Connects using a pre-authorized key, bypassing the interactive approval
119
- * flow, and returns a Sdk. `preAuthorizedKeySeed` is the 32-byte
120
- * pre-authorized private key (Uint8Array); `mnemonic` derives the app key.
121
- * @param {Uint8Array} pre_authorized_key_seed
119
+ * flow, and returns a Sdk. `mnemonic` derives the app key.
120
+ * @param {PreAuthorizedKey} pre_authorized_key
122
121
  * @param {string} mnemonic
123
122
  * @returns {Promise<Sdk>}
124
123
  */
125
- connectPreAuthorized(pre_authorized_key_seed, mnemonic) {
126
- const ptr0 = passArray8ToWasm0(pre_authorized_key_seed, wasm.__wbindgen_malloc);
124
+ connectPreAuthorized(pre_authorized_key, mnemonic) {
125
+ _assertClass(pre_authorized_key, PreAuthorizedKey);
126
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
127
127
  const len0 = WASM_VECTOR_LEN;
128
- const ptr1 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
129
- const len1 = WASM_VECTOR_LEN;
130
- const ret = wasm.builder_connectPreAuthorized(this.__wbg_ptr, ptr0, len0, ptr1, len1);
128
+ const ret = wasm.builder_connectPreAuthorized(this.__wbg_ptr, pre_authorized_key.__wbg_ptr, ptr0, len0);
131
129
  return ret;
132
130
  }
133
131
  /**
@@ -479,9 +477,71 @@ export class ObjectEvent {
479
477
  if (Symbol.dispose) ObjectEvent.prototype[Symbol.dispose] = ObjectEvent.prototype.free;
480
478
 
481
479
  /**
482
- * An object listed without its slabs, as `SharedSdk.objectSummaries` returns
483
- * it. It describes the object but cannot be downloaded. Fetch the full
484
- * object with `SharedSdk.object(id)` to download it.
480
+ * An object event from the indexer, without the object's slabs.
481
+ */
482
+ export class ObjectEventSummary {
483
+ static __wrap(ptr) {
484
+ const obj = Object.create(ObjectEventSummary.prototype);
485
+ obj.__wbg_ptr = ptr;
486
+ ObjectEventSummaryFinalization.register(obj, obj.__wbg_ptr, obj);
487
+ return obj;
488
+ }
489
+ __destroy_into_raw() {
490
+ const ptr = this.__wbg_ptr;
491
+ this.__wbg_ptr = 0;
492
+ ObjectEventSummaryFinalization.unregister(this);
493
+ return ptr;
494
+ }
495
+ free() {
496
+ const ptr = this.__destroy_into_raw();
497
+ wasm.__wbg_objecteventsummary_free(ptr, 0);
498
+ }
499
+ /**
500
+ * @returns {boolean}
501
+ */
502
+ get deleted() {
503
+ const ret = wasm.objecteventsummary_deleted(this.__wbg_ptr);
504
+ return ret !== 0;
505
+ }
506
+ /**
507
+ * @returns {string}
508
+ */
509
+ get id() {
510
+ let deferred1_0;
511
+ let deferred1_1;
512
+ try {
513
+ const ret = wasm.objecteventsummary_id(this.__wbg_ptr);
514
+ deferred1_0 = ret[0];
515
+ deferred1_1 = ret[1];
516
+ return getStringFromWasm0(ret[0], ret[1]);
517
+ } finally {
518
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
519
+ }
520
+ }
521
+ /**
522
+ * Returns the object associated with this event, if it exists.
523
+ * @returns {ObjectSummary | undefined}
524
+ */
525
+ get object() {
526
+ const ret = wasm.objecteventsummary_object(this.__wbg_ptr);
527
+ return ret === 0 ? undefined : ObjectSummary.__wrap(ret);
528
+ }
529
+ /**
530
+ * Returns the time the event occurred.
531
+ * @returns {Date}
532
+ */
533
+ get updatedAt() {
534
+ const ret = wasm.objecteventsummary_updatedAt(this.__wbg_ptr);
535
+ return ret;
536
+ }
537
+ }
538
+ if (Symbol.dispose) ObjectEventSummary.prototype[Symbol.dispose] = ObjectEventSummary.prototype.free;
539
+
540
+ /**
541
+ * An object listed without its slabs, as `Sdk.objectEventSummaries` and
542
+ * `SharedSdk.objectSummaries` return it. It describes the object but cannot
543
+ * be downloaded. Fetch the full object with `Sdk.object(id)` or
544
+ * `SharedSdk.object(id)` to download it.
485
545
  */
486
546
  export class ObjectSummary {
487
547
  static __wrap(ptr) {
@@ -809,6 +869,120 @@ export class PinnedObject {
809
869
  }
810
870
  if (Symbol.dispose) PinnedObject.prototype[Symbol.dispose] = PinnedObject.prototype.free;
811
871
 
872
+ /**
873
+ * A key used to authorize application connections with indexd.
874
+ */
875
+ export class PreAuthorizedKey {
876
+ static __wrap(ptr) {
877
+ const obj = Object.create(PreAuthorizedKey.prototype);
878
+ obj.__wbg_ptr = ptr;
879
+ PreAuthorizedKeyFinalization.register(obj, obj.__wbg_ptr, obj);
880
+ return obj;
881
+ }
882
+ __destroy_into_raw() {
883
+ const ptr = this.__wbg_ptr;
884
+ this.__wbg_ptr = 0;
885
+ PreAuthorizedKeyFinalization.unregister(this);
886
+ return ptr;
887
+ }
888
+ free() {
889
+ const ptr = this.__destroy_into_raw();
890
+ wasm.__wbg_preauthorizedkey_free(ptr, 0);
891
+ }
892
+ /**
893
+ * Exports the key as a 32-byte seed.
894
+ * @returns {Uint8Array}
895
+ */
896
+ export() {
897
+ const ret = wasm.preauthorizedkey_export(this.__wbg_ptr);
898
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
899
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
900
+ return v1;
901
+ }
902
+ /**
903
+ * Imports a pre-authorized key from a 32-byte seed.
904
+ * @param {Uint8Array} seed
905
+ * @returns {PreAuthorizedKey}
906
+ */
907
+ static import(seed) {
908
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
909
+ const len0 = WASM_VECTOR_LEN;
910
+ const ret = wasm.preauthorizedkey_import(ptr0, len0);
911
+ if (ret[2]) {
912
+ throw takeFromExternrefTable0(ret[1]);
913
+ }
914
+ return PreAuthorizedKey.__wrap(ret[0]);
915
+ }
916
+ /**
917
+ * Generates a new pre-authorized key.
918
+ */
919
+ constructor() {
920
+ const ret = wasm.preauthorizedkey_new();
921
+ this.__wbg_ptr = ret;
922
+ PreAuthorizedKeyFinalization.register(this, this.__wbg_ptr, this);
923
+ return this;
924
+ }
925
+ /**
926
+ * Returns the Ed25519 public key as a string.
927
+ * @returns {string}
928
+ */
929
+ publicKey() {
930
+ let deferred1_0;
931
+ let deferred1_1;
932
+ try {
933
+ const ret = wasm.preauthorizedkey_publicKey(this.__wbg_ptr);
934
+ deferred1_0 = ret[0];
935
+ deferred1_1 = ret[1];
936
+ return getStringFromWasm0(ret[0], ret[1]);
937
+ } finally {
938
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
939
+ }
940
+ }
941
+ /**
942
+ * Signs a message and returns its 64-byte signature.
943
+ * @param {Uint8Array} message
944
+ * @returns {Uint8Array}
945
+ */
946
+ sign(message) {
947
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
948
+ const len0 = WASM_VECTOR_LEN;
949
+ const ret = wasm.preauthorizedkey_sign(this.__wbg_ptr, ptr0, len0);
950
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
951
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
952
+ return v2;
953
+ }
954
+ /**
955
+ * Returns a signed request for creating a pre-authorized key in indexd.
956
+ * @param {PreAuthorizedKeyRequest} request
957
+ * @returns {SignedPreAuthorizedKeyRequest}
958
+ */
959
+ signRequest(request) {
960
+ const ret = wasm.preauthorizedkey_signRequest(this.__wbg_ptr, request);
961
+ if (ret[2]) {
962
+ throw takeFromExternrefTable0(ret[1]);
963
+ }
964
+ return takeFromExternrefTable0(ret[0]);
965
+ }
966
+ /**
967
+ * Verifies a message signature using this key.
968
+ * @param {Uint8Array} message
969
+ * @param {Uint8Array} signature
970
+ * @returns {boolean}
971
+ */
972
+ verifySignature(message, signature) {
973
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
974
+ const len0 = WASM_VECTOR_LEN;
975
+ const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
976
+ const len1 = WASM_VECTOR_LEN;
977
+ const ret = wasm.preauthorizedkey_verifySignature(this.__wbg_ptr, ptr0, len0, ptr1, len1);
978
+ if (ret[2]) {
979
+ throw takeFromExternrefTable0(ret[1]);
980
+ }
981
+ return ret[0] !== 0;
982
+ }
983
+ }
984
+ if (Symbol.dispose) PreAuthorizedKey.prototype[Symbol.dispose] = PreAuthorizedKey.prototype.free;
985
+
812
986
  /**
813
987
  * The main Sia storage SDK. Provides methods for uploading, downloading,
814
988
  * and managing objects on the Sia storage network via an indexer.
@@ -915,6 +1089,16 @@ export class Sdk {
915
1089
  const ret = wasm.sdk_object(this.__wbg_ptr, ptr0, len0);
916
1090
  return ret;
917
1091
  }
1092
+ /**
1093
+ * Returns object events from the indexer without the objects' slabs.
1094
+ * @param {ObjectsCursor | null | undefined} cursor
1095
+ * @param {number} limit
1096
+ * @returns {Promise<ObjectEventSummary[]>}
1097
+ */
1098
+ objectEventSummaries(cursor, limit) {
1099
+ const ret = wasm.sdk_objectEventSummaries(this.__wbg_ptr, cursor, limit);
1100
+ return ret;
1101
+ }
918
1102
  /**
919
1103
  * Returns object events for syncing local state with the indexer.
920
1104
  * @param {ObjectsCursor | null | undefined} cursor
@@ -1445,6 +1629,10 @@ function __wbg_get_imports() {
1445
1629
  __wbg__wbg_cb_unref_fffb441def202758: function(arg0) {
1446
1630
  arg0._wbg_cb_unref();
1447
1631
  },
1632
+ __wbg_abort_807c9d22f53767f5: function(arg0) {
1633
+ const ret = arg0.abort();
1634
+ return ret;
1635
+ },
1448
1636
  __wbg_abort_8bae0f33e7833997: function(arg0) {
1449
1637
  arg0.abort();
1450
1638
  },
@@ -1494,6 +1682,10 @@ function __wbg_get_imports() {
1494
1682
  const ret = arg0.cancel();
1495
1683
  return ret;
1496
1684
  },
1685
+ __wbg_cancel_3ba68e9bb6d68b37: function(arg0) {
1686
+ const ret = arg0.cancel();
1687
+ return ret;
1688
+ },
1497
1689
  __wbg_cancel_70eb325a477a4d18: function(arg0) {
1498
1690
  const ret = arg0.cancel();
1499
1691
  return ret;
@@ -1502,7 +1694,7 @@ function __wbg_get_imports() {
1502
1694
  const ret = arg0.catch(arg1);
1503
1695
  return ret;
1504
1696
  },
1505
- __wbg_clearTimeout_6b8d9a38b9263d65: function(arg0) {
1697
+ __wbg_clearTimeout_1daad5c6ee4fcd3b: function(arg0) {
1506
1698
  const ret = clearTimeout(arg0);
1507
1699
  return ret;
1508
1700
  },
@@ -1527,17 +1719,25 @@ function __wbg_get_imports() {
1527
1719
  const ret = arg0.createBidirectionalStream();
1528
1720
  return ret;
1529
1721
  },
1530
- __wbg_done_11408d3db12f8f67: function(arg0) {
1722
+ __wbg_done_89b2b13e91a60321: function(arg0) {
1531
1723
  const ret = arg0.done;
1532
1724
  return ret;
1533
1725
  },
1534
- __wbg_done_89b2b13e91a60321: function(arg0) {
1726
+ __wbg_done_ccbb9708a558f0a5: function(arg0) {
1535
1727
  const ret = arg0.done;
1536
1728
  return ret;
1537
1729
  },
1538
1730
  __wbg_enqueue_6d83b4c6281bafd6: function() { return handleError(function (arg0, arg1) {
1539
1731
  arg0.enqueue(arg1);
1540
1732
  }, arguments); },
1733
+ __wbg_entries_015dc610cd81ede0: function(arg0) {
1734
+ const ret = Object.entries(arg0);
1735
+ return ret;
1736
+ },
1737
+ __wbg_entries_900cefd6f70eb290: function(arg0) {
1738
+ const ret = arg0.entries();
1739
+ return ret;
1740
+ },
1541
1741
  __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
1542
1742
  let deferred0_0;
1543
1743
  let deferred0_1;
@@ -1549,7 +1749,7 @@ function __wbg_get_imports() {
1549
1749
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1550
1750
  }
1551
1751
  },
1552
- __wbg_fetch_9dad4fe911207b37: function(arg0) {
1752
+ __wbg_fetch_7a37768ab67c5bd8: function(arg0) {
1553
1753
  const ret = fetch(arg0);
1554
1754
  return ret;
1555
1755
  },
@@ -1580,6 +1780,10 @@ function __wbg_get_imports() {
1580
1780
  const ret = arg0.getWriter();
1581
1781
  return ret;
1582
1782
  }, arguments); },
1783
+ __wbg_get_507a50627bffa49b: function(arg0, arg1) {
1784
+ const ret = arg0[arg1 >>> 0];
1785
+ return ret;
1786
+ },
1583
1787
  __wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) {
1584
1788
  const ret = Reflect.get(arg0, arg1);
1585
1789
  return ret;
@@ -1642,6 +1846,16 @@ function __wbg_get_imports() {
1642
1846
  const ret = result;
1643
1847
  return ret;
1644
1848
  },
1849
+ __wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
1850
+ let result;
1851
+ try {
1852
+ result = arg0 instanceof Map;
1853
+ } catch (_) {
1854
+ result = false;
1855
+ }
1856
+ const ret = result;
1857
+ return ret;
1858
+ },
1645
1859
  __wbg_instanceof_Response_c8b64b2256f01bec: function(arg0) {
1646
1860
  let result;
1647
1861
  try {
@@ -1717,7 +1931,7 @@ function __wbg_get_imports() {
1717
1931
  const a = state0.a;
1718
1932
  state0.a = 0;
1719
1933
  try {
1720
- return wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(a, state0.b, arg0, arg1);
1934
+ return wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(a, state0.b, arg0, arg1);
1721
1935
  } finally {
1722
1936
  state0.a = a;
1723
1937
  }
@@ -1755,7 +1969,7 @@ function __wbg_get_imports() {
1755
1969
  const a = state0.a;
1756
1970
  state0.a = 0;
1757
1971
  try {
1758
- return wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(a, state0.b, arg0, arg1);
1972
+ return wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(a, state0.b, arg0, arg1);
1759
1973
  } finally {
1760
1974
  state0.a = a;
1761
1975
  }
@@ -1802,6 +2016,10 @@ function __wbg_get_imports() {
1802
2016
  const ret = ObjectEvent.__wrap(arg0);
1803
2017
  return ret;
1804
2018
  },
2019
+ __wbg_objecteventsummary_new: function(arg0) {
2020
+ const ret = ObjectEventSummary.__wrap(arg0);
2021
+ return ret;
2022
+ },
1805
2023
  __wbg_objectsummary_new: function(arg0) {
1806
2024
  const ret = ObjectSummary.__wrap(arg0);
1807
2025
  return ret;
@@ -1857,7 +2075,7 @@ function __wbg_get_imports() {
1857
2075
  const ret = Sdk.__wrap(arg0);
1858
2076
  return ret;
1859
2077
  },
1860
- __wbg_setTimeout_f757f00851f76c42: function(arg0, arg1) {
2078
+ __wbg_setTimeout_b4a9096784635514: function(arg0, arg1) {
1861
2079
  const ret = setTimeout(arg0, arg1);
1862
2080
  return ret;
1863
2081
  },
@@ -1891,6 +2109,12 @@ function __wbg_get_imports() {
1891
2109
  __wbg_set_mode_f6bfb5131426e6b5: function(arg0, arg1) {
1892
2110
  arg0.mode = __wbindgen_enum_ReadableStreamReaderMode[arg1];
1893
2111
  },
2112
+ __wbg_set_referrer_02890bb2de855af1: function(arg0, arg1, arg2) {
2113
+ arg0.referrer = getStringFromWasm0(arg1, arg2);
2114
+ },
2115
+ __wbg_set_referrer_policy_e49a6d0d7473fd16: function(arg0, arg1) {
2116
+ arg0.referrerPolicy = __wbindgen_enum_ReferrerPolicy[arg1];
2117
+ },
1894
2118
  __wbg_set_signal_c4ef8faddb4c1446: function(arg0, arg1) {
1895
2119
  arg0.signal = arg1;
1896
2120
  },
@@ -1933,10 +2157,6 @@ function __wbg_get_imports() {
1933
2157
  const ret = arg0.status;
1934
2158
  return ret;
1935
2159
  },
1936
- __wbg_stringify_b54333f60f1e4dad: function() { return handleError(function (arg0) {
1937
- const ret = JSON.stringify(arg0);
1938
- return ret;
1939
- }, arguments); },
1940
2160
  __wbg_subarray_3ed232c8a6baee09: function(arg0, arg1, arg2) {
1941
2161
  const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
1942
2162
  return ret;
@@ -1964,11 +2184,11 @@ function __wbg_get_imports() {
1964
2184
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1965
2185
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1966
2186
  },
1967
- __wbg_value_015ff34c896f8461: function(arg0) {
2187
+ __wbg_value_a5d5488a9589444a: function(arg0) {
1968
2188
  const ret = arg0.value;
1969
2189
  return ret;
1970
2190
  },
1971
- __wbg_value_a5d5488a9589444a: function(arg0) {
2191
+ __wbg_value_b3f5a8463f26cd7e: function(arg0) {
1972
2192
  const ret = arg0.value;
1973
2193
  return ret;
1974
2194
  },
@@ -1985,32 +2205,32 @@ function __wbg_get_imports() {
1985
2205
  return ret;
1986
2206
  },
1987
2207
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1988
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1022, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2208
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1041, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1989
2209
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true_);
1990
2210
  return ret;
1991
2211
  },
1992
2212
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1993
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 481, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2213
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 500, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1994
2214
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___JsValue______true_);
1995
2215
  return ret;
1996
2216
  },
1997
2217
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1998
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 539, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2218
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 558, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1999
2219
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___sys__Undefined__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true_);
2000
2220
  return ret;
2001
2221
  },
2002
2222
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
2003
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("WebTransportBidirectionalStream")], shim_idx: 539, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2223
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("WebTransportBidirectionalStream")], shim_idx: 558, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2004
2224
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___sys__Undefined__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true__3);
2005
2225
  return ret;
2006
2226
  },
2007
2227
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2008
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 539, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2228
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 558, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2009
2229
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___sys__Undefined__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true__4);
2010
2230
  return ret;
2011
2231
  },
2012
2232
  __wbindgen_cast_0000000000000006: function(arg0, arg1) {
2013
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 829, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2233
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 853, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2014
2234
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_63576b009277873___convert__closures_____invoke_______true_);
2015
2235
  return ret;
2016
2236
  },
@@ -2019,38 +2239,50 @@ function __wbg_get_imports() {
2019
2239
  const ret = arg0;
2020
2240
  return ret;
2021
2241
  },
2022
- __wbindgen_cast_0000000000000008: function(arg0, arg1) {
2242
+ __wbindgen_cast_0000000000000008: function(arg0) {
2243
+ // Cast intrinsic for `I64 -> Externref`.
2244
+ const ret = arg0;
2245
+ return ret;
2246
+ },
2247
+ __wbindgen_cast_0000000000000009: function(arg0, arg1) {
2023
2248
  // Cast intrinsic for `Ref(String) -> Externref`.
2024
2249
  const ret = getStringFromWasm0(arg0, arg1);
2025
2250
  return ret;
2026
2251
  },
2027
- __wbindgen_cast_0000000000000009: function(arg0) {
2252
+ __wbindgen_cast_000000000000000a: function(arg0) {
2028
2253
  // Cast intrinsic for `U64 -> Externref`.
2029
2254
  const ret = BigInt.asUintN(64, arg0);
2030
2255
  return ret;
2031
2256
  },
2032
- __wbindgen_cast_000000000000000a: function(arg0, arg1) {
2257
+ __wbindgen_cast_000000000000000b: function(arg0, arg1) {
2033
2258
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2034
2259
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2035
2260
  // Cast intrinsic for `Vector(NamedExternref("KeyRecord")) -> Externref`.
2036
2261
  const ret = v0;
2037
2262
  return ret;
2038
2263
  },
2039
- __wbindgen_cast_000000000000000b: function(arg0, arg1) {
2264
+ __wbindgen_cast_000000000000000c: function(arg0, arg1) {
2040
2265
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2041
2266
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2042
2267
  // Cast intrinsic for `Vector(NamedExternref("ObjectEvent")) -> Externref`.
2043
2268
  const ret = v0;
2044
2269
  return ret;
2045
2270
  },
2046
- __wbindgen_cast_000000000000000c: function(arg0, arg1) {
2271
+ __wbindgen_cast_000000000000000d: function(arg0, arg1) {
2272
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2273
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2274
+ // Cast intrinsic for `Vector(NamedExternref("ObjectEventSummary")) -> Externref`.
2275
+ const ret = v0;
2276
+ return ret;
2277
+ },
2278
+ __wbindgen_cast_000000000000000e: function(arg0, arg1) {
2047
2279
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2048
2280
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2049
2281
  // Cast intrinsic for `Vector(NamedExternref("ObjectSummary")) -> Externref`.
2050
2282
  const ret = v0;
2051
2283
  return ret;
2052
2284
  },
2053
- __wbindgen_cast_000000000000000d: function(arg0, arg1) {
2285
+ __wbindgen_cast_000000000000000f: function(arg0, arg1) {
2054
2286
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2055
2287
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2056
2288
  // Cast intrinsic for `Vector(NamedExternref("PinnedObject")) -> Externref`.
@@ -2109,8 +2341,8 @@ function wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bind
2109
2341
  }
2110
2342
  }
2111
2343
 
2112
- function wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
2113
- wasm.wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
2344
+ function wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
2345
+ wasm.wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
2114
2346
  }
2115
2347
 
2116
2348
 
@@ -2120,6 +2352,9 @@ const __wbindgen_enum_ReadableStreamReaderMode = ["byob"];
2120
2352
  const __wbindgen_enum_ReadableStreamType = ["bytes"];
2121
2353
 
2122
2354
 
2355
+ const __wbindgen_enum_ReferrerPolicy = ["", "no-referrer", "no-referrer-when-downgrade", "origin", "origin-when-cross-origin", "unsafe-url", "same-origin", "strict-origin", "strict-origin-when-cross-origin"];
2356
+
2357
+
2123
2358
  const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
2124
2359
 
2125
2360
 
@@ -2148,6 +2383,9 @@ const KeyRecordFinalization = (typeof FinalizationRegistry === 'undefined')
2148
2383
  const ObjectEventFinalization = (typeof FinalizationRegistry === 'undefined')
2149
2384
  ? { register: () => {}, unregister: () => {} }
2150
2385
  : new FinalizationRegistry(ptr => wasm.__wbg_objectevent_free(ptr, 1));
2386
+ const ObjectEventSummaryFinalization = (typeof FinalizationRegistry === 'undefined')
2387
+ ? { register: () => {}, unregister: () => {} }
2388
+ : new FinalizationRegistry(ptr => wasm.__wbg_objecteventsummary_free(ptr, 1));
2151
2389
  const ObjectSummaryFinalization = (typeof FinalizationRegistry === 'undefined')
2152
2390
  ? { register: () => {}, unregister: () => {} }
2153
2391
  : new FinalizationRegistry(ptr => wasm.__wbg_objectsummary_free(ptr, 1));
@@ -2157,6 +2395,9 @@ const PackedUploadFinalization = (typeof FinalizationRegistry === 'undefined')
2157
2395
  const PinnedObjectFinalization = (typeof FinalizationRegistry === 'undefined')
2158
2396
  ? { register: () => {}, unregister: () => {} }
2159
2397
  : new FinalizationRegistry(ptr => wasm.__wbg_pinnedobject_free(ptr, 1));
2398
+ const PreAuthorizedKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2399
+ ? { register: () => {}, unregister: () => {} }
2400
+ : new FinalizationRegistry(ptr => wasm.__wbg_preauthorizedkey_free(ptr, 1));
2160
2401
  const SdkFinalization = (typeof FinalizationRegistry === 'undefined')
2161
2402
  ? { register: () => {}, unregister: () => {} }
2162
2403
  : new FinalizationRegistry(ptr => wasm.__wbg_sdk_free(ptr, 1));
Binary file
@@ -5,6 +5,7 @@ export const __wbg_appkey_free: (a: number, b: number) => void;
5
5
  export const __wbg_builder_free: (a: number, b: number) => void;
6
6
  export const __wbg_keyrecord_free: (a: number, b: number) => void;
7
7
  export const __wbg_objectevent_free: (a: number, b: number) => void;
8
+ export const __wbg_objecteventsummary_free: (a: number, b: number) => void;
8
9
  export const __wbg_objectsummary_free: (a: number, b: number) => void;
9
10
  export const __wbg_packedupload_free: (a: number, b: number) => void;
10
11
  export const __wbg_pinnedobject_free: (a: number, b: number) => void;
@@ -15,7 +16,7 @@ export const appkey_new: (a: number, b: number) => [number, number, number];
15
16
  export const appkey_publicKey: (a: number) => [number, number];
16
17
  export const appkey_sign: (a: number, b: number, c: number) => [number, number];
17
18
  export const appkey_verifySignature: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
18
- export const builder_connectPreAuthorized: (a: number, b: number, c: number, d: number, e: number) => any;
19
+ export const builder_connectPreAuthorized: (a: number, b: number, c: number, d: number) => any;
19
20
  export const builder_connected: (a: number, b: number) => any;
20
21
  export const builder_matchesExistingAppKey: (a: number, b: number, c: number) => any;
21
22
  export const builder_new: (a: number, b: number, c: any) => [number, number, number];
@@ -34,6 +35,10 @@ export const objectevent_deleted: (a: number) => number;
34
35
  export const objectevent_id: (a: number) => [number, number];
35
36
  export const objectevent_object: (a: number) => number;
36
37
  export const objectevent_updatedAt: (a: number) => any;
38
+ export const objecteventsummary_deleted: (a: number) => number;
39
+ export const objecteventsummary_id: (a: number) => [number, number];
40
+ export const objecteventsummary_object: (a: number) => number;
41
+ export const objecteventsummary_updatedAt: (a: number) => any;
37
42
  export const objectsummary_createdAt: (a: number) => any;
38
43
  export const objectsummary_id: (a: number) => [number, number];
39
44
  export const objectsummary_metadata: (a: number) => [number, number];
@@ -58,6 +63,13 @@ export const pinnedobject_slabs: (a: number) => [number, number, number];
58
63
  export const pinnedobject_truncate: (a: number, b: bigint) => number;
59
64
  export const pinnedobject_updateMetadata: (a: number, b: number, c: number) => void;
60
65
  export const pinnedobject_updatedAt: (a: number) => any;
66
+ export const preauthorizedkey_export: (a: number) => [number, number];
67
+ export const preauthorizedkey_import: (a: number, b: number) => [number, number, number];
68
+ export const preauthorizedkey_new: () => number;
69
+ export const preauthorizedkey_publicKey: (a: number) => [number, number];
70
+ export const preauthorizedkey_sign: (a: number, b: number, c: number) => [number, number];
71
+ export const preauthorizedkey_signRequest: (a: number, b: any) => [number, number, number];
72
+ export const preauthorizedkey_verifySignature: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
61
73
  export const sdk_account: (a: number) => any;
62
74
  export const sdk_appKey: (a: number) => number;
63
75
  export const sdk_createSharingKey: (a: number, b: number, c: number, d: number) => any;
@@ -65,6 +77,7 @@ export const sdk_deleteObject: (a: number, b: number, c: number) => any;
65
77
  export const sdk_download: (a: number, b: number, c: number) => [number, number, number];
66
78
  export const sdk_hosts: (a: number, b: number) => any;
67
79
  export const sdk_object: (a: number, b: number, c: number) => any;
80
+ export const sdk_objectEventSummaries: (a: number, b: any, c: number) => any;
68
81
  export const sdk_objectEvents: (a: number, b: any, c: number) => any;
69
82
  export const sdk_objectFromShareUrl: (a: number, b: number, c: number) => any;
70
83
  export const sdk_objectShareUrl: (a: number, b: number, c: any) => [number, number, number, number];
@@ -91,6 +104,7 @@ export const sharingkey_fromSeed: (a: number, b: number) => [number, number, num
91
104
  export const sharingkey_publicKey: (a: number) => [number, number];
92
105
  export const sharingkey_seed: (a: number) => [number, number];
93
106
  export const validateRecoveryPhrase: (a: number, b: number) => [number, number];
107
+ export const __wbg_preauthorizedkey_free: (a: number, b: number) => void;
94
108
  export const __wbg_sharingkey_free: (a: number, b: number) => void;
95
109
  export const __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
96
110
  export const __wbg_intounderlyingsink_free: (a: number, b: number) => void;
@@ -109,7 +123,7 @@ export const wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_
109
123
  export const wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___sys__Undefined__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true_: (a: number, b: number, c: any) => [number, number];
110
124
  export const wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___sys__Undefined__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true__3: (a: number, b: number, c: any) => [number, number];
111
125
  export const wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___sys__Undefined__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_63576b009277873___JsError___true__4: (a: number, b: number, c: any) => [number, number];
112
- export const wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_eaf17bee0f0de45e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
126
+ export const wasm_bindgen_63576b009277873___convert__closures_____invoke___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined___js_sys_89dff7ebd9bf220e___Function_fn_wasm_bindgen_63576b009277873___JsValue_____wasm_bindgen_63576b009277873___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
113
127
  export const wasm_bindgen_63576b009277873___convert__closures_____invoke___wasm_bindgen_63576b009277873___JsValue______true_: (a: number, b: number, c: any) => void;
114
128
  export const wasm_bindgen_63576b009277873___convert__closures_____invoke_______true_: (a: number, b: number) => void;
115
129
  export const __wbindgen_malloc: (a: number, b: number) => number;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/stream/errors.ts","../src/stream/protocol.ts"],"sourcesContent":["/** Only sanitized strings cross the diagnostic boundary, never raw SDK objects. */\nexport function streamErrorMessage(error: unknown): string {\n const message =\n error instanceof Error\n ? error.message\n : typeof error === 'string'\n ? error\n : 'Unknown streaming failure'\n return message\n .replace(/\\b(?:https?|wss?|sia):\\/\\/[^\\s\"'<>]+/gi, '[URL redacted]')\n .replace(/(?:bearer\\s+)[^\\s,;]+/gi, 'Bearer [redacted]')\n .replace(\n /((?:seed|share|token|key|authorization)\\s*[=:]\\s*)[^\\s,;]+/gi,\n '$1[redacted]',\n )\n .replace(/[a-f0-9]{64,}/gi, '[redacted]')\n .replace(/[\\r\\n\\t]/g, ' ')\n .slice(0, 1000)\n}\n\nexport function reportStreamError(\n error: unknown,\n name: string,\n range: { offset: number; length: number } | undefined,\n) {\n const message = streamErrorMessage(error)\n // One string rather than an object, so it reads the same in every console.\n const bytes = range\n ? ` bytes ${range.offset}-${range.offset + range.length - 1}`\n : ''\n console.error(`[Sia stream] ${streamErrorMessage(name)}${bytes}: ${message}`)\n return message\n}\n","/**\n * Messages between a page and its streaming service worker.\n *\n * Stream URLs carry only the page's client id and a random token. When the\n * worker meets a token it does not know, it asks the page that made it for the\n * file and the share's credentials. The page and a worker can come from\n * different deployed versions, so the worker checks the page's reply before\n * using it.\n */\nimport type {\n AppMetadata,\n SealedObject,\n ShardProgress,\n} from '../../wasm/sia_storage_wasm.js'\n\n/**\n * What a stream URL is doing. `connecting` is a request waiting for its first\n * bytes, which on the URL's first request includes the worker connecting its\n * SDK and finding the object. `downloading` means bytes are arriving. `idle`\n * means no request for the URL is in flight, after the last one finished, was\n * cancelled or failed.\n */\nexport type StreamStatus = 'connecting' | 'downloading' | 'idle'\n\n/** The reports a page can ask for, one per callback it was given. */\nexport type StreamEvent = 'status' | 'progress' | 'shards'\nconst STREAM_EVENTS: readonly unknown[] = ['status', 'progress', 'shards']\n\n/**\n * What the worker connects its own SDK with. A `SharedSdk` reconnects from its\n * sharing key's seed, and an `Sdk` from its app key, as hex, and app metadata.\n * A `SharedSdk`'s `sealKey` is the hex of the random key the page seals its\n * objects with. A page from before it existed sends none.\n */\nexport type Connection =\n | { kind: 'shared'; indexerUrl: string; seed: string; sealKey?: string }\n | { kind: 'app'; indexerUrl: string; appKey: string; appMeta: AppMetadata }\n\nexport type SourceDetails = {\n // One per opened SDK, so the worker can release it as a whole.\n session: string\n connection: Connection\n objectId: string\n // The object, sealed with its app key or the share's `sealKey`, so the\n // worker can open it without a lookup. Without it the worker looks the\n // object up by `objectId`.\n sealed?: SealedObject\n name: string\n mime: string\n size: number\n // The reports the page wants for this URL. The worker sends no others, and\n // asks the SDK for shard reports only when `shards` is here.\n events?: StreamEvent[]\n}\n\n/** Page to worker. */\nexport type PageMessage =\n | { type: 'sia-client' }\n | { type: 'sia-release'; token: string }\n | { type: 'sia-release-share'; session: string }\n // Sent while the worker reports `sia-streaming` active. The event it raises\n // in the worker is what keeps the worker running.\n | { type: 'sia-keep-alive' }\n\n/** Worker to page. */\nexport type WorkerMessage =\n | { type: 'sia-source'; token: string }\n | {\n type: 'sia-stream-error'\n token: string\n message: string\n offset?: number\n length?: number\n }\n | { type: 'sia-stream-status'; token: string; status: StreamStatus }\n // Whether any request from this page is still being served. Sent when that\n // changes, and in reply to a keep-alive that arrives when none is.\n | { type: 'sia-streaming'; active: boolean }\n | {\n type: 'sia-stream-progress'\n token: string\n // Bytes served since the previous progress message.\n bytes: number\n shards: ShardProgress[]\n }\n\n/** The worker's answer to `sia-client`. */\nexport type ClientReply = { clientId: string; supported: boolean }\n\n/** The page's answer to `sia-source`. */\nexport type SourceReply =\n | ({ type: 'source' } & SourceDetails)\n | { type: 'error' }\n\n// Stream URLs sit under the worker's scope, so a download's navigation, which\n// only a worker whose scope covers the URL can answer, reaches it on sites\n// served from a sub-path too.\nconst STREAM_PATH = /\\/__sia_stream__\\/([^/]+)\\/([^/]+)\\/[^/]+$/\n\n/** `scope` is the worker registration's scope URL, which ends in a slash. */\nexport function streamPath(scope: string, clientId: string, token: string) {\n return `${scope}__sia_stream__/${clientId}/${token}/file`\n}\n\nexport function parseStreamPath(pathname: string) {\n const match = STREAM_PATH.exec(pathname)\n return match ? { clientId: match[1]!, token: match[2]! } : undefined\n}\n\ntype Fields = Record<string, unknown> | null | undefined\n\nconst strings = (data: Fields, fields: string[]) =>\n fields.every((field) => typeof data?.[field] === 'string')\n\n/** Checked on both sides, so bad metadata fails in `openStreams`, not per request. */\nexport function isAppMetadata(value: unknown): value is AppMetadata {\n return strings(value as Fields, ['appId', 'name', 'description', 'serviceUrl'])\n}\n\n// 32 bytes as hex, which is what the worker builds an AppKey from.\nconst isKeyHex = (value: unknown) =>\n typeof value === 'string' && /^[0-9a-f]{64}$/i.test(value)\n\nfunction isConnection(value: unknown): value is Connection {\n const data = value as Fields\n if (data?.kind === 'shared') {\n return (\n strings(data, ['indexerUrl', 'seed']) &&\n (data.sealKey === undefined || isKeyHex(data.sealKey))\n )\n }\n return (\n data?.kind === 'app' &&\n strings(data, ['indexerUrl', 'appKey']) &&\n isAppMetadata(data.appMeta)\n )\n}\n\nexport function isSourceReply(\n reply: unknown,\n): reply is { type: 'source' } & SourceDetails {\n const data = reply as Fields\n return (\n data?.type === 'source' &&\n strings(data, ['session', 'objectId', 'name', 'mime']) &&\n isConnection(data.connection) &&\n (data.connection.kind === 'shared' ||\n (typeof data.sealed === 'object' && data.sealed !== null)) &&\n Number.isSafeInteger(data.size) &&\n (data.size as number) >= 0 &&\n (data.events === undefined ||\n (Array.isArray(data.events) &&\n data.events.every((event) => STREAM_EVENTS.includes(event))))\n )\n}\n\n/**\n * Posts `message` with a reply port and resolves with the first reply. Rejects\n * after `timeout` ms, or when `signal` aborts.\n */\nexport function requestReply(\n target: { postMessage(message: unknown, transfer: Transferable[]): void },\n message: unknown,\n { timeout, signal }: { timeout?: number; signal?: AbortSignal },\n): Promise<unknown> {\n return new Promise((resolve, reject) => {\n const { port1, port2 } = new MessageChannel()\n const timer =\n timeout === undefined\n ? undefined\n : setTimeout(\n () => settle(() => reject(new Error('No reply in time.'))),\n timeout,\n )\n const abort = () => settle(() => reject(signal?.reason))\n function settle(outcome: () => void) {\n clearTimeout(timer)\n signal?.removeEventListener('abort', abort)\n port1.close()\n port2.close()\n outcome()\n }\n if (signal?.aborted) return abort()\n signal?.addEventListener('abort', abort, { once: true })\n port1.onmessage = ({ data }) => settle(() => resolve(data))\n port1.onmessageerror = () =>\n settle(() => reject(new Error('Unreadable reply.')))\n try {\n target.postMessage(message, [port2])\n } catch (error) {\n settle(() => reject(error))\n }\n })\n}\n"],"mappings":"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","names":[]}