### Run Machine Activation Example Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Execute the machine activation example. This requires the default client features. ```bash cargo run --example activate_machine ``` -------------------------------- ### Run License Validation Example Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Execute the license validation example. This requires the default client features. ```bash cargo run --example validate_license ``` -------------------------------- ### Run Product Creation Example (Admin) Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Execute the product creation example. This requires the `admin` feature flag to be enabled. ```bash cargo run --features=admin --example product/create_product ``` -------------------------------- ### Run User Creation Example (Admin) Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Execute the user creation example. This requires the `admin` feature flag to be enabled. ```bash cargo run --features=admin --example user/create_user ``` -------------------------------- ### Run License Creation Example (Admin) Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Execute the license creation example. This requires the `admin` feature flag to be enabled. ```bash cargo run --features=admin --example license/create_license ``` -------------------------------- ### Set Environment Variables for Client Examples Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Set environment variables required for client-side examples, including license key, public key, and product ID. ```bash export KEYGEN_LICENSE_KEY="your-license-key" export KEYGEN_PUBLIC_KEY="your-public-key" export KEYGEN_PRODUCT="your-product-id" ``` -------------------------------- ### Set Environment Variables for Admin Examples Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Set the environment variable required for administrator examples, which is the admin token. ```bash export KEYGEN_ADMIN_TOKEN="your-admin-token" ``` -------------------------------- ### Service Introspection: Ping, Get Info, and Check Feature Support Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Provides examples for interacting with the Keygen service, including checking its availability with `ping`, retrieving detailed service information, and verifying support for specific features like product codes. ```rust use keygen_rs::service; #[tokio::main] async fn main() -> Result<(), Error> { // Check if the service is available service::ping().await?; // Get detailed service information let info = service::get_service_info().await?; println!("API Version: {}", info.api_version); // Check if a specific feature is supported if service::supports_product_code().await? { println!("Product codes are supported!"); } Ok(()) } ``` -------------------------------- ### Product Management Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Provides examples for creating and listing products using the Keygen SDK. ```APIDOC ## Product Management Manages products within the Keygen system. ### Methods - `Product::create(CreateProductRequest)` - `Product::list(Option)` ### Description These methods allow you to programmatically create new products and retrieve a list of existing products. Product creation requires specifying details like name and distribution strategy. ### Request Example ```rust use keygen_rs::product::{Product, CreateProductRequest, DistributionStrategy}; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new product let product = Product::create(CreateProductRequest { name: "My App".to_string(), distribution_strategy: Some(DistributionStrategy::Licensed), platforms: Some(vec![Platform::MacOs, Platform::Windows]), ..Default::default() }).await?; // List all products let products = Product::list(None).await?; Ok(()) } ``` ### Response - **`Product::create`**: Returns the created `Product` object. - **`Product::list`**: Returns a list of `Product` objects. ``` -------------------------------- ### Local Preview Commands Source: https://github.com/ahonn/keygen-rs/blob/master/docs/RELEASE_GUIDE.md Commands to install release-plz locally and preview release or version updates without making actual changes. ```bash cargo install release-plz ``` ```bash release-plz release --dry-run ``` ```bash release-plz update --dry-run ``` -------------------------------- ### Activate a Machine Source: https://github.com/ahonn/keygen-rs/blob/master/README.md This example demonstrates how to activate a machine for a given license key. It first attempts to validate the license and, if it's not activated, proceeds to activate the machine using its fingerprint. ```APIDOC ## Activate a Machine This operation activates a machine for a license if it's not already activated. ### Method ```rust keygen_rs::validate(...).await license.activate(...).await ``` ### Description Attempts to validate an existing license. If the license is found but not activated for the current machine, it proceeds to activate the machine using its unique fingerprint. ### Request Example ```rust use keygen_rs::errors::Error; #[tokio::main] async fn main() -> Result<(), Error> { let fingerprint = machine_uid::get().unwrap_or("".into()); if let Err(err) = keygen_rs::validate(&[fingerprint.clone()], &[]).await { match err { Error::LicenseNotActivated { license, .. } => { let machine = license.activate(&fingerprint, &[]).await?; println!("License activated successfully: {{:?}}", machine); } _ => { println!("License validation failed: {{:?}}", err); } } } else { println!("License validated successfully"); } Ok(()) } ``` ### Response - **Success**: Prints "License activated successfully" or "License validated successfully". - **Error**: Prints "License validation failed" with the error details. ``` -------------------------------- ### Error Handling Example Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Demonstrates how to handle specific errors returned by the Keygen SDK, such as `LicenseNotActivated`. ```APIDOC ## Error Handling Handles SDK errors, specifically `LicenseNotActivated`. ### Method ```rust keygen_rs::validate(...).await license.activate(...).await ``` ### Description This example shows how to use a `match` statement to differentiate between a successful license validation and specific errors. If `LicenseNotActivated` is encountered, it attempts to activate the machine. ### Request Example ```rust use keygen_rs::{config::{self, KeygenConfig}, errors::Error}; #[tokio::main] async fn main() -> Result<(), Error> { config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); let fingerprint = machine_uid::get().unwrap_or("".into()); match keygen_rs::validate(&[fingerprint.clone()], &[]).await { Ok(license) => println!("License is valid: {{:?}}", license), Err(Error::LicenseNotActivated { license, .. }) => { println!("License is not activated. Activating..."); let machine = license.activate(&fingerprint, &[]).await?; println!("Machine activated: {{:?}}", machine); }, Err(e) => println!("Error: {{:?}}", e), } Ok(()) } ``` ### Response - **Success**: Prints "License is valid" or "Machine activated". - **Error**: Prints the specific error encountered. ``` -------------------------------- ### Pre-release Version Configuration Source: https://github.com/ahonn/keygen-rs/blob/master/docs/RELEASE_GUIDE.md Example of how to manually set a pre-release version in Cargo.toml for publishing pre-release versions. ```toml version = "0.8.0-beta.1" ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/ahonn/keygen-rs/blob/master/docs/RELEASE_GUIDE.md Examples of conventional commit messages for new features, bug fixes, breaking changes, scopes, and multi-line descriptions. ```bash git commit -m "feat: add support for offline verification" ``` ```bash git commit -m "fix: correct license validation logic" ``` ```bash git commit -m "feat!: change API response format" ``` ```bash git commit -m "feat(machine): add heartbeat functionality" ``` ```bash git commit -m "fix: resolve memory leak in verification The verifier was not properly releasing memory after signature validation, causing gradual memory increase." ``` -------------------------------- ### Custom Release Notes Example Source: https://github.com/ahonn/keygen-rs/blob/master/docs/RELEASE_GUIDE.md Markdown format for customizing release notes in a PR description, including sections for highlights and breaking changes. ```markdown ## Release Notes ### Highlights - 🚀 Added offline verification support - 🐛 Fixed memory leak issue - 📚 Improved documentation ### Breaking Changes - API response format changed ``` -------------------------------- ### Standard Build and Test in Rust Source: https://github.com/ahonn/keygen-rs/blob/master/CLAUDE.md Use these commands for standard build and testing procedures in a Rust project. Ensure Cargo is installed and the project is set up correctly. ```bash cargo build cargo test --all-features --verbose ``` -------------------------------- ### Offline License Key Verification Source: https://github.com/ahonn/keygen-rs/blob/master/README.md This example shows how to verify a signed license key offline using its signature and the public key. ```APIDOC ## Offline License Key Verification Verifies a signed license key offline. ### Method ```rust keygen_rs::verify(SchemeCode::Ed25519Sign, signed_key) ``` ### Description This function takes a `SchemeCode` (e.g., `Ed25519Sign`) and a signed license key string. It returns the verified license data if the signature is valid, otherwise it returns an error. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use keygen_rs::{config::{self, KeygenConfig}, license::SchemeCode}; fn main() { config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); let signed_key = "YOUR_SIGNED_LICENSE_KEY"; if let Ok(data) = keygen_rs::verify(SchemeCode::Ed25519Sign, signed_key) { println!("License verified: {{:?}}", String::from_utf8_lossy(&data)); } else { println!("License verification failed"); } } ``` ### Response - **Success**: Prints the verified license data. - **Error**: Prints "License verification failed". ``` -------------------------------- ### Access Plugin State and Listen for Changes in Rust Source: https://github.com/ahonn/keygen-rs/blob/master/packages/tauri-plugin-keygen-rs2/README.md Access the plugin's license and machine state, and add a listener for license state changes within your Tauri app's setup function. ```rust tauri::Builder::default() // ... other configurations .setup(|app| { let app_handle = app.handle(); tauri::async_runtime::block_on(async move { let license_state = app_handle.get_license_state(); let license_state = license_state.lock().await; println!("License: {:?}", license_state.license); let machine_state = app_handle.get_machine_state(); let machine_state = machine_state.lock().await; println!("Machine: {:?}", machine_state); tauri_plugin_keygen_rs2::add_license_listener(|state| { println!("License state change: {:?}", state); }).await; }); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` -------------------------------- ### Service Introspection Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Provides methods to check service availability, get service information, and determine feature support. ```APIDOC ## Service Introspection Provides information about the Keygen service. ### Methods - `service::ping()` - `service::get_service_info()` - `service::supports_product_code()` ### Description These methods allow you to check if the Keygen service is reachable (`ping`), retrieve detailed information about the API version and other service metadata (`get_service_info`), and determine if specific features like product codes are supported (`supports_product_code`). ### Request Example ```rust use keygen_rs::service; #[tokio::main] async fn main() -> Result<(), Error> { // Check if the service is available service::ping().await?; // Get detailed service information let info = service::get_service_info().await?; println!("API Version: {{}}", info.api_version); // Check if a specific feature is supported if service::supports_product_code().await? { println!("Product codes are supported!"); } Ok(()) } ``` ### Response - **`service::ping()`**: Returns `()` on success, indicating the service is available. - **`service::get_service_info()`**: Returns service information, including `api_version`. - **`service::supports_product_code()`**: Returns `true` if product codes are supported, `false` otherwise. ``` -------------------------------- ### Manage Software Releases and Artifacts with Keygen Rust SDK Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Demonstrates how to create a new release, list existing releases, and retrieve artifacts for a specific release using the Keygen Rust SDK. Ensure you have the necessary product ID and release ID. ```rust use keygen_rs::release::{Release, CreateReleaseRequest, ListReleasesParams}; use keygen_rs::artifact::Artifact; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new release let release = Release::create(CreateReleaseRequest { name: Some("v1.0.0".to_string()), version: "1.0.0".to_string(), channel: Some("stable".to_string()), ..Default::default() }).await?; // List releases let releases = Release::list(Some(ListReleasesParams { product: Some("PRODUCT_ID".to_string()), ..Default::default() })).await?; // Get artifacts for a release let artifacts = Artifact::list(Some(ListArtifactsParams { release: Some(release.id.clone()), ..Default::default() })).await?; Ok(()) } ``` -------------------------------- ### Configure Keygen SDK for End Users Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Set up the Keygen SDK globally for end-user license key authentication using `KeygenConfig::license_key`. ```rust use keygen_rs::config::{self, KeygenConfig}; config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); ``` -------------------------------- ### Create a New Product Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Creates a new product with specified details like name, distribution strategy, and supported platforms. Requires administrative token configuration. ```rust use keygen_rs::product::{Product, CreateProductRequest, DistributionStrategy}; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new product let product = Product::create(CreateProductRequest { name: "My App".to_string(), distribution_strategy: Some(DistributionStrategy::Licensed), platforms: Some(vec![Platform::MacOs, Platform::Windows]), ..Default::default() }).await?; // List all products let products = Product::list(None).await?; Ok(()) } ``` -------------------------------- ### Configure Keygen SDK for Administrators Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Set up the Keygen SDK globally for administrator token authentication using `KeygenConfig::admin`. ```rust use keygen_rs::config::{self, KeygenConfig}; config::set_config(KeygenConfig::admin( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_ADMIN_TOKEN", )); ``` -------------------------------- ### Initialize keygen-rs2 Plugin in main.rs Source: https://github.com/ahonn/keygen-rs/blob/master/packages/tauri-plugin-keygen-rs2/README.md Import and use the Builder to configure and add the plugin to your Tauri application. ```rust use tauri_plugin_keygen_rs2::Builder; fn main() { tauri::Builder::default() .plugin( Builder::new(account, product, public_key) .api_url(api_url) .build() ) // ... other configurations .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` -------------------------------- ### Create, Suspend, and Reinstate a License Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Demonstrates the lifecycle management of a license, including creation with a policy ID and user email, suspending it, and then reinstating it. Requires administrative token configuration. ```rust use keygen_rs::license::{License, CreateLicenseRequest}; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new license let license = License::create(CreateLicenseRequest { policy_id: "POLICY_ID".to_string(), user_email: Some("user@example.com".to_string()), ..Default::default() }).await?; // Suspend a license license.suspend().await?; // Reinstate a license license.reinstate().await?; Ok(()) } ``` -------------------------------- ### License Management Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Shows how to create, suspend, and reinstate licenses. ```APIDOC ## License Management Manages individual licenses. ### Methods - `License::create(CreateLicenseRequest)` - `license.suspend()` - `license.reinstate()` ### Description These methods enable the creation of new licenses, associating them with a policy and user. You can also suspend licenses to revoke access temporarily and reinstate them later. ### Request Example ```rust use keygen_rs::license::{License, CreateLicenseRequest}; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new license let license = License::create(CreateLicenseRequest { policy_id: "POLICY_ID".to_string(), user_email: Some("user@example.com".to_string()), ..Default::default() }).await?; // Suspend a license license.suspend().await?; // Reinstate a license license.reinstate().await?; Ok(()) } ``` ### Response - **`License::create`**: Returns the created `License` object. - **`license.suspend()` / `license.reinstate()`**: Returns `()` on success. ``` -------------------------------- ### Policy Management Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Demonstrates how to create new policies for license management. ```APIDOC ## Policy Management Manages licensing policies. ### Method `Policy::create(CreatePolicyRequest)` ### Description This method allows you to create a new licensing policy. You can define various attributes such as the policy name, authentication strategy, duration, and maximum number of machines allowed per license. ### Request Example ```rust use keygen_rs::policy::{Policy, CreatePolicyRequest, AuthenticationStrategy}; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new policy let policy = Policy::create(CreatePolicyRequest { name: "Standard License".to_string(), authentication_strategy: Some(AuthenticationStrategy::License), duration: Some(365), // days max_machines: Some(3), ..Default::default() }).await?; Ok(()) } ``` ### Response Returns the created `Policy` object. ``` -------------------------------- ### Create a New Policy Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Creates a new licensing policy with a name, authentication strategy, duration, and maximum number of machines. Requires administrative token configuration. ```rust use keygen_rs::policy::{Policy, CreatePolicyRequest, AuthenticationStrategy}; #[tokio::main] async fn main() -> Result<(), Error> { // Create a new policy let policy = Policy::create(CreatePolicyRequest { name: "Standard License".to_string(), authentication_strategy: Some(AuthenticationStrategy::License), duration: Some(365), // days max_machines: Some(3), ..Default::default() }).await?; Ok(()) } ``` -------------------------------- ### Activate a Machine with a License Key Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Activates a machine for a given license key. This is useful when a license is not yet activated on the current machine. ```rust use keygen_rs::{ config::{self, KeygenConfig}, errors::Error, }; #[tokio::main] async fn main() -> Result<(), Error> { config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); let fingerprint = machine_uid::get().unwrap_or("".into()); if let Err(err) = keygen_rs::validate(&[fingerprint.clone()], &[]).await { match err { Error::LicenseNotActivated { license, .. } => { let machine = license.activate(&fingerprint, &[]).await?; println!("License activated successfully: {:?}", machine); } _ => { println!("License validation failed: {:?}", err); } } } else { println!("License validated successfully"); } Ok(()) } ``` -------------------------------- ### Handle License Not Activated Error Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Demonstrates how to handle specific Keygen SDK errors, such as `LicenseNotActivated`, and proceed with activation if necessary. This is useful for robust error management. ```rust use keygen_rs::{config::{self, KeygenConfig}, errors::Error}; #[tokio::main] async fn main() -> Result<(), Error> { config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); let fingerprint = machine_uid::get().unwrap_or("".into()); match keygen_rs::validate(&[fingerprint.clone()], &[]).await { Ok(license) => println!("License is valid: {:?}", license), Err(Error::LicenseNotActivated { license, .. }) => { println!("License is not activated. Activating..."); let machine = license.activate(&fingerprint, &[]).await?; println!("Machine activated: {:?}", machine); }, Err(e) => println!("Error: {:?}", e), } Ok(()) } ``` -------------------------------- ### Configure keygen-rs with Feature Flags Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Specify feature flags in Cargo.toml to include or exclude specific functionalities, optimizing binary size. ```toml # For end-user features only (default) keygen-rs = "0.9" # For administrative features keygen-rs = { version = "0.9", features = ["token"] } # For both end-user and administrative features keygen-rs = { version = "0.9", features = ["license-key", "token"] } ``` -------------------------------- ### Generate Documentation in Rust Source: https://github.com/ahonn/keygen-rs/blob/master/CLAUDE.md Generate project documentation using Cargo. The `--no-deps` flag excludes dependencies from the documentation, and `--all-features` includes documentation for all features. ```bash cargo doc --no-deps --all-features ``` -------------------------------- ### Custom Keygen SDK Configuration Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Provide a custom configuration for the Keygen SDK, allowing overrides for API URL and authentication details. ```rust use keygen_rs::config::{self, KeygenConfig}; config::set_config(KeygenConfig { api_url: "https://api.keygen.sh".to_string(), // or your custom domain account: "YOUR_KEYGEN_ACCOUNT_ID".to_string(), product: "YOUR_KEYGEN_PRODUCT_ID".to_string(), license_key: Some("A_KEYGEN_LICENSE_KEY".to_string()), token: Some("YOUR_ADMIN_TOKEN".to_string()), public_key: Some("YOUR_KEYGEN_PUBLIC_KEY".to_string()), ..KeygenConfig::default() }); ``` -------------------------------- ### Validate License with Keygen SDK Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Validate a license key by configuring the SDK and calling the `validate` function with device fingerprints. Ensure `KeygenConfig` is set before making the call. ```rust use keygen_rs::{config::{self, KeygenConfig}, errors::Error}; #[tokio::main] async fn main() -> Result<(), Error> { config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); let fingerprint = machine_uid::get().unwrap_or("".into()); let license = keygen_rs::validate(&[fingerprint], &[]).await?; println!("License validated successfully: {:?}", license); Ok(()) } ``` -------------------------------- ### Run Devbox Scripts Source: https://github.com/ahonn/keygen-rs/blob/master/CLAUDE.md Execute development tasks using devbox scripts. These scripts abstract common commands like testing and building documentation. ```bash devbox run test # cargo test -- --show-output devbox run build-docs # cargo doc ``` -------------------------------- ### Environments Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for managing environments, including creation, retrieval, update, deletion, and token generation. ```APIDOC ## POST /environments ### Description Create a new environment. ### Method POST ### Endpoint /environments ``` ```APIDOC ## GET /environments/ ### Description Retrieve a specific environment. ### Method GET ### Endpoint /environments/ ``` ```APIDOC ## PATCH /environments/ ### Description Update a specific environment. ### Method PATCH ### Endpoint /environments/ ``` ```APIDOC ## DELETE /environments/ ### Description Delete a specific environment. ### Method DELETE ### Endpoint /environments/ ``` ```APIDOC ## GET /environments ### Description Retrieve a list of environments. ### Method GET ### Endpoint /environments ``` ```APIDOC ## POST /environments//tokens ### Description Generate a token for a specific environment. ### Method POST ### Endpoint /environments//tokens ``` -------------------------------- ### Set Environment Variables for API Access Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Set the necessary environment variables for accessing the Keygen API. `KEYGEN_ACCOUNT` is mandatory, and `KEYGEN_API_URL` is optional. ```bash export KEYGEN_ACCOUNT="your-account-id" export KEYGEN_API_URL="https://api.keygen.sh" # optional, defaults to this ``` -------------------------------- ### Products API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage product information, including creation, retrieval, update, deletion, and generating product tokens. ```APIDOC ## POST /products ### Description Create a new product. ### Method POST ### Endpoint /products ## GET /products/ ### Description Retrieve a specific product by its ID. ### Method GET ### Endpoint /products/ ## PATCH /products/ ### Description Update an existing product. ### Method PATCH ### Endpoint /products/ ## DELETE /products/ ### Description Delete a product. ### Method DELETE ### Endpoint /products/ ## GET /products ### Description List all products. ### Method GET ### Endpoint /products ## POST /products//tokens ### Description Generate a product token for a specific product. ### Method POST ### Endpoint /products//tokens ``` -------------------------------- ### Add keygen-rs2 Dependency to Cargo.toml Source: https://github.com/ahonn/keygen-rs/blob/master/packages/tauri-plugin-keygen-rs2/README.md Add this to your Cargo.toml to include the keygen-rs2 plugin. ```toml [dependencies] tauri-plugin-keygen-rs2 = "0.4" ``` -------------------------------- ### Packages Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for managing packages, including creation, retrieval, update, and deletion, with support for list filters. ```APIDOC ## POST /packages ### Description Create a new package. ### Method POST ### Endpoint /packages ``` ```APIDOC ## GET /packages/ ### Description Retrieve a specific package. ### Method GET ### Endpoint /packages/ ``` ```APIDOC ## PATCH /packages/ ### Description Update a specific package. ### Method PATCH ### Endpoint /packages/ ``` ```APIDOC ## DELETE /packages/ ### Description Delete a specific package. ### Method DELETE ### Endpoint /packages/ ``` ```APIDOC ## GET /packages ### Description Retrieve a list of packages. ### Method GET ### Endpoint /packages ### Parameters #### Query Parameters - **product** (string) - Optional - Filter by product. - **engine** (string) - Optional - Filter by engine. ``` -------------------------------- ### Components API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage components, including creation, retrieval, update, deletion, and listing. Supports filtering by machine, license, owner, user, and product. ```APIDOC ## POST /components ### Description Create a new component. ### Method POST ### Endpoint /components ## GET /components/ ### Description Retrieve a specific component by its ID. ### Method GET ### Endpoint /components/ ## PATCH /components/ ### Description Update an existing component. ### Method PATCH ### Endpoint /components/ ## DELETE /components/ ### Description Delete a component. ### Method DELETE ### Endpoint /components/ ## GET /components ### Description List all components. ### Method GET ### Endpoint /components ``` -------------------------------- ### Rollback Release Steps Source: https://github.com/ahonn/keygen-rs/blob/master/docs/RELEASE_GUIDE.md Steps to manually rollback a release by reverting code, creating a fix commit, and pushing to trigger a new version. ```bash # 1. Revert code git revert ``` ```bash # 2. Create fix version git commit -m "fix: revert breaking changes" ``` ```bash # 3. Push to trigger new version git push origin master ``` -------------------------------- ### Add keygen-rs to Cargo.toml Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Include the keygen-rs crate in your project's dependencies by adding it to your Cargo.toml file. ```toml [dependencies] keygen-rs = "0.9" ``` -------------------------------- ### Use keygen-rs2 API in Frontend Source: https://github.com/ahonn/keygen-rs/blob/master/packages/tauri-plugin-keygen-rs2/README.md Import and use the plugin's API functions in your frontend TypeScript code for license validation and management. ```typescript import { getLicense, validateKey, deactivate, checkoutLicense, checkoutMachine, } from 'tauri-plugin-keygen-rs-api2'; const license = await validateKey('YOUR_LICENSE_KEY'); ``` -------------------------------- ### Verify a Signed License Key Offline Source: https://github.com/ahonn/keygen-rs/blob/master/README.md Verifies a signed license key offline using the specified signature scheme. Ensure you have the correct public key configured. ```rust use keygen_rs::{config::{self, KeygenConfig}, license::SchemeCode}; fn main() { config::set_config(KeygenConfig::license_key( "YOUR_KEYGEN_ACCOUNT_ID", "YOUR_KEYGEN_PRODUCT_ID", "A_KEYGEN_LICENSE_KEY", Some("YOUR_KEYGEN_PUBLIC_KEY"), )); let signed_key = "YOUR_SIGNED_LICENSE_KEY"; if let Ok(data) = keygen_rs::verify(SchemeCode::Ed25519Sign, signed_key) { println!("License verified: {:?}", String::from_utf8_lossy(&data)); } else { println!("License verification failed"); } } ``` -------------------------------- ### Set Environment Variables for Specific Operations Source: https://github.com/ahonn/keygen-rs/blob/master/examples/README.md Set environment variables for specific operations like creating licenses or performing machine/license operations. ```bash # For creating licenses export POLICY_ID="your-policy-id" # For machine/license operations export MACHINE_ID="your-machine-id" export LICENSE_ID="your-license-id" ``` -------------------------------- ### Releases API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage software releases, including creation, retrieval, update, deletion, and actions like publishing and yanking. Also includes checking for upgrades and managing associated artifacts and constraints. ```APIDOC ## POST /releases ### Description Create a new release. ### Method POST ### Endpoint /releases ## GET /releases/ ### Description Retrieve a specific release by its ID. ### Method GET ### Endpoint /releases/ ## PATCH /releases/ ### Description Update an existing release. ### Method PATCH ### Endpoint /releases/ ## DELETE /releases/ ### Description Delete a release. ### Method DELETE ### Endpoint /releases/ ## GET /releases ### Description List releases. Note: This endpoint has limited coverage. ### Method GET ### Endpoint /releases ## POST /releases//actions/publish ### Description Publish a release. ### Method POST ### Endpoint /releases//actions/publish ## POST /releases//actions/yank ### Description Yank a release. ### Method POST ### Endpoint /releases//actions/yank ## GET /releases//upgrade ### Description Check for available upgrades for a release. ### Method GET ### Endpoint /releases//upgrade ## GET /releases//artifacts ### Description List artifacts associated with a release. ### Method GET ### Endpoint /releases//artifacts ## GET /releases//artifacts/ ### Description Download a specific artifact for a release. ### Method GET ### Endpoint /releases//artifacts/ ## POST /releases//constraints ### Description Attach constraints to a release. ### Method POST ### Endpoint /releases//constraints ## DELETE /releases//constraints ### Description Detach constraints from a release. ### Method DELETE ### Endpoint /releases//constraints ## GET /releases//constraints ### Description List constraints for a release. ### Method GET ### Endpoint /releases//constraints ## PUT /releases//package ### Description Change the package associated with a release. ### Method PUT ### Endpoint /releases//package ``` -------------------------------- ### Processes API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage processes, including creation, retrieval, update, deletion, and listing. Supports actions like pinging and filtering by various criteria. ```APIDOC ## POST /processes ### Description Create a new process. ### Method POST ### Endpoint /processes ## GET /processes/ ### Description Retrieve a specific process by its ID. ### Method GET ### Endpoint /processes/ ## PATCH /processes/ ### Description Update an existing process. ### Method PATCH ### Endpoint /processes/ ## DELETE /processes/ ### Description Delete a process. ### Method DELETE ### Endpoint /processes/ ## GET /processes ### Description List all processes. ### Method GET ### Endpoint /processes ## POST /processes//actions/ping ### Description Send a heartbeat ping for a process. ### Method POST ### Endpoint /processes//actions/ping ``` -------------------------------- ### Linting and Formatting in Rust Source: https://github.com/ahonn/keygen-rs/blob/master/CLAUDE.md Maintain code quality and consistency using Cargo's built-in linting and formatting tools. The `--check` flag for formatting ensures compliance without modifying files. ```bash cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings ``` -------------------------------- ### Artifacts API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage software artifacts, including creation, retrieval, download, update, and deletion. Supports filtering for various artifact properties. ```APIDOC ## POST /artifacts ### Description Create a new artifact. ### Method POST ### Endpoint /artifacts ## GET /artifacts/ ### Description Retrieve and download an artifact by its ID. Returns a 303 redirect. ### Method GET ### Endpoint /artifacts/ ## PATCH /artifacts/ ### Description Update an existing artifact. ### Method PATCH ### Endpoint /artifacts/ ## DELETE /artifacts/ ### Description Yank (delete) an artifact. ### Method DELETE ### Endpoint /artifacts/ ## GET /artifacts ### Description List all artifacts. ### Method GET ### Endpoint /artifacts ``` -------------------------------- ### Feature-Specific Testing in Rust Source: https://github.com/ahonn/keygen-rs/blob/master/CLAUDE.md Execute tests tailored to specific Cargo features. This allows for focused testing of different project modules, such as license key or admin features. ```bash cargo test # license-key features only cargo test --features token # admin features cargo test --all-features # all features ``` -------------------------------- ### Read-Only Distribution Resources Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for retrieving read-only distribution resources like Platforms, Arches, and Channels. ```APIDOC ## GET /platforms ### Description List platforms. ### Method GET ### Endpoint /platforms ``` ```APIDOC ## GET /platforms/ ### Description Retrieve a specific platform. ### Method GET ### Endpoint /platforms/ ``` ```APIDOC ## GET /arches ### Description List arches. ### Method GET ### Endpoint /arches ``` ```APIDOC ## GET /arches/ ### Description Retrieve a specific arch. ### Method GET ### Endpoint /arches/ ``` ```APIDOC ## GET /channels ### Description List channels. ### Method GET ### Endpoint /channels ``` ```APIDOC ## GET /channels/ ### Description Retrieve a specific channel. ### Method GET ### Endpoint /channels/ ``` -------------------------------- ### Policies API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage access policies, including creation, retrieval, update, deletion, and managing associated entitlements and pool keys. ```APIDOC ## POST /policies ### Description Create a new policy. ### Method POST ### Endpoint /policies ## GET /policies/ ### Description Retrieve a specific policy by its ID. ### Method GET ### Endpoint /policies/ ## PATCH /policies/ ### Description Update an existing policy. ### Method PATCH ### Endpoint /policies/ ## DELETE /policies/ ### Description Delete a policy. ### Method DELETE ### Endpoint /policies/ ## GET /policies ### Description List all policies. ### Method GET ### Endpoint /policies ## POST /policies//entitlements ### Description Attach entitlements to a policy. ### Method POST ### Endpoint /policies//entitlements ## DELETE /policies//entitlements ### Description Detach entitlements from a policy. ### Method DELETE ### Endpoint /policies//entitlements ## GET /policies//entitlements ### Description List entitlements associated with a policy. ### Method GET ### Endpoint /policies//entitlements ## GET /policies//pool ### Description List pool keys associated with a policy. ### Method GET ### Endpoint /policies//pool ``` -------------------------------- ### Engine Distribution Endpoints Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for engine distribution checks and information retrieval. ```APIDOC ## GET /engines/tauri/ ### Description Tauri auto-update check. ### Method GET ### Endpoint /engines/tauri/ ``` ```APIDOC ## GET /engines/pypi/simple ### Description PyPI package index. ### Method GET ### Endpoint /engines/pypi/simple ``` ```APIDOC ## GET /engines/npm/ ### Description npm package info. ### Method GET ### Endpoint /engines/npm/ ``` ```APIDOC ## GET /engines/rubygems ### Description RubyGems index. ### Method GET ### Endpoint /engines/rubygems ``` ```APIDOC ## GET /engines/oci ### Description OCI container registry. ### Method GET ### Endpoint /engines/oci ``` ```APIDOC ## GET /engines/raw//... ### Description Raw file download. ### Method GET ### Endpoint /engines/raw//... ``` -------------------------------- ### Webhook Endpoints Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for managing webhook endpoints, including creation, retrieval, update, and deletion. ```APIDOC ## POST /webhook-endpoints ### Description Create a new webhook endpoint. ### Method POST ### Endpoint /webhook-endpoints ``` ```APIDOC ## GET /webhook-endpoints/ ### Description Retrieve a specific webhook endpoint. ### Method GET ### Endpoint /webhook-endpoints/ ``` ```APIDOC ## PATCH /webhook-endpoints/ ### Description Update a specific webhook endpoint. ### Method PATCH ### Endpoint /webhook-endpoints/ ``` ```APIDOC ## DELETE /webhook-endpoints/ ### Description Delete a specific webhook endpoint. ### Method DELETE ### Endpoint /webhook-endpoints/ ``` ```APIDOC ## GET /webhook-endpoints ### Description Retrieve a list of webhook endpoints. ### Method GET ### Endpoint /webhook-endpoints ``` -------------------------------- ### Groups API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage groups, including creation, retrieval, update, deletion, and listing. Supports filtering for various group properties. ```APIDOC ## POST /groups ### Description Create a new group. ### Method POST ### Endpoint /groups ## GET /groups/ ### Description Retrieve a specific group by its ID. ### Method GET ### Endpoint /groups/ ## PATCH /groups/ ### Description Update an existing group. ### Method PATCH ### Endpoint /groups/ ## DELETE /groups/ ### Description Delete a group. ### Method DELETE ### Endpoint /groups/ ## GET /groups ### Description List all groups. ### Method GET ### Endpoint /groups ``` -------------------------------- ### Entitlements API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage entitlements, including creation, retrieval, update, and deletion. Supports filtering for various entitlement properties. ```APIDOC ## POST /entitlements ### Description Create a new entitlement. ### Method POST ### Endpoint /entitlements ## GET /entitlements/ ### Description Retrieve a specific entitlement by its ID. ### Method GET ### Endpoint /entitlements/ ## PATCH /entitlements/ ### Description Update an existing entitlement. ### Method PATCH ### Endpoint /entitlements/ ## DELETE /entitlements/ ### Description Delete an entitlement. ### Method DELETE ### Endpoint /entitlements/ ## GET /entitlements ### Description List all entitlements. ### Method GET ### Endpoint /entitlements ``` -------------------------------- ### Skipping Release Updates Source: https://github.com/ahonn/keygen-rs/blob/master/docs/RELEASE_GUIDE.md Methods to skip version updates for specific commits, either by adding '[skip ci]' to the commit message or by using the 'chore:' commit type. ```bash git commit -m "docs: update README [skip ci]" ``` ```bash git commit -m "chore: update dev dependencies" ``` -------------------------------- ### Webhook Events Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for retrieving webhook events, deleting them, and retrying failed events. ```APIDOC ## GET /webhook-events/ ### Description Retrieve a specific webhook event. ### Method GET ### Endpoint /webhook-events/ ``` ```APIDOC ## DELETE /webhook-events/ ### Description Delete a specific webhook event. ### Method DELETE ### Endpoint /webhook-events/ ``` ```APIDOC ## GET /webhook-events ### Description Retrieve a list of webhook events. ### Method GET ### Endpoint /webhook-events ``` ```APIDOC ## POST /webhook-events//actions/retry ### Description Retry a specific webhook event. ### Method POST ### Endpoint /webhook-events//actions/retry ``` -------------------------------- ### Tokens API Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Manage API tokens, including generation, retrieval, regeneration, and revocation. Supports filtering for token types and associated bearers. ```APIDOC ## POST /tokens ### Description Generate a new API token. ### Method POST ### Endpoint /tokens ## GET /tokens/ ### Description Retrieve a specific token by its ID. ### Method GET ### Endpoint /tokens/ ## PUT /tokens/ ### Description Regenerate an existing token. ### Method PUT ### Endpoint /tokens/ ## DELETE /tokens/ ### Description Revoke (delete) a token. ### Method DELETE ### Endpoint /tokens/ ## GET /tokens ### Description List all tokens. Note: This endpoint has limited coverage. ### Method GET ### Endpoint /tokens ``` -------------------------------- ### Group Relationships Source: https://github.com/ahonn/keygen-rs/blob/master/docs/API_COVERAGE.md Endpoints for retrieving relationships associated with groups. ```APIDOC ## GET /groups//owners ### Description List group owners. ### Method GET ### Endpoint /groups//owners ``` ```APIDOC ## GET /groups//users ### Description List group users. ### Method GET ### Endpoint /groups//users ``` ```APIDOC ## GET /groups//licenses ### Description List group licenses. ### Method GET ### Endpoint /groups//licenses ``` ```APIDOC ## GET /groups//machines ### Description List group machines. ### Method GET ### Endpoint /groups//machines ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.