@synonymdev/pubky 0.5.1 → 0.5.4
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 +67 -92
- package/index.js +73 -103
- package/package.json +1 -1
- package/pubky.d.ts +21 -21
- package/pubky_bg.wasm +0 -0
package/index.cjs
CHANGED
|
@@ -212,28 +212,17 @@ function debugString(val) {
|
|
|
212
212
|
return className;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
function takeFromExternrefTable0(idx) {
|
|
216
|
-
const value = wasm.__wbindgen_export_2.get(idx);
|
|
217
|
-
wasm.__externref_table_dealloc(idx);
|
|
218
|
-
return value;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* @param {string} level
|
|
222
|
-
*/
|
|
223
|
-
module.exports.setLogLevel = function(level) {
|
|
224
|
-
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
225
|
-
const len0 = WASM_VECTOR_LEN;
|
|
226
|
-
const ret = wasm.setLogLevel(ptr0, len0);
|
|
227
|
-
if (ret[1]) {
|
|
228
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
|
|
232
215
|
function _assertClass(instance, klass) {
|
|
233
216
|
if (!(instance instanceof klass)) {
|
|
234
217
|
throw new Error(`expected instance of ${klass.name}`);
|
|
235
218
|
}
|
|
236
219
|
}
|
|
220
|
+
|
|
221
|
+
function takeFromExternrefTable0(idx) {
|
|
222
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
223
|
+
wasm.__externref_table_dealloc(idx);
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
237
226
|
/**
|
|
238
227
|
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
239
228
|
* using the `passphrase`.
|
|
@@ -284,20 +273,28 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
284
273
|
wasm.__externref_drop_slice(ptr, len);
|
|
285
274
|
return result;
|
|
286
275
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
276
|
+
/**
|
|
277
|
+
* @param {string} level
|
|
278
|
+
*/
|
|
279
|
+
module.exports.setLogLevel = function(level) {
|
|
280
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
const ret = wasm.setLogLevel(ptr0, len0);
|
|
283
|
+
if (ret[1]) {
|
|
284
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
290
287
|
|
|
291
|
-
function
|
|
292
|
-
wasm.
|
|
288
|
+
function __wbg_adapter_28(arg0, arg1) {
|
|
289
|
+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h05941f9305bd75fb(arg0, arg1);
|
|
293
290
|
}
|
|
294
291
|
|
|
295
|
-
function
|
|
296
|
-
wasm.
|
|
292
|
+
function __wbg_adapter_31(arg0, arg1, arg2) {
|
|
293
|
+
wasm.closure147_externref_shim(arg0, arg1, arg2);
|
|
297
294
|
}
|
|
298
295
|
|
|
299
|
-
function
|
|
300
|
-
wasm.
|
|
296
|
+
function __wbg_adapter_74(arg0, arg1, arg2, arg3) {
|
|
297
|
+
wasm.closure70_externref_shim(arg0, arg1, arg2, arg3);
|
|
301
298
|
}
|
|
302
299
|
|
|
303
300
|
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -388,30 +385,6 @@ class Client {
|
|
|
388
385
|
const ptr = this.__destroy_into_raw();
|
|
389
386
|
wasm.__wbg_client_free(ptr, 0);
|
|
390
387
|
}
|
|
391
|
-
/**
|
|
392
|
-
* Returns a list of Pubky urls (as strings).
|
|
393
|
-
*
|
|
394
|
-
* - `url`: The Pubky url (string) to the directory you want to list its content.
|
|
395
|
-
* - `cursor`: Either a full `pubky://` Url (from previous list response),
|
|
396
|
-
* or a path (to a file or directory) relative to the `url`
|
|
397
|
-
* - `reverse`: List in reverse order
|
|
398
|
-
* - `limit` Limit the number of urls in the response
|
|
399
|
-
* - `shallow`: List directories and files, instead of flat list of files.
|
|
400
|
-
* @param {string} url
|
|
401
|
-
* @param {string | null} [cursor]
|
|
402
|
-
* @param {boolean | null} [reverse]
|
|
403
|
-
* @param {number | null} [limit]
|
|
404
|
-
* @param {boolean | null} [shallow]
|
|
405
|
-
* @returns {Promise<Array<any>>}
|
|
406
|
-
*/
|
|
407
|
-
list(url, cursor, reverse, limit, shallow) {
|
|
408
|
-
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
409
|
-
const len0 = WASM_VECTOR_LEN;
|
|
410
|
-
var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
411
|
-
var len1 = WASM_VECTOR_LEN;
|
|
412
|
-
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);
|
|
413
|
-
return ret;
|
|
414
|
-
}
|
|
415
388
|
/**
|
|
416
389
|
* Signup to a homeserver and update Pkarr accordingly.
|
|
417
390
|
*
|
|
@@ -533,15 +506,39 @@ class Client {
|
|
|
533
506
|
const ret = wasm.client_republishHomeserver(this.__wbg_ptr, keypair.__wbg_ptr, host.__wbg_ptr);
|
|
534
507
|
return ret;
|
|
535
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Returns a list of Pubky urls (as strings).
|
|
511
|
+
*
|
|
512
|
+
* - `url`: The Pubky url (string) to the directory you want to list its content.
|
|
513
|
+
* - `cursor`: Either a full `pubky://` Url (from previous list response),
|
|
514
|
+
* or a path (to a file or directory) relative to the `url`
|
|
515
|
+
* - `reverse`: List in reverse order
|
|
516
|
+
* - `limit` Limit the number of urls in the response
|
|
517
|
+
* - `shallow`: List directories and files, instead of flat list of files.
|
|
518
|
+
* @param {string} url
|
|
519
|
+
* @param {string | null} [cursor]
|
|
520
|
+
* @param {boolean | null} [reverse]
|
|
521
|
+
* @param {number | null} [limit]
|
|
522
|
+
* @param {boolean | null} [shallow]
|
|
523
|
+
* @returns {Promise<Array<any>>}
|
|
524
|
+
*/
|
|
525
|
+
list(url, cursor, reverse, limit, shallow) {
|
|
526
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
527
|
+
const len0 = WASM_VECTOR_LEN;
|
|
528
|
+
var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
529
|
+
var len1 = WASM_VECTOR_LEN;
|
|
530
|
+
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);
|
|
531
|
+
return ret;
|
|
532
|
+
}
|
|
536
533
|
/**
|
|
537
534
|
* @param {string} url
|
|
538
|
-
* @param {any | null} [
|
|
535
|
+
* @param {any | null} [init]
|
|
539
536
|
* @returns {Promise<Promise<any>>}
|
|
540
537
|
*/
|
|
541
|
-
fetch(url,
|
|
538
|
+
fetch(url, init) {
|
|
542
539
|
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
543
540
|
const len0 = WASM_VECTOR_LEN;
|
|
544
|
-
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(
|
|
541
|
+
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(init) ? 0 : addToExternrefTable0(init));
|
|
545
542
|
return ret;
|
|
546
543
|
}
|
|
547
544
|
/**
|
|
@@ -559,13 +556,16 @@ class Client {
|
|
|
559
556
|
}
|
|
560
557
|
/**
|
|
561
558
|
* Create a client with with configurations appropriate for local testing:
|
|
562
|
-
* - set Pkarr relays to `
|
|
563
|
-
* - transform `pubky://<pkarr public key>` to `http://<
|
|
564
|
-
*
|
|
559
|
+
* - set Pkarr relays to `http://<host>:15411` (defaults to `localhost`).
|
|
560
|
+
* - transform `pubky://<pkarr public key>` to `http://<host>` instead of `https:`
|
|
561
|
+
* and read the homeserver HTTP port from the PKarr record.
|
|
562
|
+
* @param {string | null} [host]
|
|
565
563
|
* @returns {Client}
|
|
566
564
|
*/
|
|
567
|
-
static testnet() {
|
|
568
|
-
|
|
565
|
+
static testnet(host) {
|
|
566
|
+
var ptr0 = isLikeNone(host) ? 0 : passStringToWasm0(host, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
567
|
+
var len0 = WASM_VECTOR_LEN;
|
|
568
|
+
const ret = wasm.client_testnet(ptr0, len0);
|
|
569
569
|
return Client.__wrap(ret);
|
|
570
570
|
}
|
|
571
571
|
}
|
|
@@ -796,11 +796,6 @@ module.exports.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(fun
|
|
|
796
796
|
return ret;
|
|
797
797
|
}, arguments) };
|
|
798
798
|
|
|
799
|
-
module.exports.__wbg_clearTimeout_5a54f8841c30079a = function(arg0) {
|
|
800
|
-
const ret = clearTimeout(arg0);
|
|
801
|
-
return ret;
|
|
802
|
-
};
|
|
803
|
-
|
|
804
799
|
module.exports.__wbg_clearTimeout_86721db0036bea98 = function(arg0) {
|
|
805
800
|
const ret = clearTimeout(arg0);
|
|
806
801
|
return ret;
|
|
@@ -824,13 +819,13 @@ module.exports.__wbg_error_80de38b3f7cc3c3c = function(arg0, arg1, arg2, arg3) {
|
|
|
824
819
|
console.error(arg0, arg1, arg2, arg3);
|
|
825
820
|
};
|
|
826
821
|
|
|
827
|
-
module.exports.
|
|
828
|
-
const ret = fetch(
|
|
822
|
+
module.exports.__wbg_fetch_509096533071c657 = function(arg0, arg1) {
|
|
823
|
+
const ret = arg0.fetch(arg1);
|
|
829
824
|
return ret;
|
|
830
825
|
};
|
|
831
826
|
|
|
832
|
-
module.exports.
|
|
833
|
-
const ret =
|
|
827
|
+
module.exports.__wbg_fetch_9e120ad639656465 = function(arg0) {
|
|
828
|
+
const ret = fetch(arg0);
|
|
834
829
|
return ret;
|
|
835
830
|
};
|
|
836
831
|
|
|
@@ -852,11 +847,6 @@ module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(func
|
|
|
852
847
|
return ret;
|
|
853
848
|
}, arguments) };
|
|
854
849
|
|
|
855
|
-
module.exports.__wbg_getheaders_8326221cf02f205d = function(arg0) {
|
|
856
|
-
const ret = arg0.headers;
|
|
857
|
-
return ret;
|
|
858
|
-
};
|
|
859
|
-
|
|
860
850
|
module.exports.__wbg_has_a5ea9117f258a0ec = function() { return handleError(function (arg0, arg1) {
|
|
861
851
|
const ret = Reflect.has(arg0, arg1);
|
|
862
852
|
return ret;
|
|
@@ -913,7 +903,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
|
|
|
913
903
|
const a = state0.a;
|
|
914
904
|
state0.a = 0;
|
|
915
905
|
try {
|
|
916
|
-
return
|
|
906
|
+
return __wbg_adapter_74(a, state0.b, arg0, arg1);
|
|
917
907
|
} finally {
|
|
918
908
|
state0.a = a;
|
|
919
909
|
}
|
|
@@ -1033,11 +1023,6 @@ module.exports.__wbg_setTimeout_2e707715f8cc9497 = function(arg0, arg1) {
|
|
|
1033
1023
|
return ret;
|
|
1034
1024
|
};
|
|
1035
1025
|
|
|
1036
|
-
module.exports.__wbg_setTimeout_db2dbaeefb6f39c7 = function() { return handleError(function (arg0, arg1) {
|
|
1037
|
-
const ret = setTimeout(arg0, arg1);
|
|
1038
|
-
return ret;
|
|
1039
|
-
}, arguments) };
|
|
1040
|
-
|
|
1041
1026
|
module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
1042
1027
|
arg0.set(arg1, arg2 >>> 0);
|
|
1043
1028
|
};
|
|
@@ -1153,18 +1138,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
1153
1138
|
return ret;
|
|
1154
1139
|
};
|
|
1155
1140
|
|
|
1156
|
-
module.exports.
|
|
1157
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1141
|
+
module.exports.__wbindgen_closure_wrapper2423 = function(arg0, arg1, arg2) {
|
|
1142
|
+
const ret = makeMutClosure(arg0, arg1, 129, __wbg_adapter_28);
|
|
1158
1143
|
return ret;
|
|
1159
1144
|
};
|
|
1160
1145
|
|
|
1161
|
-
module.exports.
|
|
1162
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1163
|
-
return ret;
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
module.exports.__wbindgen_closure_wrapper3118 = function(arg0, arg1, arg2) {
|
|
1167
|
-
const ret = makeMutClosure(arg0, arg1, 603, __wbg_adapter_36);
|
|
1146
|
+
module.exports.__wbindgen_closure_wrapper2756 = function(arg0, arg1, arg2) {
|
|
1147
|
+
const ret = makeMutClosure(arg0, arg1, 129, __wbg_adapter_31);
|
|
1168
1148
|
return ret;
|
|
1169
1149
|
};
|
|
1170
1150
|
|
|
@@ -1192,11 +1172,6 @@ module.exports.__wbindgen_is_function = function(arg0) {
|
|
|
1192
1172
|
return ret;
|
|
1193
1173
|
};
|
|
1194
1174
|
|
|
1195
|
-
module.exports.__wbindgen_is_null = function(arg0) {
|
|
1196
|
-
const ret = arg0 === null;
|
|
1197
|
-
return ret;
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
1175
|
module.exports.__wbindgen_is_object = function(arg0) {
|
|
1201
1176
|
const val = arg0;
|
|
1202
1177
|
const ret = typeof(val) === 'object' && val !== null;
|