com.xd.sdk.account 7.1.1 → 7.2.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 (25) hide show
  1. package/Plugins/Android/libs/XDGAccount_7.2.0.aar +0 -0
  2. package/Plugins/Android/libs/{XDGBridgeAccount_v7_7.1.0.aar → XDGBridgeAccount_v7_7.2.0.aar} +0 -0
  3. package/Plugins/Android/libs/XDGSupport_7.2.0.aar +0 -0
  4. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h +3 -3
  5. package/Plugins/iOS/XDAccountSDK.framework/Info.plist +0 -0
  6. package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK +0 -0
  7. package/Runtime/Internal/Mobile/AccountFeaturesImpl.cs +8 -9
  8. package/Runtime/Internal/Mobile/Http/MacAuthenticationInterceptor.cs +2 -2
  9. package/Runtime/Internal/Standalone/AccessToken/AccessTokenModule.cs +1 -1
  10. package/Runtime/Internal/Standalone/AccountFeaturesImpl.cs +22 -13
  11. package/Runtime/Internal/Standalone/Auth/TapAuth.cs +9 -16
  12. package/Runtime/Internal/Standalone/Auth/WebAuth.cs +4 -4
  13. package/Runtime/Internal/Standalone/SupportModule/SupportModule.cs +7 -7
  14. package/Runtime/Internal/Standalone/Track/AliyunTrack.Login.cs +2 -1
  15. package/Runtime/Internal/Standalone/UI/PhoneVerification/RiskControlAlert.cs +72 -32
  16. package/Runtime/Internal/Standalone/UserCenterAlert.cs +9 -9
  17. package/Runtime/Internal/Standalone/UserModule.cs +17 -17
  18. package/Runtime/Internal/Standalone/WebFunction/AccessTokenWebFunction.cs +1 -1
  19. package/Runtime/Internal/XDGAccountInternal.cs +1 -1
  20. package/package.json +2 -2
  21. package/Plugins/Android/libs/XDGAccount_7.1.0.aar +0 -0
  22. package/Plugins/Android/libs/XDGSupport_7.1.0.aar +0 -0
  23. /package/Plugins/Android/libs/{XDGAccount_7.1.0.aar.meta → XDGAccount_7.2.0.aar.meta} +0 -0
  24. /package/Plugins/Android/libs/{XDGBridgeAccount_v7_7.1.0.aar.meta → XDGBridgeAccount_v7_7.2.0.aar.meta} +0 -0
  25. /package/Plugins/Android/libs/{XDGSupport_7.1.0.aar.meta → XDGSupport_7.2.0.aar.meta} +0 -0
@@ -4,6 +4,6 @@
4
4
  //
5
5
  // Created by Fattycat on 2023/4/14.
6
6
  //
7
- #define XDGAccount_VERSION @"7.1.0"
8
- #define XDSAccount_VERSION_CODE @"7001000"
9
- // HASH 669fedcf
7
+ #define XDGAccount_VERSION @"7.2.0"
8
+ #define XDSAccount_VERSION_CODE @"7020000"
9
+ // HASH 8d15387e
@@ -171,7 +171,7 @@ namespace XD.SDK.Account.Internal.Mobile
171
171
  }
172
172
  catch (Exception e)
173
173
  {
174
- XDGLogger.Warn("convert current user error" + e.Message);
174
+ XDGLogger.Warn("convert current user error" + e.Message, XDGLoggerTag.Bridge);
175
175
  }
176
176
  }
177
177
 
@@ -243,7 +243,7 @@ namespace XD.SDK.Account.Internal.Mobile
243
243
 
244
244
  EngineBridge.GetInstance().CallHandler(command, result =>
245
245
  {
246
- XDGLogger.Debug("bindByType 方法结果: " + result.ToJson());
246
+ XDGLogger.Debug("bindByType 方法结果: " + result.ToJson(), XDGLoggerTag.Bridge);
247
247
 
248
248
  var xdgError = result.Parse2XDGError();
249
249
  if (xdgError != null)
@@ -299,27 +299,26 @@ namespace XD.SDK.Account.Internal.Mobile
299
299
  try
300
300
  {
301
301
  var result = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TdsSDKGetUser);
302
- var objectId = XDDictionary.GetValue<string>(result, "objectId");
302
+ var objectId = XDDictionary.GetValue<string>(result.GetValueOrThrow(), "objectId");
303
303
  if (objectId == user.UserId)
304
304
  {
305
305
  return;
306
306
  }
307
307
 
308
- //TODO 同步之前先退登 TDSUser
309
308
  XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
310
309
  var response = await HttpClient.PostAsync<LoginSyncResponse>(LoginSynUrl);
311
310
  var sessionToken = XDDictionary.GetValue<string>(response.Data, "sessionToken");
312
311
  if (string.IsNullOrEmpty(sessionToken))
313
312
  {
314
- XDGLogger.Warn("[SyncTDSUser] sessionToken is Null!");
313
+ XDGLogger.Warn("[SyncTDSUser] sessionToken is Null!", XDGLoggerTag.Bridge);
315
314
  return;
316
315
  }
317
316
 
318
317
  XDGEventBus.Publish(XDGEvents.TdsSDKSyncUser, sessionToken, user.UserId);
319
318
  }
320
- catch (Exception e)
319
+ catch (XDGError e)
321
320
  {
322
- XDGLogger.Warn($"[SyncTDSUser] error:{e.Message}");
321
+ XDGLogger.Warn($"[SyncTDSUser] error:{e.ErrorMsg}", XDGLoggerTag.Bridge);
323
322
  }
324
323
  }
325
324
 
@@ -329,11 +328,11 @@ namespace XD.SDK.Account.Internal.Mobile
329
328
  using (var accountBridgeClass = new AndroidJavaClass(BridgeConstants.Account.BridgeStaticImpl))
330
329
  {
331
330
  var fbToken = accountBridgeClass.CallStatic<string>("getFacebookToken");
332
- XDGLogger.Debug($"[GetFacebookToken] fbToken:{fbToken}");
331
+ XDGLogger.Debug($"[GetFacebookToken] fbToken:{fbToken}", XDGLoggerTag.Bridge);
333
332
  var tokenDic = JsonConvert.DeserializeObject<Dictionary<string, object>>(fbToken);
334
333
  if (tokenDic.ContainsKey("error"))
335
334
  {
336
- XDGLogger.Warn($"[GetFacebookToken] error:{JsonConvert.SerializeObject(tokenDic)}");
335
+ XDGLogger.Warn($"[GetFacebookToken] error:{JsonConvert.SerializeObject(tokenDic)}", XDGLoggerTag.Bridge);
337
336
  return;
338
337
  }
339
338
  var token = XDDictionary.GetValue<string>(tokenDic, "access_token");
@@ -14,7 +14,7 @@ namespace XD.SDK.Account.Internal.Mobile
14
14
  {
15
15
  protected override async Task BeforeRequestAsync(IHttpRequest request, CancellationToken cancellationToken)
16
16
  {
17
- XDGLogger.Debug($"[MacAuthenticationInterceptor] request Url: {JsonConvert.SerializeObject(request.Url)}");
17
+ XDGLogger.Debug($"[MacAuthenticationInterceptor] request Url: {JsonConvert.SerializeObject(request.Url)}", XDGLoggerTag.Http);
18
18
 
19
19
  var authDic = await GetMacToken(request.Url, request.Method);
20
20
  var authToken = "";
@@ -24,7 +24,7 @@ namespace XD.SDK.Account.Internal.Mobile
24
24
  request.Headers["Authorization"] = authToken;
25
25
  }
26
26
 
27
- XDGLogger.Debug($"[MacAuthenticationInterceptor] request Headers: {JsonConvert.SerializeObject(request.Headers)}");
27
+ XDGLogger.Debug($"[MacAuthenticationInterceptor] request Headers: {JsonConvert.SerializeObject(request.Headers)}", XDGLoggerTag.Http);
28
28
  }
29
29
 
30
30
  private static Task<Dictionary<string, string>> GetMacToken(string requestUrl, HttpMethod method)
@@ -51,7 +51,7 @@ namespace XD.SDK.Account.Internal.Standalone
51
51
  }
52
52
  catch (Exception e)
53
53
  {
54
- XDGLogger.Warn(e.Message);
54
+ XDGLogger.Warn(e.Message, XDGLoggerTag.Account);
55
55
  }
56
56
  }
57
57
  }
@@ -88,7 +88,7 @@ namespace XD.SDK.Account.Internal.Standalone
88
88
  }
89
89
  catch (Exception e)
90
90
  {
91
- XDGLogger.Error(new XDGError(ResponseCode.Common.Failed, e.Message));
91
+ XDGLogger.Error(new XDGError(ResponseCode.Common.Failed, e.Message), XDGLoggerTag.Account);
92
92
  }
93
93
  }
94
94
 
@@ -107,7 +107,7 @@ namespace XD.SDK.Account.Internal.Standalone
107
107
  var user = UserModule.current;
108
108
  if (user == null)
109
109
  {
110
- XDGLogger.Warn("请先登录");
110
+ XDGLogger.Warn("请先登录", XDGLoggerTag.Account);
111
111
  UIManager.ShowToast(XDLocalization.GetCurrentLocalizableString().NotLogin);
112
112
  return;
113
113
  }
@@ -128,7 +128,7 @@ namespace XD.SDK.Account.Internal.Standalone
128
128
  var user = UserModule.current;
129
129
  if (user == null)
130
130
  {
131
- XDGLogger.Warn("请先登录");
131
+ XDGLogger.Warn("请先登录", XDGLoggerTag.Account);
132
132
  UIManager.ShowToast(XDLocalization.GetCurrentLocalizableString().NotLogin);
133
133
  return;
134
134
  }
@@ -148,7 +148,7 @@ namespace XD.SDK.Account.Internal.Standalone
148
148
  };
149
149
  var url = AuthConstants.CN_PERSONAL_INFO + UserModule.XDG_PERSONAL_INFO + "?" +
150
150
  XDUrlUtils.ToQueryString(queries);
151
-
151
+
152
152
  UIManager.ShowUI<XDWebViewAlert>("XDWebViewAlert", new Dictionary<string, object>
153
153
  {
154
154
  {
@@ -182,7 +182,7 @@ namespace XD.SDK.Account.Internal.Standalone
182
182
  }
183
183
  catch (Exception e)
184
184
  {
185
- XDGLogger.Error(new XDGError(ResponseCode.Common.Failed, e.Message));
185
+ XDGLogger.Error(new XDGError(ResponseCode.Common.Failed, e.Message), XDGLoggerTag.Account);
186
186
  }
187
187
  }
188
188
 
@@ -194,7 +194,7 @@ namespace XD.SDK.Account.Internal.Standalone
194
194
  }
195
195
  catch (XDGError e)
196
196
  {
197
- XDGLogger.Error(new XDGError(ResponseCode.Common.Failed, e.ErrorMsg));
197
+ XDGLogger.Error(new XDGError(ResponseCode.Common.Failed, e.ErrorMsg), XDGLoggerTag.Account);
198
198
  }
199
199
  }
200
200
 
@@ -245,7 +245,8 @@ namespace XD.SDK.Account.Internal.Standalone
245
245
  // AliyunTrack.LoginAntiAddictionResult(XDDictionary.GetValue(complianceResult, "code", -100),
246
246
  // XDDictionary.GetValue<string>(complianceResult, "reason"),
247
247
  // XDDictionary.GetValue<string>(complianceResult, "extras"));
248
- if (XDDictionary.GetValue<bool>(complianceResult, "success"))
248
+ var compliance = complianceResult.GetValueOrDefault();
249
+ if (XDDictionary.GetValue<bool>(compliance, "success"))
249
250
  {
250
251
  await AgreementModule.SignAgreement(user.UserId);
251
252
  return user;
@@ -269,7 +270,15 @@ namespace XD.SDK.Account.Internal.Standalone
269
270
  }
270
271
  catch (Exception e)
271
272
  {
272
- AliyunTrack.LoginFail(e.Message);
273
+ if (e is XDGError error)
274
+ {
275
+ AliyunTrack.LoginFail(error.ErrorMsg);
276
+ }
277
+ else
278
+ {
279
+ AliyunTrack.LoginFail(e.Message);
280
+ }
281
+
273
282
  AgreementModule.ClearLocalSignedAgreements();
274
283
  throw;
275
284
  }
@@ -279,7 +288,7 @@ namespace XD.SDK.Account.Internal.Standalone
279
288
  {
280
289
  // SDK 登陆成功
281
290
  AliyunTrack.LoginLogout(logoutType);
282
-
291
+
283
292
  ClearUserCache();
284
293
 
285
294
  XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
@@ -321,7 +330,7 @@ namespace XD.SDK.Account.Internal.Standalone
321
330
  var current = UserModule.current;
322
331
  if (current == null)
323
332
  {
324
- XDGLogger.Warn("请先登录");
333
+ XDGLogger.Warn("请先登录", XDGLoggerTag.Account);
325
334
  UIManager.ShowToast(XDLocalization.GetCurrentLocalizableString().NotLogin);
326
335
  return;
327
336
  }
@@ -329,7 +338,7 @@ namespace XD.SDK.Account.Internal.Standalone
329
338
  string cancelUrl = ConfigModule.CancelUrl;
330
339
  if (string.IsNullOrEmpty(cancelUrl))
331
340
  {
332
- XDGLogger.Warn("没有有效的注销 url");
341
+ XDGLogger.Warn("没有有效的注销 url", XDGLoggerTag.Account);
333
342
  return;
334
343
  }
335
344
 
@@ -360,7 +369,7 @@ namespace XD.SDK.Account.Internal.Standalone
360
369
  }
361
370
 
362
371
  var url = $"{cancelUrl}?{XDUrlUtils.ToQueryString(queryParams)}";
363
- XDGLogger.Debug($"cancel url: {url}");
372
+ XDGLogger.Debug($"cancel url: {url}", XDGLoggerTag.Account);
364
373
 
365
374
  // 打开内置浏览器
366
375
  var data = new Dictionary<string, object>
@@ -390,7 +399,7 @@ namespace XD.SDK.Account.Internal.Standalone
390
399
  }
391
400
  catch (Exception e)
392
401
  {
393
- XDGLogger.Warn($"[InvokeXdgPaymentCheckRefundStatusWithUI] Error:{e.Message}");
402
+ XDGLogger.Warn($"[InvokeXdgPaymentCheckRefundStatusWithUI] Error:{e.Message}", XDGLoggerTag.Account);
394
403
  }
395
404
 
396
405
  return user;
@@ -27,18 +27,11 @@ namespace XD.SDK.Account.Internal.Standalone
27
27
  UIManager.ShowLoading(timeout: 3);
28
28
  }
29
29
  // 使用明确指定参数类型的反射调用
30
- var permissions = ConfigModule.TapConfig.Permissions;
31
- var authData = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKLogin, permissions);
32
-
33
- // 检查返回结果是否为 null
34
- if (authData == null)
35
- {
36
- throw new XDGError(ResponseCode.Common.Failed, "TapTap 登录返回数据为空");
37
- }
38
-
30
+ var permissions = ConfigModule.TapConfig?.Permissions;
31
+ var authDataResult = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKLogin, permissions);
32
+ var authData = authDataResult.GetValueOrThrow();
39
33
  authData.Add("type", (int)LoginType.TapTap);
40
34
  authData.Add("scope", string.Join(",", permissions?.ToArray()));
41
-
42
35
  if (ConfigModule.TapConfig != null && ConfigModule.UsingTapPC)
43
36
  {
44
37
  UIManager.DismissLoading();
@@ -50,21 +43,21 @@ namespace XD.SDK.Account.Internal.Standalone
50
43
  // {
51
44
  // if (e.code == (int)TapErrorCode.ERROR_CODE_LOGIN_CANCEL)
52
45
  // {
53
- // XDGLogger.Debug($"Tap 取消登录,{e}");
46
+ // XDGLogger.Debug($"Tap 取消登录,{e}", XDGLoggerTag.Account);
54
47
  // AliyunTrack.LoginAuthorizeFail(e.Message);
55
48
  // throw XDGErrorExtensions.CancelledError(e.message);
56
49
  // }
57
50
  // else
58
51
  // {
59
- // XDGLogger.Warn($"Tap 登录失败:{e}");
52
+ // XDGLogger.Warn($"Tap 登录失败:{e}", XDGLoggerTag.Account);
60
53
  // throw new XDGError(ResponseCode.Common.Failed, e.Message);
61
54
  // }
62
55
  // }
63
- catch (Exception e)
56
+ catch (XDGError e)
64
57
  {
65
- AliyunTrack.LoginAuthorizeFail(e.Message);
66
- XDGLogger.Warn($"Tap 登录失败:{e}");
67
- throw new XDGError(ResponseCode.Common.Failed, e.Message);
58
+ AliyunTrack.LoginAuthorizeFail(e.ErrorMsg);
59
+ XDGLogger.Warn($"Tap 登录失败:{e.ErrorMsg}",XDGLoggerTag.Common);
60
+ throw new XDGError(ResponseCode.Common.Failed, e.ErrorMsg);
68
61
  }
69
62
  }
70
63
  }
@@ -56,7 +56,7 @@ namespace XD.SDK.Account.Internal.Standalone
56
56
  string authRequest = $"{url}?{string.Join("&", queryPairs)}";
57
57
 
58
58
  // 弹出授权页
59
- XDGLogger.Debug($"auth: {authRequest}");
59
+ XDGLogger.Debug($"auth: {authRequest}", XDGLoggerTag.Account);
60
60
  AliyunTrack.LoginAuthorize();
61
61
  // 登陆跳转授权 Track
62
62
  Application.OpenURL(Uri.EscapeUriString(authRequest));
@@ -79,8 +79,8 @@ namespace XD.SDK.Account.Internal.Standalone
79
79
  {
80
80
  HttpListenerContext context = await server.GetContextAsync();
81
81
 
82
- XDGLogger.Debug($"Request url: {context.Request.RawUrl}");
83
- XDGLogger.Debug($"Request method: {context.Request.HttpMethod}");
82
+ XDGLogger.Debug($"Request url: {context.Request.RawUrl}", XDGLoggerTag.Account);
83
+ XDGLogger.Debug($"Request method: {context.Request.HttpMethod}", XDGLoggerTag.Account);
84
84
 
85
85
  context.Response.StatusCode = 200;
86
86
  context.Response.Close();
@@ -129,7 +129,7 @@ namespace XD.SDK.Account.Internal.Standalone
129
129
  }
130
130
  catch (Exception e)
131
131
  {
132
- XDGLogger.Debug(e.Message);
132
+ XDGLogger.Debug(e.Message, XDGLoggerTag.Account);
133
133
  // 异常结果则一直 pending
134
134
  // 登陆授权失败
135
135
  AliyunTrack.LoginAuthorizeFail(e.Message);
@@ -46,7 +46,7 @@ namespace XD.SDK.Account.Internal.Standalone
46
46
  return;
47
47
  }
48
48
 
49
- XDGLogger.Debug("XSupportManager is disabled by config, skipping polling start");
49
+ XDGLogger.Debug("XSupportManager is disabled by config, skipping polling start", XDGLoggerTag.Support);
50
50
  }
51
51
 
52
52
  private const string XdgSupportUserUnreadCheck = "api/support/v1/user/unread/check";
@@ -85,7 +85,7 @@ namespace XD.SDK.Account.Internal.Standalone
85
85
 
86
86
  private static async void CheckUnRead()
87
87
  {
88
- XDGLogger.Debug("Support check unread");
88
+ XDGLogger.Debug("Support check unread", XDGLoggerTag.Support);
89
89
  try
90
90
  {
91
91
  string requestUrl;
@@ -112,7 +112,7 @@ namespace XD.SDK.Account.Internal.Standalone
112
112
  Instance.bLastHasRead = bHasUnRead;
113
113
  var nextTimeInterval = bUnReadStatusChange ? 10 : IncreaseTimeInterval();
114
114
  Instance.nextCheckUnreadTime = response.Data.IntervalSec > 0 ? response.Data.IntervalSec : nextTimeInterval;
115
- XDGLogger.Debug($"Support Check UnRead Success, hasUnread:{response.Data.HasUnread} interval:{response.Data.IntervalSec}");
115
+ XDGLogger.Debug($"Support Check UnRead Success, hasUnread:{response.Data.HasUnread} interval:{response.Data.IntervalSec}", XDGLoggerTag.Support);
116
116
  if (bUnReadStatusChange)
117
117
  {
118
118
  AccountFeaturesImpl.Instance.GetUserStatusCallback()
@@ -142,7 +142,7 @@ namespace XD.SDK.Account.Internal.Standalone
142
142
  }
143
143
  catch (ObjectDisposedException e)
144
144
  {
145
- XDGLogger.Warn($"Support Cancel CheckUnRead Action error:{e.Message}");
145
+ XDGLogger.Warn($"Support Cancel CheckUnRead Action error:{e.Message}", XDGLoggerTag.Support);
146
146
  }
147
147
 
148
148
  Instance.cts = new CancellationTokenSource();
@@ -158,7 +158,7 @@ namespace XD.SDK.Account.Internal.Standalone
158
158
  }
159
159
  catch (TaskCanceledException e)
160
160
  {
161
- XDGLogger.Warn($"Support Start CheckUnRead Action error:{e.Message}");
161
+ XDGLogger.Warn($"Support Start CheckUnRead Action error:{e.Message}", XDGLoggerTag.Support);
162
162
  }
163
163
  });
164
164
  return;
@@ -169,7 +169,7 @@ namespace XD.SDK.Account.Internal.Standalone
169
169
 
170
170
  private static async void RequestSupportUrl(XDGRoleInfo roleInfo, string path, Dictionary<string, object> extra, Action<bool, bool, string> action)
171
171
  {
172
- XDGLogger.Debug("Support RequestSupportUrl");
172
+ XDGLogger.Debug("Support RequestSupportUrl", XDGLoggerTag.Support);
173
173
  try
174
174
  {
175
175
  path = path ?? "";
@@ -216,7 +216,7 @@ namespace XD.SDK.Account.Internal.Standalone
216
216
  }
217
217
  catch (XDGError e)
218
218
  {
219
- XDGLogger.Warn($"Support RequestSupportUrl error:{e.ErrorMsg}");
219
+ XDGLogger.Warn($"Support RequestSupportUrl error:{e.ErrorMsg}", XDGLoggerTag.Support);
220
220
  action.Invoke(false, false, null);
221
221
  }
222
222
  }
@@ -431,7 +431,8 @@ namespace XD.SDK.Account.Internal.Standalone
431
431
 
432
432
  private static Dictionary<string, string> GetLoginModuleCommonProperties(string eventName, string userLoginTypeString = "")
433
433
  {
434
- var current = XDGEventBus.Publish<XDGUser>(XDGEvents.AccountGetCurrentUser)?.UserId;
434
+ var result = XDGEventBus.Publish<XDGUser>(XDGEvents.AccountGetCurrentUser);
435
+ var current = result.GetValueOrDefault()?.UserId;
435
436
  var content = new Dictionary<string, string>();
436
437
  content["tag"] = "sdklogin";
437
438
  content["event_session_id"] = LoginEventSessionId;
@@ -11,8 +11,10 @@ using Vuplex.WebView;
11
11
  using XD.SDK.Common;
12
12
  using XD.SDK.Common.Internal.Standalone;
13
13
 
14
- namespace XD.SDK.Account.Internal.Standalone {
15
- public class RiskControlAlert : UIElement {
14
+ namespace XD.SDK.Account.Internal.Standalone
15
+ {
16
+ public class RiskControlAlert : UIElement
17
+ {
16
18
  public const int CONTROL_DONE_CODE = 0;
17
19
  public const int CLOSE_CODE = -1;
18
20
  public const int BACK_CODE = 1;
@@ -22,59 +24,87 @@ namespace XD.SDK.Account.Internal.Standalone {
22
24
 
23
25
  private CanvasWebViewPrefab canvasWebViewPrefab;
24
26
 
25
- public static async Task<int> Control(Func<string, Task<RequestVerifyCodeData>> requestVerifyCodeFunc) {
27
+ public static async Task<int> Control(Func<string, Task<RequestVerifyCodeData>> requestVerifyCodeFunc)
28
+ {
26
29
  RiskControlAlert alert = null;
27
30
  string riskControlData = null;
28
31
  TaskCompletionSource<int> tcs = new TaskCompletionSource<int>();
29
- try {
32
+ try
33
+ {
30
34
  UIManager.ShowLoading(true);
31
35
  RequestVerifyCodeData verifyCodeData = await requestVerifyCodeFunc(riskControlData);
32
36
  tcs.TrySetResult(verifyCodeData.ReSendInterval);
33
- } catch (XDGError e) {
34
- if (e.Code == PhoneModule.RISK_CONTROL) {
37
+ }
38
+ catch (XDGError e)
39
+ {
40
+ if (e.Code == PhoneModule.RISK_CONTROL)
41
+ {
35
42
  // 触发风控
36
- alert = UIManager.ShowUI<RiskControlAlert>("XDRiskControlAlert", null, async (code, data) => {
37
- if (code == CLOSE_CODE) {
43
+ alert = UIManager.ShowUI<RiskControlAlert>("XDRiskControlAlert", null, async (code, data) =>
44
+ {
45
+ if (code == CLOSE_CODE)
46
+ {
38
47
  UIManager.Dismiss();
39
48
  tcs.TrySetException(XDGErrorExtensions.CancelledError());
40
- } else if (code == BACK_CODE) {
49
+ }
50
+ else if (code == BACK_CODE)
51
+ {
41
52
  UIManager.Dismiss();
42
- } else if (code == CONTROL_DONE_CODE) {
53
+ }
54
+ else if (code == CONTROL_DONE_CODE)
55
+ {
43
56
  riskControlData = data as string;
44
- try {
57
+ try
58
+ {
45
59
  UIManager.ShowLoading();
46
60
  RequestVerifyCodeData result = await requestVerifyCodeFunc(riskControlData);
47
61
  tcs.TrySetResult(result.ReSendInterval);
48
- } catch (XDGError ex) {
62
+ }
63
+ catch (XDGError ex)
64
+ {
49
65
  UIManager.DismissLoading();
50
- if (ex.Code == PhoneModule.RISK_CONTROL) {
66
+ if (ex.Code == PhoneModule.RISK_CONTROL)
67
+ {
51
68
  // 触发风控
52
69
  await alert.Reload();
53
- } else if (ex.Code == PhoneModule.RISK_CONTROL_FAILED) {
70
+ }
71
+ else if (ex.Code == PhoneModule.RISK_CONTROL_FAILED)
72
+ {
54
73
  // 滑动验证失败
55
74
  await alert.Reload();
56
75
  UIManager.ShowToast(e.Message);
57
- } else {
76
+ }
77
+ else
78
+ {
58
79
  tcs.TrySetException(ex);
59
80
  }
60
- } finally {
81
+ }
82
+ finally
83
+ {
61
84
  UIManager.DismissLoading();
62
85
  }
63
86
  }
64
87
  });
65
- } else {
88
+ }
89
+ else
90
+ {
66
91
  tcs.TrySetException(e);
67
92
  }
68
- } catch (Exception e) {
93
+ }
94
+ catch (Exception e)
95
+ {
69
96
  tcs.TrySetException(e);
70
- } finally {
97
+ }
98
+ finally
99
+ {
71
100
  UIManager.DismissLoading();
72
101
  }
73
102
 
74
103
  return await tcs.Task;
75
104
  }
76
105
 
77
- private void Awake() {
106
+ private void Awake()
107
+ {
78
108
  Transform webviewContainer = transform.Find("WebViewContainer");
79
109
  canvasWebViewPrefab = CanvasWebViewPrefab.Instantiate();
80
110
  canvasWebViewPrefab.transform.SetParent(webviewContainer);
@@ -89,19 +119,21 @@ namespace XD.SDK.Account.Internal.Standalone {
89
119
  closeButton.onClick.AddListener(OnCloseClicked);
90
120
  }
91
121
 
92
- private async void Start() {
122
+ private async void Start()
123
+ {
93
124
  UIManager.ShowLoading();
94
125
 
95
126
  await canvasWebViewPrefab.WaitUntilInitialized();
96
127
 
97
128
  canvasWebViewPrefab.DragMode = DragMode.DragWithinPage;
98
129
 
99
- canvasWebViewPrefab.WebView.MessageEmitted += (sender, eventArgs) => {
100
- XDGLogger.Debug(eventArgs.Value);
130
+ canvasWebViewPrefab.WebView.MessageEmitted += (sender, eventArgs) =>
131
+ {
132
+ XDGLogger.Debug(eventArgs.Value, XDGLoggerTag.Web);
101
133
  Dictionary<string, string> response = JsonConvert.DeserializeObject<Dictionary<string, string>>(eventArgs.Value);
102
134
  Dictionary<string, object> data = JsonConvert.DeserializeObject<Dictionary<string, object>>(response["message"]);
103
135
  string riskControlData = JsonConvert.SerializeObject(data["data"]);
104
- XDGLogger.Debug(riskControlData);
136
+ XDGLogger.Debug(riskControlData, XDGLoggerTag.Web);
105
137
  UIManager.Dismiss();
106
138
 
107
139
  OnCallback(CONTROL_DONE_CODE, riskControlData);
@@ -121,7 +153,7 @@ namespace XD.SDK.Account.Internal.Standalone {
121
153
  NetworkInterfaceType _type2 = NetworkInterfaceType.Ethernet;
122
154
 
123
155
  if ((item.NetworkInterfaceType == _type1 || item.NetworkInterfaceType == _type2) && item.OperationalStatus == OperationalStatus.Up)
124
- #endif
156
+ #endif
125
157
  {
126
158
  foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
127
159
  {
@@ -129,17 +161,21 @@ namespace XD.SDK.Account.Internal.Standalone {
129
161
  if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
130
162
  {
131
163
  output = ip.Address.ToString();
132
- XDGLogger.Debug($"ip local: {output}");
164
+ XDGLogger.Debug($"ip local: {output}", XDGLoggerTag.Web);
133
165
  }
134
166
  }
135
167
  }
136
168
  }
169
+
137
170
  return output;
138
171
  }
139
- private async Task Reload() {
172
+
173
+ private async Task Reload()
174
+ {
140
175
  UIManager.ShowLoading();
141
176
  var ip = GetIP();
142
- canvasWebViewPrefab.WebView.LoadUrl($"https://login-xdsdk.xd.cn/awsc?platform={Platform}&eventSessionId={AliyunTrack.LoginEventSessionId}&login_type=Phone&sub_login_type=2&xd_client_id={ConfigModule.ClientId}&device_id={SystemInfo.deviceUniqueIdentifier}&os={SystemInfo.operatingSystem}&ip={ip}&app_version={Application.version}&language={XDLocalization.CurrentLang.ToString()}");
177
+ canvasWebViewPrefab.WebView.LoadUrl(
178
+ $"https://login-xdsdk.xd.cn/awsc?platform={Platform}&eventSessionId={AliyunTrack.LoginEventSessionId}&login_type=Phone&sub_login_type=2&xd_client_id={ConfigModule.ClientId}&device_id={SystemInfo.deviceUniqueIdentifier}&os={SystemInfo.operatingSystem}&ip={ip}&app_version={Application.version}&language={XDLocalization.CurrentLang.ToString()}");
143
179
  await canvasWebViewPrefab.WebView.WaitForNextPageLoadToFinish();
144
180
  // 注入 js
145
181
  _ = canvasWebViewPrefab.WebView.ExecuteJavaScript(@";(function (window) {
@@ -157,8 +193,10 @@ namespace XD.SDK.Account.Internal.Standalone {
157
193
  UIManager.DismissLoading();
158
194
  }
159
195
 
160
- private string Platform {
161
- get {
196
+ private string Platform
197
+ {
198
+ get
199
+ {
162
200
  if (Application.platform == RuntimePlatform.Android)
163
201
  {
164
202
  return "Android";
@@ -176,11 +214,13 @@ namespace XD.SDK.Account.Internal.Standalone {
176
214
 
177
215
  #region UI Events
178
216
 
179
- private void OnBackClicked() {
217
+ private void OnBackClicked()
218
+ {
180
219
  OnCallback(BACK_CODE, null);
181
220
  }
182
221
 
183
- private void OnCloseClicked() {
222
+ private void OnCloseClicked()
223
+ {
184
224
  OnCallback(CLOSE_CODE, null);
185
225
  }
186
226
 
@@ -227,7 +227,7 @@ namespace XD.SDK.Account.Standalone
227
227
  }
228
228
  catch (Exception e)
229
229
  {
230
- XDGLogger.Warn($"列表请求失败: {e}");
230
+ XDGLogger.Warn($"列表请求失败: {e}", XDGLoggerTag.Account);
231
231
  errorView.SetActive(true);
232
232
  }
233
233
  finally
@@ -238,7 +238,7 @@ namespace XD.SDK.Account.Standalone
238
238
 
239
239
  private async void Bind(LoginType loginType, int cellIndex)
240
240
  {
241
- XDGLogger.Debug("绑定: " + loginType);
241
+ XDGLogger.Debug("绑定:" + loginType, XDGLoggerTag.Account);
242
242
  try
243
243
  {
244
244
  await UserModule.Bind(loginType);
@@ -254,11 +254,11 @@ namespace XD.SDK.Account.Standalone
254
254
  }
255
255
  catch (TaskCanceledException)
256
256
  {
257
- XDGLogger.Debug("关闭绑定");
257
+ XDGLogger.Debug("关闭绑定", XDGLoggerTag.Account);
258
258
  }
259
259
  catch (Exception e)
260
260
  {
261
- XDGLogger.Warn($"绑定失败: {e}");
261
+ XDGLogger.Warn($"绑定失败: {e}", XDGLoggerTag.Account);
262
262
  UIManager.ShowToast(localizableString.BindError);
263
263
  }
264
264
  }
@@ -289,7 +289,7 @@ namespace XD.SDK.Account.Standalone
289
289
 
290
290
  private async void Unbind(LoginType loginType, int cellIndex)
291
291
  {
292
- XDGLogger.Debug("解绑: " + loginType);
292
+ XDGLogger.Debug("解绑: " + loginType, XDGLoggerTag.Account);
293
293
  UIManager.ShowLoading();
294
294
  try
295
295
  {
@@ -313,7 +313,7 @@ namespace XD.SDK.Account.Standalone
313
313
  }
314
314
  catch (XDGError e)
315
315
  {
316
- XDGLogger.Warn(e.ToString());
316
+ XDGLogger.Warn(e.ToString(), XDGLoggerTag.Account);
317
317
  if (string.IsNullOrEmpty(e.Message))
318
318
  {
319
319
  UIManager.ShowToast(localizableString.UnbindError);
@@ -325,11 +325,11 @@ namespace XD.SDK.Account.Standalone
325
325
  }
326
326
  catch (TaskCanceledException)
327
327
  {
328
- XDGLogger.Debug("关闭解绑");
328
+ XDGLogger.Debug("关闭解绑", XDGLoggerTag.Account);
329
329
  }
330
330
  catch (Exception e)
331
331
  {
332
- XDGLogger.Warn($"解绑失败: {e}");
332
+ XDGLogger.Warn($"解绑失败: {e}", XDGLoggerTag.Account);
333
333
  UIManager.ShowToast(localizableString.UnbindError);
334
334
  }
335
335
  finally
@@ -370,7 +370,7 @@ namespace XD.SDK.Account.Standalone
370
370
 
371
371
  public void ErrorViewTap()
372
372
  {
373
- XDGLogger.Debug("点击了 errorViewTap");
373
+ XDGLogger.Debug("点击了 errorViewTap", XDGLoggerTag.Account);
374
374
  errorView.SetActive(false);
375
375
  _ = RequestBinds();
376
376
  }
@@ -71,7 +71,7 @@ namespace XD.SDK.Account.Internal.Standalone
71
71
  }
72
72
  catch (Exception e)
73
73
  {
74
- XDGLogger.Warn(e.Message);
74
+ XDGLogger.Error(e, XDGLoggerTag.Account);
75
75
  }
76
76
  }
77
77
  }
@@ -123,7 +123,7 @@ namespace XD.SDK.Account.Internal.Standalone
123
123
  {
124
124
  if (XDGCommonInternal.IsCn())
125
125
  {
126
- XDGLogger.Warn("暂不支持的登录方式");
126
+ XDGLogger.Warn("暂不支持的登录方式", XDGLoggerTag.Account);
127
127
  throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
128
128
  }
129
129
  else
@@ -157,7 +157,7 @@ namespace XD.SDK.Account.Internal.Standalone
157
157
  {
158
158
  if (XDGCommonInternal.IsCn())
159
159
  {
160
- XDGLogger.Warn("暂不支持的登录方式");
160
+ XDGLogger.Warn($"暂不支持的登录方式:{LoginType.Email}", XDGLoggerTag.Account);
161
161
  throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
162
162
  }
163
163
  else
@@ -177,7 +177,7 @@ namespace XD.SDK.Account.Internal.Standalone
177
177
  {
178
178
  if (XDGCommonInternal.IsCn() && loginType == LoginType.Email)
179
179
  {
180
- XDGLogger.Warn("暂不支持的登录方式");
180
+ XDGLogger.Warn($"暂不支持的登录方式:{LoginType.Email}", XDGLoggerTag.Account);
181
181
  throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
182
182
  }
183
183
 
@@ -192,7 +192,7 @@ namespace XD.SDK.Account.Internal.Standalone
192
192
  {
193
193
  if (localUser == null)
194
194
  {
195
- XDGLogger.Warn("缺少本地登录信息");
195
+ XDGLogger.Warn("自动登录缺少本地登录信息", XDGLoggerTag.Account);
196
196
  if (ConfigModule.UsingTapPC && !ConfigModule.DisableAutoLogin2Tap)
197
197
  {
198
198
  return await Login(LoginType.TapTap);
@@ -205,18 +205,18 @@ namespace XD.SDK.Account.Internal.Standalone
205
205
  {
206
206
  try
207
207
  {
208
- var token = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKGetAccessToken);
209
-
208
+ var tokenResult = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKGetAccessToken);
209
+ var token = tokenResult.GetValueOrThrow();
210
210
  if (token == null || !token.ContainsKey("token"))
211
211
  {
212
- XDGLogger.Warn("Third token expired.");
212
+ XDGLogger.Warn("Third token expired.", XDGLoggerTag.Account);
213
213
  throw new XDGError(ResponseCode.Account.TokenExpired, "Third token expired.");
214
214
  }
215
215
  }
216
- catch (Exception e)
216
+ catch (XDGError e)
217
217
  {
218
- XDGLogger.Warn(e.Message);
219
- throw new XDGError(ResponseCode.Common.Failed, e.Message);
218
+ XDGLogger.Warn(e.ErrorMsg, XDGLoggerTag.Account);
219
+ throw new XDGError(ResponseCode.Common.Failed, e.ErrorMsg);
220
220
  }
221
221
  }
222
222
 
@@ -233,7 +233,7 @@ namespace XD.SDK.Account.Internal.Standalone
233
233
  }
234
234
  catch (Exception e)
235
235
  {
236
- XDGLogger.Warn(e.Message);
236
+ XDGLogger.Warn(e.Message, XDGLoggerTag.Account);
237
237
  }
238
238
 
239
239
  _ = AccessTokenModule.Refresh();
@@ -283,10 +283,10 @@ namespace XD.SDK.Account.Internal.Standalone
283
283
  }
284
284
  catch (Exception e)
285
285
  {
286
- XDGLogger.Warn(e.ToString());
286
+ XDGLogger.Warn(e.ToString(), XDGLoggerTag.Account);
287
287
  }
288
288
 
289
- XDGLogger.Debug(string.Format($"xd userID: {user.UserId}"));
289
+ XDGLogger.Debug(string.Format($"xd userID: {user.UserId}"), XDGLoggerTag.Account);
290
290
  return user;
291
291
  }
292
292
  catch (XDGError e)
@@ -366,7 +366,7 @@ namespace XD.SDK.Account.Internal.Standalone
366
366
  XDGAccessToken localToken = await AccessTokenModule.GetLocalAccessToken();
367
367
  string steamId = SteamAuth.GetSteamIdFromSDK();
368
368
  XDGUser user;
369
- XDGLogger.Debug($"LoginByConsole steamId: {steamId} localToken: {localToken} steamId: {steamId}");
369
+ XDGLogger.Debug($"LoginByConsole steamId: {steamId} localToken: {localToken} steamId: {steamId}", XDGLoggerTag.Account);
370
370
  if (!string.IsNullOrEmpty(localToken?.SteamId) && !string.IsNullOrEmpty(steamId) && localToken?.SteamId == steamId)
371
371
  {
372
372
  try
@@ -401,10 +401,10 @@ namespace XD.SDK.Account.Internal.Standalone
401
401
  }
402
402
  catch (Exception e)
403
403
  {
404
- XDGLogger.Warn(e.ToString());
404
+ XDGLogger.Warn(e.ToString(), XDGLoggerTag.Account);
405
405
  }
406
406
 
407
- XDGLogger.Debug(string.Format($"xd userID: {user.UserId}"));
407
+ XDGLogger.Debug(string.Format($"xd userID: {user.UserId}"), XDGLoggerTag.Account);
408
408
  return user;
409
409
  }
410
410
  finally
@@ -17,7 +17,7 @@ namespace XD.SDK.Account.Internal.Standalone
17
17
 
18
18
  public async void Handler(IBridgeWebView webView, string data, Action<object> callbackFunction)
19
19
  {
20
- XDGLogger.Debug($"message from javascript by:{GetName()} with data:{data}");
20
+ XDGLogger.Debug($"message from javascript by:{GetName()} with data:{data}", XDGLoggerTag.Web);
21
21
  var token = await AccessTokenModule.GetLocalAccessToken();
22
22
  if (token == null)
23
23
  {
@@ -22,7 +22,7 @@ namespace XD.SDK.Account
22
22
  #endif
23
23
  if (_platformWrapper == null)
24
24
  {
25
- XDGLogger.Error("unsupported platform: " + Application.platform);
25
+ XDGLogger.Error("unsupported platform: " + Application.platform, XDGLoggerTag.Account);
26
26
  }
27
27
  }
28
28
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.xd.sdk.account",
3
3
  "displayName": "XDGSDK Account",
4
- "version": "7.1.1",
4
+ "version": "7.2.0",
5
5
  "description": "XDGSDK",
6
6
  "unity": "2019.3",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.xd.sdk.common": "7.1.1"
9
+ "com.xd.sdk.common": "7.2.0"
10
10
  }
11
11
  }