@maoyugames/phaser-framework 1.0.10 → 1.0.11

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.
@@ -10,16 +10,26 @@ function requireTT(capability) {
10
10
  if (!hasTT()) throw new PlatformUnsupportedError("tiktok", capability);
11
11
  }
12
12
  var TikTokAuth = class {
13
+ // TikTok H5 SDK 实测(2026-05-28 反编译 connect.tiktok-minis.com/game/sdk.js)
14
+ // **没有 game.login 也没有 game.getUserInfo**——这两个 API 是抖音(国内)小游戏的协议,
15
+ // TikTok 海外走 OAuth code 流程:authorizeOpenContext({get_status_only:false}) 弹授权页拿 code,
16
+ // 后端用 code + client_secret 调 open.tiktokapis.com/v2/oauth/token/ + /v2/user/info/ 拿 user info。
13
17
  async login() {
14
18
  requireTT("auth.login");
15
- const res = await TTMinis.game.login();
16
- return { code: res.code, openId: res.openId, raw: res };
19
+ let res = await TTMinis.game.authorizeOpenContext({ get_status_only: true });
20
+ if (!res?.is_success || !res?.code) {
21
+ res = await TTMinis.game.authorizeOpenContext({ get_status_only: false });
22
+ }
23
+ if (!res?.is_success || !res?.code) {
24
+ const e = res?.error;
25
+ throw new Error(`TikTok authorize failed: ${e?.error_msg ?? "unknown"} (code=${e?.error_code ?? "NA"})`);
26
+ }
27
+ return { code: res.code, raw: res };
17
28
  }
29
+ // TikTok H5 SDK 没有客户端 user info API。nickname/avatar 必须由后端用 access_token 调
30
+ // /v2/user/info/ 取(scope=user.info.basic),客户端拿到的 user 已含这些字段。
18
31
  async getProfile() {
19
- requireTT("auth.getProfile");
20
- const info = await TTMinis.game.getUserInfo();
21
- if (!info) return null;
22
- return { nickname: info.nickName ?? "", avatarUrl: info.avatarUrl ?? "" };
32
+ return null;
23
33
  }
24
34
  };
25
35
  var TikTokAds = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maoyugames/phaser-framework",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "多平台 Phaser 游戏框架:业务/底层分离,HTTP/WebSocket/KCP,Web/TikTok/微信/Facebook/App 隔离打包",
5
5
  "type": "module",
6
6
  "license": "MIT",