@synonymdev/pubky 0.0.1 → 0.0.3

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.
Files changed (3) hide show
  1. package/README.md +32 -5
  2. package/package.json +7 -6
  3. package/browser.js +0 -794
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 "@synonymdev/pubky";
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.try_from("8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo");
23
+ let homeserver = PublicKey.from("8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo");
24
24
 
25
25
  await client.signup(keypair, homeserver)
26
+
27
+ const publicKey = keypair.public_key();
28
+
29
+ // Verify that you are signed in.
30
+ const session = await client.session(publicKey)
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
- cargo run --bin pubky_homeserver -- --testnet
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
  ```
package/package.json CHANGED
@@ -2,18 +2,20 @@
2
2
  "name": "@synonymdev/pubky",
3
3
  "type": "module",
4
4
  "description": "Pubky client",
5
- "version": "0.0.1",
5
+ "version": "0.0.3",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/pubky/pubky"
10
10
  },
11
11
  "scripts": {
12
- "lint": "standard --fix",
13
- "test": "tape test/*.js -cov",
12
+ "testnet": "cargo run -p pubky_homeserver -- --testnet",
13
+ "test": "npm run test-nodejs && npm run test-browser",
14
+ "test-nodejs": "tape test/*.js -cov",
14
15
  "test-browser": "browserify test/*.js -p esmify | npx tape-run",
15
- "preinstall": "cargo run --bin bundle_pubky_npm",
16
- "prepublishOnly": "npm run lint && npm run test"
16
+ "build": "cargo run --bin bundle_pubky_npm",
17
+ "preinstall": "npm run build",
18
+ "prepublishOnly": "npm run build && npm run test"
17
19
  },
18
20
  "files": [
19
21
  "nodejs/*",
@@ -36,7 +38,6 @@
36
38
  "devDependencies": {
37
39
  "browser-resolve": "^2.0.0",
38
40
  "esmify": "^2.1.1",
39
- "standard": "^17.1.0",
40
41
  "tape": "^5.8.1",
41
42
  "tape-run": "^11.0.0"
42
43
  }