mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2026-04-29 06:24:24 +08:00
Compare commits
4 Commits
12d38aa4b2
...
0ec1ae6276
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ec1ae6276 | ||
|
|
cb0422b8f2 | ||
|
|
e455840ab3 | ||
|
|
19437c7aa1 |
@@ -10,7 +10,7 @@ type ParsedEvent = Record<string, any>;
|
||||
type EventResult = ParsedEvent[];
|
||||
|
||||
// Using a dot as separator since it's not used in Base64
|
||||
const SEPARATOR = ".";
|
||||
const SEPARATOR = "~";
|
||||
|
||||
// Unified crypto utilities for both frontend and backend
|
||||
async function generateKey(
|
||||
@@ -85,7 +85,7 @@ export async function encrypt(
|
||||
|
||||
return [saltBase64, ivBase64, encryptedBase64].join(SEPARATOR);
|
||||
} catch (error) {
|
||||
console.error("[Encryption Error]:", error);
|
||||
// console.error("[Encryption Error]:", error);
|
||||
throw new Error("Failed to encrypt AWS credentials");
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,6 @@ export async function decrypt(
|
||||
const dec = new TextDecoder();
|
||||
return dec.decode(decrypted);
|
||||
} catch (error) {
|
||||
console.error("[Decryption Error]:", error);
|
||||
throw new Error("Failed to decrypt AWS credentials");
|
||||
}
|
||||
}
|
||||
@@ -610,9 +609,18 @@ export function processChunks(
|
||||
chunks.shift();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[Chunk Process Error]:", e);
|
||||
chunks.shift(); // Remove error chunk
|
||||
pendingChunk = null; // Reset pending chunk on error
|
||||
// console.error("[Chunk Process Error]:", e);
|
||||
// chunks.shift(); // Remove error chunk
|
||||
// pendingChunk = null; // Reset pending chunk on error
|
||||
console.warn("Failed to process chunk, attempting recovery");
|
||||
// Attempt to recover by processing the next chunk
|
||||
if (chunks.length > 1) {
|
||||
chunks.shift();
|
||||
pendingChunk = null;
|
||||
} else {
|
||||
// If this is the last chunk, throw to prevent data loss
|
||||
throw new Error("Failed to process final chunk");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user