com.xd.sdk.account 7.1.2 → 7.2.1-alpha

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.
@@ -4,6 +4,6 @@
4
4
  //
5
5
  // Created by Fattycat on 2023/4/14.
6
6
  //
7
- #define XDGAccount_VERSION @"7.1.2"
8
- #define XDSAccount_VERSION_CODE @"7001020"
9
- // HASH 5355bc04
7
+ #define XDGAccount_VERSION @"7.2.0"
8
+ #define XDSAccount_VERSION_CODE @"7020000"
9
+ // HASH 8d15387e
@@ -299,13 +299,12 @@ namespace XD.SDK.Account.Internal.Mobile
299
299
  try
300
300
  {
301
301
  var result = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TdsSDKGetUser);
302
- var objectId = XDDictionary.GetValue<string>(result, "objectId");
302
+ var objectId = XDDictionary.GetValue<string>(result.GetValueOrThrow(), "objectId");
303
303
  if (objectId == user.UserId)
304
304
  {
305
305
  return;
306
306
  }
307
307
 
308
- //TODO 同步之前先退登 TDSUser
309
308
  XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
310
309
  var response = await HttpClient.PostAsync<LoginSyncResponse>(LoginSynUrl);
311
310
  var sessionToken = XDDictionary.GetValue<string>(response.Data, "sessionToken");
@@ -317,9 +316,9 @@ namespace XD.SDK.Account.Internal.Mobile
317
316
 
318
317
  XDGEventBus.Publish(XDGEvents.TdsSDKSyncUser, sessionToken, user.UserId);
319
318
  }
320
- catch (Exception e)
319
+ catch (XDGError e)
321
320
  {
322
- XDGLogger.Warn($"[SyncTDSUser] error:{e.Message}", XDGLoggerTag.Bridge);
321
+ XDGLogger.Warn($"[SyncTDSUser] error:{e.ErrorMsg}", XDGLoggerTag.Bridge);
323
322
  }
324
323
  }
325
324
 
@@ -66,11 +66,11 @@ namespace XD.SDK.Account.Internal.Standalone
66
66
  }
67
67
  catch (XDGError xe)
68
68
  {
69
- errorCallback?.Invoke(xe);
69
+ errorCallback?.Invoke(xe.ParseToError());
70
70
  }
71
71
  catch (Exception e)
72
72
  {
73
- errorCallback?.Invoke(new XDGError(ResponseCode.Common.Failed, e.Message));
73
+ errorCallback?.Invoke(e.ParseToError());
74
74
  }
75
75
  }
76
76
 
@@ -148,7 +148,7 @@ namespace XD.SDK.Account.Internal.Standalone
148
148
  };
149
149
  var url = AuthConstants.CN_PERSONAL_INFO + UserModule.XDG_PERSONAL_INFO + "?" +
150
150
  XDUrlUtils.ToQueryString(queries);
151
-
151
+
152
152
  UIManager.ShowUI<XDWebViewAlert>("XDWebViewAlert", new Dictionary<string, object>
153
153
  {
154
154
  {
@@ -207,7 +207,7 @@ namespace XD.SDK.Account.Internal.Standalone
207
207
  }
208
208
  catch (XDGError e)
209
209
  {
210
- callback?.Invoke(false, new XDGError(ResponseCode.Common.Failed, e.ErrorMsg));
210
+ callback?.Invoke(false, e.ParseToError());
211
211
  }
212
212
  }
213
213
 
@@ -239,15 +239,16 @@ namespace XD.SDK.Account.Internal.Standalone
239
239
  {
240
240
  var user = await UserModule.Login(loginType);
241
241
  AliyunTrack.LoginAntiAddictionStartup();
242
- var complianceResult =
243
- await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKComplianceStartup, ConfigModule.IsGlobal, user.UserId);
242
+ var complianceResult = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKComplianceStartup, ConfigModule.IsGlobal, user.UserId);
244
243
  // TODO 统一走回调进行埋点
245
244
  // AliyunTrack.LoginAntiAddictionResult(XDDictionary.GetValue(complianceResult, "code", -100),
246
245
  // XDDictionary.GetValue<string>(complianceResult, "reason"),
247
246
  // XDDictionary.GetValue<string>(complianceResult, "extras"));
248
- if (XDDictionary.GetValue<bool>(complianceResult, "success"))
247
+ var compliance = complianceResult.GetValueOrDefault();
248
+ if (XDDictionary.GetValue<bool>(compliance, "success"))
249
249
  {
250
250
  await AgreementModule.SignAgreement(user.UserId);
251
+ AliyunTrack.LoginSuccess();
251
252
  return user;
252
253
  }
253
254
 
@@ -269,7 +270,15 @@ namespace XD.SDK.Account.Internal.Standalone
269
270
  }
270
271
  catch (Exception e)
271
272
  {
272
- AliyunTrack.LoginFail(e.Message);
273
+ if (e is XDGError error)
274
+ {
275
+ AliyunTrack.LoginFail(error.ErrorMsg);
276
+ }
277
+ else
278
+ {
279
+ AliyunTrack.LoginFail(e.Message);
280
+ }
281
+
273
282
  AgreementModule.ClearLocalSignedAgreements();
274
283
  throw;
275
284
  }
@@ -279,7 +288,7 @@ namespace XD.SDK.Account.Internal.Standalone
279
288
  {
280
289
  // SDK 登陆成功
281
290
  AliyunTrack.LoginLogout(logoutType);
282
-
291
+
283
292
  ClearUserCache();
284
293
 
285
294
  XDGEventBus.Publish(XDGEvents.TdsSDKLogout);
@@ -14,7 +14,7 @@ namespace XD.SDK.Account.Internal.Standalone
14
14
 
15
15
  internal static async Task<Dictionary<string, object>> GetAuthData()
16
16
  {
17
- if (SteamUtils.IsSDKSupported)
17
+ if (SteamWrapper.Initialized())
18
18
  {
19
19
  // 先尝试从 Steam SDK 中获取 auth data
20
20
  Dictionary<string, object> authData = await GetAuthDataFromSDK();
@@ -38,7 +38,7 @@ namespace XD.SDK.Account.Internal.Standalone
38
38
  AliyunTrack.LoginAuthorize();
39
39
  try
40
40
  {
41
- string ticket = await SteamUtils.Instance.GetAuthTicket();
41
+ string ticket = await SteamWrapper.Instance.GetAuthTicket();
42
42
  if (string.IsNullOrWhiteSpace(ticket))
43
43
  {
44
44
  // 登陆授权失败
@@ -70,12 +70,12 @@ namespace XD.SDK.Account.Internal.Standalone
70
70
 
71
71
  public static string GetSteamIdFromSDK()
72
72
  {
73
- return SteamUtils.Instance.GetSteamId();
73
+ return SteamWrapper.Instance.GetSteamId();
74
74
  }
75
75
 
76
76
  public static Dictionary<string, object> GetCacheData()
77
77
  {
78
- if (!SteamUtils.IsSDKSupported)
78
+ if (!SteamWrapper.Initialized())
79
79
  {
80
80
  return null;
81
81
  }
@@ -27,18 +27,11 @@ namespace XD.SDK.Account.Internal.Standalone
27
27
  UIManager.ShowLoading(timeout: 3);
28
28
  }
29
29
  // 使用明确指定参数类型的反射调用
30
- var permissions = ConfigModule.TapConfig.Permissions;
31
- var authData = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKLogin, permissions);
32
-
33
- // 检查返回结果是否为 null
34
- if (authData == null)
35
- {
36
- throw new XDGError(ResponseCode.Common.Failed, "TapTap 登录返回数据为空");
37
- }
38
-
30
+ var permissions = ConfigModule.TapConfig?.Permissions;
31
+ var authDataResult = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKLogin, permissions);
32
+ var authData = authDataResult.GetValueOrThrow();
39
33
  authData.Add("type", (int)LoginType.TapTap);
40
34
  authData.Add("scope", string.Join(",", permissions?.ToArray()));
41
-
42
35
  if (ConfigModule.TapConfig != null && ConfigModule.UsingTapPC)
43
36
  {
44
37
  UIManager.DismissLoading();
@@ -60,11 +53,11 @@ namespace XD.SDK.Account.Internal.Standalone
60
53
  // throw new XDGError(ResponseCode.Common.Failed, e.Message);
61
54
  // }
62
55
  // }
63
- catch (Exception e)
56
+ catch (XDGError e)
64
57
  {
65
- AliyunTrack.LoginAuthorizeFail(e.Message);
66
- XDGLogger.Warn($"Tap 登录失败:{e}", XDGLoggerTag.Account);
67
- throw new XDGError(ResponseCode.Common.Failed, e.Message);
58
+ AliyunTrack.LoginAuthorizeFail(e.ErrorMsg);
59
+ XDGLogger.Warn($"Tap 登录失败:{e.ErrorMsg}",XDGLoggerTag.Common);
60
+ throw new XDGError(ResponseCode.Common.Failed, e.ErrorMsg);
68
61
  }
69
62
  }
70
63
  }
@@ -431,7 +431,8 @@ namespace XD.SDK.Account.Internal.Standalone
431
431
 
432
432
  private static Dictionary<string, string> GetLoginModuleCommonProperties(string eventName, string userLoginTypeString = "")
433
433
  {
434
- var current = XDGEventBus.Publish<XDGUser>(XDGEvents.AccountGetCurrentUser)?.UserId;
434
+ var result = XDGEventBus.Publish<XDGUser>(XDGEvents.AccountGetCurrentUser);
435
+ var current = result.GetValueOrDefault()?.UserId;
435
436
  var content = new Dictionary<string, string>();
436
437
  content["tag"] = "sdklogin";
437
438
  content["event_session_id"] = LoginEventSessionId;
@@ -439,12 +440,10 @@ namespace XD.SDK.Account.Internal.Standalone
439
440
  content["user_login_type"] = string.IsNullOrEmpty(current) ? "" : userLoginTypeString;
440
441
  content["logid"] = CommonTrack.GetLogId(LoginEventSessionId, eventName);
441
442
  content["isLoginModule"] = "true";
442
- #if XD_STEAM_SUPPORT
443
- if (SteamUtils.IsSDKSupported)
443
+ if (SteamWrapper.Initialized())
444
444
  {
445
445
  content["console_type"] = "steam";
446
446
  }
447
- #endif
448
447
 
449
448
  if (isPhoneLogin)
450
449
  {
@@ -124,7 +124,7 @@ namespace XD.SDK.Account.Internal.Standalone
124
124
  if (XDGCommonInternal.IsCn())
125
125
  {
126
126
  XDGLogger.Warn("暂不支持的登录方式", XDGLoggerTag.Account);
127
- throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
127
+ throw new XDGError(ResponseCode.Account.TypeNotAvailable, "Email auth is not support in CN");
128
128
  }
129
129
  else
130
130
  {
@@ -158,7 +158,7 @@ namespace XD.SDK.Account.Internal.Standalone
158
158
  if (XDGCommonInternal.IsCn())
159
159
  {
160
160
  XDGLogger.Warn($"暂不支持的登录方式:{LoginType.Email}", XDGLoggerTag.Account);
161
- throw new XDGError(ResponseCode.Common.UnavailableService, "暂不支持的登录方式");
161
+ throw new XDGError(ResponseCode.Common.UnavailableService, "Email auth is not support in CN");
162
162
  }
163
163
  else
164
164
  {
@@ -205,18 +205,18 @@ namespace XD.SDK.Account.Internal.Standalone
205
205
  {
206
206
  try
207
207
  {
208
- var token = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKGetAccessToken);
209
-
208
+ var tokenResult = await XDGEventBus.PublishAsync<Dictionary<string, object>>(XDGEvents.TapSDKGetAccessToken);
209
+ var token = tokenResult.GetValueOrThrow();
210
210
  if (token == null || !token.ContainsKey("token"))
211
211
  {
212
212
  XDGLogger.Warn("Third token expired.", XDGLoggerTag.Account);
213
213
  throw new XDGError(ResponseCode.Account.TokenExpired, "Third token expired.");
214
214
  }
215
215
  }
216
- catch (Exception e)
216
+ catch (XDGError e)
217
217
  {
218
- XDGLogger.Warn(e.Message, XDGLoggerTag.Account);
219
- throw new XDGError(ResponseCode.Common.Failed, e.Message);
218
+ XDGLogger.Warn(e.ErrorMsg, XDGLoggerTag.Account);
219
+ throw;
220
220
  }
221
221
  }
222
222
 
@@ -228,7 +228,7 @@ namespace XD.SDK.Account.Internal.Standalone
228
228
  {
229
229
  if (e.HttpStatusCode == 401 || e.Code == 40311 || e.Code == 40312)
230
230
  {
231
- throw e;
231
+ throw;
232
232
  }
233
233
  }
234
234
  catch (Exception e)
@@ -356,7 +356,7 @@ namespace XD.SDK.Account.Internal.Standalone
356
356
  public static async Task<XDGUser> LoginByConsole()
357
357
  {
358
358
  // 判断当前有接入哪个主机 SDK
359
- if (SteamUtils.IsSDKSupported)
359
+ if (SteamWrapper.Initialized())
360
360
  {
361
361
  try
362
362
  {
@@ -444,7 +444,7 @@ namespace XD.SDK.Account.Internal.Standalone
444
444
  case LoginType.Facebook:
445
445
  return await FacebookAuth.GetAuthData();
446
446
  default:
447
- return new Dictionary<string, object>();
447
+ throw new XDGError(ResponseCode.Account.TypeNotAvailable, "暂不支持的登录方式");
448
448
  }
449
449
  }
450
450
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "com.xd.sdk.account",
3
3
  "displayName": "XDGSDK Account",
4
- "version": "7.1.2",
4
+ "version": "7.2.1-alpha",
5
5
  "description": "XDGSDK",
6
6
  "unity": "2019.3",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "com.xd.sdk.common": "7.1.2"
9
+ "com.xd.sdk.common": "7.2.1-alpha"
10
10
  }
11
11
  }