gamerpc 7.0.0 → 7.1.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/package.json +53 -52
- package/src/gameConn.js +13 -2
- package/test/game/auth.js +1 -1
- package/test/game/crm.js +1 -1
- package/test/game/mgr.js +80 -0
package/package.json
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gamerpc",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"author": "bookmansoft <ceo@920.cc>",
|
|
5
|
-
"contributors": [
|
|
6
|
-
"bookmansoft <ceo@920.cc>"
|
|
7
|
-
],
|
|
8
|
-
"license": "ISC",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"vallnet",
|
|
11
|
-
"bitcoin",
|
|
12
|
-
"gamegold",
|
|
13
|
-
"gamecloud",
|
|
14
|
-
"gameserver",
|
|
15
|
-
"gamelogic",
|
|
16
|
-
"cryptcurrency",
|
|
17
|
-
"rpc",
|
|
18
|
-
"cloud"
|
|
19
|
-
],
|
|
20
|
-
"description": "connector for gamecloud & gamegold",
|
|
21
|
-
"main": "index.js",
|
|
22
|
-
"scripts": {
|
|
23
|
-
"test": "mocha",
|
|
24
|
-
"build": "cross-env NODE_ENV=production webpack ./src/index.js --mode=production"
|
|
25
|
-
},
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/bookmansoft/gamegoldtoolkit.git"
|
|
29
|
-
},
|
|
30
|
-
"bugs": {
|
|
31
|
-
"url": "https://github.com/bookmansoft/gamegoldtoolkit/issues"
|
|
32
|
-
},
|
|
33
|
-
"homepage": "https://github.com/bookmansoft/gamegoldtoolkit#readme",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"create-hmac": "1.1.7",
|
|
36
|
-
"elliptic": "^6.5.4",
|
|
37
|
-
"node-fetch": "^2.6.1",
|
|
38
|
-
"socket.io-client": "^4.2.0"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"babel
|
|
43
|
-
"babel-
|
|
44
|
-
"babel-
|
|
45
|
-
"babel-
|
|
46
|
-
"babel-preset-
|
|
47
|
-
"babel-preset-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"webpack
|
|
51
|
-
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gamerpc",
|
|
3
|
+
"version": "7.1.0",
|
|
4
|
+
"author": "bookmansoft <ceo@920.cc>",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"bookmansoft <ceo@920.cc>"
|
|
7
|
+
],
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vallnet",
|
|
11
|
+
"bitcoin",
|
|
12
|
+
"gamegold",
|
|
13
|
+
"gamecloud",
|
|
14
|
+
"gameserver",
|
|
15
|
+
"gamelogic",
|
|
16
|
+
"cryptcurrency",
|
|
17
|
+
"rpc",
|
|
18
|
+
"cloud"
|
|
19
|
+
],
|
|
20
|
+
"description": "connector for gamecloud & gamegold",
|
|
21
|
+
"main": "index.js",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "mocha",
|
|
24
|
+
"build": "set NODE_OPTIONS=--openssl-legacy-provider & cross-env NODE_ENV=production webpack ./src/index.js --mode=production"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/bookmansoft/gamegoldtoolkit.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/bookmansoft/gamegoldtoolkit/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/bookmansoft/gamegoldtoolkit#readme",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"create-hmac": "1.1.7",
|
|
36
|
+
"elliptic": "^6.5.4",
|
|
37
|
+
"node-fetch": "^2.6.1",
|
|
38
|
+
"socket.io-client": "^4.2.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"mocha": "^10.2.0",
|
|
42
|
+
"babel": "^6.23.0",
|
|
43
|
+
"babel-core": "^6.26.3",
|
|
44
|
+
"babel-loader": "^7.1.5",
|
|
45
|
+
"babel-plugin-transform-runtime": "^6.23.0",
|
|
46
|
+
"babel-preset-env": "^1.7.0",
|
|
47
|
+
"babel-preset-es2015": "^6.24.1",
|
|
48
|
+
"babel-preset-stage-2": "^6.24.1",
|
|
49
|
+
"cross-env": "^5.2.0",
|
|
50
|
+
"webpack": "^4.46.0",
|
|
51
|
+
"webpack-cli": "^3.3.2"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/gameConn.js
CHANGED
|
@@ -127,7 +127,7 @@ class Remote {
|
|
|
127
127
|
async getSign() {
|
|
128
128
|
console.log('gameconn: getSign');
|
|
129
129
|
//此处根据实际需要,发起了基于HTTP请求的认证访问,和本身创建时指定的通讯模式无关。
|
|
130
|
-
let router = this.userInfo.
|
|
130
|
+
let router = this.userInfo.openid.split('.')[0]; //openid一般由代表验证模式的前缀,加上代表节点类型的后缀组成, 获取签名接口的路由路径默认等于其前缀
|
|
131
131
|
let msg = await this.getRequest({}, router);
|
|
132
132
|
|
|
133
133
|
//客户端从模拟网关取得了签名集
|
|
@@ -252,8 +252,19 @@ class Remote {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
if(options.domain) {
|
|
255
|
-
let authmode = options.
|
|
255
|
+
let authmode = options.openid.split('.')[0];
|
|
256
256
|
switch(authmode) {
|
|
257
|
+
case 'bxs': { //新增一种验证模式
|
|
258
|
+
this.setUserInfo({
|
|
259
|
+
domain: options.domain, //认证模式
|
|
260
|
+
openid: options.openid, //用户证书
|
|
261
|
+
openkey: options.openkey, //中间证书,经由Auth服务器转换成 openid 下发给客户端
|
|
262
|
+
auth: options.auth, //验证信息
|
|
263
|
+
}, CommStatus.reqLb);
|
|
264
|
+
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
|
|
257
268
|
case 'authwx': {
|
|
258
269
|
this.setUserInfo({
|
|
259
270
|
domain: options.domain, //认证模式
|
package/test/game/auth.js
CHANGED
|
@@ -32,7 +32,7 @@ let phone_wx = ((Math.random() * 100000000) | 0).toString();
|
|
|
32
32
|
//用于验证后期绑定成功的用户证书缓存变量
|
|
33
33
|
let authUser = '';
|
|
34
34
|
|
|
35
|
-
describe
|
|
35
|
+
describe('钱包注册登录测试', () => {
|
|
36
36
|
it('用户注册并登录 - 使用两阶段认证模式', async () => {
|
|
37
37
|
//执行登录操作,通过配置对象传入用户信息,并指定签证方式为两阶段认证
|
|
38
38
|
let ret = await remote.init(/*初始化连接器,只保留原始配置信息*/).login({
|
package/test/game/crm.js
CHANGED
|
@@ -22,7 +22,7 @@ let username = `${(Math.random()*1000000)|0}@vallnet.cn`;
|
|
|
22
22
|
let password = crypto.createHash("sha1").update(((Math.random()*1000000)|0).toString() + salt).digest("hex");
|
|
23
23
|
let mobilephone = `139${((Math.random()*100000000)|0).toString()}`;
|
|
24
24
|
|
|
25
|
-
describe
|
|
25
|
+
describe('CRM注册登录', () => {
|
|
26
26
|
it('用户注册 - 通过两阶段认证模式实现', async () => {
|
|
27
27
|
//当用户点击'获取验证码'时执行如下流程:
|
|
28
28
|
let ret = await remote.init(/*初始化连接器,只保留原始配置信息*/).login({
|
package/test/game/mgr.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 联机单元测试:远程管理
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const assert = require('assert')
|
|
6
|
+
|
|
7
|
+
//引入游戏云连接器,创建连接器对象
|
|
8
|
+
const {gameconn} = require('../../src/')
|
|
9
|
+
const remote = new gameconn({
|
|
10
|
+
"UrlHead": "http", //协议选择: http/https
|
|
11
|
+
"webserver": {
|
|
12
|
+
//注意:如果需要负载均衡,这里一般指定负载均衡服务器地址,否则直接填写业务主机地址
|
|
13
|
+
"host": "127.0.0.1", //远程主机地址
|
|
14
|
+
"authPort": 9601, //签证主机端口
|
|
15
|
+
"port": 9901 //远程主机端口
|
|
16
|
+
},
|
|
17
|
+
}).setFetch(require('node-fetch')); //设置node环境下兼容的fetch函数
|
|
18
|
+
|
|
19
|
+
//切换为长连模式
|
|
20
|
+
//remote.setmode(remote.CommMode.ws);
|
|
21
|
+
|
|
22
|
+
//这里需要填充管理员登录信息
|
|
23
|
+
let admin = {
|
|
24
|
+
openid: '',
|
|
25
|
+
openkey: '',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('远程管理', () => {
|
|
29
|
+
it.skip('执行索引服远程指令 remote.printInfo', async () => {
|
|
30
|
+
await remote.init(/*初始化连接器,只保留原始配置信息*/).login({
|
|
31
|
+
domain: 'CoreOfIndex',
|
|
32
|
+
openid: admin.openid,
|
|
33
|
+
openkey: admin.openkey,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
let msg = await remote.fetching({func: "remote.printInfo"});
|
|
37
|
+
console.log(msg);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it.skip('透过索引服执行业务服远程指令 remote.command printInfo', async () => {
|
|
41
|
+
await remote.init(/*初始化连接器,只保留原始配置信息*/).login({
|
|
42
|
+
domain: 'CoreOfIndex',
|
|
43
|
+
openid: admin.openid,
|
|
44
|
+
openkey: admin.openkey,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let msg = await remote.fetching({func: "remote.command", data: ['printInfo', 'CoreOfChickIOS', '1']});
|
|
48
|
+
console.log(msg);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('模拟用户注册并登录', async () => {
|
|
52
|
+
//执行登录操作,通过配置对象传入用户信息,并指定签证方式为两阶段认证
|
|
53
|
+
let auth = {
|
|
54
|
+
cpId: 'c376af60-cab5-11ed-90e8-25399b14218a',
|
|
55
|
+
addr: '10000000',
|
|
56
|
+
name: 'bookman',
|
|
57
|
+
bonus: '',
|
|
58
|
+
time: Date.now(),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//需要正确填充 auth.sign, 此处采用模拟命令填充, 注意命令 testSign 只在测试模式下开启
|
|
62
|
+
await remote.init().login({
|
|
63
|
+
domain: 'CoreOfIndex',
|
|
64
|
+
openid: admin.openid,
|
|
65
|
+
openkey: admin.openkey,
|
|
66
|
+
});
|
|
67
|
+
let msg = await remote.fetching({func: "remote.command", data: ['testSign', 'CoreOfChickIOS', '1', auth]});
|
|
68
|
+
auth.sign = msg['CoreOfChickIOS.1'].sign;
|
|
69
|
+
|
|
70
|
+
let ret = await remote.init().login({
|
|
71
|
+
domain: 'CoreOfChickIOS', //登录域
|
|
72
|
+
openid: `bxs.${auth.addr}`, //用户登录标识,含验证方式
|
|
73
|
+
auth,
|
|
74
|
+
});
|
|
75
|
+
if(!!ret) {
|
|
76
|
+
ret = await remote.fetching({func: "test.echo"});
|
|
77
|
+
assert(ret.code == 0);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|