Skip to main content

keeper_secrets_manager_core/
lib.rs

1// -*- coding: utf-8 -*-
2//  _  __
3// | |/ /___ ___ _ __  ___ _ _ (R)
4// | ' </ -_) -_) '_ \/ -_) '_|
5// |_|\_\___\___| .__/\___|_|
6//              |_|
7//
8// Keeper Secrets Manager
9// Copyright 2024 Keeper Security Inc.
10// Contact: sm@keepersecurity.com
11//
12
13//! # Keeper Secrets Manager Rust SDK
14//!
15//! Type-safe, zero-knowledge client library for accessing secrets stored in Keeper's vault.
16//!
17//! ## Features
18//!
19//! - **Type-Safe API** - Leverages Rust's type system for compile-time safety
20//! - **Never Panics** - All operations return `Result<T, KSMRError>` with comprehensive error handling
21//! - **Multiple Storage Options** - File-based, in-memory, and caching support
22//! - **Zero-Knowledge Architecture** - All encryption/decryption happens client-side
23//! - **Keeper Notation** - URI-based field access (`keeper://UID/field/password`)
24//! - **Password Rotation** - Transaction-based rotation with commit/rollback
25//! - **GraphSync Support** - Linked record retrieval for managing relationships
26//! - **Disaster Recovery Caching** - Automatic fallback to cached data on network failures
27//!
28//! ## Quick Start
29//!
30//! ```no_run
31//! use keeper_secrets_manager_core::{
32//!     core::{ClientOptions, SecretsManager},
33//!     custom_error::KSMRError,
34//!     enums::KvStoreType,
35//!     storage::FileKeyValueStorage,
36//! };
37//!
38//! fn main() -> Result<(), KSMRError> {
39//!     // Initialize with one-time token
40//!     let storage = FileKeyValueStorage::new(Some("config.json".to_string()))?;
41//!     let config = KvStoreType::File(storage);
42//!     let token = "US:YOUR_ONE_TIME_TOKEN".to_string();
43//!     let options = ClientOptions::new_client_options_with_token(token, config);
44//!     let mut secrets_manager = SecretsManager::new(options)?;
45//!
46//!     // Retrieve secrets
47//!     let secrets = secrets_manager.get_secrets(Vec::new())?;
48//!     for secret in secrets {
49//!         println!("Title: {}", secret.title);
50//!     }
51//!
52//!     Ok(())
53//! }
54//! ```
55//!
56//! ## Modules
57//!
58//! - [`core`] - Main `SecretsManager` API and client configuration
59//! - [`storage`] - Storage backends (File, InMemory)
60//! - [`cache`] - Performance caching layer
61//! - [`caching`] - Disaster recovery caching with network fallback
62//! - [`crypto`] - Cryptographic operations (AES-GCM, ECDH, ECDSA)
63//! - [`dto`] - Data transfer objects (Record, Folder, File, Payload types)
64//! - [`utils`] - Utilities (password generation, TOTP, Base64 encoding)
65//! - [`custom_error`] - Error types (`KSMRError` enum)
66//! - [`enums`] - Type enums (field types, record types, storage types)
67//!
68//! ## Storage Options
69//!
70//! ### File Storage (Persistent)
71//!
72//! ```no_run
73//! use keeper_secrets_manager_core::storage::FileKeyValueStorage;
74//! use keeper_secrets_manager_core::enums::KvStoreType;
75//! use keeper_secrets_manager_core::custom_error::KSMRError;
76//!
77//! fn example() -> Result<(), KSMRError> {
78//!     let storage = FileKeyValueStorage::new(Some("keeper_config.json".to_string()))?;
79//!     let config = KvStoreType::File(storage);
80//!     // Config persisted to file with secure permissions (0600 on Unix)
81//!     Ok(())
82//! }
83//! ```
84//!
85//! ### In-Memory Storage (Ephemeral)
86//!
87//! ```no_run
88//! use keeper_secrets_manager_core::storage::InMemoryKeyValueStorage;
89//! use keeper_secrets_manager_core::enums::KvStoreType;
90//! use keeper_secrets_manager_core::custom_error::KSMRError;
91//!
92//! fn example() -> Result<(), KSMRError> {
93//!     let base64_config = std::env::var("KSM_CONFIG")
94//!         .expect("KSM_CONFIG required");
95//!     let storage = InMemoryKeyValueStorage::new(Some(base64_config))?;
96//!     let config = KvStoreType::InMemory(storage);
97//!     // Useful for serverless, Docker, CI/CD pipelines
98//!     Ok(())
99//! }
100//! ```
101//!
102//! ## Examples
103//!
104//! See the [repository](https://github.com/Keeper-Security/secrets-manager/tree/master/sdk/rust/examples)
105//! for comprehensive examples covering all SDK features.
106
107pub mod cache;
108pub mod caching;
109pub mod config_keys;
110pub mod constants;
111pub mod core;
112pub mod crypto;
113pub mod custom_error;
114pub mod dto;
115pub mod enums;
116mod helpers;
117pub mod keeper_globals;
118pub mod storage;
119mod tests;
120pub mod utils;