@synonymdev/pubky 0.4.0-rc3 → 0.4.2-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/README.md +69 -32
- package/index.cjs +340 -318
- package/index.js +345 -323
- package/package.json +2 -2
- package/pubky.d.ts +49 -18
- 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.4.
|
|
5
|
+
"version": "0.4.2-rc1",
|
|
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-
|
|
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,34 +11,39 @@ 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
|
-
|
|
16
|
-
*/
|
|
17
|
-
export class Client {
|
|
14
|
+
export class AuthRequest {
|
|
15
|
+
private constructor();
|
|
18
16
|
free(): void;
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
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()`.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
url(): string;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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.
|
|
28
30
|
*/
|
|
29
|
-
|
|
31
|
+
response(): Promise<PublicKey>;
|
|
32
|
+
}
|
|
33
|
+
export class Client {
|
|
34
|
+
free(): void;
|
|
30
35
|
/**
|
|
31
36
|
* Signup to a homeserver and update Pkarr accordingly.
|
|
32
37
|
*
|
|
33
38
|
* The homeserver is a Pkarr domain name, where the TLD is a Pkarr public key
|
|
34
39
|
* for example "pubky.o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy"
|
|
35
40
|
*/
|
|
36
|
-
signup(keypair: Keypair, homeserver: PublicKey): Promise<Session>;
|
|
41
|
+
signup(keypair: Keypair, homeserver: PublicKey, signup_token?: string | null): Promise<Session>;
|
|
37
42
|
/**
|
|
38
|
-
* Check the current
|
|
43
|
+
* Check the current session for a given Pubky in its homeserver.
|
|
39
44
|
*
|
|
40
|
-
* Returns [Session] or `None` (if
|
|
41
|
-
* or throws the
|
|
45
|
+
* Returns [Session] or `None` (if received `404 NOT_FOUND`),
|
|
46
|
+
* or throws the received error if the response has any other `>=400` status code.
|
|
42
47
|
*/
|
|
43
48
|
session(pubky: PublicKey): Promise<Session | undefined>;
|
|
44
49
|
/**
|
|
@@ -54,14 +59,41 @@ export class Client {
|
|
|
54
59
|
* verifying that AuthToken, and if capabilities were requested, signing in to
|
|
55
60
|
* the Pubky's homeserver and returning the [Session] information.
|
|
56
61
|
*
|
|
57
|
-
* Returns a
|
|
62
|
+
* Returns a [AuthRequest]
|
|
58
63
|
*/
|
|
59
|
-
authRequest(relay: string, capabilities: string):
|
|
64
|
+
authRequest(relay: string, capabilities: string): AuthRequest;
|
|
60
65
|
/**
|
|
61
66
|
* Sign an [pubky_common::auth::AuthToken], encrypt it and send it to the
|
|
62
67
|
* source of the pubkyauth request url.
|
|
63
68
|
*/
|
|
64
69
|
sendAuthToken(keypair: Keypair, pubkyauth_url: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Republish the user's PKarr record pointing to their homeserver.
|
|
72
|
+
*
|
|
73
|
+
* This method will republish the record if no record exists or if the existing record
|
|
74
|
+
* is older than 6 hours.
|
|
75
|
+
*
|
|
76
|
+
* The method is intended for clients and key managers (e.g., pubky-ring) to
|
|
77
|
+
* keep the records of active users fresh and available in the DHT and relays.
|
|
78
|
+
* It is intended to be used only after failed signin due to homeserver resolution
|
|
79
|
+
* failure. This method is lighter than performing a re-signup into the last known
|
|
80
|
+
* homeserver, but does not return a session token, so a signin must be done after
|
|
81
|
+
* republishing. On a failed signin due to homeserver resolution failure, a key
|
|
82
|
+
* manager should always attempt to republish the last known homeserver.
|
|
83
|
+
*/
|
|
84
|
+
republishHomeserver(keypair: Keypair, host: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Create Client with default Settings including default relays
|
|
87
|
+
*/
|
|
88
|
+
constructor();
|
|
89
|
+
/**
|
|
90
|
+
* Create a client with with configurations appropriate for local testing:
|
|
91
|
+
* - set Pkarr relays to `["http://localhost:15411"]` instead of default relay.
|
|
92
|
+
* - transform `pubky://<pkarr public key>` to `http://<pkarr public key` instead of `https:`
|
|
93
|
+
* and read the homeserver HTTP port from the [reserved service parameter key](pubky_common::constants::reserved_param_keys::HTTP_PORT)
|
|
94
|
+
*/
|
|
95
|
+
static testnet(): Client;
|
|
96
|
+
fetch(url: string, request_init?: any | null): Promise<Promise<any>>;
|
|
65
97
|
/**
|
|
66
98
|
* Returns a list of Pubky urls (as strings).
|
|
67
99
|
*
|
|
@@ -73,7 +105,6 @@ export class Client {
|
|
|
73
105
|
* - `shallow`: List directories and files, instead of flat list of files.
|
|
74
106
|
*/
|
|
75
107
|
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
108
|
}
|
|
78
109
|
export class Keypair {
|
|
79
110
|
private constructor();
|
package/pubky_bg.wasm
CHANGED
|
Binary file
|