Skip to content

Commit 8656e71

Browse files
authored
Merge pull request #51 from lupidan/canary
v1.3.0 Release
2 parents e245b10 + 49b2451 commit 8656e71

26 files changed

Lines changed: 245 additions & 129 deletions

AppleAuth/AppleAuthLoginArgs.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ public struct AppleAuthLoginArgs
66
{
77
public readonly LoginOptions Options;
88
public readonly string Nonce;
9+
public readonly string State;
910

1011
public AppleAuthLoginArgs(
1112
LoginOptions options,
12-
string nonce = null)
13+
string nonce = null,
14+
string state = null)
1315
{
1416
this.Options = options;
1517
this.Nonce = nonce;
18+
this.State = state;
1619
}
1720
}
1821
}

AppleAuth/AppleAuthManager.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ namespace AppleAuth
1010
{
1111
public class AppleAuthManager : IAppleAuthManager
1212
{
13+
static AppleAuthManager()
14+
{
15+
const string versionMessage = "Using Sign in with Apple Unity Plugin - v1.3.0";
16+
#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
17+
PInvoke.AppleAuth_LogMessage(versionMessage);
18+
#else
19+
UnityEngine.Debug.Log(versionMessage);
20+
#endif
21+
}
22+
1323
#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
1424
private readonly IPayloadDeserializer _payloadDeserializer;
1525

@@ -47,6 +57,7 @@ public void QuickLogin(
4757
{
4858
#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
4959
var nonce = quickLoginArgs.Nonce;
60+
var state = quickLoginArgs.State;
5061
var requestId = CallbackHandler.AddMessageCallback(
5162
true,
5263
payload =>
@@ -60,7 +71,7 @@ public void QuickLogin(
6071
successCallback(response.AppleIDCredential);
6172
});
6273

63-
PInvoke.AppleAuth_QuickLogin(requestId, nonce);
74+
PInvoke.AppleAuth_QuickLogin(requestId, nonce, state);
6475
#else
6576
throw new Exception("AppleAuthManager is not supported in this platform");
6677
#endif
@@ -79,6 +90,7 @@ public void LoginWithAppleId(
7990
#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
8091
var loginOptions = loginArgs.Options;
8192
var nonce = loginArgs.Nonce;
93+
var state = loginArgs.State;
8294
var requestId = CallbackHandler.AddMessageCallback(
8395
true,
8496
payload =>
@@ -90,7 +102,7 @@ public void LoginWithAppleId(
90102
successCallback(response.AppleIDCredential);
91103
});
92104

93-
PInvoke.AppleAuth_LoginWithAppleId(requestId, (int)loginOptions, nonce);
105+
PInvoke.AppleAuth_LoginWithAppleId(requestId, (int)loginOptions, nonce, state);
94106
#else
95107
throw new Exception("AppleAuthManager is not supported in this platform");
96108
#endif
@@ -310,13 +322,16 @@ public static void NativeMessageHandlerCallback(uint requestId, string payload)
310322
public static extern void AppleAuth_GetCredentialState(uint requestId, string userId);
311323

312324
[System.Runtime.InteropServices.DllImport(DllName)]
313-
public static extern void AppleAuth_LoginWithAppleId(uint requestId, int loginOptions, string nonceCStr);
325+
public static extern void AppleAuth_LoginWithAppleId(uint requestId, int loginOptions, string nonceCStr, string stateCStr);
314326

315327
[System.Runtime.InteropServices.DllImport(DllName)]
316-
public static extern void AppleAuth_QuickLogin(uint requestId, string nonceCStr);
328+
public static extern void AppleAuth_QuickLogin(uint requestId, string nonceCStr, string stateCStr);
317329

318330
[System.Runtime.InteropServices.DllImport(DllName)]
319331
public static extern void AppleAuth_RegisterCredentialsRevokedCallbackId(uint callbackId);
332+
333+
[System.Runtime.InteropServices.DllImport(DllName)]
334+
public static extern void AppleAuth_LogMessage(string messageCStr);
320335
}
321336
#endif
322337
}

AppleAuth/AppleAuthQuickLoginArgs.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ namespace AppleAuth
33
public struct AppleAuthQuickLoginArgs
44
{
55
public readonly string Nonce;
6+
public readonly string State;
67

7-
public AppleAuthQuickLoginArgs(string nonce = null)
8+
public AppleAuthQuickLoginArgs(string nonce = null, string state = null)
89
{
910
this.Nonce = nonce;
11+
this.State = state;
1012
}
1113
}
1214
}

AppleAuth/Editor/ProjectCapabilityManagerExtension.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public static void AddSignInWithAppleWithCompatibility(this ProjectCapabilityMan
5454
var mainTargetGuid = targetGuidField.GetValue(manager) as string;
5555
var capabilityType = constructorInfo.Invoke(new object[] { "com.apple.developer.applesignin.custom", true, string.Empty, true }) as PBXCapabilityType;
5656

57-
var targetGuidToAddFramework = unityFrameworkTargetGuid ?? mainTargetGuid;
57+
var targetGuidToAddFramework = unityFrameworkTargetGuid;
58+
if (targetGuidToAddFramework == null)
59+
{
60+
targetGuidToAddFramework = mainTargetGuid;
61+
}
62+
5863
project.AddFrameworkToProject(targetGuidToAddFramework, AuthenticationServicesFramework, true);
5964
project.AddCapability(mainTargetGuid, capabilityType, entitlementFilePath, false);
6065
}

AppleAuth/Extensions/AppleErrorExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ namespace AppleAuth.Extensions
66
{
77
public static class AppleErrorExtensions
88
{
9-
public static AuthorizationErrorCode? GetAuthorizationErrorCode(this IAppleError error)
9+
public static AuthorizationErrorCode GetAuthorizationErrorCode(this IAppleError error)
1010
{
1111
if (error.Domain == "com.apple.AuthenticationServices.AuthorizationError" &&
1212
Enum.IsDefined(typeof(AuthorizationErrorCode), error.Code))
1313
{
1414
return (AuthorizationErrorCode)error.Code;
1515
}
1616

17-
return null;
17+
return AuthorizationErrorCode.Unknown;
1818
}
1919
}
2020
}

AppleAuth/Native/AppleError.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
namespace AppleAuth.Native
66
{
77
[Serializable]
8-
public class AppleError : IAppleError, ISerializationCallbackReceiver
8+
internal class AppleError : IAppleError, ISerializationCallbackReceiver
99
{
10-
public int _code;
11-
public string _domain;
12-
public string _localizedDescription;
13-
public string[] _localizedRecoveryOptions;
14-
public string _localizedRecoverySuggestion;
15-
public string _localizedFailureReason;
10+
public int _code = 0;
11+
public string _domain = null;
12+
public string _localizedDescription = null;
13+
public string[] _localizedRecoveryOptions = null;
14+
public string _localizedRecoverySuggestion = null;
15+
public string _localizedFailureReason = null;
1616

1717
public int Code { get { return this._code; } }
1818
public string Domain { get { return this._domain; } }

AppleAuth/Native/AppleIDCredential.cs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,36 @@
66
namespace AppleAuth.Native
77
{
88
[Serializable]
9-
public class AppleIDCredential : IAppleIDCredential, ISerializationCallbackReceiver
9+
internal class AppleIDCredential : IAppleIDCredential, ISerializationCallbackReceiver
1010
{
11-
public string _identityToken;
12-
public string _authorizationCode;
13-
public string _state;
14-
public string _user;
15-
public string[] _authorizedScopes;
16-
public bool _hasFullName;
17-
public FullPersonName _fullName;
18-
public string _email;
19-
public RealUserStatus _realUserStatus;
20-
21-
public byte[] IdentityToken { get { return Convert.FromBase64String(this._identityToken); } }
22-
public byte[] AuthorizationCode { get { return Convert.FromBase64String(this._authorizationCode); } }
11+
public string _base64IdentityToken = null;
12+
public string _base64AuthorizationCode = null;
13+
public string _state = null;
14+
public string _user = null;
15+
public string[] _authorizedScopes = null;
16+
public bool _hasFullName = false;
17+
public FullPersonName _fullName = null;
18+
public string _email = null;
19+
public int _realUserStatus = 0;
20+
21+
private byte[] _identityToken;
22+
private byte[] _authorizationCode;
23+
24+
public byte[] IdentityToken { get { return this._identityToken; } }
25+
public byte[] AuthorizationCode { get { return this._authorizationCode; } }
2326
public string State { get { return this._state; } }
2427
public string User { get { return this._user; } }
2528
public string[] AuthorizedScopes { get { return this._authorizedScopes; } }
2629
public IPersonName FullName { get { return this._fullName; } }
2730
public string Email { get { return this._email; } }
28-
public RealUserStatus RealUserStatus { get { return this._realUserStatus; } }
31+
public RealUserStatus RealUserStatus { get { return (RealUserStatus) this._realUserStatus; } }
2932

3033
public void OnBeforeSerialize() { }
3134

3235
public void OnAfterDeserialize()
3336
{
34-
SerializationTools.FixSerializationForString(ref this._identityToken);
35-
SerializationTools.FixSerializationForString(ref this._authorizationCode);
37+
SerializationTools.FixSerializationForString(ref this._base64IdentityToken);
38+
SerializationTools.FixSerializationForString(ref this._base64AuthorizationCode);
3639
SerializationTools.FixSerializationForString(ref this._state);
3740
SerializationTools.FixSerializationForString(ref this._user);
3841
SerializationTools.FixSerializationForString(ref this._email);
@@ -42,6 +45,9 @@ public void OnAfterDeserialize()
4245
SerializationTools.FixSerializationForObject(ref this._fullName, this._hasFullName);
4346

4447
SerializationTools.FixSerializationForFullPersonName(ref this._fullName);
48+
49+
this._identityToken = SerializationTools.GetBytesFromBase64String(this._base64IdentityToken, "_identityToken");
50+
this._authorizationCode = SerializationTools.GetBytesFromBase64String(this._base64AuthorizationCode, "_authorizationCode");
4551
}
4652
}
4753
}

AppleAuth/Native/CredentialStateResponse.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
namespace AppleAuth.Native
77
{
88
[Serializable]
9-
public class CredentialStateResponse : ICredentialStateResponse, ISerializationCallbackReceiver
9+
internal class CredentialStateResponse : ICredentialStateResponse, ISerializationCallbackReceiver
1010
{
11-
public bool _success;
12-
public bool _hasCredentialState;
13-
public bool _hasError;
14-
public CredentialState _credentialState;
15-
public AppleError _error;
11+
public bool _success = false;
12+
public bool _hasCredentialState = false;
13+
public bool _hasError = false;
14+
public int _credentialState = 0;
15+
public AppleError _error = null;
1616

1717
public bool Success { get { return this._success; } }
18-
public CredentialState CredentialState { get { return this._credentialState; } }
18+
public CredentialState CredentialState { get { return (CredentialState) this._credentialState; } }
1919
public IAppleError Error { get { return this._error; } }
2020

2121
public void OnBeforeSerialize() { }
@@ -26,4 +26,4 @@ public void OnAfterDeserialize()
2626
SerializationTools.FixSerializationForObject(ref this._error, this._hasError);
2727
}
2828
}
29-
}
29+
}

AppleAuth/Native/FullPersonName.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
namespace AppleAuth.Native
55
{
66
[Serializable]
7-
public class FullPersonName : PersonName, IPersonName
7+
internal class FullPersonName : PersonName, IPersonName
88
{
9-
public bool _hasPhoneticRepresentation;
10-
public PersonName _phoneticRepresentation;
9+
public bool _hasPhoneticRepresentation = false;
10+
public PersonName _phoneticRepresentation = null;
1111

1212
public new IPersonName PhoneticRepresentation { get { return _phoneticRepresentation; } }
1313

AppleAuth/Native/LoginWithAppleIdResponse.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace AppleAuth.Native
66
{
77
[Serializable]
8-
public class LoginWithAppleIdResponse : ILoginWithAppleIdResponse, ISerializationCallbackReceiver
8+
internal class LoginWithAppleIdResponse : ILoginWithAppleIdResponse, ISerializationCallbackReceiver
99
{
10-
public bool _success;
11-
public bool _hasAppleIdCredential;
12-
public bool _hasPasswordCredential;
13-
public bool _hasError;
14-
public AppleIDCredential _appleIdCredential;
15-
public PasswordCredential _passwordCredential;
16-
public AppleError _error;
10+
public bool _success = false;
11+
public bool _hasAppleIdCredential = false;
12+
public bool _hasPasswordCredential = false;
13+
public bool _hasError = false;
14+
public AppleIDCredential _appleIdCredential = null;
15+
public PasswordCredential _passwordCredential = null;
16+
public AppleError _error = null;
1717

1818
public bool Success { get { return this._success; } }
1919
public IAppleError Error { get { return this._error; } }

0 commit comments

Comments
 (0)