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,253 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System.Threading.Tasks;
|
|
6
|
+
using TapSDK.Compliance.Internal;
|
|
7
|
+
using TapSDK.Compliance.Localization;
|
|
8
|
+
using TapSDK.UI;
|
|
9
|
+
using TapSDK.Compliance.Model;
|
|
10
|
+
using TapSDK.Core;
|
|
11
|
+
using UnityEngine;
|
|
12
|
+
using TapSDK.Login;
|
|
13
|
+
using Network = TapSDK.Compliance.Internal.Network;
|
|
14
|
+
|
|
15
|
+
namespace TapSDK.Compliance
|
|
16
|
+
{
|
|
17
|
+
public class TapTapComplianceManager
|
|
18
|
+
{
|
|
19
|
+
public static string UserId;
|
|
20
|
+
|
|
21
|
+
public static string ClientId { get; private set; }
|
|
22
|
+
|
|
23
|
+
public static TapTapComplianceOption config;
|
|
24
|
+
|
|
25
|
+
private static bool needResumePoll;
|
|
26
|
+
|
|
27
|
+
public static TapTapComplianceOption ComplianceConfig => config == null ? config = new TapTapComplianceOption() : config;
|
|
28
|
+
|
|
29
|
+
public static ComplianceLocalizationItems LocalizationItems
|
|
30
|
+
{
|
|
31
|
+
get
|
|
32
|
+
{
|
|
33
|
+
if (_ComplianceLocalizationItems == null)
|
|
34
|
+
{
|
|
35
|
+
var textAsset = Resources.Load<TextAsset>(ComplianceLocalizationItems.PATH);
|
|
36
|
+
_ComplianceLocalizationItems = ComplianceLocalizationItems.FromJson(textAsset.text);
|
|
37
|
+
}
|
|
38
|
+
return _ComplianceLocalizationItems;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
private static ComplianceLocalizationItems _ComplianceLocalizationItems;
|
|
42
|
+
public static bool CanPlay = false;
|
|
43
|
+
|
|
44
|
+
private static PlayableResult _currentPlayableResult;
|
|
45
|
+
internal static PlayableResult CurrentPlayableResult
|
|
46
|
+
{
|
|
47
|
+
get => _currentPlayableResult;
|
|
48
|
+
set
|
|
49
|
+
{
|
|
50
|
+
if (CurrentRemainSeconds == null)
|
|
51
|
+
{
|
|
52
|
+
CompliancePoll.StartCountdownRemainTime();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (value != null)
|
|
56
|
+
{
|
|
57
|
+
CurrentRemainSeconds = value.RemainTime;
|
|
58
|
+
}
|
|
59
|
+
_currentPlayableResult = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private static UserComplianceConfigResult _currentUserAntiResult;
|
|
64
|
+
public static UserComplianceConfigResult CurrentUserAntiResult
|
|
65
|
+
{
|
|
66
|
+
get => _currentUserAntiResult;
|
|
67
|
+
set
|
|
68
|
+
{
|
|
69
|
+
Config.userLocalConfig = value.localConfig;
|
|
70
|
+
_currentUserAntiResult = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
internal static string CurrentSession = "";
|
|
75
|
+
|
|
76
|
+
internal static int? CurrentRemainSeconds {get; set; }
|
|
77
|
+
|
|
78
|
+
private static BaseComplianceWorker worker;
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
/// 初始化, 建议使用这个接口,因为默认调用了 SetRegion,如果使用另一个 Init 接口,需要在 Init 之后,手动调用 SetRegion
|
|
82
|
+
/// </summary>
|
|
83
|
+
/// <param name="config"></param>
|
|
84
|
+
public static void Init(string clientId, string clientToken, TapTapComplianceOption config)
|
|
85
|
+
{
|
|
86
|
+
if (config == null)
|
|
87
|
+
{
|
|
88
|
+
throw new ArgumentNullException(nameof(config));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
TapTapComplianceManager.config = config;
|
|
92
|
+
if (string.IsNullOrEmpty(clientId))
|
|
93
|
+
{
|
|
94
|
+
throw new ArgumentNullException(nameof(clientId));
|
|
95
|
+
}
|
|
96
|
+
TapTapComplianceManager.ClientId = clientId;
|
|
97
|
+
Network.SetGameInfo(clientId, clientToken);
|
|
98
|
+
Network.InitSetting();
|
|
99
|
+
var textAsset = Resources.Load<TextAsset>(ComplianceLocalizationItems.PATH);
|
|
100
|
+
_ComplianceLocalizationItems = ComplianceLocalizationItems.FromJson(textAsset.text);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public static void SetTestEnvironment(bool enable) {
|
|
104
|
+
Network.SetTestEnvironment(enable);
|
|
105
|
+
if (enable)
|
|
106
|
+
UIManager.Instance.OpenTip("当前处于防沉迷调试模式", Color.red, TextAnchor.UpperRight);
|
|
107
|
+
else {
|
|
108
|
+
UIManager.Instance.CloseTip();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/// <summary>
|
|
112
|
+
/// 启动
|
|
113
|
+
/// </summary>
|
|
114
|
+
/// <param name="userId">用户名</param>
|
|
115
|
+
/// <returns></returns>
|
|
116
|
+
public static async Task<int> StartUp(string userId) {
|
|
117
|
+
if (string.IsNullOrEmpty(userId))
|
|
118
|
+
{
|
|
119
|
+
throw new ArgumentNullException(nameof(userId));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
UserId = userId;
|
|
123
|
+
UIManager.Instance.OpenLoading();
|
|
124
|
+
InitWorker();
|
|
125
|
+
bool isSuccess = await UpdateConfig(userId);
|
|
126
|
+
if(isSuccess){
|
|
127
|
+
return await Worker.StartUp(UserId);
|
|
128
|
+
}else{
|
|
129
|
+
UIManager.Instance.CloseLoading();
|
|
130
|
+
return StartUpResult.INVALID_CLIENT_OR_NETWORK_ERROR;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private static void InitWorker() {
|
|
135
|
+
var worker = Worker;
|
|
136
|
+
TapTapComplianceManager.worker = worker;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private static async Task<bool> UpdateConfig(string userId) {
|
|
140
|
+
return await worker.FetchConfigAsync(userId);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// <summary>
|
|
144
|
+
/// 登出
|
|
145
|
+
/// </summary>
|
|
146
|
+
public static void Logout()
|
|
147
|
+
{
|
|
148
|
+
CurrentRemainSeconds = null;
|
|
149
|
+
CurrentPlayableResult = null;
|
|
150
|
+
Worker.Logout();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
internal static void ClearUserCache(){
|
|
154
|
+
CurrentRemainSeconds = null;
|
|
155
|
+
CurrentPlayableResult = null;
|
|
156
|
+
Worker.Logout(false);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
/// <summary>
|
|
161
|
+
/// 检查支付
|
|
162
|
+
/// </summary>
|
|
163
|
+
/// <param name="amount"></param>
|
|
164
|
+
/// <returns></returns>
|
|
165
|
+
public static async Task<PayableResult> CheckPayLimit(long amount)
|
|
166
|
+
{
|
|
167
|
+
return await Worker.CheckPayableAsync(amount);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/// <summary>
|
|
171
|
+
/// 上报支付
|
|
172
|
+
/// </summary>
|
|
173
|
+
/// <param name="amount"></param>
|
|
174
|
+
/// <returns></returns>
|
|
175
|
+
public static Task SubmitPayResult(long amount)
|
|
176
|
+
{
|
|
177
|
+
return Worker.SubmitPayResult(amount);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/// <summary>
|
|
181
|
+
/// 轮询时,检查可玩性
|
|
182
|
+
/// </summary>
|
|
183
|
+
/// <returns></returns>
|
|
184
|
+
internal static async Task<PlayableResult> CheckPlayableOnPolling()
|
|
185
|
+
{
|
|
186
|
+
CurrentPlayableResult = await Worker.CheckPlayableOnPollingAsync();
|
|
187
|
+
return CurrentPlayableResult;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public static void EnterGame()
|
|
191
|
+
{
|
|
192
|
+
if (CanPlay && needResumePoll)
|
|
193
|
+
{
|
|
194
|
+
TapLogger.Debug("enter game in antiAddiciton " );
|
|
195
|
+
CompliancePoll.StartUp();
|
|
196
|
+
needResumePoll = false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public static void LeaveGame()
|
|
201
|
+
{
|
|
202
|
+
if (CanPlay && CompliancePoll.StartPoll)
|
|
203
|
+
{
|
|
204
|
+
TapLogger.Debug("leave game in antiAddiciton ");
|
|
205
|
+
CompliancePoll.Logout();
|
|
206
|
+
needResumePoll = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// <summary>
|
|
211
|
+
/// 是否使用移动版 UI,否则就是用 Standalone 版本 UI
|
|
212
|
+
/// </summary>
|
|
213
|
+
/// <returns></returns>
|
|
214
|
+
public static bool IsUseMobileUI()
|
|
215
|
+
{
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
public static bool? useMobileUI;
|
|
220
|
+
|
|
221
|
+
#region Worker
|
|
222
|
+
|
|
223
|
+
private static BaseComplianceWorker currentWorker ;
|
|
224
|
+
|
|
225
|
+
private static BaseComplianceWorker GetWorker()
|
|
226
|
+
{
|
|
227
|
+
if (currentWorker == null){
|
|
228
|
+
currentWorker = GetChinaWorker();
|
|
229
|
+
}
|
|
230
|
+
return currentWorker;
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private static BaseComplianceWorker Worker => GetWorker();
|
|
235
|
+
|
|
236
|
+
private static BaseComplianceWorker GetChinaWorker() {
|
|
237
|
+
// get ChinaComplianceWorker from TapSDK.Compliance.Standalone.Runtime dll
|
|
238
|
+
Type baseWorkerType = typeof(BaseComplianceWorker);
|
|
239
|
+
Type[] chinaWorkerType = AppDomain.CurrentDomain.GetAssemblies()
|
|
240
|
+
.Where(asssembly => asssembly.GetName().FullName.StartsWith("TapSDK.Compliance.Standalone.Runtime"))
|
|
241
|
+
.SelectMany(assembly => assembly.GetTypes())
|
|
242
|
+
.Where(clazz => baseWorkerType.IsAssignableFrom(clazz) && clazz.IsClass)
|
|
243
|
+
.ToArray();
|
|
244
|
+
if (chinaWorkerType != null && chinaWorkerType.Length > 0) {
|
|
245
|
+
return Activator.CreateInstance(chinaWorkerType[0]) as BaseComplianceWorker;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#endregion
|
|
252
|
+
}
|
|
253
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System.Security.Cryptography;
|
|
6
|
+
using System.Text;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
|
|
9
|
+
namespace TapSDK.Compliance.Internal
|
|
10
|
+
{
|
|
11
|
+
public static class Tool
|
|
12
|
+
{
|
|
13
|
+
public static int GetMonthDayCount(int year, int month)
|
|
14
|
+
{
|
|
15
|
+
switch (month)
|
|
16
|
+
{
|
|
17
|
+
case 1:
|
|
18
|
+
case 3:
|
|
19
|
+
case 5:
|
|
20
|
+
case 7:
|
|
21
|
+
case 8:
|
|
22
|
+
case 10:
|
|
23
|
+
case 12:
|
|
24
|
+
return 31;
|
|
25
|
+
case 2:
|
|
26
|
+
return IsLeapYear(year) ? 29 : 28;
|
|
27
|
+
default:
|
|
28
|
+
return 30;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static bool IsLeapYear(int year)
|
|
33
|
+
{
|
|
34
|
+
return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// md5加密
|
|
39
|
+
/// </summary>
|
|
40
|
+
/// <param name="str"></param>
|
|
41
|
+
/// <returns></returns>
|
|
42
|
+
public static string EncryptString(string str)
|
|
43
|
+
{
|
|
44
|
+
MD5 md5 = MD5.Create();
|
|
45
|
+
// 将字符串转换成字节数组
|
|
46
|
+
byte[] byteOld = Encoding.UTF8.GetBytes(str);
|
|
47
|
+
// 调用加密方法
|
|
48
|
+
byte[] byteNew = md5.ComputeHash(byteOld);
|
|
49
|
+
// 将加密结果转换为字符串
|
|
50
|
+
StringBuilder sb = new StringBuilder();
|
|
51
|
+
foreach (byte b in byteNew)
|
|
52
|
+
{
|
|
53
|
+
// 将字节转换成16进制表示的字符串,
|
|
54
|
+
sb.Append(b.ToString("x2"));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 返回加密的字符串
|
|
58
|
+
return sb.ToString();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// Encrypt the content with public key (in string)
|
|
63
|
+
/// </summary>
|
|
64
|
+
/// <param name="input"></param>
|
|
65
|
+
/// <param name="key"></param>
|
|
66
|
+
/// <returns></returns>
|
|
67
|
+
public static string RsaEncrypt(string input, string key)
|
|
68
|
+
{
|
|
69
|
+
//https://stackoverflow.com/questions/11506891/how-to-load-the-rsa-public-key-from-file-in-c-sharp
|
|
70
|
+
try
|
|
71
|
+
{
|
|
72
|
+
var base64Info = Convert.FromBase64String(key);
|
|
73
|
+
RSACryptoServiceProvider rsa = DecodeX509PublicKey(base64Info);
|
|
74
|
+
int chunckSize = 245;
|
|
75
|
+
var encodeInfo = Encoding.UTF8.GetBytes(input);
|
|
76
|
+
|
|
77
|
+
// 用来存储加密后的数据的列表
|
|
78
|
+
List<byte[]> encryptedDataList = new List<byte[]>();
|
|
79
|
+
|
|
80
|
+
// 分段加密
|
|
81
|
+
for (int i = 0; i < encodeInfo.Length; i += chunckSize) {
|
|
82
|
+
int blockSize = Math.Min(chunckSize, encodeInfo.Length - i);
|
|
83
|
+
byte[] blockData = new byte[blockSize];
|
|
84
|
+
Buffer.BlockCopy(encodeInfo, i, blockData, 0, blockSize);
|
|
85
|
+
byte[] encryptedBlock = rsa.Encrypt(blockData, false);
|
|
86
|
+
encryptedDataList.Add(encryptedBlock);
|
|
87
|
+
}
|
|
88
|
+
// 将加密后的数据拼接在一起
|
|
89
|
+
byte[] encryptedData = encryptedDataList.SelectMany(x => x).ToArray();
|
|
90
|
+
// 最终的加密结果可以保存到文件或通过网络传输
|
|
91
|
+
string encryptedString = Convert.ToBase64String(encryptedData);
|
|
92
|
+
return encryptedString;
|
|
93
|
+
}
|
|
94
|
+
catch (Exception e)
|
|
95
|
+
{
|
|
96
|
+
Debug.LogErrorFormat("RSA Encrypt Error! input: {0} key: {1}\n Msg: {2}", input, key, e.Message);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private static bool CompareBytearrays(byte[] a, byte[] b)
|
|
102
|
+
{
|
|
103
|
+
if (a.Length != b.Length)
|
|
104
|
+
return false;
|
|
105
|
+
int i = 0;
|
|
106
|
+
foreach (byte c in a)
|
|
107
|
+
{
|
|
108
|
+
if (c != b[i])
|
|
109
|
+
return false;
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private static RSACryptoServiceProvider DecodeX509PublicKey(byte[] x509Key)
|
|
117
|
+
{
|
|
118
|
+
// encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1"
|
|
119
|
+
byte[] seqOid = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 };
|
|
120
|
+
// --------- Set up stream to read the asn.1 encoded SubjectPublicKeyInfo blob ------
|
|
121
|
+
MemoryStream mem = new MemoryStream(x509Key);
|
|
122
|
+
BinaryReader binaryReader = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading
|
|
123
|
+
|
|
124
|
+
try
|
|
125
|
+
{
|
|
126
|
+
|
|
127
|
+
var twoBytes = binaryReader.ReadUInt16();
|
|
128
|
+
if (twoBytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81)
|
|
129
|
+
binaryReader.ReadByte(); //advance 1 byte
|
|
130
|
+
else if (twoBytes == 0x8230)
|
|
131
|
+
binaryReader.ReadInt16(); //advance 2 bytes
|
|
132
|
+
else
|
|
133
|
+
return null;
|
|
134
|
+
|
|
135
|
+
var seq = binaryReader.ReadBytes(15);
|
|
136
|
+
if (!CompareBytearrays(seq, seqOid)) //make sure Sequence for OID is correct
|
|
137
|
+
return null;
|
|
138
|
+
|
|
139
|
+
twoBytes = binaryReader.ReadUInt16();
|
|
140
|
+
if (twoBytes == 0x8103) //data read as little endian order (actual data order for Bit String is 03 81)
|
|
141
|
+
binaryReader.ReadByte(); //advance 1 byte
|
|
142
|
+
else if (twoBytes == 0x8203)
|
|
143
|
+
binaryReader.ReadInt16(); //advance 2 bytes
|
|
144
|
+
else
|
|
145
|
+
return null;
|
|
146
|
+
|
|
147
|
+
var bt = binaryReader.ReadByte();
|
|
148
|
+
if (bt != 0x00) //expect null byte next
|
|
149
|
+
return null;
|
|
150
|
+
|
|
151
|
+
twoBytes = binaryReader.ReadUInt16();
|
|
152
|
+
if (twoBytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81)
|
|
153
|
+
binaryReader.ReadByte(); //advance 1 byte
|
|
154
|
+
else if (twoBytes == 0x8230)
|
|
155
|
+
binaryReader.ReadInt16(); //advance 2 bytes
|
|
156
|
+
else
|
|
157
|
+
return null;
|
|
158
|
+
|
|
159
|
+
twoBytes = binaryReader.ReadUInt16();
|
|
160
|
+
byte lowByte;
|
|
161
|
+
byte highByte = 0x00;
|
|
162
|
+
|
|
163
|
+
if (twoBytes == 0x8102) //data read as little endian order (actual data order for Integer is 02 81)
|
|
164
|
+
lowByte = binaryReader.ReadByte(); // read next bytes which is bytes in modulus
|
|
165
|
+
else if (twoBytes == 0x8202)
|
|
166
|
+
{
|
|
167
|
+
highByte = binaryReader.ReadByte(); //advance 2 bytes
|
|
168
|
+
lowByte = binaryReader.ReadByte();
|
|
169
|
+
}
|
|
170
|
+
else
|
|
171
|
+
return null;
|
|
172
|
+
byte[] modInt = { lowByte, highByte, 0x00, 0x00 }; //reverse byte order since asn.1 key uses big endian order
|
|
173
|
+
int modSize = BitConverter.ToInt32(modInt, 0);
|
|
174
|
+
|
|
175
|
+
byte firstByte = binaryReader.ReadByte();
|
|
176
|
+
binaryReader.BaseStream.Seek(-1, SeekOrigin.Current);
|
|
177
|
+
|
|
178
|
+
if (firstByte == 0x00)
|
|
179
|
+
{ //if first byte (highest order) of modulus is zero, don't include it
|
|
180
|
+
binaryReader.ReadByte(); //skip this null byte
|
|
181
|
+
modSize -= 1; //reduce modulus buffer size by 1
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
byte[] modulus = binaryReader.ReadBytes(modSize); //read the modulus bytes
|
|
185
|
+
|
|
186
|
+
if (binaryReader.ReadByte() != 0x02) //expect an Integer for the exponent data
|
|
187
|
+
return null;
|
|
188
|
+
int expBytes = binaryReader.ReadByte(); // should only need one byte for actual exponent data (for all useful values)
|
|
189
|
+
byte[] exponent = binaryReader.ReadBytes(expBytes);
|
|
190
|
+
|
|
191
|
+
// ------- create RSACryptoServiceProvider instance and initialize with public key -----
|
|
192
|
+
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
|
|
193
|
+
RSAParameters rsaKeyInfo = new RSAParameters
|
|
194
|
+
{
|
|
195
|
+
Modulus = modulus,
|
|
196
|
+
Exponent = exponent
|
|
197
|
+
};
|
|
198
|
+
rsa.ImportParameters(rsaKeyInfo);
|
|
199
|
+
return rsa;
|
|
200
|
+
}
|
|
201
|
+
catch (Exception)
|
|
202
|
+
{
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
finally { binaryReader.Close(); }
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using TapSDK.UI;
|
|
4
|
+
using TapSDK.Compliance.Model;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.UI;
|
|
7
|
+
|
|
8
|
+
namespace TapSDK.Compliance.Internal {
|
|
9
|
+
public class TapTapChinaVerifyFinishPanelController : BasePanelController
|
|
10
|
+
{
|
|
11
|
+
public Text titleText;
|
|
12
|
+
public Text contentText;
|
|
13
|
+
public Text closeTipText;
|
|
14
|
+
public Button okButton;
|
|
15
|
+
public Button closeButton;
|
|
16
|
+
|
|
17
|
+
private float _closeTime = 5.0f;
|
|
18
|
+
private float _elapse;
|
|
19
|
+
|
|
20
|
+
private Action OnOk;
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// bind ugui components for every panel
|
|
24
|
+
/// </summary>
|
|
25
|
+
protected override void BindComponents()
|
|
26
|
+
{
|
|
27
|
+
titleText = transform.Find("Root/TitleText").GetComponent<Text>();
|
|
28
|
+
contentText = transform.Find("Root/ContentText").GetComponent<Text>();
|
|
29
|
+
closeTipText = transform.Find("Root/CloseTipText").GetComponent<Text>();
|
|
30
|
+
okButton = transform.Find("Root/OKButton").GetComponent<Button>();
|
|
31
|
+
closeButton = transform.Find("Root/CloseButton").GetComponent<Button>();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected override void OnLoadSuccess()
|
|
35
|
+
{
|
|
36
|
+
base.OnLoadSuccess();
|
|
37
|
+
|
|
38
|
+
okButton.onClick.AddListener(OnOKButtonClicked);
|
|
39
|
+
closeButton.onClick.AddListener(OnOKButtonClicked);
|
|
40
|
+
|
|
41
|
+
_elapse = 0;
|
|
42
|
+
|
|
43
|
+
StartCoroutine(Countdown());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
internal void Show(PayableResult payable, Action onOk = null)
|
|
47
|
+
{
|
|
48
|
+
// if (payable != null)
|
|
49
|
+
// {
|
|
50
|
+
// titleText.text = payable.Title;
|
|
51
|
+
// contentText.text = payable.Content
|
|
52
|
+
// ?.Replace("<font color=", "<color=")
|
|
53
|
+
// .Replace("</font>", "</color>")
|
|
54
|
+
// .Replace("<br>", "\n");
|
|
55
|
+
// }
|
|
56
|
+
OnOk = onOk;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private void OnOKButtonClicked()
|
|
60
|
+
{
|
|
61
|
+
Close();
|
|
62
|
+
OnOk?.Invoke();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
IEnumerator Countdown()
|
|
66
|
+
{
|
|
67
|
+
int remainTime = 0;
|
|
68
|
+
do
|
|
69
|
+
{
|
|
70
|
+
remainTime = Mathf.CeilToInt(_closeTime - _elapse);
|
|
71
|
+
closeTipText.text = $"即将关闭当前页面({remainTime}s)";
|
|
72
|
+
yield return new WaitForSeconds(1);
|
|
73
|
+
_elapse++;
|
|
74
|
+
|
|
75
|
+
} while (remainTime > 0);
|
|
76
|
+
|
|
77
|
+
Close();
|
|
78
|
+
OnOk?.Invoke();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|