com.xd.sdk.account 6.29.1 → 7.0.1

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.
Files changed (205) hide show
  1. package/Plugins/Android/libs/XDGAccount_7.0.1.aar +0 -0
  2. package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGAccountBridge.java.meta → Plugins/Android/libs/XDGAccount_7.0.1.aar.meta} +2 -2
  3. package/Plugins/Android/libs/XDGBridgeAccount_v7_7.0.1.aar +0 -0
  4. package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnity.java.meta → Plugins/Android/libs/XDGBridgeAccount_v7_7.0.1.aar.meta} +2 -2
  5. package/Plugins/Android/libs/XDGSupport_7.0.1.aar +0 -0
  6. package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnityImpl.java.meta → Plugins/Android/libs/XDGSupport_7.0.1.aar.meta} +2 -2
  7. package/Plugins/Android/libs.meta +1 -1
  8. package/Plugins/Android.meta +1 -1
  9. package/Plugins/iOS/XDAccountSDK.framework/Headers/TDSGlobalThirdPartyLoginHelper.h +2 -8
  10. package/Plugins/iOS/XDAccountSDK.framework/Headers/TDSGlobalThirdPartyLoginHelper.h.meta +1 -1
  11. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDAccountSDK-Swift.h +329 -0
  12. package/Plugins/iOS/XDAccountSDK.framework/Headers/{TDSGlobalThirdPartyLoginManager.h.meta → XDAccountSDK-Swift.h.meta} +1 -1
  13. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDAccountSDK.h +1 -2
  14. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDAccountSDK.h.meta +1 -1
  15. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccount.h +29 -43
  16. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccount.h.meta +1 -1
  17. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountDefines.h +43 -0
  18. package/Plugins/iOS/XDAccountSDK.framework/Headers/{XDGPhoneAuthManager.h.meta → XDGAccountDefines.h.meta} +1 -1
  19. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h +3 -3
  20. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h.meta +1 -1
  21. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLogger+Account.h +3 -0
  22. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLogger+Account.h.meta +1 -1
  23. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLoginEntriesConfig.h.meta +1 -1
  24. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGLoginService.h.meta +1 -1
  25. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGTapLoginPermissionDialog.h.meta +1 -1
  26. package/Plugins/iOS/XDAccountSDK.framework/Headers.meta +1 -1
  27. package/Plugins/iOS/XDAccountSDK.framework/Info.plist +0 -0
  28. package/Plugins/iOS/XDAccountSDK.framework/Info.plist.meta +1 -1
  29. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  30. package/Plugins/iOS/XDAccountSDK.framework/{Headers/XDGRoleInfo.h.meta → Modules/XDAccountSDK.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo.meta} +1 -1
  31. package/{Mobile/Http.meta → Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/Project.meta} +1 -1
  32. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.abi.json +9 -0
  33. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.abi.json.meta +7 -0
  34. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  35. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftdoc.meta +7 -0
  36. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftmodule +0 -0
  37. package/Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule/arm64-apple-ios.swiftmodule.meta +7 -0
  38. package/{Mobile/Editor.meta → Plugins/iOS/XDAccountSDK.framework/Modules/XDAccountSDK.swiftmodule.meta} +1 -1
  39. package/Plugins/iOS/XDAccountSDK.framework/Modules/module.modulemap.meta +1 -1
  40. package/Plugins/iOS/XDAccountSDK.framework/Modules.meta +1 -1
  41. package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK +0 -0
  42. package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK.meta +1 -1
  43. package/Plugins/iOS/XDAccountSDK.framework.meta +4 -4
  44. package/Plugins/iOS.meta +1 -1
  45. package/Plugins.meta +1 -1
  46. package/Runtime/Internal/IXDGAccount.Extended.cs +11 -0
  47. package/{Mobile/Http/XDGAccountHttpConfigMobile.cs.meta → Runtime/Internal/IXDGAccount.Extended.cs.meta} +1 -1
  48. package/Runtime/Internal/Mobile/AccountFeaturesImpl.cs +348 -0
  49. package/{Mobile/User/UserManagerMobile.cs.meta → Runtime/Internal/Mobile/AccountFeaturesImpl.cs.meta} +1 -1
  50. package/Runtime/Internal/Mobile/Http/LoginSyncResponse.cs +14 -0
  51. package/Runtime/Internal/Mobile/Http/LoginSyncResponse.cs.meta +3 -0
  52. package/Runtime/Internal/Mobile/Http/MacAuthenticationInterceptor.cs +37 -0
  53. package/Runtime/Internal/Mobile/Http/MacAuthenticationInterceptor.cs.meta +3 -0
  54. package/Runtime/Internal/Mobile/Http.meta +3 -0
  55. package/{Mobile.meta → Runtime/Internal/Mobile.meta} +1 -1
  56. package/Runtime/Internal/Standalone/AccessToken/AccessTokenModule.cs +168 -0
  57. package/{Mobile/Editor/XDAccountMobileProcessBuild.cs.meta → Runtime/Internal/Standalone/AccessToken/AccessTokenModule.cs.meta} +1 -1
  58. package/Runtime/Internal/Standalone/AccessToken.meta +8 -0
  59. package/Runtime/Internal/Standalone/AccountCell.cs +143 -0
  60. package/{Mobile/XDGAccountMobile.cs.meta → Runtime/Internal/Standalone/AccountCell.cs.meta} +1 -1
  61. package/Runtime/Internal/Standalone/AccountFeaturesImpl.cs +461 -0
  62. package/Runtime/Internal/Standalone/AccountFeaturesImpl.cs.meta +11 -0
  63. package/Runtime/Internal/Standalone/Auth/AppleAuth.cs +27 -0
  64. package/Runtime/Internal/Standalone/Auth/AppleAuth.cs.meta +11 -0
  65. package/Runtime/Internal/Standalone/Auth/FacebookAuth.cs +27 -0
  66. package/Runtime/Internal/Standalone/Auth/FacebookAuth.cs.meta +11 -0
  67. package/Runtime/Internal/Standalone/Auth/GoogleAuth.cs +27 -0
  68. package/Runtime/Internal/Standalone/Auth/GoogleAuth.cs.meta +11 -0
  69. package/Runtime/Internal/Standalone/Auth/GuestAuth.cs +22 -0
  70. package/Runtime/Internal/Standalone/Auth/GuestAuth.cs.meta +11 -0
  71. package/Runtime/Internal/Standalone/Auth/PhoneAuth.cs +43 -0
  72. package/Runtime/Internal/Standalone/Auth/PhoneAuth.cs.meta +11 -0
  73. package/Runtime/Internal/Standalone/Auth/SteamAuth.cs +90 -0
  74. package/Runtime/Internal/Standalone/Auth/SteamAuth.cs.meta +11 -0
  75. package/Runtime/Internal/Standalone/Auth/TapAuth.cs +72 -0
  76. package/Runtime/Internal/Standalone/Auth/TapAuth.cs.meta +11 -0
  77. package/Runtime/Internal/Standalone/Auth/WebAuth.cs +144 -0
  78. package/Runtime/Internal/Standalone/Auth/WebAuth.cs.meta +11 -0
  79. package/Runtime/Internal/Standalone/Auth.meta +8 -0
  80. package/Runtime/Internal/Standalone/Compliance/XDComplianceCode.cs +15 -0
  81. package/Runtime/Internal/Standalone/Compliance/XDComplianceCode.cs.meta +11 -0
  82. package/Runtime/Internal/Standalone/Compliance.meta +8 -0
  83. package/Runtime/Internal/Standalone/LoginModule/Email/EmailModule.cs +374 -0
  84. package/Runtime/Internal/Standalone/LoginModule/Email/EmailModule.cs.meta +11 -0
  85. package/Runtime/Internal/Standalone/LoginModule/Email.meta +8 -0
  86. package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModule.cs +245 -0
  87. package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModule.cs.meta +11 -0
  88. package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModuleIO.cs +392 -0
  89. package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModuleIO.cs.meta +11 -0
  90. package/Runtime/Internal/Standalone/LoginModule/Phone.meta +8 -0
  91. package/Runtime/Internal/Standalone/LoginModule.meta +8 -0
  92. package/Runtime/Internal/Standalone/SupportModule/SupportModule.cs +228 -0
  93. package/Runtime/Internal/Standalone/SupportModule/SupportModule.cs.meta +3 -0
  94. package/Runtime/Internal/Standalone/SupportModule/SupportResponse.cs +27 -0
  95. package/Runtime/Internal/Standalone/SupportModule/SupportResponse.cs.meta +3 -0
  96. package/Runtime/Internal/Standalone/SupportModule.meta +3 -0
  97. package/Runtime/Internal/Standalone/Track/AliyunTrack.Login.cs +479 -0
  98. package/Runtime/Internal/Standalone/Track/AliyunTrack.Login.cs.meta +11 -0
  99. package/Runtime/Internal/Standalone/Track.meta +8 -0
  100. package/Runtime/Internal/Standalone/UI/CodeUnbindAlert.cs +156 -0
  101. package/Runtime/Internal/Standalone/UI/CodeUnbindAlert.cs.meta +11 -0
  102. package/Runtime/Internal/Standalone/UI/Email/EmailAlert.cs +295 -0
  103. package/Runtime/Internal/Standalone/UI/Email/EmailAlert.cs.meta +11 -0
  104. package/Runtime/Internal/Standalone/UI/Email.meta +8 -0
  105. package/Runtime/Internal/Standalone/UI/PhoneIO/AreaCodeCell.cs +46 -0
  106. package/Runtime/Internal/Standalone/UI/PhoneIO/AreaCodeCell.cs.meta +11 -0
  107. package/Runtime/Internal/Standalone/UI/PhoneIO/PhoneAlertIO.cs +522 -0
  108. package/Runtime/Internal/Standalone/UI/PhoneIO/PhoneAlertIO.cs.meta +11 -0
  109. package/Runtime/Internal/Standalone/UI/PhoneIO.meta +8 -0
  110. package/Runtime/Internal/Standalone/UI/PhoneVerification/PhoneNumberInputAlert.cs +84 -0
  111. package/Runtime/Internal/Standalone/UI/PhoneVerification/PhoneNumberInputAlert.cs.meta +11 -0
  112. package/Runtime/Internal/Standalone/UI/PhoneVerification/RiskControlAlert.cs +190 -0
  113. package/Runtime/Internal/Standalone/UI/PhoneVerification/RiskControlAlert.cs.meta +11 -0
  114. package/Runtime/Internal/Standalone/UI/PhoneVerification/VerifyCodeInputAlert.cs +164 -0
  115. package/Runtime/Internal/Standalone/UI/PhoneVerification/VerifyCodeInputAlert.cs.meta +11 -0
  116. package/Runtime/Internal/Standalone/UI/PhoneVerification.meta +8 -0
  117. package/Runtime/Internal/Standalone/UI.meta +8 -0
  118. package/Runtime/Internal/Standalone/UserCenterAlert.cs +405 -0
  119. package/Runtime/Internal/Standalone/UserCenterAlert.cs.meta +11 -0
  120. package/Runtime/Internal/Standalone/UserModule.cs +604 -0
  121. package/Runtime/Internal/Standalone/UserModule.cs.meta +11 -0
  122. package/Runtime/Internal/Standalone/WebFunction/AccessTokenWebFunction.cs +47 -0
  123. package/Runtime/Internal/Standalone/WebFunction/AccessTokenWebFunction.cs.meta +3 -0
  124. package/Runtime/Internal/Standalone/WebFunction.meta +3 -0
  125. package/{Mobile/Plugins.meta → Runtime/Internal/Standalone.meta} +1 -1
  126. package/Runtime/Internal/XDGAccountEventHandler.cs +23 -0
  127. package/Runtime/Internal/XDGAccountEventHandler.cs.meta +3 -0
  128. package/Runtime/Internal/XDGAccountInternal.cs +86 -0
  129. package/Runtime/Internal/XDGAccountInternal.cs.meta +11 -0
  130. package/Runtime/Internal.meta +1 -1
  131. package/Runtime/Public/XDGAccount.Deprecated.cs +37 -0
  132. package/Runtime/Public/XDGAccount.Deprecated.cs.meta +11 -0
  133. package/Runtime/Public/XDGAccount.cs +107 -0
  134. package/Runtime/{XDGAccount.cs.meta → Public/XDGAccount.cs.meta} +1 -1
  135. package/Runtime/Public.meta +8 -0
  136. package/Runtime/XD.SDK.Account.asmdef +7 -2
  137. package/Runtime/XD.SDK.Account.asmdef.meta +1 -1
  138. package/Runtime.meta +1 -1
  139. package/package.json +5 -5
  140. package/package.json.meta +2 -2
  141. package/Mobile/Editor/XD.SDK.Account.Mobile.Editor.asmdef +0 -20
  142. package/Mobile/Editor/XD.SDK.Account.Mobile.Editor.asmdef.meta +0 -7
  143. package/Mobile/Editor/XDAccountMobileProcessBuild.cs +0 -20
  144. package/Mobile/Http/XDGAccountHttpConfigMobile.cs +0 -36
  145. package/Mobile/Plugins/Android/com/xd/account/bridge/XDGAccountBridge.java +0 -36
  146. package/Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnity.java +0 -16
  147. package/Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnityImpl.java +0 -20
  148. package/Mobile/Plugins/Android/com/xd/account/bridge.meta +0 -8
  149. package/Mobile/Plugins/Android/com/xd/account.meta +0 -8
  150. package/Mobile/Plugins/Android/com/xd.meta +0 -8
  151. package/Mobile/Plugins/Android/com.meta +0 -8
  152. package/Mobile/Plugins/Android.meta +0 -8
  153. package/Mobile/Plugins/iOS/XDAccountBridge.m +0 -29
  154. package/Mobile/Plugins/iOS/XDAccountBridge.m.meta +0 -37
  155. package/Mobile/Plugins/iOS/XDGLoginServiceUnity.h +0 -17
  156. package/Mobile/Plugins/iOS/XDGLoginServiceUnity.h.meta +0 -27
  157. package/Mobile/Plugins/iOS/XDGLoginServiceUnity.m +0 -23
  158. package/Mobile/Plugins/iOS/XDGLoginServiceUnity.m.meta +0 -37
  159. package/Mobile/Plugins/iOS.meta +0 -8
  160. package/Mobile/User/UserManagerMobile.cs +0 -45
  161. package/Mobile/User.meta +0 -8
  162. package/Mobile/XD.SDK.Account.Mobile.asmdef +0 -23
  163. package/Mobile/XD.SDK.Account.Mobile.asmdef.meta +0 -7
  164. package/Mobile/XDGAccountMobile.cs +0 -138
  165. package/Mobile/XDGAccountMobileImpl.cs +0 -444
  166. package/Mobile/XDGAccountMobileImpl.cs.meta +0 -11
  167. package/Mobile/XDGTokenManager.cs +0 -116
  168. package/Mobile/XDGTokenManager.cs.meta +0 -11
  169. package/Mobile/XDGUserWrapper.cs +0 -167
  170. package/Mobile/XDGUserWrapper.cs.meta +0 -11
  171. package/Plugins/Android/libs/XDGAccount_6.29.1.aar +0 -0
  172. package/Plugins/Android/libs/XDGAccount_6.29.1.aar.meta +0 -32
  173. package/Plugins/iOS/XDAccountSDK.framework/Headers/TDSGlobalThirdPartyLoginManager.h +0 -47
  174. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGPhoneAuthManager.h +0 -33
  175. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGRoleInfo.h +0 -22
  176. package/README.md +0 -0
  177. package/README.md.meta +0 -7
  178. package/Runtime/Editor/XD.SDK.Account.Editor.asmdef +0 -19
  179. package/Runtime/Editor/XD.SDK.Account.Editor.asmdef.meta +0 -7
  180. package/Runtime/Editor/XDAccountProcessBuild.cs +0 -18
  181. package/Runtime/Editor/XDAccountProcessBuild.cs.meta +0 -11
  182. package/Runtime/Editor.meta +0 -8
  183. package/Runtime/IXDGAccount.cs +0 -44
  184. package/Runtime/IXDGAccount.cs.meta +0 -11
  185. package/Runtime/Internal/Http/IXDAccountHttpConfig.cs +0 -9
  186. package/Runtime/Internal/Http/IXDAccountHttpConfig.cs.meta +0 -11
  187. package/Runtime/Internal/Http/XDAccountHttpConfig.cs +0 -32
  188. package/Runtime/Internal/Http/XDAccountHttpConfig.cs.meta +0 -11
  189. package/Runtime/Internal/Http.meta +0 -8
  190. package/Runtime/Internal/User/IUserManagerPlatformWrapper.cs +0 -7
  191. package/Runtime/Internal/User/IUserManagerPlatformWrapper.cs.meta +0 -11
  192. package/Runtime/Internal/User.meta +0 -8
  193. package/Runtime/UserManager.cs +0 -35
  194. package/Runtime/UserManager.cs.meta +0 -11
  195. package/Runtime/XDGAccessToken.cs +0 -18
  196. package/Runtime/XDGAccessToken.cs.meta +0 -11
  197. package/Runtime/XDGAccount.cs +0 -130
  198. package/Runtime/XDGLoginType.cs +0 -17
  199. package/Runtime/XDGLoginType.cs.meta +0 -11
  200. package/Runtime/XDGRoleInfo.cs +0 -24
  201. package/Runtime/XDGRoleInfo.cs.meta +0 -11
  202. package/Runtime/XDGUser.cs +0 -30
  203. package/Runtime/XDGUser.cs.meta +0 -11
  204. package/Runtime/XDGUserStatusCode.cs +0 -16
  205. package/Runtime/XDGUserStatusCode.cs.meta +0 -11
@@ -0,0 +1,604 @@
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 System.Linq;
7
+ using UnityEngine;
8
+ using XD.SDK.Common;
9
+ using XD.SDK.Common.Internal;
10
+ using XD.SDK.Common.Internal.Events;
11
+ using XD.SDK.Common.Internal.Standalone;
12
+
13
+ namespace XD.SDK.Account.Internal.Standalone
14
+ {
15
+ public class UserModule
16
+ {
17
+ public class CodeScope
18
+ {
19
+ // Code Scope 个人信息页
20
+ public static readonly string USER_INFO = "userinfo";
21
+ }
22
+
23
+ // 获取用户信息
24
+ private static readonly string XDG_USER_PROFILE = "api/account/v2/info";
25
+
26
+ // 与leanCloud同步
27
+ private static readonly string XDG_LOGIN_SYN = "api/login/v1/syn";
28
+
29
+ // 获取用户绑定信息
30
+ private static readonly string XDG_BIND_LIST = "api/account/v1/bind/list";
31
+
32
+ // 绑定接口
33
+ public static readonly string XDG_BIND_INTERFACE = "api/account/v1/bind";
34
+
35
+ // 解绑接口
36
+ public static readonly string XDG_UNBIND_INTERFACE = "api/account/v1/unbind";
37
+
38
+ // 取消注销申请
39
+ public static readonly string XDG_CANCEL_DELETE = "api/account/v1/cancel-delete";
40
+
41
+ // 获取授权Code
42
+ public static readonly string XDG_AUTH_CODE = "/api/account/v1/apply/code";
43
+
44
+ // 个人信息页
45
+ public static readonly string XDG_PERSONAL_INFO = "/personal-info";
46
+
47
+ private static readonly Persistence persistence = new Persistence(Path.Combine(Application.persistentDataPath,
48
+ XDGConstants.XD_PERSISTENCE_NAME,
49
+ "user_v2"));
50
+
51
+ public static XDGUser current = null;
52
+
53
+ static UserModule()
54
+ {
55
+ // 迁移旧数据
56
+ string v1Path = Path.Combine(Application.persistentDataPath,
57
+ XDGConstants.XD_PERSISTENCE_NAME,
58
+ "user");
59
+ if (File.Exists(v1Path))
60
+ {
61
+ // 迁移
62
+ try
63
+ {
64
+ string v2Path = Path.Combine(Application.persistentDataPath,
65
+ XDGConstants.XD_PERSISTENCE_NAME,
66
+ "user_v2");
67
+ string encryptedData = EncryptionUtils.Encrypt(File.ReadAllText(v1Path), SystemInfo.deviceUniqueIdentifier);
68
+ File.WriteAllText(v2Path, encryptedData);
69
+
70
+ File.Delete(v1Path);
71
+ }
72
+ catch (Exception e)
73
+ {
74
+ XDGLogger.Warn(e.Message);
75
+ }
76
+ }
77
+ }
78
+
79
+ public static XDGUser GetCurrentUser()
80
+ {
81
+ return current;
82
+ }
83
+
84
+ public static async Task<XDGUser> GetLocalUser()
85
+ {
86
+ if (current == null)
87
+ {
88
+ current = await persistence.Load<XDGUser>(SystemInfo.deviceUniqueIdentifier);
89
+ }
90
+
91
+ return current;
92
+ }
93
+
94
+ public static void ClearUserData()
95
+ {
96
+ persistence.Delete();
97
+ current = null;
98
+ }
99
+
100
+ public static async Task<List<Bind>> GetBindList()
101
+ {
102
+ BindResponse response = await XDHttpClient.Client.GetAsync<BindResponse>(XDG_BIND_LIST);
103
+ return response.Binds;
104
+ }
105
+
106
+ public static async Task Bind(LoginType loginType)
107
+ {
108
+ if (loginType == LoginType.Phone)
109
+ {
110
+ AliyunTrack.ResetPhoneLoginData();
111
+ if (XDGCommonInternal.IsCn())
112
+ {
113
+ await PhoneModule.Bind();
114
+ }
115
+ else
116
+ {
117
+ await PhoneModuleIO.LoginOrBind(false);
118
+ }
119
+
120
+ return;
121
+ }
122
+ else if (loginType == LoginType.Email)
123
+ {
124
+ if (XDGCommonInternal.IsCn())
125
+ {
126
+ XDGLogger.Warn("暂不支持的登录方式");
127
+ throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
128
+ }
129
+ else
130
+ {
131
+ await EmailModule.LoginOrBind(false);
132
+ }
133
+
134
+ return;
135
+ }
136
+
137
+ Dictionary<string, object> authData = await GetLoginAuthData(loginType);
138
+ await XDHttpClient.Client.PostAsync<BaseResponse>(XDG_BIND_INTERFACE, data: authData);
139
+ }
140
+
141
+ public static Task Unbind(LoginType loginType, Dictionary<string, object> extras = null)
142
+ {
143
+ if (loginType == LoginType.Phone)
144
+ {
145
+ AliyunTrack.ResetPhoneLoginData();
146
+ // 手机号解绑需要验证码
147
+ if (XDGCommonInternal.IsCn())
148
+ {
149
+ return PhoneModule.Unbind(extras);
150
+ }
151
+ else
152
+ {
153
+ return PhoneModuleIO.Unbind(extras);
154
+ }
155
+ }
156
+ else if (loginType == LoginType.Email)
157
+ {
158
+ if (XDGCommonInternal.IsCn())
159
+ {
160
+ XDGLogger.Warn("暂不支持的登录方式");
161
+ throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
162
+ }
163
+ else
164
+ {
165
+ return EmailModule.Unbind(extras);
166
+ }
167
+ }
168
+
169
+ Dictionary<string, object> data = new Dictionary<string, object>()
170
+ {
171
+ { "type", (int)loginType }
172
+ };
173
+ return XDHttpClient.Client.PostAsync<BaseResponse>(XDG_UNBIND_INTERFACE, data: data);
174
+ }
175
+
176
+ public static async Task<XDGUser> Login(LoginType loginType)
177
+ {
178
+ if (XDGCommonInternal.IsCn() && loginType == LoginType.Email)
179
+ {
180
+ XDGLogger.Warn("暂不支持的登录方式");
181
+ throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
182
+ }
183
+
184
+ if (loginType == LoginType.Console)
185
+ {
186
+ return await LoginByConsole();
187
+ }
188
+
189
+ var localUser = await GetLocalUser();
190
+
191
+ if (loginType == LoginType.Default)
192
+ {
193
+ if (localUser == null)
194
+ {
195
+ XDGLogger.Warn("缺少本地登录信息");
196
+ if (ConfigModule.UsingTapPC && !ConfigModule.DisableAutoLogin2Tap)
197
+ {
198
+ return await Login(LoginType.TapTap);
199
+ }
200
+
201
+ throw new XDGError(ResponseCode.Common.Failed, XDLocalization.GetCurrentLocalizableString().LoginFailed);
202
+ }
203
+
204
+ if (localUser.GetLoginType() == LoginType.TapTap)
205
+ {
206
+ try
207
+ {
208
+ var token = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKGetAccessToken);
209
+
210
+ if (token == null || !token.ContainsKey("token"))
211
+ {
212
+ XDGLogger.Warn("Third token expired.");
213
+ throw new XDGError(ResponseCode.Account.TokenExpired, "Third token expired.");
214
+ }
215
+ }
216
+ catch (Exception e)
217
+ {
218
+ XDGLogger.Warn(e.Message);
219
+ throw new XDGError(ResponseCode.Common.Failed, e.Message);
220
+ }
221
+ }
222
+
223
+ try
224
+ {
225
+ localUser = await FetchUserInfo();
226
+ }
227
+ catch (XDHttpException e)
228
+ {
229
+ if (e.HttpStatusCode == 401 || e.Code == 40311 || e.Code == 40312)
230
+ {
231
+ throw e;
232
+ }
233
+ }
234
+ catch (Exception e)
235
+ {
236
+ XDGLogger.Warn(e.Message);
237
+ }
238
+
239
+ _ = AccessTokenModule.Refresh();
240
+
241
+ return localUser;
242
+ }
243
+
244
+ try
245
+ {
246
+ AliyunTrack.LoginEnableAuthorizeTrack();
247
+ // 单独处理手机号登录
248
+ if (loginType == LoginType.Phone)
249
+ {
250
+ AliyunTrack.ResetPhoneLoginData();
251
+ AliyunTrack.LoginEnableSDKLoginTrack();
252
+ if (XDGCommonInternal.IsCn())
253
+ {
254
+ await PhoneModule.Login();
255
+ }
256
+ else
257
+ {
258
+ await PhoneModuleIO.LoginOrBind(true);
259
+ }
260
+
261
+ UIManager.ShowLoading();
262
+ }
263
+ else if (loginType == LoginType.Email)
264
+ {
265
+ AliyunTrack.ResetEmailLoginData();
266
+ AliyunTrack.LoginEnableSDKLoginTrack();
267
+ await EmailModule.LoginOrBind(true);
268
+ UIManager.ShowLoading();
269
+ }
270
+ else
271
+ {
272
+ Dictionary<string, object> loginParams = await GetLoginAuthData(loginType);
273
+ UIManager.ShowLoading();
274
+ Dictionary<string, object> cacheData = GetCacheData(loginType);
275
+ await AccessTokenModule.Login(loginParams, cacheData);
276
+ }
277
+
278
+ AliyunTrack.LoginEnableSDKLoginTrack();
279
+ var user = await FetchUserInfo();
280
+ try
281
+ {
282
+ await SyncTdsUser(user.UserId);
283
+ }
284
+ catch (Exception e)
285
+ {
286
+ XDGLogger.Warn(e.ToString());
287
+ }
288
+
289
+ XDGLogger.Debug(string.Format($"xd userID: {user.UserId}"));
290
+ return user;
291
+ }
292
+ catch (XDGError e)
293
+ {
294
+ UIManager.DismissLoading();
295
+ if (e.ExtraData != null)
296
+ {
297
+ LocalizableString localizableString = XDLocalization.GetCurrentLocalizableString();
298
+ if (e.Code == 40021 || e.Code == 40901 || e.Code == 40902)
299
+ {
300
+ string title = null;
301
+ string content = null;
302
+ string lt = e.ExtraData["loginType"] as string;
303
+ string email = e.ExtraData["email"] as string;
304
+ if (e.Code == 40021)
305
+ {
306
+ title = localizableString.EmailNotVerified;
307
+ content = string.Format(localizableString.LoginEmailNotVerified, lt, email, lt);
308
+ }
309
+ else if (e.Code == 40901)
310
+ {
311
+ title = localizableString.AccountAlreadyExists;
312
+ string conflicts = string.Join("/",
313
+ (e.ExtraData["conflicts"] as List<object>).Select(item => (item as Dictionary<string, object>)["loginType"]));
314
+ content = string.Format(localizableString.LoginEmailConflict, lt, email, conflicts);
315
+ }
316
+ else if (e.Code == 40902)
317
+ {
318
+ title = localizableString.AccountAlreadyExists;
319
+ string conflicts = string.Join("/",
320
+ (e.ExtraData["conflicts"] as List<object>).Select(item => (item as Dictionary<string, object>)["loginType"]));
321
+ content = string.Format(localizableString.BindEmailConflict, lt, email, lt, conflicts);
322
+ }
323
+
324
+ Dictionary<string, object> conf = new Dictionary<string, object>
325
+ {
326
+ { ConfirmDialog.TITLE_KEY, title },
327
+ { ConfirmDialog.CONTENT_KEY, content },
328
+ { ConfirmDialog.CONFIRM_TEXT_KEY, localizableString.IUnderstand }
329
+ };
330
+
331
+ TaskCompletionSource<XDGUser> tcs = new TaskCompletionSource<XDGUser>();
332
+ UIManager.ShowUI<ConfirmDialog>(conf, (code, data) =>
333
+ {
334
+ UIManager.Dismiss();
335
+ // e.ExtraData = null;
336
+ tcs.TrySetException(e);
337
+ });
338
+ return await tcs.Task;
339
+ }
340
+ else
341
+ {
342
+ throw e;
343
+ }
344
+ }
345
+ else
346
+ {
347
+ throw e;
348
+ }
349
+ }
350
+ finally
351
+ {
352
+ UIManager.DismissLoading();
353
+ }
354
+ }
355
+
356
+ public static async Task<XDGUser> LoginByConsole()
357
+ {
358
+ // 判断当前有接入哪个主机 SDK
359
+ if (SteamUtils.IsSDKSupported)
360
+ {
361
+ try
362
+ {
363
+ AliyunTrack.LoginStart("Default_Steam", "Steam");
364
+ UIManager.ShowLoading();
365
+
366
+ XDGAccessToken localToken = await AccessTokenModule.GetLocalAccessToken();
367
+ string steamId = SteamAuth.GetSteamIdFromSDK();
368
+ XDGUser user;
369
+ XDGLogger.Debug($"LoginByConsole steamId: {steamId} localToken: {localToken} steamId: {steamId}");
370
+ if (!string.IsNullOrEmpty(localToken?.SteamId) && !string.IsNullOrEmpty(steamId) && localToken?.SteamId == steamId)
371
+ {
372
+ try
373
+ {
374
+ user = await FetchUserInfo();
375
+ // 同自动登录一样,触发刷新 token
376
+ _ = AccessTokenModule.Refresh();
377
+ }
378
+ catch (XDGError e)
379
+ {
380
+ if (e.Code == ResponseCode.Account.TokenExpired)
381
+ {
382
+ // Token 过期
383
+ AliyunTrack.LoginEnableSlientAuthorize();
384
+ user = await LoginByConsoleInternal();
385
+ }
386
+ else
387
+ {
388
+ throw e;
389
+ }
390
+ }
391
+ }
392
+ else
393
+ {
394
+ // 当前 steamId 与缓存 steamId 不一致,则使用当前 steam 信息重新授权(相当于忽略本地缓存)
395
+ user = await LoginByConsoleInternal();
396
+ }
397
+
398
+ try
399
+ {
400
+ await SyncTdsUser(user.UserId);
401
+ }
402
+ catch (Exception e)
403
+ {
404
+ XDGLogger.Warn(e.ToString());
405
+ }
406
+
407
+ XDGLogger.Debug(string.Format($"xd userID: {user.UserId}"));
408
+ return user;
409
+ }
410
+ finally
411
+ {
412
+ UIManager.DismissLoading();
413
+ }
414
+ }
415
+
416
+ // 尝试其他主机 SDK
417
+ throw new NotImplementedException("NO supported console sdk.");
418
+ }
419
+
420
+ internal static async Task<XDGUser> LoginByConsoleInternal()
421
+ {
422
+ AliyunTrack.LoginEnableAuthorizeTrack();
423
+ Dictionary<string, object> authData = await SteamAuth.GetAuthDataFromSDK();
424
+ Dictionary<string, object> cacheData = SteamAuth.GetCacheData();
425
+ AliyunTrack.LoginEnableSDKLoginTrack();
426
+ await AccessTokenModule.SignIn(authData, cacheData);
427
+ return await FetchUserInfo();
428
+ }
429
+
430
+ internal static async Task<Dictionary<string, object>> GetLoginAuthData(LoginType loginType)
431
+ {
432
+ switch (loginType)
433
+ {
434
+ case LoginType.Guest:
435
+ return GuestAuth.GetAuthData();
436
+ case LoginType.TapTap:
437
+ return await TapAuth.GetAuthData();
438
+ case LoginType.Apple:
439
+ return await AppleAuth.GetAuthData();
440
+ case LoginType.Google:
441
+ return await GoogleAuth.GetAuthData();
442
+ case LoginType.Steam:
443
+ return await SteamAuth.GetAuthData();
444
+ case LoginType.Facebook:
445
+ return await FacebookAuth.GetAuthData();
446
+ default:
447
+ return new Dictionary<string, object>();
448
+ }
449
+ }
450
+
451
+ internal static Dictionary<string, object> GetCacheData(LoginType loginType)
452
+ {
453
+ switch (loginType)
454
+ {
455
+ case LoginType.Steam:
456
+ return SteamAuth.GetCacheData();
457
+ default:
458
+ return null;
459
+ }
460
+ }
461
+
462
+ private static async Task SyncTdsUser(string userId)
463
+ {
464
+ // 效果等于 BecomeWithSessionToken,为了少一次网络请求
465
+ // SyncTokenResponse tokenResponse = await XDHttpClient.Client.PostAsync<SyncTokenResponse>(XDG_LOGIN_SYN);
466
+ // TDSUser user = TDSUser.CreateWithoutData(TDSUser.CLASS_NAME, userId) as TDSUser;
467
+ // user.SessionToken = tokenResponse.SyncToken.SessionToken;
468
+ // await user.SaveToLocal();
469
+ var bHasTdsUser = ReflectionUtils.FindType("TapTap.Bootstrap.TDSUser", "XD.SDK.TDSWrapper") != null;
470
+ if (bHasTdsUser)
471
+ {
472
+ var token = await XDHttpClient.Client.PostAsync<SyncTokenResponse>(XDG_LOGIN_SYN);
473
+ XDGEventBus.Publish(XDGEvents.TdsSDKSyncUser, token.SyncToken.SessionToken, userId);
474
+ }
475
+ }
476
+
477
+ public static async Task<XDGUser> FetchUserInfo()
478
+ {
479
+ try
480
+ {
481
+ ProfileResponse response = await XDHttpClient.Client.GetAsync<ProfileResponse>(XDG_USER_PROFILE);
482
+
483
+ if (current == null)
484
+ {
485
+ current = response.User;
486
+ }
487
+ else
488
+ {
489
+ current.Update(response.User);
490
+ }
491
+
492
+ await persistence.Save(current, SystemInfo.deviceUniqueIdentifier);
493
+ AliyunTrack.LoginPreSuccess();
494
+ return current;
495
+ }
496
+ catch (XDHttpException xdException)
497
+ {
498
+ if (xdException.Code == 40312 && xdException.ExtraData != null)
499
+ {
500
+ var extra = xdException.ExtraData["extra"] as Dictionary<string, object>;
501
+ var realNameUrl = extra?["url"] as string;
502
+ if (!string.IsNullOrEmpty(realNameUrl))
503
+ {
504
+ var tcs = new TaskCompletionSource<XDGUser>();
505
+ XDGCommon.OpenWebPage(realNameUrl, async (action, data) =>
506
+ {
507
+ if (action == WebActionEnum.CLOSE)
508
+ {
509
+ if (data != null)
510
+ {
511
+ data.TryGetValue("success", out var success);
512
+ if (success is bool)
513
+ {
514
+ if ((bool)success)
515
+ {
516
+ tcs.SetResult(await FetchUserInfo());
517
+ }
518
+
519
+ return;
520
+ }
521
+ }
522
+ }
523
+
524
+ tcs.TrySetException(xdException);
525
+ });
526
+ return await tcs.Task;
527
+ }
528
+ }
529
+
530
+ if (xdException.Code == 40311 && xdException.ExtraData != null)
531
+ {
532
+ var title = xdException.ExtraData["title"] as string;
533
+ var content = xdException.ExtraData["content"] as string;
534
+ var negativeButton = xdException.ExtraData["negativeButton"] as string;
535
+ var positiveButton = xdException.ExtraData["positiveButton"] as string;
536
+
537
+ if (title != null && content != null)
538
+ {
539
+ var config = new Dictionary<string, object>
540
+ {
541
+ { Dialog.TITLE_KEY, title },
542
+ { Dialog.CONTENT_KEY, content },
543
+ { Dialog.PRIMARY_TEXT_KEY, positiveButton },
544
+ { Dialog.SECONDARY_TEXT_KEY, negativeButton }
545
+ };
546
+
547
+ var tcs = new TaskCompletionSource<XDGUser>();
548
+ UIManager.ShowUI<Dialog>("Dialog", config, async (code, data) =>
549
+ {
550
+ if (code == 1 || code == -1)
551
+ {
552
+ UIManager.Dismiss();
553
+ tcs.TrySetException(xdException);
554
+ }
555
+ else
556
+ {
557
+ await CancelDelete();
558
+ UIManager.Dismiss();
559
+ tcs.SetResult(await FetchUserInfo());
560
+ }
561
+ });
562
+ UIManager.DismissLoading();
563
+ return await tcs.Task;
564
+ }
565
+ }
566
+
567
+ var errorMsg = xdException.Message;
568
+ // 所有 40801 错误代表 401 授权失败,需要明示原因为 XD_TOKEN_EXPIRED
569
+ if (xdException.Code == ResponseCode.Account.TokenExpired || xdException.HttpStatusCode == 401)
570
+ errorMsg = "XD_TOKEN_EXPIRED";
571
+ AliyunTrack.LoginPreFail(errorMsg);
572
+ throw xdException;
573
+ }
574
+ catch (Exception e)
575
+ {
576
+ AliyunTrack.LoginPreFail(e.Message);
577
+ throw e;
578
+ }
579
+ }
580
+
581
+ private static async Task CancelDelete()
582
+ {
583
+ UIManager.ShowLoading();
584
+ try
585
+ {
586
+ await XDHttpClient.Client.PostAsync<BaseResponse>(XDG_CANCEL_DELETE);
587
+ UIManager.DismissLoading();
588
+ }
589
+ catch (Exception e)
590
+ {
591
+ UIManager.DismissLoading();
592
+ var errorMsg = XDLocalization.GetCurrentLocalizableString().NetworkErrorSafeRetry;
593
+ if (e is XDGError xdException && !string.IsNullOrEmpty(xdException.ErrorMsg))
594
+ {
595
+ errorMsg = xdException.ErrorMsg;
596
+ }
597
+
598
+ UIManager.ShowToast(errorMsg);
599
+ throw e;
600
+ }
601
+ }
602
+ }
603
+ }
604
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c383e216b16d4fb894ee1f5d4e88400e
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,47 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+
3
+ using System;
4
+ using System.Collections.Generic;
5
+ using XD.SDK.Common;
6
+ using XD.SDK.Common.Internal;
7
+ using XD.SDK.Common.Internal.Standalone;
8
+
9
+ namespace XD.SDK.Account.Internal.Standalone
10
+ {
11
+ public class AccessTokenWebFunction : IWebFunction
12
+ {
13
+ public string GetName()
14
+ {
15
+ return "getAccessToken";
16
+ }
17
+
18
+ public async void Handler(IBridgeWebView webView, string data, Action<object> callbackFunction)
19
+ {
20
+ XDGLogger.Debug($"message from javascript by:{GetName()} with data:{data}");
21
+ var token = await AccessTokenModule.GetLocalAccessToken();
22
+ if (token == null)
23
+ {
24
+ callbackFunction(new WebBridgeResponse.Failed
25
+ {
26
+ Msg = "AccessToken is null!"
27
+ });
28
+ return;
29
+ }
30
+
31
+ var result = new Dictionary<string, object>
32
+ {
33
+ { "expireIn", token.ExpireIn },
34
+ { "macKey", token.MacKey },
35
+ { "macAlgorithm", token.MacAlgorithm },
36
+ { "tokenType", token.TokenType },
37
+ { "kid", token.Kid }
38
+ };
39
+
40
+ callbackFunction(new WebBridgeResponse.Success
41
+ {
42
+ Data = result
43
+ });
44
+ }
45
+ }
46
+ }
47
+ #endif
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 567b5e9620564fe89dc5767d53ec2393
3
+ timeCreated: 1753339498
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: df785d454b4044e8b6234b3d167a6ee3
3
+ timeCreated: 1753339610
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 5a0325abf107a43c988e1612aeddd17b
2
+ guid: 89cb1a6563bc46879d197296e3f88d58
3
3
  folderAsset: yes
4
4
  DefaultImporter:
5
5
  externalObjects: {}