@seayoo-io/combo-sdk-node 0.1.8 → 0.1.10
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 +13 -0
- package/dist/const.d.ts +1 -1
- package/dist/index.cjs +12 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -3
- package/dist/request/inc/type.d.ts +1 -1
- package/dist/utils/index.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,12 +109,25 @@ interface CreateOrderResponse {
|
|
|
109
109
|
|
|
110
110
|
### 进入/离开游戏
|
|
111
111
|
|
|
112
|
+
下述两个接口对应的功能是**中宣部防沉迷系统**的上报功能,这里的 SessionID 是一次游戏会话的标识,也就是每次玩家进入游戏+离开游戏,算一个 Game Session。单次游戏会话的上下线动作必须使用同一个 SessionID 上报。
|
|
113
|
+
|
|
112
114
|
```js
|
|
113
115
|
// 进入游戏
|
|
114
116
|
await client.enterGame("<ComboID>", "<SessionID>");
|
|
115
117
|
|
|
116
118
|
// 离开游戏
|
|
117
119
|
await client.leaveGame("<ComboID>", "<SessionID>");
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> 注意,SessionID 不可重复使用,可以使用 SDK 提供的工具函数生成 SessionID
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
import { genSessionID } from "@seayoo-io/combo-sdk-node"
|
|
127
|
+
|
|
128
|
+
// genSessionID 接受唯一参数 comboId 作为输入,返回一个 32 位固定长度的不重复字符串
|
|
129
|
+
const userSessionID = genSessionID("1240110117740001")
|
|
130
|
+
|
|
118
131
|
```
|
|
119
132
|
|
|
120
133
|
## Notify
|
package/dist/const.d.ts
CHANGED
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 = "0.1.
|
|
15
|
+
const SDKVersion = "0.1.10";
|
|
16
16
|
/**
|
|
17
17
|
* 世游支持的服务端点列表
|
|
18
18
|
*/
|
|
@@ -349,6 +349,15 @@ async function done(res, statusCode, message) {
|
|
|
349
349
|
res.end();
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
/**
|
|
353
|
+
* 生成一个 SessionID 以用作用户上下线的上报标记
|
|
354
|
+
*/
|
|
355
|
+
function genSessionID(comboId) {
|
|
356
|
+
const ts = process.hrtime.bigint();
|
|
357
|
+
const r = Math.random() + Math.random();
|
|
358
|
+
return crypto.createHash("md5").update(`${comboId}${ts}${r}`).digest("hex").toLowerCase();
|
|
359
|
+
}
|
|
360
|
+
|
|
352
361
|
const defaultDataField = "data";
|
|
353
362
|
const defaultMessageField = "message";
|
|
354
363
|
/**
|
|
@@ -637,7 +646,7 @@ function convertBody(body) {
|
|
|
637
646
|
if (!body) {
|
|
638
647
|
return;
|
|
639
648
|
}
|
|
640
|
-
if (
|
|
649
|
+
if (typeof body === "string" || body instanceof URLSearchParams) {
|
|
641
650
|
return body;
|
|
642
651
|
}
|
|
643
652
|
return JSON.stringify(body);
|
|
@@ -1296,6 +1305,7 @@ exports.ApiClient = ApiClient;
|
|
|
1296
1305
|
exports.TokenVerifier = TokenVerifier;
|
|
1297
1306
|
exports.calcAuthorizationHeader = calcAuthorizationHeader;
|
|
1298
1307
|
exports.checkHttpAuthInfo = checkHttpAuthInfo;
|
|
1308
|
+
exports.genSessionID = genSessionID;
|
|
1299
1309
|
exports.getNotificationHandler = getNotificationHandler;
|
|
1300
1310
|
exports.getNotificationHandlerForExpress = getNotificationHandlerForExpress;
|
|
1301
1311
|
exports.getNotificationHandlerForKoa = getNotificationHandlerForKoa;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export { NotificationType } from "./notify/types";
|
|
|
9
9
|
export type { NotificationHandler } from "./notify/types";
|
|
10
10
|
export type { SDKBaseConfig } from "./utils";
|
|
11
11
|
export { Endpoint, Platform, IdP } from "./const";
|
|
12
|
-
export { parseAuthorizationHeader, calcAuthorizationHeader, checkHttpAuthInfo } from "./utils";
|
|
12
|
+
export { genSessionID, parseAuthorizationHeader, calcAuthorizationHeader, checkHttpAuthInfo } from "./utils";
|
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 = "0.1.
|
|
10
|
+
const SDKVersion = "0.1.10";
|
|
11
11
|
/**
|
|
12
12
|
* 世游支持的服务端点列表
|
|
13
13
|
*/
|
|
@@ -344,6 +344,15 @@ async function done(res, statusCode, message) {
|
|
|
344
344
|
res.end();
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
/**
|
|
348
|
+
* 生成一个 SessionID 以用作用户上下线的上报标记
|
|
349
|
+
*/
|
|
350
|
+
function genSessionID(comboId) {
|
|
351
|
+
const ts = process.hrtime.bigint();
|
|
352
|
+
const r = Math.random() + Math.random();
|
|
353
|
+
return createHash("md5").update(`${comboId}${ts}${r}`).digest("hex").toLowerCase();
|
|
354
|
+
}
|
|
355
|
+
|
|
347
356
|
const defaultDataField = "data";
|
|
348
357
|
const defaultMessageField = "message";
|
|
349
358
|
/**
|
|
@@ -632,7 +641,7 @@ function convertBody(body) {
|
|
|
632
641
|
if (!body) {
|
|
633
642
|
return;
|
|
634
643
|
}
|
|
635
|
-
if (
|
|
644
|
+
if (typeof body === "string" || body instanceof URLSearchParams) {
|
|
636
645
|
return body;
|
|
637
646
|
}
|
|
638
647
|
return JSON.stringify(body);
|
|
@@ -1287,4 +1296,4 @@ function getNotificationMiddlewareForKoa(paths, config, handler) {
|
|
|
1287
1296
|
};
|
|
1288
1297
|
}
|
|
1289
1298
|
|
|
1290
|
-
export { ApiClient, Endpoint, IdP, Platform, TokenVerifier, calcAuthorizationHeader, checkHttpAuthInfo, getNotificationHandler, getNotificationHandlerForExpress, getNotificationHandlerForKoa, getNotificationMiddlewareForExpress, getNotificationMiddlewareForKoa, parseAuthorizationHeader };
|
|
1299
|
+
export { ApiClient, Endpoint, IdP, Platform, TokenVerifier, calcAuthorizationHeader, checkHttpAuthInfo, genSessionID, getNotificationHandler, getNotificationHandlerForExpress, getNotificationHandlerForKoa, getNotificationMiddlewareForExpress, getNotificationMiddlewareForKoa, parseAuthorizationHeader };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestGlobalConfig } from "./config";
|
|
2
2
|
import type { MaybePromise, TypeGuard, TypeGuardFn } from "../../utils";
|
|
3
|
-
export type IBaseRequestBody =
|
|
3
|
+
export type IBaseRequestBody = URLSearchParams | string;
|
|
4
4
|
/** 通用网络请求工具的基本配置 */
|
|
5
5
|
export interface IBaseRequestOptions {
|
|
6
6
|
/** 网络请求方法,默认 GET */
|
package/dist/utils/index.d.ts
CHANGED