@seayoo-web/gamer-api 2.0.14 → 2.0.15

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 CHANGED
@@ -3,7 +3,6 @@ var me = (i, t, n) => t in i ? le(i, t, { enumerable: !0, configurable: !0, writ
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
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 A } from "@seayoo-web/utils";
6
- import "@seayoo-web/request";
7
6
  function ye(i) {
8
7
  return v(i, "gamer_token") && typeof i.gamer_token == "string";
9
8
  }
@@ -59,7 +58,7 @@ const he = {
59
58
  }
60
59
  }
61
60
  }, w = "gamer_token";
62
- class hr {
61
+ class wr {
63
62
  constructor(t, n) {
64
63
  l(this, "$idToken", "");
65
64
  l(this, "$weixinToken", "");
@@ -354,7 +353,7 @@ const ve = {
354
353
  }).lock(), Ge = e.object({
355
354
  ...C(X.shape, "tag"),
356
355
  product: Y.clone().optional()
357
- }).lock(), kr = e.union(
356
+ }).lock(), hr = e.union(
358
357
  e.object({
359
358
  server_id: e.string(),
360
359
  role_id: e.string()
@@ -396,7 +395,7 @@ const ve = {
396
395
  redemptions: e.array(Ne),
397
396
  next_token: e.string().optional()
398
397
  });
399
- class vr {
398
+ class kr {
400
399
  constructor(t) {
401
400
  l(this, "token");
402
401
  l(this, "req");
@@ -644,7 +643,7 @@ const V = {
644
643
  ExternalCode: "external_gift_code",
645
644
  /** 空奖励 */
646
645
  VoidItem: "void_item"
647
- }, Z = e.string().enum(V).lock(), Cr = V, W = Z, Ze = {
646
+ }, Z = e.string().enum(V).lock(), vr = V, W = Z, Ze = {
648
647
  /** 世游通行证 ID / Combo ID */
649
648
  UserId: "user_id",
650
649
  /** 游戏角色 ID */
@@ -720,7 +719,7 @@ const V = {
720
719
  Failed: "failed",
721
720
  /** 奖励已发货 */
722
721
  Delivered: "delivered"
723
- }, Vr = e.string().enum(g).lock(), P = {
722
+ }, Cr = e.string().enum(g).lock(), P = {
724
723
  /**
725
724
  * 奖励未领取,拼写错误以兼容后端历史版本,检查请使用 Unclaimed
726
725
  *
@@ -773,7 +772,7 @@ const V = {
773
772
  Claimed: "claimed",
774
773
  /** 领奖失败 */
775
774
  Fail: "fail"
776
- }, Rr = e.string().enum(h).lock(), ut = {
775
+ }, Vr = e.string().enum(h).lock(), ut = {
777
776
  /** 发起组队 */
778
777
  Assemble: "assemble",
779
778
  /** 加入队伍 */
@@ -784,14 +783,14 @@ const V = {
784
783
  ChangeVisibility: "change_visibility",
785
784
  /** 查询组队信息 */
786
785
  Query: "query"
787
- }, jr = e.string().enum(ut).lock(), lt = {
786
+ }, Rr = e.string().enum(ut).lock(), lt = {
788
787
  /** 查询抽奖券 */
789
788
  Query: "query",
790
789
  /** 开奖 */
791
790
  Draw: "draw",
792
791
  /** 领奖 */
793
792
  Claim: "claim"
794
- }, Tr = e.string().enum(lt).lock(), mt = e.string().enum(C(V, "GiftCode", "LotteryTicket")), $ = e.object({
793
+ }, jr = e.string().enum(lt).lock(), mt = e.string().enum(C(V, "GiftCode", "LotteryTicket")), $ = e.object({
795
794
  reward_item_id: e.number(),
796
795
  reward_amount: e.number(),
797
796
  reward_item_name: e.string(),
@@ -1064,7 +1063,7 @@ const V = {
1064
1063
  team_code: e.string(),
1065
1064
  leader_name: e.string(),
1066
1065
  total_members: e.number()
1067
- }), qr = e.object({
1066
+ }), Tr = e.object({
1068
1067
  is_leader: e.bool(),
1069
1068
  is_myself: e.bool().optional(),
1070
1069
  role_name: e.string(),
@@ -1183,7 +1182,7 @@ const V = {
1183
1182
  }), Dn = o({
1184
1183
  img: e.string()
1185
1184
  });
1186
- class xr {
1185
+ class qr {
1187
1186
  constructor(t, n) {
1188
1187
  l(this, "token");
1189
1188
  l(this, "event", 0);
@@ -1450,7 +1449,7 @@ const In = {
1450
1449
  Comment: "comment",
1451
1450
  /** 点赞通知 */
1452
1451
  Like: "like"
1453
- }, Sr = e.string().enum(On).lock(), m = {
1452
+ }, xr = e.string().enum(On).lock(), m = {
1454
1453
  /** 系统通知 */
1455
1454
  System: "system",
1456
1455
  /** 帖子被置顶 */
@@ -1649,7 +1648,7 @@ const In = {
1649
1648
  comment: e.number(),
1650
1649
  like: e.number()
1651
1650
  });
1652
- class Lr {
1651
+ class Sr {
1653
1652
  constructor(t) {
1654
1653
  l(this, "token");
1655
1654
  l(this, "req");
@@ -1877,7 +1876,7 @@ function S(i) {
1877
1876
  return v(i, "open_id", "union_id", "weixin_token");
1878
1877
  }
1879
1878
  const H = "wx_login_cache";
1880
- class Pr {
1879
+ class Lr {
1881
1880
  /**
1882
1881
  * 创建微信相关功能接口
1883
1882
  *
@@ -2020,13 +2019,13 @@ class Pr {
2020
2019
  }
2021
2020
  export {
2022
2021
  se as AntispamValidator,
2023
- hr as AuthToken,
2022
+ wr as AuthToken,
2024
2023
  nn as CashbackEngagementDataValidator,
2025
2024
  _ as ClaimRewardStatus,
2026
2025
  E as ClaimRewardStatusValidator,
2027
2026
  Vn as ClaimedItemValidator,
2028
2027
  K as ClubAddressValidator,
2029
- vr as ClubApi,
2028
+ kr as ClubApi,
2030
2029
  X as ClubBenefitSummaryValidator,
2031
2030
  Ge as ClubBenefitValidator,
2032
2031
  je as ClubCreditChangeScene,
@@ -2045,12 +2044,12 @@ export {
2045
2044
  Fe as ClubUserProfileValidator,
2046
2045
  fn as CommentEngagementValidator,
2047
2046
  k as CommentValidator,
2048
- Lr as CommunityApi,
2047
+ Sr as CommunityApi,
2049
2048
  Ze as EngageAccountType,
2050
2049
  We as EngageAccountTypeValidator,
2051
2050
  Cn as EngageResponseValidator,
2052
2051
  hn as EngageRewardValidator,
2053
- xr as EventApi,
2052
+ qr as EventApi,
2054
2053
  tn as EventConfigValidator,
2055
2054
  _t as EventFeatureConfigOfCashbackValidator,
2056
2055
  yt as EventFeatureConfigOfCheckInValidator,
@@ -2089,14 +2088,14 @@ export {
2089
2088
  rn as GiftCodeEngagementDataValidator,
2090
2089
  on as InviteEngagementDataValidator,
2091
2090
  lt as LotteryDrawAction,
2092
- Tr as LotteryDrawActionValidator,
2091
+ jr as LotteryDrawActionValidator,
2093
2092
  un as LotteryDrawEngagementDataValidator,
2094
2093
  an as LotteryEngagementDataValidator,
2095
2094
  h as LotteryTicketStatus,
2096
- Rr as LotteryTicketStatusValidator,
2095
+ Vr as LotteryTicketStatusValidator,
2097
2096
  y as NotificationBaseValidator,
2098
2097
  On as NotificationCategory,
2099
- Sr as NotificationCategoryValidator,
2098
+ xr as NotificationCategoryValidator,
2100
2099
  Kn as NotificationCommentReplyValidator,
2101
2100
  Xn as NotificationCommentValidator,
2102
2101
  j as NotificationPayloadCommentValidator,
@@ -2121,29 +2120,29 @@ export {
2121
2120
  mn as QuestEngagementDataValidator,
2122
2121
  rt as QuestObjective,
2123
2122
  ee as QuestObjectiveValidator,
2124
- kr as RedeemParamsValidator,
2123
+ hr as RedeemParamsValidator,
2125
2124
  Ne as RedemptionValidator,
2126
2125
  dt as RegularRewardValidator,
2127
2126
  Bn as ReplyToValidator,
2128
2127
  R as ReplyValidator,
2129
- Cr as RewardItemType,
2128
+ vr as RewardItemType,
2130
2129
  W as RewardItemTypeValidator,
2131
2130
  at as RewardSource,
2132
2131
  U as RewardSourceValidator,
2133
2132
  g as RewardStatus,
2134
2133
  P as RewardStatusSuffix,
2135
2134
  te as RewardStatusSuffixValidator,
2136
- Vr as RewardStatusValidator,
2135
+ Cr as RewardStatusValidator,
2137
2136
  wn as RewardValidator,
2138
2137
  Ue as RoleBaseInfoValidator,
2139
2138
  Ee as ServerBaseInfoValidator,
2140
2139
  dn as ShareEngagementDataValidator,
2141
2140
  pn as SurveyEngagementDataValidator,
2142
2141
  ut as TeamAction,
2143
- jr as TeamActionValidator,
2142
+ Rr as TeamActionValidator,
2144
2143
  bn as TeamEngagementDataValidator,
2145
2144
  _n as TeamEngagementValidator,
2146
- qr as TeamMemberValidator,
2145
+ Tr as TeamMemberValidator,
2147
2146
  st as TeamVisibility,
2148
2147
  ct as TeamVisibilityValidator,
2149
2148
  F as TopicValidator,
@@ -2155,7 +2154,7 @@ export {
2155
2154
  yn as VoteEngagementDataValidator,
2156
2155
  it as VoteOptionSource,
2157
2156
  ot as VoteOptionSourceValidator,
2158
- Pr as WeixinApi,
2157
+ Lr as WeixinApi,
2159
2158
  gn as WeixinSubscribeEngagementDataValidator,
2160
2159
  _r as WeixinWebLoginErrorCode,
2161
2160
  pr as isWeixinSignResponse
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.14",
4
+ "version": "2.0.15",
5
5
  "type": "module",
6
6
  "source": "index.ts",
7
7
  "main": "./dist/index.js",
@@ -22,17 +22,16 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.13.1",
25
- "vitest": "^3.0.5",
26
25
  "@seayoo-web/combo-webview": "^2.5.3",
27
26
  "@seayoo-web/request": "^3.0.3",
28
- "@seayoo-web/utils": "^3.4.4",
29
- "@seayoo-web/scripts": "^2.0.3",
30
- "@seayoo-web/tsconfig": "^1.0.3"
27
+ "@seayoo-web/scripts": "^2.0.4",
28
+ "@seayoo-web/tsconfig": "^1.0.3",
29
+ "@seayoo-web/utils": "^3.4.4"
31
30
  },
32
31
  "peerDependencies": {
33
32
  "@seayoo-web/combo-webview": "^2.5.3",
34
- "@seayoo-web/utils": "^3.4.4",
35
- "@seayoo-web/request": "^3.0.3"
33
+ "@seayoo-web/request": "^3.0.3",
34
+ "@seayoo-web/utils": "^3.4.4"
36
35
  },
37
36
  "scripts": {
38
37
  "prebuild": "pnpm -F request build && pnpm -F combo-webview build",
@@ -1,8 +1,8 @@
1
- import { type RequestInternalError } from "@seayoo-web/request";
2
1
  import { type SomePartial } from "@seayoo-web/utils";
3
2
  import type { ClubAddress, ClubUserProfile, RedeemParams } from "./club.define";
4
3
  import type { ClubCreditChangeType, ClubItemType } from "./club.enums";
5
4
  import type { AuthToken } from "./token";
5
+ import type { RequestInternalError } from "@seayoo-web/request";
6
6
  export * from "./club.enums";
7
7
  export * from "./club.define";
8
8
  export declare class ClubApi {
@@ -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<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "external_gift_code" | "void_item", false, false>;
3
+ declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"credit" | "event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "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<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "credit" | "external_gift_code" | "void_item", false, false>;
2
+ declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"credit" | "event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "external_gift_code" | "void_item", false, false>;
3
3
  export interface EventRewardItemConfig {
4
4
  /** 玩法奖励道具 id */
5
5
  reward_item_id: number;
@@ -1,4 +1,4 @@
1
- import { type StorageHelper } from "./utils";
1
+ import type { StorageHelper } from "./utils";
2
2
  import type { NetRequestFactory } from "@seayoo-web/request";
3
3
  export * from "./token.define";
4
4
  /**
@@ -11,81 +11,82 @@ export * from "./token.define";
11
11
  * - [Weixin Token](https://kdocs.cn/l/cf2mO2uRLqh9?linkname=YtzQpmRQ0v)
12
12
  */
13
13
  export declare class AuthToken {
14
- private $idToken;
15
- private $weixinToken;
16
- private $gamerToken;
17
- req: ReturnType<NetRequestFactory>;
18
- storage: StorageHelper;
19
- constructor(
14
+ private $idToken;
15
+ private $weixinToken;
16
+ private $gamerToken;
17
+ req: ReturnType<NetRequestFactory>;
18
+ storage: StorageHelper;
19
+ constructor(
20
20
  /**
21
21
  * 服务端点
22
22
  *
23
23
  * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=k2iGGXbfov
24
24
  */
25
- endpoint: string,
25
+ endpoint: string,
26
26
  /** request 工具类 */
27
- NetRequest: NetRequestFactory);
28
- private loadGamerTokenCache;
29
- /** 当前是否为登录状态,即是否拥有 gamerToken */
30
- get isLoggedIn(): boolean;
31
- /** 读取已经设置的 idToken */
32
- get idToken(): string;
33
- /** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
34
- set idToken(value: string);
35
- /** 读取设置 weixinToken */
36
- get weixinToken(): string;
37
- /**
38
- * 设置 Weixin Token,用于后续请求自动置换 Gamer Token
39
- *
40
- * 仅仅在微信小程序模式下有效
41
- */
42
- set weixinToken(value: string);
43
- /** 读取自动置换的 gamerToken */
44
- get gamerToken(): string;
45
- /**
46
- * 直接写入 Gamer Token,并更新缓存
47
- */
48
- set gamerToken(value: string);
49
- /**
50
- * 退出登录,销毁相关 Token
51
- */
52
- logout(): void;
53
- /**
54
- * 用世游通行证统一登录能力签发的 ID Token / Weixin Token,自动置换 Gamer Token,成功后会自动设置后续 Request Headers
55
- *
56
- * [世游通行证统一登录](https://kdocs.cn/l/cf2mO2uRLqh9?linkname=FJXYgqvLHs)
57
- *
58
- * [世游通行证统一登录 - Web 站点](https://365.kdocs.cn/l/cf57sp1qLlZh)
59
- *
60
- * [世游通行证统一登录 - 微信小程序](https://365.kdocs.cn/l/ccHVuUs0UsZs)
61
- *
62
- * - 此方法通常不需要手动调用,在需要登录的接口调用时会自动执行
63
- * - 为了提高页面执行速度,可以在设置 Token 后立即调用 autoLogin
64
- *
65
- * 🔕请求静默进行,无消息提示
66
- *
67
- * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ReeJpWraRO
68
- */
69
- autoLogin(): Promise<boolean>;
70
- /**
71
- * 获取当前登录用户的 Session 的信息
72
- *
73
- * 🔕请求静默进行,无消息提示
74
- *
75
- * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OdGVCdQxEu
76
- */
77
- getSession(): Promise<import("./token.define").GamerSession | null>;
78
- /**
79
- * 实名认证
80
- *
81
- * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=kZYnwX6RcF
82
- */
83
- authRealName(option: {
84
- /** 用户输入的真实姓名。明文或者密文 */
85
- real_name: string;
86
- /** 用户输入的身份证号码。明文或者密文 */
87
- identity_card: string;
88
- /** 预留参数,是否加密 real_name 和 identity_card,加密的密钥应当使用 api 服务的 ECDSA Public Key */
89
- encrypted?: boolean;
90
- }): Promise<import("./token.define").GamerSession | null>;
27
+ NetRequest: NetRequestFactory,
28
+ );
29
+ private loadGamerTokenCache;
30
+ /** 当前是否为登录状态,即是否拥有 gamerToken */
31
+ get isLoggedIn(): boolean;
32
+ /** 读取已经设置的 idToken */
33
+ get idToken(): string;
34
+ /** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
35
+ set idToken(value: string);
36
+ /** 读取设置 weixinToken */
37
+ get weixinToken(): string;
38
+ /**
39
+ * 设置 Weixin Token,用于后续请求自动置换 Gamer Token
40
+ *
41
+ * 仅仅在微信小程序模式下有效
42
+ */
43
+ set weixinToken(value: string);
44
+ /** 读取自动置换的 gamerToken */
45
+ get gamerToken(): string;
46
+ /**
47
+ * 直接写入 Gamer Token,并更新缓存
48
+ */
49
+ set gamerToken(value: string);
50
+ /**
51
+ * 退出登录,销毁相关 Token
52
+ */
53
+ logout(): void;
54
+ /**
55
+ * 用世游通行证统一登录能力签发的 ID Token / Weixin Token,自动置换 Gamer Token,成功后会自动设置后续 Request Headers
56
+ *
57
+ * [世游通行证统一登录](https://kdocs.cn/l/cf2mO2uRLqh9?linkname=FJXYgqvLHs)
58
+ *
59
+ * [世游通行证统一登录 - Web 站点](https://365.kdocs.cn/l/cf57sp1qLlZh)
60
+ *
61
+ * [世游通行证统一登录 - 微信小程序](https://365.kdocs.cn/l/ccHVuUs0UsZs)
62
+ *
63
+ * - 此方法通常不需要手动调用,在需要登录的接口调用时会自动执行
64
+ * - 为了提高页面执行速度,可以在设置 Token 后立即调用 autoLogin
65
+ *
66
+ * 🔕请求静默进行,无消息提示
67
+ *
68
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ReeJpWraRO
69
+ */
70
+ autoLogin(): Promise<boolean>;
71
+ /**
72
+ * 获取当前登录用户的 Session 的信息
73
+ *
74
+ * 🔕请求静默进行,无消息提示
75
+ *
76
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OdGVCdQxEu
77
+ */
78
+ getSession(): Promise<import("./token.define").GamerSession | null>;
79
+ /**
80
+ * 实名认证
81
+ *
82
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=kZYnwX6RcF
83
+ */
84
+ authRealName(option: {
85
+ /** 用户输入的真实姓名。明文或者密文 */
86
+ real_name: string;
87
+ /** 用户输入的身份证号码。明文或者密文 */
88
+ identity_card: string;
89
+ /** 预留参数,是否加密 real_name 和 identity_card,加密的密钥应当使用 api 服务的 ECDSA Public Key */
90
+ encrypted?: boolean;
91
+ }): Promise<import("./token.define").GamerSession | null>;
91
92
  }
@@ -1,96 +1,104 @@
1
- import { type WeixinWebLoginErrorCode } from "./weixin.define";
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
- 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
- /**
24
- * 检查缓存中的登录数据
25
- *
26
- * 如果没有缓存或缓存数据错误,则需要调用 [wx.login](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html) 后调用 login 方法
27
- *
28
- * 也可以直接调用 login 方法,并传入 weixin code 的读取函数
29
- */
30
- getLoginCache(): Promise<import("./weixin.define").WeixinLoginResponse | null>;
31
- /**
32
- * 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
33
- *
34
- * 使用场景:
35
- *
36
- * - 小程序的任意页面打开后应该优先调用此方法以获取登录状态
37
- *
38
- * 注意:
39
- *
40
- * - 登录成功后会将登录信息缓存到本地,重复或并发调用不会引起任何副作用。
41
- * - 由于小程序的存储是以用户维度隔离的,每个微信用户在每个小程序下只要成功调用一次此 API 就会缓存请求结果。
42
- * - 微信公众号网页授权请使用 webLogin 方法
43
- *
44
- * 🔕请求静默进行,无消息提示
45
- *
46
- * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=GwIZ0givCb
47
- */
48
- login(): Promise<import("./weixin.define").WeixinLoginResponse | {
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
+ /**
24
+ * 检查缓存中的登录数据
25
+ *
26
+ * 如果没有缓存或缓存数据错误,则需要调用 [wx.login](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html) 后调用 login 方法
27
+ *
28
+ * 也可以直接调用 login 方法,并传入 weixin code 的读取函数
29
+ */
30
+ getLoginCache(): Promise<import("./weixin.define").WeixinLoginResponse | null>;
31
+ /**
32
+ * 小程序页面微信静默登录,获取 weixinToken / open_id / union_id。
33
+ *
34
+ * 使用场景:
35
+ *
36
+ * - 小程序的任意页面打开后应该优先调用此方法以获取登录状态
37
+ *
38
+ * 注意:
39
+ *
40
+ * - 登录成功后会将登录信息缓存到本地,重复或并发调用不会引起任何副作用。
41
+ * - 由于小程序的存储是以用户维度隔离的,每个微信用户在每个小程序下只要成功调用一次此 API 就会缓存请求结果。
42
+ * - 微信公众号网页授权请使用 webLogin 方法
43
+ *
44
+ * 🔕请求静默进行,无消息提示
45
+ *
46
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=GwIZ0givCb
47
+ */
48
+ login(): Promise<
49
+ | import("./weixin.define").WeixinLoginResponse
50
+ | {
49
51
  error: RequestInternalError | "invalid_weixin_appid" | "invalid_weixin_code";
50
- }>;
51
- /**
52
- * 在微信内嵌网页中调用微信公众号授权登录【暂未启用】
53
- *
54
- * 注意:
55
- *
56
- * - 登录回调地址强制是当前页面,包括 location search 和 location hash 部分
57
- * - 登录跳转返回 code 后,会将 code url 中删除以防止 code 泄露,如需设置分享则需要在此方法执行完毕之后
58
- *
59
- * 官方参考资料:
60
- *
61
- * - [微信网页开发 / 网页授权](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html)
62
- *
63
- * @param scope - 网页授权作用域
64
- * - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取 union_id 则需要 snsapi_userinfo
65
- * - snsapi_userinfo 【默认】弹出授权页面,可拿到 openidunion_id、昵称、头像等信息,但用户也可能会拒绝授权
66
- */
67
- webLogin(scope?: "snsapi_base" | "snsapi_userinfo"): Promise<import("./weixin.define").WeixinLoginResponse | {
52
+ }
53
+ >;
54
+ /**
55
+ * 在微信内嵌网页中调用微信公众号授权登录【暂未启用】
56
+ *
57
+ * 注意:
58
+ *
59
+ * - 登录回调地址强制是当前页面,包括 location search location hash 部分
60
+ * - 登录跳转返回 code 后,会将 code 从 url 中删除以防止 code 泄露,如需设置分享则需要在此方法执行完毕之后
61
+ *
62
+ * 官方参考资料:
63
+ *
64
+ * - [微信网页开发 / 网页授权](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html)
65
+ *
66
+ * @param scope - 网页授权作用域
67
+ * - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取 union_id 则需要 snsapi_userinfo
68
+ * - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、union_id、昵称、头像等信息,但用户也可能会拒绝授权
69
+ */
70
+ webLogin(scope?: "snsapi_base" | "snsapi_userinfo"): Promise<
71
+ | import("./weixin.define").WeixinLoginResponse
72
+ | {
68
73
  error: WeixinWebLoginErrorCode;
69
- } | {
74
+ }
75
+ | {
70
76
  error: RequestInternalError | "invalid_weixin_appid" | "invalid_weixin_code";
71
- } | undefined>;
72
- /**
73
- * 关联游戏账号,无返回值,全程静默
74
- *
75
- * 用于从游戏内跳转至小程序时,将微信用户身份和游戏内身份关联起来,使得后续的企业微信客服流程能够知道该微信用户在游戏内的身份。
76
- *
77
- * 🔕请求静默进行,无消息提示
78
- *
79
- * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ci73N833Mk
80
- *
81
- * @param weixinToken 调用 login 后,得到的 weixinToken,如果 weixinToken 为空则跳过不处理
82
- * @param gameCode 从游戏内跳转至小程序时,通过请求参数 query 携带的 game_code,如果值为空则跳过不处理
83
- */
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
- appid: string;
92
- nonceStr: string;
93
- timestamp: number;
94
- signature: string;
95
- } | null>;
77
+ }
78
+ | undefined
79
+ >;
80
+ /**
81
+ * 关联游戏账号,无返回值,全程静默
82
+ *
83
+ * 用于从游戏内跳转至小程序时,将微信用户身份和游戏内身份关联起来,使得后续的企业微信客服流程能够知道该微信用户在游戏内的身份。
84
+ *
85
+ * 🔕请求静默进行,无消息提示
86
+ *
87
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ci73N833Mk
88
+ *
89
+ * @param weixinToken 调用 login 后,得到的 weixinToken,如果 weixinToken 为空则跳过不处理
90
+ * @param gameCode 从游戏内跳转至小程序时,通过请求参数 query 携带的 game_code,如果值为空则跳过不处理
91
+ */
92
+ linkPlayer(weixinToken: string, gameCode: string): Promise<void>;
93
+ /**
94
+ * 获取集成 JSSDK 所需的签名信息
95
+ *
96
+ * https://kdocs.cn/l/cf2mO2uRLqh9?linkname=CuWOqxr9Ue
97
+ */
98
+ getJSSDKConfig(): Promise<{
99
+ appid: string;
100
+ nonceStr: string;
101
+ timestamp: number;
102
+ signature: string;
103
+ } | null>;
96
104
  }