@synonymdev/pubky 0.4.0-rc2 → 0.4.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/package.json CHANGED
@@ -2,14 +2,14 @@
2
2
  "name": "@synonymdev/pubky",
3
3
  "type": "module",
4
4
  "description": "Pubky client",
5
- "version": "0.4.0-rc2",
5
+ "version": "0.4.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
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-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
@@ -11,9 +11,25 @@ export function createRecoveryFile(keypair: Keypair, passphrase: string): Uint8A
11
11
  * using the `passphrase`.
12
12
  */
13
13
  export function decryptRecoveryFile(recovery_file: Uint8Array, passphrase: string): Keypair;
14
- /**
15
- * A client for Pubky homeserver API, as well as generic HTTP requests to Pubky urls.
16
- */
14
+ export class AuthRequest {
15
+ private constructor();
16
+ free(): void;
17
+ /**
18
+ * Returns the Pubky Auth url, which you should show to the user
19
+ * to request an authentication or authorization token.
20
+ *
21
+ * Wait for this token using `this.response()`.
22
+ */
23
+ url(): string;
24
+ /**
25
+ * Wait for the user to send an authentication or authorization proof.
26
+ *
27
+ * If successful, you should expect an instance of [PublicKey]
28
+ *
29
+ * Otherwise it will throw an error.
30
+ */
31
+ response(): Promise<PublicKey>;
32
+ }
17
33
  export class Client {
18
34
  free(): void;
19
35
  /**
@@ -27,6 +43,18 @@ export class Client {
27
43
  * and read the homeserver HTTP port from the [reserved service parameter key](pubky_common::constants::reserved_param_keys::HTTP_PORT)
28
44
  */
29
45
  static testnet(): Client;
46
+ fetch(url: string, request_init?: any | null): Promise<Promise<any>>;
47
+ /**
48
+ * Returns a list of Pubky urls (as strings).
49
+ *
50
+ * - `url`: The Pubky url (string) to the directory you want to list its content.
51
+ * - `cursor`: Either a full `pubky://` Url (from previous list response),
52
+ * or a path (to a file or directory) relative to the `url`
53
+ * - `reverse`: List in reverse order
54
+ * - `limit` Limit the number of urls in the response
55
+ * - `shallow`: List directories and files, instead of flat list of files.
56
+ */
57
+ list(url: string, cursor?: string | null, reverse?: boolean | null, limit?: number | null, shallow?: boolean | null): Promise<Array<any>>;
30
58
  /**
31
59
  * Signup to a homeserver and update Pkarr accordingly.
32
60
  *
@@ -35,10 +63,10 @@ export class Client {
35
63
  */
36
64
  signup(keypair: Keypair, homeserver: PublicKey): Promise<Session>;
37
65
  /**
38
- * Check the current sesison for a given Pubky in its homeserver.
66
+ * Check the current session for a given Pubky in its homeserver.
39
67
  *
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.
68
+ * Returns [Session] or `None` (if received `404 NOT_FOUND`),
69
+ * or throws the received error if the response has any other `>=400` status code.
42
70
  */
43
71
  session(pubky: PublicKey): Promise<Session | undefined>;
44
72
  /**
@@ -54,26 +82,14 @@ export class Client {
54
82
  * verifying that AuthToken, and if capabilities were requested, signing in to
55
83
  * the Pubky's homeserver and returning the [Session] information.
56
84
  *
57
- * Returns a tuple of [pubkyAuthUrl, Promise<Session>]
85
+ * Returns a [AuthRequest]
58
86
  */
59
- authRequest(relay: string, capabilities: string): Array<any>;
87
+ authRequest(relay: string, capabilities: string): AuthRequest;
60
88
  /**
61
89
  * Sign an [pubky_common::auth::AuthToken], encrypt it and send it to the
62
90
  * source of the pubkyauth request url.
63
91
  */
64
92
  sendAuthToken(keypair: Keypair, pubkyauth_url: string): Promise<void>;
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
- */
75
- list(url: string, cursor?: string, reverse?: boolean, limit?: number, shallow?: boolean): Promise<Array<any>>;
76
- fetch(url: string, request_init?: any): Promise<Promise<any>>;
77
93
  }
78
94
  export class Keypair {
79
95
  private constructor();
@@ -121,5 +137,5 @@ export class Session {
121
137
  /**
122
138
  * Return the capabilities that this session has.
123
139
  */
124
- capabilities(): (string)[];
140
+ capabilities(): string[];
125
141
  }
package/pubky_bg.wasm CHANGED
Binary file