@synonymdev/pubky 0.1.8 → 0.1.10
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 +110 -0
- package/browser.js +82 -23
- package/{nodejs/pubky.js → index.cjs} +81 -22
- package/package.json +6 -8
- package/{nodejs/pubky.d.ts → pubky.d.ts} +26 -5
- package/{nodejs/pubky_bg.wasm → pubky_bg.wasm} +0 -0
- package/index.js +0 -1
- package/nodejs/pubky_bg.wasm.d.ts +0 -32
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,110 @@ 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 delete(url);
|
|
114
|
+
```
|
|
115
|
+
- url: A string representing the Pubky URL.
|
|
116
|
+
|
|
117
|
+
### Keypair
|
|
118
|
+
|
|
119
|
+
#### random
|
|
120
|
+
```js
|
|
121
|
+
let keypair = Keypair.random()
|
|
122
|
+
```
|
|
123
|
+
- Returns: A new random Keypair.
|
|
124
|
+
|
|
125
|
+
#### fromSecretKey
|
|
126
|
+
```js
|
|
127
|
+
let keypair = Keypair.fromSecretKey(secretKey)
|
|
128
|
+
```
|
|
129
|
+
- secretKey: A 32 bytes Uint8array.
|
|
130
|
+
- Returns: A new Keypair.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
#### publicKey
|
|
134
|
+
```js
|
|
135
|
+
let publicKey = keypair.publicKey()
|
|
136
|
+
```
|
|
137
|
+
- Returns: The [PublicKey](#publickey) associated with the Keypair.
|
|
138
|
+
|
|
139
|
+
#### secretKey
|
|
140
|
+
```js
|
|
141
|
+
let secretKey = keypair.secretKey()
|
|
142
|
+
```
|
|
143
|
+
- Returns: The Uint8array secret key associated with the Keypair.
|
|
144
|
+
|
|
145
|
+
### PublicKey
|
|
146
|
+
|
|
147
|
+
#### from
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
let publicKey = PublicKey.from(string);
|
|
151
|
+
```
|
|
152
|
+
- string: A string representing the public key.
|
|
153
|
+
- Returns: A new PublicKey instance.
|
|
154
|
+
|
|
155
|
+
#### z32
|
|
156
|
+
```js
|
|
157
|
+
let pubky = publicKey.z32();
|
|
158
|
+
```
|
|
159
|
+
Returns: The z-base-32 encoded string representation of the PublicKey.
|
|
160
|
+
|
|
51
161
|
## Test and Development
|
|
52
162
|
|
|
53
163
|
For test and development, you can run a local homeserver in a test network.
|