com.xd.sdk.account 6.29.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Plugins/Android/libs/XDGAccount_7.0.0.aar +0 -0
- package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGAccountBridge.java.meta → Plugins/Android/libs/XDGAccount_7.0.0.aar.meta} +2 -2
- package/Plugins/Android/libs/XDGBridgeAccount_v7_7.0.0.aar +0 -0
- package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnity.java.meta → Plugins/Android/libs/XDGBridgeAccount_v7_7.0.0.aar.meta} +2 -2
- package/Plugins/Android/libs/XDGSupport_7.0.0.aar +0 -0
- package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnityImpl.java.meta → Plugins/Android/libs/XDGSupport_7.0.0.aar.meta} +2 -2
- package/Plugins/Android/libs.meta +1 -1
- package/Plugins/Android.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/TDSGlobalThirdPartyLoginHelper.h +2 -8
- package/Plugins/iOS/XDAccountSDK.framework/Headers/TDSGlobalThirdPartyLoginHelper.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDAccountSDK-Swift.h +329 -0
- package/Plugins/iOS/XDAccountSDK.framework/Headers/{TDSGlobalThirdPartyLoginManager.h.meta → XDAccountSDK-Swift.h.meta} +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDAccountSDK.h +1 -2
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDAccountSDK.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccount.h +29 -43
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccount.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountDefines.h +43 -0
- package/Plugins/iOS/XDAccountSDK.framework/Headers/{XDGPhoneAuthManager.h.meta → XDGAccountDefines.h.meta} +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h +3 -3
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLogger+Account.h +3 -0
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLogger+Account.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLoginEntriesConfig.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLoginService.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGTapLoginPermissionDialog.h.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Headers.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Info.plist +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/Info.plist.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/{Headers/XDGRoleInfo.h.meta → Modules/XDAccountSDK.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo.meta} +1 -1
- package/{Mobile/Http.meta → Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/Project.meta} +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.abi.json +9 -0
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.abi.json.meta +7 -0
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftdoc.meta +7 -0
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftmodule +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftmodule.meta +7 -0
- package/{Mobile/Editor.meta → Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule.meta} +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Modules/module.modulemap.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/Modules.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK.meta +1 -1
- package/Plugins/iOS/XDAccountSDK.framework.meta +4 -4
- package/Plugins/iOS.meta +1 -1
- package/Plugins.meta +1 -1
- package/Runtime/Internal/IXDGAccount.Extended.cs +11 -0
- package/{Mobile/Http/XDGAccountHttpConfigMobile.cs.meta → Runtime/Internal/IXDGAccount.Extended.cs.meta} +1 -1
- package/Runtime/Internal/Mobile/AccountFeaturesImpl.cs +348 -0
- package/{Mobile/User/UserManagerMobile.cs.meta → Runtime/Internal/Mobile/AccountFeaturesImpl.cs.meta} +1 -1
- package/Runtime/Internal/Mobile/Http/LoginSyncResponse.cs +14 -0
- package/Runtime/Internal/Mobile/Http/LoginSyncResponse.cs.meta +3 -0
- package/Runtime/Internal/Mobile/Http/MacAuthenticationInterceptor.cs +37 -0
- package/Runtime/Internal/Mobile/Http/MacAuthenticationInterceptor.cs.meta +3 -0
- package/Runtime/Internal/Mobile/Http.meta +3 -0
- package/{Mobile.meta → Runtime/Internal/Mobile.meta} +1 -1
- package/Runtime/Internal/Standalone/AccessToken/AccessTokenModule.cs +168 -0
- package/{Mobile/Editor/XDAccountMobileProcessBuild.cs.meta → Runtime/Internal/Standalone/AccessToken/AccessTokenModule.cs.meta} +1 -1
- package/Runtime/Internal/Standalone/AccessToken.meta +8 -0
- package/Runtime/Internal/Standalone/AccountCell.cs +143 -0
- package/{Mobile/XDGAccountMobile.cs.meta → Runtime/Internal/Standalone/AccountCell.cs.meta} +1 -1
- package/Runtime/Internal/Standalone/AccountFeaturesImpl.cs +461 -0
- package/Runtime/Internal/Standalone/AccountFeaturesImpl.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/AppleAuth.cs +27 -0
- package/Runtime/Internal/Standalone/Auth/AppleAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/FacebookAuth.cs +27 -0
- package/Runtime/Internal/Standalone/Auth/FacebookAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/GoogleAuth.cs +27 -0
- package/Runtime/Internal/Standalone/Auth/GoogleAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/GuestAuth.cs +22 -0
- package/Runtime/Internal/Standalone/Auth/GuestAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/PhoneAuth.cs +43 -0
- package/Runtime/Internal/Standalone/Auth/PhoneAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/SteamAuth.cs +90 -0
- package/Runtime/Internal/Standalone/Auth/SteamAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/TapAuth.cs +72 -0
- package/Runtime/Internal/Standalone/Auth/TapAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth/WebAuth.cs +144 -0
- package/Runtime/Internal/Standalone/Auth/WebAuth.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Auth.meta +8 -0
- package/Runtime/Internal/Standalone/Compliance/XDComplianceCode.cs +15 -0
- package/Runtime/Internal/Standalone/Compliance/XDComplianceCode.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Compliance.meta +8 -0
- package/Runtime/Internal/Standalone/LoginModule/Email/EmailModule.cs +374 -0
- package/Runtime/Internal/Standalone/LoginModule/Email/EmailModule.cs.meta +11 -0
- package/Runtime/Internal/Standalone/LoginModule/Email.meta +8 -0
- package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModule.cs +245 -0
- package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModule.cs.meta +11 -0
- package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModuleIO.cs +392 -0
- package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModuleIO.cs.meta +11 -0
- package/Runtime/Internal/Standalone/LoginModule/Phone.meta +8 -0
- package/Runtime/Internal/Standalone/LoginModule.meta +8 -0
- package/Runtime/Internal/Standalone/SupportModule/SupportModule.cs +228 -0
- package/Runtime/Internal/Standalone/SupportModule/SupportModule.cs.meta +3 -0
- package/Runtime/Internal/Standalone/SupportModule/SupportResponse.cs +27 -0
- package/Runtime/Internal/Standalone/SupportModule/SupportResponse.cs.meta +3 -0
- package/Runtime/Internal/Standalone/SupportModule.meta +3 -0
- package/Runtime/Internal/Standalone/Track/AliyunTrack.Login.cs +479 -0
- package/Runtime/Internal/Standalone/Track/AliyunTrack.Login.cs.meta +11 -0
- package/Runtime/Internal/Standalone/Track.meta +8 -0
- package/Runtime/Internal/Standalone/UI/CodeUnbindAlert.cs +156 -0
- package/Runtime/Internal/Standalone/UI/CodeUnbindAlert.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/Email/EmailAlert.cs +295 -0
- package/Runtime/Internal/Standalone/UI/Email/EmailAlert.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/Email.meta +8 -0
- package/Runtime/Internal/Standalone/UI/PhoneIO/AreaCodeCell.cs +46 -0
- package/Runtime/Internal/Standalone/UI/PhoneIO/AreaCodeCell.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/PhoneIO/PhoneAlertIO.cs +522 -0
- package/Runtime/Internal/Standalone/UI/PhoneIO/PhoneAlertIO.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/PhoneIO.meta +8 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification/PhoneNumberInputAlert.cs +84 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification/PhoneNumberInputAlert.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification/RiskControlAlert.cs +190 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification/RiskControlAlert.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification/VerifyCodeInputAlert.cs +164 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification/VerifyCodeInputAlert.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UI/PhoneVerification.meta +8 -0
- package/Runtime/Internal/Standalone/UI.meta +8 -0
- package/Runtime/Internal/Standalone/UserCenterAlert.cs +405 -0
- package/Runtime/Internal/Standalone/UserCenterAlert.cs.meta +11 -0
- package/Runtime/Internal/Standalone/UserModule.cs +604 -0
- package/Runtime/Internal/Standalone/UserModule.cs.meta +11 -0
- package/Runtime/Internal/Standalone/WebFunction/AccessTokenWebFunction.cs +47 -0
- package/Runtime/Internal/Standalone/WebFunction/AccessTokenWebFunction.cs.meta +3 -0
- package/Runtime/Internal/Standalone/WebFunction.meta +3 -0
- package/{Mobile/Plugins.meta → Runtime/Internal/Standalone.meta} +1 -1
- package/Runtime/Internal/XDGAccountEventHandler.cs +23 -0
- package/Runtime/Internal/XDGAccountEventHandler.cs.meta +3 -0
- package/Runtime/Internal/XDGAccountInternal.cs +86 -0
- package/Runtime/Internal/XDGAccountInternal.cs.meta +11 -0
- package/Runtime/Internal.meta +1 -1
- package/Runtime/Public/XDGAccount.Deprecated.cs +37 -0
- package/Runtime/Public/XDGAccount.Deprecated.cs.meta +11 -0
- package/Runtime/Public/XDGAccount.cs +107 -0
- package/Runtime/{XDGAccount.cs.meta → Public/XDGAccount.cs.meta} +1 -1
- package/Runtime/Public.meta +8 -0
- package/Runtime/XD.SDK.Account.asmdef +7 -2
- package/Runtime/XD.SDK.Account.asmdef.meta +1 -1
- package/Runtime.meta +1 -1
- package/package.json +5 -5
- package/package.json.meta +2 -2
- package/Mobile/Editor/XD.SDK.Account.Mobile.Editor.asmdef +0 -20
- package/Mobile/Editor/XD.SDK.Account.Mobile.Editor.asmdef.meta +0 -7
- package/Mobile/Editor/XDAccountMobileProcessBuild.cs +0 -20
- package/Mobile/Http/XDGAccountHttpConfigMobile.cs +0 -36
- package/Mobile/Plugins/Android/com/xd/account/bridge/XDGAccountBridge.java +0 -36
- package/Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnity.java +0 -16
- package/Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnityImpl.java +0 -20
- package/Mobile/Plugins/Android/com/xd/account/bridge.meta +0 -8
- package/Mobile/Plugins/Android/com/xd/account.meta +0 -8
- package/Mobile/Plugins/Android/com/xd.meta +0 -8
- package/Mobile/Plugins/Android/com.meta +0 -8
- package/Mobile/Plugins/Android.meta +0 -8
- package/Mobile/Plugins/iOS/XDAccountBridge.m +0 -29
- package/Mobile/Plugins/iOS/XDAccountBridge.m.meta +0 -37
- package/Mobile/Plugins/iOS/XDGLoginServiceUnity.h +0 -17
- package/Mobile/Plugins/iOS/XDGLoginServiceUnity.h.meta +0 -27
- package/Mobile/Plugins/iOS/XDGLoginServiceUnity.m +0 -23
- package/Mobile/Plugins/iOS/XDGLoginServiceUnity.m.meta +0 -37
- package/Mobile/Plugins/iOS.meta +0 -8
- package/Mobile/User/UserManagerMobile.cs +0 -45
- package/Mobile/User.meta +0 -8
- package/Mobile/XD.SDK.Account.Mobile.asmdef +0 -23
- package/Mobile/XD.SDK.Account.Mobile.asmdef.meta +0 -7
- package/Mobile/XDGAccountMobile.cs +0 -138
- package/Mobile/XDGAccountMobileImpl.cs +0 -444
- package/Mobile/XDGAccountMobileImpl.cs.meta +0 -11
- package/Mobile/XDGTokenManager.cs +0 -116
- package/Mobile/XDGTokenManager.cs.meta +0 -11
- package/Mobile/XDGUserWrapper.cs +0 -167
- package/Mobile/XDGUserWrapper.cs.meta +0 -11
- package/Plugins/Android/libs/XDGAccount_6.29.1.aar +0 -0
- package/Plugins/Android/libs/XDGAccount_6.29.1.aar.meta +0 -32
- package/Plugins/iOS/XDAccountSDK.framework/Headers/TDSGlobalThirdPartyLoginManager.h +0 -47
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGPhoneAuthManager.h +0 -33
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGRoleInfo.h +0 -22
- package/README.md +0 -0
- package/README.md.meta +0 -7
- package/Runtime/Editor/XD.SDK.Account.Editor.asmdef +0 -19
- package/Runtime/Editor/XD.SDK.Account.Editor.asmdef.meta +0 -7
- package/Runtime/Editor/XDAccountProcessBuild.cs +0 -18
- package/Runtime/Editor/XDAccountProcessBuild.cs.meta +0 -11
- package/Runtime/Editor.meta +0 -8
- package/Runtime/IXDGAccount.cs +0 -44
- package/Runtime/IXDGAccount.cs.meta +0 -11
- package/Runtime/Internal/Http/IXDAccountHttpConfig.cs +0 -9
- package/Runtime/Internal/Http/IXDAccountHttpConfig.cs.meta +0 -11
- package/Runtime/Internal/Http/XDAccountHttpConfig.cs +0 -32
- package/Runtime/Internal/Http/XDAccountHttpConfig.cs.meta +0 -11
- package/Runtime/Internal/Http.meta +0 -8
- package/Runtime/Internal/User/IUserManagerPlatformWrapper.cs +0 -7
- package/Runtime/Internal/User/IUserManagerPlatformWrapper.cs.meta +0 -11
- package/Runtime/Internal/User.meta +0 -8
- package/Runtime/UserManager.cs +0 -35
- package/Runtime/UserManager.cs.meta +0 -11
- package/Runtime/XDGAccessToken.cs +0 -18
- package/Runtime/XDGAccessToken.cs.meta +0 -11
- package/Runtime/XDGAccount.cs +0 -130
- package/Runtime/XDGLoginType.cs +0 -17
- package/Runtime/XDGLoginType.cs.meta +0 -11
- package/Runtime/XDGRoleInfo.cs +0 -24
- package/Runtime/XDGRoleInfo.cs.meta +0 -11
- package/Runtime/XDGUser.cs +0 -30
- package/Runtime/XDGUser.cs.meta +0 -11
- package/Runtime/XDGUserStatusCode.cs +0 -16
- package/Runtime/XDGUserStatusCode.cs.meta +0 -11
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#if UNITY_EDITOR || UNITY_STANDALONE
|
|
2
|
+
using System;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using Newtonsoft.Json;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
using XD.SDK.Common;
|
|
9
|
+
using XD.SDK.Common.Internal;
|
|
10
|
+
using XD.SDK.Common.Internal.Standalone;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
namespace XD.SDK.Account.Internal.Standalone
|
|
14
|
+
{
|
|
15
|
+
public class AccessTokenModule
|
|
16
|
+
{
|
|
17
|
+
// 登录
|
|
18
|
+
private readonly static string XDG_COMMON_LOGIN = "api/login/v1/union";
|
|
19
|
+
|
|
20
|
+
// 登录不注册,主机登录时用到
|
|
21
|
+
private readonly static string XDG_COMMON_SIGNIN = "api/login/v1/signin";
|
|
22
|
+
|
|
23
|
+
// 刷新 token
|
|
24
|
+
private readonly static string XDG_COMMON_REFRESH = "api/login/v1/token/refresh";
|
|
25
|
+
|
|
26
|
+
private static readonly Persistence persistence = new Persistence(Path.Combine(Application.persistentDataPath,
|
|
27
|
+
XDGConstants.XD_PERSISTENCE_NAME,
|
|
28
|
+
"access_token_v2"));
|
|
29
|
+
|
|
30
|
+
public static XDGAccessToken local;
|
|
31
|
+
|
|
32
|
+
static AccessTokenModule()
|
|
33
|
+
{
|
|
34
|
+
// 迁移旧数据
|
|
35
|
+
string v1Path = Path.Combine(Application.persistentDataPath,
|
|
36
|
+
XDGConstants.XD_PERSISTENCE_NAME,
|
|
37
|
+
"access_token");
|
|
38
|
+
if (File.Exists(v1Path))
|
|
39
|
+
{
|
|
40
|
+
// 迁移
|
|
41
|
+
try
|
|
42
|
+
{
|
|
43
|
+
string v2Path = Path.Combine(Application.persistentDataPath,
|
|
44
|
+
XDGConstants.XD_PERSISTENCE_NAME,
|
|
45
|
+
"access_token_v2");
|
|
46
|
+
string encryptedData =
|
|
47
|
+
EncryptionUtils.Encrypt(File.ReadAllText(v1Path), SystemInfo.deviceUniqueIdentifier);
|
|
48
|
+
File.WriteAllText(v2Path, encryptedData);
|
|
49
|
+
|
|
50
|
+
File.Delete(v1Path);
|
|
51
|
+
}
|
|
52
|
+
catch (Exception e)
|
|
53
|
+
{
|
|
54
|
+
XDGLogger.Warn(e.Message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public static async Task<XDGAccessToken> GetLocalAccessToken()
|
|
60
|
+
{
|
|
61
|
+
if (local == null)
|
|
62
|
+
{
|
|
63
|
+
local = await persistence.Load<XDGAccessToken>(SystemInfo.deviceUniqueIdentifier);
|
|
64
|
+
}
|
|
65
|
+
return local;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static void ClearToken()
|
|
69
|
+
{
|
|
70
|
+
persistence.Delete();
|
|
71
|
+
local = null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// 登录且注册
|
|
76
|
+
/// </summary>
|
|
77
|
+
/// <param name="param"></param>
|
|
78
|
+
/// <returns></returns>
|
|
79
|
+
public static Task<XDGAccessToken> Login(Dictionary<string, object> param, Dictionary<string, object> cacheData)
|
|
80
|
+
{
|
|
81
|
+
return LoginInternal(XDG_COMMON_LOGIN, param, cacheData);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
/// 登录不注册
|
|
86
|
+
/// </summary>
|
|
87
|
+
/// <param name="param"></param>
|
|
88
|
+
/// <returns></returns>
|
|
89
|
+
public static Task<XDGAccessToken> SignIn(Dictionary<string, object> param, Dictionary<string, object> cacheData)
|
|
90
|
+
{
|
|
91
|
+
return LoginInternal(XDG_COMMON_SIGNIN, param, cacheData);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static async Task<XDGAccessToken> LoginInternal(string path,
|
|
95
|
+
Dictionary<string, object> param, Dictionary<string, object> cacheData)
|
|
96
|
+
{
|
|
97
|
+
try
|
|
98
|
+
{
|
|
99
|
+
AccessTokenResponse response = await XDHttpClient.Client.PostAsync<AccessTokenResponse>(path, data: param);
|
|
100
|
+
|
|
101
|
+
if (cacheData == null)
|
|
102
|
+
{
|
|
103
|
+
local = new XDGAccessToken();
|
|
104
|
+
}
|
|
105
|
+
else
|
|
106
|
+
{
|
|
107
|
+
local = JsonConvert.DeserializeObject<XDGAccessToken>(JsonConvert.SerializeObject(cacheData));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return await UpdateLocalToken(response.AccessToken);
|
|
111
|
+
}
|
|
112
|
+
catch (XDHttpException xdException)
|
|
113
|
+
{
|
|
114
|
+
var errorMsg = xdException.Message;
|
|
115
|
+
// 所有 40801 错误代表 401 授权失败,需要明示原因为 XD_TOKEN_EXPIRED
|
|
116
|
+
if (xdException.Code == ResponseCode.Account.TokenExpired || xdException.HttpStatusCode == 401)
|
|
117
|
+
errorMsg = "XD_TOKEN_EXPIRED";
|
|
118
|
+
// 触发风控以及登陆频繁不需要发送 PreFail
|
|
119
|
+
if (xdException.Code != PhoneModule.INVALID_VERIFY_CODE &&
|
|
120
|
+
xdException.Code != PhoneModule.LOGIN_REQUEST_FREQUENTLY)
|
|
121
|
+
{
|
|
122
|
+
AliyunTrack.LoginPreFail(errorMsg);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
throw xdException;
|
|
126
|
+
}
|
|
127
|
+
catch (Exception e)
|
|
128
|
+
{
|
|
129
|
+
AliyunTrack.LoginPreFail(e.Message);
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public static async Task<XDGAccessToken> Refresh()
|
|
135
|
+
{
|
|
136
|
+
RefreshTokenResponse response = await XDHttpClient.Client.PostAsync<RefreshTokenResponse>(XDG_COMMON_REFRESH);
|
|
137
|
+
if (response.Data.IsUpdated)
|
|
138
|
+
{
|
|
139
|
+
await UpdateLocalToken(response.Data.AccessToken);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return local;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// <summary>
|
|
146
|
+
/// 更新本地 AccessToken,因为 AccessToken 中包含 SDK 的缓存字段,所以只做部分更新
|
|
147
|
+
/// </summary>
|
|
148
|
+
/// <param name="token"></param>
|
|
149
|
+
/// <returns></returns>
|
|
150
|
+
static async Task<XDGAccessToken> UpdateLocalToken(XDGAccessToken token)
|
|
151
|
+
{
|
|
152
|
+
if (local == null)
|
|
153
|
+
{
|
|
154
|
+
local = new XDGAccessToken();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
local.Kid = token.Kid;
|
|
158
|
+
local.MacKey = token.MacKey;
|
|
159
|
+
local.TokenType = token.TokenType;
|
|
160
|
+
local.ExpireIn = token.ExpireIn;
|
|
161
|
+
|
|
162
|
+
await persistence.Save(local, SystemInfo.deviceUniqueIdentifier);
|
|
163
|
+
|
|
164
|
+
return local;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
#endif
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#if UNITY_EDITOR || UNITY_STANDALONE
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.UI;
|
|
6
|
+
using XD.SDK.Common;
|
|
7
|
+
using XD.SDK.Common.Internal.Standalone;
|
|
8
|
+
|
|
9
|
+
namespace XD.SDK.Account.Standalone
|
|
10
|
+
{
|
|
11
|
+
public class AccountCell : MonoBehaviour
|
|
12
|
+
{
|
|
13
|
+
public class AccountCellModel
|
|
14
|
+
{
|
|
15
|
+
public string LoginName { get; set; }
|
|
16
|
+
public LoginType LoginType { get; set; }
|
|
17
|
+
public BindType BindType { get; set; }
|
|
18
|
+
public Dictionary<string, object> Extras { get; set; }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private Image iconImage;
|
|
22
|
+
private Text nameText;
|
|
23
|
+
private Text bindFlagText;
|
|
24
|
+
private Button bindBt;
|
|
25
|
+
|
|
26
|
+
public int cellIndex = 0;
|
|
27
|
+
|
|
28
|
+
internal AccountCellModel model;
|
|
29
|
+
|
|
30
|
+
internal Action<int> OnBind;
|
|
31
|
+
|
|
32
|
+
public void SetModel(AccountCellModel model)
|
|
33
|
+
{
|
|
34
|
+
this.model = model;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public void RefreshState(AccountCellModel model)
|
|
38
|
+
{
|
|
39
|
+
this.model = model;
|
|
40
|
+
Start();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private void Awake()
|
|
44
|
+
{
|
|
45
|
+
iconImage = transform.Find("IconImage").GetComponent<Image>();
|
|
46
|
+
nameText = transform.Find("AccountContainer/NameText").GetComponent<Text>();
|
|
47
|
+
bindFlagText = transform.Find("AccountContainer/BindFlagText").GetComponent<Text>();
|
|
48
|
+
bindFlagText.gameObject.SetActive(false);
|
|
49
|
+
bindBt = transform.Find("BindButton").GetComponent<Button>();
|
|
50
|
+
bindBt.onClick.AddListener(BindButtonTap);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void Start()
|
|
54
|
+
{
|
|
55
|
+
LocalizableString localizableString = XDLocalization.GetCurrentLocalizableString();
|
|
56
|
+
bindFlagText.text = localizableString.Bound;
|
|
57
|
+
if (model != null)
|
|
58
|
+
{
|
|
59
|
+
string displayName = LoginTypeModel.GetReadableName(model.LoginType);
|
|
60
|
+
if (model.LoginType == LoginType.Phone || model.LoginType == LoginType.Email)
|
|
61
|
+
{
|
|
62
|
+
if (model.Extras != null && model.Extras.TryGetValue("openId", out object openId))
|
|
63
|
+
{
|
|
64
|
+
displayName += $"({openId as string})";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
nameText.text = displayName;
|
|
69
|
+
string iconAssets;
|
|
70
|
+
switch (model.LoginType)
|
|
71
|
+
{
|
|
72
|
+
case LoginType.TapTap:
|
|
73
|
+
iconAssets = "Images/type_icon_tap";
|
|
74
|
+
break;
|
|
75
|
+
case LoginType.Google:
|
|
76
|
+
iconAssets = "Images/type_icon_google";
|
|
77
|
+
break;
|
|
78
|
+
case LoginType.Apple:
|
|
79
|
+
iconAssets = "Images/type_icon_apple";
|
|
80
|
+
break;
|
|
81
|
+
case LoginType.Steam:
|
|
82
|
+
iconAssets = "Images/type_icon_steam";
|
|
83
|
+
break;
|
|
84
|
+
case LoginType.Phone:
|
|
85
|
+
iconAssets = "Images/type_icon_phone";
|
|
86
|
+
break;
|
|
87
|
+
case LoginType.Facebook:
|
|
88
|
+
iconAssets = "Images/type_icon_fb";
|
|
89
|
+
break;
|
|
90
|
+
case LoginType.Email:
|
|
91
|
+
iconAssets = "Images/type_icon_email";
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
iconAssets = "Images/type_icon_tap";
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
iconImage.sprite = Resources.Load(iconAssets, typeof(Sprite)) as Sprite;
|
|
99
|
+
|
|
100
|
+
if (model.BindType == BindType.Bind)
|
|
101
|
+
{
|
|
102
|
+
bindBt.transform.Find("Text").GetComponent<Text>().text = localizableString.Unbind;
|
|
103
|
+
bindBt.transform.Find("Text").GetComponent<Text>().color = new Color(0.1333f, 0.1333f, 0.1333f);
|
|
104
|
+
bindFlagText.gameObject.SetActive(true);
|
|
105
|
+
BindEntryConfig bindEntry = GetBindEntryConfig(model.LoginName);
|
|
106
|
+
bindBt.gameObject.SetActive(bindEntry?.CanUnbind == 1);
|
|
107
|
+
}
|
|
108
|
+
else if (model.BindType == BindType.UnBind)
|
|
109
|
+
{
|
|
110
|
+
bindBt.transform.Find("Text").GetComponent<Text>().text = localizableString.Bind;
|
|
111
|
+
bindBt.transform.Find("Text").GetComponent<Text>().color = new Color(0.0823f, 0.7725f, 0.8078f);
|
|
112
|
+
bindFlagText.gameObject.SetActive(false);
|
|
113
|
+
BindEntryConfig bindEntry = GetBindEntryConfig(model.LoginName);
|
|
114
|
+
bindBt.gameObject.SetActive(bindEntry?.CanBind == 1);
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
{
|
|
118
|
+
bindFlagText.gameObject.SetActive(false);
|
|
119
|
+
bindBt.gameObject.SetActive(false);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public void BindButtonTap()
|
|
125
|
+
{
|
|
126
|
+
OnBind?.Invoke(cellIndex);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private BindEntryConfig GetBindEntryConfig(string entryName)
|
|
130
|
+
{
|
|
131
|
+
foreach (BindEntryConfig bindEntry in ConfigModule.BindEntryConfigs)
|
|
132
|
+
{
|
|
133
|
+
if (bindEntry.EntryName.Equals(entryName, StringComparison.InvariantCultureIgnoreCase))
|
|
134
|
+
{
|
|
135
|
+
return bindEntry;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
#endif
|