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

fix: add missing switch cases and update compiler check #457

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,21 @@ public enum SignInWithAppleError {
errorCode = "authorization-error/notHandled"
case .failed:
errorCode = "authorization-error/failed"
#if (os(iOS) && swift(>=5.5)) || (os(macOS) && swift(>=5.5.1))
#if compiler(>=5.5)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this change needed? The old comment refers to this being shipped in different versions for iOS and macOS.

But overall I would not mind to change this, as we only support Xcode 14.3.1 (with Swift 5.8), so this will work on either OS with this check and that macOS version.

Just generally of the "don't fix what's not broken" camp here, as we don't know if there is not some user relying on this behavior because of a certain old Xcode version (though by now there might be 3 other changes that would've long prevented that one from using the latest version of this package, as we can not test every single combination).

// new case since Xcode 13, arrived earlier in iOS
// use https://swiftly.dev/swift-versions to match Swift to Xcode versions (as this is in practice driven by the OS SDK, not Swift version)
// use https://xcodereleases.com/ to match Swift to Xcode versions (as this is in practice driven by the OS SDK, not Swift version)
case .notInteractive:
errorCode = "authorization-error/notInteractive"
#endif
#if compiler(>=6.0)
case .matchedExcludedCredential:
errorCode = "authorization-error/matchedExcludedCredential"
#endif
#if compiler(>=6.0.3)
case .credentialImport:
errorCode = "authorization-error/credentialImport"
juliansteenbakker marked this conversation as resolved.
Show resolved Hide resolved
case .credentialExport:
errorCode = "authorization-error/credentialExport"
#endif
@unknown default:
print("[SignInWithApplePlugin]: Unknown authorization error code: \(code)");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

- Adds credentialExport and credentialImport to AuthorizationErrorCode

## 1.1.0

- Use proper type name in toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ abstract class SignInWithAppleException implements Exception {
code: AuthorizationErrorCode.failed,
message: exception.message ?? 'no message provided',
);
case 'authorization-error/credentialImport':
return SignInWithAppleAuthorizationException(
code: AuthorizationErrorCode.credentialImport,
message: exception.message ?? 'no message provided',
);
case 'authorization-error/credentialExport':
return SignInWithAppleAuthorizationException(
code: AuthorizationErrorCode.credentialExport,
message: exception.message ?? 'no message provided',
);
case 'authorization-error/matchedExcludedCredential':
return SignInWithAppleAuthorizationException(
code: AuthorizationErrorCode.credentialExport,
message: exception.message ?? 'no message provided',
);

case 'credentials-error':
return SignInWithAppleCredentialsException(
Expand Down Expand Up @@ -114,6 +129,15 @@ enum AuthorizationErrorCode {

/// The authorization attempt failed for an unknown reason.
unknown,

/// The credential export request failed.
credentialExport,

/// The credential import request failed.
credentialImport,

/// This error should only be returned when specifying @c excludedCredentials on a public key credential registration request.
matchedExcludedCredential,
}

/// A [SignInWithAppleException] indicating something went wrong while authenticating.
Expand Down