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
@@ -0,0 +1,88 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+ using System;
3
+ using System.Threading.Tasks;
4
+ using XD.SDK.Common;
5
+ using XD.SDK.Common.Internal.Standalone;
6
+
7
+ namespace XD.SDK.Account.Internal.Standalone
8
+ {
9
+ internal static class XDComplianceWebOpener
10
+ {
11
+ private static TaskCompletionSource<XDComplianceCloseResult> _currentTcs;
12
+
13
+ internal static bool IsActive => _currentTcs != null;
14
+
15
+ internal static Task<XDComplianceCloseResult> OpenAsync(string url)
16
+ {
17
+ var tcs = new TaskCompletionSource<XDComplianceCloseResult>();
18
+
19
+ if (string.IsNullOrEmpty(url))
20
+ {
21
+ XDGLogger.Warn("[Compliance] complianceUrl is empty, treat as cancelled.", XDGLoggerTag.Account);
22
+ tcs.SetResult(new XDComplianceCloseResult());
23
+ return tcs.Task;
24
+ }
25
+
26
+ _currentTcs = tcs;
27
+ XDGLogger.Debug($"[Compliance] Open compliance web: {url}", XDGLoggerTag.Account);
28
+
29
+ #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
30
+ try
31
+ {
32
+ XDGCommon.OpenWebPage(url, (action, data) =>
33
+ {
34
+ if (action != WebActionEnum.CLOSE)
35
+ {
36
+ return;
37
+ }
38
+
39
+ Complete(tcs, XDComplianceCloseResult.Parse(data));
40
+ });
41
+ }
42
+ catch (Exception e)
43
+ {
44
+ XDGLogger.Warn($"[Compliance] Open compliance web failed: {e.Message}", XDGLoggerTag.Account);
45
+ Complete(tcs, new XDComplianceCloseResult { Reason = "webview_open_failed" });
46
+ }
47
+ #else
48
+ XDGLogger.Warn("[Compliance] WebView is unavailable, compliance web cannot be opened.",
49
+ XDGLoggerTag.Account);
50
+ Complete(tcs, new XDComplianceCloseResult { Reason = "webview_unavailable" });
51
+ #endif
52
+
53
+ return tcs.Task;
54
+ }
55
+
56
+ internal static void TryClose()
57
+ {
58
+ var tcs = _currentTcs;
59
+ if (tcs == null)
60
+ {
61
+ return;
62
+ }
63
+
64
+ try
65
+ {
66
+ UIManager.Dismiss();
67
+ }
68
+ catch (Exception e)
69
+ {
70
+ XDGLogger.Warn($"[Compliance] Close compliance web failed: {e.Message}", XDGLoggerTag.Account);
71
+ }
72
+
73
+ Complete(tcs, new XDComplianceCloseResult { Reason = "user_canceled" });
74
+ }
75
+
76
+ private static void Complete(TaskCompletionSource<XDComplianceCloseResult> tcs, XDComplianceCloseResult result)
77
+ {
78
+ if (_currentTcs != tcs)
79
+ {
80
+ return;
81
+ }
82
+
83
+ _currentTcs = null;
84
+ tcs.TrySetResult(result);
85
+ }
86
+ }
87
+ }
88
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 0cad8e1cd5a44ab3bd5c0e93b504da40
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Threading.Tasks;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Threading.Tasks;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Threading.Tasks;
@@ -9,6 +9,9 @@ using UnityEngine;
9
9
  using XD.SDK.Common;
10
10
  using XD.SDK.Common.Internal;
11
11
  using XD.SDK.Common.Internal.Standalone;
12
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
13
+ using XD.SDK.WebView;
14
+ #endif
12
15
 
13
16
  namespace XD.SDK.Account.Internal.Standalone
14
17
  {
@@ -75,25 +78,32 @@ namespace XD.SDK.Account.Internal.Standalone
75
78
 
76
79
  if (xd)
77
80
  {
78
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
79
- WebRequest.OpenWebPage(url, (code, data) =>
81
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
82
+ if (XDWebViewService.IsAvailable)
80
83
  {
81
-
82
- });
83
- #else
84
- Application.OpenURL(url);
84
+ WebRequest.OpenWebPage(url, (code, data) =>
85
+ {
86
+ });
87
+ return;
88
+ }
89
+
90
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Support);
85
91
  #endif
86
92
  }
87
- else
88
- {
89
- Application.OpenURL(url);
90
- }
93
+
94
+ Application.OpenURL(url);
91
95
  });
92
96
  }
93
97
 
94
98
  private static async void CheckUnRead()
95
99
  {
96
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
100
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
101
+ if (!XDWebViewService.IsAvailable)
102
+ {
103
+ XDGLogger.Error("[XDSDK WebView] XDWebViewService.Provider is not registered. Please check whether XD.SDK.WebView.Vuplex is included and preserved in the build.", XDGLoggerTag.Support);
104
+ return;
105
+ }
106
+
97
107
  XDGLogger.Debug("Support check unread", XDGLoggerTag.Support);
98
108
  try
99
109
  {
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using TMPro;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Linq;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using UnityEngine;
4
4
  using UnityEngine.UI;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Linq;
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Threading.Tasks;
4
4
  using System.Collections.Generic;
@@ -7,7 +7,7 @@ using System.Net.Sockets;
7
7
  using Newtonsoft.Json;
8
8
  using UnityEngine;
9
9
  using UnityEngine.UI;
10
- using Vuplex.WebView;
10
+ using XD.SDK.WebView;
11
11
  using XD.SDK.Common;
12
12
  using XD.SDK.Common.Internal.Standalone;
13
13
 
@@ -18,11 +18,15 @@ namespace XD.SDK.Account.Internal.Standalone
18
18
  public const int CONTROL_DONE_CODE = 0;
19
19
  public const int CLOSE_CODE = -1;
20
20
  public const int BACK_CODE = 1;
21
+ private const float RequestLoadingTimeoutSeconds = 30f;
22
+ private const float WebLoadingTimeoutSeconds = 5f;
21
23
 
22
24
  private Button backButton;
23
25
  private Button closeButton;
24
26
 
25
- private CanvasWebViewPrefab canvasWebViewPrefab;
27
+ private IXDWebViewPanel webViewPanel;
28
+ private bool closeCallbackEmitted;
29
+ private bool controlRequestInProgress;
26
30
 
27
31
  public static async Task<int> Control(Func<string, Task<RequestVerifyCodeData>> requestVerifyCodeFunc)
28
32
  {
@@ -31,7 +35,7 @@ namespace XD.SDK.Account.Internal.Standalone
31
35
  TaskCompletionSource<int> tcs = new TaskCompletionSource<int>();
32
36
  try
33
37
  {
34
- UIManager.ShowLoading(true);
38
+ UIManager.ShowLoading(true, RequestLoadingTimeoutSeconds);
35
39
  RequestVerifyCodeData verifyCodeData = await requestVerifyCodeFunc(riskControlData);
36
40
  tcs.TrySetResult(verifyCodeData.ReSendInterval);
37
41
  }
@@ -56,32 +60,54 @@ namespace XD.SDK.Account.Internal.Standalone
56
60
  riskControlData = data as string;
57
61
  try
58
62
  {
59
- UIManager.ShowLoading();
63
+ UIManager.ShowLoading(timeout: RequestLoadingTimeoutSeconds);
60
64
  RequestVerifyCodeData result = await requestVerifyCodeFunc(riskControlData);
65
+ if (!alert.TryClose())
66
+ {
67
+ return;
68
+ }
69
+
70
+ UIManager.Dismiss();
61
71
  tcs.TrySetResult(result.ReSendInterval);
62
72
  }
63
73
  catch (XDGError ex)
64
74
  {
75
+ if (alert.IsClosed)
76
+ {
77
+ return;
78
+ }
79
+
65
80
  UIManager.DismissLoading();
66
81
  if (ex.Code == PhoneModule.RISK_CONTROL)
67
82
  {
68
83
  // 触发风控
69
84
  await alert.Reload();
85
+ alert.ResetControlRequest();
70
86
  }
71
87
  else if (ex.Code == PhoneModule.RISK_CONTROL_FAILED)
72
88
  {
73
89
  // 滑动验证失败
74
90
  await alert.Reload();
91
+ alert.ResetControlRequest();
75
92
  UIManager.ShowToast(ex.ErrorMsg);
76
93
  }
77
94
  else
78
95
  {
96
+ if (!alert.TryClose())
97
+ {
98
+ return;
99
+ }
100
+
101
+ UIManager.Dismiss();
79
102
  tcs.TrySetException(ex);
80
103
  }
81
104
  }
82
105
  finally
83
106
  {
84
- UIManager.DismissLoading();
107
+ if (!alert.IsClosed)
108
+ {
109
+ UIManager.DismissLoading();
110
+ }
85
111
  }
86
112
  }
87
113
  });
@@ -106,9 +132,9 @@ namespace XD.SDK.Account.Internal.Standalone
106
132
  private void Awake()
107
133
  {
108
134
  Transform webviewContainer = transform.Find("WebViewContainer");
109
- canvasWebViewPrefab = CanvasWebViewPrefab.Instantiate();
110
- canvasWebViewPrefab.transform.SetParent(webviewContainer);
111
- RectTransform rectTransform = canvasWebViewPrefab.GetComponent<RectTransform>();
135
+ webViewPanel = XDWebViewService.Provider.CreatePanel();
136
+ webViewPanel.GameObject.transform.SetParent(webviewContainer);
137
+ RectTransform rectTransform = webViewPanel.GameObject.GetComponent<RectTransform>();
112
138
  rectTransform.offsetMin = Vector2.zero;
113
139
  rectTransform.offsetMax = Vector2.zero;
114
140
 
@@ -121,20 +147,19 @@ namespace XD.SDK.Account.Internal.Standalone
121
147
 
122
148
  private async void Start()
123
149
  {
124
- UIManager.ShowLoading();
150
+ UIManager.ShowLoading(timeout: WebLoadingTimeoutSeconds);
125
151
 
126
- await canvasWebViewPrefab.WaitUntilInitialized();
152
+ await webViewPanel.WaitUntilInitialized();
127
153
 
128
- canvasWebViewPrefab.DragMode = DragMode.DragWithinPage;
154
+ webViewPanel.DragMode = XDWebViewDragMode.DragWithinPage;
129
155
 
130
- canvasWebViewPrefab.WebView.MessageEmitted += (sender, eventArgs) =>
156
+ webViewPanel.WebView.MessageEmitted += (sender, message) =>
131
157
  {
132
- XDGLogger.Debug(eventArgs.Value, XDGLoggerTag.Web);
133
- Dictionary<string, string> response = JsonConvert.DeserializeObject<Dictionary<string, string>>(eventArgs.Value);
158
+ XDGLogger.Debug(message, XDGLoggerTag.Web);
159
+ Dictionary<string, string> response = JsonConvert.DeserializeObject<Dictionary<string, string>>(message);
134
160
  Dictionary<string, object> data = JsonConvert.DeserializeObject<Dictionary<string, object>>(response["message"]);
135
161
  string riskControlData = JsonConvert.SerializeObject(data["data"]);
136
162
  XDGLogger.Debug(riskControlData, XDGLoggerTag.Web);
137
- UIManager.Dismiss();
138
163
 
139
164
  OnCallback(CONTROL_DONE_CODE, riskControlData);
140
165
  };
@@ -172,25 +197,30 @@ namespace XD.SDK.Account.Internal.Standalone
172
197
 
173
198
  private async Task Reload()
174
199
  {
175
- UIManager.ShowLoading();
200
+ UIManager.ShowLoading(timeout: WebLoadingTimeoutSeconds);
176
201
  var ip = GetIP();
177
- canvasWebViewPrefab.WebView.LoadUrl(
202
+ webViewPanel.WebView.LoadUrl(
178
203
  $"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()}");
179
- await canvasWebViewPrefab.WebView.WaitForNextPageLoadToFinish();
180
- // 注入 js
181
- _ = canvasWebViewPrefab.WebView.ExecuteJavaScript(@";(function (window) {
204
+ try
205
+ {
206
+ await webViewPanel.WebView.WaitForNextPageLoadToFinish();
207
+ // 注入 js
208
+ _ = webViewPanel.WebView.ExecuteJavaScript(@";(function (window) {
182
209
  window._xd_jsbridge = {
183
210
  invoke: function (json) {
184
211
  try {
185
- window.vuplex.postMessage({ type: 'verify', message: json });
212
+ " + XDWebViewService.Provider.JsPostMessageFunction + @"({ type: 'verify', message: json });
186
213
  } catch (error) {
187
214
  console.error('xd-jsbridge error::', error)
188
215
  }
189
216
  },
190
217
  };
191
218
  })(window);");
192
-
193
- UIManager.DismissLoading();
219
+ }
220
+ finally
221
+ {
222
+ UIManager.DismissLoading();
223
+ }
194
224
  }
195
225
 
196
226
  private string Platform
@@ -224,7 +254,49 @@ namespace XD.SDK.Account.Internal.Standalone
224
254
  OnCallback(CLOSE_CODE, null);
225
255
  }
226
256
 
257
+ protected override void OnCallback(int code, object data)
258
+ {
259
+ if (code == CLOSE_CODE || code == BACK_CODE)
260
+ {
261
+ if (!TryClose())
262
+ {
263
+ return;
264
+ }
265
+ }
266
+ else if (code == CONTROL_DONE_CODE)
267
+ {
268
+ if (closeCallbackEmitted || controlRequestInProgress)
269
+ {
270
+ return;
271
+ }
272
+
273
+ controlRequestInProgress = true;
274
+ UIManager.DismissLoading();
275
+ }
276
+
277
+ base.OnCallback(code, data);
278
+ }
279
+
280
+ private void ResetControlRequest()
281
+ {
282
+ controlRequestInProgress = false;
283
+ }
284
+
285
+ private bool TryClose()
286
+ {
287
+ if (closeCallbackEmitted)
288
+ {
289
+ return false;
290
+ }
291
+
292
+ closeCallbackEmitted = true;
293
+ UIManager.DismissLoading();
294
+ return true;
295
+ }
296
+
297
+ private bool IsClosed => closeCallbackEmitted;
298
+
227
299
  #endregion
228
300
  }
229
301
  }
230
- #endif
302
+ #endif
@@ -1,4 +1,4 @@
1
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
1
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
2
2
  using System;
3
3
  using System.Threading.Tasks;
4
4
  using System.Collections;