@softtynet/zca-js 2.2.8 → 2.2.9

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 (142) hide show
  1. package/README.md +1 -0
  2. package/dist/apis/clearUnreadFriendRequests.d.ts +2 -0
  3. package/dist/apis/clearUnreadFriendRequests.js +29 -0
  4. package/dist/apis/encryptGids.d.ts +4 -0
  5. package/dist/apis/encryptGids.js +24 -0
  6. package/dist/apis/getAliasListV2.d.ts +10 -0
  7. package/dist/apis/getAliasListV2.js +28 -0
  8. package/dist/apis/getBlockFriends.d.ts +6 -0
  9. package/dist/apis/getBlockFriends.js +28 -0
  10. package/dist/apis/getCloudInfo.d.ts +3 -0
  11. package/dist/apis/getCloudInfo.js +34 -0
  12. package/dist/apis/getCloudSettings.d.ts +10 -0
  13. package/dist/apis/getCloudSettings.js +34 -0
  14. package/dist/apis/getCloudViewerKey.d.ts +5 -0
  15. package/dist/apis/getCloudViewerKey.js +25 -0
  16. package/dist/apis/getConversationMedia.d.ts +26 -0
  17. package/dist/apis/getConversationMedia.js +39 -0
  18. package/dist/apis/getEmojiStatusConfig.d.ts +17 -0
  19. package/dist/apis/getEmojiStatusConfig.js +23 -0
  20. package/dist/apis/getExtraFriendInfo.d.ts +3 -0
  21. package/dist/apis/getExtraFriendInfo.js +31 -0
  22. package/dist/apis/getExtraGroupInfo.d.ts +7 -0
  23. package/dist/apis/getExtraGroupInfo.js +32 -0
  24. package/dist/apis/getFamilyProfile.d.ts +3 -0
  25. package/dist/apis/getFamilyProfile.js +34 -0
  26. package/dist/apis/getFamilyUsage.d.ts +7 -0
  27. package/dist/apis/getFamilyUsage.js +34 -0
  28. package/dist/apis/getFamilyViewerKey.d.ts +5 -0
  29. package/dist/apis/getFamilyViewerKey.js +25 -0
  30. package/dist/apis/getFriendsEmojiStatus.d.ts +17 -0
  31. package/dist/apis/getFriendsEmojiStatus.js +30 -0
  32. package/dist/apis/getGroupCloudMessageJump.d.ts +3 -0
  33. package/dist/apis/getGroupCloudMessageJump.js +46 -0
  34. package/dist/apis/getLastReadContactTab.d.ts +4 -0
  35. package/dist/apis/getLastReadContactTab.js +15 -0
  36. package/dist/apis/getLastSeen.d.ts +11 -0
  37. package/dist/apis/getLastSeen.js +40 -0
  38. package/dist/apis/getLastSeenReaction.d.ts +9 -0
  39. package/dist/apis/getLastSeenReaction.js +28 -0
  40. package/dist/apis/getListPinTopics.d.ts +5 -0
  41. package/dist/apis/getListPinTopics.js +28 -0
  42. package/dist/apis/getMediaStorePreview.d.ts +3 -0
  43. package/dist/apis/getMediaStorePreview.js +31 -0
  44. package/dist/apis/getMiniProfile.d.ts +13 -0
  45. package/dist/apis/getMiniProfile.js +34 -0
  46. package/dist/apis/getPersonalizedStickerList.d.ts +5 -0
  47. package/dist/apis/getPersonalizedStickerList.js +24 -0
  48. package/dist/apis/getPhonebookV2.d.ts +6 -0
  49. package/dist/apis/getPhonebookV2.js +21 -0
  50. package/dist/apis/getProfileRank.d.ts +5 -0
  51. package/dist/apis/getProfileRank.js +25 -0
  52. package/dist/apis/getProfileVerificationStatus.d.ts +5 -0
  53. package/dist/apis/getProfileVerificationStatus.js +20 -0
  54. package/dist/apis/getQuotaCommunity.d.ts +8 -0
  55. package/dist/apis/getQuotaCommunity.js +27 -0
  56. package/dist/apis/getRecentSearchList.d.ts +6 -0
  57. package/dist/apis/getRecentSearchList.js +25 -0
  58. package/dist/apis/getStickerCategoriesV2.d.ts +17 -0
  59. package/dist/apis/getStickerCategoriesV2.js +21 -0
  60. package/dist/apis/getStickerCategoryData.d.ts +3 -0
  61. package/dist/apis/getStickerCategoryData.js +25 -0
  62. package/dist/apis/getStickerHello.d.ts +16 -0
  63. package/dist/apis/getStickerHello.js +34 -0
  64. package/dist/apis/getStickerSuggestKeywords.d.ts +12 -0
  65. package/dist/apis/getStickerSuggestKeywords.js +24 -0
  66. package/dist/apis/getStickerSuggestion.d.ts +12 -0
  67. package/dist/apis/getStickerSuggestion.js +30 -0
  68. package/dist/apis/getUsageMyCloud.d.ts +7 -0
  69. package/dist/apis/getUsageMyCloud.js +34 -0
  70. package/dist/apis/getUsageZCloud.d.ts +11 -0
  71. package/dist/apis/getUsageZCloud.js +34 -0
  72. package/dist/apis/keepAlive.d.ts +2 -1
  73. package/dist/apis/keepAlive.js +5 -3
  74. package/dist/apis/listen.d.ts +13 -0
  75. package/dist/apis/listen.js +10 -0
  76. package/dist/apis/readContactTab.d.ts +2 -0
  77. package/dist/apis/readContactTab.js +26 -0
  78. package/dist/apis/removeConversationMedia.d.ts +8 -0
  79. package/dist/apis/removeConversationMedia.js +30 -0
  80. package/dist/apis/undoMultiMessage.d.ts +9 -0
  81. package/dist/apis/undoMultiMessage.js +46 -0
  82. package/dist/apis/updateRecentSearch.d.ts +11 -0
  83. package/dist/apis/updateRecentSearch.js +41 -0
  84. package/dist/apis/verifyCloudMedia.d.ts +14 -0
  85. package/dist/apis/verifyCloudMedia.js +43 -0
  86. package/dist/apis/voiceToText.d.ts +4 -0
  87. package/dist/apis/voiceToText.js +30 -0
  88. package/dist/apis.d.ts +82 -0
  89. package/dist/apis.js +82 -0
  90. package/dist/cjs/apis/clearUnreadFriendRequests.cjs +34 -0
  91. package/dist/cjs/apis/encryptGids.cjs +29 -0
  92. package/dist/cjs/apis/getAliasListV2.cjs +33 -0
  93. package/dist/cjs/apis/getBlockFriends.cjs +33 -0
  94. package/dist/cjs/apis/getCloudInfo.cjs +39 -0
  95. package/dist/cjs/apis/getCloudSettings.cjs +39 -0
  96. package/dist/cjs/apis/getCloudViewerKey.cjs +30 -0
  97. package/dist/cjs/apis/getConversationMedia.cjs +44 -0
  98. package/dist/cjs/apis/getEmojiStatusConfig.cjs +28 -0
  99. package/dist/cjs/apis/getExtraFriendInfo.cjs +36 -0
  100. package/dist/cjs/apis/getExtraGroupInfo.cjs +37 -0
  101. package/dist/cjs/apis/getFamilyProfile.cjs +39 -0
  102. package/dist/cjs/apis/getFamilyUsage.cjs +39 -0
  103. package/dist/cjs/apis/getFamilyViewerKey.cjs +30 -0
  104. package/dist/cjs/apis/getFriendsEmojiStatus.cjs +35 -0
  105. package/dist/cjs/apis/getGroupCloudMessageJump.cjs +63 -0
  106. package/dist/cjs/apis/getLastReadContactTab.cjs +20 -0
  107. package/dist/cjs/apis/getLastSeen.cjs +45 -0
  108. package/dist/cjs/apis/getLastSeenReaction.cjs +33 -0
  109. package/dist/cjs/apis/getListPinTopics.cjs +33 -0
  110. package/dist/cjs/apis/getMediaStorePreview.cjs +36 -0
  111. package/dist/cjs/apis/getMiniProfile.cjs +39 -0
  112. package/dist/cjs/apis/getPersonalizedStickerList.cjs +29 -0
  113. package/dist/cjs/apis/getPhonebookV2.cjs +26 -0
  114. package/dist/cjs/apis/getProfileRank.cjs +30 -0
  115. package/dist/cjs/apis/getProfileVerificationStatus.cjs +25 -0
  116. package/dist/cjs/apis/getQuotaCommunity.cjs +32 -0
  117. package/dist/cjs/apis/getRecentSearchList.cjs +30 -0
  118. package/dist/cjs/apis/getStickerCategoriesV2.cjs +26 -0
  119. package/dist/cjs/apis/getStickerCategoryData.cjs +30 -0
  120. package/dist/cjs/apis/getStickerHello.cjs +39 -0
  121. package/dist/cjs/apis/getStickerSuggestKeywords.cjs +29 -0
  122. package/dist/cjs/apis/getStickerSuggestion.cjs +35 -0
  123. package/dist/cjs/apis/getUsageMyCloud.cjs +39 -0
  124. package/dist/cjs/apis/getUsageZCloud.cjs +39 -0
  125. package/dist/cjs/apis/keepAlive.cjs +5 -3
  126. package/dist/cjs/apis/listen.cjs +10 -0
  127. package/dist/cjs/apis/readContactTab.cjs +31 -0
  128. package/dist/cjs/apis/removeConversationMedia.cjs +35 -0
  129. package/dist/cjs/apis/undoMultiMessage.cjs +62 -0
  130. package/dist/cjs/apis/updateRecentSearch.cjs +46 -0
  131. package/dist/cjs/apis/verifyCloudMedia.cjs +48 -0
  132. package/dist/cjs/apis/voiceToText.cjs +35 -0
  133. package/dist/cjs/apis.cjs +82 -0
  134. package/dist/cjs/index.cjs +2 -0
  135. package/dist/cjs/utils.cjs +25 -0
  136. package/dist/context.d.ts +4 -0
  137. package/dist/index.d.ts +42 -1
  138. package/dist/index.js +1 -1
  139. package/dist/utils.d.ts +10 -0
  140. package/dist/utils.js +23 -0
  141. package/docs/INTEGRATION_GUIDE_SYNC_AND_CALL.md +110 -0
  142. package/package.json +1 -1
package/README.md CHANGED
@@ -41,6 +41,7 @@ So với phiên bản cộng đồng tiêu chuẩn, **`@softtynet/zca-js`** bổ
41
41
  | **Đồng bộ sao lưu từ Điện thoại (`ZDB4.0`)** | Hỗ trợ trọn vẹn chu trình [`api.requestSyncFromPhone()`](src/apis/requestSyncFromPhone.ts) (`cmd 12000`), [`api.cancelPullMobile()`](src/apis/cancelPullMobile.ts) (`cmd 12700`), sự kiện `sync_event` (`user_confirm`, `syncmsg_info`, `transfer_after_login`), tải gói `.db.crypt` qua [`api.getSyncData()`](src/apis/getSyncData.ts) và giải mã RSA-2048 PKCS#1 v1.5 + AES-256-CBC đa khối 64KB + đọc mục lục SQLite (`parseZdbHeader`). |
42
42
  | **Ánh xạ ID ẩn danh (Noised / Global ID)** | Hỗ trợ [`api.getNoisedIds()`](src/apis/getNoisedIds.ts) (`cmd 12390` kèm cơ chế tự động fallback sang `zwid.api.zalo.me`) và [`api.decryptGids()`](src/apis/decryptGids.ts) (`cmd 12054`) để ánh xạ tên file SQLite `3_<me>_<peer>.db` về User ID / Group ID thật. |
43
43
  | **Gọi Thoại & Gọi Video (Signaling 2 bước)** | Hỗ trợ [`api.sendVoiceCall()`](src/apis/sendVoiceCall.ts) (`cmd 11300` + `11301`), [`api.cancelVoiceCall()`](src/apis/cancelVoiceCall.ts) (`cmd 11305`), [`api.endVoiceCall()`](src/apis/endVoiceCall.ts) (`cmd 11306`) và sự kiện `call_event` chuẩn giao thức C++ `ZaloCall` cho cả **Gọi Thoại (`CallType.Audio = 1`)** lẫn **Gọi Video (`CallType.Video = 3`, H.264)**. |
44
+ | **Hệ sinh thái ZCloud, ZFamily & AI (`26.7.10`)** | Hỗ trợ chuẩn mã hóa `98yS` (AES-256-CBC với 16-byte Random IV) cho ZCloud & ZFamily ([`getCloudViewerKey`](src/apis/getCloudViewerKey.ts), [`getUsageZCloud`](src/apis/getUsageZCloud.ts), [`getUsageMyCloud`](src/apis/getUsageMyCloud.ts), [`getCloudSettings`](src/apis/getCloudSettings.ts), [`getCloudInfo`](src/apis/getCloudInfo.ts), [`getFamilyUsage`](src/apis/getFamilyUsage.ts), [`verifyCloudMedia`](src/apis/verifyCloudMedia.ts), [`getFamilyViewerKey`](src/apis/getFamilyViewerKey.ts), [`getFamilyProfile`](src/apis/getFamilyProfile.ts)), AI chuyển giọng nói thành văn bản [`voiceToText`](src/apis/voiceToText.ts) (`cmd 13394` + `voice2text_event`), Emoji Status ([`getEmojiStatusConfig`](src/apis/getEmojiStatusConfig.ts), [`getFriendsEmojiStatus`](src/apis/getFriendsEmojiStatus.ts)), Kho Lưu Trữ Hội Thoại ([`getConversationMedia`](src/apis/getConversationMedia.ts), [`getMediaStorePreview`](src/apis/getMediaStorePreview.ts), [`removeConversationMedia`](src/apis/removeConversationMedia.ts)), Lịch sử tìm kiếm ([`getRecentSearchList`](src/apis/getRecentSearchList.ts), [`updateRecentSearch`](src/apis/updateRecentSearch.ts)) cùng 25+ API Nhóm, Hồ sơ, Danh bạ & Nhãn dán V2 đã kiểm định Live 100%. |
44
45
  | **Độ ổn định & Bảo vệ bộ nhớ** | Tự động giải phóng bộ nhớ `uploadCallbacks` sau 5 phút trong [`uploadAttachment`](src/apis/uploadAttachment.ts), xử lý phản hồi rỗng hợp lệ (`error_code === 0, data === ""`) và bảo toàn độ chính xác chuỗi UID 19 chữ số. |
45
46
 
46
47
  ---
@@ -0,0 +1,2 @@
1
+ export type ClearUnreadFriendRequestsResponse = Record<string, unknown> | string;
2
+ export declare const clearUnreadFriendRequestsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (uidsSeen?: string[]) => Promise<ClearUnreadFriendRequestsResponse>;
@@ -0,0 +1,29 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const clearUnreadFriendRequestsFactory = apiFactory()((api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/recommendsv2/read-requests`);
5
+ /**
6
+ * Đánh dấu đã xem danh sách lời mời kết bạn chưa đọc (command 12232)
7
+ *
8
+ * @param uidsSeen Danh sách UID đã xem lời mời kết bạn (mặc định `[]`)
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function clearUnreadFriendRequests(uidsSeen = []) {
12
+ if (!uidsSeen || uidsSeen.length === 0) {
13
+ return {};
14
+ }
15
+ const params = {
16
+ uids_seen: uidsSeen,
17
+ };
18
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
19
+ if (!encryptedParams)
20
+ throw new ZaloApiError("Failed to encrypt params");
21
+ const response = await utils.request(serviceURL, {
22
+ method: "POST",
23
+ body: new URLSearchParams({
24
+ params: encryptedParams,
25
+ }),
26
+ });
27
+ return utils.resolve(response);
28
+ };
29
+ });
@@ -0,0 +1,4 @@
1
+ export type EncryptGidsResponse = {
2
+ data: Record<string, string>;
3
+ };
4
+ export declare const encryptGidsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (uids: string[]) => Promise<EncryptGidsResponse>;
@@ -0,0 +1,24 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const encryptGidsFactory = apiFactory()((api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/gid/encrypt`);
5
+ /**
6
+ * Mã hóa danh sách UID thật sang định danh ẩn danh Global Noise ID (`OTDAKO...`) (command 12053)
7
+ *
8
+ * @param uids Mảng chuỗi các UID cần mã hóa
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function encryptGids(uids) {
12
+ if (!Array.isArray(uids) || uids.length === 0) {
13
+ return { data: {} };
14
+ }
15
+ const encryptedParams = utils.encodeAES(JSON.stringify({ noiseUids: uids }));
16
+ if (!encryptedParams) {
17
+ throw new ZaloApiError("Failed to encrypt params");
18
+ }
19
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
20
+ method: "GET",
21
+ });
22
+ return utils.resolve(response);
23
+ };
24
+ });
@@ -0,0 +1,10 @@
1
+ export type AliasItemV2 = {
2
+ userId: string;
3
+ alias: string;
4
+ };
5
+ export type GetAliasListV2Response = {
6
+ items: AliasItemV2[];
7
+ updateTime?: string;
8
+ [key: string]: unknown;
9
+ };
10
+ export declare const getAliasListV2Factory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (page?: number, count?: number) => Promise<GetAliasListV2Response>;
@@ -0,0 +1,28 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getAliasListV2Factory = apiFactory()((api, ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.alias[0]}/api/alias/list/v2`);
5
+ /**
6
+ * Lấy danh sách tên gợi nhớ (Alias) của bạn bè chuẩn V2 có hỗ trợ phân trang (command 12205)
7
+ *
8
+ * @param page Trang cần lấy (mặc định: 1)
9
+ * @param count Số lượng mục mỗi trang (mặc định: 100)
10
+ * @throws {ZaloApiError}
11
+ */
12
+ return async function getAliasListV2(page = 1, count = 100) {
13
+ const params = {
14
+ page,
15
+ count,
16
+ src: -1,
17
+ imei: ctx.imei,
18
+ };
19
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
20
+ if (!encryptedParams) {
21
+ throw new ZaloApiError("Failed to encrypt params");
22
+ }
23
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
24
+ method: "GET",
25
+ });
26
+ return utils.resolve(response);
27
+ };
28
+ });
@@ -0,0 +1,6 @@
1
+ export type GetBlockFriendsResponse = {
2
+ profiles: Record<string, unknown>[];
3
+ version: number;
4
+ hasMore: number;
5
+ };
6
+ export declare const getBlockFriendsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (page?: number, count?: number, avatarSize?: number) => Promise<GetBlockFriendsResponse>;
@@ -0,0 +1,28 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getBlockFriendsFactory = apiFactory()((api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/blocklistv2`);
5
+ /**
6
+ * Lấy danh sách người dùng đang bị chặn chuẩn V2 (command 11429)
7
+ *
8
+ * @param page Trang cần lấy (mặc định: 1)
9
+ * @param count Số lượng mỗi trang (mặc định: 50)
10
+ * @param avatarSize Kích thước ảnh đại diện (mặc định: 120)
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getBlockFriends(page = 1, count = 50, avatarSize = 120) {
14
+ const params = {
15
+ page,
16
+ count,
17
+ avatar: avatarSize,
18
+ };
19
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
20
+ if (!encryptedParams) {
21
+ throw new ZaloApiError("Failed to encrypt params");
22
+ }
23
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
24
+ method: "GET",
25
+ });
26
+ return utils.resolve(response);
27
+ };
28
+ });
@@ -0,0 +1,3 @@
1
+ import type { GetCloudViewerKeyResponse } from "./getCloudViewerKey.js";
2
+ export type GetCloudInfoResponse = Record<string, unknown>;
3
+ export declare const getCloudInfoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (viewerKeyInfo?: GetCloudViewerKeyResponse) => Promise<GetCloudInfoResponse>;
@@ -0,0 +1,34 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory, decryptZCloudAES } from "../utils.js";
3
+ export const getCloudInfoFactory = apiFactory()((api, _ctx, utils) => {
4
+ var _a;
5
+ const baseDomain = ((_a = api.zpwServiceMap.zcloud) === null || _a === void 0 ? void 0 : _a[0]) || "https://zcld.chat.zalo.me";
6
+ const serviceURL = utils.makeURL(`${baseDomain}/zalocloud/cloudinfopcweb/v1/info`);
7
+ /**
8
+ * Lấy thông tin gói thuê bao Zalo Cloud (command 12754)
9
+ *
10
+ * @param viewerKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getCloudViewerKey()`.
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getCloudInfo(viewerKeyInfo) {
14
+ const keyInfo = viewerKeyInfo !== null && viewerKeyInfo !== void 0 ? viewerKeyInfo : (await api.getCloudViewerKey());
15
+ if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
16
+ throw new ZaloApiError("Invalid CloudViewerKey");
17
+ }
18
+ const response = await utils.request(serviceURL, {
19
+ method: "GET",
20
+ headers: {
21
+ "cloud-viewer-key": keyInfo.viewer_key,
22
+ },
23
+ });
24
+ const json = (await response.json());
25
+ if (json.error_code !== 0 && json.error_code !== -904) {
26
+ throw new ZaloApiError(json.error_message || "getCloudInfo failed", json.error_code);
27
+ }
28
+ if (!json.data) {
29
+ return {};
30
+ }
31
+ const decrypted = decryptZCloudAES(json.data, keyInfo.enk);
32
+ return JSON.parse(decrypted);
33
+ };
34
+ });
@@ -0,0 +1,10 @@
1
+ import type { GetCloudViewerKeyResponse } from "./getCloudViewerKey.js";
2
+ export type GetCloudSettingsResponse = {
3
+ cloud_media_file_size_limit: number;
4
+ enable_community: number;
5
+ my_cloud_file_size_limit: number;
6
+ opt_in: number;
7
+ key_export: Record<string, unknown>;
8
+ enable_offload: number;
9
+ };
10
+ export declare const getCloudSettingsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (viewerKeyInfo?: GetCloudViewerKeyResponse) => Promise<GetCloudSettingsResponse>;
@@ -0,0 +1,34 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory, decryptZCloudAES } from "../utils.js";
3
+ export const getCloudSettingsFactory = apiFactory()((api, _ctx, utils) => {
4
+ var _a;
5
+ const baseDomain = ((_a = api.zpwServiceMap.zcloud) === null || _a === void 0 ? void 0 : _a[0]) || "https://zcld.chat.zalo.me";
6
+ const serviceURL = utils.makeURL(`${baseDomain}/cloudmedia/info/pc/v1/cloud-settings`);
7
+ /**
8
+ * Lấy cấu hình giới hạn tệp và cài đặt ZCloud của tài khoản (command 12756)
9
+ *
10
+ * @param viewerKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getCloudViewerKey()`. Nếu không truyền sẽ tự động lấy mới.
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getCloudSettings(viewerKeyInfo) {
14
+ const keyInfo = viewerKeyInfo !== null && viewerKeyInfo !== void 0 ? viewerKeyInfo : (await api.getCloudViewerKey());
15
+ if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
16
+ throw new ZaloApiError("Invalid CloudViewerKey");
17
+ }
18
+ const response = await utils.request(serviceURL, {
19
+ method: "GET",
20
+ headers: {
21
+ "cloud-viewer-key": keyInfo.viewer_key,
22
+ },
23
+ });
24
+ const json = (await response.json());
25
+ if (json.error_code !== 0 && json.error_code !== -904) {
26
+ throw new ZaloApiError(json.error_message || "getCloudSettings failed", json.error_code);
27
+ }
28
+ if (!json.data) {
29
+ throw new ZaloApiError("Empty ZCloud settings data", json.error_code);
30
+ }
31
+ const decrypted = decryptZCloudAES(json.data, keyInfo.enk);
32
+ return JSON.parse(decrypted);
33
+ };
34
+ });
@@ -0,0 +1,5 @@
1
+ export type GetCloudViewerKeyResponse = {
2
+ viewer_key: string;
3
+ enk: string;
4
+ };
5
+ export declare const getCloudViewerKeyFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetCloudViewerKeyResponse>;
@@ -0,0 +1,25 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getCloudViewerKeyFactory = apiFactory()((_api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL("https://wpa.chat.zalo.me/api/getCloudViewerKey");
5
+ /**
6
+ * Lấy cặp khóa phiên (`viewer_key` và khóa giải mã AES-256 `enk`) cho hệ thống ZCloud / MyCloud (command 12741)
7
+ *
8
+ * @throws {ZaloApiError}
9
+ */
10
+ return async function getCloudViewerKey() {
11
+ const response = await utils.request(serviceURL, {
12
+ method: "GET",
13
+ });
14
+ const res = await utils.resolve(response);
15
+ if (typeof res === "string") {
16
+ try {
17
+ return JSON.parse(res);
18
+ }
19
+ catch (_a) {
20
+ throw new ZaloApiError("Failed to parse CloudViewerKey response");
21
+ }
22
+ }
23
+ return res;
24
+ };
25
+ });
@@ -0,0 +1,26 @@
1
+ export type MediaStoreType = "media" | "file" | "link";
2
+ export type GetConversationMediaOptions = {
3
+ groupId?: string;
4
+ threadId?: string;
5
+ mediaType?: MediaStoreType;
6
+ limit?: number;
7
+ lastId?: number | string;
8
+ lastFetchId?: number;
9
+ };
10
+ export type MediaStoreItem = {
11
+ id: number | string;
12
+ type: string;
13
+ title?: string;
14
+ src_url?: string;
15
+ thumb_url?: string;
16
+ previewThumb?: string | null;
17
+ created_time?: number;
18
+ [key: string]: unknown;
19
+ };
20
+ export type GetConversationMediaResponse = {
21
+ items: MediaStoreItem[];
22
+ isLimitPermission: boolean;
23
+ last_id: number | string;
24
+ has_more: number;
25
+ };
26
+ export declare const getConversationMediaFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options: GetConversationMediaOptions) => Promise<GetConversationMediaResponse>;
@@ -0,0 +1,39 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getConversationMediaFactory = apiFactory()((api, ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store[0]}/api/mediastore/list`);
5
+ /**
6
+ * Lấy danh sách Kho Lưu Trữ (Ảnh/Video `"media"`, File `"file"`, hoặc Link `"link"`) trong hội thoại nhóm (command 11841)
7
+ *
8
+ * @param options Tùy chọn truy vấn (`groupId`, `mediaType`, `limit`, `lastId`, `lastFetchId`)
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function getConversationMedia(options) {
12
+ var _a, _b;
13
+ const rawGroupId = options.groupId || options.threadId;
14
+ if (!rawGroupId) {
15
+ throw new ZaloApiError("Missing groupId");
16
+ }
17
+ const groupId = rawGroupId.startsWith("g") ? rawGroupId.slice(1) : rawGroupId;
18
+ const params = {
19
+ media_type: (_a = options.mediaType) !== null && _a !== void 0 ? _a : "media",
20
+ group_id: groupId,
21
+ limit: (_b = options.limit) !== null && _b !== void 0 ? _b : 20,
22
+ imei: ctx.imei,
23
+ };
24
+ if (options.lastId !== undefined) {
25
+ params.last_id = options.lastId;
26
+ }
27
+ if (options.lastFetchId !== undefined && !Number.isNaN(options.lastFetchId)) {
28
+ params.lastFetchId = options.lastFetchId;
29
+ }
30
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
31
+ if (!encryptedParams) {
32
+ throw new ZaloApiError("Failed to encrypt params");
33
+ }
34
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
35
+ method: "GET",
36
+ });
37
+ return utils.resolve(response);
38
+ };
39
+ });
@@ -0,0 +1,17 @@
1
+ export type EmojiStatusItem = {
2
+ id: number;
3
+ caption: {
4
+ vi: string;
5
+ en: string;
6
+ };
7
+ thumb: string;
8
+ full: string;
9
+ };
10
+ export type GetEmojiStatusConfigResponse = {
11
+ expireTime: number;
12
+ config: {
13
+ emojis: EmojiStatusItem[];
14
+ [key: string]: unknown;
15
+ };
16
+ };
17
+ export declare const getEmojiStatusConfigFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (version?: number) => Promise<GetEmojiStatusConfigResponse>;
@@ -0,0 +1,23 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getEmojiStatusConfigFactory = apiFactory()((api, _ctx, utils) => {
4
+ var _a;
5
+ const baseDomain = ((_a = api.zpwServiceMap.emoji_stt) === null || _a === void 0 ? void 0 : _a[0]) || "https://emoji-status.chat.zalo.me";
6
+ const serviceURL = utils.makeURL(`${baseDomain}/api/v1/emoji-status/resource-config`);
7
+ /**
8
+ * Lấy cấu hình và danh sách bộ biểu tượng Trạng thái Emoji (Emoji Status - command 16300)
9
+ *
10
+ * @param version Phiên bản bộ nhớ đệm (mặc định: 0 để lấy đầy đủ danh sách)
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getEmojiStatusConfig(version = 0) {
14
+ const encryptedParams = utils.encodeAES(JSON.stringify({ version }));
15
+ if (!encryptedParams) {
16
+ throw new ZaloApiError("Failed to encrypt params");
17
+ }
18
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
19
+ method: "GET",
20
+ });
21
+ return utils.resolve(response);
22
+ };
23
+ });
@@ -0,0 +1,3 @@
1
+ import type { ExtraContextInfo } from "./getExtraGroupInfo.js";
2
+ export type GetExtraFriendInfoResponse = Record<string, ExtraContextInfo>;
3
+ export declare const getExtraFriendInfoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (friendIds: string[]) => Promise<GetExtraFriendInfoResponse>;
@@ -0,0 +1,31 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getExtraFriendInfoFactory = apiFactory()((api, ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/context/multiget`);
5
+ /**
6
+ * Lấy ngữ cảnh và vai trò mở rộng (ví dụ `role: ["boss"]`) của danh sách bạn bè (command 11442)
7
+ *
8
+ * @param friendIds Mảng UID cần truy vấn
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function getExtraFriendInfo(friendIds) {
12
+ if (!Array.isArray(friendIds) || friendIds.length === 0) {
13
+ return {};
14
+ }
15
+ const params = {
16
+ fids: friendIds,
17
+ imei: ctx.imei,
18
+ };
19
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
20
+ if (!encryptedParams) {
21
+ throw new ZaloApiError("Failed to encrypt params");
22
+ }
23
+ const response = await utils.request(serviceURL, {
24
+ method: "POST",
25
+ body: new URLSearchParams({
26
+ params: encryptedParams,
27
+ }),
28
+ });
29
+ return utils.resolve(response);
30
+ };
31
+ });
@@ -0,0 +1,7 @@
1
+ export type ExtraContextInfo = {
2
+ purpose: string;
3
+ role: string[];
4
+ [key: string]: unknown;
5
+ };
6
+ export type GetExtraGroupInfoResponse = Record<string, ExtraContextInfo>;
7
+ export declare const getExtraGroupInfoFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupIds: string[]) => Promise<GetExtraGroupInfoResponse>;
@@ -0,0 +1,32 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getExtraGroupInfoFactory = apiFactory()((api, ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/userctx/multiget`);
5
+ /**
6
+ * Lấy ngữ cảnh và vai trò mở rộng của người dùng đối với nhiều nhóm (command 12607)
7
+ *
8
+ * @param groupIds Mảng ID các nhóm cần truy vấn
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function getExtraGroupInfo(groupIds) {
12
+ if (!Array.isArray(groupIds) || groupIds.length === 0) {
13
+ return {};
14
+ }
15
+ const cleanGroupIds = groupIds.map((g) => (g.startsWith("g") ? g.slice(1) : g));
16
+ const params = {
17
+ grids: cleanGroupIds,
18
+ imei: ctx.imei,
19
+ };
20
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
21
+ if (!encryptedParams) {
22
+ throw new ZaloApiError("Failed to encrypt params");
23
+ }
24
+ const response = await utils.request(serviceURL, {
25
+ method: "POST",
26
+ body: new URLSearchParams({
27
+ params: encryptedParams,
28
+ }),
29
+ });
30
+ return utils.resolve(response);
31
+ };
32
+ });
@@ -0,0 +1,3 @@
1
+ import type { GetFamilyViewerKeyResponse } from "./getFamilyViewerKey.js";
2
+ export type GetFamilyProfileResponse = Record<string, unknown>;
3
+ export declare const getFamilyProfileFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (familyKeyInfo?: GetFamilyViewerKeyResponse) => Promise<GetFamilyProfileResponse>;
@@ -0,0 +1,34 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory, decryptZCloudAES } from "../utils.js";
3
+ export const getFamilyProfileFactory = apiFactory()((api, _ctx, utils) => {
4
+ var _a;
5
+ const baseDomain = ((_a = api.zpwServiceMap.zfamily) === null || _a === void 0 ? void 0 : _a[0]) || "https://zfml.chat.zalo.me";
6
+ const serviceURL = utils.makeURL(`${baseDomain}/zfamily/pc/family-profile/v1/family`);
7
+ /**
8
+ * Lấy thông tin nhóm gia đình ZFamily (command 12757)
9
+ *
10
+ * @param familyKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getFamilyViewerKey()`.
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getFamilyProfile(familyKeyInfo) {
14
+ const keyInfo = familyKeyInfo !== null && familyKeyInfo !== void 0 ? familyKeyInfo : (await api.getFamilyViewerKey());
15
+ if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
16
+ throw new ZaloApiError("Invalid FamilyViewerKey");
17
+ }
18
+ const response = await utils.request(serviceURL, {
19
+ method: "GET",
20
+ headers: {
21
+ "zfamily-viewer-key": keyInfo.viewer_key,
22
+ },
23
+ });
24
+ const json = (await response.json());
25
+ if (json.error_code !== 0 && json.error_code !== -904) {
26
+ throw new ZaloApiError(json.error_message || "getFamilyProfile failed", json.error_code);
27
+ }
28
+ if (!json.data) {
29
+ return {};
30
+ }
31
+ const decrypted = decryptZCloudAES(json.data, keyInfo.enk);
32
+ return JSON.parse(decrypted);
33
+ };
34
+ });
@@ -0,0 +1,7 @@
1
+ import type { GetCloudViewerKeyResponse } from "./getCloudViewerKey.js";
2
+ export type GetFamilyUsageResponse = {
3
+ usage: number;
4
+ quota: number;
5
+ lastUpdated: number;
6
+ };
7
+ export declare const getFamilyUsageFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (viewerKeyInfo?: GetCloudViewerKeyResponse) => Promise<GetFamilyUsageResponse>;
@@ -0,0 +1,34 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory, decryptZCloudAES } from "../utils.js";
3
+ export const getFamilyUsageFactory = apiFactory()((api, _ctx, utils) => {
4
+ var _a;
5
+ const baseDomain = ((_a = api.zpwServiceMap.zcloud) === null || _a === void 0 ? void 0 : _a[0]) || "https://zcld.chat.zalo.me";
6
+ const serviceURL = utils.makeURL(`${baseDomain}/cloudmedia/info/pc/v1/family-usage`);
7
+ /**
8
+ * Kiểm tra dung lượng sử dụng gói ZCloud Gia đình (Family Usage - command 12758)
9
+ *
10
+ * @param viewerKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getCloudViewerKey()`. Nếu không truyền sẽ tự động lấy mới.
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getFamilyUsage(viewerKeyInfo) {
14
+ const keyInfo = viewerKeyInfo !== null && viewerKeyInfo !== void 0 ? viewerKeyInfo : (await api.getCloudViewerKey());
15
+ if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
16
+ throw new ZaloApiError("Invalid CloudViewerKey");
17
+ }
18
+ const response = await utils.request(serviceURL, {
19
+ method: "GET",
20
+ headers: {
21
+ "cloud-viewer-key": keyInfo.viewer_key,
22
+ },
23
+ });
24
+ const json = (await response.json());
25
+ if (json.error_code !== 0 && json.error_code !== -904) {
26
+ throw new ZaloApiError(json.error_message || "getFamilyUsage failed", json.error_code);
27
+ }
28
+ if (!json.data) {
29
+ throw new ZaloApiError("Empty FamilyUsage data", json.error_code);
30
+ }
31
+ const decrypted = decryptZCloudAES(json.data, keyInfo.enk);
32
+ return JSON.parse(decrypted);
33
+ };
34
+ });
@@ -0,0 +1,5 @@
1
+ export type GetFamilyViewerKeyResponse = {
2
+ viewer_key: string;
3
+ enk: string;
4
+ };
5
+ export declare const getFamilyViewerKeyFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetFamilyViewerKeyResponse>;
@@ -0,0 +1,25 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getFamilyViewerKeyFactory = apiFactory()((_api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL("https://wpa.chat.zalo.me/api/getFamilyViewerKey");
5
+ /**
6
+ * Lấy cặp khóa phiên (`viewer_key` và khóa giải mã AES-256 `enk`) cho gói gia đình ZFamily (command 12759)
7
+ *
8
+ * @throws {ZaloApiError}
9
+ */
10
+ return async function getFamilyViewerKey() {
11
+ const response = await utils.request(serviceURL, {
12
+ method: "GET",
13
+ });
14
+ const res = await utils.resolve(response);
15
+ if (typeof res === "string") {
16
+ try {
17
+ return JSON.parse(res);
18
+ }
19
+ catch (_a) {
20
+ throw new ZaloApiError("Failed to parse FamilyViewerKey response");
21
+ }
22
+ }
23
+ return res;
24
+ };
25
+ });
@@ -0,0 +1,17 @@
1
+ export type GetFriendsEmojiStatusOptions = {
2
+ version?: number;
3
+ fromUid?: string;
4
+ maxEmojiStatusId?: string | number;
5
+ page?: number;
6
+ };
7
+ export type GetFriendsEmojiStatusResponse = {
8
+ expireTime: number;
9
+ emojiStatuses: Record<string, unknown>[];
10
+ version: number;
11
+ type: number;
12
+ maxEmojiStatusId: number;
13
+ loadMore: boolean;
14
+ lastUid: string;
15
+ page: number;
16
+ };
17
+ export declare const getFriendsEmojiStatusFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options?: GetFriendsEmojiStatusOptions) => Promise<GetFriendsEmojiStatusResponse>;
@@ -0,0 +1,30 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getFriendsEmojiStatusFactory = apiFactory()((api, _ctx, utils) => {
4
+ var _a;
5
+ const baseDomain = ((_a = api.zpwServiceMap.emoji_stt) === null || _a === void 0 ? void 0 : _a[0]) || "https://emoji-status.chat.zalo.me";
6
+ const serviceURL = utils.makeURL(`${baseDomain}/api/v1/emoji-status/friends`);
7
+ /**
8
+ * Lấy danh sách trạng thái Emoji (Emoji Status) hiện tại của bạn bè (command 16301)
9
+ *
10
+ * @param options Tùy chọn phân trang (`version`, `fromUid`, `maxEmojiStatusId`, `page`)
11
+ * @throws {ZaloApiError}
12
+ */
13
+ return async function getFriendsEmojiStatus(options = {}) {
14
+ var _a, _b, _c, _d;
15
+ const params = {
16
+ version: (_a = options.version) !== null && _a !== void 0 ? _a : 0,
17
+ fromUid: (_b = options.fromUid) !== null && _b !== void 0 ? _b : "0",
18
+ maxEmojiStatusId: String((_c = options.maxEmojiStatusId) !== null && _c !== void 0 ? _c : "0"),
19
+ page: (_d = options.page) !== null && _d !== void 0 ? _d : 1,
20
+ };
21
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
22
+ if (!encryptedParams) {
23
+ throw new ZaloApiError("Failed to encrypt params");
24
+ }
25
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
26
+ method: "GET",
27
+ });
28
+ return utils.resolve(response);
29
+ };
30
+ });
@@ -0,0 +1,3 @@
1
+ import type { GetGroupChatHistoryResponse } from "./getGroupChatHistory.js";
2
+ export type GetGroupCloudMessageJumpResponse = GetGroupChatHistoryResponse;
3
+ export declare const getGroupCloudMessageJumpFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupId: string, globalMsgId: string | number, count?: number, msgJump?: number, msgIds?: Array<string | number>) => Promise<GetGroupChatHistoryResponse>;