com.taptap.sdk.compliance 4.6.2 → 4.6.3
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.
- package/Mobile/Editor/NativeDependencies.xml +2 -2
- package/Runtime/Public/TapTapCompliance.cs +1 -2
- package/Standalone/Runtime/ComplianceWorker.cs +16 -87
- package/Standalone/Runtime/Internal/ComplianceNewJob.cs +26 -13
- package/Standalone/Runtime/Internal/Model/Verification.cs +27 -27
- package/Standalone/Runtime/Internal/TapTapComplianceManager.cs +15 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceIDInputController.cs +5 -2
- package/Standalone/Runtime/Internal/Verification.cs +86 -94
- package/Standalone/Runtime/Internal/Worker/BaseComplianceWorker.cs +44 -20
- package/link.xml.meta +4 -0
- package/package.json +3 -3
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
6
|
</repositories>
|
|
7
|
-
<androidPackage spec="com.taptap.sdk:tap-compliance:4.6.
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-compliance:4.6.3"/>
|
|
8
8
|
</androidPackages>
|
|
9
9
|
<iosPods>
|
|
10
10
|
<sources>
|
|
11
11
|
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
12
12
|
</sources>
|
|
13
|
-
<iosPod name="TapTapComplianceSDK" version="~> 4.
|
|
13
|
+
<iosPod name="TapTapComplianceSDK" version="~> 4.6.3" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
14
14
|
</iosPods>
|
|
15
15
|
</dependencies>
|
|
@@ -9,8 +9,7 @@ namespace TapSDK.Compliance
|
|
|
9
9
|
|
|
10
10
|
public static class TapTapCompliance
|
|
11
11
|
{
|
|
12
|
-
|
|
13
|
-
public static readonly string Version = "4.6.2";
|
|
12
|
+
public static readonly string Version = "4.6.3";
|
|
14
13
|
|
|
15
14
|
public static void RegisterComplianceCallback(Action<int, string> callback)
|
|
16
15
|
{
|
|
@@ -36,10 +36,8 @@ namespace TapSDK.Compliance
|
|
|
36
36
|
/// <summary>
|
|
37
37
|
/// 激活手动认证
|
|
38
38
|
/// </summary>
|
|
39
|
-
|
|
40
|
-
protected override async Task VerifyManuallyAsync(bool activelyVerifyManually)
|
|
39
|
+
protected override async Task VerifyManuallyAsync()
|
|
41
40
|
{
|
|
42
|
-
var userId = TapTapComplianceManager.UserId;
|
|
43
41
|
do
|
|
44
42
|
{
|
|
45
43
|
try
|
|
@@ -109,7 +107,7 @@ namespace TapSDK.Compliance
|
|
|
109
107
|
// 计算时间
|
|
110
108
|
DateTimeOffset gameEndTime = Config.StrictEndTime;
|
|
111
109
|
DateTimeOffset now = DateTimeOffset.FromUnixTimeSeconds(GetCurrentTime()).ToOffset(DateTimeOffset.Now.Offset);
|
|
112
|
-
TimeSpan remain = gameEndTime - now;
|
|
110
|
+
TimeSpan remain = gameEndTime.TimeOfDay - now.TimeOfDay;
|
|
113
111
|
|
|
114
112
|
return new PlayableResult
|
|
115
113
|
{
|
|
@@ -194,7 +192,7 @@ namespace TapSDK.Compliance
|
|
|
194
192
|
try {
|
|
195
193
|
VerificationResult result = await Verification.FetchVerificationByTapToken(userId,accessToken);
|
|
196
194
|
UIManager.Instance.CloseLoading();
|
|
197
|
-
if(result.Status != null && result.
|
|
195
|
+
if(result.Status != null && !result.IsVerifyFailed){
|
|
198
196
|
tcs.TrySetResult(0);
|
|
199
197
|
}else{
|
|
200
198
|
tcs.TrySetResult(-1);
|
|
@@ -230,10 +228,10 @@ namespace TapSDK.Compliance
|
|
|
230
228
|
if(holidays.Contains(currentDate)){
|
|
231
229
|
DateTimeOffset strictStart = Config.StrictStartTime;
|
|
232
230
|
DateTimeOffset strictEnd = Config.StrictEndTime;
|
|
233
|
-
|
|
234
231
|
bool playable;
|
|
235
|
-
TapLogger.Debug(" now = " + now + " ,start = " + strictStart + ", end = " + strictEnd);
|
|
236
|
-
playable = now >= strictStart && now < strictEnd;
|
|
232
|
+
TapLogger.Debug(" now = " + now.TimeOfDay + " ,start = " + strictStart.TimeOfDay + ", end = " + strictEnd.TimeOfDay);
|
|
233
|
+
playable = now.TimeOfDay >= strictStart.TimeOfDay && now.TimeOfDay < strictEnd.TimeOfDay;
|
|
234
|
+
TapLogger.Debug("check result = " + playable);
|
|
237
235
|
return playable;
|
|
238
236
|
}
|
|
239
237
|
return false;
|
|
@@ -251,7 +249,6 @@ namespace TapSDK.Compliance
|
|
|
251
249
|
/// <summary>
|
|
252
250
|
/// 打开中国实名制窗口
|
|
253
251
|
/// </summary>
|
|
254
|
-
/// <param name="activelyVerifyManually">是否为主动选择激活手动认证</param>
|
|
255
252
|
/// <returns></returns>
|
|
256
253
|
private Task<VerificationResult> OpenVerificationPanelCn()
|
|
257
254
|
{
|
|
@@ -306,13 +303,15 @@ namespace TapSDK.Compliance
|
|
|
306
303
|
TapLogger.Debug("[TapTap: ChinaCompliance] 获得登录Access Token!Token结果: {0}\n是否包括Compliance: {1}",
|
|
307
304
|
accessToken.ToJson(), HaveComplianceScope(accessToken));
|
|
308
305
|
if (HaveComplianceScope(accessToken)) {
|
|
309
|
-
// 0-正常;1
|
|
306
|
+
// 0-正常;1-异常;-1-实名失败
|
|
310
307
|
var fetchResult = await FetchByTapToken(userId, accessToken);
|
|
311
|
-
if (fetchResult
|
|
312
|
-
|
|
308
|
+
if (fetchResult != 0 ) {
|
|
309
|
+
/// 异常问题
|
|
310
|
+
if (fetchResult == 1)
|
|
311
|
+
{
|
|
312
|
+
UIManager.Instance.OpenToast("授权异常", UIManager.GeneralToastLevel.Error);
|
|
313
|
+
}
|
|
313
314
|
mannualVerify = 2;
|
|
314
|
-
}else if (fetchResult == -1) {
|
|
315
|
-
mannualVerify = 2;
|
|
316
315
|
}
|
|
317
316
|
}
|
|
318
317
|
else {
|
|
@@ -360,7 +359,7 @@ namespace TapSDK.Compliance
|
|
|
360
359
|
// 手动认证
|
|
361
360
|
if (mannualVerify != 0) {
|
|
362
361
|
try {
|
|
363
|
-
await VerifyManuallyAsync(
|
|
362
|
+
await VerifyManuallyAsync();
|
|
364
363
|
}
|
|
365
364
|
catch (TaskCanceledException) {
|
|
366
365
|
TapLogger.Debug("[TapTap: ChinaCompliance] 手动实名制过程中主动退出! 触发 TaskCanceledException");
|
|
@@ -368,82 +367,12 @@ namespace TapSDK.Compliance
|
|
|
368
367
|
return tcs.Task.Result;
|
|
369
368
|
}
|
|
370
369
|
}
|
|
371
|
-
|
|
372
|
-
try {
|
|
373
|
-
var tempResult = await ValidateVerification(showPopupInVerification);
|
|
374
|
-
tcs.TrySetResult(tempResult);
|
|
375
|
-
bool isVerified = tempResult == 0;
|
|
376
|
-
if (isVerified && mannualVerify == 0) {
|
|
377
|
-
ShowVerifiedToast();
|
|
378
|
-
}
|
|
379
|
-
//认证失败:前置无弹窗的话,回调取消;前置有弹窗,保持弹窗
|
|
380
|
-
else if (tempResult == -3) {
|
|
381
|
-
if (showPopupInVerification) {
|
|
382
|
-
tcs.TrySetResult(await GetVerificationResult(userId));
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
TapLogger.Debug("[TapTap: ChinaCompliance] 认证失败,并且没有前置弹窗,直接触发取消回调! 触发 TaskCanceledException");
|
|
386
|
-
tcs.TrySetResult(StartUpResult.REAL_NAME_STOP);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
catch (TaskCanceledException) {
|
|
391
|
-
TapLogger.Debug("[TapTap: ChinaCompliance] 手动实名制过程中主动退出! 触发 TaskCanceledException");
|
|
392
|
-
tcs.TrySetResult(StartUpResult.REAL_NAME_STOP);
|
|
393
|
-
}
|
|
394
|
-
catch (Exception e) {
|
|
395
|
-
tcs.TrySetException(e);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return tcs.Task.Result;
|
|
370
|
+
return Verification.IsVerified ? 0 : await ShowVerifingTip();
|
|
399
371
|
}
|
|
400
372
|
|
|
401
|
-
/// <summary>
|
|
402
|
-
/// 验证已经获取到的 Verification 是否有效,如果有效,则直接返回;如果无效,则弹出相应的提示
|
|
403
|
-
/// </summary>
|
|
404
|
-
/// <param name="havePopupBefore">前置是否有弹窗</param>
|
|
405
|
-
/// <returns>-1:认证中;-2:实名信息为空;-3:认证未通过;0-认证成功</returns>
|
|
406
|
-
private async Task<int> ValidateVerification(bool havePopupBefore) {
|
|
407
|
-
var tcs = new TaskCompletionSource<int>();
|
|
408
|
-
if (Verification.Current == null) {
|
|
409
|
-
TapLogger.Error("[TapTap: ChinaCompliance] 已经获取过实名信息,但是到了验证阶段实名信息仍未空!");
|
|
410
|
-
tcs.TrySetResult(-2);
|
|
411
|
-
}
|
|
412
|
-
else if (Verification.IsVerifing) {
|
|
413
|
-
var tip = Config.GetInputIdentifyBlockingTip();
|
|
414
|
-
Action onOk = () => {
|
|
415
|
-
TapLogger.Debug("[TapTap: ChinaCompliance] 认证中,退出游戏!");
|
|
416
|
-
tcs.TrySetResult(-1);
|
|
417
|
-
#if !UNITY_EDITOR
|
|
418
|
-
Application.Quit();
|
|
419
|
-
#else
|
|
420
|
-
EditorApplication.isPlaying = false;
|
|
421
|
-
#endif
|
|
422
|
-
};
|
|
423
|
-
TapComplianceUI.OpenHealthPaymentPanel(tip.Title, tip.Content, tip.PositiveButtonText, onOk);
|
|
424
|
-
await tcs.Task;
|
|
425
|
-
}
|
|
426
|
-
else if (Verification.IsVerifyFailed) {
|
|
427
|
-
// TODO:多语言
|
|
428
|
-
UIManager.Instance.OpenToast("认证未通过, 请在 Tap 客户端重新提交实名信息", UIManager.GeneralToastLevel.Error);
|
|
429
|
-
if (havePopupBefore) {
|
|
430
|
-
tcs.TrySetResult(-3);
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
throw new TaskCanceledException();
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
TapLogger.Debug("[TapTap: ChinaCompliance] 认证成功!接入认证!");
|
|
438
|
-
tcs.TrySetResult(0);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
await tcs.Task;
|
|
442
|
-
return tcs.Task.Result;
|
|
443
|
-
}
|
|
444
373
|
|
|
445
374
|
/// <summary>
|
|
446
|
-
/// 获取 Token,分为几种情况:1)不是TapUser
|
|
375
|
+
/// 获取 Token,分为几种情况:1)不是TapUser的话,需要去展示包含手动的授权界面;2)是TapUser,这时需要去展示仅包含 Tap 的授权界面;
|
|
447
376
|
/// </summary>
|
|
448
377
|
/// <param name="userId"></param>
|
|
449
378
|
/// <returns></returns>
|
|
@@ -9,6 +9,7 @@ using TapSDK.Core;
|
|
|
9
9
|
using TapSDK.Core.Standalone;
|
|
10
10
|
using TapSDK.Core.Internal.Utils;
|
|
11
11
|
using Newtonsoft.Json;
|
|
12
|
+
using TapSDK.UI;
|
|
12
13
|
|
|
13
14
|
namespace TapSDK.Compliance
|
|
14
15
|
{
|
|
@@ -217,8 +218,10 @@ namespace TapSDK.Compliance
|
|
|
217
218
|
TapTapComplianceManager.SetTestEnvironment(enable);
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
public void OnInvokeExternalCallback(int code, string msg)
|
|
221
|
-
|
|
221
|
+
public void OnInvokeExternalCallback(int code, string msg)
|
|
222
|
+
{
|
|
223
|
+
switch (code)
|
|
224
|
+
{
|
|
222
225
|
case StartUpResult.LOGIN_SUCCESS:
|
|
223
226
|
TapTapComplianceManager.CanPlay = true;
|
|
224
227
|
break;
|
|
@@ -236,12 +239,13 @@ namespace TapSDK.Compliance
|
|
|
236
239
|
|| code == StartUpResult.EXITED // 登出用户
|
|
237
240
|
|| code == StartUpResult.AGE_LIMIT // 年龄限制
|
|
238
241
|
|| code == StartUpResult.SWITCH_ACCOUNT // 切换账号
|
|
239
|
-
|| code == StartUpResult.INVALID_CLIENT_OR_NETWORK_ERROR)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
|| code == StartUpResult.INVALID_CLIENT_OR_NETWORK_ERROR)
|
|
243
|
+
{ // 网络异常
|
|
244
|
+
// 用户结束校验流程
|
|
245
|
+
isCheckingUser = false;
|
|
246
|
+
}
|
|
247
|
+
// 在 openlog 中设置当前用户信息
|
|
248
|
+
if (code == StartUpResult.LOGIN_SUCCESS || code == StartUpResult.EXITED || code == StartUpResult.SWITCH_ACCOUNT)
|
|
245
249
|
{
|
|
246
250
|
string userIdentifier = "";
|
|
247
251
|
string userSessionId = "";
|
|
@@ -250,21 +254,30 @@ namespace TapSDK.Compliance
|
|
|
250
254
|
userIdentifier = TapTapComplianceManager.UserId ?? "";
|
|
251
255
|
userSessionId = TapTapComplianceManager.CurrentSession ?? "";
|
|
252
256
|
}
|
|
253
|
-
Dictionary<string,string> userData = new Dictionary<string,string>()
|
|
257
|
+
Dictionary<string, string> userData = new Dictionary<string, string>()
|
|
258
|
+
{
|
|
254
259
|
["anti_addict_user_identifier"] = userIdentifier,
|
|
255
260
|
["anti_addict_session_id"] = userSessionId
|
|
256
261
|
};
|
|
257
262
|
string userInfo = JsonConvert.SerializeObject(userData);
|
|
258
263
|
EventManager.TriggerEvent(EventManager.OnComplianceUserChanged, userInfo);
|
|
259
|
-
}
|
|
264
|
+
}
|
|
260
265
|
|
|
261
|
-
if (StartUpResult.Contains(code))
|
|
262
|
-
|
|
263
|
-
|
|
266
|
+
if (StartUpResult.Contains(code))
|
|
267
|
+
{
|
|
268
|
+
if (_externalCallbackList != null)
|
|
269
|
+
{
|
|
270
|
+
foreach (Action<int, string> callback in _externalCallbackList)
|
|
271
|
+
{
|
|
264
272
|
callback?.Invoke(code, msg);
|
|
265
273
|
}
|
|
266
274
|
}
|
|
267
275
|
}
|
|
276
|
+
|
|
277
|
+
if (code == StartUpResult.LOGIN_SUCCESS)
|
|
278
|
+
{
|
|
279
|
+
TapTapComplianceManager.ShowAntiAddictionTip();
|
|
280
|
+
}
|
|
268
281
|
}
|
|
269
282
|
|
|
270
283
|
/// <summary>
|
|
@@ -5,30 +5,30 @@ using TapSDK.Core;
|
|
|
5
5
|
|
|
6
6
|
namespace TapSDK.Compliance.Model
|
|
7
7
|
{
|
|
8
|
-
public class VerificationResult
|
|
8
|
+
public class VerificationResult
|
|
9
9
|
{
|
|
10
10
|
|
|
11
11
|
[JsonProperty("status")]
|
|
12
12
|
public string Status { get; private set; }
|
|
13
13
|
|
|
14
|
-
[JsonProperty("anti_addiction_token")]
|
|
14
|
+
[JsonProperty("anti_addiction_token")]
|
|
15
15
|
internal string ComplianceToken { get; private set; }
|
|
16
|
-
|
|
17
|
-
[JsonProperty("code")]
|
|
16
|
+
|
|
17
|
+
[JsonProperty("code")]
|
|
18
18
|
public int errorCode { get; private set; }
|
|
19
|
-
|
|
20
|
-
[JsonProperty("error")]
|
|
19
|
+
|
|
20
|
+
[JsonProperty("error")]
|
|
21
21
|
public string error { get; private set; }
|
|
22
|
-
|
|
23
|
-
[JsonProperty("error_description")]
|
|
22
|
+
|
|
23
|
+
[JsonProperty("error_description")]
|
|
24
24
|
public string errorDescription { get; private set; }
|
|
25
|
-
|
|
26
|
-
[JsonProperty("msg")]
|
|
25
|
+
|
|
26
|
+
[JsonProperty("msg")]
|
|
27
27
|
public string msg { get; private set; }
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
internal VerificationResult() { }
|
|
30
30
|
|
|
31
|
-
internal VerificationResult(VerificationResult other)
|
|
31
|
+
internal VerificationResult(VerificationResult other)
|
|
32
32
|
{
|
|
33
33
|
TapLogger.Debug("current state = " + other.Status);
|
|
34
34
|
Status = other.Status;
|
|
@@ -38,6 +38,21 @@ namespace TapSDK.Compliance.Model
|
|
|
38
38
|
errorDescription = other.errorDescription;
|
|
39
39
|
msg = other.msg;
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// 是否已认证
|
|
44
|
+
/// </summary>
|
|
45
|
+
internal bool IsVerified => Status?.Equals(ComplianceConst.VERIFICATION_STATUS_SUCCESS) ?? false;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// 是否在认证中
|
|
49
|
+
/// /// </summary>
|
|
50
|
+
internal bool IsVerifing => Status?.Equals(ComplianceConst.VERIFICATION_STATUS_WAITING) ?? false;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
/// 是否认证失败
|
|
54
|
+
/// /// </summary>
|
|
55
|
+
internal bool IsVerifyFailed => Status?.Equals(ComplianceConst.VERIFICATION_STATUS_FAILED) ?? false;
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
|
|
@@ -66,21 +81,6 @@ namespace TapSDK.Compliance.Model
|
|
|
66
81
|
|
|
67
82
|
internal LocalVerification(VerificationResult obj) : base(obj) { }
|
|
68
83
|
|
|
69
|
-
/// <summary>
|
|
70
|
-
/// 是否已认证
|
|
71
|
-
/// </summary>
|
|
72
|
-
internal bool IsVerified => Status.Equals(ComplianceConst.VERIFICATION_STATUS_SUCCESS);
|
|
73
|
-
|
|
74
|
-
/// <summary>
|
|
75
|
-
/// 是否在认证中
|
|
76
|
-
/// /// </summary>
|
|
77
|
-
internal bool IsVerifing => Status.Equals(ComplianceConst.VERIFICATION_STATUS_WAITING);
|
|
78
|
-
|
|
79
|
-
/// <summary>
|
|
80
|
-
/// 是否认证失败
|
|
81
|
-
/// /// </summary>
|
|
82
|
-
internal bool IsVerifyFailed => Status.Equals(ComplianceConst.VERIFICATION_STATUS_FAILED);
|
|
83
|
-
|
|
84
84
|
internal bool CheckIsAdult => AgeLimit == Verification.AGE_LIMIT_ADULT || AgeLimit == Verification.UNKNOWN_AGE_ADULT;
|
|
85
85
|
|
|
86
86
|
|
|
@@ -215,6 +215,21 @@ namespace TapSDK.Compliance
|
|
|
215
215
|
{
|
|
216
216
|
return false;
|
|
217
217
|
}
|
|
218
|
+
|
|
219
|
+
/// 首次通过,弹防沉迷提示文案
|
|
220
|
+
internal static void ShowAntiAddictionTip()
|
|
221
|
+
{
|
|
222
|
+
if (string.IsNullOrEmpty(UserId)){
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
var userIdEncode = "compliance_tip_" + Tool.EncryptString(UserId);
|
|
226
|
+
var hasShowTip = !string.IsNullOrEmpty(DataStorage.LoadString(userIdEncode));
|
|
227
|
+
if (!hasShowTip)
|
|
228
|
+
{
|
|
229
|
+
TapMessage.ShowMessage("已通过防沉迷校验,祝您游戏愉快!", position:TapMessage.Position.bottom, time:TapMessage.Time.threeSecond);
|
|
230
|
+
DataStorage.SaveString(userIdEncode, "1");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
218
233
|
|
|
219
234
|
public static bool? useMobileUI;
|
|
220
235
|
|
|
@@ -146,11 +146,14 @@ namespace TapSDK.Compliance.Internal
|
|
|
146
146
|
isSending = false;
|
|
147
147
|
// 后端返回后按钮可用
|
|
148
148
|
submitButton.interactable = true;
|
|
149
|
-
if (verificationResult.
|
|
149
|
+
if (!verificationResult.IsVerifyFailed)
|
|
150
150
|
{
|
|
151
151
|
// TODO@luran:本地化
|
|
152
152
|
Close();
|
|
153
|
-
|
|
153
|
+
if (verificationResult.IsVerified)
|
|
154
|
+
{
|
|
155
|
+
UIManager.Instance.OpenToast("提交成功", UIManager.GeneralToastLevel.Success);
|
|
156
|
+
}
|
|
154
157
|
}
|
|
155
158
|
OnVerified?.Invoke(verificationResult);
|
|
156
159
|
}
|
|
@@ -8,7 +8,7 @@ using TapSDK.Login;
|
|
|
8
8
|
|
|
9
9
|
namespace TapSDK.Compliance.Internal
|
|
10
10
|
{
|
|
11
|
-
public static class Verification
|
|
11
|
+
public static class Verification
|
|
12
12
|
{
|
|
13
13
|
internal const int AGE_LIMIT_UNKNOWN = -1;
|
|
14
14
|
internal const int AGE_LIMIT_CHILD = 0;
|
|
@@ -19,7 +19,7 @@ namespace TapSDK.Compliance.Internal
|
|
|
19
19
|
internal const int UNKNOWN_AGE = 100;
|
|
20
20
|
// 已实名,但未同意年龄段信息授权且成年
|
|
21
21
|
internal const int UNKNOWN_AGE_ADULT = 110;
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
static readonly string VERIFICATION_FILENAME = "verification";
|
|
24
24
|
|
|
25
25
|
static readonly string VERIFICATION_V2_FILENAME = "verification_v2";
|
|
@@ -40,46 +40,48 @@ namespace TapSDK.Compliance.Internal
|
|
|
40
40
|
/// 快速获取身份信息
|
|
41
41
|
/// </summary>
|
|
42
42
|
/// <param name="userId"></param>
|
|
43
|
-
public static async Task Fetch(string userId)
|
|
43
|
+
public static async Task Fetch(string userId)
|
|
44
44
|
{
|
|
45
|
-
if(current != null && !current.UserId.Equals(userId))
|
|
45
|
+
if (current != null && !current.UserId.Equals(userId))
|
|
46
|
+
{
|
|
46
47
|
Logout(false);
|
|
47
48
|
}
|
|
48
49
|
string filename = Tool.EncryptString(userId);
|
|
49
50
|
// 存储 v2 token 数据
|
|
50
|
-
if(persistenceV2 == null)
|
|
51
|
+
if (persistenceV2 == null)
|
|
52
|
+
{
|
|
51
53
|
persistenceV2 = new Persistence(Path.Combine(
|
|
52
54
|
VERIFICATION_V2_FILENAME,
|
|
53
|
-
filename));
|
|
55
|
+
filename));
|
|
54
56
|
}
|
|
55
57
|
VerificationResult result;
|
|
56
|
-
try
|
|
58
|
+
try
|
|
57
59
|
{
|
|
58
60
|
LocalVerification localVerification;
|
|
59
61
|
TapLogger.Debug("start check v2 token in local");
|
|
60
62
|
//先检查本地是否有 v2 缓存
|
|
61
63
|
localVerification = await persistenceV2.Load<LocalVerification>();
|
|
62
|
-
if(localVerification != null && localVerification.ComplianceToken != null
|
|
63
|
-
&& localVerification.ComplianceToken.Length > 0)
|
|
64
|
+
if (localVerification != null && localVerification.ComplianceToken != null
|
|
65
|
+
&& localVerification.ComplianceToken.Length > 0)
|
|
66
|
+
{
|
|
64
67
|
current = localVerification;
|
|
65
68
|
return;
|
|
66
69
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
TapTapAccount tapAccount = await TapTapLogin.Instance.GetCurrentTapAccount();
|
|
71
|
+
AccessToken accessToken = tapAccount?.accessToken;
|
|
72
|
+
if (HasComplianceAuthInTapToken(accessToken))
|
|
70
73
|
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
await Save(userId, result);
|
|
79
|
-
}
|
|
74
|
+
await FetchByTapToken(userId);
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
{
|
|
78
|
+
TapLogger.Debug("try get v2 token with userId");
|
|
79
|
+
result = await Network.FetchVerification(userId);
|
|
80
|
+
await Save(userId, result);
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
catch (Exception e)
|
|
83
85
|
{
|
|
84
86
|
//首次异常报错
|
|
85
87
|
TapLogger.Debug("try get v2 token failed error: " + e.Message);
|
|
@@ -88,56 +90,34 @@ namespace TapSDK.Compliance.Internal
|
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
internal static async Task
|
|
92
|
-
|
|
93
|
-
string filename = Tool.EncryptString(userId);
|
|
94
|
-
//存储 v1 token数据
|
|
95
|
-
if(persistence == null){
|
|
96
|
-
persistence = new Persistence(Path.Combine(
|
|
97
|
-
VERIFICATION_FILENAME,
|
|
98
|
-
filename));
|
|
99
|
-
}
|
|
100
|
-
LocalVerification localVerification = await persistence.Load<LocalVerification>();
|
|
101
|
-
try{
|
|
102
|
-
if(localVerification != null && localVerification.ComplianceToken != null
|
|
103
|
-
&& localVerification.ComplianceToken.Length > 0){
|
|
104
|
-
VerificationResult result = await Network.UpgradeToken(userId, localVerification.ComplianceToken);
|
|
105
|
-
await Save(userId, result);
|
|
106
|
-
persistence.Delete();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
}catch(Exception e){
|
|
110
|
-
// 4xx 清除本地缓存
|
|
111
|
-
if(e is ComplianceException aee){
|
|
112
|
-
TapLogger.Debug("get httpCode = " + aee.code + " so remove local old token");
|
|
113
|
-
persistence.Delete();
|
|
114
|
-
}
|
|
115
|
-
throw e;
|
|
116
|
-
}
|
|
117
|
-
throw new Exception();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
internal static async Task FetchByTapToken(string userId, AccessToken accessToken = null){
|
|
93
|
+
internal static async Task FetchByTapToken(string userId, AccessToken accessToken = null)
|
|
94
|
+
{
|
|
121
95
|
TapLogger.Debug("start check tapToken in local");
|
|
122
96
|
long timestamp = 0;
|
|
123
97
|
int retryTimes = 1;
|
|
124
98
|
VerificationResult result;
|
|
125
|
-
while(true)
|
|
126
|
-
|
|
99
|
+
while (true)
|
|
100
|
+
{
|
|
101
|
+
if (accessToken == null)
|
|
102
|
+
{
|
|
127
103
|
///判断本地是否有包含 compliance 的 token
|
|
128
104
|
TapTapAccount tapAccount = await TapTapLogin.Instance.GetCurrentTapAccount();
|
|
129
|
-
accessToken =
|
|
105
|
+
accessToken = tapAccount?.accessToken;
|
|
130
106
|
}
|
|
131
|
-
try
|
|
132
|
-
|
|
107
|
+
try
|
|
108
|
+
{
|
|
109
|
+
if (HasComplianceAuthInTapToken(accessToken))
|
|
110
|
+
{
|
|
133
111
|
TapLogger.Debug("try use tapToken to get v2 token");
|
|
134
|
-
result = await Network.FetchVerificationByTapToken(userId,accessToken, timestamp);
|
|
112
|
+
result = await Network.FetchVerificationByTapToken(userId, accessToken, timestamp);
|
|
135
113
|
await Save(userId, result);
|
|
136
114
|
return;
|
|
137
115
|
}
|
|
138
|
-
}
|
|
116
|
+
}
|
|
117
|
+
catch (Exception e)
|
|
118
|
+
{
|
|
139
119
|
//时间戳异常
|
|
140
|
-
if (e is ComplianceException aee && aee.Error != null
|
|
120
|
+
if (e is ComplianceException aee && aee.Error != null
|
|
141
121
|
&& aee.Error.Equals(ComplianceConst.SERVER_ERROR_TYPE_INVALID_TIME) && retryTimes > 0)
|
|
142
122
|
{
|
|
143
123
|
timestamp = aee.Now;
|
|
@@ -151,23 +131,28 @@ namespace TapSDK.Compliance.Internal
|
|
|
151
131
|
}
|
|
152
132
|
throw new Exception();
|
|
153
133
|
}
|
|
154
|
-
|
|
134
|
+
|
|
155
135
|
}
|
|
156
136
|
|
|
157
|
-
internal static bool HasComplianceAuthInTapToken(AccessToken accessToken)
|
|
158
|
-
|
|
137
|
+
internal static bool HasComplianceAuthInTapToken(AccessToken accessToken)
|
|
138
|
+
{
|
|
139
|
+
if (accessToken == null)
|
|
140
|
+
{
|
|
159
141
|
return false;
|
|
160
142
|
}
|
|
161
143
|
bool useAgeRange = TapTapComplianceManager.config.useAgeRange;
|
|
162
|
-
if(useAgeRange)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
144
|
+
if (useAgeRange)
|
|
145
|
+
{
|
|
146
|
+
return accessToken.scopeSet != null && accessToken.scopeSet.Contains(ComplianceWorker.SCOPE_COMPLIANCE);
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
{
|
|
150
|
+
return accessToken.scopeSet != null &&
|
|
151
|
+
(accessToken.scopeSet.Contains(ComplianceWorker.SCOPE_COMPLIANCE) || accessToken.scopeSet.Contains(ComplianceWorker.SCOPE_COMPLIANCE_BASIC));
|
|
167
152
|
}
|
|
168
153
|
}
|
|
169
154
|
|
|
170
|
-
|
|
155
|
+
|
|
171
156
|
/// <summary>
|
|
172
157
|
/// 手动输入身份信息
|
|
173
158
|
/// </summary>
|
|
@@ -177,14 +162,14 @@ namespace TapSDK.Compliance.Internal
|
|
|
177
162
|
/// <returns></returns>
|
|
178
163
|
internal static async Task<VerificationResult> FetchVerificationManual(string userId, string userName, string idCard)
|
|
179
164
|
{
|
|
180
|
-
var tcs = new TaskCompletionSource<VerificationResult>();
|
|
165
|
+
var tcs = new TaskCompletionSource<VerificationResult>();
|
|
181
166
|
try
|
|
182
167
|
{
|
|
183
168
|
VerificationResult result = await Network.FetchVerificationManual(userName, idCard);
|
|
184
169
|
tcs.SetResult(result);
|
|
185
170
|
await Save(userId, result);
|
|
186
|
-
}
|
|
187
|
-
catch (Exception e)
|
|
171
|
+
}
|
|
172
|
+
catch (Exception e)
|
|
188
173
|
{
|
|
189
174
|
tcs.SetException(e);
|
|
190
175
|
TapLogger.Error(e.ToString());
|
|
@@ -202,11 +187,12 @@ namespace TapSDK.Compliance.Internal
|
|
|
202
187
|
/// <returns></returns>
|
|
203
188
|
public static async Task<VerificationResult> FetchVerificationByTapToken(string userId, AccessToken token)
|
|
204
189
|
{
|
|
205
|
-
var tcs = new TaskCompletionSource<VerificationResult>();
|
|
190
|
+
var tcs = new TaskCompletionSource<VerificationResult>();
|
|
206
191
|
try
|
|
207
192
|
{
|
|
208
193
|
await FetchByTapToken(userId, token);
|
|
209
|
-
if(persistenceV2 == null)
|
|
194
|
+
if (persistenceV2 == null)
|
|
195
|
+
{
|
|
210
196
|
var filename = Tool.EncryptString(userId);
|
|
211
197
|
persistenceV2 = new Persistence(Path.Combine(
|
|
212
198
|
VERIFICATION_V2_FILENAME,
|
|
@@ -214,8 +200,8 @@ namespace TapSDK.Compliance.Internal
|
|
|
214
200
|
}
|
|
215
201
|
VerificationResult result = await persistenceV2.Load<VerificationResult>();
|
|
216
202
|
tcs.SetResult(result);
|
|
217
|
-
}
|
|
218
|
-
catch (Exception e)
|
|
203
|
+
}
|
|
204
|
+
catch (Exception e)
|
|
219
205
|
{
|
|
220
206
|
tcs.SetException(e);
|
|
221
207
|
TapLogger.Error(e.ToString());
|
|
@@ -225,14 +211,15 @@ namespace TapSDK.Compliance.Internal
|
|
|
225
211
|
return await tcs.Task;
|
|
226
212
|
}
|
|
227
213
|
|
|
228
|
-
public static async Task Save(string userId, VerificationResult verification)
|
|
214
|
+
public static async Task Save(string userId, VerificationResult verification)
|
|
229
215
|
{
|
|
230
|
-
current = new LocalVerification(verification)
|
|
216
|
+
current = new LocalVerification(verification)
|
|
231
217
|
{
|
|
232
218
|
UserId = userId
|
|
233
219
|
};
|
|
234
220
|
TapLogger.Debug("try save v2 token to local");
|
|
235
|
-
if(persistenceV2 == null)
|
|
221
|
+
if (persistenceV2 == null)
|
|
222
|
+
{
|
|
236
223
|
var filename = Tool.EncryptString(userId);
|
|
237
224
|
persistenceV2 = new Persistence(Path.Combine(
|
|
238
225
|
VERIFICATION_V2_FILENAME,
|
|
@@ -241,12 +228,15 @@ namespace TapSDK.Compliance.Internal
|
|
|
241
228
|
await persistenceV2.Save(current);
|
|
242
229
|
}
|
|
243
230
|
|
|
244
|
-
public static async Task setAgeState(int ageLimit, bool isAdult)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
231
|
+
public static async Task setAgeState(int ageLimit, bool isAdult)
|
|
232
|
+
{
|
|
233
|
+
if (current != null)
|
|
234
|
+
{
|
|
235
|
+
current.AgeLimit = ageLimit < 0 ?
|
|
236
|
+
(isAdult ? UNKNOWN_AGE_ADULT : UNKNOWN_AGE) : ageLimit;
|
|
248
237
|
current.IsAdult = isAdult;
|
|
249
|
-
if(persistenceV2 == null)
|
|
238
|
+
if (persistenceV2 == null)
|
|
239
|
+
{
|
|
250
240
|
var filename = Tool.EncryptString(current.UserId);
|
|
251
241
|
persistenceV2 = new Persistence(Path.Combine(
|
|
252
242
|
VERIFICATION_V2_FILENAME,
|
|
@@ -256,20 +246,22 @@ namespace TapSDK.Compliance.Internal
|
|
|
256
246
|
}
|
|
257
247
|
}
|
|
258
248
|
|
|
259
|
-
public static void ClearCacheVerfiction()
|
|
249
|
+
public static void ClearCacheVerfiction()
|
|
250
|
+
{
|
|
260
251
|
persistence?.Delete();
|
|
261
252
|
persistenceV2?.Delete();
|
|
262
253
|
}
|
|
263
254
|
|
|
264
|
-
internal static void Logout(bool needClearCache = true)
|
|
255
|
+
internal static void Logout(bool needClearCache = true)
|
|
265
256
|
{
|
|
266
257
|
// if (IsVerified && !IsAdult)
|
|
267
258
|
// {
|
|
268
|
-
// #pragma warning disable CS4014
|
|
269
|
-
// Network.CheckPlayable();
|
|
270
|
-
// #pragma warning restore CS4014
|
|
259
|
+
// #pragma warning disable CS4014
|
|
260
|
+
// Network.CheckPlayable();
|
|
261
|
+
// #pragma warning restore CS4014
|
|
271
262
|
// }
|
|
272
|
-
if(needClearCache)
|
|
263
|
+
if (needClearCache)
|
|
264
|
+
{
|
|
273
265
|
ClearCacheVerfiction();
|
|
274
266
|
}
|
|
275
267
|
persistence = null;
|
|
@@ -277,7 +269,7 @@ namespace TapSDK.Compliance.Internal
|
|
|
277
269
|
current = null;
|
|
278
270
|
}
|
|
279
271
|
|
|
280
|
-
internal static string GetCurrentToken()
|
|
272
|
+
internal static string GetCurrentToken()
|
|
281
273
|
{
|
|
282
274
|
return current?.ComplianceToken;
|
|
283
275
|
}
|
|
@@ -286,12 +278,12 @@ namespace TapSDK.Compliance.Internal
|
|
|
286
278
|
/// 是否已认证
|
|
287
279
|
/// </summary>
|
|
288
280
|
public static bool IsVerified => current?.IsVerified ?? DEFAULT_VERIFIED;
|
|
289
|
-
|
|
281
|
+
|
|
290
282
|
/// <summary>
|
|
291
283
|
/// 是否在认证中
|
|
292
284
|
/// </summary>
|
|
293
285
|
public static bool IsVerifing => current?.IsVerifing ?? DEFAULT_VERIFING;
|
|
294
|
-
|
|
286
|
+
|
|
295
287
|
/// <summary>
|
|
296
288
|
/// 是否认证失败
|
|
297
289
|
/// </summary>
|
|
@@ -32,8 +32,7 @@ namespace TapSDK.Compliance
|
|
|
32
32
|
/// <summary>
|
|
33
33
|
/// 激活手动认证
|
|
34
34
|
/// </summary>
|
|
35
|
-
|
|
36
|
-
protected abstract Task VerifyManuallyAsync(bool activelyVerifyManually);
|
|
35
|
+
protected abstract Task VerifyManuallyAsync();
|
|
37
36
|
|
|
38
37
|
/// <summary>
|
|
39
38
|
/// 检查未成年人可玩性
|
|
@@ -69,6 +68,10 @@ namespace TapSDK.Compliance
|
|
|
69
68
|
/// <returns></returns>
|
|
70
69
|
protected virtual async Task<int> OnCheckedPlayableWithMinorAsync(PlayableResult playable)
|
|
71
70
|
{
|
|
71
|
+
if (playable.RemainTime > 0)
|
|
72
|
+
{
|
|
73
|
+
TapTapComplianceManager.ShowAntiAddictionTip();
|
|
74
|
+
}
|
|
72
75
|
var tcs = new TaskCompletionSource<int>();
|
|
73
76
|
Action onOk;
|
|
74
77
|
if (playable.RemainTime > 0) {
|
|
@@ -344,40 +347,61 @@ namespace TapSDK.Compliance
|
|
|
344
347
|
#region Internal
|
|
345
348
|
|
|
346
349
|
public async Task<int> StartUp(string userId) {
|
|
347
|
-
|
|
348
|
-
if (
|
|
350
|
+
await FetchVerificationAsync(userId);
|
|
351
|
+
if (Verification.Current == null || Verification.IsVerifyFailed)
|
|
352
|
+
{
|
|
349
353
|
TapLogger.Debug("try get token internal by UI");
|
|
350
354
|
var result = await InternalStartup(userId);
|
|
351
|
-
// 目前只会返回 9002 和 0-认证成功
|
|
355
|
+
// 目前只会返回 9002 和 0-认证成功
|
|
352
356
|
// 9002 是 StartUpResult.REAL_NAME_STOP
|
|
353
|
-
if (result != 0)
|
|
357
|
+
if (result != 0)
|
|
358
|
+
{
|
|
354
359
|
return result;
|
|
355
360
|
}
|
|
356
361
|
}
|
|
357
|
-
else
|
|
362
|
+
else if (Verification.IsVerifing)
|
|
363
|
+
{
|
|
364
|
+
return await ShowVerifingTip();
|
|
365
|
+
}
|
|
366
|
+
else
|
|
367
|
+
{
|
|
358
368
|
UIManager.Instance.CloseLoading();
|
|
359
369
|
}
|
|
360
370
|
return await OnVerificationFetched();
|
|
361
371
|
}
|
|
362
372
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
373
|
+
/// <summary>
|
|
374
|
+
/// 显示实名中提示
|
|
375
|
+
/// </summary>
|
|
376
|
+
internal async Task<int> ShowVerifingTip()
|
|
377
|
+
{
|
|
378
|
+
var task = new TaskCompletionSource<int>();
|
|
379
|
+
var tip = Config.GetInputIdentifyBlockingTip();
|
|
380
|
+
Action onOk = () =>
|
|
381
|
+
{
|
|
382
|
+
TapLogger.Debug("[TapTap: ChinaCompliance] 认证中,实名取消!");
|
|
383
|
+
task.TrySetResult(StartUpResult.REAL_NAME_STOP);
|
|
384
|
+
};
|
|
385
|
+
TapComplianceUI.OpenHealthPaymentPanel(tip.Title, tip.Content, tip.PositiveButtonText, onOk);
|
|
386
|
+
return await task.Task;
|
|
366
387
|
}
|
|
367
388
|
/// <summary>
|
|
368
389
|
/// 获得实名信息
|
|
369
390
|
/// </summary>
|
|
370
|
-
public async Task FetchVerificationAsync(string userId)
|
|
391
|
+
public async Task FetchVerificationAsync(string userId)
|
|
392
|
+
{
|
|
371
393
|
// 拉取服务端实名信息
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
394
|
+
try
|
|
395
|
+
{
|
|
396
|
+
await Verification.Fetch(userId);
|
|
397
|
+
UIManager.Instance.CloseLoading();
|
|
398
|
+
}
|
|
399
|
+
catch (Exception e)
|
|
400
|
+
{
|
|
401
|
+
TapLogger.Error(e);
|
|
402
|
+
UIManager.Instance.CloseLoading();
|
|
403
|
+
//所有错误跳过,执行实名
|
|
404
|
+
}
|
|
381
405
|
}
|
|
382
406
|
|
|
383
407
|
/// <summary>
|
package/link.xml.meta
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
fileFormatVersion: 2
|
|
2
|
+
<<<<<<< HEAD
|
|
2
3
|
guid: 2621f25a6f7ee4b41b72671be0520177
|
|
4
|
+
=======
|
|
5
|
+
guid: 07c47b078fb194edca068de7ed08ffa1
|
|
6
|
+
>>>>>>> 7453f549f (feat: pipeline build TapSDK4 Unity Demo changed version #no-ticket)
|
|
3
7
|
TextScriptImporter:
|
|
4
8
|
externalObjects: {}
|
|
5
9
|
userData:
|
package/package.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "com.taptap.sdk.compliance",
|
|
3
3
|
"displayName": "TapTapSDK Compliance",
|
|
4
4
|
"description": "TapTapSDK Compliance",
|
|
5
|
-
"version": "4.6.
|
|
5
|
+
"version": "4.6.3",
|
|
6
6
|
"unity": "2019.4",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"com.taptap.sdk.core": "4.6.
|
|
10
|
-
"com.taptap.sdk.login": "4.6.
|
|
9
|
+
"com.taptap.sdk.core": "4.6.3",
|
|
10
|
+
"com.taptap.sdk.login": "4.6.3"
|
|
11
11
|
}
|
|
12
12
|
}
|