com.xd.sdk.account 6.29.4 → 6.31.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/Plugins/Android/libs/XDGAccount_6.31.0.aar +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/Headers/XDGAccountVersion.h +3 -3
- package/Plugins/iOS/XDAccountSDK.framework/Info.plist +0 -0
- package/Plugins/iOS/XDAccountSDK.framework/XDAccountSDK +0 -0
- package/Runtime/Internal/SecurityPwd/XDGSecurityPasswordResults.cs +110 -0
- package/Runtime/Internal/SecurityPwd/XDGSecurityPasswordResults.cs.meta +3 -0
- package/Runtime/Internal/SecurityPwd.meta +3 -0
- package/Runtime/Internal/XDGUserCenterTracker.cs +1 -0
- package/Runtime/Internal/XDGUserCenterTracker.cs.meta +3 -0
- package/Runtime/XDGAccount.cs +40 -18
- package/Runtime/XDGAccountUnified.cs +53 -0
- package/Runtime/XDGAccountUnified.cs.meta +3 -0
- package/package.json +1 -1
- package/Plugins/Android/libs/XDGAccount_6.29.4.aar +0 -0
- /package/Plugins/Android/libs/{XDGAccount_6.29.4.aar.meta → XDGAccount_6.31.0.aar.meta} +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using LC.Newtonsoft.Json;
|
|
4
|
+
using XD.SDK.Common;
|
|
5
|
+
using XD.SDK.Common.Internal;
|
|
6
|
+
|
|
7
|
+
namespace XD.SDK.Account
|
|
8
|
+
{
|
|
9
|
+
[Serializable]
|
|
10
|
+
public class XDGSecurityPasswordResponse
|
|
11
|
+
{
|
|
12
|
+
[JsonProperty("code")] public int Code { get; set; }
|
|
13
|
+
[JsonProperty("msg")] public string Msg { get; set; }
|
|
14
|
+
|
|
15
|
+
[JsonProperty("page")] public string Page { get; set; }
|
|
16
|
+
[JsonProperty("results")] public XDGSecurityPasswordResults Results { get; set; }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[Serializable]
|
|
20
|
+
public class XDGSecurityPasswordResults
|
|
21
|
+
{
|
|
22
|
+
[JsonProperty("ticket")] public string Ticket { get; set; }
|
|
23
|
+
|
|
24
|
+
/** 操作标识:sdk_setup_security_password / action / change */
|
|
25
|
+
[JsonProperty("action")]
|
|
26
|
+
public string Action { get; set; }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static class XDGSecurityPasswordHelper
|
|
30
|
+
{
|
|
31
|
+
internal static void HandleSecurity(Action<XDGSecurityPasswordResults, XDGError> callback, WebActionEnum webActionEnum, Dictionary<string, object> objects)
|
|
32
|
+
{
|
|
33
|
+
var resp = ParseSecurityPasswordResponse(webActionEnum, objects);
|
|
34
|
+
if (resp != null && resp.Code == 0 &&
|
|
35
|
+
resp.Results != null &&
|
|
36
|
+
!string.IsNullOrEmpty(resp.Results.Ticket) &&
|
|
37
|
+
!string.IsNullOrEmpty(resp.Results.Action))
|
|
38
|
+
{
|
|
39
|
+
callback?.Invoke(resp.Results, null);
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
{
|
|
43
|
+
var err = new XDException(resp?.Code ?? -1, resp?.Msg ?? "unknown error");
|
|
44
|
+
callback?.Invoke(null, err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
internal static XDGSecurityPasswordResponse ParseSecurityPasswordResponse(WebActionEnum actionEnum, Dictionary<string, object> properties)
|
|
49
|
+
{
|
|
50
|
+
// 关闭无参数:返回取消
|
|
51
|
+
if (properties == null)
|
|
52
|
+
{
|
|
53
|
+
if (actionEnum == WebActionEnum.CLOSE)
|
|
54
|
+
{
|
|
55
|
+
return new XDGSecurityPasswordResponse
|
|
56
|
+
{
|
|
57
|
+
Code = -1,
|
|
58
|
+
Msg = "cancel",
|
|
59
|
+
Results = new XDGSecurityPasswordResults()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return new XDGSecurityPasswordResponse { Results = new XDGSecurityPasswordResults() };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var normalized = new Dictionary<string, object>(properties);
|
|
67
|
+
if (normalized.TryGetValue("code", out var codeVal))
|
|
68
|
+
{
|
|
69
|
+
normalized["code"] = ToInt(codeVal);
|
|
70
|
+
}
|
|
71
|
+
if (normalized.TryGetValue("results", out var resultsVal) && resultsVal is string rs && rs.Length > 0)
|
|
72
|
+
{
|
|
73
|
+
char c = rs[0];
|
|
74
|
+
if (c == '{' || c == '[')
|
|
75
|
+
{
|
|
76
|
+
try
|
|
77
|
+
{
|
|
78
|
+
var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(rs);
|
|
79
|
+
if (dict != null)
|
|
80
|
+
{
|
|
81
|
+
normalized["results"] = dict;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch { /* 忽略并保留原值 */ }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var json = JsonConvert.SerializeObject(normalized);
|
|
89
|
+
var resp = JsonConvert.DeserializeObject<XDGSecurityPasswordResponse>(json) ?? new XDGSecurityPasswordResponse();
|
|
90
|
+
if (resp.Results == null)
|
|
91
|
+
{
|
|
92
|
+
resp.Results = new XDGSecurityPasswordResults();
|
|
93
|
+
}
|
|
94
|
+
return resp;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private static int ToInt(object value)
|
|
98
|
+
{
|
|
99
|
+
if (value == null) return 0;
|
|
100
|
+
if (value is int i) return i;
|
|
101
|
+
if (value is long l) return (int)l;
|
|
102
|
+
if (value is float f) return (int)f;
|
|
103
|
+
if (value is double d) return (int)d;
|
|
104
|
+
var s = Convert.ToString(value);
|
|
105
|
+
if (int.TryParse(s, out var iv)) return iv;
|
|
106
|
+
if (double.TryParse(s, out var dv)) return (int)dv;
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
using System;
|
|
2
|
public class XDGUserCenterTracker
|
|
1
3
|
{
|
|
2
4
|
public static Dictionary<string, string> SetPasswordStartProperties()
|
|
3
5
|
{
|
|
4
6
|
return GetCommonProperties("set_password_open");
|
|
5
7
|
}
|
|
6
8
|
public static Dictionary<string, string> ReSetPasswordStartProperties()
|
|
7
9
|
{
|
|
8
10
|
return GetCommonProperties("reset_password_open");
|
|
9
11
|
}
|
|
10
12
|
public static Dictionary<string, string> VerifyPasswordStartProperties()
|
|
11
13
|
{
|
|
12
14
|
return GetCommonProperties("verify_password_open");
|
|
13
15
|
}
|
|
14
16
|
private static Dictionary<string, string> GetCommonProperties(string eventName)
|
|
15
17
|
{
|
|
16
18
|
var eventSessionId = Guid.NewGuid().ToString();
|
|
17
19
|
var utc = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
|
|
18
20
|
var logid = string.Format($"{eventSessionId}{eventName}{utc}");
|
|
19
21
|
return new Dictionary<string, string>
|
|
20
22
|
{
|
|
21
23
|
{ "event_session_id", eventSessionId },
|
|
22
24
|
{ "tag", "usercenter" },
|
|
23
25
|
{ "eventName", eventName },
|
|
24
26
|
{ "logid", logid }
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
}
|
package/Runtime/XDGAccount.cs
CHANGED
|
@@ -7,35 +7,37 @@ using UnityEngine.Scripting;
|
|
|
7
7
|
using XD.SDK.Account;
|
|
8
8
|
using XD.SDK.Common;
|
|
9
9
|
using XD.SDK.Account.Internal;
|
|
10
|
-
|
|
11
10
|
using LoginType = XD.SDK.Account.LoginType;
|
|
12
11
|
|
|
13
12
|
[assembly: Preserve]
|
|
14
13
|
[assembly: AlwaysLinkAssembly]
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
namespace XD.SDK.Account
|
|
16
|
+
{
|
|
16
17
|
public class XDGAccount
|
|
17
18
|
{
|
|
18
19
|
private static IXDGAccount platformWrapper;
|
|
19
20
|
public static LoginType LoginType { get; set; }
|
|
20
|
-
|
|
21
|
-
static XDGAccount()
|
|
21
|
+
|
|
22
|
+
static XDGAccount()
|
|
22
23
|
{
|
|
23
24
|
var interfaceType = typeof(IXDGAccount);
|
|
24
25
|
var platformInterfaceType = AppDomain.CurrentDomain.GetAssemblies()
|
|
25
26
|
.SelectMany(assembly => assembly.GetTypes())
|
|
26
|
-
.FirstOrDefault(clazz => interfaceType.IsAssignableFrom(clazz)&& clazz.IsClass);
|
|
27
|
-
if (platformInterfaceType != null)
|
|
27
|
+
.FirstOrDefault(clazz => interfaceType.IsAssignableFrom(clazz) && clazz.IsClass);
|
|
28
|
+
if (platformInterfaceType != null)
|
|
29
|
+
{
|
|
28
30
|
platformWrapper = Activator.CreateInstance(platformInterfaceType) as IXDGAccount;
|
|
29
31
|
|
|
30
32
|
XDAccountHttpConfig.Init();
|
|
31
33
|
UserManager.Init();
|
|
32
34
|
}
|
|
33
|
-
else
|
|
35
|
+
else
|
|
34
36
|
{
|
|
35
37
|
TapLogger.Error($"No class implements {interfaceType} Type. Current Platform: {Application.platform}, if you are using Editor, please check if you have installed XDSDK pc module.");
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
|
|
39
41
|
public static void Login(List<LoginType> loginTypes, Action<XDGUser> callback, Action<XDGError> errorCallback)
|
|
40
42
|
{
|
|
41
43
|
platformWrapper.Login(loginTypes, callback, errorCallback);
|
|
@@ -56,8 +58,9 @@ namespace XD.SDK.Account{
|
|
|
56
58
|
{
|
|
57
59
|
platformWrapper.Logout();
|
|
58
60
|
}
|
|
59
|
-
|
|
60
|
-
public static void AddUserStatusChangeCallback(Action<XDGUserStatusCodeType, string> callback)
|
|
61
|
+
|
|
62
|
+
public static void AddUserStatusChangeCallback(Action<XDGUserStatusCodeType, string> callback)
|
|
63
|
+
{
|
|
61
64
|
platformWrapper.AddUserStatusChangeCallback(callback);
|
|
62
65
|
}
|
|
63
66
|
|
|
@@ -65,27 +68,31 @@ namespace XD.SDK.Account{
|
|
|
65
68
|
{
|
|
66
69
|
return UserManager.GetCurrentUser();
|
|
67
70
|
}
|
|
68
|
-
|
|
71
|
+
|
|
69
72
|
public static void GetUser(Action<XDGUser> callback, Action<XDGError> errorCallback)
|
|
70
73
|
{
|
|
71
74
|
platformWrapper.GetUser(callback, errorCallback);
|
|
72
75
|
}
|
|
73
|
-
|
|
74
|
-
public static void OpenUserCenter()
|
|
76
|
+
|
|
77
|
+
public static void OpenUserCenter()
|
|
78
|
+
{
|
|
75
79
|
platformWrapper.OpenUserCenter();
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
public static void OpenUnregister()
|
|
82
|
+
public static void OpenUnregister()
|
|
83
|
+
{
|
|
79
84
|
platformWrapper.OpenUnregister();
|
|
80
85
|
}
|
|
81
|
-
|
|
86
|
+
|
|
82
87
|
//641 FB token
|
|
83
|
-
public static void IsTokenActiveWithType(LoginType loginType, Action<bool> callback)
|
|
88
|
+
public static void IsTokenActiveWithType(LoginType loginType, Action<bool> callback)
|
|
89
|
+
{
|
|
84
90
|
platformWrapper.IsTokenActiveWithType(loginType, callback);
|
|
85
91
|
}
|
|
86
|
-
|
|
92
|
+
|
|
87
93
|
//除了 Default 和 Guest
|
|
88
|
-
public static void BindByType(LoginType loginType, Action<bool,XDGError> callback)
|
|
94
|
+
public static void BindByType(LoginType loginType, Action<bool, XDGError> callback)
|
|
95
|
+
{
|
|
89
96
|
platformWrapper.BindByType(loginType, callback);
|
|
90
97
|
}
|
|
91
98
|
|
|
@@ -94,6 +101,21 @@ namespace XD.SDK.Account{
|
|
|
94
101
|
platformWrapper.OpenUserDashboard(roleInfo);
|
|
95
102
|
}
|
|
96
103
|
|
|
104
|
+
public static void SecurityPwdSetUp(Action<XDGSecurityPasswordResults, XDGError> callback)
|
|
105
|
+
{
|
|
106
|
+
XDGAccountUnified.SecurityPwdSetUp(callback);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public static void SecurityPwdAction(string action, Action<XDGSecurityPasswordResults, XDGError> callback)
|
|
110
|
+
{
|
|
111
|
+
XDGAccountUnified.SecurityPwdAction(action, callback);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public static void SecurityPwdChange(Action<bool, XDGError> callback)
|
|
115
|
+
{
|
|
116
|
+
XDGAccountUnified.SecurityPwdChange(callback);
|
|
117
|
+
}
|
|
118
|
+
|
|
97
119
|
public static string GetLoginTypeString(LoginType loginType)
|
|
98
120
|
{
|
|
99
121
|
switch (loginType)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using XD.SDK.Account.Internal;
|
|
3
|
+
using XD.SDK.Common;
|
|
4
|
+
using XD.SDK.Common.Internal;
|
|
5
|
+
|
|
6
|
+
namespace XD.SDK.Account
|
|
7
|
+
{
|
|
8
|
+
public class XDGAccountUnified
|
|
9
|
+
{
|
|
10
|
+
public static void SecurityPwdSetUp(Action<XDGSecurityPasswordResults, XDGError> callback)
|
|
11
|
+
{
|
|
12
|
+
var properties = XDGUserCenterTracker.SetPasswordStartProperties();
|
|
13
|
+
var eventUuid = XDGTracker.LogCommonEvent(properties);
|
|
14
|
+
XDGLogger.Debug($"eventUUId:{eventUuid}");
|
|
15
|
+
properties.TryGetValue("event_session_id", out var eventSessionId);
|
|
16
|
+
var host = XDConfigs.IsCN ? Constants.XD_PERSONAL_INFO_CN : Constants.XD_PERSONAL_INFO_IO;
|
|
17
|
+
var url = $"{host}/security-password/setup?xdClose=0&xdNav=0&xdBgColor=FFFFFF00&sessionUUID={eventUuid}&eventSessionId={eventSessionId}";
|
|
18
|
+
XDGCommon.OpenWebPage(url, (webActionEnum, objects) => { XDGSecurityPasswordHelper.HandleSecurity(callback, webActionEnum, objects); });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static void SecurityPwdAction(string action, Action<XDGSecurityPasswordResults, XDGError> callback)
|
|
22
|
+
{
|
|
23
|
+
var properties = XDGUserCenterTracker.SetPasswordStartProperties();
|
|
24
|
+
var eventUuid = XDGTracker.LogCommonEvent(properties);
|
|
25
|
+
XDGLogger.Debug($"eventUUId:{eventUuid}");
|
|
26
|
+
properties.TryGetValue("event_session_id", out var eventSessionId);
|
|
27
|
+
var host = XDConfigs.IsCN ? Constants.XD_PERSONAL_INFO_CN : Constants.XD_PERSONAL_INFO_IO;
|
|
28
|
+
var url = $"{host}/security-password/verify/{action}?xdClose=0&xdNav=0&xdBgColor=FFFFFF00&sessionUUID={eventUuid}&eventSessionId={eventSessionId}";
|
|
29
|
+
XDGCommon.OpenWebPage(url, (webActionEnum, objects) => { XDGSecurityPasswordHelper.HandleSecurity(callback, webActionEnum, objects); });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static void SecurityPwdChange(Action<bool, XDGError> callback)
|
|
33
|
+
{
|
|
34
|
+
var properties = XDGUserCenterTracker.SetPasswordStartProperties();
|
|
35
|
+
var eventUuid = XDGTracker.LogCommonEvent(properties);
|
|
36
|
+
XDGLogger.Debug($"eventUUId:{eventUuid}");
|
|
37
|
+
properties.TryGetValue("event_session_id", out var eventSessionId);
|
|
38
|
+
var host = XDConfigs.IsCN ? Constants.XD_PERSONAL_INFO_CN : Constants.XD_PERSONAL_INFO_IO;
|
|
39
|
+
var url = $"{host}/security-password/change?xdClose=0&xdNav=0&xdBgColor=FFFFFF00&sessionUUID={eventUuid}&eventSessionId={eventSessionId}";
|
|
40
|
+
XDGCommon.OpenWebPage(url, (webActionEnum, objects) =>
|
|
41
|
+
{
|
|
42
|
+
var response = XDGSecurityPasswordHelper.ParseSecurityPasswordResponse(webActionEnum, objects);
|
|
43
|
+
if (response.Code == 0)
|
|
44
|
+
{
|
|
45
|
+
callback.Invoke(true, null);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
callback.Invoke(false, null);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
package/package.json
CHANGED
|
Binary file
|
|
File without changes
|