@seayoo-io/combo-sdk-node 1.4.4 → 1.5.0
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 +25 -11
- package/dist/const.d.ts +1 -7
- package/dist/index.cjs +5 -10
- package/dist/index.js +5 -10
- package/dist/verify/id.d.ts +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,10 +108,6 @@ interface OrderMetaData {
|
|
|
108
108
|
role_name?: string
|
|
109
109
|
/** 游戏角色的等级 */
|
|
110
110
|
role_level?: number
|
|
111
|
-
/** 微信小游戏的 App ID, 微信小游戏的 iOS 支付场景必须传入 */
|
|
112
|
-
weixin_appid?: string
|
|
113
|
-
/** 微信小游戏的玩家 OpenID, 微信小游戏的 iOS 支付场景必须传入 */
|
|
114
|
-
weixin_openid?: string
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
interface CreateOrderResponse {
|
|
@@ -298,9 +294,8 @@ const identityPayload = verifier.verifyIdentityToken(token)
|
|
|
298
294
|
if(identityPayload instanceof Error) {
|
|
299
295
|
console.error(result.message)
|
|
300
296
|
} else {
|
|
301
|
-
//
|
|
302
|
-
if(identityPayload.idp === IdP.
|
|
303
|
-
// 微信登录会提供 weixin_unionid
|
|
297
|
+
// WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏
|
|
298
|
+
if(identityPayload.idp === IdP.WebGL) {
|
|
304
299
|
// do something
|
|
305
300
|
}
|
|
306
301
|
// 游客登录判断
|
|
@@ -331,11 +326,11 @@ interface IdentityPayload {
|
|
|
331
326
|
/** external_name 是用户在外部 IdP 中的名称,通常是用户的昵称 */
|
|
332
327
|
external_name: string
|
|
333
328
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
329
|
+
* weixin_session_key 是用户在微信小游戏登录时,从微信服务端获得的会话密钥 session_key。
|
|
330
|
+
* 该字段在 Identity Token 中以 AES-256-GCM 加密存储,SDK 会自动解密。
|
|
331
|
+
* weixin_session_key 只在 IdP 为 MinigameWeixin 时才会有值。
|
|
337
332
|
*/
|
|
338
|
-
|
|
333
|
+
weixin_session_key: string
|
|
339
334
|
/**
|
|
340
335
|
* device_id 是用户在登录时使用的设备的唯一 ID。
|
|
341
336
|
*/
|
|
@@ -351,6 +346,25 @@ interface IdentityPayload {
|
|
|
351
346
|
* 注意:Variant 只在客户端是分包时才会有值。当客户端不是分包的情况下,variant 为空字符串。
|
|
352
347
|
*/
|
|
353
348
|
variant: string
|
|
349
|
+
/**
|
|
350
|
+
* age 是根据用户的实名认证信息得到的年龄。
|
|
351
|
+
*
|
|
352
|
+
* 0 表示未知。
|
|
353
|
+
*
|
|
354
|
+
* 在某些特殊场景下,游戏侧可用 age 来自行处理防沉迷。
|
|
355
|
+
*
|
|
356
|
+
* 注意:age 不保证返回精确的年龄信息,仅保证用于防沉迷处理时的准确度够用。
|
|
357
|
+
*
|
|
358
|
+
* 例如:
|
|
359
|
+
*
|
|
360
|
+
* 当某个用户真实年龄为 35 岁时,age 可能返回 18,
|
|
361
|
+
* 当某个用户真实年龄为 17 岁时,age 可能返回 16。
|
|
362
|
+
*/
|
|
363
|
+
age: number
|
|
364
|
+
/**
|
|
365
|
+
* reg_time 是用户 ID(Combo ID)在的注册时间。Unix timestamp in seconds。
|
|
366
|
+
*/
|
|
367
|
+
reg_time: number
|
|
354
368
|
}
|
|
355
369
|
```
|
|
356
370
|
|
package/dist/const.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** SDK 名称 */
|
|
2
2
|
export declare const SDKName = "combo-sdk-node";
|
|
3
3
|
/** SDK 版本,在编译前会被动态替换 */
|
|
4
|
-
export declare const SDKVersion = "1.
|
|
4
|
+
export declare const SDKVersion = "1.5.0";
|
|
5
5
|
/**
|
|
6
6
|
* 世游支持的服务端点列表
|
|
7
7
|
*/
|
|
@@ -21,12 +21,6 @@ export declare enum Platform {
|
|
|
21
21
|
Windows = "windows",
|
|
22
22
|
/** macOS 桌面平台 */
|
|
23
23
|
macOS = "macos",
|
|
24
|
-
/**
|
|
25
|
-
* 微信小游戏
|
|
26
|
-
*
|
|
27
|
-
* @deprecated 已被 Platform.WebGL 取代
|
|
28
|
-
*/
|
|
29
|
-
Weixin = "weixin",
|
|
30
24
|
/** WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏 */
|
|
31
25
|
WebGL = "webgl",
|
|
32
26
|
/** 华为的 HarmonyOS NEXT 鸿蒙应用开发平台 */
|
package/dist/index.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
|
12
12
|
/** SDK 名称 */
|
|
13
13
|
const SDKName = "combo-sdk-node";
|
|
14
14
|
/** SDK 版本,在编译前会被动态替换 */
|
|
15
|
-
const SDKVersion = "1.
|
|
15
|
+
const SDKVersion = "1.5.0";
|
|
16
16
|
/**
|
|
17
17
|
* 世游支持的服务端点列表
|
|
18
18
|
*/
|
|
@@ -34,12 +34,6 @@ exports.Platform = void 0;
|
|
|
34
34
|
Platform["Windows"] = "windows";
|
|
35
35
|
/** macOS 桌面平台 */
|
|
36
36
|
Platform["macOS"] = "macos";
|
|
37
|
-
/**
|
|
38
|
-
* 微信小游戏
|
|
39
|
-
*
|
|
40
|
-
* @deprecated 已被 Platform.WebGL 取代
|
|
41
|
-
*/
|
|
42
|
-
Platform["Weixin"] = "weixin";
|
|
43
37
|
/** WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏 */
|
|
44
38
|
Platform["WebGL"] = "webgl";
|
|
45
39
|
/** 华为的 HarmonyOS NEXT 鸿蒙应用开发平台 */
|
|
@@ -1167,7 +1161,7 @@ function isCreateOrderResponse(data) {
|
|
|
1167
1161
|
}
|
|
1168
1162
|
|
|
1169
1163
|
function isIdentityJwtPayload(payload) {
|
|
1170
|
-
return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "device_id" in payload && "external_id" in payload && "external_name" in payload;
|
|
1164
|
+
return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "device_id" in payload && "external_id" in payload && "external_name" in payload && "reg_time" in payload;
|
|
1171
1165
|
}
|
|
1172
1166
|
|
|
1173
1167
|
function isAdJwtPayload(payload) {
|
|
@@ -1215,11 +1209,12 @@ class TokenVerifier {
|
|
|
1215
1209
|
idp: payload.idp,
|
|
1216
1210
|
external_id: payload.external_id,
|
|
1217
1211
|
external_name: payload.external_name,
|
|
1218
|
-
|
|
1212
|
+
weixin_session_key: payload.weixin_session_key || "",
|
|
1219
1213
|
distro: payload.distro || "",
|
|
1220
1214
|
variant: payload.variant || "",
|
|
1221
1215
|
device_id: payload.device_id || "",
|
|
1222
|
-
age: payload.age || 0
|
|
1216
|
+
age: payload.age || 0,
|
|
1217
|
+
reg_time: payload.reg_time || 0
|
|
1223
1218
|
};
|
|
1224
1219
|
} catch (error) {
|
|
1225
1220
|
return new Error(`IdentityToken 验证失败: ${error instanceof Error ? error.message : String(error)}`);
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { verify } from 'jsonwebtoken';
|
|
|
7
7
|
/** SDK 名称 */
|
|
8
8
|
const SDKName = "combo-sdk-node";
|
|
9
9
|
/** SDK 版本,在编译前会被动态替换 */
|
|
10
|
-
const SDKVersion = "1.
|
|
10
|
+
const SDKVersion = "1.5.0";
|
|
11
11
|
/**
|
|
12
12
|
* 世游支持的服务端点列表
|
|
13
13
|
*/
|
|
@@ -29,12 +29,6 @@ var Platform;
|
|
|
29
29
|
Platform["Windows"] = "windows";
|
|
30
30
|
/** macOS 桌面平台 */
|
|
31
31
|
Platform["macOS"] = "macos";
|
|
32
|
-
/**
|
|
33
|
-
* 微信小游戏
|
|
34
|
-
*
|
|
35
|
-
* @deprecated 已被 Platform.WebGL 取代
|
|
36
|
-
*/
|
|
37
|
-
Platform["Weixin"] = "weixin";
|
|
38
32
|
/** WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏 */
|
|
39
33
|
Platform["WebGL"] = "webgl";
|
|
40
34
|
/** 华为的 HarmonyOS NEXT 鸿蒙应用开发平台 */
|
|
@@ -1162,7 +1156,7 @@ function isCreateOrderResponse(data) {
|
|
|
1162
1156
|
}
|
|
1163
1157
|
|
|
1164
1158
|
function isIdentityJwtPayload(payload) {
|
|
1165
|
-
return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "device_id" in payload && "external_id" in payload && "external_name" in payload;
|
|
1159
|
+
return isObject(payload) && "sub" in payload && "iss" in payload && "scope" in payload && "idp" in payload && "device_id" in payload && "external_id" in payload && "external_name" in payload && "reg_time" in payload;
|
|
1166
1160
|
}
|
|
1167
1161
|
|
|
1168
1162
|
function isAdJwtPayload(payload) {
|
|
@@ -1210,11 +1204,12 @@ class TokenVerifier {
|
|
|
1210
1204
|
idp: payload.idp,
|
|
1211
1205
|
external_id: payload.external_id,
|
|
1212
1206
|
external_name: payload.external_name,
|
|
1213
|
-
|
|
1207
|
+
weixin_session_key: payload.weixin_session_key || "",
|
|
1214
1208
|
distro: payload.distro || "",
|
|
1215
1209
|
variant: payload.variant || "",
|
|
1216
1210
|
device_id: payload.device_id || "",
|
|
1217
|
-
age: payload.age || 0
|
|
1211
|
+
age: payload.age || 0,
|
|
1212
|
+
reg_time: payload.reg_time || 0
|
|
1218
1213
|
};
|
|
1219
1214
|
} catch (error) {
|
|
1220
1215
|
return new Error(`IdentityToken 验证失败: ${error instanceof Error ? error.message : String(error)}`);
|
package/dist/verify/id.d.ts
CHANGED
|
@@ -30,12 +30,12 @@ export interface IdentityPayload {
|
|
|
30
30
|
*/
|
|
31
31
|
external_name: string;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* weixin_session_key 是用户在微信小游戏登录时,从微信服务端获得的会话密钥 session_key。
|
|
34
|
+
* 该字段在 Identity Token 中以 AES-256-GCM 加密存储,SDK 会自动解密。
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* weixin_session_key 只在 IdP 为 MinigameWeixin 时才会有值。
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
weixin_session_key: string;
|
|
39
39
|
/**
|
|
40
40
|
* DeviceId 是用户在登录时使用的设备的唯一 ID。
|
|
41
41
|
*/
|
|
@@ -67,6 +67,10 @@ export interface IdentityPayload {
|
|
|
67
67
|
* 当某个用户真实年龄为 17 岁时,age 可能返回 16。
|
|
68
68
|
*/
|
|
69
69
|
age: number;
|
|
70
|
+
/**
|
|
71
|
+
* reg_time 是用户 ID(Combo ID)注册时间。Unix timestamp in seconds。
|
|
72
|
+
*/
|
|
73
|
+
reg_time: number;
|
|
70
74
|
}
|
|
71
75
|
export type IdentityJwtPayload = JwtPayload & Omit<IdentityPayload, "combo_id"> & {
|
|
72
76
|
scope: string;
|