fix(whatsapp): write creds.json atomically (#63577)

Merged via squash.

Prepared head SHA: 70ef5b379f
Co-authored-by: OwenYWT <103073962+OwenYWT@users.noreply.github.com>
Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com>
Reviewed-by: @mcaxtr
This commit is contained in:
OwenYWT
2026-04-16 13:44:46 +08:00
committed by GitHub
parent 4af7641350
commit b878d50e0e
5 changed files with 189 additions and 61 deletions

View File

@@ -26,6 +26,10 @@ export type MockBaileysSocket = {
};
export type MockBaileysModule = {
BufferJSON: {
replacer: (key: string, value: unknown) => unknown;
reviver: (key: string, value: unknown) => unknown;
};
DisconnectReason: { loggedOut: number };
extractMessageContent: ReturnType<typeof vi.fn<ExtractMessageContentFn>>;
fetchLatestBaileysVersion: ReturnType<typeof vi.fn<FetchLatestBaileysVersionFn>>;
@@ -148,6 +152,10 @@ export function createMockBaileys(): {
});
const mod: MockBaileysModule = {
BufferJSON: {
replacer: (_key: string, value: unknown) => value,
reviver: (_key: string, value: unknown) => value,
},
DisconnectReason: { loggedOut: 401 },
extractMessageContent: vi.fn<ExtractMessageContentFn>((message) =>
mockExtractMessageContent(message),