@ynhcj/xiaoyi 2.1.3 → 2.1.5

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 CHANGED
@@ -2,6 +2,8 @@ import { AuthCredentials } from "./types";
2
2
  /**
3
3
  * Generate authentication signature using AK/SK mechanism
4
4
  * Based on: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
5
+ *
6
+ * Signature format: Base64(HMAC-SHA256(secretKey, ts))
5
7
  */
6
8
  export declare class XiaoYiAuth {
7
9
  private ak;
@@ -14,7 +16,9 @@ export declare class XiaoYiAuth {
14
16
  generateAuthCredentials(): AuthCredentials;
15
17
  /**
16
18
  * Generate HMAC-SHA256 signature
17
- * Format: HMAC-SHA256(SK, "ak={AK}&timestamp={TIMESTAMP}")
19
+ * Format: Base64(HMAC-SHA256(secretKey, ts))
20
+ * Reference: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
21
+ * @param timestamp - Timestamp as string (e.g., "1514764800000")
18
22
  */
19
23
  private generateSignature;
20
24
  /**
package/dist/auth.js CHANGED
@@ -38,6 +38,8 @@ const crypto = __importStar(require("crypto"));
38
38
  /**
39
39
  * Generate authentication signature using AK/SK mechanism
40
40
  * Based on: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
41
+ *
42
+ * Signature format: Base64(HMAC-SHA256(secretKey, ts))
41
43
  */
42
44
  class XiaoYiAuth {
43
45
  constructor(ak, sk, agentId) {
@@ -50,7 +52,7 @@ class XiaoYiAuth {
50
52
  */
51
53
  generateAuthCredentials() {
52
54
  const timestamp = Date.now();
53
- const signature = this.generateSignature(timestamp);
55
+ const signature = this.generateSignature(timestamp.toString());
54
56
  return {
55
57
  ak: this.ak,
56
58
  sk: this.sk,
@@ -60,19 +62,23 @@ class XiaoYiAuth {
60
62
  }
61
63
  /**
62
64
  * Generate HMAC-SHA256 signature
63
- * Format: HMAC-SHA256(SK, "ak={AK}&timestamp={TIMESTAMP}")
65
+ * Format: Base64(HMAC-SHA256(secretKey, ts))
66
+ * Reference: https://developer.huawei.com/consumer/cn/doc/service/pushmessage-0000002505761436
67
+ * @param timestamp - Timestamp as string (e.g., "1514764800000")
64
68
  */
65
69
  generateSignature(timestamp) {
66
- const stringToSign = `ak=${this.ak}&timestamp=${timestamp}`;
70
+ // HMAC-SHA256(secretKey, ts)
67
71
  const hmac = crypto.createHmac("sha256", this.sk);
68
- hmac.update(stringToSign);
69
- return hmac.digest("hex");
72
+ hmac.update(timestamp);
73
+ const digest = hmac.digest();
74
+ // Base64 encode
75
+ return digest.toString("base64");
70
76
  }
71
77
  /**
72
78
  * Verify if credentials are valid
73
79
  */
74
80
  verifyCredentials(credentials) {
75
- const expectedSignature = this.generateSignature(credentials.timestamp);
81
+ const expectedSignature = this.generateSignature(credentials.timestamp.toString());
76
82
  return credentials.signature === expectedSignature;
77
83
  }
78
84
  /**
@@ -80,7 +86,7 @@ class XiaoYiAuth {
80
86
  */
81
87
  generateAuthHeaders() {
82
88
  const timestamp = Date.now();
83
- const signature = this.generateSignature(timestamp);
89
+ const signature = this.generateSignature(timestamp.toString());
84
90
  return {
85
91
  "x-access-key": this.ak,
86
92
  "x-sign": signature,
package/dist/websocket.js CHANGED
@@ -137,6 +137,13 @@ class XiaoYiWebSocketManager extends events_1.EventEmitter {
137
137
  taskId: requestId,
138
138
  msgDetail: JSON.stringify(jsonRpcResponse),
139
139
  };
140
+ console.log("\n[CLEAR] Sending clearContext response:");
141
+ console.log(` msgType: ${message.msgType}`);
142
+ console.log(` agentId: ${message.agentId}`);
143
+ console.log(` sessionId: ${message.sessionId}`);
144
+ console.log(` taskId: ${message.taskId}`);
145
+ console.log(` msgDetail: ${message.msgDetail}`);
146
+ console.log("");
140
147
  this.sendMessage(message);
141
148
  }
142
149
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "XiaoYi channel plugin for OpenClaw",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",