@seayoo-web/gamer-api 2.0.15 → 2.0.16
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 +119 -112
- package/package.json +4 -4
- package/types/src/token.d.ts +74 -73
- package/types/src/weixin.d.ts +89 -96
package/dist/index.js
CHANGED
|
@@ -2,18 +2,18 @@ var le = Object.defineProperty;
|
|
|
2
2
|
var me = (i, t, n) => t in i ? le(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
|
|
3
3
|
var l = (i, t, n) => me(i, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { isComboWebView as de } from "@seayoo-web/combo-webview";
|
|
5
|
-
import { isPlainObject as v, useConsole as ge, Support as b, usePromise as pe, pruneURL as _e, queryString as L, pruneObject as a, v as e, omitFields as C, typedObjectGuard as o, parseJSON as be, removePara as
|
|
5
|
+
import { isPlainObject as v, useConsole as ge, Support as b, usePromise as pe, pruneURL as _e, queryString as L, pruneObject as a, v as e, omitFields as C, typedObjectGuard as o, parseJSON as be, removePara as N } from "@seayoo-web/utils";
|
|
6
6
|
function ye(i) {
|
|
7
7
|
return v(i, "gamer_token") && typeof i.gamer_token == "string";
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function A(i) {
|
|
10
10
|
return v(i);
|
|
11
11
|
}
|
|
12
12
|
const f = ge("GamerApiSDK");
|
|
13
13
|
function fe(i) {
|
|
14
14
|
return /^\/[a-z\d-]+$/.test(i);
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
16
|
+
async function he() {
|
|
17
17
|
const { promise: i, resolve: t } = pe();
|
|
18
18
|
return wx.login({
|
|
19
19
|
success(n) {
|
|
@@ -24,7 +24,7 @@ async function we() {
|
|
|
24
24
|
}
|
|
25
25
|
}), await i;
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const we = {
|
|
28
28
|
get(i) {
|
|
29
29
|
return localStorage.getItem(i) || "";
|
|
30
30
|
},
|
|
@@ -57,17 +57,18 @@ const he = {
|
|
|
57
57
|
f.error("removeStorageSync", t);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
},
|
|
61
|
-
class
|
|
60
|
+
}, h = "gamer_token";
|
|
61
|
+
class hr {
|
|
62
62
|
constructor(t, n) {
|
|
63
|
+
l(this, "$NetRequest");
|
|
63
64
|
l(this, "$idToken", "");
|
|
64
65
|
l(this, "$weixinToken", "");
|
|
65
66
|
l(this, "$gamerToken", "");
|
|
66
67
|
l(this, "req");
|
|
67
68
|
l(this, "storage");
|
|
68
|
-
this.storage = b.wx ? ke :
|
|
69
|
+
this.storage = b.wx ? ke : we;
|
|
69
70
|
const r = fe(t) ? t : `https://${_e(t)}`;
|
|
70
|
-
this.req = n({
|
|
71
|
+
this.$NetRequest = n, this.req = n({
|
|
71
72
|
baseURL: `${r}/v1`,
|
|
72
73
|
timeout: 1e4,
|
|
73
74
|
responseRule: {
|
|
@@ -84,8 +85,11 @@ class wr {
|
|
|
84
85
|
}
|
|
85
86
|
}), de() ? this.$gamerToken = L("gamer_token") : this.loadGamerTokenCache();
|
|
86
87
|
}
|
|
88
|
+
get NetRequest() {
|
|
89
|
+
return this.$NetRequest;
|
|
90
|
+
}
|
|
87
91
|
loadGamerTokenCache() {
|
|
88
|
-
const n = this.storage.get(
|
|
92
|
+
const n = this.storage.get(h).match(/^(\d{12,})#(.{8,})$/);
|
|
89
93
|
if (n) {
|
|
90
94
|
const r = parseInt(n[1]), s = n[2];
|
|
91
95
|
if (r > Date.now() - (24 * 3600 - 10) * 1e3) {
|
|
@@ -93,7 +97,7 @@ class wr {
|
|
|
93
97
|
return;
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
|
-
this.storage.remove(
|
|
100
|
+
this.storage.remove(h);
|
|
97
101
|
}
|
|
98
102
|
/** 当前是否为登录状态,即是否拥有 gamerToken */
|
|
99
103
|
get isLoggedIn() {
|
|
@@ -127,7 +131,7 @@ class wr {
|
|
|
127
131
|
* 直接写入 Gamer Token,并更新缓存
|
|
128
132
|
*/
|
|
129
133
|
set gamerToken(t) {
|
|
130
|
-
this.$gamerToken = t, t ? this.storage.set(
|
|
134
|
+
this.$gamerToken = t, t ? this.storage.set(h, `${Date.now()}#${t}`) : this.storage.remove(h);
|
|
131
135
|
}
|
|
132
136
|
/**
|
|
133
137
|
* 退出登录,销毁相关 Token
|
|
@@ -183,7 +187,7 @@ class wr {
|
|
|
183
187
|
*/
|
|
184
188
|
async getSession() {
|
|
185
189
|
if (!await this.autoLogin()) return null;
|
|
186
|
-
const { data: t } = await this.req.get("session",
|
|
190
|
+
const { data: t } = await this.req.get("session", A, {
|
|
187
191
|
message: !1
|
|
188
192
|
});
|
|
189
193
|
return t;
|
|
@@ -195,7 +199,7 @@ class wr {
|
|
|
195
199
|
*/
|
|
196
200
|
async authRealName(t) {
|
|
197
201
|
if (!await this.autoLogin()) return null;
|
|
198
|
-
const { data: n } = await this.req.post("auth-real-name", a(t),
|
|
202
|
+
const { data: n } = await this.req.post("auth-real-name", a(t), A);
|
|
199
203
|
return n;
|
|
200
204
|
}
|
|
201
205
|
}
|
|
@@ -206,14 +210,14 @@ const ve = {
|
|
|
206
210
|
Male: "male",
|
|
207
211
|
/** 女 */
|
|
208
212
|
Female: "female"
|
|
209
|
-
}, Ce = e.string().enum(ve).lock(),
|
|
213
|
+
}, Ce = e.string().enum(ve).lock(), Re = {
|
|
210
214
|
/** 积分增加 */
|
|
211
215
|
Increase: "increase",
|
|
212
216
|
/** 积分减少 */
|
|
213
217
|
Decrease: "decrease",
|
|
214
218
|
/** 积分过期 */
|
|
215
219
|
Expired: "expired"
|
|
216
|
-
},
|
|
220
|
+
}, Ve = e.string().enum(Re).lock(), je = {
|
|
217
221
|
/** 游戏内购买 */
|
|
218
222
|
Order: "order",
|
|
219
223
|
/** 游戏内消耗 */
|
|
@@ -270,15 +274,15 @@ const ve = {
|
|
|
270
274
|
}).lock(), Ee = e.object({
|
|
271
275
|
server_id: e.string(),
|
|
272
276
|
server_name: e.string()
|
|
273
|
-
}).lock(),
|
|
277
|
+
}).lock(), $e = e.object({
|
|
274
278
|
role_id: e.string(),
|
|
275
279
|
role_name: e.string()
|
|
276
280
|
}).lock(), J = e.object({
|
|
277
|
-
|
|
281
|
+
...$e.shape,
|
|
278
282
|
...Ee.shape,
|
|
279
283
|
role_level: e.number(),
|
|
280
284
|
last_login_time: e.number()
|
|
281
|
-
}).lock(),
|
|
285
|
+
}).lock(), Ue = e.object({
|
|
282
286
|
...J.shape,
|
|
283
287
|
/** 角色战力 */
|
|
284
288
|
role_fighting: e.number(),
|
|
@@ -310,7 +314,7 @@ const ve = {
|
|
|
310
314
|
balance_credit: e.number()
|
|
311
315
|
}).lock(), Ie = e.object({
|
|
312
316
|
id: e.number(),
|
|
313
|
-
change_type:
|
|
317
|
+
change_type: Ve,
|
|
314
318
|
change_scene: Te,
|
|
315
319
|
change_credit: e.number(),
|
|
316
320
|
balance: e.number(),
|
|
@@ -353,7 +357,7 @@ const ve = {
|
|
|
353
357
|
}).lock(), Ge = e.object({
|
|
354
358
|
...C(X.shape, "tag"),
|
|
355
359
|
product: Y.clone().optional()
|
|
356
|
-
}).lock(),
|
|
360
|
+
}).lock(), wr = e.union(
|
|
357
361
|
e.object({
|
|
358
362
|
server_id: e.string(),
|
|
359
363
|
role_id: e.string()
|
|
@@ -361,7 +365,7 @@ const ve = {
|
|
|
361
365
|
e.object({
|
|
362
366
|
address_id: e.number()
|
|
363
367
|
})
|
|
364
|
-
).satisfies().lock(),
|
|
368
|
+
).satisfies().lock(), Ne = e.object({
|
|
365
369
|
recipient: e.string(),
|
|
366
370
|
mobile: e.string(),
|
|
367
371
|
province: e.string(),
|
|
@@ -370,11 +374,11 @@ const ve = {
|
|
|
370
374
|
address: e.string(),
|
|
371
375
|
express_company: e.string(),
|
|
372
376
|
express_number: e.string()
|
|
373
|
-
}).lock(),
|
|
377
|
+
}).lock(), Ae = e.object({
|
|
374
378
|
server_id: e.string(),
|
|
375
379
|
role_id: e.string(),
|
|
376
380
|
role_name: e.string()
|
|
377
|
-
}).lock(),
|
|
381
|
+
}).lock(), Oe = e.object({
|
|
378
382
|
redemption_id: e.number(),
|
|
379
383
|
player_id: e.string(),
|
|
380
384
|
product_id: e.number(),
|
|
@@ -387,12 +391,12 @@ const ve = {
|
|
|
387
391
|
amount: e.number(),
|
|
388
392
|
status: Se,
|
|
389
393
|
created_at: e.number(),
|
|
390
|
-
extra_data: e.union(
|
|
391
|
-
}), Be = e.guard(Le),
|
|
394
|
+
extra_data: e.union(Ne.clone(), Ae.clone()).satisfies().optional()
|
|
395
|
+
}), Be = e.guard(Le), O = o({ player: Pe }), Qe = o({ roles: e.array(J) }), T = o({ role_card: Ue }), B = e.guard(Fe), Q = e.guard(K), Me = o({ addresses: e.array(K) }), He = e.guard(De), ze = o({
|
|
392
396
|
credit_logs: e.array(Ie),
|
|
393
397
|
next_token: e.string().optional()
|
|
394
398
|
}), Je = o({ products: e.array(Y) }), Ke = o({ benefits: e.array(X) }), Xe = o({ benefit: Ge }), Ye = o({
|
|
395
|
-
redemptions: e.array(
|
|
399
|
+
redemptions: e.array(Oe),
|
|
396
400
|
next_token: e.string().optional()
|
|
397
401
|
});
|
|
398
402
|
class kr {
|
|
@@ -417,7 +421,7 @@ class kr {
|
|
|
417
421
|
*/
|
|
418
422
|
async getCurrentPlayer() {
|
|
419
423
|
await this.token.autoLogin();
|
|
420
|
-
const { data: t, code: n } = await this.req.get("club/current-player",
|
|
424
|
+
const { data: t, code: n } = await this.req.get("club/current-player", O);
|
|
421
425
|
return (t == null ? void 0 : t.player) ?? { error: n };
|
|
422
426
|
}
|
|
423
427
|
/**
|
|
@@ -432,7 +436,7 @@ class kr {
|
|
|
432
436
|
{
|
|
433
437
|
id_token: this.token.idToken
|
|
434
438
|
},
|
|
435
|
-
|
|
439
|
+
O
|
|
436
440
|
);
|
|
437
441
|
return (t == null ? void 0 : t.player) ?? {
|
|
438
442
|
error: n
|
|
@@ -624,7 +628,7 @@ class kr {
|
|
|
624
628
|
return { redemptions: (n == null ? void 0 : n.redemptions) || [], next_token: n == null ? void 0 : n.next_token };
|
|
625
629
|
}
|
|
626
630
|
}
|
|
627
|
-
const
|
|
631
|
+
const R = {
|
|
628
632
|
/** 活动道具 */
|
|
629
633
|
EventItem: "event_item",
|
|
630
634
|
/** 游戏内道具 */
|
|
@@ -643,7 +647,7 @@ const V = {
|
|
|
643
647
|
ExternalCode: "external_gift_code",
|
|
644
648
|
/** 空奖励 */
|
|
645
649
|
VoidItem: "void_item"
|
|
646
|
-
}, Z = e.string().enum(
|
|
650
|
+
}, Z = e.string().enum(R).lock(), vr = R, W = Z, Ze = {
|
|
647
651
|
/** 世游通行证 ID / Combo ID */
|
|
648
652
|
UserId: "user_id",
|
|
649
653
|
/** 游戏角色 ID */
|
|
@@ -756,12 +760,12 @@ const V = {
|
|
|
756
760
|
Output: "output",
|
|
757
761
|
/** 玩法参与奖励 */
|
|
758
762
|
Engage: "engage"
|
|
759
|
-
},
|
|
763
|
+
}, $ = e.string().enum(at).lock(), st = {
|
|
760
764
|
/** 私有队伍 */
|
|
761
765
|
Private: "private",
|
|
762
766
|
/** 公开队伍 */
|
|
763
767
|
Public: "public"
|
|
764
|
-
}, ct = e.string().enum(st).lock(),
|
|
768
|
+
}, ct = e.string().enum(st).lock(), w = {
|
|
765
769
|
/** 未知状态 */
|
|
766
770
|
Unknown: "unknown",
|
|
767
771
|
/** 等待开奖 */
|
|
@@ -772,7 +776,7 @@ const V = {
|
|
|
772
776
|
Claimed: "claimed",
|
|
773
777
|
/** 领奖失败 */
|
|
774
778
|
Fail: "fail"
|
|
775
|
-
},
|
|
779
|
+
}, Rr = e.string().enum(w).lock(), ut = {
|
|
776
780
|
/** 发起组队 */
|
|
777
781
|
Assemble: "assemble",
|
|
778
782
|
/** 加入队伍 */
|
|
@@ -783,14 +787,14 @@ const V = {
|
|
|
783
787
|
ChangeVisibility: "change_visibility",
|
|
784
788
|
/** 查询组队信息 */
|
|
785
789
|
Query: "query"
|
|
786
|
-
},
|
|
790
|
+
}, Vr = e.string().enum(ut).lock(), lt = {
|
|
787
791
|
/** 查询抽奖券 */
|
|
788
792
|
Query: "query",
|
|
789
793
|
/** 开奖 */
|
|
790
794
|
Draw: "draw",
|
|
791
795
|
/** 领奖 */
|
|
792
796
|
Claim: "claim"
|
|
793
|
-
}, jr = e.string().enum(lt).lock(), mt = e.string().enum(C(
|
|
797
|
+
}, jr = e.string().enum(lt).lock(), mt = e.string().enum(C(R, "GiftCode", "LotteryTicket")), U = e.object({
|
|
794
798
|
reward_item_id: e.number(),
|
|
795
799
|
reward_amount: e.number(),
|
|
796
800
|
reward_item_name: e.string(),
|
|
@@ -800,11 +804,11 @@ const V = {
|
|
|
800
804
|
reward_item_rating: e.number()
|
|
801
805
|
}).lock(), dt = e.object({
|
|
802
806
|
engage_count: e.number(),
|
|
803
|
-
rewards: e.array(
|
|
807
|
+
rewards: e.array(U)
|
|
804
808
|
}).lock(), gt = e.union(
|
|
805
809
|
e.object({
|
|
806
810
|
feature_reward_type: e.string().enum("every"),
|
|
807
|
-
reward_details: e.array(
|
|
811
|
+
reward_details: e.array(U)
|
|
808
812
|
}),
|
|
809
813
|
e.object({
|
|
810
814
|
feature_reward_type: e.string().enum("regular"),
|
|
@@ -832,12 +836,12 @@ const V = {
|
|
|
832
836
|
}), bt = c.CheckIn, yt = e.object({
|
|
833
837
|
...u.shape,
|
|
834
838
|
feature_type: e.string().enum(bt)
|
|
835
|
-
}), ft = c.ClaimRewards,
|
|
839
|
+
}), ft = c.ClaimRewards, ht = e.object({
|
|
836
840
|
...u.shape,
|
|
837
841
|
feature_type: e.string().enum(ft)
|
|
838
|
-
}),
|
|
842
|
+
}), wt = c.Comment, kt = e.object({
|
|
839
843
|
...u.shape,
|
|
840
|
-
feature_type: e.string().enum(
|
|
844
|
+
feature_type: e.string().enum(wt),
|
|
841
845
|
config: e.object({
|
|
842
846
|
comments: e.array(e.string()),
|
|
843
847
|
send_rate: e.number()
|
|
@@ -852,15 +856,15 @@ const V = {
|
|
|
852
856
|
qr_code_url: e.string().optional(),
|
|
853
857
|
platform_desc: e.string().optional()
|
|
854
858
|
})
|
|
855
|
-
}),
|
|
859
|
+
}), Rt = c.GiftCode, Vt = e.object({
|
|
856
860
|
name: e.string(),
|
|
857
861
|
icon_url: e.string(),
|
|
858
862
|
count: e.number()
|
|
859
863
|
}), jt = e.object({
|
|
860
864
|
...u.shape,
|
|
861
|
-
feature_type: e.string().enum(
|
|
865
|
+
feature_type: e.string().enum(Rt),
|
|
862
866
|
config: e.object({
|
|
863
|
-
gift_items: e.array(
|
|
867
|
+
gift_items: e.array(Vt),
|
|
864
868
|
mp_url: e.string().optional(),
|
|
865
869
|
mp_qrcode_url: e.string().optional()
|
|
866
870
|
})
|
|
@@ -873,7 +877,7 @@ const V = {
|
|
|
873
877
|
}), xt = c.InvitedRegister, St = e.object({
|
|
874
878
|
...u.shape,
|
|
875
879
|
feature_type: e.string().enum(xt)
|
|
876
|
-
}), Lt = e.string().enum(C(
|
|
880
|
+
}), Lt = e.string().enum(C(R, "GiftCode", "LotteryTicket")), Pt = c.Lottery, Et = e.object({
|
|
877
881
|
reward_item_id: e.number(),
|
|
878
882
|
reward_item_name: e.string(),
|
|
879
883
|
reward_item_type: Lt,
|
|
@@ -881,7 +885,7 @@ const V = {
|
|
|
881
885
|
reward_item_desc: e.string().optional(),
|
|
882
886
|
reward_amount: e.number(),
|
|
883
887
|
reward_remaining_stock: e.number()
|
|
884
|
-
}),
|
|
888
|
+
}), $t = e.object({
|
|
885
889
|
...u.shape,
|
|
886
890
|
feature_type: e.string().enum(Pt),
|
|
887
891
|
config: e.object({
|
|
@@ -892,9 +896,9 @@ const V = {
|
|
|
892
896
|
consume_item_desc: e.string().optional(),
|
|
893
897
|
rewards: e.array(Et)
|
|
894
898
|
})
|
|
895
|
-
}),
|
|
899
|
+
}), Ut = c.LotteryDraw, Ft = e.object({
|
|
896
900
|
...u.shape,
|
|
897
|
-
feature_type: e.string().enum(
|
|
901
|
+
feature_type: e.string().enum(Ut),
|
|
898
902
|
config: e.object({
|
|
899
903
|
draw_not_before: e.number(),
|
|
900
904
|
draw_not_after: e.number()
|
|
@@ -902,7 +906,7 @@ const V = {
|
|
|
902
906
|
}), Dt = c.Preregister, It = e.object({
|
|
903
907
|
...u.shape,
|
|
904
908
|
feature_type: e.string().enum(Dt)
|
|
905
|
-
}), Gt = c.Quest,
|
|
909
|
+
}), Gt = c.Quest, Nt = e.object({
|
|
906
910
|
...u.shape,
|
|
907
911
|
feature_type: e.string().enum(Gt),
|
|
908
912
|
config: e.object({
|
|
@@ -913,9 +917,9 @@ const V = {
|
|
|
913
917
|
completion_value: e.number()
|
|
914
918
|
}).optional()
|
|
915
919
|
})
|
|
916
|
-
}),
|
|
920
|
+
}), At = c.Register, Ot = e.object({
|
|
917
921
|
...u.shape,
|
|
918
|
-
feature_type: e.string().enum(
|
|
922
|
+
feature_type: e.string().enum(At)
|
|
919
923
|
}), Bt = c.Share, Qt = e.object({
|
|
920
924
|
...u.shape,
|
|
921
925
|
feature_type: e.string().enum(Bt),
|
|
@@ -963,22 +967,22 @@ const V = {
|
|
|
963
967
|
finalists_amount: e.number(),
|
|
964
968
|
source: ot,
|
|
965
969
|
options: e.array(Zt),
|
|
966
|
-
rewards: e.array(
|
|
970
|
+
rewards: e.array(U)
|
|
967
971
|
})
|
|
968
972
|
}), en = e.union(
|
|
969
973
|
_t,
|
|
970
974
|
yt,
|
|
971
|
-
|
|
975
|
+
ht,
|
|
972
976
|
kt,
|
|
973
977
|
Ct,
|
|
974
978
|
jt,
|
|
975
979
|
qt,
|
|
976
980
|
St,
|
|
977
|
-
|
|
981
|
+
$t,
|
|
978
982
|
Ft,
|
|
979
983
|
It,
|
|
980
|
-
At,
|
|
981
984
|
Nt,
|
|
985
|
+
Ot,
|
|
982
986
|
Qt,
|
|
983
987
|
Ht,
|
|
984
988
|
Jt,
|
|
@@ -1006,7 +1010,7 @@ const V = {
|
|
|
1006
1010
|
}), ne = e.object({
|
|
1007
1011
|
reward_id: e.number(),
|
|
1008
1012
|
reward_item_id: e.number(),
|
|
1009
|
-
reward_source:
|
|
1013
|
+
reward_source: $,
|
|
1010
1014
|
reward_item_name: e.string(),
|
|
1011
1015
|
reward_item_type: Z,
|
|
1012
1016
|
reward_item_icon_url: e.string(),
|
|
@@ -1023,14 +1027,14 @@ const V = {
|
|
|
1023
1027
|
// https://kdocs.cn/l/ckWFDcOsYEUA?linkname=merUzJsVYH
|
|
1024
1028
|
// 后续会格式化为具体的类型,此处的校验需要对应增加
|
|
1025
1029
|
extra_data: e.record(e.unknown()).optional()
|
|
1026
|
-
}), sn = e.string().enum(
|
|
1030
|
+
}), sn = e.string().enum(w.Unknown, w.Pending), cn = e.union(
|
|
1027
1031
|
e.object({
|
|
1028
1032
|
ticket: e.string(),
|
|
1029
1033
|
status: sn
|
|
1030
1034
|
}),
|
|
1031
1035
|
e.object({
|
|
1032
1036
|
ticket: e.string(),
|
|
1033
|
-
status: e.string().enum(C(
|
|
1037
|
+
status: e.string().enum(C(w, "Unknown", "Pending")),
|
|
1034
1038
|
reward: ne
|
|
1035
1039
|
})
|
|
1036
1040
|
).satisfies(), un = e.object({
|
|
@@ -1104,20 +1108,20 @@ const V = {
|
|
|
1104
1108
|
"EmptyObject",
|
|
1105
1109
|
(i) => v(i) && Object.keys(i).length === 0
|
|
1106
1110
|
)
|
|
1107
|
-
).satisfies().lock(),
|
|
1111
|
+
).satisfies().lock(), hn = e.object({
|
|
1108
1112
|
reward_id: e.number(),
|
|
1109
1113
|
reward_item_id: e.number(),
|
|
1110
1114
|
reward_item_type: W,
|
|
1111
1115
|
reward_count: e.number(),
|
|
1112
1116
|
reward_status: te,
|
|
1113
|
-
reward_source:
|
|
1117
|
+
reward_source: $,
|
|
1114
1118
|
reward_item_name: e.string(),
|
|
1115
1119
|
reward_item_icon_url: e.string(),
|
|
1116
1120
|
reward_item_desc: e.string().optional(),
|
|
1117
1121
|
reward_item_rating: e.number(),
|
|
1118
1122
|
receive_time: e.number(),
|
|
1119
1123
|
extra_data: e.union(...re.validators, e.record(e.unknown())).satisfies().optional()
|
|
1120
|
-
}),
|
|
1124
|
+
}), wn = e.object({
|
|
1121
1125
|
reward_id: e.number(),
|
|
1122
1126
|
reward_item_id: e.number(),
|
|
1123
1127
|
reward_item_name: e.string(),
|
|
@@ -1126,7 +1130,7 @@ const V = {
|
|
|
1126
1130
|
reward_item_desc: e.string().optional(),
|
|
1127
1131
|
reward_amount: e.number(),
|
|
1128
1132
|
reward_status: te,
|
|
1129
|
-
reward_source:
|
|
1133
|
+
reward_source: $,
|
|
1130
1134
|
extra_data: e.record(e.unknown()).optional()
|
|
1131
1135
|
}), ie = e.object({
|
|
1132
1136
|
engagement_id: e.number(),
|
|
@@ -1138,7 +1142,7 @@ const V = {
|
|
|
1138
1142
|
server_id: e.string().optional(),
|
|
1139
1143
|
role_id: e.string().optional(),
|
|
1140
1144
|
created_at: e.number(),
|
|
1141
|
-
rewards: e.array(
|
|
1145
|
+
rewards: e.array(hn).optional()
|
|
1142
1146
|
}).lock(), kn = e.object({
|
|
1143
1147
|
allowed: e.bool(),
|
|
1144
1148
|
registered: e.bool()
|
|
@@ -1156,12 +1160,12 @@ const V = {
|
|
|
1156
1160
|
role_id: e.string(),
|
|
1157
1161
|
data: ie.clone().optional()
|
|
1158
1162
|
}).optional(),
|
|
1159
|
-
rewards: e.array(
|
|
1163
|
+
rewards: e.array(wn).optional(),
|
|
1160
1164
|
scan: e.bool().optional()
|
|
1161
|
-
}),
|
|
1165
|
+
}), Rn = e.object({
|
|
1162
1166
|
reward_id: e.number(),
|
|
1163
1167
|
reward_status: E
|
|
1164
|
-
}),
|
|
1168
|
+
}), Vn = e.guard(tn), jn = e.guard(kn), x = o({ count: e.number() }), Tn = o({ first_visit: e.bool() }), qn = o({
|
|
1165
1169
|
engagements: e.union(e.array(fn), e.array(_n))
|
|
1166
1170
|
}), xn = o({
|
|
1167
1171
|
status: e.array(vn)
|
|
@@ -1169,13 +1173,13 @@ const V = {
|
|
|
1169
1173
|
engagements: e.array(ie),
|
|
1170
1174
|
next_token: e.string().optional()
|
|
1171
1175
|
}), Ln = e.guard(Cn), Pn = o({
|
|
1172
|
-
claimed_items: e.array(
|
|
1176
|
+
claimed_items: e.array(Rn)
|
|
1173
1177
|
}), En = o({
|
|
1174
1178
|
reward_status: E
|
|
1175
|
-
}),
|
|
1179
|
+
}), $n = o({
|
|
1176
1180
|
user_rewards: e.array(ne),
|
|
1177
1181
|
next_token: e.string().optional()
|
|
1178
|
-
}),
|
|
1182
|
+
}), Un = o({
|
|
1179
1183
|
scene: e.string()
|
|
1180
1184
|
}), Fn = o({
|
|
1181
1185
|
params: e.string()
|
|
@@ -1206,7 +1210,7 @@ class qr {
|
|
|
1206
1210
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=wFXxtdNKPm
|
|
1207
1211
|
*/
|
|
1208
1212
|
async getConfig() {
|
|
1209
|
-
const { data: t } = await this.req.get(`event/${this.event}/event-config`,
|
|
1213
|
+
const { data: t } = await this.req.get(`event/${this.event}/event-config`, Vn);
|
|
1210
1214
|
return t;
|
|
1211
1215
|
}
|
|
1212
1216
|
/**
|
|
@@ -1361,7 +1365,7 @@ class qr {
|
|
|
1361
1365
|
const { data: n } = await this.req.post(
|
|
1362
1366
|
"event/user-rewards",
|
|
1363
1367
|
a({ max_results: 20, ...t, event_id: this.event }),
|
|
1364
|
-
|
|
1368
|
+
$n
|
|
1365
1369
|
);
|
|
1366
1370
|
return {
|
|
1367
1371
|
user_rewards: ((n == null ? void 0 : n.user_rewards) || []).map((r) => (r.reward_status = r.reward_status === _.UnclaimedErr ? _.Unclaimed : r.reward_status, r)),
|
|
@@ -1399,7 +1403,7 @@ class qr {
|
|
|
1399
1403
|
*/
|
|
1400
1404
|
async getUnlimitQrcodeScene(t) {
|
|
1401
1405
|
if (!await this.token.autoLogin()) return null;
|
|
1402
|
-
const { data: n } = await this.req.get("event/unlimit-qrcode-scene",
|
|
1406
|
+
const { data: n } = await this.req.get("event/unlimit-qrcode-scene", Un, {
|
|
1403
1407
|
params: { params: t }
|
|
1404
1408
|
});
|
|
1405
1409
|
return (n == null ? void 0 : n.scene) ?? null;
|
|
@@ -1433,7 +1437,7 @@ const In = {
|
|
|
1433
1437
|
All: "all",
|
|
1434
1438
|
/** 指定用户可发帖 */
|
|
1435
1439
|
Limit: "limit"
|
|
1436
|
-
}, Gn = e.string().enum(In).lock(),
|
|
1440
|
+
}, Gn = e.string().enum(In).lock(), Nn = {
|
|
1437
1441
|
/** 待审核(仅自己可见) */
|
|
1438
1442
|
Pending: "pending",
|
|
1439
1443
|
/** 审核通过 */
|
|
@@ -1442,14 +1446,14 @@ const In = {
|
|
|
1442
1446
|
Failed: "failed",
|
|
1443
1447
|
/** 嫌疑(仅自己可见) */
|
|
1444
1448
|
Suspect: "suspect"
|
|
1445
|
-
}, oe = e.string().enum(
|
|
1449
|
+
}, oe = e.string().enum(Nn).lock(), An = {
|
|
1446
1450
|
/** 系统通知 */
|
|
1447
1451
|
System: "system",
|
|
1448
1452
|
/** 评论我的 */
|
|
1449
1453
|
Comment: "comment",
|
|
1450
1454
|
/** 点赞通知 */
|
|
1451
1455
|
Like: "like"
|
|
1452
|
-
}, xr = e.string().enum(
|
|
1456
|
+
}, xr = e.string().enum(An).lock(), m = {
|
|
1453
1457
|
/** 系统通知 */
|
|
1454
1458
|
System: "system",
|
|
1455
1459
|
/** 帖子被置顶 */
|
|
@@ -1474,7 +1478,7 @@ const In = {
|
|
|
1474
1478
|
ReplyLiked: "reply_liked",
|
|
1475
1479
|
/** 回复被删除 */
|
|
1476
1480
|
ReplyDeleted: "reply_deleted"
|
|
1477
|
-
},
|
|
1481
|
+
}, On = e.string().enum(m).lock(), ae = e.object({
|
|
1478
1482
|
forum_id: e.number(),
|
|
1479
1483
|
icon_url: e.string(),
|
|
1480
1484
|
name: e.string(),
|
|
@@ -1516,7 +1520,7 @@ const In = {
|
|
|
1516
1520
|
replied_by: e.string(),
|
|
1517
1521
|
nickname: e.string(),
|
|
1518
1522
|
avatar_url: e.string()
|
|
1519
|
-
}).lock(),
|
|
1523
|
+
}).lock(), V = e.object({
|
|
1520
1524
|
reply_id: e.number(),
|
|
1521
1525
|
comment_id: e.number(),
|
|
1522
1526
|
comment_content: e.string().optional(),
|
|
@@ -1550,14 +1554,14 @@ const In = {
|
|
|
1550
1554
|
image_url: e.string(),
|
|
1551
1555
|
create_time: e.number(),
|
|
1552
1556
|
status: oe,
|
|
1553
|
-
replies: e.array(
|
|
1557
|
+
replies: e.array(V).optional()
|
|
1554
1558
|
}).lock(), Qn = e.object({
|
|
1555
1559
|
image_url: e.string(),
|
|
1556
1560
|
upload_url: e.string(),
|
|
1557
1561
|
existed: e.bool()
|
|
1558
1562
|
}).lock(), y = e.object({
|
|
1559
1563
|
notification_id: e.string(),
|
|
1560
|
-
notification_type:
|
|
1564
|
+
notification_type: On,
|
|
1561
1565
|
is_read: e.bool(),
|
|
1562
1566
|
create_time: e.number(),
|
|
1563
1567
|
origin_user_id: e.string(),
|
|
@@ -1629,10 +1633,10 @@ const In = {
|
|
|
1629
1633
|
posts: e.array(D),
|
|
1630
1634
|
next_token: e.string().optional()
|
|
1631
1635
|
}), ir = o({ post: D, antispam: se }), or = o({
|
|
1632
|
-
replies: e.array(
|
|
1636
|
+
replies: e.array(V),
|
|
1633
1637
|
next_token: e.string().optional()
|
|
1634
|
-
}), ar = o({ reply:
|
|
1635
|
-
reply:
|
|
1638
|
+
}), ar = o({ reply: V }), sr = o({
|
|
1639
|
+
reply: V.clone().optional(),
|
|
1636
1640
|
antispam: se.clone().optional()
|
|
1637
1641
|
}), cr = o({ comment: k }), ur = o({
|
|
1638
1642
|
comments: e.array(k),
|
|
@@ -1892,9 +1896,12 @@ class Lr {
|
|
|
1892
1896
|
*/
|
|
1893
1897
|
constructor(t, n) {
|
|
1894
1898
|
l(this, "token");
|
|
1895
|
-
l(this, "appid");
|
|
1899
|
+
l(this, "$appid");
|
|
1896
1900
|
l(this, "req");
|
|
1897
|
-
this.token = t, this.req = t.req, this
|
|
1901
|
+
this.token = t, this.req = t.req, this.$appid = n, this.getLoginCache();
|
|
1902
|
+
}
|
|
1903
|
+
get appid() {
|
|
1904
|
+
return this.$appid;
|
|
1898
1905
|
}
|
|
1899
1906
|
/**
|
|
1900
1907
|
* 检查缓存中的登录数据
|
|
@@ -1933,7 +1940,7 @@ class Lr {
|
|
|
1933
1940
|
const t = await this.getLoginCache();
|
|
1934
1941
|
if (t)
|
|
1935
1942
|
return t;
|
|
1936
|
-
const n = await
|
|
1943
|
+
const n = await he(), { data: r, code: s } = await this.req.post(
|
|
1937
1944
|
"weixin/login",
|
|
1938
1945
|
{ code: n, appid: this.appid },
|
|
1939
1946
|
S,
|
|
@@ -1960,7 +1967,7 @@ class Lr {
|
|
|
1960
1967
|
async webLogin(t = "snsapi_userinfo") {
|
|
1961
1968
|
const n = L("code"), r = Date.now(), s = +L("state");
|
|
1962
1969
|
if (!n || !s || s < r - 1e3 * 60 * 5 || s > r) {
|
|
1963
|
-
const ue =
|
|
1970
|
+
const ue = N(["code", "state"]);
|
|
1964
1971
|
location.replace(
|
|
1965
1972
|
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(ue)}&response_type=code&scope=${t}&state=${r}#wechat_redirect`
|
|
1966
1973
|
);
|
|
@@ -1968,7 +1975,7 @@ class Lr {
|
|
|
1968
1975
|
}
|
|
1969
1976
|
if (/^100\d{2}$/.test(n))
|
|
1970
1977
|
return { error: n };
|
|
1971
|
-
const d =
|
|
1978
|
+
const d = N(["code", "state"]);
|
|
1972
1979
|
"replaceState" in history && history.replaceState({}, "", d);
|
|
1973
1980
|
const { data: p, code: ce } = await this.req.post(
|
|
1974
1981
|
"weixin/login",
|
|
@@ -2019,19 +2026,19 @@ class Lr {
|
|
|
2019
2026
|
}
|
|
2020
2027
|
export {
|
|
2021
2028
|
se as AntispamValidator,
|
|
2022
|
-
|
|
2029
|
+
hr as AuthToken,
|
|
2023
2030
|
nn as CashbackEngagementDataValidator,
|
|
2024
2031
|
_ as ClaimRewardStatus,
|
|
2025
2032
|
E as ClaimRewardStatusValidator,
|
|
2026
|
-
|
|
2033
|
+
Rn as ClaimedItemValidator,
|
|
2027
2034
|
K as ClubAddressValidator,
|
|
2028
2035
|
kr as ClubApi,
|
|
2029
2036
|
X as ClubBenefitSummaryValidator,
|
|
2030
2037
|
Ge as ClubBenefitValidator,
|
|
2031
2038
|
je as ClubCreditChangeScene,
|
|
2032
2039
|
Te as ClubCreditChangeSceneValidator,
|
|
2033
|
-
|
|
2034
|
-
|
|
2040
|
+
Re as ClubCreditChangeType,
|
|
2041
|
+
Ve as ClubCreditChangeTypeValidator,
|
|
2035
2042
|
Ie as ClubCreditLogValidator,
|
|
2036
2043
|
Le as ClubGlobalConfigValidator,
|
|
2037
2044
|
qe as ClubItemType,
|
|
@@ -2048,22 +2055,22 @@ export {
|
|
|
2048
2055
|
Ze as EngageAccountType,
|
|
2049
2056
|
We as EngageAccountTypeValidator,
|
|
2050
2057
|
Cn as EngageResponseValidator,
|
|
2051
|
-
|
|
2058
|
+
wn as EngageRewardValidator,
|
|
2052
2059
|
qr as EventApi,
|
|
2053
2060
|
tn as EventConfigValidator,
|
|
2054
2061
|
_t as EventFeatureConfigOfCashbackValidator,
|
|
2055
2062
|
yt as EventFeatureConfigOfCheckInValidator,
|
|
2056
|
-
|
|
2063
|
+
ht as EventFeatureConfigOfClaimRewardsValidator,
|
|
2057
2064
|
kt as EventFeatureConfigOfCommentValidator,
|
|
2058
2065
|
Ct as EventFeatureConfigOfFollowValidator,
|
|
2059
2066
|
jt as EventFeatureConfigOfGiftCodeValidator,
|
|
2060
2067
|
qt as EventFeatureConfigOfInviteValidator,
|
|
2061
2068
|
St as EventFeatureConfigOfInvitedRegisterValidator,
|
|
2062
2069
|
Ft as EventFeatureConfigOfLotteryDrawValidator,
|
|
2063
|
-
|
|
2070
|
+
$t as EventFeatureConfigOfLotteryValidator,
|
|
2064
2071
|
It as EventFeatureConfigOfPreregisterValidator,
|
|
2065
|
-
|
|
2066
|
-
|
|
2072
|
+
Nt as EventFeatureConfigOfQuestValidator,
|
|
2073
|
+
Ot as EventFeatureConfigOfRegisterValidator,
|
|
2067
2074
|
Qt as EventFeatureConfigOfShareValidator,
|
|
2068
2075
|
Ht as EventFeatureConfigOfSubscribeValidator,
|
|
2069
2076
|
Jt as EventFeatureConfigOfSurveyValidator,
|
|
@@ -2072,16 +2079,16 @@ export {
|
|
|
2072
2079
|
en as EventFeatureConfigValidator,
|
|
2073
2080
|
et as EventPeriodType,
|
|
2074
2081
|
tt as EventPeriodTypeValidator,
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2082
|
+
U as EventRewardItemConfigValidator,
|
|
2083
|
+
Ae as ExtraGameRewardValidator,
|
|
2084
|
+
Ne as ExtraPhysicalShipmentValidator,
|
|
2078
2085
|
gt as FeatureRewardValidator,
|
|
2079
2086
|
c as FeatureType,
|
|
2080
2087
|
nt as FeatureTypeValidator,
|
|
2081
2088
|
In as ForumMode,
|
|
2082
2089
|
Gn as ForumModeValidator,
|
|
2083
2090
|
ae as ForumValidator,
|
|
2084
|
-
|
|
2091
|
+
R as GamerItemType,
|
|
2085
2092
|
Z as GamerItemTypeValidator,
|
|
2086
2093
|
ve as Gender,
|
|
2087
2094
|
Ce as GenderValidator,
|
|
@@ -2091,10 +2098,10 @@ export {
|
|
|
2091
2098
|
jr as LotteryDrawActionValidator,
|
|
2092
2099
|
un as LotteryDrawEngagementDataValidator,
|
|
2093
2100
|
an as LotteryEngagementDataValidator,
|
|
2094
|
-
|
|
2095
|
-
|
|
2101
|
+
w as LotteryTicketStatus,
|
|
2102
|
+
Rr as LotteryTicketStatusValidator,
|
|
2096
2103
|
y as NotificationBaseValidator,
|
|
2097
|
-
|
|
2104
|
+
An as NotificationCategory,
|
|
2098
2105
|
xr as NotificationCategoryValidator,
|
|
2099
2106
|
Kn as NotificationCommentReplyValidator,
|
|
2100
2107
|
Xn as NotificationCommentValidator,
|
|
@@ -2108,11 +2115,11 @@ export {
|
|
|
2108
2115
|
Zn as NotificationReplyValidator,
|
|
2109
2116
|
Hn as NotificationSystemValidator,
|
|
2110
2117
|
m as NotificationType,
|
|
2111
|
-
|
|
2118
|
+
On as NotificationTypeValidator,
|
|
2112
2119
|
Wn as NotificationValidator,
|
|
2113
|
-
|
|
2120
|
+
Ue as PlayerRoleCardValidator,
|
|
2114
2121
|
J as PlayerRoleValidator,
|
|
2115
|
-
|
|
2122
|
+
Nn as PostStatus,
|
|
2116
2123
|
oe as PostStatusValidator,
|
|
2117
2124
|
D as PostValidator,
|
|
2118
2125
|
ln as PreregisterEngagementDataValidator,
|
|
@@ -2120,26 +2127,26 @@ export {
|
|
|
2120
2127
|
mn as QuestEngagementDataValidator,
|
|
2121
2128
|
rt as QuestObjective,
|
|
2122
2129
|
ee as QuestObjectiveValidator,
|
|
2123
|
-
|
|
2124
|
-
|
|
2130
|
+
wr as RedeemParamsValidator,
|
|
2131
|
+
Oe as RedemptionValidator,
|
|
2125
2132
|
dt as RegularRewardValidator,
|
|
2126
2133
|
Bn as ReplyToValidator,
|
|
2127
|
-
|
|
2134
|
+
V as ReplyValidator,
|
|
2128
2135
|
vr as RewardItemType,
|
|
2129
2136
|
W as RewardItemTypeValidator,
|
|
2130
2137
|
at as RewardSource,
|
|
2131
|
-
|
|
2138
|
+
$ as RewardSourceValidator,
|
|
2132
2139
|
g as RewardStatus,
|
|
2133
2140
|
P as RewardStatusSuffix,
|
|
2134
2141
|
te as RewardStatusSuffixValidator,
|
|
2135
2142
|
Cr as RewardStatusValidator,
|
|
2136
|
-
|
|
2137
|
-
|
|
2143
|
+
hn as RewardValidator,
|
|
2144
|
+
$e as RoleBaseInfoValidator,
|
|
2138
2145
|
Ee as ServerBaseInfoValidator,
|
|
2139
2146
|
dn as ShareEngagementDataValidator,
|
|
2140
2147
|
pn as SurveyEngagementDataValidator,
|
|
2141
2148
|
ut as TeamAction,
|
|
2142
|
-
|
|
2149
|
+
Vr as TeamActionValidator,
|
|
2143
2150
|
bn as TeamEngagementDataValidator,
|
|
2144
2151
|
_n as TeamEngagementValidator,
|
|
2145
2152
|
Tr as TeamMemberValidator,
|
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
|
+
"version": "2.0.16",
|
|
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.3",
|
|
26
|
-
"@seayoo-web/request": "^3.0.3",
|
|
27
|
-
"@seayoo-web/scripts": "^2.0.4",
|
|
28
26
|
"@seayoo-web/tsconfig": "^1.0.3",
|
|
29
|
-
"@seayoo-web/
|
|
27
|
+
"@seayoo-web/request": "^3.0.3",
|
|
28
|
+
"@seayoo-web/utils": "^3.4.4",
|
|
29
|
+
"@seayoo-web/scripts": "^2.0.12"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@seayoo-web/combo-webview": "^2.5.3",
|
package/types/src/token.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type StorageHelper } from "./utils";
|
|
2
2
|
import type { NetRequestFactory } from "@seayoo-web/request";
|
|
3
3
|
export * from "./token.define";
|
|
4
4
|
/**
|
|
@@ -11,82 +11,83 @@ export * from "./token.define";
|
|
|
11
11
|
* - [Weixin Token](https://kdocs.cn/l/cf2mO2uRLqh9?linkname=YtzQpmRQ0v)
|
|
12
12
|
*/
|
|
13
13
|
export declare class AuthToken {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
private $NetRequest;
|
|
15
|
+
private $idToken;
|
|
16
|
+
private $weixinToken;
|
|
17
|
+
private $gamerToken;
|
|
18
|
+
req: ReturnType<NetRequestFactory>;
|
|
19
|
+
storage: StorageHelper;
|
|
20
|
+
constructor(
|
|
20
21
|
/**
|
|
21
22
|
* 服务端点
|
|
22
23
|
*
|
|
23
24
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=k2iGGXbfov
|
|
24
25
|
*/
|
|
25
|
-
endpoint: string,
|
|
26
|
+
endpoint: string,
|
|
26
27
|
/** request 工具类 */
|
|
27
|
-
NetRequest: NetRequestFactory
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
28
|
+
NetRequest: NetRequestFactory);
|
|
29
|
+
get NetRequest(): typeof import("@seayoo-web/request").NetRequest;
|
|
30
|
+
private loadGamerTokenCache;
|
|
31
|
+
/** 当前是否为登录状态,即是否拥有 gamerToken */
|
|
32
|
+
get isLoggedIn(): boolean;
|
|
33
|
+
/** 读取已经设置的 idToken */
|
|
34
|
+
get idToken(): string;
|
|
35
|
+
/** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
|
|
36
|
+
set idToken(value: string);
|
|
37
|
+
/** 读取设置 weixinToken */
|
|
38
|
+
get weixinToken(): string;
|
|
39
|
+
/**
|
|
40
|
+
* 设置 Weixin Token,用于后续请求自动置换 Gamer Token
|
|
41
|
+
*
|
|
42
|
+
* 仅仅在微信小程序模式下有效
|
|
43
|
+
*/
|
|
44
|
+
set weixinToken(value: string);
|
|
45
|
+
/** 读取自动置换的 gamerToken */
|
|
46
|
+
get gamerToken(): string;
|
|
47
|
+
/**
|
|
48
|
+
* 直接写入 Gamer Token,并更新缓存
|
|
49
|
+
*/
|
|
50
|
+
set gamerToken(value: string);
|
|
51
|
+
/**
|
|
52
|
+
* 退出登录,销毁相关 Token
|
|
53
|
+
*/
|
|
54
|
+
logout(): void;
|
|
55
|
+
/**
|
|
56
|
+
* 用世游通行证统一登录能力签发的 ID Token / Weixin Token,自动置换 Gamer Token,成功后会自动设置后续 Request Headers
|
|
57
|
+
*
|
|
58
|
+
* [世游通行证统一登录](https://kdocs.cn/l/cf2mO2uRLqh9?linkname=FJXYgqvLHs)
|
|
59
|
+
*
|
|
60
|
+
* [世游通行证统一登录 - Web 站点](https://365.kdocs.cn/l/cf57sp1qLlZh)
|
|
61
|
+
*
|
|
62
|
+
* [世游通行证统一登录 - 微信小程序](https://365.kdocs.cn/l/ccHVuUs0UsZs)
|
|
63
|
+
*
|
|
64
|
+
* - 此方法通常不需要手动调用,在需要登录的接口调用时会自动执行
|
|
65
|
+
* - 为了提高页面执行速度,可以在设置 Token 后立即调用 autoLogin
|
|
66
|
+
*
|
|
67
|
+
* 🔕请求静默进行,无消息提示
|
|
68
|
+
*
|
|
69
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ReeJpWraRO
|
|
70
|
+
*/
|
|
71
|
+
autoLogin(): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* 获取当前登录用户的 Session 的信息
|
|
74
|
+
*
|
|
75
|
+
* 🔕请求静默进行,无消息提示
|
|
76
|
+
*
|
|
77
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OdGVCdQxEu
|
|
78
|
+
*/
|
|
79
|
+
getSession(): Promise<import("./token.define").GamerSession | null>;
|
|
80
|
+
/**
|
|
81
|
+
* 实名认证
|
|
82
|
+
*
|
|
83
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=kZYnwX6RcF
|
|
84
|
+
*/
|
|
85
|
+
authRealName(option: {
|
|
86
|
+
/** 用户输入的真实姓名。明文或者密文 */
|
|
87
|
+
real_name: string;
|
|
88
|
+
/** 用户输入的身份证号码。明文或者密文 */
|
|
89
|
+
identity_card: string;
|
|
90
|
+
/** 预留参数,是否加密 real_name 和 identity_card,加密的密钥应当使用 api 服务的 ECDSA Public Key */
|
|
91
|
+
encrypted?: boolean;
|
|
92
|
+
}): Promise<import("./token.define").GamerSession | null>;
|
|
92
93
|
}
|
package/types/src/weixin.d.ts
CHANGED
|
@@ -1,104 +1,97 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type WeixinWebLoginErrorCode } from "./weixin.define";
|
|
2
2
|
import type { AuthToken } from "./token";
|
|
3
3
|
import type { RequestInternalError } from "@seayoo-web/request";
|
|
4
4
|
export * from "./weixin.define";
|
|
5
5
|
export declare class WeixinApi {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
| {
|
|
6
|
+
private token;
|
|
7
|
+
private $appid;
|
|
8
|
+
private req;
|
|
9
|
+
/**
|
|
10
|
+
* 创建微信相关功能接口
|
|
11
|
+
*
|
|
12
|
+
* - authToken 需要导入 AuthToken 进行初始化后传入
|
|
13
|
+
* - appid 可以静态设置,也可以在小程序中动态获取,见下示例代码
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* const info = wx.getAccountInfoSync();
|
|
17
|
+
* console.log(info.miniProgram.appId)
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/account-info/wx.getAccountInfoSync.html
|
|
21
|
+
*/
|
|
22
|
+
constructor(authToken: AuthToken, appid: string);
|
|
23
|
+
get appid(): string;
|
|
24
|
+
/**
|
|
25
|
+
* 检查缓存中的登录数据
|
|
26
|
+
*
|
|
27
|
+
* 如果没有缓存或缓存数据错误,则需要调用 [wx.login](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html) 后调用 login 方法
|
|
28
|
+
*
|
|
29
|
+
* 也可以直接调用 login 方法,并传入 weixin code 的读取函数
|
|
30
|
+
*/
|
|
31
|
+
getLoginCache(): Promise<import("./weixin.define").WeixinLoginResponse | null>;
|
|
32
|
+
/**
|
|
33
|
+
* 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
|
|
34
|
+
*
|
|
35
|
+
* 使用场景:
|
|
36
|
+
*
|
|
37
|
+
* - 小程序的任意页面打开后应该优先调用此方法以获取登录状态
|
|
38
|
+
*
|
|
39
|
+
* 注意:
|
|
40
|
+
*
|
|
41
|
+
* - 登录成功后会将登录信息缓存到本地,重复或并发调用不会引起任何副作用。
|
|
42
|
+
* - 由于小程序的存储是以用户维度隔离的,每个微信用户在每个小程序下只要成功调用一次此 API 就会缓存请求结果。
|
|
43
|
+
* - 微信公众号网页授权请使用 webLogin 方法
|
|
44
|
+
*
|
|
45
|
+
* 🔕请求静默进行,无消息提示
|
|
46
|
+
*
|
|
47
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=GwIZ0givCb
|
|
48
|
+
*/
|
|
49
|
+
login(): Promise<import("./weixin.define").WeixinLoginResponse | {
|
|
51
50
|
error: RequestInternalError | "invalid_weixin_appid" | "invalid_weixin_code";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
webLogin(scope?: "snsapi_base" | "snsapi_userinfo"): Promise<
|
|
71
|
-
| import("./weixin.define").WeixinLoginResponse
|
|
72
|
-
| {
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* 在微信内嵌网页中调用微信公众号授权登录【暂未启用】
|
|
54
|
+
*
|
|
55
|
+
* 注意:
|
|
56
|
+
*
|
|
57
|
+
* - 登录回调地址强制是当前页面,包括 location search 和 location hash 部分
|
|
58
|
+
* - 登录跳转返回 code 后,会将 code 从 url 中删除以防止 code 泄露,如需设置分享则需要在此方法执行完毕之后
|
|
59
|
+
*
|
|
60
|
+
* 官方参考资料:
|
|
61
|
+
*
|
|
62
|
+
* - [微信网页开发 / 网页授权](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html)
|
|
63
|
+
*
|
|
64
|
+
* @param scope - 网页授权作用域
|
|
65
|
+
* - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取 union_id 则需要 snsapi_userinfo
|
|
66
|
+
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
|
|
67
|
+
*/
|
|
68
|
+
webLogin(scope?: "snsapi_base" | "snsapi_userinfo"): Promise<import("./weixin.define").WeixinLoginResponse | {
|
|
73
69
|
error: WeixinWebLoginErrorCode;
|
|
74
|
-
|
|
75
|
-
| {
|
|
70
|
+
} | {
|
|
76
71
|
error: RequestInternalError | "invalid_weixin_appid" | "invalid_weixin_code";
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
signature: string;
|
|
103
|
-
} | null>;
|
|
72
|
+
} | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* 关联游戏账号,无返回值,全程静默
|
|
75
|
+
*
|
|
76
|
+
* 用于从游戏内跳转至小程序时,将微信用户身份和游戏内身份关联起来,使得后续的企业微信客服流程能够知道该微信用户在游戏内的身份。
|
|
77
|
+
*
|
|
78
|
+
* 🔕请求静默进行,无消息提示
|
|
79
|
+
*
|
|
80
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ci73N833Mk
|
|
81
|
+
*
|
|
82
|
+
* @param weixinToken 调用 login 后,得到的 weixinToken,如果 weixinToken 为空则跳过不处理
|
|
83
|
+
* @param gameCode 从游戏内跳转至小程序时,通过请求参数 query 携带的 game_code,如果值为空则跳过不处理
|
|
84
|
+
*/
|
|
85
|
+
linkPlayer(weixinToken: string, gameCode: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* 获取集成 JSSDK 所需的签名信息
|
|
88
|
+
*
|
|
89
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=CuWOqxr9Ue
|
|
90
|
+
*/
|
|
91
|
+
getJSSDKConfig(): Promise<{
|
|
92
|
+
appid: string;
|
|
93
|
+
nonceStr: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
signature: string;
|
|
96
|
+
} | null>;
|
|
104
97
|
}
|