com.taptap.sdk.login 4.4.2 → 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.
Files changed (30) hide show
  1. package/Mobile/Editor/NativeDependencies.xml +2 -2
  2. package/Runtime/Internal/Region.cs +6 -18
  3. package/Runtime/Public/TapTapLogin.cs +1 -1
  4. package/Runtime/Public/TapTapSdk.cs +0 -3
  5. package/Standalone/Resources/Sprites/tapsdk-login-client-cn-android.png +0 -0
  6. package/Standalone/Resources/Sprites/{taptap-login-android-client.png.meta → tapsdk-login-client-cn-android.png.meta} +2 -2
  7. package/Standalone/Resources/Sprites/tapsdk-login-client-cn-ios.png +0 -0
  8. package/Standalone/Resources/Sprites/{taptap-login-ios-client.png.meta → tapsdk-login-client-cn-ios.png.meta} +2 -38
  9. package/Standalone/Resources/Sprites/tapsdk-login-client-global-android.png +0 -0
  10. package/Standalone/Resources/Sprites/tapsdk-login-client-global-android.png.meta +92 -0
  11. package/Standalone/Resources/Sprites/tapsdk-login-client-global-ios.png +0 -0
  12. package/Standalone/Resources/Sprites/tapsdk-login-client-global-ios.png.meta +92 -0
  13. package/Standalone/Runtime/Internal2/AccountManager.cs +2 -0
  14. package/Standalone/Runtime/Internal2/Http/Response/ProfileResponse.cs +0 -5
  15. package/Standalone/Runtime/Internal2/Http/Response/QRCodeResponse.cs +0 -5
  16. package/Standalone/Runtime/Internal2/Http/Response/TokenResponse.cs +0 -5
  17. package/Standalone/Runtime/Internal2/Http/TapLoginSign.cs +27 -0
  18. package/Standalone/Runtime/Internal2/Http/{LoginHttpClient.cs.meta → TapLoginSign.cs.meta} +1 -1
  19. package/Standalone/Runtime/Internal2/LoginService.cs +56 -22
  20. package/Standalone/Runtime/Internal2/TapLoginStandaloneImpl.cs +3 -2
  21. package/Standalone/Runtime/Internal2/UI/QRCodeController.cs +16 -19
  22. package/Standalone/Runtime/Internal2/UI/WebController.cs +1 -0
  23. package/package.json +2 -2
  24. package/Standalone/Resources/Sprites/taptap-login-android-client.png +0 -0
  25. package/Standalone/Resources/Sprites/taptap-login-ios-client.png +0 -0
  26. package/Standalone/Runtime/Internal2/Http/LoginHttpClient.cs +0 -139
  27. package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs +0 -16
  28. package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs.meta +0 -11
  29. package/link.xml +0 -4
  30. package/link.xml.meta +0 -7
@@ -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.4.2"/>
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.4.0" bitcodeEnabled="false" addToAllTargets="false"/>
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 isRND ? webHostRND : webHost;
49
+ return webHost;
58
50
  }
59
51
 
60
52
  public override string ApiHost()
61
53
  {
62
- return isRND ? apiHostRND : apiHost;
54
+ return apiHost;
63
55
  }
64
56
 
65
57
  public override string AccountHost()
66
58
  {
67
- return isRND ? accountHostRND : accountHost;
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 isRND ? webHostRND : webHost;
72
+ return webHost;
85
73
  }
86
74
 
87
75
  public override string ApiHost()
88
76
  {
89
- return isRND ? apiHostRND : apiHost;
77
+ return apiHost;
90
78
  }
91
79
 
92
80
  public override string AccountHost()
93
81
  {
94
- return isRND ? accountHostRND : accountHost;
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.4.2";
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";
@@ -8,9 +8,6 @@ namespace TapSDK.Login.Internal
8
8
  {
9
9
  public static class TapTapSdk
10
10
  {
11
- // todo
12
- public const string Version = "4.3.10";
13
-
14
11
  public static string ClientId { get; private set; }
15
12
 
16
13
  public static Region CurrentRegion { get; private set; }
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 4b5153c44d44441ab840b57d857ccb66
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: 0
39
+ wrapW: 1
40
40
  nPOTScale: 0
41
41
  lightmap: 0
42
42
  compressionQuality: 50
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: d0d91238b4da84ff39e0ba9920b1a022
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: 0
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:
@@ -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:
@@ -47,10 +47,12 @@ namespace TapSDK.Login.Internal
47
47
  if (value == null)
48
48
  {
49
49
  DataStorage.SaveString(_account, null);
50
+ TapAppDurationStandalone.OnLogout();
50
51
  }
51
52
  else
52
53
  {
53
54
  DataStorage.SaveString(_account, value.ToJson());
55
+ TapAppDurationStandalone.OnLogin(value?.openId);
54
56
  }
55
57
  }
56
58
  }
@@ -20,9 +20,4 @@ namespace TapSDK.Login.Internal.Http {
20
20
  [JsonProperty("email")]
21
21
  public string Email { get; set; }
22
22
  }
23
-
24
- public class ProfileResponse {
25
- [JsonProperty("data")]
26
- public ProfileData Data { get; set; }
27
- }
28
23
  }
@@ -14,9 +14,4 @@ namespace TapSDK.Login.Internal.Http {
14
14
  [JsonProperty("interval")]
15
15
  public int Interval { get; set; }
16
16
  }
17
-
18
- public class QRCodeResponse {
19
- [JsonProperty("data")]
20
- public QRCodeData Data { get; set; }
21
- }
22
17
  }
@@ -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
+ }
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: e3ed262175bd04db487ef5c3f3b5953d
2
+ guid: 3c6306bc968684651bbdec346cc621ca
3
3
  MonoImporter:
4
4
  externalObjects: {}
5
5
  serializedVersion: 2
@@ -5,29 +5,37 @@ 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.Service;
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 LoginHttpClient httpClient = new LoginHttpClient();
15
-
16
- public static LoginHttpClient HttpClient => httpClient;
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, object> data = new Dictionary<string, object> {
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) },
24
- { "version", TapTapSdk.Version },
26
+ { "version", TapTapLogin.Version },
25
27
  { "platform", "unity" },
26
28
  { "info", "{\"device_id\":\"" + SystemInfo.deviceModel + "\"}" }
27
29
  };
28
- QRCodeResponse response = await httpClient.Post<QRCodeResponse>(TapTapSdk.CurrentRegion.CodeUrl(),
29
- data: data);
30
- return response.Data;
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
- TokenResponse response = await httpClient.Post<TokenResponse>(TapTapSdk.CurrentRegion.TokenUrl(),
44
- data: data);
45
- return response.Data;
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
- TokenResponse response = await httpClient.Post<TokenResponse>(TapTapSdk.CurrentRegion.TokenUrl(),
60
- data: data);
61
- return response.Data;
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, object> headers = new Dictionary<string, object> {
101
+ Dictionary<string, string> headers = new Dictionary<string, string> {
82
102
  { "Authorization", sign }
83
103
  };
84
- ProfileResponse response = await httpClient.Get<ProfileResponse>(url, headers: headers);
85
- return response.Data;
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, object> data = new Dictionary<string, object> {
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
- TokenResponse response = await httpClient.Post<TokenResponse>(TapTapSdk.CurrentRegion.TokenUrl(),
134
- data: data);
135
- return response.Data;
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(TapException e){
159
+ }catch(TapHttpServerException e){
159
160
  //清除本地缓存
160
- if(e.code < 0 ){
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 DEMO_IMAGE_CN_HOST = "https://sdk-assets.tds1.tapfiles.cn";
14
- private readonly static string DEMO_IMAGE_URL_IOS_ZH = $"{DEMO_IMAGE_CN_HOST}/scan-guide/ios.png";
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 DEMO_IMAGE_IO_HOST = "https://sdk-assets.ap-sg.tdsfiles.com";
18
- private readonly static string DEMO_IMAGE_URL_IOS_EN = $"{DEMO_IMAGE_IO_HOST}/scan-guide/ios.png";
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 (TapException e) {
116
+ } catch (TapHttpServerException e) {
117
+ string errorMsg = e.ErrorData?.Error ?? "";
122
118
  ILoginLang lang = LoginLanguage.GetCurrentLang();
123
- if (e.Message == AUTH_PENDING) {
119
+ if (errorMsg == AUTH_PENDING) {
124
120
 
125
- } else if (e.Message == AUTH_WAITING) {
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 (e.Message == AUTH_DENIED) {
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 = DEMO_IMAGE_URL_IOS_ZH;
140
+ string url = DEFAULT_CLIENT_CN_IOS;
145
141
  if (TapTapSDK.taptapSdkOptions != null && TapTapSDK.taptapSdkOptions.region == TapTapRegionType.Overseas) {
146
- url = DEMO_IMAGE_URL_IOS_EN;
142
+ url = DEFAULT_CLIENT_GLOBAL_IOS;
147
143
  }
148
144
  ShowDemoImage(url);
149
145
  }
150
146
 
151
147
  private void OnShowAndroidDemoImage() {
152
- string url = DEMO_IMAGE_URL_ANDROID_ZH;
148
+ string url = DEFAULT_CLIENT_CN_ANDROID;
153
149
  if (TapTapSDK.taptapSdkOptions != null && TapTapSDK.taptapSdkOptions.region == TapTapRegionType.Overseas) {
154
- url = DEMO_IMAGE_URL_ANDROID_EN;
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 = await ImageUtils.LoadImage(url);
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
  }
@@ -62,6 +62,7 @@ namespace TapSDK.Login.Internal {
62
62
  WebLoginRequestManager.Instance.CreateNewLoginRequest(scopes);
63
63
 
64
64
  string url = WebLoginRequestManager.Instance.GetCurrentRequest().GetWebLoginUrl();
65
+ TapLog.Log("WebController , OpenURL : " + url);
65
66
  Application.OpenURL(url);
66
67
 
67
68
  // 启动监听
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.4.2",
5
+ "version": "4.5.0",
6
6
  "unity": "2019.4",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.taptap.sdk.core": "4.4.2"
9
+ "com.taptap.sdk.core": "4.5.0"
10
10
  }
11
11
  }
@@ -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
- }
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: bf3ced9270c8442a4a7c2158841ccad8
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
package/link.xml DELETED
@@ -1,4 +0,0 @@
1
- <linker>
2
- <assembly fullname="TapSDK.Login.Runtime" preserve="all" />
3
- <assembly fullname="TapSDK.Login.Mobile.Runtime" preserve="all" />
4
- </linker>
package/link.xml.meta DELETED
@@ -1,7 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: be71b67c0945c40c0817e128f2bff96a
3
- TextScriptImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant: