tabby-ai-assistant 1.0.0 → 1.0.2
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:
|
|
56
|
+
export declare function secureCompare(a: any, b: any): boolean;
|
|
57
57
|
/**
|
|
58
58
|
* 清除敏感数据
|
|
59
59
|
*/
|
package/package.json
CHANGED
|
@@ -180,14 +180,18 @@ export function base64Decode(encodedText: string): string {
|
|
|
180
180
|
/**
|
|
181
181
|
* 安全地比较两个字符串(防止时序攻击)
|
|
182
182
|
*/
|
|
183
|
-
export function secureCompare(a:
|
|
184
|
-
|
|
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 <
|
|
190
|
-
result |=
|
|
193
|
+
for (let i = 0; i < strA.length; i++) {
|
|
194
|
+
result |= strA.charCodeAt(i) ^ strB.charCodeAt(i);
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
return result === 0;
|