@seayoo-io/combo-sdk-node 1.4.1 → 1.4.3
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 +3 -3
- package/dist/const.d.ts +21 -5
- package/dist/index.cjs +50 -2
- package/dist/index.js +50 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -359,7 +359,7 @@ interface IdentityPayload {
|
|
|
359
359
|
```js
|
|
360
360
|
// verifyAdToken 对 AdToken 进行验证
|
|
361
361
|
// 返回 AdPayload 数据,如果解析出错则返回 Error 对象
|
|
362
|
-
const adInfo =
|
|
362
|
+
const adInfo = verifier.verifyAdToken(token)
|
|
363
363
|
if(result instanceof Error) {
|
|
364
364
|
console.error(result.message)
|
|
365
365
|
} else {
|
|
@@ -416,7 +416,7 @@ function gmCommandHandler(command, args, requestId, idempotencyKey, version, ori
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
/** GM 预设错误类型枚举 */
|
|
419
|
-
|
|
419
|
+
enum GMError {
|
|
420
420
|
/** 请求中的 HTTP method 不正确,没有按照预期使用 POST。*/
|
|
421
421
|
InvalidHttpMethod = "invalid_http_method",
|
|
422
422
|
/** 请求中的 Content-Type 不是 application/json。*/
|
|
@@ -519,7 +519,7 @@ import { getGMHandlerForKoa } from "@seayoo-io/combo-sdk-node"
|
|
|
519
519
|
const koaHandler = getGMHandlerForKoa(config, gmCommandHandler, storeHelper)
|
|
520
520
|
app.post("/path/to/your/gm/url", koaHandler)
|
|
521
521
|
|
|
522
|
-
// 方式 3. 使用
|
|
522
|
+
// 方式 3. 使用 express / koa 的中间件,推荐
|
|
523
523
|
import { getGMMiddlewareForExpress } from "@seayoo-io/combo-sdk-node"
|
|
524
524
|
const gmMiddleware = getGMMiddlewareForExpress("/path/to/your/gm/url", config, gmCommandHandler, storeHelper);
|
|
525
525
|
app.use(gmMiddleware);
|
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.
|
|
4
|
+
export declare const SDKVersion = "1.4.3";
|
|
5
5
|
/**
|
|
6
6
|
* 世游支持的服务端点列表
|
|
7
7
|
*/
|
|
@@ -21,10 +21,16 @@ export declare enum Platform {
|
|
|
21
21
|
Windows = "windows",
|
|
22
22
|
/** macOS 桌面平台 */
|
|
23
23
|
macOS = "macos",
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* 微信小游戏
|
|
26
|
+
*
|
|
27
|
+
* @deprecated 已被 Platform.WebGL 取代
|
|
28
|
+
*/
|
|
25
29
|
Weixin = "weixin",
|
|
26
30
|
/** WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏 */
|
|
27
|
-
WebGL = "webgl"
|
|
31
|
+
WebGL = "webgl",
|
|
32
|
+
/** 华为的 HarmonyOS NEXT 鸿蒙应用开发平台 */
|
|
33
|
+
HarmonyOS = "harmonyos"
|
|
28
34
|
}
|
|
29
35
|
/** 支持的登录提供方 */
|
|
30
36
|
export declare enum IdP {
|
|
@@ -71,10 +77,20 @@ export declare enum IdP {
|
|
|
71
77
|
/** 酷派 */
|
|
72
78
|
Coolpad = "coolpad",
|
|
73
79
|
/** 努比亚 */
|
|
74
|
-
Nubia = "nubia"
|
|
80
|
+
Nubia = "nubia",
|
|
81
|
+
/** 绝峰游戏 */
|
|
82
|
+
Juefeng = "juefeng",
|
|
83
|
+
/** 魅拓游戏 */
|
|
84
|
+
Meituo = "meituo",
|
|
85
|
+
/** 微信小游戏 */
|
|
86
|
+
MinigameWeixin = "minigame_weixin",
|
|
87
|
+
/** MuMu 模拟器 */
|
|
88
|
+
Mumu = "mumu",
|
|
89
|
+
/** 虎牙游戏 */
|
|
90
|
+
Huya = "huya"
|
|
75
91
|
}
|
|
76
92
|
/** GM 错误类型枚举 */
|
|
77
|
-
export declare
|
|
93
|
+
export declare enum GMError {
|
|
78
94
|
/** 请求中的 HTTP method 不正确,没有按照预期使用 POST。*/
|
|
79
95
|
InvalidHttpMethod = "invalid_http_method",
|
|
80
96
|
/** 请求中的 Content-Type 不是 application/json。*/
|
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.4.
|
|
15
|
+
const SDKVersion = "1.4.3";
|
|
16
16
|
/**
|
|
17
17
|
* 世游支持的服务端点列表
|
|
18
18
|
*/
|
|
@@ -34,10 +34,16 @@ exports.Platform = void 0;
|
|
|
34
34
|
Platform["Windows"] = "windows";
|
|
35
35
|
/** macOS 桌面平台 */
|
|
36
36
|
Platform["macOS"] = "macos";
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* 微信小游戏
|
|
39
|
+
*
|
|
40
|
+
* @deprecated 已被 Platform.WebGL 取代
|
|
41
|
+
*/
|
|
38
42
|
Platform["Weixin"] = "weixin";
|
|
39
43
|
/** WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏 */
|
|
40
44
|
Platform["WebGL"] = "webgl";
|
|
45
|
+
/** 华为的 HarmonyOS NEXT 鸿蒙应用开发平台 */
|
|
46
|
+
Platform["HarmonyOS"] = "harmonyos";
|
|
41
47
|
})(exports.Platform || (exports.Platform = {}));
|
|
42
48
|
/** 支持的登录提供方 */
|
|
43
49
|
exports.IdP = void 0;
|
|
@@ -86,7 +92,49 @@ exports.IdP = void 0;
|
|
|
86
92
|
IdP["Coolpad"] = "coolpad";
|
|
87
93
|
/** 努比亚 */
|
|
88
94
|
IdP["Nubia"] = "nubia";
|
|
95
|
+
/** 绝峰游戏 */
|
|
96
|
+
IdP["Juefeng"] = "juefeng";
|
|
97
|
+
/** 魅拓游戏 */
|
|
98
|
+
IdP["Meituo"] = "meituo";
|
|
99
|
+
/** 微信小游戏 */
|
|
100
|
+
IdP["MinigameWeixin"] = "minigame_weixin";
|
|
101
|
+
/** MuMu 模拟器 */
|
|
102
|
+
IdP["Mumu"] = "mumu";
|
|
103
|
+
/** 虎牙游戏 */
|
|
104
|
+
IdP["Huya"] = "huya";
|
|
89
105
|
})(exports.IdP || (exports.IdP = {}));
|
|
106
|
+
/** GM 错误类型枚举 */
|
|
107
|
+
var GMError;
|
|
108
|
+
(function (GMError) {
|
|
109
|
+
/** 请求中的 HTTP method 不正确,没有按照预期使用 POST。*/
|
|
110
|
+
GMError["InvalidHttpMethod"] = "invalid_http_method";
|
|
111
|
+
/** 请求中的 Content-Type 不是 application/json。*/
|
|
112
|
+
GMError["InvalidContentType"] = "invalid_content_type";
|
|
113
|
+
/** 对 HTTP 请求的签名验证不通过。这意味着 HTTP 请求不可信。 */
|
|
114
|
+
GMError["InvalidSignature"] = "invalid_signature";
|
|
115
|
+
/** 请求的结构不正确。例如,缺少必要的字段,或字段类型不正确。 */
|
|
116
|
+
GMError["InvalidRequest"] = "invalid_request";
|
|
117
|
+
/** 游戏侧不认识请求中的 GM 命令。 */
|
|
118
|
+
GMError["InvalidCommand"] = "invalid_command";
|
|
119
|
+
/** GM 命令发送频率过高,被游戏侧限流,命令未被处理。 */
|
|
120
|
+
GMError["ThrottlingError"] = "throttling_error";
|
|
121
|
+
/** 幂等处理重试请求时,idempotency_key 所对应的原始请求尚未处理完毕。*/
|
|
122
|
+
GMError["IdempotencyConflict"] = "idempotency_conflict";
|
|
123
|
+
/** 幂等处理重试请求时,请求内容和 idempotency_key 所对应的原始请求内容不一致。*/
|
|
124
|
+
GMError["IdempotencyMismatch"] = "idempotency_mismatch";
|
|
125
|
+
/** GM 命令的参数不正确。例如,参数缺少必要的字段,或参数的字段类型不正确。 */
|
|
126
|
+
GMError["InvalidArgs"] = "invalid_args";
|
|
127
|
+
/** 游戏当前处于停服维护状态,无法处理收到的 GM 命令。*/
|
|
128
|
+
GMError["MaintenanceError"] = "maintenance_error";
|
|
129
|
+
/** 网络通信错误。 */
|
|
130
|
+
GMError["NetworkError"] = "network_error";
|
|
131
|
+
/** 数据库操作异常导致 GM 命令执行失败。 */
|
|
132
|
+
GMError["DatabaseError"] = "database_error";
|
|
133
|
+
/** GM 命令处理超时。 */
|
|
134
|
+
GMError["TimeoutError"] = "timeout_error";
|
|
135
|
+
/** 处理 GM 命令时内部出错。可作为兜底的通用错误类型。*/
|
|
136
|
+
GMError["InternalError"] = "internal_error";
|
|
137
|
+
})(GMError || (GMError = {}));
|
|
90
138
|
|
|
91
139
|
function getUserAgent(game) {
|
|
92
140
|
return `${SDKName}/${SDKVersion} game/${game} node/${process.version} os/${os.platform()} arch/${os.arch()}`;
|
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.4.
|
|
10
|
+
const SDKVersion = "1.4.3";
|
|
11
11
|
/**
|
|
12
12
|
* 世游支持的服务端点列表
|
|
13
13
|
*/
|
|
@@ -29,10 +29,16 @@ var Platform;
|
|
|
29
29
|
Platform["Windows"] = "windows";
|
|
30
30
|
/** macOS 桌面平台 */
|
|
31
31
|
Platform["macOS"] = "macos";
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* 微信小游戏
|
|
34
|
+
*
|
|
35
|
+
* @deprecated 已被 Platform.WebGL 取代
|
|
36
|
+
*/
|
|
33
37
|
Platform["Weixin"] = "weixin";
|
|
34
38
|
/** WebGL 平台,包括微信、抖音等小游戏,以及 HTML5 网页游戏 */
|
|
35
39
|
Platform["WebGL"] = "webgl";
|
|
40
|
+
/** 华为的 HarmonyOS NEXT 鸿蒙应用开发平台 */
|
|
41
|
+
Platform["HarmonyOS"] = "harmonyos";
|
|
36
42
|
})(Platform || (Platform = {}));
|
|
37
43
|
/** 支持的登录提供方 */
|
|
38
44
|
var IdP;
|
|
@@ -81,7 +87,49 @@ var IdP;
|
|
|
81
87
|
IdP["Coolpad"] = "coolpad";
|
|
82
88
|
/** 努比亚 */
|
|
83
89
|
IdP["Nubia"] = "nubia";
|
|
90
|
+
/** 绝峰游戏 */
|
|
91
|
+
IdP["Juefeng"] = "juefeng";
|
|
92
|
+
/** 魅拓游戏 */
|
|
93
|
+
IdP["Meituo"] = "meituo";
|
|
94
|
+
/** 微信小游戏 */
|
|
95
|
+
IdP["MinigameWeixin"] = "minigame_weixin";
|
|
96
|
+
/** MuMu 模拟器 */
|
|
97
|
+
IdP["Mumu"] = "mumu";
|
|
98
|
+
/** 虎牙游戏 */
|
|
99
|
+
IdP["Huya"] = "huya";
|
|
84
100
|
})(IdP || (IdP = {}));
|
|
101
|
+
/** GM 错误类型枚举 */
|
|
102
|
+
var GMError;
|
|
103
|
+
(function (GMError) {
|
|
104
|
+
/** 请求中的 HTTP method 不正确,没有按照预期使用 POST。*/
|
|
105
|
+
GMError["InvalidHttpMethod"] = "invalid_http_method";
|
|
106
|
+
/** 请求中的 Content-Type 不是 application/json。*/
|
|
107
|
+
GMError["InvalidContentType"] = "invalid_content_type";
|
|
108
|
+
/** 对 HTTP 请求的签名验证不通过。这意味着 HTTP 请求不可信。 */
|
|
109
|
+
GMError["InvalidSignature"] = "invalid_signature";
|
|
110
|
+
/** 请求的结构不正确。例如,缺少必要的字段,或字段类型不正确。 */
|
|
111
|
+
GMError["InvalidRequest"] = "invalid_request";
|
|
112
|
+
/** 游戏侧不认识请求中的 GM 命令。 */
|
|
113
|
+
GMError["InvalidCommand"] = "invalid_command";
|
|
114
|
+
/** GM 命令发送频率过高,被游戏侧限流,命令未被处理。 */
|
|
115
|
+
GMError["ThrottlingError"] = "throttling_error";
|
|
116
|
+
/** 幂等处理重试请求时,idempotency_key 所对应的原始请求尚未处理完毕。*/
|
|
117
|
+
GMError["IdempotencyConflict"] = "idempotency_conflict";
|
|
118
|
+
/** 幂等处理重试请求时,请求内容和 idempotency_key 所对应的原始请求内容不一致。*/
|
|
119
|
+
GMError["IdempotencyMismatch"] = "idempotency_mismatch";
|
|
120
|
+
/** GM 命令的参数不正确。例如,参数缺少必要的字段,或参数的字段类型不正确。 */
|
|
121
|
+
GMError["InvalidArgs"] = "invalid_args";
|
|
122
|
+
/** 游戏当前处于停服维护状态,无法处理收到的 GM 命令。*/
|
|
123
|
+
GMError["MaintenanceError"] = "maintenance_error";
|
|
124
|
+
/** 网络通信错误。 */
|
|
125
|
+
GMError["NetworkError"] = "network_error";
|
|
126
|
+
/** 数据库操作异常导致 GM 命令执行失败。 */
|
|
127
|
+
GMError["DatabaseError"] = "database_error";
|
|
128
|
+
/** GM 命令处理超时。 */
|
|
129
|
+
GMError["TimeoutError"] = "timeout_error";
|
|
130
|
+
/** 处理 GM 命令时内部出错。可作为兜底的通用错误类型。*/
|
|
131
|
+
GMError["InternalError"] = "internal_error";
|
|
132
|
+
})(GMError || (GMError = {}));
|
|
85
133
|
|
|
86
134
|
function getUserAgent(game) {
|
|
87
135
|
return `${SDKName}/${SDKVersion} game/${game} node/${process.version} os/${platform()} arch/${arch()}`;
|