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