LicenseKit 0.4 is out
Nov 9, 2022
LicenseKit 0.4 is out, with a bunch of new features, like new tier capabilities, new license errors and a new cached license service.
LicenseTier now lets you compare and validate if a tier matches another tier level or meets it as a minimum requirement, for instance:
let basic = LicenseTier.basic let silver = LicenseTier.silver let gold = LicenseTier.gold try gold.validateMeets(.silver) // Succeeds try gold.validateMatches(.silver) // Throws an error try basic.validateMeets(.silver) // Throws an error
This makes it a lot easier to implement tier-based functionality.
The previously removed
LicenseError.missingLicense has been re-added, together with a new
.other type that you can use to throw custom license errors.
.other error can be used to invalidate the new license cache for a custom reason, other than the ones that are automatically handled by the library.
There’s a new
CachedLicenseService that can be used to wrap any other license service and add caching capabilities to it.
Cached license services try to get licenses using the wrapped service. If the operation succeeds, the license is cached and returned to the caller. If the operation fails with a
LicenseError, the cache is cleared and the error thrown to the caller. If the operation fails with another error, the service will return any previously cached license, or throw a
missingLicense error if none exists.
Cached license services make it possible to keep licenses valid even if license validation fails due to e.g. network errors. You can combine this with strict expiration dates and licenses that don’t allow expirations to keep previously validated licenses valid until they expire, even if a user stays offline.