@synonymdev/pubky 0.5.0-rc.2 → 0.5.2
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 +75 -102
- package/index.js +91 -123
- package/package.json +1 -1
- package/pubky.d.ts +0 -197
- package/pubky_bg.wasm +0 -0
package/index.cjs
CHANGED
|
@@ -229,17 +229,6 @@ module.exports.setLogLevel = function(level) {
|
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
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(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
238
|
-
}
|
|
239
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
240
|
-
return result;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
232
|
function _assertClass(instance, klass) {
|
|
244
233
|
if (!(instance instanceof klass)) {
|
|
245
234
|
throw new Error(`expected instance of ${klass.name}`);
|
|
@@ -285,20 +274,26 @@ module.exports.decryptRecoveryFile = function(recovery_file, passphrase) {
|
|
|
285
274
|
return Keypair.__wrap(ret[0]);
|
|
286
275
|
};
|
|
287
276
|
|
|
288
|
-
function
|
|
289
|
-
|
|
277
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
278
|
+
ptr = ptr >>> 0;
|
|
279
|
+
const mem = getDataViewMemory0();
|
|
280
|
+
const result = [];
|
|
281
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
282
|
+
result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
|
|
283
|
+
}
|
|
284
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
285
|
+
return result;
|
|
290
286
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf8c6f475b193d201(arg0, arg1);
|
|
287
|
+
function __wbg_adapter_28(arg0, arg1) {
|
|
288
|
+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h76b7e185a7848c9a(arg0, arg1);
|
|
294
289
|
}
|
|
295
290
|
|
|
296
|
-
function
|
|
297
|
-
wasm.
|
|
291
|
+
function __wbg_adapter_31(arg0, arg1, arg2) {
|
|
292
|
+
wasm.closure650_externref_shim(arg0, arg1, arg2);
|
|
298
293
|
}
|
|
299
294
|
|
|
300
|
-
function
|
|
301
|
-
wasm.
|
|
295
|
+
function __wbg_adapter_167(arg0, arg1, arg2, arg3) {
|
|
296
|
+
wasm.closure767_externref_shim(arg0, arg1, arg2, arg3);
|
|
302
297
|
}
|
|
303
298
|
|
|
304
299
|
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -389,6 +384,17 @@ class Client {
|
|
|
389
384
|
const ptr = this.__destroy_into_raw();
|
|
390
385
|
wasm.__wbg_client_free(ptr, 0);
|
|
391
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* @param {string} url
|
|
389
|
+
* @param {any | null} [init]
|
|
390
|
+
* @returns {Promise<Promise<any>>}
|
|
391
|
+
*/
|
|
392
|
+
fetch(url, init) {
|
|
393
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
394
|
+
const len0 = WASM_VECTOR_LEN;
|
|
395
|
+
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(init) ? 0 : addToExternrefTable0(init));
|
|
396
|
+
return ret;
|
|
397
|
+
}
|
|
392
398
|
/**
|
|
393
399
|
* Signup to a homeserver and update Pkarr accordingly.
|
|
394
400
|
*
|
|
@@ -510,41 +516,6 @@ class Client {
|
|
|
510
516
|
const ret = wasm.client_republishHomeserver(this.__wbg_ptr, keypair.__wbg_ptr, host.__wbg_ptr);
|
|
511
517
|
return ret;
|
|
512
518
|
}
|
|
513
|
-
/**
|
|
514
|
-
* Create a new Pubky Client with an optional configuration.
|
|
515
|
-
* @param {PubkyClientConfig | null} [config_opt]
|
|
516
|
-
*/
|
|
517
|
-
constructor(config_opt) {
|
|
518
|
-
const ret = wasm.client_new(isLikeNone(config_opt) ? 0 : addToExternrefTable0(config_opt));
|
|
519
|
-
if (ret[2]) {
|
|
520
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
521
|
-
}
|
|
522
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
523
|
-
ClientFinalization.register(this, this.__wbg_ptr, this);
|
|
524
|
-
return this;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Create a client with with configurations appropriate for local testing:
|
|
528
|
-
* - set Pkarr relays to `["http://localhost:15411"]` instead of default relay.
|
|
529
|
-
* - transform `pubky://<pkarr public key>` to `http://<pkarr public key` instead of `https:`
|
|
530
|
-
* and read the homeserver HTTP port from the [reserved service parameter key](pubky_common::constants::reserved_param_keys::HTTP_PORT)
|
|
531
|
-
* @returns {Client}
|
|
532
|
-
*/
|
|
533
|
-
static testnet() {
|
|
534
|
-
const ret = wasm.client_testnet();
|
|
535
|
-
return Client.__wrap(ret);
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* @param {string} url
|
|
539
|
-
* @param {any | null} [request_init]
|
|
540
|
-
* @returns {Promise<Promise<any>>}
|
|
541
|
-
*/
|
|
542
|
-
fetch(url, request_init) {
|
|
543
|
-
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
544
|
-
const len0 = WASM_VECTOR_LEN;
|
|
545
|
-
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(request_init) ? 0 : addToExternrefTable0(request_init));
|
|
546
|
-
return ret;
|
|
547
|
-
}
|
|
548
519
|
/**
|
|
549
520
|
* Returns a list of Pubky urls (as strings).
|
|
550
521
|
*
|
|
@@ -569,6 +540,33 @@ class Client {
|
|
|
569
540
|
const ret = wasm.client_list(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(reverse) ? 0xFFFFFF : reverse ? 1 : 0, isLikeNone(limit) ? 0xFFFFFF : limit, isLikeNone(shallow) ? 0xFFFFFF : shallow ? 1 : 0);
|
|
570
541
|
return ret;
|
|
571
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Create a new Pubky Client with an optional configuration.
|
|
545
|
+
* @param {PubkyClientConfig | null} [config_opt]
|
|
546
|
+
*/
|
|
547
|
+
constructor(config_opt) {
|
|
548
|
+
const ret = wasm.client_new(isLikeNone(config_opt) ? 0 : addToExternrefTable0(config_opt));
|
|
549
|
+
if (ret[2]) {
|
|
550
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
551
|
+
}
|
|
552
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
553
|
+
ClientFinalization.register(this, this.__wbg_ptr, this);
|
|
554
|
+
return this;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Create a client with with configurations appropriate for local testing:
|
|
558
|
+
* - set Pkarr relays to `http://<host>:15411` (defaults to `localhost`).
|
|
559
|
+
* - transform `pubky://<pkarr public key>` to `http://<host>` instead of `https:`
|
|
560
|
+
* and read the homeserver HTTP port from the PKarr record.
|
|
561
|
+
* @param {string | null} [host]
|
|
562
|
+
* @returns {Client}
|
|
563
|
+
*/
|
|
564
|
+
static testnet(host) {
|
|
565
|
+
var ptr0 = isLikeNone(host) ? 0 : passStringToWasm0(host, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
566
|
+
var len0 = WASM_VECTOR_LEN;
|
|
567
|
+
const ret = wasm.client_testnet(ptr0, len0);
|
|
568
|
+
return Client.__wrap(ret);
|
|
569
|
+
}
|
|
572
570
|
}
|
|
573
571
|
module.exports.Client = Client;
|
|
574
572
|
|
|
@@ -797,17 +795,12 @@ module.exports.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(fun
|
|
|
797
795
|
return ret;
|
|
798
796
|
}, arguments) };
|
|
799
797
|
|
|
800
|
-
module.exports.
|
|
798
|
+
module.exports.__wbg_clearTimeout_0b53d391c1b94dda = function(arg0) {
|
|
801
799
|
const ret = clearTimeout(arg0);
|
|
802
800
|
return ret;
|
|
803
801
|
};
|
|
804
802
|
|
|
805
|
-
module.exports.
|
|
806
|
-
const ret = clearTimeout(arg0);
|
|
807
|
-
return ret;
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
module.exports.__wbg_crypto_ed58b8e10a292839 = function(arg0) {
|
|
803
|
+
module.exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
811
804
|
const ret = arg0.crypto;
|
|
812
805
|
return ret;
|
|
813
806
|
};
|
|
@@ -825,26 +818,26 @@ module.exports.__wbg_error_80de38b3f7cc3c3c = function(arg0, arg1, arg2, arg3) {
|
|
|
825
818
|
console.error(arg0, arg1, arg2, arg3);
|
|
826
819
|
};
|
|
827
820
|
|
|
828
|
-
module.exports.
|
|
829
|
-
const ret =
|
|
821
|
+
module.exports.__wbg_fetch_11bff8299d0ecd2b = function(arg0) {
|
|
822
|
+
const ret = fetch(arg0);
|
|
830
823
|
return ret;
|
|
831
824
|
};
|
|
832
825
|
|
|
833
|
-
module.exports.
|
|
834
|
-
const ret = fetch(
|
|
826
|
+
module.exports.__wbg_fetch_509096533071c657 = function(arg0, arg1) {
|
|
827
|
+
const ret = arg0.fetch(arg1);
|
|
835
828
|
return ret;
|
|
836
829
|
};
|
|
837
830
|
|
|
838
|
-
module.exports.
|
|
831
|
+
module.exports.__wbg_fetch_de12f9389c1d3a90 = function(arg0) {
|
|
839
832
|
const ret = fetch(arg0);
|
|
840
833
|
return ret;
|
|
841
834
|
};
|
|
842
835
|
|
|
843
|
-
module.exports.
|
|
836
|
+
module.exports.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return handleError(function (arg0, arg1) {
|
|
844
837
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
845
838
|
}, arguments) };
|
|
846
839
|
|
|
847
|
-
module.exports.
|
|
840
|
+
module.exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
848
841
|
arg0.getRandomValues(arg1);
|
|
849
842
|
}, arguments) };
|
|
850
843
|
|
|
@@ -853,11 +846,6 @@ module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(func
|
|
|
853
846
|
return ret;
|
|
854
847
|
}, arguments) };
|
|
855
848
|
|
|
856
|
-
module.exports.__wbg_getheaders_8326221cf02f205d = function(arg0) {
|
|
857
|
-
const ret = arg0.headers;
|
|
858
|
-
return ret;
|
|
859
|
-
};
|
|
860
|
-
|
|
861
849
|
module.exports.__wbg_has_a5ea9117f258a0ec = function() { return handleError(function (arg0, arg1) {
|
|
862
850
|
const ret = Reflect.has(arg0, arg1);
|
|
863
851
|
return ret;
|
|
@@ -897,7 +885,7 @@ module.exports.__wbg_log_cad59bb680daec67 = function(arg0, arg1, arg2, arg3) {
|
|
|
897
885
|
console.log(arg0, arg1, arg2, arg3);
|
|
898
886
|
};
|
|
899
887
|
|
|
900
|
-
module.exports.
|
|
888
|
+
module.exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
901
889
|
const ret = arg0.msCrypto;
|
|
902
890
|
return ret;
|
|
903
891
|
};
|
|
@@ -914,7 +902,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
|
|
|
914
902
|
const a = state0.a;
|
|
915
903
|
state0.a = 0;
|
|
916
904
|
try {
|
|
917
|
-
return
|
|
905
|
+
return __wbg_adapter_167(a, state0.b, arg0, arg1);
|
|
918
906
|
} finally {
|
|
919
907
|
state0.a = a;
|
|
920
908
|
}
|
|
@@ -976,7 +964,7 @@ module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(fun
|
|
|
976
964
|
return ret;
|
|
977
965
|
}, arguments) };
|
|
978
966
|
|
|
979
|
-
module.exports.
|
|
967
|
+
module.exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
980
968
|
const ret = arg0.node;
|
|
981
969
|
return ret;
|
|
982
970
|
};
|
|
@@ -986,7 +974,7 @@ module.exports.__wbg_now_807e54c39636c349 = function() {
|
|
|
986
974
|
return ret;
|
|
987
975
|
};
|
|
988
976
|
|
|
989
|
-
module.exports.
|
|
977
|
+
module.exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
990
978
|
const ret = arg0.process;
|
|
991
979
|
return ret;
|
|
992
980
|
};
|
|
@@ -1010,11 +998,11 @@ module.exports.__wbg_queueMicrotask_d3219def82552485 = function(arg0) {
|
|
|
1010
998
|
return ret;
|
|
1011
999
|
};
|
|
1012
1000
|
|
|
1013
|
-
module.exports.
|
|
1001
|
+
module.exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
1014
1002
|
arg0.randomFillSync(arg1);
|
|
1015
1003
|
}, arguments) };
|
|
1016
1004
|
|
|
1017
|
-
module.exports.
|
|
1005
|
+
module.exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
1018
1006
|
const ret = module.require;
|
|
1019
1007
|
return ret;
|
|
1020
1008
|
}, arguments) };
|
|
@@ -1029,16 +1017,11 @@ module.exports.__wbg_session_new = function(arg0) {
|
|
|
1029
1017
|
return ret;
|
|
1030
1018
|
};
|
|
1031
1019
|
|
|
1032
|
-
module.exports.
|
|
1020
|
+
module.exports.__wbg_setTimeout_73ce8df12de4f2f2 = function(arg0, arg1) {
|
|
1033
1021
|
const ret = setTimeout(arg0, arg1);
|
|
1034
1022
|
return ret;
|
|
1035
1023
|
};
|
|
1036
1024
|
|
|
1037
|
-
module.exports.__wbg_setTimeout_db2dbaeefb6f39c7 = function() { return handleError(function (arg0, arg1) {
|
|
1038
|
-
const ret = setTimeout(arg0, arg1);
|
|
1039
|
-
return ret;
|
|
1040
|
-
}, arguments) };
|
|
1041
|
-
|
|
1042
1025
|
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
1043
1026
|
arg0.set(arg1, arg2 >>> 0);
|
|
1044
1027
|
};
|
|
@@ -1135,7 +1118,7 @@ module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
|
|
|
1135
1118
|
return ret;
|
|
1136
1119
|
};
|
|
1137
1120
|
|
|
1138
|
-
module.exports.
|
|
1121
|
+
module.exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
1139
1122
|
const ret = arg0.versions;
|
|
1140
1123
|
return ret;
|
|
1141
1124
|
};
|
|
@@ -1154,18 +1137,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
1154
1137
|
return ret;
|
|
1155
1138
|
};
|
|
1156
1139
|
|
|
1157
|
-
module.exports.
|
|
1158
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1140
|
+
module.exports.__wbindgen_closure_wrapper1409 = function(arg0, arg1, arg2) {
|
|
1141
|
+
const ret = makeMutClosure(arg0, arg1, 624, __wbg_adapter_28);
|
|
1159
1142
|
return ret;
|
|
1160
1143
|
};
|
|
1161
1144
|
|
|
1162
|
-
module.exports.
|
|
1163
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1164
|
-
return ret;
|
|
1165
|
-
};
|
|
1166
|
-
|
|
1167
|
-
module.exports.__wbindgen_closure_wrapper3083 = function(arg0, arg1, arg2) {
|
|
1168
|
-
const ret = makeMutClosure(arg0, arg1, 594, __wbg_adapter_36);
|
|
1145
|
+
module.exports.__wbindgen_closure_wrapper1514 = function(arg0, arg1, arg2) {
|
|
1146
|
+
const ret = makeMutClosure(arg0, arg1, 651, __wbg_adapter_31);
|
|
1169
1147
|
return ret;
|
|
1170
1148
|
};
|
|
1171
1149
|
|
|
@@ -1193,11 +1171,6 @@ module.exports.__wbindgen_is_function = function(arg0) {
|
|
|
1193
1171
|
return ret;
|
|
1194
1172
|
};
|
|
1195
1173
|
|
|
1196
|
-
module.exports.__wbindgen_is_null = function(arg0) {
|
|
1197
|
-
const ret = arg0 === null;
|
|
1198
|
-
return ret;
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
1174
|
module.exports.__wbindgen_is_object = function(arg0) {
|
|
1202
1175
|
const val = arg0;
|
|
1203
1176
|
const ret = typeof(val) === 'object' && val !== null;
|
|
@@ -1237,7 +1210,7 @@ module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
|
1237
1210
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1238
1211
|
};
|
|
1239
1212
|
|
|
1240
|
-
const path = require('path').join(__dirname, '
|
|
1213
|
+
const path = require('path').join(__dirname, 'pubky_wasm_bg.wasm');
|
|
1241
1214
|
const bytes = require('fs').readFileSync(path);
|
|
1242
1215
|
|
|
1243
1216
|
const wasmModule = new WebAssembly.Module(bytes);
|