pub struct TapAgent {
pub config: AgentConfig,
/* private fields */
}Expand description
TapAgent implementation using the AgentKeyManager for cryptographic operations.
Fields§
§config: AgentConfigConfiguration for the agent
Implementations§
Source§impl TapAgent
impl TapAgent
Sourcepub fn key_manager(&self) -> &Arc<AgentKeyManager>
pub fn key_manager(&self) -> &Arc<AgentKeyManager>
Returns a reference to the agent’s key manager
Sourcepub fn new(config: AgentConfig, key_manager: Arc<AgentKeyManager>) -> Self
pub fn new(config: AgentConfig, key_manager: Arc<AgentKeyManager>) -> Self
Creates a new TapAgent with the given configuration and AgentKeyManager
Sourcepub async fn from_ephemeral_key() -> Result<(Self, String)>
pub async fn from_ephemeral_key() -> Result<(Self, String)>
Creates a new TapAgent with an ephemeral key
This function generates a new DID key for temporary use. The key is not persisted to storage and will be lost when the agent is dropped.
§Returns
A tuple containing the TapAgent and the DID that was generated
Sourcepub async fn from_stored_keys(did: Option<String>, debug: bool) -> Result<Self>
pub async fn from_stored_keys(did: Option<String>, debug: bool) -> Result<Self>
Creates a new TapAgent from stored keys
This function uses the AgentKeyManagerBuilder to load keys from storage
§Arguments
did- Optional DID to use. If None, the default DID from storage is used.debug- Whether to enable debug mode
§Returns
A Result containing either the created agent or an error if no keys are available
Sourcepub async fn from_secret_helper(
config: &SecretHelperConfig,
did: &str,
debug: bool,
) -> Result<(Self, String)>
pub async fn from_secret_helper( config: &SecretHelperConfig, did: &str, debug: bool, ) -> Result<(Self, String)>
Creates a new TapAgent from a secret helper
Invokes the secret helper to retrieve the private key for the given DID, then creates a TapAgent using that key.
§Arguments
config- The secret helper configurationdid- The DID to fetch the key fordebug- Whether to enable debug mode
Sourcepub async fn from_private_key(
private_key: &[u8],
key_type: KeyType,
debug: bool,
) -> Result<(Self, String)>
pub async fn from_private_key( private_key: &[u8], key_type: KeyType, debug: bool, ) -> Result<(Self, String)>
Creates a new TapAgent from an existing private key
This function creates a new TapAgent using a provided private key, which can be useful for integrating with external key management systems or when keys are generated outside the TAP agent.
§Arguments
private_key- The private key byteskey_type- The type of key (Ed25519, P256, or Secp256k1)debug- Whether to enable debug mode
§Returns
A Result containing either the created agent or an error
Sourcepub async fn get_signing_kid(&self) -> Result<String>
pub async fn get_signing_kid(&self) -> Result<String>
Get the signing key ID for this agent
Resolves the DID document and returns the first authentication verification method ID
Sourcepub async fn get_encryption_kid(&self, recipient_did: &str) -> Result<String>
pub async fn get_encryption_kid(&self, recipient_did: &str) -> Result<String>
Get the encryption key ID for a recipient
Resolves the DID document and returns the appropriate key agreement method ID
Sourcepub async fn create_enhanced_agent(
agent_id: String,
policies: Vec<String>,
metadata: HashMap<String, String>,
save_to_storage: bool,
) -> Result<(Self, String)>
pub async fn create_enhanced_agent( agent_id: String, policies: Vec<String>, metadata: HashMap<String, String>, save_to_storage: bool, ) -> Result<(Self, String)>
Create an agent with enhanced configuration (policies and metadata)
Sourcepub async fn create_enhanced_agent_with_path(
agent_id: String,
policies: Vec<String>,
metadata: HashMap<String, String>,
save_to_storage: bool,
storage_path: Option<PathBuf>,
) -> Result<(Self, String)>
pub async fn create_enhanced_agent_with_path( agent_id: String, policies: Vec<String>, metadata: HashMap<String, String>, save_to_storage: bool, storage_path: Option<PathBuf>, ) -> Result<(Self, String)>
Create an agent with enhanced configuration (policies and metadata) with custom storage path
Sourcepub async fn load_enhanced_agent(
did: &str,
) -> Result<(Self, Vec<String>, HashMap<String, String>)>
pub async fn load_enhanced_agent( did: &str, ) -> Result<(Self, Vec<String>, HashMap<String, String>)>
Load an enhanced agent from storage with policies and metadata
Sourcepub fn list_enhanced_agents() -> Result<Vec<EnhancedAgentInfo>>
pub fn list_enhanced_agents() -> Result<Vec<EnhancedAgentInfo>>
List all enhanced agents with their policies and metadata
Sourcepub fn list_enhanced_agents_with_path(
storage_path: Option<PathBuf>,
) -> Result<Vec<EnhancedAgentInfo>>
pub fn list_enhanced_agents_with_path( storage_path: Option<PathBuf>, ) -> Result<Vec<EnhancedAgentInfo>>
List all enhanced agents with their policies and metadata with custom storage path