diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml deleted file mode 100644 index 1f0cba64..00000000 --- a/.github/codeql/codeql-config.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: "MDK CodeQL Configuration" - -queries: - - uses: security-and-quality - -# Suppress rules that produce only false positives in this codebase. -# -# rust/hard-coded-cryptographic-value (47 false positives): -# Flags zero-initialized buffers like `[0u8; 32]` that are immediately filled -# by CSPRNG (OsRng) or HKDF, HKDF domain separation labels (b"mip04-v2"), -# and MIME type string constants ("image/png"). None of these are actual -# hard-coded key material. Test code also uses deterministic values for -# assertions, which is expected and correct. -# -# rust/cleartext-logging (20 false positives): -# All alerts are in #[cfg(test)] modules -- test assertions comparing -# exporter_secret values (e.g., assert_ne!(initial, final)). These never -# execute in production. Production logging of sensitive identifiers is -# enforced by AGENTS.md policy, STYLE.md, and code review. -# -# See AGENTS.md "Sensitive Identifiers - NEVER Log or Expose" for the -# production policy that guards against the real versions of these issues. -query-filters: - - exclude: - id: rust/hard-coded-cryptographic-value - - exclude: - id: rust/cleartext-logging diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index da1a2d84..00000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 6 * * 1' # Weekly on Monday at 06:00 UTC - -permissions: - contents: read - security-events: write - -jobs: - analyze-rust: - name: Analyze Rust - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - - - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y pkg-config - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: rust - config-file: ./.github/codeql/codeql-config.yml - - - name: Build - run: cargo build --all-features - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:rust" - - analyze-actions: - name: Analyze GitHub Actions - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: actions - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:actions" diff --git a/.github/workflows/publish-crates.yml b/.github/workflows/publish-crates.yml new file mode 100644 index 00000000..84eeb6e6 --- /dev/null +++ b/.github/workflows/publish-crates.yml @@ -0,0 +1,120 @@ +name: Publish to crates.io + +on: + release: + types: [published] + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + publish-storage-traits: + runs-on: ubuntu-latest + name: Publish mdk-storage-traits + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + key: publish-storage-traits + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config + + - name: Publish mdk-storage-traits + run: cargo publish -p mdk-storage-traits + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + publish-memory-storage: + needs: publish-storage-traits + runs-on: ubuntu-latest + name: Publish mdk-memory-storage + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + key: publish-memory-storage + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config + + - name: Wait for mdk-storage-traits to be indexed + run: sleep 30 + + - name: Publish mdk-memory-storage + run: cargo publish -p mdk-memory-storage + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + publish-sqlite-storage: + needs: publish-storage-traits + runs-on: ubuntu-latest + name: Publish mdk-sqlite-storage + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + key: publish-sqlite-storage + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config + + - name: Wait for mdk-storage-traits to be indexed + run: sleep 30 + + - name: Publish mdk-sqlite-storage + run: cargo publish -p mdk-sqlite-storage + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + publish-core: + needs: [publish-memory-storage, publish-sqlite-storage] + runs-on: ubuntu-latest + name: Publish mdk-core + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + key: publish-core + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y pkg-config + + - name: Wait for dependencies to be indexed + run: sleep 30 + + - name: Publish mdk-core + run: cargo publish -p mdk-core --all-features + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/LICENSE b/LICENSE index 100258ab..11f4b15c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024-2025 Parres +Copyright (c) 2024-2026 Internet Privacy Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 969bf039..a826e840 100644 --- a/README.md +++ b/README.md @@ -98,10 +98,10 @@ Add MDK to your `Cargo.toml`: ```toml [dependencies] -mdk-core = "0.5.0" -mdk-memory-storage = "0.5.0" # For in-memory storage +mdk-core = "0.6.0" +mdk-memory-storage = "0.6.0" # For in-memory storage # OR -mdk-sqlite-storage = "0.5.0" # For persistent SQLite storage +mdk-sqlite-storage = "0.6.0" # For persistent SQLite storage ``` ### Feature Flags @@ -110,7 +110,7 @@ mdk-sqlite-storage = "0.5.0" # For persistent SQLite storage ```toml [dependencies] -mdk-core = { version = "0.5.0", features = ["mip04"] } +mdk-core = { version = "0.6.0", features = ["mip04"] } ``` ## 🚀 Quick Start diff --git a/crates/mdk-core/CHANGELOG.md b/crates/mdk-core/CHANGELOG.md index 9440f092..a9286971 100644 --- a/crates/mdk-core/CHANGELOG.md +++ b/crates/mdk-core/CHANGELOG.md @@ -29,12 +29,8 @@ ### Added -- **`clear_pending_commit` method**: Added `MDK::clear_pending_commit(group_id)` to allow callers to roll back an uncommitted pending MLS commit. This is essential for recovering from failed relay publishes — without it, a single failed publish permanently blocks all future group operations with "pending commit exists" errors. Wraps OpenMLS's `MlsGroup::clear_pending_commit` with MDK's group-loading and error handling. ([#192](https://github.com/marmot-protocol/mdk/pull/192)) - ### Fixed -- **`clear_pending_commit` orphaned keypair**: When `clear_pending_commit` rolls back a `self_update` pending commit, it now deletes the new `SignatureKeyPair` that was eagerly stored in the provider during `self_update`. Previously, repeated failed self-update publishes would accumulate unreachable private key material in storage. ([#197](https://github.com/marmot-protocol/mdk/pull/197)) - ### Removed ### Deprecated @@ -93,6 +89,7 @@ ### Added +- **`clear_pending_commit` method**: Added `MDK::clear_pending_commit(group_id)` to allow callers to roll back an uncommitted pending MLS commit. This is essential for recovering from failed relay publishes — without it, a single failed publish permanently blocks all future group operations with "pending commit exists" errors. Wraps OpenMLS's `MlsGroup::clear_pending_commit` with MDK's group-loading and error handling. ([#192](https://github.com/marmot-protocol/mdk/pull/192)) - **Self-update tracking**: `accept_welcome()` now sets `self_update_state` to `SelfUpdateState::Required` on the joined group (MIP-02 post-join obligation). `merge_pending_commit()` detects pure self-update commits and transitions the state to `SelfUpdateState::CompletedAt(now)`, recording the rotation timestamp for MIP-00 periodic staleness checks. `create_group()` initializes the state to `SelfUpdateState::NotRequired` (creator has no immediate obligation). ([#184](https://github.com/marmot-protocol/mdk/pull/184)) - **`groups_needing_self_update()` method**: Returns group IDs of active groups that need a self-update, either because the state is `Required` or because the last rotation is older than a configurable threshold. ([#184](https://github.com/marmot-protocol/mdk/pull/184)) - **KeyPackageRef `i` tag for efficient relay queries**: KeyPackage events now include an `i` tag with the hex-encoded `KeyPackageRef` (computed per RFC 9420 Section 5.2). This enables efficient relay queries for specific KeyPackages when processing Welcome messages, avoiding the need to download and decode all KeyPackage events. ([#182](https://github.com/marmot-protocol/mdk/pull/182)) @@ -128,6 +125,7 @@ ### Fixed +- **`clear_pending_commit` orphaned keypair**: When `clear_pending_commit` rolls back a `self_update` pending commit, it now deletes the new `SignatureKeyPair` that was eagerly stored in the provider during `self_update`. Previously, repeated failed self-update publishes would accumulate unreachable private key material in storage. ([#197](https://github.com/marmot-protocol/mdk/pull/197)) - **Welcome validation no longer requires `client` tag**: The `validate_welcome_event` function now correctly treats the `client` tag as optional per MIP-02. Previously, welcome events without a `client` tag were rejected, which would cause spec-compliant third-party implementations to be unable to send Welcome events to MDK-based clients. ([#186](https://github.com/marmot-protocol/mdk/pull/186)) - **Security dependency updates**: Updated `time` (0.3.44 → 0.3.47), `bytes` (1.11.0 → 1.11.1), and `lru` (0.16.2 → 0.16.3) to resolve Dependabot security advisories. ([#174](https://github.com/marmot-protocol/mdk/pull/174)) - **Message Ordering Consistency**: Fixed inconsistency where `group.last_message_id` might not match `get_messages()[0].id` due to different sorting logic. The `last_message_id` update logic now uses `created_at DESC, processed_at DESC, id DESC` ordering to match the `messages()` query, ensuring the first message returned is always the same as `last_message_id`. Added `last_message_processed_at` field to `Group` to track this secondary sort key. ([#166](https://github.com/marmot-protocol/mdk/pull/166)) diff --git a/crates/mdk-core/LICENSE b/crates/mdk-core/LICENSE new file mode 100644 index 00000000..11f4b15c --- /dev/null +++ b/crates/mdk-core/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2026 Internet Privacy Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/mdk-core/README.md b/crates/mdk-core/README.md index dc8909ac..a68bc851 100644 --- a/crates/mdk-core/README.md +++ b/crates/mdk-core/README.md @@ -1,9 +1,7 @@ -# Nostr Messaging Layer Security (MLS) +# mdk-core -## Description - -A simplified interface to build secure messaging apps on nostr with MLS ([RFC 9420](https://datatracker.ietf.org/doc/html/rfc9420)), -according to [NIP-EE](https://github.com/nostr-protocol/nips/pull/1427). +A simplified interface to build secure messaging apps on Nostr with MLS ([RFC 9420](https://www.rfc-editor.org/rfc/rfc9420.html)), +implementing the [Marmot Protocol](https://github.com/marmot-protocol/marmot). ## Changelog @@ -11,12 +9,8 @@ All notable changes to this library are documented in the [CHANGELOG.md](CHANGEL ## State -**This library is in an ALPHA state**, things that are implemented generally work but the API will change in breaking ways. - -## Donations - -`rust-nostr` is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the `rust-nostr` libs/software/services, then please [donate](https://rust-nostr.org/donate). +**This library is in an ALPHA state.** Things that are implemented generally work, but the API may change in breaking ways. ## License -This project is distributed under the MIT software license - see the [LICENSE](../../LICENSE) file for details +This project is distributed under the MIT software license - see the [LICENSE](https://github.com/marmot-protocol/mdk/blob/master/LICENSE) file for details, or visit . diff --git a/crates/mdk-memory-storage/CHANGELOG.md b/crates/mdk-memory-storage/CHANGELOG.md index b08d780e..48f5ef72 100644 --- a/crates/mdk-memory-storage/CHANGELOG.md +++ b/crates/mdk-memory-storage/CHANGELOG.md @@ -65,7 +65,7 @@ - **Epoch Lookup by Tag Content**: Implemented `find_message_epoch_by_tag_content` for in-memory storage, scanning cached group messages and matching serialized tags. ([#167](https://github.com/marmot-protocol/mdk/pull/167)) - **Retryable Message Support**: Updated storage implementation to handle `ProcessedMessageState::Retryable` transitions and persistence. ([#161](https://github.com/marmot-protocol/mdk/pull/161)) - **MLS Storage Module**: New `mls_storage` module with complete `StorageProvider<1>` implementation for OpenMLS integration ([#148](https://github.com/marmot-protocol/mdk/pull/148)) - - JSON codec for serializing/deserializing OpenMLS types + - Postcard codec (`MlsCodec`) for serializing/deserializing OpenMLS types ([#179](https://github.com/marmot-protocol/mdk/pull/179)) - Support for all 53 `StorageProvider<1>` methods - In-memory storage using `HashMap` for all MLS data types - **Snapshot Support**: New `snapshot` module for creating and restoring storage snapshots, useful for testing rollback scenarios ([#148](https://github.com/marmot-protocol/mdk/pull/148)) diff --git a/crates/mdk-memory-storage/LICENSE b/crates/mdk-memory-storage/LICENSE new file mode 100644 index 00000000..11f4b15c --- /dev/null +++ b/crates/mdk-memory-storage/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2026 Internet Privacy Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/mdk-memory-storage/README.md b/crates/mdk-memory-storage/README.md index c9a0490c..094a442e 100644 --- a/crates/mdk-memory-storage/README.md +++ b/crates/mdk-memory-storage/README.md @@ -1,51 +1,35 @@ -# MDK Memory Storage +# mdk-memory-storage -Memory-based storage implementation for MDK. This crate provides a storage backend that implements the `MdkStorageProvider` trait from the [mdk-storage-traits](../mdk-storage-traits) crate. +In-memory storage backend for [MDK](https://github.com/marmot-protocol/mdk). Implements the `MdkStorageProvider` trait from [`mdk-storage-traits`](https://crates.io/crates/mdk-storage-traits). -## Features - -- Uses an LRU (Least Recently Used) caching mechanism to store data in memory -- Provides both read and write operations that are thread-safe through `parking_lot::RwLock` -- Configurable cache size (default: 1000 items) -- Non-persistent storage that is cleared when the application terminates +Intended for testing and development. Data is not persisted across restarts. For production use, see [`mdk-sqlite-storage`](https://crates.io/crates/mdk-sqlite-storage). -## Performance - -This implementation uses `parking_lot::RwLock` instead of the standard library's `std::sync::RwLock` for improved performance. The `parking_lot` implementation offers several advantages: +## Features -- Smaller memory footprint -- Faster lock acquisition and release -- No poisoning on panic -- More efficient read-heavy workloads, which is ideal for this caching implementation -- Consistent behavior across different platforms +- LRU (Least Recently Used) caching with configurable capacity (default: 1000 items) +- Thread-safe via `parking_lot::RwLock` for efficient read-heavy workloads +- No external dependencies or setup required ## Example Usage -```rust,ignore +```rust use mdk_memory_storage::MdkMemoryStorage; -use mdk_storage_traits::MdkStorageProvider; -// Create a new memory storage instance +// Default cache size (1000 items) let storage = MdkMemoryStorage::default(); -// Or create with a custom cache size -let custom_storage = MdkMemoryStorage::with_cache_size(100); +// Custom cache size +let storage = MdkMemoryStorage::with_cache_size(500); ``` -For more advanced usage examples, see the tests in the source code. - ## Changelog All notable changes to this library are documented in the [CHANGELOG.md](CHANGELOG.md). ## State -**This library is in an ALPHA state**, things that are implemented generally work but the API will change in breaking ways. - -## Donations - -`rust-nostr` is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the `rust-nostr` libs/software/services, then please [donate](https://rust-nostr.org/donate). +**This library is in an ALPHA state.** Things that are implemented generally work, but the API may change in breaking ways. ## License -This project is distributed under the MIT software license - see the [LICENSE](../../LICENSE) file for details +This project is distributed under the MIT software license - see the [LICENSE](https://github.com/marmot-protocol/mdk/blob/master/LICENSE) file for details, or visit . diff --git a/crates/mdk-sqlite-storage/CHANGELOG.md b/crates/mdk-sqlite-storage/CHANGELOG.md index 885bc25a..f0ce0e0a 100644 --- a/crates/mdk-sqlite-storage/CHANGELOG.md +++ b/crates/mdk-sqlite-storage/CHANGELOG.md @@ -73,7 +73,7 @@ - **Epoch Lookup by Tag Content**: Implemented `find_message_epoch_by_tag_content` for SQLite storage using `SELECT epoch FROM messages WHERE tags LIKE ?` query. ([#167](https://github.com/marmot-protocol/mdk/pull/167)) - **Retryable Message Support**: Updated storage implementation to handle `ProcessedMessageState::Retryable` transitions and persistence. ([#161](https://github.com/marmot-protocol/mdk/pull/161)) - **MLS Storage Module**: New `mls_storage` module with complete `StorageProvider<1>` implementation for OpenMLS integration ([#148](https://github.com/marmot-protocol/mdk/pull/148)) - - JSON codec for serializing/deserializing OpenMLS types + - Postcard codec (`MlsCodec`) for serializing/deserializing OpenMLS types ([#179](https://github.com/marmot-protocol/mdk/pull/179)) - Support for all 53 `StorageProvider<1>` methods - Manages 8 OpenMLS tables: `openmls_group_data`, `openmls_proposals`, `openmls_own_leaf_nodes`, `openmls_key_packages`, `openmls_psks`, `openmls_signature_keys`, `openmls_encryption_keys`, `openmls_epoch_key_pairs` - Input validation for storage operations to prevent unbounded writes ([#94](https://github.com/marmot-protocol/mdk/pull/94)) diff --git a/crates/mdk-sqlite-storage/LICENSE b/crates/mdk-sqlite-storage/LICENSE new file mode 100644 index 00000000..11f4b15c --- /dev/null +++ b/crates/mdk-sqlite-storage/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2026 Internet Privacy Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/mdk-sqlite-storage/README.md b/crates/mdk-sqlite-storage/README.md index e511cf3b..e68e5335 100644 --- a/crates/mdk-sqlite-storage/README.md +++ b/crates/mdk-sqlite-storage/README.md @@ -1,6 +1,52 @@ -# MDK SQLite Storage +# mdk-sqlite-storage -Sqlite MLS storage backend for nostr apps +SQLite-based persistent storage backend for [MDK](https://github.com/marmot-protocol/mdk). Implements the `MdkStorageProvider` trait from [`mdk-storage-traits`](https://crates.io/crates/mdk-storage-traits). + +Designed for production use. The database is encrypted at rest using SQLCipher (ChaCha20-Poly1305) with a 256-bit key. + +## Features + +- Encrypted SQLite database via SQLCipher +- Automatic schema migrations +- Optional keyring integration via `keyring-core` for secure key management +- File permission hardening (mode `0600` on Unix) + +## Usage + +### Automatic key management (recommended) + +Initialize your platform's keyring store once at app startup, then let MDK handle key generation and storage: + +```rust,ignore +use mdk_sqlite_storage::MdkSqliteStorage; + +// e.g., keyring_core::set_default_store(AppleStore::new()); + +let storage = MdkSqliteStorage::new( + "path/to/database.db", + "com.example.myapp", // service identifier + "mdk.db.key.default", // key identifier +)?; +``` + +### Manual key management + +```rust +use mdk_sqlite_storage::{MdkSqliteStorage, EncryptionConfig}; + +let key = [0u8; 32]; // your securely stored 32-byte key +let config = EncryptionConfig::new(key); +let storage = MdkSqliteStorage::new_with_key("path/to/database.db", config)?; +``` + +### Unencrypted (development only) + +```rust +use mdk_sqlite_storage::MdkSqliteStorage; + +// ⚠️ WARNING: unencrypted — for development/testing only +let storage = MdkSqliteStorage::new_unencrypted("path/to/database.db")?; +``` ## Changelog @@ -8,12 +54,8 @@ All notable changes to this library are documented in the [CHANGELOG.md](CHANGEL ## State -**This library is in an ALPHA state**, things that are implemented generally work but the API will change in breaking ways. - -## Donations - -`rust-nostr` is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the `rust-nostr` libs/software/services, then please [donate](https://rust-nostr.org/donate). +**This library is in an ALPHA state.** Things that are implemented generally work, but the API may change in breaking ways. ## License -This project is distributed under the MIT software license - see the [LICENSE](../../LICENSE) file for details +This project is distributed under the MIT software license - see the [LICENSE](https://github.com/marmot-protocol/mdk/blob/master/LICENSE) file for details, or visit . diff --git a/crates/mdk-storage-traits/LICENSE b/crates/mdk-storage-traits/LICENSE new file mode 100644 index 00000000..11f4b15c --- /dev/null +++ b/crates/mdk-storage-traits/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2026 Internet Privacy Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/mdk-storage-traits/README.md b/crates/mdk-storage-traits/README.md index 807e5ce7..240e9eaa 100644 --- a/crates/mdk-storage-traits/README.md +++ b/crates/mdk-storage-traits/README.md @@ -1,10 +1,11 @@ -# MDK Storage Traits +# mdk-storage-traits -This crate provides an abstraction for the storage layer that MLS requires. +Storage abstraction layer for [MDK](https://github.com/marmot-protocol/mdk). This crate defines the `MdkStorageProvider` trait and associated types that storage backends must implement. -## MdkStorageProvider trait +Storage backends in the MDK ecosystem: -THis library contains the `MdkStorageProvider` trait. +- [`mdk-memory-storage`](https://crates.io/crates/mdk-memory-storage): In-memory storage for testing and development +- [`mdk-sqlite-storage`](https://crates.io/crates/mdk-sqlite-storage): SQLite-based persistent storage for production use ## Changelog @@ -12,12 +13,8 @@ All notable changes to this library are documented in the [CHANGELOG.md](CHANGEL ## State -**This library is in an ALPHA state**, things that are implemented generally work but the API will change in breaking ways. - -## Donations - -`rust-nostr` is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the `rust-nostr` libs/software/services, then please [donate](https://rust-nostr.org/donate). +**This library is in an ALPHA state.** Things that are implemented generally work, but the API may change in breaking ways. ## License -This project is distributed under the MIT software license - see the [LICENSE](../../LICENSE) file for details +This project is distributed under the MIT software license - see the [LICENSE](https://github.com/marmot-protocol/mdk/blob/master/LICENSE) file for details, or visit . diff --git a/crates/mdk-uniffi/CHANGELOG.md b/crates/mdk-uniffi/CHANGELOG.md index f2cdd956..50d9faec 100644 --- a/crates/mdk-uniffi/CHANGELOG.md +++ b/crates/mdk-uniffi/CHANGELOG.md @@ -31,8 +31,6 @@ ### Added -- **`clear_pending_commit` method**: Added `clear_pending_commit(group_id)` to allow callers to roll back an uncommitted pending MLS commit. ([#196](https://github.com/marmot-protocol/mdk/pull/196)) - ### Fixed ### Removed @@ -58,6 +56,7 @@ ### Added +- **`clear_pending_commit` method**: Added `clear_pending_commit(group_id)` to allow callers to roll back an uncommitted pending MLS commit. ([#196](https://github.com/marmot-protocol/mdk/pull/196)) - **`groups_needing_self_update()` method**: Returns hex-encoded group IDs of active groups that need a self-update (post-join obligation or stale rotation), given a threshold in seconds. ([#184](https://github.com/marmot-protocol/mdk/pull/184)) - **Custom Message Sort Order**: `get_messages()` now accepts an optional `sort_order` parameter (`"created_at_first"` or `"processed_at_first"`) to control message ordering. Defaults to `"created_at_first"` when omitted. ([#171](https://github.com/marmot-protocol/mdk/pull/171)) - **Last Message by Sort Order**: Added `get_last_message(mls_group_id, sort_order)` method to retrieve the most recent message under a given sort order, so clients using `"processed_at_first"` can get a "last message" consistent with their `get_messages()` ordering. ([#171](https://github.com/marmot-protocol/mdk/pull/171))