Auth0.swift icon indicating copy to clipboard operation
Auth0.swift copied to clipboard

Replacing NSCoder with Swift's Codable

Open Vaidios opened this issue 1 year ago • 3 comments

  • [x] All new/changed/fixed functionality is covered by tests (or N/A)
  • [x] 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 https://github.com/auth0/Auth0.swift/issues/862

🎯 Testing

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

Vaidios avatar Sep 06 '24 10:09 Vaidios

@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

Vaidios avatar Sep 10 '24 07:09 Vaidios

Hi @Vaidios,

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

desusai7 avatar Sep 10 '24 07:09 desusai7

Hey @desusai7, are there any updates on this?

Vaidios avatar Sep 19 '24 07:09 Vaidios

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.

shusuke0812 avatar Dec 17 '24 08:12 shusuke0812

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 https://github.com/auth0/Auth0.swift/issues/862#issuecomment-2583238245 for a way to log the underlying Keychain error.

Widcket avatar Jan 10 '25 19:01 Widcket