### Create New Git Branch (Bash) Source: https://github.com/zhangxichang/dp2p/blob/main/docs/CONTRIBUTING.md This code snippet shows how to create a new branch in Git, typically for feature development or bug fixes. It uses the `git checkout -b` command, starting from the latest `main` branch. ```bash git checkout -b ``` -------------------------------- ### SolidJS Store Management Source: https://context7.com/zhangxichang/dp2p/llms.txt Explains the SolidJS store pattern used for state management, including initialization of main and home stores, context provision, and consumption within components. ```APIDOC ## SolidJS Store Pattern ### Description This section details the SolidJS store pattern for managing application state, including global state, P2P endpoints, and SQLite connections. ### Usage 1. **Initialization**: Create instances of `MainStore` and `HomeStore`. ```typescript const mainStore = await MainStore.new(); const homeStore = await HomeStore.new(mainStore, "user_abc123"); ``` 2. **Context Provision**: Provide the stores as context in your application's root component. ```typescript {/* ... */} ``` 3. **Context Consumption**: Access stores in child components using `use_context`. ```typescript const mainStore = use_context(MainContext); ``` 4. **Cleanup**: Ensure stores are properly cleaned up to release resources. ```typescript await mainStore.cleanup(); ``` ``` -------------------------------- ### TypeScript - SolidJS Store Pattern for State Management Source: https://context7.com/zhangxichang/dp2p/llms.txt Illustrates the implementation of a store pattern using SolidJS contexts for managing global application state. This includes initializing and using stores for app-wide data, user-specific data, and managing P2P endpoints and SQLite connections. It also demonstrates how to provide and consume context in SolidJS components and handle cleanup. ```typescript // TypeScript - Store initialization and usage import { MainStore } from "~/stores/main"; import { HomeStore } from "~/stores/home"; import { MainContext, HomeContext, use_context } from "~/components/context"; // Initialize main store (app-wide) const mainStore = await MainStore.new(); // Initializes: SQLite module, Endpoint module, database connection // Create home store for authenticated user const homeStore = await HomeStore.new(mainStore, "user_abc123"); // Queries user from DB, creates P2P endpoint with user's credentials // In components - provide context function App() { const [mainStore] = createResource(() => MainStore.new()); return ( ); } // In child components - consume context function LoginComponent() { const mainStore = use_context(MainContext); // Query users from SQLite const [users] = createResource(async () => { return await mainStore.sqlite.query<{ id: string; name: string }>( QueryBuilder.selectFrom("user").select(["id", "name"]).compile() ); }); // Generate new user credentials async function registerUser(name: string) { const secretKey = await mainStore.endpoint_module.generate_secret_key(); const userId = await mainStore.endpoint_module.get_secret_key_id(secretKey); await mainStore.sqlite.execute( QueryBuilder.insertInto("user") .values({ id: userId, key: secretKey, name, bio: "New user" }) .compile() ); } return (/* JSX */); } // Home component with P2P endpoint function HomeComponent() { const mainStore = use_context(MainContext); const homeStore = use_context(HomeContext); // Access P2P endpoint const endpoint = homeStore.endpoint; // Cleanup on unmount onCleanup(async () => { await homeStore.cleanup(); // Closes P2P connection }); } // Store cleanup await mainStore.cleanup(); // Closes SQLite, frees modules ``` -------------------------------- ### SQLite Operations with Kysely - TypeScript Source: https://context7.com/zhangxichang/dp2p/llms.txt Demonstrates local data persistence using SQLite with the Kysely query builder in TypeScript. It covers schema creation, data insertion, querying with conditions, updates, deletions, and subscribing to database changes. Requires 'tokio-rusqlite' for native or 'wa-sqlite' with OPFS for web environments. ```typescript // TypeScript - SQLite operations with Kysely query builder import { QueryBuilder } from "~/lib/query_builder"; import type { SQLite } from "~/lib/sqlite/interface"; // Initialize SQLite (abstracted for native/web) const sqlite: SQLite = await sqliteModule.create_sqlite("data.db"); // Execute raw SQL for schema creation await sqlite.execute_sql(` CREATE TABLE IF NOT EXISTS user ( id TEXT PRIMARY KEY, key BLOB NOT NULL, name TEXT UNIQUE NOT NULL, avatar BLOB, bio TEXT DEFAULT 'No bio yet' ); CREATE TABLE IF NOT EXISTS friend ( id TEXT PRIMARY KEY, user_id TEXT NOT NULL, name TEXT NOT NULL, avatar BLOB, bio TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS message ( id INTEGER PRIMARY KEY AUTOINCREMENT, sender_id TEXT NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, text TEXT NOT NULL ); `); // Insert new user with type-safe query builder const secretKey = new Uint8Array([/* ... */]); await sqlite.execute( QueryBuilder.insertInto("user") .values({ id: "user_abc123", key: secretKey, name: "Charlie", avatar: null, bio: "Hello world!" }) .compile() ); // Query users const users = await sqlite.query<{ id: string; name: string; avatar?: Uint8Array }>( QueryBuilder.selectFrom("user") .select(["id", "name", "avatar"]) .compile() ); console.log(`Found ${users.length} users`); // Query with conditions const user = await sqlite.query<{ key: Uint8Array; name: string; bio: string }>( QueryBuilder.selectFrom("user") .select(["key", "name", "bio"]) .where("id", "=", "user_abc123") .limit(1) .compile() ); // Update user await sqlite.execute( QueryBuilder.updateTable("user") .set({ bio: "Updated bio!" }) .where("id", "=", "user_abc123") .compile() ); // Delete user await sqlite.execute( QueryBuilder.deleteFrom("user") .where("id", "=", "user_abc123") .compile() ); // Subscribe to database changes const unsubscribe = sqlite.on_update((event) => { console.log(`Table ${event.table_name}: ${event.update_type} on row ${event.row_id}`); // update_type: 9 = DELETE, 18 = INSERT, 23 = UPDATE }); // Cleanup await sqlite.close(); ``` -------------------------------- ### Rust Endpoint API for P2P Networking Source: https://context7.com/zhangxichang/dp2p/llms.txt Demonstrates creating and managing P2P connections using the Rust Endpoint API. It covers identity generation, user profile creation, connecting to the P2P network, requesting peer information, managing friend requests, initiating chat connections, checking connection quality, and creating/joining group chats. Dependencies include the 'endpoint' and 'person_protocol' crates. ```rust use endpoint::{Endpoint, generate_secret_key, get_secret_key_id, generate_ticket}; use person_protocol::Person; // Generate a new cryptographic identity let secret_key = generate_secret_key(); let user_id = get_secret_key_id(secret_key.clone())?; println!("User ID: {}", user_id); // Create user profile let person = Person { name: "Alice".to_string(), avatar: None, bio: "Hello, I'm Alice!".to_string(), }; // Initialize endpoint and connect to P2P network let endpoint = Endpoint::new(secret_key, person).await?; println!("Connected with ID: {}", endpoint.id()); // Request another user's profile let peer_id = "abc123..."; // Remote peer's EndpointId let remote_person = endpoint.request_person(peer_id.to_string()).await?; println!("Found peer: {}", remote_person.name); // Send friend request let accepted = endpoint.request_friend(peer_id.to_string()).await?; if accepted { // Initiate chat connection if let Some(chat_handle) = endpoint.request_chat(peer_id.to_string()).await? { println!("Chat established with handle: {}", chat_handle); } } // Check connection quality let conn_type = endpoint.conn_type(peer_id.to_string())?; let latency_ms = endpoint.latency(peer_id.to_string())?; // Create and join group chat let group_id = endpoint::generate_group_id(); let bootstrap_peers = vec![user_id.clone()]; let ticket = endpoint::generate_ticket(group_id, bootstrap_peers)?; let group_handle = endpoint.subscribe_group(ticket).await?; // Cleanup endpoint.close().await?; ``` -------------------------------- ### Endpoint API - Create and Manage P2P Connections (Rust) Source: https://context7.com/zhangxichang/dp2p/llms.txt This section details the Rust implementation for creating and managing P2P connections using the DP2P Endpoint API. It covers identity generation, user profile creation, network connection, and communication with peers. ```APIDOC ## POST /api/endpoint ### Description This endpoint allows for the creation and management of P2P connections within the DP2P network. It handles user identity, peer communication, and group chat functionalities. ### Method POST ### Endpoint /api/endpoint ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **secret_key** (string) - Required - The cryptographic secret key for the user. - **person** (object) - Required - User profile information. - **name** (string) - Required - The user's name. - **avatar** (string) - Optional - URL or identifier for the user's avatar. - **bio** (string) - Optional - A short biography for the user. ### Request Example ```json { "secret_key": "generated_secret_key_string", "person": { "name": "Alice", "bio": "Hello, I'm Alice!" } } ``` ### Response #### Success Response (200) - **endpoint_id** (string) - The unique identifier for the created endpoint. - **status** (string) - Indicates the connection status. #### Response Example ```json { "endpoint_id": "user_id_from_secret_key", "status": "Connected" } ``` ## GET /api/endpoint/{peer_id}/person ### Description Retrieves the profile information of a remote peer. ### Method GET ### Endpoint /api/endpoint/{peer_id}/person ### Parameters #### Path Parameters - **peer_id** (string) - Required - The unique identifier of the remote peer. #### Query Parameters None #### Request Body None ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **person** (object) - The profile information of the remote peer. - **name** (string) - The peer's name. - **avatar** (string) - Optional - URL or identifier for the peer's avatar. - **bio** (string) - Optional - A short biography for the peer. #### Response Example ```json { "person": { "name": "Bob", "bio": "Hello from Bob!" } } ``` ## POST /api/endpoint/{peer_id}/friend_request ### Description Sends a friend request to a specified peer. ### Method POST ### Endpoint /api/endpoint/{peer_id}/friend_request ### Parameters #### Path Parameters - **peer_id** (string) - Required - The unique identifier of the peer to send the request to. #### Query Parameters None #### Request Body None ### Request Example (No request body for this action) ### Response #### Success Response (200) - **accepted** (boolean) - True if the friend request was accepted, false otherwise. #### Response Example ```json { "accepted": true } ``` ## POST /api/endpoint/{peer_id}/chat_request ### Description Initiates a chat connection with a specified peer. ### Method POST ### Endpoint /api/endpoint/{peer_id}/chat_request ### Parameters #### Path Parameters - **peer_id** (string) - Required - The unique identifier of the peer to initiate a chat with. #### Query Parameters None #### Request Body None ### Request Example (No request body for this action) ### Response #### Success Response (200) - **chat_handle** (string) - A handle for the established chat connection, or null if connection failed. #### Response Example ```json { "chat_handle": "chat_connection_identifier" } ``` ## GET /api/endpoint/{peer_id}/connection_type ### Description Retrieves the connection type to a specified peer. ### Method GET ### Endpoint /api/endpoint/{peer_id}/connection_type ### Parameters #### Path Parameters - **peer_id** (string) - Required - The unique identifier of the peer. #### Query Parameters None #### Request Body None ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **connection_type** (string) - The type of connection (e.g., "Direct", "Relay", "Mixed", "None"). #### Response Example ```json { "connection_type": "Direct" } ``` ## GET /api/endpoint/{peer_id}/latency ### Description Retrieves the latency in milliseconds to a specified peer. ### Method GET ### Endpoint /api/endpoint/{peer_id}/latency ### Parameters #### Path Parameters - **peer_id** (string) - Required - The unique identifier of the peer. #### Query Parameters None #### Request Body None ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **latency_ms** (integer) - The latency to the peer in milliseconds. #### Response Example ```json { "latency_ms": 50 } ``` ## POST /api/endpoint/group/subscribe ### Description Subscribes to a group chat using a generated ticket. ### Method POST ### Endpoint /api/endpoint/group/subscribe ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **ticket** (object) - Required - The invitation ticket for the group. - **group_id** (string) - Required - The ID of the group. - **bootstrap_peers** (array) - Required - A list of peer IDs to bootstrap the connection. - **peer_id** (string) - The identifier of a bootstrap peer. ### Request Example ```json { "ticket": { "group_id": "generated_group_id", "bootstrap_peers": ["user_id_from_secret_key"] } } ``` ### Response #### Success Response (200) - **group_handle** (string) - A handle for the subscribed group chat. #### Response Example ```json { "group_handle": "group_chat_identifier" } ``` ## DELETE /api/endpoint ### Description Closes the current P2P endpoint and disconnects from the network. ### Method DELETE ### Endpoint /api/endpoint ### Parameters None ### Request Example (No request body for DELETE requests) ### Response #### Success Response (200) - **status** (string) - Indicates the status of the closure (e.g., "Disconnected"). #### Response Example ```json { "status": "Disconnected" } ``` ``` -------------------------------- ### Clone DP2P Repository (Bash) Source: https://github.com/zhangxichang/dp2p/blob/main/docs/CONTRIBUTING.md This snippet demonstrates how to clone the DP2P repository from GitHub to your local machine. It involves using the `git clone` command followed by changing the directory into the cloned repository. ```bash git clone https://github.com/your-username/dp2p cd dp2p ``` -------------------------------- ### WebAssembly Endpoint Bindings (TypeScript) Source: https://context7.com/zhangxichang/dp2p/llms.txt This section provides documentation for using the DP2P Endpoint API from JavaScript/TypeScript environments via WebAssembly. It covers initialization, identity generation, peer interaction, and group chat subscription. ```APIDOC ## Initialization ### Description Initializes the WebAssembly module for the DP2P endpoint. ### Method `init()` ### Endpoint N/A (Module function) ### Parameters None ### Request Example ```typescript import init from '@dp2p/endpoint'; await init(); ``` ## Endpoint Creation ### Description Creates a new DP2P endpoint instance with a user profile. ### Method `Endpoint.new(secretKey, person)` ### Endpoint N/A (Class method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **secretKey** (string) - Required - The cryptographic secret key. - **person** (object) - Required - User profile object. - **name** (string) - Required - The user's name. - **avatar** (null | string) - Optional - User's avatar URL or identifier. - **bio** (string) - Optional - User's biography. ### Request Example ```typescript const secretKey = generate_secret_key(); const person = { name: "Bob", avatar: null, bio: "Web user connecting via WASM" }; const endpoint = await Endpoint.new(secretKey, person); ``` ### Response #### Success Response - **endpoint** (Endpoint) - An instance of the Endpoint class. #### Response Example ```typescript // endpoint object is returned ``` ## Request Peer Information ### Description Requests profile information from a remote peer. ### Method `endpoint.request_person(peerId)` ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **peerId** (string) - Required - The ID of the peer to request information from. ### Request Example ```typescript const peerInfo = await endpoint.request_person(peerId); console.log(peerInfo.name); ``` ### Response #### Success Response - **peerInfo** (object) - The profile information of the peer. - **name** (string) - Peer's name. - **avatar** (null | string) - Peer's avatar. - **bio** (string) - Peer's biography. #### Response Example ```json { "name": "Alice", "avatar": null, "bio": "Hello from Alice!" } ``` ## Subscribe to Group Chat ### Description Subscribes to a group chat using an invitation ticket. ### Method `endpoint.subscribe_group(ticket)` ### Endpoint N/A (Instance method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **ticket** (object) - Required - The invitation ticket. - **groupId** (string) - Required - The ID of the group. - **bootstrapPeers** (array) - Required - An array of peer IDs for bootstrapping. - **peerId** (string) - A peer ID. ### Request Example ```typescript const groupId = generate_group_id(); const ticket = generate_ticket(groupId, [userId]); const groupHandle = await endpoint.subscribe_group(ticket); ``` ### Response #### Success Response - **groupHandle** (string) - A handle to the subscribed group chat. #### Response Example ```json { "groupHandle": "group_chat_identifier" } ``` ## Event Handling ### Description Listens for and processes incoming events such as friend requests and chat requests. ### Method `endpoint.person_protocol_next_event()` and `endpoint.person_protocol_event(key)` ### Endpoint N/A (Instance methods) ### Parameters - `person_protocol_next_event()`: None - `person_protocol_event(key)`: - **key** (string) - Required - The key of the event data to retrieve (e.g., "remote_id", "accept"). ### Request Example ```typescript async function handleEvents() { while (true) { const eventType = await endpoint.person_protocol_next_event(); if (eventType === "FriendRequest") { const remoteId = endpoint.person_protocol_event("remote_id"); endpoint.person_protocol_event("accept"); } if (eventType === "ChatRequest") { const chatHandle = endpoint.person_protocol_event("accept"); } } } ``` ### Response #### Success Response - `person_protocol_next_event()` returns a string representing the event type. - `person_protocol_event(key)` returns the value associated with the requested key. #### Response Example ```json // For FriendRequest: // eventType = "FriendRequest" // remoteId = "peer_id_string" // For ChatRequest: // eventType = "ChatRequest" // chatHandle = "chat_handle_string" ``` ## Endpoint Cleanup ### Description Closes the endpoint and cleans up resources. ### Method `endpoint.close()` ### Endpoint N/A (Instance method) ### Parameters None ### Request Example ```typescript await endpoint.close(); ``` ### Response #### Success Response None (typically returns a Promise that resolves when closed). #### Response Example (No specific response body) ``` -------------------------------- ### TypeScript WASM Bindings for P2P Communication Source: https://context7.com/zhangxichang/dp2p/llms.txt Shows how to use the WebAssembly Endpoint module in JavaScript/TypeScript for browser-based P2P communication. It covers initializing the WASM module, generating identities, creating endpoints, handling incoming events like friend and chat requests, requesting peer information, and creating group invites. This enables the same P2P functionality as the Rust backend but within a web environment. ```typescript import init, { Endpoint, generate_secret_key, get_secret_key_id, generate_group_id, generate_ticket } from '@dp2p/endpoint'; // Initialize WASM module await init(); // Generate cryptographic identity const secretKey = generate_secret_key(); const userId = get_secret_key_id(secretKey); console.log(`Generated user ID: ${userId}`); // Create endpoint with user profile const person = { name: "Bob", avatar: null, bio: "Web user connecting via WASM" }; const endpoint = await Endpoint.new(secretKey, person); console.log(`Connected as: ${endpoint.id()}`); // Listen for incoming events (friend requests, chat requests) async function handleEvents() { while (true) { const eventType = await endpoint.person_protocol_next_event(); if (eventType === "FriendRequest") { const remoteId = endpoint.person_protocol_event("remote_id"); console.log(`Friend request from: ${remoteId}`); endpoint.person_protocol_event("accept"); // or "reject" } if (eventType === "ChatRequest") { const remoteId = endpoint.person_protocol_event("remote_id"); const chatHandle = endpoint.person_protocol_event("accept"); console.log(`Chat accepted, handle: ${chatHandle}`); } } } // Request peer information const peerId = "xyz789..."; const peerInfo = await endpoint.request_person(peerId); console.log(`Peer name: ${peerInfo.name}, bio: ${peerInfo.bio}`); // Create group and generate invite ticket const groupId = generate_group_id(); const ticket = generate_ticket(groupId, [userId]); const groupHandle = await endpoint.subscribe_group(ticket); // Cleanup await endpoint.close(); ``` -------------------------------- ### TauRPC SQLite Operations Source: https://context7.com/zhangxichang/dp2p/llms.txt Illustrates how to use TauRPC to perform SQLite database operations, including opening connections, executing SQL queries, and closing connections. ```APIDOC ## POST /rpc/sqlite ### Description Interact with the TauRPC sqlite module for database operations. ### Method POST ### Endpoint /rpc/sqlite ### Parameters #### Request Body - **method** (string) - Required - The method to call on the sqlite module (e.g., `open_db`, `execute_sql`). - **params** (array) - Optional - An array of parameters to pass to the method. ### Request Example ```json { "method": "open_db", "params": ["data.db"] } ``` ### Response #### Success Response (200) - **result** (any) - The result of the method call. #### Response Example ```json { "result": "some_db_handle_or_row_data" } ``` ``` -------------------------------- ### Person Protocol for P2P Discovery and Messaging - Rust Source: https://context7.com/zhangxichang/dp2p/llms.txt Implements the Person Protocol for P2P user discovery and messaging using Iroh's QUIC. This Rust code handles incoming friend and chat requests, allows requesting peer profiles, sending friend requests, and establishing chat sessions. It relies on the 'person_protocol' and 'iroh' crates. ```rust // Rust - Person Protocol implementation use person_protocol::{PersonProtocol, Person, Event, FriendRequest, ChatRequest}; use iroh::Endpoint; // Create protocol handler let person = Person { name: "David".to_string(), avatar: Some(vec![/* PNG bytes */]), bio: "Rust developer".to_string(), }; let protocol = PersonProtocol::new(endpoint.clone(), person); // Handle incoming events loop { match protocol.next_event().await? { Event::FriendRequest(request) => { let remote_id = request.remote_id(); println!("Friend request from: {}", remote_id); // Accept or reject the request if should_accept(remote_id) { request.accept()?; } else { request.reject()?; } } Event::ChatRequest(request) => { let remote_id = request.remote_id(); println!("Chat request from: {}", remote_id); // Accept returns the connection for messaging let connection = request.accept()?; // Use connection for bidirectional streaming } } } // Outbound requests let peer_id: EndpointId = "xyz...".parse()?; // Get peer's profile let peer_person = protocol.request_person(peer_id).await?; println!("Peer: {} - {}", peer_person.name, peer_person.bio); // Send friend request (returns true if accepted) let accepted = protocol.request_friend(peer_id).await?; // Request chat session if let Some(connection) = protocol.request_chat(peer_id).await? { // Chat session established - use connection for messaging let (send, recv) = connection.open_bi().await?; send.write_all(b"Hello!").await?; } ``` -------------------------------- ### Push Branch to Remote Repository (Bash) Source: https://github.com/zhangxichang/dp2p/blob/main/docs/CONTRIBUTING.md This command is used to push your local branch changes to your forked remote repository on GitHub. It ensures that your contributions are available for review. ```bash git push origin ``` -------------------------------- ### TypeScript - Interact with TauRPC IPC Endpoints Source: https://context7.com/zhangxichang/dp2p/llms.txt Demonstrates how to use TauRPC to interact with various IPC endpoints from the frontend. It covers operations like generating secret keys, opening and managing P2P endpoints, requesting peer information, handling friend and chat requests, performing connection diagnostics, managing group chats, and closing endpoints. It also shows how to perform SQLite operations via TauRPC. ```typescript // TypeScript - Using TauRPC from the frontend import { createTauRPCProxy } from "~/generated/ipc_bindings"; const rpc = createTauRPCProxy(); // Endpoint operations const secretKey = await rpc.endpoint.generate_secret_key(); const userId = await rpc.endpoint.get_secret_key_id(Array.from(secretKey)); // Open P2P endpoint const handle = await rpc.endpoint.open_endpoint( Array.from(secretKey), { name: "Eve", avatar: null, bio: "Native app user" } ); // Get endpoint ID const endpointId = await rpc.endpoint.id(handle); // Request peer info const peerInfo = await rpc.endpoint.request_person(handle, "peer_xyz..."); // Friend and chat requests const friendAccepted = await rpc.endpoint.request_friend(handle, "peer_xyz..."); const chatHandle = await rpc.endpoint.request_chat(handle, "peer_xyz..."); // Connection diagnostics const connType = await rpc.endpoint.conn_type(handle, "peer_xyz..."); // Direct/Relay/Mixed/None const latency = await rpc.endpoint.latency(handle, "peer_xyz..."); // milliseconds // Group chat const groupId = await rpc.endpoint.generate_group_id(); const ticket = await rpc.endpoint.generate_ticket(groupId, [endpointId]); const groupHandle = await rpc.endpoint.subscribe_group(handle, ticket); // Close endpoint await rpc.endpoint.close_endpoint(handle); // SQLite operations via TauRPC const dbHandle = await rpc.sqlite.open_db("data.db"); await rpc.sqlite.execute_sql(dbHandle, "CREATE TABLE IF NOT EXISTS test (id INT)"); const rows = await rpc.sqlite.query(dbHandle, "SELECT * FROM user", []); await rpc.sqlite.close_db(dbHandle); ``` -------------------------------- ### TauRPC Endpoint Operations Source: https://context7.com/zhangxichang/dp2p/llms.txt Demonstrates how to use TauRPC to interact with the endpoint module for P2P communication, including generating keys, opening endpoints, managing connections, and handling friend/chat requests. ```APIDOC ## POST /rpc/endpoint ### Description Interact with the TauRPC endpoint module for peer-to-peer communication. ### Method POST ### Endpoint /rpc/endpoint ### Parameters #### Request Body - **method** (string) - Required - The method to call on the endpoint module (e.g., `generate_secret_key`, `open_endpoint`). - **params** (array) - Optional - An array of parameters to pass to the method. ### Request Example ```json { "method": "generate_secret_key", "params": [] } ``` ### Response #### Success Response (200) - **result** (any) - The result of the method call. #### Response Example ```json { "result": "some_secret_key_or_handle" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.