@ynhcj/xiaoyi 1.6.0 → 1.7.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/dist/auth.d.ts +2 -1
- package/dist/auth.js +6 -6
- package/dist/websocket.js +1 -1
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { AuthCredentials } from "./types";
|
|
|
6
6
|
export declare class XiaoYiAuth {
|
|
7
7
|
private ak;
|
|
8
8
|
private sk;
|
|
9
|
-
|
|
9
|
+
private agentId;
|
|
10
|
+
constructor(ak: string, sk: string, agentId: string);
|
|
10
11
|
/**
|
|
11
12
|
* Generate authentication credentials with signature
|
|
12
13
|
*/
|
package/dist/auth.js
CHANGED
|
@@ -40,9 +40,10 @@ const crypto = __importStar(require("crypto"));
|
|
|
40
40
|
* Based on: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
|
|
41
41
|
*/
|
|
42
42
|
class XiaoYiAuth {
|
|
43
|
-
constructor(ak, sk) {
|
|
43
|
+
constructor(ak, sk, agentId) {
|
|
44
44
|
this.ak = ak;
|
|
45
45
|
this.sk = sk;
|
|
46
|
+
this.agentId = agentId;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* Generate authentication credentials with signature
|
|
@@ -81,11 +82,10 @@ class XiaoYiAuth {
|
|
|
81
82
|
const credentials = this.generateAuthCredentials();
|
|
82
83
|
return {
|
|
83
84
|
type: "auth",
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
85
|
+
ak: credentials.ak,
|
|
86
|
+
agentId: this.agentId,
|
|
87
|
+
timestamp: credentials.timestamp,
|
|
88
|
+
signature: credentials.signature,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
}
|
package/dist/websocket.js
CHANGED
|
@@ -14,7 +14,7 @@ class XiaoYiWebSocketManager extends events_1.EventEmitter {
|
|
|
14
14
|
this.heartbeatInterval = null;
|
|
15
15
|
this.reconnectTimeout = null;
|
|
16
16
|
this.config = config;
|
|
17
|
-
this.auth = new auth_1.XiaoYiAuth(config.ak, config.sk);
|
|
17
|
+
this.auth = new auth_1.XiaoYiAuth(config.ak, config.sk, config.agentId);
|
|
18
18
|
this.state = {
|
|
19
19
|
connected: false,
|
|
20
20
|
authenticated: false,
|