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