@kodelyth/zalouser 2026.5.42 → 2026.6.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.
Files changed (71) hide show
  1. package/klaw.plugin.json +286 -3
  2. package/package.json +19 -6
  3. package/api.ts +0 -9
  4. package/channel-plugin-api.ts +0 -3
  5. package/contract-api.ts +0 -2
  6. package/doctor-contract-api.ts +0 -1
  7. package/index.ts +0 -34
  8. package/runtime-api.ts +0 -62
  9. package/secret-contract-api.ts +0 -4
  10. package/setup-entry.ts +0 -9
  11. package/setup-plugin-api.ts +0 -2
  12. package/src/accounts.runtime.ts +0 -1
  13. package/src/accounts.test-mocks.ts +0 -14
  14. package/src/accounts.test.ts +0 -298
  15. package/src/accounts.ts +0 -136
  16. package/src/channel-api.ts +0 -16
  17. package/src/channel.adapters.ts +0 -432
  18. package/src/channel.directory.test.ts +0 -59
  19. package/src/channel.runtime.ts +0 -12
  20. package/src/channel.sendpayload.test.ts +0 -311
  21. package/src/channel.setup.test.ts +0 -30
  22. package/src/channel.setup.ts +0 -12
  23. package/src/channel.test.ts +0 -424
  24. package/src/channel.ts +0 -221
  25. package/src/config-schema.ts +0 -33
  26. package/src/directory.ts +0 -54
  27. package/src/doctor-contract.ts +0 -156
  28. package/src/doctor.test.ts +0 -87
  29. package/src/doctor.ts +0 -37
  30. package/src/group-policy.test.ts +0 -61
  31. package/src/group-policy.ts +0 -83
  32. package/src/message-sid.test.ts +0 -66
  33. package/src/message-sid.ts +0 -80
  34. package/src/monitor.account-scope.test.ts +0 -122
  35. package/src/monitor.group-gating.test.ts +0 -967
  36. package/src/monitor.send-mocks.ts +0 -20
  37. package/src/monitor.ts +0 -1057
  38. package/src/probe.test.ts +0 -60
  39. package/src/probe.ts +0 -35
  40. package/src/qr-temp-file.ts +0 -19
  41. package/src/reaction.test.ts +0 -19
  42. package/src/reaction.ts +0 -32
  43. package/src/runtime.ts +0 -9
  44. package/src/security-audit.test.ts +0 -83
  45. package/src/security-audit.ts +0 -71
  46. package/src/send-receipt.ts +0 -31
  47. package/src/send.test.ts +0 -424
  48. package/src/send.ts +0 -280
  49. package/src/session-route.ts +0 -121
  50. package/src/setup-core.ts +0 -36
  51. package/src/setup-surface.test.ts +0 -367
  52. package/src/setup-surface.ts +0 -481
  53. package/src/setup-test-helpers.ts +0 -42
  54. package/src/shared.ts +0 -92
  55. package/src/status-issues.test.ts +0 -31
  56. package/src/status-issues.ts +0 -55
  57. package/src/test-helpers.ts +0 -26
  58. package/src/text-styles.test.ts +0 -203
  59. package/src/text-styles.ts +0 -540
  60. package/src/tool.test.ts +0 -212
  61. package/src/tool.ts +0 -200
  62. package/src/types.ts +0 -127
  63. package/src/zalo-js.credentials.test.ts +0 -465
  64. package/src/zalo-js.test-mocks.ts +0 -89
  65. package/src/zalo-js.ts +0 -1889
  66. package/src/zca-client.test.ts +0 -27
  67. package/src/zca-client.ts +0 -259
  68. package/src/zca-constants.ts +0 -55
  69. package/src/zca-js-exports.d.ts +0 -22
  70. package/test-api.ts +0 -21
  71. package/tsconfig.json +0 -16
@@ -1,465 +0,0 @@
1
- import {
2
- lstat,
3
- mkdir,
4
- mkdtemp,
5
- readFile,
6
- rm,
7
- stat,
8
- symlink,
9
- utimes,
10
- writeFile,
11
- } from "node:fs/promises";
12
- import os from "node:os";
13
- import path from "node:path";
14
- import { withEnvAsync } from "klaw/plugin-sdk/test-env";
15
- import { beforeEach, describe, expect, it, vi } from "vitest";
16
- import type { API, Credentials, LoginQRCallbackEvent } from "./zca-client.js";
17
- import { LoginQRCallbackEventType } from "./zca-constants.js";
18
-
19
- const createZaloMock = vi.hoisted(() => vi.fn());
20
- const ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u;
21
-
22
- vi.mock("./zca-client.js", () => ({
23
- createZalo: createZaloMock,
24
- TextStyle: { Indent: 9 },
25
- }));
26
-
27
- import {
28
- checkZaloAuthenticated,
29
- listZaloFriends,
30
- sendZaloLink,
31
- sendZaloReaction,
32
- startZaloQrLogin,
33
- waitForZaloQrLogin,
34
- } from "./zalo-js.js";
35
-
36
- type StoredCredentialFile = {
37
- imei: string;
38
- cookie: Credentials["cookie"];
39
- userAgent: string;
40
- language?: string;
41
- createdAt?: string;
42
- lastUsedAt?: string;
43
- };
44
-
45
- function credentialPath(stateDir: string, profile: string): string {
46
- const trimmed = profile.trim().toLowerCase();
47
- const filename =
48
- !trimmed || trimmed === "default"
49
- ? "credentials.json"
50
- : `credentials-${encodeURIComponent(trimmed)}.json`;
51
- return path.join(stateDir, "credentials", "zalouser", filename);
52
- }
53
-
54
- async function readStoredCredentials(
55
- stateDir: string,
56
- profile: string,
57
- ): Promise<StoredCredentialFile> {
58
- return JSON.parse(
59
- await readFile(credentialPath(stateDir, profile), "utf8"),
60
- ) as StoredCredentialFile;
61
- }
62
-
63
- function createMockApi(params: {
64
- imei: string;
65
- userAgent: string;
66
- language?: string;
67
- cookies: unknown[] | (() => unknown[]);
68
- getAllFriends?: API["getAllFriends"];
69
- }): API {
70
- return {
71
- getContext: () => ({
72
- imei: params.imei,
73
- userAgent: params.userAgent,
74
- language: params.language,
75
- }),
76
- getCookie: () => ({
77
- toJSON: () => ({
78
- cookies: typeof params.cookies === "function" ? params.cookies() : params.cookies,
79
- }),
80
- }),
81
- fetchAccountInfo: async () => ({
82
- userId: "user-1",
83
- username: "user-1",
84
- displayName: "Zalo User",
85
- zaloName: "Zalo User",
86
- avatar: "",
87
- }),
88
- getAllFriends: params.getAllFriends ?? vi.fn(async () => []),
89
- listener: {
90
- on: vi.fn(),
91
- off: vi.fn(),
92
- start: vi.fn(),
93
- stop: vi.fn(),
94
- },
95
- } as unknown as API;
96
- }
97
-
98
- describe("zalouser credential persistence", () => {
99
- beforeEach(() => {
100
- createZaloMock.mockReset();
101
- });
102
-
103
- it("persists the final API cookie jar after QR login", async () => {
104
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
105
- const profile = "qr-refresh";
106
- const callbackCookie = [{ key: "zpsid", value: "callback", domain: "chat.zalo.me" }];
107
- const refreshedCookie = [{ key: "zpsid", value: "refreshed", domain: "chat.zalo.me" }];
108
- const api = createMockApi({
109
- imei: "api-imei",
110
- userAgent: "api-user-agent",
111
- language: "vi",
112
- cookies: refreshedCookie,
113
- });
114
-
115
- createZaloMock.mockResolvedValueOnce({
116
- loginQR: async (_options: unknown, callback?: (event: LoginQRCallbackEvent) => unknown) => {
117
- callback?.({
118
- type: LoginQRCallbackEventType.QRCodeGenerated,
119
- data: {
120
- code: "qr-code",
121
- image: "data:image/png;base64,abc123",
122
- },
123
- actions: {
124
- saveToFile: vi.fn(async () => undefined),
125
- retry: vi.fn(),
126
- abort: vi.fn(),
127
- },
128
- });
129
- callback?.({
130
- type: LoginQRCallbackEventType.GotLoginInfo,
131
- data: {
132
- cookie: callbackCookie,
133
- imei: "callback-imei",
134
- userAgent: "callback-user-agent",
135
- },
136
- actions: null,
137
- });
138
- return api;
139
- },
140
- });
141
-
142
- try {
143
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
144
- await startZaloQrLogin({ profile, timeoutMs: 1000 });
145
-
146
- const loginResult = await waitForZaloQrLogin({ profile, timeoutMs: 1000 });
147
- expect(loginResult.connected).toBe(true);
148
-
149
- const stored = await readStoredCredentials(stateDir, profile);
150
- expect(stored.imei).toBe("api-imei");
151
- expect(stored.userAgent).toBe("api-user-agent");
152
- expect(stored.language).toBe("vi");
153
- expect(stored.cookie).toEqual(refreshedCookie);
154
- });
155
- } finally {
156
- await rm(stateDir, { recursive: true, force: true });
157
- }
158
- });
159
-
160
- it("rewrites restored sessions with cookies refreshed by zca-js login", async () => {
161
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
162
- const profile = "restore-refresh";
163
- const storedCookie = [{ key: "zpsid", value: "stored", domain: "chat.zalo.me" }];
164
- const refreshedCookie = [{ key: "zpsid", value: "refreshed", domain: "chat.zalo.me" }];
165
- const filePath = credentialPath(stateDir, profile);
166
- await mkdir(path.dirname(filePath), { recursive: true });
167
- await writeFile(
168
- filePath,
169
- JSON.stringify(
170
- {
171
- imei: "stored-imei",
172
- cookie: storedCookie,
173
- userAgent: "stored-user-agent",
174
- createdAt: "2026-04-01T00:00:00.000Z",
175
- },
176
- null,
177
- 2,
178
- ),
179
- );
180
-
181
- const api = createMockApi({
182
- imei: "stored-imei",
183
- userAgent: "stored-user-agent",
184
- language: "vi",
185
- cookies: refreshedCookie,
186
- });
187
- const login = vi.fn(async () => api);
188
- createZaloMock.mockResolvedValueOnce({ login });
189
-
190
- try {
191
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
192
- await expect(checkZaloAuthenticated(profile)).resolves.toBe(true);
193
-
194
- expect(login).toHaveBeenCalledWith({
195
- imei: "stored-imei",
196
- cookie: storedCookie,
197
- userAgent: "stored-user-agent",
198
- language: undefined,
199
- });
200
- const stored = await readStoredCredentials(stateDir, profile);
201
- expect(stored.cookie).toEqual(refreshedCookie);
202
- expect(stored.createdAt).toBe("2026-04-01T00:00:00.000Z");
203
- expect(stored.lastUsedAt).toMatch(ISO_TIMESTAMP_RE);
204
- });
205
- } finally {
206
- await rm(stateDir, { recursive: true, force: true });
207
- }
208
- });
209
-
210
- it("persists cookie changes after a successful API call", async () => {
211
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
212
- const profile = "api-refresh";
213
- const storedCookie: unknown[] = [{ key: "zpsid", value: "stored", domain: "chat.zalo.me" }];
214
- const loginCookie: unknown[] = [{ key: "zpsid", value: "login", domain: "chat.zalo.me" }];
215
- const refreshedCookie: unknown[] = [
216
- { key: "zpsid", value: "api-refreshed", domain: "chat.zalo.me" },
217
- ];
218
- const filePath = credentialPath(stateDir, profile);
219
- await mkdir(path.dirname(filePath), { recursive: true });
220
- await writeFile(
221
- filePath,
222
- JSON.stringify(
223
- {
224
- imei: "stored-imei",
225
- cookie: storedCookie,
226
- userAgent: "stored-user-agent",
227
- createdAt: "2026-04-01T00:00:00.000Z",
228
- },
229
- null,
230
- 2,
231
- ),
232
- );
233
-
234
- let currentCookie = loginCookie;
235
- const api = createMockApi({
236
- imei: "stored-imei",
237
- userAgent: "stored-user-agent",
238
- language: "vi",
239
- cookies: () => currentCookie,
240
- getAllFriends: vi.fn(async () => {
241
- currentCookie = refreshedCookie;
242
- return [
243
- {
244
- userId: "friend-1",
245
- username: "friend-1",
246
- displayName: "Friend One",
247
- zaloName: "Friend One",
248
- avatar: "",
249
- },
250
- ];
251
- }),
252
- });
253
- createZaloMock.mockResolvedValueOnce({ login: vi.fn(async () => api) });
254
-
255
- try {
256
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
257
- await expect(listZaloFriends(profile)).resolves.toEqual([
258
- {
259
- userId: "friend-1",
260
- displayName: "Friend One",
261
- avatar: undefined,
262
- },
263
- ]);
264
-
265
- const stored = await readStoredCredentials(stateDir, profile);
266
- expect(stored.cookie).toEqual(refreshedCookie);
267
- expect(stored.createdAt).toBe("2026-04-01T00:00:00.000Z");
268
- expect(stored.lastUsedAt).toMatch(ISO_TIMESTAMP_RE);
269
- });
270
- } finally {
271
- await rm(stateDir, { recursive: true, force: true });
272
- }
273
- });
274
-
275
- it("does not rewrite credentials when the live cookie jar only reorders cookies", async () => {
276
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
277
- const profile = "api-stable";
278
- const cookieA: unknown[] = [
279
- { key: "zpsid", value: "same", domain: "chat.zalo.me" },
280
- { key: "zpw", value: "same-secondary", domain: "chat.zalo.me" },
281
- ];
282
- const cookieB = [...cookieA].toReversed();
283
- const filePath = credentialPath(stateDir, profile);
284
- await mkdir(path.dirname(filePath), { recursive: true });
285
- await writeFile(
286
- filePath,
287
- JSON.stringify(
288
- {
289
- imei: "stored-imei",
290
- cookie: cookieA,
291
- userAgent: "stored-user-agent",
292
- createdAt: "2026-04-01T00:00:00.000Z",
293
- },
294
- null,
295
- 2,
296
- ),
297
- );
298
-
299
- let currentCookie = cookieA;
300
- const api = createMockApi({
301
- imei: "stored-imei",
302
- userAgent: "stored-user-agent",
303
- language: "vi",
304
- cookies: () => currentCookie,
305
- getAllFriends: vi.fn(async () => []),
306
- });
307
- createZaloMock.mockResolvedValueOnce({ login: vi.fn(async () => api) });
308
-
309
- try {
310
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
311
- await expect(listZaloFriends(profile)).resolves.toStrictEqual([]);
312
- const firstRaw = await readFile(filePath, "utf8");
313
- const stableMtime = new Date("2026-04-01T00:00:10.000Z");
314
- await utimes(filePath, stableMtime, stableMtime);
315
- const firstMtimeMs = (await stat(filePath)).mtimeMs;
316
-
317
- currentCookie = cookieB;
318
-
319
- await expect(listZaloFriends(profile)).resolves.toStrictEqual([]);
320
- expect(await readFile(filePath, "utf8")).toBe(firstRaw);
321
- expect((await stat(filePath)).mtimeMs).toBe(firstMtimeMs);
322
- });
323
- } finally {
324
- await rm(stateDir, { recursive: true, force: true });
325
- }
326
- });
327
-
328
- function expectMissingSessionResult(result: { ok: boolean; error?: string }) {
329
- expect(result.ok).toBe(false);
330
- expect(result.error).toContain("No saved Zalo session");
331
- }
332
-
333
- it("keeps reaction sends non-throwing when session restore fails", async () => {
334
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
335
-
336
- try {
337
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
338
- const result = await sendZaloReaction({
339
- profile: "missing-session",
340
- threadId: "thread-1",
341
- msgId: "msg-1",
342
- cliMsgId: "cli-1",
343
- emoji: "like",
344
- });
345
- expectMissingSessionResult(result);
346
- });
347
- } finally {
348
- await rm(stateDir, { recursive: true, force: true });
349
- }
350
- });
351
-
352
- it("keeps link sends non-throwing when session restore fails", async () => {
353
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
354
-
355
- try {
356
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
357
- const result = await sendZaloLink("thread-1", "https://example.com", {
358
- profile: "missing-session",
359
- });
360
- expectMissingSessionResult(result);
361
- });
362
- } finally {
363
- await rm(stateDir, { recursive: true, force: true });
364
- }
365
- });
366
-
367
- it.skipIf(process.platform === "win32")(
368
- "writes credentials with private permissions",
369
- async () => {
370
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
371
- const profile = "private-mode";
372
- const api = createMockApi({
373
- imei: "api-imei",
374
- userAgent: "api-user-agent",
375
- cookies: [{ key: "zpsid", value: "private", domain: "chat.zalo.me" }],
376
- });
377
-
378
- createZaloMock.mockResolvedValueOnce({
379
- loginQR: async (_options: unknown, callback?: (event: LoginQRCallbackEvent) => unknown) => {
380
- callback?.({
381
- type: LoginQRCallbackEventType.QRCodeGenerated,
382
- data: {
383
- code: "qr-code",
384
- image: "data:image/png;base64,abc123",
385
- },
386
- actions: {
387
- saveToFile: vi.fn(async () => undefined),
388
- retry: vi.fn(),
389
- abort: vi.fn(),
390
- },
391
- });
392
- return api;
393
- },
394
- });
395
-
396
- try {
397
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
398
- await startZaloQrLogin({ profile, timeoutMs: 1000 });
399
- const loginResult = await waitForZaloQrLogin({ profile, timeoutMs: 1000 });
400
- expect(loginResult.connected).toBe(true);
401
-
402
- const filePath = credentialPath(stateDir, profile);
403
- const dirMode = (await stat(path.dirname(filePath))).mode & 0o777;
404
- const fileMode = (await stat(filePath)).mode & 0o777;
405
- expect(dirMode).toBe(0o700);
406
- expect(fileMode).toBe(0o600);
407
- });
408
- } finally {
409
- await rm(stateDir, { recursive: true, force: true });
410
- }
411
- },
412
- );
413
-
414
- it.skipIf(process.platform === "win32")(
415
- "refuses to write credentials through a symlinked file",
416
- async () => {
417
- const stateDir = await mkdtemp(path.join(os.tmpdir(), "klaw-zalouser-credentials-"));
418
- const profile = "symlink-target";
419
- const filePath = credentialPath(stateDir, profile);
420
- const targetPath = path.join(stateDir, "outside.json");
421
- const api = createMockApi({
422
- imei: "api-imei",
423
- userAgent: "api-user-agent",
424
- cookies: [{ key: "zpsid", value: "symlink", domain: "chat.zalo.me" }],
425
- });
426
-
427
- await mkdir(path.dirname(filePath), { recursive: true });
428
- await writeFile(targetPath, "sentinel", "utf8");
429
- await symlink(targetPath, filePath);
430
-
431
- createZaloMock.mockResolvedValueOnce({
432
- loginQR: async (_options: unknown, callback?: (event: LoginQRCallbackEvent) => unknown) => {
433
- callback?.({
434
- type: LoginQRCallbackEventType.QRCodeGenerated,
435
- data: {
436
- code: "qr-code",
437
- image: "data:image/png;base64,abc123",
438
- },
439
- actions: {
440
- saveToFile: vi.fn(async () => undefined),
441
- retry: vi.fn(),
442
- abort: vi.fn(),
443
- },
444
- });
445
- return api;
446
- },
447
- });
448
-
449
- try {
450
- await withEnvAsync({ KLAW_STATE_DIR: stateDir }, async () => {
451
- const started = await startZaloQrLogin({ profile, timeoutMs: 1000 });
452
- const waited = await waitForZaloQrLogin({ profile, timeoutMs: 1000 });
453
- expect(`${started.message} ${waited.message}`).toMatch(
454
- /Refusing to write Zalo credentials to symlinked path|private store target must be a regular file/,
455
- );
456
- });
457
-
458
- expect(await readFile(targetPath, "utf8")).toBe("sentinel");
459
- expect((await lstat(filePath)).isSymbolicLink()).toBe(true);
460
- } finally {
461
- await rm(stateDir, { recursive: true, force: true });
462
- }
463
- },
464
- );
465
- });
@@ -1,89 +0,0 @@
1
- import { vi, type Mock } from "vitest";
2
-
3
- type ZaloJsModule = typeof import("./zalo-js.js");
4
- type ZaloJsMocks = {
5
- checkZaloAuthenticatedMock: Mock<ZaloJsModule["checkZaloAuthenticated"]>;
6
- getZaloUserInfoMock: Mock<ZaloJsModule["getZaloUserInfo"]>;
7
- listZaloFriendsMock: Mock<ZaloJsModule["listZaloFriends"]>;
8
- listZaloFriendsMatchingMock: Mock<ZaloJsModule["listZaloFriendsMatching"]>;
9
- listZaloGroupMembersMock: Mock<ZaloJsModule["listZaloGroupMembers"]>;
10
- listZaloGroupsMock: Mock<ZaloJsModule["listZaloGroups"]>;
11
- listZaloGroupsMatchingMock: Mock<ZaloJsModule["listZaloGroupsMatching"]>;
12
- logoutZaloProfileMock: Mock<ZaloJsModule["logoutZaloProfile"]>;
13
- resolveZaloAllowFromEntriesMock: Mock<ZaloJsModule["resolveZaloAllowFromEntries"]>;
14
- resolveZaloGroupContextMock: Mock<ZaloJsModule["resolveZaloGroupContext"]>;
15
- resolveZaloGroupsByEntriesMock: Mock<ZaloJsModule["resolveZaloGroupsByEntries"]>;
16
- startZaloListenerMock: Mock<ZaloJsModule["startZaloListener"]>;
17
- startZaloQrLoginMock: Mock<ZaloJsModule["startZaloQrLogin"]>;
18
- waitForZaloQrLoginMock: Mock<ZaloJsModule["waitForZaloQrLogin"]>;
19
- };
20
-
21
- const zaloJsMocks = vi.hoisted(
22
- (): ZaloJsMocks => ({
23
- checkZaloAuthenticatedMock: vi.fn(async () => false),
24
- getZaloUserInfoMock: vi.fn(async () => null),
25
- listZaloFriendsMock: vi.fn(async () => []),
26
- listZaloFriendsMatchingMock: vi.fn(async () => []),
27
- listZaloGroupMembersMock: vi.fn(async () => []),
28
- listZaloGroupsMock: vi.fn(async () => []),
29
- listZaloGroupsMatchingMock: vi.fn(async () => []),
30
- logoutZaloProfileMock: vi.fn(async () => ({
31
- cleared: true,
32
- loggedOut: true,
33
- message: "Logged out and cleared local session.",
34
- })),
35
- resolveZaloAllowFromEntriesMock: vi.fn(async ({ entries }: { entries: string[] }) =>
36
- entries.map((entry) => ({ input: entry, resolved: true, id: entry, note: undefined })),
37
- ),
38
- resolveZaloGroupContextMock: vi.fn(async (_profile, groupId) => ({
39
- groupId,
40
- name: undefined,
41
- members: [],
42
- })),
43
- resolveZaloGroupsByEntriesMock: vi.fn(async ({ entries }: { entries: string[] }) =>
44
- entries.map((entry) => ({ input: entry, resolved: true, id: entry, note: undefined })),
45
- ),
46
- startZaloListenerMock: vi.fn(async () => ({ stop: vi.fn() })),
47
- startZaloQrLoginMock: vi.fn(async () => ({
48
- message: "qr pending",
49
- qrDataUrl: undefined,
50
- })),
51
- waitForZaloQrLoginMock: vi.fn(async () => ({
52
- connected: false,
53
- message: "login pending",
54
- })),
55
- }),
56
- );
57
-
58
- export const checkZaloAuthenticatedMock = zaloJsMocks.checkZaloAuthenticatedMock;
59
- export const getZaloUserInfoMock = zaloJsMocks.getZaloUserInfoMock;
60
- export const listZaloFriendsMock = zaloJsMocks.listZaloFriendsMock;
61
- export const listZaloFriendsMatchingMock = zaloJsMocks.listZaloFriendsMatchingMock;
62
- export const listZaloGroupMembersMock = zaloJsMocks.listZaloGroupMembersMock;
63
- export const listZaloGroupsMock = zaloJsMocks.listZaloGroupsMock;
64
- export const listZaloGroupsMatchingMock = zaloJsMocks.listZaloGroupsMatchingMock;
65
- export const logoutZaloProfileMock = zaloJsMocks.logoutZaloProfileMock;
66
- export const resolveZaloAllowFromEntriesMock = zaloJsMocks.resolveZaloAllowFromEntriesMock;
67
- export const resolveZaloGroupContextMock = zaloJsMocks.resolveZaloGroupContextMock;
68
- export const resolveZaloGroupsByEntriesMock = zaloJsMocks.resolveZaloGroupsByEntriesMock;
69
- export const startZaloListenerMock: Mock<ZaloJsModule["startZaloListener"]> =
70
- zaloJsMocks.startZaloListenerMock;
71
- export const startZaloQrLoginMock = zaloJsMocks.startZaloQrLoginMock;
72
- export const waitForZaloQrLoginMock = zaloJsMocks.waitForZaloQrLoginMock;
73
-
74
- vi.mock("./zalo-js.js", () => ({
75
- checkZaloAuthenticated: checkZaloAuthenticatedMock,
76
- getZaloUserInfo: getZaloUserInfoMock,
77
- listZaloFriends: listZaloFriendsMock,
78
- listZaloFriendsMatching: listZaloFriendsMatchingMock,
79
- listZaloGroupMembers: listZaloGroupMembersMock,
80
- listZaloGroups: listZaloGroupsMock,
81
- listZaloGroupsMatching: listZaloGroupsMatchingMock,
82
- logoutZaloProfile: logoutZaloProfileMock,
83
- resolveZaloAllowFromEntries: resolveZaloAllowFromEntriesMock,
84
- resolveZaloGroupContext: resolveZaloGroupContextMock,
85
- resolveZaloGroupsByEntries: resolveZaloGroupsByEntriesMock,
86
- startZaloListener: startZaloListenerMock,
87
- startZaloQrLogin: startZaloQrLoginMock,
88
- waitForZaloQrLogin: waitForZaloQrLoginMock,
89
- }));