tabby-ai-assistant 1.0.0 → 1.0.3

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.
@@ -53,7 +53,7 @@ export declare function base64Decode(encodedText: string): string;
53
53
  /**
54
54
  * 安全地比较两个字符串(防止时序攻击)
55
55
  */
56
- export declare function secureCompare(a: string, b: string): boolean;
56
+ export declare function secureCompare(a: any, b: any): boolean;
57
57
  /**
58
58
  * 清除敏感数据
59
59
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabby-ai-assistant",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Tabby终端AI助手插件 - 支持多AI提供商(OpenAI、Anthropic、Minimax、GLM)",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -180,14 +180,24 @@ export function base64Decode(encodedText: string): string {
180
180
  /**
181
181
  * 安全地比较两个字符串(防止时序攻击)
182
182
  */
183
- export function secureCompare(a: string, b: string): boolean {
184
- if (a.length !== b.length) {
183
+ export function secureCompare(a: any, b: any): boolean {
184
+ // 确保输入是字符串
185
+ const strA = a != null ? String(a) : '';
186
+ const strB = b != null ? String(b) : '';
187
+
188
+ if (strA.length !== strB.length) {
185
189
  return false;
186
190
  }
187
191
 
188
192
  let result = 0;
189
- for (let i = 0; i < a.length; i++) {
190
- result |= a.charCodeAt(i) ^ b.charCodeAt(i);
193
+ for (let i = 0; i < strA.length; i++) {
194
+ const codeA = strA.charCodeAt(i);
195
+ const codeB = strB.charCodeAt(i);
196
+ // 确保charCodeAt返回有效值
197
+ if (typeof codeA !== 'number' || typeof codeB !== 'number') {
198
+ return false;
199
+ }
200
+ result |= codeA ^ codeB;
191
201
  }
192
202
 
193
203
  return result === 0;