@synonymdev/pubky 0.1.16 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -1,3 +1,8 @@
1
+ const makeFetchCookie = require("fetch-cookie").default;
2
+
3
+ let originalFetch = globalThis.fetch;
4
+ globalThis.fetch = makeFetchCookie(originalFetch);
5
+
1
6
 
2
7
  let imports = {};
3
8
  imports['__wbindgen_placeholder__'] = module.exports;
@@ -216,27 +221,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
216
221
  return real;
217
222
  }
218
223
  function __wbg_adapter_26(arg0, arg1, arg2) {
219
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h319ede9bf10254b2(arg0, arg1, addHeapObject(arg2));
220
- }
221
-
222
- function passArrayJsValueToWasm0(array, malloc) {
223
- const ptr = malloc(array.length * 4, 4) >>> 0;
224
- const mem = getDataViewMemory0();
225
- for (let i = 0; i < array.length; i++) {
226
- mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
227
- }
228
- WASM_VECTOR_LEN = array.length;
229
- return ptr;
230
- }
231
-
232
- function getArrayJsValueFromWasm0(ptr, len) {
233
- ptr = ptr >>> 0;
234
- const mem = getDataViewMemory0();
235
- const result = [];
236
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
237
- result.push(takeObject(mem.getUint32(i, true)));
238
- }
239
- return result;
224
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf3abd8d2e3570b7c(arg0, arg1, addHeapObject(arg2));
240
225
  }
241
226
 
242
227
  function _assertClass(instance, klass) {
@@ -245,13 +230,6 @@ function _assertClass(instance, klass) {
245
230
  }
246
231
  return instance.ptr;
247
232
  }
248
-
249
- function passArray8ToWasm0(arg, malloc) {
250
- const ptr = malloc(arg.length * 1, 1) >>> 0;
251
- getUint8ArrayMemory0().set(arg, ptr / 1);
252
- WASM_VECTOR_LEN = arg.length;
253
- return ptr;
254
- }
255
233
  /**
256
234
  * Create a recovery file of the `keypair`, containing the secret key encrypted
257
235
  * using the `passphrase`.
@@ -278,6 +256,12 @@ module.exports.createRecoveryFile = function(keypair, passphrase) {
278
256
  }
279
257
  };
280
258
 
259
+ function passArray8ToWasm0(arg, malloc) {
260
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
261
+ getUint8ArrayMemory0().set(arg, ptr / 1);
262
+ WASM_VECTOR_LEN = arg.length;
263
+ return ptr;
264
+ }
281
265
  /**
282
266
  * Create a recovery file of the `keypair`, containing the secret key encrypted
283
267
  * using the `passphrase`.
@@ -305,6 +289,16 @@ module.exports.decryptRecoveryFile = function(recovery_file, passphrase) {
305
289
  }
306
290
  };
307
291
 
292
+ function getArrayJsValueFromWasm0(ptr, len) {
293
+ ptr = ptr >>> 0;
294
+ const mem = getDataViewMemory0();
295
+ const result = [];
296
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
297
+ result.push(takeObject(mem.getUint32(i, true)));
298
+ }
299
+ return result;
300
+ }
301
+
308
302
  function handleError(f, args) {
309
303
  try {
310
304
  return f.apply(this, args);
@@ -312,8 +306,8 @@ function handleError(f, args) {
312
306
  wasm.__wbindgen_exn_store(addHeapObject(e));
313
307
  }
314
308
  }
315
- function __wbg_adapter_140(arg0, arg1, arg2, arg3) {
316
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h53759509a0f0816b(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
309
+ function __wbg_adapter_141(arg0, arg1, arg2, arg3) {
310
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h6757e2d3bad4487e(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
317
311
  }
318
312
 
319
313
  const KeypairFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -416,53 +410,6 @@ class PubkyClient {
416
410
  wasm.__wbg_pubkyclient_free(ptr, 0);
417
411
  }
418
412
  /**
419
- */
420
- constructor() {
421
- const ret = wasm.pubkyclient_new();
422
- this.__wbg_ptr = ret >>> 0;
423
- PubkyClientFinalization.register(this, this.__wbg_ptr, this);
424
- return this;
425
- }
426
- /**
427
- * Create a client with with configurations appropriate for local testing:
428
- * - set Pkarr relays to `["http://localhost:15411/pkarr"]` instead of default relay.
429
- * @returns {PubkyClient}
430
- */
431
- static testnet() {
432
- const ret = wasm.pubkyclient_testnet();
433
- return PubkyClient.__wrap(ret);
434
- }
435
- /**
436
- * Set Pkarr relays used for publishing and resolving Pkarr packets.
437
- *
438
- * By default, [PubkyClient] will use `["https://relay.pkarr.org"]`
439
- * @param {(string)[]} relays
440
- * @returns {PubkyClient}
441
- */
442
- setPkarrRelays(relays) {
443
- const ptr = this.__destroy_into_raw();
444
- const ptr0 = passArrayJsValueToWasm0(relays, wasm.__wbindgen_malloc);
445
- const len0 = WASM_VECTOR_LEN;
446
- const ret = wasm.pubkyclient_setPkarrRelays(ptr, ptr0, len0);
447
- return PubkyClient.__wrap(ret);
448
- }
449
- /**
450
- * @returns {(string)[]}
451
- */
452
- getPkarrRelays() {
453
- try {
454
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
455
- wasm.pubkyclient_getPkarrRelays(retptr, this.__wbg_ptr);
456
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
457
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
458
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
459
- wasm.__wbindgen_free(r0, r1 * 4, 4);
460
- return v1;
461
- } finally {
462
- wasm.__wbindgen_add_to_stack_pointer(16);
463
- }
464
- }
465
- /**
466
413
  * Signup to a homeserver and update Pkarr accordingly.
467
414
  *
468
415
  * The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
@@ -613,6 +560,35 @@ class PubkyClient {
613
560
  const ret = wasm.pubkyclient_list(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(reverse) ? 0xFFFFFF : reverse ? 1 : 0, isLikeNone(limit) ? 0xFFFFFF : limit, isLikeNone(shallow) ? 0xFFFFFF : shallow ? 1 : 0);
614
561
  return takeObject(ret);
615
562
  }
563
+ /**
564
+ * Create PubkyClient with default Settings including default relays
565
+ */
566
+ constructor() {
567
+ const ret = wasm.pubkyclient_new();
568
+ this.__wbg_ptr = ret >>> 0;
569
+ PubkyClientFinalization.register(this, this.__wbg_ptr, this);
570
+ return this;
571
+ }
572
+ /**
573
+ * Create a client with with configurations appropriate for local testing:
574
+ * - set Pkarr relays to `["http://localhost:15411/pkarr"]` instead of default relay.
575
+ * @returns {PubkyClient}
576
+ */
577
+ static testnet() {
578
+ const ret = wasm.pubkyclient_testnet();
579
+ return PubkyClient.__wrap(ret);
580
+ }
581
+ /**
582
+ * @param {string} url
583
+ * @param {any} init
584
+ * @returns {Promise<Promise<any>>}
585
+ */
586
+ fetch(url, init) {
587
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
588
+ const len0 = WASM_VECTOR_LEN;
589
+ const ret = wasm.pubkyclient_fetch(this.__wbg_ptr, ptr0, len0, addHeapObject(init));
590
+ return takeObject(ret);
591
+ }
616
592
  }
617
593
  module.exports.PubkyClient = PubkyClient;
618
594
 
@@ -775,7 +751,12 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
775
751
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
776
752
  };
777
753
 
778
- module.exports.__wbg_fetch_1e4e8ed1f64c7e28 = function(arg0) {
754
+ module.exports.__wbg_fetch_f7009dcc8692ba82 = function(arg0) {
755
+ const ret = fetch(getObject(arg0));
756
+ return addHeapObject(ret);
757
+ };
758
+
759
+ module.exports.__wbg_fetch_f8d735ba6fe1b719 = function(arg0) {
779
760
  const ret = fetch(getObject(arg0));
780
761
  return addHeapObject(ret);
781
762
  };
@@ -785,23 +766,33 @@ module.exports.__wbindgen_object_clone_ref = function(arg0) {
785
766
  return addHeapObject(ret);
786
767
  };
787
768
 
788
- module.exports.__wbg_fetch_ba7fe179e527d942 = function(arg0, arg1) {
789
- const ret = getObject(arg0).fetch(getObject(arg1));
790
- return addHeapObject(ret);
769
+ module.exports.__wbindgen_cb_drop = function(arg0) {
770
+ const obj = takeObject(arg0).original;
771
+ if (obj.cnt-- == 1) {
772
+ obj.a = 0;
773
+ return true;
774
+ }
775
+ const ret = false;
776
+ return ret;
791
777
  };
792
778
 
793
- module.exports.__wbg_signal_41e46ccad44bb5e2 = function(arg0) {
794
- const ret = getObject(arg0).signal;
795
- return addHeapObject(ret);
779
+ module.exports.__wbg_queueMicrotask_12a30234db4045d3 = function(arg0) {
780
+ queueMicrotask(getObject(arg0));
796
781
  };
797
782
 
798
- module.exports.__wbg_new_ebf2727385ee825c = function() { return handleError(function () {
799
- const ret = new AbortController();
783
+ module.exports.__wbg_queueMicrotask_48421b3cc9052b68 = function(arg0) {
784
+ const ret = getObject(arg0).queueMicrotask;
800
785
  return addHeapObject(ret);
801
- }, arguments) };
786
+ };
802
787
 
803
- module.exports.__wbg_abort_8659d889a7877ae3 = function(arg0) {
804
- getObject(arg0).abort();
788
+ module.exports.__wbindgen_is_function = function(arg0) {
789
+ const ret = typeof(getObject(arg0)) === 'function';
790
+ return ret;
791
+ };
792
+
793
+ module.exports.__wbg_fetch_ba7fe179e527d942 = function(arg0, arg1) {
794
+ const ret = getObject(arg0).fetch(getObject(arg1));
795
+ return addHeapObject(ret);
805
796
  };
806
797
 
807
798
  module.exports.__wbg_newwithstrandinit_a31c69e4cc337183 = function() { return handleError(function (arg0, arg1, arg2) {
@@ -833,6 +824,20 @@ module.exports.__wbg_setsignal_91c4e8ebd04eb935 = function(arg0, arg1) {
833
824
  getObject(arg0).signal = getObject(arg1);
834
825
  };
835
826
 
827
+ module.exports.__wbg_signal_41e46ccad44bb5e2 = function(arg0) {
828
+ const ret = getObject(arg0).signal;
829
+ return addHeapObject(ret);
830
+ };
831
+
832
+ module.exports.__wbg_new_ebf2727385ee825c = function() { return handleError(function () {
833
+ const ret = new AbortController();
834
+ return addHeapObject(ret);
835
+ }, arguments) };
836
+
837
+ module.exports.__wbg_abort_8659d889a7877ae3 = function(arg0) {
838
+ getObject(arg0).abort();
839
+ };
840
+
836
841
  module.exports.__wbg_new_e27c93803e1acc42 = function() { return handleError(function () {
837
842
  const ret = new Headers();
838
843
  return addHeapObject(ret);
@@ -876,30 +881,6 @@ module.exports.__wbg_arrayBuffer_a5fbad63cc7e663b = function() { return handleEr
876
881
  return addHeapObject(ret);
877
882
  }, arguments) };
878
883
 
879
- module.exports.__wbindgen_cb_drop = function(arg0) {
880
- const obj = takeObject(arg0).original;
881
- if (obj.cnt-- == 1) {
882
- obj.a = 0;
883
- return true;
884
- }
885
- const ret = false;
886
- return ret;
887
- };
888
-
889
- module.exports.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) {
890
- queueMicrotask(getObject(arg0));
891
- };
892
-
893
- module.exports.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) {
894
- const ret = getObject(arg0).queueMicrotask;
895
- return addHeapObject(ret);
896
- };
897
-
898
- module.exports.__wbindgen_is_function = function(arg0) {
899
- const ret = typeof(getObject(arg0)) === 'function';
900
- return ret;
901
- };
902
-
903
884
  module.exports.__wbindgen_is_object = function(arg0) {
904
885
  const val = getObject(arg0);
905
886
  const ret = typeof(val) === 'object' && val !== null;
@@ -1046,7 +1027,7 @@ module.exports.__wbg_new_b85e72ed1bfd57f9 = function(arg0, arg1) {
1046
1027
  const a = state0.a;
1047
1028
  state0.a = 0;
1048
1029
  try {
1049
- return __wbg_adapter_140(a, state0.b, arg0, arg1);
1030
+ return __wbg_adapter_141(a, state0.b, arg0, arg1);
1050
1031
  } finally {
1051
1032
  state0.a = a;
1052
1033
  }
@@ -1155,8 +1136,8 @@ module.exports.__wbindgen_memory = function() {
1155
1136
  return addHeapObject(ret);
1156
1137
  };
1157
1138
 
1158
- module.exports.__wbindgen_closure_wrapper2075 = function(arg0, arg1, arg2) {
1159
- const ret = makeMutClosure(arg0, arg1, 357, __wbg_adapter_26);
1139
+ module.exports.__wbindgen_closure_wrapper1476 = function(arg0, arg1, arg2) {
1140
+ const ret = makeMutClosure(arg0, arg1, 284, __wbg_adapter_26);
1160
1141
  return addHeapObject(ret);
1161
1142
  };
1162
1143