com.taptap.sdk.compliance 4.3.0-aplha.13
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 +18 -0
- package/Mobile/Editor/NativeDependencies.xml.meta +7 -0
- package/Mobile/Editor/TapComplianceMobileProcessBuild.cs +21 -0
- package/Mobile/Editor/TapComplianceMobileProcessBuild.cs.meta +3 -0
- package/Mobile/Editor/TapSDK.Compliance.Mobile.Editor.asmdef +17 -0
- package/Mobile/Editor/TapSDK.Compliance.Mobile.Editor.asmdef.meta +7 -0
- package/Mobile/Editor/iOS/BuidPostProcessor.cs +45 -0
- package/Mobile/Editor/iOS/BuidPostProcessor.cs.meta +11 -0
- package/Mobile/Editor/iOS.meta +8 -0
- package/Mobile/Editor.meta +8 -0
- package/Mobile/Runtime/ComplianceMobileBridge.cs +319 -0
- package/Mobile/Runtime/ComplianceMobileBridge.cs.meta +11 -0
- package/Mobile/Runtime/ComplianceMobileOldJob.cs +81 -0
- package/Mobile/Runtime/ComplianceMobileOldJob.cs.meta +11 -0
- package/Mobile/Runtime/TapSDK.Compliance.Mobile.Runtime.asmdef +19 -0
- package/Mobile/Runtime/TapSDK.Compliance.Mobile.Runtime.asmdef.meta +7 -0
- package/Mobile/Runtime.meta +3 -0
- package/Mobile.meta +8 -0
- package/Resources/BillingMode.json +1 -0
- package/Resources/BillingMode.json.meta +7 -0
- package/Resources/Config/ComplianceLocalization.json +116 -0
- package/Resources/Config/ComplianceLocalization.json.meta +7 -0
- package/Resources/Config.meta +8 -0
- package/Resources/Prefabs/Mobile/TapTapAntiAddictionRetryAlert.prefab +803 -0
- package/Resources/Prefabs/Mobile/TapTapAntiAddictionRetryAlert.prefab.meta +7 -0
- package/Resources/Prefabs/Mobile/TapTapHealthPaymentPanel.prefab +820 -0
- package/Resources/Prefabs/Mobile/TapTapHealthPaymentPanel.prefab.meta +7 -0
- package/Resources/Prefabs/Mobile/TapTapHealthReminderPanel.prefab +988 -0
- package/Resources/Prefabs/Mobile/TapTapHealthReminderPanel.prefab.meta +7 -0
- package/Resources/Prefabs/Mobile/TapTapVietnamTimeSelectorPanel.prefab +3176 -0
- package/Resources/Prefabs/Mobile/TapTapVietnamTimeSelectorPanel.prefab.meta +7 -0
- package/Resources/Prefabs/Mobile.meta +8 -0
- package/Resources/Prefabs.meta +8 -0
- package/Resources/Textures/Background.png +0 -0
- package/Resources/Textures/Background.png.meta +128 -0
- package/Resources/Textures/Button.png +0 -0
- package/Resources/Textures/Button.png.meta +128 -0
- package/Resources/Textures/Checkmark.png +0 -0
- package/Resources/Textures/Checkmark.png.meta +128 -0
- package/Resources/Textures/Dropdown.png +0 -0
- package/Resources/Textures/Dropdown.png.meta +128 -0
- package/Resources/Textures/DropdownH.png +0 -0
- package/Resources/Textures/DropdownH.png.meta +128 -0
- package/Resources/Textures/Loading.png +0 -0
- package/Resources/Textures/Loading.png.meta +128 -0
- package/Resources/Textures/On.png +0 -0
- package/Resources/Textures/On.png.meta +128 -0
- package/Resources/Textures/Scrollview.png +0 -0
- package/Resources/Textures/Scrollview.png.meta +128 -0
- package/Resources/Textures/WhiteButton.png +0 -0
- package/Resources/Textures/WhiteButton.png.meta +128 -0
- package/Resources/Textures/error_tip.png +0 -0
- package/Resources/Textures/error_tip.png.meta +128 -0
- package/Resources/Textures/off.png +0 -0
- package/Resources/Textures/off.png.meta +128 -0
- package/Resources/Textures/taptap-antiaddiction-input.png +0 -0
- package/Resources/Textures/taptap-antiaddiction-input.png.meta +128 -0
- package/Resources/Textures/taptap-antiaddiction-largebutton.png +0 -0
- package/Resources/Textures/taptap-antiaddiction-largebutton.png.meta +128 -0
- package/Resources/Textures/taptap-antiaddiction-mobile-button.png +0 -0
- package/Resources/Textures/taptap-antiaddiction-mobile-button.png.meta +128 -0
- package/Resources/Textures.meta +8 -0
- package/Resources.meta +8 -0
- package/Runtime/Internal/ComplianceJobManager.cs +85 -0
- package/Runtime/Internal/ComplianceJobManager.cs.meta +11 -0
- package/Runtime/Internal/ComplianceResult.cs +89 -0
- package/Runtime/Internal/ComplianceResult.cs.meta +3 -0
- package/Runtime/Internal/IComplianceJob.cs +51 -0
- package/Runtime/Internal/IComplianceJob.cs.meta +11 -0
- package/Runtime/Internal/Init/ComplianceInitTask.cs +46 -0
- package/Runtime/Internal/Init/ComplianceInitTask.cs.meta +3 -0
- package/Runtime/Internal/Init.meta +3 -0
- package/Runtime/Internal/Model/StartUpResult.cs +28 -0
- package/Runtime/Internal/Model/StartUpResult.cs.meta +11 -0
- package/Runtime/Internal/Model.meta +8 -0
- package/Runtime/Internal.meta +8 -0
- package/Runtime/Public/TapTapCompliance.cs +119 -0
- package/Runtime/Public/TapTapCompliance.cs.meta +11 -0
- package/Runtime/Public/TapTapComplianceOption.cs +52 -0
- package/Runtime/Public/TapTapComplianceOption.cs.meta +3 -0
- package/Runtime/Public.meta +3 -0
- package/Runtime/TapSDK.Compliance.Runtime.asmdef +16 -0
- package/Runtime/TapSDK.Compliance.Runtime.asmdef.meta +7 -0
- package/Runtime.meta +3 -0
- package/Standalone/Editor/TapComplianceStandaloneProcessBuild.cs +20 -0
- package/Standalone/Editor/TapComplianceStandaloneProcessBuild.cs.meta +3 -0
- package/Standalone/Editor/TapSDK.Compliance.Standalone.Editor.asmdef +17 -0
- package/Standalone/Editor/TapSDK.Compliance.Standalone.Editor.asmdef.meta +7 -0
- package/Standalone/Editor.meta +3 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapAntiAddictionRetryAlert.prefab +835 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapAntiAddictionRetryAlert.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapChinaIDInputPanel.prefab +1646 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapChinaIDInputPanel.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapChinaQuickVerifyTipPanel.prefab +1591 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapChinaQuickVerifyTipPanel.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapHealthPaymentPanel.prefab +897 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapHealthPaymentPanel.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapHealthReminderPanel.prefab +1065 -0
- package/Standalone/Resources/Prefabs/Standalone/TapTapHealthReminderPanel.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/Standalone.meta +8 -0
- package/Standalone/Resources/Prefabs.meta +8 -0
- package/Standalone/Resources/Textures/QuickVerifyTip.png +0 -0
- package/Standalone/Resources/Textures/QuickVerifyTip.png.meta +128 -0
- package/Standalone/Resources/Textures/taptap-antiaddiction-largebutton.png +0 -0
- package/Standalone/Resources/Textures/taptap-antiaddiction-largebutton.png.meta +128 -0
- package/Standalone/Resources/Textures.meta +8 -0
- package/Standalone/Resources.meta +8 -0
- package/Standalone/Runtime/ComplianceWorker.cs +524 -0
- package/Standalone/Runtime/ComplianceWorker.cs.meta +11 -0
- package/Standalone/Runtime/Internal/AccessTokenJsonConverter.cs +58 -0
- package/Standalone/Runtime/Internal/AccessTokenJsonConverter.cs.meta +3 -0
- package/Standalone/Runtime/Internal/ComplianceConst.cs +73 -0
- package/Standalone/Runtime/Internal/ComplianceConst.cs.meta +11 -0
- package/Standalone/Runtime/Internal/ComplianceException.cs +24 -0
- package/Standalone/Runtime/Internal/ComplianceException.cs.meta +11 -0
- package/Standalone/Runtime/Internal/ComplianceNewJob.cs +174 -0
- package/Standalone/Runtime/Internal/ComplianceNewJob.cs.meta +11 -0
- package/Standalone/Runtime/Internal/CompliancePoll.cs +136 -0
- package/Standalone/Runtime/Internal/CompliancePoll.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Config.cs +137 -0
- package/Standalone/Runtime/Internal/Config.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/ComplianceHttpClient.cs +215 -0
- package/Standalone/Runtime/Internal/Http/ComplianceHttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http.meta +8 -0
- package/Standalone/Runtime/Internal/Model/BaseResponse.cs +14 -0
- package/Standalone/Runtime/Internal/Model/BaseResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/ErrorResponse.cs +27 -0
- package/Standalone/Runtime/Internal/Model/ErrorResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/Payable.cs +23 -0
- package/Standalone/Runtime/Internal/Model/Payable.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/Playable.cs +48 -0
- package/Standalone/Runtime/Internal/Model/Playable.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/RealNameConfig.cs +73 -0
- package/Standalone/Runtime/Internal/Model/RealNameConfig.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/ServerTime.cs +19 -0
- package/Standalone/Runtime/Internal/Model/ServerTime.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/StandaloneResponse.cs +12 -0
- package/Standalone/Runtime/Internal/Model/StandaloneResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/SubmitPayment.cs +8 -0
- package/Standalone/Runtime/Internal/Model/SubmitPayment.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/UserComplianceConfig.cs +109 -0
- package/Standalone/Runtime/Internal/Model/UserComplianceConfig.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model/Verification.cs +88 -0
- package/Standalone/Runtime/Internal/Model/Verification.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Model.meta +8 -0
- package/Standalone/Runtime/Internal/Network.cs +296 -0
- package/Standalone/Runtime/Internal/Network.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Persistence.cs +91 -0
- package/Standalone/Runtime/Internal/Persistence.cs.meta +11 -0
- package/Standalone/Runtime/Internal/TapComplianceUI.cs +68 -0
- package/Standalone/Runtime/Internal/TapComplianceUI.cs.meta +11 -0
- package/Standalone/Runtime/Internal/TapLoginPermissionProvider.cs +24 -0
- package/Standalone/Runtime/Internal/TapLoginPermissionProvider.cs.meta +11 -0
- package/Standalone/Runtime/Internal/TapTapComplianceManager.cs +253 -0
- package/Standalone/Runtime/Internal/TapTapComplianceManager.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Tool.cs +211 -0
- package/Standalone/Runtime/Internal/Tool.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/Controller/TapTapChinaVerifyFinishPanelController.cs +81 -0
- package/Standalone/Runtime/Internal/UI/Controller/TapTapChinaVerifyFinishPanelController.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/Controller/TapTapComplianceQuickVerifyTipController.cs +119 -0
- package/Standalone/Runtime/Internal/UI/Controller/TapTapComplianceQuickVerifyTipController.cs.meta +3 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceHealthPaymentController.cs +105 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceHealthPaymentController.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceHealthReminderController.cs +129 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceHealthReminderController.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceIDInputController.cs +218 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceIDInputController.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceRetryAlertController.cs +46 -0
- package/Standalone/Runtime/Internal/UI/Controller/TaptapComplianceRetryAlertController.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/Controller.meta +8 -0
- package/Standalone/Runtime/Internal/UI.meta +8 -0
- package/Standalone/Runtime/Internal/Verification.cs +315 -0
- package/Standalone/Runtime/Internal/Verification.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Worker/BaseComplianceWorker.cs +489 -0
- package/Standalone/Runtime/Internal/Worker/BaseComplianceWorker.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Worker.meta +8 -0
- package/Standalone/Runtime/Internal.meta +3 -0
- package/Standalone/Runtime/TapTap.AntiAddiction.Standalone.Runtime.asmdef +26 -0
- package/Standalone/Runtime/TapTap.AntiAddiction.Standalone.Runtime.asmdef.meta +3 -0
- package/Standalone/Runtime/gen/ComplianceLocalizationItems.cs +121 -0
- package/Standalone/Runtime/gen/ComplianceLocalizationItems.cs.meta +11 -0
- package/Standalone/Runtime/gen.meta +8 -0
- package/Standalone/Runtime.meta +3 -0
- package/Standalone.meta +3 -0
- package/package.json +12 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using TapSDK.Compliance.Model;
|
|
6
|
+
using TapSDK.Core;
|
|
7
|
+
using TapSDK.Login;
|
|
8
|
+
|
|
9
|
+
namespace TapSDK.Compliance.Internal
|
|
10
|
+
{
|
|
11
|
+
public static class Verification
|
|
12
|
+
{
|
|
13
|
+
internal const int AGE_LIMIT_UNKNOWN = -1;
|
|
14
|
+
internal const int AGE_LIMIT_CHILD = 0;
|
|
15
|
+
internal const int AGE_LIMIT_TEEN = 8;
|
|
16
|
+
internal const int AGE_LIMIT_YOUNG = 16;
|
|
17
|
+
internal const int AGE_LIMIT_ADULT = 18;
|
|
18
|
+
// 已实名,但未同意年龄段信息授权且未成年
|
|
19
|
+
internal const int UNKNOWN_AGE = 100;
|
|
20
|
+
// 已实名,但未同意年龄段信息授权且成年
|
|
21
|
+
internal const int UNKNOWN_AGE_ADULT = 110;
|
|
22
|
+
|
|
23
|
+
static readonly string VERIFICATION_FILENAME = "verification";
|
|
24
|
+
|
|
25
|
+
static readonly string VERIFICATION_V2_FILENAME = "verification_v2";
|
|
26
|
+
static readonly bool DEFAULT_VERIFIED = false;
|
|
27
|
+
static readonly bool DEFAULT_VERIFING = false;
|
|
28
|
+
static readonly bool DEFAULT_ADULT = false;
|
|
29
|
+
|
|
30
|
+
static LocalVerification current;
|
|
31
|
+
|
|
32
|
+
public static LocalVerification Current => current;
|
|
33
|
+
|
|
34
|
+
static Persistence persistence;
|
|
35
|
+
|
|
36
|
+
static Persistence persistenceV2;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// 快速获取身份信息
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <param name="userId"></param>
|
|
43
|
+
public static async Task Fetch(string userId)
|
|
44
|
+
{
|
|
45
|
+
if(current != null && !current.UserId.Equals(userId)){
|
|
46
|
+
Logout(false);
|
|
47
|
+
}
|
|
48
|
+
string filename = Tool.EncryptString(userId);
|
|
49
|
+
// 存储 v2 token 数据
|
|
50
|
+
if(persistenceV2 == null){
|
|
51
|
+
persistenceV2 = new Persistence(Path.Combine(Application.persistentDataPath,
|
|
52
|
+
Config.ANTI_ADDICTION_DIR,
|
|
53
|
+
VERIFICATION_V2_FILENAME,
|
|
54
|
+
filename));
|
|
55
|
+
}
|
|
56
|
+
VerificationResult result;
|
|
57
|
+
try
|
|
58
|
+
{
|
|
59
|
+
LocalVerification localVerification;
|
|
60
|
+
TapLogger.Debug("start check v2 token in local");
|
|
61
|
+
//先检查本地是否有 v2 缓存
|
|
62
|
+
localVerification = await persistenceV2.Load<LocalVerification>();
|
|
63
|
+
if(localVerification != null && localVerification.ComplianceToken != null
|
|
64
|
+
&& localVerification.ComplianceToken.Length > 0){
|
|
65
|
+
current = localVerification;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try{
|
|
69
|
+
await FetchByOldToken(userId);
|
|
70
|
+
}catch(Exception e){
|
|
71
|
+
TapTapAccount tapAccount = await TapTapLogin.Instance.GetCurrentAccount();
|
|
72
|
+
AccessToken accessToken = tapAccount?.accessToken;
|
|
73
|
+
if(HasComplianceAuthInTapToken(accessToken)){
|
|
74
|
+
await FetchByTapToken(userId);
|
|
75
|
+
}else{
|
|
76
|
+
TapLogger.Debug("try get v2 token with userId");
|
|
77
|
+
result = await Network.FetchVerification(userId);
|
|
78
|
+
await Save(userId, result);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (Exception e)
|
|
83
|
+
{
|
|
84
|
+
//首次异常报错
|
|
85
|
+
TapLogger.Debug("try get v2 token failed error: " + e.Message);
|
|
86
|
+
TapLogger.Error(e.ToString());
|
|
87
|
+
throw;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
internal static async Task FetchByOldToken(string userId) {
|
|
92
|
+
TapLogger.Debug("start check v1 token in local");
|
|
93
|
+
string filename = Tool.EncryptString(userId);
|
|
94
|
+
//存储 v1 token数据
|
|
95
|
+
if(persistence == null){
|
|
96
|
+
persistence = new Persistence(Path.Combine(Application.persistentDataPath,
|
|
97
|
+
Config.ANTI_ADDICTION_DIR,
|
|
98
|
+
VERIFICATION_FILENAME,
|
|
99
|
+
filename));
|
|
100
|
+
}
|
|
101
|
+
LocalVerification localVerification = await persistence.Load<LocalVerification>();
|
|
102
|
+
try{
|
|
103
|
+
if(localVerification != null && localVerification.ComplianceToken != null
|
|
104
|
+
&& localVerification.ComplianceToken.Length > 0){
|
|
105
|
+
VerificationResult result = await Network.UpgradeToken(userId, localVerification.ComplianceToken);
|
|
106
|
+
await Save(userId, result);
|
|
107
|
+
persistence.Delete();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}catch(Exception e){
|
|
111
|
+
// 4xx 清除本地缓存
|
|
112
|
+
if(e is ComplianceException aee){
|
|
113
|
+
TapLogger.Debug("get httpCode = " + aee.code + " so remove local old token");
|
|
114
|
+
persistence.Delete();
|
|
115
|
+
}
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
118
|
+
throw new Exception();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
internal static async Task FetchByTapToken(string userId, AccessToken accessToken = null){
|
|
122
|
+
TapLogger.Debug("start check tapToken in local");
|
|
123
|
+
long timestamp = 0;
|
|
124
|
+
int retryTimes = 1;
|
|
125
|
+
VerificationResult result;
|
|
126
|
+
while(true){
|
|
127
|
+
if(accessToken == null){
|
|
128
|
+
///判断本地是否有包含 compliance 的 token
|
|
129
|
+
TapTapAccount tapAccount = await TapTapLogin.Instance.GetCurrentAccount();
|
|
130
|
+
accessToken = tapAccount?.accessToken;
|
|
131
|
+
}
|
|
132
|
+
try{
|
|
133
|
+
if(HasComplianceAuthInTapToken(accessToken)){
|
|
134
|
+
TapLogger.Debug("try use tapToken to get v2 token");
|
|
135
|
+
result = await Network.FetchVerificationByTapToken(userId,accessToken, timestamp);
|
|
136
|
+
await Save(userId, result);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}catch(Exception e){
|
|
140
|
+
//时间戳异常
|
|
141
|
+
if (e is ComplianceException aee && aee.Error != null
|
|
142
|
+
&& aee.Error.Equals(ComplianceConst.SERVER_ERROR_TYPE_INVALID_TIME) && retryTimes > 0)
|
|
143
|
+
{
|
|
144
|
+
timestamp = aee.Now;
|
|
145
|
+
retryTimes--;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
{
|
|
150
|
+
throw e;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw new Exception();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
internal static bool HasComplianceAuthInTapToken(AccessToken accessToken){
|
|
159
|
+
if(accessToken == null){
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
bool useAgeRange = TapTapComplianceManager.config.useAgeRange;
|
|
163
|
+
if(useAgeRange){
|
|
164
|
+
return accessToken.scopeSet != null && accessToken.scopeSet.Contains(ComplianceWorker.SCOPE_COMPLIANCE);
|
|
165
|
+
}else{
|
|
166
|
+
return accessToken.scopeSet != null &&
|
|
167
|
+
(accessToken.scopeSet.Contains(ComplianceWorker.SCOPE_COMPLIANCE) || accessToken.scopeSet.Contains(ComplianceWorker.SCOPE_COMPLIANCE_BASIC));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/// <summary>
|
|
173
|
+
/// 手动输入身份信息
|
|
174
|
+
/// </summary>
|
|
175
|
+
/// <param name="userId"></param>
|
|
176
|
+
/// <param name="userName">身份证姓名</param>
|
|
177
|
+
/// <param name="idCard">身份证号</param>
|
|
178
|
+
/// <returns></returns>
|
|
179
|
+
internal static async Task<VerificationResult> FetchVerificationManual(string userId, string userName, string idCard)
|
|
180
|
+
{
|
|
181
|
+
var tcs = new TaskCompletionSource<VerificationResult>();
|
|
182
|
+
try
|
|
183
|
+
{
|
|
184
|
+
VerificationResult result = await Network.FetchVerificationManual(userName, idCard);
|
|
185
|
+
tcs.SetResult(result);
|
|
186
|
+
await Save(userId, result);
|
|
187
|
+
}
|
|
188
|
+
catch (Exception e)
|
|
189
|
+
{
|
|
190
|
+
tcs.SetException(e);
|
|
191
|
+
TapLogger.Error(e.ToString());
|
|
192
|
+
throw;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return await tcs.Task;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/// <summary>
|
|
199
|
+
/// TapToken 获取实名
|
|
200
|
+
/// </summary>
|
|
201
|
+
/// <param name="userId"></param>
|
|
202
|
+
/// <param name="token">TapToken</param>
|
|
203
|
+
/// <returns></returns>
|
|
204
|
+
public static async Task<VerificationResult> FetchVerificationByTapToken(string userId, AccessToken token)
|
|
205
|
+
{
|
|
206
|
+
var tcs = new TaskCompletionSource<VerificationResult>();
|
|
207
|
+
try
|
|
208
|
+
{
|
|
209
|
+
await FetchByTapToken(userId, token);
|
|
210
|
+
if(persistenceV2 == null){
|
|
211
|
+
var filename = Tool.EncryptString(userId);
|
|
212
|
+
persistenceV2 = new Persistence(Path.Combine(Application.persistentDataPath,
|
|
213
|
+
Config.ANTI_ADDICTION_DIR,
|
|
214
|
+
VERIFICATION_V2_FILENAME,
|
|
215
|
+
filename));
|
|
216
|
+
}
|
|
217
|
+
VerificationResult result = await persistenceV2.Load<VerificationResult>();
|
|
218
|
+
tcs.SetResult(result);
|
|
219
|
+
}
|
|
220
|
+
catch (Exception e)
|
|
221
|
+
{
|
|
222
|
+
tcs.SetException(e);
|
|
223
|
+
TapLogger.Error(e.ToString());
|
|
224
|
+
throw;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return await tcs.Task;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public static async Task Save(string userId, VerificationResult verification)
|
|
231
|
+
{
|
|
232
|
+
current = new LocalVerification(verification)
|
|
233
|
+
{
|
|
234
|
+
UserId = userId
|
|
235
|
+
};
|
|
236
|
+
TapLogger.Debug("try save v2 token to local");
|
|
237
|
+
if(persistenceV2 == null){
|
|
238
|
+
var filename = Tool.EncryptString(userId);
|
|
239
|
+
persistenceV2 = new Persistence(Path.Combine(Application.persistentDataPath,
|
|
240
|
+
Config.ANTI_ADDICTION_DIR,
|
|
241
|
+
VERIFICATION_V2_FILENAME,
|
|
242
|
+
filename));
|
|
243
|
+
}
|
|
244
|
+
await persistenceV2.Save(current);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
public static async Task setAgeState(int ageLimit, bool isAdult){
|
|
248
|
+
if(current != null){
|
|
249
|
+
current.AgeLimit = ageLimit < 0 ?
|
|
250
|
+
(isAdult ? UNKNOWN_AGE_ADULT : UNKNOWN_AGE ) : ageLimit;
|
|
251
|
+
current.IsAdult = isAdult;
|
|
252
|
+
if(persistenceV2 == null){
|
|
253
|
+
var filename = Tool.EncryptString(current.UserId);
|
|
254
|
+
persistenceV2 = new Persistence(Path.Combine(Application.persistentDataPath,
|
|
255
|
+
Config.ANTI_ADDICTION_DIR,
|
|
256
|
+
VERIFICATION_V2_FILENAME,
|
|
257
|
+
filename));
|
|
258
|
+
}
|
|
259
|
+
await persistenceV2.Save(current);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public static void ClearCacheVerfiction(){
|
|
264
|
+
persistence?.Delete();
|
|
265
|
+
persistenceV2?.Delete();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
internal static void Logout(bool needClearCache = true)
|
|
269
|
+
{
|
|
270
|
+
// if (IsVerified && !IsAdult)
|
|
271
|
+
// {
|
|
272
|
+
// #pragma warning disable CS4014
|
|
273
|
+
// Network.CheckPlayable();
|
|
274
|
+
// #pragma warning restore CS4014
|
|
275
|
+
// }
|
|
276
|
+
if(needClearCache){
|
|
277
|
+
ClearCacheVerfiction();
|
|
278
|
+
}
|
|
279
|
+
persistence = null;
|
|
280
|
+
persistenceV2 = null;
|
|
281
|
+
current = null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
internal static string GetCurrentToken()
|
|
285
|
+
{
|
|
286
|
+
return current?.ComplianceToken;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/// <summary>
|
|
290
|
+
/// 是否已认证
|
|
291
|
+
/// </summary>
|
|
292
|
+
public static bool IsVerified => current?.IsVerified ?? DEFAULT_VERIFIED;
|
|
293
|
+
|
|
294
|
+
/// <summary>
|
|
295
|
+
/// 是否在认证中
|
|
296
|
+
/// </summary>
|
|
297
|
+
public static bool IsVerifing => current?.IsVerifing ?? DEFAULT_VERIFING;
|
|
298
|
+
|
|
299
|
+
/// <summary>
|
|
300
|
+
/// 是否认证失败
|
|
301
|
+
/// </summary>
|
|
302
|
+
public static bool IsVerifyFailed => current?.IsVerifyFailed ?? DEFAULT_VERIFING;
|
|
303
|
+
|
|
304
|
+
/// <summary>
|
|
305
|
+
/// 是否是成年人
|
|
306
|
+
/// </summary>
|
|
307
|
+
internal static bool IsAdult => current?.IsAdult ?? DEFAULT_ADULT;
|
|
308
|
+
|
|
309
|
+
/// <summary>
|
|
310
|
+
/// 年龄级别
|
|
311
|
+
/// </summary>
|
|
312
|
+
internal static int AgeLimit => current?.AgeLimit ?? AGE_LIMIT_CHILD;
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
}
|