refactor: remove all dead legacy and migration code

- Remove unused migrateSession() functions (never called in production)
  - NoiseSession.migrateSession() - 13 lines
  - NoiseEncryptionService.migratePeerSession() - 18 lines
  - Test for migration functionality - 17 lines

- Remove unnecessary keychain cleanup code (no legacy data existed)
  - cleanupLegacyKeychainItems() - 62 lines
  - aggressiveCleanupLegacyItems() - 72 lines
  - resetCleanupFlag() - 4 lines
  - Simplified panic mode to just use deleteAllKeychainData()

Total removed: 194 lines of dead/unnecessary code

Analysis revealed:
- KeychainManager introduced July 5, 2025
- Cleanup code added July 15, 2025 (10 days later)
- Legacy service names were never used in production
- Migration functions were incomplete implementation never called
- Peer ID rotation remains active (not legacy)
This commit is contained in:
jack
2025-08-12 10:15:05 +02:00
parent a36eda3fbe
commit 63f05b5d7e
5 changed files with 2 additions and 196 deletions
@@ -226,23 +226,6 @@ final class NoiseProtocolTests: XCTestCase {
XCTAssertEqual(decrypted, plaintext)
}
func testSessionMigration() throws {
let manager = NoiseSessionManager(localStaticKey: aliceKey)
// Create and establish a session
_ = try manager.initiateHandshake(with: TestConstants.testPeerID2)
// Migrate to new peer ID
let newPeerID = TestConstants.testPeerID3
manager.migrateSession(from: TestConstants.testPeerID2, to: newPeerID)
// Old peer ID should not have session
XCTAssertNil(manager.getSession(for: TestConstants.testPeerID2))
// New peer ID should have the session
XCTAssertNotNil(manager.getSession(for: newPeerID))
}
// MARK: - Security Tests
func testTamperedCiphertextDetection() throws {