@synonymdev/pubky 0.1.8 → 0.1.10
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/README.md +110 -0
- package/browser.js +82 -23
- package/{nodejs/pubky.js → index.cjs} +81 -22
- package/package.json +6 -8
- package/{nodejs/pubky.d.ts → pubky.d.ts} +26 -5
- package/{nodejs/pubky_bg.wasm → pubky_bg.wasm} +0 -0
- package/index.js +0 -1
- package/nodejs/pubky_bg.wasm.d.ts +0 -32
|
@@ -218,6 +218,20 @@ function __wbg_adapter_26(arg0, arg1, arg2) {
|
|
|
218
218
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha5424c6cb7b1ff0d(arg0, arg1, addHeapObject(arg2));
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
function _assertClass(instance, klass) {
|
|
222
|
+
if (!(instance instanceof klass)) {
|
|
223
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
224
|
+
}
|
|
225
|
+
return instance.ptr;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
229
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
230
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
231
|
+
WASM_VECTOR_LEN = arg.length;
|
|
232
|
+
return ptr;
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
let cachedUint32Memory0 = null;
|
|
222
236
|
|
|
223
237
|
function getUint32Memory0() {
|
|
@@ -248,20 +262,6 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
248
262
|
return result;
|
|
249
263
|
}
|
|
250
264
|
|
|
251
|
-
function _assertClass(instance, klass) {
|
|
252
|
-
if (!(instance instanceof klass)) {
|
|
253
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
254
|
-
}
|
|
255
|
-
return instance.ptr;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
259
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
260
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
261
|
-
WASM_VECTOR_LEN = arg.length;
|
|
262
|
-
return ptr;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
265
|
function handleError(f, args) {
|
|
266
266
|
try {
|
|
267
267
|
return f.apply(this, args);
|
|
@@ -269,7 +269,7 @@ function handleError(f, args) {
|
|
|
269
269
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function __wbg_adapter_117(arg0, arg1, arg2, arg3) {
|
|
273
273
|
wasm.wasm_bindgen__convert__closures__invoke2_mut__hcef77123246c6bdb(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
274
274
|
}
|
|
275
275
|
|
|
@@ -312,11 +312,19 @@ class Keypair {
|
|
|
312
312
|
* @param {Uint8Array} secret_key
|
|
313
313
|
* @returns {Keypair}
|
|
314
314
|
*/
|
|
315
|
-
static
|
|
316
|
-
const ret = wasm.
|
|
315
|
+
static fromSecretKey(secret_key) {
|
|
316
|
+
const ret = wasm.keypair_fromSecretKey(addHeapObject(secret_key));
|
|
317
317
|
return Keypair.__wrap(ret);
|
|
318
318
|
}
|
|
319
319
|
/**
|
|
320
|
+
* Returns the secret key of this keypair.
|
|
321
|
+
* @returns {Uint8Array}
|
|
322
|
+
*/
|
|
323
|
+
secretKey() {
|
|
324
|
+
const ret = wasm.keypair_secretKey(this.__wbg_ptr);
|
|
325
|
+
return takeObject(ret);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
320
328
|
* Returns the [PublicKey] of this keypair.
|
|
321
329
|
* @returns {PublicKey}
|
|
322
330
|
*/
|
|
@@ -370,10 +378,61 @@ class PubkyClient {
|
|
|
370
378
|
return PubkyClient.__wrap(ret);
|
|
371
379
|
}
|
|
372
380
|
/**
|
|
381
|
+
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
382
|
+
* using the `passphrase`.
|
|
383
|
+
* @param {Keypair} keypair
|
|
384
|
+
* @param {string} passphrase
|
|
385
|
+
* @returns {Uint8Array}
|
|
386
|
+
*/
|
|
387
|
+
static createRecoveryFile(keypair, passphrase) {
|
|
388
|
+
try {
|
|
389
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
390
|
+
_assertClass(keypair, Keypair);
|
|
391
|
+
const ptr0 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
392
|
+
const len0 = WASM_VECTOR_LEN;
|
|
393
|
+
wasm.pubkyclient_createRecoveryFile(retptr, keypair.__wbg_ptr, ptr0, len0);
|
|
394
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
395
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
396
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
397
|
+
if (r2) {
|
|
398
|
+
throw takeObject(r1);
|
|
399
|
+
}
|
|
400
|
+
return takeObject(r0);
|
|
401
|
+
} finally {
|
|
402
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
407
|
+
* using the `passphrase`.
|
|
408
|
+
* @param {Uint8Array} recovery_file
|
|
409
|
+
* @param {string} passphrase
|
|
410
|
+
* @returns {Keypair}
|
|
411
|
+
*/
|
|
412
|
+
static decryptRecoveryFile(recovery_file, passphrase) {
|
|
413
|
+
try {
|
|
414
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
415
|
+
const ptr0 = passArray8ToWasm0(recovery_file, wasm.__wbindgen_malloc);
|
|
416
|
+
const len0 = WASM_VECTOR_LEN;
|
|
417
|
+
const ptr1 = passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
418
|
+
const len1 = WASM_VECTOR_LEN;
|
|
419
|
+
wasm.pubkyclient_decryptRecoveryFile(retptr, ptr0, len0, ptr1, len1);
|
|
420
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
421
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
422
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
423
|
+
if (r2) {
|
|
424
|
+
throw takeObject(r1);
|
|
425
|
+
}
|
|
426
|
+
return Keypair.__wrap(r0);
|
|
427
|
+
} finally {
|
|
428
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
373
432
|
* Set Pkarr relays used for publishing and resolving Pkarr packets.
|
|
374
433
|
*
|
|
375
434
|
* By default, [PubkyClient] will use `["https://relay.pkarr.org"]`
|
|
376
|
-
* @param {
|
|
435
|
+
* @param {(string)[]} relays
|
|
377
436
|
* @returns {PubkyClient}
|
|
378
437
|
*/
|
|
379
438
|
setPkarrRelays(relays) {
|
|
@@ -384,7 +443,7 @@ class PubkyClient {
|
|
|
384
443
|
return PubkyClient.__wrap(ret);
|
|
385
444
|
}
|
|
386
445
|
/**
|
|
387
|
-
* @returns {
|
|
446
|
+
* @returns {(string)[]}
|
|
388
447
|
*/
|
|
389
448
|
getPkarrRelays() {
|
|
390
449
|
try {
|
|
@@ -852,7 +911,7 @@ module.exports.__wbg_new_81740750da40724f = function(arg0, arg1) {
|
|
|
852
911
|
const a = state0.a;
|
|
853
912
|
state0.a = 0;
|
|
854
913
|
try {
|
|
855
|
-
return
|
|
914
|
+
return __wbg_adapter_117(a, state0.b, arg0, arg1);
|
|
856
915
|
} finally {
|
|
857
916
|
state0.a = a;
|
|
858
917
|
}
|
|
@@ -950,8 +1009,8 @@ module.exports.__wbindgen_memory = function() {
|
|
|
950
1009
|
return addHeapObject(ret);
|
|
951
1010
|
};
|
|
952
1011
|
|
|
953
|
-
module.exports.
|
|
954
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1012
|
+
module.exports.__wbindgen_closure_wrapper1744 = function(arg0, arg1, arg2) {
|
|
1013
|
+
const ret = makeMutClosure(arg0, arg1, 291, __wbg_adapter_26);
|
|
955
1014
|
return addHeapObject(ret);
|
|
956
1015
|
};
|
|
957
1016
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@synonymdev/pubky",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Pubky client",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.10",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -17,16 +17,14 @@
|
|
|
17
17
|
"prepublishOnly": "npm run build && npm run test"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"
|
|
21
|
-
"nodejs/pubky.js",
|
|
22
|
-
"nodejs/pubky.d.ts",
|
|
23
|
-
"nodejs/pubky_bg.wasm.d.ts",
|
|
20
|
+
"index.cjs",
|
|
24
21
|
"browser.js",
|
|
25
|
-
"
|
|
22
|
+
"pubky.d.ts",
|
|
23
|
+
"pubky_bg.wasm"
|
|
26
24
|
],
|
|
27
|
-
"main": "index.
|
|
25
|
+
"main": "index.cjs",
|
|
28
26
|
"browser": "browser.js",
|
|
29
|
-
"types": "
|
|
27
|
+
"types": "pubky.d.ts",
|
|
30
28
|
"keywords": [
|
|
31
29
|
"web",
|
|
32
30
|
"dht",
|
|
@@ -14,7 +14,12 @@ export class Keypair {
|
|
|
14
14
|
* @param {Uint8Array} secret_key
|
|
15
15
|
* @returns {Keypair}
|
|
16
16
|
*/
|
|
17
|
-
static
|
|
17
|
+
static fromSecretKey(secret_key: Uint8Array): Keypair;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the secret key of this keypair.
|
|
20
|
+
* @returns {Uint8Array}
|
|
21
|
+
*/
|
|
22
|
+
secretKey(): Uint8Array;
|
|
18
23
|
/**
|
|
19
24
|
* Returns the [PublicKey] of this keypair.
|
|
20
25
|
* @returns {PublicKey}
|
|
@@ -35,17 +40,33 @@ export class PubkyClient {
|
|
|
35
40
|
*/
|
|
36
41
|
static testnet(): PubkyClient;
|
|
37
42
|
/**
|
|
43
|
+
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
44
|
+
* using the `passphrase`.
|
|
45
|
+
* @param {Keypair} keypair
|
|
46
|
+
* @param {string} passphrase
|
|
47
|
+
* @returns {Uint8Array}
|
|
48
|
+
*/
|
|
49
|
+
static createRecoveryFile(keypair: Keypair, passphrase: string): Uint8Array;
|
|
50
|
+
/**
|
|
51
|
+
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
52
|
+
* using the `passphrase`.
|
|
53
|
+
* @param {Uint8Array} recovery_file
|
|
54
|
+
* @param {string} passphrase
|
|
55
|
+
* @returns {Keypair}
|
|
56
|
+
*/
|
|
57
|
+
static decryptRecoveryFile(recovery_file: Uint8Array, passphrase: string): Keypair;
|
|
58
|
+
/**
|
|
38
59
|
* Set Pkarr relays used for publishing and resolving Pkarr packets.
|
|
39
60
|
*
|
|
40
61
|
* By default, [PubkyClient] will use `["https://relay.pkarr.org"]`
|
|
41
|
-
* @param {
|
|
62
|
+
* @param {(string)[]} relays
|
|
42
63
|
* @returns {PubkyClient}
|
|
43
64
|
*/
|
|
44
|
-
setPkarrRelays(relays:
|
|
65
|
+
setPkarrRelays(relays: (string)[]): PubkyClient;
|
|
45
66
|
/**
|
|
46
|
-
* @returns {
|
|
67
|
+
* @returns {(string)[]}
|
|
47
68
|
*/
|
|
48
|
-
getPkarrRelays():
|
|
69
|
+
getPkarrRelays(): (string)[];
|
|
49
70
|
/**
|
|
50
71
|
* Signup to a homeserver and update Pkarr accordingly.
|
|
51
72
|
*
|
|
Binary file
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './nodejs/pubky.js'
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export function __wbg_pubkyclient_free(a: number): void;
|
|
5
|
-
export function __wbg_session_free(a: number): void;
|
|
6
|
-
export function pubkyclient_new(): number;
|
|
7
|
-
export function pubkyclient_testnet(): number;
|
|
8
|
-
export function pubkyclient_setPkarrRelays(a: number, b: number, c: number): number;
|
|
9
|
-
export function pubkyclient_getPkarrRelays(a: number, b: number): void;
|
|
10
|
-
export function pubkyclient_signup(a: number, b: number, c: number): number;
|
|
11
|
-
export function pubkyclient_session(a: number, b: number): number;
|
|
12
|
-
export function pubkyclient_signout(a: number, b: number): number;
|
|
13
|
-
export function pubkyclient_signin(a: number, b: number): number;
|
|
14
|
-
export function pubkyclient_put(a: number, b: number, c: number, d: number, e: number): number;
|
|
15
|
-
export function pubkyclient_get(a: number, b: number, c: number): number;
|
|
16
|
-
export function pubkyclient_delete(a: number, b: number, c: number): number;
|
|
17
|
-
export function __wbg_keypair_free(a: number): void;
|
|
18
|
-
export function keypair_random(): number;
|
|
19
|
-
export function keypair_from_secret_key(a: number): number;
|
|
20
|
-
export function keypair_publicKey(a: number): number;
|
|
21
|
-
export function __wbg_publickey_free(a: number): void;
|
|
22
|
-
export function publickey_to_uint8array(a: number): number;
|
|
23
|
-
export function publickey_z32(a: number, b: number): void;
|
|
24
|
-
export function publickey_from(a: number, b: number): void;
|
|
25
|
-
export function __wbindgen_malloc(a: number, b: number): number;
|
|
26
|
-
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
27
|
-
export const __wbindgen_export_2: WebAssembly.Table;
|
|
28
|
-
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha5424c6cb7b1ff0d(a: number, b: number, c: number): void;
|
|
29
|
-
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
30
|
-
export function __wbindgen_free(a: number, b: number, c: number): void;
|
|
31
|
-
export function __wbindgen_exn_store(a: number): void;
|
|
32
|
-
export function wasm_bindgen__convert__closures__invoke2_mut__hcef77123246c6bdb(a: number, b: number, c: number, d: number): void;
|