@seayoo-web/gamer-api 2.0.4 → 2.0.7

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/README.md CHANGED
@@ -47,7 +47,7 @@ export async function login() {
47
47
 
48
48
  // 获取用户数据
49
49
  export async function getUserInfo() {
50
- return authToken.isLogined ? await authToken.getSession() : null;
50
+ return authToken.isLoggedIn ? await authToken.getSession() : null;
51
51
  }
52
52
 
53
53
  // 退出登录(同步操作)
@@ -92,7 +92,7 @@ export function login() {
92
92
 
93
93
  // 获取用户数据
94
94
  export async function getUserInfo() {
95
- return authToken.isLogined ? await authToken.getSession() : null;
95
+ return authToken.isLoggedIn ? await authToken.getSession() : null;
96
96
  }
97
97
 
98
98
  // 退出登录(同步操作)
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ var ue = Object.defineProperty;
2
2
  var le = (i, t, n) => t in i ? ue(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
3
3
  var l = (i, t, n) => le(i, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { isComboWebView as me } from "@seayoo-web/combo-webview";
5
- import { isPlainObject as L, useConsole as de, Support as _, usePromise as ge, pruneURL as pe, queryString as S, pruneObject as a, v as e, omitFields as k, typedObjectGuard as o, parseJSON as _e, removePara as G } from "@seayoo-web/utils";
5
+ import { isPlainObject as k, useConsole as de, Support as _, usePromise as ge, pruneURL as pe, queryString as L, pruneObject as a, v as e, omitFields as v, typedObjectGuard as o, parseJSON as _e, removePara as G } from "@seayoo-web/utils";
6
6
  import "@seayoo-web/request";
7
7
  function be(i) {
8
- return L(i, "gamer_token") && typeof i.gamer_token == "string";
8
+ return k(i, "gamer_token") && typeof i.gamer_token == "string";
9
9
  }
10
10
  function A(i) {
11
- return L(i);
11
+ return k(i);
12
12
  }
13
13
  const y = de("GamerApiSDK");
14
14
  function ye(i) {
@@ -59,7 +59,7 @@ const he = {
59
59
  }
60
60
  }
61
61
  }, f = "gamer_token";
62
- class hr {
62
+ class wr {
63
63
  constructor(t, n) {
64
64
  l(this, "$idToken", "");
65
65
  l(this, "$weixinToken", "");
@@ -83,7 +83,7 @@ class hr {
83
83
  requestTransformer: (u) => {
84
84
  this.$gamerToken && (u.headers.Authorization = `Bearer ${this.$gamerToken}`);
85
85
  }
86
- }), me() ? this.$gamerToken = S("gamer_token") : this.loadGamerTokenCache();
86
+ }), me() ? this.$gamerToken = L("gamer_token") : this.loadGamerTokenCache();
87
87
  }
88
88
  loadGamerTokenCache() {
89
89
  const n = this.storage.get(f).match(/^(\d{12,})#(.{8,})$/);
@@ -309,7 +309,7 @@ const ke = {
309
309
  decreased_credit: e.number(),
310
310
  expired_credit: e.number(),
311
311
  balance_credit: e.number()
312
- }).lock(), Ie = e.object({
312
+ }).lock(), De = e.object({
313
313
  id: e.number(),
314
314
  change_type: Ve,
315
315
  change_scene: je,
@@ -351,10 +351,10 @@ const ke = {
351
351
  created_at: e.number(),
352
352
  updated_at: e.number(),
353
353
  redeemable_quantity: e.number().optional()
354
- }).lock(), De = e.object({
355
- ...k(K.shape, "tag"),
354
+ }).lock(), Ie = e.object({
355
+ ...v(K.shape, "tag"),
356
356
  product: X.clone().optional()
357
- }).lock(), wr = e.union(
357
+ }).lock(), kr = e.union(
358
358
  e.object({
359
359
  server_id: e.string(),
360
360
  role_id: e.string()
@@ -375,7 +375,7 @@ const ke = {
375
375
  server_id: e.string(),
376
376
  role_id: e.string(),
377
377
  role_name: e.string()
378
- }).lock(), Ne = e.object({
378
+ }).lock(), Oe = e.object({
379
379
  redemption_id: e.number(),
380
380
  player_id: e.string(),
381
381
  product_id: e.number(),
@@ -389,14 +389,14 @@ const ke = {
389
389
  status: xe,
390
390
  created_at: e.number(),
391
391
  extra_data: e.union(Ge.clone(), Ae.clone()).satisfies().optional()
392
- }), Oe = e.guard(Se), N = o({ player: Le }), Be = o({ roles: e.array(z) }), j = o({ role_card: $e }), O = e.guard(Ue), B = e.guard(J), Qe = o({ addresses: e.array(J) }), Me = e.guard(Fe), He = o({
393
- credit_logs: e.array(Ie),
392
+ }), Ne = e.guard(Se), O = o({ player: Le }), Be = o({ roles: e.array(z) }), T = o({ role_card: $e }), N = e.guard(Ue), B = e.guard(J), Qe = o({ addresses: e.array(J) }), Me = e.guard(Fe), He = o({
393
+ credit_logs: e.array(De),
394
394
  next_token: e.string().optional()
395
- }), ze = o({ products: e.array(X) }), Je = o({ benefits: e.array(K) }), Ke = o({ benefit: De }), Xe = o({
396
- redemptions: e.array(Ne),
395
+ }), ze = o({ products: e.array(X) }), Je = o({ benefits: e.array(K) }), Ke = o({ benefit: Ie }), Xe = o({
396
+ redemptions: e.array(Oe),
397
397
  next_token: e.string().optional()
398
398
  });
399
- class kr {
399
+ class vr {
400
400
  constructor(t) {
401
401
  l(this, "token");
402
402
  l(this, "req");
@@ -408,7 +408,7 @@ class kr {
408
408
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=tuhsPt3ihp
409
409
  */
410
410
  async getConfig() {
411
- const { data: t } = await this.req.get("club/config", Oe);
411
+ const { data: t } = await this.req.get("club/config", Ne);
412
412
  return t;
413
413
  }
414
414
  /**
@@ -418,7 +418,7 @@ class kr {
418
418
  */
419
419
  async getCurrentPlayer() {
420
420
  await this.token.autoLogin();
421
- const { data: t, code: n } = await this.req.get("club/current-player", N);
421
+ const { data: t, code: n } = await this.req.get("club/current-player", O);
422
422
  return (t == null ? void 0 : t.player) ?? { error: n };
423
423
  }
424
424
  /**
@@ -433,7 +433,7 @@ class kr {
433
433
  {
434
434
  id_token: this.token.idToken
435
435
  },
436
- N
436
+ O
437
437
  );
438
438
  return (t == null ? void 0 : t.player) ?? {
439
439
  error: n
@@ -457,7 +457,7 @@ class kr {
457
457
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=A1Wr7kUXnS
458
458
  */
459
459
  async getRoleCard(t) {
460
- const { data: n } = await this.req.get("club/role-card", j, {
460
+ const { data: n } = await this.req.get("club/role-card", T, {
461
461
  params: { member_id: t }
462
462
  });
463
463
  return (n == null ? void 0 : n.role_card) ?? null;
@@ -469,7 +469,7 @@ class kr {
469
469
  */
470
470
  async setRoleCard(t) {
471
471
  if (!await this.token.autoLogin()) return null;
472
- const { data: n } = await this.req.post("club/role-card", t, j);
472
+ const { data: n } = await this.req.post("club/role-card", t, T);
473
473
  return (n == null ? void 0 : n.role_card) ?? null;
474
474
  }
475
475
  /**
@@ -479,7 +479,7 @@ class kr {
479
479
  */
480
480
  async refreshRoleCard() {
481
481
  if (!await this.token.autoLogin()) return null;
482
- const { data: t } = await this.req.post("club/refresh-role-card", {}, j);
482
+ const { data: t } = await this.req.post("club/refresh-role-card", {}, T);
483
483
  return (t == null ? void 0 : t.role_card) ?? null;
484
484
  }
485
485
  /**
@@ -488,7 +488,7 @@ class kr {
488
488
  * https://kdocs.cn/l/cgp4gSBMbOf1?linkname=TMWBCFcOr2
489
489
  */
490
490
  async getUserProfile(t) {
491
- const { data: n } = await this.req.get("club/user-profile", O, {
491
+ const { data: n } = await this.req.get("club/user-profile", N, {
492
492
  params: { member_id: t }
493
493
  });
494
494
  return n;
@@ -500,7 +500,7 @@ class kr {
500
500
  */
501
501
  async updateUserProfile(t) {
502
502
  await this.token.autoLogin();
503
- const { data: n, code: r } = await this.req.post("club/user-profile", t, O);
503
+ const { data: n, code: r } = await this.req.post("club/user-profile", t, N);
504
504
  return n ?? {
505
505
  error: r
506
506
  };
@@ -625,7 +625,7 @@ class kr {
625
625
  return { redemptions: (n == null ? void 0 : n.redemptions) || [], next_token: n == null ? void 0 : n.next_token };
626
626
  }
627
627
  }
628
- const v = {
628
+ const C = {
629
629
  /** 活动道具 */
630
630
  EventItem: "event_item",
631
631
  /** 游戏内道具 */
@@ -642,7 +642,7 @@ const v = {
642
642
  Credit: "credit",
643
643
  /** 空奖励 */
644
644
  VoidItem: "void_item"
645
- }, Y = e.string().enum(v).lock(), vr = v, Z = Y, Ye = {
645
+ }, Y = e.string().enum(C).lock(), Cr = C, Z = Y, Ye = {
646
646
  /** 世游通行证 ID / Combo ID */
647
647
  UserId: "user_id",
648
648
  /** 游戏角色 ID */
@@ -718,7 +718,7 @@ const v = {
718
718
  Failed: "failed",
719
719
  /** 奖励已发货 */
720
720
  Delivered: "delivered"
721
- }, Cr = e.string().enum(g).lock(), ot = {
721
+ }, Vr = e.string().enum(g).lock(), ot = {
722
722
  /** 奖励未领取 */
723
723
  Unclaimed: g.Unclaimed,
724
724
  /** 奖励已领取 */
@@ -765,7 +765,7 @@ const v = {
765
765
  Claimed: "claimed",
766
766
  /** 领奖失败 */
767
767
  Fail: "fail"
768
- }, Vr = e.string().enum(h).lock(), ut = {
768
+ }, Rr = e.string().enum(h).lock(), ut = {
769
769
  /** 发起组队 */
770
770
  Assemble: "assemble",
771
771
  /** 加入队伍 */
@@ -776,14 +776,14 @@ const v = {
776
776
  ChangeVisibility: "change_visibility",
777
777
  /** 查询组队信息 */
778
778
  Query: "query"
779
- }, Rr = e.string().enum(ut).lock(), lt = {
779
+ }, jr = e.string().enum(ut).lock(), lt = {
780
780
  /** 查询抽奖券 */
781
781
  Query: "query",
782
782
  /** 开奖 */
783
783
  Draw: "draw",
784
784
  /** 领奖 */
785
785
  Claim: "claim"
786
- }, jr = e.string().enum(lt).lock(), mt = e.string().enum(k(v, "GiftCode", "LotteryTicket")), $ = e.object({
786
+ }, Tr = e.string().enum(lt).lock(), mt = e.string().enum(v(C, "GiftCode", "LotteryTicket")), $ = e.object({
787
787
  reward_item_id: e.number(),
788
788
  reward_amount: e.number(),
789
789
  reward_item_name: e.string(),
@@ -866,7 +866,7 @@ const v = {
866
866
  }), xt = s.InvitedRegister, St = e.object({
867
867
  ...c.shape,
868
868
  feature_type: e.string().enum(xt)
869
- }), Lt = e.string().enum(k(v, "GiftCode", "LotteryTicket")), Pt = s.Lottery, Et = e.object({
869
+ }), Lt = e.string().enum(v(C, "GiftCode", "LotteryTicket")), Pt = s.Lottery, Et = e.object({
870
870
  reward_item_id: e.number(),
871
871
  reward_item_name: e.string(),
872
872
  reward_item_type: Lt,
@@ -892,9 +892,9 @@ const v = {
892
892
  draw_not_before: e.number(),
893
893
  draw_not_after: e.number()
894
894
  })
895
- }), It = s.Preregister, Dt = e.object({
895
+ }), Dt = s.Preregister, It = e.object({
896
896
  ...c.shape,
897
- feature_type: e.string().enum(It)
897
+ feature_type: e.string().enum(Dt)
898
898
  }), Gt = s.Quest, At = e.object({
899
899
  ...c.shape,
900
900
  feature_type: e.string().enum(Gt),
@@ -906,9 +906,9 @@ const v = {
906
906
  completion_value: e.number()
907
907
  }).optional()
908
908
  })
909
- }), Nt = s.Register, Ot = e.object({
909
+ }), Ot = s.Register, Nt = e.object({
910
910
  ...c.shape,
911
- feature_type: e.string().enum(Nt)
911
+ feature_type: e.string().enum(Ot)
912
912
  }), Bt = s.Share, Qt = e.object({
913
913
  ...c.shape,
914
914
  feature_type: e.string().enum(Bt),
@@ -969,9 +969,9 @@ const v = {
969
969
  St,
970
970
  $t,
971
971
  Ft,
972
- Dt,
972
+ It,
973
973
  At,
974
- Ot,
974
+ Nt,
975
975
  Qt,
976
976
  Ht,
977
977
  Jt,
@@ -984,10 +984,10 @@ const v = {
984
984
  until: e.number(),
985
985
  visit_count: e.number().optional(),
986
986
  features: e.array(en)
987
- }).lock(), T = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), nn = e.object({
988
- order_total_amount: T,
989
- cashback_total_amount: T,
990
- game_item_count: T
987
+ }).lock(), q = e.union(e.string().pattern("NumberString", /^\d+$/), e.number()), nn = e.object({
988
+ order_total_amount: q,
989
+ cashback_total_amount: q,
990
+ game_item_count: q
991
991
  }), rn = e.object({
992
992
  gift_code: e.string()
993
993
  }), on = e.object({
@@ -1021,7 +1021,7 @@ const v = {
1021
1021
  }),
1022
1022
  e.object({
1023
1023
  ticket: e.string(),
1024
- status: e.string().enum(k(h, "Unknown", "Pending")),
1024
+ status: e.string().enum(v(h, "Unknown", "Pending")),
1025
1025
  reward: te
1026
1026
  })
1027
1027
  ).satisfies(), un = e.object({
@@ -1054,7 +1054,7 @@ const v = {
1054
1054
  team_code: e.string(),
1055
1055
  leader_name: e.string(),
1056
1056
  total_members: e.number()
1057
- }), Tr = e.object({
1057
+ }), qr = e.object({
1058
1058
  is_leader: e.bool(),
1059
1059
  is_myself: e.bool().optional(),
1060
1060
  role_name: e.string(),
@@ -1090,7 +1090,11 @@ const v = {
1090
1090
  rn,
1091
1091
  bn,
1092
1092
  mn,
1093
- un
1093
+ un,
1094
+ e.custom(
1095
+ "EmptyObject",
1096
+ (i) => k(i) && Object.keys(i).length === 0
1097
+ )
1094
1098
  ).satisfies().lock(), hn = e.object({
1095
1099
  reward_id: e.number(),
1096
1100
  reward_item_id: e.number(),
@@ -1148,7 +1152,7 @@ const v = {
1148
1152
  }), Vn = e.object({
1149
1153
  reward_id: e.number(),
1150
1154
  reward_status: P
1151
- }), Rn = e.guard(tn), jn = e.guard(kn), q = o({ count: e.number() }), Tn = o({ first_visit: e.bool() }), qn = o({
1155
+ }), Rn = e.guard(tn), jn = e.guard(kn), x = o({ count: e.number() }), Tn = o({ first_visit: e.bool() }), qn = o({
1152
1156
  engagements: e.union(e.array(fn), e.array(_n))
1153
1157
  }), xn = o({
1154
1158
  status: e.array(vn)
@@ -1166,10 +1170,10 @@ const v = {
1166
1170
  scene: e.string()
1167
1171
  }), Fn = o({
1168
1172
  params: e.string()
1169
- }), In = o({
1173
+ }), Dn = o({
1170
1174
  img: e.string()
1171
1175
  });
1172
- class qr {
1176
+ class xr {
1173
1177
  constructor(t, n) {
1174
1178
  l(this, "token");
1175
1179
  l(this, "event", 0);
@@ -1202,7 +1206,7 @@ class qr {
1202
1206
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
1203
1207
  */
1204
1208
  async getEngagementsUserCount(t) {
1205
- const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, q, {
1209
+ const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
1206
1210
  params: { feature_id: t, type: "user" }
1207
1211
  });
1208
1212
  return (n == null ? void 0 : n.count) ?? null;
@@ -1213,7 +1217,7 @@ class qr {
1213
1217
  * https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
1214
1218
  */
1215
1219
  async getEngagementsCount(t) {
1216
- const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, q, {
1220
+ const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, x, {
1217
1221
  params: { feature_id: t, type: "engagement" }
1218
1222
  });
1219
1223
  return (n == null ? void 0 : n.count) ?? null;
@@ -1362,7 +1366,7 @@ class qr {
1362
1366
  */
1363
1367
  async getUserItemCount(t) {
1364
1368
  if (!await this.token.autoLogin()) return null;
1365
- const { data: n } = await this.req.get(`event/${this.event}/user-item-count`, q, {
1369
+ const { data: n } = await this.req.get(`event/${this.event}/user-item-count`, x, {
1366
1370
  params: { item_id: t }
1367
1371
  });
1368
1372
  return (n == null ? void 0 : n.count) ?? null;
@@ -1411,16 +1415,16 @@ class qr {
1411
1415
  */
1412
1416
  async generateUnlimitQrcode(t) {
1413
1417
  if (!await this.token.autoLogin()) return null;
1414
- const { data: n } = await this.req.post("event/unlimit-qrcode", a(t), In);
1418
+ const { data: n } = await this.req.post("event/unlimit-qrcode", a(t), Dn);
1415
1419
  return (n == null ? void 0 : n.img) ?? null;
1416
1420
  }
1417
1421
  }
1418
- const Dn = {
1422
+ const In = {
1419
1423
  /** 所有人均可以发帖 */
1420
1424
  All: "all",
1421
1425
  /** 指定用户可发帖 */
1422
1426
  Limit: "limit"
1423
- }, Gn = e.string().enum(Dn).lock(), An = {
1427
+ }, Gn = e.string().enum(In).lock(), An = {
1424
1428
  /** 待审核(仅自己可见) */
1425
1429
  Pending: "pending",
1426
1430
  /** 审核通过 */
@@ -1429,14 +1433,14 @@ const Dn = {
1429
1433
  Failed: "failed",
1430
1434
  /** 嫌疑(仅自己可见) */
1431
1435
  Suspect: "suspect"
1432
- }, ie = e.string().enum(An).lock(), Nn = {
1436
+ }, ie = e.string().enum(An).lock(), On = {
1433
1437
  /** 系统通知 */
1434
1438
  System: "system",
1435
1439
  /** 评论我的 */
1436
1440
  Comment: "comment",
1437
1441
  /** 点赞通知 */
1438
1442
  Like: "like"
1439
- }, xr = e.string().enum(Nn).lock(), m = {
1443
+ }, Sr = e.string().enum(On).lock(), m = {
1440
1444
  /** 系统通知 */
1441
1445
  System: "system",
1442
1446
  /** 帖子被置顶 */
@@ -1461,7 +1465,7 @@ const Dn = {
1461
1465
  ReplyLiked: "reply_liked",
1462
1466
  /** 回复被删除 */
1463
1467
  ReplyDeleted: "reply_deleted"
1464
- }, On = e.string().enum(m).lock(), oe = e.object({
1468
+ }, Nn = e.string().enum(m).lock(), oe = e.object({
1465
1469
  forum_id: e.number(),
1466
1470
  icon_url: e.string(),
1467
1471
  name: e.string(),
@@ -1503,7 +1507,7 @@ const Dn = {
1503
1507
  replied_by: e.string(),
1504
1508
  nickname: e.string(),
1505
1509
  avatar_url: e.string()
1506
- }).lock(), C = e.object({
1510
+ }).lock(), V = e.object({
1507
1511
  reply_id: e.number(),
1508
1512
  comment_id: e.number(),
1509
1513
  comment_content: e.string().optional(),
@@ -1537,14 +1541,14 @@ const Dn = {
1537
1541
  image_url: e.string(),
1538
1542
  create_time: e.number(),
1539
1543
  status: ie,
1540
- replies: e.array(C).optional()
1544
+ replies: e.array(V).optional()
1541
1545
  }).lock(), Qn = e.object({
1542
1546
  image_url: e.string(),
1543
1547
  upload_url: e.string(),
1544
1548
  existed: e.bool()
1545
1549
  }).lock(), b = e.object({
1546
1550
  notification_id: e.string(),
1547
- notification_type: On,
1551
+ notification_type: Nn,
1548
1552
  is_read: e.bool(),
1549
1553
  create_time: e.number(),
1550
1554
  origin_user_id: e.string(),
@@ -1553,15 +1557,15 @@ const Dn = {
1553
1557
  }).lock(), Mn = e.object({
1554
1558
  system_message_subject: e.string(),
1555
1559
  system_message_content: e.string()
1556
- }).lock(), I = e.object({
1560
+ }).lock(), D = e.object({
1557
1561
  post_id: e.number(),
1558
1562
  post_subject: e.string(),
1559
1563
  post_summary: e.string(),
1560
1564
  post_image_url: e.string()
1561
- }).lock(), V = e.object({
1565
+ }).lock(), R = e.object({
1562
1566
  comment_id: e.number(),
1563
1567
  comment_content: e.string()
1564
- }).lock(), D = e.object({
1568
+ }).lock(), I = e.object({
1565
1569
  reply_id: e.number(),
1566
1570
  reply_content: e.string()
1567
1571
  }).lock(), Hn = e.object({
@@ -1570,7 +1574,7 @@ const Dn = {
1570
1574
  notification_type: e.string().enum(m.System)
1571
1575
  }), zn = e.object({
1572
1576
  ...b.shape,
1573
- ...I.shape,
1577
+ ...D.shape,
1574
1578
  notification_type: e.string().enum(
1575
1579
  m.PostPinned,
1576
1580
  m.PostHighlighted,
@@ -1579,30 +1583,30 @@ const Dn = {
1579
1583
  )
1580
1584
  }), Jn = e.object({
1581
1585
  ...b.shape,
1582
- ...I.shape,
1583
- ...V.shape,
1586
+ ...D.shape,
1587
+ ...R.shape,
1584
1588
  notification_type: e.string().enum(m.PostCommented)
1585
1589
  }), Kn = e.object({
1586
1590
  ...b.shape,
1587
- ...V.shape,
1588
- ...D.shape,
1591
+ ...R.shape,
1592
+ ...I.shape,
1589
1593
  notification_type: e.string().enum(m.CommentReplied)
1590
1594
  }), Xn = e.object({
1591
1595
  ...b.shape,
1592
- ...V.shape,
1593
- ...I.shape,
1596
+ ...R.shape,
1597
+ ...D.shape,
1594
1598
  notification_type: e.string().enum(m.CommentLiked, m.CommentDeleted)
1595
1599
  }), Yn = e.object({
1596
1600
  ...b.shape,
1597
- ...D.shape,
1601
+ ...I.shape,
1598
1602
  notification_type: e.string().enum(m.ReplyReplied),
1599
1603
  comment_id: e.number(),
1600
1604
  reply_to_reply_id: e.number(),
1601
1605
  reply_to_reply_content: e.string()
1602
1606
  }), Zn = e.object({
1603
1607
  ...b.shape,
1604
- ...D.shape,
1605
- ...V.shape,
1608
+ ...I.shape,
1609
+ ...R.shape,
1606
1610
  notification_type: e.string().enum(m.ReplyLiked, m.ReplyDeleted)
1607
1611
  }), Wn = e.union(
1608
1612
  Hn,
@@ -1616,10 +1620,10 @@ const Dn = {
1616
1620
  posts: e.array(F),
1617
1621
  next_token: e.string().optional()
1618
1622
  }), ir = o({ post: F, antispam: ae }), or = o({
1619
- replies: e.array(C),
1623
+ replies: e.array(V),
1620
1624
  next_token: e.string().optional()
1621
- }), ar = o({ reply: C }), sr = o({
1622
- reply: C.clone().optional(),
1625
+ }), ar = o({ reply: V }), sr = o({
1626
+ reply: V.clone().optional(),
1623
1627
  antispam: ae.clone().optional()
1624
1628
  }), cr = o({ comment: w }), ur = o({
1625
1629
  comments: e.array(w),
@@ -1635,7 +1639,7 @@ const Dn = {
1635
1639
  comment: e.number(),
1636
1640
  like: e.number()
1637
1641
  });
1638
- class Sr {
1642
+ class Lr {
1639
1643
  constructor(t) {
1640
1644
  l(this, "token");
1641
1645
  l(this, "req");
@@ -1853,12 +1857,17 @@ class Sr {
1853
1857
  return n;
1854
1858
  }
1855
1859
  }
1856
- function x(i) {
1857
- return L(i, "openid", "unionid", "weixin_token");
1860
+ const pr = o({
1861
+ nonce_str: e.string(),
1862
+ timestamp: e.number(),
1863
+ signature: e.string()
1864
+ });
1865
+ var _r = /* @__PURE__ */ ((i) => (i.RedirectUriDisMatch = "10003", i.AppidError = "10016", i.AuthorizationError = "10015", i.NoRightForScope = "10005", i.Frequently = "10009", i.AppBanded = "10004", i.ShouldFollow = "10006", i.ScopeNull = "10010", i.RedirectUriNull = "10011", i.AppidNull = "10012", i.StateNull = "10013", i))(_r || {});
1866
+ function S(i) {
1867
+ return k(i, "openid", "unionid", "weixin_token");
1858
1868
  }
1859
- var pr = /* @__PURE__ */ ((i) => (i.RedirectUriDisMatch = "10003", i.AppidError = "10016", i.AuthorizationError = "10015", i.NoRightForScope = "10005", i.Frequently = "10009", i.AppBanded = "10004", i.ShouldFollow = "10006", i.ScopeNull = "10010", i.RedirectUriNull = "10011", i.AppidNull = "10012", i.StateNull = "10013", i))(pr || {});
1860
1869
  const M = "wx_login_cache";
1861
- class Lr {
1870
+ class Pr {
1862
1871
  /**
1863
1872
  * 创建微信相关功能接口
1864
1873
  *
@@ -1890,7 +1899,7 @@ class Lr {
1890
1899
  if (!t)
1891
1900
  return null;
1892
1901
  const n = _e(t);
1893
- return x(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
1902
+ return S(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
1894
1903
  }
1895
1904
  /**
1896
1905
  * 小程序页面微信静默登录,获取 weixinToken / openid / unionid。
@@ -1918,7 +1927,7 @@ class Lr {
1918
1927
  const n = await fe(), { data: r, code: u } = await this.req.post(
1919
1928
  "weixin/login",
1920
1929
  { code: n, appid: this.appid },
1921
- x,
1930
+ S,
1922
1931
  { message: !1 }
1923
1932
  );
1924
1933
  return r && (this.token.weixinToken = r.weixin_token, this.token.storage.set(M, JSON.stringify(r)), await this.token.autoLogin()), r ?? { error: u };
@@ -1940,7 +1949,7 @@ class Lr {
1940
1949
  * - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、unionid、昵称、头像等信息,但用户也可能会拒绝授权
1941
1950
  */
1942
1951
  async webLogin(t = "snsapi_userinfo") {
1943
- const n = S("code"), r = Date.now(), u = +S("state");
1952
+ const n = L("code"), r = Date.now(), u = +L("state");
1944
1953
  if (!n || !u || u < r - 1e3 * 60 * 5 || u > r) {
1945
1954
  const ce = G(["code", "state"]);
1946
1955
  location.replace(
@@ -1952,15 +1961,15 @@ class Lr {
1952
1961
  return { error: n };
1953
1962
  const d = G(["code", "state"]);
1954
1963
  "replaceState" in history && history.replaceState({}, "", d);
1955
- const { data: R, code: se } = await this.req.post(
1964
+ const { data: j, code: se } = await this.req.post(
1956
1965
  "weixin/login",
1957
1966
  {
1958
1967
  code: n,
1959
1968
  appid: this.appid
1960
1969
  },
1961
- x
1970
+ S
1962
1971
  );
1963
- return R && (this.token.weixinToken = R.weixin_token, await this.token.autoLogin()), R ?? { error: se };
1972
+ return j && (this.token.weixinToken = j.weixin_token, await this.token.autoLogin()), j ?? { error: se };
1964
1973
  }
1965
1974
  /**
1966
1975
  * 关联游戏账号,无返回值,全程静默
@@ -1979,23 +1988,37 @@ class Lr {
1979
1988
  message: !1
1980
1989
  });
1981
1990
  }
1991
+ /**
1992
+ * 获取集成 JSSDK 所需的签名信息
1993
+ *
1994
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=CuWOqxr9Ue
1995
+ */
1996
+ async getJSSDKConfig() {
1997
+ const { data: t } = await this.req.get("weixin/jssdk-sign", pr, {
1998
+ params: {
1999
+ appid: this.appid,
2000
+ url: location.href.split("#")[0]
2001
+ }
2002
+ });
2003
+ return t;
2004
+ }
1982
2005
  }
1983
2006
  export {
1984
2007
  ae as AntispamValidator,
1985
- hr as AuthToken,
2008
+ wr as AuthToken,
1986
2009
  nn as CashbackEngagementDataValidator,
1987
2010
  p as ClaimRewardStatus,
1988
2011
  P as ClaimRewardStatusValidator,
1989
2012
  Vn as ClaimedItemValidator,
1990
2013
  J as ClubAddressValidator,
1991
- kr as ClubApi,
2014
+ vr as ClubApi,
1992
2015
  K as ClubBenefitSummaryValidator,
1993
- De as ClubBenefitValidator,
2016
+ Ie as ClubBenefitValidator,
1994
2017
  Re as ClubCreditChangeScene,
1995
2018
  je as ClubCreditChangeSceneValidator,
1996
2019
  Ce as ClubCreditChangeType,
1997
2020
  Ve as ClubCreditChangeTypeValidator,
1998
- Ie as ClubCreditLogValidator,
2021
+ De as ClubCreditLogValidator,
1999
2022
  Se as ClubGlobalConfigValidator,
2000
2023
  Te as ClubItemType,
2001
2024
  H as ClubItemTypeValidator,
@@ -2007,12 +2030,12 @@ export {
2007
2030
  Ue as ClubUserProfileValidator,
2008
2031
  fn as CommentEngagementValidator,
2009
2032
  w as CommentValidator,
2010
- Sr as CommunityApi,
2033
+ Lr as CommunityApi,
2011
2034
  Ye as EngageAccountType,
2012
2035
  Ze as EngageAccountTypeValidator,
2013
2036
  Cn as EngageResponseValidator,
2014
2037
  wn as EngageRewardValidator,
2015
- qr as EventApi,
2038
+ xr as EventApi,
2016
2039
  tn as EventConfigValidator,
2017
2040
  _t as EventFeatureConfigOfCashbackValidator,
2018
2041
  yt as EventFeatureConfigOfCheckInValidator,
@@ -2024,9 +2047,9 @@ export {
2024
2047
  St as EventFeatureConfigOfInvitedRegisterValidator,
2025
2048
  Ft as EventFeatureConfigOfLotteryDrawValidator,
2026
2049
  $t as EventFeatureConfigOfLotteryValidator,
2027
- Dt as EventFeatureConfigOfPreregisterValidator,
2050
+ It as EventFeatureConfigOfPreregisterValidator,
2028
2051
  At as EventFeatureConfigOfQuestValidator,
2029
- Ot as EventFeatureConfigOfRegisterValidator,
2052
+ Nt as EventFeatureConfigOfRegisterValidator,
2030
2053
  Qt as EventFeatureConfigOfShareValidator,
2031
2054
  Ht as EventFeatureConfigOfSubscribeValidator,
2032
2055
  Jt as EventFeatureConfigOfSurveyValidator,
@@ -2041,29 +2064,29 @@ export {
2041
2064
  gt as FeatureRewardValidator,
2042
2065
  s as FeatureType,
2043
2066
  tt as FeatureTypeValidator,
2044
- Dn as ForumMode,
2067
+ In as ForumMode,
2045
2068
  Gn as ForumModeValidator,
2046
2069
  oe as ForumValidator,
2047
- v as GamerItemType,
2070
+ C as GamerItemType,
2048
2071
  Y as GamerItemTypeValidator,
2049
2072
  ke as Gender,
2050
2073
  ve as GenderValidator,
2051
2074
  rn as GiftCodeEngagementDataValidator,
2052
2075
  on as InviteEngagementDataValidator,
2053
2076
  lt as LotteryDrawAction,
2054
- jr as LotteryDrawActionValidator,
2077
+ Tr as LotteryDrawActionValidator,
2055
2078
  un as LotteryDrawEngagementDataValidator,
2056
2079
  an as LotteryEngagementDataValidator,
2057
2080
  h as LotteryTicketStatus,
2058
- Vr as LotteryTicketStatusValidator,
2081
+ Rr as LotteryTicketStatusValidator,
2059
2082
  b as NotificationBaseValidator,
2060
- Nn as NotificationCategory,
2061
- xr as NotificationCategoryValidator,
2083
+ On as NotificationCategory,
2084
+ Sr as NotificationCategoryValidator,
2062
2085
  Kn as NotificationCommentReplyValidator,
2063
2086
  Xn as NotificationCommentValidator,
2064
- V as NotificationPayloadCommentValidator,
2065
- I as NotificationPayloadPostValidator,
2066
- D as NotificationPayloadReplyValidator,
2087
+ R as NotificationPayloadCommentValidator,
2088
+ D as NotificationPayloadPostValidator,
2089
+ I as NotificationPayloadReplyValidator,
2067
2090
  Mn as NotificationPayloadSystemValidator,
2068
2091
  Jn as NotificationPostCommentValidator,
2069
2092
  zn as NotificationPostValidator,
@@ -2071,7 +2094,7 @@ export {
2071
2094
  Zn as NotificationReplyValidator,
2072
2095
  Hn as NotificationSystemValidator,
2073
2096
  m as NotificationType,
2074
- On as NotificationTypeValidator,
2097
+ Nn as NotificationTypeValidator,
2075
2098
  Wn as NotificationValidator,
2076
2099
  $e as PlayerRoleCardValidator,
2077
2100
  z as PlayerRoleValidator,
@@ -2083,29 +2106,29 @@ export {
2083
2106
  mn as QuestEngagementDataValidator,
2084
2107
  nt as QuestObjective,
2085
2108
  W as QuestObjectiveValidator,
2086
- wr as RedeemParamsValidator,
2087
- Ne as RedemptionValidator,
2109
+ kr as RedeemParamsValidator,
2110
+ Oe as RedemptionValidator,
2088
2111
  dt as RegularRewardValidator,
2089
2112
  Bn as ReplyToValidator,
2090
- C as ReplyValidator,
2091
- vr as RewardItemType,
2113
+ V as ReplyValidator,
2114
+ Cr as RewardItemType,
2092
2115
  Z as RewardItemTypeValidator,
2093
2116
  at as RewardSource,
2094
2117
  E as RewardSourceValidator,
2095
2118
  g as RewardStatus,
2096
2119
  ot as RewardStatusSuffix,
2097
2120
  ee as RewardStatusSuffixValidator,
2098
- Cr as RewardStatusValidator,
2121
+ Vr as RewardStatusValidator,
2099
2122
  hn as RewardValidator,
2100
2123
  Ee as RoleBaseInfoValidator,
2101
2124
  Pe as ServerBaseInfoValidator,
2102
2125
  dn as ShareEngagementDataValidator,
2103
2126
  pn as SurveyEngagementDataValidator,
2104
2127
  ut as TeamAction,
2105
- Rr as TeamActionValidator,
2128
+ jr as TeamActionValidator,
2106
2129
  bn as TeamEngagementDataValidator,
2107
2130
  _n as TeamEngagementValidator,
2108
- Tr as TeamMemberValidator,
2131
+ qr as TeamMemberValidator,
2109
2132
  st as TeamVisibility,
2110
2133
  ct as TeamVisibilityValidator,
2111
2134
  U as TopicValidator,
@@ -2117,7 +2140,8 @@ export {
2117
2140
  yn as VoteEngagementDataValidator,
2118
2141
  rt as VoteOptionSource,
2119
2142
  it as VoteOptionSourceValidator,
2120
- Lr as WeixinApi,
2143
+ Pr as WeixinApi,
2121
2144
  gn as WeixinSubscribeEngagementDataValidator,
2122
- pr as WeixinWebLoginErrorCode
2145
+ _r as WeixinWebLoginErrorCode,
2146
+ pr as isWeixinSignResponse
2123
2147
  };
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.0.4",
4
+ "version": "2.0.7",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -23,17 +23,18 @@
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.13.1",
25
25
  "vitest": "^3.0.5",
26
- "@seayoo-web/combo-webview": "^2.5.0",
26
+ "@seayoo-web/combo-webview": "^2.5.1",
27
+ "@seayoo-web/tsconfig": "^1.0.3",
27
28
  "@seayoo-web/scripts": "^2.0.1",
28
29
  "@seayoo-web/utils": "^3.4.3",
29
- "@seayoo-web/request": "^3.0.0",
30
- "@seayoo-web/tsconfig": "^1.0.3"
30
+ "@seayoo-web/request": "^3.0.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@seayoo-web/utils": "^3.4.3",
34
- "@seayoo-web/combo-webview": "^2.5.0"
33
+ "@seayoo-web/combo-webview": "^2.5.1",
34
+ "@seayoo-web/utils": "^3.4.3"
35
35
  },
36
36
  "scripts": {
37
+ "prebuild": "pnpm -F request build && pnpm -F combo-webview build",
37
38
  "build": "vite build && tsc --emitDeclarationOnly",
38
39
  "type-check": "tsc --noEmit",
39
40
  "lint": "eslint ./src/**/*.ts",
@@ -1,6 +1,6 @@
1
1
  import { type InferType } from "@seayoo-web/utils";
2
2
  import { type EventFeatureBaseConfig } from "./feature.base";
3
- declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"credit" | "event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "void_item", false, false>;
3
+ declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "void_item", false, false>;
4
4
  declare const featureType: "lottery";
5
5
  export interface FeatureLotteryItemConfig {
6
6
  /** 抽奖奖励道具 id */
@@ -1,5 +1,5 @@
1
1
  import { type InferType } from "@seayoo-web/utils";
2
- declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"credit" | "event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "void_item", false, false>;
2
+ declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "void_item", false, false>;
3
3
  export interface EventRewardItemConfig {
4
4
  /** 玩法奖励道具 id */
5
5
  reward_item_id: number;
@@ -23,7 +23,8 @@ export * from "./engage.subscribe";
23
23
  export * from "./engage.survey";
24
24
  export * from "./engage.team";
25
25
  export * from "./engage.vote";
26
- export type UserEngagementData = PreregisterEngagementData | LotteryEngagementData | SurveyEngagementData | InviteEngagementData | ShareEngagementData | VoteEngagementData | WeixinSubscribeEngagementData | CashbackEngagementData | GiftCodeEngagementData | TeamEngagementData | QuestEngagementData | LotteryDrawEngagementData;
26
+ export type EmptyObject = Record<string | number | symbol, never>;
27
+ export type UserEngagementData = PreregisterEngagementData | LotteryEngagementData | SurveyEngagementData | InviteEngagementData | ShareEngagementData | VoteEngagementData | WeixinSubscribeEngagementData | CashbackEngagementData | GiftCodeEngagementData | TeamEngagementData | QuestEngagementData | LotteryDrawEngagementData | EmptyObject;
27
28
  export declare const UserEngagementDataValidator: import("@seayoo-web/utils").UnionValidator<[import("@seayoo-web/utils").ObjectValidator<{
28
29
  platforms: string[];
29
30
  }, false, false>, import("@seayoo-web/utils").ObjectValidator<LotteryEngagementData, false, false>, import("@seayoo-web/utils").ObjectValidator<{
@@ -37,7 +38,7 @@ export declare const UserEngagementDataValidator: import("@seayoo-web/utils").Un
37
38
  status: /*elided*/ any;
38
39
  reward: /*elided*/ any;
39
40
  })[];
40
- }, false, false>], false, false> & {
41
+ }, false, false>, import("@seayoo-web/utils").CustomValidator<EmptyObject, false, false>], false, false> & {
41
42
  optional: never;
42
43
  maybeNull: never;
43
44
  key: never;
@@ -1,5 +1,5 @@
1
+ import { type WeixinWebLoginErrorCode } from "./weixin.define";
1
2
  import type { AuthToken } from "./token";
2
- import type { WeixinWebLoginErrorCode } from "./weixin.define";
3
3
  import type { RequestInternalError } from "@seayoo-web/request";
4
4
  export * from "./weixin.define";
5
5
  export declare class WeixinApi {
@@ -82,4 +82,14 @@ export declare class WeixinApi {
82
82
  * @param gameCode 从游戏内跳转至小程序时,通过请求参数 query 携带的 game_code,如果值为空则跳过不处理
83
83
  */
84
84
  linkPlayer(weixinToken: string, gameCode: string): Promise<void>;
85
+ /**
86
+ * 获取集成 JSSDK 所需的签名信息
87
+ *
88
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=CuWOqxr9Ue
89
+ */
90
+ getJSSDKConfig(): Promise<{
91
+ nonce_str: string;
92
+ timestamp: number;
93
+ signature: string;
94
+ } | null>;
85
95
  }
@@ -10,6 +10,11 @@ export interface WeixinLoginResponse {
10
10
  */
11
11
  weixin_token: string;
12
12
  }
13
+ export declare const isWeixinSignResponse: (data: unknown) => data is {
14
+ nonce_str: string;
15
+ timestamp: number;
16
+ signature: string;
17
+ };
13
18
  /**
14
19
  * 微信web登录错误码
15
20
  *