com.taptap.sdk.login 4.3.0-aplha.5
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 +20 -0
- package/Mobile/Editor/NativeDependencies.xml.meta +7 -0
- package/Mobile/Editor/TapLoginIOSProcessor.cs +91 -0
- package/Mobile/Editor/TapLoginIOSProcessor.cs.meta +11 -0
- package/Mobile/Editor/TapLoginMobileProcessBuild.cs +20 -0
- package/Mobile/Editor/TapLoginMobileProcessBuild.cs.meta +11 -0
- package/Mobile/Editor/TapSDK.Login.Mobile.Editor.asmdef +17 -0
- package/Mobile/Editor/TapSDK.Login.Mobile.Editor.asmdef.meta +7 -0
- package/Mobile/Editor.meta +8 -0
- package/Mobile/Runtime/AccountWrapper.cs +32 -0
- package/Mobile/Runtime/AccountWrapper.cs.meta +3 -0
- package/Mobile/Runtime/TapSDK.Login.Mobile.Runtime.asmdef +20 -0
- package/Mobile/Runtime/TapSDK.Login.Mobile.Runtime.asmdef.meta +7 -0
- package/Mobile/Runtime/TapTapLoginImpl.cs +81 -0
- package/Mobile/Runtime/TapTapLoginImpl.cs.meta +3 -0
- package/Mobile/Runtime.meta +8 -0
- package/Mobile.meta +8 -0
- package/Plugins/iOS/TapTapSDKLoginAppDelegate.mm +40 -0
- package/Plugins/iOS/TapTapSDKLoginAppDelegate.mm.meta +37 -0
- package/Plugins/iOS.meta +8 -0
- package/Plugins/zxing.unity.dll +0 -0
- package/Plugins/zxing.unity.dll.meta +33 -0
- package/Plugins.meta +8 -0
- package/Runtime/Internal/ITapTapLoginPlatform.cs +15 -0
- package/Runtime/Internal/ITapTapLoginPlatform.cs.meta +3 -0
- package/Runtime/Internal/Init/LoginInitTask.cs +20 -0
- package/Runtime/Internal/Init/LoginInitTask.cs.meta +11 -0
- package/Runtime/Internal/Init.meta +8 -0
- package/Runtime/Internal/Region.cs +98 -0
- package/Runtime/Internal/Region.cs.meta +11 -0
- package/Runtime/Internal/TapTapLoginManager.cs +38 -0
- package/Runtime/Internal/TapTapLoginManager.cs.meta +3 -0
- package/Runtime/Internal.meta +8 -0
- package/Runtime/Public/AccessToken.cs +83 -0
- package/Runtime/Public/AccessToken.cs.meta +11 -0
- package/Runtime/Public/Profile.cs +51 -0
- package/Runtime/Public/Profile.cs.meta +11 -0
- package/Runtime/Public/TapTapAccount.cs +70 -0
- package/Runtime/Public/TapTapAccount.cs.meta +3 -0
- package/Runtime/Public/TapTapLogin.cs +39 -0
- package/Runtime/Public/TapTapLogin.cs.meta +3 -0
- package/Runtime/Public/TapTapSdk.cs +26 -0
- package/Runtime/Public/TapTapSdk.cs.meta +11 -0
- package/Runtime/Public.meta +8 -0
- package/Runtime/TapSDK.Login.Runtime.asmdef +15 -0
- package/Runtime/TapSDK.Login.Runtime.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Standalone/Editor/TapLoginStandaloneProcessBuild.cs +22 -0
- package/Standalone/Editor/TapLoginStandaloneProcessBuild.cs.meta +11 -0
- package/Standalone/Editor/TapSDK.Login.Standalone.Editor.asmdef +17 -0
- package/Standalone/Editor/TapSDK.Login.Standalone.Editor.asmdef.meta +7 -0
- package/Standalone/Editor.meta +8 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginPanel.prefab +811 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginPanel.prefab.meta +8 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginWithPermissionPanel.prefab +820 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginWithPermissionPanel.prefab.meta +8 -0
- package/Standalone/Resources/Prefabs/TapLogin/PermissionItem.prefab +314 -0
- package/Standalone/Resources/Prefabs/TapLogin/PermissionItem.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/QRCodeContainer.prefab +1501 -0
- package/Standalone/Resources/Prefabs/TapLogin/QRCodeContainer.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/Tips.prefab +286 -0
- package/Standalone/Resources/Prefabs/TapLogin/Tips.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/TopBar.prefab +485 -0
- package/Standalone/Resources/Prefabs/TapLogin/TopBar.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebContainer.prefab +514 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebContainer.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebWithPermissionContainer.prefab +988 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebWithPermissionContainer.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin.meta +8 -0
- package/Standalone/Resources/Prefabs/TapTapSdkWindow.prefab +175 -0
- package/Standalone/Resources/Prefabs/TapTapSdkWindow.prefab.meta +8 -0
- package/Standalone/Resources/Prefabs.meta +8 -0
- package/Standalone/Resources/Sprites/taptap-client-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-client-bg.png.meta +92 -0
- package/Standalone/Resources/Sprites/taptap-divider.png +0 -0
- package/Standalone/Resources/Sprites/taptap-divider.png.meta +146 -0
- package/Standalone/Resources/Sprites/taptap-login-android-client.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-android-client.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked-v2.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked-v2.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-unchecked.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-unchecked.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-button-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-button-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-confirm-triangle.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-confirm-triangle.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-ios-client.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-ios-client.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-tips-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-tips-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-logo.png +0 -0
- package/Standalone/Resources/Sprites/taptap-logo.png.meta +130 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-error.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-error.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-info.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-info.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-success.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-success.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-warning.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-warning.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-cancel.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-cancel.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-guide.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-guide.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-logo.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-logo.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg-grey.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg-grey.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh-btn-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh-btn-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-tap-log-v2.png +0 -0
- package/Standalone/Resources/Sprites/taptap-tap-log-v2.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-tap-logo.png +0 -0
- package/Standalone/Resources/Sprites/taptap-tap-logo.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon-v2.png +0 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon-v2.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon.png +0 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-web-login.png +0 -0
- package/Standalone/Resources/Sprites/taptap-web-login.png.meta +146 -0
- package/Standalone/Resources/Sprites.meta +8 -0
- package/Standalone/Resources.meta +8 -0
- package/Standalone/Runtime/Internal/ContainerWindow.cs +67 -0
- package/Standalone/Runtime/Internal/ContainerWindow.cs.meta +11 -0
- package/Standalone/Runtime/Internal/LoginLanguage.cs +1117 -0
- package/Standalone/Runtime/Internal/LoginLanguage.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Net.cs +291 -0
- package/Standalone/Runtime/Internal/Net.cs.meta +11 -0
- package/Standalone/Runtime/Internal/QRCodeWindow.cs +776 -0
- package/Standalone/Runtime/Internal/QRCodeWindow.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI.cs +22 -0
- package/Standalone/Runtime/Internal/UI.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIAnimator.cs +77 -0
- package/Standalone/Runtime/Internal/UIAnimator.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIBase.cs +27 -0
- package/Standalone/Runtime/Internal/UIBase.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIElement.cs +185 -0
- package/Standalone/Runtime/Internal/UIElement.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIManager.cs +100 -0
- package/Standalone/Runtime/Internal/UIManager.cs.meta +11 -0
- package/Standalone/Runtime/Internal/WebLoginRequestManager.cs +185 -0
- package/Standalone/Runtime/Internal/WebLoginRequestManager.cs.meta +11 -0
- package/Standalone/Runtime/Internal.meta +8 -0
- package/Standalone/Runtime/Internal2/AccountManager.cs +87 -0
- package/Standalone/Runtime/Internal2/AccountManager.cs.meta +3 -0
- package/Standalone/Runtime/Internal2/AuthorizationProviderImpl.cs +13 -0
- package/Standalone/Runtime/Internal2/AuthorizationProviderImpl.cs.meta +3 -0
- package/Standalone/Runtime/Internal2/Http/LoginHttpClient.cs +139 -0
- package/Standalone/Runtime/Internal2/Http/LoginHttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs +16 -0
- package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/ProfileResponse.cs +28 -0
- package/Standalone/Runtime/Internal2/Http/Response/ProfileResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/QRCodeResponse.cs +22 -0
- package/Standalone/Runtime/Internal2/Http/Response/QRCodeResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/TokenResponse.cs +33 -0
- package/Standalone/Runtime/Internal2/Http/Response/TokenResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response.meta +8 -0
- package/Standalone/Runtime/Internal2/Http.meta +8 -0
- package/Standalone/Runtime/Internal2/LoginService.cs +127 -0
- package/Standalone/Runtime/Internal2/LoginService.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/QRCodeUtils.cs +50 -0
- package/Standalone/Runtime/Internal2/QRCodeUtils.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/TapLoginStandaloneImpl.cs +181 -0
- package/Standalone/Runtime/Internal2/TapLoginStandaloneImpl.cs.meta +3 -0
- package/Standalone/Runtime/Internal2/UI/ClientButtonListener.cs +20 -0
- package/Standalone/Runtime/Internal2/UI/ClientButtonListener.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/LoginPanelController.cs +72 -0
- package/Standalone/Runtime/Internal2/UI/LoginPanelController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/QRCodeController.cs +180 -0
- package/Standalone/Runtime/Internal2/UI/QRCodeController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/TitleController.cs +20 -0
- package/Standalone/Runtime/Internal2/UI/TitleController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/WebController.cs +125 -0
- package/Standalone/Runtime/Internal2/UI/WebController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI.meta +8 -0
- package/Standalone/Runtime/Internal2.meta +8 -0
- package/Standalone/Runtime/Public/IAuthorizationProvider.cs +9 -0
- package/Standalone/Runtime/Public/IAuthorizationProvider.cs.meta +3 -0
- package/Standalone/Runtime/Public/IComplianceProvider.cs +7 -0
- package/Standalone/Runtime/Public/IComplianceProvider.cs.meta +3 -0
- package/Standalone/Runtime/Public/TapTapLoginStandalone.cs +38 -0
- package/Standalone/Runtime/Public/TapTapLoginStandalone.cs.meta +3 -0
- package/Standalone/Runtime/Public.meta +8 -0
- package/Standalone/Runtime/TapSDK.Login.Standalone.Runtime.asmdef +24 -0
- package/Standalone/Runtime/TapSDK.Login.Standalone.Runtime.asmdef.meta +7 -0
- package/Standalone/Runtime.meta +8 -0
- package/Standalone.meta +8 -0
- package/package.json +11 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace TapSDK.Login.Internal
|
|
4
|
+
{
|
|
5
|
+
internal static class UIOperation
|
|
6
|
+
{
|
|
7
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
8
|
+
public static T GetComponent<T>(GameObject obj) where T : Component
|
|
9
|
+
{
|
|
10
|
+
T component = obj.GetComponent<T>();
|
|
11
|
+
|
|
12
|
+
if (component == null)
|
|
13
|
+
{
|
|
14
|
+
component = obj.AddComponent<T>();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return component;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace TapSDK.Login.Internal
|
|
6
|
+
{
|
|
7
|
+
[DisallowMultipleComponent]
|
|
8
|
+
internal class UIAnimator : MonoBehaviour
|
|
9
|
+
{
|
|
10
|
+
public delegate void Action();
|
|
11
|
+
|
|
12
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
13
|
+
public void DoExitAnimation(UIElement exit, UIElement resume, Action onAnimationEnd = null)
|
|
14
|
+
{
|
|
15
|
+
float exitDuration = 0, resumeDuration = 0;
|
|
16
|
+
|
|
17
|
+
if (exit != null)
|
|
18
|
+
{
|
|
19
|
+
exitDuration = exit.DoExitAnimation();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (resume != null)
|
|
23
|
+
{
|
|
24
|
+
resumeDuration = resume.DoResumeAnimation();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
BlockForSecond(Math.Max(exitDuration, resumeDuration) + 0.1f, onAnimationEnd);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public void DoEnterAnimation(UIElement pause, UIElement enter, Action onAnimationEnd = null)
|
|
31
|
+
{
|
|
32
|
+
float pauseDuration = 0, enterDuration = 0;
|
|
33
|
+
|
|
34
|
+
if (pause != null)
|
|
35
|
+
{
|
|
36
|
+
pauseDuration = pause.DoPauseAnimation();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (enter != null)
|
|
40
|
+
{
|
|
41
|
+
enterDuration = enter.DoEnterAnimation();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
BlockForSecond(Math.Max(pauseDuration, enterDuration) + 0.1f, onAnimationEnd);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private void BlockForSecond(float duration, Action callback = null)
|
|
48
|
+
{
|
|
49
|
+
if (duration > 0)
|
|
50
|
+
{
|
|
51
|
+
StartCoroutine(BlockCoroutine(duration, () =>
|
|
52
|
+
{
|
|
53
|
+
if (callback != null)
|
|
54
|
+
{
|
|
55
|
+
callback();
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
{
|
|
61
|
+
if (callback != null)
|
|
62
|
+
{
|
|
63
|
+
callback();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private IEnumerator BlockCoroutine(float blockDuration, Action onBlockEnd = null)
|
|
69
|
+
{
|
|
70
|
+
yield return new WaitForSeconds(blockDuration);
|
|
71
|
+
if (onBlockEnd != null)
|
|
72
|
+
{
|
|
73
|
+
onBlockEnd();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace TapSDK.Login.Internal
|
|
4
|
+
{
|
|
5
|
+
internal class UIBase : MonoBehaviour
|
|
6
|
+
{
|
|
7
|
+
public virtual void OnEnter()
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public virtual void OnPause()
|
|
13
|
+
{
|
|
14
|
+
gameObject.SetActive(false);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public virtual void OnResume()
|
|
18
|
+
{
|
|
19
|
+
gameObject.SetActive(true);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public virtual void OnExit()
|
|
23
|
+
{
|
|
24
|
+
Destroy(gameObject);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Login.Internal
|
|
7
|
+
{
|
|
8
|
+
internal class UIElement : UIBase
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
protected Dictionary<string, object> extra = null;
|
|
12
|
+
public event Action<int, object> Callback;
|
|
13
|
+
|
|
14
|
+
protected bool animationLaunched = false;
|
|
15
|
+
protected float transitionDurationTime = 0.2f;
|
|
16
|
+
|
|
17
|
+
private static readonly int animType = 0;
|
|
18
|
+
|
|
19
|
+
public virtual Dictionary<string, object> Extra
|
|
20
|
+
{
|
|
21
|
+
get
|
|
22
|
+
{
|
|
23
|
+
return extra;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set
|
|
27
|
+
{
|
|
28
|
+
extra = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public UIManager Manager { set; private get; }
|
|
33
|
+
|
|
34
|
+
public void ClearCallback()
|
|
35
|
+
{
|
|
36
|
+
Callback = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected virtual void OnCallback(int code, object data)
|
|
40
|
+
{
|
|
41
|
+
if (Callback != null)
|
|
42
|
+
{
|
|
43
|
+
Callback(code, data);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected UIManager GetUIManager()
|
|
48
|
+
{
|
|
49
|
+
return Manager;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected internal virtual float DoPauseAnimation()
|
|
53
|
+
{
|
|
54
|
+
return 0f;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected internal virtual float DoResumeAnimation()
|
|
58
|
+
{
|
|
59
|
+
return 0f;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected internal virtual float DoExitAnimation()
|
|
63
|
+
{
|
|
64
|
+
StartCoroutine(PlayExit());
|
|
65
|
+
return transitionDurationTime;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected internal virtual float DoEnterAnimation()
|
|
69
|
+
{
|
|
70
|
+
StartCoroutine(PlayEnter());
|
|
71
|
+
return transitionDurationTime;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
75
|
+
public virtual IEnumerator PlayExit()
|
|
76
|
+
{
|
|
77
|
+
if (animType == 0)
|
|
78
|
+
{
|
|
79
|
+
if (!animationLaunched)
|
|
80
|
+
{
|
|
81
|
+
animationLaunched = true;
|
|
82
|
+
float startTime = Time.time;
|
|
83
|
+
float endTime = startTime + transitionDurationTime;
|
|
84
|
+
CanvasGroup canvasGroup = UIOperation.GetComponent<CanvasGroup>(gameObject);
|
|
85
|
+
canvasGroup.alpha = 1f;
|
|
86
|
+
while (Time.time < endTime)
|
|
87
|
+
{
|
|
88
|
+
yield return new WaitForEndOfFrame();
|
|
89
|
+
float delta = (Time.time - startTime) / transitionDurationTime;
|
|
90
|
+
canvasGroup.alpha = 1 - delta;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
animationLaunched = false;
|
|
94
|
+
yield return null;
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
{
|
|
98
|
+
if (!animationLaunched)
|
|
99
|
+
{
|
|
100
|
+
animationLaunched = true;
|
|
101
|
+
float startTime = Time.time;
|
|
102
|
+
float endTime = startTime + transitionDurationTime;
|
|
103
|
+
RectTransform rectTransform = transform.GetComponent<RectTransform>();
|
|
104
|
+
float targetX = rectTransform.position.x + Screen.width / 2 + rectTransform.rect.width / 2 + 200;
|
|
105
|
+
Vector3 startV3 = new Vector3(
|
|
106
|
+
rectTransform.position.x,
|
|
107
|
+
rectTransform.position.y,
|
|
108
|
+
rectTransform.position.z
|
|
109
|
+
);
|
|
110
|
+
rectTransform.position = startV3;
|
|
111
|
+
while (Time.time < endTime)
|
|
112
|
+
{
|
|
113
|
+
yield return new WaitForEndOfFrame();
|
|
114
|
+
float delta = (Time.time - startTime) / transitionDurationTime;
|
|
115
|
+
Vector3 currentV3 = new Vector3(
|
|
116
|
+
rectTransform.position.x + (targetX - rectTransform.position.x) * delta,
|
|
117
|
+
rectTransform.position.y,
|
|
118
|
+
rectTransform.position.z
|
|
119
|
+
);
|
|
120
|
+
rectTransform.position = currentV3;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
animationLaunched = false;
|
|
124
|
+
yield return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public virtual IEnumerator PlayEnter()
|
|
130
|
+
{
|
|
131
|
+
if (animType == 0)
|
|
132
|
+
{
|
|
133
|
+
if (!animationLaunched)
|
|
134
|
+
{
|
|
135
|
+
animationLaunched = true;
|
|
136
|
+
float startTime = Time.time;
|
|
137
|
+
float endTime = startTime + transitionDurationTime;
|
|
138
|
+
CanvasGroup canvasGroup = UIOperation.GetComponent<CanvasGroup>(gameObject);
|
|
139
|
+
canvasGroup.alpha = 0f;
|
|
140
|
+
while (Time.time < endTime)
|
|
141
|
+
{
|
|
142
|
+
yield return new WaitForEndOfFrame();
|
|
143
|
+
float delta = (Time.time - startTime) / transitionDurationTime;
|
|
144
|
+
canvasGroup.alpha = delta;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
animationLaunched = false;
|
|
148
|
+
yield return null;
|
|
149
|
+
}
|
|
150
|
+
else
|
|
151
|
+
{
|
|
152
|
+
if (!animationLaunched)
|
|
153
|
+
{
|
|
154
|
+
animationLaunched = true;
|
|
155
|
+
float startTime = Time.time;
|
|
156
|
+
float endTime = startTime + transitionDurationTime;
|
|
157
|
+
RectTransform rectTransform = transform.GetComponent<RectTransform>();
|
|
158
|
+
float targetX = rectTransform.position.x;
|
|
159
|
+
Vector3 startV3 = new Vector3(
|
|
160
|
+
rectTransform.position.x + Screen.width / 2 + rectTransform.rect.width / 2 + 200,
|
|
161
|
+
rectTransform.position.y,
|
|
162
|
+
rectTransform.position.z
|
|
163
|
+
);
|
|
164
|
+
rectTransform.position = startV3;
|
|
165
|
+
while (Time.time < endTime)
|
|
166
|
+
{
|
|
167
|
+
yield return new WaitForEndOfFrame();
|
|
168
|
+
float delta = (Time.time - startTime) / transitionDurationTime;
|
|
169
|
+
Vector3 currentV3 = new Vector3(
|
|
170
|
+
rectTransform.position.x + (targetX - rectTransform.position.x) * delta,
|
|
171
|
+
rectTransform.position.y,
|
|
172
|
+
rectTransform.position.z
|
|
173
|
+
);
|
|
174
|
+
rectTransform.position = currentV3;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
animationLaunched = false;
|
|
178
|
+
yield return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using Object = UnityEngine.Object;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Login.Internal
|
|
7
|
+
{
|
|
8
|
+
internal class UIManager : MonoBehaviour
|
|
9
|
+
{
|
|
10
|
+
public static readonly int RESULT_FAILED = -1;
|
|
11
|
+
public static readonly int RESULT_SUCCESS = 0;
|
|
12
|
+
public static readonly int RESULT_BACK = 1;
|
|
13
|
+
public static readonly int RESULT_CLOSE = 2;
|
|
14
|
+
|
|
15
|
+
private GameObject containerObj;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
private readonly List<UIElement> uiElements = new List<UIElement>();
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
public void Pop()
|
|
22
|
+
{
|
|
23
|
+
PopUIElement(null);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private void PopUIElement(string targetName)
|
|
27
|
+
{
|
|
28
|
+
if (containerObj == null || uiElements.Count == 0)
|
|
29
|
+
{
|
|
30
|
+
Debug.LogError("No UIElement can be popped.");
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
{
|
|
34
|
+
UIElement element = uiElements[uiElements.Count - 1];
|
|
35
|
+
|
|
36
|
+
if (targetName != null && !targetName.Equals(element.name))
|
|
37
|
+
{
|
|
38
|
+
Debug.LogError("Could not find specify UIElement : " + targetName);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
uiElements.RemoveAt(uiElements.Count - 1);
|
|
43
|
+
|
|
44
|
+
UIElement lastElement = null;
|
|
45
|
+
if (uiElements.Count > 0)
|
|
46
|
+
{
|
|
47
|
+
lastElement = uiElements[uiElements.Count - 1];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
UIAnimator animator = UIOperation.GetComponent<UIAnimator>(containerObj);
|
|
51
|
+
if (lastElement != null)
|
|
52
|
+
{
|
|
53
|
+
lastElement.OnResume();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
animator.DoExitAnimation(element, lastElement, () =>
|
|
57
|
+
{
|
|
58
|
+
element.OnExit();
|
|
59
|
+
if (uiElements.Count == 0)
|
|
60
|
+
{
|
|
61
|
+
DestroyContainer();
|
|
62
|
+
Destroy(gameObject);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private void CreateContainer()
|
|
69
|
+
{
|
|
70
|
+
containerObj = Instantiate(Resources.Load("Prefabs/TapTapSdkWindow")) as GameObject;
|
|
71
|
+
containerObj.name = "TapTapSdkWindow";
|
|
72
|
+
DontDestroyOnLoad(containerObj);
|
|
73
|
+
UIElement containerElement = UIOperation.GetComponent<ContainerWindow>(containerObj);
|
|
74
|
+
UIAnimator containerAnimator = UIOperation.GetComponent<UIAnimator>(containerObj);
|
|
75
|
+
containerElement.Manager = this;
|
|
76
|
+
containerElement.OnEnter();
|
|
77
|
+
containerAnimator.DoEnterAnimation(null, containerElement,
|
|
78
|
+
() =>
|
|
79
|
+
{
|
|
80
|
+
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
85
|
+
private void DestroyContainer()
|
|
86
|
+
{
|
|
87
|
+
if (containerObj != null)
|
|
88
|
+
{
|
|
89
|
+
UIElement containerElement = UIOperation.GetComponent<ContainerWindow>(containerObj);
|
|
90
|
+
UIAnimator containerAnimator = UIOperation.GetComponent<UIAnimator>(containerObj);
|
|
91
|
+
containerElement.OnEnter();
|
|
92
|
+
containerAnimator.DoExitAnimation(containerElement, null, () =>
|
|
93
|
+
{
|
|
94
|
+
Destroy(containerObj);
|
|
95
|
+
containerObj = null;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Net;
|
|
4
|
+
using System.Net.Sockets;
|
|
5
|
+
using System.Security.Cryptography;
|
|
6
|
+
using System.Text;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using TapSDK.Core;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
using Random = System.Random;
|
|
11
|
+
|
|
12
|
+
namespace TapSDK.Login.Internal
|
|
13
|
+
{
|
|
14
|
+
public class WebLoginRequestManager
|
|
15
|
+
{
|
|
16
|
+
private static volatile WebLoginRequestManager _instance;
|
|
17
|
+
private static readonly object ObjLock = new object();
|
|
18
|
+
|
|
19
|
+
public static WebLoginRequestManager Instance
|
|
20
|
+
{
|
|
21
|
+
get
|
|
22
|
+
{
|
|
23
|
+
if (_instance != null) return _instance;
|
|
24
|
+
lock (ObjLock)
|
|
25
|
+
{
|
|
26
|
+
if (_instance == null)
|
|
27
|
+
{
|
|
28
|
+
_instance = new WebLoginRequestManager();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return _instance;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private string _codeVerifier;
|
|
37
|
+
|
|
38
|
+
private WebLoginRequest _currentRequest;
|
|
39
|
+
|
|
40
|
+
public void CreateNewLoginRequest(string[] scopes)
|
|
41
|
+
{
|
|
42
|
+
_codeVerifier = CodeUtil.GenerateCodeVerifier();
|
|
43
|
+
_currentRequest = new WebLoginRequest(scopes, _codeVerifier);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public string GetCodeVerifier()
|
|
47
|
+
{
|
|
48
|
+
return _codeVerifier;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public WebLoginRequest GetCurrentRequest()
|
|
52
|
+
{
|
|
53
|
+
return _currentRequest;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public class WebLoginRequest
|
|
58
|
+
{
|
|
59
|
+
private readonly string[] _scopes;
|
|
60
|
+
private readonly string _state;
|
|
61
|
+
private readonly string _codeChallenge;
|
|
62
|
+
private string _redirectHost;
|
|
63
|
+
|
|
64
|
+
public WebLoginRequest(string[] scopes, string codeVerifier)
|
|
65
|
+
{
|
|
66
|
+
this._scopes = scopes;
|
|
67
|
+
_codeChallenge = CodeUtil.GetCodeChallenge(codeVerifier);
|
|
68
|
+
_state = Guid.NewGuid().ToString("N");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public string GetWebLoginUrl()
|
|
72
|
+
{
|
|
73
|
+
var data = new Dictionary<string, string>
|
|
74
|
+
{
|
|
75
|
+
{ "client_id", TapTapSdk.ClientId },
|
|
76
|
+
{ "response_type", "code" },
|
|
77
|
+
{ "redirect_uri", GetRedirectUri() },
|
|
78
|
+
{ "state", _state },
|
|
79
|
+
{ "code_challenge", _codeChallenge },
|
|
80
|
+
{ "code_challenge_method", "S256" },
|
|
81
|
+
{ "scope", string.Join(",", _scopes) },
|
|
82
|
+
{ "flow", "pc_localhost" }
|
|
83
|
+
};
|
|
84
|
+
var paramStr = MapToParameters(data);
|
|
85
|
+
|
|
86
|
+
return TapTapSdk.CurrentRegion.AccountUrl() + paramStr;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private static string MapToParameters(Dictionary<string, string> data)
|
|
90
|
+
{
|
|
91
|
+
IEnumerable<string> kvs = data
|
|
92
|
+
.Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}");
|
|
93
|
+
return string.Join("&", kvs);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public string GetState()
|
|
97
|
+
{
|
|
98
|
+
return _state;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public string GetRedirectHost()
|
|
102
|
+
{
|
|
103
|
+
if (string.IsNullOrEmpty(_redirectHost))
|
|
104
|
+
{
|
|
105
|
+
_redirectHost = CodeUtil.GetRedirectUri();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return _redirectHost;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public string GetRedirectUri()
|
|
112
|
+
{
|
|
113
|
+
return GetRedirectHost() + "authorize";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public static class CodeUtil
|
|
118
|
+
{
|
|
119
|
+
public static string GetRedirectUri()
|
|
120
|
+
{
|
|
121
|
+
var redirectUri = $"http://{IPAddress.Loopback}:{GetRandomUnusedPort()}/";
|
|
122
|
+
TapLogger.Debug($"redirect uri:{redirectUri}");
|
|
123
|
+
return redirectUri;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public static string GetTapTapOAuthRedirectUri()
|
|
127
|
+
{
|
|
128
|
+
return $"open-taptap-{TapTapSdk.ClientId}://{GetTapTapOAuthPrefix()}";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public static string GetTapTapOAuthPrefix()
|
|
132
|
+
{
|
|
133
|
+
return "authorize";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private static int GetRandomUnusedPort()
|
|
137
|
+
{
|
|
138
|
+
var listener = new TcpListener(IPAddress.Loopback, 0);
|
|
139
|
+
listener.Start();
|
|
140
|
+
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
|
|
141
|
+
listener.Stop();
|
|
142
|
+
return port;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public static string GenerateCodeVerifier()
|
|
146
|
+
{
|
|
147
|
+
const string baseStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
|
|
148
|
+
var random = new Random();
|
|
149
|
+
var builder = new StringBuilder();
|
|
150
|
+
int l = baseStr.Length;
|
|
151
|
+
for (var i = 0; i < 128; i++)
|
|
152
|
+
{
|
|
153
|
+
var number = random.Next(l);
|
|
154
|
+
builder.Append(baseStr[number]);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return builder.ToString();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public static string GetCodeChallenge(string codeVerifier)
|
|
161
|
+
{
|
|
162
|
+
return Base64UrlEncodeNoPadding(SHA256(codeVerifier));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private static string Base64UrlEncodeNoPadding(byte[] buffer)
|
|
166
|
+
{
|
|
167
|
+
var base64 = Convert.ToBase64String(buffer);
|
|
168
|
+
|
|
169
|
+
// Converts base64 to base64url.
|
|
170
|
+
base64 = base64.Replace("+", "-");
|
|
171
|
+
base64 = base64.Replace("/", "_");
|
|
172
|
+
// Strips padding.
|
|
173
|
+
base64 = base64.Replace("=", "");
|
|
174
|
+
|
|
175
|
+
return base64;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private static byte[] SHA256(string inputStirng)
|
|
179
|
+
{
|
|
180
|
+
var bytes = Encoding.ASCII.GetBytes(inputStirng);
|
|
181
|
+
var sha256 = new SHA256Managed();
|
|
182
|
+
return sha256.ComputeHash(bytes);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|