feat: public obfuscator #10
Open
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
This PR extracts the core obfuscation functionality into a new library product
ConfidentialObfuscator
, enabling other CLI tools and Swift packages to use the obfuscation logic without depending on theswift-confidential
CLI tool.This change transforms the obfuscation functionality from a CLI-only tool into a reusable Swift library.
Why This Change?
The previous architecture tightly coupled the obfuscation logic with the CLI tool, making it difficult to:
What Changed
🆕 New Library Product
ConfidentialObfuscator
library product with a clean public APIConfidentialObfuscator.obfuscate(configurationData:) throws -> String
Data
inputString
🔄 Some refactoring
swift-confidential
) to use the newConfidentialObfuscator
APISourceFileText
to return text viatext()
method instead of writing directly to filesBreaking Changes
None. This is purely additive:
swift-confidential
CLI tool continues to work exactly as beforeUsage Example
Alternatives considered
Make
ConfidentialCore
andParsing
public (I actually did this in the first place; I thought it would be the easy way 😅).I think this will not work well from the consumer perspective since
Configuration
,SourceFileSpec
, and other types will become public. Consumers will need to know how to do the obfuscation correctly.The current solution looks better, since it leaves the configuration parsing and obfuscation logic in a black box, as with the CLI.