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.
Files changed (205) hide show
  1. package/Plugins/Android/libs/XDGAccount_7.0.0.aar +0 -0
  2. package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGAccountBridge.java.meta → Plugins/Android/libs/XDGAccount_7.0.0.aar.meta} +2 -2
  3. package/Plugins/Android/libs/XDGBridgeAccount_v7_7.0.0.aar +0 -0
  4. package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnity.java.meta → Plugins/Android/libs/XDGBridgeAccount_v7_7.0.0.aar.meta} +2 -2
  5. package/Plugins/Android/libs/XDGSupport_7.0.0.aar +0 -0
  6. package/{Mobile/Plugins/Android/com/xd/account/bridge/XDGLoginServiceUnityImpl.java.meta → Plugins/Android/libs/XDGSupport_7.0.0.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,374 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+ using System;
3
+ using System.Collections.Generic;
4
+ using System.Threading.Tasks;
5
+ using XD.SDK.Common;
6
+ using XD.SDK.Common.Internal;
7
+ using XD.SDK.Common.Internal.Standalone;
8
+
9
+
10
+ namespace XD.SDK.Account.Internal.Standalone
11
+ {
12
+ public static class EmailModule
13
+ {
14
+ private static readonly string XDG_LOGIN_CODE_SEND = "api/login/v1/verification/code/send";
15
+ private static readonly string XDG_UNBIND_CODE_SEND = "api/account/v1/unbind/verification/code/send";
16
+
17
+ public const int RISK_CONTROL = 40024;
18
+ public const int RISK_CONTROL_FAILED = 40025;
19
+ public const int INVALID_EMAIL_FORMAT = 40031;
20
+ public const int INVALID_VERIFY_CODE = 40114;
21
+
22
+ private static EmailAlert loginAlert;
23
+ private static CodeUnbindAlert unbindAlert;
24
+
25
+ public static Task LoginOrBind(bool login)
26
+ {
27
+ TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
28
+ AliyunTrack.LoginAuthorize();
29
+ if (login)
30
+ {
31
+ AliyunTrack.LoginTrackEmailData();
32
+ }
33
+
34
+ loginAlert = UIManager.ShowUI<EmailAlert>("XDEmailAlert", new Dictionary<string, object>() { { "login", login } }, async (code, data) =>
35
+ {
36
+ switch (code)
37
+ {
38
+ case EmailAlert.CLOSE_CODE:
39
+ UIManager.Dismiss();
40
+ AliyunTrack.LoginAuthorizeFail("cancel");
41
+ tcs.TrySetException(XDGErrorExtensions.CancelledError());
42
+ break;
43
+ case EmailAlert.SEND_CODE:
44
+ try
45
+ {
46
+ EmailAlert.Data emailData = data as EmailAlert.Data;
47
+ if (emailData?.email.Length != 0)
48
+ {
49
+ await RequestLoginVerifyCode(emailData?.email);
50
+ }
51
+ else
52
+ {
53
+ loginAlert.UpdateEmailError(XDLocalization.GetCurrentLocalizableString().EmailEmpty);
54
+ }
55
+ }
56
+ catch (Exception)
57
+ {
58
+ UIManager.DismissLoading();
59
+ }
60
+
61
+ break;
62
+ case EmailAlert.LOGIN_OR_BIND:
63
+ try
64
+ {
65
+ EmailAlert.Data emailData = data as EmailAlert.Data;
66
+ if (emailData?.email.Length != 0)
67
+ {
68
+ if (emailData?.code.Length != 0)
69
+ {
70
+ if (login)
71
+ {
72
+ await LoginByEmail(emailData?.email, emailData?.code);
73
+ }
74
+ else
75
+ {
76
+ await BindByEmail(emailData?.email, emailData?.code);
77
+ }
78
+
79
+ UIManager.Dismiss();
80
+ tcs.TrySetResult(null);
81
+ }
82
+ else
83
+ {
84
+ loginAlert.UpdateCodeError(XDLocalization.GetCurrentLocalizableString().CodeEmpty);
85
+ }
86
+ }
87
+ else
88
+ {
89
+ loginAlert.UpdateEmailError(XDLocalization.GetCurrentLocalizableString().EmailEmpty);
90
+ }
91
+ }
92
+ catch (XDGError e)
93
+ {
94
+ if (e.Code == INVALID_VERIFY_CODE)
95
+ {
96
+ loginAlert.UpdateCodeError(e.ErrorMsg);
97
+ }
98
+ else if (e.Code == INVALID_EMAIL_FORMAT)
99
+ {
100
+ loginAlert.UpdateEmailError(e.ErrorMsg);
101
+ }
102
+ else
103
+ {
104
+ UIManager.ShowToast(e.ErrorMsg);
105
+ }
106
+ }
107
+ catch (Exception e)
108
+ {
109
+ tcs.TrySetException(e);
110
+ }
111
+
112
+ break;
113
+ }
114
+ });
115
+ return tcs.Task;
116
+ }
117
+
118
+ public static Task Unbind(Dictionary<string, object> extras)
119
+ {
120
+ TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
121
+ unbindAlert = UIManager.ShowUI<CodeUnbindAlert>("XDCodeUnbindAlert", extras, async (code, data) =>
122
+ {
123
+ switch (code)
124
+ {
125
+ case CodeUnbindAlert.CLOSE_CODE:
126
+ UIManager.Dismiss();
127
+ AliyunTrack.LoginAuthorizeFail("cancel");
128
+ AliyunTrack.LoginFail("cancel");
129
+ tcs.TrySetException(XDGErrorExtensions.CancelledError());
130
+ break;
131
+ case CodeUnbindAlert.SEND_CODE:
132
+ {
133
+ try
134
+ {
135
+ await RequestUnbindVerifyCode();
136
+ }
137
+ catch (Exception)
138
+ {
139
+ UIManager.DismissLoading();
140
+ }
141
+ }
142
+ break;
143
+ case CodeUnbindAlert.UNBIND:
144
+ {
145
+ try
146
+ {
147
+ CodeUnbindAlert.Data unbindData = data as CodeUnbindAlert.Data;
148
+ await UnbindByEmail(unbindData?.code);
149
+ UIManager.Dismiss();
150
+ tcs.TrySetResult(null);
151
+ }
152
+ catch (XDGError e)
153
+ {
154
+ if (e.Code == INVALID_VERIFY_CODE)
155
+ {
156
+ unbindAlert.UpdateCodeError(e.ErrorMsg);
157
+ }
158
+ else
159
+ {
160
+ UIManager.ShowToast(e.ErrorMsg);
161
+ }
162
+ }
163
+ catch (Exception e)
164
+ {
165
+ tcs.TrySetException(e);
166
+ }
167
+ }
168
+ break;
169
+ }
170
+ });
171
+ return tcs.Task;
172
+ }
173
+
174
+ private static async Task<RequestVerifyCodeData> RequestLoginVerifyCode(string email, string riskControlData = null)
175
+ {
176
+ Dictionary<string, object> data = new Dictionary<string, object>
177
+ {
178
+ { "type", "EMAIL" },
179
+ { "email", email },
180
+ };
181
+ Dictionary<string, object> headers = null;
182
+ if (riskControlData != null)
183
+ {
184
+ headers = new Dictionary<string, object>()
185
+ {
186
+ { "Risk-Authenticate-Sig", riskControlData }
187
+ };
188
+ }
189
+
190
+ RequestVerifyCodeData response = null;
191
+ UIManager.ShowLoading(true);
192
+ try
193
+ {
194
+ loginAlert?.SetSendButtonEnable(false);
195
+ response = (await XDHttpClient.Client.PostAsync<RequestVerifyCodeResponse>(XDG_LOGIN_CODE_SEND, headers: headers, data: data))?.Data;
196
+ loginAlert?.SetSendButtonEnable(true);
197
+ if (response != null) loginAlert?.UpdateCanResendSeconds(response.ReSendInterval);
198
+ AliyunTrack.SendEmailCode(true);
199
+ UIManager.ShowToast(XDLocalization.GetCurrentLocalizableString()?.CodeSendSuccess);
200
+ }
201
+ catch (XDGError e)
202
+ {
203
+ AliyunTrack.SendEmailCode(false);
204
+ loginAlert?.SetSendButtonEnable(true);
205
+ if (e.Code == RISK_CONTROL || e.Code == RISK_CONTROL_FAILED)
206
+ {
207
+ TaskCompletionSource<RequestVerifyCodeData> tcs = new TaskCompletionSource<RequestVerifyCodeData>();
208
+
209
+ string scene = e.ExtraData["captcha_scene"] as string;
210
+
211
+ async void Callback(string token, XDGError error)
212
+ {
213
+ if (!string.IsNullOrEmpty(token))
214
+ {
215
+ try
216
+ {
217
+ AliyunTrack.TriggerCaptchaSuccess("login_email");
218
+ RequestVerifyCodeData codeData = await RequestLoginVerifyCode(email, token);
219
+ tcs.TrySetResult(codeData);
220
+ }
221
+ catch (XDGError exception)
222
+ {
223
+ tcs.TrySetException(exception);
224
+ }
225
+ }
226
+ else
227
+ {
228
+ tcs.TrySetException(error as XDGError ?? throw new InvalidOperationException());
229
+ }
230
+ }
231
+
232
+ AliyunTrack.TriggerCaptchaStart("login_email");
233
+ XDGCaptcha.ValidateWithCaptcha(scene, new Dictionary<string, string>(){{"eventSessionId", AliyunTrack.LoginEventSessionId}}, Callback);
234
+ response = await tcs.Task;
235
+ }
236
+ else if (e.Code == INVALID_EMAIL_FORMAT)
237
+ {
238
+ loginAlert?.UpdateEmailError(e.ErrorMsg);
239
+ }
240
+ else
241
+ {
242
+ UIManager.ShowToast(e.ErrorMsg);
243
+ }
244
+ }
245
+ catch (Exception)
246
+ {
247
+ loginAlert?.SetSendButtonEnable(true);
248
+ AliyunTrack.SendEmailCode(false);
249
+ UIManager.DismissLoading();
250
+ throw;
251
+ }
252
+
253
+ UIManager.DismissLoading();
254
+ return response;
255
+ }
256
+
257
+ private static async Task<RequestVerifyCodeData> RequestUnbindVerifyCode(string riskControlData = null)
258
+ {
259
+ Dictionary<string, object> data = new Dictionary<string, object>
260
+ {
261
+ { "type", "EMAIL" }
262
+ };
263
+ Dictionary<string, object> headers = null;
264
+ if (riskControlData != null)
265
+ {
266
+ headers = new Dictionary<string, object>()
267
+ {
268
+ { "Risk-Authenticate-Sig", riskControlData }
269
+ };
270
+ }
271
+
272
+ RequestVerifyCodeData response = null;
273
+ try
274
+ {
275
+ unbindAlert?.SetSendButtonEnable(false);
276
+ response = (await XDHttpClient.Client.PostAsync<RequestVerifyCodeResponse>(XDG_UNBIND_CODE_SEND, headers: headers, data: data))?.Data;
277
+ unbindAlert?.SetSendButtonEnable(true);
278
+ if (response != null) unbindAlert?.UpdateCanResendSeconds(response.ReSendInterval);
279
+ UIManager.ShowToast(XDLocalization.GetCurrentLocalizableString()?.CodeSendSuccess);
280
+ }
281
+ catch (XDGError e)
282
+ {
283
+ unbindAlert?.SetSendButtonEnable(true);
284
+ if (e.Code == RISK_CONTROL || e.Code == RISK_CONTROL_FAILED)
285
+ {
286
+ TaskCompletionSource<RequestVerifyCodeData> tcs = new TaskCompletionSource<RequestVerifyCodeData>();
287
+
288
+ string scene = e.ExtraData["captcha_scene"] as string;
289
+
290
+ async void Callback(string token, XDGError error)
291
+ {
292
+ if (!string.IsNullOrEmpty(token))
293
+ {
294
+ try
295
+ {
296
+ RequestVerifyCodeData codeData = await RequestUnbindVerifyCode(token);
297
+ tcs.TrySetResult(codeData);
298
+ }
299
+ catch (XDGError exception)
300
+ {
301
+ tcs.TrySetException(exception);
302
+ }
303
+ }
304
+ else
305
+ {
306
+ tcs.TrySetException(error as XDGError ?? throw new InvalidOperationException());
307
+ }
308
+ }
309
+
310
+ XDGCaptcha.ValidateWithCaptcha(scene, new Dictionary<string, string>(){{"eventSessionId", AliyunTrack.LoginEventSessionId}}, Callback);
311
+ response = await tcs.Task;
312
+ }
313
+ else
314
+ {
315
+ UIManager.ShowToast(e.ErrorMsg);
316
+ }
317
+ }
318
+ catch (Exception)
319
+ {
320
+ unbindAlert?.SetSendButtonEnable(true);
321
+ UIManager.DismissLoading();
322
+ throw;
323
+ }
324
+
325
+ return response;
326
+ }
327
+
328
+ private static async Task LoginByEmail(string email, string code)
329
+ {
330
+ Dictionary<string, object> authData = new Dictionary<string, object>
331
+ {
332
+ { "type", (int)LoginType.Email },
333
+ { "token", email },
334
+ { "secret", code },
335
+ { "subType", "text" }
336
+ };
337
+ try
338
+ {
339
+ await AccessTokenModule.Login(authData, null);
340
+ AliyunTrack.EmailCodeVerifyResult(true);
341
+ }
342
+ catch (XDGError e)
343
+ {
344
+ AliyunTrack.EmailCodeVerifyResult(false, e.ErrorMsg);
345
+ throw;
346
+ }
347
+ }
348
+
349
+ private static async Task BindByEmail(string email, string code)
350
+ {
351
+ Dictionary<string, object> authData = new Dictionary<string, object>
352
+ {
353
+ { "type", (int)LoginType.Email },
354
+ { "token", email },
355
+ { "secret", code },
356
+ { "subType", "text" }
357
+ };
358
+ await XDHttpClient.Client.PostAsync<BaseResponse>(UserModule.XDG_BIND_INTERFACE, data: authData);
359
+ }
360
+
361
+ private static async Task UnbindByEmail(string code)
362
+ {
363
+ Dictionary<string, object> data = new Dictionary<string, object>()
364
+ {
365
+ { "type", (int)LoginType.Email },
366
+ { "verificationCode", code }
367
+ };
368
+ await XDHttpClient.Client.PostAsync<BaseResponse>(UserModule.XDG_UNBIND_INTERFACE, data: data);
369
+ }
370
+ }
371
+ }
372
+
373
+
374
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: e4225f4b2d4f44589f74e2da5767fae0
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,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 3ee97390704a4f4d88706fe3c6cb51f2
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,245 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+ using System;
3
+ using System.Collections.Generic;
4
+ using System.Threading.Tasks;
5
+ using XD.SDK.Common;
6
+ using XD.SDK.Common.Internal;
7
+ using XD.SDK.Common.Internal.Standalone;
8
+
9
+
10
+ namespace XD.SDK.Account.Internal.Standalone
11
+ {
12
+ public class PhoneModule
13
+ {
14
+ public const int INVALID_PHONE_NUMBER_FORMAT = 40022;
15
+ public const int REQUEST_CODE_FREQUENTLY = 42901;
16
+ public const int LOGIN_REQUEST_FREQUENTLY = 42900;
17
+ public const int RISK_CONTROL = 40024;
18
+ public const int RISK_CONTROL_FAILED = 40025;
19
+ public const int INVALID_VERIFY_CODE = 40114;
20
+ public const int LOGIN_FREQUENTLY = 42900;
21
+ public const int INVALILD_TOKEN = 40113;
22
+
23
+ public static Task Login()
24
+ {
25
+ // 手机登录总流程
26
+ TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
27
+ PhoneNumberInputAlert alert = null;
28
+ AliyunTrack.LoginAuthorize();
29
+ AliyunTrack.LoginTrackPhoneData();
30
+
31
+ alert = UIManager.ShowUI<PhoneNumberInputAlert>("XDPhoneNumberInputAlert", null, async (code, data) =>
32
+ {
33
+ if (code == PhoneNumberInputAlert.CLOSE_CODE)
34
+ {
35
+ // 关闭不结束 Task,同 Web 授权
36
+ UIManager.Dismiss();
37
+ AliyunTrack.LoginAuthorizeFail("cancel");
38
+ AliyunTrack.LoginFail("cancel");
39
+ tcs.TrySetException(XDGErrorExtensions.CancelledError());
40
+ }
41
+ else if (code == PhoneNumberInputAlert.NEXT_CODE)
42
+ {
43
+ // 已经拿到手机号
44
+ PhoneNumberInputAlert.Data input = data as PhoneNumberInputAlert.Data;
45
+ string areaCode = input.AreaCode;
46
+ string phoneNumber = input.PhoneNumber;
47
+ try
48
+ {
49
+ // 验证码阶段
50
+ await VerifyCodeInputAlert.Verify(
51
+ phoneNumber,
52
+ riskControlData => RequestLoginVerifyCode(areaCode, phoneNumber, riskControlData),
53
+ verificationCode => LoginByPhone(areaCode, phoneNumber, verificationCode)
54
+ );
55
+ AliyunTrack.LoginAuthorizeSuccess();
56
+ tcs.TrySetResult(null);
57
+ UIManager.Dismiss();
58
+ }
59
+ catch (XDGError e)
60
+ {
61
+ if (e.Code == INVALID_PHONE_NUMBER_FORMAT)
62
+ {
63
+ alert.CheckPhoneNumberValid(phoneNumber);
64
+ }
65
+ else if (e.Code == REQUEST_CODE_FREQUENTLY)
66
+ {
67
+ // 频繁登录
68
+ UIManager.ShowToast(e.Message);
69
+ }
70
+ else
71
+ {
72
+ // 其他异常
73
+ if (string.IsNullOrEmpty(e.Message))
74
+ {
75
+ // TODO 翻译
76
+ UIManager.ShowToast("发送失败");
77
+ }
78
+ else
79
+ {
80
+ UIManager.ShowToast(e.Message);
81
+ }
82
+ }
83
+ }
84
+ catch (TaskCanceledException tce)
85
+ {
86
+ // 退出不处理
87
+ AliyunTrack.LoginAuthorizeFail(tce.Message);
88
+ UIManager.Dismiss();
89
+ AliyunTrack.LoginFail("cancel");
90
+ }
91
+ catch (Exception e)
92
+ {
93
+ AliyunTrack.LoginAuthorizeFail(e.Message);
94
+ UIManager.ShowToast("发送失败");
95
+ }
96
+ }
97
+ });
98
+ return tcs.Task;
99
+ }
100
+
101
+ public static Task Bind()
102
+ {
103
+ TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
104
+ UIManager.ShowUI<PhoneNumberInputAlert>("XDPhoneNumberInputAlert", null, async (code, data) =>
105
+ {
106
+ if (code == PhoneNumberInputAlert.CLOSE_CODE)
107
+ {
108
+ UIManager.Dismiss();
109
+ tcs.TrySetException(XDGErrorExtensions.CancelledError());
110
+ }
111
+ else if (code == PhoneNumberInputAlert.NEXT_CODE)
112
+ {
113
+ try
114
+ {
115
+ PhoneNumberInputAlert.Data input = data as PhoneNumberInputAlert.Data;
116
+ string areaCode = input.AreaCode;
117
+ string phoneNumber = input.PhoneNumber;
118
+ await VerifyCodeInputAlert.Verify(
119
+ phoneNumber,
120
+ riskControlData => RequestLoginVerifyCode(areaCode, phoneNumber, riskControlData),
121
+ verificationCode => BindByPhone(areaCode, phoneNumber, verificationCode)
122
+ );
123
+ tcs.TrySetResult(null);
124
+ UIManager.Dismiss();
125
+ }
126
+ catch (TaskCanceledException)
127
+ {
128
+ UIManager.Dismiss();
129
+ }
130
+ catch (XDGError e)
131
+ {
132
+ if (e.Code == REQUEST_CODE_FREQUENTLY)
133
+ {
134
+ // 频繁登录
135
+ UIManager.ShowToast(e.Message);
136
+ }
137
+ else
138
+ {
139
+ tcs.TrySetException(e);
140
+ }
141
+ }
142
+ }
143
+ });
144
+ return tcs.Task;
145
+ }
146
+
147
+ public static async Task Unbind(Dictionary<string, object> extras)
148
+ {
149
+ string phoneNumber = extras["openId"] as string;
150
+ await VerifyCodeInputAlert.Verify(phoneNumber,
151
+ riskControlData => RequestUnbindVerifyCode(riskControlData),
152
+ code => UnbindByPhone(code));
153
+ }
154
+
155
+ private static async Task<RequestVerifyCodeData> RequestLoginVerifyCode(string areaCode, string phoneNumber,
156
+ string riskControlData = null)
157
+ {
158
+ string path = "api/login/v1/verification/code/send";
159
+ Dictionary<string, object> data = new Dictionary<string, object>
160
+ {
161
+ { "areaCode", areaCode }, // 当前版本固定国内
162
+ { "phoneNumber", phoneNumber }
163
+ };
164
+ Dictionary<string, object> headers = null;
165
+ if (riskControlData != null)
166
+ {
167
+ headers = new Dictionary<string, object>()
168
+ {
169
+ { "Risk-Authenticate-Sig", riskControlData }
170
+ };
171
+ }
172
+
173
+ RequestVerifyCodeResponse response = null;
174
+ UIManager.ShowLoading(true);
175
+ try
176
+ {
177
+ response = await XDHttpClient.Client.PostAsync<RequestVerifyCodeResponse>(path,
178
+ headers: headers, data: data);
179
+ AliyunTrack.LoginMobileVerifyCodeSendSuccess();
180
+ }
181
+ catch (Exception)
182
+ {
183
+ UIManager.DismissLoading();
184
+ AliyunTrack.LoginMobileVerifyCodeSendFail();
185
+ throw;
186
+ }
187
+
188
+ UIManager.DismissLoading();
189
+ return response?.Data;
190
+ }
191
+
192
+ private static async Task<RequestVerifyCodeData> RequestUnbindVerifyCode(string riskControlData = null)
193
+ {
194
+ string path = "api/account/v1/unbind/verification/code/send";
195
+ Dictionary<string, object> headers = null;
196
+ if (riskControlData != null)
197
+ {
198
+ headers = new Dictionary<string, object>()
199
+ {
200
+ { "Risk-Authenticate-Sig", riskControlData }
201
+ };
202
+ }
203
+
204
+ RequestVerifyCodeResponse response = await XDHttpClient.Client.PostAsync<RequestVerifyCodeResponse>(path,
205
+ headers: headers);
206
+ return response.Data;
207
+ }
208
+
209
+ private static async Task LoginByPhone(string areaCode, string phoneNumber, string code)
210
+ {
211
+ Dictionary<string, object> authData = new Dictionary<string, object>
212
+ {
213
+ { "type", (int)LoginType.Phone },
214
+ { "token", $"{areaCode} {phoneNumber}" },
215
+ { "secret", code },
216
+ { "subType", "text" }
217
+ };
218
+ await AccessTokenModule.Login(authData, null);
219
+ AliyunTrack.LoginMobileVerifyCodePassSuccess();
220
+ }
221
+
222
+ private static async Task BindByPhone(string areaCode, string phoneNumber, string code)
223
+ {
224
+ Dictionary<string, object> authData = new Dictionary<string, object>
225
+ {
226
+ { "type", (int)LoginType.Phone },
227
+ { "token", $"{areaCode} {phoneNumber}" },
228
+ { "secret", code },
229
+ { "subType", "text" }
230
+ };
231
+ await XDHttpClient.Client.PostAsync<BaseResponse>(UserModule.XDG_BIND_INTERFACE, data: authData);
232
+ }
233
+
234
+ private static async Task UnbindByPhone(string code)
235
+ {
236
+ Dictionary<string, object> data = new Dictionary<string, object>()
237
+ {
238
+ { "type", (int)LoginType.Phone },
239
+ { "verificationCode", code }
240
+ };
241
+ await XDHttpClient.Client.PostAsync<BaseResponse>(UserModule.XDG_UNBIND_INTERFACE, data: data);
242
+ }
243
+ }
244
+ }
245
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 551c9104e48f4e41b06fba7dd51ea466
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: