@synonymdev/pubky 0.2.0 → 0.4.0-rc.4

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/package.json CHANGED
@@ -2,14 +2,14 @@
2
2
  "name": "@synonymdev/pubky",
3
3
  "type": "module",
4
4
  "description": "Pubky client",
5
- "version": "0.2.0",
5
+ "version": "0.4.0-rc.4",
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 pubky_homeserver -- --testnet",
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
- "browser.js",
21
+ "index.js",
22
22
  "pubky.d.ts",
23
23
  "pubky_bg.wasm"
24
24
  ],
25
25
  "main": "index.cjs",
26
- "browser": "browser.js",
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 class Keypair {
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 PubkyClient {
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,24 @@ 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
54
  /**
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>}
55
+ * Create Client with default Settings including default relays
128
56
  */
129
- get(url: string): Promise<Uint8Array | undefined>;
57
+ constructor();
130
58
  /**
131
- * Delete a file at a path relative to a pubky author.
132
- * @param {string} url
133
- * @returns {Promise<void>}
59
+ * Create a client with with configurations appropriate for local testing:
60
+ * - set Pkarr relays to `["http://localhost:15411"]` instead of default relay.
61
+ * - transform `pubky://<pkarr public key>` to `http://<pkarr public key` instead of `https:`
62
+ * and read the homeserver HTTP port from the [reserved service parameter key](pubky_common::constants::reserved_param_keys::HTTP_PORT)
134
63
  */
135
- delete(url: string): Promise<void>;
64
+ static testnet(): Client;
136
65
  /**
137
66
  * Returns a list of Pubky urls (as strings).
138
67
  *
@@ -142,44 +71,55 @@ export class PubkyClient {
142
71
  * - `reverse`: List in reverse order
143
72
  * - `limit` Limit the number of urls in the response
144
73
  * - `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
- */
152
- list(url: string, cursor?: string, reverse?: boolean, limit?: number, shallow?: boolean): Promise<Array<any>>;
74
+ */
75
+ list(url: string, cursor?: string | null, reverse?: boolean | null, limit?: number | null, shallow?: boolean | null): Promise<Array<any>>;
76
+ fetch(url: string, request_init?: any | null): 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;
153
97
  }
154
98
  export class PublicKey {
99
+ private constructor();
155
100
  free(): void;
156
101
  /**
157
102
  * Convert the PublicKey to Uint8Array
158
- * @returns {Uint8Array}
159
103
  */
160
104
  to_uint8array(): Uint8Array;
161
105
  /**
162
106
  * Returns the z-base32 encoding of this public key
163
- * @returns {string}
164
107
  */
165
108
  z32(): string;
166
109
  /**
167
110
  * @throws
168
- * @param {any} value
169
- * @returns {PublicKey}
170
111
  */
171
112
  static from(value: any): PublicKey;
172
113
  }
173
114
  export class Session {
115
+ private constructor();
174
116
  free(): void;
175
117
  /**
176
118
  * Return the [PublicKey] of this session
177
- * @returns {PublicKey}
178
119
  */
179
120
  pubky(): PublicKey;
180
121
  /**
181
122
  * Return the capabilities that this session has.
182
- * @returns {(string)[]}
183
123
  */
184
- capabilities(): (string)[];
124
+ capabilities(): string[];
185
125
  }
package/pubky_bg.wasm CHANGED
Binary file