Discovery
Overview¶
The discovery process allows the server to determine who it is communicating with and moves communication from an insecure channel to a secure, encrypted channel.
Key Points:
- The discovery process is not a direct connection but a method to establish a connection.
- The main goal is to obtain the address of the user you want to connect with.
How it works¶
The discovery process is like introducing two strangers who want to talk securely. Here's how it works:
- Build Discovery QR Code: The server creates a special code (QR code) that contains information about how to reach it.
- Display QR Code: This code is shown to a user, typically on a screen.
- Scan QR Code: The user scans the QR code with their phone or device.
- Send Address: By scanning the code, the user's device learns how to contact the server securely. The user's device then sends its own contact information back to the server.
- Start Conversation: Now that they both know how to reach each other securely, they can start a private, encrypted conversation.
sequenceDiagram
participant Server
participant User Device
Server->>Server: Build discovery QR code
Server->>User Device: Display QR code
User Device->>User Device: Scan QR code
User Device->>Server: Send address
Server->>User Device: Start conversation
The main point of this process is to make sure that when the server and the user's device start talking, they do it in a way that's safe and private. It's like exchanging secret handshakes before having a confidential chat.
Benefits:
- It's a safe way for the server and user to meet for the first time.
- It helps set up a secure way to talk, so others can't eavesdrop.
- Once this introduction is done, the server and user can have more complex and secure interactions in the future.
In essence, it's all about making sure the right devices are talking to each other and that their conversations are private from the very beginning.
Implementation¶
Discovery process is implemented both on the server and the user's mobile device.
Server Side Implementation¶
1. Building a Discovery QR Code¶
2. Managing discovery requests¶
Mobile App Implementation¶
While QR code scanning is a common method for discovery, there are alternative approaches for connecting mobile apps to servers using Self:
-
Direct Connection: If the mobile app knows the server's address, developers can use the
connectionNegotiate
method from the mobile SDK to connect directly to the server. This approach bypasses the need for QR code scanning, making the discovery process implicit. -
QR Code Scanning: The traditional method where users scan a QR code displayed by the server to initiate the connection.
-
Dynamic Links: Self does not support dynamic links for the discovery process yet, but this feature may be considered for future updates.
Call this below method from Account
instance.
Conclusion¶
The discovery process allows users to securely discover and connect on the Self network, preserving necessary information for ongoing communication.