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