@synonymdev/pubky 0.0.1 → 0.0.2
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 +32 -5
- package/browser.js +244 -72
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install @synonymdev/pubky
|
|
|
11
11
|
## Getting started
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
import PubkyClient from
|
|
14
|
+
import { PubkyClient, Keypair, PublicKey } from '../index.js'
|
|
15
15
|
|
|
16
16
|
// Initialize PubkyClient with Pkarr relay(s).
|
|
17
17
|
let client = new PubkyClient();
|
|
@@ -20,9 +20,26 @@ let client = new PubkyClient();
|
|
|
20
20
|
let keypair = Keypair.random();
|
|
21
21
|
|
|
22
22
|
// Create a new account
|
|
23
|
-
let homeserver = PublicKey.
|
|
23
|
+
let homeserver = PublicKey.from("8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo");
|
|
24
24
|
|
|
25
25
|
await client.signup(keypair, homeserver)
|
|
26
|
+
|
|
27
|
+
// Verify that you are signed in.
|
|
28
|
+
const session = await client.session(publicKey)
|
|
29
|
+
|
|
30
|
+
const publicKey = keypair.public_key();
|
|
31
|
+
|
|
32
|
+
const body = Buffer.from(JSON.stringify({ foo: 'bar' }))
|
|
33
|
+
|
|
34
|
+
// PUT public data, by authorized client
|
|
35
|
+
await client.put(publicKey, "/pub/example.com/arbitrary", body);
|
|
36
|
+
|
|
37
|
+
// GET public data without signup or signin
|
|
38
|
+
{
|
|
39
|
+
const client = new PubkyClient();
|
|
40
|
+
|
|
41
|
+
let response = await client.get(publicKey, "/pub/example.com/arbitrary");
|
|
42
|
+
}
|
|
26
43
|
```
|
|
27
44
|
|
|
28
45
|
## Test and Development
|
|
@@ -39,11 +56,21 @@ Clone the Pubky repository:
|
|
|
39
56
|
|
|
40
57
|
```bash
|
|
41
58
|
git clone https://github.com/pubky/pubky
|
|
42
|
-
cd pubky/
|
|
59
|
+
cd pubky/pkg
|
|
43
60
|
```
|
|
44
61
|
|
|
45
|
-
Run the testnet server
|
|
62
|
+
Run the local testnet server
|
|
46
63
|
|
|
47
64
|
```bash
|
|
48
|
-
|
|
65
|
+
npm run testnet
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Pass the logged addresses as inputs to `PubkyClient`
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import { PubkyClient, PublicKey } from '../index.js'
|
|
72
|
+
|
|
73
|
+
const client = new PubkyClient().setPkarrRelays(["http://localhost:15411/pkarr"]);
|
|
74
|
+
|
|
75
|
+
let homeserver = PublicKey.from("8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo");
|
|
49
76
|
```
|