@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,27 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
-
3
- describe("zca-client runtime loading", () => {
4
- it("does not import zca-js until a session is created", async () => {
5
- vi.clearAllMocks();
6
- let constructedOptions: { logging?: boolean; selfListen?: boolean } | undefined;
7
- function MockZalo(options?: { logging?: boolean; selfListen?: boolean }) {
8
- constructedOptions = options;
9
- }
10
- const runtimeFactory = vi.fn(() => ({
11
- Zalo: MockZalo,
12
- }));
13
-
14
- vi.doMock("zca-js", runtimeFactory);
15
-
16
- const zcaClient = await import("./zca-client.js");
17
- expect(runtimeFactory).not.toHaveBeenCalled();
18
-
19
- await zcaClient.createZalo({ logging: false, selfListen: true });
20
-
21
- expect(runtimeFactory).toHaveBeenCalledTimes(1);
22
- expect(constructedOptions).toEqual({
23
- logging: false,
24
- selfListen: true,
25
- });
26
- });
27
- });
package/src/zca-client.ts DELETED
@@ -1,259 +0,0 @@
1
- import {
2
- LoginQRCallbackEventType,
3
- Reactions,
4
- TextStyle,
5
- ThreadType,
6
- type Style,
7
- } from "./zca-constants.js";
8
-
9
- type ZcaJsRuntime = {
10
- Zalo: unknown;
11
- };
12
- let zcaJsRuntimePromise: Promise<ZcaJsRuntime> | null = null;
13
-
14
- async function loadZcaJsRuntime(): Promise<ZcaJsRuntime> {
15
- // Keep zca-js behind a runtime boundary so bundled metadata/contracts can load
16
- // without resolving its optional WebSocket dependency tree.
17
- zcaJsRuntimePromise ??= import("zca-js").then((mod) => mod as unknown as ZcaJsRuntime);
18
- return await zcaJsRuntimePromise;
19
- }
20
-
21
- export { LoginQRCallbackEventType, Reactions, TextStyle, ThreadType };
22
- export type { Style };
23
-
24
- export type Credentials = {
25
- imei: string;
26
- cookie: unknown;
27
- userAgent: string;
28
- language?: string;
29
- };
30
-
31
- export type User = {
32
- userId: string;
33
- username: string;
34
- displayName: string;
35
- zaloName: string;
36
- avatar: string;
37
- };
38
-
39
- export type GroupInfo = {
40
- groupId: string;
41
- name: string;
42
- totalMember?: number;
43
- memberIds?: unknown[];
44
- currentMems?: Array<{
45
- id?: unknown;
46
- dName?: string;
47
- zaloName?: string;
48
- avatar?: string;
49
- }>;
50
- };
51
-
52
- export type Message = {
53
- type: number;
54
- threadId: string;
55
- isSelf: boolean;
56
- data: Record<string, unknown>;
57
- };
58
-
59
- export type LoginQRCallbackEvent =
60
- | {
61
- type: 0;
62
- data: {
63
- code: string;
64
- image: string;
65
- };
66
- actions: {
67
- saveToFile: (qrPath?: string) => Promise<unknown>;
68
- retry: () => unknown;
69
- abort: () => unknown;
70
- };
71
- }
72
- | {
73
- type: 1;
74
- data: null;
75
- actions: {
76
- retry: () => unknown;
77
- abort: () => unknown;
78
- };
79
- }
80
- | {
81
- type: 2;
82
- data: {
83
- avatar: string;
84
- display_name: string;
85
- };
86
- actions: {
87
- retry: () => unknown;
88
- abort: () => unknown;
89
- };
90
- }
91
- | {
92
- type: 3;
93
- data: {
94
- code: string;
95
- };
96
- actions: {
97
- retry: () => unknown;
98
- abort: () => unknown;
99
- };
100
- }
101
- | {
102
- type: 4;
103
- data: {
104
- cookie: unknown;
105
- imei: string;
106
- userAgent: string;
107
- };
108
- actions: null;
109
- };
110
-
111
- export type Listener = {
112
- on(event: "message", callback: (message: Message) => void): void;
113
- on(event: "error", callback: (error: unknown) => void): void;
114
- on(event: "closed", callback: (code: number, reason: string) => void): void;
115
- off(event: "message", callback: (message: Message) => void): void;
116
- off(event: "error", callback: (error: unknown) => void): void;
117
- off(event: "closed", callback: (code: number, reason: string) => void): void;
118
- start(opts?: { retryOnClose?: boolean }): void;
119
- stop(): void;
120
- };
121
-
122
- type DeliveryEventMessage = {
123
- msgId: string;
124
- cliMsgId: string;
125
- uidFrom: string;
126
- idTo: string;
127
- msgType: string;
128
- st: number;
129
- at: number;
130
- cmd: number;
131
- ts: string | number;
132
- };
133
-
134
- type DeliveryEventMessages = DeliveryEventMessage | DeliveryEventMessage[];
135
-
136
- export type API = {
137
- listener: Listener;
138
- getContext(): {
139
- imei: string;
140
- userAgent: string;
141
- language?: string;
142
- };
143
- getCookie(): {
144
- toJSON(): {
145
- cookies: unknown[];
146
- };
147
- };
148
- fetchAccountInfo(): Promise<User | { profile: User }>;
149
- getAllFriends(): Promise<User[]>;
150
- getOwnId(): string;
151
- getAllGroups(): Promise<{
152
- gridVerMap: Record<string, string>;
153
- }>;
154
- getGroupInfo(groupId: string | string[]): Promise<{
155
- gridInfoMap: Record<string, GroupInfo & { memVerList?: unknown }>;
156
- }>;
157
- getGroupMembersInfo(memberId: string | string[]): Promise<{
158
- profiles: Record<
159
- string,
160
- {
161
- id?: string;
162
- displayName?: string;
163
- zaloName?: string;
164
- avatar?: string;
165
- }
166
- >;
167
- }>;
168
- sendMessage(
169
- message: string | Record<string, unknown>,
170
- threadId: string,
171
- type?: number,
172
- ): Promise<{
173
- msgId?: string | number;
174
- message?: { msgId?: string | number } | null;
175
- attachment?: Array<{ msgId?: string | number }>;
176
- }>;
177
- uploadAttachment(
178
- sources:
179
- | string
180
- | {
181
- data: Buffer;
182
- filename: `${string}.${string}`;
183
- metadata: {
184
- totalSize: number;
185
- width?: number;
186
- height?: number;
187
- };
188
- }
189
- | Array<
190
- | string
191
- | {
192
- data: Buffer;
193
- filename: `${string}.${string}`;
194
- metadata: {
195
- totalSize: number;
196
- width?: number;
197
- height?: number;
198
- };
199
- }
200
- >,
201
- threadId: string,
202
- type?: number,
203
- ): Promise<
204
- Array<{
205
- fileType: "image" | "video" | "others";
206
- fileUrl?: string;
207
- msgId?: string | number;
208
- fileId?: string;
209
- fileName?: string;
210
- }>
211
- >;
212
- sendVoice(
213
- options: {
214
- voiceUrl: string;
215
- ttl?: number;
216
- },
217
- threadId: string,
218
- type?: number,
219
- ): Promise<{ msgId?: string | number }>;
220
- sendLink(
221
- payload: { link: string; msg?: string },
222
- threadId: string,
223
- type?: number,
224
- ): Promise<{ msgId?: string | number }>;
225
- sendTypingEvent(threadId: string, type?: number, destType?: number): Promise<{ status: number }>;
226
- addReaction(
227
- icon: string | { rType: number; source: number; icon: string },
228
- dest: {
229
- data: {
230
- msgId: string;
231
- cliMsgId: string;
232
- };
233
- threadId: string;
234
- type: number;
235
- },
236
- ): Promise<unknown>;
237
- sendDeliveredEvent(
238
- isSeen: boolean,
239
- messages: DeliveryEventMessages,
240
- type?: number,
241
- ): Promise<unknown>;
242
- sendSeenEvent(messages: DeliveryEventMessages, type?: number): Promise<unknown>;
243
- };
244
-
245
- type ZaloCtor = new (options?: { logging?: boolean; selfListen?: boolean }) => {
246
- login(credentials: Credentials): Promise<API>;
247
- loginQR(
248
- options?: { userAgent?: string; language?: string; qrPath?: string },
249
- callback?: (event: LoginQRCallbackEvent) => unknown,
250
- ): Promise<API>;
251
- };
252
-
253
- export async function createZalo(
254
- options?: ConstructorParameters<ZaloCtor>[0],
255
- ): Promise<InstanceType<ZaloCtor>> {
256
- const zcaJs = await loadZcaJsRuntime();
257
- const Zalo = zcaJs.Zalo as ZaloCtor;
258
- return new Zalo(options);
259
- }
@@ -1,55 +0,0 @@
1
- export const ThreadType = {
2
- User: 0,
3
- Group: 1,
4
- } as const;
5
-
6
- export const LoginQRCallbackEventType = {
7
- QRCodeGenerated: 0,
8
- QRCodeExpired: 1,
9
- QRCodeScanned: 2,
10
- QRCodeDeclined: 3,
11
- GotLoginInfo: 4,
12
- } as const;
13
-
14
- export const Reactions = {
15
- HEART: "/-heart",
16
- LIKE: "/-strong",
17
- HAHA: ":>",
18
- WOW: ":o",
19
- CRY: ":-((",
20
- ANGRY: ":-h",
21
- NONE: "",
22
- } as const;
23
-
24
- // Mirror zca-js sendMessage style constants locally because the package root
25
- // typing surface does not consistently expose TextStyle/Style to tsgo.
26
- export const TextStyle = {
27
- Bold: "b",
28
- Italic: "i",
29
- Underline: "u",
30
- StrikeThrough: "s",
31
- Red: "c_db342e",
32
- Orange: "c_f27806",
33
- Yellow: "c_f7b503",
34
- Green: "c_15a85f",
35
- Small: "f_13",
36
- Big: "f_18",
37
- UnorderedList: "lst_1",
38
- OrderedList: "lst_2",
39
- Indent: "ind_$",
40
- } as const;
41
-
42
- type TextStyleValue = (typeof TextStyle)[keyof typeof TextStyle];
43
-
44
- export type Style =
45
- | {
46
- start: number;
47
- len: number;
48
- st: Exclude<TextStyleValue, typeof TextStyle.Indent>;
49
- }
50
- | {
51
- start: number;
52
- len: number;
53
- st: typeof TextStyle.Indent;
54
- indentSize?: number;
55
- };
@@ -1,22 +0,0 @@
1
- declare module "zca-js" {
2
- export const ThreadType: {
3
- User: number;
4
- Group: number;
5
- };
6
-
7
- export const LoginQRCallbackEventType: {
8
- QRCodeGenerated: number;
9
- QRCodeExpired: number;
10
- QRCodeScanned: number;
11
- QRCodeDeclined: number;
12
- GotLoginInfo: number;
13
- };
14
-
15
- export const Reactions: Record<string, string>;
16
-
17
- export class Zalo {
18
- constructor(options?: { logging?: boolean; selfListen?: boolean });
19
- login(credentials: unknown): Promise<unknown>;
20
- loginQR(options?: unknown, callback?: (event: unknown) => unknown): Promise<unknown>;
21
- }
22
- }
package/test-api.ts DELETED
@@ -1,21 +0,0 @@
1
- export { sendMessageZalouser } from "./src/send.js";
2
- export { parseZalouserOutboundTarget } from "./src/session-route.js";
3
- export {
4
- checkZcaAuthenticated,
5
- getZcaUserInfo,
6
- listZalouserAccountIds,
7
- resolveDefaultZalouserAccountId,
8
- resolveZalouserAccountSync,
9
- } from "./src/accounts.js";
10
- export {
11
- checkZaloAuthenticated,
12
- getZaloUserInfo,
13
- listZaloFriendsMatching,
14
- listZaloGroupMembers,
15
- listZaloGroupsMatching,
16
- logoutZaloProfile,
17
- resolveZaloAllowFromEntries,
18
- resolveZaloGroupsByEntries,
19
- startZaloQrLogin,
20
- waitForZaloQrLogin,
21
- } from "./src/zalo-js.js";
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "../tsconfig.package-boundary.base.json",
3
- "compilerOptions": {
4
- "rootDir": "."
5
- },
6
- "include": ["./*.ts", "./src/**/*.ts"],
7
- "exclude": [
8
- "./**/*.test.ts",
9
- "./dist/**",
10
- "./node_modules/**",
11
- "./src/test-support/**",
12
- "./src/**/*test-helpers.ts",
13
- "./src/**/*test-harness.ts",
14
- "./src/**/*test-support.ts"
15
- ]
16
- }