com.xd.sdk.account 7.7.0 → 7.8.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 (32) hide show
  1. package/Editor/Android/XDAccountAndroidGradleProcessor.cs +1 -3
  2. package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h +3 -3
  3. package/Plugins/iOS/XDAccountSDK.framework/Info.plist +0 -0
  4. package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK +0 -0
  5. package/Runtime/Internal/Standalone/AccessToken/AccessTokenModule.cs +7 -3
  6. package/Runtime/Internal/Standalone/AccountFeaturesImpl.cs +56 -13
  7. package/Runtime/Internal/Standalone/Auth/UrlSchemeAuth.cs +66 -4
  8. package/Runtime/Internal/Standalone/Compliance/XDCompliance.cs +129 -0
  9. package/Runtime/Internal/Standalone/Compliance/XDCompliance.cs.meta +11 -0
  10. package/Runtime/Internal/Standalone/Compliance/XDComplianceCloseResult.cs +43 -0
  11. package/Runtime/Internal/Standalone/Compliance/XDComplianceCloseResult.cs.meta +11 -0
  12. package/Runtime/Internal/Standalone/Compliance/XDComplianceCountdownService.cs +83 -0
  13. package/Runtime/Internal/Standalone/Compliance/XDComplianceCountdownService.cs.meta +11 -0
  14. package/Runtime/Internal/Standalone/Compliance/XDComplianceException.cs +29 -0
  15. package/Runtime/Internal/Standalone/Compliance/XDComplianceException.cs.meta +11 -0
  16. package/Runtime/Internal/Standalone/Compliance/XDComplianceWebOpener.cs +88 -0
  17. package/Runtime/Internal/Standalone/Compliance/XDComplianceWebOpener.cs.meta +11 -0
  18. package/Runtime/Internal/Standalone/LoginModule/Email/EmailModule.cs +1 -1
  19. package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModule.cs +1 -1
  20. package/Runtime/Internal/Standalone/LoginModule/Phone/PhoneModuleIO.cs +1 -1
  21. package/Runtime/Internal/Standalone/SupportModule/SupportModule.cs +21 -11
  22. package/Runtime/Internal/Standalone/UI/CodeUnbindAlert.cs +1 -1
  23. package/Runtime/Internal/Standalone/UI/Email/EmailAlert.cs +1 -1
  24. package/Runtime/Internal/Standalone/UI/PhoneIO/AreaCodeCell.cs +1 -1
  25. package/Runtime/Internal/Standalone/UI/PhoneIO/PhoneAlertIO.cs +1 -1
  26. package/Runtime/Internal/Standalone/UI/PhoneVerification/RiskControlAlert.cs +97 -25
  27. package/Runtime/Internal/Standalone/UI/PhoneVerification/VerifyCodeInputAlert.cs +1 -1
  28. package/Runtime/Internal/Standalone/UserModule.cs +152 -11
  29. package/Runtime/Internal/Standalone/WebFunction/GetUserInfoWebFunction.cs +47 -29
  30. package/Runtime/XD.SDK.Account.asmdef +1 -1
  31. package/package.json +2 -2
  32. package/Runtime/Internal/Mobile/Http/LoginSyncResponse.cs.meta +0 -3
@@ -4,16 +4,34 @@ using System.IO;
4
4
  using System.Threading.Tasks;
5
5
  using System.Collections.Generic;
6
6
  using System.Linq;
7
+ using Newtonsoft.Json;
8
+ using Newtonsoft.Json.Linq;
7
9
  using UnityEngine;
8
10
  using XD.SDK.Common;
9
11
  using XD.SDK.Common.Internal;
10
12
  using XD.SDK.Common.Internal.Events;
11
13
  using XD.SDK.Common.Internal.Standalone;
14
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
15
+ using XD.SDK.WebView;
16
+ #endif
12
17
 
13
18
  namespace XD.SDK.Account.Internal.Standalone
14
19
  {
15
20
  public class UserModule
16
21
  {
22
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
23
+ private static void EnsureWebViewAvailable()
24
+ {
25
+ if (XDWebViewService.IsAvailable)
26
+ {
27
+ return;
28
+ }
29
+
30
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Account);
31
+ throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
32
+ }
33
+ #endif
34
+
17
35
  public class CodeScope
18
36
  {
19
37
  // Code Scope 个人信息页
@@ -108,7 +126,8 @@ namespace XD.SDK.Account.Internal.Standalone
108
126
  if (loginType == LoginType.Phone)
109
127
  {
110
128
  AliyunTrack.ResetPhoneLoginData();
111
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
129
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
130
+ EnsureWebViewAvailable();
112
131
  if (XDGCommonInternal.IsCn())
113
132
  {
114
133
  await PhoneModule.Bind();
@@ -120,7 +139,6 @@ namespace XD.SDK.Account.Internal.Standalone
120
139
  #else
121
140
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
122
141
  #endif
123
-
124
142
  return;
125
143
  }
126
144
  else if (loginType == LoginType.Email)
@@ -132,7 +150,8 @@ namespace XD.SDK.Account.Internal.Standalone
132
150
  }
133
151
  else
134
152
  {
135
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
153
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
154
+ EnsureWebViewAvailable();
136
155
  await EmailModule.LoginOrBind(false);
137
156
  #else
138
157
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
@@ -151,7 +170,8 @@ namespace XD.SDK.Account.Internal.Standalone
151
170
  if (loginType == LoginType.Phone)
152
171
  {
153
172
  AliyunTrack.ResetPhoneLoginData();
154
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
173
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
174
+ EnsureWebViewAvailable();
155
175
  // 手机号解绑需要验证码
156
176
  if (XDGCommonInternal.IsCn())
157
177
  {
@@ -174,7 +194,8 @@ namespace XD.SDK.Account.Internal.Standalone
174
194
  }
175
195
  else
176
196
  {
177
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
197
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
198
+ EnsureWebViewAvailable();
178
199
  return EmailModule.Unbind(extras);
179
200
  #else
180
201
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
@@ -242,11 +263,15 @@ namespace XD.SDK.Account.Internal.Standalone
242
263
  }
243
264
  catch (XDHttpException e)
244
265
  {
245
- if (e.HttpStatusCode == 401 || e.Code == 40311 || e.Code == 40312)
266
+ if (e.HttpStatusCode == 401 || e.Code == 40311 || e.Code == 40312 || XDCompliance.IsRequired(e))
246
267
  {
247
268
  throw;
248
269
  }
249
270
  }
271
+ catch (XDComplianceException)
272
+ {
273
+ throw;
274
+ }
250
275
  catch (Exception e)
251
276
  {
252
277
  XDGLogger.Warn(e.Message, XDGLoggerTag.Account);
@@ -265,7 +290,8 @@ namespace XD.SDK.Account.Internal.Standalone
265
290
  {
266
291
  AliyunTrack.ResetPhoneLoginData();
267
292
  AliyunTrack.LoginEnableSDKLoginTrack();
268
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
293
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
294
+ EnsureWebViewAvailable();
269
295
  if (XDGCommonInternal.IsCn())
270
296
  {
271
297
  await PhoneModule.Login();
@@ -284,13 +310,13 @@ namespace XD.SDK.Account.Internal.Standalone
284
310
  {
285
311
  AliyunTrack.ResetEmailLoginData();
286
312
  AliyunTrack.LoginEnableSDKLoginTrack();
287
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
313
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
314
+ EnsureWebViewAvailable();
288
315
  await EmailModule.LoginOrBind(true);
289
316
  UIManager.ShowLoading();
290
317
  #else
291
318
  throw new XDGError(ResponseCode.Common.Failed, "This function need vuplex enabled");
292
319
  #endif
293
-
294
320
  }
295
321
  else
296
322
  {
@@ -400,6 +426,10 @@ namespace XD.SDK.Account.Internal.Standalone
400
426
  // 同自动登录一样,触发刷新 token
401
427
  _ = AccessTokenModule.Refresh();
402
428
  }
429
+ catch (XDComplianceException)
430
+ {
431
+ throw;
432
+ }
403
433
  catch (XDGError e)
404
434
  {
405
435
  if (e.Code == ResponseCode.Account.TokenExpired)
@@ -499,7 +529,12 @@ namespace XD.SDK.Account.Internal.Standalone
499
529
  }
500
530
  }
501
531
 
502
- public static async Task<XDGUser> FetchUserInfo()
532
+ public static Task<XDGUser> FetchUserInfo()
533
+ {
534
+ return FetchUserInfo(true);
535
+ }
536
+
537
+ private static async Task<XDGUser> FetchUserInfo(bool allowComplianceRetry)
503
538
  {
504
539
  try
505
540
  {
@@ -515,11 +550,54 @@ namespace XD.SDK.Account.Internal.Standalone
515
550
  }
516
551
 
517
552
  await persistence.Save(current, SystemInfo.deviceUniqueIdentifier);
553
+ XDCompliance.ApplyRemainingSeconds(response.RemainingSeconds);
518
554
  AliyunTrack.LoginPreSuccess();
519
555
  return current;
520
556
  }
521
557
  catch (XDHttpException xdException)
522
558
  {
559
+ var isComplianceRequired = XDCompliance.IsRequired(xdException);
560
+ var complianceUrl = GetComplianceUrl(xdException.ExtraData);
561
+ if (allowComplianceRetry
562
+ && isComplianceRequired
563
+ && !XDComplianceWebOpener.IsActive
564
+ && !string.IsNullOrEmpty(complianceUrl))
565
+ {
566
+ XDGLogger.Debug($"[Compliance] Trigger login web. code={xdException.Code}, message={xdException.ErrorMsg}, detail={xdException.Detail}, global={ConfigModule.IsGlobal}, active={XDComplianceWebOpener.IsActive}, url={complianceUrl}", XDGLoggerTag.Account);
567
+ try
568
+ {
569
+ await XDCompliance.RunOnLogin(complianceUrl);
570
+ }
571
+ catch (Exception e)
572
+ {
573
+ AliyunTrack.LoginPreFail(e.Message);
574
+ throw;
575
+ }
576
+
577
+ try
578
+ {
579
+ return await FetchUserInfo(false);
580
+ }
581
+ // IL2CPP: keep explicit catch order; do not use catch filters.
582
+ catch (XDComplianceException)
583
+ {
584
+ throw;
585
+ }
586
+ catch (XDGError e)
587
+ {
588
+ throw new XDComplianceException(e);
589
+ }
590
+ catch (Exception e)
591
+ {
592
+ throw new XDComplianceException(e);
593
+ }
594
+ }
595
+
596
+ if (isComplianceRequired)
597
+ {
598
+ XDGLogger.Warn($"[Compliance] Login web not opened. code={xdException.Code}, message={xdException.ErrorMsg}, detail={xdException.Detail}, global={ConfigModule.IsGlobal}, allowRetry={allowComplianceRetry}, active={XDComplianceWebOpener.IsActive}, hasExtraData={xdException.ExtraData != null}, url={complianceUrl}, extraData={SerializeComplianceExtraData(xdException.ExtraData)}", XDGLoggerTag.Account);
599
+ }
600
+
523
601
  if (xdException.Code == 40312 && xdException.ExtraData != null)
524
602
  {
525
603
  var extra = xdException.ExtraData["extra"] as Dictionary<string, object>;
@@ -624,6 +702,69 @@ namespace XD.SDK.Account.Internal.Standalone
624
702
  throw e;
625
703
  }
626
704
  }
705
+
706
+ private static string SerializeComplianceExtraData(Dictionary<string, object> extraData)
707
+ {
708
+ if (extraData == null)
709
+ {
710
+ return string.Empty;
711
+ }
712
+
713
+ try
714
+ {
715
+ return JsonConvert.SerializeObject(extraData);
716
+ }
717
+ catch (Exception e)
718
+ {
719
+ return $"<serialize failed: {e.Message}>";
720
+ }
721
+ }
722
+
723
+ private static string GetComplianceUrl(Dictionary<string, object> extraData)
724
+ {
725
+ if (extraData == null)
726
+ {
727
+ return null;
728
+ }
729
+
730
+ if (TryGetString(extraData, "url", out var url))
731
+ {
732
+ return url;
733
+ }
734
+
735
+ if (extraData.TryGetValue("extra", out var extraObj) && TryGetString(extraObj, "url", out url))
736
+ {
737
+ return url;
738
+ }
739
+
740
+ return null;
741
+ }
742
+
743
+ private static bool TryGetString(object source, string key, out string value)
744
+ {
745
+ value = null;
746
+
747
+ if (source is Dictionary<string, object> dictionary
748
+ && dictionary.TryGetValue(key, out var dictionaryValue)
749
+ && dictionaryValue != null)
750
+ {
751
+ value = dictionaryValue as string ?? dictionaryValue.ToString();
752
+ return !string.IsNullOrEmpty(value);
753
+ }
754
+
755
+ if (source is JObject jObject)
756
+ {
757
+ var token = jObject[key];
758
+ if (token != null && token.Type != JTokenType.Null)
759
+ {
760
+ value = token.ToString();
761
+ return !string.IsNullOrEmpty(value);
762
+ }
763
+ }
764
+
765
+ return false;
766
+ }
767
+
627
768
  }
628
769
  }
629
- #endif
770
+ #endif
@@ -19,43 +19,61 @@ namespace XD.SDK.Account.Internal.Standalone
19
19
  {
20
20
  XDGLogger.Debug($"message from javascript by:{GetName()} with data:{data}", XDGLoggerTag.Web);
21
21
 
22
- var user = await UserModule.GetLocalUser();
23
- if (user == null || string.IsNullOrEmpty(user.UserId))
22
+ try
24
23
  {
25
- callbackFunction(new WebBridgeResponse.Failed
24
+ var localUser = await UserModule.GetLocalUser();
25
+ if (localUser == null || string.IsNullOrEmpty(localUser.UserId))
26
26
  {
27
- Msg = "current user is null"
28
- });
29
- return;
30
- }
27
+ callbackFunction(new WebBridgeResponse.Failed
28
+ {
29
+ Msg = XDGErrorExtensions.NotLoginError().ErrorMsg
30
+ });
31
+ return;
32
+ }
31
33
 
32
- var result = new Dictionary<string, object>
33
- {
34
- { "userId", user.UserId },
35
- { "username", user.UserName },
36
- { "loginTypeEntryName", user.LoginTypeName },
37
- { "loginList", user.BoundAccounts ?? new List<string>() },
38
- { "nickName", user.NickName },
39
- { "avatar", user.Avatar }
40
- };
34
+ var user = await UserModule.FetchUserInfo();
35
+ var result = new Dictionary<string, object>
36
+ {
37
+ { "userId", user.UserId },
38
+ { "username", user.UserName },
39
+ { "loginTypeEntryName", user.LoginTypeName },
40
+ { "loginList", user.BoundAccounts ?? new List<string>() },
41
+ { "nickName", user.NickName },
42
+ { "avatar", user.Avatar }
43
+ };
44
+
45
+ var token = await AccessTokenModule.GetLocalAccessToken();
46
+ if (token != null)
47
+ {
48
+ result["accessToken"] = new Dictionary<string, object>
49
+ {
50
+ { "kid", token.Kid },
51
+ { "macKey", token.MacKey },
52
+ { "macAlgorithm", token.MacAlgorithm },
53
+ { "tokenType", token.TokenType },
54
+ { "expireIn", token.ExpireIn }
55
+ };
56
+ }
41
57
 
42
- var token = await AccessTokenModule.GetLocalAccessToken();
43
- if (token != null)
58
+ callbackFunction(new WebBridgeResponse.Success
59
+ {
60
+ Data = result
61
+ });
62
+ }
63
+ catch (XDGError e)
44
64
  {
45
- result["accessToken"] = new Dictionary<string, object>
65
+ callbackFunction(new WebBridgeResponse.Failed
46
66
  {
47
- { "kid", token.Kid },
48
- { "macKey", token.MacKey },
49
- { "macAlgorithm", token.MacAlgorithm },
50
- { "tokenType", token.TokenType },
51
- { "expireIn", token.ExpireIn }
52
- };
67
+ Msg = e.ErrorMsg
68
+ });
53
69
  }
54
-
55
- callbackFunction(new WebBridgeResponse.Success
70
+ catch (Exception e)
56
71
  {
57
- Data = result
58
- });
72
+ callbackFunction(new WebBridgeResponse.Failed
73
+ {
74
+ Msg = e.Message
75
+ });
76
+ }
59
77
  }
60
78
  }
61
79
  }
@@ -4,7 +4,7 @@
4
4
  "references": [
5
5
  "XD.SDK.Common",
6
6
  "XD.SDK.Foundation",
7
- "Vuplex.WebView",
7
+ "XD.SDK.WebView",
8
8
  "Unity.TextMeshPro",
9
9
  "TapTap.Common.Runtime",
10
10
  "TapTap.Login.Runtime"
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.7.0",
4
+ "version": "7.8.0",
5
5
  "description": "XDGSDK",
6
6
  "unity": "2019.3",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.xd.sdk.common": "7.7.0"
9
+ "com.xd.sdk.common": "7.8.0"
10
10
  }
11
11
  }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 2e63b267153141939359668e82217cb0
3
- timeCreated: 1752580026