hunter-open-sdk 2.0.0-beta.14 → 2.0.0-beta.15
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/lib/abilities/reboot/index.js +54 -0
- package/lib/abilities/reboot/worker.js +24 -0
- package/lib/abilities/shutdown/index.js +54 -0
- package/lib/abilities/shutdown/worker.js +24 -0
- package/lib/index.js +5 -1
- package/lib/resources/dll/{libinspectionkit_x64_0.2.1.dll → libinspectionkit_x64_0.3.0.dll} +0 -0
- package/lib/resources/mac/{libinspectionkit_amd64_0.2.1.dylib → libinspectionkit_amd64_0.3.0.dylib} +0 -0
- package/lib/resources/mac/{libinspectionkit_arm64_0.2.1.dylib → libinspectionkit_arm64_0.3.0.dylib} +0 -0
- package/lib/resources/version.online +1 -1
- package/lib/utils/utils.global.js +78 -2
- package/lib/utils/utils.initDll.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reboot = reboot;
|
|
7
|
+
var _webWorker = _interopRequireDefault(require("web-worker"));
|
|
8
|
+
var _url = _interopRequireDefault(require("url"));
|
|
9
|
+
var _utils = require("../../utils/utils.path");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class Reboot {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.initWorker();
|
|
14
|
+
this.initWorkerListener();
|
|
15
|
+
}
|
|
16
|
+
worker = null;
|
|
17
|
+
callback = null;
|
|
18
|
+
exec(params, callback) {
|
|
19
|
+
this.callback = callback;
|
|
20
|
+
this.worker && this.worker.postMessage({
|
|
21
|
+
type: 'reboot',
|
|
22
|
+
params
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
initWorkerListener() {
|
|
26
|
+
this.worker && this.worker.addEventListener('message', event => {
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
data
|
|
30
|
+
} = event.data;
|
|
31
|
+
switch (type) {
|
|
32
|
+
case 'rebootSuccess':
|
|
33
|
+
this.callback(data);
|
|
34
|
+
break;
|
|
35
|
+
case 'rebootFail':
|
|
36
|
+
this.callback(data);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
this.callback = null;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
initWorker() {
|
|
43
|
+
if (!this.worker) {
|
|
44
|
+
const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
|
|
45
|
+
this.worker = new _webWorker.default(workerPath, {
|
|
46
|
+
type: "module"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const entity = new Reboot();
|
|
52
|
+
function reboot(paramStr, callback) {
|
|
53
|
+
entity.exec(paramStr, callback);
|
|
54
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("../../utils/utils.global");
|
|
4
|
+
function onMainMessage(event) {
|
|
5
|
+
const {
|
|
6
|
+
type,
|
|
7
|
+
params
|
|
8
|
+
} = event.data;
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'reboot':
|
|
11
|
+
{
|
|
12
|
+
if (!params) {
|
|
13
|
+
return {
|
|
14
|
+
code: -1,
|
|
15
|
+
message: '【reboot】方法缺少必要参数'
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const res = (0, _utils.rebootCallKit)(params);
|
|
19
|
+
postMessage(res);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
addEventListener('message', onMainMessage);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shutdown = shutdown;
|
|
7
|
+
var _webWorker = _interopRequireDefault(require("web-worker"));
|
|
8
|
+
var _url = _interopRequireDefault(require("url"));
|
|
9
|
+
var _utils = require("../../utils/utils.path");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class Shutdown {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.initWorker();
|
|
14
|
+
this.initWorkerListener();
|
|
15
|
+
}
|
|
16
|
+
worker = null;
|
|
17
|
+
callback = null;
|
|
18
|
+
exec(params, callback) {
|
|
19
|
+
this.callback = callback;
|
|
20
|
+
this.worker && this.worker.postMessage({
|
|
21
|
+
type: 'shutdown',
|
|
22
|
+
params
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
initWorkerListener() {
|
|
26
|
+
this.worker && this.worker.addEventListener('message', event => {
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
data
|
|
30
|
+
} = event.data;
|
|
31
|
+
switch (type) {
|
|
32
|
+
case 'shutdownSuccess':
|
|
33
|
+
this.callback(data);
|
|
34
|
+
break;
|
|
35
|
+
case 'shutdownFail':
|
|
36
|
+
this.callback(data);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
this.callback = null;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
initWorker() {
|
|
43
|
+
if (!this.worker) {
|
|
44
|
+
const workerPath = new _url.default.URL('file://' + (0, _utils.getCurrentEnvPath)(__dirname, './worker.js'));
|
|
45
|
+
this.worker = new _webWorker.default(workerPath, {
|
|
46
|
+
type: "module"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const entity = new Shutdown();
|
|
52
|
+
function shutdown(paramStr, callback) {
|
|
53
|
+
entity.exec(paramStr, callback);
|
|
54
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("../../utils/utils.global");
|
|
4
|
+
function onMainMessage(event) {
|
|
5
|
+
const {
|
|
6
|
+
type,
|
|
7
|
+
params
|
|
8
|
+
} = event.data;
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'shutdown':
|
|
11
|
+
{
|
|
12
|
+
if (!params) {
|
|
13
|
+
return {
|
|
14
|
+
code: -1,
|
|
15
|
+
message: '【shutdown】方法缺少必要参数'
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const res = (0, _utils.shutdownCallKit)(params);
|
|
19
|
+
postMessage(res);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
addEventListener('message', onMainMessage);
|
package/lib/index.js
CHANGED
|
@@ -11,6 +11,8 @@ var _getGeneralReport = require("./abilities/getGeneralReport");
|
|
|
11
11
|
var _erase = require("./abilities/erase");
|
|
12
12
|
var _activate = require("./abilities/activate");
|
|
13
13
|
var _skip = require("./abilities/skip");
|
|
14
|
+
var _reboot = require("./abilities/reboot");
|
|
15
|
+
var _shutdown = require("./abilities/shutdown");
|
|
14
16
|
const Sentry = require('@sentry/browser');
|
|
15
17
|
Sentry.init({
|
|
16
18
|
dsn: 'https://8a5296c59083430fbac0756f56ddbf5d@sentry.zhuanzhuan.com/2300',
|
|
@@ -27,5 +29,7 @@ var _default = exports.default = {
|
|
|
27
29
|
getGeneralReport: _getGeneralReport.getGeneralReport,
|
|
28
30
|
erase: _erase.erase,
|
|
29
31
|
activate: _activate.activate,
|
|
30
|
-
skip: _skip.skip
|
|
32
|
+
skip: _skip.skip,
|
|
33
|
+
reboot: _reboot.reboot,
|
|
34
|
+
shutdown: _shutdown.shutdown
|
|
31
35
|
};
|
|
Binary file
|
package/lib/resources/mac/{libinspectionkit_amd64_0.2.1.dylib → libinspectionkit_amd64_0.3.0.dylib}
RENAMED
|
Binary file
|
package/lib/resources/mac/{libinspectionkit_arm64_0.2.1.dylib → libinspectionkit_arm64_0.3.0.dylib}
RENAMED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.skipCallKit = exports.setGlobalProperty = exports.hasGlobalProperty = exports.getSaaSReportCallKit = exports.getHunterInspectionKit = exports.getGlobalProperty = exports.getGlobalObject = exports.getGeneralReportCallKit = exports.eraseCallKit = exports.deleteGlobalProperty = exports.callHunterInspectionKit = exports.activateCallKit = void 0;
|
|
6
|
+
exports.skipCallKit = exports.shutdownCallKit = exports.setGlobalProperty = exports.rebootCallKit = exports.hasGlobalProperty = exports.getSaaSReportCallKit = exports.getHunterInspectionKit = exports.getGlobalProperty = exports.getGlobalObject = exports.getGeneralReportCallKit = exports.eraseCallKit = exports.deleteGlobalProperty = exports.callHunterInspectionKit = exports.activateCallKit = void 0;
|
|
7
7
|
var _utils = require("../utils/utils.initDll");
|
|
8
8
|
/**
|
|
9
9
|
* 全局对象兼容性处理工具
|
|
@@ -315,4 +315,80 @@ const skipCallKit = paramStr => {
|
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
};
|
|
318
|
-
exports.skipCallKit = skipCallKit;
|
|
318
|
+
exports.skipCallKit = skipCallKit;
|
|
319
|
+
const rebootCallKit = paramStr => {
|
|
320
|
+
const res = callHunterInspectionKit('InspectionKit', paramStr, 'reboot', paramStr);
|
|
321
|
+
if (res) {
|
|
322
|
+
const resObj = JSON.parse(res);
|
|
323
|
+
const {
|
|
324
|
+
Code,
|
|
325
|
+
Data,
|
|
326
|
+
Message
|
|
327
|
+
} = resObj;
|
|
328
|
+
if (Code == 0) {
|
|
329
|
+
return {
|
|
330
|
+
type: 'rebootSuccess',
|
|
331
|
+
data: {
|
|
332
|
+
code: 0,
|
|
333
|
+
data: Data,
|
|
334
|
+
message: '重启设备成功'
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
type: 'rebootFail',
|
|
340
|
+
data: {
|
|
341
|
+
code: -1,
|
|
342
|
+
data: {},
|
|
343
|
+
message: Message || '重启设备失败'
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
type: 'rebootFail',
|
|
349
|
+
data: {
|
|
350
|
+
code: -1,
|
|
351
|
+
data: {},
|
|
352
|
+
message: '重启设备失败'
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
exports.rebootCallKit = rebootCallKit;
|
|
357
|
+
const shutdownCallKit = paramStr => {
|
|
358
|
+
const res = callHunterInspectionKit('InspectionKit', paramStr, 'shutdown', paramStr);
|
|
359
|
+
if (res) {
|
|
360
|
+
const resObj = JSON.parse(res);
|
|
361
|
+
const {
|
|
362
|
+
Code,
|
|
363
|
+
Data,
|
|
364
|
+
Message
|
|
365
|
+
} = resObj;
|
|
366
|
+
if (Code == 0) {
|
|
367
|
+
return {
|
|
368
|
+
type: 'shutdownSuccess',
|
|
369
|
+
data: {
|
|
370
|
+
code: 0,
|
|
371
|
+
data: Data,
|
|
372
|
+
message: '关闭设备成功'
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
type: 'shutdownFail',
|
|
378
|
+
data: {
|
|
379
|
+
code: -1,
|
|
380
|
+
data: {},
|
|
381
|
+
message: Message || '关闭设备失败'
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
return {
|
|
386
|
+
type: 'shutdownFail',
|
|
387
|
+
data: {
|
|
388
|
+
code: -1,
|
|
389
|
+
data: {},
|
|
390
|
+
message: '关闭设备失败'
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
exports.shutdownCallKit = shutdownCallKit;
|
|
@@ -22,7 +22,7 @@ const initHunterInspectionKit = () => {
|
|
|
22
22
|
|
|
23
23
|
// 读取本地sdk的version
|
|
24
24
|
const versionPath = _path.default.resolve(__dirname, '../resources/version.online');
|
|
25
|
-
const version = _fs.default.readFileSync(versionPath, 'utf-8');
|
|
25
|
+
const version = _fs.default.readFileSync(versionPath, 'utf-8').trim();
|
|
26
26
|
if ((0, _utils.isMac)()) {
|
|
27
27
|
if ((0, _utils.isArm64)()) {
|
|
28
28
|
dllPath = _path.default.resolve(__dirname, `../resources/mac/libinspectionkit_arm64_${version}.dylib`);
|