You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-5Lines changed: 54 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,13 +179,23 @@ for (let block of nip27.parse(evt.content)) {
179
179
180
180
### Connecting to a bunker using NIP-46
181
181
182
+
`BunkerSigner` allows your application to request signatures and other actions from a remote NIP-46 signer, often called a "bunker". There are two primary ways to establish a connection, depending on whether the client or the bunker initiates the connection.
183
+
184
+
A local secret key is required for the client to communicate securely with the bunker. This key should generally be persisted for the user's session.
// the client needs a local secret key (which is generally persisted) for communicating with the bunker
188
189
constlocalSecretKey=generateSecretKey()
190
+
```
191
+
192
+
### Method 1: Using a Bunker URI (`bunker://`)
193
+
194
+
This is the bunker-initiated flow. Your client receives a `bunker://` string or a NIP-05 identifier from the user. You use `BunkerSigner.fromBunker()` to create an instance, which returns immediately. You must then explicitly call `await bunker.connect()` to establish the connection with the bunker.
constbunker=newBunkerSigner(localSecretKey, bunkerPointer, { pool })
208
+
constbunker=BunkerSigner.fromBunker(localSecretKey, bunkerPointer, { pool })
199
209
awaitbunker.connect()
200
210
201
211
// and use it
@@ -212,6 +222,45 @@ await signer.close()
212
222
pool.close([])
213
223
```
214
224
225
+
### Method 2: Using a Client-generated URI (`nostrconnect://`)
226
+
227
+
This is the client-initiated flow, which generally provides a better user experience for first-time connections (e.g., via QR code). Your client generates a `nostrconnect://` URI and waits for the bunker to connect to it.
228
+
229
+
`BunkerSigner.fromURI()` is an **asynchronous** method. It returns a `Promise` that resolves only after the bunker has successfully connected. Therefore, the returned signer instance is already fully connected and ready to use, so you **do not** need to call `.connect()` on it.
0 commit comments