Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing NSCoder with Swift's Codable #868

Closed
wants to merge 4 commits into from

Conversation

Vaidios
Copy link

@Vaidios Vaidios commented Sep 6, 2024

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

  • Replaced occurrences of NSKeyedUnarchiver/NSKeyedArchiver with JSONDecoder/JSONEncoder
  • Added encode function to Credentials type

📎 References

It doesn't seem like usage of this API is required in this context. Credentials type doesn't use polymorphism, which could be only handled by NSKeyedUnarchiver.

Thanks to these changes my code now properly runs inside a SPM package

Please let me know if there is something that I don't understand :)

https://forums.swift.org/t/should-i-stick-with-codable-or-switch-back-to-nscoding/61604
#862

🎯 Testing

This is not a breaking change, these code paths are covered by unit tests

@Vaidios Vaidios requested a review from a team as a code owner September 6, 2024 10:29
@Vaidios Vaidios changed the title Removing nskeyedunarchiver Replacing NSCoder with Swift's Codable Sep 6, 2024
do {
return try JSONDecoder().decode(Credentials.self, from: data)
} catch {
print(error.localizedDescription)
Copy link

@theolampert theolampert Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vaidios I know that this error was already not being surfaced here, so this is not a comment on your PR but more this process in general. If an NSCoder failure is the cause of #862 there is an argument to be made that the problem would have been easier to debug had this function either throw here and bubbled the error up or have the .noCredentials error provide a more descriptive message. What are your thoughts @desusai7 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree, it would be much easier to find a root cause if that error would be propagated.
Maybe we should throw an error such as 'credentialsParsingFailure' instead of non-descriptive 'noCredentials'.

PS. For the time being, I will remove that do-catch with print to be optional try, just as before

@Vaidios Vaidios force-pushed the removing-nskeyedunarchiver branch from 42deca3 to 6b18d73 Compare September 9, 2024 07:10
@Vaidios Vaidios requested a review from theolampert September 10, 2024 07:27
@Vaidios
Copy link
Author

Vaidios commented Sep 10, 2024

@theolampert sorry for tagging you here, I was just wondering if there is any button to ask for the review from maintainers and I clicked it without thinking much about it :E

@desusai7
Copy link
Contributor

desusai7 commented Sep 10, 2024

Hi @Vaidios,

Thank you for raising a PR to address this, we will look into it and get back to you !

@Vaidios
Copy link
Author

Vaidios commented Sep 19, 2024

Hey @desusai7, are there any updates on this?

@shusuke0812
Copy link

Hello @desusai7

We are encountering the same issue which gets "No credentials were found in the store." message.
Could you please provide any updates on when this issue might be resolved? Thank you.

@Widcket
Copy link
Contributor

Widcket commented Jan 10, 2025

Hi everyone,

We cannot accept this PR because JSONDecoder cannot read credentials encoded with NSKeyedArchiver. This means all the users of all Auth0 customers using this SDK would be logged out after updating the app and would have to log in again.

This is precisely the reason why the existing NSKeyedUnarchiver/NSKeyedArchiver-based solution was left as-is during the development of Auth0.swift v2.

@shusuke0812 please see #862 (comment) for a way to log the underlying Keychain error.

@Widcket Widcket closed this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants