mirror of
https://github.com/nostr-connect/connect.git
synced 2025-12-17 05:04:20 +01:00
96be7385f983d67444a73da20be4efd89ceff840
Nostr Connect allows Nostr apps to connect with remote signing devices
Having to enter your Nostr private key on each website or random app sucks.
Protocol
TL;DR
App (typically a web app, it generates a random ephemeral keypair) and Wallet (typically a mobile app, it holds the private key of the user that represents his Nostr account) send to each other kind:4 encrypted DMs, using a relay of choice.
App prompts the Wallet to do things such as fetching the public key or signing events.
The content field must be a JSONRPC-ish request or response.
Messages
Request
{
"id": <random_string>,
"method": <one_of_the_methods>,
"params": [<anything>, <else>]
}
Response
{
"id": <request_id>,
"result": <anything>,
"error": <reason>
}
Methods
connect- params [
pubkey]
- params [
disconnect- params []
get_public_key- params []
- result
pubkey
sign_event- params [
event] - result
signature
- params [
optional
delegateget_relaysnip04_encryptnip04_decrypt
Nostr Connect URI
Walle discovers App by scanning a QR code or clicking on a deep link or copy-pasting an URI.
The App generates a special URI with prefix nostr:// and base path connect with the following querystring parameters
targethexadecimal public key of the ApprelayURL of the relay of choice where the App is connected and the Wallet must send and listen for messages.metadatametadata JSON of the AppurlURL of the website requesting the connectionnamehuman-readable name of the Appdescription(optional) description of the Appicons(optional) array of URLs for icons of the App.
Example
nostr://conect?target=<pubkey>&relay=<relay>&metadata={"url": "example.com","name": "Example"}
Flow
Connect
- User clicks on "Connect" button on a website or scan it with a QR code
- It will show an URI to open a "nostr connect" enabled Wallet
- In the URI there is a pubkey of the App ie.
nostr://conect?target=<pubkey>&relay=<relay>&metadata=<metadata> - The Wallet will send a kind 4 encrypted message to ACK the
connectrequest, along with his public key
Disconnect (from App)
- User clicks on "Disconnect" button on the App
- The App will send a kind 4 encrypted message to the Wallet with a
disconnectrequest - The Wallet will send a kind 4 encrypted message to ACK the
disconnectrequest
Disconnect (from Wallet)
- User clicks on "Disconnect" button on the Wallet
- The Wallet will send a kind 4 encrypted message to the App with a
disconnectrequest
Get Public Key
- The App will send a kind 4 encrypted message to the Wallet with a
get_public_keyrequest - The Wallet will send back a kind 4 encrypted message with the public key as a response to the
get_public_keyrequest
Sign Event
- The App will send a kind 4 encrypted message to the Wallet with a
sign_eventrequest along with the event to be signed - The Wallet will show a popup to the user to inspect the event and sign it
- The Wallet will send back a kind 4 encrypted message with the schnorr
signatureof the event as a response to thesign_eventrequest
Delegate
- The App will send a kind 4 encrypted message with metadata to the Wallet with a
delegaterequest along with the conditions query string and the pubkey of the App to be delegated. - The Wallet will show a popup to the user to delegate the App to sign on his behalf
- The Wallet will send back a kind 4 encrypted message with the signed NIP-26 delegation token or reject it
- All others subsequent
delegateRequests will be ACKed automatically
Languages
TypeScript
98.2%
HTML
1.5%
JavaScript
0.3%