@seayoo-web/gamer-api 1.1.0 → 1.1.2
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 +25 -19
- package/package.json +3 -3
- package/types/src/event.config.d.ts +1 -1
- package/types/src/token.d.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var Q = (e, t, r) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var u = (e, t, r) => Q(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { isComboWebView as
|
|
5
|
-
import { isPlainObject as n, useConsole as
|
|
4
|
+
import { isComboWebView as T } from "@seayoo-web/combo-webview";
|
|
5
|
+
import { isPlainObject as n, useConsole as M, Support as m, usePromise as H, pruneURL as j, queryString as h, pruneObject as s, isArray as a, isString as z, isValuedString as J, parseJSON as K, removePara as A } from "@seayoo-web/utils";
|
|
6
6
|
import "@seayoo-web/request";
|
|
7
7
|
function N(e) {
|
|
8
8
|
return n(e, "gamer_token") && typeof e.gamer_token == "string";
|
|
@@ -10,9 +10,9 @@ function N(e) {
|
|
|
10
10
|
function L(e) {
|
|
11
11
|
return n(e);
|
|
12
12
|
}
|
|
13
|
-
const l =
|
|
13
|
+
const l = M("GamerApiSDK");
|
|
14
14
|
async function O() {
|
|
15
|
-
const { promise: e, resolve: t } =
|
|
15
|
+
const { promise: e, resolve: t } = H();
|
|
16
16
|
return wx.login({
|
|
17
17
|
success(r) {
|
|
18
18
|
t(r);
|
|
@@ -78,7 +78,7 @@ class Xt {
|
|
|
78
78
|
requestTransformer: (i) => {
|
|
79
79
|
this.$gamerToken && (i.headers.Authorization = `Bearer ${this.$gamerToken}`);
|
|
80
80
|
}
|
|
81
|
-
}),
|
|
81
|
+
}), T() ? this.$gamerToken = h("gamer_token") : this.loadGamerTokenCache();
|
|
82
82
|
}
|
|
83
83
|
loadGamerTokenCache() {
|
|
84
84
|
const r = this.storage.get(_).match(/^(\d{12,})#(.{8,})$/);
|
|
@@ -101,7 +101,7 @@ class Xt {
|
|
|
101
101
|
}
|
|
102
102
|
/** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
|
|
103
103
|
set idToken(t) {
|
|
104
|
-
|
|
104
|
+
this.$idToken !== t && (this.$idToken = t, this.gamerToken = "");
|
|
105
105
|
}
|
|
106
106
|
/** 读取设置 wexinToken */
|
|
107
107
|
get weixinToken() {
|
|
@@ -125,6 +125,12 @@ class Xt {
|
|
|
125
125
|
set gamerToken(t) {
|
|
126
126
|
this.$gamerToken = t, t ? this.storage.set(_, `${Date.now()}#${t}`) : this.storage.remove(_);
|
|
127
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* 退出登录,销毁相关 Token
|
|
130
|
+
*/
|
|
131
|
+
logout() {
|
|
132
|
+
this.$idToken = "", this.$weixinToken = "", this.gamerToken = "";
|
|
133
|
+
}
|
|
128
134
|
/**
|
|
129
135
|
* 用世游通行证统一登录能力签发的 ID Token / Weixin Token,自动置换 Gamer Token,成功后会自动设置后续 Request Headers
|
|
130
136
|
*
|
|
@@ -168,7 +174,7 @@ class Xt {
|
|
|
168
174
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OdGVCdQxEu
|
|
169
175
|
*/
|
|
170
176
|
async getSession() {
|
|
171
|
-
if (await this.autoLogin()) return null;
|
|
177
|
+
if (!await this.autoLogin()) return null;
|
|
172
178
|
const { data: t } = await this.req.get("session", L, {
|
|
173
179
|
message: !1
|
|
174
180
|
});
|
|
@@ -180,7 +186,7 @@ class Xt {
|
|
|
180
186
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=kZYnwX6RcF
|
|
181
187
|
*/
|
|
182
188
|
async authRealName(t) {
|
|
183
|
-
if (await this.autoLogin()) return null;
|
|
189
|
+
if (!await this.autoLogin()) return null;
|
|
184
190
|
const { data: r } = await this.req.post("auth-real-name", s(t), L);
|
|
185
191
|
return r;
|
|
186
192
|
}
|
|
@@ -611,7 +617,7 @@ class Yt {
|
|
|
611
617
|
}
|
|
612
618
|
var ve = /* @__PURE__ */ ((e) => (e.EventItem = "event_item", e.GameItem = "game_item", e.PhysicalItem = "physical_item", e.WeixinHongbao = "weixin_hongbao", e.GiftCode = "gift_code", e.LotteryTicket = "lottery_ticket", e.VoidItem = "void_item", e))(ve || {}), ke = /* @__PURE__ */ ((e) => (e.UserId = "user_id", e.RoleId = "role_id", e))(ke || {}), be = /* @__PURE__ */ ((e) => (e.None = "none", e.Daily = "daily", e.Weekly = "weekly", e.Monthly = "monthly", e))(be || {}), o = /* @__PURE__ */ ((e) => (e.Preregister = "preregister", e.Lottery = "lottery", e.Survey = "survey", e.Invite = "invite", e.Share = "share", e.Follow = "follow", e.Subscribe = "weixin_subscribe", e.Comment = "comment", e.Vote = "vote", e.GiftCode = "gift_code", e.Register = "register", e.InvitedRegister = "invited_register", e.ClaimRewards = "claim_rewards", e.Cashback = "cashback", e.Quest = "quest", e.Team = "team", e.LotteryDraw = "lottery_draw", e))(o || {}), qe = /* @__PURE__ */ ((e) => (e.Active = "player_active_points", e.Login = "player_login_days", e.OrderAmount = "order_total_amount", e.Posts = "community_posts", e.Comments = "community_comments", e))(qe || {}), Re = /* @__PURE__ */ ((e) => (e.System = "system", e.UserSubmission = "user_submission", e.Shortlisted = "shortlisted", e))(Re || {}), xe = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e))(xe || {}), Ae = /* @__PURE__ */ ((e) => (e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e.Delivered = "delivered", e))(Ae || {}), Le = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e))(Le || {}), Ce = /* @__PURE__ */ ((e) => (e.Output = "output", e.Engage = "engage", e))(Ce || {}), Ue = /* @__PURE__ */ ((e) => (e.Private = "private", e.Public = "public", e))(Ue || {}), Pe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Pending = "pending", e.Drawn = "drawn", e.Claimed = "claimed", e.Fail = "fail", e))(Pe || {}), $e = /* @__PURE__ */ ((e) => (e.Assemble = "assemble", e.Join = "join", e.Disband = "disband", e.ChangeVisibility = "change_visibility", e.Query = "query", e))($e || {}), Se = /* @__PURE__ */ ((e) => (e.Query = "query", e.Draw = "draw", e.Claim = "claim", e))(Se || {});
|
|
613
619
|
function De(e) {
|
|
614
|
-
return n(e, "event_name", "rules", "since", "until", "
|
|
620
|
+
return n(e, "event_name", "rules", "since", "until", "features") && Array.isArray(e.features) && e.features.every(Ee);
|
|
615
621
|
}
|
|
616
622
|
function Ee(e) {
|
|
617
623
|
if (!Fe(e))
|
|
@@ -629,11 +635,11 @@ function Ee(e) {
|
|
|
629
635
|
case o.Invite:
|
|
630
636
|
return Qe(e.config);
|
|
631
637
|
case o.Share:
|
|
632
|
-
return
|
|
638
|
+
return Te(e.config);
|
|
633
639
|
case o.Follow:
|
|
634
|
-
return
|
|
640
|
+
return Me(e.config);
|
|
635
641
|
case o.Subscribe:
|
|
636
|
-
return
|
|
642
|
+
return He(e.config);
|
|
637
643
|
case o.Comment:
|
|
638
644
|
return je(e.config);
|
|
639
645
|
case o.Vote:
|
|
@@ -707,13 +713,13 @@ function Ve(e) {
|
|
|
707
713
|
function Qe(e) {
|
|
708
714
|
return n(e, "share_url");
|
|
709
715
|
}
|
|
710
|
-
function
|
|
716
|
+
function Te(e) {
|
|
711
717
|
return n(e, "share_platform");
|
|
712
718
|
}
|
|
713
|
-
function
|
|
719
|
+
function Me(e) {
|
|
714
720
|
return n(e, "platform");
|
|
715
721
|
}
|
|
716
|
-
function
|
|
722
|
+
function He(e) {
|
|
717
723
|
return n(e, "weixin_template_ids") && Array.isArray(e.weixin_template_ids) && e.weixin_template_ids.every((t) => typeof t == "string");
|
|
718
724
|
}
|
|
719
725
|
function je(e) {
|
|
@@ -1239,7 +1245,7 @@ function Vt(e) {
|
|
|
1239
1245
|
function Qt(e) {
|
|
1240
1246
|
return n(e, "system", "comment", "like");
|
|
1241
1247
|
}
|
|
1242
|
-
var
|
|
1248
|
+
var Tt = /* @__PURE__ */ ((e) => (e.All = "all", e.Limit = "limit", e))(Tt || {}), Mt = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Approved = "approved", e.Failed = "failed", e.Suspect = "suspect", e))(Mt || {}), Ht = /* @__PURE__ */ ((e) => (e.System = "system", e.Comment = "comment", e.Like = "like", e))(Ht || {}), jt = /* @__PURE__ */ ((e) => (e.System = "system", e.PostPinned = "post_pinned", e.PostHighlighted = "post_highlighted", e.PostDeleted = "post_deleted", e.PostCommented = "post_commented", e.PostLiked = "post_liked", e.CommentReplied = "comment_replied", e.CommentLiked = "comment_liked", e.CommentDeleted = "comment_deleted", e.ReplyReplied = "reply_replied", e.ReplyLiked = "reply_liked", e.ReplyDeleted = "reply_deleted", e))(jt || {});
|
|
1243
1249
|
class Wt {
|
|
1244
1250
|
constructor(t) {
|
|
1245
1251
|
u(this, "token");
|
|
@@ -1602,14 +1608,14 @@ export {
|
|
|
1602
1608
|
Zt as EventApi,
|
|
1603
1609
|
be as EventPeriodType,
|
|
1604
1610
|
o as FeatureType,
|
|
1605
|
-
|
|
1611
|
+
Tt as ForumMode,
|
|
1606
1612
|
ve as GamerItemType,
|
|
1607
1613
|
pe as Gender,
|
|
1608
1614
|
Se as LotteryDrawAction,
|
|
1609
1615
|
Pe as LotteryTicketStatus,
|
|
1610
|
-
|
|
1616
|
+
Ht as NotificationCategory,
|
|
1611
1617
|
jt as NotificationType,
|
|
1612
|
-
|
|
1618
|
+
Mt as PostStatus,
|
|
1613
1619
|
qe as QuestObjective,
|
|
1614
1620
|
Ce as RewardSoure,
|
|
1615
1621
|
xe as RewardStatusPrefix,
|
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": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "index.ts",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.13.1",
|
|
25
25
|
"@seayoo-web/combo-webview": "^2.5.0",
|
|
26
|
-
"@seayoo-web/request": "^2.1.2",
|
|
27
26
|
"@seayoo-web/tsconfig": "^1.0.3",
|
|
28
27
|
"@seayoo-web/scripts": "^1.3.9",
|
|
29
|
-
"@seayoo-web/utils": "^3.0.10"
|
|
28
|
+
"@seayoo-web/utils": "^3.0.10",
|
|
29
|
+
"@seayoo-web/request": "^2.1.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@seayoo-web/combo-webview": "^2.5.0",
|
package/types/src/token.d.ts
CHANGED