com.taptap.sdk.login 4.4.3 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Mobile/Editor/NativeDependencies.xml +2 -2
- package/Runtime/Internal/Region.cs +6 -18
- package/Runtime/Public/TapTapLogin.cs +1 -1
- package/Standalone/Resources/Sprites/tapsdk-login-client-cn-android.png +0 -0
- package/Standalone/Resources/Sprites/{taptap-login-android-client.png.meta → tapsdk-login-client-cn-android.png.meta} +2 -2
- package/Standalone/Resources/Sprites/tapsdk-login-client-cn-ios.png +0 -0
- package/Standalone/Resources/Sprites/{taptap-login-ios-client.png.meta → tapsdk-login-client-cn-ios.png.meta} +2 -38
- package/Standalone/Resources/Sprites/tapsdk-login-client-global-android.png +0 -0
- package/Standalone/Resources/Sprites/tapsdk-login-client-global-android.png.meta +92 -0
- package/Standalone/Resources/Sprites/tapsdk-login-client-global-ios.png +0 -0
- package/Standalone/Resources/Sprites/tapsdk-login-client-global-ios.png.meta +92 -0
- package/Standalone/Runtime/Internal2/Http/Response/ProfileResponse.cs +0 -5
- package/Standalone/Runtime/Internal2/Http/Response/QRCodeResponse.cs +0 -5
- package/Standalone/Runtime/Internal2/Http/Response/TokenResponse.cs +0 -5
- package/Standalone/Runtime/Internal2/Http/TapLoginSign.cs +27 -0
- package/Standalone/Runtime/Internal2/Http/{LoginHttpClient.cs.meta → TapLoginSign.cs.meta} +1 -1
- package/Standalone/Runtime/Internal2/LoginService.cs +55 -21
- package/Standalone/Runtime/Internal2/TapLoginStandaloneImpl.cs +3 -2
- package/Standalone/Runtime/Internal2/UI/QRCodeController.cs +16 -19
- package/package.json +2 -2
- package/Standalone/Resources/Sprites/taptap-login-android-client.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-ios-client.png +0 -0
- package/Standalone/Runtime/Internal2/Http/LoginHttpClient.cs +0 -139
- package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs +0 -16
- package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs.meta +0 -11
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
6
|
</repositories>
|
|
7
|
-
<androidPackage spec="com.taptap.sdk:tap-login-unity:4.
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-login-unity:4.5.0"/>
|
|
8
8
|
</androidPackages>
|
|
9
9
|
<iosPods>
|
|
10
10
|
<sources>
|
|
11
11
|
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
12
12
|
</sources>
|
|
13
13
|
<iosPod name="Kingfisher" version="~> 6.0" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
14
|
-
<iosPod name="TapTapLoginSDK" version="~> 4.
|
|
14
|
+
<iosPod name="TapTapLoginSDK" version="~> 4.5.0" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
15
15
|
</iosPods>
|
|
16
16
|
</dependencies>
|
|
@@ -2,8 +2,6 @@ namespace TapSDK.Login.Internal
|
|
|
2
2
|
{
|
|
3
3
|
public abstract class Region
|
|
4
4
|
{
|
|
5
|
-
protected static bool isRND = false;
|
|
6
|
-
|
|
7
5
|
public abstract string WebHost();
|
|
8
6
|
|
|
9
7
|
public abstract string ApiHost();
|
|
@@ -46,25 +44,19 @@ namespace TapSDK.Login.Internal
|
|
|
46
44
|
|
|
47
45
|
private static string accountHost = "https://accounts.taptap.cn";
|
|
48
46
|
|
|
49
|
-
private static string webHostRND = "https://oauth.api.xdrnd.cn";
|
|
50
|
-
|
|
51
|
-
private static string apiHostRND = "https://open.api.xdrnd.cn";
|
|
52
|
-
|
|
53
|
-
private static string accountHostRND = "https://accounts-beta.xdrnd.cn";
|
|
54
|
-
|
|
55
47
|
public override string WebHost()
|
|
56
48
|
{
|
|
57
|
-
return
|
|
49
|
+
return webHost;
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
public override string ApiHost()
|
|
61
53
|
{
|
|
62
|
-
return
|
|
54
|
+
return apiHost;
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
public override string AccountHost()
|
|
66
58
|
{
|
|
67
|
-
return
|
|
59
|
+
return accountHost;
|
|
68
60
|
}
|
|
69
61
|
|
|
70
62
|
}
|
|
@@ -75,23 +67,19 @@ namespace TapSDK.Login.Internal
|
|
|
75
67
|
private static string apiHost = "https://open.tapapis.com";
|
|
76
68
|
private static string accountHost = "https://accounts.taptap.io";
|
|
77
69
|
|
|
78
|
-
private static string webHostRND = "https://oauth.api.xdrnd.com";
|
|
79
|
-
private static string apiHostRND = "https://open.api.xdrnd.com";
|
|
80
|
-
private static string accountHostRND = "https://accounts-io-beta.xdrnd.com";
|
|
81
|
-
|
|
82
70
|
public override string WebHost()
|
|
83
71
|
{
|
|
84
|
-
return
|
|
72
|
+
return webHost;
|
|
85
73
|
}
|
|
86
74
|
|
|
87
75
|
public override string ApiHost()
|
|
88
76
|
{
|
|
89
|
-
return
|
|
77
|
+
return apiHost;
|
|
90
78
|
}
|
|
91
79
|
|
|
92
80
|
public override string AccountHost()
|
|
93
81
|
{
|
|
94
|
-
return
|
|
82
|
+
return accountHost;
|
|
95
83
|
}
|
|
96
84
|
|
|
97
85
|
}
|
|
@@ -7,7 +7,7 @@ namespace TapSDK.Login
|
|
|
7
7
|
public class TapTapLogin
|
|
8
8
|
{
|
|
9
9
|
|
|
10
|
-
public static readonly string Version = "4.
|
|
10
|
+
public static readonly string Version = "4.5.0";
|
|
11
11
|
|
|
12
12
|
public const string TAP_LOGIN_SCOPE_BASIC_INFO = "basic_info";
|
|
13
13
|
public const string TAP_LOGIN_SCOPE_PUBLIC_PROFILE = "public_profile";
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
fileFormatVersion: 2
|
|
2
|
-
guid:
|
|
2
|
+
guid: e38788d43832b4897aa451bc9f3cb2b4
|
|
3
3
|
TextureImporter:
|
|
4
4
|
internalIDToNameTable: []
|
|
5
5
|
externalObjects: {}
|
|
@@ -36,7 +36,7 @@ TextureImporter:
|
|
|
36
36
|
mipBias: 0
|
|
37
37
|
wrapU: 1
|
|
38
38
|
wrapV: 1
|
|
39
|
-
wrapW:
|
|
39
|
+
wrapW: 1
|
|
40
40
|
nPOTScale: 0
|
|
41
41
|
lightmap: 0
|
|
42
42
|
compressionQuality: 50
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
fileFormatVersion: 2
|
|
2
|
-
guid:
|
|
2
|
+
guid: 788e0772bd246491aab010b1272ec919
|
|
3
3
|
TextureImporter:
|
|
4
4
|
internalIDToNameTable: []
|
|
5
5
|
externalObjects: {}
|
|
@@ -36,7 +36,7 @@ TextureImporter:
|
|
|
36
36
|
mipBias: 0
|
|
37
37
|
wrapU: 1
|
|
38
38
|
wrapV: 1
|
|
39
|
-
wrapW:
|
|
39
|
+
wrapW: 1
|
|
40
40
|
nPOTScale: 0
|
|
41
41
|
lightmap: 0
|
|
42
42
|
compressionQuality: 50
|
|
@@ -71,42 +71,6 @@ TextureImporter:
|
|
|
71
71
|
overridden: 0
|
|
72
72
|
androidETC2FallbackOverride: 0
|
|
73
73
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
74
|
-
- serializedVersion: 3
|
|
75
|
-
buildTarget: Standalone
|
|
76
|
-
maxTextureSize: 2048
|
|
77
|
-
resizeAlgorithm: 0
|
|
78
|
-
textureFormat: -1
|
|
79
|
-
textureCompression: 1
|
|
80
|
-
compressionQuality: 50
|
|
81
|
-
crunchedCompression: 0
|
|
82
|
-
allowsAlphaSplitting: 0
|
|
83
|
-
overridden: 0
|
|
84
|
-
androidETC2FallbackOverride: 0
|
|
85
|
-
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
86
|
-
- serializedVersion: 3
|
|
87
|
-
buildTarget: iPhone
|
|
88
|
-
maxTextureSize: 2048
|
|
89
|
-
resizeAlgorithm: 0
|
|
90
|
-
textureFormat: -1
|
|
91
|
-
textureCompression: 1
|
|
92
|
-
compressionQuality: 50
|
|
93
|
-
crunchedCompression: 0
|
|
94
|
-
allowsAlphaSplitting: 0
|
|
95
|
-
overridden: 0
|
|
96
|
-
androidETC2FallbackOverride: 0
|
|
97
|
-
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
98
|
-
- serializedVersion: 3
|
|
99
|
-
buildTarget: Android
|
|
100
|
-
maxTextureSize: 2048
|
|
101
|
-
resizeAlgorithm: 0
|
|
102
|
-
textureFormat: -1
|
|
103
|
-
textureCompression: 1
|
|
104
|
-
compressionQuality: 50
|
|
105
|
-
crunchedCompression: 0
|
|
106
|
-
allowsAlphaSplitting: 0
|
|
107
|
-
overridden: 0
|
|
108
|
-
androidETC2FallbackOverride: 0
|
|
109
|
-
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
110
74
|
spriteSheet:
|
|
111
75
|
serializedVersion: 2
|
|
112
76
|
sprites: []
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 3fbe7ff9924f040c8858c551bdd67c5c
|
|
3
|
+
TextureImporter:
|
|
4
|
+
internalIDToNameTable: []
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
serializedVersion: 11
|
|
7
|
+
mipmaps:
|
|
8
|
+
mipMapMode: 0
|
|
9
|
+
enableMipMap: 0
|
|
10
|
+
sRGBTexture: 1
|
|
11
|
+
linearTexture: 0
|
|
12
|
+
fadeOut: 0
|
|
13
|
+
borderMipMap: 0
|
|
14
|
+
mipMapsPreserveCoverage: 0
|
|
15
|
+
alphaTestReferenceValue: 0.5
|
|
16
|
+
mipMapFadeDistanceStart: 1
|
|
17
|
+
mipMapFadeDistanceEnd: 3
|
|
18
|
+
bumpmap:
|
|
19
|
+
convertToNormalMap: 0
|
|
20
|
+
externalNormalMap: 0
|
|
21
|
+
heightScale: 0.25
|
|
22
|
+
normalMapFilter: 0
|
|
23
|
+
isReadable: 0
|
|
24
|
+
streamingMipmaps: 0
|
|
25
|
+
streamingMipmapsPriority: 0
|
|
26
|
+
grayScaleToAlpha: 0
|
|
27
|
+
generateCubemap: 6
|
|
28
|
+
cubemapConvolution: 0
|
|
29
|
+
seamlessCubemap: 0
|
|
30
|
+
textureFormat: 1
|
|
31
|
+
maxTextureSize: 2048
|
|
32
|
+
textureSettings:
|
|
33
|
+
serializedVersion: 2
|
|
34
|
+
filterMode: 1
|
|
35
|
+
aniso: 1
|
|
36
|
+
mipBias: 0
|
|
37
|
+
wrapU: 1
|
|
38
|
+
wrapV: 1
|
|
39
|
+
wrapW: 1
|
|
40
|
+
nPOTScale: 0
|
|
41
|
+
lightmap: 0
|
|
42
|
+
compressionQuality: 50
|
|
43
|
+
spriteMode: 1
|
|
44
|
+
spriteExtrude: 1
|
|
45
|
+
spriteMeshType: 1
|
|
46
|
+
alignment: 0
|
|
47
|
+
spritePivot: {x: 0.5, y: 0.5}
|
|
48
|
+
spritePixelsToUnits: 100
|
|
49
|
+
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
50
|
+
spriteGenerateFallbackPhysicsShape: 1
|
|
51
|
+
alphaUsage: 1
|
|
52
|
+
alphaIsTransparency: 1
|
|
53
|
+
spriteTessellationDetail: -1
|
|
54
|
+
textureType: 8
|
|
55
|
+
textureShape: 1
|
|
56
|
+
singleChannelComponent: 0
|
|
57
|
+
maxTextureSizeSet: 0
|
|
58
|
+
compressionQualitySet: 0
|
|
59
|
+
textureFormatSet: 0
|
|
60
|
+
applyGammaDecoding: 0
|
|
61
|
+
platformSettings:
|
|
62
|
+
- serializedVersion: 3
|
|
63
|
+
buildTarget: DefaultTexturePlatform
|
|
64
|
+
maxTextureSize: 2048
|
|
65
|
+
resizeAlgorithm: 0
|
|
66
|
+
textureFormat: -1
|
|
67
|
+
textureCompression: 1
|
|
68
|
+
compressionQuality: 50
|
|
69
|
+
crunchedCompression: 0
|
|
70
|
+
allowsAlphaSplitting: 0
|
|
71
|
+
overridden: 0
|
|
72
|
+
androidETC2FallbackOverride: 0
|
|
73
|
+
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
74
|
+
spriteSheet:
|
|
75
|
+
serializedVersion: 2
|
|
76
|
+
sprites: []
|
|
77
|
+
outline: []
|
|
78
|
+
physicsShape: []
|
|
79
|
+
bones: []
|
|
80
|
+
spriteID: 5e97eb03825dee720800000000000000
|
|
81
|
+
internalID: 0
|
|
82
|
+
vertices: []
|
|
83
|
+
indices:
|
|
84
|
+
edges: []
|
|
85
|
+
weights: []
|
|
86
|
+
secondaryTextures: []
|
|
87
|
+
spritePackingTag:
|
|
88
|
+
pSDRemoveMatte: 0
|
|
89
|
+
pSDShowRemoveMatteOption: 0
|
|
90
|
+
userData:
|
|
91
|
+
assetBundleName:
|
|
92
|
+
assetBundleVariant:
|
|
Binary file
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 63974b91ba2c14a8b937b229d4e686bc
|
|
3
|
+
TextureImporter:
|
|
4
|
+
internalIDToNameTable: []
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
serializedVersion: 11
|
|
7
|
+
mipmaps:
|
|
8
|
+
mipMapMode: 0
|
|
9
|
+
enableMipMap: 0
|
|
10
|
+
sRGBTexture: 1
|
|
11
|
+
linearTexture: 0
|
|
12
|
+
fadeOut: 0
|
|
13
|
+
borderMipMap: 0
|
|
14
|
+
mipMapsPreserveCoverage: 0
|
|
15
|
+
alphaTestReferenceValue: 0.5
|
|
16
|
+
mipMapFadeDistanceStart: 1
|
|
17
|
+
mipMapFadeDistanceEnd: 3
|
|
18
|
+
bumpmap:
|
|
19
|
+
convertToNormalMap: 0
|
|
20
|
+
externalNormalMap: 0
|
|
21
|
+
heightScale: 0.25
|
|
22
|
+
normalMapFilter: 0
|
|
23
|
+
isReadable: 0
|
|
24
|
+
streamingMipmaps: 0
|
|
25
|
+
streamingMipmapsPriority: 0
|
|
26
|
+
grayScaleToAlpha: 0
|
|
27
|
+
generateCubemap: 6
|
|
28
|
+
cubemapConvolution: 0
|
|
29
|
+
seamlessCubemap: 0
|
|
30
|
+
textureFormat: 1
|
|
31
|
+
maxTextureSize: 2048
|
|
32
|
+
textureSettings:
|
|
33
|
+
serializedVersion: 2
|
|
34
|
+
filterMode: 1
|
|
35
|
+
aniso: 1
|
|
36
|
+
mipBias: 0
|
|
37
|
+
wrapU: 1
|
|
38
|
+
wrapV: 1
|
|
39
|
+
wrapW: 1
|
|
40
|
+
nPOTScale: 0
|
|
41
|
+
lightmap: 0
|
|
42
|
+
compressionQuality: 50
|
|
43
|
+
spriteMode: 1
|
|
44
|
+
spriteExtrude: 1
|
|
45
|
+
spriteMeshType: 1
|
|
46
|
+
alignment: 0
|
|
47
|
+
spritePivot: {x: 0.5, y: 0.5}
|
|
48
|
+
spritePixelsToUnits: 100
|
|
49
|
+
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
50
|
+
spriteGenerateFallbackPhysicsShape: 1
|
|
51
|
+
alphaUsage: 1
|
|
52
|
+
alphaIsTransparency: 1
|
|
53
|
+
spriteTessellationDetail: -1
|
|
54
|
+
textureType: 8
|
|
55
|
+
textureShape: 1
|
|
56
|
+
singleChannelComponent: 0
|
|
57
|
+
maxTextureSizeSet: 0
|
|
58
|
+
compressionQualitySet: 0
|
|
59
|
+
textureFormatSet: 0
|
|
60
|
+
applyGammaDecoding: 0
|
|
61
|
+
platformSettings:
|
|
62
|
+
- serializedVersion: 3
|
|
63
|
+
buildTarget: DefaultTexturePlatform
|
|
64
|
+
maxTextureSize: 2048
|
|
65
|
+
resizeAlgorithm: 0
|
|
66
|
+
textureFormat: -1
|
|
67
|
+
textureCompression: 1
|
|
68
|
+
compressionQuality: 50
|
|
69
|
+
crunchedCompression: 0
|
|
70
|
+
allowsAlphaSplitting: 0
|
|
71
|
+
overridden: 0
|
|
72
|
+
androidETC2FallbackOverride: 0
|
|
73
|
+
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
74
|
+
spriteSheet:
|
|
75
|
+
serializedVersion: 2
|
|
76
|
+
sprites: []
|
|
77
|
+
outline: []
|
|
78
|
+
physicsShape: []
|
|
79
|
+
bones: []
|
|
80
|
+
spriteID: 5e97eb03825dee720800000000000000
|
|
81
|
+
internalID: 0
|
|
82
|
+
vertices: []
|
|
83
|
+
indices:
|
|
84
|
+
edges: []
|
|
85
|
+
weights: []
|
|
86
|
+
secondaryTextures: []
|
|
87
|
+
spritePackingTag:
|
|
88
|
+
pSDRemoveMatte: 0
|
|
89
|
+
pSDShowRemoveMatteOption: 0
|
|
90
|
+
userData:
|
|
91
|
+
assetBundleName:
|
|
92
|
+
assetBundleVariant:
|
|
@@ -25,9 +25,4 @@ namespace TapSDK.Login.Internal.Http {
|
|
|
25
25
|
public HashSet<string> Scopes => !string.IsNullOrEmpty(Scope) ?
|
|
26
26
|
new HashSet<string>(Scope.Split(' ')) : new HashSet<string>();
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
public class TokenResponse {
|
|
30
|
-
[JsonProperty("data")]
|
|
31
|
-
public TokenData Data { get; set; }
|
|
32
|
-
}
|
|
33
28
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Net.Http;
|
|
3
|
+
using TapSDK.Core.Standalone.Internal.Http;
|
|
4
|
+
|
|
5
|
+
namespace TapSDK.Login.Standalone.Internal.Http
|
|
6
|
+
{
|
|
7
|
+
internal class TapLoginSign : ITapHttpSign
|
|
8
|
+
{
|
|
9
|
+
public Dictionary<string, string> GetFixedHeaders(string url, HttpMethod method, string moduleName, string moduleVersion, bool enableAuthorization)
|
|
10
|
+
{
|
|
11
|
+
return new Dictionary<string, string>
|
|
12
|
+
{
|
|
13
|
+
{ "User-Agent", TapHttpUtils.GenerateUserAgent()},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public Dictionary<string, string> GetFixedQueryParams()
|
|
18
|
+
{
|
|
19
|
+
return new Dictionary<string, string>();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public void Sign(HttpRequestMessage signData)
|
|
23
|
+
{
|
|
24
|
+
// Do nothing
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -5,19 +5,21 @@ using System.Security.Cryptography;
|
|
|
5
5
|
using System.Text;
|
|
6
6
|
using UnityEngine;
|
|
7
7
|
using TapSDK.Login.Internal.Http;
|
|
8
|
-
using TapSDK.Core.Standalone.Internal.
|
|
8
|
+
using TapSDK.Core.Standalone.Internal.Http;
|
|
9
|
+
using TapSDK.Login.Standalone.Internal.Http;
|
|
9
10
|
|
|
10
11
|
namespace TapSDK.Login.Internal
|
|
11
12
|
{
|
|
12
13
|
public static class LoginService
|
|
13
14
|
{
|
|
14
|
-
private static readonly
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
private static readonly TapHttp tapHttp = TapHttp
|
|
16
|
+
.NewBuilder("TapLogin", TapTapLogin.Version)
|
|
17
|
+
.Sign(new TapLoginSign())
|
|
18
|
+
.Build();
|
|
17
19
|
|
|
18
20
|
public static async Task<QRCodeData> GetQRCodeUrl(string clientId, string[] scopes)
|
|
19
21
|
{
|
|
20
|
-
Dictionary<string,
|
|
22
|
+
Dictionary<string, string> data = new Dictionary<string, string> {
|
|
21
23
|
{ "client_id", clientId },
|
|
22
24
|
{ "response_type", "device_code" },
|
|
23
25
|
{ "scope", string.Join(",", scopes) },
|
|
@@ -25,9 +27,15 @@ namespace TapSDK.Login.Internal
|
|
|
25
27
|
{ "platform", "unity" },
|
|
26
28
|
{ "info", "{\"device_id\":\"" + SystemInfo.deviceModel + "\"}" }
|
|
27
29
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
TapHttpResult<QRCodeData> result = await tapHttp.PostFormAsync<QRCodeData>(TapTapSdk.CurrentRegion.CodeUrl(), form: data);
|
|
31
|
+
if (result.IsSuccess)
|
|
32
|
+
{
|
|
33
|
+
return result.Data;
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
{
|
|
37
|
+
throw result.HttpException;
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
public static async Task<TokenData> Authorize(string clientId, string code)
|
|
@@ -40,9 +48,15 @@ namespace TapSDK.Login.Internal
|
|
|
40
48
|
{ "redirect_uri", WebLoginRequestManager.Instance.GetCurrentRequest().GetRedirectUri() },
|
|
41
49
|
{ "code_verifier", WebLoginRequestManager.Instance.GetCodeVerifier() }
|
|
42
50
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
TapHttpResult<TokenData> result = await tapHttp.PostFormAsync<TokenData>(TapTapSdk.CurrentRegion.TokenUrl(), form: data);
|
|
52
|
+
if (result.IsSuccess)
|
|
53
|
+
{
|
|
54
|
+
return result.Data;
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
{
|
|
58
|
+
throw result.HttpException;
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
public static async Task<TokenData> RequestScanQRCodeResult(string clientId, string deviceCode)
|
|
@@ -56,9 +70,15 @@ namespace TapSDK.Login.Internal
|
|
|
56
70
|
{ "platform", "unity" },
|
|
57
71
|
{ "info", "{\"device_id\":\"" + SystemInfo.deviceModel + "\"}" }
|
|
58
72
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
TapHttpResult<TokenData> result = await tapHttp.PostFormAsync<TokenData>(TapTapSdk.CurrentRegion.TokenUrl(), form: data);
|
|
74
|
+
if (result.IsSuccess)
|
|
75
|
+
{
|
|
76
|
+
return result.Data;
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
{
|
|
80
|
+
throw result.HttpException;
|
|
81
|
+
}
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
public static async Task<ProfileData> GetProfile(string clientId, AccessToken token, int timestamp = 0)
|
|
@@ -78,11 +98,19 @@ namespace TapSDK.Login.Internal
|
|
|
78
98
|
uri.PathAndQuery,
|
|
79
99
|
uri.Host,
|
|
80
100
|
"443", ts);
|
|
81
|
-
Dictionary<string,
|
|
101
|
+
Dictionary<string, string> headers = new Dictionary<string, string> {
|
|
82
102
|
{ "Authorization", sign }
|
|
83
103
|
};
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
|
|
105
|
+
TapHttpResult<ProfileData> result = await tapHttp.GetAsync<ProfileData>(url, headers: headers);
|
|
106
|
+
if(result.IsSuccess)
|
|
107
|
+
{
|
|
108
|
+
return result.Data;
|
|
109
|
+
}
|
|
110
|
+
else
|
|
111
|
+
{
|
|
112
|
+
throw result.HttpException;
|
|
113
|
+
}
|
|
86
114
|
}
|
|
87
115
|
|
|
88
116
|
public static string GetAuthorizationHeader(string kid,
|
|
@@ -122,7 +150,7 @@ namespace TapSDK.Login.Internal
|
|
|
122
150
|
|
|
123
151
|
public static async Task<TokenData> RefreshToken(string clientId, string accessToken)
|
|
124
152
|
{
|
|
125
|
-
Dictionary<string,
|
|
153
|
+
Dictionary<string, string> data = new Dictionary<string, string> {
|
|
126
154
|
{ "client_id", clientId },
|
|
127
155
|
{ "grant_type", "refresh_token" },
|
|
128
156
|
{ "token", accessToken },
|
|
@@ -130,9 +158,15 @@ namespace TapSDK.Login.Internal
|
|
|
130
158
|
{ "platform", "unity" },
|
|
131
159
|
{ "info", "{\"device_id\":\"" + SystemInfo.deviceModel + "\"}" }
|
|
132
160
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
161
|
+
TapHttpResult<TokenData> result = await tapHttp.PostFormAsync<TokenData>(TapTapSdk.CurrentRegion.TokenUrl(), form: data);
|
|
162
|
+
if(result.IsSuccess)
|
|
163
|
+
{
|
|
164
|
+
return result.Data;
|
|
165
|
+
}
|
|
166
|
+
else
|
|
167
|
+
{
|
|
168
|
+
throw result.HttpException;
|
|
169
|
+
}
|
|
136
170
|
}
|
|
137
171
|
}
|
|
138
172
|
}
|
|
@@ -4,6 +4,7 @@ using System.Linq;
|
|
|
4
4
|
using System.Threading.Tasks;
|
|
5
5
|
using TapSDK.Core;
|
|
6
6
|
using TapSDK.Core.Internal.Utils;
|
|
7
|
+
using TapSDK.Core.Standalone.Internal.Http;
|
|
7
8
|
using TapSDK.Login.Internal.Http;
|
|
8
9
|
using TapSDK.Login.Standalone;
|
|
9
10
|
using TapSDK.Login.Standalone.Internal;
|
|
@@ -155,9 +156,9 @@ namespace TapSDK.Login.Internal
|
|
|
155
156
|
TokenData tokenData = null;
|
|
156
157
|
try{
|
|
157
158
|
tokenData = await LoginService.RefreshToken(TapTapSdk.ClientId, accessToken.kid);
|
|
158
|
-
}catch(
|
|
159
|
+
}catch(TapHttpServerException e){
|
|
159
160
|
//清除本地缓存
|
|
160
|
-
if(e.
|
|
161
|
+
if(e.ErrorData.Code < 0 ){
|
|
161
162
|
Logout();
|
|
162
163
|
}
|
|
163
164
|
return;
|
|
@@ -7,19 +7,15 @@ using TapSDK.Core;
|
|
|
7
7
|
using TapSDK.Core.Internal.Utils;
|
|
8
8
|
using UnityEngine.EventSystems;
|
|
9
9
|
using TapSDK.Core.Internal.Log;
|
|
10
|
+
using TapSDK.Core.Standalone.Internal.Http;
|
|
10
11
|
|
|
11
12
|
namespace TapSDK.Login.Internal {
|
|
12
13
|
public class QRCodeController {
|
|
13
|
-
private readonly static string
|
|
14
|
-
private readonly static string
|
|
15
|
-
private readonly static string DEMO_IMAGE_URL_ANDROID_ZH = $"{DEMO_IMAGE_CN_HOST}/scan-guide/android.png";
|
|
14
|
+
private readonly static string DEFAULT_CLIENT_CN_IOS = "Sprites/tapsdk-login-client-cn-ios";
|
|
15
|
+
private readonly static string DEFAULT_CLIENT_CN_ANDROID = "Sprites/tapsdk-login-client-cn-android";
|
|
16
16
|
|
|
17
|
-
private readonly static string
|
|
18
|
-
private readonly static string
|
|
19
|
-
private readonly static string DEMO_IMAGE_URL_ANDROID_EN = $"{DEMO_IMAGE_IO_HOST}/scan-guide/android.png";
|
|
20
|
-
|
|
21
|
-
// private readonly static string DEFAULT_IOS_CLIENT = "Sprites/taptap-login-ios-client";
|
|
22
|
-
// private readonly static string DEFAULT_ANDROID_CLIENT = "Sprites/taptap-login-android-client";
|
|
17
|
+
private readonly static string DEFAULT_CLIENT_GLOBAL_IOS = "Sprites/tapsdk-login-client-global-ios";
|
|
18
|
+
private readonly static string DEFAULT_CLIENT_GLOBAL_ANDROID = "Sprites/tapsdk-login-client-global-android";
|
|
23
19
|
|
|
24
20
|
private readonly static string AUTH_PENDING = "authorization_pending";
|
|
25
21
|
private readonly static string AUTH_WAITING = "authorization_waiting";
|
|
@@ -116,17 +112,17 @@ namespace TapSDK.Login.Internal {
|
|
|
116
112
|
TokenData tokenData = await LoginService.RequestScanQRCodeResult(clientId, qrcodeData.DeviceCode);
|
|
117
113
|
TapLog.Log("Login , QRCodeController Success");
|
|
118
114
|
onAuth.Invoke(tokenData, "pc_code");
|
|
119
|
-
|
|
120
115
|
return ;
|
|
121
|
-
} catch (
|
|
116
|
+
} catch (TapHttpServerException e) {
|
|
117
|
+
string errorMsg = e.ErrorData?.Error ?? "";
|
|
122
118
|
ILoginLang lang = LoginLanguage.GetCurrentLang();
|
|
123
|
-
if (
|
|
119
|
+
if (errorMsg == AUTH_PENDING) {
|
|
124
120
|
|
|
125
|
-
} else if (
|
|
121
|
+
} else if (errorMsg == AUTH_WAITING) {
|
|
126
122
|
UI.UIManager.Instance.OpenToast(true,
|
|
127
123
|
$"{lang.QrnNoticeSuccess()},{lang.QrnNoticeSuccess2()}",
|
|
128
124
|
icon: UI.UIManager.WhiteToastSuccessIcon);
|
|
129
|
-
} else if (
|
|
125
|
+
} else if (errorMsg == AUTH_DENIED) {
|
|
130
126
|
UI.UIManager.Instance.OpenToast(true,
|
|
131
127
|
$"{lang.QrNoticeCancel()},{lang.QrNoticeCancel2()}",
|
|
132
128
|
icon: UI.UIManager.WhiteToastErrorIcon);
|
|
@@ -141,17 +137,17 @@ namespace TapSDK.Login.Internal {
|
|
|
141
137
|
}
|
|
142
138
|
|
|
143
139
|
private void OnShowIOSDemoImage() {
|
|
144
|
-
string url =
|
|
140
|
+
string url = DEFAULT_CLIENT_CN_IOS;
|
|
145
141
|
if (TapTapSDK.taptapSdkOptions != null && TapTapSDK.taptapSdkOptions.region == TapTapRegionType.Overseas) {
|
|
146
|
-
url =
|
|
142
|
+
url = DEFAULT_CLIENT_GLOBAL_IOS;
|
|
147
143
|
}
|
|
148
144
|
ShowDemoImage(url);
|
|
149
145
|
}
|
|
150
146
|
|
|
151
147
|
private void OnShowAndroidDemoImage() {
|
|
152
|
-
string url =
|
|
148
|
+
string url = DEFAULT_CLIENT_CN_ANDROID;
|
|
153
149
|
if (TapTapSDK.taptapSdkOptions != null && TapTapSDK.taptapSdkOptions.region == TapTapRegionType.Overseas) {
|
|
154
|
-
url =
|
|
150
|
+
url = DEFAULT_CLIENT_GLOBAL_ANDROID;
|
|
155
151
|
}
|
|
156
152
|
ShowDemoImage(url);
|
|
157
153
|
}
|
|
@@ -160,8 +156,9 @@ namespace TapSDK.Login.Internal {
|
|
|
160
156
|
demoImage.texture = null;
|
|
161
157
|
scanTips.SetActive(true);
|
|
162
158
|
try {
|
|
163
|
-
demoImage.texture =
|
|
159
|
+
demoImage.texture = Resources.Load<Texture2D>(url);
|
|
164
160
|
} catch (Exception) {
|
|
161
|
+
TapLog.Log("Load demo image failed : " + url);
|
|
165
162
|
demoImage.texture = null;
|
|
166
163
|
}
|
|
167
164
|
}
|
package/package.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"name": "com.taptap.sdk.login",
|
|
3
3
|
"displayName": "TapTapSDK Login",
|
|
4
4
|
"description": "TapTapSDK Login",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.5.0",
|
|
6
6
|
"unity": "2019.4",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"com.taptap.sdk.core": "4.
|
|
9
|
+
"com.taptap.sdk.core": "4.5.0"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Net;
|
|
3
|
-
using System.Text;
|
|
4
|
-
using System.Linq;
|
|
5
|
-
using System.Collections.Generic;
|
|
6
|
-
using System.Net.Http;
|
|
7
|
-
using System.Net.Http.Headers;
|
|
8
|
-
using System.Threading.Tasks;
|
|
9
|
-
using System.Security.Cryptography;
|
|
10
|
-
using Newtonsoft.Json;
|
|
11
|
-
using TapSDK.Core;
|
|
12
|
-
using TapSDK.Core.Internal.Json;
|
|
13
|
-
using TapSDK.Core.Internal.Http;
|
|
14
|
-
|
|
15
|
-
namespace TapSDK.Login.Internal.Http {
|
|
16
|
-
public class LoginHttpClient {
|
|
17
|
-
private readonly HttpClient client;
|
|
18
|
-
|
|
19
|
-
public LoginHttpClient() {
|
|
20
|
-
client = new HttpClient();
|
|
21
|
-
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public Task<T> Get<T>(string url,
|
|
25
|
-
Dictionary<string, object> headers = null,
|
|
26
|
-
Dictionary<string, object> queryParams = null) {
|
|
27
|
-
return Request<T>(url, HttpMethod.Get, headers, null, queryParams);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public Task<T> Post<T>(string url,
|
|
31
|
-
Dictionary<string, object> headers = null,
|
|
32
|
-
object data = null,
|
|
33
|
-
Dictionary<string, object> queryParams = null) {
|
|
34
|
-
return Request<T>(url, HttpMethod.Post, headers, data, queryParams);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public Task<T> Put<T>(string url,
|
|
38
|
-
Dictionary<string, object> headers = null,
|
|
39
|
-
object data = null,
|
|
40
|
-
Dictionary<string, object> queryParams = null) {
|
|
41
|
-
return Request<T>(url, HttpMethod.Put, headers, data, queryParams);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public Task Delete(string url,
|
|
45
|
-
Dictionary<string, object> headers = null,
|
|
46
|
-
object data = null,
|
|
47
|
-
Dictionary<string, object> queryParams = null) {
|
|
48
|
-
return Request<Dictionary<string, object>>(url, HttpMethod.Delete, headers, data, queryParams);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async Task<T> Request<T>(string url,
|
|
52
|
-
HttpMethod method,
|
|
53
|
-
Dictionary<string, object> headers = null,
|
|
54
|
-
object data = null,
|
|
55
|
-
Dictionary<string, object> queryParams = null) {
|
|
56
|
-
url = BuildUrl(url, queryParams);
|
|
57
|
-
HttpRequestMessage request = new HttpRequestMessage {
|
|
58
|
-
RequestUri = new Uri(url),
|
|
59
|
-
Method = method,
|
|
60
|
-
};
|
|
61
|
-
FillHeaders(request.Headers, headers);
|
|
62
|
-
|
|
63
|
-
string content = null;
|
|
64
|
-
if (data != null) {
|
|
65
|
-
content = JsonConvert.SerializeObject(data);
|
|
66
|
-
Dictionary<string, string> formData = JsonConvert.DeserializeObject<Dictionary<string, object>>(content)
|
|
67
|
-
.ToDictionary(item => item.Key, item => item.Value.ToString());
|
|
68
|
-
FormUrlEncodedContent requestContent = new FormUrlEncodedContent(formData);
|
|
69
|
-
request.Content = requestContent;
|
|
70
|
-
}
|
|
71
|
-
TapHttpUtils.PrintRequest(client, request, content);
|
|
72
|
-
HttpResponseMessage response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
|
73
|
-
request.Dispose();
|
|
74
|
-
|
|
75
|
-
string resultString = await response.Content.ReadAsStringAsync();
|
|
76
|
-
response.Dispose();
|
|
77
|
-
TapHttpUtils.PrintResponse(response, resultString);
|
|
78
|
-
|
|
79
|
-
if (response.IsSuccessStatusCode) {
|
|
80
|
-
T ret = JsonConvert.DeserializeObject<T>(resultString,
|
|
81
|
-
TapJsonConverter.Default);
|
|
82
|
-
return ret;
|
|
83
|
-
}
|
|
84
|
-
throw HandleErrorResponse(response.StatusCode, resultString);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
TapException HandleErrorResponse(HttpStatusCode statusCode, string responseContent) {
|
|
88
|
-
int code = (int)statusCode;
|
|
89
|
-
string message = responseContent;
|
|
90
|
-
try {
|
|
91
|
-
ErrorResponse response = JsonConvert.DeserializeObject<ErrorResponse>(responseContent,
|
|
92
|
-
TapJsonConverter.Default);
|
|
93
|
-
code = response.Data.Code;
|
|
94
|
-
message = response.Data.Error;
|
|
95
|
-
} catch (Exception e) {
|
|
96
|
-
TapLogger.Error(e);
|
|
97
|
-
}
|
|
98
|
-
return new TapException(code, message);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
string BuildUrl(string url, Dictionary<string, object> queryParams) {
|
|
102
|
-
if (queryParams != null) {
|
|
103
|
-
IEnumerable<string> queryPairs = queryParams.Select(kv => $"{kv.Key}={kv.Value}");
|
|
104
|
-
string queries = string.Join("&", queryPairs);
|
|
105
|
-
url = $"{url}?{queries}";
|
|
106
|
-
}
|
|
107
|
-
return url;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
void FillHeaders(HttpRequestHeaders headers, Dictionary<string, object> reqHeaders = null) {
|
|
111
|
-
// 额外 headers
|
|
112
|
-
if (reqHeaders != null) {
|
|
113
|
-
foreach (KeyValuePair<string, object> kv in reqHeaders) {
|
|
114
|
-
headers.Add(kv.Key, kv.Value.ToString());
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 签名
|
|
119
|
-
long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
120
|
-
string hash = GetMd5Hash($"{timestamp}");
|
|
121
|
-
string sign = $"{hash},{timestamp}";
|
|
122
|
-
headers.Add("X-LC-Sign", sign);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
static string GetMd5Hash(string input) {
|
|
126
|
-
MD5 md5 = MD5.Create();
|
|
127
|
-
byte[] data = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
|
|
128
|
-
return ToHex(data);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static string ToHex(byte[] bytes) {
|
|
132
|
-
StringBuilder sb = new StringBuilder();
|
|
133
|
-
for (int i = 0; i < bytes.Length; i++) {
|
|
134
|
-
sb.Append(bytes[i].ToString("x2"));
|
|
135
|
-
}
|
|
136
|
-
return sb.ToString();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
using Newtonsoft.Json;
|
|
2
|
-
|
|
3
|
-
namespace TapSDK.Login.Internal.Http {
|
|
4
|
-
public class ErrorData {
|
|
5
|
-
[JsonProperty("code")]
|
|
6
|
-
public int Code { get; set; }
|
|
7
|
-
|
|
8
|
-
[JsonProperty("error")]
|
|
9
|
-
public string Error { get; set; }
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public class ErrorResponse {
|
|
13
|
-
[JsonProperty("data")]
|
|
14
|
-
public ErrorData Data { get; set; }
|
|
15
|
-
}
|
|
16
|
-
}
|