@seayoo-web/gamer-api 2.0.6 → 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
@@ -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", "");
@@ -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({
354
+ }).lock(), Ie = e.object({
355
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()
@@ -390,13 +390,13 @@ const ke = {
390
390
  created_at: e.number(),
391
391
  extra_data: e.union(Ge.clone(), Ae.clone()).satisfies().optional()
392
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(Ie),
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({
395
+ }), ze = o({ products: e.array(X) }), Je = o({ benefits: e.array(K) }), Ke = o({ benefit: Ie }), Xe = o({
396
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");
@@ -642,7 +642,7 @@ const C = {
642
642
  Credit: "credit",
643
643
  /** 空奖励 */
644
644
  VoidItem: "void_item"
645
- }, Y = e.string().enum(C).lock(), vr = C, 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 C = {
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 C = {
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 C = {
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(v(C, "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(),
@@ -892,9 +892,9 @@ const C = {
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),
@@ -969,7 +969,7 @@ const C = {
969
969
  St,
970
970
  $t,
971
971
  Ft,
972
- Dt,
972
+ It,
973
973
  At,
974
974
  Nt,
975
975
  Qt,
@@ -1054,7 +1054,7 @@ const C = {
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(),
@@ -1170,10 +1170,10 @@ const C = {
1170
1170
  scene: e.string()
1171
1171
  }), Fn = o({
1172
1172
  params: e.string()
1173
- }), In = o({
1173
+ }), Dn = o({
1174
1174
  img: e.string()
1175
1175
  });
1176
- class qr {
1176
+ class xr {
1177
1177
  constructor(t, n) {
1178
1178
  l(this, "token");
1179
1179
  l(this, "event", 0);
@@ -1415,16 +1415,16 @@ class qr {
1415
1415
  */
1416
1416
  async generateUnlimitQrcode(t) {
1417
1417
  if (!await this.token.autoLogin()) return null;
1418
- 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);
1419
1419
  return (n == null ? void 0 : n.img) ?? null;
1420
1420
  }
1421
1421
  }
1422
- const Dn = {
1422
+ const In = {
1423
1423
  /** 所有人均可以发帖 */
1424
1424
  All: "all",
1425
1425
  /** 指定用户可发帖 */
1426
1426
  Limit: "limit"
1427
- }, Gn = e.string().enum(Dn).lock(), An = {
1427
+ }, Gn = e.string().enum(In).lock(), An = {
1428
1428
  /** 待审核(仅自己可见) */
1429
1429
  Pending: "pending",
1430
1430
  /** 审核通过 */
@@ -1440,7 +1440,7 @@ const Dn = {
1440
1440
  Comment: "comment",
1441
1441
  /** 点赞通知 */
1442
1442
  Like: "like"
1443
- }, xr = e.string().enum(On).lock(), m = {
1443
+ }, Sr = e.string().enum(On).lock(), m = {
1444
1444
  /** 系统通知 */
1445
1445
  System: "system",
1446
1446
  /** 帖子被置顶 */
@@ -1557,7 +1557,7 @@ const Dn = {
1557
1557
  }).lock(), Mn = e.object({
1558
1558
  system_message_subject: e.string(),
1559
1559
  system_message_content: e.string()
1560
- }).lock(), I = e.object({
1560
+ }).lock(), D = e.object({
1561
1561
  post_id: e.number(),
1562
1562
  post_subject: e.string(),
1563
1563
  post_summary: e.string(),
@@ -1565,7 +1565,7 @@ const Dn = {
1565
1565
  }).lock(), R = e.object({
1566
1566
  comment_id: e.number(),
1567
1567
  comment_content: e.string()
1568
- }).lock(), D = e.object({
1568
+ }).lock(), I = e.object({
1569
1569
  reply_id: e.number(),
1570
1570
  reply_content: e.string()
1571
1571
  }).lock(), Hn = e.object({
@@ -1574,7 +1574,7 @@ const Dn = {
1574
1574
  notification_type: e.string().enum(m.System)
1575
1575
  }), zn = e.object({
1576
1576
  ...b.shape,
1577
- ...I.shape,
1577
+ ...D.shape,
1578
1578
  notification_type: e.string().enum(
1579
1579
  m.PostPinned,
1580
1580
  m.PostHighlighted,
@@ -1583,29 +1583,29 @@ const Dn = {
1583
1583
  )
1584
1584
  }), Jn = e.object({
1585
1585
  ...b.shape,
1586
- ...I.shape,
1586
+ ...D.shape,
1587
1587
  ...R.shape,
1588
1588
  notification_type: e.string().enum(m.PostCommented)
1589
1589
  }), Kn = e.object({
1590
1590
  ...b.shape,
1591
1591
  ...R.shape,
1592
- ...D.shape,
1592
+ ...I.shape,
1593
1593
  notification_type: e.string().enum(m.CommentReplied)
1594
1594
  }), Xn = e.object({
1595
1595
  ...b.shape,
1596
1596
  ...R.shape,
1597
- ...I.shape,
1597
+ ...D.shape,
1598
1598
  notification_type: e.string().enum(m.CommentLiked, m.CommentDeleted)
1599
1599
  }), Yn = e.object({
1600
1600
  ...b.shape,
1601
- ...D.shape,
1601
+ ...I.shape,
1602
1602
  notification_type: e.string().enum(m.ReplyReplied),
1603
1603
  comment_id: e.number(),
1604
1604
  reply_to_reply_id: e.number(),
1605
1605
  reply_to_reply_content: e.string()
1606
1606
  }), Zn = e.object({
1607
1607
  ...b.shape,
1608
- ...D.shape,
1608
+ ...I.shape,
1609
1609
  ...R.shape,
1610
1610
  notification_type: e.string().enum(m.ReplyLiked, m.ReplyDeleted)
1611
1611
  }), Wn = e.union(
@@ -1639,7 +1639,7 @@ const Dn = {
1639
1639
  comment: e.number(),
1640
1640
  like: e.number()
1641
1641
  });
1642
- class Sr {
1642
+ class Lr {
1643
1643
  constructor(t) {
1644
1644
  l(this, "token");
1645
1645
  l(this, "req");
@@ -1857,12 +1857,17 @@ class Sr {
1857
1857
  return n;
1858
1858
  }
1859
1859
  }
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 || {});
1860
1866
  function S(i) {
1861
1867
  return k(i, "openid", "unionid", "weixin_token");
1862
1868
  }
1863
- 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 || {});
1864
1869
  const M = "wx_login_cache";
1865
- class Lr {
1870
+ class Pr {
1866
1871
  /**
1867
1872
  * 创建微信相关功能接口
1868
1873
  *
@@ -1983,23 +1988,37 @@ class Lr {
1983
1988
  message: !1
1984
1989
  });
1985
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
+ }
1986
2005
  }
1987
2006
  export {
1988
2007
  ae as AntispamValidator,
1989
- hr as AuthToken,
2008
+ wr as AuthToken,
1990
2009
  nn as CashbackEngagementDataValidator,
1991
2010
  p as ClaimRewardStatus,
1992
2011
  P as ClaimRewardStatusValidator,
1993
2012
  Vn as ClaimedItemValidator,
1994
2013
  J as ClubAddressValidator,
1995
- kr as ClubApi,
2014
+ vr as ClubApi,
1996
2015
  K as ClubBenefitSummaryValidator,
1997
- De as ClubBenefitValidator,
2016
+ Ie as ClubBenefitValidator,
1998
2017
  Re as ClubCreditChangeScene,
1999
2018
  je as ClubCreditChangeSceneValidator,
2000
2019
  Ce as ClubCreditChangeType,
2001
2020
  Ve as ClubCreditChangeTypeValidator,
2002
- Ie as ClubCreditLogValidator,
2021
+ De as ClubCreditLogValidator,
2003
2022
  Se as ClubGlobalConfigValidator,
2004
2023
  Te as ClubItemType,
2005
2024
  H as ClubItemTypeValidator,
@@ -2011,12 +2030,12 @@ export {
2011
2030
  Ue as ClubUserProfileValidator,
2012
2031
  fn as CommentEngagementValidator,
2013
2032
  w as CommentValidator,
2014
- Sr as CommunityApi,
2033
+ Lr as CommunityApi,
2015
2034
  Ye as EngageAccountType,
2016
2035
  Ze as EngageAccountTypeValidator,
2017
2036
  Cn as EngageResponseValidator,
2018
2037
  wn as EngageRewardValidator,
2019
- qr as EventApi,
2038
+ xr as EventApi,
2020
2039
  tn as EventConfigValidator,
2021
2040
  _t as EventFeatureConfigOfCashbackValidator,
2022
2041
  yt as EventFeatureConfigOfCheckInValidator,
@@ -2028,7 +2047,7 @@ export {
2028
2047
  St as EventFeatureConfigOfInvitedRegisterValidator,
2029
2048
  Ft as EventFeatureConfigOfLotteryDrawValidator,
2030
2049
  $t as EventFeatureConfigOfLotteryValidator,
2031
- Dt as EventFeatureConfigOfPreregisterValidator,
2050
+ It as EventFeatureConfigOfPreregisterValidator,
2032
2051
  At as EventFeatureConfigOfQuestValidator,
2033
2052
  Nt as EventFeatureConfigOfRegisterValidator,
2034
2053
  Qt as EventFeatureConfigOfShareValidator,
@@ -2045,7 +2064,7 @@ export {
2045
2064
  gt as FeatureRewardValidator,
2046
2065
  s as FeatureType,
2047
2066
  tt as FeatureTypeValidator,
2048
- Dn as ForumMode,
2067
+ In as ForumMode,
2049
2068
  Gn as ForumModeValidator,
2050
2069
  oe as ForumValidator,
2051
2070
  C as GamerItemType,
@@ -2055,19 +2074,19 @@ export {
2055
2074
  rn as GiftCodeEngagementDataValidator,
2056
2075
  on as InviteEngagementDataValidator,
2057
2076
  lt as LotteryDrawAction,
2058
- jr as LotteryDrawActionValidator,
2077
+ Tr as LotteryDrawActionValidator,
2059
2078
  un as LotteryDrawEngagementDataValidator,
2060
2079
  an as LotteryEngagementDataValidator,
2061
2080
  h as LotteryTicketStatus,
2062
- Vr as LotteryTicketStatusValidator,
2081
+ Rr as LotteryTicketStatusValidator,
2063
2082
  b as NotificationBaseValidator,
2064
2083
  On as NotificationCategory,
2065
- xr as NotificationCategoryValidator,
2084
+ Sr as NotificationCategoryValidator,
2066
2085
  Kn as NotificationCommentReplyValidator,
2067
2086
  Xn as NotificationCommentValidator,
2068
2087
  R as NotificationPayloadCommentValidator,
2069
- I as NotificationPayloadPostValidator,
2070
- D as NotificationPayloadReplyValidator,
2088
+ D as NotificationPayloadPostValidator,
2089
+ I as NotificationPayloadReplyValidator,
2071
2090
  Mn as NotificationPayloadSystemValidator,
2072
2091
  Jn as NotificationPostCommentValidator,
2073
2092
  zn as NotificationPostValidator,
@@ -2087,29 +2106,29 @@ export {
2087
2106
  mn as QuestEngagementDataValidator,
2088
2107
  nt as QuestObjective,
2089
2108
  W as QuestObjectiveValidator,
2090
- wr as RedeemParamsValidator,
2109
+ kr as RedeemParamsValidator,
2091
2110
  Oe as RedemptionValidator,
2092
2111
  dt as RegularRewardValidator,
2093
2112
  Bn as ReplyToValidator,
2094
2113
  V as ReplyValidator,
2095
- vr as RewardItemType,
2114
+ Cr as RewardItemType,
2096
2115
  Z as RewardItemTypeValidator,
2097
2116
  at as RewardSource,
2098
2117
  E as RewardSourceValidator,
2099
2118
  g as RewardStatus,
2100
2119
  ot as RewardStatusSuffix,
2101
2120
  ee as RewardStatusSuffixValidator,
2102
- Cr as RewardStatusValidator,
2121
+ Vr as RewardStatusValidator,
2103
2122
  hn as RewardValidator,
2104
2123
  Ee as RoleBaseInfoValidator,
2105
2124
  Pe as ServerBaseInfoValidator,
2106
2125
  dn as ShareEngagementDataValidator,
2107
2126
  pn as SurveyEngagementDataValidator,
2108
2127
  ut as TeamAction,
2109
- Rr as TeamActionValidator,
2128
+ jr as TeamActionValidator,
2110
2129
  bn as TeamEngagementDataValidator,
2111
2130
  _n as TeamEngagementValidator,
2112
- Tr as TeamMemberValidator,
2131
+ qr as TeamMemberValidator,
2113
2132
  st as TeamVisibility,
2114
2133
  ct as TeamVisibilityValidator,
2115
2134
  U as TopicValidator,
@@ -2121,7 +2140,8 @@ export {
2121
2140
  yn as VoteEngagementDataValidator,
2122
2141
  rt as VoteOptionSource,
2123
2142
  it as VoteOptionSourceValidator,
2124
- Lr as WeixinApi,
2143
+ Pr as WeixinApi,
2125
2144
  gn as WeixinSubscribeEngagementDataValidator,
2126
- pr as WeixinWebLoginErrorCode
2145
+ _r as WeixinWebLoginErrorCode,
2146
+ pr as isWeixinSignResponse
2127
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.6",
4
+ "version": "2.0.7",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -24,10 +24,10 @@
24
24
  "@types/node": "^22.13.1",
25
25
  "vitest": "^3.0.5",
26
26
  "@seayoo-web/combo-webview": "^2.5.1",
27
- "@seayoo-web/request": "^3.0.1",
28
27
  "@seayoo-web/tsconfig": "^1.0.3",
28
+ "@seayoo-web/scripts": "^2.0.1",
29
29
  "@seayoo-web/utils": "^3.4.3",
30
- "@seayoo-web/scripts": "^2.0.1"
30
+ "@seayoo-web/request": "^3.0.1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@seayoo-web/combo-webview": "^2.5.1",
@@ -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;
@@ -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
  *