1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! HTTP server implementation for the Transaction Authorization Protocol (TAP).
//!
//! This crate provides an HTTP server for handling DIDComm messages as part of the
//! Transaction Authorization Protocol (TAP). It leverages the new optimized message
//! routing architecture of TAP Node.
//!
//! # Architecture
//!
//! The HTTP server acts as a gateway between external clients and the TAP Node. It:
//!
//! - **Validates Security**: Ensures only signed or encrypted messages are accepted
//! - **Parses Messages**: Converts HTTP requests to JSON for TAP Node processing
//! - **Routes Efficiently**: Leverages TAP Node's optimized message routing
//! - **Provides Monitoring**: Health checks and event logging capabilities
//!
//! # Message Processing Flow
//!
//! 1. **HTTP Request**: Client sends POST to `/didcomm` with DIDComm message
//! 2. **Security Validation**: Content-Type header validated (must be signed or encrypted)
//! 3. **JSON Parsing**: Request body parsed as JSON Value
//! 4. **Node Processing**: JSON passed to TAP Node's `receive_message()`
//! 5. **Optimized Routing**: TAP Node handles verification/decryption and agent routing
//! 6. **HTTP Response**: Result returned to client
//!
//! # Security Features
//!
//! - **No Plain Messages**: Plain DIDComm messages are rejected for security
//! - **Content-Type Validation**: Strict validation of message security types
//! - **Event Logging**: All message processing events are logged for audit
//!
//! # Key Components
//!
//! - **Handler**: Request/response processing with validation
//! - **Server**: Warp-based HTTP server with configurable endpoints
//! - **Client**: HTTP client for outgoing message delivery
//! - **Event Bus**: Comprehensive event logging and monitoring
//!
//! # Example Usage
//!
//! ```rust,no_run
//! use tap_http::{TapHttpConfig, TapHttpServer};
//! use tap_node::{TapNode, NodeConfig};
//! use tap_agent::TapAgent;
//! use std::sync::Arc;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create TAP Node
//! let node_config = NodeConfig::default();
//! let mut node = TapNode::new(node_config);
//!
//! // Register an agent
//! let (agent, _did) = TapAgent::from_ephemeral_key().await?;
//! node.register_agent(Arc::new(agent)).await?;
//!
//! // Configure and create the HTTP server
//! let config = TapHttpConfig::default();
//! let mut server = TapHttpServer::new(config, node);
//!
//! // Start the server
//! server.start().await?;
//!
//! // Server now accepts signed and encrypted DIDComm messages
//! // Messages are efficiently routed by the TAP Node
//!
//! Ok(())
//! }
//! ```
// Public modules
// Re-exports
pub use DIDCommClient;
pub use TapHttpConfig;
pub use ;
pub use TapHttpServer;