refactor(storage): inject KeychainHelper into storage classes via init#1153
Merged
Conversation
5 tasks
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four storage classes that read the keychain (
AIKeyStorage,SSHProfileStorage,ConnectionStorage,LicenseStorage) now hold aprivate let keychain: KeychainHelperand read through it instead of dialingKeychainHelper.shared24 times.keychain: KeychainHelper = .shared(matching the pattern already used forsyncTrackerandappSettingsinConnectionStorage).private init()is dropped onAIKeyStorage,SSHProfileStorage, andLicenseStorageso tests can inject a different keychain. Thestatic let shared = X()line still calls the parameterless default.KeychainHelper.shared.Xcalls converted tokeychain.X.Why this matters
This is the next slice of audit findings 3.1 + arch 5.1 ("complete the AppServices threading"). After PRs #1151 and #1152 widened
AppServicesand converted services-aware files, this PR addresses the storage layer's internal cross-references.KeychainHelperis now a dependency of each storage class, not a global it reaches for. Fits the audit's recommended "complete the migration" path.Test plan