Replace JSONObjectPayload
with Codable
on Credentials
[SDK-2958]
#549
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.
Changes
This PR replaces the conformance of
Credentials
toJSONObjectPayload
with conformance toCodable
and uses the newer, non-deprecated methods ofNSKeyedArchiver
andNSKeyedUnarchiver
to archive and unarchiveCredentials
.Additionally, the
Credentials
class was madefinal
.Care was taken to ensure that credentials archived with Auth0.swift 1.x can be unarchived successfully, and the other way around (in case customers need to downgrade to 1.x). Otherwise, if apps are using the Credentials Manager of Auth0.swift 1.x and then get upgraded to 2.x, the stored credentials will not be readable, essentially logging out all the users.
To maintain compatibility,
@objc(A0Credentials)
was added back toCredentials
, which still needs to inherit fromNSObject
.Dropping
NSSecureCoding
in favor ofCodable
+ theCodable
-supporting methods ofNSKeyedArchiver
andNSKeyedUnarchiver
has been ruled out for the sake of this compatibility after doing a spike testing it.Testing
The backward compatibility of the archived credentials was tested manually in a test app, by:
These tests were performed on both iOS 15 (simulator) and macOS Big Sur.
Checklist