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
@@ -11,9 +11,7 @@ namespace XD.SDK.Account.Editor
11
11
  var sdkVersion = VersionCatalog.XDAndroidSdkVersion;
12
12
  var result = new List<AndroidGradleProjectConfig.Dependency>
13
13
  {
14
- new AndroidGradleProjectConfig.Dependency(group: "com.xd.sdk.android", module: "account-bridge",
15
- version: sdkVersion),
16
- new AndroidGradleProjectConfig.Dependency(group: "com.xd.sdk.android", module: "support",
14
+ new AndroidGradleProjectConfig.Dependency(group: "com.xd.sdk.android", module: "account",
17
15
  version: sdkVersion),
18
16
  };
19
17
 
@@ -4,6 +4,6 @@
4
4
  //
5
5
  // Created by Fattycat on 2023/4/14.
6
6
  //
7
- #define XDGAccount_VERSION @"7.7.0"
8
- #define XDSAccount_VERSION_CODE @"7070000"
9
- // HASH a8b1407f
7
+ #define XDGAccount_VERSION @"7.8.0"
8
+ #define XDSAccount_VERSION_CODE @"7080000"
9
+ // HASH 0094cc326
@@ -8,6 +8,9 @@ using UnityEngine;
8
8
  using XD.SDK.Common;
9
9
  using XD.SDK.Common.Internal;
10
10
  using XD.SDK.Common.Internal.Standalone;
11
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
12
+ using XD.SDK.WebView;
13
+ #endif
11
14
 
12
15
 
13
16
  namespace XD.SDK.Account.Internal.Standalone
@@ -116,9 +119,10 @@ namespace XD.SDK.Account.Internal.Standalone
116
119
  if (xdException.Code == ResponseCode.Account.TokenExpired || xdException.HttpStatusCode == 401)
117
120
  errorMsg = "XD_TOKEN_EXPIRED";
118
121
  // 触发风控以及登陆频繁不需要发送 PreFail
119
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
120
- if (xdException.Code != PhoneModule.INVALID_VERIFY_CODE &&
121
- xdException.Code != PhoneModule.LOGIN_REQUEST_FREQUENTLY)
122
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
123
+ if (!XDWebViewService.IsAvailable ||
124
+ (xdException.Code != PhoneModule.INVALID_VERIFY_CODE &&
125
+ xdException.Code != PhoneModule.LOGIN_REQUEST_FREQUENTLY))
122
126
  {
123
127
  AliyunTrack.LoginPreFail(errorMsg);
124
128
  }
@@ -11,6 +11,9 @@ using XD.SDK.Common;
11
11
  using XD.SDK.Common.Internal;
12
12
  using XD.SDK.Common.Internal.Events;
13
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
14
17
  using Random = System.Random;
15
18
 
16
19
  namespace XD.SDK.Account.Internal.Standalone
@@ -20,6 +23,8 @@ namespace XD.SDK.Account.Internal.Standalone
20
23
  private static AccountFeaturesImpl _instance;
21
24
 
22
25
  private static readonly object LockObj = new object();
26
+ private const string GlobalComplianceLogout = "GLOBAL_COMPLIANCE_LOGOUT";
27
+ private const string GlobalComplianceExit = "GLOBAL_COMPLIANCE_EXIT";
23
28
 
24
29
  public static AccountFeaturesImpl Instance
25
30
  {
@@ -117,7 +122,7 @@ namespace XD.SDK.Account.Internal.Standalone
117
122
 
118
123
  public async void OpenUserDashboard(XDGRoleInfo roleInfo)
119
124
  {
120
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
125
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
121
126
  try
122
127
  {
123
128
  if (!XDGCommonInternal.IsCn())
@@ -134,6 +139,12 @@ namespace XD.SDK.Account.Internal.Standalone
134
139
  return;
135
140
  }
136
141
 
142
+ if (!XDWebViewService.IsAvailable)
143
+ {
144
+ 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);
145
+ return;
146
+ }
147
+
137
148
  Dictionary<string, object> authData = new Dictionary<string, object>()
138
149
  { { "scope", UserModule.CodeScope.USER_INFO } };
139
150
  try
@@ -239,15 +250,12 @@ namespace XD.SDK.Account.Internal.Standalone
239
250
 
240
251
  // 登录埋点
241
252
  AliyunTrack.LoginStart(loginType.ToString());
253
+ XDCompliance.LogoutHandler = needNotify => InternalLogout(GlobalComplianceExit, needNotify);
242
254
  try
243
255
  {
244
256
  var user = await UserModule.Login(loginType);
245
257
  AliyunTrack.LoginAntiAddictionStartup();
246
258
  var complianceResult = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKComplianceStartup, ConfigModule.IsGlobal, user.UserId);
247
- // TODO 统一走回调进行埋点
248
- // AliyunTrack.LoginAntiAddictionResult(XDDictionary.GetValue(complianceResult, "code", -100),
249
- // XDDictionary.GetValue<string>(complianceResult, "reason"),
250
- // XDDictionary.GetValue<string>(complianceResult, "extras"));
251
259
  var compliance = complianceResult.GetValueOrDefault();
252
260
  if (XDDictionary.GetValue<bool>(compliance, "success"))
253
261
  {
@@ -261,7 +269,11 @@ namespace XD.SDK.Account.Internal.Standalone
261
269
  }
262
270
  catch (XDHttpException e)
263
271
  {
264
- if ((e.HttpStatusCode == 401 && loginType == LoginType.Default) || e.Code == 40311 || e.Code == 40312)
272
+ if (XDCompliance.IsRequired(e))
273
+ {
274
+ InternalLogout(GlobalComplianceLogout, false);
275
+ }
276
+ else if ((e.HttpStatusCode == 401 && loginType == LoginType.Default) || e.Code == 40311 || e.Code == 40312)
265
277
  {
266
278
  InternalLogout("LOGOUT_API", false);
267
279
  }
@@ -272,6 +284,18 @@ namespace XD.SDK.Account.Internal.Standalone
272
284
  AliyunTrack.LoginFail(errorMsg);
273
285
  throw;
274
286
  }
287
+ catch (XDComplianceException e)
288
+ {
289
+ var originalException = e.OriginalException;
290
+ AliyunTrack.LoginFail(originalException?.Message ?? e.ErrorMsg);
291
+ InternalLogout(GlobalComplianceLogout, false);
292
+ if (originalException != null)
293
+ {
294
+ throw originalException;
295
+ }
296
+
297
+ throw;
298
+ }
275
299
  catch (Exception e)
276
300
  {
277
301
  if (e is XDGError error)
@@ -293,16 +317,26 @@ namespace XD.SDK.Account.Internal.Standalone
293
317
  // SDK 登陆成功
294
318
  AliyunTrack.LoginLogout(logoutType);
295
319
 
296
- ClearUserCache();
320
+ var preserveAgreement = logoutType == GlobalComplianceLogout
321
+ || logoutType == GlobalComplianceExit;
322
+ ClearUserCache(preserveAgreement);
297
323
 
298
324
  XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
299
325
  XDGEventBus.Publish(XDGEvents.TapSDKLogout);
300
- if (logoutType != "SWITCH_ACCOUNT" && logoutType != "COMPLIANCE_EXIT")
326
+ if (logoutType != "SWITCH_ACCOUNT"
327
+ && logoutType != "COMPLIANCE_EXIT"
328
+ && logoutType != GlobalComplianceLogout
329
+ && logoutType != GlobalComplianceExit)
301
330
  {
302
331
  XDGEventBus.Publish(XDGEvents.TapSDKComplianceExit, ConfigModule.IsGlobal);
303
332
  }
304
333
 
305
- if (bShowAgreement)
334
+ if (logoutType != "COMPLIANCE_EXIT" && logoutType != GlobalComplianceExit)
335
+ {
336
+ XDCompliance.Stop();
337
+ }
338
+
339
+ if (bShowAgreement && !preserveAgreement)
306
340
  {
307
341
  _ = AgreementModule.ConfirmAgreement().ContinueWith(t =>
308
342
  {
@@ -322,16 +356,19 @@ namespace XD.SDK.Account.Internal.Standalone
322
356
  }
323
357
  }
324
358
 
325
- private static void ClearUserCache()
359
+ private static void ClearUserCache(bool preserveAgreement = false)
326
360
  {
327
361
  AccessTokenModule.ClearToken();
328
362
  UserModule.ClearUserData();
329
- AgreementModule.ClearLocalSignedAgreements();
363
+ if (!preserveAgreement)
364
+ {
365
+ AgreementModule.ClearLocalSignedAgreements();
366
+ }
330
367
  }
331
368
 
332
369
  private async Task CancelAccount()
333
370
  {
334
- #if (UNITY_STANDALONE || (UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS)) && !XDSDK_DISABLE_VUPLEX
371
+ #if ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) || ((UNITY_EDITOR_WIN || UNITY_EDITOR_OSX) && !UNITY_ANDROID && !UNITY_IOS))
335
372
  var current = UserModule.current;
336
373
  if (current == null)
337
374
  {
@@ -347,6 +384,12 @@ namespace XD.SDK.Account.Internal.Standalone
347
384
  return;
348
385
  }
349
386
 
387
+ if (!XDWebViewService.IsAvailable)
388
+ {
389
+ 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);
390
+ return;
391
+ }
392
+
350
393
  try
351
394
  {
352
395
  UIManager.ShowLoading();
@@ -475,4 +518,4 @@ namespace XD.SDK.Account.Internal.Standalone
475
518
  }
476
519
  }
477
520
  }
478
- #endif
521
+ #endif
@@ -22,11 +22,21 @@ namespace XD.SDK.Account.Internal.Standalone
22
22
  internal static string TryGetRedirectScheme()
23
23
  {
24
24
  #if UNITY_STANDALONE_WIN && !UNITY_EDITOR
25
- var scheme = StandaloneDeeplinkRegistrar.TryGetSchemeForCurrentGame();
26
- if (string.IsNullOrEmpty(scheme))
25
+ if (!StandaloneDeeplinkRegistrar.TryGetRegisteredScheme(out string scheme, out string reason))
27
26
  {
27
+ XDGLogger.Debug($"[DeepLink] RedirectScheme disabled. reason={reason}", XDGLoggerTag.Account);
28
28
  return null;
29
29
  }
30
+
31
+ if (!StandaloneDeepLinkReceiver.IsStarted)
32
+ {
33
+ XDGLogger.Debug(
34
+ $"[DeepLink] RedirectScheme disabled. reason=pipe receiver not started, {StandaloneDeeplinkRegistrar.GetRegistrationDiagnostic()}",
35
+ XDGLoggerTag.Account);
36
+ return null;
37
+ }
38
+
39
+ XDGLogger.Debug($"[DeepLink] RedirectScheme enabled. scheme={scheme}://", XDGLoggerTag.Account);
30
40
  return $"{scheme}://{DefaultUrlSchemePath}";
31
41
  #else
32
42
  return null;
@@ -72,7 +82,7 @@ namespace XD.SDK.Account.Internal.Standalone
72
82
  {
73
83
  if (string.IsNullOrEmpty(deepLinkUrl)) return;
74
84
 
75
- XDGLogger.Debug($"[Auth][DeepLink] url: {deepLinkUrl}", XDGLoggerTag.Account);
85
+ XDGLogger.Debug($"[Auth][DeepLink] url: {RedactAuthUrl(deepLinkUrl)}", XDGLoggerTag.Account);
76
86
 
77
87
  // 不用 new Uri(),直接截取 query,避免 Uri 对自定义 scheme 做编码归一化
78
88
  int qIdx = deepLinkUrl.IndexOf('?');
@@ -112,6 +122,7 @@ namespace XD.SDK.Account.Internal.Standalone
112
122
  {
113
123
  if (done == deepLinkTcs.Task)
114
124
  {
125
+ XDGLogger.Debug("[Auth] Callback channel: DeepLink", XDGLoggerTag.Account);
115
126
  XDGLogger.Debug("[Auth] DeepLink auth succeeded (won race)", XDGLoggerTag.Account);
116
127
  StopAllListeners();
117
128
  return await deepLinkTcs.Task;
@@ -119,6 +130,7 @@ namespace XD.SDK.Account.Internal.Standalone
119
130
 
120
131
  if (done == httpTask)
121
132
  {
133
+ XDGLogger.Debug("[Auth] Callback channel: HttpListener", XDGLoggerTag.Account);
122
134
  XDGLogger.Debug("[Auth] HTTP auth succeeded (won race)", XDGLoggerTag.Account);
123
135
  return await httpTask;
124
136
  }
@@ -144,6 +156,56 @@ namespace XD.SDK.Account.Internal.Standalone
144
156
  }
145
157
  }
146
158
  }
159
+
160
+ private static string RedactAuthUrl(string url)
161
+ {
162
+ if (string.IsNullOrEmpty(url))
163
+ {
164
+ return url;
165
+ }
166
+
167
+ int queryIndex = url.IndexOf('?');
168
+ if (queryIndex < 0 || queryIndex >= url.Length - 1)
169
+ {
170
+ return url;
171
+ }
172
+
173
+ string prefix = url.Substring(0, queryIndex + 1);
174
+ string query = url.Substring(queryIndex + 1);
175
+ string[] pairs = query.Split('&');
176
+ for (int i = 0; i < pairs.Length; i++)
177
+ {
178
+ string pair = pairs[i];
179
+ int equalIndex = pair.IndexOf('=');
180
+ if (equalIndex <= 0)
181
+ {
182
+ continue;
183
+ }
184
+
185
+ string key = pair.Substring(0, equalIndex);
186
+ if (IsSensitiveQueryKey(key))
187
+ {
188
+ pairs[i] = $"{key}=<redacted>";
189
+ }
190
+ }
191
+
192
+ return prefix + string.Join("&", pairs);
193
+ }
194
+
195
+ private static bool IsSensitiveQueryKey(string key)
196
+ {
197
+ if (string.IsNullOrEmpty(key))
198
+ {
199
+ return false;
200
+ }
201
+
202
+ return key.Equals("code", StringComparison.OrdinalIgnoreCase) ||
203
+ key.Equals("token", StringComparison.OrdinalIgnoreCase) ||
204
+ key.Equals("access_token", StringComparison.OrdinalIgnoreCase) ||
205
+ key.Equals("refresh_token", StringComparison.OrdinalIgnoreCase) ||
206
+ key.Equals("id_token", StringComparison.OrdinalIgnoreCase) ||
207
+ key.IndexOf("token", StringComparison.OrdinalIgnoreCase) >= 0;
208
+ }
147
209
  }
148
210
  }
149
- #endif
211
+ #endif
@@ -0,0 +1,129 @@
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
+ namespace XD.SDK.Account.Internal.Standalone
10
+ {
11
+ internal static class XDCompliance
12
+ {
13
+ private const int RequiredKr = 40313;
14
+ private const int RequiredGlobal = 40314;
15
+ internal static Action<bool> LogoutHandler;
16
+
17
+ private static bool _isTimeLimitDialogVisible;
18
+ private static int _timeLimitDialogVersion;
19
+
20
+ internal static bool IsRequired(int code)
21
+ {
22
+ return code == RequiredKr || code == RequiredGlobal;
23
+ }
24
+
25
+ internal static bool IsRequired(XDHttpException exception)
26
+ {
27
+ return exception != null && IsRequired(exception.Code);
28
+ }
29
+
30
+ internal static async Task RunOnLogin(string url)
31
+ {
32
+ if (!ConfigModule.IsGlobal)
33
+ {
34
+ XDGLogger.Warn("[Compliance] Compliance required code received in non-Global region. The server should only issue 40313/40314 to Global compliance clients.",
35
+ XDGLoggerTag.Account);
36
+ throw new XDComplianceException("Compliance triggered in non-Global region");
37
+ }
38
+
39
+ if (string.IsNullOrEmpty(url))
40
+ {
41
+ throw new XDComplianceException("Compliance url is empty");
42
+ }
43
+
44
+ var result = await XDComplianceWebOpener.OpenAsync(url);
45
+ if (!result.IsPassed)
46
+ {
47
+ throw new XDComplianceException(result.Reason ?? "Compliance cancelled");
48
+ }
49
+
50
+ // Web close payload only indicates whether the compliance flow passed.
51
+ // The retried /account/v2/info response is the authoritative countdown source.
52
+ }
53
+
54
+ internal static void ApplyRemainingSeconds(long? remainingSeconds)
55
+ {
56
+ XDComplianceCountdownService.Cancel();
57
+ var remaining = remainingSeconds.GetValueOrDefault(0);
58
+ if (remaining <= 0)
59
+ {
60
+ return;
61
+ }
62
+
63
+ XDComplianceCountdownService.Schedule(remaining, ShowTimeLimitDialog);
64
+ }
65
+
66
+ internal static void Stop()
67
+ {
68
+ XDComplianceCountdownService.Cancel();
69
+ _isTimeLimitDialogVisible = false;
70
+ _timeLimitDialogVersion++;
71
+ XDComplianceWebOpener.TryClose();
72
+ }
73
+
74
+ private static void ShowTimeLimitDialog()
75
+ {
76
+ if (_isTimeLimitDialogVisible)
77
+ {
78
+ return;
79
+ }
80
+
81
+ _isTimeLimitDialogVisible = true;
82
+ var dialogVersion = ++_timeLimitDialogVersion;
83
+ var localizable = XDLocalization.GetCurrentLocalizableString();
84
+ var config = new Dictionary<string, object>
85
+ {
86
+ { ConfirmDialog.TITLE_KEY, FirstNonEmpty(localizable?.CompliancePlayTimeLimitTitle, "Play Time Ended") },
87
+ { ConfirmDialog.CONTENT_KEY, FirstNonEmpty(localizable?.CompliancePlayTimeLimitContent, "This account has used up today's available play time and cannot continue playing for now.") },
88
+ { ConfirmDialog.CONFIRM_TEXT_KEY, FirstNonEmpty(localizable?.CompliancePlayTimeLimitConfirm, localizable?.IUnderstand, "OK") }
89
+ };
90
+
91
+ try
92
+ {
93
+ UIManager.ShowUI<ConfirmDialog>(config, (code, data) =>
94
+ {
95
+ var isCurrentDialog = dialogVersion == _timeLimitDialogVersion;
96
+ _isTimeLimitDialogVisible = false;
97
+ UIManager.Dismiss();
98
+ if (isCurrentDialog)
99
+ {
100
+ LogoutHandler?.Invoke(true);
101
+ }
102
+ });
103
+ }
104
+ catch (Exception e)
105
+ {
106
+ XDGLogger.Warn($"[Compliance] Show time limit dialog failed: {e.Message}", XDGLoggerTag.Account);
107
+ _isTimeLimitDialogVisible = false;
108
+ if (dialogVersion == _timeLimitDialogVersion)
109
+ {
110
+ LogoutHandler?.Invoke(true);
111
+ }
112
+ }
113
+ }
114
+
115
+ private static string FirstNonEmpty(params string[] values)
116
+ {
117
+ foreach (var value in values)
118
+ {
119
+ if (!string.IsNullOrEmpty(value))
120
+ {
121
+ return value;
122
+ }
123
+ }
124
+
125
+ return string.Empty;
126
+ }
127
+ }
128
+ }
129
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 93cd5172f2404e398f74e057d1d44007
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,43 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+ using System.Collections.Generic;
3
+
4
+ namespace XD.SDK.Account.Internal.Standalone
5
+ {
6
+ internal class XDComplianceCloseResult
7
+ {
8
+ internal int Code = 1;
9
+ internal string Reason;
10
+ internal long? RemainingSeconds;
11
+
12
+ internal bool IsPassed => Code == 0;
13
+
14
+ internal static XDComplianceCloseResult Parse(Dictionary<string, object> data)
15
+ {
16
+ var result = new XDComplianceCloseResult();
17
+ if (data == null)
18
+ {
19
+ return result;
20
+ }
21
+
22
+ if (data.TryGetValue("code", out var code) && code != null && int.TryParse(code.ToString(), out var parsedCode))
23
+ {
24
+ result.Code = parsedCode;
25
+ }
26
+
27
+ if (data.TryGetValue("reason", out var reason) && reason is string reasonString)
28
+ {
29
+ result.Reason = reasonString;
30
+ }
31
+
32
+ if (data.TryGetValue("remainingSeconds", out var remainingSeconds)
33
+ && remainingSeconds != null
34
+ && long.TryParse(remainingSeconds.ToString(), out var parsedRemainingSeconds))
35
+ {
36
+ result.RemainingSeconds = parsedRemainingSeconds;
37
+ }
38
+
39
+ return result;
40
+ }
41
+ }
42
+ }
43
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 7a0823956056460da928c003951c0f84
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,83 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+ using System;
3
+ using System.Diagnostics;
4
+ using System.Threading;
5
+ using UnityEngine;
6
+ using XD.SDK.Common;
7
+
8
+ namespace XD.SDK.Account.Internal.Standalone
9
+ {
10
+ internal class XDComplianceCountdownService : MonoBehaviour
11
+ {
12
+ private sealed class Entry
13
+ {
14
+ internal long DeadlineStopwatchTicks;
15
+ internal Action OnElapsed;
16
+ }
17
+
18
+ private static XDComplianceCountdownService _instance;
19
+ private static Entry _schedule;
20
+
21
+ [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
22
+ private static void Bootstrap()
23
+ {
24
+ if (_instance != null)
25
+ {
26
+ return;
27
+ }
28
+
29
+ var go = new GameObject("XDComplianceCountdown") { hideFlags = HideFlags.HideAndDontSave };
30
+ DontDestroyOnLoad(go);
31
+ _instance = go.AddComponent<XDComplianceCountdownService>();
32
+ }
33
+
34
+ internal static void Schedule(long seconds, Action onElapsed)
35
+ {
36
+ if (seconds <= 0 || onElapsed == null)
37
+ {
38
+ return;
39
+ }
40
+
41
+ var schedule = new Entry
42
+ {
43
+ DeadlineStopwatchTicks = Stopwatch.GetTimestamp() + seconds * Stopwatch.Frequency,
44
+ OnElapsed = onElapsed
45
+ };
46
+ Interlocked.Exchange(ref _schedule, schedule);
47
+ }
48
+
49
+ internal static void Cancel()
50
+ {
51
+ Interlocked.Exchange(ref _schedule, null);
52
+ }
53
+
54
+ private void Update()
55
+ {
56
+ var schedule = _schedule;
57
+ if (schedule == null)
58
+ {
59
+ return;
60
+ }
61
+
62
+ if (Stopwatch.GetTimestamp() < schedule.DeadlineStopwatchTicks)
63
+ {
64
+ return;
65
+ }
66
+
67
+ if (Interlocked.CompareExchange(ref _schedule, null, schedule) != schedule)
68
+ {
69
+ return;
70
+ }
71
+
72
+ try
73
+ {
74
+ schedule.OnElapsed();
75
+ }
76
+ catch (Exception e)
77
+ {
78
+ XDGLogger.Warn($"[Compliance] Countdown callback failed: {e.Message}", XDGLoggerTag.Account);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 1d0c20acb781416e91db9f03f4ccb553
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,29 @@
1
+ #if UNITY_EDITOR || UNITY_STANDALONE
2
+ using System;
3
+ using XD.SDK.Common;
4
+
5
+ namespace XD.SDK.Account.Internal.Standalone
6
+ {
7
+ internal class XDComplianceException : XDGError
8
+ {
9
+ internal Exception OriginalException { get; }
10
+
11
+ internal XDComplianceException(string message)
12
+ : base(ResponseCode.Common.Cancelled, message)
13
+ {
14
+ }
15
+
16
+ internal XDComplianceException(XDGError exception)
17
+ : base(exception.Code, exception.ErrorMsg, exception.Detail, exception.ExtraData)
18
+ {
19
+ OriginalException = exception;
20
+ }
21
+
22
+ internal XDComplianceException(Exception exception)
23
+ : base(ResponseCode.Common.Failed, exception.Message)
24
+ {
25
+ OriginalException = exception;
26
+ }
27
+ }
28
+ }
29
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: aa95d3b4be1d45579e68fc24b47a69ab
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: