Browse Source

chore: update

wxyyxc1992 5 years ago
parent
commit
d3f54d1c53

+ 3
- 3
packages/cts-api/dist/cjs/packet.js View File

1
 "use strict";
1
 "use strict";
2
 Object.defineProperty(exports, "__esModule", { value: true });
2
 Object.defineProperty(exports, "__esModule", { value: true });
3
 var utils_1 = require("./utils");
3
 var utils_1 = require("./utils");
4
-var node_int64_1 = require("node-int64");
4
+var Int64 = require("node-int64");
5
 var Packet = (function () {
5
 var Packet = (function () {
6
     function Packet() {
6
     function Packet() {
7
         this.key = 'b8ca9aa66def05ff3f24919274bb4a66';
7
         this.key = 'b8ca9aa66def05ff3f24919274bb4a66';
13
         var bodyLength = body.length;
13
         var bodyLength = body.length;
14
         var buf = new ArrayBuffer(20 + headerLength + bodyLength);
14
         var buf = new ArrayBuffer(20 + headerLength + bodyLength);
15
         var dataView = new DataView(buf);
15
         var dataView = new DataView(buf);
16
-        var nsBuf = new node_int64_1.default(sequence).toBuffer();
16
+        var nsBuf = new Int64(sequence).toBuffer();
17
         dataView.setUint32(0, operator);
17
         dataView.setUint32(0, operator);
18
         dataView.setUint32(12, headerLength);
18
         dataView.setUint32(12, headerLength);
19
         dataView.setUint32(16, bodyLength);
19
         dataView.setUint32(16, bodyLength);
32
     Packet.prototype.unPack = function (data) {
32
     Packet.prototype.unPack = function (data) {
33
         var dataView = new DataView(data);
33
         var dataView = new DataView(data);
34
         this.operator = dataView.getUint32(0, false);
34
         this.operator = dataView.getUint32(0, false);
35
-        this.sequence = new node_int64_1.default(new Uint8Array(dataView.buffer.slice(4, 12))).toNumber();
35
+        this.sequence = new Int64(new Uint8Array(dataView.buffer.slice(4, 12))).toNumber();
36
         this.headerLength = dataView.getUint32(12, false);
36
         this.headerLength = dataView.getUint32(12, false);
37
         this.bodyLength = dataView.getUint32(16, false);
37
         this.bodyLength = dataView.getUint32(16, false);
38
         var header = utils_1.Utils.ab2str(dataView.buffer.slice(20, 20 + this.headerLength));
38
         var header = utils_1.Utils.ab2str(dataView.buffer.slice(20, 20 + this.headerLength));

+ 1
- 1
packages/cts-api/dist/index.js
File diff suppressed because it is too large
View File


+ 4
- 13
packages/cts-api/src/packet.ts View File

1
 import { Utils } from './utils';
1
 import { Utils } from './utils';
2
-import Int64 from 'node-int64';
2
+import * as Int64 from 'node-int64';
3
 
3
 
4
 export class Packet {
4
 export class Packet {
5
   private key: string = 'b8ca9aa66def05ff3f24919274bb4a66';
5
   private key: string = 'b8ca9aa66def05ff3f24919274bb4a66';
10
   public header: string;
10
   public header: string;
11
   public body: string;
11
   public body: string;
12
 
12
 
13
-  public pack(
14
-    operator: number,
15
-    sequence: number,
16
-    header: string,
17
-    body: string,
18
-  ): ArrayBuffer {
13
+  public pack(operator: number, sequence: number, header: string, body: string): ArrayBuffer {
19
     header = Utils.encrypt(header, this.key, this.key);
14
     header = Utils.encrypt(header, this.key, this.key);
20
     body = Utils.encrypt(body, this.key, this.key);
15
     body = Utils.encrypt(body, this.key, this.key);
21
 
16
 
49
     const dataView = new DataView(data);
44
     const dataView = new DataView(data);
50
 
45
 
51
     this.operator = dataView.getUint32(0, false);
46
     this.operator = dataView.getUint32(0, false);
52
-    this.sequence = new Int64(
53
-      new Uint8Array(dataView.buffer.slice(4, 12)),
54
-    ).toNumber();
47
+    this.sequence = new Int64(new Uint8Array(dataView.buffer.slice(4, 12))).toNumber();
55
     this.headerLength = dataView.getUint32(12, false);
48
     this.headerLength = dataView.getUint32(12, false);
56
     this.bodyLength = dataView.getUint32(16, false);
49
     this.bodyLength = dataView.getUint32(16, false);
57
 
50
 
58
-    const header = Utils.ab2str(
59
-      dataView.buffer.slice(20, 20 + this.headerLength),
60
-    );
51
+    const header = Utils.ab2str(dataView.buffer.slice(20, 20 + this.headerLength));
61
     const body = Utils.ab2str(dataView.buffer.slice(20 + this.headerLength));
52
     const body = Utils.ab2str(dataView.buffer.slice(20 + this.headerLength));
62
 
53
 
63
     this.header = Utils.decrypt(header, this.key, this.key);
54
     this.header = Utils.decrypt(header, this.key, this.key);

+ 1
- 0
packages/cts-api/src/types/node-int64.d.ts View File

1
+declare module 'node-int64';

+ 2
- 0
packages/cts-api/types.d.ts View File

12
   const content: string;
12
   const content: string;
13
   export default content;
13
   export default content;
14
 }
14
 }
15
+
16
+declare module 'node-int64';