@synonymdev/pubky 0.2.0 → 0.4.0-rc1
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 +24 -36
- package/index.cjs +1161 -1
- package/index.js +1267 -0
- package/package.json +5 -5
- package/pubky.d.ts +34 -96
- package/pubky_bg.wasm +0 -0
- package/browser.js +0 -1244
package/package.json
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"name": "@synonymdev/pubky",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Pubky client",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.4.0-rc1",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/pubky/pubky"
|
|
9
|
+
"url": "git+https://github.com/pubky/pubky-core.git"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"testnet": "cargo run -p
|
|
12
|
+
"testnet": "cargo run -p pubky-homeserver -- --testnet",
|
|
13
13
|
"test": "npm run test-nodejs && npm run test-browser",
|
|
14
14
|
"test-nodejs": "tape test/*.js -cov",
|
|
15
15
|
"test-browser": "browserify test/*.js -p esmify | npx tape-run",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"index.cjs",
|
|
21
|
-
"
|
|
21
|
+
"index.js",
|
|
22
22
|
"pubky.d.ts",
|
|
23
23
|
"pubky_bg.wasm"
|
|
24
24
|
],
|
|
25
25
|
"main": "index.cjs",
|
|
26
|
-
"browser": "
|
|
26
|
+
"browser": "index.js",
|
|
27
27
|
"types": "pubky.d.ts",
|
|
28
28
|
"keywords": [
|
|
29
29
|
"web",
|
package/pubky.d.ts
CHANGED
|
@@ -3,75 +3,24 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
5
5
|
* using the `passphrase`.
|
|
6
|
-
* @param {Keypair} keypair
|
|
7
|
-
* @param {string} passphrase
|
|
8
|
-
* @returns {Uint8Array}
|
|
9
6
|
*/
|
|
10
7
|
export function createRecoveryFile(keypair: Keypair, passphrase: string): Uint8Array;
|
|
11
8
|
/**
|
|
12
9
|
* Create a recovery file of the `keypair`, containing the secret key encrypted
|
|
13
10
|
* using the `passphrase`.
|
|
14
|
-
* @param {Uint8Array} recovery_file
|
|
15
|
-
* @param {string} passphrase
|
|
16
|
-
* @returns {Keypair}
|
|
17
11
|
*/
|
|
18
12
|
export function decryptRecoveryFile(recovery_file: Uint8Array, passphrase: string): Keypair;
|
|
19
|
-
export
|
|
20
|
-
free(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Generate a random [Keypair]
|
|
23
|
-
* @returns {Keypair}
|
|
24
|
-
*/
|
|
25
|
-
static random(): Keypair;
|
|
26
|
-
/**
|
|
27
|
-
* Generate a [Keypair] from a secret key.
|
|
28
|
-
* @param {Uint8Array} secret_key
|
|
29
|
-
* @returns {Keypair}
|
|
30
|
-
*/
|
|
31
|
-
static fromSecretKey(secret_key: Uint8Array): Keypair;
|
|
32
|
-
/**
|
|
33
|
-
* Returns the secret key of this keypair.
|
|
34
|
-
* @returns {Uint8Array}
|
|
35
|
-
*/
|
|
36
|
-
secretKey(): Uint8Array;
|
|
37
|
-
/**
|
|
38
|
-
* Returns the [PublicKey] of this keypair.
|
|
39
|
-
* @returns {PublicKey}
|
|
40
|
-
*/
|
|
41
|
-
publicKey(): PublicKey;
|
|
42
|
-
}
|
|
13
|
+
export function setLogLevel(level: string): void;
|
|
43
14
|
/**
|
|
44
15
|
* A client for Pubky homeserver API, as well as generic HTTP requests to Pubky urls.
|
|
45
16
|
*/
|
|
46
|
-
export class
|
|
17
|
+
export class Client {
|
|
47
18
|
free(): void;
|
|
48
|
-
constructor();
|
|
49
|
-
/**
|
|
50
|
-
* Create a client with with configurations appropriate for local testing:
|
|
51
|
-
* - set Pkarr relays to `["http://localhost:15411/pkarr"]` instead of default relay.
|
|
52
|
-
* @returns {PubkyClient}
|
|
53
|
-
*/
|
|
54
|
-
static testnet(): PubkyClient;
|
|
55
|
-
/**
|
|
56
|
-
* Set Pkarr relays used for publishing and resolving Pkarr packets.
|
|
57
|
-
*
|
|
58
|
-
* By default, [PubkyClient] will use `["https://relay.pkarr.org"]`
|
|
59
|
-
* @param {(string)[]} relays
|
|
60
|
-
* @returns {PubkyClient}
|
|
61
|
-
*/
|
|
62
|
-
setPkarrRelays(relays: (string)[]): PubkyClient;
|
|
63
|
-
/**
|
|
64
|
-
* @returns {(string)[]}
|
|
65
|
-
*/
|
|
66
|
-
getPkarrRelays(): (string)[];
|
|
67
19
|
/**
|
|
68
20
|
* Signup to a homeserver and update Pkarr accordingly.
|
|
69
21
|
*
|
|
70
22
|
* The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
|
|
71
23
|
* for example "pubky.o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy"
|
|
72
|
-
* @param {Keypair} keypair
|
|
73
|
-
* @param {PublicKey} homeserver
|
|
74
|
-
* @returns {Promise<Session>}
|
|
75
24
|
*/
|
|
76
25
|
signup(keypair: Keypair, homeserver: PublicKey): Promise<Session>;
|
|
77
26
|
/**
|
|
@@ -79,20 +28,14 @@ export class PubkyClient {
|
|
|
79
28
|
*
|
|
80
29
|
* Returns [Session] or `None` (if recieved `404 NOT_FOUND`),
|
|
81
30
|
* or throws the recieved error if the response has any other `>=400` status code.
|
|
82
|
-
* @param {PublicKey} pubky
|
|
83
|
-
* @returns {Promise<Session | undefined>}
|
|
84
31
|
*/
|
|
85
32
|
session(pubky: PublicKey): Promise<Session | undefined>;
|
|
86
33
|
/**
|
|
87
34
|
* Signout from a homeserver.
|
|
88
|
-
* @param {PublicKey} pubky
|
|
89
|
-
* @returns {Promise<void>}
|
|
90
35
|
*/
|
|
91
36
|
signout(pubky: PublicKey): Promise<void>;
|
|
92
37
|
/**
|
|
93
38
|
* Signin to a homeserver using the root Keypair.
|
|
94
|
-
* @param {Keypair} keypair
|
|
95
|
-
* @returns {Promise<void>}
|
|
96
39
|
*/
|
|
97
40
|
signin(keypair: Keypair): Promise<void>;
|
|
98
41
|
/**
|
|
@@ -101,38 +44,13 @@ export class PubkyClient {
|
|
|
101
44
|
* the Pubky's homeserver and returning the [Session] information.
|
|
102
45
|
*
|
|
103
46
|
* Returns a tuple of [pubkyAuthUrl, Promise<Session>]
|
|
104
|
-
* @param {string} relay
|
|
105
|
-
* @param {string} capabilities
|
|
106
|
-
* @returns {Array<any>}
|
|
107
47
|
*/
|
|
108
48
|
authRequest(relay: string, capabilities: string): Array<any>;
|
|
109
49
|
/**
|
|
110
50
|
* Sign an [pubky_common::auth::AuthToken], encrypt it and send it to the
|
|
111
51
|
* source of the pubkyauth request url.
|
|
112
|
-
* @param {Keypair} keypair
|
|
113
|
-
* @param {string} pubkyauth_url
|
|
114
|
-
* @returns {Promise<void>}
|
|
115
52
|
*/
|
|
116
53
|
sendAuthToken(keypair: Keypair, pubkyauth_url: string): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Upload a small payload to a given path.
|
|
119
|
-
* @param {string} url
|
|
120
|
-
* @param {Uint8Array} content
|
|
121
|
-
* @returns {Promise<void>}
|
|
122
|
-
*/
|
|
123
|
-
put(url: string, content: Uint8Array): Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Download a small payload from a given path relative to a pubky author.
|
|
126
|
-
* @param {string} url
|
|
127
|
-
* @returns {Promise<Uint8Array | undefined>}
|
|
128
|
-
*/
|
|
129
|
-
get(url: string): Promise<Uint8Array | undefined>;
|
|
130
|
-
/**
|
|
131
|
-
* Delete a file at a path relative to a pubky author.
|
|
132
|
-
* @param {string} url
|
|
133
|
-
* @returns {Promise<void>}
|
|
134
|
-
*/
|
|
135
|
-
delete(url: string): Promise<void>;
|
|
136
54
|
/**
|
|
137
55
|
* Returns a list of Pubky urls (as strings).
|
|
138
56
|
*
|
|
@@ -142,44 +60,64 @@ export class PubkyClient {
|
|
|
142
60
|
* - `reverse`: List in reverse order
|
|
143
61
|
* - `limit` Limit the number of urls in the response
|
|
144
62
|
* - `shallow`: List directories and files, instead of flat list of files.
|
|
145
|
-
* @param {string} url
|
|
146
|
-
* @param {string | undefined} [cursor]
|
|
147
|
-
* @param {boolean | undefined} [reverse]
|
|
148
|
-
* @param {number | undefined} [limit]
|
|
149
|
-
* @param {boolean | undefined} [shallow]
|
|
150
|
-
* @returns {Promise<Array<any>>}
|
|
151
63
|
*/
|
|
152
64
|
list(url: string, cursor?: string, reverse?: boolean, limit?: number, shallow?: boolean): Promise<Array<any>>;
|
|
65
|
+
fetch(url: string, request_init?: any): Promise<Promise<any>>;
|
|
66
|
+
/**
|
|
67
|
+
* Create Client with default Settings including default relays
|
|
68
|
+
*/
|
|
69
|
+
constructor();
|
|
70
|
+
/**
|
|
71
|
+
* Create a client with with configurations appropriate for local testing:
|
|
72
|
+
* - set Pkarr relays to `["http://localhost:15411"]` instead of default relay.
|
|
73
|
+
*/
|
|
74
|
+
static testnet(): Client;
|
|
75
|
+
}
|
|
76
|
+
export class Keypair {
|
|
77
|
+
private constructor();
|
|
78
|
+
free(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Generate a random [Keypair]
|
|
81
|
+
*/
|
|
82
|
+
static random(): Keypair;
|
|
83
|
+
/**
|
|
84
|
+
* Generate a [Keypair] from a secret key.
|
|
85
|
+
*/
|
|
86
|
+
static fromSecretKey(secret_key: Uint8Array): Keypair;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the secret key of this keypair.
|
|
89
|
+
*/
|
|
90
|
+
secretKey(): Uint8Array;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the [PublicKey] of this keypair.
|
|
93
|
+
*/
|
|
94
|
+
publicKey(): PublicKey;
|
|
153
95
|
}
|
|
154
96
|
export class PublicKey {
|
|
97
|
+
private constructor();
|
|
155
98
|
free(): void;
|
|
156
99
|
/**
|
|
157
100
|
* Convert the PublicKey to Uint8Array
|
|
158
|
-
* @returns {Uint8Array}
|
|
159
101
|
*/
|
|
160
102
|
to_uint8array(): Uint8Array;
|
|
161
103
|
/**
|
|
162
104
|
* Returns the z-base32 encoding of this public key
|
|
163
|
-
* @returns {string}
|
|
164
105
|
*/
|
|
165
106
|
z32(): string;
|
|
166
107
|
/**
|
|
167
108
|
* @throws
|
|
168
|
-
* @param {any} value
|
|
169
|
-
* @returns {PublicKey}
|
|
170
109
|
*/
|
|
171
110
|
static from(value: any): PublicKey;
|
|
172
111
|
}
|
|
173
112
|
export class Session {
|
|
113
|
+
private constructor();
|
|
174
114
|
free(): void;
|
|
175
115
|
/**
|
|
176
116
|
* Return the [PublicKey] of this session
|
|
177
|
-
* @returns {PublicKey}
|
|
178
117
|
*/
|
|
179
118
|
pubky(): PublicKey;
|
|
180
119
|
/**
|
|
181
120
|
* Return the capabilities that this session has.
|
|
182
|
-
* @returns {(string)[]}
|
|
183
121
|
*/
|
|
184
122
|
capabilities(): (string)[];
|
|
185
123
|
}
|
package/pubky_bg.wasm
CHANGED
|
Binary file
|