@synonymdev/pubky 0.1.14 → 0.1.15
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 +78 -16
- package/browser.js +380 -221
- package/index.cjs +267 -187
- package/package.json +1 -1
- package/pubky.d.ts +48 -19
- package/pubky_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -67,35 +67,65 @@ await client.delete(url);
|
|
|
67
67
|
let client = new PubkyClient()
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
####
|
|
70
|
+
#### signup
|
|
71
71
|
```js
|
|
72
|
-
|
|
72
|
+
await client.signup(keypair, homeserver)
|
|
73
73
|
```
|
|
74
74
|
- keypair: An instance of [Keypair](#keypair).
|
|
75
|
-
-
|
|
76
|
-
- Returns: A recovery file with a spec line and an encrypted secret key.
|
|
75
|
+
- homeserver: An instance of [PublicKey](#publickey) representing the homeserver.
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
Returns:
|
|
78
|
+
- session: An instance of [Session](#session).
|
|
79
|
+
|
|
80
|
+
#### signin
|
|
79
81
|
```js
|
|
80
|
-
let
|
|
82
|
+
let session = await client.signin(keypair)
|
|
81
83
|
```
|
|
82
|
-
-
|
|
83
|
-
- passphrase: A utf-8 string [passphrase](https://www.useapassphrase.com/).
|
|
84
|
-
- Returns: An instance of [Keypair](#keypair).
|
|
84
|
+
- keypair: An instance of [Keypair](#keypair).
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
Returns:
|
|
87
|
+
- An instance of [Session](#session).
|
|
88
|
+
|
|
89
|
+
#### signout
|
|
87
90
|
```js
|
|
88
|
-
await client.
|
|
91
|
+
await client.signout(publicKey)
|
|
89
92
|
```
|
|
90
|
-
-
|
|
91
|
-
- homeserver: An instance of [PublicKey](#publickey) representing the homeserver.
|
|
93
|
+
- publicKey: An instance of [PublicKey](#publicKey).
|
|
92
94
|
|
|
93
|
-
####
|
|
95
|
+
#### authRequest
|
|
96
|
+
```js
|
|
97
|
+
let [pubkyauthUrl, sessionPromise] = client.authRequest(relay, capabilities);
|
|
98
|
+
|
|
99
|
+
showQr(pubkyauthUrl);
|
|
100
|
+
|
|
101
|
+
let session = await sessionPromise;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Sign in to a user's Homeserver, without access to their [Keypair](#keypair), nor even [PublicKey](#publickey),
|
|
105
|
+
instead request permissions (showing the user pubkyauthUrl), and await a Session after the user consenting to that request.
|
|
106
|
+
|
|
107
|
+
- relay: A URL to an [HTTP relay](https://httprelay.io/features/link/) endpoint.
|
|
108
|
+
- capabilities: A list of capabilities required for the app for example `/pub/pubky.app/:rw,/pub/example.com/:r`.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
- pubkyauthUrl: A url to show to the user to scan or paste into an Authenticator app holding the user [Keypair](#keypair)
|
|
112
|
+
- sessionPromise: A promise that resolves into a [Session](#session) on success.
|
|
113
|
+
|
|
114
|
+
#### sendAuthToken
|
|
115
|
+
```js
|
|
116
|
+
await client.sendAuthToken(keypair, pubkyauthUrl);
|
|
117
|
+
```
|
|
118
|
+
Consenting to authentication or authorization according to the required capabilities in the `pubkyauthUrl` , and sign and send an auth token to the requester.
|
|
119
|
+
|
|
120
|
+
- keypair: An instance of [KeyPair](#keypair)
|
|
121
|
+
- pubkyauthUrl: A string `pubkyauth://` url
|
|
122
|
+
|
|
123
|
+
#### session {#session-method}
|
|
94
124
|
```js
|
|
95
125
|
let session = await client.session(publicKey)
|
|
96
126
|
```
|
|
97
127
|
- publicKey: An instance of [PublicKey](#publickey).
|
|
98
|
-
- Returns: A session object if signed in, or undefined if not.
|
|
128
|
+
- Returns: A [Session](#session) object if signed in, or undefined if not.
|
|
99
129
|
|
|
100
130
|
#### put
|
|
101
131
|
```js
|
|
@@ -144,7 +174,7 @@ let keypair = Keypair.fromSecretKey(secretKey)
|
|
|
144
174
|
- Returns: A new Keypair.
|
|
145
175
|
|
|
146
176
|
|
|
147
|
-
#### publicKey
|
|
177
|
+
#### publicKey {#publickey-method}
|
|
148
178
|
```js
|
|
149
179
|
let publicKey = keypair.publicKey()
|
|
150
180
|
```
|
|
@@ -172,6 +202,38 @@ let pubky = publicKey.z32();
|
|
|
172
202
|
```
|
|
173
203
|
Returns: The z-base-32 encoded string representation of the PublicKey.
|
|
174
204
|
|
|
205
|
+
### Session
|
|
206
|
+
|
|
207
|
+
#### pubky
|
|
208
|
+
```js
|
|
209
|
+
let pubky = session.pubky();
|
|
210
|
+
```
|
|
211
|
+
Returns an instance of [PublicKey](#publickey)
|
|
212
|
+
|
|
213
|
+
#### capabilities
|
|
214
|
+
```js
|
|
215
|
+
let capabilities = session.capabilities();
|
|
216
|
+
```
|
|
217
|
+
Returns an array of capabilities, for example `["/pub/pubky.app/:rw"]`
|
|
218
|
+
|
|
219
|
+
### Helper functions
|
|
220
|
+
|
|
221
|
+
#### createRecoveryFile
|
|
222
|
+
```js
|
|
223
|
+
let recoveryFile = createRecoveryFile(keypair, passphrase)
|
|
224
|
+
```
|
|
225
|
+
- keypair: An instance of [Keypair](#keypair).
|
|
226
|
+
- passphrase: A utf-8 string [passphrase](https://www.useapassphrase.com/).
|
|
227
|
+
- Returns: A recovery file with a spec line and an encrypted secret key.
|
|
228
|
+
|
|
229
|
+
#### createRecoveryFile
|
|
230
|
+
```js
|
|
231
|
+
let keypair = decryptRecoveryfile(recoveryFile, passphrase)
|
|
232
|
+
```
|
|
233
|
+
- recoveryFile: An instance of Uint8Array containing the recovery file blob.
|
|
234
|
+
- passphrase: A utf-8 string [passphrase](https://www.useapassphrase.com/).
|
|
235
|
+
- Returns: An instance of [Keypair](#keypair).
|
|
236
|
+
|
|
175
237
|
## Test and Development
|
|
176
238
|
|
|
177
239
|
For test and development, you can run a local homeserver in a test network.
|