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 8 commits into
base: master
Choose a base branch
from
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)
// 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"
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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
code: AuthorizationErrorCode.credentialExport,
code: AuthorizationErrorCode.matchedExcludedCredential,

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does @c mean here?

matchedExcludedCredential,
}

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