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