@synonymdev/pubky 0.1.9 → 0.1.11

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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  JavaScript implementation of [Pubky](https://github.com/pubky/pubky).
4
4
 
5
+ ## Table of Contents
6
+ - [Install](#install)
7
+ - [Getting Started](#getting-started)
8
+ - [API](#api)
9
+ - [Test and Development](#test-and-development)
10
+
5
11
  ## Install
6
12
 
7
13
  ```bash
@@ -48,6 +54,120 @@ await client.put(url, body);
48
54
  await client.delete(url);
49
55
  ```
50
56
 
57
+ ## API
58
+
59
+ ### PubkyClient
60
+
61
+ #### constructor
62
+ ```js
63
+ let client = new PubkyClient()
64
+ ```
65
+
66
+ #### createRecoveryFile
67
+ ```js
68
+ let recoveryFile = PubkyClient.createRecoveryFile(keypair, passphrase)
69
+ ```
70
+ - keypair: An instance of [Keypair](#keypair).
71
+ - passphrase: A utf-8 string [passphrase](https://www.useapassphrase.com/).
72
+ - Returns: A recovery file with a spec line and an encrypted secret key.
73
+
74
+ #### createRecoveryFile
75
+ ```js
76
+ let keypair = PubkyClient.decryptRecoveryfile(recoveryFile, passphrase)
77
+ ```
78
+ - recoveryFile: An instance of Uint8Array containing the recovery file blob.
79
+ - passphrase: A utf-8 string [passphrase](https://www.useapassphrase.com/).
80
+ - Returns: An instance of [Keypair](#keypair).
81
+
82
+ #### signup
83
+ ```js
84
+ await client.signup(keypair, homeserver)
85
+ ```
86
+ - keypair: An instance of [Keypair](#keypair).
87
+ - homeserver: An instance of [PublicKey](#publickey) representing the homeserver.
88
+
89
+ #### session
90
+ ```js
91
+ let session = await client.session(publicKey)
92
+ ```
93
+ - publicKey: An instance of [PublicKey](#publickey).
94
+ - Returns: A session object if signed in, or undefined if not.
95
+
96
+ #### put
97
+ ```js
98
+ let response = await client.put(url, body);
99
+ ```
100
+ - url: A string representing the Pubky URL.
101
+ - body: A Buffer containing the data to be stored.
102
+
103
+ ### get
104
+ ```js
105
+ let response = await client.get(url)
106
+ ```
107
+ - url: A string representing the Pubky URL.
108
+ - Returns: A response object containing the requested data.
109
+
110
+ ### delete
111
+
112
+ ```js
113
+ let response = await client.delete(url);
114
+ ```
115
+ - url: A string representing the Pubky URL.
116
+
117
+ ### list
118
+ ```js
119
+ let response = await client.list(url, cursor, reverse, limit)
120
+ ```
121
+ - url: A string representing the Pubky URL. The path in that url is the prefix that you want to list files within.
122
+ - cursor: Usually the last URL from previous calls. List urls after/before (depending on `reverse`) the cursor.
123
+ - reverse: Whether or not return urls in reverse order.
124
+ - limit: Number of urls to return.
125
+ - Returns: A list of URLs of the files in the `url` you passed.
126
+
127
+ ### Keypair
128
+
129
+ #### random
130
+ ```js
131
+ let keypair = Keypair.random()
132
+ ```
133
+ - Returns: A new random Keypair.
134
+
135
+ #### fromSecretKey
136
+ ```js
137
+ let keypair = Keypair.fromSecretKey(secretKey)
138
+ ```
139
+ - secretKey: A 32 bytes Uint8array.
140
+ - Returns: A new Keypair.
141
+
142
+
143
+ #### publicKey
144
+ ```js
145
+ let publicKey = keypair.publicKey()
146
+ ```
147
+ - Returns: The [PublicKey](#publickey) associated with the Keypair.
148
+
149
+ #### secretKey
150
+ ```js
151
+ let secretKey = keypair.secretKey()
152
+ ```
153
+ - Returns: The Uint8array secret key associated with the Keypair.
154
+
155
+ ### PublicKey
156
+
157
+ #### from
158
+
159
+ ```js
160
+ let publicKey = PublicKey.from(string);
161
+ ```
162
+ - string: A string representing the public key.
163
+ - Returns: A new PublicKey instance.
164
+
165
+ #### z32
166
+ ```js
167
+ let pubky = publicKey.z32();
168
+ ```
169
+ Returns: The z-base-32 encoded string representation of the PublicKey.
170
+
51
171
  ## Test and Development
52
172
 
53
173
  For test and development, you can run a local homeserver in a test network.
@@ -76,5 +196,5 @@ Use the logged addresses as inputs to `PubkyClient`
76
196
  ```js
77
197
  import { PubkyClient } from '../index.js'
78
198
 
79
- const client = new PubkyClient().testnet();
199
+ const client = PubkyClient().testnet();
80
200
  ```