@seayoo-web/gamer-api 2.0.11 → 2.0.13
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 +1 -1
- package/dist/index.js +8 -4
- package/package.json +4 -4
- package/types/src/event.config/feature.lottery.d.ts +1 -1
- package/types/src/event.config/reward.d.ts +1 -1
- package/types/src/event.enums.d.ts +4 -0
- package/types/src/weixin.d.ts +3 -3
- package/types/src/weixin.define.d.ts +4 -4
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ export function login() {
|
|
|
78
78
|
if(!idToken) {
|
|
79
79
|
return
|
|
80
80
|
}
|
|
81
|
-
// 获取 weixinToken,成功时返回 { weixin_token,
|
|
81
|
+
// 获取 weixinToken,成功时返回 { weixin_token, open_id, union_id }
|
|
82
82
|
const result = await weixinApi.login();
|
|
83
83
|
if(!("weixin_token" in result)) {
|
|
84
84
|
return
|
package/dist/index.js
CHANGED
|
@@ -640,6 +640,8 @@ const V = {
|
|
|
640
640
|
LotteryTicket: "lottery_ticket",
|
|
641
641
|
/** 积分 */
|
|
642
642
|
Credit: "credit",
|
|
643
|
+
/** 外部兑换码 */
|
|
644
|
+
ExternalCode: "external_gift_code",
|
|
643
645
|
/** 空奖励 */
|
|
644
646
|
VoidItem: "void_item"
|
|
645
647
|
}, Z = e.string().enum(V).lock(), Cr = V, W = Z, Ze = {
|
|
@@ -1019,6 +1021,8 @@ const V = {
|
|
|
1019
1021
|
engagement_id: e.number(),
|
|
1020
1022
|
feature_type: nt,
|
|
1021
1023
|
receive_time: e.number(),
|
|
1024
|
+
// https://kdocs.cn/l/ckWFDcOsYEUA?linkname=merUzJsVYH
|
|
1025
|
+
// 后续会格式化为具体的类型,此处的校验需要对应增加
|
|
1022
1026
|
extra_data: e.record(e.unknown()).optional()
|
|
1023
1027
|
}), sn = e.string().enum(h.Unknown, h.Pending), cn = e.union(
|
|
1024
1028
|
e.object({
|
|
@@ -1870,7 +1874,7 @@ const pr = o({
|
|
|
1870
1874
|
});
|
|
1871
1875
|
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 || {});
|
|
1872
1876
|
function S(i) {
|
|
1873
|
-
return v(i, "
|
|
1877
|
+
return v(i, "open_id", "union_id", "weixin_token");
|
|
1874
1878
|
}
|
|
1875
1879
|
const H = "wx_login_cache";
|
|
1876
1880
|
class Pr {
|
|
@@ -1908,7 +1912,7 @@ class Pr {
|
|
|
1908
1912
|
return S(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
|
|
1909
1913
|
}
|
|
1910
1914
|
/**
|
|
1911
|
-
* 小程序页面微信静默登录,获取 weixinToken /
|
|
1915
|
+
* 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
|
|
1912
1916
|
*
|
|
1913
1917
|
* 使用场景:
|
|
1914
1918
|
*
|
|
@@ -1951,8 +1955,8 @@ class Pr {
|
|
|
1951
1955
|
* - [微信网页开发 / 网页授权](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html)
|
|
1952
1956
|
*
|
|
1953
1957
|
* @param scope - 网页授权作用域
|
|
1954
|
-
* - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取
|
|
1955
|
-
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、
|
|
1958
|
+
* - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取 union_id 则需要 snsapi_userinfo
|
|
1959
|
+
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
|
|
1956
1960
|
*/
|
|
1957
1961
|
async webLogin(t = "snsapi_userinfo") {
|
|
1958
1962
|
const n = L("code"), r = Date.now(), s = +L("state");
|
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.13",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "index.ts",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">=22"
|
|
20
20
|
},
|
|
21
21
|
"author": "web@seayoo.com",
|
|
22
22
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"vitest": "^3.0.5",
|
|
26
26
|
"@seayoo-web/combo-webview": "^2.5.3",
|
|
27
27
|
"@seayoo-web/request": "^3.0.3",
|
|
28
|
-
"@seayoo-web/scripts": "^2.0.1",
|
|
29
28
|
"@seayoo-web/tsconfig": "^1.0.3",
|
|
30
|
-
"@seayoo-web/utils": "^3.4.4"
|
|
29
|
+
"@seayoo-web/utils": "^3.4.4",
|
|
30
|
+
"@seayoo-web/scripts": "^2.0.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@seayoo-web/combo-webview": "^2.5.3",
|
|
@@ -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<"
|
|
3
|
+
declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "external_gift_code" | "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<"
|
|
2
|
+
declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "external_gift_code" | "void_item", false, false>;
|
|
3
3
|
export interface EventRewardItemConfig {
|
|
4
4
|
/** 玩法奖励道具 id */
|
|
5
5
|
reward_item_id: number;
|
|
@@ -15,6 +15,8 @@ export declare const GamerItemType: {
|
|
|
15
15
|
readonly LotteryTicket: "lottery_ticket";
|
|
16
16
|
/** 积分 */
|
|
17
17
|
readonly Credit: "credit";
|
|
18
|
+
/** 外部兑换码 */
|
|
19
|
+
readonly ExternalCode: "external_gift_code";
|
|
18
20
|
/** 空奖励 */
|
|
19
21
|
readonly VoidItem: "void_item";
|
|
20
22
|
};
|
|
@@ -44,6 +46,8 @@ export declare const RewardItemType: {
|
|
|
44
46
|
readonly LotteryTicket: "lottery_ticket";
|
|
45
47
|
/** 积分 */
|
|
46
48
|
readonly Credit: "credit";
|
|
49
|
+
/** 外部兑换码 */
|
|
50
|
+
readonly ExternalCode: "external_gift_code";
|
|
47
51
|
/** 空奖励 */
|
|
48
52
|
readonly VoidItem: "void_item";
|
|
49
53
|
};
|
package/types/src/weixin.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class WeixinApi {
|
|
|
29
29
|
*/
|
|
30
30
|
getLoginCache(): Promise<import("./weixin.define").WeixinLoginResponse | null>;
|
|
31
31
|
/**
|
|
32
|
-
* 小程序页面微信静默登录,获取 weixinToken /
|
|
32
|
+
* 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
|
|
33
33
|
*
|
|
34
34
|
* 使用场景:
|
|
35
35
|
*
|
|
@@ -61,8 +61,8 @@ export declare class WeixinApi {
|
|
|
61
61
|
* - [微信网页开发 / 网页授权](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html)
|
|
62
62
|
*
|
|
63
63
|
* @param scope - 网页授权作用域
|
|
64
|
-
* - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取
|
|
65
|
-
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、
|
|
64
|
+
* - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取 union_id 则需要 snsapi_userinfo
|
|
65
|
+
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
|
|
66
66
|
*/
|
|
67
67
|
webLogin(scope?: "snsapi_base" | "snsapi_userinfo"): Promise<import("./weixin.define").WeixinLoginResponse | {
|
|
68
68
|
error: WeixinWebLoginErrorCode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface WeixinLoginResponse {
|
|
2
|
-
/** 微信小程序下,用户的
|
|
3
|
-
|
|
4
|
-
/** 微信小程序所在的微信开放平台账号下,用户的
|
|
5
|
-
|
|
2
|
+
/** 微信小程序下,用户的 open_id */
|
|
3
|
+
open_id: string;
|
|
4
|
+
/** 微信小程序所在的微信开放平台账号下,用户的 union_id */
|
|
5
|
+
union_id: string;
|
|
6
6
|
/**
|
|
7
7
|
* Gamer 为这个微信小程序用户签发的 Weixin Token。长期有效
|
|
8
8
|
*
|