@softtynet/zca-js 2.2.7 → 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 (147) hide show
  1. package/README.md +160 -179
  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/update.cjs +8 -6
  136. package/dist/cjs/utils.cjs +25 -0
  137. package/dist/context.d.ts +4 -0
  138. package/dist/index.d.ts +42 -1
  139. package/dist/index.js +1 -1
  140. package/dist/update.js +8 -6
  141. package/dist/utils.d.ts +10 -0
  142. package/dist/utils.js +23 -0
  143. package/docs/INTEGRATION_GUIDE_SYNC_AND_CALL.md +110 -0
  144. package/package.json +12 -9
  145. package/CODE_OF_CONDUCT.md +0 -163
  146. package/CONTRIBUTING.md +0 -470
  147. package/SECURITY.md +0 -83
@@ -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>;
@@ -0,0 +1,46 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { GroupMessage } from "../models/index.js";
3
+ import { apiFactory } from "../utils.js";
4
+ export const getGroupCloudMessageJumpFactory = apiFactory()((api, ctx, utils) => {
5
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_cloud_message[0]}/api/cm/rgetv2`);
6
+ /**
7
+ * Nhảy tới vị trí một tin nhắn nhóm cụ thể trên Zalo Cloud Message và lấy ngữ cảnh xung quanh (command 12508)
8
+ *
9
+ * @param groupId ID nhóm
10
+ * @param globalMsgId ID tin nhắn toàn cục cần nhảy tới
11
+ * @param count Số lượng tin nhắn ngữ cảnh cần tải (mặc định `20`)
12
+ * @param msgJump Cờ nhảy tin nhắn (mặc định `1`)
13
+ * @param msgIds Danh sách msgId bổ sung (mặc định `[]`)
14
+ * @throws {ZaloApiError}
15
+ */
16
+ return async function getGroupCloudMessageJump(groupId, globalMsgId, count = 20, msgJump = 1, msgIds = []) {
17
+ if (!groupId)
18
+ throw new ZaloApiError("Missing groupId");
19
+ if (groupId.startsWith("g"))
20
+ groupId = groupId.slice(1);
21
+ const params = {
22
+ groupId,
23
+ globalMsgId: String(globalMsgId),
24
+ count: Math.min(Math.max(count, 1), 50),
25
+ msgJump,
26
+ msgIds,
27
+ src: 3,
28
+ };
29
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
30
+ if (!encryptedParams)
31
+ throw new ZaloApiError("Failed to encrypt params");
32
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams, nretry: 0 }), {
33
+ method: "GET",
34
+ });
35
+ const page = await utils.resolve(response, (result) => {
36
+ let data = result.data;
37
+ if (typeof data === "string") {
38
+ data = JSON.parse(data);
39
+ }
40
+ return data;
41
+ });
42
+ const rawMsgs = Array.isArray(page === null || page === void 0 ? void 0 : page.groupMsgs) ? page.groupMsgs : [];
43
+ const groupMsgs = rawMsgs.map((data) => new GroupMessage(ctx.uid, data));
44
+ return Object.assign({}, page || {}, { groupMsgs });
45
+ };
46
+ });
@@ -0,0 +1,4 @@
1
+ export type GetLastReadContactTabResponse = {
2
+ ts: number;
3
+ };
4
+ export declare const getLastReadContactTabFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetLastReadContactTabResponse>;
@@ -0,0 +1,15 @@
1
+ import { apiFactory } from "../utils.js";
2
+ export const getLastReadContactTabFactory = apiFactory()((api, _ctx, utils) => {
3
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/last-read-contact-tab`);
4
+ /**
5
+ * Lấy dấu thời gian lần cuối đọc tab Danh bạ (command 12230)
6
+ *
7
+ * @throws {ZaloApiError}
8
+ */
9
+ return async function getLastReadContactTab() {
10
+ const response = await utils.request(serviceURL, {
11
+ method: "GET",
12
+ });
13
+ return utils.resolve(response);
14
+ };
15
+ });
@@ -0,0 +1,11 @@
1
+ export type GetLastSeenOptions = {
2
+ groupIds?: string[];
3
+ userIds?: string[];
4
+ };
5
+ export type GetLastSeenResponse = {
6
+ clearUnreadInfo?: Record<string, unknown>[];
7
+ data?: string;
8
+ status?: number;
9
+ [key: string]: unknown;
10
+ };
11
+ export declare const getLastSeenFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options?: GetLastSeenOptions) => Promise<GetLastSeenResponse>;
@@ -0,0 +1,40 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getLastSeenFactory = apiFactory()((api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/preloadconvers/get-last-seen`);
5
+ /**
6
+ * Lấy thông tin trạng thái đã xem cuối cùng của danh sách nhóm và cá nhân (command 12009)
7
+ *
8
+ * @param options Danh sách ID nhóm (`groupIds`) và UID cá nhân (`userIds`)
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function getLastSeen(options = {}) {
12
+ var _a, _b;
13
+ const group = ((_a = options.groupIds) !== null && _a !== void 0 ? _a : []).map((g) => (g.startsWith("g") ? g.slice(1) : g));
14
+ const oneone = (_b = options.userIds) !== null && _b !== void 0 ? _b : [];
15
+ const params = {
16
+ param: JSON.stringify({ group, oneone }),
17
+ };
18
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
19
+ if (!encryptedParams) {
20
+ throw new ZaloApiError("Failed to encrypt params");
21
+ }
22
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
23
+ method: "GET",
24
+ });
25
+ return utils.resolve(response, (result) => {
26
+ var _a;
27
+ const raw = result.data;
28
+ if (raw && typeof raw.data === "string") {
29
+ try {
30
+ const inner = JSON.parse(raw.data);
31
+ return ((_a = inner === null || inner === void 0 ? void 0 : inner.data) !== null && _a !== void 0 ? _a : inner);
32
+ }
33
+ catch (_b) {
34
+ return raw;
35
+ }
36
+ }
37
+ return raw;
38
+ });
39
+ };
40
+ });
@@ -0,0 +1,9 @@
1
+ export type GetLastSeenReactionOptions = {
2
+ groupIds?: string[];
3
+ userIds?: string[];
4
+ };
5
+ export type GetLastSeenReactionResponse = {
6
+ clearUnreadInfo: Record<string, unknown>[];
7
+ [key: string]: unknown;
8
+ };
9
+ export declare const getLastSeenReactionFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options?: GetLastSeenReactionOptions) => Promise<GetLastSeenReactionResponse>;
@@ -0,0 +1,28 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getLastSeenReactionFactory = apiFactory()((api, _ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.reaction[0]}/api/react/gLastSn`);
5
+ /**
6
+ * Lấy trạng thái đã xem cảm xúc (Reaction) cuối cùng của danh sách nhóm và cá nhân (command 12450)
7
+ *
8
+ * @param options Danh sách ID nhóm (`groupIds`) và UID cá nhân (`userIds`)
9
+ * @throws {ZaloApiError}
10
+ */
11
+ return async function getLastSeenReaction(options = {}) {
12
+ var _a, _b;
13
+ const group = ((_a = options.groupIds) !== null && _a !== void 0 ? _a : []).map((g) => (g.startsWith("g") ? g.slice(1) : g));
14
+ const oneone = (_b = options.userIds) !== null && _b !== void 0 ? _b : [];
15
+ const params = {
16
+ group,
17
+ oneone,
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,5 @@
1
+ export type GetListPinTopicsResponse = {
2
+ items: unknown[];
3
+ version: number;
4
+ };
5
+ export declare const getListPinTopicsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupId: string, boardVersion?: number) => Promise<GetListPinTopicsResponse>;
@@ -0,0 +1,28 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { apiFactory } from "../utils.js";
3
+ export const getListPinTopicsFactory = apiFactory()((api, ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/pin/list`);
5
+ /**
6
+ * Lấy danh sách chủ đề / tin nhắn đã ghim trong bảng tin nhóm (command 12001)
7
+ *
8
+ * @param groupId ID nhóm
9
+ * @param boardVersion Phiên bản bảng ghim hiện tại (mặc định `0`)
10
+ * @throws {ZaloApiError}
11
+ */
12
+ return async function getListPinTopics(groupId, boardVersion = 0) {
13
+ const params = {
14
+ groupId,
15
+ boardVersion,
16
+ imei: ctx.imei,
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(utils.makeURL(serviceURL, {
22
+ params: encryptedParams,
23
+ }), {
24
+ method: "GET",
25
+ });
26
+ return utils.resolve(response);
27
+ };
28
+ });
@@ -0,0 +1,3 @@
1
+ import type { MediaStoreItem } from "./getConversationMedia.js";
2
+ export type GetMediaStorePreviewResponse = MediaStoreItem[];
3
+ export declare const getMediaStorePreviewFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupId: string, limit?: number) => Promise<GetMediaStorePreviewResponse>;