### Install Dependencies and Start Development Server Source: https://pubky.org/explore/technologies/pubky-explorer Install project dependencies and start the development server for local testing. Access the application via http://localhost:5173. ```bash npm install npm run dev # Open browser to http://localhost:5173 ``` -------------------------------- ### Quick Start: JavaScript Example Source: https://pubky.org/explore/pubkycore/introduction A basic JavaScript example demonstrating how to create a Pubky client, sign up for a homeserver, store, and retrieve JSON data. ```javascript import { Pubky, Keypair } from "@synonymdev/pubky"; // Create client and signer const pubky = new Pubky(); const signer = pubky.signer(Keypair.random()); // Sign up (pass signup token for gated homeservers, null for open/testnet) const session = await signer.signup(homeserverPk, null); // Store data await session.storage.putJson("/pub/myapp/profile", { name: "Alice", bio: "Decentralized and loving it!", }); // Retrieve data const profile = await session.storage.getJson("/pub/myapp/profile"); ``` -------------------------------- ### Quick Start Example for Pubky App (JavaScript) Source: https://pubky.org/explore/pubkycore/getting-started A basic JavaScript example demonstrating how to get started with building a Pubky application. Key concepts include data storage per public key, path structure, HTTP operations, and cryptographic signatures. ```javascript ``` -------------------------------- ### Build and Run Pubky Documentation Locally Source: https://pubky.org/contributing Clone the repository, install dependencies, and start the development server to test changes locally. Visit http://localhost:4321 to view the site. ```bash git clone https://github.com/pubky/pubky-knowledge-base cd pubky-knowledge-base npm install npm run dev # Visit http://localhost:4321 ``` -------------------------------- ### Configure Pubky Environment Variables Source: https://pubky.org/troubleshooting Copy the example environment file and edit it to configure your settings. This is necessary if containers fail to start due to missing environment variables. ```bash cp .env.example .env # Edit .env with your settings ``` -------------------------------- ### Start Local Pubky Homeserver Source: https://pubky.org/explore/technologies/pubky-cli Starts a local Pubky homeserver for development. Requires PostgreSQL and a database_url in the configuration. Use `cargo run -p pubky-homeserver -- --data-dir ~/.pubky` to start. ```bash # Start local homeserver (requires PostgreSQL and database_url in config) cargo run -p pubky-homeserver -- --data-dir ~/.pubky ``` -------------------------------- ### Install Pubky CLI from Source Source: https://pubky.org/explore/technologies/pubky-cli Installs the Pubky CLI by cloning the repository and building from source using Cargo. ```bash git clone https://github.com/pubky/pubky-cli cd pubky-cli cargo install --path . ``` -------------------------------- ### Install Pubky SDK Source: https://pubky.org/explore/pubkycore/introduction Install the Pubky SDK for Rust or JavaScript. For other languages, refer to the SDK documentation. ```bash # Rust cargo add pubky # JavaScript npm install @synonymdev/pubky # See mobile bindings in SDK documentation ``` -------------------------------- ### Install Pubky SDK for JavaScript/TypeScript (npm) Source: https://pubky.org/explore/pubkycore/sdk Install the Pubky SDK for web and Node.js environments using npm. ```bash npm install @synonymdev/pubky ``` -------------------------------- ### Run Development Server Source: https://pubky.org/explore/technologies/homegate After setting up the environment, run database migrations and then start the development server. ```shell # Run database migrations cargo run -- migrate # Start server cargo run ``` -------------------------------- ### PKDNS Configuration File Example Source: https://pubky.org/explore/technologies/pkdns Example TOML configuration file for PKDNS, demonstrating settings for fallback DNS, DoH, rate limiting, and caching. ```toml # Upstream DNS for ICANN domains fallback_dns = "8.8.8.8:53" # Enable DNS-over-HTTPS [doh] enabled = true port = 443 cert_path = "/path/to/cert.pem" key_path = "/path/to/key.pem" # Rate limiting [rate_limit] requests_per_minute = 100 burst_size = 20 # Caching [cache] max_entries = 10000 ttl_seconds = 300 ``` -------------------------------- ### Install Pubky SDK for JavaScript/TypeScript (yarn) Source: https://pubky.org/explore/pubkycore/sdk Install the Pubky SDK for web and Node.js environments using yarn. ```bash yarn add @synonymdev/pubky ``` -------------------------------- ### Install Pubky SDK for JavaScript/TypeScript Source: https://pubky.org/explore/pubkycore/getting-started Install the Pubky SDK for web and Node.js environments using npm or yarn. ```bash npm install @synonymdev/pubky # or yarn add @synonymdev/pubky ``` -------------------------------- ### Clone, Build, and Install Pubky CLI Source: https://pubky.org/contributing Clone the Pubky CLI repository, build the project, and install it locally. Includes commands for running tests and generating shell completions. ```bash # Clone git clone https://github.com/pubky/pubky-cli cd pubky-cli # Build cargo build # Install locally cargo install --path . # Run tests cargo test # Generate completions pubky-cli tools completions bash > completions.bash ``` -------------------------------- ### Install Dependencies and Run App Source: https://pubky.org/explore/technologies/pubky-ring Install project dependencies using Yarn and then run the application on iOS or Android. For iOS, CocoaPods are also required. ```bash # Install dependencies yarn install cd ios && pod install && cd .. # Run on iOS yarn ios # Run on Android yarn android ``` -------------------------------- ### Start Pubky Explorer Development Server Source: https://pubky.org/explore/technologies/pubky-explorer Start the development server for Pubky Explorer. Access the application at http://localhost:5173. ```bash npm run dev ``` -------------------------------- ### Serve Pubky Project Locally Source: https://pubky.org/explore/technologies/pubky-cli Command to start a local development server for Pubky projects. ```bash pubky serve ``` -------------------------------- ### Build and Install Pubky CLI (Rust) Source: https://pubky.org/contributing Commands to clone, build, and locally install the Pubky CLI Rust project. Also includes instructions for running tests and generating shell completions. ```bash git clone https://github.com/pubky/pubky-cli cd pubky-cli # Build cargo build # Install locally cargo install --path . # Run tests cargo test # Generate completions pubky-cli tools completions bash > completions.bash ``` -------------------------------- ### Clone Repository and Start Nexus Source: https://pubky.org/explore/pubky-apps/indexing-and-aggregation/pubky-nexus Clone the Pubky Nexus repository and start the service using Cargo. Ensure databases are set up via Docker Compose. ```bash # Clone the repository git clone https://github.com/pubky/pubky-nexus cd pubky-nexus # Set up databases via Docker cd docker cp .env-sample .env docker compose up -d # Run the service (uses default config) cargo run -p nexusd ``` -------------------------------- ### Capability Scoping Examples Source: https://pubky.org/explore/pubkycore/security-model Illustrates how capabilities are used to scope permissions for accessing resources. These examples show read/write access to directories and files, emphasizing the principle of least privilege. ```text /pub/my-app/:rw # Read+write to specific directory only ``` ```text /pub/file.txt:r # Read-only single file ``` ```text /:rw # Root access (avoid when possible) ``` -------------------------------- ### PKDNS TOML Configuration File Example Source: https://pubky.org/explore/technologies/pkdns Example configuration for PKDNS using TOML format. Specifies upstream DNS, DoH settings, rate limiting parameters, and caching options. ```toml # Upstream DNS for ICANN domains fallback_dns = "8.8.8.8:53" # Enable DNS-over-HTTPS [doh] enabled = true port = 443 cert_path = "/path/to/cert.pem" key_path = "/path/to/key.pem" # Rate limiting [rate_limit] requests_per_minute = 100 burst_size = 20 # Caching [cache] max_entries = 10000 ttl_seconds = 300 ``` -------------------------------- ### Markdown Linking Examples Source: https://pubky.org/contributing Demonstrates how to create internal and external links using Markdown. ```markdown [Pubky Core](/explore/pubkycore/introduction/) [Official Docs](https://docs.pubky.org/) ``` -------------------------------- ### Set Up Databases with Docker Compose Source: https://pubky.org/explore/pubky-apps/indexing-and-aggregation/pubky-nexus Navigate to the docker directory, copy the environment file, and start the databases using Docker Compose. ```bash cd docker cp .env-sample .env docker compose up -d ``` -------------------------------- ### Clone Repository and Set Up Environment Source: https://pubky.org/explore/technologies/homegate Clone the Homegate repository, navigate into the directory, copy the example environment file, and edit it with your credentials. ```shell git clone https://github.com/pubky/homegate cd homegate cp .env.example .env # Edit .env with your credentials ``` -------------------------------- ### Setup and Run Pubky Ring (React Native) Source: https://pubky.org/contributing Instructions for cloning, installing dependencies, and running the Pubky Ring React Native application on iOS and Android. Requires Node.js >= 22.11.0 and Yarn 1.x. ```bash git clone https://github.com/pubky/pubky-ring cd pubky-ring # Install dependencies yarn install cd ios && pod install && cd .. # Run on iOS yarn ios # Run on Android yarn android # Run tests yarn test # Lint yarn lint ``` -------------------------------- ### Install Pubky SDK for React Native Source: https://pubky.org/explore/pubkycore/getting-started Install the Pubky SDK for React Native projects and run pod install for iOS. ```bash npm install @synonymdev/react-native-pubky cd ios && pod install # iOS only ``` -------------------------------- ### Start Homegate Service in Production Source: https://pubky.org/explore/technologies/homegate Launch the Homegate service using the compiled release binary for production deployment. ```bash ./target/release/homegate serve ``` -------------------------------- ### Clone and Set Up Homegate for Development Source: https://pubky.org/explore/technologies/homegate Steps to clone the Homegate repository, copy the example environment file, and edit it with your credentials for local development. ```bash # Clone repository git clone https://github.com/pubky/homegate cd homegate # Set up environment cp .env.example .env # Edit .env with your credentials ``` -------------------------------- ### Build and Run Production Binary Source: https://pubky.org/explore/technologies/homegate Build a release binary for production, run database migrations, and then start the service. ```shell # Build release binary cargo build --release # Run migrations ./target/release/homegate migrate # Start service ./target/release/homegate serve ``` -------------------------------- ### Install Pubky React Native Package Source: https://pubky.org/explore/pubkycore/sdk Installs the Pubky React Native package using npm or yarn, and installs CocoaPods dependencies for iOS. This command should be run in a React Native project's terminal. ```bash npm install @synonymdev/react-native-pubky# or yarn add @synonymdev/react-native-pubky For iOS, also run: cd ios && pod install ``` -------------------------------- ### Clone and Install Pubky Explorer Source: https://pubky.org/explore/technologies/pubky-explorer Clone the Pubky Explorer repository and install its dependencies using npm. ```bash git clone https://github.com/pubky/pubky-explorer cd pubky-explorer npm install ``` -------------------------------- ### Verify Pubky CLI Installation Source: https://pubky.org/explore/technologies/pubky-cli Checks if the Pubky CLI has been installed correctly by displaying its version information. ```bash pubky-cli --version ``` -------------------------------- ### Sign Up (Create Account on Homeserver) Source: https://pubky.org/explore/pubkycore/sdk Creates a new user account on a homeserver. For gated homeservers, a signup token from Homegate is required. Pass `None`/`null` for open homeservers or local testnets. ```APIDOC ## Sign Up (Create Account on Homeserver) Creates a new user account on a homeserver. For gated homeservers, a signup token from Homegate is required. Pass `None`/`null` for open homeservers or local testnets. ### Rust ```rust // Rust code for sign up ``` ### JavaScript ```javascript // JavaScript code for sign up ``` ``` -------------------------------- ### Simple Profile Storage with Pubky Core Source: https://pubky.org/explore/pubkycore/sdk Illustrates creating a Pubky instance, generating a keypair, signing up at a homeserver, and storing/retrieving a JSON profile. This example uses the core `pubky` crate and follows `pubky-app-specs`. ```javascript import { Pubky, Keypair } from "@synonymdev/pubky"; async function storeProfile() { const pubky = new Pubky(); const keypair = Keypair.random(); const signer = pubky.signer(keypair); // Sign up at a homeserver (null token for open/testnet homeservers) const session = await signer.signup(homeserverPk, signupToken); console.log(`Public Key: ${signer.publicKey.z32()}`); // Store profile (following pubky-app-specs format) const profile = { name: "Alice", bio: "Building on Pubky", image: "pubky://user_id/pub/pubky.app/files/0000000000000", links: [{ title: "GitHub", url: "https://github.com/alice" }], status: "Exploring decentralized tech.", }; // Store at standard pubky-app location await session.storage.putJson("/pub/pubky.app/profile.json", profile); console.log("Profile stored!"); // Retrieve profile const retrieved = await session.storage.getJson( "/pub/pubky.app/profile.json", ); console.log("Retrieved:", retrieved); } ``` -------------------------------- ### Start Pubky Docker Stack Source: https://pubky.org/explore/technologies/pubky-docker Start all Pubky services in detached mode using Docker Compose. ```bash docker compose up -d ``` -------------------------------- ### Sign Up User (JavaScript) Source: https://pubky.org/explore/pubkycore/sdk Creates a new user account on a homeserver. Requires a signup token for gated homeservers. Use `null` for open homeservers or local testnets. ```javascript const signer = pubky.signer(keypair); const session = await signer.signup(homeserverPk, signupToken); ``` -------------------------------- ### Retrieve Data (GET) Source: https://pubky.org/explore/pubkycore/sdk Retrieves data from a specified storage path. This operation uses the GET method. ```APIDOC ## Retrieve Data (GET) Retrieves data from a specified storage path. This operation uses the GET method. ### Rust ```rust // Rust code for retrieving data (GET) ``` ### JavaScript ```javascript // JavaScript code for retrieving data (GET) ``` ``` -------------------------------- ### Start Homegate Server in Development Source: https://pubky.org/explore/technologies/homegate Launch the Homegate server for development purposes using the Cargo command. ```bash cargo run ``` -------------------------------- ### Automated User Onboarding Script Source: https://pubky.org/explore/technologies/pubky-cli An example workflow script for automating user onboarding. It covers generating a recovery file, signing up, signing in, and publishing an initial profile using the Pubky CLI. ```bash #!/bin/bash # Automated user onboarding script # 1. Generate recovery file pubky-cli tools generate-recovery ./user.recovery --passphrase $PASSWORD # 2. Sign up PUBKY_CLI_RECOVERY_PASSPHRASE=$PASSWORD \ pubky-cli user signup $HOMESERVER_PK ./user.recovery --testnet # 3. Sign in PUBKY_CLI_RECOVERY_PASSPHRASE=$PASSWORD \ pubky-cli user signin ./user.recovery --testnet # 4. Publish initial profile PUBKY_CLI_RECOVERY_PASSPHRASE=$PASSWORD \ pubky-cli user publish "/pub/pubky.app/profile.json" ./profile.json ./user.recovery --testnet echo "User onboarded successfully!" ``` -------------------------------- ### Install Pubky SDK for React Native Source: https://pubky.org/explore/pubkycore/getting-started Install the Pubky SDK for React Native projects and link for iOS. ```bash npm install @synonymdev/react-native-pubky ``` ```bash cd ios && pod install ``` -------------------------------- ### Install Pubky SDK for JavaScript/TypeScript Source: https://pubky.org/explore/pubkycore/getting-started Install the Pubky SDK for web and Node.js projects using npm or yarn. ```bash npm install @synonymdev/pubky ``` ```bash yarn add @synonymdev/pubky ``` -------------------------------- ### Build PKDNS from Source Source: https://pubky.org/explore/technologies/pkdns Install the Rust toolchain, clone the PKDNS repository, build the release binary, and then run it. Requires root privileges for port 53 access. ```bash # Install Rust toolchain curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Clone and build git clone https://github.com/pubky/pkdns.git cd pkdns cargo build --release # Run sudo ./target/release/pkdns --verbose ``` -------------------------------- ### Sign Up (Create Account on Homeserver) Source: https://pubky.org/explore/pubkycore/sdk Create a new user account on a homeserver. Requires a signup token for gated homeservers. ```APIDOC ## Sign Up (Create Account on Homeserver) ### Description Create a new user account on a homeserver. For gated homeservers, obtain a signup token via Homegate first. Pass `None`/`null` only for open homeservers or local testnets. ### Rust ```rust use pubky::{Keypair, Pubky, PublicKey}; let pubky = Pubky::new()?; let keypair = Keypair::random(); let homeserver = PublicKey::try_from("8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo").unwrap(); let signer = pubky.signer(keypair); let session = signer.signup(&homeserver, signup_token.as_deref()).await?; ``` ### JavaScript ```javascript const signer = pubky.signer(keypair); const session = await signer.signup(homeserverPk, signupToken); ``` ``` -------------------------------- ### Install Pubky SDK for React Native (yarn) Source: https://pubky.org/explore/pubkycore/sdk Install the Pubky SDK for React Native applications using yarn. ```bash yarn add @synonymdev/react-native-pubky ``` -------------------------------- ### Sign Up for a New Account (JavaScript) Source: https://pubky.org/explore/pubkycore/sdk Creates a new user account on a gated homeserver using a signup token. For open homeservers or local testnets, pass null. ```javascript import { Client } from "@pubky/sdk"; async function js_signup(client, signup_token) { await client.signup(signup_token); } ``` -------------------------------- ### Install Pubky SDK for React Native (npm) Source: https://pubky.org/explore/pubkycore/sdk Install the Pubky SDK for React Native applications using npm. ```bash npm install @synonymdev/react-native-pubky ``` -------------------------------- ### Signup for Pubky Testnet Source: https://pubky.org/explore/technologies/pubky-cli Use this command to sign up a new user on a local testnet environment. Ensure the HOMESERVER_PK environment variable is set. ```bash pubky-cli user signup $HOMESERVER_PK ./recovery --testnet ``` -------------------------------- ### Get Pubky CLI Data Source: https://pubky.org/troubleshooting Use the Pubky CLI to get data from a specified path, requiring a recovery file. ```bash # Test data operations pubky-cli user get /pub/test ./recovery.file ``` -------------------------------- ### Install Pubky CLI from Crates.io Source: https://pubky.org/explore/technologies/pubky-cli Installs the Pubky CLI using Cargo, the Rust package manager, from the official crates.io repository. ```bash cargo install pubky-cli ``` -------------------------------- ### Build PKDNS from Source Source: https://pubky.org/explore/technologies/pkdns Install the Rust toolchain, clone the PKDNS repository, build the release version, and run the executable. Requires root privileges to bind to port 53. ```bash # Install Rust toolchain curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Clone and build git clone https://github.com/pubky/pkdns.git cd pkdns cargo build --release # Runsudo ./target/release/pkdns --verbose ``` -------------------------------- ### Retrieve Data (GET) (JavaScript) Source: https://pubky.org/explore/pubkycore/sdk Retrieves data from a specified path using the GET method. Can be used for public or authenticated data. ```javascript import { Client } from "@pubky/sdk"; async function js_get(client, path) { return await client.get(path); } ``` -------------------------------- ### Copy Environment Sample Source: https://pubky.org/explore/technologies/pubky-docker Copy the sample environment file to start configuring your Docker environment. Refer to the .env-sample file for all available variables. ```bash cp .env-sample .env ``` -------------------------------- ### Retrieve Data (GET) (Rust) Source: https://pubky.org/explore/pubkycore/sdk Retrieves data from a specified path using the GET method. Can be used for public or authenticated data. ```rust use pubky::Client; async fn get(client: &Client, path: &str) -> Vec { client.get(path).await.expect("Failed to get data") } ``` -------------------------------- ### Capability Syntax Examples Source: https://pubky.org/explore/pubkycore/api Examples of capability syntax for defining access control rules. These specify allowed operations and path prefixes. ```plaintext read:/pub/ # Read all public data write:/pub/myapp/ # Write to /pub/myapp/* only *:/pub/myapp/posts/ # Full access to posts read:/pub/social/profile # Read specific path ``` -------------------------------- ### Install E2E Test Drivers Source: https://pubky.org/explore/technologies/pubky-ring Install necessary drivers for end-to-end testing using Appium/WebdriverIO. This step is required before running the E2E tests. ```bash # Install test drivers yarn e2e:drivers ``` -------------------------------- ### Automated User Onboarding Script Source: https://pubky.org/explore/technologies/pubky-cli A bash script demonstrating the automated onboarding of a new user, including recovery file generation, signup, signin, and profile publishing. ```bash #!/bin/bash# Automated user onboarding script # 1. Generate recovery file pubky-cli tools generate-recovery ./user.recovery --passphrase $PASSWORD # 2. Sign up PUBKY_CLI_RECOVERY_PASSPHRASE=$PASSWORD \ pubky-cli user signup $HOMESERVER_PK ./user.recovery --testnet # 3. Sign in PUBKY_CLI_RECOVERY_PASSPHRASE=$PASSWORD \ pubky-cli user signin ./user.recovery --testnet # 4. Publish initial profile PUBKY_CLI_RECOVERY_PASSPHRASE=$PASSWORD \ pubky-cli user publish "/pub/pubky.app/profile.json" ./profile.json ./user.recovery --testnet echo "User onboarded successfully!" ```