@seayoo-web/gamer-api 2.5.5 → 2.5.6

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/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var me = Object.defineProperty;
2
2
  var de = (a, t, r) => t in a ? me(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r;
3
- var d = (a, t, r) => de(a, typeof t != "symbol" ? t + "" : t, r);
3
+ var m = (a, t, r) => de(a, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { isComboWebView as ge } from "@seayoo-web/combo-webview";
5
- import { isPlainObject as C, Support as y, useConsole as pe, usePromise as _e, pruneURL as be, queryString as P, pruneObject as c, v as e, omitFields as V, typedObjectGuard as s, parseJSON as ye, removePara as Q } from "@seayoo-web/utils";
6
- function fe(a) {
5
+ import { isPlainObject as C, Support as y, useConsole as pe, usePromise as _e, pruneURL as be, queryString as $, pruneObject as c, v as e, omitFields as V, typedObjectGuard as s, parseJSON as ye, removePara as Q } from "@seayoo-web/utils";
6
+ function he(a) {
7
7
  return C(a, "gamer_token") && typeof a.gamer_token == "string";
8
8
  }
9
9
  function M(a) {
10
10
  return C(a);
11
11
  }
12
12
  const q = pe("GamerApiSDK");
13
- function he(a) {
13
+ function fe(a) {
14
14
  return /^\/[a-z\d-]+$/.test(a);
15
15
  }
16
16
  async function we() {
@@ -60,14 +60,15 @@ const ke = {
60
60
  }, w = "gamer_token";
61
61
  class Sr {
62
62
  constructor(t, r) {
63
- d(this, "$NetRequest");
64
- d(this, "$idToken", "");
65
- d(this, "$weixinToken", "");
66
- d(this, "$gamerToken", "");
67
- d(this, "req");
68
- d(this, "storage");
63
+ m(this, "$NetRequest");
64
+ m(this, "$idToken", "");
65
+ m(this, "$weixinToken", "");
66
+ m(this, "$gamerToken", "");
67
+ m(this, "req");
68
+ m(this, "storage");
69
+ m(this, "$loginWithTokenJob", null);
69
70
  this.storage = y.wx ? ve : ke;
70
- const n = he(t) ? t : `https://${be(t)}`;
71
+ const n = fe(t) ? t : `https://${be(t)}`;
71
72
  if (this.$NetRequest = r, this.req = r({
72
73
  baseURL: `${n}/v1`,
73
74
  timeout: 1e4,
@@ -89,7 +90,7 @@ class Sr {
89
90
  this.$gamerToken && (i.headers.Authorization = `Bearer ${this.$gamerToken}`);
90
91
  }
91
92
  }), y.window) {
92
- const i = /^(?:localhost|[\d.]+):\d{4}$/.test(location.host), o = P("gamer_token");
93
+ const i = /^(?:localhost|[\d.]+):\d{4}$/.test(location.host), o = $("gamer_token");
93
94
  (ge() || i && o) && (this.$gamerToken = o);
94
95
  }
95
96
  this.$gamerToken || this.loadGamerTokenCache();
@@ -169,12 +170,7 @@ class Sr {
169
170
  return !0;
170
171
  if (!this.idToken || y.wx && !this.weixinToken)
171
172
  return !1;
172
- const { code: t, data: r } = await this.req.post(
173
- "login-with-token",
174
- c({ id_token: this.idToken, weixin_token: y.wx ? this.weixinToken : null }),
175
- fe,
176
- { message: !1 }
177
- );
173
+ const { code: t, data: r } = await this.loginWithToken();
178
174
  switch (t) {
179
175
  case "invalid_id_token":
180
176
  this.idToken = "";
@@ -185,6 +181,18 @@ class Sr {
185
181
  }
186
182
  return this.gamerToken = (r == null ? void 0 : r.gamer_token) || "", !!this.gamerToken;
187
183
  }
184
+ async loginWithToken() {
185
+ if (this.$loginWithTokenJob)
186
+ return await this.$loginWithTokenJob;
187
+ this.$loginWithTokenJob = this.req.post(
188
+ "login-with-token",
189
+ c({ id_token: this.idToken, weixin_token: y.wx ? this.weixinToken : null }),
190
+ he,
191
+ { message: !1 }
192
+ );
193
+ const t = await this.$loginWithTokenJob;
194
+ return this.$loginWithTokenJob = null, t;
195
+ }
188
196
  /**
189
197
  * 获取当前登录用户的 Session 的信息
190
198
  *
@@ -244,7 +252,7 @@ const Ce = {
244
252
  Physical: "physical",
245
253
  /** 虚拟商品 */
246
254
  Virtual: "virtual"
247
- }, X = e.string().enum(xe).lock(), Se = {
255
+ }, W = e.string().enum(xe).lock(), Se = {
248
256
  /** 待发放 */
249
257
  Pending: "pending",
250
258
  /** 已发放 */
@@ -269,7 +277,7 @@ const Ce = {
269
277
  exp_description: e.string(),
270
278
  credit_description: e.string(),
271
279
  send_role_mail_rate_limit: e.number()
272
- }).lock(), Pe = e.object({
280
+ }).lock(), $e = e.object({
273
281
  member_id: e.string(),
274
282
  player_id: e.string(),
275
283
  exp: e.number(),
@@ -278,19 +286,19 @@ const Ce = {
278
286
  credit_expiring: e.number(),
279
287
  level_change_time: e.number(),
280
288
  level_expire_time: e.number()
281
- }).lock(), $e = e.object({
289
+ }).lock(), Pe = e.object({
282
290
  server_id: e.string(),
283
291
  server_name: e.string()
284
292
  }).lock(), Ue = e.object({
285
293
  role_id: e.string(),
286
294
  role_name: e.string()
287
- }).lock(), Y = e.object({
295
+ }).lock(), X = e.object({
288
296
  ...Ue.shape,
289
- ...$e.shape,
297
+ ...Pe.shape,
290
298
  role_level: e.number(),
291
299
  last_login_time: e.number()
292
300
  }).lock(), Fe = e.object({
293
- ...Y.shape,
301
+ ...X.shape,
294
302
  /** 角色战力 */
295
303
  role_fighting: e.number(),
296
304
  /** 宗门 ID */
@@ -305,7 +313,7 @@ const Ce = {
305
313
  bio: e.string(),
306
314
  gender: Ve,
307
315
  birthday: e.object({ year: e.number(), month: e.number(), day: e.number() })
308
- }).lock(), W = e.object({
316
+ }).lock(), Y = e.object({
309
317
  address_id: e.number(),
310
318
  recipient: e.string(),
311
319
  mobile: e.string(),
@@ -339,7 +347,7 @@ const Ce = {
339
347
  product_id: e.number(),
340
348
  catalog_id: e.number(),
341
349
  catalog_name: e.string(),
342
- item_type: X,
350
+ item_type: W,
343
351
  name: e.string(),
344
352
  img_url: e.string(),
345
353
  description: e.string(),
@@ -391,7 +399,7 @@ const Ce = {
391
399
  product_id: e.number(),
392
400
  name: e.string(),
393
401
  img_url: e.string(),
394
- item_type: X,
402
+ item_type: W,
395
403
  catalog_id: e.number(),
396
404
  catalog_name: e.string(),
397
405
  quantity: e.number(),
@@ -399,17 +407,17 @@ const Ce = {
399
407
  status: Le,
400
408
  created_at: e.number(),
401
409
  extra_data: e.union(Ne.clone(), Oe.clone()).satisfies().optional()
402
- }), Qe = e.guard(Ee), K = s({ player: Pe }), Me = s({ roles: e.array(Y) }), x = s({ role_card: Fe }), H = e.guard(De), z = e.guard(W), Ke = s({ addresses: e.array(W) }), He = e.guard(Ie), ze = s({
410
+ }), Qe = e.guard(Ee), J = s({ player: $e }), Me = s({ roles: e.array(X) }), x = s({ role_card: Fe }), K = e.guard(De), H = e.guard(Y), Je = s({ addresses: e.array(Y) }), Ke = e.guard(Ie), He = s({
403
411
  credit_logs: e.array(Ge),
404
412
  next_token: e.string().optional()
405
- }), Je = s({ products: e.array(te) }), Ze = s({ benefits: e.array(ee) }), Xe = s({ benefit: Ae }), Ye = s({
413
+ }), ze = s({ products: e.array(te) }), Ze = s({ benefits: e.array(ee) }), We = s({ benefit: Ae }), Xe = s({
406
414
  redemptions: e.array(Be),
407
415
  next_token: e.string().optional()
408
416
  });
409
417
  class Er {
410
418
  constructor(t) {
411
- d(this, "token");
412
- d(this, "req");
419
+ m(this, "token");
420
+ m(this, "req");
413
421
  this.token = t, this.req = t.req;
414
422
  }
415
423
  /**
@@ -428,7 +436,7 @@ class Er {
428
436
  */
429
437
  async getCurrentPlayer(t) {
430
438
  await this.token.autoLogin();
431
- const { data: r, code: n, message: i } = await this.req.get("club/current-player", K, t);
439
+ const { data: r, code: n, message: i } = await this.req.get("club/current-player", J, t);
432
440
  return (r == null ? void 0 : r.player) ?? {
433
441
  message: i,
434
442
  error: n
@@ -444,7 +452,7 @@ class Er {
444
452
  const { data: r, code: n, message: i } = await this.req.post(
445
453
  "club/link-player",
446
454
  { id_token: this.token.idToken },
447
- K,
455
+ J,
448
456
  t
449
457
  );
450
458
  return (r == null ? void 0 : r.player) ?? {
@@ -503,7 +511,7 @@ class Er {
503
511
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=TMWBCFcOr2
504
512
  */
505
513
  async getUserProfile(t, r) {
506
- const { data: n } = await this.req.get("club/user-profile", H, {
514
+ const { data: n } = await this.req.get("club/user-profile", K, {
507
515
  ...r,
508
516
  params: { member_id: t }
509
517
  });
@@ -516,7 +524,7 @@ class Er {
516
524
  */
517
525
  async updateUserProfile(t, r) {
518
526
  await this.token.autoLogin();
519
- const { data: n, code: i, message: o } = await this.req.post("club/user-profile", t, H, r);
527
+ const { data: n, code: i, message: o } = await this.req.post("club/user-profile", t, K, r);
520
528
  return n ?? {
521
529
  message: o,
522
530
  error: i
@@ -529,7 +537,7 @@ class Er {
529
537
  */
530
538
  async getAddresses(t) {
531
539
  if (!await this.token.autoLogin()) return [];
532
- const { data: r } = await this.req.get("club/addresses", Ke, t);
540
+ const { data: r } = await this.req.get("club/addresses", Je, t);
533
541
  return (r == null ? void 0 : r.addresses) ?? [];
534
542
  }
535
543
  /**
@@ -539,7 +547,7 @@ class Er {
539
547
  */
540
548
  async addAddress(t, r) {
541
549
  if (!await this.token.autoLogin()) return null;
542
- const { data: n } = await this.req.post("/club/add-address", c(t), z, r);
550
+ const { data: n } = await this.req.post("/club/add-address", c(t), H, r);
543
551
  return n;
544
552
  }
545
553
  /**
@@ -552,7 +560,7 @@ class Er {
552
560
  const { data: n, code: i, message: o } = await this.req.post(
553
561
  "club/update-address",
554
562
  c(t),
555
- z,
563
+ H,
556
564
  r
557
565
  );
558
566
  return n ?? {
@@ -577,7 +585,7 @@ class Er {
577
585
  */
578
586
  async getUserCredit(t, r) {
579
587
  await this.token.autoLogin();
580
- const { data: n, code: i, message: o } = await this.req.get("club/user-credit", He, {
588
+ const { data: n, code: i, message: o } = await this.req.get("club/user-credit", Ke, {
581
589
  ...r,
582
590
  params: c(t)
583
591
  });
@@ -593,7 +601,7 @@ class Er {
593
601
  */
594
602
  async getCreditLogs(t, r) {
595
603
  await this.token.autoLogin();
596
- const { data: n } = await this.req.get("club/credit-logs", ze, {
604
+ const { data: n } = await this.req.get("club/credit-logs", He, {
597
605
  ...r,
598
606
  params: c({ max_results: 20, ...t })
599
607
  });
@@ -619,7 +627,7 @@ class Er {
619
627
  */
620
628
  async getBenefit(t, r) {
621
629
  if (!await this.token.autoLogin()) return null;
622
- const { data: n } = await this.req.get("club/benefit", Xe, {
630
+ const { data: n } = await this.req.get("club/benefit", We, {
623
631
  ...r,
624
632
  params: { benefit_id: t }
625
633
  });
@@ -631,7 +639,7 @@ class Er {
631
639
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=r3vC3PzfMQ
632
640
  */
633
641
  async getProducts(t, r) {
634
- const { data: n } = await this.req.get("club/products", Je, {
642
+ const { data: n } = await this.req.get("club/products", ze, {
635
643
  ...r,
636
644
  params: t
637
645
  });
@@ -657,7 +665,7 @@ class Er {
657
665
  */
658
666
  async getRedemptions(t, r) {
659
667
  await this.token.autoLogin();
660
- const { data: n } = await this.req.get("club/redemptions", Ye, {
668
+ const { data: n } = await this.req.get("club/redemptions", Xe, {
661
669
  ...r,
662
670
  params: c({ max_results: 20, ...t })
663
671
  });
@@ -688,12 +696,12 @@ const R = {
688
696
  ExternalCode: "external_gift_code",
689
697
  /** 空奖励 */
690
698
  VoidItem: "void_item"
691
- }, ne = e.string().enum(R).lock(), Pr = R, re = ne, We = {
699
+ }, ne = e.string().enum(R).lock(), $r = R, re = ne, Ye = {
692
700
  /** 世游通行证 ID / Combo ID */
693
701
  UserId: "user_id",
694
702
  /** 游戏角色 ID */
695
703
  RoleId: "role_id"
696
- }, et = e.string().enum(We).lock(), tt = {
704
+ }, et = e.string().enum(Ye).lock(), tt = {
697
705
  None: "none",
698
706
  Daily: "daily",
699
707
  Weekly: "weekly",
@@ -772,7 +780,7 @@ const R = {
772
780
  Failed: "failed",
773
781
  /** 奖励已发货 */
774
782
  Delivered: "delivered"
775
- }, $r = e.string().enum(_).lock(), $ = {
783
+ }, Pr = e.string().enum(_).lock(), P = {
776
784
  /**
777
785
  * 奖励未领取,拼写错误以兼容后端历史版本,检查请使用 Unclaimed
778
786
  *
@@ -787,7 +795,7 @@ const R = {
787
795
  Failed: _.Failed,
788
796
  /** 奖励已发货 */
789
797
  Delivered: _.Delivered
790
- }, oe = e.string().enum($).lock(), b = {
798
+ }, oe = e.string().enum(P).lock(), b = {
791
799
  /** 未获得奖励 */
792
800
  Ineligible: _.Ineligible,
793
801
  /**
@@ -882,12 +890,12 @@ const R = {
882
890
  claim_rewards_start_time: e.number(),
883
891
  claim_rewards_end_time: e.number()
884
892
  })
885
- }), yt = u.CheckIn, ft = e.object({
893
+ }), yt = u.CheckIn, ht = e.object({
886
894
  ...l.shape,
887
895
  feature_type: e.string().enum(yt)
888
- }), ht = u.ClaimActivationKey, wt = e.object({
896
+ }), ft = u.ClaimActivationKey, wt = e.object({
889
897
  ...l.shape,
890
- feature_type: e.string().enum(ht)
898
+ feature_type: e.string().enum(ft)
891
899
  }), kt = u.ClaimRewards, vt = e.object({
892
900
  ...l.shape,
893
901
  feature_type: e.string().enum(kt)
@@ -926,13 +934,13 @@ const R = {
926
934
  config: e.object({
927
935
  share_url: e.string()
928
936
  })
929
- }), Et = u.InvitedRegister, Pt = e.object({
937
+ }), Et = u.InvitedRegister, $t = e.object({
930
938
  ...l.shape,
931
939
  feature_type: e.string().enum(Et)
932
- }), $t = e.string().enum(V(R, "GiftCode", "LotteryTicket")), Ut = u.Lottery, Ft = e.object({
940
+ }), Pt = e.string().enum(V(R, "GiftCode", "LotteryTicket")), Ut = u.Lottery, Ft = e.object({
933
941
  reward_item_id: e.number(),
934
942
  reward_item_name: e.string(),
935
- reward_item_type: $t,
943
+ reward_item_type: Pt,
936
944
  reward_item_icon_url: e.string(),
937
945
  reward_item_desc: e.string().optional(),
938
946
  reward_amount: e.number(),
@@ -977,30 +985,30 @@ const R = {
977
985
  }), Qt = u.Register, Mt = e.object({
978
986
  ...l.shape,
979
987
  feature_type: e.string().enum(Qt)
980
- }), Kt = u.Share, Ht = e.object({
988
+ }), Jt = u.Share, Kt = e.object({
981
989
  ...l.shape,
982
- feature_type: e.string().enum(Kt),
990
+ feature_type: e.string().enum(Jt),
983
991
  config: e.object({
984
992
  share_platform: e.string(),
985
993
  jump_url: e.string().optional(),
986
994
  icon_url: e.string().optional()
987
995
  })
988
- }), zt = u.Subscribe, Jt = e.object({
996
+ }), Ht = u.Subscribe, zt = e.object({
989
997
  ...l.shape,
990
- feature_type: e.string().enum(zt),
998
+ feature_type: e.string().enum(Ht),
991
999
  config: e.object({
992
1000
  weixin_template_ids: e.array(e.string())
993
1001
  })
994
- }), Zt = u.Survey, Xt = e.object({
1002
+ }), Zt = u.Survey, Wt = e.object({
995
1003
  ...l.shape,
996
1004
  feature_type: e.string().enum(Zt),
997
1005
  config: e.object({
998
1006
  survey_id: e.string(),
999
1007
  survey_url: e.string()
1000
1008
  })
1001
- }), Yt = u.Team, Wt = e.object({
1009
+ }), Xt = u.Team, Yt = e.object({
1002
1010
  ...l.shape,
1003
- feature_type: e.string().enum(Yt),
1011
+ feature_type: e.string().enum(Xt),
1004
1012
  config: e.object({
1005
1013
  max_members: e.number().min(1),
1006
1014
  min_members: e.number().min(1)
@@ -1031,22 +1039,22 @@ const R = {
1031
1039
  feature_type: e.string().enum(rn)
1032
1040
  }), an = e.union(
1033
1041
  bt,
1034
- ft,
1042
+ ht,
1035
1043
  vt,
1036
1044
  Vt,
1037
1045
  jt,
1038
1046
  xt,
1039
1047
  Lt,
1040
- Pt,
1048
+ $t,
1041
1049
  Dt,
1042
1050
  Gt,
1043
1051
  Nt,
1044
1052
  Bt,
1045
1053
  Mt,
1046
- Ht,
1047
- Jt,
1048
- Xt,
1054
+ Kt,
1055
+ zt,
1049
1056
  Wt,
1057
+ Yt,
1050
1058
  nn,
1051
1059
  wt,
1052
1060
  on
@@ -1119,9 +1127,9 @@ const R = {
1119
1127
  })
1120
1128
  )
1121
1129
  }).optional()
1122
- }), fn = e.object({
1123
- platform: e.string()
1124
1130
  }), hn = e.object({
1131
+ platform: e.string()
1132
+ }), fn = e.object({
1125
1133
  weixin_openid: e.string()
1126
1134
  }), wn = e.object({
1127
1135
  serial_number: e.number()
@@ -1163,9 +1171,9 @@ const R = {
1163
1171
  dn,
1164
1172
  wn,
1165
1173
  mn,
1166
- fn,
1167
- Cn,
1168
1174
  hn,
1175
+ Cn,
1176
+ fn,
1169
1177
  cn,
1170
1178
  ln,
1171
1179
  vn,
@@ -1229,10 +1237,10 @@ const R = {
1229
1237
  }).optional(),
1230
1238
  rewards: e.array(qn).optional(),
1231
1239
  scan: e.bool().optional()
1232
- }), Pn = e.object({
1240
+ }), $n = e.object({
1233
1241
  reward_id: e.number(),
1234
1242
  reward_status: U
1235
- }), $n = e.guard(sn), Un = e.guard(Sn), L = s({ count: e.number() }), Fn = s({ first_visit: e.bool() }), Dn = s({
1243
+ }), Pn = e.guard(sn), Un = e.guard(Sn), L = s({ count: e.number() }), Fn = s({ first_visit: e.bool() }), Dn = s({
1236
1244
  engagements: e.union(e.array(jn), e.array(kn))
1237
1245
  }), In = s({
1238
1246
  status: e.array(Ln)
@@ -1242,7 +1250,7 @@ const R = {
1242
1250
  engagements: e.array(xn),
1243
1251
  next_token: e.string().optional()
1244
1252
  }), Nn = e.guard(En), On = s({
1245
- claimed_items: e.array(Pn)
1253
+ claimed_items: e.array($n)
1246
1254
  }), Bn = s({
1247
1255
  rewards: e.array(I)
1248
1256
  }), Qn = s({
@@ -1250,18 +1258,18 @@ const R = {
1250
1258
  }), Mn = s({
1251
1259
  user_rewards: e.array(I),
1252
1260
  next_token: e.string().optional()
1253
- }), Kn = s({
1261
+ }), Jn = s({
1254
1262
  scene: e.string()
1255
- }), Hn = s({
1263
+ }), Kn = s({
1256
1264
  params: e.string()
1257
- }), zn = s({
1265
+ }), Hn = s({
1258
1266
  img: e.string()
1259
1267
  });
1260
1268
  class Gr {
1261
1269
  constructor(t, r) {
1262
- d(this, "token");
1263
- d(this, "event", 0);
1264
- d(this, "req");
1270
+ m(this, "token");
1271
+ m(this, "event", 0);
1272
+ m(this, "req");
1265
1273
  this.token = t, this.event = +r, this.req = t.req;
1266
1274
  }
1267
1275
  /**
@@ -1282,7 +1290,7 @@ class Gr {
1282
1290
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=wFXxtdNKPm
1283
1291
  */
1284
1292
  async getConfig(t) {
1285
- const { data: r } = await this.req.get(`event/${this.event}/event-config`, $n, t);
1293
+ const { data: r } = await this.req.get(`event/${this.event}/event-config`, Pn, t);
1286
1294
  return r;
1287
1295
  }
1288
1296
  /**
@@ -1410,7 +1418,7 @@ class Gr {
1410
1418
  */
1411
1419
  async engage(t, r, n, i) {
1412
1420
  await this.token.autoLogin();
1413
- const { data: o, code: g, message: m } = await this.req.post(
1421
+ const { data: o, code: g, message: d } = await this.req.post(
1414
1422
  `event/${this.event}/engage`,
1415
1423
  c({
1416
1424
  feature_id: t,
@@ -1420,8 +1428,8 @@ class Gr {
1420
1428
  Nn,
1421
1429
  i
1422
1430
  );
1423
- return o && o.rewards && (o.rewards = o.rewards.map((h) => (h.reward_status = h.reward_status === $.UnclaimedErr ? $.Unclaimed : h.reward_status, h))), o ?? {
1424
- message: m,
1431
+ return o && o.rewards && (o.rewards = o.rewards.map((f) => (f.reward_status = f.reward_status === P.UnclaimedErr ? P.Unclaimed : f.reward_status, f))), o ?? {
1432
+ message: d,
1425
1433
  error: g
1426
1434
  // 激活码已领完
1427
1435
  };
@@ -1444,7 +1452,7 @@ class Gr {
1444
1452
  On,
1445
1453
  r
1446
1454
  ), g = n == null ? void 0 : n.claimed_items;
1447
- return g ? g.map((m) => (m.reward_status = m.reward_status === b.UnclaimedErr ? b.Unclaimed : m.reward_status, m)) : {
1455
+ return g ? g.map((d) => (d.reward_status = d.reward_status === b.UnclaimedErr ? b.Unclaimed : d.reward_status, d)) : {
1448
1456
  message: o,
1449
1457
  error: i
1450
1458
  };
@@ -1465,7 +1473,7 @@ class Gr {
1465
1473
  Bn,
1466
1474
  r
1467
1475
  ), g = n == null ? void 0 : n.rewards;
1468
- return g ? g.map((m) => (m.reward_status = m.reward_status === b.UnclaimedErr ? b.Unclaimed : m.reward_status, m)) : {
1476
+ return g ? g.map((d) => (d.reward_status = d.reward_status === b.UnclaimedErr ? b.Unclaimed : d.reward_status, d)) : {
1469
1477
  message: o,
1470
1478
  error: i
1471
1479
  };
@@ -1561,7 +1569,7 @@ class Gr {
1561
1569
  */
1562
1570
  async getUnlimitQrcodeScene(t, r) {
1563
1571
  if (!await this.token.autoLogin()) return null;
1564
- const { data: n } = await this.req.get("event/unlimit-qrcode-scene", Kn, {
1572
+ const { data: n } = await this.req.get("event/unlimit-qrcode-scene", Jn, {
1565
1573
  ...r,
1566
1574
  params: { params: t }
1567
1575
  });
@@ -1575,7 +1583,7 @@ class Gr {
1575
1583
  * @param scene - 小程序码 scene 值
1576
1584
  */
1577
1585
  async getParamsByQrcodeScene(t, r) {
1578
- const { data: n } = await this.req.get("event/params-by-qrcode-scene", Hn, {
1586
+ const { data: n } = await this.req.get("event/params-by-qrcode-scene", Kn, {
1579
1587
  ...r,
1580
1588
  params: { scene: t }
1581
1589
  });
@@ -1591,18 +1599,18 @@ class Gr {
1591
1599
  const { data: n } = await this.req.post(
1592
1600
  "event/unlimit-qrcode",
1593
1601
  c(t),
1594
- zn,
1602
+ Hn,
1595
1603
  r
1596
1604
  );
1597
1605
  return (n == null ? void 0 : n.img) ?? null;
1598
1606
  }
1599
1607
  }
1600
- const Jn = {
1608
+ const zn = {
1601
1609
  /** 所有人均可以发帖 */
1602
1610
  All: "all",
1603
1611
  /** 指定用户可发帖 */
1604
1612
  Limit: "limit"
1605
- }, Zn = e.string().enum(Jn).lock(), Xn = {
1613
+ }, Zn = e.string().enum(zn).lock(), Wn = {
1606
1614
  /** 待审核(仅自己可见) */
1607
1615
  Pending: "pending",
1608
1616
  /** 审核通过 */
@@ -1611,14 +1619,14 @@ const Jn = {
1611
1619
  Failed: "failed",
1612
1620
  /** 嫌疑(仅自己可见) */
1613
1621
  Suspect: "suspect"
1614
- }, ae = e.string().enum(Xn).lock(), Yn = {
1622
+ }, ae = e.string().enum(Wn).lock(), Xn = {
1615
1623
  /** 系统通知 */
1616
1624
  System: "system",
1617
1625
  /** 评论我的 */
1618
1626
  Comment: "comment",
1619
1627
  /** 点赞通知 */
1620
1628
  Like: "like"
1621
- }, Ar = e.string().enum(Yn).lock(), p = {
1629
+ }, Ar = e.string().enum(Xn).lock(), p = {
1622
1630
  /** 系统通知 */
1623
1631
  System: "system",
1624
1632
  /** 帖子被置顶 */
@@ -1643,7 +1651,7 @@ const Jn = {
1643
1651
  ReplyLiked: "reply_liked",
1644
1652
  /** 回复被删除 */
1645
1653
  ReplyDeleted: "reply_deleted"
1646
- }, Wn = e.string().enum(p).lock(), se = e.object({
1654
+ }, Yn = e.string().enum(p).lock(), se = e.object({
1647
1655
  forum_id: e.number(),
1648
1656
  icon_url: e.string(),
1649
1657
  name: e.string(),
@@ -1725,9 +1733,9 @@ const Jn = {
1725
1733
  image_url: e.string(),
1726
1734
  upload_url: e.string(),
1727
1735
  existed: e.bool()
1728
- }).lock(), f = e.object({
1736
+ }).lock(), h = e.object({
1729
1737
  notification_id: e.string(),
1730
- notification_type: Wn,
1738
+ notification_type: Yn,
1731
1739
  is_read: e.bool(),
1732
1740
  create_time: e.number(),
1733
1741
  origin_user_id: e.string(),
@@ -1748,11 +1756,11 @@ const Jn = {
1748
1756
  reply_id: e.number(),
1749
1757
  reply_content: e.string()
1750
1758
  }).lock(), rr = e.object({
1751
- ...f.shape,
1759
+ ...h.shape,
1752
1760
  ...nr.shape,
1753
1761
  notification_type: e.string().enum(p.System)
1754
1762
  }), ir = e.object({
1755
- ...f.shape,
1763
+ ...h.shape,
1756
1764
  ...O.shape,
1757
1765
  notification_type: e.string().enum(
1758
1766
  p.PostPinned,
@@ -1761,29 +1769,29 @@ const Jn = {
1761
1769
  p.PostLiked
1762
1770
  )
1763
1771
  }), or = e.object({
1764
- ...f.shape,
1772
+ ...h.shape,
1765
1773
  ...O.shape,
1766
1774
  ...T.shape,
1767
1775
  notification_type: e.string().enum(p.PostCommented)
1768
1776
  }), ar = e.object({
1769
- ...f.shape,
1777
+ ...h.shape,
1770
1778
  ...T.shape,
1771
1779
  ...B.shape,
1772
1780
  notification_type: e.string().enum(p.CommentReplied)
1773
1781
  }), sr = e.object({
1774
- ...f.shape,
1782
+ ...h.shape,
1775
1783
  ...T.shape,
1776
1784
  ...O.shape,
1777
1785
  notification_type: e.string().enum(p.CommentLiked, p.CommentDeleted)
1778
1786
  }), cr = e.object({
1779
- ...f.shape,
1787
+ ...h.shape,
1780
1788
  ...B.shape,
1781
1789
  notification_type: e.string().enum(p.ReplyReplied),
1782
1790
  comment_id: e.number(),
1783
1791
  reply_to_reply_id: e.number(),
1784
1792
  reply_to_reply_content: e.string()
1785
1793
  }), ur = e.object({
1786
- ...f.shape,
1794
+ ...h.shape,
1787
1795
  ...B.shape,
1788
1796
  ...T.shape,
1789
1797
  notification_type: e.string().enum(p.ReplyLiked, p.ReplyDeleted)
@@ -1795,16 +1803,16 @@ const Jn = {
1795
1803
  sr,
1796
1804
  cr,
1797
1805
  ur
1798
- ).satisfies().lock(), mr = s({ forums: e.array(se) }), dr = s({ topics: e.array(A) }), gr = s({ topic: A }), pr = s({ post: N }), J = s({
1806
+ ).satisfies().lock(), mr = s({ forums: e.array(se) }), dr = s({ topics: e.array(A) }), gr = s({ topic: A }), pr = s({ post: N }), z = s({
1799
1807
  posts: e.array(N),
1800
1808
  next_token: e.string().optional()
1801
1809
  }), _r = s({ post: N, antispam: ce }), br = s({
1802
1810
  replies: e.array(j),
1803
1811
  next_token: e.string().optional()
1804
- }), yr = s({ reply: j }), fr = s({
1812
+ }), yr = s({ reply: j }), hr = s({
1805
1813
  reply: j.clone().optional(),
1806
1814
  antispam: ce.clone().optional()
1807
- }), hr = s({ comment: v }), wr = s({
1815
+ }), fr = s({ comment: v }), wr = s({
1808
1816
  comments: e.array(v),
1809
1817
  next_token: e.string().optional()
1810
1818
  }), kr = s({
@@ -1820,8 +1828,8 @@ const Jn = {
1820
1828
  });
1821
1829
  class Nr {
1822
1830
  constructor(t) {
1823
- d(this, "token");
1824
- d(this, "req");
1831
+ m(this, "token");
1832
+ m(this, "req");
1825
1833
  this.token = t, this.req = t.req;
1826
1834
  }
1827
1835
  /**
@@ -1860,7 +1868,7 @@ class Nr {
1860
1868
  * https://kdocs.cn/l/cbggfJodHLIz?linkname=XKI9lDVrPq
1861
1869
  */
1862
1870
  async getPosts(t, r) {
1863
- const { data: n, code: i, message: o } = await this.req.get("community/posts", J, {
1871
+ const { data: n, code: i, message: o } = await this.req.get("community/posts", z, {
1864
1872
  ...r,
1865
1873
  params: c(t)
1866
1874
  });
@@ -1875,12 +1883,12 @@ class Nr {
1875
1883
  * https://kdocs.cn/l/cbggfJodHLIz?linkname=yXubbZuDlC
1876
1884
  */
1877
1885
  async getPinnedPosts(t, r, n, i) {
1878
- const { data: o, code: g, message: m } = await this.req.get("community/pinned-posts", J, {
1886
+ const { data: o, code: g, message: d } = await this.req.get("community/pinned-posts", z, {
1879
1887
  ...i,
1880
1888
  params: c({ forum_id: t, max_results: r, next_token: n })
1881
1889
  });
1882
1890
  return o ?? {
1883
- message: m,
1891
+ message: d,
1884
1892
  error: g
1885
1893
  };
1886
1894
  }
@@ -1937,7 +1945,7 @@ class Nr {
1937
1945
  * https://kdocs.cn/l/cbggfJodHLIz?linkname=RIc7oxVGae
1938
1946
  */
1939
1947
  async getComment(t, r) {
1940
- const { data: n, code: i, message: o } = await this.req.get("community/comment", hr, {
1948
+ const { data: n, code: i, message: o } = await this.req.get("community/comment", fr, {
1941
1949
  ...r,
1942
1950
  params: { comment_id: t }
1943
1951
  });
@@ -2004,7 +2012,7 @@ class Nr {
2004
2012
  const { data: n, code: i, message: o } = await this.req.post(
2005
2013
  "community/reply",
2006
2014
  c(t),
2007
- fr,
2015
+ hr,
2008
2016
  r
2009
2017
  );
2010
2018
  return n ?? {
@@ -2129,9 +2137,9 @@ class Or {
2129
2137
  * https://developers.weixin.qq.com/miniprogram/dev/api/open-api/account-info/wx.getAccountInfoSync.html
2130
2138
  */
2131
2139
  constructor(t, r) {
2132
- d(this, "token");
2133
- d(this, "$appid");
2134
- d(this, "req");
2140
+ m(this, "token");
2141
+ m(this, "$appid");
2142
+ m(this, "req");
2135
2143
  this.token = t, this.req = t.req, this.$appid = r, this.getLoginCache();
2136
2144
  }
2137
2145
  get appid() {
@@ -2202,7 +2210,7 @@ class Or {
2202
2210
  * - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
2203
2211
  */
2204
2212
  async webLogin(t = "snsapi_userinfo", r) {
2205
- const n = P("code"), i = Date.now(), o = +P("state");
2213
+ const n = $("code"), i = Date.now(), o = +$("state");
2206
2214
  if (!n || !o || o < i - 1e3 * 60 * 5 || o > i) {
2207
2215
  const le = Q(["code", "state"]);
2208
2216
  location.replace(
@@ -2218,13 +2226,13 @@ class Or {
2218
2226
  const g = Q(["code", "state"]);
2219
2227
  "replaceState" in history && history.replaceState({}, "", g);
2220
2228
  const {
2221
- data: m,
2222
- code: h,
2229
+ data: d,
2230
+ code: f,
2223
2231
  message: ue
2224
2232
  } = await this.req.post("weixin/login", { code: n, appid: this.appid }, E, r);
2225
- return m && (this.token.weixinToken = m.weixin_token, await this.token.autoLogin()), m ?? {
2233
+ return d && (this.token.weixinToken = d.weixin_token, await this.token.autoLogin()), d ?? {
2226
2234
  message: ue,
2227
- error: h
2235
+ error: f
2228
2236
  };
2229
2237
  }
2230
2238
  /**
@@ -2276,8 +2284,8 @@ export {
2276
2284
  un as ClaimActivationKeyEngagementDataValidator,
2277
2285
  b as ClaimRewardStatus,
2278
2286
  U as ClaimRewardStatusValidator,
2279
- Pn as ClaimedItemValidator,
2280
- W as ClubAddressValidator,
2287
+ $n as ClaimedItemValidator,
2288
+ Y as ClubAddressValidator,
2281
2289
  Er as ClubApi,
2282
2290
  ee as ClubBenefitSummaryValidator,
2283
2291
  Ae as ClubBenefitValidator,
@@ -2288,8 +2296,8 @@ export {
2288
2296
  Ge as ClubCreditLogValidator,
2289
2297
  Ee as ClubGlobalConfigValidator,
2290
2298
  xe as ClubItemType,
2291
- X as ClubItemTypeValidator,
2292
- Pe as ClubPlayerValidator,
2299
+ W as ClubItemTypeValidator,
2300
+ $e as ClubPlayerValidator,
2293
2301
  te as ClubProductValidator,
2294
2302
  Se as ClubRedemptionStatus,
2295
2303
  Le as ClubRedemptionStatusValidator,
@@ -2298,30 +2306,30 @@ export {
2298
2306
  jn as CommentEngagementValidator,
2299
2307
  v as CommentValidator,
2300
2308
  Nr as CommunityApi,
2301
- We as EngageAccountType,
2309
+ Ye as EngageAccountType,
2302
2310
  et as EngageAccountTypeValidator,
2303
2311
  En as EngageResponseValidator,
2304
2312
  qn as EngageRewardValidator,
2305
2313
  Gr as EventApi,
2306
2314
  sn as EventConfigValidator,
2307
2315
  bt as EventFeatureConfigOfCashbackValidator,
2308
- ft as EventFeatureConfigOfCheckInValidator,
2316
+ ht as EventFeatureConfigOfCheckInValidator,
2309
2317
  wt as EventFeatureConfigOfClaimActivationKeyValidator,
2310
2318
  vt as EventFeatureConfigOfClaimRewardsValidator,
2311
2319
  Vt as EventFeatureConfigOfCommentValidator,
2312
2320
  jt as EventFeatureConfigOfFollowValidator,
2313
2321
  xt as EventFeatureConfigOfGiftCodeValidator,
2314
2322
  Lt as EventFeatureConfigOfInviteValidator,
2315
- Pt as EventFeatureConfigOfInvitedRegisterValidator,
2323
+ $t as EventFeatureConfigOfInvitedRegisterValidator,
2316
2324
  Gt as EventFeatureConfigOfLotteryDrawValidator,
2317
2325
  Dt as EventFeatureConfigOfLotteryValidator,
2318
2326
  Nt as EventFeatureConfigOfPreregisterValidator,
2319
2327
  Bt as EventFeatureConfigOfQuestValidator,
2320
2328
  Mt as EventFeatureConfigOfRegisterValidator,
2321
- Ht as EventFeatureConfigOfShareValidator,
2322
- Jt as EventFeatureConfigOfSubscribeValidator,
2323
- Xt as EventFeatureConfigOfSurveyValidator,
2324
- Wt as EventFeatureConfigOfTeamValidator,
2329
+ Kt as EventFeatureConfigOfShareValidator,
2330
+ zt as EventFeatureConfigOfSubscribeValidator,
2331
+ Wt as EventFeatureConfigOfSurveyValidator,
2332
+ Yt as EventFeatureConfigOfTeamValidator,
2325
2333
  nn as EventFeatureConfigOfVoteValidator,
2326
2334
  an as EventFeatureConfigValidator,
2327
2335
  tt as EventPeriodType,
@@ -2332,7 +2340,7 @@ export {
2332
2340
  pt as FeatureRewardValidator,
2333
2341
  u as FeatureType,
2334
2342
  rt as FeatureTypeValidator,
2335
- Jn as ForumMode,
2343
+ zn as ForumMode,
2336
2344
  Zn as ForumModeValidator,
2337
2345
  se as ForumValidator,
2338
2346
  R as GamerItemType,
@@ -2347,8 +2355,8 @@ export {
2347
2355
  dn as LotteryEngagementDataValidator,
2348
2356
  k as LotteryTicketStatus,
2349
2357
  Ur as LotteryTicketStatusValidator,
2350
- f as NotificationBaseValidator,
2351
- Yn as NotificationCategory,
2358
+ h as NotificationBaseValidator,
2359
+ Xn as NotificationCategory,
2352
2360
  Ar as NotificationCategoryValidator,
2353
2361
  ar as NotificationCommentReplyValidator,
2354
2362
  sr as NotificationCommentValidator,
@@ -2362,11 +2370,11 @@ export {
2362
2370
  ur as NotificationReplyValidator,
2363
2371
  rr as NotificationSystemValidator,
2364
2372
  p as NotificationType,
2365
- Wn as NotificationTypeValidator,
2373
+ Yn as NotificationTypeValidator,
2366
2374
  lr as NotificationValidator,
2367
2375
  Fe as PlayerRoleCardValidator,
2368
- Y as PlayerRoleValidator,
2369
- Xn as PostStatus,
2376
+ X as PlayerRoleValidator,
2377
+ Wn as PostStatus,
2370
2378
  ae as PostStatusValidator,
2371
2379
  N as PostValidator,
2372
2380
  bn as PreregisterEngagementDataValidator,
@@ -2379,18 +2387,18 @@ export {
2379
2387
  gt as RegularRewardValidator,
2380
2388
  er as ReplyToValidator,
2381
2389
  j as ReplyValidator,
2382
- Pr as RewardItemType,
2390
+ $r as RewardItemType,
2383
2391
  re as RewardItemTypeValidator,
2384
2392
  st as RewardSource,
2385
2393
  F as RewardSourceValidator,
2386
2394
  _ as RewardStatus,
2387
- $ as RewardStatusSuffix,
2395
+ P as RewardStatusSuffix,
2388
2396
  oe as RewardStatusSuffixValidator,
2389
- $r as RewardStatusValidator,
2397
+ Pr as RewardStatusValidator,
2390
2398
  Tn as RewardValidator,
2391
2399
  Ue as RoleBaseInfoValidator,
2392
- $e as ServerBaseInfoValidator,
2393
- fn as ShareEngagementDataValidator,
2400
+ Pe as ServerBaseInfoValidator,
2401
+ hn as ShareEngagementDataValidator,
2394
2402
  wn as SurveyEngagementDataValidator,
2395
2403
  lt as TeamAction,
2396
2404
  Fr as TeamActionValidator,
@@ -2409,7 +2417,7 @@ export {
2409
2417
  ot as VoteOptionSource,
2410
2418
  at as VoteOptionSourceValidator,
2411
2419
  Or as WeixinApi,
2412
- hn as WeixinSubscribeEngagementDataValidator,
2420
+ fn as WeixinSubscribeEngagementDataValidator,
2413
2421
  jr as WeixinWebLoginErrorCode,
2414
2422
  Rr as isWeixinSignResponse
2415
2423
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@seayoo-web/gamer-api",
3
3
  "description": "agent for gamer api",
4
- "version": "2.5.5",
4
+ "version": "2.5.6",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -30,15 +30,15 @@
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.13.1",
33
+ "@seayoo-web/tsconfig": "^1.0.5",
33
34
  "@seayoo-web/combo-webview": "^2.5.4",
35
+ "@seayoo-web/utils": "^3.6.2",
34
36
  "@seayoo-web/request": "^3.2.0",
35
- "@seayoo-web/scripts": "^2.6.1",
36
- "@seayoo-web/utils": "^3.6.1",
37
- "@seayoo-web/tsconfig": "^1.0.5"
37
+ "@seayoo-web/scripts": "^2.6.2"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@seayoo-web/combo-webview": "^2.5.4",
41
- "@seayoo-web/utils": "^3.6.1"
41
+ "@seayoo-web/utils": "^3.6.2"
42
42
  },
43
43
  "scripts": {
44
44
  "prebuild": "pnpm -F request build && pnpm -F combo-webview build",
@@ -69,6 +69,8 @@ export declare class AuthToken {
69
69
  * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ReeJpWraRO
70
70
  */
71
71
  autoLogin(): Promise<boolean>;
72
+ private $loginWithTokenJob;
73
+ private loginWithToken;
72
74
  /**
73
75
  * 获取当前登录用户的 Session 的信息
74
76
  *