Skip to content

Commit 98e027f

Browse files
author
rbenzing
committed
update gitignore
2 parents a78ec70 + a1249d5 commit 98e027f

4 files changed

Lines changed: 733 additions & 1 deletion

File tree

.claude/settings.local.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(powershell:*)",
5+
"Bash(dotnet build)",
6+
"Bash(/bashes)",
7+
"Bash(where dotnet)",
8+
"Bash(cmd /c:*)",
9+
"Bash(xmllint:*)",
10+
"WebFetch(domain:mermaid.js.org)",
11+
"Bash(dotnet build:*)",
12+
"WebSearch",
13+
"Bash(dotnet --version)",
14+
"Bash(dotnet --list-sdks)",
15+
"Bash(dotnet test:*)",
16+
"Bash(dotnet tool list:*)"
17+
],
18+
"deny": [],
19+
"ask": []
20+
}
21+
}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,8 @@ FodyWeavers.xsd
397397
*.msp
398398

399399
# JetBrains Rider
400-
*.sln.iml
400+
*.sln.iml
401+
402+
# Claude
403+
.claude/
404+
CLAUDE.md

CLAUDE.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build and Development Commands
6+
7+
### Building the Solution
8+
```cmd
9+
# Restore dependencies
10+
dotnet restore
11+
12+
# Build the entire solution
13+
dotnet build
14+
15+
# Build specific configuration
16+
dotnet build --configuration Release
17+
dotnet build --configuration Debug
18+
19+
# Build specific project
20+
dotnet build LibEmiddle/LibEmiddle.csproj
21+
```
22+
23+
### Running Tests
24+
```cmd
25+
# Run all tests
26+
dotnet test
27+
28+
# Run tests with specific configuration
29+
dotnet test --configuration Release
30+
31+
# Run tests with code coverage
32+
dotnet test --collect:"XPlat Code Coverage"
33+
34+
# Run a specific test file
35+
dotnet test LibEmiddle.Tests.Unit/ChatSessionTests.cs
36+
37+
# Run tests with verbosity for debugging
38+
dotnet test --verbosity normal
39+
```
40+
41+
### Creating NuGet Packages
42+
```cmd
43+
# Create package from main project
44+
dotnet pack --configuration Release
45+
46+
# Create package with specific version
47+
dotnet pack --configuration Release -p:Version=2.0.1
48+
```
49+
50+
### Code Analysis and Quality
51+
The project uses:
52+
- **TreatWarningsAsErrors**: All warnings are treated as errors
53+
- **Microsoft.CodeAnalysis.NetAnalyzers**: Static code analysis
54+
- **SecurityCodeScan.VS2019**: Security analysis
55+
- **Nullable reference types**: Enabled for null safety
56+
57+
## High-Level Architecture
58+
59+
### Project Structure
60+
This is a .NET 8.0 C# solution with a layered architecture implementing end-to-end encryption protocols using Sodium Library as a DLL
61+
62+
**Core Projects:**
63+
- **LibEmiddle** - Main library with unified `LibEmiddleClient` API
64+
- **LibEmiddle.Abstractions** - Interfaces and contracts
65+
- **LibEmiddle.Domain** - Domain models, DTOs, and enums
66+
- **LibEmiddle.Tests.Unit** - MSTest-based unit tests
67+
68+
### Key Architectural Components
69+
70+
#### 1. Unified Client API (`LibEmiddle.API.LibEmiddleClient`)
71+
The main entry point providing:
72+
- Individual chat sessions via `CreateChatSessionAsync()`
73+
- Group messaging via `CreateGroupAsync()` and `JoinGroupAsync()`
74+
- Multi-device support via `DeviceManager`
75+
- Transport abstraction (HTTP, WebSocket, InMemory)
76+
77+
#### 2. Cryptographic Protocols (`LibEmiddle.Protocol`)
78+
- **X3DHProtocol** - Extended Triple Diffie-Hellman for initial key exchange
79+
- **DoubleRatchetProtocol** - Continuous key rotation with forward secrecy
80+
- **CryptoProvider** - libsodium-based crypto operations (AES-GCM, Ed25519, X25519)
81+
82+
#### 3. Session Management (`LibEmiddle.Sessions`)
83+
- **SessionManager** - Lifecycle management for all session types
84+
- **SessionPersistenceManager** - Secure session storage and recovery
85+
- **ChatSession** - Individual encrypted conversations
86+
- **GroupSession** - Encrypted group messaging with member management
87+
88+
#### 4. Multi-Device Architecture (`LibEmiddle.MultiDevice`)
89+
- **DeviceManager** - Device linking and revocation
90+
- **DeviceLinkingService** - Secure device pairing protocol
91+
- **SyncMessageValidator** - Cross-device state synchronization
92+
93+
#### 5. Transport Layer (`LibEmiddle.Messaging.Transport`)
94+
- **MailboxManager** - Message routing and delivery
95+
- **HttpMailboxTransport** - REST API transport
96+
- **SecureWebSocketClient** - Real-time messaging transport
97+
- **InMemoryMailboxTransport** - Testing transport
98+
99+
#### 6. Key Management (`LibEmiddle.KeyManagement`)
100+
- **KeyManager** - Cryptographic key lifecycle
101+
- **KeyStorage** - Secure key persistence
102+
- Automatic key rotation with configurable strategies
103+
104+
### Security Design Principles
105+
106+
#### Protocol Implementation
107+
- **X3DH + Double Ratchet**: Industry-standard Signal Protocol implementation
108+
- **Perfect Forward Secrecy**: Past messages remain secure if keys are compromised
109+
- **Post-Compromise Security**: Future messages are secure after key recovery
110+
- **Deniable Authentication**: Messages cannot be proven authentic to third parties
111+
112+
#### Key Security Features
113+
- **libsodium Integration**: Uses battle-tested cryptographic primitives
114+
- **Secure Memory Handling**: Sensitive data cleared from memory (`SecureMemory` class)
115+
- **Replay Protection**: Message timestamps and unique IDs prevent replay attacks
116+
- **Constant-Time Operations**: Protection against timing attacks
117+
118+
#### Configuration-Based Security
119+
Security policies configured via `LibEmiddleClientOptions.SecurityPolicy`:
120+
- `RequirePerfectForwardSecrecy`
121+
- `RequireMessageAuthentication`
122+
- `MinimumProtocolVersion`
123+
- `AllowInsecureConnections`
124+
125+
## Development Guidelines
126+
127+
### Cryptographic Constants
128+
All crypto parameters centralized in `LibEmiddle.Domain.Constants`:
129+
- Key sizes (AES-256, X25519, Ed25519)
130+
- Security timeouts and limits
131+
- Protocol version information
132+
133+
### Error Handling Patterns
134+
- Use specific exception types for different error categories
135+
- Always validate input parameters, especially cryptographic material
136+
- Log security events appropriately (without exposing sensitive data)
137+
138+
### Testing Strategy
139+
- MSTest framework with Moq for mocking
140+
- Separate test classes for each major component
141+
- Integration tests cover end-to-end encryption flows
142+
- Performance tests for cryptographic operations
143+
- Unit tests are needed for all implementations
144+
- Unit tests are located in `LibEmiddle.Tests.Unit`
145+
146+
### Version Management
147+
- **v2.x.x**: Current main branch (modern architecture)
148+
- **v1.x.x**: Legacy branch (deprecated)
149+
150+
## Common Development Tasks
151+
152+
### Adding New Message Types
153+
1. Define enum in `LibEmiddle.Domain.Enums.MessageType`
154+
2. Create corresponding DTO in `LibEmiddle.Domain.DTO`
155+
3. Update `MailboxManager` message routing
156+
4. Add serialization/deserialization logic
157+
5. Update transport implementations
158+
159+
### Implementing New Transport
160+
1. Inherit from `BaseMailboxTransport`
161+
2. Implement required abstract methods
162+
3. Add transport type to `TransportType` enum
163+
4. Update `LibEmiddleClient` transport factory
164+
5. Add integration tests
165+
166+
### Adding Cryptographic Operations
167+
1. Extend `ICryptoProvider` interface
168+
2. Implement in `CryptoProvider` using libsodium
169+
3. Add security constants to `Constants` class
170+
4. Update `SecureMemory` for proper cleanup
171+
5. Add comprehensive unit tests
172+
173+
### Multi-Device Features
174+
1. Extend `IDeviceManager` interface
175+
2. Implement in `DeviceManager`
176+
3. Update sync message protocols
177+
4. Add device validation logic
178+
5. Test cross-device scenarios
179+
180+
### Adding new code paths
181+
1. Check for existing code paths to see if it makes more sense to extend existing code paths before creating new ones.
182+
2. Looks for existing related methods before creating new ones to see if they will work for the task requested.

0 commit comments

Comments
 (0)