@synonymdev/pubky 0.5.0-rc.1 → 0.5.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 +101 -95
- package/index.js +107 -103
- package/package.json +1 -1
- package/pubky.d.ts +51 -16
- package/pubky_bg.wasm +0 -0
package/index.cjs
CHANGED
|
@@ -212,6 +212,23 @@ 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
|
+
|
|
215
232
|
function _assertClass(instance, klass) {
|
|
216
233
|
if (!(instance instanceof klass)) {
|
|
217
234
|
throw new Error(`expected instance of ${klass.name}`);
|
|
@@ -238,12 +255,6 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
238
255
|
WASM_VECTOR_LEN = arg.length;
|
|
239
256
|
return ptr;
|
|
240
257
|
}
|
|
241
|
-
|
|
242
|
-
function takeFromExternrefTable0(idx) {
|
|
243
|
-
const value = wasm.__wbindgen_export_2.get(idx);
|
|
244
|
-
wasm.__externref_table_dealloc(idx);
|
|
245
|
-
return value;
|
|
246
|
-
}
|
|
247
258
|
/**
|
|
248
259
|
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
249
260
|
* using the `passphrase`.
|
|
@@ -263,18 +274,6 @@ module.exports.decryptRecoveryFile = function(recovery_file, passphrase) {
|
|
|
263
274
|
return Keypair.__wrap(ret[0]);
|
|
264
275
|
};
|
|
265
276
|
|
|
266
|
-
/**
|
|
267
|
-
* @param {string} level
|
|
268
|
-
*/
|
|
269
|
-
module.exports.setLogLevel = function(level) {
|
|
270
|
-
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
271
|
-
const len0 = WASM_VECTOR_LEN;
|
|
272
|
-
const ret = wasm.setLogLevel(ptr0, len0);
|
|
273
|
-
if (ret[1]) {
|
|
274
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
277
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
279
278
|
ptr = ptr >>> 0;
|
|
280
279
|
const mem = getDataViewMemory0();
|
|
@@ -286,19 +285,19 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
286
285
|
return result;
|
|
287
286
|
}
|
|
288
287
|
function __wbg_adapter_30(arg0, arg1) {
|
|
289
|
-
wasm.
|
|
288
|
+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h457b2f02283a1dc1(arg0, arg1);
|
|
290
289
|
}
|
|
291
290
|
|
|
292
291
|
function __wbg_adapter_33(arg0, arg1) {
|
|
293
|
-
wasm.
|
|
292
|
+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb951c8f299470c3c(arg0, arg1);
|
|
294
293
|
}
|
|
295
294
|
|
|
296
295
|
function __wbg_adapter_36(arg0, arg1, arg2) {
|
|
297
|
-
wasm.
|
|
296
|
+
wasm.closure602_externref_shim(arg0, arg1, arg2);
|
|
298
297
|
}
|
|
299
298
|
|
|
300
|
-
function
|
|
301
|
-
wasm.
|
|
299
|
+
function __wbg_adapter_178(arg0, arg1, arg2, arg3) {
|
|
300
|
+
wasm.closure622_externref_shim(arg0, arg1, arg2, arg3);
|
|
302
301
|
}
|
|
303
302
|
|
|
304
303
|
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -389,6 +388,30 @@ class Client {
|
|
|
389
388
|
const ptr = this.__destroy_into_raw();
|
|
390
389
|
wasm.__wbg_client_free(ptr, 0);
|
|
391
390
|
}
|
|
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
|
+
}
|
|
392
415
|
/**
|
|
393
416
|
* Signup to a homeserver and update Pkarr accordingly.
|
|
394
417
|
*
|
|
@@ -511,11 +534,26 @@ class Client {
|
|
|
511
534
|
return ret;
|
|
512
535
|
}
|
|
513
536
|
/**
|
|
514
|
-
*
|
|
537
|
+
* @param {string} url
|
|
538
|
+
* @param {any | null} [request_init]
|
|
539
|
+
* @returns {Promise<Promise<any>>}
|
|
540
|
+
*/
|
|
541
|
+
fetch(url, request_init) {
|
|
542
|
+
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
543
|
+
const len0 = WASM_VECTOR_LEN;
|
|
544
|
+
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(request_init) ? 0 : addToExternrefTable0(request_init));
|
|
545
|
+
return ret;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Create a new Pubky Client with an optional configuration.
|
|
549
|
+
* @param {PubkyClientConfig | null} [config_opt]
|
|
515
550
|
*/
|
|
516
|
-
constructor() {
|
|
517
|
-
const ret = wasm.client_new();
|
|
518
|
-
|
|
551
|
+
constructor(config_opt) {
|
|
552
|
+
const ret = wasm.client_new(isLikeNone(config_opt) ? 0 : addToExternrefTable0(config_opt));
|
|
553
|
+
if (ret[2]) {
|
|
554
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
555
|
+
}
|
|
556
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
519
557
|
ClientFinalization.register(this, this.__wbg_ptr, this);
|
|
520
558
|
return this;
|
|
521
559
|
}
|
|
@@ -530,41 +568,6 @@ class Client {
|
|
|
530
568
|
const ret = wasm.client_testnet();
|
|
531
569
|
return Client.__wrap(ret);
|
|
532
570
|
}
|
|
533
|
-
/**
|
|
534
|
-
* @param {string} url
|
|
535
|
-
* @param {any | null} [request_init]
|
|
536
|
-
* @returns {Promise<Promise<any>>}
|
|
537
|
-
*/
|
|
538
|
-
fetch(url, request_init) {
|
|
539
|
-
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
540
|
-
const len0 = WASM_VECTOR_LEN;
|
|
541
|
-
const ret = wasm.client_fetch(this.__wbg_ptr, ptr0, len0, isLikeNone(request_init) ? 0 : addToExternrefTable0(request_init));
|
|
542
|
-
return ret;
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Returns a list of Pubky urls (as strings).
|
|
546
|
-
*
|
|
547
|
-
* - `url`: The Pubky url (string) to the directory you want to list its content.
|
|
548
|
-
* - `cursor`: Either a full `pubky://` Url (from previous list response),
|
|
549
|
-
* or a path (to a file or directory) relative to the `url`
|
|
550
|
-
* - `reverse`: List in reverse order
|
|
551
|
-
* - `limit` Limit the number of urls in the response
|
|
552
|
-
* - `shallow`: List directories and files, instead of flat list of files.
|
|
553
|
-
* @param {string} url
|
|
554
|
-
* @param {string | null} [cursor]
|
|
555
|
-
* @param {boolean | null} [reverse]
|
|
556
|
-
* @param {number | null} [limit]
|
|
557
|
-
* @param {boolean | null} [shallow]
|
|
558
|
-
* @returns {Promise<Array<any>>}
|
|
559
|
-
*/
|
|
560
|
-
list(url, cursor, reverse, limit, shallow) {
|
|
561
|
-
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
562
|
-
const len0 = WASM_VECTOR_LEN;
|
|
563
|
-
var ptr1 = isLikeNone(cursor) ? 0 : passStringToWasm0(cursor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
564
|
-
var len1 = WASM_VECTOR_LEN;
|
|
565
|
-
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);
|
|
566
|
-
return ret;
|
|
567
|
-
}
|
|
568
571
|
}
|
|
569
572
|
module.exports.Client = Client;
|
|
570
573
|
|
|
@@ -607,7 +610,9 @@ class Keypair {
|
|
|
607
610
|
* @returns {Keypair}
|
|
608
611
|
*/
|
|
609
612
|
static fromSecretKey(secret_key) {
|
|
610
|
-
const
|
|
613
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
614
|
+
const len0 = WASM_VECTOR_LEN;
|
|
615
|
+
const ret = wasm.keypair_fromSecretKey(ptr0, len0);
|
|
611
616
|
if (ret[2]) {
|
|
612
617
|
throw takeFromExternrefTable0(ret[1]);
|
|
613
618
|
}
|
|
@@ -619,7 +624,9 @@ class Keypair {
|
|
|
619
624
|
*/
|
|
620
625
|
secretKey() {
|
|
621
626
|
const ret = wasm.keypair_secretKey(this.__wbg_ptr);
|
|
622
|
-
|
|
627
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
628
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
629
|
+
return v1;
|
|
623
630
|
}
|
|
624
631
|
/**
|
|
625
632
|
* Returns the [PublicKey] of this keypair.
|
|
@@ -659,11 +666,24 @@ class PublicKey {
|
|
|
659
666
|
}
|
|
660
667
|
/**
|
|
661
668
|
* Convert the PublicKey to Uint8Array
|
|
669
|
+
* @deprecated Use `toUint8Array` instead
|
|
662
670
|
* @returns {Uint8Array}
|
|
663
671
|
*/
|
|
664
672
|
to_uint8array() {
|
|
665
673
|
const ret = wasm.publickey_to_uint8array(this.__wbg_ptr);
|
|
666
|
-
|
|
674
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
675
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
676
|
+
return v1;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Convert the PublicKey to Uint8Array
|
|
680
|
+
* @returns {Uint8Array}
|
|
681
|
+
*/
|
|
682
|
+
toUint8Array() {
|
|
683
|
+
const ret = wasm.publickey_toUint8Array(this.__wbg_ptr);
|
|
684
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
685
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
686
|
+
return v1;
|
|
667
687
|
}
|
|
668
688
|
/**
|
|
669
689
|
* Returns the z-base32 encoding of this public key
|
|
@@ -683,11 +703,13 @@ class PublicKey {
|
|
|
683
703
|
}
|
|
684
704
|
/**
|
|
685
705
|
* @throws
|
|
686
|
-
* @param {
|
|
706
|
+
* @param {string} value
|
|
687
707
|
* @returns {PublicKey}
|
|
688
708
|
*/
|
|
689
709
|
static from(value) {
|
|
690
|
-
const
|
|
710
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
711
|
+
const len0 = WASM_VECTOR_LEN;
|
|
712
|
+
const ret = wasm.publickey_from(ptr0, len0);
|
|
691
713
|
if (ret[2]) {
|
|
692
714
|
throw takeFromExternrefTable0(ret[1]);
|
|
693
715
|
}
|
|
@@ -764,11 +786,6 @@ module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
|
764
786
|
return ret;
|
|
765
787
|
};
|
|
766
788
|
|
|
767
|
-
module.exports.__wbg_byteLength_e674b853d9c77e1d = function(arg0) {
|
|
768
|
-
const ret = arg0.byteLength;
|
|
769
|
-
return ret;
|
|
770
|
-
};
|
|
771
|
-
|
|
772
789
|
module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
773
790
|
const ret = arg0.call(arg1);
|
|
774
791
|
return ret;
|
|
@@ -807,17 +824,17 @@ module.exports.__wbg_error_80de38b3f7cc3c3c = function(arg0, arg1, arg2, arg3) {
|
|
|
807
824
|
console.error(arg0, arg1, arg2, arg3);
|
|
808
825
|
};
|
|
809
826
|
|
|
810
|
-
module.exports.
|
|
811
|
-
const ret =
|
|
827
|
+
module.exports.__wbg_fetch_00edbc0718dc5567 = function(arg0) {
|
|
828
|
+
const ret = fetch(arg0);
|
|
812
829
|
return ret;
|
|
813
830
|
};
|
|
814
831
|
|
|
815
|
-
module.exports.
|
|
816
|
-
const ret = fetch(
|
|
832
|
+
module.exports.__wbg_fetch_509096533071c657 = function(arg0, arg1) {
|
|
833
|
+
const ret = arg0.fetch(arg1);
|
|
817
834
|
return ret;
|
|
818
835
|
};
|
|
819
836
|
|
|
820
|
-
module.exports.
|
|
837
|
+
module.exports.__wbg_fetch_d36a73832f0a45e8 = function(arg0) {
|
|
821
838
|
const ret = fetch(arg0);
|
|
822
839
|
return ret;
|
|
823
840
|
};
|
|
@@ -865,17 +882,6 @@ module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function(arg0) {
|
|
|
865
882
|
return ret;
|
|
866
883
|
};
|
|
867
884
|
|
|
868
|
-
module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(arg0) {
|
|
869
|
-
let result;
|
|
870
|
-
try {
|
|
871
|
-
result = arg0 instanceof Uint8Array;
|
|
872
|
-
} catch (_) {
|
|
873
|
-
result = false;
|
|
874
|
-
}
|
|
875
|
-
const ret = result;
|
|
876
|
-
return ret;
|
|
877
|
-
};
|
|
878
|
-
|
|
879
885
|
module.exports.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
880
886
|
const ret = Symbol.iterator;
|
|
881
887
|
return ret;
|
|
@@ -907,7 +913,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
|
|
|
907
913
|
const a = state0.a;
|
|
908
914
|
state0.a = 0;
|
|
909
915
|
try {
|
|
910
|
-
return
|
|
916
|
+
return __wbg_adapter_178(a, state0.b, arg0, arg1);
|
|
911
917
|
} finally {
|
|
912
918
|
state0.a = a;
|
|
913
919
|
}
|
|
@@ -1147,18 +1153,18 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
1147
1153
|
return ret;
|
|
1148
1154
|
};
|
|
1149
1155
|
|
|
1150
|
-
module.exports.
|
|
1151
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1156
|
+
module.exports.__wbindgen_closure_wrapper1056 = function(arg0, arg1, arg2) {
|
|
1157
|
+
const ret = makeMutClosure(arg0, arg1, 292, __wbg_adapter_30);
|
|
1152
1158
|
return ret;
|
|
1153
1159
|
};
|
|
1154
1160
|
|
|
1155
|
-
module.exports.
|
|
1156
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1161
|
+
module.exports.__wbindgen_closure_wrapper2891 = function(arg0, arg1, arg2) {
|
|
1162
|
+
const ret = makeMutClosure(arg0, arg1, 565, __wbg_adapter_33);
|
|
1157
1163
|
return ret;
|
|
1158
1164
|
};
|
|
1159
1165
|
|
|
1160
|
-
module.exports.
|
|
1161
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1166
|
+
module.exports.__wbindgen_closure_wrapper3118 = function(arg0, arg1, arg2) {
|
|
1167
|
+
const ret = makeMutClosure(arg0, arg1, 603, __wbg_adapter_36);
|
|
1162
1168
|
return ret;
|
|
1163
1169
|
};
|
|
1164
1170
|
|